@sourceregistry/node-jwt 1.5.4 → 1.5.6
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/README.md +1 -0
- package/package.json +11 -3
- package/dist/index-BgMSfLZD.cjs +0 -2
- package/dist/index-BgMSfLZD.cjs.map +0 -1
- package/dist/index-tE21mX91.js +0 -814
- package/dist/index-tE21mX91.js.map +0 -1
- package/dist/index.cjs.js +0 -2
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.es.js +0 -23
- package/dist/index.es.js.map +0 -1
- package/dist/jwks/index.d.ts +0 -130
- package/dist/jwks/promises.d.ts +0 -81
- package/dist/jwt/index.d.ts +0 -243
- package/dist/jwt/promises.d.ts +0 -89
- package/dist/promises.cjs.js +0 -2
- package/dist/promises.cjs.js.map +0 -1
- package/dist/promises.d.ts +0 -2
- package/dist/promises.es.js +0 -44
- package/dist/promises.es.js.map +0 -1
package/dist/jwt/index.d.ts
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import { BinaryLike, KeyLike, KeyObject } from 'crypto';
|
|
2
|
-
export declare const base64Url: {
|
|
3
|
-
encode: (input: string | Buffer) => string;
|
|
4
|
-
decode: (input: string) => string;
|
|
5
|
-
};
|
|
6
|
-
export interface JWTPayload {
|
|
7
|
-
/**
|
|
8
|
-
* Issuer
|
|
9
|
-
*/
|
|
10
|
-
iss?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Subject
|
|
13
|
-
*/
|
|
14
|
-
sub?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Audience
|
|
17
|
-
*/
|
|
18
|
-
aud?: string | string[];
|
|
19
|
-
/**
|
|
20
|
-
* Expiration Time (as UNIX timestamp)
|
|
21
|
-
*/
|
|
22
|
-
exp?: number;
|
|
23
|
-
/**
|
|
24
|
-
* Not Before (as UNIX timestamp)
|
|
25
|
-
*/
|
|
26
|
-
nbf?: number;
|
|
27
|
-
/**
|
|
28
|
-
* Issued At (as UNIX timestamp)
|
|
29
|
-
*/
|
|
30
|
-
iat?: number;
|
|
31
|
-
/**
|
|
32
|
-
* JWT ID
|
|
33
|
-
*/
|
|
34
|
-
jti?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Session ID
|
|
37
|
-
*/
|
|
38
|
-
sid?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Custom claims
|
|
41
|
-
*/
|
|
42
|
-
[key: string]: unknown;
|
|
43
|
-
}
|
|
44
|
-
export interface JWTHeader {
|
|
45
|
-
alg: string;
|
|
46
|
-
typ?: string;
|
|
47
|
-
kid?: string;
|
|
48
|
-
}
|
|
49
|
-
export interface JWT {
|
|
50
|
-
header: JWTHeader;
|
|
51
|
-
payload: JWTPayload;
|
|
52
|
-
signature: string;
|
|
53
|
-
}
|
|
54
|
-
export declare const SignatureAlgorithm: {
|
|
55
|
-
readonly HS256: {
|
|
56
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
57
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
58
|
-
};
|
|
59
|
-
readonly HS384: {
|
|
60
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
61
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
62
|
-
};
|
|
63
|
-
readonly HS512: {
|
|
64
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
65
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
66
|
-
};
|
|
67
|
-
readonly RS256: {
|
|
68
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
69
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
70
|
-
};
|
|
71
|
-
readonly RS384: {
|
|
72
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
73
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
74
|
-
};
|
|
75
|
-
readonly RS512: {
|
|
76
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
77
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
78
|
-
};
|
|
79
|
-
readonly ES256: {
|
|
80
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
81
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
82
|
-
};
|
|
83
|
-
readonly ES384: {
|
|
84
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
85
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
86
|
-
};
|
|
87
|
-
readonly ES512: {
|
|
88
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
89
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
90
|
-
};
|
|
91
|
-
readonly ES256K: {
|
|
92
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
93
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
94
|
-
};
|
|
95
|
-
readonly PS256: {
|
|
96
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
97
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
98
|
-
};
|
|
99
|
-
readonly PS384: {
|
|
100
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
101
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
102
|
-
};
|
|
103
|
-
readonly PS512: {
|
|
104
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
105
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
106
|
-
};
|
|
107
|
-
readonly EdDSA: {
|
|
108
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
109
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
export type SupportedAlgorithm = keyof typeof SignatureAlgorithm;
|
|
113
|
-
export declare const SupportedAlgorithms: Array<SupportedAlgorithm>;
|
|
114
|
-
/**
|
|
115
|
-
* Autodetection of algorithm for KeyObjects
|
|
116
|
-
* @param key
|
|
117
|
-
* @constructor
|
|
118
|
-
*/
|
|
119
|
-
export declare function AutodetectAlgorithm(key: KeyObject): SupportedAlgorithm;
|
|
120
|
-
/**
|
|
121
|
-
* Decode a JWT string into its parts (without verification)
|
|
122
|
-
* @param token
|
|
123
|
-
*/
|
|
124
|
-
export declare const decode: (token: string) => JWT;
|
|
125
|
-
export type SignOptions = {
|
|
126
|
-
alg?: SupportedAlgorithm;
|
|
127
|
-
kid?: string;
|
|
128
|
-
typ?: string;
|
|
129
|
-
/**
|
|
130
|
-
* default 'der'
|
|
131
|
-
*/
|
|
132
|
-
signatureFormat?: 'der' | 'jose';
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Sign a JWT
|
|
136
|
-
* @param payload
|
|
137
|
-
* @param secret
|
|
138
|
-
* @param options
|
|
139
|
-
*/
|
|
140
|
-
export declare const sign: (payload: JWTPayload, secret: KeyLike, options?: SignOptions) => string;
|
|
141
|
-
export type VerifyOptions = {
|
|
142
|
-
algorithms?: SupportedAlgorithm[];
|
|
143
|
-
issuer?: string;
|
|
144
|
-
subject?: string;
|
|
145
|
-
audience?: string | string[];
|
|
146
|
-
jwtId?: string;
|
|
147
|
-
ignoreExpiration?: boolean;
|
|
148
|
-
clockSkew?: number;
|
|
149
|
-
maxTokenAge?: number;
|
|
150
|
-
signatureFormat?: 'der' | 'jose';
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* Verify and validate a JWT
|
|
154
|
-
* @param token
|
|
155
|
-
* @param secret
|
|
156
|
-
* @param options
|
|
157
|
-
*/
|
|
158
|
-
export declare const verify: (token: string, secret: KeyLike, options?: VerifyOptions) => {
|
|
159
|
-
valid: true;
|
|
160
|
-
header: JWTHeader;
|
|
161
|
-
payload: JWTPayload;
|
|
162
|
-
signature: string;
|
|
163
|
-
} | {
|
|
164
|
-
valid: false;
|
|
165
|
-
error: {
|
|
166
|
-
reason: string;
|
|
167
|
-
code: string;
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
export declare const JWT: {
|
|
171
|
-
readonly sign: (payload: JWTPayload, secret: KeyLike, options?: SignOptions) => string;
|
|
172
|
-
readonly verify: (token: string, secret: KeyLike, options?: VerifyOptions) => {
|
|
173
|
-
valid: true;
|
|
174
|
-
header: JWTHeader;
|
|
175
|
-
payload: JWTPayload;
|
|
176
|
-
signature: string;
|
|
177
|
-
} | {
|
|
178
|
-
valid: false;
|
|
179
|
-
error: {
|
|
180
|
-
reason: string;
|
|
181
|
-
code: string;
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
readonly decode: (token: string) => JWT;
|
|
185
|
-
readonly algorithms: {
|
|
186
|
-
readonly HS256: {
|
|
187
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
188
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
189
|
-
};
|
|
190
|
-
readonly HS384: {
|
|
191
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
192
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
193
|
-
};
|
|
194
|
-
readonly HS512: {
|
|
195
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
196
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
197
|
-
};
|
|
198
|
-
readonly RS256: {
|
|
199
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
200
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
201
|
-
};
|
|
202
|
-
readonly RS384: {
|
|
203
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
204
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
205
|
-
};
|
|
206
|
-
readonly RS512: {
|
|
207
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
208
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
209
|
-
};
|
|
210
|
-
readonly ES256: {
|
|
211
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
212
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
213
|
-
};
|
|
214
|
-
readonly ES384: {
|
|
215
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
216
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
217
|
-
};
|
|
218
|
-
readonly ES512: {
|
|
219
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
220
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
221
|
-
};
|
|
222
|
-
readonly ES256K: {
|
|
223
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
224
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
225
|
-
};
|
|
226
|
-
readonly PS256: {
|
|
227
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
228
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
229
|
-
};
|
|
230
|
-
readonly PS384: {
|
|
231
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
232
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
233
|
-
};
|
|
234
|
-
readonly PS512: {
|
|
235
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
236
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
237
|
-
};
|
|
238
|
-
readonly EdDSA: {
|
|
239
|
-
readonly sign: (data: BinaryLike, secret: KeyLike) => string;
|
|
240
|
-
readonly verify: (data: BinaryLike, secret: KeyLike, signature: string) => boolean;
|
|
241
|
-
};
|
|
242
|
-
};
|
|
243
|
-
};
|
package/dist/jwt/promises.d.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { JWT as JSONWebToken, sign as signSync, verify as verifySync, JWTPayload, JWTHeader } from '../';
|
|
2
|
-
export { type SupportedAlgorithm, SupportedAlgorithms, SignatureAlgorithm, type JWTHeader, type JWTPayload } from '../index';
|
|
3
|
-
/**
|
|
4
|
-
* Decode a JWT string into its parts (without verification)
|
|
5
|
-
* @param token
|
|
6
|
-
*/
|
|
7
|
-
export declare const decode: (token: string) => Promise<JSONWebToken>;
|
|
8
|
-
/**
|
|
9
|
-
* Sign a JWT
|
|
10
|
-
* @see(synchronous parameters)
|
|
11
|
-
*/
|
|
12
|
-
export declare const sign: (...args: Parameters<typeof signSync>) => Promise<string>;
|
|
13
|
-
/**
|
|
14
|
-
* Verify and validate a JWT
|
|
15
|
-
* @throws { { reason: string; code: string } } if invalid
|
|
16
|
-
*/
|
|
17
|
-
export declare const verify: (...args: Parameters<typeof verifySync>) => Promise<{
|
|
18
|
-
header: JWTHeader;
|
|
19
|
-
payload: JWTPayload;
|
|
20
|
-
signature: string;
|
|
21
|
-
}>;
|
|
22
|
-
export type JWT = JSONWebToken;
|
|
23
|
-
export declare const JWT: {
|
|
24
|
-
sign: (payload: JWTPayload, secret: import('node:crypto').KeyLike, options?: import('.').SignOptions | undefined) => Promise<string>;
|
|
25
|
-
verify: (token: string, secret: import('node:crypto').KeyLike, options?: import('.').VerifyOptions | undefined) => Promise<{
|
|
26
|
-
header: JWTHeader;
|
|
27
|
-
payload: JWTPayload;
|
|
28
|
-
signature: string;
|
|
29
|
-
}>;
|
|
30
|
-
decode: (token: string) => Promise<JSONWebToken>;
|
|
31
|
-
algorithms: {
|
|
32
|
-
readonly HS256: {
|
|
33
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
34
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
35
|
-
};
|
|
36
|
-
readonly HS384: {
|
|
37
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
38
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
39
|
-
};
|
|
40
|
-
readonly HS512: {
|
|
41
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
42
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
43
|
-
};
|
|
44
|
-
readonly RS256: {
|
|
45
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
46
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
47
|
-
};
|
|
48
|
-
readonly RS384: {
|
|
49
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
50
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
51
|
-
};
|
|
52
|
-
readonly RS512: {
|
|
53
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
54
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
55
|
-
};
|
|
56
|
-
readonly ES256: {
|
|
57
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
58
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
59
|
-
};
|
|
60
|
-
readonly ES384: {
|
|
61
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
62
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
63
|
-
};
|
|
64
|
-
readonly ES512: {
|
|
65
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
66
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
67
|
-
};
|
|
68
|
-
readonly ES256K: {
|
|
69
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
70
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
71
|
-
};
|
|
72
|
-
readonly PS256: {
|
|
73
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
74
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
75
|
-
};
|
|
76
|
-
readonly PS384: {
|
|
77
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
78
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
79
|
-
};
|
|
80
|
-
readonly PS512: {
|
|
81
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
82
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
83
|
-
};
|
|
84
|
-
readonly EdDSA: {
|
|
85
|
-
readonly sign: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike) => string;
|
|
86
|
-
readonly verify: (data: import('node:crypto').BinaryLike, secret: import('node:crypto').KeyLike, signature: string) => boolean;
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
};
|
package/dist/promises.cjs.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-BgMSfLZD.cjs");require("crypto");const r=e=>Promise.resolve().then(()=>o.decode(e)),i=(...e)=>Promise.resolve().then(()=>o.sign(...e)),s=(...e)=>Promise.resolve().then(()=>{const t=o.verify(...e);if(!t.valid)throw t.error;const{header:J,payload:p,signature:g}=t;return{header:J,payload:p,signature:g}}),b={sign:i,verify:s,decode:r,algorithms:o.SignatureAlgorithm},n=e=>Promise.resolve().then(()=>o.exportJWK(e)),m=e=>Promise.resolve().then(()=>o.importJWK(e)),c=e=>Promise.resolve().then(()=>o.toPublicJWK(e)),l=(e,t="sha256")=>Promise.resolve().then(()=>o.getJWKThumbprint(e,t)),W=(e,t)=>Promise.resolve().then(()=>o.JWKSToKeyObject(e,t)),K=e=>Promise.resolve().then(()=>o.normalizeJWKS(e)),h=e=>Promise.resolve().then(()=>o.computeX5T(e)),u=(...e)=>Promise.resolve().then(()=>o.fromWeb(...e)),a={export:n,import:m,toPublic:c,thumbprint:l,computeX5T:h},v={toKeyObject:W,normalize:K,fromWeb:u};exports.SignatureAlgorithm=o.SignatureAlgorithm;exports.SupportedAlgorithms=o.SupportedAlgorithms;exports.JWK=a;exports.JWKS=v;exports.JWKSToKeyObject=W;exports.JWT=b;exports.computeX5T=h;exports.decode=r;exports.exportJWK=n;exports.fromWeb=u;exports.getJWKThumbprint=l;exports.importJWK=m;exports.normalizeJWKS=K;exports.sign=i;exports.toPublicJWK=c;exports.verify=s;
|
|
2
|
-
//# sourceMappingURL=promises.cjs.js.map
|
package/dist/promises.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"promises.cjs.js","sources":["../src/jwt/promises.ts","../src/jwks/promises.ts"],"sourcesContent":["import {\n type JWT as JSONWebToken,\n decode as decodeSync,\n sign as signSync,\n verify as verifySync,\n JWTPayload,\n type SupportedAlgorithm,\n JWTHeader,\n SignatureAlgorithm\n} from '../';\n\nexport {\n type SupportedAlgorithm, SupportedAlgorithms, SignatureAlgorithm, type JWTHeader, type JWTPayload\n} from '../index';\n\n/**\n * Decode a JWT string into its parts (without verification)\n * @param token\n */\nexport const decode = (token: string): Promise<JSONWebToken> =>\n Promise.resolve().then(() => decodeSync(token));\n\n/**\n * Sign a JWT\n * @see(synchronous parameters)\n */\nexport const sign = (...args: Parameters<typeof signSync>): Promise<string> =>\n Promise.resolve().then(() => signSync(...args));\n\n/**\n * Verify and validate a JWT\n * @throws { { reason: string; code: string } } if invalid\n */\nexport const verify = (...args: Parameters<typeof verifySync>): Promise<{\n header: JWTHeader;\n payload: JWTPayload;\n signature: string\n}> =>\n Promise.resolve().then(() => {\n const result = verifySync(...args);\n if (!result.valid) {\n throw result.error;\n }\n const {header, payload, signature} = result;\n return {header, payload, signature};\n });\n\nexport type JWT = JSONWebToken;\n\n//namespace export\nexport const JWT = {\n sign,\n verify,\n decode,\n algorithms: SignatureAlgorithm\n};\n","import type {KeyObject} from 'crypto';\n\nimport {\n type JWK as JWKType,\n type JWKS as JSONWebKeySet,\n exportJWK as exportJWKSYNC,\n importJWK as importJWKSYNC,\n toPublicJWK as toPublicJWKSYNC,\n getJWKThumbprint as getJWKThumbprintSYNC,\n JWKSToKeyObject as JWKSToKeyObjectSYNC,\n normalizeJWKS as normalizeJWKSSYNC,\n computeX5T as computeX5TSYNC,\n fromWeb as fromWebSYNC\n} from './';\n\n/**\n * Export a KeyObject to JWK\n * @param key\n */\nexport const exportJWK = (key: KeyObject): Promise<JWKType> =>\n Promise.resolve().then(() => exportJWKSYNC(key));\n\n/**\n * Import a JWK to KeyObject\n * @param jwk\n */\nexport const importJWK = (jwk: JWKType): Promise<KeyObject> =>\n Promise.resolve().then(() => importJWKSYNC(jwk));\n\n/**\n * Export public-only JWK\n * @param key\n */\nexport const toPublicJWK = (key: KeyObject): Promise<JWKType> =>\n Promise.resolve().then(() => toPublicJWKSYNC(key));\n\n/**\n * RFC 7638 JWK thumbprint\n * @param jwk\n * @param hashAlg\n */\nexport const getJWKThumbprint = (\n jwk: JWKType,\n hashAlg: 'sha256' = 'sha256'\n): Promise<string> =>\n Promise.resolve().then(() => getJWKThumbprintSYNC(jwk, hashAlg));\n\n/**\n * Resolve a KeyObject from a JWKS (kid-based)\n * @param jwks\n * @param kid\n * @constructor\n */\nexport const JWKSToKeyObject = (\n jwks: JSONWebKeySet,\n kid?: string\n): Promise<KeyObject> =>\n Promise.resolve().then(() => JWKSToKeyObjectSYNC(jwks, kid));\n\n/**\n * Normalize JWKS (auto-generate missing kid values)\n * @param jwks\n */\nexport const normalizeJWKS = (\n jwks: JSONWebKeySet\n): Promise<JSONWebKeySet> =>\n Promise.resolve().then(() => normalizeJWKSSYNC(jwks));\n\n/**\n * Compute x5t (SHA-1) from first cert in x5c if not set\n * @param jwk\n */\nexport const computeX5T = (jwk: JWKType) => Promise.resolve().then(() => computeX5TSYNC(jwk))\n\n/**\n * Load and resolve JWKS from a remote endpoint\n * @param args\n */\nexport const fromWeb = (\n ...args: Parameters<typeof fromWebSYNC>\n) => Promise.resolve().then(() => fromWebSYNC(...args));\n\n//namespaced exports\nexport const JWK = {\n export: exportJWK,\n import: importJWK,\n toPublic: toPublicJWK,\n thumbprint: getJWKThumbprint,\n computeX5T: computeX5T,\n};\n\n//namespaced exports\nexport const JWKS = {\n toKeyObject: JWKSToKeyObject,\n normalize: normalizeJWKS,\n fromWeb,\n};\n"],"names":["decode","token","decodeSync","sign","args","signSync","verify","result","verifySync","header","payload","signature","JWT","SignatureAlgorithm","exportJWK","key","exportJWKSYNC","importJWK","jwk","importJWKSYNC","toPublicJWK","toPublicJWKSYNC","getJWKThumbprint","hashAlg","getJWKThumbprintSYNC","JWKSToKeyObject","jwks","kid","JWKSToKeyObjectSYNC","normalizeJWKS","normalizeJWKSSYNC","computeX5T","computeX5TSYNC","fromWeb","fromWebSYNC","JWK","JWKS"],"mappings":"0IAmBO,MAAMA,EAAUC,GACnB,QAAQ,QAAA,EAAU,KAAK,IAAMC,EAAAA,OAAWD,CAAK,CAAC,EAMrCE,EAAO,IAAIC,IACpB,QAAQ,QAAA,EAAU,KAAK,IAAMC,OAAS,GAAGD,CAAI,CAAC,EAMrCE,EAAS,IAAIF,IAKtB,QAAQ,QAAA,EAAU,KAAK,IAAM,CACzB,MAAMG,EAASC,SAAW,GAAGJ,CAAI,EACjC,GAAI,CAACG,EAAO,MACR,MAAMA,EAAO,MAEjB,KAAM,CAAC,OAAAE,EAAQ,QAAAC,EAAS,UAAAC,CAAA,EAAaJ,EACrC,MAAO,CAAC,OAAAE,EAAQ,QAAAC,EAAS,UAAAC,CAAA,CAC7B,CAAC,EAKQC,EAAM,CACf,KAAAT,EACA,OAAAG,EACA,OAAAN,EACA,WAAYa,EAAAA,kBAChB,ECpCaC,EAAaC,GACtB,QAAQ,QAAA,EAAU,KAAK,IAAMC,EAAAA,UAAcD,CAAG,CAAC,EAMtCE,EAAaC,GACtB,QAAQ,QAAA,EAAU,KAAK,IAAMC,EAAAA,UAAcD,CAAG,CAAC,EAMtCE,EAAeL,GACxB,QAAQ,QAAA,EAAU,KAAK,IAAMM,EAAAA,YAAgBN,CAAG,CAAC,EAOxCO,EAAmB,CAC5BJ,EACAK,EAAoB,WAEpB,QAAQ,QAAA,EAAU,KAAK,IAAMC,mBAAqBN,EAAKK,CAAO,CAAC,EAQtDE,EAAkB,CAC3BC,EACAC,IAEA,QAAQ,UAAU,KAAK,IAAMC,EAAAA,gBAAoBF,EAAMC,CAAG,CAAC,EAMlDE,EACTH,GAEA,QAAQ,QAAA,EAAU,KAAK,IAAMI,EAAAA,cAAkBJ,CAAI,CAAC,EAM3CK,EAAcb,GAAiB,QAAQ,QAAA,EAAU,KAAK,IAAMc,EAAAA,WAAed,CAAG,CAAC,EAM/Ee,EAAU,IAChB7B,IACF,QAAQ,QAAA,EAAU,KAAK,IAAM8B,UAAY,GAAG9B,CAAI,CAAC,EAGzC+B,EAAM,CACf,OAAQrB,EACR,OAAQG,EACR,SAAUG,EACV,WAAYE,EACZ,WAAAS,CACJ,EAGaK,EAAO,CAChB,YAAaX,EACb,UAAWI,EACX,QAAAI,CACJ"}
|
package/dist/promises.d.ts
DELETED
package/dist/promises.es.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { S as n, g as i, v as m, s as c, f as a, j as l, t as h, k as p, h as K, i as W, l as v, b as J } from "./index-tE21mX91.js";
|
|
2
|
-
import { d as q } from "./index-tE21mX91.js";
|
|
3
|
-
import "crypto";
|
|
4
|
-
const P = (e) => Promise.resolve().then(() => i(e)), u = (...e) => Promise.resolve().then(() => c(...e)), b = (...e) => Promise.resolve().then(() => {
|
|
5
|
-
const o = m(...e);
|
|
6
|
-
if (!o.valid)
|
|
7
|
-
throw o.error;
|
|
8
|
-
const { header: t, payload: s, signature: r } = o;
|
|
9
|
-
return { header: t, payload: s, signature: r };
|
|
10
|
-
}), O = {
|
|
11
|
-
sign: u,
|
|
12
|
-
verify: b,
|
|
13
|
-
decode: P,
|
|
14
|
-
algorithms: n
|
|
15
|
-
}, $ = (e) => Promise.resolve().then(() => K(e)), g = (e) => Promise.resolve().then(() => p(e)), d = (e) => Promise.resolve().then(() => h(e)), f = (e, o = "sha256") => Promise.resolve().then(() => l(e, o)), S = (e, o) => Promise.resolve().then(() => J(e, o)), T = (e) => Promise.resolve().then(() => v(e)), y = (e) => Promise.resolve().then(() => a(e)), x = (...e) => Promise.resolve().then(() => W(...e)), A = {
|
|
16
|
-
export: $,
|
|
17
|
-
import: g,
|
|
18
|
-
toPublic: d,
|
|
19
|
-
thumbprint: f,
|
|
20
|
-
computeX5T: y
|
|
21
|
-
}, X = {
|
|
22
|
-
toKeyObject: S,
|
|
23
|
-
normalize: T,
|
|
24
|
-
fromWeb: x
|
|
25
|
-
};
|
|
26
|
-
export {
|
|
27
|
-
A as JWK,
|
|
28
|
-
X as JWKS,
|
|
29
|
-
S as JWKSToKeyObject,
|
|
30
|
-
O as JWT,
|
|
31
|
-
n as SignatureAlgorithm,
|
|
32
|
-
q as SupportedAlgorithms,
|
|
33
|
-
y as computeX5T,
|
|
34
|
-
P as decode,
|
|
35
|
-
$ as exportJWK,
|
|
36
|
-
x as fromWeb,
|
|
37
|
-
f as getJWKThumbprint,
|
|
38
|
-
g as importJWK,
|
|
39
|
-
T as normalizeJWKS,
|
|
40
|
-
u as sign,
|
|
41
|
-
d as toPublicJWK,
|
|
42
|
-
b as verify
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=promises.es.js.map
|
package/dist/promises.es.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"promises.es.js","sources":["../src/jwt/promises.ts","../src/jwks/promises.ts"],"sourcesContent":["import {\n type JWT as JSONWebToken,\n decode as decodeSync,\n sign as signSync,\n verify as verifySync,\n JWTPayload,\n type SupportedAlgorithm,\n JWTHeader,\n SignatureAlgorithm\n} from '../';\n\nexport {\n type SupportedAlgorithm, SupportedAlgorithms, SignatureAlgorithm, type JWTHeader, type JWTPayload\n} from '../index';\n\n/**\n * Decode a JWT string into its parts (without verification)\n * @param token\n */\nexport const decode = (token: string): Promise<JSONWebToken> =>\n Promise.resolve().then(() => decodeSync(token));\n\n/**\n * Sign a JWT\n * @see(synchronous parameters)\n */\nexport const sign = (...args: Parameters<typeof signSync>): Promise<string> =>\n Promise.resolve().then(() => signSync(...args));\n\n/**\n * Verify and validate a JWT\n * @throws { { reason: string; code: string } } if invalid\n */\nexport const verify = (...args: Parameters<typeof verifySync>): Promise<{\n header: JWTHeader;\n payload: JWTPayload;\n signature: string\n}> =>\n Promise.resolve().then(() => {\n const result = verifySync(...args);\n if (!result.valid) {\n throw result.error;\n }\n const {header, payload, signature} = result;\n return {header, payload, signature};\n });\n\nexport type JWT = JSONWebToken;\n\n//namespace export\nexport const JWT = {\n sign,\n verify,\n decode,\n algorithms: SignatureAlgorithm\n};\n","import type {KeyObject} from 'crypto';\n\nimport {\n type JWK as JWKType,\n type JWKS as JSONWebKeySet,\n exportJWK as exportJWKSYNC,\n importJWK as importJWKSYNC,\n toPublicJWK as toPublicJWKSYNC,\n getJWKThumbprint as getJWKThumbprintSYNC,\n JWKSToKeyObject as JWKSToKeyObjectSYNC,\n normalizeJWKS as normalizeJWKSSYNC,\n computeX5T as computeX5TSYNC,\n fromWeb as fromWebSYNC\n} from './';\n\n/**\n * Export a KeyObject to JWK\n * @param key\n */\nexport const exportJWK = (key: KeyObject): Promise<JWKType> =>\n Promise.resolve().then(() => exportJWKSYNC(key));\n\n/**\n * Import a JWK to KeyObject\n * @param jwk\n */\nexport const importJWK = (jwk: JWKType): Promise<KeyObject> =>\n Promise.resolve().then(() => importJWKSYNC(jwk));\n\n/**\n * Export public-only JWK\n * @param key\n */\nexport const toPublicJWK = (key: KeyObject): Promise<JWKType> =>\n Promise.resolve().then(() => toPublicJWKSYNC(key));\n\n/**\n * RFC 7638 JWK thumbprint\n * @param jwk\n * @param hashAlg\n */\nexport const getJWKThumbprint = (\n jwk: JWKType,\n hashAlg: 'sha256' = 'sha256'\n): Promise<string> =>\n Promise.resolve().then(() => getJWKThumbprintSYNC(jwk, hashAlg));\n\n/**\n * Resolve a KeyObject from a JWKS (kid-based)\n * @param jwks\n * @param kid\n * @constructor\n */\nexport const JWKSToKeyObject = (\n jwks: JSONWebKeySet,\n kid?: string\n): Promise<KeyObject> =>\n Promise.resolve().then(() => JWKSToKeyObjectSYNC(jwks, kid));\n\n/**\n * Normalize JWKS (auto-generate missing kid values)\n * @param jwks\n */\nexport const normalizeJWKS = (\n jwks: JSONWebKeySet\n): Promise<JSONWebKeySet> =>\n Promise.resolve().then(() => normalizeJWKSSYNC(jwks));\n\n/**\n * Compute x5t (SHA-1) from first cert in x5c if not set\n * @param jwk\n */\nexport const computeX5T = (jwk: JWKType) => Promise.resolve().then(() => computeX5TSYNC(jwk))\n\n/**\n * Load and resolve JWKS from a remote endpoint\n * @param args\n */\nexport const fromWeb = (\n ...args: Parameters<typeof fromWebSYNC>\n) => Promise.resolve().then(() => fromWebSYNC(...args));\n\n//namespaced exports\nexport const JWK = {\n export: exportJWK,\n import: importJWK,\n toPublic: toPublicJWK,\n thumbprint: getJWKThumbprint,\n computeX5T: computeX5T,\n};\n\n//namespaced exports\nexport const JWKS = {\n toKeyObject: JWKSToKeyObject,\n normalize: normalizeJWKS,\n fromWeb,\n};\n"],"names":["decode","token","decodeSync","sign","args","signSync","verify","result","verifySync","header","payload","signature","JWT","SignatureAlgorithm","exportJWK","key","exportJWKSYNC","importJWK","jwk","importJWKSYNC","toPublicJWK","toPublicJWKSYNC","getJWKThumbprint","hashAlg","getJWKThumbprintSYNC","JWKSToKeyObject","jwks","kid","JWKSToKeyObjectSYNC","normalizeJWKS","normalizeJWKSSYNC","computeX5T","computeX5TSYNC","fromWeb","fromWebSYNC","JWK","JWKS"],"mappings":";;;AAmBO,MAAMA,IAAS,CAACC,MACnB,QAAQ,QAAA,EAAU,KAAK,MAAMC,EAAWD,CAAK,CAAC,GAMrCE,IAAO,IAAIC,MACpB,QAAQ,QAAA,EAAU,KAAK,MAAMC,EAAS,GAAGD,CAAI,CAAC,GAMrCE,IAAS,IAAIF,MAKtB,QAAQ,QAAA,EAAU,KAAK,MAAM;AACzB,QAAMG,IAASC,EAAW,GAAGJ,CAAI;AACjC,MAAI,CAACG,EAAO;AACR,UAAMA,EAAO;AAEjB,QAAM,EAAC,QAAAE,GAAQ,SAAAC,GAAS,WAAAC,EAAA,IAAaJ;AACrC,SAAO,EAAC,QAAAE,GAAQ,SAAAC,GAAS,WAAAC,EAAA;AAC7B,CAAC,GAKQC,IAAM;AAAA,EACf,MAAAT;AAAA,EACA,QAAAG;AAAA,EACA,QAAAN;AAAA,EACA,YAAYa;AAChB,GCpCaC,IAAY,CAACC,MACtB,QAAQ,QAAA,EAAU,KAAK,MAAMC,EAAcD,CAAG,CAAC,GAMtCE,IAAY,CAACC,MACtB,QAAQ,QAAA,EAAU,KAAK,MAAMC,EAAcD,CAAG,CAAC,GAMtCE,IAAc,CAACL,MACxB,QAAQ,QAAA,EAAU,KAAK,MAAMM,EAAgBN,CAAG,CAAC,GAOxCO,IAAmB,CAC5BJ,GACAK,IAAoB,aAEpB,QAAQ,QAAA,EAAU,KAAK,MAAMC,EAAqBN,GAAKK,CAAO,CAAC,GAQtDE,IAAkB,CAC3BC,GACAC,MAEA,QAAQ,UAAU,KAAK,MAAMC,EAAoBF,GAAMC,CAAG,CAAC,GAMlDE,IAAgB,CACzBH,MAEA,QAAQ,QAAA,EAAU,KAAK,MAAMI,EAAkBJ,CAAI,CAAC,GAM3CK,IAAa,CAACb,MAAiB,QAAQ,QAAA,EAAU,KAAK,MAAMc,EAAed,CAAG,CAAC,GAM/Ee,IAAU,IAChB7B,MACF,QAAQ,QAAA,EAAU,KAAK,MAAM8B,EAAY,GAAG9B,CAAI,CAAC,GAGzC+B,IAAM;AAAA,EACf,QAAQrB;AAAA,EACR,QAAQG;AAAA,EACR,UAAUG;AAAA,EACV,YAAYE;AAAA,EACZ,YAAAS;AACJ,GAGaK,IAAO;AAAA,EAChB,aAAaX;AAAA,EACb,WAAWI;AAAA,EACX,SAAAI;AACJ;"}
|