@nordcraft/std-lib 1.0.17 → 1.0.19

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.
@@ -0,0 +1,3 @@
1
+ import type { ActionHandler } from '@nordcraft/core/dist/types';
2
+ declare const handler: ActionHandler;
3
+ export default handler;
@@ -0,0 +1,49 @@
1
+ const handler = async function ([name, value, ttl, _sameSite, _path, _includeSubdomains], ctx) {
2
+ const error = (message) => ctx.triggerActionEvent('Error', new Error(message));
3
+ if (typeof name !== 'string') {
4
+ error('The "Name" argument must be a string');
5
+ return;
6
+ }
7
+ if (typeof value !== 'string') {
8
+ error('The "Value" argument must be a string');
9
+ return;
10
+ }
11
+ const sameSite = _sameSite ?? 'Lax'; // Default value
12
+ if (typeof sameSite !== 'string' ||
13
+ !['lax', 'strict', 'none'].includes(sameSite.toLocaleLowerCase())) {
14
+ error('The "SameSite" argument must be "Lax", "Strict" or "None"');
15
+ return;
16
+ }
17
+ const path = _path ?? '/'; // Default value
18
+ if (typeof path !== 'string' || !path.startsWith('/')) {
19
+ error('The "Path" argument must be a string and start with /');
20
+ return;
21
+ }
22
+ if (ttl !== undefined &&
23
+ ttl !== null &&
24
+ (typeof ttl !== 'number' || isNaN(ttl))) {
25
+ error('The "Expires in" argument must be a number');
26
+ return;
27
+ }
28
+ const includeSubdomains = _includeSubdomains ?? true; // Default value
29
+ if (typeof includeSubdomains !== 'boolean') {
30
+ error('The "Include Subdomains" argument must be a boolean');
31
+ return;
32
+ }
33
+ // The cookie will always be set to Secure. Anything else can be configured
34
+ let cookie = `${name}=${value}; SameSite=${sameSite}; Path=${path}`;
35
+ // If no ttl is set, the cookie will be a session cookie
36
+ if (typeof ttl === 'number') {
37
+ const date = new Date(Date.now() + ttl * 1000);
38
+ cookie += `; Expires=${date.toUTCString()}`;
39
+ }
40
+ if (includeSubdomains) {
41
+ // When the domain is set, the cookie is also available to subdomains - otherwise
42
+ // it is only available on the current domain
43
+ cookie += `; Domain=${window.location.hostname}`;
44
+ }
45
+ document.cookie = cookie;
46
+ ctx.triggerActionEvent('Success', undefined);
47
+ };
48
+ export default handler;
49
+ //# sourceMappingURL=handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../actions/setCookie/handler.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAkB,KAAK,WAClC,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,CAAC,EACxD,GAAG;IAEH,MAAM,KAAK,GAAG,CAAC,OAAe,EAAE,EAAE,CAChC,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;IACrD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,KAAK,CAAC,sCAAsC,CAAC,CAAA;QAC7C,OAAM;IACR,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,KAAK,CAAC,uCAAuC,CAAC,CAAA;QAC9C,OAAM;IACR,CAAC;IACD,MAAM,QAAQ,GAAG,SAAS,IAAI,KAAK,CAAA,CAAC,gBAAgB;IACpD,IACE,OAAO,QAAQ,KAAK,QAAQ;QAC5B,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,EACjE,CAAC;QACD,KAAK,CAAC,2DAA2D,CAAC,CAAA;QAClE,OAAM;IACR,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,IAAI,GAAG,CAAA,CAAC,gBAAgB;IAC1C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACtD,KAAK,CAAC,uDAAuD,CAAC,CAAA;QAC9D,OAAM;IACR,CAAC;IACD,IACE,GAAG,KAAK,SAAS;QACjB,GAAG,KAAK,IAAI;QACZ,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,EACvC,CAAC;QACD,KAAK,CAAC,4CAA4C,CAAC,CAAA;QACnD,OAAM;IACR,CAAC;IACD,MAAM,iBAAiB,GAAG,kBAAkB,IAAI,IAAI,CAAA,CAAC,gBAAgB;IACrE,IAAI,OAAO,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAC3C,KAAK,CAAC,qDAAqD,CAAC,CAAA;QAC5D,OAAM;IACR,CAAC;IACD,2EAA2E;IAC3E,IAAI,MAAM,GAAG,GAAG,IAAI,IAAI,KAAK,cAAc,QAAQ,UAAU,IAAI,EAAE,CAAA;IACnE,wDAAwD;IACxD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,CAAA;QAC9C,MAAM,IAAI,aAAa,IAAI,CAAC,WAAW,EAAE,EAAE,CAAA;IAC7C,CAAC;IACD,IAAI,iBAAiB,EAAE,CAAC;QACtB,iFAAiF;QACjF,6CAA6C;QAC7C,MAAM,IAAI,YAAY,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAA;IAClD,CAAC;IACD,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,GAAG,CAAC,kBAAkB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;AAC9C,CAAC,CAAA;AAED,eAAe,OAAO,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { ActionHandler } from '@nordcraft/core/dist/types';
2
+ declare const handler: ActionHandler;
3
+ export default handler;
@@ -0,0 +1,56 @@
1
+ const handler = async function ([name, value, ttl, _sameSite, _path, _includeSubdomains], ctx) {
2
+ const error = (message) => ctx.triggerActionEvent('Error', new Error(message));
3
+ if (typeof name !== 'string') {
4
+ error('The "Name" argument must be a string');
5
+ return;
6
+ }
7
+ if (typeof value !== 'string') {
8
+ error('The "Value" argument must be a string');
9
+ return;
10
+ }
11
+ const sameSite = _sameSite ?? 'Lax'; // Default value
12
+ if (typeof sameSite !== 'string' ||
13
+ !['lax', 'strict', 'none'].includes(sameSite.toLocaleLowerCase())) {
14
+ error('The "SameSite" argument must be "Lax", "Strict" or "None"');
15
+ return;
16
+ }
17
+ const path = _path ?? '/'; // Default value
18
+ if (typeof path !== 'string' || !path.startsWith('/')) {
19
+ error('The "Path" argument must be a string and start with /');
20
+ return;
21
+ }
22
+ if (ttl !== undefined &&
23
+ ttl !== null &&
24
+ (typeof ttl !== 'number' || isNaN(ttl))) {
25
+ error('The "Expires in" argument must be a number');
26
+ return;
27
+ }
28
+ const includeSubdomains = _includeSubdomains ?? true; // Default value
29
+ if (typeof includeSubdomains !== 'boolean') {
30
+ error('The "Include Subdomains" argument must be a boolean');
31
+ return;
32
+ }
33
+ const params = new URLSearchParams();
34
+ params.set('name', name);
35
+ params.set('value', value);
36
+ params.set('sameSite', sameSite);
37
+ params.set('path', path);
38
+ params.set('includeSubdomains', String(includeSubdomains));
39
+ if (typeof ttl === 'number') {
40
+ params.set('ttl', String(ttl));
41
+ }
42
+ try {
43
+ const res = await fetch(`/.nordcraft/cookies/set-cookie?${params.toString()}`);
44
+ if (res.ok) {
45
+ ctx.triggerActionEvent('Success', undefined);
46
+ }
47
+ else {
48
+ error(await res.text());
49
+ }
50
+ }
51
+ catch (err) {
52
+ error(err instanceof Error ? err.message : 'An unexpected error occurred');
53
+ }
54
+ };
55
+ export default handler;
56
+ //# sourceMappingURL=handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../actions/setHttpOnlyCookie/handler.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAkB,KAAK,WAClC,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,CAAC,EACxD,GAAG;IAEH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AAC;IACD,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAA;IACpC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACxB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC1B,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IAChC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACxB,MAAM,CAAC,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAA;IAC1D,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IAChC,CAAC;IACD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CACrB,kCAAkC,MAAM,CAAC,QAAQ,EAAE,EAAE,CACtD,CAAA;QACD,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;YACX,GAAG,CAAC,kBAAkB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QAC9C,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAA;IAC5E,CAAC;AACH,CAAC,CAAA;AAED,eAAe,OAAO,CAAA"}
package/dist/actions.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import * as saveToLocalStorage from "./actions/saveToLocalStorage/handler";
2
+ import * as setHttpOnlyCookie from "./actions/setHttpOnlyCookie/handler";
2
3
  import * as clearSessionStorage from "./actions/clearSessionStorage/handler";
