hd-wallet-ui 2.0.20 → 2.0.26
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/LICENSE +190 -0
- package/README.md +101 -123
- package/data/common-passwords-sdn-v1.source.json +12 -0
- package/data/common-passwords-sdn-v1.txt +10000 -0
- package/dist/browser/sdn-wallet-callback.js +1 -0
- package/dist/browser/sdn-wallet-public-client.js +1 -0
- package/dist/browser/wallet-callback.html +6 -0
- package/dist/client/asset-review.d.ts +8 -0
- package/dist/client/asset-review.js +1570 -0
- package/dist/client/callback.d.ts +13 -0
- package/dist/client/callback.js +29 -0
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.js +1379 -0
- package/dist/client/sdn.d.ts +8 -0
- package/dist/client/sdn.js +1542 -0
- package/dist/client/style.css +32 -0
- package/dist/client/types.d.ts +278 -0
- package/dist/compat/index.d.ts +26 -0
- package/dist/compat/index.js +62 -0
- package/dist/wallet-origin/index.d.ts +21 -0
- package/dist/wallet-origin/index.js +4607 -0
- package/dist/wallet-origin-host/assets/wallet-origin.3d16729bf9aaca4517cc699bec526c7209be184cdbb0ba0dbf4063d36a091e1d.js +12463 -0
- package/dist/wallet-origin-host/assets/wallet-origin.e22071a3643a57055d29f2e6951c1a2f15e77c1b58b0f81bb7f2afed5bcfb0b4.wasm +0 -0
- package/dist/wallet-origin-host/assets/wallet-origin.f3273f7ea70bb494cda1fc02264b936f2e9b010dc07df15eed05fa3f7d1356de.css +1 -0
- package/dist/wallet-origin-host/index.html +10 -0
- package/dist/wallet-origin-host/integrity.json +1 -0
- package/package.json +46 -18
- package/src/address-derivation.js +0 -514
- package/src/app.js +0 -6008
- package/src/blockchain-trust.js +0 -752
- package/src/clipboard.js +0 -44
- package/src/constants.js +0 -66
- package/src/hash.js +0 -9
- package/src/lib.js +0 -66
- package/src/template.js +0 -626
- package/src/trust-ui.js +0 -745
- package/src/wallet-storage.js +0 -773
- package/styles/main.css +0 -6220
- package/styles/widget.css +0 -6212
|
@@ -0,0 +1,4607 @@
|
|
|
1
|
+
import { getWalletOriginCapabilities as Un } from "hd-wallet-wasm";
|
|
2
|
+
const Ni = Object.freeze({
|
|
3
|
+
cm: 0.01,
|
|
4
|
+
km: 1e3,
|
|
5
|
+
m: 1,
|
|
6
|
+
mm: 1e-3
|
|
7
|
+
}), Ti = Object.freeze({
|
|
8
|
+
metersPerSourceUnit: Ni,
|
|
9
|
+
quaternionNormTolerance: 1e-6,
|
|
10
|
+
scaleComponentExclusiveMin: 0,
|
|
11
|
+
scaleComponentInclusiveMax: 1e6,
|
|
12
|
+
translationComponentAbsMax: 1e6,
|
|
13
|
+
upAxes: Object.freeze(["X_UP", "Y_UP", "Z_UP"])
|
|
14
|
+
}), Ci = Object.freeze({ reviewedTransform: Ti, schemaVersion: 1 }), Le = new TextEncoder(), jn = Object.getPrototypeOf(Uint8Array.prototype), _i = Object.getOwnPropertyDescriptor(jn, "buffer").get, xi = Object.getOwnPropertyDescriptor(jn, "length").get, Di = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get, pn = typeof SharedArrayBuffer > "u" ? null : Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get, we = "sdn-bip32-slip10-purpose-v1", pt = "password-scrypt-v2", xe = "ed25519-over-sha256-jcs-v1", hn = "ed25519-raw-32-v1", Bn = "https://review.spacedatanetwork.org", Vn = "sdn-asset-review-v1", ki = "asset-review:assets.ipfs.01", Pi = "asset-review-authority:assets.ipfs.01", Ut = "sdn-login:sdn.spaceaware.io", Ui = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u, se = /^[0-9a-f]{64}$/u, Mn = /^[0-9a-f]{128}$/u, Me = /^sha256:[0-9a-f]{64}$/u, ji = /^[1-9A-HJ-NP-Za-km-z]+$/u, Bi = /^b[a-z2-7]{58}$/u, jt = "abcdefghijklmnopqrstuvwxyz234567", $n = 131072, Vi = [
|
|
15
|
+
"accountFingerprint",
|
|
16
|
+
"accountIndex",
|
|
17
|
+
"accountLabel",
|
|
18
|
+
"accountPeerId",
|
|
19
|
+
"accountXpub",
|
|
20
|
+
"identityScheme",
|
|
21
|
+
"keys",
|
|
22
|
+
"schemaVersion",
|
|
23
|
+
"seedProfile"
|
|
24
|
+
], Mi = [
|
|
25
|
+
"bip32Fingerprint",
|
|
26
|
+
"curve",
|
|
27
|
+
"derivation",
|
|
28
|
+
"encoding",
|
|
29
|
+
"identityScheme",
|
|
30
|
+
"keyId",
|
|
31
|
+
"path",
|
|
32
|
+
"publicKeyHex",
|
|
33
|
+
"purpose",
|
|
34
|
+
"seedProfile",
|
|
35
|
+
"signatureProfile"
|
|
36
|
+
], $i = [
|
|
37
|
+
"connectionExpiresAt",
|
|
38
|
+
"event",
|
|
39
|
+
"identity",
|
|
40
|
+
"schemaVersion"
|
|
41
|
+
], Fi = [
|
|
42
|
+
"algorithm",
|
|
43
|
+
"encoding",
|
|
44
|
+
"identityScheme",
|
|
45
|
+
"keyId",
|
|
46
|
+
"schemaVersion",
|
|
47
|
+
"signatureHex",
|
|
48
|
+
"signatureProfile"
|
|
49
|
+
], Wi = [
|
|
50
|
+
"algorithm",
|
|
51
|
+
"canonicalEnvelope",
|
|
52
|
+
"encoding",
|
|
53
|
+
"identityScheme",
|
|
54
|
+
"keyId",
|
|
55
|
+
"schemaVersion",
|
|
56
|
+
"signatureHex",
|
|
57
|
+
"signatureProfile",
|
|
58
|
+
"signedDigestSha256"
|
|
59
|
+
], ht = [
|
|
60
|
+
"audience",
|
|
61
|
+
"clientId",
|
|
62
|
+
"expiresAt",
|
|
63
|
+
"identityScheme",
|
|
64
|
+
"issuedAt",
|
|
65
|
+
"keyId",
|
|
66
|
+
"nonce",
|
|
67
|
+
"protocolVersion",
|
|
68
|
+
"publicKeyHex",
|
|
69
|
+
"purpose",
|
|
70
|
+
"requestOrigin",
|
|
71
|
+
"serviceInstance",
|
|
72
|
+
"signatureProfile"
|
|
73
|
+
], Bt = [
|
|
74
|
+
"audience",
|
|
75
|
+
"candidateKey",
|
|
76
|
+
"challengeId",
|
|
77
|
+
"clientId",
|
|
78
|
+
"decision",
|
|
79
|
+
"expiresAt",
|
|
80
|
+
"issuedAt",
|
|
81
|
+
"metadataSha256",
|
|
82
|
+
"modelBytes",
|
|
83
|
+
"modelCid",
|
|
84
|
+
"modelSha256",
|
|
85
|
+
"nonce",
|
|
86
|
+
"previousDecisionHead",
|
|
87
|
+
"protocolVersion",
|
|
88
|
+
"requestOrigin"
|
|
89
|
+
], zi = [
|
|
90
|
+
"metersPerSourceUnit",
|
|
91
|
+
"rotation",
|
|
92
|
+
"scale",
|
|
93
|
+
"sourceUnits",
|
|
94
|
+
"translation",
|
|
95
|
+
"upAxis"
|
|
96
|
+
];
|
|
97
|
+
function y(e) {
|
|
98
|
+
throw new TypeError(e);
|
|
99
|
+
}
|
|
100
|
+
function St(e) {
|
|
101
|
+
if (e === null || typeof e != "object" || Array.isArray(e)) return !1;
|
|
102
|
+
const t = Object.getPrototypeOf(e);
|
|
103
|
+
return t === Object.prototype || t === null;
|
|
104
|
+
}
|
|
105
|
+
function oe(e, t) {
|
|
106
|
+
typeof e != "string" && y(`${t} must be a string`);
|
|
107
|
+
for (let n = 0; n < e.length; n += 1) {
|
|
108
|
+
const i = e.charCodeAt(n);
|
|
109
|
+
let r = i;
|
|
110
|
+
if (i >= 55296 && i <= 56319) {
|
|
111
|
+
const s = e.charCodeAt(n + 1);
|
|
112
|
+
s >= 56320 && s <= 57343 || y(`${t} contains an unpaired surrogate`), r = 65536 + (i - 55296 << 10) + (s - 56320), n += 1;
|
|
113
|
+
} else i >= 56320 && i <= 57343 && y(`${t} contains an unpaired surrogate`);
|
|
114
|
+
((r & 65535) === 65534 || (r & 65535) === 65535 || r >= 64976 && r <= 65007) && y(`${t} contains a Unicode noncharacter`);
|
|
115
|
+
}
|
|
116
|
+
return e;
|
|
117
|
+
}
|
|
118
|
+
function Fn(e) {
|
|
119
|
+
typeof e != "string" && y("wire JSON must be a string"), Le.encode(e).byteLength > $n && y("wire JSON is too large"), e.charCodeAt(0) === 65279 && y("wire JSON must not contain a BOM");
|
|
120
|
+
let t = 0, n = 0;
|
|
121
|
+
const i = () => {
|
|
122
|
+
for (; t < e.length && /[\u0009\u000a\u000d\u0020]/u.test(e[t]); ) t += 1;
|
|
123
|
+
}, r = () => {
|
|
124
|
+
e[t] !== '"' && y("invalid JSON string");
|
|
125
|
+
const o = t;
|
|
126
|
+
for (t += 1; t < e.length; ) {
|
|
127
|
+
const c = e.charCodeAt(t);
|
|
128
|
+
if (c === 34) {
|
|
129
|
+
t += 1;
|
|
130
|
+
let l;
|
|
131
|
+
try {
|
|
132
|
+
l = JSON.parse(e.slice(o, t));
|
|
133
|
+
} catch {
|
|
134
|
+
y("invalid JSON string");
|
|
135
|
+
}
|
|
136
|
+
return oe(l, "JSON string");
|
|
137
|
+
}
|
|
138
|
+
c < 32 && y("invalid JSON control character"), c === 92 && (t += 1, t >= e.length && y("unterminated JSON escape")), t += 1;
|
|
139
|
+
}
|
|
140
|
+
y("unterminated JSON string");
|
|
141
|
+
}, s = (o = 0) => {
|
|
142
|
+
o > 32 && y("wire JSON nesting is too deep"), n += 1, n > 4096 && y("wire JSON contains too many values"), i();
|
|
143
|
+
const c = e[t];
|
|
144
|
+
if (c === '"') return r();
|
|
145
|
+
if (c === "{") {
|
|
146
|
+
t += 1;
|
|
147
|
+
const u = /* @__PURE__ */ Object.create(null), f = /* @__PURE__ */ new Set();
|
|
148
|
+
if (i(), e[t] === "}")
|
|
149
|
+
return t += 1, u;
|
|
150
|
+
for (; t < e.length; ) {
|
|
151
|
+
i();
|
|
152
|
+
const p = r();
|
|
153
|
+
if (f.has(p) && y(`duplicate JSON field: ${p}`), f.add(p), i(), e[t] !== ":" && y("missing JSON object colon"), t += 1, u[p] = s(o + 1), i(), e[t] === "}")
|
|
154
|
+
return t += 1, u;
|
|
155
|
+
e[t] !== "," && y("invalid JSON object separator"), t += 1;
|
|
156
|
+
}
|
|
157
|
+
y("unterminated JSON object");
|
|
158
|
+
}
|
|
159
|
+
if (c === "[") {
|
|
160
|
+
t += 1;
|
|
161
|
+
const u = [];
|
|
162
|
+
if (i(), e[t] === "]")
|
|
163
|
+
return t += 1, u;
|
|
164
|
+
for (; t < e.length; ) {
|
|
165
|
+
if (u.push(s(o + 1)), i(), e[t] === "]")
|
|
166
|
+
return t += 1, u;
|
|
167
|
+
e[t] !== "," && y("invalid JSON array separator"), t += 1;
|
|
168
|
+
}
|
|
169
|
+
y("unterminated JSON array");
|
|
170
|
+
}
|
|
171
|
+
for (const [u, f] of [["true", !0], ["false", !1], ["null", null]])
|
|
172
|
+
if (e.startsWith(u, t))
|
|
173
|
+
return t += u.length, f;
|
|
174
|
+
const l = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/u.exec(e.slice(t));
|
|
175
|
+
l || y("invalid JSON value"), t += l[0].length;
|
|
176
|
+
const d = Number(l[0]);
|
|
177
|
+
return Number.isFinite(d) || y("wire JSON number must be finite"), d;
|
|
178
|
+
};
|
|
179
|
+
i();
|
|
180
|
+
const a = s();
|
|
181
|
+
return i(), t !== e.length && y("wire JSON contains trailing bytes"), a;
|
|
182
|
+
}
|
|
183
|
+
function Wn(e) {
|
|
184
|
+
return typeof e == "string" ? Fn(e) : e;
|
|
185
|
+
}
|
|
186
|
+
function qi(e, t) {
|
|
187
|
+
if (e.byteLength !== t.byteLength) return !1;
|
|
188
|
+
let n = 0;
|
|
189
|
+
for (let i = 0; i < e.byteLength; i += 1) n |= e[i] ^ t[i];
|
|
190
|
+
return n === 0;
|
|
191
|
+
}
|
|
192
|
+
function Z(e, t, n) {
|
|
193
|
+
const i = Wn(e);
|
|
194
|
+
St(i) || y(`${n} must be a JSON object`), Object.getOwnPropertySymbols(i).length !== 0 && y(`${n} has an unknown symbol field`);
|
|
195
|
+
const r = Object.getOwnPropertyNames(i).sort(), s = [...t].sort(), a = Le.encode(r.join("\0")), o = Le.encode(s.join("\0"));
|
|
196
|
+
qi(a, o) || y(`${n} has missing or unknown fields`);
|
|
197
|
+
for (const c of r) {
|
|
198
|
+
const l = Object.getOwnPropertyDescriptor(i, c);
|
|
199
|
+
(!l || !l.enumerable || !("value" in l)) && y(`${n}.${c} must be an enumerable data field`), l.value === void 0 && y(`${n}.${c} must not be undefined`);
|
|
200
|
+
}
|
|
201
|
+
return i;
|
|
202
|
+
}
|
|
203
|
+
function it(e) {
|
|
204
|
+
if (!e || typeof e != "object" || Object.isFrozen(e)) return e;
|
|
205
|
+
for (const t of Object.values(e)) it(t);
|
|
206
|
+
return Object.freeze(e);
|
|
207
|
+
}
|
|
208
|
+
function ae(e) {
|
|
209
|
+
return it(Object.fromEntries([...e].sort(([t], [n]) => t < n ? -1 : t > n ? 1 : 0)));
|
|
210
|
+
}
|
|
211
|
+
function Ht(e, t, n) {
|
|
212
|
+
(!Array.isArray(e) || Object.getPrototypeOf(e) !== Array.prototype || e.length !== t) && y(`${n} must be a plain array with exactly ${t} values`);
|
|
213
|
+
const i = [...Array.from({ length: t }, (s, a) => String(a)), "length"], r = Reflect.ownKeys(e);
|
|
214
|
+
(r.length !== i.length || r.some((s, a) => s !== i[a])) && y(`${n} must be a dense plain array`);
|
|
215
|
+
for (let s = 0; s < t; s += 1) {
|
|
216
|
+
const a = Object.getOwnPropertyDescriptor(e, String(s));
|
|
217
|
+
(!a || !a.enumerable || !("value" in a) || a.value === void 0) && y(`${n} must contain enumerable data values`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function Hi(e) {
|
|
221
|
+
const t = Z(
|
|
222
|
+
e,
|
|
223
|
+
["reviewedTransform", "schemaVersion"],
|
|
224
|
+
"asset review protocol policy"
|
|
225
|
+
);
|
|
226
|
+
S(t.schemaVersion, 1, "asset review protocol schemaVersion");
|
|
227
|
+
const n = Z(t.reviewedTransform, [
|
|
228
|
+
"metersPerSourceUnit",
|
|
229
|
+
"quaternionNormTolerance",
|
|
230
|
+
"scaleComponentExclusiveMin",
|
|
231
|
+
"scaleComponentInclusiveMax",
|
|
232
|
+
"translationComponentAbsMax",
|
|
233
|
+
"upAxes"
|
|
234
|
+
], "asset review transform policy"), i = Z(
|
|
235
|
+
n.metersPerSourceUnit,
|
|
236
|
+
["cm", "km", "m", "mm"],
|
|
237
|
+
"asset review unit policy"
|
|
238
|
+
);
|
|
239
|
+
for (const [r, s] of Object.entries(i))
|
|
240
|
+
(typeof s != "number" || !Number.isFinite(s) || s <= 0) && y(`asset review unit policy ${r} must be positive and finite`);
|
|
241
|
+
for (const [r, s] of [
|
|
242
|
+
["quaternionNormTolerance", n.quaternionNormTolerance],
|
|
243
|
+
["scaleComponentExclusiveMin", n.scaleComponentExclusiveMin],
|
|
244
|
+
["scaleComponentInclusiveMax", n.scaleComponentInclusiveMax],
|
|
245
|
+
["translationComponentAbsMax", n.translationComponentAbsMax]
|
|
246
|
+
])
|
|
247
|
+
(typeof s != "number" || !Number.isFinite(s)) && y(`asset review transform policy ${r} must be finite`);
|
|
248
|
+
return (n.quaternionNormTolerance <= 0 || n.scaleComponentInclusiveMax <= n.scaleComponentExclusiveMin || n.translationComponentAbsMax <= 0) && y("asset review transform policy bounds are inconsistent"), Ht(n.upAxes, 3, "asset review up-axis policy"), n.upAxes.join("\0") !== "X_UP\0Y_UP\0Z_UP" && y("asset review up-axis policy is invalid"), ae([
|
|
249
|
+
["metersPerSourceUnit", ae(Object.entries(i))],
|
|
250
|
+
["quaternionNormTolerance", n.quaternionNormTolerance],
|
|
251
|
+
["scaleComponentExclusiveMin", n.scaleComponentExclusiveMin],
|
|
252
|
+
["scaleComponentInclusiveMax", n.scaleComponentInclusiveMax],
|
|
253
|
+
["translationComponentAbsMax", n.translationComponentAbsMax],
|
|
254
|
+
["upAxes", Object.freeze(Array.from({ length: 3 }, (r, s) => n.upAxes[s]))]
|
|
255
|
+
]);
|
|
256
|
+
}
|
|
257
|
+
const Ce = Hi(Ci);
|
|
258
|
+
function S(e, t, n) {
|
|
259
|
+
return e !== t && y(`${n} must equal ${JSON.stringify(t)}`), e;
|
|
260
|
+
}
|
|
261
|
+
function Gt(e, t, n) {
|
|
262
|
+
return t.includes(e) || y(`${n} is not an allowed value`), e;
|
|
263
|
+
}
|
|
264
|
+
function K(e, t, n) {
|
|
265
|
+
return oe(e, n), t.test(e) || y(`${n} has an invalid encoding`), e;
|
|
266
|
+
}
|
|
267
|
+
function be(e, t) {
|
|
268
|
+
return oe(e, t), (!Ui.test(e) || new Date(e).toISOString() !== e) && y(`${t} must be exact RFC3339 milliseconds UTC`), e;
|
|
269
|
+
}
|
|
270
|
+
function Rt(e, t) {
|
|
271
|
+
const n = Date.parse(e), i = Date.parse(t);
|
|
272
|
+
i > n && i - n <= 3e5 || y("request lifetime must be in (0, 300] seconds");
|
|
273
|
+
}
|
|
274
|
+
function Gi(e, t) {
|
|
275
|
+
(!ArrayBuffer.isView(e) || !(e instanceof Uint8Array) || Object.getPrototypeOf(e) !== Uint8Array.prototype) && y(`${t} must be a plain Uint8Array`), xi.call(e) !== 32 && y(`${t} must be exactly 32 bytes`);
|
|
276
|
+
const i = Array.from({ length: 32 }, (d, u) => String(u)), r = Reflect.ownKeys(e);
|
|
277
|
+
(r.length !== i.length || r.some((d, u) => d !== i[u])) && y(`${t} Uint8Array must contain only 32 indexed bytes`);
|
|
278
|
+
const s = _i.call(e);
|
|
279
|
+
let a = !1;
|
|
280
|
+
if (pn)
|
|
281
|
+
try {
|
|
282
|
+
pn.call(s), a = !0;
|
|
283
|
+
} catch {
|
|
284
|
+
a = !1;
|
|
285
|
+
}
|
|
286
|
+
a && y(`${t} must not use SharedArrayBuffer storage`);
|
|
287
|
+
try {
|
|
288
|
+
Di.call(s);
|
|
289
|
+
} catch {
|
|
290
|
+
y(`${t} must use ArrayBuffer storage`);
|
|
291
|
+
}
|
|
292
|
+
const o = new Uint8Array(32);
|
|
293
|
+
for (let d = 0; d < 32; d += 1) {
|
|
294
|
+
const u = Object.getOwnPropertyDescriptor(e, String(d));
|
|
295
|
+
(!u || !u.enumerable || !("value" in u) || !Number.isInteger(u.value) || u.value < 0 || u.value > 255) && y(`${t} Uint8Array contains an invalid indexed byte`), o[d] = e[d];
|
|
296
|
+
}
|
|
297
|
+
let c = "";
|
|
298
|
+
for (let d = 0; d < 32; d += 1) c += String.fromCharCode(o[d]);
|
|
299
|
+
const l = globalThis.btoa(c).replace(/\+/gu, "-").replace(/\//gu, "_").replace(/=+$/gu, "");
|
|
300
|
+
return l.length !== 43 && y(`${t} did not encode to 43 base64url characters`), l;
|
|
301
|
+
}
|
|
302
|
+
function zn(e, t) {
|
|
303
|
+
oe(e, t), /^[A-Za-z0-9_-]{43}$/u.test(e) || y(`${t} must be canonical unpadded base64url`);
|
|
304
|
+
let n;
|
|
305
|
+
try {
|
|
306
|
+
n = globalThis.atob(`${e.replace(/-/gu, "+").replace(/_/gu, "/")}=`);
|
|
307
|
+
} catch {
|
|
308
|
+
y(`${t} must be valid base64url`);
|
|
309
|
+
}
|
|
310
|
+
const i = Uint8Array.from(n, (r) => r.charCodeAt(0));
|
|
311
|
+
return (i.byteLength !== 32 || Gi(i, t) !== e) && y(`${t} must canonically encode exactly 32 bytes`), e;
|
|
312
|
+
}
|
|
313
|
+
function Ki(e) {
|
|
314
|
+
let t = 0, n = 0, i = "";
|
|
315
|
+
for (const r of e)
|
|
316
|
+
for (t = t << 8 | r, n += 8; n >= 5; )
|
|
317
|
+
n -= 5, i += jt[t >>> n & 31], t &= (1 << n) - 1;
|
|
318
|
+
return n !== 0 && (i += jt[t << 5 - n & 31]), i;
|
|
319
|
+
}
|
|
320
|
+
function Ji(e, t) {
|
|
321
|
+
oe(e, "modelCid"), Bi.test(e) || y("modelCid must be canonical CIDv1 raw sha2-256 base32");
|
|
322
|
+
let n = 0, i = 0;
|
|
323
|
+
const r = [];
|
|
324
|
+
for (const o of e.slice(1)) {
|
|
325
|
+
const c = jt.indexOf(o);
|
|
326
|
+
c < 0 && y("modelCid contains invalid base32"), n = n << 5 | c, i += 5, i >= 8 && (i -= 8, r.push(n >>> i & 255), n &= (1 << i) - 1);
|
|
327
|
+
}
|
|
328
|
+
(i !== 0 && n !== 0 || r.length !== 36) && y("modelCid has noncanonical base32 tail bits or length");
|
|
329
|
+
const s = Uint8Array.from(r);
|
|
330
|
+
(s[0] !== 1 || s[1] !== 85 || s[2] !== 18 || s[3] !== 32) && y("modelCid must encode CIDv1 raw sha2-256 with a 32-byte digest"), `b${Ki(s)}` !== e && y("modelCid base32 is not canonical");
|
|
331
|
+
let a = 0;
|
|
332
|
+
for (let o = 0; o < 32; o += 1) {
|
|
333
|
+
const c = Number.parseInt(t.slice(o * 2, o * 2 + 2), 16);
|
|
334
|
+
a |= s[o + 4] ^ c;
|
|
335
|
+
}
|
|
336
|
+
return a !== 0 && y("modelCid digest does not match modelSha256"), e;
|
|
337
|
+
}
|
|
338
|
+
function Vt(e) {
|
|
339
|
+
return e === null || typeof e == "boolean" ? JSON.stringify(e) : typeof e == "string" ? (oe(e, "canonical JSON string"), JSON.stringify(e)) : typeof e == "number" ? (Number.isFinite(e) || y("canonical JSON numbers must be finite"), JSON.stringify(e)) : Array.isArray(e) ? `[${e.map(Vt).join(",")}]` : (St(e) || y("canonical JSON contains an unsupported value"), `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${Vt(e[t])}`).join(",")}}`);
|
|
340
|
+
}
|
|
341
|
+
function Kt(e, t) {
|
|
342
|
+
for (const n of ["identityScheme", "keyId", "signatureProfile"])
|
|
343
|
+
e[n] !== t[n] && y(`canonicalEnvelope ${n} must match the signature result`);
|
|
344
|
+
}
|
|
345
|
+
function Qi(e, t) {
|
|
346
|
+
const i = Z(e, [
|
|
347
|
+
"audience",
|
|
348
|
+
"challengeSha256",
|
|
349
|
+
"clientId",
|
|
350
|
+
"expiresAt",
|
|
351
|
+
"identityScheme",
|
|
352
|
+
"issuedAt",
|
|
353
|
+
"keyId",
|
|
354
|
+
"kind",
|
|
355
|
+
"nonce",
|
|
356
|
+
"protocolVersion",
|
|
357
|
+
"requestOrigin",
|
|
358
|
+
"signatureProfile"
|
|
359
|
+
], "SDN login canonicalEnvelope");
|
|
360
|
+
Kt(i, t), S(i.audience, Ut, "SDN login envelope audience"), K(i.challengeSha256, se, "SDN login envelope challengeSha256"), S(i.clientId, "sdn-node-console-v1", "SDN login envelope clientId"), be(i.issuedAt, "SDN login envelope issuedAt"), be(i.expiresAt, "SDN login envelope expiresAt"), Rt(i.issuedAt, i.expiresAt), S(i.identityScheme, we, "SDN login envelope identityScheme"), K(i.keyId, Me, "SDN login envelope keyId"), S(i.kind, "sdn-login", "SDN login envelope kind"), K(i.nonce, se, "SDN login envelope nonce"), S(i.protocolVersion, 2, "SDN login envelope protocolVersion"), S(i.requestOrigin, "https://sdn.spaceaware.io", "SDN login envelope requestOrigin"), S(i.signatureProfile, xe, "SDN login envelope signatureProfile");
|
|
361
|
+
}
|
|
362
|
+
function Yi(e, t) {
|
|
363
|
+
const n = Z(
|
|
364
|
+
e,
|
|
365
|
+
[...ht, "kind"],
|
|
366
|
+
"authority activation canonicalEnvelope"
|
|
367
|
+
);
|
|
368
|
+
Kt(n, t), S(n.kind, "asset-review-authority-activation", "activation envelope kind"), Hn(Object.fromEntries(ht.map((i) => [i, n[i]])));
|
|
369
|
+
}
|
|
370
|
+
function Xi(e, t) {
|
|
371
|
+
const n = e?.decision === "approve" ? ["note", "reviewedTransform"] : e?.decision === "disapprove" ? ["reason"] : [], i = [...Bt, ...n], r = Z(e, [
|
|
372
|
+
...i,
|
|
373
|
+
"identityScheme",
|
|
374
|
+
"keyId",
|
|
375
|
+
"kind",
|
|
376
|
+
"purpose",
|
|
377
|
+
"signatureProfile"
|
|
378
|
+
], "asset review decision canonicalEnvelope");
|
|
379
|
+
Kt(r, t), S(r.identityScheme, we, "decision envelope identityScheme"), K(r.keyId, Me, "decision envelope keyId"), S(r.kind, "asset-review-attestation", "decision envelope kind"), S(r.purpose, "asset-review-approval", "decision envelope purpose"), S(r.signatureProfile, xe, "decision envelope signatureProfile"), Gn(Object.fromEntries(i.map((s) => [s, r[s]])));
|
|
380
|
+
}
|
|
381
|
+
function Zi(e, t, n) {
|
|
382
|
+
oe(e, "canonicalEnvelope"), Le.encode(e).byteLength > $n && y("canonicalEnvelope is too large");
|
|
383
|
+
const i = Fn(e);
|
|
384
|
+
return (!St(i) || i.kind !== t) && y("canonicalEnvelope kind does not match the operation"), Vt(i) !== e && y("canonicalEnvelope must be exact JCS"), t === "sdn-login" ? Qi(i, n) : t === "asset-review-authority-activation" ? Yi(i, n) : t === "asset-review-attestation" ? Xi(i, n) : y("canonicalEnvelope operation is not registered"), e;
|
|
385
|
+
}
|
|
386
|
+
function er(e, t) {
|
|
387
|
+
const n = Z(e, Mi, `identity key ${t.purpose}`);
|
|
388
|
+
return S(n.purpose, t.purpose, "key purpose"), S(n.identityScheme, we, "key identityScheme"), S(n.seedProfile, pt, "key seedProfile"), S(n.signatureProfile, t.signatureProfile, "key signatureProfile"), S(n.curve, t.curve, "key curve"), S(n.derivation, "slip10", "key derivation"), S(n.path, t.path, "key path"), S(n.encoding, "raw", "key encoding"), K(n.publicKeyHex, se, "key publicKeyHex"), S(n.bip32Fingerprint, null, "key bip32Fingerprint"), K(n.keyId, Me, "key keyId"), ae([
|
|
389
|
+
["bip32Fingerprint", null],
|
|
390
|
+
["curve", n.curve],
|
|
391
|
+
["derivation", "slip10"],
|
|
392
|
+
["encoding", "raw"],
|
|
393
|
+
["identityScheme", we],
|
|
394
|
+
["keyId", n.keyId],
|
|
395
|
+
["path", n.path],
|
|
396
|
+
["publicKeyHex", n.publicKeyHex],
|
|
397
|
+
["purpose", n.purpose],
|
|
398
|
+
["seedProfile", pt],
|
|
399
|
+
["signatureProfile", n.signatureProfile]
|
|
400
|
+
]);
|
|
401
|
+
}
|
|
402
|
+
function tr(e) {
|
|
403
|
+
const t = Z(e, Vi, "WalletPublicIdentity");
|
|
404
|
+
S(t.schemaVersion, 1, "identity schemaVersion"), S(t.identityScheme, we, "identity identityScheme"), S(t.seedProfile, pt, "identity seedProfile"), t.accountIndex !== 0 && y("public wallet identity must use account 0"), S(t.accountLabel, null, "identity accountLabel"), oe(t.accountXpub, "identity accountXpub"), /^xpub[1-9A-HJ-NP-Za-km-z]{107}$/u.test(t.accountXpub) || y("identity accountXpub is invalid"), oe(t.accountPeerId, "identity accountPeerId"), (!t.accountPeerId.startsWith("16Uiu2H") || t.accountPeerId.length < 40 || t.accountPeerId.length > 64 || !ji.test(t.accountPeerId)) && y("identity accountPeerId is invalid"), K(t.accountFingerprint, /^[0-9a-f]{8}$/u, "identity accountFingerprint"), Ht(t.keys, 3, "public identity keys array");
|
|
405
|
+
const n = [
|
|
406
|
+
{
|
|
407
|
+
purpose: "asset-review-approval",
|
|
408
|
+
curve: "ed25519",
|
|
409
|
+
signatureProfile: xe,
|
|
410
|
+
path: "m/44'/0'/0'/2'/0'"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
purpose: "contact-encryption",
|
|
414
|
+
curve: "x25519",
|
|
415
|
+
signatureProfile: null,
|
|
416
|
+
path: "m/44'/0'/0'/1'/0'"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
purpose: "sdn-authentication",
|
|
420
|
+
curve: "ed25519",
|
|
421
|
+
signatureProfile: xe,
|
|
422
|
+
path: "m/44'/0'/0'/0'/0'"
|
|
423
|
+
}
|
|
424
|
+
], i = Array.from(
|
|
425
|
+
{ length: 3 },
|
|
426
|
+
(r, s) => er(t.keys[s], n[s])
|
|
427
|
+
);
|
|
428
|
+
return ae([
|
|
429
|
+
["accountFingerprint", t.accountFingerprint],
|
|
430
|
+
["accountIndex", 0],
|
|
431
|
+
["accountLabel", null],
|
|
432
|
+
["accountPeerId", t.accountPeerId],
|
|
433
|
+
["accountXpub", t.accountXpub],
|
|
434
|
+
["identityScheme", we],
|
|
435
|
+
["keys", it(i)],
|
|
436
|
+
["schemaVersion", 1],
|
|
437
|
+
["seedProfile", pt]
|
|
438
|
+
]);
|
|
439
|
+
}
|
|
440
|
+
function qn(e, t) {
|
|
441
|
+
const n = Z(e, $i, `${t} result`);
|
|
442
|
+
S(n.schemaVersion, 1, "connection result schemaVersion"), Gt(n.event, ["connected", "disconnected"], "connection event"), t === "connect" && n.event !== "connected" && y("connect result must be connected");
|
|
443
|
+
let i = null, r = null;
|
|
444
|
+
return n.event === "connected" ? (i = tr(n.identity), r = be(n.connectionExpiresAt, "connectionExpiresAt")) : (n.identity !== null || n.connectionExpiresAt !== null) && y("disconnected result must clear identity and expiry"), ae([
|
|
445
|
+
["connectionExpiresAt", r],
|
|
446
|
+
["event", n.event],
|
|
447
|
+
["identity", i],
|
|
448
|
+
["schemaVersion", 1]
|
|
449
|
+
]);
|
|
450
|
+
}
|
|
451
|
+
function nr(e) {
|
|
452
|
+
const t = Z(e, Fi, "raw signature");
|
|
453
|
+
return S(t.schemaVersion, 1, "signature schemaVersion"), K(t.keyId, Me, "signature keyId"), Gt(t.identityScheme, [
|
|
454
|
+
"sdn-fast-password-auth-v1-legacy",
|
|
455
|
+
"sdn-bip39-auth-v1-legacy"
|
|
456
|
+
], "raw signature identityScheme"), S(t.algorithm, "ed25519", "signature algorithm"), S(t.encoding, "raw", "signature encoding"), S(t.signatureProfile, hn, "signature profile"), K(t.signatureHex, Mn, "signatureHex"), ae([
|
|
457
|
+
["algorithm", "ed25519"],
|
|
458
|
+
["encoding", "raw"],
|
|
459
|
+
["identityScheme", t.identityScheme],
|
|
460
|
+
["keyId", t.keyId],
|
|
461
|
+
["schemaVersion", 1],
|
|
462
|
+
["signatureHex", t.signatureHex],
|
|
463
|
+
["signatureProfile", hn]
|
|
464
|
+
]);
|
|
465
|
+
}
|
|
466
|
+
function Jt(e, t) {
|
|
467
|
+
const n = Z(e, Wi, "canonical signature");
|
|
468
|
+
return S(n.schemaVersion, 1, "signature schemaVersion"), K(n.keyId, Me, "signature keyId"), S(n.identityScheme, we, "signature identityScheme"), S(n.algorithm, "ed25519", "signature algorithm"), S(n.encoding, "raw", "signature encoding"), S(n.signatureProfile, xe, "signature profile"), Zi(n.canonicalEnvelope, t, n), K(n.signedDigestSha256, se, "signedDigestSha256"), K(n.signatureHex, Mn, "signatureHex"), ae([
|
|
469
|
+
["algorithm", "ed25519"],
|
|
470
|
+
["canonicalEnvelope", n.canonicalEnvelope],
|
|
471
|
+
["encoding", "raw"],
|
|
472
|
+
["identityScheme", we],
|
|
473
|
+
["keyId", n.keyId],
|
|
474
|
+
["schemaVersion", 1],
|
|
475
|
+
["signatureHex", n.signatureHex],
|
|
476
|
+
["signatureProfile", xe],
|
|
477
|
+
["signedDigestSha256", n.signedDigestSha256]
|
|
478
|
+
]);
|
|
479
|
+
}
|
|
480
|
+
function ir(e) {
|
|
481
|
+
const t = Z(e, ["challengeBase64url", "protocolVersion"], "SDN login v1 request");
|
|
482
|
+
return S(t.protocolVersion, 1, "SDN login v1 protocolVersion"), zn(t.challengeBase64url, "challengeBase64url"), ae([
|
|
483
|
+
["challengeBase64url", t.challengeBase64url],
|
|
484
|
+
["protocolVersion", 1]
|
|
485
|
+
]);
|
|
486
|
+
}
|
|
487
|
+
function rr(e) {
|
|
488
|
+
const t = Z(e, [
|
|
489
|
+
"audience",
|
|
490
|
+
"challengeBase64url",
|
|
491
|
+
"expiresAt",
|
|
492
|
+
"issuedAt",
|
|
493
|
+
"nonce",
|
|
494
|
+
"protocolVersion"
|
|
495
|
+
], "SDN login v2 request");
|
|
496
|
+
return S(t.protocolVersion, 2, "SDN login v2 protocolVersion"), S(t.audience, Ut, "SDN login v2 audience"), zn(t.challengeBase64url, "challengeBase64url"), K(t.nonce, se, "SDN login nonce"), be(t.issuedAt, "SDN login issuedAt"), be(t.expiresAt, "SDN login expiresAt"), Rt(t.issuedAt, t.expiresAt), ae([
|
|
497
|
+
["audience", Ut],
|
|
498
|
+
["challengeBase64url", t.challengeBase64url],
|
|
499
|
+
["expiresAt", t.expiresAt],
|
|
500
|
+
["issuedAt", t.issuedAt],
|
|
501
|
+
["nonce", t.nonce],
|
|
502
|
+
["protocolVersion", 2]
|
|
503
|
+
]);
|
|
504
|
+
}
|
|
505
|
+
function Hn(e) {
|
|
506
|
+
const t = Z(e, ht, "authority activation request");
|
|
507
|
+
return S(t.protocolVersion, 1, "activation protocolVersion"), S(t.audience, Pi, "activation audience"), S(t.requestOrigin, Bn, "activation requestOrigin"), S(t.clientId, Vn, "activation clientId"), S(t.serviceInstance, "assets.ipfs.01/asset-review-attestation", "activation serviceInstance"), S(t.purpose, "asset-review-authority-activation", "activation purpose"), K(t.nonce, se, "activation nonce"), be(t.issuedAt, "activation issuedAt"), be(t.expiresAt, "activation expiresAt"), Rt(t.issuedAt, t.expiresAt), K(t.publicKeyHex, se, "activation publicKeyHex"), K(t.keyId, Me, "activation keyId"), S(t.identityScheme, we, "activation identityScheme"), S(t.signatureProfile, xe, "activation signatureProfile"), ae(ht.map((n) => [n, t[n]]));
|
|
508
|
+
}
|
|
509
|
+
function Ct(e, t, n) {
|
|
510
|
+
Ht(e, t, `${n} array`);
|
|
511
|
+
const i = Array.from({ length: t }, (r, s) => {
|
|
512
|
+
const a = e[s];
|
|
513
|
+
return (typeof a != "number" || !Number.isFinite(a)) && y(`${n} values must be finite numbers`), a;
|
|
514
|
+
});
|
|
515
|
+
return it(i);
|
|
516
|
+
}
|
|
517
|
+
function sr(e) {
|
|
518
|
+
const t = Z(e, zi, "reviewedTransform"), n = Ct(t.translation, 3, "translation"), i = Ct(t.rotation, 4, "rotation"), r = Ct(t.scale, 3, "scale");
|
|
519
|
+
n.some((a) => Math.abs(a) > Ce.translationComponentAbsMax) && y("translation values exceed the reviewed transform policy"), r.some((a) => a <= Ce.scaleComponentExclusiveMin || a > Ce.scaleComponentInclusiveMax) && y("scale values exceed the reviewed transform policy");
|
|
520
|
+
const s = Math.hypot(...i);
|
|
521
|
+
return Math.abs(s - 1) > Ce.quaternionNormTolerance && y("rotation must be a unit quaternion within the reviewed tolerance"), Gt(t.upAxis, Ce.upAxes, "upAxis"), oe(t.sourceUnits, "sourceUnits"), Object.hasOwn(Ce.metersPerSourceUnit, t.sourceUnits) || y("sourceUnits is not allowed by the reviewed transform policy"), (typeof t.metersPerSourceUnit != "number" || !Number.isFinite(t.metersPerSourceUnit) || t.metersPerSourceUnit !== Ce.metersPerSourceUnit[t.sourceUnits]) && y("metersPerSourceUnit must exactly match sourceUnits"), ae([
|
|
522
|
+
["metersPerSourceUnit", t.metersPerSourceUnit],
|
|
523
|
+
["rotation", i],
|
|
524
|
+
["scale", r],
|
|
525
|
+
["sourceUnits", t.sourceUnits],
|
|
526
|
+
["translation", n],
|
|
527
|
+
["upAxis", t.upAxis]
|
|
528
|
+
]);
|
|
529
|
+
}
|
|
530
|
+
function yn(e) {
|
|
531
|
+
return e >= 9 && e <= 13 || e === 32 || e === 160 || e === 5760 || e >= 8192 && e <= 8202 || e === 8232 || e === 8233 || e === 8239 || e === 8287 || e === 12288 || e === 65279;
|
|
532
|
+
}
|
|
533
|
+
function mn(e, t, n) {
|
|
534
|
+
if (n && e === null) return null;
|
|
535
|
+
oe(e, t), (e.length === 0 || Le.encode(e).byteLength > 2e3) && y(`${t} has an invalid length`);
|
|
536
|
+
const i = Array.from(e, (r) => r.codePointAt(0));
|
|
537
|
+
return (yn(i[0]) || yn(i[i.length - 1])) && y(`${t} must already be trimmed`), e;
|
|
538
|
+
}
|
|
539
|
+
function Gn(e) {
|
|
540
|
+
const t = Wn(e);
|
|
541
|
+
St(t) || y("asset review decision request must be a JSON object");
|
|
542
|
+
const n = Object.getOwnPropertyDescriptor(t, "decision");
|
|
543
|
+
(!n || !n.enumerable || !("value" in n) || n.value === void 0) && y("asset review decision request has an invalid decision field");
|
|
544
|
+
const i = n.value, r = i === "approve" ? ["note", "reviewedTransform"] : i === "disapprove" ? ["reason"] : [], s = Z(t, [...Bt, ...r], "asset review decision request");
|
|
545
|
+
S(s.protocolVersion, 1, "decision protocolVersion"), S(s.audience, ki, "decision audience"), S(s.requestOrigin, Bn, "decision requestOrigin"), S(s.clientId, Vn, "decision clientId"), K(s.challengeId, se, "challengeId"), K(s.nonce, se, "decision nonce"), be(s.issuedAt, "decision issuedAt"), be(s.expiresAt, "decision expiresAt"), Rt(s.issuedAt, s.expiresAt), K(s.modelSha256, se, "modelSha256"), K(s.metadataSha256, se, "metadataSha256"), s.previousDecisionHead !== null && K(s.previousDecisionHead, se, "previousDecisionHead"), Ji(s.modelCid, s.modelSha256), (!Number.isSafeInteger(s.modelBytes) || s.modelBytes <= 0) && y("modelBytes must be a positive safe integer"), oe(s.candidateKey, "candidateKey");
|
|
546
|
+
const a = "asset-review:", o = `:${s.modelSha256}`;
|
|
547
|
+
(!s.candidateKey.startsWith(a) || !s.candidateKey.endsWith(o) || Le.encode(s.candidateKey).byteLength > 206) && y("candidateKey does not bind the model digest");
|
|
548
|
+
const c = s.candidateKey.slice(a.length, -o.length);
|
|
549
|
+
(!/^[a-z0-9-]+\/[a-z0-9][a-z0-9-]*$/u.test(c) || Le.encode(c).byteLength > 128) && y("candidateKey entityId is invalid");
|
|
550
|
+
const l = Bt.map((u) => [u, s[u]]);
|
|
551
|
+
return i === "approve" ? (l.push(["note", mn(s.note, "note", !0)]), l.push(["reviewedTransform", sr(s.reviewedTransform)])) : l.push(["reason", mn(s.reason, "reason", !1)]), Object.values(s).filter((u) => typeof u == "string").reduce((u, f) => u + Le.encode(f).byteLength, 0) > 16384 && y("decision request strings exceed 16 KiB"), ae(l);
|
|
552
|
+
}
|
|
553
|
+
function Kn(e, t) {
|
|
554
|
+
return Z(e, [], t), it({});
|
|
555
|
+
}
|
|
556
|
+
function or(e) {
|
|
557
|
+
return Kn(e, "wallet connect request");
|
|
558
|
+
}
|
|
559
|
+
function ar(e) {
|
|
560
|
+
return qn(e, "connect");
|
|
561
|
+
}
|
|
562
|
+
function cr(e) {
|
|
563
|
+
return Kn(e, "wallet account request");
|
|
564
|
+
}
|
|
565
|
+
function Jn(e) {
|
|
566
|
+
return qn(e, "account");
|
|
567
|
+
}
|
|
568
|
+
function lr(e) {
|
|
569
|
+
return ir(e);
|
|
570
|
+
}
|
|
571
|
+
function ur(e) {
|
|
572
|
+
return nr(e);
|
|
573
|
+
}
|
|
574
|
+
function dr(e) {
|
|
575
|
+
return rr(e);
|
|
576
|
+
}
|
|
577
|
+
function fr(e) {
|
|
578
|
+
return Jt(e, "sdn-login");
|
|
579
|
+
}
|
|
580
|
+
function pr(e) {
|
|
581
|
+
return Hn(e);
|
|
582
|
+
}
|
|
583
|
+
function hr(e) {
|
|
584
|
+
return Jt(e, "asset-review-authority-activation");
|
|
585
|
+
}
|
|
586
|
+
function yr(e) {
|
|
587
|
+
return Gn(e);
|
|
588
|
+
}
|
|
589
|
+
function mr(e) {
|
|
590
|
+
return Jt(e, "asset-review-attestation");
|
|
591
|
+
}
|
|
592
|
+
const gr = Object.freeze([
|
|
593
|
+
"callbackUri",
|
|
594
|
+
"clientDisplayName",
|
|
595
|
+
"clientId",
|
|
596
|
+
"expiresAt",
|
|
597
|
+
"operation",
|
|
598
|
+
"registryVersion",
|
|
599
|
+
"request",
|
|
600
|
+
"requestOrigin",
|
|
601
|
+
"requestSha256",
|
|
602
|
+
"resultToken",
|
|
603
|
+
"schemaVersion",
|
|
604
|
+
"state",
|
|
605
|
+
"transactionId"
|
|
606
|
+
]), _t = /^[0-9a-f]{64}$/u, Qn = /^[A-Za-z0-9_-]{43}$/u, Ar = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u, Er = new TextEncoder(), Yn = Object.freeze({
|
|
607
|
+
"sdn.auth.jcs-envelope.v2": Object.freeze({
|
|
608
|
+
parseRequest: dr,
|
|
609
|
+
buildResult: fr,
|
|
610
|
+
sign(e, t, n, i) {
|
|
611
|
+
return e.signSdnLoginV2(t, n, i.registryRow);
|
|
612
|
+
}
|
|
613
|
+
}),
|
|
614
|
+
"sdn.auth.raw-challenge.v1": Object.freeze({
|
|
615
|
+
parseRequest: lr,
|
|
616
|
+
buildResult: ur,
|
|
617
|
+
sign(e, t, n) {
|
|
618
|
+
return e.signSdnLoginV1(t, Rr(n.challengeBase64url));
|
|
619
|
+
}
|
|
620
|
+
}),
|
|
621
|
+
"sdn.asset-review.authority-activation.v1": Object.freeze({
|
|
622
|
+
parseRequest: pr,
|
|
623
|
+
buildResult: hr,
|
|
624
|
+
sign(e, t, n, i) {
|
|
625
|
+
return e.signAssetReviewAuthorityActivation(t, n, i.registryRow);
|
|
626
|
+
}
|
|
627
|
+
}),
|
|
628
|
+
"sdn.asset-review.decision.v1": Object.freeze({
|
|
629
|
+
parseRequest: yr,
|
|
630
|
+
buildResult: mr,
|
|
631
|
+
sign(e, t, n, i) {
|
|
632
|
+
return e.signAssetReviewDecision(t, n, i.registryRow);
|
|
633
|
+
}
|
|
634
|
+
}),
|
|
635
|
+
"sdn.wallet.account.v1": Object.freeze({
|
|
636
|
+
parseRequest: cr,
|
|
637
|
+
buildResult: Jn,
|
|
638
|
+
connect: !0
|
|
639
|
+
}),
|
|
640
|
+
"sdn.wallet.connect.v1": Object.freeze({
|
|
641
|
+
parseRequest: or,
|
|
642
|
+
buildResult: ar,
|
|
643
|
+
connect: !0
|
|
644
|
+
})
|
|
645
|
+
});
|
|
646
|
+
class Ne extends Error {
|
|
647
|
+
constructor(t) {
|
|
648
|
+
super(t), this.name = "WalletOperationError", this.code = t;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
function $(e) {
|
|
652
|
+
throw new Ne(e);
|
|
653
|
+
}
|
|
654
|
+
function Qt(e) {
|
|
655
|
+
if (e === null || typeof e != "object" || Array.isArray(e)) return !1;
|
|
656
|
+
const t = Object.getPrototypeOf(e);
|
|
657
|
+
return t === Object.prototype || t === null;
|
|
658
|
+
}
|
|
659
|
+
function wr(e, t, n = "INVALID_TRANSACTION") {
|
|
660
|
+
Qt(e) || $(n);
|
|
661
|
+
let i;
|
|
662
|
+
try {
|
|
663
|
+
i = Reflect.ownKeys(e);
|
|
664
|
+
} catch {
|
|
665
|
+
$(n);
|
|
666
|
+
}
|
|
667
|
+
i.some((o) => typeof o != "string") && $(n);
|
|
668
|
+
const r = [...i].sort(), s = [...t].sort();
|
|
669
|
+
(r.length !== s.length || r.some((o, c) => o !== s[c])) && $(n);
|
|
670
|
+
const a = /* @__PURE__ */ Object.create(null);
|
|
671
|
+
for (const o of r) {
|
|
672
|
+
let c;
|
|
673
|
+
try {
|
|
674
|
+
c = Object.getOwnPropertyDescriptor(e, o);
|
|
675
|
+
} catch {
|
|
676
|
+
$(n);
|
|
677
|
+
}
|
|
678
|
+
(!c?.enumerable || !("value" in c) || c.value === void 0) && $(n), a[o] = c.value;
|
|
679
|
+
}
|
|
680
|
+
return a;
|
|
681
|
+
}
|
|
682
|
+
function br(e, t = "INVALID_TRANSACTION") {
|
|
683
|
+
(typeof e != "string" || !Ar.test(e)) && $(t);
|
|
684
|
+
const n = Date.parse(e);
|
|
685
|
+
return (!Number.isFinite(n) || new Date(n).toISOString() !== e) && $(t), n;
|
|
686
|
+
}
|
|
687
|
+
function Xe(e) {
|
|
688
|
+
if (Array.isArray(e)) return Object.freeze(e.map(Xe));
|
|
689
|
+
if (!Qt(e)) return e;
|
|
690
|
+
const t = {};
|
|
691
|
+
for (const n of Object.keys(e).sort()) t[n] = Xe(e[n]);
|
|
692
|
+
return Object.freeze(t);
|
|
693
|
+
}
|
|
694
|
+
function yt(e) {
|
|
695
|
+
return e === null || typeof e == "boolean" || typeof e == "string" ? JSON.stringify(e) : typeof e == "number" ? (Number.isFinite(e) || $("INVALID_TRANSACTION"), JSON.stringify(e)) : Array.isArray(e) ? `[${e.map(yt).join(",")}]` : (Qt(e) || $("INVALID_TRANSACTION"), `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${yt(e[t])}`).join(",")}}`);
|
|
696
|
+
}
|
|
697
|
+
async function Ir(e, t) {
|
|
698
|
+
typeof t != "function" && $("CRYPTO_UNAVAILABLE");
|
|
699
|
+
let n;
|
|
700
|
+
try {
|
|
701
|
+
n = await t(Er.encode(yt(e)));
|
|
702
|
+
} catch {
|
|
703
|
+
$("CRYPTO_UNAVAILABLE");
|
|
704
|
+
}
|
|
705
|
+
return (!(n instanceof Uint8Array) || n.byteLength !== 32) && $("CRYPTO_UNAVAILABLE"), Array.from(n, (i) => i.toString(16).padStart(2, "0")).join("");
|
|
706
|
+
}
|
|
707
|
+
function vr(e, t) {
|
|
708
|
+
if (typeof e != "string" || typeof t != "string") return !1;
|
|
709
|
+
const n = Math.max(e.length, t.length);
|
|
710
|
+
let i = e.length ^ t.length;
|
|
711
|
+
for (let r = 0; r < n; r += 1)
|
|
712
|
+
i |= (e.charCodeAt(r) || 0) ^ (t.charCodeAt(r) || 0);
|
|
713
|
+
return i === 0;
|
|
714
|
+
}
|
|
715
|
+
function Sr(e, t) {
|
|
716
|
+
try {
|
|
717
|
+
if (typeof e?.resolveRegistryBinding == "function")
|
|
718
|
+
return e.resolveRegistryBinding(t);
|
|
719
|
+
if (typeof e?.resolve == "function") return e.resolve(t);
|
|
720
|
+
if (typeof e == "function") return e(t);
|
|
721
|
+
} catch (n) {
|
|
722
|
+
if (n instanceof Ne) throw n;
|
|
723
|
+
$("UNREGISTERED_TRANSACTION");
|
|
724
|
+
}
|
|
725
|
+
$("UNREGISTERED_TRANSACTION");
|
|
726
|
+
}
|
|
727
|
+
function ne({ document: e, window: t }) {
|
|
728
|
+
let n = !1;
|
|
729
|
+
try {
|
|
730
|
+
n = t?.top === t;
|
|
731
|
+
} catch {
|
|
732
|
+
n = !1;
|
|
733
|
+
}
|
|
734
|
+
(!n || e?.visibilityState !== "visible" || typeof e?.hasFocus != "function" || e.hasFocus() !== !0) && $("WALLET_CONTEXT_UNTRUSTED");
|
|
735
|
+
}
|
|
736
|
+
async function xt(e, {
|
|
737
|
+
registry: t,
|
|
738
|
+
relay: n,
|
|
739
|
+
sha256: i,
|
|
740
|
+
window: r,
|
|
741
|
+
now: s = () => Date.now(),
|
|
742
|
+
expectedTransactionId: a = null
|
|
743
|
+
}) {
|
|
744
|
+
const o = wr(e, gr);
|
|
745
|
+
(o.schemaVersion !== 1 || typeof o.clientDisplayName != "string" || o.clientDisplayName.length < 1 || o.clientDisplayName.length > 80 || !_t.test(o.transactionId) || !_t.test(o.state) || !_t.test(o.requestSha256) || !Qn.test(o.resultToken)) && $("INVALID_TRANSACTION"), a !== null && o.transactionId !== a && $("INVALID_TRANSACTION");
|
|
746
|
+
const c = Yn[o.operation];
|
|
747
|
+
c || $("UNREGISTERED_TRANSACTION");
|
|
748
|
+
const l = Sr(t, {
|
|
749
|
+
clientId: o.clientId,
|
|
750
|
+
operation: o.operation,
|
|
751
|
+
requestOrigin: o.requestOrigin
|
|
752
|
+
});
|
|
753
|
+
(l.registryReleaseSha256 !== o.registryVersion || l.callbackUri !== o.callbackUri || l.clientDisplayName !== o.clientDisplayName || l.clientId !== o.clientId || l.operation !== o.operation || l.requestOrigin !== o.requestOrigin) && $("REGISTRY_BINDING_MISMATCH");
|
|
754
|
+
const d = s(), u = br(o.expiresAt);
|
|
755
|
+
(!Number.isFinite(d) || u <= d || u - d > l.maxLifetimeSeconds * 1e3) && $("TRANSACTION_EXPIRED");
|
|
756
|
+
let f;
|
|
757
|
+
try {
|
|
758
|
+
f = c.parseRequest(o.request);
|
|
759
|
+
} catch {
|
|
760
|
+
$("INVALID_TRANSACTION");
|
|
761
|
+
}
|
|
762
|
+
let p;
|
|
763
|
+
try {
|
|
764
|
+
p = await Ir(f, i);
|
|
765
|
+
} catch (E) {
|
|
766
|
+
if (E instanceof Ne) throw E;
|
|
767
|
+
$("CRYPTO_UNAVAILABLE");
|
|
768
|
+
}
|
|
769
|
+
vr(p, o.requestSha256) || $("REQUEST_HASH_MISMATCH");
|
|
770
|
+
const g = { ...o, request: f };
|
|
771
|
+
return Object.freeze({
|
|
772
|
+
binding: Xe(l),
|
|
773
|
+
operation: c,
|
|
774
|
+
request: Xe(f),
|
|
775
|
+
transaction: Xe(g)
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
function Rr(e) {
|
|
779
|
+
Qn.test(e) || $("INVALID_TRANSACTION");
|
|
780
|
+
let t;
|
|
781
|
+
try {
|
|
782
|
+
t = globalThis.atob(`${e.replace(/-/gu, "+").replace(/_/gu, "/")}=`);
|
|
783
|
+
} catch {
|
|
784
|
+
$("INVALID_TRANSACTION");
|
|
785
|
+
}
|
|
786
|
+
const n = Uint8Array.from(t, (i) => i.charCodeAt(0));
|
|
787
|
+
return n.byteLength !== 32 && $("INVALID_TRANSACTION"), n;
|
|
788
|
+
}
|
|
789
|
+
function de(e, t, n, i) {
|
|
790
|
+
const r = e.createElement("div");
|
|
791
|
+
r.className = "wallet-confirmation-row";
|
|
792
|
+
const s = e.createElement("strong");
|
|
793
|
+
s.textContent = `${n}: `;
|
|
794
|
+
const a = e.createElement("span");
|
|
795
|
+
a.textContent = i === null ? "null" : typeof i == "string" ? i : yt(i), r.append(s, a), t.append(r);
|
|
796
|
+
}
|
|
797
|
+
function Lr(e, {
|
|
798
|
+
binding: t,
|
|
799
|
+
document: n,
|
|
800
|
+
identity: i = null,
|
|
801
|
+
request: r,
|
|
802
|
+
transaction: s = null
|
|
803
|
+
}) {
|
|
804
|
+
e.replaceChildren();
|
|
805
|
+
const a = n.createElement("h1");
|
|
806
|
+
a.id = "wallet-confirmation-heading", a.textContent = "Confirm wallet action", e.append(a), de(n, e, "Client", t.clientDisplayName), de(n, e, "Requesting origin", t.requestOrigin), de(n, e, "Operation", t.operation), t.audience !== void 0 && de(n, e, "Audience", t.audience), t.callbackUri !== void 0 && de(n, e, "Callback URI", t.callbackUri), s && (de(n, e, "Transaction ID", s.transactionId), de(n, e, "Request hash", s.requestSha256), de(n, e, "Registry release", s.registryVersion), de(n, e, "Transaction expiry", s.expiresAt));
|
|
807
|
+
const o = t.operation.startsWith("sdn.asset-review.") ? "asset-review-approval" : t.operation.startsWith("sdn.auth.") ? "sdn-authentication" : null, c = o && Array.isArray(i?.keys) ? i.keys.find((l) => l?.purpose === o) : null;
|
|
808
|
+
c?.keyId && de(n, e, "Signing key ID", c.keyId);
|
|
809
|
+
for (const l of Object.keys(r).sort()) de(n, e, l, r[l]);
|
|
810
|
+
return e;
|
|
811
|
+
}
|
|
812
|
+
function Or({ binding: e, document: t, identity: n = null, request: i, transaction: r = null }) {
|
|
813
|
+
const s = t.activeElement ?? null, a = t.createElement("section");
|
|
814
|
+
a.className = "wallet-confirmation", a.setAttribute?.("role", "dialog"), a.setAttribute?.("aria-modal", "true"), a.setAttribute?.("aria-labelledby", "wallet-confirmation-heading"), a.tabIndex = -1, Lr(a, { binding: e, document: t, identity: n, request: i, transaction: r });
|
|
815
|
+
const o = t.createElement("div");
|
|
816
|
+
o.className = "wallet-confirmation-actions";
|
|
817
|
+
const c = t.createElement("button");
|
|
818
|
+
c.type = "button", c.dataset.walletAction = "confirm", c.textContent = i?.decision === "approve" ? "Approve" : i?.decision === "disapprove" ? "Disapprove" : e.operation === "sdn.asset-review.authority-activation.v1" ? "Activate" : "Confirm";
|
|
819
|
+
const l = t.createElement("button");
|
|
820
|
+
l.type = "button", l.dataset.walletAction = "cancel", l.textContent = "Cancel", o.append(c, l), a.append(o), t.body.append(a);
|
|
821
|
+
let d = !1, u, f;
|
|
822
|
+
const p = new Promise((N, v) => {
|
|
823
|
+
u = N, f = v;
|
|
824
|
+
}), g = (N, v) => {
|
|
825
|
+
d || v?.isTrusted !== !0 || (d = !0, c.disabled = !0, l.disabled = !0, N ? u() : f(new Ne("USER_CANCELLED")));
|
|
826
|
+
}, E = (N) => g(!0, N), h = (N) => g(!1, N), A = (N) => {
|
|
827
|
+
if (N?.isTrusted !== !0) return;
|
|
828
|
+
if (N.key === "Escape") {
|
|
829
|
+
N.preventDefault?.(), g(!1, N);
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
if (N.key !== "Tab") return;
|
|
833
|
+
N.preventDefault?.();
|
|
834
|
+
const v = t.activeElement;
|
|
835
|
+
N.shiftKey === !0 ? (v === c ? l : c).focus?.() : (v === l ? c : l).focus?.();
|
|
836
|
+
}, m = (N) => {
|
|
837
|
+
let v = !1;
|
|
838
|
+
try {
|
|
839
|
+
v = a.contains?.(N?.target) === !0;
|
|
840
|
+
} catch {
|
|
841
|
+
v = !1;
|
|
842
|
+
}
|
|
843
|
+
v || c.focus?.();
|
|
844
|
+
};
|
|
845
|
+
c.addEventListener("click", E), l.addEventListener("click", h), a.addEventListener("keydown", A), t.addEventListener?.("focusin", m);
|
|
846
|
+
try {
|
|
847
|
+
c.focus?.();
|
|
848
|
+
} catch {
|
|
849
|
+
}
|
|
850
|
+
return Object.freeze({
|
|
851
|
+
promise: p,
|
|
852
|
+
cancel(N = "STALE_CONTROLLER") {
|
|
853
|
+
d || (d = !0, f(new Ne(N)));
|
|
854
|
+
},
|
|
855
|
+
destroy() {
|
|
856
|
+
c.removeEventListener?.("click", E), l.removeEventListener?.("click", h), a.removeEventListener?.("keydown", A), t.removeEventListener?.("focusin", m), a.remove();
|
|
857
|
+
try {
|
|
858
|
+
s?.focus?.();
|
|
859
|
+
} catch {
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
async function Nr({
|
|
865
|
+
assertCurrent: e = () => {
|
|
866
|
+
},
|
|
867
|
+
binding: t,
|
|
868
|
+
handle: n,
|
|
869
|
+
identity: i,
|
|
870
|
+
transaction: r,
|
|
871
|
+
wasm: s
|
|
872
|
+
}) {
|
|
873
|
+
const a = s?.sdn ?? s, o = Yn[r.operation];
|
|
874
|
+
if ((!o || !a) && $("OPERATION_NOT_ALLOWED"), o.connect)
|
|
875
|
+
return o.buildResult({
|
|
876
|
+
connectionExpiresAt: r.expiresAt,
|
|
877
|
+
event: "connected",
|
|
878
|
+
identity: i,
|
|
879
|
+
schemaVersion: 1
|
|
880
|
+
});
|
|
881
|
+
let c;
|
|
882
|
+
try {
|
|
883
|
+
c = await o.sign(a, n, r.request, t);
|
|
884
|
+
} catch (l) {
|
|
885
|
+
throw l;
|
|
886
|
+
}
|
|
887
|
+
e();
|
|
888
|
+
try {
|
|
889
|
+
return o.buildResult(c);
|
|
890
|
+
} catch {
|
|
891
|
+
$("INVALID_WALLET_RESULT");
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
function Tr() {
|
|
895
|
+
return Jn({
|
|
896
|
+
connectionExpiresAt: null,
|
|
897
|
+
event: "disconnected",
|
|
898
|
+
identity: null,
|
|
899
|
+
schemaVersion: 1
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
const gn = "webauthn-prf-hkdf-sha256-aes256gcm-v2", Cr = "sdn-bip32-slip10-purpose-v1", _r = "password-scrypt-v2", xr = Object.freeze([
|
|
903
|
+
"aad",
|
|
904
|
+
"canonicalUsername",
|
|
905
|
+
"ciphertextBase64url",
|
|
906
|
+
"createdAt",
|
|
907
|
+
"credentialIdBase64url",
|
|
908
|
+
"hkdfSaltBase64url",
|
|
909
|
+
"nonceBase64url",
|
|
910
|
+
"prfInputBase64url",
|
|
911
|
+
"schemaVersion",
|
|
912
|
+
"storageProfile"
|
|
913
|
+
]), Dr = Object.freeze([
|
|
914
|
+
"credentialIdBase64url",
|
|
915
|
+
"identityScheme",
|
|
916
|
+
"schemaVersion",
|
|
917
|
+
"seedProfile",
|
|
918
|
+
"storageProfile",
|
|
919
|
+
"usernameSha256"
|
|
920
|
+
]), kr = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u, Pr = /^[0-9a-f]{64}$/u, Ur = /^[A-Za-z0-9_-]+$/u, jr = new TextEncoder(), ie = "sdn.wallet.remembered.v2", Oe = `${ie}.pending`, ut = 16 * 1024, Xn = Object.freeze([
|
|
921
|
+
"wallet_storage_metadata",
|
|
922
|
+
"wallet_storage_encrypted",
|
|
923
|
+
"wallet_storage_passkey_credential",
|
|
924
|
+
"encrypted_wallet",
|
|
925
|
+
"passkey_credential",
|
|
926
|
+
"passkey_wallet"
|
|
927
|
+
]), Zn = /* @__PURE__ */ new Set([
|
|
928
|
+
ie,
|
|
929
|
+
Oe,
|
|
930
|
+
...Xn
|
|
931
|
+
]), Mt = /* @__PURE__ */ new WeakSet();
|
|
932
|
+
class rt extends Error {
|
|
933
|
+
constructor(t) {
|
|
934
|
+
super(t), this.name = "WalletStorageError", this.code = t;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
function T(e) {
|
|
938
|
+
throw new rt(e);
|
|
939
|
+
}
|
|
940
|
+
function ei(e) {
|
|
941
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
942
|
+
const t = Object.getPrototypeOf(e);
|
|
943
|
+
return t === Object.prototype || t === null;
|
|
944
|
+
}
|
|
945
|
+
function An(e, t) {
|
|
946
|
+
ei(e) || T("INVALID_REMEMBERED_WALLET");
|
|
947
|
+
let n;
|
|
948
|
+
try {
|
|
949
|
+
n = Reflect.ownKeys(e);
|
|
950
|
+
} catch {
|
|
951
|
+
T("INVALID_REMEMBERED_WALLET");
|
|
952
|
+
}
|
|
953
|
+
n.some((a) => typeof a != "string") && T("INVALID_REMEMBERED_WALLET");
|
|
954
|
+
const i = [...t].sort(), r = [...n].sort();
|
|
955
|
+
(r.length !== i.length || r.some((a, o) => a !== i[o])) && T("INVALID_REMEMBERED_WALLET");
|
|
956
|
+
const s = {};
|
|
957
|
+
for (const a of i) {
|
|
958
|
+
let o;
|
|
959
|
+
try {
|
|
960
|
+
o = Object.getOwnPropertyDescriptor(e, a);
|
|
961
|
+
} catch {
|
|
962
|
+
T("INVALID_REMEMBERED_WALLET");
|
|
963
|
+
}
|
|
964
|
+
(!o?.enumerable || !("value" in o) || o.value === void 0) && T("INVALID_REMEMBERED_WALLET"), s[a] = o.value;
|
|
965
|
+
}
|
|
966
|
+
return s;
|
|
967
|
+
}
|
|
968
|
+
function En(e) {
|
|
969
|
+
if (typeof e != "string") return !1;
|
|
970
|
+
for (let t = 0; t < e.length; t += 1) {
|
|
971
|
+
const n = e.charCodeAt(t);
|
|
972
|
+
if (n >= 55296 && n <= 56319) {
|
|
973
|
+
const i = e.charCodeAt(++t);
|
|
974
|
+
if (!(i >= 56320 && i <= 57343)) return !1;
|
|
975
|
+
} else if (n >= 56320 && n <= 57343)
|
|
976
|
+
return !1;
|
|
977
|
+
}
|
|
978
|
+
return !0;
|
|
979
|
+
}
|
|
980
|
+
function Br(e) {
|
|
981
|
+
let t = "";
|
|
982
|
+
for (let n = 0; n < e.length; n += 32768)
|
|
983
|
+
t += String.fromCharCode(...e.subarray(n, n + 32768));
|
|
984
|
+
return btoa(t).replace(/\+/gu, "-").replace(/\//gu, "_").replace(/=+$/u, "");
|
|
985
|
+
}
|
|
986
|
+
function me(e, { minimum: t = 0, maximum: n = 65536, exact: i = null } = {}) {
|
|
987
|
+
(typeof e != "string" || e.length === 0 || !Ur.test(e)) && T("INVALID_REMEMBERED_WALLET");
|
|
988
|
+
const r = e.length % 4;
|
|
989
|
+
r === 1 && T("INVALID_REMEMBERED_WALLET");
|
|
990
|
+
const s = e.replace(/-/gu, "+").replace(/_/gu, "/") + "=".repeat((4 - r) % 4);
|
|
991
|
+
let a;
|
|
992
|
+
try {
|
|
993
|
+
a = atob(s);
|
|
994
|
+
} catch {
|
|
995
|
+
T("INVALID_REMEMBERED_WALLET");
|
|
996
|
+
}
|
|
997
|
+
const o = new Uint8Array(a.length);
|
|
998
|
+
for (let c = 0; c < a.length; c += 1) o[c] = a.charCodeAt(c);
|
|
999
|
+
return (Br(o) !== e || o.length < t || o.length > n || i !== null && o.length !== i) && T("INVALID_REMEMBERED_WALLET"), o;
|
|
1000
|
+
}
|
|
1001
|
+
function Yt(e) {
|
|
1002
|
+
return e === null || typeof e == "boolean" || typeof e == "string" || typeof e == "number" && Number.isFinite(e) ? JSON.stringify(e) : (ei(e) || T("INVALID_REMEMBERED_WALLET"), `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${Yt(e[t])}`).join(",")}}`);
|
|
1003
|
+
}
|
|
1004
|
+
function Vr(e) {
|
|
1005
|
+
return Object.freeze({
|
|
1006
|
+
aad: Object.freeze({ ...e.aad }),
|
|
1007
|
+
canonicalUsername: e.canonicalUsername,
|
|
1008
|
+
ciphertextBase64url: e.ciphertextBase64url,
|
|
1009
|
+
createdAt: e.createdAt,
|
|
1010
|
+
credentialIdBase64url: e.credentialIdBase64url,
|
|
1011
|
+
hkdfSaltBase64url: e.hkdfSaltBase64url,
|
|
1012
|
+
nonceBase64url: e.nonceBase64url,
|
|
1013
|
+
prfInputBase64url: e.prfInputBase64url,
|
|
1014
|
+
schemaVersion: e.schemaVersion,
|
|
1015
|
+
storageProfile: e.storageProfile
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
function ti(e) {
|
|
1019
|
+
const t = An(e, xr), n = An(t.aad, Dr), i = En(t.canonicalUsername) ? jr.encode(t.canonicalUsername) : null;
|
|
1020
|
+
return (t.schemaVersion !== 2 || t.storageProfile !== gn || n.schemaVersion !== 2 || n.storageProfile !== gn || n.identityScheme !== Cr || n.seedProfile !== _r || !i || i.length < 3 || i.length > 64 || !/^[a-z0-9][a-z0-9._-]*$/u.test(t.canonicalUsername) || !Pr.test(n.usernameSha256) || t.credentialIdBase64url !== n.credentialIdBase64url || !En(t.createdAt) || !kr.test(t.createdAt) || new Date(t.createdAt).toISOString() !== t.createdAt) && T("INVALID_REMEMBERED_WALLET"), me(t.credentialIdBase64url, { minimum: 1, maximum: 1024 }), me(t.ciphertextBase64url, { minimum: 17, maximum: 1024 }), me(t.hkdfSaltBase64url, { exact: 32 }), me(t.nonceBase64url, { exact: 12 }), me(t.prfInputBase64url, { exact: 32 }), Vr({ ...t, aad: n });
|
|
1021
|
+
}
|
|
1022
|
+
function Mr(e) {
|
|
1023
|
+
return Yt(ti(e));
|
|
1024
|
+
}
|
|
1025
|
+
function Xt(e) {
|
|
1026
|
+
(typeof e != "string" || e.length === 0 || e.length > 131072) && T("INVALID_REMEMBERED_WALLET");
|
|
1027
|
+
let t;
|
|
1028
|
+
try {
|
|
1029
|
+
t = JSON.parse(e);
|
|
1030
|
+
} catch {
|
|
1031
|
+
T("INVALID_REMEMBERED_WALLET");
|
|
1032
|
+
}
|
|
1033
|
+
const n = ti(t);
|
|
1034
|
+
return Yt(n) !== e && T("INVALID_REMEMBERED_WALLET"), n;
|
|
1035
|
+
}
|
|
1036
|
+
function $t(e, t, { pending: n = !1 } = {}) {
|
|
1037
|
+
(!e || typeof e.getItem != "function") && T("STORAGE_UNAVAILABLE");
|
|
1038
|
+
let i;
|
|
1039
|
+
try {
|
|
1040
|
+
i = e.getItem(t);
|
|
1041
|
+
} catch {
|
|
1042
|
+
T("STORAGE_UNAVAILABLE");
|
|
1043
|
+
}
|
|
1044
|
+
if (i === null) return Object.freeze({ raw: null, record: null, status: "empty" });
|
|
1045
|
+
typeof i != "string" && T("STORAGE_UNAVAILABLE");
|
|
1046
|
+
const r = i.length > ut;
|
|
1047
|
+
if (n || r)
|
|
1048
|
+
return Object.freeze({
|
|
1049
|
+
exportable: !r,
|
|
1050
|
+
oversized: r,
|
|
1051
|
+
raw: r ? null : i,
|
|
1052
|
+
rawLength: i.length,
|
|
1053
|
+
record: null,
|
|
1054
|
+
status: "quarantined"
|
|
1055
|
+
});
|
|
1056
|
+
try {
|
|
1057
|
+
const s = Xt(i);
|
|
1058
|
+
return Object.freeze({
|
|
1059
|
+
raw: i,
|
|
1060
|
+
record: s,
|
|
1061
|
+
status: n ? "quarantined" : "valid"
|
|
1062
|
+
});
|
|
1063
|
+
} catch {
|
|
1064
|
+
return Object.freeze({
|
|
1065
|
+
exportable: !0,
|
|
1066
|
+
oversized: !1,
|
|
1067
|
+
raw: i,
|
|
1068
|
+
rawLength: i.length,
|
|
1069
|
+
record: null,
|
|
1070
|
+
status: "quarantined"
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
function ni(e) {
|
|
1075
|
+
const t = $t(e, Oe, { pending: !0 }), n = $t(e, ie), i = t.status === "empty", r = n.status === "empty" || n.status === "valid";
|
|
1076
|
+
return Object.freeze({
|
|
1077
|
+
active: n,
|
|
1078
|
+
canRestore: i && n.status === "valid",
|
|
1079
|
+
canSetup: i && r,
|
|
1080
|
+
pending: t
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
function $r(e, t) {
|
|
1084
|
+
const n = ni(e);
|
|
1085
|
+
n.canSetup || T("STORAGE_QUARANTINED");
|
|
1086
|
+
const i = Mr(t);
|
|
1087
|
+
try {
|
|
1088
|
+
e.setItem(Oe, i);
|
|
1089
|
+
} catch (a) {
|
|
1090
|
+
throw a;
|
|
1091
|
+
}
|
|
1092
|
+
let r;
|
|
1093
|
+
try {
|
|
1094
|
+
r = e.getItem(Oe);
|
|
1095
|
+
} catch {
|
|
1096
|
+
T("STORAGE_UNAVAILABLE");
|
|
1097
|
+
}
|
|
1098
|
+
r !== i && T("STORAGE_WRITE_FAILED"), Xt(r);
|
|
1099
|
+
const s = Object.freeze({
|
|
1100
|
+
previousActiveRaw: n.active.raw,
|
|
1101
|
+
serialized: i,
|
|
1102
|
+
storage: e
|
|
1103
|
+
});
|
|
1104
|
+
return Mt.add(s), s;
|
|
1105
|
+
}
|
|
1106
|
+
function Fr(e, t) {
|
|
1107
|
+
(!Mt.has(t) || t.storage !== e) && T("INVALID_STORAGE_TRANSACTION"), Mt.delete(t);
|
|
1108
|
+
let n, i;
|
|
1109
|
+
try {
|
|
1110
|
+
n = e.getItem(Oe), i = e.getItem(ie);
|
|
1111
|
+
} catch {
|
|
1112
|
+
T("STORAGE_UNAVAILABLE");
|
|
1113
|
+
}
|
|
1114
|
+
(n !== t.serialized || i !== t.previousActiveRaw) && T("STORAGE_COLLISION"), e.removeItem(Oe), e.getItem(Oe) !== null && T("STORAGE_WRITE_FAILED"), e.setItem(ie, t.serialized);
|
|
1115
|
+
}
|
|
1116
|
+
function Zt(e, t) {
|
|
1117
|
+
Zn.has(t) || T("INVALID_STORAGE_KEY"), (!e || typeof e.getItem != "function") && T("STORAGE_UNAVAILABLE");
|
|
1118
|
+
let n;
|
|
1119
|
+
try {
|
|
1120
|
+
n = e.getItem(t);
|
|
1121
|
+
} catch {
|
|
1122
|
+
T("STORAGE_UNAVAILABLE");
|
|
1123
|
+
}
|
|
1124
|
+
if (n === null) return null;
|
|
1125
|
+
if (typeof n != "string" && T("STORAGE_UNAVAILABLE"), t === ie && n.length <= ut)
|
|
1126
|
+
try {
|
|
1127
|
+
Xt(n), T("NOT_QUARANTINED");
|
|
1128
|
+
} catch (i) {
|
|
1129
|
+
if (i instanceof rt && i.code === "NOT_QUARANTINED") throw i;
|
|
1130
|
+
}
|
|
1131
|
+
return Object.freeze({
|
|
1132
|
+
exportable: n.length <= ut,
|
|
1133
|
+
key: t,
|
|
1134
|
+
oversized: n.length > ut,
|
|
1135
|
+
raw: n,
|
|
1136
|
+
rawLength: n.length
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
function Wr(e) {
|
|
1140
|
+
return Object.freeze({
|
|
1141
|
+
exportable: e.exportable,
|
|
1142
|
+
key: e.key,
|
|
1143
|
+
oversized: e.oversized,
|
|
1144
|
+
rawLength: e.rawLength
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
function zr(e) {
|
|
1148
|
+
const t = [];
|
|
1149
|
+
for (const n of [
|
|
1150
|
+
ie,
|
|
1151
|
+
Oe,
|
|
1152
|
+
...Xn
|
|
1153
|
+
]) {
|
|
1154
|
+
let i;
|
|
1155
|
+
try {
|
|
1156
|
+
i = Zt(e, n);
|
|
1157
|
+
} catch (r) {
|
|
1158
|
+
if (r instanceof rt && r.code === "NOT_QUARANTINED") continue;
|
|
1159
|
+
throw r;
|
|
1160
|
+
}
|
|
1161
|
+
i && t.push(Wr(i));
|
|
1162
|
+
}
|
|
1163
|
+
return Object.freeze(t);
|
|
1164
|
+
}
|
|
1165
|
+
function qr(e, t) {
|
|
1166
|
+
const n = Zt(e, t);
|
|
1167
|
+
return n || T("QUARANTINE_NOT_FOUND"), n.exportable || T("QUARANTINE_EXPORT_TOO_LARGE"), n.raw;
|
|
1168
|
+
}
|
|
1169
|
+
function Hr(e, t, n) {
|
|
1170
|
+
Zn.has(t) || T("INVALID_STORAGE_KEY"), n !== t && T("CONFIRMATION_REQUIRED"), Zt(e, t) || T("QUARANTINE_NOT_FOUND");
|
|
1171
|
+
try {
|
|
1172
|
+
e.removeItem(t), e.getItem(t) !== null && T("STORAGE_WRITE_FAILED");
|
|
1173
|
+
} catch (r) {
|
|
1174
|
+
if (r instanceof rt) throw r;
|
|
1175
|
+
T("STORAGE_UNAVAILABLE");
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
function Gr(e, t) {
|
|
1179
|
+
t !== ie && T("CONFIRMATION_REQUIRED");
|
|
1180
|
+
const n = $t(e, ie);
|
|
1181
|
+
n.status === "empty" && T("REMEMBER_UNAVAILABLE"), n.status !== "valid" && T("STORAGE_QUARANTINED");
|
|
1182
|
+
try {
|
|
1183
|
+
e.removeItem(ie), e.getItem(ie) !== null && T("STORAGE_WRITE_FAILED");
|
|
1184
|
+
} catch (i) {
|
|
1185
|
+
if (i instanceof rt) throw i;
|
|
1186
|
+
T("STORAGE_UNAVAILABLE");
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
const mt = "sdn-bip32-slip10-purpose-v1", gt = "password-scrypt-v2", Ft = "m/44'/0'/0'/2'/0'", en = "Approval unavailable — migrate to the new wallet profile", wn = Object.freeze({
|
|
1190
|
+
"bip39-mnemonic-v1-legacy": "sdn-bip39-auth-v1-legacy",
|
|
1191
|
+
"password-fast-v1-legacy": "sdn-fast-password-auth-v1-legacy"
|
|
1192
|
+
}), bn = new TextEncoder(), Kr = Uint8Array.prototype.fill, tn = Object.freeze([
|
|
1193
|
+
"accountFingerprint",
|
|
1194
|
+
"accountIndex",
|
|
1195
|
+
"accountLabel",
|
|
1196
|
+
"accountPeerId",
|
|
1197
|
+
"accountXpub",
|
|
1198
|
+
"identityScheme",
|
|
1199
|
+
"keys",
|
|
1200
|
+
"schemaVersion",
|
|
1201
|
+
"seedProfile"
|
|
1202
|
+
]), nn = Object.freeze([
|
|
1203
|
+
"bip32Fingerprint",
|
|
1204
|
+
"curve",
|
|
1205
|
+
"derivation",
|
|
1206
|
+
"encoding",
|
|
1207
|
+
"identityScheme",
|
|
1208
|
+
"keyId",
|
|
1209
|
+
"path",
|
|
1210
|
+
"publicKeyHex",
|
|
1211
|
+
"purpose",
|
|
1212
|
+
"seedProfile",
|
|
1213
|
+
"signatureProfile"
|
|
1214
|
+
]), At = Object.freeze([
|
|
1215
|
+
Object.freeze({
|
|
1216
|
+
curve: "ed25519",
|
|
1217
|
+
path: Ft,
|
|
1218
|
+
purpose: "asset-review-approval",
|
|
1219
|
+
signatureProfile: "ed25519-over-sha256-jcs-v1"
|
|
1220
|
+
}),
|
|
1221
|
+
Object.freeze({
|
|
1222
|
+
curve: "x25519",
|
|
1223
|
+
path: "m/44'/0'/0'/1'/0'",
|
|
1224
|
+
purpose: "contact-encryption",
|
|
1225
|
+
signatureProfile: null
|
|
1226
|
+
}),
|
|
1227
|
+
Object.freeze({
|
|
1228
|
+
curve: "ed25519",
|
|
1229
|
+
path: "m/44'/0'/0'/0'/0'",
|
|
1230
|
+
purpose: "sdn-authentication",
|
|
1231
|
+
signatureProfile: "ed25519-over-sha256-jcs-v1"
|
|
1232
|
+
})
|
|
1233
|
+
]);
|
|
1234
|
+
class ii extends Error {
|
|
1235
|
+
constructor(t) {
|
|
1236
|
+
super(t === "APPROVAL_UNAVAILABLE" ? en : t), this.name = "WalletAccountError", this.code = t;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
function B(e) {
|
|
1240
|
+
throw new ii(e);
|
|
1241
|
+
}
|
|
1242
|
+
function In(e) {
|
|
1243
|
+
if (e instanceof Uint8Array)
|
|
1244
|
+
try {
|
|
1245
|
+
Kr.call(e, 0);
|
|
1246
|
+
} catch {
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
function De(e) {
|
|
1250
|
+
if (Array.isArray(e)) return Object.freeze(e.map(De));
|
|
1251
|
+
if (!e || typeof e != "object") return e;
|
|
1252
|
+
const t = {};
|
|
1253
|
+
for (const n of Object.keys(e).sort()) t[n] = De(e[n]);
|
|
1254
|
+
return Object.freeze(t);
|
|
1255
|
+
}
|
|
1256
|
+
function Jr(e) {
|
|
1257
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
1258
|
+
const t = Object.getPrototypeOf(e);
|
|
1259
|
+
return t === Object.prototype || t === null;
|
|
1260
|
+
}
|
|
1261
|
+
function Et(e, t) {
|
|
1262
|
+
Jr(e) || B("INVALID_PUBLIC_IDENTITY");
|
|
1263
|
+
let n;
|
|
1264
|
+
try {
|
|
1265
|
+
n = Reflect.ownKeys(e);
|
|
1266
|
+
} catch {
|
|
1267
|
+
B("INVALID_PUBLIC_IDENTITY");
|
|
1268
|
+
}
|
|
1269
|
+
n.some((a) => typeof a != "string") && B("INVALID_PUBLIC_IDENTITY");
|
|
1270
|
+
const i = [...n].sort(), r = [...t].sort();
|
|
1271
|
+
(i.length !== r.length || i.some((a, o) => a !== r[o])) && B("INVALID_PUBLIC_IDENTITY");
|
|
1272
|
+
const s = {};
|
|
1273
|
+
for (const a of i) {
|
|
1274
|
+
let o;
|
|
1275
|
+
try {
|
|
1276
|
+
o = Object.getOwnPropertyDescriptor(e, a);
|
|
1277
|
+
} catch {
|
|
1278
|
+
B("INVALID_PUBLIC_IDENTITY");
|
|
1279
|
+
}
|
|
1280
|
+
(!o?.enumerable || !("value" in o) || o.value === void 0) && B("INVALID_PUBLIC_IDENTITY"), s[a] = o.value;
|
|
1281
|
+
}
|
|
1282
|
+
return s;
|
|
1283
|
+
}
|
|
1284
|
+
function je(e) {
|
|
1285
|
+
if (typeof e != "string") return !1;
|
|
1286
|
+
for (let t = 0; t < e.length; t += 1) {
|
|
1287
|
+
const n = e.charCodeAt(t);
|
|
1288
|
+
if (n >= 55296 && n <= 56319) {
|
|
1289
|
+
const i = e.charCodeAt(++t);
|
|
1290
|
+
if (!(i >= 56320 && i <= 57343)) return !1;
|
|
1291
|
+
} else if (n >= 56320 && n <= 57343) return !1;
|
|
1292
|
+
}
|
|
1293
|
+
return !0;
|
|
1294
|
+
}
|
|
1295
|
+
function Qr(e) {
|
|
1296
|
+
if (!Array.isArray(e) || Object.getPrototypeOf(e) !== Array.prototype || e.length !== At.length) return !1;
|
|
1297
|
+
let t;
|
|
1298
|
+
try {
|
|
1299
|
+
t = Reflect.ownKeys(e);
|
|
1300
|
+
} catch {
|
|
1301
|
+
return !1;
|
|
1302
|
+
}
|
|
1303
|
+
const n = ["0", "1", "2", "length"];
|
|
1304
|
+
if (t.length !== n.length || t.some((i, r) => i !== n[r])) return !1;
|
|
1305
|
+
for (let i = 0; i < At.length; i += 1) {
|
|
1306
|
+
const r = Object.getOwnPropertyDescriptor(e, String(i));
|
|
1307
|
+
if (!r?.enumerable || !("value" in r)) return !1;
|
|
1308
|
+
}
|
|
1309
|
+
return !0;
|
|
1310
|
+
}
|
|
1311
|
+
function Yr(e) {
|
|
1312
|
+
if (!Array.isArray(e) || Object.getPrototypeOf(e) !== Array.prototype || e.length !== 1) return !1;
|
|
1313
|
+
let t;
|
|
1314
|
+
try {
|
|
1315
|
+
t = Reflect.ownKeys(e);
|
|
1316
|
+
} catch {
|
|
1317
|
+
return !1;
|
|
1318
|
+
}
|
|
1319
|
+
if (t.length !== 2 || t[0] !== "0" || t[1] !== "length") return !1;
|
|
1320
|
+
const n = Object.getOwnPropertyDescriptor(e, "0");
|
|
1321
|
+
return n?.enumerable === !0 && "value" in n;
|
|
1322
|
+
}
|
|
1323
|
+
function he(e) {
|
|
1324
|
+
const t = Et(e, tn);
|
|
1325
|
+
(t.schemaVersion !== 1 || t.identityScheme !== mt || t.seedProfile !== gt || t.accountIndex !== 0 || t.accountLabel !== null || !/^[0-9a-f]{8}$/u.test(t.accountFingerprint) || !je(t.accountXpub) || !/^xpub[1-9A-HJ-NP-Za-km-z]{107}$/u.test(t.accountXpub) || !je(t.accountPeerId) || !/^16Uiu2H[1-9A-HJ-NP-Za-km-z]{33,57}$/u.test(t.accountPeerId) || !Qr(t.keys)) && B("INVALID_PUBLIC_IDENTITY");
|
|
1326
|
+
const n = At.map((i, r) => {
|
|
1327
|
+
const s = Et(t.keys[r], nn);
|
|
1328
|
+
return (s.bip32Fingerprint !== null || s.curve !== i.curve || s.derivation !== "slip10" || s.encoding !== "raw" || s.identityScheme !== mt || s.path !== i.path || s.purpose !== i.purpose || s.seedProfile !== gt || s.signatureProfile !== i.signatureProfile || !/^[0-9a-f]{64}$/u.test(s.publicKeyHex) || !/^sha256:[0-9a-f]{64}$/u.test(s.keyId)) && B("INVALID_PUBLIC_IDENTITY"), De(s);
|
|
1329
|
+
});
|
|
1330
|
+
return De({ ...t, keys: n });
|
|
1331
|
+
}
|
|
1332
|
+
function Xr(e, { accountIndex: t = 0, profile: n } = {}) {
|
|
1333
|
+
const i = Object.hasOwn(wn, n) ? wn[n] : null;
|
|
1334
|
+
(!i || t !== 0) && B("INVALID_LEGACY_PROFILE");
|
|
1335
|
+
const r = Et(e, tn);
|
|
1336
|
+
(r.schemaVersion !== 1 || r.identityScheme !== i || r.seedProfile !== n || r.accountIndex !== t || r.accountLabel !== null || !/^[0-9a-f]{8}$/u.test(r.accountFingerprint) || !je(r.accountXpub) || !/^xpub[1-9A-HJ-NP-Za-km-z]{107}$/u.test(r.accountXpub) || !je(r.accountPeerId) || !/^16Uiu2H[1-9A-HJ-NP-Za-km-z]{33,57}$/u.test(r.accountPeerId) || !Yr(r.keys)) && B("INVALID_PUBLIC_IDENTITY");
|
|
1337
|
+
const s = Et(r.keys[0], nn);
|
|
1338
|
+
return (s.bip32Fingerprint !== null || s.curve !== "ed25519" || s.derivation !== "bip32-scalar-as-ed25519-seed" || s.encoding !== "raw" || s.identityScheme !== i || s.path !== `m/44'/0'/${t}'/0/0` || s.purpose !== "sdn-authentication" || s.seedProfile !== n || s.signatureProfile !== "ed25519-raw-32-v1" || !/^[0-9a-f]{64}$/u.test(s.publicKeyHex) || !/^sha256:[0-9a-f]{64}$/u.test(s.keyId)) && B("INVALID_PUBLIC_IDENTITY"), De({ ...r, keys: [s] });
|
|
1339
|
+
}
|
|
1340
|
+
function vn(e) {
|
|
1341
|
+
if (!(!e || typeof e != "object")) {
|
|
1342
|
+
try {
|
|
1343
|
+
e.value = "";
|
|
1344
|
+
} catch {
|
|
1345
|
+
}
|
|
1346
|
+
try {
|
|
1347
|
+
e.defaultValue = "";
|
|
1348
|
+
} catch {
|
|
1349
|
+
}
|
|
1350
|
+
try {
|
|
1351
|
+
e.disabled = !0;
|
|
1352
|
+
} catch {
|
|
1353
|
+
}
|
|
1354
|
+
try {
|
|
1355
|
+
e.inert = !0;
|
|
1356
|
+
} catch {
|
|
1357
|
+
}
|
|
1358
|
+
try {
|
|
1359
|
+
e.removeAttribute?.("name");
|
|
1360
|
+
} catch {
|
|
1361
|
+
}
|
|
1362
|
+
try {
|
|
1363
|
+
e.removeAttribute?.("autocomplete");
|
|
1364
|
+
} catch {
|
|
1365
|
+
}
|
|
1366
|
+
try {
|
|
1367
|
+
e.setSelectionRange?.(0, 0);
|
|
1368
|
+
} catch {
|
|
1369
|
+
}
|
|
1370
|
+
try {
|
|
1371
|
+
e.setCustomValidity?.("");
|
|
1372
|
+
} catch {
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
function Sn(e, t) {
|
|
1377
|
+
if (typeof e != "string" || typeof t != "string") return !1;
|
|
1378
|
+
const n = Math.max(e.length, t.length);
|
|
1379
|
+
let i = e.length ^ t.length;
|
|
1380
|
+
for (let r = 0; r < n; r += 2) {
|
|
1381
|
+
const s = Number.parseInt(e.slice(r, r + 2), 16), a = Number.parseInt(t.slice(r, r + 2), 16);
|
|
1382
|
+
i |= (Number.isNaN(s) ? 256 : s) ^ (Number.isNaN(a) ? 256 : a);
|
|
1383
|
+
}
|
|
1384
|
+
return i === 0;
|
|
1385
|
+
}
|
|
1386
|
+
function Zr(e) {
|
|
1387
|
+
return !e || typeof e != "object" || !Array.isArray(e.keys) ? null : e.keys.find((t) => t?.purpose === "asset-review-approval") ?? null;
|
|
1388
|
+
}
|
|
1389
|
+
function Dt(e, t) {
|
|
1390
|
+
try {
|
|
1391
|
+
e = he(e), t = he(t);
|
|
1392
|
+
} catch {
|
|
1393
|
+
return !1;
|
|
1394
|
+
}
|
|
1395
|
+
let n = !0;
|
|
1396
|
+
for (const i of tn.filter((r) => r !== "keys"))
|
|
1397
|
+
n = e[i] === t[i] && n;
|
|
1398
|
+
for (let i = 0; i < At.length; i += 1) {
|
|
1399
|
+
const r = e.keys[i], s = t.keys[i];
|
|
1400
|
+
for (const a of nn.filter((o) => o !== "publicKeyHex" && o !== "keyId"))
|
|
1401
|
+
n = r[a] === s[a] && n;
|
|
1402
|
+
n = Sn(r.publicKeyHex, s.publicKeyHex) && n, n = Sn(r.keyId.slice(7), s.keyId.slice(7)) && n;
|
|
1403
|
+
}
|
|
1404
|
+
return n;
|
|
1405
|
+
}
|
|
1406
|
+
function Pe(e, t, n, i) {
|
|
1407
|
+
const r = e.createElement("div");
|
|
1408
|
+
r.className = "wallet-account-row";
|
|
1409
|
+
const s = e.createElement("strong");
|
|
1410
|
+
s.textContent = `${n}: `;
|
|
1411
|
+
const a = e.createElement("span");
|
|
1412
|
+
a.textContent = i == null ? "" : String(i), r.append(s, a), t.append(r);
|
|
1413
|
+
}
|
|
1414
|
+
function ri(e) {
|
|
1415
|
+
(e?.identityScheme !== mt || e?.seedProfile !== gt || e?.accountIndex !== 0) && B("APPROVAL_UNAVAILABLE");
|
|
1416
|
+
const t = Zr(e);
|
|
1417
|
+
return (!t || t.identityScheme !== e.identityScheme || t.seedProfile !== e.seedProfile || t.signatureProfile !== "ed25519-over-sha256-jcs-v1" || t.curve !== "ed25519" || t.derivation !== "slip10" || t.path !== Ft || t.encoding !== "raw" || !/^[0-9a-f]{64}$/u.test(t.publicKeyHex) || !/^sha256:[0-9a-f]{64}$/u.test(t.keyId)) && B("APPROVAL_UNAVAILABLE"), De({
|
|
1418
|
+
algorithm: "Ed25519",
|
|
1419
|
+
derivationPath: Ft,
|
|
1420
|
+
encoding: "raw-32-byte",
|
|
1421
|
+
identityScheme: e.identityScheme,
|
|
1422
|
+
keyId: t.keyId,
|
|
1423
|
+
publicKeyHex: t.publicKeyHex,
|
|
1424
|
+
purpose: "asset-review-approval",
|
|
1425
|
+
schemaVersion: 1,
|
|
1426
|
+
seedProfile: e.seedProfile,
|
|
1427
|
+
signatureProfile: "ed25519-over-sha256-jcs-v1"
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
function es(e) {
|
|
1431
|
+
return JSON.stringify(e, null, 2);
|
|
1432
|
+
}
|
|
1433
|
+
function ts(e, t, { document: n = e.ownerDocument } = {}) {
|
|
1434
|
+
e.replaceChildren();
|
|
1435
|
+
const i = n.createElement("h1");
|
|
1436
|
+
if (i.textContent = "Account", e.append(i), Pe(n, e, "Username / account", t?.accountLabel ?? "account 0"), Pe(n, e, "Account xpub", t?.accountXpub), Pe(n, e, "Peer ID", t?.accountPeerId), Pe(n, e, "Fingerprint", t?.accountFingerprint), t?.identityScheme !== mt || t?.seedProfile !== gt) {
|
|
1437
|
+
const s = n.createElement("p");
|
|
1438
|
+
return s.textContent = en, e.append(s), Object.freeze({ approvalAvailable: !1 });
|
|
1439
|
+
}
|
|
1440
|
+
const r = ri(t);
|
|
1441
|
+
return Pe(n, e, "Asset approval public key", r.publicKeyHex), Pe(n, e, "Asset approval key ID", r.keyId), Object.freeze({ approvalAvailable: !0, configuration: r });
|
|
1442
|
+
}
|
|
1443
|
+
function ns(e, { document: t = e.ownerDocument } = {}) {
|
|
1444
|
+
e.replaceChildren();
|
|
1445
|
+
const n = t.createElement("h2");
|
|
1446
|
+
n.textContent = "Stored wallet";
|
|
1447
|
+
const i = t.createElement("p");
|
|
1448
|
+
i.textContent = "Forgetting removes the saved unlock record but keeps this account signed in.";
|
|
1449
|
+
const r = t.createElement("button");
|
|
1450
|
+
r.type = "button", r.dataset.walletAction = "forget-stored-wallet", r.textContent = "Forget stored wallet";
|
|
1451
|
+
const s = t.createElement("div");
|
|
1452
|
+
s.hidden = !0;
|
|
1453
|
+
const a = t.createElement("p");
|
|
1454
|
+
a.textContent = `Type ${ie} to confirm.`;
|
|
1455
|
+
const o = t.createElement("input");
|
|
1456
|
+
o.type = "text", o.autocomplete = "off", o.spellcheck = !1, o.dataset.walletForgetConfirmation = "exact-storage-key";
|
|
1457
|
+
const c = t.createElement("button");
|
|
1458
|
+
c.type = "button", c.dataset.walletAction = "confirm-forget-stored-wallet", c.textContent = "Confirm forget";
|
|
1459
|
+
const l = t.createElement("button");
|
|
1460
|
+
l.type = "button", l.dataset.walletAction = "cancel-forget-stored-wallet", l.textContent = "Cancel";
|
|
1461
|
+
const d = t.createElement("p");
|
|
1462
|
+
return d.dataset.walletForgetStatus = "true", d.setAttribute?.("aria-live", "polite"), s.append(a, o, c, l), e.append(n, i, r, s, d), Object.freeze({
|
|
1463
|
+
cancel: l,
|
|
1464
|
+
confirm: c,
|
|
1465
|
+
confirmation: o,
|
|
1466
|
+
confirmationGroup: s,
|
|
1467
|
+
confirmationKey: ie,
|
|
1468
|
+
launch: r,
|
|
1469
|
+
status: d
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
function is(e, t, { document: n = e.ownerDocument } = {}) {
|
|
1473
|
+
e.replaceChildren();
|
|
1474
|
+
const i = n.createElement("h2");
|
|
1475
|
+
i.textContent = "Quarantined wallet storage";
|
|
1476
|
+
const r = n.createElement("p");
|
|
1477
|
+
r.textContent = "These records are never unlocked automatically. Export or delete each exact storage key.";
|
|
1478
|
+
const s = n.createElement("div"), a = n.createElement("p");
|
|
1479
|
+
a.dataset.walletQuarantineStatus = "true", a.setAttribute?.("aria-live", "polite");
|
|
1480
|
+
const o = [];
|
|
1481
|
+
for (const c of t) {
|
|
1482
|
+
const l = n.createElement("div");
|
|
1483
|
+
l.className = "wallet-quarantine-row";
|
|
1484
|
+
const d = n.createElement("code");
|
|
1485
|
+
d.dataset.walletQuarantineLabel = "true", d.textContent = c.key;
|
|
1486
|
+
const u = n.createElement("span");
|
|
1487
|
+
u.textContent = c.oversized ? `Export unavailable (${c.rawLength} characters)` : `${c.rawLength} characters`;
|
|
1488
|
+
const f = n.createElement("button");
|
|
1489
|
+
f.type = "button", f.dataset.walletAction = "export-quarantined-wallet", f.dataset.walletQuarantineKey = c.key, f.textContent = c.exportable ? "Export" : "Export unavailable";
|
|
1490
|
+
const p = n.createElement("button");
|
|
1491
|
+
p.type = "button", p.dataset.walletAction = "delete-quarantined-wallet", p.dataset.walletQuarantineKey = c.key, p.textContent = "Delete";
|
|
1492
|
+
const g = n.createElement("div");
|
|
1493
|
+
g.hidden = !0;
|
|
1494
|
+
const E = n.createElement("p");
|
|
1495
|
+
E.textContent = `Type ${c.key} to confirm deletion.`;
|
|
1496
|
+
const h = n.createElement("input");
|
|
1497
|
+
h.type = "text", h.autocomplete = "off", h.spellcheck = !1, h.dataset.walletQuarantineConfirmation = c.key;
|
|
1498
|
+
const A = n.createElement("button");
|
|
1499
|
+
A.type = "button", A.dataset.walletAction = "confirm-delete-quarantined-wallet", A.dataset.walletQuarantineKey = c.key, A.textContent = "Confirm delete";
|
|
1500
|
+
const m = n.createElement("button");
|
|
1501
|
+
m.type = "button", m.dataset.walletAction = "cancel-delete-quarantined-wallet", m.dataset.walletQuarantineKey = c.key, m.textContent = "Cancel", g.append(E, h, A, m), l.append(d, u, f, p, g), s.append(l), o.push(Object.freeze({
|
|
1502
|
+
cancel: m,
|
|
1503
|
+
confirm: A,
|
|
1504
|
+
confirmation: h,
|
|
1505
|
+
confirmationGroup: g,
|
|
1506
|
+
deleteButton: p,
|
|
1507
|
+
entry: c,
|
|
1508
|
+
exportButton: f
|
|
1509
|
+
}));
|
|
1510
|
+
}
|
|
1511
|
+
return e.append(i, r, s, a), Object.freeze({ rows: Object.freeze(o), status: a });
|
|
1512
|
+
}
|
|
1513
|
+
async function rs(e, {
|
|
1514
|
+
assertCurrent: t = () => {
|
|
1515
|
+
},
|
|
1516
|
+
clipboard: n = globalThis.navigator?.clipboard,
|
|
1517
|
+
container: i,
|
|
1518
|
+
document: r = i?.ownerDocument
|
|
1519
|
+
}) {
|
|
1520
|
+
const s = es(e);
|
|
1521
|
+
let a = !1;
|
|
1522
|
+
try {
|
|
1523
|
+
if (!n?.writeText) throw new Error("clipboard unavailable");
|
|
1524
|
+
await n.writeText(s), a = !0;
|
|
1525
|
+
} catch {
|
|
1526
|
+
}
|
|
1527
|
+
if (t(), !a && i && r) {
|
|
1528
|
+
const o = r.createElement("textarea");
|
|
1529
|
+
o.readOnly = !0, o.value = s, o.textContent = s, i.replaceChildren(o);
|
|
1530
|
+
try {
|
|
1531
|
+
o.select?.();
|
|
1532
|
+
} catch {
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
return a;
|
|
1536
|
+
}
|
|
1537
|
+
async function Rn(e, t, n, {
|
|
1538
|
+
assertCurrent: i,
|
|
1539
|
+
ownBuffer: r,
|
|
1540
|
+
ownHandle: s,
|
|
1541
|
+
releaseBuffer: a
|
|
1542
|
+
}) {
|
|
1543
|
+
const o = await t(n), c = o?.usernameControl, l = o?.passwordControl;
|
|
1544
|
+
let d, u;
|
|
1545
|
+
try {
|
|
1546
|
+
i();
|
|
1547
|
+
const p = c?.value, g = l?.value;
|
|
1548
|
+
(typeof p != "string" || typeof g != "string") && B("CREDENTIAL_CONFIRMATION_MISMATCH"), (!je(p) || !je(g)) && B("CREDENTIAL_CONFIRMATION_MISMATCH"), d = bn.encode(p), r(d), u = bn.encode(g), r(u);
|
|
1549
|
+
} finally {
|
|
1550
|
+
vn(c), vn(l);
|
|
1551
|
+
const p = c?.form, g = l?.form;
|
|
1552
|
+
try {
|
|
1553
|
+
(p?.parentNode ?? p)?.remove?.();
|
|
1554
|
+
} catch {
|
|
1555
|
+
}
|
|
1556
|
+
if (g !== p)
|
|
1557
|
+
try {
|
|
1558
|
+
(g?.parentNode ?? g)?.remove?.();
|
|
1559
|
+
} catch {
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
let f;
|
|
1563
|
+
try {
|
|
1564
|
+
i(), f = await e.derivePasswordIdentity({
|
|
1565
|
+
accountIndex: 0,
|
|
1566
|
+
passwordUtf8: u,
|
|
1567
|
+
usernameUtf8: d
|
|
1568
|
+
}), f?.handle || B("CREDENTIAL_CONFIRMATION_MISMATCH"), s(f.handle), i();
|
|
1569
|
+
let p;
|
|
1570
|
+
try {
|
|
1571
|
+
p = he(f.identity);
|
|
1572
|
+
} catch {
|
|
1573
|
+
B("CREDENTIAL_CONFIRMATION_MISMATCH");
|
|
1574
|
+
}
|
|
1575
|
+
return { handle: f.handle, identity: p };
|
|
1576
|
+
} finally {
|
|
1577
|
+
a(d), a(u);
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
class ss {
|
|
1581
|
+
#d = null;
|
|
1582
|
+
#m;
|
|
1583
|
+
#h = !1;
|
|
1584
|
+
#a = /* @__PURE__ */ new Set();
|
|
1585
|
+
#f;
|
|
1586
|
+
#v = 0;
|
|
1587
|
+
#e = 0;
|
|
1588
|
+
#n = /* @__PURE__ */ new Set();
|
|
1589
|
+
#r = /* @__PURE__ */ new Set();
|
|
1590
|
+
#t;
|
|
1591
|
+
constructor({ wasm: t, credentialRound: n, expectedIdentity: i = null }) {
|
|
1592
|
+
this.#t = t?.sdn ?? t, this.#m = n;
|
|
1593
|
+
try {
|
|
1594
|
+
this.#f = i === null ? null : he(i);
|
|
1595
|
+
} catch {
|
|
1596
|
+
B("CREDENTIAL_CONFIRMATION_MISMATCH");
|
|
1597
|
+
}
|
|
1598
|
+
(typeof this.#t?.derivePasswordIdentity != "function" || typeof this.#t?.destroySdnIdentity != "function" || typeof n != "function") && B("CREDENTIAL_CONFIRMATION_MISMATCH");
|
|
1599
|
+
}
|
|
1600
|
+
get confirmed() {
|
|
1601
|
+
return this.#d;
|
|
1602
|
+
}
|
|
1603
|
+
clear() {
|
|
1604
|
+
return this.#d = null, this.#h || (this.#h = !0, this.#v += 1, this.#f = null), this.#o(), this.#R(), this.#e === 0 && this.#n.size === 0;
|
|
1605
|
+
}
|
|
1606
|
+
destroy() {
|
|
1607
|
+
return this.clear();
|
|
1608
|
+
}
|
|
1609
|
+
async confirm() {
|
|
1610
|
+
if (this.#h && B("CREDENTIAL_CONFIRMATION_MISMATCH"), this.#d) return this.#d;
|
|
1611
|
+
this.#e += 1;
|
|
1612
|
+
const t = this.#v;
|
|
1613
|
+
let n, i;
|
|
1614
|
+
try {
|
|
1615
|
+
this.#R(), this.#n.size !== 0 && B("CREDENTIAL_CONFIRMATION_MISMATCH");
|
|
1616
|
+
const s = {
|
|
1617
|
+
assertCurrent: () => this.#p(t),
|
|
1618
|
+
ownBuffer: (a) => this.#r.add(a),
|
|
1619
|
+
ownHandle: (a) => this.#n.add(a),
|
|
1620
|
+
releaseBuffer: (a) => {
|
|
1621
|
+
In(a), this.#r.delete(a);
|
|
1622
|
+
}
|
|
1623
|
+
};
|
|
1624
|
+
return n = await Rn(this.#t, this.#m, 1, s), this.#S(n.handle) || B("CREDENTIAL_CONFIRMATION_MISMATCH"), n.handle = null, this.#p(t), i = await Rn(this.#t, this.#m, 2, s), this.#S(i.handle) || B("CREDENTIAL_CONFIRMATION_MISMATCH"), i.handle = null, this.#p(t), (!Dt(n.identity, i.identity) || this.#f !== null && (!Dt(n.identity, this.#f) || !Dt(i.identity, this.#f))) && B("CREDENTIAL_CONFIRMATION_MISMATCH"), this.#n.size !== 0 && B("CREDENTIAL_CONFIRMATION_MISMATCH"), this.#d = ri(i.identity), this.#d;
|
|
1625
|
+
} catch (r) {
|
|
1626
|
+
if (this.#d = null, r instanceof ii && r.code === "CREDENTIAL_CONFIRMATION_MISMATCH") throw r;
|
|
1627
|
+
B("CREDENTIAL_CONFIRMATION_MISMATCH");
|
|
1628
|
+
} finally {
|
|
1629
|
+
this.#o(), this.#R(), this.#e -= 1;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
#p(t) {
|
|
1633
|
+
(this.#h || this.#v !== t) && B("CREDENTIAL_CONFIRMATION_MISMATCH");
|
|
1634
|
+
}
|
|
1635
|
+
#S(t) {
|
|
1636
|
+
if (!this.#n.has(t)) return !0;
|
|
1637
|
+
if (this.#a.has(t)) return !1;
|
|
1638
|
+
this.#a.add(t);
|
|
1639
|
+
try {
|
|
1640
|
+
return this.#t.destroySdnIdentity(t), this.#n.delete(t), !0;
|
|
1641
|
+
} catch {
|
|
1642
|
+
return !1;
|
|
1643
|
+
} finally {
|
|
1644
|
+
this.#a.delete(t);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
#R() {
|
|
1648
|
+
for (const t of [...this.#n]) this.#S(t);
|
|
1649
|
+
}
|
|
1650
|
+
#o() {
|
|
1651
|
+
const t = [...this.#r];
|
|
1652
|
+
this.#r.clear();
|
|
1653
|
+
for (const n of t) In(n);
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
async function os({
|
|
1657
|
+
wasm: e,
|
|
1658
|
+
profile: t,
|
|
1659
|
+
operation: n,
|
|
1660
|
+
credentials: i,
|
|
1661
|
+
accountIndex: r = 0,
|
|
1662
|
+
assertCurrent: s = () => {
|
|
1663
|
+
},
|
|
1664
|
+
ownHandle: a = () => {
|
|
1665
|
+
}
|
|
1666
|
+
}) {
|
|
1667
|
+
const o = e?.sdn ?? e;
|
|
1668
|
+
let c;
|
|
1669
|
+
return t === "password-fast-v1-legacy" ? (typeof o?.deriveLegacyPasswordIdentity != "function" && B("INVALID_LEGACY_PROFILE"), c = await o.deriveLegacyPasswordIdentity({ accountIndex: r, ...i })) : t === "bip39-mnemonic-v1-legacy" ? (typeof o?.importLegacyMnemonicIdentity != "function" && B("INVALID_LEGACY_PROFILE"), c = await o.importLegacyMnemonicIdentity({ accountIndex: r, ...i })) : B("INVALID_LEGACY_PROFILE"), c?.handle !== null && c?.handle !== void 0 && a(c.handle), s(), Object.freeze({
|
|
1670
|
+
approval: null,
|
|
1671
|
+
handle: c.handle,
|
|
1672
|
+
identity: De(c.identity),
|
|
1673
|
+
legacy: !0
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
function as(e, { document: t = e.ownerDocument } = {}) {
|
|
1677
|
+
e.replaceChildren();
|
|
1678
|
+
const n = t.createElement("h2");
|
|
1679
|
+
n.textContent = "Migrate legacy wallet";
|
|
1680
|
+
const i = t.createElement("p");
|
|
1681
|
+
i.textContent = "Select the exact legacy profile and compare its legacy xpub and authentication key.";
|
|
1682
|
+
const r = t.createElement("select");
|
|
1683
|
+
r.dataset.walletLegacyProfile = "required";
|
|
1684
|
+
for (const [o, c] of [
|
|
1685
|
+
["password-fast-v1-legacy", "Legacy fast-password profile"],
|
|
1686
|
+
["bip39-mnemonic-v1-legacy", "Legacy BIP-39 mnemonic import"]
|
|
1687
|
+
]) {
|
|
1688
|
+
const l = t.createElement("option");
|
|
1689
|
+
l.value = o, l.textContent = c, r.append(l);
|
|
1690
|
+
}
|
|
1691
|
+
const s = t.createElement("button");
|
|
1692
|
+
s.type = "button", s.dataset.walletAction = "launch-legacy-migration", s.textContent = "Compare selected legacy account";
|
|
1693
|
+
const a = t.createElement("div");
|
|
1694
|
+
return a.className = "wallet-legacy-comparison", e.append(n, i, r, s, a), Object.freeze({ launch: s, result: a, select: r });
|
|
1695
|
+
}
|
|
1696
|
+
const wt = Uint8Array, si = ArrayBuffer, rn = Object.getPrototypeOf(wt.prototype), cs = Object.getOwnPropertyDescriptor(rn, "buffer").get, ls = Object.getOwnPropertyDescriptor(rn, "byteLength").get, us = Object.getOwnPropertyDescriptor(rn, "byteOffset").get, ds = Object.getOwnPropertyDescriptor(si.prototype, "byteLength").get;
|
|
1697
|
+
class fs extends Error {
|
|
1698
|
+
constructor(t = "RNG_FAILURE") {
|
|
1699
|
+
super(t), this.name = "WalletRandomError", this.code = t;
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
function Re() {
|
|
1703
|
+
throw new fs();
|
|
1704
|
+
}
|
|
1705
|
+
function ps(e) {
|
|
1706
|
+
if (!(e instanceof wt) || Object.getPrototypeOf(e) !== wt.prototype) return null;
|
|
1707
|
+
let t, n, i;
|
|
1708
|
+
try {
|
|
1709
|
+
t = Reflect.apply(cs, e, []), n = Reflect.apply(ls, e, []), i = Reflect.apply(us, e, []);
|
|
1710
|
+
} catch {
|
|
1711
|
+
return null;
|
|
1712
|
+
}
|
|
1713
|
+
let r;
|
|
1714
|
+
try {
|
|
1715
|
+
r = Reflect.apply(ds, t, []);
|
|
1716
|
+
} catch {
|
|
1717
|
+
return null;
|
|
1718
|
+
}
|
|
1719
|
+
return Object.getPrototypeOf(t) !== si.prototype || i !== 0 || n !== r || n !== 12 && n !== 32 ? null : t;
|
|
1720
|
+
}
|
|
1721
|
+
function hs({ getRandomValues: e, observedWrite: t } = {}) {
|
|
1722
|
+
if (typeof e != "function")
|
|
1723
|
+
return () => Re();
|
|
1724
|
+
const n = /* @__PURE__ */ new WeakSet(), i = /* @__PURE__ */ new WeakSet();
|
|
1725
|
+
return function(s) {
|
|
1726
|
+
const a = ps(s);
|
|
1727
|
+
(!a || n.has(s) || i.has(a)) && Re(), n.add(s), i.add(a);
|
|
1728
|
+
let o;
|
|
1729
|
+
try {
|
|
1730
|
+
o = e(s);
|
|
1731
|
+
} catch {
|
|
1732
|
+
Re();
|
|
1733
|
+
}
|
|
1734
|
+
if (o !== s && Re(), t !== void 0) {
|
|
1735
|
+
typeof t != "function" && Re();
|
|
1736
|
+
let c = !1;
|
|
1737
|
+
try {
|
|
1738
|
+
c = t(s) === !0;
|
|
1739
|
+
} catch {
|
|
1740
|
+
Re();
|
|
1741
|
+
}
|
|
1742
|
+
c || Re();
|
|
1743
|
+
}
|
|
1744
|
+
return s;
|
|
1745
|
+
};
|
|
1746
|
+
}
|
|
1747
|
+
function Ue(e, t) {
|
|
1748
|
+
(typeof e != "function" || t !== 12 && t !== 32) && Re();
|
|
1749
|
+
const n = new wt(t);
|
|
1750
|
+
return e(n);
|
|
1751
|
+
}
|
|
1752
|
+
const Ze = new TextEncoder(), ys = new TextDecoder("utf-8", { fatal: !0 }), ms = Uint8Array.prototype.fill, gs = Uint8Array.prototype.slice, As = Uint8Array.prototype.subarray, sn = Object.getPrototypeOf(Uint8Array.prototype), Es = Object.getOwnPropertyDescriptor(sn, "buffer").get, oi = Object.getOwnPropertyDescriptor(sn, "byteLength").get, ws = Object.getOwnPropertyDescriptor(sn, "byteOffset").get, ai = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get, bs = ArrayBuffer.prototype.slice, Ln = "webauthn-prf-hkdf-sha256-aes256gcm-v2", Is = "sdn-bip32-slip10-purpose-v1", vs = "password-scrypt-v2", ci = "wallet.spacedatanetwork.org", Ss = "Space Data Network Wallet", li = 12e4;
|
|
1753
|
+
class Rs extends Error {
|
|
1754
|
+
constructor(t) {
|
|
1755
|
+
super(t), this.name = "RememberedWalletError", this.code = t;
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
function _(e) {
|
|
1759
|
+
throw new Rs(e);
|
|
1760
|
+
}
|
|
1761
|
+
function k(e) {
|
|
1762
|
+
if (e instanceof Uint8Array)
|
|
1763
|
+
try {
|
|
1764
|
+
ms.call(e, 0);
|
|
1765
|
+
} catch {
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
function bt(e) {
|
|
1769
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
1770
|
+
const t = Object.getPrototypeOf(e);
|
|
1771
|
+
return t === Object.prototype || t === null;
|
|
1772
|
+
}
|
|
1773
|
+
function ui(e, t) {
|
|
1774
|
+
if (!bt(e)) return !1;
|
|
1775
|
+
let n;
|
|
1776
|
+
try {
|
|
1777
|
+
n = Reflect.ownKeys(e);
|
|
1778
|
+
} catch {
|
|
1779
|
+
return !1;
|
|
1780
|
+
}
|
|
1781
|
+
if (n.some((s) => typeof s != "string")) return !1;
|
|
1782
|
+
const i = [...n].sort(), r = [...t].sort();
|
|
1783
|
+
return i.length === r.length && i.every((s, a) => s === r[a]);
|
|
1784
|
+
}
|
|
1785
|
+
function et(e, t) {
|
|
1786
|
+
if (!ui(e, t)) return null;
|
|
1787
|
+
const n = {};
|
|
1788
|
+
for (const i of t) {
|
|
1789
|
+
let r;
|
|
1790
|
+
try {
|
|
1791
|
+
r = Object.getOwnPropertyDescriptor(e, i);
|
|
1792
|
+
} catch {
|
|
1793
|
+
return null;
|
|
1794
|
+
}
|
|
1795
|
+
if (!r?.enumerable || !("value" in r) || r.value === void 0)
|
|
1796
|
+
return null;
|
|
1797
|
+
n[i] = r.value;
|
|
1798
|
+
}
|
|
1799
|
+
return n;
|
|
1800
|
+
}
|
|
1801
|
+
function dt(e, t = null) {
|
|
1802
|
+
if (!(e instanceof Uint8Array) || Object.getPrototypeOf(e) !== Uint8Array.prototype)
|
|
1803
|
+
return !1;
|
|
1804
|
+
let n, i, r, s;
|
|
1805
|
+
try {
|
|
1806
|
+
n = Reflect.apply(Es, e, []), i = Reflect.apply(oi, e, []), r = Reflect.apply(ws, e, []), s = Reflect.apply(ai, n, []);
|
|
1807
|
+
} catch {
|
|
1808
|
+
return !1;
|
|
1809
|
+
}
|
|
1810
|
+
return Object.getPrototypeOf(n) === ArrayBuffer.prototype && r === 0 && i === s && (t === null || i === t);
|
|
1811
|
+
}
|
|
1812
|
+
function di(e, t, n) {
|
|
1813
|
+
if (!(e instanceof ArrayBuffer) || Object.getPrototypeOf(e) !== ArrayBuffer.prototype)
|
|
1814
|
+
return !1;
|
|
1815
|
+
let i;
|
|
1816
|
+
try {
|
|
1817
|
+
i = Reflect.apply(ai, e, []);
|
|
1818
|
+
} catch {
|
|
1819
|
+
return !1;
|
|
1820
|
+
}
|
|
1821
|
+
return i >= t && i <= n;
|
|
1822
|
+
}
|
|
1823
|
+
function _e(e) {
|
|
1824
|
+
try {
|
|
1825
|
+
return Reflect.apply(oi, e, []);
|
|
1826
|
+
} catch {
|
|
1827
|
+
return -1;
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
function Ge(e) {
|
|
1831
|
+
let t = "";
|
|
1832
|
+
const n = _e(e);
|
|
1833
|
+
n < 0 && _("INVALID_REMEMBERED_WALLET");
|
|
1834
|
+
for (let i = 0; i < n; i += 32768)
|
|
1835
|
+
t += String.fromCharCode(...Reflect.apply(
|
|
1836
|
+
As,
|
|
1837
|
+
e,
|
|
1838
|
+
[i, i + 32768]
|
|
1839
|
+
));
|
|
1840
|
+
return btoa(t).replace(/\+/gu, "-").replace(/\//gu, "_").replace(/=+$/u, "");
|
|
1841
|
+
}
|
|
1842
|
+
function Ls(e) {
|
|
1843
|
+
let t = "";
|
|
1844
|
+
for (const n of e) t += n.toString(16).padStart(2, "0");
|
|
1845
|
+
return t;
|
|
1846
|
+
}
|
|
1847
|
+
function Be(e) {
|
|
1848
|
+
return e === null || typeof e == "boolean" || typeof e == "string" || typeof e == "number" && Number.isFinite(e) ? JSON.stringify(e) : Array.isArray(e) ? `[${e.map(Be).join(",")}]` : (bt(e) || _("INVALID_REMEMBERED_WALLET"), `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${Be(e[t])}`).join(",")}}`);
|
|
1849
|
+
}
|
|
1850
|
+
function Os(e, t) {
|
|
1851
|
+
if (!(e instanceof Uint8Array) || !(t instanceof Uint8Array)) return !1;
|
|
1852
|
+
const n = _e(e), i = _e(t);
|
|
1853
|
+
if (n < 0 || i < 0) return !1;
|
|
1854
|
+
const r = Math.max(n, i);
|
|
1855
|
+
let s = n ^ i;
|
|
1856
|
+
for (let a = 0; a < r; a += 1)
|
|
1857
|
+
s |= (e[a] ?? 0) ^ (t[a] ?? 0);
|
|
1858
|
+
return s === 0;
|
|
1859
|
+
}
|
|
1860
|
+
function Ns(e, t) {
|
|
1861
|
+
return Be(e) === Be(t);
|
|
1862
|
+
}
|
|
1863
|
+
function fi(e) {
|
|
1864
|
+
(!e || typeof e != "object" && typeof e != "function") && _("WEBAUTHN_INVALID_RESPONSE");
|
|
1865
|
+
let t, n, i;
|
|
1866
|
+
try {
|
|
1867
|
+
t = e.type, n = e.rawId, i = e.getClientExtensionResults;
|
|
1868
|
+
} catch {
|
|
1869
|
+
_("WEBAUTHN_INVALID_RESPONSE");
|
|
1870
|
+
}
|
|
1871
|
+
return (t !== "public-key" || !di(n, 1, 1024) || typeof i != "function") && _("WEBAUTHN_INVALID_RESPONSE"), Object.freeze({
|
|
1872
|
+
rawId: new Uint8Array(Reflect.apply(bs, n, [0])),
|
|
1873
|
+
readExtensionResults() {
|
|
1874
|
+
try {
|
|
1875
|
+
return Reflect.apply(i, e, []);
|
|
1876
|
+
} catch {
|
|
1877
|
+
_("WEBAUTHN_PRF_REQUIRED");
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1882
|
+
function Ts(e) {
|
|
1883
|
+
const t = et(e.readExtensionResults(), ["prf"]), n = t ? et(t.prf, ["enabled"]) : null;
|
|
1884
|
+
(!n || n.enabled !== !0) && _("WEBAUTHN_PRF_REQUIRED");
|
|
1885
|
+
}
|
|
1886
|
+
function Cs(e, t) {
|
|
1887
|
+
const n = fi(e), i = n.rawId;
|
|
1888
|
+
Os(i, t) || (k(i), _("WEBAUTHN_CREDENTIAL_MISMATCH")), k(i);
|
|
1889
|
+
const r = et(n.readExtensionResults(), ["prf"]), s = r ? et(r.prf, ["results"]) : null, o = (s ? et(s.results, ["first"]) : null)?.first;
|
|
1890
|
+
di(o, 32, 32) || _("WEBAUTHN_PRF_REQUIRED");
|
|
1891
|
+
const c = new Uint8Array(o), l = Reflect.apply(gs, c, []);
|
|
1892
|
+
return k(c), l;
|
|
1893
|
+
}
|
|
1894
|
+
function _s({ challenge: e, credentialId: t, prfInput: n, signal: i }) {
|
|
1895
|
+
return {
|
|
1896
|
+
publicKey: {
|
|
1897
|
+
allowCredentials: [{
|
|
1898
|
+
id: t,
|
|
1899
|
+
type: "public-key"
|
|
1900
|
+
}],
|
|
1901
|
+
challenge: e,
|
|
1902
|
+
extensions: { prf: { eval: { first: n } } },
|
|
1903
|
+
rpId: ci,
|
|
1904
|
+
timeout: li,
|
|
1905
|
+
userVerification: "required"
|
|
1906
|
+
},
|
|
1907
|
+
signal: i
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
async function On({ assertCurrent: e, credentials: t, credentialId: n, fillRandom: i, prfInput: r, signal: s }) {
|
|
1911
|
+
const a = Ue(i, 32);
|
|
1912
|
+
let o;
|
|
1913
|
+
try {
|
|
1914
|
+
o = await t.get(_s({
|
|
1915
|
+
challenge: a,
|
|
1916
|
+
credentialId: n,
|
|
1917
|
+
prfInput: r,
|
|
1918
|
+
signal: s
|
|
1919
|
+
}));
|
|
1920
|
+
} catch (c) {
|
|
1921
|
+
throw e(), c;
|
|
1922
|
+
} finally {
|
|
1923
|
+
k(a);
|
|
1924
|
+
}
|
|
1925
|
+
return e(), Cs(o, n);
|
|
1926
|
+
}
|
|
1927
|
+
function xs(e) {
|
|
1928
|
+
if (typeof e != "string") return !1;
|
|
1929
|
+
for (let t = 0; t < e.length; t += 1) {
|
|
1930
|
+
const n = e.charCodeAt(t);
|
|
1931
|
+
if (n >= 55296 && n <= 56319) {
|
|
1932
|
+
const i = e.charCodeAt(++t);
|
|
1933
|
+
if (!(i >= 56320 && i <= 57343)) return !1;
|
|
1934
|
+
} else if (n >= 56320 && n <= 57343)
|
|
1935
|
+
return !1;
|
|
1936
|
+
}
|
|
1937
|
+
return !0;
|
|
1938
|
+
}
|
|
1939
|
+
function Ds(e) {
|
|
1940
|
+
if (typeof e == "string")
|
|
1941
|
+
return xs(e) || _("INVALID_USERNAME"), Ze.encode(e).length > 256 && _("INVALID_USERNAME"), e;
|
|
1942
|
+
(!dt(e) || _e(e) > 256) && _("INVALID_USERNAME");
|
|
1943
|
+
try {
|
|
1944
|
+
return ys.decode(e);
|
|
1945
|
+
} catch {
|
|
1946
|
+
_("INVALID_USERNAME");
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
function Wt(e) {
|
|
1950
|
+
const n = Ds(e).replace(/^ +/u, "").replace(/ +$/u, "").replace(/[A-Z]/gu, (r) => r.toLowerCase()), i = Ze.encode(n);
|
|
1951
|
+
return (i.length < 3 || i.length > 64 || !/^[a-z0-9][a-z0-9._-]*$/u.test(n)) && _("INVALID_USERNAME"), n;
|
|
1952
|
+
}
|
|
1953
|
+
function ks(e) {
|
|
1954
|
+
let t;
|
|
1955
|
+
try {
|
|
1956
|
+
t = Un(e?.module);
|
|
1957
|
+
} catch {
|
|
1958
|
+
_("WASM_UNAVAILABLE");
|
|
1959
|
+
}
|
|
1960
|
+
return (!ui(t, ["sdn", "sha256"]) || typeof t.sha256 != "function" || !t.sdn || typeof t.sdn != "object") && _("WASM_UNAVAILABLE"), t;
|
|
1961
|
+
}
|
|
1962
|
+
function Ps(e) {
|
|
1963
|
+
const t = ks(e), n = t.sdn, i = e?.storage, r = e?.credentials, s = hs(e?.rng), a = e?.createRequestController, o = e?.releaseRequestController, c = e?.ownHandle, l = e?.destroyHandle, d = e?.ownedHandlesClean, u = e?.now ?? (() => /* @__PURE__ */ new Date()), f = () => typeof r?.create == "function" && typeof r?.get == "function", p = () => ni(i), g = () => zr(i), E = (I) => qr(i, I), h = (I, b) => (Hr(i, I, b), g().some((x) => x.key === I) && _("STORAGE_WRITE_FAILED"), !0), A = () => p().active.status === "valid", m = ({ confirmation: I } = {}) => (A() || _("REMEMBER_UNAVAILABLE"), Gr(i, I), p().active.status !== "empty" && _("STORAGE_WRITE_FAILED"), !0), N = async (I) => {
|
|
1964
|
+
let b;
|
|
1965
|
+
try {
|
|
1966
|
+
b = await t.sha256(Ze.encode(I));
|
|
1967
|
+
} catch {
|
|
1968
|
+
_("WASM_FAILURE");
|
|
1969
|
+
}
|
|
1970
|
+
return dt(b, 32) || _("WASM_FAILURE"), Ls(b);
|
|
1971
|
+
};
|
|
1972
|
+
return Object.freeze({
|
|
1973
|
+
canForget: A,
|
|
1974
|
+
deleteQuarantine: h,
|
|
1975
|
+
exportQuarantine: E,
|
|
1976
|
+
forget: m,
|
|
1977
|
+
inspect: p,
|
|
1978
|
+
listQuarantine: g,
|
|
1979
|
+
restore: async ({ assertCurrent: I } = {}) => {
|
|
1980
|
+
(typeof I != "function" || !f() || typeof n.importRememberedIdentity != "function" || typeof c != "function" || typeof l != "function" || typeof a != "function" || typeof o != "function") && _("REMEMBER_UNAVAILABLE");
|
|
1981
|
+
const b = p();
|
|
1982
|
+
(!b.canRestore || !b.active.record) && _("STORAGE_QUARANTINED");
|
|
1983
|
+
const x = b.active.record;
|
|
1984
|
+
Wt(x.canonicalUsername) !== x.canonicalUsername && _("INVALID_REMEMBERED_WALLET"), await N(x.canonicalUsername) !== x.aad.usernameSha256 && _("INVALID_REMEMBERED_WALLET"), I();
|
|
1985
|
+
const z = me(x.credentialIdBase64url, {
|
|
1986
|
+
minimum: 1,
|
|
1987
|
+
maximum: 1024
|
|
1988
|
+
}), O = me(x.prfInputBase64url, { exact: 32 }), F = me(x.ciphertextBase64url, {
|
|
1989
|
+
minimum: 17,
|
|
1990
|
+
maximum: 1024
|
|
1991
|
+
}), D = me(x.hkdfSaltBase64url, { exact: 32 }), ee = me(x.nonceBase64url, { exact: 12 }), G = Ze.encode(x.canonicalUsername), M = Be(x.aad), R = typeof a == "function" ? a() : null;
|
|
1992
|
+
(!R?.signal || typeof R.abort != "function") && (k(z), k(O), k(F), k(D), k(ee), k(G), _("WEBAUTHN_UNAVAILABLE"));
|
|
1993
|
+
let W, q = null, J = !1;
|
|
1994
|
+
try {
|
|
1995
|
+
W = await On({
|
|
1996
|
+
assertCurrent: I,
|
|
1997
|
+
credentialId: z,
|
|
1998
|
+
credentials: r,
|
|
1999
|
+
fillRandom: s,
|
|
2000
|
+
prfInput: O,
|
|
2001
|
+
signal: R.signal
|
|
2002
|
+
}), I();
|
|
2003
|
+
let Q;
|
|
2004
|
+
const ce = W;
|
|
2005
|
+
try {
|
|
2006
|
+
Q = n.importRememberedIdentity({
|
|
2007
|
+
canonicalAad: M,
|
|
2008
|
+
canonicalUsernameUtf8: G,
|
|
2009
|
+
ciphertextAndTag: F,
|
|
2010
|
+
hkdfSalt: D,
|
|
2011
|
+
nonce: ee,
|
|
2012
|
+
prfOutput: ce
|
|
2013
|
+
});
|
|
2014
|
+
} finally {
|
|
2015
|
+
k(ce), W = null;
|
|
2016
|
+
}
|
|
2017
|
+
bt(Q) || _("WASM_FAILURE"), q = Q.handle, (q == null || typeof c != "function") && _("WASM_FAILURE"), c(q);
|
|
2018
|
+
const te = he(Q.identity);
|
|
2019
|
+
return I(), J = !0, Object.freeze({ handle: q, identity: te });
|
|
2020
|
+
} finally {
|
|
2021
|
+
!J && q !== null && typeof l == "function" && (l(q) || _("DESTRUCTION_FAILED")), k(W), k(z), k(O), k(F), k(D), k(ee), k(G), typeof o == "function" && o(R);
|
|
2022
|
+
}
|
|
2023
|
+
},
|
|
2024
|
+
setup: async ({ assertCurrent: I, canonicalUsername: b, handle: x, identity: H, passwordUtf8: z }) => {
|
|
2025
|
+
try {
|
|
2026
|
+
(typeof I != "function" || x === null || x === void 0 || !dt(z) || _e(z) === 0 || _e(z) > 256 || Wt(b) !== b || !f() || typeof n.sealRememberedIdentity != "function" || typeof n.importRememberedIdentity != "function" || typeof c != "function" || typeof l != "function" || typeof d != "function" || typeof a != "function" || typeof o != "function") && (k(z), _("REMEMBER_UNAVAILABLE"));
|
|
2027
|
+
const O = he(H);
|
|
2028
|
+
p().canSetup || (k(z), _("STORAGE_QUARANTINED"));
|
|
2029
|
+
const D = typeof a == "function" ? a() : null;
|
|
2030
|
+
(!D?.signal || typeof D.abort != "function") && (k(z), _("WEBAUTHN_UNAVAILABLE"));
|
|
2031
|
+
let ee, G, M, R, W, q, J, Q, ce, te = null, Ie = null;
|
|
2032
|
+
try {
|
|
2033
|
+
ee = Ue(s, 32), G = Ue(s, 32), M = Ue(s, 32), R = Ue(s, 32), W = Ue(s, 12), I();
|
|
2034
|
+
let ve;
|
|
2035
|
+
try {
|
|
2036
|
+
ve = await r.create({
|
|
2037
|
+
publicKey: {
|
|
2038
|
+
attestation: "none",
|
|
2039
|
+
authenticatorSelection: {
|
|
2040
|
+
residentKey: "preferred",
|
|
2041
|
+
userVerification: "required"
|
|
2042
|
+
},
|
|
2043
|
+
challenge: ee,
|
|
2044
|
+
extensions: { prf: {} },
|
|
2045
|
+
pubKeyCredParams: [
|
|
2046
|
+
{ alg: -7, type: "public-key" },
|
|
2047
|
+
{ alg: -257, type: "public-key" }
|
|
2048
|
+
],
|
|
2049
|
+
rp: { id: ci, name: Ss },
|
|
2050
|
+
timeout: li,
|
|
2051
|
+
user: {
|
|
2052
|
+
displayName: b,
|
|
2053
|
+
id: G,
|
|
2054
|
+
name: b
|
|
2055
|
+
}
|
|
2056
|
+
},
|
|
2057
|
+
signal: D.signal
|
|
2058
|
+
});
|
|
2059
|
+
} catch (Se) {
|
|
2060
|
+
throw I(), Se;
|
|
2061
|
+
}
|
|
2062
|
+
I();
|
|
2063
|
+
const le = fi(ve);
|
|
2064
|
+
q = le.rawId, Ts(le), J = await On({
|
|
2065
|
+
assertCurrent: I,
|
|
2066
|
+
credentialId: q,
|
|
2067
|
+
credentials: r,
|
|
2068
|
+
fillRandom: s,
|
|
2069
|
+
prfInput: M,
|
|
2070
|
+
signal: D.signal
|
|
2071
|
+
}), Q = J.slice(), ce = J.slice(), k(J), J = null;
|
|
2072
|
+
const $e = await N(b);
|
|
2073
|
+
I();
|
|
2074
|
+
const ke = Ge(q), Fe = Object.freeze({
|
|
2075
|
+
credentialIdBase64url: ke,
|
|
2076
|
+
identityScheme: Is,
|
|
2077
|
+
schemaVersion: 2,
|
|
2078
|
+
seedProfile: vs,
|
|
2079
|
+
storageProfile: Ln,
|
|
2080
|
+
usernameSha256: $e
|
|
2081
|
+
}), ge = Be(Fe);
|
|
2082
|
+
let Ae;
|
|
2083
|
+
try {
|
|
2084
|
+
Ae = n.sealRememberedIdentity(x, {
|
|
2085
|
+
canonicalAad: ge,
|
|
2086
|
+
hkdfSalt: R,
|
|
2087
|
+
nonce: W,
|
|
2088
|
+
passwordUtf8: z,
|
|
2089
|
+
prfOutput: Q
|
|
2090
|
+
});
|
|
2091
|
+
} finally {
|
|
2092
|
+
k(z), k(Q);
|
|
2093
|
+
}
|
|
2094
|
+
z = null, Q = null;
|
|
2095
|
+
const We = _e(Ae);
|
|
2096
|
+
(!dt(Ae) || We < 17 || We > 1024) && _("WASM_FAILURE");
|
|
2097
|
+
let ze;
|
|
2098
|
+
try {
|
|
2099
|
+
const Se = u();
|
|
2100
|
+
ze = Se instanceof Date ? Se.toISOString() : new Date(Se).toISOString();
|
|
2101
|
+
} catch {
|
|
2102
|
+
_("CLOCK_FAILURE");
|
|
2103
|
+
}
|
|
2104
|
+
const st = Object.freeze({
|
|
2105
|
+
aad: Fe,
|
|
2106
|
+
canonicalUsername: b,
|
|
2107
|
+
ciphertextBase64url: Ge(Ae),
|
|
2108
|
+
createdAt: ze,
|
|
2109
|
+
credentialIdBase64url: ke,
|
|
2110
|
+
hkdfSaltBase64url: Ge(R),
|
|
2111
|
+
nonceBase64url: Ge(W),
|
|
2112
|
+
prfInputBase64url: Ge(M),
|
|
2113
|
+
schemaVersion: 2,
|
|
2114
|
+
storageProfile: Ln
|
|
2115
|
+
});
|
|
2116
|
+
I(), Ie = $r(i, st);
|
|
2117
|
+
let Ee;
|
|
2118
|
+
const qe = ce;
|
|
2119
|
+
try {
|
|
2120
|
+
Ee = n.importRememberedIdentity({
|
|
2121
|
+
canonicalAad: ge,
|
|
2122
|
+
canonicalUsernameUtf8: Ze.encode(b),
|
|
2123
|
+
ciphertextAndTag: Ae.slice(),
|
|
2124
|
+
hkdfSalt: R.slice(),
|
|
2125
|
+
nonce: W.slice(),
|
|
2126
|
+
prfOutput: qe
|
|
2127
|
+
});
|
|
2128
|
+
} finally {
|
|
2129
|
+
k(qe), ce = null;
|
|
2130
|
+
}
|
|
2131
|
+
bt(Ee) || _("WASM_FAILURE"), te = Ee.handle, (te == null || typeof c != "function") && _("WASM_FAILURE"), c(te);
|
|
2132
|
+
const ot = he(Ee.identity);
|
|
2133
|
+
return Ns(O, ot) || _("IDENTITY_MISMATCH"), I(), (typeof l != "function" || !l(te)) && _("DESTRUCTION_FAILED"), te = null, (typeof d != "function" || !d(x)) && _("DESTRUCTION_FAILED"), I(), Fr(i, Ie), Ie = null, Object.freeze({ remembered: !0 });
|
|
2134
|
+
} finally {
|
|
2135
|
+
te !== null && typeof l == "function" && l(te), k(z), k(ee), k(G), k(J), k(Q), k(ce), k(R), k(W), k(q), typeof o == "function" && o(D);
|
|
2136
|
+
}
|
|
2137
|
+
} finally {
|
|
2138
|
+
k(z);
|
|
2139
|
+
}
|
|
2140
|
+
},
|
|
2141
|
+
supported: f
|
|
2142
|
+
});
|
|
2143
|
+
}
|
|
2144
|
+
const tt = /^[0-9a-f]{64}$/u, Us = /^[A-Za-z0-9_-]{43}$/u, js = Object.freeze([
|
|
2145
|
+
"callbackUri",
|
|
2146
|
+
"clientDisplayName",
|
|
2147
|
+
"clientId",
|
|
2148
|
+
"expiresAt",
|
|
2149
|
+
"operation",
|
|
2150
|
+
"registryVersion",
|
|
2151
|
+
"request",
|
|
2152
|
+
"requestOrigin",
|
|
2153
|
+
"requestSha256",
|
|
2154
|
+
"resultToken",
|
|
2155
|
+
"schemaVersion",
|
|
2156
|
+
"state",
|
|
2157
|
+
"transactionId"
|
|
2158
|
+
]), Bs = Object.freeze(["redirectUri", "schemaVersion", "transactionId"]), Vs = 64 * 1024, Ms = 4 * 1024, $s = new TextEncoder(), Fs = new TextDecoder("utf-8", { fatal: !0 });
|
|
2159
|
+
class It extends Error {
|
|
2160
|
+
constructor() {
|
|
2161
|
+
super("RELAY_FAILURE"), this.name = "WalletRelayError", this.code = "RELAY_FAILURE";
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
function C() {
|
|
2165
|
+
throw new It();
|
|
2166
|
+
}
|
|
2167
|
+
function pi(e) {
|
|
2168
|
+
if (e === null || typeof e != "object" || Array.isArray(e)) return !1;
|
|
2169
|
+
const t = Object.getPrototypeOf(e);
|
|
2170
|
+
return t === Object.prototype || t === null;
|
|
2171
|
+
}
|
|
2172
|
+
function hi(e, t) {
|
|
2173
|
+
pi(e) || C();
|
|
2174
|
+
let n;
|
|
2175
|
+
try {
|
|
2176
|
+
n = Reflect.ownKeys(e);
|
|
2177
|
+
} catch {
|
|
2178
|
+
C();
|
|
2179
|
+
}
|
|
2180
|
+
n.some((s) => typeof s != "string") && C();
|
|
2181
|
+
const i = [...n].sort(), r = [...t].sort();
|
|
2182
|
+
(i.length !== r.length || i.some((s, a) => s !== r[a])) && C();
|
|
2183
|
+
for (const s of i) {
|
|
2184
|
+
let a;
|
|
2185
|
+
try {
|
|
2186
|
+
a = Object.getOwnPropertyDescriptor(e, s);
|
|
2187
|
+
} catch {
|
|
2188
|
+
C();
|
|
2189
|
+
}
|
|
2190
|
+
(!a?.enumerable || !("value" in a) || a.value === void 0) && C();
|
|
2191
|
+
}
|
|
2192
|
+
return e;
|
|
2193
|
+
}
|
|
2194
|
+
function zt(e) {
|
|
2195
|
+
if (Array.isArray(e)) return Object.freeze(e.map(zt));
|
|
2196
|
+
if (!pi(e)) return e;
|
|
2197
|
+
const t = {};
|
|
2198
|
+
for (const n of Object.keys(e).sort()) t[n] = zt(e[n]);
|
|
2199
|
+
return Object.freeze(t);
|
|
2200
|
+
}
|
|
2201
|
+
function Ws(e, t) {
|
|
2202
|
+
(typeof e != "string" || $s.encode(e).byteLength > t || e.charCodeAt(0) === 65279) && C();
|
|
2203
|
+
let n = 0, i = 0;
|
|
2204
|
+
const r = () => {
|
|
2205
|
+
for (; n < e.length && /[\u0009\u000a\u000d\u0020]/u.test(e[n]); ) n += 1;
|
|
2206
|
+
}, s = () => {
|
|
2207
|
+
e[n] !== '"' && C();
|
|
2208
|
+
const c = n;
|
|
2209
|
+
for (n += 1; n < e.length; ) {
|
|
2210
|
+
const l = e.charCodeAt(n);
|
|
2211
|
+
if (l === 34) {
|
|
2212
|
+
n += 1;
|
|
2213
|
+
let d;
|
|
2214
|
+
try {
|
|
2215
|
+
d = JSON.parse(e.slice(c, n));
|
|
2216
|
+
} catch {
|
|
2217
|
+
C();
|
|
2218
|
+
}
|
|
2219
|
+
for (let u = 0; u < d.length; u += 1) {
|
|
2220
|
+
const f = d.charCodeAt(u);
|
|
2221
|
+
if (f >= 55296 && f <= 56319) {
|
|
2222
|
+
const p = d.charCodeAt(u + 1);
|
|
2223
|
+
p >= 56320 && p <= 57343 || C(), u += 1;
|
|
2224
|
+
} else f >= 56320 && f <= 57343 && C();
|
|
2225
|
+
}
|
|
2226
|
+
return d;
|
|
2227
|
+
}
|
|
2228
|
+
l < 32 && C(), l === 92 && (n += 1, n >= e.length && C()), n += 1;
|
|
2229
|
+
}
|
|
2230
|
+
C();
|
|
2231
|
+
}, a = (c = 0) => {
|
|
2232
|
+
(c > 32 || ++i > 4096) && C(), r();
|
|
2233
|
+
const l = e[n];
|
|
2234
|
+
if (l === '"') return s();
|
|
2235
|
+
if (l === "{") {
|
|
2236
|
+
n += 1;
|
|
2237
|
+
const f = /* @__PURE__ */ Object.create(null), p = /* @__PURE__ */ new Set();
|
|
2238
|
+
if (r(), e[n] === "}")
|
|
2239
|
+
return n += 1, f;
|
|
2240
|
+
for (; n < e.length; ) {
|
|
2241
|
+
r();
|
|
2242
|
+
const g = s();
|
|
2243
|
+
if (p.has(g) && C(), p.add(g), r(), e[n] !== ":" && C(), n += 1, f[g] = a(c + 1), r(), e[n] === "}")
|
|
2244
|
+
return n += 1, f;
|
|
2245
|
+
e[n] !== "," && C(), n += 1;
|
|
2246
|
+
}
|
|
2247
|
+
C();
|
|
2248
|
+
}
|
|
2249
|
+
if (l === "[") {
|
|
2250
|
+
n += 1;
|
|
2251
|
+
const f = [];
|
|
2252
|
+
if (r(), e[n] === "]")
|
|
2253
|
+
return n += 1, f;
|
|
2254
|
+
for (; n < e.length; ) {
|
|
2255
|
+
if (f.push(a(c + 1)), r(), e[n] === "]")
|
|
2256
|
+
return n += 1, f;
|
|
2257
|
+
e[n] !== "," && C(), n += 1;
|
|
2258
|
+
}
|
|
2259
|
+
C();
|
|
2260
|
+
}
|
|
2261
|
+
for (const [f, p] of [["true", !0], ["false", !1], ["null", null]])
|
|
2262
|
+
if (e.startsWith(f, n))
|
|
2263
|
+
return n += f.length, p;
|
|
2264
|
+
const d = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/u.exec(e.slice(n));
|
|
2265
|
+
d || C(), n += d[0].length;
|
|
2266
|
+
const u = Number(d[0]);
|
|
2267
|
+
return Number.isFinite(u) || C(), u;
|
|
2268
|
+
};
|
|
2269
|
+
r();
|
|
2270
|
+
const o = a();
|
|
2271
|
+
return r(), n !== e.length && C(), o;
|
|
2272
|
+
}
|
|
2273
|
+
function Nn(e) {
|
|
2274
|
+
try {
|
|
2275
|
+
Promise.resolve(e).catch(() => {
|
|
2276
|
+
});
|
|
2277
|
+
} catch {
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
function yi(e, t = null) {
|
|
2281
|
+
try {
|
|
2282
|
+
const n = t?.cancel;
|
|
2283
|
+
typeof n == "function" && Nn(Reflect.apply(n, t, []));
|
|
2284
|
+
} catch {
|
|
2285
|
+
}
|
|
2286
|
+
if (!t)
|
|
2287
|
+
try {
|
|
2288
|
+
const n = e?.body, i = n?.cancel;
|
|
2289
|
+
typeof i == "function" && Nn(Reflect.apply(i, n, []));
|
|
2290
|
+
} catch {
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
function mi(e, t, n = null) {
|
|
2294
|
+
let i;
|
|
2295
|
+
try {
|
|
2296
|
+
i = Promise.resolve(e);
|
|
2297
|
+
} catch {
|
|
2298
|
+
return Promise.reject(new It());
|
|
2299
|
+
}
|
|
2300
|
+
return t ? new Promise((r, s) => {
|
|
2301
|
+
let a = !1;
|
|
2302
|
+
const o = () => {
|
|
2303
|
+
try {
|
|
2304
|
+
t.removeEventListener?.("abort", l);
|
|
2305
|
+
} catch {
|
|
2306
|
+
}
|
|
2307
|
+
}, c = (d, u) => a ? !1 : (a = !0, o(), d(u), !0), l = () => c(s, new It());
|
|
2308
|
+
try {
|
|
2309
|
+
t.addEventListener?.("abort", l, { once: !0 }), t.aborted === !0 && l();
|
|
2310
|
+
} catch {
|
|
2311
|
+
l();
|
|
2312
|
+
}
|
|
2313
|
+
i.then(
|
|
2314
|
+
(d) => {
|
|
2315
|
+
if (!c(r, d))
|
|
2316
|
+
try {
|
|
2317
|
+
n?.(d);
|
|
2318
|
+
} catch {
|
|
2319
|
+
}
|
|
2320
|
+
},
|
|
2321
|
+
(d) => {
|
|
2322
|
+
c(s, d);
|
|
2323
|
+
}
|
|
2324
|
+
);
|
|
2325
|
+
}) : i;
|
|
2326
|
+
}
|
|
2327
|
+
async function zs(e, t, n, i) {
|
|
2328
|
+
let r = null;
|
|
2329
|
+
try {
|
|
2330
|
+
(!e || e.status !== t || e.redirected === !0 || e.headers?.get?.("cache-control")?.trim().toLowerCase() !== "no-store" || e.headers?.get?.("content-type")?.trim().toLowerCase() !== "application/json; charset=utf-8" || typeof e.body?.getReader != "function") && C(), r = e.body.getReader(), (!r || typeof r.read != "function" || i?.aborted === !0) && C();
|
|
2331
|
+
const s = [];
|
|
2332
|
+
let a = 0;
|
|
2333
|
+
for (; ; ) {
|
|
2334
|
+
i?.aborted === !0 && C();
|
|
2335
|
+
const { done: l, value: d } = await mi(r.read(), i);
|
|
2336
|
+
if (i?.aborted === !0 && C(), l) break;
|
|
2337
|
+
d instanceof Uint8Array || C(), a += d.byteLength, a > n && C(), s.push(d);
|
|
2338
|
+
}
|
|
2339
|
+
const o = new Uint8Array(a);
|
|
2340
|
+
let c = 0;
|
|
2341
|
+
for (const l of s)
|
|
2342
|
+
o.set(l, c), c += l.byteLength;
|
|
2343
|
+
return Ws(Fs.decode(o), n);
|
|
2344
|
+
} catch (s) {
|
|
2345
|
+
if (yi(e, r), s instanceof It) throw s;
|
|
2346
|
+
C();
|
|
2347
|
+
} finally {
|
|
2348
|
+
try {
|
|
2349
|
+
r?.releaseLock?.();
|
|
2350
|
+
} catch {
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
function Tn(e, t) {
|
|
2355
|
+
return hi(e, js), (e.schemaVersion !== 1 || e.transactionId !== t || !tt.test(e.transactionId) || !tt.test(e.state) || !tt.test(e.requestSha256) || !Us.test(e.resultToken) || typeof e.callbackUri != "string" || typeof e.clientDisplayName != "string" || typeof e.clientId != "string" || typeof e.expiresAt != "string" || typeof e.operation != "string" || typeof e.registryVersion != "string" || typeof e.requestOrigin != "string") && C(), zt(e);
|
|
2356
|
+
}
|
|
2357
|
+
function qt(e, t) {
|
|
2358
|
+
hi(t, Bs), (t.schemaVersion !== 1 || t.transactionId !== e.transactionId || typeof t.redirectUri != "string") && C();
|
|
2359
|
+
const n = `${e.callbackUri}#code=`, i = `&state=${e.state}`;
|
|
2360
|
+
(!t.redirectUri.startsWith(n) || !t.redirectUri.endsWith(i)) && C();
|
|
2361
|
+
const r = t.redirectUri.slice(n.length, t.redirectUri.length - i.length);
|
|
2362
|
+
return (!tt.test(r) || t.redirectUri !== `${n}${r}${i}`) && C(), Object.freeze({
|
|
2363
|
+
redirectUri: t.redirectUri,
|
|
2364
|
+
schemaVersion: 1,
|
|
2365
|
+
transactionId: t.transactionId
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
function Cn(e, t, n = void 0) {
|
|
2369
|
+
const i = {
|
|
2370
|
+
cache: "no-store",
|
|
2371
|
+
credentials: "omit",
|
|
2372
|
+
headers: e === "POST" ? { Accept: "application/json", "Content-Type": "application/json" } : { Accept: "application/json" },
|
|
2373
|
+
method: e,
|
|
2374
|
+
mode: "same-origin",
|
|
2375
|
+
redirect: "error",
|
|
2376
|
+
referrerPolicy: "no-referrer",
|
|
2377
|
+
signal: t
|
|
2378
|
+
};
|
|
2379
|
+
return n !== void 0 && (i.body = JSON.stringify(n)), i;
|
|
2380
|
+
}
|
|
2381
|
+
function qs({ fetch: e, location: t }) {
|
|
2382
|
+
(typeof e != "function" || typeof t?.replace != "function") && C();
|
|
2383
|
+
const n = /* @__PURE__ */ new Set(), i = async (r, s, a, o) => {
|
|
2384
|
+
let c;
|
|
2385
|
+
try {
|
|
2386
|
+
c = await mi(e(r, s), s.signal, (l) => yi(l));
|
|
2387
|
+
} catch {
|
|
2388
|
+
C();
|
|
2389
|
+
}
|
|
2390
|
+
return zs(c, a, o, s.signal);
|
|
2391
|
+
};
|
|
2392
|
+
return Object.freeze({
|
|
2393
|
+
async fetchTransaction(r, { signal: s } = {}) {
|
|
2394
|
+
(typeof r != "string" || !tt.test(r)) && C();
|
|
2395
|
+
const a = await i(
|
|
2396
|
+
`/relay/v1/transactions/${r}`,
|
|
2397
|
+
Cn("GET", s),
|
|
2398
|
+
200,
|
|
2399
|
+
Vs
|
|
2400
|
+
);
|
|
2401
|
+
return Tn(a, r);
|
|
2402
|
+
},
|
|
2403
|
+
async publishResult(r, s, { signal: a } = {}) {
|
|
2404
|
+
const o = Tn(r, r?.transactionId), c = await i(
|
|
2405
|
+
`/relay/v1/transactions/${o.transactionId}/result`,
|
|
2406
|
+
Cn("POST", a, {
|
|
2407
|
+
result: s,
|
|
2408
|
+
resultToken: o.resultToken,
|
|
2409
|
+
schemaVersion: 1,
|
|
2410
|
+
transactionId: o.transactionId
|
|
2411
|
+
}),
|
|
2412
|
+
201,
|
|
2413
|
+
Ms
|
|
2414
|
+
), l = qt(o, c);
|
|
2415
|
+
return n.clear(), n.add(l.redirectUri), l;
|
|
2416
|
+
},
|
|
2417
|
+
navigate(r) {
|
|
2418
|
+
(typeof r != "string" || !n.delete(r)) && C();
|
|
2419
|
+
try {
|
|
2420
|
+
Reflect.apply(t.replace, t, [r]);
|
|
2421
|
+
} catch {
|
|
2422
|
+
C();
|
|
2423
|
+
}
|
|
2424
|
+
},
|
|
2425
|
+
revokeNow() {
|
|
2426
|
+
n.clear();
|
|
2427
|
+
},
|
|
2428
|
+
async destroy() {
|
|
2429
|
+
n.clear();
|
|
2430
|
+
}
|
|
2431
|
+
});
|
|
2432
|
+
}
|
|
2433
|
+
const gi = Uint8Array, Hs = gi.prototype.fill, Ke = new TextEncoder();
|
|
2434
|
+
class j extends Error {
|
|
2435
|
+
constructor(t) {
|
|
2436
|
+
super(t), this.name = "WalletOriginError", this.code = t;
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
function w(e) {
|
|
2440
|
+
throw new j(e);
|
|
2441
|
+
}
|
|
2442
|
+
function Je(e) {
|
|
2443
|
+
throw e instanceof Ne ? new j(e.code) : e;
|
|
2444
|
+
}
|
|
2445
|
+
function fe(e) {
|
|
2446
|
+
if (e instanceof gi)
|
|
2447
|
+
try {
|
|
2448
|
+
Hs.call(e, 0);
|
|
2449
|
+
} catch {
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
function Qe(e) {
|
|
2453
|
+
if (typeof e != "string") return !1;
|
|
2454
|
+
for (let t = 0; t < e.length; t += 1) {
|
|
2455
|
+
const n = e.charCodeAt(t);
|
|
2456
|
+
if (n >= 55296 && n <= 56319) {
|
|
2457
|
+
const i = e.charCodeAt(++t);
|
|
2458
|
+
if (!(i >= 56320 && i <= 57343)) return !1;
|
|
2459
|
+
} else if (n >= 56320 && n <= 57343) return !1;
|
|
2460
|
+
}
|
|
2461
|
+
return !0;
|
|
2462
|
+
}
|
|
2463
|
+
function _n(e) {
|
|
2464
|
+
if (!(!e || typeof e != "object")) {
|
|
2465
|
+
try {
|
|
2466
|
+
e.type === "checkbox" && (e.checked = !1);
|
|
2467
|
+
} catch {
|
|
2468
|
+
}
|
|
2469
|
+
try {
|
|
2470
|
+
e.type === "checkbox" && (e.defaultChecked = !1);
|
|
2471
|
+
} catch {
|
|
2472
|
+
}
|
|
2473
|
+
for (const t of ["value", "defaultValue"])
|
|
2474
|
+
try {
|
|
2475
|
+
e[t] = "";
|
|
2476
|
+
} catch {
|
|
2477
|
+
}
|
|
2478
|
+
try {
|
|
2479
|
+
e.disabled = !0;
|
|
2480
|
+
} catch {
|
|
2481
|
+
}
|
|
2482
|
+
try {
|
|
2483
|
+
e.inert = !0;
|
|
2484
|
+
} catch {
|
|
2485
|
+
}
|
|
2486
|
+
for (const t of ["name", "autocomplete"])
|
|
2487
|
+
try {
|
|
2488
|
+
e.removeAttribute?.(t);
|
|
2489
|
+
} catch {
|
|
2490
|
+
}
|
|
2491
|
+
try {
|
|
2492
|
+
e.setSelectionRange?.(0, 0);
|
|
2493
|
+
} catch {
|
|
2494
|
+
}
|
|
2495
|
+
try {
|
|
2496
|
+
e.setCustomValidity?.("");
|
|
2497
|
+
} catch {
|
|
2498
|
+
}
|
|
2499
|
+
for (const t of ["onbeforeinput", "onchange", "oninput", "onkeydown", "onkeyup", "onpaste"])
|
|
2500
|
+
try {
|
|
2501
|
+
e[t] = null;
|
|
2502
|
+
} catch {
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
function Ye(e, t) {
|
|
2507
|
+
const n = /* @__PURE__ */ new Set();
|
|
2508
|
+
for (const i of t) {
|
|
2509
|
+
let r = null;
|
|
2510
|
+
try {
|
|
2511
|
+
r = i?.form ?? i?.closest?.("form") ?? null;
|
|
2512
|
+
} catch {
|
|
2513
|
+
r = null;
|
|
2514
|
+
}
|
|
2515
|
+
r && n.add(r), _n(i);
|
|
2516
|
+
}
|
|
2517
|
+
for (const i of n) {
|
|
2518
|
+
let r = [];
|
|
2519
|
+
try {
|
|
2520
|
+
r = i.querySelectorAll?.("input, textarea") ?? [];
|
|
2521
|
+
} catch {
|
|
2522
|
+
r = [];
|
|
2523
|
+
}
|
|
2524
|
+
for (const s of r) _n(s);
|
|
2525
|
+
try {
|
|
2526
|
+
i.inert = !0, i.setAttribute?.("aria-hidden", "true");
|
|
2527
|
+
const s = e.createElement("div");
|
|
2528
|
+
s.dataset.walletCredentialState = "cleared", i.replaceWith?.(s), i.replaceChildren?.();
|
|
2529
|
+
} catch {
|
|
2530
|
+
try {
|
|
2531
|
+
i.remove?.();
|
|
2532
|
+
} catch {
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
function Gs(e) {
|
|
2538
|
+
let t;
|
|
2539
|
+
try {
|
|
2540
|
+
t = Un(e);
|
|
2541
|
+
} catch {
|
|
2542
|
+
w("WASM_UNAVAILABLE");
|
|
2543
|
+
}
|
|
2544
|
+
const n = t?.sdn, i = t?.sha256;
|
|
2545
|
+
return (!n || typeof n.derivePasswordIdentity != "function" || typeof n.destroySdnIdentity != "function" || typeof i != "function") && w("WASM_UNAVAILABLE"), Object.freeze({ capabilities: n, sha256: i });
|
|
2546
|
+
}
|
|
2547
|
+
function ct(e) {
|
|
2548
|
+
const t = e?.AbortController ?? globalThis.AbortController;
|
|
2549
|
+
return typeof t == "function" ? new t() : null;
|
|
2550
|
+
}
|
|
2551
|
+
class Ks {
|
|
2552
|
+
#d = !1;
|
|
2553
|
+
#m;
|
|
2554
|
+
#h = null;
|
|
2555
|
+
#a = /* @__PURE__ */ new Set();
|
|
2556
|
+
#f = /* @__PURE__ */ new Set();
|
|
2557
|
+
#v = null;
|
|
2558
|
+
#e = !1;
|
|
2559
|
+
#n;
|
|
2560
|
+
#r = 0;
|
|
2561
|
+
#t = null;
|
|
2562
|
+
#p = null;
|
|
2563
|
+
#S = [];
|
|
2564
|
+
#R = /* @__PURE__ */ new Set();
|
|
2565
|
+
#o = /* @__PURE__ */ new Set();
|
|
2566
|
+
#g = null;
|
|
2567
|
+
#C = null;
|
|
2568
|
+
#D = /* @__PURE__ */ new WeakSet();
|
|
2569
|
+
#k = /* @__PURE__ */ new WeakMap();
|
|
2570
|
+
#u = null;
|
|
2571
|
+
#_;
|
|
2572
|
+
#y;
|
|
2573
|
+
#c;
|
|
2574
|
+
#V = !1;
|
|
2575
|
+
#A = null;
|
|
2576
|
+
#i = !1;
|
|
2577
|
+
#L = 0;
|
|
2578
|
+
#l = /* @__PURE__ */ new Set();
|
|
2579
|
+
#x;
|
|
2580
|
+
#O = /* @__PURE__ */ new Set();
|
|
2581
|
+
#s;
|
|
2582
|
+
constructor({
|
|
2583
|
+
credentials: t,
|
|
2584
|
+
document: n,
|
|
2585
|
+
now: i,
|
|
2586
|
+
registry: r,
|
|
2587
|
+
relay: s,
|
|
2588
|
+
rng: a,
|
|
2589
|
+
storage: o,
|
|
2590
|
+
wasm: c,
|
|
2591
|
+
window: l
|
|
2592
|
+
}) {
|
|
2593
|
+
const d = Gs(c);
|
|
2594
|
+
this.#m = d.capabilities, this.#x = d.sha256, this.#_ = r, this.#c = s, this.#n = n, this.#s = l, this.#y = Ps({
|
|
2595
|
+
createRequestController: () => {
|
|
2596
|
+
const u = ct(this.#s);
|
|
2597
|
+
return u && (this.#a.add(u), this.#O.add(u)), u;
|
|
2598
|
+
},
|
|
2599
|
+
credentials: t ?? l?.navigator?.credentials ?? globalThis.navigator?.credentials,
|
|
2600
|
+
destroyHandle: (u) => this.#E(u),
|
|
2601
|
+
module: c,
|
|
2602
|
+
now: i,
|
|
2603
|
+
ownHandle: (u) => this.#o.add(u),
|
|
2604
|
+
ownedHandlesClean: (u) => this.#o.size === 1 && this.#o.has(u) && this.#t === u,
|
|
2605
|
+
releaseRequestController: (u) => {
|
|
2606
|
+
this.#O.delete(u), this.#a.delete(u);
|
|
2607
|
+
},
|
|
2608
|
+
rng: a ?? {
|
|
2609
|
+
getRandomValues: l?.crypto?.getRandomValues?.bind(l.crypto) ?? globalThis.crypto?.getRandomValues?.bind(globalThis.crypto)
|
|
2610
|
+
},
|
|
2611
|
+
storage: o ?? l?.localStorage ?? globalThis.localStorage
|
|
2612
|
+
}), this.#F();
|
|
2613
|
+
}
|
|
2614
|
+
get generation() {
|
|
2615
|
+
return this.#r;
|
|
2616
|
+
}
|
|
2617
|
+
#P() {
|
|
2618
|
+
return this.#r = this.#r >= Number.MAX_SAFE_INTEGER ? 1 : this.#r + 1, this.#r;
|
|
2619
|
+
}
|
|
2620
|
+
#F() {
|
|
2621
|
+
const t = (n, i, r) => {
|
|
2622
|
+
n?.addEventListener?.(i, r), this.#S.push([n, i, r]);
|
|
2623
|
+
};
|
|
2624
|
+
t(this.#s, "pagehide", () => this.revokeNow("pagehide")), t(this.#n, "freeze", () => this.revokeNow("freeze")), t(this.#s, "beforeunload", () => this.revokeNow("beforeunload")), t(this.#s, "pageshow", (n) => {
|
|
2625
|
+
if (n?.persisted === !0) {
|
|
2626
|
+
this.revokeNow("bfcache-restore");
|
|
2627
|
+
try {
|
|
2628
|
+
this.#s.location?.reload?.();
|
|
2629
|
+
} catch {
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
});
|
|
2633
|
+
}
|
|
2634
|
+
#W() {
|
|
2635
|
+
for (const [t, n, i] of this.#S)
|
|
2636
|
+
try {
|
|
2637
|
+
t?.removeEventListener?.(n, i);
|
|
2638
|
+
} catch {
|
|
2639
|
+
}
|
|
2640
|
+
this.#S = [];
|
|
2641
|
+
}
|
|
2642
|
+
#E(t = this.#t) {
|
|
2643
|
+
if (t == null) return !0;
|
|
2644
|
+
if (this.#o.add(t), this.#R.has(t)) return !1;
|
|
2645
|
+
this.#R.add(t);
|
|
2646
|
+
let n = !1;
|
|
2647
|
+
try {
|
|
2648
|
+
this.#m.destroySdnIdentity(t), n = !0;
|
|
2649
|
+
} catch {
|
|
2650
|
+
n = !1;
|
|
2651
|
+
} finally {
|
|
2652
|
+
this.#R.delete(t);
|
|
2653
|
+
}
|
|
2654
|
+
return n ? (this.#o.delete(t), this.#t === t && (this.#t = null, this.#p = null), !0) : !1;
|
|
2655
|
+
}
|
|
2656
|
+
#w() {
|
|
2657
|
+
let t = !0;
|
|
2658
|
+
for (const n of [...this.#o])
|
|
2659
|
+
this.#E(n) || (t = !1);
|
|
2660
|
+
return t;
|
|
2661
|
+
}
|
|
2662
|
+
#M() {
|
|
2663
|
+
const t = [...this.#a];
|
|
2664
|
+
this.#a.clear(), this.#O.clear();
|
|
2665
|
+
for (const n of t)
|
|
2666
|
+
try {
|
|
2667
|
+
n.abort();
|
|
2668
|
+
} catch {
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
#z() {
|
|
2672
|
+
const t = [...this.#O];
|
|
2673
|
+
this.#O.clear();
|
|
2674
|
+
for (const n of t) {
|
|
2675
|
+
this.#a.delete(n);
|
|
2676
|
+
try {
|
|
2677
|
+
n.abort();
|
|
2678
|
+
} catch {
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
#U() {
|
|
2683
|
+
const t = [...this.#l];
|
|
2684
|
+
this.#l.clear();
|
|
2685
|
+
for (const n of t) fe(n);
|
|
2686
|
+
}
|
|
2687
|
+
#N(t = []) {
|
|
2688
|
+
if (this.#f.size === 0) return;
|
|
2689
|
+
const n = new Set(t), i = [];
|
|
2690
|
+
for (const r of this.#f)
|
|
2691
|
+
n.has(r) || i.push(r);
|
|
2692
|
+
this.#f = new Set(
|
|
2693
|
+
[...this.#f].filter((r) => n.has(r))
|
|
2694
|
+
), Ye(this.#n, i);
|
|
2695
|
+
}
|
|
2696
|
+
#j(t = []) {
|
|
2697
|
+
(this.#e || this.#i) && w("STALE_CONTROLLER");
|
|
2698
|
+
const n = this.#P();
|
|
2699
|
+
this.#N(t), this.#z(), this.#U();
|
|
2700
|
+
let i = this.#E();
|
|
2701
|
+
return i && (i = this.#w() && this.#o.size === 0), i || (this.revokeNow("native-destruction-failed"), this.#w(), w("DESTRUCTION_FAILED")), this.#A = null, n;
|
|
2702
|
+
}
|
|
2703
|
+
#B(t, n, {
|
|
2704
|
+
allowPublication: i = !1,
|
|
2705
|
+
retainIdentity: r = !1
|
|
2706
|
+
} = {}) {
|
|
2707
|
+
const s = !this.#e && !this.#i && this.#r === n && this.#t === t, a = this.#t === t || this.#o.has(t);
|
|
2708
|
+
if (!s) {
|
|
2709
|
+
const f = !a || this.#E(t);
|
|
2710
|
+
return f || (this.revokeNow("native-destruction-failed"), this.#w()), Object.freeze({ destroyed: f, permit: null });
|
|
2711
|
+
}
|
|
2712
|
+
const o = this.#L, c = i ? Object.freeze({}) : null;
|
|
2713
|
+
this.#P(), this.#i = !0, this.#d = !1, this.#u = c, this.#o.add(t), this.#t = null, this.#p = null, r || (this.#A = null);
|
|
2714
|
+
const l = this.#h;
|
|
2715
|
+
this.#h = null;
|
|
2716
|
+
let d = this.#E(t);
|
|
2717
|
+
d && (d = this.#w() && this.#o.size === 0), d || (this.#u = null, this.#A = null);
|
|
2718
|
+
try {
|
|
2719
|
+
l?.cancel("STALE_CONTROLLER");
|
|
2720
|
+
} catch {
|
|
2721
|
+
}
|
|
2722
|
+
try {
|
|
2723
|
+
l?.destroy();
|
|
2724
|
+
} catch {
|
|
2725
|
+
}
|
|
2726
|
+
this.#N(), this.#U(), this.#M(), d || this.#w();
|
|
2727
|
+
const u = d && this.#L === o && this.#u === c ? c : null;
|
|
2728
|
+
return u === null && this.#u === c && (this.#u = null), Object.freeze({ destroyed: d, permit: u });
|
|
2729
|
+
}
|
|
2730
|
+
#b(t, n) {
|
|
2731
|
+
(this.#e || this.#i || this.#r !== n || this.#t !== t) && w("STALE_CONTROLLER");
|
|
2732
|
+
}
|
|
2733
|
+
#T(t) {
|
|
2734
|
+
(this.#e || this.#i || this.#r !== t) && w("STALE_CONTROLLER");
|
|
2735
|
+
}
|
|
2736
|
+
#I(t, n) {
|
|
2737
|
+
(this.#e || this.#L !== t || this.#o.size !== 0 || n === null || this.#u !== n) && w("STALE_CONTROLLER");
|
|
2738
|
+
}
|
|
2739
|
+
#$(t) {
|
|
2740
|
+
if (this.#C) return this.#C;
|
|
2741
|
+
const n = this.#g;
|
|
2742
|
+
if (!n || t !== "connected" && t !== "disconnected")
|
|
2743
|
+
return Promise.reject(new j("STALE_CONTROLLER"));
|
|
2744
|
+
this.#g = null, this.#A = null;
|
|
2745
|
+
let i, r;
|
|
2746
|
+
const s = new Promise((a, o) => {
|
|
2747
|
+
i = a, r = o;
|
|
2748
|
+
});
|
|
2749
|
+
return this.#C = s, (async () => {
|
|
2750
|
+
const a = ct(this.#s);
|
|
2751
|
+
a && this.#a.add(a);
|
|
2752
|
+
try {
|
|
2753
|
+
this.#I(n.epoch, n.permit), ne({ document: this.#n, window: this.#s }), typeof this.#c?.publishResult != "function" && w("RELAY_UNAVAILABLE");
|
|
2754
|
+
const o = t === "connected" ? n.connectedResult : Tr();
|
|
2755
|
+
let c;
|
|
2756
|
+
try {
|
|
2757
|
+
c = await this.#c.publishResult(n.transaction, o, {
|
|
2758
|
+
signal: a?.signal
|
|
2759
|
+
});
|
|
2760
|
+
} catch (l) {
|
|
2761
|
+
throw this.#I(n.epoch, n.permit), l;
|
|
2762
|
+
}
|
|
2763
|
+
if (this.#I(n.epoch, n.permit), ne({ document: this.#n, window: this.#s }), typeof this.#c?.navigate == "function") {
|
|
2764
|
+
const l = qt(n.transaction, c);
|
|
2765
|
+
this.#I(n.epoch, n.permit), this.#u = null, this.#c.navigate(l.redirectUri);
|
|
2766
|
+
} else
|
|
2767
|
+
this.#u = null;
|
|
2768
|
+
i(c);
|
|
2769
|
+
} catch (o) {
|
|
2770
|
+
this.#u === n.permit && (this.#u = null);
|
|
2771
|
+
try {
|
|
2772
|
+
this.#c?.revokeNow?.("account-publication-failed");
|
|
2773
|
+
} catch {
|
|
2774
|
+
}
|
|
2775
|
+
r(o);
|
|
2776
|
+
} finally {
|
|
2777
|
+
a && this.#a.delete(a);
|
|
2778
|
+
}
|
|
2779
|
+
})(), s;
|
|
2780
|
+
}
|
|
2781
|
+
registerCredentialControls({ usernameControl: t, passwordControl: n }) {
|
|
2782
|
+
(this.#e || this.#i) && w("STALE_CONTROLLER"), (!t || !n) && w("INVALID_CREDENTIAL_FORM"), this.#f.add(t), this.#f.add(n);
|
|
2783
|
+
}
|
|
2784
|
+
copyPublicIdentity() {
|
|
2785
|
+
const t = this.#p ?? this.#A;
|
|
2786
|
+
t || w("STALE_CONTROLLER");
|
|
2787
|
+
try {
|
|
2788
|
+
return he(t);
|
|
2789
|
+
} catch {
|
|
2790
|
+
w("WASM_FAILURE");
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
supportsRememberedWallet() {
|
|
2794
|
+
return !this.#e && !this.#i && this.#y.supported();
|
|
2795
|
+
}
|
|
2796
|
+
canRestoreRememberedWallet() {
|
|
2797
|
+
if (!this.supportsRememberedWallet()) return !1;
|
|
2798
|
+
try {
|
|
2799
|
+
return this.#y.inspect().canRestore === !0;
|
|
2800
|
+
} catch {
|
|
2801
|
+
return !1;
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
isUiGenerationCurrent(t) {
|
|
2805
|
+
return Number.isSafeInteger(t) && t === this.#r && !this.#e && (!this.#i || this.#g !== null);
|
|
2806
|
+
}
|
|
2807
|
+
listQuarantinedWalletRecords() {
|
|
2808
|
+
(this.#e || this.#i && !this.#g) && w("STALE_CONTROLLER");
|
|
2809
|
+
try {
|
|
2810
|
+
return this.#y.listQuarantine();
|
|
2811
|
+
} catch (t) {
|
|
2812
|
+
throw typeof t?.code == "string" ? new j(t.code) : t;
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
exportQuarantinedWalletRecord(t) {
|
|
2816
|
+
(this.#e || this.#i && !this.#g) && w("STALE_CONTROLLER");
|
|
2817
|
+
try {
|
|
2818
|
+
return this.#y.exportQuarantine(t);
|
|
2819
|
+
} catch (n) {
|
|
2820
|
+
throw typeof n?.code == "string" ? new j(n.code) : n;
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
deleteQuarantinedWalletRecord(t, n) {
|
|
2824
|
+
(this.#e || this.#i && !this.#g) && w("STALE_CONTROLLER");
|
|
2825
|
+
try {
|
|
2826
|
+
return this.#y.deleteQuarantine(t, n);
|
|
2827
|
+
} catch (i) {
|
|
2828
|
+
throw typeof i?.code == "string" ? new j(i.code) : i;
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
canForgetRememberedWallet() {
|
|
2832
|
+
if (this.#e || !this.#A || !this.#g) return !1;
|
|
2833
|
+
try {
|
|
2834
|
+
return this.#y.canForget() === !0;
|
|
2835
|
+
} catch {
|
|
2836
|
+
return !1;
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
forgetRememberedWallet(t) {
|
|
2840
|
+
this.canForgetRememberedWallet() || w("REMEMBER_UNAVAILABLE");
|
|
2841
|
+
try {
|
|
2842
|
+
return this.#y.forget({ confirmation: t });
|
|
2843
|
+
} catch (n) {
|
|
2844
|
+
throw typeof n?.code == "string" ? new j(n.code) : n;
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
async unlockPassword({
|
|
2848
|
+
accountIndex: t = 0,
|
|
2849
|
+
passwordControl: n,
|
|
2850
|
+
rememberControl: i = null,
|
|
2851
|
+
rememberStatus: r = null,
|
|
2852
|
+
usernameControl: s
|
|
2853
|
+
}) {
|
|
2854
|
+
(this.#e || this.#i) && w("STALE_CONTROLLER"), t !== 0 && w("INVALID_ACCOUNT"), (!s || !n) && w("INVALID_CREDENTIAL_FORM");
|
|
2855
|
+
try {
|
|
2856
|
+
ne({ document: this.#n, window: this.#s });
|
|
2857
|
+
} catch (h) {
|
|
2858
|
+
Ye(
|
|
2859
|
+
this.#n,
|
|
2860
|
+
[s, n, i].filter(Boolean)
|
|
2861
|
+
), Je(h);
|
|
2862
|
+
}
|
|
2863
|
+
let a;
|
|
2864
|
+
try {
|
|
2865
|
+
a = this.#j([s, n]);
|
|
2866
|
+
} catch (h) {
|
|
2867
|
+
throw Ye(
|
|
2868
|
+
this.#n,
|
|
2869
|
+
[s, n, i].filter(Boolean)
|
|
2870
|
+
), h;
|
|
2871
|
+
}
|
|
2872
|
+
this.registerCredentialControls({ passwordControl: n, usernameControl: s });
|
|
2873
|
+
let o, c, l, d, u, f, p = null, g = !1;
|
|
2874
|
+
try {
|
|
2875
|
+
try {
|
|
2876
|
+
ne({ document: this.#n, window: this.#s });
|
|
2877
|
+
} catch (A) {
|
|
2878
|
+
Je(A);
|
|
2879
|
+
}
|
|
2880
|
+
this.#T(a);
|
|
2881
|
+
const h = s?.value;
|
|
2882
|
+
p = n?.value, Qe(h) || w("INVALID_USERNAME"), Qe(p) || w("INVALID_PASSWORD");
|
|
2883
|
+
try {
|
|
2884
|
+
o = Wt(h);
|
|
2885
|
+
} catch {
|
|
2886
|
+
w("INVALID_USERNAME");
|
|
2887
|
+
}
|
|
2888
|
+
c = Ke.encode(h), f = Ke.encode(p), g = i?.checked === !0 && i?.disabled !== !0 && this.#y.supported(), g ? ((f.length === 0 || f.length > 256) && w("INVALID_PASSWORD"), l = f.slice(), d = f.slice(), u = d, fe(f), f = null) : (l = f, f = null), this.#l.add(c), this.#l.add(l), d && this.#l.add(d);
|
|
2889
|
+
} finally {
|
|
2890
|
+
if (p = null, i && typeof i == "object") {
|
|
2891
|
+
try {
|
|
2892
|
+
i.checked = !1;
|
|
2893
|
+
} catch {
|
|
2894
|
+
}
|
|
2895
|
+
try {
|
|
2896
|
+
i.defaultChecked = !1;
|
|
2897
|
+
} catch {
|
|
2898
|
+
}
|
|
2899
|
+
try {
|
|
2900
|
+
i.disabled = !0;
|
|
2901
|
+
} catch {
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
fe(f), this.#N();
|
|
2905
|
+
}
|
|
2906
|
+
let E;
|
|
2907
|
+
try {
|
|
2908
|
+
E = await this.#m.derivePasswordIdentity({
|
|
2909
|
+
accountIndex: t,
|
|
2910
|
+
passwordUtf8: l,
|
|
2911
|
+
usernameUtf8: c
|
|
2912
|
+
}), (!E || typeof E != "object") && w("WASM_FAILURE");
|
|
2913
|
+
const h = E.handle;
|
|
2914
|
+
h == null && w("WASM_FAILURE"), this.#o.add(h);
|
|
2915
|
+
let A;
|
|
2916
|
+
try {
|
|
2917
|
+
A = he(E.identity);
|
|
2918
|
+
} catch {
|
|
2919
|
+
const m = this.#E(h);
|
|
2920
|
+
E = null, m || (this.revokeNow("native-destruction-failed"), w("DESTRUCTION_FAILED")), w("WASM_FAILURE");
|
|
2921
|
+
}
|
|
2922
|
+
if ((this.#e || this.#i || this.#r !== a) && (this.#E(h) || (this.revokeNow("native-destruction-failed"), w("DESTRUCTION_FAILED")), w("STALE_CONTROLLER")), this.#t = h, this.#p = A, g)
|
|
2923
|
+
try {
|
|
2924
|
+
await this.#y.setup({
|
|
2925
|
+
assertCurrent: () => this.#b(h, a),
|
|
2926
|
+
canonicalUsername: o,
|
|
2927
|
+
handle: h,
|
|
2928
|
+
identity: A,
|
|
2929
|
+
passwordUtf8: d
|
|
2930
|
+
}), this.#b(h, a), this.#l.delete(u), d = null;
|
|
2931
|
+
try {
|
|
2932
|
+
r && (r.textContent = "Wallet remembered on this device.");
|
|
2933
|
+
} catch {
|
|
2934
|
+
}
|
|
2935
|
+
} catch {
|
|
2936
|
+
fe(d), this.#l.delete(u), d = null, (this.#e || this.#i || this.#r !== a || this.#t !== h) && w("STALE_CONTROLLER"), this.#o.size === 1 && this.#o.has(h) && this.#t === h || (this.revokeNow("remembered-wallet-cleanup-failed"), w("DESTRUCTION_FAILED"));
|
|
2937
|
+
try {
|
|
2938
|
+
r && (r.textContent = "Wallet was not remembered.");
|
|
2939
|
+
} catch {
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
return this.#b(h, a), A;
|
|
2943
|
+
} catch (h) {
|
|
2944
|
+
throw h instanceof j && h.code === "DESTRUCTION_FAILED" || (this.#e || this.#i || this.#r !== a) && w("STALE_CONTROLLER"), h;
|
|
2945
|
+
} finally {
|
|
2946
|
+
fe(c), fe(l), fe(d), fe(u), this.#l.delete(c), this.#l.delete(l), this.#l.delete(u);
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
async unlockRemembered({ accountIndex: t = 0 } = {}) {
|
|
2950
|
+
(this.#e || this.#i) && w("STALE_CONTROLLER"), t !== 0 && w("INVALID_ACCOUNT"), this.canRestoreRememberedWallet() || w("REMEMBER_UNAVAILABLE");
|
|
2951
|
+
try {
|
|
2952
|
+
ne({ document: this.#n, window: this.#s });
|
|
2953
|
+
} catch (i) {
|
|
2954
|
+
Je(i);
|
|
2955
|
+
}
|
|
2956
|
+
const n = this.#j();
|
|
2957
|
+
try {
|
|
2958
|
+
const i = await this.#y.restore({
|
|
2959
|
+
assertCurrent: () => this.#T(n)
|
|
2960
|
+
}), r = i?.handle;
|
|
2961
|
+
(r == null || !this.#o.has(r)) && w("WASM_FAILURE");
|
|
2962
|
+
let s;
|
|
2963
|
+
try {
|
|
2964
|
+
s = he(i.identity);
|
|
2965
|
+
} catch {
|
|
2966
|
+
w("WASM_FAILURE");
|
|
2967
|
+
}
|
|
2968
|
+
return (this.#e || this.#i || this.#r !== n) && (this.#E(r) || (this.revokeNow("native-destruction-failed"), w("DESTRUCTION_FAILED")), w("STALE_CONTROLLER")), this.#t = r, this.#p = s, s;
|
|
2969
|
+
} catch (i) {
|
|
2970
|
+
throw i instanceof j && i.code === "DESTRUCTION_FAILED" || ((this.#e || this.#i || this.#r !== n) && w("STALE_CONTROLLER"), this.#o.size > 0 && (this.#w(), this.#o.size > 0 && (this.revokeNow("remembered-wallet-cleanup-failed"), w("DESTRUCTION_FAILED"))), i instanceof j) ? i : typeof i?.code == "string" ? new j(i.code) : i;
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
async unlockLegacy({
|
|
2974
|
+
accountIndex: t = 0,
|
|
2975
|
+
mnemonicControl: n = null,
|
|
2976
|
+
operation: i,
|
|
2977
|
+
passwordControl: r = null,
|
|
2978
|
+
profile: s,
|
|
2979
|
+
usernameControl: a = null
|
|
2980
|
+
}) {
|
|
2981
|
+
(this.#e || this.#i) && w("STALE_CONTROLLER"), i !== "sdn.auth.raw-challenge.v1" && w("OPERATION_NOT_ALLOWED"), t !== 0 && w("INVALID_ACCOUNT");
|
|
2982
|
+
const o = s === "password-fast-v1-legacy";
|
|
2983
|
+
!o && !(s === "bip39-mnemonic-v1-legacy") && w("INVALID_LEGACY_PROFILE"), o ? (!a || !r) && w("INVALID_CREDENTIAL_FORM") : (!n || typeof n != "object") && w("INVALID_CREDENTIAL_FORM");
|
|
2984
|
+
const l = o ? [a, r] : [n];
|
|
2985
|
+
try {
|
|
2986
|
+
ne({ document: this.#n, window: this.#s });
|
|
2987
|
+
} catch (E) {
|
|
2988
|
+
Ye(this.#n, l), Je(E);
|
|
2989
|
+
}
|
|
2990
|
+
let d;
|
|
2991
|
+
try {
|
|
2992
|
+
d = this.#j(l);
|
|
2993
|
+
} catch (E) {
|
|
2994
|
+
throw Ye(this.#n, l), E;
|
|
2995
|
+
}
|
|
2996
|
+
o ? this.registerCredentialControls({ passwordControl: r, usernameControl: a }) : this.#f.add(n);
|
|
2997
|
+
let u, f, p;
|
|
2998
|
+
try {
|
|
2999
|
+
try {
|
|
3000
|
+
ne({ document: this.#n, window: this.#s });
|
|
3001
|
+
} catch (E) {
|
|
3002
|
+
Je(E);
|
|
3003
|
+
}
|
|
3004
|
+
if (this.#T(d), o) {
|
|
3005
|
+
const E = a?.value, h = r?.value;
|
|
3006
|
+
Qe(E) || w("INVALID_USERNAME"), Qe(h) || w("INVALID_PASSWORD"), u = Ke.encode(E), f = Ke.encode(h), this.#l.add(u), this.#l.add(f);
|
|
3007
|
+
} else {
|
|
3008
|
+
const E = n?.value;
|
|
3009
|
+
Qe(E) || w("INVALID_MNEMONIC"), p = Ke.encode(E), this.#l.add(p);
|
|
3010
|
+
}
|
|
3011
|
+
} finally {
|
|
3012
|
+
this.#N();
|
|
3013
|
+
}
|
|
3014
|
+
let g;
|
|
3015
|
+
try {
|
|
3016
|
+
g = o ? await this.#m.deriveLegacyPasswordIdentity({
|
|
3017
|
+
accountIndex: t,
|
|
3018
|
+
passwordUtf8: f,
|
|
3019
|
+
usernameUtf8: u
|
|
3020
|
+
}) : await this.#m.importLegacyMnemonicIdentity({ accountIndex: t, mnemonicUtf8: p }), (!g || typeof g != "object") && w("WASM_FAILURE");
|
|
3021
|
+
const E = g.handle;
|
|
3022
|
+
E == null && w("WASM_FAILURE"), this.#o.add(E);
|
|
3023
|
+
let h;
|
|
3024
|
+
try {
|
|
3025
|
+
h = Xr(g.identity, { accountIndex: t, profile: s });
|
|
3026
|
+
} catch {
|
|
3027
|
+
const A = this.#E(E);
|
|
3028
|
+
g = null, A || (this.revokeNow("native-destruction-failed"), w("DESTRUCTION_FAILED")), w("WASM_FAILURE");
|
|
3029
|
+
}
|
|
3030
|
+
return (this.#e || this.#i || this.#r !== d) && (this.#E(E) || (this.revokeNow("native-destruction-failed"), w("DESTRUCTION_FAILED")), w("STALE_CONTROLLER")), this.#t = E, this.#p = h, h;
|
|
3031
|
+
} catch (E) {
|
|
3032
|
+
throw E instanceof j && E.code === "DESTRUCTION_FAILED" || (this.#e || this.#i || this.#r !== d) && w("STALE_CONTROLLER"), E;
|
|
3033
|
+
} finally {
|
|
3034
|
+
fe(u), fe(f), fe(p), this.#l.delete(u), this.#l.delete(f), this.#l.delete(p);
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
async prepare(t) {
|
|
3038
|
+
(this.#e || this.#i) && w("STALE_CONTROLLER"), this.#d && w("TRANSACTION_IN_PROGRESS"), this.#d = !0;
|
|
3039
|
+
const n = this.#r, i = typeof t == "string" ? t : t?.transactionId ?? null, r = ct(this.#s);
|
|
3040
|
+
r && this.#a.add(r);
|
|
3041
|
+
try {
|
|
3042
|
+
const s = typeof this.#c?.fetchTransaction == "function" ? await this.#c.fetchTransaction(t, { signal: r?.signal }) : t;
|
|
3043
|
+
this.#T(n);
|
|
3044
|
+
const a = await xt(s, {
|
|
3045
|
+
expectedTransactionId: i,
|
|
3046
|
+
registry: this.#_,
|
|
3047
|
+
relay: this.#c,
|
|
3048
|
+
sha256: this.#x,
|
|
3049
|
+
window: this.#s
|
|
3050
|
+
});
|
|
3051
|
+
return this.#T(n), ne({ document: this.#n, window: this.#s }), this.#D.add(a), r && this.#k.set(a, r), a;
|
|
3052
|
+
} catch (s) {
|
|
3053
|
+
const a = this.#e || this.#i || this.#r !== n;
|
|
3054
|
+
throw this.#d = !1, r && this.#a.delete(r), a && w("STALE_CONTROLLER"), s instanceof j ? s : s instanceof Ne ? new j(s.code) : s;
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
async executePrepared(t) {
|
|
3058
|
+
(!t || typeof t != "object" || !this.#D.has(t)) && w("INVALID_TRANSACTION"), this.#D.delete(t);
|
|
3059
|
+
const n = this.#k.get(t) ?? null;
|
|
3060
|
+
this.#k.delete(t), (this.#e || this.#i || this.#t === null) && (n && this.#a.delete(n), this.#d = !1, w("STALE_CONTROLLER"));
|
|
3061
|
+
const i = this.#t, r = this.#p, s = this.#r;
|
|
3062
|
+
let a = !1;
|
|
3063
|
+
try {
|
|
3064
|
+
this.#b(i, s);
|
|
3065
|
+
let o = await xt(t.transaction, {
|
|
3066
|
+
expectedTransactionId: t.transaction.transactionId,
|
|
3067
|
+
registry: this.#_,
|
|
3068
|
+
relay: this.#c,
|
|
3069
|
+
sha256: this.#x,
|
|
3070
|
+
window: this.#s
|
|
3071
|
+
});
|
|
3072
|
+
this.#b(i, s), ne({ document: this.#n, window: this.#s }), this.#h = Or({
|
|
3073
|
+
binding: o.binding,
|
|
3074
|
+
document: this.#n,
|
|
3075
|
+
identity: r,
|
|
3076
|
+
request: o.request,
|
|
3077
|
+
transaction: o.transaction
|
|
3078
|
+
}), await this.#h.promise, this.#b(i, s), ne({ document: this.#n, window: this.#s }), o = await xt(t.transaction, {
|
|
3079
|
+
expectedTransactionId: t.transaction.transactionId,
|
|
3080
|
+
registry: this.#_,
|
|
3081
|
+
relay: this.#c,
|
|
3082
|
+
sha256: this.#x,
|
|
3083
|
+
window: this.#s
|
|
3084
|
+
}), this.#b(i, s), ne({ document: this.#n, window: this.#s });
|
|
3085
|
+
const c = await Nr({
|
|
3086
|
+
assertCurrent: () => this.#b(i, s),
|
|
3087
|
+
binding: o.binding,
|
|
3088
|
+
handle: i,
|
|
3089
|
+
identity: r,
|
|
3090
|
+
transaction: o.transaction,
|
|
3091
|
+
wasm: this.#m
|
|
3092
|
+
});
|
|
3093
|
+
this.#b(i, s), ne({ document: this.#n, window: this.#s });
|
|
3094
|
+
const l = o.transaction.operation === "sdn.wallet.account.v1";
|
|
3095
|
+
l && (this.#A = he(r));
|
|
3096
|
+
const d = this.#B(i, s, {
|
|
3097
|
+
allowPublication: !0,
|
|
3098
|
+
retainIdentity: l
|
|
3099
|
+
});
|
|
3100
|
+
a = !0, d.destroyed || (this.#A = null, w("DESTRUCTION_FAILED"));
|
|
3101
|
+
const u = this.#L, f = d.permit;
|
|
3102
|
+
if (l)
|
|
3103
|
+
return this.#I(u, f), this.#g = Object.freeze({
|
|
3104
|
+
connectedResult: c,
|
|
3105
|
+
epoch: u,
|
|
3106
|
+
permit: f,
|
|
3107
|
+
transaction: o.transaction
|
|
3108
|
+
}), Object.freeze({ accountReady: !0 });
|
|
3109
|
+
try {
|
|
3110
|
+
this.#I(u, f), typeof this.#c?.publishResult != "function" && w("RELAY_UNAVAILABLE");
|
|
3111
|
+
const p = ct(this.#s);
|
|
3112
|
+
p && this.#a.add(p);
|
|
3113
|
+
let g;
|
|
3114
|
+
try {
|
|
3115
|
+
try {
|
|
3116
|
+
g = await this.#c.publishResult(o.transaction, c, {
|
|
3117
|
+
signal: p?.signal
|
|
3118
|
+
});
|
|
3119
|
+
} catch (E) {
|
|
3120
|
+
throw this.#I(u, f), E;
|
|
3121
|
+
}
|
|
3122
|
+
} finally {
|
|
3123
|
+
p && this.#a.delete(p);
|
|
3124
|
+
}
|
|
3125
|
+
if (this.#I(u, f), ne({ document: this.#n, window: this.#s }), typeof this.#c?.navigate == "function") {
|
|
3126
|
+
const E = qt(o.transaction, g);
|
|
3127
|
+
this.#I(u, f), this.#u = null, this.#c.navigate(E.redirectUri);
|
|
3128
|
+
} else
|
|
3129
|
+
this.#u = null;
|
|
3130
|
+
return g;
|
|
3131
|
+
} finally {
|
|
3132
|
+
this.#u === f && (this.#u = null);
|
|
3133
|
+
}
|
|
3134
|
+
} catch (o) {
|
|
3135
|
+
throw !a && (this.#r !== s || this.#t !== i) && w("STALE_CONTROLLER"), o instanceof j ? o : o instanceof Ne ? new j(o.code) : o;
|
|
3136
|
+
} finally {
|
|
3137
|
+
n && this.#a.delete(n), a || this.#B(i, s);
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
async execute(t) {
|
|
3141
|
+
(this.#e || this.#i || this.#t === null) && w("STALE_CONTROLLER");
|
|
3142
|
+
const n = this.#t, i = this.#r;
|
|
3143
|
+
try {
|
|
3144
|
+
const r = await this.prepare(t);
|
|
3145
|
+
return await this.executePrepared(r);
|
|
3146
|
+
} catch (r) {
|
|
3147
|
+
throw !this.#i && this.#t === n && this.#B(n, i), r;
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
async logout() {
|
|
3151
|
+
if (this.#g || this.#C)
|
|
3152
|
+
return this.#$("disconnected");
|
|
3153
|
+
this.revokeNow("logout"), this.#A = null;
|
|
3154
|
+
}
|
|
3155
|
+
returnToSite() {
|
|
3156
|
+
return this.#$("connected");
|
|
3157
|
+
}
|
|
3158
|
+
revokeNow(t) {
|
|
3159
|
+
if (this.#L = this.#L >= Number.MAX_SAFE_INTEGER ? 1 : this.#L + 1, this.#u = null, this.#g = null, this.#e) {
|
|
3160
|
+
this.#w();
|
|
3161
|
+
return;
|
|
3162
|
+
}
|
|
3163
|
+
!this.#i && (this.#i = !0, this.#P()), this.#d = !1, this.#A = null, this.#t !== null && this.#t !== void 0 && this.#o.add(this.#t), this.#t = null, this.#p = null;
|
|
3164
|
+
const i = this.#h;
|
|
3165
|
+
this.#h = null;
|
|
3166
|
+
const r = !this.#V;
|
|
3167
|
+
r && (this.#V = !0);
|
|
3168
|
+
try {
|
|
3169
|
+
i?.cancel("STALE_CONTROLLER");
|
|
3170
|
+
} catch {
|
|
3171
|
+
}
|
|
3172
|
+
try {
|
|
3173
|
+
i?.destroy();
|
|
3174
|
+
} catch {
|
|
3175
|
+
}
|
|
3176
|
+
if (this.#N(), this.#U(), this.#M(), this.#w(), r)
|
|
3177
|
+
try {
|
|
3178
|
+
this.#c?.revokeNow?.(t);
|
|
3179
|
+
} catch {
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
destroy(t = "destroy") {
|
|
3183
|
+
if (this.#v)
|
|
3184
|
+
return this.#w(), this.#v;
|
|
3185
|
+
let n;
|
|
3186
|
+
const i = new Promise((r) => {
|
|
3187
|
+
n = r;
|
|
3188
|
+
});
|
|
3189
|
+
return this.#v = i, (async () => {
|
|
3190
|
+
try {
|
|
3191
|
+
this.revokeNow(t), this.#e = !0, this.#W();
|
|
3192
|
+
try {
|
|
3193
|
+
await this.#c?.destroy?.(t);
|
|
3194
|
+
} catch {
|
|
3195
|
+
}
|
|
3196
|
+
} finally {
|
|
3197
|
+
n();
|
|
3198
|
+
}
|
|
3199
|
+
})(), i;
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
const Js = [
|
|
3203
|
+
{
|
|
3204
|
+
allowedOperations: [
|
|
3205
|
+
"sdn.wallet.account.v1",
|
|
3206
|
+
"sdn.wallet.connect.v1"
|
|
3207
|
+
],
|
|
3208
|
+
audiences: [],
|
|
3209
|
+
callbackUri: "https://spacedatanetwork.org/wallet-callback.html",
|
|
3210
|
+
clientDisplayName: "Space Data Network",
|
|
3211
|
+
clientId: "sdn-landing-web-v1",
|
|
3212
|
+
operationBindings: [
|
|
3213
|
+
{
|
|
3214
|
+
audience: null,
|
|
3215
|
+
maxLifetimeSeconds: 300,
|
|
3216
|
+
operation: "sdn.wallet.account.v1",
|
|
3217
|
+
registryRow: null,
|
|
3218
|
+
serviceActivationState: null,
|
|
3219
|
+
serviceInstance: null
|
|
3220
|
+
},
|
|
3221
|
+
{
|
|
3222
|
+
audience: null,
|
|
3223
|
+
maxLifetimeSeconds: 300,
|
|
3224
|
+
operation: "sdn.wallet.connect.v1",
|
|
3225
|
+
registryRow: null,
|
|
3226
|
+
serviceActivationState: null,
|
|
3227
|
+
serviceInstance: null
|
|
3228
|
+
}
|
|
3229
|
+
],
|
|
3230
|
+
requestOrigin: "https://spacedatanetwork.org"
|
|
3231
|
+
},
|
|
3232
|
+
{
|
|
3233
|
+
allowedOperations: [
|
|
3234
|
+
"sdn.wallet.account.v1",
|
|
3235
|
+
"sdn.wallet.connect.v1"
|
|
3236
|
+
],
|
|
3237
|
+
audiences: [],
|
|
3238
|
+
callbackUri: "https://spacedatastandards.org/wallet-callback.html",
|
|
3239
|
+
clientDisplayName: "Space Data Standards",
|
|
3240
|
+
clientId: "sdn-standards-web-v1",
|
|
3241
|
+
operationBindings: [
|
|
3242
|
+
{
|
|
3243
|
+
audience: null,
|
|
3244
|
+
maxLifetimeSeconds: 300,
|
|
3245
|
+
operation: "sdn.wallet.account.v1",
|
|
3246
|
+
registryRow: null,
|
|
3247
|
+
serviceActivationState: null,
|
|
3248
|
+
serviceInstance: null
|
|
3249
|
+
},
|
|
3250
|
+
{
|
|
3251
|
+
audience: null,
|
|
3252
|
+
maxLifetimeSeconds: 300,
|
|
3253
|
+
operation: "sdn.wallet.connect.v1",
|
|
3254
|
+
registryRow: null,
|
|
3255
|
+
serviceActivationState: null,
|
|
3256
|
+
serviceInstance: null
|
|
3257
|
+
}
|
|
3258
|
+
],
|
|
3259
|
+
requestOrigin: "https://spacedatastandards.org"
|
|
3260
|
+
},
|
|
3261
|
+
{
|
|
3262
|
+
allowedOperations: [
|
|
3263
|
+
"sdn.wallet.account.v1",
|
|
3264
|
+
"sdn.wallet.connect.v1"
|
|
3265
|
+
],
|
|
3266
|
+
audiences: [],
|
|
3267
|
+
callbackUri: "https://digitalarsenal.github.io/flatbuffers/wallet-callback.html",
|
|
3268
|
+
clientDisplayName: "FlatBuffers Documentation",
|
|
3269
|
+
clientId: "sdn-flatbuffers-pages-v1",
|
|
3270
|
+
operationBindings: [
|
|
3271
|
+
{
|
|
3272
|
+
audience: null,
|
|
3273
|
+
maxLifetimeSeconds: 300,
|
|
3274
|
+
operation: "sdn.wallet.account.v1",
|
|
3275
|
+
registryRow: null,
|
|
3276
|
+
serviceActivationState: null,
|
|
3277
|
+
serviceInstance: null
|
|
3278
|
+
},
|
|
3279
|
+
{
|
|
3280
|
+
audience: null,
|
|
3281
|
+
maxLifetimeSeconds: 300,
|
|
3282
|
+
operation: "sdn.wallet.connect.v1",
|
|
3283
|
+
registryRow: null,
|
|
3284
|
+
serviceActivationState: null,
|
|
3285
|
+
serviceInstance: null
|
|
3286
|
+
}
|
|
3287
|
+
],
|
|
3288
|
+
requestOrigin: "https://digitalarsenal.github.io"
|
|
3289
|
+
},
|
|
3290
|
+
{
|
|
3291
|
+
allowedOperations: [
|
|
3292
|
+
"sdn.wallet.account.v1",
|
|
3293
|
+
"sdn.wallet.connect.v1"
|
|
3294
|
+
],
|
|
3295
|
+
audiences: [],
|
|
3296
|
+
callbackUri: "https://digitalarsenal.github.io/flatsql/wallet-callback.html",
|
|
3297
|
+
clientDisplayName: "FlatSQL Documentation",
|
|
3298
|
+
clientId: "sdn-flatsql-pages-v1",
|
|
3299
|
+
operationBindings: [
|
|
3300
|
+
{
|
|
3301
|
+
audience: null,
|
|
3302
|
+
maxLifetimeSeconds: 300,
|
|
3303
|
+
operation: "sdn.wallet.account.v1",
|
|
3304
|
+
registryRow: null,
|
|
3305
|
+
serviceActivationState: null,
|
|
3306
|
+
serviceInstance: null
|
|
3307
|
+
},
|
|
3308
|
+
{
|
|
3309
|
+
audience: null,
|
|
3310
|
+
maxLifetimeSeconds: 300,
|
|
3311
|
+
operation: "sdn.wallet.connect.v1",
|
|
3312
|
+
registryRow: null,
|
|
3313
|
+
serviceActivationState: null,
|
|
3314
|
+
serviceInstance: null
|
|
3315
|
+
}
|
|
3316
|
+
],
|
|
3317
|
+
requestOrigin: "https://digitalarsenal.github.io"
|
|
3318
|
+
},
|
|
3319
|
+
{
|
|
3320
|
+
allowedOperations: [
|
|
3321
|
+
"sdn.wallet.account.v1",
|
|
3322
|
+
"sdn.wallet.connect.v1"
|
|
3323
|
+
],
|
|
3324
|
+
audiences: [],
|
|
3325
|
+
callbackUri: "https://digitalarsenal.github.io/space-data-module-sdk/wallet-callback.html",
|
|
3326
|
+
clientDisplayName: "Space Data Module SDK",
|
|
3327
|
+
clientId: "sdn-module-sdk-pages-v1",
|
|
3328
|
+
operationBindings: [
|
|
3329
|
+
{
|
|
3330
|
+
audience: null,
|
|
3331
|
+
maxLifetimeSeconds: 300,
|
|
3332
|
+
operation: "sdn.wallet.account.v1",
|
|
3333
|
+
registryRow: null,
|
|
3334
|
+
serviceActivationState: null,
|
|
3335
|
+
serviceInstance: null
|
|
3336
|
+
},
|
|
3337
|
+
{
|
|
3338
|
+
audience: null,
|
|
3339
|
+
maxLifetimeSeconds: 300,
|
|
3340
|
+
operation: "sdn.wallet.connect.v1",
|
|
3341
|
+
registryRow: null,
|
|
3342
|
+
serviceActivationState: null,
|
|
3343
|
+
serviceInstance: null
|
|
3344
|
+
}
|
|
3345
|
+
],
|
|
3346
|
+
requestOrigin: "https://digitalarsenal.github.io"
|
|
3347
|
+
},
|
|
3348
|
+
{
|
|
3349
|
+
allowedOperations: [
|
|
3350
|
+
"sdn.wallet.account.v1",
|
|
3351
|
+
"sdn.wallet.connect.v1"
|
|
3352
|
+
],
|
|
3353
|
+
audiences: [],
|
|
3354
|
+
callbackUri: "https://spaceaware.io/wallet/callback",
|
|
3355
|
+
clientDisplayName: "SpaceAware",
|
|
3356
|
+
clientId: "spaceaware-web-v1",
|
|
3357
|
+
operationBindings: [
|
|
3358
|
+
{
|
|
3359
|
+
audience: null,
|
|
3360
|
+
maxLifetimeSeconds: 300,
|
|
3361
|
+
operation: "sdn.wallet.account.v1",
|
|
3362
|
+
registryRow: null,
|
|
3363
|
+
serviceActivationState: null,
|
|
3364
|
+
serviceInstance: null
|
|
3365
|
+
},
|
|
3366
|
+
{
|
|
3367
|
+
audience: null,
|
|
3368
|
+
maxLifetimeSeconds: 300,
|
|
3369
|
+
operation: "sdn.wallet.connect.v1",
|
|
3370
|
+
registryRow: null,
|
|
3371
|
+
serviceActivationState: null,
|
|
3372
|
+
serviceInstance: null
|
|
3373
|
+
}
|
|
3374
|
+
],
|
|
3375
|
+
requestOrigin: "https://spaceaware.io"
|
|
3376
|
+
},
|
|
3377
|
+
{
|
|
3378
|
+
allowedOperations: [
|
|
3379
|
+
"sdn.auth.jcs-envelope.v2",
|
|
3380
|
+
"sdn.auth.raw-challenge.v1",
|
|
3381
|
+
"sdn.wallet.account.v1",
|
|
3382
|
+
"sdn.wallet.connect.v1"
|
|
3383
|
+
],
|
|
3384
|
+
audiences: [
|
|
3385
|
+
"sdn-login:sdn.spaceaware.io"
|
|
3386
|
+
],
|
|
3387
|
+
callbackUri: "https://sdn.spaceaware.io/wallet/callback",
|
|
3388
|
+
clientDisplayName: "SDN Node Console",
|
|
3389
|
+
clientId: "sdn-node-console-v1",
|
|
3390
|
+
operationBindings: [
|
|
3391
|
+
{
|
|
3392
|
+
audience: "sdn-login:sdn.spaceaware.io",
|
|
3393
|
+
maxLifetimeSeconds: 300,
|
|
3394
|
+
operation: "sdn.auth.jcs-envelope.v2",
|
|
3395
|
+
registryRow: "sdn-node-console-v2",
|
|
3396
|
+
serviceActivationState: null,
|
|
3397
|
+
serviceInstance: null
|
|
3398
|
+
},
|
|
3399
|
+
{
|
|
3400
|
+
audience: "sdn-login:sdn.spaceaware.io",
|
|
3401
|
+
maxLifetimeSeconds: 300,
|
|
3402
|
+
operation: "sdn.auth.raw-challenge.v1",
|
|
3403
|
+
registryRow: null,
|
|
3404
|
+
serviceActivationState: null,
|
|
3405
|
+
serviceInstance: null
|
|
3406
|
+
},
|
|
3407
|
+
{
|
|
3408
|
+
audience: null,
|
|
3409
|
+
maxLifetimeSeconds: 300,
|
|
3410
|
+
operation: "sdn.wallet.account.v1",
|
|
3411
|
+
registryRow: null,
|
|
3412
|
+
serviceActivationState: null,
|
|
3413
|
+
serviceInstance: null
|
|
3414
|
+
},
|
|
3415
|
+
{
|
|
3416
|
+
audience: null,
|
|
3417
|
+
maxLifetimeSeconds: 300,
|
|
3418
|
+
operation: "sdn.wallet.connect.v1",
|
|
3419
|
+
registryRow: null,
|
|
3420
|
+
serviceActivationState: null,
|
|
3421
|
+
serviceInstance: null
|
|
3422
|
+
}
|
|
3423
|
+
],
|
|
3424
|
+
requestOrigin: "https://sdn.spaceaware.io"
|
|
3425
|
+
},
|
|
3426
|
+
{
|
|
3427
|
+
allowedOperations: [
|
|
3428
|
+
"sdn.wallet.account.v1",
|
|
3429
|
+
"sdn.wallet.connect.v1"
|
|
3430
|
+
],
|
|
3431
|
+
audiences: [],
|
|
3432
|
+
callbackUri: "https://digitalarsenal.github.io/OrbPro/wallet-callback.html",
|
|
3433
|
+
clientDisplayName: "OrbPro",
|
|
3434
|
+
clientId: "orbpro-pages-v1",
|
|
3435
|
+
operationBindings: [
|
|
3436
|
+
{
|
|
3437
|
+
audience: null,
|
|
3438
|
+
maxLifetimeSeconds: 300,
|
|
3439
|
+
operation: "sdn.wallet.account.v1",
|
|
3440
|
+
registryRow: null,
|
|
3441
|
+
serviceActivationState: null,
|
|
3442
|
+
serviceInstance: null
|
|
3443
|
+
},
|
|
3444
|
+
{
|
|
3445
|
+
audience: null,
|
|
3446
|
+
maxLifetimeSeconds: 300,
|
|
3447
|
+
operation: "sdn.wallet.connect.v1",
|
|
3448
|
+
registryRow: null,
|
|
3449
|
+
serviceActivationState: null,
|
|
3450
|
+
serviceInstance: null
|
|
3451
|
+
}
|
|
3452
|
+
],
|
|
3453
|
+
requestOrigin: "https://digitalarsenal.github.io"
|
|
3454
|
+
},
|
|
3455
|
+
{
|
|
3456
|
+
allowedOperations: [
|
|
3457
|
+
"sdn.wallet.account.v1",
|
|
3458
|
+
"sdn.wallet.connect.v1"
|
|
3459
|
+
],
|
|
3460
|
+
audiences: [],
|
|
3461
|
+
callbackUri: "https://digitalarsenal.github.io/asset-models/wallet-callback.html",
|
|
3462
|
+
clientDisplayName: "SDN Asset Models",
|
|
3463
|
+
clientId: "sdn-asset-models-pages-v1",
|
|
3464
|
+
operationBindings: [
|
|
3465
|
+
{
|
|
3466
|
+
audience: null,
|
|
3467
|
+
maxLifetimeSeconds: 300,
|
|
3468
|
+
operation: "sdn.wallet.account.v1",
|
|
3469
|
+
registryRow: null,
|
|
3470
|
+
serviceActivationState: null,
|
|
3471
|
+
serviceInstance: null
|
|
3472
|
+
},
|
|
3473
|
+
{
|
|
3474
|
+
audience: null,
|
|
3475
|
+
maxLifetimeSeconds: 300,
|
|
3476
|
+
operation: "sdn.wallet.connect.v1",
|
|
3477
|
+
registryRow: null,
|
|
3478
|
+
serviceActivationState: null,
|
|
3479
|
+
serviceInstance: null
|
|
3480
|
+
}
|
|
3481
|
+
],
|
|
3482
|
+
requestOrigin: "https://digitalarsenal.github.io"
|
|
3483
|
+
},
|
|
3484
|
+
{
|
|
3485
|
+
allowedOperations: [
|
|
3486
|
+
"sdn.asset-review.authority-activation.v1",
|
|
3487
|
+
"sdn.asset-review.decision.v1",
|
|
3488
|
+
"sdn.wallet.account.v1",
|
|
3489
|
+
"sdn.wallet.connect.v1"
|
|
3490
|
+
],
|
|
3491
|
+
audiences: [
|
|
3492
|
+
"asset-review-authority:assets.ipfs.01",
|
|
3493
|
+
"asset-review:assets.ipfs.01"
|
|
3494
|
+
],
|
|
3495
|
+
callbackUri: "https://review.spacedatanetwork.org/wallet/callback",
|
|
3496
|
+
clientDisplayName: "SDN Asset Review",
|
|
3497
|
+
clientId: "sdn-asset-review-v1",
|
|
3498
|
+
operationBindings: [
|
|
3499
|
+
{
|
|
3500
|
+
audience: "asset-review-authority:assets.ipfs.01",
|
|
3501
|
+
maxLifetimeSeconds: 300,
|
|
3502
|
+
operation: "sdn.asset-review.authority-activation.v1",
|
|
3503
|
+
registryRow: "asset-review-authority-activation-v1",
|
|
3504
|
+
serviceActivationState: "unactivated",
|
|
3505
|
+
serviceInstance: "assets.ipfs.01/asset-review-attestation"
|
|
3506
|
+
},
|
|
3507
|
+
{
|
|
3508
|
+
audience: "asset-review:assets.ipfs.01",
|
|
3509
|
+
maxLifetimeSeconds: 300,
|
|
3510
|
+
operation: "sdn.asset-review.decision.v1",
|
|
3511
|
+
registryRow: "asset-review-decision-v1",
|
|
3512
|
+
serviceActivationState: "activated",
|
|
3513
|
+
serviceInstance: null
|
|
3514
|
+
},
|
|
3515
|
+
{
|
|
3516
|
+
audience: null,
|
|
3517
|
+
maxLifetimeSeconds: 300,
|
|
3518
|
+
operation: "sdn.wallet.account.v1",
|
|
3519
|
+
registryRow: null,
|
|
3520
|
+
serviceActivationState: null,
|
|
3521
|
+
serviceInstance: null
|
|
3522
|
+
},
|
|
3523
|
+
{
|
|
3524
|
+
audience: null,
|
|
3525
|
+
maxLifetimeSeconds: 300,
|
|
3526
|
+
operation: "sdn.wallet.connect.v1",
|
|
3527
|
+
registryRow: null,
|
|
3528
|
+
serviceActivationState: null,
|
|
3529
|
+
serviceInstance: null
|
|
3530
|
+
}
|
|
3531
|
+
],
|
|
3532
|
+
requestOrigin: "https://review.spacedatanetwork.org"
|
|
3533
|
+
}
|
|
3534
|
+
], Qs = "e1ce6fe903c9700484a8a87d96581c8cad97063dabf63030b4518a31a3bdaa93", Ys = 1, Ai = {
|
|
3535
|
+
clients: Js,
|
|
3536
|
+
registryReleaseSha256: Qs,
|
|
3537
|
+
schemaVersion: Ys
|
|
3538
|
+
}, Xs = new TextEncoder(), Zs = /^[0-9a-f]{64}$/u, eo = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u, to = Object.freeze({
|
|
3539
|
+
"sdn.wallet.account.v1": Object.freeze({
|
|
3540
|
+
audience: null,
|
|
3541
|
+
registryRow: null,
|
|
3542
|
+
serviceActivationState: null,
|
|
3543
|
+
serviceInstance: null
|
|
3544
|
+
}),
|
|
3545
|
+
"sdn.wallet.connect.v1": Object.freeze({
|
|
3546
|
+
audience: null,
|
|
3547
|
+
registryRow: null,
|
|
3548
|
+
serviceActivationState: null,
|
|
3549
|
+
serviceInstance: null
|
|
3550
|
+
}),
|
|
3551
|
+
"sdn.auth.raw-challenge.v1": Object.freeze({
|
|
3552
|
+
audience: "sdn-login:sdn.spaceaware.io",
|
|
3553
|
+
registryRow: null,
|
|
3554
|
+
serviceActivationState: null,
|
|
3555
|
+
serviceInstance: null
|
|
3556
|
+
}),
|
|
3557
|
+
"sdn.auth.jcs-envelope.v2": Object.freeze({
|
|
3558
|
+
audience: "sdn-login:sdn.spaceaware.io",
|
|
3559
|
+
registryRow: "sdn-node-console-v2",
|
|
3560
|
+
serviceActivationState: null,
|
|
3561
|
+
serviceInstance: null
|
|
3562
|
+
}),
|
|
3563
|
+
"sdn.asset-review.authority-activation.v1": Object.freeze({
|
|
3564
|
+
audience: "asset-review-authority:assets.ipfs.01",
|
|
3565
|
+
registryRow: "asset-review-authority-activation-v1",
|
|
3566
|
+
serviceActivationState: "unactivated",
|
|
3567
|
+
serviceInstance: "assets.ipfs.01/asset-review-attestation"
|
|
3568
|
+
}),
|
|
3569
|
+
"sdn.asset-review.decision.v1": Object.freeze({
|
|
3570
|
+
audience: "asset-review:assets.ipfs.01",
|
|
3571
|
+
registryRow: "asset-review-decision-v1",
|
|
3572
|
+
serviceActivationState: "activated",
|
|
3573
|
+
serviceInstance: null
|
|
3574
|
+
})
|
|
3575
|
+
}), ye = Object.freeze([
|
|
3576
|
+
"sdn.wallet.account.v1",
|
|
3577
|
+
"sdn.wallet.connect.v1"
|
|
3578
|
+
]), no = Object.freeze([
|
|
3579
|
+
"sdn.auth.jcs-envelope.v2",
|
|
3580
|
+
"sdn.auth.raw-challenge.v1",
|
|
3581
|
+
...ye
|
|
3582
|
+
]), io = Object.freeze([
|
|
3583
|
+
"sdn.asset-review.authority-activation.v1",
|
|
3584
|
+
"sdn.asset-review.decision.v1",
|
|
3585
|
+
...ye
|
|
3586
|
+
]), xn = Object.freeze([
|
|
3587
|
+
Object.freeze(["sdn-landing-web-v1", "Space Data Network", "https://spacedatanetwork.org", "https://spacedatanetwork.org/wallet-callback.html", ye]),
|
|
3588
|
+
Object.freeze(["sdn-standards-web-v1", "Space Data Standards", "https://spacedatastandards.org", "https://spacedatastandards.org/wallet-callback.html", ye]),
|
|
3589
|
+
Object.freeze(["sdn-flatbuffers-pages-v1", "FlatBuffers Documentation", "https://digitalarsenal.github.io", "https://digitalarsenal.github.io/flatbuffers/wallet-callback.html", ye]),
|
|
3590
|
+
Object.freeze(["sdn-flatsql-pages-v1", "FlatSQL Documentation", "https://digitalarsenal.github.io", "https://digitalarsenal.github.io/flatsql/wallet-callback.html", ye]),
|
|
3591
|
+
Object.freeze(["sdn-module-sdk-pages-v1", "Space Data Module SDK", "https://digitalarsenal.github.io", "https://digitalarsenal.github.io/space-data-module-sdk/wallet-callback.html", ye]),
|
|
3592
|
+
Object.freeze(["spaceaware-web-v1", "SpaceAware", "https://spaceaware.io", "https://spaceaware.io/wallet/callback", ye]),
|
|
3593
|
+
Object.freeze(["sdn-node-console-v1", "SDN Node Console", "https://sdn.spaceaware.io", "https://sdn.spaceaware.io/wallet/callback", no]),
|
|
3594
|
+
Object.freeze(["orbpro-pages-v1", "OrbPro", "https://digitalarsenal.github.io", "https://digitalarsenal.github.io/OrbPro/wallet-callback.html", ye]),
|
|
3595
|
+
Object.freeze(["sdn-asset-models-pages-v1", "SDN Asset Models", "https://digitalarsenal.github.io", "https://digitalarsenal.github.io/asset-models/wallet-callback.html", ye]),
|
|
3596
|
+
Object.freeze(["sdn-asset-review-v1", "SDN Asset Review", "https://review.spacedatanetwork.org", "https://review.spacedatanetwork.org/wallet/callback", io])
|
|
3597
|
+
]), ro = Object.freeze([
|
|
3598
|
+
Object.freeze({
|
|
3599
|
+
audience: "sdn-login:sdn.spaceaware.io",
|
|
3600
|
+
clientId: "sdn-node-console-v1",
|
|
3601
|
+
maxLifetimeSeconds: 300,
|
|
3602
|
+
operation: "sdn.auth.jcs-envelope.v2",
|
|
3603
|
+
requestOrigin: "https://sdn.spaceaware.io",
|
|
3604
|
+
registryRow: "sdn-node-console-v2",
|
|
3605
|
+
serviceActivationState: null,
|
|
3606
|
+
serviceInstance: null
|
|
3607
|
+
}),
|
|
3608
|
+
Object.freeze({
|
|
3609
|
+
audience: "asset-review-authority:assets.ipfs.01",
|
|
3610
|
+
clientId: "sdn-asset-review-v1",
|
|
3611
|
+
maxLifetimeSeconds: 300,
|
|
3612
|
+
operation: "sdn.asset-review.authority-activation.v1",
|
|
3613
|
+
requestOrigin: "https://review.spacedatanetwork.org",
|
|
3614
|
+
registryRow: "asset-review-authority-activation-v1",
|
|
3615
|
+
serviceActivationState: "unactivated",
|
|
3616
|
+
serviceInstance: "assets.ipfs.01/asset-review-attestation"
|
|
3617
|
+
}),
|
|
3618
|
+
Object.freeze({
|
|
3619
|
+
audience: "asset-review:assets.ipfs.01",
|
|
3620
|
+
clientId: "sdn-asset-review-v1",
|
|
3621
|
+
maxLifetimeSeconds: 300,
|
|
3622
|
+
operation: "sdn.asset-review.decision.v1",
|
|
3623
|
+
requestOrigin: "https://review.spacedatanetwork.org",
|
|
3624
|
+
registryRow: "asset-review-decision-v1",
|
|
3625
|
+
serviceActivationState: "activated",
|
|
3626
|
+
serviceInstance: null
|
|
3627
|
+
})
|
|
3628
|
+
]);
|
|
3629
|
+
function U(e) {
|
|
3630
|
+
throw new TypeError(e);
|
|
3631
|
+
}
|
|
3632
|
+
function on(e) {
|
|
3633
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
3634
|
+
const t = Object.getPrototypeOf(e);
|
|
3635
|
+
return t === Object.prototype || t === null;
|
|
3636
|
+
}
|
|
3637
|
+
function ft(e, t, n) {
|
|
3638
|
+
on(e) || U(`${n} must be an object`);
|
|
3639
|
+
const i = Reflect.ownKeys(e);
|
|
3640
|
+
i.some((a) => typeof a != "string") && U(`${n} has missing or unknown fields`);
|
|
3641
|
+
const r = i.sort(), s = [...t].sort();
|
|
3642
|
+
(r.length !== s.length || r.some((a, o) => a !== s[o])) && U(`${n} has missing or unknown fields`);
|
|
3643
|
+
for (const a of r) {
|
|
3644
|
+
const o = Object.getOwnPropertyDescriptor(e, a);
|
|
3645
|
+
(!o || !o.enumerable || !("value" in o) || o.value === void 0) && U(`${n} has an invalid field`);
|
|
3646
|
+
}
|
|
3647
|
+
return e;
|
|
3648
|
+
}
|
|
3649
|
+
function pe(e) {
|
|
3650
|
+
return e === null || typeof e == "boolean" || typeof e == "string" ? JSON.stringify(e) : typeof e == "number" ? (Number.isFinite(e) || U("registry contains a non-finite number"), JSON.stringify(e)) : Array.isArray(e) ? `[${e.map(pe).join(",")}]` : (on(e) || U("registry contains an unsupported value"), `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${pe(e[t])}`).join(",")}}`);
|
|
3651
|
+
}
|
|
3652
|
+
async function so(e) {
|
|
3653
|
+
const t = globalThis.crypto?.subtle;
|
|
3654
|
+
t || U("Web Crypto SHA-256 is unavailable");
|
|
3655
|
+
const n = new Uint8Array(await t.digest("SHA-256", Xs.encode(e)));
|
|
3656
|
+
return Array.from(n, (i) => i.toString(16).padStart(2, "0")).join("");
|
|
3657
|
+
}
|
|
3658
|
+
function vt(e) {
|
|
3659
|
+
if (Array.isArray(e)) return Object.freeze(e.map(vt));
|
|
3660
|
+
if (!on(e)) return e;
|
|
3661
|
+
const t = {};
|
|
3662
|
+
for (const n of Object.keys(e).sort()) t[n] = vt(e[n]);
|
|
3663
|
+
return Object.freeze(t);
|
|
3664
|
+
}
|
|
3665
|
+
function oo(e, t) {
|
|
3666
|
+
(typeof e != "string" || !e.startsWith("https://") || e.includes("*")) && U(`${t} must be exact HTTPS`);
|
|
3667
|
+
let n;
|
|
3668
|
+
try {
|
|
3669
|
+
n = new URL(e);
|
|
3670
|
+
} catch {
|
|
3671
|
+
U(`${t} must be a valid URL`);
|
|
3672
|
+
}
|
|
3673
|
+
(n.protocol !== "https:" || n.username || n.password || n.port || n.origin !== e || n.pathname !== "/" || n.search || n.hash) && U(`${t} must be an exact HTTPS origin`);
|
|
3674
|
+
}
|
|
3675
|
+
function ao(e, t) {
|
|
3676
|
+
(typeof e != "string" || !e.startsWith("https://") || e.includes("*")) && U("callbackUri must be exact HTTPS");
|
|
3677
|
+
let n;
|
|
3678
|
+
try {
|
|
3679
|
+
n = new URL(e);
|
|
3680
|
+
} catch {
|
|
3681
|
+
U("callbackUri must be a valid URL");
|
|
3682
|
+
}
|
|
3683
|
+
(n.protocol !== "https:" || n.username || n.password || n.port || n.origin !== t || n.search || n.hash || n.href !== e) && U("callbackUri must be exact and same-origin");
|
|
3684
|
+
}
|
|
3685
|
+
function co(e) {
|
|
3686
|
+
ft(e, ["clients", "registryReleaseSha256", "schemaVersion"], "registry"), e.schemaVersion !== 1 && U("registry schemaVersion must be 1"), (typeof e.registryReleaseSha256 != "string" || !Zs.test(e.registryReleaseSha256)) && U("registryReleaseSha256 must be lowercase SHA-256"), (!Array.isArray(e.clients) || e.clients.length !== xn.length) && U("registry must contain exactly the reviewed clients");
|
|
3687
|
+
const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
3688
|
+
e.clients.forEach((i, r) => {
|
|
3689
|
+
ft(i, [
|
|
3690
|
+
"allowedOperations",
|
|
3691
|
+
"audiences",
|
|
3692
|
+
"callbackUri",
|
|
3693
|
+
"clientDisplayName",
|
|
3694
|
+
"clientId",
|
|
3695
|
+
"operationBindings",
|
|
3696
|
+
"requestOrigin"
|
|
3697
|
+
], `client ${r}`);
|
|
3698
|
+
const [s, a, o, c, l] = xn[r];
|
|
3699
|
+
(i.clientId !== s || i.clientDisplayName !== a || i.requestOrigin !== o || i.callbackUri !== c) && U(`client ${r} differs from the reviewed row`), (!eo.test(i.clientId) || t.has(i.clientId)) && U("clientId must be unique and canonical"), t.add(i.clientId), (typeof i.clientDisplayName != "string" || i.clientDisplayName.length < 1 || i.clientDisplayName.length > 80) && U("clientDisplayName is invalid"), oo(i.requestOrigin, "requestOrigin"), ao(i.callbackUri, i.requestOrigin), (!Array.isArray(i.allowedOperations) || pe(i.allowedOperations) !== pe(l)) && U(`${i.clientId} allowedOperations differ from the reviewed allowlist`), (!Array.isArray(i.operationBindings) || i.operationBindings.length !== l.length) && U(`${i.clientId} operationBindings differ from the reviewed allowlist`), i.operationBindings.forEach((u, f) => {
|
|
3700
|
+
ft(u, [
|
|
3701
|
+
"audience",
|
|
3702
|
+
"maxLifetimeSeconds",
|
|
3703
|
+
"operation",
|
|
3704
|
+
"registryRow",
|
|
3705
|
+
"serviceActivationState",
|
|
3706
|
+
"serviceInstance"
|
|
3707
|
+
], `${i.clientId} operation ${f}`);
|
|
3708
|
+
const p = l[f];
|
|
3709
|
+
u.operation !== p && U(`${i.clientId} operation allowlist order or value changed`);
|
|
3710
|
+
const g = to[u.operation];
|
|
3711
|
+
g || U("unknown registry operation"), (u.maxLifetimeSeconds !== 300 || u.audience !== g.audience || u.registryRow !== g.registryRow || u.serviceActivationState !== g.serviceActivationState || u.serviceInstance !== g.serviceInstance) && U(`${i.clientId} operation policy differs from the reviewed binding`);
|
|
3712
|
+
const E = `${i.clientId}\0${i.requestOrigin}\0${u.operation}`;
|
|
3713
|
+
n.has(E) && U("duplicate registry binding"), n.add(E);
|
|
3714
|
+
});
|
|
3715
|
+
const d = [...new Set(i.operationBindings.map(({ audience: u }) => u).filter((u) => u !== null))].sort();
|
|
3716
|
+
(!Array.isArray(i.audiences) || pe(i.audiences) !== pe(d)) && U(`${i.clientId} audiences differ from operationBindings`), pe(i.allowedOperations) !== pe(i.operationBindings.map(({ operation: u }) => u)) && U(`${i.clientId} allowedOperations differ from operationBindings`);
|
|
3717
|
+
});
|
|
3718
|
+
for (const i of ro) {
|
|
3719
|
+
const r = e.clients.find((o) => o.clientId === i.clientId && o.requestOrigin === i.requestOrigin), s = r?.operationBindings.find((o) => o.operation === i.operation), a = s && {
|
|
3720
|
+
audience: s.audience,
|
|
3721
|
+
clientId: r.clientId,
|
|
3722
|
+
maxLifetimeSeconds: s.maxLifetimeSeconds,
|
|
3723
|
+
operation: s.operation,
|
|
3724
|
+
requestOrigin: r.requestOrigin,
|
|
3725
|
+
registryRow: s.registryRow,
|
|
3726
|
+
serviceActivationState: s.serviceActivationState,
|
|
3727
|
+
serviceInstance: s.serviceInstance
|
|
3728
|
+
};
|
|
3729
|
+
(!a || pe(a) !== pe(i)) && U(`registry projection drifted from compiled row ${i.registryRow}`);
|
|
3730
|
+
}
|
|
3731
|
+
return vt(e);
|
|
3732
|
+
}
|
|
3733
|
+
const { registryReleaseSha256: lo, ...uo } = Ai, fo = await so(pe(uo));
|
|
3734
|
+
fo !== lo && U("registry release SHA-256 mismatch");
|
|
3735
|
+
const Dn = co(Ai);
|
|
3736
|
+
function po(e) {
|
|
3737
|
+
const t = ft(e, ["clientId", "operation", "requestOrigin"], "registry lookup");
|
|
3738
|
+
(typeof t.clientId != "string" || typeof t.requestOrigin != "string" || typeof t.operation != "string") && U("registry lookup fields must be strings");
|
|
3739
|
+
const n = Dn.clients.find((r) => r.clientId === t.clientId && r.requestOrigin === t.requestOrigin), i = n?.operationBindings.find((r) => r.operation === t.operation);
|
|
3740
|
+
return (!n || !i) && U("no exact registry binding exists"), vt({
|
|
3741
|
+
audience: i.audience,
|
|
3742
|
+
callbackUri: n.callbackUri,
|
|
3743
|
+
clientDisplayName: n.clientDisplayName,
|
|
3744
|
+
clientId: n.clientId,
|
|
3745
|
+
maxLifetimeSeconds: i.maxLifetimeSeconds,
|
|
3746
|
+
operation: i.operation,
|
|
3747
|
+
requestOrigin: n.requestOrigin,
|
|
3748
|
+
registryReleaseSha256: Dn.registryReleaseSha256,
|
|
3749
|
+
registryRow: i.registryRow,
|
|
3750
|
+
serviceActivationState: i.serviceActivationState,
|
|
3751
|
+
serviceInstance: i.serviceInstance
|
|
3752
|
+
});
|
|
3753
|
+
}
|
|
3754
|
+
const ho = /^\/transaction\/([0-9a-f]{64})$/u, kt = new TextEncoder(), yo = Uint8Array.prototype.fill, mo = Object.freeze({ resolveRegistryBinding: po });
|
|
3755
|
+
function kn(e) {
|
|
3756
|
+
if (e instanceof Uint8Array)
|
|
3757
|
+
try {
|
|
3758
|
+
yo.call(e, 0);
|
|
3759
|
+
} catch {
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
function Pt(e) {
|
|
3763
|
+
if (typeof e != "string") return !1;
|
|
3764
|
+
for (let t = 0; t < e.length; t += 1) {
|
|
3765
|
+
const n = e.charCodeAt(t);
|
|
3766
|
+
if (n >= 55296 && n <= 56319) {
|
|
3767
|
+
const i = e.charCodeAt(++t);
|
|
3768
|
+
if (!(i >= 56320 && i <= 57343)) return !1;
|
|
3769
|
+
} else if (n >= 56320 && n <= 57343) return !1;
|
|
3770
|
+
}
|
|
3771
|
+
return !0;
|
|
3772
|
+
}
|
|
3773
|
+
function Pn() {
|
|
3774
|
+
return new j("INVALID_TRANSACTION");
|
|
3775
|
+
}
|
|
3776
|
+
function nt(e, t, n, i) {
|
|
3777
|
+
const r = e.createElement("label"), s = e.createElement("span");
|
|
3778
|
+
s.textContent = n, r.append(s, i), t.append(r);
|
|
3779
|
+
}
|
|
3780
|
+
function Ve(e, t) {
|
|
3781
|
+
for (const n of t) {
|
|
3782
|
+
try {
|
|
3783
|
+
n.value = "";
|
|
3784
|
+
} catch {
|
|
3785
|
+
}
|
|
3786
|
+
try {
|
|
3787
|
+
n.defaultValue = "";
|
|
3788
|
+
} catch {
|
|
3789
|
+
}
|
|
3790
|
+
try {
|
|
3791
|
+
n.disabled = !0;
|
|
3792
|
+
} catch {
|
|
3793
|
+
}
|
|
3794
|
+
try {
|
|
3795
|
+
n.inert = !0;
|
|
3796
|
+
} catch {
|
|
3797
|
+
}
|
|
3798
|
+
try {
|
|
3799
|
+
n.removeAttribute?.("name");
|
|
3800
|
+
} catch {
|
|
3801
|
+
}
|
|
3802
|
+
try {
|
|
3803
|
+
n.removeAttribute?.("autocomplete");
|
|
3804
|
+
} catch {
|
|
3805
|
+
}
|
|
3806
|
+
try {
|
|
3807
|
+
n.setSelectionRange?.(0, 0);
|
|
3808
|
+
} catch {
|
|
3809
|
+
}
|
|
3810
|
+
try {
|
|
3811
|
+
n.setCustomValidity?.("");
|
|
3812
|
+
} catch {
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
try {
|
|
3816
|
+
e.remove?.();
|
|
3817
|
+
} catch {
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
function Ei({
|
|
3821
|
+
clipboard: e,
|
|
3822
|
+
controller: t,
|
|
3823
|
+
document: n,
|
|
3824
|
+
onChanged: i = () => {
|
|
3825
|
+
}
|
|
3826
|
+
}) {
|
|
3827
|
+
if (!t || typeof t.listQuarantinedWalletRecords != "function") return null;
|
|
3828
|
+
const r = n.createElement("section");
|
|
3829
|
+
r.className = "wallet-quarantine-manager";
|
|
3830
|
+
const s = t.generation;
|
|
3831
|
+
let a = !1, o = 0, c = [], l = null;
|
|
3832
|
+
const d = (h = o) => !a && h === o && t.isUiGenerationCurrent?.(s) === !0, u = (h, A = o) => {
|
|
3833
|
+
d(A) && l?.status && (l.status.textContent = h);
|
|
3834
|
+
}, f = () => {
|
|
3835
|
+
o += 1;
|
|
3836
|
+
for (const [h, A, m] of c)
|
|
3837
|
+
try {
|
|
3838
|
+
h.removeEventListener?.(A, m);
|
|
3839
|
+
} catch {
|
|
3840
|
+
}
|
|
3841
|
+
c = [];
|
|
3842
|
+
for (const h of l?.rows ?? []) {
|
|
3843
|
+
try {
|
|
3844
|
+
h.confirmation.value = "";
|
|
3845
|
+
} catch {
|
|
3846
|
+
}
|
|
3847
|
+
try {
|
|
3848
|
+
h.confirmation.defaultValue = "";
|
|
3849
|
+
} catch {
|
|
3850
|
+
}
|
|
3851
|
+
try {
|
|
3852
|
+
h.confirmation.disabled = !0;
|
|
3853
|
+
} catch {
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
l?.status && (l.status.textContent = ""), l = null;
|
|
3857
|
+
}, p = (h, A, m) => {
|
|
3858
|
+
h.addEventListener?.(A, m), c.push([h, A, m]);
|
|
3859
|
+
}, g = () => {
|
|
3860
|
+
if (f(), a || t.isUiGenerationCurrent?.(s) !== !0)
|
|
3861
|
+
return r.replaceChildren(), r.hidden = !0, !1;
|
|
3862
|
+
let h;
|
|
3863
|
+
try {
|
|
3864
|
+
h = t.listQuarantinedWalletRecords();
|
|
3865
|
+
} catch {
|
|
3866
|
+
h = [];
|
|
3867
|
+
}
|
|
3868
|
+
if (!Array.isArray(h) || h.length === 0)
|
|
3869
|
+
return r.replaceChildren(), r.hidden = !0, !1;
|
|
3870
|
+
r.hidden = !1, l = is(r, h, { document: n });
|
|
3871
|
+
const A = o;
|
|
3872
|
+
for (const m of l.rows) {
|
|
3873
|
+
const { entry: N } = m, v = async (x) => {
|
|
3874
|
+
if (x?.isTrusted !== !0 || !d(A)) return;
|
|
3875
|
+
if (N.exportable !== !0) {
|
|
3876
|
+
u("Quarantined record is too large to export.", A);
|
|
3877
|
+
return;
|
|
3878
|
+
}
|
|
3879
|
+
let H;
|
|
3880
|
+
try {
|
|
3881
|
+
if (H = t.exportQuarantinedWalletRecord(N.key), typeof e?.writeText != "function") throw new Error("clipboard unavailable");
|
|
3882
|
+
await e.writeText(H), u("Quarantined record exported to the clipboard.", A);
|
|
3883
|
+
} catch {
|
|
3884
|
+
u("Quarantined record export failed.", A);
|
|
3885
|
+
} finally {
|
|
3886
|
+
H = null;
|
|
3887
|
+
}
|
|
3888
|
+
}, V = (x) => {
|
|
3889
|
+
if (!(x?.isTrusted !== !0 || !d(A))) {
|
|
3890
|
+
try {
|
|
3891
|
+
m.confirmation.value = "";
|
|
3892
|
+
} catch {
|
|
3893
|
+
}
|
|
3894
|
+
try {
|
|
3895
|
+
m.confirmation.defaultValue = "";
|
|
3896
|
+
} catch {
|
|
3897
|
+
}
|
|
3898
|
+
m.confirmationGroup.hidden = !1, u(`Type ${N.key} to confirm deletion.`, A);
|
|
3899
|
+
try {
|
|
3900
|
+
m.confirmation.focus?.();
|
|
3901
|
+
} catch {
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
}, I = (x) => {
|
|
3905
|
+
if (!(x?.isTrusted !== !0 || !d(A))) {
|
|
3906
|
+
try {
|
|
3907
|
+
m.confirmation.value = "";
|
|
3908
|
+
} catch {
|
|
3909
|
+
}
|
|
3910
|
+
try {
|
|
3911
|
+
m.confirmation.defaultValue = "";
|
|
3912
|
+
} catch {
|
|
3913
|
+
}
|
|
3914
|
+
m.confirmationGroup.hidden = !0, u("", A);
|
|
3915
|
+
}
|
|
3916
|
+
}, b = (x) => {
|
|
3917
|
+
if (x?.isTrusted !== !0 || !d(A)) return;
|
|
3918
|
+
const H = m.confirmation.value;
|
|
3919
|
+
if (H !== N.key) {
|
|
3920
|
+
u("Type the exact storage key to confirm deletion.", A);
|
|
3921
|
+
return;
|
|
3922
|
+
}
|
|
3923
|
+
try {
|
|
3924
|
+
t.deleteQuarantinedWalletRecord(N.key, H);
|
|
3925
|
+
} catch {
|
|
3926
|
+
u("Quarantined record deletion failed.", A);
|
|
3927
|
+
return;
|
|
3928
|
+
}
|
|
3929
|
+
try {
|
|
3930
|
+
m.confirmation.value = "";
|
|
3931
|
+
} catch {
|
|
3932
|
+
}
|
|
3933
|
+
try {
|
|
3934
|
+
m.confirmation.defaultValue = "";
|
|
3935
|
+
} catch {
|
|
3936
|
+
}
|
|
3937
|
+
g(), a || i();
|
|
3938
|
+
};
|
|
3939
|
+
p(m.exportButton, "click", v), p(m.deleteButton, "click", V), p(m.cancel, "click", I), p(m.confirm, "click", b);
|
|
3940
|
+
}
|
|
3941
|
+
return !0;
|
|
3942
|
+
}, E = g();
|
|
3943
|
+
return Object.freeze({
|
|
3944
|
+
container: r,
|
|
3945
|
+
destroy() {
|
|
3946
|
+
a || (a = !0, f(), r.replaceChildren(), r.remove?.());
|
|
3947
|
+
},
|
|
3948
|
+
hasEntries: E,
|
|
3949
|
+
refresh: g
|
|
3950
|
+
});
|
|
3951
|
+
}
|
|
3952
|
+
function go({
|
|
3953
|
+
clipboard: e = globalThis.navigator?.clipboard,
|
|
3954
|
+
controller: t = null,
|
|
3955
|
+
document: n,
|
|
3956
|
+
mount: i = null,
|
|
3957
|
+
offerRememberedUnlock: r = !0,
|
|
3958
|
+
title: s = "Sign in"
|
|
3959
|
+
}) {
|
|
3960
|
+
const a = i ?? n?.body;
|
|
3961
|
+
if (!n?.createElement || !a?.append) throw new j("DOM_UNAVAILABLE");
|
|
3962
|
+
const o = n.createElement("section");
|
|
3963
|
+
o.className = "wallet-login";
|
|
3964
|
+
const c = n.createElement("h1");
|
|
3965
|
+
c.textContent = s;
|
|
3966
|
+
const l = n.createElement("p");
|
|
3967
|
+
l.textContent = "Account 0";
|
|
3968
|
+
const d = n.createElement("form");
|
|
3969
|
+
d.noValidate = !0;
|
|
3970
|
+
const u = n.createElement("input");
|
|
3971
|
+
u.type = "text", u.name = "username", u.autocomplete = "username", u.required = !0;
|
|
3972
|
+
const f = n.createElement("input");
|
|
3973
|
+
f.type = "password", f.name = "password", f.autocomplete = "current-password", f.required = !0, nt(n, d, "Username", u), nt(n, d, "Password", f);
|
|
3974
|
+
let p = null;
|
|
3975
|
+
if (t && typeof t == "object") {
|
|
3976
|
+
p = n.createElement("input"), p.type = "checkbox", p.dataset.walletRemember = "prf-only", p.checked = !1, p.defaultChecked = !1;
|
|
3977
|
+
let R = !1;
|
|
3978
|
+
try {
|
|
3979
|
+
R = t.supportsRememberedWallet?.() === !0;
|
|
3980
|
+
} catch {
|
|
3981
|
+
R = !1;
|
|
3982
|
+
}
|
|
3983
|
+
p.disabled = !R, nt(n, d, "Remember on this device", p);
|
|
3984
|
+
}
|
|
3985
|
+
const g = n.createElement("p");
|
|
3986
|
+
g.dataset.walletRememberStatus = "true";
|
|
3987
|
+
let E = () => {
|
|
3988
|
+
};
|
|
3989
|
+
const h = Ei({
|
|
3990
|
+
clipboard: e,
|
|
3991
|
+
controller: t,
|
|
3992
|
+
document: n,
|
|
3993
|
+
onChanged: () => E()
|
|
3994
|
+
}), A = n.createElement("div");
|
|
3995
|
+
A.className = "wallet-login-actions";
|
|
3996
|
+
let m = null, N = !1;
|
|
3997
|
+
try {
|
|
3998
|
+
N = t?.canRestoreRememberedWallet?.() === !0;
|
|
3999
|
+
} catch {
|
|
4000
|
+
N = !1;
|
|
4001
|
+
}
|
|
4002
|
+
N && r && (m = n.createElement("button"), m.type = "button", m.dataset.walletAction = "unlock-remembered", m.textContent = "Unlock remembered wallet");
|
|
4003
|
+
const v = n.createElement("button");
|
|
4004
|
+
v.type = "submit", v.dataset.walletAction = "login", v.textContent = "Login";
|
|
4005
|
+
const V = n.createElement("button");
|
|
4006
|
+
V.type = "button", V.dataset.walletAction = "cancel-login", V.textContent = "Cancel", m && A.append(m), A.append(v, V), d.append(A), o.append(c, l), h?.hasEntries && o.append(h.container), o.append(d, g), a.append(o), t?.registerCredentialControls?.({ passwordControl: f, usernameControl: u });
|
|
4007
|
+
let I = !1, b, x;
|
|
4008
|
+
const H = new Promise((R, W) => {
|
|
4009
|
+
b = R, x = W;
|
|
4010
|
+
}), z = () => {
|
|
4011
|
+
d.removeEventListener?.("submit", ee), V.removeEventListener?.("click", G), m?.removeEventListener?.("click", M);
|
|
4012
|
+
}, O = () => {
|
|
4013
|
+
if (h?.destroy?.(), p) {
|
|
4014
|
+
try {
|
|
4015
|
+
p.checked = !1;
|
|
4016
|
+
} catch {
|
|
4017
|
+
}
|
|
4018
|
+
try {
|
|
4019
|
+
p.defaultChecked = !1;
|
|
4020
|
+
} catch {
|
|
4021
|
+
}
|
|
4022
|
+
try {
|
|
4023
|
+
p.disabled = !0;
|
|
4024
|
+
} catch {
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
4027
|
+
g.textContent = "";
|
|
4028
|
+
}, F = () => {
|
|
4029
|
+
z(), Ve(d, [u, f]), O(), o.remove?.();
|
|
4030
|
+
}, D = (R) => {
|
|
4031
|
+
if (!I) {
|
|
4032
|
+
I = !0;
|
|
4033
|
+
try {
|
|
4034
|
+
t?.revokeNow?.(R);
|
|
4035
|
+
} catch {
|
|
4036
|
+
}
|
|
4037
|
+
F(), x(new j(R));
|
|
4038
|
+
}
|
|
4039
|
+
}, ee = (R) => {
|
|
4040
|
+
R?.preventDefault?.(), !(I || R?.isTrusted !== !0) && (I = !0, z(), h?.destroy?.(), b({ passwordControl: f, rememberControl: p, rememberStatus: g, usernameControl: u }));
|
|
4041
|
+
}, G = (R) => {
|
|
4042
|
+
R?.isTrusted === !0 && D("USER_CANCELLED");
|
|
4043
|
+
}, M = (R) => {
|
|
4044
|
+
I || R?.isTrusted !== !0 || (I = !0, z(), h?.destroy?.(), Ve(d, [u, f]), b({ remembered: !0, rememberStatus: g }));
|
|
4045
|
+
};
|
|
4046
|
+
E = () => {
|
|
4047
|
+
if (I || !r) return;
|
|
4048
|
+
let R = !1;
|
|
4049
|
+
try {
|
|
4050
|
+
R = t?.canRestoreRememberedWallet?.() === !0;
|
|
4051
|
+
} catch {
|
|
4052
|
+
R = !1;
|
|
4053
|
+
}
|
|
4054
|
+
R && !m ? (m = n.createElement("button"), m.type = "button", m.dataset.walletAction = "unlock-remembered", m.textContent = "Unlock remembered wallet", A.replaceChildren(m, v, V), m.addEventListener?.("click", M)) : !R && m && (m.removeEventListener?.("click", M), m.remove?.(), m = null);
|
|
4055
|
+
}, d.addEventListener("submit", ee), V.addEventListener("click", G), m?.addEventListener?.("click", M);
|
|
4056
|
+
try {
|
|
4057
|
+
u.focus?.();
|
|
4058
|
+
} catch {
|
|
4059
|
+
}
|
|
4060
|
+
return Object.freeze({
|
|
4061
|
+
cancel() {
|
|
4062
|
+
I ? F() : D("STALE_CONTROLLER");
|
|
4063
|
+
},
|
|
4064
|
+
controls: Object.freeze({ passwordControl: f, rememberControl: p, rememberStatus: g, usernameControl: u }),
|
|
4065
|
+
form: d,
|
|
4066
|
+
promise: H,
|
|
4067
|
+
remove: F
|
|
4068
|
+
});
|
|
4069
|
+
}
|
|
4070
|
+
function wi({
|
|
4071
|
+
document: e,
|
|
4072
|
+
mount: t = null,
|
|
4073
|
+
submitLabel: n = "Compare legacy account",
|
|
4074
|
+
title: i = "Enter the legacy BIP-39 mnemonic"
|
|
4075
|
+
}) {
|
|
4076
|
+
const r = t ?? e?.body;
|
|
4077
|
+
if (!e?.createElement || !r?.append) throw new j("DOM_UNAVAILABLE");
|
|
4078
|
+
const s = e.createElement("section");
|
|
4079
|
+
s.className = "wallet-login wallet-legacy-credentials";
|
|
4080
|
+
const a = e.createElement("h1");
|
|
4081
|
+
a.textContent = i;
|
|
4082
|
+
const o = e.createElement("form");
|
|
4083
|
+
o.noValidate = !0;
|
|
4084
|
+
const c = e.createElement("textarea");
|
|
4085
|
+
c.name = "mnemonic", c.autocomplete = "off", c.required = !0, nt(e, o, "Mnemonic", c);
|
|
4086
|
+
const l = e.createElement("button");
|
|
4087
|
+
l.type = "submit", l.dataset.walletAction = "confirm-legacy-mnemonic", l.textContent = n;
|
|
4088
|
+
const d = e.createElement("button");
|
|
4089
|
+
d.type = "button", d.dataset.walletAction = "cancel-legacy-migration", d.textContent = "Cancel", o.append(l, d), s.append(a, o), r.append(s);
|
|
4090
|
+
let u = !1, f, p;
|
|
4091
|
+
const g = new Promise((v, V) => {
|
|
4092
|
+
f = v, p = V;
|
|
4093
|
+
}), E = () => {
|
|
4094
|
+
o.removeEventListener?.("submit", m), d.removeEventListener?.("click", N);
|
|
4095
|
+
}, h = () => {
|
|
4096
|
+
E(), Ve(o, [c]), s.remove?.();
|
|
4097
|
+
}, A = () => {
|
|
4098
|
+
u || (u = !0, h(), p(new j("USER_CANCELLED")));
|
|
4099
|
+
}, m = (v) => {
|
|
4100
|
+
v?.preventDefault?.(), !(u || v?.isTrusted !== !0) && (u = !0, E(), f({ form: o, mnemonicControl: c, section: s }));
|
|
4101
|
+
}, N = (v) => {
|
|
4102
|
+
v?.isTrusted === !0 && A();
|
|
4103
|
+
};
|
|
4104
|
+
o.addEventListener("submit", m), d.addEventListener("click", N);
|
|
4105
|
+
try {
|
|
4106
|
+
c.focus?.();
|
|
4107
|
+
} catch {
|
|
4108
|
+
}
|
|
4109
|
+
return Object.freeze({
|
|
4110
|
+
cancel() {
|
|
4111
|
+
u ? h() : A();
|
|
4112
|
+
},
|
|
4113
|
+
promise: g,
|
|
4114
|
+
remove: h
|
|
4115
|
+
});
|
|
4116
|
+
}
|
|
4117
|
+
function Ao({ document: e, mount: t = null, title: n = "Choose legacy wallet profile" }) {
|
|
4118
|
+
const i = t ?? e?.body;
|
|
4119
|
+
if (!e?.createElement || !i?.append) throw new j("DOM_UNAVAILABLE");
|
|
4120
|
+
const r = e.createElement("section");
|
|
4121
|
+
r.className = "wallet-login wallet-legacy-profile";
|
|
4122
|
+
const s = e.createElement("h1");
|
|
4123
|
+
s.textContent = n;
|
|
4124
|
+
const a = e.createElement("p");
|
|
4125
|
+
a.textContent = "Raw-v1 compatibility login requires the exact legacy profile. It cannot approve assets.";
|
|
4126
|
+
const o = e.createElement("form");
|
|
4127
|
+
o.noValidate = !0;
|
|
4128
|
+
const c = e.createElement("select");
|
|
4129
|
+
c.dataset.walletLegacyProfile = "required", c.required = !0, c.value = "";
|
|
4130
|
+
for (const [v, V] of [
|
|
4131
|
+
["", "Select a legacy profile"],
|
|
4132
|
+
["password-fast-v1-legacy", "Legacy fast-password profile"],
|
|
4133
|
+
["bip39-mnemonic-v1-legacy", "Legacy BIP-39 mnemonic import"]
|
|
4134
|
+
]) {
|
|
4135
|
+
const I = e.createElement("option");
|
|
4136
|
+
I.value = v, I.textContent = V, v === "" && (I.disabled = !0, I.selected = !0), c.append(I);
|
|
4137
|
+
}
|
|
4138
|
+
nt(e, o, "Legacy profile", c);
|
|
4139
|
+
const l = e.createElement("button");
|
|
4140
|
+
l.type = "submit", l.dataset.walletAction = "continue-legacy-login", l.textContent = "Continue";
|
|
4141
|
+
const d = e.createElement("button");
|
|
4142
|
+
d.type = "button", d.dataset.walletAction = "cancel-legacy-login", d.textContent = "Cancel", o.append(l, d), r.append(s, a, o), i.append(r);
|
|
4143
|
+
let u = !1, f, p;
|
|
4144
|
+
const g = new Promise((v, V) => {
|
|
4145
|
+
f = v, p = V;
|
|
4146
|
+
}), E = () => {
|
|
4147
|
+
o.removeEventListener?.("submit", m), d.removeEventListener?.("click", N);
|
|
4148
|
+
}, h = () => {
|
|
4149
|
+
try {
|
|
4150
|
+
c.value = "";
|
|
4151
|
+
} catch {
|
|
4152
|
+
}
|
|
4153
|
+
Ve(o, [c]), r.remove?.();
|
|
4154
|
+
}, A = () => {
|
|
4155
|
+
u || (u = !0, E(), h(), p(new j("USER_CANCELLED")));
|
|
4156
|
+
}, m = (v) => {
|
|
4157
|
+
if (v?.preventDefault?.(), u || v?.isTrusted !== !0) return;
|
|
4158
|
+
const V = c.value;
|
|
4159
|
+
V !== "password-fast-v1-legacy" && V !== "bip39-mnemonic-v1-legacy" || (u = !0, E(), h(), f(V));
|
|
4160
|
+
}, N = (v) => {
|
|
4161
|
+
v?.isTrusted === !0 && A();
|
|
4162
|
+
};
|
|
4163
|
+
o.addEventListener("submit", m), d.addEventListener("click", N);
|
|
4164
|
+
try {
|
|
4165
|
+
c.focus?.();
|
|
4166
|
+
} catch {
|
|
4167
|
+
}
|
|
4168
|
+
return Object.freeze({ cancel: A, promise: g });
|
|
4169
|
+
}
|
|
4170
|
+
function lt(e, t, n, i) {
|
|
4171
|
+
const r = e.createElement("div"), s = e.createElement("strong");
|
|
4172
|
+
s.textContent = `${n}: `;
|
|
4173
|
+
const a = e.createElement("span");
|
|
4174
|
+
a.textContent = String(i ?? ""), r.append(s, a), t.append(r);
|
|
4175
|
+
}
|
|
4176
|
+
function bi(e, t, n, i = null) {
|
|
4177
|
+
const r = i ?? e?.body, s = e.createElement("section");
|
|
4178
|
+
s.className = "wallet-complete";
|
|
4179
|
+
const a = e.createElement("h1");
|
|
4180
|
+
a.textContent = "Complete";
|
|
4181
|
+
const o = e.createElement("p");
|
|
4182
|
+
o.textContent = n;
|
|
4183
|
+
const c = e.createElement("button");
|
|
4184
|
+
c.type = "button", c.dataset.walletAction = "close", c.textContent = "Close", c.addEventListener("click", (l) => {
|
|
4185
|
+
if (l?.isTrusted === !0)
|
|
4186
|
+
try {
|
|
4187
|
+
t?.close?.();
|
|
4188
|
+
} catch {
|
|
4189
|
+
}
|
|
4190
|
+
}), s.append(a, o, c), r?.replaceChildren?.(s);
|
|
4191
|
+
}
|
|
4192
|
+
function Ii(e, t = "The wallet request could not be completed. Close this window.", n = null) {
|
|
4193
|
+
const i = n ?? e?.body;
|
|
4194
|
+
if (!e?.createElement || !i?.replaceChildren) return;
|
|
4195
|
+
const r = e.createElement("section");
|
|
4196
|
+
r.className = "wallet-terminal-error";
|
|
4197
|
+
const s = e.createElement("h1");
|
|
4198
|
+
s.textContent = "Wallet request stopped";
|
|
4199
|
+
const a = e.createElement("p");
|
|
4200
|
+
a.textContent = t, r.append(s, a), i.replaceChildren(r);
|
|
4201
|
+
}
|
|
4202
|
+
function Eo({
|
|
4203
|
+
clipboard: e,
|
|
4204
|
+
controller: t,
|
|
4205
|
+
document: n,
|
|
4206
|
+
identity: i,
|
|
4207
|
+
isAppCurrent: r = () => !0,
|
|
4208
|
+
makeCredentialPrompt: s,
|
|
4209
|
+
mount: a,
|
|
4210
|
+
onClear: o,
|
|
4211
|
+
wasm: c
|
|
4212
|
+
}) {
|
|
4213
|
+
const l = n.createElement("section");
|
|
4214
|
+
l.className = "wallet-account";
|
|
4215
|
+
const d = n.createElement("div"), u = ts(d, i, { document: n }), f = n.createElement("section");
|
|
4216
|
+
f.className = "wallet-approval-card";
|
|
4217
|
+
const p = n.createElement("h2");
|
|
4218
|
+
p.textContent = "Asset review approval";
|
|
4219
|
+
const g = n.createElement("p"), E = n.createElement("div"), h = n.createElement("button");
|
|
4220
|
+
h.type = "button", h.dataset.walletAction = "copy-approval", h.textContent = "Copy approval configuration", h.disabled = !u.approvalAvailable, u.approvalAvailable || (g.textContent = en), f.append(p, g, h, E);
|
|
4221
|
+
const A = n.createElement("button");
|
|
4222
|
+
A.type = "button", A.dataset.walletAction = "logout", A.textContent = "Logout";
|
|
4223
|
+
const m = n.createElement("button");
|
|
4224
|
+
m.type = "button", m.dataset.walletAction = "return-to-site", m.textContent = "Return to site";
|
|
4225
|
+
const N = n.createElement("section");
|
|
4226
|
+
N.className = "wallet-legacy-migration";
|
|
4227
|
+
const v = as(N, { document: n });
|
|
4228
|
+
let V = !1;
|
|
4229
|
+
try {
|
|
4230
|
+
V = t.canForgetRememberedWallet?.() === !0;
|
|
4231
|
+
} catch {
|
|
4232
|
+
V = !1;
|
|
4233
|
+
}
|
|
4234
|
+
const I = V ? n.createElement("section") : null, b = I ? ns(I, { document: n }) : null;
|
|
4235
|
+
b && (b.launch.dataset.walletAction = "forget-stored-wallet");
|
|
4236
|
+
const x = Ei({
|
|
4237
|
+
clipboard: e,
|
|
4238
|
+
controller: t,
|
|
4239
|
+
document: n
|
|
4240
|
+
}), H = n.createElement("p");
|
|
4241
|
+
H.className = "wallet-account-exit-status", l.append(d, f), I && l.append(I), x?.hasEntries && l.append(x.container), l.append(m, A, N), a.replaceChildren(l);
|
|
4242
|
+
const z = new ss({
|
|
4243
|
+
credentialRound: async (L) => {
|
|
4244
|
+
const P = s({
|
|
4245
|
+
controller: null,
|
|
4246
|
+
document: n,
|
|
4247
|
+
mount: a,
|
|
4248
|
+
title: `Confirm account (${L} of 2)`
|
|
4249
|
+
});
|
|
4250
|
+
P?.promise && O.add(P);
|
|
4251
|
+
try {
|
|
4252
|
+
return P?.promise ? await P.promise : await P;
|
|
4253
|
+
} finally {
|
|
4254
|
+
P?.promise && O.delete(P);
|
|
4255
|
+
}
|
|
4256
|
+
},
|
|
4257
|
+
expectedIdentity: i,
|
|
4258
|
+
wasm: c
|
|
4259
|
+
}), O = /* @__PURE__ */ new Set(), F = /* @__PURE__ */ new Set(), D = /* @__PURE__ */ new Set(), ee = /* @__PURE__ */ new Set();
|
|
4260
|
+
let G = !1, M = !1, R = !1, W = null, q = !1, J = !1, Q = !1, ce = 0, te = !1, Ie = 0;
|
|
4261
|
+
const ve = (L) => !M && Ie === L, le = (L) => {
|
|
4262
|
+
if (!ve(L)) throw new Error("account surface closed");
|
|
4263
|
+
}, $e = (L) => (L instanceof Uint8Array && ee.add(L), L), ke = (L) => {
|
|
4264
|
+
kn(L), ee.delete(L);
|
|
4265
|
+
}, Fe = () => {
|
|
4266
|
+
const L = [...ee];
|
|
4267
|
+
ee.clear();
|
|
4268
|
+
for (const P of L) kn(P);
|
|
4269
|
+
}, ge = () => {
|
|
4270
|
+
const L = G || Q || q;
|
|
4271
|
+
m.disabled = R, A.disabled = R, M || (h.disabled = L || !u.approvalAvailable, v.launch.disabled = L, b && (b.launch.disabled = L || J, b.confirm.disabled = L, b.cancel.disabled = L));
|
|
4272
|
+
}, Ae = (L) => {
|
|
4273
|
+
if (!F.has(L)) return !0;
|
|
4274
|
+
if (D.has(L)) return !1;
|
|
4275
|
+
D.add(L);
|
|
4276
|
+
try {
|
|
4277
|
+
return (c?.sdn ?? c).destroySdnIdentity(L), F.delete(L), !0;
|
|
4278
|
+
} catch {
|
|
4279
|
+
return !1;
|
|
4280
|
+
} finally {
|
|
4281
|
+
D.delete(L);
|
|
4282
|
+
}
|
|
4283
|
+
}, We = () => {
|
|
4284
|
+
for (const L of [...F]) Ae(L);
|
|
4285
|
+
return F.size === 0;
|
|
4286
|
+
}, ze = async (L) => {
|
|
4287
|
+
if (L?.isTrusted !== !0 || G || Q || q) return;
|
|
4288
|
+
const P = Ie;
|
|
4289
|
+
G = !0, ge(), g.textContent = "Confirm the same account twice to enable Copy.";
|
|
4290
|
+
try {
|
|
4291
|
+
const ue = await z.confirm();
|
|
4292
|
+
le(P);
|
|
4293
|
+
const Y = await rs(ue, {
|
|
4294
|
+
assertCurrent: () => le(P),
|
|
4295
|
+
clipboard: e,
|
|
4296
|
+
container: E,
|
|
4297
|
+
document: n
|
|
4298
|
+
});
|
|
4299
|
+
le(P), g.textContent = Y ? "Approval configuration copied." : "Clipboard unavailable. Copy the exact configuration shown below.";
|
|
4300
|
+
} catch {
|
|
4301
|
+
ve(P) && (g.textContent = "The two entries did not produce the same account.");
|
|
4302
|
+
} finally {
|
|
4303
|
+
G = !1, ve(P) && ge();
|
|
4304
|
+
}
|
|
4305
|
+
}, st = async (L) => {
|
|
4306
|
+
if (L?.isTrusted !== !0 || Q || G || q) return;
|
|
4307
|
+
const P = v.select.value || "password-fast-v1-legacy";
|
|
4308
|
+
if (P !== "password-fast-v1-legacy" && P !== "bip39-mnemonic-v1-legacy") {
|
|
4309
|
+
v.result.textContent = "Legacy profile unavailable.";
|
|
4310
|
+
return;
|
|
4311
|
+
}
|
|
4312
|
+
const ue = Ie;
|
|
4313
|
+
Q = !0, ce += 1, ge(), v.result.textContent = "Enter the selected legacy credentials to compare accounts.";
|
|
4314
|
+
let Y = null, Te, Ot, Nt, re = null;
|
|
4315
|
+
try {
|
|
4316
|
+
let Tt;
|
|
4317
|
+
if (P === "password-fast-v1-legacy") {
|
|
4318
|
+
Y = s({
|
|
4319
|
+
controller: null,
|
|
4320
|
+
document: n,
|
|
4321
|
+
mount: a,
|
|
4322
|
+
title: "Enter the legacy fast-password account"
|
|
4323
|
+
}), Y?.promise && O.add(Y);
|
|
4324
|
+
const X = Y?.promise ? await Y.promise : await Y;
|
|
4325
|
+
le(ue);
|
|
4326
|
+
const He = X?.usernameControl?.value, dn = X?.passwordControl?.value;
|
|
4327
|
+
if (!Pt(He) || !Pt(dn)) throw new Error("invalid legacy credentials");
|
|
4328
|
+
Te = $e(kt.encode(He)), Ot = $e(kt.encode(dn));
|
|
4329
|
+
const fn = X?.usernameControl?.form ?? X?.passwordControl?.form ?? Y?.form, Oi = fn?.parentNode;
|
|
4330
|
+
Ve(fn, [X?.usernameControl, X?.passwordControl]), Oi?.remove?.(), Tt = { passwordUtf8: Ot, usernameUtf8: Te };
|
|
4331
|
+
} else {
|
|
4332
|
+
Y = wi({ document: n, mount: a }), O.add(Y);
|
|
4333
|
+
const X = await Y.promise;
|
|
4334
|
+
le(ue);
|
|
4335
|
+
const He = X?.mnemonicControl?.value;
|
|
4336
|
+
if (!Pt(He)) throw new Error("invalid legacy credentials");
|
|
4337
|
+
Nt = $e(kt.encode(He)), Ve(X.form, [X.mnemonicControl]), X.section?.remove?.(), Tt = { mnemonicUtf8: Nt };
|
|
4338
|
+
}
|
|
4339
|
+
if (Y?.promise && O.delete(Y), re = await os({
|
|
4340
|
+
accountIndex: 0,
|
|
4341
|
+
credentials: Tt,
|
|
4342
|
+
operation: "sdn.auth.raw-challenge.v1",
|
|
4343
|
+
profile: P,
|
|
4344
|
+
wasm: c,
|
|
4345
|
+
assertCurrent: () => le(ue),
|
|
4346
|
+
ownHandle: (X) => F.add(X)
|
|
4347
|
+
}), le(ue), !re?.handle) throw new Error("legacy derivation failed");
|
|
4348
|
+
const Si = P === "password-fast-v1-legacy" ? "sdn-fast-password-auth-v1-legacy" : "sdn-bip39-auth-v1-legacy", at = Array.isArray(re.identity?.keys) ? re.identity.keys.find((X) => X?.purpose === "sdn-authentication") : null;
|
|
4349
|
+
if (re.identity?.identityScheme !== Si || re.identity?.seedProfile !== P || typeof re.identity?.accountXpub != "string" || !at || typeof at.publicKeyHex != "string" || !/^[0-9a-f]{64}$/u.test(at.publicKeyHex))
|
|
4350
|
+
throw new Error("legacy identity invalid");
|
|
4351
|
+
const Ri = re.identity;
|
|
4352
|
+
if (!Ae(re.handle)) throw new Error("legacy destruction failed");
|
|
4353
|
+
re = null, le(ue);
|
|
4354
|
+
const Li = i.keys.find((X) => X.purpose === "sdn-authentication");
|
|
4355
|
+
v.result.replaceChildren(), lt(n, v.result, "Current account xpub", i.accountXpub), lt(n, v.result, "Legacy account xpub", Ri.accountXpub), lt(n, v.result, "Current authentication key", Li?.publicKeyHex), lt(n, v.result, "Legacy authentication key", at.publicKeyHex);
|
|
4356
|
+
} catch {
|
|
4357
|
+
ve(ue) && (v.result.textContent = "Legacy account comparison could not be completed.");
|
|
4358
|
+
} finally {
|
|
4359
|
+
re?.handle && Ae(re.handle), Y?.promise && O.delete(Y), ke(Te), ke(Ot), ke(Nt), We(), ce -= 1, Q = !1, ve(ue) && ge();
|
|
4360
|
+
}
|
|
4361
|
+
}, Ee = () => {
|
|
4362
|
+
if (b) {
|
|
4363
|
+
try {
|
|
4364
|
+
b.confirmation.value = "";
|
|
4365
|
+
} catch {
|
|
4366
|
+
}
|
|
4367
|
+
try {
|
|
4368
|
+
b.confirmation.defaultValue = "";
|
|
4369
|
+
} catch {
|
|
4370
|
+
}
|
|
4371
|
+
}
|
|
4372
|
+
}, qe = (L) => {
|
|
4373
|
+
if (!(!b || L?.isTrusted !== !0 || G || Q || q || J || M)) {
|
|
4374
|
+
Ee(), b.confirmationGroup.hidden = !1, b.status.textContent = `Type ${b.confirmationKey} to confirm.`;
|
|
4375
|
+
try {
|
|
4376
|
+
b.confirmation.focus?.();
|
|
4377
|
+
} catch {
|
|
4378
|
+
}
|
|
4379
|
+
}
|
|
4380
|
+
}, ot = (L) => {
|
|
4381
|
+
!b || L?.isTrusted !== !0 || q || M || (Ee(), b.confirmationGroup.hidden = !0, b.status.textContent = "Forget cancelled.");
|
|
4382
|
+
}, Se = (L) => {
|
|
4383
|
+
if (!b || L?.isTrusted !== !0 || G || Q || q || J || M) return;
|
|
4384
|
+
const P = b.confirmation.value;
|
|
4385
|
+
if (P !== b.confirmationKey) {
|
|
4386
|
+
b.status.textContent = "Type the exact storage key to confirm.";
|
|
4387
|
+
return;
|
|
4388
|
+
}
|
|
4389
|
+
q = !0, ge(), Ee();
|
|
4390
|
+
try {
|
|
4391
|
+
t.forgetRememberedWallet(P), J = !0, b.confirmationGroup.hidden = !0, b.status.textContent = "Stored wallet forgotten. This account remains signed in.";
|
|
4392
|
+
} catch {
|
|
4393
|
+
b.status.textContent = "Stored wallet could not be forgotten.";
|
|
4394
|
+
} finally {
|
|
4395
|
+
q = !1, M || ge();
|
|
4396
|
+
}
|
|
4397
|
+
}, an = (L) => {
|
|
4398
|
+
if (M)
|
|
4399
|
+
Fe();
|
|
4400
|
+
else {
|
|
4401
|
+
M = !0, Ie += 1, h.disabled = !0, v.launch.disabled = !0, b && (b.launch.disabled = !0, b.confirm.disabled = !0, b.cancel.disabled = !0, Ee(), b.launch.removeEventListener?.("click", qe), b.confirm.removeEventListener?.("click", Se), b.cancel.removeEventListener?.("click", ot)), x?.destroy?.(), Fe(), h.removeEventListener?.("click", ze), v.launch.removeEventListener?.("click", st);
|
|
4402
|
+
for (const P of O) P.cancel?.();
|
|
4403
|
+
O.clear();
|
|
4404
|
+
}
|
|
4405
|
+
L && !te && (H.textContent = "Secure cleanup is still pending. Retry Return or Logout.", l.replaceChildren(H, m, A), m.disabled = !1, A.disabled = !1);
|
|
4406
|
+
}, cn = () => {
|
|
4407
|
+
const L = z.destroy(), P = We();
|
|
4408
|
+
return L && P && ce === 0 && !Q && !G;
|
|
4409
|
+
}, vi = () => (an(!1), te || (te = !0, m.disabled = !0, A.disabled = !0, m.removeEventListener?.("click", ln), A.removeEventListener?.("click", un), l.remove?.()), cn()), Lt = (L, P, ue, { requireTrustedEvent: Y = !0 } = {}) => Y && L?.isTrusted !== !0 ? Promise.resolve() : W || (R || te ? Promise.reject(new j("STALE_CONTROLLER")) : (an(!0), cn() ? (R = !0, m.disabled = !0, A.disabled = !0, W = (async () => {
|
|
4410
|
+
o(), bi(n, null, ue, a);
|
|
4411
|
+
try {
|
|
4412
|
+
const Te = await P();
|
|
4413
|
+
if (!r()) throw new j("STALE_CONTROLLER");
|
|
4414
|
+
return Te;
|
|
4415
|
+
} catch (Te) {
|
|
4416
|
+
throw r() && Ii(n, void 0, a), Te;
|
|
4417
|
+
}
|
|
4418
|
+
})(), W) : (H.textContent = "Secure cleanup is still pending. Retry Return or Logout.", m.disabled = !1, A.disabled = !1, Promise.reject(new j("DESTRUCTION_FAILED"))))), ln = (L) => {
|
|
4419
|
+
Lt(
|
|
4420
|
+
L,
|
|
4421
|
+
() => t.returnToSite(),
|
|
4422
|
+
"Returning to the requesting site."
|
|
4423
|
+
).catch(() => {
|
|
4424
|
+
});
|
|
4425
|
+
}, un = (L) => {
|
|
4426
|
+
Lt(
|
|
4427
|
+
L,
|
|
4428
|
+
() => t.logout(),
|
|
4429
|
+
"Logged out. Returning to the requesting site."
|
|
4430
|
+
).catch(() => {
|
|
4431
|
+
});
|
|
4432
|
+
};
|
|
4433
|
+
return h.addEventListener("click", ze), v.launch.addEventListener("click", st), b?.launch.addEventListener?.("click", qe), b?.confirm.addEventListener?.("click", Se), b?.cancel.addEventListener?.("click", ot), m.addEventListener("click", ln), A.addEventListener("click", un), Object.freeze({
|
|
4434
|
+
destroy: vi,
|
|
4435
|
+
logout: () => Lt(
|
|
4436
|
+
null,
|
|
4437
|
+
() => t.logout(),
|
|
4438
|
+
"Logged out. Returning to the requesting site.",
|
|
4439
|
+
{ requireTrustedEvent: !1 }
|
|
4440
|
+
)
|
|
4441
|
+
});
|
|
4442
|
+
}
|
|
4443
|
+
function wo(e) {
|
|
4444
|
+
const t = e?.pathname, n = e?.search ?? "", i = e?.hash ?? "";
|
|
4445
|
+
if (typeof t != "string" || n !== "" || i !== "") throw Pn();
|
|
4446
|
+
const r = ho.exec(t);
|
|
4447
|
+
if (!r) throw Pn();
|
|
4448
|
+
return r[1];
|
|
4449
|
+
}
|
|
4450
|
+
function bo(e) {
|
|
4451
|
+
const t = e?.window ?? globalThis.window, n = e?.document ?? t?.document ?? globalThis.document, i = e?.mount ?? n?.body, r = typeof t?.fetch == "function" ? t.fetch.bind(t) : typeof globalThis.fetch == "function" ? globalThis.fetch.bind(globalThis) : null, s = e?.relay ?? (e?.controller ? null : qs({
|
|
4452
|
+
fetch: e?.fetch ?? r,
|
|
4453
|
+
location: e?.location ?? t?.location
|
|
4454
|
+
})), a = e?.registry ?? mo, o = e?.controller ?? new Ks({
|
|
4455
|
+
...e,
|
|
4456
|
+
document: n,
|
|
4457
|
+
registry: a,
|
|
4458
|
+
relay: s,
|
|
4459
|
+
window: t
|
|
4460
|
+
}), c = e?.credentialPrompt ?? ((O) => go(O));
|
|
4461
|
+
let l = null, d = null, u = null, f = null, p = null, g = [], E = 0, h = !1;
|
|
4462
|
+
const A = () => {
|
|
4463
|
+
(l?.destroy?.() ?? !0) && (l = null), d = null;
|
|
4464
|
+
}, m = () => {
|
|
4465
|
+
try {
|
|
4466
|
+
i?.replaceChildren?.();
|
|
4467
|
+
} catch {
|
|
4468
|
+
}
|
|
4469
|
+
}, N = () => (E = E >= Number.MAX_SAFE_INTEGER ? 1 : E + 1, E), v = () => {
|
|
4470
|
+
h = !0, N();
|
|
4471
|
+
}, V = (O) => !h && E === O, I = (O) => {
|
|
4472
|
+
if (!V(O)) throw new j("STALE_CONTROLLER");
|
|
4473
|
+
}, b = (O) => {
|
|
4474
|
+
try {
|
|
4475
|
+
O?.remove?.();
|
|
4476
|
+
} catch {
|
|
4477
|
+
}
|
|
4478
|
+
u === O && (u = null);
|
|
4479
|
+
}, x = () => {
|
|
4480
|
+
v(), u?.cancel?.(), u = null, A(), m();
|
|
4481
|
+
}, H = (O, F, D) => {
|
|
4482
|
+
O?.addEventListener?.(F, D), g.push([O, F, D]);
|
|
4483
|
+
}, z = () => {
|
|
4484
|
+
for (const [O, F, D] of g)
|
|
4485
|
+
try {
|
|
4486
|
+
O?.removeEventListener?.(F, D);
|
|
4487
|
+
} catch {
|
|
4488
|
+
}
|
|
4489
|
+
g = [];
|
|
4490
|
+
};
|
|
4491
|
+
return H(t, "pagehide", x), H(n, "freeze", x), H(t, "beforeunload", x), H(t, "pageshow", (O) => {
|
|
4492
|
+
O?.persisted === !0 && x();
|
|
4493
|
+
}), Object.freeze({
|
|
4494
|
+
controller: o,
|
|
4495
|
+
logout() {
|
|
4496
|
+
return l ? l.logout() : (v(), u?.cancel?.(), u = null, d = null, o.logout());
|
|
4497
|
+
},
|
|
4498
|
+
start() {
|
|
4499
|
+
if (f) return f;
|
|
4500
|
+
const O = E;
|
|
4501
|
+
return h ? (f = Promise.reject(new j("STALE_CONTROLLER")), f) : (f = (async () => {
|
|
4502
|
+
try {
|
|
4503
|
+
const F = wo(t?.location);
|
|
4504
|
+
if (typeof o.prepare != "function" || typeof o.executePrepared != "function" || typeof o.unlockPassword != "function") {
|
|
4505
|
+
const M = await o.execute(F);
|
|
4506
|
+
return I(O), M;
|
|
4507
|
+
}
|
|
4508
|
+
const D = await o.prepare(F);
|
|
4509
|
+
if (I(O), D.transaction.operation === "sdn.auth.raw-challenge.v1") {
|
|
4510
|
+
const M = Ao({
|
|
4511
|
+
document: n,
|
|
4512
|
+
mount: i,
|
|
4513
|
+
title: `Choose the legacy profile for ${D.binding.clientDisplayName}`
|
|
4514
|
+
});
|
|
4515
|
+
u = M;
|
|
4516
|
+
const R = await M.promise;
|
|
4517
|
+
I(O), u === M && (u = null);
|
|
4518
|
+
const W = R === "password-fast-v1-legacy" ? c({
|
|
4519
|
+
controller: null,
|
|
4520
|
+
document: n,
|
|
4521
|
+
mount: i,
|
|
4522
|
+
title: `Sign in to ${D.binding.clientDisplayName}`,
|
|
4523
|
+
transaction: D
|
|
4524
|
+
}) : wi({
|
|
4525
|
+
document: n,
|
|
4526
|
+
mount: i,
|
|
4527
|
+
submitLabel: "Continue",
|
|
4528
|
+
title: `Sign in to ${D.binding.clientDisplayName}`
|
|
4529
|
+
});
|
|
4530
|
+
u = W?.promise ? W : null;
|
|
4531
|
+
const q = W?.promise ? await W.promise : await W;
|
|
4532
|
+
I(O);
|
|
4533
|
+
const J = await o.unlockLegacy({
|
|
4534
|
+
...q,
|
|
4535
|
+
operation: D.transaction.operation,
|
|
4536
|
+
profile: R
|
|
4537
|
+
});
|
|
4538
|
+
I(O), d = J;
|
|
4539
|
+
} else {
|
|
4540
|
+
let M = !1;
|
|
4541
|
+
for (; ; ) {
|
|
4542
|
+
const R = c({
|
|
4543
|
+
controller: o,
|
|
4544
|
+
document: n,
|
|
4545
|
+
mount: i,
|
|
4546
|
+
offerRememberedUnlock: !M,
|
|
4547
|
+
title: `Sign in to ${D.binding.clientDisplayName}`,
|
|
4548
|
+
transaction: D
|
|
4549
|
+
});
|
|
4550
|
+
M && R?.controls?.rememberStatus && (R.controls.rememberStatus.textContent = "Remembered wallet unavailable. Enter username and password."), u = R?.promise ? R : null;
|
|
4551
|
+
const W = R?.promise ? await R.promise : await R;
|
|
4552
|
+
if (I(O), W?.remembered === !0)
|
|
4553
|
+
try {
|
|
4554
|
+
const J = await o.unlockRemembered();
|
|
4555
|
+
I(O), d = J;
|
|
4556
|
+
break;
|
|
4557
|
+
} catch {
|
|
4558
|
+
if (!V(O))
|
|
4559
|
+
throw b(R), new j("STALE_CONTROLLER");
|
|
4560
|
+
M = !0, b(R);
|
|
4561
|
+
continue;
|
|
4562
|
+
}
|
|
4563
|
+
const q = await o.unlockPassword(W);
|
|
4564
|
+
I(O), d = q;
|
|
4565
|
+
break;
|
|
4566
|
+
}
|
|
4567
|
+
}
|
|
4568
|
+
const G = await o.executePrepared(D);
|
|
4569
|
+
return I(O), b(u), D.transaction.operation === "sdn.wallet.account.v1" ? (d = o.copyPublicIdentity(), l = Eo({
|
|
4570
|
+
clipboard: e?.clipboard ?? globalThis.navigator?.clipboard,
|
|
4571
|
+
controller: o,
|
|
4572
|
+
document: n,
|
|
4573
|
+
identity: d,
|
|
4574
|
+
isAppCurrent: () => V(O),
|
|
4575
|
+
makeCredentialPrompt: c,
|
|
4576
|
+
mount: i,
|
|
4577
|
+
onClear: A,
|
|
4578
|
+
wasm: e?.wasm
|
|
4579
|
+
})) : (d = null, n?.createElement && i?.replaceChildren && bi(
|
|
4580
|
+
n,
|
|
4581
|
+
t,
|
|
4582
|
+
"The wallet request completed successfully.",
|
|
4583
|
+
i
|
|
4584
|
+
)), G;
|
|
4585
|
+
} catch (F) {
|
|
4586
|
+
const D = !V(O);
|
|
4587
|
+
throw u?.cancel?.(), u = null, A(), z(), D || Ii(n, F?.code === "USER_CANCELLED" ? "Cancelled. You may close this window." : void 0, i), await (p ?? o.destroy(D ? "stale-startup" : "startup-failure")), D && F?.code !== "DESTRUCTION_FAILED" ? new j("STALE_CONTROLLER") : F;
|
|
4588
|
+
}
|
|
4589
|
+
})(), f);
|
|
4590
|
+
},
|
|
4591
|
+
stop(O = "close") {
|
|
4592
|
+
v(), u?.cancel?.(), u = null, A(), m();
|
|
4593
|
+
const F = o.destroy(O);
|
|
4594
|
+
return p || (z(), p = F), p;
|
|
4595
|
+
}
|
|
4596
|
+
});
|
|
4597
|
+
}
|
|
4598
|
+
async function vo(e) {
|
|
4599
|
+
const t = bo(e);
|
|
4600
|
+
return await t.start(), t;
|
|
4601
|
+
}
|
|
4602
|
+
export {
|
|
4603
|
+
go as createPasswordCredentialPrompt,
|
|
4604
|
+
bo as createWalletOriginApp,
|
|
4605
|
+
vo as mountWalletOriginApp,
|
|
4606
|
+
wo as transactionIdFromLocation
|
|
4607
|
+
};
|