@zkp2p/sdk 0.14.8-rc.0 → 0.14.9

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.
@@ -0,0 +1,12 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // <define:__ZKP2P_SDK_BUILD_METADATA__>
8
+ var define_ZKP2P_SDK_BUILD_METADATA_default = { schemaVersion: 2, source: { repository: "zkp2p/zkp2p-clients", commitSha: "d2e1cd11fec30f7b401b43a3842414c11379ab35", kind: "github", distributable: true }, sdkPackageVersion: "0.14.9", contractsPackageVersion: "0.4.4-rc.2", indexerSchemaPackageVersion: "0.22.0", activeDisputeStack: { base: { version: 2, selectionHash: "ba40c2954b408d0c658881a8d28e5bfcc9bade5cc3d953fd17eae1eca69d841c" }, baseStaging: { version: 2, selectionHash: "6c49c1ce51eec594a22385c4efcab08aa9926b6b63a725e14a0027ec5d2f4fc9" } } };
9
+
10
+ export { __export, define_ZKP2P_SDK_BUILD_METADATA_default };
11
+ //# sourceMappingURL=chunk-ERJIIFAV.mjs.map
12
+ //# sourceMappingURL=chunk-ERJIIFAV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["%3Cdefine:__ZKP2P_SDK_BUILD_METADATA__%3E"],"names":[],"mappings":";;;;;;;AAAA,IAAA,uCAAA,GAAA,EAAC,aAAA,EAAgB,CAAA,EAAE,MAAA,EAAS,EAAC,YAAa,qBAAA,EAAsB,SAAA,EAAY,0CAAA,EAA2C,IAAA,EAAO,UAAS,aAAA,EAAgB,IAAA,EAAI,EAAE,iBAAA,EAAoB,UAAS,uBAAA,EAA0B,YAAA,EAAa,2BAAA,EAA8B,QAAA,EAAS,oBAAqB,EAAC,IAAA,EAAO,EAAC,OAAA,EAAU,GAAE,aAAA,EAAgB,kEAAA,EAAkE,EAAE,WAAA,EAAc,EAAC,OAAA,EAAU,CAAA,EAAE,aAAA,EAAgB,kEAAA,IAAmE","file":"chunk-ERJIIFAV.mjs","sourcesContent":["{\"schemaVersion\":2,\"source\":{\"repository\":\"zkp2p/zkp2p-clients\",\"commitSha\":\"d2e1cd11fec30f7b401b43a3842414c11379ab35\",\"kind\":\"github\",\"distributable\":true},\"sdkPackageVersion\":\"0.14.9\",\"contractsPackageVersion\":\"0.4.4-rc.2\",\"indexerSchemaPackageVersion\":\"0.22.0\",\"activeDisputeStack\":{\"base\":{\"version\":2,\"selectionHash\":\"ba40c2954b408d0c658881a8d28e5bfcc9bade5cc3d953fd17eae1eca69d841c\"},\"baseStaging\":{\"version\":2,\"selectionHash\":\"6c49c1ce51eec594a22385c4efcab08aa9926b6b63a725e14a0027ec5d2f4fc9\"}}}"]}
@@ -1,4 +1,4 @@
1
1
  export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchain, mapConversionRatesToOnchainMinRate } from './chunk-WDEEWFEU.mjs';