3
4
  import * as saveToSessionStorage from "./actions/saveToSessionStorage/handler";
4
5
  import * as gotToURL from "./actions/gotToURL/handler";
5
6
  import * as preventDefault from "./actions/preventDefault/handler";
6
7
  import * as sleep from "./actions/sleep/handler";
7
8
  import * as focus from "./actions/focus/handler";
9
+ import * as setCookie from "./actions/setCookie/handler";
8
10
  import * as clearLocalStorage from "./actions/clearLocalStorage/handler";
9
11
  import * as copyToClipboard from "./actions/copyToClipboard/handler";
10
12
  import * as interval from "./actions/interval/handler";
@@ -14,4 +16,4 @@ import * as setSessionCookies from "./actions/setSessionCookies/handler";
14
16
  import * as deleteFromSessionStorage from "./actions/deleteFromSessionStorage/handler";
15
17
  import * as share from "./actions/share/handler";
16
18
  import * as logToConsole from "./actions/logToConsole/handler";
17
- export { saveToLocalStorage, clearSessionStorage, saveToSessionStorage, gotToURL, preventDefault, sleep, focus, clearLocalStorage, copyToClipboard, interval, stopPropagation, deleteFromLocalStorage, setSessionCookies, deleteFromSessionStorage, share, logToConsole };
19
+ export { saveToLocalStorage, setHttpOnlyCookie, clearSessionStorage, saveToSessionStorage, gotToURL, preventDefault, sleep, focus, setCookie, clearLocalStorage, copyToClipboard, interval, stopPropagation, deleteFromLocalStorage, setSessionCookies, deleteFromSessionStorage, share, logToConsole };
package/dist/actions.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import * as saveToLocalStorage from "./actions/saveToLocalStorage/handler";
2
+ import * as setHttpOnlyCookie from "./actions/setHttpOnlyCookie/handler";
2
3
  import * as clearSessionStorage from "./actions/clearSessionStorage/handler";
