@twin.org/web 0.0.1-next.3 → 0.0.1-next.31

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.
@@ -28,15 +28,21 @@ Encode a token.
28
28
 
29
29
  #### Parameters
30
30
 
31
- **header**: `U`
31
+ ##### header
32
+
33
+ `U`
32
34
 
33
35
  The header to encode.
34
36
 
35
- **payload**: `T`
37
+ ##### payload
38
+
39
+ `T`
36
40
 
37
41
  The payload to encode.
38
42
 
39
- **key**: `Uint8Array`
43
+ ##### key
44
+
45
+ `Uint8Array`
40
46
 
41
47
  The key for signing the token, can be omitted if a signer is provided.
42
48
 
@@ -62,15 +68,21 @@ Encode a token.
62
68
 
63
69
  #### Parameters
64
70
 
65
- **header**: `U`
71
+ ##### header
72
+
73
+ `U`
66
74
 
67
75
  The header to encode.
68
76
 
69
- **payload**: `T`
77
+ ##### payload
78
+
79
+ `T`
70
80
 
71
81
  The payload to encode.
72
82
 
73
- **signer**
83
+ ##### signer
84
+
85
+ (`alg`, `key`, `payload`) => `Promise`\<`Uint8Array`\>
74
86
 
75
87
  Custom signer method.
76
88
 
@@ -84,7 +96,7 @@ The encoded token.
84
96
 
85
97
  ### decode()
86
98
 
87
- > `static` **decode**\<`U`, `T`\>(`token`): `Promise`\<`object`\>
99
+ > `static` **decode**\<`U`, `T`\>(`token`): `Promise`\<\{ `header`: `U`; `payload`: `T`; `signature`: `Uint8Array`; \}\>
88
100
 
89
101
  Decode a token.
90
102
 
@@ -96,33 +108,23 @@ Decode a token.
96
108
 
97
109
  #### Parameters
98
110
 
99
- **token**: `string`
111
+ ##### token
112
+
113
+ `string`
100
114
 
101
115
  The token to decode.
102
116
 
103
117
  #### Returns
104
118
 
105
- `Promise`\<`object`\>
119
+ `Promise`\<\{ `header`: `U`; `payload`: `T`; `signature`: `Uint8Array`; \}\>
106
120
 
107
121
  The decoded payload.
108
122
 
109
- ##### header?
110
-
111
- > `optional` **header**: `U`
112
-
113
- ##### payload?
114
-
115
- > `optional` **payload**: `T`
116
-
117
- ##### signature?
118
-
119
- > `optional` **signature**: `Uint8Array`
120
-
121
123
  ***
122
124
 
123
125
  ### verify()
124
126
 
125
- > `static` **verify**\<`U`, `T`\>(`token`, `key`): `Promise`\<`object`\>
127
+ > `static` **verify**\<`U`, `T`\>(`token`, `key`): `Promise`\<\{ `verified`: `boolean`; `header`: `U`; `payload`: `T`; `signature`: `Uint8Array`; \}\>
126
128
 
127
129
  Verify a token.
128
130
 
@@ -134,41 +136,29 @@ Verify a token.
134
136
 
135
137
  #### Parameters
136
138
 
137
- **token**: `string`
139
+ ##### token
140
+
141
+ `string`
138
142
 
139
143
  The token to verify.
140
144
 
141
- **key**: `Uint8Array`
145
+ ##### key
146
+
147
+ `Uint8Array`
142
148
 
143
149
  The key for verifying the token
144
150
 
145
151
  #### Returns
146
152
 
147
- `Promise`\<`object`\>
153
+ `Promise`\<\{ `verified`: `boolean`; `header`: `U`; `payload`: `T`; `signature`: `Uint8Array`; \}\>
148
154
 
149
155
  The decoded payload.
150
156
 