2
- import './chunk-KQT4XYPO.mjs';
3
- //# sourceMappingURL=currency-45EYG6OA.mjs.map
4
- //# sourceMappingURL=currency-45EYG6OA.mjs.map
2
+ import './chunk-ERJIIFAV.mjs';
3
+ //# sourceMappingURL=currency-AGVR2YDU.mjs.map
4
+ //# sourceMappingURL=currency-AGVR2YDU.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"currency-45EYG6OA.mjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"currency-AGVR2YDU.mjs"}
package/dist/index.cjs CHANGED
@@ -21,7 +21,7 @@ var __export = (target, all) => {
21
21
  var define_ZKP2P_SDK_BUILD_METADATA_default;
22
22
  var init_define_ZKP2P_SDK_BUILD_METADATA = __esm({
23
23
  "<define:__ZKP2P_SDK_BUILD_METADATA__>"() {
24
- define_ZKP2P_SDK_BUILD_METADATA_default = { schemaVersion: 2, source: { repository: "zkp2p/zkp2p-clients", commitSha: "959ea2fdca3a9938c97be98f96f66f1e74ec144d", kind: "github", distributable: true }, sdkPackageVersion: "0.14.8-rc.0", contractsPackageVersion: "0.4.4-rc.2", indexerSchemaPackageVersion: "0.22.0", activeDisputeStack: { base: { version: 2, selectionHash: "ba40c2954b408d0c658881a8d28e5bfcc9bade5cc3d953fd17eae1eca69d841c" }, baseStaging: { version: 2, selectionHash: "6c49c1ce51eec594a22385c4efcab08aa9926b6b63a725e14a0027ec5d2f4fc9" } } };
24
+ define_ZKP2P_SDK_BUILD_METADATA_default = { schemaVersion: 2, source: { repository: "zkp2p/zkp2p-clients", commitSha: "d2e1cd11fec30f7b401b43a3842414c11379ab35", kind: "github", distributable: true }, sdkPackageVersion: "0.14.9", contractsPackageVersion: "0.4.4-rc.2", indexerSchemaPackageVersion: "0.22.0", activeDisputeStack: { base: { version: 2, selectionHash: "ba40c2954b408d0c658881a8d28e5bfcc9bade5cc3d953fd17eae1eca69d841c" }, baseStaging: { version: 2, selectionHash: "6c49c1ce51eec594a22385c4efcab08aa9926b6b63a725e14a0027ec5d2f4fc9" } } };
25
25
  }
26
26
  });
27
27
 
@@ -102221,6 +102221,55 @@ var zelleCitiVerifyConfig = {
102221
102221
  return `Transfer of $${Number(metadata.amount)} to ${metadata.recipient}`;
102222
102222
  }
102223
102223
  };
