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