@lumenwipe/verify 0.2.0 → 0.4.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 +43 -1
- package/README.md +52 -5
- package/dist/index.cjs +165 -28
- package/dist/index.d.cts +72 -5
- package/dist/index.d.ts +72 -5
- package/dist/index.js +164 -29
- package/package.json +3 -2
- package/vectors/close-v1.json +373 -0
- package/vectors/revoke-allowance-v1.json +437 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@lumenwipe/verify`: the verifier the LumenWipe web app runs before every signature, compiled
|
|
3
|
-
* from the web's own modules rather than copied
|
|
3
|
+
* from the web's own modules rather than copied, together with the web's trust anchor for an
|
|
4
|
+
* allowance revocation. There is one implementation; this file only
|
|
4
5
|
* gives it explicit, documented types. `tests/types.test.ts` pins every type below to the web
|
|
5
6
|
* signature in both directions, so a change on either side fails the build.
|
|
6
7
|
*
|
|
@@ -324,6 +325,8 @@ export declare interface ExchangeRegistryEntry {
|
|
|
324
325
|
requiresMemo: boolean;
|
|
325
326
|
/** The required memo type, if `requiresMemo` is true. */
|
|
326
327
|
memoType: "text" | "id" | "hash";
|
|
328
|
+
/** Present only on an entry scoped to testnet. Absent means the entry applies on every network. */
|
|
329
|
+
network?: "testnet";
|
|
327
330
|
}
|
|
328
331
|
|
|
329
332
|
/**
|
|
@@ -411,6 +414,9 @@ declare interface PhoenixStakePosition extends DefiPositionBase {
|
|
|
411
414
|
stakedAmount: string;
|
|
412
415
|
/** Unix seconds; unbonding requires the original stake's timestamp (architecture.md §9.6). */
|
|
413
416
|
stakedAtEpoch: string;
|
|
417
|
+
/** The pool's LP share token (`CONFIG.share_token`): unbonding returns the shares to it, and the
|
|
418
|
+
* withdrawal that follows transfers them back to the pool. Read from the pool. */
|
|
419
|
+
shareToken?: string;
|
|
414
420
|
}
|
|
415
421
|
|
|
416
422
|
declare interface PlanBlocker {
|
|
@@ -426,13 +432,48 @@ declare interface PoolShareEntry {
|
|
|
426
432
|
}
|
|
427
433
|
|
|
428
434
|
/**
|
|
429
|
-
* Whether a close to `address` goes through the shared intermediary: true only for
|
|
430
|
-
* the registry bundled in this package lists as unable to receive
|
|
431
|
-
*
|
|
435
|
+
* Whether a close to `address` on `network` goes through the shared intermediary: true only for
|
|
436
|
+
* an exchange the registry bundled in this package lists, on that network, as unable to receive
|
|
437
|
+
* an account merge. An entry scoped to testnet never answers true on mainnet. The same rule
|
|
438
|
+
* `verifyCloseTransaction` applies, so an integrator decides from it, never from the API's
|
|
432
439
|
* response, whether a transaction needs the intermediary's co-signature. A served snapshot never
|
|
433
440
|
* changes this answer, so it takes none.
|
|
434
441
|
*/
|
|
435
|
-
export declare function requiresMediator(address: string): boolean;
|
|
442
|
+
export declare function requiresMediator(address: string, network: Network): boolean;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Every reason the revocation anchor refuses a transaction, one stable code each, in the order the
|
|
446
|
+
* checks run. The code is the contract an integrator branches on; the message is the current
|
|
447
|
+
* English wording and may change. Each code carries a `revoke_` prefix so it never shares a value
|
|
448
|
+
* with a close `VerificationErrorCode`.
|
|
449
|
+
*/
|
|
450
|
+
declare const REVOKE_ALLOWANCE_VERIFICATION_ERROR_CODES: readonly ["revoke_expiry_missing", "revoke_expiry_too_far", "revoke_transaction_source_mismatch", "revoke_memo_present", "revoke_fee_above_cap", "revoke_operation_count", "revoke_operation_source_mismatch", "revoke_not_invocation", "revoke_token_mismatch", "revoke_function_not_approve", "revoke_approve_args_mismatch", "revoke_auth_beyond_self", "revoke_auth_nested", "revoke_address_unsupported", "revoke_foreign_account", "revoke_foreign_contract"];
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* What the screen showed the user before they approved an allowance revocation: the allowance
|
|
454
|
+
* the revocation must zero, and nothing else. Every value is one the integrator already displayed,
|
|
455
|
+
* never one read from the transaction under verification.
|
|
456
|
+
*/
|
|
457
|
+
export declare interface RevokeAllowanceExpectation {
|
|
458
|
+
/** The account whose allowance is revoked. The transaction and its one operation must be
|
|
459
|
+
* sourced from it, and it is the only account the call may authorize. */
|
|
460
|
+
owner: string;
|
|
461
|
+
/** The token contract (`C...`) `approve` is called on. */
|
|
462
|
+
token: string;
|
|
463
|
+
/** The spender whose allowance goes to zero: a contract (`C...`) or, less often, an account
|
|
464
|
+
* (`G...`). */
|
|
465
|
+
spender: string;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/** Thrown when a server-built allowance revocation fails verification. Never sign past this. */
|
|
469
|
+
export declare class RevokeAllowanceVerificationError extends Error {
|
|
470
|
+
/** Why the transaction was refused. Stable across releases, unlike the message. */
|
|
471
|
+
readonly code: RevokeAllowanceVerificationErrorCode;
|
|
472
|
+
constructor(code: RevokeAllowanceVerificationErrorCode, message: string);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/** The reason a {@link RevokeAllowanceVerificationError} was thrown. */
|
|
476
|
+
export declare type RevokeAllowanceVerificationErrorCode = (typeof REVOKE_ALLOWANCE_VERIFICATION_ERROR_CODES)[number];
|
|
436
477
|
|
|
437
478
|
/**
|
|
438
479
|
* A served exchange registry: the body of `GET /v1/config/exchange-registry` (the SDK's
|
|
@@ -448,6 +489,9 @@ export declare function requiresMediator(address: string): boolean;
|
|
|
448
489
|
* - It never enables the mediated hand-off. That stays limited to the exchanges the bundled
|
|
449
490
|
* registry lists ({@link requiresMediator}), so an address only the snapshot lists as needing
|
|
450
491
|
* the intermediary refuses both shapes until this package is updated.
|
|
492
|
+
* - It never changes the network a bundled exchange applies on: a testnet-only entry stays
|
|
493
|
+
* unlisted on mainnet, and an entry listed on every network stays listed on both. An entry it
|
|
494
|
+
* adds with `network: "testnet"` applies on testnet only; any other `network` value drops it.
|
|
451
495
|
* - Its `validUntil` may move the bundled expiry later, by at most 120 days, never earlier.
|
|
452
496
|
* - It never decides a memo type. A different type for a bundled exchange is refused with
|
|
453
497
|
* `registry_memo_type_conflict`, and a type for an address it adds that differs from the one
|
|
@@ -651,4 +695,27 @@ export declare interface VerifyCloseInput {
|
|
|
651
695
|
*/
|
|
652
696
|
export declare function verifyCloseTransaction(input: VerifyCloseInput): void;
|
|
653
697
|
|
|
698
|
+
/**
|
|
699
|
+
* Decodes an API-built, unsigned allowance revocation and asserts it is exactly
|
|
700
|
+
* `approve(owner, spender, 0, expiration)` on `token`: one operation, sourced from `owner`, no
|
|
701
|
+
* memo, a fee of at most 10,000,000 stroops, valid for at most 900 seconds after `nowSeconds`,
|
|
702
|
+
* authorized only by the owner's own source account with no nested call, and naming no other
|
|
703
|
+
* account or contract. Returns only when the transaction may be signed.
|
|
704
|
+
*
|
|
705
|
+
* What it guarantees is that the signed transaction does what the screen said, so an API cannot
|
|
706
|
+
* swap the token or the spender between what was shown and what is signed. It does not judge
|
|
707
|
+
* whether the shown allowance is worth revoking.
|
|
708
|
+
*
|
|
709
|
+
* Throws {@link RevokeAllowanceVerificationError} with a stable `code` on any mismatch, or
|
|
710
|
+
* {@link VerificationError} when the envelope cannot be decoded at all (for example a text memo
|
|
711
|
+
* that is not valid UTF-8). Synchronous and offline: it reads no network and no page state, and
|
|
712
|
+
* keeps no state between calls. Run it once per transaction, immediately before the signature.
|
|
713
|
+
*
|
|
714
|
+
* @param unsignedXdr - The unsigned transaction envelope as returned by the API, base64.
|
|
715
|
+
* @param networkPassphrase - The passphrase of the network the revocation runs on.
|
|
716
|
+
* @param expected - The allowance the screen showed.
|
|
717
|
+
* @param nowSeconds - The current Unix time in seconds; defaults to the system clock.
|
|
718
|
+
*/
|
|
719
|
+
export declare function verifyRevokeAllowanceTransaction(unsignedXdr: string, networkPassphrase: string, expected: RevokeAllowanceExpectation, nowSeconds?: number): void;
|
|
720
|
+
|
|
654
721
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -170,18 +170,36 @@ var exchange_registry_default = {
|
|
|
170
170
|
requiresMediator: true,
|
|
171
171
|
requiresMemo: true,
|
|
172
172
|
memoType: "text"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
address: "GB4VXLVR2DDIJUPVVY74QVPEIHINBMMXO6WUY67JUEYO42LQSDS5IMKW",
|
|
176
|
+
name: "LumenWipe testnet exchange",
|
|
177
|
+
domain: "lumenwipe.com",
|
|
178
|
+
requiresMediator: true,
|
|
179
|
+
requiresMemo: true,
|
|
180
|
+
memoType: "id",
|
|
181
|
+
network: "testnet"
|
|
173
182
|
}
|
|
174
183
|
]
|
|
175
184
|
};
|
|
176
185
|
|
|
177
186
|
// ../../apps/web/lib/exchange-registry/merge.ts
|
|
187
|
+
function appliesOn(entry, network) {
|
|
188
|
+
return entry.network === void 0 || entry.network === network;
|
|
189
|
+
}
|
|
178
190
|
function isUsableEntry(e) {
|
|
179
191
|
if (typeof e !== "object" || e === null) return false;
|
|
180
192
|
const r = e;
|
|
181
|
-
return typeof r.address === "string" && r.address.startsWith("G") && r.address.length === 56 && typeof r.name === "string" && typeof r.requiresMediator === "boolean" && typeof r.requiresMemo === "boolean" && (r.memoType === "text" || r.memoType === "id" || r.memoType === "hash");
|
|
193
|
+
return typeof r.address === "string" && r.address.startsWith("G") && r.address.length === 56 && typeof r.name === "string" && typeof r.requiresMediator === "boolean" && typeof r.requiresMemo === "boolean" && (r.memoType === "text" || r.memoType === "id" || r.memoType === "hash") && (!("network" in r) || r.network === "testnet");
|
|
194
|
+
}
|
|
195
|
+
function bundledEntries(raw) {
|
|
196
|
+
if (!Array.isArray(raw)) throw new Error("The bundled exchange registry has no entries list.");
|
|
197
|
+
const bad = raw.findIndex((e) => !isUsableEntry(e));
|
|
198
|
+
if (bad !== -1) throw new Error(`The bundled exchange registry entry ${bad} is malformed.`);
|
|
199
|
+
return raw;
|
|
182
200
|
}
|
|
183
201
|
function tightenedOver(embeddedEntry, servedEntry) {
|
|
184
|
-
|
|
202
|
+
const tightened = {
|
|
185
203
|
...servedEntry,
|
|
186
204
|
requiresMemo: embeddedEntry.requiresMemo || servedEntry.requiresMemo,
|
|
187
205
|
requiresMediator: embeddedEntry.requiresMediator || servedEntry.requiresMediator,
|
|
@@ -190,6 +208,9 @@ function tightenedOver(embeddedEntry, servedEntry) {
|
|
|
190
208
|
// (`mergeServedRegistry`) and the close is refused until the bundled copy is updated.
|
|
191
209
|
memoType: embeddedEntry.memoType
|
|
192
210
|
};
|
|
211
|
+
if (embeddedEntry.network === void 0) delete tightened.network;
|
|
212
|
+
else tightened.network = embeddedEntry.network;
|
|
213
|
+
return tightened;
|
|
193
214
|
}
|
|
194
215
|
var MAX_EXTENSION_DAYS = 120;
|
|
195
216
|
function boundedValidUntil(embeddedUntil, servedUntil) {
|
|
@@ -232,15 +253,12 @@ function isUsableAt(validUntil, now) {
|
|
|
232
253
|
}
|
|
233
254
|
|
|
234
255
|
// ../../apps/web/lib/exchange-registry/index.ts
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
var EMBEDDED = snapshotFrom(exchange_registry_default, false);
|
|
256
|
+
var EMBEDDED = {
|
|
257
|
+
entries: bundledEntries(exchange_registry_default.entries),
|
|
258
|
+
lastVerified: exchange_registry_default.lastVerified,
|
|
259
|
+
validUntil: exchange_registry_default.validUntil,
|
|
260
|
+
served: false
|
|
261
|
+
};
|
|
244
262
|
var current = EMBEDDED;
|
|
245
263
|
function bundledRegistry() {
|
|
246
264
|
return EMBEDDED;
|
|
@@ -248,14 +266,17 @@ function bundledRegistry() {
|
|
|
248
266
|
function isRegistryUsable(now = /* @__PURE__ */ new Date()) {
|
|
249
267
|
return isUsableAt(current.validUntil, now);
|
|
250
268
|
}
|
|
251
|
-
function byAddress() {
|
|
252
|
-
return new Map(current.entries.map((e) => [e.address, e]));
|
|
269
|
+
function byAddress(network) {
|
|
270
|
+
return new Map(current.entries.filter((e) => appliesOn(e, network)).map((e) => [e.address, e]));
|
|
253
271
|
}
|
|
254
|
-
function lookupExchange(address) {
|
|
255
|
-
return byAddress().get(address) ?? null;
|
|
272
|
+
function lookupExchange(address, network) {
|
|
273
|
+
return byAddress(network).get(address) ?? null;
|
|
256
274
|
}
|
|
257
|
-
function
|
|
258
|
-
return EMBEDDED.entries.find((e) => e.address === address)
|
|
275
|
+
function bundledExchange(address, network) {
|
|
276
|
+
return EMBEDDED.entries.find((e) => e.address === address && appliesOn(e, network)) ?? null;
|
|
277
|
+
}
|
|
278
|
+
function mediatorAllowedFor(address, network) {
|
|
279
|
+
return bundledExchange(address, network)?.requiresMediator === true;
|
|
259
280
|
}
|
|
260
281
|
function memoTypeInDispute(address) {
|
|
261
282
|
return current.memoTypeDisputes?.includes(address) ?? false;
|
|
@@ -1453,9 +1474,13 @@ function depositAddressesOf(transfers, lookup) {
|
|
|
1453
1474
|
}
|
|
1454
1475
|
return listed;
|
|
1455
1476
|
}
|
|
1456
|
-
function registryView(served) {
|
|
1477
|
+
function registryView(served, network) {
|
|
1457
1478
|
if (served === void 0) {
|
|
1458
|
-
return {
|
|
1479
|
+
return {
|
|
1480
|
+
lookup: (address) => lookupExchange(address, network),
|
|
1481
|
+
usable: () => isRegistryUsable(),
|
|
1482
|
+
memoTypeInDispute
|
|
1483
|
+
};
|
|
1459
1484
|
}
|
|
1460
1485
|
const merged = mergeServedRegistry(bundledRegistry(), served);
|
|
1461
1486
|
if (merged === null) {
|
|
@@ -1464,7 +1489,9 @@ function registryView(served) {
|
|
|
1464
1489
|
"The exchange registry passed to the verifier is not a registry (it needs an entries list, lastVerified and validUntil), so this close cannot be checked against it."
|
|
1465
1490
|
);
|
|
1466
1491
|
}
|
|
1467
|
-
const byAddress2 = new Map(
|
|
1492
|
+
const byAddress2 = new Map(
|
|
1493
|
+
merged.entries.filter((e) => appliesOn(e, network)).map((e) => [e.address, e])
|
|
1494
|
+
);
|
|
1468
1495
|
const disputes = new Set(merged.memoTypeDisputes);
|
|
1469
1496
|
return {
|
|
1470
1497
|
lookup: (address) => byAddress2.get(address) ?? null,
|
|
@@ -1472,15 +1499,14 @@ function registryView(served) {
|
|
|
1472
1499
|
memoTypeInDispute: (address) => disputes.has(address)
|
|
1473
1500
|
};
|
|
1474
1501
|
}
|
|
1475
|
-
function listedMemoType(exchange, registry, expected) {
|
|
1502
|
+
function listedMemoType(exchange, registry, network, expected) {
|
|
1476
1503
|
if (registry.memoTypeInDispute(expected.destination)) {
|
|
1477
1504
|
throw new VerificationError(
|
|
1478
1505
|
"registry_memo_type_conflict",
|
|
1479
1506
|
`The served exchange registry gives ${exchange.name} a different memo type than the bundled one, so the memo this close needs cannot be checked.`
|
|
1480
1507
|
);
|
|
1481
1508
|
}
|
|
1482
|
-
|
|
1483
|
-
if (bundled) return exchange.memoType;
|
|
1509
|
+
if (bundledExchange(expected.destination, network) !== null) return exchange.memoType;
|
|
1484
1510
|
if (expected.memo !== null && expected.memoType !== null && expected.memoType !== exchange.memoType) {
|
|
1485
1511
|
throw new VerificationError(
|
|
1486
1512
|
"registry_memo_type_unconfirmed",
|
|
@@ -1491,7 +1517,7 @@ function listedMemoType(exchange, registry, expected) {
|
|
|
1491
1517
|
}
|
|
1492
1518
|
function verifyCloseTransaction(opts) {
|
|
1493
1519
|
const intent = intentFromXdr(opts.unsignedXdr, NETWORK_PASSPHRASES[opts.network]);
|
|
1494
|
-
const registry = registryView(opts.servedRegistry);
|
|
1520
|
+
const registry = registryView(opts.servedRegistry, opts.network);
|
|
1495
1521
|
const exchange = registry.lookup(opts.expected.destination);
|
|
1496
1522
|
if (exchange !== null && !registry.usable()) {
|
|
1497
1523
|
throw new VerificationError(
|
|
@@ -1506,10 +1532,10 @@ function verifyCloseTransaction(opts) {
|
|
|
1506
1532
|
registry.lookup
|
|
1507
1533
|
),
|
|
1508
1534
|
// From the bundled copy alone, whatever was served: see `registryView`.
|
|
1509
|
-
mediatorRequired: mediatorAllowedFor(opts.expected.destination),
|
|
1535
|
+
mediatorRequired: mediatorAllowedFor(opts.expected.destination, opts.network),
|
|
1510
1536
|
directMergeRefused: exchange?.requiresMediator ?? false,
|
|
1511
1537
|
memoRequired: exchange?.requiresMemo ?? false,
|
|
1512
|
-
memoType: exchange === null ? opts.expected.memoType : listedMemoType(exchange, registry, opts.expected),
|
|
1538
|
+
memoType: exchange === null ? opts.expected.memoType : listedMemoType(exchange, registry, opts.network, opts.expected),
|
|
1513
1539
|
nowSeconds: Math.floor(Date.now() / 1e3),
|
|
1514
1540
|
preAuthorized: opts.preAuthorized === true
|
|
1515
1541
|
});
|
|
@@ -2353,6 +2379,112 @@ function exitExpectations(accountState, network) {
|
|
|
2353
2379
|
};
|
|
2354
2380
|
}
|
|
2355
2381
|
|
|
2382
|
+
// ../../apps/web/lib/stellar/verify-revoke-allowance.ts
|
|
2383
|
+
var MAX_REVOKE_FEE_STROOPS = BigInt(1e7);
|
|
2384
|
+
var MAX_VALIDITY_SECONDS2 = BigInt(900);
|
|
2385
|
+
var RevokeAllowanceVerificationError = class extends Error {
|
|
2386
|
+
constructor(code, message) {
|
|
2387
|
+
super(message);
|
|
2388
|
+
this.name = "RevokeAllowanceVerificationError";
|
|
2389
|
+
this.code = code;
|
|
2390
|
+
}
|
|
2391
|
+
};
|
|
2392
|
+
function fail(code, message) {
|
|
2393
|
+
throw new RevokeAllowanceVerificationError(code, message);
|
|
2394
|
+
}
|
|
2395
|
+
function verifyRevokeAllowanceTransaction(xdr2, networkPassphrase, expected, nowSeconds = Math.floor(Date.now() / 1e3)) {
|
|
2396
|
+
const intent = intentFromXdr(xdr2, networkPassphrase);
|
|
2397
|
+
const maxTime = intent.maxTime ?? null;
|
|
2398
|
+
if (maxTime === null || !/^\d+$/.test(maxTime)) {
|
|
2399
|
+
fail(
|
|
2400
|
+
"revoke_expiry_missing",
|
|
2401
|
+
"This transaction never expires, so it could be submitted long after you approved it."
|
|
2402
|
+
);
|
|
2403
|
+
}
|
|
2404
|
+
if (BigInt(maxTime) > BigInt(Math.floor(nowSeconds)) + MAX_VALIDITY_SECONDS2) {
|
|
2405
|
+
fail(
|
|
2406
|
+
"revoke_expiry_too_far",
|
|
2407
|
+
"This transaction stays valid for far longer than a revocation needs."
|
|
2408
|
+
);
|
|
2409
|
+
}
|
|
2410
|
+
if (intent.source !== expected.owner) {
|
|
2411
|
+
fail(
|
|
2412
|
+
"revoke_transaction_source_mismatch",
|
|
2413
|
+
"This transaction is not sourced from the account being revoked for."
|
|
2414
|
+
);
|
|
2415
|
+
}
|
|
2416
|
+
if (intent.memo !== null) {
|
|
2417
|
+
fail("revoke_memo_present", "This transaction carries a memo, which a revocation never needs.");
|
|
2418
|
+
}
|
|
2419
|
+
if (BigInt(intent.fee) > MAX_REVOKE_FEE_STROOPS) {
|
|
2420
|
+
fail(
|
|
2421
|
+
"revoke_fee_above_cap",
|
|
2422
|
+
"This transaction's fee is higher than a revocation should ever need."
|
|
2423
|
+
);
|
|
2424
|
+
}
|
|
2425
|
+
if (intent.operations.length !== 1) {
|
|
2426
|
+
fail(
|
|
2427
|
+
"revoke_operation_count",
|
|
2428
|
+
`This transaction has ${intent.operations.length} operations; a revocation has exactly one.`
|
|
2429
|
+
);
|
|
2430
|
+
}
|
|
2431
|
+
const op = intent.operations[0];
|
|
2432
|
+
if (op.source !== expected.owner) {
|
|
2433
|
+
fail(
|
|
2434
|
+
"revoke_operation_source_mismatch",
|
|
2435
|
+
"The operation does not act as the account being revoked for."
|
|
2436
|
+
);
|
|
2437
|
+
}
|
|
2438
|
+
if (op.type !== "invoke_host_function") {
|
|
2439
|
+
fail("revoke_not_invocation", "This transaction does not invoke a contract.");
|
|
2440
|
+
}
|
|
2441
|
+
if (op.contract !== expected.token) {
|
|
2442
|
+
fail("revoke_token_mismatch", "This transaction does not touch the expected token contract.");
|
|
2443
|
+
}
|
|
2444
|
+
if (op.function !== "approve") {
|
|
2445
|
+
fail(
|
|
2446
|
+
"revoke_function_not_approve",
|
|
2447
|
+
"This transaction does not call approve, so it is not a revocation."
|
|
2448
|
+
);
|
|
2449
|
+
}
|
|
2450
|
+
if (op.args.length !== 4 || op.args[0] !== expected.owner || op.args[1] !== expected.spender || op.args[2] !== "0") {
|
|
2451
|
+
fail(
|
|
2452
|
+
"revoke_approve_args_mismatch",
|
|
2453
|
+
"This transaction does not revoke the expected spender's allowance on this token."
|
|
2454
|
+
);
|
|
2455
|
+
}
|
|
2456
|
+
if (op.authorizesBeyondSelf) {
|
|
2457
|
+
fail(
|
|
2458
|
+
"revoke_auth_beyond_self",
|
|
2459
|
+
"This transaction authorizes more than the account's own revocation."
|
|
2460
|
+
);
|
|
2461
|
+
}
|
|
2462
|
+
if (op.authDepth !== 0) {
|
|
2463
|
+
fail(
|
|
2464
|
+
"revoke_auth_nested",
|
|
2465
|
+
"This transaction authorizes a nested call, which a plain revocation never needs."
|
|
2466
|
+
);
|
|
2467
|
+
}
|
|
2468
|
+
if (op.unsupportedAddressCount > 0) {
|
|
2469
|
+
fail(
|
|
2470
|
+
"revoke_address_unsupported",
|
|
2471
|
+
"This transaction references an address form that cannot be verified."
|
|
2472
|
+
);
|
|
2473
|
+
}
|
|
2474
|
+
if (op.accountsReferenced.some((a) => a !== expected.owner && a !== expected.spender)) {
|
|
2475
|
+
fail(
|
|
2476
|
+
"revoke_foreign_account",
|
|
2477
|
+
"This transaction references an account other than the one being revoked for."
|
|
2478
|
+
);
|
|
2479
|
+
}
|
|
2480
|
+
if (op.contractsReferenced.some((c) => c !== expected.token && c !== expected.spender)) {
|
|
2481
|
+
fail(
|
|
2482
|
+
"revoke_foreign_contract",
|
|
2483
|
+
"This transaction references a contract other than the token or the spender."
|
|
2484
|
+
);
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
|
|
2356
2488
|
// src/index.ts
|
|
2357
2489
|
function verifyCloseTransaction2(input) {
|
|
2358
2490
|
verifyCloseTransaction(input);
|
|
@@ -2360,8 +2492,11 @@ function verifyCloseTransaction2(input) {
|
|
|
2360
2492
|
function exitExpectations2(accountState, network) {
|
|
2361
2493
|
return exitExpectations(accountState, network);
|
|
2362
2494
|
}
|
|
2363
|
-
function requiresMediator(address) {
|
|
2364
|
-
return mediatorAllowedFor(address);
|
|
2495
|
+
function requiresMediator(address, network) {
|
|
2496
|
+
return mediatorAllowedFor(address, network);
|
|
2497
|
+
}
|
|
2498
|
+
function verifyRevokeAllowanceTransaction2(unsignedXdr, networkPassphrase, expected, nowSeconds) {
|
|
2499
|
+
verifyRevokeAllowanceTransaction(unsignedXdr, networkPassphrase, expected, nowSeconds);
|
|
2365
2500
|
}
|
|
2366
2501
|
|
|
2367
|
-
export { VerificationError, exitExpectations2 as exitExpectations, requiresMediator, verifyCloseTransaction2 as verifyCloseTransaction };
|
|
2502
|
+
export { RevokeAllowanceVerificationError, VerificationError, exitExpectations2 as exitExpectations, requiresMediator, verifyCloseTransaction2 as verifyCloseTransaction, verifyRevokeAllowanceTransaction2 as verifyRevokeAllowanceTransaction };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumenwipe/verify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Reference verifier for LumenWipe close transactions, compiled from the web app's own trust anchor, with a conformance vector set.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"default": "./dist/index.cjs"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
"./vectors/close-v1.json": "./vectors/close-v1.json"
|
|
21
|
+
"./vectors/close-v1.json": "./vectors/close-v1.json",
|
|
22
|
+
"./vectors/revoke-allowance-v1.json": "./vectors/revoke-allowance-v1.json"
|
|
22
23
|
},
|
|
23
24
|
"files": [
|
|
24
25
|
"dist",
|