hd-wallet-ui 2.1.3 → 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 +47 -2
- package/dist/browser/sdn-wallet-public-client.js +1 -1
- package/dist/client/asset-review.js +444 -439
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +986 -762
- package/dist/client/sdn.js +152 -147
- package/dist/client/types.d.ts +41 -2
- package/dist/wallet-origin/index.js +2219 -1876
- package/dist/wallet-origin-host/assets/{wallet-origin.83503193e638837518c50e7a3002b11d16574d6ff37e53ee6337486cb3db515d.css → wallet-origin.154fa2fd7f7dc1bf2051e35c1490915763fcaa6f05d88a3d32f1973ef0da5844.css} +1 -1
- package/dist/wallet-origin-host/assets/wallet-origin.c31bc2645e955c72dea686ed92e596c7d7348e80d1cd56d965d833a4bb7374b9.js +13880 -0
- package/dist/wallet-origin-host/assets/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
- package/dist/wallet-origin-host/assets/wallet-origin.03379597b86b0df5afbdfde8e251f33003611be5bf11fd014a624eb7e5312dcc.js +0 -13465
- package/dist/wallet-origin-host/assets/wallet-origin.b3fbc9f99c1c835b83651acb7326a69d9dee7baf4e314e82f0424edc8fb1d561.wasm +0 -0
|
@@ -10,12 +10,12 @@ const Pe = Object.freeze({
|
|
|
10
10
|
scaleComponentInclusiveMax: 1e6,
|
|
11
11
|
translationComponentAbsMax: 1e6,
|
|
12
12
|
upAxes: Object.freeze(["X_UP", "Y_UP", "Z_UP"])
|
|
13
|
-
}), De = Object.freeze({ reviewedTransform: Ne, schemaVersion: 1 }),
|
|
14
|
-
Object.getOwnPropertyDescriptor(
|
|
15
|
-
Object.getOwnPropertyDescriptor(
|
|
13
|
+
}), De = Object.freeze({ reviewedTransform: Ne, schemaVersion: 1 }), _ = new TextEncoder(), me = Object.getPrototypeOf(Uint8Array.prototype);
|
|
14
|
+
Object.getOwnPropertyDescriptor(me, "buffer").get;
|
|
15
|
+
Object.getOwnPropertyDescriptor(me, "length").get;
|
|
16
16
|
Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
|
|
17
17
|
typeof SharedArrayBuffer > "u" || Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get;
|
|
18
|
-
const w = "sdn-bip32-slip10-purpose-v1", J = "password-scrypt-v2", x = "ed25519-over-sha256-jcs-v1", pe = "https://review.spacedatanetwork.org", Re = "sdn-asset-review-v1", ke = "asset-review:assets.ipfs.01", je = "asset-review-authority:assets.ipfs.01", Me = "sdn-login:sdn.spaceaware.io", Ve = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u, b = /^[0-9a-f]{64}$/u, Ye = /^[0-9a-f]{128}$/u, M = /^sha256:[0-9a-f]{64}$/u,
|
|
18
|
+
const w = "sdn-bip32-slip10-purpose-v1", J = "password-scrypt-v2", x = "ed25519-over-sha256-jcs-v1", pe = "https://review.spacedatanetwork.org", Re = "sdn-asset-review-v1", ke = "asset-review:assets.ipfs.01", je = "asset-review-authority:assets.ipfs.01", Me = "sdn-login:sdn.spaceaware.io", Ve = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u, b = /^[0-9a-f]{64}$/u, Ye = /^[0-9a-f]{128}$/u, M = /^sha256:[0-9a-f]{64}$/u, Ue = /^[1-9A-HJ-NP-Za-km-z]+$/u, $e = /^b[a-z2-7]{58}$/u, X = "abcdefghijklmnopqrstuvwxyz234567", Ee = 131072, Fe = [
|
|
19
19
|
"accountFingerprint",
|
|
20
20
|
"accountIndex",
|
|
21
21
|
"accountLabel",
|
|
@@ -101,31 +101,31 @@ function K(i) {
|
|
|
101
101
|
function v(i, e) {
|
|
102
102
|
typeof i != "string" && c(`${e} must be a string`);
|
|
103
103
|
for (let t = 0; t < i.length; t += 1) {
|
|
104
|
-
const
|
|
105
|
-
let
|
|
106
|
-
if (
|
|
104
|
+
const r = i.charCodeAt(t);
|
|
105
|
+
let n = r;
|
|
106
|
+
if (r >= 55296 && r <= 56319) {
|
|
107
107
|
const s = i.charCodeAt(t + 1);
|
|
108
|
-
s >= 56320 && s <= 57343 || c(`${e} contains an unpaired surrogate`),
|
|
109
|
-
} else
|
|
110
|
-
((
|
|
108
|
+
s >= 56320 && s <= 57343 || c(`${e} contains an unpaired surrogate`), n = 65536 + (r - 55296 << 10) + (s - 56320), t += 1;
|
|
109
|
+
} else r >= 56320 && r <= 57343 && c(`${e} contains an unpaired surrogate`);
|
|
110
|
+
((n & 65535) === 65534 || (n & 65535) === 65535 || n >= 64976 && n <= 65007) && c(`${e} contains a Unicode noncharacter`);
|
|
111
111
|
}
|
|
112
112
|
return i;
|
|
113
113
|
}
|
|
114
114
|
function Ae(i) {
|
|
115
|
-
typeof i != "string" && c("wire JSON must be a string"),
|
|
115
|
+
typeof i != "string" && c("wire JSON must be a string"), _.encode(i).byteLength > Ee && c("wire JSON is too large"), i.charCodeAt(0) === 65279 && c("wire JSON must not contain a BOM");
|
|
116
116
|
let e = 0, t = 0;
|
|
117
|
-
const
|
|
117
|
+
const r = () => {
|
|
118
118
|
for (; e < i.length && /[\u0009\u000a\u000d\u0020]/u.test(i[e]); ) e += 1;
|
|
119
|
-
},
|
|
119
|
+
}, n = () => {
|
|
120
120
|
i[e] !== '"' && c("invalid JSON string");
|
|
121
|
-
const
|
|
121
|
+
const a = e;
|
|
122
122
|
for (e += 1; e < i.length; ) {
|
|
123
123
|
const u = i.charCodeAt(e);
|
|
124
124
|
if (u === 34) {
|
|
125
125
|
e += 1;
|
|
126
126
|
let h;
|
|
127
127
|
try {
|
|
128
|
-
h = JSON.parse(i.slice(
|
|
128
|
+
h = JSON.parse(i.slice(a, e));
|
|
129
129
|
} catch {
|
|
130
130
|
c("invalid JSON string");
|
|
131
131
|
}
|
|
@@ -134,47 +134,47 @@ function Ae(i) {
|
|
|
134
134
|
u < 32 && c("invalid JSON control character"), u === 92 && (e += 1, e >= i.length && c("unterminated JSON escape")), e += 1;
|
|
135
135
|
}
|
|
136
136
|
c("unterminated JSON string");
|
|
137
|
-
}, s = (
|
|
138
|
-
|
|
137
|
+
}, s = (a = 0) => {
|
|
138
|
+
a > 32 && c("wire JSON nesting is too deep"), t += 1, t > 4096 && c("wire JSON contains too many values"), r();
|
|
139
139
|
const u = i[e];
|
|
140
|
-
if (u === '"') return
|
|
140
|
+
if (u === '"') return n();
|
|
141
141
|
if (u === "{") {
|
|
142
142
|
e += 1;
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
145
|
-
return e += 1,
|
|
143
|
+
const d = /* @__PURE__ */ Object.create(null), m = /* @__PURE__ */ new Set();
|
|
144
|
+
if (r(), i[e] === "}")
|
|
145
|
+
return e += 1, d;
|
|
146
146
|
for (; e < i.length; ) {
|
|
147
|
-
|
|
148
|
-
const R =
|
|
149
|
-
if (
|
|
150
|
-
return e += 1,
|
|
147
|
+
r();
|
|
148
|
+
const R = n();
|
|
149
|
+
if (m.has(R) && c(`duplicate JSON field: ${R}`), m.add(R), r(), i[e] !== ":" && c("missing JSON object colon"), e += 1, d[R] = s(a + 1), r(), i[e] === "}")
|
|
150
|
+
return e += 1, d;
|
|
151
151
|
i[e] !== "," && c("invalid JSON object separator"), e += 1;
|
|
152
152
|
}
|
|
153
153
|
c("unterminated JSON object");
|
|
154
154
|
}
|
|
155
155
|
if (u === "[") {
|
|
156
156
|
e += 1;
|
|
157
|
-
const
|
|
158
|
-
if (
|
|
159
|
-
return e += 1,
|
|
157
|
+
const d = [];
|
|
158
|
+
if (r(), i[e] === "]")
|
|
159
|
+
return e += 1, d;
|
|
160
160
|
for (; e < i.length; ) {
|
|
161
|
-
if (
|
|
162
|
-
return e += 1,
|
|
161
|
+
if (d.push(s(a + 1)), r(), i[e] === "]")
|
|
162
|
+
return e += 1, d;
|
|
163
163
|
i[e] !== "," && c("invalid JSON array separator"), e += 1;
|
|
164
164
|
}
|
|
165
165
|
c("unterminated JSON array");
|
|
166
166
|
}
|
|
167
|
-
for (const [
|
|
168
|
-
if (i.startsWith(
|
|
169
|
-
return e +=
|
|
167
|
+
for (const [d, m] of [["true", !0], ["false", !1], ["null", null]])
|
|
168
|
+
if (i.startsWith(d, e))
|
|
169
|
+
return e += d.length, m;
|
|
170
170
|
const h = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/u.exec(i.slice(e));
|
|
171
171
|
h || c("invalid JSON value"), e += h[0].length;
|
|
172
|
-
const
|
|
173
|
-
return Number.isFinite(
|
|
172
|
+
const y = Number(h[0]);
|
|
173
|
+
return Number.isFinite(y) || c("wire JSON number must be finite"), y;
|
|
174
174
|
};
|
|
175
|
-
|
|
175
|
+
r();
|
|
176
176
|
const o = s();
|
|
177
|
-
return
|
|
177
|
+
return r(), e !== i.length && c("wire JSON contains trailing bytes"), o;
|
|
178
178
|
}
|
|
179
179
|
function be(i) {
|
|
180
180
|
return typeof i == "string" ? Ae(i) : i;
|
|
@@ -182,19 +182,19 @@ function be(i) {
|
|
|
182
182
|
function Ke(i, e) {
|
|
183
183
|
if (i.byteLength !== e.byteLength) return !1;
|
|
184
184
|
let t = 0;
|
|
185
|
-
for (let
|
|
185
|
+
for (let r = 0; r < i.byteLength; r += 1) t |= i[r] ^ e[r];
|
|
186
186
|
return t === 0;
|
|
187
187
|
}
|
|
188
188
|
function E(i, e, t) {
|
|
189
|
-
const
|
|
190
|
-
K(
|
|
191
|
-
const
|
|
192
|
-
Ke(o,
|
|
193
|
-
for (const u of
|
|
194
|
-
const h = Object.getOwnPropertyDescriptor(
|
|
189
|
+
const r = be(i);
|
|
190
|
+
K(r) || c(`${t} must be a JSON object`), Object.getOwnPropertySymbols(r).length !== 0 && c(`${t} has an unknown symbol field`);
|
|
191
|
+
const n = Object.getOwnPropertyNames(r).sort(), s = [...e].sort(), o = _.encode(n.join("\0")), a = _.encode(s.join("\0"));
|
|
192
|
+
Ke(o, a) || c(`${t} has missing or unknown fields`);
|
|
193
|
+
for (const u of n) {
|
|
194
|
+
const h = Object.getOwnPropertyDescriptor(r, u);
|
|
195
195
|
(!h || !h.enumerable || !("value" in h)) && c(`${t}.${u} must be an enumerable data field`), h.value === void 0 && c(`${t}.${u} must not be undefined`);
|
|
196
196
|
}
|
|
197
|
-
return
|
|
197
|
+
return r;
|
|
198
198
|
}
|
|
199
199
|
function V(i) {
|
|
200
200
|
if (!i || typeof i != "object" || Object.isFrozen(i)) return i;
|
|
@@ -206,8 +206,8 @@ function S(i) {
|
|
|
206
206
|
}
|
|
207
207
|
function G(i, e, t) {
|
|
208
208
|
(!Array.isArray(i) || Object.getPrototypeOf(i) !== Array.prototype || i.length !== e) && c(`${t} must be a plain array with exactly ${e} values`);
|
|
209
|
-
const
|
|
210
|
-
(
|
|
209
|
+
const r = [...Array.from({ length: e }, (s, o) => String(o)), "length"], n = Reflect.ownKeys(i);
|
|
210
|
+
(n.length !== r.length || n.some((s, o) => s !== r[o])) && c(`${t} must be a dense plain array`);
|
|
211
211
|
for (let s = 0; s < e; s += 1) {
|
|
212
212
|
const o = Object.getOwnPropertyDescriptor(i, String(s));
|
|
213
213
|
(!o || !o.enumerable || !("value" in o) || o.value === void 0) && c(`${t} must contain enumerable data values`);
|
|
@@ -227,27 +227,27 @@ function ze(i) {
|
|
|
227
227
|
"scaleComponentInclusiveMax",
|
|
228
228
|
"translationComponentAbsMax",
|
|
229
229
|
"upAxes"
|
|
230
|
-
], "asset review transform policy"),
|
|
230
|
+
], "asset review transform policy"), r = E(
|
|
231
231
|
t.metersPerSourceUnit,
|
|
232
232
|
["cm", "km", "m", "mm"],
|
|
233
233
|
"asset review unit policy"
|
|
234
234
|
);
|
|
235
|
-
for (const [
|
|
236
|
-
(typeof s != "number" || !Number.isFinite(s) || s <= 0) && c(`asset review unit policy ${
|
|
237
|
-
for (const [
|
|
235
|
+
for (const [n, s] of Object.entries(r))
|
|
236
|
+
(typeof s != "number" || !Number.isFinite(s) || s <= 0) && c(`asset review unit policy ${n} must be positive and finite`);
|
|
237
|
+
for (const [n, s] of [
|
|
238
238
|
["quaternionNormTolerance", t.quaternionNormTolerance],
|
|
239
239
|
["scaleComponentExclusiveMin", t.scaleComponentExclusiveMin],
|
|
240
240
|
["scaleComponentInclusiveMax", t.scaleComponentInclusiveMax],
|
|
241
241
|
["translationComponentAbsMax", t.translationComponentAbsMax]
|
|
242
242
|
])
|
|
243
|
-
(typeof s != "number" || !Number.isFinite(s)) && c(`asset review transform policy ${
|
|
243
|
+
(typeof s != "number" || !Number.isFinite(s)) && c(`asset review transform policy ${n} must be finite`);
|
|
244
244
|
return (t.quaternionNormTolerance <= 0 || t.scaleComponentInclusiveMax <= t.scaleComponentExclusiveMin || t.translationComponentAbsMax <= 0) && c("asset review transform policy bounds are inconsistent"), G(t.upAxes, 3, "asset review up-axis policy"), t.upAxes.join("\0") !== "X_UP\0Y_UP\0Z_UP" && c("asset review up-axis policy is invalid"), S([
|
|
245
|
-
["metersPerSourceUnit", S(Object.entries(
|
|
245
|
+
["metersPerSourceUnit", S(Object.entries(r))],
|
|
246
246
|
["quaternionNormTolerance", t.quaternionNormTolerance],
|
|
247
247
|
["scaleComponentExclusiveMin", t.scaleComponentExclusiveMin],
|
|
248
248
|
["scaleComponentInclusiveMax", t.scaleComponentInclusiveMax],
|
|
249
249
|
["translationComponentAbsMax", t.translationComponentAbsMax],
|
|
250
|
-
["upAxes", Object.freeze(Array.from({ length: 3 }, (
|
|
250
|
+
["upAxes", Object.freeze(Array.from({ length: 3 }, (n, s) => t.upAxes[s]))]
|
|
251
251
|
]);
|
|
252
252
|
}
|
|
253
253
|
const L = ze(De);
|
|
@@ -264,31 +264,31 @@ function T(i, e) {
|
|
|
264
264
|
return v(i, e), (!Ve.test(i) || new Date(i).toISOString() !== i) && c(`${e} must be exact RFC3339 milliseconds UTC`), i;
|
|
265
265
|
}
|
|
266
266
|
function ee(i, e) {
|
|
267
|
-
const t = Date.parse(i),
|
|
268
|
-
|
|
267
|
+
const t = Date.parse(i), r = Date.parse(e);
|
|
268
|
+
r > t && r - t <= 3e5 || c("request lifetime must be in (0, 300] seconds");
|
|
269
269
|
}
|
|
270
270
|
function He(i) {
|
|
271
|
-
let e = 0, t = 0,
|
|
272
|
-
for (const
|
|
273
|
-
for (e = e << 8 |
|
|
274
|
-
t -= 5,
|
|
275
|
-
return t !== 0 && (
|
|
271
|
+
let e = 0, t = 0, r = "";
|
|
272
|
+
for (const n of i)
|
|
273
|
+
for (e = e << 8 | n, t += 8; t >= 5; )
|
|
274
|
+
t -= 5, r += X[e >>> t & 31], e &= (1 << t) - 1;
|
|
275
|
+
return t !== 0 && (r += X[e << 5 - t & 31]), r;
|
|
276
276
|
}
|
|
277
277
|
function Xe(i, e) {
|
|
278
|
-
v(i, "modelCid"),
|
|
279
|
-
let t = 0,
|
|
280
|
-
const
|
|
281
|
-
for (const
|
|
282
|
-
const u = X.indexOf(
|
|
283
|
-
u < 0 && c("modelCid contains invalid base32"), t = t << 5 | u,
|
|
278
|
+
v(i, "modelCid"), $e.test(i) || c("modelCid must be canonical CIDv1 raw sha2-256 base32");
|
|
279
|
+
let t = 0, r = 0;
|
|
280
|
+
const n = [];
|
|
281
|
+
for (const a of i.slice(1)) {
|
|
282
|
+
const u = X.indexOf(a);
|
|
283
|
+
u < 0 && c("modelCid contains invalid base32"), t = t << 5 | u, r += 5, r >= 8 && (r -= 8, n.push(t >>> r & 255), t &= (1 << r) - 1);
|
|
284
284
|
}
|
|
285
|
-
(
|
|
286
|
-
const s = Uint8Array.from(
|
|
285
|
+
(r !== 0 && t !== 0 || n.length !== 36) && c("modelCid has noncanonical base32 tail bits or length");
|
|
286
|
+
const s = Uint8Array.from(n);
|
|
287
287
|
(s[0] !== 1 || s[1] !== 85 || s[2] !== 18 || s[3] !== 32) && c("modelCid must encode CIDv1 raw sha2-256 with a 32-byte digest"), `b${He(s)}` !== i && c("modelCid base32 is not canonical");
|
|
288
288
|
let o = 0;
|
|
289
|
-
for (let
|
|
290
|
-
const u = Number.parseInt(e.slice(
|
|
291
|
-
o |= s[
|
|
289
|
+
for (let a = 0; a < 32; a += 1) {
|
|
290
|
+
const u = Number.parseInt(e.slice(a * 2, a * 2 + 2), 16);
|
|
291
|
+
o |= s[a + 4] ^ u;
|
|
292
292
|
}
|
|
293
293
|
return o !== 0 && c("modelCid digest does not match modelSha256"), i;
|
|
294
294
|
}
|
|
@@ -300,7 +300,7 @@ function te(i, e) {
|
|
|
300
300
|
i[t] !== e[t] && c(`canonicalEnvelope ${t} must match the signature result`);
|
|
301
301
|
}
|
|
302
302
|
function Qe(i, e) {
|
|
303
|
-
const
|
|
303
|
+
const r = E(i, [
|
|
304
304
|
"audience",
|
|
305
305
|
"challengeSha256",
|
|
306
306
|
"clientId",
|
|
@@ -314,7 +314,7 @@ function Qe(i, e) {
|
|
|
314
314
|
"requestOrigin",
|
|
315
315
|
"signatureProfile"
|
|
316
316
|
], "SDN login canonicalEnvelope");
|
|
317
|
-
te(
|
|
317
|
+
te(r, e), f(r.audience, Me, "SDN login envelope audience"), p(r.challengeSha256, b, "SDN login envelope challengeSha256"), f(r.clientId, "sdn-node-console-v1", "SDN login envelope clientId"), T(r.issuedAt, "SDN login envelope issuedAt"), T(r.expiresAt, "SDN login envelope expiresAt"), ee(r.issuedAt, r.expiresAt), f(r.identityScheme, w, "SDN login envelope identityScheme"), p(r.keyId, M, "SDN login envelope keyId"), f(r.kind, "sdn-login", "SDN login envelope kind"), p(r.nonce, b, "SDN login envelope nonce"), f(r.protocolVersion, 2, "SDN login envelope protocolVersion"), f(r.requestOrigin, "https://sdn.spaceaware.io", "SDN login envelope requestOrigin"), f(r.signatureProfile, x, "SDN login envelope signatureProfile");
|
|
318
318
|
}
|
|
319
319
|
function Ze(i, e) {
|
|
320
320
|
const t = E(
|
|
@@ -322,23 +322,23 @@ function Ze(i, e) {
|
|
|
322
322
|
[...W, "kind"],
|
|
323
323
|
"authority activation canonicalEnvelope"
|
|
324
324
|
);
|
|
325
|
-
te(t, e), f(t.kind, "asset-review-authority-activation", "activation envelope kind"), Se(Object.fromEntries(W.map((
|
|
325
|
+
te(t, e), f(t.kind, "asset-review-authority-activation", "activation envelope kind"), Se(Object.fromEntries(W.map((r) => [r, t[r]])));
|
|
326
326
|
}
|
|
327
327
|
function Ge(i, e) {
|
|
328
|
-
const t = i?.decision === "approve" ? ["note", "reviewedTransform"] : i?.decision === "disapprove" ? ["reason"] : [],
|
|
329
|
-
...
|
|
328
|
+
const t = i?.decision === "approve" ? ["note", "reviewedTransform"] : i?.decision === "disapprove" ? ["reason"] : [], r = [...Q, ...t], n = E(i, [
|
|
329
|
+
...r,
|
|
330
330
|
"identityScheme",
|
|
331
331
|
"keyId",
|
|
332
332
|
"kind",
|
|
333
333
|
"purpose",
|
|
334
334
|
"signatureProfile"
|
|
335
335
|
], "asset review decision canonicalEnvelope");
|
|
336
|
-
te(
|
|
336
|
+
te(n, e), f(n.identityScheme, w, "decision envelope identityScheme"), p(n.keyId, M, "decision envelope keyId"), f(n.kind, "asset-review-attestation", "decision envelope kind"), f(n.purpose, "asset-review-approval", "decision envelope purpose"), f(n.signatureProfile, x, "decision envelope signatureProfile"), Ie(Object.fromEntries(r.map((s) => [s, n[s]])));
|
|
337
337
|
}
|
|
338
338
|
function et(i, e, t) {
|
|
339
|
-
v(i, "canonicalEnvelope"),
|
|
340
|
-
const
|
|
341
|
-
return (!K(
|
|
339
|
+
v(i, "canonicalEnvelope"), _.encode(i).byteLength > Ee && c("canonicalEnvelope is too large");
|
|
340
|
+
const r = Ae(i);
|
|
341
|
+
return (!K(r) || r.kind !== e) && c("canonicalEnvelope kind does not match the operation"), Z(r) !== i && c("canonicalEnvelope must be exact JCS"), e === "sdn-login" ? Qe(r, t) : e === "asset-review-authority-activation" ? Ze(r, t) : e === "asset-review-attestation" ? Ge(r, t) : c("canonicalEnvelope operation is not registered"), i;
|
|
342
342
|
}
|
|
343
343
|
function tt(i, e) {
|
|
344
344
|
const t = E(i, qe, `identity key ${e.purpose}`);
|
|
@@ -358,7 +358,7 @@ function tt(i, e) {
|
|
|
358
358
|
}
|
|
359
359
|
function it(i) {
|
|
360
360
|
const e = E(i, Fe, "WalletPublicIdentity");
|
|
361
|
-
f(e.schemaVersion, 1, "identity schemaVersion"), f(e.identityScheme, w, "identity identityScheme"), f(e.seedProfile, J, "identity seedProfile"), e.accountIndex !== 0 && c("public wallet identity must use account 0"), f(e.accountLabel, null, "identity accountLabel"), v(e.accountXpub, "identity accountXpub"), /^xpub[1-9A-HJ-NP-Za-km-z]{107}$/u.test(e.accountXpub) || c("identity accountXpub is invalid"), v(e.accountPeerId, "identity accountPeerId"), (!e.accountPeerId.startsWith("16Uiu2H") || e.accountPeerId.length < 40 || e.accountPeerId.length > 64 ||
|
|
361
|
+
f(e.schemaVersion, 1, "identity schemaVersion"), f(e.identityScheme, w, "identity identityScheme"), f(e.seedProfile, J, "identity seedProfile"), e.accountIndex !== 0 && c("public wallet identity must use account 0"), f(e.accountLabel, null, "identity accountLabel"), v(e.accountXpub, "identity accountXpub"), /^xpub[1-9A-HJ-NP-Za-km-z]{107}$/u.test(e.accountXpub) || c("identity accountXpub is invalid"), v(e.accountPeerId, "identity accountPeerId"), (!e.accountPeerId.startsWith("16Uiu2H") || e.accountPeerId.length < 40 || e.accountPeerId.length > 64 || !Ue.test(e.accountPeerId)) && c("identity accountPeerId is invalid"), p(e.accountFingerprint, /^[0-9a-f]{8}$/u, "identity accountFingerprint"), G(e.keys, 3, "public identity keys array");
|
|
362
362
|
const t = [
|
|
363
363
|
{
|
|
364
364
|
purpose: "asset-review-approval",
|
|
@@ -378,9 +378,9 @@ function it(i) {
|
|
|
378
378
|
signatureProfile: x,
|
|
379
379
|
path: "m/44'/0'/0'/0'/0'"
|
|
380
380
|
}
|
|
381
|
-
],
|
|
381
|
+
], r = Array.from(
|
|
382
382
|
{ length: 3 },
|
|
383
|
-
(
|
|
383
|
+
(n, s) => tt(e.keys[s], t[s])
|
|
384
384
|
);
|
|
385
385
|
return S([
|
|
386
386
|
["accountFingerprint", e.accountFingerprint],
|
|
@@ -389,7 +389,7 @@ function it(i) {
|
|
|
389
389
|
["accountPeerId", e.accountPeerId],
|
|
390
390
|
["accountXpub", e.accountXpub],
|
|
391
391
|
["identityScheme", w],
|
|
392
|
-
["keys", V(
|
|
392
|
+
["keys", V(r)],
|
|
393
393
|
["schemaVersion", 1],
|
|
394
394
|
["seedProfile", J]
|
|
395
395
|
]);
|
|
@@ -397,11 +397,11 @@ function it(i) {
|
|
|
397
397
|
function Oe(i, e) {
|
|
398
398
|
const t = E(i, Be, `${e} result`);
|
|
399
399
|
f(t.schemaVersion, 1, "connection result schemaVersion"), ve(t.event, ["connected", "disconnected"], "connection event"), e === "connect" && t.event !== "connected" && c("connect result must be connected");
|
|
400
|
-
let
|
|
401
|
-
return t.event === "connected" ? (
|
|
402
|
-
["connectionExpiresAt",
|
|
400
|
+
let r = null, n = null;
|
|
401
|
+
return t.event === "connected" ? (r = it(t.identity), n = T(t.connectionExpiresAt, "connectionExpiresAt")) : (t.identity !== null || t.connectionExpiresAt !== null) && c("disconnected result must clear identity and expiry"), S([
|
|
402
|
+
["connectionExpiresAt", n],
|
|
403
403
|
["event", t.event],
|
|
404
|
-
["identity",
|
|
404
|
+
["identity", r],
|
|
405
405
|
["schemaVersion", 1]
|
|
406
406
|
]);
|
|
407
407
|
}
|
|
@@ -425,20 +425,20 @@ function Se(i) {
|
|
|
425
425
|
}
|
|
426
426
|
function z(i, e, t) {
|
|
427
427
|
G(i, e, `${t} array`);
|
|
428
|
-
const
|
|
428
|
+
const r = Array.from({ length: e }, (n, s) => {
|
|
429
429
|
const o = i[s];
|
|
430
430
|
return (typeof o != "number" || !Number.isFinite(o)) && c(`${t} values must be finite numbers`), o;
|
|
431
431
|
});
|
|
432
|
-
return V(
|
|
432
|
+
return V(r);
|
|
433
433
|
}
|
|
434
|
-
function
|
|
435
|
-
const e = E(i, We, "reviewedTransform"), t = z(e.translation, 3, "translation"),
|
|
436
|
-
t.some((o) => Math.abs(o) > L.translationComponentAbsMax) && c("translation values exceed the reviewed transform policy"),
|
|
437
|
-
const s = Math.hypot(...
|
|
434
|
+
function rt(i) {
|
|
435
|
+
const e = E(i, We, "reviewedTransform"), t = z(e.translation, 3, "translation"), r = z(e.rotation, 4, "rotation"), n = z(e.scale, 3, "scale");
|
|
436
|
+
t.some((o) => Math.abs(o) > L.translationComponentAbsMax) && c("translation values exceed the reviewed transform policy"), n.some((o) => o <= L.scaleComponentExclusiveMin || o > L.scaleComponentInclusiveMax) && c("scale values exceed the reviewed transform policy");
|
|
437
|
+
const s = Math.hypot(...r);
|
|
438
438
|
return Math.abs(s - 1) > L.quaternionNormTolerance && c("rotation must be a unit quaternion within the reviewed tolerance"), ve(e.upAxis, L.upAxes, "upAxis"), v(e.sourceUnits, "sourceUnits"), Object.hasOwn(L.metersPerSourceUnit, e.sourceUnits) || c("sourceUnits is not allowed by the reviewed transform policy"), (typeof e.metersPerSourceUnit != "number" || !Number.isFinite(e.metersPerSourceUnit) || e.metersPerSourceUnit !== L.metersPerSourceUnit[e.sourceUnits]) && c("metersPerSourceUnit must exactly match sourceUnits"), S([
|
|
439
439
|
["metersPerSourceUnit", e.metersPerSourceUnit],
|
|
440
|
-
["rotation",
|
|
441
|
-
["scale",
|
|
440
|
+
["rotation", r],
|
|
441
|
+
["scale", n],
|
|
442
442
|
["sourceUnits", e.sourceUnits],
|
|
443
443
|
["translation", t],
|
|
444
444
|
["upAxis", e.upAxis]
|
|
@@ -449,35 +449,35 @@ function se(i) {
|
|
|
449
449
|
}
|
|
450
450
|
function oe(i, e, t) {
|
|
451
451
|
if (t && i === null) return null;
|
|
452
|
-
v(i, e), (i.length === 0 ||
|
|
453
|
-
const
|
|
454
|
-
return (se(
|
|
452
|
+
v(i, e), (i.length === 0 || _.encode(i).byteLength > 2e3) && c(`${e} has an invalid length`);
|
|
453
|
+
const r = Array.from(i, (n) => n.codePointAt(0));
|
|
454
|
+
return (se(r[0]) || se(r[r.length - 1])) && c(`${e} must already be trimmed`), i;
|
|
455
455
|
}
|
|
456
456
|
function Ie(i) {
|
|
457
457
|
const e = be(i);
|
|
458
458
|
K(e) || c("asset review decision request must be a JSON object");
|
|
459
459
|
const t = Object.getOwnPropertyDescriptor(e, "decision");
|
|
460
460
|
(!t || !t.enumerable || !("value" in t) || t.value === void 0) && c("asset review decision request has an invalid decision field");
|
|
461
|
-
const
|
|
461
|
+
const r = t.value, n = r === "approve" ? ["note", "reviewedTransform"] : r === "disapprove" ? ["reason"] : [], s = E(e, [...Q, ...n], "asset review decision request");
|
|
462
462
|
f(s.protocolVersion, 1, "decision protocolVersion"), f(s.audience, ke, "decision audience"), f(s.requestOrigin, pe, "decision requestOrigin"), f(s.clientId, Re, "decision clientId"), p(s.challengeId, b, "challengeId"), p(s.nonce, b, "decision nonce"), T(s.issuedAt, "decision issuedAt"), T(s.expiresAt, "decision expiresAt"), ee(s.issuedAt, s.expiresAt), p(s.modelSha256, b, "modelSha256"), p(s.metadataSha256, b, "metadataSha256"), s.previousDecisionHead !== null && p(s.previousDecisionHead, b, "previousDecisionHead"), Xe(s.modelCid, s.modelSha256), (!Number.isSafeInteger(s.modelBytes) || s.modelBytes <= 0) && c("modelBytes must be a positive safe integer"), v(s.candidateKey, "candidateKey");
|
|
463
|
-
const o = "asset-review:",
|
|
464
|
-
(!s.candidateKey.startsWith(o) || !s.candidateKey.endsWith(
|
|
465
|
-
const u = s.candidateKey.slice(o.length, -
|
|
466
|
-
(!/^[a-z0-9-]+\/[a-z0-9][a-z0-9-]*$/u.test(u) ||
|
|
467
|
-
const h = Q.map((
|
|
468
|
-
return
|
|
469
|
-
}
|
|
470
|
-
function
|
|
463
|
+
const o = "asset-review:", a = `:${s.modelSha256}`;
|
|
464
|
+
(!s.candidateKey.startsWith(o) || !s.candidateKey.endsWith(a) || _.encode(s.candidateKey).byteLength > 206) && c("candidateKey does not bind the model digest");
|
|
465
|
+
const u = s.candidateKey.slice(o.length, -a.length);
|
|
466
|
+
(!/^[a-z0-9-]+\/[a-z0-9][a-z0-9-]*$/u.test(u) || _.encode(u).byteLength > 128) && c("candidateKey entityId is invalid");
|
|
467
|
+
const h = Q.map((d) => [d, s[d]]);
|
|
468
|
+
return r === "approve" ? (h.push(["note", oe(s.note, "note", !0)]), h.push(["reviewedTransform", rt(s.reviewedTransform)])) : h.push(["reason", oe(s.reason, "reason", !1)]), Object.values(s).filter((d) => typeof d == "string").reduce((d, m) => d + _.encode(m).byteLength, 0) > 16384 && c("decision request strings exceed 16 KiB"), S(h);
|
|
469
|
+
}
|
|
470
|
+
function _e(i, e) {
|
|
471
471
|
return E(i, [], e), V({});
|
|
472
472
|
}
|
|
473
|
-
function
|
|
474
|
-
return
|
|
473
|
+
function nt(i = {}) {
|
|
474
|
+
return _e(i, "wallet connect request");
|
|
475
475
|
}
|
|
476
476
|
function st(i) {
|
|
477
477
|
return Oe(i, "connect");
|
|
478
478
|
}
|
|
479
479
|
function ot(i = {}) {
|
|
480
|
-
return
|
|
480
|
+
return _e(i, "wallet account request");
|
|
481
481
|
}
|
|
482
482
|
function ct(i) {
|
|
483
483
|
return Oe(i, "account");
|
|
@@ -494,7 +494,7 @@ function ut(i) {
|
|
|
494
494
|
function ht(i) {
|
|
495
495
|
return we(i, "asset-review-attestation");
|
|
496
496
|
}
|
|
497
|
-
const P = "https://wallet.spacedatanetwork.org", Y = "sdn.wallet.callback.v1:", D = /^[0-9a-f]{64}$/u, ce = /^[A-Za-z0-9_-]{43}$/u, ft = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u, dt = 250,
|
|
497
|
+
const P = "https://wallet.spacedatanetwork.org", Y = "sdn.wallet.callback.v1:", D = /^[0-9a-f]{64}$/u, ce = /^[A-Za-z0-9_-]{43}$/u, ft = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u, dt = 250, yt = 3e4, mt = 3e5, pt = 9e5, Rt = 12e4, Et = 8, ae = 4096, le = 70 * 1024, At = 64, ge = Object.freeze({
|
|
498
498
|
CALLBACK_ERROR: "The wallet return could not be verified. Try again.",
|
|
499
499
|
CRYPTO_UNAVAILABLE: "Secure browser cryptography is unavailable.",
|
|
500
500
|
DESTROYED: "This wallet client has been destroyed.",
|
|
@@ -502,13 +502,14 @@ const P = "https://wallet.spacedatanetwork.org", Y = "sdn.wallet.callback.v1:",
|
|
|
502
502
|
EXPIRED: "The wallet connection expired.",
|
|
503
503
|
INVALID_CLIENT: "This wallet client is not registered.",
|
|
504
504
|
INVALID_REQUEST: "The wallet request is invalid.",
|
|
505
|
+
NOT_ADDRESSED_TO_ACCOUNT: "This data is not sealed to your wallet.",
|
|
505
506
|
RELAY_ERROR: "The wallet service could not complete the request. Try again.",
|
|
506
507
|
REPLACED: "A newer wallet request replaced this one.",
|
|
507
508
|
WALLET_NOT_COMPLETED: "The wallet did not complete. Check popup settings and try again."
|
|
508
509
|
}), Le = new TextEncoder(), bt = new TextDecoder("utf-8", { fatal: !0 });
|
|
509
510
|
class j extends Error {
|
|
510
511
|
constructor(e) {
|
|
511
|
-
super(
|
|
512
|
+
super(ge[e]), this.name = "WalletClientError", Object.defineProperty(this, "code", {
|
|
512
513
|
configurable: !1,
|
|
513
514
|
enumerable: !0,
|
|
514
515
|
value: e,
|
|
@@ -516,141 +517,141 @@ class j extends Error {
|
|
|
516
517
|
});
|
|
517
518
|
}
|
|
518
519
|
}
|
|
519
|
-
function
|
|
520
|
-
return Object.hasOwn(
|
|
520
|
+
function l(i) {
|
|
521
|
+
return Object.hasOwn(ge, i) ? new j(i) : new j("RELAY_ERROR");
|
|
521
522
|
}
|
|
522
523
|
function vt(i) {
|
|
523
524
|
if (i === null || typeof i != "object" || Array.isArray(i)) return !1;
|
|
524
525
|
const e = Object.getPrototypeOf(i);
|
|
525
526
|
return e === Object.prototype || e === null;
|
|
526
527
|
}
|
|
527
|
-
function
|
|
528
|
+
function $(i, e) {
|
|
528
529
|
if (typeof i != "string" || i.length > e || Le.encode(i).byteLength > e || i.charCodeAt(0) === 65279)
|
|
529
|
-
throw
|
|
530
|
-
let t = 0,
|
|
531
|
-
const
|
|
530
|
+
throw l("RELAY_ERROR");
|
|
531
|
+
let t = 0, r = 0;
|
|
532
|
+
const n = () => {
|
|
532
533
|
for (; t < i.length && /[\u0009\u000a\u000d\u0020]/u.test(i[t]); ) t += 1;
|
|
533
534
|
}, s = () => {
|
|
534
|
-
if (i[t] !== '"') throw
|
|
535
|
+
if (i[t] !== '"') throw l("RELAY_ERROR");
|
|
535
536
|
const u = t;
|
|
536
537
|
for (t += 1; t < i.length; ) {
|
|
537
538
|
const h = i.charCodeAt(t);
|
|
538
539
|
if (h === 34) {
|
|
539
540
|
t += 1;
|
|
540
|
-
let
|
|
541
|
+
let y;
|
|
541
542
|
try {
|
|
542
|
-
|
|
543
|
+
y = JSON.parse(i.slice(u, t));
|
|
543
544
|
} catch {
|
|
544
|
-
throw
|
|
545
|
+
throw l("RELAY_ERROR");
|
|
545
546
|
}
|
|
546
|
-
for (let
|
|
547
|
-
const
|
|
548
|
-
if (
|
|
549
|
-
const R =
|
|
550
|
-
if (!(R >= 56320 && R <= 57343)) throw
|
|
551
|
-
|
|
552
|
-
} else if (
|
|
553
|
-
throw
|
|
547
|
+
for (let d = 0; d < y.length; d += 1) {
|
|
548
|
+
const m = y.charCodeAt(d);
|
|
549
|
+
if (m >= 55296 && m <= 56319) {
|
|
550
|
+
const R = y.charCodeAt(d + 1);
|
|
551
|
+
if (!(R >= 56320 && R <= 57343)) throw l("RELAY_ERROR");
|
|
552
|
+
d += 1;
|
|
553
|
+
} else if (m >= 56320 && m <= 57343)
|
|
554
|
+
throw l("RELAY_ERROR");
|
|
554
555
|
}
|
|
555
|
-
return
|
|
556
|
+
return y;
|
|
556
557
|
}
|
|
557
558
|
if (h < 32 || h === 92 && (t += 1, t >= i.length))
|
|
558
|
-
throw
|
|
559
|
+
throw l("RELAY_ERROR");
|
|
559
560
|
t += 1;
|
|
560
561
|
}
|
|
561
|
-
throw
|
|
562
|
+
throw l("RELAY_ERROR");
|
|
562
563
|
}, o = (u = 0) => {
|
|
563
|
-
if (u > 32 || ++
|
|
564
|
-
|
|
564
|
+
if (u > 32 || ++r > 4096) throw l("RELAY_ERROR");
|
|
565
|
+
n();
|
|
565
566
|
const h = i[t];
|
|
566
567
|
if (h === '"') return s();
|
|
567
568
|
if (h === "{") {
|
|
568
569
|
t += 1;
|
|
569
|
-
const
|
|
570
|
-
if (
|
|
571
|
-
return t += 1,
|
|
570
|
+
const m = /* @__PURE__ */ Object.create(null), R = /* @__PURE__ */ new Set();
|
|
571
|
+
if (n(), i[t] === "}")
|
|
572
|
+
return t += 1, m;
|
|
572
573
|
for (; t < i.length; ) {
|
|
573
|
-
|
|
574
|
+
n();
|
|
574
575
|
const I = s();
|
|
575
|
-
if (R.has(I) || (R.add(I),
|
|
576
|
-
if (t += 1,
|
|
577
|
-
return t += 1,
|
|
578
|
-
if (i[t] !== ",") throw
|
|
576
|
+
if (R.has(I) || (R.add(I), n(), i[t] !== ":")) throw l("RELAY_ERROR");
|
|
577
|
+
if (t += 1, m[I] = o(u + 1), n(), i[t] === "}")
|
|
578
|
+
return t += 1, m;
|
|
579
|
+
if (i[t] !== ",") throw l("RELAY_ERROR");
|
|
579
580
|
t += 1;
|
|
580
581
|
}
|
|
581
|
-
throw
|
|
582
|
+
throw l("RELAY_ERROR");
|
|
582
583
|
}
|
|
583
584
|
if (h === "[") {
|
|
584
585
|
t += 1;
|
|
585
|
-
const
|
|
586
|
-
if (
|
|
587
|
-
return t += 1,
|
|
586
|
+
const m = [];
|
|
587
|
+
if (n(), i[t] === "]")
|
|
588
|
+
return t += 1, m;
|
|
588
589
|
for (; t < i.length; ) {
|
|
589
|
-
if (
|
|
590
|
-
return t += 1,
|
|
591
|
-
if (i[t] !== ",") throw
|
|
590
|
+
if (m.push(o(u + 1)), n(), i[t] === "]")
|
|
591
|
+
return t += 1, m;
|
|
592
|
+
if (i[t] !== ",") throw l("RELAY_ERROR");
|
|
592
593
|
t += 1;
|
|
593
594
|
}
|
|
594
|
-
throw
|
|
595
|
+
throw l("RELAY_ERROR");
|
|
595
596
|
}
|
|
596
|
-
for (const [
|
|
597
|
-
if (i.startsWith(
|
|
598
|
-
return t +=
|
|
599
|
-
const
|
|
600
|
-
if (!
|
|
601
|
-
t +=
|
|
602
|
-
const
|
|
603
|
-
if (!Number.isFinite(
|
|
604
|
-
return
|
|
597
|
+
for (const [m, R] of [["true", !0], ["false", !1], ["null", null]])
|
|
598
|
+
if (i.startsWith(m, t))
|
|
599
|
+
return t += m.length, R;
|
|
600
|
+
const y = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/u.exec(i.slice(t));
|
|
601
|
+
if (!y) throw l("RELAY_ERROR");
|
|
602
|
+
t += y[0].length;
|
|
603
|
+
const d = Number(y[0]);
|
|
604
|
+
if (!Number.isFinite(d)) throw l("RELAY_ERROR");
|
|
605
|
+
return d;
|
|
605
606
|
};
|
|
606
|
-
|
|
607
|
-
const
|
|
608
|
-
if (
|
|
609
|
-
return
|
|
607
|
+
n();
|
|
608
|
+
const a = o();
|
|
609
|
+
if (n(), t !== i.length) throw l("RELAY_ERROR");
|
|
610
|
+
return a;
|
|
610
611
|
}
|
|
611
612
|
function F(i, e, t = "RELAY_ERROR") {
|
|
612
613
|
if (!vt(i) || Object.getOwnPropertySymbols(i).length !== 0)
|
|
613
|
-
throw
|
|
614
|
-
const
|
|
615
|
-
if (
|
|
616
|
-
throw
|
|
617
|
-
for (const s of
|
|
614
|
+
throw l(t);
|
|
615
|
+
const r = Object.getOwnPropertyNames(i).sort(), n = [...e].sort();
|
|
616
|
+
if (r.length !== n.length || r.some((s, o) => s !== n[o]))
|
|
617
|
+
throw l(t);
|
|
618
|
+
for (const s of r) {
|
|
618
619
|
const o = Object.getOwnPropertyDescriptor(i, s);
|
|
619
620
|
if (!o?.enumerable || !("value" in o) || o.value === void 0)
|
|
620
|
-
throw
|
|
621
|
+
throw l(t);
|
|
621
622
|
}
|
|
622
623
|
return i;
|
|
623
624
|
}
|
|
624
625
|
function q(i, e = "RELAY_ERROR") {
|
|
625
626
|
if (typeof i != "string" || !ft.test(i))
|
|
626
|
-
throw
|
|
627
|
+
throw l(e);
|
|
627
628
|
const t = Date.parse(i);
|
|
628
629
|
if (!Number.isFinite(t) || new Date(t).toISOString() !== i)
|
|
629
|
-
throw
|
|
630
|
+
throw l(e);
|
|
630
631
|
return t;
|
|
631
632
|
}
|
|
632
|
-
function
|
|
633
|
-
return Array.isArray(i) ? Object.freeze(i.map(
|
|
634
|
-
Object.entries(i).map(([e, t]) => [e,
|
|
633
|
+
function g(i) {
|
|
634
|
+
return Array.isArray(i) ? Object.freeze(i.map(g)) : i && typeof i == "object" ? Object.freeze(Object.fromEntries(
|
|
635
|
+
Object.entries(i).map(([e, t]) => [e, g(t)])
|
|
635
636
|
)) : i;
|
|
636
637
|
}
|
|
637
638
|
function ue(i) {
|
|
638
639
|
const e = {
|
|
639
|
-
identity: i.identity === null ? null :
|
|
640
|
+
identity: i.identity === null ? null : g(i.identity),
|
|
640
641
|
status: i.status
|
|
641
642
|
};
|
|
642
|
-
return i.connectionExpiresAt !== void 0 && (e.connectionExpiresAt = i.connectionExpiresAt), i.error !== void 0 && (e.error =
|
|
643
|
+
return i.connectionExpiresAt !== void 0 && (e.connectionExpiresAt = i.connectionExpiresAt), i.error !== void 0 && (e.error = g(i.error)), g(e);
|
|
643
644
|
}
|
|
644
645
|
function N(i) {
|
|
645
646
|
return Object.freeze({ code: i.code, message: i.message });
|
|
646
647
|
}
|
|
647
648
|
function he(i) {
|
|
648
649
|
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
649
|
-
let t = 0,
|
|
650
|
+
let t = 0, r = 0, n = "";
|
|
650
651
|
for (const s of i)
|
|
651
|
-
for (t = t << 8 | s,
|
|
652
|
-
|
|
653
|
-
return
|
|
652
|
+
for (t = t << 8 | s, r += 8; r >= 6; )
|
|
653
|
+
r -= 6, n += e[t >>> r & 63], t &= (1 << r) - 1;
|
|
654
|
+
return r !== 0 && (n += e[t << 6 - r & 63]), n;
|
|
654
655
|
}
|
|
655
656
|
function fe(i) {
|
|
656
657
|
let e = "";
|
|
@@ -701,74 +702,74 @@ function C(i, e, t = null) {
|
|
|
701
702
|
t && xe(t), k(e);
|
|
702
703
|
}
|
|
703
704
|
function B(i, e, t = null) {
|
|
704
|
-
let
|
|
705
|
+
let r;
|
|
705
706
|
try {
|
|
706
|
-
|
|
707
|
-
} catch (
|
|
708
|
-
return Promise.reject(
|
|
707
|
+
r = Promise.resolve(i);
|
|
708
|
+
} catch (n) {
|
|
709
|
+
return Promise.reject(n);
|
|
709
710
|
}
|
|
710
|
-
return new Promise((
|
|
711
|
+
return new Promise((n, s) => {
|
|
711
712
|
let o = !1;
|
|
712
|
-
const
|
|
713
|
+
const a = () => {
|
|
713
714
|
try {
|
|
714
715
|
e.removeEventListener("abort", h);
|
|
715
716
|
} catch {
|
|
716
717
|
}
|
|
717
|
-
}, u = (
|
|
718
|
-
u(s,
|
|
718
|
+
}, u = (y, d) => o ? !1 : (o = !0, a(), y(d), !0), h = () => {
|
|
719
|
+
u(s, l("RELAY_ERROR"));
|
|
719
720
|
};
|
|
720
721
|
try {
|
|
721
722
|
e.addEventListener("abort", h, { once: !0 }), e.aborted && h();
|
|
722
723
|
} catch {
|
|
723
724
|
h();
|
|
724
725
|
}
|
|
725
|
-
|
|
726
|
-
(
|
|
726
|
+
r.then(
|
|
727
|
+
(y) => {
|
|
727
728
|
if (o) {
|
|
728
729
|
try {
|
|
729
|
-
t?.(
|
|
730
|
+
t?.(y);
|
|
730
731
|
} catch {
|
|
731
732
|
}
|
|
732
733
|
return;
|
|
733
734
|
}
|
|
734
|
-
u(
|
|
735
|
+
u(n, y);
|
|
735
736
|
},
|
|
736
|
-
(
|
|
737
|
-
o || u(s,
|
|
737
|
+
(y) => {
|
|
738
|
+
o || u(s, y);
|
|
738
739
|
}
|
|
739
740
|
);
|
|
740
741
|
});
|
|
741
742
|
}
|
|
742
743
|
async function de(i, e, t) {
|
|
743
|
-
let
|
|
744
|
-
const
|
|
744
|
+
let r = null;
|
|
745
|
+
const n = [];
|
|
745
746
|
let s = 0;
|
|
746
747
|
try {
|
|
747
748
|
if (!Ot(i) || typeof i?.body?.getReader != "function")
|
|
748
|
-
throw
|
|
749
|
-
for (
|
|
750
|
-
const u =
|
|
749
|
+
throw l("RELAY_ERROR");
|
|
750
|
+
for (r = i.body.getReader(); ; ) {
|
|
751
|
+
const u = r.read(), { done: h, value: y } = await B(u, t.signal);
|
|
751
752
|
if (h) break;
|
|
752
|
-
if (!(
|
|
753
|
-
throw
|
|
754
|
-
|
|
753
|
+
if (!(y instanceof Uint8Array) || (s += y.byteLength, s > e))
|
|
754
|
+
throw l("RELAY_ERROR");
|
|
755
|
+
n.push(y);
|
|
755
756
|
}
|
|
756
757
|
const o = new Uint8Array(s);
|
|
757
|
-
let
|
|
758
|
-
for (const u of
|
|
759
|
-
o.set(u,
|
|
758
|
+
let a = 0;
|
|
759
|
+
for (const u of n)
|
|
760
|
+
o.set(u, a), a += u.byteLength;
|
|
760
761
|
return bt.decode(o);
|
|
761
762
|
} catch {
|
|
762
763
|
try {
|
|
763
764
|
t.abort();
|
|
764
765
|
} catch {
|
|
765
766
|
}
|
|
766
|
-
throw
|
|
767
|
+
throw r && xe(r), l("RELAY_ERROR");
|
|
767
768
|
} finally {
|
|
768
|
-
|
|
769
|
+
r && wt(r);
|
|
769
770
|
}
|
|
770
771
|
}
|
|
771
|
-
function
|
|
772
|
+
function U(i, e) {
|
|
772
773
|
const t = {
|
|
773
774
|
body: JSON.stringify(i),
|
|
774
775
|
cache: "no-store",
|
|
@@ -782,18 +783,18 @@ function $(i, e) {
|
|
|
782
783
|
return e !== void 0 && (t.signal = e), t;
|
|
783
784
|
}
|
|
784
785
|
function St(i, e, t) {
|
|
785
|
-
let
|
|
786
|
+
let r;
|
|
786
787
|
try {
|
|
787
|
-
|
|
788
|
+
r = $(i, 2048), F(r, ["code", "expiresAt", "schemaVersion", "state"], "CALLBACK_ERROR");
|
|
788
789
|
} catch {
|
|
789
|
-
throw
|
|
790
|
+
throw l("CALLBACK_ERROR");
|
|
790
791
|
}
|
|
791
|
-
if (
|
|
792
|
-
throw
|
|
793
|
-
const
|
|
794
|
-
if (
|
|
795
|
-
throw
|
|
796
|
-
return { code:
|
|
792
|
+
if (r.schemaVersion !== 1 || r.state !== e || !D.test(r.code))
|
|
793
|
+
throw l("CALLBACK_ERROR");
|
|
794
|
+
const n = q(r.expiresAt, "CALLBACK_ERROR");
|
|
795
|
+
if (n <= t || n - t > Rt)
|
|
796
|
+
throw l("CALLBACK_ERROR");
|
|
797
|
+
return { code: r.code, expiresAt: n, state: r.state };
|
|
797
798
|
}
|
|
798
799
|
function It() {
|
|
799
800
|
let i;
|
|
@@ -801,13 +802,13 @@ function It() {
|
|
|
801
802
|
i = t;
|
|
802
803
|
}), resolve: i };
|
|
803
804
|
}
|
|
804
|
-
function
|
|
805
|
+
function ye() {
|
|
805
806
|
let i, e;
|
|
806
|
-
return { promise: new Promise((
|
|
807
|
-
i =
|
|
807
|
+
return { promise: new Promise((r, n) => {
|
|
808
|
+
i = n, e = r;
|
|
808
809
|
}), reject: i, resolve: e };
|
|
809
810
|
}
|
|
810
|
-
function
|
|
811
|
+
function _t() {
|
|
811
812
|
const i = globalThis.window;
|
|
812
813
|
return Object.freeze({
|
|
813
814
|
AbortController: globalThis.AbortController,
|
|
@@ -828,7 +829,7 @@ function gt() {
|
|
|
828
829
|
window: i
|
|
829
830
|
});
|
|
830
831
|
}
|
|
831
|
-
class
|
|
832
|
+
class gt {
|
|
832
833
|
#j;
|
|
833
834
|
#M;
|
|
834
835
|
#x = !1;
|
|
@@ -846,22 +847,22 @@ class _t {
|
|
|
846
847
|
#T = [];
|
|
847
848
|
#o = null;
|
|
848
849
|
#C = !1;
|
|
849
|
-
#
|
|
850
|
+
#y = /* @__PURE__ */ new Set();
|
|
850
851
|
#Y = Object.freeze({ identity: null, status: "dormant" });
|
|
851
852
|
#u = null;
|
|
852
|
-
#
|
|
853
|
+
#_ = null;
|
|
853
854
|
#b = null;
|
|
854
855
|
#R = /* @__PURE__ */ new Set();
|
|
855
|
-
#
|
|
856
|
-
constructor({ adapters: e, clientId: t, dependencies:
|
|
857
|
-
this.#j = e, this.#M = t, this.#e =
|
|
856
|
+
#m;
|
|
857
|
+
constructor({ adapters: e, clientId: t, dependencies: r }) {
|
|
858
|
+
this.#j = e, this.#M = t, this.#e = r ?? _t(), this.#m = this.#e.window;
|
|
858
859
|
}
|
|
859
860
|
getSnapshot() {
|
|
860
861
|
return this.#F(), ue(this.#Y);
|
|
861
862
|
}
|
|
862
863
|
subscribe(e) {
|
|
863
|
-
if (typeof e != "function") throw
|
|
864
|
-
if (this.#i) throw
|
|
864
|
+
if (typeof e != "function") throw l("INVALID_REQUEST");
|
|
865
|
+
if (this.#i) throw l("DESTROYED");
|
|
865
866
|
this.#I.add(e);
|
|
866
867
|
try {
|
|
867
868
|
e(this.getSnapshot());
|
|
@@ -873,59 +874,59 @@ class _t {
|
|
|
873
874
|
};
|
|
874
875
|
}
|
|
875
876
|
execute(e, t) {
|
|
876
|
-
if (this.#i) return Promise.reject(
|
|
877
|
-
const
|
|
878
|
-
if (!
|
|
877
|
+
if (this.#i) return Promise.reject(l("DESTROYED"));
|
|
878
|
+
const r = this.#p, n = this.#j[e];
|
|
879
|
+
if (!n) return Promise.reject(l("INVALID_REQUEST"));
|
|
879
880
|
let s;
|
|
880
881
|
try {
|
|
881
|
-
s =
|
|
882
|
+
s = n.buildRequest(t);
|
|
882
883
|
} catch {
|
|
883
|
-
const A = this.#t(
|
|
884
|
-
return A ? Promise.reject(A) : Promise.reject(
|
|
884
|
+
const A = this.#t(r);
|
|
885
|
+
return A ? Promise.reject(A) : Promise.reject(l("INVALID_REQUEST"));
|
|
885
886
|
}
|
|
886
|
-
let o = this.#t(
|
|
887
|
+
let o = this.#t(r);
|
|
887
888
|
if (o) return Promise.reject(o);
|
|
888
889
|
if (this.#x)
|
|
889
|
-
return this.#l = !0, Promise.reject(
|
|
890
|
-
const
|
|
891
|
-
if (this.#Q(), o = this.#t(
|
|
890
|
+
return this.#l = !0, Promise.reject(l("REPLACED"));
|
|
891
|
+
const a = ++this.#p;
|
|
892
|
+
if (this.#Q(), o = this.#t(a), o) return Promise.reject(o);
|
|
892
893
|
if (this.#l)
|
|
893
|
-
return Promise.reject(
|
|
894
|
-
if (this.#F(), o = this.#t(
|
|
895
|
-
const u = this.#
|
|
896
|
-
if (o = this.#t(
|
|
894
|
+
return Promise.reject(l("CALLBACK_ERROR"));
|
|
895
|
+
if (this.#F(), o = this.#t(a), o) return Promise.reject(o);
|
|
896
|
+
const u = this.#n();
|
|
897
|
+
if (o = this.#t(a), o) return Promise.reject(o);
|
|
897
898
|
const h = this.#s && this.#s.expiresAtMs > u ? this.#s : null;
|
|
898
|
-
if (o = this.#t(
|
|
899
|
-
const
|
|
900
|
-
let
|
|
899
|
+
if (o = this.#t(a), o) return Promise.reject(o);
|
|
900
|
+
const y = this.#o;
|
|
901
|
+
let d, m, R;
|
|
901
902
|
try {
|
|
902
|
-
const A = this.#e.crypto, O = A?.getRandomValues, Ce = A?.subtle?.digest,
|
|
903
|
-
if (o = this.#t(
|
|
904
|
-
if (typeof O != "function" || typeof Ce != "function" || typeof
|
|
905
|
-
throw
|
|
906
|
-
if (
|
|
907
|
-
if (!D.test(
|
|
908
|
-
throw
|
|
909
|
-
if (Reflect.apply(
|
|
910
|
-
`${P}/transaction/${
|
|
903
|
+
const A = this.#e.crypto, O = A?.getRandomValues, Ce = A?.subtle?.digest, ne = this.#m?.open;
|
|
904
|
+
if (o = this.#t(a), o) throw o;
|
|
905
|
+
if (typeof O != "function" || typeof Ce != "function" || typeof ne != "function")
|
|
906
|
+
throw l("CRYPTO_UNAVAILABLE");
|
|
907
|
+
if (d = fe(H(A, O)), o = this.#t(a), o || (m = fe(H(A, O)), o = this.#t(a), o) || (R = he(H(A, O)), o = this.#t(a), o)) throw o;
|
|
908
|
+
if (!D.test(d) || !D.test(m) || !ce.test(R))
|
|
909
|
+
throw l("CRYPTO_UNAVAILABLE");
|
|
910
|
+
if (Reflect.apply(ne, this.#m, [
|
|
911
|
+
`${P}/transaction/${d}`,
|
|
911
912
|
"_blank",
|
|
912
913
|
"noopener"
|
|
913
|
-
]), o = this.#t(
|
|
914
|
+
]), o = this.#t(a), o) throw o;
|
|
914
915
|
} catch (A) {
|
|
915
|
-
if (o = this.#t(
|
|
916
|
+
if (o = this.#t(a), o) return Promise.reject(o);
|
|
916
917
|
let O;
|
|
917
918
|
try {
|
|
918
|
-
O = A instanceof j ? A :
|
|
919
|
+
O = A instanceof j ? A : l("CRYPTO_UNAVAILABLE");
|
|
919
920
|
} catch {
|
|
920
|
-
O =
|
|
921
|
+
O = l("CRYPTO_UNAVAILABLE");
|
|
921
922
|
}
|
|
922
|
-
return
|
|
923
|
+
return y && (this.#g(y, "REPLACED", !1), o = this.#t(a), o) ? Promise.reject(o) : (this.#U(null, O, h, n.kind), Promise.reject(O));
|
|
923
924
|
}
|
|
924
|
-
if (
|
|
925
|
+
if (y && (this.#g(y, "REPLACED", !1), o = this.#t(a), o))
|
|
925
926
|
return Promise.reject(o);
|
|
926
|
-
const I =
|
|
927
|
+
const I = ye(), Te = It(), re = {
|
|
927
928
|
active: !0,
|
|
928
|
-
adapter:
|
|
929
|
+
adapter: n,
|
|
929
930
|
callbackBusy: !1,
|
|
930
931
|
challenge: null,
|
|
931
932
|
cleanup: Te,
|
|
@@ -939,70 +940,71 @@ class _t {
|
|
|
939
940
|
pollTimer: null,
|
|
940
941
|
priorConnection: h,
|
|
941
942
|
promise: I.promise,
|
|
942
|
-
registrationDeadlineMs: u +
|
|
943
|
+
registrationDeadlineMs: u + yt,
|
|
943
944
|
registrationOutcome: "none",
|
|
944
945
|
reject: I.reject,
|
|
946
|
+
openResult: null,
|
|
945
947
|
request: s,
|
|
946
948
|
resolve: I.resolve,
|
|
947
949
|
retryResolve: null,
|
|
948
950
|
retryTimer: null,
|
|
949
|
-
state:
|
|
951
|
+
state: m,
|
|
950
952
|
transactionExpiresAtMs: null,
|
|
951
|
-
transactionId:
|
|
953
|
+
transactionId: d,
|
|
952
954
|
verifier: R
|
|
953
955
|
};
|
|
954
|
-
return this.#o =
|
|
956
|
+
return this.#o = re, this.#r({
|
|
955
957
|
...h ? {
|
|
956
958
|
connectionExpiresAt: h.expiresAt,
|
|
957
959
|
identity: h.identity
|
|
958
960
|
} : { identity: null },
|
|
959
961
|
status: "opening"
|
|
960
|
-
}), this.#J(
|
|
962
|
+
}), this.#J(re), I.promise;
|
|
961
963
|
}
|
|
962
964
|
async disconnect() {
|
|
963
|
-
if (this.#i) throw
|
|
965
|
+
if (this.#i) throw l("DESTROYED");
|
|
964
966
|
const e = ++this.#p;
|
|
965
967
|
this.#f();
|
|
966
968
|
const t = this.#o;
|
|
967
|
-
let
|
|
968
|
-
t && (
|
|
969
|
-
let
|
|
970
|
-
if (
|
|
971
|
-
throw await
|
|
972
|
-
if (this.#
|
|
969
|
+
let r = Promise.resolve();
|
|
970
|
+
t && (r = this.#g(t, "DISCONNECTED", !1));
|
|
971
|
+
let n = this.#t(e);
|
|
972
|
+
if (n)
|
|
973
|
+
throw await r, n;
|
|
974
|
+
if (this.#r({ identity: null, status: "dormant" }), await r, n = this.#t(e), n) throw n;
|
|
973
975
|
}
|
|
974
976
|
destroy() {
|
|
975
977
|
if (this.#w) return this.#w;
|
|
976
|
-
const e =
|
|
978
|
+
const e = ye();
|
|
977
979
|
this.#w = e.promise, this.#p += 1;
|
|
978
980
|
try {
|
|
979
981
|
this.#B(), e.resolve();
|
|
980
982
|
} catch {
|
|
981
|
-
e.reject(
|
|
983
|
+
e.reject(l("RELAY_ERROR"));
|
|
982
984
|
}
|
|
983
985
|
return this.#w;
|
|
984
986
|
}
|
|
985
987
|
#B() {
|
|
986
988
|
this.#i = !0, this.#S += 1, this.#f();
|
|
987
989
|
const e = [], t = this.#o;
|
|
988
|
-
t && (t.active = !1, this.#o = null, this.#L(t), t.reject(
|
|
989
|
-
for (const
|
|
990
|
-
|
|
991
|
-
for (const
|
|
990
|
+
t && (t.active = !1, this.#o = null, this.#L(t), t.reject(l("DESTROYED")), t.challenge && t.verifier && e.push(t));
|
|
991
|
+
for (const r of this.#y)
|
|
992
|
+
r.challenge && r.verifier && e.push(r);
|
|
993
|
+
for (const r of this.#A) r.abort();
|
|
992
994
|
this.#A.clear();
|
|
993
|
-
for (const
|
|
994
|
-
this.#e.clearTimeout(
|
|
995
|
+
for (const r of this.#R)
|
|
996
|
+
this.#e.clearTimeout(r), this.#e.clearInterval(r);
|
|
995
997
|
if (this.#R.clear(), this.#b)
|
|
996
998
|
try {
|
|
997
999
|
this.#b();
|
|
998
1000
|
} catch {
|
|
999
1001
|
}
|
|
1000
|
-
this.#
|
|
1001
|
-
for (const
|
|
1002
|
+
this.#_ = null, this.#b = null, this.#u = null, this.#I.clear();
|
|
1003
|
+
for (const r of e) this.#X(r);
|
|
1002
1004
|
t && this.#a(t);
|
|
1003
|
-
for (const
|
|
1004
|
-
this.#
|
|
1005
|
-
error: N(
|
|
1005
|
+
for (const r of [...this.#y]) this.#a(r);
|
|
1006
|
+
this.#r({
|
|
1007
|
+
error: N(l("DESTROYED")),
|
|
1006
1008
|
identity: null,
|
|
1007
1009
|
status: "error"
|
|
1008
1010
|
});
|
|
@@ -1010,33 +1012,36 @@ class _t {
|
|
|
1010
1012
|
async #J(e) {
|
|
1011
1013
|
if (!(!this.#c(e) || e.cleanupFinished))
|
|
1012
1014
|
try {
|
|
1013
|
-
e.operationTimer = this.#v(() => {
|
|
1015
|
+
if (e.operationTimer = this.#v(() => {
|
|
1014
1016
|
if (!e.cleanupFinished) {
|
|
1015
1017
|
if (e.phase === "hashing") {
|
|
1016
1018
|
this.#c(e) && this.#h(e, "CRYPTO_UNAVAILABLE", !1);
|
|
1017
1019
|
return;
|
|
1018
1020
|
}
|
|
1019
1021
|
if (e.phase === "registering")
|
|
1020
|
-
for (const
|
|
1022
|
+
for (const a of e.controllers) a.abort();
|
|
1021
1023
|
}
|
|
1022
|
-
}, Math.max(0, e.registrationDeadlineMs - this.#
|
|
1024
|
+
}, Math.max(0, e.registrationDeadlineMs - this.#n())), typeof e.adapter.seal == "function") {
|
|
1025
|
+
const a = await e.adapter.seal(e.request, this.#e.crypto);
|
|
1026
|
+
e.request = a.request, e.openResult = a.open;
|
|
1027
|
+
}
|
|
1023
1028
|
const t = await this.#e.crypto.subtle.digest(
|
|
1024
1029
|
"SHA-256",
|
|
1025
1030
|
Le.encode(e.verifier)
|
|
1026
|
-
),
|
|
1027
|
-
if (!ce.test(
|
|
1031
|
+
), r = he(new Uint8Array(t));
|
|
1032
|
+
if (!ce.test(r)) throw l("CRYPTO_UNAVAILABLE");
|
|
1028
1033
|
if (!this.#c(e)) {
|
|
1029
1034
|
e.registrationOutcome = "not-started", this.#a(e);
|
|
1030
1035
|
return;
|
|
1031
1036
|
}
|
|
1032
|
-
e.challenge =
|
|
1033
|
-
const
|
|
1037
|
+
e.challenge = r, e.phase = "registering";
|
|
1038
|
+
const n = this.#N(e);
|
|
1034
1039
|
let s, o = null;
|
|
1035
1040
|
try {
|
|
1036
1041
|
try {
|
|
1037
1042
|
const u = this.#e.fetch(
|
|
1038
1043
|
`${P}/relay/v1/transactions`,
|
|
1039
|
-
|
|
1044
|
+
U({
|
|
1040
1045
|
clientId: this.#M,
|
|
1041
1046
|
codeChallenge: e.challenge,
|
|
1042
1047
|
codeChallengeMethod: "S256",
|
|
@@ -1045,11 +1050,11 @@ class _t {
|
|
|
1045
1050
|
schemaVersion: 1,
|
|
1046
1051
|
state: e.state,
|
|
1047
1052
|
transactionId: e.transactionId
|
|
1048
|
-
},
|
|
1053
|
+
}, n.signal)
|
|
1049
1054
|
);
|
|
1050
1055
|
o = await B(
|
|
1051
1056
|
u,
|
|
1052
|
-
|
|
1057
|
+
n.signal,
|
|
1053
1058
|
k
|
|
1054
1059
|
);
|
|
1055
1060
|
} catch {
|
|
@@ -1057,42 +1062,42 @@ class _t {
|
|
|
1057
1062
|
return;
|
|
1058
1063
|
}
|
|
1059
1064
|
e.registrationOutcome = "ambiguous";
|
|
1060
|
-
let
|
|
1065
|
+
let a;
|
|
1061
1066
|
try {
|
|
1062
|
-
|
|
1067
|
+
a = o.status;
|
|
1063
1068
|
} catch {
|
|
1064
|
-
C(
|
|
1069
|
+
C(n, o), e.active ? this.#h(e, "RELAY_ERROR") : this.#E(e);
|
|
1065
1070
|
return;
|
|
1066
1071
|
}
|
|
1067
|
-
if (
|
|
1068
|
-
e.registrationOutcome = "definitive-failure", C(
|
|
1072
|
+
if (a !== 201) {
|
|
1073
|
+
e.registrationOutcome = "definitive-failure", C(n, o), e.active ? this.#h(e, "RELAY_ERROR", !1) : this.#a(e);
|
|
1069
1074
|
return;
|
|
1070
1075
|
}
|
|
1071
1076
|
try {
|
|
1072
1077
|
const u = await de(
|
|
1073
1078
|
o,
|
|
1074
1079
|
ae,
|
|
1075
|
-
|
|
1080
|
+
n
|
|
1076
1081
|
), h = F(
|
|
1077
|
-
|
|
1082
|
+
$(u, ae),
|
|
1078
1083
|
["expiresAt", "schemaVersion", "transactionId"]
|
|
1079
1084
|
);
|
|
1080
1085
|
if (h.schemaVersion !== 1 || h.transactionId !== e.transactionId)
|
|
1081
|
-
throw
|
|
1086
|
+
throw l("RELAY_ERROR");
|
|
1082
1087
|
s = q(h.expiresAt);
|
|
1083
|
-
const
|
|
1084
|
-
if (s <=
|
|
1085
|
-
throw
|
|
1088
|
+
const y = this.#n();
|
|
1089
|
+
if (s <= y || s - y > mt)
|
|
1090
|
+
throw l("RELAY_ERROR");
|
|
1086
1091
|
} catch {
|
|
1087
|
-
e.registrationOutcome = "ambiguous", C(
|
|
1092
|
+
e.registrationOutcome = "ambiguous", C(n, o), e.active ? this.#h(e, "RELAY_ERROR") : this.#E(e);
|
|
1088
1093
|
return;
|
|
1089
1094
|
}
|
|
1090
1095
|
} finally {
|
|
1091
1096
|
try {
|
|
1092
|
-
|
|
1097
|
+
n.abort();
|
|
1093
1098
|
} catch {
|
|
1094
1099
|
}
|
|
1095
|
-
this.#D(e,
|
|
1100
|
+
this.#D(e, n), this.#d(e.operationTimer), e.operationTimer = null;
|
|
1096
1101
|
}
|
|
1097
1102
|
if (e.transactionExpiresAtMs = s, e.registrationOutcome = "registered", !this.#c(e)) {
|
|
1098
1103
|
this.#E(e);
|
|
@@ -1100,7 +1105,7 @@ class _t {
|
|
|
1100
1105
|
}
|
|
1101
1106
|
e.phase = "waiting-callback", e.expiryTimer = this.#v(() => {
|
|
1102
1107
|
this.#c(e) && this.#h(e, "WALLET_NOT_COMPLETED");
|
|
1103
|
-
}, Math.max(0, e.transactionExpiresAtMs - this.#
|
|
1108
|
+
}, Math.max(0, e.transactionExpiresAtMs - this.#n())), e.pollTimer = this.#H(() => {
|
|
1104
1109
|
this.#P(e, !1);
|
|
1105
1110
|
}, dt), await this.#P(e, !1);
|
|
1106
1111
|
} catch (t) {
|
|
@@ -1108,28 +1113,28 @@ class _t {
|
|
|
1108
1113
|
e.registrationOutcome === "ambiguous" || e.registrationOutcome === "registered" ? this.#E(e) : this.#a(e);
|
|
1109
1114
|
return;
|
|
1110
1115
|
}
|
|
1111
|
-
const
|
|
1112
|
-
this.#h(e,
|
|
1116
|
+
const r = t instanceof j ? t.code : e.phase === "hashing" ? "CRYPTO_UNAVAILABLE" : "RELAY_ERROR";
|
|
1117
|
+
this.#h(e, r, e.registrationOutcome !== "none");
|
|
1113
1118
|
}
|
|
1114
1119
|
}
|
|
1115
1120
|
async #P(e, t) {
|
|
1116
1121
|
if (!this.#c(e) || e.phase !== "waiting-callback" || e.callbackBusy || !this.#u) return;
|
|
1117
|
-
const
|
|
1118
|
-
let
|
|
1122
|
+
const r = `${Y}${e.state}`;
|
|
1123
|
+
let n;
|
|
1119
1124
|
try {
|
|
1120
|
-
|
|
1125
|
+
n = this.#u.getItem(r);
|
|
1121
1126
|
} catch {
|
|
1122
1127
|
t && this.#h(e, "CALLBACK_ERROR");
|
|
1123
1128
|
return;
|
|
1124
1129
|
}
|
|
1125
|
-
if (
|
|
1130
|
+
if (n === null) return;
|
|
1126
1131
|
e.callbackBusy = !0;
|
|
1127
1132
|
let s;
|
|
1128
1133
|
try {
|
|
1129
|
-
s = St(
|
|
1134
|
+
s = St(n, e.state, this.#n()), this.#u.removeItem(r);
|
|
1130
1135
|
} catch {
|
|
1131
1136
|
try {
|
|
1132
|
-
this.#u.removeItem(
|
|
1137
|
+
this.#u.removeItem(r);
|
|
1133
1138
|
} catch {
|
|
1134
1139
|
}
|
|
1135
1140
|
this.#h(e, "CALLBACK_ERROR");
|
|
@@ -1138,11 +1143,11 @@ class _t {
|
|
|
1138
1143
|
if (!this.#c(e)) return;
|
|
1139
1144
|
e.phase = "redeeming", this.#d(e.pollTimer, !0), e.pollTimer = null;
|
|
1140
1145
|
const o = this.#N(e);
|
|
1141
|
-
let
|
|
1146
|
+
let a = null;
|
|
1142
1147
|
try {
|
|
1143
1148
|
const u = this.#e.fetch(
|
|
1144
1149
|
`${P}/relay/v1/codes/redeem`,
|
|
1145
|
-
|
|
1150
|
+
U({
|
|
1146
1151
|
code: s.code,
|
|
1147
1152
|
codeVerifier: e.verifier,
|
|
1148
1153
|
schemaVersion: 1,
|
|
@@ -1150,31 +1155,31 @@ class _t {
|
|
|
1150
1155
|
transactionId: e.transactionId
|
|
1151
1156
|
}, o.signal)
|
|
1152
1157
|
);
|
|
1153
|
-
if (
|
|
1158
|
+
if (a = await B(
|
|
1154
1159
|
u,
|
|
1155
1160
|
o.signal,
|
|
1156
1161
|
k
|
|
1157
|
-
),
|
|
1162
|
+
), a.status !== 200) throw l("RELAY_ERROR");
|
|
1158
1163
|
const h = await de(
|
|
1159
|
-
|
|
1164
|
+
a,
|
|
1160
1165
|
le,
|
|
1161
1166
|
o
|
|
1162
|
-
),
|
|
1163
|
-
|
|
1167
|
+
), y = F(
|
|
1168
|
+
$(h, le),
|
|
1164
1169
|
["result", "schemaVersion", "transactionId"]
|
|
1165
1170
|
);
|
|
1166
|
-
if (
|
|
1167
|
-
throw
|
|
1168
|
-
let
|
|
1171
|
+
if (y.schemaVersion !== 1 || y.transactionId !== e.transactionId)
|
|
1172
|
+
throw l("RELAY_ERROR");
|
|
1173
|
+
let d;
|
|
1169
1174
|
try {
|
|
1170
|
-
|
|
1175
|
+
d = e.adapter.parseResult(y.result);
|
|
1171
1176
|
} catch {
|
|
1172
|
-
throw
|
|
1177
|
+
throw l("RELAY_ERROR");
|
|
1173
1178
|
}
|
|
1174
|
-
if (!this.#c(e)) return;
|
|
1175
|
-
this.#W(e,
|
|
1179
|
+
if (e.openResult && (d = await e.openResult(d)), !this.#c(e)) return;
|
|
1180
|
+
this.#W(e, d);
|
|
1176
1181
|
} catch (u) {
|
|
1177
|
-
if (
|
|
1182
|
+
if (a && C(o, a), !this.#c(e)) return;
|
|
1178
1183
|
const h = u instanceof j ? u.code : "RELAY_ERROR";
|
|
1179
1184
|
this.#h(e, h);
|
|
1180
1185
|
} finally {
|
|
@@ -1187,86 +1192,86 @@ class _t {
|
|
|
1187
1192
|
}
|
|
1188
1193
|
#W(e, t) {
|
|
1189
1194
|
if (!this.#c(e)) return;
|
|
1190
|
-
let
|
|
1191
|
-
(e.adapter.kind === "connect" || e.adapter.kind === "account" && t.event === "connected") && (
|
|
1192
|
-
let
|
|
1193
|
-
e.adapter.kind === "connect" ? (this
|
|
1195
|
+
let r = null;
|
|
1196
|
+
(e.adapter.kind === "connect" || e.adapter.kind === "account" && t.event === "connected") && (r = this.#K(t)), e.active = !1, this.#o = null, this.#L(e);
|
|
1197
|
+
let n = t;
|
|
1198
|
+
e.adapter.kind === "connect" ? (this.#$(r), n = g(t.identity)) : e.adapter.kind === "account" ? (t.event === "connected" ? this.#$(r) : (this.#f(), this.#r({ identity: null, status: "dormant" })), n = void 0) : this.#z(e, void 0), e.resolve(n), this.#a(e);
|
|
1194
1199
|
}
|
|
1195
|
-
#h(e, t,
|
|
1196
|
-
this.#c(e) && this.#
|
|
1200
|
+
#h(e, t, r = !0) {
|
|
1201
|
+
this.#c(e) && this.#g(e, t, !0, r);
|
|
1197
1202
|
}
|
|
1198
|
-
#
|
|
1203
|
+
#g(e, t, r, n = !0) {
|
|
1199
1204
|
if (!e.active) return e.cleanup.promise;
|
|
1200
1205
|
const s = this.#p;
|
|
1201
1206
|
e.active = !1, this.#o === e && (this.#o = null), this.#S += 1, this.#L(e);
|
|
1202
1207
|
for (const u of e.controllers)
|
|
1203
1208
|
e.phase !== "registering" && u.abort();
|
|
1204
|
-
const o = this.#t(s),
|
|
1205
|
-
return e.reject(
|
|
1209
|
+
const o = this.#t(s), a = o ?? l(t);
|
|
1210
|
+
return e.reject(a), r && !o && this.#U(e, a, e.priorConnection, e.adapter.kind), this.#i ? (e.challenge && e.verifier && this.#q(e), this.#a(e), e.cleanup.promise) : (!n || e.registrationOutcome === "definitive-failure" || e.registrationOutcome === "not-started" ? this.#a(e) : e.phase === "hashing" ? (e.registrationOutcome = "not-started", this.#a(e)) : e.phase === "registering" && e.registrationOutcome === "none" ? this.#k(e) : (this.#k(e), this.#E(e)), e.cleanup.promise);
|
|
1206
1211
|
}
|
|
1207
|
-
|
|
1208
|
-
if (
|
|
1209
|
-
this.#s =
|
|
1210
|
-
connectionExpiresAt:
|
|
1212
|
+
#U(e, t, r, n) {
|
|
1213
|
+
if (r?.expiresAtMs > this.#n()) {
|
|
1214
|
+
this.#s = r, this.#r({
|
|
1215
|
+
connectionExpiresAt: r.expiresAt,
|
|
1211
1216
|
error: N(t),
|
|
1212
|
-
identity:
|
|
1217
|
+
identity: r.identity,
|
|
1213
1218
|
status: "connected"
|
|
1214
1219
|
});
|
|
1215
1220
|
return;
|
|
1216
1221
|
}
|
|
1217
|
-
this.#f(), this.#
|
|
1222
|
+
this.#f(), this.#r({
|
|
1218
1223
|
error: N(t),
|
|
1219
1224
|
identity: null,
|
|
1220
1225
|
status: "error"
|
|
1221
1226
|
});
|
|
1222
1227
|
}
|
|
1223
1228
|
#K(e) {
|
|
1224
|
-
const t = q(e.connectionExpiresAt),
|
|
1225
|
-
if (t <=
|
|
1226
|
-
throw
|
|
1229
|
+
const t = q(e.connectionExpiresAt), r = this.#n();
|
|
1230
|
+
if (t <= r || t - r > pt)
|
|
1231
|
+
throw l("RELAY_ERROR");
|
|
1227
1232
|
return {
|
|
1228
1233
|
expiresAt: e.connectionExpiresAt,
|
|
1229
1234
|
expiresAtMs: t,
|
|
1230
|
-
identity:
|
|
1235
|
+
identity: g(e.identity)
|
|
1231
1236
|
};
|
|
1232
1237
|
}
|
|
1233
|
-
|
|
1234
|
-
const t = this.#
|
|
1238
|
+
#$(e) {
|
|
1239
|
+
const t = this.#n();
|
|
1235
1240
|
this.#f(), this.#s = e;
|
|
1236
|
-
const
|
|
1241
|
+
const r = this.#s;
|
|
1237
1242
|
this.#O = this.#v(() => {
|
|
1238
|
-
this.#s ===
|
|
1239
|
-
}, Math.max(0, e.expiresAtMs - t)), this.#
|
|
1243
|
+
this.#s === r && (this.#s = null, this.#O = null, this.#o ? this.#r({ identity: null, status: "opening" }) : this.#r({ identity: null, status: "dormant" }));
|
|
1244
|
+
}, Math.max(0, e.expiresAtMs - t)), this.#r({
|
|
1240
1245
|
connectionExpiresAt: e.expiresAt,
|
|
1241
1246
|
identity: this.#s.identity,
|
|
1242
1247
|
status: "connected"
|
|
1243
1248
|
});
|
|
1244
1249
|
}
|
|
1245
1250
|
#z(e, t) {
|
|
1246
|
-
const
|
|
1247
|
-
|
|
1248
|
-
connectionExpiresAt:
|
|
1251
|
+
const r = e.priorConnection;
|
|
1252
|
+
r?.expiresAtMs > this.#n() ? (this.#s = r, this.#r({
|
|
1253
|
+
connectionExpiresAt: r.expiresAt,
|
|
1249
1254
|
...t ? { error: N(t) } : {},
|
|
1250
|
-
identity:
|
|
1255
|
+
identity: r.identity,
|
|
1251
1256
|
status: "connected"
|
|
1252
|
-
})) : t ? (this.#f(), this.#
|
|
1257
|
+
})) : t ? (this.#f(), this.#r({ error: N(t), identity: null, status: "error" })) : (this.#f(), this.#r({ identity: null, status: "dormant" }));
|
|
1253
1258
|
}
|
|
1254
1259
|
#F() {
|
|
1255
|
-
!this.#s || this.#s.expiresAtMs > this.#
|
|
1260
|
+
!this.#s || this.#s.expiresAtMs > this.#n() || (this.#f(), this.#o ? this.#r({ identity: null, status: "opening" }) : this.#r({ identity: null, status: "dormant" }));
|
|
1256
1261
|
}
|
|
1257
1262
|
#f() {
|
|
1258
1263
|
this.#s = null, this.#d(this.#O), this.#O = null;
|
|
1259
1264
|
}
|
|
1260
|
-
#
|
|
1261
|
-
const t =
|
|
1265
|
+
#r(e) {
|
|
1266
|
+
const t = g(e);
|
|
1262
1267
|
if (this.#Y = t, this.#T.push(t), !this.#C) {
|
|
1263
1268
|
this.#C = !0;
|
|
1264
1269
|
try {
|
|
1265
1270
|
for (; this.#T.length !== 0; ) {
|
|
1266
|
-
const
|
|
1267
|
-
for (const
|
|
1271
|
+
const r = this.#T.shift();
|
|
1272
|
+
for (const n of [...this.#I])
|
|
1268
1273
|
try {
|
|
1269
|
-
|
|
1274
|
+
n(ue(r));
|
|
1270
1275
|
} catch {
|
|
1271
1276
|
}
|
|
1272
1277
|
}
|
|
@@ -1279,9 +1284,9 @@ class _t {
|
|
|
1279
1284
|
return !this.#i && e.active && this.#o === e && e.generation === this.#S;
|
|
1280
1285
|
}
|
|
1281
1286
|
#t(e) {
|
|
1282
|
-
return this.#i ?
|
|
1287
|
+
return this.#i ? l("DESTROYED") : e !== this.#p ? l("REPLACED") : null;
|
|
1283
1288
|
}
|
|
1284
|
-
#
|
|
1289
|
+
#n() {
|
|
1285
1290
|
return this.#e.now();
|
|
1286
1291
|
}
|
|
1287
1292
|
#N(e) {
|
|
@@ -1292,14 +1297,14 @@ class _t {
|
|
|
1292
1297
|
e.controllers.delete(t), this.#A.delete(t);
|
|
1293
1298
|
}
|
|
1294
1299
|
#v(e, t) {
|
|
1295
|
-
let
|
|
1296
|
-
return
|
|
1297
|
-
this.#R.delete(
|
|
1298
|
-
}, Math.max(0, t)), this.#R.add(
|
|
1300
|
+
let r;
|
|
1301
|
+
return r = this.#e.setTimeout(() => {
|
|
1302
|
+
this.#R.delete(r), e();
|
|
1303
|
+
}, Math.max(0, t)), this.#R.add(r), r;
|
|
1299
1304
|
}
|
|
1300
1305
|
#H(e, t) {
|
|
1301
|
-
const
|
|
1302
|
-
return this.#R.add(
|
|
1306
|
+
const r = this.#e.setInterval(e, t);
|
|
1307
|
+
return this.#R.add(r), r;
|
|
1303
1308
|
}
|
|
1304
1309
|
#d(e, t = !1) {
|
|
1305
1310
|
e != null && (t ? this.#e.clearInterval(e) : this.#e.clearTimeout(e), this.#R.delete(e));
|
|
@@ -1308,10 +1313,10 @@ class _t {
|
|
|
1308
1313
|
this.#d(e.expiryTimer), this.#d(e.pollTimer, !0), e.expiryTimer = null, e.pollTimer = null;
|
|
1309
1314
|
}
|
|
1310
1315
|
#k(e) {
|
|
1311
|
-
if (!(e.cleanupFinished || this.#
|
|
1312
|
-
for (this.#
|
|
1313
|
-
const t = this.#
|
|
1314
|
-
for (const
|
|
1316
|
+
if (!(e.cleanupFinished || this.#y.has(e)))
|
|
1317
|
+
for (this.#y.add(e); this.#y.size > Et; ) {
|
|
1318
|
+
const t = this.#y.values().next().value;
|
|
1319
|
+
for (const r of t.controllers) r.abort();
|
|
1315
1320
|
this.#a(t);
|
|
1316
1321
|
}
|
|
1317
1322
|
}
|
|
@@ -1319,14 +1324,14 @@ class _t {
|
|
|
1319
1324
|
if (e.cleanupFinished || e.cleanupStarted || this.#i)
|
|
1320
1325
|
return e.cleanup.promise;
|
|
1321
1326
|
e.cleanupStarted = !0, this.#k(e);
|
|
1322
|
-
let t = 100,
|
|
1323
|
-
for (; !this.#i && !e.cleanupFinished && (
|
|
1324
|
-
|
|
1325
|
-
const
|
|
1327
|
+
let t = 100, r = !0;
|
|
1328
|
+
for (; !this.#i && !e.cleanupFinished && (r || this.#n() <= e.registrationDeadlineMs); ) {
|
|
1329
|
+
r = !1;
|
|
1330
|
+
const n = await this.#q(e);
|
|
1326
1331
|
if (e.cleanupFinished) return e.cleanup.promise;
|
|
1327
|
-
if (
|
|
1332
|
+
if (n === "done")
|
|
1328
1333
|
return this.#a(e), e.cleanup.promise;
|
|
1329
|
-
const s = e.registrationDeadlineMs - this.#
|
|
1334
|
+
const s = e.registrationDeadlineMs - this.#n();
|
|
1330
1335
|
if (s <= 0) break;
|
|
1331
1336
|
await new Promise((o) => {
|
|
1332
1337
|
e.retryResolve = o, e.retryTimer = this.#v(() => {
|
|
@@ -1338,12 +1343,12 @@ class _t {
|
|
|
1338
1343
|
}
|
|
1339
1344
|
async #q(e) {
|
|
1340
1345
|
if (!e.verifier || !e.challenge) return "done";
|
|
1341
|
-
const t = this.#N(e),
|
|
1346
|
+
const t = this.#N(e), r = e.registrationDeadlineMs - this.#n(), n = r > 0 ? Math.min(4e3, r) : 1e3, s = this.#v(() => t.abort(), Math.max(1, n));
|
|
1342
1347
|
let o = null;
|
|
1343
1348
|
try {
|
|
1344
|
-
const
|
|
1349
|
+
const a = this.#e.fetch(
|
|
1345
1350
|
`${P}/relay/v1/transactions/${e.transactionId}/cancel`,
|
|
1346
|
-
|
|
1351
|
+
U({
|
|
1347
1352
|
codeVerifier: e.verifier,
|
|
1348
1353
|
schemaVersion: 1,
|
|
1349
1354
|
state: e.state,
|
|
@@ -1351,7 +1356,7 @@ class _t {
|
|
|
1351
1356
|
}, t.signal)
|
|
1352
1357
|
);
|
|
1353
1358
|
o = await B(
|
|
1354
|
-
|
|
1359
|
+
a,
|
|
1355
1360
|
t.signal,
|
|
1356
1361
|
k
|
|
1357
1362
|
);
|
|
@@ -1373,7 +1378,7 @@ class _t {
|
|
|
1373
1378
|
t = this.#e.fetch(
|
|
1374
1379
|
`${P}/relay/v1/transactions/${e.transactionId}/cancel`,
|
|
1375
1380
|
{
|
|
1376
|
-
|
|
1381
|
+
...U({
|
|
1377
1382
|
codeVerifier: e.verifier,
|
|
1378
1383
|
schemaVersion: 1,
|
|
1379
1384
|
state: e.state,
|
|
@@ -1393,7 +1398,7 @@ class _t {
|
|
|
1393
1398
|
e.cleanupFinished = !0, this.#d(e.retryTimer), e.retryResolve?.(), e.retryResolve = null, e.retryTimer = null, this.#d(e.operationTimer), e.operationTimer = null, this.#L(e);
|
|
1394
1399
|
for (const t of e.controllers)
|
|
1395
1400
|
t.abort(), this.#A.delete(t);
|
|
1396
|
-
e.controllers.clear(), this.#
|
|
1401
|
+
e.controllers.clear(), this.#y.delete(e), e.adapter = null, e.challenge = null, e.priorConnection = null, e.request = null, e.state = null, e.transactionExpiresAtMs = null, e.transactionId = null, e.verifier = null, e.cleanup.resolve();
|
|
1397
1402
|
}
|
|
1398
1403
|
}
|
|
1399
1404
|
#Q() {
|
|
@@ -1423,29 +1428,29 @@ class _t {
|
|
|
1423
1428
|
const t = (s) => {
|
|
1424
1429
|
const o = this.#o;
|
|
1425
1430
|
if (!o || !this.#c(o)) return;
|
|
1426
|
-
const
|
|
1427
|
-
s?.key ===
|
|
1431
|
+
const a = `${Y}${o.state}`;
|
|
1432
|
+
s?.key === a && this.#P(o, !0);
|
|
1428
1433
|
};
|
|
1429
|
-
this.#
|
|
1430
|
-
let
|
|
1434
|
+
this.#_ = t;
|
|
1435
|
+
let r = !1, n = null;
|
|
1431
1436
|
try {
|
|
1432
|
-
const s = this.#
|
|
1437
|
+
const s = this.#m?.addEventListener, o = this.#m?.removeEventListener;
|
|
1433
1438
|
if (typeof s != "function" || typeof o != "function")
|
|
1434
1439
|
throw new TypeError("storage events unavailable");
|
|
1435
|
-
|
|
1440
|
+
n = () => Reflect.apply(
|
|
1436
1441
|
o,
|
|
1437
|
-
this.#
|
|
1442
|
+
this.#m,
|
|
1438
1443
|
["storage", t]
|
|
1439
|
-
), this.#b =
|
|
1444
|
+
), this.#b = n, Reflect.apply(s, this.#m, ["storage", this.#_]), r = !0;
|
|
1440
1445
|
} catch {
|
|
1441
1446
|
this.#l = !0;
|
|
1442
1447
|
}
|
|
1443
|
-
if (!
|
|
1448
|
+
if (!r || this.#i || this.#l) {
|
|
1444
1449
|
try {
|
|
1445
|
-
|
|
1450
|
+
n?.();
|
|
1446
1451
|
} catch {
|
|
1447
1452
|
}
|
|
1448
|
-
this.#
|
|
1453
|
+
this.#_ = null, this.#b = null, this.#u = null;
|
|
1449
1454
|
}
|
|
1450
1455
|
} finally {
|
|
1451
1456
|
this.#x = !1;
|
|
@@ -1462,68 +1467,68 @@ class _t {
|
|
|
1462
1467
|
return;
|
|
1463
1468
|
}
|
|
1464
1469
|
if (!Number.isSafeInteger(t) || t < 0) return;
|
|
1465
|
-
const
|
|
1466
|
-
for (let s = 0; s <
|
|
1470
|
+
const r = Math.min(t, At), n = [];
|
|
1471
|
+
for (let s = 0; s < r && !this.#i && !this.#l; s += 1) {
|
|
1467
1472
|
let o;
|
|
1468
1473
|
try {
|
|
1469
1474
|
o = e.key(s);
|
|
1470
1475
|
} catch {
|
|
1471
1476
|
continue;
|
|
1472
1477
|
}
|
|
1473
|
-
|
|
1478
|
+
n.push(o);
|
|
1474
1479
|
}
|
|
1475
|
-
for (const s of
|
|
1480
|
+
for (const s of n) {
|
|
1476
1481
|
if (this.#i || this.#l) return;
|
|
1477
1482
|
if (typeof s != "string" || !s.startsWith(Y)) continue;
|
|
1478
1483
|
const o = s.slice(Y.length);
|
|
1479
1484
|
if (D.test(o))
|
|
1480
1485
|
try {
|
|
1481
|
-
const
|
|
1482
|
-
if (
|
|
1486
|
+
const a = e.getItem(s);
|
|
1487
|
+
if (a === null) continue;
|
|
1483
1488
|
const u = F(
|
|
1484
|
-
|
|
1489
|
+
$(a, 2048),
|
|
1485
1490
|
["code", "expiresAt", "schemaVersion", "state"],
|
|
1486
1491
|
"CALLBACK_ERROR"
|
|
1487
1492
|
);
|
|
1488
1493
|
if (u.schemaVersion !== 1 || u.state !== o || !D.test(u.code))
|
|
1489
1494
|
continue;
|
|
1490
|
-
q(u.expiresAt, "CALLBACK_ERROR") <= this.#
|
|
1495
|
+
q(u.expiresAt, "CALLBACK_ERROR") <= this.#n() && e.removeItem(s);
|
|
1491
1496
|
} catch {
|
|
1492
1497
|
}
|
|
1493
1498
|
}
|
|
1494
1499
|
}
|
|
1495
1500
|
}
|
|
1496
1501
|
function Lt(i) {
|
|
1497
|
-
return new
|
|
1502
|
+
return new gt(i);
|
|
1498
1503
|
}
|
|
1499
1504
|
function xt(i, e = {}) {
|
|
1500
|
-
const t = (
|
|
1501
|
-
connect(...
|
|
1502
|
-
return t(
|
|
1505
|
+
const t = (n, s) => n !== 0 ? Promise.reject(l("INVALID_REQUEST")) : s(), r = {
|
|
1506
|
+
connect(...n) {
|
|
1507
|
+
return t(n.length, () => i.execute("connect", void 0));
|
|
1503
1508
|
},
|
|
1504
|
-
destroy(...
|
|
1505
|
-
return t(
|
|
1509
|
+
destroy(...n) {
|
|
1510
|
+
return t(n.length, () => i.destroy());
|
|
1506
1511
|
},
|
|
1507
|
-
disconnect(...
|
|
1508
|
-
return t(
|
|
1512
|
+
disconnect(...n) {
|
|
1513
|
+
return t(n.length, () => i.disconnect());
|
|
1509
1514
|
},
|
|
1510
|
-
getSnapshot(...
|
|
1511
|
-
if (
|
|
1515
|
+
getSnapshot(...n) {
|
|
1516
|
+
if (n.length !== 0) throw l("INVALID_REQUEST");
|
|
1512
1517
|
return i.getSnapshot();
|
|
1513
1518
|
},
|
|
1514
|
-
openAccount(...
|
|
1515
|
-
return t(
|
|
1519
|
+
openAccount(...n) {
|
|
1520
|
+
return t(n.length, () => i.execute("account", void 0));
|
|
1516
1521
|
},
|
|
1517
|
-
subscribe(
|
|
1518
|
-
if (s.length !== 0) throw
|
|
1519
|
-
return i.subscribe(
|
|
1522
|
+
subscribe(n, ...s) {
|
|
1523
|
+
if (s.length !== 0) throw l("INVALID_REQUEST");
|
|
1524
|
+
return i.subscribe(n);
|
|
1520
1525
|
}
|
|
1521
1526
|
};
|
|
1522
|
-
for (const [
|
|
1523
|
-
n
|
|
1524
|
-
return u.length !== 0 ? Promise.reject(
|
|
1527
|
+
for (const [n, s] of Object.entries(e))
|
|
1528
|
+
r[n] = function(a, ...u) {
|
|
1529
|
+
return u.length !== 0 ? Promise.reject(l("INVALID_REQUEST")) : i.execute(s, a);
|
|
1525
1530
|
};
|
|
1526
|
-
return Object.freeze(
|
|
1531
|
+
return Object.freeze(r);
|
|
1527
1532
|
}
|
|
1528
1533
|
const Tt = Object.freeze({
|
|
1529
1534
|
account: Object.freeze({
|
|
@@ -1533,7 +1538,7 @@ const Tt = Object.freeze({
|
|
|
1533
1538
|
parseResult: ct
|
|
1534
1539
|
}),
|
|
1535
1540
|
connect: Object.freeze({
|
|
1536
|
-
buildRequest: () =>
|
|
1541
|
+
buildRequest: () => nt({}),
|
|
1537
1542
|
kind: "connect",
|
|
1538
1543
|
operation: "sdn.wallet.connect.v1",
|
|
1539
1544
|
parseResult: st
|
|
@@ -1554,7 +1559,7 @@ const Tt = Object.freeze({
|
|
|
1554
1559
|
})
|
|
1555
1560
|
});
|
|
1556
1561
|
function Pt() {
|
|
1557
|
-
if (arguments.length !== 0) throw
|
|
1562
|
+
if (arguments.length !== 0) throw l("INVALID_REQUEST");
|
|
1558
1563
|
const i = Lt({
|
|
1559
1564
|
adapters: Ct,
|
|
1560
1565
|
clientId: "sdn-asset-review-v1"
|
|
@@ -1565,6 +1570,6 @@ function Pt() {
|
|
|
1565
1570
|
});
|
|
1566
1571
|
}
|
|
1567
1572
|
export {
|
|
1568
|
-
|
|
1573
|
+
ge as WALLET_CLIENT_ERRORS,
|
|
1569
1574
|
Pt as createAssetReviewWalletClient
|
|
1570
1575
|
};
|