@vapi-network/core 0.15.1 → 0.16.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/README.md +6 -2
- package/dist/agent-link.js +73 -7
- package/dist/agent-link.js.map +1 -1
- package/dist/atomic-file.d.ts +1 -0
- package/dist/atomic-file.d.ts.map +1 -1
- package/dist/backup.js +6 -4
- package/dist/backup.js.map +1 -1
- package/dist/cloud-backup.js +79 -11
- package/dist/cloud-backup.js.map +2 -2
- package/dist/index.js +126 -16
- package/dist/index.js.map +2 -2
- package/dist/net-guard.d.ts +17 -0
- package/dist/net-guard.d.ts.map +1 -1
- package/dist/router-client.js +110 -16
- package/dist/router-client.js.map +2 -2
- package/dist/secrets.js +19 -8
- package/dist/secrets.js.map +1 -1
- package/dist/support-report.d.ts +1 -1
- package/dist/tasks/actions.d.ts +1 -0
- package/dist/tasks/actions.d.ts.map +1 -1
- package/dist/tasks/ballots.d.ts +43 -0
- package/dist/tasks/ballots.d.ts.map +1 -0
- package/dist/tasks/chain-port.d.ts +26 -0
- package/dist/tasks/chain-port.d.ts.map +1 -1
- package/dist/tasks/chain.d.ts +5 -0
- package/dist/tasks/chain.d.ts.map +1 -1
- package/dist/tasks/client.d.ts +33 -3
- package/dist/tasks/client.d.ts.map +1 -1
- package/dist/tasks/funding-attempts.d.ts +58 -0
- package/dist/tasks/funding-attempts.d.ts.map +1 -0
- package/dist/tasks/funding-intent.d.ts +11 -0
- package/dist/tasks/funding-intent.d.ts.map +1 -0
- package/dist/tasks/index.d.ts +13 -2
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/money.d.ts +2 -0
- package/dist/tasks/money.d.ts.map +1 -1
- package/dist/tasks/operation-support.d.ts +10 -2
- package/dist/tasks/operation-support.d.ts.map +1 -1
- package/dist/tasks/operations.d.ts +651 -13
- package/dist/tasks/operations.d.ts.map +1 -1
- package/dist/tasks/pending-transactions.d.ts +11 -0
- package/dist/tasks/pending-transactions.d.ts.map +1 -1
- package/dist/tasks/post-options.d.ts +144 -0
- package/dist/tasks/post-options.d.ts.map +1 -0
- package/dist/tasks/types.d.ts +5505 -74
- package/dist/tasks/types.d.ts.map +1 -1
- package/dist/tasks/v2-abi.d.ts +12 -0
- package/dist/tasks/v2-abi.d.ts.map +1 -0
- package/dist/tasks/v2-abi.generated.d.ts +5966 -0
- package/dist/tasks/v2-abi.generated.d.ts.map +1 -0
- package/dist/tasks/v2-events.d.ts +6460 -0
- package/dist/tasks/v2-events.d.ts.map +1 -0
- package/dist/tasks/v2-execution.d.ts +1070 -0
- package/dist/tasks/v2-execution.d.ts.map +1 -0
- package/dist/tasks/v2-jury.d.ts +863 -0
- package/dist/tasks/v2-jury.d.ts.map +1 -0
- package/dist/tasks/v2-plan-guard.d.ts +100 -0
- package/dist/tasks/v2-plan-guard.d.ts.map +1 -0
- package/dist/tasks/v2-public.d.ts +154 -0
- package/dist/tasks/v2-public.d.ts.map +1 -0
- package/dist/tasks/v2-trust.d.ts +27 -0
- package/dist/tasks/v2-trust.d.ts.map +1 -0
- package/dist/tasks/v2-write.d.ts +886 -0
- package/dist/tasks/v2-write.d.ts.map +1 -0
- package/dist/tasks/v2.d.ts +847 -0
- package/dist/tasks/v2.d.ts.map +1 -0
- package/dist/tasks/verbs.d.ts +1 -1
- package/dist/tasks/verbs.d.ts.map +1 -1
- package/dist/tasks/x402-funding.d.ts +49 -0
- package/dist/tasks/x402-funding.d.ts.map +1 -0
- package/dist/tasks.js +17541 -4184
- package/dist/tasks.js.map +3 -3
- package/dist/x402-pay.d.ts +11 -1
- package/dist/x402-pay.d.ts.map +1 -1
- package/dist/x402.d.ts +6 -0
- package/dist/x402.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/net-guard.d.ts
CHANGED
|
@@ -10,4 +10,21 @@ export declare function createPublicFetch(options: {
|
|
|
10
10
|
lookup?: LookupFn;
|
|
11
11
|
}): typeof fetch;
|
|
12
12
|
export declare function pinnedLookup(lookup: LookupFn): LookupFunction;
|
|
13
|
+
/**
|
|
14
|
+
* A request the guard refused before connecting. `reason` is `unresolved` when
|
|
15
|
+
* the hostname's DNS lookup failed or timed out, and `blocked` otherwise.
|
|
16
|
+
*/
|
|
17
|
+
export declare class NetworkGuardError extends Error {
|
|
18
|
+
readonly reason: "blocked" | "unresolved";
|
|
19
|
+
constructor(message: string, reason: "blocked" | "unresolved");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Says why a request to `url` never got an answer, in words that are safe to
|
|
23
|
+
* print: the host, and a Node system error code such as `ECONNREFUSED`, never
|
|
24
|
+
* the error's own message. When the proxy variable for the URL's protocol is
|
|
25
|
+
* set it adds how Node.js treats it: the proxy is used only with
|
|
26
|
+
* `NODE_USE_ENV_PROXY=1`, and the host must still resolve on this machine
|
|
27
|
+
* because the guard looks it up first.
|
|
28
|
+
*/
|
|
29
|
+
export declare function describeNetworkFailure(error: unknown, url: URL, env?: NodeJS.ProcessEnv): string;
|
|
13
30
|
//# sourceMappingURL=net-guard.d.ts.map
|
package/dist/net-guard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"net-guard.d.ts","sourceRoot":"","sources":["../src/net-guard.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAGrD,MAAM,MAAM,QAAQ,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAO/D,wBAAsB,eAAe,CACnC,GAAG,EAAE,GAAG,EACR,OAAO,EAAE;IAAE,mBAAmB,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/E,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB,GAAG,OAAO,KAAK,CAmDf;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,cAAc,CAoB7D"}
|
|
1
|
+
{"version":3,"file":"net-guard.d.ts","sourceRoot":"","sources":["../src/net-guard.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAGrD,MAAM,MAAM,QAAQ,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAO/D,wBAAsB,eAAe,CACnC,GAAG,EAAE,GAAG,EACR,OAAO,EAAE;IAAE,mBAAmB,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/E,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB,GAAG,OAAO,KAAK,CAmDf;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG,cAAc,CAoB7D;AAyHD;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAGxC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,YAAY;gBADzC,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,SAAS,GAAG,YAAY;CAK5C;AAgBD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,GAAG,EACR,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,CA6BR"}
|
package/dist/router-client.js
CHANGED
|
@@ -36714,12 +36714,12 @@ async function removeStaleLock(path) {
|
|
|
36714
36714
|
const pid = lockOwnerPid(owner);
|
|
36715
36715
|
if (pid !== void 0 && processIsAlive(pid)) return;
|
|
36716
36716
|
await atomicFileTestHooks?.beforeStaleLockBreak?.(path);
|
|
36717
|
-
await removeOwnedLock(path, [owner]);
|
|
36717
|
+
await removeOwnedLock(path, [owner], true);
|
|
36718
36718
|
} catch (error61) {
|
|
36719
36719
|
if (!hasCode(error61, "ENOENT")) throw error61;
|
|
36720
36720
|
}
|
|
36721
36721
|
}
|
|
36722
|
-
async function removeOwnedLock(path, owners) {
|
|
36722
|
+
async function removeOwnedLock(path, owners, staleDeadOwner = false) {
|
|
36723
36723
|
const tombPath = `${path}.stale.${randomBytes2(16).toString("hex")}`;
|
|
36724
36724
|
try {
|
|
36725
36725
|
await rename(path, tombPath);
|
|
@@ -36728,7 +36728,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
36728
36728
|
await removeOwnedTombs(path, owners);
|
|
36729
36729
|
const currentOwner = await readFile(path, "utf8").catch(() => void 0);
|
|
36730
36730
|
if (currentOwner !== void 0 && owners.includes(currentOwner)) {
|
|
36731
|
-
await removeOwnedLock(path, owners);
|
|
36731
|
+
await removeOwnedLock(path, owners, staleDeadOwner);
|
|
36732
36732
|
}
|
|
36733
36733
|
return;
|
|
36734
36734
|
}
|
|
@@ -36737,6 +36737,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
36737
36737
|
let pendingError;
|
|
36738
36738
|
let renamedOwner;
|
|
36739
36739
|
try {
|
|
36740
|
+
await atomicFileTestHooks?.afterLockRename?.(tombPath);
|
|
36740
36741
|
renamedOwner = await readFile(tombPath, "utf8");
|
|
36741
36742
|
if (!owners.includes(renamedOwner) && !lockOwnerReleased(renamedOwner)) {
|
|
36742
36743
|
await atomicFileTestHooks?.afterMismatchedLockRename?.(path);
|
|
@@ -36745,6 +36746,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
36745
36746
|
await atomicFileTestHooks?.afterMismatchedLockRestore?.(path);
|
|
36746
36747
|
}
|
|
36747
36748
|
} catch (error61) {
|
|
36749
|
+
if (hasCode(error61, "ENOENT")) return;
|
|
36748
36750
|
pendingError = error61;
|
|
36749
36751
|
}
|
|
36750
36752
|
try {
|
|
@@ -36753,7 +36755,7 @@ async function removeOwnedLock(path, owners) {
|
|
|
36753
36755
|
} catch (error61) {
|
|
36754
36756
|
if (!tombUnlinkTolerated(
|
|
36755
36757
|
error61,
|
|
36756
|
-
renamedOwner !== void 0 && lockOwnerReleased(renamedOwner) && owners.includes(renamedOwner)
|
|
36758
|
+
renamedOwner !== void 0 && (lockOwnerReleased(renamedOwner) || staleDeadOwner) && owners.includes(renamedOwner)
|
|
36757
36759
|
) && pendingError === void 0) {
|
|
36758
36760
|
pendingError = error61;
|
|
36759
36761
|
}
|
|
@@ -36950,7 +36952,7 @@ async function assertPublicUrl(url2, options) {
|
|
|
36950
36952
|
options.timeoutMs ?? 5e3
|
|
36951
36953
|
);
|
|
36952
36954
|
} catch {
|
|
36953
|
-
throw guardError(url2);
|
|
36955
|
+
throw guardError(url2, "unresolved");
|
|
36954
36956
|
}
|
|
36955
36957
|
if (addresses.length === 0 || addresses.some(isNonPublicAddress)) {
|
|
36956
36958
|
throw guardError(url2);
|
|
@@ -37105,10 +37107,67 @@ function isNonPublicIpv6(hextets) {
|
|
|
37105
37107
|
const isDocumentation = first === 8193 && hextets[1] === 3512;
|
|
37106
37108
|
return isUnspecified || isLoopback || isUniqueLocal || isLinkLocal || isSiteLocal || isMulticast || isDocumentation;
|
|
37107
37109
|
}
|
|
37108
|
-
|
|
37109
|
-
|
|
37110
|
-
|
|
37110
|
+
var NetworkGuardError = class extends Error {
|
|
37111
|
+
constructor(message, reason) {
|
|
37112
|
+
super(message);
|
|
37113
|
+
this.reason = reason;
|
|
37114
|
+
this.name = "NetworkGuardError";
|
|
37115
|
+
}
|
|
37116
|
+
reason;
|
|
37117
|
+
};
|
|
37118
|
+
function guardError(url2, reason = "blocked") {
|
|
37119
|
+
return new NetworkGuardError(
|
|
37120
|
+
`URL hostname ${JSON.stringify(url2.hostname)} is not allowed; private or internal destinations require allowPrivateNetwork true in the vAPI config.`,
|
|
37121
|
+
reason
|
|
37122
|
+
);
|
|
37123
|
+
}
|
|
37124
|
+
var PROXY_VARIABLES = {
|
|
37125
|
+
"https:": ["HTTPS_PROXY", "https_proxy"],
|
|
37126
|
+
"http:": ["HTTP_PROXY", "http_proxy"]
|
|
37127
|
+
};
|
|
37128
|
+
var SYSTEM_ERROR_CODE = /^[A-Z][A-Z0-9_]{1,39}$/u;
|
|
37129
|
+
function describeNetworkFailure(error61, url2, env = process.env) {
|
|
37130
|
+
const host = url2.host;
|
|
37131
|
+
let reason;
|
|
37132
|
+
const guard = guardReason(error61);
|
|
37133
|
+
if (guard !== void 0) {
|
|
37134
|
+
reason = guard === "unresolved" ? `the DNS lookup for ${host} failed` : `${host} is not a public address`;
|
|
37135
|
+
} else if (isTimeout(error61)) {
|
|
37136
|
+
reason = `the connection to ${host} timed out`;
|
|
37137
|
+
} else {
|
|
37138
|
+
const code = systemErrorCode(error61);
|
|
37139
|
+
reason = `could not connect to ${host}${code === void 0 ? "" : ` (${code})`}`;
|
|
37140
|
+
}
|
|
37141
|
+
const proxy = (PROXY_VARIABLES[url2.protocol] ?? []).find(
|
|
37142
|
+
(name) => (env[name] ?? "").trim() !== ""
|
|
37111
37143
|
);
|
|
37144
|
+
let hint = "";
|
|
37145
|
+
if (proxy !== void 0) {
|
|
37146
|
+
if (env.NODE_USE_ENV_PROXY !== "1") {
|
|
37147
|
+
hint = ` ${proxy} is set, but Node.js uses it only with NODE_USE_ENV_PROXY=1 (Node.js 22.21 or later): run the command again with NODE_USE_ENV_PROXY=1.`;
|
|
37148
|
+
} else if (guard === "unresolved") {
|
|
37149
|
+
hint = ` vapi looks ${host} up on this machine before it uses the proxy in ${proxy}, so the name must resolve here too.`;
|
|
37150
|
+
} else if (guard === void 0) {
|
|
37151
|
+
hint = ` NODE_USE_ENV_PROXY=1 and ${proxy} are set, so the proxy may have refused the connection.`;
|
|
37152
|
+
}
|
|
37153
|
+
}
|
|
37154
|
+
return `${reason}.${hint}`;
|
|
37155
|
+
}
|
|
37156
|
+
function guardReason(error61) {
|
|
37157
|
+
if (!(error61 instanceof Error) || error61.name !== "NetworkGuardError") return void 0;
|
|
37158
|
+
const reason = error61.reason;
|
|
37159
|
+
return reason === "blocked" || reason === "unresolved" ? reason : void 0;
|
|
37160
|
+
}
|
|
37161
|
+
function isTimeout(error61) {
|
|
37162
|
+
return error61 instanceof Error && (error61.name === "TimeoutError" || error61.name === "AbortError");
|
|
37163
|
+
}
|
|
37164
|
+
function systemErrorCode(error61) {
|
|
37165
|
+
for (let current = error61, depth = 0; current instanceof Error && depth < 3; depth += 1) {
|
|
37166
|
+
const code = current.code;
|
|
37167
|
+
if (typeof code === "string" && SYSTEM_ERROR_CODE.test(code)) return code;
|
|
37168
|
+
current = current.cause;
|
|
37169
|
+
}
|
|
37170
|
+
return void 0;
|
|
37112
37171
|
}
|
|
37113
37172
|
|
|
37114
37173
|
// src/networks.ts
|
|
@@ -37923,16 +37982,25 @@ function withBearer(init, accessToken) {
|
|
|
37923
37982
|
async function safeFetch(fetchImpl, input2, init) {
|
|
37924
37983
|
try {
|
|
37925
37984
|
return await fetchImpl(input2, init);
|
|
37926
|
-
} catch {
|
|
37927
|
-
throw httpError(
|
|
37985
|
+
} catch (error61) {
|
|
37986
|
+
throw httpError(`The vAPI agent link request failed: ${networkFailure(error61, input2)}`);
|
|
37928
37987
|
}
|
|
37929
37988
|
}
|
|
37930
37989
|
async function safeAgentFetch(fetchImpl, input2, init) {
|
|
37931
37990
|
try {
|
|
37932
37991
|
return await fetchImpl(input2, init);
|
|
37992
|
+
} catch (error61) {
|
|
37993
|
+
throw httpError(`The vAPI agent request failed: ${networkFailure(error61, input2)}`);
|
|
37994
|
+
}
|
|
37995
|
+
}
|
|
37996
|
+
function networkFailure(error61, input2) {
|
|
37997
|
+
let url2;
|
|
37998
|
+
try {
|
|
37999
|
+
url2 = new URL(input2 instanceof Request ? input2.url : input2);
|
|
37933
38000
|
} catch {
|
|
37934
|
-
|
|
38001
|
+
return "the request did not reach vAPI.";
|
|
37935
38002
|
}
|
|
38003
|
+
return describeNetworkFailure(error61, url2);
|
|
37936
38004
|
}
|
|
37937
38005
|
function notLinkedError() {
|
|
37938
38006
|
return new AgentLinkError("not_linked", "Run vapi login first.");
|
|
@@ -44371,6 +44439,7 @@ async function buildX402Payment(args) {
|
|
|
44371
44439
|
nowSeconds: args.nowSeconds ?? Math.floor(Date.now() / 1e3),
|
|
44372
44440
|
...args.maximumValidBeforeSeconds === void 0 ? {} : { maximumValidBeforeSeconds: args.maximumValidBeforeSeconds }
|
|
44373
44441
|
});
|
|
44442
|
+
await args.beforeSignTypedData?.(typedData);
|
|
44374
44443
|
await args.beforeSign?.({
|
|
44375
44444
|
network: args.quote.accepted.network,
|
|
44376
44445
|
token: args.quote.accepted.asset,
|
|
@@ -44378,6 +44447,7 @@ async function buildX402Payment(args) {
|
|
|
44378
44447
|
authorization
|
|
44379
44448
|
});
|
|
44380
44449
|
const signature = await args.signer.signTypedData(typedData);
|
|
44450
|
+
args.onSigned?.();
|
|
44381
44451
|
const payload = {
|
|
44382
44452
|
x402Version: 2,
|
|
44383
44453
|
resource: args.quote.resource,
|
|
@@ -44397,6 +44467,8 @@ async function buildCompatibleX402Payment(args) {
|
|
|
44397
44467
|
const payment = await buildX402Payment({
|
|
44398
44468
|
signer: args.account,
|
|
44399
44469
|
quote: args.quote,
|
|
44470
|
+
...args.beforeSignTypedData ? { beforeSignTypedData: args.beforeSignTypedData } : {},
|
|
44471
|
+
...args.onSigned ? { onSigned: args.onSigned } : {},
|
|
44400
44472
|
...args.nowSeconds === void 0 ? {} : { nowSeconds: args.nowSeconds },
|
|
44401
44473
|
...args.maximumValidBeforeSeconds === void 0 ? {} : { maximumValidBeforeSeconds: args.maximumValidBeforeSeconds },
|
|
44402
44474
|
...args.nonce === void 0 ? {} : { nonce: args.nonce },
|
|
@@ -46796,7 +46868,7 @@ var RunBudgetError = class extends Error {
|
|
|
46796
46868
|
};
|
|
46797
46869
|
|
|
46798
46870
|
// src/support-report.ts
|
|
46799
|
-
var VAPI_CLIENT_VERSION = "0.
|
|
46871
|
+
var VAPI_CLIENT_VERSION = "0.16.0";
|
|
46800
46872
|
|
|
46801
46873
|
// src/x402-pay.ts
|
|
46802
46874
|
var X402PaymentError = class extends Error {
|
|
@@ -46987,13 +47059,23 @@ async function completeX402Payment(args) {
|
|
|
46987
47059
|
const spendReservation = {
|
|
46988
47060
|
ledgerPath: args.ledgerPath ?? getVapiPaths().ledger,
|
|
46989
47061
|
now: args.now,
|
|
46990
|
-
...args.wallet === void 0 ? {} : { wallet: args.wallet }
|
|
47062
|
+
...args.wallet === void 0 ? {} : { wallet: args.wallet },
|
|
47063
|
+
...args.taskFunding === void 0 ? {} : {
|
|
47064
|
+
kind: "escrow-funding",
|
|
47065
|
+
taskKey: args.taskFunding.taskKey,
|
|
47066
|
+
maxPerTaskAtomic: args.taskFunding.maxPerTaskAtomic
|
|
47067
|
+
}
|
|
46991
47068
|
};
|
|
46992
47069
|
let reservationId;
|
|
46993
47070
|
let reservedOn;
|
|
46994
47071
|
if (args.runBudget === void 0) {
|
|
46995
47072
|
try {
|
|
46996
|
-
|
|
47073
|
+
if (args.taskFunding) reservationId = args.paymentId ?? randomUUID2();
|
|
47074
|
+
const reservation = await reserveSpend(quote.amountAtomic, args.caps, {
|
|
47075
|
+
...spendReservation,
|
|
47076
|
+
...reservationId ? { reservationId } : {}
|
|
47077
|
+
});
|
|
47078
|
+
reservedOn = reservation.date;
|
|
46997
47079
|
} catch (error61) {
|
|
46998
47080
|
throw walletCapError(error61, quote.amountAtomic, args);
|
|
46999
47081
|
}
|
|
@@ -47033,10 +47115,19 @@ async function completeX402Payment(args) {
|
|
|
47033
47115
|
}
|
|
47034
47116
|
const signStarted = nowMs();
|
|
47035
47117
|
let payment;
|
|
47118
|
+
let authorizationProduced = false;
|
|
47036
47119
|
try {
|
|
47037
47120
|
payment = await buildCompatibleX402Payment({
|
|
47038
47121
|
account: args.account,
|
|
47039
47122
|
quote,
|
|
47123
|
+
...args.taskFunding ? {
|
|
47124
|
+
beforeSignTypedData: async (data) => {
|
|
47125
|
+
await args.taskFunding?.beforeSign?.(data, { id: reservationId, date: reservedOn });
|
|
47126
|
+
},
|
|
47127
|
+
onSigned: () => {
|
|
47128
|
+
authorizationProduced = true;
|
|
47129
|
+
}
|
|
47130
|
+
} : {},
|
|
47040
47131
|
...args.beforeSign === void 0 ? {} : { beforeSign: args.beforeSign },
|
|
47041
47132
|
fetchImpl: args.fetchImpl ?? createPublicFetch({
|
|
47042
47133
|
allowPrivateNetwork: args.config.allowPrivateNetwork ?? false
|
|
@@ -47055,14 +47146,17 @@ async function completeX402Payment(args) {
|
|
|
47055
47146
|
}
|
|
47056
47147
|
}
|
|
47057
47148
|
} catch (error61) {
|
|
47058
|
-
if (args.runBudget !== void 0 && reservationId !== void 0 && reservedOn !== void 0) {
|
|
47149
|
+
if ((args.runBudget !== void 0 || args.taskFunding !== void 0) && !authorizationProduced && reservationId !== void 0 && reservedOn !== void 0) {
|
|
47059
47150
|
const released = await releaseUnsentReservation(
|
|
47060
47151
|
args,
|
|
47061
47152
|
quote.amountAtomic,
|
|
47062
47153
|
reservationId,
|
|
47063
47154
|
reservedOn
|
|
47064
47155
|
);
|
|
47065
|
-
if (released)
|
|
47156
|
+
if (released) {
|
|
47157
|
+
args.runBudget?.release(reservationId);
|
|
47158
|
+
await args.taskFunding?.onUnsent?.();
|
|
47159
|
+
}
|
|
47066
47160
|
}
|
|
47067
47161
|
throw error61;
|
|
47068
47162
|
} finally {
|