@blamejs/blamejs-shop 0.5.19 → 0.5.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 (194) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -0
  3. package/SECURITY.md +17 -0
  4. package/lib/addresses.js +2 -2
  5. package/lib/admin.js +49 -45
  6. package/lib/affiliates.js +7 -23
  7. package/lib/announcement-bar.js +5 -22
  8. package/lib/api-keys.js +4 -13
  9. package/lib/asset-manifest.json +1 -1
  10. package/lib/banner-ab-tests.js +5 -9
  11. package/lib/blog-articles.js +8 -26
  12. package/lib/captcha-gate.js +7 -17
  13. package/lib/carrier-accounts.js +3 -10
  14. package/lib/catalog-drafts.js +5 -12
  15. package/lib/category-navigation.js +4 -20
  16. package/lib/cms-blocks.js +4 -7
  17. package/lib/compliance-export.js +4 -11
  18. package/lib/consent-ledger.js +2 -4
  19. package/lib/cost-layers.js +56 -21
  20. package/lib/customer-import.js +2 -2
  21. package/lib/customer-notes.js +7 -23
  22. package/lib/customer-roles.js +3 -5
  23. package/lib/customer-segments.js +17 -14
  24. package/lib/customer-surveys.js +7 -14
  25. package/lib/customers.js +2 -4
  26. package/lib/dispute-resolution.js +5 -13
  27. package/lib/dropship-forwarding.js +3 -5
  28. package/lib/dunning.js +2 -7
  29. package/lib/email-ab-tests.js +4 -8
  30. package/lib/email-campaigns.js +25 -14
  31. package/lib/email-warmup.js +2 -7
  32. package/lib/experiments.js +6 -10
  33. package/lib/externaldb-d1.js +78 -44
  34. package/lib/geolocation.js +18 -28
  35. package/lib/gift-options.js +5 -23
  36. package/lib/knowledge-base.js +7 -22
  37. package/lib/line-gift-wrap.js +3 -17
  38. package/lib/live-chat.js +5 -18
  39. package/lib/metered-usage.js +3 -8
  40. package/lib/notifications.js +3 -7
  41. package/lib/operator-accounts.js +3 -5
  42. package/lib/operator-approvals.js +6 -8
  43. package/lib/operator-audit-log.js +2 -7
  44. package/lib/operator-help-center.js +5 -21
  45. package/lib/operator-inbox.js +4 -11
  46. package/lib/operator-roles.js +5 -7
  47. package/lib/order-escalation.js +2 -2
  48. package/lib/order-export.js +24 -20
  49. package/lib/order-notes.js +4 -14
  50. package/lib/order-ratings.js +4 -10
  51. package/lib/payment-methods.js +5 -13
  52. package/lib/payment-retries.js +2 -7
  53. package/lib/payment.js +103 -58
  54. package/lib/pixel-events.js +8 -23
  55. package/lib/plan-changes.js +2 -7
  56. package/lib/product-qa.js +4 -8
  57. package/lib/promo-banners.js +7 -15
  58. package/lib/purchase-orders.js +3 -6
  59. package/lib/push-notifications.js +7 -32
  60. package/lib/pwa-manifest.js +6 -11
  61. package/lib/quotes.js +5 -9
  62. package/lib/referrals.js +10 -6
  63. package/lib/reviews.js +4 -10
  64. package/lib/robots-config.js +6 -14
  65. package/lib/sales-tax-filings.js +2 -2
  66. package/lib/search-facets.js +5 -5
  67. package/lib/search-ranking.js +4 -7
  68. package/lib/search-synonyms.js +7 -21
  69. package/lib/security-middleware.js +125 -70
  70. package/lib/seller-signup.js +10 -26
  71. package/lib/sidebar-widgets.js +6 -15
  72. package/lib/site-redirects.js +49 -137
  73. package/lib/sitemap-generator.js +3 -7
  74. package/lib/sms-dispatcher.js +7 -23
  75. package/lib/stock-receipts.js +4 -10
  76. package/lib/storefront-dashboards.js +2 -10
  77. package/lib/storefront-forms.js +9 -22
  78. package/lib/storefront-pages.js +6 -20
  79. package/lib/storefront.js +21 -23
  80. package/lib/subscription-billing.js +3 -8
  81. package/lib/subscription-controls.js +2 -7
  82. package/lib/suggestion-box.js +9 -26
  83. package/lib/support-tickets.js +6 -24
  84. package/lib/tax-remittance.js +2 -2
  85. package/lib/tenants.js +2 -7
  86. package/lib/text-guard.js +137 -35
  87. package/lib/theme-assets.js +4 -16
  88. package/lib/translations.js +3 -6
  89. package/lib/trust-badges.js +4 -7
  90. package/lib/vendor/MANIFEST.json +107 -97
  91. package/lib/vendor/blamejs/CHANGELOG.md +180 -0
  92. package/lib/vendor/blamejs/NOTICE +14 -10
  93. package/lib/vendor/blamejs/README.md +17 -5
  94. package/lib/vendor/blamejs/index.js +2 -0
  95. package/lib/vendor/blamejs/lib/acme.js +9 -9
  96. package/lib/vendor/blamejs/lib/api-snapshot.js +35 -16
  97. package/lib/vendor/blamejs/lib/app-shutdown.js +1 -1
  98. package/lib/vendor/blamejs/lib/archive-adapters.js +1 -1
  99. package/lib/vendor/blamejs/lib/archive.js +13 -24
  100. package/lib/vendor/blamejs/lib/auth/access-lock.js +2 -1
  101. package/lib/vendor/blamejs/lib/auth/bot-challenge.js +3 -6
  102. package/lib/vendor/blamejs/lib/auth/ciba.js +32 -3
  103. package/lib/vendor/blamejs/lib/auth/oauth.js +65 -8
  104. package/lib/vendor/blamejs/lib/auth/password.js +1 -1
  105. package/lib/vendor/blamejs/lib/auth/saml.js +21 -3
  106. package/lib/vendor/blamejs/lib/auth-bot-challenge.js +3 -3
  107. package/lib/vendor/blamejs/lib/backup/index.js +5 -5
  108. package/lib/vendor/blamejs/lib/case-fold-classes.js +491 -0
  109. package/lib/vendor/blamejs/lib/codepoint-class.js +131 -0
  110. package/lib/vendor/blamejs/lib/constants.js +79 -0
  111. package/lib/vendor/blamejs/lib/db-declare-view.js +8 -2
  112. package/lib/vendor/blamejs/lib/error-page.js +20 -1
  113. package/lib/vendor/blamejs/lib/external-db.js +5 -1
  114. package/lib/vendor/blamejs/lib/flag-evaluation-context.js +24 -6
  115. package/lib/vendor/blamejs/lib/flag.js +28 -2
  116. package/lib/vendor/blamejs/lib/framework-schema.js +14 -3
  117. package/lib/vendor/blamejs/lib/guard-regex.js +2345 -89
  118. package/lib/vendor/blamejs/lib/http-client.js +217 -40
  119. package/lib/vendor/blamejs/lib/mail-bimi.js +1 -1
  120. package/lib/vendor/blamejs/lib/mail-crypto-pgp.js +3 -2
  121. package/lib/vendor/blamejs/lib/mail-dav.js +26 -26
  122. package/lib/vendor/blamejs/lib/mail-deploy.js +10 -10
  123. package/lib/vendor/blamejs/lib/mail-scan.js +3 -0
  124. package/lib/vendor/blamejs/lib/mail-store.js +7 -1
  125. package/lib/vendor/blamejs/lib/mail.js +5 -1
  126. package/lib/vendor/blamejs/lib/middleware/age-gate.js +3 -2
  127. package/lib/vendor/blamejs/lib/middleware/api-encrypt.js +1 -1
  128. package/lib/vendor/blamejs/lib/middleware/assetlinks.js +2 -1
  129. package/lib/vendor/blamejs/lib/middleware/asyncapi-serve.js +3 -2
  130. package/lib/vendor/blamejs/lib/middleware/bearer-auth.js +2 -1
  131. package/lib/vendor/blamejs/lib/middleware/compression.js +1 -1
  132. package/lib/vendor/blamejs/lib/middleware/cors.js +1 -1
  133. package/lib/vendor/blamejs/lib/middleware/csp-report.js +5 -5
  134. package/lib/vendor/blamejs/lib/middleware/csrf-protect.js +2 -1
  135. package/lib/vendor/blamejs/lib/middleware/daily-byte-quota.js +2 -2
  136. package/lib/vendor/blamejs/lib/middleware/deny-response.js +2 -1
  137. package/lib/vendor/blamejs/lib/middleware/dpop.js +2 -2
  138. package/lib/vendor/blamejs/lib/middleware/fetch-metadata.js +2 -1
  139. package/lib/vendor/blamejs/lib/middleware/flag-context.js +17 -0
  140. package/lib/vendor/blamejs/lib/middleware/idempotency-key.js +10 -8
  141. package/lib/vendor/blamejs/lib/middleware/openapi-serve.js +3 -2
  142. package/lib/vendor/blamejs/lib/middleware/require-aal.js +3 -2
  143. package/lib/vendor/blamejs/lib/middleware/require-auth.js +4 -3
  144. package/lib/vendor/blamejs/lib/middleware/require-bound-key.js +4 -3
  145. package/lib/vendor/blamejs/lib/middleware/require-content-type.js +3 -2
  146. package/lib/vendor/blamejs/lib/middleware/require-methods.js +3 -2
  147. package/lib/vendor/blamejs/lib/middleware/require-mtls.js +3 -2
  148. package/lib/vendor/blamejs/lib/middleware/security-txt.js +2 -1
  149. package/lib/vendor/blamejs/lib/middleware/web-app-manifest.js +2 -1
  150. package/lib/vendor/blamejs/lib/network-dns-resolver.js +1 -1
  151. package/lib/vendor/blamejs/lib/network-dns.js +3 -3
  152. package/lib/vendor/blamejs/lib/network-nts.js +35 -14
  153. package/lib/vendor/blamejs/lib/network-proxy.js +42 -4
  154. package/lib/vendor/blamejs/lib/network-smtp-policy.js +1 -1
  155. package/lib/vendor/blamejs/lib/network-tls.js +341 -11
  156. package/lib/vendor/blamejs/lib/nist-crosswalk.js +2 -2
  157. package/lib/vendor/blamejs/lib/ntp-check.js +30 -19
  158. package/lib/vendor/blamejs/lib/object-store/azure-blob.js +1 -1
  159. package/lib/vendor/blamejs/lib/object-store/gcs.js +1 -1
  160. package/lib/vendor/blamejs/lib/object-store/http-put.js +2 -1
  161. package/lib/vendor/blamejs/lib/object-store/sigv4-bucket-ops.js +5 -5
  162. package/lib/vendor/blamejs/lib/object-store/sigv4.js +2 -2
  163. package/lib/vendor/blamejs/lib/observability-otlp-exporter.js +4 -2
  164. package/lib/vendor/blamejs/lib/openapi.js +1 -1
  165. package/lib/vendor/blamejs/lib/pqc-agent.js +4 -7
  166. package/lib/vendor/blamejs/lib/problem-details.js +2 -1
  167. package/lib/vendor/blamejs/lib/redis-client.js +12 -1
  168. package/lib/vendor/blamejs/lib/regex-linear.js +1349 -0
  169. package/lib/vendor/blamejs/lib/render.js +531 -7
  170. package/lib/vendor/blamejs/lib/request-helpers.js +181 -5
  171. package/lib/vendor/blamejs/lib/router.js +37 -13
  172. package/lib/vendor/blamejs/lib/safe-async.js +142 -0
  173. package/lib/vendor/blamejs/lib/safe-icap.js +3 -0
  174. package/lib/vendor/blamejs/lib/safe-sql.js +15 -3
  175. package/lib/vendor/blamejs/lib/self-update.js +2 -2
  176. package/lib/vendor/blamejs/lib/testing.js +54 -7
  177. package/lib/vendor/blamejs/lib/validate-opts.js +56 -0
  178. package/lib/vendor/blamejs/lib/vendor/MANIFEST.json +62 -25
  179. package/lib/vendor/blamejs/lib/vendor/blamejs-pki.cjs +2004 -142
  180. package/lib/vendor/blamejs/lib/vendor/browser/noble-ciphers.mjs +727 -0
  181. package/lib/vendor/blamejs/lib/vendor/browser/noble-hashes.mjs +1070 -0
  182. package/lib/vendor/blamejs/lib/vendor/browser/noble-post-quantum.mjs +1090 -0
  183. package/lib/vendor/blamejs/lib/vendor/noble-post-quantum.cjs +510 -227
  184. package/lib/vendor/blamejs/lib/webhook-hmac.js +19 -2
  185. package/lib/vendor/blamejs/lib/webhook.js +1 -1
  186. package/lib/vendor/blamejs/lib/ws-client.js +24 -2
  187. package/lib/vendor/blamejs/package.json +1 -1
  188. package/lib/vendor/blamejs/sbom.cdx.json +6 -6
  189. package/lib/vendor-invoices.js +3 -6
  190. package/lib/vendors.js +5 -19
  191. package/lib/webhook-receiver.js +46 -83
  192. package/lib/webhook-subscriptions.js +3 -13
  193. package/lib/wishlist-sharing.js +5 -10
  194. package/package.json +1 -1
