jsonauthtoken 3.0.3 → 3.0.4-beta-2
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.
- package/dist/node.index.d.mts +53 -0
- package/dist/node.index.d.ts +53 -0
- package/dist/node.index.js +767 -0
- package/dist/node.index.mjs +728 -0
- package/dist/types.d-D_Cze-FV.d.mts +32 -0
- package/dist/types.d-D_Cze-FV.d.ts +32 -0
- package/dist/types.d.ts +68 -0
- package/dist/web.index.d.mts +52 -0
- package/dist/web.index.d.ts +52 -0
- package/dist/web.index.js +599 -0
- package/dist/web.index.mjs +571 -0
- package/package.json +36 -5
- package/types.d.ts +54 -53
- package/dist/config/algo.config.d.ts +0 -2
- package/dist/config/algo.config.js +0 -28
- package/dist/config/name.config.d.ts +0 -1
- package/dist/config/name.config.js +0 -4
- package/dist/config/runtime.config.d.ts +0 -1
- package/dist/config/runtime.config.js +0 -15
- package/dist/index.d.ts +0 -34
- package/dist/index.js +0 -133
- package/dist/lib/decoading.lib.d.ts +0 -2
- package/dist/lib/decoading.lib.js +0 -9
- package/dist/lib/encoading.lib.d.ts +0 -2
- package/dist/lib/encoading.lib.js +0 -8
- package/dist/lib/functions.lib.d.ts +0 -12
- package/dist/lib/functions.lib.js +0 -85
- package/dist/lib/timeformat.d.ts +0 -1
- package/dist/lib/timeformat.js +0 -42
- package/dist/runtime/node.runtime.d.ts +0 -31
- package/dist/runtime/node.runtime.js +0 -146
- package/dist/runtime/runtime.d.ts +0 -12
- package/dist/runtime/runtime.js +0 -152
- package/dist/runtime/web.runtime.d.ts +0 -38
- package/dist/runtime/web.runtime.js +0 -180
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
interface WebJATInstance {
|
|
2
|
+
create: ({ key, exp, algo }: { key: string, exp: JsonAuthTokenExpiry, algo: RuntimeWiseAlgorithmMap['web'] }, payload: any) => Promise<string>
|
|
3
|
+
verify: <T>(token: string, key: string) => Promise<T>
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
//timeformat type
|
|
8
|
+
type TimeUnit = 'S' | 'MIN' | 'H' | 'D' | 'M' | 'Y';
|
|
9
|
+
type ExpirationString = `${number}${TimeUnit}` | `${number}${Lowercase<TimeUnit>}`;
|
|
10
|
+
type JsonAuthTokenExpiry = number | ExpirationString;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
interface GenerateKeyPair {
|
|
15
|
+
privateKey: string
|
|
16
|
+
publicKey: string
|
|
17
|
+
}
|
|
18
|
+
type EncryptionAlgorithmType = 'symmetric' | 'asymmetric';
|
|
19
|
+
type NodeRuntime = 'node' | 'web'
|
|
20
|
+
|
|
21
|
+
interface AlgorithmDetails {
|
|
22
|
+
name: string;
|
|
23
|
+
value: string
|
|
24
|
+
type: EncryptionAlgorithmType;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface RuntimeWiseAlgorithmMap {
|
|
28
|
+
node: 'AES-256-GCM' | 'RSA+A256GCM'
|
|
29
|
+
web: 'AES-GCM' | 'RSA+AES-GCM'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type { AlgorithmDetails as A, GenerateKeyPair as G, JsonAuthTokenExpiry as J, NodeRuntime as N, RuntimeWiseAlgorithmMap as R, WebJATInstance as W };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
interface WebJATInstance {
|
|
2
|
+
create: ({ key, exp, algo }: { key: string, exp: JsonAuthTokenExpiry, algo: RuntimeWiseAlgorithmMap['web'] }, payload: any) => Promise<string>
|
|
3
|
+
verify: <T>(token: string, key: string) => Promise<T>
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
//timeformat type
|
|
8
|
+
type TimeUnit = 'S' | 'MIN' | 'H' | 'D' | 'M' | 'Y';
|
|
9
|
+
type ExpirationString = `${number}${TimeUnit}` | `${number}${Lowercase<TimeUnit>}`;
|
|
10
|
+
type JsonAuthTokenExpiry = number | ExpirationString;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
interface GenerateKeyPair {
|
|
15
|
+
privateKey: string
|
|
16
|
+
publicKey: string
|
|
17
|
+
}
|
|
18
|
+
type EncryptionAlgorithmType = 'symmetric' | 'asymmetric';
|
|
19
|
+
type NodeRuntime = 'node' | 'web'
|
|
20
|
+
|
|
21
|
+
interface AlgorithmDetails {
|
|
22
|
+
name: string;
|
|
23
|
+
value: string
|
|
24
|
+
type: EncryptionAlgorithmType;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface RuntimeWiseAlgorithmMap {
|
|
28
|
+
node: 'AES-256-GCM' | 'RSA+A256GCM'
|
|
29
|
+
web: 'AES-GCM' | 'RSA+AES-GCM'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type { AlgorithmDetails as A, GenerateKeyPair as G, JsonAuthTokenExpiry as J, NodeRuntime as N, RuntimeWiseAlgorithmMap as R, WebJATInstance as W };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export interface WebJATInstance {
|
|
2
|
+
create: ({ key, exp, algo }: { key: string, exp: JsonAuthTokenExpiry, algo: RuntimeWiseAlgorithmMap['web'] }, payload: any) => Promise<string>
|
|
3
|
+
verify: <T>(token: string, key: string) => Promise<T>
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface NodeJATInstance {
|
|
7
|
+
create: ({ key, exp, algo }: { key: string, exp: JsonAuthTokenExpiry, algo: RuntimeWiseAlgorithmMap['node'] }, payload: any) => Promise<string>
|
|
8
|
+
verify: <T>(token: string, key: string) => Promise<T>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export declare function JAT(config: { runtime: 'node', dev?: boolean }): NodeJATInstance;
|
|
12
|
+
export declare function JAT(config?: { runtime?: 'web', dev?: boolean }): WebJATInstance;
|
|
13
|
+
export declare function JAT(config: { runtime: 'web' | 'node', dev?: boolean }): NodeJATInstance | WebJATInstance;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
//timeformat type
|
|
17
|
+
export type TimeUnit = 'S' | 'MIN' | 'H' | 'D' | 'M' | 'Y';
|
|
18
|
+
export type ExpirationString = `${number}${TimeUnit}` | `${number}${Lowercase<TimeUnit>}`;
|
|
19
|
+
export type JsonAuthTokenExpiry = number | ExpirationString;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export interface GenerateKeyPair {
|
|
24
|
+
privateKey: string
|
|
25
|
+
publicKey: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type Runtimes = 'node' | 'web';
|
|
29
|
+
export type EncryptionAlgorithmType = 'symmetric' | 'asymmetric';
|
|
30
|
+
|
|
31
|
+
export type WebRuntime = 'web'
|
|
32
|
+
export type NodeRuntime = 'node' | 'web'
|
|
33
|
+
|
|
34
|
+
export interface AlgorithmDetails {
|
|
35
|
+
name: string;
|
|
36
|
+
value: string
|
|
37
|
+
type: EncryptionAlgorithmType;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface RuntimeWiseAlgorithmMap {
|
|
41
|
+
node: 'AES-256-GCM' | 'RSA+A256GCM'
|
|
42
|
+
web: 'AES-GCM' | 'RSA+AES-GCM'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type RuntimeWiseAlgorithm<R extends Runtimes> = RuntimeWiseAlgorithmMap[R];
|
|
46
|
+
|
|
47
|
+
export interface BaseTokenMetaData<R extends Runtimes> {
|
|
48
|
+
runtime: Runtimes;
|
|
49
|
+
algo: RuntimeWiseAlgorithm<R>;
|
|
50
|
+
v: string;
|
|
51
|
+
iv: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type TokenMetaData<R extends Runtimes> =
|
|
55
|
+
| (BaseTokenMetaData<R> & {
|
|
56
|
+
runtime: 'node';
|
|
57
|
+
tag: string;
|
|
58
|
+
} & (
|
|
59
|
+
| { type: 'symmetric'; encryptedKey?: never }
|
|
60
|
+
| { type: 'asymmetric'; encryptedKey: string }
|
|
61
|
+
))
|
|
62
|
+
| (BaseTokenMetaData<R> & {
|
|
63
|
+
runtime: 'web';
|
|
64
|
+
tag?: never;
|
|
65
|
+
} & (
|
|
66
|
+
| { type: 'symmetric'; encryptedKey?: never }
|
|
67
|
+
| { type: 'asymmetric'; encryptedKey: string }
|
|
68
|
+
));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { W as WebJATInstance, J as JsonAuthTokenExpiry, R as RuntimeWiseAlgorithmMap, G as GenerateKeyPair, A as AlgorithmDetails } from './types.d-D_Cze-FV.mjs';
|
|
2
|
+
|
|
3
|
+
declare class WebCryptoModule implements WebJATInstance {
|
|
4
|
+
private dev;
|
|
5
|
+
private runtime;
|
|
6
|
+
private web;
|
|
7
|
+
constructor({ runtime, dev }?: {
|
|
8
|
+
dev?: boolean;
|
|
9
|
+
runtime?: 'web';
|
|
10
|
+
});
|
|
11
|
+
private createToken;
|
|
12
|
+
private verifyToken;
|
|
13
|
+
create({ key, exp, algo }: {
|
|
14
|
+
key: string;
|
|
15
|
+
exp: JsonAuthTokenExpiry;
|
|
16
|
+
algo: RuntimeWiseAlgorithmMap['web'];
|
|
17
|
+
}, payload: any): Promise<string>;
|
|
18
|
+
verify<T>(token: string, key: string): Promise<T>;
|
|
19
|
+
}
|
|
20
|
+
declare const JAT: ({ runtime, dev }?: {
|
|
21
|
+
runtime?: "web";
|
|
22
|
+
dev?: boolean;
|
|
23
|
+
}) => WebCryptoModule;
|
|
24
|
+
declare const getSupportedAlgorithm: () => AlgorithmDetails[];
|
|
25
|
+
declare const P2KG: {
|
|
26
|
+
generateKeyPair: (options?: {
|
|
27
|
+
runtime?: "web";
|
|
28
|
+
dev?: boolean;
|
|
29
|
+
}) => Promise<GenerateKeyPair>;
|
|
30
|
+
generatePublicKey: (privateKeyPem: string, options?: {
|
|
31
|
+
runtime?: "web";
|
|
32
|
+
dev?: boolean;
|
|
33
|
+
}) => Promise<string>;
|
|
34
|
+
};
|
|
35
|
+
declare const jsonauthtoken: {
|
|
36
|
+
JAT: ({ runtime, dev }?: {
|
|
37
|
+
runtime?: "web";
|
|
38
|
+
dev?: boolean;
|
|
39
|
+
}) => WebCryptoModule;
|
|
40
|
+
P2KG: {
|
|
41
|
+
generateKeyPair: (options?: {
|
|
42
|
+
runtime?: "web";
|
|
43
|
+
dev?: boolean;
|
|
44
|
+
}) => Promise<GenerateKeyPair>;
|
|
45
|
+
generatePublicKey: (privateKeyPem: string, options?: {
|
|
46
|
+
runtime?: "web";
|
|
47
|
+
dev?: boolean;
|
|
48
|
+
}) => Promise<string>;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { JAT, P2KG, jsonauthtoken as default, getSupportedAlgorithm };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { W as WebJATInstance, J as JsonAuthTokenExpiry, R as RuntimeWiseAlgorithmMap, G as GenerateKeyPair, A as AlgorithmDetails } from './types.d-D_Cze-FV.js';
|
|
2
|
+
|
|
3
|
+
declare class WebCryptoModule implements WebJATInstance {
|
|
4
|
+
private dev;
|
|
5
|
+
private runtime;
|
|
6
|
+
private web;
|
|
7
|
+
constructor({ runtime, dev }?: {
|
|
8
|
+
dev?: boolean;
|
|
9
|
+
runtime?: 'web';
|
|
10
|
+
});
|
|
11
|
+
private createToken;
|
|
12
|
+
private verifyToken;
|
|
13
|
+
create({ key, exp, algo }: {
|
|
14
|
+
key: string;
|
|
15
|
+
exp: JsonAuthTokenExpiry;
|
|
16
|
+
algo: RuntimeWiseAlgorithmMap['web'];
|
|
17
|
+
}, payload: any): Promise<string>;
|
|
18
|
+
verify<T>(token: string, key: string): Promise<T>;
|
|
19
|
+
}
|
|
20
|
+
declare const JAT: ({ runtime, dev }?: {
|
|
21
|
+
runtime?: "web";
|
|
22
|
+
dev?: boolean;
|
|
23
|
+
}) => WebCryptoModule;
|
|
24
|
+
declare const getSupportedAlgorithm: () => AlgorithmDetails[];
|
|
25
|
+
declare const P2KG: {
|
|
26
|
+
generateKeyPair: (options?: {
|
|
27
|
+
runtime?: "web";
|
|
28
|
+
dev?: boolean;
|
|
29
|
+
}) => Promise<GenerateKeyPair>;
|
|
30
|
+
generatePublicKey: (privateKeyPem: string, options?: {
|
|
31
|
+
runtime?: "web";
|
|
32
|
+
dev?: boolean;
|
|
33
|
+
}) => Promise<string>;
|
|
34
|
+
};
|
|
35
|
+
declare const jsonauthtoken: {
|
|
36
|
+
JAT: ({ runtime, dev }?: {
|
|
37
|
+
runtime?: "web";
|
|
38
|
+
dev?: boolean;
|
|
39
|
+
}) => WebCryptoModule;
|
|
40
|
+
P2KG: {
|
|
41
|
+
generateKeyPair: (options?: {
|
|
42
|
+
runtime?: "web";
|
|
43
|
+
dev?: boolean;
|
|
44
|
+
}) => Promise<GenerateKeyPair>;
|
|
45
|
+
generatePublicKey: (privateKeyPem: string, options?: {
|
|
46
|
+
runtime?: "web";
|
|
47
|
+
dev?: boolean;
|
|
48
|
+
}) => Promise<string>;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { JAT, P2KG, jsonauthtoken as default, getSupportedAlgorithm };
|