3
4
  import * as saveToSessionStorage from "./actions/saveToSessionStorage/handler";
4
5
  import * as gotToURL from "./actions/gotToURL/handler";
5
6
  import * as preventDefault from "./actions/preventDefault/handler";
6
7
  import * as sleep from "./actions/sleep/handler";
7
8
  import * as focus from "./actions/focus/handler";
9
+ import * as setCookie from "./actions/setCookie/handler";
8
10
  import * as clearLocalStorage from "./actions/clearLocalStorage/handler";
9
11
  import * as copyToClipboard from "./actions/copyToClipboard/handler";
10
12
  import * as interval from "./actions/interval/handler";
@@ -14,5 +16,5 @@ import * as setSessionCookies from "./actions/setSessionCookies/handler";
14
16
  import * as deleteFromSessionStorage from "./actions/deleteFromSessionStorage/handler";
15
17
  import * as share from "./actions/share/handler";
16
18
  import * as logToConsole from "./actions/logToConsole/handler";
17
- export { saveToLocalStorage, clearSessionStorage, saveToSessionStorage, gotToURL, preventDefault, sleep, focus, clearLocalStorage, copyToClipboard, interval, stopPropagation, deleteFromLocalStorage, setSessionCookies, deleteFromSessionStorage, share, logToConsole };
19
+ export { saveToLocalStorage, setHttpOnlyCookie, clearSessionStorage, saveToSessionStorage, gotToURL, preventDefault, sleep, focus, setCookie, clearLocalStorage, copyToClipboard, interval, stopPropagation, deleteFromLocalStorage, setSessionCookies, deleteFromSessionStorage, share, logToConsole };
18
20
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,MAAM,sCAAsC,CAAA;AAC1E,OAAO,KAAK,mBAAmB,MAAM,uCAAuC,CAAA;AAC5E,OAAO,KAAK,oBAAoB,MAAM,wCAAwC,CAAA;AAC9E,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAA;AACtD,OAAO,KAAK,cAAc,MAAM,kCAAkC,CAAA;AAClE,OAAO,KAAK,KAAK,MAAM,yBAAyB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,yBAAyB,CAAA;AAChD,OAAO,KAAK,iBAAiB,MAAM,qCAAqC,CAAA;AACxE,OAAO,KAAK,eAAe,MAAM,mCAAmC,CAAA;AACpE,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAA;AACtD,OAAO,KAAK,eAAe,MAAM,mCAAmC,CAAA;AACpE,OAAO,KAAK,sBAAsB,MAAM,0CAA0C,CAAA;AAClF,OAAO,KAAK,iBAAiB,MAAM,qCAAqC,CAAA;AACxE,OAAO,KAAK,wBAAwB,MAAM,4CAA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kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,QAAQ,EACR,cAAc,EACd,KAAK,EACL,KAAK,EACL,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,QAAQ,EACR,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,EACL,YAAY,EACb,CAAA"}
@@ -1,3 +1,3 @@
1
- import type { ActionHandler } from '@nordcraft/core/dist/types';
2
- declare const handler: ActionHandler;
1
+ import type { FormulaHandler } from '@nordcraft/core/dist/types';
2
+ declare const handler: FormulaHandler<boolean>;
3
3
  export default handler;
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../formulas/canShare/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAE3D,MAAM,OAAO,GAAkB,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;IACpD,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnC,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,UAAU,GAAG,CAAC,KAAU,EAAmB,EAAE,CACjD,SAAS,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAA;IAC/C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAChE,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,IAAI,GAAc,EAAE,CAAA;IAC1B,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC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AAED,eAAe,OAAO,CAAA"}
@@ -1,3 +1,3 @@
1
1
  import type { FormulaHandler } from '@nordcraft/core/dist/types';
