@nevermined-io/ui-widgets-server 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ import type { CreateInitTokenOptions } from './types.js';
2
+ export declare function createInitToken(options: CreateInitTokenOptions): Promise<string>;
3
+ //# sourceMappingURL=create-init-token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-init-token.d.ts","sourceRoot":"","sources":["../src/create-init-token.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAKxD,wBAAsB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBtF"}
@@ -0,0 +1,20 @@
1
+ import { SignJWT } from 'jose';
2
+ const WIDGET_AUDIENCE = 'nvm:widgets';
3
+ const DEFAULT_EXPIRES_IN = '5m';
4
+ export async function createInitToken(options) {
5
+ const { userId, orgId, secretKey, expiresIn = DEFAULT_EXPIRES_IN } = options;
6
+ if (!secretKey?.trim())
7
+ throw new Error('secretKey is required');
8
+ if (!userId?.trim())
9
+ throw new Error('userId is required');
10
+ if (!orgId?.trim())
11
+ throw new Error('orgId is required');
12
+ const secret = new TextEncoder().encode(secretKey);
13
+ return new SignJWT({ orgId })
14
+ .setProtectedHeader({ alg: 'HS256' })
15
+ .setSubject(userId)
16
+ .setAudience(WIDGET_AUDIENCE)
17
+ .setIssuedAt()
18
+ .setExpirationTime(expiresIn)
19
+ .sign(secret);
20
+ }
@@ -0,0 +1,3 @@
1
+ export { createInitToken } from './create-init-token.js';
2
+ export type { CreateInitTokenOptions, InitTokenPayload } from './types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { createInitToken } from './create-init-token.js';
@@ -0,0 +1,14 @@
1
+ export interface CreateInitTokenOptions {
2
+ userId: string;
3
+ orgId: string;
4
+ secretKey: string;
5
+ expiresIn?: string;
6
+ }
7
+ export interface InitTokenPayload {
8
+ sub: string;
9
+ orgId: string;
10
+ aud: string;
11
+ iat: number;
12
+ exp: number;
13
+ }
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@nevermined-io/ui-widgets-server",
3
+ "version": "0.3.1",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ "./package.json": "./package.json",
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "!**/*.tsbuildinfo"
19
+ ],
20
+ "dependencies": {
21
+ "jose": "4.15.9"
22
+ }
23
+ }