uvd-x402-sdk 2.108.0 → 2.110.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 CHANGED
@@ -10,7 +10,7 @@ Users sign a message or transaction, and the Ultravioleta facilitator handles on
10
10
 
11
11
  ## Features
12
12
 
13
- **Arras NEAR escrow (v2.108.0):** offline local-key NEP-366 authorization, canonical Rust payment IDs and pull lifecycle helpers through `uvd-x402-sdk/near`. [Guide and agent example](docs/near-escrow.md). As of 2026-11-02 the facilitator advertises escrow only on testnet, and the SDK's escrow contract registry has no mainnet row yet.
13
+ **Arras NEAR escrow (v2.110.0):** offline local-key NEP-366 authorization, canonical Rust payment IDs and pull lifecycle helpers through `uvd-x402-sdk/near`. [Guide and agent example](docs/near-escrow.md). As of 2026-11-03 the production facilitator relays NEAR escrow only on testnet. Since 2.110.0 the registry allows mainnet escrow signing only for `v1.arras-escrow.near`; testnet keeps `arras-v1b-1101.testnet`.
14
14
 
15
15
  - **31 Networks**: EVM (19 including HashKey Chain, Arc, Scroll, SKALE Base, Robinhood Chain), Solana, Fogo, Stellar, NEAR, Algorand, Sui, XRP Ledger, Hedera (mainnet + testnet)
16
16
  - **Multi-Stablecoin**: USDC, EURC, AUSD, PYUSD, USDT, USDG (Robinhood Chain)
@@ -19,7 +19,7 @@ interface PaymentIdParams extends EscrowMsgParams {
19
19
  }
20
20
  interface NearLocalSigner {
21
21
  readonly publicKey: Uint8Array;
22
- /** Sign the NEP-366 SHA-256 digest directly, without a NEP-413 envelope. */
22
+ /** Sign the supplied SHA-256 digest directly. The calling helper supplies its domain prefix. */
23
23
  sign(digest: Uint8Array): Uint8Array | Promise<Uint8Array>;
24
24
  }
