@lumenwipe/verify 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -1
- package/README.md +17 -7
- package/dist/index.cjs +206 -16
- package/dist/index.d.cts +49 -17
- package/dist/index.d.ts +49 -17
- package/dist/index.js +207 -17
- package/package.json +4 -2
- package/vectors/close-v1.json +1223 -118
- package/vectors/registry-signing-v1.json +1035 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,45 @@ release is cut.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.9.0] - 2026-11-27
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- A served exchange registry may carry a maintainer signature. `ServedRegistry` gains an optional
|
|
15
|
+
`signature` (`ExchangeRegistrySignature`), `version` and `source`: pass the body of
|
|
16
|
+
`GET /v1/config/exchange-registry` as served. A signature made by one of the two registry keys
|
|
17
|
+
pinned in this release, not older than the registry bundled here, not past its `validUntil` and
|
|
18
|
+
not dated more than a day ahead of the clock, lets the snapshot add an exchange that needs the
|
|
19
|
+
mediated hand-off, which `verifyCloseTransaction` then accepts through the mediated shape
|
|
20
|
+
only. A missing, truncated, forged or stale signature leaves the snapshot stricter-only, exactly
|
|
21
|
+
as in 0.8.0. A signed snapshot adds exchanges and changes no bundled entry, memo type or network
|
|
22
|
+
scope, and the signature does not vouch for the account a mediated close merges into.
|
|
23
|
+
`requiresMediator(address, network, servedRegistry?)` takes the snapshot and answers by the same
|
|
24
|
+
rule. New vectors: `vectors/registry-signing-v1.json` for the signature scheme, and rejected
|
|
25
|
+
`close-v1` vectors for a snapshot signed by a key this package does not pin, with a forged
|
|
26
|
+
signature and with a truncated one. Rotating a key is a release of this package.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- The bundled contract registry (version `2026-11-25`) re-pins the mainnet Aquarius router
|
|
31
|
+
(`CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK`) to the code it runs since its
|
|
32
|
+
upstream upgrade on 2026-11-25. The previous code is no longer recognized. The router's address,
|
|
33
|
+
the Aquarius pool codes and the contracts a close may call are unchanged, and so is
|
|
34
|
+
verification.
|
|
35
|
+
|
|
36
|
+
## [0.8.0] - 2026-11-24
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- `verify()` accepts a Soroswap aggregator `swap_exact_in` whose `partner` is a 0-bps partner,
|
|
41
|
+
`{ bps: 0, id }`, a shape 0.7.0 refused. Since the aggregator's 2026-11-23 upgrade the Soroswap
|
|
42
|
+
API names one on every swap it builds for an API key. At 0 bps the partner only labels the swap:
|
|
43
|
+
the aggregator charges its own 10 bps fee, as with no partner, and pays no partner. Any other bps,
|
|
44
|
+
a key out of order, a missing or extra key, or a bps that is not the number 0 is still refused
|
|
45
|
+
with `swap_args_unreadable`, and the id is trusted for nothing. A new accepted mainnet vector
|
|
46
|
+
converts a token through the aggregator with a 0-bps partner, with rejected mutations at 1, 25
|
|
47
|
+
and 100 bps and with a third key in the partner.
|
|
48
|
+
|
|
10
49
|
## [0.7.0] - 2026-11-23
|
|
11
50
|
|
|
12
51
|
### Added
|
|
@@ -217,7 +256,9 @@ The bundled exchange and contract registries are unchanged.
|
|
|
217
256
|
is optional, and a rejection may mutate the snapshot instead of, or with, the transaction.
|
|
218
257
|
- The package ships its `LICENSE` and this `CHANGELOG.md`.
|
|
219
258
|
|
|
220
|
-
[Unreleased]: https://github.com/LumenWipe/lumenwipe/compare/verify-v0.
|
|
259
|
+
[Unreleased]: https://github.com/LumenWipe/lumenwipe/compare/verify-v0.9.0...HEAD
|
|
260
|
+
[0.9.0]: https://github.com/LumenWipe/lumenwipe/compare/verify-v0.8.0...verify-v0.9.0
|
|
261
|
+
[0.8.0]: https://github.com/LumenWipe/lumenwipe/compare/verify-v0.7.0...verify-v0.8.0
|
|
221
262
|
[0.7.0]: https://github.com/LumenWipe/lumenwipe/compare/verify-v0.6.0...verify-v0.7.0
|
|
222
263
|
[0.6.0]: https://github.com/LumenWipe/lumenwipe/compare/verify-v0.5.0...verify-v0.6.0
|
|
223
264
|
[0.5.0]: https://github.com/LumenWipe/lumenwipe/compare/verify-v0.4.0...verify-v0.5.0
|
package/README.md
CHANGED
|
@@ -98,19 +98,29 @@ network at all. A new version is released on every registry change.
|
|
|
98
98
|
|
|
99
99
|
`verifyCloseTransaction` takes an optional `servedRegistry`: the body of
|
|
100
100
|
`GET /v1/config/exchange-registry` (`client.getExchangeRegistry()`), fetched by you and passed
|
|
101
|
-
as is. It is merged over the bundled exchange registry with the same
|
|
102
|
-
app applies to the copy it is served.
|
|
103
|
-
because it can only make verification stricter:
|
|
101
|
+
as is, `signature` included. It is merged over the bundled exchange registry with the same
|
|
102
|
+
stricter-only rule the web app applies to the copy it is served. Unless its signature verifies it
|
|
103
|
+
is not authenticated; it is safe to pass because it can only make verification stricter:
|
|
104
104
|
|
|
105
105
|
- A bundled exchange is never removed, and its memo requirement and its refusal of a direct
|
|
106
106
|
merge are never turned off.
|
|
107
107
|
- An address the snapshot adds is checked as an exchange: a direct merge into it is refused if it
|
|
108
108
|
needs the intermediary, a memo is required if it needs one, and a transfer to it is refused.
|
|
109
|
-
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
- Without a signature that verifies it never enables the mediated hand-off: that stays limited to
|
|
110
|
+
the exchanges bundled here. An address an unsigned snapshot lists as needing the intermediary
|
|
111
|
+
refuses both a direct merge and the hand-off until you upgrade. Accepting the hand-off on
|
|
112
|
+
unauthenticated data would let the API, which also builds the transaction and reports the
|
|
113
113
|
balance the forward is checked against, choose which closes go through an intermediary.
|
|
114
|
+
- With a signature that verifies, the snapshot may add an exchange that needs the hand-off, and
|
|
115
|
+
nothing else (`requiresMediator(address, network, servedRegistry)` answers by the same rule). The
|
|
116
|
+
signature is an Ed25519 signature by one of two registry keys pinned in this release, over the
|
|
117
|
+
registry, a sequence and an issue date. It verifies only when a pinned key made it, its sequence
|
|
118
|
+
is at least the one of the registry bundled here, `validUntil` has not passed by your clock and
|
|
119
|
+
`issuedAt` is no more than a day ahead of it. A missing, truncated, forged or stale signature
|
|
120
|
+
leaves the snapshot unsigned rather than refusing the close. It changes no bundled entry, memo
|
|
121
|
+
type or network scope, and it gates the hand-off without vouching for the account a mediated
|
|
122
|
+
close merges into. Rotating a key is a release of this package; the conformance vectors are
|
|
123
|
+
`vectors/registry-signing-v1.json`.
|
|
114
124
|
- It never changes the network a bundled exchange applies on: a testnet-only entry stays
|
|
115
125
|
unlisted on mainnet, and an entry listed on every network stays listed on both. An address it
|
|
116
126
|
adds with `"network": "testnet"` applies on testnet only.
|
package/dist/index.cjs
CHANGED
|
@@ -187,6 +187,142 @@ var exchange_registry_default = {
|
|
|
187
187
|
]
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
+
// ../../apps/api/src/config/exchange-registry.sig.json
|
|
191
|
+
var exchange_registry_sig_default = {
|
|
192
|
+
format: 1,
|
|
193
|
+
sequence: 1,
|
|
194
|
+
issuedAt: "2026-11-27",
|
|
195
|
+
signature: "nQ6wwF1KWDUlrOXa9eagarWoRz4DfOj57njy0uBBQpnvGUv+CjlW+PgNGLf3ZwqxKKh90/U2Gbqa1KbNqMl8AQ=="
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// ../../apps/web/lib/exchange-registry/canonical.ts
|
|
199
|
+
function canonicalJson(value) {
|
|
200
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
201
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
202
|
+
if (typeof value === "number") {
|
|
203
|
+
if (!Number.isSafeInteger(value) || Object.is(value, -0)) {
|
|
204
|
+
throw new Error("A canonical payload holds only safe integers.");
|
|
205
|
+
}
|
|
206
|
+
return String(value);
|
|
207
|
+
}
|
|
208
|
+
if (Array.isArray(value)) return `[${Array.from(value, canonicalJson).join(",")}]`;
|
|
209
|
+
if (typeof value === "object" && value !== null) {
|
|
210
|
+
const proto = Object.getPrototypeOf(value);
|
|
211
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
212
|
+
throw new Error("A canonical payload holds only plain objects.");
|
|
213
|
+
}
|
|
214
|
+
const record = value;
|
|
215
|
+
const members = Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`);
|
|
216
|
+
return `{${members.join(",")}}`;
|
|
217
|
+
}
|
|
218
|
+
throw new Error(
|
|
219
|
+
"A canonical payload holds only objects, arrays, strings, booleans and integers."
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// ../../apps/web/lib/exchange-registry/signature.ts
|
|
224
|
+
var SIGNING_LABEL = "lumenwipe.exchange-registry.signature.v1";
|
|
225
|
+
var SIGNATURE_FORMAT = 1;
|
|
226
|
+
var REGISTRY_FIELDS = [
|
|
227
|
+
"version",
|
|
228
|
+
"lastVerified",
|
|
229
|
+
"validUntil",
|
|
230
|
+
"source",
|
|
231
|
+
"entries"
|
|
232
|
+
];
|
|
233
|
+
var DAY_MS = 864e5;
|
|
234
|
+
var ISO_DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
235
|
+
var BASE64 = /^[A-Za-z0-9+/]{86}==$/;
|
|
236
|
+
function isDay(value) {
|
|
237
|
+
if (typeof value !== "string" || !ISO_DAY.test(value)) return false;
|
|
238
|
+
const ms = Date.parse(`${value}T00:00:00Z`);
|
|
239
|
+
return Number.isFinite(ms) && new Date(ms).toISOString().startsWith(value);
|
|
240
|
+
}
|
|
241
|
+
function parseSignature(raw) {
|
|
242
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null;
|
|
243
|
+
const r = raw;
|
|
244
|
+
const keys = Object.keys(r).sort().join(",");
|
|
245
|
+
if (keys !== "format,issuedAt,sequence,signature") return null;
|
|
246
|
+
if (r.format !== SIGNATURE_FORMAT) return null;
|
|
247
|
+
if (typeof r.sequence !== "number" || !Number.isSafeInteger(r.sequence) || r.sequence < 1) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
if (!isDay(r.issuedAt)) return null;
|
|
251
|
+
if (typeof r.signature !== "string" || !BASE64.test(r.signature)) return null;
|
|
252
|
+
return {
|
|
253
|
+
format: SIGNATURE_FORMAT,
|
|
254
|
+
sequence: r.sequence,
|
|
255
|
+
issuedAt: r.issuedAt,
|
|
256
|
+
signature: r.signature
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function registryProjection(body) {
|
|
260
|
+
if (typeof body !== "object" || body === null) return null;
|
|
261
|
+
const source = body;
|
|
262
|
+
const projection = {};
|
|
263
|
+
for (const field of REGISTRY_FIELDS) {
|
|
264
|
+
if (!(field in source)) return null;
|
|
265
|
+
projection[field] = source[field];
|
|
266
|
+
}
|
|
267
|
+
return projection;
|
|
268
|
+
}
|
|
269
|
+
function signingBytes(registry, meta) {
|
|
270
|
+
const projection = registryProjection(registry);
|
|
271
|
+
if (projection === null) return null;
|
|
272
|
+
try {
|
|
273
|
+
const text = canonicalJson({
|
|
274
|
+
format: SIGNATURE_FORMAT,
|
|
275
|
+
issuedAt: meta.issuedAt,
|
|
276
|
+
registry: projection,
|
|
277
|
+
sequence: meta.sequence
|
|
278
|
+
});
|
|
279
|
+
return new TextEncoder().encode(`${SIGNING_LABEL}
|
|
280
|
+
${text}`);
|
|
281
|
+
} catch {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
function decodeSignature(encoded) {
|
|
286
|
+
try {
|
|
287
|
+
const raw = atob(encoded);
|
|
288
|
+
const bytes = Uint8Array.from(raw, (c) => c.charCodeAt(0));
|
|
289
|
+
return bytes.length === 64 && btoa(raw) === encoded ? bytes : null;
|
|
290
|
+
} catch {
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function verifiesUnderAny(keys, bytes, signature) {
|
|
295
|
+
return keys.some((key) => {
|
|
296
|
+
try {
|
|
297
|
+
return stellarSdk.Keypair.fromPublicKey(key).verify(bytes, signature);
|
|
298
|
+
} catch {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
function verifyRegistrySignature(body, envelope, context) {
|
|
304
|
+
const parsed = parseSignature(envelope);
|
|
305
|
+
const bytes = parsed === null ? null : signingBytes(body, parsed);
|
|
306
|
+
const signature = parsed === null ? null : decodeSignature(parsed.signature);
|
|
307
|
+
if (parsed === null || bytes === null || signature === null) {
|
|
308
|
+
return { ok: false, reason: "malformed" };
|
|
309
|
+
}
|
|
310
|
+
if (!verifiesUnderAny(context.keys, bytes, signature)) {
|
|
311
|
+
return { ok: false, reason: "bad-signature" };
|
|
312
|
+
}
|
|
313
|
+
if (parsed.sequence < context.bundledSequence) return { ok: false, reason: "stale-sequence" };
|
|
314
|
+
const { validUntil } = body;
|
|
315
|
+
const until = typeof validUntil === "string" ? validUntil : "";
|
|
316
|
+
if (!isDay(until) || Date.parse(`${until}T23:59:59Z`) < context.now.getTime()) {
|
|
317
|
+
return { ok: false, reason: "expired" };
|
|
318
|
+
}
|
|
319
|
+
const issued = Date.parse(`${parsed.issuedAt}T00:00:00Z`);
|
|
320
|
+
if (issued > context.now.getTime() + DAY_MS || parsed.issuedAt > until) {
|
|
321
|
+
return { ok: false, reason: "future-dated" };
|
|
322
|
+
}
|
|
323
|
+
return { ok: true, sequence: parsed.sequence };
|
|
324
|
+
}
|
|
325
|
+
|
|
190
326
|
// ../../apps/web/lib/exchange-registry/merge.ts
|
|
191
327
|
function appliesOn(entry, network) {
|
|
192
328
|
return entry.network === void 0 || entry.network === network;
|
|
@@ -251,19 +387,54 @@ function mergeServedRegistry(floor, body) {
|
|
|
251
387
|
memoTypeDisputes: [...disputes]
|
|
252
388
|
};
|
|
253
389
|
}
|
|
390
|
+
function resolveServedRegistry(floor, body, context) {
|
|
391
|
+
const merged = mergeServedRegistry(floor, body);
|
|
392
|
+
if (merged === null) return null;
|
|
393
|
+
const envelope = body.signature;
|
|
394
|
+
const verdict = verifyRegistrySignature(body, envelope, context);
|
|
395
|
+
if (!verdict.ok) return { ...merged, trust: "unsigned", sequence: null, mediatedAdditions: [] };
|
|
396
|
+
const bundled = new Set(floor.entries.map((e) => e.address));
|
|
397
|
+
return {
|
|
398
|
+
...merged,
|
|
399
|
+
trust: "signed",
|
|
400
|
+
sequence: verdict.sequence,
|
|
401
|
+
mediatedAdditions: merged.entries.filter((e) => !bundled.has(e.address) && e.requiresMediator).map((e) => e.address)
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function mediatedByAddition(registry, address, network) {
|
|
405
|
+
if (!registry.mediatedAdditions?.includes(address)) return false;
|
|
406
|
+
return registry.entries.some(
|
|
407
|
+
(e) => e.address === address && e.requiresMediator && appliesOn(e, network)
|
|
408
|
+
);
|
|
409
|
+
}
|
|
254
410
|
function isUsableAt(validUntil, now) {
|
|
255
411
|
const until = Date.parse(`${validUntil}T23:59:59Z`);
|
|
256
412
|
return Number.isFinite(until) && now.getTime() <= until;
|
|
257
413
|
}
|
|
258
414
|
|
|
415
|
+
// ../../apps/web/lib/exchange-registry/trust-roots.ts
|
|
416
|
+
var REGISTRY_SIGNING_KEYS = [
|
|
417
|
+
"GAKGKRCTIPJIFS4UAL6TZEXW3ZUUYBFBPBAVNG37NKILQQ5ZSW3VGDTK",
|
|
418
|
+
"GAOXVNB4UHWUOXDLSQXTPUJUZWRHKO35ZP5P5XZNPESMEIPUL3X66PDD"
|
|
419
|
+
];
|
|
420
|
+
|
|
259
421
|
// ../../apps/web/lib/exchange-registry/index.ts
|
|
422
|
+
var BUNDLED_SIGNATURE = parseSignature(exchange_registry_sig_default);
|
|
423
|
+
if (BUNDLED_SIGNATURE === null) {
|
|
424
|
+
throw new Error("The bundled exchange registry signature is malformed.");
|
|
425
|
+
}
|
|
260
426
|
var EMBEDDED = {
|
|
261
427
|
entries: bundledEntries(exchange_registry_default.entries),
|
|
262
428
|
lastVerified: exchange_registry_default.lastVerified,
|
|
263
429
|
validUntil: exchange_registry_default.validUntil,
|
|
264
|
-
served: false
|
|
430
|
+
served: false,
|
|
431
|
+
trust: "bundled",
|
|
432
|
+
sequence: BUNDLED_SIGNATURE.sequence
|
|
265
433
|
};
|
|
266
434
|
var current = EMBEDDED;
|
|
435
|
+
function pinnedRegistryTrust() {
|
|
436
|
+
return { keys: REGISTRY_SIGNING_KEYS, bundledSequence: EMBEDDED.sequence };
|
|
437
|
+
}
|
|
267
438
|
function bundledRegistry() {
|
|
268
439
|
return EMBEDDED;
|
|
269
440
|
}
|
|
@@ -280,7 +451,7 @@ function bundledExchange(address, network) {
|
|
|
280
451
|
return EMBEDDED.entries.find((e) => e.address === address && appliesOn(e, network)) ?? null;
|
|
281
452
|
}
|
|
282
453
|
function mediatorAllowedFor(address, network) {
|
|
283
|
-
return bundledExchange(address, network)?.requiresMediator === true;
|
|
454
|
+
return bundledExchange(address, network)?.requiresMediator === true || mediatedByAddition(current, address, network);
|
|
284
455
|
}
|
|
285
456
|
function memoTypeInDispute(address) {
|
|
286
457
|
return current.memoTypeDisputes?.includes(address) ?? false;
|
|
@@ -960,11 +1131,22 @@ function readSwapArgs(fn, args) {
|
|
|
960
1131
|
const min = integer(args[4]);
|
|
961
1132
|
if (!CONTRACT_ID.test(token) || !CONTRACT_ID.test(assetOut)) return null;
|
|
962
1133
|
if (amountIn === null || min === null) return null;
|
|
963
|
-
if (args[6] !== "null") return null;
|
|
1134
|
+
if (args[6] !== "null" && !isZeroFeePartner(args[6] ?? "")) return null;
|
|
964
1135
|
return { token, assetOut, amountIn, destination: args[0] ?? "", minAmountOut: min };
|
|
965
1136
|
}
|
|
966
1137
|
return null;
|
|
967
1138
|
}
|
|
1139
|
+
function isZeroFeePartner(rendered) {
|
|
1140
|
+
let parsed;
|
|
1141
|
+
try {
|
|
1142
|
+
parsed = JSON.parse(rendered);
|
|
1143
|
+
} catch {
|
|
1144
|
+
return false;
|
|
1145
|
+
}
|
|
1146
|
+
if (typeof parsed !== "object" || parsed === null) return false;
|
|
1147
|
+
const { id } = parsed;
|
|
1148
|
+
return typeof id === "string" && rendered === JSON.stringify({ bps: 0, id });
|
|
1149
|
+
}
|
|
968
1150
|
var XBULL_SWAP_FUNCTION = "strict_send";
|
|
969
1151
|
function readXBullSwapArgs(args) {
|
|
970
1152
|
if (args.length !== 6) return null;
|
|
@@ -1720,15 +1902,17 @@ function depositAddressesOf(transfers, lookup) {
|
|
|
1720
1902
|
}
|
|
1721
1903
|
return listed;
|
|
1722
1904
|
}
|
|
1723
|
-
function registryView(served, network) {
|
|
1905
|
+
function registryView(served, network, trust) {
|
|
1724
1906
|
if (served === void 0) {
|
|
1725
1907
|
return {
|
|
1726
1908
|
lookup: (address) => lookupExchange(address, network),
|
|
1727
1909
|
usable: () => isRegistryUsable(),
|
|
1728
|
-
memoTypeInDispute
|
|
1910
|
+
memoTypeInDispute,
|
|
1911
|
+
mediatorAllowed: (address) => mediatorAllowedFor(address, network)
|
|
1729
1912
|
};
|
|
1730
1913
|
}
|
|
1731
|
-
const
|
|
1914
|
+
const bundled = bundledRegistry();
|
|
1915
|
+
const merged = resolveServedRegistry(bundled, served, { ...trust, now: /* @__PURE__ */ new Date() });
|
|
1732
1916
|
if (merged === null) {
|
|
1733
1917
|
throw new VerificationError(
|
|
1734
1918
|
"registry_snapshot_invalid",
|
|
@@ -1742,9 +1926,13 @@ function registryView(served, network) {
|
|
|
1742
1926
|
return {
|
|
1743
1927
|
lookup: (address) => byAddress2.get(address) ?? null,
|
|
1744
1928
|
usable: () => isUsableAt(merged.validUntil, /* @__PURE__ */ new Date()),
|
|
1745
|
-
memoTypeInDispute: (address) => disputes.has(address)
|
|
1929
|
+
memoTypeInDispute: (address) => disputes.has(address),
|
|
1930
|
+
mediatorAllowed: (address) => bundledExchange(address, network)?.requiresMediator === true || mediatedByAddition(merged, address, network)
|
|
1746
1931
|
};
|
|
1747
1932
|
}
|
|
1933
|
+
function mediatorAllowedUnder(destination, network, served) {
|
|
1934
|
+
return registryView(served, network, pinnedRegistryTrust()).mediatorAllowed(destination);
|
|
1935
|
+
}
|
|
1748
1936
|
function listedMemoType(exchange, registry, network, expected) {
|
|
1749
1937
|
if (registry.memoTypeInDispute(expected.destination)) {
|
|
1750
1938
|
throw new VerificationError(
|
|
@@ -1762,8 +1950,11 @@ function listedMemoType(exchange, registry, network, expected) {
|
|
|
1762
1950
|
return expected.memoType;
|
|
1763
1951
|
}
|
|
1764
1952
|
function verifyCloseTransaction(opts) {
|
|
1953
|
+
verifyCloseWith(opts, pinnedRegistryTrust());
|
|
1954
|
+
}
|
|
1955
|
+
function verifyCloseWith(opts, trust) {
|
|
1765
1956
|
const intent = intentFromXdr(opts.unsignedXdr, NETWORK_PASSPHRASES[opts.network]);
|
|
1766
|
-
const registry = registryView(opts.servedRegistry, opts.network);
|
|
1957
|
+
const registry = registryView(opts.servedRegistry, opts.network, trust);
|
|
1767
1958
|
const exchange = registry.lookup(opts.expected.destination);
|
|
1768
1959
|
if (exchange !== null && !registry.usable()) {
|
|
1769
1960
|
throw new VerificationError(
|
|
@@ -1777,8 +1968,7 @@ function verifyCloseTransaction(opts) {
|
|
|
1777
1968
|
[...Object.values(opts.expected.transfers), ...Object.values(opts.expected.tokenTransfers)],
|
|
1778
1969
|
registry.lookup
|
|
1779
1970
|
),
|
|
1780
|
-
|
|
1781
|
-
mediatorRequired: mediatorAllowedFor(opts.expected.destination, opts.network),
|
|
1971
|
+
mediatorRequired: registry.mediatorAllowed(opts.expected.destination),
|
|
1782
1972
|
directMergeRefused: exchange?.requiresMediator ?? false,
|
|
1783
1973
|
memoRequired: exchange?.requiresMemo ?? false,
|
|
1784
1974
|
memoType: exchange === null ? opts.expected.memoType : listedMemoType(exchange, registry, opts.network, opts.expected),
|
|
@@ -2181,13 +2371,13 @@ var contract_registry_default = {
|
|
|
2181
2371
|
protocol: "aquarius",
|
|
2182
2372
|
kind: "router",
|
|
2183
2373
|
address: "CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK",
|
|
2184
|
-
wasmHash: "
|
|
2374
|
+
wasmHash: "2f8e7d7f237eca17e188c4e5d08b73b0065584b3d39f9e1d801993a8510a3107",
|
|
2185
2375
|
version: "v1",
|
|
2186
|
-
label: "Aquarius AMM router (mainnet, docs.aqua.network; stellar.expert: 'Aquarius Router') - enumerates the pools; never a call target of an exit;
|
|
2376
|
+
label: "Aquarius AMM router (mainnet, docs.aqua.network; stellar.expert: 'Aquarius Router') - enumerates the pools; never a call target of an exit; re-pinned 2026-11-25 after an upstream upgrade (every earlier function unchanged; swap_split, get_reward_token and get_reward_token_count added)",
|
|
2187
2377
|
verifiedLive: true,
|
|
2188
|
-
verifiedBy: "2026-
|
|
2378
|
+
verifiedBy: "2026-10-10 (#581): address matched against docs.aqua.network; 2026-11-25 (#1121): re-pinned after commit_upgrade tx 060f587341861b30d3c434b62d49d36ed006fe987b535a5771a3165d162ef7ae (ledger 65560332) and apply_upgrade tx 0169293062a1177282f3ddd8ea3ad7f8418bb3404b54a5b1bbe870c7ffaef3ae (ledger 65663788), each signed 2 of 3 by the router's Admin account; plain Wasm, version() 222; no public source, so trusted by spec and host-import diff and a live read of all 392 pools",
|
|
2189
2379
|
source: "docs.aqua.network/developers/reference/addresses-and-networks; stellar.expert directory 'Aquarius Router'",
|
|
2190
|
-
verifiedAt: "2026-11-
|
|
2380
|
+
verifiedAt: "2026-11-25"
|
|
2191
2381
|
},
|
|
2192
2382
|
{
|
|
2193
2383
|
network: "mainnet",
|
|
@@ -2932,8 +3122,8 @@ function exitExpectations2(accountState, network) {
|
|
|
2932
3122
|
function poolWithdrawalExpectations2(accountState) {
|
|
2933
3123
|
return poolWithdrawalExpectations(accountState);
|
|
2934
3124
|
}
|
|
2935
|
-
function requiresMediator(address, network) {
|
|
2936
|
-
return
|
|
3125
|
+
function requiresMediator(address, network, servedRegistry) {
|
|
3126
|
+
return mediatorAllowedUnder(address, network, servedRegistry);
|
|
2937
3127
|
}
|
|
2938
3128
|
function verifyRevokeAllowanceTransaction2(unsignedXdr, networkPassphrase, expected, nowSeconds) {
|
|
2939
3129
|
verifyRevokeAllowanceTransaction(unsignedXdr, networkPassphrase, expected, nowSeconds);
|
package/dist/index.d.cts
CHANGED
|
@@ -345,6 +345,21 @@ export declare interface ExchangeRegistryEntry {
|
|
|
345
345
|
network?: "testnet";
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
+
/**
|
|
349
|
+
* A maintainer signature over the exchange registry (an Ed25519 signature over the canonical JSON
|
|
350
|
+
* of the registry fields, this envelope's `sequence` and `issuedAt`, under a fixed domain label).
|
|
351
|
+
* `@lumenwipe/verify` checks it against the keys pinned in its release.
|
|
352
|
+
*/
|
|
353
|
+
export declare interface ExchangeRegistrySignature {
|
|
354
|
+
format: 1;
|
|
355
|
+
/** Rises by one with every signed registry. */
|
|
356
|
+
sequence: number;
|
|
357
|
+
/** The day it was signed (YYYY-MM-DD, UTC). */
|
|
358
|
+
issuedAt: string;
|
|
359
|
+
/** Base64 of the 64-byte signature. */
|
|
360
|
+
signature: string;
|
|
361
|
+
}
|
|
362
|
+
|
|
348
363
|
/**
|
|
349
364
|
* The DeFi half of the expectation. Build it with {@link exitExpectations} from the account read
|
|
350
365
|
* the user reviewed, never by hand from a plan: it combines that read with the registries bundled
|
|
@@ -487,14 +502,15 @@ export declare interface PoolWithdrawalExpectation {
|
|
|
487
502
|
export declare function poolWithdrawalExpectations(accountState: AccountState | null | undefined): Record<string, PoolWithdrawalExpectation>;
|
|
488
503
|
|
|
489
504
|
/**
|
|
490
|
-
* Whether a close to `address` on `network` goes through the shared intermediary: true
|
|
491
|
-
*
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
505
|
+
* Whether a close to `address` on `network` goes through the shared intermediary: true for an
|
|
506
|
+
* exchange the registry bundled in this package lists, on that network, as unable to receive an
|
|
507
|
+
* account merge, and for one a verified signature on `servedRegistry` adds. An entry scoped to
|
|
508
|
+
* testnet never answers true on mainnet. The same rule `verifyCloseTransaction` applies, so an
|
|
509
|
+
* integrator decides from it, never from the API's response, whether a transaction needs the
|
|
510
|
+
* intermediary's co-signature. Pass the same snapshot you pass to `verifyCloseTransaction`;
|
|
511
|
+
* without one, or with an unsigned one, only the bundled registry answers.
|
|
496
512
|
*/
|
|
497
|
-
export declare function requiresMediator(address: string, network: Network): boolean;
|
|
513
|
+
export declare function requiresMediator(address: string, network: Network, servedRegistry?: ServedRegistry): boolean;
|
|
498
514
|
|
|
499
515
|
/**
|
|
500
516
|
* Every reason the revocation anchor refuses a transaction, one stable code each, in the order the
|
|
@@ -532,21 +548,30 @@ export declare type RevokeAllowanceVerificationErrorCode = (typeof REVOKE_ALLOWA
|
|
|
532
548
|
|
|
533
549
|
/**
|
|
534
550
|
* A served exchange registry: the body of `GET /v1/config/exchange-registry` (the SDK's
|
|
535
|
-
* `client.getExchangeRegistry()`), passed as is
|
|
551
|
+
* `client.getExchangeRegistry()`), passed as is, with its `signature`.
|
|
536
552
|
*
|
|
537
|
-
*
|
|
538
|
-
* registry bundled in this package and can only make
|
|
553
|
+
* Without a signature that verifies, it is not authenticated, and it does not need to be for what
|
|
554
|
+
* it can do: it is merged over the registry bundled in this package and can only make
|
|
555
|
+
* verification stricter.
|
|
539
556
|
*
|
|
540
557
|
* - A bundled exchange is never removed, and its memo requirement and its refusal of a direct
|
|
541
558
|
* merge are never turned off.
|
|
542
559
|
* - An address it adds is checked as an exchange: a direct merge into it is refused when it
|
|
543
560
|
* needs the intermediary, a memo is required when it needs one, and a transfer to it is refused.
|
|
544
|
-
* -
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
*
|
|
561
|
+
* - Its `signature` is an Ed25519 signature by one of the two registry keys pinned in this
|
|
562
|
+
* release, over the registry fields (`version`, `lastVerified`, `validUntil`, `source`,
|
|
563
|
+
* `entries`) with a sequence and an issue date. It verifies only when it is by a pinned key, is
|
|
564
|
+
* not older than the registry bundled here (its sequence is at least the bundled one), has not
|
|
565
|
+
* passed its `validUntil` by this machine's clock, and is not dated more than a day ahead.
|
|
566
|
+
* Anything else, including a missing or truncated signature, leaves the snapshot unsigned.
|
|
567
|
+
* - Only a verified signature enables the mediated hand-off, and only for an address it adds that
|
|
568
|
+
* needs the intermediary ({@link requiresMediator}). An address an unsigned snapshot lists as
|
|
569
|
+
* needing the intermediary refuses both shapes until this package is updated. The signature
|
|
570
|
+
* gates the shape; it does not vouch for the account a mediated close merges into.
|
|
571
|
+
* - A verified signature adds exchanges and nothing else. It never changes a bundled entry, the
|
|
572
|
+
* network a bundled exchange applies on, or a memo type: a testnet-only entry stays unlisted
|
|
573
|
+
* on mainnet, and an entry it adds with `network: "testnet"` applies on testnet only; any other
|
|
574
|
+
* `network` value drops it.
|
|
550
575
|
* - Its `validUntil` may move the bundled expiry later, by at most 120 days, never earlier.
|
|
551
576
|
* - It never decides a memo type. A different type for a bundled exchange is refused with
|
|
552
577
|
* `registry_memo_type_conflict`, and a type for an address it adds that differs from the one
|
|
@@ -558,10 +583,17 @@ export declare type RevokeAllowanceVerificationErrorCode = (typeof REVOKE_ALLOWA
|
|
|
558
583
|
export declare interface ServedRegistry {
|
|
559
584
|
/** The listed exchanges. An entry that is not well formed is dropped. */
|
|
560
585
|
entries: ExchangeRegistryEntry[];
|
|
561
|
-
/** When the entries were last checked (YYYY-MM-DD).
|
|
586
|
+
/** When the entries were last checked (YYYY-MM-DD). Covered by the signature. */
|
|
562
587
|
lastVerified: string;
|
|
563
588
|
/** The date (YYYY-MM-DD) after which the registry is not relied on. */
|
|
564
589
|
validUntil: string;
|
|
590
|
+
/** The registry's version. Covered by the signature, so pass it as served. */
|
|
591
|
+
version?: string;
|
|
592
|
+
/** Where the entries come from. Covered by the signature, so pass it as served. */
|
|
593
|
+
source?: string;
|
|
594
|
+
/** The maintainers' signature, as served. Omit it, or pass a copy that fails to verify, and
|
|
595
|
+
* the snapshot can only make verification stricter. */
|
|
596
|
+
signature?: ExchangeRegistrySignature;
|
|
565
597
|
}
|
|
566
598
|
|
|
567
599
|
/** A SEP-41 token balance the account holds in a contract's storage - not a classic trustline. */
|
package/dist/index.d.ts
CHANGED
|
@@ -345,6 +345,21 @@ export declare interface ExchangeRegistryEntry {
|
|
|
345
345
|
network?: "testnet";
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
+
/**
|
|
349
|
+
* A maintainer signature over the exchange registry (an Ed25519 signature over the canonical JSON
|
|
350
|
+
* of the registry fields, this envelope's `sequence` and `issuedAt`, under a fixed domain label).
|
|
351
|
+
* `@lumenwipe/verify` checks it against the keys pinned in its release.
|
|
352
|
+
*/
|
|
353
|
+
export declare interface ExchangeRegistrySignature {
|
|
354
|
+
format: 1;
|
|
355
|
+
/** Rises by one with every signed registry. */
|
|
356
|
+
sequence: number;
|
|
357
|
+
/** The day it was signed (YYYY-MM-DD, UTC). */
|
|
358
|
+
issuedAt: string;
|
|
359
|
+
/** Base64 of the 64-byte signature. */
|
|
360
|
+
signature: string;
|
|
361
|
+
}
|
|
362
|
+
|
|
348
363
|
/**
|
|
349
364
|
* The DeFi half of the expectation. Build it with {@link exitExpectations} from the account read
|
|
350
365
|
* the user reviewed, never by hand from a plan: it combines that read with the registries bundled
|
|
@@ -487,14 +502,15 @@ export declare interface PoolWithdrawalExpectation {
|
|
|
487
502
|
export declare function poolWithdrawalExpectations(accountState: AccountState | null | undefined): Record<string, PoolWithdrawalExpectation>;
|
|
488
503
|
|
|
489
504
|
/**
|
|
490
|
-
* Whether a close to `address` on `network` goes through the shared intermediary: true
|
|
491
|
-
*
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
505
|
+
* Whether a close to `address` on `network` goes through the shared intermediary: true for an
|
|
506
|
+
* exchange the registry bundled in this package lists, on that network, as unable to receive an
|
|
507
|
+
* account merge, and for one a verified signature on `servedRegistry` adds. An entry scoped to
|
|
508
|
+
* testnet never answers true on mainnet. The same rule `verifyCloseTransaction` applies, so an
|
|
509
|
+
* integrator decides from it, never from the API's response, whether a transaction needs the
|
|
510
|
+
* intermediary's co-signature. Pass the same snapshot you pass to `verifyCloseTransaction`;
|
|
511
|
+
* without one, or with an unsigned one, only the bundled registry answers.
|
|
496
512
|
*/
|
|
497
|
-
export declare function requiresMediator(address: string, network: Network): boolean;
|
|
513
|
+
export declare function requiresMediator(address: string, network: Network, servedRegistry?: ServedRegistry): boolean;
|
|
498
514
|
|
|
499
515
|
/**
|
|
500
516
|
* Every reason the revocation anchor refuses a transaction, one stable code each, in the order the
|
|
@@ -532,21 +548,30 @@ export declare type RevokeAllowanceVerificationErrorCode = (typeof REVOKE_ALLOWA
|
|
|
532
548
|
|
|
533
549
|
/**
|
|
534
550
|
* A served exchange registry: the body of `GET /v1/config/exchange-registry` (the SDK's
|
|
535
|
-
* `client.getExchangeRegistry()`), passed as is
|
|
551
|
+
* `client.getExchangeRegistry()`), passed as is, with its `signature`.
|
|
536
552
|
*
|
|
537
|
-
*
|
|
538
|
-
* registry bundled in this package and can only make
|
|
553
|
+
* Without a signature that verifies, it is not authenticated, and it does not need to be for what
|
|
554
|
+
* it can do: it is merged over the registry bundled in this package and can only make
|
|
555
|
+
* verification stricter.
|
|
539
556
|
*
|
|
540
557
|
* - A bundled exchange is never removed, and its memo requirement and its refusal of a direct
|
|
541
558
|
* merge are never turned off.
|
|
542
559
|
* - An address it adds is checked as an exchange: a direct merge into it is refused when it
|
|
543
560
|
* needs the intermediary, a memo is required when it needs one, and a transfer to it is refused.
|
|
544
|
-
* -
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
*
|
|
561
|
+
* - Its `signature` is an Ed25519 signature by one of the two registry keys pinned in this
|
|
562
|
+
* release, over the registry fields (`version`, `lastVerified`, `validUntil`, `source`,
|
|
563
|
+
* `entries`) with a sequence and an issue date. It verifies only when it is by a pinned key, is
|
|
564
|
+
* not older than the registry bundled here (its sequence is at least the bundled one), has not
|
|
565
|
+
* passed its `validUntil` by this machine's clock, and is not dated more than a day ahead.
|
|
566
|
+
* Anything else, including a missing or truncated signature, leaves the snapshot unsigned.
|
|
567
|
+
* - Only a verified signature enables the mediated hand-off, and only for an address it adds that
|
|
568
|
+
* needs the intermediary ({@link requiresMediator}). An address an unsigned snapshot lists as
|
|
569
|
+
* needing the intermediary refuses both shapes until this package is updated. The signature
|
|
570
|
+
* gates the shape; it does not vouch for the account a mediated close merges into.
|
|
571
|
+
* - A verified signature adds exchanges and nothing else. It never changes a bundled entry, the
|
|
572
|
+
* network a bundled exchange applies on, or a memo type: a testnet-only entry stays unlisted
|
|
573
|
+
* on mainnet, and an entry it adds with `network: "testnet"` applies on testnet only; any other
|
|
574
|
+
* `network` value drops it.
|
|
550
575
|
* - Its `validUntil` may move the bundled expiry later, by at most 120 days, never earlier.
|
|
551
576
|
* - It never decides a memo type. A different type for a bundled exchange is refused with
|
|
552
577
|
* `registry_memo_type_conflict`, and a type for an address it adds that differs from the one
|
|
@@ -558,10 +583,17 @@ export declare type RevokeAllowanceVerificationErrorCode = (typeof REVOKE_ALLOWA
|
|
|
558
583
|
export declare interface ServedRegistry {
|
|
559
584
|
/** The listed exchanges. An entry that is not well formed is dropped. */
|
|
560
585
|
entries: ExchangeRegistryEntry[];
|
|
561
|
-
/** When the entries were last checked (YYYY-MM-DD).
|
|
586
|
+
/** When the entries were last checked (YYYY-MM-DD). Covered by the signature. */
|
|
562
587
|
lastVerified: string;
|
|
563
588
|
/** The date (YYYY-MM-DD) after which the registry is not relied on. */
|
|
564
589
|
validUntil: string;
|
|
590
|
+
/** The registry's version. Covered by the signature, so pass it as served. */
|
|
591
|
+
version?: string;
|
|
592
|
+
/** Where the entries come from. Covered by the signature, so pass it as served. */
|
|
593
|
+
source?: string;
|
|
594
|
+
/** The maintainers' signature, as served. Omit it, or pass a copy that fails to verify, and
|
|
595
|
+
* the snapshot can only make verification stricter. */
|
|
596
|
+
signature?: ExchangeRegistrySignature;
|
|
565
597
|
}
|
|
566
598
|
|
|
567
599
|
/** A SEP-41 token balance the account holds in a contract's storage - not a classic trustline. */
|