@twin.org/web 0.0.1-next.1

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.
Files changed (43) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +21 -0
  3. package/dist/cjs/index.cjs +1056 -0
  4. package/dist/esm/index.mjs +1046 -0
  5. package/dist/types/errors/fetchError.d.ts +22 -0
  6. package/dist/types/index.d.ts +14 -0
  7. package/dist/types/models/IFetchOptions.d.ts +30 -0
  8. package/dist/types/models/IHttpHeaders.d.ts +6 -0
  9. package/dist/types/models/IJwk.d.ts +62 -0
  10. package/dist/types/models/IJwtHeader.d.ts +22 -0
  11. package/dist/types/models/IJwtPayload.d.ts +37 -0
  12. package/dist/types/models/headerTypes.d.ts +41 -0
  13. package/dist/types/models/httpMethod.d.ts +18 -0
  14. package/dist/types/models/httpStatusCode.d.ts +257 -0
  15. package/dist/types/models/jwtAlgorithms.d.ts +17 -0
  16. package/dist/types/models/mimeTypes.d.ts +93 -0
  17. package/dist/types/utils/fetchHelper.d.ts +52 -0
  18. package/dist/types/utils/jwt.d.ts +85 -0
  19. package/dist/types/utils/mimeTypeHelper.d.ts +17 -0
  20. package/docs/changelog.md +5 -0
  21. package/docs/examples.md +1 -0
  22. package/docs/reference/classes/FetchError.md +379 -0
  23. package/docs/reference/classes/FetchHelper.md +185 -0
  24. package/docs/reference/classes/Jwt.md +313 -0
  25. package/docs/reference/classes/MimeTypeHelper.md +53 -0
  26. package/docs/reference/index.md +32 -0
  27. package/docs/reference/interfaces/IFetchOptions.md +53 -0
  28. package/docs/reference/interfaces/IHttpHeaders.md +7 -0
  29. package/docs/reference/interfaces/IJwk.md +111 -0
  30. package/docs/reference/interfaces/IJwtHeader.md +31 -0
  31. package/docs/reference/interfaces/IJwtPayload.md +63 -0
  32. package/docs/reference/type-aliases/HeaderTypes.md +5 -0
  33. package/docs/reference/type-aliases/HttpMethod.md +5 -0
  34. package/docs/reference/type-aliases/HttpStatusCode.md +5 -0
  35. package/docs/reference/type-aliases/JwtAlgorithms.md +5 -0
  36. package/docs/reference/type-aliases/MimeTypes.md +5 -0
  37. package/docs/reference/variables/HeaderTypes.md +55 -0
  38. package/docs/reference/variables/HttpMethod.md +43 -0
  39. package/docs/reference/variables/HttpStatusCode.md +379 -0
  40. package/docs/reference/variables/JwtAlgorithms.md +19 -0
  41. package/docs/reference/variables/MimeTypes.md +133 -0
  42. package/locales/en.json +18 -0
  43. package/package.json +65 -0
