@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.
- package/CHANGELOG.md +4 -0
- package/README.md +1 -0
- package/SECURITY.md +17 -0
- package/lib/addresses.js +2 -2
- package/lib/admin.js +49 -45
- package/lib/affiliates.js +7 -23
- package/lib/announcement-bar.js +5 -22
- package/lib/api-keys.js +4 -13
- package/lib/asset-manifest.json +1 -1
- package/lib/banner-ab-tests.js +5 -9
- package/lib/blog-articles.js +8 -26
- package/lib/captcha-gate.js +7 -17
- package/lib/carrier-accounts.js +3 -10
- package/lib/catalog-drafts.js +5 -12
- package/lib/category-navigation.js +4 -20
- package/lib/cms-blocks.js +4 -7
- package/lib/compliance-export.js +4 -11
- package/lib/consent-ledger.js +2 -4
- package/lib/cost-layers.js +56 -21
- package/lib/customer-import.js +2 -2
- package/lib/customer-notes.js +7 -23
- package/lib/customer-roles.js +3 -5
- package/lib/customer-segments.js +17 -14
- package/lib/customer-surveys.js +7 -14
- package/lib/customers.js +2 -4
- package/lib/dispute-resolution.js +5 -13
- package/lib/dropship-forwarding.js +3 -5
- package/lib/dunning.js +2 -7
- package/lib/email-ab-tests.js +4 -8
- package/lib/email-campaigns.js +25 -14
- package/lib/email-warmup.js +2 -7
- package/lib/experiments.js +6 -10
- package/lib/externaldb-d1.js +78 -44
- package/lib/geolocation.js +18 -28
- package/lib/gift-options.js +5 -23
- package/lib/knowledge-base.js +7 -22
- package/lib/line-gift-wrap.js +3 -17
- package/lib/live-chat.js +5 -18
- package/lib/metered-usage.js +3 -8
- package/lib/notifications.js +3 -7
- package/lib/operator-accounts.js +3 -5
- package/lib/operator-approvals.js +6 -8
- package/lib/operator-audit-log.js +2 -7
- package/lib/operator-help-center.js +5 -21
- package/lib/operator-inbox.js +4 -11
- package/lib/operator-roles.js +5 -7
- package/lib/order-escalation.js +2 -2
- package/lib/order-export.js +24 -20
- package/lib/order-notes.js +4 -14
- package/lib/order-ratings.js +4 -10
- package/lib/payment-methods.js +5 -13
- package/lib/payment-retries.js +2 -7
- package/lib/payment.js +103 -58
- package/lib/pixel-events.js +8 -23
- package/lib/plan-changes.js +2 -7
- package/lib/product-qa.js +4 -8
- package/lib/promo-banners.js +7 -15
- package/lib/purchase-orders.js +3 -6
- package/lib/push-notifications.js +7 -32
- package/lib/pwa-manifest.js +6 -11
- package/lib/quotes.js +5 -9
- package/lib/referrals.js +10 -6
- package/lib/reviews.js +4 -10
- package/lib/robots-config.js +6 -14
- package/lib/sales-tax-filings.js +2 -2
- package/lib/search-facets.js +5 -5
- package/lib/search-ranking.js +4 -7
- package/lib/search-synonyms.js +7 -21
- package/lib/security-middleware.js +125 -70
- package/lib/seller-signup.js +10 -26
- package/lib/sidebar-widgets.js +6 -15
- package/lib/site-redirects.js +49 -137
- package/lib/sitemap-generator.js +3 -7
- package/lib/sms-dispatcher.js +7 -23
- package/lib/stock-receipts.js +4 -10
- package/lib/storefront-dashboards.js +2 -10
- package/lib/storefront-forms.js +9 -22
- package/lib/storefront-pages.js +6 -20
- package/lib/storefront.js +21 -23
- package/lib/subscription-billing.js +3 -8
- package/lib/subscription-controls.js +2 -7
- package/lib/suggestion-box.js +9 -26
- package/lib/support-tickets.js +6 -24
- package/lib/tax-remittance.js +2 -2
- package/lib/tenants.js +2 -7
- package/lib/text-guard.js +137 -35
- package/lib/theme-assets.js +4 -16
- package/lib/translations.js +3 -6
- package/lib/trust-badges.js +4 -7
- package/lib/vendor/MANIFEST.json +107 -97
- package/lib/vendor/blamejs/CHANGELOG.md +180 -0
- package/lib/vendor/blamejs/NOTICE +14 -10
- package/lib/vendor/blamejs/README.md +17 -5
- package/lib/vendor/blamejs/index.js +2 -0
- package/lib/vendor/blamejs/lib/acme.js +9 -9
- package/lib/vendor/blamejs/lib/api-snapshot.js +35 -16
- package/lib/vendor/blamejs/lib/app-shutdown.js +1 -1
- package/lib/vendor/blamejs/lib/archive-adapters.js +1 -1
- package/lib/vendor/blamejs/lib/archive.js +13 -24
- package/lib/vendor/blamejs/lib/auth/access-lock.js +2 -1
- package/lib/vendor/blamejs/lib/auth/bot-challenge.js +3 -6
- package/lib/vendor/blamejs/lib/auth/ciba.js +32 -3
- package/lib/vendor/blamejs/lib/auth/oauth.js +65 -8
- package/lib/vendor/blamejs/lib/auth/password.js +1 -1
- package/lib/vendor/blamejs/lib/auth/saml.js +21 -3
- package/lib/vendor/blamejs/lib/auth-bot-challenge.js +3 -3
- package/lib/vendor/blamejs/lib/backup/index.js +5 -5
- package/lib/vendor/blamejs/lib/case-fold-classes.js +491 -0
- package/lib/vendor/blamejs/lib/codepoint-class.js +131 -0
- package/lib/vendor/blamejs/lib/constants.js +79 -0
- package/lib/vendor/blamejs/lib/db-declare-view.js +8 -2
- package/lib/vendor/blamejs/lib/error-page.js +20 -1
- package/lib/vendor/blamejs/lib/external-db.js +5 -1
- package/lib/vendor/blamejs/lib/flag-evaluation-context.js +24 -6
- package/lib/vendor/blamejs/lib/flag.js +28 -2
- package/lib/vendor/blamejs/lib/framework-schema.js +14 -3
- package/lib/vendor/blamejs/lib/guard-regex.js +2345 -89
- package/lib/vendor/blamejs/lib/http-client.js +217 -40
- package/lib/vendor/blamejs/lib/mail-bimi.js +1 -1
- package/lib/vendor/blamejs/lib/mail-crypto-pgp.js +3 -2
- package/lib/vendor/blamejs/lib/mail-dav.js +26 -26
- package/lib/vendor/blamejs/lib/mail-deploy.js +10 -10
- package/lib/vendor/blamejs/lib/mail-scan.js +3 -0
- package/lib/vendor/blamejs/lib/mail-store.js +7 -1
- package/lib/vendor/blamejs/lib/mail.js +5 -1
- package/lib/vendor/blamejs/lib/middleware/age-gate.js +3 -2
- package/lib/vendor/blamejs/lib/middleware/api-encrypt.js +1 -1
- package/lib/vendor/blamejs/lib/middleware/assetlinks.js +2 -1
- package/lib/vendor/blamejs/lib/middleware/asyncapi-serve.js +3 -2
- package/lib/vendor/blamejs/lib/middleware/bearer-auth.js +2 -1
- package/lib/vendor/blamejs/lib/middleware/compression.js +1 -1
- package/lib/vendor/blamejs/lib/middleware/cors.js +1 -1
- package/lib/vendor/blamejs/lib/middleware/csp-report.js +5 -5
- package/lib/vendor/blamejs/lib/middleware/csrf-protect.js +2 -1
- package/lib/vendor/blamejs/lib/middleware/daily-byte-quota.js +2 -2
- package/lib/vendor/blamejs/lib/middleware/deny-response.js +2 -1
- package/lib/vendor/blamejs/lib/middleware/dpop.js +2 -2
- package/lib/vendor/blamejs/lib/middleware/fetch-metadata.js +2 -1
- package/lib/vendor/blamejs/lib/middleware/flag-context.js +17 -0
- package/lib/vendor/blamejs/lib/middleware/idempotency-key.js +10 -8
- package/lib/vendor/blamejs/lib/middleware/openapi-serve.js +3 -2
- package/lib/vendor/blamejs/lib/middleware/require-aal.js +3 -2
- package/lib/vendor/blamejs/lib/middleware/require-auth.js +4 -3
- package/lib/vendor/blamejs/lib/middleware/require-bound-key.js +4 -3
- package/lib/vendor/blamejs/lib/middleware/require-content-type.js +3 -2
- package/lib/vendor/blamejs/lib/middleware/require-methods.js +3 -2
- package/lib/vendor/blamejs/lib/middleware/require-mtls.js +3 -2
- package/lib/vendor/blamejs/lib/middleware/security-txt.js +2 -1
- package/lib/vendor/blamejs/lib/middleware/web-app-manifest.js +2 -1
- package/lib/vendor/blamejs/lib/network-dns-resolver.js +1 -1
- package/lib/vendor/blamejs/lib/network-dns.js +3 -3
- package/lib/vendor/blamejs/lib/network-nts.js +35 -14
- package/lib/vendor/blamejs/lib/network-proxy.js +42 -4
- package/lib/vendor/blamejs/lib/network-smtp-policy.js +1 -1
- package/lib/vendor/blamejs/lib/network-tls.js +341 -11
- package/lib/vendor/blamejs/lib/nist-crosswalk.js +2 -2
- package/lib/vendor/blamejs/lib/ntp-check.js +30 -19
- package/lib/vendor/blamejs/lib/object-store/azure-blob.js +1 -1
- package/lib/vendor/blamejs/lib/object-store/gcs.js +1 -1
- package/lib/vendor/blamejs/lib/object-store/http-put.js +2 -1
- package/lib/vendor/blamejs/lib/object-store/sigv4-bucket-ops.js +5 -5
- package/lib/vendor/blamejs/lib/object-store/sigv4.js +2 -2
- package/lib/vendor/blamejs/lib/observability-otlp-exporter.js +4 -2
- package/lib/vendor/blamejs/lib/openapi.js +1 -1
- package/lib/vendor/blamejs/lib/pqc-agent.js +4 -7
- package/lib/vendor/blamejs/lib/problem-details.js +2 -1
- package/lib/vendor/blamejs/lib/redis-client.js +12 -1
- package/lib/vendor/blamejs/lib/regex-linear.js +1349 -0
- package/lib/vendor/blamejs/lib/render.js +531 -7
- package/lib/vendor/blamejs/lib/request-helpers.js +181 -5
- package/lib/vendor/blamejs/lib/router.js +37 -13
- package/lib/vendor/blamejs/lib/safe-async.js +142 -0
- package/lib/vendor/blamejs/lib/safe-icap.js +3 -0
- package/lib/vendor/blamejs/lib/safe-sql.js +15 -3
- package/lib/vendor/blamejs/lib/self-update.js +2 -2
- package/lib/vendor/blamejs/lib/testing.js +54 -7
- package/lib/vendor/blamejs/lib/validate-opts.js +56 -0
- package/lib/vendor/blamejs/lib/vendor/MANIFEST.json +62 -25
- package/lib/vendor/blamejs/lib/vendor/blamejs-pki.cjs +2004 -142
- package/lib/vendor/blamejs/lib/vendor/browser/noble-ciphers.mjs +727 -0
- package/lib/vendor/blamejs/lib/vendor/browser/noble-hashes.mjs +1070 -0
- package/lib/vendor/blamejs/lib/vendor/browser/noble-post-quantum.mjs +1090 -0
- package/lib/vendor/blamejs/lib/vendor/noble-post-quantum.cjs +510 -227
- package/lib/vendor/blamejs/lib/webhook-hmac.js +19 -2
- package/lib/vendor/blamejs/lib/webhook.js +1 -1
- package/lib/vendor/blamejs/lib/ws-client.js +24 -2
- package/lib/vendor/blamejs/package.json +1 -1
- package/lib/vendor/blamejs/sbom.cdx.json +6 -6
- package/lib/vendor-invoices.js +3 -6
- package/lib/vendors.js +5 -19
- package/lib/webhook-receiver.js +46 -83
- package/lib/webhook-subscriptions.js +3 -13
- package/lib/wishlist-sharing.js +5 -10
- package/package.json +1 -1
|
@@ -0,0 +1,1070 @@
|
|
|
1
|
+
// @noble/hashes v2.3.0 — vendored from Paul Miller
|
|
2
|
+
// License: MIT — https://github.com/paulmillr/noble-hashes
|
|
3
|
+
// Browser build (ESM), bundled with esbuild. The server side uses node:crypto
|
|
4
|
+
// for these, so there is no .cjs beside it.
|
|
5
|
+
// Exports: shake128 / shake256 / sha3_256 / sha3_512 (FIPS 202),
|
|
6
|
+
// sha256 / sha512, hmac (RFC 2104), hkdf (RFC 5869).
|
|
7
|
+
// node_modules/@noble/hashes/_u64.js
|
|
8
|
+
var U32_MASK64 = /* @__PURE__ */ (() => BigInt(2 ** 32 - 1))();
|
|
9
|
+
var _32n = /* @__PURE__ */ BigInt(32);
|
|
10
|
+
function fromBig(n, le = false) {
|
|
11
|
+
if (le)
|
|
12
|
+
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
|
|
13
|
+
return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
14
|
+
}
|
|
15
|
+
function split(lst, le = false) {
|
|
16
|
+
const len = lst.length;
|
|
17
|
+
let Ah = new Uint32Array(len);
|
|
18
|
+
let Al = new Uint32Array(len);
|
|
19
|
+
for (let i = 0; i < len; i++) {
|
|
20
|
+
const { h, l } = fromBig(lst[i], le);
|
|
21
|
+
[Ah[i], Al[i]] = [h, l];
|
|
22
|
+
}
|
|
23
|
+
return [Ah, Al];
|
|
24
|
+
}
|
|
25
|
+
var fromNumH = (n) => n / 2 ** 32 | 0;
|
|
26
|
+
var fromNumL = (n) => n >>> 0;
|
|
27
|
+
function setU64FromNum(view, byteOffset, n, isLE2) {
|
|
28
|
+
const h = fromNumH(n);
|
|
29
|
+
const l = fromNumL(n);
|
|
30
|
+
view.setUint32(byteOffset, isLE2 ? l : h, isLE2);
|
|
31
|
+
view.setUint32(byteOffset + 4, isLE2 ? h : l, isLE2);
|
|
32
|
+
}
|
|
33
|
+
var shrSH = (h, _l, s) => h >>> s;
|
|
34
|
+
var shrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
35
|
+
var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
|
|
36
|
+
var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
37
|
+
var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
|
|
38
|
+
var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
|
|
39
|
+
function add(Ah, Al, Bh, Bl) {
|
|
40
|
+
const l = (Al >>> 0) + (Bl >>> 0);
|
|
41
|
+
return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
|
|
42
|
+
}
|
|
43
|
+
var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
44
|
+
var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
45
|
+
var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
46
|
+
var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
47
|
+
var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
48
|
+
var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
49
|
+
|
|
50
|
+
// node_modules/@noble/hashes/utils.js
|
|
51
|
+
function isBytes(a) {
|
|
52
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
53
|
+
}
|
|
54
|
+
var atitle = (title) => title ? `"${title}" ` : "";
|
|
55
|
+
function anumber(n, title = "") {
|
|
56
|
+
if (typeof n !== "number")
|
|
57
|
+
throw new TypeError(atitle(title) + "expected number, got " + typeof n);
|
|
58
|
+
if (!Number.isSafeInteger(n) || n < 0)
|
|
59
|
+
throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
|
|
60
|
+
return n;
|
|
61
|
+
}
|
|
62
|
+
function abool(value, title = "") {
|
|
63
|
+
if (typeof value !== "boolean")
|
|
64
|
+
throw new TypeError(atitle(title) + "expected boolean, got type=" + typeof value);
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
function abytes(value, length, title = "") {
|
|
68
|
+
if (isBytes(value) && (length === void 0 || value.length === length))
|
|
69
|
+
return value;
|
|
70
|
+
if (length !== void 0)
|
|
71
|
+
anumber(length, "length");
|
|
72
|
+
const bytes = isBytes(value);
|
|
73
|
+
const ofLen = length !== void 0 ? ` of length ${length}` : "";
|
|
74
|
+
const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
|
|
75
|
+
const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
|
|
76
|
+
if (!bytes)
|
|
77
|
+
throw new TypeError(message);
|
|
78
|
+
throw new RangeError(message);
|
|
79
|
+
}
|
|
80
|
+
function ahash(h) {
|
|
81
|
+
if (typeof h !== "function" || typeof h.create !== "function")
|
|
82
|
+
throw new TypeError("expected hash wrapped by utils.createHasher");
|
|
83
|
+
anumber(h.outputLen);
|
|
84
|
+
anumber(h.blockLen);
|
|
85
|
+
if (h.outputLen < 1 || h.blockLen < 1)
|
|
86
|
+
throw new Error("hash blockLen / outputLen must be >= 1");
|
|
87
|
+
}
|
|
88
|
+
var aobject = (value, label) => {
|
|
89
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
90
|
+
throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
|
|
91
|
+
};
|
|
92
|
+
function aexists(instance, checkFinished = true) {
|
|
93
|
+
if (instance.destroyed)
|
|
94
|
+
throw new Error("hash was destroyed");
|
|
95
|
+
if (checkFinished && instance.finished)
|
|
96
|
+
throw new Error("digest() was already called");
|
|
97
|
+
}
|
|
98
|
+
function aoutput(out, instance) {
|
|
99
|
+
abytes(out, void 0, "output");
|
|
100
|
+
const min = instance.outputLen;
|
|
101
|
+
if (!(out.length >= min)) {
|
|
102
|
+
throw new RangeError('"output" expected length >= ' + min);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function u32(arr) {
|
|
106
|
+
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
107
|
+
}
|
|
108
|
+
function clean(...arrays) {
|
|
109
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
110
|
+
arrays[i].fill(0);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function createView(arr) {
|
|
114
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
115
|
+
}
|
|
116
|
+
function rotr(word, shift) {
|
|
117
|
+
return word << 32 - shift | word >>> shift;
|
|
118
|
+
}
|
|
119
|
+
var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
120
|
+
function byteSwap(word) {
|
|
121
|
+
return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
122
|
+
}
|
|
123
|
+
function byteSwap32(arr) {
|
|
124
|
+
for (let i = 0; i < arr.length; i++) {
|
|
125
|
+
arr[i] = byteSwap(arr[i]);
|
|
126
|
+
}
|
|
127
|
+
return arr;
|
|
128
|
+
}
|
|
129
|
+
var swap32IfBE = isLE ? (u) => u : byteSwap32;
|
|
130
|
+
function checkOpts(defaults, opts, title = "opts") {
|
|
131
|
+
aobject(defaults, "defaults");
|
|
132
|
+
if (opts !== void 0)
|
|
133
|
+
aobject(opts, title);
|
|
134
|
+
const merged = Object.assign(defaults, opts);
|
|
135
|
+
return merged;
|
|
136
|
+
}
|
|
137
|
+
function createHasher(hashCons, info = {}) {
|
|
138
|
+
if (typeof hashCons !== "function")
|
|
139
|
+
throw new TypeError('"hashCons" expected function, got type=' + typeof hashCons);
|
|
140
|
+
info = checkOpts({}, info, "info");
|
|
141
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
142
|
+
const tmp = hashCons(void 0);
|
|
143
|
+
hashC.outputLen = tmp.outputLen;
|
|
144
|
+
hashC.blockLen = tmp.blockLen;
|
|
145
|
+
hashC.canXOF = tmp.canXOF;
|
|
146
|
+
hashC.create = (opts) => hashCons(opts);
|
|
147
|
+
Object.assign(hashC, info);
|
|
148
|
+
return Object.freeze(hashC);
|
|
149
|
+
}
|
|
150
|
+
var oidNist = (suffix) => ({
|
|
151
|
+
// Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.
|
|
152
|
+
// Larger suffix values would need base-128 OID encoding and a different length byte.
|
|
153
|
+
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// node_modules/@noble/hashes/sha3.js
|
|
157
|
+
var _0n = BigInt(0);
|
|
158
|
+
var _1n = BigInt(1);
|
|
159
|
+
var _2n = BigInt(2);
|
|
160
|
+
var _7n = BigInt(7);
|
|
161
|
+
var _256n = BigInt(256);
|
|
162
|
+
var _0x71n = BigInt(113);
|
|
163
|
+
var SHA3_PI = [];
|
|
164
|
+
var SHA3_ROTL = [];
|
|
165
|
+
var _SHA3_IOTA = [];
|
|
166
|
+
for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
|
|
167
|
+
[x, y] = [y, (2 * x + 3 * y) % 5];
|
|
168
|
+
SHA3_PI.push(2 * (5 * y + x));
|
|
169
|
+
SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
|
|
170
|
+
let t = _0n;
|
|
171
|
+
for (let j = 0; j < 7; j++) {
|
|
172
|
+
R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
|
|
173
|
+
if (R & _2n)
|
|
174
|
+
t ^= _1n << (_1n << BigInt(j)) - _1n;
|
|
175
|
+
}
|
|
176
|
+
_SHA3_IOTA.push(t);
|
|
177
|
+
}
|
|
178
|
+
var IOTAS = split(_SHA3_IOTA, true);
|
|
179
|
+
var SHA3_IOTA_H = IOTAS[0];
|
|
180
|
+
var SHA3_IOTA_L = IOTAS[1];
|
|
181
|
+
var rotlSH = (h, l, s) => h << s | l >>> 32 - s;
|
|
182
|
+
var rotlSL = (h, l, s) => l << s | h >>> 32 - s;
|
|
183
|
+
var rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
|
|
184
|
+
var rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
|
|
185
|
+
var rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s);
|
|
186
|
+
var rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s);
|
|
187
|
+
var B = new Uint32Array(5 * 2);
|
|
188
|
+
function keccakP(s, rounds = 24) {
|
|
189
|
+
if (!(s instanceof Uint32Array))
|
|
190
|
+
throw new TypeError('"s" expected Uint32Array(50), got type=' + typeof s);
|
|
191
|
+
if (s.length !== 50)
|
|
192
|
+
throw new RangeError('"s" expected Uint32Array(50), got length=' + s.length);
|
|
193
|
+
anumber(rounds, "rounds");
|
|
194
|
+
if (rounds < 1 || rounds > 24)
|
|
195
|
+
throw new Error('"rounds" expected integer 1..24');
|
|
196
|
+
for (let round = 24 - rounds; round < 24; round++) {
|
|
197
|
+
for (let x = 0; x < 10; x++)
|
|
198
|
+
B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
|
|
199
|
+
for (let x = 0; x < 10; x += 2) {
|
|
200
|
+
const idx1 = (x + 8) % 10;
|
|
201
|
+
const idx0 = (x + 2) % 10;
|
|
202
|
+
const B0 = B[idx0];
|
|
203
|
+
const B1 = B[idx0 + 1];
|
|
204
|
+
const Th = rotlH(B0, B1, 1) ^ B[idx1];
|
|
205
|
+
const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
|
|
206
|
+
for (let y = 0; y < 50; y += 10) {
|
|
207
|
+
s[x + y] ^= Th;
|
|
208
|
+
s[x + y + 1] ^= Tl;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
let curH = s[2];
|
|
212
|
+
let curL = s[3];
|
|
213
|
+
for (let t = 0; t < 24; t++) {
|
|
214
|
+
const shift = SHA3_ROTL[t];
|
|
215
|
+
const Th = rotlH(curH, curL, shift);
|
|
216
|
+
const Tl = rotlL(curH, curL, shift);
|
|
217
|
+
const PI = SHA3_PI[t];
|
|
218
|
+
curH = s[PI];
|
|
219
|
+
curL = s[PI + 1];
|
|
220
|
+
s[PI] = Th;
|
|
221
|
+
s[PI + 1] = Tl;
|
|
222
|
+
}
|
|
223
|
+
for (let y = 0; y < 50; y += 10) {
|
|
224
|
+
const b0 = s[y], b1 = s[y + 1], b2 = s[y + 2], b3 = s[y + 3];
|
|
225
|
+
s[y] ^= ~s[y + 2] & s[y + 4];
|
|
226
|
+
s[y + 1] ^= ~s[y + 3] & s[y + 5];
|
|
227
|
+
s[y + 2] ^= ~s[y + 4] & s[y + 6];
|
|
228
|
+
s[y + 3] ^= ~s[y + 5] & s[y + 7];
|
|
229
|
+
s[y + 4] ^= ~s[y + 6] & s[y + 8];
|
|
230
|
+
s[y + 5] ^= ~s[y + 7] & s[y + 9];
|
|
231
|
+
s[y + 6] ^= ~s[y + 8] & b0;
|
|
232
|
+
s[y + 7] ^= ~s[y + 9] & b1;
|
|
233
|
+
s[y + 8] ^= ~b0 & b2;
|
|
234
|
+
s[y + 9] ^= ~b1 & b3;
|
|
235
|
+
}
|
|
236
|
+
s[0] ^= SHA3_IOTA_H[round];
|
|
237
|
+
s[1] ^= SHA3_IOTA_L[round];
|
|
238
|
+
}
|
|
239
|
+
clean(B);
|
|
240
|
+
}
|
|
241
|
+
var Keccak = class _Keccak {
|
|
242
|
+
state;
|
|
243
|
+
pos = 0;
|
|
244
|
+
posOut = 0;
|
|
245
|
+
finished = false;
|
|
246
|
+
state32;
|
|
247
|
+
destroyed = false;
|
|
248
|
+
blockLen;
|
|
249
|
+
suffix;
|
|
250
|
+
outputLen;
|
|
251
|
+
canXOF;
|
|
252
|
+
enableXOF = false;
|
|
253
|
+
rounds;
|
|
254
|
+
// NOTE: we accept arguments in bytes instead of bits here.
|
|
255
|
+
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
256
|
+
anumber(blockLen, "blockLen");
|
|
257
|
+
anumber(suffix, "suffix");
|
|
258
|
+
anumber(rounds, "rounds");
|
|
259
|
+
abool(enableXOF, "enableXOF");
|
|
260
|
+
this.blockLen = blockLen;
|
|
261
|
+
this.suffix = suffix;
|
|
262
|
+
this.outputLen = outputLen;
|
|
263
|
+
this.enableXOF = enableXOF;
|
|
264
|
+
this.canXOF = enableXOF;
|
|
265
|
+
this.rounds = rounds;
|
|
266
|
+
anumber(outputLen, "outputLen");
|
|
267
|
+
if (!(0 < blockLen && blockLen < 200))
|
|
268
|
+
throw new Error('"blockLen" must be 1..199');
|
|
269
|
+
this.state = new Uint8Array(200);
|
|
270
|
+
this.state32 = u32(this.state);
|
|
271
|
+
}
|
|
272
|
+
clone() {
|
|
273
|
+
return this._cloneInto();
|
|
274
|
+
}
|
|
275
|
+
keccak() {
|
|
276
|
+
swap32IfBE(this.state32);
|
|
277
|
+
keccakP(this.state32, this.rounds);
|
|
278
|
+
swap32IfBE(this.state32);
|
|
279
|
+
this.posOut = 0;
|
|
280
|
+
this.pos = 0;
|
|
281
|
+
}
|
|
282
|
+
update(data) {
|
|
283
|
+
aexists(this);
|
|
284
|
+
abytes(data);
|
|
285
|
+
const { blockLen, state, state32 } = this;
|
|
286
|
+
const len = data.length;
|
|
287
|
+
const canUseU32 = blockLen % 4 === 0 && data.byteOffset % 4 === 0;
|
|
288
|
+
const blockLen32 = blockLen / 4;
|
|
289
|
+
const data32 = canUseU32 && len >= blockLen ? u32(data) : void 0;
|
|
290
|
+
for (let pos = 0; pos < len; ) {
|
|
291
|
+
if (data32 !== void 0 && this.pos === 0 && pos % 4 === 0 && len - pos >= blockLen) {
|
|
292
|
+
for (let i = 0, o = pos / 4; i < blockLen32; i++)
|
|
293
|
+
state32[i] ^= data32[o + i];
|
|
294
|
+
pos += blockLen;
|
|
295
|
+
this.pos = blockLen;
|
|
296
|
+
this.keccak();
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
300
|
+
for (let i = 0; i < take; i++)
|
|
301
|
+
state[this.pos++] ^= data[pos++];
|
|
302
|
+
if (this.pos === blockLen)
|
|
303
|
+
this.keccak();
|
|
304
|
+
}
|
|
305
|
+
return this;
|
|
306
|
+
}
|
|
307
|
+
finish() {
|
|
308
|
+
if (this.finished)
|
|
309
|
+
return;
|
|
310
|
+
this.finished = true;
|
|
311
|
+
const { state, suffix, pos, blockLen } = this;
|
|
312
|
+
state[pos] ^= suffix;
|
|
313
|
+
if ((suffix & 128) !== 0 && pos === blockLen - 1)
|
|
314
|
+
this.keccak();
|
|
315
|
+
state[blockLen - 1] ^= 128;
|
|
316
|
+
this.keccak();
|
|
317
|
+
}
|
|
318
|
+
writeInto(out) {
|
|
319
|
+
aexists(this, false);
|
|
320
|
+
abytes(out);
|
|
321
|
+
this.finish();
|
|
322
|
+
const bufferOut = this.state;
|
|
323
|
+
const { blockLen } = this;
|
|
324
|
+
for (let pos = 0, len = out.length; pos < len; ) {
|
|
325
|
+
if (this.posOut >= blockLen)
|
|
326
|
+
this.keccak();
|
|
327
|
+
const take = Math.min(blockLen - this.posOut, len - pos);
|
|
328
|
+
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
|
|
329
|
+
this.posOut += take;
|
|
330
|
+
pos += take;
|
|
331
|
+
}
|
|
332
|
+
return out;
|
|
333
|
+
}
|
|
334
|
+
xofInto(out) {
|
|
335
|
+
if (!this.enableXOF)
|
|
336
|
+
throw new Error("XOF is not enabled");
|
|
337
|
+
return this.writeInto(out);
|
|
338
|
+
}
|
|
339
|
+
xof(bytes) {
|
|
340
|
+
anumber(bytes);
|
|
341
|
+
return this.xofInto(new Uint8Array(bytes));
|
|
342
|
+
}
|
|
343
|
+
digestInto(out) {
|
|
344
|
+
aoutput(out, this);
|
|
345
|
+
if (this.finished)
|
|
346
|
+
throw new Error("digest() was already called");
|
|
347
|
+
this.writeInto(out.length === this.outputLen ? out : out.subarray(0, this.outputLen));
|
|
348
|
+
this.destroy();
|
|
349
|
+
}
|
|
350
|
+
digest() {
|
|
351
|
+
const out = new Uint8Array(this.outputLen);
|
|
352
|
+
this.digestInto(out);
|
|
353
|
+
return out;
|
|
354
|
+
}
|
|
355
|
+
destroy() {
|
|
356
|
+
this.destroyed = true;
|
|
357
|
+
clean(this.state);
|
|
358
|
+
}
|
|
359
|
+
_cloneInto(to) {
|
|
360
|
+
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
361
|
+
to ||= new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds);
|
|
362
|
+
to.blockLen = blockLen;
|
|
363
|
+
to.state32.set(this.state32);
|
|
364
|
+
to.pos = this.pos;
|
|
365
|
+
to.posOut = this.posOut;
|
|
366
|
+
to.finished = this.finished;
|
|
367
|
+
to.rounds = rounds;
|
|
368
|
+
to.suffix = suffix;
|
|
369
|
+
to.outputLen = outputLen;
|
|
370
|
+
to.enableXOF = enableXOF;
|
|
371
|
+
to.canXOF = this.canXOF;
|
|
372
|
+
to.destroyed = this.destroyed;
|
|
373
|
+
return to;
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
var genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher(() => new Keccak(blockLen, suffix, outputLen), info);
|
|
377
|
+
var sha3_256 = /* @__PURE__ */ genKeccak(
|
|
378
|
+
6,
|
|
379
|
+
136,
|
|
380
|
+
32,
|
|
381
|
+
/* @__PURE__ */ oidNist(8)
|
|
382
|
+
);
|
|
383
|
+
var sha3_512 = /* @__PURE__ */ genKeccak(
|
|
384
|
+
6,
|
|
385
|
+
72,
|
|
386
|
+
64,
|
|
387
|
+
/* @__PURE__ */ oidNist(10)
|
|
388
|
+
);
|
|
389
|
+
var genShake = (suffix, blockLen, outputLen, info = {}) => createHasher((opts = {}) => {
|
|
390
|
+
opts = checkOpts({}, opts);
|
|
391
|
+
return new Keccak(blockLen, suffix, opts.dkLen === void 0 ? outputLen : opts.dkLen, true);
|
|
392
|
+
}, info);
|
|
393
|
+
var shake128 = /* @__PURE__ */ genShake(31, 168, 16, /* @__PURE__ */ oidNist(11));
|
|
394
|
+
var shake256 = /* @__PURE__ */ genShake(31, 136, 32, /* @__PURE__ */ oidNist(12));
|
|
395
|
+
|
|
396
|
+
// node_modules/@noble/hashes/_md.js
|
|
397
|
+
function Chi(a, b, c) {
|
|
398
|
+
return a & b ^ ~a & c;
|
|
399
|
+
}
|
|
400
|
+
function Maj(a, b, c) {
|
|
401
|
+
return a & b ^ a & c ^ b & c;
|
|
402
|
+
}
|
|
403
|
+
var HashMD = class {
|
|
404
|
+
blockLen;
|
|
405
|
+
outputLen;
|
|
406
|
+
canXOF = false;
|
|
407
|
+
padOffset;
|
|
408
|
+
isLE;
|
|
409
|
+
// For partial updates less than block size
|
|
410
|
+
buffer;
|
|
411
|
+
view;
|
|
412
|
+
finished = false;
|
|
413
|
+
length = 0;
|
|
414
|
+
pos = 0;
|
|
415
|
+
destroyed = false;
|
|
416
|
+
constructor(blockLen, outputLen, padOffset, isLE2) {
|
|
417
|
+
this.blockLen = blockLen;
|
|
418
|
+
this.outputLen = outputLen;
|
|
419
|
+
this.padOffset = padOffset;
|
|
420
|
+
this.isLE = isLE2;
|
|
421
|
+
this.buffer = new Uint8Array(blockLen);
|
|
422
|
+
this.view = createView(this.buffer);
|
|
423
|
+
}
|
|
424
|
+
update(data) {
|
|
425
|
+
aexists(this);
|
|
426
|
+
abytes(data);
|
|
427
|
+
const { view, buffer, blockLen } = this;
|
|
428
|
+
const len = data.length;
|
|
429
|
+
let processed = false;
|
|
430
|
+
for (let pos = 0; pos < len; ) {
|
|
431
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
432
|
+
if (take === blockLen) {
|
|
433
|
+
const dataView = createView(data);
|
|
434
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
435
|
+
this.process(dataView, pos);
|
|
436
|
+
processed = true;
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);
|
|
440
|
+
this.pos += take;
|
|
441
|
+
pos += take;
|
|
442
|
+
if (this.pos === blockLen) {
|
|
443
|
+
this.process(view, 0);
|
|
444
|
+
this.pos = 0;
|
|
445
|
+
processed = true;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
this.length += data.length;
|
|
449
|
+
if (processed)
|
|
450
|
+
this.roundClean();
|
|
451
|
+
return this;
|
|
452
|
+
}
|
|
453
|
+
digestInto(out) {
|
|
454
|
+
aexists(this);
|
|
455
|
+
aoutput(out, this);
|
|
456
|
+
this.finished = true;
|
|
457
|
+
const { buffer, view, blockLen, isLE: isLE2 } = this;
|
|
458
|
+
let { pos } = this;
|
|
459
|
+
buffer[pos++] = 128;
|
|
460
|
+
buffer.fill(0, pos);
|
|
461
|
+
if (this.padOffset > blockLen - pos) {
|
|
462
|
+
this.process(view, 0);
|
|
463
|
+
buffer.fill(0);
|
|
464
|
+
}
|
|
465
|
+
setU64FromNum(view, blockLen - 8, this.length * 8, isLE2);
|
|
466
|
+
this.process(view, 0);
|
|
467
|
+
this.roundClean();
|
|
468
|
+
const oview = out === buffer ? view : createView(out);
|
|
469
|
+
const len = this.outputLen;
|
|
470
|
+
const outLen = len / 4;
|
|
471
|
+
const state = this.get();
|
|
472
|
+
if (len % 4 || outLen > state.length)
|
|
473
|
+
throw new Error("invalid outputLen");
|
|
474
|
+
for (let i = 0; i < outLen; i++)
|
|
475
|
+
oview.setUint32(4 * i, state[i], isLE2);
|
|
476
|
+
}
|
|
477
|
+
digest() {
|
|
478
|
+
const { buffer, outputLen } = this;
|
|
479
|
+
this.digestInto(buffer);
|
|
480
|
+
const res = buffer.slice(0, outputLen);
|
|
481
|
+
this.destroy();
|
|
482
|
+
return res;
|
|
483
|
+
}
|
|
484
|
+
_cloneIntoMeta(to) {
|
|
485
|
+
const { buffer, length, finished, destroyed, pos } = this;
|
|
486
|
+
to.destroyed = destroyed;
|
|
487
|
+
to.finished = finished;
|
|
488
|
+
to.length = length;
|
|
489
|
+
to.pos = pos;
|
|
490
|
+
if (pos)
|
|
491
|
+
to.buffer.set(buffer);
|
|
492
|
+
return to;
|
|
493
|
+
}
|
|
494
|
+
clone() {
|
|
495
|
+
return this._cloneInto();
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
499
|
+
1779033703,
|
|
500
|
+
3144134277,
|
|
501
|
+
1013904242,
|
|
502
|
+
2773480762,
|
|
503
|
+
1359893119,
|
|
504
|
+
2600822924,
|
|
505
|
+
528734635,
|
|
506
|
+
1541459225
|
|
507
|
+
]);
|
|
508
|
+
var SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
509
|
+
1779033703,
|
|
510
|
+
4089235720,
|
|
511
|
+
3144134277,
|
|
512
|
+
2227873595,
|
|
513
|
+
1013904242,
|
|
514
|
+
4271175723,
|
|
515
|
+
2773480762,
|
|
516
|
+
1595750129,
|
|
517
|
+
1359893119,
|
|
518
|
+
2917565137,
|
|
519
|
+
2600822924,
|
|
520
|
+
725511199,
|
|
521
|
+
528734635,
|
|
522
|
+
4215389547,
|
|
523
|
+
1541459225,
|
|
524
|
+
327033209
|
|
525
|
+
]);
|
|
526
|
+
|
|
527
|
+
// node_modules/@noble/hashes/sha2.js
|
|
528
|
+
var SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
529
|
+
1116352408,
|
|
530
|
+
1899447441,
|
|
531
|
+
3049323471,
|
|
532
|
+
3921009573,
|
|
533
|
+
961987163,
|
|
534
|
+
1508970993,
|
|
535
|
+
2453635748,
|
|
536
|
+
2870763221,
|
|
537
|
+
3624381080,
|
|
538
|
+
310598401,
|
|
539
|
+
607225278,
|
|
540
|
+
1426881987,
|
|
541
|
+
1925078388,
|
|
542
|
+
2162078206,
|
|
543
|
+
2614888103,
|
|
544
|
+
3248222580,
|
|
545
|
+
3835390401,
|
|
546
|
+
4022224774,
|
|
547
|
+
264347078,
|
|
548
|
+
604807628,
|
|
549
|
+
770255983,
|
|
550
|
+
1249150122,
|
|
551
|
+
1555081692,
|
|
552
|
+
1996064986,
|
|
553
|
+
2554220882,
|
|
554
|
+
2821834349,
|
|
555
|
+
2952996808,
|
|
556
|
+
3210313671,
|
|
557
|
+
3336571891,
|
|
558
|
+
3584528711,
|
|
559
|
+
113926993,
|
|
560
|
+
338241895,
|
|
561
|
+
666307205,
|
|
562
|
+
773529912,
|
|
563
|
+
1294757372,
|
|
564
|
+
1396182291,
|
|
565
|
+
1695183700,
|
|
566
|
+
1986661051,
|
|
567
|
+
2177026350,
|
|
568
|
+
2456956037,
|
|
569
|
+
2730485921,
|
|
570
|
+
2820302411,
|
|
571
|
+
3259730800,
|
|
572
|
+
3345764771,
|
|
573
|
+
3516065817,
|
|
574
|
+
3600352804,
|
|
575
|
+
4094571909,
|
|
576
|
+
275423344,
|
|
577
|
+
430227734,
|
|
578
|
+
506948616,
|
|
579
|
+
659060556,
|
|
580
|
+
883997877,
|
|
581
|
+
958139571,
|
|
582
|
+
1322822218,
|
|
583
|
+
1537002063,
|
|
584
|
+
1747873779,
|
|
585
|
+
1955562222,
|
|
586
|
+
2024104815,
|
|
587
|
+
2227730452,
|
|
588
|
+
2361852424,
|
|
589
|
+
2428436474,
|
|
590
|
+
2756734187,
|
|
591
|
+
3204031479,
|
|
592
|
+
3329325298
|
|
593
|
+
]);
|
|
594
|
+
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
595
|
+
var SHA2_32B = class extends HashMD {
|
|
596
|
+
// We cannot use array here since array allows indexing by variable
|
|
597
|
+
// which means optimizer/compiler cannot use registers.
|
|
598
|
+
// Numeric initializers matter: starting the fields as `undefined` changes
|
|
599
|
+
// V8's field representation and makes sha256 3x slower (measured).
|
|
600
|
+
A = 0;
|
|
601
|
+
B = 0;
|
|
602
|
+
C = 0;
|
|
603
|
+
D = 0;
|
|
604
|
+
E = 0;
|
|
605
|
+
F = 0;
|
|
606
|
+
G = 0;
|
|
607
|
+
H = 0;
|
|
608
|
+
constructor(outputLen, IV) {
|
|
609
|
+
super(64, outputLen, 8, false);
|
|
610
|
+
this.A = IV[0] | 0;
|
|
611
|
+
this.B = IV[1] | 0;
|
|
612
|
+
this.C = IV[2] | 0;
|
|
613
|
+
this.D = IV[3] | 0;
|
|
614
|
+
this.E = IV[4] | 0;
|
|
615
|
+
this.F = IV[5] | 0;
|
|
616
|
+
this.G = IV[6] | 0;
|
|
617
|
+
this.H = IV[7] | 0;
|
|
618
|
+
}
|
|
619
|
+
get() {
|
|
620
|
+
const { A, B: B2, C, D, E, F, G, H } = this;
|
|
621
|
+
return [A, B2, C, D, E, F, G, H];
|
|
622
|
+
}
|
|
623
|
+
// prettier-ignore
|
|
624
|
+
set(A, B2, C, D, E, F, G, H) {
|
|
625
|
+
this.A = A | 0;
|
|
626
|
+
this.B = B2 | 0;
|
|
627
|
+
this.C = C | 0;
|
|
628
|
+
this.D = D | 0;
|
|
629
|
+
this.E = E | 0;
|
|
630
|
+
this.F = F | 0;
|
|
631
|
+
this.G = G | 0;
|
|
632
|
+
this.H = H | 0;
|
|
633
|
+
}
|
|
634
|
+
_cloneInto(to) {
|
|
635
|
+
(to ||= new this.constructor()).set(...this.get());
|
|
636
|
+
return this._cloneIntoMeta(to);
|
|
637
|
+
}
|
|
638
|
+
process(view, offset) {
|
|
639
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
640
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
641
|
+
for (let i = 16; i < 64; i++) {
|
|
642
|
+
const W15 = SHA256_W[i - 15];
|
|
643
|
+
const W2 = SHA256_W[i - 2];
|
|
644
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
645
|
+
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
|
646
|
+
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
647
|
+
}
|
|
648
|
+
let { A, B: B2, C, D, E, F, G, H } = this;
|
|
649
|
+
for (let i = 0; i < 64; i++) {
|
|
650
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
651
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
652
|
+
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
653
|
+
const T2 = sigma0 + Maj(A, B2, C) | 0;
|
|
654
|
+
H = G;
|
|
655
|
+
G = F;
|
|
656
|
+
F = E;
|
|
657
|
+
E = D + T1 | 0;
|
|
658
|
+
D = C;
|
|
659
|
+
C = B2;
|
|
660
|
+
B2 = A;
|
|
661
|
+
A = T1 + T2 | 0;
|
|
662
|
+
}
|
|
663
|
+
A = A + this.A | 0;
|
|
664
|
+
B2 = B2 + this.B | 0;
|
|
665
|
+
C = C + this.C | 0;
|
|
666
|
+
D = D + this.D | 0;
|
|
667
|
+
E = E + this.E | 0;
|
|
668
|
+
F = F + this.F | 0;
|
|
669
|
+
G = G + this.G | 0;
|
|
670
|
+
H = H + this.H | 0;
|
|
671
|
+
this.set(A, B2, C, D, E, F, G, H);
|
|
672
|
+
}
|
|
673
|
+
roundClean() {
|
|
674
|
+
clean(SHA256_W);
|
|
675
|
+
}
|
|
676
|
+
destroy() {
|
|
677
|
+
this.destroyed = true;
|
|
678
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
679
|
+
clean(this.buffer);
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
var _SHA256 = class extends SHA2_32B {
|
|
683
|
+
constructor() {
|
|
684
|
+
super(32, SHA256_IV);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
var K512 = /* @__PURE__ */ (() => split([
|
|
688
|
+
"0x428a2f98d728ae22",
|
|
689
|
+
"0x7137449123ef65cd",
|
|
690
|
+
"0xb5c0fbcfec4d3b2f",
|
|
691
|
+
"0xe9b5dba58189dbbc",
|
|
692
|
+
"0x3956c25bf348b538",
|
|
693
|
+
"0x59f111f1b605d019",
|
|
694
|
+
"0x923f82a4af194f9b",
|
|
695
|
+
"0xab1c5ed5da6d8118",
|
|
696
|
+
"0xd807aa98a3030242",
|
|
697
|
+
"0x12835b0145706fbe",
|
|
698
|
+
"0x243185be4ee4b28c",
|
|
699
|
+
"0x550c7dc3d5ffb4e2",
|
|
700
|
+
"0x72be5d74f27b896f",
|
|
701
|
+
"0x80deb1fe3b1696b1",
|
|
702
|
+
"0x9bdc06a725c71235",
|
|
703
|
+
"0xc19bf174cf692694",
|
|
704
|
+
"0xe49b69c19ef14ad2",
|
|
705
|
+
"0xefbe4786384f25e3",
|
|
706
|
+
"0x0fc19dc68b8cd5b5",
|
|
707
|
+
"0x240ca1cc77ac9c65",
|
|
708
|
+
"0x2de92c6f592b0275",
|
|
709
|
+
"0x4a7484aa6ea6e483",
|
|
710
|
+
"0x5cb0a9dcbd41fbd4",
|
|
711
|
+
"0x76f988da831153b5",
|
|
712
|
+
"0x983e5152ee66dfab",
|
|
713
|
+
"0xa831c66d2db43210",
|
|
714
|
+
"0xb00327c898fb213f",
|
|
715
|
+
"0xbf597fc7beef0ee4",
|
|
716
|
+
"0xc6e00bf33da88fc2",
|
|
717
|
+
"0xd5a79147930aa725",
|
|
718
|
+
"0x06ca6351e003826f",
|
|
719
|
+
"0x142929670a0e6e70",
|
|
720
|
+
"0x27b70a8546d22ffc",
|
|
721
|
+
"0x2e1b21385c26c926",
|
|
722
|
+
"0x4d2c6dfc5ac42aed",
|
|
723
|
+
"0x53380d139d95b3df",
|
|
724
|
+
"0x650a73548baf63de",
|
|
725
|
+
"0x766a0abb3c77b2a8",
|
|
726
|
+
"0x81c2c92e47edaee6",
|
|
727
|
+
"0x92722c851482353b",
|
|
728
|
+
"0xa2bfe8a14cf10364",
|
|
729
|
+
"0xa81a664bbc423001",
|
|
730
|
+
"0xc24b8b70d0f89791",
|
|
731
|
+
"0xc76c51a30654be30",
|
|
732
|
+
"0xd192e819d6ef5218",
|
|
733
|
+
"0xd69906245565a910",
|
|
734
|
+
"0xf40e35855771202a",
|
|
735
|
+
"0x106aa07032bbd1b8",
|
|
736
|
+
"0x19a4c116b8d2d0c8",
|
|
737
|
+
"0x1e376c085141ab53",
|
|
738
|
+
"0x2748774cdf8eeb99",
|
|
739
|
+
"0x34b0bcb5e19b48a8",
|
|
740
|
+
"0x391c0cb3c5c95a63",
|
|
741
|
+
"0x4ed8aa4ae3418acb",
|
|
742
|
+
"0x5b9cca4f7763e373",
|
|
743
|
+
"0x682e6ff3d6b2b8a3",
|
|
744
|
+
"0x748f82ee5defb2fc",
|
|
745
|
+
"0x78a5636f43172f60",
|
|
746
|
+
"0x84c87814a1f0ab72",
|
|
747
|
+
"0x8cc702081a6439ec",
|
|
748
|
+
"0x90befffa23631e28",
|
|
749
|
+
"0xa4506cebde82bde9",
|
|
750
|
+
"0xbef9a3f7b2c67915",
|
|
751
|
+
"0xc67178f2e372532b",
|
|
752
|
+
"0xca273eceea26619c",
|
|
753
|
+
"0xd186b8c721c0c207",
|
|
754
|
+
"0xeada7dd6cde0eb1e",
|
|
755
|
+
"0xf57d4f7fee6ed178",
|
|
756
|
+
"0x06f067aa72176fba",
|
|
757
|
+
"0x0a637dc5a2c898a6",
|
|
758
|
+
"0x113f9804bef90dae",
|
|
759
|
+
"0x1b710b35131c471b",
|
|
760
|
+
"0x28db77f523047d84",
|
|
761
|
+
"0x32caab7b40c72493",
|
|
762
|
+
"0x3c9ebe0a15c9bebc",
|
|
763
|
+
"0x431d67c49c100d4c",
|
|
764
|
+
"0x4cc5d4becb3e42b6",
|
|
765
|
+
"0x597f299cfc657e2a",
|
|
766
|
+
"0x5fcb6fab3ad6faec",
|
|
767
|
+
"0x6c44198c4a475817"
|
|
768
|
+
].map((n) => BigInt(n))))();
|
|
769
|
+
var SHA512_Kh = /* @__PURE__ */ (() => K512[0])();
|
|
770
|
+
var SHA512_Kl = /* @__PURE__ */ (() => K512[1])();
|
|
771
|
+
var SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
772
|
+
var SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
773
|
+
var SHA2_64B = class extends HashMD {
|
|
774
|
+
// We cannot use array here since array allows indexing by variable
|
|
775
|
+
// which means optimizer/compiler cannot use registers.
|
|
776
|
+
// h -- high 32 bits, l -- low 32 bits
|
|
777
|
+
// Numeric initializers matter: starting the fields as `undefined` changes
|
|
778
|
+
// V8's field representation and slows hashing down (measured on sha256).
|
|
779
|
+
Ah = 0;
|
|
780
|
+
Al = 0;
|
|
781
|
+
Bh = 0;
|
|
782
|
+
Bl = 0;
|
|
783
|
+
Ch = 0;
|
|
784
|
+
Cl = 0;
|
|
785
|
+
Dh = 0;
|
|
786
|
+
Dl = 0;
|
|
787
|
+
Eh = 0;
|
|
788
|
+
El = 0;
|
|
789
|
+
Fh = 0;
|
|
790
|
+
Fl = 0;
|
|
791
|
+
Gh = 0;
|
|
792
|
+
Gl = 0;
|
|
793
|
+
Hh = 0;
|
|
794
|
+
Hl = 0;
|
|
795
|
+
constructor(outputLen, IV) {
|
|
796
|
+
super(128, outputLen, 16, false);
|
|
797
|
+
this.Ah = IV[0] | 0;
|
|
798
|
+
this.Al = IV[1] | 0;
|
|
799
|
+
this.Bh = IV[2] | 0;
|
|
800
|
+
this.Bl = IV[3] | 0;
|
|
801
|
+
this.Ch = IV[4] | 0;
|
|
802
|
+
this.Cl = IV[5] | 0;
|
|
803
|
+
this.Dh = IV[6] | 0;
|
|
804
|
+
this.Dl = IV[7] | 0;
|
|
805
|
+
this.Eh = IV[8] | 0;
|
|
806
|
+
this.El = IV[9] | 0;
|
|
807
|
+
this.Fh = IV[10] | 0;
|
|
808
|
+
this.Fl = IV[11] | 0;
|
|
809
|
+
this.Gh = IV[12] | 0;
|
|
810
|
+
this.Gl = IV[13] | 0;
|
|
811
|
+
this.Hh = IV[14] | 0;
|
|
812
|
+
this.Hl = IV[15] | 0;
|
|
813
|
+
}
|
|
814
|
+
// prettier-ignore
|
|
815
|
+
get() {
|
|
816
|
+
const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
817
|
+
return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];
|
|
818
|
+
}
|
|
819
|
+
// prettier-ignore
|
|
820
|
+
set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
|
|
821
|
+
this.Ah = Ah | 0;
|
|
822
|
+
this.Al = Al | 0;
|
|
823
|
+
this.Bh = Bh | 0;
|
|
824
|
+
this.Bl = Bl | 0;
|
|
825
|
+
this.Ch = Ch | 0;
|
|
826
|
+
this.Cl = Cl | 0;
|
|
827
|
+
this.Dh = Dh | 0;
|
|
828
|
+
this.Dl = Dl | 0;
|
|
829
|
+
this.Eh = Eh | 0;
|
|
830
|
+
this.El = El | 0;
|
|
831
|
+
this.Fh = Fh | 0;
|
|
832
|
+
this.Fl = Fl | 0;
|
|
833
|
+
this.Gh = Gh | 0;
|
|
834
|
+
this.Gl = Gl | 0;
|
|
835
|
+
this.Hh = Hh | 0;
|
|
836
|
+
this.Hl = Hl | 0;
|
|
837
|
+
}
|
|
838
|
+
_cloneInto(to) {
|
|
839
|
+
(to ||= new this.constructor()).set(...this.get());
|
|
840
|
+
return this._cloneIntoMeta(to);
|
|
841
|
+
}
|
|
842
|
+
process(view, offset) {
|
|
843
|
+
for (let i = 0; i < 16; i++, offset += 4) {
|
|
844
|
+
SHA512_W_H[i] = view.getUint32(offset);
|
|
845
|
+
SHA512_W_L[i] = view.getUint32(offset += 4);
|
|
846
|
+
}
|
|
847
|
+
for (let i = 16; i < 80; i++) {
|
|
848
|
+
const W15h = SHA512_W_H[i - 15] | 0;
|
|
849
|
+
const W15l = SHA512_W_L[i - 15] | 0;
|
|
850
|
+
const s0h = rotrSH(W15h, W15l, 1) ^ rotrSH(W15h, W15l, 8) ^ shrSH(W15h, W15l, 7);
|
|
851
|
+
const s0l = rotrSL(W15h, W15l, 1) ^ rotrSL(W15h, W15l, 8) ^ shrSL(W15h, W15l, 7);
|
|
852
|
+
const W2h = SHA512_W_H[i - 2] | 0;
|
|
853
|
+
const W2l = SHA512_W_L[i - 2] | 0;
|
|
854
|
+
const s1h = rotrSH(W2h, W2l, 19) ^ rotrBH(W2h, W2l, 61) ^ shrSH(W2h, W2l, 6);
|
|
855
|
+
const s1l = rotrSL(W2h, W2l, 19) ^ rotrBL(W2h, W2l, 61) ^ shrSL(W2h, W2l, 6);
|
|
856
|
+
const SUMl = add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
|
857
|
+
const SUMh = add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
|
|
858
|
+
SHA512_W_H[i] = SUMh | 0;
|
|
859
|
+
SHA512_W_L[i] = SUMl | 0;
|
|
860
|
+
}
|
|
861
|
+
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
862
|
+
for (let i = 0; i < 80; i++) {
|
|
863
|
+
const sigma1h = rotrSH(Eh, El, 14) ^ rotrSH(Eh, El, 18) ^ rotrBH(Eh, El, 41);
|
|
864
|
+
const sigma1l = rotrSL(Eh, El, 14) ^ rotrSL(Eh, El, 18) ^ rotrBL(Eh, El, 41);
|
|
865
|
+
const CHIh = Eh & Fh ^ ~Eh & Gh;
|
|
866
|
+
const CHIl = El & Fl ^ ~El & Gl;
|
|
867
|
+
const T1ll = add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
|
868
|
+
const T1h = add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
|
869
|
+
const T1l = T1ll | 0;
|
|
870
|
+
const sigma0h = rotrSH(Ah, Al, 28) ^ rotrBH(Ah, Al, 34) ^ rotrBH(Ah, Al, 39);
|
|
871
|
+
const sigma0l = rotrSL(Ah, Al, 28) ^ rotrBL(Ah, Al, 34) ^ rotrBL(Ah, Al, 39);
|
|
872
|
+
const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
|
|
873
|
+
const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
|
|
874
|
+
Hh = Gh | 0;
|
|
875
|
+
Hl = Gl | 0;
|
|
876
|
+
Gh = Fh | 0;
|
|
877
|
+
Gl = Fl | 0;
|
|
878
|
+
Fh = Eh | 0;
|
|
879
|
+
Fl = El | 0;
|
|
880
|
+
({ h: Eh, l: El } = add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
881
|
+
Dh = Ch | 0;
|
|
882
|
+
Dl = Cl | 0;
|
|
883
|
+
Ch = Bh | 0;
|
|
884
|
+
Cl = Bl | 0;
|
|
885
|
+
Bh = Ah | 0;
|
|
886
|
+
Bl = Al | 0;
|
|
887
|
+
const All = add3L(T1l, sigma0l, MAJl);
|
|
888
|
+
Ah = add3H(All, T1h, sigma0h, MAJh);
|
|
889
|
+
Al = All | 0;
|
|
890
|
+
}
|
|
891
|
+
({ h: Ah, l: Al } = add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
892
|
+
({ h: Bh, l: Bl } = add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
893
|
+
({ h: Ch, l: Cl } = add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
894
|
+
({ h: Dh, l: Dl } = add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
895
|
+
({ h: Eh, l: El } = add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
896
|
+
({ h: Fh, l: Fl } = add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
897
|
+
({ h: Gh, l: Gl } = add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
898
|
+
({ h: Hh, l: Hl } = add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
899
|
+
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
900
|
+
}
|
|
901
|
+
roundClean() {
|
|
902
|
+
clean(SHA512_W_H, SHA512_W_L);
|
|
903
|
+
}
|
|
904
|
+
destroy() {
|
|
905
|
+
this.destroyed = true;
|
|
906
|
+
clean(this.buffer);
|
|
907
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
var _SHA512 = class extends SHA2_64B {
|
|
911
|
+
constructor() {
|
|
912
|
+
super(64, SHA512_IV);
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
var sha256 = /* @__PURE__ */ createHasher(
|
|
916
|
+
() => new _SHA256(),
|
|
917
|
+
/* @__PURE__ */ oidNist(1)
|
|
918
|
+
);
|
|
919
|
+
var sha512 = /* @__PURE__ */ createHasher(
|
|
920
|
+
() => new _SHA512(),
|
|
921
|
+
/* @__PURE__ */ oidNist(3)
|
|
922
|
+
);
|
|
923
|
+
|
|
924
|
+
// node_modules/@noble/hashes/hmac.js
|
|
925
|
+
var _HMAC = class {
|
|
926
|
+
oHash;
|
|
927
|
+
iHash;
|
|
928
|
+
blockLen;
|
|
929
|
+
outputLen;
|
|
930
|
+
canXOF = false;
|
|
931
|
+
finished = false;
|
|
932
|
+
destroyed = false;
|
|
933
|
+
constructor(hash, key) {
|
|
934
|
+
ahash(hash);
|
|
935
|
+
abytes(key, void 0, "key");
|
|
936
|
+
this.iHash = hash.create();
|
|
937
|
+
if (typeof this.iHash.update !== "function")
|
|
938
|
+
throw new Error("expected Hash instance");
|
|
939
|
+
this.blockLen = this.iHash.blockLen;
|
|
940
|
+
this.outputLen = this.iHash.outputLen;
|
|
941
|
+
const blockLen = this.blockLen;
|
|
942
|
+
const pad = new Uint8Array(blockLen);
|
|
943
|
+
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
|
|
944
|
+
for (let i = 0; i < pad.length; i++)
|
|
945
|
+
pad[i] ^= 54;
|
|
946
|
+
this.iHash.update(pad);
|
|
947
|
+
this.oHash = hash.create();
|
|
948
|
+
for (let i = 0; i < pad.length; i++)
|
|
949
|
+
pad[i] ^= 54 ^ 92;
|
|
950
|
+
this.oHash.update(pad);
|
|
951
|
+
clean(pad);
|
|
952
|
+
}
|
|
953
|
+
update(buf) {
|
|
954
|
+
aexists(this);
|
|
955
|
+
this.iHash.update(buf);
|
|
956
|
+
return this;
|
|
957
|
+
}
|
|
958
|
+
digestInto(out) {
|
|
959
|
+
aexists(this);
|
|
960
|
+
aoutput(out, this);
|
|
961
|
+
this.finished = true;
|
|
962
|
+
const buf = out.subarray(0, this.outputLen);
|
|
963
|
+
this.iHash.digestInto(buf);
|
|
964
|
+
this.oHash.update(buf);
|
|
965
|
+
this.oHash.digestInto(buf);
|
|
966
|
+
this.destroy();
|
|
967
|
+
}
|
|
968
|
+
digest() {
|
|
969
|
+
const out = new Uint8Array(this.oHash.outputLen);
|
|
970
|
+
this.digestInto(out);
|
|
971
|
+
return out;
|
|
972
|
+
}
|
|
973
|
+
_cloneInto(to) {
|
|
974
|
+
to ||= Object.create(Object.getPrototypeOf(this), {});
|
|
975
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen, canXOF } = this;
|
|
976
|
+
to = to;
|
|
977
|
+
to.finished = finished;
|
|
978
|
+
to.destroyed = destroyed;
|
|
979
|
+
to.blockLen = blockLen;
|
|
980
|
+
to.outputLen = outputLen;
|
|
981
|
+
to.canXOF = canXOF;
|
|
982
|
+
to.oHash = oHash._cloneInto(to.oHash);
|
|
983
|
+
to.iHash = iHash._cloneInto(to.iHash);
|
|
984
|
+
return to;
|
|
985
|
+
}
|
|
986
|
+
clone() {
|
|
987
|
+
return this._cloneInto();
|
|
988
|
+
}
|
|
989
|
+
destroy() {
|
|
990
|
+
this.destroyed = true;
|
|
991
|
+
this.oHash.destroy();
|
|
992
|
+
this.iHash.destroy();
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
var hmac = /* @__PURE__ */ (() => {
|
|
996
|
+
const hmac_ = ((hash, key, message) => new _HMAC(hash, key).update(message).digest());
|
|
997
|
+
hmac_.create = (hash, key) => new _HMAC(hash, key);
|
|
998
|
+
return hmac_;
|
|
999
|
+
})();
|
|
1000
|
+
|
|
1001
|
+
// node_modules/@noble/hashes/hkdf.js
|
|
1002
|
+
var HKDF_COUNTER = /* @__PURE__ */ Uint8Array.of(0);
|
|
1003
|
+
var EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of();
|
|
1004
|
+
function expand(hash, prk, info, length = 32, _recycled) {
|
|
1005
|
+
ahash(hash);
|
|
1006
|
+
anumber(length, "length");
|
|
1007
|
+
abytes(prk, void 0, "prk");
|
|
1008
|
+
const olen = hash.outputLen;
|
|
1009
|
+
if (prk.length < olen)
|
|
1010
|
+
throw new Error('"prk" must be at least HashLen octets');
|
|
1011
|
+
if (length > 255 * olen)
|
|
1012
|
+
throw new Error("Length must be <= 255*HashLen");
|
|
1013
|
+
const blocks = Math.ceil(length / olen);
|
|
1014
|
+
if (info === void 0)
|
|
1015
|
+
info = EMPTY_BUFFER;
|
|
1016
|
+
else
|
|
1017
|
+
abytes(info, void 0, "info");
|
|
1018
|
+
if (!blocks) {
|
|
1019
|
+
if (_recycled)
|
|
1020
|
+
clean(prk);
|
|
1021
|
+
return new Uint8Array();
|
|
1022
|
+
}
|
|
1023
|
+
const okm = _recycled && blocks === 1 ? prk : new Uint8Array(blocks * olen);
|
|
1024
|
+
const { iHash, oHash } = hmac.create(hash, prk);
|
|
1025
|
+
const T = _recycled ? prk : new Uint8Array(olen);
|
|
1026
|
+
const worker = blocks > 1 ? _recycled?.iHash || hash.create() : void 0;
|
|
1027
|
+
for (let counter = 0; counter < blocks - 1; counter++) {
|
|
1028
|
+
HKDF_COUNTER[0] = counter + 1;
|
|
1029
|
+
const iWork = iHash._cloneInto(worker);
|
|
1030
|
+
if (counter)
|
|
1031
|
+
iWork.update(T);
|
|
1032
|
+
iWork.update(info).update(HKDF_COUNTER).digestInto(T);
|
|
1033
|
+
oHash._cloneInto(worker).update(T).digestInto(T);
|
|
1034
|
+
okm.set(T, olen * counter);
|
|
1035
|
+
}
|
|
1036
|
+
HKDF_COUNTER[0] = blocks;
|
|
1037
|
+
if (blocks > 1)
|
|
1038
|
+
iHash.update(T);
|
|
1039
|
+
iHash.update(info).update(HKDF_COUNTER).digestInto(T);
|
|
1040
|
+
oHash.update(T).digestInto(T);
|
|
1041
|
+
okm.set(T, olen * (blocks - 1));
|
|
1042
|
+
iHash.destroy();
|
|
1043
|
+
oHash.destroy();
|
|
1044
|
+
worker?.destroy();
|
|
1045
|
+
if (T !== okm)
|
|
1046
|
+
clean(T);
|
|
1047
|
+
clean(HKDF_COUNTER);
|
|
1048
|
+
if (length === okm.length)
|
|
1049
|
+
return okm;
|
|
1050
|
+
const res = okm.slice(0, length);
|
|
1051
|
+
clean(okm);
|
|
1052
|
+
return res;
|
|
1053
|
+
}
|
|
1054
|
+
var hkdf = (hash, ikm, salt, info, length) => {
|
|
1055
|
+
ahash(hash);
|
|
1056
|
+
if (salt === void 0)
|
|
1057
|
+
salt = new Uint8Array(hash.outputLen);
|
|
1058
|
+
const HMAC = hmac.create(hash, salt).update(ikm);
|
|
1059
|
+
return expand(hash, HMAC.digest(), info, length, HMAC);
|
|
1060
|
+
};
|
|
1061
|
+
export {
|
|
1062
|
+
hkdf,
|
|
1063
|
+
hmac,
|
|
1064
|
+
sha256,
|
|
1065
|
+
sha3_256,
|
|
1066
|
+
sha3_512,
|
|
1067
|
+
sha512,
|
|
1068
|
+
shake128,
|
|
1069
|
+
shake256
|
|
1070
|
+
};
|