module-develop-kit 1.3.0 → 1.4.0
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/dist/commonjs-virtual-dir/index.js +5 -3
- package/dist/commonjs-virtual-dir/index2.js +3 -3
- package/dist/commonjs-virtual-dir/index3.js +2 -7
- package/dist/commonjs-virtual-dir/index4.js +4 -2
- package/dist/commonjs-virtual-dir/index5.js +2 -2
- package/dist/main.d.ts +74 -28
- package/dist/main.js +40 -35
- package/dist/src/outside-call/utils.js +1 -1
- package/dist/src/shield/crypto/const.js +2 -2
- package/dist/src/shield/crypto/sm2.js +4 -4
- package/dist/src/shield/crypto/util.js +11 -23
- package/dist/src/shield/gcm-crypto/gcm.service.js +29 -0
- package/dist/src/shield/gcm-crypto/hex.js +18 -0
- package/dist/src/shield/gcm-crypto/index.js +40 -0
- package/dist/src/shield/gcm-crypto/init.js +61 -0
- package/dist/src/shield/gcm-crypto/string.js +10 -0
- package/dist/src/utils/is.js +4 -0
- package/dist/src/vite-plugins/vite-plugin-sri/index.js +4 -1
- package/dist/src/vite-plugins/vite-plugin-sri/internal.js +52 -53
- package/dist/types/axios.d.ts +16 -0
- package/dist/vendor/@noble/ciphers/esm/_polyval.js +116 -0
- package/dist/vendor/@noble/ciphers/esm/utils.js +68 -0
- package/dist/vendor/@noble/curves/esm/abstract/curve.js +203 -0
- package/dist/vendor/@noble/curves/esm/abstract/modular.js +240 -0
- package/dist/vendor/@noble/curves/esm/abstract/utils.js +10 -0
- package/dist/vendor/@noble/curves/esm/abstract/weierstrass.js +791 -0
- package/dist/vendor/@noble/curves/esm/utils.js +154 -0
- package/dist/vendor/@noble/hashes/esm/crypto.js +4 -0
- package/dist/vendor/@noble/hashes/esm/hmac.js +45 -0
- package/dist/vendor/@noble/hashes/esm/utils.js +112 -0
- package/dist/vendor/ieee754/index.js +1 -1
- package/dist/vendor/sdp-transform/lib/index.js +1 -1
- package/dist/vendor/sm-crypto-v2/dist/index.js +1004 -0
- package/dist/vendor/token-types/lib/index.js +1 -1
- package/package.json +3 -2
- package/dist/commonjs-virtual-dir/index7.js +0 -4
- package/dist/commonjs-virtual-dir/index8.js +0 -4
- package/dist/src/shield/crypto/index.js +0 -53
- package/dist/src/shield/crypto/sm4.js +0 -15
- package/dist/vendor/base64-js/index.js +0 -52
- package/dist/vendor/gm-crypt/index.js +0 -10
- package/dist/vendor/gm-crypt/src/crypt.js +0 -60
- package/dist/vendor/gm-crypt/src/sm4.js +0 -513
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createHash as
|
|
2
|
-
import { createRequire as
|
|
1
|
+
import { createHash as X } from "node:crypto";
|
|
2
|
+
import { createRequire as Q } from "node:module";
|
|
3
3
|
import $ from "node:path";
|
|
4
4
|
import { pathToFileURL as _ } from "node:url";
|
|
5
5
|
import { parse as T } from "../../../vendor/parse5/dist/index.js";
|
|
6
|
-
import { getVitePluginSriBase as
|
|
6
|
+
import { getVitePluginSriBase as Y } from "./config.js";
|
|
7
7
|
import { serialize as H } from "../../../vendor/parse5/dist/serializer/index.js";
|
|
8
8
|
function C(e) {
|
|
9
9
|
return typeof e == "string" && /^(https?:)?\/\//i.test(e);
|
|
@@ -14,30 +14,30 @@ function B(e) {
|
|
|
14
14
|
function F(e) {
|
|
15
15
|
return typeof e != "string" ? e : e.startsWith("//") ? e.slice(2) : e.startsWith("/") ? e.slice(1) : e.startsWith("./") ? e.slice(2) : e;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function V(e, t) {
|
|
18
18
|
if (C(e)) {
|
|
19
19
|
const n = e.endsWith("/") ? e : `${e}/`, r = t.startsWith("/") ? t.slice(1) : t;
|
|
20
20
|
return n + r;
|
|
21
21
|
}
|
|
22
22
|
return $.posix.join(e, t);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function Z(e, t, n) {
|
|
25
25
|
if (C(e) || e.startsWith("/"))
|
|
26
|
-
return
|
|
26
|
+
return V(e, t);
|
|
27
27
|
const r = $.posix.dirname(n), i = $.posix.relative(r === "" ? "." : r, t);
|
|
28
28
|
return i.startsWith("..") ? i : `./${i}`;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function tt(e) {
|
|
31
31
|
return e.startsWith("/") || C(e);
|
|
32
32
|
}
|
|
33
33
|
function U(e, t, n = [], r = /* @__PURE__ */ new Set()) {
|
|
34
|
-
if (!
|
|
34
|
+
if (!tt(t)) return null;
|
|
35
35
|
const i = {};
|
|
36
|
-
for (const { pathname: s, fileName: f } of
|
|
37
|
-
i[
|
|
36
|
+
for (const { pathname: s, fileName: f } of P(e, n, r))
|
|
37
|
+
i[V(t, f)] = e[s];
|
|
38
38
|
return i;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function P(e, t = [], n = /* @__PURE__ */ new Set()) {
|
|
41
41
|
const r = [];
|
|
42
42
|
for (const i of Object.keys(e)) {
|
|
43
43
|
if (!/\.m?js(\?|$)/i.test(i)) continue;
|
|
@@ -52,7 +52,7 @@ function R(e, t) {
|
|
|
52
52
|
if (A(n, e) || A(n, `/${e}`)) return !0;
|
|
53
53
|
return !1;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function et(e) {
|
|
56
56
|
if (C(e))
|
|
57
57
|
try {
|
|
58
58
|
const n = e.startsWith("//") ? `https:${e}` : e;
|
|
@@ -62,7 +62,7 @@ function nt(e) {
|
|
|
62
62
|
const t = F(e);
|
|
63
63
|
return t.startsWith("/") ? t : `/${t}`;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function nt(e, t) {
|
|
66
66
|
if (!e) return null;
|
|
67
67
|
const n = Object.keys(e);
|
|
68
68
|
if (e[t]) return e[t];
|
|
@@ -71,7 +71,7 @@ function rt(e, t) {
|
|
|
71
71
|
const i = t.split("/").pop();
|
|
72
72
|
return i ? (r = n.find((s) => s === i || s.endsWith(`/${i}`)), r ? e[r] : null) : null;
|
|
73
73
|
}
|
|
74
|
-
async function
|
|
74
|
+
async function rt(e, t, n) {
|
|
75
75
|
if (!e) return null;
|
|
76
76
|
const r = n?.enableCache !== !1, i = n?.cache, s = n?.fetchTimeoutMs ?? 0, f = n?.pending;
|
|
77
77
|
if (C(e)) {
|
|
@@ -103,11 +103,11 @@ async function it(e, t, n) {
|
|
|
103
103
|
if (!t) return null;
|
|
104
104
|
const a = F(e);
|
|
105
105
|
if (typeof a != "string" || !a) return null;
|
|
106
|
-
const c =
|
|
106
|
+
const c = nt(t, a);
|
|
107
107
|
return c ? c.code ?? c.source ?? null : null;
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
const n = Buffer.from(e), r =
|
|
109
|
+
function q(e, t) {
|
|
110
|
+
const n = Buffer.from(e), r = X(t).update(n).digest("base64");
|
|
111
111
|
return `${t}-${r}`;
|
|
112
112
|
}
|
|
113
113
|
function A(e, t) {
|
|
@@ -116,7 +116,7 @@ function A(e, t) {
|
|
|
116
116
|
const n = e.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
117
117
|
return new RegExp(`^${n}$`).test(t);
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function it(e, t) {
|
|
120
120
|
if (!t || t.length === 0) return !1;
|
|
121
121
|
const n = w(e, "id"), r = w(e, "src"), i = w(e, "href");
|
|
122
122
|
for (const s of t)
|
|
@@ -124,7 +124,7 @@ function st(e, t) {
|
|
|
124
124
|
return !0;
|
|
125
125
|
return !1;
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function st(e) {
|
|
128
128
|
return !e || !e.nodeName ? null : e.nodeName.toLowerCase() === "script" ? "src" : "href";
|
|
129
129
|
}
|
|
130
130
|
function N(e, t) {
|
|
@@ -139,7 +139,7 @@ function N(e, t) {
|
|
|
139
139
|
function w(e, t) {
|
|
140
140
|
return e.attrs.find((r) => r.name === t)?.value;
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function ot(e) {
|
|
143
143
|
if (!e.childNodes) return 0;
|
|
144
144
|
for (let t = 0; t < e.childNodes.length; t++) {
|
|
145
145
|
const n = e.childNodes[t];
|
|
@@ -155,35 +155,35 @@ function z(e) {
|
|
|
155
155
|
}
|
|
156
156
|
return 0;
|
|
157
157
|
}
|
|
158
|
-
function
|
|
158
|
+
function z(e, t, n) {
|
|
159
159
|
const r = e.attrs.find((i) => i.name === t);
|
|
160
160
|
r ? r.value = n : e.attrs.push({ name: t, value: n });
|
|
161
161
|
}
|
|
162
162
|
async function at(e, t, n, r, i, s) {
|
|
163
163
|
if (!e || !e.attrs || w(e, "integrity")) return;
|
|
164
|
-
const f =
|
|
164
|
+
const f = st(e);
|
|
165
165
|
if (!f) return;
|
|
166
166
|
let a = w(e, f);
|
|
167
167
|
if (!a) return;
|
|
168
|
-
const c =
|
|
168
|
+
const c = Y();
|
|
169
169
|
c && a.startsWith(c) && (a = a.slice(c.length));
|
|
170
170
|
let u;
|
|
171
171
|
if (s && a) {
|
|
172
|
-
const l =
|
|
172
|
+
const l = et(a);
|
|
173
173
|
if (u = s[l], !u) {
|
|
174
174
|
const d = F(l);
|
|
175
175
|
u = s[d] || s[`/${d}`];
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
if (!u) {
|
|
179
|
-
const l = await
|
|
179
|
+
const l = await rt(a, t, i);
|
|
180
180
|
if (!l) return;
|
|
181
|
-
u =
|
|
181
|
+
u = q(l, n);
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
z(e, "integrity", u), r && z(e, "crossorigin", r);
|
|
184
184
|
}
|
|
185
185
|
function ct(e, t) {
|
|
186
|
-
if (!e.nodeName || !e.attrs || t &&
|
|
186
|
+
if (!e.nodeName || !e.attrs || t && it(e, t))
|
|
187
187
|
return !1;
|
|
188
188
|
const n = e.nodeName.toLowerCase(), r = w(e, "rel")?.toLowerCase(), i = w(e, "as")?.toLowerCase();
|
|
189
189
|
return !!(n === "script" && w(e, "src") || n === "link" && w(e, "href") && (r === "stylesheet" || r === "modulepreload" || r === "preload" && (i === "script" || i === "style")));
|
|
@@ -371,7 +371,7 @@ class St {
|
|
|
371
371
|
} else
|
|
372
372
|
return this.logger.warn(`Unknown bundle item type for ${t}, skipping`), null;
|
|
373
373
|
try {
|
|
374
|
-
const i =
|
|
374
|
+
const i = q(r, this.algorithm);
|
|
375
375
|
return { pathname: $.posix.join("/", t), integrity: i };
|
|
376
376
|
} catch (i) {
|
|
377
377
|
return this.logger.error(
|
|
@@ -635,7 +635,7 @@ class vt {
|
|
|
635
635
|
let c = await this.addSriToHtmlContent(a, r, i);
|
|
636
636
|
const u = this.config.importMapIntegrity === !1 ? /* @__PURE__ */ new Set([
|
|
637
637
|
...s,
|
|
638
|
-
...
|
|
638
|
+
...P(i, this.config.skipResources, f).map(
|
|
639
639
|
(l) => l.fileName
|
|
640
640
|
)
|
|
641
641
|
]) : s;
|
|
@@ -728,7 +728,7 @@ class vt {
|
|
|
728
728
|
* @returns boolean - Whether a link was added
|
|
729
729
|
*/
|
|
730
730
|
addPreloadLinkForChunk(t, n, r, i) {
|
|
731
|
-
const s =
|
|
731
|
+
const s = Z(this.config.base, n, i);
|
|
732
732
|
if (N(t, (u) => {
|
|
733
733
|
if (u.nodeName?.toLowerCase() !== "link") return !1;
|
|
734
734
|
const l = w(u, "rel"), d = w(u, "href");
|
|
@@ -754,7 +754,7 @@ class vt {
|
|
|
754
754
|
return this.config.crossorigin && c.attrs.push({
|
|
755
755
|
name: "crossorigin",
|
|
756
756
|
value: this.config.crossorigin
|
|
757
|
-
}), t.childNodes || (t.childNodes = []), t.childNodes.
|
|
757
|
+
}), t.childNodes || (t.childNodes = []), t.childNodes.push(c), !0;
|
|
758
758
|
}
|
|
759
759
|
/**
|
|
760
760
|
* Injects (or merges into) a `<script type="importmap">` carrying an
|
|
@@ -765,10 +765,9 @@ class vt {
|
|
|
765
765
|
* `integrity` key (progressive enhancement, same model as SRI attributes
|
|
766
766
|
* generally).
|
|
767
767
|
*
|
|
768
|
-
* Must run AFTER addDynamicChunkPreloads:
|
|
769
|
-
*
|
|
770
|
-
* the
|
|
771
|
-
* before any module script or modulepreload link.
|
|
768
|
+
* Must run AFTER addDynamicChunkPreloads: preload links are appended to
|
|
769
|
+
* <head>, while a newly-created import map is inserted near its start. This
|
|
770
|
+
* preserves the spec requirement that the map precede modulepreload links.
|
|
772
771
|
*
|
|
773
772
|
* No-ops (returning the input unchanged) when: base is relative (the
|
|
774
773
|
* resulting keys — bare or document-relative — cannot be used portably
|
|
@@ -837,7 +836,7 @@ class vt {
|
|
|
837
836
|
parentNode: a,
|
|
838
837
|
sourceCodeLocation: void 0
|
|
839
838
|
};
|
|
840
|
-
d.parentNode = g, a.childNodes || (a.childNodes = []), a.childNodes.splice(
|
|
839
|
+
d.parentNode = g, a.childNodes || (a.childNodes = []), a.childNodes.splice(ot(a), 0, g);
|
|
841
840
|
}
|
|
842
841
|
return H(f);
|
|
843
842
|
} catch (f) {
|
|
@@ -958,12 +957,12 @@ class L {
|
|
|
958
957
|
return R(t, n);
|
|
959
958
|
}
|
|
960
959
|
}
|
|
961
|
-
const
|
|
960
|
+
const D = "sri-runtime.js";
|
|
962
961
|
async function Et(e, t = () => import("vite")) {
|
|
963
962
|
try {
|
|
964
963
|
return await t();
|
|
965
964
|
} catch {
|
|
966
|
-
const n =
|
|
965
|
+
const n = Q(_($.join(e, "package.json")).href), r = $.dirname(n.resolve("vite/package.json"));
|
|
967
966
|
return await import(_($.join(r, "dist", "node", "index.js")).href);
|
|
968
967
|
}
|
|
969
968
|
}
|
|
@@ -972,12 +971,12 @@ async function $t(e, t, n = () => import("vite")) {
|
|
|
972
971
|
const r = await n();
|
|
973
972
|
let i;
|
|
974
973
|
if (typeof r.minifySync == "function") {
|
|
975
|
-
const f = r.minifySync(
|
|
974
|
+
const f = r.minifySync(D, e);
|
|
976
975
|
if (f?.errors?.length)
|
|
977
976
|
return t?.info(`SRI runtime minification skipped: ${String(f.errors[0])}`), e;
|
|
978
977
|
i = f?.code;
|
|
979
978
|
} else if (typeof r.transformWithEsbuild == "function")
|
|
980
|
-
i = (await r.transformWithEsbuild(e,
|
|
979
|
+
i = (await r.transformWithEsbuild(e, D, {
|
|
981
980
|
minify: !0,
|
|
982
981
|
target: "esnext",
|
|
983
982
|
keepNames: !1
|
|
@@ -1058,10 +1057,10 @@ function Nt(e, t) {
|
|
|
1058
1057
|
let b;
|
|
1059
1058
|
try {
|
|
1060
1059
|
b = new URL(E, k || globalThis.location?.href || void 0);
|
|
1061
|
-
} catch (
|
|
1060
|
+
} catch (G) {
|
|
1062
1061
|
throw new Error(
|
|
1063
1062
|
`[vite-plugin-sri-gen] Cannot resolve dynamic import specifier ${E}${k ? ` against ${k}` : ""}`,
|
|
1064
|
-
{ cause:
|
|
1063
|
+
{ cause: G }
|
|
1065
1064
|
);
|
|
1066
1065
|
}
|
|
1067
1066
|
const v = a(b.pathname);
|
|
@@ -1079,7 +1078,7 @@ function Nt(e, t) {
|
|
|
1079
1078
|
throw new Error(
|
|
1080
1079
|
`[vite-plugin-sri-gen] Failed to fetch ${b.href} for integrity verification (HTTP ${x.status})`
|
|
1081
1080
|
);
|
|
1082
|
-
const
|
|
1081
|
+
const J = await x.arrayBuffer(), K = await crypto.subtle.digest(O, J), W = v.slice(0, v.indexOf("-") + 1) + m(new Uint8Array(K));
|
|
1083
1082
|
if (W !== v)
|
|
1084
1083
|
throw new Error(
|
|
1085
1084
|
`[vite-plugin-sri-gen] Integrity verification failed for ${b.href} (expected ${v}, got ${W})`
|
|
@@ -1148,26 +1147,26 @@ export {
|
|
|
1148
1147
|
L as ManifestProcessor,
|
|
1149
1148
|
ft as addSriToHtml,
|
|
1150
1149
|
U as buildImportIntegrityObject,
|
|
1151
|
-
|
|
1152
|
-
|
|
1150
|
+
P as collectModuleChunkFiles,
|
|
1151
|
+
q as computeIntegrity,
|
|
1153
1152
|
yt as createLogger,
|
|
1154
1153
|
B as escapeForScript,
|
|
1155
|
-
|
|
1156
|
-
|
|
1154
|
+
et as extractPathnameFromResourceUrl,
|
|
1155
|
+
st as getUrlAttrName,
|
|
1157
1156
|
kt as handleGenerateBundleError,
|
|
1158
1157
|
Nt as installSriRuntime,
|
|
1159
1158
|
ct as isEligibleForSri,
|
|
1160
1159
|
C as isHttpUrl,
|
|
1161
|
-
|
|
1160
|
+
tt as isImportMapCapableBase,
|
|
1162
1161
|
R as isSkippedResource,
|
|
1163
|
-
|
|
1164
|
-
|
|
1162
|
+
V as joinBaseHref,
|
|
1163
|
+
rt as loadResource,
|
|
1165
1164
|
Et as loadVite,
|
|
1166
1165
|
A as matchesPattern,
|
|
1167
1166
|
$t as minifyRuntimeSource,
|
|
1168
1167
|
F as normalizeBundlePath,
|
|
1169
|
-
|
|
1168
|
+
Z as preloadHref,
|
|
1170
1169
|
at as processElement,
|
|
1171
|
-
|
|
1170
|
+
it as shouldSkipElement,
|
|
1172
1171
|
wt as validateGenerateBundleInputs
|
|
1173
1172
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "axios";
|
|
2
|
+
|
|
3
|
+
declare module "axios" {
|
|
4
|
+
export interface InternalAxiosRequestConfig {
|
|
5
|
+
/**
|
|
6
|
+
* 接口是否不需要自动加密
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
isNotAutoEncryption?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* 响应是否需要自动解密
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
isAutoDecryptionResponse?: boolean;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { toBytes as y, u32 as x, abytes as W, createView as G, aexists as U, clean as k, aoutput as H, copyBytes as M } from "./utils.js";
|
|
2
|
+
const f = 16, v = /* @__PURE__ */ new Uint8Array(16), l = x(v), R = 225, V = (o, t, s, e) => {
|
|
3
|
+
const n = e & 1;
|
|
4
|
+
return {
|
|
5
|
+
s3: s << 31 | e >>> 1,
|
|
6
|
+
s2: t << 31 | s >>> 1,
|
|
7
|
+
s1: o << 31 | t >>> 1,
|
|
8
|
+
s0: o >>> 1 ^ R << 24 & -(n & 1)
|
|
9
|
+
// reduce % poly
|
|
10
|
+
};
|
|
11
|
+
}, c = (o) => (o >>> 0 & 255) << 24 | (o >>> 8 & 255) << 16 | (o >>> 16 & 255) << 8 | o >>> 24 & 255 | 0;
|
|
12
|
+
function j(o) {
|
|
13
|
+
o.reverse();
|
|
14
|
+
const t = o[15] & 1;
|
|
15
|
+
let s = 0;
|
|
16
|
+
for (let e = 0; e < o.length; e++) {
|
|
17
|
+
const n = o[e];
|
|
18
|
+
o[e] = n >>> 1 | s, s = (n & 1) << 7;
|
|
19
|
+
}
|
|
20
|
+
return o[0] ^= -t & 225, o;
|
|
21
|
+
}
|
|
22
|
+
const C = (o) => o > 64 * 1024 ? 8 : o > 1024 ? 4 : 2;
|
|
23
|
+
class I {
|
|
24
|
+
// We select bits per window adaptively based on expectedLength
|
|
25
|
+
constructor(t, s) {
|
|
26
|
+
this.blockLen = f, this.outputLen = f, this.s0 = 0, this.s1 = 0, this.s2 = 0, this.s3 = 0, this.finished = !1, t = y(t), W(t, 16);
|
|
27
|
+
const e = G(t);
|
|
28
|
+
let n = e.getUint32(0, !1), i = e.getUint32(4, !1), r = e.getUint32(8, !1), b = e.getUint32(12, !1);
|
|
29
|
+
const g = [];
|
|
30
|
+
for (let u = 0; u < 128; u++)
|
|
31
|
+
g.push({ s0: c(n), s1: c(i), s2: c(r), s3: c(b) }), { s0: n, s1: i, s2: r, s3: b } = V(n, i, r, b);
|
|
32
|
+
const h = C(s || 1024);
|
|
33
|
+
if (![1, 2, 4, 8].includes(h))
|
|
34
|
+
throw new Error("ghash: invalid window size, expected 2, 4 or 8");
|
|
35
|
+
this.W = h;
|
|
36
|
+
const B = 128 / h, A = this.windowSize = 2 ** h, a = [];
|
|
37
|
+
for (let u = 0; u < B; u++)
|
|
38
|
+
for (let w = 0; w < A; w++) {
|
|
39
|
+
let L = 0, d = 0, m = 0, S = 0;
|
|
40
|
+
for (let p = 0; p < h; p++) {
|
|
41
|
+
if (!(w >>> h - p - 1 & 1))
|
|
42
|
+
continue;
|
|
43
|
+
const { s0: E, s1: O, s2: P, s3: Z } = g[h * u + p];
|
|
44
|
+
L ^= E, d ^= O, m ^= P, S ^= Z;
|
|
45
|
+
}
|
|
46
|
+
a.push({ s0: L, s1: d, s2: m, s3: S });
|
|
47
|
+
}
|
|
48
|
+
this.t = a;
|
|
49
|
+
}
|
|
50
|
+
_updateBlock(t, s, e, n) {
|
|
51
|
+
t ^= this.s0, s ^= this.s1, e ^= this.s2, n ^= this.s3;
|
|
52
|
+
const { W: i, t: r, windowSize: b } = this;
|
|
53
|
+
let g = 0, h = 0, _ = 0, B = 0;
|
|
54
|
+
const A = (1 << i) - 1;
|
|
55
|
+
let a = 0;
|
|
56
|
+
for (const u of [t, s, e, n])
|
|
57
|
+
for (let w = 0; w < 4; w++) {
|
|
58
|
+
const L = u >>> 8 * w & 255;
|
|
59
|
+
for (let d = 8 / i - 1; d >= 0; d--) {
|
|
60
|
+
const m = L >>> i * d & A, { s0: S, s1: p, s2: z, s3: E } = r[a * b + m];
|
|
61
|
+
g ^= S, h ^= p, _ ^= z, B ^= E, a += 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
this.s0 = g, this.s1 = h, this.s2 = _, this.s3 = B;
|
|
65
|
+
}
|
|
66
|
+
update(t) {
|
|
67
|
+
U(this), t = y(t), W(t);
|
|
68
|
+
const s = x(t), e = Math.floor(t.length / f), n = t.length % f;
|
|
69
|
+
for (let i = 0; i < e; i++)
|
|
70
|
+
this._updateBlock(s[i * 4 + 0], s[i * 4 + 1], s[i * 4 + 2], s[i * 4 + 3]);
|
|
71
|
+
return n && (v.set(t.subarray(e * f)), this._updateBlock(l[0], l[1], l[2], l[3]), k(l)), this;
|
|
72
|
+
}
|
|
73
|
+
destroy() {
|
|
74
|
+
const { t } = this;
|
|
75
|
+
for (const s of t)
|
|
76
|
+
s.s0 = 0, s.s1 = 0, s.s2 = 0, s.s3 = 0;
|
|
77
|
+
}
|
|
78
|
+
digestInto(t) {
|
|
79
|
+
U(this), H(t, this), this.finished = !0;
|
|
80
|
+
const { s0: s, s1: e, s2: n, s3: i } = this, r = x(t);
|
|
81
|
+
return r[0] = s, r[1] = e, r[2] = n, r[3] = i, t;
|
|
82
|
+
}
|
|
83
|
+
digest() {
|
|
84
|
+
const t = new Uint8Array(f);
|
|
85
|
+
return this.digestInto(t), this.destroy(), t;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
class Y extends I {
|
|
89
|
+
constructor(t, s) {
|
|
90
|
+
t = y(t), W(t);
|
|
91
|
+
const e = j(M(t));
|
|
92
|
+
super(e, s), k(e);
|
|
93
|
+
}
|
|
94
|
+
update(t) {
|
|
95
|
+
t = y(t), U(this);
|
|
96
|
+
const s = x(t), e = t.length % f, n = Math.floor(t.length / f);
|
|
97
|
+
for (let i = 0; i < n; i++)
|
|
98
|
+
this._updateBlock(c(s[i * 4 + 3]), c(s[i * 4 + 2]), c(s[i * 4 + 1]), c(s[i * 4 + 0]));
|
|
99
|
+
return e && (v.set(t.subarray(n * f)), this._updateBlock(c(l[3]), c(l[2]), c(l[1]), c(l[0])), k(l)), this;
|
|
100
|
+
}
|
|
101
|
+
digestInto(t) {
|
|
102
|
+
U(this), H(t, this), this.finished = !0;
|
|
103
|
+
const { s0: s, s1: e, s2: n, s3: i } = this, r = x(t);
|
|
104
|
+
return r[0] = s, r[1] = e, r[2] = n, r[3] = i, t.reverse();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function K(o) {
|
|
108
|
+
const t = (e, n) => o(n, e.length).update(y(e)).digest(), s = o(new Uint8Array(16), 0);
|
|
109
|
+
return t.outputLen = s.outputLen, t.blockLen = s.blockLen, t.create = (e, n) => o(e, n), t;
|
|
110
|
+
}
|
|
111
|
+
const D = K((o, t) => new I(o, t));
|
|
112
|
+
K((o, t) => new Y(o, t));
|
|
113
|
+
export {
|
|
114
|
+
j as _toGHASHKey,
|
|
115
|
+
D as ghash
|
|
116
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
|
|
2
|
+
function i(t) {
|
|
3
|
+
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
|
|
4
|
+
}
|
|
5
|
+
function y(t, ...e) {
|
|
6
|
+
if (!i(t))
|
|
7
|
+
throw new Error("Uint8Array expected");
|
|
8
|
+
if (e.length > 0 && !e.includes(t.length))
|
|
9
|
+
throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
|
|
10
|
+
}
|
|
11
|
+
function l(t, e = !0) {
|
|
12
|
+
if (t.destroyed)
|
|
13
|
+
throw new Error("Hash instance has been destroyed");
|
|
14
|
+
if (e && t.finished)
|
|
15
|
+
throw new Error("Hash#digest() has already been called");
|
|
16
|
+
}
|
|
17
|
+
function p(t, e) {
|
|
18
|
+
y(t);
|
|
19
|
+
const n = e.outputLen;
|
|
20
|
+
if (t.length < n)
|
|
21
|
+
throw new Error("digestInto() expects output buffer of length at least " + n);
|
|
22
|
+
}
|
|
23
|
+
function U(t) {
|
|
24
|
+
return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
|
|
25
|
+
}
|
|
26
|
+
function x(...t) {
|
|
27
|
+
for (let e = 0; e < t.length; e++)
|
|
28
|
+
t[e].fill(0);
|
|
29
|
+
}
|
|
30
|
+
function B(t) {
|
|
31
|
+
return new DataView(t.buffer, t.byteOffset, t.byteLength);
|
|
32
|
+
}
|
|
33
|
+
function g(t) {
|
|
34
|
+
if (typeof t != "string")
|
|
35
|
+
throw new Error("string expected");
|
|
36
|
+
return new Uint8Array(new TextEncoder().encode(t));
|
|
37
|
+
}
|
|
38
|
+
function d(t) {
|
|
39
|
+
if (typeof t == "string")
|
|
40
|
+
t = g(t);
|
|
41
|
+
else if (i(t))
|
|
42
|
+
t = w(t);
|
|
43
|
+
else
|
|
44
|
+
throw new Error("Uint8Array expected, got " + typeof t);
|
|
45
|
+
return t;
|
|
46
|
+
}
|
|
47
|
+
function A(t, e, n, r) {
|
|
48
|
+
if (typeof t.setBigUint64 == "function")
|
|
49
|
+
return t.setBigUint64(e, n, r);
|
|
50
|
+
const f = BigInt(32), o = BigInt(4294967295), c = Number(n >> f & o), s = Number(n & o), u = 0, h = 4;
|
|
51
|
+
t.setUint32(e + u, c, r), t.setUint32(e + h, s, r);
|
|
52
|
+
}
|
|
53
|
+
function w(t) {
|
|
54
|
+
return Uint8Array.from(t);
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
y as abytes,
|
|
58
|
+
l as aexists,
|
|
59
|
+
p as aoutput,
|
|
60
|
+
x as clean,
|
|
61
|
+
w as copyBytes,
|
|
62
|
+
B as createView,
|
|
63
|
+
i as isBytes,
|
|
64
|
+
A as setBigUint64,
|
|
65
|
+
d as toBytes,
|
|
66
|
+
U as u32,
|
|
67
|
+
g as utf8ToBytes
|
|
68
|
+
};
|