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.
@@ -1,21 +1,21 @@
1
- const lt = Object.freeze({
1
+ const Se = Object.freeze({
2
2
  cm: 0.01,
3
3
  km: 1e3,
4
4
  m: 1,
5
5
  mm: 1e-3
6
- }), ut = Object.freeze({
7
- metersPerSourceUnit: lt,
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
- }), ht = Object.freeze({ reviewedTransform: ut, schemaVersion: 1 }), $ = new TextEncoder(), tt = Object.getPrototypeOf(Uint8Array.prototype);
14
- Object.getOwnPropertyDescriptor(tt, "buffer").get;
15
- Object.getOwnPropertyDescriptor(tt, "length").get;
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 k = "sdn-bip32-slip10-purpose-v1", M = "password-scrypt-v2", W = "ed25519-over-sha256-jcs-v1", ft = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u, dt = /^[0-9a-f]{64}$/u, yt = /^sha256:[0-9a-f]{64}$/u, mt = /^[1-9A-HJ-NP-Za-km-z]+$/u, Rt = 131072, pt = [
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
- ], Et = [
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
- ], bt = [
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 At(r) {
49
+ function me(r) {
50
50
  if (r === null || typeof r != "object" || Array.isArray(r)) return !1;
51
- const t = Object.getPrototypeOf(r);
52
- return t === Object.prototype || t === null;
53
- }
54
- function S(r, t) {
55
- typeof r != "string" && u(`${t} must be a string`);
56
- for (let e = 0; e < r.length; e += 1) {
57
- const i = r.charCodeAt(e);
58
- let s = i;
59
- if (i >= 55296 && i <= 56319) {
60
- const o = r.charCodeAt(e + 1);
61
- o >= 56320 && o <= 57343 || u(`${t} contains an unpaired surrogate`), s = 65536 + (i - 55296 << 10) + (o - 56320), e += 1;
62
- } else i >= 56320 && i <= 57343 && u(`${t} contains an unpaired surrogate`);
63
- ((s & 65535) === 65534 || (s & 65535) === 65535 || s >= 64976 && s <= 65007) && u(`${t} contains a Unicode noncharacter`);
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 Ot(r) {
68
- typeof r != "string" && u("wire JSON must be a string"), $.encode(r).byteLength > Rt && u("wire JSON is too large"), r.charCodeAt(0) === 65279 && u("wire JSON must not contain a BOM");
69
- let t = 0, e = 0;
70
- const i = () => {
71
- for (; t < r.length && /[\u0009\u000a\u000d\u0020]/u.test(r[t]); ) t += 1;
72
- }, s = () => {
73
- r[t] !== '"' && u("invalid JSON string");
74
- const l = t;
75
- for (t += 1; t < r.length; ) {
76
- const a = r.charCodeAt(t);
77
- if (a === 34) {
78
- t += 1;
79
- let h;
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
- h = JSON.parse(r.slice(l, t));
81
+ f = JSON.parse(r.slice(a, e));
82
82
  } catch {
83
83
  u("invalid JSON string");
84
84
  }
85
- return S(h, "JSON string");
85
+ return v(f, "JSON string");
86
86
  }
87
- a < 32 && u("invalid JSON control character"), a === 92 && (t += 1, t >= r.length && u("unterminated JSON escape")), t += 1;
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 = (l = 0) => {
91
- l > 32 && u("wire JSON nesting is too deep"), e += 1, e > 4096 && u("wire JSON contains too many values"), i();
92
- const a = r[t];
93
- if (a === '"') return s();
94
- if (a === "{") {
95
- t += 1;
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 (i(), r[t] === "}")
98
- return t += 1, d;
99
- for (; t < r.length; ) {
100
- i();
101
- const m = s();
102
- if (y.has(m) && u(`duplicate JSON field: ${m}`), y.add(m), i(), r[t] !== ":" && u("missing JSON object colon"), t += 1, d[m] = o(l + 1), i(), r[t] === "}")
103
- return t += 1, d;
104
- r[t] !== "," && u("invalid JSON object separator"), t += 1;
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 (a === "[") {
109
- t += 1;
108
+ if (l === "[") {
109
+ e += 1;
110
110
  const d = [];
111
- if (i(), r[t] === "]")
112
- return t += 1, d;
113
- for (; t < r.length; ) {
114
- if (d.push(o(l + 1)), i(), r[t] === "]")
115
- return t += 1, d;
116
- r[t] !== "," && u("invalid JSON array separator"), t += 1;
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, t))
122
- return t += d.length, y;
123
- const h = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/u.exec(r.slice(t));
124
- h || u("invalid JSON value"), t += h[0].length;
125
- const f = Number(h[0]);
126
- return Number.isFinite(f) || u("wire JSON number must be finite"), f;
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
- i();
128
+ s();
129
129
  const n = o();
130
- return i(), t !== r.length && u("wire JSON contains trailing bytes"), n;
131
- }
132
- function wt(r) {
133
- return typeof r == "string" ? Ot(r) : r;
134
- }
135
- function vt(r, t) {
136
- if (r.byteLength !== t.byteLength) return !1;
137
- let e = 0;
138
- for (let i = 0; i < r.byteLength; i += 1) e |= r[i] ^ t[i];
139
- return e === 0;
140
- }
141
- function O(r, t, e) {
142
- const i = wt(r);
143
- At(i) || u(`${e} must be a JSON object`), Object.getOwnPropertySymbols(i).length !== 0 && u(`${e} has an unknown symbol field`);
144
- const s = Object.getOwnPropertyNames(i).sort(), o = [...t].sort(), n = $.encode(s.join("\0")), l = $.encode(o.join("\0"));
145
- vt(n, l) || u(`${e} has missing or unknown fields`);
146
- for (const a of s) {
147
- const h = Object.getOwnPropertyDescriptor(i, a);
148
- (!h || !h.enumerable || !("value" in h)) && u(`${e}.${a} must be an enumerable data field`), h.value === void 0 && u(`${e}.${a} must not be undefined`);
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 i;
150
+ return s;
151
151
  }
152
- function Y(r) {
152
+ function S(r) {
153
153
  if (!r || typeof r != "object" || Object.isFrozen(r)) return r;
154
- for (const t of Object.values(r)) Y(t);
154
+ for (const e of Object.values(r)) S(e);
155
155
  return Object.freeze(r);
156
156
  }
157
- function C(r) {
158
- return Y(Object.fromEntries([...r].sort(([t], [e]) => t < e ? -1 : t > e ? 1 : 0)));
157
+ function A(r) {
158
+ return S(Object.fromEntries([...r].sort(([e], [t]) => e < t ? -1 : e > t ? 1 : 0)));
159
159
  }
160
- function et(r, t, e) {
161
- (!Array.isArray(r) || Object.getPrototypeOf(r) !== Array.prototype || r.length !== t) && u(`${e} must be a plain array with exactly ${t} values`);
162
- const i = [...Array.from({ length: t }, (o, n) => String(n)), "length"], s = Reflect.ownKeys(r);
163
- (s.length !== i.length || s.some((o, n) => o !== i[n])) && u(`${e} must be a dense plain array`);
164
- for (let o = 0; o < t; o += 1) {
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(`${e} must contain enumerable data values`);
166
+ (!n || !n.enumerable || !("value" in n) || n.value === void 0) && u(`${t} must contain enumerable data values`);
167
167
  }
168
168
  }
169
- function Lt(r) {
170
- const t = O(
169
+ function Ve(r) {
170
+ const e = R(
171
171
  r,
172
172
  ["reviewedTransform", "schemaVersion"],
173
173
  "asset review protocol policy"
174
174
  );
175
- R(t.schemaVersion, 1, "asset review protocol schemaVersion");
176
- const e = O(t.reviewedTransform, [
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"), i = O(
184
- e.metersPerSourceUnit,
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 [s, o] of Object.entries(i))
189
- (typeof o != "number" || !Number.isFinite(o) || o <= 0) && u(`asset review unit policy ${s} must be positive and finite`);
190
- for (const [s, o] of [
191
- ["quaternionNormTolerance", e.quaternionNormTolerance],
192
- ["scaleComponentExclusiveMin", e.scaleComponentExclusiveMin],
193
- ["scaleComponentInclusiveMax", e.scaleComponentInclusiveMax],
194
- ["translationComponentAbsMax", e.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 ${s} must be finite`);
197
- return (e.quaternionNormTolerance <= 0 || e.scaleComponentInclusiveMax <= e.scaleComponentExclusiveMin || e.translationComponentAbsMax <= 0) && u("asset review transform policy bounds are inconsistent"), et(e.upAxes, 3, "asset review up-axis policy"), e.upAxes.join("\0") !== "X_UP\0Y_UP\0Z_UP" && u("asset review up-axis policy is invalid"), C([
198
- ["metersPerSourceUnit", C(Object.entries(i))],
199
- ["quaternionNormTolerance", e.quaternionNormTolerance],
200
- ["scaleComponentExclusiveMin", e.scaleComponentExclusiveMin],
201
- ["scaleComponentInclusiveMax", e.scaleComponentInclusiveMax],
202
- ["translationComponentAbsMax", e.translationComponentAbsMax],
203
- ["upAxes", Object.freeze(Array.from({ length: 3 }, (s, o) => e.upAxes[o]))]
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
- Lt(ht);
207
- function R(r, t, e) {
208
- return r !== t && u(`${e} must equal ${JSON.stringify(t)}`), 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 _t(r, t, e) {
211
- return t.includes(r) || u(`${e} is not an allowed value`), r;
210
+ function Ye(r, e, t) {
211
+ return e.includes(r) || u(`${t} is not an allowed value`), r;
212
212
  }
213
- function U(r, t, e) {
214
- return S(r, e), t.test(r) || u(`${e} has an invalid encoding`), r;
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 It(r, t) {
217
- return S(r, t), (!ft.test(r) || new Date(r).toISOString() !== r) && u(`${t} must be exact RFC3339 milliseconds UTC`), r;
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 Tt(r, t) {
220
- const e = O(r, Et, `identity key ${t.purpose}`);
221
- return R(e.purpose, t.purpose, "key purpose"), R(e.identityScheme, k, "key identityScheme"), R(e.seedProfile, M, "key seedProfile"), R(e.signatureProfile, t.signatureProfile, "key signatureProfile"), R(e.curve, t.curve, "key curve"), R(e.derivation, "slip10", "key derivation"), R(e.path, t.path, "key path"), R(e.encoding, "raw", "key encoding"), U(e.publicKeyHex, dt, "key publicKeyHex"), R(e.bip32Fingerprint, null, "key bip32Fingerprint"), U(e.keyId, yt, "key keyId"), C([
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", e.curve],
223
+ ["curve", t.curve],
224
224
  ["derivation", "slip10"],
225
225
  ["encoding", "raw"],
226
- ["identityScheme", k],
227
- ["keyId", e.keyId],
228
- ["path", e.path],
229
- ["publicKeyHex", e.publicKeyHex],
230
- ["purpose", e.purpose],
231
- ["seedProfile", M],
232
- ["signatureProfile", e.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 St(r) {
236
- const t = O(r, pt, "WalletPublicIdentity");
237
- R(t.schemaVersion, 1, "identity schemaVersion"), R(t.identityScheme, k, "identity identityScheme"), R(t.seedProfile, M, "identity seedProfile"), t.accountIndex !== 0 && u("public wallet identity must use account 0"), R(t.accountLabel, null, "identity accountLabel"), S(t.accountXpub, "identity accountXpub"), /^xpub[1-9A-HJ-NP-Za-km-z]{107}$/u.test(t.accountXpub) || u("identity accountXpub is invalid"), S(t.accountPeerId, "identity accountPeerId"), (!t.accountPeerId.startsWith("16Uiu2H") || t.accountPeerId.length < 40 || t.accountPeerId.length > 64 || !mt.test(t.accountPeerId)) && u("identity accountPeerId is invalid"), U(t.accountFingerprint, /^[0-9a-f]{8}$/u, "identity accountFingerprint"), et(t.keys, 3, "public identity keys array");
238
- const e = [
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: W,
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: W,
254
+ signatureProfile: ee,
255
255
  path: "m/44'/0'/0'/0'/0'"
256
256
  }
257
- ], i = Array.from(
257
+ ], s = Array.from(
258
258
  { length: 3 },
259
- (s, o) => Tt(t.keys[o], e[o])
259
+ (i, o) => Ke(e.keys[o], t[o])
260
260
  );
261
- return C([
262
- ["accountFingerprint", t.accountFingerprint],
261
+ return A([
262
+ ["accountFingerprint", e.accountFingerprint],
263
263
  ["accountIndex", 0],
264
264
  ["accountLabel", null],
265
- ["accountPeerId", t.accountPeerId],
266
- ["accountXpub", t.accountXpub],
267
- ["identityScheme", k],
268
- ["keys", Y(i)],
265
+ ["accountPeerId", e.accountPeerId],
266
+ ["accountXpub", e.accountXpub],
267
+ ["identityScheme", F],
268
+ ["keys", S(s)],
269
269
  ["schemaVersion", 1],
270
- ["seedProfile", M]
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 rt(r, t) {
274
- const e = O(r, bt, `${t} result`);
275
- R(e.schemaVersion, 1, "connection result schemaVersion"), _t(e.event, ["connected", "disconnected"], "connection event"), t === "connect" && e.event !== "connected" && u("connect result must be connected");
276
- let i = null, s = null;
277
- return e.event === "connected" ? (i = St(e.identity), s = It(e.connectionExpiresAt, "connectionExpiresAt")) : (e.identity !== null || e.connectionExpiresAt !== null) && u("disconnected result must clear identity and expiry"), C([
278
- ["connectionExpiresAt", s],
279
- ["event", e.event],
280
- ["identity", i],
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 it(r, t) {
285
- return O(r, [], t), Y({});
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 Ct(r = {}) {
288
- return it(r, "wallet connect request");
382
+ function rt(r) {
383
+ return be(r);
289
384
  }
290
- function Pt(r) {
291
- return rt(r, "connect");
385
+ function st(r) {
386
+ return we(r, E.fields);
292
387
  }
293
- function xt(r = {}) {
294
- return it(r, "wallet account request");
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 Nt(r) {
297
- return rt(r, "account");
398
+ function nt(r) {
399
+ return Ae(r);
298
400
  }
299
- const v = "https://wallet.spacedatanetwork.org", P = "sdn.wallet.callback.v1:", _ = /^[0-9a-f]{64}$/u, q = /^[A-Za-z0-9_-]{43}$/u, jt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u, gt = 250, Dt = 3e4, kt = 3e5, Mt = 9e5, Yt = 12e4, Vt = 8, K = 4096, z = 70 * 1024, $t = 64, st = Object.freeze({
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
- }), nt = new TextEncoder(), Ut = new TextDecoder("utf-8", { fatal: !0 });
311
- class T extends Error {
312
- constructor(t) {
313
- super(st[t]), this.name = "WalletClientError", Object.defineProperty(this, "code", {
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: t,
469
+ value: e,
317
470
  writable: !1
318
471
  });
319
472
  }
320
473
  }
321
474
  function c(r) {
322
- return Object.hasOwn(st, r) ? new T(r) : new T("RELAY_ERROR");
475
+ return Object.hasOwn(Oe, r) ? new g(r) : new g("RELAY_ERROR");
323
476
  }
324
- function Ft(r) {
477
+ function Ot(r) {
325
478
  if (r === null || typeof r != "object" || Array.isArray(r)) return !1;
326
- const t = Object.getPrototypeOf(r);
327
- return t === Object.prototype || t === null;
479
+ const e = Object.getPrototypeOf(r);
480
+ return e === Object.prototype || e === null;
328
481
  }
329
- function N(r, t) {
330
- if (typeof r != "string" || r.length > t || nt.encode(r).byteLength > t || r.charCodeAt(0) === 65279)
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 e = 0, i = 0;
333
- const s = () => {
334
- for (; e < r.length && /[\u0009\u000a\u000d\u0020]/u.test(r[e]); ) e += 1;
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[e] !== '"') throw c("RELAY_ERROR");
337
- const a = e;
338
- for (e += 1; e < r.length; ) {
339
- const h = r.charCodeAt(e);
340
- if (h === 34) {
341
- e += 1;
342
- let f;
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
- f = JSON.parse(r.slice(a, e));
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 < f.length; d += 1) {
349
- const y = f.charCodeAt(d);
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 = f.charCodeAt(d + 1);
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 f;
510
+ return h;
358
511
  }
359
- if (h < 32 || h === 92 && (e += 1, e >= r.length))
512
+ if (f < 32 || f === 92 && (t += 1, t >= r.length))
360
513
  throw c("RELAY_ERROR");
361
- e += 1;
514
+ t += 1;
362
515
  }
363
516
  throw c("RELAY_ERROR");
364
- }, n = (a = 0) => {
365
- if (a > 32 || ++i > 4096) throw c("RELAY_ERROR");
366
- s();
367
- const h = r[e];
368
- if (h === '"') return o();
369
- if (h === "{") {
370
- e += 1;
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 (s(), r[e] === "}")
373
- return e += 1, y;
374
- for (; e < r.length; ) {
375
- s();
376
- const b = o();
377
- if (m.has(b) || (m.add(b), s(), r[e] !== ":")) throw c("RELAY_ERROR");
378
- if (e += 1, y[b] = n(a + 1), s(), r[e] === "}")
379
- return e += 1, y;
380
- if (r[e] !== ",") throw c("RELAY_ERROR");
381
- e += 1;
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 (h === "[") {
386
- e += 1;
538
+ if (f === "[") {
539
+ t += 1;
387
540
  const y = [];
388
- if (s(), r[e] === "]")
389
- return e += 1, y;
390
- for (; e < r.length; ) {
391
- if (y.push(n(a + 1)), s(), r[e] === "]")
392
- return e += 1, y;
393
- if (r[e] !== ",") throw c("RELAY_ERROR");
394
- e += 1;
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, e))
400
- return e += y.length, m;
401
- const f = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/u.exec(r.slice(e));
402
- if (!f) throw c("RELAY_ERROR");
403
- e += f[0].length;
404
- const d = Number(f[0]);
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
- s();
409
- const l = n();
410
- if (s(), e !== r.length) throw c("RELAY_ERROR");
411
- return l;
561
+ i();
562
+ const a = n();
563
+ if (i(), t !== r.length) throw c("RELAY_ERROR");
564
+ return a;
412
565
  }
413
- function j(r, t, e = "RELAY_ERROR") {
414
- if (!Ft(r) || Object.getOwnPropertySymbols(r).length !== 0)
415
- throw c(e);
416
- const i = Object.getOwnPropertyNames(r).sort(), s = [...t].sort();
417
- if (i.length !== s.length || i.some((o, n) => o !== s[n]))
418
- throw c(e);
419
- for (const o of i) {
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(e);
575
+ throw c(t);
423
576
  }
424
577
  return r;
425
578
  }
426
- function g(r, t = "RELAY_ERROR") {
427
- if (typeof r != "string" || !jt.test(r))
428
- throw c(t);
429
- const e = Date.parse(r);
430
- if (!Number.isFinite(e) || new Date(e).toISOString() !== r)
431
- throw c(t);
432
- return e;
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 A(r) {
435
- return Array.isArray(r) ? Object.freeze(r.map(A)) : r && typeof r == "object" ? Object.freeze(Object.fromEntries(
436
- Object.entries(r).map(([t, e]) => [t, A(e)])
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 X(r) {
440
- const t = {
441
- identity: r.identity === null ? null : A(r.identity),
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 && (t.connectionExpiresAt = r.connectionExpiresAt), r.error !== void 0 && (t.error = A(r.error)), A(t);
597
+ return r.connectionExpiresAt !== void 0 && (e.connectionExpiresAt = r.connectionExpiresAt), r.error !== void 0 && (e.error = _(r.error)), _(e);
445
598
  }
446
- function L(r) {
599
+ function C(r) {
447
600
  return Object.freeze({ code: r.code, message: r.message });
448
601
  }
449
- function H(r) {
450
- const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
451
- let e = 0, i = 0, s = "";
602
+ function ae(r) {
603
+ const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
604
+ let t = 0, s = 0, i = "";
452
605
  for (const o of r)
453
- for (e = e << 8 | o, i += 8; i >= 6; )
454
- i -= 6, s += t[e >>> i & 63], e &= (1 << i) - 1;
455
- return i !== 0 && (s += t[e << 6 - i & 63]), s;
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 Q(r) {
458
- let t = "";
459
- for (const e of r) t += e.toString(16).padStart(2, "0");
460
- return t;
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 V(r, t) {
463
- const e = new Uint8Array(32);
464
- return Reflect.apply(t, r, [e]), e;
615
+ function W(r, e) {
616
+ const t = new Uint8Array(32);
617
+ return Reflect.apply(e, r, [t]), t;
465
618
  }
466
- function Bt(r) {
467
- const t = r?.headers?.get?.("content-type");
468
- return typeof t == "string" && /^application\/json(?:\s*;\s*charset=utf-8)?$/iu.test(t.trim());
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 F(r) {
623
+ function Q(r) {
471
624
  try {
472
625
  Promise.resolve(r).catch(() => {
473
626
  });
474
627
  } catch {
475
628
  }
476
629
  }
477
- function I(r) {
630
+ function N(r) {
478
631
  try {
479
- const t = r?.body, e = t?.cancel;
480
- typeof e == "function" && F(Reflect.apply(e, t, []));
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 ot(r) {
637
+ function ve(r) {
485
638
  try {
486
- const t = r?.cancel;
487
- typeof t == "function" && F(Reflect.apply(t, r, []));
639
+ const e = r?.cancel;
640
+ typeof e == "function" && Q(Reflect.apply(e, r, []));
488
641
  } catch {
489
642
  }
490
643
  }
491
- function Jt(r) {
644
+ function vt(r) {
492
645
  try {
493
- const t = r?.releaseLock;
494
- typeof t == "function" && Reflect.apply(t, r, []);
646
+ const e = r?.releaseLock;
647
+ typeof e == "function" && Reflect.apply(e, r, []);
495
648
  } catch {
496
649
  }
497
650
  }
498
- function w(r, t, e = null) {
651
+ function L(r, e, t = null) {
499
652
  try {
500
653
  r.abort();
501
654
  } catch {
502
655
  }
503
- e && ot(e), I(t);
656
+ t && ve(t), N(e);
504
657
  }
505
- function D(r, t, e = null) {
506
- let i;
658
+ function V(r, e, t = null) {
659
+ let s;
507
660
  try {
508
- i = Promise.resolve(r);
509
- } catch (s) {
510
- return Promise.reject(s);
661
+ s = Promise.resolve(r);
662
+ } catch (i) {
663
+ return Promise.reject(i);
511
664
  }
512
- return new Promise((s, o) => {
665
+ return new Promise((i, o) => {
513
666
  let n = !1;
514
- const l = () => {
667
+ const a = () => {
515
668
  try {
516
- t.removeEventListener("abort", h);
669
+ e.removeEventListener("abort", f);
517
670
  } catch {
518
671
  }
519
- }, a = (f, d) => n ? !1 : (n = !0, l(), f(d), !0), h = () => {
520
- a(o, c("RELAY_ERROR"));
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
- t.addEventListener("abort", h, { once: !0 }), t.aborted && h();
676
+ e.addEventListener("abort", f, { once: !0 }), e.aborted && f();
524
677
  } catch {
525
- h();
678
+ f();
526
679
  }
527
- i.then(
528
- (f) => {
680
+ s.then(
681
+ (h) => {
529
682
  if (n) {
530
683
  try {
531
- e?.(f);
684
+ t?.(h);
532
685
  } catch {
533
686
  }
534
687
  return;
535
688
  }
536
- a(s, f);
689
+ l(i, h);
537
690
  },
538
- (f) => {
539
- n || a(o, f);
691
+ (h) => {
692
+ n || l(o, h);
540
693
  }
541
694
  );
542
695
  });
543
696
  }
544
- async function Z(r, t, e) {
545
- let i = null;
546
- const s = [];
697
+ async function ue(r, e, t) {
698
+ let s = null;
699
+ const i = [];
547
700
  let o = 0;
548
701
  try {
549
- if (!Bt(r) || typeof r?.body?.getReader != "function")
702
+ if (!_t(r) || typeof r?.body?.getReader != "function")
550
703
  throw c("RELAY_ERROR");
551
- for (i = r.body.getReader(); ; ) {
552
- const a = i.read(), { done: h, value: f } = await D(a, e.signal);
553
- if (h) break;
554
- if (!(f instanceof Uint8Array) || (o += f.byteLength, o > t))
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
- s.push(f);
709
+ i.push(h);
557
710
  }
558
711
  const n = new Uint8Array(o);
559
- let l = 0;
560
- for (const a of s)
561
- n.set(a, l), l += a.byteLength;
562
- return Ut.decode(n);
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
- e.abort();
718
+ t.abort();
566
719
  } catch {
567
720
  }
568
- throw i && ot(i), c("RELAY_ERROR");
721
+ throw s && ve(s), c("RELAY_ERROR");
569
722
  } finally {
570
- i && Jt(i);
723
+ s && vt(s);
571
724
  }
572
725
  }
573
- function x(r, t) {
574
- const e = {
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 t !== void 0 && (e.signal = t), e;
737
+ return e !== void 0 && (t.signal = e), t;
585
738
  }
586
- function Wt(r, t, e) {
587
- let i;
739
+ function Lt(r, e, t) {
740
+ let s;
588
741
  try {
589
- i = N(r, 2048), j(i, ["code", "expiresAt", "schemaVersion", "state"], "CALLBACK_ERROR");
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 (i.schemaVersion !== 1 || i.state !== t || !_.test(i.code))
746
+ if (s.schemaVersion !== 1 || s.state !== e || !P.test(s.code))
594
747
  throw c("CALLBACK_ERROR");
595
- const s = g(i.expiresAt, "CALLBACK_ERROR");
596
- if (s <= e || s - e > Yt)
748
+ const i = M(s.expiresAt, "CALLBACK_ERROR");
749
+ if (i <= t || i - t > Et)
597
750
  throw c("CALLBACK_ERROR");
598
- return { code: i.code, expiresAt: s, state: i.state };
751
+ return { code: s.code, expiresAt: i, state: s.state };
599
752
  }
600
- function qt() {
753
+ function Tt() {
601
754
  let r;
602
- return { promise: new Promise((e) => {
603
- r = e;
755
+ return { promise: new Promise((t) => {
756
+ r = t;
604
757
  }), resolve: r };
605
758
  }
606
- function G() {
607
- let r, t;
608
- return { promise: new Promise((i, s) => {
609
- r = s, t = i;
610
- }), reject: r, resolve: t };
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 Kt() {
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 zt {
786
+ class St {
634
787
  #k;
635
- #M;
636
- #C = !1;
788
+ #B;
789
+ #x = !1;
637
790
  #l = !1;
638
- #Y = !1;
791
+ #$ = !1;
639
792
  #n = null;
640
- #w = null;
793
+ #O = null;
641
794
  #b = /* @__PURE__ */ new Set();
642
- #t;
643
- #v = null;
795
+ #e;
796
+ #_ = null;
644
797
  #r = !1;
645
- #R = 0;
646
- #L = 0;
647
- #_ = /* @__PURE__ */ new Set();
648
- #P = [];
798
+ #m = 0;
799
+ #v = 0;
800
+ #L = /* @__PURE__ */ new Set();
801
+ #C = [];
649
802
  #o = null;
650
- #x = !1;
803
+ #P = !1;
651
804
  #y = /* @__PURE__ */ new Set();
652
- #V = Object.freeze({ identity: null, status: "dormant" });
805
+ #U = Object.freeze({ identity: null, status: "dormant" });
653
806
  #u = null;
654
- #I = null;
807
+ #T = null;
655
808
  #A = null;
656
- #p = /* @__PURE__ */ new Set();
657
- #m;
658
- constructor({ adapters: t, clientId: e, dependencies: i }) {
659
- this.#k = t, this.#M = e, this.#t = i ?? Kt(), this.#m = this.#t.window;
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.#F(), X(this.#V);
815
+ return this.#Y(), ce(this.#U);
663
816
  }
664
- subscribe(t) {
665
- if (typeof t != "function") throw c("INVALID_REQUEST");
817
+ subscribe(e) {
818
+ if (typeof e != "function") throw c("INVALID_REQUEST");
666
819
  if (this.#r) throw c("DESTROYED");
667
- this.#_.add(t);
820
+ this.#L.add(e);
668
821
  try {
669
- t(this.getSnapshot());
822
+ e(this.getSnapshot());
670
823
  } catch {
671
824
  }
672
- let e = !0;
825
+ let t = !0;
673
826
  return () => {
674
- e && (e = !1, this.#_.delete(t));
827
+ t && (t = !1, this.#L.delete(e));
675
828
  };
676
829
  }
677
- execute(t, e) {
830
+ execute(e, t) {
678
831
  if (this.#r) return Promise.reject(c("DESTROYED"));
679
- const i = this.#R, s = this.#k[t];
680
- if (!s) return Promise.reject(c("INVALID_REQUEST"));
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 = s.buildRequest(e);
836
+ o = i.buildRequest(t);
684
837
  } catch {
685
- const p = this.#e(i);
686
- return p ? Promise.reject(p) : Promise.reject(c("INVALID_REQUEST"));
838
+ const b = this.#t(s);
839
+ return b ? Promise.reject(b) : Promise.reject(c("INVALID_REQUEST"));
687
840
  }
688
- let n = this.#e(i);
841
+ let n = this.#t(s);
689
842
  if (n) return Promise.reject(n);
690
- if (this.#C)
843
+ if (this.#x)
691
844
  return this.#l = !0, Promise.reject(c("REPLACED"));
692
- const l = ++this.#R;
693
- if (this.#Q(), n = this.#e(l), n) return Promise.reject(n);
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.#F(), n = this.#e(l), n) return Promise.reject(n);
697
- const a = this.#s();
698
- if (n = this.#e(l), n) return Promise.reject(n);
699
- const h = this.#n && this.#n.expiresAtMs > a ? this.#n : null;
700
- if (n = this.#e(l), n) return Promise.reject(n);
701
- const f = this.#o;
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 p = this.#t.crypto, E = p?.getRandomValues, at = p?.subtle?.digest, J = this.#m?.open;
705
- if (n = this.#e(l), n) throw n;
706
- if (typeof E != "function" || typeof at != "function" || typeof J != "function")
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 = Q(V(p, E)), n = this.#e(l), n || (y = Q(V(p, E)), n = this.#e(l), n) || (m = H(V(p, E)), n = this.#e(l), n)) throw n;
709
- if (!_.test(d) || !_.test(y) || !q.test(m))
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(J, this.#m, [
712
- `${v}/transaction/${d}`,
864
+ if (Reflect.apply(G, this.#p, [
865
+ `${x}/transaction/${d}`,
713
866
  "_blank",
714
867
  "noopener"
715
- ]), n = this.#e(l), n) throw n;
716
- } catch (p) {
717
- if (n = this.#e(l), n) return Promise.reject(n);
718
- let E;
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
- E = p instanceof T ? p : c("CRYPTO_UNAVAILABLE");
873
+ O = b instanceof g ? b : c("CRYPTO_UNAVAILABLE");
721
874
  } catch {
722
- E = c("CRYPTO_UNAVAILABLE");
875
+ O = c("CRYPTO_UNAVAILABLE");
723
876
  }
724
- return f && (this.#T(f, "REPLACED", !1), n = this.#e(l), n) ? Promise.reject(n) : (this.#$(null, E, h, s.kind), Promise.reject(E));
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 (f && (this.#T(f, "REPLACED", !1), n = this.#e(l), n))
879
+ if (h && (this.#I(h, "REPLACED", !1), n = this.#t(a), n))
727
880
  return Promise.reject(n);
728
- const b = G(), ct = qt(), B = {
881
+ const w = fe(), H = Tt(), Z = {
729
882
  active: !0,
730
- adapter: s,
883
+ adapter: i,
731
884
  callbackBusy: !1,
732
885
  challenge: null,
733
- cleanup: ct,
886
+ cleanup: H,
734
887
  cleanupFinished: !1,
735
888
  cleanupStarted: !1,
736
889
  controllers: /* @__PURE__ */ new Set(),
737
890
  expiryTimer: null,
738
- generation: ++this.#L,
891
+ generation: ++this.#v,
739
892
  operationTimer: null,
740
893
  phase: "hashing",
741
894
  pollTimer: null,
742
- priorConnection: h,
743
- promise: b.promise,
744
- registrationDeadlineMs: a + Dt,
895
+ priorConnection: f,
896
+ promise: w.promise,
897
+ registrationDeadlineMs: l + pt,
745
898
  registrationOutcome: "none",
746
- reject: b.reject,
899
+ reject: w.reject,
900
+ openResult: null,
747
901
  request: o,
748
- resolve: b.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 = B, this.#i({
757
- ...h ? {
758
- connectionExpiresAt: h.expiresAt,
759
- identity: h.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.#W(B), b.promise;
916
+ }), this.#q(Z), w.promise;
763
917
  }
764
918
  async disconnect() {
765
919
  if (this.#r) throw c("DESTROYED");
766
- const t = ++this.#R;
767
- this.#f();
768
- const e = this.#o;
769
- let i = Promise.resolve();
770
- e && (i = this.#T(e, "DISCONNECTED", !1));
771
- let s = this.#e(t);
772
- if (s)
773
- throw await i, s;
774
- if (this.#i({ identity: null, status: "dormant" }), await i, s = this.#e(t), s) throw s;
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.#v) return this.#v;
778
- const t = G();
779
- this.#v = t.promise, this.#R += 1;
931
+ if (this.#_) return this.#_;
932
+ const e = fe();
933
+ this.#_ = e.promise, this.#m += 1;
780
934
  try {
781
- this.#J(), t.resolve();
935
+ this.#K(), e.resolve();
782
936
  } catch {
783
- t.reject(c("RELAY_ERROR"));
937
+ e.reject(c("RELAY_ERROR"));
784
938
  }
785
- return this.#v;
939
+ return this.#_;
786
940
  }
787
- #J() {
788
- this.#r = !0, this.#L += 1, this.#f();
789
- const t = [], e = this.#o;
790
- e && (e.active = !1, this.#o = null, this.#S(e), e.reject(c("DESTROYED")), e.challenge && e.verifier && t.push(e));
791
- for (const i of this.#y)
792
- i.challenge && i.verifier && t.push(i);
793
- for (const i of this.#b) i.abort();
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 i of this.#p)
796
- this.#t.clearTimeout(i), this.#t.clearInterval(i);
797
- if (this.#p.clear(), this.#A)
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.#I = null, this.#A = null, this.#u = null, this.#_.clear();
803
- for (const i of t) this.#H(i);
804
- e && this.#a(e);
805
- for (const i of [...this.#y]) this.#a(i);
806
- this.#i({
807
- error: L(c("DESTROYED")),
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 #W(t) {
813
- if (!(!this.#c(t) || t.cleanupFinished))
966
+ async #q(e) {
967
+ if (!(!this.#c(e) || e.cleanupFinished))
814
968
  try {
815
- t.operationTimer = this.#O(() => {
816
- if (!t.cleanupFinished) {
817
- if (t.phase === "hashing") {
818
- this.#c(t) && this.#h(t, "CRYPTO_UNAVAILABLE", !1);
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 (t.phase === "registering")
822
- for (const l of t.controllers) l.abort();
975
+ if (e.phase === "registering")
976
+ for (const a of e.controllers) a.abort();
823
977
  }
824
- }, Math.max(0, t.registrationDeadlineMs - this.#s()));
825
- const e = await this.#t.crypto.subtle.digest(
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
- nt.encode(t.verifier)
828
- ), i = H(new Uint8Array(e));
829
- if (!q.test(i)) throw c("CRYPTO_UNAVAILABLE");
830
- if (!this.#c(t)) {
831
- t.registrationOutcome = "not-started", this.#a(t);
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
- t.challenge = i, t.phase = "registering";
835
- const s = this.#j(t);
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 a = this.#t.fetch(
840
- `${v}/relay/v1/transactions`,
841
- x({
842
- clientId: this.#M,
843
- codeChallenge: t.challenge,
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: t.adapter.operation,
846
- request: t.request,
1002
+ operation: e.adapter.operation,
1003
+ request: e.request,
847
1004
  schemaVersion: 1,
848
- state: t.state,
849
- transactionId: t.transactionId
850
- }, s.signal)
1005
+ state: e.state,
1006
+ transactionId: e.transactionId
1007
+ }, i.signal)
851
1008
  );
852
- n = await D(
853
- a,
854
- s.signal,
855
- I
1009
+ n = await V(
1010
+ l,
1011
+ i.signal,
1012
+ N
856
1013
  );
857
1014
  } catch {
858
- t.registrationOutcome = "ambiguous", t.active ? this.#h(t, "RELAY_ERROR") : this.#E(t);
1015
+ e.registrationOutcome = "ambiguous", e.active ? this.#f(e, "RELAY_ERROR") : this.#E(e);
859
1016
  return;
860
1017
  }
861
- t.registrationOutcome = "ambiguous";
862
- let l;
1018
+ e.registrationOutcome = "ambiguous";
1019
+ let a;
863
1020
  try {
864
- l = n.status;
1021
+ a = n.status;
865
1022
  } catch {
866
- w(s, n), t.active ? this.#h(t, "RELAY_ERROR") : this.#E(t);
1023
+ L(i, n), e.active ? this.#f(e, "RELAY_ERROR") : this.#E(e);
867
1024
  return;
868
1025
  }
869
- if (l !== 201) {
870
- t.registrationOutcome = "definitive-failure", w(s, n), t.active ? this.#h(t, "RELAY_ERROR", !1) : this.#a(t);
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 a = await Z(
1031
+ const l = await ue(
875
1032
  n,
876
- K,
877
- s
878
- ), h = j(
879
- N(a, K),
1033
+ ne,
1034
+ i
1035
+ ), f = U(
1036
+ $(l, ne),
880
1037
  ["expiresAt", "schemaVersion", "transactionId"]
881
1038
  );
882
- if (h.schemaVersion !== 1 || h.transactionId !== t.transactionId)
1039
+ if (f.schemaVersion !== 1 || f.transactionId !== e.transactionId)
883
1040
  throw c("RELAY_ERROR");
884
- o = g(h.expiresAt);
885
- const f = this.#s();
886
- if (o <= f || o - f > kt)
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
- t.registrationOutcome = "ambiguous", w(s, n), t.active ? this.#h(t, "RELAY_ERROR") : this.#E(t);
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
- s.abort();
1051
+ i.abort();
895
1052
  } catch {
896
1053
  }
897
- this.#g(t, s), this.#d(t.operationTimer), t.operationTimer = null;
1054
+ this.#D(e, i), this.#d(e.operationTimer), e.operationTimer = null;
898
1055
  }
899
- if (t.transactionExpiresAtMs = o, t.registrationOutcome = "registered", !this.#c(t)) {
900
- this.#E(t);
1056
+ if (e.transactionExpiresAtMs = o, e.registrationOutcome = "registered", !this.#c(e)) {
1057
+ this.#E(e);
901
1058
  return;
902
1059
  }
903
- t.phase = "waiting-callback", t.expiryTimer = this.#O(() => {
904
- this.#c(t) && this.#h(t, "WALLET_NOT_COMPLETED");
905
- }, Math.max(0, t.transactionExpiresAtMs - this.#s())), t.pollTimer = this.#X(() => {
906
- this.#N(t, !1);
907
- }, gt), await this.#N(t, !1);
908
- } catch (e) {
909
- if (!t.active) {
910
- t.registrationOutcome === "ambiguous" || t.registrationOutcome === "registered" ? this.#E(t) : this.#a(t);
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 i = e instanceof T ? e.code : t.phase === "hashing" ? "CRYPTO_UNAVAILABLE" : "RELAY_ERROR";
914
- this.#h(t, i, t.registrationOutcome !== "none");
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(t, e) {
918
- if (!this.#c(t) || t.phase !== "waiting-callback" || t.callbackBusy || !this.#u) return;
919
- const i = `${P}${t.state}`;
920
- let s;
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
- s = this.#u.getItem(i);
1079
+ i = this.#u.getItem(s);
923
1080
  } catch {
924
- e && this.#h(t, "CALLBACK_ERROR");
1081
+ t && this.#f(e, "CALLBACK_ERROR");
925
1082
  return;
926
1083
  }
927
- if (s === null) return;
928
- t.callbackBusy = !0;
1084
+ if (i === null) return;
1085
+ e.callbackBusy = !0;
929
1086
  let o;
930
1087
  try {
931
- o = Wt(s, t.state, this.#s()), this.#u.removeItem(i);
1088
+ o = Lt(i, e.state, this.#i()), this.#u.removeItem(s);
932
1089
  } catch {
933
1090
  try {
934
- this.#u.removeItem(i);
1091
+ this.#u.removeItem(s);
935
1092
  } catch {
936
1093
  }
937
- this.#h(t, "CALLBACK_ERROR");
1094
+ this.#f(e, "CALLBACK_ERROR");
938
1095
  return;
939
1096
  }
940
- if (!this.#c(t)) return;
941
- t.phase = "redeeming", this.#d(t.pollTimer, !0), t.pollTimer = null;
942
- const n = this.#j(t);
943
- let l = null;
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 a = this.#t.fetch(
946
- `${v}/relay/v1/codes/redeem`,
947
- x({
1102
+ const l = this.#e.fetch(
1103
+ `${x}/relay/v1/codes/redeem`,
1104
+ B({
948
1105
  code: o.code,
949
- codeVerifier: t.verifier,
1106
+ codeVerifier: e.verifier,
950
1107
  schemaVersion: 1,
951
- state: t.state,
952
- transactionId: t.transactionId
1108
+ state: e.state,
1109
+ transactionId: e.transactionId
953
1110
  }, n.signal)
954
1111
  );
955
- if (l = await D(
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
- z,
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
- ), f = j(
965
- N(h, z),
1121
+ ), h = U(
1122
+ $(f, oe),
966
1123
  ["result", "schemaVersion", "transactionId"]
967
1124
  );
968
- if (f.schemaVersion !== 1 || f.transactionId !== t.transactionId)
1125
+ if (h.schemaVersion !== 1 || h.transactionId !== e.transactionId)
969
1126
  throw c("RELAY_ERROR");
970
1127
  let d;
971
1128
  try {
972
- d = t.adapter.parseResult(f.result);
1129
+ d = e.adapter.parseResult(h.result);
973
1130
  } catch {
974
1131
  throw c("RELAY_ERROR");
975
1132
  }
976
- if (!this.#c(t)) return;
977
- this.#q(t, d);
978
- } catch (a) {
979
- if (l && w(n, l), !this.#c(t)) return;
980
- const h = a instanceof T ? a.code : "RELAY_ERROR";
981
- this.#h(t, h);
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.#g(t, n);
1144
+ this.#D(e, n);
988
1145
  }
989
1146
  }
990
- #q(t, e) {
991
- if (!this.#c(t)) return;
992
- let i = null;
993
- (t.adapter.kind === "connect" || t.adapter.kind === "account" && e.event === "connected") && (i = this.#K(e)), t.active = !1, this.#o = null, this.#S(t);
994
- let s = e;
995
- t.adapter.kind === "connect" ? (this.#U(i), s = A(e.identity)) : t.adapter.kind === "account" ? (e.event === "connected" ? this.#U(i) : (this.#f(), this.#i({ identity: null, status: "dormant" })), s = void 0) : this.#z(t, void 0), t.resolve(s), this.#a(t);
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
- #h(t, e, i = !0) {
998
- this.#c(t) && this.#T(t, e, !0, i);
1154
+ #f(e, t, s = !0) {
1155
+ this.#c(e) && this.#I(e, t, !0, s);
999
1156
  }
1000
- #T(t, e, i, s = !0) {
1001
- if (!t.active) return t.cleanup.promise;
1002
- const o = this.#R;
1003
- t.active = !1, this.#o === t && (this.#o = null), this.#L += 1, this.#S(t);
1004
- for (const a of t.controllers)
1005
- t.phase !== "registering" && a.abort();
1006
- const n = this.#e(o), l = n ?? c(e);
1007
- return t.reject(l), i && !n && this.#$(t, l, t.priorConnection, t.adapter.kind), this.#r ? (t.challenge && t.verifier && this.#B(t), this.#a(t), t.cleanup.promise) : (!s || t.registrationOutcome === "definitive-failure" || t.registrationOutcome === "not-started" ? this.#a(t) : t.phase === "hashing" ? (t.registrationOutcome = "not-started", this.#a(t)) : t.phase === "registering" && t.registrationOutcome === "none" ? this.#D(t) : (this.#D(t), this.#E(t)), t.cleanup.promise);
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
- #$(t, e, i, s) {
1010
- if (i?.expiresAtMs > this.#s()) {
1011
- this.#n = i, this.#i({
1012
- connectionExpiresAt: i.expiresAt,
1013
- error: L(e),
1014
- identity: i.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.#f(), this.#i({
1020
- error: L(e),
1176
+ this.#h(), this.#s({
1177
+ error: C(t),
1021
1178
  identity: null,
1022
1179
  status: "error"
1023
1180
  });
1024
1181
  }
1025
- #K(t) {
1026
- const e = g(t.connectionExpiresAt), i = this.#s();
1027
- if (e <= i || e - i > Mt)
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: t.connectionExpiresAt,
1031
- expiresAtMs: e,
1032
- identity: A(t.identity)
1187
+ expiresAt: e.connectionExpiresAt,
1188
+ expiresAtMs: t,
1189
+ identity: _(e.identity)
1033
1190
  };
1034
1191
  }
1035
- #U(t) {
1036
- const e = this.#s();
1037
- this.#f(), this.#n = t;
1038
- const i = this.#n;
1039
- this.#w = this.#O(() => {
1040
- this.#n === i && (this.#n = null, this.#w = null, this.#o ? this.#i({ identity: null, status: "opening" }) : this.#i({ identity: null, status: "dormant" }));
1041
- }, Math.max(0, t.expiresAtMs - e)), this.#i({
1042
- connectionExpiresAt: t.expiresAt,
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
- #z(t, e) {
1048
- const i = t.priorConnection;
1049
- i?.expiresAtMs > this.#s() ? (this.#n = i, this.#i({
1050
- connectionExpiresAt: i.expiresAt,
1051
- ...e ? { error: L(e) } : {},
1052
- identity: i.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
- })) : e ? (this.#f(), this.#i({ error: L(e), identity: null, status: "error" })) : (this.#f(), this.#i({ identity: null, status: "dormant" }));
1211
+ })) : t ? (this.#h(), this.#s({ error: C(t), identity: null, status: "error" })) : (this.#h(), this.#s({ identity: null, status: "dormant" }));
1055
1212
  }
1056
- #F() {
1057
- !this.#n || this.#n.expiresAtMs > this.#s() || (this.#f(), this.#o ? this.#i({ identity: null, status: "opening" }) : this.#i({ identity: null, status: "dormant" }));
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
- #f() {
1060
- this.#n = null, this.#d(this.#w), this.#w = null;
1216
+ #h() {
1217
+ this.#n = null, this.#d(this.#O), this.#O = null;
1061
1218
  }
1062
- #i(t) {
1063
- const e = A(t);
1064
- if (this.#V = e, this.#P.push(e), !this.#x) {
1065
- this.#x = !0;
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.#P.length !== 0; ) {
1068
- const i = this.#P.shift();
1069
- for (const s of [...this.#_])
1224
+ for (; this.#C.length !== 0; ) {
1225
+ const s = this.#C.shift();
1226
+ for (const i of [...this.#L])
1070
1227
  try {
1071
- s(X(i));
1228
+ i(ce(s));
1072
1229
  } catch {
1073
1230
  }
1074
1231
  }
1075
1232
  } finally {
1076
- this.#x = !1;
1233
+ this.#P = !1;
1077
1234
  }
1078
1235
  }
1079
1236
  }
1080
- #c(t) {
1081
- return !this.#r && t.active && this.#o === t && t.generation === this.#L;
1237
+ #c(e) {
1238
+ return !this.#r && e.active && this.#o === e && e.generation === this.#v;
1082
1239
  }
1083
- #e(t) {
1084
- return this.#r ? c("DESTROYED") : t !== this.#R ? c("REPLACED") : null;
1240
+ #t(e) {
1241
+ return this.#r ? c("DESTROYED") : e !== this.#m ? c("REPLACED") : null;
1085
1242
  }
1086
- #s() {
1087
- return this.#t.now();
1243
+ #i() {
1244
+ return this.#e.now();
1088
1245
  }
1089
- #j(t) {
1090
- const e = new this.#t.AbortController();
1091
- return t.controllers.add(e), this.#b.add(e), e;
1246
+ #g(e) {
1247
+ const t = new this.#e.AbortController();
1248
+ return e.controllers.add(t), this.#b.add(t), t;
1092
1249
  }
1093
- #g(t, e) {
1094
- t.controllers.delete(e), this.#b.delete(e);
1250
+ #D(e, t) {
1251
+ e.controllers.delete(t), this.#b.delete(t);
1095
1252
  }
1096
- #O(t, e) {
1097
- let i;
1098
- return i = this.#t.setTimeout(() => {
1099
- this.#p.delete(i), t();
1100
- }, Math.max(0, e)), this.#p.add(i), i;
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
- #X(t, e) {
1103
- const i = this.#t.setInterval(t, e);
1104
- return this.#p.add(i), i;
1259
+ #W(e, t) {
1260
+ const s = this.#e.setInterval(e, t);
1261
+ return this.#R.add(s), s;
1105
1262
  }
1106
- #d(t, e = !1) {
1107
- t != null && (e ? this.#t.clearInterval(t) : this.#t.clearTimeout(t), this.#p.delete(t));
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(t) {
1110
- this.#d(t.expiryTimer), this.#d(t.pollTimer, !0), t.expiryTimer = null, t.pollTimer = null;
1266
+ #S(e) {
1267
+ this.#d(e.expiryTimer), this.#d(e.pollTimer, !0), e.expiryTimer = null, e.pollTimer = null;
1111
1268
  }
1112
- #D(t) {
1113
- if (!(t.cleanupFinished || this.#y.has(t)))
1114
- for (this.#y.add(t); this.#y.size > Vt; ) {
1115
- const e = this.#y.values().next().value;
1116
- for (const i of e.controllers) i.abort();
1117
- this.#a(e);
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(t) {
1121
- if (t.cleanupFinished || t.cleanupStarted || this.#r)
1122
- return t.cleanup.promise;
1123
- t.cleanupStarted = !0, this.#D(t);
1124
- let e = 100, i = !0;
1125
- for (; !this.#r && !t.cleanupFinished && (i || this.#s() <= t.registrationDeadlineMs); ) {
1126
- i = !1;
1127
- const s = await this.#B(t);
1128
- if (t.cleanupFinished) return t.cleanup.promise;
1129
- if (s === "done")
1130
- return this.#a(t), t.cleanup.promise;
1131
- const o = t.registrationDeadlineMs - this.#s();
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
- t.retryResolve = n, t.retryTimer = this.#O(() => {
1135
- t.retryResolve = null, n();
1136
- }, Math.min(e, o));
1137
- }), t.retryResolve = null, t.retryTimer = null, e = Math.min(e * 2, 4e3);
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(t), t.cleanup.promise;
1296
+ return this.#a(e), e.cleanup.promise;
1140
1297
  }
1141
- async #B(t) {
1142
- if (!t.verifier || !t.challenge) return "done";
1143
- const e = this.#j(t), i = t.registrationDeadlineMs - this.#s(), s = i > 0 ? Math.min(4e3, i) : 1e3, o = this.#O(() => e.abort(), Math.max(1, s));
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 l = this.#t.fetch(
1147
- `${v}/relay/v1/transactions/${t.transactionId}/cancel`,
1148
- x({
1149
- codeVerifier: t.verifier,
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: t.state,
1152
- transactionId: t.transactionId
1153
- }, e.signal)
1308
+ state: e.state,
1309
+ transactionId: e.transactionId
1310
+ }, t.signal)
1154
1311
  );
1155
- n = await D(
1156
- l,
1157
- e.signal,
1158
- I
1312
+ n = await V(
1313
+ a,
1314
+ t.signal,
1315
+ N
1159
1316
  );
1160
- const a = n.status;
1161
- return w(e, n), n = null, a === 204 || a === 400 || a === 403 || a === 409 || a === 410 ? "done" : "retry";
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 && w(e, n), "retry";
1320
+ return n && L(t, n), "retry";
1164
1321
  } finally {
1165
1322
  try {
1166
- e.abort();
1323
+ t.abort();
1167
1324
  } catch {
1168
1325
  }
1169
- this.#d(o), this.#g(t, e);
1326
+ this.#d(o), this.#D(e, t);
1170
1327
  }
1171
1328
  }
1172
- #H(t) {
1173
- let e;
1329
+ #X(e) {
1330
+ let t;
1174
1331
  try {
1175
- e = this.#t.fetch(
1176
- `${v}/relay/v1/transactions/${t.transactionId}/cancel`,
1332
+ t = this.#e.fetch(
1333
+ `${x}/relay/v1/transactions/${e.transactionId}/cancel`,
1177
1334
  {
1178
- ...x({
1179
- codeVerifier: t.verifier,
1335
+ ...B({
1336
+ codeVerifier: e.verifier,
1180
1337
  schemaVersion: 1,
1181
- state: t.state,
1182
- transactionId: t.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
- F(Promise.resolve(e).then(I));
1348
+ Q(Promise.resolve(t).then(N));
1192
1349
  }
1193
- #a(t) {
1194
- if (!t.cleanupFinished) {
1195
- t.cleanupFinished = !0, this.#d(t.retryTimer), t.retryResolve?.(), t.retryResolve = null, t.retryTimer = null, this.#d(t.operationTimer), t.operationTimer = null, this.#S(t);
1196
- for (const e of t.controllers)
1197
- e.abort(), this.#b.delete(e);
1198
- t.controllers.clear(), this.#y.delete(t), t.adapter = null, t.challenge = null, t.priorConnection = null, t.request = null, t.state = null, t.transactionExpiresAtMs = null, t.transactionId = null, t.verifier = null, t.cleanup.resolve();
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.#Y || this.#r)) {
1203
- this.#Y = !0, this.#C = !0;
1359
+ if (!(this.#$ || this.#r)) {
1360
+ this.#$ = !0, this.#x = !0;
1204
1361
  try {
1205
- let t = null;
1362
+ let e = null;
1206
1363
  try {
1207
- const o = this.#t.getStorage;
1208
- t = typeof o == "function" ? Reflect.apply(o, void 0, []) : this.#t.storage ?? null;
1364
+ const o = this.#e.getStorage;
1365
+ e = typeof o == "function" ? Reflect.apply(o, void 0, []) : this.#e.storage ?? null;
1209
1366
  } catch {
1210
- t = null, this.#l = !0;
1367
+ e = null, this.#l = !0;
1211
1368
  }
1212
1369
  try {
1213
- (!t || typeof t.getItem != "function" || typeof t.removeItem != "function") && (this.#l = !0);
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 = t, this.#Z(), this.#r || this.#l) {
1378
+ if (this.#u = e, this.#Z(), this.#r || this.#l) {
1222
1379
  this.#u = null;
1223
1380
  return;
1224
1381
  }
1225
- const e = (o) => {
1382
+ const t = (o) => {
1226
1383
  const n = this.#o;
1227
1384
  if (!n || !this.#c(n)) return;
1228
- const l = `${P}${n.state}`;
1229
- o?.key === l && this.#N(n, !0);
1385
+ const a = `${k}${n.state}`;
1386
+ o?.key === a && this.#N(n, !0);
1230
1387
  };
1231
- this.#I = e;
1232
- let i = !1, s = null;
1388
+ this.#T = t;
1389
+ let s = !1, i = null;
1233
1390
  try {
1234
- const o = this.#m?.addEventListener, n = this.#m?.removeEventListener;
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
- s = () => Reflect.apply(
1394
+ i = () => Reflect.apply(
1238
1395
  n,
1239
- this.#m,
1240
- ["storage", e]
1241
- ), this.#A = s, Reflect.apply(o, this.#m, ["storage", this.#I]), i = !0;
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 (!i || this.#r || this.#l) {
1402
+ if (!s || this.#r || this.#l) {
1246
1403
  try {
1247
- s?.();
1404
+ i?.();
1248
1405
  } catch {
1249
1406
  }
1250
- this.#I = null, this.#A = null, this.#u = null;
1407
+ this.#T = null, this.#A = null, this.#u = null;
1251
1408
  }
1252
1409
  } finally {
1253
- this.#C = !1;
1410
+ this.#x = !1;
1254
1411
  }
1255
1412
  }
1256
1413
  }
1257
1414
  #Z() {
1258
- const t = this.#u;
1259
- if (!t) return;
1260
- let e;
1415
+ const e = this.#u;
1416
+ if (!e) return;
1417
+ let t;
1261
1418
  try {
1262
- e = t.length;
1419
+ t = e.length;
1263
1420
  } catch {
1264
1421
  return;
1265
1422
  }
1266
- if (!Number.isSafeInteger(e) || e < 0) return;
1267
- const i = Math.min(e, $t), s = [];
1268
- for (let o = 0; o < i && !this.#r && !this.#l; o += 1) {
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 = t.key(o);
1428
+ n = e.key(o);
1272
1429
  } catch {
1273
1430
  continue;
1274
1431
  }
1275
- s.push(n);
1432
+ i.push(n);
1276
1433
  }
1277
- for (const o of s) {
1434
+ for (const o of i) {
1278
1435
  if (this.#r || this.#l) return;
1279
- if (typeof o != "string" || !o.startsWith(P)) continue;
1280
- const n = o.slice(P.length);
1281
- if (_.test(n))
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 l = t.getItem(o);
1284
- if (l === null) continue;
1285
- const a = j(
1286
- N(l, 2048),
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 (a.schemaVersion !== 1 || a.state !== n || !_.test(a.code))
1447
+ if (l.schemaVersion !== 1 || l.state !== n || !P.test(l.code))
1291
1448
  continue;
1292
- g(a.expiresAt, "CALLBACK_ERROR") <= this.#s() && t.removeItem(o);
1449
+ M(l.expiresAt, "CALLBACK_ERROR") <= this.#i() && e.removeItem(o);
1293
1450
  } catch {
1294
1451
  }
1295
1452
  }
1296
1453
  }
1297
1454
  }
1298
- function Xt(r) {
1299
- return new zt(r);
1455
+ function he(r) {
1456
+ return new St(r);
1300
1457
  }
1301
- function Ht(r, t = {}) {
1302
- const e = (s, o) => s !== 0 ? Promise.reject(c("INVALID_REQUEST")) : o(), i = {
1303
- connect(...s) {
1304
- return e(s.length, () => r.execute("connect", void 0));
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(...s) {
1307
- return e(s.length, () => r.destroy());
1463
+ destroy(...i) {
1464
+ return t(i.length, () => r.destroy());
1308
1465
  },
1309
- disconnect(...s) {
1310
- return e(s.length, () => r.disconnect());
1466
+ disconnect(...i) {
1467
+ return t(i.length, () => r.disconnect());
1311
1468
  },
1312
- getSnapshot(...s) {
1313
- if (s.length !== 0) throw c("INVALID_REQUEST");
1469
+ getSnapshot(...i) {
1470
+ if (i.length !== 0) throw c("INVALID_REQUEST");
1314
1471
  return r.getSnapshot();
1315
1472
  },
1316
- openAccount(...s) {
1317
- return e(s.length, () => r.execute("account", void 0));
1473
+ openAccount(...i) {
1474
+ return t(i.length, () => r.execute("account", void 0));
1318
1475
  },
1319
- subscribe(s, ...o) {
1476
+ subscribe(i, ...o) {
1320
1477
  if (o.length !== 0) throw c("INVALID_REQUEST");
1321
- return r.subscribe(s);
1478
+ return r.subscribe(i);
1322
1479
  }
1323
1480
  };
1324
- for (const [s, o] of Object.entries(t))
1325
- i[s] = function(l, ...a) {
1326
- return a.length !== 0 ? Promise.reject(c("INVALID_REQUEST")) : r.execute(o, l);
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(i);
1485
+ return Object.freeze(s);
1329
1486
  }
1330
- const Qt = Object.freeze([
1331
- "orbpro-pages-v1",
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 Zt(r) {
1343
- let t;
1499
+ function Ct(r) {
1500
+ let e;
1344
1501
  try {
1345
- const e = Reflect.ownKeys(r);
1346
- if (r === null || typeof r != "object" || Array.isArray(r) || Object.getPrototypeOf(r) !== Object.prototype || e.length !== 1 || e[0] !== "clientId")
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
- t = Object.getOwnPropertyDescriptor(r, "clientId");
1505
+ e = Object.getOwnPropertyDescriptor(r, "clientId");
1349
1506
  } catch {
1350
1507
  throw c("INVALID_REQUEST");
1351
1508
  }
1352
- if (!t?.enumerable || !("value" in t) || typeof t.value != "string")
1509
+ if (!e?.enumerable || !("value" in e) || typeof e.value != "string")
1353
1510
  throw c("INVALID_REQUEST");
1354
- if (!Qt.includes(t.value)) throw c("INVALID_CLIENT");
1355
- return t.value;
1511
+ if (!xt.includes(e.value)) throw c("INVALID_CLIENT");
1512
+ return e.value;
1356
1513
  }
1357
- const Gt = Object.freeze({
1514
+ const ye = Object.freeze({
1358
1515
  account: Object.freeze({
1359
- buildRequest: () => xt({}),
1516
+ buildRequest: () => Je({}),
1360
1517
  kind: "account",
1361
1518
  operation: "sdn.wallet.account.v1",
1362
- parseResult: Nt
1519
+ parseResult: We
1363
1520
  }),
1364
1521
  connect: Object.freeze({
1365
- buildRequest: () => Ct({}),
1522
+ buildRequest: () => ze({}),
1366
1523
  kind: "connect",
1367
1524
  operation: "sdn.wallet.connect.v1",
1368
- parseResult: Pt
1525
+ parseResult: He
1369
1526
  })
1370
1527
  });
1371
- function te(r) {
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 t = Zt(r), e = Xt({ adapters: Gt, clientId: t });
1374
- return Ht(e);
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
- st as WALLET_CLIENT_ERRORS,
1378
- te as createWalletClient
1601
+ Oe as WALLET_CLIENT_ERRORS,
1602
+ Dt as createWalletClient
1379
1603
  };