hd-wallet-ui 2.2.1 → 2.2.2
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/README.md +7 -4
- package/dist/browser/sdn-wallet-public-client.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/types.d.ts +1 -1
- package/dist/wallet-origin/index.js +1039 -1037
- package/dist/wallet-origin-host/assets/{wallet-origin.a76de7ca94a41a4800d35df29d7b115206c3da6ff3a7e828309aa34adc88b5c3.css → wallet-origin.154fa2fd7f7dc1bf2051e35c1490915763fcaa6f05d88a3d32f1973ef0da5844.css} +1 -1
- package/dist/wallet-origin-host/assets/{wallet-origin.d0119af9e661f9c0a7fb9f00725255d398037b15e691c02c43f357c15ecd7fab.js → wallet-origin.c31bc2645e955c72dea686ed92e596c7d7348e80d1cd56d965d833a4bb7374b9.js} +488 -486
- package/dist/wallet-origin-host/assets/{wallet-origin.8c6002e69b67d46d4d1d8cd987671c7954e8890eb23f5ef2c06c76a0af3583ef.wasm → wallet-origin.c66954bde582bdefa0bd25d09628b36ddf90f917f63af56c52d1168ed995962d.wasm} +0 -0
- package/dist/wallet-origin-host/index.html +2 -2
- package/dist/wallet-origin-host/integrity.json +1 -1
- package/package.json +3 -3
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { getWalletOriginCapabilities as
|
|
2
|
-
const
|
|
1
|
+
import { getWalletOriginCapabilities as tr } from "hd-wallet-wasm";
|
|
2
|
+
const ei = Object.freeze({
|
|
3
3
|
cm: 0.01,
|
|
4
4
|
km: 1e3,
|
|
5
5
|
m: 1,
|
|
6
6
|
mm: 1e-3
|
|
7
|
-
}),
|
|
8
|
-
metersPerSourceUnit:
|
|
7
|
+
}), ti = Object.freeze({
|
|
8
|
+
metersPerSourceUnit: ei,
|
|
9
9
|
quaternionNormTolerance: 1e-6,
|
|
10
10
|
scaleComponentExclusiveMin: 0,
|
|
11
11
|
scaleComponentInclusiveMax: 1e6,
|
|
12
12
|
translationComponentAbsMax: 1e6,
|
|
13
13
|
upAxes: Object.freeze(["X_UP", "Y_UP", "Z_UP"])
|
|
14
|
-
}),
|
|
14
|
+
}), ni = Object.freeze({ reviewedTransform: ti, schemaVersion: 1 }), Ee = new TextEncoder(), nr = Object.getPrototypeOf(Uint8Array.prototype), ri = Object.getOwnPropertyDescriptor(nr, "buffer").get, ii = Object.getOwnPropertyDescriptor(nr, "length").get, si = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get, vn = typeof SharedArrayBuffer > "u" ? null : Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get, we = "sdn-bip32-slip10-purpose-v1", vt = "password-scrypt-v2", ke = "ed25519-over-sha256-jcs-v1", Sn = "ed25519-raw-32-v1", oi = "ed25519-sdn-signed-request-v2", Rn = ["protocolVersion", "providerOrigin", "method", "requestUri", "bodySha256", "bodyBytes", "schema", "entityId", "entityName", "documentCount"], On = ["schemaVersion", "keyId", "identityScheme", "algorithm", "encoding", "signatureProfile", "publicKeyHex", "signatureHex", "requestDigestSha256", "challengeId", "challengeBase64url"], rr = "https://review.spacedatanetwork.org", ir = "sdn-asset-review-v1", ai = "asset-review:assets.ipfs.01", ci = "asset-review-authority:assets.ipfs.01", Wt = "sdn-login:sdn.spaceaware.io", li = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u, te = /^[0-9a-f]{64}$/u, rn = /^[0-9a-f]{128}$/u, je = /^sha256:[0-9a-f]{64}$/u, ui = /^[1-9A-HJ-NP-Za-km-z]+$/u, di = /^b[a-z2-7]{58}$/u, Ht = "abcdefghijklmnopqrstuvwxyz234567", sr = 131072, fi = [
|
|
15
15
|
"accountFingerprint",
|
|
16
16
|
"accountIndex",
|
|
17
17
|
"accountLabel",
|
|
@@ -21,7 +21,7 @@ const er = Object.freeze({
|
|
|
21
21
|
"keys",
|
|
22
22
|
"schemaVersion",
|
|
23
23
|
"seedProfile"
|
|
24
|
-
],
|
|
24
|
+
], pi = [
|
|
25
25
|
"bip32Fingerprint",
|
|
26
26
|
"curve",
|
|
27
27
|
"derivation",
|
|
@@ -33,12 +33,12 @@ const er = Object.freeze({
|
|
|
33
33
|
"purpose",
|
|
34
34
|
"seedProfile",
|
|
35
35
|
"signatureProfile"
|
|
36
|
-
],
|
|
36
|
+
], hi = [
|
|
37
37
|
"connectionExpiresAt",
|
|
38
38
|
"event",
|
|
39
39
|
"identity",
|
|
40
40
|
"schemaVersion"
|
|
41
|
-
],
|
|
41
|
+
], yi = [
|
|
42
42
|
"algorithm",
|
|
43
43
|
"encoding",
|
|
44
44
|
"identityScheme",
|
|
@@ -46,7 +46,7 @@ const er = Object.freeze({
|
|
|
46
46
|
"schemaVersion",
|
|
47
47
|
"signatureHex",
|
|
48
48
|
"signatureProfile"
|
|
49
|
-
],
|
|
49
|
+
], mi = [
|
|
50
50
|
"algorithm",
|
|
51
51
|
"canonicalEnvelope",
|
|
52
52
|
"encoding",
|
|
@@ -70,7 +70,7 @@ const er = Object.freeze({
|
|
|
70
70
|
"requestOrigin",
|
|
71
71
|
"serviceInstance",
|
|
72
72
|
"signatureProfile"
|
|
73
|
-
],
|
|
73
|
+
], zt = [
|
|
74
74
|
"audience",
|
|
75
75
|
"candidateKey",
|
|
76
76
|
"challengeId",
|
|
@@ -86,7 +86,7 @@ const er = Object.freeze({
|
|
|
86
86
|
"previousDecisionHead",
|
|
87
87
|
"protocolVersion",
|
|
88
88
|
"requestOrigin"
|
|
89
|
-
],
|
|
89
|
+
], gi = [
|
|
90
90
|
"metersPerSourceUnit",
|
|
91
91
|
"rotation",
|
|
92
92
|
"scale",
|
|
@@ -102,25 +102,25 @@ function lt(e) {
|
|
|
102
102
|
const t = Object.getPrototypeOf(e);
|
|
103
103
|
return t === Object.prototype || t === null;
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function ie(e, t) {
|
|
106
106
|
typeof e != "string" && y(`${t} must be a string`);
|
|
107
107
|
for (let n = 0; n < e.length; n += 1) {
|
|
108
|
-
const
|
|
109
|
-
let
|
|
110
|
-
if (
|
|
108
|
+
const r = e.charCodeAt(n);
|
|
109
|
+
let i = r;
|
|
110
|
+
if (r >= 55296 && r <= 56319) {
|
|
111
111
|
const s = e.charCodeAt(n + 1);
|
|
112
|
-
s >= 56320 && s <= 57343 || y(`${t} contains an unpaired surrogate`),
|
|
113
|
-
} else
|
|
114
|
-
((
|
|
112
|
+
s >= 56320 && s <= 57343 || y(`${t} contains an unpaired surrogate`), i = 65536 + (r - 55296 << 10) + (s - 56320), n += 1;
|
|
113
|
+
} else r >= 56320 && r <= 57343 && y(`${t} contains an unpaired surrogate`);
|
|
114
|
+
((i & 65535) === 65534 || (i & 65535) === 65535 || i >= 64976 && i <= 65007) && y(`${t} contains a Unicode noncharacter`);
|
|
115
115
|
}
|
|
116
116
|
return e;
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
typeof e != "string" && y("wire JSON must be a string"), Ee.encode(e).byteLength >
|
|
118
|
+
function or(e) {
|
|
119
|
+
typeof e != "string" && y("wire JSON must be a string"), Ee.encode(e).byteLength > sr && y("wire JSON is too large"), e.charCodeAt(0) === 65279 && y("wire JSON must not contain a BOM");
|
|
120
120
|
let t = 0, n = 0;
|
|
121
|
-
const
|
|
121
|
+
const r = () => {
|
|
122
122
|
for (; t < e.length && /[\u0009\u000a\u000d\u0020]/u.test(e[t]); ) t += 1;
|
|
123
|
-
},
|
|
123
|
+
}, i = () => {
|
|
124
124
|
e[t] !== '"' && y("invalid JSON string");
|
|
125
125
|
const o = t;
|
|
126
126
|
for (t += 1; t < e.length; ) {
|
|
@@ -133,24 +133,24 @@ function oi(e) {
|
|
|
133
133
|
} catch {
|
|
134
134
|
y("invalid JSON string");
|
|
135
135
|
}
|
|
136
|
-
return
|
|
136
|
+
return ie(l, "JSON string");
|
|
137
137
|
}
|
|
138
138
|
c < 32 && y("invalid JSON control character"), c === 92 && (t += 1, t >= e.length && y("unterminated JSON escape")), t += 1;
|
|
139
139
|
}
|
|
140
140
|
y("unterminated JSON string");
|
|
141
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"),
|
|
142
|
+
o > 32 && y("wire JSON nesting is too deep"), n += 1, n > 4096 && y("wire JSON contains too many values"), r();
|
|
143
143
|
const c = e[t];
|
|
144
|
-
if (c === '"') return
|
|
144
|
+
if (c === '"') return i();
|
|
145
145
|
if (c === "{") {
|
|
146
146
|
t += 1;
|
|
147
147
|
const u = /* @__PURE__ */ Object.create(null), p = /* @__PURE__ */ new Set();
|
|
148
|
-
if (
|
|
148
|
+
if (r(), e[t] === "}")
|
|
149
149
|
return t += 1, u;
|
|
150
150
|
for (; t < e.length; ) {
|
|
151
|
-
|
|
152
|
-
const f =
|
|
153
|
-
if (p.has(f) && y(`duplicate JSON field: ${f}`), p.add(f),
|
|
151
|
+
r();
|
|
152
|
+
const f = i();
|
|
153
|
+
if (p.has(f) && y(`duplicate JSON field: ${f}`), p.add(f), r(), e[t] !== ":" && y("missing JSON object colon"), t += 1, u[f] = s(o + 1), r(), e[t] === "}")
|
|
154
154
|
return t += 1, u;
|
|
155
155
|
e[t] !== "," && y("invalid JSON object separator"), t += 1;
|
|
156
156
|
}
|
|
@@ -159,10 +159,10 @@ function oi(e) {
|
|
|
159
159
|
if (c === "[") {
|
|
160
160
|
t += 1;
|
|
161
161
|
const u = [];
|
|
162
|
-
if (
|
|
162
|
+
if (r(), e[t] === "]")
|
|
163
163
|
return t += 1, u;
|
|
164
164
|
for (; t < e.length; ) {
|
|
165
|
-
if (u.push(s(o + 1)),
|
|
165
|
+
if (u.push(s(o + 1)), r(), e[t] === "]")
|
|
166
166
|
return t += 1, u;
|
|
167
167
|
e[t] !== "," && y("invalid JSON array separator"), t += 1;
|
|
168
168
|
}
|
|
@@ -176,29 +176,29 @@ function oi(e) {
|
|
|
176
176
|
const d = Number(l[0]);
|
|
177
177
|
return Number.isFinite(d) || y("wire JSON number must be finite"), d;
|
|
178
178
|
};
|
|
179
|
-
|
|
179
|
+
r();
|
|
180
180
|
const a = s();
|
|
181
|
-
return
|
|
181
|
+
return r(), t !== e.length && y("wire JSON contains trailing bytes"), a;
|
|
182
182
|
}
|
|
183
|
-
function
|
|
184
|
-
return typeof e == "string" ?
|
|
183
|
+
function ar(e) {
|
|
184
|
+
return typeof e == "string" ? or(e) : e;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function Ai(e, t) {
|
|
187
187
|
if (e.byteLength !== t.byteLength) return !1;
|
|
188
188
|
let n = 0;
|
|
189
|
-
for (let
|
|
189
|
+
for (let r = 0; r < e.byteLength; r += 1) n |= e[r] ^ t[r];
|
|
190
190
|
return n === 0;
|
|
191
191
|
}
|
|
192
|
-
function
|
|
193
|
-
const
|
|
194
|
-
lt(
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
for (const c of
|
|
198
|
-
const l = Object.getOwnPropertyDescriptor(
|
|
192
|
+
function z(e, t, n) {
|
|
193
|
+
const r = ar(e);
|
|
194
|
+
lt(r) || y(`${n} must be a JSON object`), Object.getOwnPropertySymbols(r).length !== 0 && y(`${n} has an unknown symbol field`);
|
|
195
|
+
const i = Object.getOwnPropertyNames(r).sort(), s = [...t].sort(), a = Ee.encode(i.join("\0")), o = Ee.encode(s.join("\0"));
|
|
196
|
+
Ai(a, o) || y(`${n} has missing or unknown fields`);
|
|
197
|
+
for (const c of i) {
|
|
198
|
+
const l = Object.getOwnPropertyDescriptor(r, c);
|
|
199
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
200
|
}
|
|
201
|
-
return
|
|
201
|
+
return r;
|
|
202
202
|
}
|
|
203
203
|
function Ve(e) {
|
|
204
204
|
if (!e || typeof e != "object" || Object.isFrozen(e)) return e;
|
|
@@ -210,51 +210,51 @@ function J(e) {
|
|
|
210
210
|
}
|
|
211
211
|
function ut(e, t, n) {
|
|
212
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
|
|
214
|
-
(
|
|
213
|
+
const r = [...Array.from({ length: t }, (s, a) => String(a)), "length"], i = Reflect.ownKeys(e);
|
|
214
|
+
(i.length !== r.length || i.some((s, a) => s !== r[a])) && y(`${n} must be a dense plain array`);
|
|
215
215
|
for (let s = 0; s < t; s += 1) {
|
|
216
216
|
const a = Object.getOwnPropertyDescriptor(e, String(s));
|
|
217
217
|
(!a || !a.enumerable || !("value" in a) || a.value === void 0) && y(`${n} must contain enumerable data values`);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
function
|
|
221
|
-
const t =
|
|
220
|
+
function bi(e) {
|
|
221
|
+
const t = z(
|
|
222
222
|
e,
|
|
223
223
|
["reviewedTransform", "schemaVersion"],
|
|
224
224
|
"asset review protocol policy"
|
|
225
225
|
);
|
|
226
226
|
w(t.schemaVersion, 1, "asset review protocol schemaVersion");
|
|
227
|
-
const n =
|
|
227
|
+
const n = z(t.reviewedTransform, [
|
|
228
228
|
"metersPerSourceUnit",
|
|
229
229
|
"quaternionNormTolerance",
|
|
230
230
|
"scaleComponentExclusiveMin",
|
|
231
231
|
"scaleComponentInclusiveMax",
|
|
232
232
|
"translationComponentAbsMax",
|
|
233
233
|
"upAxes"
|
|
234
|
-
], "asset review transform policy"),
|
|
234
|
+
], "asset review transform policy"), r = z(
|
|
235
235
|
n.metersPerSourceUnit,
|
|
236
236
|
["cm", "km", "m", "mm"],
|
|
237
237
|
"asset review unit policy"
|
|
238
238
|
);
|
|
239
|
-
for (const [
|
|
240
|
-
(typeof s != "number" || !Number.isFinite(s) || s <= 0) && y(`asset review unit policy ${
|
|
241
|
-
for (const [
|
|
239
|
+
for (const [i, s] of Object.entries(r))
|
|
240
|
+
(typeof s != "number" || !Number.isFinite(s) || s <= 0) && y(`asset review unit policy ${i} must be positive and finite`);
|
|
241
|
+
for (const [i, s] of [
|
|
242
242
|
["quaternionNormTolerance", n.quaternionNormTolerance],
|
|
243
243
|
["scaleComponentExclusiveMin", n.scaleComponentExclusiveMin],
|
|
244
244
|
["scaleComponentInclusiveMax", n.scaleComponentInclusiveMax],
|
|
245
245
|
["translationComponentAbsMax", n.translationComponentAbsMax]
|
|
246
246
|
])
|
|
247
|
-
(typeof s != "number" || !Number.isFinite(s)) && y(`asset review transform policy ${
|
|
247
|
+
(typeof s != "number" || !Number.isFinite(s)) && y(`asset review transform policy ${i} must be finite`);
|
|
248
248
|
return (n.quaternionNormTolerance <= 0 || n.scaleComponentInclusiveMax <= n.scaleComponentExclusiveMin || n.translationComponentAbsMax <= 0) && y("asset review transform policy bounds are inconsistent"), ut(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"), J([
|
|
249
|
-
["metersPerSourceUnit", J(Object.entries(
|
|
249
|
+
["metersPerSourceUnit", J(Object.entries(r))],
|
|
250
250
|
["quaternionNormTolerance", n.quaternionNormTolerance],
|
|
251
251
|
["scaleComponentExclusiveMin", n.scaleComponentExclusiveMin],
|
|
252
252
|
["scaleComponentInclusiveMax", n.scaleComponentInclusiveMax],
|
|
253
253
|
["translationComponentAbsMax", n.translationComponentAbsMax],
|
|
254
|
-
["upAxes", Object.freeze(Array.from({ length: 3 }, (
|
|
254
|
+
["upAxes", Object.freeze(Array.from({ length: 3 }, (i, s) => n.upAxes[s]))]
|
|
255
255
|
]);
|
|
256
256
|
}
|
|
257
|
-
const De =
|
|
257
|
+
const De = bi(ni);
|
|
258
258
|
function w(e, t, n) {
|
|
259
259
|
return e !== t && y(`${n} must equal ${JSON.stringify(t)}`), e;
|
|
260
260
|
}
|
|
@@ -262,20 +262,20 @@ function ct(e, t, n) {
|
|
|
262
262
|
return t.includes(e) || y(`${n} is not an allowed value`), e;
|
|
263
263
|
}
|
|
264
264
|
function F(e, t, n) {
|
|
265
|
-
return
|
|
265
|
+
return ie(e, n), t.test(e) || y(`${n} has an invalid encoding`), e;
|
|
266
266
|
}
|
|
267
267
|
function ve(e, t) {
|
|
268
|
-
return
|
|
268
|
+
return ie(e, t), (!li.test(e) || new Date(e).toISOString() !== e) && y(`${t} must be exact RFC3339 milliseconds UTC`), e;
|
|
269
269
|
}
|
|
270
270
|
function Dt(e, t) {
|
|
271
|
-
const n = Date.parse(e),
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
function
|
|
275
|
-
(!ArrayBuffer.isView(e) || !(e instanceof Uint8Array) || Object.getPrototypeOf(e) !== Uint8Array.prototype) && y(`${t} must be a plain Uint8Array`),
|
|
276
|
-
const
|
|
277
|
-
(
|
|
278
|
-
const s =
|
|
271
|
+
const n = Date.parse(e), r = Date.parse(t);
|
|
272
|
+
r > n && r - n <= 3e5 || y("request lifetime must be in (0, 300] seconds");
|
|
273
|
+
}
|
|
274
|
+
function Ei(e, t) {
|
|
275
|
+
(!ArrayBuffer.isView(e) || !(e instanceof Uint8Array) || Object.getPrototypeOf(e) !== Uint8Array.prototype) && y(`${t} must be a plain Uint8Array`), ii.call(e) !== 32 && y(`${t} must be exactly 32 bytes`);
|
|
276
|
+
const r = Array.from({ length: 32 }, (d, u) => String(u)), i = Reflect.ownKeys(e);
|
|
277
|
+
(i.length !== r.length || i.some((d, u) => d !== r[u])) && y(`${t} Uint8Array must contain only 32 indexed bytes`);
|
|
278
|
+
const s = ri.call(e);
|
|
279
279
|
let a = !1;
|
|
280
280
|
if (vn)
|
|
281
281
|
try {
|
|
@@ -285,7 +285,7 @@ function Er(e, t) {
|
|
|
285
285
|
}
|
|
286
286
|
a && y(`${t} must not use SharedArrayBuffer storage`);
|
|
287
287
|
try {
|
|
288
|
-
|
|
288
|
+
si.call(s);
|
|
289
289
|
} catch {
|
|
290
290
|
y(`${t} must use ArrayBuffer storage`);
|
|
291
291
|
}
|
|
@@ -300,34 +300,34 @@ function Er(e, t) {
|
|
|
300
300
|
return l.length !== 43 && y(`${t} did not encode to 43 base64url characters`), l;
|
|
301
301
|
}
|
|
302
302
|
function sn(e, t) {
|
|
303
|
-
|
|
303
|
+
ie(e, t), /^[A-Za-z0-9_-]{43}$/u.test(e) || y(`${t} must be canonical unpadded base64url`);
|
|
304
304
|
let n;
|
|
305
305
|
try {
|
|
306
306
|
n = globalThis.atob(`${e.replace(/-/gu, "+").replace(/_/gu, "/")}=`);
|
|
307
307
|
} catch {
|
|
308
308
|
y(`${t} must be valid base64url`);
|
|
309
309
|
}
|
|
310
|
-
const
|
|
311
|
-
return (
|
|
310
|
+
const r = Uint8Array.from(n, (i) => i.charCodeAt(0));
|
|
311
|
+
return (r.byteLength !== 32 || Ei(r, t) !== e) && y(`${t} must canonically encode exactly 32 bytes`), e;
|
|
312
312
|
}
|
|
313
|
-
function
|
|
314
|
-
let t = 0, n = 0,
|
|
315
|
-
for (const
|
|
316
|
-
for (t = t << 8 |
|
|
317
|
-
n -= 5,
|
|
318
|
-
return n !== 0 && (
|
|
313
|
+
function wi(e) {
|
|
314
|
+
let t = 0, n = 0, r = "";
|
|
315
|
+
for (const i of e)
|
|
316
|
+
for (t = t << 8 | i, n += 8; n >= 5; )
|
|
317
|
+
n -= 5, r += Ht[t >>> n & 31], t &= (1 << n) - 1;
|
|
318
|
+
return n !== 0 && (r += Ht[t << 5 - n & 31]), r;
|
|
319
319
|
}
|
|
320
|
-
function
|
|
321
|
-
|
|
322
|
-
let n = 0,
|
|
323
|
-
const
|
|
320
|
+
function Ii(e, t) {
|
|
321
|
+
ie(e, "modelCid"), di.test(e) || y("modelCid must be canonical CIDv1 raw sha2-256 base32");
|
|
322
|
+
let n = 0, r = 0;
|
|
323
|
+
const i = [];
|
|
324
324
|
for (const o of e.slice(1)) {
|
|
325
|
-
const c =
|
|
326
|
-
c < 0 && y("modelCid contains invalid base32"), n = n << 5 | c,
|
|
325
|
+
const c = Ht.indexOf(o);
|
|
326
|
+
c < 0 && y("modelCid contains invalid base32"), n = n << 5 | c, r += 5, r >= 8 && (r -= 8, i.push(n >>> r & 255), n &= (1 << r) - 1);
|
|
327
327
|
}
|
|
328
|
-
(
|
|
329
|
-
const s = Uint8Array.from(
|
|
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${
|
|
328
|
+
(r !== 0 && n !== 0 || i.length !== 36) && y("modelCid has noncanonical base32 tail bits or length");
|
|
329
|
+
const s = Uint8Array.from(i);
|
|
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${wi(s)}` !== e && y("modelCid base32 is not canonical");
|
|
331
331
|
let a = 0;
|
|
332
332
|
for (let o = 0; o < 32; o += 1) {
|
|
333
333
|
const c = Number.parseInt(t.slice(o * 2, o * 2 + 2), 16);
|
|
@@ -336,14 +336,14 @@ function Ir(e, t) {
|
|
|
336
336
|
return a !== 0 && y("modelCid digest does not match modelSha256"), e;
|
|
337
337
|
}
|
|
338
338
|
function Kt(e) {
|
|
339
|
-
return e === null || typeof e == "boolean" ? JSON.stringify(e) : typeof e == "string" ? (
|
|
339
|
+
return e === null || typeof e == "boolean" ? JSON.stringify(e) : typeof e == "string" ? (ie(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(Kt).join(",")}]` : (lt(e) || y("canonical JSON contains an unsupported value"), `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${Kt(e[t])}`).join(",")}}`);
|
|
340
340
|
}
|
|
341
341
|
function on(e, t) {
|
|
342
342
|
for (const n of ["identityScheme", "keyId", "signatureProfile"])
|
|
343
343
|
e[n] !== t[n] && y(`canonicalEnvelope ${n} must match the signature result`);
|
|
344
344
|
}
|
|
345
|
-
function
|
|
346
|
-
const
|
|
345
|
+
function vi(e, t) {
|
|
346
|
+
const r = z(e, [
|
|
347
347
|
"audience",
|
|
348
348
|
"challengeSha256",
|
|
349
349
|
"clientId",
|
|
@@ -357,34 +357,34 @@ function vr(e, t) {
|
|
|
357
357
|
"requestOrigin",
|
|
358
358
|
"signatureProfile"
|
|
359
359
|
], "SDN login canonicalEnvelope");
|
|
360
|
-
on(
|
|
360
|
+
on(r, t), w(r.audience, Wt, "SDN login envelope audience"), F(r.challengeSha256, te, "SDN login envelope challengeSha256"), w(r.clientId, "sdn-node-console-v1", "SDN login envelope clientId"), ve(r.issuedAt, "SDN login envelope issuedAt"), ve(r.expiresAt, "SDN login envelope expiresAt"), Dt(r.issuedAt, r.expiresAt), w(r.identityScheme, we, "SDN login envelope identityScheme"), F(r.keyId, je, "SDN login envelope keyId"), w(r.kind, "sdn-login", "SDN login envelope kind"), F(r.nonce, te, "SDN login envelope nonce"), w(r.protocolVersion, 2, "SDN login envelope protocolVersion"), w(r.requestOrigin, "https://sdn.spaceaware.io", "SDN login envelope requestOrigin"), w(r.signatureProfile, ke, "SDN login envelope signatureProfile");
|
|
361
361
|
}
|
|
362
|
-
function
|
|
363
|
-
const n =
|
|
362
|
+
function Si(e, t) {
|
|
363
|
+
const n = z(
|
|
364
364
|
e,
|
|
365
365
|
[...St, "kind"],
|
|
366
366
|
"authority activation canonicalEnvelope"
|
|
367
367
|
);
|
|
368
|
-
on(n, t), w(n.kind, "asset-review-authority-activation", "activation envelope kind"),
|
|
368
|
+
on(n, t), w(n.kind, "asset-review-authority-activation", "activation envelope kind"), lr(Object.fromEntries(St.map((r) => [r, n[r]])));
|
|
369
369
|
}
|
|
370
|
-
function
|
|
371
|
-
const n = e?.decision === "approve" ? ["note", "reviewedTransform"] : e?.decision === "disapprove" ? ["reason"] : [],
|
|
372
|
-
...
|
|
370
|
+
function Ri(e, t) {
|
|
371
|
+
const n = e?.decision === "approve" ? ["note", "reviewedTransform"] : e?.decision === "disapprove" ? ["reason"] : [], r = [...zt, ...n], i = z(e, [
|
|
372
|
+
...r,
|
|
373
373
|
"identityScheme",
|
|
374
374
|
"keyId",
|
|
375
375
|
"kind",
|
|
376
376
|
"purpose",
|
|
377
377
|
"signatureProfile"
|
|
378
378
|
], "asset review decision canonicalEnvelope");
|
|
379
|
-
on(
|
|
379
|
+
on(i, t), w(i.identityScheme, we, "decision envelope identityScheme"), F(i.keyId, je, "decision envelope keyId"), w(i.kind, "asset-review-attestation", "decision envelope kind"), w(i.purpose, "asset-review-approval", "decision envelope purpose"), w(i.signatureProfile, ke, "decision envelope signatureProfile"), ur(Object.fromEntries(r.map((s) => [s, i[s]])));
|
|
380
380
|
}
|
|
381
|
-
function
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
return (!lt(
|
|
381
|
+
function Oi(e, t, n) {
|
|
382
|
+
ie(e, "canonicalEnvelope"), Ee.encode(e).byteLength > sr && y("canonicalEnvelope is too large");
|
|
383
|
+
const r = or(e);
|
|
384
|
+
return (!lt(r) || r.kind !== t) && y("canonicalEnvelope kind does not match the operation"), Kt(r) !== e && y("canonicalEnvelope must be exact JCS"), t === "sdn-login" ? vi(r, n) : t === "asset-review-authority-activation" ? Si(r, n) : t === "asset-review-attestation" ? Ri(r, n) : y("canonicalEnvelope operation is not registered"), e;
|
|
385
385
|
}
|
|
386
|
-
function
|
|
387
|
-
const n =
|
|
386
|
+
function Li(e, t) {
|
|
387
|
+
const n = z(e, pi, `identity key ${t.purpose}`);
|
|
388
388
|
return w(n.purpose, t.purpose, "key purpose"), w(n.identityScheme, we, "key identityScheme"), w(n.seedProfile, vt, "key seedProfile"), w(n.signatureProfile, t.signatureProfile, "key signatureProfile"), w(n.curve, t.curve, "key curve"), w(n.derivation, "slip10", "key derivation"), w(n.path, t.path, "key path"), w(n.encoding, "raw", "key encoding"), F(n.publicKeyHex, te, "key publicKeyHex"), w(n.bip32Fingerprint, null, "key bip32Fingerprint"), F(n.keyId, je, "key keyId"), J([
|
|
389
389
|
["bip32Fingerprint", null],
|
|
390
390
|
["curve", n.curve],
|
|
@@ -399,9 +399,9 @@ function Lr(e, t) {
|
|
|
399
399
|
["signatureProfile", n.signatureProfile]
|
|
400
400
|
]);
|
|
401
401
|
}
|
|
402
|
-
function
|
|
403
|
-
const t =
|
|
404
|
-
w(t.schemaVersion, 1, "identity schemaVersion"), w(t.identityScheme, we, "identity identityScheme"), w(t.seedProfile, vt, "identity seedProfile"), t.accountIndex !== 0 && y("public wallet identity must use account 0"), w(t.accountLabel, null, "identity accountLabel"),
|
|
402
|
+
function Ni(e) {
|
|
403
|
+
const t = z(e, fi, "WalletPublicIdentity");
|
|
404
|
+
w(t.schemaVersion, 1, "identity schemaVersion"), w(t.identityScheme, we, "identity identityScheme"), w(t.seedProfile, vt, "identity seedProfile"), t.accountIndex !== 0 && y("public wallet identity must use account 0"), w(t.accountLabel, null, "identity accountLabel"), ie(t.accountXpub, "identity accountXpub"), /^xpub[1-9A-HJ-NP-Za-km-z]{107}$/u.test(t.accountXpub) || y("identity accountXpub is invalid"), ie(t.accountPeerId, "identity accountPeerId"), (!t.accountPeerId.startsWith("16Uiu2H") || t.accountPeerId.length < 40 || t.accountPeerId.length > 64 || !ui.test(t.accountPeerId)) && y("identity accountPeerId is invalid"), F(t.accountFingerprint, /^[0-9a-f]{8}$/u, "identity accountFingerprint"), ut(t.keys, 3, "public identity keys array");
|
|
405
405
|
const n = [
|
|
406
406
|
{
|
|
407
407
|
purpose: "asset-review-approval",
|
|
@@ -421,9 +421,9 @@ function Nr(e) {
|
|
|
421
421
|
signatureProfile: ke,
|
|
422
422
|
path: "m/44'/0'/0'/0'/0'"
|
|
423
423
|
}
|
|
424
|
-
],
|
|
424
|
+
], r = Array.from(
|
|
425
425
|
{ length: 3 },
|
|
426
|
-
(
|
|
426
|
+
(i, s) => Li(t.keys[s], n[s])
|
|
427
427
|
);
|
|
428
428
|
return J([
|
|
429
429
|
["accountFingerprint", t.accountFingerprint],
|
|
@@ -432,24 +432,24 @@ function Nr(e) {
|
|
|
432
432
|
["accountPeerId", t.accountPeerId],
|
|
433
433
|
["accountXpub", t.accountXpub],
|
|
434
434
|
["identityScheme", we],
|
|
435
|
-
["keys", Ve(
|
|
435
|
+
["keys", Ve(r)],
|
|
436
436
|
["schemaVersion", 1],
|
|
437
437
|
["seedProfile", vt]
|
|
438
438
|
]);
|
|
439
439
|
}
|
|
440
|
-
function
|
|
441
|
-
const n =
|
|
440
|
+
function cr(e, t) {
|
|
441
|
+
const n = z(e, hi, `${t} result`);
|
|
442
442
|
w(n.schemaVersion, 1, "connection result schemaVersion"), ct(n.event, ["connected", "disconnected"], "connection event"), t === "connect" && n.event !== "connected" && y("connect result must be connected");
|
|
443
|
-
let
|
|
444
|
-
return n.event === "connected" ? (
|
|
445
|
-
["connectionExpiresAt",
|
|
443
|
+
let r = null, i = null;
|
|
444
|
+
return n.event === "connected" ? (r = Ni(n.identity), i = ve(n.connectionExpiresAt, "connectionExpiresAt")) : (n.identity !== null || n.connectionExpiresAt !== null) && y("disconnected result must clear identity and expiry"), J([
|
|
445
|
+
["connectionExpiresAt", i],
|
|
446
446
|
["event", n.event],
|
|
447
|
-
["identity",
|
|
447
|
+
["identity", r],
|
|
448
448
|
["schemaVersion", 1]
|
|
449
449
|
]);
|
|
450
450
|
}
|
|
451
|
-
function
|
|
452
|
-
const t =
|
|
451
|
+
function Ti(e) {
|
|
452
|
+
const t = z(e, yi, "raw signature");
|
|
453
453
|
return w(t.schemaVersion, 1, "signature schemaVersion"), F(t.keyId, je, "signature keyId"), ct(t.identityScheme, [
|
|
454
454
|
"sdn-fast-password-auth-v1-legacy",
|
|
455
455
|
"sdn-bip39-auth-v1-legacy"
|
|
@@ -464,8 +464,8 @@ function Tr(e) {
|
|
|
464
464
|
]);
|
|
465
465
|
}
|
|
466
466
|
function an(e, t) {
|
|
467
|
-
const n =
|
|
468
|
-
return w(n.schemaVersion, 1, "signature schemaVersion"), F(n.keyId, je, "signature keyId"), w(n.identityScheme, we, "signature identityScheme"), w(n.algorithm, "ed25519", "signature algorithm"), w(n.encoding, "raw", "signature encoding"), w(n.signatureProfile, ke, "signature profile"),
|
|
467
|
+
const n = z(e, mi, "canonical signature");
|
|
468
|
+
return w(n.schemaVersion, 1, "signature schemaVersion"), F(n.keyId, je, "signature keyId"), w(n.identityScheme, we, "signature identityScheme"), w(n.algorithm, "ed25519", "signature algorithm"), w(n.encoding, "raw", "signature encoding"), w(n.signatureProfile, ke, "signature profile"), Oi(n.canonicalEnvelope, t, n), F(n.signedDigestSha256, te, "signedDigestSha256"), F(n.signatureHex, rn, "signatureHex"), J([
|
|
469
469
|
["algorithm", "ed25519"],
|
|
470
470
|
["canonicalEnvelope", n.canonicalEnvelope],
|
|
471
471
|
["encoding", "raw"],
|
|
@@ -477,16 +477,16 @@ function an(e, t) {
|
|
|
477
477
|
["signedDigestSha256", n.signedDigestSha256]
|
|
478
478
|
]);
|
|
479
479
|
}
|
|
480
|
-
function
|
|
481
|
-
const t =
|
|
480
|
+
function _i(e) {
|
|
481
|
+
const t = z(e, ["challengeBase64url", "protocolVersion"], "SDN login v1 request");
|
|
482
482
|
return w(t.protocolVersion, 1, "SDN login v1 protocolVersion"), sn(t.challengeBase64url, "challengeBase64url"), J([
|
|
483
483
|
["challengeBase64url", t.challengeBase64url],
|
|
484
484
|
["protocolVersion", 1]
|
|
485
485
|
]);
|
|
486
486
|
}
|
|
487
|
-
function
|
|
488
|
-
const t =
|
|
489
|
-
w(t.protocolVersion, 1, "publication protocolVersion"), w(t.method, "POST", "publication method"), ct(t.schema, ["CZM", "ETM"], "publication schema"),
|
|
487
|
+
function Ci(e) {
|
|
488
|
+
const t = z(e, Rn, "SDN publication request");
|
|
489
|
+
w(t.protocolVersion, 1, "publication protocolVersion"), w(t.method, "POST", "publication method"), ct(t.schema, ["CZM", "ETM"], "publication schema"), ie(t.providerOrigin, "providerOrigin");
|
|
490
490
|
let n;
|
|
491
491
|
try {
|
|
492
492
|
n = new URL(t.providerOrigin);
|
|
@@ -494,23 +494,23 @@ function Cr(e) {
|
|
|
494
494
|
y("providerOrigin must be canonical HTTPS");
|
|
495
495
|
}
|
|
496
496
|
(n.protocol !== "https:" || t.providerOrigin !== n.origin || n.username || n.password || n.port === "0" || n.pathname !== "/" || n.search || n.hash || n.hostname.length > 253 || n.hostname.split(".").some((s) => !/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/u.test(s))) && y("providerOrigin must be a canonical HTTPS DNS or IPv4 origin");
|
|
497
|
-
const
|
|
498
|
-
ct(t.requestUri, [
|
|
497
|
+
const r = `/api/v1/data/publish/${t.schema}`, i = `/api/v1/data/publish/batch/${t.schema}`;
|
|
498
|
+
ct(t.requestUri, [r, `${r}.fbs`, i, `${i}.fbs`], "publication requestUri"), F(t.bodySha256, te, "publication bodySha256");
|
|
499
499
|
for (const [s, a] of [["bodyBytes", 1048576], ["documentCount", 1e5]])
|
|
500
500
|
(!Number.isInteger(t[s]) || t[s] < 1 || t[s] > a) && y(`publication ${s} is outside its bounds`);
|
|
501
501
|
for (const s of ["entityId", "entityName"]) {
|
|
502
|
-
|
|
502
|
+
ie(t[s], s);
|
|
503
503
|
const a = Ee.encode(t[s]).byteLength;
|
|
504
504
|
(a < 1 || a > 256 || /[\u0000-\u001f\u007f]/u.test(t[s])) && y(`${s} must contain 1..256 UTF-8 bytes without controls`);
|
|
505
505
|
}
|
|
506
|
-
return J(
|
|
506
|
+
return J(Rn.map((s) => [s, t[s]]));
|
|
507
507
|
}
|
|
508
|
-
function
|
|
509
|
-
const t =
|
|
510
|
-
return w(t.schemaVersion, 1, "publication signature schemaVersion"), w(t.identityScheme, we, "publication identityScheme"), w(t.algorithm, "ed25519", "publication algorithm"), w(t.encoding, "raw", "publication encoding"), w(t.signatureProfile,
|
|
508
|
+
function xi(e) {
|
|
509
|
+
const t = z(e, On, "SDN publication signature");
|
|
510
|
+
return w(t.schemaVersion, 1, "publication signature schemaVersion"), w(t.identityScheme, we, "publication identityScheme"), w(t.algorithm, "ed25519", "publication algorithm"), w(t.encoding, "raw", "publication encoding"), w(t.signatureProfile, oi, "publication signatureProfile"), F(t.keyId, je, "publication keyId"), F(t.publicKeyHex, te, "publication publicKeyHex"), F(t.signatureHex, rn, "publication signatureHex"), F(t.requestDigestSha256, te, "publication requestDigestSha256"), F(t.challengeId, /^[0-9a-f]{32}$/u, "publication challengeId"), sn(t.challengeBase64url, "publication challengeBase64url"), J(On.map((n) => [n, t[n]]));
|
|
511
511
|
}
|
|
512
|
-
function
|
|
513
|
-
const t =
|
|
512
|
+
function Di(e) {
|
|
513
|
+
const t = z(e, [
|
|
514
514
|
"audience",
|
|
515
515
|
"challengeBase64url",
|
|
516
516
|
"expiresAt",
|
|
@@ -527,26 +527,26 @@ function Dr(e) {
|
|
|
527
527
|
["protocolVersion", 2]
|
|
528
528
|
]);
|
|
529
529
|
}
|
|
530
|
-
function
|
|
531
|
-
const t =
|
|
532
|
-
return w(t.protocolVersion, 1, "activation protocolVersion"), w(t.audience,
|
|
530
|
+
function lr(e) {
|
|
531
|
+
const t = z(e, St, "authority activation request");
|
|
532
|
+
return w(t.protocolVersion, 1, "activation protocolVersion"), w(t.audience, ci, "activation audience"), w(t.requestOrigin, rr, "activation requestOrigin"), w(t.clientId, ir, "activation clientId"), w(t.serviceInstance, "assets.ipfs.01/asset-review-attestation", "activation serviceInstance"), w(t.purpose, "asset-review-authority-activation", "activation purpose"), F(t.nonce, te, "activation nonce"), ve(t.issuedAt, "activation issuedAt"), ve(t.expiresAt, "activation expiresAt"), Dt(t.issuedAt, t.expiresAt), F(t.publicKeyHex, te, "activation publicKeyHex"), F(t.keyId, je, "activation keyId"), w(t.identityScheme, we, "activation identityScheme"), w(t.signatureProfile, ke, "activation signatureProfile"), J(St.map((n) => [n, t[n]]));
|
|
533
533
|
}
|
|
534
534
|
function jt(e, t, n) {
|
|
535
535
|
ut(e, t, `${n} array`);
|
|
536
|
-
const
|
|
536
|
+
const r = Array.from({ length: t }, (i, s) => {
|
|
537
537
|
const a = e[s];
|
|
538
538
|
return (typeof a != "number" || !Number.isFinite(a)) && y(`${n} values must be finite numbers`), a;
|
|
539
539
|
});
|
|
540
|
-
return Ve(
|
|
540
|
+
return Ve(r);
|
|
541
541
|
}
|
|
542
|
-
function
|
|
543
|
-
const t =
|
|
544
|
-
n.some((a) => Math.abs(a) > De.translationComponentAbsMax) && y("translation values exceed the reviewed transform policy"),
|
|
545
|
-
const s = Math.hypot(...
|
|
546
|
-
return Math.abs(s - 1) > De.quaternionNormTolerance && y("rotation must be a unit quaternion within the reviewed tolerance"), ct(t.upAxis, De.upAxes, "upAxis"),
|
|
542
|
+
function Pi(e) {
|
|
543
|
+
const t = z(e, gi, "reviewedTransform"), n = jt(t.translation, 3, "translation"), r = jt(t.rotation, 4, "rotation"), i = jt(t.scale, 3, "scale");
|
|
544
|
+
n.some((a) => Math.abs(a) > De.translationComponentAbsMax) && y("translation values exceed the reviewed transform policy"), i.some((a) => a <= De.scaleComponentExclusiveMin || a > De.scaleComponentInclusiveMax) && y("scale values exceed the reviewed transform policy");
|
|
545
|
+
const s = Math.hypot(...r);
|
|
546
|
+
return Math.abs(s - 1) > De.quaternionNormTolerance && y("rotation must be a unit quaternion within the reviewed tolerance"), ct(t.upAxis, De.upAxes, "upAxis"), ie(t.sourceUnits, "sourceUnits"), Object.hasOwn(De.metersPerSourceUnit, t.sourceUnits) || y("sourceUnits is not allowed by the reviewed transform policy"), (typeof t.metersPerSourceUnit != "number" || !Number.isFinite(t.metersPerSourceUnit) || t.metersPerSourceUnit !== De.metersPerSourceUnit[t.sourceUnits]) && y("metersPerSourceUnit must exactly match sourceUnits"), J([
|
|
547
547
|
["metersPerSourceUnit", t.metersPerSourceUnit],
|
|
548
|
-
["rotation",
|
|
549
|
-
["scale",
|
|
548
|
+
["rotation", r],
|
|
549
|
+
["scale", i],
|
|
550
550
|
["sourceUnits", t.sourceUnits],
|
|
551
551
|
["translation", n],
|
|
552
552
|
["upAxis", t.upAxis]
|
|
@@ -557,67 +557,67 @@ function Ln(e) {
|
|
|
557
557
|
}
|
|
558
558
|
function Nn(e, t, n) {
|
|
559
559
|
if (n && e === null) return null;
|
|
560
|
-
|
|
561
|
-
const
|
|
562
|
-
return (Ln(
|
|
560
|
+
ie(e, t), (e.length === 0 || Ee.encode(e).byteLength > 2e3) && y(`${t} has an invalid length`);
|
|
561
|
+
const r = Array.from(e, (i) => i.codePointAt(0));
|
|
562
|
+
return (Ln(r[0]) || Ln(r[r.length - 1])) && y(`${t} must already be trimmed`), e;
|
|
563
563
|
}
|
|
564
|
-
function
|
|
565
|
-
const t =
|
|
564
|
+
function ur(e) {
|
|
565
|
+
const t = ar(e);
|
|
566
566
|
lt(t) || y("asset review decision request must be a JSON object");
|
|
567
567
|
const n = Object.getOwnPropertyDescriptor(t, "decision");
|
|
568
568
|
(!n || !n.enumerable || !("value" in n) || n.value === void 0) && y("asset review decision request has an invalid decision field");
|
|
569
|
-
const
|
|
570
|
-
w(s.protocolVersion, 1, "decision protocolVersion"), w(s.audience,
|
|
569
|
+
const r = n.value, i = r === "approve" ? ["note", "reviewedTransform"] : r === "disapprove" ? ["reason"] : [], s = z(t, [...zt, ...i], "asset review decision request");
|
|
570
|
+
w(s.protocolVersion, 1, "decision protocolVersion"), w(s.audience, ai, "decision audience"), w(s.requestOrigin, rr, "decision requestOrigin"), w(s.clientId, ir, "decision clientId"), F(s.challengeId, te, "challengeId"), F(s.nonce, te, "decision nonce"), ve(s.issuedAt, "decision issuedAt"), ve(s.expiresAt, "decision expiresAt"), Dt(s.issuedAt, s.expiresAt), F(s.modelSha256, te, "modelSha256"), F(s.metadataSha256, te, "metadataSha256"), s.previousDecisionHead !== null && F(s.previousDecisionHead, te, "previousDecisionHead"), Ii(s.modelCid, s.modelSha256), (!Number.isSafeInteger(s.modelBytes) || s.modelBytes <= 0) && y("modelBytes must be a positive safe integer"), ie(s.candidateKey, "candidateKey");
|
|
571
571
|
const a = "asset-review:", o = `:${s.modelSha256}`;
|
|
572
572
|
(!s.candidateKey.startsWith(a) || !s.candidateKey.endsWith(o) || Ee.encode(s.candidateKey).byteLength > 206) && y("candidateKey does not bind the model digest");
|
|
573
573
|
const c = s.candidateKey.slice(a.length, -o.length);
|
|
574
574
|
(!/^[a-z0-9-]+\/[a-z0-9][a-z0-9-]*$/u.test(c) || Ee.encode(c).byteLength > 128) && y("candidateKey entityId is invalid");
|
|
575
|
-
const l =
|
|
576
|
-
return
|
|
575
|
+
const l = zt.map((u) => [u, s[u]]);
|
|
576
|
+
return r === "approve" ? (l.push(["note", Nn(s.note, "note", !0)]), l.push(["reviewedTransform", Pi(s.reviewedTransform)])) : l.push(["reason", Nn(s.reason, "reason", !1)]), Object.values(s).filter((u) => typeof u == "string").reduce((u, p) => u + Ee.encode(p).byteLength, 0) > 16384 && y("decision request strings exceed 16 KiB"), J(l);
|
|
577
577
|
}
|
|
578
|
-
function
|
|
579
|
-
return
|
|
578
|
+
function dr(e, t) {
|
|
579
|
+
return z(e, [], t), Ve({});
|
|
580
580
|
}
|
|
581
|
-
function
|
|
582
|
-
return
|
|
581
|
+
function ki(e) {
|
|
582
|
+
return dr(e, "wallet connect request");
|
|
583
583
|
}
|
|
584
|
-
function
|
|
585
|
-
return
|
|
584
|
+
function Ui(e) {
|
|
585
|
+
return cr(e, "connect");
|
|
586
586
|
}
|
|
587
|
-
function
|
|
588
|
-
return
|
|
587
|
+
function Bi(e) {
|
|
588
|
+
return dr(e, "wallet account request");
|
|
589
589
|
}
|
|
590
|
-
function
|
|
591
|
-
return
|
|
590
|
+
function fr(e) {
|
|
591
|
+
return cr(e, "account");
|
|
592
592
|
}
|
|
593
|
-
function
|
|
594
|
-
return
|
|
593
|
+
function ji(e) {
|
|
594
|
+
return _i(e);
|
|
595
595
|
}
|
|
596
|
-
function
|
|
597
|
-
return
|
|
596
|
+
function Vi(e) {
|
|
597
|
+
return Ti(e);
|
|
598
598
|
}
|
|
599
|
-
function $
|
|
600
|
-
return
|
|
599
|
+
function $i(e) {
|
|
600
|
+
return Di(e);
|
|
601
601
|
}
|
|
602
|
-
function
|
|
602
|
+
function Mi(e) {
|
|
603
603
|
return an(e, "sdn-login");
|
|
604
604
|
}
|
|
605
|
-
function
|
|
606
|
-
return
|
|
605
|
+
function pr(e) {
|
|
606
|
+
return Ci(e);
|
|
607
607
|
}
|
|
608
|
-
function
|
|
609
|
-
return
|
|
608
|
+
function hr(e) {
|
|
609
|
+
return xi(e);
|
|
610
610
|
}
|
|
611
|
-
function
|
|
612
|
-
return
|
|
611
|
+
function Fi(e) {
|
|
612
|
+
return lr(e);
|
|
613
613
|
}
|
|
614
|
-
function
|
|
614
|
+
function qi(e) {
|
|
615
615
|
return an(e, "asset-review-authority-activation");
|
|
616
616
|
}
|
|
617
|
-
function
|
|
618
|
-
return
|
|
617
|
+
function Wi(e) {
|
|
618
|
+
return ur(e);
|
|
619
619
|
}
|
|
620
|
-
function
|
|
620
|
+
function Hi(e) {
|
|
621
621
|
return an(e, "asset-review-attestation");
|
|
622
622
|
}
|
|
623
623
|
const ce = Object.freeze({
|
|
@@ -626,108 +626,108 @@ const ce = Object.freeze({
|
|
|
626
626
|
batchBytes: 12288,
|
|
627
627
|
fields: 16,
|
|
628
628
|
contextBytes: 256
|
|
629
|
-
}),
|
|
630
|
-
function
|
|
629
|
+
}), zi = /^sdn-field-encryption\/v1\|[A-Za-z0-9_.-]{1,64}\|[A-Za-z0-9_.-]{1,64}\|[A-Za-z0-9_.-]{1,64}\|k[1-9][0-9]{0,8}$/u, Tn = ["ciphertextBase64url", "context", "encBase64url", "fieldId"], Ki = ["fields", "protocolVersion", "replyPublicKeyHex"], _n = ["context", "encBase64url", "kmfBase64url", "protocolVersion", "replyPublicKeyHex"], Gi = ["fields", "replyEphemeralPublicKeyHex", "schemaVersion"], Ji = /^[A-Za-z0-9_-]*$/u;
|
|
630
|
+
function yr(e) {
|
|
631
631
|
let t = "";
|
|
632
632
|
for (let n = 0; n < e.length; n += 1) t += String.fromCharCode(e[n]);
|
|
633
633
|
return globalThis.btoa(t).replace(/\+/gu, "-").replace(/\//gu, "_").replace(/=+$/gu, "");
|
|
634
634
|
}
|
|
635
|
-
function Ue(e, t, n,
|
|
636
|
-
|
|
637
|
-
let
|
|
635
|
+
function Ue(e, t, n, r) {
|
|
636
|
+
ie(e, r), (!Ji.test(e) || e.length % 4 === 1 || e.length > Math.ceil(n * 4 / 3)) && y(`${r} must be canonical unpadded base64url`);
|
|
637
|
+
let i;
|
|
638
638
|
try {
|
|
639
|
-
|
|
639
|
+
i = globalThis.atob(e.replace(/-/gu, "+").replace(/_/gu, "/").padEnd(Math.ceil(e.length / 4) * 4, "="));
|
|
640
640
|
} catch {
|
|
641
|
-
y(`${
|
|
641
|
+
y(`${r} must be valid base64url`);
|
|
642
642
|
}
|
|
643
|
-
const s = Uint8Array.from(
|
|
644
|
-
return (s.length < t || s.length > n ||
|
|
643
|
+
const s = Uint8Array.from(i, (a) => a.charCodeAt(0));
|
|
644
|
+
return (s.length < t || s.length > n || yr(s) !== e) && y(`${r} must canonically encode ${t}..${n} bytes`), s;
|
|
645
645
|
}
|
|
646
|
-
function
|
|
647
|
-
return
|
|
646
|
+
function mr(e, t) {
|
|
647
|
+
return ie(e, t), (Ee.encode(e).byteLength > ce.contextBytes || !zi.test(e)) && y(`${t} must be sdn-field-encryption/v1|<site>|<schema>|<field>|k<version>`), e;
|
|
648
648
|
}
|
|
649
|
-
function
|
|
650
|
-
const t =
|
|
649
|
+
function Yi(e) {
|
|
650
|
+
const t = z(e, Ki, "field-open request");
|
|
651
651
|
w(t.protocolVersion, 1, "field-open protocolVersion"), F(t.replyPublicKeyHex, te, "replyPublicKeyHex"), (!Array.isArray(t.fields) || t.fields.length < 1 || t.fields.length > ce.fields) && y(`field-open request carries 1..${ce.fields} fields`), ut(t.fields, t.fields.length, "field-open fields");
|
|
652
652
|
let n = 0;
|
|
653
|
-
const
|
|
654
|
-
const a =
|
|
655
|
-
return Ue(a.encBase64url, 1, ce.envelopeBytes, `field ${s} encBase64url`), n += Ue(a.ciphertextBase64url, 1, ce.fieldBytes, `field ${s} ciphertextBase64url`).length,
|
|
653
|
+
const r = t.fields.map((i, s) => {
|
|
654
|
+
const a = z(i, Tn, `field ${s}`);
|
|
655
|
+
return Ue(a.encBase64url, 1, ce.envelopeBytes, `field ${s} encBase64url`), n += Ue(a.ciphertextBase64url, 1, ce.fieldBytes, `field ${s} ciphertextBase64url`).length, mr(a.context, `field ${s} context`), (!Number.isInteger(a.fieldId) || a.fieldId < 0 || a.fieldId > 65535) && y(`field ${s} fieldId must be 0..65535`), J(Tn.map((o) => [o, a[o]]));
|
|
656
656
|
});
|
|
657
657
|
return n > ce.batchBytes && y(`field-open ciphertext exceeds ${ce.batchBytes} bytes`), J([
|
|
658
|
-
["fields", Ve(
|
|
658
|
+
["fields", Ve(r)],
|
|
659
659
|
["protocolVersion", 1],
|
|
660
660
|
["replyPublicKeyHex", t.replyPublicKeyHex]
|
|
661
661
|
]);
|
|
662
662
|
}
|
|
663
|
-
function
|
|
664
|
-
const t =
|
|
665
|
-
return w(t.protocolVersion, 1, "key-unwrap protocolVersion"), F(t.replyPublicKeyHex, te, "replyPublicKeyHex"),
|
|
663
|
+
function Qi(e) {
|
|
664
|
+
const t = z(e, _n, "key-unwrap request");
|
|
665
|
+
return w(t.protocolVersion, 1, "key-unwrap protocolVersion"), F(t.replyPublicKeyHex, te, "replyPublicKeyHex"), mr(t.context, "key-unwrap context"), Ue(t.encBase64url, 1, ce.envelopeBytes, "key-unwrap encBase64url"), Ue(t.kmfBase64url, 1, ce.envelopeBytes, "key-unwrap kmfBase64url"), J(_n.map((n) => [n, t[n]]));
|
|
666
666
|
}
|
|
667
|
-
function
|
|
668
|
-
const n =
|
|
667
|
+
function gr(e, t) {
|
|
668
|
+
const n = z(e, Gi, "field result");
|
|
669
669
|
w(n.schemaVersion, 1, "field result schemaVersion"), F(n.replyEphemeralPublicKeyHex, te, "replyEphemeralPublicKeyHex"), (!Array.isArray(n.fields) || n.fields.length < 1 || n.fields.length > t) && y(`field result carries 1..${t} fields`), ut(n.fields, n.fields.length, "field result fields");
|
|
670
|
-
const
|
|
671
|
-
if ((lt(
|
|
672
|
-
const c =
|
|
670
|
+
const r = n.fields.map((i, s) => {
|
|
671
|
+
if ((lt(i) ? i.status : void 0) === "opened") {
|
|
672
|
+
const c = z(i, ["ciphertextBase64url", "status"], `field result ${s}`);
|
|
673
673
|
return Ue(c.ciphertextBase64url, 1, ce.fieldBytes, `field result ${s} ciphertext`), J([["ciphertextBase64url", c.ciphertextBase64url], ["status", "opened"]]);
|
|
674
674
|
}
|
|
675
|
-
const o =
|
|
675
|
+
const o = z(i, ["reason", "status"], `field result ${s}`);
|
|
676
676
|
return w(o.status, "refused", `field result ${s} status`), w(o.reason, "NOT_ADDRESSED_TO_ACCOUNT", `field result ${s} reason`), J([["reason", "NOT_ADDRESSED_TO_ACCOUNT"], ["status", "refused"]]);
|
|
677
677
|
});
|
|
678
678
|
return J([
|
|
679
|
-
["fields", Ve(
|
|
679
|
+
["fields", Ve(r)],
|
|
680
680
|
["replyEphemeralPublicKeyHex", n.replyEphemeralPublicKeyHex],
|
|
681
681
|
["schemaVersion", 1]
|
|
682
682
|
]);
|
|
683
683
|
}
|
|
684
|
-
function
|
|
685
|
-
return
|
|
684
|
+
function Xi(e) {
|
|
685
|
+
return Yi(e);
|
|
686
686
|
}
|
|
687
|
-
function
|
|
688
|
-
return
|
|
687
|
+
function Zi(e) {
|
|
688
|
+
return gr(e, ce.fields);
|
|
689
689
|
}
|
|
690
690
|
function es(e) {
|
|
691
|
-
return
|
|
691
|
+
return Qi(e);
|
|
692
692
|
}
|
|
693
693
|
function ts(e) {
|
|
694
|
-
return
|
|
694
|
+
return gr(e, 1);
|
|
695
695
|
}
|
|
696
696
|
const ns = new TextDecoder("utf-8", { fatal: !0 });
|
|
697
|
-
class
|
|
697
|
+
class Ar extends Error {
|
|
698
698
|
constructor() {
|
|
699
699
|
super("MALFORMED_ENVELOPE"), this.name = "SealedEnvelopeError", this.code = "MALFORMED_ENVELOPE";
|
|
700
700
|
}
|
|
701
701
|
}
|
|
702
702
|
function de() {
|
|
703
|
-
throw new
|
|
703
|
+
throw new Ar();
|
|
704
704
|
}
|
|
705
|
-
function
|
|
705
|
+
function br(e, t) {
|
|
706
706
|
(!(e instanceof Uint8Array) || e.length < 12) && de();
|
|
707
707
|
const n = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
708
708
|
for (let c = 0; c < 4; c += 1)
|
|
709
709
|
e[4 + c] !== t.charCodeAt(c) && de();
|
|
710
|
-
const
|
|
711
|
-
(
|
|
712
|
-
const
|
|
713
|
-
(
|
|
714
|
-
const s = n.getUint16(
|
|
715
|
-
(s < 4 || s % 2 !== 0 ||
|
|
710
|
+
const r = n.getUint32(0, !0);
|
|
711
|
+
(r < 8 || r + 4 > e.length) && de();
|
|
712
|
+
const i = r - n.getInt32(r, !0);
|
|
713
|
+
(i < 0 || i + 4 > e.length) && de();
|
|
714
|
+
const s = n.getUint16(i, !0), a = n.getUint16(i + 2, !0);
|
|
715
|
+
(s < 4 || s % 2 !== 0 || i + s > e.length || a < 4 || r + a > e.length) && de();
|
|
716
716
|
const o = (c) => {
|
|
717
717
|
const l = 4 + c * 2;
|
|
718
718
|
if (l >= s) return 0;
|
|
719
|
-
const d = n.getUint16(
|
|
719
|
+
const d = n.getUint16(i + l, !0);
|
|
720
720
|
return d !== 0 && (d < 4 || d >= a) && de(), d;
|
|
721
721
|
};
|
|
722
722
|
return {
|
|
723
723
|
scalar(c, l) {
|
|
724
724
|
const d = o(c);
|
|
725
|
-
return d === 0 ? l : e[
|
|
725
|
+
return d === 0 ? l : e[r + d];
|
|
726
726
|
},
|
|
727
727
|
vector(c) {
|
|
728
728
|
const l = o(c);
|
|
729
729
|
if (l === 0) return null;
|
|
730
|
-
const d =
|
|
730
|
+
const d = r + l;
|
|
731
731
|
d + 4 > e.length && de();
|
|
732
732
|
const u = d + n.getUint32(d, !0);
|
|
733
733
|
u + 4 > e.length && de();
|
|
@@ -736,36 +736,36 @@ function bi(e, t) {
|
|
|
736
736
|
}
|
|
737
737
|
};
|
|
738
738
|
}
|
|
739
|
-
function
|
|
740
|
-
const t =
|
|
739
|
+
function rs(e) {
|
|
740
|
+
const t = br(e, "$ENC");
|
|
741
741
|
(t.scalar(0, 1) !== 1 || t.scalar(1, 0) !== 0 || t.scalar(2, 0) !== 0 || t.scalar(3, 0) !== 0) && de();
|
|
742
|
-
const n = t.vector(4),
|
|
743
|
-
(n?.length !== 32 ||
|
|
742
|
+
const n = t.vector(4), r = t.vector(5), i = t.vector(6), s = t.vector(7);
|
|
743
|
+
(n?.length !== 32 || r?.length !== 12 || i?.length !== 8 || !s || s.length === 0) && de();
|
|
744
744
|
let a;
|
|
745
745
|
try {
|
|
746
746
|
a = ns.decode(s);
|
|
747
747
|
} catch {
|
|
748
748
|
de();
|
|
749
749
|
}
|
|
750
|
-
return Object.freeze({ context: a, ephemeralPublic: n, recipientKeyId:
|
|
750
|
+
return Object.freeze({ context: a, ephemeralPublic: n, recipientKeyId: i });
|
|
751
751
|
}
|
|
752
|
-
function
|
|
753
|
-
const t =
|
|
752
|
+
function is(e) {
|
|
753
|
+
const t = br(e, "$KMF").vector(4);
|
|
754
754
|
return t?.length !== 32 && de(), t;
|
|
755
755
|
}
|
|
756
|
-
const Gt = "sdn.wallet.consent.v1", cn = 15 * 60 * 1e3,
|
|
756
|
+
const Gt = "sdn.wallet.consent.v1", cn = 15 * 60 * 1e3, Er = 20, Cn = 16;
|
|
757
757
|
function xn(e, t) {
|
|
758
758
|
let n = {};
|
|
759
759
|
try {
|
|
760
|
-
const
|
|
761
|
-
|
|
760
|
+
const i = JSON.parse(e?.getItem?.(Gt) ?? "{}");
|
|
761
|
+
i && typeof i == "object" && !Array.isArray(i) && (n = i);
|
|
762
762
|
} catch {
|
|
763
763
|
n = {};
|
|
764
764
|
}
|
|
765
|
-
const
|
|
766
|
-
for (const [
|
|
767
|
-
Number.isSafeInteger(s?.expiresAt) && s.expiresAt > t && s.expiresAt - t <= cn && Number.isSafeInteger(s?.remaining) && s.remaining > 0 && s.remaining <=
|
|
768
|
-
return
|
|
765
|
+
const r = {};
|
|
766
|
+
for (const [i, s] of Object.entries(n))
|
|
767
|
+
Number.isSafeInteger(s?.expiresAt) && s.expiresAt > t && s.expiresAt - t <= cn && Number.isSafeInteger(s?.remaining) && s.remaining > 0 && s.remaining <= Er && (r[i] = { expiresAt: s.expiresAt, remaining: s.remaining });
|
|
768
|
+
return r;
|
|
769
769
|
}
|
|
770
770
|
function Vt(e, t) {
|
|
771
771
|
try {
|
|
@@ -777,7 +777,7 @@ function Vt(e, t) {
|
|
|
777
777
|
function ss(e, t) {
|
|
778
778
|
if (e?.operation !== "sdn.wallet.field-open.v1" && e?.operation !== "sdn.wallet.key-unwrap.v1")
|
|
779
779
|
return null;
|
|
780
|
-
const n = t?.keys?.find?.((
|
|
780
|
+
const n = t?.keys?.find?.((r) => r?.purpose === "contact-encryption");
|
|
781
781
|
return typeof n?.keyId != "string" ? null : [e.clientId, e.requestOrigin, e.operation, n.keyId].join("|");
|
|
782
782
|
}
|
|
783
783
|
function os({ storage: e, now: t = () => Date.now() }) {
|
|
@@ -785,19 +785,19 @@ function os({ storage: e, now: t = () => Date.now() }) {
|
|
|
785
785
|
/** Uses one unattended opening of a live grant; false means ask. */
|
|
786
786
|
take(n) {
|
|
787
787
|
if (!n) return !1;
|
|
788
|
-
const
|
|
789
|
-
return
|
|
788
|
+
const r = xn(e, t()), i = r[n];
|
|
789
|
+
return i ? (i.remaining -= 1, i.remaining === 0 && delete r[n], Vt(e, r)) : !1;
|
|
790
790
|
},
|
|
791
791
|
grant(n) {
|
|
792
792
|
if (!n) return;
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
const s = Object.keys(
|
|
793
|
+
const r = t(), i = xn(e, r);
|
|
794
|
+
i[n] = { expiresAt: r + cn, remaining: Er };
|
|
795
|
+
const s = Object.keys(i);
|
|
796
796
|
if (s.length > Cn) {
|
|
797
|
-
s.sort((a, o) =>
|
|
798
|
-
for (const a of s.slice(0, s.length - Cn)) delete
|
|
797
|
+
s.sort((a, o) => i[a].expiresAt - i[o].expiresAt);
|
|
798
|
+
for (const a of s.slice(0, s.length - Cn)) delete i[a];
|
|
799
799
|
}
|
|
800
|
-
Vt(e,
|
|
800
|
+
Vt(e, i);
|
|
801
801
|
},
|
|
802
802
|
clear() {
|
|
803
803
|
Vt(e, {});
|
|
@@ -818,53 +818,53 @@ const as = Object.freeze([
|
|
|
818
818
|
"schemaVersion",
|
|
819
819
|
"state",
|
|
820
820
|
"transactionId"
|
|
821
|
-
]), gt = /^[0-9a-f]{64}$/u,
|
|
821
|
+
]), gt = /^[0-9a-f]{64}$/u, wr = /^[A-Za-z0-9_-]{43}$/u, cs = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u, ls = new TextEncoder(), Ir = Object.freeze({
|
|
822
822
|
"sdn.auth.publish-request.v1": Object.freeze({
|
|
823
|
-
parseRequest:
|
|
824
|
-
buildResult:
|
|
823
|
+
parseRequest: pr,
|
|
824
|
+
buildResult: hr,
|
|
825
825
|
publish: !0
|
|
826
826
|
}),
|
|
827
827
|
"sdn.auth.jcs-envelope.v2": Object.freeze({
|
|
828
|
-
parseRequest: $
|
|
829
|
-
buildResult:
|
|
830
|
-
sign(e, t, n,
|
|
831
|
-
return e.signSdnLoginV2(t, n,
|
|
828
|
+
parseRequest: $i,
|
|
829
|
+
buildResult: Mi,
|
|
830
|
+
sign(e, t, n, r) {
|
|
831
|
+
return e.signSdnLoginV2(t, n, r.registryRow);
|
|
832
832
|
}
|
|
833
833
|
}),
|
|
834
834
|
"sdn.auth.raw-challenge.v1": Object.freeze({
|
|
835
|
-
parseRequest:
|
|
836
|
-
buildResult:
|
|
835
|
+
parseRequest: ji,
|
|
836
|
+
buildResult: Vi,
|
|
837
837
|
sign(e, t, n) {
|
|
838
838
|
return e.signSdnLoginV1(t, gs(n.challengeBase64url));
|
|
839
839
|
}
|
|
840
840
|
}),
|
|
841
841
|
"sdn.asset-review.authority-activation.v1": Object.freeze({
|
|
842
|
-
parseRequest:
|
|
843
|
-
buildResult:
|
|
844
|
-
sign(e, t, n,
|
|
845
|
-
return e.signAssetReviewAuthorityActivation(t, n,
|
|
842
|
+
parseRequest: Fi,
|
|
843
|
+
buildResult: qi,
|
|
844
|
+
sign(e, t, n, r) {
|
|
845
|
+
return e.signAssetReviewAuthorityActivation(t, n, r.registryRow);
|
|
846
846
|
}
|
|
847
847
|
}),
|
|
848
848
|
"sdn.asset-review.decision.v1": Object.freeze({
|
|
849
|
-
parseRequest:
|
|
850
|
-
buildResult:
|
|
851
|
-
sign(e, t, n,
|
|
852
|
-
return e.signAssetReviewDecision(t, n,
|
|
849
|
+
parseRequest: Wi,
|
|
850
|
+
buildResult: Hi,
|
|
851
|
+
sign(e, t, n, r) {
|
|
852
|
+
return e.signAssetReviewDecision(t, n, r.registryRow);
|
|
853
853
|
}
|
|
854
854
|
}),
|
|
855
855
|
"sdn.wallet.account.v1": Object.freeze({
|
|
856
|
-
parseRequest:
|
|
857
|
-
buildResult:
|
|
856
|
+
parseRequest: Bi,
|
|
857
|
+
buildResult: fr,
|
|
858
858
|
connect: !0
|
|
859
859
|
}),
|
|
860
860
|
"sdn.wallet.connect.v1": Object.freeze({
|
|
861
|
-
parseRequest:
|
|
862
|
-
buildResult:
|
|
861
|
+
parseRequest: ki,
|
|
862
|
+
buildResult: Ui,
|
|
863
863
|
connect: !0
|
|
864
864
|
}),
|
|
865
865
|
"sdn.wallet.field-open.v1": Object.freeze({
|
|
866
|
-
parseRequest:
|
|
867
|
-
buildResult:
|
|
866
|
+
parseRequest: Xi,
|
|
867
|
+
buildResult: Zi,
|
|
868
868
|
bindRequest: (e, t) => e.fields.map((n) => Dn(n.encBase64url, n.context, n.fieldId, n.ciphertextBase64url, t))
|
|
869
869
|
}),
|
|
870
870
|
"sdn.wallet.key-unwrap.v1": Object.freeze({
|
|
@@ -880,21 +880,21 @@ const as = Object.freeze([
|
|
|
880
880
|
)]
|
|
881
881
|
})
|
|
882
882
|
}), us = 4;
|
|
883
|
-
function Dn(e, t, n,
|
|
883
|
+
function Dn(e, t, n, r, i, s = !1) {
|
|
884
884
|
let a, o;
|
|
885
885
|
try {
|
|
886
|
-
a =
|
|
886
|
+
a = rs(Ue(e, 1, ce.envelopeBytes, "enc"));
|
|
887
887
|
const c = Ue(
|
|
888
|
-
|
|
888
|
+
r,
|
|
889
889
|
1,
|
|
890
890
|
s ? ce.envelopeBytes : ce.fieldBytes,
|
|
891
891
|
"payload"
|
|
892
892
|
);
|
|
893
|
-
o = s ?
|
|
893
|
+
o = s ? is(c) : c;
|
|
894
894
|
} catch (c) {
|
|
895
|
-
c instanceof
|
|
895
|
+
c instanceof Ar && L("MALFORMED_ENVELOPE"), L("INVALID_TRANSACTION");
|
|
896
896
|
}
|
|
897
|
-
return a.context !== t && L("MALFORMED_ENVELOPE"), (typeof
|
|
897
|
+
return a.context !== t && L("MALFORMED_ENVELOPE"), (typeof i?.audience != "string" || !t.startsWith(`${i.audience}|`)) && L("FIELD_SITE_MISMATCH"), Object.freeze({
|
|
898
898
|
ciphertext: o,
|
|
899
899
|
context: t,
|
|
900
900
|
ephemeralPublic: a.ephemeralPublic,
|
|
@@ -908,14 +908,14 @@ function ds(e) {
|
|
|
908
908
|
function fs(e) {
|
|
909
909
|
return Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
|
|
910
910
|
}
|
|
911
|
-
function ps(e, t, n,
|
|
911
|
+
function ps(e, t, n, r, i) {
|
|
912
912
|
typeof e.openSealedFields != "function" && L("OPERATION_NOT_ALLOWED");
|
|
913
|
-
const s =
|
|
913
|
+
const s = i.bindRequest(n, r), a = e.openSealedFields(t, {
|
|
914
914
|
fields: s.map((o) => ({ ...o })),
|
|
915
915
|
replyPublic: ds(n.replyPublicKeyHex)
|
|
916
|
-
},
|
|
917
|
-
return
|
|
918
|
-
fields: a.fields.map((o) => o.opened ? { ciphertextBase64url:
|
|
916
|
+
}, r.registryRow);
|
|
917
|
+
return i.buildResult({
|
|
918
|
+
fields: a.fields.map((o) => o.opened ? { ciphertextBase64url: yr(o.ciphertext), status: "opened" } : { reason: "NOT_ADDRESSED_TO_ACCOUNT", status: "refused" }),
|
|
919
919
|
replyEphemeralPublicKeyHex: fs(a.ephemeralPublic),
|
|
920
920
|
schemaVersion: 1
|
|
921
921
|
});
|
|
@@ -935,17 +935,17 @@ function ln(e) {
|
|
|
935
935
|
}
|
|
936
936
|
function Jt(e, t, n = "INVALID_TRANSACTION") {
|
|
937
937
|
ln(e) || L(n);
|
|
938
|
-
let
|
|
938
|
+
let r;
|
|
939
939
|
try {
|
|
940
|
-
|
|
940
|
+
r = Reflect.ownKeys(e);
|
|
941
941
|
} catch {
|
|
942
942
|
L(n);
|
|
943
943
|
}
|
|
944
|
-
|
|
945
|
-
const
|
|
946
|
-
(
|
|
944
|
+
r.some((o) => typeof o != "string") && L(n);
|
|
945
|
+
const i = [...r].sort(), s = [...t].sort();
|
|
946
|
+
(i.length !== s.length || i.some((o, c) => o !== s[c])) && L(n);
|
|
947
947
|
const a = /* @__PURE__ */ Object.create(null);
|
|
948
|
-
for (const o of
|
|
948
|
+
for (const o of i) {
|
|
949
949
|
let c;
|
|
950
950
|
try {
|
|
951
951
|
c = Object.getOwnPropertyDescriptor(e, o);
|
|
@@ -961,11 +961,11 @@ function At(e, t = "INVALID_TRANSACTION") {
|
|
|
961
961
|
const n = Date.parse(e);
|
|
962
962
|
return (!Number.isFinite(n) || new Date(n).toISOString() !== e) && L(t), n;
|
|
963
963
|
}
|
|
964
|
-
function
|
|
965
|
-
if (Array.isArray(e)) return Object.freeze(e.map(
|
|
964
|
+
function it(e) {
|
|
965
|
+
if (Array.isArray(e)) return Object.freeze(e.map(it));
|
|
966
966
|
if (!ln(e)) return e;
|
|
967
967
|
const t = {};
|
|
968
|
-
for (const n of Object.keys(e).sort()) t[n] =
|
|
968
|
+
for (const n of Object.keys(e).sort()) t[n] = it(e[n]);
|
|
969
969
|
return Object.freeze(t);
|
|
970
970
|
}
|
|
971
971
|
function Yt(e) {
|
|
@@ -979,15 +979,15 @@ async function hs(e, t) {
|
|
|
979
979
|
} catch {
|
|
980
980
|
L("CRYPTO_UNAVAILABLE");
|
|
981
981
|
}
|
|
982
|
-
return (!(n instanceof Uint8Array) || n.byteLength !== 32) && L("CRYPTO_UNAVAILABLE"), Array.from(n, (
|
|
982
|
+
return (!(n instanceof Uint8Array) || n.byteLength !== 32) && L("CRYPTO_UNAVAILABLE"), Array.from(n, (r) => r.toString(16).padStart(2, "0")).join("");
|
|
983
983
|
}
|
|
984
984
|
function ys(e, t) {
|
|
985
985
|
if (typeof e != "string" || typeof t != "string") return !1;
|
|
986
986
|
const n = Math.max(e.length, t.length);
|
|
987
|
-
let
|
|
988
|
-
for (let
|
|
989
|
-
|
|
990
|
-
return
|
|
987
|
+
let r = e.length ^ t.length;
|
|
988
|
+
for (let i = 0; i < n; i += 1)
|
|
989
|
+
r |= (e.charCodeAt(i) || 0) ^ (t.charCodeAt(i) || 0);
|
|
990
|
+
return r === 0;
|
|
991
991
|
}
|
|
992
992
|
function ms(e, t) {
|
|
993
993
|
try {
|
|
@@ -1013,14 +1013,14 @@ function ue({ document: e, window: t }) {
|
|
|
1013
1013
|
async function $t(e, {
|
|
1014
1014
|
registry: t,
|
|
1015
1015
|
relay: n,
|
|
1016
|
-
sha256:
|
|
1017
|
-
window:
|
|
1016
|
+
sha256: r,
|
|
1017
|
+
window: i,
|
|
1018
1018
|
now: s = () => Date.now(),
|
|
1019
1019
|
expectedTransactionId: a = null
|
|
1020
1020
|
}) {
|
|
1021
1021
|
const o = Jt(e, as);
|
|
1022
|
-
(o.schemaVersion !== 1 || typeof o.clientDisplayName != "string" || o.clientDisplayName.length < 1 || o.clientDisplayName.length > 80 || !gt.test(o.transactionId) || !gt.test(o.state) || !gt.test(o.requestSha256) || !
|
|
1023
|
-
const c =
|
|
1022
|
+
(o.schemaVersion !== 1 || typeof o.clientDisplayName != "string" || o.clientDisplayName.length < 1 || o.clientDisplayName.length > 80 || !gt.test(o.transactionId) || !gt.test(o.state) || !gt.test(o.requestSha256) || !wr.test(o.resultToken)) && L("INVALID_TRANSACTION"), a !== null && o.transactionId !== a && L("INVALID_TRANSACTION");
|
|
1023
|
+
const c = Ir[o.operation];
|
|
1024
1024
|
c || L("UNREGISTERED_TRANSACTION");
|
|
1025
1025
|
const l = ms(t, {
|
|
1026
1026
|
clientId: o.clientId,
|
|
@@ -1039,7 +1039,7 @@ async function $t(e, {
|
|
|
1039
1039
|
c.bindRequest && c.bindRequest(p, l);
|
|
1040
1040
|
let f;
|
|
1041
1041
|
try {
|
|
1042
|
-
f = await hs(p,
|
|
1042
|
+
f = await hs(p, r);
|
|
1043
1043
|
} catch (b) {
|
|
1044
1044
|
if (b instanceof Ie) throw b;
|
|
1045
1045
|
L("CRYPTO_UNAVAILABLE");
|
|
@@ -1047,30 +1047,30 @@ async function $t(e, {
|
|
|
1047
1047
|
ys(f, o.requestSha256) || L("REQUEST_HASH_MISMATCH");
|
|
1048
1048
|
const A = { ...o, request: p };
|
|
1049
1049
|
return Object.freeze({
|
|
1050
|
-
binding:
|
|
1050
|
+
binding: it(l),
|
|
1051
1051
|
operation: c,
|
|
1052
|
-
request:
|
|
1053
|
-
transaction:
|
|
1052
|
+
request: it(p),
|
|
1053
|
+
transaction: it(A)
|
|
1054
1054
|
});
|
|
1055
1055
|
}
|
|
1056
1056
|
function gs(e) {
|
|
1057
|
-
|
|
1057
|
+
wr.test(e) || L("INVALID_TRANSACTION");
|
|
1058
1058
|
let t;
|
|
1059
1059
|
try {
|
|
1060
1060
|
t = globalThis.atob(`${e.replace(/-/gu, "+").replace(/_/gu, "/")}=`);
|
|
1061
1061
|
} catch {
|
|
1062
1062
|
L("INVALID_TRANSACTION");
|
|
1063
1063
|
}
|
|
1064
|
-
const n = Uint8Array.from(t, (
|
|
1064
|
+
const n = Uint8Array.from(t, (r) => r.charCodeAt(0));
|
|
1065
1065
|
return n.byteLength !== 32 && L("INVALID_TRANSACTION"), n;
|
|
1066
1066
|
}
|
|
1067
|
-
function As(e, t, n,
|
|
1068
|
-
const
|
|
1069
|
-
|
|
1067
|
+
function As(e, t, n, r) {
|
|
1068
|
+
const i = e.createElement("div");
|
|
1069
|
+
i.className = "wallet-confirmation-row";
|
|
1070
1070
|
const s = e.createElement("strong");
|
|
1071
1071
|
s.textContent = n;
|
|
1072
1072
|
const a = e.createElement("span");
|
|
1073
|
-
a.textContent =
|
|
1073
|
+
a.textContent = r, i.append(s, a), t.append(i);
|
|
1074
1074
|
}
|
|
1075
1075
|
function Pn(e) {
|
|
1076
1076
|
try {
|
|
@@ -1080,8 +1080,8 @@ function Pn(e) {
|
|
|
1080
1080
|
}
|
|
1081
1081
|
}
|
|
1082
1082
|
const kn = "The site sees your public key and address. It cannot spend or sign anything without asking you.";
|
|
1083
|
-
function
|
|
1084
|
-
const n = Pn(e.requestOrigin),
|
|
1083
|
+
function vr(e, t = {}) {
|
|
1084
|
+
const n = Pn(e.requestOrigin), r = String(e.clientDisplayName ?? "").trim(), i = r || n, s = r && n && r !== n ? [["Site", n]] : [], a = (o, c, l, d = []) => ({
|
|
1085
1085
|
title: o,
|
|
1086
1086
|
detail: c,
|
|
1087
1087
|
action: l,
|
|
@@ -1090,11 +1090,11 @@ function vi(e, t = {}) {
|
|
|
1090
1090
|
switch (e.operation) {
|
|
1091
1091
|
case "sdn.auth.raw-challenge.v1":
|
|
1092
1092
|
case "sdn.auth.jcs-envelope.v2":
|
|
1093
|
-
return a(`Sign in to ${
|
|
1093
|
+
return a(`Sign in to ${i}`, "This proves you hold this wallet. Nothing is paid, sent or shared.", "Sign in");
|
|
1094
1094
|
case "sdn.wallet.connect.v1":
|
|
1095
|
-
return a(`Connect your wallet to ${
|
|
1095
|
+
return a(`Connect your wallet to ${i}`, kn, "Connect");
|
|
1096
1096
|
case "sdn.wallet.account.v1":
|
|
1097
|
-
return a(`Share your account with ${
|
|
1097
|
+
return a(`Share your account with ${i}`, kn, "Share");
|
|
1098
1098
|
case "sdn.auth.publish-request.v1":
|
|
1099
1099
|
return a(`Publish to ${Pn(t.providerOrigin)}`, "One signed publication of exactly this data. It grants no session and no later writes.", "Publish", [
|
|
1100
1100
|
["Provider", t.providerOrigin],
|
|
@@ -1103,10 +1103,10 @@ function vi(e, t = {}) {
|
|
|
1103
1103
|
["Documents", t.documentCount]
|
|
1104
1104
|
]);
|
|
1105
1105
|
case "sdn.asset-review.authority-activation.v1":
|
|
1106
|
-
return a("Activate asset review", `Your key becomes the asset reviewer ${
|
|
1106
|
+
return a("Activate asset review", `Your key becomes the asset reviewer ${i} accepts.`, "Activate");
|
|
1107
1107
|
case "sdn.asset-review.decision.v1": {
|
|
1108
1108
|
const o = t.decision !== "disapprove";
|
|
1109
|
-
return a(o ? "Approve this model" : "Disapprove this model", `Your decision is signed and published by ${
|
|
1109
|
+
return a(o ? "Approve this model" : "Disapprove this model", `Your decision is signed and published by ${i}.`, o ? "Approve" : "Disapprove", [
|
|
1110
1110
|
["Model", String(t.candidateKey ?? "").replace(/^asset-review:/u, "").replace(/:[0-9a-f]{64}$/u, "")],
|
|
1111
1111
|
["Note", t.note]
|
|
1112
1112
|
]);
|
|
@@ -1114,7 +1114,7 @@ function vi(e, t = {}) {
|
|
|
1114
1114
|
case "sdn.wallet.field-open.v1": {
|
|
1115
1115
|
const o = Array.isArray(t.fields) ? t.fields.length : 0;
|
|
1116
1116
|
return a(
|
|
1117
|
-
`Open ${o} encrypted ${o === 1 ? "field" : "fields"} for ${
|
|
1117
|
+
`Open ${o} encrypted ${o === 1 ? "field" : "fields"} for ${i}`,
|
|
1118
1118
|
"Your wallet decrypts fields sealed to your encryption key for this site and gives the site their contents. Your keys stay in the wallet.",
|
|
1119
1119
|
"Open",
|
|
1120
1120
|
[["Fields", o]]
|
|
@@ -1122,31 +1122,31 @@ function vi(e, t = {}) {
|
|
|
1122
1122
|
}
|
|
1123
1123
|
case "sdn.wallet.key-unwrap.v1":
|
|
1124
1124
|
return a(
|
|
1125
|
-
`Reopen a database for ${
|
|
1125
|
+
`Reopen a database for ${i}`,
|
|
1126
1126
|
"Your wallet unwraps the key of this one database, sealed to your encryption key for this site, and gives that key to the site. Your wallet keys stay in the wallet.",
|
|
1127
1127
|
"Reopen",
|
|
1128
1128
|
[["Database", String(t.context ?? "").split("|")[2]]]
|
|
1129
1129
|
);
|
|
1130
1130
|
default:
|
|
1131
|
-
return a(`Confirm a request from ${
|
|
1131
|
+
return a(`Confirm a request from ${i}`, "", "Confirm");
|
|
1132
1132
|
}
|
|
1133
1133
|
}
|
|
1134
|
-
function bs(e, { binding: t, document: n, request:
|
|
1135
|
-
const
|
|
1134
|
+
function bs(e, { binding: t, document: n, request: r }) {
|
|
1135
|
+
const i = vr(t, r ?? {});
|
|
1136
1136
|
e.replaceChildren();
|
|
1137
1137
|
const s = n.createElement("h1");
|
|
1138
|
-
if (s.id = "wallet-confirmation-heading", s.textContent =
|
|
1138
|
+
if (s.id = "wallet-confirmation-heading", s.textContent = i.title, e.append(s), i.detail) {
|
|
1139
1139
|
const a = n.createElement("p");
|
|
1140
|
-
a.className = "wallet-confirmation-detail", a.textContent =
|
|
1140
|
+
a.className = "wallet-confirmation-detail", a.textContent = i.detail, e.append(a);
|
|
1141
1141
|
}
|
|
1142
|
-
for (const [a, o] of
|
|
1142
|
+
for (const [a, o] of i.facts) As(n, e, a, String(o));
|
|
1143
1143
|
return e;
|
|
1144
1144
|
}
|
|
1145
|
-
async function Es({ assertCurrent: e, binding: t, capabilities: n, handle:
|
|
1146
|
-
const a =
|
|
1147
|
-
(t.clientId !== "spaceaware-web-v1" || t.requestOrigin !== "https://spaceaware.io" || t.registryRow !== "spaceaware-publish-request-v1" || typeof n.signSdnPublishRequest != "function" ||
|
|
1148
|
-
const o =
|
|
1149
|
-
(o.length !== 1 || o[0].identityScheme !==
|
|
1145
|
+
async function Es({ assertCurrent: e, binding: t, capabilities: n, handle: r, identity: i, transaction: s }) {
|
|
1146
|
+
const a = pr(s.request);
|
|
1147
|
+
(t.clientId !== "spaceaware-web-v1" || t.requestOrigin !== "https://spaceaware.io" || t.registryRow !== "spaceaware-publish-request-v1" || typeof n.signSdnPublishRequest != "function" || i?.identityScheme !== "sdn-bip32-slip10-purpose-v1" || i?.seedProfile !== "password-scrypt-v2") && L("OPERATION_NOT_ALLOWED");
|
|
1148
|
+
const o = i.keys?.filter((m) => m?.purpose === "sdn-authentication") ?? [];
|
|
1149
|
+
(o.length !== 1 || o[0].identityScheme !== i.identityScheme || o[0].seedProfile !== i.seedProfile || o[0].curve !== "ed25519" || !gt.test(o[0].publicKeyHex) || !/^sha256:[0-9a-f]{64}$/u.test(o[0].keyId)) && L("OPERATION_NOT_ALLOWED");
|
|
1150
1150
|
const { publicKeyHex: c, keyId: l } = o[0], d = `${a.providerOrigin}/api/auth/challenge`, u = new AbortController(), p = setTimeout(() => u.abort(), 1e4);
|
|
1151
1151
|
let f;
|
|
1152
1152
|
try {
|
|
@@ -1181,8 +1181,8 @@ async function Es({ assertCurrent: e, binding: t, capabilities: n, handle: i, id
|
|
|
1181
1181
|
for (const W of S)
|
|
1182
1182
|
U.set(W, P), P += W.byteLength;
|
|
1183
1183
|
f = Jt(JSON.parse(new TextDecoder("utf-8", { fatal: !0 }).decode(U)), ["challenge_id", "challenge", "expires_at"], "PROVIDER_CHALLENGE_FAILED"), (!/^[0-9a-f]{32}$/u.test(f.challenge_id) || !/^[A-Za-z0-9+/]{43}$/u.test(f.challenge) || !Number.isSafeInteger(f.expires_at) || f.expires_at * 1e3 <= Date.now() || f.expires_at * 1e3 - Date.now() > 3e5) && L("PROVIDER_CHALLENGE_FAILED");
|
|
1184
|
-
const
|
|
1185
|
-
(
|
|
1184
|
+
const O = globalThis.atob(`${f.challenge}=`);
|
|
1185
|
+
(O.length !== 32 || globalThis.btoa(O).replace(/=+$/u, "") !== f.challenge) && L("PROVIDER_CHALLENGE_FAILED");
|
|
1186
1186
|
} catch (m) {
|
|
1187
1187
|
if (e(), m instanceof Ie) throw m;
|
|
1188
1188
|
L("PROVIDER_CHALLENGE_FAILED");
|
|
@@ -1191,27 +1191,27 @@ async function Es({ assertCurrent: e, binding: t, capabilities: n, handle: i, id
|
|
|
1191
1191
|
}
|
|
1192
1192
|
const A = f.challenge.replace(/\+/gu, "-").replace(/\//gu, "_").replace(/=+$/u, "");
|
|
1193
1193
|
e(), (Date.now() >= At(s.expiresAt) || f.expires_at * 1e3 <= Date.now()) && L("TRANSACTION_EXPIRED");
|
|
1194
|
-
const b = await n.signSdnPublishRequest(
|
|
1194
|
+
const b = await n.signSdnPublishRequest(r, {
|
|
1195
1195
|
...a,
|
|
1196
1196
|
challengeId: f.challenge_id,
|
|
1197
1197
|
challengeBase64url: A
|
|
1198
1198
|
}, t.registryRow);
|
|
1199
1199
|
e(), (Date.now() >= At(s.expiresAt) || f.expires_at * 1e3 <= Date.now()) && L("TRANSACTION_EXPIRED");
|
|
1200
1200
|
const h = Jt(b, ["schemaVersion", "keyId", "identityScheme", "algorithm", "encoding", "signatureProfile", "publicKeyHex", "signatureHex", "requestDigestSha256"], "INVALID_WALLET_RESULT");
|
|
1201
|
-
return (h.keyId !== l || h.publicKeyHex !== c) && L("INVALID_WALLET_RESULT"),
|
|
1201
|
+
return (h.keyId !== l || h.publicKeyHex !== c) && L("INVALID_WALLET_RESULT"), hr({ ...h, challengeId: f.challenge_id, challengeBase64url: A });
|
|
1202
1202
|
}
|
|
1203
|
-
function ws({ binding: e, document: t, request: n, offerRemember:
|
|
1204
|
-
const
|
|
1203
|
+
function ws({ binding: e, document: t, request: n, offerRemember: r = !1 }) {
|
|
1204
|
+
const i = t.activeElement ?? null, s = t.createElement("section");
|
|
1205
1205
|
s.className = "wallet-confirmation", s.setAttribute?.("role", "dialog"), s.setAttribute?.("aria-modal", "true"), s.setAttribute?.("aria-labelledby", "wallet-confirmation-heading"), s.tabIndex = -1, bs(s, { binding: e, document: t, request: n });
|
|
1206
1206
|
let a = null;
|
|
1207
|
-
if (
|
|
1207
|
+
if (r) {
|
|
1208
1208
|
const S = t.createElement("label");
|
|
1209
1209
|
S.className = "wallet-confirmation-remember", a = t.createElement("input"), a.type = "checkbox", a.dataset.walletControl = "remember-site", S.append(a, ` Don't ask again for this site for ${Math.round(cn / 6e4)} minutes`), s.append(S);
|
|
1210
1210
|
}
|
|
1211
1211
|
const o = t.createElement("div");
|
|
1212
1212
|
o.className = "wallet-confirmation-actions";
|
|
1213
1213
|
const c = t.createElement("button");
|
|
1214
|
-
c.type = "button", c.dataset.walletAction = "confirm", c.textContent =
|
|
1214
|
+
c.type = "button", c.dataset.walletAction = "confirm", c.textContent = vr(e, n ?? {}).action;
|
|
1215
1215
|
const l = t.createElement("button");
|
|
1216
1216
|
l.type = "button", l.dataset.walletAction = "cancel", l.textContent = "Cancel", o.append(c, l), s.append(o), t.body.append(s);
|
|
1217
1217
|
let d = !1, u, p;
|
|
@@ -1251,7 +1251,7 @@ function ws({ binding: e, document: t, request: n, offerRemember: i = !1 }) {
|
|
|
1251
1251
|
destroy() {
|
|
1252
1252
|
c.removeEventListener?.("click", b), l.removeEventListener?.("click", h), s.removeEventListener?.("keydown", m), t.removeEventListener?.("focusin", g), s.remove();
|
|
1253
1253
|
try {
|
|
1254
|
-
|
|
1254
|
+
i?.focus?.();
|
|
1255
1255
|
} catch {
|
|
1256
1256
|
}
|
|
1257
1257
|
}
|
|
@@ -1262,16 +1262,16 @@ async function Is({
|
|
|
1262
1262
|
},
|
|
1263
1263
|
binding: t,
|
|
1264
1264
|
handle: n,
|
|
1265
|
-
identity:
|
|
1266
|
-
transaction:
|
|
1265
|
+
identity: r,
|
|
1266
|
+
transaction: i,
|
|
1267
1267
|
wasm: s
|
|
1268
1268
|
}) {
|
|
1269
|
-
const a = s?.sdn ?? s, o =
|
|
1270
|
-
if ((!o || !a) && L("OPERATION_NOT_ALLOWED"), o.publish) return Es({ assertCurrent: e, binding: t, capabilities: a, handle: n, identity:
|
|
1269
|
+
const a = s?.sdn ?? s, o = Ir[i.operation];
|
|
1270
|
+
if ((!o || !a) && L("OPERATION_NOT_ALLOWED"), o.publish) return Es({ assertCurrent: e, binding: t, capabilities: a, handle: n, identity: r, transaction: i });
|
|
1271
1271
|
if (o.bindRequest) {
|
|
1272
1272
|
let l;
|
|
1273
1273
|
try {
|
|
1274
|
-
l = ps(a, n,
|
|
1274
|
+
l = ps(a, n, i.request, t, o);
|
|
1275
1275
|
} catch (d) {
|
|
1276
1276
|
if (d instanceof Ie) throw d;
|
|
1277
1277
|
L(d?.code === "OPERATION_NOT_ALLOWED" ? "OPERATION_NOT_ALLOWED" : "INVALID_WALLET_RESULT");
|
|
@@ -1280,14 +1280,14 @@ async function Is({
|
|
|
1280
1280
|
}
|
|
1281
1281
|
if (o.connect)
|
|
1282
1282
|
return o.buildResult({
|
|
1283
|
-
connectionExpiresAt:
|
|
1283
|
+
connectionExpiresAt: i.expiresAt,
|
|
1284
1284
|
event: "connected",
|
|
1285
|
-
identity:
|
|
1285
|
+
identity: r,
|
|
1286
1286
|
schemaVersion: 1
|
|
1287
1287
|
});
|
|
1288
1288
|
let c;
|
|
1289
1289
|
try {
|
|
1290
|
-
c = await o.sign(a, n,
|
|
1290
|
+
c = await o.sign(a, n, i.request, t);
|
|
1291
1291
|
} catch (l) {
|
|
1292
1292
|
throw l;
|
|
1293
1293
|
}
|
|
@@ -1299,14 +1299,14 @@ async function Is({
|
|
|
1299
1299
|
}
|
|
1300
1300
|
}
|
|
1301
1301
|
function vs() {
|
|
1302
|
-
return
|
|
1302
|
+
return fr({
|
|
1303
1303
|
connectionExpiresAt: null,
|
|
1304
1304
|
event: "disconnected",
|
|
1305
1305
|
identity: null,
|
|
1306
1306
|
schemaVersion: 1
|
|
1307
1307
|
});
|
|
1308
1308
|
}
|
|
1309
|
-
const Un = "webauthn-prf-hkdf-sha256-aes256gcm-v2", Ss = "sdn-bip32-slip10-purpose-v1",
|
|
1309
|
+
const Un = "webauthn-prf-hkdf-sha256-aes256gcm-v2", Ss = "sdn-bip32-slip10-purpose-v1", Rs = "password-scrypt-v2", Os = Object.freeze([
|
|
1310
1310
|
"aad",
|
|
1311
1311
|
"canonicalUsername",
|
|
1312
1312
|
"ciphertextBase64url",
|
|
@@ -1324,17 +1324,17 @@ const Un = "webauthn-prf-hkdf-sha256-aes256gcm-v2", Ss = "sdn-bip32-slip10-purpo
|
|
|
1324
1324
|
"seedProfile",
|
|
1325
1325
|
"storageProfile",
|
|
1326
1326
|
"usernameSha256"
|
|
1327
|
-
]), Ns = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u, Ts = /^[0-9a-f]{64}$/u, _s = /^[A-Za-z0-9_-]+$/u, Cs = new TextEncoder(), fe = "sdn.wallet.remembered.v2", Le = `${fe}.pending`, bt = 16 * 1024,
|
|
1327
|
+
]), Ns = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u, Ts = /^[0-9a-f]{64}$/u, _s = /^[A-Za-z0-9_-]+$/u, Cs = new TextEncoder(), fe = "sdn.wallet.remembered.v2", Le = `${fe}.pending`, bt = 16 * 1024, Sr = Object.freeze([
|
|
1328
1328
|
"wallet_storage_metadata",
|
|
1329
1329
|
"wallet_storage_encrypted",
|
|
1330
1330
|
"wallet_storage_passkey_credential",
|
|
1331
1331
|
"encrypted_wallet",
|
|
1332
1332
|
"passkey_credential",
|
|
1333
1333
|
"passkey_wallet"
|
|
1334
|
-
]),
|
|
1334
|
+
]), Rr = /* @__PURE__ */ new Set([
|
|
1335
1335
|
fe,
|
|
1336
1336
|
Le,
|
|
1337
|
-
...
|
|
1337
|
+
...Sr
|
|
1338
1338
|
]), Qt = /* @__PURE__ */ new WeakSet();
|
|
1339
1339
|
class dt extends Error {
|
|
1340
1340
|
constructor(t) {
|
|
@@ -1344,13 +1344,13 @@ class dt extends Error {
|
|
|
1344
1344
|
function C(e) {
|
|
1345
1345
|
throw new dt(e);
|
|
1346
1346
|
}
|
|
1347
|
-
function
|
|
1347
|
+
function Or(e) {
|
|
1348
1348
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
1349
1349
|
const t = Object.getPrototypeOf(e);
|
|
1350
1350
|
return t === Object.prototype || t === null;
|
|
1351
1351
|
}
|
|
1352
1352
|
function Bn(e, t) {
|
|
1353
|
-
|
|
1353
|
+
Or(e) || C("INVALID_REMEMBERED_WALLET");
|
|
1354
1354
|
let n;
|
|
1355
1355
|
try {
|
|
1356
1356
|
n = Reflect.ownKeys(e);
|
|
@@ -1358,10 +1358,10 @@ function Bn(e, t) {
|
|
|
1358
1358
|
C("INVALID_REMEMBERED_WALLET");
|
|
1359
1359
|
}
|
|
1360
1360
|
n.some((a) => typeof a != "string") && C("INVALID_REMEMBERED_WALLET");
|
|
1361
|
-
const
|
|
1362
|
-
(
|
|
1361
|
+
const r = [...t].sort(), i = [...n].sort();
|
|
1362
|
+
(i.length !== r.length || i.some((a, o) => a !== r[o])) && C("INVALID_REMEMBERED_WALLET");
|
|
1363
1363
|
const s = {};
|
|
1364
|
-
for (const a of
|
|
1364
|
+
for (const a of r) {
|
|
1365
1365
|
let o;
|
|
1366
1366
|
try {
|
|
1367
1367
|
o = Object.getOwnPropertyDescriptor(e, a);
|
|
@@ -1372,20 +1372,20 @@ function Bn(e, t) {
|
|
|
1372
1372
|
}
|
|
1373
1373
|
return s;
|
|
1374
1374
|
}
|
|
1375
|
-
function
|
|
1375
|
+
function Lr(e) {
|
|
1376
1376
|
if (typeof e != "string") return !1;
|
|
1377
1377
|
for (let t = 0; t < e.length; t += 1) {
|
|
1378
1378
|
const n = e.charCodeAt(t);
|
|
1379
1379
|
if (n >= 55296 && n <= 56319) {
|
|
1380
|
-
const
|
|
1381
|
-
if (!(
|
|
1380
|
+
const r = e.charCodeAt(++t);
|
|
1381
|
+
if (!(r >= 56320 && r <= 57343)) return !1;
|
|
1382
1382
|
} else if (n >= 56320 && n <= 57343)
|
|
1383
1383
|
return !1;
|
|
1384
1384
|
}
|
|
1385
1385
|
return !0;
|
|
1386
1386
|
}
|
|
1387
|
-
function
|
|
1388
|
-
if (!
|
|
1387
|
+
function Nr(e) {
|
|
1388
|
+
if (!Lr(e)) return !1;
|
|
1389
1389
|
const t = Cs.encode(e).length;
|
|
1390
1390
|
return t >= 3 && t <= 64 && !/[\u0000-\u001f\u007f-\u009f]/u.test(e) && !/^ | $/u.test(e) && !/[A-Z]/u.test(e);
|
|
1391
1391
|
}
|
|
@@ -1395,11 +1395,11 @@ function xs(e) {
|
|
|
1395
1395
|
t += String.fromCharCode(...e.subarray(n, n + 32768));
|
|
1396
1396
|
return btoa(t).replace(/\+/gu, "-").replace(/\//gu, "_").replace(/=+$/u, "");
|
|
1397
1397
|
}
|
|
1398
|
-
function Ae(e, { minimum: t = 0, maximum: n = 65536, exact:
|
|
1398
|
+
function Ae(e, { minimum: t = 0, maximum: n = 65536, exact: r = null } = {}) {
|
|
1399
1399
|
(typeof e != "string" || e.length === 0 || !_s.test(e)) && C("INVALID_REMEMBERED_WALLET");
|
|
1400
|
-
const
|
|
1401
|
-
|
|
1402
|
-
const s = e.replace(/-/gu, "+").replace(/_/gu, "/") + "=".repeat((4 -
|
|
1400
|
+
const i = e.length % 4;
|
|
1401
|
+
i === 1 && C("INVALID_REMEMBERED_WALLET");
|
|
1402
|
+
const s = e.replace(/-/gu, "+").replace(/_/gu, "/") + "=".repeat((4 - i) % 4);
|
|
1403
1403
|
let a;
|
|
1404
1404
|
try {
|
|
1405
1405
|
a = atob(s);
|
|
@@ -1408,10 +1408,10 @@ function Ae(e, { minimum: t = 0, maximum: n = 65536, exact: i = null } = {}) {
|
|
|
1408
1408
|
}
|
|
1409
1409
|
const o = new Uint8Array(a.length);
|
|
1410
1410
|
for (let c = 0; c < a.length; c += 1) o[c] = a.charCodeAt(c);
|
|
1411
|
-
return (xs(o) !== e || o.length < t || o.length > n ||
|
|
1411
|
+
return (xs(o) !== e || o.length < t || o.length > n || r !== null && o.length !== r) && C("INVALID_REMEMBERED_WALLET"), o;
|
|
1412
1412
|
}
|
|
1413
1413
|
function un(e) {
|
|
1414
|
-
return e === null || typeof e == "boolean" || typeof e == "string" || typeof e == "number" && Number.isFinite(e) ? JSON.stringify(e) : (
|
|
1414
|
+
return e === null || typeof e == "boolean" || typeof e == "string" || typeof e == "number" && Number.isFinite(e) ? JSON.stringify(e) : (Or(e) || C("INVALID_REMEMBERED_WALLET"), `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${un(e[t])}`).join(",")}}`);
|
|
1415
1415
|
}
|
|
1416
1416
|
function Ds(e) {
|
|
1417
1417
|
return Object.freeze({
|
|
@@ -1427,12 +1427,12 @@ function Ds(e) {
|
|
|
1427
1427
|
storageProfile: e.storageProfile
|
|
1428
1428
|
});
|
|
1429
1429
|
}
|
|
1430
|
-
function
|
|
1431
|
-
const t = Bn(e,
|
|
1432
|
-
return (t.schemaVersion !== 2 || t.storageProfile !== Un || n.schemaVersion !== 2 || n.storageProfile !== Un || n.identityScheme !== Ss || n.seedProfile !==
|
|
1430
|
+
function Tr(e) {
|
|
1431
|
+
const t = Bn(e, Os), n = Bn(t.aad, Ls);
|
|
1432
|
+
return (t.schemaVersion !== 2 || t.storageProfile !== Un || n.schemaVersion !== 2 || n.storageProfile !== Un || n.identityScheme !== Ss || n.seedProfile !== Rs || !Nr(t.canonicalUsername) || !Ts.test(n.usernameSha256) || t.credentialIdBase64url !== n.credentialIdBase64url || !Lr(t.createdAt) || !Ns.test(t.createdAt) || new Date(t.createdAt).toISOString() !== t.createdAt) && C("INVALID_REMEMBERED_WALLET"), Ae(t.credentialIdBase64url, { minimum: 1, maximum: 1024 }), Ae(t.ciphertextBase64url, { minimum: 17, maximum: 1024 }), Ae(t.hkdfSaltBase64url, { exact: 32 }), Ae(t.nonceBase64url, { exact: 12 }), Ae(t.prfInputBase64url, { exact: 32 }), Ds({ ...t, aad: n });
|
|
1433
1433
|
}
|
|
1434
1434
|
function Ps(e) {
|
|
1435
|
-
return un(
|
|
1435
|
+
return un(Tr(e));
|
|
1436
1436
|
}
|
|
1437
1437
|
function dn(e) {
|
|
1438
1438
|
(typeof e != "string" || e.length === 0 || e.length > 131072) && C("INVALID_REMEMBERED_WALLET");
|
|
@@ -1442,33 +1442,33 @@ function dn(e) {
|
|
|
1442
1442
|
} catch {
|
|
1443
1443
|
C("INVALID_REMEMBERED_WALLET");
|
|
1444
1444
|
}
|
|
1445
|
-
const n =
|
|
1445
|
+
const n = Tr(t);
|
|
1446
1446
|
return un(n) !== e && C("INVALID_REMEMBERED_WALLET"), n;
|
|
1447
1447
|
}
|
|
1448
1448
|
function Xt(e, t, { pending: n = !1 } = {}) {
|
|
1449
1449
|
(!e || typeof e.getItem != "function") && C("STORAGE_UNAVAILABLE");
|
|
1450
|
-
let
|
|
1450
|
+
let r;
|
|
1451
1451
|
try {
|
|
1452
|
-
|
|
1452
|
+
r = e.getItem(t);
|
|
1453
1453
|
} catch {
|
|
1454
1454
|
C("STORAGE_UNAVAILABLE");
|
|
1455
1455
|
}
|
|
1456
|
-
if (
|
|
1457
|
-
typeof
|
|
1458
|
-
const
|
|
1459
|
-
if (n ||
|
|
1456
|
+
if (r === null) return Object.freeze({ raw: null, record: null, status: "empty" });
|
|
1457
|
+
typeof r != "string" && C("STORAGE_UNAVAILABLE");
|
|
1458
|
+
const i = r.length > bt;
|
|
1459
|
+
if (n || i)
|
|
1460
1460
|
return Object.freeze({
|
|
1461
|
-
exportable: !
|
|
1462
|
-
oversized:
|
|
1463
|
-
raw:
|
|
1464
|
-
rawLength:
|
|
1461
|
+
exportable: !i,
|
|
1462
|
+
oversized: i,
|
|
1463
|
+
raw: i ? null : r,
|
|
1464
|
+
rawLength: r.length,
|
|
1465
1465
|
record: null,
|
|
1466
1466
|
status: "quarantined"
|
|
1467
1467
|
});
|
|
1468
1468
|
try {
|
|
1469
|
-
const s = dn(
|
|
1469
|
+
const s = dn(r);
|
|
1470
1470
|
return Object.freeze({
|
|
1471
|
-
raw:
|
|
1471
|
+
raw: r,
|
|
1472
1472
|
record: s,
|
|
1473
1473
|
status: n ? "quarantined" : "valid"
|
|
1474
1474
|
});
|
|
@@ -1476,57 +1476,57 @@ function Xt(e, t, { pending: n = !1 } = {}) {
|
|
|
1476
1476
|
return Object.freeze({
|
|
1477
1477
|
exportable: !0,
|
|
1478
1478
|
oversized: !1,
|
|
1479
|
-
raw:
|
|
1480
|
-
rawLength:
|
|
1479
|
+
raw: r,
|
|
1480
|
+
rawLength: r.length,
|
|
1481
1481
|
record: null,
|
|
1482
1482
|
status: "quarantined"
|
|
1483
1483
|
});
|
|
1484
1484
|
}
|
|
1485
1485
|
}
|
|
1486
|
-
function
|
|
1487
|
-
const t = Xt(e, Le, { pending: !0 }), n = Xt(e, fe),
|
|
1486
|
+
function _r(e) {
|
|
1487
|
+
const t = Xt(e, Le, { pending: !0 }), n = Xt(e, fe), r = t.status === "empty", i = n.status === "empty" || n.status === "valid";
|
|
1488
1488
|
return Object.freeze({
|
|
1489
1489
|
active: n,
|
|
1490
|
-
canRestore:
|
|
1491
|
-
canSetup:
|
|
1490
|
+
canRestore: r && n.status === "valid",
|
|
1491
|
+
canSetup: r && i,
|
|
1492
1492
|
pending: t
|
|
1493
1493
|
});
|
|
1494
1494
|
}
|
|
1495
1495
|
function ks(e, t) {
|
|
1496
|
-
const n =
|
|
1496
|
+
const n = _r(e);
|
|
1497
1497
|
n.canSetup || C("STORAGE_QUARANTINED");
|
|
1498
|
-
const
|
|
1498
|
+
const r = Ps(t);
|
|
1499
1499
|
try {
|
|
1500
|
-
e.setItem(Le,
|
|
1500
|
+
e.setItem(Le, r);
|
|
1501
1501
|
} catch (a) {
|
|
1502
1502
|
throw a;
|
|
1503
1503
|
}
|
|
1504
|
-
let
|
|
1504
|
+
let i;
|
|
1505
1505
|
try {
|
|
1506
|
-
|
|
1506
|
+
i = e.getItem(Le);
|
|
1507
1507
|
} catch {
|
|
1508
1508
|
C("STORAGE_UNAVAILABLE");
|
|
1509
1509
|
}
|
|
1510
|
-
|
|
1510
|
+
i !== r && C("STORAGE_WRITE_FAILED"), dn(i);
|
|
1511
1511
|
const s = Object.freeze({
|
|
1512
1512
|
previousActiveRaw: n.active.raw,
|
|
1513
|
-
serialized:
|
|
1513
|
+
serialized: r,
|
|
1514
1514
|
storage: e
|
|
1515
1515
|
});
|
|
1516
1516
|
return Qt.add(s), s;
|
|
1517
1517
|
}
|
|
1518
1518
|
function Us(e, t) {
|
|
1519
1519
|
(!Qt.has(t) || t.storage !== e) && C("INVALID_STORAGE_TRANSACTION"), Qt.delete(t);
|
|
1520
|
-
let n,
|
|
1520
|
+
let n, r;
|
|
1521
1521
|
try {
|
|
1522
|
-
n = e.getItem(Le),
|
|
1522
|
+
n = e.getItem(Le), r = e.getItem(fe);
|
|
1523
1523
|
} catch {
|
|
1524
1524
|
C("STORAGE_UNAVAILABLE");
|
|
1525
1525
|
}
|
|
1526
|
-
(n !== t.serialized ||
|
|
1526
|
+
(n !== t.serialized || r !== t.previousActiveRaw) && C("STORAGE_COLLISION"), e.removeItem(Le), e.getItem(Le) !== null && C("STORAGE_WRITE_FAILED"), e.setItem(fe, t.serialized);
|
|
1527
1527
|
}
|
|
1528
1528
|
function fn(e, t) {
|
|
1529
|
-
|
|
1529
|
+
Rr.has(t) || C("INVALID_STORAGE_KEY"), (!e || typeof e.getItem != "function") && C("STORAGE_UNAVAILABLE");
|
|
1530
1530
|
let n;
|
|
1531
1531
|
try {
|
|
1532
1532
|
n = e.getItem(t);
|
|
@@ -1537,8 +1537,8 @@ function fn(e, t) {
|
|
|
1537
1537
|
if (typeof n != "string" && C("STORAGE_UNAVAILABLE"), t === fe && n.length <= bt)
|
|
1538
1538
|
try {
|
|
1539
1539
|
dn(n), C("NOT_QUARANTINED");
|
|
1540
|
-
} catch (
|
|
1541
|
-
if (
|
|
1540
|
+
} catch (r) {
|
|
1541
|
+
if (r instanceof dt && r.code === "NOT_QUARANTINED") throw r;
|
|
1542
1542
|
}
|
|
1543
1543
|
return Object.freeze({
|
|
1544
1544
|
exportable: n.length <= bt,
|
|
@@ -1561,16 +1561,16 @@ function js(e) {
|
|
|
1561
1561
|
for (const n of [
|
|
1562
1562
|
fe,
|
|
1563
1563
|
Le,
|
|
1564
|
-
...
|
|
1564
|
+
...Sr
|
|
1565
1565
|
]) {
|
|
1566
|
-
let
|
|
1566
|
+
let r;
|
|
1567
1567
|
try {
|
|
1568
|
-
|
|
1569
|
-
} catch (
|
|
1570
|
-
if (
|
|
1571
|
-
throw
|
|
1568
|
+
r = fn(e, n);
|
|
1569
|
+
} catch (i) {
|
|
1570
|
+
if (i instanceof dt && i.code === "NOT_QUARANTINED") continue;
|
|
1571
|
+
throw i;
|
|
1572
1572
|
}
|
|
1573
|
-
|
|
1573
|
+
r && t.push(Bs(r));
|
|
1574
1574
|
}
|
|
1575
1575
|
return Object.freeze(t);
|
|
1576
1576
|
}
|
|
@@ -1579,11 +1579,11 @@ function Vs(e, t) {
|
|
|
1579
1579
|
return n || C("QUARANTINE_NOT_FOUND"), n.exportable || C("QUARANTINE_EXPORT_TOO_LARGE"), n.raw;
|
|
1580
1580
|
}
|
|
1581
1581
|
function $s(e, t, n) {
|
|
1582
|
-
|
|
1582
|
+
Rr.has(t) || C("INVALID_STORAGE_KEY"), n !== t && C("CONFIRMATION_REQUIRED"), fn(e, t) || C("QUARANTINE_NOT_FOUND");
|
|
1583
1583
|
try {
|
|
1584
1584
|
e.removeItem(t), e.getItem(t) !== null && C("STORAGE_WRITE_FAILED");
|
|
1585
|
-
} catch (
|
|
1586
|
-
if (
|
|
1585
|
+
} catch (i) {
|
|
1586
|
+
if (i instanceof dt) throw i;
|
|
1587
1587
|
C("STORAGE_UNAVAILABLE");
|
|
1588
1588
|
}
|
|
1589
1589
|
}
|
|
@@ -1593,12 +1593,12 @@ function Ms(e, t) {
|
|
|
1593
1593
|
n.status === "empty" && C("REMEMBER_UNAVAILABLE"), n.status !== "valid" && C("STORAGE_QUARANTINED");
|
|
1594
1594
|
try {
|
|
1595
1595
|
e.removeItem(fe), e.getItem(fe) !== null && C("STORAGE_WRITE_FAILED");
|
|
1596
|
-
} catch (
|
|
1597
|
-
if (
|
|
1596
|
+
} catch (r) {
|
|
1597
|
+
if (r instanceof dt) throw r;
|
|
1598
1598
|
C("STORAGE_UNAVAILABLE");
|
|
1599
1599
|
}
|
|
1600
1600
|
}
|
|
1601
|
-
const
|
|
1601
|
+
const Rt = "sdn-bip32-slip10-purpose-v1", Ot = "password-scrypt-v2", Zt = "m/44'/0'/0'/2'/0'", pn = "Approval unavailable — migrate to the new wallet profile", jn = Object.freeze({
|
|
1602
1602
|
"bip39-mnemonic-v1-legacy": "sdn-bip39-auth-v1-legacy",
|
|
1603
1603
|
"password-fast-v1-legacy": "sdn-fast-password-auth-v1-legacy"
|
|
1604
1604
|
}), Vn = new TextEncoder(), Fs = Uint8Array.prototype.fill, hn = Object.freeze([
|
|
@@ -1643,13 +1643,13 @@ const Ot = "sdn-bip32-slip10-purpose-v1", Rt = "password-scrypt-v2", Zt = "m/44'
|
|
|
1643
1643
|
signatureProfile: "ed25519-over-sha256-jcs-v1"
|
|
1644
1644
|
})
|
|
1645
1645
|
]);
|
|
1646
|
-
class
|
|
1646
|
+
class Cr extends Error {
|
|
1647
1647
|
constructor(t) {
|
|
1648
1648
|
super(t === "APPROVAL_UNAVAILABLE" ? pn : t), this.name = "WalletAccountError", this.code = t;
|
|
1649
1649
|
}
|
|
1650
1650
|
}
|
|
1651
1651
|
function M(e) {
|
|
1652
|
-
throw new
|
|
1652
|
+
throw new Cr(e);
|
|
1653
1653
|
}
|
|
1654
1654
|
function $n(e) {
|
|
1655
1655
|
if (e instanceof Uint8Array)
|
|
@@ -1679,10 +1679,10 @@ function Nt(e, t) {
|
|
|
1679
1679
|
M("INVALID_PUBLIC_IDENTITY");
|
|
1680
1680
|
}
|
|
1681
1681
|
n.some((a) => typeof a != "string") && M("INVALID_PUBLIC_IDENTITY");
|
|
1682
|
-
const
|
|
1683
|
-
(
|
|
1682
|
+
const r = [...n].sort(), i = [...t].sort();
|
|
1683
|
+
(r.length !== i.length || r.some((a, o) => a !== i[o])) && M("INVALID_PUBLIC_IDENTITY");
|
|
1684
1684
|
const s = {};
|
|
1685
|
-
for (const a of
|
|
1685
|
+
for (const a of r) {
|
|
1686
1686
|
let o;
|
|
1687
1687
|
try {
|
|
1688
1688
|
o = Object.getOwnPropertyDescriptor(e, a);
|
|
@@ -1698,8 +1698,8 @@ function We(e) {
|
|
|
1698
1698
|
for (let t = 0; t < e.length; t += 1) {
|
|
1699
1699
|
const n = e.charCodeAt(t);
|
|
1700
1700
|
if (n >= 55296 && n <= 56319) {
|
|
1701
|
-
const
|
|
1702
|
-
if (!(
|
|
1701
|
+
const r = e.charCodeAt(++t);
|
|
1702
|
+
if (!(r >= 56320 && r <= 57343)) return !1;
|
|
1703
1703
|
} else if (n >= 56320 && n <= 57343) return !1;
|
|
1704
1704
|
}
|
|
1705
1705
|
return !0;
|
|
@@ -1713,14 +1713,14 @@ function Ws(e) {
|
|
|
1713
1713
|
return !1;
|
|
1714
1714
|
}
|
|
1715
1715
|
const n = ["0", "1", "2", "length"];
|
|
1716
|
-
if (t.length !== n.length || t.some((
|
|
1717
|
-
for (let
|
|
1718
|
-
const
|
|
1719
|
-
if (!
|
|
1716
|
+
if (t.length !== n.length || t.some((r, i) => r !== n[i])) return !1;
|
|
1717
|
+
for (let r = 0; r < Lt.length; r += 1) {
|
|
1718
|
+
const i = Object.getOwnPropertyDescriptor(e, String(r));
|
|
1719
|
+
if (!i?.enumerable || !("value" in i)) return !1;
|
|
1720
1720
|
}
|
|
1721
1721
|
return !0;
|
|
1722
1722
|
}
|
|
1723
|
-
function
|
|
1723
|
+
function Hs(e) {
|
|
1724
1724
|
if (!Array.isArray(e) || Object.getPrototypeOf(e) !== Array.prototype || e.length !== 1) return !1;
|
|
1725
1725
|
let t;
|
|
1726
1726
|
try {
|
|
@@ -1734,20 +1734,20 @@ function zs(e) {
|
|
|
1734
1734
|
}
|
|
1735
1735
|
function ge(e) {
|
|
1736
1736
|
const t = Nt(e, hn);
|
|
1737
|
-
(t.schemaVersion !== 1 || t.identityScheme !==
|
|
1738
|
-
const n = Lt.map((
|
|
1739
|
-
const s = Nt(t.keys[
|
|
1740
|
-
return (s.bip32Fingerprint !== null || s.curve !==
|
|
1737
|
+
(t.schemaVersion !== 1 || t.identityScheme !== Rt || t.seedProfile !== Ot || t.accountIndex !== 0 || t.accountLabel !== null || !/^[0-9a-f]{8}$/u.test(t.accountFingerprint) || !We(t.accountXpub) || !/^xpub[1-9A-HJ-NP-Za-km-z]{107}$/u.test(t.accountXpub) || !We(t.accountPeerId) || !/^16Uiu2H[1-9A-HJ-NP-Za-km-z]{33,57}$/u.test(t.accountPeerId) || !Ws(t.keys)) && M("INVALID_PUBLIC_IDENTITY");
|
|
1738
|
+
const n = Lt.map((r, i) => {
|
|
1739
|
+
const s = Nt(t.keys[i], yn);
|
|
1740
|
+
return (s.bip32Fingerprint !== null || s.curve !== r.curve || s.derivation !== "slip10" || s.encoding !== "raw" || s.identityScheme !== Rt || s.path !== r.path || s.purpose !== r.purpose || s.seedProfile !== Ot || s.signatureProfile !== r.signatureProfile || !/^[0-9a-f]{64}$/u.test(s.publicKeyHex) || !/^sha256:[0-9a-f]{64}$/u.test(s.keyId)) && M("INVALID_PUBLIC_IDENTITY"), Be(s);
|
|
1741
1741
|
});
|
|
1742
1742
|
return Be({ ...t, keys: n });
|
|
1743
1743
|
}
|
|
1744
|
-
function
|
|
1745
|
-
const
|
|
1746
|
-
(!
|
|
1747
|
-
const
|
|
1748
|
-
(
|
|
1749
|
-
const s = Nt(
|
|
1750
|
-
return (s.bip32Fingerprint !== null || s.curve !== "ed25519" || s.derivation !== "bip32-scalar-as-ed25519-seed" || s.encoding !== "raw" || s.identityScheme !==
|
|
1744
|
+
function zs(e, { accountIndex: t = 0, profile: n } = {}) {
|
|
1745
|
+
const r = Object.hasOwn(jn, n) ? jn[n] : null;
|
|
1746
|
+
(!r || t !== 0) && M("INVALID_LEGACY_PROFILE");
|
|
1747
|
+
const i = Nt(e, hn);
|
|
1748
|
+
(i.schemaVersion !== 1 || i.identityScheme !== r || i.seedProfile !== n || i.accountIndex !== t || i.accountLabel !== null || !/^[0-9a-f]{8}$/u.test(i.accountFingerprint) || !We(i.accountXpub) || !/^xpub[1-9A-HJ-NP-Za-km-z]{107}$/u.test(i.accountXpub) || !We(i.accountPeerId) || !/^16Uiu2H[1-9A-HJ-NP-Za-km-z]{33,57}$/u.test(i.accountPeerId) || !Hs(i.keys)) && M("INVALID_PUBLIC_IDENTITY");
|
|
1749
|
+
const s = Nt(i.keys[0], yn);
|
|
1750
|
+
return (s.bip32Fingerprint !== null || s.curve !== "ed25519" || s.derivation !== "bip32-scalar-as-ed25519-seed" || s.encoding !== "raw" || s.identityScheme !== r || 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)) && M("INVALID_PUBLIC_IDENTITY"), Be({ ...i, keys: [s] });
|
|
1751
1751
|
}
|
|
1752
1752
|
function Mn(e) {
|
|
1753
1753
|
if (!(!e || typeof e != "object")) {
|
|
@@ -1788,12 +1788,12 @@ function Mn(e) {
|
|
|
1788
1788
|
function Fn(e, t) {
|
|
1789
1789
|
if (typeof e != "string" || typeof t != "string") return !1;
|
|
1790
1790
|
const n = Math.max(e.length, t.length);
|
|
1791
|
-
let
|
|
1792
|
-
for (let
|
|
1793
|
-
const s = Number.parseInt(e.slice(
|
|
1794
|
-
|
|
1791
|
+
let r = e.length ^ t.length;
|
|
1792
|
+
for (let i = 0; i < n; i += 2) {
|
|
1793
|
+
const s = Number.parseInt(e.slice(i, i + 2), 16), a = Number.parseInt(t.slice(i, i + 2), 16);
|
|
1794
|
+
r |= (Number.isNaN(s) ? 256 : s) ^ (Number.isNaN(a) ? 256 : a);
|
|
1795
1795
|
}
|
|
1796
|
-
return
|
|
1796
|
+
return r === 0;
|
|
1797
1797
|
}
|
|
1798
1798
|
function Ks(e) {
|
|
1799
1799
|
return !e || typeof e != "object" || !Array.isArray(e.keys) ? null : e.keys.find((t) => t?.purpose === "asset-review-approval") ?? null;
|
|
@@ -1805,26 +1805,26 @@ function Mt(e, t) {
|
|
|
1805
1805
|
return !1;
|
|
1806
1806
|
}
|
|
1807
1807
|
let n = !0;
|
|
1808
|
-
for (const
|
|
1809
|
-
n = e[
|
|
1810
|
-
for (let
|
|
1811
|
-
const
|
|
1808
|
+
for (const r of hn.filter((i) => i !== "keys"))
|
|
1809
|
+
n = e[r] === t[r] && n;
|
|
1810
|
+
for (let r = 0; r < Lt.length; r += 1) {
|
|
1811
|
+
const i = e.keys[r], s = t.keys[r];
|
|
1812
1812
|
for (const a of yn.filter((o) => o !== "publicKeyHex" && o !== "keyId"))
|
|
1813
|
-
n =
|
|
1814
|
-
n = Fn(
|
|
1813
|
+
n = i[a] === s[a] && n;
|
|
1814
|
+
n = Fn(i.publicKeyHex, s.publicKeyHex) && n, n = Fn(i.keyId.slice(7), s.keyId.slice(7)) && n;
|
|
1815
1815
|
}
|
|
1816
1816
|
return n;
|
|
1817
1817
|
}
|
|
1818
|
-
function Fe(e, t, n,
|
|
1819
|
-
const
|
|
1820
|
-
|
|
1818
|
+
function Fe(e, t, n, r) {
|
|
1819
|
+
const i = e.createElement("div");
|
|
1820
|
+
i.className = "wallet-account-row";
|
|
1821
1821
|
const s = e.createElement("strong");
|
|
1822
1822
|
s.textContent = `${n}: `;
|
|
1823
1823
|
const a = e.createElement("span");
|
|
1824
|
-
a.textContent =
|
|
1824
|
+
a.textContent = r == null ? "" : String(r), i.append(s, a), t.append(i);
|
|
1825
1825
|
}
|
|
1826
|
-
function
|
|
1827
|
-
(e?.identityScheme !==
|
|
1826
|
+
function xr(e) {
|
|
1827
|
+
(e?.identityScheme !== Rt || e?.seedProfile !== Ot || e?.accountIndex !== 0) && M("APPROVAL_UNAVAILABLE");
|
|
1828
1828
|
const t = Ks(e);
|
|
1829
1829
|
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 !== Zt || t.encoding !== "raw" || !/^[0-9a-f]{64}$/u.test(t.publicKeyHex) || !/^sha256:[0-9a-f]{64}$/u.test(t.keyId)) && M("APPROVAL_UNAVAILABLE"), Be({
|
|
1830
1830
|
algorithm: "Ed25519",
|
|
@@ -1844,22 +1844,22 @@ function Gs(e) {
|
|
|
1844
1844
|
}
|
|
1845
1845
|
function Js(e, t, { document: n = e.ownerDocument } = {}) {
|
|
1846
1846
|
e.replaceChildren();
|
|
1847
|
-
const
|
|
1848
|
-
if (
|
|
1847
|
+
const r = n.createElement("h1");
|
|
1848
|
+
if (r.textContent = "Account", e.append(r), Fe(n, e, "Username / account", t?.accountLabel ?? "account 0"), Fe(n, e, "Account xpub", t?.accountXpub), Fe(n, e, "Peer ID", t?.accountPeerId), Fe(n, e, "Fingerprint", t?.accountFingerprint), t?.identityScheme !== Rt || t?.seedProfile !== Ot) {
|
|
1849
1849
|
const s = n.createElement("p");
|
|
1850
1850
|
return s.textContent = pn, e.append(s), Object.freeze({ approvalAvailable: !1 });
|
|
1851
1851
|
}
|
|
1852
|
-
const
|
|
1853
|
-
return Fe(n, e, "Asset approval public key",
|
|
1852
|
+
const i = xr(t);
|
|
1853
|
+
return Fe(n, e, "Asset approval public key", i.publicKeyHex), Fe(n, e, "Asset approval key ID", i.keyId), Object.freeze({ approvalAvailable: !0, configuration: i });
|
|
1854
1854
|
}
|
|
1855
1855
|
function Ys(e, { document: t = e.ownerDocument } = {}) {
|
|
1856
1856
|
e.replaceChildren();
|
|
1857
1857
|
const n = t.createElement("h2");
|
|
1858
1858
|
n.textContent = "Stored wallet";
|
|
1859
|
-
const
|
|
1860
|
-
|
|
1861
|
-
const
|
|
1862
|
-
|
|
1859
|
+
const r = t.createElement("p");
|
|
1860
|
+
r.textContent = "Forgetting removes the saved unlock record but keeps this account signed in.";
|
|
1861
|
+
const i = t.createElement("button");
|
|
1862
|
+
i.type = "button", i.dataset.walletAction = "forget-stored-wallet", i.textContent = "Forget stored wallet";
|
|
1863
1863
|
const s = t.createElement("div");
|
|
1864
1864
|
s.hidden = !0;
|
|
1865
1865
|
const a = t.createElement("p");
|
|
@@ -1871,22 +1871,22 @@ function Ys(e, { document: t = e.ownerDocument } = {}) {
|
|
|
1871
1871
|
const l = t.createElement("button");
|
|
1872
1872
|
l.type = "button", l.dataset.walletAction = "cancel-forget-stored-wallet", l.textContent = "Cancel";
|
|
1873
1873
|
const d = t.createElement("p");
|
|
1874
|
-
return d.dataset.walletForgetStatus = "true", d.setAttribute?.("aria-live", "polite"), s.append(a, o, c, l), e.append(n,
|
|
1874
|
+
return d.dataset.walletForgetStatus = "true", d.setAttribute?.("aria-live", "polite"), s.append(a, o, c, l), e.append(n, r, i, s, d), Object.freeze({
|
|
1875
1875
|
cancel: l,
|
|
1876
1876
|
confirm: c,
|
|
1877
1877
|
confirmation: o,
|
|
1878
1878
|
confirmationGroup: s,
|
|
1879
1879
|
confirmationKey: fe,
|
|
1880
|
-
launch:
|
|
1880
|
+
launch: i,
|
|
1881
1881
|
status: d
|
|
1882
1882
|
});
|
|
1883
1883
|
}
|
|
1884
1884
|
function Qs(e, t, { document: n = e.ownerDocument } = {}) {
|
|
1885
1885
|
e.replaceChildren();
|
|
1886
|
-
const
|
|
1887
|
-
|
|
1888
|
-
const
|
|
1889
|
-
|
|
1886
|
+
const r = n.createElement("h2");
|
|
1887
|
+
r.textContent = "Quarantined wallet storage";
|
|
1888
|
+
const i = n.createElement("p");
|
|
1889
|
+
i.textContent = "These records are never unlocked automatically. Export or delete each exact storage key.";
|
|
1890
1890
|
const s = n.createElement("div"), a = n.createElement("p");
|
|
1891
1891
|
a.dataset.walletQuarantineStatus = "true", a.setAttribute?.("aria-live", "polite");
|
|
1892
1892
|
const o = [];
|
|
@@ -1920,14 +1920,14 @@ function Qs(e, t, { document: n = e.ownerDocument } = {}) {
|
|
|
1920
1920
|
exportButton: p
|
|
1921
1921
|
}));
|
|
1922
1922
|
}
|
|
1923
|
-
return e.append(
|
|
1923
|
+
return e.append(r, i, s, a), Object.freeze({ rows: Object.freeze(o), status: a });
|
|
1924
1924
|
}
|
|
1925
1925
|
async function Xs(e, {
|
|
1926
1926
|
assertCurrent: t = () => {
|
|
1927
1927
|
},
|
|
1928
1928
|
clipboard: n = globalThis.navigator?.clipboard,
|
|
1929
|
-
container:
|
|
1930
|
-
document:
|
|
1929
|
+
container: r,
|
|
1930
|
+
document: i = r?.ownerDocument
|
|
1931
1931
|
}) {
|
|
1932
1932
|
const s = Gs(e);
|
|
1933
1933
|
let a = !1;
|
|
@@ -1936,9 +1936,9 @@ async function Xs(e, {
|
|
|
1936
1936
|
await n.writeText(s), a = !0;
|
|
1937
1937
|
} catch {
|
|
1938
1938
|
}
|
|
1939
|
-
if (t(), !a &&
|
|
1940
|
-
const o =
|
|
1941
|
-
o.readOnly = !0, o.value = s, o.textContent = s,
|
|
1939
|
+
if (t(), !a && r && i) {
|
|
1940
|
+
const o = i.createElement("textarea");
|
|
1941
|
+
o.readOnly = !0, o.value = s, o.textContent = s, r.replaceChildren(o);
|
|
1942
1942
|
try {
|
|
1943
1943
|
o.select?.();
|
|
1944
1944
|
} catch {
|
|
@@ -1947,17 +1947,17 @@ async function Xs(e, {
|
|
|
1947
1947
|
return a;
|
|
1948
1948
|
}
|
|
1949
1949
|
async function qn(e, t, n, {
|
|
1950
|
-
assertCurrent:
|
|
1951
|
-
ownBuffer:
|
|
1950
|
+
assertCurrent: r,
|
|
1951
|
+
ownBuffer: i,
|
|
1952
1952
|
ownHandle: s,
|
|
1953
1953
|
releaseBuffer: a
|
|
1954
1954
|
}) {
|
|
1955
1955
|
const o = await t(n), c = o?.usernameControl, l = o?.passwordControl;
|
|
1956
1956
|
let d, u;
|
|
1957
1957
|
try {
|
|
1958
|
-
|
|
1958
|
+
r();
|
|
1959
1959
|
const f = c?.value, A = l?.value;
|
|
1960
|
-
(typeof f != "string" || typeof A != "string") && M("CREDENTIAL_CONFIRMATION_MISMATCH"), (!We(f) || !We(A)) && M("CREDENTIAL_CONFIRMATION_MISMATCH"), d = Vn.encode(f),
|
|
1960
|
+
(typeof f != "string" || typeof A != "string") && M("CREDENTIAL_CONFIRMATION_MISMATCH"), (!We(f) || !We(A)) && M("CREDENTIAL_CONFIRMATION_MISMATCH"), d = Vn.encode(f), i(d), u = Vn.encode(A), i(u);
|
|
1961
1961
|
} finally {
|
|
1962
1962
|
Mn(c), Mn(l);
|
|
1963
1963
|
const f = c?.form, A = l?.form;
|
|
@@ -1973,11 +1973,11 @@ async function qn(e, t, n, {
|
|
|
1973
1973
|
}
|
|
1974
1974
|
let p;
|
|
1975
1975
|
try {
|
|
1976
|
-
|
|
1976
|
+
r(), p = await e.derivePasswordIdentity({
|
|
1977
1977
|
accountIndex: 0,
|
|
1978
1978
|
passwordUtf8: u,
|
|
1979
1979
|
usernameUtf8: d
|
|
1980
|
-
}), p?.handle || M("CREDENTIAL_CONFIRMATION_MISMATCH"), s(p.handle),
|
|
1980
|
+
}), p?.handle || M("CREDENTIAL_CONFIRMATION_MISMATCH"), s(p.handle), r();
|
|
1981
1981
|
let f;
|
|
1982
1982
|
try {
|
|
1983
1983
|
f = ge(p.identity);
|
|
@@ -1998,22 +1998,22 @@ class Zs {
|
|
|
1998
1998
|
#y = 0;
|
|
1999
1999
|
#S = 0;
|
|
2000
2000
|
#e = /* @__PURE__ */ new Set();
|
|
2001
|
-
#
|
|
2002
|
-
#
|
|
2003
|
-
constructor({ wasm: t, credentialRound: n, expectedIdentity:
|
|
2004
|
-
this.#
|
|
2001
|
+
#i = /* @__PURE__ */ new Set();
|
|
2002
|
+
#r;
|
|
2003
|
+
constructor({ wasm: t, credentialRound: n, expectedIdentity: r = null }) {
|
|
2004
|
+
this.#r = t?.sdn ?? t, this.#f = n;
|
|
2005
2005
|
try {
|
|
2006
|
-
this.#o =
|
|
2006
|
+
this.#o = r === null ? null : ge(r);
|
|
2007
2007
|
} catch {
|
|
2008
2008
|
M("CREDENTIAL_CONFIRMATION_MISMATCH");
|
|
2009
2009
|
}
|
|
2010
|
-
(typeof this.#
|
|
2010
|
+
(typeof this.#r?.derivePasswordIdentity != "function" || typeof this.#r?.destroySdnIdentity != "function" || typeof n != "function") && M("CREDENTIAL_CONFIRMATION_MISMATCH");
|
|
2011
2011
|
}
|
|
2012
2012
|
get confirmed() {
|
|
2013
2013
|
return this.#d;
|
|
2014
2014
|
}
|
|
2015
2015
|
clear() {
|
|
2016
|
-
return this.#d = null, this.#h || (this.#h = !0, this.#y += 1, this.#o = null), this.#L(), this.#
|
|
2016
|
+
return this.#d = null, this.#h || (this.#h = !0, this.#y += 1, this.#o = null), this.#L(), this.#R(), this.#S === 0 && this.#e.size === 0;
|
|
2017
2017
|
}
|
|
2018
2018
|
destroy() {
|
|
2019
2019
|
return this.clear();
|
|
@@ -2022,23 +2022,23 @@ class Zs {
|
|
|
2022
2022
|
if (this.#h && M("CREDENTIAL_CONFIRMATION_MISMATCH"), this.#d) return this.#d;
|
|
2023
2023
|
this.#S += 1;
|
|
2024
2024
|
const t = this.#y;
|
|
2025
|
-
let n,
|
|
2025
|
+
let n, r;
|
|
2026
2026
|
try {
|
|
2027
|
-
this.#
|
|
2027
|
+
this.#R(), this.#e.size !== 0 && M("CREDENTIAL_CONFIRMATION_MISMATCH");
|
|
2028
2028
|
const s = {
|
|
2029
2029
|
assertCurrent: () => this.#t(t),
|
|
2030
|
-
ownBuffer: (a) => this.#
|
|
2030
|
+
ownBuffer: (a) => this.#i.add(a),
|
|
2031
2031
|
ownHandle: (a) => this.#e.add(a),
|
|
2032
2032
|
releaseBuffer: (a) => {
|
|
2033
|
-
$n(a), this.#
|
|
2033
|
+
$n(a), this.#i.delete(a);
|
|
2034
2034
|
}
|
|
2035
2035
|
};
|
|
2036
|
-
return n = await qn(this.#
|
|
2037
|
-
} catch (
|
|
2038
|
-
if (this.#d = null,
|
|
2036
|
+
return n = await qn(this.#r, this.#f, 1, s), this.#p(n.handle) || M("CREDENTIAL_CONFIRMATION_MISMATCH"), n.handle = null, this.#t(t), r = await qn(this.#r, this.#f, 2, s), this.#p(r.handle) || M("CREDENTIAL_CONFIRMATION_MISMATCH"), r.handle = null, this.#t(t), (!Mt(n.identity, r.identity) || this.#o !== null && (!Mt(n.identity, this.#o) || !Mt(r.identity, this.#o))) && M("CREDENTIAL_CONFIRMATION_MISMATCH"), this.#e.size !== 0 && M("CREDENTIAL_CONFIRMATION_MISMATCH"), this.#d = xr(r.identity), this.#d;
|
|
2037
|
+
} catch (i) {
|
|
2038
|
+
if (this.#d = null, i instanceof Cr && i.code === "CREDENTIAL_CONFIRMATION_MISMATCH") throw i;
|
|
2039
2039
|
M("CREDENTIAL_CONFIRMATION_MISMATCH");
|
|
2040
2040
|
} finally {
|
|
2041
|
-
this.#L(), this.#
|
|
2041
|
+
this.#L(), this.#R(), this.#S -= 1;
|
|
2042
2042
|
}
|
|
2043
2043
|
}
|
|
2044
2044
|
#t(t) {
|
|
@@ -2049,19 +2049,19 @@ class Zs {
|
|
|
2049
2049
|
if (this.#v.has(t)) return !1;
|
|
2050
2050
|
this.#v.add(t);
|
|
2051
2051
|
try {
|
|
2052
|
-
return this.#
|
|
2052
|
+
return this.#r.destroySdnIdentity(t), this.#e.delete(t), !0;
|
|
2053
2053
|
} catch {
|
|
2054
2054
|
return !1;
|
|
2055
2055
|
} finally {
|
|
2056
2056
|
this.#v.delete(t);
|
|
2057
2057
|
}
|
|
2058
2058
|
}
|
|
2059
|
-
#
|
|
2059
|
+
#R() {
|
|
2060
2060
|
for (const t of [...this.#e]) this.#p(t);
|
|
2061
2061
|
}
|
|
2062
2062
|
#L() {
|
|
2063
|
-
const t = [...this.#
|
|
2064
|
-
this.#
|
|
2063
|
+
const t = [...this.#i];
|
|
2064
|
+
this.#i.clear();
|
|
2065
2065
|
for (const n of t) $n(n);
|
|
2066
2066
|
}
|
|
2067
2067
|
}
|
|
@@ -2069,8 +2069,8 @@ async function eo({
|
|
|
2069
2069
|
wasm: e,
|
|
2070
2070
|
profile: t,
|
|
2071
2071
|
operation: n,
|
|
2072
|
-
credentials:
|
|
2073
|
-
accountIndex:
|
|
2072
|
+
credentials: r,
|
|
2073
|
+
accountIndex: i = 0,
|
|
2074
2074
|
assertCurrent: s = () => {
|
|
2075
2075
|
},
|
|
2076
2076
|
ownHandle: a = () => {
|
|
@@ -2078,7 +2078,7 @@ async function eo({
|
|
|
2078
2078
|
}) {
|
|
2079
2079
|
const o = e?.sdn ?? e;
|
|
2080
2080
|
let c;
|
|
2081
|
-
return t === "password-fast-v1-legacy" ? (typeof o?.deriveLegacyPasswordIdentity != "function" && M("INVALID_LEGACY_PROFILE"), c = await o.deriveLegacyPasswordIdentity({ accountIndex:
|
|
2081
|
+
return t === "password-fast-v1-legacy" ? (typeof o?.deriveLegacyPasswordIdentity != "function" && M("INVALID_LEGACY_PROFILE"), c = await o.deriveLegacyPasswordIdentity({ accountIndex: i, ...r })) : t === "bip39-mnemonic-v1-legacy" ? (typeof o?.importLegacyMnemonicIdentity != "function" && M("INVALID_LEGACY_PROFILE"), c = await o.importLegacyMnemonicIdentity({ accountIndex: i, ...r })) : M("INVALID_LEGACY_PROFILE"), c?.handle !== null && c?.handle !== void 0 && a(c.handle), s(), Object.freeze({
|
|
2082
2082
|
approval: null,
|
|
2083
2083
|
handle: c.handle,
|
|
2084
2084
|
identity: Be(c.identity),
|
|
@@ -2089,79 +2089,79 @@ function to(e, { document: t = e.ownerDocument } = {}) {
|
|
|
2089
2089
|
e.replaceChildren();
|
|
2090
2090
|
const n = t.createElement("h2");
|
|
2091
2091
|
n.textContent = "Migrate legacy wallet";
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2094
|
-
const
|
|
2095
|
-
|
|
2092
|
+
const r = t.createElement("p");
|
|
2093
|
+
r.textContent = "Select the exact legacy profile and compare its legacy xpub and authentication key.";
|
|
2094
|
+
const i = t.createElement("select");
|
|
2095
|
+
i.dataset.walletLegacyProfile = "required";
|
|
2096
2096
|
for (const [o, c] of [
|
|
2097
2097
|
["password-fast-v1-legacy", "Legacy fast-password profile"],
|
|
2098
2098
|
["bip39-mnemonic-v1-legacy", "Legacy BIP-39 mnemonic import"]
|
|
2099
2099
|
]) {
|
|
2100
2100
|
const l = t.createElement("option");
|
|
2101
|
-
l.value = o, l.textContent = c,
|
|
2101
|
+
l.value = o, l.textContent = c, i.append(l);
|
|
2102
2102
|
}
|
|
2103
2103
|
const s = t.createElement("button");
|
|
2104
2104
|
s.type = "button", s.dataset.walletAction = "launch-legacy-migration", s.textContent = "Compare selected legacy account";
|
|
2105
2105
|
const a = t.createElement("div");
|
|
2106
|
-
return a.className = "wallet-legacy-comparison", e.append(n,
|
|
2106
|
+
return a.className = "wallet-legacy-comparison", e.append(n, r, i, s, a), Object.freeze({ launch: s, result: a, select: i });
|
|
2107
2107
|
}
|
|
2108
|
-
const Tt = Uint8Array,
|
|
2108
|
+
const Tt = Uint8Array, Dr = ArrayBuffer, mn = Object.getPrototypeOf(Tt.prototype), no = Object.getOwnPropertyDescriptor(mn, "buffer").get, ro = Object.getOwnPropertyDescriptor(mn, "byteLength").get, io = Object.getOwnPropertyDescriptor(mn, "byteOffset").get, so = Object.getOwnPropertyDescriptor(Dr.prototype, "byteLength").get;
|
|
2109
2109
|
class oo extends Error {
|
|
2110
2110
|
constructor(t = "RNG_FAILURE") {
|
|
2111
2111
|
super(t), this.name = "WalletRandomError", this.code = t;
|
|
2112
2112
|
}
|
|
2113
2113
|
}
|
|
2114
|
-
function
|
|
2114
|
+
function Oe() {
|
|
2115
2115
|
throw new oo();
|
|
2116
2116
|
}
|
|
2117
2117
|
function ao(e) {
|
|
2118
2118
|
if (!(e instanceof Tt) || Object.getPrototypeOf(e) !== Tt.prototype) return null;
|
|
2119
|
-
let t, n,
|
|
2119
|
+
let t, n, r;
|
|
2120
2120
|
try {
|
|
2121
|
-
t = Reflect.apply(no, e, []), n = Reflect.apply(
|
|
2121
|
+
t = Reflect.apply(no, e, []), n = Reflect.apply(ro, e, []), r = Reflect.apply(io, e, []);
|
|
2122
2122
|
} catch {
|
|
2123
2123
|
return null;
|
|
2124
2124
|
}
|
|
2125
|
-
let
|
|
2125
|
+
let i;
|
|
2126
2126
|
try {
|
|
2127
|
-
|
|
2127
|
+
i = Reflect.apply(so, t, []);
|
|
2128
2128
|
} catch {
|
|
2129
2129
|
return null;
|
|
2130
2130
|
}
|
|
2131
|
-
return Object.getPrototypeOf(t) !==
|
|
2131
|
+
return Object.getPrototypeOf(t) !== Dr.prototype || r !== 0 || n !== i || n !== 12 && n !== 32 ? null : t;
|
|
2132
2132
|
}
|
|
2133
2133
|
function co({ getRandomValues: e, observedWrite: t } = {}) {
|
|
2134
2134
|
if (typeof e != "function")
|
|
2135
|
-
return () =>
|
|
2136
|
-
const n = /* @__PURE__ */ new WeakSet(),
|
|
2135
|
+
return () => Oe();
|
|
2136
|
+
const n = /* @__PURE__ */ new WeakSet(), r = /* @__PURE__ */ new WeakSet();
|
|
2137
2137
|
return function(s) {
|
|
2138
2138
|
const a = ao(s);
|
|
2139
|
-
(!a || n.has(s) ||
|
|
2139
|
+
(!a || n.has(s) || r.has(a)) && Oe(), n.add(s), r.add(a);
|
|
2140
2140
|
let o;
|
|
2141
2141
|
try {
|
|
2142
2142
|
o = e(s);
|
|
2143
2143
|
} catch {
|
|
2144
|
-
|
|
2144
|
+
Oe();
|
|
2145
2145
|
}
|
|
2146
|
-
if (o !== s &&
|
|
2147
|
-
typeof t != "function" &&
|
|
2146
|
+
if (o !== s && Oe(), t !== void 0) {
|
|
2147
|
+
typeof t != "function" && Oe();
|
|
2148
2148
|
let c = !1;
|
|
2149
2149
|
try {
|
|
2150
2150
|
c = t(s) === !0;
|
|
2151
2151
|
} catch {
|
|
2152
|
-
|
|
2152
|
+
Oe();
|
|
2153
2153
|
}
|
|
2154
|
-
c ||
|
|
2154
|
+
c || Oe();
|
|
2155
2155
|
}
|
|
2156
2156
|
return s;
|
|
2157
2157
|
};
|
|
2158
2158
|
}
|
|
2159
2159
|
function qe(e, t) {
|
|
2160
|
-
(typeof e != "function" || t !== 12 && t !== 32) &&
|
|
2160
|
+
(typeof e != "function" || t !== 12 && t !== 32) && Oe();
|
|
2161
2161
|
const n = new Tt(t);
|
|
2162
2162
|
return e(n);
|
|
2163
2163
|
}
|
|
2164
|
-
const Et = new TextEncoder(), lo = new TextDecoder("utf-8", { fatal: !0 }), uo = Uint8Array.prototype.fill, fo = Uint8Array.prototype.slice, po = Uint8Array.prototype.subarray, gn = Object.getPrototypeOf(Uint8Array.prototype), ho = Object.getOwnPropertyDescriptor(gn, "buffer").get,
|
|
2164
|
+
const Et = new TextEncoder(), lo = new TextDecoder("utf-8", { fatal: !0 }), uo = Uint8Array.prototype.fill, fo = Uint8Array.prototype.slice, po = Uint8Array.prototype.subarray, gn = Object.getPrototypeOf(Uint8Array.prototype), ho = Object.getOwnPropertyDescriptor(gn, "buffer").get, Pr = Object.getOwnPropertyDescriptor(gn, "byteLength").get, yo = Object.getOwnPropertyDescriptor(gn, "byteOffset").get, kr = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get, mo = ArrayBuffer.prototype.slice, Wn = "webauthn-prf-hkdf-sha256-aes256gcm-v2", go = "sdn-bip32-slip10-purpose-v1", Ao = "password-scrypt-v2", bo = "Space Data Network Wallet", Ur = 12e4;
|
|
2165
2165
|
class Eo extends Error {
|
|
2166
2166
|
constructor(t) {
|
|
2167
2167
|
super(t), this.name = "RememberedWalletError", this.code = t;
|
|
@@ -2170,17 +2170,17 @@ class Eo extends Error {
|
|
|
2170
2170
|
function x(e) {
|
|
2171
2171
|
throw new Eo(e);
|
|
2172
2172
|
}
|
|
2173
|
-
function
|
|
2173
|
+
function Hn(e) {
|
|
2174
2174
|
if (typeof e != "string") return "";
|
|
2175
2175
|
const t = e.trim().toLowerCase();
|
|
2176
2176
|
return t.endsWith(".") ? t.slice(0, -1) : t;
|
|
2177
2177
|
}
|
|
2178
2178
|
function wo(e, t) {
|
|
2179
2179
|
if (e == null || e === "") return;
|
|
2180
|
-
const n =
|
|
2180
|
+
const n = Hn(e);
|
|
2181
2181
|
n === "" && x("INVALID_RP_ID");
|
|
2182
|
-
const
|
|
2183
|
-
if (
|
|
2182
|
+
const r = Hn(t);
|
|
2183
|
+
if (r === "" || n === r || r.endsWith(`.${n}`)) return n;
|
|
2184
2184
|
x("INVALID_RP_ID");
|
|
2185
2185
|
}
|
|
2186
2186
|
function k(e) {
|
|
@@ -2195,7 +2195,7 @@ function _t(e) {
|
|
|
2195
2195
|
const t = Object.getPrototypeOf(e);
|
|
2196
2196
|
return t === Object.prototype || t === null;
|
|
2197
2197
|
}
|
|
2198
|
-
function
|
|
2198
|
+
function Br(e, t) {
|
|
2199
2199
|
if (!_t(e)) return !1;
|
|
2200
2200
|
let n;
|
|
2201
2201
|
try {
|
|
@@ -2204,50 +2204,50 @@ function Bi(e, t) {
|
|
|
2204
2204
|
return !1;
|
|
2205
2205
|
}
|
|
2206
2206
|
if (n.some((s) => typeof s != "string")) return !1;
|
|
2207
|
-
const
|
|
2208
|
-
return
|
|
2207
|
+
const r = [...n].sort(), i = [...t].sort();
|
|
2208
|
+
return r.length === i.length && r.every((s, a) => s === i[a]);
|
|
2209
2209
|
}
|
|
2210
2210
|
function st(e, t) {
|
|
2211
|
-
if (!
|
|
2211
|
+
if (!Br(e, t)) return null;
|
|
2212
2212
|
const n = {};
|
|
2213
|
-
for (const
|
|
2214
|
-
let
|
|
2213
|
+
for (const r of t) {
|
|
2214
|
+
let i;
|
|
2215
2215
|
try {
|
|
2216
|
-
|
|
2216
|
+
i = Object.getOwnPropertyDescriptor(e, r);
|
|
2217
2217
|
} catch {
|
|
2218
2218
|
return null;
|
|
2219
2219
|
}
|
|
2220
|
-
if (!
|
|
2220
|
+
if (!i?.enumerable || !("value" in i) || i.value === void 0)
|
|
2221
2221
|
return null;
|
|
2222
|
-
n[
|
|
2222
|
+
n[r] = i.value;
|
|
2223
2223
|
}
|
|
2224
2224
|
return n;
|
|
2225
2225
|
}
|
|
2226
2226
|
function wt(e, t = null) {
|
|
2227
2227
|
if (!(e instanceof Uint8Array) || Object.getPrototypeOf(e) !== Uint8Array.prototype)
|
|
2228
2228
|
return !1;
|
|
2229
|
-
let n,
|
|
2229
|
+
let n, r, i, s;
|
|
2230
2230
|
try {
|
|
2231
|
-
n = Reflect.apply(ho, e, []),
|
|
2231
|
+
n = Reflect.apply(ho, e, []), r = Reflect.apply(Pr, e, []), i = Reflect.apply(yo, e, []), s = Reflect.apply(kr, n, []);
|
|
2232
2232
|
} catch {
|
|
2233
2233
|
return !1;
|
|
2234
2234
|
}
|
|
2235
|
-
return Object.getPrototypeOf(n) === ArrayBuffer.prototype &&
|
|
2235
|
+
return Object.getPrototypeOf(n) === ArrayBuffer.prototype && i === 0 && r === s && (t === null || r === t);
|
|
2236
2236
|
}
|
|
2237
|
-
function
|
|
2237
|
+
function jr(e, t, n) {
|
|
2238
2238
|
if (!(e instanceof ArrayBuffer) || Object.getPrototypeOf(e) !== ArrayBuffer.prototype)
|
|
2239
2239
|
return !1;
|
|
2240
|
-
let
|
|
2240
|
+
let r;
|
|
2241
2241
|
try {
|
|
2242
|
-
|
|
2242
|
+
r = Reflect.apply(kr, e, []);
|
|
2243
2243
|
} catch {
|
|
2244
2244
|
return !1;
|
|
2245
2245
|
}
|
|
2246
|
-
return
|
|
2246
|
+
return r >= t && r <= n;
|
|
2247
2247
|
}
|
|
2248
2248
|
function Pe(e) {
|
|
2249
2249
|
try {
|
|
2250
|
-
return Reflect.apply(
|
|
2250
|
+
return Reflect.apply(Pr, e, []);
|
|
2251
2251
|
} catch {
|
|
2252
2252
|
return -1;
|
|
2253
2253
|
}
|
|
@@ -2256,11 +2256,11 @@ function Ze(e) {
|
|
|
2256
2256
|
let t = "";
|
|
2257
2257
|
const n = Pe(e);
|
|
2258
2258
|
n < 0 && x("INVALID_REMEMBERED_WALLET");
|
|
2259
|
-
for (let
|
|
2259
|
+
for (let r = 0; r < n; r += 32768)
|
|
2260
2260
|
t += String.fromCharCode(...Reflect.apply(
|
|
2261
2261
|
po,
|
|
2262
2262
|
e,
|
|
2263
|
-
[
|
|
2263
|
+
[r, r + 32768]
|
|
2264
2264
|
));
|
|
2265
2265
|
return btoa(t).replace(/\+/gu, "-").replace(/\//gu, "_").replace(/=+$/u, "");
|
|
2266
2266
|
}
|
|
@@ -2269,54 +2269,54 @@ function Io(e) {
|
|
|
2269
2269
|
for (const n of e) t += n.toString(16).padStart(2, "0");
|
|
2270
2270
|
return t;
|
|
2271
2271
|
}
|
|
2272
|
-
function
|
|
2273
|
-
return e === null || typeof e == "boolean" || typeof e == "string" || typeof e == "number" && Number.isFinite(e) ? JSON.stringify(e) : Array.isArray(e) ? `[${e.map(
|
|
2272
|
+
function He(e) {
|
|
2273
|
+
return e === null || typeof e == "boolean" || typeof e == "string" || typeof e == "number" && Number.isFinite(e) ? JSON.stringify(e) : Array.isArray(e) ? `[${e.map(He).join(",")}]` : (_t(e) || x("INVALID_REMEMBERED_WALLET"), `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${He(e[t])}`).join(",")}}`);
|
|
2274
2274
|
}
|
|
2275
2275
|
function vo(e, t) {
|
|
2276
2276
|
if (!(e instanceof Uint8Array) || !(t instanceof Uint8Array)) return !1;
|
|
2277
|
-
const n = Pe(e),
|
|
2278
|
-
if (n < 0 ||
|
|
2279
|
-
const
|
|
2280
|
-
let s = n ^
|
|
2281
|
-
for (let a = 0; a <
|
|
2277
|
+
const n = Pe(e), r = Pe(t);
|
|
2278
|
+
if (n < 0 || r < 0) return !1;
|
|
2279
|
+
const i = Math.max(n, r);
|
|
2280
|
+
let s = n ^ r;
|
|
2281
|
+
for (let a = 0; a < i; a += 1)
|
|
2282
2282
|
s |= (e[a] ?? 0) ^ (t[a] ?? 0);
|
|
2283
2283
|
return s === 0;
|
|
2284
2284
|
}
|
|
2285
2285
|
function So(e, t) {
|
|
2286
|
-
return
|
|
2286
|
+
return He(e) === He(t);
|
|
2287
2287
|
}
|
|
2288
|
-
function
|
|
2288
|
+
function Vr(e) {
|
|
2289
2289
|
(!e || typeof e != "object" && typeof e != "function") && x("WEBAUTHN_INVALID_RESPONSE");
|
|
2290
|
-
let t, n,
|
|
2290
|
+
let t, n, r;
|
|
2291
2291
|
try {
|
|
2292
|
-
t = e.type, n = e.rawId,
|
|
2292
|
+
t = e.type, n = e.rawId, r = e.getClientExtensionResults;
|
|
2293
2293
|
} catch {
|
|
2294
2294
|
x("WEBAUTHN_INVALID_RESPONSE");
|
|
2295
2295
|
}
|
|
2296
|
-
return (t !== "public-key" || !
|
|
2296
|
+
return (t !== "public-key" || !jr(n, 1, 1024) || typeof r != "function") && x("WEBAUTHN_INVALID_RESPONSE"), Object.freeze({
|
|
2297
2297
|
rawId: new Uint8Array(Reflect.apply(mo, n, [0])),
|
|
2298
2298
|
readExtensionResults() {
|
|
2299
2299
|
try {
|
|
2300
|
-
return Reflect.apply(
|
|
2300
|
+
return Reflect.apply(r, e, []);
|
|
2301
2301
|
} catch {
|
|
2302
2302
|
x("WEBAUTHN_PRF_REQUIRED");
|
|
2303
2303
|
}
|
|
2304
2304
|
}
|
|
2305
2305
|
});
|
|
2306
2306
|
}
|
|
2307
|
-
function
|
|
2307
|
+
function Ro(e) {
|
|
2308
2308
|
const t = st(e.readExtensionResults(), ["prf"]), n = t ? st(t.prf, ["enabled"]) : null;
|
|
2309
2309
|
(!n || n.enabled !== !0) && x("WEBAUTHN_PRF_REQUIRED");
|
|
2310
2310
|
}
|
|
2311
|
-
function
|
|
2312
|
-
const n =
|
|
2313
|
-
vo(
|
|
2314
|
-
const
|
|
2315
|
-
|
|
2311
|
+
function Oo(e, t) {
|
|
2312
|
+
const n = Vr(e), r = n.rawId;
|
|
2313
|
+
vo(r, t) || (k(r), x("WEBAUTHN_CREDENTIAL_MISMATCH")), k(r);
|
|
2314
|
+
const i = st(n.readExtensionResults(), ["prf"]), s = i ? st(i.prf, ["results"]) : null, o = (s ? st(s.results, ["first"]) : null)?.first;
|
|
2315
|
+
jr(o, 32, 32) || x("WEBAUTHN_PRF_REQUIRED");
|
|
2316
2316
|
const c = new Uint8Array(o), l = Reflect.apply(fo, c, []);
|
|
2317
2317
|
return k(c), l;
|
|
2318
2318
|
}
|
|
2319
|
-
function Lo({ challenge: e, credentialId: t, prfInput: n, rpId:
|
|
2319
|
+
function Lo({ challenge: e, credentialId: t, prfInput: n, rpId: r, signal: i }) {
|
|
2320
2320
|
return {
|
|
2321
2321
|
publicKey: {
|
|
2322
2322
|
allowCredentials: [{
|
|
@@ -2325,21 +2325,21 @@ function Lo({ challenge: e, credentialId: t, prfInput: n, rpId: i, signal: r })
|
|
|
2325
2325
|
}],
|
|
2326
2326
|
challenge: e,
|
|
2327
2327
|
extensions: { prf: { eval: { first: n } } },
|
|
2328
|
-
...
|
|
2329
|
-
timeout:
|
|
2328
|
+
...r === void 0 ? {} : { rpId: r },
|
|
2329
|
+
timeout: Ur,
|
|
2330
2330
|
userVerification: "required"
|
|
2331
2331
|
},
|
|
2332
|
-
signal:
|
|
2332
|
+
signal: i
|
|
2333
2333
|
};
|
|
2334
2334
|
}
|
|
2335
|
-
async function
|
|
2336
|
-
const o = qe(
|
|
2335
|
+
async function zn({ assertCurrent: e, credentials: t, credentialId: n, fillRandom: r, prfInput: i, rpId: s, signal: a }) {
|
|
2336
|
+
const o = qe(r, 32);
|
|
2337
2337
|
let c;
|
|
2338
2338
|
try {
|
|
2339
2339
|
c = await t.get(Lo({
|
|
2340
2340
|
challenge: o,
|
|
2341
2341
|
credentialId: n,
|
|
2342
|
-
prfInput:
|
|
2342
|
+
prfInput: i,
|
|
2343
2343
|
rpId: s,
|
|
2344
2344
|
signal: a
|
|
2345
2345
|
}));
|
|
@@ -2348,15 +2348,15 @@ async function Hn({ assertCurrent: e, credentials: t, credentialId: n, fillRando
|
|
|
2348
2348
|
} finally {
|
|
2349
2349
|
k(o);
|
|
2350
2350
|
}
|
|
2351
|
-
return e(),
|
|
2351
|
+
return e(), Oo(c, n);
|
|
2352
2352
|
}
|
|
2353
2353
|
function No(e) {
|
|
2354
2354
|
if (typeof e != "string") return !1;
|
|
2355
2355
|
for (let t = 0; t < e.length; t += 1) {
|
|
2356
2356
|
const n = e.charCodeAt(t);
|
|
2357
2357
|
if (n >= 55296 && n <= 56319) {
|
|
2358
|
-
const
|
|
2359
|
-
if (!(
|
|
2358
|
+
const r = e.charCodeAt(++t);
|
|
2359
|
+
if (!(r >= 56320 && r <= 57343)) return !1;
|
|
2360
2360
|
} else if (n >= 56320 && n <= 57343)
|
|
2361
2361
|
return !1;
|
|
2362
2362
|
}
|
|
@@ -2374,19 +2374,19 @@ function To(e) {
|
|
|
2374
2374
|
}
|
|
2375
2375
|
function en(e) {
|
|
2376
2376
|
const t = To(e).replace(/^ +/u, "").replace(/ +$/u, "").replace(/[A-Z]/gu, (n) => n.toLowerCase());
|
|
2377
|
-
return
|
|
2377
|
+
return Nr(t) || x("INVALID_USERNAME"), t;
|
|
2378
2378
|
}
|
|
2379
2379
|
function _o(e) {
|
|
2380
2380
|
let t;
|
|
2381
2381
|
try {
|
|
2382
|
-
t =
|
|
2382
|
+
t = tr(e?.module);
|
|
2383
2383
|
} catch {
|
|
2384
2384
|
x("WASM_UNAVAILABLE");
|
|
2385
2385
|
}
|
|
2386
|
-
return (!
|
|
2386
|
+
return (!Br(t, ["sdn", "sha256"]) || typeof t.sha256 != "function" || !t.sdn || typeof t.sdn != "object") && x("WASM_UNAVAILABLE"), t;
|
|
2387
2387
|
}
|
|
2388
2388
|
function Co(e) {
|
|
2389
|
-
const t = _o(e), n = t.sdn,
|
|
2389
|
+
const t = _o(e), n = t.sdn, r = e?.storage, i = e?.credentials, s = co(e?.rng), a = e?.createRequestController, o = e?.releaseRequestController, c = e?.ownHandle, l = e?.destroyHandle, d = e?.ownedHandlesClean, u = e?.now ?? (() => /* @__PURE__ */ new Date()), p = e?.rpHostname ?? e?.window?.location?.hostname ?? globalThis?.location?.hostname, f = wo(e?.rpId, p), A = typeof e?.rpName == "string" && e.rpName !== "" ? e.rpName : bo, b = () => typeof i?.create == "function" && typeof i?.get == "function", h = () => _r(r), m = () => js(r), g = (T) => Vs(r, T), S = (T, q) => ($s(r, T, q), m().some((v) => v.key === T) && x("STORAGE_WRITE_FAILED"), !0), I = () => h().active.status === "valid", U = ({ confirmation: T } = {}) => (I() || x("REMEMBER_UNAVAILABLE"), Ms(r, T), h().active.status !== "empty" && x("STORAGE_WRITE_FAILED"), !0), P = async (T) => {
|
|
2390
2390
|
let q;
|
|
2391
2391
|
try {
|
|
2392
2392
|
q = await t.sha256(Et.encode(T));
|
|
@@ -2414,14 +2414,14 @@ function Co(e) {
|
|
|
2414
2414
|
}), oe = Ae(v.prfInputBase64url, { exact: 32 }), X = Ae(v.ciphertextBase64url, {
|
|
2415
2415
|
minimum: 17,
|
|
2416
2416
|
maximum: 1024
|
|
2417
|
-
}), B = Ae(v.hkdfSaltBase64url, { exact: 32 }), N = Ae(v.nonceBase64url, { exact: 12 }), K = Et.encode(v.canonicalUsername), Z =
|
|
2417
|
+
}), B = Ae(v.hkdfSaltBase64url, { exact: 32 }), N = Ae(v.nonceBase64url, { exact: 12 }), K = Et.encode(v.canonicalUsername), Z = He(v.aad), G = typeof a == "function" ? a() : null;
|
|
2418
2418
|
(!G?.signal || typeof G.abort != "function") && (k(_), k(oe), k(X), k(B), k(N), k(K), x("WEBAUTHN_UNAVAILABLE"));
|
|
2419
|
-
let Y,
|
|
2419
|
+
let Y, re = null, ae = !1;
|
|
2420
2420
|
try {
|
|
2421
|
-
Y = await
|
|
2421
|
+
Y = await zn({
|
|
2422
2422
|
assertCurrent: T,
|
|
2423
2423
|
credentialId: _,
|
|
2424
|
-
credentials:
|
|
2424
|
+
credentials: i,
|
|
2425
2425
|
fillRandom: s,
|
|
2426
2426
|
prfInput: oe,
|
|
2427
2427
|
rpId: f,
|
|
@@ -2441,26 +2441,26 @@ function Co(e) {
|
|
|
2441
2441
|
} finally {
|
|
2442
2442
|
k(le), Y = null;
|
|
2443
2443
|
}
|
|
2444
|
-
_t(se) || x("WASM_FAILURE"),
|
|
2444
|
+
_t(se) || x("WASM_FAILURE"), re = se.handle, (re == null || typeof c != "function") && x("WASM_FAILURE"), c(re);
|
|
2445
2445
|
const Q = ge(se.identity);
|
|
2446
|
-
return T(), ae = !0, Object.freeze({ handle:
|
|
2446
|
+
return T(), ae = !0, Object.freeze({ handle: re, identity: Q });
|
|
2447
2447
|
} finally {
|
|
2448
|
-
!ae &&
|
|
2448
|
+
!ae && re !== null && typeof l == "function" && (l(re) || x("DESTRUCTION_FAILED")), k(Y), k(_), k(oe), k(X), k(B), k(N), k(K), typeof o == "function" && o(G);
|
|
2449
2449
|
}
|
|
2450
2450
|
},
|
|
2451
|
-
setup: async ({ assertCurrent: T, canonicalUsername: q, handle: v, identity:
|
|
2451
|
+
setup: async ({ assertCurrent: T, canonicalUsername: q, handle: v, identity: H, passwordUtf8: _ }) => {
|
|
2452
2452
|
try {
|
|
2453
2453
|
(typeof T != "function" || v === null || v === void 0 || !wt(_) || Pe(_) === 0 || Pe(_) > 256 || en(q) !== q || !b() || typeof n.sealRememberedIdentity != "function" || typeof n.importRememberedIdentity != "function" || typeof c != "function" || typeof l != "function" || typeof d != "function" || typeof a != "function" || typeof o != "function") && (k(_), x("REMEMBER_UNAVAILABLE"));
|
|
2454
|
-
const oe = ge(
|
|
2454
|
+
const oe = ge(H);
|
|
2455
2455
|
h().canSetup || (k(_), x("STORAGE_QUARANTINED"));
|
|
2456
2456
|
const B = typeof a == "function" ? a() : null;
|
|
2457
2457
|
(!B?.signal || typeof B.abort != "function") && (k(_), x("WEBAUTHN_UNAVAILABLE"));
|
|
2458
|
-
let N, K, Z, G, Y,
|
|
2458
|
+
let N, K, Z, G, Y, re, ae, se, le, Q = null, Ne = null;
|
|
2459
2459
|
try {
|
|
2460
2460
|
N = qe(s, 32), K = qe(s, 32), Z = qe(s, 32), G = qe(s, 32), Y = qe(s, 12), T();
|
|
2461
2461
|
let $e;
|
|
2462
2462
|
try {
|
|
2463
|
-
$e = await
|
|
2463
|
+
$e = await i.create({
|
|
2464
2464
|
publicKey: {
|
|
2465
2465
|
attestation: "none",
|
|
2466
2466
|
authenticatorSelection: {
|
|
@@ -2474,7 +2474,7 @@ function Co(e) {
|
|
|
2474
2474
|
{ alg: -257, type: "public-key" }
|
|
2475
2475
|
],
|
|
2476
2476
|
rp: f === void 0 ? { name: A } : { id: f, name: A },
|
|
2477
|
-
timeout:
|
|
2477
|
+
timeout: Ur,
|
|
2478
2478
|
user: {
|
|
2479
2479
|
displayName: q,
|
|
2480
2480
|
id: K,
|
|
@@ -2487,11 +2487,11 @@ function Co(e) {
|
|
|
2487
2487
|
throw T(), Ce;
|
|
2488
2488
|
}
|
|
2489
2489
|
T();
|
|
2490
|
-
const Ke =
|
|
2491
|
-
|
|
2490
|
+
const Ke = Vr($e);
|
|
2491
|
+
re = Ke.rawId, Ro(Ke), ae = await zn({
|
|
2492
2492
|
assertCurrent: T,
|
|
2493
|
-
credentialId:
|
|
2494
|
-
credentials:
|
|
2493
|
+
credentialId: re,
|
|
2494
|
+
credentials: i,
|
|
2495
2495
|
fillRandom: s,
|
|
2496
2496
|
prfInput: Z,
|
|
2497
2497
|
rpId: f,
|
|
@@ -2499,17 +2499,17 @@ function Co(e) {
|
|
|
2499
2499
|
}), se = ae.slice(), le = ae.slice(), k(ae), ae = null;
|
|
2500
2500
|
const Se = await P(q);
|
|
2501
2501
|
T();
|
|
2502
|
-
const Me = Ze(
|
|
2502
|
+
const Me = Ze(re), Ge = Object.freeze({
|
|
2503
2503
|
credentialIdBase64url: Me,
|
|
2504
2504
|
identityScheme: go,
|
|
2505
2505
|
schemaVersion: 2,
|
|
2506
2506
|
seedProfile: Ao,
|
|
2507
2507
|
storageProfile: Wn,
|
|
2508
2508
|
usernameSha256: Se
|
|
2509
|
-
}), Je =
|
|
2510
|
-
let
|
|
2509
|
+
}), Je = He(Ge);
|
|
2510
|
+
let Re;
|
|
2511
2511
|
try {
|
|
2512
|
-
|
|
2512
|
+
Re = n.sealRememberedIdentity(v, {
|
|
2513
2513
|
canonicalAad: Je,
|
|
2514
2514
|
hkdfSalt: G,
|
|
2515
2515
|
nonce: Y,
|
|
@@ -2520,8 +2520,8 @@ function Co(e) {
|
|
|
2520
2520
|
k(_), k(se);
|
|
2521
2521
|
}
|
|
2522
2522
|
_ = null, se = null;
|
|
2523
|
-
const Te = Pe(
|
|
2524
|
-
(!wt(
|
|
2523
|
+
const Te = Pe(Re);
|
|
2524
|
+
(!wt(Re) || Te < 17 || Te > 1024) && x("WASM_FAILURE");
|
|
2525
2525
|
let Ye;
|
|
2526
2526
|
try {
|
|
2527
2527
|
const Ce = u();
|
|
@@ -2532,7 +2532,7 @@ function Co(e) {
|
|
|
2532
2532
|
const ft = Object.freeze({
|
|
2533
2533
|
aad: Ge,
|
|
2534
2534
|
canonicalUsername: q,
|
|
2535
|
-
ciphertextBase64url: Ze(
|
|
2535
|
+
ciphertextBase64url: Ze(Re),
|
|
2536
2536
|
createdAt: Ye,
|
|
2537
2537
|
credentialIdBase64url: Me,
|
|
2538
2538
|
hkdfSaltBase64url: Ze(G),
|
|
@@ -2541,14 +2541,14 @@ function Co(e) {
|
|
|
2541
2541
|
schemaVersion: 2,
|
|
2542
2542
|
storageProfile: Wn
|
|
2543
2543
|
});
|
|
2544
|
-
T(), Ne = ks(
|
|
2544
|
+
T(), Ne = ks(r, ft);
|
|
2545
2545
|
let _e;
|
|
2546
2546
|
const Qe = le;
|
|
2547
2547
|
try {
|
|
2548
2548
|
_e = n.importRememberedIdentity({
|
|
2549
2549
|
canonicalAad: Je,
|
|
2550
2550
|
canonicalUsernameUtf8: Et.encode(q),
|
|
2551
|
-
ciphertextAndTag:
|
|
2551
|
+
ciphertextAndTag: Re.slice(),
|
|
2552
2552
|
hkdfSalt: G.slice(),
|
|
2553
2553
|
nonce: Y.slice(),
|
|
2554
2554
|
prfOutput: Qe
|
|
@@ -2558,9 +2558,9 @@ function Co(e) {
|
|
|
2558
2558
|
}
|
|
2559
2559
|
_t(_e) || x("WASM_FAILURE"), Q = _e.handle, (Q == null || typeof c != "function") && x("WASM_FAILURE"), c(Q);
|
|
2560
2560
|
const pt = ge(_e.identity);
|
|
2561
|
-
return So(oe, pt) || x("IDENTITY_MISMATCH"), T(), (typeof l != "function" || !l(Q)) && x("DESTRUCTION_FAILED"), Q = null, (typeof d != "function" || !d(v)) && x("DESTRUCTION_FAILED"), T(), Us(
|
|
2561
|
+
return So(oe, pt) || x("IDENTITY_MISMATCH"), T(), (typeof l != "function" || !l(Q)) && x("DESTRUCTION_FAILED"), Q = null, (typeof d != "function" || !d(v)) && x("DESTRUCTION_FAILED"), T(), Us(r, Ne), Ne = null, Object.freeze({ remembered: !0 });
|
|
2562
2562
|
} finally {
|
|
2563
|
-
Q !== null && typeof l == "function" && l(Q), k(_), k(N), k(K), k(ae), k(se), k(le), k(G), k(Y), k(
|
|
2563
|
+
Q !== null && typeof l == "function" && l(Q), k(_), k(N), k(K), k(ae), k(se), k(le), k(G), k(Y), k(re), typeof o == "function" && o(B);
|
|
2564
2564
|
}
|
|
2565
2565
|
} finally {
|
|
2566
2566
|
k(_);
|
|
@@ -2592,13 +2592,13 @@ class Ct extends Error {
|
|
|
2592
2592
|
function D() {
|
|
2593
2593
|
throw new Ct();
|
|
2594
2594
|
}
|
|
2595
|
-
function $
|
|
2595
|
+
function $r(e) {
|
|
2596
2596
|
if (e === null || typeof e != "object" || Array.isArray(e)) return !1;
|
|
2597
2597
|
const t = Object.getPrototypeOf(e);
|
|
2598
2598
|
return t === Object.prototype || t === null;
|
|
2599
2599
|
}
|
|
2600
|
-
function
|
|
2601
|
-
$
|
|
2600
|
+
function Mr(e, t) {
|
|
2601
|
+
$r(e) || D();
|
|
2602
2602
|
let n;
|
|
2603
2603
|
try {
|
|
2604
2604
|
n = Reflect.ownKeys(e);
|
|
@@ -2606,9 +2606,9 @@ function Mi(e, t) {
|
|
|
2606
2606
|
D();
|
|
2607
2607
|
}
|
|
2608
2608
|
n.some((s) => typeof s != "string") && D();
|
|
2609
|
-
const
|
|
2610
|
-
(
|
|
2611
|
-
for (const s of
|
|
2609
|
+
const r = [...n].sort(), i = [...t].sort();
|
|
2610
|
+
(r.length !== i.length || r.some((s, a) => s !== i[a])) && D();
|
|
2611
|
+
for (const s of r) {
|
|
2612
2612
|
let a;
|
|
2613
2613
|
try {
|
|
2614
2614
|
a = Object.getOwnPropertyDescriptor(e, s);
|
|
@@ -2621,15 +2621,15 @@ function Mi(e, t) {
|
|
|
2621
2621
|
}
|
|
2622
2622
|
function tn(e) {
|
|
2623
2623
|
if (Array.isArray(e)) return Object.freeze(e.map(tn));
|
|
2624
|
-
if (!$
|
|
2624
|
+
if (!$r(e)) return e;
|
|
2625
2625
|
const t = {};
|
|
2626
2626
|
for (const n of Object.keys(e).sort()) t[n] = tn(e[n]);
|
|
2627
2627
|
return Object.freeze(t);
|
|
2628
2628
|
}
|
|
2629
2629
|
function Vo(e, t) {
|
|
2630
2630
|
(typeof e != "string" || Bo.encode(e).byteLength > t || e.charCodeAt(0) === 65279) && D();
|
|
2631
|
-
let n = 0,
|
|
2632
|
-
const
|
|
2631
|
+
let n = 0, r = 0;
|
|
2632
|
+
const i = () => {
|
|
2633
2633
|
for (; n < e.length && /[\u0009\u000a\u000d\u0020]/u.test(e[n]); ) n += 1;
|
|
2634
2634
|
}, s = () => {
|
|
2635
2635
|
e[n] !== '"' && D();
|
|
@@ -2657,18 +2657,18 @@ function Vo(e, t) {
|
|
|
2657
2657
|
}
|
|
2658
2658
|
D();
|
|
2659
2659
|
}, a = (c = 0) => {
|
|
2660
|
-
(c > 32 || ++
|
|
2660
|
+
(c > 32 || ++r > 4096) && D(), i();
|
|
2661
2661
|
const l = e[n];
|
|
2662
2662
|
if (l === '"') return s();
|
|
2663
2663
|
if (l === "{") {
|
|
2664
2664
|
n += 1;
|
|
2665
2665
|
const p = /* @__PURE__ */ Object.create(null), f = /* @__PURE__ */ new Set();
|
|
2666
|
-
if (
|
|
2666
|
+
if (i(), e[n] === "}")
|
|
2667
2667
|
return n += 1, p;
|
|
2668
2668
|
for (; n < e.length; ) {
|
|
2669
|
-
|
|
2669
|
+
i();
|
|
2670
2670
|
const A = s();
|
|
2671
|
-
if (f.has(A) && D(), f.add(A),
|
|
2671
|
+
if (f.has(A) && D(), f.add(A), i(), e[n] !== ":" && D(), n += 1, p[A] = a(c + 1), i(), e[n] === "}")
|
|
2672
2672
|
return n += 1, p;
|
|
2673
2673
|
e[n] !== "," && D(), n += 1;
|
|
2674
2674
|
}
|
|
@@ -2677,10 +2677,10 @@ function Vo(e, t) {
|
|
|
2677
2677
|
if (l === "[") {
|
|
2678
2678
|
n += 1;
|
|
2679
2679
|
const p = [];
|
|
2680
|
-
if (
|
|
2680
|
+
if (i(), e[n] === "]")
|
|
2681
2681
|
return n += 1, p;
|
|
2682
2682
|
for (; n < e.length; ) {
|
|
2683
|
-
if (p.push(a(c + 1)),
|
|
2683
|
+
if (p.push(a(c + 1)), i(), e[n] === "]")
|
|
2684
2684
|
return n += 1, p;
|
|
2685
2685
|
e[n] !== "," && D(), n += 1;
|
|
2686
2686
|
}
|
|
@@ -2694,9 +2694,9 @@ function Vo(e, t) {
|
|
|
2694
2694
|
const u = Number(d[0]);
|
|
2695
2695
|
return Number.isFinite(u) || D(), u;
|
|
2696
2696
|
};
|
|
2697
|
-
|
|
2697
|
+
i();
|
|
2698
2698
|
const o = a();
|
|
2699
|
-
return
|
|
2699
|
+
return i(), n !== e.length && D(), o;
|
|
2700
2700
|
}
|
|
2701
2701
|
function Kn(e) {
|
|
2702
2702
|
try {
|
|
@@ -2705,7 +2705,7 @@ function Kn(e) {
|
|
|
2705
2705
|
} catch {
|
|
2706
2706
|
}
|
|
2707
2707
|
}
|
|
2708
|
-
function
|
|
2708
|
+
function Fr(e, t = null) {
|
|
2709
2709
|
try {
|
|
2710
2710
|
const n = t?.cancel;
|
|
2711
2711
|
typeof n == "function" && Kn(Reflect.apply(n, t, []));
|
|
@@ -2713,19 +2713,19 @@ function Fi(e, t = null) {
|
|
|
2713
2713
|
}
|
|
2714
2714
|
if (!t)
|
|
2715
2715
|
try {
|
|
2716
|
-
const n = e?.body,
|
|
2717
|
-
typeof
|
|
2716
|
+
const n = e?.body, r = n?.cancel;
|
|
2717
|
+
typeof r == "function" && Kn(Reflect.apply(r, n, []));
|
|
2718
2718
|
} catch {
|
|
2719
2719
|
}
|
|
2720
2720
|
}
|
|
2721
|
-
function
|
|
2722
|
-
let
|
|
2721
|
+
function qr(e, t, n = null) {
|
|
2722
|
+
let r;
|
|
2723
2723
|
try {
|
|
2724
|
-
|
|
2724
|
+
r = Promise.resolve(e);
|
|
2725
2725
|
} catch {
|
|
2726
2726
|
return Promise.reject(new Ct());
|
|
2727
2727
|
}
|
|
2728
|
-
return t ? new Promise((
|
|
2728
|
+
return t ? new Promise((i, s) => {
|
|
2729
2729
|
let a = !1;
|
|
2730
2730
|
const o = () => {
|
|
2731
2731
|
try {
|
|
@@ -2738,9 +2738,9 @@ function qi(e, t, n = null) {
|
|
|
2738
2738
|
} catch {
|
|
2739
2739
|
l();
|
|
2740
2740
|
}
|
|
2741
|
-
|
|
2741
|
+
r.then(
|
|
2742
2742
|
(d) => {
|
|
2743
|
-
if (!c(
|
|
2743
|
+
if (!c(i, d))
|
|
2744
2744
|
try {
|
|
2745
2745
|
n?.(d);
|
|
2746
2746
|
} catch {
|
|
@@ -2750,18 +2750,18 @@ function qi(e, t, n = null) {
|
|
|
2750
2750
|
c(s, d);
|
|
2751
2751
|
}
|
|
2752
2752
|
);
|
|
2753
|
-
}) :
|
|
2753
|
+
}) : r;
|
|
2754
2754
|
}
|
|
2755
|
-
async function $o(e, t, n,
|
|
2756
|
-
let
|
|
2755
|
+
async function $o(e, t, n, r) {
|
|
2756
|
+
let i = null;
|
|
2757
2757
|
try {
|
|
2758
|
-
(!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") && D(),
|
|
2758
|
+
(!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") && D(), i = e.body.getReader(), (!i || typeof i.read != "function" || r?.aborted === !0) && D();
|
|
2759
2759
|
const s = [];
|
|
2760
2760
|
let a = 0;
|
|
2761
2761
|
for (; ; ) {
|
|
2762
|
-
|
|
2763
|
-
const { done: l, value: d } = await
|
|
2764
|
-
if (
|
|
2762
|
+
r?.aborted === !0 && D();
|
|
2763
|
+
const { done: l, value: d } = await qr(i.read(), r);
|
|
2764
|
+
if (r?.aborted === !0 && D(), l) break;
|
|
2765
2765
|
d instanceof Uint8Array || D(), a += d.byteLength, a > n && D(), s.push(d);
|
|
2766
2766
|
}
|
|
2767
2767
|
const o = new Uint8Array(a);
|
|
@@ -2770,31 +2770,31 @@ async function $o(e, t, n, i) {
|
|
|
2770
2770
|
o.set(l, c), c += l.byteLength;
|
|
2771
2771
|
return Vo(jo.decode(o), n);
|
|
2772
2772
|
} catch (s) {
|
|
2773
|
-
if (
|
|
2773
|
+
if (Fr(e, i), s instanceof Ct) throw s;
|
|
2774
2774
|
D();
|
|
2775
2775
|
} finally {
|
|
2776
2776
|
try {
|
|
2777
|
-
|
|
2777
|
+
i?.releaseLock?.();
|
|
2778
2778
|
} catch {
|
|
2779
2779
|
}
|
|
2780
2780
|
}
|
|
2781
2781
|
}
|
|
2782
2782
|
function Gn(e, t) {
|
|
2783
|
-
return
|
|
2783
|
+
return Mr(e, Do), (e.schemaVersion !== 1 || e.transactionId !== t || !ot.test(e.transactionId) || !ot.test(e.state) || !ot.test(e.requestSha256) || !xo.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") && D(), tn(e);
|
|
2784
2784
|
}
|
|
2785
2785
|
function nn(e, t) {
|
|
2786
|
-
|
|
2787
|
-
const n = `${e.callbackUri}#code=`,
|
|
2788
|
-
(!t.redirectUri.startsWith(n) || !t.redirectUri.endsWith(
|
|
2789
|
-
const
|
|
2790
|
-
return (!ot.test(
|
|
2786
|
+
Mr(t, Po), (t.schemaVersion !== 1 || t.transactionId !== e.transactionId || typeof t.redirectUri != "string") && D();
|
|
2787
|
+
const n = `${e.callbackUri}#code=`, r = `&state=${e.state}`;
|
|
2788
|
+
(!t.redirectUri.startsWith(n) || !t.redirectUri.endsWith(r)) && D();
|
|
2789
|
+
const i = t.redirectUri.slice(n.length, t.redirectUri.length - r.length);
|
|
2790
|
+
return (!ot.test(i) || t.redirectUri !== `${n}${i}${r}`) && D(), Object.freeze({
|
|
2791
2791
|
redirectUri: t.redirectUri,
|
|
2792
2792
|
schemaVersion: 1,
|
|
2793
2793
|
transactionId: t.transactionId
|
|
2794
2794
|
});
|
|
2795
2795
|
}
|
|
2796
2796
|
function Jn(e, t, n = void 0) {
|
|
2797
|
-
const
|
|
2797
|
+
const r = {
|
|
2798
2798
|
cache: "no-store",
|
|
2799
2799
|
credentials: "omit",
|
|
2800
2800
|
headers: e === "POST" ? { Accept: "application/json", "Content-Type": "application/json" } : { Accept: "application/json" },
|
|
@@ -2804,32 +2804,32 @@ function Jn(e, t, n = void 0) {
|
|
|
2804
2804
|
referrerPolicy: "no-referrer",
|
|
2805
2805
|
signal: t
|
|
2806
2806
|
};
|
|
2807
|
-
return n !== void 0 && (
|
|
2807
|
+
return n !== void 0 && (r.body = JSON.stringify(n)), r;
|
|
2808
2808
|
}
|
|
2809
2809
|
function Mo({ fetch: e, location: t }) {
|
|
2810
2810
|
(typeof e != "function" || typeof t?.replace != "function") && D();
|
|
2811
|
-
const n = /* @__PURE__ */ new Set(),
|
|
2811
|
+
const n = /* @__PURE__ */ new Set(), r = async (i, s, a, o) => {
|
|
2812
2812
|
let c;
|
|
2813
2813
|
try {
|
|
2814
|
-
c = await
|
|
2814
|
+
c = await qr(e(i, s), s.signal, (l) => Fr(l));
|
|
2815
2815
|
} catch {
|
|
2816
2816
|
D();
|
|
2817
2817
|
}
|
|
2818
2818
|
return $o(c, a, o, s.signal);
|
|
2819
2819
|
};
|
|
2820
2820
|
return Object.freeze({
|
|
2821
|
-
async fetchTransaction(
|
|
2822
|
-
(typeof
|
|
2823
|
-
const a = await
|
|
2824
|
-
`/relay/v1/transactions/${
|
|
2821
|
+
async fetchTransaction(i, { signal: s } = {}) {
|
|
2822
|
+
(typeof i != "string" || !ot.test(i)) && D();
|
|
2823
|
+
const a = await r(
|
|
2824
|
+
`/relay/v1/transactions/${i}`,
|
|
2825
2825
|
Jn("GET", s),
|
|
2826
2826
|
200,
|
|
2827
2827
|
ko
|
|
2828
2828
|
);
|
|
2829
|
-
return Gn(a,
|
|
2829
|
+
return Gn(a, i);
|
|
2830
2830
|
},
|
|
2831
|
-
async publishResult(
|
|
2832
|
-
const o = Gn(
|
|
2831
|
+
async publishResult(i, s, { signal: a } = {}) {
|
|
2832
|
+
const o = Gn(i, i?.transactionId), c = await r(
|
|
2833
2833
|
`/relay/v1/transactions/${o.transactionId}/result`,
|
|
2834
2834
|
Jn("POST", a, {
|
|
2835
2835
|
result: s,
|
|
@@ -2842,10 +2842,10 @@ function Mo({ fetch: e, location: t }) {
|
|
|
2842
2842
|
), l = nn(o, c);
|
|
2843
2843
|
return n.clear(), n.add(l.redirectUri), l;
|
|
2844
2844
|
},
|
|
2845
|
-
navigate(
|
|
2846
|
-
(typeof
|
|
2845
|
+
navigate(i) {
|
|
2846
|
+
(typeof i != "string" || !n.delete(i)) && D();
|
|
2847
2847
|
try {
|
|
2848
|
-
Reflect.apply(t.replace, t, [
|
|
2848
|
+
Reflect.apply(t.replace, t, [i]);
|
|
2849
2849
|
} catch {
|
|
2850
2850
|
D();
|
|
2851
2851
|
}
|
|
@@ -2858,7 +2858,7 @@ function Mo({ fetch: e, location: t }) {
|
|
|
2858
2858
|
}
|
|
2859
2859
|
});
|
|
2860
2860
|
}
|
|
2861
|
-
const
|
|
2861
|
+
const Wr = Uint8Array, Fo = Wr.prototype.fill, et = new TextEncoder();
|
|
2862
2862
|
class $ extends Error {
|
|
2863
2863
|
constructor(t) {
|
|
2864
2864
|
super(t), this.name = "WalletOriginError", this.code = t;
|
|
@@ -2871,7 +2871,7 @@ function tt(e) {
|
|
|
2871
2871
|
throw e instanceof Ie ? new $(e.code) : e;
|
|
2872
2872
|
}
|
|
2873
2873
|
function ye(e) {
|
|
2874
|
-
if (e instanceof
|
|
2874
|
+
if (e instanceof Wr)
|
|
2875
2875
|
try {
|
|
2876
2876
|
Fo.call(e, 0);
|
|
2877
2877
|
} catch {
|
|
@@ -2882,8 +2882,8 @@ function nt(e) {
|
|
|
2882
2882
|
for (let t = 0; t < e.length; t += 1) {
|
|
2883
2883
|
const n = e.charCodeAt(t);
|
|
2884
2884
|
if (n >= 55296 && n <= 56319) {
|
|
2885
|
-
const
|
|
2886
|
-
if (!(
|
|
2885
|
+
const r = e.charCodeAt(++t);
|
|
2886
|
+
if (!(r >= 56320 && r <= 57343)) return !1;
|
|
2887
2887
|
} else if (n >= 56320 && n <= 57343) return !1;
|
|
2888
2888
|
}
|
|
2889
2889
|
return !0;
|
|
@@ -2931,32 +2931,32 @@ function Yn(e) {
|
|
|
2931
2931
|
}
|
|
2932
2932
|
}
|
|
2933
2933
|
}
|
|
2934
|
-
function
|
|
2934
|
+
function rt(e, t) {
|
|
2935
2935
|
const n = /* @__PURE__ */ new Set();
|
|
2936
|
-
for (const
|
|
2937
|
-
let
|
|
2936
|
+
for (const r of t) {
|
|
2937
|
+
let i = null;
|
|
2938
2938
|
try {
|
|
2939
|
-
|
|
2939
|
+
i = r?.form ?? r?.closest?.("form") ?? null;
|
|
2940
2940
|
} catch {
|
|
2941
|
-
|
|
2941
|
+
i = null;
|
|
2942
2942
|
}
|
|
2943
|
-
|
|
2943
|
+
i && n.add(i), Yn(r);
|
|
2944
2944
|
}
|
|
2945
|
-
for (const
|
|
2946
|
-
let
|
|
2945
|
+
for (const r of n) {
|
|
2946
|
+
let i = [];
|
|
2947
2947
|
try {
|
|
2948
|
-
|
|
2948
|
+
i = r.querySelectorAll?.("input, textarea") ?? [];
|
|
2949
2949
|
} catch {
|
|
2950
|
-
|
|
2950
|
+
i = [];
|
|
2951
2951
|
}
|
|
2952
|
-
for (const s of
|
|
2952
|
+
for (const s of i) Yn(s);
|
|
2953
2953
|
try {
|
|
2954
|
-
|
|
2954
|
+
r.inert = !0, r.setAttribute?.("aria-hidden", "true");
|
|
2955
2955
|
const s = e.createElement("div");
|
|
2956
|
-
s.dataset.walletCredentialState = "cleared",
|
|
2956
|
+
s.dataset.walletCredentialState = "cleared", r.replaceWith?.(s), r.replaceChildren?.();
|
|
2957
2957
|
} catch {
|
|
2958
2958
|
try {
|
|
2959
|
-
|
|
2959
|
+
r.remove?.();
|
|
2960
2960
|
} catch {
|
|
2961
2961
|
}
|
|
2962
2962
|
}
|
|
@@ -2965,12 +2965,12 @@ function it(e, t) {
|
|
|
2965
2965
|
function qo(e) {
|
|
2966
2966
|
let t;
|
|
2967
2967
|
try {
|
|
2968
|
-
t =
|
|
2968
|
+
t = tr(e);
|
|
2969
2969
|
} catch {
|
|
2970
2970
|
E("WASM_UNAVAILABLE");
|
|
2971
2971
|
}
|
|
2972
|
-
const n = t?.sdn,
|
|
2973
|
-
return (!n || typeof n.derivePasswordIdentity != "function" || typeof n.destroySdnIdentity != "function" || typeof
|
|
2972
|
+
const n = t?.sdn, r = t?.sha256;
|
|
2973
|
+
return (!n || typeof n.derivePasswordIdentity != "function" || typeof n.destroySdnIdentity != "function" || typeof r != "function") && E("WASM_UNAVAILABLE"), Object.freeze({ capabilities: n, sha256: r });
|
|
2974
2974
|
}
|
|
2975
2975
|
function yt(e) {
|
|
2976
2976
|
const t = e?.AbortController ?? globalThis.AbortController;
|
|
@@ -2985,11 +2985,11 @@ class Wo {
|
|
|
2985
2985
|
#y = /* @__PURE__ */ new Set();
|
|
2986
2986
|
#S = null;
|
|
2987
2987
|
#e = !1;
|
|
2988
|
-
#
|
|
2989
|
-
#
|
|
2988
|
+
#i;
|
|
2989
|
+
#r = 0;
|
|
2990
2990
|
#t = null;
|
|
2991
2991
|
#p = null;
|
|
2992
|
-
#
|
|
2992
|
+
#R = [];
|
|
2993
2993
|
#L = /* @__PURE__ */ new Set();
|
|
2994
2994
|
#a = /* @__PURE__ */ new Set();
|
|
2995
2995
|
#g = null;
|
|
@@ -3003,7 +3003,7 @@ class Wo {
|
|
|
3003
3003
|
#$ = !1;
|
|
3004
3004
|
#A = null;
|
|
3005
3005
|
#n = !1;
|
|
3006
|
-
#
|
|
3006
|
+
#O = 0;
|
|
3007
3007
|
#l = /* @__PURE__ */ new Set();
|
|
3008
3008
|
#D;
|
|
3009
3009
|
#N = /* @__PURE__ */ new Set();
|
|
@@ -3011,8 +3011,8 @@ class Wo {
|
|
|
3011
3011
|
constructor({
|
|
3012
3012
|
credentials: t,
|
|
3013
3013
|
document: n,
|
|
3014
|
-
now:
|
|
3015
|
-
registry:
|
|
3014
|
+
now: r,
|
|
3015
|
+
registry: i,
|
|
3016
3016
|
relay: s,
|
|
3017
3017
|
rng: a,
|
|
3018
3018
|
rpId: o,
|
|
@@ -3022,7 +3022,7 @@ class Wo {
|
|
|
3022
3022
|
window: u
|
|
3023
3023
|
}) {
|
|
3024
3024
|
const p = qo(d);
|
|
3025
|
-
this.#f = p.capabilities, this.#D = p.sha256, this.#x =
|
|
3025
|
+
this.#f = p.capabilities, this.#D = p.sha256, this.#x = i, this.#c = s, this.#i = n, this.#s = u, this.#m = Co({
|
|
3026
3026
|
createRequestController: () => {
|
|
3027
3027
|
const f = yt(this.#s);
|
|
3028
3028
|
return f && (this.#o.add(f), this.#N.add(f)), f;
|
|
@@ -3033,7 +3033,7 @@ class Wo {
|
|
|
3033
3033
|
rpName: c,
|
|
3034
3034
|
destroyHandle: (f) => this.#b(f),
|
|
3035
3035
|
module: d,
|
|
3036
|
-
now:
|
|
3036
|
+
now: r,
|
|
3037
3037
|
ownHandle: (f) => this.#a.add(f),
|
|
3038
3038
|
ownedHandlesClean: (f) => this.#a.size === 1 && this.#a.has(f) && this.#t === f,
|
|
3039
3039
|
releaseRequestController: (f) => {
|
|
@@ -3044,21 +3044,21 @@ class Wo {
|
|
|
3044
3044
|
},
|
|
3045
3045
|
storage: l ?? u?.localStorage ?? globalThis.localStorage
|
|
3046
3046
|
}), this.#v = os({
|
|
3047
|
-
now:
|
|
3047
|
+
now: r,
|
|
3048
3048
|
storage: l ?? u?.localStorage ?? globalThis.localStorage
|
|
3049
3049
|
}), this.#q();
|
|
3050
3050
|
}
|
|
3051
3051
|
get generation() {
|
|
3052
|
-
return this.#
|
|
3052
|
+
return this.#r;
|
|
3053
3053
|
}
|
|
3054
3054
|
#U() {
|
|
3055
|
-
return this.#
|
|
3055
|
+
return this.#r = this.#r >= Number.MAX_SAFE_INTEGER ? 1 : this.#r + 1, this.#r;
|
|
3056
3056
|
}
|
|
3057
3057
|
#q() {
|
|
3058
|
-
const t = (n,
|
|
3059
|
-
n?.addEventListener?.(
|
|
3058
|
+
const t = (n, r, i) => {
|
|
3059
|
+
n?.addEventListener?.(r, i), this.#R.push([n, r, i]);
|
|
3060
3060
|
};
|
|
3061
|
-
t(this.#s, "pagehide", () => this.revokeNow("pagehide")), t(this.#
|
|
3061
|
+
t(this.#s, "pagehide", () => this.revokeNow("pagehide")), t(this.#i, "freeze", () => this.revokeNow("freeze")), t(this.#s, "beforeunload", () => this.revokeNow("beforeunload")), t(this.#s, "pageshow", (n) => {
|
|
3062
3062
|
if (n?.persisted === !0) {
|
|
3063
3063
|
this.revokeNow("bfcache-restore");
|
|
3064
3064
|
try {
|
|
@@ -3069,12 +3069,12 @@ class Wo {
|
|
|
3069
3069
|
});
|
|
3070
3070
|
}
|
|
3071
3071
|
#W() {
|
|
3072
|
-
for (const [t, n,
|
|
3072
|
+
for (const [t, n, r] of this.#R)
|
|
3073
3073
|
try {
|
|
3074
|
-
t?.removeEventListener?.(n,
|
|
3074
|
+
t?.removeEventListener?.(n, r);
|
|
3075
3075
|
} catch {
|
|
3076
3076
|
}
|
|
3077
|
-
this.#
|
|
3077
|
+
this.#R = [];
|
|
3078
3078
|
}
|
|
3079
3079
|
#b(t = this.#t) {
|
|
3080
3080
|
if (t == null) return !0;
|
|
@@ -3105,7 +3105,7 @@ class Wo {
|
|
|
3105
3105
|
} catch {
|
|
3106
3106
|
}
|
|
3107
3107
|
}
|
|
3108
|
-
#
|
|
3108
|
+
#H() {
|
|
3109
3109
|
const t = [...this.#N];
|
|
3110
3110
|
this.#N.clear();
|
|
3111
3111
|
for (const n of t) {
|
|
@@ -3123,31 +3123,31 @@ class Wo {
|
|
|
3123
3123
|
}
|
|
3124
3124
|
#T(t = []) {
|
|
3125
3125
|
if (this.#y.size === 0) return;
|
|
3126
|
-
const n = new Set(t),
|
|
3127
|
-
for (const
|
|
3128
|
-
n.has(
|
|
3126
|
+
const n = new Set(t), r = [];
|
|
3127
|
+
for (const i of this.#y)
|
|
3128
|
+
n.has(i) || r.push(i);
|
|
3129
3129
|
this.#y = new Set(
|
|
3130
|
-
[...this.#y].filter((
|
|
3131
|
-
),
|
|
3130
|
+
[...this.#y].filter((i) => n.has(i))
|
|
3131
|
+
), rt(this.#i, r);
|
|
3132
3132
|
}
|
|
3133
3133
|
#j(t = []) {
|
|
3134
3134
|
(this.#e || this.#n) && E("STALE_CONTROLLER");
|
|
3135
3135
|
const n = this.#U();
|
|
3136
|
-
this.#T(t), this.#
|
|
3137
|
-
let
|
|
3138
|
-
return
|
|
3136
|
+
this.#T(t), this.#H(), this.#B();
|
|
3137
|
+
let r = this.#b();
|
|
3138
|
+
return r && (r = this.#E() && this.#a.size === 0), r || (this.revokeNow("native-destruction-failed"), this.#E(), E("DESTRUCTION_FAILED")), this.#A = null, n;
|
|
3139
3139
|
}
|
|
3140
3140
|
#V(t, n, {
|
|
3141
|
-
allowPublication:
|
|
3142
|
-
retainIdentity:
|
|
3141
|
+
allowPublication: r = !1,
|
|
3142
|
+
retainIdentity: i = !1
|
|
3143
3143
|
} = {}) {
|
|
3144
|
-
const s = !this.#e && !this.#n && this.#
|
|
3144
|
+
const s = !this.#e && !this.#n && this.#r === n && this.#t === t, a = this.#t === t || this.#a.has(t);
|
|
3145
3145
|
if (!s) {
|
|
3146
3146
|
const p = !a || this.#b(t);
|
|
3147
3147
|
return p || (this.revokeNow("native-destruction-failed"), this.#E()), Object.freeze({ destroyed: p, permit: null });
|
|
3148
3148
|
}
|
|
3149
|
-
const o = this.#
|
|
3150
|
-
this.#U(), this.#n = !0, this.#d = !1, this.#u = c, this.#a.add(t), this.#t = null, this.#p = null,
|
|
3149
|
+
const o = this.#O, c = r ? Object.freeze({}) : null;
|
|
3150
|
+
this.#U(), this.#n = !0, this.#d = !1, this.#u = c, this.#a.add(t), this.#t = null, this.#p = null, i || (this.#A = null);
|
|
3151
3151
|
const l = this.#h;
|
|
3152
3152
|
this.#h = null;
|
|
3153
3153
|
let d = this.#b(t);
|
|
@@ -3161,17 +3161,17 @@ class Wo {
|
|
|
3161
3161
|
} catch {
|
|
3162
3162
|
}
|
|
3163
3163
|
this.#T(), this.#B(), this.#M(), d || this.#E();
|
|
3164
|
-
const u = d && this.#
|
|
3164
|
+
const u = d && this.#O === o && this.#u === c ? c : null;
|
|
3165
3165
|
return u === null && this.#u === c && (this.#u = null), Object.freeze({ destroyed: d, permit: u });
|
|
3166
3166
|
}
|
|
3167
3167
|
#w(t, n) {
|
|
3168
|
-
(this.#e || this.#n || this.#
|
|
3168
|
+
(this.#e || this.#n || this.#r !== n || this.#t !== t) && E("STALE_CONTROLLER");
|
|
3169
3169
|
}
|
|
3170
3170
|
#_(t) {
|
|
3171
|
-
(this.#e || this.#n || this.#
|
|
3171
|
+
(this.#e || this.#n || this.#r !== t) && E("STALE_CONTROLLER");
|
|
3172
3172
|
}
|
|
3173
3173
|
#I(t, n) {
|
|
3174
|
-
(this.#e || this.#
|
|
3174
|
+
(this.#e || this.#O !== t || this.#a.size !== 0 || n === null || this.#u !== n) && E("STALE_CONTROLLER");
|
|
3175
3175
|
}
|
|
3176
3176
|
#F(t) {
|
|
3177
3177
|
if (this.#C) return this.#C;
|
|
@@ -3179,15 +3179,15 @@ class Wo {
|
|
|
3179
3179
|
if (!n || t !== "connected" && t !== "disconnected")
|
|
3180
3180
|
return Promise.reject(new $("STALE_CONTROLLER"));
|
|
3181
3181
|
this.#g = null, this.#A = null;
|
|
3182
|
-
let
|
|
3182
|
+
let r, i;
|
|
3183
3183
|
const s = new Promise((a, o) => {
|
|
3184
|
-
|
|
3184
|
+
r = a, i = o;
|
|
3185
3185
|
});
|
|
3186
3186
|
return this.#C = s, (async () => {
|
|
3187
3187
|
const a = yt(this.#s);
|
|
3188
3188
|
a && this.#o.add(a);
|
|
3189
3189
|
try {
|
|
3190
|
-
this.#I(n.epoch, n.permit), ue({ document: this.#
|
|
3190
|
+
this.#I(n.epoch, n.permit), ue({ document: this.#i, window: this.#s }), typeof this.#c?.publishResult != "function" && E("RELAY_UNAVAILABLE");
|
|
3191
3191
|
const o = t === "connected" ? n.connectedResult : vs();
|
|
3192
3192
|
let c;
|
|
3193
3193
|
try {
|
|
@@ -3197,19 +3197,19 @@ class Wo {
|
|
|
3197
3197
|
} catch (l) {
|
|
3198
3198
|
throw this.#I(n.epoch, n.permit), l;
|
|
3199
3199
|
}
|
|
3200
|
-
if (this.#I(n.epoch, n.permit), ue({ document: this.#
|
|
3200
|
+
if (this.#I(n.epoch, n.permit), ue({ document: this.#i, window: this.#s }), typeof this.#c?.navigate == "function") {
|
|
3201
3201
|
const l = nn(n.transaction, c);
|
|
3202
3202
|
this.#I(n.epoch, n.permit), this.#u = null, this.#c.navigate(l.redirectUri);
|
|
3203
3203
|
} else
|
|
3204
3204
|
this.#u = null;
|
|
3205
|
-
|
|
3205
|
+
r(c);
|
|
3206
3206
|
} catch (o) {
|
|
3207
3207
|
this.#u === n.permit && (this.#u = null);
|
|
3208
3208
|
try {
|
|
3209
3209
|
this.#c?.revokeNow?.("account-publication-failed");
|
|
3210
3210
|
} catch {
|
|
3211
3211
|
}
|
|
3212
|
-
|
|
3212
|
+
i(o);
|
|
3213
3213
|
} finally {
|
|
3214
3214
|
a && this.#o.delete(a);
|
|
3215
3215
|
}
|
|
@@ -3257,7 +3257,7 @@ class Wo {
|
|
|
3257
3257
|
}
|
|
3258
3258
|
}
|
|
3259
3259
|
isUiGenerationCurrent(t) {
|
|
3260
|
-
return Number.isSafeInteger(t) && t === this.#
|
|
3260
|
+
return Number.isSafeInteger(t) && t === this.#r && !this.#e && (!this.#n || this.#g !== null);
|
|
3261
3261
|
}
|
|
3262
3262
|
listQuarantinedWalletRecords() {
|
|
3263
3263
|
(this.#e || this.#n && !this.#g) && E("STALE_CONTROLLER");
|
|
@@ -3279,8 +3279,8 @@ class Wo {
|
|
|
3279
3279
|
(this.#e || this.#n && !this.#g) && E("STALE_CONTROLLER");
|
|
3280
3280
|
try {
|
|
3281
3281
|
return this.#m.deleteQuarantine(t, n);
|
|
3282
|
-
} catch (
|
|
3283
|
-
throw typeof
|
|
3282
|
+
} catch (r) {
|
|
3283
|
+
throw typeof r?.code == "string" ? new $(r.code) : r;
|
|
3284
3284
|
}
|
|
3285
3285
|
}
|
|
3286
3286
|
canForgetRememberedWallet() {
|
|
@@ -3302,33 +3302,33 @@ class Wo {
|
|
|
3302
3302
|
async unlockPassword({
|
|
3303
3303
|
accountIndex: t = 0,
|
|
3304
3304
|
passwordControl: n,
|
|
3305
|
-
rememberControl:
|
|
3306
|
-
rememberStatus:
|
|
3305
|
+
rememberControl: r = null,
|
|
3306
|
+
rememberStatus: i = null,
|
|
3307
3307
|
usernameControl: s
|
|
3308
3308
|
}) {
|
|
3309
3309
|
(this.#e || this.#n) && E("STALE_CONTROLLER"), t !== 0 && E("INVALID_ACCOUNT"), (!s || !n) && E("INVALID_CREDENTIAL_FORM");
|
|
3310
3310
|
try {
|
|
3311
|
-
ue({ document: this.#
|
|
3311
|
+
ue({ document: this.#i, window: this.#s });
|
|
3312
3312
|
} catch (h) {
|
|
3313
|
-
|
|
3314
|
-
this.#
|
|
3315
|
-
[s, n,
|
|
3313
|
+
rt(
|
|
3314
|
+
this.#i,
|
|
3315
|
+
[s, n, r].filter(Boolean)
|
|
3316
3316
|
), tt(h);
|
|
3317
3317
|
}
|
|
3318
3318
|
let a;
|
|
3319
3319
|
try {
|
|
3320
3320
|
a = this.#j([s, n]);
|
|
3321
3321
|
} catch (h) {
|
|
3322
|
-
throw
|
|
3323
|
-
this.#
|
|
3324
|
-
[s, n,
|
|
3322
|
+
throw rt(
|
|
3323
|
+
this.#i,
|
|
3324
|
+
[s, n, r].filter(Boolean)
|
|
3325
3325
|
), h;
|
|
3326
3326
|
}
|
|
3327
3327
|
this.registerCredentialControls({ passwordControl: n, usernameControl: s });
|
|
3328
3328
|
let o, c, l, d, u, p, f = null, A = !1;
|
|
3329
3329
|
try {
|
|
3330
3330
|
try {
|
|
3331
|
-
ue({ document: this.#
|
|
3331
|
+
ue({ document: this.#i, window: this.#s });
|
|
3332
3332
|
} catch (m) {
|
|
3333
3333
|
tt(m);
|
|
3334
3334
|
}
|
|
@@ -3340,19 +3340,19 @@ class Wo {
|
|
|
3340
3340
|
} catch {
|
|
3341
3341
|
E("INVALID_USERNAME");
|
|
3342
3342
|
}
|
|
3343
|
-
c = et.encode(h), p = et.encode(f), A =
|
|
3343
|
+
c = et.encode(h), p = et.encode(f), A = r?.checked === !0 && r?.disabled !== !0 && this.#m.supported(), A ? ((p.length === 0 || p.length > 256) && E("INVALID_PASSWORD"), l = p.slice(), d = p.slice(), u = d, ye(p), p = null) : (l = p, p = null), this.#l.add(c), this.#l.add(l), d && this.#l.add(d);
|
|
3344
3344
|
} finally {
|
|
3345
|
-
if (f = null,
|
|
3345
|
+
if (f = null, r && typeof r == "object") {
|
|
3346
3346
|
try {
|
|
3347
|
-
|
|
3347
|
+
r.checked = !1;
|
|
3348
3348
|
} catch {
|
|
3349
3349
|
}
|
|
3350
3350
|
try {
|
|
3351
|
-
|
|
3351
|
+
r.defaultChecked = !1;
|
|
3352
3352
|
} catch {
|
|
3353
3353
|
}
|
|
3354
3354
|
try {
|
|
3355
|
-
|
|
3355
|
+
r.disabled = !0;
|
|
3356
3356
|
} catch {
|
|
3357
3357
|
}
|
|
3358
3358
|
}
|
|
@@ -3374,7 +3374,7 @@ class Wo {
|
|
|
3374
3374
|
const g = this.#b(h);
|
|
3375
3375
|
b = null, g || (this.revokeNow("native-destruction-failed"), E("DESTRUCTION_FAILED")), E("WASM_FAILURE");
|
|
3376
3376
|
}
|
|
3377
|
-
if ((this.#e || this.#n || this.#
|
|
3377
|
+
if ((this.#e || this.#n || this.#r !== a) && (this.#b(h) || (this.revokeNow("native-destruction-failed"), E("DESTRUCTION_FAILED")), E("STALE_CONTROLLER")), this.#t = h, this.#p = m, A)
|
|
3378
3378
|
try {
|
|
3379
3379
|
await this.#m.setup({
|
|
3380
3380
|
assertCurrent: () => this.#w(h, a),
|
|
@@ -3384,19 +3384,19 @@ class Wo {
|
|
|
3384
3384
|
passwordUtf8: d
|
|
3385
3385
|
}), this.#w(h, a), this.#l.delete(u), d = null;
|
|
3386
3386
|
try {
|
|
3387
|
-
|
|
3387
|
+
i && (i.textContent = "Wallet remembered on this device.");
|
|
3388
3388
|
} catch {
|
|
3389
3389
|
}
|
|
3390
3390
|
} catch {
|
|
3391
|
-
ye(d), this.#l.delete(u), d = null, (this.#e || this.#n || this.#
|
|
3391
|
+
ye(d), this.#l.delete(u), d = null, (this.#e || this.#n || this.#r !== a || this.#t !== h) && E("STALE_CONTROLLER"), this.#a.size === 1 && this.#a.has(h) && this.#t === h || (this.revokeNow("remembered-wallet-cleanup-failed"), E("DESTRUCTION_FAILED"));
|
|
3392
3392
|
try {
|
|
3393
|
-
|
|
3393
|
+
i && (i.textContent = "Wallet was not remembered.");
|
|
3394
3394
|
} catch {
|
|
3395
3395
|
}
|
|
3396
3396
|
}
|
|
3397
3397
|
return this.#w(h, a), m;
|
|
3398
3398
|
} catch (h) {
|
|
3399
|
-
throw h instanceof $ && h.code === "DESTRUCTION_FAILED" || (this.#e || this.#n || this.#
|
|
3399
|
+
throw h instanceof $ && h.code === "DESTRUCTION_FAILED" || (this.#e || this.#n || this.#r !== a) && E("STALE_CONTROLLER"), h;
|
|
3400
3400
|
} finally {
|
|
3401
3401
|
ye(c), ye(l), ye(d), ye(u), this.#l.delete(c), this.#l.delete(l), this.#l.delete(u);
|
|
3402
3402
|
}
|
|
@@ -3404,60 +3404,60 @@ class Wo {
|
|
|
3404
3404
|
async unlockRemembered({ accountIndex: t = 0 } = {}) {
|
|
3405
3405
|
(this.#e || this.#n) && E("STALE_CONTROLLER"), t !== 0 && E("INVALID_ACCOUNT"), this.canRestoreRememberedWallet() || E("REMEMBER_UNAVAILABLE");
|
|
3406
3406
|
try {
|
|
3407
|
-
ue({ document: this.#
|
|
3408
|
-
} catch (
|
|
3409
|
-
tt(
|
|
3407
|
+
ue({ document: this.#i, window: this.#s });
|
|
3408
|
+
} catch (r) {
|
|
3409
|
+
tt(r);
|
|
3410
3410
|
}
|
|
3411
3411
|
const n = this.#j();
|
|
3412
3412
|
try {
|
|
3413
|
-
const
|
|
3413
|
+
const r = await this.#m.restore({
|
|
3414
3414
|
assertCurrent: () => this.#_(n)
|
|
3415
|
-
}),
|
|
3416
|
-
(
|
|
3415
|
+
}), i = r?.handle;
|
|
3416
|
+
(i == null || !this.#a.has(i)) && E("WASM_FAILURE");
|
|
3417
3417
|
let s;
|
|
3418
3418
|
try {
|
|
3419
|
-
s = ge(
|
|
3419
|
+
s = ge(r.identity);
|
|
3420
3420
|
} catch {
|
|
3421
3421
|
E("WASM_FAILURE");
|
|
3422
3422
|
}
|
|
3423
|
-
return (this.#e || this.#n || this.#
|
|
3424
|
-
} catch (
|
|
3425
|
-
throw
|
|
3423
|
+
return (this.#e || this.#n || this.#r !== n) && (this.#b(i) || (this.revokeNow("native-destruction-failed"), E("DESTRUCTION_FAILED")), E("STALE_CONTROLLER")), this.#t = i, this.#p = s, s;
|
|
3424
|
+
} catch (r) {
|
|
3425
|
+
throw r instanceof $ && r.code === "DESTRUCTION_FAILED" || ((this.#e || this.#n || this.#r !== n) && E("STALE_CONTROLLER"), this.#a.size > 0 && (this.#E(), this.#a.size > 0 && (this.revokeNow("remembered-wallet-cleanup-failed"), E("DESTRUCTION_FAILED"))), r instanceof $) ? r : typeof r?.code == "string" ? new $(r.code) : r;
|
|
3426
3426
|
}
|
|
3427
3427
|
}
|
|
3428
3428
|
async unlockLegacy({
|
|
3429
3429
|
accountIndex: t = 0,
|
|
3430
3430
|
mnemonicControl: n = null,
|
|
3431
|
-
operation:
|
|
3432
|
-
passwordControl:
|
|
3431
|
+
operation: r,
|
|
3432
|
+
passwordControl: i = null,
|
|
3433
3433
|
profile: s,
|
|
3434
3434
|
usernameControl: a = null
|
|
3435
3435
|
}) {
|
|
3436
|
-
(this.#e || this.#n) && E("STALE_CONTROLLER"),
|
|
3436
|
+
(this.#e || this.#n) && E("STALE_CONTROLLER"), r !== "sdn.auth.raw-challenge.v1" && E("OPERATION_NOT_ALLOWED"), t !== 0 && E("INVALID_ACCOUNT");
|
|
3437
3437
|
const o = s === "password-fast-v1-legacy";
|
|
3438
|
-
!o && !(s === "bip39-mnemonic-v1-legacy") && E("INVALID_LEGACY_PROFILE"), o ? (!a || !
|
|
3439
|
-
const l = o ? [a,
|
|
3438
|
+
!o && !(s === "bip39-mnemonic-v1-legacy") && E("INVALID_LEGACY_PROFILE"), o ? (!a || !i) && E("INVALID_CREDENTIAL_FORM") : (!n || typeof n != "object") && E("INVALID_CREDENTIAL_FORM");
|
|
3439
|
+
const l = o ? [a, i] : [n];
|
|
3440
3440
|
try {
|
|
3441
|
-
ue({ document: this.#
|
|
3441
|
+
ue({ document: this.#i, window: this.#s });
|
|
3442
3442
|
} catch (b) {
|
|
3443
|
-
|
|
3443
|
+
rt(this.#i, l), tt(b);
|
|
3444
3444
|
}
|
|
3445
3445
|
let d;
|
|
3446
3446
|
try {
|
|
3447
3447
|
d = this.#j(l);
|
|
3448
3448
|
} catch (b) {
|
|
3449
|
-
throw
|
|
3449
|
+
throw rt(this.#i, l), b;
|
|
3450
3450
|
}
|
|
3451
|
-
o ? this.registerCredentialControls({ passwordControl:
|
|
3451
|
+
o ? this.registerCredentialControls({ passwordControl: i, usernameControl: a }) : this.#y.add(n);
|
|
3452
3452
|
let u, p, f;
|
|
3453
3453
|
try {
|
|
3454
3454
|
try {
|
|
3455
|
-
ue({ document: this.#
|
|
3455
|
+
ue({ document: this.#i, window: this.#s });
|
|
3456
3456
|
} catch (b) {
|
|
3457
3457
|
tt(b);
|
|
3458
3458
|
}
|
|
3459
3459
|
if (this.#_(d), o) {
|
|
3460
|
-
const b = a?.value, h =
|
|
3460
|
+
const b = a?.value, h = i?.value;
|
|
3461
3461
|
nt(b) || E("INVALID_USERNAME"), nt(h) || E("INVALID_PASSWORD"), u = et.encode(b), p = et.encode(h), this.#l.add(u), this.#l.add(p);
|
|
3462
3462
|
} else {
|
|
3463
3463
|
const b = n?.value;
|
|
@@ -3477,46 +3477,46 @@ class Wo {
|
|
|
3477
3477
|
b == null && E("WASM_FAILURE"), this.#a.add(b);
|
|
3478
3478
|
let h;
|
|
3479
3479
|
try {
|
|
3480
|
-
h =
|
|
3480
|
+
h = zs(A.identity, { accountIndex: t, profile: s });
|
|
3481
3481
|
} catch {
|
|
3482
3482
|
const m = this.#b(b);
|
|
3483
3483
|
A = null, m || (this.revokeNow("native-destruction-failed"), E("DESTRUCTION_FAILED")), E("WASM_FAILURE");
|
|
3484
3484
|
}
|
|
3485
|
-
return (this.#e || this.#n || this.#
|
|
3485
|
+
return (this.#e || this.#n || this.#r !== d) && (this.#b(b) || (this.revokeNow("native-destruction-failed"), E("DESTRUCTION_FAILED")), E("STALE_CONTROLLER")), this.#t = b, this.#p = h, h;
|
|
3486
3486
|
} catch (b) {
|
|
3487
|
-
throw b instanceof $ && b.code === "DESTRUCTION_FAILED" || (this.#e || this.#n || this.#
|
|
3487
|
+
throw b instanceof $ && b.code === "DESTRUCTION_FAILED" || (this.#e || this.#n || this.#r !== d) && E("STALE_CONTROLLER"), b;
|
|
3488
3488
|
} finally {
|
|
3489
3489
|
ye(u), ye(p), ye(f), this.#l.delete(u), this.#l.delete(p), this.#l.delete(f);
|
|
3490
3490
|
}
|
|
3491
3491
|
}
|
|
3492
3492
|
async prepare(t) {
|
|
3493
3493
|
(this.#e || this.#n) && E("STALE_CONTROLLER"), this.#d && E("TRANSACTION_IN_PROGRESS"), this.#d = !0;
|
|
3494
|
-
const n = this.#
|
|
3495
|
-
|
|
3494
|
+
const n = this.#r, r = typeof t == "string" ? t : t?.transactionId ?? null, i = yt(this.#s);
|
|
3495
|
+
i && this.#o.add(i);
|
|
3496
3496
|
try {
|
|
3497
|
-
const s = typeof this.#c?.fetchTransaction == "function" ? await this.#c.fetchTransaction(t, { signal:
|
|
3497
|
+
const s = typeof this.#c?.fetchTransaction == "function" ? await this.#c.fetchTransaction(t, { signal: i?.signal }) : t;
|
|
3498
3498
|
this.#_(n);
|
|
3499
3499
|
const a = await $t(s, {
|
|
3500
|
-
expectedTransactionId:
|
|
3500
|
+
expectedTransactionId: r,
|
|
3501
3501
|
registry: this.#x,
|
|
3502
3502
|
relay: this.#c,
|
|
3503
3503
|
sha256: this.#D,
|
|
3504
3504
|
window: this.#s
|
|
3505
3505
|
});
|
|
3506
|
-
return this.#_(n), ue({ document: this.#
|
|
3506
|
+
return this.#_(n), ue({ document: this.#i, window: this.#s }), this.#P.add(a), i && this.#k.set(a, i), a;
|
|
3507
3507
|
} catch (s) {
|
|
3508
|
-
const a = this.#e || this.#n || this.#
|
|
3509
|
-
throw this.#d = !1,
|
|
3508
|
+
const a = this.#e || this.#n || this.#r !== n;
|
|
3509
|
+
throw this.#d = !1, i && this.#o.delete(i), a && E("STALE_CONTROLLER"), s instanceof $ ? s : s instanceof Ie ? new $(s.code) : s;
|
|
3510
3510
|
}
|
|
3511
3511
|
}
|
|
3512
3512
|
async executePrepared(t) {
|
|
3513
3513
|
(!t || typeof t != "object" || !this.#P.has(t)) && E("INVALID_TRANSACTION"), this.#P.delete(t);
|
|
3514
3514
|
const n = this.#k.get(t) ?? null;
|
|
3515
3515
|
this.#k.delete(t), (this.#e || this.#n || this.#t === null) && (n && this.#o.delete(n), this.#d = !1, E("STALE_CONTROLLER"));
|
|
3516
|
-
const
|
|
3516
|
+
const r = this.#t, i = this.#p, s = this.#r;
|
|
3517
3517
|
let a = !1;
|
|
3518
3518
|
try {
|
|
3519
|
-
this.#w(
|
|
3519
|
+
this.#w(r, s);
|
|
3520
3520
|
let o = await $t(t.transaction, {
|
|
3521
3521
|
expectedTransactionId: t.transaction.transactionId,
|
|
3522
3522
|
registry: this.#x,
|
|
@@ -3524,13 +3524,13 @@ class Wo {
|
|
|
3524
3524
|
sha256: this.#D,
|
|
3525
3525
|
window: this.#s
|
|
3526
3526
|
});
|
|
3527
|
-
this.#w(
|
|
3528
|
-
const c = ss(o.binding,
|
|
3527
|
+
this.#w(r, s), ue({ document: this.#i, window: this.#s });
|
|
3528
|
+
const c = ss(o.binding, i);
|
|
3529
3529
|
if (!this.#v.take(c)) {
|
|
3530
3530
|
this.#h = ws({
|
|
3531
3531
|
binding: o.binding,
|
|
3532
|
-
document: this.#
|
|
3533
|
-
identity:
|
|
3532
|
+
document: this.#i,
|
|
3533
|
+
identity: i,
|
|
3534
3534
|
offerRemember: c !== null,
|
|
3535
3535
|
request: o.request,
|
|
3536
3536
|
transaction: o.transaction
|
|
@@ -3538,30 +3538,30 @@ class Wo {
|
|
|
3538
3538
|
const A = await this.#h.promise;
|
|
3539
3539
|
c !== null && A?.remember === !0 && this.#v.grant(c);
|
|
3540
3540
|
}
|
|
3541
|
-
this.#w(
|
|
3541
|
+
this.#w(r, s), ue({ document: this.#i, window: this.#s }), o = await $t(t.transaction, {
|
|
3542
3542
|
expectedTransactionId: t.transaction.transactionId,
|
|
3543
3543
|
registry: this.#x,
|
|
3544
3544
|
relay: this.#c,
|
|
3545
3545
|
sha256: this.#D,
|
|
3546
3546
|
window: this.#s
|
|
3547
|
-
}), this.#w(
|
|
3547
|
+
}), this.#w(r, s), ue({ document: this.#i, window: this.#s });
|
|
3548
3548
|
const l = await Is({
|
|
3549
|
-
assertCurrent: () => this.#w(
|
|
3549
|
+
assertCurrent: () => this.#w(r, s),
|
|
3550
3550
|
binding: o.binding,
|
|
3551
|
-
handle:
|
|
3552
|
-
identity:
|
|
3551
|
+
handle: r,
|
|
3552
|
+
identity: i,
|
|
3553
3553
|
transaction: o.transaction,
|
|
3554
3554
|
wasm: this.#f
|
|
3555
3555
|
});
|
|
3556
|
-
this.#w(
|
|
3556
|
+
this.#w(r, s), ue({ document: this.#i, window: this.#s });
|
|
3557
3557
|
const d = o.transaction.operation === "sdn.wallet.account.v1";
|
|
3558
|
-
d && (this.#A = ge(
|
|
3559
|
-
const u = this.#V(
|
|
3558
|
+
d && (this.#A = ge(i));
|
|
3559
|
+
const u = this.#V(r, s, {
|
|
3560
3560
|
allowPublication: !0,
|
|
3561
3561
|
retainIdentity: d
|
|
3562
3562
|
});
|
|
3563
3563
|
a = !0, u.destroyed || (this.#A = null, E("DESTRUCTION_FAILED"));
|
|
3564
|
-
const p = this.#
|
|
3564
|
+
const p = this.#O, f = u.permit;
|
|
3565
3565
|
if (d)
|
|
3566
3566
|
return this.#I(p, f), this.#g = Object.freeze({
|
|
3567
3567
|
connectedResult: l,
|
|
@@ -3585,7 +3585,7 @@ class Wo {
|
|
|
3585
3585
|
} finally {
|
|
3586
3586
|
A && this.#o.delete(A);
|
|
3587
3587
|
}
|
|
3588
|
-
if (this.#I(p, f), ue({ document: this.#
|
|
3588
|
+
if (this.#I(p, f), ue({ document: this.#i, window: this.#s }), typeof this.#c?.navigate == "function") {
|
|
3589
3589
|
const h = nn(o.transaction, b);
|
|
3590
3590
|
this.#I(p, f), this.#u = null, this.#c.navigate(h.redirectUri);
|
|
3591
3591
|
} else
|
|
@@ -3595,19 +3595,19 @@ class Wo {
|
|
|
3595
3595
|
this.#u === f && (this.#u = null);
|
|
3596
3596
|
}
|
|
3597
3597
|
} catch (o) {
|
|
3598
|
-
throw !a && (this.#
|
|
3598
|
+
throw !a && (this.#r !== s || this.#t !== r) && E("STALE_CONTROLLER"), o instanceof $ ? o : o instanceof Ie ? new $(o.code) : o;
|
|
3599
3599
|
} finally {
|
|
3600
|
-
n && this.#o.delete(n), a || this.#V(
|
|
3600
|
+
n && this.#o.delete(n), a || this.#V(r, s);
|
|
3601
3601
|
}
|
|
3602
3602
|
}
|
|
3603
3603
|
async execute(t) {
|
|
3604
3604
|
(this.#e || this.#n || this.#t === null) && E("STALE_CONTROLLER");
|
|
3605
|
-
const n = this.#t,
|
|
3605
|
+
const n = this.#t, r = this.#r;
|
|
3606
3606
|
try {
|
|
3607
|
-
const
|
|
3608
|
-
return await this.executePrepared(
|
|
3609
|
-
} catch (
|
|
3610
|
-
throw !this.#n && this.#t === n && this.#V(n,
|
|
3607
|
+
const i = await this.prepare(t);
|
|
3608
|
+
return await this.executePrepared(i);
|
|
3609
|
+
} catch (i) {
|
|
3610
|
+
throw !this.#n && this.#t === n && this.#V(n, r), i;
|
|
3611
3611
|
}
|
|
3612
3612
|
}
|
|
3613
3613
|
async logout() {
|
|
@@ -3619,24 +3619,24 @@ class Wo {
|
|
|
3619
3619
|
return this.#F("connected");
|
|
3620
3620
|
}
|
|
3621
3621
|
revokeNow(t) {
|
|
3622
|
-
if (this.#
|
|
3622
|
+
if (this.#O = this.#O >= Number.MAX_SAFE_INTEGER ? 1 : this.#O + 1, this.#u = null, this.#g = null, this.#e) {
|
|
3623
3623
|
this.#E();
|
|
3624
3624
|
return;
|
|
3625
3625
|
}
|
|
3626
3626
|
!this.#n && (this.#n = !0, this.#U()), this.#d = !1, this.#A = null, this.#t !== null && this.#t !== void 0 && this.#a.add(this.#t), this.#t = null, this.#p = null;
|
|
3627
|
-
const
|
|
3627
|
+
const r = this.#h;
|
|
3628
3628
|
this.#h = null;
|
|
3629
|
-
const
|
|
3630
|
-
|
|
3629
|
+
const i = !this.#$;
|
|
3630
|
+
i && (this.#$ = !0);
|
|
3631
3631
|
try {
|
|
3632
|
-
|
|
3632
|
+
r?.cancel("STALE_CONTROLLER");
|
|
3633
3633
|
} catch {
|
|
3634
3634
|
}
|
|
3635
3635
|
try {
|
|
3636
|
-
|
|
3636
|
+
r?.destroy();
|
|
3637
3637
|
} catch {
|
|
3638
3638
|
}
|
|
3639
|
-
if (this.#T(), this.#B(), this.#M(), this.#E(),
|
|
3639
|
+
if (this.#T(), this.#B(), this.#M(), this.#E(), i)
|
|
3640
3640
|
try {
|
|
3641
3641
|
this.#c?.revokeNow?.(t);
|
|
3642
3642
|
} catch {
|
|
@@ -3646,10 +3646,10 @@ class Wo {
|
|
|
3646
3646
|
if (this.#S)
|
|
3647
3647
|
return this.#E(), this.#S;
|
|
3648
3648
|
let n;
|
|
3649
|
-
const
|
|
3650
|
-
n =
|
|
3649
|
+
const r = new Promise((i) => {
|
|
3650
|
+
n = i;
|
|
3651
3651
|
});
|
|
3652
|
-
return this.#S =
|
|
3652
|
+
return this.#S = r, (async () => {
|
|
3653
3653
|
try {
|
|
3654
3654
|
this.revokeNow(t), this.#e = !0, this.#W();
|
|
3655
3655
|
try {
|
|
@@ -3659,10 +3659,10 @@ class Wo {
|
|
|
3659
3659
|
} finally {
|
|
3660
3660
|
n();
|
|
3661
3661
|
}
|
|
3662
|
-
})(),
|
|
3662
|
+
})(), r;
|
|
3663
3663
|
}
|
|
3664
3664
|
}
|
|
3665
|
-
const
|
|
3665
|
+
const Ho = [
|
|
3666
3666
|
{
|
|
3667
3667
|
allowedOperations: [
|
|
3668
3668
|
"sdn.wallet.account.v1",
|
|
@@ -3730,7 +3730,7 @@ const zo = [
|
|
|
3730
3730
|
audiences: [
|
|
3731
3731
|
"sdn-field-encryption/v1|flatbuffers"
|
|
3732
3732
|
],
|
|
3733
|
-
callbackUri: "https://
|
|
3733
|
+
callbackUri: "https://flatbuffers.spacedatanetwork.org/wallet-callback.html",
|
|
3734
3734
|
clientDisplayName: "FlatBuffers Documentation",
|
|
3735
3735
|
clientId: "sdn-flatbuffers-pages-v1",
|
|
3736
3736
|
operationBindings: [
|
|
@@ -3759,7 +3759,7 @@ const zo = [
|
|
|
3759
3759
|
serviceInstance: null
|
|
3760
3760
|
}
|
|
3761
3761
|
],
|
|
3762
|
-
requestOrigin: "https://
|
|
3762
|
+
requestOrigin: "https://flatbuffers.spacedatanetwork.org"
|
|
3763
3763
|
},
|
|
3764
3764
|
{
|
|
3765
3765
|
allowedOperations: [
|
|
@@ -3770,7 +3770,7 @@ const zo = [
|
|
|
3770
3770
|
audiences: [
|
|
3771
3771
|
"sdn-field-encryption/v1|flatsql"
|
|
3772
3772
|
],
|
|
3773
|
-
callbackUri: "https://
|
|
3773
|
+
callbackUri: "https://flatsql.spacedatanetwork.org/wallet-callback.html",
|
|
3774
3774
|
clientDisplayName: "FlatSQL Documentation",
|
|
3775
3775
|
clientId: "sdn-flatsql-pages-v1",
|
|
3776
3776
|
operationBindings: [
|
|
@@ -3799,7 +3799,7 @@ const zo = [
|
|
|
3799
3799
|
serviceInstance: null
|
|
3800
3800
|
}
|
|
3801
3801
|
],
|
|
3802
|
-
requestOrigin: "https://
|
|
3802
|
+
requestOrigin: "https://flatsql.spacedatanetwork.org"
|
|
3803
3803
|
},
|
|
3804
3804
|
{
|
|
3805
3805
|
allowedOperations: [
|
|
@@ -3807,7 +3807,7 @@ const zo = [
|
|
|
3807
3807
|
"sdn.wallet.connect.v1"
|
|
3808
3808
|
],
|
|
3809
3809
|
audiences: [],
|
|
3810
|
-
callbackUri: "https://
|
|
3810
|
+
callbackUri: "https://module-sdk.spacedatanetwork.org/wallet-callback.html",
|
|
3811
3811
|
clientDisplayName: "Space Data Module SDK",
|
|
3812
3812
|
clientId: "sdn-module-sdk-pages-v1",
|
|
3813
3813
|
operationBindings: [
|
|
@@ -3828,7 +3828,7 @@ const zo = [
|
|
|
3828
3828
|
serviceInstance: null
|
|
3829
3829
|
}
|
|
3830
3830
|
],
|
|
3831
|
-
requestOrigin: "https://
|
|
3831
|
+
requestOrigin: "https://module-sdk.spacedatanetwork.org"
|
|
3832
3832
|
},
|
|
3833
3833
|
{
|
|
3834
3834
|
allowedOperations: [
|
|
@@ -3923,9 +3923,9 @@ const zo = [
|
|
|
3923
3923
|
"sdn.wallet.connect.v1"
|
|
3924
3924
|
],
|
|
3925
3925
|
audiences: [],
|
|
3926
|
-
callbackUri: "https://digitalarsenal.github.io/
|
|
3927
|
-
clientDisplayName: "
|
|
3928
|
-
clientId: "
|
|
3926
|
+
callbackUri: "https://digitalarsenal.github.io/hd-wallet-wasm/wallet-callback.html",
|
|
3927
|
+
clientDisplayName: "DigitalArsenal GitHub Pages",
|
|
3928
|
+
clientId: "digitalarsenal-pages-v1",
|
|
3929
3929
|
operationBindings: [
|
|
3930
3930
|
{
|
|
3931
3931
|
audience: null,
|
|
@@ -3952,7 +3952,7 @@ const zo = [
|
|
|
3952
3952
|
"sdn.wallet.connect.v1"
|
|
3953
3953
|
],
|
|
3954
3954
|
audiences: [],
|
|
3955
|
-
callbackUri: "https://
|
|
3955
|
+
callbackUri: "https://asset-models.spacedatanetwork.org/wallet-callback.html",
|
|
3956
3956
|
clientDisplayName: "SDN Asset Models",
|
|
3957
3957
|
clientId: "sdn-asset-models-pages-v1",
|
|
3958
3958
|
operationBindings: [
|
|
@@ -3973,7 +3973,7 @@ const zo = [
|
|
|
3973
3973
|
serviceInstance: null
|
|
3974
3974
|
}
|
|
3975
3975
|
],
|
|
3976
|
-
requestOrigin: "https://
|
|
3976
|
+
requestOrigin: "https://asset-models.spacedatanetwork.org"
|
|
3977
3977
|
},
|
|
3978
3978
|
{
|
|
3979
3979
|
allowedOperations: [
|
|
@@ -4025,9 +4025,9 @@ const zo = [
|
|
|
4025
4025
|
],
|
|
4026
4026
|
requestOrigin: "https://review.spacedatanetwork.org"
|
|
4027
4027
|
}
|
|
4028
|
-
],
|
|
4029
|
-
clients:
|
|
4030
|
-
registryReleaseSha256:
|
|
4028
|
+
], zo = "f5f7e3eab42bbb12bd85d95289e0a8006941ceb8505f6dc1cde12a38f4a79a63", Ko = 1, Hr = {
|
|
4029
|
+
clients: Ho,
|
|
4030
|
+
registryReleaseSha256: zo,
|
|
4031
4031
|
schemaVersion: Ko
|
|
4032
4032
|
}, Go = new TextEncoder(), Jo = /^[0-9a-f]{64}$/u, Yo = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u, Qo = Object.freeze({
|
|
4033
4033
|
"sdn.auth.publish-request.v1": Object.freeze({
|
|
@@ -4100,15 +4100,17 @@ const zo = [
|
|
|
4100
4100
|
]), Qn = Object.freeze([
|
|
4101
4101
|
Object.freeze(["sdn-landing-web-v1", "Space Data Network", "https://spacedatanetwork.org", "https://spacedatanetwork.org/wallet-callback.html", be]),
|
|
4102
4102
|
Object.freeze(["sdn-standards-web-v1", "Space Data Standards", "https://spacedatastandards.org", "https://spacedatastandards.org/wallet-callback.html", be]),
|
|
4103
|
-
Object.freeze(["sdn-flatbuffers-pages-v1", "FlatBuffers Documentation", "https://
|
|
4104
|
-
Object.freeze(["sdn-flatsql-pages-v1", "FlatSQL Documentation", "https://
|
|
4105
|
-
Object.freeze(["sdn-module-sdk-pages-v1", "Space Data Module SDK", "https://
|
|
4103
|
+
Object.freeze(["sdn-flatbuffers-pages-v1", "FlatBuffers Documentation", "https://flatbuffers.spacedatanetwork.org", "https://flatbuffers.spacedatanetwork.org/wallet-callback.html", ea]),
|
|
4104
|
+
Object.freeze(["sdn-flatsql-pages-v1", "FlatSQL Documentation", "https://flatsql.spacedatanetwork.org", "https://flatsql.spacedatanetwork.org/wallet-callback.html", ta]),
|
|
4105
|
+
Object.freeze(["sdn-module-sdk-pages-v1", "Space Data Module SDK", "https://module-sdk.spacedatanetwork.org", "https://module-sdk.spacedatanetwork.org/wallet-callback.html", be]),
|
|
4106
4106
|
Object.freeze(["spaceaware-web-v1", "SpaceAware", "https://spaceaware.io", "https://spaceaware.io/wallet/callback", Zo]),
|
|
4107
4107
|
Object.freeze(["sdn-node-console-v1", "SDN Node Console", "https://sdn.spaceaware.io", "https://sdn.spaceaware.io/wallet/callback", Xo]),
|
|
4108
|
-
|
|
4109
|
-
|
|
4108
|
+
// Every page on digitalarsenal.github.io is one browser origin, so it is one
|
|
4109
|
+
// client and signs in only: no key operation is bound to a shared origin.
|
|
4110
|
+
Object.freeze(["digitalarsenal-pages-v1", "DigitalArsenal GitHub Pages", "https://digitalarsenal.github.io", "https://digitalarsenal.github.io/hd-wallet-wasm/wallet-callback.html", be]),
|
|
4111
|
+
Object.freeze(["sdn-asset-models-pages-v1", "SDN Asset Models", "https://asset-models.spacedatanetwork.org", "https://asset-models.spacedatanetwork.org/wallet-callback.html", be]),
|
|
4110
4112
|
Object.freeze(["sdn-asset-review-v1", "SDN Asset Review", "https://review.spacedatanetwork.org", "https://review.spacedatanetwork.org/wallet/callback", na])
|
|
4111
|
-
]),
|
|
4113
|
+
]), ra = Object.freeze([
|
|
4112
4114
|
Object.freeze({
|
|
4113
4115
|
audience: null,
|
|
4114
4116
|
clientId: "spaceaware-web-v1",
|
|
@@ -4154,7 +4156,7 @@ const zo = [
|
|
|
4154
4156
|
clientId: "sdn-flatbuffers-pages-v1",
|
|
4155
4157
|
maxLifetimeSeconds: 300,
|
|
4156
4158
|
operation: "sdn.wallet.field-open.v1",
|
|
4157
|
-
requestOrigin: "https://
|
|
4159
|
+
requestOrigin: "https://flatbuffers.spacedatanetwork.org",
|
|
4158
4160
|
registryRow: "flatbuffers-field-open-v1",
|
|
4159
4161
|
serviceActivationState: null,
|
|
4160
4162
|
serviceInstance: null
|
|
@@ -4164,7 +4166,7 @@ const zo = [
|
|
|
4164
4166
|
clientId: "sdn-flatsql-pages-v1",
|
|
4165
4167
|
maxLifetimeSeconds: 300,
|
|
4166
4168
|
operation: "sdn.wallet.key-unwrap.v1",
|
|
4167
|
-
requestOrigin: "https://
|
|
4169
|
+
requestOrigin: "https://flatsql.spacedatanetwork.org",
|
|
4168
4170
|
registryRow: "flatsql-key-unwrap-v1",
|
|
4169
4171
|
serviceActivationState: null,
|
|
4170
4172
|
serviceInstance: null
|
|
@@ -4180,11 +4182,11 @@ function An(e) {
|
|
|
4180
4182
|
}
|
|
4181
4183
|
function It(e, t, n) {
|
|
4182
4184
|
An(e) || V(`${n} must be an object`);
|
|
4183
|
-
const
|
|
4184
|
-
|
|
4185
|
-
const
|
|
4186
|
-
(
|
|
4187
|
-
for (const a of
|
|
4185
|
+
const r = Reflect.ownKeys(e);
|
|
4186
|
+
r.some((a) => typeof a != "string") && V(`${n} has missing or unknown fields`);
|
|
4187
|
+
const i = r.sort(), s = [...t].sort();
|
|
4188
|
+
(i.length !== s.length || i.some((a, o) => a !== s[o])) && V(`${n} has missing or unknown fields`);
|
|
4189
|
+
for (const a of i) {
|
|
4188
4190
|
const o = Object.getOwnPropertyDescriptor(e, a);
|
|
4189
4191
|
(!o || !o.enumerable || !("value" in o) || o.value === void 0) && V(`${n} has an invalid field`);
|
|
4190
4192
|
}
|
|
@@ -4193,11 +4195,11 @@ function It(e, t, n) {
|
|
|
4193
4195
|
function me(e) {
|
|
4194
4196
|
return e === null || typeof e == "boolean" || typeof e == "string" ? JSON.stringify(e) : typeof e == "number" ? (Number.isFinite(e) || V("registry contains a non-finite number"), JSON.stringify(e)) : Array.isArray(e) ? `[${e.map(me).join(",")}]` : (An(e) || V("registry contains an unsupported value"), `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${me(e[t])}`).join(",")}}`);
|
|
4195
4197
|
}
|
|
4196
|
-
async function
|
|
4198
|
+
async function ia(e) {
|
|
4197
4199
|
const t = globalThis.crypto?.subtle;
|
|
4198
4200
|
t || V("Web Crypto SHA-256 is unavailable");
|
|
4199
4201
|
const n = new Uint8Array(await t.digest("SHA-256", Go.encode(e)));
|
|
4200
|
-
return Array.from(n, (
|
|
4202
|
+
return Array.from(n, (r) => r.toString(16).padStart(2, "0")).join("");
|
|
4201
4203
|
}
|
|
4202
4204
|
function xt(e) {
|
|
4203
4205
|
if (Array.isArray(e)) return Object.freeze(e.map(xt));
|
|
@@ -4229,8 +4231,8 @@ function oa(e, t) {
|
|
|
4229
4231
|
function aa(e) {
|
|
4230
4232
|
It(e, ["clients", "registryReleaseSha256", "schemaVersion"], "registry"), e.schemaVersion !== 1 && V("registry schemaVersion must be 1"), (typeof e.registryReleaseSha256 != "string" || !Jo.test(e.registryReleaseSha256)) && V("registryReleaseSha256 must be lowercase SHA-256"), (!Array.isArray(e.clients) || e.clients.length !== Qn.length) && V("registry must contain exactly the reviewed clients");
|
|
4231
4233
|
const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
4232
|
-
e.clients.forEach((
|
|
4233
|
-
It(
|
|
4234
|
+
e.clients.forEach((r, i) => {
|
|
4235
|
+
It(r, [
|
|
4234
4236
|
"allowedOperations",
|
|
4235
4237
|
"audiences",
|
|
4236
4238
|
"callbackUri",
|
|
@@ -4238,9 +4240,9 @@ function aa(e) {
|
|
|
4238
4240
|
"clientId",
|
|
4239
4241
|
"operationBindings",
|
|
4240
4242
|
"requestOrigin"
|
|
4241
|
-
], `client ${
|
|
4242
|
-
const [s, a, o, c, l] = Qn[
|
|
4243
|
-
(
|
|
4243
|
+
], `client ${i}`);
|
|
4244
|
+
const [s, a, o, c, l] = Qn[i];
|
|
4245
|
+
(r.clientId !== s || r.clientDisplayName !== a || r.requestOrigin !== o || r.callbackUri !== c) && V(`client ${i} differs from the reviewed row`), (!Yo.test(r.clientId) || t.has(r.clientId)) && V("clientId must be unique and canonical"), t.add(r.clientId), (typeof r.clientDisplayName != "string" || r.clientDisplayName.length < 1 || r.clientDisplayName.length > 80) && V("clientDisplayName is invalid"), sa(r.requestOrigin, "requestOrigin"), oa(r.callbackUri, r.requestOrigin), (!Array.isArray(r.allowedOperations) || me(r.allowedOperations) !== me(l)) && V(`${r.clientId} allowedOperations differ from the reviewed allowlist`), (!Array.isArray(r.operationBindings) || r.operationBindings.length !== l.length) && V(`${r.clientId} operationBindings differ from the reviewed allowlist`), r.operationBindings.forEach((u, p) => {
|
|
4244
4246
|
It(u, [
|
|
4245
4247
|
"audience",
|
|
4246
4248
|
"maxLifetimeSeconds",
|
|
@@ -4248,51 +4250,51 @@ function aa(e) {
|
|
|
4248
4250
|
"registryRow",
|
|
4249
4251
|
"serviceActivationState",
|
|
4250
4252
|
"serviceInstance"
|
|
4251
|
-
], `${
|
|
4253
|
+
], `${r.clientId} operation ${p}`);
|
|
4252
4254
|
const f = l[p];
|
|
4253
|
-
u.operation !== f && V(`${
|
|
4255
|
+
u.operation !== f && V(`${r.clientId} operation allowlist order or value changed`);
|
|
4254
4256
|
const A = Qo[u.operation];
|
|
4255
|
-
A || V("unknown registry operation"), (u.maxLifetimeSeconds !== 300 || u.audience !== A.audience || u.registryRow !== A.registryRow || u.serviceActivationState !== A.serviceActivationState || u.serviceInstance !== A.serviceInstance) && V(`${
|
|
4256
|
-
const b = `${
|
|
4257
|
+
A || V("unknown registry operation"), (u.maxLifetimeSeconds !== 300 || u.audience !== A.audience || u.registryRow !== A.registryRow || u.serviceActivationState !== A.serviceActivationState || u.serviceInstance !== A.serviceInstance) && V(`${r.clientId} operation policy differs from the reviewed binding`);
|
|
4258
|
+
const b = `${r.clientId}\0${r.requestOrigin}\0${u.operation}`;
|
|
4257
4259
|
n.has(b) && V("duplicate registry binding"), n.add(b);
|
|
4258
4260
|
});
|
|
4259
|
-
const d = [...new Set(
|
|
4260
|
-
(!Array.isArray(
|
|
4261
|
+
const d = [...new Set(r.operationBindings.map(({ audience: u }) => u).filter((u) => u !== null))].sort();
|
|
4262
|
+
(!Array.isArray(r.audiences) || me(r.audiences) !== me(d)) && V(`${r.clientId} audiences differ from operationBindings`), me(r.allowedOperations) !== me(r.operationBindings.map(({ operation: u }) => u)) && V(`${r.clientId} allowedOperations differ from operationBindings`);
|
|
4261
4263
|
});
|
|
4262
|
-
for (const
|
|
4263
|
-
const
|
|
4264
|
+
for (const r of ra) {
|
|
4265
|
+
const i = e.clients.find((o) => o.clientId === r.clientId && o.requestOrigin === r.requestOrigin), s = i?.operationBindings.find((o) => o.operation === r.operation), a = s && {
|
|
4264
4266
|
audience: s.audience,
|
|
4265
|
-
clientId:
|
|
4267
|
+
clientId: i.clientId,
|
|
4266
4268
|
maxLifetimeSeconds: s.maxLifetimeSeconds,
|
|
4267
4269
|
operation: s.operation,
|
|
4268
|
-
requestOrigin:
|
|
4270
|
+
requestOrigin: i.requestOrigin,
|
|
4269
4271
|
registryRow: s.registryRow,
|
|
4270
4272
|
serviceActivationState: s.serviceActivationState,
|
|
4271
4273
|
serviceInstance: s.serviceInstance
|
|
4272
4274
|
};
|
|
4273
|
-
(!a || me(a) !== me(
|
|
4275
|
+
(!a || me(a) !== me(r)) && V(`registry projection drifted from compiled row ${r.registryRow}`);
|
|
4274
4276
|
}
|
|
4275
4277
|
return xt(e);
|
|
4276
4278
|
}
|
|
4277
|
-
const { registryReleaseSha256: ca, ...la } =
|
|
4279
|
+
const { registryReleaseSha256: ca, ...la } = Hr, ua = await ia(me(la));
|
|
4278
4280
|
ua !== ca && V("registry release SHA-256 mismatch");
|
|
4279
|
-
const Xn = aa(
|
|
4281
|
+
const Xn = aa(Hr);
|
|
4280
4282
|
function da(e) {
|
|
4281
4283
|
const t = It(e, ["clientId", "operation", "requestOrigin"], "registry lookup");
|
|
4282
4284
|
(typeof t.clientId != "string" || typeof t.requestOrigin != "string" || typeof t.operation != "string") && V("registry lookup fields must be strings");
|
|
4283
|
-
const n = Xn.clients.find((
|
|
4284
|
-
return (!n || !
|
|
4285
|
-
audience:
|
|
4285
|
+
const n = Xn.clients.find((i) => i.clientId === t.clientId && i.requestOrigin === t.requestOrigin), r = n?.operationBindings.find((i) => i.operation === t.operation);
|
|
4286
|
+
return (!n || !r) && V("no exact registry binding exists"), xt({
|
|
4287
|
+
audience: r.audience,
|
|
4286
4288
|
callbackUri: n.callbackUri,
|
|
4287
4289
|
clientDisplayName: n.clientDisplayName,
|
|
4288
4290
|
clientId: n.clientId,
|
|
4289
|
-
maxLifetimeSeconds:
|
|
4290
|
-
operation:
|
|
4291
|
+
maxLifetimeSeconds: r.maxLifetimeSeconds,
|
|
4292
|
+
operation: r.operation,
|
|
4291
4293
|
requestOrigin: n.requestOrigin,
|
|
4292
4294
|
registryReleaseSha256: Xn.registryReleaseSha256,
|
|
4293
|
-
registryRow:
|
|
4294
|
-
serviceActivationState:
|
|
4295
|
-
serviceInstance:
|
|
4295
|
+
registryRow: r.registryRow,
|
|
4296
|
+
serviceActivationState: r.serviceActivationState,
|
|
4297
|
+
serviceInstance: r.serviceInstance
|
|
4296
4298
|
});
|
|
4297
4299
|
}
|
|
4298
4300
|
const fa = /^\/transaction\/([0-9a-f]{64})$/u, Ft = new TextEncoder(), pa = Uint8Array.prototype.fill, ha = Object.freeze({ resolveRegistryBinding: da });
|
|
@@ -4308,20 +4310,20 @@ function qt(e) {
|
|
|
4308
4310
|
for (let t = 0; t < e.length; t += 1) {
|
|
4309
4311
|
const n = e.charCodeAt(t);
|
|
4310
4312
|
if (n >= 55296 && n <= 56319) {
|
|
4311
|
-
const
|
|
4312
|
-
if (!(
|
|
4313
|
+
const r = e.charCodeAt(++t);
|
|
4314
|
+
if (!(r >= 56320 && r <= 57343)) return !1;
|
|
4313
4315
|
} else if (n >= 56320 && n <= 57343) return !1;
|
|
4314
4316
|
}
|
|
4315
4317
|
return !0;
|
|
4316
4318
|
}
|
|
4317
|
-
function
|
|
4319
|
+
function er() {
|
|
4318
4320
|
return new $("INVALID_TRANSACTION");
|
|
4319
4321
|
}
|
|
4320
|
-
function at(e, t, n,
|
|
4321
|
-
const
|
|
4322
|
-
s.textContent = n,
|
|
4322
|
+
function at(e, t, n, r) {
|
|
4323
|
+
const i = e.createElement("label"), s = e.createElement("span");
|
|
4324
|
+
s.textContent = n, i.append(s, r), t.append(i);
|
|
4323
4325
|
}
|
|
4324
|
-
function
|
|
4326
|
+
function ze(e, t) {
|
|
4325
4327
|
for (const n of t) {
|
|
4326
4328
|
try {
|
|
4327
4329
|
n.value = "";
|
|
@@ -4361,16 +4363,16 @@ function He(e, t) {
|
|
|
4361
4363
|
} catch {
|
|
4362
4364
|
}
|
|
4363
4365
|
}
|
|
4364
|
-
function
|
|
4366
|
+
function zr({
|
|
4365
4367
|
clipboard: e,
|
|
4366
4368
|
controller: t,
|
|
4367
4369
|
document: n,
|
|
4368
|
-
onChanged:
|
|
4370
|
+
onChanged: r = () => {
|
|
4369
4371
|
}
|
|
4370
4372
|
}) {
|
|
4371
4373
|
if (!t || typeof t.listQuarantinedWalletRecords != "function") return null;
|
|
4372
|
-
const
|
|
4373
|
-
|
|
4374
|
+
const i = n.createElement("section");
|
|
4375
|
+
i.className = "wallet-quarantine-manager";
|
|
4374
4376
|
const s = t.generation;
|
|
4375
4377
|
let a = !1, o = 0, c = [], l = null;
|
|
4376
4378
|
const d = (h = o) => !a && h === o && t.isUiGenerationCurrent?.(s) === !0, u = (h, m = o) => {
|
|
@@ -4402,7 +4404,7 @@ function Hi({
|
|
|
4402
4404
|
h.addEventListener?.(m, g), c.push([h, m, g]);
|
|
4403
4405
|
}, A = () => {
|
|
4404
4406
|
if (p(), a || t.isUiGenerationCurrent?.(s) !== !0)
|
|
4405
|
-
return
|
|
4407
|
+
return i.replaceChildren(), i.hidden = !0, !1;
|
|
4406
4408
|
let h;
|
|
4407
4409
|
try {
|
|
4408
4410
|
h = t.listQuarantinedWalletRecords();
|
|
@@ -4410,8 +4412,8 @@ function Hi({
|
|
|
4410
4412
|
h = [];
|
|
4411
4413
|
}
|
|
4412
4414
|
if (!Array.isArray(h) || h.length === 0)
|
|
4413
|
-
return
|
|
4414
|
-
|
|
4415
|
+
return i.replaceChildren(), i.hidden = !0, !1;
|
|
4416
|
+
i.hidden = !1, l = Qs(i, h, { document: n });
|
|
4415
4417
|
const m = o;
|
|
4416
4418
|
for (const g of l.rows) {
|
|
4417
4419
|
const { entry: S } = g, I = async (W) => {
|
|
@@ -4457,7 +4459,7 @@ function Hi({
|
|
|
4457
4459
|
}
|
|
4458
4460
|
g.confirmationGroup.hidden = !0, u("", m);
|
|
4459
4461
|
}
|
|
4460
|
-
},
|
|
4462
|
+
}, O = (W) => {
|
|
4461
4463
|
if (W?.isTrusted !== !0 || !d(m)) return;
|
|
4462
4464
|
const T = g.confirmation.value;
|
|
4463
4465
|
if (T !== S.key) {
|
|
@@ -4478,16 +4480,16 @@ function Hi({
|
|
|
4478
4480
|
g.confirmation.defaultValue = "";
|
|
4479
4481
|
} catch {
|
|
4480
4482
|
}
|
|
4481
|
-
A(), a ||
|
|
4483
|
+
A(), a || r();
|
|
4482
4484
|
};
|
|
4483
|
-
f(g.exportButton, "click", I), f(g.deleteButton, "click", U), f(g.cancel, "click", P), f(g.confirm, "click",
|
|
4485
|
+
f(g.exportButton, "click", I), f(g.deleteButton, "click", U), f(g.cancel, "click", P), f(g.confirm, "click", O);
|
|
4484
4486
|
}
|
|
4485
4487
|
return !0;
|
|
4486
4488
|
}, b = A();
|
|
4487
4489
|
return Object.freeze({
|
|
4488
|
-
container:
|
|
4490
|
+
container: i,
|
|
4489
4491
|
destroy() {
|
|
4490
|
-
a || (a = !0, p(),
|
|
4492
|
+
a || (a = !0, p(), i.replaceChildren(), i.remove?.());
|
|
4491
4493
|
},
|
|
4492
4494
|
hasEntries: b,
|
|
4493
4495
|
refresh: A
|
|
@@ -4497,11 +4499,11 @@ function ya({
|
|
|
4497
4499
|
clipboard: e = globalThis.navigator?.clipboard,
|
|
4498
4500
|
controller: t = null,
|
|
4499
4501
|
document: n,
|
|
4500
|
-
mount:
|
|
4501
|
-
offerRememberedUnlock:
|
|
4502
|
+
mount: r = null,
|
|
4503
|
+
offerRememberedUnlock: i = !0,
|
|
4502
4504
|
title: s = "Sign in"
|
|
4503
4505
|
}) {
|
|
4504
|
-
const a =
|
|
4506
|
+
const a = r ?? n?.body;
|
|
4505
4507
|
if (!n?.createElement || !a?.append) throw new $("DOM_UNAVAILABLE");
|
|
4506
4508
|
const o = n.createElement("section");
|
|
4507
4509
|
o.className = "wallet-login";
|
|
@@ -4530,7 +4532,7 @@ function ya({
|
|
|
4530
4532
|
A.dataset.walletRememberStatus = "true";
|
|
4531
4533
|
let b = () => {
|
|
4532
4534
|
};
|
|
4533
|
-
const h =
|
|
4535
|
+
const h = zr({
|
|
4534
4536
|
clipboard: e,
|
|
4535
4537
|
controller: t,
|
|
4536
4538
|
document: n,
|
|
@@ -4543,14 +4545,14 @@ function ya({
|
|
|
4543
4545
|
} catch {
|
|
4544
4546
|
S = !1;
|
|
4545
4547
|
}
|
|
4546
|
-
S &&
|
|
4548
|
+
S && i && (g = n.createElement("button"), g.type = "button", g.dataset.walletAction = "unlock-remembered", g.textContent = "Unlock remembered wallet");
|
|
4547
4549
|
const I = n.createElement("button");
|
|
4548
4550
|
I.type = "submit", I.dataset.walletAction = "login", I.textContent = "Login";
|
|
4549
4551
|
const U = n.createElement("button");
|
|
4550
4552
|
U.type = "button", U.dataset.walletAction = "cancel-login", U.textContent = "Cancel", g && m.append(g), m.append(I, U), d.append(m), o.append(c, l), h?.hasEntries && o.append(h.container), o.append(d, A), a.append(o), t?.registerCredentialControls?.({ passwordControl: p, usernameControl: u });
|
|
4551
|
-
let P = !1,
|
|
4553
|
+
let P = !1, O, W;
|
|
4552
4554
|
const T = new Promise((N, K) => {
|
|
4553
|
-
|
|
4555
|
+
O = N, W = K;
|
|
4554
4556
|
}), q = () => {
|
|
4555
4557
|
d.removeEventListener?.("submit", oe), U.removeEventListener?.("click", X), g?.removeEventListener?.("click", B);
|
|
4556
4558
|
}, v = () => {
|
|
@@ -4569,8 +4571,8 @@ function ya({
|
|
|
4569
4571
|
}
|
|
4570
4572
|
}
|
|
4571
4573
|
A.textContent = "";
|
|
4572
|
-
},
|
|
4573
|
-
q(),
|
|
4574
|
+
}, H = () => {
|
|
4575
|
+
q(), ze(d, [u, p]), v(), o.remove?.();
|
|
4574
4576
|
}, _ = (N) => {
|
|
4575
4577
|
if (!P) {
|
|
4576
4578
|
P = !0;
|
|
@@ -4578,17 +4580,17 @@ function ya({
|
|
|
4578
4580
|
t?.revokeNow?.(N);
|
|
4579
4581
|
} catch {
|
|
4580
4582
|
}
|
|
4581
|
-
|
|
4583
|
+
H(), W(new $(N));
|
|
4582
4584
|
}
|
|
4583
4585
|
}, oe = (N) => {
|
|
4584
|
-
N?.preventDefault?.(), !(P || N?.isTrusted !== !0) && (P = !0, q(), h?.destroy?.(),
|
|
4586
|
+
N?.preventDefault?.(), !(P || N?.isTrusted !== !0) && (P = !0, q(), h?.destroy?.(), O({ passwordControl: p, rememberControl: f, rememberStatus: A, usernameControl: u }));
|
|
4585
4587
|
}, X = (N) => {
|
|
4586
4588
|
N?.isTrusted === !0 && _("USER_CANCELLED");
|
|
4587
4589
|
}, B = (N) => {
|
|
4588
|
-
P || N?.isTrusted !== !0 || (P = !0, q(), h?.destroy?.(),
|
|
4590
|
+
P || N?.isTrusted !== !0 || (P = !0, q(), h?.destroy?.(), ze(d, [u, p]), O({ remembered: !0, rememberStatus: A }));
|
|
4589
4591
|
};
|
|
4590
4592
|
b = () => {
|
|
4591
|
-
if (P || !
|
|
4593
|
+
if (P || !i) return;
|
|
4592
4594
|
let N = !1;
|
|
4593
4595
|
try {
|
|
4594
4596
|
N = t?.canRestoreRememberedWallet?.() === !0;
|
|
@@ -4603,26 +4605,26 @@ function ya({
|
|
|
4603
4605
|
}
|
|
4604
4606
|
return Object.freeze({
|
|
4605
4607
|
cancel() {
|
|
4606
|
-
P ?
|
|
4608
|
+
P ? H() : _("STALE_CONTROLLER");
|
|
4607
4609
|
},
|
|
4608
4610
|
controls: Object.freeze({ passwordControl: p, rememberControl: f, rememberStatus: A, usernameControl: u }),
|
|
4609
4611
|
form: d,
|
|
4610
4612
|
promise: T,
|
|
4611
|
-
remove:
|
|
4613
|
+
remove: H
|
|
4612
4614
|
});
|
|
4613
4615
|
}
|
|
4614
|
-
function
|
|
4616
|
+
function Kr({
|
|
4615
4617
|
document: e,
|
|
4616
4618
|
mount: t = null,
|
|
4617
4619
|
submitLabel: n = "Compare legacy account",
|
|
4618
|
-
title:
|
|
4620
|
+
title: r = "Enter the legacy BIP-39 mnemonic"
|
|
4619
4621
|
}) {
|
|
4620
|
-
const
|
|
4621
|
-
if (!e?.createElement || !
|
|
4622
|
+
const i = t ?? e?.body;
|
|
4623
|
+
if (!e?.createElement || !i?.append) throw new $("DOM_UNAVAILABLE");
|
|
4622
4624
|
const s = e.createElement("section");
|
|
4623
4625
|
s.className = "wallet-login wallet-legacy-credentials";
|
|
4624
4626
|
const a = e.createElement("h1");
|
|
4625
|
-
a.textContent =
|
|
4627
|
+
a.textContent = r;
|
|
4626
4628
|
const o = e.createElement("form");
|
|
4627
4629
|
o.noValidate = !0;
|
|
4628
4630
|
const c = e.createElement("textarea");
|
|
@@ -4630,14 +4632,14 @@ function Ki({
|
|
|
4630
4632
|
const l = e.createElement("button");
|
|
4631
4633
|
l.type = "submit", l.dataset.walletAction = "confirm-legacy-mnemonic", l.textContent = n;
|
|
4632
4634
|
const d = e.createElement("button");
|
|
4633
|
-
d.type = "button", d.dataset.walletAction = "cancel-legacy-migration", d.textContent = "Cancel", o.append(l, d), s.append(a, o),
|
|
4635
|
+
d.type = "button", d.dataset.walletAction = "cancel-legacy-migration", d.textContent = "Cancel", o.append(l, d), s.append(a, o), i.append(s);
|
|
4634
4636
|
let u = !1, p, f;
|
|
4635
4637
|
const A = new Promise((I, U) => {
|
|
4636
4638
|
p = I, f = U;
|
|
4637
4639
|
}), b = () => {
|
|
4638
4640
|
o.removeEventListener?.("submit", g), d.removeEventListener?.("click", S);
|
|
4639
4641
|
}, h = () => {
|
|
4640
|
-
b(),
|
|
4642
|
+
b(), ze(o, [c]), s.remove?.();
|
|
4641
4643
|
}, m = () => {
|
|
4642
4644
|
u || (u = !0, h(), f(new $("USER_CANCELLED")));
|
|
4643
4645
|
}, g = (I) => {
|
|
@@ -4659,10 +4661,10 @@ function Ki({
|
|
|
4659
4661
|
});
|
|
4660
4662
|
}
|
|
4661
4663
|
function ma({ document: e, mount: t = null, title: n = "Choose legacy wallet profile" }) {
|
|
4662
|
-
const
|
|
4663
|
-
if (!e?.createElement || !
|
|
4664
|
-
const
|
|
4665
|
-
|
|
4664
|
+
const r = t ?? e?.body;
|
|
4665
|
+
if (!e?.createElement || !r?.append) throw new $("DOM_UNAVAILABLE");
|
|
4666
|
+
const i = e.createElement("section");
|
|
4667
|
+
i.className = "wallet-login wallet-legacy-profile";
|
|
4666
4668
|
const s = e.createElement("h1");
|
|
4667
4669
|
s.textContent = n;
|
|
4668
4670
|
const a = e.createElement("p");
|
|
@@ -4683,7 +4685,7 @@ function ma({ document: e, mount: t = null, title: n = "Choose legacy wallet pro
|
|
|
4683
4685
|
const l = e.createElement("button");
|
|
4684
4686
|
l.type = "submit", l.dataset.walletAction = "continue-legacy-login", l.textContent = "Continue";
|
|
4685
4687
|
const d = e.createElement("button");
|
|
4686
|
-
d.type = "button", d.dataset.walletAction = "cancel-legacy-login", d.textContent = "Cancel", o.append(l, d),
|
|
4688
|
+
d.type = "button", d.dataset.walletAction = "cancel-legacy-login", d.textContent = "Cancel", o.append(l, d), i.append(s, a, o), r.append(i);
|
|
4687
4689
|
let u = !1, p, f;
|
|
4688
4690
|
const A = new Promise((I, U) => {
|
|
4689
4691
|
p = I, f = U;
|
|
@@ -4694,7 +4696,7 @@ function ma({ document: e, mount: t = null, title: n = "Choose legacy wallet pro
|
|
|
4694
4696
|
c.value = "";
|
|
4695
4697
|
} catch {
|
|
4696
4698
|
}
|
|
4697
|
-
|
|
4699
|
+
ze(o, [c]), i.remove?.();
|
|
4698
4700
|
}, m = () => {
|
|
4699
4701
|
u || (u = !0, b(), h(), f(new $("USER_CANCELLED")));
|
|
4700
4702
|
}, g = (I) => {
|
|
@@ -4711,14 +4713,14 @@ function ma({ document: e, mount: t = null, title: n = "Choose legacy wallet pro
|
|
|
4711
4713
|
}
|
|
4712
4714
|
return Object.freeze({ cancel: m, promise: A });
|
|
4713
4715
|
}
|
|
4714
|
-
function mt(e, t, n,
|
|
4715
|
-
const
|
|
4716
|
+
function mt(e, t, n, r) {
|
|
4717
|
+
const i = e.createElement("div"), s = e.createElement("strong");
|
|
4716
4718
|
s.textContent = `${n}: `;
|
|
4717
4719
|
const a = e.createElement("span");
|
|
4718
|
-
a.textContent = String(
|
|
4720
|
+
a.textContent = String(r ?? ""), i.append(s, a), t.append(i);
|
|
4719
4721
|
}
|
|
4720
|
-
function
|
|
4721
|
-
const
|
|
4722
|
+
function Gr(e, t, n, r = null) {
|
|
4723
|
+
const i = r ?? e?.body, s = e.createElement("section");
|
|
4722
4724
|
s.className = "wallet-complete";
|
|
4723
4725
|
const a = e.createElement("h1");
|
|
4724
4726
|
a.textContent = "Complete";
|
|
@@ -4731,24 +4733,24 @@ function Gi(e, t, n, i = null) {
|
|
|
4731
4733
|
t?.close?.();
|
|
4732
4734
|
} catch {
|
|
4733
4735
|
}
|
|
4734
|
-
}), s.append(a, o, c),
|
|
4736
|
+
}), s.append(a, o, c), i?.replaceChildren?.(s);
|
|
4735
4737
|
}
|
|
4736
|
-
function
|
|
4737
|
-
const
|
|
4738
|
-
if (!e?.createElement || !
|
|
4739
|
-
const
|
|
4740
|
-
|
|
4738
|
+
function Jr(e, t = "The wallet request could not be completed. Close this window.", n = null) {
|
|
4739
|
+
const r = n ?? e?.body;
|
|
4740
|
+
if (!e?.createElement || !r?.replaceChildren) return;
|
|
4741
|
+
const i = e.createElement("section");
|
|
4742
|
+
i.className = "wallet-terminal-error";
|
|
4741
4743
|
const s = e.createElement("h1");
|
|
4742
4744
|
s.textContent = "Wallet request stopped";
|
|
4743
4745
|
const a = e.createElement("p");
|
|
4744
|
-
a.textContent = t,
|
|
4746
|
+
a.textContent = t, i.append(s, a), r.replaceChildren(i);
|
|
4745
4747
|
}
|
|
4746
4748
|
function ga({
|
|
4747
4749
|
clipboard: e,
|
|
4748
4750
|
controller: t,
|
|
4749
4751
|
document: n,
|
|
4750
|
-
identity:
|
|
4751
|
-
isAppCurrent:
|
|
4752
|
+
identity: r,
|
|
4753
|
+
isAppCurrent: i = () => !0,
|
|
4752
4754
|
makeCredentialPrompt: s,
|
|
4753
4755
|
mount: a,
|
|
4754
4756
|
onClear: o,
|
|
@@ -4756,7 +4758,7 @@ function ga({
|
|
|
4756
4758
|
}) {
|
|
4757
4759
|
const l = n.createElement("section");
|
|
4758
4760
|
l.className = "wallet-account";
|
|
4759
|
-
const d = n.createElement("div"), u = Js(d,
|
|
4761
|
+
const d = n.createElement("div"), u = Js(d, r, { document: n }), p = n.createElement("section");
|
|
4760
4762
|
p.className = "wallet-approval-card";
|
|
4761
4763
|
const f = n.createElement("h2");
|
|
4762
4764
|
f.textContent = "Asset review approval";
|
|
@@ -4775,21 +4777,21 @@ function ga({
|
|
|
4775
4777
|
} catch {
|
|
4776
4778
|
U = !1;
|
|
4777
4779
|
}
|
|
4778
|
-
const P = U ? n.createElement("section") : null,
|
|
4779
|
-
|
|
4780
|
-
const W =
|
|
4780
|
+
const P = U ? n.createElement("section") : null, O = P ? Ys(P, { document: n }) : null;
|
|
4781
|
+
O && (O.launch.dataset.walletAction = "forget-stored-wallet");
|
|
4782
|
+
const W = zr({
|
|
4781
4783
|
clipboard: e,
|
|
4782
4784
|
controller: t,
|
|
4783
4785
|
document: n
|
|
4784
4786
|
}), T = n.createElement("p");
|
|
4785
4787
|
T.className = "wallet-account-exit-status", l.append(d, p), P && l.append(P), W?.hasEntries && l.append(W.container), l.append(g, m, S), a.replaceChildren(l);
|
|
4786
4788
|
const q = new Zs({
|
|
4787
|
-
credentialRound: async (
|
|
4789
|
+
credentialRound: async (R) => {
|
|
4788
4790
|
const j = s({
|
|
4789
4791
|
controller: null,
|
|
4790
4792
|
document: n,
|
|
4791
4793
|
mount: a,
|
|
4792
|
-
title: `Confirm account (${
|
|
4794
|
+
title: `Confirm account (${R} of 2)`
|
|
4793
4795
|
});
|
|
4794
4796
|
j?.promise && v.add(j);
|
|
4795
4797
|
try {
|
|
@@ -4798,37 +4800,37 @@ function ga({
|
|
|
4798
4800
|
j?.promise && v.delete(j);
|
|
4799
4801
|
}
|
|
4800
4802
|
},
|
|
4801
|
-
expectedIdentity:
|
|
4803
|
+
expectedIdentity: r,
|
|
4802
4804
|
wasm: c
|
|
4803
|
-
}), v = /* @__PURE__ */ new Set(),
|
|
4804
|
-
let X = !1, B = !1, N = !1, K = null, Z = !1, G = !1, Y = !1,
|
|
4805
|
-
const le = (
|
|
4806
|
-
if (!le(
|
|
4807
|
-
}, Ne = (
|
|
4808
|
-
Zn(
|
|
4805
|
+
}), v = /* @__PURE__ */ new Set(), H = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Set(), oe = /* @__PURE__ */ new Set();
|
|
4806
|
+
let X = !1, B = !1, N = !1, K = null, Z = !1, G = !1, Y = !1, re = 0, ae = !1, se = 0;
|
|
4807
|
+
const le = (R) => !B && se === R, Q = (R) => {
|
|
4808
|
+
if (!le(R)) throw new Error("account surface closed");
|
|
4809
|
+
}, Ne = (R) => (R instanceof Uint8Array && oe.add(R), R), $e = (R) => {
|
|
4810
|
+
Zn(R), oe.delete(R);
|
|
4809
4811
|
}, Ke = () => {
|
|
4810
|
-
const
|
|
4812
|
+
const R = [...oe];
|
|
4811
4813
|
oe.clear();
|
|
4812
|
-
for (const j of
|
|
4814
|
+
for (const j of R) Zn(j);
|
|
4813
4815
|
}, Se = () => {
|
|
4814
|
-
const
|
|
4815
|
-
g.disabled = N, m.disabled = N, B || (h.disabled =
|
|
4816
|
-
}, Me = (
|
|
4817
|
-
if (!
|
|
4818
|
-
if (_.has(
|
|
4819
|
-
_.add(
|
|
4816
|
+
const R = X || Y || Z;
|
|
4817
|
+
g.disabled = N, m.disabled = N, B || (h.disabled = R || !u.approvalAvailable, I.launch.disabled = R, O && (O.launch.disabled = R || G, O.confirm.disabled = R, O.cancel.disabled = R));
|
|
4818
|
+
}, Me = (R) => {
|
|
4819
|
+
if (!H.has(R)) return !0;
|
|
4820
|
+
if (_.has(R)) return !1;
|
|
4821
|
+
_.add(R);
|
|
4820
4822
|
try {
|
|
4821
|
-
return (c?.sdn ?? c).destroySdnIdentity(
|
|
4823
|
+
return (c?.sdn ?? c).destroySdnIdentity(R), H.delete(R), !0;
|
|
4822
4824
|
} catch {
|
|
4823
4825
|
return !1;
|
|
4824
4826
|
} finally {
|
|
4825
|
-
_.delete(
|
|
4827
|
+
_.delete(R);
|
|
4826
4828
|
}
|
|
4827
4829
|
}, Ge = () => {
|
|
4828
|
-
for (const
|
|
4829
|
-
return
|
|
4830
|
-
}, Je = async (
|
|
4831
|
-
if (
|
|
4830
|
+
for (const R of [...H]) Me(R);
|
|
4831
|
+
return H.size === 0;
|
|
4832
|
+
}, Je = async (R) => {
|
|
4833
|
+
if (R?.isTrusted !== !0 || X || Y || Z) return;
|
|
4832
4834
|
const j = se;
|
|
4833
4835
|
X = !0, Se(), A.textContent = "Confirm the same account twice to enable Copy.";
|
|
4834
4836
|
try {
|
|
@@ -4846,15 +4848,15 @@ function ga({
|
|
|
4846
4848
|
} finally {
|
|
4847
4849
|
X = !1, le(j) && Se();
|
|
4848
4850
|
}
|
|
4849
|
-
},
|
|
4850
|
-
if (
|
|
4851
|
+
}, Re = async (R) => {
|
|
4852
|
+
if (R?.isTrusted !== !0 || Y || X || Z) return;
|
|
4851
4853
|
const j = I.select.value || "password-fast-v1-legacy";
|
|
4852
4854
|
if (j !== "password-fast-v1-legacy" && j !== "bip39-mnemonic-v1-legacy") {
|
|
4853
4855
|
I.result.textContent = "Legacy profile unavailable.";
|
|
4854
4856
|
return;
|
|
4855
4857
|
}
|
|
4856
4858
|
const he = se;
|
|
4857
|
-
Y = !0,
|
|
4859
|
+
Y = !0, re += 1, Se(), I.result.textContent = "Enter the selected legacy credentials to compare accounts.";
|
|
4858
4860
|
let ee = null, xe, kt, Ut, pe = null;
|
|
4859
4861
|
try {
|
|
4860
4862
|
let Bt;
|
|
@@ -4870,15 +4872,15 @@ function ga({
|
|
|
4870
4872
|
const Xe = ne?.usernameControl?.value, wn = ne?.passwordControl?.value;
|
|
4871
4873
|
if (!qt(Xe) || !qt(wn)) throw new Error("invalid legacy credentials");
|
|
4872
4874
|
xe = Ne(Ft.encode(Xe)), kt = Ne(Ft.encode(wn));
|
|
4873
|
-
const In = ne?.usernameControl?.form ?? ne?.passwordControl?.form ?? ee?.form,
|
|
4874
|
-
|
|
4875
|
+
const In = ne?.usernameControl?.form ?? ne?.passwordControl?.form ?? ee?.form, Zr = In?.parentNode;
|
|
4876
|
+
ze(In, [ne?.usernameControl, ne?.passwordControl]), Zr?.remove?.(), Bt = { passwordUtf8: kt, usernameUtf8: xe };
|
|
4875
4877
|
} else {
|
|
4876
|
-
ee =
|
|
4878
|
+
ee = Kr({ document: n, mount: a }), v.add(ee);
|
|
4877
4879
|
const ne = await ee.promise;
|
|
4878
4880
|
Q(he);
|
|
4879
4881
|
const Xe = ne?.mnemonicControl?.value;
|
|
4880
4882
|
if (!qt(Xe)) throw new Error("invalid legacy credentials");
|
|
4881
|
-
Ut = Ne(Ft.encode(Xe)),
|
|
4883
|
+
Ut = Ne(Ft.encode(Xe)), ze(ne.form, [ne.mnemonicControl]), ne.section?.remove?.(), Bt = { mnemonicUtf8: Ut };
|
|
4882
4884
|
}
|
|
4883
4885
|
if (ee?.promise && v.delete(ee), pe = await eo({
|
|
4884
4886
|
accountIndex: 0,
|
|
@@ -4887,94 +4889,94 @@ function ga({
|
|
|
4887
4889
|
profile: j,
|
|
4888
4890
|
wasm: c,
|
|
4889
4891
|
assertCurrent: () => Q(he),
|
|
4890
|
-
ownHandle: (ne) =>
|
|
4892
|
+
ownHandle: (ne) => H.add(ne)
|
|
4891
4893
|
}), Q(he), !pe?.handle) throw new Error("legacy derivation failed");
|
|
4892
|
-
const
|
|
4893
|
-
if (pe.identity?.identityScheme !==
|
|
4894
|
+
const Yr = j === "password-fast-v1-legacy" ? "sdn-fast-password-auth-v1-legacy" : "sdn-bip39-auth-v1-legacy", ht = Array.isArray(pe.identity?.keys) ? pe.identity.keys.find((ne) => ne?.purpose === "sdn-authentication") : null;
|
|
4895
|
+
if (pe.identity?.identityScheme !== Yr || pe.identity?.seedProfile !== j || typeof pe.identity?.accountXpub != "string" || !ht || typeof ht.publicKeyHex != "string" || !/^[0-9a-f]{64}$/u.test(ht.publicKeyHex))
|
|
4894
4896
|
throw new Error("legacy identity invalid");
|
|
4895
|
-
const
|
|
4897
|
+
const Qr = pe.identity;
|
|
4896
4898
|
if (!Me(pe.handle)) throw new Error("legacy destruction failed");
|
|
4897
4899
|
pe = null, Q(he);
|
|
4898
|
-
const
|
|
4899
|
-
I.result.replaceChildren(), mt(n, I.result, "Current account xpub",
|
|
4900
|
+
const Xr = r.keys.find((ne) => ne.purpose === "sdn-authentication");
|
|
4901
|
+
I.result.replaceChildren(), mt(n, I.result, "Current account xpub", r.accountXpub), mt(n, I.result, "Legacy account xpub", Qr.accountXpub), mt(n, I.result, "Current authentication key", Xr?.publicKeyHex), mt(n, I.result, "Legacy authentication key", ht.publicKeyHex);
|
|
4900
4902
|
} catch {
|
|
4901
4903
|
le(he) && (I.result.textContent = "Legacy account comparison could not be completed.");
|
|
4902
4904
|
} finally {
|
|
4903
|
-
pe?.handle && Me(pe.handle), ee?.promise && v.delete(ee), $e(xe), $e(kt), $e(Ut), Ge(),
|
|
4905
|
+
pe?.handle && Me(pe.handle), ee?.promise && v.delete(ee), $e(xe), $e(kt), $e(Ut), Ge(), re -= 1, Y = !1, le(he) && Se();
|
|
4904
4906
|
}
|
|
4905
4907
|
}, Te = () => {
|
|
4906
|
-
if (
|
|
4908
|
+
if (O) {
|
|
4907
4909
|
try {
|
|
4908
|
-
|
|
4910
|
+
O.confirmation.value = "";
|
|
4909
4911
|
} catch {
|
|
4910
4912
|
}
|
|
4911
4913
|
try {
|
|
4912
|
-
|
|
4914
|
+
O.confirmation.defaultValue = "";
|
|
4913
4915
|
} catch {
|
|
4914
4916
|
}
|
|
4915
4917
|
}
|
|
4916
|
-
}, Ye = (
|
|
4917
|
-
if (!(!
|
|
4918
|
-
Te(),
|
|
4918
|
+
}, Ye = (R) => {
|
|
4919
|
+
if (!(!O || R?.isTrusted !== !0 || X || Y || Z || G || B)) {
|
|
4920
|
+
Te(), O.confirmationGroup.hidden = !1, O.status.textContent = `Type ${O.confirmationKey} to confirm.`;
|
|
4919
4921
|
try {
|
|
4920
|
-
|
|
4922
|
+
O.confirmation.focus?.();
|
|
4921
4923
|
} catch {
|
|
4922
4924
|
}
|
|
4923
4925
|
}
|
|
4924
|
-
}, ft = (
|
|
4925
|
-
!
|
|
4926
|
-
}, _e = (
|
|
4927
|
-
if (!
|
|
4928
|
-
const j =
|
|
4929
|
-
if (j !==
|
|
4930
|
-
|
|
4926
|
+
}, ft = (R) => {
|
|
4927
|
+
!O || R?.isTrusted !== !0 || Z || B || (Te(), O.confirmationGroup.hidden = !0, O.status.textContent = "Forget cancelled.");
|
|
4928
|
+
}, _e = (R) => {
|
|
4929
|
+
if (!O || R?.isTrusted !== !0 || X || Y || Z || G || B) return;
|
|
4930
|
+
const j = O.confirmation.value;
|
|
4931
|
+
if (j !== O.confirmationKey) {
|
|
4932
|
+
O.status.textContent = "Type the exact storage key to confirm.";
|
|
4931
4933
|
return;
|
|
4932
4934
|
}
|
|
4933
4935
|
Z = !0, Se(), Te();
|
|
4934
4936
|
try {
|
|
4935
|
-
t.forgetRememberedWallet(j), G = !0,
|
|
4937
|
+
t.forgetRememberedWallet(j), G = !0, O.confirmationGroup.hidden = !0, O.status.textContent = "Stored wallet forgotten. This account remains signed in.";
|
|
4936
4938
|
} catch {
|
|
4937
|
-
|
|
4939
|
+
O.status.textContent = "Stored wallet could not be forgotten.";
|
|
4938
4940
|
} finally {
|
|
4939
4941
|
Z = !1, B || Se();
|
|
4940
4942
|
}
|
|
4941
|
-
}, Qe = (
|
|
4943
|
+
}, Qe = (R) => {
|
|
4942
4944
|
if (B)
|
|
4943
4945
|
Ke();
|
|
4944
4946
|
else {
|
|
4945
|
-
B = !0, se += 1, h.disabled = !0, I.launch.disabled = !0,
|
|
4947
|
+
B = !0, se += 1, h.disabled = !0, I.launch.disabled = !0, O && (O.launch.disabled = !0, O.confirm.disabled = !0, O.cancel.disabled = !0, Te(), O.launch.removeEventListener?.("click", Ye), O.confirm.removeEventListener?.("click", _e), O.cancel.removeEventListener?.("click", ft)), W?.destroy?.(), Ke(), h.removeEventListener?.("click", Je), I.launch.removeEventListener?.("click", Re);
|
|
4946
4948
|
for (const j of v) j.cancel?.();
|
|
4947
4949
|
v.clear();
|
|
4948
4950
|
}
|
|
4949
|
-
|
|
4951
|
+
R && !ae && (T.textContent = "Secure cleanup is still pending. Retry Return or Logout.", l.replaceChildren(T, g, m), g.disabled = !1, m.disabled = !1);
|
|
4950
4952
|
}, pt = () => {
|
|
4951
|
-
const
|
|
4952
|
-
return
|
|
4953
|
-
}, Ce = () => (Qe(!1), ae || (ae = !0, g.disabled = !0, m.disabled = !0, g.removeEventListener?.("click", bn), m.removeEventListener?.("click", En), l.remove?.()), pt()), Pt = (
|
|
4954
|
-
o(),
|
|
4953
|
+
const R = q.destroy(), j = Ge();
|
|
4954
|
+
return R && j && re === 0 && !Y && !X;
|
|
4955
|
+
}, Ce = () => (Qe(!1), ae || (ae = !0, g.disabled = !0, m.disabled = !0, g.removeEventListener?.("click", bn), m.removeEventListener?.("click", En), l.remove?.()), pt()), Pt = (R, j, he, { requireTrustedEvent: ee = !0 } = {}) => ee && R?.isTrusted !== !0 ? Promise.resolve() : K || (N || ae ? Promise.reject(new $("STALE_CONTROLLER")) : (Qe(!0), pt() ? (N = !0, g.disabled = !0, m.disabled = !0, K = (async () => {
|
|
4956
|
+
o(), Gr(n, null, he, a);
|
|
4955
4957
|
try {
|
|
4956
4958
|
const xe = await j();
|
|
4957
|
-
if (!
|
|
4959
|
+
if (!i()) throw new $("STALE_CONTROLLER");
|
|
4958
4960
|
return xe;
|
|
4959
4961
|
} catch (xe) {
|
|
4960
|
-
throw
|
|
4962
|
+
throw i() && Jr(n, void 0, a), xe;
|
|
4961
4963
|
}
|
|
4962
|
-
})(), K) : (T.textContent = "Secure cleanup is still pending. Retry Return or Logout.", g.disabled = !1, m.disabled = !1, Promise.reject(new $("DESTRUCTION_FAILED"))))), bn = (
|
|
4964
|
+
})(), K) : (T.textContent = "Secure cleanup is still pending. Retry Return or Logout.", g.disabled = !1, m.disabled = !1, Promise.reject(new $("DESTRUCTION_FAILED"))))), bn = (R) => {
|
|
4963
4965
|
Pt(
|
|
4964
|
-
|
|
4966
|
+
R,
|
|
4965
4967
|
() => t.returnToSite(),
|
|
4966
4968
|
"Returning to the requesting site."
|
|
4967
4969
|
).catch(() => {
|
|
4968
4970
|
});
|
|
4969
|
-
}, En = (
|
|
4971
|
+
}, En = (R) => {
|
|
4970
4972
|
Pt(
|
|
4971
|
-
|
|
4973
|
+
R,
|
|
4972
4974
|
() => t.logout(),
|
|
4973
4975
|
"Logged out. Returning to the requesting site."
|
|
4974
4976
|
).catch(() => {
|
|
4975
4977
|
});
|
|
4976
4978
|
};
|
|
4977
|
-
return h.addEventListener("click", Je), I.launch.addEventListener("click",
|
|
4979
|
+
return h.addEventListener("click", Je), I.launch.addEventListener("click", Re), O?.launch.addEventListener?.("click", Ye), O?.confirm.addEventListener?.("click", _e), O?.cancel.addEventListener?.("click", ft), g.addEventListener("click", bn), m.addEventListener("click", En), Object.freeze({
|
|
4978
4980
|
destroy: Ce,
|
|
4979
4981
|
logout: () => Pt(
|
|
4980
4982
|
null,
|
|
@@ -4985,15 +4987,15 @@ function ga({
|
|
|
4985
4987
|
});
|
|
4986
4988
|
}
|
|
4987
4989
|
function Aa(e) {
|
|
4988
|
-
const t = e?.pathname, n = e?.search ?? "",
|
|
4989
|
-
if (typeof t != "string" || n !== "" ||
|
|
4990
|
-
const
|
|
4991
|
-
if (!
|
|
4992
|
-
return
|
|
4990
|
+
const t = e?.pathname, n = e?.search ?? "", r = e?.hash ?? "";
|
|
4991
|
+
if (typeof t != "string" || n !== "" || r !== "") throw er();
|
|
4992
|
+
const i = fa.exec(t);
|
|
4993
|
+
if (!i) throw er();
|
|
4994
|
+
return i[1];
|
|
4993
4995
|
}
|
|
4994
4996
|
function ba(e) {
|
|
4995
|
-
const t = e?.window ?? globalThis.window, n = e?.document ?? t?.document ?? globalThis.document,
|
|
4996
|
-
fetch: e?.fetch ??
|
|
4997
|
+
const t = e?.window ?? globalThis.window, n = e?.document ?? t?.document ?? globalThis.document, r = e?.mount ?? n?.body, i = typeof t?.fetch == "function" ? t.fetch.bind(t) : typeof globalThis.fetch == "function" ? globalThis.fetch.bind(globalThis) : null, s = e?.relay ?? (e?.controller ? null : Mo({
|
|
4998
|
+
fetch: e?.fetch ?? i,
|
|
4997
4999
|
location: e?.location ?? t?.location
|
|
4998
5000
|
})), a = e?.registry ?? ha, o = e?.controller ?? new Wo({
|
|
4999
5001
|
...e,
|
|
@@ -5007,14 +5009,14 @@ function ba(e) {
|
|
|
5007
5009
|
(l?.destroy?.() ?? !0) && (l = null), d = null;
|
|
5008
5010
|
}, g = () => {
|
|
5009
5011
|
try {
|
|
5010
|
-
|
|
5012
|
+
r?.replaceChildren?.();
|
|
5011
5013
|
} catch {
|
|
5012
5014
|
}
|
|
5013
5015
|
}, S = () => (b = b >= Number.MAX_SAFE_INTEGER ? 1 : b + 1, b), I = () => {
|
|
5014
5016
|
h = !0, S();
|
|
5015
5017
|
}, U = (v) => !h && b === v, P = (v) => {
|
|
5016
5018
|
if (!U(v)) throw new $("STALE_CONTROLLER");
|
|
5017
|
-
},
|
|
5019
|
+
}, O = (v) => {
|
|
5018
5020
|
try {
|
|
5019
5021
|
v?.remove?.();
|
|
5020
5022
|
} catch {
|
|
@@ -5022,12 +5024,12 @@ function ba(e) {
|
|
|
5022
5024
|
u === v && (u = null);
|
|
5023
5025
|
}, W = () => {
|
|
5024
5026
|
I(), u?.cancel?.(), u = null, m(), g();
|
|
5025
|
-
}, T = (v,
|
|
5026
|
-
v?.addEventListener?.(
|
|
5027
|
+
}, T = (v, H, _) => {
|
|
5028
|
+
v?.addEventListener?.(H, _), A.push([v, H, _]);
|
|
5027
5029
|
}, q = () => {
|
|
5028
|
-
for (const [v,
|
|
5030
|
+
for (const [v, H, _] of A)
|
|
5029
5031
|
try {
|
|
5030
|
-
v?.removeEventListener?.(
|
|
5032
|
+
v?.removeEventListener?.(H, _);
|
|
5031
5033
|
} catch {
|
|
5032
5034
|
}
|
|
5033
5035
|
A = [];
|
|
@@ -5044,16 +5046,16 @@ function ba(e) {
|
|
|
5044
5046
|
const v = b;
|
|
5045
5047
|
return h ? (p = Promise.reject(new $("STALE_CONTROLLER")), p) : (p = (async () => {
|
|
5046
5048
|
try {
|
|
5047
|
-
const
|
|
5049
|
+
const H = Aa(t?.location);
|
|
5048
5050
|
if (typeof o.prepare != "function" || typeof o.executePrepared != "function" || typeof o.unlockPassword != "function") {
|
|
5049
|
-
const B = await o.execute(
|
|
5051
|
+
const B = await o.execute(H);
|
|
5050
5052
|
return P(v), B;
|
|
5051
5053
|
}
|
|
5052
|
-
const _ = await o.prepare(
|
|
5054
|
+
const _ = await o.prepare(H);
|
|
5053
5055
|
if (P(v), _.transaction.operation === "sdn.auth.raw-challenge.v1") {
|
|
5054
5056
|
const B = ma({
|
|
5055
5057
|
document: n,
|
|
5056
|
-
mount:
|
|
5058
|
+
mount: r,
|
|
5057
5059
|
title: `Choose the legacy profile for ${_.binding.clientDisplayName}`
|
|
5058
5060
|
});
|
|
5059
5061
|
u = B;
|
|
@@ -5062,12 +5064,12 @@ function ba(e) {
|
|
|
5062
5064
|
const K = N === "password-fast-v1-legacy" ? c({
|
|
5063
5065
|
controller: null,
|
|
5064
5066
|
document: n,
|
|
5065
|
-
mount:
|
|
5067
|
+
mount: r,
|
|
5066
5068
|
title: `Sign in to ${_.binding.clientDisplayName}`,
|
|
5067
5069
|
transaction: _
|
|
5068
|
-
}) :
|
|
5070
|
+
}) : Kr({
|
|
5069
5071
|
document: n,
|
|
5070
|
-
mount:
|
|
5072
|
+
mount: r,
|
|
5071
5073
|
submitLabel: "Continue",
|
|
5072
5074
|
title: `Sign in to ${_.binding.clientDisplayName}`
|
|
5073
5075
|
});
|
|
@@ -5086,7 +5088,7 @@ function ba(e) {
|
|
|
5086
5088
|
const N = c({
|
|
5087
5089
|
controller: o,
|
|
5088
5090
|
document: n,
|
|
5089
|
-
mount:
|
|
5091
|
+
mount: r,
|
|
5090
5092
|
offerRememberedUnlock: !B,
|
|
5091
5093
|
title: `Sign in to ${_.binding.clientDisplayName}`,
|
|
5092
5094
|
transaction: _
|
|
@@ -5100,8 +5102,8 @@ function ba(e) {
|
|
|
5100
5102
|
break;
|
|
5101
5103
|
} catch {
|
|
5102
5104
|
if (!U(v))
|
|
5103
|
-
throw
|
|
5104
|
-
B = !0,
|
|
5105
|
+
throw O(N), new $("STALE_CONTROLLER");
|
|
5106
|
+
B = !0, O(N);
|
|
5105
5107
|
continue;
|
|
5106
5108
|
}
|
|
5107
5109
|
const Z = await o.unlockPassword(K);
|
|
@@ -5110,32 +5112,32 @@ function ba(e) {
|
|
|
5110
5112
|
}
|
|
5111
5113
|
}
|
|
5112
5114
|
const X = await o.executePrepared(_);
|
|
5113
|
-
return P(v),
|
|
5115
|
+
return P(v), O(u), _.transaction.operation === "sdn.wallet.account.v1" ? (d = o.copyPublicIdentity(), l = ga({
|
|
5114
5116
|
clipboard: e?.clipboard ?? globalThis.navigator?.clipboard,
|
|
5115
5117
|
controller: o,
|
|
5116
5118
|
document: n,
|
|
5117
5119
|
identity: d,
|
|
5118
5120
|
isAppCurrent: () => U(v),
|
|
5119
5121
|
makeCredentialPrompt: c,
|
|
5120
|
-
mount:
|
|
5122
|
+
mount: r,
|
|
5121
5123
|
onClear: m,
|
|
5122
5124
|
wasm: e?.wasm
|
|
5123
|
-
})) : (d = null, n?.createElement &&
|
|
5125
|
+
})) : (d = null, n?.createElement && r?.replaceChildren && Gr(
|
|
5124
5126
|
n,
|
|
5125
5127
|
t,
|
|
5126
5128
|
"The wallet request completed successfully.",
|
|
5127
|
-
|
|
5129
|
+
r
|
|
5128
5130
|
)), X;
|
|
5129
|
-
} catch (
|
|
5131
|
+
} catch (H) {
|
|
5130
5132
|
const _ = !U(v);
|
|
5131
|
-
throw u?.cancel?.(), u = null, m(), q(), _ ||
|
|
5133
|
+
throw u?.cancel?.(), u = null, m(), q(), _ || Jr(n, H?.code === "USER_CANCELLED" ? "Cancelled. You may close this window." : void 0, r), await (f ?? o.destroy(_ ? "stale-startup" : "startup-failure")), _ && H?.code !== "DESTRUCTION_FAILED" ? new $("STALE_CONTROLLER") : H;
|
|
5132
5134
|
}
|
|
5133
5135
|
})(), p);
|
|
5134
5136
|
},
|
|
5135
5137
|
stop(v = "close") {
|
|
5136
5138
|
I(), u?.cancel?.(), u = null, m(), g();
|
|
5137
|
-
const
|
|
5138
|
-
return f || (q(), f =
|
|
5139
|
+
const H = o.destroy(v);
|
|
5140
|
+
return f || (q(), f = H), f;
|
|
5139
5141
|
}
|
|
5140
5142
|
});
|
|
5141
5143
|
}
|