@workos-inc/node 8.0.0-rc.5 → 8.0.0-rc.7

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 (28) hide show
  1. package/lib/common/crypto/seal.cjs +7 -7
  2. package/lib/common/crypto/seal.cjs.map +1 -1
  3. package/lib/common/crypto/seal.js +1 -1
  4. package/lib/node_modules/iron-webcrypto/index.cjs +218 -0
  5. package/lib/node_modules/iron-webcrypto/index.cjs.map +1 -0
  6. package/lib/node_modules/iron-webcrypto/index.js +216 -0
  7. package/lib/node_modules/iron-webcrypto/index.js.map +1 -0
  8. package/lib/node_modules/uint8array-extras/index.cjs +55 -0
  9. package/lib/node_modules/uint8array-extras/index.cjs.map +1 -0
  10. package/lib/node_modules/uint8array-extras/index.js +52 -0
  11. package/lib/node_modules/uint8array-extras/index.js.map +1 -0
  12. package/lib/user-management/interfaces/authenticate-with-session-cookie.interface.cjs.map +1 -1
  13. package/lib/user-management/interfaces/authenticate-with-session-cookie.interface.d.cts +3 -2
  14. package/lib/user-management/interfaces/authenticate-with-session-cookie.interface.d.ts +3 -2
  15. package/lib/user-management/interfaces/authenticate-with-session-cookie.interface.js.map +1 -1
  16. package/lib/user-management/session.cjs +2 -0
  17. package/lib/user-management/session.cjs.map +1 -1
  18. package/lib/user-management/session.js +2 -0
  19. package/lib/user-management/session.js.map +1 -1
  20. package/lib/user-management/user-management.cjs +3 -1
  21. package/lib/user-management/user-management.cjs.map +1 -1
  22. package/lib/user-management/user-management.js +3 -1
  23. package/lib/user-management/user-management.js.map +1 -1
  24. package/lib/workos.cjs +1 -1
  25. package/lib/workos.cjs.map +1 -1
  26. package/lib/workos.js +1 -1
  27. package/lib/workos.js.map +1 -1
  28. package/package.json +1 -1
@@ -1,21 +1,21 @@
1
- let iron_webcrypto = require("iron-webcrypto");
1
+ const require_index = require('../../node_modules/iron-webcrypto/index.cjs');
2
2
 
3
3
  //#region src/common/crypto/seal.ts
4
4
  const VERSION_DELIMITER = "~";
5
5
  const CURRENT_MAJOR_VERSION = 2;