151
- ##### verified
152
-
153
- > **verified**: `boolean`
154
-
155
- ##### header?
156
-
157
- > `optional` **header**: `U`
158
-
159
- ##### payload?
160
-
161
- > `optional` **payload**: `T`
162
-
163
- ##### signature?
164
-
165
- > `optional` **signature**: `Uint8Array`
166
-
167
157
  ***
168
158
 
169
159
  ### verifyWithVerifier()
170
160
 
171
- > `static` **verifyWithVerifier**\<`U`, `T`\>(`token`, `verifier`): `Promise`\<`object`\>
161
+ > `static` **verifyWithVerifier**\<`U`, `T`\>(`token`, `verifier`): `Promise`\<\{ `verified`: `boolean`; `header`: `U`; `payload`: `T`; `signature`: `Uint8Array`; \}\>
172
162
 
173
163
  Verify a token.
174
164
 
@@ -180,36 +170,24 @@ Verify a token.
180
170
 
181
171
  #### Parameters
182
172
 
183
- **token**: `string`
173
+ ##### token
174
+
175
+ `string`
184
176
 
185
177
  The token to verify.
186
178
 
187
- **verifier**
179
+ ##### verifier
180
+
181
+ (`alg`, `key`, `payload`, `signature`) => `Promise`\<`boolean`\>
188
182
 
189
183
  Custom verification method.
190
184
 
191
185
  #### Returns
192
186
 
193
- `Promise`\<`object`\>
187
+ `Promise`\<\{ `verified`: `boolean`; `header`: `U`; `payload`: `T`; `signature`: `Uint8Array`; \}\>
194
188
 
195
189
  The decoded payload.
196
190
 
197
- ##### verified
198
-
199
- > **verified**: `boolean`
200
-
201
- ##### header?
202
-
203
- > `optional` **header**: `U`
204
-
205
- ##### payload?
206
-
207
- > `optional` **payload**: `T`
208
-
209
- ##### signature?
210
-
211
- > `optional` **signature**: `Uint8Array`
212
-
213
191
  ***
214
192
 
215
193
  ### verifySignature()
@@ -226,23 +204,33 @@ Verify a token by parts.
226
204
 
227
205
  #### Parameters
228
206
 
229
- **header?**: `U`
207
+ ##### header?
208
+
209
+ `U`
230
210
 
231
211
  The header to verify.
232
212
 
233
- **payload?**: `T`
213
+ ##### payload?
214
+
215
+ `T`
234
216
 
235
217
  The payload to verify.
236
218
 
237
- **signature?**: `Uint8Array`
219
+ ##### signature?
220
+
221
+ `Uint8Array`
238
222
 
239
223
  The signature to verify.
240
224
 
241
- **key?**: `Uint8Array`
225
+ ##### key?
226
+
227
+ `Uint8Array`
242
228
 
243
229
  The key for verifying the token, if not provided no verification occurs.
244
230
 
245
- **verifier?**
231
+ ##### verifier?
232
+
233
+ (`alg`, `key`, `payload`, `signature`) => `Promise`\<`boolean`\>
246
234
 
247
235
  Custom verification method.
248
236
 
@@ -262,15 +250,21 @@ The default signer for the JWT.
262
250
 
263
251
  #### Parameters
264
252
 
265
- **alg**: [`JwtAlgorithms`](../type-aliases/JwtAlgorithms.md)
253
+ ##### alg
254
+
255
+ [`JwtAlgorithms`](../type-aliases/JwtAlgorithms.md)
266
256
 
267
257
  The algorithm to use.
268
258
 
269
- **key**: `undefined` \| `Uint8Array`
259
+ ##### key
270
260
 
271
261
  The key to sign with.
272
262
 
273
- **payload**: `Uint8Array`
263
+ `undefined` | `Uint8Array`
264
+
265
+ ##### payload
266
+
267
+ `Uint8Array`
274
268
 
275
269
  The payload to sign.
276
270
 
@@ -290,19 +284,27 @@ The default verifier for the JWT.
290
284
 
