@twin.org/web 0.0.1-next.9 → 0.0.2-next.3
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 +298 -94
- package/dist/esm/index.mjs +299 -96
- package/dist/types/index.d.ts +3 -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 +4 -0
- package/dist/types/models/mimeTypes.d.ts +8 -0
- package/dist/types/utils/fetchHelper.d.ts +7 -0
- package/dist/types/utils/jwk.d.ts +41 -0
- package/dist/types/utils/jws.d.ts +22 -0
- package/dist/types/utils/jwt.d.ts +67 -29
- package/docs/changelog.md +480 -1
- package/docs/reference/classes/FetchError.md +16 -8
- package/docs/reference/classes/FetchHelper.md +104 -28
- package/docs/reference/classes/Jwk.md +129 -0
- package/docs/reference/classes/Jws.md +81 -0
- package/docs/reference/classes/Jwt.md +261 -105
- package/docs/reference/classes/MimeTypeHelper.md +9 -5
- package/docs/reference/index.md +3 -2
- package/docs/reference/interfaces/IHttpHeaders.md +1 -1
- package/docs/reference/interfaces/IJwk.md +2 -106
- package/docs/reference/interfaces/IJwtHeader.md +5 -23
- package/docs/reference/interfaces/IJwtPayload.md +5 -55
- package/docs/reference/type-aliases/HeaderTypes.md +1 -1
- package/docs/reference/type-aliases/HttpMethod.md +1 -1
- package/docs/reference/type-aliases/HttpStatusCode.md +1 -1
- package/docs/reference/type-aliases/JwkCryptoKey.md +5 -0
- package/docs/reference/type-aliases/MimeTypes.md +1 -1
- package/docs/reference/variables/MimeTypes.md +12 -0
- package/locales/en.json +11 -1
- package/package.json +7 -6
- 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
|
@@ -4,41 +4,51 @@ Class to helper with fetch operations.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new FetchHelper**():
|
|
9
|
+
> **new FetchHelper**(): `FetchHelper`
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`FetchHelper`
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
17
17
|
### fetch()
|
|
18
18
|
|
|
19
|
-
> `static` **fetch**(`source`, `url`, `method`, `body
|
|
19
|
+
> `static` **fetch**(`source`, `url`, `method`, `body?`, `options?`): `Promise`\<`Response`\>
|
|
20
20
|
|
|
21
21
|
Perform a fetch request.
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### source
|
|
26
|
+
|
|
27
|
+
`string`
|
|
26
28
|
|
|
27
29
|
The source for the request.
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
##### url
|
|
32
|
+
|
|
33
|
+
`string`
|
|
30
34
|
|
|
31
35
|
The url for the request.
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
##### method
|
|
38
|
+
|
|
39
|
+
[`HttpMethod`](../type-aliases/HttpMethod.md)
|
|
34
40
|
|
|
35
41
|
The http method.
|
|
36
42
|
|
|
37
|
-
|
|
43
|
+
##### body?
|
|
38
44
|
|
|
39
45
|
Request to send to the endpoint.
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
`string` | `Uint8Array`\<`ArrayBufferLike`\>
|
|
48
|
+
|
|
49
|
+
##### options?
|
|
50
|
+
|
|
51
|
+
`Omit`\<[`IFetchOptions`](../interfaces/IFetchOptions.md), `"cacheTtlSeconds"`\>
|
|
42
52
|
|
|
43
53
|
Options for sending the requests.
|
|
44
54
|
|
|
@@ -52,35 +62,49 @@ The response.
|
|
|
52
62
|
|
|
53
63
|
### fetchJson()
|
|
54
64
|
|
|
55
|
-
> `static` **fetchJson**\<`T`, `U`\>(`source`, `url`, `method`, `requestData
|
|
65
|
+
> `static` **fetchJson**\<`T`, `U`\>(`source`, `url`, `method`, `requestData?`, `options?`): `Promise`\<`U`\>
|
|
56
66
|
|
|
57
67
|
Perform a request in json format.
|
|
58
68
|
|
|
59
69
|
#### Type Parameters
|
|
60
70
|
|
|
61
|
-
|
|
71
|
+
##### T
|
|
72
|
+
|
|
73
|
+
`T`
|
|
62
74
|
|
|
63
|
-
|
|
75
|
+
##### U
|
|
76
|
+
|
|
77
|
+
`U`
|
|
64
78
|
|
|
65
79
|
#### Parameters
|
|
66
80
|
|
|
67
|
-
|
|
81
|
+
##### source
|
|
82
|
+
|
|
83
|
+
`string`
|
|
68
84
|
|
|
69
85
|
The source for the request.
|
|
70
86
|
|
|
71
|
-
|
|
87
|
+
##### url
|
|
88
|
+
|
|
89
|
+
`string`
|
|
72
90
|
|
|
73
91
|
The url for the request.
|
|
74
92
|
|
|
75
|
-
|
|
93
|
+
##### method
|
|
94
|
+
|
|
95
|
+
[`HttpMethod`](../type-aliases/HttpMethod.md)
|
|
76
96
|
|
|
77
97
|
The http method.
|
|
78
98
|
|
|
79
|
-
|
|
99
|
+
##### requestData?
|
|
100
|
+
|
|
101
|
+
`T`
|
|
80
102
|
|
|
81
103
|
Request to send to the endpoint.
|
|
82
104
|
|
|
83
|
-
|
|
105
|
+
##### options?
|
|
106
|
+
|
|
107
|
+
[`IFetchOptions`](../interfaces/IFetchOptions.md)
|
|
84
108
|
|
|
85
109
|
Options for sending the requests.
|
|
86
110
|
|
|
@@ -94,39 +118,51 @@ The response.
|
|
|
94
118
|
|
|
95
119
|
### fetchBinary()
|
|
96
120
|
|
|
97
|
-
> `static` **fetchBinary**\<`T`\>(`source`, `url`, `method`, `requestData
|
|
121
|
+
> `static` **fetchBinary**\<`T`\>(`source`, `url`, `method`, `requestData?`, `options?`): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\> \| `T`\>
|
|
98
122
|
|
|
99
123
|
Perform a request for binary data.
|
|
100
124
|
|
|
101
125
|
#### Type Parameters
|
|
102
126
|
|
|
103
|
-
|
|
127
|
+
##### T
|
|
128
|
+
|
|
129
|
+
`T`
|
|
104
130
|
|
|
105
131
|
#### Parameters
|
|
106
132
|
|
|
107
|
-
|
|
133
|
+
##### source
|
|
134
|
+
|
|
135
|
+
`string`
|
|
108
136
|
|
|
109
137
|
The source for the request.
|
|
110
138
|
|
|
111
|
-
|
|
139
|
+
##### url
|
|
140
|
+
|
|
141
|
+
`string`
|
|
112
142
|
|
|
113
143
|
The url for the request.
|
|
114
144
|
|
|
115
|
-
|
|
145
|
+
##### method
|
|
116
146
|
|
|
117
147
|
The http method.
|
|
118
148
|
|
|
119
|
-
|
|
149
|
+
`"GET"` | `"POST"`
|
|
150
|
+
|
|
151
|
+
##### requestData?
|
|
152
|
+
|
|
153
|
+
`Uint8Array`\<`ArrayBufferLike`\>
|
|
120
154
|
|
|
121
155
|
Request to send to the endpoint.
|
|
122
156
|
|
|
123
|
-
|
|
157
|
+
##### options?
|
|
158
|
+
|
|
159
|
+
[`IFetchOptions`](../interfaces/IFetchOptions.md)
|
|
124
160
|
|
|
125
161
|
Options for sending the requests.
|
|
126
162
|
|
|
127
163
|
#### Returns
|
|
128
164
|
|
|
129
|
-
`Promise`\<`Uint8Array
|
|
165
|
+
`Promise`\<`Uint8Array`\<`ArrayBufferLike`\> \| `T`\>
|
|
130
166
|
|
|
131
167
|
The response.
|
|
132
168
|
|
|
@@ -152,11 +188,15 @@ Get a cache entry.
|
|
|
152
188
|
|
|
153
189
|
#### Type Parameters
|
|
154
190
|
|
|
155
|
-
|
|
191
|
+
##### T
|
|
192
|
+
|
|
193
|
+
`T`
|
|
156
194
|
|
|
157
195
|
#### Parameters
|
|
158
196
|
|
|
159
|
-
|
|
197
|
+
##### url
|
|
198
|
+
|
|
199
|
+
`string`
|
|
160
200
|
|
|
161
201
|
The url for the request.
|
|
162
202
|
|
|
@@ -168,6 +208,40 @@ The cache entry if it exists.
|
|
|
168
208
|
|
|
169
209
|
***
|
|
170
210
|
|
|
211
|
+
### setCacheEntry()
|
|
212
|
+
|
|
213
|
+
> `static` **setCacheEntry**\<`T`\>(`url`, `value`): `Promise`\<`void`\>
|
|
214
|
+
|
|
215
|
+
Set a cache entry.
|
|
216
|
+
|
|
217
|
+
#### Type Parameters
|
|
218
|
+
|
|
219
|
+
##### T
|
|
220
|
+
|
|
221
|
+
`T`
|
|
222
|
+
|
|
223
|
+
#### Parameters
|
|
224
|
+
|
|
225
|
+
##### url
|
|
226
|
+
|
|
227
|
+
`string`
|
|
228
|
+
|
|
229
|
+
The url for the request.
|
|
230
|
+
|
|
231
|
+
##### value
|
|
232
|
+
|
|
233
|
+
`T`
|
|
234
|
+
|
|
235
|
+
The value to cache.
|
|
236
|
+
|
|
237
|
+
#### Returns
|
|
238
|
+
|
|
239
|
+
`Promise`\<`void`\>
|
|
240
|
+
|
|
241
|
+
The cache entry if it exists.
|
|
242
|
+
|
|
243
|
+
***
|
|
244
|
+
|
|
171
245
|
### removeCacheEntry()
|
|
172
246
|
|
|
173
247
|
> `static` **removeCacheEntry**(`url`): `void`
|
|
@@ -176,7 +250,9 @@ Remove a cache entry.
|
|
|
176
250
|
|
|
177
251
|
#### Parameters
|
|
178
252
|
|
|
179
|
-
|
|
253
|
+
##### url
|
|
254
|
+
|
|
255
|
+
`string`
|
|
180
256
|
|
|
181
257
|
The url for the request.
|
|
182
258
|
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Class: Jwk
|
|
2
|
+
|
|
3
|
+
Class to handle JSON Web Keys.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
> **new Jwk**(): `Jwk`
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
`Jwk`
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### toCryptoKey()
|
|
18
|
+
|
|
19
|
+
> `static` **toCryptoKey**(`jwk`, `alg?`): `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
|
+
##### alg?
|
|
32
|
+
|
|
33
|
+
`string`
|
|
34
|
+
|
|
35
|
+
The alg to be used, defaults to jwk.alg.
|
|
36
|
+
|
|
37
|
+
#### Returns
|
|
38
|
+
|
|
39
|
+
`Promise`\<[`JwkCryptoKey`](../type-aliases/JwkCryptoKey.md)\>
|
|
40
|
+
|
|
41
|
+
The crypto key.
|
|
42
|
+
|
|
43
|
+
***
|
|
44
|
+
|
|
45
|
+
### fromEd25519Private()
|
|
46
|
+
|
|
47
|
+
> `static` **fromEd25519Private**(`privateKey`): `Promise`\<[`IJwk`](../interfaces/IJwk.md)\>
|
|
48
|
+
|
|
49
|
+
Convert the Ed25519 private key to a crypto key.
|
|
50
|
+
|
|
51
|
+
#### Parameters
|
|
52
|
+
|
|
53
|
+
##### privateKey
|
|
54
|
+
|
|
55
|
+
`Uint8Array`
|
|
56
|
+
|
|
57
|
+
The private key to use.
|
|
58
|
+
|
|
59
|
+
#### Returns
|
|
60
|
+
|
|
61
|
+
`Promise`\<[`IJwk`](../interfaces/IJwk.md)\>
|
|
62
|
+
|
|
63
|
+
The crypto key.
|
|
64
|
+
|
|
65
|
+
***
|
|
66
|
+
|
|
67
|
+
### fromEd25519Public()
|
|
68
|
+
|
|
69
|
+
> `static` **fromEd25519Public**(`publicKey`): `Promise`\<[`IJwk`](../interfaces/IJwk.md)\>
|
|
70
|
+
|
|
71
|
+
Convert the Ed25519 public key to a crypto key.
|
|
72
|
+
|
|
73
|
+
#### Parameters
|
|
74
|
+
|
|
75
|
+
##### publicKey
|
|
76
|
+
|
|
77
|
+
`Uint8Array`
|
|
78
|
+
|
|
79
|
+
The private key to use.
|
|
80
|
+
|
|
81
|
+
#### Returns
|
|
82
|
+
|
|
83
|
+
`Promise`\<[`IJwk`](../interfaces/IJwk.md)\>
|
|
84
|
+
|
|
85
|
+
The crypto key.
|
|
86
|
+
|
|
87
|
+
***
|
|
88
|
+
|
|
89
|
+
### toRaw()
|
|
90
|
+
|
|
91
|
+
> `static` **toRaw**(`jwk`): `Promise`\<\{ `publicKey?`: `Uint8Array`\<`ArrayBufferLike`\>; `privateKey?`: `Uint8Array`\<`ArrayBufferLike`\>; \}\>
|
|
92
|
+
|
|
93
|
+
Convert the JWK to raw keys.
|
|
94
|
+
|
|
95
|
+
#### Parameters
|
|
96
|
+
|
|
97
|
+
##### jwk
|
|
98
|
+
|
|
99
|
+
[`IJwk`](../interfaces/IJwk.md)
|
|
100
|
+
|
|
101
|
+
The JWK to convert to raw.
|
|
102
|
+
|
|
103
|
+
#### Returns
|
|
104
|
+
|
|
105
|
+
`Promise`\<\{ `publicKey?`: `Uint8Array`\<`ArrayBufferLike`\>; `privateKey?`: `Uint8Array`\<`ArrayBufferLike`\>; \}\>
|
|
106
|
+
|
|
107
|
+
The crypto key.
|
|
108
|
+
|
|
109
|
+
***
|
|
110
|
+
|
|
111
|
+
### generateKid()
|
|
112
|
+
|
|
113
|
+
> `static` **generateKid**(`jwk`): `Promise`\<`string`\>
|
|
114
|
+
|
|
115
|
+
Generate a KID for the JWK.
|
|
116
|
+
|
|
117
|
+
#### Parameters
|
|
118
|
+
|
|
119
|
+
##### jwk
|
|
120
|
+
|
|
121
|
+
[`IJwk`](../interfaces/IJwk.md)
|
|
122
|
+
|
|
123
|
+
The JWK to generate a KID for.
|
|
124
|
+
|
|
125
|
+
#### Returns
|
|
126
|
+
|
|
127
|
+
`Promise`\<`string`\>
|
|
128
|
+
|
|
129
|
+
The KID.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Class: Jws
|
|
2
|
+
|
|
3
|
+
Class to handle JSON Web Signatures.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
> **new Jws**(): `Jws`
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
`Jws`
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### create()
|
|
18
|
+
|
|
19
|
+
> `static` **create**(`privateKey`, `hash`, `algOverride?`): `Promise`\<`string`\>
|
|
20
|
+
|
|
21
|
+
Create a signature.
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
##### privateKey
|
|
26
|
+
|
|
27
|
+
[`JwkCryptoKey`](../type-aliases/JwkCryptoKey.md)
|
|
28
|
+
|
|
29
|
+
The private key to use.
|
|
30
|
+
|
|
31
|
+
##### hash
|
|
32
|
+
|
|
33
|
+
`Uint8Array`
|
|
34
|
+
|
|
35
|
+
The hash to sign.
|
|
36
|
+
|
|
37
|
+
##### algOverride?
|
|
38
|
+
|
|
39
|
+
`string`
|
|
40
|
+
|
|
41
|
+
An optional algorithm override.
|
|
42
|
+
|
|
43
|
+
#### Returns
|
|
44
|
+
|
|
45
|
+
`Promise`\<`string`\>
|
|
46
|
+
|
|
47
|
+
The signature.
|
|
48
|
+
|
|
49
|
+
***
|
|
50
|
+
|
|
51
|
+
### verify()
|
|
52
|
+
|
|
53
|
+
> `static` **verify**(`jws`, `publicKey`, `hash`): `Promise`\<`boolean`\>
|
|
54
|
+
|
|
55
|
+
Verify a signature.
|
|
56
|
+
|
|
57
|
+
#### Parameters
|
|
58
|
+
|
|
59
|
+
##### jws
|
|
60
|
+
|
|
61
|
+
`string`
|
|
62
|
+
|
|
63
|
+
The signature to verify.
|
|
64
|
+
|
|
65
|
+
##### publicKey
|
|
66
|
+
|
|
67
|
+
[`JwkCryptoKey`](../type-aliases/JwkCryptoKey.md)
|
|
68
|
+
|
|
69
|
+
The public key to verify the signature with.
|
|
70
|
+
|
|
71
|
+
##### hash
|
|
72
|
+
|
|
73
|
+
`Uint8Array`
|
|
74
|
+
|
|
75
|
+
The hash to verify.
|
|
76
|
+
|
|
77
|
+
#### Returns
|
|
78
|
+
|
|
79
|
+
`Promise`\<`boolean`\>
|
|
80
|
+
|
|
81
|
+
True if the signature was verified.
|