2
- declare const handler: FormulaHandler<string>;
2
+ declare const handler: FormulaHandler<string | Array<unknown> | Record<string, unknown>>;
3
3
  export default handler;
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../formulas/concatenate/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAE1D,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;IAChD,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,EAAE,CAAA;QACjB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;QACtB,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,CAAA;IACpC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACvB,CAAC,CAAA;AAED,eAAe,OAAO,CAAA"}
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../formulas/concatenate/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAE1D,MAAM,OAAO,GAET,CAAC,KAAK,EAAE,EAAE;IACZ,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,EAAE,CAAA;QACjB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;QACtB,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,CAAA;IACpC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACvB,CAAC,CAAA;AAED,eAAe,OAAO,CAAA"}
package/dist/lib.ts CHANGED
@@ -923,7 +923,7 @@
923
923
  },
924
924
  "@toddle/fromEntries": {
925
925
  "name": "From entries",
926
- "description": "Create a record from an Array of entries. This formula is the reverse of Entries.",
926
+ "description": "Transform an Array of key-value pairs into an Object. This formula is the reverse of Entries.",
927
927
  "arguments": [
928
928
  {
929
929
  "name": "Array",
@@ -931,14 +931,14 @@
931
931
  "type": "value",
932
932
  "value": null
933
933
  },
934
- "description": "The array of entries.",
934
+ "description": "An Array of Objects. Each Object should have a `key` and `value` property named `key` and `value` respectively e.g. `[{ key: 'yourKey', value: 'yourValue' }]`.",
935
935
  "type": {
936
936
  "type": "Array"
937
937
  }
938
938
  }
939
939
  ],
940
940
  "output": {
941
- "description": "An Object containing all entries from the input Array.",
941
+ "description": "An Object containing all entries from the input Array in the format `{yourKey: yourValue}`.",
942
942
  "type": {
943
943
  "type": "Object"
944
944
  }
@@ -2932,6 +2932,88 @@
2932
2932
  }
2933
2933
  ]
2934
2934
  },
2935
+ "@toddle/setHttpOnlyCookie": {
2936
+ "name": "Set Http-Only Cookie",
2937
+ "description": "Save a key/value pair as an Http-Only cookie. Useful for storing JWTs or other tokens.",
2938
+ "arguments": [
2939
+ {
2940
+ "name": "Name",
2941
+ "description": "The name of the cookie.",
2942
+ "type": {
2943
+ "type": "String"
2944
+ },
2945
+ "formula": {
2946
+ "type": "value",
2947
+ "value": "access_token"
2948
+ }
2949
+ },
2950
+ {
2951
+ "name": "Value",
2952
+ "description": "The value to be stored in the cookie.",
2953
+ "type": {
2954
+ "type": "String"
2955
+ },
2956
+ "formula": {
2957
+ "type": "value",
2958
+ "value": ""
2959
+ }
2960
+ },
2961
+ {
2962
+ "name": "Expires in",
2963
+ "description": "(Optional) Time in seconds until the cookie expires. This should be null for JWTs to use the JWT's expiration. If not provided, the cookie will be a session cookie.",
2964
+ "type": {
2965
+ "type": "Number"
2966
+ },
2967
+ "formula": {
2968
+ "type": "value",
2969
+ "value": null
2970
+ }
2971
+ },
2972
+ {
2973
+ "name": "SameSite",
2974
+ "description": "(Optional) The SameSite attribute of the cookie. Defaults to Lax.",
2975
+ "type": {
2976
+ "type": "String"
2977
+ },
2978
+ "formula": {
2979
+ "type": "value",
2980
+ "value": null
2981
+ }
2982
+ },
2983
+ {
2984
+ "name": "Path",
2985
+ "description": "(Optional) The Path attribute of the cookie. Defaults to /.",
2986
+ "type": {
2987
+ "type": "String"
2988
+ },
2989
+ "formula": {
2990
+ "type": "value",
2991
+ "value": null
2992
+ }
2993
+ },
2994
+ {
2995
+ "name": "Include Subdomains",
2996
+ "description": "(Optional) Whether to include subdomains when setting the cookie. Defaults to true.",
2997
+ "type": {
2998
+ "type": "Boolean"
2999
+ },
3000
+ "formula": {
3001
+ "type": "value",
3002
+ "value": null
3003
+ }
3004
+ }
3005
+ ],
3006
+ "events": {
3007
+ "Success": {
3008
+ "description": "This event is triggered once the cookie has been saved.",
3009
+ "actions": []
3010
+ },
3011
+ "Error": {
3012
+ "description": "This event is triggered if the cookie could not be saved.",
3013
+ "actions": []
3014
+ }
3015
+ }
3016
+ },
2935
3017
  "@toddle/clearSessionStorage": {
2936
3018
  "name": "Clear Session Storage",
2937
3019
  "description": "Delete all values in session storage.",
@@ -3027,6 +3109,88 @@
3027
3109
  }