291
285
  #### Parameters
292
286
 
293
- **alg**: [`JwtAlgorithms`](../type-aliases/JwtAlgorithms.md)
287
+ ##### alg
288
+
289
+ [`JwtAlgorithms`](../type-aliases/JwtAlgorithms.md)
294
290
 
295
291
  The algorithm to use.
296
292
 
297
- **key**: `undefined` \| `Uint8Array`
293
+ ##### key
298
294
 
299
295
  The key to verify with.
300
296
 
301
- **payload**: `Uint8Array`
297
+ `undefined` | `Uint8Array`
298
+
299
+ ##### payload
300
+
301
+ `Uint8Array`
302
302
 
303
303
  The payload to verify.
304
304
 
305
- **signature**: `Uint8Array`
305
+ ##### signature
306
+
307
+ `Uint8Array`
306
308
 
307
309
  The signature to verify.
308
310
 
@@ -22,7 +22,9 @@ Detect the mime type from a byte array.
22
22
 
23
23
  #### Parameters
24
24
 
25
- **data**: `Uint8Array`
25
+ ##### data
26
+
27
+ `Uint8Array`
26
28
 
27
29
  The data to test.
28
30
 
@@ -42,10 +44,12 @@ Return the default extension for a mime type.
42
44
 
43
45
  #### Parameters
44
46
 
45
- **mimeType**: `undefined` \| `string`
47
+ ##### mimeType
46
48
 
47
49
  The mimetype to get the extension for.
48
50
 
51
+ `undefined` | `string`
52
+
49
53
  #### Returns
50
54
 
51
55
  `undefined` \| `string`
@@ -4,4 +4,4 @@ Model used for Http headers parameter.
4
4
 
5
5
  ## Indexable
6
6
 
7
- \[`key`: `string`\]: `string` \| `string`[]
7
+ \[`key`: `string`\]: `string` \| `string`[]
@@ -4,7 +4,7 @@ The fields in a JSON Web Key.
4
4
 
5
5
  ## Indexable
6
6
 
7
- \[`key`: `string`\]: `unknown`
7
+ \[`key`: `string`\]: `unknown`
8
8
 
9
9
  ## Properties
10
10
 
@@ -4,7 +4,7 @@ The fields in a JSON Web Token header.
4
4
 
5
5
  ## Indexable
6
6
 
7
- \[`key`: `string`\]: `unknown`
7
+ \[`key`: `string`\]: `unknown`
8
8
 
9
9
  ## Properties
10
10
 
@@ -4,7 +4,7 @@ The fields in a JSON Web Token payload.
4
4
 
5
5
  ## Indexable
6
6
 
7
- \[`key`: `string`\]: `unknown`
7
+ \[`key`: `string`\]: `unknown`
8
8
 
9
9
  ## Properties
10
10
 
@@ -8,48 +8,48 @@ Common http header types.
8
8
 
9
9
  ### ContentType
10
10
 
11
- > `readonly` **ContentType**: `"Content-Type"` = `"Content-Type"`
11
+ > `readonly` **ContentType**: `"content-type"` = `"content-type"`
12
12
 
13
13
  Content Type.
14
14
 
15
15
  ### ContentLength
16
16
 
17
- > `readonly` **ContentLength**: `"Content-Length"` = `"Content-Length"`
17
+ > `readonly` **ContentLength**: `"content-length"` = `"content-length"`
18
18
 
19
19
  Content Length.
20
20
 
21
21
  ### ContentDisposition
22
22
 
23
- > `readonly` **ContentDisposition**: `"Content-Disposition"` = `"Content-Disposition"`
23
+ > `readonly` **ContentDisposition**: `"content-disposition"` = `"content-disposition"`
24
24
 
25
25
  Content Disposition.
26
26
 
27
27
  ### Accept
28
28
 
