@zkp2p/sdk 0.4.2 → 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 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.3.3`
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 Onramp Deeplinks
108
+ ## Extension Metadata Bridge
109
109
 
110
- Use `createPeerExtensionSdk()` when a third-party page has signaled an intent and should hand payment authentication and proof generation into the Peer extension.
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
- const submitPreparedTransaction = async ({ transaction }) => {
121
- await walletClient.sendTransaction({
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
- For exact-deposit handoffs, pass `depositId` as a string or bigint unless it is known to be a JavaScript-safe integer. The extension derives payment method hashes from `paymentPlatform`; do not pass escrow addresses, payment method hashes, or hashed on-chain ids through the onramp URL. `getOnrampTransaction(intentHash)` is the pull recovery path for prepared calldata when the callback message was missed.
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
- See [Extension Onramp Deeplinks](../../docs/extension-onramp-deeplinks.md) for the full parameter contract, exact-deposit semantics, and prepared calldata recovery behavior.
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
@@ -42384,7 +42384,7 @@ function normalizeOptionalString(value) {
42384
42384
  function normalizeBaseUrl(value, label) {
42385
42385
  const normalized = normalizeOptionalString(value)?.replace(/\/+$/u, "");
42386
42386
  if (!normalized) {
42387
- throw new Error(`${label} is required for buyer TEE session encryption.`);
42387
+ throw new Error(`${label} is required.`);
42388
42388
  }
42389
42389
  return normalized;
42390
42390
  }
@@ -42477,6 +42477,35 @@ async function apiVerifyBuyerTeePayment(payload, attestationServiceUrl, platform
42477
42477
  return res.json();
42478
42478
  });
42479
42479
  }
42480
+ async function apiRequestIdentityAttestation(payload, attestationServiceUrl, platform, actionType) {
42481
+ return withRetry(async () => {
42482
+ let res;
42483
+ try {
42484
+ const endpoint = "/identity";
42485
+ const baseUrl = normalizeBaseUrl(attestationServiceUrl, "Attestation Service URL");
42486
+ res = await fetch(`${baseUrl}${endpoint}`, {
42487
+ method: "POST",
42488
+ headers: headers(),
42489
+ body: JSON.stringify({
42490
+ platform,
42491
+ actionType,
42492
+ encryptedSessionMaterial: payload.encryptedSessionMaterial,
42493
+ params: payload.params
42494
+ })
42495
+ });
42496
+ } catch (error) {
42497
+ throw new exports.NetworkError("Failed to connect to Attestation Service", {
42498
+ endpoint: "/identity",
42499
+ error
42500
+ });
42501
+ }
42502
+ if (!res.ok) {
42503
+ const errorText = await res.text();
42504
+ throw parseAPIError(res, errorText);
42505
+ }
42506
+ return res.json();
42507
+ });
42508
+ }
42480
42509
  async function createEncryptedBuyerTeeSessionMaterial({
42481
42510
  actionType,
42482
42511
  attestationRuntime,
@@ -43320,6 +43349,7 @@ var IntentOperations = class {
43320
43349
  paymentProof,
43321
43350
  data: encodeAddressAsBytes(attestation.responseObject.signer)
43322
43351
  });
43352
+ params.callbacks?.onAttestationComplete?.(attestation);
43323
43353
  }
43324
43354
  const args = [
43325
43355
  {
@@ -45286,6 +45316,7 @@ var INTENT_FULFILLMENTS_QUERY = (
45286
45316
  query GetFulfilledIntents($intentHashes: [String!]) {
45287
45317
  Orchestrator_V21_IntentFulfilled(where: { intentHash: { _in: $intentHashes } }) {
45288
45318
  intentHash
45319
+ amount
45289
45320
  isManualRelease
45290
45321
  fundsTransferredTo
45291
45322
  }
@@ -47328,6 +47359,58 @@ async function apiGetDepositBundle(params, optsOrBaseApiUrl, timeoutMs, apiKey)
47328
47359
  return response.responseObject;
47329
47360
  }
47330
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
+
47331
47414
  // src/client/Zkp2pClient.ts
47332
47415
  init_contracts();
47333
47416
  init_paymentResolution();
@@ -47476,11 +47559,11 @@ var ERC20_ABI = [
47476
47559
  ];
47477
47560
 
47478
47561
  // src/client/Zkp2pClient.ts
47479
- function isStringRecord(value) {
47562
+ function isObjectRecord(value) {
47480
47563
  if (!value || typeof value !== "object" || Array.isArray(value)) {
47481
47564
  return false;
47482
47565
  }
47483
- return Object.values(value).every((entry) => typeof entry === "string");
47566
+ return true;
47484
47567
  }
47485
47568
  function normalizeTelegramUsername(value) {
47486
47569
  if (typeof value !== "string") {
@@ -47517,7 +47600,7 @@ function normalizeQuotePayeeData(maker) {
47517
47600
  return {
47518
47601
  offchainId,
47519
47602
  telegramUsername: normalizeTelegramUsername(maker?.telegramUsername) ?? legacy?.telegramUsername ?? null,
47520
- metadata: isStringRecord(maker?.metadata) ? maker.metadata : legacy?.metadata ?? null
47603
+ metadata: isObjectRecord(maker?.metadata) ? maker.metadata : legacy?.metadata ?? null
47521
47604
  };
47522
47605
  }
47523
47606
  function normalizePayeeDataInputItem(raw) {
@@ -49219,7 +49302,9 @@ var Zkp2pClient = class {
49219
49302
  * { limit: 50, orderBy: 'remainingDeposits', orderDirection: 'desc' }
49220
49303
  * );
49221
49304
  *
49222
- * // 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.
49223
49308
  * const fulfillments = await client.indexer.getFulfilledIntentEvents(['0x...']);
49224
49309
  * ```
