@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
@@ -1,35 +1,144 @@
1
1
  /**
2
2
  * Common mime types.
3
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
3
4
  */
4
5
  export declare const MimeTypes: {
5
6
  /**
6
7
  * Plaint Text - text/plain
7
8
  */
8
9
  readonly PlainText: "text/plain";
10
+ /**
11
+ * Event Stream - text/event-stream
12
+ */
13
+ readonly EventStream: "text/event-stream";
9
14
  /**
10
15
  * HTML - text/html
11
16
  */
12
17
  readonly Html: "text/html";
18
+ /**
19
+ * CSS - text/css
20
+ */
21
+ readonly Css: "text/css";
13
22
  /**
14
23
  * Javascript - text/javascript
15
24
  */
16
25
  readonly Javascript: "text/javascript";
26
+ /**
27
+ * Markdown - text/markdown
28
+ */
29
+ readonly Markdown: "text/markdown";
17
30
  /**
18
31
  * JSON - application/json
19
32
  */
20
33
  readonly Json: "application/json";
34
+ /**
35
+ * Problem JSON - application/problem+json
36
+ */
37
+ readonly ProblemJson: "application/problem+json";
21
38
  /**
22
39
  * JSON-LD - application/ld+json
23
40
  */
24
41
  readonly JsonLd: "application/ld+json";
42
+ /**
43
+ * Activity Streams - application/activity+json
44
+ */
45
+ readonly ActivityStreams: "application/activity+json";
46
+ /**
47
+ * WebFinger JRD - application/jrd+json
48
+ */
49
+ readonly JrdJson: "application/jrd+json";
25
50
  /**
26
51
  * JWT - application/jwt
27
52
  */
28
53
  readonly Jwt: "application/jwt";
54
+ /**
55
+ * Access Token JWT - application/at+jwt
56
+ */
57
+ readonly AccessTokenJwt: "application/at+jwt";
58
+ /**
59
+ * JOSE (Compact Serialization) - application/jose
60
+ */
61
+ readonly Jose: "application/jose";
62
+ /**
63
+ * JOSE (JSON Serialization) - application/jose+json
64
+ */
65
+ readonly JoseJson: "application/jose+json";
66
+ /**
67
+ * JSON Web Key (JWK) - application/jwk+json
68
+ */
69
+ readonly JwkJson: "application/jwk+json";
70
+ /**
71
+ * JSON Web Key Set (JWKS) - application/jwk-set+json
72
+ */
73
+ readonly JwkSetJson: "application/jwk-set+json";
74
+ /**
75
+ * Decentralized Identifier (DID) - application/did+json
76
+ */
77
+ readonly DidJson: "application/did+json";
78
+ /**
79
+ * Decentralized Identifier (DID) (JSON-LD) - application/did+ld+json
80
+ */
81
+ readonly DidLdJson: "application/did+ld+json";
82
+ /**
83
+ * Verifiable Credential (JSON-LD) - application/vc+ld+json
84
+ */
85
+ readonly VerifiableCredentialLdJson: "application/vc+ld+json";
86
+ /**
87
+ * Verifiable Presentation (JSON-LD) - application/vp+ld+json
88
+ */
89
+ readonly VerifiablePresentationLdJson: "application/vp+ld+json";
90
+ /**
91
+ * Verifiable Credential (JWT) - application/vc+jwt
92
+ */
93
+ readonly VerifiableCredentialJwt: "application/vc+jwt";
94
+ /**
95
+ * Verifiable Presentation (JWT) - application/vp+jwt
96
+ */
97
+ readonly VerifiablePresentationJwt: "application/vp+jwt";
98
+ /**
99
+ * JSON Patch - application/json-patch+json
100
+ */
101
+ readonly JsonPatch: "application/json-patch+json";
102
+ /**
103
+ * JSON Merge Patch - application/merge-patch+json
104
+ */
105
+ readonly MergePatch: "application/merge-patch+json";
106
+ /**
107
+ * CBOR Web Token (CWT) - application/cwt
108
+ */
109
+ readonly Cwt: "application/cwt";
110
+ /**
111
+ * COSE - application/cose
112
+ */
113
+ readonly Cose: "application/cose";
114
+ /**
115
+ * COSE Key - application/cose-key
116
+ */
117
+ readonly CoseKey: "application/cose-key";
118
+ /**
119
+ * COSE Key Set - application/cose-key-set
120
+ */
121
+ readonly CoseKeySet: "application/cose-key-set";
122
+ /**
123
+ * Form URL Encoded - application/x-www-form-urlencoded
124
+ */
125
+ readonly FormUrlEncoded: "application/x-www-form-urlencoded";
126
+ /**
127
+ * Multipart Form Data - multipart/form-data
128
+ */
129
+ readonly MultipartFormData: "multipart/form-data";
29
130
  /**
30
131
  * XML - application/xml
31
132
  */
32
133
  readonly Xml: "application/xml";
134
+ /**
135
+ * WASM - application/wasm
136
+ */
137
+ readonly Wasm: "application/wasm";
138
+ /**
139
+ * Web App Manifest - application/manifest+json
140
+ */
141
+ readonly WebManifest: "application/manifest+json";
33
142
  /**
34
143
  * Application Octet Stream, arbitrary binary - application/octet-stream
35
144
  */
@@ -78,10 +187,62 @@ export declare const MimeTypes: {
78
187
  * Image SVG - image/svg+xml
79
188
  */
80
189
  readonly Svg: "image/svg+xml";
190
+ /**
191
+ * Image ICO - image/x-icon
192
+ */
193
+ readonly Ico: "image/x-icon";
81
194
  /**
82
195
  * Image WEBP - image/webp
83
196
  */
84
197
  readonly WebP: "image/webp";
198
+ /**
199
+ * Image AVIF - image/avif
200
+ */
201
+ readonly Avif: "image/avif";
202
+ /**
203
+ * Image APNG - image/apng
204
+ */
205
+ readonly Apng: "image/apng";
206
+ /**
207
+ * Font WOFF - font/woff
208
+ */
209
+ readonly Woff: "font/woff";
210
+ /**
211
+ * Font WOFF2 - font/woff2
212
+ */
213
+ readonly Woff2: "font/woff2";
214
+ /**
215
+ * Font TTF - font/ttf
216
+ */
217
+ readonly Ttf: "font/ttf";
218
+ /**
219
+ * Font OTF - font/otf
220
+ */
221
+ readonly Otf: "font/otf";
222
+ /**
223
+ * Audio MP3 - audio/mpeg
224
+ */
225
+ readonly Mp3: "audio/mpeg";
226
+ /**
227
+ * Audio OGG - audio/ogg
228
+ */
229
+ readonly OggAudio: "audio/ogg";
230
+ /**
231
+ * Audio WAV - audio/wav
232
+ */
233
+ readonly Wav: "audio/wav";
234
+ /**
235
+ * Audio WEBM - audio/webm
236
+ */
237
+ readonly WebmAudio: "audio/webm";
238
+ /**
239
+ * Audio AAC - audio/aac
240
+ */
241
+ readonly Aac: "audio/aac";
242
+ /**
243
+ * Audio MP4 - audio/mp4
244
+ */
245
+ readonly Mp4Audio: "audio/mp4";
85
246
  /**
86
247
  * Video MP4 - video/mp4
87
248
  */
@@ -94,6 +255,14 @@ export declare const MimeTypes: {
94
255
  * Video WEBM - video/webm
95
256
  */
96
257
  readonly Webm: "video/webm";
258
+ /**
259
+ * Video OGG - video/ogg
260
+ */
261
+ readonly OggVideo: "video/ogg";
262
+ /**
263
+ * Video QuickTime - video/quicktime
264
+ */
265
+ readonly Quicktime: "video/quicktime";
97
266
  };
98
267
  /**
99
268
  * Common mime types.
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Class to help with cookie operations.
3
+ */
4
+ export declare class CookieHelper {
5
+ /**
6
+ * Runtime name for the class.
7
+ */
8
+ static readonly CLASS_NAME: string;
9
+ /**
10
+ * Create a cookie string.
11
+ * @param cookieName The name of the cookie.
12
+ * @param cookieValue The value of the cookie.
13
+ * @param options Additional cookie options.
14
+ * @param options.secure Should this be a secure cookie.
15
+ * @param options.httpOnly Should this be an http only cookie.
16
+ * @param options.sameSite The same site option for the cookie.
17
+ * @param options.path The path for the cookie.
18
+ * @returns The created cookie string.
19
+ */
20
+ static createCookie(cookieName: string, cookieValue: string, options?: {
21
+ secure?: boolean;
22
+ httpOnly?: boolean;
23
+ sameSite?: "Strict" | "Lax" | "None";
24
+ path?: string;
25
+ }): string;
26
+ /**
27
+ * Create a cookie string which will delete a cookie.
28
+ * @param cookieName The name of the cookie.
29
+ * @param options Additional cookie options.
30
+ * @param options.secure Should this be a secure cookie.
31
+ * @param options.httpOnly Should this be an http only cookie.
32
+ * @param options.sameSite The same site option for the cookie.
33
+ * @param options.path The path for the cookie.
34
+ * @returns The created cookie string.
35
+ */
36
+ static deleteCookie(cookieName: string, options?: {
37
+ secure?: boolean;
38
+ httpOnly?: boolean;
39
+ sameSite?: "Strict" | "Lax" | "None";
40
+ path?: string;
41
+ }): string;
42
+ /**
43
+ * Get cookies from headers.
44
+ * @param headers The headers to get cookies from.
45
+ * @param cookieName The name of the cookie to get.
46
+ * @returns The cookies found in the headers.
47
+ */
48
+ static getCookieFromHeaders(headers: string | string[] | undefined, cookieName: string): string | undefined;
49
+ }
@@ -2,6 +2,10 @@
2
2
  * Class to helper with header operations.
3
3
  */
4
4
  export declare class HeaderHelper {
5
+ /**
6
+ * Runtime name for the class.
7
+ */
8
+ static readonly CLASS_NAME: string;
5
9
  /**
6
10
  * Create a bearer token header.
7
11
  * @param token The token to create the header for.
@@ -14,4 +18,67 @@ export declare class HeaderHelper {
14
18
  * @returns The extracted token if it exists.
15
19
  */
16
20
  static extractBearer(header: unknown): string;
21
+ /**
22
+ * Extract the properties from a Link header for a specific relation type.
23
+ * @param linkHeader The Link header value in format `<url>; rel="..."; param1=""; param2=""`.
24
+ * @param relation The relation type to extract.
25
+ * @returns The extracted URL, rel and optional params or undefined if invalid/missing.
26
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link
27
+ */
28
+ static extractLinkHeaderRelation(linkHeader: unknown, relation: string): {
29
+ url: string;
30
+ urlQueryParams?: {
31
+ [id: string]: string;
32
+ };
33
+ rel: string;
34
+ params?: {
35
+ [id: string]: string;
36
+ };
37
+ } | undefined;
38
+ /**
39
+ * Extract the link headers.
40
+ * @param linkHeader The Link header value in format `<url>; rel="..."; param1=""; param2=""`.
41
+ * @returns The extracted possible array of 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 extractLinkHeaders(linkHeader: unknown): {
45
+ url: string;
46
+ urlQueryParams?: {
47
+ [id: string]: string;
48
+ };
49
+ rel: string;
50
+ params?: {
51
+ [id: string]: string;
52
+ };
53
+ }[] | undefined;
54
+ /**
55
+ * Extract the properties from a Link header.
56
+ * @param linkHeader The Link header value in format `<url>; rel="..."; param1=""; param2=""`.
57
+ * @returns The extracted URL, rel and optional params or undefined if invalid/missing.
58
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link
59
+ */
60
+ static extractLinkHeader(linkHeader: string): {
61
+ url: string;
62
+ urlQueryParams?: {
63
+ [id: string]: string;
64
+ };
65
+ rel: string;
66
+ params?: {
67
+ [id: string]: string;
68
+ };
69
+ } | undefined;
70
+ /**
71
+ * Create a compliant Link header.
72
+ * @param url The URL to include in the Link header.
73
+ * @param urlQueryParams Optional query parameters to include in the URL.
74
+ * @param rel The relation type (e.g., "next", "prev", "self").
75
+ * @returns The formatted Link header string.
76
+ * @throws GeneralError if the URL or rel are invalid.
77
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link
78
+ */
79
+ static createLinkHeader(url: string, urlQueryParams: {
80
+ [id: string]: string;
81
+ } | undefined, rel: string, params?: {
82
+ [id: string]: string;
83
+ }): string;
17
84
  }