@twin.org/web 0.0.1-next.36 → 0.0.1-next.37
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/cjs/index.cjs +78 -85
- package/dist/esm/index.mjs +79 -86
- package/dist/types/index.d.ts +2 -1
- package/dist/types/models/IJwk.d.ts +2 -58
- package/dist/types/models/IJwtHeader.d.ts +2 -18
- package/dist/types/models/IJwtPayload.d.ts +2 -33
- package/dist/types/models/jwkCryptoKey.d.ts +5 -0
- package/dist/types/utils/jwk.d.ts +13 -0
- package/dist/types/utils/jwt.d.ts +28 -23
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/Jwk.md +35 -0
- package/docs/reference/classes/Jwt.md +45 -57
- package/docs/reference/index.md +2 -2
- package/docs/reference/interfaces/IJwk.md +2 -106
- package/docs/reference/interfaces/IJwtHeader.md +4 -24
- package/docs/reference/interfaces/IJwtPayload.md +4 -56
- package/docs/reference/type-aliases/JwkCryptoKey.md +5 -0
- package/locales/en.json +5 -1
- package/package.json +5 -4
- package/dist/types/models/jwtAlgorithms.d.ts +0 -17
- package/docs/reference/type-aliases/JwtAlgorithms.md +0 -5
- package/docs/reference/variables/JwtAlgorithms.md +0 -19
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { IJwtHeader } from "../models/IJwtHeader";
|
|
2
2
|
import type { IJwtPayload } from "../models/IJwtPayload";
|
|
3
|
-
import {
|
|
3
|
+
import type { JwkCryptoKey } from "../models/jwkCryptoKey";
|
|
4
4
|
/**
|
|
5
|
-
* Class to
|
|
5
|
+
* Class to handle JSON Web Tokens.
|
|
6
6
|
*/
|
|
7
7
|
export declare class Jwt {
|
|
8
8
|
/**
|
|
@@ -12,7 +12,7 @@ export declare class Jwt {
|
|
|
12
12
|
* @param key The key for signing the token, can be omitted if a signer is provided.
|
|
13
13
|
* @returns The encoded token.
|
|
14
14
|
*/
|
|
15
|
-
static encode<U extends IJwtHeader, T extends IJwtPayload>(header: U, payload: T, key:
|
|
15
|
+
static encode<U extends IJwtHeader, T extends IJwtPayload>(header: U, payload: T, key: JwkCryptoKey): Promise<string>;
|
|
16
16
|
/**
|
|
17
17
|
* Encode a token.
|
|
18
18
|
* @param header The header to encode.
|
|
@@ -20,7 +20,7 @@ export declare class Jwt {
|
|
|
20
20
|
* @param signer Custom signer method.
|
|
21
21
|
* @returns The encoded token.
|
|
22
22
|
*/
|
|
23
|
-
static encodeWithSigner<U extends IJwtHeader, T extends IJwtPayload>(header: U, payload: T, signer: (alg:
|
|
23
|
+
static encodeWithSigner<U extends IJwtHeader, T extends IJwtPayload>(header: U, payload: T, signer: (alg: string, key: JwkCryptoKey | undefined, header: IJwtHeader, payload: IJwtPayload) => Promise<string>): Promise<string>;
|
|
24
24
|
/**
|
|
25
25
|
* Decode a token.
|
|
26
26
|
* @param token The token to decode.
|
|
@@ -37,11 +37,9 @@ export declare class Jwt {
|
|
|
37
37
|
* @param key The key for verifying the token
|
|
38
38
|
* @returns The decoded payload.
|
|
39
39
|
*/
|
|
40
|
-
static verify<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
payload?: T;
|
|
44
|
-
signature?: Uint8Array;
|
|
40
|
+
static verify<T extends IJwtHeader, U extends IJwtPayload>(token: string, key: JwkCryptoKey): Promise<{
|
|
41
|
+
header: T;
|
|
42
|
+
payload: U;
|
|
45
43
|
}>;
|
|
46
44
|
/**
|
|
47
45
|
* Verify a token.
|
|
@@ -49,37 +47,44 @@ export declare class Jwt {
|
|
|
49
47
|
* @param verifier Custom verification method.
|
|
50
48
|
* @returns The decoded payload.
|
|
51
49
|
*/
|
|
52
|
-
static verifyWithVerifier<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
static verifyWithVerifier<T extends IJwtHeader, U extends IJwtPayload>(token: string, verifier: (token: string, key: JwkCryptoKey | undefined) => Promise<{
|
|
51
|
+
header: T;
|
|
52
|
+
payload: U;
|
|
53
|
+
}>): Promise<{
|
|
54
|
+
header: T;
|
|
55
|
+
payload: U;
|
|
57
56
|
}>;
|
|
58
57
|
/**
|
|
59
58
|
* Verify a token by parts.
|
|
60
|
-
* @param
|
|
61
|
-
* @param payload The payload to verify.
|
|
62
|
-
* @param signature The signature to verify.
|
|
59
|
+
* @param token The token to verify.
|
|
63
60
|
* @param key The key for verifying the token, if not provided no verification occurs.
|
|
64
61
|
* @param verifier Custom verification method.
|
|
65
62
|
* @returns True if the parts are verified.
|
|
66
63
|
*/
|
|
67
|
-
static verifySignature<
|
|
64
|
+
static verifySignature<T extends IJwtHeader, U extends IJwtPayload>(token: string, key?: JwkCryptoKey, verifier?: (token: string, key: JwkCryptoKey | undefined) => Promise<{
|
|
65
|
+
header: T;
|
|
66
|
+
payload: U;
|
|
67
|
+
}>): Promise<{
|
|
68
|
+
header: T;
|
|
69
|
+
payload: U;
|
|
70
|
+
}>;
|
|
68
71
|
/**
|
|
69
72
|
* The default signer for the JWT.
|
|
70
73
|
* @param alg The algorithm to use.
|
|
71
74
|
* @param key The key to sign with.
|
|
75
|
+
* @param header The header to sign.
|
|
72
76
|
* @param payload The payload to sign.
|
|
73
77
|
* @returns The signature.
|
|
74
78
|
*/
|
|
75
|
-
static defaultSigner(alg:
|
|
79
|
+
static defaultSigner(alg: string, key: JwkCryptoKey | undefined, header: IJwtHeader, payload: IJwtPayload): Promise<string>;
|
|
76
80
|
/**
|
|
77
81
|
* The default verifier for the JWT.
|
|
78
|
-
* @param
|
|
82
|
+
* @param token The token to verify.
|
|
79
83
|
* @param key The key to verify with.
|
|
80
|
-
* @param payload The payload to verify.
|
|
81
|
-
* @param signature The signature to verify.
|
|
82
84
|
* @returns True if the signature was verified.
|
|
83
85
|
*/
|
|
84
|
-
static defaultVerifier(
|
|
86
|
+
static defaultVerifier<T extends IJwtHeader, U extends IJwtPayload>(token: string, key: JwkCryptoKey | undefined): Promise<{
|
|
87
|
+
header: T;
|
|
88
|
+
payload: U;
|
|
89
|
+
}>;
|
|
85
90
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Class: Jwk
|
|
2
|
+
|
|
3
|
+
Class to handle JSON Web Keys.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new Jwk()
|
|
8
|
+
|
|
9
|
+
> **new Jwk**(): [`Jwk`](Jwk.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`Jwk`](Jwk.md)
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### toCryptoKey()
|
|
18
|
+
|
|
19
|
+
> `static` **toCryptoKey**(`jwk`): `Promise`\<[`JwkCryptoKey`](../type-aliases/JwkCryptoKey.md)\>
|
|
20
|
+
|
|
21
|
+
Convert the JWK to a crypto key.
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
##### jwk
|
|
26
|
+
|
|
27
|
+
[`IJwk`](../interfaces/IJwk.md)
|
|
28
|
+
|
|
29
|
+
The JWK to convert.
|
|
30
|
+
|
|
31
|
+
#### Returns
|
|
32
|
+
|
|
33
|
+
`Promise`\<[`JwkCryptoKey`](../type-aliases/JwkCryptoKey.md)\>
|
|
34
|
+
|
|
35
|
+
The crypto key.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Class: Jwt
|
|
2
2
|
|
|
3
|
-
Class to
|
|
3
|
+
Class to handle JSON Web Tokens.
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
@@ -42,7 +42,7 @@ The payload to encode.
|
|
|
42
42
|
|
|
43
43
|
##### key
|
|
44
44
|
|
|
45
|
-
`
|
|
45
|
+
[`JwkCryptoKey`](../type-aliases/JwkCryptoKey.md)
|
|
46
46
|
|
|
47
47
|
The key for signing the token, can be omitted if a signer is provided.
|
|
48
48
|
|
|
@@ -82,7 +82,7 @@ The payload to encode.
|
|
|
82
82
|
|
|
83
83
|
##### signer
|
|
84
84
|
|
|
85
|
-
(`alg`, `key`, `payload`) => `Promise`\<`
|
|
85
|
+
(`alg`, `key`, `header`, `payload`) => `Promise`\<`string`\>
|
|
86
86
|
|
|
87
87
|
Custom signer method.
|
|
88
88
|
|
|
@@ -124,15 +124,15 @@ The decoded payload.
|
|
|
124
124
|
|
|
125
125
|
### verify()
|
|
126
126
|
|
|
127
|
-
> `static` **verify**\<`
|
|
127
|
+
> `static` **verify**\<`T`, `U`\>(`token`, `key`): `Promise`\<\{ `header`: `T`; `payload`: `U`; \}\>
|
|
128
128
|
|
|
129
129
|
Verify a token.
|
|
130
130
|
|
|
131
131
|
#### Type Parameters
|
|
132
132
|
|
|
133
|
-
• **
|
|
133
|
+
• **T** *extends* [`IJwtHeader`](../interfaces/IJwtHeader.md)
|
|
134
134
|
|
|
135
|
-
• **
|
|
135
|
+
• **U** *extends* [`IJwtPayload`](../interfaces/IJwtPayload.md)
|
|
136
136
|
|
|
137
137
|
#### Parameters
|
|
138
138
|
|
|
@@ -144,13 +144,13 @@ The token to verify.
|
|
|
144
144
|
|
|
145
145
|
##### key
|
|
146
146
|
|
|
147
|
-
`
|
|
147
|
+
[`JwkCryptoKey`](../type-aliases/JwkCryptoKey.md)
|
|
148
148
|
|
|
149
149
|
The key for verifying the token
|
|
150
150
|
|
|
151
151
|
#### Returns
|
|
152
152
|
|
|
153
|
-
`Promise`\<\{ `
|
|
153
|
+
`Promise`\<\{ `header`: `T`; `payload`: `U`; \}\>
|
|
154
154
|
|
|
155
155
|
The decoded payload.
|
|
156
156
|
|
|
@@ -158,15 +158,15 @@ The decoded payload.
|
|
|
158
158
|
|
|
159
159
|
### verifyWithVerifier()
|
|
160
160
|
|
|
161
|
-
> `static` **verifyWithVerifier**\<`
|
|
161
|
+
> `static` **verifyWithVerifier**\<`T`, `U`\>(`token`, `verifier`): `Promise`\<\{ `header`: `T`; `payload`: `U`; \}\>
|
|
162
162
|
|
|
163
163
|
Verify a token.
|
|
164
164
|
|
|
165
165
|
#### Type Parameters
|
|
166
166
|
|
|
167
|
-
• **
|
|
167
|
+
• **T** *extends* [`IJwtHeader`](../interfaces/IJwtHeader.md)
|
|
168
168
|
|
|
169
|
-
• **
|
|
169
|
+
• **U** *extends* [`IJwtPayload`](../interfaces/IJwtPayload.md)
|
|
170
170
|
|
|
171
171
|
#### Parameters
|
|
172
172
|
|
|
@@ -178,13 +178,13 @@ The token to verify.
|
|
|
178
178
|
|
|
179
179
|
##### verifier
|
|
180
180
|
|
|
181
|
-
(`
|
|
181
|
+
(`token`, `key`) => `Promise`\<\{ `header`: `T`; `payload`: `U`; \}\>
|
|
182
182
|
|
|
183
183
|
Custom verification method.
|
|
184
184
|
|
|
185
185
|
#### Returns
|
|
186
186
|
|
|
187
|
-
`Promise`\<\{ `
|
|
187
|
+
`Promise`\<\{ `header`: `T`; `payload`: `U`; \}\>
|
|
188
188
|
|
|
189
189
|
The decoded payload.
|
|
190
190
|
|
|
@@ -192,51 +192,39 @@ The decoded payload.
|
|
|
192
192
|
|
|
193
193
|
### verifySignature()
|
|
194
194
|
|
|
195
|
-
> `static` **verifySignature**\<`
|
|
195
|
+
> `static` **verifySignature**\<`T`, `U`\>(`token`, `key`?, `verifier`?): `Promise`\<\{ `header`: `T`; `payload`: `U`; \}\>
|
|
196
196
|
|
|
197
197
|
Verify a token by parts.
|
|
198
198
|
|
|
199
199
|
#### Type Parameters
|
|
200
200
|
|
|
201
|
-
• **
|
|
201
|
+
• **T** *extends* [`IJwtHeader`](../interfaces/IJwtHeader.md)
|
|
202
202
|
|
|
203
|
-
• **
|
|
203
|
+
• **U** *extends* [`IJwtPayload`](../interfaces/IJwtPayload.md)
|
|
204
204
|
|
|
205
205
|
#### Parameters
|
|
206
206
|
|
|
207
|
-
#####
|
|
208
|
-
|
|
209
|
-
`U`
|
|
210
|
-
|
|
211
|
-
The header to verify.
|
|
212
|
-
|
|
213
|
-
##### payload?
|
|
214
|
-
|
|
215
|
-
`T`
|
|
216
|
-
|
|
217
|
-
The payload to verify.
|
|
218
|
-
|
|
219
|
-
##### signature?
|
|
207
|
+
##### token
|
|
220
208
|
|
|
221
|
-
`
|
|
209
|
+
`string`
|
|
222
210
|
|
|
223
|
-
The
|
|
211
|
+
The token to verify.
|
|
224
212
|
|
|
225
213
|
##### key?
|
|
226
214
|
|
|
227
|
-
`
|
|
215
|
+
[`JwkCryptoKey`](../type-aliases/JwkCryptoKey.md)
|
|
228
216
|
|
|
229
217
|
The key for verifying the token, if not provided no verification occurs.
|
|
230
218
|
|
|
231
219
|
##### verifier?
|
|
232
220
|
|
|
233
|
-
(`
|
|
221
|
+
(`token`, `key`) => `Promise`\<\{ `header`: `T`; `payload`: `U`; \}\>
|
|
234
222
|
|
|
235
223
|
Custom verification method.
|
|
236
224
|
|
|
237
225
|
#### Returns
|
|
238
226
|
|
|
239
|
-
`Promise
|
|
227
|
+
`Promise`\<\{ `header`: `T`; `payload`: `U`; \}\>
|
|
240
228
|
|
|
241
229
|
True if the parts are verified.
|
|
242
230
|
|
|
@@ -244,7 +232,7 @@ True if the parts are verified.
|
|
|
244
232
|
|
|
245
233
|
### defaultSigner()
|
|
246
234
|
|
|
247
|
-
> `static` **defaultSigner**(`alg`, `key`, `payload`): `Promise`\<`
|
|
235
|
+
> `static` **defaultSigner**(`alg`, `key`, `header`, `payload`): `Promise`\<`string`\>
|
|
248
236
|
|
|
249
237
|
The default signer for the JWT.
|
|
250
238
|
|
|
@@ -252,7 +240,7 @@ The default signer for the JWT.
|
|
|
252
240
|
|
|
253
241
|
##### alg
|
|
254
242
|
|
|
255
|
-
|
|
243
|
+
`string`
|
|
256
244
|
|
|
257
245
|
The algorithm to use.
|
|
258
246
|
|
|
@@ -260,17 +248,23 @@ The algorithm to use.
|
|
|
260
248
|
|
|
261
249
|
The key to sign with.
|
|
262
250
|
|
|
263
|
-
`undefined` | `
|
|
251
|
+
`undefined` | [`JwkCryptoKey`](../type-aliases/JwkCryptoKey.md)
|
|
252
|
+
|
|
253
|
+
##### header
|
|
254
|
+
|
|
255
|
+
[`IJwtHeader`](../interfaces/IJwtHeader.md)
|
|
256
|
+
|
|
257
|
+
The header to sign.
|
|
264
258
|
|
|
265
259
|
##### payload
|
|
266
260
|
|
|
267
|
-
`
|
|
261
|
+
[`IJwtPayload`](../interfaces/IJwtPayload.md)
|
|
268
262
|
|
|
269
263
|
The payload to sign.
|
|
270
264
|
|
|
271
265
|
#### Returns
|
|
272
266
|
|
|
273
|
-
`Promise`\<`
|
|
267
|
+
`Promise`\<`string`\>
|
|
274
268
|
|
|
275
269
|
The signature.
|
|
276
270
|
|
|
@@ -278,38 +272,32 @@ The signature.
|
|
|
278
272
|
|
|
279
273
|
### defaultVerifier()
|
|
280
274
|
|
|
281
|
-
> `static` **defaultVerifier
|
|
275
|
+
> `static` **defaultVerifier**\<`T`, `U`\>(`token`, `key`): `Promise`\<\{ `header`: `T`; `payload`: `U`; \}\>
|
|
282
276
|
|
|
283
277
|
The default verifier for the JWT.
|
|
284
278
|
|
|
285
|
-
#### Parameters
|
|
286
|
-
|
|
287
|
-
##### alg
|
|
279
|
+
#### Type Parameters
|
|
288
280
|
|
|
289
|
-
[`
|
|
281
|
+
• **T** *extends* [`IJwtHeader`](../interfaces/IJwtHeader.md)
|
|
290
282
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
##### key
|
|
283
|
+
• **U** *extends* [`IJwtPayload`](../interfaces/IJwtPayload.md)
|
|
294
284
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
`undefined` | `Uint8Array`
|
|
285
|
+
#### Parameters
|
|
298
286
|
|
|
299
|
-
#####
|
|
287
|
+
##### token
|
|
300
288
|
|
|
301
|
-
`
|
|
289
|
+
`string`
|
|
302
290
|
|
|
303
|
-
The
|
|
291
|
+
The token to verify.
|
|
304
292
|
|
|
305
|
-
#####
|
|
293
|
+
##### key
|
|
306
294
|
|
|
307
|
-
|
|
295
|
+
The key to verify with.
|
|
308
296
|
|
|
309
|
-
|
|
297
|
+
`undefined` | [`JwkCryptoKey`](../type-aliases/JwkCryptoKey.md)
|
|
310
298
|
|
|
311
299
|
#### Returns
|
|
312
300
|
|
|
313
|
-
`Promise
|
|
301
|
+
`Promise`\<\{ `header`: `T`; `payload`: `U`; \}\>
|
|
314
302
|
|
|
315
303
|
True if the signature was verified.
|
package/docs/reference/index.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
- [FetchError](classes/FetchError.md)
|
|
6
6
|
- [FetchHelper](classes/FetchHelper.md)
|
|
7
|
+
- [Jwk](classes/Jwk.md)
|
|
7
8
|
- [Jwt](classes/Jwt.md)
|
|
8
9
|
- [MimeTypeHelper](classes/MimeTypeHelper.md)
|
|
9
10
|
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
- [HeaderTypes](type-aliases/HeaderTypes.md)
|
|
21
22
|
- [HttpMethod](type-aliases/HttpMethod.md)
|
|
22
23
|
- [HttpStatusCode](type-aliases/HttpStatusCode.md)
|
|
23
|
-
- [
|
|
24
|
+
- [JwkCryptoKey](type-aliases/JwkCryptoKey.md)
|
|
24
25
|
- [MimeTypes](type-aliases/MimeTypes.md)
|
|
25
26
|
|
|
26
27
|
## Variables
|
|
@@ -28,5 +29,4 @@
|
|
|
28
29
|
- [HeaderTypes](variables/HeaderTypes.md)
|
|
29
30
|
- [HttpMethod](variables/HttpMethod.md)
|
|
30
31
|
- [HttpStatusCode](variables/HttpStatusCode.md)
|
|
31
|
-
- [JwtAlgorithms](variables/JwtAlgorithms.md)
|
|
32
32
|
- [MimeTypes](variables/MimeTypes.md)
|
|
@@ -2,110 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
The fields in a JSON Web Key.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Extends
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Properties
|
|
10
|
-
|
|
11
|
-
### alg?
|
|
12
|
-
|
|
13
|
-
> `optional` **alg**: [`JwtAlgorithms`](../type-aliases/JwtAlgorithms.md)
|
|
14
|
-
|
|
15
|
-
The cryptographic algorithm for the key.
|
|
16
|
-
|
|
17
|
-
***
|
|
18
|
-
|
|
19
|
-
### use?
|
|
20
|
-
|
|
21
|
-
> `optional` **use**: `string`
|
|
22
|
-
|
|
23
|
-
The intended use for the key.
|
|
24
|
-
|
|
25
|
-
***
|
|
26
|
-
|
|
27
|
-
### key\_ops?
|
|
28
|
-
|
|
29
|
-
> `optional` **key\_ops**: `string`[]
|
|
30
|
-
|
|
31
|
-
The operation(s) that the key is intended to be used for.
|
|
32
|
-
|
|
33
|
-
***
|
|
34
|
-
|
|
35
|
-
### kty
|
|
36
|
-
|
|
37
|
-
> **kty**: `string`
|
|
38
|
-
|
|
39
|
-
The key type parameter.
|
|
40
|
-
|
|
41
|
-
***
|
|
42
|
-
|
|
43
|
-
### n?
|
|
44
|
-
|
|
45
|
-
> `optional` **n**: `string`
|
|
46
|
-
|
|
47
|
-
The public key parameters.
|
|
48
|
-
|
|
49
|
-
***
|
|
50
|
-
|
|
51
|
-
### e?
|
|
52
|
-
|
|
53
|
-
> `optional` **e**: `string`
|
|
54
|
-
|
|
55
|
-
Exponent parameter.
|
|
56
|
-
|
|
57
|
-
***
|
|
58
|
-
|
|
59
|
-
### d?
|
|
60
|
-
|
|
61
|
-
> `optional` **d**: `string`
|
|
62
|
-
|
|
63
|
-
The private key parameters.
|
|
64
|
-
|
|
65
|
-
***
|
|
66
|
-
|
|
67
|
-
### p?
|
|
68
|
-
|
|
69
|
-
> `optional` **p**: `string`
|
|
70
|
-
|
|
71
|
-
The private key parameters.
|
|
72
|
-
|
|
73
|
-
***
|
|
74
|
-
|
|
75
|
-
### q?
|
|
76
|
-
|
|
77
|
-
> `optional` **q**: `string`
|
|
78
|
-
|
|
79
|
-
The private key parameters.
|
|
80
|
-
|
|
81
|
-
***
|
|
82
|
-
|
|
83
|
-
### dp?
|
|
84
|
-
|
|
85
|
-
> `optional` **dp**: `string`
|
|
86
|
-
|
|
87
|
-
The private key parameters.
|
|
88
|
-
|
|
89
|
-
***
|
|
90
|
-
|
|
91
|
-
### dq?
|
|
92
|
-
|
|
93
|
-
> `optional` **dq**: `string`
|
|
94
|
-
|
|
95
|
-
The private key parameters.
|
|
96
|
-
|
|
97
|
-
***
|
|
98
|
-
|
|
99
|
-
### qi?
|
|
100
|
-
|
|
101
|
-
> `optional` **qi**: `string`
|
|
102
|
-
|
|
103
|
-
The private key parameters.
|
|
104
|
-
|
|
105
|
-
***
|
|
106
|
-
|
|
107
|
-
### kid?
|
|
108
|
-
|
|
109
|
-
> `optional` **kid**: `string`
|
|
110
|
-
|
|
111
|
-
The key ID.
|
|
7
|
+
- `JWK`
|
|
@@ -2,30 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
The fields in a JSON Web Token header.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
\[`key`: `string`\]: `unknown`
|
|
8
|
-
|
|
9
|
-
## Properties
|
|
10
|
-
|
|
11
|
-
### typ?
|
|
12
|
-
|
|
13
|
-
> `optional` **typ**: `string`
|
|
14
|
-
|
|
15
|
-
The type of the token.
|
|
5
|
+
## Extends
|
|
16
6
|
|
|
17
|
-
|
|
7
|
+
- `JWTHeaderParameters`
|
|
18
8
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
> **alg**: [`JwtAlgorithms`](../type-aliases/JwtAlgorithms.md)
|
|
22
|
-
|
|
23
|
-
The algorithm used to sign the token.
|
|
24
|
-
|
|
25
|
-
***
|
|
26
|
-
|
|
27
|
-
### kid?
|
|
28
|
-
|
|
29
|
-
> `optional` **kid**: `string`
|
|
9
|
+
## Indexable
|
|
30
10
|
|
|
31
|
-
|
|
11
|
+
\[`propName`: `string`\]: `unknown`
|
|
@@ -2,62 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
The fields in a JSON Web Token payload.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
\[`key`: `string`\]: `unknown`
|
|
8
|
-
|
|
9
|
-
## Properties
|
|
10
|
-
|
|
11
|
-
### iss?
|
|
12
|
-
|
|
13
|
-
> `optional` **iss**: `string`
|
|
14
|
-
|
|
15
|
-
The issuer of the token.
|
|
16
|
-
|
|
17
|
-
***
|
|
18
|
-
|
|
19
|
-
### sub?
|
|
20
|
-
|
|
21
|
-
> `optional` **sub**: `string`
|
|
22
|
-
|
|
23
|
-
The subject of the token.
|
|
24
|
-
|
|
25
|
-
***
|
|
26
|
-
|
|
27
|
-
### aud?
|
|
28
|
-
|
|
29
|
-
> `optional` **aud**: `string`
|
|
30
|
-
|
|
31
|
-
The audience of the token.
|
|
5
|
+
## Extends
|
|
32
6
|
|
|
33
|
-
|
|
7
|
+
- `JWTPayload`
|
|
34
8
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
> `optional` **exp**: `number`
|
|
38
|
-
|
|
39
|
-
The expiration time of the token.
|
|
40
|
-
|
|
41
|
-
***
|
|
42
|
-
|
|
43
|
-
### nbf?
|
|
44
|
-
|
|
45
|
-
> `optional` **nbf**: `number`
|
|
46
|
-
|
|
47
|
-
The not before time of the token.
|
|
48
|
-
|
|
49
|
-
***
|
|
50
|
-
|
|
51
|
-
### iat?
|
|
52
|
-
|
|
53
|
-
> `optional` **iat**: `number`
|
|
54
|
-
|
|
55
|
-
The issued at time of the token.
|
|
56
|
-
|
|
57
|
-
***
|
|
58
|
-
|
|
59
|
-
### jti?
|
|
60
|
-
|
|
61
|
-
> `optional` **jti**: `string`
|
|
9
|
+
## Indexable
|
|
62
10
|
|
|
63
|
-
|
|
11
|
+
\[`propName`: `string`\]: `unknown`
|
package/locales/en.json
CHANGED
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
},
|
|
10
10
|
"jwt": {
|
|
11
11
|
"noKeyOrSigner": "No key or signer was provided for JWT creation",
|
|
12
|
-
"noKeyOrVerifier": "No key or verifier was provided for JWT creation"
|
|
12
|
+
"noKeyOrVerifier": "No key or verifier was provided for JWT creation",
|
|
13
|
+
"verifyFailed": "Failed to verify JWT"
|
|
14
|
+
},
|
|
15
|
+
"jwk": {
|
|
16
|
+
"jwkImportFailed": "Failed to import JWK"
|
|
13
17
|
}
|
|
14
18
|
},
|
|
15
19
|
"errorMessages": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/web",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.37",
|
|
4
4
|
"description": "Contains classes for use with web operations",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/core": "0.0.1-next.
|
|
18
|
-
"@twin.org/crypto": "0.0.1-next.
|
|
19
|
-
"@twin.org/nameof": "next"
|
|
17
|
+
"@twin.org/core": "0.0.1-next.37",
|
|
18
|
+
"@twin.org/crypto": "0.0.1-next.37",
|
|
19
|
+
"@twin.org/nameof": "next",
|
|
20
|
+
"jose": "6.0.8"
|
|
20
21
|
},
|
|
21
22
|
"main": "./dist/cjs/index.cjs",
|
|
22
23
|
"module": "./dist/esm/index.mjs",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The cryptographic algorithms supported for JSON Web Tokens and JSON Web Keys.
|
|
3
|
-
*/
|
|
4
|
-
export declare const JwtAlgorithms: {
|
|
5
|
-
/**
|
|
6
|
-
* HMAC using SHA-256.
|
|
7
|
-
*/
|
|
8
|
-
readonly HS256: "HS256";
|
|
9
|
-
/**
|
|
10
|
-
* EdDSA using Ed25519.
|
|
11
|
-
*/
|
|
12
|
-
readonly EdDSA: "EdDSA";
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* The cryptographic algorithms supported for JSON Web Tokens and JSON Web Keys.
|
|
16
|
-
*/
|
|
17
|
-
export type JwtAlgorithms = (typeof JwtAlgorithms)[keyof typeof JwtAlgorithms];
|