@toon-protocol/client 2.2.0 → 3.0.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/dist/{chunk-A3JKQOWQ.js → chunk-GDWZ736I.js} +93 -101
- package/dist/chunk-GDWZ736I.js.map +1 -0
- package/dist/cli/main.js +1 -1
- package/dist/{client-VA4727SQ.js → client-TEP26FMO.js} +2 -2
- package/dist/index.d.ts +135 -125
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-A3JKQOWQ.js.map +0 -1
- /package/dist/{client-VA4727SQ.js.map → client-TEP26FMO.js.map} +0 -0
|
@@ -317,12 +317,11 @@ function decodeGeneralizedTime(buf, offset) {
|
|
|
317
317
|
return { value, bytesRead: GENERALIZED_TIME_LENGTH };
|
|
318
318
|
}
|
|
319
319
|
function serializeIlpPrepare(packet) {
|
|
320
|
-
const condition = packet.executionCondition.length === 32 ? packet.executionCondition : new Uint8Array(32);
|
|
321
320
|
return concat(
|
|
322
321
|
writeUint8(ILPPacketType.PREPARE),
|
|
323
322
|
encodeVarUInt(packet.amount),
|
|
324
323
|
encodeGeneralizedTime(packet.expiresAt),
|
|
325
|
-
|
|
324
|
+
writeUint8(packet.greeting ? 1 : 0),
|
|
326
325
|
encodeVarOctetString(textEncoder.encode(packet.destination)),
|
|
327
326
|
encodeVarOctetString(packet.data)
|
|
328
327
|
);
|
|
@@ -341,11 +340,17 @@ function deserializeIlpPrepare(buf) {
|
|
|
341
340
|
offset
|
|
342
341
|
);
|
|
343
342
|
offset += timeBytes;
|
|
344
|
-
if (offset
|
|
345
|
-
throw new Error("Buffer underflow reading PREPARE
|
|
343
|
+
if (offset >= buf.length) {
|
|
344
|
+
throw new Error("Buffer underflow reading PREPARE greeting flag");
|
|
346
345
|
}
|
|
347
|
-
const
|
|
348
|
-
|
|
346
|
+
const greetingByte = buf[offset];
|
|
347
|
+
if (greetingByte !== 0 && greetingByte !== 1) {
|
|
348
|
+
throw new Error(
|
|
349
|
+
`Malformed PREPARE greeting flag: expected 0x00 or 0x01, got 0x${greetingByte.toString(16).padStart(2, "0")}`
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
const greeting = greetingByte === 1;
|
|
353
|
+
offset += 1;
|
|
349
354
|
const { value: destinationBytes, bytesRead: destBytes } = decodeVarOctetString(buf, offset);
|
|
350
355
|
offset += destBytes;
|
|
351
356
|
const destination = textDecoder.decode(destinationBytes);
|
|
@@ -354,7 +359,7 @@ function deserializeIlpPrepare(buf) {
|
|
|
354
359
|
type: ILPPacketType.PREPARE,
|
|
355
360
|
amount,
|
|
356
361
|
destination,
|
|
357
|
-
|
|
362
|
+
greeting,
|
|
358
363
|
expiresAt,
|
|
359
364
|
data
|
|
360
365
|
};
|
|
@@ -681,39 +686,30 @@ function decodeUtf8(bytes) {
|
|
|
681
686
|
return new TextDecoder().decode(bytes);
|
|
682
687
|
}
|
|
683
688
|
|
|
684
|
-
// src/utils/
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
689
|
+
// src/utils/fulfillment.ts
|
|
690
|
+
var FULFILLMENT_LENGTH = 32;
|
|
691
|
+
function fulfillmentMatches(returned, expected) {
|
|
692
|
+
if (returned === void 0 || returned.length !== FULFILLMENT_LENGTH) {
|
|
693
|
+
return false;
|
|
694
|
+
}
|
|
695
|
+
if (expected.length !== FULFILLMENT_LENGTH) return false;
|
|
696
|
+
for (let i = 0; i < FULFILLMENT_LENGTH; i++) {
|
|
697
|
+
if (returned[i] !== expected[i]) return false;
|
|
692
698
|
}
|
|
693
699
|
return true;
|
|
694
700
|
}
|
|
695
|
-
function
|
|
696
|
-
if (
|
|
701
|
+
function assertValidFulfillment(fulfillment) {
|
|
702
|
+
if (fulfillment.length !== FULFILLMENT_LENGTH) {
|
|
697
703
|
throw new Error(
|
|
698
|
-
`
|
|
704
|
+
`an expected fulfillment must be exactly ${FULFILLMENT_LENGTH} bytes, got ${fulfillment.length}`
|
|
699
705
|
);
|
|
700
706
|
}
|
|
701
707
|
}
|
|
702
|
-
function fulfillmentMatchesCondition(fulfillment, condition) {
|
|
703
|
-
if (fulfillment === void 0 || fulfillment.length !== CONDITION_LENGTH) {
|
|
704
|
-
return false;
|
|
705
|
-
}
|
|
706
|
-
const digest = sha256(fulfillment);
|
|
707
|
-
for (let i = 0; i < CONDITION_LENGTH; i++) {
|
|
708
|
-
if (digest[i] !== condition[i]) return false;
|
|
709
|
-
}
|
|
710
|
-
return true;
|
|
711
|
-
}
|
|
712
708
|
|
|
713
709
|
// src/ilp/ilp-send.ts
|
|
714
|
-
function
|
|
715
|
-
if (
|
|
716
|
-
return typeof
|
|
710
|
+
function resolveExpectedFulfillment(fulfillment) {
|
|
711
|
+
if (fulfillment === void 0) return void 0;
|
|
712
|
+
return typeof fulfillment === "string" ? fromBase64(fulfillment) : fulfillment;
|
|
717
713
|
}
|
|
718
714
|
var PACKET_EXPIRY_HEADROOM_MS = 15e3;
|
|
719
715
|
function resolveExpiresAt(expiresAt, timeoutMs) {
|
|
@@ -721,14 +717,14 @@ function resolveExpiresAt(expiresAt, timeoutMs) {
|
|
|
721
717
|
return expiresAt instanceof Date ? new Date(expiresAt.getTime()) : new Date(expiresAt);
|
|
722
718
|
}
|
|
723
719
|
var FULFILLMENT_MISMATCH_CODE = "F99";
|
|
724
|
-
var FULFILLMENT_MISMATCH_MESSAGE = "FULFILL fulfillment
|
|
725
|
-
function mapIlpResponse(packet,
|
|
720
|
+
var FULFILLMENT_MISMATCH_MESSAGE = "FULFILL fulfillment is not the one this packet's sealed secret derives (ADR 0019) \u2014 packet counted failed";
|
|
721
|
+
function mapIlpResponse(packet, expectedFulfillment) {
|
|
726
722
|
if (packet.type === ILPPacketType.FULFILL) {
|
|
727
723
|
const dataField = packet.data.length > 0 ? { data: toBase64(packet.data) } : {};
|
|
728
|
-
if (
|
|
724
|
+
if (expectedFulfillment === void 0) {
|
|
729
725
|
return { accepted: true, ...dataField };
|
|
730
726
|
}
|
|
731
|
-
if (!
|
|
727
|
+
if (!fulfillmentMatches(packet.fulfillment, expectedFulfillment)) {
|
|
732
728
|
return {
|
|
733
729
|
accepted: false,
|
|
734
730
|
code: FULFILLMENT_MISMATCH_CODE,
|
|
@@ -1326,11 +1322,10 @@ var BtpRuntimeClient = class {
|
|
|
1326
1322
|
* Sends an ILP packet via BTP with auto-reconnect on connection errors.
|
|
1327
1323
|
* Satisfies IlpClient interface.
|
|
1328
1324
|
*
|
|
1329
|
-
* `params` may carry
|
|
1330
|
-
* `
|
|
1331
|
-
*
|
|
1332
|
-
*
|
|
1333
|
-
* as a failed result — see `mapIlpResponse`.
|
|
1325
|
+
* `params` may carry an `expectedFulfillment` (the sender's end-to-end
|
|
1326
|
+
* check, ADR 0069), a `greeting` flag and an explicit `expiresAt`. With an
|
|
1327
|
+
* expected fulfilment the FULFILL preimage is compared against it and a
|
|
1328
|
+
* mismatch is surfaced as a failed result — see `mapIlpResponse`.
|
|
1334
1329
|
*/
|
|
1335
1330
|
async sendIlpPacket(params) {
|
|
1336
1331
|
return withRetry(() => this._sendIlpPacketOnce(params), {
|
|
@@ -1347,8 +1342,8 @@ var BtpRuntimeClient = class {
|
|
|
1347
1342
|
* Sends a balance proof claim via BTP protocol data, then sends an ILP packet.
|
|
1348
1343
|
* Auto-reconnects on connection errors.
|
|
1349
1344
|
*
|
|
1350
|
-
*
|
|
1351
|
-
*
|
|
1345
|
+
* `expectedFulfillment` / `greeting` / `expiresAt` semantics are identical
|
|
1346
|
+
* to {@link sendIlpPacket}.
|
|
1352
1347
|
*/
|
|
1353
1348
|
async sendIlpPacketWithClaim(params, claim) {
|
|
1354
1349
|
return withRetry(() => this._sendIlpPacketWithClaimOnce(params, claim), {
|
|
@@ -1392,27 +1387,29 @@ var BtpRuntimeClient = class {
|
|
|
1392
1387
|
);
|
|
1393
1388
|
}
|
|
1394
1389
|
/**
|
|
1395
|
-
* Build the ILP PREPARE for a send, applying the
|
|
1396
|
-
* explicit expiry when provided
|
|
1397
|
-
*
|
|
1398
|
-
*
|
|
1399
|
-
*
|
|
1390
|
+
* Build the ILP PREPARE for a send, applying the
|
|
1391
|
+
* explicit expiry when provided, carrying the `greeting` flag ADR 0069 put
|
|
1392
|
+
* where the execution condition used to be, and validating that an expected
|
|
1393
|
+
* fulfilment is exactly 32 bytes (a wrong-length one could never match a
|
|
1394
|
+
* real FULFILL, so every delivery would be counted failed).
|
|
1400
1395
|
*/
|
|
1401
1396
|
buildPrepare(params) {
|
|
1402
|
-
const
|
|
1403
|
-
|
|
1404
|
-
|
|
1397
|
+
const expectedFulfillment = resolveExpectedFulfillment(
|
|
1398
|
+
params.expectedFulfillment
|
|
1399
|
+
);
|
|
1400
|
+
if (expectedFulfillment !== void 0) {
|
|
1401
|
+
assertValidFulfillment(expectedFulfillment);
|
|
1405
1402
|
}
|
|
1406
1403
|
return {
|
|
1407
1404
|
prepare: {
|
|
1408
1405
|
type: 12,
|
|
1409
1406
|
amount: BigInt(params.amount),
|
|
1410
1407
|
destination: params.destination,
|
|
1411
|
-
|
|
1408
|
+
greeting: params.greeting ?? false,
|
|
1412
1409
|
expiresAt: resolveExpiresAt(params.expiresAt, params.timeout ?? 3e4),
|
|
1413
1410
|
data: fromBase64(params.data)
|
|
1414
1411
|
},
|
|
1415
|
-
|
|
1412
|
+
expectedFulfillment
|
|
1416
1413
|
};
|
|
1417
1414
|
}
|
|
1418
1415
|
/**
|
|
@@ -1422,10 +1419,10 @@ var BtpRuntimeClient = class {
|
|
|
1422
1419
|
if (!this._isConnected) {
|
|
1423
1420
|
await this.reconnect();
|
|
1424
1421
|
}
|
|
1425
|
-
const { prepare,
|
|
1422
|
+
const { prepare, expectedFulfillment } = this.buildPrepare(params);
|
|
1426
1423
|
const response = await this.btpClient.sendPacket(prepare);
|
|
1427
1424
|
return {
|
|
1428
|
-
...mapIlpResponse(response.packet,
|
|
1425
|
+
...mapIlpResponse(response.packet, expectedFulfillment),
|
|
1429
1426
|
...readResponseMeta(response.protocolData)
|
|
1430
1427
|
};
|
|
1431
1428
|
}
|
|
@@ -1446,10 +1443,10 @@ var BtpRuntimeClient = class {
|
|
|
1446
1443
|
data: encodeUtf8(JSON.stringify(claim))
|
|
1447
1444
|
}
|
|
1448
1445
|
];
|
|
1449
|
-
const { prepare,
|
|
1446
|
+
const { prepare, expectedFulfillment } = this.buildPrepare(params);
|
|
1450
1447
|
const response = await this.btpClient.sendPacket(prepare, protocolData);
|
|
1451
1448
|
return {
|
|
1452
|
-
...mapIlpResponse(response.packet,
|
|
1449
|
+
...mapIlpResponse(response.packet, expectedFulfillment),
|
|
1453
1450
|
...readResponseMeta(response.protocolData)
|
|
1454
1451
|
};
|
|
1455
1452
|
}
|
|
@@ -1617,11 +1614,10 @@ var HttpIlpClient = class {
|
|
|
1617
1614
|
* this only on free/zero-amount routes; paid writes must use
|
|
1618
1615
|
* {@link sendIlpPacketWithClaim}. Satisfies the IlpClient interface.
|
|
1619
1616
|
*
|
|
1620
|
-
* `params` may carry
|
|
1621
|
-
* `
|
|
1622
|
-
*
|
|
1623
|
-
*
|
|
1624
|
-
* as a failed result — see {@link mapIlpResponse}.
|
|
1617
|
+
* `params` may carry an `expectedFulfillment` (the sender's end-to-end
|
|
1618
|
+
* check, ADR 0069), a `greeting` flag and an explicit `expiresAt`. With an
|
|
1619
|
+
* expected fulfilment the FULFILL preimage is compared against it and a
|
|
1620
|
+
* mismatch is surfaced as a failed result — see {@link mapIlpResponse}.
|
|
1625
1621
|
*/
|
|
1626
1622
|
async sendIlpPacket(params) {
|
|
1627
1623
|
return withRetry(() => this.postPrepare(params), {
|
|
@@ -1637,8 +1633,8 @@ var HttpIlpClient = class {
|
|
|
1637
1633
|
* the BTP path attaches as the `payment-channel-claim` protocolData entry —
|
|
1638
1634
|
* we base64(JSON.stringify(claim)) it, byte-for-byte identical to BTP.
|
|
1639
1635
|
*
|
|
1640
|
-
*
|
|
1641
|
-
*
|
|
1636
|
+
* `expectedFulfillment` / `greeting` / `expiresAt` semantics are identical
|
|
1637
|
+
* to {@link sendIlpPacket}.
|
|
1642
1638
|
*/
|
|
1643
1639
|
async sendIlpPacketWithClaim(params, claim) {
|
|
1644
1640
|
return withRetry(() => this.postPrepare(params, claim), {
|
|
@@ -1716,15 +1712,17 @@ var HttpIlpClient = class {
|
|
|
1716
1712
|
*/
|
|
1717
1713
|
async postPrepare(params, claim) {
|
|
1718
1714
|
const requestTimeout = params.timeout ?? this.timeout;
|
|
1719
|
-
const
|
|
1720
|
-
|
|
1721
|
-
|
|
1715
|
+
const expectedFulfillment = resolveExpectedFulfillment(
|
|
1716
|
+
params.expectedFulfillment
|
|
1717
|
+
);
|
|
1718
|
+
if (expectedFulfillment !== void 0) {
|
|
1719
|
+
assertValidFulfillment(expectedFulfillment);
|
|
1722
1720
|
}
|
|
1723
1721
|
const prepare = serializeIlpPrepare({
|
|
1724
1722
|
type: ILPPacketType.PREPARE,
|
|
1725
1723
|
amount: BigInt(params.amount),
|
|
1726
1724
|
destination: params.destination,
|
|
1727
|
-
|
|
1725
|
+
greeting: params.greeting ?? false,
|
|
1728
1726
|
expiresAt: resolveExpiresAt(params.expiresAt, requestTimeout),
|
|
1729
1727
|
data: fromBase64(params.data)
|
|
1730
1728
|
});
|
|
@@ -1746,7 +1744,7 @@ var HttpIlpClient = class {
|
|
|
1746
1744
|
signal: controller.signal
|
|
1747
1745
|
});
|
|
1748
1746
|
clearTimeout(timeoutId);
|
|
1749
|
-
return await this.mapResponse(response,
|
|
1747
|
+
return await this.mapResponse(response, expectedFulfillment);
|
|
1750
1748
|
} catch (error) {
|
|
1751
1749
|
clearTimeout(timeoutId);
|
|
1752
1750
|
throw this.mapTransportError(error, requestTimeout);
|
|
@@ -1757,11 +1755,11 @@ var HttpIlpClient = class {
|
|
|
1757
1755
|
* to a transport error. Per the wire contract, ILP-level rejects arrive as a
|
|
1758
1756
|
* 200 + REJECT body — only HTTP non-2xx means a transport-layer failure.
|
|
1759
1757
|
*
|
|
1760
|
-
* When `
|
|
1761
|
-
* it; a mismatch yields `accepted: false` (shared `mapIlpResponse`
|
|
1762
|
-
* identical to the BTP path).
|
|
1758
|
+
* When `expectedFulfillment` is given the FULFILL preimage is compared
|
|
1759
|
+
* against it; a mismatch yields `accepted: false` (shared `mapIlpResponse`
|
|
1760
|
+
* logic, identical to the BTP path).
|
|
1763
1761
|
*/
|
|
1764
|
-
async mapResponse(response,
|
|
1762
|
+
async mapResponse(response, expectedFulfillment) {
|
|
1765
1763
|
if (response.ok) {
|
|
1766
1764
|
const buf = new Uint8Array(await response.arrayBuffer());
|
|
1767
1765
|
if (buf.length === 0) {
|
|
@@ -1770,7 +1768,7 @@ var HttpIlpClient = class {
|
|
|
1770
1768
|
);
|
|
1771
1769
|
}
|
|
1772
1770
|
return {
|
|
1773
|
-
...mapIlpResponse(deserializeIlpPacket(buf),
|
|
1771
|
+
...mapIlpResponse(deserializeIlpPacket(buf), expectedFulfillment),
|
|
1774
1772
|
...readResponseMeta2(response.headers)
|
|
1775
1773
|
};
|
|
1776
1774
|
}
|
|
@@ -2225,16 +2223,18 @@ var ConnectorEdgeClient = class {
|
|
|
2225
2223
|
async probe(endpoint, params, claim) {
|
|
2226
2224
|
const base = connectorEdgeBaseUrl(endpoint);
|
|
2227
2225
|
const url = `${base}/ilp/probe`;
|
|
2228
|
-
const
|
|
2229
|
-
|
|
2230
|
-
|
|
2226
|
+
const expectedFulfillment = resolveExpectedFulfillment(
|
|
2227
|
+
params.expectedFulfillment
|
|
2228
|
+
);
|
|
2229
|
+
if (expectedFulfillment !== void 0) {
|
|
2230
|
+
assertValidFulfillment(expectedFulfillment);
|
|
2231
2231
|
}
|
|
2232
2232
|
const timeout = params.timeout ?? this.timeout;
|
|
2233
2233
|
const prepare = serializeIlpPrepare({
|
|
2234
2234
|
type: ILPPacketType.PREPARE,
|
|
2235
2235
|
amount: BigInt(params.amount),
|
|
2236
2236
|
destination: params.destination,
|
|
2237
|
-
|
|
2237
|
+
greeting: params.greeting ?? false,
|
|
2238
2238
|
expiresAt: resolveExpiresAt(params.expiresAt, timeout),
|
|
2239
2239
|
data: fromBase64(params.data)
|
|
2240
2240
|
});
|
|
@@ -2282,7 +2282,7 @@ var ConnectorEdgeClient = class {
|
|
|
2282
2282
|
);
|
|
2283
2283
|
}
|
|
2284
2284
|
return {
|
|
2285
|
-
...mapIlpResponse(deserializeIlpPacket(body),
|
|
2285
|
+
...mapIlpResponse(deserializeIlpPacket(body), expectedFulfillment),
|
|
2286
2286
|
...readResponseMeta2(response.headers)
|
|
2287
2287
|
};
|
|
2288
2288
|
}
|
|
@@ -2342,13 +2342,11 @@ var ConnectorEdgeClient = class {
|
|
|
2342
2342
|
);
|
|
2343
2343
|
}
|
|
2344
2344
|
const base = connectorEdgeBaseUrl(endpoint);
|
|
2345
|
-
const condition = new Uint8Array(32);
|
|
2346
|
-
condition[0] = 1;
|
|
2347
2345
|
const prepare = serializeIlpPrepare({
|
|
2348
2346
|
type: ILPPacketType.PREPARE,
|
|
2349
2347
|
amount: 0n,
|
|
2350
2348
|
destination,
|
|
2351
|
-
|
|
2349
|
+
greeting: false,
|
|
2352
2350
|
expiresAt: new Date(Date.now() + 3e4),
|
|
2353
2351
|
data: new Uint8Array(0)
|
|
2354
2352
|
});
|
|
@@ -4149,7 +4147,7 @@ function sleep2(ms) {
|
|
|
4149
4147
|
|
|
4150
4148
|
// src/channel/solana/payment-channel.ts
|
|
4151
4149
|
import { ed25519 } from "@noble/curves/ed25519.js";
|
|
4152
|
-
import { sha256
|
|
4150
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
4153
4151
|
var TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
4154
4152
|
var SYSTEM_PROGRAM_ID = "11111111111111111111111111111111";
|
|
4155
4153
|
var RENT_SYSVAR_ID = "SysvarRent111111111111111111111111111111111";
|
|
@@ -4244,7 +4242,7 @@ function findProgramAddress(seeds, programId) {
|
|
|
4244
4242
|
input.set(programId, offset);
|
|
4245
4243
|
offset += programId.length;
|
|
4246
4244
|
input.set(PDA_MARKER, offset);
|
|
4247
|
-
const hash =
|
|
4245
|
+
const hash = sha256(input);
|
|
4248
4246
|
if (!isOnCurve(hash)) return { pda: hash, bump };
|
|
4249
4247
|
}
|
|
4250
4248
|
throw new Error("Could not find a viable PDA bump seed");
|
|
@@ -5766,8 +5764,8 @@ function decodeEnvelope(buf, direction) {
|
|
|
5766
5764
|
import { secp256k1 } from "@noble/curves/secp256k1.js";
|
|
5767
5765
|
import { chacha20poly1305 } from "@noble/ciphers/chacha.js";
|
|
5768
5766
|
import { hkdf } from "@noble/hashes/hkdf.js";
|
|
5769
|
-
import { sha256 as
|
|
5770
|
-
import { randomBytes
|
|
5767
|
+
import { sha256 as sha2562 } from "@noble/hashes/sha2.js";
|
|
5768
|
+
import { randomBytes } from "@noble/hashes/utils.js";
|
|
5771
5769
|
var GIFTWRAP_NONCE_LENGTH = 12;
|
|
5772
5770
|
var GIFTWRAP_SECRET_LENGTH = 32;
|
|
5773
5771
|
var GIFTWRAP_PUBLIC_KEY_LENGTH = 65;
|
|
@@ -5813,7 +5811,7 @@ function concat3(parts) {
|
|
|
5813
5811
|
return out;
|
|
5814
5812
|
}
|
|
5815
5813
|
function hkdfKey(ikm, info) {
|
|
5816
|
-
return hkdf(
|
|
5814
|
+
return hkdf(sha2562, ikm, void 0, info, 32);
|
|
5817
5815
|
}
|
|
5818
5816
|
function encryptWithNonce(key, plaintext, nonce) {
|
|
5819
5817
|
return concat3([nonce, chacha20poly1305(key, nonce).encrypt(plaintext)]);
|
|
@@ -5880,8 +5878,8 @@ function sealRequestWithRandomness(plaintext, receiverPublicKey, ephemeralSecret
|
|
|
5880
5878
|
}
|
|
5881
5879
|
function sealRequest(plaintext, receiverPublicKey) {
|
|
5882
5880
|
const ephemeralSecretKey = secp256k1.utils.randomSecretKey();
|
|
5883
|
-
const sharedSecret =
|
|
5884
|
-
const nonce =
|
|
5881
|
+
const sharedSecret = randomBytes(GIFTWRAP_SECRET_LENGTH);
|
|
5882
|
+
const nonce = randomBytes(GIFTWRAP_NONCE_LENGTH);
|
|
5885
5883
|
return {
|
|
5886
5884
|
wrapped: sealRequestWithRandomness(
|
|
5887
5885
|
plaintext,
|
|
@@ -5940,7 +5938,7 @@ function sealResponse(sharedSecret, plaintext) {
|
|
|
5940
5938
|
return sealResponseWithRandomness(
|
|
5941
5939
|
sharedSecret,
|
|
5942
5940
|
plaintext,
|
|
5943
|
-
|
|
5941
|
+
randomBytes(GIFTWRAP_NONCE_LENGTH)
|
|
5944
5942
|
);
|
|
5945
5943
|
}
|
|
5946
5944
|
function openResponse(sharedSecret, bytes) {
|
|
@@ -5967,9 +5965,6 @@ function deriveFulfillment(sharedSecret) {
|
|
|
5967
5965
|
}
|
|
5968
5966
|
return hkdfKey(sharedSecret, FULFILLMENT_INFO);
|
|
5969
5967
|
}
|
|
5970
|
-
function deriveCondition(fulfillment) {
|
|
5971
|
-
return sha2563(fulfillment);
|
|
5972
|
-
}
|
|
5973
5968
|
|
|
5974
5969
|
// src/wire/sealed-exchange.ts
|
|
5975
5970
|
var SealedResponseError = class extends Error {
|
|
@@ -5987,12 +5982,10 @@ function sealExchange(request, connectorPublicKey) {
|
|
|
5987
5982
|
encodeEnvelopeRequest(request),
|
|
5988
5983
|
connectorPublicKey
|
|
5989
5984
|
);
|
|
5990
|
-
const fulfillment = deriveFulfillment(sharedSecret);
|
|
5991
5985
|
return {
|
|
5992
5986
|
data: wrapped,
|
|
5993
|
-
condition: deriveCondition(fulfillment),
|
|
5994
5987
|
sharedSecret,
|
|
5995
|
-
fulfillment
|
|
5988
|
+
fulfillment: deriveFulfillment(sharedSecret)
|
|
5996
5989
|
};
|
|
5997
5990
|
}
|
|
5998
5991
|
function readExchangeOutcome(result, data, sharedSecret) {
|
|
@@ -7568,7 +7561,7 @@ async function attempt(context, params) {
|
|
|
7568
7561
|
destination: params.destination,
|
|
7569
7562
|
amount: params.amount.toString(),
|
|
7570
7563
|
data: toBase64(params.exchange.data),
|
|
7571
|
-
|
|
7564
|
+
expectedFulfillment: params.exchange.fulfillment,
|
|
7572
7565
|
timeout: params.timeoutMs
|
|
7573
7566
|
},
|
|
7574
7567
|
claim
|
|
@@ -7592,7 +7585,7 @@ async function attemptUnpaid(context, params) {
|
|
|
7592
7585
|
destination: params.destination,
|
|
7593
7586
|
amount: params.amount.toString(),
|
|
7594
7587
|
data: toBase64(params.exchange.data),
|
|
7595
|
-
|
|
7588
|
+
expectedFulfillment: params.exchange.fulfillment,
|
|
7596
7589
|
timeout: params.timeoutMs
|
|
7597
7590
|
});
|
|
7598
7591
|
return { result: toSendResult(result, params, void 0), channelId: void 0 };
|
|
@@ -7902,7 +7895,7 @@ var ToonClient = class _ToonClient {
|
|
|
7902
7895
|
destination,
|
|
7903
7896
|
amount: "0",
|
|
7904
7897
|
data: toBase64(exchange.data),
|
|
7905
|
-
|
|
7898
|
+
expectedFulfillment: exchange.fulfillment,
|
|
7906
7899
|
timeout: this.config.timeoutMs
|
|
7907
7900
|
},
|
|
7908
7901
|
claim
|
|
@@ -8297,7 +8290,7 @@ export {
|
|
|
8297
8290
|
toHex,
|
|
8298
8291
|
encodeUtf8,
|
|
8299
8292
|
decodeUtf8,
|
|
8300
|
-
|
|
8293
|
+
resolveExpectedFulfillment,
|
|
8301
8294
|
PACKET_EXPIRY_HEADROOM_MS,
|
|
8302
8295
|
resolveExpiresAt,
|
|
8303
8296
|
FULFILLMENT_MISMATCH_CODE,
|
|
@@ -8382,7 +8375,6 @@ export {
|
|
|
8382
8375
|
openResponse,
|
|
8383
8376
|
looksLikeSealedResponse,
|
|
8384
8377
|
deriveFulfillment,
|
|
8385
|
-
deriveCondition,
|
|
8386
8378
|
SealedResponseError,
|
|
8387
8379
|
sealExchange,
|
|
8388
8380
|
readExchangeOutcome,
|
|
@@ -8412,4 +8404,4 @@ export {
|
|
|
8412
8404
|
toEnvelopeRequest,
|
|
8413
8405
|
ToonClient
|
|
8414
8406
|
};
|
|
8415
|
-
//# sourceMappingURL=chunk-
|
|
8407
|
+
//# sourceMappingURL=chunk-GDWZ736I.js.map
|