@mysten-incubation/suipay-buyer 0.3.0 → 0.4.0-dev.1
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 +29 -0
- package/dist/{chunk-XSL5G2RU.js → chunk-BCI3TKYX.js} +352 -3
- package/dist/index.d.ts +111 -5
- package/dist/index.js +1519 -412
- package/dist/{native-transfer-GD3KlVqG.d.ts → native-transfer-DspFvMQc.d.ts} +102 -2
- package/dist/native-transfer.d.ts +1 -1
- package/dist/native-transfer.js +1 -1
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -169,6 +169,35 @@ bytes to the owner signer (ADR-0065). If transaction bytes do not strictly match
|
|
|
169
169
|
the expected operation, signing is refused and a `TransactionVerificationError`
|
|
170
170
|
is thrown.
|
|
171
171
|
|
|
172
|
+
What is checked comes from your own input, never from the gateway's reply
|
|
173
|
+
(ADR-0089). `agents.createAndActivate` signs an open-recipient grant only when
|
|
174
|
+
you pass `accessMode: 'open'`, and only for assets you declared in
|
|
175
|
+
`assetScopes`, with those caps.
|
|
176
|
+
|
|
177
|
+
Activating a policy takes the terms you created it with:
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
// One call: create, then activate with the same input.
|
|
181
|
+
await client.policies.createAndActivate({
|
|
182
|
+
name: 'research',
|
|
183
|
+
asset: 'usdc',
|
|
184
|
+
serviceIds: ['svc-1'],
|
|
185
|
+
totalCap: '10000000',
|
|
186
|
+
maxPerPayment: '1000000',
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// Or activate a draft created earlier. `expected` is required.
|
|
190
|
+
await client.policies.activate(policyId, {
|
|
191
|
+
expected: { asset: 'usdc', totalCap: '10000000', maxPerPayment: '1000000', expiresAt: null, targetCount: 1 },
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Breaking in 0.4.0: `policies.activate(id)` and `policies.activate(id, signer)`
|
|
196
|
+
are refused with `request.invalid` before anything is fetched or signed. Pass
|
|
197
|
+
the policy's terms as `expected` (and the signer as `options.signer`), or use
|
|
198
|
+
`policies.createAndActivate`. `expected.asset` fixes the coin type: a policy
|
|
199
|
+
the gateway reports for another asset is refused before anything is signed.
|
|
200
|
+
|
|
172
201
|
`createAndActivate` and the pool / policy / grant action helpers run the
|
|
173
202
|
prepare → sponsor → sign → execute → finalize round-trip. After execute
|
|
174
203
|
is sent, a lost confirmation is `chain.tx_unconfirmed` (money state
|
|
@@ -1008,6 +1008,17 @@ var INDEXER_CODES = {
|
|
|
1008
1008
|
user: null,
|
|
1009
1009
|
logOnly: true
|
|
1010
1010
|
},
|
|
1011
|
+
"indexer.native_settlement_deferred": {
|
|
1012
|
+
surfaces: ["indexer"],
|
|
1013
|
+
status: null,
|
|
1014
|
+
title: "Native settlement is deferred; holding the checkpoint",
|
|
1015
|
+
paymentState: "not_charged",
|
|
1016
|
+
retry: "after_delay",
|
|
1017
|
+
retryAfterSeconds: 5,
|
|
1018
|
+
nextAction: "retry_later",
|
|
1019
|
+
user: null,
|
|
1020
|
+
logOnly: true
|
|
1021
|
+
},
|
|
1011
1022
|
"indexer.config_invalid": {
|
|
1012
1023
|
surfaces: ["indexer"],
|
|
1013
1024
|
status: null,
|
|
@@ -1138,7 +1149,7 @@ var LIMIT_CODES = {
|
|
|
1138
1149
|
}
|
|
1139
1150
|
},
|
|
1140
1151
|
"limit.rate_limited": {
|
|
1141
|
-
surfaces: ["gateway", "console_server"],
|
|
1152
|
+
surfaces: ["gateway", "console_server", "sdk"],
|
|
1142
1153
|
status: 429,
|
|
1143
1154
|
title: "Rate limit exceeded",
|
|
1144
1155
|
paymentState: "not_charged",
|
|
@@ -1622,6 +1633,55 @@ var REQUEST_CODES = {
|
|
|
1622
1633
|
nextAction: "fix_request",
|
|
1623
1634
|
user: { title: "Address not found", message: "That web address doesn't exist. Check the spelling and try again." }
|
|
1624
1635
|
},
|
|
1636
|
+
"request.recipient_changed": {
|
|
1637
|
+
surfaces: ["gateway"],
|
|
1638
|
+
status: 409,
|
|
1639
|
+
title: "Pay-to address changed while its registry was being checked",
|
|
1640
|
+
paymentState: "not_charged",
|
|
1641
|
+
retry: "never",
|
|
1642
|
+
nextAction: "fix_request",
|
|
1643
|
+
user: {
|
|
1644
|
+
title: "Retry this publish",
|
|
1645
|
+
message: "The payout address changed while its payment registry was being checked. Retry so the current address is checked."
|
|
1646
|
+
}
|
|
1647
|
+
},
|
|
1648
|
+
"request.recipient_registry_invalid": {
|
|
1649
|
+
surfaces: ["gateway"],
|
|
1650
|
+
status: 409,
|
|
1651
|
+
title: "Payment registry does not verify for this deployment",
|
|
1652
|
+
paymentState: "not_charged",
|
|
1653
|
+
retry: "never",
|
|
1654
|
+
nextAction: "fix_request",
|
|
1655
|
+
user: {
|
|
1656
|
+
title: "Registry does not match",
|
|
1657
|
+
message: "The payout address's payment registry does not match this deployment. Fix it, then publish again."
|
|
1658
|
+
}
|
|
1659
|
+
},
|
|
1660
|
+
"request.recipient_registry_missing": {
|
|
1661
|
+
surfaces: ["gateway"],
|
|
1662
|
+
status: 409,
|
|
1663
|
+
title: "Pay-to address has no payment registry",
|
|
1664
|
+
paymentState: "not_charged",
|
|
1665
|
+
retry: "never",
|
|
1666
|
+
nextAction: "fix_request",
|
|
1667
|
+
user: {
|
|
1668
|
+
title: "Create a payment registry",
|
|
1669
|
+
message: "This payout address has no payment registry on this network yet. Create it in the seller console, then publish again."
|
|
1670
|
+
}
|
|
1671
|
+
},
|
|
1672
|
+
"request.recipient_registry_unreadable": {
|
|
1673
|
+
surfaces: ["gateway"],
|
|
1674
|
+
status: 503,
|
|
1675
|
+
title: "Payment registry could not be read",
|
|
1676
|
+
paymentState: "not_charged",
|
|
1677
|
+
retry: "after_delay",
|
|
1678
|
+
retryAfterSeconds: 5,
|
|
1679
|
+
nextAction: "retry_later",
|
|
1680
|
+
user: {
|
|
1681
|
+
title: "Registry unread",
|
|
1682
|
+
message: "The payment registry could not be read just now. Wait a moment and try again."
|
|
1683
|
+
}
|
|
1684
|
+
},
|
|
1625
1685
|
"request.redirect_refused": {
|
|
1626
1686
|
surfaces: ["console_server", "sdk"],
|
|
1627
1687
|
status: 422,
|
|
@@ -2077,7 +2137,7 @@ var SERVICE_CODES = {
|
|
|
2077
2137
|
},
|
|
2078
2138
|
// Boot or configuration fell back to a degraded mode instead of failing.
|
|
2079
2139
|
"service.config_degraded": {
|
|
2080
|
-
surfaces: ["gateway"],
|
|
2140
|
+
surfaces: ["gateway", "console_server"],
|
|
2081
2141
|
status: null,
|
|
2082
2142
|
title: "Service started with degraded configuration",
|
|
2083
2143
|
paymentState: "not_charged",
|
|
@@ -2086,6 +2146,19 @@ var SERVICE_CODES = {
|
|
|
2086
2146
|
user: null,
|
|
2087
2147
|
logOnly: true
|
|
2088
2148
|
},
|
|
2149
|
+
// A readiness gauge moved while the process is still serving. Not a degraded
|
|
2150
|
+
// boot: `service.config_degraded` is reserved for that, and for the sample
|
|
2151
|
+
// that actually fails closed.
|
|
2152
|
+
"service.readiness": {
|
|
2153
|
+
surfaces: ["gateway"],
|
|
2154
|
+
status: null,
|
|
2155
|
+
title: "Readiness gauge updated",
|
|
2156
|
+
paymentState: "not_charged",
|
|
2157
|
+
retry: "never",
|
|
2158
|
+
nextAction: "none",
|
|
2159
|
+
user: null,
|
|
2160
|
+
logOnly: true
|
|
2161
|
+
},
|
|
2089
2162
|
// A best-effort write (a trace event, a receipt, a delivery record) failed.
|
|
2090
2163
|
// The request it belongs to keeps its answer.
|
|
2091
2164
|
"service.bookkeeping_failed": {
|
|
@@ -2097,6 +2170,39 @@ var SERVICE_CODES = {
|
|
|
2097
2170
|
nextAction: "none",
|
|
2098
2171
|
user: null,
|
|
2099
2172
|
logOnly: true
|
|
2173
|
+
},
|
|
2174
|
+
// What a process started with: network, posture, rails, gas pool. Healthy.
|
|
2175
|
+
"service.boot": {
|
|
2176
|
+
surfaces: ["gateway", "seller", "indexer"],
|
|
2177
|
+
status: null,
|
|
2178
|
+
title: "Service started",
|
|
2179
|
+
paymentState: "not_charged",
|
|
2180
|
+
retry: "never",
|
|
2181
|
+
nextAction: "none",
|
|
2182
|
+
user: null,
|
|
2183
|
+
logOnly: true
|
|
2184
|
+
},
|
|
2185
|
+
// A background worker started, stopped, swept or retried on schedule. Healthy.
|
|
2186
|
+
"service.lifecycle": {
|
|
2187
|
+
surfaces: ["gateway", "seller", "indexer"],
|
|
2188
|
+
status: null,
|
|
2189
|
+
title: "Background work progressed",
|
|
2190
|
+
paymentState: "not_charged",
|
|
2191
|
+
retry: "never",
|
|
2192
|
+
nextAction: "none",
|
|
2193
|
+
user: null,
|
|
2194
|
+
logOnly: true
|
|
2195
|
+
},
|
|
2196
|
+
// Detail about healthy traffic an operator may want when reading a trace.
|
|
2197
|
+
"service.diagnostic": {
|
|
2198
|
+
surfaces: ["gateway", "seller", "indexer"],
|
|
2199
|
+
status: null,
|
|
2200
|
+
title: "Diagnostic detail",
|
|
2201
|
+
paymentState: "not_charged",
|
|
2202
|
+
retry: "never",
|
|
2203
|
+
nextAction: "none",
|
|
2204
|
+
user: null,
|
|
2205
|
+
logOnly: true
|
|
2100
2206
|
}
|
|
2101
2207
|
};
|
|
2102
2208
|
|
|
@@ -2797,6 +2903,240 @@ function newTraceId(randomBytes = cryptoRandomBytes) {
|
|
|
2797
2903
|
return /^0+$/.test(hex) ? newTraceId(randomBytes) : hex;
|
|
2798
2904
|
}
|
|
2799
2905
|
|
|
2906
|
+
// ../core/dist/errors/context-allowlist.js
|
|
2907
|
+
var CONTEXT_ALLOWLIST = /* @__PURE__ */ new Set([
|
|
2908
|
+
// Settlement and request identifiers.
|
|
2909
|
+
"txDigest",
|
|
2910
|
+
"digest",
|
|
2911
|
+
"challengeId",
|
|
2912
|
+
"paymentId",
|
|
2913
|
+
"paymentHash",
|
|
2914
|
+
"paymentKey",
|
|
2915
|
+
"paymentState",
|
|
2916
|
+
"requestId",
|
|
2917
|
+
"traceId",
|
|
2918
|
+
"clientId",
|
|
2919
|
+
"serviceId",
|
|
2920
|
+
"configId",
|
|
2921
|
+
"seedId",
|
|
2922
|
+
"grantId",
|
|
2923
|
+
"grantObjectId",
|
|
2924
|
+
"policyId",
|
|
2925
|
+
"onChainPolicyId",
|
|
2926
|
+
"sameGrantObjectId",
|
|
2927
|
+
"verifiedGrant",
|
|
2928
|
+
"poolObjectId",
|
|
2929
|
+
"packageId",
|
|
2930
|
+
"activePackageId",
|
|
2931
|
+
"expectedPackageId",
|
|
2932
|
+
"actualPackageId",
|
|
2933
|
+
"mandateId",
|
|
2934
|
+
"session",
|
|
2935
|
+
"coinId",
|
|
2936
|
+
"coinIds",
|
|
2937
|
+
"id",
|
|
2938
|
+
"dedupeKey",
|
|
2939
|
+
"hook",
|
|
2940
|
+
// Addresses (public on chain).
|
|
2941
|
+
"owner",
|
|
2942
|
+
"payTo",
|
|
2943
|
+
"recipient",
|
|
2944
|
+
"delegateAddress",
|
|
2945
|
+
// Codes, kinds and states.
|
|
2946
|
+
"code",
|
|
2947
|
+
"innerCode",
|
|
2948
|
+
"requestedCode",
|
|
2949
|
+
"failureCode",
|
|
2950
|
+
"oauthError",
|
|
2951
|
+
"errorKind",
|
|
2952
|
+
"kind",
|
|
2953
|
+
"mode",
|
|
2954
|
+
"effectiveMode",
|
|
2955
|
+
"state",
|
|
2956
|
+
"outcome",
|
|
2957
|
+
"status",
|
|
2958
|
+
"httpStatus",
|
|
2959
|
+
"reason",
|
|
2960
|
+
"action",
|
|
2961
|
+
"stage",
|
|
2962
|
+
"paid",
|
|
2963
|
+
"delivery",
|
|
2964
|
+
"sellerStatus",
|
|
2965
|
+
"sellerCode",
|
|
2966
|
+
"bindingCode",
|
|
2967
|
+
"errorName",
|
|
2968
|
+
"gasStationStatus",
|
|
2969
|
+
"readFailure",
|
|
2970
|
+
"refusal",
|
|
2971
|
+
"refusedAs",
|
|
2972
|
+
"registryCode",
|
|
2973
|
+
"sessionDecision",
|
|
2974
|
+
"settleCode",
|
|
2975
|
+
"signedRequest",
|
|
2976
|
+
"signerCode",
|
|
2977
|
+
"consentCode",
|
|
2978
|
+
"publicReason",
|
|
2979
|
+
"details",
|
|
2980
|
+
"event",
|
|
2981
|
+
"eventType",
|
|
2982
|
+
"surface",
|
|
2983
|
+
"scope",
|
|
2984
|
+
"field",
|
|
2985
|
+
"header",
|
|
2986
|
+
"dependency",
|
|
2987
|
+
"network",
|
|
2988
|
+
"rails",
|
|
2989
|
+
"shard",
|
|
2990
|
+
"metric",
|
|
2991
|
+
// Gateway readiness gauge. Fixed marks only: 0 or 1, and up, down, skipped, unknown.
|
|
2992
|
+
"ready",
|
|
2993
|
+
"grpc",
|
|
2994
|
+
"enoki",
|
|
2995
|
+
"postgres",
|
|
2996
|
+
"alarm",
|
|
2997
|
+
"alert",
|
|
2998
|
+
"from",
|
|
2999
|
+
"to",
|
|
3000
|
+
"expected",
|
|
3001
|
+
"required",
|
|
3002
|
+
"violated",
|
|
3003
|
+
"diverged",
|
|
3004
|
+
"replaced",
|
|
3005
|
+
"suppressed",
|
|
3006
|
+
"unknown",
|
|
3007
|
+
"verified",
|
|
3008
|
+
"verification",
|
|
3009
|
+
"simulation",
|
|
3010
|
+
"isNew",
|
|
3011
|
+
"needsTopup",
|
|
3012
|
+
"operatorCapSet",
|
|
3013
|
+
"wantAgent",
|
|
3014
|
+
"wantGrant",
|
|
3015
|
+
"wantPool",
|
|
3016
|
+
"limitedBy",
|
|
3017
|
+
"peer",
|
|
3018
|
+
// Counts, amounts and timings.
|
|
3019
|
+
"amount",
|
|
3020
|
+
"scanned",
|
|
3021
|
+
"deleted",
|
|
3022
|
+
"intents",
|
|
3023
|
+
"policies",
|
|
3024
|
+
"connections",
|
|
3025
|
+
"events",
|
|
3026
|
+
"maxQueueSize",
|
|
3027
|
+
"bytes",
|
|
3028
|
+
"sha256",
|
|
3029
|
+
"ts",
|
|
3030
|
+
"count",
|
|
3031
|
+
"countRaw",
|
|
3032
|
+
"matchingCount",
|
|
3033
|
+
"registry_field_count",
|
|
3034
|
+
"applied",
|
|
3035
|
+
"attempt",
|
|
3036
|
+
"attempts",
|
|
3037
|
+
"cap",
|
|
3038
|
+
"max",
|
|
3039
|
+
"maxChallenges",
|
|
3040
|
+
"MAX_GAS_COIN_PAGES",
|
|
3041
|
+
"pagesScanned",
|
|
3042
|
+
"size",
|
|
3043
|
+
"free",
|
|
3044
|
+
"used",
|
|
3045
|
+
"fill",
|
|
3046
|
+
"limits",
|
|
3047
|
+
"refills",
|
|
3048
|
+
"refilled",
|
|
3049
|
+
"split",
|
|
3050
|
+
"unconfirmed",
|
|
3051
|
+
"spent",
|
|
3052
|
+
"reserveAfter",
|
|
3053
|
+
"claimedUntilMs",
|
|
3054
|
+
"repaired",
|
|
3055
|
+
"splits",
|
|
3056
|
+
"spend",
|
|
3057
|
+
"reserve",
|
|
3058
|
+
"reserveBalance",
|
|
3059
|
+
"ownerDailyMist",
|
|
3060
|
+
"ownerHourlyMist",
|
|
3061
|
+
"ownerIdentityDailyMist",
|
|
3062
|
+
"delegateDailyMist",
|
|
3063
|
+
"delegateHourlyMist",
|
|
3064
|
+
"delegateIdentityDailyMist",
|
|
3065
|
+
"consecutiveFailures",
|
|
3066
|
+
"failuresInARow",
|
|
3067
|
+
"epochReadFailures",
|
|
3068
|
+
"daysRemaining",
|
|
3069
|
+
"deadline",
|
|
3070
|
+
"delay",
|
|
3071
|
+
"delayMs",
|
|
3072
|
+
"ageMs",
|
|
3073
|
+
"timeoutMs",
|
|
3074
|
+
"nowMs",
|
|
3075
|
+
"switchedAtMs",
|
|
3076
|
+
"observeUntil",
|
|
3077
|
+
"window",
|
|
3078
|
+
"checkpointSeq",
|
|
3079
|
+
"eventSeq",
|
|
3080
|
+
"sampleSubjects",
|
|
3081
|
+
// Operator-facing error text. Redacted and length-capped like every string.
|
|
3082
|
+
"error",
|
|
3083
|
+
"errors",
|
|
3084
|
+
"err",
|
|
3085
|
+
"lastError",
|
|
3086
|
+
"outcomeError",
|
|
3087
|
+
"detail",
|
|
3088
|
+
"raw",
|
|
3089
|
+
"value"
|
|
3090
|
+
]);
|
|
3091
|
+
var MAX_CONTEXT_STRING = 512;
|
|
3092
|
+
var MAX_CONTEXT_ARRAY = 32;
|
|
3093
|
+
var MAX_CONTEXT_DEPTH = 4;
|
|
3094
|
+
function filterContext(context) {
|
|
3095
|
+
let dropped = 0;
|
|
3096
|
+
const filterValue = (value2, depth) => {
|
|
3097
|
+
if (typeof value2 === "bigint")
|
|
3098
|
+
return value2.toString();
|
|
3099
|
+
if (value2 === null || typeof value2 !== "object")
|
|
3100
|
+
return value2;
|
|
3101
|
+
if (depth >= MAX_CONTEXT_DEPTH) {
|
|
3102
|
+
dropped += 1;
|
|
3103
|
+
return void 0;
|
|
3104
|
+
}
|
|
3105
|
+
if (Array.isArray(value2)) {
|
|
3106
|
+
return value2.slice(0, MAX_CONTEXT_ARRAY).map((item) => filterValue(item, depth + 1));
|
|
3107
|
+
}
|
|
3108
|
+
if (value2 instanceof Date)
|
|
3109
|
+
return value2.toISOString();
|
|
3110
|
+
return filterObject(value2, depth + 1);
|
|
3111
|
+
};
|
|
3112
|
+
const filterObject = (object, depth) => {
|
|
3113
|
+
const out = {};
|
|
3114
|
+
for (const [key, value2] of Object.entries(object)) {
|
|
3115
|
+
if (!CONTEXT_ALLOWLIST.has(key)) {
|
|
3116
|
+
dropped += 1;
|
|
3117
|
+
continue;
|
|
3118
|
+
}
|
|
3119
|
+
const kept = filterValue(value2, depth);
|
|
3120
|
+
if (kept !== void 0)
|
|
3121
|
+
out[key] = kept;
|
|
3122
|
+
}
|
|
3123
|
+
return out;
|
|
3124
|
+
};
|
|
3125
|
+
const value = filterObject(context, 0);
|
|
3126
|
+
return { value, dropped };
|
|
3127
|
+
}
|
|
3128
|
+
function capContextStrings(value) {
|
|
3129
|
+
if (typeof value === "string") {
|
|
3130
|
+
return value.length > MAX_CONTEXT_STRING ? `${value.slice(0, MAX_CONTEXT_STRING)}\u2026` : value;
|
|
3131
|
+
}
|
|
3132
|
+
if (Array.isArray(value))
|
|
3133
|
+
return value.map(capContextStrings);
|
|
3134
|
+
if (value !== null && typeof value === "object") {
|
|
3135
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, capContextStrings(v)]));
|
|
3136
|
+
}
|
|
3137
|
+
return value;
|
|
3138
|
+
}
|
|
3139
|
+
|
|
2800
3140
|
// ../core/dist/errors/log.js
|
|
2801
3141
|
var MAX_CAUSE_DEPTH = 5;
|
|
2802
3142
|
function causeChain(error) {
|
|
@@ -2847,6 +3187,7 @@ function safeStringify(value) {
|
|
|
2847
3187
|
function errorLogLine(context, error, now = /* @__PURE__ */ new Date()) {
|
|
2848
3188
|
const wantStack = context.withStack ?? (context.httpStatus !== void 0 && context.httpStatus >= 500);
|
|
2849
3189
|
const stack = wantStack && error instanceof Error && error.stack ? redactSecrets(error.stack) : void 0;
|
|
3190
|
+
const filtered = context.context ? filterContext(context.context) : void 0;
|
|
2850
3191
|
return {
|
|
2851
3192
|
level: context.level ?? "error",
|
|
2852
3193
|
time: now.toISOString(),
|
|
@@ -2858,10 +3199,12 @@ function errorLogLine(context, error, now = /* @__PURE__ */ new Date()) {
|
|
|
2858
3199
|
trace_id: context.traceId || newTraceId(),
|
|
2859
3200
|
cause: error === void 0 ? [] : causeChain(error),
|
|
2860
3201
|
...stack ? { stack } : {},
|
|
2861
|
-
...
|
|
3202
|
+
...filtered ? { context: capContextStrings(redactValue(filtered.value)) } : {},
|
|
3203
|
+
...filtered && filtered.dropped > 0 ? { context_dropped: filtered.dropped } : {}
|
|
2862
3204
|
};
|
|
2863
3205
|
}
|
|
2864
3206
|
var stderrWriter = (line) => console.error(line);
|
|
3207
|
+
var lineShipper = null;
|
|
2865
3208
|
function logError(context, error, write = stderrWriter) {
|
|
2866
3209
|
let line;
|
|
2867
3210
|
let traceId = "";
|
|
@@ -2882,6 +3225,12 @@ function logError(context, error, write = stderrWriter) {
|
|
|
2882
3225
|
write(line);
|
|
2883
3226
|
} catch {
|
|
2884
3227
|
}
|
|
3228
|
+
if (write === stderrWriter && lineShipper) {
|
|
3229
|
+
try {
|
|
3230
|
+
lineShipper.enqueue(line, context.level ?? "error");
|
|
3231
|
+
} catch {
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
2885
3234
|
}
|
|
2886
3235
|
|
|
2887
3236
|
// ../core/dist/errors/suipay-error.js
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as ErrorCode, P as PaymentState, N as NextAction, R as Receipt, C as CodeFor, D as DelegationScope, O as Offer } from './native-transfer-
|
|
2
|
-
export { B as BuildNativeTransferInput, M as McpPaymentSigner, a as NativeTransferAccept, b as NativeTransferBuild, c as NativeTransferError, d as NativeTransferGas, e as NativeTransferSignerInput, S as SuiPayError, f as SuiPayErrorFields, g as buildMcpPaymentPayload, h as buildNativeTransferBytes, i as createNativeTransferSigner, j as inspectNativeTransfer, t as toErrorFields } from './native-transfer-
|
|
1
|
+
import { E as ErrorCode, P as PaymentState, N as NextAction, R as Receipt, C as CodeFor, D as DelegationScope, O as Offer } from './native-transfer-DspFvMQc.js';
|
|
2
|
+
export { B as BuildNativeTransferInput, M as McpPaymentSigner, a as NativeTransferAccept, b as NativeTransferBuild, c as NativeTransferError, d as NativeTransferGas, e as NativeTransferSignerInput, S as SuiPayError, f as SuiPayErrorFields, g as buildMcpPaymentPayload, h as buildNativeTransferBytes, i as createNativeTransferSigner, j as inspectNativeTransfer, t as toErrorFields } from './native-transfer-DspFvMQc.js';
|
|
3
3
|
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
4
4
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
5
5
|
import { KeyObject } from 'node:crypto';
|
|
@@ -250,6 +250,16 @@ interface CreateDelegatedSignerResponse {
|
|
|
250
250
|
method: string;
|
|
251
251
|
idempotentReplay: boolean;
|
|
252
252
|
grants: PreparedSessionTxKind[];
|
|
253
|
+
/**
|
|
254
|
+
* On a replay, grants whose create already executed. Finalize their digest;
|
|
255
|
+
* sponsoring them again could mint a second grant.
|
|
256
|
+
*/
|
|
257
|
+
submitted?: SubmittedGrantCreate[];
|
|
258
|
+
}
|
|
259
|
+
interface SubmittedGrantCreate {
|
|
260
|
+
grantId: string;
|
|
261
|
+
asset: string;
|
|
262
|
+
digest: string;
|
|
253
263
|
}
|
|
254
264
|
interface FinalizeSessionResponse {
|
|
255
265
|
delegatedSignerId: string;
|
|
@@ -385,6 +395,48 @@ interface CreatePolicyResponse {
|
|
|
385
395
|
interface CreateProfileResponse {
|
|
386
396
|
profile: AgentProfile;
|
|
387
397
|
}
|
|
398
|
+
/**
|
|
399
|
+
* Discriminated union for prepared consent grant transactions.
|
|
400
|
+
* Returned by POST /v1/oauth/sessions/:id/grants/prepare.
|
|
401
|
+
*/
|
|
402
|
+
type PreparedConsentGrant = {
|
|
403
|
+
kind: 'sponsored';
|
|
404
|
+
connectionGrantId: string;
|
|
405
|
+
connectionGrantIds?: string[];
|
|
406
|
+
asset: string;
|
|
407
|
+
coinType: string;
|
|
408
|
+
target: string;
|
|
409
|
+
sender: string;
|
|
410
|
+
bytes: string;
|
|
411
|
+
digest: string;
|
|
412
|
+
transactionKindBytes?: string;
|
|
413
|
+
completed?: false;
|
|
414
|
+
} | {
|
|
415
|
+
kind: 'unsponsored';
|
|
416
|
+
connectionGrantId: string;
|
|
417
|
+
connectionGrantIds?: string[];
|
|
418
|
+
asset: string;
|
|
419
|
+
coinType: string;
|
|
420
|
+
target: string;
|
|
421
|
+
sender: string;
|
|
422
|
+
transactionKindBytes: string;
|
|
423
|
+
bytes?: undefined;
|
|
424
|
+
digest?: undefined;
|
|
425
|
+
completed?: false;
|
|
426
|
+
} | {
|
|
427
|
+
kind: 'completed';
|
|
428
|
+
connectionGrantId: string;
|
|
429
|
+
connectionGrantIds?: string[];
|
|
430
|
+
asset: string;
|
|
431
|
+
coinType: string;
|
|
432
|
+
target: string;
|
|
433
|
+
sender: string;
|
|
434
|
+
bytes?: string;
|
|
435
|
+
digest?: string;
|
|
436
|
+
grantObjectId?: string;
|
|
437
|
+
completed: true;
|
|
438
|
+
transactionKindBytes?: string;
|
|
439
|
+
};
|
|
388
440
|
/** @deprecated Renamed to {@link DelegatedSignerSession}. */
|
|
389
441
|
type DelegatedSignerGrant = DelegatedSignerSession;
|
|
390
442
|
/** @deprecated Renamed to {@link PreparedSessionTxKind}. */
|
|
@@ -446,6 +498,11 @@ interface AgentsApi {
|
|
|
446
498
|
/**
|
|
447
499
|
* Create then sponsor/sign/execute/finalize every returned grant.
|
|
448
500
|
* Stops without retrying if any grant may already have been submitted.
|
|
501
|
+
*
|
|
502
|
+
* What is signed follows `input`, not the gateway's reply: an open grant
|
|
503
|
+
* only when `accessMode` is `'open'`, and only for an asset declared in
|
|
504
|
+
* `assetScopes`, with those caps. Anything else throws
|
|
505
|
+
* `TransactionVerificationError` before the signer is asked.
|
|
449
506
|
*/
|
|
450
507
|
createAndActivate(input: CreateDelegatedSignerInput, signer?: TransactionSigner): Promise<BuyerResult<CreateAndActivateResult>>;
|
|
451
508
|
}
|
|
@@ -471,6 +528,25 @@ interface SpendAccountsApi {
|
|
|
471
528
|
/** @deprecated Renamed to {@link SpendAccountsApi}. Kept one minor for compatibility. */
|
|
472
529
|
type AccountsApi = SpendAccountsApi;
|
|
473
530
|
|
|
531
|
+
/**
|
|
532
|
+
* The terms the caller created a policy with. `activate` signs only a
|
|
533
|
+
* `create_spend_policy` carrying exactly these values, so a gateway cannot
|
|
534
|
+
* raise a cap or drop an expiry between create and activate.
|
|
535
|
+
*/
|
|
536
|
+
interface PolicyActivationExpectation {
|
|
537
|
+
/** The asset the policy was created for: its table id (`usdc`) or coin type. */
|
|
538
|
+
asset: string;
|
|
539
|
+
totalCap: string;
|
|
540
|
+
maxPerPayment: string;
|
|
541
|
+
/** ISO time or epoch ms; omit or null for no expiry. */
|
|
542
|
+
expiresAt?: string | number | null;
|
|
543
|
+
/** Number of distinct services the policy was created for. */
|
|
544
|
+
targetCount: number;
|
|
545
|
+
}
|
|
546
|
+
interface ActivatePolicyOptions {
|
|
547
|
+
expected: PolicyActivationExpectation;
|
|
548
|
+
signer?: TransactionSigner;
|
|
549
|
+
}
|
|
474
550
|
interface PoliciesApi {
|
|
475
551
|
list(): Promise<BuyerResult<BuyerPolicy[]>>;
|
|
476
552
|
get(id: string): Promise<BuyerResult<BuyerPolicy>>;
|
|
@@ -479,7 +555,16 @@ interface PoliciesApi {
|
|
|
479
555
|
preparePause(id: string): Promise<BuyerResult<PreparedIntent>>;
|
|
480
556
|
prepareResume(id: string): Promise<BuyerResult<PreparedIntent>>;
|
|
481
557
|
prepareRevoke(id: string): Promise<BuyerResult<PreparedIntent>>;
|
|
482
|
-
|
|
558
|
+
/**
|
|
559
|
+
* Put a draft policy on chain. `options.expected` is required: the owner
|
|
560
|
+
* signs only the caps, expiry and target count given there. Without it
|
|
561
|
+
* nothing is signed and the call fails with `request.invalid`.
|
|
562
|
+
*/
|
|
563
|
+
activate(id: string, options: ActivatePolicyOptions): Promise<BuyerResult<ExecuteIntentResult>>;
|
|
564
|
+
/** Create a policy and activate it with the same input as the expectation. */
|
|
565
|
+
createAndActivate(input: CreatePolicyInput, signer?: TransactionSigner): Promise<BuyerResult<ExecuteIntentResult & {
|
|
566
|
+
policy: BuyerPolicy;
|
|
567
|
+
}>>;
|
|
483
568
|
pause(id: string, signer?: TransactionSigner): Promise<BuyerResult<ExecuteIntentResult>>;
|
|
484
569
|
resume(id: string, signer?: TransactionSigner): Promise<BuyerResult<ExecuteIntentResult>>;
|
|
485
570
|
revoke(id: string, signer?: TransactionSigner): Promise<BuyerResult<ExecuteIntentResult>>;
|
|
@@ -905,7 +990,7 @@ declare function createReader(options: PayerReadClientOptions): PayerReadClient;
|
|
|
905
990
|
* prior done result is never lost when capability is unavailable.
|
|
906
991
|
* 5. Derive payment_id_hash / terms_hash.
|
|
907
992
|
* 6. Build the full executable pay transaction (real shared-object versions).
|
|
908
|
-
* 7. Validate-before-sign (
|
|
993
|
+
* 7. Validate-before-sign (intended pay plus the caller's gas authority).
|
|
909
994
|
* 8. Sign, 9. execute, 10. complete(ledger) with terminal ok/ambiguous, settle.
|
|
910
995
|
* x402 refuses before 3 when its offer, gas pins or epoch are missing, skips
|
|
911
996
|
* 4, builds 6 with the offer-pinned sponsor gas, and in place of 9-10
|
|
@@ -1740,6 +1825,9 @@ interface VerifyPreparedSettlementInput {
|
|
|
1740
1825
|
*/
|
|
1741
1826
|
expectedGrantObjectId?: string;
|
|
1742
1827
|
expectedPoolObjectId?: string;
|
|
1828
|
+
/** Independently read network bounds for Epoch / ValidDuring envelopes. */
|
|
1829
|
+
getCurrentEpoch?: () => Promise<bigint | number>;
|
|
1830
|
+
getChainIdentifier?: () => Promise<string>;
|
|
1743
1831
|
}
|
|
1744
1832
|
/**
|
|
1745
1833
|
* Verify a prepared settlement and return it, or throw
|
|
@@ -1763,4 +1851,22 @@ interface VerifyPreparedSettlementInput {
|
|
|
1763
1851
|
*/
|
|
1764
1852
|
declare function verifyPreparedPayment(input: VerifyPreparedSettlementInput): Promise<PreparedSettlement>;
|
|
1765
1853
|
|
|
1766
|
-
|
|
1854
|
+
interface OAuthDelegateBinding {
|
|
1855
|
+
clientId: string;
|
|
1856
|
+
redirectUri: string;
|
|
1857
|
+
resource: string;
|
|
1858
|
+
scope: string;
|
|
1859
|
+
codeChallenge: string;
|
|
1860
|
+
delegateAddress: string | null;
|
|
1861
|
+
}
|
|
1862
|
+
interface OAuthDelegateProof {
|
|
1863
|
+
signature: string;
|
|
1864
|
+
expiresAtMs: number;
|
|
1865
|
+
ownerAddress: string;
|
|
1866
|
+
}
|
|
1867
|
+
declare const OAUTH_DELEGATE_PROOF_TTL_MS: number;
|
|
1868
|
+
/** Exact text values are signed; the Sui address alone is normalized. */
|
|
1869
|
+
declare function encodeOAuthDelegateProof(binding: OAuthDelegateBinding, expiresAtMs: number, ownerAddress: string): Uint8Array;
|
|
1870
|
+
declare function verifyOAuthDelegateProof(binding: OAuthDelegateBinding, proof: unknown, nowMs?: number, expectedOwner?: string): Promise<boolean>;
|
|
1871
|
+
|
|
1872
|
+
export { type AccountApi, type AccountsApi, type ActivatePolicyOptions, type AgentConnectionManifest, type AgentGrantBinding, type AgentProfile, type AgentSessionBinding, type AgentsApi, type AssetScopeInput, type BuyerAccount, type BuyerClient, type BuyerClientError, type BuyerClientOptions, type BuyerConnection, type BuyerPolicy, type BuyerResult, type CatalogApi, type CatalogService, type CreateAndActivateResult, type CreateDelegatedSignerInput, type CreateDelegatedSignerResponse, type CreatePolicyInput, type CreatePolicyResponse, type CreateProfileInput, type CreateProfileResponse, type DashboardBridgeResolvers, type DashboardConnectionManifest, type DelegatedSigner, type DelegatedSignerGrant, type DelegatedSignerGrantStatus, type DelegatedSignerSession, type DelegatedSignerStatus, type DelegatedSignersApi, ErrorCode, type ExecuteIntentKind, type ExecuteIntentResult, type FinalizeGrantResponse, type FinalizeIntentResult, type FinalizeSessionResponse, type FundHistoryItem, type GrantsApi, type ManifestError, type ManifestResult, NextAction, OAUTH_DELEGATE_PROOF_TTL_MS, type OAuthDelegateBinding, type OAuthDelegateProof, type PatchProfileInput, type PayInput, type PayResult, type Payer, type PayerOptions, type PaymentMethod, type PaymentReceipt, type PaymentRow, PaymentState, type PaymentStatusValue, type PaymentsApi, type PoliciesApi, type PolicyActivationExpectation, type PolicyStatus, type PolicyTarget, type PrepareCreateGrantInput, type PrepareCreateSessionInput, type PreparedConsentGrant, type PreparedGrantTxKind, type PreparedIntent, type PreparedRevokeTxKind, type PreparedSessionTxKind, type ProfileStatus, type ProfilesApi, type ReceiptsApi, type RegistryApi, type RegistryService, type RevokeDelegatedSignerResponse, type ServiceRail, type ServicesApi, type SessionsApi, type SettlementRow, type SettlementsApi, type SpendAccount, type SpendAccountStatus, type SpendAccountsApi, type SponsoredTx, type SubmittedGrantCreate, type TransactionSigner, type TrustSignal, createBuyer, createBuyerControlPlane, createMemoryLedger, createPayer, createReader, dashboardManifestToAgentManifest, encodeOAuthDelegateProof, manifestToSession, parseAgentManifest, personalMessageSigner, verifyOAuthDelegateProof, verifyPreparedPayment };
|