@zkp2p/sdk 0.5.0 → 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/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.4.3`
9
+ Current version: `0.5.0`
10
10
 
11
11
  ## Why This SDK
12
12
 
@@ -256,7 +256,11 @@ const intentHash = await client.signalIntent({
256
256
 
257
257
  await client.fulfillIntent({
258
258
  intentHash,
259
- proof: zkTlsProofJson,
259
+ proof: {
260
+ proofType: 'buyerTee',
261
+ encryptedSessionMaterial,
262
+ params: buyerTeePaymentParams,
263
+ },
260
264
  });
261
265
 
262
266
  await client.releaseFundsToPayer({
@@ -415,7 +419,7 @@ await client.setDepositWhitelistHook({
415
419
  });
416
420
  ```
417
421
 
418
- Use `removeDelegate()` and `clearRateManager()` to unwind delegation. Phase-4 hook methods are available when the target deployment supports them.
422
+ Use `removeDelegate()` and `clearRateManager()` to unwind delegation. Hook methods are part of the current V2 surface; still validate target contract support before assuming a deployment exposes every hook.
419
423
 
420
424
  ## Vault / DRM
421
425
 
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({
@@ -43431,9 +43398,12 @@ var IntentOperations = class {
43431
43398
  const deposit = await this.config.getIndexerService().fetchDepositWithRelations(record.depositId, {
43432
43399
  includeIntents: false
43433
43400
  });
43401
+ if (!deposit) {
43402
+ throw new Error(`Deposit ${record.depositId} not found on indexer for intent ${intentHash}`);
43403
+ }
43434
43404
  let payee;
43435
43405
  const paymentMethodHashLower = (record.paymentMethodHash || "").toLowerCase();
43436
- for (const paymentMethod of deposit?.paymentMethods || []) {
43406
+ for (const paymentMethod of deposit.paymentMethods || []) {
43437
43407
  if ((paymentMethod.paymentMethodHash || "").toLowerCase() === paymentMethodHashLower) {
43438
43408
  payee = paymentMethod.payeeDetailsHash;
43439
43409
  break;
@@ -43451,12 +43421,6 @@ var IntentOperations = class {
43451
43421
  };
43452
43422
  }
43453
43423
  };
43454
- function serializeProofInput(proof) {
43455
- return JSON.stringify(
43456
- proof,
43457
- (_key, value) => typeof value === "bigint" ? value.toString() : value
43458
- );
43459
- }
43460
43424
  function isRecord(value) {
43461
43425
  return typeof value === "object" && value !== null && !Array.isArray(value);
43462
43426
  }
@@ -43467,7 +43431,9 @@ function isBuyerTeeParams(value) {
43467
43431
  }
43468
43432
  function parseBuyerTeePaymentProofInput(proof) {
43469
43433
  if (!isRecord(proof) || proof.proofType !== "buyerTee") {
43470
- return null;
43434
+ throw new Error(
43435
+ "Buyer TEE proof input is required; legacy proof inputs are no longer supported."
43436
+ );
43471
43437
  }
43472
43438
  if (typeof proof.encryptedSessionMaterial !== "string" || !isBuyerTeeParams(proof.params)) {
43473
43439
  throw new Error("Buyer TEE proof requires encryptedSessionMaterial and params.");
@@ -46951,6 +46917,46 @@ init_contracts();
46951
46917
 
46952
46918
  // src/adapters/api.ts
46953
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
46954
46960
  function createHeaders2(apiKey, authToken) {
46955
46961
  const headers2 = { "Content-Type": "application/json" };
46956
46962
  if (apiKey) headers2["x-api-key"] = apiKey;
@@ -47057,10 +47063,17 @@ function buildLegacyVerifierCurrencies(deposit) {
47057
47063
  const currenciesByMethod = /* @__PURE__ */ new Map();
47058
47064
  for (const currency of deposit.currencies ?? []) {
47059
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
+ }
47060
47073
  const bucket = currenciesByMethod.get(methodHash) ?? [];
47061
47074
  bucket.push({
47062
47075
  currencyCode: currency.currencyCode,
47063
- conversionRate: currency.conversionRate ?? currency.minConversionRate,
47076
+ conversionRate: resolvedConversionRate,
47064
47077
  minConversionRate: currency.minConversionRate,
47065
47078
  managerRate: currency.managerRate ?? null,
47066
47079
  rateManagerId: currency.rateManagerId ?? null
@@ -47263,19 +47276,6 @@ async function apiUploadSellerCredential(processorName, payeeDetails, bundle, ba
47263
47276
  timeoutMs
47264
47277
  });
47265
47278
  }
47266
- async function apiConfirmPayPalForwarding(payeeDetails, body, baseApiUrl, opts) {
47267
- const endpoint = `/v2/makers/paypal/${encodeURIComponent(
47268
- payeeDetails
47269
- )}/seller-credential/forwarding-confirmation`;
47270
- return apiFetch({
47271
- url: `${withApiBase(baseApiUrl)}${endpoint}`,
47272
- method: "POST",
47273
- body,
47274
- apiKey: opts?.apiKey,
47275
- authToken: opts?.authToken,
47276
- timeoutMs: opts?.timeoutMs
47277
- });
47278
- }
47279
47279
  async function apiUploadGoogleOAuthSellerCredential(processorName, payeeDetails, body, baseApiUrl, opts) {
47280
47280
  const endpoint = `/v2/makers/${encodeURIComponent(processorName)}/${encodeURIComponent(
47281
47281
  payeeDetails
@@ -48417,7 +48417,7 @@ var Zkp2pClient = class {
48417
48417
  * ```
48418
48418
  *
48419
48419
  * @param params.intentHash - The intent hash to fulfill (0x-prefixed, 32 bytes)
48420
- * @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
48421
48421
  * @param params.timestampBufferMs - Allowed timestamp variance (default: 300000ms)
48422
48422
  * @param params.attestationServiceUrl - Override attestation service URL
48423
48423
  * @param params.postIntentHookData - Data to pass to post-intent hook
@@ -50048,32 +50048,6 @@ var Zkp2pClient = class {
50048
50048
  const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
50049
50049
  return apiUploadSellerCredentialBundle(params, baseApiUrl, timeoutMs);
50050
50050
  }
50051
- /**
50052
- * Confirms the PayPal Gmail-forwarding setup for an existing maker payee hash.
50053
- *
50054
- * Uses curator's `/forwarding-confirmation` route and forwards both API key and
50055
- * bearer token so either auth strategy can satisfy the hybrid gate. The endpoint
50056
- * is rate-limited server-side; callers should surface retry guidance from APIError.
50057
- */
50058
- async confirmPayPalForwarding(params, opts) {
50059
- const baseApiUrl = this.stripTrailingSlash(
50060
- opts?.baseApiUrl ?? this.baseApiUrl ?? DEFAULT_BASE_API_URL
50061
- );
50062
- const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
50063
- return apiConfirmPayPalForwarding(
50064
- params.payeeDetails,
50065
- {
50066
- payeeEmail: params.payeeEmail,
50067
- forwardingInitiatorEmail: params.forwardingInitiatorEmail
50068
- },
50069
- baseApiUrl,
50070
- {
50071
- apiKey: this.apiKey,
50072
- authToken: this.authorizationToken,
50073
- timeoutMs
50074
- }
50075
- );
50076
- }
50077
50051
  /**
50078
50052
  * Upload a seller Gmail OAuth authorization code through curator.
50079
50053
  *
@@ -50363,46 +50337,6 @@ init_paymentResolution();
50363
50337
  init_contracts();
50364
50338
  init_bytes32();
50365
50339
  init_protocolViewerParsers();
50366
-
50367
- // src/utils/logger.ts
50368
- var currentLevel = "info";
50369
- function setLogLevel(level) {
50370
- currentLevel = level;
50371
- }
50372
- function shouldLog(level) {
50373
- switch (currentLevel) {
50374
- case "debug":
50375
- return true;
50376
- case "info":
50377
- return level !== "debug";
50378
- case "error":
50379
- return level === "error";
50380
- default:
50381
- return true;
50382
- }
50383
- }
50384
- var logger = {
50385
- debug: (...args) => {
50386
- if (shouldLog("debug")) {
50387
- console.log("[DEBUG]", ...args);
50388
- }
50389
- },
50390
- info: (...args) => {
50391
- if (shouldLog("info")) {
50392
- console.log("[INFO]", ...args);
50393
- }
50394
- },
50395
- warn: (...args) => {
50396
- if (shouldLog("info")) {
50397
- console.warn("[WARN]", ...args);
50398
- }
50399
- },
50400
- error: (...args) => {
50401
- console.error("[ERROR]", ...args);
50402
- }
50403
- };
50404
-
50405
- // src/index.ts
50406
50340
  init_errors();
50407
50341
 
50408
50342
  // src/react/hooks/vaultUtils.ts
@@ -50432,6 +50366,10 @@ var classifyDelegationState = (currentRateManagerId, currentRegistry, targetRate
50432
50366
  };
50433
50367
  var getDelegationRoute = (_client, _escrow) => "v2";
50434
50368
 
50369
+ Object.defineProperty(exports, "createNitroAttestationClient", {
50370
+ enumerable: true,
50371
+ get: function () { return zkp2pAttestation.createNitroAttestationClient; }
50372
+ });
50435
50373
  exports.BASE_BUILDER_CODE = BASE_BUILDER_CODE;
50436
50374
  exports.CHAINLINK_ORACLE_ADAPTER = CHAINLINK_ORACLE_ADAPTER;
50437
50375
  exports.CHAINLINK_ORACLE_FEEDS = CHAINLINK_ORACLE_FEEDS;
@@ -50454,7 +50392,6 @@ exports.ZERO_RATE_MANAGER_ID = ZERO_RATE_MANAGER_ID;
50454
50392
  exports.ZKP2P_ANDROID_REFERRER = ZKP2P_ANDROID_REFERRER;
50455
50393
  exports.ZKP2P_IOS_REFERRER = ZKP2P_IOS_REFERRER;
50456
50394
  exports.Zkp2pClient = Zkp2pClient;
50457
- exports.apiConfirmPayPalForwarding = apiConfirmPayPalForwarding;
50458
50395
  exports.apiCreateSellerCredentialBundle = apiCreateSellerCredentialBundle;
50459
50396
  exports.apiGetDepositBundle = apiGetDepositBundle;
50460
50397
  exports.apiGetOrderbook = apiGetOrderbook;