@zkp2p/sdk 0.4.1 → 0.4.3

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
@@ -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,
@@ -43301,8 +43330,8 @@ var IntentOperations = class {
43301
43330
  intent
43302
43331
  },
43303
43332
  attestationServiceUrl,
43304
- platformConfig.actionPlatform,
43305
- platformConfig.actionType
43333
+ buyerTeeProof.actionPlatform ?? platformConfig.actionPlatform,
43334
+ buyerTeeProof.actionType ?? platformConfig.actionType
43306
43335
  ) : await apiCreatePaymentAttestation(
43307
43336
  {
43308
43337
  proofType: "reclaim",
@@ -43442,11 +43471,18 @@ function parseBuyerTeePaymentProofInput(proof) {
43442
43471
  if (typeof proof.encryptedSessionMaterial !== "string" || !isBuyerTeeParams(proof.params)) {
43443
43472
  throw new Error("Buyer TEE proof requires encryptedSessionMaterial and params.");
43444
43473
  }
43445
- return {
43474
+ const parsed = {
43446
43475
  proofType: "buyerTee",
43447
43476
  encryptedSessionMaterial: proof.encryptedSessionMaterial,
43448
43477
  params: proof.params
43449
43478
  };
43479
+ if (typeof proof.actionType === "string") {
43480
+ parsed.actionType = proof.actionType;
43481
+ }
43482
+ if (typeof proof.actionPlatform === "string") {
43483
+ parsed.actionPlatform = proof.actionPlatform;
43484
+ }
43485
+ return parsed;
43450
43486
  }
43451
43487
  function normalizeSignalIntentReferralFees(params) {
43452
43488
  if (params.referralFees) {
@@ -47238,6 +47274,19 @@ async function apiConfirmPayPalForwarding(payeeDetails, body, baseApiUrl, opts)
47238
47274
  timeoutMs: opts?.timeoutMs
47239
47275
  });
47240
47276
  }
47277
+ async function apiUploadGoogleOAuthSellerCredential(processorName, payeeDetails, body, baseApiUrl, opts) {
47278
+ const endpoint = `/v2/makers/${encodeURIComponent(processorName)}/${encodeURIComponent(
47279
+ payeeDetails
47280
+ )}/seller-credential/google-oauth`;
47281
+ return apiFetch({
47282
+ url: `${withApiBase(baseApiUrl)}${endpoint}`,
47283
+ method: "POST",
47284
+ body,
47285
+ apiKey: opts?.apiKey,
47286
+ authToken: opts?.authToken,
47287
+ timeoutMs: opts?.timeoutMs
47288
+ });
47289
+ }
47241
47290
  async function apiGetSellerCredentialStatus(processorName, payeeDetails, baseApiUrl, timeoutMs) {
47242
47291
  const endpoint = `/v2/makers/${encodeURIComponent(processorName)}/${encodeURIComponent(
47243
47292
  payeeDetails
@@ -47456,11 +47505,11 @@ var ERC20_ABI = [
47456
47505
  ];
47457
47506
 
47458
47507
  // src/client/Zkp2pClient.ts
47459
- function isStringRecord(value) {
47508
+ function isObjectRecord(value) {
47460
47509
  if (!value || typeof value !== "object" || Array.isArray(value)) {
47461
47510
  return false;
47462
47511
  }
47463
- return Object.values(value).every((entry) => typeof entry === "string");
47512
+ return true;
47464
47513
  }
47465
47514
  function normalizeTelegramUsername(value) {
47466
47515
  if (typeof value !== "string") {
@@ -47497,7 +47546,7 @@ function normalizeQuotePayeeData(maker) {
47497
47546
  return {
47498
47547
  offchainId,
47499
47548
  telegramUsername: normalizeTelegramUsername(maker?.telegramUsername) ?? legacy?.telegramUsername ?? null,
47500
- metadata: isStringRecord(maker?.metadata) ? maker.metadata : legacy?.metadata ?? null
47549
+ metadata: isObjectRecord(maker?.metadata) ? maker.metadata : legacy?.metadata ?? null
47501
47550
  };
47502
47551
  }
47503
47552
  function normalizePayeeDataInputItem(raw) {
@@ -49976,6 +50025,50 @@ var Zkp2pClient = class {
49976
50025
  }
49977
50026
  );
49978
50027
  }
50028
+ /**
50029
+ * Upload a seller Gmail OAuth authorization code through curator.
50030
+ *
50031
+ * Curator owns the encryption hop to attestation-service for this flow, so
50032
+ * callers send the one-time Google code plus the stable seller identity.
50033
+ */
50034
+ async uploadGoogleOAuthSellerCredential(params, opts) {
50035
+ const baseApiUrl = this.stripTrailingSlash(
50036
+ opts?.baseApiUrl ?? this.baseApiUrl ?? DEFAULT_BASE_API_URL
50037
+ );
50038
+ const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
50039
+ if (params.platform === "paypal") {
50040
+ return apiUploadGoogleOAuthSellerCredential(
50041
+ "paypal",
50042
+ params.payeeDetails,
50043
+ {
50044
+ payeeEmail: params.payeeEmail,
50045
+ authorizationCode: params.authorizationCode,
50046
+ redirectUri: params.redirectUri
50047
+ },
50048
+ baseApiUrl,
50049
+ {
50050
+ apiKey: this.apiKey,
50051
+ authToken: this.authorizationToken,
50052
+ timeoutMs
50053
+ }
50054
+ );
50055
+ }
50056
+ return apiUploadGoogleOAuthSellerCredential(
50057
+ "venmo",
50058
+ params.payeeDetails,
50059
+ {
50060
+ accountId: params.accountId,
50061
+ authorizationCode: params.authorizationCode,
50062
+ redirectUri: params.redirectUri
50063
+ },
50064
+ baseApiUrl,
50065
+ {
50066
+ apiKey: this.apiKey,
50067
+ authToken: this.authorizationToken,
50068
+ timeoutMs
50069
+ }
50070
+ );
50071
+ }
49979
50072
  /**
49980
50073
  * Status is a coarse curator-owned signal (`active` / `inactive` / `missing`) and intentionally
49981
50074
  * omits low-level diagnostics. Curator may still re-probe stale credentials during verify, so callers
@@ -50497,6 +50590,8 @@ exports.apiGetPayeeDetails = apiGetPayeeDetails;
50497
50590
  exports.apiGetQuotesBestByPlatform = apiGetQuotesBestByPlatform;
50498
50591
  exports.apiGetTakerTier = apiGetTakerTier;
50499
50592
  exports.apiPostDepositDetails = apiPostDepositDetails;
50593
+ exports.apiRequestIdentityAttestation = apiRequestIdentityAttestation;
50594
+ exports.apiUploadGoogleOAuthSellerCredential = apiUploadGoogleOAuthSellerCredential;
50500
50595
  exports.apiValidatePayeeDetails = apiValidatePayeeDetails;
50501
50596
  exports.appendAttributionToCalldata = appendAttributionToCalldata;
50502
50597
  exports.asciiToBytes32 = asciiToBytes32;