@twin.org/web 0.0.3-next.2 → 0.0.3-next.21

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 (33) hide show
  1. package/dist/es/index.js +1 -0
  2. package/dist/es/index.js.map +1 -1
  3. package/dist/es/models/headerTypes.js +129 -1
  4. package/dist/es/models/headerTypes.js.map +1 -1
  5. package/dist/es/models/httpMethod.js +36 -0
  6. package/dist/es/models/httpMethod.js.map +1 -1
  7. package/dist/es/models/httpStatusCode.js +63 -0
  8. package/dist/es/models/httpStatusCode.js.map +1 -1
  9. package/dist/es/models/mimeTypes.js +170 -1
  10. package/dist/es/models/mimeTypes.js.map +1 -1
  11. package/dist/es/utils/cookieHelper.js +83 -0
  12. package/dist/es/utils/cookieHelper.js.map +1 -0
  13. package/dist/es/utils/headerHelper.js +135 -1
  14. package/dist/es/utils/headerHelper.js.map +1 -1
  15. package/dist/es/utils/mimeTypeHelper.js +42 -1
  16. package/dist/es/utils/mimeTypeHelper.js.map +1 -1
  17. package/dist/types/index.d.ts +1 -0
  18. package/dist/types/models/headerTypes.d.ts +128 -0
  19. package/dist/types/models/httpMethod.d.ts +36 -0
  20. package/dist/types/models/httpStatusCode.d.ts +63 -0
  21. package/dist/types/models/mimeTypes.d.ts +169 -0
  22. package/dist/types/utils/cookieHelper.d.ts +49 -0
  23. package/dist/types/utils/headerHelper.d.ts +67 -0
  24. package/docs/changelog.md +431 -0
  25. package/docs/reference/classes/CookieHelper.md +155 -0
  26. package/docs/reference/classes/HeaderHelper.md +136 -0
  27. package/docs/reference/index.md +1 -0
  28. package/docs/reference/variables/HeaderTypes.md +272 -0
  29. package/docs/reference/variables/HttpMethod.md +54 -0
  30. package/docs/reference/variables/HttpStatusCode.md +252 -0
  31. package/docs/reference/variables/MimeTypes.md +256 -0
  32. package/locales/en.json +4 -0
  33. package/package.json +4 -4
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
3
  /**
4
4
  * Common mime types.
5
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
5
6
  */
6
7
  // eslint-disable-next-line @typescript-eslint/naming-convention