29
- > `readonly` **Accept**: `"Accept"` = `"Accept"`
29
+ > `readonly` **Accept**: `"accept"` = `"accept"`
30
30
 
31
31
  Accept.
32
32
 
33
33
  ### Authorization
34
34
 
35
- > `readonly` **Authorization**: `"Authorization"` = `"Authorization"`
35
+ > `readonly` **Authorization**: `"authorization"` = `"authorization"`
36
36
 
37
37
  Authorization.
38
38
 
39
39
  ### Cookie
40
40
 
41
- > `readonly` **Cookie**: `"Cookie"` = `"Cookie"`
41
+ > `readonly` **Cookie**: `"cookie"` = `"cookie"`
42
42
 
43
43
  Cookie.
44
44
 
45
45
  ### SetCookie
46
46
 
47
- > `readonly` **SetCookie**: `"Set-Cookie"` = `"Set-Cookie"`
47
+ > `readonly` **SetCookie**: `"set-cookie"` = `"set-cookie"`
48
48
 
49
49
  Set Cookie.
50
50
 
51
51
  ### Location
52
52
 
53
- > `readonly` **Location**: `"Location"` = `"Location"`
53
+ > `readonly` **Location**: `"location"` = `"location"`
54
54
 
55
55
  Location
@@ -36,6 +36,12 @@ JSON - application/json
36
36
 
37
37
  JSON-LD - application/ld+json
38
38
 
39
+ ### Jwt
40
+
41
+ > `readonly` **Jwt**: `"application/jwt"` = `"application/jwt"`
42
+
43
+ JWT - application/jwt
44
+
39
45
  ### Xml
40
46
 
41
47
  > `readonly` **Xml**: `"application/xml"` = `"application/xml"`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/web",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.31",
4
4
  "description": "Contains classes for use with web operations",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,46 +13,19 @@
13
13
  "engines": {
14
14
  "node": ">=20.0.0"
15
15
  },
16
- "scripts": {
17
- "clean": "rimraf dist coverage",
18
- "build": "tspc",
19
- "test": "vitest --run --config ./vitest.config.ts --no-cache",
20
- "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
21
- "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
22
- "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
23
- "bundle": "npm run bundle:esm && npm run bundle:cjs",
24
- "docs:clean": "rimraf docs/reference",
25
- "docs:generate": "typedoc",
26
- "docs": "npm run docs:clean && npm run docs:generate",
27
- "dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
28
- },
29
16
  "dependencies": {
30
- "@twin.org/core": "0.0.1-next.3",
31
- "@twin.org/crypto": "0.0.1-next.3",
17
+ "@twin.org/core": "0.0.1-next.31",
18
+ "@twin.org/crypto": "0.0.1-next.31",
32
19
  "@twin.org/nameof": "next"
33
20
  },
34
- "devDependencies": {
35
- "@twin.org/nameof-transformer": "next",
36
- "@types/node": "22.5.5",
37
- "@vitest/coverage-v8": "2.1.1",
38
- "copyfiles": "2.4.1",
39
- "rimraf": "6.0.1",
40
- "rollup": "4.21.3",
41
- "rollup-plugin-typescript2": "0.36.0",
42
- "ts-patch": "3.2.1",
43
- "typedoc": "0.26.7",
44
- "typedoc-plugin-markdown": "4.2.7",
45
- "typescript": "5.6.2",
46
- "vitest": "2.1.1"
47
- },
48
21
  "main": "./dist/cjs/index.cjs",
49
22
  "module": "./dist/esm/index.mjs",
50
23
  "types": "./dist/types/index.d.ts",
51
24
  "exports": {
52
25
  ".": {
26
+ "types": "./dist/types/index.d.ts",
53
27
  "require": "./dist/cjs/index.cjs",
54
- "import": "./dist/esm/index.mjs",
55
- "types": "./dist/types/index.d.ts"
28
+ "import": "./dist/esm/index.mjs"
56
29
  }
57
30
  },
58
31
  "files": [