@croct/sdk 0.17.9 → 0.17.10

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 (107) hide show
  1. package/activeRecord.cjs +135 -0
  2. package/apiKey.cjs +178 -0
  3. package/base64Url.cjs +41 -0
  4. package/cache/cache.cjs +34 -0
  5. package/cache/cookieCache.cjs +85 -0
  6. package/cache/fallbackCache.cjs +47 -0
  7. package/cache/inMemoryCache.cjs +41 -0
  8. package/cache/index.cjs +37 -0
  9. package/cache/localStorageCache.cjs +81 -0
  10. package/channel/channel.cjs +48 -0
  11. package/channel/encodedChannel.cjs +39 -0
  12. package/channel/guaranteedChannel.cjs +105 -0
  13. package/channel/httpBeaconChannel.cjs +111 -0
  14. package/channel/index.cjs +46 -0
  15. package/channel/queuedChannel.cjs +122 -0
  16. package/channel/retryChannel.cjs +87 -0
  17. package/channel/sandboxChannel.cjs +63 -0
  18. package/cid/assigner.cjs +16 -0
  19. package/cid/cachedAssigner.cjs +66 -0
  20. package/cid/fixedAssigner.cjs +35 -0
  21. package/cid/index.cjs +37 -0
  22. package/cid/remoteAssigner.cjs +65 -0
  23. package/constants.cjs +37 -0
  24. package/constants.cjs.map +1 -1
  25. package/constants.d.ts +2 -2
  26. package/constants.js +1 -1
  27. package/constants.js.map +1 -1
  28. package/container.cjs +305 -0
  29. package/contentFetcher.cjs +193 -0
  30. package/context.cjs +114 -0
  31. package/error.cjs +52 -0
  32. package/evaluator.cjs +219 -0
  33. package/eventManager.cjs +53 -0
  34. package/eventSubjectProcessor.cjs +84 -0
  35. package/facade/contentFetcherFacade.cjs +61 -0
  36. package/facade/evaluatorFacade.cjs +94 -0
  37. package/facade/index.cjs +52 -0
  38. package/facade/sdkFacade.cjs +229 -0
  39. package/facade/sessionFacade.cjs +36 -0
  40. package/facade/sessionPatch.cjs +48 -0
  41. package/facade/trackerFacade.cjs +87 -0
  42. package/facade/userFacade.cjs +43 -0
  43. package/facade/userPatch.cjs +48 -0
  44. package/help.cjs +45 -0
  45. package/index.cjs +33 -0
  46. package/logging/consoleLogger.cjs +50 -0
  47. package/logging/filteredLogger.cjs +62 -0
  48. package/logging/index.cjs +40 -0
  49. package/logging/logger.cjs +16 -0
  50. package/logging/namespacedLogger.cjs +48 -0
  51. package/logging/nullLogger.cjs +37 -0
  52. package/namespacedStorage.cjs +77 -0
  53. package/package.json +7 -6
  54. package/patch.cjs +16 -0
  55. package/queue/capacityRestrictedQueue.cjs +57 -0
  56. package/queue/inMemoryQueue.cjs +58 -0
  57. package/queue/index.cjs +40 -0
  58. package/queue/monitoredQueue.cjs +141 -0
  59. package/queue/persistentQueue.cjs +78 -0
  60. package/queue/queue.cjs +16 -0
  61. package/retry/arbitraryPolicy.cjs +41 -0
  62. package/retry/backoffPolicy.cjs +81 -0
  63. package/retry/index.cjs +40 -0
  64. package/retry/maxAttemptsPolicy.cjs +45 -0
  65. package/retry/neverPolicy.cjs +35 -0
  66. package/retry/policy.cjs +16 -0
  67. package/schema/attributeSchema.cjs +32 -0
  68. package/schema/contentFetcherSchemas.cjs +49 -0
  69. package/schema/contentSchemas.cjs +70 -0
  70. package/schema/contextSchemas.cjs +31 -0
  71. package/schema/ecommerceSchemas.cjs +209 -0
  72. package/schema/evaluatorSchemas.cjs +64 -0
  73. package/schema/eventSchemas.cjs +162 -0
  74. package/schema/index.cjs +42 -0
  75. package/schema/loggerSchema.cjs +38 -0
  76. package/schema/operationSchemas.cjs +122 -0
  77. package/schema/sdkFacadeSchemas.cjs +82 -0
  78. package/schema/sdkSchemas.cjs +110 -0
  79. package/schema/tokenSchema.cjs +68 -0
  80. package/schema/userSchema.cjs +202 -0
  81. package/sdk.cjs +134 -0
  82. package/sdkEvents.cjs +16 -0
  83. package/sourceLocation.cjs +92 -0
  84. package/tab.cjs +122 -0
  85. package/token/cachedTokenStore.cjs +51 -0
  86. package/token/inMemoryTokenStore.cjs +38 -0
  87. package/token/index.cjs +37 -0
  88. package/token/replicatedTokenStore.cjs +40 -0
  89. package/token/token.cjs +239 -0
  90. package/tracker.cjs +358 -0
  91. package/trackingEvents.cjs +94 -0
  92. package/transformer.cjs +30 -0
  93. package/utilityTypes.cjs +16 -0
  94. package/uuid.cjs +55 -0
  95. package/validation/arrayType.cjs +75 -0
  96. package/validation/booleanType.cjs +46 -0
  97. package/validation/functionType.cjs +46 -0
  98. package/validation/index.cjs +66 -0
  99. package/validation/jsonType.cjs +142 -0
  100. package/validation/mixedSchema.cjs +31 -0
  101. package/validation/nullType.cjs +46 -0
  102. package/validation/numberType.cjs +69 -0
  103. package/validation/objectType.cjs +114 -0
  104. package/validation/schema.cjs +34 -0
  105. package/validation/stringType.cjs +106 -0
  106. package/validation/unionType.cjs +67 -0
  107. package/validation/violation.cjs +47 -0