7
8
  export const MimeTypes = {
@@ -9,30 +10,138 @@ export const MimeTypes = {
9
10
  * Plaint Text - text/plain
10
11
  */
11
12
  PlainText: "text/plain",
13
+ /**
14
+ * Event Stream - text/event-stream
15
+ */
16
+ EventStream: "text/event-stream",
12
17
  /**
13
18
  * HTML - text/html
14
19
  */
15
20
  Html: "text/html",
21
+ /**
22
+ * CSS - text/css
23
+ */
24
+ Css: "text/css",
16
25
  /**
17
26
  * Javascript - text/javascript
18
27
  */
19
28
  Javascript: "text/javascript",
29
+ /**
30
+ * Markdown - text/markdown
31
+ */
32
+ Markdown: "text/markdown",
20
33
  /**
21
34
  * JSON - application/json
22
35
  */
23
36
  Json: "application/json",
37
+ /**
38
+ * Problem JSON - application/problem+json
39
+ */
40
+ ProblemJson: "application/problem+json",
24
41
  /**
25
42
  * JSON-LD - application/ld+json
26
43
  */
27
44
  JsonLd: "application/ld+json",
45
+ /**
46
+ * Activity Streams - application/activity+json
47
+ */
48
+ ActivityStreams: "application/activity+json",
49
+ /**
50
+ * WebFinger JRD - application/jrd+json
51
+ */
52
+ JrdJson: "application/jrd+json",
28
53
  /**
29
54
  * JWT - application/jwt
30
55
  */
31
56
  Jwt: "application/jwt",
57
+ /**
58
+ * Access Token JWT - application/at+jwt
59
+ */
60
+ AccessTokenJwt: "application/at+jwt",
61
+ /**
62
+ * JOSE (Compact Serialization) - application/jose
63
+ */
64
+ Jose: "application/jose",
65
+ /**
66
+ * JOSE (JSON Serialization) - application/jose+json
67
+ */
68
+ JoseJson: "application/jose+json",
69
+ /**
70
+ * JSON Web Key (JWK) - application/jwk+json
71
+ */
72
+ JwkJson: "application/jwk+json",
73
+ /**
74
+ * JSON Web Key Set (JWKS) - application/jwk-set+json
75
+ */
76
+ JwkSetJson: "application/jwk-set+json",
77
+ /**
78
+ * Decentralized Identifier (DID) - application/did+json
79
+ */
80
+ DidJson: "application/did+json",
81
+ /**
82
+ * Decentralized Identifier (DID) (JSON-LD) - application/did+ld+json
83
+ */
84
+ DidLdJson: "application/did+ld+json",
85
+ /**
86
+ * Verifiable Credential (JSON-LD) - application/vc+ld+json
87
+ */
88
+ VerifiableCredentialLdJson: "application/vc+ld+json",
89
+ /**
90
+ * Verifiable Presentation (JSON-LD) - application/vp+ld+json
91
+ */
92
+ VerifiablePresentationLdJson: "application/vp+ld+json",
93
+ /**
94
+ * Verifiable Credential (JWT) - application/vc+jwt
95
+ */
96
+ VerifiableCredentialJwt: "application/vc+jwt",
97
+ /**
98
+ * Verifiable Presentation (JWT) - application/vp+jwt
99
+ */
100
+ VerifiablePresentationJwt: "application/vp+jwt",
101
+ /**
102
+ * JSON Patch - application/json-patch+json
103
+ */
104
+ JsonPatch: "application/json-patch+json",
105
+ /**
106
+ * JSON Merge Patch - application/merge-patch+json
107
+ */
108
+ MergePatch: "application/merge-patch+json",
109
+ /**
110
+ * CBOR Web Token (CWT) - application/cwt
111
+ */
112
+ Cwt: "application/cwt",
113
+ /**
114
+ * COSE - application/cose
115
+ */
116
+ Cose: "application/cose",
117
+ /**
118
+ * COSE Key - application/cose-key
119
+ */
120
+ CoseKey: "application/cose-key",
121
+ /**
122
+ * COSE Key Set - application/cose-key-set
123
+ */
124
+ CoseKeySet: "application/cose-key-set",
125
+ /**
126
+ * Form URL Encoded - application/x-www-form-urlencoded
127
+ */
128
+ FormUrlEncoded: "application/x-www-form-urlencoded",
129
+ /**
130
+ * Multipart Form Data - multipart/form-data
131
+ */
132
+ MultipartFormData: "multipart/form-data",
32
133
  /**
33
134
  * XML - application/xml
34
135
  */
35
136
  Xml: "application/xml",
137
+ /**
138
+ * WASM - application/wasm
139
+ */
140
+ Wasm: "application/wasm",
141
+ /**
142
+ * Web App Manifest - application/manifest+json
143
+ */
144
+ WebManifest: "application/manifest+json",
36
145
  /**
37
146
  * Application Octet Stream, arbitrary binary - application/octet-stream
38
147
  */
@@ -81,10 +190,62 @@ export const MimeTypes = {
81
190
  * Image SVG - image/svg+xml
82
191
  */
83
192
  Svg: "image/svg+xml",
193
+ /**
194
+ * Image ICO - image/x-icon
195
+ */
196
+ Ico: "image/x-icon",
84
197
  /**
85
198
  * Image WEBP - image/webp
86
199
  */
87
200
  WebP: "image/webp",
201
+ /**
202
+ * Image AVIF - image/avif
203
+ */
204
+ Avif: "image/avif",
205
+ /**
206
+ * Image APNG - image/apng
207
+ */
208
+ Apng: "image/apng",
209
+ /**
210
+ * Font WOFF - font/woff
211
+ */
212
+ Woff: "font/woff",
213
+ /**
214
+ * Font WOFF2 - font/woff2
215
+ */
216
+ Woff2: "font/woff2",
217
+ /**
218
+ * Font TTF - font/ttf
219
+ */
220
+ Ttf: "font/ttf",
221
+ /**
222
+ * Font OTF - font/otf
223
+ */
224
+ Otf: "font/otf",
225
+ /**
226
+ * Audio MP3 - audio/mpeg
227
+ */
228
+ Mp3: "audio/mpeg",
229
+ /**
230
+ * Audio OGG - audio/ogg
231
+ */
232
+ OggAudio: "audio/ogg",
233
+ /**
234
+ * Audio WAV - audio/wav
235
+ */
236
+ Wav: "audio/wav",
237
+ /**
238
+ * Audio WEBM - audio/webm
239
+ */
240
+ WebmAudio: "audio/webm",
241
+ /**
242
+ * Audio AAC - audio/aac
243
+ */
244
+ Aac: "audio/aac",
245
+ /**
246
+ * Audio MP4 - audio/mp4
247
+ */
248
+ Mp4Audio: "audio/mp4",
88
249
  /**
89
250
  * Video MP4 - video/mp4
90
251
  */
@@ -96,6 +257,14 @@ export const MimeTypes = {
96
257
  /**
97
258
  * Video WEBM - video/webm
98
259
  */
99
- Webm: "video/webm"
260
+ Webm: "video/webm",
261
+ /**
262
+ * Video OGG - video/ogg
263
+ */
264
+ OggVideo: "video/ogg",
265
+ /**
266
+ * Video QuickTime - video/quicktime
267
+ */
268
+ Quicktime: "video/quicktime"
100
269
  };
101
270
  //# sourceMappingURL=mimeTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mimeTypes.js","sourceRoot":"","sources":["../../../src/models/mimeTypes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,SAAS,GAAG;IACxB;;OAEG;IACH,SAAS,EAAE,YAAY;IAEvB;;OAEG;IACH,IAAI,EAAE,WAAW;IAEjB;;OAEG;IACH,UAAU,EAAE,iBAAiB;IAE7B;;OAEG;IACH,IAAI,EAAE,kBAAkB;IAExB;;OAEG;IACH,MAAM,EAAE,qBAAqB;IAE7B;;OAEG;IACH,GAAG,EAAE,iBAAiB;IAEtB;;OAEG;IACH,GAAG,EAAE,iBAAiB;IAEtB;;OAEG;IACH,WAAW,EAAE,0BAA0B;IAEvC;;OAEG;IACH,IAAI,EAAE,kBAAkB;IAExB;;OAEG;IACH,IAAI,EAAE,kBAAkB;IAExB;;OAEG;IACH,KAAK,EAAE,qBAAqB;IAE5B;;OAEG;IACH,GAAG,EAAE,iBAAiB;IAEtB;;OAEG;IACH,GAAG,EAAE,iBAAiB;IAEtB;;OAEG;IACH,GAAG,EAAE,WAAW;IAEhB;;OAEG;IACH,GAAG,EAAE,WAAW;IAEhB;;OAEG;IACH,IAAI,EAAE,YAAY;IAElB;;OAEG;IACH,GAAG,EAAE,WAAW;IAEhB;;OAEG;IACH,IAAI,EAAE,YAAY;IAElB;;OAEG;IACH,GAAG,EAAE,eAAe;IAEpB;;OAEG;IACH,IAAI,EAAE,YAAY;IAElB;;OAEG;IACH,GAAG,EAAE,WAAW;IAEhB;;OAEG;IACH,IAAI,EAAE,YAAY;IAElB;;OAEG;IACH,IAAI,EAAE,YAAY;CACT,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Common mime types.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const MimeTypes = {\n\t/**\n\t * Plaint Text - text/plain\n\t */\n\tPlainText: \"text/plain\",\n\n\t/**\n\t * HTML - text/html\n\t */\n\tHtml: \"text/html\",\n\n\t/**\n\t * Javascript - text/javascript\n\t */\n\tJavascript: \"text/javascript\",\n\n\t/**\n\t * JSON - application/json\n\t */\n\tJson: \"application/json\",\n\n\t/**\n\t * JSON-LD - application/ld+json\n\t */\n\tJsonLd: \"application/ld+json\",\n\n\t/**\n\t * JWT - application/jwt\n\t */\n\tJwt: \"application/jwt\",\n\n\t/**\n\t * XML - application/xml\n\t */\n\tXml: \"application/xml\",\n\n\t/**\n\t * Application Octet Stream, arbitrary binary - application/octet-stream\n\t */\n\tOctetStream: \"application/octet-stream\",\n\n\t/**\n\t * Application GZIP - application/gzip\n\t */\n\tGzip: \"application/gzip\",\n\n\t/**\n\t * Application deflate - application/zlib\n\t */\n\tZlib: \"application/zlib\",\n\n\t/**\n\t * Application BZIP2 - application/x-bzip2\n\t */\n\tBzip2: \"application/x-bzip2\",\n\n\t/**\n\t * Application ZIP - application/zip\n\t */\n\tZip: \"application/zip\",\n\n\t/**\n\t * Application PDF - application/pdf\n\t */\n\tPdf: \"application/pdf\",\n\n\t/**\n\t * Image GIF - image/gif\n\t */\n\tGif: \"image/gif\",\n\n\t/**\n\t * Image BMP - image/bmp\n\t */\n\tBmp: \"image/bmp\",\n\n\t/**\n\t * Image JPEG - image/jpeg\n\t */\n\tJpeg: \"image/jpeg\",\n\n\t/**\n\t * Image PNG - image/png\n\t */\n\tPng: \"image/png\",\n\n\t/**\n\t * Image Tiff - image/tiff\n\t */\n\tTiff: \"image/tiff\",\n\n\t/**\n\t * Image SVG - image/svg+xml\n\t */\n\tSvg: \"image/svg+xml\",\n\n\t/**\n\t * Image WEBP - image/webp\n\t */\n\tWebP: \"image/webp\",\n\n\t/**\n\t * Video MP4 - video/mp4\n\t */\n\tMp4: \"video/mp4\",\n\n\t/**\n\t * Audio/Video MPEG - video/mpeg\n\t */\n\tMpeg: \"video/mpeg\",\n\n\t/**\n\t * Video WEBM - video/webm\n\t */\n\tWebm: \"video/webm\"\n} as const;\n\n/**\n * Common mime types.\n */\nexport type MimeTypes = (typeof MimeTypes)[keyof typeof MimeTypes];\n"]}
1
+ {"version":3,"file":"mimeTypes.js","sourceRoot":"","sources":["../../../src/models/mimeTypes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;;GAGG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,SAAS,GAAG;IACxB;;OAEG;IACH,SAAS,EAAE,YAAY;IAEvB;;OAEG;IACH,WAAW,EAAE,mBAAmB;IAEhC;;OAEG;IACH,IAAI,EAAE,WAAW;IAEjB;;OAEG;IACH,GAAG,EAAE,UAAU;IAEf;;OAEG;IACH,UAAU,EAAE,iBAAiB;IAE7B;;OAEG;IACH,QAAQ,EAAE,eAAe;IAEzB;;OAEG;IACH,IAAI,EAAE,kBAAkB;IAExB;;OAEG;IACH,WAAW,EAAE,0BAA0B;IAEvC;;OAEG;IACH,MAAM,EAAE,qBAAqB;IAE7B;;OAEG;IACH,eAAe,EAAE,2BAA2B;IAE5C;;OAEG;IACH,OAAO,EAAE,sBAAsB;IAE/B;;OAEG;IACH,GAAG,EAAE,iBAAiB;IAEtB;;OAEG;IACH,cAAc,EAAE,oBAAoB;IAEpC;;OAEG;IACH,IAAI,EAAE,kBAAkB;IAExB;;OAEG;IACH,QAAQ,EAAE,uBAAuB;IAEjC;;OAEG;IACH,OAAO,EAAE,sBAAsB;IAE/B;;OAEG;IACH,UAAU,EAAE,0BAA0B;IAEtC;;OAEG;IACH,OAAO,EAAE,sBAAsB;IAE/B;;OAEG;IACH,SAAS,EAAE,yBAAyB;IAEpC;;OAEG;IACH,0BAA0B,EAAE,wBAAwB;IAEpD;;OAEG;IACH,4BAA4B,EAAE,wBAAwB;IAEtD;;OAEG;IACH,uBAAuB,EAAE,oBAAoB;IAE7C;;OAEG;IACH,yBAAyB,EAAE,oBAAoB;IAE/C;;OAEG;IACH,SAAS,EAAE,6BAA6B;IAExC;;OAEG;IACH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WAAW;IAEhB;;OAEG;IACH,SAAS,EAAE,YAAY;IAEvB;;OAEG;IACH,GAAG,EAAE,WAAW;IAEhB;;OAEG;IACH,QAAQ,EAAE,WAAW;IAErB;;OAEG;IACH,GAAG,EAAE,WAAW;IAEhB;;OAEG;IACH,IAAI,EAAE,YAAY;IAElB;;OAEG;IACH,IAAI,EAAE,YAAY;IAElB;;OAEG;IACH,QAAQ,EAAE,WAAW;IAErB;;OAEG;IACH,SAAS,EAAE,iBAAiB;CACnB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Common mime types.\n * @see https://www.iana.org/assignments/media-types/media-types.xhtml\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const MimeTypes = {\n\t/**\n\t * Plaint Text - text/plain\n\t */\n\tPlainText: \"text/plain\",\n\n\t/**\n\t * Event Stream - text/event-stream\n\t */\n\tEventStream: \"text/event-stream\",\n\n\t/**\n\t * HTML - text/html\n\t */\n\tHtml: \"text/html\",\n\n\t/**\n\t * CSS - text/css\n\t */\n\tCss: \"text/css\",\n\n\t/**\n\t * Javascript - text/javascript\n\t */\n\tJavascript: \"text/javascript\",\n\n\t/**\n\t * Markdown - text/markdown\n\t */\n\tMarkdown: \"text/markdown\",\n\n\t/**\n\t * JSON - application/json\n\t */\n\tJson: \"application/json\",\n\n\t/**\n\t * Problem JSON - application/problem+json\n\t */\n\tProblemJson: \"application/problem+json\",\n\n\t/**\n\t * JSON-LD - application/ld+json\n\t */\n\tJsonLd: \"application/ld+json\",\n\n\t/**\n\t * Activity Streams - application/activity+json\n\t */\n\tActivityStreams: \"application/activity+json\",\n\n\t/**\n\t * WebFinger JRD - application/jrd+json\n\t */\n\tJrdJson: \"application/jrd+json\",\n\n\t/**\n\t * JWT - application/jwt\n\t */\n\tJwt: \"application/jwt\",\n\n\t/**\n\t * Access Token JWT - application/at+jwt\n\t */\n\tAccessTokenJwt: \"application/at+jwt\",\n\n\t/**\n\t * JOSE (Compact Serialization) - application/jose\n\t */\n\tJose: \"application/jose\",\n\n\t/**\n\t * JOSE (JSON Serialization) - application/jose+json\n\t */\n\tJoseJson: \"application/jose+json\",\n\n\t/**\n\t * JSON Web Key (JWK) - application/jwk+json\n\t */\n\tJwkJson: \"application/jwk+json\",\n\n\t/**\n\t * JSON Web Key Set (JWKS) - application/jwk-set+json\n\t */\n\tJwkSetJson: \"application/jwk-set+json\",\n\n\t/**\n\t * Decentralized Identifier (DID) - application/did+json\n\t */\n\tDidJson: \"application/did+json\",\n\n\t/**\n\t * Decentralized Identifier (DID) (JSON-LD) - application/did+ld+json\n\t */\n\tDidLdJson: \"application/did+ld+json\",\n\n\t/**\n\t * Verifiable Credential (JSON-LD) - application/vc+ld+json\n\t */\n\tVerifiableCredentialLdJson: \"application/vc+ld+json\",\n\n\t/**\n\t * Verifiable Presentation (JSON-LD) - application/vp+ld+json\n\t */\n\tVerifiablePresentationLdJson: \"application/vp+ld+json\",\n\n\t/**\n\t * Verifiable Credential (JWT) - application/vc+jwt\n\t */\n\tVerifiableCredentialJwt: \"application/vc+jwt\",\n\n\t/**\n\t * Verifiable Presentation (JWT) - application/vp+jwt\n\t */\n\tVerifiablePresentationJwt: \"application/vp+jwt\",\n\n\t/**\n\t * JSON Patch - application/json-patch+json\n\t */\n\tJsonPatch: \"application/json-patch+json\",\n\n\t/**\n\t * JSON Merge Patch - application/merge-patch+json\n\t */\n\tMergePatch: \"application/merge-patch+json\",\n\n\t/**\n\t * CBOR Web Token (CWT) - application/cwt\n\t */\n\tCwt: \"application/cwt\",\n\n\t/**\n\t * COSE - application/cose\n\t */\n\tCose: \"application/cose\",\n\n\t/**\n\t * COSE Key - application/cose-key\n\t */\n\tCoseKey: \"application/cose-key\",\n\n\t/**\n\t * COSE Key Set - application/cose-key-set\n\t */\n\tCoseKeySet: \"application/cose-key-set\",\n\n\t/**\n\t * Form URL Encoded - application/x-www-form-urlencoded\n\t */\n\tFormUrlEncoded: \"application/x-www-form-urlencoded\",\n\n\t/**\n\t * Multipart Form Data - multipart/form-data\n\t */\n\tMultipartFormData: \"multipart/form-data\",\n\n\t/**\n\t * XML - application/xml\n\t */\n\tXml: \"application/xml\",\n\n\t/**\n\t * WASM - application/wasm\n\t */\n\tWasm: \"application/wasm\",\n\n\t/**\n\t * Web App Manifest - application/manifest+json\n\t */\n\tWebManifest: \"application/manifest+json\",\n\n\t/**\n\t * Application Octet Stream, arbitrary binary - application/octet-stream\n\t */\n\tOctetStream: \"application/octet-stream\",\n\n\t/**\n\t * Application GZIP - application/gzip\n\t */\n\tGzip: \"application/gzip\",\n\n\t/**\n\t * Application deflate - application/zlib\n\t */\n\tZlib: \"application/zlib\",\n\n\t/**\n\t * Application BZIP2 - application/x-bzip2\n\t */\n\tBzip2: \"application/x-bzip2\",\n\n\t/**\n\t * Application ZIP - application/zip\n\t */\n\tZip: \"application/zip\",\n\n\t/**\n\t * Application PDF - application/pdf\n\t */\n\tPdf: \"application/pdf\",\n\n\t/**\n\t * Image GIF - image/gif\n\t */\n\tGif: \"image/gif\",\n\n\t/**\n\t * Image BMP - image/bmp\n\t */\n\tBmp: \"image/bmp\",\n\n\t/**\n\t * Image JPEG - image/jpeg\n\t */\n\tJpeg: \"image/jpeg\",\n\n\t/**\n\t * Image PNG - image/png\n\t */\n\tPng: \"image/png\",\n\n\t/**\n\t * Image Tiff - image/tiff\n\t */\n\tTiff: \"image/tiff\",\n\n\t/**\n\t * Image SVG - image/svg+xml\n\t */\n\tSvg: \"image/svg+xml\",\n\n\t/**\n\t * Image ICO - image/x-icon\n\t */\n\tIco: \"image/x-icon\",\n\n\t/**\n\t * Image WEBP - image/webp\n\t */\n\tWebP: \"image/webp\",\n\n\t/**\n\t * Image AVIF - image/avif\n\t */\n\tAvif: \"image/avif\",\n\n\t/**\n\t * Image APNG - image/apng\n\t */\n\tApng: \"image/apng\",\n\n\t/**\n\t * Font WOFF - font/woff\n\t */\n\tWoff: \"font/woff\",\n\n\t/**\n\t * Font WOFF2 - font/woff2\n\t */\n\tWoff2: \"font/woff2\",\n\n\t/**\n\t * Font TTF - font/ttf\n\t */\n\tTtf: \"font/ttf\",\n\n\t/**\n\t * Font OTF - font/otf\n\t */\n\tOtf: \"font/otf\",\n\n\t/**\n\t * Audio MP3 - audio/mpeg\n\t */\n\tMp3: \"audio/mpeg\",\n\n\t/**\n\t * Audio OGG - audio/ogg\n\t */\n\tOggAudio: \"audio/ogg\",\n\n\t/**\n\t * Audio WAV - audio/wav\n\t */\n\tWav: \"audio/wav\",\n\n\t/**\n\t * Audio WEBM - audio/webm\n\t */\n\tWebmAudio: \"audio/webm\",\n\n\t/**\n\t * Audio AAC - audio/aac\n\t */\n\tAac: \"audio/aac\",\n\n\t/**\n\t * Audio MP4 - audio/mp4\n\t */\n\tMp4Audio: \"audio/mp4\",\n\n\t/**\n\t * Video MP4 - video/mp4\n\t */\n\tMp4: \"video/mp4\",\n\n\t/**\n\t * Audio/Video MPEG - video/mpeg\n\t */\n\tMpeg: \"video/mpeg\",\n\n\t/**\n\t * Video WEBM - video/webm\n\t */\n\tWebm: \"video/webm\",\n\n\t/**\n\t * Video OGG - video/ogg\n\t */\n\tOggVideo: \"video/ogg\",\n\n\t/**\n\t * Video QuickTime - video/quicktime\n\t */\n\tQuicktime: \"video/quicktime\"\n} as const;\n\n/**\n * Common mime types.\n */\nexport type MimeTypes = (typeof MimeTypes)[keyof typeof MimeTypes];\n"]}
@@ -0,0 +1,83 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { Guards, Is } from "@twin.org/core";
4
+ /**
5
+ * Class to help with cookie operations.
6
+ */
7
+ export class CookieHelper {
8
+ /**
9
+ * Runtime name for the class.
10
+ */
11
+ static CLASS_NAME = "CookieHelper";
12
+ /**
13
+ * Create a cookie string.
14
+ * @param cookieName The name of the cookie.
15
+ * @param cookieValue The value of the cookie.
16
+ * @param options Additional cookie options.
17
+ * @param options.secure Should this be a secure cookie.
18
+ * @param options.httpOnly Should this be an http only cookie.
19
+ * @param options.sameSite The same site option for the cookie.
20
+ * @param options.path The path for the cookie.
21
+ * @returns The created cookie string.
22
+ */
23
+ static createCookie(cookieName, cookieValue, options) {
24
+ Guards.stringValue(CookieHelper.CLASS_NAME, "cookieName", cookieName);
25
+ Guards.string(CookieHelper.CLASS_NAME, "cookieValue", cookieValue);
26
+ const cookieParts = [`${cookieName}=${encodeURIComponent(cookieValue)}`];
27
+ const localOptions = options ?? {};
28
+ localOptions.secure ??= true;
29
+ localOptions.httpOnly ??= true;
30
+ localOptions.sameSite ??= "Strict";
31
+ localOptions.path ??= "/";
32
+ if (localOptions.secure) {
33
+ cookieParts.push("Secure");
34
+ }
35
+ if (localOptions.httpOnly) {
36
+ cookieParts.push("HttpOnly");
37
+ }
38
+ if (localOptions.sameSite) {
39
+ cookieParts.push(`SameSite=${localOptions.sameSite}`);
40
+ }
41
+ if (localOptions.path) {
42
+ cookieParts.push(`Path=${localOptions.path}`);
43
+ }
44
+ return cookieParts.join("; ");
45
+ }
46
+ /**
47
+ * Create a cookie string which will delete a cookie.
48
+ * @param cookieName The name of the cookie.
49
+ * @param options Additional cookie options.
50
+ * @param options.secure Should this be a secure cookie.
51
+ * @param options.httpOnly Should this be an http only cookie.
52
+ * @param options.sameSite The same site option for the cookie.
53
+ * @param options.path The path for the cookie.
54
+ * @returns The created cookie string.
55
+ */
56
+ static deleteCookie(cookieName, options) {
57
+ return `${CookieHelper.createCookie(cookieName, "", options)}; Max-Age=0`;
58
+ }
59
+ /**
60
+ * Get cookies from headers.
61
+ * @param headers The headers to get cookies from.
62
+ * @param cookieName The name of the cookie to get.
63
+ * @returns The cookies found in the headers.
64
+ */
65
+ static getCookieFromHeaders(headers, cookieName) {
66
+ Guards.stringValue(CookieHelper.CLASS_NAME, "cookieName", cookieName);
67
+ if (!Is.empty(headers)) {
68
+ const cookies = Is.arrayValue(headers) ? headers : [headers];
69
+ for (const cookie of cookies) {
70
+ if (Is.stringValue(cookie)) {
71
+ const accessTokenCookie = cookie
72
+ .split(";")
73
+ .map(c => c.trim())
74
+ .find(c => c.startsWith(`${cookieName}=`));
75
+ if (Is.stringValue(accessTokenCookie)) {
76
+ return decodeURIComponent(accessTokenCookie.slice(cookieName.length + 1).trim());
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ //# sourceMappingURL=cookieHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookieHelper.js","sourceRoot":"","sources":["../../../src/utils/cookieHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAG5C;;GAEG;AACH,MAAM,OAAO,YAAY;IACxB;;OAEG;IACI,MAAM,CAAU,UAAU,kBAAkC;IAEnE;;;;;;;;;;OAUG;IACI,MAAM,CAAC,YAAY,CACzB,UAAkB,EAClB,WAAmB,EACnB,OAKC;QAED,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,gBAAsB,UAAU,CAAC,CAAC;QAC5E,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,iBAAuB,WAAW,CAAC,CAAC;QAEzE,MAAM,WAAW,GAAG,CAAC,GAAG,UAAU,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAEzE,MAAM,YAAY,GAAG,OAAO,IAAI,EAAE,CAAC;QACnC,YAAY,CAAC,MAAM,KAAK,IAAI,CAAC;QAC7B,YAAY,CAAC,QAAQ,KAAK,IAAI,CAAC;QAC/B,YAAY,CAAC,QAAQ,KAAK,QAAQ,CAAC;QACnC,YAAY,CAAC,IAAI,KAAK,GAAG,CAAC;QAE1B,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;YACzB,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;QACD,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;YAC3B,WAAW,C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BAE5C,IAAI,EAAE,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,CAAC;wBACvC,OAAO,kBAAkB,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;oBAClF,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Guards, Is } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Class to help with cookie operations.\n */\nexport class CookieHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<CookieHelper>();\n\n\t/**\n\t * Create a cookie string.\n\t * @param cookieName The name of the cookie.\n\t * @param cookieValue The value of the cookie.\n\t * @param options Additional cookie options.\n\t * @param options.secure Should this be a secure cookie.\n\t * @param options.httpOnly Should this be an http only cookie.\n\t * @param options.sameSite The same site option for the cookie.\n\t * @param options.path The path for the cookie.\n\t * @returns The created cookie string.\n\t */\n\tpublic static createCookie(\n\t\tcookieName: string,\n\t\tcookieValue: string,\n\t\toptions?: {\n\t\t\tsecure?: boolean;\n\t\t\thttpOnly?: boolean;\n\t\t\tsameSite?: \"Strict\" | \"Lax\" | \"None\";\n\t\t\tpath?: string;\n\t\t}\n\t): string {\n\t\tGuards.stringValue(CookieHelper.CLASS_NAME, nameof(cookieName), cookieName);\n\t\tGuards.string(CookieHelper.CLASS_NAME, nameof(cookieValue), cookieValue);\n\n\t\tconst cookieParts = [`${cookieName}=${encodeURIComponent(cookieValue)}`];\n\n\t\tconst localOptions = options ?? {};\n\t\tlocalOptions.secure ??= true;\n\t\tlocalOptions.httpOnly ??= true;\n\t\tlocalOptions.sameSite ??= \"Strict\";\n\t\tlocalOptions.path ??= \"/\";\n\n\t\tif (localOptions.secure) {\n\t\t\tcookieParts.push(\"Secure\");\n\t\t}\n\t\tif (localOptions.httpOnly) {\n\t\t\tcookieParts.push(\"HttpOnly\");\n\t\t}\n\t\tif (localOptions.sameSite) {\n\t\t\tcookieParts.push(`SameSite=${localOptions.sameSite}`);\n\t\t}\n\t\tif (localOptions.path) {\n\t\t\tcookieParts.push(`Path=${localOptions.path}`);\n\t\t}\n\n\t\treturn cookieParts.join(\"; \");\n\t}\n\n\t/**\n\t * Create a cookie string which will delete a cookie.\n\t * @param cookieName The name of the cookie.\n\t * @param options Additional cookie options.\n\t * @param options.secure Should this be a secure cookie.\n\t * @param options.httpOnly Should this be an http only cookie.\n\t * @param options.sameSite The same site option for the cookie.\n\t * @param options.path The path for the cookie.\n\t * @returns The created cookie string.\n\t */\n\tpublic static deleteCookie(\n\t\tcookieName: string,\n\t\toptions?: {\n\t\t\tsecure?: boolean;\n\t\t\thttpOnly?: boolean;\n\t\t\tsameSite?: \"Strict\" | \"Lax\" | \"None\";\n\t\t\tpath?: string;\n\t\t}\n\t): string {\n\t\treturn `${CookieHelper.createCookie(cookieName, \"\", options)}; Max-Age=0`;\n\t}\n\n\t/**\n\t * Get cookies from headers.\n\t * @param headers The headers to get cookies from.\n\t * @param cookieName The name of the cookie to get.\n\t * @returns The cookies found in the headers.\n\t */\n\tpublic static getCookieFromHeaders(\n\t\theaders: string | string[] | undefined,\n\t\tcookieName: string\n\t): string | undefined {\n\t\tGuards.stringValue(CookieHelper.CLASS_NAME, nameof(cookieName), cookieName);\n\n\t\tif (!Is.empty(headers)) {\n\t\t\tconst cookies = Is.arrayValue(headers) ? headers : [headers];\n\t\t\tfor (const cookie of cookies) {\n\t\t\t\tif (Is.stringValue(cookie)) {\n\t\t\t\t\tconst accessTokenCookie = cookie\n\t\t\t\t\t\t.split(\";\")\n\t\t\t\t\t\t.map(c => c.trim())\n\t\t\t\t\t\t.find(c => c.startsWith(`${cookieName}=`));\n\n\t\t\t\t\tif (Is.stringValue(accessTokenCookie)) {\n\t\t\t\t\t\treturn decodeURIComponent(accessTokenCookie.slice(cookieName.length + 1).trim());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -1,10 +1,14 @@
1
1
  // Copyright 2024 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
- import { Is } from "@twin.org/core";
3
+ import { GeneralError, Guards, Is } from "@twin.org/core";
4
4
  /**
5
5
  * Class to helper with header operations.
6
6
  */
7
7
  export class HeaderHelper {
8
+ /**
9
+ * Runtime name for the class.
10
+ */
11
+ static CLASS_NAME = "HeaderHelper";
8
12
  /**
9
13
  * Create a bearer token header.
10
14
  * @param token The token to create the header for.
@@ -30,5 +34,135 @@ export class HeaderHelper {
30
34
  }
31
35
  return "";
32
36
  }
37
+ /**
38
+ * Extract the properties from a Link header for a specific relation type.
39
+ * @param linkHeader The Link header value in format `<url>; rel="..."; param1=""; param2=""`.
40
+ * @param relation The relation type to extract.
41
+ * @returns The extracted URL, rel and optional params or undefined if invalid/missing.
42
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link
43
+ */
44
+ static extractLinkHeaderRelation(linkHeader, relation) {
45
+ const headers = HeaderHelper.extractLinkHeaders(linkHeader);
46
+ if (Is.arrayValue(headers)) {
47
+ return headers.find(h => h.rel === relation);
48
+ }
49
+ }
50
+ /**
51
+ * Extract the link headers.
52
+ * @param linkHeader The Link header value in format `<url>; rel="..."; param1=""; param2=""`.
53
+ * @returns The extracted possible array of URL, rel and optional params or undefined if invalid/missing.
54
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link
55
+ */
56
+ static extractLinkHeaders(linkHeader) {
57
+ if (Is.stringValue(linkHeader)) {
58
+ const header = HeaderHelper.extractLinkHeader(linkHeader);
59
+ return header ? [header] : [];
60
+ }
61
+ if (Is.arrayValue(linkHeader)) {
62
+ const results = [];
63
+ for (const singleLinkHeader of linkHeader) {
64
+ const header = HeaderHelper.extractLinkHeader(singleLinkHeader);
65
+ if (header) {
66
+ results.push(header);
67
+ }
68
+ }
69
+ return results;
70
+ }
71
+ return undefined;
72
+ }
73
+ /**
74
+ * Extract the properties from a Link header.
75
+ * @param linkHeader The Link header value in format `<url>; rel="..."; param1=""; param2=""`.
76
+ * @returns The extracted URL, rel and optional params or undefined if invalid/missing.
77
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link
78
+ */
79
+ static extractLinkHeader(linkHeader) {
80
+ if (!Is.stringValue(linkHeader)) {
81
+ return undefined;
82
+ }
83
+ const parts = linkHeader.split(";");
84
+ if (parts.length >= 2) {
85
+ let url;
86
+ let urlQueryParams;
87
+ const urlMatch = /<([^>]+)>/.exec(parts[0]);
88
+ if (Is.stringValue(urlMatch?.[1])) {
89
+ url = urlMatch[1];
90
+ const queryIndex = url.indexOf("?");
91
+ if (queryIndex !== -1) {
92
+ const urlParamsString = url.slice(queryIndex + 1);
93
+ const queryParts = urlParamsString.split("&");
94
+ for (const queryPart of queryParts) {
95
+ const [key, value] = queryPart.split("=");
96
+ if (Is.stringValue(key) && Is.stringValue(value)) {
97
+ urlQueryParams ??= {};
98
+ urlQueryParams[key] = decodeURIComponent(value);
99
+ }
100
+ }
101
+ }
102
+ }
103
+ let rel;
104
+ const params = {};
105
+ for (let i = 1; i < parts.length; i++) {
106
+ const relMatch = /rel="([^"]+)"/.exec(parts[i].trim());
107
+ if (relMatch?.[1]) {
108
+ rel = relMatch[1];
109
+ }
110
+ else {
111
+ const paramMatch = /([^=]+)="([^"]+)"/.exec(parts[i].trim());
112
+ if (paramMatch?.[1] && paramMatch?.[2]) {
113
+ params[paramMatch[1]] = paramMatch[2];
114
+ }
115
+ }
116
+ }
117
+ if (Is.stringValue(url) && Is.stringValue(rel)) {
118
+ return {
119
+ url,
120
+ urlQueryParams,
121
+ rel,
122
+ params: Object.keys(params).length > 0 ? params : undefined
123
+ };
124
+ }
125
+ }
126
+ return undefined;
127
+ }
128
+ /**
129
+ * Create a compliant Link header.
130
+ * @param url The URL to include in the Link header.
131
+ * @param urlQueryParams Optional query parameters to include in the URL.
132
+ * @param rel The relation type (e.g., "next", "prev", "self").
133
+ * @returns The formatted Link header string.
134
+ * @throws GeneralError if the URL or rel are invalid.
135
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link
136
+ */
137
+ static createLinkHeader(url, urlQueryParams, rel, params) {
138
+ Guards.stringValue(HeaderHelper.CLASS_NAME, "url", url);
139
+ Guards.stringValue(HeaderHelper.CLASS_NAME, "rel", rel);
140
+ if (url.includes(">")) {
141
+ throw new GeneralError(HeaderHelper.CLASS_NAME, "invalidLinkHeaderURL");
142
+ }
143
+ if (rel.includes('"')) {
144
+ throw new GeneralError(HeaderHelper.CLASS_NAME, "invalidLinkHeaderRel");
145
+ }
146
+ if (Is.objectValue(urlQueryParams)) {
147
+ const queryParamsString = Object.entries(urlQueryParams)
148
+ .map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
149
+ .join("&");
150
+ const queryIndex = url.indexOf("?");
151
+ if (queryIndex === -1) {
152
+ url += `?${queryParamsString}`;
153
+ }
154
+ else if (queryIndex === url.length - 1) {
155
+ url += queryParamsString;
156
+ }
157
+ else {
158
+ url += `&${queryParamsString}`;
159
+ }
160
+ }
161
+ return `<${url}>; rel="${rel}"${params
162
+ ? Object.entries(params)
163
+ .map(([key, value]) => `; ${key}="${value}"`)
164
+ .join("")
165
+ : ""}`;
166
+ }
33
167
  }
34
168
  //# sourceMappingURL=headerHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"headerHelper.js","sourceRoot":"","sources":["../../../src/utils/headerHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,YAAY;IACxB;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAAC,KAAc;QACxC,IAAI,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,IAAI,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;gBACjC,OAAO,KAAK,CAAC;YACd,CAAC;YACD,OAAO,UAAU,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QACjC,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,aAAa,CAAC,MAAe;QAC1C,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9C,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Is } from \"@twin.org/core\";\n\n/**\n * Class to helper with header operations.\n */\nexport class HeaderHelper {\n\t/**\n\t * Create a bearer token header.\n\t * @param token The token to create the header for.\n\t * @returns The bearer token header.\n\t */\n\tpublic static createBearer(token: unknown): string {\n\t\tif (Is.stringValue(token)) {\n\t\t\tif (token.startsWith(\"Bearer \")) {\n\t\t\t\treturn token;\n\t\t\t}\n\t\t\treturn `Bearer ${token.trim()}`;\n\t\t}\n\t\treturn \"\";\n\t}\n\n\t/**\n\t * Extract the bearer token from a header.\n\t * @param header The header value to extract the token from.\n\t * @returns The extracted token if it exists.\n\t */\n\tpublic static extractBearer(header: unknown): string {\n\t\tif (Is.stringValue(header) && header.startsWith(\"Bearer \")) {\n\t\t\treturn header.slice(7, header.length).trim();\n\t\t}\n\t\treturn \"\";\n\t}\n}\n"]}
1
+ {"version":3,"file":"headerHelper.js","sourceRoot":"","sources":["../../../src/utils/headerHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EA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AE,CAAC;gBACvB,GAAG,IAAI,IAAI,iBAAiB,EAAE,CAAC;YAChC,CAAC;iBAAM,IAAI,UAAU,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1C,GAAG,IAAI,iBAAiB,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACP,GAAG,IAAI,IAAI,iBAAiB,EAAE,CAAC;YAChC,CAAC;QACF,CAAC;QAED,OAAO,IAAI,GAAG,WAAW,GAAG,IAC3B,MAAM;YACL,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;iBACrB,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,KAAK,KAAK,GAAG,CAAC;iBAC5C,IAAI,CAAC,EAAE,CAAC;YACX,CAAC,CAAC,EACJ,EAAE,CAAC;IACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Guards, Is } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Class to helper with header operations.\n */\nexport class HeaderHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<HeaderHelper>();\n\n\t/**\n\t * Create a bearer token header.\n\t * @param token The token to create the header for.\n\t * @returns The bearer token header.\n\t */\n\tpublic static createBearer(token: unknown): string {\n\t\tif (Is.stringValue(token)) {\n\t\t\tif (token.startsWith(\"Bearer \")) {\n\t\t\t\treturn token;\n\t\t\t}\n\t\t\treturn `Bearer ${token.trim()}`;\n\t\t}\n\t\treturn \"\";\n\t}\n\n\t/**\n\t * Extract the bearer token from a header.\n\t * @param header The header value to extract the token from.\n\t * @returns The extracted token if it exists.\n\t */\n\tpublic static extractBearer(header: unknown): string {\n\t\tif (Is.stringValue(header) && header.startsWith(\"Bearer \")) {\n\t\t\treturn header.slice(7, header.length).trim();\n\t\t}\n\t\treturn \"\";\n\t}\n\n\t/**\n\t * Extract the properties from a Link header for a specific relation type.\n\t * @param linkHeader The Link header value in format `<url>; rel=\"...\"; param1=\"\"; param2=\"\"`.\n\t * @param relation The relation type to extract.\n\t * @returns The extracted URL, rel and optional params or undefined if invalid/missing.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link\n\t */\n\tpublic static extractLinkHeaderRelation(\n\t\tlinkHeader: unknown,\n\t\trelation: string\n\t):\n\t\t| {\n\t\t\t\turl: string;\n\t\t\t\turlQueryParams?: { [id: string]: string };\n\t\t\t\trel: string;\n\t\t\t\tparams?: { [id: string]: string };\n\t\t }\n\t\t| undefined {\n\t\tconst headers = HeaderHelper.extractLinkHeaders(linkHeader);\n\t\tif (Is.arrayValue(headers)) {\n\t\t\treturn headers.find(h => h.rel === relation);\n\t\t}\n\t}\n\n\t/**\n\t * Extract the link headers.\n\t * @param linkHeader The Link header value in format `<url>; rel=\"...\"; param1=\"\"; param2=\"\"`.\n\t * @returns The extracted possible array of URL, rel and optional params or undefined if invalid/missing.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link\n\t */\n\tpublic static extractLinkHeaders(linkHeader: unknown):\n\t\t| {\n\t\t\t\turl: string;\n\t\t\t\turlQueryParams?: { [id: string]: string };\n\t\t\t\trel: string;\n\t\t\t\tparams?: { [id: string]: string };\n\t\t }[]\n\t\t| undefined {\n\t\tif (Is.stringValue(linkHeader)) {\n\t\t\tconst header = HeaderHelper.extractLinkHeader(linkHeader);\n\t\t\treturn header ? [header] : [];\n\t\t}\n\t\tif (Is.arrayValue<string>(linkHeader)) {\n\t\t\tconst results = [];\n\t\t\tfor (const singleLinkHeader of linkHeader) {\n\t\t\t\tconst header = HeaderHelper.extractLinkHeader(singleLinkHeader);\n\t\t\t\tif (header) {\n\t\t\t\t\tresults.push(header);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Extract the properties from a Link header.\n\t * @param linkHeader The Link header value in format `<url>; rel=\"...\"; param1=\"\"; param2=\"\"`.\n\t * @returns The extracted URL, rel and optional params or undefined if invalid/missing.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link\n\t */\n\tpublic static extractLinkHeader(linkHeader: string):\n\t\t| {\n\t\t\t\turl: string;\n\t\t\t\turlQueryParams?: { [id: string]: string };\n\t\t\t\trel: string;\n\t\t\t\tparams?: { [id: string]: string };\n\t\t }\n\t\t| undefined {\n\t\tif (!Is.stringValue(linkHeader)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst parts = linkHeader.split(\";\");\n\n\t\tif (parts.length >= 2) {\n\t\t\tlet url;\n\t\t\tlet urlQueryParams: { [id: string]: string } | undefined;\n\n\t\t\tconst urlMatch = /<([^>]+)>/.exec(parts[0]);\n\t\t\tif (Is.stringValue(urlMatch?.[1])) {\n\t\t\t\turl = urlMatch[1];\n\n\t\t\t\tconst queryIndex = url.indexOf(\"?\");\n\t\t\t\tif (queryIndex !== -1) {\n\t\t\t\t\tconst urlParamsString = url.slice(queryIndex + 1);\n\t\t\t\t\tconst queryParts = urlParamsString.split(\"&\");\n\n\t\t\t\t\tfor (const queryPart of queryParts) {\n\t\t\t\t\t\tconst [key, value] = queryPart.split(\"=\");\n\t\t\t\t\t\tif (Is.stringValue(key) && Is.stringValue(value)) {\n\t\t\t\t\t\t\turlQueryParams ??= {};\n\t\t\t\t\t\t\turlQueryParams[key] = decodeURIComponent(value);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet rel;\n\t\t\tconst params: { [id: string]: string } = {};\n\n\t\t\tfor (let i = 1; i < parts.length; i++) {\n\t\t\t\tconst relMatch = /rel=\"([^\"]+)\"/.exec(parts[i].trim());\n\t\t\t\tif (relMatch?.[1]) {\n\t\t\t\t\trel = relMatch[1];\n\t\t\t\t} else {\n\t\t\t\t\tconst paramMatch = /([^=]+)=\"([^\"]+)\"/.exec(parts[i].trim());\n\t\t\t\t\tif (paramMatch?.[1] && paramMatch?.[2]) {\n\t\t\t\t\t\tparams[paramMatch[1]] = paramMatch[2];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (Is.stringValue(url) && Is.stringValue(rel)) {\n\t\t\t\treturn {\n\t\t\t\t\turl,\n\t\t\t\t\turlQueryParams,\n\t\t\t\t\trel,\n\t\t\t\t\tparams: Object.keys(params).length > 0 ? params : undefined\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Create a compliant Link header.\n\t * @param url The URL to include in the Link header.\n\t * @param urlQueryParams Optional query parameters to include in the URL.\n\t * @param rel The relation type (e.g., \"next\", \"prev\", \"self\").\n\t * @returns The formatted Link header string.\n\t * @throws GeneralError if the URL or rel are invalid.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link\n\t */\n\tpublic static createLinkHeader(\n\t\turl: string,\n\t\turlQueryParams: { [id: string]: string } | undefined,\n\t\trel: string,\n\t\tparams?: { [id: string]: string }\n\t): string {\n\t\tGuards.stringValue(HeaderHelper.CLASS_NAME, nameof(url), url);\n\t\tGuards.stringValue(HeaderHelper.CLASS_NAME, nameof(rel), rel);\n\n\t\tif (url.includes(\">\")) {\n\t\t\tthrow new GeneralError(HeaderHelper.CLASS_NAME, \"invalidLinkHeaderURL\");\n\t\t}\n\t\tif (rel.includes('\"')) {\n\t\t\tthrow new GeneralError(HeaderHelper.CLASS_NAME, \"invalidLinkHeaderRel\");\n\t\t}\n\n\t\tif (Is.objectValue(urlQueryParams)) {\n\t\t\tconst queryParamsString = Object.entries(urlQueryParams)\n\t\t\t\t.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)\n\t\t\t\t.join(\"&\");\n\t\t\tconst queryIndex = url.indexOf(\"?\");\n\t\t\tif (queryIndex === -1) {\n\t\t\t\turl += `?${queryParamsString}`;\n\t\t\t} else if (queryIndex === url.length - 1) {\n\t\t\t\turl += queryParamsString;\n\t\t\t} else {\n\t\t\t\turl += `&${queryParamsString}`;\n\t\t\t}\n\t\t}\n\n\t\treturn `<${url}>; rel=\"${rel}\"${\n\t\t\tparams\n\t\t\t\t? Object.entries(params)\n\t\t\t\t\t\t.map(([key, value]) => `; ${key}=\"${value}\"`)\n\t\t\t\t\t\t.join(\"\")\n\t\t\t\t: \"\"\n\t\t}`;\n\t}\n}\n"]}
@@ -85,12 +85,38 @@ export class MimeTypeHelper {
85
85
  }
86
86
  const lookup = {
87
87
  [MimeTypes.PlainText]: "txt",
88
+ [MimeTypes.EventStream]: "txt",
88
89
  [MimeTypes.Html]: "html",
90
+ [MimeTypes.Css]: "css",
89
91
  [MimeTypes.Javascript]: "js",
92
+ [MimeTypes.Markdown]: "md",
90
93
  [MimeTypes.Json]: "json",
94
+ [MimeTypes.ProblemJson]: "json",
95
+ [MimeTypes.WebManifest]: "webmanifest",
91
96
  [MimeTypes.JsonLd]: "jsonld",
92
97
  [MimeTypes.Jwt]: "jwt",
98
+ [MimeTypes.AccessTokenJwt]: "jwt",
99
+ [MimeTypes.Jose]: "jose",
100
+ [MimeTypes.JoseJson]: "json",
101
+ [MimeTypes.JwkJson]: "json",
102
+ [MimeTypes.JwkSetJson]: "json",
103
+ [MimeTypes.JrdJson]: "json",
104
+ [MimeTypes.DidJson]: "json",
105
+ [MimeTypes.DidLdJson]: "jsonld",
106
+ [MimeTypes.VerifiableCredentialLdJson]: "jsonld",
107
+ [MimeTypes.VerifiablePresentationLdJson]: "jsonld",
108
+ [MimeTypes.VerifiableCredentialJwt]: "jwt",
109
+ [MimeTypes.VerifiablePresentationJwt]: "jwt",
110
+ [MimeTypes.JsonPatch]: "json",
111
+ [MimeTypes.MergePatch]: "json",
112
+ [MimeTypes.Cwt]: "cwt",
113
+ [MimeTypes.Cose]: "cose",
114
+ [MimeTypes.CoseKey]: "cose",
115
+ [MimeTypes.CoseKeySet]: "cose",
116
+ [MimeTypes.FormUrlEncoded]: "txt",
117
+ [MimeTypes.MultipartFormData]: "txt",
93
118
  [MimeTypes.Xml]: "xml",
119
+ [MimeTypes.Wasm]: "wasm",
94
120
  [MimeTypes.OctetStream]: "bin",
95
121
  [MimeTypes.Gzip]: "gzip",
96
122
  [MimeTypes.Zlib]: "zlib",
@@ -103,10 +129,25 @@ export class MimeTypeHelper {
103
129
  [MimeTypes.Png]: "png",
104
130
  [MimeTypes.Tiff]: "tif",
105
131
  [MimeTypes.Svg]: "svg",
132
+ [MimeTypes.Ico]: "ico",
106
133
  [MimeTypes.WebP]: "webp",
134
+ [MimeTypes.Avif]: "avif",
135
+ [MimeTypes.Apng]: "apng",
136
+ [MimeTypes.Woff]: "woff",
137
+ [MimeTypes.Woff2]: "woff2",
138
+ [MimeTypes.Ttf]: "ttf",
139
+ [MimeTypes.Otf]: "otf",
140
+ [MimeTypes.Mp3]: "mp3",
141
+ [MimeTypes.OggAudio]: "ogg",
142
+ [MimeTypes.Wav]: "wav",
143
+ [MimeTypes.WebmAudio]: "webm",
144
+ [MimeTypes.Aac]: "aac",
145
+ [MimeTypes.Mp4Audio]: "m4a",
107
146
  [MimeTypes.Mp4]: "mp4",
108
147
  [MimeTypes.Mpeg]: "mpg",
109
- [MimeTypes.Webm]: "webm"
148
+ [MimeTypes.Webm]: "webm",
149
+ [MimeTypes.OggVideo]: "ogv",
150
+ [MimeTypes.Quicktime]: "mov"
110
151
  };
111
152
  return lookup[mimeType];
112
153
  }