@@ -0,0 +1,55 @@
1
+ # Variable: HeaderTypes
2
+
3
+ > `const` **HeaderTypes**: `object`
4
+
5
+ Common http header types.
6
+
7
+ ## Type declaration
8
+
9
+ ### ContentType
10
+
11
+ > `readonly` **ContentType**: `"Content-Type"` = `"Content-Type"`
12
+
13
+ Content Type.
14
+
15
+ ### ContentLength
16
+
17
+ > `readonly` **ContentLength**: `"Content-Length"` = `"Content-Length"`
18
+
19
+ Content Length.
20
+
21
+ ### ContentDisposition
22
+
23
+ > `readonly` **ContentDisposition**: `"Content-Disposition"` = `"Content-Disposition"`
24
+
25
+ Content Disposition.
26
+
27
+ ### Accept
28
+
29
+ > `readonly` **Accept**: `"Accept"` = `"Accept"`
30
+
31
+ Accept.
32
+
33
+ ### Authorization
34
+
35
+ > `readonly` **Authorization**: `"Authorization"` = `"Authorization"`
36
+
37
+ Authorization.
38
+
39
+ ### Cookie
40
+
41
+ > `readonly` **Cookie**: `"Cookie"` = `"Cookie"`
42
+
43
+ Cookie.
44
+
45
+ ### SetCookie
46
+
47
+ > `readonly` **SetCookie**: `"Set-Cookie"` = `"Set-Cookie"`
48
+
49
+ Set Cookie.
50
+
51
+ ### Location
52
+
53
+ > `readonly` **Location**: `"Location"` = `"Location"`
54
+
55
+ Location
@@ -0,0 +1,43 @@
1
+ # Variable: HttpMethod
2
+
3
+ > `const` **HttpMethod**: `object`
4
+
5
+ The names of the HTTP Methods.
6
+
7
+ ## Type declaration
8
+
9
+ ### GET
10
+
11
+ > `readonly` **GET**: `"GET"` = `"GET"`
12
+
13
+ ### POST
14
+
15
+ > `readonly` **POST**: `"POST"` = `"POST"`
16
+
17
+ ### PUT
18
+
19
+ > `readonly` **PUT**: `"PUT"` = `"PUT"`
20
+
21
+ ### PATCH
22
+
23
+ > `readonly` **PATCH**: `"PATCH"` = `"PATCH"`
24
+
25
+ ### DELETE
26
+
27
+ > `readonly` **DELETE**: `"DELETE"` = `"DELETE"`
28
+
29
+ ### OPTIONS
30
+
31
+ > `readonly` **OPTIONS**: `"OPTIONS"` = `"OPTIONS"`
32
+
33
+ ### HEAD
34
+
35
+ > `readonly` **HEAD**: `"HEAD"` = `"HEAD"`
36
+
37
+ ### CONNECT
38
+
39
+ > `readonly` **CONNECT**: `"CONNECT"` = `"CONNECT"`
40
+
41
+ ### TRACE
42
+
43
+ > `readonly` **TRACE**: `"TRACE"` = `"TRACE"`
@@ -0,0 +1,379 @@
1
+ # Variable: HttpStatusCode
2
+
3
+ > `const` **HttpStatusCode**: `object`
4
+
5
+ Standard HTTP status codes.
6
+
7
+ ## Type declaration
8
+
9
+ ### continue
10
+
11
+ > `readonly` **continue**: `100` = `100`
12
+
13
+ Continue status code.
14
+
15
+ ### switchingProtocols
16
+
17
+ > `readonly` **switchingProtocols**: `101` = `101`
18
+
19
+ Switching Protocols status code.
20
+
21
+ ### processing
22
+
23
+ > `readonly` **processing**: `102` = `102`
24
+
25
+ Processing status code.
26
+
27
+ ### earlyHints
28
+
29
+ > `readonly` **earlyHints**: `103` = `103`
30
+
31
+ Early Hints status code.
32
+
33
+ ### ok
34
+
35
+ > `readonly` **ok**: `200` = `200`
36
+
37
+ OK status code.
38
+
39
+ ### created
40
+
41
+ > `readonly` **created**: `201` = `201`
42
+
43
+ Created status code.
44
+
45
+ ### accepted
46
+
47
+ > `readonly` **accepted**: `202` = `202`
48
+
49
+ Accepted status code.
50
+
51
+ ### nonAuthoritativeInformation
52
+
53
+ > `readonly` **nonAuthoritativeInformation**: `203` = `203`
54
+
55
+ Non-Authoritative Information status code.
56
+
57
+ ### noContent
58
+
59
+ > `readonly` **noContent**: `204` = `204`
60
+
61
+ No Content status code.
62
+
63
+ ### resetContent
64
+
65
+ > `readonly` **resetContent**: `205` = `205`
66
+
67
+ Reset Content status code.
68
+
69
+ ### partialContent
70
+
71
+ > `readonly` **partialContent**: `206` = `206`
72
+
73
+ Partial Content status code.
74
+
75
+ ### multiStatus
76
+
77
+ > `readonly` **multiStatus**: `207` = `207`
78
+
79
+ Multi-Status status code.
80
+
81
+ ### alreadyReported
82
+
83
+ > `readonly` **alreadyReported**: `208` = `208`
84
+
85
+ Already Reported status code.
86
+
87
+ ### imUsed
88
+
89
+ > `readonly` **imUsed**: `226` = `226`
90
+
91
+ IM Used status code.
92
+
93
+ ### multipleChoices
94
+
95
+ > `readonly` **multipleChoices**: `300` = `300`
96
+
97
+ Multiple Choices status code.
98
+
99
+ ### movedPermanently
100
+
101
+ > `readonly` **movedPermanently**: `301` = `301`
102
+
103
+ Moved Permanently status code.
104
+
105
+ ### found
106
+
107
+ > `readonly` **found**: `302` = `302`
108
+
109
+ Found status code.
110
+
111
+ ### seeOther
112
+
113
+ > `readonly` **seeOther**: `303` = `303`
114
+
115
+ See Other status code.
116
+
117
+ ### notModified
118
+
119
+ > `readonly` **notModified**: `304` = `304`
120
+
121
+ Not Modified status code.
122
+
123
+ ### useProxy
124
+
125
+ > `readonly` **useProxy**: `305` = `305`
126
+
127
+ Use Proxy status code.
128
+
129
+ ### temporaryRedirect
130
+
131
+ > `readonly` **temporaryRedirect**: `307` = `307`
132
+
133
+ Temporary Redirect status code.
134
+
135
+ ### permanentRedirect
136
+
137
+ > `readonly` **permanentRedirect**: `308` = `308`
138
+
139
+ Permanent Redirect status code.
140
+
141
+ ### badRequest
142
+
143
+ > `readonly` **badRequest**: `400` = `400`
144
+
145
+ Bad Request status code.
146
+
147
+ ### unauthorized
148
+
149
+ > `readonly` **unauthorized**: `401` = `401`
150
+
151
+ Unauthorized status code.
152
+
153
+ ### paymentRequired
154
+
155
+ > `readonly` **paymentRequired**: `402` = `402`
156
+
157
+ Payment Required status code.
158
+
159
+ ### forbidden
160
+
161
+ > `readonly` **forbidden**: `403` = `403`
162
+
163
+ Forbidden status code.
164
+
165
+ ### notFound
166
+
167
+ > `readonly` **notFound**: `404` = `404`
168
+
169
+ Not Found status code.
170
+
171
+ ### methodNotAllowed
172
+
173
+ > `readonly` **methodNotAllowed**: `405` = `405`
174
+
175
+ Method Not Allowed status code.
176
+
177
+ ### notAcceptable
178
+
179
+ > `readonly` **notAcceptable**: `406` = `406`
180
+
181
+ Not Acceptable status code.
182
+
183
+ ### proxyAuthenticationRequired
184
+
185
+ > `readonly` **proxyAuthenticationRequired**: `407` = `407`
186
+
187
+ Proxy Authentication Required status code.
188
+
189
+ ### requestTimeout
190
+
191
+ > `readonly` **requestTimeout**: `408` = `408`
192
+
193
+ Request Timeout status code.
194
+
195
+ ### conflict
196
+
197
+ > `readonly` **conflict**: `409` = `409`
198
+
199
+ Conflict status code.
200
+
201
+ ### gone
202
+
203
+ > `readonly` **gone**: `410` = `410`
204
+
205
+ Gone status code.
206
+
207
+ ### lengthRequired
208
+
209
+ > `readonly` **lengthRequired**: `411` = `411`
210
+
211
+ Length Required status code.
212
+
213
+ ### preconditionFailed
214
+
215
+ > `readonly` **preconditionFailed**: `412` = `412`
216
+
217
+ Precondition Failed status code.
218
+
219
+ ### payloadTooLarge
220
+
221
+ > `readonly` **payloadTooLarge**: `413` = `413`
222
+
223
+ Payload Too Large status code.
224
+
225
+ ### uriTooLong
226
+
227
+ > `readonly` **uriTooLong**: `414` = `414`
228
+
229
+ URI Too Long status code.
230
+
231
+ ### unsupportedMediaType
232
+
233
+ > `readonly` **unsupportedMediaType**: `415` = `415`
234
+
235
+ Unsupported Media Type status code.
236
+
237
+ ### rangeNotSatisfiable
238
+
239
+ > `readonly` **rangeNotSatisfiable**: `416` = `416`
240
+
241
+ Range Not Satisfiable status code.
242
+
243
+ ### expectationFailed
244
+
245
+ > `readonly` **expectationFailed**: `417` = `417`
246
+
247
+ Expectation Failed status code.
248
+
249
+ ### imATeapot
250
+
251
+ > `readonly` **imATeapot**: `418` = `418`
252
+
253
+ I'm a Teapot status code.
254
+
255
+ ### misdirectedRequest
256
+
257
+ > `readonly` **misdirectedRequest**: `421` = `421`
258
+
259
+ Misdirected Request status code.
260
+
261
+ ### unprocessableEntity
262
+
263
+ > `readonly` **unprocessableEntity**: `422` = `422`
264
+
265
+ Unprocessable Entity status code.
266
+
267
+ ### locked
268
+
269
+ > `readonly` **locked**: `423` = `423`
270
+
271
+ Locked status code.
272
+
273
+ ### failedDependency
274
+
275
+ > `readonly` **failedDependency**: `424` = `424`
276
+
277
+ Failed Dependency status code.
278
+
279
+ ### tooEarly
280
+
281
+ > `readonly` **tooEarly**: `425` = `425`
282
+
283
+ Too Early status code.
284
+
285
+ ### upgradeRequired
286
+
287
+ > `readonly` **upgradeRequired**: `426` = `426`
288
+
289
+ Upgrade Required status code.
290
+
291
+ ### preconditionRequired
292
+
293
+ > `readonly` **preconditionRequired**: `428` = `428`
294
+
295
+ Precondition Required status code.
296
+
297
+ ### tooManyRequests
298
+
299
+ > `readonly` **tooManyRequests**: `429` = `429`
300
+
301
+ Too Many Requests status code.
302
+
303
+ ### requestHeaderFieldsTooLarge
304
+
305
+ > `readonly` **requestHeaderFieldsTooLarge**: `431` = `431`
306
+
307
+ Request Header Fields Too Large status code.
308
+
309
+ ### unavailableForLegalReasons
310
+
311
+ > `readonly` **unavailableForLegalReasons**: `451` = `451`
312
+
313
+ Unavailable For Legal Reasons status code.
314
+
315
+ ### internalServerError
316
+
317
+ > `readonly` **internalServerError**: `500` = `500`
318
+
319
+ Internal Server Error status code.
320
+
321
+ ### notImplemented
322
+
323
+ > `readonly` **notImplemented**: `501` = `501`
324
+
325
+ Not Implemented status code.
326
+
327
+ ### badGateway
328
+
329
+ > `readonly` **badGateway**: `502` = `502`
330
+
331
+ Bad Gateway status code.
332
+
333
+ ### serviceUnavailable
334
+
335
+ > `readonly` **serviceUnavailable**: `503` = `503`
336
+
337
+ Service Unavailable status code.
338
+
339
+ ### gatewayTimeout
340
+
341
+ > `readonly` **gatewayTimeout**: `504` = `504`
342
+
343
+ Gateway Timeout status code.
344
+
345
+ ### httpVersionNotSupported
346
+
347
+ > `readonly` **httpVersionNotSupported**: `505` = `505`
348
+
349
+ HTTP Version Not Supported status code.
350
+
351
+ ### variantAlsoNegotiates
352
+
353
+ > `readonly` **variantAlsoNegotiates**: `506` = `506`
354
+
355
+ Variant Also Negotiates status code.
356
+
357
+ ### insufficientStorage
358
+
359
+ > `readonly` **insufficientStorage**: `507` = `507`
360
+
361
+ Insufficient Storage status code.
362
+
363
+ ### loopDetected
364
+
365
+ > `readonly` **loopDetected**: `508` = `508`
366
+
367
+ Loop Detected status code.
368
+
369
+ ### notExtended
370
+
371
+ > `readonly` **notExtended**: `510` = `510`
372
+
373
+ Not Extended status code.
374
+
375
+ ### networkAuthenticationRequired
376
+
377
+ > `readonly` **networkAuthenticationRequired**: `511` = `511`
378
+
379
+ Network Authentication Required status code.
@@ -0,0 +1,19 @@
1
+ # Variable: JwtAlgorithms
2
+
3
+ > `const` **JwtAlgorithms**: `object`
4
+
5
+ The cryptographic algorithms supported for JSON Web Tokens and JSON Web Keys.
6
+
7
+ ## Type declaration
8
+
9
+ ### HS256
10
+
11
+ > `readonly` **HS256**: `"HS256"` = `"HS256"`
12
+
13
+ HMAC using SHA-256.
14
+
15
+ ### EdDSA
16
+
17
+ > `readonly` **EdDSA**: `"EdDSA"` = `"EdDSA"`
18
+
19
+ EdDSA using Ed25519.
@@ -0,0 +1,133 @@
1
+ # Variable: MimeTypes
2
+
3
+ > `const` **MimeTypes**: `object`
4
+
5
+ Common mime types.
6
+
7
+ ## Type declaration
8
+
9
+ ### PlainText
10
+
11
+ > `readonly` **PlainText**: `"text/plain"` = `"text/plain"`
12
+
13
+ Plaint Text - text/plain
14
+
15
+ ### Html
16
+
17
+ > `readonly` **Html**: `"text/html"` = `"text/html"`
18
+
19
+ HTML - text/html
20
+
21
+ ### Javascript
22
+
23
+ > `readonly` **Javascript**: `"text/javascript"` = `"text/javascript"`
24
+
25
+ Javascript - text/javascript
26
+
27
+ ### Json
28
+
29
+ > `readonly` **Json**: `"application/json"` = `"application/json"`
30
+
31
+ JSON - application/json
32
+
33
+ ### JsonLd
34
+
35
+ > `readonly` **JsonLd**: `"application/ld+json"` = `"application/ld+json"`
36
+
37
+ JSON-LD - application/ld+json
38
+
39
+ ### Xml
40
+
41
+ > `readonly` **Xml**: `"application/xml"` = `"application/xml"`
42
+
43
+ XML - application/xml
44
+
45
+ ### OctetStream
46
+
47
+ > `readonly` **OctetStream**: `"application/octet-stream"` = `"application/octet-stream"`
48
+
49
+ Application Octet Stream, arbitrary binary - application/octet-stream
50
+
51
+ ### Gzip
52
+
53
+ > `readonly` **Gzip**: `"application/gzip"` = `"application/gzip"`
54
+
55
+ Application GZIP - application/gzip
56
+
57
+ ### Bzip2
58
+
59
+ > `readonly` **Bzip2**: `"application/x-bzip2"` = `"application/x-bzip2"`
60
+
61
+ Application BZIP2 - application/x-bzip2
62
+
63
+ ### Zip
64
+
65
+ > `readonly` **Zip**: `"application/zip"` = `"application/zip"`
66
+
67
+ Application ZIP - application/zip
68
+
69
+ ### Pdf
70
+
71
+ > `readonly` **Pdf**: `"application/pdf"` = `"application/pdf"`
72
+
73
+ Application PDF - application/pdf
74
+
75
+ ### Gif
76
+
77
+ > `readonly` **Gif**: `"image/gif"` = `"image/gif"`
78
+
79
+ Image GIF - image/gif
80
+
81
+ ### Bmp
82
+
83
+ > `readonly` **Bmp**: `"image/bmp"` = `"image/bmp"`
84
+
85
+ Image BMP - image/bmp
86
+
87
+ ### Jpeg
88
+
89
+ > `readonly` **Jpeg**: `"image/jpeg"` = `"image/jpeg"`
90
+
91
+ Image JPEG - image/jpeg
92
+
93
+ ### Png
94
+
95
+ > `readonly` **Png**: `"image/png"` = `"image/png"`
96
+
97
+ Image PNG - image/png
98
+
99
+ ### Tiff
100
+
101
+ > `readonly` **Tiff**: `"image/tiff"` = `"image/tiff"`
102
+
103
+ Image Tiff - image/tiff
104
+
105
+ ### Svg
106
+
107
+ > `readonly` **Svg**: `"image/svg+xml"` = `"image/svg+xml"`
108
+
109
+ Image SVG - image/svg+xml
110
+
111
+ ### WebP
112
+
113
+ > `readonly` **WebP**: `"image/webp"` = `"image/webp"`
114
+
115
+ Image WEBP - image/webp
116
+
117
+ ### Mp4
118
+
119
+ > `readonly` **Mp4**: `"video/mp4"` = `"video/mp4"`
120
+
121
+ Video MP4 - video/mp4
122
+
123
+ ### Mpeg
124
+
125
+ > `readonly` **Mpeg**: `"video/mpeg"` = `"video/mpeg"`
126
+
127
+ Audio/Video MPEG - video/mpeg
128
+
129
+ ### Webm
130
+
131
+ > `readonly` **Webm**: `"video/webm"` = `"video/webm"`
132
+
133
+ Video WEBM - video/webm
@@ -0,0 +1,18 @@
1
+ {
2
+ "error": {
3
+ "fetchHelper": {
4
+ "decodingJSON": "Decoding JSON failed for route \"{route}\"",
5
+ "failureStatusText": "The request to the API failed: \"{statusText}\"",
6
+ "connectivity": "The request failed, the API could be offline, or there are other connectivity issues",
7
+ "timeout": "The request timed out",
8
+ "general": "A general failure occurred during the request"
9
+ },
10
+ "jwt": {
11
+ "noKeyOrSigner": "No key or signer was provided for JWT creation",
12
+ "noKeyOrVerifier": "No key or verifier was provided for JWT creation"
13
+ }
14
+ },
15
+ "errorMessages": {
16
+ "fetch": "Fetch"
17
+ }
18
+ }
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@twin.org/web",
3
+ "version": "0.0.1-next.1",
4
+ "description": "Contains classes for use with web operations",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/framework.git",
8
+ "directory": "packages/web"
9
+ },
10
+ "author": "martyn.janes@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=20.0.0"
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
+ "dependencies": {
30
+ "@twin.org/core": "0.0.1-next.1",
31
+ "@twin.org/crypto": "0.0.1-next.1",
32
+ "@twin.org/nameof": "next"
33
+ },
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
+ "main": "./dist/cjs/index.cjs",
49
+ "module": "./dist/esm/index.mjs",
50
+ "types": "./dist/types/index.d.ts",
51
+ "exports": {
52
+ ".": {
53
+ "require": "./dist/cjs/index.cjs",
54
+ "import": "./dist/esm/index.mjs",
55
+ "types": "./dist/types/index.d.ts"
56
+ }
57
+ },
58
+ "files": [
59
+ "dist/cjs",
60
+ "dist/esm",
61
+ "dist/types",
62
+ "locales",
63
+ "docs"
64
+ ]
65
+ }