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