@@ -0,0 +1,727 @@
1
+ // XChaCha20-Poly1305 — vendored from @noble/ciphers v2.3.0 by Paul Miller
2
+ // License: MIT — https://github.com/paulmillr/noble-ciphers
3
+ // Browser build (ESM), bundled with esbuild from the same install as the
4
+ // server bundle beside it. Exports: xchacha20poly1305
5
+ // node_modules/@noble/ciphers/utils.js
6
+ function isBytes(a) {
7
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
8
+ }
9
+ var atitle = (title) => title ? `"${title}" ` : "";
10
+ function abool(value, title = "") {
11
+ if (typeof value !== "boolean")
12
+ throw new TypeError(atitle(title) + "expected boolean, got type=" + typeof value);
13
+ return value;
14
+ }
15
+ function anumber(n, title = "") {
16
+ if (typeof n !== "number")
17
+ throw new TypeError(atitle(title) + "expected number, got " + typeof n);
18
+ if (!Number.isSafeInteger(n) || n < 0)
19
+ throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
20
+ return n;
21
+ }
22
+ function abytes(value, length, title = "") {
23
+ if (isBytes(value) && (length === void 0 || value.length === length))
24
+ return value;
25
+ if (length !== void 0)
26
+ anumber(length, "length");
27
+ const bytes = isBytes(value);
28
+ const ofLen = length !== void 0 ? ` of length ${length}` : "";
29
+ const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
30
+ const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
31
+ if (!bytes)
32
+ throw new TypeError(message);
33
+ throw new RangeError(message);
34
+ }
35
+ var aobject = (value, label) => {
36
+ if (value === null || typeof value !== "object" || Array.isArray(value))
37
+ throw new TypeError(label === "object" ? "expected valid options object" : `"${label}" expected object, got type=${typeof value}`);
38
+ };
39
+ function aexists(instance, checkFinished = true) {
40
+ if (instance.destroyed)
41
+ throw new Error("hash was destroyed");
42
+ if (checkFinished && instance.finished)
43
+ throw new Error("digest() was already called");
44
+ }
45
+ function aoutput(out, instance) {
46
+ abytes(out, void 0, "output");
47
+ const min = instance.outputLen;
48
+ if (!(out.length >= min)) {
49
+ throw new RangeError('"output" expected length >= ' + min);
50
+ }
51
+ }
52
+ function u32(arr) {
53
+ return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
54
+ }
55
+ function clean(...arrays) {
56
+ for (let i = 0; i < arrays.length; i++) {
57
+ arrays[i].fill(0);
58
+ }
59
+ }
60
+ function createView(arr) {
61
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
62
+ }
63
+ var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
64
+ function byteSwap(word) {
65
+ return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
66
+ }
67
+ function byteSwap32(arr) {
68
+ for (let i = 0; i < arr.length; i++) {
69
+ arr[i] = byteSwap(arr[i]);
70
+ }
71
+ return arr;
72
+ }
73
+ var swap32IfBE = isLE ? (u) => u : byteSwap32;
74
+ function checkOpts(defaults, opts) {
75
+ aobject(defaults, "defaults");
76
+ aobject(opts, "opts");
77
+ const merged = Object.assign(defaults, opts);
78
+ return merged;
79
+ }
80
+ function equalBytes(a, b) {
81
+ a = abytes(a);
82
+ b = abytes(b);
83
+ if (a.length !== b.length)
84
+ return false;
85
+ let diff = 0;
86
+ for (let i = 0; i < a.length; i++)
87
+ diff |= a[i] ^ b[i];
88
+ return diff === 0;
89
+ }
90
+ function wrapMacConstructor(keyLen, macCons, fromMsg) {
91
+ const mac = macCons;
92
+ const getArgs = fromMsg || (() => []);
93
+ const macC = (msg, key) => mac(key, ...getArgs(msg)).update(msg).digest();
94
+ const tmp = mac(new Uint8Array(keyLen), ...getArgs(new Uint8Array(0)));
95
+ macC.outputLen = tmp.outputLen;
96
+ macC.blockLen = tmp.blockLen;
97
+ macC.create = (key, ...args) => mac(key, ...args);
98
+ return macC;
99
+ }
100
+ var wrapCipher = /* @__NO_SIDE_EFFECTS__ */ (params, constructor) => {
101
+ function wrappedCipher(key, ...args) {
102
+ abytes(key, void 0, "key");
103
+ if (params.nonceLength !== void 0) {
104
+ const nonce = args[0];
105
+ abytes(nonce, params.varSizeNonce ? void 0 : params.nonceLength, "nonce");
106
+ }
107
+ const tagl = params.tagLength;
108
+ const aadStart = params.nonceLength !== void 0 ? 1 : 0;
109
+ if (!params.withAAD) {
110
+ for (let i = aadStart; i < args.length; i++)
111
+ if (isBytes(args[i]))
112
+ throw new Error("AAD not supported");
113
+ }
114
+ if (params.withAAD && args[aadStart] !== void 0)
115
+ abytes(args[aadStart], void 0, "AAD");
116
+ const cipher = constructor(key, ...args);
117
+ const checkOutput = (fnLength, output) => {
118
+ if (output !== void 0) {
119
+ if (fnLength !== 2)
120
+ throw new Error("cipher output not supported");
121
+ abytes(output, void 0, "output");
122
+ }
123
+ };
124
+ let called = false;
125
+ const wrCipher = {
126
+ encrypt(data, output) {
127
+ if (called)
128
+ throw new Error("cannot encrypt() twice with same key + nonce");
129
+ called = true;
130
+ abytes(data, void 0, "data");
131
+ checkOutput(cipher.encrypt.length, output);
132
+ return cipher.encrypt(data, output);
133
+ },
134
+ decrypt(data, output) {
135
+ abytes(data, void 0, "data");
136
+ if (tagl && data.length < tagl)
137
+ throw new Error('"ciphertext" expected length >= tagLength=' + tagl);
138
+ checkOutput(cipher.decrypt.length, output);
139
+ return cipher.decrypt(data, output);
140
+ }
141
+ };
142
+ return wrCipher;
143
+ }
144
+ Object.assign(wrappedCipher, params);
145
+ return wrappedCipher;
146
+ };
147
+ function getOutput(expectedLength, out, onlyAligned = true) {
148
+ if (out === void 0)
149
+ return new Uint8Array(expectedLength);
150
+ abytes(out, expectedLength, "output");
151
+ if (onlyAligned && !isAligned32(out))
152
+ throw new Error("invalid output, must be aligned");
153
+ return out;
154
+ }
155
+ function u64Lengths(dataLength, aadLength, isLE2) {
156
+ anumber(dataLength);
157
+ anumber(aadLength);
158
+ abool(isLE2);
159
+ const num = new Uint8Array(16);
160
+ const view = createView(num);
161
+ view.setBigUint64(0, BigInt(aadLength), isLE2);
162
+ view.setBigUint64(8, BigInt(dataLength), isLE2);
163
+ return num;
164
+ }
165
+ function isAligned32(bytes) {
166
+ return bytes.byteOffset % 4 === 0;
167
+ }
168
+ function copyBytes(bytes) {
169
+ return Uint8Array.from(abytes(bytes));
170
+ }
171
+
172
+ // node_modules/@noble/ciphers/_arx.js
173
+ var encodeStr = (str) => Uint8Array.from(str.split(""), (c) => c.charCodeAt(0));
174
+ var sigma16_32 = /* @__PURE__ */ (() => swap32IfBE(u32(encodeStr("expand 16-byte k"))))();
175
+ var sigma32_32 = /* @__PURE__ */ (() => swap32IfBE(u32(encodeStr("expand 32-byte k"))))();
176
+ function rotl(a, b) {
177
+ return a << b | a >>> 32 - b;
178
+ }
179
+ var BLOCK_LEN = 64;
180
+ var BLOCK_LEN32 = 16;
181
+ var MAX_COUNTER = /* @__PURE__ */ (() => 2 ** 32 - 1)();
182
+ var U32_EMPTY = /* @__PURE__ */ Uint32Array.of();
183
+ function runCipher(core, sigma, key, nonce, data, output, counter, rounds) {
184
+ const len = data.length;
185
+ const block = new Uint8Array(BLOCK_LEN);
186
+ const b32 = u32(block);
187
+ const isAligned = isLE && isAligned32(data) && isAligned32(output);
188
+ const d32 = isAligned ? u32(data) : U32_EMPTY;
189
+ const o32 = isAligned ? u32(output) : U32_EMPTY;
190
+ if (!isLE) {
191
+ for (let pos = 0; pos < len; counter++) {
192
+ core(sigma, key, nonce, b32, counter, rounds);
193
+ swap32IfBE(b32);
194
+ if (counter >= MAX_COUNTER)
195
+ throw new Error("arx: counter overflow");
196
+ const take = Math.min(BLOCK_LEN, len - pos);
197
+ for (let j = 0, posj; j < take; j++) {
198
+ posj = pos + j;
199
+ output[posj] = data[posj] ^ block[j];
200
+ }
201
+ pos += take;
202
+ }
203
+ return;
204
+ }
205
+ for (let pos = 0; pos < len; counter++) {
206
+ core(sigma, key, nonce, b32, counter, rounds);
207
+ if (counter >= MAX_COUNTER)
208
+ throw new Error("arx: counter overflow");
209
+ const take = Math.min(BLOCK_LEN, len - pos);
210
+ if (isAligned && take === BLOCK_LEN) {
211
+ const pos32 = pos / 4;
212
+ if (pos % 4 !== 0)
213
+ throw new Error("arx: invalid block position");
214
+ for (let j = 0, posj; j < BLOCK_LEN32; j++) {
215
+ posj = pos32 + j;
216
+ o32[posj] = d32[posj] ^ b32[j];
217
+ }
218
+ pos += BLOCK_LEN;
219
+ continue;
220
+ }
221
+ for (let j = 0, posj; j < take; j++) {
222
+ posj = pos + j;
223
+ output[posj] = data[posj] ^ block[j];
224
+ }
225
+ pos += take;
226
+ }
227
+ }
228
+ function createCipher(core, opts) {
229
+ const { allowShortKeys, extendNonceFn, counterLength, counterRight, rounds } = checkOpts({ allowShortKeys: false, counterLength: 8, counterRight: false, rounds: 20 }, opts);
230
+ if (typeof core !== "function")
231
+ throw new Error("core must be a function");
232
+ anumber(counterLength);
233
+ anumber(rounds);
234
+ abool(counterRight);
235
+ abool(allowShortKeys);
236
+ return (key, nonce, data, output, counter = 0) => {
237
+ abytes(key, void 0, "key");
238
+ abytes(nonce, void 0, "nonce");
239
+ abytes(data, void 0, "data");
240
+ const len = data.length;
241
+ output = getOutput(len, output, false);
242
+ anumber(counter);
243
+ if (counter < 0 || counter >= MAX_COUNTER)
244
+ throw new Error("arx: counter overflow");
245
+ const toClean = [];
246
+ let l = key.length;
247
+ let k;
248
+ let sigma;
249
+ if (l === 32) {
250
+ toClean.push(k = copyBytes(key));
251
+ sigma = sigma32_32;
252
+ } else if (l === 16 && allowShortKeys) {
253
+ k = new Uint8Array(32);
254
+ k.set(key);
255
+ k.set(key, 16);
256
+ sigma = sigma16_32;
257
+ toClean.push(k);
258
+ } else {
259
+ abytes(key, 32, "arx key");
260
+ throw new Error("invalid key size");
261
+ }
262
+ if (!isLE || !isAligned32(nonce))
263
+ toClean.push(nonce = copyBytes(nonce));
264
+ let k32 = u32(k);
265
+ if (extendNonceFn) {
266
+ if (nonce.length !== 24)
267
+ throw new Error("arx: extended nonce must be 24 bytes");
268
+ const n16 = nonce.subarray(0, 16);
269
+ if (isLE)
270
+ extendNonceFn(sigma, k32, u32(n16), k32);
271
+ else {
272
+ const sigmaRaw = swap32IfBE(Uint32Array.from(sigma));
273
+ extendNonceFn(sigmaRaw, k32, u32(n16), k32);
274
+ clean(sigmaRaw);
275
+ swap32IfBE(k32);
276
+ }
277
+ nonce = nonce.subarray(16);
278
+ } else if (!isLE)
279
+ swap32IfBE(k32);
280
+ const nonceNcLen = 16 - counterLength;
281
+ if (nonceNcLen !== nonce.length)
282
+ throw new Error(`arx: nonce must be ${nonceNcLen} or 16 bytes`);
283
+ if (nonceNcLen !== 12) {
284
+ const nc = new Uint8Array(12);
285
+ nc.set(nonce, counterRight ? 0 : 12 - nonce.length);
286
+ nonce = nc;
287
+ toClean.push(nonce);
288
+ }
289
+ const n32 = swap32IfBE(u32(nonce));
290
+ try {
291
+ runCipher(core, sigma, k32, n32, data, output, counter, rounds);
292
+ return output;
293
+ } finally {
294
+ clean(...toClean);
295
+ }
296
+ };
297
+ }
298
+
299
+ // node_modules/@noble/ciphers/_poly1305.js
300
+ function u8to16(a, i) {
301
+ return a[i++] & 255 | (a[i++] & 255) << 8;
302
+ }
303
+ var Poly1305 = class {
304
+ blockLen = 16;
305
+ outputLen = 16;
306
+ buffer = new Uint8Array(16);
307
+ r = new Uint16Array(10);
308
+ // Allocating 1 array with .subarray() here is slower than 3
309
+ h = new Uint16Array(10);
310
+ pad = new Uint16Array(8);
311
+ pos = 0;
312
+ finished = false;
313
+ destroyed = false;
314
+ // Can be speed-up using BigUint64Array, at the cost of complexity
315
+ constructor(key) {
316
+ key = copyBytes(abytes(key, 32, "key"));
317
+ const t0 = u8to16(key, 0);
318
+ const t1 = u8to16(key, 2);
319
+ const t2 = u8to16(key, 4);
320
+ const t3 = u8to16(key, 6);
321
+ const t4 = u8to16(key, 8);
322
+ const t5 = u8to16(key, 10);
323
+ const t6 = u8to16(key, 12);
324
+ const t7 = u8to16(key, 14);
325
+ this.r[0] = t0 & 8191;
326
+ this.r[1] = (t0 >>> 13 | t1 << 3) & 8191;
327
+ this.r[2] = (t1 >>> 10 | t2 << 6) & 7939;
328
+ this.r[3] = (t2 >>> 7 | t3 << 9) & 8191;
329
+ this.r[4] = (t3 >>> 4 | t4 << 12) & 255;
330
+ this.r[5] = t4 >>> 1 & 8190;
331
+ this.r[6] = (t4 >>> 14 | t5 << 2) & 8191;
332
+ this.r[7] = (t5 >>> 11 | t6 << 5) & 8065;
333
+ this.r[8] = (t6 >>> 8 | t7 << 8) & 8191;
334
+ this.r[9] = t7 >>> 5 & 127;
335
+ for (let i = 0; i < 8; i++)
336
+ this.pad[i] = u8to16(key, 16 + 2 * i);
337
+ }
338
+ process(data, offset, isLast = false) {
339
+ const hibit = isLast ? 0 : 1 << 11;
340
+ const { h, r } = this;
341
+ const r0 = r[0];
342
+ const r1 = r[1];
343
+ const r2 = r[2];
344
+ const r3 = r[3];
345
+ const r4 = r[4];
346
+ const r5 = r[5];
347
+ const r6 = r[6];
348
+ const r7 = r[7];
349
+ const r8 = r[8];
350
+ const r9 = r[9];
351
+ const t0 = u8to16(data, offset + 0);
352
+ const t1 = u8to16(data, offset + 2);
353
+ const t2 = u8to16(data, offset + 4);
354
+ const t3 = u8to16(data, offset + 6);
355
+ const t4 = u8to16(data, offset + 8);
356
+ const t5 = u8to16(data, offset + 10);
357
+ const t6 = u8to16(data, offset + 12);
358
+ const t7 = u8to16(data, offset + 14);
359
+ let h0 = h[0] + (t0 & 8191);
360
+ let h1 = h[1] + ((t0 >>> 13 | t1 << 3) & 8191);
361
+ let h2 = h[2] + ((t1 >>> 10 | t2 << 6) & 8191);
362
+ let h3 = h[3] + ((t2 >>> 7 | t3 << 9) & 8191);
363
+ let h4 = h[4] + ((t3 >>> 4 | t4 << 12) & 8191);
364
+ let h5 = h[5] + (t4 >>> 1 & 8191);
365
+ let h6 = h[6] + ((t4 >>> 14 | t5 << 2) & 8191);
366
+ let h7 = h[7] + ((t5 >>> 11 | t6 << 5) & 8191);
367
+ let h8 = h[8] + ((t6 >>> 8 | t7 << 8) & 8191);
368
+ let h9 = h[9] + (t7 >>> 5 | hibit);
369
+ let c = 0;
370
+ let d0 = c + h0 * r0 + h1 * (5 * r9) + h2 * (5 * r8) + h3 * (5 * r7) + h4 * (5 * r6);
371
+ c = d0 >>> 13;
372
+ d0 &= 8191;
373
+ d0 += h5 * (5 * r5) + h6 * (5 * r4) + h7 * (5 * r3) + h8 * (5 * r2) + h9 * (5 * r1);
374
+ c += d0 >>> 13;
375
+ d0 &= 8191;
376
+ let d1 = c + h0 * r1 + h1 * r0 + h2 * (5 * r9) + h3 * (5 * r8) + h4 * (5 * r7);
377
+ c = d1 >>> 13;
378
+ d1 &= 8191;
379
+ d1 += h5 * (5 * r6) + h6 * (5 * r5) + h7 * (5 * r4) + h8 * (5 * r3) + h9 * (5 * r2);
380
+ c += d1 >>> 13;
381
+ d1 &= 8191;
382
+ let d2 = c + h0 * r2 + h1 * r1 + h2 * r0 + h3 * (5 * r9) + h4 * (5 * r8);
383
+ c = d2 >>> 13;
384
+ d2 &= 8191;
385
+ d2 += h5 * (5 * r7) + h6 * (5 * r6) + h7 * (5 * r5) + h8 * (5 * r4) + h9 * (5 * r3);
386
+ c += d2 >>> 13;
387
+ d2 &= 8191;
388
+ let d3 = c + h0 * r3 + h1 * r2 + h2 * r1 + h3 * r0 + h4 * (5 * r9);
389
+ c = d3 >>> 13;
390
+ d3 &= 8191;
391
+ d3 += h5 * (5 * r8) + h6 * (5 * r7) + h7 * (5 * r6) + h8 * (5 * r5) + h9 * (5 * r4);
392
+ c += d3 >>> 13;
393
+ d3 &= 8191;
394
+ let d4 = c + h0 * r4 + h1 * r3 + h2 * r2 + h3 * r1 + h4 * r0;
395
+ c = d4 >>> 13;
396
+ d4 &= 8191;
397
+ d4 += h5 * (5 * r9) + h6 * (5 * r8) + h7 * (5 * r7) + h8 * (5 * r6) + h9 * (5 * r5);
398
+ c += d4 >>> 13;
399
+ d4 &= 8191;
400
+ let d5 = c + h0 * r5 + h1 * r4 + h2 * r3 + h3 * r2 + h4 * r1;
401
+ c = d5 >>> 13;
402
+ d5 &= 8191;
403
+ d5 += h5 * r0 + h6 * (5 * r9) + h7 * (5 * r8) + h8 * (5 * r7) + h9 * (5 * r6);
404
+ c += d5 >>> 13;
405
+ d5 &= 8191;
406
+ let d6 = c + h0 * r6 + h1 * r5 + h2 * r4 + h3 * r3 + h4 * r2;
407
+ c = d6 >>> 13;
408
+ d6 &= 8191;
409
+ d6 += h5 * r1 + h6 * r0 + h7 * (5 * r9) + h8 * (5 * r8) + h9 * (5 * r7);
410
+ c += d6 >>> 13;
411
+ d6 &= 8191;
412
+ let d7 = c + h0 * r7 + h1 * r6 + h2 * r5 + h3 * r4 + h4 * r3;
413
+ c = d7 >>> 13;
414
+ d7 &= 8191;
415
+ d7 += h5 * r2 + h6 * r1 + h7 * r0 + h8 * (5 * r9) + h9 * (5 * r8);
416
+ c += d7 >>> 13;
417
+ d7 &= 8191;
418
+ let d8 = c + h0 * r8 + h1 * r7 + h2 * r6 + h3 * r5 + h4 * r4;
419
+ c = d8 >>> 13;
420
+ d8 &= 8191;
421
+ d8 += h5 * r3 + h6 * r2 + h7 * r1 + h8 * r0 + h9 * (5 * r9);
422
+ c += d8 >>> 13;
423
+ d8 &= 8191;
424
+ let d9 = c + h0 * r9 + h1 * r8 + h2 * r7 + h3 * r6 + h4 * r5;
425
+ c = d9 >>> 13;
426
+ d9 &= 8191;
427
+ d9 += h5 * r4 + h6 * r3 + h7 * r2 + h8 * r1 + h9 * r0;
428
+ c += d9 >>> 13;
429
+ d9 &= 8191;
430
+ c = (c << 2) + c | 0;
431
+ c = c + d0 | 0;
432
+ d0 = c & 8191;
433
+ c = c >>> 13;
434
+ d1 += c;
435
+ h[0] = d0;
436
+ h[1] = d1;
437
+ h[2] = d2;
438
+ h[3] = d3;
439
+ h[4] = d4;
440
+ h[5] = d5;
441
+ h[6] = d6;
442
+ h[7] = d7;
443
+ h[8] = d8;
444
+ h[9] = d9;
445
+ }
446
+ finalize() {
447
+ const { h, pad } = this;
448
+ const g = new Uint16Array(10);
449
+ let c = h[1] >>> 13;
450
+ h[1] &= 8191;
451
+ for (let i = 2; i < 10; i++) {
452
+ h[i] += c;
453
+ c = h[i] >>> 13;
454
+ h[i] &= 8191;
455
+ }
456
+ h[0] += c * 5;
457
+ c = h[0] >>> 13;
458
+ h[0] &= 8191;
459
+ h[1] += c;
460
+ c = h[1] >>> 13;
461
+ h[1] &= 8191;
462
+ h[2] += c;
463
+ g[0] = h[0] + 5;
464
+ c = g[0] >>> 13;
465
+ g[0] &= 8191;
466
+ for (let i = 1; i < 10; i++) {
467
+ g[i] = h[i] + c;
468
+ c = g[i] >>> 13;
469
+ g[i] &= 8191;
470
+ }
471
+ g[9] -= 1 << 13;
472
+ let mask = (c ^ 1) - 1;
473
+ for (let i = 0; i < 10; i++)
474
+ g[i] &= mask;
475
+ mask = ~mask;
476
+ for (let i = 0; i < 10; i++)
477
+ h[i] = h[i] & mask | g[i];
478
+ h[0] = (h[0] | h[1] << 13) & 65535;
479
+ h[1] = (h[1] >>> 3 | h[2] << 10) & 65535;
480
+ h[2] = (h[2] >>> 6 | h[3] << 7) & 65535;
481
+ h[3] = (h[3] >>> 9 | h[4] << 4) & 65535;
482
+ h[4] = (h[4] >>> 12 | h[5] << 1 | h[6] << 14) & 65535;
483
+ h[5] = (h[6] >>> 2 | h[7] << 11) & 65535;
484
+ h[6] = (h[7] >>> 5 | h[8] << 8) & 65535;
485
+ h[7] = (h[8] >>> 8 | h[9] << 5) & 65535;
486
+ let f = h[0] + pad[0];
487
+ h[0] = f & 65535;
488
+ for (let i = 1; i < 8; i++) {
489
+ f = (h[i] + pad[i] | 0) + (f >>> 16) | 0;
490
+ h[i] = f & 65535;
491
+ }
492
+ clean(g);
493
+ }
494
+ update(data) {
495
+ aexists(this);
496
+ abytes(data);
497
+ data = copyBytes(data);
498
+ const { buffer, blockLen } = this;
499
+ const len = data.length;
500
+ for (let pos = 0; pos < len; ) {
501
+ const take = Math.min(blockLen - this.pos, len - pos);
502
+ if (take === blockLen) {
503
+ for (; blockLen <= len - pos; pos += blockLen)
504
+ this.process(data, pos);
505
+ continue;
506
+ }
507
+ buffer.set(data.subarray(pos, pos + take), this.pos);
508
+ this.pos += take;
509
+ pos += take;
510
+ if (this.pos === blockLen) {
511
+ this.process(buffer, 0, false);
512
+ this.pos = 0;
513
+ }
514
+ }
515
+ return this;
516
+ }
517
+ destroy() {
518
+ this.destroyed = true;
519
+ clean(this.h, this.r, this.buffer, this.pad);
520
+ }
521
+ digestInto(out) {
522
+ aexists(this);
523
+ aoutput(out, this);
524
+ this.finished = true;
525
+ const { buffer, h } = this;
526
+ let { pos } = this;
527
+ if (pos) {
528
+ buffer[pos++] = 1;
529
+ for (; pos < 16; pos++)
530
+ buffer[pos] = 0;
531
+ this.process(buffer, 0, true);
532
+ }
533
+ this.finalize();
534
+ let opos = 0;
535
+ for (let i = 0; i < 8; i++) {
536
+ out[opos++] = h[i] >>> 0;
537
+ out[opos++] = h[i] >>> 8;
538
+ }
539
+ }
540
+ digest() {
541
+ const { buffer, outputLen } = this;
542
+ this.digestInto(buffer);
543
+ const res = buffer.slice(0, outputLen);
544
+ this.destroy();
545
+ return res;
546
+ }
547
+ };
548
+ var poly1305 = /* @__PURE__ */ wrapMacConstructor(32, (key) => new Poly1305(key));
549
+
550
+ // node_modules/@noble/ciphers/chacha.js
551
+ function chachaCore(s, k, n, out, cnt, rounds = 20) {
552
+ let y00 = s[0], y01 = s[1], y02 = s[2], y03 = s[3], y04 = k[0], y05 = k[1], y06 = k[2], y07 = k[3], y08 = k[4], y09 = k[5], y10 = k[6], y11 = k[7], y12 = cnt, y13 = n[0], y14 = n[1], y15 = n[2];
553
+ let x00 = y00, x01 = y01, x02 = y02, x03 = y03, x04 = y04, x05 = y05, x06 = y06, x07 = y07, x08 = y08, x09 = y09, x10 = y10, x11 = y11, x12 = y12, x13 = y13, x14 = y14, x15 = y15;
554
+ for (let r = 0; r < rounds; r += 2) {
555
+ x00 = x00 + x04 | 0;
556
+ x12 = rotl(x12 ^ x00, 16);
557
+ x08 = x08 + x12 | 0;
558
+ x04 = rotl(x04 ^ x08, 12);
559
+ x00 = x00 + x04 | 0;
560
+ x12 = rotl(x12 ^ x00, 8);
561
+ x08 = x08 + x12 | 0;
562
+ x04 = rotl(x04 ^ x08, 7);
563
+ x01 = x01 + x05 | 0;
564
+ x13 = rotl(x13 ^ x01, 16);
565
+ x09 = x09 + x13 | 0;
566
+ x05 = rotl(x05 ^ x09, 12);
567
+ x01 = x01 + x05 | 0;
568
+ x13 = rotl(x13 ^ x01, 8);
569
+ x09 = x09 + x13 | 0;
570
+ x05 = rotl(x05 ^ x09, 7);
571
+ x02 = x02 + x06 | 0;
572
+ x14 = rotl(x14 ^ x02, 16);
573
+ x10 = x10 + x14 | 0;
574
+ x06 = rotl(x06 ^ x10, 12);
575
+ x02 = x02 + x06 | 0;
576
+ x14 = rotl(x14 ^ x02, 8);
577
+ x10 = x10 + x14 | 0;
578
+ x06 = rotl(x06 ^ x10, 7);
579
+ x03 = x03 + x07 | 0;
580
+ x15 = rotl(x15 ^ x03, 16);
581
+ x11 = x11 + x15 | 0;
582
+ x07 = rotl(x07 ^ x11, 12);
583
+ x03 = x03 + x07 | 0;
584
+ x15 = rotl(x15 ^ x03, 8);
585
+ x11 = x11 + x15 | 0;
586
+ x07 = rotl(x07 ^ x11, 7);
587
+ x00 = x00 + x05 | 0;
588
+ x15 = rotl(x15 ^ x00, 16);
589
+ x10 = x10 + x15 | 0;
590
+ x05 = rotl(x05 ^ x10, 12);
591
+ x00 = x00 + x05 | 0;
592
+ x15 = rotl(x15 ^ x00, 8);
593
+ x10 = x10 + x15 | 0;
594
+ x05 = rotl(x05 ^ x10, 7);
595
+ x01 = x01 + x06 | 0;
596
+ x12 = rotl(x12 ^ x01, 16);
597
+ x11 = x11 + x12 | 0;
598
+ x06 = rotl(x06 ^ x11, 12);
599
+ x01 = x01 + x06 | 0;
600
+ x12 = rotl(x12 ^ x01, 8);
601
+ x11 = x11 + x12 | 0;
602
+ x06 = rotl(x06 ^ x11, 7);
603
+ x02 = x02 + x07 | 0;
604
+ x13 = rotl(x13 ^ x02, 16);
605
+ x08 = x08 + x13 | 0;
606
+ x07 = rotl(x07 ^ x08, 12);
607
+ x02 = x02 + x07 | 0;
608
+ x13 = rotl(x13 ^ x02, 8);
609
+ x08 = x08 + x13 | 0;
610
+ x07 = rotl(x07 ^ x08, 7);
611
+ x03 = x03 + x04 | 0;
612
+ x14 = rotl(x14 ^ x03, 16);
613
+ x09 = x09 + x14 | 0;
614
+ x04 = rotl(x04 ^ x09, 12);
615
+ x03 = x03 + x04 | 0;
616
+ x14 = rotl(x14 ^ x03, 8);
617
+ x09 = x09 + x14 | 0;
618
+ x04 = rotl(x04 ^ x09, 7);
619
+ }
620
+ let oi = 0;
621
+ out[oi++] = y00 + x00 | 0;
622
+ out[oi++] = y01 + x01 | 0;
623
+ out[oi++] = y02 + x02 | 0;
624
+ out[oi++] = y03 + x03 | 0;
625
+ out[oi++] = y04 + x04 | 0;
626
+ out[oi++] = y05 + x05 | 0;
627
+ out[oi++] = y06 + x06 | 0;
628
+ out[oi++] = y07 + x07 | 0;
629
+ out[oi++] = y08 + x08 | 0;
630
+ out[oi++] = y09 + x09 | 0;
631
+ out[oi++] = y10 + x10 | 0;
632
+ out[oi++] = y11 + x11 | 0;
633
+ out[oi++] = y12 + x12 | 0;
634
+ out[oi++] = y13 + x13 | 0;
635
+ out[oi++] = y14 + x14 | 0;
636
+ out[oi++] = y15 + x15 | 0;
637
+ }
638
+ function hchacha(s, k, i, out) {
639
+ const s2 = isLE ? s : swap32IfBE(s.slice(0, 4));
640
+ const k2 = isLE ? k : swap32IfBE(k.slice(0, 8));
641
+ const i2 = isLE ? i : swap32IfBE(i.slice(0, 4));
642
+ const t = new Uint32Array(16);
643
+ chachaCore(s2, k2, i2.subarray(1), t, i2[0]);
644
+ let oi = 0;
645
+ out[oi++] = t[0] - s2[0] | 0;
646
+ out[oi++] = t[1] - s2[1] | 0;
647
+ out[oi++] = t[2] - s2[2] | 0;
648
+ out[oi++] = t[3] - s2[3] | 0;
649
+ out[oi++] = t[12] - i2[0] | 0;
650
+ out[oi++] = t[13] - i2[1] | 0;
651
+ out[oi++] = t[14] - i2[2] | 0;
652
+ out[oi++] = t[15] - i2[3] | 0;
653
+ swap32IfBE(out);
654
+ if (!isLE)
655
+ clean(s2, k2, i2);
656
+ clean(t);
657
+ }
658
+ var xchacha20 = /* @__PURE__ */ createCipher(chachaCore, {
659
+ counterRight: false,
660
+ counterLength: 8,
661
+ extendNonceFn: hchacha,
662
+ allowShortKeys: false
663
+ });
664
+ var ZEROS16 = /* @__PURE__ */ new Uint8Array(16);
665
+ var updatePadded = (h, msg) => {
666
+ h.update(msg);
667
+ const leftover = msg.length % 16;
668
+ if (leftover)
669
+ h.update(ZEROS16.subarray(leftover));
670
+ };
671
+ var ZEROS32 = /* @__PURE__ */ new Uint8Array(32);
672
+ function computeTag(fn, key, nonce, ciphertext, AAD) {
673
+ if (AAD !== void 0)
674
+ abytes(AAD, void 0, "AAD");
675
+ const authKey = fn(key, nonce, ZEROS32);
676
+ const lengths = u64Lengths(ciphertext.length, AAD ? AAD.length : 0, true);
677
+ const h = poly1305.create(authKey);
678
+ if (AAD)
679
+ updatePadded(h, AAD);
680
+ updatePadded(h, ciphertext);
681
+ h.update(lengths);
682
+ const res = h.digest();
683
+ clean(authKey, lengths);
684
+ return res;
685
+ }
686
+ var _poly1305_aead = (xorStream) => (key, nonce, AAD) => {
687
+ const tagLength = 16;
688
+ return {
689
+ encrypt(plaintext, output) {
690
+ const plength = plaintext.length;
691
+ output = getOutput(plength + tagLength, output, false);
692
+ output.set(plaintext);
693
+ const oPlain = output.subarray(0, -tagLength);
694
+ xorStream(key, nonce, oPlain, oPlain, 1);
695
+ const tag = computeTag(xorStream, key, nonce, oPlain, AAD);
696
+ output.set(tag, plength);
697
+ clean(tag);
698
+ return output;
699
+ },
700
+ decrypt(ciphertext, output) {
701
+ output = getOutput(ciphertext.length - tagLength, output, false);
702
+ const data = ciphertext.subarray(0, -tagLength);
703
+ const passedTag = ciphertext.subarray(-tagLength);
704
+ const tag = computeTag(xorStream, key, nonce, data, AAD);
705
+ if (!equalBytes(passedTag, tag)) {
706
+ clean(tag);
707
+ throw new Error("invalid tag");
708
+ }
709
+ output.set(ciphertext.subarray(0, -tagLength));
710
+ xorStream(key, nonce, output, output, 1);
711
+ clean(tag);
712
+ return output;
713
+ }
714
+ };
715
+ };
716
+ var xchacha20poly1305 = /* @__PURE__ */ wrapCipher(
717
+ { blockSize: 64, nonceLength: 24, tagLength: 16, withAAD: true },
718
+ /* @__PURE__ */ _poly1305_aead(xchacha20)
719
+ );
720
+ export {
721
+ xchacha20poly1305
722
+ };
723
+ /*! Bundled license information:
724
+
725
+ @noble/ciphers/utils.js:
726
+ (*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
727
+ */