25
25
  interface NearEscrowDelegateOptions {
@@ -65,7 +65,7 @@ declare const NEAR_ESCROW_TOKENS: Readonly<Record<NearEscrowNetwork, string>>;
65
65
  /**
66
66
  * The Arras escrow deployments this SDK signs for, per network. Any other escrowContract is refused before the
67
67
  * signer is called, for authorization and lifecycle alike: a signed delegate can be relayed by anyone, so a 402
68
- * server must not be able to point it at its own account. Mainnet stays empty until its contract ships in a release.
68
+ * server must not be able to point it at its own account. Only deployed Arras v1 contracts are registered.
69
69
  */
70
70
  declare const NEAR_ESCROW_CONTRACTS: Readonly<Record<NearEscrowNetwork, readonly string[]>>;
71
71
  /** Canonical Arras JSON: field order, decimal-string timestamps, lowercase hex, no spaces. */
@@ -95,6 +95,154 @@ declare const withdrawFor: (o: NearEscrowDelegateOptions, account: string) => Pr
95
95
  interface AuthorizeFromBudget {
96
96
  authorizeFromBudget(request: unknown): Promise<NearEscrowPayment>;
97
97
  }
98
+ /** Local-key exact NEP-366 payment; uses the escrow serializer and raw digest signer. */
99
+ interface NearExactDelegateOptions extends Omit<NearEscrowDelegateOptions, 'escrowContract'> {
100
+ token: string;
101
+ payTo: string;
102
+ amount: NearUnsigned;
103
+ }
104
+ interface NearExactPayment extends Omit<NearEscrowPayment, 'scheme'> {
105
+ scheme: 'exact';
106
+ }
107
+ declare function signExactNearDelegate(options: NearExactDelegateOptions): Promise<NearExactPayment>;
108
+
109
+ interface Nep413Message {
110
+ message: string;
111
+ nonce: Uint8Array;
112
+ recipient: string;
113
+ callbackUrl?: string;
114
+ }
115
+ interface SignNep413Options extends Nep413Message {
116
+ signer: NearLocalSigner;
117
+ accountId: string;
118
+ }
119
+ interface Nep413SignedMessage {
120
+ accountId: string;
121
+ publicKey: string;
122
+ signature: string;
123
+ }
124
+ /** Prefix 2^31+413 followed by message, fixed nonce, recipient and Option<String> callback. */
125
+ declare function nep413Preimage(options: Nep413Message): Uint8Array;
126
+ declare function signNep413(options: SignNep413Options): Promise<Nep413SignedMessage>;
127
+
128
+ /** Payer-funded NEP-145 calls. These are unsigned normal transactions, never facilitator delegates. */
129
+
130
+ interface NearStorageTransaction {
131
+ signerId: string;
132
+ receiverId: string;
133
+ actions: [
134
+ {
135
+ type: 'FunctionCall';
136
+ params: {
137
+ methodName: 'storage_deposit';
138
+ args: {
139
+ account_id: string;
140
+ registration_only: boolean;
141
+ };
142
+ gas: string;
143
+ deposit: string;
144
+ };
145
+ }
146
+ ];
147
+ }
148
+ interface NearStorageOptions {
149
+ network: NearEscrowNetwork;
150
+ /** Account that signs the normal transaction and pays its deposit and gas. */
151
+ payerId: string;
152
+ /** Account to register or fund; defaults to payerId. */
153
+ accountId?: string;
154
+ /** YoctoNEAR, not NEAR. Query storage_balance_bounds for the live contract minimum. */
155
+ deposit?: NearUnsigned;
156
+ }
157
+ /** Explicit deployment from NEAR_ESCROW_CONTRACTS for the selected network. */
158
+ interface ArrasStorageOptions extends NearStorageOptions {
159
+ escrowContract: string;
160
+ }
161
+ declare const NEAR_ARRAS_STORAGE_DEPOSIT = "50000000000000000000000";
162
+ declare const NEAR_USDC_STORAGE_DEPOSIT = "1250000000000000000000";
163
+ /** Keep surplus available for payment storage; registration_only must be false for Arras. */
164
+ declare function buildArrasStorageDeposit(options: ArrasStorageOptions): NearStorageTransaction;
165
+ /** Register in native USDC; refund any surplus rather than topping up an FT registration. */
166
+ declare function buildUsdcStorageDeposit(options: NearStorageOptions): NearStorageTransaction;
167
+
168
+ interface ArrasAuthorizedData {
169
+ payment_id: string;
170
+ operator_id: string;
171
+ token: string;
172
+ payer: string;
173
+ receiver: string;
174
+ amount: string;
175
+ fee_bps: number;
176
+ fee_recipient: string;
177
+ terms_hash: string;
178
+ }
179
+ interface ArrasReleasedData {
180
+ payment_id: string;
181
+ amount: string;
182
+ net: string;
183
+ fee: string;
184
+ }
185
+ interface ArrasPaymentAmountData {
186
+ payment_id: string;
187
+ amount: string;
188
+ }
189
+ interface ArrasWithdrawnData {
190
+ account: string;
191
+ token: string;
192
+ amount: string;
193
+ ok: boolean;
194
+ }
195
+ interface ArrasCompactedData {
196
+ payment_id: string;
197
+ }
198
+ interface ArrasOperatorData {
199
+ operator_id: string;
200
+ owner?: string;
201
+ capturers?: string[];
202
+ fee_bps?: number;
203
+ fee_recipient?: string;
204
+ min_amount?: string;
205
+ tope_tvl_operador?: string;
206
+ tope_tvl_por_payer?: string;
207
+ sponsor_max_por_payer?: string;
208
+ }
209
+ interface ArrasCapsSetData {
210
+ by: string;
211
+ tope_por_pago: string;
212
+ tope_tvl_global: string;
213
+ }
214
+ interface ArrasPauseData {
215
+ by: string;
216
+ paused: boolean;
217
+ at: string;
218
+ }
219
+ interface ArrasEventData {
220
+ authorized: ArrasAuthorizedData;
221
+ released: ArrasReleasedData;
222
+ refunded: ArrasPaymentAmountData;
223
+ reclaimed: ArrasPaymentAmountData;
224
+ withdrawn: ArrasWithdrawnData;
225
+ compacted: ArrasCompactedData;
226
+ operator_registered: ArrasOperatorData;
227
+ operator_updated: ArrasOperatorData;
228
+ caps_set: ArrasCapsSetData;
229
+ paused: ArrasPauseData;
230
+ unpaused: ArrasPauseData;
231
+ }
232
+ type ArrasEvent = {
233
+ [K in keyof ArrasEventData]: {
234
+ standard: 'arras';
235
+ version: '1.0.0';
236
+ event: K;
237
+ data: ArrasEventData[K][];
238
+ };
239
+ }[keyof ArrasEventData];
240
+ /**
241
+ * Pass flattened receipt outcome logs. Foreign logs, malformed envelopes/data and unknown
242
+ * standards, versions or events are skipped. Preserve each batch and decimal integer bytes.
243
+ * Logs alone do not authenticate the emitter: the caller must check the receipt executor/status.
244
+ */
245
+ declare function parseArrasEvents(logs: readonly unknown[]): ArrasEvent[];
98
246
 
99
247
  /**
100
248
  * uvd-x402-sdk - NEAR Provider
@@ -234,4 +382,4 @@ declare class NEARProvider implements WalletAdapter {
234
382
  private base58Encode;
235
383
  }
236
384
 
237
- export { type AuthorizeFromBudget, type EscrowAuthorizationOptions, type EscrowMsgParams, NEARProvider, NEAR_ESCROW_CONTRACTS, NEAR_ESCROW_MAX_GAS, NEAR_ESCROW_MIN_GAS, NEAR_ESCROW_TOKENS, type NearEscrowDelegate, type NearEscrowDelegateOptions, type NearEscrowFunctionCall, type NearEscrowLifecycleMethod, type NearEscrowNetwork, type NearEscrowPayment, type NearLocalSigner, type NearUnsigned, type PaymentIdParams, type WalletSelectorOptions, buildEscrowAuthorizationDelegate, buildEscrowMsg, computePaymentId, createNearLocalSigner, NEARProvider as default, paymentIdPreimage, reclaim, refund, release, signEscrowAuthorization, signEscrowLifecycle, validateEscrowAuthorizationDelegate, withdraw, withdrawFor };
385
+ export { type ArrasAuthorizedData, type ArrasCapsSetData, type ArrasCompactedData, type ArrasEvent, type ArrasEventData, type ArrasOperatorData, type ArrasPauseData, type ArrasPaymentAmountData, type ArrasReleasedData, type ArrasStorageOptions, type ArrasWithdrawnData, type AuthorizeFromBudget, type EscrowAuthorizationOptions, type EscrowMsgParams, NEARProvider, NEAR_ARRAS_STORAGE_DEPOSIT, NEAR_ESCROW_CONTRACTS, NEAR_ESCROW_MAX_GAS, NEAR_ESCROW_MIN_GAS, NEAR_ESCROW_TOKENS, NEAR_USDC_STORAGE_DEPOSIT, type NearEscrowDelegate, type NearEscrowDelegateOptions, type NearEscrowFunctionCall, type NearEscrowLifecycleMethod, type NearEscrowNetwork, type NearEscrowPayment, type NearExactDelegateOptions, type NearExactPayment, type NearLocalSigner, type NearStorageOptions, type NearStorageTransaction, type NearUnsigned, type Nep413Message, type Nep413SignedMessage, type PaymentIdParams, type SignNep413Options, type WalletSelectorOptions, buildArrasStorageDeposit, buildEscrowAuthorizationDelegate, buildEscrowMsg, buildUsdcStorageDeposit, computePaymentId, createNearLocalSigner, NEARProvider as default, nep413Preimage, parseArrasEvents, paymentIdPreimage, reclaim, refund, release, signEscrowAuthorization, signEscrowLifecycle, signExactNearDelegate, signNep413, validateEscrowAuthorizationDelegate, withdraw, withdrawFor };
@@ -19,7 +19,7 @@ interface PaymentIdParams extends EscrowMsgParams {
19
19
  }
20
20
  interface NearLocalSigner {
21
21
  readonly publicKey: Uint8Array;
22
- /** Sign the NEP-366 SHA-256 digest directly, without a NEP-413 envelope. */
22
+ /** Sign the supplied SHA-256 digest directly. The calling helper supplies its domain prefix. */
23
23
  sign(digest: Uint8Array): Uint8Array | Promise<Uint8Array>;
24
24
  }