@@ -0,0 +1,135 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var activeRecord_exports = {};
19
+ __export(activeRecord_exports, {
20
+ ActiveRecord: () => ActiveRecord
21
+ });
22
+ module.exports = __toCommonJS(activeRecord_exports);
23
+ var import_schema = require("./schema");
24
+ const operationSchema = {
25
+ add: import_schema.addOperation,
26
+ set: import_schema.setOperation,
27
+ merge: import_schema.mergeOperation,
28
+ combine: import_schema.combineOperation,
29
+ increment: import_schema.incrementOperation,
30
+ decrement: import_schema.decrementOperation,
31
+ clear: import_schema.clearOperation,
32
+ unset: import_schema.unsetOperation,
33
+ remove: import_schema.removeOperation
34
+ };
35
+ class ActiveRecord {
36
+ constructor() {
37
+ this.operations = [];
38
+ }
39
+ set(propertyOrValue, value) {
40
+ if (typeof propertyOrValue === "string") {
41
+ return this.pushOperation({
42
+ type: "set",
43
+ path: propertyOrValue,
44
+ value
45
+ });
46
+ }
47
+ return this.pushOperation({
48
+ type: "set",
49
+ path: ".",
50
+ value: propertyOrValue
51
+ });
52
+ }
53
+ add(property, value) {
54
+ return this.pushOperation({
55
+ type: "add",
56
+ path: property,
57
+ value
58
+ });
59
+ }
60
+ combine(property, value) {
61
+ return this.pushOperation({
62
+ type: "combine",
63
+ path: property,
64
+ value
65
+ });
66
+ }
67
+ merge(propertyOrValue, value) {
68
+ if (typeof propertyOrValue === "string") {
69
+ return this.pushOperation({
70
+ type: "merge",
71
+ path: propertyOrValue,
72
+ value
73
+ });
74
+ }
75
+ return this.pushOperation({
76
+ type: "merge",
77
+ path: ".",
78
+ value: propertyOrValue
79
+ });
80
+ }
81
+ increment(property, amount = 1) {
82
+ return this.pushOperation({
83
+ type: "increment",
84
+ path: property,
85
+ value: amount
86
+ });
87
+ }
88
+ decrement(property, amount = 1) {
89
+ return this.pushOperation({
90
+ type: "decrement",
91
+ path: property,
92
+ value: amount
93
+ });
94
+ }
95
+ clear(property) {
96
+ return this.pushOperation({
97
+ type: "clear",
98
+ path: property
99
+ });
100
+ }
101
+ unset(property) {
102
+ return this.pushOperation({
103
+ type: "unset",
104
+ path: property
105
+ });
106
+ }
107
+ remove(property, value) {
108
+ return this.pushOperation({
109
+ type: "remove",
110
+ path: property,
111
+ value
112
+ });
113
+ }
114
+ pushOperation(operation) {
115
+ const { type, ...data } = operation;
116
+ operationSchema[type].validate(data);
117
+ this.operations.push(operation);
118
+ return this;
119
+ }
120
+ reset() {
121
+ this.operations.splice(0);
122
+ return this;
123
+ }
124
+ isDirty() {
125
+ return this.operations.length > 0;
126
+ }
127
+ buildPatch() {
128
+ return { operations: this.operations.slice() };
129
+ }
130
+ }
131
+ // Annotate the CommonJS export names for ESM import in node:
132
+ 0 && (module.exports = {
133
+ ActiveRecord
134
+ });
135
+ //# sourceMappingURL=activeRecord.cjs.map
package/apiKey.cjs ADDED
@@ -0,0 +1,178 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var apiKey_exports = {};
19
+ __export(apiKey_exports, {
20
+ ApiKey: () => ApiKey
21
+ });
22
+ module.exports = __toCommonJS(apiKey_exports);
23
+ const _ApiKey = class _ApiKey {
24
+ constructor(identifier, privateKey) {
25
+ this.identifier = identifier;
26
+ this.privateKey = privateKey;
27
+ }
28
+ static from(apiKey) {
29
+ if (apiKey instanceof _ApiKey) {
30
+ return apiKey;
31
+ }
32
+ return _ApiKey.parse(apiKey);
33
+ }
34
+ static parse(apiKey) {
35
+ const parts = apiKey.split(":");
36
+ if (parts.length > 2) {
37
+ throw new Error("Invalid API key format.");
38
+ }
39
+ return _ApiKey.of(parts[0], parts[1]);
40
+ }
41
+ static of(identifier, privateKey) {
42
+ if (!_ApiKey.IDENTIFIER_PATTERN.test(identifier)) {
43
+ throw new Error("The identifier must be a UUID.");
44
+ }
45
+ if (privateKey === void 0 || privateKey === "") {
46
+ return new _ApiKey(identifier);
47
+ }
48
+ if (!_ApiKey.PRIVATE_KEY_PATTERN.test(privateKey)) {
49
+ throw new Error("The private key is malformed.");
50
+ }
51
+ const [algorithmName, encodedKey] = privateKey.split(";");
52
+ if (!(algorithmName in _ApiKey.ALGORITHMS)) {
53
+ throw new Error(`Unsupported signing algorithm "${algorithmName}".`);
54
+ }
55
+ return new _ApiKey(identifier, {
56
+ algorithm: algorithmName,
57
+ encodedKey
58
+ });
59
+ }
60
+ getIdentifier() {
61
+ return this.identifier;
62
+ }
63
+ async getIdentifierHash() {
64
+ const identifierBytes = _ApiKey.createByteArrayFromHexString(this.identifier.replace(/-/g, ""));
65
+ const rawHash = await crypto.subtle.digest("SHA-256", identifierBytes);
66
+ return _ApiKey.convertBufferToHexString(rawHash);
67
+ }
68
+ hasPrivateKey() {
69
+ return this.privateKey !== void 0;
70
+ }
71
+ getPrivateKey() {
72
+ if (this.privateKey === void 0) {
73
+ throw new Error("The API key does not have a private key.");
74
+ }
75
+ return `${this.privateKey.algorithm};${this.privateKey.encodedKey}`;
76
+ }
77
+ async sign(data) {
78
+ const key = await this.importKey();
79
+ const algorithm = this.getSigningAlgorithm();
80
+ return _ApiKey.convertBufferToString(
81
+ await crypto.subtle.sign(
82
+ _ApiKey.ALGORITHMS[algorithm].signatureAlgorithm,
83
+ key,
84
+ _ApiKey.createByteArrayFromString(data)
85
+ )
86
+ );
87
+ }
88
+ getSigningAlgorithm() {
89
+ const { algorithm } = this.getParsedPrivateKey();
90
+ return algorithm;
91
+ }
92
+ importKey() {
93
+ const { algorithm, encodedKey } = this.getParsedPrivateKey();
94
+ if (this.importedKey === void 0) {
95
+ this.importedKey = crypto.subtle.importKey(
96
+ "pkcs8",
97
+ _ApiKey.createByteArrayFromString(atob(encodedKey)),
98
+ _ApiKey.ALGORITHMS[algorithm].keyAlgorithm,
99
+ false,
100
+ ["sign"]
101
+ );
102
+ }
103
+ return this.importedKey;
104
+ }
105
+ getParsedPrivateKey() {
106
+ if (this.privateKey === void 0) {
107
+ throw new Error("The API key does not have a private key.");
108
+ }
109
+ return this.privateKey;
110
+ }
111
+ export() {
112
+ return this.identifier + (this.hasPrivateKey() ? `:${this.getPrivateKey()}` : "");
113
+ }
114
+ toString() {
115
+ return "[redacted]";
116
+ }
117
+ /**
118
+ * Create an array buffer from a string.
119
+ *
120
+ * @see https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String
121
+ *
122
+ * @param data The string to convert.
123
+ * @returns The array buffer.
124
+ */
125
+ static createByteArrayFromString(data) {
126
+ const byteArray = new Uint8Array(data.length);
127
+ for (let i = 0; i < byteArray.length; i++) {
128
+ byteArray[i] = data.charCodeAt(i);
129
+ }
130
+ return byteArray;
131
+ }
132
+ static createByteArrayFromHexString(data) {
133
+ const byteArray = new Uint8Array(data.length / 2);
134
+ for (let i = 0; i < byteArray.length; i++) {
135
+ byteArray[i] = parseInt(data.substring(i * 2, i * 2 + 2), 16);
136
+ }
137
+ return byteArray;
138
+ }
139
+ /**
140
+ * Convert an array buffer to a string.
141
+ *
142
+ * @see https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String
143
+ *
144
+ * @param buffer The buffer to convert.
145
+ * @returns The string.
146
+ */
147
+ static convertBufferToString(buffer) {
148
+ return String.fromCharCode(...new Uint8Array(buffer));
149
+ }
150
+ static convertBufferToHexString(buffer) {
151
+ const bytes = new Uint8Array(buffer);
152
+ let hexString = "";
153
+ for (let i = 0; i < bytes.length; i++) {
154
+ hexString += bytes[i].toString(16).padStart(2, "0");
155
+ }
156
+ return hexString;
157
+ }
158
+ };
159
+ _ApiKey.IDENTIFIER_PATTERN = /^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/i;
160
+ _ApiKey.PRIVATE_KEY_PATTERN = /^[a-z0-9]+;[^;]+$/i;
161
+ _ApiKey.ALGORITHMS = {
162
+ ES256: {
163
+ keyAlgorithm: {
164
+ name: "ECDSA",
165
+ namedCurve: "P-256"
166
+ },
167
+ signatureAlgorithm: {
168
+ name: "ECDSA",
169
+ hash: "SHA-256"
170
+ }
171
+ }
172
+ };
173
+ let ApiKey = _ApiKey;
174
+ // Annotate the CommonJS export names for ESM import in node:
175
+ 0 && (module.exports = {
176
+ ApiKey
177
+ });
178
+ //# sourceMappingURL=apiKey.cjs.map
package/base64Url.cjs ADDED
@@ -0,0 +1,41 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var base64Url_exports = {};
19
+ __export(base64Url_exports, {
20
+ base64UrlDecode: () => base64UrlDecode,
21
+ base64UrlEncode: () => base64UrlEncode
22
+ });
23
+ module.exports = __toCommonJS(base64Url_exports);
24
+ function base64Unescape(value) {
25
+ return (value + "===".slice((value.length + 3) % 4)).replace(/-/g, "+").replace(/_/g, "/");
26
+ }
27
+ function base64Escape(value) {
28
+ return value.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
29
+ }
30
+ function base64UrlEncode(value, utf8 = false) {
31
+ return utf8 ? base64Escape(btoa(String.fromCodePoint(...new TextEncoder().encode(value)))) : base64Escape(btoa(value));
32
+ }
33
+ function base64UrlDecode(value, utf8 = false) {
34
+ return utf8 ? new TextDecoder().decode(Uint8Array.from(atob(base64Unescape(value)), (m) => m.codePointAt(0))) : atob(base64Unescape(value));
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ base64UrlDecode,
39
+ base64UrlEncode
40
+ });
41
+ //# sourceMappingURL=base64Url.cjs.map
@@ -0,0 +1,34 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var cache_exports = {};
19
+ __export(cache_exports, {
20
+ ObservableCache: () => ObservableCache
21
+ });
22
+ module.exports = __toCommonJS(cache_exports);
23
+ var ObservableCache;
24
+ ((ObservableCache2) => {
25
+ function isObservable(cache) {
26
+ return typeof cache.addListener === "function" && typeof cache.removeListener === "function";
27
+ }
28
+ ObservableCache2.isObservable = isObservable;
29
+ })(ObservableCache || (ObservableCache = {}));
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ ObservableCache
33
+ });
34
+ //# sourceMappingURL=cache.cjs.map
@@ -0,0 +1,85 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var cookieCache_exports = {};
19
+ __export(cookieCache_exports, {
20
+ CookieCache: () => CookieCache
21
+ });
22
+ module.exports = __toCommonJS(cookieCache_exports);
23
+ class CookieCache {
24
+ constructor(config, defaultSecure = window.location.protocol === "https:") {
25
+ this.config = {
26
+ ...config,
27
+ path: config.path ?? "/"
28
+ };
29
+ if (defaultSecure && this.config.secure === void 0) {
30
+ this.config.secure = true;
31
+ }
32
+ if (this.config.secure === true && this.config.sameSite === void 0) {
33
+ this.config.sameSite = "none";
34
+ }
35
+ }
36
+ get() {
37
+ const entries = document.cookie.split(";");
38
+ for (const entry of entries) {
39
+ const [name, value] = entry.split("=");
40
+ if (CookieCache.decode(name).trim() === this.config.name) {
41
+ return CookieCache.decode(value.trim());
42
+ }
43
+ }
44
+ return null;
45
+ }
46
+ put(value) {
47
+ document.cookie = CookieCache.serializeCookie(value, this.config);
48
+ }
49
+ clear() {
50
+ document.cookie = CookieCache.serializeCookie("", {
51
+ ...this.config,
52
+ maxAge: 0
53
+ });
54
+ }
55
+ static serializeCookie(value, config) {
56
+ const cookie = [`${CookieCache.encode(config.name)}=${CookieCache.encode(value)}`];
57
+ if (config.maxAge !== void 0) {
58
+ cookie.push(`Max-Age=${config.maxAge}`);
59
+ }
60
+ if (config.domain !== void 0) {
61
+ cookie.push(`Domain=${CookieCache.encode(config.domain)}`);
62
+ }
63
+ if (config.path !== void 0) {
64
+ cookie.push(`Path=${CookieCache.encode(config.path)}`);
65
+ }
66
+ if (config.secure === true) {
67
+ cookie.push("Secure");
68
+ }
69
+ if (config.sameSite !== void 0) {
70
+ cookie.push(`SameSite=${{ strict: "Strict", lax: "Lax", none: "None" }[config.sameSite]}`);
71
+ }
72
+ return cookie.join("; ");
73
+ }
74
+ static encode(value) {
75
+ return value.replace(/[,; ]+/g, encodeURIComponent);
76
+ }
77
+ static decode(value) {
78
+ return decodeURIComponent(value);
79
+ }
80
+ }
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ CookieCache
84
+ });
85
+ //# sourceMappingURL=cookieCache.cjs.map
@@ -0,0 +1,47 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var fallbackCache_exports = {};
19
+ __export(fallbackCache_exports, {
20
+ FallbackCache: () => FallbackCache
21
+ });
22
+ module.exports = __toCommonJS(fallbackCache_exports);
23
+ class FallbackCache {
24
+ constructor(...caches) {
25
+ this.caches = caches;
26
+ }
27
+ get() {
28
+ for (const cache of this.caches) {
29
+ const value = cache.get();
30
+ if (value !== null) {
31
+ return value;
32
+ }
33
+ }
34
+ return null;
35
+ }
36
+ put(value) {
37
+ this.caches.forEach((cache) => cache.put(value));
38
+ }
39
+ clear() {
40
+ this.caches.forEach((cache) => cache.clear());
41
+ }
42
+ }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ FallbackCache
46
+ });
47
+ //# sourceMappingURL=fallbackCache.cjs.map
@@ -0,0 +1,41 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var inMemoryCache_exports = {};
19
+ __export(inMemoryCache_exports, {
20
+ InMemoryCache: () => InMemoryCache
21
+ });
22
+ module.exports = __toCommonJS(inMemoryCache_exports);
23
+ class InMemoryCache {
24
+ constructor(cache) {
25
+ this.cache = cache;
26
+ }
27
+ get() {
28
+ return this.cache ?? null;
29
+ }
30
+ put(value) {
31
+ this.cache = value;
32
+ }
33
+ clear() {
34
+ delete this.cache;
35
+ }
36
+ }
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ InMemoryCache
40
+ });
41
+ //# sourceMappingURL=inMemoryCache.cjs.map
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var cache_exports = {};
20
+ __export(cache_exports, {
21
+ FallbackCache: () => import_fallbackCache.FallbackCache,
22
+ InMemoryCache: () => import_inMemoryCache.InMemoryCache,
23
+ LocalStorageCache: () => import_localStorageCache.LocalStorageCache
24
+ });
25
+ module.exports = __toCommonJS(cache_exports);
26
+ __reExport(cache_exports, require("./cache"), module.exports);
27
+ var import_fallbackCache = require("./fallbackCache");
28
+ var import_inMemoryCache = require("./inMemoryCache");
29
+ var import_localStorageCache = require("./localStorageCache");
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ FallbackCache,
33
+ InMemoryCache,
34
+ LocalStorageCache,
35
+ ...require("./cache")
36
+ });
37
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,81 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var localStorageCache_exports = {};
19
+ __export(localStorageCache_exports, {
20
+ LocalStorageCache: () => LocalStorageCache
21
+ });
22
+ module.exports = __toCommonJS(localStorageCache_exports);
23
+ class LocalStorageCache {
24
+ constructor(storage, key) {
25
+ this.listeners = [];
26
+ this.storage = storage;
27
+ this.key = key;
28
+ this.value = storage.getItem(key);
29
+ }
30
+ static autoSync(cache) {
31
+ const listener = cache.sync.bind(cache);
32
+ window.addEventListener("storage", listener);
33
+ return () => window.removeEventListener("storage", listener);
34
+ }
35
+ get() {
36
+ return this.value;
37
+ }
38
+ put(value) {
39
+ this.storage.setItem(this.key, value);
40
+ if (this.value !== value) {
41
+ this.value = value;
42
+ this.notifyChange(value);
43
+ }
44
+ }
45
+ clear() {
46
+ this.storage.removeItem(this.key);
47
+ if (this.value !== null) {
48
+ this.value = null;
49
+ this.notifyChange(null);
50
+ }
51
+ }
52
+ addListener(listener) {
53
+ if (!this.listeners.includes(listener)) {
54
+ this.listeners.push(listener);
55
+ }
56
+ }
57
+ removeListener(listener) {
58
+ const index = this.listeners.indexOf(listener);
59
+ if (index > -1) {
60
+ this.listeners.splice(index, 1);
61
+ }
62
+ }
63
+ notifyChange(value) {
64
+ this.listeners.forEach((listener) => listener(value));
65
+ }
66
+ sync(event) {
67
+ if (event.storageArea !== this.storage || event.key !== null && event.key !== this.key) {
68
+ return;
69
+ }
70
+ const value = this.storage.getItem(this.key);
71
+ if (this.value !== value) {
72
+ this.value = value;
73
+ this.notifyChange(value);
74
+ }
75
+ }
76
+ }
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ LocalStorageCache
80
+ });
81
+ //# sourceMappingURL=localStorageCache.cjs.map