Skip to content

Commit a0752e8

Browse files
feat: Add OAuth token encryption and decryption functions (#79)
* Add @types/node as a dev dependency * Add encryption module * Export from index * Change crypto import * Move to new package * Undo embed-sdk dev dependency * Update pnpm-lock * Update readme * Another readme revision * Update function definitions * Crypto import * Clean up tsup.config.js * Add changeset
1 parent ef862b2 commit a0752e8

File tree

11 files changed

+641
-3
lines changed

11 files changed

+641
-3
lines changed

.changeset/friendly-files-train.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sigmacomputing/node-embed-sdk": minor
3+
---
4+
5+
Add OAuth token encryption utils for JWT embeds
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** @type {import("eslint").Linter.Config} */
2+
module.exports = {
3+
root: true,
4+
extends: ["@sigmacomputing/eslint-config/react-internal.js"],
5+
parser: "@typescript-eslint/parser",
6+
parserOptions: {
7+
project: "./tsconfig.lint.json",
8+
tsconfigRootDir: __dirname,
9+
},
10+
};

packages/node-embed-sdk/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Sigma Node.js Embed SDK
2+
3+
This package provides Node.js utilities for working with Sigma Computing's Embed API.
4+
5+
## Getting Started
6+
7+
To use the node-embed-sdk in your project, you can install it using your node package manager.
8+
9+
**Using npm:**
10+
11+
```code
12+
npm install @sigmacomputing/node-embed-sdk
13+
```
14+
15+
**yarn:**
16+
17+
```code
18+
yarn add @sigmacomputing/node-embed-sdk
19+
```
20+
21+
**pnpm:**
22+
23+
```code
24+
pnpm add @sigmacomputing/node-embed-sdk
25+
```
26+
27+
## Features
28+
29+
### Token Encryption and Decryption
30+
31+
The SDK provides utilities for encrypting and decrypting OAuth tokens using AES-256-GCM encryption:
32+
33+
```typescript
34+
import { encrypt, decrypt } from '@sigmacomputing/node-embed-sdk';
35+
36+
// Encrypt an OAuth token
37+
const encryptedToken = encrypt(
38+
'your-embed-secret',
39+
'your-oauth-token'
40+
);
41+
42+
// Decrypt an encrypted token
43+
const decryptedToken = decrypt(
44+
'your-embed-secret',
45+
encryptedToken
46+
);
47+
```
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "@sigmacomputing/node-embed-sdk",
3+
"author": "sigmacomputing",
4+
"version": "0.1.0",
5+
"description": "Node.js SDK for Sigma Computing with encryption/decryption utilities",
6+
"license": "MIT",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/sigmacomputing/embed-sdk.git",
10+
"directory": "packages/node-embed-sdk"
11+
},
12+
"homepage": "https://sigmacomputing.com",
13+
"bugs": {
14+
"url": "https://github.com/sigmacomputing/embed-sdk/issues"
15+
},
16+
"keywords": [
17+
"embed",
18+
"sdk",
19+
"sigma",
20+
"node"
21+
],
22+
"scripts": {
23+
"prepublish": "turbo run build",
24+
"build": "tsup",
25+
"lint": "eslint . --ext .ts",
26+
"watch": "tsup --watch",
27+
"typecheck": "tsc --noEmit",
28+
"test": "echo \"Error: no test specified\" && exit 1"
29+
},
30+
"main": "./dist/index.js",
31+
"module": "./dist/index.mjs",
32+
"types": "./dist/index.d.ts",
33+
"exports": {
34+
"import": {
35+
"import": "./dist/index.mjs",
36+
"types": "./dist/index.d.mts"
37+
},
38+
"require": {
39+
"require": "./dist/index.js",
40+
"types": "./dist/index.d.ts"
41+
}
42+
},
43+
"files": [
44+
"dist"
45+
],
46+
"devDependencies": {
47+
"@sigmacomputing/eslint-config": "workspace:*",
48+
"@sigmacomputing/typescript-config": "workspace:*",
49+
"@types/node": "^20.17.16"
50+
},
51+
"engines": {
52+
"node": ">=18"
53+
}
54+
}

0 commit comments

Comments
 (0)