25
25
  interface NearEscrowDelegateOptions {
@@ -65,7 +65,7 @@ declare const NEAR_ESCROW_TOKENS: Readonly<Record<NearEscrowNetwork, string>>;
65
65
  /**
66
66
  * The Arras escrow deployments this SDK signs for, per network. Any other escrowContract is refused before the
67
67
  * signer is called, for authorization and lifecycle alike: a signed delegate can be relayed by anyone, so a 402
68
- * server must not be able to point it at its own account. Mainnet stays empty until its contract ships in a release.
68
+ * server must not be able to point it at its own account. Only deployed Arras v1 contracts are registered.
69
69
  */
70
70
  declare const NEAR_ESCROW_CONTRACTS: Readonly<Record<NearEscrowNetwork, readonly string[]>>;
71
71
  /** Canonical Arras JSON: field order, decimal-string timestamps, lowercase hex, no spaces. */
@@ -95,6 +95,154 @@ declare const withdrawFor: (o: NearEscrowDelegateOptions, account: string) => Pr
95
95
  interface AuthorizeFromBudget {
96
96
  authorizeFromBudget(request: unknown): Promise<NearEscrowPayment>;
97
97
  }
98
+ /** Local-key exact NEP-366 payment; uses the escrow serializer and raw digest signer. */
99
+ interface NearExactDelegateOptions extends Omit<NearEscrowDelegateOptions, 'escrowContract'> {
100
+ token: string;
101
+ payTo: string;
102
+ amount: NearUnsigned;
103
+ }
104
+ interface NearExactPayment extends Omit<NearEscrowPayment, 'scheme'> {
105
+ scheme: 'exact';
106
+ }
107
+ declare function signExactNearDelegate(options: NearExactDelegateOptions): Promise<NearExactPayment>;
108
+
109
+ interface Nep413Message {
110
+ message: string;
111
+ nonce: Uint8Array;
112
+ recipient: string;
113
+ callbackUrl?: string;
114
+ }
115
+ interface SignNep413Options extends Nep413Message {
116
+ signer: NearLocalSigner;
117
+ accountId: string;
118
+ }
119
+ interface Nep413SignedMessage {
120
+ accountId: string;
121
+ publicKey: string;
122
+ signature: string;
123
+ }
124
+ /** Prefix 2^31+413 followed by message, fixed nonce, recipient and Option<String> callback. */
125
+ declare function nep413Preimage(options: Nep413Message): Uint8Array;
126
+ declare function signNep413(options: SignNep413Options): Promise<Nep413SignedMessage>;
127
+
128
+ /** Payer-funded NEP-145 calls. These are unsigned normal transactions, never facilitator delegates. */
129
+
130
+ interface NearStorageTransaction {
131
+ signerId: string;
132
+ receiverId: string;
133
+ actions: [
134
+ {
135
+ type: 'FunctionCall';
136
+ params: {
137
+ methodName: 'storage_deposit';
138
+ args: {
139
+ account_id: string;
140
+ registration_only: boolean;
141
+ };
142
+ gas: string;
143
+ deposit: string;
144
+ };
145
+ }
146
+ ];
147
+ }
148
+ interface NearStorageOptions {
149
+ network: NearEscrowNetwork;
150
+ /** Account that signs the normal transaction and pays its deposit and gas. */
151
+ payerId: string;
152
+ /** Account to register or fund; defaults to payerId. */
153
+ accountId?: string;
154
+ /** YoctoNEAR, not NEAR. Query storage_balance_bounds for the live contract minimum. */
155
+ deposit?: NearUnsigned;
156
+ }
157
+ /** Explicit deployment from NEAR_ESCROW_CONTRACTS for the selected network. */
158
+ interface ArrasStorageOptions extends NearStorageOptions {
159
+ escrowContract: string;
160
+ }
161
+ declare const NEAR_ARRAS_STORAGE_DEPOSIT = "50000000000000000000000";
162
+ declare const NEAR_USDC_STORAGE_DEPOSIT = "1250000000000000000000";
163
+ /** Keep surplus available for payment storage; registration_only must be false for Arras. */
164
+ declare function buildArrasStorageDeposit(options: ArrasStorageOptions): NearStorageTransaction;
165
+ /** Register in native USDC; refund any surplus rather than topping up an FT registration. */
166
+ declare function buildUsdcStorageDeposit(options: NearStorageOptions): NearStorageTransaction;
167
+
168
+ interface ArrasAuthorizedData {
169
+ payment_id: string;
170
+ operator_id: string;
171
+ token: string;
172
+ payer: string;
173
+ receiver: string;
174
+ amount: string;
175
+ fee_bps: number;
176
+ fee_recipient: string;
177
+ terms_hash: string;
178
+ }
179
+ interface ArrasReleasedData {
180
+ payment_id: string;
181
+ amount: string;
182
+ net: string;
183
+ fee: string;
184
+ }
185
+ interface ArrasPaymentAmountData {
186
+ payment_id: string;
187
+ amount: string;
188
+ }
189
+ interface ArrasWithdrawnData {
190
+ account: string;
191
+ token: string;
192
+ amount: string;
193
+ ok: boolean;
194
+ }
195
+ interface ArrasCompactedData {
196
+ payment_id: string;
197
+ }
198
+ interface ArrasOperatorData {
199
+ operator_id: string;
200
+ owner?: string;
201
+ capturers?: string[];
202
+ fee_bps?: number;
203
+ fee_recipient?: string;
204
+ min_amount?: string;
205
+ tope_tvl_operador?: string;
206
+ tope_tvl_por_payer?: string;
207
+ sponsor_max_por_payer?: string;
208
+ }
209
+ interface ArrasCapsSetData {
210
+ by: string;
211
+ tope_por_pago: string;
212
+ tope_tvl_global: string;
213
+ }
214
+ interface ArrasPauseData {
215
+ by: string;
216
+ paused: boolean;
217
+ at: string;
218
+ }
219
+ interface ArrasEventData {
220
+ authorized: ArrasAuthorizedData;
221
+ released: ArrasReleasedData;
222
+ refunded: ArrasPaymentAmountData;
223
+ reclaimed: ArrasPaymentAmountData;
224
+ withdrawn: ArrasWithdrawnData;
225
+ compacted: ArrasCompactedData;
226
+ operator_registered: ArrasOperatorData;
227
+ operator_updated: ArrasOperatorData;
228
+ caps_set: ArrasCapsSetData;
229
+ paused: ArrasPauseData;
230
+ unpaused: ArrasPauseData;
231
+ }
232
+ type ArrasEvent = {
233
+ [K in keyof ArrasEventData]: {
234
+ standard: 'arras';
235
+ version: '1.0.0';
236
+ event: K;
237
+ data: ArrasEventData[K][];
238
+ };
239
+ }[keyof ArrasEventData];
240
+ /**
241
+ * Pass flattened receipt outcome logs. Foreign logs, malformed envelopes/data and unknown
242
+ * standards, versions or events are skipped. Preserve each batch and decimal integer bytes.
243
+ * Logs alone do not authenticate the emitter: the caller must check the receipt executor/status.
244
+ */
245
+ declare function parseArrasEvents(logs: readonly unknown[]): ArrasEvent[];
98
246
 
99
247
  /**
100
248
  * uvd-x402-sdk - NEAR Provider
@@ -234,4 +382,4 @@ declare class NEARProvider implements WalletAdapter {
234
382
  private base58Encode;
235
383
  }
236
384
 
237
- export { type AuthorizeFromBudget, type EscrowAuthorizationOptions, type EscrowMsgParams, NEARProvider, NEAR_ESCROW_CONTRACTS, NEAR_ESCROW_MAX_GAS, NEAR_ESCROW_MIN_GAS, NEAR_ESCROW_TOKENS, type NearEscrowDelegate, type NearEscrowDelegateOptions, type NearEscrowFunctionCall, type NearEscrowLifecycleMethod, type NearEscrowNetwork, type NearEscrowPayment, type NearLocalSigner, type NearUnsigned, type PaymentIdParams, type WalletSelectorOptions, buildEscrowAuthorizationDelegate, buildEscrowMsg, computePaymentId, createNearLocalSigner, NEARProvider as default, paymentIdPreimage, reclaim, refund, release, signEscrowAuthorization, signEscrowLifecycle, validateEscrowAuthorizationDelegate, withdraw, withdrawFor };
385
+ export { type ArrasAuthorizedData, type ArrasCapsSetData, type ArrasCompactedData, type ArrasEvent, type ArrasEventData, type ArrasOperatorData, type ArrasPauseData, type ArrasPaymentAmountData, type ArrasReleasedData, type ArrasStorageOptions, type ArrasWithdrawnData, type AuthorizeFromBudget, type EscrowAuthorizationOptions, type EscrowMsgParams, NEARProvider, NEAR_ARRAS_STORAGE_DEPOSIT, NEAR_ESCROW_CONTRACTS, NEAR_ESCROW_MAX_GAS, NEAR_ESCROW_MIN_GAS, NEAR_ESCROW_TOKENS, NEAR_USDC_STORAGE_DEPOSIT, type NearEscrowDelegate, type NearEscrowDelegateOptions, type NearEscrowFunctionCall, type NearEscrowLifecycleMethod, type NearEscrowNetwork, type NearEscrowPayment, type NearExactDelegateOptions, type NearExactPayment, type NearLocalSigner, type NearStorageOptions, type NearStorageTransaction, type NearUnsigned, type Nep413Message, type Nep413SignedMessage, type PaymentIdParams, type SignNep413Options, type WalletSelectorOptions, buildArrasStorageDeposit, buildEscrowAuthorizationDelegate, buildEscrowMsg, buildUsdcStorageDeposit, computePaymentId, createNearLocalSigner, NEARProvider as default, nep413Preimage, parseArrasEvents, paymentIdPreimage, reclaim, refund, release, signEscrowAuthorization, signEscrowLifecycle, signExactNearDelegate, signNep413, validateEscrowAuthorizationDelegate, withdraw, withdrawFor };