102224
+ var CAPITAL_ONE_ZELLE_APP_LINK = "https://links.capitalone.com/bank/zelle/getting-started/";
102225
+ var zelleCapitalOneSendConfig = {
102226
+ paymentMethodName: "Capital One",
102227
+ defaultPaymentMode: "QR_CODE",
102228
+ useCustomQRCode: true,
102229
+ getFormattedSendLink: () => CAPITAL_ONE_ZELLE_APP_LINK,
102230
+ troubleScanningQRCodeLink: () => CAPITAL_ONE_ZELLE_APP_LINK,
102231
+ deepLinkEmbedsRecipient: false,
102232
+ supportsSendingPaymentOnWeb: true,
102233
+ showTroubleScanningQRCodeLink: true,
102234
+ sendPaymentWarning: (currency, amount) => `Send exactly ${amount} ${currencyInfo[currency].currencyCode} in a single payment through Capital One's Zelle.`,
102235
+ sendPaymentInfo: () => "Only use Capital One. Keep the \u201CYou sent money with Zelle\u201D email to verify this payment.",
102236
+ sendPaymentDos: (currency, amount) => [
102237
+ { text: "Use Capital One for this payment", emphasize: ["Capital One"] },
102238
+ {
102239
+ text: `Send exactly ${amount} ${currencyInfo[currency].currencyCode} in a single payment`,
102240
+ emphasize: [
102241
+ "exactly",
102242
+ amount,
102243
+ currencyInfo[currency].currencyCode,
102244
+ "single"
102245
+ ]
102246
+ }
102247
+ ],
102248
+ sendPaymentDonts: () => [
102249
+ {
102250
+ text: "Do not send unless you can open the Capital One payment email. The email is required to verify your payment and complete this order.",
102251
+ emphasize: ["Do not send", "payment email"]
102252
+ },
102253
+ { text: "Do not send using any other bank", emphasize: ["Do not"] }
102254
+ ]
102255
+ };
102256
+ var zelleCapitalOneVerifyConfig = {
102257
+ authLink: "https://myaccounts.capitalone.com/",
102258
+ actionType: "transfer_zelle_capitalone",
102259
+ actionPlatform: PaymentPlatform.ZELLE,
102260
+ numPaymentsFetched: 20,
102261
+ minExtensionVersion: "0.0.0",
102262
+ supportsAppclip: false,
102263
+ totalProofs: 1,
102264
+ verifiesByEmail: true,
102265
+ // PeerAuth never captures payment metadata for an email-verified bank.
102266
+ parseMetadata: () => {
102267
+ throw new Error("Capital One payments have no PeerAuth metadata");
102268
+ },
102269
+ getSubjectText: () => {
102270
+ throw new Error("Capital One payments have no PeerAuth metadata");
102271
+ }
102272
+ };
102224
102273
  var genericZelleBankRoutes = [
102225
102274
  {
102226
102275
  bankId: "chase",
@@ -102236,12 +102285,24 @@ var genericZelleBankRoutes = [
102236
102285
  bankId: "citi",
102237
102286
  sendConfig: zelleCitiSendConfig,
102238
102287
  verifyConfig: zelleCitiVerifyConfig
102288
+ },
102289
+ {
102290
+ bankId: "capitalone",
102291
+ sendConfig: zelleCapitalOneSendConfig,
102292
+ verifyConfig: zelleCapitalOneVerifyConfig
102239
102293
  }
102240
102294
  ];
102241
102295
  genericZelleBankRoutes.map(({ sendConfig, verifyConfig }) => ({
102242
102296
  sendConfig,
102243
102297
  verifyConfig
102244
102298
  }));
102299
+ var usdcUnits = (amount) => {
102300
+ return viem.parseUnits(amount.toString(), 6);
102301
+ };
102302
+ ({
102303
+ orderCapDeposit: {
102304
+ minOrder: usdcUnits(5),
102305
+ maxOrder: usdcUnits(500)}});
102245
102306
  var DISPUTE_PROTECTION_STAKE_PLATFORMS = [
102246
102307
  PaymentPlatform.VENMO,
102247
102308
  PaymentPlatform.PAYPAL
@@ -103516,6 +103577,7 @@ function resolvePlatformAttestationConfig(platformName) {
103516
103577
  // src/client/IntentOperations.ts
103517
103578
  var GENERIC_ZELLE_ATTESTATION_ACTION_TYPES = /* @__PURE__ */ new Set([
103518
103579
  "transfer_zelle_bofa",
103580
+ "transfer_zelle_capitalone",
103519
103581
  "transfer_zelle_chase",
103520
103582
  "transfer_zelle_citi"
103521
103583
  ]);
@@ -107216,7 +107278,7 @@ async function apiUploadMicrosoftOAuthSellerCredential(processorName, payeeDetai
107216
107278
  }
107217
107279
  async function apiUploadEmailOAuthSellerCredential(provider, processorName, payeeDetails, body, baseApiUrl, opts) {
107218
107280
  const providerName = provider === "google" ? "Google" : "Microsoft";
107219
- if (processorName !== "paypal" && processorName !== "venmo") {
107281
+ if (processorName !== "paypal" && processorName !== "venmo" && processorName !== "xmoney") {
107220
107282
  throw new exports.ValidationError(
107221
107283
  `Unsupported ${providerName} OAuth seller credential platform: ${String(processorName)}`,
107222
107284
  "processorName"
@@ -110925,7 +110987,7 @@ function toAttestorError(error, platform, mailboxEmail) {
110925
110987
  const status = error.details?.status;
110926
110988
  const responseObject = asRecord(error.details?.responseObject);
110927
110989
  if (status === 429) return rateLimited(mailboxEmail, responseObject, error);
110928
- if (status === 400 && responseObject?.code === `${platform.toUpperCase()}_ICLOUD_RECEIPT_NOT_FOUND`) {
110990
+ if (status === 400 && responseObject?.code === (platform === "xmoney" ? "XMONEY_EMAIL_RECEIPT_NOT_FOUND" : `${platform.toUpperCase()}_ICLOUD_RECEIPT_NOT_FOUND`)) {
110929
110991
  return new ICloudMailCredentialError("receipt_not_found", error.message, {
110930
110992
  cause: error
110931
110993
  });
@@ -111011,7 +111073,7 @@ function resolveAttestorEnvironment(attestationServiceUrl) {
111011
111073
  }
111012
111074
  return environment;
111013
111075
  }
111014
- async function attestICloudMailSellerCredential(params, context) {
111076
+ async function uploadICloudMailSellerCredential(params, context) {
111015
111077
  const { appSpecificPassword, platform } = params;
111016
111078
  const mailboxEmail = params.mailboxEmail.trim().toLowerCase();
111017
111079
  if (!mailboxEmail) throw new exports.ValidationError("mailboxEmail is required", "mailboxEmail");
@@ -111019,11 +111081,11 @@ async function attestICloudMailSellerCredential(params, context) {
111019
111081
  throw new exports.ValidationError("appSpecificPassword is required", "appSpecificPassword");
111020
111082
  }
111021
111083
  const payeeDetails = params.payeeDetails.toLowerCase();
111022
- const payeeEmail = params.platform === "paypal" ? params.payeeEmail.trim().toLowerCase() : null;
111023
- if (payeeEmail !== null && zkp2pAttestation.hashUtf8(payeeEmail) !== payeeDetails) {
111084
+ const suppliedPayeeId = params.platform === "paypal" ? params.payeeEmail.trim().toLowerCase() : params.platform === "xmoney" ? params.payeeUsername.trim().replace(/^@/u, "").toLowerCase() : null;
111085
+ if (suppliedPayeeId !== null && zkp2pAttestation.hashUtf8(suppliedPayeeId) !== payeeDetails) {
111024
111086
  throw new ICloudMailCredentialError(
111025
111087
  "payee_mismatch",
111026
- "The PayPal email does not match the registered maker"
111088
+ params.platform === "paypal" ? "The PayPal email does not match the registered maker" : "The X username does not match the registered maker"
111027
111089
  );
111028
111090
  }
111029
111091
  const retryAt = mailboxRetryAt.get(mailboxEmail);
@@ -111038,7 +111100,7 @@ async function attestICloudMailSellerCredential(params, context) {
111038
111100
  const environment = resolveAttestorEnvironment(context.attestationServiceUrl);
111039
111101
  mailboxesInFlight.add(mailboxEmail);
111040
111102
  try {
111041
- const payeeId = payeeEmail ?? await resolveVenmoPayeeId(payeeDetails, mailboxEmail, context);
111103
+ const payeeId = suppliedPayeeId ?? await resolveVenmoPayeeId(payeeDetails, mailboxEmail, context);
111042
111104
  let bundle;
111043
111105
  try {
111044
111106
  const nitro = zkp2pAttestation.createNitroAttestationClient({
@@ -111074,39 +111136,33 @@ async function attestICloudMailSellerCredential(params, context) {
111074
111136
  `Attestor returned credential type ${bundle.credentialType}`
111075
111137
  );
111076
111138
  }
111077
- return bundle;
111139
+ let stored;
111140
+ try {
111141
+ const response = await apiUploadSellerCredential(
111142
+ platform,
111143
+ payeeDetails,
111144
+ bundle,
111145
+ context.baseApiUrl,
111146
+ context.timeoutMs,
111147
+ context.authorizationToken,
111148
+ // Send once: a 429 or lost response returns to the user, who retries.
111149
+ 1
111150
+ );
111151
+ stored = response.success ? response.responseObject : null;
111152
+ } catch (error) {
111153
+ throw toCuratorError(error, mailboxEmail);
111154
+ }
111155
+ if (stored?.status !== "active" || stored.credentialType !== "icloud_mail" || stored.platform !== platform || stored.payeeIdHash.toLowerCase() !== payeeDetails) {
111156
+ throw new ICloudMailCredentialError(
111157
+ "store_failed",
111158
+ "Curator did not store an active iCloud credential"
111159
+ );
111160
+ }
111161
+ return stored;
111078
111162
  } finally {
111079
111163
  mailboxesInFlight.delete(mailboxEmail);
111080
111164
  }
111081
111165
  }
111082
- async function uploadICloudMailSellerCredential(params, context) {
111083
- const bundle = await attestICloudMailSellerCredential(params, context);
111084
- const { platform } = params;
111085
- const payeeDetails = params.payeeDetails.toLowerCase();
111086
- let stored;
111087
- try {
111088
- const response = await apiUploadSellerCredential(
111089
- platform,
111090
- payeeDetails,
111091
- bundle,
111092
- context.baseApiUrl,
111093
- context.timeoutMs,
111094
- context.authorizationToken,
111095
- // Send once: a 429 or lost response returns to the user, who retries.
111096
- 1
111097
- );
111098
- stored = response.success ? response.responseObject : null;
111099
- } catch (error) {
111100
- throw toCuratorError(error, params.mailboxEmail.trim().toLowerCase());
111101
- }
111102
- if (stored?.status !== "active" || stored.credentialType !== "icloud_mail" || stored.platform !== platform || stored.payeeIdHash.toLowerCase() !== payeeDetails) {
111103
- throw new ICloudMailCredentialError(
111104
- "store_failed",
111105
- "Curator did not store an active iCloud credential"
111106
- );
111107
- }
111108
- return stored;
111109
- }
111110
111166
 
111111
111167
  // src/sellerCredentials.ts
111112
111168
  init_define_ZKP2P_SDK_BUILD_METADATA();
@@ -114367,7 +114423,7 @@ var Zkp2pClient = class {
114367
114423
  const providerName = params.provider === "google" ? "Google" : "Microsoft";
114368
114424
  if (opts?.signal?.aborted) throw new Error(`${providerName} OAuth upload cancelled.`);
114369
114425
  const platform = params.platform;
114370
- if (platform !== "paypal" && platform !== "venmo") {
114426
+ if (platform !== "paypal" && platform !== "venmo" && platform !== "xmoney") {
114371
114427
  throw new exports.ValidationError(
114372
114428
  `Unsupported ${providerName} OAuth seller credential platform: ${String(platform)}`,
114373
114429
  "platform"
@@ -114403,7 +114459,7 @@ var Zkp2pClient = class {
114403
114459
  );
114404
114460
  }
114405
114461
  /**
114406
- * Connect an iCloud Mail receipt inbox for PayPal or Venmo seller automated
114462
+ * Connect an iCloud Mail receipt inbox for PayPal, Venmo or X Money seller automated
114407
114463
  * release. The app-specific password is encrypted to the attested enclave and
114408
114464
  * posted directly to the attestor (no proxy, no retry). The returned bundle is
114409
114465
  * verified against the pinned enclave signer, platform and registered maker,
@@ -114415,34 +114471,18 @@ var Zkp2pClient = class {
114415
114471
  * delay. The attestor defaults to the one paired with `baseApiUrl`.
114416
114472
  */
114417
114473
  async uploadICloudMailSellerCredential(params, opts) {
114418
- return uploadICloudMailSellerCredential(params, {
114419
- ...this.iCloudMailAttestContext(opts),
114420
- authorizationToken: await this.resolveAuthorizationToken()
114421
- });
114422
- }
114423
- /**
114424
- * Run the checks, enclave upload and bundle verification of
114425
- * `uploadICloudMailSellerCredential` and return the verified bundle without
114426
- * storing it, for callers that store it through another Curator route. Needs
114427
- * no Curator session; Venmo still fetches the maker's account ID from
114428
- * `baseApiUrl`. Rejects with the same `ICloudMailCredentialError` reasons,
114429
- * mailbox lock and rate-limit delay.
114430
- */
114431
- async attestICloudMailSellerCredential(params, opts) {
114432
- return attestICloudMailSellerCredential(params, this.iCloudMailAttestContext(opts));
114433
- }
114434
- iCloudMailAttestContext(opts) {
114435
114474
  const baseApiUrl = this.stripTrailingSlash(
114436
114475
  opts?.baseApiUrl ?? this.baseApiUrl ?? DEFAULT_BASE_API_URL
114437
114476
  );
114438
- return {
114477
+ return uploadICloudMailSellerCredential(params, {
114439
114478
  attestationServiceUrl: this.stripTrailingSlash(
114440
114479
  opts?.attestationServiceUrl ?? this.defaultAttestationServiceForBaseApiUrl(baseApiUrl)
114441
114480
  ),
114442
114481
  attestationRuntime: opts?.attestationRuntime,
114443
114482
  baseApiUrl,
114444
- timeoutMs: this.apiTimeoutMs
114445
- };
114483
+ timeoutMs: this.apiTimeoutMs,
114484
+ authorizationToken: await this.resolveAuthorizationToken()
114485
+ });
114446
114486
  }
114447
114487
  /**
114448
114488
  * Status is a coarse curator-owned signal (`active` / `inactive` / `missing`) and intentionally
@@ -114982,7 +115022,6 @@ exports.apiVerifyBuyerTeePayment = apiVerifyBuyerTeePayment;
114982
115022
  exports.appendAttributionToCalldata = appendAttributionToCalldata;
114983
115023
  exports.asciiToBytes32 = asciiToBytes32;
114984
115024
  exports.assertValidReferrerFeeConfig = assertValidReferrerFeeConfig;
114985
- exports.attestICloudMailSellerCredential = attestICloudMailSellerCredential;
114986
115025
  exports.buildStakingEntityIds = buildStakingEntityIds;
114987
115026
  exports.calculateRequiredCoverage = calculateRequiredCoverage;
114988
115027
  exports.calculateStakeBackedCapacity = calculateStakeBackedCapacity;