hd-wallet-ui 2.0.21 → 2.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/README.md +101 -123
- package/data/common-passwords-sdn-v1.source.json +12 -0
- package/data/common-passwords-sdn-v1.txt +10000 -0
- package/dist/browser/sdn-wallet-callback.js +1 -0
- package/dist/browser/sdn-wallet-public-client.js +1 -0
- package/dist/browser/wallet-callback.html +6 -0
- package/dist/client/asset-review.d.ts +8 -0
- package/dist/client/asset-review.js +1570 -0
- package/dist/client/callback.d.ts +13 -0
- package/dist/client/callback.js +29 -0
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.js +1379 -0
- package/dist/client/sdn.d.ts +8 -0
- package/dist/client/sdn.js +1542 -0
- package/dist/client/style.css +32 -0
- package/dist/client/types.d.ts +278 -0
- package/dist/compat/index.d.ts +26 -0
- package/dist/compat/index.js +62 -0
- package/dist/wallet-origin/index.d.ts +21 -0
- package/dist/wallet-origin/index.js +4607 -0
- package/dist/wallet-origin-host/assets/wallet-origin.43cf84e0eba17742309357ec6bc2c544736e155ffd5d76d5024408e998500a57.wasm +0 -0
- package/dist/wallet-origin-host/assets/wallet-origin.4c9455f1a2618948e203f720485add9d8ebf77b5542b41f933594afcfbb34361.css +1 -0
- package/dist/wallet-origin-host/assets/wallet-origin.aedc355452e665e16c0f72a6597602873378dbc39d4cbf6104621c07579347e0.js +12463 -0
- package/dist/wallet-origin-host/index.html +10 -0
- package/dist/wallet-origin-host/integrity.json +1 -0
- package/package.json +46 -18
- package/src/address-derivation.js +0 -514
- package/src/app.js +0 -6008
- package/src/blockchain-trust.js +0 -752
- package/src/clipboard.js +0 -44
- package/src/constants.js +0 -66
- package/src/hash.js +0 -9
- package/src/lib.js +0 -66
- package/src/template.js +0 -626
- package/src/trust-ui.js +0 -745
- package/src/wallet-storage.js +0 -773
- package/styles/main.css +0 -6220
- package/styles/widget.css +0 -6212
|
@@ -0,0 +1,1570 @@
|
|
|
1
|
+
const Pe = Object.freeze({
|
|
2
|
+
cm: 0.01,
|
|
3
|
+
km: 1e3,
|
|
4
|
+
m: 1,
|
|
5
|
+
mm: 1e-3
|
|
6
|
+
}), Ne = Object.freeze({
|
|
7
|
+
metersPerSourceUnit: Pe,
|
|
8
|
+
quaternionNormTolerance: 1e-6,
|
|
9
|
+
scaleComponentExclusiveMin: 0,
|
|
10
|
+
scaleComponentInclusiveMax: 1e6,
|
|
11
|
+
translationComponentAbsMax: 1e6,
|
|
12
|
+
upAxes: Object.freeze(["X_UP", "Y_UP", "Z_UP"])
|
|
13
|
+
}), De = Object.freeze({ reviewedTransform: Ne, schemaVersion: 1 }), g = new TextEncoder(), ye = Object.getPrototypeOf(Uint8Array.prototype);
|
|
14
|
+
Object.getOwnPropertyDescriptor(ye, "buffer").get;
|
|
15
|
+
Object.getOwnPropertyDescriptor(ye, "length").get;
|
|
16
|
+
Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
|
|
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, $e = /^[1-9A-HJ-NP-Za-km-z]+$/u, Ue = /^b[a-z2-7]{58}$/u, X = "abcdefghijklmnopqrstuvwxyz234567", Ee = 131072, Fe = [
|
|
19
|
+
"accountFingerprint",
|
|
20
|
+
"accountIndex",
|
|
21
|
+
"accountLabel",
|
|
22
|
+
"accountPeerId",
|
|
23
|
+
"accountXpub",
|
|
24
|
+
"identityScheme",
|
|
25
|
+
"keys",
|
|
26
|
+
"schemaVersion",
|
|
27
|
+
"seedProfile"
|
|
28
|
+
], qe = [
|
|
29
|
+
"bip32Fingerprint",
|
|
30
|
+
"curve",
|
|
31
|
+
"derivation",
|
|
32
|
+
"encoding",
|
|
33
|
+
"identityScheme",
|
|
34
|
+
"keyId",
|
|
35
|
+
"path",
|
|
36
|
+
"publicKeyHex",
|
|
37
|
+
"purpose",
|
|
38
|
+
"seedProfile",
|
|
39
|
+
"signatureProfile"
|
|
40
|
+
], Be = [
|
|
41
|
+
"connectionExpiresAt",
|
|
42
|
+
"event",
|
|
43
|
+
"identity",
|
|
44
|
+
"schemaVersion"
|
|
45
|
+
], Je = [
|
|
46
|
+
"algorithm",
|
|
47
|
+
"canonicalEnvelope",
|
|
48
|
+
"encoding",
|
|
49
|
+
"identityScheme",
|
|
50
|
+
"keyId",
|
|
51
|
+
"schemaVersion",
|
|
52
|
+
"signatureHex",
|
|
53
|
+
"signatureProfile",
|
|
54
|
+
"signedDigestSha256"
|
|
55
|
+
], W = [
|
|
56
|
+
"audience",
|
|
57
|
+
"clientId",
|
|
58
|
+
"expiresAt",
|
|
59
|
+
"identityScheme",
|
|
60
|
+
"issuedAt",
|
|
61
|
+
"keyId",
|
|
62
|
+
"nonce",
|
|
63
|
+
"protocolVersion",
|
|
64
|
+
"publicKeyHex",
|
|
65
|
+
"purpose",
|
|
66
|
+
"requestOrigin",
|
|
67
|
+
"serviceInstance",
|
|
68
|
+
"signatureProfile"
|
|
69
|
+
], Q = [
|
|
70
|
+
"audience",
|
|
71
|
+
"candidateKey",
|
|
72
|
+
"challengeId",
|
|
73
|
+
"clientId",
|
|
74
|
+
"decision",
|
|
75
|
+
"expiresAt",
|
|
76
|
+
"issuedAt",
|
|
77
|
+
"metadataSha256",
|
|
78
|
+
"modelBytes",
|
|
79
|
+
"modelCid",
|
|
80
|
+
"modelSha256",
|
|
81
|
+
"nonce",
|
|
82
|
+
"previousDecisionHead",
|
|
83
|
+
"protocolVersion",
|
|
84
|
+
"requestOrigin"
|
|
85
|
+
], We = [
|
|
86
|
+
"metersPerSourceUnit",
|
|
87
|
+
"rotation",
|
|
88
|
+
"scale",
|
|
89
|
+
"sourceUnits",
|
|
90
|
+
"translation",
|
|
91
|
+
"upAxis"
|
|
92
|
+
];
|
|
93
|
+
function c(i) {
|
|
94
|
+
throw new TypeError(i);
|
|
95
|
+
}
|
|
96
|
+
function K(i) {
|
|
97
|
+
if (i === null || typeof i != "object" || Array.isArray(i)) return !1;
|
|
98
|
+
const e = Object.getPrototypeOf(i);
|
|
99
|
+
return e === Object.prototype || e === null;
|
|
100
|
+
}
|
|
101
|
+
function v(i, e) {
|
|
102
|
+
typeof i != "string" && c(`${e} must be a string`);
|
|
103
|
+
for (let t = 0; t < i.length; t += 1) {
|
|
104
|
+
const n = i.charCodeAt(t);
|
|
105
|
+
let r = n;
|
|
106
|
+
if (n >= 55296 && n <= 56319) {
|
|
107
|
+
const s = i.charCodeAt(t + 1);
|
|
108
|
+
s >= 56320 && s <= 57343 || c(`${e} contains an unpaired surrogate`), r = 65536 + (n - 55296 << 10) + (s - 56320), t += 1;
|
|
109
|
+
} else n >= 56320 && n <= 57343 && c(`${e} contains an unpaired surrogate`);
|
|
110
|
+
((r & 65535) === 65534 || (r & 65535) === 65535 || r >= 64976 && r <= 65007) && c(`${e} contains a Unicode noncharacter`);
|
|
111
|
+
}
|
|
112
|
+
return i;
|
|
113
|
+
}
|
|
114
|
+
function Ae(i) {
|
|
115
|
+
typeof i != "string" && c("wire JSON must be a string"), g.encode(i).byteLength > Ee && c("wire JSON is too large"), i.charCodeAt(0) === 65279 && c("wire JSON must not contain a BOM");
|
|
116
|
+
let e = 0, t = 0;
|
|
117
|
+
const n = () => {
|
|
118
|
+
for (; e < i.length && /[\u0009\u000a\u000d\u0020]/u.test(i[e]); ) e += 1;
|
|
119
|
+
}, r = () => {
|
|
120
|
+
i[e] !== '"' && c("invalid JSON string");
|
|
121
|
+
const l = e;
|
|
122
|
+
for (e += 1; e < i.length; ) {
|
|
123
|
+
const u = i.charCodeAt(e);
|
|
124
|
+
if (u === 34) {
|
|
125
|
+
e += 1;
|
|
126
|
+
let h;
|
|
127
|
+
try {
|
|
128
|
+
h = JSON.parse(i.slice(l, e));
|
|
129
|
+
} catch {
|
|
130
|
+
c("invalid JSON string");
|
|
131
|
+
}
|
|
132
|
+
return v(h, "JSON string");
|
|
133
|
+
}
|
|
134
|
+
u < 32 && c("invalid JSON control character"), u === 92 && (e += 1, e >= i.length && c("unterminated JSON escape")), e += 1;
|
|
135
|
+
}
|
|
136
|
+
c("unterminated JSON string");
|
|
137
|
+
}, s = (l = 0) => {
|
|
138
|
+
l > 32 && c("wire JSON nesting is too deep"), t += 1, t > 4096 && c("wire JSON contains too many values"), n();
|
|
139
|
+
const u = i[e];
|
|
140
|
+
if (u === '"') return r();
|
|
141
|
+
if (u === "{") {
|
|
142
|
+
e += 1;
|
|
143
|
+
const m = /* @__PURE__ */ Object.create(null), y = /* @__PURE__ */ new Set();
|
|
144
|
+
if (n(), i[e] === "}")
|
|
145
|
+
return e += 1, m;
|
|
146
|
+
for (; e < i.length; ) {
|
|
147
|
+
n();
|
|
148
|
+
const R = r();
|
|
149
|
+
if (y.has(R) && c(`duplicate JSON field: ${R}`), y.add(R), n(), i[e] !== ":" && c("missing JSON object colon"), e += 1, m[R] = s(l + 1), n(), i[e] === "}")
|
|
150
|
+
return e += 1, m;
|
|
151
|
+
i[e] !== "," && c("invalid JSON object separator"), e += 1;
|
|
152
|
+
}
|
|
153
|
+
c("unterminated JSON object");
|
|
154
|
+
}
|
|
155
|
+
if (u === "[") {
|
|
156
|
+
e += 1;
|
|
157
|
+
const m = [];
|
|
158
|
+
if (n(), i[e] === "]")
|
|
159
|
+
return e += 1, m;
|
|
160
|
+
for (; e < i.length; ) {
|
|
161
|
+
if (m.push(s(l + 1)), n(), i[e] === "]")
|
|
162
|
+
return e += 1, m;
|
|
163
|
+
i[e] !== "," && c("invalid JSON array separator"), e += 1;
|
|
164
|
+
}
|
|
165
|
+
c("unterminated JSON array");
|
|
166
|
+
}
|
|
167
|
+
for (const [m, y] of [["true", !0], ["false", !1], ["null", null]])
|
|
168
|
+
if (i.startsWith(m, e))
|
|
169
|
+
return e += m.length, y;
|
|
170
|
+
const h = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/u.exec(i.slice(e));
|
|
171
|
+
h || c("invalid JSON value"), e += h[0].length;
|
|
172
|
+
const d = Number(h[0]);
|
|
173
|
+
return Number.isFinite(d) || c("wire JSON number must be finite"), d;
|
|
174
|
+
};
|
|
175
|
+
n();
|
|
176
|
+
const o = s();
|
|
177
|
+
return n(), e !== i.length && c("wire JSON contains trailing bytes"), o;
|
|
178
|
+
}
|
|
179
|
+
function be(i) {
|
|
180
|
+
return typeof i == "string" ? Ae(i) : i;
|
|
181
|
+
}
|
|
182
|
+
function Ke(i, e) {
|
|
183
|
+
if (i.byteLength !== e.byteLength) return !1;
|
|
184
|
+
let t = 0;
|
|
185
|
+
for (let n = 0; n < i.byteLength; n += 1) t |= i[n] ^ e[n];
|
|
186
|
+
return t === 0;
|
|
187
|
+
}
|
|
188
|
+
function E(i, e, t) {
|
|
189
|
+
const n = be(i);
|
|
190
|
+
K(n) || c(`${t} must be a JSON object`), Object.getOwnPropertySymbols(n).length !== 0 && c(`${t} has an unknown symbol field`);
|
|
191
|
+
const r = Object.getOwnPropertyNames(n).sort(), s = [...e].sort(), o = g.encode(r.join("\0")), l = g.encode(s.join("\0"));
|
|
192
|
+
Ke(o, l) || c(`${t} has missing or unknown fields`);
|
|
193
|
+
for (const u of r) {
|
|
194
|
+
const h = Object.getOwnPropertyDescriptor(n, u);
|
|
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
|
+
}
|
|
197
|
+
return n;
|
|
198
|
+
}
|
|
199
|
+
function V(i) {
|
|
200
|
+
if (!i || typeof i != "object" || Object.isFrozen(i)) return i;
|
|
201
|
+
for (const e of Object.values(i)) V(e);
|
|
202
|
+
return Object.freeze(i);
|
|
203
|
+
}
|
|
204
|
+
function S(i) {
|
|
205
|
+
return V(Object.fromEntries([...i].sort(([e], [t]) => e < t ? -1 : e > t ? 1 : 0)));
|
|
206
|
+
}
|
|
207
|
+
function G(i, e, t) {
|
|
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 n = [...Array.from({ length: e }, (s, o) => String(o)), "length"], r = Reflect.ownKeys(i);
|
|
210
|
+
(r.length !== n.length || r.some((s, o) => s !== n[o])) && c(`${t} must be a dense plain array`);
|
|
211
|
+
for (let s = 0; s < e; s += 1) {
|
|
212
|
+
const o = Object.getOwnPropertyDescriptor(i, String(s));
|
|
213
|
+
(!o || !o.enumerable || !("value" in o) || o.value === void 0) && c(`${t} must contain enumerable data values`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function ze(i) {
|
|
217
|
+
const e = E(
|
|
218
|
+
i,
|
|
219
|
+
["reviewedTransform", "schemaVersion"],
|
|
220
|
+
"asset review protocol policy"
|
|
221
|
+
);
|
|
222
|
+
f(e.schemaVersion, 1, "asset review protocol schemaVersion");
|
|
223
|
+
const t = E(e.reviewedTransform, [
|
|
224
|
+
"metersPerSourceUnit",
|
|
225
|
+
"quaternionNormTolerance",
|
|
226
|
+
"scaleComponentExclusiveMin",
|
|
227
|
+
"scaleComponentInclusiveMax",
|
|
228
|
+
"translationComponentAbsMax",
|
|
229
|
+
"upAxes"
|
|
230
|
+
], "asset review transform policy"), n = E(
|
|
231
|
+
t.metersPerSourceUnit,
|
|
232
|
+
["cm", "km", "m", "mm"],
|
|
233
|
+
"asset review unit policy"
|
|
234
|
+
);
|
|
235
|
+
for (const [r, s] of Object.entries(n))
|
|
236
|
+
(typeof s != "number" || !Number.isFinite(s) || s <= 0) && c(`asset review unit policy ${r} must be positive and finite`);
|
|
237
|
+
for (const [r, s] of [
|
|
238
|
+
["quaternionNormTolerance", t.quaternionNormTolerance],
|
|
239
|
+
["scaleComponentExclusiveMin", t.scaleComponentExclusiveMin],
|
|
240
|
+
["scaleComponentInclusiveMax", t.scaleComponentInclusiveMax],
|
|
241
|
+
["translationComponentAbsMax", t.translationComponentAbsMax]
|
|
242
|
+
])
|
|
243
|
+
(typeof s != "number" || !Number.isFinite(s)) && c(`asset review transform policy ${r} must be finite`);
|
|
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(n))],
|
|
246
|
+
["quaternionNormTolerance", t.quaternionNormTolerance],
|
|
247
|
+
["scaleComponentExclusiveMin", t.scaleComponentExclusiveMin],
|
|
248
|
+
["scaleComponentInclusiveMax", t.scaleComponentInclusiveMax],
|
|
249
|
+
["translationComponentAbsMax", t.translationComponentAbsMax],
|
|
250
|
+
["upAxes", Object.freeze(Array.from({ length: 3 }, (r, s) => t.upAxes[s]))]
|
|
251
|
+
]);
|
|
252
|
+
}
|
|
253
|
+
const L = ze(De);
|
|
254
|
+
function f(i, e, t) {
|
|
255
|
+
return i !== e && c(`${t} must equal ${JSON.stringify(e)}`), i;
|
|
256
|
+
}
|
|
257
|
+
function ve(i, e, t) {
|
|
258
|
+
return e.includes(i) || c(`${t} is not an allowed value`), i;
|
|
259
|
+
}
|
|
260
|
+
function p(i, e, t) {
|
|
261
|
+
return v(i, t), e.test(i) || c(`${t} has an invalid encoding`), i;
|
|
262
|
+
}
|
|
263
|
+
function T(i, e) {
|
|
264
|
+
return v(i, e), (!Ve.test(i) || new Date(i).toISOString() !== i) && c(`${e} must be exact RFC3339 milliseconds UTC`), i;
|
|
265
|
+
}
|
|
266
|
+
function ee(i, e) {
|
|
267
|
+
const t = Date.parse(i), n = Date.parse(e);
|
|
268
|
+
n > t && n - t <= 3e5 || c("request lifetime must be in (0, 300] seconds");
|
|
269
|
+
}
|
|
270
|
+
function He(i) {
|
|
271
|
+
let e = 0, t = 0, n = "";
|
|
272
|
+
for (const r of i)
|
|
273
|
+
for (e = e << 8 | r, t += 8; t >= 5; )
|
|
274
|
+
t -= 5, n += X[e >>> t & 31], e &= (1 << t) - 1;
|
|
275
|
+
return t !== 0 && (n += X[e << 5 - t & 31]), n;
|
|
276
|
+
}
|
|
277
|
+
function Xe(i, e) {
|
|
278
|
+
v(i, "modelCid"), Ue.test(i) || c("modelCid must be canonical CIDv1 raw sha2-256 base32");
|
|
279
|
+
let t = 0, n = 0;
|
|
280
|
+
const r = [];
|
|
281
|
+
for (const l of i.slice(1)) {
|
|
282
|
+
const u = X.indexOf(l);
|
|
283
|
+
u < 0 && c("modelCid contains invalid base32"), t = t << 5 | u, n += 5, n >= 8 && (n -= 8, r.push(t >>> n & 255), t &= (1 << n) - 1);
|
|
284
|
+
}
|
|
285
|
+
(n !== 0 && t !== 0 || r.length !== 36) && c("modelCid has noncanonical base32 tail bits or length");
|
|
286
|
+
const s = Uint8Array.from(r);
|
|
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
|
+
let o = 0;
|
|
289
|
+
for (let l = 0; l < 32; l += 1) {
|
|
290
|
+
const u = Number.parseInt(e.slice(l * 2, l * 2 + 2), 16);
|
|
291
|
+
o |= s[l + 4] ^ u;
|
|
292
|
+
}
|
|
293
|
+
return o !== 0 && c("modelCid digest does not match modelSha256"), i;
|
|
294
|
+
}
|
|
295
|
+
function Z(i) {
|
|
296
|
+
return i === null || typeof i == "boolean" ? JSON.stringify(i) : typeof i == "string" ? (v(i, "canonical JSON string"), JSON.stringify(i)) : typeof i == "number" ? (Number.isFinite(i) || c("canonical JSON numbers must be finite"), JSON.stringify(i)) : Array.isArray(i) ? `[${i.map(Z).join(",")}]` : (K(i) || c("canonical JSON contains an unsupported value"), `{${Object.keys(i).sort().map((e) => `${JSON.stringify(e)}:${Z(i[e])}`).join(",")}}`);
|
|
297
|
+
}
|
|
298
|
+
function te(i, e) {
|
|
299
|
+
for (const t of ["identityScheme", "keyId", "signatureProfile"])
|
|
300
|
+
i[t] !== e[t] && c(`canonicalEnvelope ${t} must match the signature result`);
|
|
301
|
+
}
|
|
302
|
+
function Qe(i, e) {
|
|
303
|
+
const n = E(i, [
|
|
304
|
+
"audience",
|
|
305
|
+
"challengeSha256",
|
|
306
|
+
"clientId",
|
|
307
|
+
"expiresAt",
|
|
308
|
+
"identityScheme",
|
|
309
|
+
"issuedAt",
|
|
310
|
+
"keyId",
|
|
311
|
+
"kind",
|
|
312
|
+
"nonce",
|
|
313
|
+
"protocolVersion",
|
|
314
|
+
"requestOrigin",
|
|
315
|
+
"signatureProfile"
|
|
316
|
+
], "SDN login canonicalEnvelope");
|
|
317
|
+
te(n, e), f(n.audience, Me, "SDN login envelope audience"), p(n.challengeSha256, b, "SDN login envelope challengeSha256"), f(n.clientId, "sdn-node-console-v1", "SDN login envelope clientId"), T(n.issuedAt, "SDN login envelope issuedAt"), T(n.expiresAt, "SDN login envelope expiresAt"), ee(n.issuedAt, n.expiresAt), f(n.identityScheme, w, "SDN login envelope identityScheme"), p(n.keyId, M, "SDN login envelope keyId"), f(n.kind, "sdn-login", "SDN login envelope kind"), p(n.nonce, b, "SDN login envelope nonce"), f(n.protocolVersion, 2, "SDN login envelope protocolVersion"), f(n.requestOrigin, "https://sdn.spaceaware.io", "SDN login envelope requestOrigin"), f(n.signatureProfile, x, "SDN login envelope signatureProfile");
|
|
318
|
+
}
|
|
319
|
+
function Ze(i, e) {
|
|
320
|
+
const t = E(
|
|
321
|
+
i,
|
|
322
|
+
[...W, "kind"],
|
|
323
|
+
"authority activation canonicalEnvelope"
|
|
324
|
+
);
|
|
325
|
+
te(t, e), f(t.kind, "asset-review-authority-activation", "activation envelope kind"), Se(Object.fromEntries(W.map((n) => [n, t[n]])));
|
|
326
|
+
}
|
|
327
|
+
function Ge(i, e) {
|
|
328
|
+
const t = i?.decision === "approve" ? ["note", "reviewedTransform"] : i?.decision === "disapprove" ? ["reason"] : [], n = [...Q, ...t], r = E(i, [
|
|
329
|
+
...n,
|
|
330
|
+
"identityScheme",
|
|
331
|
+
"keyId",
|
|
332
|
+
"kind",
|
|
333
|
+
"purpose",
|
|
334
|
+
"signatureProfile"
|
|
335
|
+
], "asset review decision canonicalEnvelope");
|
|
336
|
+
te(r, e), f(r.identityScheme, w, "decision envelope identityScheme"), p(r.keyId, M, "decision envelope keyId"), f(r.kind, "asset-review-attestation", "decision envelope kind"), f(r.purpose, "asset-review-approval", "decision envelope purpose"), f(r.signatureProfile, x, "decision envelope signatureProfile"), Ie(Object.fromEntries(n.map((s) => [s, r[s]])));
|
|
337
|
+
}
|
|
338
|
+
function et(i, e, t) {
|
|
339
|
+
v(i, "canonicalEnvelope"), g.encode(i).byteLength > Ee && c("canonicalEnvelope is too large");
|
|
340
|
+
const n = Ae(i);
|
|
341
|
+
return (!K(n) || n.kind !== e) && c("canonicalEnvelope kind does not match the operation"), Z(n) !== i && c("canonicalEnvelope must be exact JCS"), e === "sdn-login" ? Qe(n, t) : e === "asset-review-authority-activation" ? Ze(n, t) : e === "asset-review-attestation" ? Ge(n, t) : c("canonicalEnvelope operation is not registered"), i;
|
|
342
|
+
}
|
|
343
|
+
function tt(i, e) {
|
|
344
|
+
const t = E(i, qe, `identity key ${e.purpose}`);
|
|
345
|
+
return f(t.purpose, e.purpose, "key purpose"), f(t.identityScheme, w, "key identityScheme"), f(t.seedProfile, J, "key seedProfile"), f(t.signatureProfile, e.signatureProfile, "key signatureProfile"), f(t.curve, e.curve, "key curve"), f(t.derivation, "slip10", "key derivation"), f(t.path, e.path, "key path"), f(t.encoding, "raw", "key encoding"), p(t.publicKeyHex, b, "key publicKeyHex"), f(t.bip32Fingerprint, null, "key bip32Fingerprint"), p(t.keyId, M, "key keyId"), S([
|
|
346
|
+
["bip32Fingerprint", null],
|
|
347
|
+
["curve", t.curve],
|
|
348
|
+
["derivation", "slip10"],
|
|
349
|
+
["encoding", "raw"],
|
|
350
|
+
["identityScheme", w],
|
|
351
|
+
["keyId", t.keyId],
|
|
352
|
+
["path", t.path],
|
|
353
|
+
["publicKeyHex", t.publicKeyHex],
|
|
354
|
+
["purpose", t.purpose],
|
|
355
|
+
["seedProfile", J],
|
|
356
|
+
["signatureProfile", t.signatureProfile]
|
|
357
|
+
]);
|
|
358
|
+
}
|
|
359
|
+
function it(i) {
|
|
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 || !$e.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
|
+
const t = [
|
|
363
|
+
{
|
|
364
|
+
purpose: "asset-review-approval",
|
|
365
|
+
curve: "ed25519",
|
|
366
|
+
signatureProfile: x,
|
|
367
|
+
path: "m/44'/0'/0'/2'/0'"
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
purpose: "contact-encryption",
|
|
371
|
+
curve: "x25519",
|
|
372
|
+
signatureProfile: null,
|
|
373
|
+
path: "m/44'/0'/0'/1'/0'"
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
purpose: "sdn-authentication",
|
|
377
|
+
curve: "ed25519",
|
|
378
|
+
signatureProfile: x,
|
|
379
|
+
path: "m/44'/0'/0'/0'/0'"
|
|
380
|
+
}
|
|
381
|
+
], n = Array.from(
|
|
382
|
+
{ length: 3 },
|
|
383
|
+
(r, s) => tt(e.keys[s], t[s])
|
|
384
|
+
);
|
|
385
|
+
return S([
|
|
386
|
+
["accountFingerprint", e.accountFingerprint],
|
|
387
|
+
["accountIndex", 0],
|
|
388
|
+
["accountLabel", null],
|
|
389
|
+
["accountPeerId", e.accountPeerId],
|
|
390
|
+
["accountXpub", e.accountXpub],
|
|
391
|
+
["identityScheme", w],
|
|
392
|
+
["keys", V(n)],
|
|
393
|
+
["schemaVersion", 1],
|
|
394
|
+
["seedProfile", J]
|
|
395
|
+
]);
|
|
396
|
+
}
|
|
397
|
+
function Oe(i, e) {
|
|
398
|
+
const t = E(i, Be, `${e} result`);
|
|
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 n = null, r = null;
|
|
401
|
+
return t.event === "connected" ? (n = it(t.identity), r = T(t.connectionExpiresAt, "connectionExpiresAt")) : (t.identity !== null || t.connectionExpiresAt !== null) && c("disconnected result must clear identity and expiry"), S([
|
|
402
|
+
["connectionExpiresAt", r],
|
|
403
|
+
["event", t.event],
|
|
404
|
+
["identity", n],
|
|
405
|
+
["schemaVersion", 1]
|
|
406
|
+
]);
|
|
407
|
+
}
|
|
408
|
+
function we(i, e) {
|
|
409
|
+
const t = E(i, Je, "canonical signature");
|
|
410
|
+
return f(t.schemaVersion, 1, "signature schemaVersion"), p(t.keyId, M, "signature keyId"), f(t.identityScheme, w, "signature identityScheme"), f(t.algorithm, "ed25519", "signature algorithm"), f(t.encoding, "raw", "signature encoding"), f(t.signatureProfile, x, "signature profile"), et(t.canonicalEnvelope, e, t), p(t.signedDigestSha256, b, "signedDigestSha256"), p(t.signatureHex, Ye, "signatureHex"), S([
|
|
411
|
+
["algorithm", "ed25519"],
|
|
412
|
+
["canonicalEnvelope", t.canonicalEnvelope],
|
|
413
|
+
["encoding", "raw"],
|
|
414
|
+
["identityScheme", w],
|
|
415
|
+
["keyId", t.keyId],
|
|
416
|
+
["schemaVersion", 1],
|
|
417
|
+
["signatureHex", t.signatureHex],
|
|
418
|
+
["signatureProfile", x],
|
|
419
|
+
["signedDigestSha256", t.signedDigestSha256]
|
|
420
|
+
]);
|
|
421
|
+
}
|
|
422
|
+
function Se(i) {
|
|
423
|
+
const e = E(i, W, "authority activation request");
|
|
424
|
+
return f(e.protocolVersion, 1, "activation protocolVersion"), f(e.audience, je, "activation audience"), f(e.requestOrigin, pe, "activation requestOrigin"), f(e.clientId, Re, "activation clientId"), f(e.serviceInstance, "assets.ipfs.01/asset-review-attestation", "activation serviceInstance"), f(e.purpose, "asset-review-authority-activation", "activation purpose"), p(e.nonce, b, "activation nonce"), T(e.issuedAt, "activation issuedAt"), T(e.expiresAt, "activation expiresAt"), ee(e.issuedAt, e.expiresAt), p(e.publicKeyHex, b, "activation publicKeyHex"), p(e.keyId, M, "activation keyId"), f(e.identityScheme, w, "activation identityScheme"), f(e.signatureProfile, x, "activation signatureProfile"), S(W.map((t) => [t, e[t]]));
|
|
425
|
+
}
|
|
426
|
+
function z(i, e, t) {
|
|
427
|
+
G(i, e, `${t} array`);
|
|
428
|
+
const n = Array.from({ length: e }, (r, s) => {
|
|
429
|
+
const o = i[s];
|
|
430
|
+
return (typeof o != "number" || !Number.isFinite(o)) && c(`${t} values must be finite numbers`), o;
|
|
431
|
+
});
|
|
432
|
+
return V(n);
|
|
433
|
+
}
|
|
434
|
+
function nt(i) {
|
|
435
|
+
const e = E(i, We, "reviewedTransform"), t = z(e.translation, 3, "translation"), n = z(e.rotation, 4, "rotation"), r = z(e.scale, 3, "scale");
|
|
436
|
+
t.some((o) => Math.abs(o) > L.translationComponentAbsMax) && c("translation values exceed the reviewed transform policy"), r.some((o) => o <= L.scaleComponentExclusiveMin || o > L.scaleComponentInclusiveMax) && c("scale values exceed the reviewed transform policy");
|
|
437
|
+
const s = Math.hypot(...n);
|
|
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
|
+
["metersPerSourceUnit", e.metersPerSourceUnit],
|
|
440
|
+
["rotation", n],
|
|
441
|
+
["scale", r],
|
|
442
|
+
["sourceUnits", e.sourceUnits],
|
|
443
|
+
["translation", t],
|
|
444
|
+
["upAxis", e.upAxis]
|
|
445
|
+
]);
|
|
446
|
+
}
|
|
447
|
+
function se(i) {
|
|
448
|
+
return i >= 9 && i <= 13 || i === 32 || i === 160 || i === 5760 || i >= 8192 && i <= 8202 || i === 8232 || i === 8233 || i === 8239 || i === 8287 || i === 12288 || i === 65279;
|
|
449
|
+
}
|
|
450
|
+
function oe(i, e, t) {
|
|
451
|
+
if (t && i === null) return null;
|
|
452
|
+
v(i, e), (i.length === 0 || g.encode(i).byteLength > 2e3) && c(`${e} has an invalid length`);
|
|
453
|
+
const n = Array.from(i, (r) => r.codePointAt(0));
|
|
454
|
+
return (se(n[0]) || se(n[n.length - 1])) && c(`${e} must already be trimmed`), i;
|
|
455
|
+
}
|
|
456
|
+
function Ie(i) {
|
|
457
|
+
const e = be(i);
|
|
458
|
+
K(e) || c("asset review decision request must be a JSON object");
|
|
459
|
+
const t = Object.getOwnPropertyDescriptor(e, "decision");
|
|
460
|
+
(!t || !t.enumerable || !("value" in t) || t.value === void 0) && c("asset review decision request has an invalid decision field");
|
|
461
|
+
const n = t.value, r = n === "approve" ? ["note", "reviewedTransform"] : n === "disapprove" ? ["reason"] : [], s = E(e, [...Q, ...r], "asset review decision request");
|
|
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:", l = `:${s.modelSha256}`;
|
|
464
|
+
(!s.candidateKey.startsWith(o) || !s.candidateKey.endsWith(l) || g.encode(s.candidateKey).byteLength > 206) && c("candidateKey does not bind the model digest");
|
|
465
|
+
const u = s.candidateKey.slice(o.length, -l.length);
|
|
466
|
+
(!/^[a-z0-9-]+\/[a-z0-9][a-z0-9-]*$/u.test(u) || g.encode(u).byteLength > 128) && c("candidateKey entityId is invalid");
|
|
467
|
+
const h = Q.map((m) => [m, s[m]]);
|
|
468
|
+
return n === "approve" ? (h.push(["note", oe(s.note, "note", !0)]), h.push(["reviewedTransform", nt(s.reviewedTransform)])) : h.push(["reason", oe(s.reason, "reason", !1)]), Object.values(s).filter((m) => typeof m == "string").reduce((m, y) => m + g.encode(y).byteLength, 0) > 16384 && c("decision request strings exceed 16 KiB"), S(h);
|
|
469
|
+
}
|
|
470
|
+
function ge(i, e) {
|
|
471
|
+
return E(i, [], e), V({});
|
|
472
|
+
}
|
|
473
|
+
function rt(i = {}) {
|
|
474
|
+
return ge(i, "wallet connect request");
|
|
475
|
+
}
|
|
476
|
+
function st(i) {
|
|
477
|
+
return Oe(i, "connect");
|
|
478
|
+
}
|
|
479
|
+
function ot(i = {}) {
|
|
480
|
+
return ge(i, "wallet account request");
|
|
481
|
+
}
|
|
482
|
+
function ct(i) {
|
|
483
|
+
return Oe(i, "account");
|
|
484
|
+
}
|
|
485
|
+
function at(i) {
|
|
486
|
+
return Se(i);
|
|
487
|
+
}
|
|
488
|
+
function lt(i) {
|
|
489
|
+
return we(i, "asset-review-authority-activation");
|
|
490
|
+
}
|
|
491
|
+
function ut(i) {
|
|
492
|
+
return Ie(i);
|
|
493
|
+
}
|
|
494
|
+
function ht(i) {
|
|
495
|
+
return we(i, "asset-review-attestation");
|
|
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, mt = 3e4, yt = 3e5, pt = 9e5, Rt = 12e4, Et = 8, ae = 4096, le = 70 * 1024, At = 64, _e = Object.freeze({
|
|
498
|
+
CALLBACK_ERROR: "The wallet return could not be verified. Try again.",
|
|
499
|
+
CRYPTO_UNAVAILABLE: "Secure browser cryptography is unavailable.",
|
|
500
|
+
DESTROYED: "This wallet client has been destroyed.",
|
|
501
|
+
DISCONNECTED: "The wallet was disconnected.",
|
|
502
|
+
EXPIRED: "The wallet connection expired.",
|
|
503
|
+
INVALID_CLIENT: "This wallet client is not registered.",
|
|
504
|
+
INVALID_REQUEST: "The wallet request is invalid.",
|
|
505
|
+
RELAY_ERROR: "The wallet service could not complete the request. Try again.",
|
|
506
|
+
REPLACED: "A newer wallet request replaced this one.",
|
|
507
|
+
WALLET_NOT_COMPLETED: "The wallet did not complete. Check popup settings and try again."
|
|
508
|
+
}), Le = new TextEncoder(), bt = new TextDecoder("utf-8", { fatal: !0 });
|
|
509
|
+
class j extends Error {
|
|
510
|
+
constructor(e) {
|
|
511
|
+
super(_e[e]), this.name = "WalletClientError", Object.defineProperty(this, "code", {
|
|
512
|
+
configurable: !1,
|
|
513
|
+
enumerable: !0,
|
|
514
|
+
value: e,
|
|
515
|
+
writable: !1
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function a(i) {
|
|
520
|
+
return Object.hasOwn(_e, i) ? new j(i) : new j("RELAY_ERROR");
|
|
521
|
+
}
|
|
522
|
+
function vt(i) {
|
|
523
|
+
if (i === null || typeof i != "object" || Array.isArray(i)) return !1;
|
|
524
|
+
const e = Object.getPrototypeOf(i);
|
|
525
|
+
return e === Object.prototype || e === null;
|
|
526
|
+
}
|
|
527
|
+
function U(i, e) {
|
|
528
|
+
if (typeof i != "string" || i.length > e || Le.encode(i).byteLength > e || i.charCodeAt(0) === 65279)
|
|
529
|
+
throw a("RELAY_ERROR");
|
|
530
|
+
let t = 0, n = 0;
|
|
531
|
+
const r = () => {
|
|
532
|
+
for (; t < i.length && /[\u0009\u000a\u000d\u0020]/u.test(i[t]); ) t += 1;
|
|
533
|
+
}, s = () => {
|
|
534
|
+
if (i[t] !== '"') throw a("RELAY_ERROR");
|
|
535
|
+
const u = t;
|
|
536
|
+
for (t += 1; t < i.length; ) {
|
|
537
|
+
const h = i.charCodeAt(t);
|
|
538
|
+
if (h === 34) {
|
|
539
|
+
t += 1;
|
|
540
|
+
let d;
|
|
541
|
+
try {
|
|
542
|
+
d = JSON.parse(i.slice(u, t));
|
|
543
|
+
} catch {
|
|
544
|
+
throw a("RELAY_ERROR");
|
|
545
|
+
}
|
|
546
|
+
for (let m = 0; m < d.length; m += 1) {
|
|
547
|
+
const y = d.charCodeAt(m);
|
|
548
|
+
if (y >= 55296 && y <= 56319) {
|
|
549
|
+
const R = d.charCodeAt(m + 1);
|
|
550
|
+
if (!(R >= 56320 && R <= 57343)) throw a("RELAY_ERROR");
|
|
551
|
+
m += 1;
|
|
552
|
+
} else if (y >= 56320 && y <= 57343)
|
|
553
|
+
throw a("RELAY_ERROR");
|
|
554
|
+
}
|
|
555
|
+
return d;
|
|
556
|
+
}
|
|
557
|
+
if (h < 32 || h === 92 && (t += 1, t >= i.length))
|
|
558
|
+
throw a("RELAY_ERROR");
|
|
559
|
+
t += 1;
|
|
560
|
+
}
|
|
561
|
+
throw a("RELAY_ERROR");
|
|
562
|
+
}, o = (u = 0) => {
|
|
563
|
+
if (u > 32 || ++n > 4096) throw a("RELAY_ERROR");
|
|
564
|
+
r();
|
|
565
|
+
const h = i[t];
|
|
566
|
+
if (h === '"') return s();
|
|
567
|
+
if (h === "{") {
|
|
568
|
+
t += 1;
|
|
569
|
+
const y = /* @__PURE__ */ Object.create(null), R = /* @__PURE__ */ new Set();
|
|
570
|
+
if (r(), i[t] === "}")
|
|
571
|
+
return t += 1, y;
|
|
572
|
+
for (; t < i.length; ) {
|
|
573
|
+
r();
|
|
574
|
+
const I = s();
|
|
575
|
+
if (R.has(I) || (R.add(I), r(), i[t] !== ":")) throw a("RELAY_ERROR");
|
|
576
|
+
if (t += 1, y[I] = o(u + 1), r(), i[t] === "}")
|
|
577
|
+
return t += 1, y;
|
|
578
|
+
if (i[t] !== ",") throw a("RELAY_ERROR");
|
|
579
|
+
t += 1;
|
|
580
|
+
}
|
|
581
|
+
throw a("RELAY_ERROR");
|
|
582
|
+
}
|
|
583
|
+
if (h === "[") {
|
|
584
|
+
t += 1;
|
|
585
|
+
const y = [];
|
|
586
|
+
if (r(), i[t] === "]")
|
|
587
|
+
return t += 1, y;
|
|
588
|
+
for (; t < i.length; ) {
|
|
589
|
+
if (y.push(o(u + 1)), r(), i[t] === "]")
|
|
590
|
+
return t += 1, y;
|
|
591
|
+
if (i[t] !== ",") throw a("RELAY_ERROR");
|
|
592
|
+
t += 1;
|
|
593
|
+
}
|
|
594
|
+
throw a("RELAY_ERROR");
|
|
595
|
+
}
|
|
596
|
+
for (const [y, R] of [["true", !0], ["false", !1], ["null", null]])
|
|
597
|
+
if (i.startsWith(y, t))
|
|
598
|
+
return t += y.length, R;
|
|
599
|
+
const d = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/u.exec(i.slice(t));
|
|
600
|
+
if (!d) throw a("RELAY_ERROR");
|
|
601
|
+
t += d[0].length;
|
|
602
|
+
const m = Number(d[0]);
|
|
603
|
+
if (!Number.isFinite(m)) throw a("RELAY_ERROR");
|
|
604
|
+
return m;
|
|
605
|
+
};
|
|
606
|
+
r();
|
|
607
|
+
const l = o();
|
|
608
|
+
if (r(), t !== i.length) throw a("RELAY_ERROR");
|
|
609
|
+
return l;
|
|
610
|
+
}
|
|
611
|
+
function F(i, e, t = "RELAY_ERROR") {
|
|
612
|
+
if (!vt(i) || Object.getOwnPropertySymbols(i).length !== 0)
|
|
613
|
+
throw a(t);
|
|
614
|
+
const n = Object.getOwnPropertyNames(i).sort(), r = [...e].sort();
|
|
615
|
+
if (n.length !== r.length || n.some((s, o) => s !== r[o]))
|
|
616
|
+
throw a(t);
|
|
617
|
+
for (const s of n) {
|
|
618
|
+
const o = Object.getOwnPropertyDescriptor(i, s);
|
|
619
|
+
if (!o?.enumerable || !("value" in o) || o.value === void 0)
|
|
620
|
+
throw a(t);
|
|
621
|
+
}
|
|
622
|
+
return i;
|
|
623
|
+
}
|
|
624
|
+
function q(i, e = "RELAY_ERROR") {
|
|
625
|
+
if (typeof i != "string" || !ft.test(i))
|
|
626
|
+
throw a(e);
|
|
627
|
+
const t = Date.parse(i);
|
|
628
|
+
if (!Number.isFinite(t) || new Date(t).toISOString() !== i)
|
|
629
|
+
throw a(e);
|
|
630
|
+
return t;
|
|
631
|
+
}
|
|
632
|
+
function _(i) {
|
|
633
|
+
return Array.isArray(i) ? Object.freeze(i.map(_)) : i && typeof i == "object" ? Object.freeze(Object.fromEntries(
|
|
634
|
+
Object.entries(i).map(([e, t]) => [e, _(t)])
|
|
635
|
+
)) : i;
|
|
636
|
+
}
|
|
637
|
+
function ue(i) {
|
|
638
|
+
const e = {
|
|
639
|
+
identity: i.identity === null ? null : _(i.identity),
|
|
640
|
+
status: i.status
|
|
641
|
+
};
|
|
642
|
+
return i.connectionExpiresAt !== void 0 && (e.connectionExpiresAt = i.connectionExpiresAt), i.error !== void 0 && (e.error = _(i.error)), _(e);
|
|
643
|
+
}
|
|
644
|
+
function N(i) {
|
|
645
|
+
return Object.freeze({ code: i.code, message: i.message });
|
|
646
|
+
}
|
|
647
|
+
function he(i) {
|
|
648
|
+
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
649
|
+
let t = 0, n = 0, r = "";
|
|
650
|
+
for (const s of i)
|
|
651
|
+
for (t = t << 8 | s, n += 8; n >= 6; )
|
|
652
|
+
n -= 6, r += e[t >>> n & 63], t &= (1 << n) - 1;
|
|
653
|
+
return n !== 0 && (r += e[t << 6 - n & 63]), r;
|
|
654
|
+
}
|
|
655
|
+
function fe(i) {
|
|
656
|
+
let e = "";
|
|
657
|
+
for (const t of i) e += t.toString(16).padStart(2, "0");
|
|
658
|
+
return e;
|
|
659
|
+
}
|
|
660
|
+
function H(i, e) {
|
|
661
|
+
const t = new Uint8Array(32);
|
|
662
|
+
return Reflect.apply(e, i, [t]), t;
|
|
663
|
+
}
|
|
664
|
+
function Ot(i) {
|
|
665
|
+
const e = i?.headers?.get?.("content-type");
|
|
666
|
+
return typeof e == "string" && /^application\/json(?:\s*;\s*charset=utf-8)?$/iu.test(e.trim());
|
|
667
|
+
}
|
|
668
|
+
function ie(i) {
|
|
669
|
+
try {
|
|
670
|
+
Promise.resolve(i).catch(() => {
|
|
671
|
+
});
|
|
672
|
+
} catch {
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
function k(i) {
|
|
676
|
+
try {
|
|
677
|
+
const e = i?.body, t = e?.cancel;
|
|
678
|
+
typeof t == "function" && ie(Reflect.apply(t, e, []));
|
|
679
|
+
} catch {
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
function xe(i) {
|
|
683
|
+
try {
|
|
684
|
+
const e = i?.cancel;
|
|
685
|
+
typeof e == "function" && ie(Reflect.apply(e, i, []));
|
|
686
|
+
} catch {
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
function wt(i) {
|
|
690
|
+
try {
|
|
691
|
+
const e = i?.releaseLock;
|
|
692
|
+
typeof e == "function" && Reflect.apply(e, i, []);
|
|
693
|
+
} catch {
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
function C(i, e, t = null) {
|
|
697
|
+
try {
|
|
698
|
+
i.abort();
|
|
699
|
+
} catch {
|
|
700
|
+
}
|
|
701
|
+
t && xe(t), k(e);
|
|
702
|
+
}
|
|
703
|
+
function B(i, e, t = null) {
|
|
704
|
+
let n;
|
|
705
|
+
try {
|
|
706
|
+
n = Promise.resolve(i);
|
|
707
|
+
} catch (r) {
|
|
708
|
+
return Promise.reject(r);
|
|
709
|
+
}
|
|
710
|
+
return new Promise((r, s) => {
|
|
711
|
+
let o = !1;
|
|
712
|
+
const l = () => {
|
|
713
|
+
try {
|
|
714
|
+
e.removeEventListener("abort", h);
|
|
715
|
+
} catch {
|
|
716
|
+
}
|
|
717
|
+
}, u = (d, m) => o ? !1 : (o = !0, l(), d(m), !0), h = () => {
|
|
718
|
+
u(s, a("RELAY_ERROR"));
|
|
719
|
+
};
|
|
720
|
+
try {
|
|
721
|
+
e.addEventListener("abort", h, { once: !0 }), e.aborted && h();
|
|
722
|
+
} catch {
|
|
723
|
+
h();
|
|
724
|
+
}
|
|
725
|
+
n.then(
|
|
726
|
+
(d) => {
|
|
727
|
+
if (o) {
|
|
728
|
+
try {
|
|
729
|
+
t?.(d);
|
|
730
|
+
} catch {
|
|
731
|
+
}
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
u(r, d);
|
|
735
|
+
},
|
|
736
|
+
(d) => {
|
|
737
|
+
o || u(s, d);
|
|
738
|
+
}
|
|
739
|
+
);
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
async function de(i, e, t) {
|
|
743
|
+
let n = null;
|
|
744
|
+
const r = [];
|
|
745
|
+
let s = 0;
|
|
746
|
+
try {
|
|
747
|
+
if (!Ot(i) || typeof i?.body?.getReader != "function")
|
|
748
|
+
throw a("RELAY_ERROR");
|
|
749
|
+
for (n = i.body.getReader(); ; ) {
|
|
750
|
+
const u = n.read(), { done: h, value: d } = await B(u, t.signal);
|
|
751
|
+
if (h) break;
|
|
752
|
+
if (!(d instanceof Uint8Array) || (s += d.byteLength, s > e))
|
|
753
|
+
throw a("RELAY_ERROR");
|
|
754
|
+
r.push(d);
|
|
755
|
+
}
|
|
756
|
+
const o = new Uint8Array(s);
|
|
757
|
+
let l = 0;
|
|
758
|
+
for (const u of r)
|
|
759
|
+
o.set(u, l), l += u.byteLength;
|
|
760
|
+
return bt.decode(o);
|
|
761
|
+
} catch {
|
|
762
|
+
try {
|
|
763
|
+
t.abort();
|
|
764
|
+
} catch {
|
|
765
|
+
}
|
|
766
|
+
throw n && xe(n), a("RELAY_ERROR");
|
|
767
|
+
} finally {
|
|
768
|
+
n && wt(n);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
function $(i, e) {
|
|
772
|
+
const t = {
|
|
773
|
+
body: JSON.stringify(i),
|
|
774
|
+
cache: "no-store",
|
|
775
|
+
credentials: "omit",
|
|
776
|
+
headers: { "Content-Type": "application/json" },
|
|
777
|
+
method: "POST",
|
|
778
|
+
mode: "cors",
|
|
779
|
+
redirect: "error",
|
|
780
|
+
referrerPolicy: "no-referrer"
|
|
781
|
+
};
|
|
782
|
+
return e !== void 0 && (t.signal = e), t;
|
|
783
|
+
}
|
|
784
|
+
function St(i, e, t) {
|
|
785
|
+
let n;
|
|
786
|
+
try {
|
|
787
|
+
n = U(i, 2048), F(n, ["code", "expiresAt", "schemaVersion", "state"], "CALLBACK_ERROR");
|
|
788
|
+
} catch {
|
|
789
|
+
throw a("CALLBACK_ERROR");
|
|
790
|
+
}
|
|
791
|
+
if (n.schemaVersion !== 1 || n.state !== e || !D.test(n.code))
|
|
792
|
+
throw a("CALLBACK_ERROR");
|
|
793
|
+
const r = q(n.expiresAt, "CALLBACK_ERROR");
|
|
794
|
+
if (r <= t || r - t > Rt)
|
|
795
|
+
throw a("CALLBACK_ERROR");
|
|
796
|
+
return { code: n.code, expiresAt: r, state: n.state };
|
|
797
|
+
}
|
|
798
|
+
function It() {
|
|
799
|
+
let i;
|
|
800
|
+
return { promise: new Promise((t) => {
|
|
801
|
+
i = t;
|
|
802
|
+
}), resolve: i };
|
|
803
|
+
}
|
|
804
|
+
function me() {
|
|
805
|
+
let i, e;
|
|
806
|
+
return { promise: new Promise((n, r) => {
|
|
807
|
+
i = r, e = n;
|
|
808
|
+
}), reject: i, resolve: e };
|
|
809
|
+
}
|
|
810
|
+
function gt() {
|
|
811
|
+
const i = globalThis.window;
|
|
812
|
+
return Object.freeze({
|
|
813
|
+
AbortController: globalThis.AbortController,
|
|
814
|
+
clearInterval: globalThis.clearInterval.bind(globalThis),
|
|
815
|
+
clearTimeout: globalThis.clearTimeout.bind(globalThis),
|
|
816
|
+
crypto: globalThis.crypto,
|
|
817
|
+
fetch: typeof globalThis.fetch == "function" ? globalThis.fetch.bind(globalThis) : void 0,
|
|
818
|
+
getStorage: () => {
|
|
819
|
+
try {
|
|
820
|
+
return i?.localStorage ?? null;
|
|
821
|
+
} catch {
|
|
822
|
+
return null;
|
|
823
|
+
}
|
|
824
|
+
},
|
|
825
|
+
now: () => Date.now(),
|
|
826
|
+
setInterval: globalThis.setInterval.bind(globalThis),
|
|
827
|
+
setTimeout: globalThis.setTimeout.bind(globalThis),
|
|
828
|
+
window: i
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
class _t {
|
|
832
|
+
#j;
|
|
833
|
+
#M;
|
|
834
|
+
#x = !1;
|
|
835
|
+
#l = !1;
|
|
836
|
+
#V = !1;
|
|
837
|
+
#s = null;
|
|
838
|
+
#O = null;
|
|
839
|
+
#A = /* @__PURE__ */ new Set();
|
|
840
|
+
#e;
|
|
841
|
+
#w = null;
|
|
842
|
+
#i = !1;
|
|
843
|
+
#p = 0;
|
|
844
|
+
#S = 0;
|
|
845
|
+
#I = /* @__PURE__ */ new Set();
|
|
846
|
+
#T = [];
|
|
847
|
+
#o = null;
|
|
848
|
+
#C = !1;
|
|
849
|
+
#m = /* @__PURE__ */ new Set();
|
|
850
|
+
#Y = Object.freeze({ identity: null, status: "dormant" });
|
|
851
|
+
#u = null;
|
|
852
|
+
#g = null;
|
|
853
|
+
#b = null;
|
|
854
|
+
#R = /* @__PURE__ */ new Set();
|
|
855
|
+
#y;
|
|
856
|
+
constructor({ adapters: e, clientId: t, dependencies: n }) {
|
|
857
|
+
this.#j = e, this.#M = t, this.#e = n ?? gt(), this.#y = this.#e.window;
|
|
858
|
+
}
|
|
859
|
+
getSnapshot() {
|
|
860
|
+
return this.#F(), ue(this.#Y);
|
|
861
|
+
}
|
|
862
|
+
subscribe(e) {
|
|
863
|
+
if (typeof e != "function") throw a("INVALID_REQUEST");
|
|
864
|
+
if (this.#i) throw a("DESTROYED");
|
|
865
|
+
this.#I.add(e);
|
|
866
|
+
try {
|
|
867
|
+
e(this.getSnapshot());
|
|
868
|
+
} catch {
|
|
869
|
+
}
|
|
870
|
+
let t = !0;
|
|
871
|
+
return () => {
|
|
872
|
+
t && (t = !1, this.#I.delete(e));
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
execute(e, t) {
|
|
876
|
+
if (this.#i) return Promise.reject(a("DESTROYED"));
|
|
877
|
+
const n = this.#p, r = this.#j[e];
|
|
878
|
+
if (!r) return Promise.reject(a("INVALID_REQUEST"));
|
|
879
|
+
let s;
|
|
880
|
+
try {
|
|
881
|
+
s = r.buildRequest(t);
|
|
882
|
+
} catch {
|
|
883
|
+
const A = this.#t(n);
|
|
884
|
+
return A ? Promise.reject(A) : Promise.reject(a("INVALID_REQUEST"));
|
|
885
|
+
}
|
|
886
|
+
let o = this.#t(n);
|
|
887
|
+
if (o) return Promise.reject(o);
|
|
888
|
+
if (this.#x)
|
|
889
|
+
return this.#l = !0, Promise.reject(a("REPLACED"));
|
|
890
|
+
const l = ++this.#p;
|
|
891
|
+
if (this.#Q(), o = this.#t(l), o) return Promise.reject(o);
|
|
892
|
+
if (this.#l)
|
|
893
|
+
return Promise.reject(a("CALLBACK_ERROR"));
|
|
894
|
+
if (this.#F(), o = this.#t(l), o) return Promise.reject(o);
|
|
895
|
+
const u = this.#r();
|
|
896
|
+
if (o = this.#t(l), o) return Promise.reject(o);
|
|
897
|
+
const h = this.#s && this.#s.expiresAtMs > u ? this.#s : null;
|
|
898
|
+
if (o = this.#t(l), o) return Promise.reject(o);
|
|
899
|
+
const d = this.#o;
|
|
900
|
+
let m, y, R;
|
|
901
|
+
try {
|
|
902
|
+
const A = this.#e.crypto, O = A?.getRandomValues, Ce = A?.subtle?.digest, re = this.#y?.open;
|
|
903
|
+
if (o = this.#t(l), o) throw o;
|
|
904
|
+
if (typeof O != "function" || typeof Ce != "function" || typeof re != "function")
|
|
905
|
+
throw a("CRYPTO_UNAVAILABLE");
|
|
906
|
+
if (m = fe(H(A, O)), o = this.#t(l), o || (y = fe(H(A, O)), o = this.#t(l), o) || (R = he(H(A, O)), o = this.#t(l), o)) throw o;
|
|
907
|
+
if (!D.test(m) || !D.test(y) || !ce.test(R))
|
|
908
|
+
throw a("CRYPTO_UNAVAILABLE");
|
|
909
|
+
if (Reflect.apply(re, this.#y, [
|
|
910
|
+
`${P}/transaction/${m}`,
|
|
911
|
+
"_blank",
|
|
912
|
+
"noopener"
|
|
913
|
+
]), o = this.#t(l), o) throw o;
|
|
914
|
+
} catch (A) {
|
|
915
|
+
if (o = this.#t(l), o) return Promise.reject(o);
|
|
916
|
+
let O;
|
|
917
|
+
try {
|
|
918
|
+
O = A instanceof j ? A : a("CRYPTO_UNAVAILABLE");
|
|
919
|
+
} catch {
|
|
920
|
+
O = a("CRYPTO_UNAVAILABLE");
|
|
921
|
+
}
|
|
922
|
+
return d && (this.#_(d, "REPLACED", !1), o = this.#t(l), o) ? Promise.reject(o) : (this.#$(null, O, h, r.kind), Promise.reject(O));
|
|
923
|
+
}
|
|
924
|
+
if (d && (this.#_(d, "REPLACED", !1), o = this.#t(l), o))
|
|
925
|
+
return Promise.reject(o);
|
|
926
|
+
const I = me(), Te = It(), ne = {
|
|
927
|
+
active: !0,
|
|
928
|
+
adapter: r,
|
|
929
|
+
callbackBusy: !1,
|
|
930
|
+
challenge: null,
|
|
931
|
+
cleanup: Te,
|
|
932
|
+
cleanupFinished: !1,
|
|
933
|
+
cleanupStarted: !1,
|
|
934
|
+
controllers: /* @__PURE__ */ new Set(),
|
|
935
|
+
expiryTimer: null,
|
|
936
|
+
generation: ++this.#S,
|
|
937
|
+
operationTimer: null,
|
|
938
|
+
phase: "hashing",
|
|
939
|
+
pollTimer: null,
|
|
940
|
+
priorConnection: h,
|
|
941
|
+
promise: I.promise,
|
|
942
|
+
registrationDeadlineMs: u + mt,
|
|
943
|
+
registrationOutcome: "none",
|
|
944
|
+
reject: I.reject,
|
|
945
|
+
request: s,
|
|
946
|
+
resolve: I.resolve,
|
|
947
|
+
retryResolve: null,
|
|
948
|
+
retryTimer: null,
|
|
949
|
+
state: y,
|
|
950
|
+
transactionExpiresAtMs: null,
|
|
951
|
+
transactionId: m,
|
|
952
|
+
verifier: R
|
|
953
|
+
};
|
|
954
|
+
return this.#o = ne, this.#n({
|
|
955
|
+
...h ? {
|
|
956
|
+
connectionExpiresAt: h.expiresAt,
|
|
957
|
+
identity: h.identity
|
|
958
|
+
} : { identity: null },
|
|
959
|
+
status: "opening"
|
|
960
|
+
}), this.#J(ne), I.promise;
|
|
961
|
+
}
|
|
962
|
+
async disconnect() {
|
|
963
|
+
if (this.#i) throw a("DESTROYED");
|
|
964
|
+
const e = ++this.#p;
|
|
965
|
+
this.#f();
|
|
966
|
+
const t = this.#o;
|
|
967
|
+
let n = Promise.resolve();
|
|
968
|
+
t && (n = this.#_(t, "DISCONNECTED", !1));
|
|
969
|
+
let r = this.#t(e);
|
|
970
|
+
if (r)
|
|
971
|
+
throw await n, r;
|
|
972
|
+
if (this.#n({ identity: null, status: "dormant" }), await n, r = this.#t(e), r) throw r;
|
|
973
|
+
}
|
|
974
|
+
destroy() {
|
|
975
|
+
if (this.#w) return this.#w;
|
|
976
|
+
const e = me();
|
|
977
|
+
this.#w = e.promise, this.#p += 1;
|
|
978
|
+
try {
|
|
979
|
+
this.#B(), e.resolve();
|
|
980
|
+
} catch {
|
|
981
|
+
e.reject(a("RELAY_ERROR"));
|
|
982
|
+
}
|
|
983
|
+
return this.#w;
|
|
984
|
+
}
|
|
985
|
+
#B() {
|
|
986
|
+
this.#i = !0, this.#S += 1, this.#f();
|
|
987
|
+
const e = [], t = this.#o;
|
|
988
|
+
t && (t.active = !1, this.#o = null, this.#L(t), t.reject(a("DESTROYED")), t.challenge && t.verifier && e.push(t));
|
|
989
|
+
for (const n of this.#m)
|
|
990
|
+
n.challenge && n.verifier && e.push(n);
|
|
991
|
+
for (const n of this.#A) n.abort();
|
|
992
|
+
this.#A.clear();
|
|
993
|
+
for (const n of this.#R)
|
|
994
|
+
this.#e.clearTimeout(n), this.#e.clearInterval(n);
|
|
995
|
+
if (this.#R.clear(), this.#b)
|
|
996
|
+
try {
|
|
997
|
+
this.#b();
|
|
998
|
+
} catch {
|
|
999
|
+
}
|
|
1000
|
+
this.#g = null, this.#b = null, this.#u = null, this.#I.clear();
|
|
1001
|
+
for (const n of e) this.#X(n);
|
|
1002
|
+
t && this.#a(t);
|
|
1003
|
+
for (const n of [...this.#m]) this.#a(n);
|
|
1004
|
+
this.#n({
|
|
1005
|
+
error: N(a("DESTROYED")),
|
|
1006
|
+
identity: null,
|
|
1007
|
+
status: "error"
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
async #J(e) {
|
|
1011
|
+
if (!(!this.#c(e) || e.cleanupFinished))
|
|
1012
|
+
try {
|
|
1013
|
+
e.operationTimer = this.#v(() => {
|
|
1014
|
+
if (!e.cleanupFinished) {
|
|
1015
|
+
if (e.phase === "hashing") {
|
|
1016
|
+
this.#c(e) && this.#h(e, "CRYPTO_UNAVAILABLE", !1);
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
if (e.phase === "registering")
|
|
1020
|
+
for (const l of e.controllers) l.abort();
|
|
1021
|
+
}
|
|
1022
|
+
}, Math.max(0, e.registrationDeadlineMs - this.#r()));
|
|
1023
|
+
const t = await this.#e.crypto.subtle.digest(
|
|
1024
|
+
"SHA-256",
|
|
1025
|
+
Le.encode(e.verifier)
|
|
1026
|
+
), n = he(new Uint8Array(t));
|
|
1027
|
+
if (!ce.test(n)) throw a("CRYPTO_UNAVAILABLE");
|
|
1028
|
+
if (!this.#c(e)) {
|
|
1029
|
+
e.registrationOutcome = "not-started", this.#a(e);
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
e.challenge = n, e.phase = "registering";
|
|
1033
|
+
const r = this.#N(e);
|
|
1034
|
+
let s, o = null;
|
|
1035
|
+
try {
|
|
1036
|
+
try {
|
|
1037
|
+
const u = this.#e.fetch(
|
|
1038
|
+
`${P}/relay/v1/transactions`,
|
|
1039
|
+
$({
|
|
1040
|
+
clientId: this.#M,
|
|
1041
|
+
codeChallenge: e.challenge,
|
|
1042
|
+
codeChallengeMethod: "S256",
|
|
1043
|
+
operation: e.adapter.operation,
|
|
1044
|
+
request: e.request,
|
|
1045
|
+
schemaVersion: 1,
|
|
1046
|
+
state: e.state,
|
|
1047
|
+
transactionId: e.transactionId
|
|
1048
|
+
}, r.signal)
|
|
1049
|
+
);
|
|
1050
|
+
o = await B(
|
|
1051
|
+
u,
|
|
1052
|
+
r.signal,
|
|
1053
|
+
k
|
|
1054
|
+
);
|
|
1055
|
+
} catch {
|
|
1056
|
+
e.registrationOutcome = "ambiguous", e.active ? this.#h(e, "RELAY_ERROR") : this.#E(e);
|
|
1057
|
+
return;
|
|
1058
|
+
}
|
|
1059
|
+
e.registrationOutcome = "ambiguous";
|
|
1060
|
+
let l;
|
|
1061
|
+
try {
|
|
1062
|
+
l = o.status;
|
|
1063
|
+
} catch {
|
|
1064
|
+
C(r, o), e.active ? this.#h(e, "RELAY_ERROR") : this.#E(e);
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
if (l !== 201) {
|
|
1068
|
+
e.registrationOutcome = "definitive-failure", C(r, o), e.active ? this.#h(e, "RELAY_ERROR", !1) : this.#a(e);
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
try {
|
|
1072
|
+
const u = await de(
|
|
1073
|
+
o,
|
|
1074
|
+
ae,
|
|
1075
|
+
r
|
|
1076
|
+
), h = F(
|
|
1077
|
+
U(u, ae),
|
|
1078
|
+
["expiresAt", "schemaVersion", "transactionId"]
|
|
1079
|
+
);
|
|
1080
|
+
if (h.schemaVersion !== 1 || h.transactionId !== e.transactionId)
|
|
1081
|
+
throw a("RELAY_ERROR");
|
|
1082
|
+
s = q(h.expiresAt);
|
|
1083
|
+
const d = this.#r();
|
|
1084
|
+
if (s <= d || s - d > yt)
|
|
1085
|
+
throw a("RELAY_ERROR");
|
|
1086
|
+
} catch {
|
|
1087
|
+
e.registrationOutcome = "ambiguous", C(r, o), e.active ? this.#h(e, "RELAY_ERROR") : this.#E(e);
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
} finally {
|
|
1091
|
+
try {
|
|
1092
|
+
r.abort();
|
|
1093
|
+
} catch {
|
|
1094
|
+
}
|
|
1095
|
+
this.#D(e, r), this.#d(e.operationTimer), e.operationTimer = null;
|
|
1096
|
+
}
|
|
1097
|
+
if (e.transactionExpiresAtMs = s, e.registrationOutcome = "registered", !this.#c(e)) {
|
|
1098
|
+
this.#E(e);
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1101
|
+
e.phase = "waiting-callback", e.expiryTimer = this.#v(() => {
|
|
1102
|
+
this.#c(e) && this.#h(e, "WALLET_NOT_COMPLETED");
|
|
1103
|
+
}, Math.max(0, e.transactionExpiresAtMs - this.#r())), e.pollTimer = this.#H(() => {
|
|
1104
|
+
this.#P(e, !1);
|
|
1105
|
+
}, dt), await this.#P(e, !1);
|
|
1106
|
+
} catch (t) {
|
|
1107
|
+
if (!e.active) {
|
|
1108
|
+
e.registrationOutcome === "ambiguous" || e.registrationOutcome === "registered" ? this.#E(e) : this.#a(e);
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1111
|
+
const n = t instanceof j ? t.code : e.phase === "hashing" ? "CRYPTO_UNAVAILABLE" : "RELAY_ERROR";
|
|
1112
|
+
this.#h(e, n, e.registrationOutcome !== "none");
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
async #P(e, t) {
|
|
1116
|
+
if (!this.#c(e) || e.phase !== "waiting-callback" || e.callbackBusy || !this.#u) return;
|
|
1117
|
+
const n = `${Y}${e.state}`;
|
|
1118
|
+
let r;
|
|
1119
|
+
try {
|
|
1120
|
+
r = this.#u.getItem(n);
|
|
1121
|
+
} catch {
|
|
1122
|
+
t && this.#h(e, "CALLBACK_ERROR");
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
if (r === null) return;
|
|
1126
|
+
e.callbackBusy = !0;
|
|
1127
|
+
let s;
|
|
1128
|
+
try {
|
|
1129
|
+
s = St(r, e.state, this.#r()), this.#u.removeItem(n);
|
|
1130
|
+
} catch {
|
|
1131
|
+
try {
|
|
1132
|
+
this.#u.removeItem(n);
|
|
1133
|
+
} catch {
|
|
1134
|
+
}
|
|
1135
|
+
this.#h(e, "CALLBACK_ERROR");
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
if (!this.#c(e)) return;
|
|
1139
|
+
e.phase = "redeeming", this.#d(e.pollTimer, !0), e.pollTimer = null;
|
|
1140
|
+
const o = this.#N(e);
|
|
1141
|
+
let l = null;
|
|
1142
|
+
try {
|
|
1143
|
+
const u = this.#e.fetch(
|
|
1144
|
+
`${P}/relay/v1/codes/redeem`,
|
|
1145
|
+
$({
|
|
1146
|
+
code: s.code,
|
|
1147
|
+
codeVerifier: e.verifier,
|
|
1148
|
+
schemaVersion: 1,
|
|
1149
|
+
state: e.state,
|
|
1150
|
+
transactionId: e.transactionId
|
|
1151
|
+
}, o.signal)
|
|
1152
|
+
);
|
|
1153
|
+
if (l = await B(
|
|
1154
|
+
u,
|
|
1155
|
+
o.signal,
|
|
1156
|
+
k
|
|
1157
|
+
), l.status !== 200) throw a("RELAY_ERROR");
|
|
1158
|
+
const h = await de(
|
|
1159
|
+
l,
|
|
1160
|
+
le,
|
|
1161
|
+
o
|
|
1162
|
+
), d = F(
|
|
1163
|
+
U(h, le),
|
|
1164
|
+
["result", "schemaVersion", "transactionId"]
|
|
1165
|
+
);
|
|
1166
|
+
if (d.schemaVersion !== 1 || d.transactionId !== e.transactionId)
|
|
1167
|
+
throw a("RELAY_ERROR");
|
|
1168
|
+
let m;
|
|
1169
|
+
try {
|
|
1170
|
+
m = e.adapter.parseResult(d.result);
|
|
1171
|
+
} catch {
|
|
1172
|
+
throw a("RELAY_ERROR");
|
|
1173
|
+
}
|
|
1174
|
+
if (!this.#c(e)) return;
|
|
1175
|
+
this.#W(e, m);
|
|
1176
|
+
} catch (u) {
|
|
1177
|
+
if (l && C(o, l), !this.#c(e)) return;
|
|
1178
|
+
const h = u instanceof j ? u.code : "RELAY_ERROR";
|
|
1179
|
+
this.#h(e, h);
|
|
1180
|
+
} finally {
|
|
1181
|
+
try {
|
|
1182
|
+
o.abort();
|
|
1183
|
+
} catch {
|
|
1184
|
+
}
|
|
1185
|
+
this.#D(e, o);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
#W(e, t) {
|
|
1189
|
+
if (!this.#c(e)) return;
|
|
1190
|
+
let n = null;
|
|
1191
|
+
(e.adapter.kind === "connect" || e.adapter.kind === "account" && t.event === "connected") && (n = this.#K(t)), e.active = !1, this.#o = null, this.#L(e);
|
|
1192
|
+
let r = t;
|
|
1193
|
+
e.adapter.kind === "connect" ? (this.#U(n), r = _(t.identity)) : e.adapter.kind === "account" ? (t.event === "connected" ? this.#U(n) : (this.#f(), this.#n({ identity: null, status: "dormant" })), r = void 0) : this.#z(e, void 0), e.resolve(r), this.#a(e);
|
|
1194
|
+
}
|
|
1195
|
+
#h(e, t, n = !0) {
|
|
1196
|
+
this.#c(e) && this.#_(e, t, !0, n);
|
|
1197
|
+
}
|
|
1198
|
+
#_(e, t, n, r = !0) {
|
|
1199
|
+
if (!e.active) return e.cleanup.promise;
|
|
1200
|
+
const s = this.#p;
|
|
1201
|
+
e.active = !1, this.#o === e && (this.#o = null), this.#S += 1, this.#L(e);
|
|
1202
|
+
for (const u of e.controllers)
|
|
1203
|
+
e.phase !== "registering" && u.abort();
|
|
1204
|
+
const o = this.#t(s), l = o ?? a(t);
|
|
1205
|
+
return e.reject(l), n && !o && this.#$(e, l, e.priorConnection, e.adapter.kind), this.#i ? (e.challenge && e.verifier && this.#q(e), this.#a(e), e.cleanup.promise) : (!r || 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
|
+
}
|
|
1207
|
+
#$(e, t, n, r) {
|
|
1208
|
+
if (n?.expiresAtMs > this.#r()) {
|
|
1209
|
+
this.#s = n, this.#n({
|
|
1210
|
+
connectionExpiresAt: n.expiresAt,
|
|
1211
|
+
error: N(t),
|
|
1212
|
+
identity: n.identity,
|
|
1213
|
+
status: "connected"
|
|
1214
|
+
});
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
this.#f(), this.#n({
|
|
1218
|
+
error: N(t),
|
|
1219
|
+
identity: null,
|
|
1220
|
+
status: "error"
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
#K(e) {
|
|
1224
|
+
const t = q(e.connectionExpiresAt), n = this.#r();
|
|
1225
|
+
if (t <= n || t - n > pt)
|
|
1226
|
+
throw a("RELAY_ERROR");
|
|
1227
|
+
return {
|
|
1228
|
+
expiresAt: e.connectionExpiresAt,
|
|
1229
|
+
expiresAtMs: t,
|
|
1230
|
+
identity: _(e.identity)
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
#U(e) {
|
|
1234
|
+
const t = this.#r();
|
|
1235
|
+
this.#f(), this.#s = e;
|
|
1236
|
+
const n = this.#s;
|
|
1237
|
+
this.#O = this.#v(() => {
|
|
1238
|
+
this.#s === n && (this.#s = null, this.#O = null, this.#o ? this.#n({ identity: null, status: "opening" }) : this.#n({ identity: null, status: "dormant" }));
|
|
1239
|
+
}, Math.max(0, e.expiresAtMs - t)), this.#n({
|
|
1240
|
+
connectionExpiresAt: e.expiresAt,
|
|
1241
|
+
identity: this.#s.identity,
|
|
1242
|
+
status: "connected"
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
#z(e, t) {
|
|
1246
|
+
const n = e.priorConnection;
|
|
1247
|
+
n?.expiresAtMs > this.#r() ? (this.#s = n, this.#n({
|
|
1248
|
+
connectionExpiresAt: n.expiresAt,
|
|
1249
|
+
...t ? { error: N(t) } : {},
|
|
1250
|
+
identity: n.identity,
|
|
1251
|
+
status: "connected"
|
|
1252
|
+
})) : t ? (this.#f(), this.#n({ error: N(t), identity: null, status: "error" })) : (this.#f(), this.#n({ identity: null, status: "dormant" }));
|
|
1253
|
+
}
|
|
1254
|
+
#F() {
|
|
1255
|
+
!this.#s || this.#s.expiresAtMs > this.#r() || (this.#f(), this.#o ? this.#n({ identity: null, status: "opening" }) : this.#n({ identity: null, status: "dormant" }));
|
|
1256
|
+
}
|
|
1257
|
+
#f() {
|
|
1258
|
+
this.#s = null, this.#d(this.#O), this.#O = null;
|
|
1259
|
+
}
|
|
1260
|
+
#n(e) {
|
|
1261
|
+
const t = _(e);
|
|
1262
|
+
if (this.#Y = t, this.#T.push(t), !this.#C) {
|
|
1263
|
+
this.#C = !0;
|
|
1264
|
+
try {
|
|
1265
|
+
for (; this.#T.length !== 0; ) {
|
|
1266
|
+
const n = this.#T.shift();
|
|
1267
|
+
for (const r of [...this.#I])
|
|
1268
|
+
try {
|
|
1269
|
+
r(ue(n));
|
|
1270
|
+
} catch {
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
} finally {
|
|
1274
|
+
this.#C = !1;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
#c(e) {
|
|
1279
|
+
return !this.#i && e.active && this.#o === e && e.generation === this.#S;
|
|
1280
|
+
}
|
|
1281
|
+
#t(e) {
|
|
1282
|
+
return this.#i ? a("DESTROYED") : e !== this.#p ? a("REPLACED") : null;
|
|
1283
|
+
}
|
|
1284
|
+
#r() {
|
|
1285
|
+
return this.#e.now();
|
|
1286
|
+
}
|
|
1287
|
+
#N(e) {
|
|
1288
|
+
const t = new this.#e.AbortController();
|
|
1289
|
+
return e.controllers.add(t), this.#A.add(t), t;
|
|
1290
|
+
}
|
|
1291
|
+
#D(e, t) {
|
|
1292
|
+
e.controllers.delete(t), this.#A.delete(t);
|
|
1293
|
+
}
|
|
1294
|
+
#v(e, t) {
|
|
1295
|
+
let n;
|
|
1296
|
+
return n = this.#e.setTimeout(() => {
|
|
1297
|
+
this.#R.delete(n), e();
|
|
1298
|
+
}, Math.max(0, t)), this.#R.add(n), n;
|
|
1299
|
+
}
|
|
1300
|
+
#H(e, t) {
|
|
1301
|
+
const n = this.#e.setInterval(e, t);
|
|
1302
|
+
return this.#R.add(n), n;
|
|
1303
|
+
}
|
|
1304
|
+
#d(e, t = !1) {
|
|
1305
|
+
e != null && (t ? this.#e.clearInterval(e) : this.#e.clearTimeout(e), this.#R.delete(e));
|
|
1306
|
+
}
|
|
1307
|
+
#L(e) {
|
|
1308
|
+
this.#d(e.expiryTimer), this.#d(e.pollTimer, !0), e.expiryTimer = null, e.pollTimer = null;
|
|
1309
|
+
}
|
|
1310
|
+
#k(e) {
|
|
1311
|
+
if (!(e.cleanupFinished || this.#m.has(e)))
|
|
1312
|
+
for (this.#m.add(e); this.#m.size > Et; ) {
|
|
1313
|
+
const t = this.#m.values().next().value;
|
|
1314
|
+
for (const n of t.controllers) n.abort();
|
|
1315
|
+
this.#a(t);
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
async #E(e) {
|
|
1319
|
+
if (e.cleanupFinished || e.cleanupStarted || this.#i)
|
|
1320
|
+
return e.cleanup.promise;
|
|
1321
|
+
e.cleanupStarted = !0, this.#k(e);
|
|
1322
|
+
let t = 100, n = !0;
|
|
1323
|
+
for (; !this.#i && !e.cleanupFinished && (n || this.#r() <= e.registrationDeadlineMs); ) {
|
|
1324
|
+
n = !1;
|
|
1325
|
+
const r = await this.#q(e);
|
|
1326
|
+
if (e.cleanupFinished) return e.cleanup.promise;
|
|
1327
|
+
if (r === "done")
|
|
1328
|
+
return this.#a(e), e.cleanup.promise;
|
|
1329
|
+
const s = e.registrationDeadlineMs - this.#r();
|
|
1330
|
+
if (s <= 0) break;
|
|
1331
|
+
await new Promise((o) => {
|
|
1332
|
+
e.retryResolve = o, e.retryTimer = this.#v(() => {
|
|
1333
|
+
e.retryResolve = null, o();
|
|
1334
|
+
}, Math.min(t, s));
|
|
1335
|
+
}), e.retryResolve = null, e.retryTimer = null, t = Math.min(t * 2, 4e3);
|
|
1336
|
+
}
|
|
1337
|
+
return this.#a(e), e.cleanup.promise;
|
|
1338
|
+
}
|
|
1339
|
+
async #q(e) {
|
|
1340
|
+
if (!e.verifier || !e.challenge) return "done";
|
|
1341
|
+
const t = this.#N(e), n = e.registrationDeadlineMs - this.#r(), r = n > 0 ? Math.min(4e3, n) : 1e3, s = this.#v(() => t.abort(), Math.max(1, r));
|
|
1342
|
+
let o = null;
|
|
1343
|
+
try {
|
|
1344
|
+
const l = this.#e.fetch(
|
|
1345
|
+
`${P}/relay/v1/transactions/${e.transactionId}/cancel`,
|
|
1346
|
+
$({
|
|
1347
|
+
codeVerifier: e.verifier,
|
|
1348
|
+
schemaVersion: 1,
|
|
1349
|
+
state: e.state,
|
|
1350
|
+
transactionId: e.transactionId
|
|
1351
|
+
}, t.signal)
|
|
1352
|
+
);
|
|
1353
|
+
o = await B(
|
|
1354
|
+
l,
|
|
1355
|
+
t.signal,
|
|
1356
|
+
k
|
|
1357
|
+
);
|
|
1358
|
+
const u = o.status;
|
|
1359
|
+
return C(t, o), o = null, u === 204 || u === 400 || u === 403 || u === 409 || u === 410 ? "done" : "retry";
|
|
1360
|
+
} catch {
|
|
1361
|
+
return o && C(t, o), "retry";
|
|
1362
|
+
} finally {
|
|
1363
|
+
try {
|
|
1364
|
+
t.abort();
|
|
1365
|
+
} catch {
|
|
1366
|
+
}
|
|
1367
|
+
this.#d(s), this.#D(e, t);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
#X(e) {
|
|
1371
|
+
let t;
|
|
1372
|
+
try {
|
|
1373
|
+
t = this.#e.fetch(
|
|
1374
|
+
`${P}/relay/v1/transactions/${e.transactionId}/cancel`,
|
|
1375
|
+
{
|
|
1376
|
+
...$({
|
|
1377
|
+
codeVerifier: e.verifier,
|
|
1378
|
+
schemaVersion: 1,
|
|
1379
|
+
state: e.state,
|
|
1380
|
+
transactionId: e.transactionId
|
|
1381
|
+
}),
|
|
1382
|
+
// Let the browser finish the tiny revocation after local teardown or unload.
|
|
1383
|
+
keepalive: !0
|
|
1384
|
+
}
|
|
1385
|
+
);
|
|
1386
|
+
} catch {
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
ie(Promise.resolve(t).then(k));
|
|
1390
|
+
}
|
|
1391
|
+
#a(e) {
|
|
1392
|
+
if (!e.cleanupFinished) {
|
|
1393
|
+
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
|
+
for (const t of e.controllers)
|
|
1395
|
+
t.abort(), this.#A.delete(t);
|
|
1396
|
+
e.controllers.clear(), this.#m.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
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
#Q() {
|
|
1400
|
+
if (!(this.#V || this.#i)) {
|
|
1401
|
+
this.#V = !0, this.#x = !0;
|
|
1402
|
+
try {
|
|
1403
|
+
let e = null;
|
|
1404
|
+
try {
|
|
1405
|
+
const s = this.#e.getStorage;
|
|
1406
|
+
e = typeof s == "function" ? Reflect.apply(s, void 0, []) : this.#e.storage ?? null;
|
|
1407
|
+
} catch {
|
|
1408
|
+
e = null, this.#l = !0;
|
|
1409
|
+
}
|
|
1410
|
+
try {
|
|
1411
|
+
(!e || typeof e.getItem != "function" || typeof e.removeItem != "function") && (this.#l = !0);
|
|
1412
|
+
} catch {
|
|
1413
|
+
this.#l = !0;
|
|
1414
|
+
}
|
|
1415
|
+
if (this.#i || this.#l) {
|
|
1416
|
+
this.#u = null;
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1419
|
+
if (this.#u = e, this.#Z(), this.#i || this.#l) {
|
|
1420
|
+
this.#u = null;
|
|
1421
|
+
return;
|
|
1422
|
+
}
|
|
1423
|
+
const t = (s) => {
|
|
1424
|
+
const o = this.#o;
|
|
1425
|
+
if (!o || !this.#c(o)) return;
|
|
1426
|
+
const l = `${Y}${o.state}`;
|
|
1427
|
+
s?.key === l && this.#P(o, !0);
|
|
1428
|
+
};
|
|
1429
|
+
this.#g = t;
|
|
1430
|
+
let n = !1, r = null;
|
|
1431
|
+
try {
|
|
1432
|
+
const s = this.#y?.addEventListener, o = this.#y?.removeEventListener;
|
|
1433
|
+
if (typeof s != "function" || typeof o != "function")
|
|
1434
|
+
throw new TypeError("storage events unavailable");
|
|
1435
|
+
r = () => Reflect.apply(
|
|
1436
|
+
o,
|
|
1437
|
+
this.#y,
|
|
1438
|
+
["storage", t]
|
|
1439
|
+
), this.#b = r, Reflect.apply(s, this.#y, ["storage", this.#g]), n = !0;
|
|
1440
|
+
} catch {
|
|
1441
|
+
this.#l = !0;
|
|
1442
|
+
}
|
|
1443
|
+
if (!n || this.#i || this.#l) {
|
|
1444
|
+
try {
|
|
1445
|
+
r?.();
|
|
1446
|
+
} catch {
|
|
1447
|
+
}
|
|
1448
|
+
this.#g = null, this.#b = null, this.#u = null;
|
|
1449
|
+
}
|
|
1450
|
+
} finally {
|
|
1451
|
+
this.#x = !1;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
#Z() {
|
|
1456
|
+
const e = this.#u;
|
|
1457
|
+
if (!e) return;
|
|
1458
|
+
let t;
|
|
1459
|
+
try {
|
|
1460
|
+
t = e.length;
|
|
1461
|
+
} catch {
|
|
1462
|
+
return;
|
|
1463
|
+
}
|
|
1464
|
+
if (!Number.isSafeInteger(t) || t < 0) return;
|
|
1465
|
+
const n = Math.min(t, At), r = [];
|
|
1466
|
+
for (let s = 0; s < n && !this.#i && !this.#l; s += 1) {
|
|
1467
|
+
let o;
|
|
1468
|
+
try {
|
|
1469
|
+
o = e.key(s);
|
|
1470
|
+
} catch {
|
|
1471
|
+
continue;
|
|
1472
|
+
}
|
|
1473
|
+
r.push(o);
|
|
1474
|
+
}
|
|
1475
|
+
for (const s of r) {
|
|
1476
|
+
if (this.#i || this.#l) return;
|
|
1477
|
+
if (typeof s != "string" || !s.startsWith(Y)) continue;
|
|
1478
|
+
const o = s.slice(Y.length);
|
|
1479
|
+
if (D.test(o))
|
|
1480
|
+
try {
|
|
1481
|
+
const l = e.getItem(s);
|
|
1482
|
+
if (l === null) continue;
|
|
1483
|
+
const u = F(
|
|
1484
|
+
U(l, 2048),
|
|
1485
|
+
["code", "expiresAt", "schemaVersion", "state"],
|
|
1486
|
+
"CALLBACK_ERROR"
|
|
1487
|
+
);
|
|
1488
|
+
if (u.schemaVersion !== 1 || u.state !== o || !D.test(u.code))
|
|
1489
|
+
continue;
|
|
1490
|
+
q(u.expiresAt, "CALLBACK_ERROR") <= this.#r() && e.removeItem(s);
|
|
1491
|
+
} catch {
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
function Lt(i) {
|
|
1497
|
+
return new _t(i);
|
|
1498
|
+
}
|
|
1499
|
+
function xt(i, e = {}) {
|
|
1500
|
+
const t = (r, s) => r !== 0 ? Promise.reject(a("INVALID_REQUEST")) : s(), n = {
|
|
1501
|
+
connect(...r) {
|
|
1502
|
+
return t(r.length, () => i.execute("connect", void 0));
|
|
1503
|
+
},
|
|
1504
|
+
destroy(...r) {
|
|
1505
|
+
return t(r.length, () => i.destroy());
|
|
1506
|
+
},
|
|
1507
|
+
disconnect(...r) {
|
|
1508
|
+
return t(r.length, () => i.disconnect());
|
|
1509
|
+
},
|
|
1510
|
+
getSnapshot(...r) {
|
|
1511
|
+
if (r.length !== 0) throw a("INVALID_REQUEST");
|
|
1512
|
+
return i.getSnapshot();
|
|
1513
|
+
},
|
|
1514
|
+
openAccount(...r) {
|
|
1515
|
+
return t(r.length, () => i.execute("account", void 0));
|
|
1516
|
+
},
|
|
1517
|
+
subscribe(r, ...s) {
|
|
1518
|
+
if (s.length !== 0) throw a("INVALID_REQUEST");
|
|
1519
|
+
return i.subscribe(r);
|
|
1520
|
+
}
|
|
1521
|
+
};
|
|
1522
|
+
for (const [r, s] of Object.entries(e))
|
|
1523
|
+
n[r] = function(l, ...u) {
|
|
1524
|
+
return u.length !== 0 ? Promise.reject(a("INVALID_REQUEST")) : i.execute(s, l);
|
|
1525
|
+
};
|
|
1526
|
+
return Object.freeze(n);
|
|
1527
|
+
}
|
|
1528
|
+
const Tt = Object.freeze({
|
|
1529
|
+
account: Object.freeze({
|
|
1530
|
+
buildRequest: () => ot({}),
|
|
1531
|
+
kind: "account",
|
|
1532
|
+
operation: "sdn.wallet.account.v1",
|
|
1533
|
+
parseResult: ct
|
|
1534
|
+
}),
|
|
1535
|
+
connect: Object.freeze({
|
|
1536
|
+
buildRequest: () => rt({}),
|
|
1537
|
+
kind: "connect",
|
|
1538
|
+
operation: "sdn.wallet.connect.v1",
|
|
1539
|
+
parseResult: st
|
|
1540
|
+
})
|
|
1541
|
+
}), Ct = Object.freeze({
|
|
1542
|
+
...Tt,
|
|
1543
|
+
assetReviewApproval: Object.freeze({
|
|
1544
|
+
buildRequest: ut,
|
|
1545
|
+
kind: "typed",
|
|
1546
|
+
operation: "sdn.asset-review.decision.v1",
|
|
1547
|
+
parseResult: ht
|
|
1548
|
+
}),
|
|
1549
|
+
authorityActivation: Object.freeze({
|
|
1550
|
+
buildRequest: at,
|
|
1551
|
+
kind: "typed",
|
|
1552
|
+
operation: "sdn.asset-review.authority-activation.v1",
|
|
1553
|
+
parseResult: lt
|
|
1554
|
+
})
|
|
1555
|
+
});
|
|
1556
|
+
function Pt() {
|
|
1557
|
+
if (arguments.length !== 0) throw a("INVALID_REQUEST");
|
|
1558
|
+
const i = Lt({
|
|
1559
|
+
adapters: Ct,
|
|
1560
|
+
clientId: "sdn-asset-review-v1"
|
|
1561
|
+
});
|
|
1562
|
+
return xt(i, {
|
|
1563
|
+
requestAssetReviewApproval: "assetReviewApproval",
|
|
1564
|
+
requestAuthorityActivation: "authorityActivation"
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
export {
|
|
1568
|
+
_e as WALLET_CLIENT_ERRORS,
|
|
1569
|
+
Pt as createAssetReviewWalletClient
|
|
1570
|
+
};
|