@twin.org/web 0.0.3-next.7 → 0.0.3-next.9
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/es/index.js +1 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/utils/cookieHelper.js +83 -0
- package/dist/es/utils/cookieHelper.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utils/cookieHelper.d.ts +49 -0
- package/docs/changelog.md +40 -0
- package/docs/reference/classes/CookieHelper.md +155 -0
- package/docs/reference/index.md +1 -0
- package/package.json +4 -4
package/dist/es/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./models/IJwtHeader.js";
|
|
|
11
11
|
export * from "./models/IJwtPayload.js";
|
|
12
12
|
export * from "./models/jwkCryptoKey.js";
|
|
13
13
|
export * from "./models/mimeTypes.js";
|
|
14
|
+
export * from "./utils/cookieHelper.js";
|
|
14
15
|
export * from "./utils/fetchHelper.js";
|
|
15
16
|
export * from "./utils/headerHelper.js";
|
|
16
17
|
export * from "./utils/jwk.js";
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./errors/fetchError.js\";\nexport * from \"./models/headerTypes.js\";\nexport * from \"./models/httpMethod.js\";\nexport * from \"./models/httpStatusCode.js\";\nexport * from \"./models/IFetchOptions.js\";\nexport * from \"./models/IHttpHeaders.js\";\nexport * from \"./models/IJwk.js\";\nexport * from \"./models/IJwtHeader.js\";\nexport * from \"./models/IJwtPayload.js\";\nexport * from \"./models/jwkCryptoKey.js\";\nexport * from \"./models/mimeTypes.js\";\nexport * from \"./utils/fetchHelper.js\";\nexport * from \"./utils/headerHelper.js\";\nexport * from \"./utils/jwk.js\";\nexport * from \"./utils/jws.js\";\nexport * from \"./utils/jwt.js\";\nexport * from \"./utils/mimeTypeHelper.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./errors/fetchError.js\";\nexport * from \"./models/headerTypes.js\";\nexport * from \"./models/httpMethod.js\";\nexport * from \"./models/httpStatusCode.js\";\nexport * from \"./models/IFetchOptions.js\";\nexport * from \"./models/IHttpHeaders.js\";\nexport * from \"./models/IJwk.js\";\nexport * from \"./models/IJwtHeader.js\";\nexport * from \"./models/IJwtPayload.js\";\nexport * from \"./models/jwkCryptoKey.js\";\nexport * from \"./models/mimeTypes.js\";\nexport * from \"./utils/cookieHelper.js\";\nexport * from \"./utils/fetchHelper.js\";\nexport * from \"./utils/headerHelper.js\";\nexport * from \"./utils/jwk.js\";\nexport * from \"./utils/jws.js\";\nexport * from \"./utils/jwt.js\";\nexport * from \"./utils/mimeTypeHelper.js\";\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,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9B,CAAC;QACD,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;YAC3B,WAAW,CAAC,IAAI,CAAC,YAAY,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,YAAY,CAAC,IAAI,EAAE,CAAC;YACvB,WAAW,CAAC,IAAI,CAAC,QAAQ,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,YAAY,CACzB,UAAkB,EAClB,OAKC;QAED,OAAO,GAAG,YAAY,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,EAAE,OAAO,CAAC,aAAa,CAAC;IAC3E,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,oBAAoB,CACjC,OAAsC,EACtC,UAAkB;QAElB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,gBAAsB,UAAU,CAAC,CAAC;QAE5E,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YACxB,MAAM,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YAC7D,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC9B,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC5B,MAAM,iBAAiB,GAAG,MAAM;yBAC9B,KAAK,CAAC,GAAG,CAAC;yBACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;yBAClB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC;oBAE5C,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"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./models/IJwtHeader.js";
|
|
|
9
9
|
export * from "./models/IJwtPayload.js";
|
|
10
10
|
export * from "./models/jwkCryptoKey.js";
|
|
11
11
|
export * from "./models/mimeTypes.js";
|
|
12
|
+
export * from "./utils/cookieHelper.js";
|
|
12
13
|
export * from "./utils/fetchHelper.js";
|
|
13
14
|
export * from "./utils/headerHelper.js";
|
|
14
15
|
export * from "./utils/jwk.js";
|
|
@@ -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
|
+
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @twin.org/web - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.9](https://github.com/twinfoundation/framework/compare/web-v0.0.3-next.8...web-v0.0.3-next.9) (2026-01-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add cookie helper method to web package ([#217](https://github.com/twinfoundation/framework/issues/217)) ([043c632](https://github.com/twinfoundation/framework/commit/043c63298bff96f70bdefed56b82afef42ec3f44))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/core bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
16
|
+
* @twin.org/crypto bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
17
|
+
* @twin.org/nameof bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
18
|
+
* devDependencies
|
|
19
|
+
* @twin.org/nameof-transformer bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
20
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
21
|
+
* @twin.org/validate-locales bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
22
|
+
|
|
23
|
+
## [0.0.3-next.8](https://github.com/twinfoundation/framework/compare/web-v0.0.3-next.7...web-v0.0.3-next.8) (2025-11-26)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Miscellaneous Chores
|
|
27
|
+
|
|
28
|
+
* **web:** Synchronize repo versions
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Dependencies
|
|
32
|
+
|
|
33
|
+
* The following workspace dependencies were updated
|
|
34
|
+
* dependencies
|
|
35
|
+
* @twin.org/core bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
36
|
+
* @twin.org/crypto bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
37
|
+
* @twin.org/nameof bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
38
|
+
* devDependencies
|
|
39
|
+
* @twin.org/nameof-transformer bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
40
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
41
|
+
* @twin.org/validate-locales bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
42
|
+
|
|
3
43
|
## [0.0.3-next.7](https://github.com/twinfoundation/framework/compare/web-v0.0.3-next.6...web-v0.0.3-next.7) (2025-11-25)
|
|
4
44
|
|
|
5
45
|
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Class: CookieHelper
|
|
2
|
+
|
|
3
|
+
Class to help with cookie operations.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
> **new CookieHelper**(): `CookieHelper`
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
`CookieHelper`
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### CLASS\_NAME
|
|
18
|
+
|
|
19
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
|
+
|
|
21
|
+
Runtime name for the class.
|
|
22
|
+
|
|
23
|
+
## Methods
|
|
24
|
+
|
|
25
|
+
### createCookie()
|
|
26
|
+
|
|
27
|
+
> `static` **createCookie**(`cookieName`, `cookieValue`, `options?`): `string`
|
|
28
|
+
|
|
29
|
+
Create a cookie string.
|
|
30
|
+
|
|
31
|
+
#### Parameters
|
|
32
|
+
|
|
33
|
+
##### cookieName
|
|
34
|
+
|
|
35
|
+
`string`
|
|
36
|
+
|
|
37
|
+
The name of the cookie.
|
|
38
|
+
|
|
39
|
+
##### cookieValue
|
|
40
|
+
|
|
41
|
+
`string`
|
|
42
|
+
|
|
43
|
+
The value of the cookie.
|
|
44
|
+
|
|
45
|
+
##### options?
|
|
46
|
+
|
|
47
|
+
Additional cookie options.
|
|
48
|
+
|
|
49
|
+
###### secure?
|
|
50
|
+
|
|
51
|
+
`boolean`
|
|
52
|
+
|
|
53
|
+
Should this be a secure cookie.
|
|
54
|
+
|
|
55
|
+
###### httpOnly?
|
|
56
|
+
|
|
57
|
+
`boolean`
|
|
58
|
+
|
|
59
|
+
Should this be an http only cookie.
|
|
60
|
+
|
|
61
|
+
###### sameSite?
|
|
62
|
+
|
|
63
|
+
`"Strict"` \| `"Lax"` \| `"None"`
|
|
64
|
+
|
|
65
|
+
The same site option for the cookie.
|
|
66
|
+
|
|
67
|
+
###### path?
|
|
68
|
+
|
|
69
|
+
`string`
|
|
70
|
+
|
|
71
|
+
The path for the cookie.
|
|
72
|
+
|
|
73
|
+
#### Returns
|
|
74
|
+
|
|
75
|
+
`string`
|
|
76
|
+
|
|
77
|
+
The created cookie string.
|
|
78
|
+
|
|
79
|
+
***
|
|
80
|
+
|
|
81
|
+
### deleteCookie()
|
|
82
|
+
|
|
83
|
+
> `static` **deleteCookie**(`cookieName`, `options?`): `string`
|
|
84
|
+
|
|
85
|
+
Create a cookie string which will delete a cookie.
|
|
86
|
+
|
|
87
|
+
#### Parameters
|
|
88
|
+
|
|
89
|
+
##### cookieName
|
|
90
|
+
|
|
91
|
+
`string`
|
|
92
|
+
|
|
93
|
+
The name of the cookie.
|
|
94
|
+
|
|
95
|
+
##### options?
|
|
96
|
+
|
|
97
|
+
Additional cookie options.
|
|
98
|
+
|
|
99
|
+
###### secure?
|
|
100
|
+
|
|
101
|
+
`boolean`
|
|
102
|
+
|
|
103
|
+
Should this be a secure cookie.
|
|
104
|
+
|
|
105
|
+
###### httpOnly?
|
|
106
|
+
|
|
107
|
+
`boolean`
|
|
108
|
+
|
|
109
|
+
Should this be an http only cookie.
|
|
110
|
+
|
|
111
|
+
###### sameSite?
|
|
112
|
+
|
|
113
|
+
`"Strict"` \| `"Lax"` \| `"None"`
|
|
114
|
+
|
|
115
|
+
The same site option for the cookie.
|
|
116
|
+
|
|
117
|
+
###### path?
|
|
118
|
+
|
|
119
|
+
`string`
|
|
120
|
+
|
|
121
|
+
The path for the cookie.
|
|
122
|
+
|
|
123
|
+
#### Returns
|
|
124
|
+
|
|
125
|
+
`string`
|
|
126
|
+
|
|
127
|
+
The created cookie string.
|
|
128
|
+
|
|
129
|
+
***
|
|
130
|
+
|
|
131
|
+
### getCookieFromHeaders()
|
|
132
|
+
|
|
133
|
+
> `static` **getCookieFromHeaders**(`headers`, `cookieName`): `string` \| `undefined`
|
|
134
|
+
|
|
135
|
+
Get cookies from headers.
|
|
136
|
+
|
|
137
|
+
#### Parameters
|
|
138
|
+
|
|
139
|
+
##### headers
|
|
140
|
+
|
|
141
|
+
The headers to get cookies from.
|
|
142
|
+
|
|
143
|
+
`string` | `string`[] | `undefined`
|
|
144
|
+
|
|
145
|
+
##### cookieName
|
|
146
|
+
|
|
147
|
+
`string`
|
|
148
|
+
|
|
149
|
+
The name of the cookie to get.
|
|
150
|
+
|
|
151
|
+
#### Returns
|
|
152
|
+
|
|
153
|
+
`string` \| `undefined`
|
|
154
|
+
|
|
155
|
+
The cookies found in the headers.
|
package/docs/reference/index.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/web",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.9",
|
|
4
4
|
"description": "Contains classes for use with web operations",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/core": "0.0.3-next.
|
|
18
|
-
"@twin.org/crypto": "0.0.3-next.
|
|
19
|
-
"@twin.org/nameof": "0.0.3-next.
|
|
17
|
+
"@twin.org/core": "0.0.3-next.9",
|
|
18
|
+
"@twin.org/crypto": "0.0.3-next.9",
|
|
19
|
+
"@twin.org/nameof": "0.0.3-next.9",
|
|
20
20
|
"jose": "6.1.1"
|
|
21
21
|
},
|
|
22
22
|
"main": "./dist/es/index.js",
|