@zkp2p/sdk 0.4.3 → 0.5.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 +49 -35
- package/dist/index.cjs +94 -220
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +51 -31
- package/dist/index.d.ts +51 -31
- package/dist/index.mjs +94 -221
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/{vaultUtils-BZU2bc0T.d.mts → vaultUtils-BL8tzsmH.d.mts} +31 -4
- package/dist/{vaultUtils-BZU2bc0T.d.ts → vaultUtils-BL8tzsmH.d.ts} +31 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Stable TypeScript SDK for trustless fiat-to-crypto on Base. ZKP2P combines escrowed on-chain settlement, TLS attestations for payment verification, and API/indexer helpers so makers, takers, wallets, and embedded ramps can ship production-grade fiat liquidity flows without building their own contract or indexing stack.
|
|
8
8
|
|
|
9
|
-
Current version: `0.
|
|
9
|
+
Current version: `0.4.3`
|
|
10
10
|
|
|
11
11
|
## Why This SDK
|
|
12
12
|
|
|
@@ -105,50 +105,59 @@ Indexer defaults by environment:
|
|
|
105
105
|
| React hooks | `@zkp2p/sdk/react` exports hooks for deposits, intents, delegation, vaults, payment methods, and taker tier |
|
|
106
106
|
| Attribution | ERC-8021 helpers like `sendTransactionWithAttribution`, `encodeWithAttribution`, and `txOverrides.referrer` support |
|
|
107
107
|
|
|
108
|
-
## Extension
|
|
108
|
+
## Extension Metadata Bridge
|
|
109
109
|
|
|
110
|
-
Use `createPeerExtensionSdk()` when a
|
|
110
|
+
Use `createPeerExtensionSdk()` when a page needs the Peer extension to open a
|
|
111
|
+
provider auth tab and interact with the Peer TEE protocol. The extension owns
|
|
112
|
+
provider-tab capture and Buyer TEE session encryption. For seller automated
|
|
113
|
+
release, the extension captures seller session material, creates the encrypted
|
|
114
|
+
attestation-service bundle, and returns only that bundle plus the maker
|
|
115
|
+
`offchainId`. The page owns maker payee registration and curator credential
|
|
116
|
+
storage.
|
|
111
117
|
|
|
112
118
|
```ts
|
|
113
119
|
import { createPeerExtensionSdk } from '@zkp2p/sdk';
|
|
114
120
|
|
|
115
121
|
const peer = createPeerExtensionSdk();
|
|
116
|
-
const intentHash = await client.signalIntent({
|
|
117
|
-
// quote-selected intent params
|
|
118
|
-
});
|
|
119
122
|
|
|
120
|
-
|
|
121
|
-
await
|
|
122
|
-
to: transaction.to,
|
|
123
|
-
data: transaction.data,
|
|
124
|
-
value: BigInt(transaction.value),
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const existing = await peer.getOnrampTransaction(intentHash);
|
|
129
|
-
if (existing) {
|
|
130
|
-
await submitPreparedTransaction(existing);
|
|
131
|
-
} else {
|
|
132
|
-
peer.onramp(
|
|
133
|
-
{
|
|
134
|
-
intentHash,
|
|
135
|
-
referrer: 'Liquidity Page',
|
|
136
|
-
inputCurrency: 'USD',
|
|
137
|
-
inputAmount: '500',
|
|
138
|
-
paymentPlatform: 'venmo',
|
|
139
|
-
depositId: '12345678901234567890',
|
|
140
|
-
amountUsdc: '488280000',
|
|
141
|
-
toToken: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
142
|
-
recipientAddress: '0xRecipient',
|
|
143
|
-
},
|
|
144
|
-
submitPreparedTransaction,
|
|
145
|
-
);
|
|
123
|
+
if ((await peer.getState()) === 'needs_connection') {
|
|
124
|
+
await peer.requestConnection();
|
|
146
125
|
}
|
|
147
|
-
```
|
|
148
126
|
|
|
149
|
-
|
|
127
|
+
const unsubscribe = peer.onMetadataMessage((message) => {
|
|
128
|
+
if (message.sarCredentialCapture) {
|
|
129
|
+
console.log('SAR credential bundle captured', message.sarCredentialCapture.credentialBundle);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
console.log('captured payment metadata', message.metadata);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
peer.authenticate({
|
|
137
|
+
actionType: 'transfer_venmo',
|
|
138
|
+
captureMode: 'buyerTee',
|
|
139
|
+
platform: 'venmo',
|
|
140
|
+
attestationServiceUrl: 'https://attestation.zkp2p.xyz',
|
|
141
|
+
});
|
|
142
|
+
```
|
|
150
143
|
|
|
151
|
-
|
|
144
|
+
`requestConnection()` is required for third-party origins. `authenticate()`
|
|
145
|
+
accepts an optional inline `providerConfig` object; otherwise the extension
|
|
146
|
+
fetches the default template from `https://api.zkp2p.xyz/providers/`. Buyer TEE
|
|
147
|
+
is API/template driven: pass `captureMode: "buyerTee"` plus
|
|
148
|
+
`attestationServiceUrl`, and the extension returns encrypted session material.
|
|
149
|
+
For SAR, pass `captureMode: "sellerCredential"` and optionally pass
|
|
150
|
+
`attestationServiceUrl` only when overriding the extension's production
|
|
151
|
+
attestation default. The extension returns `sarCredentialCapture.credentialBundle`
|
|
152
|
+
plus `offchainId`. The page should call `apiUploadSellerCredentialBundle()` to
|
|
153
|
+
register maker payee details with curator, compare the registered hash to the
|
|
154
|
+
bundle `payeeIdHash`, and store the encrypted bundle with curator. Plaintext
|
|
155
|
+
seller session material is never returned to the page.
|
|
156
|
+
|
|
157
|
+
`Zkp2pClient.uploadSellerCredential()` remains the backwards-compatible
|
|
158
|
+
plaintext convenience path for mobile and React Native callers. Internally it
|
|
159
|
+
creates the encrypted bundle, then uses the same
|
|
160
|
+
`apiUploadSellerCredentialBundle()` storage helper.
|
|
152
161
|
|
|
153
162
|
## Create a Deposit
|
|
154
163
|
|
|
@@ -502,6 +511,11 @@ const fulfilledEvents = await client.indexer.getFulfilledIntentEvents(['0xIntent
|
|
|
502
511
|
const fulfillment = await client.indexer.getIntentFulfillmentAmounts('0xIntentHash');
|
|
503
512
|
const fulfillmentAndPayment = await client.indexer.getFulfillmentAndPayment('0xIntentHash');
|
|
504
513
|
|
|
514
|
+
// Received USDC:
|
|
515
|
+
// - fulfilledEvents[0].amount is the net USDC transferred to the taker.
|
|
516
|
+
// - fulfillment.takerAmountNetFees is the same net taker amount from the Intent row.
|
|
517
|
+
// - fulfillment.releasedAmount is gross USDC released from the deposit before fees.
|
|
518
|
+
|
|
505
519
|
// Fund activity and snapshots
|
|
506
520
|
const fundActivities = await client.indexer.getDepositFundActivities('8453_0xEscrowAddress_42');
|
|
507
521
|
const makerActivities = await client.indexer.getMakerFundActivities('0xMaker', 50);
|
package/dist/index.cjs
CHANGED
|
@@ -43349,6 +43349,7 @@ var IntentOperations = class {
|
|
|
43349
43349
|
paymentProof,
|
|
43350
43350
|
data: encodeAddressAsBytes(attestation.responseObject.signer)
|
|
43351
43351
|
});
|
|
43352
|
+
params.callbacks?.onAttestationComplete?.(attestation);
|
|
43352
43353
|
}
|
|
43353
43354
|
const args = [
|
|
43354
43355
|
{
|
|
@@ -45315,6 +45316,7 @@ var INTENT_FULFILLMENTS_QUERY = (
|
|
|
45315
45316
|
query GetFulfilledIntents($intentHashes: [String!]) {
|
|
45316
45317
|
Orchestrator_V21_IntentFulfilled(where: { intentHash: { _in: $intentHashes } }) {
|
|
45317
45318
|
intentHash
|
|
45319
|
+
amount
|
|
45318
45320
|
isManualRelease
|
|
45319
45321
|
fundsTransferredTo
|
|
45320
45322
|
}
|
|
@@ -47357,6 +47359,58 @@ async function apiGetDepositBundle(params, optsOrBaseApiUrl, timeoutMs, apiKey)
|
|
|
47357
47359
|
return response.responseObject;
|
|
47358
47360
|
}
|
|
47359
47361
|
|
|
47362
|
+
// src/sellerCredentials.ts
|
|
47363
|
+
function normalizeBaseApiUrl(value) {
|
|
47364
|
+
return (value?.trim().replace(/\/+$/u, "") || DEFAULT_BASE_API_URL).replace(/\/v1$/u, "");
|
|
47365
|
+
}
|
|
47366
|
+
function assertBundlePlatformMatches(params) {
|
|
47367
|
+
if (params.bundle.platform.toLowerCase() !== params.platform) {
|
|
47368
|
+
throw new Error("Seller credential bundle platform does not match upload platform");
|
|
47369
|
+
}
|
|
47370
|
+
}
|
|
47371
|
+
async function apiUploadSellerCredentialBundle(params, baseApiUrl, timeoutMs) {
|
|
47372
|
+
assertBundlePlatformMatches(params);
|
|
47373
|
+
const normalizedBaseApiUrl = normalizeBaseApiUrl(baseApiUrl);
|
|
47374
|
+
if (params.platform === "wise") {
|
|
47375
|
+
return apiUploadSellerCredential(
|
|
47376
|
+
params.platform,
|
|
47377
|
+
params.bundle.payeeIdHash,
|
|
47378
|
+
params.bundle,
|
|
47379
|
+
normalizedBaseApiUrl,
|
|
47380
|
+
timeoutMs
|
|
47381
|
+
);
|
|
47382
|
+
}
|
|
47383
|
+
const registeredPayeePayload = {
|
|
47384
|
+
offchainId: params.offchainId,
|
|
47385
|
+
processorName: params.platform
|
|
47386
|
+
};
|
|
47387
|
+
if (params.telegramUsername !== void 0) {
|
|
47388
|
+
registeredPayeePayload.telegramUsername = params.telegramUsername;
|
|
47389
|
+
}
|
|
47390
|
+
if (params.metadata !== void 0) {
|
|
47391
|
+
registeredPayeePayload.metadata = params.metadata;
|
|
47392
|
+
}
|
|
47393
|
+
const registeredPayeeResponse = await apiPostDepositDetails(
|
|
47394
|
+
registeredPayeePayload,
|
|
47395
|
+
normalizedBaseApiUrl,
|
|
47396
|
+
timeoutMs
|
|
47397
|
+
);
|
|
47398
|
+
if (!registeredPayeeResponse.success || !registeredPayeeResponse.responseObject) {
|
|
47399
|
+
throw new Error(registeredPayeeResponse.message || "Failed to register seller payee details");
|
|
47400
|
+
}
|
|
47401
|
+
const registeredPayee = registeredPayeeResponse.responseObject;
|
|
47402
|
+
if (registeredPayee.hashedOnchainId.toLowerCase() !== params.bundle.payeeIdHash.toLowerCase()) {
|
|
47403
|
+
throw new Error("Seller credential payee hash does not match registered payee details");
|
|
47404
|
+
}
|
|
47405
|
+
return apiUploadSellerCredential(
|
|
47406
|
+
params.platform,
|
|
47407
|
+
registeredPayee.hashedOnchainId,
|
|
47408
|
+
params.bundle,
|
|
47409
|
+
normalizedBaseApiUrl,
|
|
47410
|
+
timeoutMs
|
|
47411
|
+
);
|
|
47412
|
+
}
|
|
47413
|
+
|
|
47360
47414
|
// src/client/Zkp2pClient.ts
|
|
47361
47415
|
init_contracts();
|
|
47362
47416
|
init_paymentResolution();
|
|
@@ -49248,7 +49302,9 @@ var Zkp2pClient = class {
|
|
|
49248
49302
|
* { limit: 50, orderBy: 'remainingDeposits', orderDirection: 'desc' }
|
|
49249
49303
|
* );
|
|
49250
49304
|
*
|
|
49251
|
-
* // Get historical fulfillment data
|
|
49305
|
+
* // Get historical fulfillment event data. Use `amount` for net USDC
|
|
49306
|
+
* // transferred to the taker; use getIntentFulfillmentAmounts() when you
|
|
49307
|
+
* // also need gross released USDC.
|
|
49252
49308
|
* const fulfillments = await client.indexer.getFulfilledIntentEvents(['0x...']);
|
|
49253
49309
|
* ```
|
|
49254
49310
|
*/
|
|
@@ -49310,13 +49366,15 @@ var Zkp2pClient = class {
|
|
|
49310
49366
|
return service.fetchExpiredIntents(params);
|
|
49311
49367
|
},
|
|
49312
49368
|
/**
|
|
49313
|
-
* Fetches fulfillment events for completed intents.
|
|
49369
|
+
* Fetches fulfillment events for completed intents. `amount` is the net
|
|
49370
|
+
* USDC transferred to the taker after protocol/referrer fees.
|
|
49314
49371
|
*/
|
|
49315
49372
|
getFulfilledIntentEvents: (intentHashes) => {
|
|
49316
49373
|
return service.fetchFulfilledIntentEvents(intentHashes);
|
|
49317
49374
|
},
|
|
49318
49375
|
/**
|
|
49319
|
-
* Fetches gross and net fulfillment amounts for an intent.
|
|
49376
|
+
* Fetches gross and net fulfillment amounts for an intent. Use
|
|
49377
|
+
* `takerAmountNetFees` as the buyer/taker received USDC amount.
|
|
49320
49378
|
*/
|
|
49321
49379
|
getIntentFulfillmentAmounts: (intentHash) => {
|
|
49322
49380
|
return service.fetchIntentFulfillmentAmounts(intentHash);
|
|
@@ -49934,14 +49992,14 @@ var Zkp2pClient = class {
|
|
|
49934
49992
|
const attestationServiceUrl = this.stripTrailingSlash(
|
|
49935
49993
|
opts?.attestationServiceUrl ?? this.defaultAttestationServiceForBaseApiUrl(baseApiUrl)
|
|
49936
49994
|
);
|
|
49937
|
-
const createBundle = (
|
|
49938
|
-
|
|
49995
|
+
const createBundle = (uploadPayload) => opts?.attestationRuntime ? apiCreateSellerCredentialBundle(
|
|
49996
|
+
uploadPayload,
|
|
49939
49997
|
attestationServiceUrl,
|
|
49940
49998
|
params.platform,
|
|
49941
49999
|
timeoutMs,
|
|
49942
50000
|
opts.attestationRuntime
|
|
49943
50001
|
) : apiCreateSellerCredentialBundle(
|
|
49944
|
-
|
|
50002
|
+
uploadPayload,
|
|
49945
50003
|
attestationServiceUrl,
|
|
49946
50004
|
params.platform,
|
|
49947
50005
|
timeoutMs
|
|
@@ -49953,51 +50011,42 @@ var Zkp2pClient = class {
|
|
|
49953
50011
|
if (!bundleResponse2.success || !bundleResponse2.responseObject) {
|
|
49954
50012
|
throw new Error(bundleResponse2.message || "Failed to create seller credential bundle");
|
|
49955
50013
|
}
|
|
49956
|
-
return
|
|
49957
|
-
|
|
49958
|
-
|
|
49959
|
-
|
|
49960
|
-
|
|
49961
|
-
timeoutMs
|
|
50014
|
+
return this.uploadSellerCredentialBundle(
|
|
50015
|
+
{
|
|
50016
|
+
bundle: bundleResponse2.responseObject,
|
|
50017
|
+
platform: params.platform
|
|
50018
|
+
},
|
|
50019
|
+
{ baseApiUrl, timeoutMs }
|
|
49962
50020
|
);
|
|
49963
50021
|
}
|
|
49964
|
-
const
|
|
49965
|
-
offchainId: params.offchainId,
|
|
49966
|
-
processorName: params.platform
|
|
49967
|
-
};
|
|
49968
|
-
if (params.telegramUsername !== void 0) {
|
|
49969
|
-
registeredPayeePayload.telegramUsername = params.telegramUsername;
|
|
49970
|
-
}
|
|
49971
|
-
if (params.metadata !== void 0) {
|
|
49972
|
-
registeredPayeePayload.metadata = params.metadata;
|
|
49973
|
-
}
|
|
49974
|
-
const registeredPayeeResponse = await apiPostDepositDetails(
|
|
49975
|
-
registeredPayeePayload,
|
|
49976
|
-
baseApiUrl,
|
|
49977
|
-
timeoutMs
|
|
49978
|
-
);
|
|
49979
|
-
if (!registeredPayeeResponse.success || !registeredPayeeResponse.responseObject) {
|
|
49980
|
-
throw new Error(registeredPayeeResponse.message || "Failed to register seller payee details");
|
|
49981
|
-
}
|
|
49982
|
-
const uploadPayload = {
|
|
50022
|
+
const bundlePayload = {
|
|
49983
50023
|
payeeId: params.payeeId,
|
|
49984
50024
|
sessionMaterial: params.sessionMaterial
|
|
49985
50025
|
};
|
|
49986
|
-
const bundleResponse = await createBundle(
|
|
50026
|
+
const bundleResponse = await createBundle(bundlePayload);
|
|
49987
50027
|
if (!bundleResponse.success || !bundleResponse.responseObject) {
|
|
49988
50028
|
throw new Error(bundleResponse.message || "Failed to create seller credential bundle");
|
|
49989
50029
|
}
|
|
49990
|
-
|
|
49991
|
-
|
|
49992
|
-
|
|
49993
|
-
|
|
49994
|
-
|
|
49995
|
-
|
|
49996
|
-
|
|
49997
|
-
|
|
49998
|
-
baseApiUrl,
|
|
49999
|
-
|
|
50030
|
+
return this.uploadSellerCredentialBundle(
|
|
50031
|
+
{
|
|
50032
|
+
bundle: bundleResponse.responseObject,
|
|
50033
|
+
offchainId: params.offchainId,
|
|
50034
|
+
platform: params.platform,
|
|
50035
|
+
...params.telegramUsername !== void 0 ? { telegramUsername: params.telegramUsername } : {},
|
|
50036
|
+
...params.metadata !== void 0 ? { metadata: params.metadata } : {}
|
|
50037
|
+
},
|
|
50038
|
+
{ baseApiUrl, timeoutMs }
|
|
50039
|
+
);
|
|
50040
|
+
}
|
|
50041
|
+
/**
|
|
50042
|
+
* Store an already-encrypted seller credential bundle with curator.
|
|
50043
|
+
*/
|
|
50044
|
+
async uploadSellerCredentialBundle(params, opts) {
|
|
50045
|
+
const baseApiUrl = this.stripTrailingSlash(
|
|
50046
|
+
opts?.baseApiUrl ?? this.baseApiUrl ?? DEFAULT_BASE_API_URL
|
|
50000
50047
|
);
|
|
50048
|
+
const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
|
|
50049
|
+
return apiUploadSellerCredentialBundle(params, baseApiUrl, timeoutMs);
|
|
50001
50050
|
}
|
|
50002
50051
|
/**
|
|
50003
50052
|
* Confirms the PayPal Gmail-forwarding setup for an existing maker payee hash.
|
|
@@ -50296,189 +50345,13 @@ var getPeerExtensionState = async (options) => {
|
|
|
50296
50345
|
return "needs_connection";
|
|
50297
50346
|
}
|
|
50298
50347
|
};
|
|
50299
|
-
var fiatAmountRegex = /^-?\d*(\.\d{0,6})?$/;
|
|
50300
|
-
var usdcAmountRegex = /^\d+$/;
|
|
50301
|
-
var assertObjectInput = (params) => {
|
|
50302
|
-
if (params === void 0) {
|
|
50303
|
-
throw new Error("Peer extension onramp requires query params with intentHash.");
|
|
50304
|
-
}
|
|
50305
|
-
if (params === null || typeof params !== "object" || Array.isArray(params)) {
|
|
50306
|
-
throw new Error("Peer extension onramp expects an object of query params.");
|
|
50307
|
-
}
|
|
50308
|
-
return params;
|
|
50309
|
-
};
|
|
50310
|
-
var normalizeOptionalString2 = (value, label) => {
|
|
50311
|
-
if (value === void 0) {
|
|
50312
|
-
return void 0;
|
|
50313
|
-
}
|
|
50314
|
-
if (typeof value !== "string") {
|
|
50315
|
-
throw new Error(`Peer extension onramp ${label} must be a non-empty string.`);
|
|
50316
|
-
}
|
|
50317
|
-
const trimmed = value.trim();
|
|
50318
|
-
if (!trimmed) {
|
|
50319
|
-
throw new Error(`Peer extension onramp ${label} must be a non-empty string.`);
|
|
50320
|
-
}
|
|
50321
|
-
return trimmed;
|
|
50322
|
-
};
|
|
50323
|
-
var normalizeOptionalUrl = (value, label) => {
|
|
50324
|
-
const trimmed = normalizeOptionalString2(value, label);
|
|
50325
|
-
if (trimmed === void 0) {
|
|
50326
|
-
return void 0;
|
|
50327
|
-
}
|
|
50328
|
-
let parsed;
|
|
50329
|
-
try {
|
|
50330
|
-
parsed = new URL(trimmed);
|
|
50331
|
-
} catch (error) {
|
|
50332
|
-
throw new Error(`Peer extension onramp ${label} must be a valid URL.`);
|
|
50333
|
-
}
|
|
50334
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
50335
|
-
throw new Error(`Peer extension onramp ${label} must use http or https.`);
|
|
50336
|
-
}
|
|
50337
|
-
return trimmed;
|
|
50338
|
-
};
|
|
50339
|
-
var normalizeFiatAmount = (value) => {
|
|
50340
|
-
if (value === void 0) {
|
|
50341
|
-
return void 0;
|
|
50342
|
-
}
|
|
50343
|
-
const normalized = typeof value === "number" ? String(value) : value;
|
|
50344
|
-
if (typeof normalized !== "string") {
|
|
50345
|
-
throw new Error("Peer extension onramp inputAmount must be a string or number.");
|
|
50346
|
-
}
|
|
50347
|
-
const trimmed = normalized.trim();
|
|
50348
|
-
if (!trimmed) {
|
|
50349
|
-
throw new Error("Peer extension onramp inputAmount must be a non-empty value.");
|
|
50350
|
-
}
|
|
50351
|
-
if (!fiatAmountRegex.test(trimmed)) {
|
|
50352
|
-
throw new Error(
|
|
50353
|
-
"Peer extension onramp inputAmount must be a non-negative number with up to 6 decimals."
|
|
50354
|
-
);
|
|
50355
|
-
}
|
|
50356
|
-
if (Number.isNaN(Number(trimmed)) || Number(trimmed) < 0) {
|
|
50357
|
-
throw new Error(
|
|
50358
|
-
"Peer extension onramp inputAmount must be a non-negative number with up to 6 decimals."
|
|
50359
|
-
);
|
|
50360
|
-
}
|
|
50361
|
-
return trimmed;
|
|
50362
|
-
};
|
|
50363
|
-
var normalizeUsdcAmount = (value) => {
|
|
50364
|
-
if (value === void 0) {
|
|
50365
|
-
return void 0;
|
|
50366
|
-
}
|
|
50367
|
-
if (typeof value === "bigint") {
|
|
50368
|
-
if (value < 0n) {
|
|
50369
|
-
throw new Error("Peer extension onramp amountUsdc must be a non-negative integer.");
|
|
50370
|
-
}
|
|
50371
|
-
return value.toString();
|
|
50372
|
-
}
|
|
50373
|
-
if (typeof value === "number") {
|
|
50374
|
-
if (!Number.isFinite(value) || value < 0 || !Number.isInteger(value)) {
|
|
50375
|
-
throw new Error("Peer extension onramp amountUsdc must be a non-negative integer.");
|
|
50376
|
-
}
|
|
50377
|
-
return String(value);
|
|
50378
|
-
}
|
|
50379
|
-
if (typeof value !== "string") {
|
|
50380
|
-
throw new Error("Peer extension onramp amountUsdc must be a string, number, or bigint.");
|
|
50381
|
-
}
|
|
50382
|
-
const trimmed = value.trim();
|
|
50383
|
-
if (!trimmed) {
|
|
50384
|
-
throw new Error("Peer extension onramp amountUsdc must be a non-empty value.");
|
|
50385
|
-
}
|
|
50386
|
-
if (!usdcAmountRegex.test(trimmed)) {
|
|
50387
|
-
throw new Error("Peer extension onramp amountUsdc must be a non-negative integer.");
|
|
50388
|
-
}
|
|
50389
|
-
return trimmed;
|
|
50390
|
-
};
|
|
50391
|
-
var normalizeIntegerParam = (value, label) => {
|
|
50392
|
-
if (value === void 0) {
|
|
50393
|
-
return void 0;
|
|
50394
|
-
}
|
|
50395
|
-
if (typeof value === "bigint") {
|
|
50396
|
-
if (value < 0n) {
|
|
50397
|
-
throw new Error(`Peer extension onramp ${label} must be a non-negative integer.`);
|
|
50398
|
-
}
|
|
50399
|
-
return value.toString();
|
|
50400
|
-
}
|
|
50401
|
-
if (typeof value === "number") {
|
|
50402
|
-
if (!Number.isFinite(value) || value < 0 || !Number.isInteger(value)) {
|
|
50403
|
-
throw new Error(`Peer extension onramp ${label} must be a non-negative integer.`);
|
|
50404
|
-
}
|
|
50405
|
-
if (!Number.isSafeInteger(value)) {
|
|
50406
|
-
throw new Error(
|
|
50407
|
-
`Peer extension onramp ${label} number input must be a safe integer; pass a string or bigint for larger values.`
|
|
50408
|
-
);
|
|
50409
|
-
}
|
|
50410
|
-
return String(value);
|
|
50411
|
-
}
|
|
50412
|
-
if (typeof value !== "string") {
|
|
50413
|
-
throw new Error(`Peer extension onramp ${label} must be a string, number, or bigint.`);
|
|
50414
|
-
}
|
|
50415
|
-
const trimmed = value.trim();
|
|
50416
|
-
if (!trimmed) {
|
|
50417
|
-
throw new Error(`Peer extension onramp ${label} must be a non-empty value.`);
|
|
50418
|
-
}
|
|
50419
|
-
if (!/^\d+$/.test(trimmed)) {
|
|
50420
|
-
throw new Error(`Peer extension onramp ${label} must be a non-negative integer.`);
|
|
50421
|
-
}
|
|
50422
|
-
return trimmed;
|
|
50423
|
-
};
|
|
50424
|
-
var intentHashRegex = /^0x[a-fA-F0-9]{64}$/;
|
|
50425
|
-
var normalizeIntentHash = (value) => {
|
|
50426
|
-
if (value === void 0) {
|
|
50427
|
-
throw new Error("Peer extension onramp intentHash is required.");
|
|
50428
|
-
}
|
|
50429
|
-
if (typeof value !== "string") {
|
|
50430
|
-
throw new Error("Peer extension onramp intentHash must be a string.");
|
|
50431
|
-
}
|
|
50432
|
-
const trimmed = value.trim();
|
|
50433
|
-
if (!trimmed) {
|
|
50434
|
-
throw new Error("Peer extension onramp intentHash must be a non-empty string.");
|
|
50435
|
-
}
|
|
50436
|
-
if (!intentHashRegex.test(trimmed)) {
|
|
50437
|
-
throw new Error(
|
|
50438
|
-
"Peer extension onramp intentHash must be a valid bytes32 hex string (0x + 64 hex characters)."
|
|
50439
|
-
);
|
|
50440
|
-
}
|
|
50441
|
-
return trimmed.toLowerCase();
|
|
50442
|
-
};
|
|
50443
|
-
var buildOnrampQueryString = (params) => {
|
|
50444
|
-
const validated = assertObjectInput(params);
|
|
50445
|
-
const searchParams = new URLSearchParams();
|
|
50446
|
-
const setParam = (key, value) => {
|
|
50447
|
-
if (value !== void 0) {
|
|
50448
|
-
searchParams.set(key, value);
|
|
50449
|
-
}
|
|
50450
|
-
};
|
|
50451
|
-
setParam("referrer", normalizeOptionalString2(validated.referrer, "referrer"));
|
|
50452
|
-
setParam("referrerLogo", normalizeOptionalUrl(validated.referrerLogo, "referrerLogo"));
|
|
50453
|
-
setParam("inputCurrency", normalizeOptionalString2(validated.inputCurrency, "inputCurrency"));
|
|
50454
|
-
setParam("inputAmount", normalizeFiatAmount(validated.inputAmount));
|
|
50455
|
-
setParam(
|
|
50456
|
-
"paymentPlatform",
|
|
50457
|
-
normalizeOptionalString2(validated.paymentPlatform, "paymentPlatform")
|
|
50458
|
-
);
|
|
50459
|
-
setParam("depositId", normalizeIntegerParam(validated.depositId, "depositId"));
|
|
50460
|
-
setParam("toToken", normalizeOptionalString2(validated.toToken, "toToken"));
|
|
50461
|
-
setParam("amountUsdc", normalizeUsdcAmount(validated.amountUsdc));
|
|
50462
|
-
setParam(
|
|
50463
|
-
"recipientAddress",
|
|
50464
|
-
normalizeOptionalString2(validated.recipientAddress, "recipientAddress")
|
|
50465
|
-
);
|
|
50466
|
-
setParam("intentHash", normalizeIntentHash(validated.intentHash));
|
|
50467
|
-
return searchParams.toString();
|
|
50468
|
-
};
|
|
50469
50348
|
var createPeerExtensionSdk = (options = {}) => ({
|
|
50470
50349
|
isAvailable: () => isPeerExtensionAvailable(options),
|
|
50471
50350
|
requestConnection: () => requirePeer(options).requestConnection(),
|
|
50472
50351
|
checkConnectionStatus: () => requirePeer(options).checkConnectionStatus(),
|
|
50473
|
-
openSidebar: (route) => requirePeer(options).openSidebar(route),
|
|
50474
|
-
onramp: (params, callback) => {
|
|
50475
|
-
if (typeof callback !== "function") {
|
|
50476
|
-
throw new Error("Peer extension onramp callback is required.");
|
|
50477
|
-
}
|
|
50478
|
-
requirePeer(options).onramp(buildOnrampQueryString(params), callback);
|
|
50479
|
-
},
|
|
50480
|
-
getOnrampTransaction: (intentHash) => requirePeer(options).getOnrampTransaction(normalizeIntentHash(intentHash)),
|
|
50481
50352
|
getVersion: () => requirePeer(options).getVersion(),
|
|
50353
|
+
authenticate: (params) => requirePeer(options).authenticate(params),
|
|
50354
|
+
onMetadataMessage: (callback) => requirePeer(options).onMetadataMessage(callback),
|
|
50482
50355
|
openInstallPage: () => openPeerExtensionInstallPage(options),
|
|
50483
50356
|
getState: () => getPeerExtensionState(options)
|
|
50484
50357
|
});
|
|
@@ -50592,6 +50465,7 @@ exports.apiGetTakerTier = apiGetTakerTier;
|
|
|
50592
50465
|
exports.apiPostDepositDetails = apiPostDepositDetails;
|
|
50593
50466
|
exports.apiRequestIdentityAttestation = apiRequestIdentityAttestation;
|
|
50594
50467
|
exports.apiUploadGoogleOAuthSellerCredential = apiUploadGoogleOAuthSellerCredential;
|
|
50468
|
+
exports.apiUploadSellerCredentialBundle = apiUploadSellerCredentialBundle;
|
|
50595
50469
|
exports.apiValidatePayeeDetails = apiValidatePayeeDetails;
|
|
50596
50470
|
exports.appendAttributionToCalldata = appendAttributionToCalldata;
|
|
50597
50471
|
exports.asciiToBytes32 = asciiToBytes32;
|