3028
3110
  ]
3029
3111
  },
3112
+ "@toddle/setCookie": {
3113
+ "name": "Set Cookie",
3114
+ "description": "Save a key/value pair as a non-http-only cookie (readable on the client). Useful for storing user preferences.",
3115
+ "arguments": [
3116
+ {
3117
+ "name": "Name",
3118
+ "description": "The name of the cookie.",
3119
+ "type": {
3120
+ "type": "String"
3121
+ },
3122
+ "formula": {
3123
+ "type": "value",
3124
+ "value": ""
3125
+ }
3126
+ },
3127
+ {
3128
+ "name": "Value",
3129
+ "description": "The value to be stored in the cookie.",
3130
+ "type": {
3131
+ "type": "String"
3132
+ },
3133
+ "formula": {
3134
+ "type": "value",
3135
+ "value": ""
3136
+ }
3137
+ },
3138
+ {
3139
+ "name": "Expires in",
3140
+ "description": "(Optional) Time in seconds until the cookie expires. If this is null, the cookie will expire at the end of the user's session.",
3141
+ "type": {
3142
+ "type": "Number"
3143
+ },
3144
+ "formula": {
3145
+ "type": "value",
3146
+ "value": null
3147
+ }
3148
+ },
3149
+ {
3150
+ "name": "SameSite",
3151
+ "description": "(Optional) The SameSite attribute of the cookie. Defaults to Lax.",
3152
+ "type": {
3153
+ "type": "String"
3154
+ },
3155
+ "formula": {
3156
+ "type": "value",
3157
+ "value": null
3158
+ }
3159
+ },
3160
+ {
3161
+ "name": "Path",
3162
+ "description": "(Optional) The Path attribute of the cookie. Defaults to /.",
3163
+ "type": {
3164
+ "type": "String"
3165
+ },
3166
+ "formula": {
3167
+ "type": "value",
3168
+ "value": null
3169
+ }
3170
+ },
3171
+ {
3172
+ "name": "Include Subdomains",
3173
+ "description": "(Optional) Whether to include subdomains when setting the cookie. Defaults to true.",
3174
+ "type": {
3175
+ "type": "Boolean"
3176
+ },
3177
+ "formula": {
3178
+ "type": "value",
3179
+ "value": null
3180
+ }
3181
+ }
3182
+ ],
3183
+ "events": {
3184
+ "Success": {
3185
+ "description": "This event is triggered once the cookie has been saved.",
3186
+ "actions": []
3187
+ },
3188
+ "Error": {
3189
+ "description": "This event is triggered if the cookie could not be saved.",
3190
+ "actions": []
3191
+ }
3192
+ }
3193
+ },
3030
3194
  "@toddle/clearLocalStorage": {
3031
3195
  "name": "Clear Local Storage",
3032
3196
  "description": "Delete all values in local storage.",
package/package.json CHANGED
@@ -5,17 +5,18 @@
5
5
  "homepage": "https://github.com/nordcraftengine/nordcraft",
6
6
  "dependencies": {
7
7
  "fast-deep-equal": "3.1.3",
8
- "@nordcraft/core": "1.0.17"
8
+ "@nordcraft/core": "1.0.19"
9
9
  },
10
10
  "devDependencies": {
11
- "@types/node": "22.15.21"
11
+ "@types/node": "22.15.23",
12
+ "@happy-dom/global-registrator": "17.5.6"
12
13
  },
13
14
  "scripts": {
14
15
  "build": "bun ./bin/generate.js && tsc --project tsconfig.build.json",
15
16
  "npm-publish": "bun run build && bun publish --access public",
16
17
  "typecheck": "tsc --noEmit",
17
- "typecheck:watch": "tsc --noEmit -w"
18
+ "watch": "tsc --noEmit -w"
18
19
  },
19
20
  "files": ["dist"],
20
- "version": "1.0.17"
21
+ "version": "1.0.19"
21
22
  }