6
- function parseSeal(seal) {
7
- const [sealWithoutVersion = "", tokenVersionAsString] = seal.split(VERSION_DELIMITER);
6
+ function parseSeal(seal$1) {
7
+ const [sealWithoutVersion = "", tokenVersionAsString] = seal$1.split(VERSION_DELIMITER);
8
8
  return {
9
9
  sealWithoutVersion,
10
10
  tokenVersion: tokenVersionAsString == null ? null : parseInt(tokenVersionAsString, 10)
11
11
  };
12
12
  }
13
13
  async function sealData(data, { password }) {
14
- return `${await (0, iron_webcrypto.seal)(data, {
14
+ return `${await require_index.seal(data, {
15
15
  id: "1",
16
16
  secret: password
17
17
  }, {
18
- ...iron_webcrypto.defaults,
18
+ ...require_index.defaults,
19
19
  ttl: 0,
20
20
  encode: JSON.stringify
21
21
  })}${VERSION_DELIMITER}${CURRENT_MAJOR_VERSION}`;
@@ -25,8 +25,8 @@ async function unsealData(encryptedData, { password }) {
25
25
  const passwordMap = { 1: password };
26
26
  let data;
27
27
  try {
28
- data = await (0, iron_webcrypto.unseal)(sealWithoutVersion, passwordMap, {
29
- ...iron_webcrypto.defaults,
28
+ data = await require_index.unseal(sealWithoutVersion, passwordMap, {
29
+ ...require_index.defaults,
30
30
  ttl: 0
31
31
  }) ?? {};
32
32
  } catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"seal.cjs","names":["defaults","data: unknown"],"sources":["../../../src/common/crypto/seal.ts"],"sourcesContent":["import {\n seal as ironSeal,\n unseal as ironUnseal,\n defaults,\n} from 'iron-webcrypto';\n\nconst VERSION_DELIMITER = '~';\nconst CURRENT_MAJOR_VERSION = 2;\n\ninterface SealOptions {\n password: string;\n}\n\ninterface UnsealOptions {\n password: string;\n}\n\nfunction parseSeal(seal: string): {\n sealWithoutVersion: string;\n tokenVersion: number | null;\n} {\n const [sealWithoutVersion = '', tokenVersionAsString] =\n seal.split(VERSION_DELIMITER);\n const tokenVersion =\n tokenVersionAsString == null ? null : parseInt(tokenVersionAsString, 10);\n return { sealWithoutVersion, tokenVersion };\n}\n\nexport async function sealData(\n data: unknown,\n { password }: SealOptions,\n): Promise<string> {\n const passwordObj = {\n id: '1',\n secret: password,\n };\n\n const seal = await ironSeal(data, passwordObj, {\n ...defaults,\n ttl: 0,\n encode: JSON.stringify,\n });\n\n return `${seal}${VERSION_DELIMITER}${CURRENT_MAJOR_VERSION}`;\n}\n\nexport async function unsealData<T = unknown>(\n encryptedData: string,\n { password }: UnsealOptions,\n): Promise<T> {\n const { sealWithoutVersion, tokenVersion } = parseSeal(encryptedData);\n\n const passwordMap = { 1: password };\n\n let data: unknown;\n try {\n data =\n (await ironUnseal(sealWithoutVersion, passwordMap, {\n ...defaults,\n ttl: 0,\n })) ?? {};\n } catch (error) {\n if (\n error instanceof Error &&\n /^(Expired seal|Bad hmac value|Cannot find password|Incorrect number of sealed components|Wrong mac prefix)/.test(\n error.message,\n )\n ) {\n return {} as T;\n }\n throw error;\n }\n\n if (tokenVersion === 2) {\n return data as T;\n } else if (tokenVersion !== null) {\n const record = data as Record<string, unknown>;\n return (record.persistent ?? data) as T;\n }\n\n return data as T;\n}\n"],"mappings":";;;AAMA,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAU9B,SAAS,UAAU,MAGjB;CACA,MAAM,CAAC,qBAAqB,IAAI,wBAC9B,KAAK,MAAM,kBAAkB;AAG/B,QAAO;EAAE;EAAoB,cAD3B,wBAAwB,OAAO,OAAO,SAAS,sBAAsB,GAAG;EAC/B;;AAG7C,eAAsB,SACpB,MACA,EAAE,YACe;AAYjB,QAAO,GANM,+BAAe,MALR;EAClB,IAAI;EACJ,QAAQ;EACT,EAE8C;EAC7C,GAAGA;EACH,KAAK;EACL,QAAQ,KAAK;EACd,CAAC,GAEe,oBAAoB;;AAGvC,eAAsB,WACpB,eACA,EAAE,YACU;CACZ,MAAM,EAAE,oBAAoB,iBAAiB,UAAU,cAAc;CAErE,MAAM,cAAc,EAAE,GAAG,UAAU;CAEnC,IAAIC;AACJ,KAAI;AACF,SACG,iCAAiB,oBAAoB,aAAa;GACjD,GAAGD;GACH,KAAK;GACN,CAAC,IAAK,EAAE;UACJ,OAAO;AACd,MACE,iBAAiB,SACjB,6GAA6G,KAC3G,MAAM,QACP,CAED,QAAO,EAAE;AAEX,QAAM;;AAGR,KAAI,iBAAiB,EACnB,QAAO;UACE,iBAAiB,KAE1B,QADe,KACA,cAAc;AAG/B,QAAO"}
1
+ {"version":3,"file":"seal.cjs","names":["seal","ironSeal","defaults","data: unknown","ironUnseal"],"sources":["../../../src/common/crypto/seal.ts"],"sourcesContent":["import {\n seal as ironSeal,\n unseal as ironUnseal,\n defaults,\n} from 'iron-webcrypto';\n\nconst VERSION_DELIMITER = '~';\nconst CURRENT_MAJOR_VERSION = 2;\n\ninterface SealOptions {\n password: string;\n}\n\ninterface UnsealOptions {\n password: string;\n}\n\nfunction parseSeal(seal: string): {\n sealWithoutVersion: string;\n tokenVersion: number | null;\n} {\n const [sealWithoutVersion = '', tokenVersionAsString] =\n seal.split(VERSION_DELIMITER);\n const tokenVersion =\n tokenVersionAsString == null ? null : parseInt(tokenVersionAsString, 10);\n return { sealWithoutVersion, tokenVersion };\n}\n\nexport async function sealData(\n data: unknown,\n { password }: SealOptions,\n): Promise<string> {\n const passwordObj = {\n id: '1',\n secret: password,\n };\n\n const seal = await ironSeal(data, passwordObj, {\n ...defaults,\n ttl: 0,\n encode: JSON.stringify,\n });\n\n return `${seal}${VERSION_DELIMITER}${CURRENT_MAJOR_VERSION}`;\n}\n\nexport async function unsealData<T = unknown>(\n encryptedData: string,\n { password }: UnsealOptions,\n): Promise<T> {\n const { sealWithoutVersion, tokenVersion } = parseSeal(encryptedData);\n\n const passwordMap = { 1: password };\n\n let data: unknown;\n try {\n data =\n (await ironUnseal(sealWithoutVersion, passwordMap, {\n ...defaults,\n ttl: 0,\n })) ?? {};\n } catch (error) {\n if (\n error instanceof Error &&\n /^(Expired seal|Bad hmac value|Cannot find password|Incorrect number of sealed components|Wrong mac prefix)/.test(\n error.message,\n )\n ) {\n return {} as T;\n }\n throw error;\n }\n\n if (tokenVersion === 2) {\n return data as T;\n } else if (tokenVersion !== null) {\n const record = data as Record<string, unknown>;\n return (record.persistent ?? data) as T;\n }\n\n return data as T;\n}\n"],"mappings":";;;AAMA,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAU9B,SAAS,UAAU,QAGjB;CACA,MAAM,CAAC,qBAAqB,IAAI,wBAC9BA,OAAK,MAAM,kBAAkB;AAG/B,QAAO;EAAE;EAAoB,cAD3B,wBAAwB,OAAO,OAAO,SAAS,sBAAsB,GAAG;EAC/B;;AAG7C,eAAsB,SACpB,MACA,EAAE,YACe;AAYjB,QAAO,GANM,MAAMC,mBAAS,MALR;EAClB,IAAI;EACJ,QAAQ;EACT,EAE8C;EAC7C,GAAGC;EACH,KAAK;EACL,QAAQ,KAAK;EACd,CAAC,GAEe,oBAAoB;;AAGvC,eAAsB,WACpB,eACA,EAAE,YACU;CACZ,MAAM,EAAE,oBAAoB,iBAAiB,UAAU,cAAc;CAErE,MAAM,cAAc,EAAE,GAAG,UAAU;CAEnC,IAAIC;AACJ,KAAI;AACF,SACG,MAAMC,qBAAW,oBAAoB,aAAa;GACjD,GAAGF;GACH,KAAK;GACN,CAAC,IAAK,EAAE;UACJ,OAAO;AACd,MACE,iBAAiB,SACjB,6GAA6G,KAC3G,MAAM,QACP,CAED,QAAO,EAAE;AAEX,QAAM;;AAGR,KAAI,iBAAiB,EACnB,QAAO;UACE,iBAAiB,KAE1B,QADe,KACA,cAAc;AAG/B,QAAO"}
@@ -1,4 +1,4 @@
1
- import { defaults, seal, unseal } from "iron-webcrypto";
1
+ import { defaults, seal, unseal } from "../../node_modules/iron-webcrypto/index.js";
2
2
 
3
3
  //#region src/common/crypto/seal.ts
4
4
  const VERSION_DELIMITER = "~";
@@ -0,0 +1,218 @@
1
+ const require_index = require('../uint8array-extras/index.cjs');
2
+
3
+ //#region node_modules/iron-webcrypto/index.js
4
+ function losslessJsonStringify(data) {
5
+ try {
6
+ if (isJson(data)) {
7
+ let stringified = JSON.stringify(data);
8
+ if (stringified) return stringified;
9
+ }
10
+ } catch {}
11
+ throw Error("Data is not JSON serializable");
12
+ }
13
+ function jsonParse(string) {
14
+ try {
15
+ return JSON.parse(string);
16
+ } catch (err) {
17
+ throw Error("Failed parsing sealed object JSON: " + err.message);
18
+ }
19
+ }
20
+ function isJson(val) {
21
+ let stack = [], seen = /* @__PURE__ */ new WeakSet(), check = (val$1) => val$1 === null || typeof val$1 == "string" || typeof val$1 == "boolean" ? !0 : typeof val$1 == "number" ? Number.isFinite(val$1) : typeof val$1 == "object" ? seen.has(val$1) ? !0 : (seen.add(val$1), stack.push(val$1), !0) : !1;
22
+ if (!check(val)) return !1;
23
+ for (; stack.length;) {
24
+ let obj = stack.pop();
25
+ if (Array.isArray(obj)) {
26
+ let i$1 = obj.length;
27
+ for (; i$1--;) if (!check(obj[i$1])) return !1;
28
+ continue;
29
+ }
30
+ let proto = Reflect.getPrototypeOf(obj);
31
+ if (proto !== null && proto !== Object.prototype) return !1;
32
+ let keys = Reflect.ownKeys(obj), i = keys.length;
33
+ for (; i--;) {
34
+ let key = keys[i];
35
+ if (typeof key != "string" || Reflect.getOwnPropertyDescriptor(obj, key)?.enumerable === !1) return !1;
36
+ let val$1 = obj[key];
37
+ if (val$1 !== void 0 && !check(val$1)) return !1;
38
+ }
39
+ }
40
+ return !0;
41
+ }
42
+ const enc = /* @__PURE__ */ new TextEncoder(), dec = /* @__PURE__ */ new TextDecoder(), jsBase64Enabled = /* @__PURE__ */ (() => typeof Uint8Array.fromBase64 == "function" && typeof Uint8Array.prototype.toBase64 == "function" && typeof Uint8Array.prototype.toHex == "function")();
43
+ function b64ToU8(str) {
44
+ return jsBase64Enabled ? Uint8Array.fromBase64(str, { alphabet: "base64url" }) : require_index.base64ToUint8Array(str);
45
+ }
46
+ function u8ToB64(arr) {
47
+ return arr = arr instanceof ArrayBuffer ? new Uint8Array(arr) : arr, jsBase64Enabled ? arr.toBase64({
48
+ alphabet: "base64url",
49
+ omitPadding: !0
50
+ }) : require_index.uint8ArrayToBase64(arr, { urlSafe: !0 });
51
+ }
52
+ function u8ToHex(arr) {
53
+ return arr = arr instanceof ArrayBuffer ? new Uint8Array(arr) : arr, jsBase64Enabled ? arr.toHex() : require_index.uint8ArrayToHex(arr);
54
+ }
55
+ const defaults = /* @__PURE__ */ Object.freeze({
56
+ encryption: /* @__PURE__ */ Object.freeze({
57
+ algorithm: "aes-256-cbc",
58
+ saltBits: 256,
59
+ iterations: 1,
60
+ minPasswordlength: 32
61
+ }),
62
+ integrity: /* @__PURE__ */ Object.freeze({
63
+ algorithm: "sha256",
64
+ saltBits: 256,
65
+ iterations: 1,
66
+ minPasswordlength: 32
67
+ }),
68
+ ttl: 0,
69
+ timestampSkewSec: 60,
70
+ localtimeOffsetMsec: 0
71
+ });
72
+ const algorithms = /* @__PURE__ */ Object.freeze({
73
+ "aes-128-ctr": /* @__PURE__ */ Object.freeze({
74
+ keyBits: 128,
75
+ ivBits: 128,
76
+ name: "AES-CTR"
77
+ }),
78
+ "aes-256-cbc": /* @__PURE__ */ Object.freeze({
79
+ keyBits: 256,
80
+ ivBits: 128,
81
+ name: "AES-CBC"
82
+ }),
83
+ sha256: /* @__PURE__ */ Object.freeze({
84
+ keyBits: 256,
85
+ ivBits: void 0,
86
+ name: "SHA-256"
87
+ })
88
+ }), macFormatVersion = "2", macPrefix = "Fe26.2";
89
+ function randomBits(bits) {
90
+ return crypto.getRandomValues(new Uint8Array(bits / 8));
91
+ }
92
+ async function generateKey(password, options) {
93
+ if (!password || !password.length) throw Error("Empty password");
94
+ if (!options || typeof options != "object") throw Error("Bad options");
95
+ let algorithm = algorithms[options.algorithm];
96
+ if (!algorithm) throw Error("Unknown algorithm: " + options.algorithm);
97
+ let isHmac = algorithm.name === "SHA-256", id = isHmac ? {
98
+ name: "HMAC",
99
+ hash: algorithm.name,
100
+ length: algorithm.keyBits
101
+ } : {
102
+ name: algorithm.name,
103
+ length: algorithm.keyBits
104
+ }, usages = isHmac ? ["sign", "verify"] : ["encrypt", "decrypt"], iv = options.iv || (algorithm.ivBits ? randomBits(algorithm.ivBits) : void 0);
105
+ if (typeof password == "string") {
106
+ if (password.length < options.minPasswordlength) throw Error("Password string too short (min " + options.minPasswordlength + " characters required)");
107
+ let salt = options.salt;
108
+ if (!salt) {
109
+ if (!options.saltBits) throw Error("Missing salt and saltBits options");
110
+ salt = u8ToHex(randomBits(options.saltBits));
111
+ }
112
+ let baseKey = await crypto.subtle.importKey("raw", enc.encode(password), "PBKDF2", !1, ["deriveKey"]), algorithm$1 = {
113
+ name: "PBKDF2",
114
+ salt: enc.encode(salt),
115
+ iterations: options.iterations,
116
+ hash: "SHA-1"
117
+ };
118
+ return {
119
+ key: await crypto.subtle.deriveKey(algorithm$1, baseKey, id, !1, usages),
120
+ iv,
121
+ salt
122
+ };
123
+ }
124
+ if (password.length < algorithm.keyBits / 8) throw Error("Key buffer (password) too small");
125
+ return {
126
+ key: await crypto.subtle.importKey("raw", password.slice(), id, !1, usages),
127
+ iv,
128
+ salt: ""
129
+ };
130
+ }
131
+ function getEncryptParams(algorithm, key, data) {
132
+ return [
133
+ algorithm === "aes-128-ctr" ? {
134
+ name: "AES-CTR",
135
+ counter: key.iv,
136
+ length: 128
137
+ } : {
138
+ name: "AES-CBC",
139
+ iv: key.iv
140
+ },
141
+ key.key,
142
+ typeof data == "string" ? enc.encode(data) : data.slice()
143
+ ];
144
+ }
145
+ async function encrypt(password, options, data) {
146
+ let key = await generateKey(password, options), encrypted = await crypto.subtle.encrypt(...getEncryptParams(options.algorithm, key, data));
147
+ return {
148
+ encrypted: new Uint8Array(encrypted),
149
+ key
150
+ };
151
+ }
152
+ async function decrypt(password, options, data) {
153
+ let key = await generateKey(password, options), decrypted = await crypto.subtle.decrypt(...getEncryptParams(options.algorithm, key, data));
154
+ return dec.decode(decrypted);
155
+ }
156
+ async function hmacWithPassword(password, options, data) {
157
+ let key = await generateKey(password, options);
158
+ return {
159
+ digest: u8ToB64(await crypto.subtle.sign("HMAC", key.key, enc.encode(data))),
160
+ salt: key.salt
161
+ };
162
+ }
163
+ function normalizePassword(password) {
164
+ let normalized = typeof password == "string" || password instanceof Uint8Array ? {
165
+ encryption: password,
166
+ integrity: password
167
+ } : password && typeof password == "object" ? "secret" in password ? {
168
+ id: password.id,
169
+ encryption: password.secret,
170
+ integrity: password.secret
171
+ } : {
172
+ id: password.id,
173
+ encryption: password.encryption,
174
+ integrity: password.integrity
175
+ } : void 0;
176
+ if (!normalized || !normalized.encryption || normalized.encryption.length === 0 || !normalized.integrity || normalized.integrity.length === 0) throw Error("Empty password");
177
+ return normalized;
178
+ }
179
+ async function seal(object, password, options) {
180
+ let now = Date.now() + (options.localtimeOffsetMsec || 0), { id = "", encryption, integrity } = normalizePassword(password);
181
+ if (id && !/^\w+$/.test(id)) throw Error("Invalid password id");
182
+ let { encrypted, key } = await encrypt(encryption, options.encryption, (options.encode || losslessJsonStringify)(object)), expiration = options.ttl ? now + options.ttl : "", macBaseString = macPrefix + "*" + id + "*" + key.salt + "*" + u8ToB64(key.iv) + "*" + u8ToB64(encrypted) + "*" + expiration, mac = await hmacWithPassword(integrity, options.integrity, macBaseString);
183
+ return macBaseString + "*" + mac.salt + "*" + mac.digest;
184
+ }
185
+ async function unseal(sealed, password, options) {
186
+ let now = Date.now() + (options.localtimeOffsetMsec || 0), parts = sealed.split("*");
187
+ if (parts.length !== 8) throw Error("Incorrect number of sealed components");
188
+ let [prefix, passwordId, encryptionSalt, ivB64, encryptedB64, expiration, hmacSalt, hmacDigestB64] = parts;
189
+ if (prefix !== macPrefix) throw Error("Wrong mac prefix");
190
+ if (expiration) {
191
+ if (!/^[1-9]\d*$/.test(expiration)) throw Error("Invalid expiration");
192
+ if (Number.parseInt(expiration, 10) <= now - options.timestampSkewSec * 1e3) throw Error("Expired seal");
193
+ }
194
+ let pass;
195
+ if (typeof password == "string" || password instanceof Uint8Array) pass = password;
196
+ else if (typeof password == "object" && password) {
197
+ let passwordIdKey = passwordId || "default";
198
+ if (pass = password[passwordIdKey], !pass) throw Error("Cannot find password: " + passwordIdKey);
199
+ }
200
+ pass = normalizePassword(pass);
201
+ let key = await generateKey(pass.integrity, {
202
+ ...options.integrity,
203
+ salt: hmacSalt
204
+ }), macBaseString = prefix + "*" + passwordId + "*" + encryptionSalt + "*" + ivB64 + "*" + encryptedB64 + "*" + expiration;
205
+ if (!await crypto.subtle.verify("HMAC", key.key, b64ToU8(hmacDigestB64), enc.encode(macBaseString))) throw Error("Bad hmac value");
206
+ let decryptedString = await decrypt(pass.encryption, {
207
+ ...options.encryption,
208
+ salt: encryptionSalt,
209
+ iv: b64ToU8(ivB64)
210
+ }, b64ToU8(encryptedB64));
211
+ return (options.decode || jsonParse)(decryptedString);
212
+ }
213
+
214
+ //#endregion
215
+ exports.defaults = defaults;
216
+ exports.seal = seal;
217
+ exports.unseal = unseal;
218
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["base64ToUint8Array","uint8ArrayToBase64","uint8ArrayToHex"],"sources":["../../../node_modules/iron-webcrypto/index.js"],"sourcesContent":["/* @ts-self-types=\"./index.d.ts\" */\nimport { base64ToUint8Array, uint8ArrayToBase64, uint8ArrayToHex } from \"uint8array-extras\";\nfunction losslessJsonStringify(data) {\n\ttry {\n\t\tif (isJson(data)) {\n\t\t\tlet stringified = JSON.stringify(data);\n\t\t\tif (stringified) return stringified;\n\t\t}\n\t} catch {}\n\tthrow Error(\"Data is not JSON serializable\");\n}\nfunction jsonParse(string) {\n\ttry {\n\t\treturn JSON.parse(string);\n\t} catch (err) {\n\t\tthrow Error(\"Failed parsing sealed object JSON: \" + err.message);\n\t}\n}\nfunction isJson(val) {\n\tlet stack = [], seen = /* @__PURE__ */ new WeakSet(), check = (val$1) => val$1 === null || typeof val$1 == \"string\" || typeof val$1 == \"boolean\" ? !0 : typeof val$1 == \"number\" ? Number.isFinite(val$1) : typeof val$1 == \"object\" ? seen.has(val$1) ? !0 : (seen.add(val$1), stack.push(val$1), !0) : !1;\n\tif (!check(val)) return !1;\n\tfor (; stack.length;) {\n\t\tlet obj = stack.pop();\n\t\tif (Array.isArray(obj)) {\n\t\t\tlet i$1 = obj.length;\n\t\t\tfor (; i$1--;) if (!check(obj[i$1])) return !1;\n\t\t\tcontinue;\n\t\t}\n\t\tlet proto = Reflect.getPrototypeOf(obj);\n\t\tif (proto !== null && proto !== Object.prototype) return !1;\n\t\tlet keys = Reflect.ownKeys(obj), i = keys.length;\n\t\tfor (; i--;) {\n\t\t\tlet key = keys[i];\n\t\t\tif (typeof key != \"string\" || Reflect.getOwnPropertyDescriptor(obj, key)?.enumerable === !1) return !1;\n\t\t\tlet val$1 = obj[key];\n\t\t\tif (val$1 !== void 0 && !check(val$1)) return !1;\n\t\t}\n\t}\n\treturn !0;\n}\nconst enc = /* @__PURE__ */ new TextEncoder(), dec = /* @__PURE__ */ new TextDecoder(), jsBase64Enabled = /* @__PURE__ */ (() => typeof Uint8Array.fromBase64 == \"function\" && typeof Uint8Array.prototype.toBase64 == \"function\" && typeof Uint8Array.prototype.toHex == \"function\")();\nfunction b64ToU8(str) {\n\treturn jsBase64Enabled ? Uint8Array.fromBase64(str, { alphabet: \"base64url\" }) : base64ToUint8Array(str);\n}\nfunction u8ToB64(arr) {\n\treturn arr = arr instanceof ArrayBuffer ? new Uint8Array(arr) : arr, jsBase64Enabled ? arr.toBase64({\n\t\talphabet: \"base64url\",\n\t\tomitPadding: !0\n\t}) : uint8ArrayToBase64(arr, { urlSafe: !0 });\n}\nfunction u8ToHex(arr) {\n\treturn arr = arr instanceof ArrayBuffer ? new Uint8Array(arr) : arr, jsBase64Enabled ? arr.toHex() : uint8ArrayToHex(arr);\n}\nconst defaults = /* @__PURE__ */ Object.freeze({\n\tencryption: /* @__PURE__ */ Object.freeze({\n\t\talgorithm: \"aes-256-cbc\",\n\t\tsaltBits: 256,\n\t\titerations: 1,\n\t\tminPasswordlength: 32\n\t}),\n\tintegrity: /* @__PURE__ */ Object.freeze({\n\t\talgorithm: \"sha256\",\n\t\tsaltBits: 256,\n\t\titerations: 1,\n\t\tminPasswordlength: 32\n\t}),\n\tttl: 0,\n\ttimestampSkewSec: 60,\n\tlocaltimeOffsetMsec: 0\n});\nfunction clone(options) {\n\treturn {\n\t\t...options,\n\t\tencryption: { ...options.encryption },\n\t\tintegrity: { ...options.integrity }\n\t};\n}\nconst algorithms = /* @__PURE__ */ Object.freeze({\n\t\"aes-128-ctr\": /* @__PURE__ */ Object.freeze({\n\t\tkeyBits: 128,\n\t\tivBits: 128,\n\t\tname: \"AES-CTR\"\n\t}),\n\t\"aes-256-cbc\": /* @__PURE__ */ Object.freeze({\n\t\tkeyBits: 256,\n\t\tivBits: 128,\n\t\tname: \"AES-CBC\"\n\t}),\n\tsha256: /* @__PURE__ */ Object.freeze({\n\t\tkeyBits: 256,\n\t\tivBits: void 0,\n\t\tname: \"SHA-256\"\n\t})\n}), macFormatVersion = \"2\", macPrefix = \"Fe26.2\";\nfunction randomBits(bits) {\n\treturn crypto.getRandomValues(new Uint8Array(bits / 8));\n}\nasync function generateKey(password, options) {\n\tif (!password || !password.length) throw Error(\"Empty password\");\n\tif (!options || typeof options != \"object\") throw Error(\"Bad options\");\n\tlet algorithm = algorithms[options.algorithm];\n\tif (!algorithm) throw Error(\"Unknown algorithm: \" + options.algorithm);\n\tlet isHmac = algorithm.name === \"SHA-256\", id = isHmac ? {\n\t\tname: \"HMAC\",\n\t\thash: algorithm.name,\n\t\tlength: algorithm.keyBits\n\t} : {\n\t\tname: algorithm.name,\n\t\tlength: algorithm.keyBits\n\t}, usages = isHmac ? [\"sign\", \"verify\"] : [\"encrypt\", \"decrypt\"], iv = options.iv || (algorithm.ivBits ? randomBits(algorithm.ivBits) : void 0);\n\tif (typeof password == \"string\") {\n\t\tif (password.length < options.minPasswordlength) throw Error(\"Password string too short (min \" + options.minPasswordlength + \" characters required)\");\n\t\tlet salt = options.salt;\n\t\tif (!salt) {\n\t\t\tif (!options.saltBits) throw Error(\"Missing salt and saltBits options\");\n\t\t\tsalt = u8ToHex(randomBits(options.saltBits));\n\t\t}\n\t\tlet baseKey = await crypto.subtle.importKey(\"raw\", enc.encode(password), \"PBKDF2\", !1, [\"deriveKey\"]), algorithm$1 = {\n\t\t\tname: \"PBKDF2\",\n\t\t\tsalt: enc.encode(salt),\n\t\t\titerations: options.iterations,\n\t\t\thash: \"SHA-1\"\n\t\t};\n\t\treturn {\n\t\t\tkey: await crypto.subtle.deriveKey(algorithm$1, baseKey, id, !1, usages),\n\t\t\tiv,\n\t\t\tsalt\n\t\t};\n\t}\n\tif (password.length < algorithm.keyBits / 8) throw Error(\"Key buffer (password) too small\");\n\treturn {\n\t\tkey: await crypto.subtle.importKey(\"raw\", password.slice(), id, !1, usages),\n\t\tiv,\n\t\tsalt: \"\"\n\t};\n}\nfunction getEncryptParams(algorithm, key, data) {\n\treturn [\n\t\talgorithm === \"aes-128-ctr\" ? {\n\t\t\tname: \"AES-CTR\",\n\t\t\tcounter: key.iv,\n\t\t\tlength: 128\n\t\t} : {\n\t\t\tname: \"AES-CBC\",\n\t\t\tiv: key.iv\n\t\t},\n\t\tkey.key,\n\t\ttypeof data == \"string\" ? enc.encode(data) : data.slice()\n\t];\n}\nasync function encrypt(password, options, data) {\n\tlet key = await generateKey(password, options), encrypted = await crypto.subtle.encrypt(...getEncryptParams(options.algorithm, key, data));\n\treturn {\n\t\tencrypted: new Uint8Array(encrypted),\n\t\tkey\n\t};\n}\nasync function decrypt(password, options, data) {\n\tlet key = await generateKey(password, options), decrypted = await crypto.subtle.decrypt(...getEncryptParams(options.algorithm, key, data));\n\treturn dec.decode(decrypted);\n}\nasync function hmacWithPassword(password, options, data) {\n\tlet key = await generateKey(password, options);\n\treturn {\n\t\tdigest: u8ToB64(await crypto.subtle.sign(\"HMAC\", key.key, enc.encode(data))),\n\t\tsalt: key.salt\n\t};\n}\nfunction normalizePassword(password) {\n\tlet normalized = typeof password == \"string\" || password instanceof Uint8Array ? {\n\t\tencryption: password,\n\t\tintegrity: password\n\t} : password && typeof password == \"object\" ? \"secret\" in password ? {\n\t\tid: password.id,\n\t\tencryption: password.secret,\n\t\tintegrity: password.secret\n\t} : {\n\t\tid: password.id,\n\t\tencryption: password.encryption,\n\t\tintegrity: password.integrity\n\t} : void 0;\n\tif (!normalized || !normalized.encryption || normalized.encryption.length === 0 || !normalized.integrity || normalized.integrity.length === 0) throw Error(\"Empty password\");\n\treturn normalized;\n}\nasync function seal(object, password, options) {\n\tlet now = Date.now() + (options.localtimeOffsetMsec || 0), { id = \"\", encryption, integrity } = normalizePassword(password);\n\tif (id && !/^\\w+$/.test(id)) throw Error(\"Invalid password id\");\n\tlet { encrypted, key } = await encrypt(encryption, options.encryption, (options.encode || losslessJsonStringify)(object)), expiration = options.ttl ? now + options.ttl : \"\", macBaseString = macPrefix + \"*\" + id + \"*\" + key.salt + \"*\" + u8ToB64(key.iv) + \"*\" + u8ToB64(encrypted) + \"*\" + expiration, mac = await hmacWithPassword(integrity, options.integrity, macBaseString);\n\treturn macBaseString + \"*\" + mac.salt + \"*\" + mac.digest;\n}\nasync function unseal(sealed, password, options) {\n\tlet now = Date.now() + (options.localtimeOffsetMsec || 0), parts = sealed.split(\"*\");\n\tif (parts.length !== 8) throw Error(\"Incorrect number of sealed components\");\n\tlet [prefix, passwordId, encryptionSalt, ivB64, encryptedB64, expiration, hmacSalt, hmacDigestB64] = parts;\n\tif (prefix !== macPrefix) throw Error(\"Wrong mac prefix\");\n\tif (expiration) {\n\t\tif (!/^[1-9]\\d*$/.test(expiration)) throw Error(\"Invalid expiration\");\n\t\tif (Number.parseInt(expiration, 10) <= now - options.timestampSkewSec * 1e3) throw Error(\"Expired seal\");\n\t}\n\tlet pass;\n\tif (typeof password == \"string\" || password instanceof Uint8Array) pass = password;\n\telse if (typeof password == \"object\" && password) {\n\t\tlet passwordIdKey = passwordId || \"default\";\n\t\tif (pass = password[passwordIdKey], !pass) throw Error(\"Cannot find password: \" + passwordIdKey);\n\t}\n\tpass = normalizePassword(pass);\n\tlet key = await generateKey(pass.integrity, {\n\t\t...options.integrity,\n\t\tsalt: hmacSalt\n\t}), macBaseString = prefix + \"*\" + passwordId + \"*\" + encryptionSalt + \"*\" + ivB64 + \"*\" + encryptedB64 + \"*\" + expiration;\n\tif (!await crypto.subtle.verify(\"HMAC\", key.key, b64ToU8(hmacDigestB64), enc.encode(macBaseString))) throw Error(\"Bad hmac value\");\n\tlet decryptedString = await decrypt(pass.encryption, {\n\t\t...options.encryption,\n\t\tsalt: encryptionSalt,\n\t\tiv: b64ToU8(ivB64)\n\t}, b64ToU8(encryptedB64));\n\treturn (options.decode || jsonParse)(decryptedString);\n}\nexport { algorithms, clone, decrypt, defaults, encrypt, generateKey, hmacWithPassword, macFormatVersion, macPrefix, randomBits, seal, unseal };\n"],"x_google_ignoreList":[0],"mappings":";;;AAEA,SAAS,sBAAsB,MAAM;AACpC,KAAI;AACH,MAAI,OAAO,KAAK,EAAE;GACjB,IAAI,cAAc,KAAK,UAAU,KAAK;AACtC,OAAI,YAAa,QAAO;;SAElB;AACR,OAAM,MAAM,gCAAgC;;AAE7C,SAAS,UAAU,QAAQ;AAC1B,KAAI;AACH,SAAO,KAAK,MAAM,OAAO;UACjB,KAAK;AACb,QAAM,MAAM,wCAAwC,IAAI,QAAQ;;;AAGlE,SAAS,OAAO,KAAK;CACpB,IAAI,QAAQ,EAAE,EAAE,uBAAuB,IAAI,SAAS,EAAE,SAAS,UAAU,UAAU,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY,CAAC,IAAI,OAAO,SAAS,WAAW,OAAO,SAAS,MAAM,GAAG,OAAO,SAAS,WAAW,KAAK,IAAI,MAAM,GAAG,CAAC,KAAK,KAAK,IAAI,MAAM,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC,KAAK,CAAC;AAC1S,KAAI,CAAC,MAAM,IAAI,CAAE,QAAO,CAAC;AACzB,QAAO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uint8array-extras/index.js";
2
+
3
+ //#region node_modules/iron-webcrypto/index.js
4
+ function losslessJsonStringify(data) {
5
+ try {
6
+ if (isJson(data)) {
7
+ let stringified = JSON.stringify(data);
8
+ if (stringified) return stringified;
9
+ }
10
+ } catch {}
11
+ throw Error("Data is not JSON serializable");
12
+ }
13
+ function jsonParse(string) {
14
+ try {
15
+ return JSON.parse(string);
16
+ } catch (err) {
17
+ throw Error("Failed parsing sealed object JSON: " + err.message);
18
+ }
19
+ }
20
+ function isJson(val) {
21
+ let stack = [], seen = /* @__PURE__ */ new WeakSet(), check = (val$1) => val$1 === null || typeof val$1 == "string" || typeof val$1 == "boolean" ? !0 : typeof val$1 == "number" ? Number.isFinite(val$1) : typeof val$1 == "object" ? seen.has(val$1) ? !0 : (seen.add(val$1), stack.push(val$1), !0) : !1;
22
+ if (!check(val)) return !1;
23
+ for (; stack.length;) {
24
+ let obj = stack.pop();
25
+ if (Array.isArray(obj)) {
26
+ let i$1 = obj.length;
27
+ for (; i$1--;) if (!check(obj[i$1])) return !1;
28
+ continue;
29
+ }
30
+ let proto = Reflect.getPrototypeOf(obj);
31
+ if (proto !== null && proto !== Object.prototype) return !1;
32
+ let keys = Reflect.ownKeys(obj), i = keys.length;
33
+ for (; i--;) {
34
+ let key = keys[i];
35
+ if (typeof key != "string" || Reflect.getOwnPropertyDescriptor(obj, key)?.enumerable === !1) return !1;
36
+ let val$1 = obj[key];
37
+ if (val$1 !== void 0 && !check(val$1)) return !1;
38
+ }
39
+ }
40
+ return !0;
41
+ }
42
+ const enc = /* @__PURE__ */ new TextEncoder(), dec = /* @__PURE__ */ new TextDecoder(), jsBase64Enabled = /* @__PURE__ */ (() => typeof Uint8Array.fromBase64 == "function" && typeof Uint8Array.prototype.toBase64 == "function" && typeof Uint8Array.prototype.toHex == "function")();
43
+ function b64ToU8(str) {
44
+ return jsBase64Enabled ? Uint8Array.fromBase64(str, { alphabet: "base64url" }) : base64ToUint8Array(str);
45
+ }
46
+ function u8ToB64(arr) {
47
+ return arr = arr instanceof ArrayBuffer ? new Uint8Array(arr) : arr, jsBase64Enabled ? arr.toBase64({
48
+ alphabet: "base64url",
49
+ omitPadding: !0
50
+ }) : uint8ArrayToBase64(arr, { urlSafe: !0 });
51
+ }
52
+ function u8ToHex(arr) {
53
+ return arr = arr instanceof ArrayBuffer ? new Uint8Array(arr) : arr, jsBase64Enabled ? arr.toHex() : uint8ArrayToHex(arr);
54
+ }
55
+ const defaults = /* @__PURE__ */ Object.freeze({
56
+ encryption: /* @__PURE__ */ Object.freeze({
57
+ algorithm: "aes-256-cbc",
58
+ saltBits: 256,
59
+ iterations: 1,
60
+ minPasswordlength: 32
61
+ }),
62
+ integrity: /* @__PURE__ */ Object.freeze({
63
+ algorithm: "sha256",
64
+ saltBits: 256,
65
+ iterations: 1,
66
+ minPasswordlength: 32
67
+ }),
68
+ ttl: 0,
69
+ timestampSkewSec: 60,
70
+ localtimeOffsetMsec: 0
71
+ });
72
+ const algorithms = /* @__PURE__ */ Object.freeze({
73
+ "aes-128-ctr": /* @__PURE__ */ Object.freeze({
74
+ keyBits: 128,
75
+ ivBits: 128,
76
+ name: "AES-CTR"
77
+ }),
78
+ "aes-256-cbc": /* @__PURE__ */ Object.freeze({
79
+ keyBits: 256,
80
+ ivBits: 128,
81
+ name: "AES-CBC"
82
+ }),
83
+ sha256: /* @__PURE__ */ Object.freeze({
84
+ keyBits: 256,
85
+ ivBits: void 0,
86
+ name: "SHA-256"
87
+ })
88
+ }), macFormatVersion = "2", macPrefix = "Fe26.2";
89
+ function randomBits(bits) {
90
+ return crypto.getRandomValues(new Uint8Array(bits / 8));
91
+ }
92
+ async function generateKey(password, options) {
93
+ if (!password || !password.length) throw Error("Empty password");
94
+ if (!options || typeof options != "object") throw Error("Bad options");
95
+ let algorithm = algorithms[options.algorithm];
96
+ if (!algorithm) throw Error("Unknown algorithm: " + options.algorithm);
97
+ let isHmac = algorithm.name === "SHA-256", id = isHmac ? {
98
+ name: "HMAC",
99
+ hash: algorithm.name,
100
+ length: algorithm.keyBits
101
+ } : {
102
+ name: algorithm.name,
103
+ length: algorithm.keyBits
104
+ }, usages = isHmac ? ["sign", "verify"] : ["encrypt", "decrypt"], iv = options.iv || (algorithm.ivBits ? randomBits(algorithm.ivBits) : void 0);
105
+ if (typeof password == "string") {
106
+ if (password.length < options.minPasswordlength) throw Error("Password string too short (min " + options.minPasswordlength + " characters required)");
107
+ let salt = options.salt;
108
+ if (!salt) {
109
+ if (!options.saltBits) throw Error("Missing salt and saltBits options");
110
+ salt = u8ToHex(randomBits(options.saltBits));
111
+ }
112
+ let baseKey = await crypto.subtle.importKey("raw", enc.encode(password), "PBKDF2", !1, ["deriveKey"]), algorithm$1 = {
113
+ name: "PBKDF2",
114
+ salt: enc.encode(salt),
115
+ iterations: options.iterations,
116
+ hash: "SHA-1"
117
+ };
118
+ return {
119
+ key: await crypto.subtle.deriveKey(algorithm$1, baseKey, id, !1, usages),
120
+ iv,
121
+ salt
122
+ };
123
+ }
124
+ if (password.length < algorithm.keyBits / 8) throw Error("Key buffer (password) too small");
125
+ return {
126
+ key: await crypto.subtle.importKey("raw", password.slice(), id, !1, usages),
127
+ iv,
128
+ salt: ""
129
+ };
130
+ }
131
+ function getEncryptParams(algorithm, key, data) {
132
+ return [
133
+ algorithm === "aes-128-ctr" ? {
134
+ name: "AES-CTR",
135
+ counter: key.iv,
136
+ length: 128
137
+ } : {
138
+ name: "AES-CBC",
139
+ iv: key.iv
140
+ },
141
+ key.key,
142
+ typeof data == "string" ? enc.encode(data) : data.slice()
143
+ ];
144
+ }
145
+ async function encrypt(password, options, data) {
146
+ let key = await generateKey(password, options), encrypted = await crypto.subtle.encrypt(...getEncryptParams(options.algorithm, key, data));
147
+ return {
148
+ encrypted: new Uint8Array(encrypted),
149
+ key
150
+ };
151
+ }
152
+ async function decrypt(password, options, data) {
153
+ let key = await generateKey(password, options), decrypted = await crypto.subtle.decrypt(...getEncryptParams(options.algorithm, key, data));
154
+ return dec.decode(decrypted);
155
+ }
156
+ async function hmacWithPassword(password, options, data) {
157
+ let key = await generateKey(password, options);
158
+ return {
159
+ digest: u8ToB64(await crypto.subtle.sign("HMAC", key.key, enc.encode(data))),
160
+ salt: key.salt
161
+ };
162
+ }
163
+ function normalizePassword(password) {
164
+ let normalized = typeof password == "string" || password instanceof Uint8Array ? {
165
+ encryption: password,
166
+ integrity: password
167
+ } : password && typeof password == "object" ? "secret" in password ? {
168
+ id: password.id,
169
+ encryption: password.secret,
170
+ integrity: password.secret
171
+ } : {
172
+ id: password.id,
173
+ encryption: password.encryption,
174
+ integrity: password.integrity
175
+ } : void 0;
176
+ if (!normalized || !normalized.encryption || normalized.encryption.length === 0 || !normalized.integrity || normalized.integrity.length === 0) throw Error("Empty password");
177
+ return normalized;
178
+ }
179
+ async function seal(object, password, options) {
180
+ let now = Date.now() + (options.localtimeOffsetMsec || 0), { id = "", encryption, integrity } = normalizePassword(password);
181
+ if (id && !/^\w+$/.test(id)) throw Error("Invalid password id");
182
+ let { encrypted, key } = await encrypt(encryption, options.encryption, (options.encode || losslessJsonStringify)(object)), expiration = options.ttl ? now + options.ttl : "", macBaseString = macPrefix + "*" + id + "*" + key.salt + "*" + u8ToB64(key.iv) + "*" + u8ToB64(encrypted) + "*" + expiration, mac = await hmacWithPassword(integrity, options.integrity, macBaseString);
183
+ return macBaseString + "*" + mac.salt + "*" + mac.digest;
184
+ }
185
+ async function unseal(sealed, password, options) {
186
+ let now = Date.now() + (options.localtimeOffsetMsec || 0), parts = sealed.split("*");
187
+ if (parts.length !== 8) throw Error("Incorrect number of sealed components");
188
+ let [prefix, passwordId, encryptionSalt, ivB64, encryptedB64, expiration, hmacSalt, hmacDigestB64] = parts;
189
+ if (prefix !== macPrefix) throw Error("Wrong mac prefix");
190
+ if (expiration) {
191
+ if (!/^[1-9]\d*$/.test(expiration)) throw Error("Invalid expiration");
192
+ if (Number.parseInt(expiration, 10) <= now - options.timestampSkewSec * 1e3) throw Error("Expired seal");
193
+ }
194
+ let pass;
195
+ if (typeof password == "string" || password instanceof Uint8Array) pass = password;
196
+ else if (typeof password == "object" && password) {
197
+ let passwordIdKey = passwordId || "default";
198
+ if (pass = password[passwordIdKey], !pass) throw Error("Cannot find password: " + passwordIdKey);
199
+ }
200
+ pass = normalizePassword(pass);
201
+ let key = await generateKey(pass.integrity, {
202
+ ...options.integrity,
203
+ salt: hmacSalt
204
+ }), macBaseString = prefix + "*" + passwordId + "*" + encryptionSalt + "*" + ivB64 + "*" + encryptedB64 + "*" + expiration;
205
+ if (!await crypto.subtle.verify("HMAC", key.key, b64ToU8(hmacDigestB64), enc.encode(macBaseString))) throw Error("Bad hmac value");
206
+ let decryptedString = await decrypt(pass.encryption, {
207
+ ...options.encryption,
208
+ salt: encryptionSalt,
209
+ iv: b64ToU8(ivB64)
210
+ }, b64ToU8(encryptedB64));
211
+ return (options.decode || jsonParse)(decryptedString);
212
+ }
213
+
214
+ //#endregion
215
+ export { defaults, seal, unseal };
216
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../node_modules/iron-webcrypto/index.js"],"sourcesContent":["/* @ts-self-types=\"./index.d.ts\" */\nimport { base64ToUint8Array, uint8ArrayToBase64, uint8ArrayToHex } from \"uint8array-extras\";\nfunction losslessJsonStringify(data) {\n\ttry {\n\t\tif (isJson(data)) {\n\t\t\tlet stringified = JSON.stringify(data);\n\t\t\tif (stringified) return stringified;\n\t\t}\n\t} catch {}\n\tthrow Error(\"Data is not JSON serializable\");\n}\nfunction jsonParse(string) {\n\ttry {\n\t\treturn JSON.parse(string);\n\t} catch (err) {\n\t\tthrow Error(\"Failed parsing sealed object JSON: \" + err.message);\n\t}\n}\nfunction isJson(val) {\n\tlet stack = [], seen = /* @__PURE__ */ new WeakSet(), check = (val$1) => val$1 === null || typeof val$1 == \"string\" || typeof val$1 == \"boolean\" ? !0 : typeof val$1 == \"number\" ? Number.isFinite(val$1) : typeof val$1 == \"object\" ? seen.has(val$1) ? !0 : (seen.add(val$1), stack.push(val$1), !0) : !1;\n\tif (!check(val)) return !1;\n\tfor (; stack.length;) {\n\t\tlet obj = stack.pop();\n\t\tif (Array.isArray(obj)) {\n\t\t\tlet i$1 = obj.length;\n\t\t\tfor (; i$1--;) if (!check(obj[i$1])) return !1;\n\t\t\tcontinue;\n\t\t}\n\t\tlet proto = Reflect.getPrototypeOf(obj);\n\t\tif (proto !== null && proto !== Object.prototype) return !1;\n\t\tlet keys = Reflect.ownKeys(obj), i = keys.length;\n\t\tfor (; i--;) {\n\t\t\tlet key = keys[i];\n\t\t\tif (typeof key != \"string\" || Reflect.getOwnPropertyDescriptor(obj, key)?.enumerable === !1) return !1;\n\t\t\tlet val$1 = obj[key];\n\t\t\tif (val$1 !== void 0 && !check(val$1)) return !1;\n\t\t}\n\t}\n\treturn !0;\n}\nconst enc = /* @__PURE__ */ new TextEncoder(), dec = /* @__PURE__ */ new TextDecoder(), jsBase64Enabled = /* @__PURE__ */ (() => typeof Uint8Array.fromBase64 == \"function\" && typeof Uint8Array.prototype.toBase64 == \"function\" && typeof Uint8Array.prototype.toHex == \"function\")();\nfunction b64ToU8(str) {\n\treturn jsBase64Enabled ? Uint8Array.fromBase64(str, { alphabet: \"base64url\" }) : base64ToUint8Array(str);\n}\nfunction u8ToB64(arr) {\n\treturn arr = arr instanceof ArrayBuffer ? new Uint8Array(arr) : arr, jsBase64Enabled ? arr.toBase64({\n\t\talphabet: \"base64url\",\n\t\tomitPadding: !0\n\t}) : uint8ArrayToBase64(arr, { urlSafe: !0 });\n}\nfunction u8ToHex(arr) {\n\treturn arr = arr instanceof ArrayBuffer ? new Uint8Array(arr) : arr, jsBase64Enabled ? arr.toHex() : uint8ArrayToHex(arr);\n}\nconst defaults = /* @__PURE__ */ Object.freeze({\n\tencryption: /* @__PURE__ */ Object.freeze({\n\t\talgorithm: \"aes-256-cbc\",\n\t\tsaltBits: 256,\n\t\titerations: 1,\n\t\tminPasswordlength: 32\n\t}),\n\tintegrity: /* @__PURE__ */ Object.freeze({\n\t\talgorithm: \"sha256\",\n\t\tsaltBits: 256,\n\t\titerations: 1,\n\t\tminPasswordlength: 32\n\t}),\n\tttl: 0,\n\ttimestampSkewSec: 60,\n\tlocaltimeOffsetMsec: 0\n});\nfunction clone(options) {\n\treturn {\n\t\t...options,\n\t\tencryption: { ...options.encryption },\n\t\tintegrity: { ...options.integrity }\n\t};\n}\nconst algorithms = /* @__PURE__ */ Object.freeze({\n\t\"aes-128-ctr\": /* @__PURE__ */ Object.freeze({\n\t\tkeyBits: 128,\n\t\tivBits: 128,\n\t\tname: \"AES-CTR\"\n\t}),\n\t\"aes-256-cbc\": /* @__PURE__ */ Object.freeze({\n\t\tkeyBits: 256,\n\t\tivBits: 128,\n\t\tname: \"AES-CBC\"\n\t}),\n\tsha256: /* @__PURE__ */ Object.freeze({\n\t\tkeyBits: 256,\n\t\tivBits: void 0,\n\t\tname: \"SHA-256\"\n\t})\n}), macFormatVersion = \"2\", macPrefix = \"Fe26.2\";\nfunction randomBits(bits) {\n\treturn crypto.getRandomValues(new Uint8Array(bits / 8));\n}\nasync function generateKey(password, options) {\n\tif (!password || !password.length) throw Error(\"Empty password\");\n\tif (!options || typeof options != \"object\") throw Error(\"Bad options\");\n\tlet algorithm = algorithms[options.algorithm];\n\tif (!algorithm) throw Error(\"Unknown algorithm: \" + options.algorithm);\n\tlet isHmac = algorithm.name === \"SHA-256\", id = isHmac ? {\n\t\tname: \"HMAC\",\n\t\thash: algorithm.name,\n\t\tlength: algorithm.keyBits\n\t} : {\n\t\tname: algorithm.name,\n\t\tlength: algorithm.keyBits\n\t}, usages = isHmac ? [\"sign\", \"verify\"] : [\"encrypt\", \"decrypt\"], iv = options.iv || (algorithm.ivBits ? randomBits(algorithm.ivBits) : void 0);\n\tif (typeof password == \"string\") {\n\t\tif (password.length < options.minPasswordlength) throw Error(\"Password string too short (min \" + options.minPasswordlength + \" characters required)\");\n\t\tlet salt = options.salt;\n\t\tif (!salt) {\n\t\t\tif (!options.saltBits) throw Error(\"Missing salt and saltBits options\");\n\t\t\tsalt = u8ToHex(randomBits(options.saltBits));\n\t\t}\n\t\tlet baseKey = await crypto.subtle.importKey(\"raw\", enc.encode(password), \"PBKDF2\", !1, [\"deriveKey\"]), algorithm$1 = {\n\t\t\tname: \"PBKDF2\",\n\t\t\tsalt: enc.encode(salt),\n\t\t\titerations: options.iterations,\n\t\t\thash: \"SHA-1\"\n\t\t};\n\t\treturn {\n\t\t\tkey: await crypto.subtle.deriveKey(algorithm$1, baseKey, id, !1, usages),\n\t\t\tiv,\n\t\t\tsalt\n\t\t};\n\t}\n\tif (password.length < algorithm.keyBits / 8) throw Error(\"Key buffer (password) too small\");\n\treturn {\n\t\tkey: await crypto.subtle.importKey(\"raw\", password.slice(), id, !1, usages),\n\t\tiv,\n\t\tsalt: \"\"\n\t};\n}\nfunction getEncryptParams(algorithm, key, data) {\n\treturn [\n\t\talgorithm === \"aes-128-ctr\" ? {\n\t\t\tname: \"AES-CTR\",\n\t\t\tcounter: key.iv,\n\t\t\tlength: 128\n\t\t} : {\n\t\t\tname: \"AES-CBC\",\n\t\t\tiv: key.iv\n\t\t},\n\t\tkey.key,\n\t\ttypeof data == \"string\" ? enc.encode(data) : data.slice()\n\t];\n}\nasync function encrypt(password, options, data) {\n\tlet key = await generateKey(password, options), encrypted = await crypto.subtle.encrypt(...getEncryptParams(options.algorithm, key, data));\n\treturn {\n\t\tencrypted: new Uint8Array(encrypted),\n\t\tkey\n\t};\n}\nasync function decrypt(password, options, data) {\n\tlet key = await generateKey(password, options), decrypted = await crypto.subtle.decrypt(...getEncryptParams(options.algorithm, key, data));\n\treturn dec.decode(decrypted);\n}\nasync function hmacWithPassword(password, options, data) {\n\tlet key = await generateKey(password, options);\n\treturn {\n\t\tdigest: u8ToB64(await crypto.subtle.sign(\"HMAC\", key.key, enc.encode(data))),\n\t\tsalt: key.salt\n\t};\n}\nfunction normalizePassword(password) {\n\tlet normalized = typeof password == \"string\" || password instanceof Uint8Array ? {\n\t\tencryption: password,\n\t\tintegrity: password\n\t} : password && typeof password == \"object\" ? \"secret\" in password ? {\n\t\tid: password.id,\n\t\tencryption: password.secret,\n\t\tintegrity: password.secret\n\t} : {\n\t\tid: password.id,\n\t\tencryption: password.encryption,\n\t\tintegrity: password.integrity\n\t} : void 0;\n\tif (!normalized || !normalized.encryption || normalized.encryption.length === 0 || !normalized.integrity || normalized.integrity.length === 0) throw Error(\"Empty password\");\n\treturn normalized;\n}\nasync function seal(object, password, options) {\n\tlet now = Date.now() + (options.localtimeOffsetMsec || 0), { id = \"\", encryption, integrity } = normalizePassword(password);\n\tif (id && !/^\\w+$/.test(id)) throw Error(\"Invalid password id\");\n\tlet { encrypted, key } = await encrypt(encryption, options.encryption, (options.encode || losslessJsonStringify)(object)), expiration = options.ttl ? now + options.ttl : \"\", macBaseString = macPrefix + \"*\" + id + \"*\" + key.salt + \"*\" + u8ToB64(key.iv) + \"*\" + u8ToB64(encrypted) + \"*\" + expiration, mac = await hmacWithPassword(integrity, options.integrity, macBaseString);\n\treturn macBaseString + \"*\" + mac.salt + \"*\" + mac.digest;\n}\nasync function unseal(sealed, password, options) {\n\tlet now = Date.now() + (options.localtimeOffsetMsec || 0), parts = sealed.split(\"*\");\n\tif (parts.length !== 8) throw Error(\"Incorrect number of sealed components\");\n\tlet [prefix, passwordId, encryptionSalt, ivB64, encryptedB64, expiration, hmacSalt, hmacDigestB64] = parts;\n\tif (prefix !== macPrefix) throw Error(\"Wrong mac prefix\");\n\tif (expiration) {\n\t\tif (!/^[1-9]\\d*$/.test(expiration)) throw Error(\"Invalid expiration\");\n\t\tif (Number.parseInt(expiration, 10) <= now - options.timestampSkewSec * 1e3) throw Error(\"Expired seal\");\n\t}\n\tlet pass;\n\tif (typeof password == \"string\" || password instanceof Uint8Array) pass = password;\n\telse if (typeof password == \"object\" && password) {\n\t\tlet passwordIdKey = passwordId || \"default\";\n\t\tif (pass = password[passwordIdKey], !pass) throw Error(\"Cannot find password: \" + passwordIdKey);\n\t}\n\tpass = normalizePassword(pass);\n\tlet key = await generateKey(pass.integrity, {\n\t\t...options.integrity,\n\t\tsalt: hmacSalt\n\t}), macBaseString = prefix + \"*\" + passwordId + \"*\" + encryptionSalt + \"*\" + ivB64 + \"*\" + encryptedB64 + \"*\" + expiration;\n\tif (!await crypto.subtle.verify(\"HMAC\", key.key, b64ToU8(hmacDigestB64), enc.encode(macBaseString))) throw Error(\"Bad hmac value\");\n\tlet decryptedString = await decrypt(pass.encryption, {\n\t\t...options.encryption,\n\t\tsalt: encryptionSalt,\n\t\tiv: b64ToU8(ivB64)\n\t}, b64ToU8(encryptedB64));\n\treturn (options.decode || jsonParse)(decryptedString);\n}\nexport { algorithms, clone, decrypt, defaults, encrypt, generateKey, hmacWithPassword, macFormatVersion, macPrefix, randomBits, seal, unseal };\n"],"x_google_ignoreList":[0],"mappings":";;;AAEA,SAAS,sBAAsB,MAAM;AACpC,KAAI;AACH,MAAI,OAAO,KAAK,EAAE;GACjB,IAAI,cAAc,KAAK,UAAU,KAAK;AACtC,OAAI,YAAa,QAAO;;SAElB;AACR,OAAM,MAAM,gCAAgC;;AAE7C,SAAS,UAAU,QAAQ;AAC1B,KAAI;AACH,SAAO,KAAK,MAAM,OAAO;UACjB,KAAK;AACb,QAAM,MAAM,wCAAwC,IAAI,QAAQ;;;AAGlE,SAAS,OAAO,KAAK;CACpB,IAAI,QAAQ,EAAE,EAAE,uBAAuB,IAAI,SAAS,EAAE,SAAS,UAAU,UAAU,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY,CAAC,IAAI,OAAO,SAAS,WAAW,OAAO,SAAS,MAAM,GAAG,OAAO,SAAS,WAAW,KAAK,IAAI,MAAM,GAAG,CAAC,KAAK,KAAK,IAAI,MAAM,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC,KAAK,CAAC;AAC1S,KAAI,CAAC,MAAM,IAAI,CAAE,QAAO,CAAC;AACzB,QAAO,MAAM,SAAS;EACrB,IAAI,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[object Uint8Array]";
5
+ function isType(value, typeConstructor, typeStringified) {
6
+ if (!value) return false;
7
+ if (value.constructor === typeConstructor) return true;
8
+ return objectToString.call(value) === typeStringified;
9
+ }
10
+ function isUint8Array(value) {
11
+ return isType(value, Uint8Array, uint8ArrayStringified);
12
+ }
13
+ function assertUint8Array(value) {
14
+ if (!isUint8Array(value)) throw new TypeError(`Expected \`Uint8Array\`, got \`${typeof value}\``);
15
+ }
16
+ const cachedDecoders = { utf8: new globalThis.TextDecoder("utf8") };
17
+ function assertString(value) {
18
+ if (typeof value !== "string") throw new TypeError(`Expected \`string\`, got \`${typeof value}\``);
19
+ }
20
+ const cachedEncoder = new globalThis.TextEncoder();
21
+ function base64ToBase64Url(base64) {
22
+ return base64.replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
23
+ }
24
+ function base64UrlToBase64(base64url) {
25
+ const base64 = base64url.replaceAll("-", "+").replaceAll("_", "/");
26
+ const padding = (4 - base64.length % 4) % 4;
27
+ return base64 + "=".repeat(padding);
28
+ }
29
+ const MAX_BLOCK_SIZE = 65535;
30
+ function uint8ArrayToBase64(array, { urlSafe = false } = {}) {
31
+ assertUint8Array(array);
32
+ let base64 = "";
33
+ for (let index = 0; index < array.length; index += MAX_BLOCK_SIZE) {
34
+ const chunk = array.subarray(index, index + MAX_BLOCK_SIZE);
35
+ base64 += globalThis.btoa(String.fromCodePoint.apply(void 0, chunk));
36
+ }
37
+ return urlSafe ? base64ToBase64Url(base64) : base64;
38
+ }
39
+ function base64ToUint8Array(base64String) {
40
+ assertString(base64String);
41
+ return Uint8Array.from(globalThis.atob(base64UrlToBase64(base64String)), (x) => x.codePointAt(0));
42
+ }
43
+ const byteToHexLookupTable = Array.from({ length: 256 }, (_, index) => index.toString(16).padStart(2, "0"));
44
+ function uint8ArrayToHex(array) {
45
+ assertUint8Array(array);
46
+ let hexString = "";
47
+ for (let index = 0; index < array.length; index++) hexString += byteToHexLookupTable[array[index]];
48
+ return hexString;
49
+ }
50
+
51
+ //#endregion
52
+ exports.base64ToUint8Array = base64ToUint8Array;
53
+ exports.uint8ArrayToBase64 = uint8ArrayToBase64;
54
+ exports.uint8ArrayToHex = uint8ArrayToHex;
55
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../../node_modules/uint8array-extras/index.js"],"sourcesContent":["const objectToString = Object.prototype.toString;\nconst uint8ArrayStringified = '[object Uint8Array]';\nconst arrayBufferStringified = '[object ArrayBuffer]';\n\nfunction isType(value, typeConstructor, typeStringified) {\n\tif (!value) {\n\t\treturn false;\n\t}\n\n\tif (value.constructor === typeConstructor) {\n\t\treturn true;\n\t}\n\n\treturn objectToString.call(value) === typeStringified;\n}\n\nexport function isUint8Array(value) {\n\treturn isType(value, Uint8Array, uint8ArrayStringified);\n}\n\nfunction isArrayBuffer(value) {\n\treturn isType(value, ArrayBuffer, arrayBufferStringified);\n}\n\nfunction isUint8ArrayOrArrayBuffer(value) {\n\treturn isUint8Array(value) || isArrayBuffer(value);\n}\n\nexport function assertUint8Array(value) {\n\tif (!isUint8Array(value)) {\n\t\tthrow new TypeError(`Expected \\`Uint8Array\\`, got \\`${typeof value}\\``);\n\t}\n}\n\nexport function assertUint8ArrayOrArrayBuffer(value) {\n\tif (!isUint8ArrayOrArrayBuffer(value)) {\n\t\tthrow new TypeError(`Expected \\`Uint8Array\\` or \\`ArrayBuffer\\`, got \\`${typeof value}\\``);\n\t}\n}\n\nexport function toUint8Array(value) {\n\tif (value instanceof ArrayBuffer) {\n\t\treturn new Uint8Array(value);\n\t}\n\n\tif (ArrayBuffer.isView(value)) {\n\t\treturn new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n\t}\n\n\tthrow new TypeError(`Unsupported value, got \\`${typeof value}\\`.`);\n}\n\nexport function concatUint8Arrays(arrays, totalLength) {\n\tif (arrays.length === 0) {\n\t\treturn new Uint8Array(0);\n\t}\n\n\ttotalLength ??= arrays.reduce((accumulator, currentValue) => accumulator + currentValue.length, 0);\n\n\tconst returnValue = new Uint8Array(totalLength);\n\n\tlet offset = 0;\n\tfor (const array of arrays) {\n\t\tassertUint8Array(array);\n\t\treturnValue.set(array, offset);\n\t\toffset += array.length;\n\t}\n\n\treturn returnValue;\n}\n\nexport function areUint8ArraysEqual(a, b) {\n\tassertUint8Array(a);\n\tassertUint8Array(b);\n\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a.length !== b.length) {\n\t\treturn false;\n\t}\n\n\t// eslint-disable-next-line unicorn/no-for-loop\n\tfor (let index = 0; index < a.length; index++) {\n\t\tif (a[index] !== b[index]) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nexport function compareUint8Arrays(a, b) {\n\tassertUint8Array(a);\n\tassertUint8Array(b);\n\n\tconst length = Math.min(a.length, b.length);\n\n\tfor (let index = 0; index < length; index++) {\n\t\tconst diff = a[index] - b[index];\n\t\tif (diff !== 0) {\n\t\t\treturn Math.sign(diff);\n\t\t}\n\t}\n\n\t// At this point, all the compared elements are equal.\n\t// The shorter array should come first if the arrays are of different lengths.\n\treturn Math.sign(a.length - b.length);\n}\n\nconst cachedDecoders = {\n\tutf8: new globalThis.TextDecoder('utf8'),\n};\n\nexport function uint8ArrayToString(array, encoding = 'utf8') {\n\tassertUint8ArrayOrArrayBuffer(array);\n\tcachedDecoders[encoding] ??= new globalThis.TextDecoder(encoding);\n\treturn cachedDecoders[encoding].decode(array);\n}\n\nfunction assertString(value) {\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Expected \\`string\\`, got \\`${typeof value}\\``);\n\t}\n}\n\nconst cachedEncoder = new globalThis.TextEncoder();\n\nexport function stringToUint8Array(string) {\n\tassertString(string);\n\treturn cachedEncoder.encode(string);\n}\n\nfunction base64ToBase64Url(base64) {\n\treturn base64.replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');\n}\n\nfunction base64UrlToBase64(base64url) {\n\tconst base64 = base64url.replaceAll('-', '+').replaceAll('_', '/');\n\tconst padding = (4 - (base64.length % 4)) % 4;\n\treturn base64 + '='.repeat(padding);\n}\n\n// Reference: https://phuoc.ng/collection/this-vs-that/concat-vs-push/\n// Important: Keep this value divisible by 3 so intermediate chunks produce no Base64 padding.\nconst MAX_BLOCK_SIZE = 65_535;\n\nexport function uint8ArrayToBase64(array, {urlSafe = false} = {}) {\n\tassertUint8Array(array);\n\n\tlet base64 = '';\n\n\tfor (let index = 0; index < array.length; index += MAX_BLOCK_SIZE) {\n\t\tconst chunk = array.subarray(index, index + MAX_BLOCK_SIZE);\n\t\t// Required as `btoa` and `atob` don't properly support Unicode: https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem\n\t\tbase64 += globalThis.btoa(String.fromCodePoint.apply(undefined, chunk));\n\t}\n\n\treturn urlSafe ? base64ToBase64Url(base64) : base64;\n}\n\nexport function base64ToUint8Array(base64String) {\n\tassertString(base64String);\n\treturn Uint8Array.from(globalThis.atob(base64UrlToBase64(base64String)), x => x.codePointAt(0));\n}\n\nexport function stringToBase64(string, {urlSafe = false} = {}) {\n\tassertString(string);\n\treturn uint8ArrayToBase64(stringToUint8Array(string), {urlSafe});\n}\n\nexport function base64ToString(base64String) {\n\tassertString(base64String);\n\treturn uint8ArrayToString(base64ToUint8Array(base64String));\n}\n\nconst byteToHexLookupTable = Array.from({length: 256}, (_, index) => index.toString(16).padStart(2, '0'));\n\nexport function uint8ArrayToHex(array) {\n\tassertUint8Array(array);\n\n\t// Concatenating a string is faster than using an array.\n\tlet hexString = '';\n\n\t// eslint-disable-next-line unicorn/no-for-loop -- Max performance is critical.\n\tfor (let index = 0; index < array.length; index++) {\n\t\thexString += byteToHexLookupTable[array[index]];\n\t}\n\n\treturn hexString;\n}\n\nconst hexToDecimalLookupTable = {\n\t0: 0,\n\t1: 1,\n\t2: 2,\n\t3: 3,\n\t4: 4,\n\t5: 5,\n\t6: 6,\n\t7: 7,\n\t8: 8,\n\t9: 9,\n\ta: 10,\n\tb: 11,\n\tc: 12,\n\td: 13,\n\te: 14,\n\tf: 15,\n\tA: 10,\n\tB: 11,\n\tC: 12,\n\tD: 13,\n\tE: 14,\n\tF: 15,\n};\n\nexport function hexToUint8Array(hexString) {\n\tassertString(hexString);\n\n\tif (hexString.length % 2 !== 0) {\n\t\tthrow new Error('Invalid Hex string length.');\n\t}\n\n\tconst resultLength = hexString.length / 2;\n\tconst bytes = new Uint8Array(resultLength);\n\n\tfor (let index = 0; index < resultLength; index++) {\n\t\tconst highNibble = hexToDecimalLookupTable[hexString[index * 2]];\n\t\tconst lowNibble = hexToDecimalLookupTable[hexString[(index * 2) + 1]];\n\n\t\tif (highNibble === undefined || lowNibble === undefined) {\n\t\t\tthrow new Error(`Invalid Hex character encountered at position ${index * 2}`);\n\t\t}\n\n\t\tbytes[index] = (highNibble << 4) | lowNibble; // eslint-disable-line no-bitwise\n\t}\n\n\treturn bytes;\n}\n\n/**\n@param {DataView} view\n@returns {number}\n*/\nexport function getUintBE(view) {\n\tconst {byteLength} = view;\n\n\tif (byteLength === 6) {\n\t\treturn (view.getUint16(0) * (2 ** 32)) + view.getUint32(2);\n\t}\n\n\tif (byteLength === 5) {\n\t\treturn (view.getUint8(0) * (2 ** 32)) + view.getUint32(1);\n\t}\n\n\tif (byteLength === 4) {\n\t\treturn view.getUint32(0);\n\t}\n\n\tif (byteLength === 3) {\n\t\treturn (view.getUint8(0) * (2 ** 16)) + view.getUint16(1);\n\t}\n\n\tif (byteLength === 2) {\n\t\treturn view.getUint16(0);\n\t}\n\n\tif (byteLength === 1) {\n\t\treturn view.getUint8(0);\n\t}\n}\n\n/**\n@param {Uint8Array} array\n@param {Uint8Array} value\n@returns {number}\n*/\nexport function indexOf(array, value) {\n\tconst arrayLength = array.length;\n\tconst valueLength = value.length;\n\n\tif (valueLength === 0) {\n\t\treturn -1;\n\t}\n\n\tif (valueLength > arrayLength) {\n\t\treturn -1;\n\t}\n\n\tconst validOffsetLength = arrayLength - valueLength;\n\n\tfor (let index = 0; index <= validOffsetLength; index++) {\n\t\tlet isMatch = true;\n\t\tfor (let index2 = 0; index2 < valueLength; index2++) {\n\t\t\tif (array[index + index2] !== value[index2]) {\n\t\t\t\tisMatch = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (isMatch) {\n\t\t\treturn index;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\n/**\n@param {Uint8Array} array\n@param {Uint8Array} value\n@returns {boolean}\n*/\nexport function includes(array, value) {\n\treturn indexOf(array, value) !== -1;\n}\n"],"x_google_ignoreList":[0],"mappings":";;AAAA,MAAM,iBAAiB,OAAO,UAAU;AACxC,MAAM,wBAAwB;AAG9B,SAAS,OAAO,OAAO,iBAAiB,iBAAiB;AACxD,KAAI,CAAC,MACJ,QAAO;AAGR,KAAI,MAAM,gBAAgB,gBACzB,QAAO;AAGR,QAAO,eAAe,KAAK,MAAM,KAAK;;AAGvC,SAAgB,aAAa,OAAO;AACnC,QAAO,OAAO,OAAO,YAAY,sBAAsB;;AAWxD,SAAgB,iBAAiB,OAAO;AACvC,KAAI,CAAC,aAAa,MAAM,CACvB,OAAM,IAAI,UAAU,kCAAkC,OAAO,MAAM,IAAI;;AAiFzE,MAAM,iBAAiB,EACtB,MAAM,IAAI,WAAW,YAAY,OAAO,EACxC;AAQD,SAAS,aAAa,OAAO;AAC5B,KAAI,OAAO,UAAU,SACpB,OAAM,IAAI,UAAU,8BAA8B,OAAO,MAAM,IAAI;;AAIrE,MAAM,gBAAgB,IAAI,WAAW,aAAa;AAOlD,SAAS,kBAAkB,QAAQ;AAClC,QAAO,OAAO,WAAW,KAAK,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,QAAQ,OAAO,GAAG;;AAG3E,SAAS,kBAAkB,WAAW;CACrC,MAAM,SAAS,UAAU,WAAW,KAAK,IAAI,CAAC,WAAW,KAAK,IAAI;CAClE,MAAM,WAAW,IAAK,OAAO,SAAS,KAAM;AAC5C,QAAO,SAAS,IAAI,OAAO,QAAQ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