@zkp2p/sdk 0.4.3 → 0.5.2

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/dist/index.cjs CHANGED
@@ -42429,29 +42429,6 @@ async function createEncryptedSellerCredentialUploadForPlatform({
42429
42429
  ...attestationRuntime?.getRandomValues ? { getRandomValues: attestationRuntime.getRandomValues } : {}
42430
42430
  });
42431
42431
  }
42432
- async function apiCreatePaymentAttestation(payload, attestationServiceUrl, platform, actionType) {
42433
- return withRetry(async () => {
42434
- let res;
42435
- try {
42436
- const endpoint = `/verify/${encodeURIComponent(platform)}/${encodeURIComponent(actionType)}`;
42437
- res = await fetch(`${attestationServiceUrl}${endpoint}`, {
42438
- method: "POST",
42439
- headers: headers(),
42440
- body: JSON.stringify(payload)
42441
- });
42442
- } catch (error) {
42443
- throw new exports.NetworkError("Failed to connect to Attestation Service", {
42444
- endpoint: `/verify/${platform}/${actionType}`,
42445
- error
42446
- });
42447
- }
42448
- if (!res.ok) {
42449
- const errorText = await res.text();
42450
- throw parseAPIError(res, errorText);
42451
- }
42452
- return res.json();
42453
- });
42454
- }
42455
42432
  async function apiVerifyBuyerTeePayment(payload, attestationServiceUrl, platform, actionType) {
42456
42433
  return withRetry(async () => {
42457
42434
  let res;
@@ -42489,6 +42466,7 @@ async function apiRequestIdentityAttestation(payload, attestationServiceUrl, pla
42489
42466
  body: JSON.stringify({
42490
42467
  platform,
42491
42468
  actionType,
42469
+ callerAddress: payload.callerAddress,
42492
42470
  encryptedSessionMaterial: payload.encryptedSessionMaterial,
42493
42471
  params: payload.params
42494
42472
  })
@@ -43296,8 +43274,7 @@ var IntentOperations = class {
43296
43274
  paymentProof = precomputed.paymentProof;
43297
43275
  verificationData = precomputed.verificationData;
43298
43276
  } else {
43299
- const { proof } = params;
43300
- const buyerTeeProof = parseBuyerTeePaymentProofInput(proof);
43277
+ const buyerTeeProof = parseBuyerTeePaymentProofInput(params.proof);
43301
43278
  const attestationServiceUrl = params.attestationServiceUrl ?? this.defaultAttestationService();
43302
43279
  const inputs = await this.config.host.getFulfillIntentInputs(intentHash, {
43303
43280
  orchestratorAddress: orchestratorContext.address
@@ -43322,7 +43299,7 @@ var IntentOperations = class {
43322
43299
  payeeDetails: inputs.payeeDetails,
43323
43300
  timestampBufferMs: params.timestampBufferMs ?? "300000"
43324
43301
  };
43325
- const attestation = buyerTeeProof ? await apiVerifyBuyerTeePayment(
43302
+ const attestation = await apiVerifyBuyerTeePayment(
43326
43303
  {
43327
43304
  encryptedSessionMaterial: buyerTeeProof.encryptedSessionMaterial,
43328
43305
  params: buyerTeeProof.params,
@@ -43332,16 +43309,6 @@ var IntentOperations = class {
43332
43309
  attestationServiceUrl,
43333
43310
  buyerTeeProof.actionPlatform ?? platformConfig.actionPlatform,
43334
43311
  buyerTeeProof.actionType ?? platformConfig.actionType
43335
- ) : await apiCreatePaymentAttestation(
43336
- {
43337
- proofType: "reclaim",
43338
- proof: typeof proof === "string" ? proof : serializeProofInput(proof),
43339
- chainId: this.config.getChainId(),
43340
- intent
43341
- },
43342
- attestationServiceUrl,
43343
- platformConfig.actionPlatform,
43344
- platformConfig.actionType
43345
43312
  );
43346
43313
  paymentProof = encodePaymentAttestation(attestation);
43347
43314
  verificationData = encodeVerifyPaymentData({
@@ -43349,6 +43316,7 @@ var IntentOperations = class {
43349
43316
  paymentProof,
43350
43317
  data: encodeAddressAsBytes(attestation.responseObject.signer)
43351
43318
  });
43319
+ params.callbacks?.onAttestationComplete?.(attestation);
43352
43320
  }
43353
43321
  const args = [
43354
43322
  {
@@ -43430,9 +43398,12 @@ var IntentOperations = class {
43430
43398
  const deposit = await this.config.getIndexerService().fetchDepositWithRelations(record.depositId, {
43431
43399
  includeIntents: false
43432
43400
  });
43401
+ if (!deposit) {
43402
+ throw new Error(`Deposit ${record.depositId} not found on indexer for intent ${intentHash}`);
43403
+ }
43433
43404
  let payee;
43434
43405
  const paymentMethodHashLower = (record.paymentMethodHash || "").toLowerCase();
43435
- for (const paymentMethod of deposit?.paymentMethods || []) {
43406
+ for (const paymentMethod of deposit.paymentMethods || []) {
43436
43407
  if ((paymentMethod.paymentMethodHash || "").toLowerCase() === paymentMethodHashLower) {
43437
43408
  payee = paymentMethod.payeeDetailsHash;
43438
43409
  break;
@@ -43450,12 +43421,6 @@ var IntentOperations = class {
43450
43421
  };
43451
43422
  }
43452
43423
  };
43453
- function serializeProofInput(proof) {
43454
- return JSON.stringify(
43455
- proof,
43456
- (_key, value) => typeof value === "bigint" ? value.toString() : value
43457
- );
43458
- }
43459
43424
  function isRecord(value) {
43460
43425
  return typeof value === "object" && value !== null && !Array.isArray(value);
43461
43426
  }
@@ -43466,7 +43431,9 @@ function isBuyerTeeParams(value) {
43466
43431
  }
43467
43432
  function parseBuyerTeePaymentProofInput(proof) {
43468
43433
  if (!isRecord(proof) || proof.proofType !== "buyerTee") {
43469
- return null;
43434
+ throw new Error(
43435
+ "Buyer TEE proof input is required; legacy proof inputs are no longer supported."
43436
+ );
43470
43437
  }
43471
43438
  if (typeof proof.encryptedSessionMaterial !== "string" || !isBuyerTeeParams(proof.params)) {
43472
43439
  throw new Error("Buyer TEE proof requires encryptedSessionMaterial and params.");
@@ -45315,6 +45282,7 @@ var INTENT_FULFILLMENTS_QUERY = (
45315
45282
  query GetFulfilledIntents($intentHashes: [String!]) {
45316
45283
  Orchestrator_V21_IntentFulfilled(where: { intentHash: { _in: $intentHashes } }) {
45317
45284
  intentHash
45285
+ amount
45318
45286
  isManualRelease
45319
45287
  fundsTransferredTo
45320
45288
  }
@@ -46949,6 +46917,46 @@ init_contracts();
46949
46917
 
46950
46918
  // src/adapters/api.ts
46951
46919
  init_errors();
46920
+
46921
+ // src/utils/logger.ts
46922
+ var currentLevel = "info";
46923
+ function setLogLevel(level) {
46924
+ currentLevel = level;
46925
+ }
46926
+ function shouldLog(level) {
46927
+ switch (currentLevel) {
46928
+ case "debug":
46929
+ return true;
46930
+ case "info":
46931
+ return level !== "debug";
46932
+ case "error":
46933
+ return level === "error";
46934
+ default:
46935
+ return true;
46936
+ }
46937
+ }
46938
+ var logger = {
46939
+ debug: (...args) => {
46940
+ if (shouldLog("debug")) {
46941
+ console.log("[DEBUG]", ...args);
46942
+ }
46943
+ },
46944
+ info: (...args) => {
46945
+ if (shouldLog("info")) {
46946
+ console.log("[INFO]", ...args);
46947
+ }
46948
+ },
46949
+ warn: (...args) => {
46950
+ if (shouldLog("info")) {
46951
+ console.warn("[WARN]", ...args);
46952
+ }
46953
+ },
46954
+ error: (...args) => {
46955
+ console.error("[ERROR]", ...args);
46956
+ }
46957
+ };
46958
+
46959
+ // src/adapters/api.ts
46952
46960
  function createHeaders2(apiKey, authToken) {
46953
46961
  const headers2 = { "Content-Type": "application/json" };
46954
46962
  if (apiKey) headers2["x-api-key"] = apiKey;
@@ -47055,10 +47063,17 @@ function buildLegacyVerifierCurrencies(deposit) {
47055
47063
  const currenciesByMethod = /* @__PURE__ */ new Map();
47056
47064
  for (const currency of deposit.currencies ?? []) {
47057
47065
  const methodHash = currency.paymentMethodHash;
47066
+ const resolvedConversionRate = currency.conversionRate ?? currency.minConversionRate;
47067
+ if (resolvedConversionRate === null || resolvedConversionRate === void 0) {
47068
+ logger.warn(
47069
+ `[sdk] Skipping currency with missing conversion rate (deposit ${deposit.depositId}, currency ${currency.currencyCode})`
47070
+ );
47071
+ continue;
47072
+ }
47058
47073
  const bucket = currenciesByMethod.get(methodHash) ?? [];
47059
47074
  bucket.push({
47060
47075
  currencyCode: currency.currencyCode,
47061
- conversionRate: currency.conversionRate ?? currency.minConversionRate,
47076
+ conversionRate: resolvedConversionRate,
47062
47077
  minConversionRate: currency.minConversionRate,
47063
47078
  managerRate: currency.managerRate ?? null,
47064
47079
  rateManagerId: currency.rateManagerId ?? null
@@ -47261,19 +47276,6 @@ async function apiUploadSellerCredential(processorName, payeeDetails, bundle, ba
47261
47276
  timeoutMs
47262
47277
  });
47263
47278
  }
47264
- async function apiConfirmPayPalForwarding(payeeDetails, body, baseApiUrl, opts) {
47265
- const endpoint = `/v2/makers/paypal/${encodeURIComponent(
47266
- payeeDetails
47267
- )}/seller-credential/forwarding-confirmation`;
47268
- return apiFetch({
47269
- url: `${withApiBase(baseApiUrl)}${endpoint}`,
47270
- method: "POST",
47271
- body,
47272
- apiKey: opts?.apiKey,
47273
- authToken: opts?.authToken,
47274
- timeoutMs: opts?.timeoutMs
47275
- });
47276
- }
47277
47279
  async function apiUploadGoogleOAuthSellerCredential(processorName, payeeDetails, body, baseApiUrl, opts) {
47278
47280
  const endpoint = `/v2/makers/${encodeURIComponent(processorName)}/${encodeURIComponent(
47279
47281
  payeeDetails
@@ -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();
@@ -48363,7 +48417,7 @@ var Zkp2pClient = class {
48363
48417
  * ```
48364
48418
  *
48365
48419
  * @param params.intentHash - The intent hash to fulfill (0x-prefixed, 32 bytes)
48366
- * @param params.proof - Payment proof from Reclaim (object or JSON string) or buyer TEE proof input
48420
+ * @param params.proof - Buyer TEE payment proof input
48367
48421
  * @param params.timestampBufferMs - Allowed timestamp variance (default: 300000ms)
48368
48422
  * @param params.attestationServiceUrl - Override attestation service URL
48369
48423
  * @param params.postIntentHookData - Data to pass to post-intent hook
@@ -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 = (uploadPayload2) => opts?.attestationRuntime ? apiCreateSellerCredentialBundle(
49938
- uploadPayload2,
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
- uploadPayload2,
50002
+ uploadPayload,
49945
50003
  attestationServiceUrl,
49946
50004
  params.platform,
49947
50005
  timeoutMs
@@ -49953,77 +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 apiUploadSellerCredential(
49957
- params.platform,
49958
- bundleResponse2.responseObject.payeeIdHash,
49959
- bundleResponse2.responseObject,
49960
- baseApiUrl,
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 registeredPayeePayload = {
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(uploadPayload);
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
- const registeredPayee = registeredPayeeResponse.responseObject;
49991
- if (registeredPayee.hashedOnchainId.toLowerCase() !== bundleResponse.responseObject.payeeIdHash.toLowerCase()) {
49992
- throw new Error("Seller credential payee hash does not match registered payee details");
49993
- }
49994
- return apiUploadSellerCredential(
49995
- params.platform,
49996
- registeredPayee.hashedOnchainId,
49997
- bundleResponse.responseObject,
49998
- baseApiUrl,
49999
- 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 }
50000
50039
  );
50001
50040
  }
50002
50041
  /**
50003
- * Confirms the PayPal Gmail-forwarding setup for an existing maker payee hash.
50004
- *
50005
- * Uses curator's `/forwarding-confirmation` route and forwards both API key and
50006
- * bearer token so either auth strategy can satisfy the hybrid gate. The endpoint
50007
- * is rate-limited server-side; callers should surface retry guidance from APIError.
50042
+ * Store an already-encrypted seller credential bundle with curator.
50008
50043
  */
50009
- async confirmPayPalForwarding(params, opts) {
50044
+ async uploadSellerCredentialBundle(params, opts) {
50010
50045
  const baseApiUrl = this.stripTrailingSlash(
50011
50046
  opts?.baseApiUrl ?? this.baseApiUrl ?? DEFAULT_BASE_API_URL
50012
50047
  );
50013
50048
  const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
50014
- return apiConfirmPayPalForwarding(
50015
- params.payeeDetails,
50016
- {
50017
- payeeEmail: params.payeeEmail,
50018
- forwardingInitiatorEmail: params.forwardingInitiatorEmail
50019
- },
50020
- baseApiUrl,
50021
- {
50022
- apiKey: this.apiKey,
50023
- authToken: this.authorizationToken,
50024
- timeoutMs
50025
- }
50026
- );
50049
+ return apiUploadSellerCredentialBundle(params, baseApiUrl, timeoutMs);
50027
50050
  }
50028
50051
  /**
50029
50052
  * Upload a seller Gmail OAuth authorization code through curator.
@@ -50296,189 +50319,13 @@ var getPeerExtensionState = async (options) => {
50296
50319
  return "needs_connection";
50297
50320
  }
50298
50321
  };
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
50322
  var createPeerExtensionSdk = (options = {}) => ({
50470
50323
  isAvailable: () => isPeerExtensionAvailable(options),
50471
50324
  requestConnection: () => requirePeer(options).requestConnection(),
50472
50325
  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
50326
  getVersion: () => requirePeer(options).getVersion(),
50327
+ authenticate: (params) => requirePeer(options).authenticate(params),
50328
+ onMetadataMessage: (callback) => requirePeer(options).onMetadataMessage(callback),
50482
50329
  openInstallPage: () => openPeerExtensionInstallPage(options),
50483
50330
  getState: () => getPeerExtensionState(options)
50484
50331
  });
@@ -50490,46 +50337,6 @@ init_paymentResolution();
50490
50337
  init_contracts();
50491
50338
  init_bytes32();
50492
50339
  init_protocolViewerParsers();
50493
-
50494
- // src/utils/logger.ts
50495
- var currentLevel = "info";
50496
- function setLogLevel(level) {
50497
- currentLevel = level;
50498
- }
50499
- function shouldLog(level) {
50500
- switch (currentLevel) {
50501
- case "debug":
50502
- return true;
50503
- case "info":
50504
- return level !== "debug";
50505
- case "error":
50506
- return level === "error";
50507
- default:
50508
- return true;
50509
- }
50510
- }
50511
- var logger = {
50512
- debug: (...args) => {
50513
- if (shouldLog("debug")) {
50514
- console.log("[DEBUG]", ...args);
50515
- }
50516
- },
50517
- info: (...args) => {
50518
- if (shouldLog("info")) {
50519
- console.log("[INFO]", ...args);
50520
- }
50521
- },
50522
- warn: (...args) => {
50523
- if (shouldLog("info")) {
50524
- console.warn("[WARN]", ...args);
50525
- }
50526
- },
50527
- error: (...args) => {
50528
- console.error("[ERROR]", ...args);
50529
- }
50530
- };
50531
-
50532
- // src/index.ts
50533
50340
  init_errors();
50534
50341
 
50535
50342
  // src/react/hooks/vaultUtils.ts
@@ -50559,6 +50366,10 @@ var classifyDelegationState = (currentRateManagerId, currentRegistry, targetRate
50559
50366
  };
50560
50367
  var getDelegationRoute = (_client, _escrow) => "v2";
50561
50368
 
50369
+ Object.defineProperty(exports, "createNitroAttestationClient", {
50370
+ enumerable: true,
50371
+ get: function () { return zkp2pAttestation.createNitroAttestationClient; }
50372
+ });
50562
50373
  exports.BASE_BUILDER_CODE = BASE_BUILDER_CODE;
50563
50374
  exports.CHAINLINK_ORACLE_ADAPTER = CHAINLINK_ORACLE_ADAPTER;
50564
50375
  exports.CHAINLINK_ORACLE_FEEDS = CHAINLINK_ORACLE_FEEDS;
@@ -50581,7 +50392,6 @@ exports.ZERO_RATE_MANAGER_ID = ZERO_RATE_MANAGER_ID;
50581
50392
  exports.ZKP2P_ANDROID_REFERRER = ZKP2P_ANDROID_REFERRER;
50582
50393
  exports.ZKP2P_IOS_REFERRER = ZKP2P_IOS_REFERRER;
50583
50394
  exports.Zkp2pClient = Zkp2pClient;
50584
- exports.apiConfirmPayPalForwarding = apiConfirmPayPalForwarding;
50585
50395
  exports.apiCreateSellerCredentialBundle = apiCreateSellerCredentialBundle;
50586
50396
  exports.apiGetDepositBundle = apiGetDepositBundle;
50587
50397
  exports.apiGetOrderbook = apiGetOrderbook;
@@ -50592,6 +50402,7 @@ exports.apiGetTakerTier = apiGetTakerTier;
50592
50402
  exports.apiPostDepositDetails = apiPostDepositDetails;
50593
50403
  exports.apiRequestIdentityAttestation = apiRequestIdentityAttestation;
50594
50404
  exports.apiUploadGoogleOAuthSellerCredential = apiUploadGoogleOAuthSellerCredential;
50405
+ exports.apiUploadSellerCredentialBundle = apiUploadSellerCredentialBundle;
50595
50406
  exports.apiValidatePayeeDetails = apiValidatePayeeDetails;
50596
50407
  exports.appendAttributionToCalldata = appendAttributionToCalldata;
50597
50408
  exports.asciiToBytes32 = asciiToBytes32;