49225
49310
  */
@@ -49281,13 +49366,15 @@ var Zkp2pClient = class {
49281
49366
  return service.fetchExpiredIntents(params);
49282
49367
  },
49283
49368
  /**
49284
- * 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.
49285
49371
  */
49286
49372
  getFulfilledIntentEvents: (intentHashes) => {
49287
49373
  return service.fetchFulfilledIntentEvents(intentHashes);
49288
49374
  },
49289
49375
  /**
49290
- * 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.
49291
49378
  */
49292
49379
  getIntentFulfillmentAmounts: (intentHash) => {
49293
49380
  return service.fetchIntentFulfillmentAmounts(intentHash);
@@ -49905,14 +49992,14 @@ var Zkp2pClient = class {
49905
49992
  const attestationServiceUrl = this.stripTrailingSlash(
49906
49993
  opts?.attestationServiceUrl ?? this.defaultAttestationServiceForBaseApiUrl(baseApiUrl)
49907
49994
  );
49908
- const createBundle = (uploadPayload2) => opts?.attestationRuntime ? apiCreateSellerCredentialBundle(
49909
- uploadPayload2,
49995
+ const createBundle = (uploadPayload) => opts?.attestationRuntime ? apiCreateSellerCredentialBundle(
49996
+ uploadPayload,
49910
49997
  attestationServiceUrl,
49911
49998
  params.platform,
49912
49999
  timeoutMs,
49913
50000
  opts.attestationRuntime
49914
50001
  ) : apiCreateSellerCredentialBundle(
49915
- uploadPayload2,
50002
+ uploadPayload,
49916
50003
  attestationServiceUrl,
49917
50004
  params.platform,
49918
50005
  timeoutMs
@@ -49924,51 +50011,42 @@ var Zkp2pClient = class {
49924
50011
  if (!bundleResponse2.success || !bundleResponse2.responseObject) {
49925
50012
  throw new Error(bundleResponse2.message || "Failed to create seller credential bundle");
49926
50013
  }
49927
- return apiUploadSellerCredential(
49928
- params.platform,
49929
- bundleResponse2.responseObject.payeeIdHash,
49930
- bundleResponse2.responseObject,
49931
- baseApiUrl,
49932
- timeoutMs
50014
+ return this.uploadSellerCredentialBundle(
50015
+ {
50016
+ bundle: bundleResponse2.responseObject,
50017
+ platform: params.platform
50018
+ },
50019
+ { baseApiUrl, timeoutMs }
49933
50020
  );
49934
50021
  }
49935
- const registeredPayeePayload = {
49936
- offchainId: params.offchainId,
49937
- processorName: params.platform
49938
- };
49939
- if (params.telegramUsername !== void 0) {
49940
- registeredPayeePayload.telegramUsername = params.telegramUsername;
49941
- }
49942
- if (params.metadata !== void 0) {
49943
- registeredPayeePayload.metadata = params.metadata;
49944
- }
49945
- const registeredPayeeResponse = await apiPostDepositDetails(
49946
- registeredPayeePayload,
49947
- baseApiUrl,
49948
- timeoutMs
49949
- );
49950
- if (!registeredPayeeResponse.success || !registeredPayeeResponse.responseObject) {
49951
- throw new Error(registeredPayeeResponse.message || "Failed to register seller payee details");
49952
- }
49953
- const uploadPayload = {
50022
+ const bundlePayload = {
49954
50023
  payeeId: params.payeeId,
49955
50024
  sessionMaterial: params.sessionMaterial
49956
50025
  };
49957
- const bundleResponse = await createBundle(uploadPayload);
50026
+ const bundleResponse = await createBundle(bundlePayload);
49958
50027
  if (!bundleResponse.success || !bundleResponse.responseObject) {
49959
50028
  throw new Error(bundleResponse.message || "Failed to create seller credential bundle");
49960
50029
  }
49961
- const registeredPayee = registeredPayeeResponse.responseObject;
49962
- if (registeredPayee.hashedOnchainId.toLowerCase() !== bundleResponse.responseObject.payeeIdHash.toLowerCase()) {
49963
- throw new Error("Seller credential payee hash does not match registered payee details");
49964
- }
49965
- return apiUploadSellerCredential(
49966
- params.platform,
49967
- registeredPayee.hashedOnchainId,
49968
- bundleResponse.responseObject,
49969
- baseApiUrl,
49970
- timeoutMs
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
49971
50047
  );
50048
+ const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
50049
+ return apiUploadSellerCredentialBundle(params, baseApiUrl, timeoutMs);
49972
50050
  }
49973
50051
  /**
49974
50052
  * Confirms the PayPal Gmail-forwarding setup for an existing maker payee hash.
@@ -50267,189 +50345,13 @@ var getPeerExtensionState = async (options) => {
50267
50345
  return "needs_connection";
50268
50346
  }
50269
50347
  };
50270
- var fiatAmountRegex = /^-?\d*(\.\d{0,6})?$/;
50271
- var usdcAmountRegex = /^\d+$/;
50272
- var assertObjectInput = (params) => {
50273
- if (params === void 0) {
50274
- throw new Error("Peer extension onramp requires query params with intentHash.");
50275
- }
50276
- if (params === null || typeof params !== "object" || Array.isArray(params)) {
50277
- throw new Error("Peer extension onramp expects an object of query params.");
50278
- }
50279
- return params;
50280
- };
50281
- var normalizeOptionalString2 = (value, label) => {
50282
- if (value === void 0) {
50283
- return void 0;
50284
- }
50285
- if (typeof value !== "string") {
50286
- throw new Error(`Peer extension onramp ${label} must be a non-empty string.`);
50287
- }
50288
- const trimmed = value.trim();
50289
- if (!trimmed) {
50290
- throw new Error(`Peer extension onramp ${label} must be a non-empty string.`);
50291
- }
50292
- return trimmed;
50293
- };
50294
- var normalizeOptionalUrl = (value, label) => {
50295
- const trimmed = normalizeOptionalString2(value, label);
50296
- if (trimmed === void 0) {
50297
- return void 0;
50298
- }
50299
- let parsed;
50300
- try {
50301
- parsed = new URL(trimmed);
50302
- } catch (error) {
50303
- throw new Error(`Peer extension onramp ${label} must be a valid URL.`);
50304
- }
50305
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
50306
- throw new Error(`Peer extension onramp ${label} must use http or https.`);
50307
- }
50308
- return trimmed;
50309
- };
50310
- var normalizeFiatAmount = (value) => {
50311
- if (value === void 0) {
50312
- return void 0;
50313
- }
50314
- const normalized = typeof value === "number" ? String(value) : value;
50315
- if (typeof normalized !== "string") {
50316
- throw new Error("Peer extension onramp inputAmount must be a string or number.");
50317
- }
50318
- const trimmed = normalized.trim();
50319
- if (!trimmed) {
50320
- throw new Error("Peer extension onramp inputAmount must be a non-empty value.");
50321
- }
50322
- if (!fiatAmountRegex.test(trimmed)) {
50323
- throw new Error(
50324
- "Peer extension onramp inputAmount must be a non-negative number with up to 6 decimals."
50325
- );
50326
- }
50327
- if (Number.isNaN(Number(trimmed)) || Number(trimmed) < 0) {
50328
- throw new Error(
50329
- "Peer extension onramp inputAmount must be a non-negative number with up to 6 decimals."
50330
- );
50331
- }
50332
- return trimmed;
50333
- };
50334
- var normalizeUsdcAmount = (value) => {
50335
- if (value === void 0) {
50336
- return void 0;
50337
- }
50338
- if (typeof value === "bigint") {
50339
- if (value < 0n) {
50340
- throw new Error("Peer extension onramp amountUsdc must be a non-negative integer.");
50341
- }
50342
- return value.toString();
50343
- }
50344
- if (typeof value === "number") {
50345
- if (!Number.isFinite(value) || value < 0 || !Number.isInteger(value)) {
50346
- throw new Error("Peer extension onramp amountUsdc must be a non-negative integer.");
50347
- }
50348
- return String(value);
50349
- }
50350
- if (typeof value !== "string") {
50351
- throw new Error("Peer extension onramp amountUsdc must be a string, number, or bigint.");
50352
- }
50353
- const trimmed = value.trim();
50354
- if (!trimmed) {
50355
- throw new Error("Peer extension onramp amountUsdc must be a non-empty value.");
50356
- }
50357
- if (!usdcAmountRegex.test(trimmed)) {
50358
- throw new Error("Peer extension onramp amountUsdc must be a non-negative integer.");
50359
- }
50360
- return trimmed;
50361
- };
50362
- var normalizeIntegerParam = (value, label) => {
50363
- if (value === void 0) {
50364
- return void 0;
50365
- }
50366
- if (typeof value === "bigint") {
50367
- if (value < 0n) {
50368
- throw new Error(`Peer extension onramp ${label} must be a non-negative integer.`);
50369
- }
50370
- return value.toString();
50371
- }
50372
- if (typeof value === "number") {
50373
- if (!Number.isFinite(value) || value < 0 || !Number.isInteger(value)) {
50374
- throw new Error(`Peer extension onramp ${label} must be a non-negative integer.`);
50375
- }
50376
- if (!Number.isSafeInteger(value)) {
50377
- throw new Error(
50378
- `Peer extension onramp ${label} number input must be a safe integer; pass a string or bigint for larger values.`
50379
- );
50380
- }
50381
- return String(value);
50382
- }
50383
- if (typeof value !== "string") {
50384
- throw new Error(`Peer extension onramp ${label} must be a string, number, or bigint.`);
50385
- }
50386
- const trimmed = value.trim();
50387
- if (!trimmed) {
50388
- throw new Error(`Peer extension onramp ${label} must be a non-empty value.`);
50389
- }
50390
- if (!/^\d+$/.test(trimmed)) {
50391
- throw new Error(`Peer extension onramp ${label} must be a non-negative integer.`);
50392
- }
50393
- return trimmed;
50394
- };
50395
- var intentHashRegex = /^0x[a-fA-F0-9]{64}$/;
50396
- var normalizeIntentHash = (value) => {
50397
- if (value === void 0) {
50398
- throw new Error("Peer extension onramp intentHash is required.");
50399
- }
50400
- if (typeof value !== "string") {
50401
- throw new Error("Peer extension onramp intentHash must be a string.");
50402
- }
50403
- const trimmed = value.trim();
50404
- if (!trimmed) {
50405
- throw new Error("Peer extension onramp intentHash must be a non-empty string.");
50406
- }
50407
- if (!intentHashRegex.test(trimmed)) {
50408
- throw new Error(
50409
- "Peer extension onramp intentHash must be a valid bytes32 hex string (0x + 64 hex characters)."
50410
- );
50411
- }
50412
- return trimmed.toLowerCase();
50413
- };
50414
- var buildOnrampQueryString = (params) => {
50415
- const validated = assertObjectInput(params);
50416
- const searchParams = new URLSearchParams();
50417
- const setParam = (key, value) => {
50418
- if (value !== void 0) {
50419
- searchParams.set(key, value);
50420
- }
50421
- };
50422
- setParam("referrer", normalizeOptionalString2(validated.referrer, "referrer"));
50423
- setParam("referrerLogo", normalizeOptionalUrl(validated.referrerLogo, "referrerLogo"));
50424
- setParam("inputCurrency", normalizeOptionalString2(validated.inputCurrency, "inputCurrency"));
50425
- setParam("inputAmount", normalizeFiatAmount(validated.inputAmount));
50426
- setParam(
50427
- "paymentPlatform",
50428
- normalizeOptionalString2(validated.paymentPlatform, "paymentPlatform")
50429
- );
50430
- setParam("depositId", normalizeIntegerParam(validated.depositId, "depositId"));
50431
- setParam("toToken", normalizeOptionalString2(validated.toToken, "toToken"));
50432
- setParam("amountUsdc", normalizeUsdcAmount(validated.amountUsdc));
50433
- setParam(
50434
- "recipientAddress",
50435
- normalizeOptionalString2(validated.recipientAddress, "recipientAddress")
50436
- );
50437
- setParam("intentHash", normalizeIntentHash(validated.intentHash));
50438
- return searchParams.toString();
50439
- };
50440
50348
  var createPeerExtensionSdk = (options = {}) => ({
50441
50349
  isAvailable: () => isPeerExtensionAvailable(options),
50442
50350
  requestConnection: () => requirePeer(options).requestConnection(),
50443
50351
  checkConnectionStatus: () => requirePeer(options).checkConnectionStatus(),
50444
- openSidebar: (route) => requirePeer(options).openSidebar(route),
50445
- onramp: (params, callback) => {
50446
- if (typeof callback !== "function") {
50447
- throw new Error("Peer extension onramp callback is required.");
50448
- }
50449
- requirePeer(options).onramp(buildOnrampQueryString(params), callback);
50450
- },
50451
- getOnrampTransaction: (intentHash) => requirePeer(options).getOnrampTransaction(normalizeIntentHash(intentHash)),
50452
50352
  getVersion: () => requirePeer(options).getVersion(),
50353
+ authenticate: (params) => requirePeer(options).authenticate(params),
50354
+ onMetadataMessage: (callback) => requirePeer(options).onMetadataMessage(callback),
50453
50355
  openInstallPage: () => openPeerExtensionInstallPage(options),
50454
50356
  getState: () => getPeerExtensionState(options)
50455
50357
  });
@@ -50561,7 +50463,9 @@ exports.apiGetPayeeDetails = apiGetPayeeDetails;
50561
50463
  exports.apiGetQuotesBestByPlatform = apiGetQuotesBestByPlatform;
50562
50464
  exports.apiGetTakerTier = apiGetTakerTier;
50563
50465
  exports.apiPostDepositDetails = apiPostDepositDetails;
50466
+ exports.apiRequestIdentityAttestation = apiRequestIdentityAttestation;
50564
50467
  exports.apiUploadGoogleOAuthSellerCredential = apiUploadGoogleOAuthSellerCredential;
50468
+ exports.apiUploadSellerCredentialBundle = apiUploadSellerCredentialBundle;
50565
50469
  exports.apiValidatePayeeDetails = apiValidatePayeeDetails;
50566
50470
  exports.appendAttributionToCalldata = appendAttributionToCalldata;
50567
50471
  exports.asciiToBytes32 = asciiToBytes32;