@zkp2p/sdk 0.14.8 → 0.14.10

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.
@@ -1,4 +1,4 @@
1
1
  export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchain, mapConversionRatesToOnchainMinRate } from './chunk-WDEEWFEU.mjs';
2
- import './chunk-HG27KAGT.mjs';
3
- //# sourceMappingURL=currency-ELLII4P5.mjs.map
4
- //# sourceMappingURL=currency-ELLII4P5.mjs.map
2
+ import './chunk-DIHRDN2W.mjs';
3
+ //# sourceMappingURL=currency-74LZHM6Q.mjs.map
4
+ //# sourceMappingURL=currency-74LZHM6Q.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"currency-ELLII4P5.mjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"currency-74LZHM6Q.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: "46efc268b38382bdd6c66bbd7fd9b91f9368a79d", kind: "github", distributable: true }, sdkPackageVersion: "0.14.8", 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: "561ca15adeac3e97e582647c818656e69289020d", kind: "github", distributable: true }, sdkPackageVersion: "0.14.10", 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
 
@@ -102300,8 +102300,9 @@ var usdcUnits = (amount) => {
102300
102300
  return viem.parseUnits(amount.toString(), 6);
102301
102301
  };
102302
102302
  ({
102303
- singleOrderDeposit: {
102304
- minDeposit: usdcUnits(10)}});
102303
+ orderCapDeposit: {
102304
+ minOrder: usdcUnits(5),
102305
+ maxOrder: usdcUnits(500)}});
102305
102306
  var DISPUTE_PROTECTION_STAKE_PLATFORMS = [
102306
102307
  PaymentPlatform.VENMO,
102307
102308
  PaymentPlatform.PAYPAL
@@ -107277,7 +107278,7 @@ async function apiUploadMicrosoftOAuthSellerCredential(processorName, payeeDetai
107277
107278
  }
107278
107279
  async function apiUploadEmailOAuthSellerCredential(provider, processorName, payeeDetails, body, baseApiUrl, opts) {
107279
107280
  const providerName = provider === "google" ? "Google" : "Microsoft";
107280
- if (processorName !== "paypal" && processorName !== "venmo") {
107281
+ if (processorName !== "paypal" && processorName !== "venmo" && processorName !== "xmoney") {
107281
107282
  throw new exports.ValidationError(
107282
107283
  `Unsupported ${providerName} OAuth seller credential platform: ${String(processorName)}`,
107283
107284
  "processorName"
@@ -110409,15 +110410,15 @@ var DisputeProtectionReadinessReader = class {
110409
110410
  async verifyRuntimeIdentities(names, blockNumber) {
110410
110411
  await Promise.all(
110411
110412
  names.map(async (name) => {
110412
- const identity = this.config.manifest.runtimeIdentities[name];
110413
+ const identity2 = this.config.manifest.runtimeIdentities[name];
110413
110414
  const bytecode = await this.config.publicClient.getBytecode({
110414
- address: identity.address,
110415
+ address: identity2.address,
110415
110416
  blockNumber
110416
110417
  });
110417
110418
  if (!bytecode || bytecode === "0x") {
110418
110419
  throw new ReadinessMismatch(`${name} runtime bytecode unavailable`);
110419
110420
  }
110420
- if (viem.keccak256(bytecode).toLowerCase() !== identity.runtimeCodeHash.toLowerCase()) {
110421
+ if (viem.keccak256(bytecode).toLowerCase() !== identity2.runtimeCodeHash.toLowerCase()) {
110421
110422
  throw new ReadinessMismatch(`${name} runtime code hash mismatch`);
110422
110423
  }
110423
110424
  })
@@ -110986,7 +110987,7 @@ function toAttestorError(error, platform, mailboxEmail) {
110986
110987
  const status = error.details?.status;
110987
110988
  const responseObject = asRecord(error.details?.responseObject);
110988
110989
  if (status === 429) return rateLimited(mailboxEmail, responseObject, error);
110989
- 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`)) {
110990
110991
  return new ICloudMailCredentialError("receipt_not_found", error.message, {
110991
110992
  cause: error
110992
110993
  });
@@ -111080,11 +111081,11 @@ async function uploadICloudMailSellerCredential(params, context) {
111080
111081
  throw new exports.ValidationError("appSpecificPassword is required", "appSpecificPassword");
111081
111082
  }
111082
111083
  const payeeDetails = params.payeeDetails.toLowerCase();
111083
- const payeeEmail = params.platform === "paypal" ? params.payeeEmail.trim().toLowerCase() : null;
111084
- 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) {
111085
111086
  throw new ICloudMailCredentialError(
111086
111087
  "payee_mismatch",
111087
- "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"
111088
111089
  );
111089
111090
  }
111090
111091
  const retryAt = mailboxRetryAt.get(mailboxEmail);
@@ -111099,7 +111100,7 @@ async function uploadICloudMailSellerCredential(params, context) {
111099
111100
  const environment = resolveAttestorEnvironment(context.attestationServiceUrl);
111100
111101
  mailboxesInFlight.add(mailboxEmail);
111101
111102
  try {
111102
- const payeeId = payeeEmail ?? await resolveVenmoPayeeId(payeeDetails, mailboxEmail, context);
111103
+ const payeeId = suppliedPayeeId ?? await resolveVenmoPayeeId(payeeDetails, mailboxEmail, context);
111103
111104
  let bundle;
111104
111105
  try {
111105
111106
  const nitro = zkp2pAttestation.createNitroAttestationClient({
@@ -114422,7 +114423,7 @@ var Zkp2pClient = class {
114422
114423
  const providerName = params.provider === "google" ? "Google" : "Microsoft";
114423
114424
  if (opts?.signal?.aborted) throw new Error(`${providerName} OAuth upload cancelled.`);
114424
114425
  const platform = params.platform;
114425
- if (platform !== "paypal" && platform !== "venmo") {
114426
+ if (platform !== "paypal" && platform !== "venmo" && platform !== "xmoney") {
114426
114427
  throw new exports.ValidationError(
114427
114428
  `Unsupported ${providerName} OAuth seller credential platform: ${String(platform)}`,
114428
114429
  "platform"
@@ -114458,7 +114459,7 @@ var Zkp2pClient = class {
114458
114459
  );
114459
114460
  }
114460
114461
  /**
114461
- * 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
114462
114463
  * release. The app-specific password is encrypted to the attested enclave and
114463
114464
  * posted directly to the attestor (no proxy, no retry). The returned bundle is
114464
114465
  * verified against the pinned enclave signer, platform and registered maker,
@@ -114781,6 +114782,9 @@ var getDelegationRoute = (_client, _escrow) => "v2";
114781
114782
 
114782
114783
  // src/venmoGmail.ts
114783
114784
  init_define_ZKP2P_SDK_BUILD_METADATA();
114785
+
114786
+ // src/mailboxConnect.ts
114787
+ init_define_ZKP2P_SDK_BUILD_METADATA();
114784
114788
  init_errors();
114785
114789
 
114786
114790
  // src/venmoGmailAppearance.ts
@@ -114852,22 +114856,18 @@ function getVenmoGmailPopupSize(popup = {}) {
114852
114856
  return { width, height };
114853
114857
  }
114854
114858
 
114855
- // src/venmoGmail.ts
114856
- var VenmoGmailConnectError = class extends Error {
114857
- constructor(code, message) {
114858
- super(message);
114859
- this.code = code;
114860
- this.name = "VenmoGmailConnectError";
114861
- }
114862
- };
114863
- function getVenmoGmailConnectUrl({
114859
+ // src/mailboxConnect.ts
114860
+ function getMailboxConnectUrl({
114864
114861
  payeeDetails,
114862
+ platform,
114863
+ label,
114864
+ payeeUsername,
114865
114865
  peerOrigin = "https://app.peer.xyz",
114866
114866
  appearance,
114867
114867
  returnUrl
114868
114868
  }) {
114869
114869
  if (!/^0x[0-9a-f]{64}$/i.test(payeeDetails)) {
114870
- throw new exports.ValidationError("Expected a Venmo payee hash", "payeeDetails");
114870
+ throw new exports.ValidationError(`Expected a ${label} payee hash`, "payeeDetails");
114871
114871
  }
114872
114872
  let origin;
114873
114873
  try {
@@ -114878,7 +114878,7 @@ function getVenmoGmailConnectUrl({
114878
114878
  if (origin.protocol !== "https:" && !(origin.protocol === "http:" && origin.hostname === "localhost") || origin.pathname !== "/" || origin.search || origin.hash || origin.username || origin.password) {
114879
114879
  throw new exports.ValidationError("Expected an HTTPS Peer web origin", "peerOrigin");
114880
114880
  }
114881
- const url = new URL("/connect/venmo", origin);
114881
+ const url = new URL(`/connect/${platform}`, origin);
114882
114882
  if (returnUrl) {
114883
114883
  try {
114884
114884
  new URL(returnUrl);
@@ -114889,11 +114889,11 @@ function getVenmoGmailConnectUrl({
114889
114889
  }
114890
114890
  if (appearance)
114891
114891
  url.searchParams.set("appearance", JSON.stringify(parseVenmoGmailAppearance(appearance)));
114892
- url.hash = payeeDetails;
114892
+ url.hash = payeeUsername === void 0 ? payeeDetails : new URLSearchParams({ payeeDetails, payeeUsername }).toString();
114893
114893
  return url.toString();
114894
114894
  }
114895
- function openVenmoGmailConnect(options) {
114896
- const url = new URL(getVenmoGmailConnectUrl(options));
114895
+ function openMailboxConnect(options) {
114896
+ const url = new URL(getMailboxConnectUrl(options));
114897
114897
  const { width, height } = getVenmoGmailPopupSize(options.popup);
114898
114898
  const requestId = window.crypto.randomUUID();
114899
114899
  url.searchParams.set("requestId", requestId);
@@ -114908,9 +114908,9 @@ function openVenmoGmailConnect(options) {
114908
114908
  }
114909
114909
  if (!popup) {
114910
114910
  reject(
114911
- new VenmoGmailConnectError(
114911
+ new options.ErrorClass(
114912
114912
  "popup_blocked",
114913
- "Allow popups for this site, then link Venmo again."
114913
+ `Allow popups for this site, then link ${options.label} again.`
114914
114914
  )
114915
114915
  );
114916
114916
  return;
@@ -114927,18 +114927,19 @@ function openVenmoGmailConnect(options) {
114927
114927
  const data150 = event.data;
114928
114928
  if (typeof data150 !== "object" || !data150) return;
114929
114929
  const result = data150;
114930
- if (result.type !== "peer:venmo-connect" || result.requestId !== requestId) return;
114930
+ if (result.type !== `peer:${options.platform}-connect` || result.requestId !== requestId)
114931
+ return;
114931
114932
  if (result.status === "connected" && typeof result.payeeDetails === "string" && result.payeeDetails.toLowerCase() === options.payeeDetails.toLowerCase()) {
114932
114933
  finish();
114933
114934
  } else if (result.status === "error" && typeof result.code === "string" && typeof result.message === "string") {
114934
- finish(new VenmoGmailConnectError(result.code, result.message));
114935
+ finish(new options.ErrorClass(result.code, result.message));
114935
114936
  }
114936
114937
  };
114937
114938
  const timeout = window.setTimeout(
114938
114939
  () => finish(
114939
- new VenmoGmailConnectError(
114940
+ new options.ErrorClass(
114940
114941
  "connection_timeout",
114941
- "Venmo linking timed out. Check the connection status before trying again."
114942
+ `${options.label} linking timed out. Check the connection status before trying again.`
114942
114943
  )
114943
114944
  ),
114944
114945
  10 * 60 * 1e3
@@ -114946,7 +114947,7 @@ function openVenmoGmailConnect(options) {
114946
114947
  const closedCheck = window.setInterval(() => {
114947
114948
  if (popup.closed)
114948
114949
  finish(
114949
- new VenmoGmailConnectError(
114950
+ new options.ErrorClass(
114950
114951
  "connection_closed",
114951
114952
  "The linking window closed or became unavailable. Check the connection status before trying again."
114952
114953
  )
@@ -114956,6 +114957,54 @@ function openVenmoGmailConnect(options) {
114956
114957
  });
114957
114958
  }
114958
114959
 
114960
+ // src/venmoGmail.ts
114961
+ var VenmoGmailConnectError = class extends Error {
114962
+ constructor(code, message) {
114963
+ super(message);
114964
+ this.code = code;
114965
+ this.name = "VenmoGmailConnectError";
114966
+ }
114967
+ };
114968
+ function getVenmoGmailConnectUrl(options) {
114969
+ return getMailboxConnectUrl({ ...options, platform: "venmo", label: "Venmo" });
114970
+ }
114971
+ function openVenmoGmailConnect(options) {
114972
+ return openMailboxConnect({
114973
+ ...options,
114974
+ platform: "venmo",
114975
+ label: "Venmo",
114976
+ ErrorClass: VenmoGmailConnectError
114977
+ });
114978
+ }
114979
+
114980
+ // src/xMoneyConnect.ts
114981
+ init_define_ZKP2P_SDK_BUILD_METADATA();
114982
+ init_errors();
114983
+ var XMoneyConnectError = class extends Error {
114984
+ constructor(code, message) {
114985
+ super(message);
114986
+ this.code = code;
114987
+ this.name = "XMoneyConnectError";
114988
+ }
114989
+ };
114990
+ function identity(options) {
114991
+ const payeeUsername = options.payeeUsername.trim().replace(/^@/u, "").toLowerCase();
114992
+ if (!payeeUsername || viem.keccak256(viem.stringToBytes(payeeUsername)) !== options.payeeDetails.toLowerCase()) {
114993
+ throw new exports.ValidationError("X username must match the registered payee hash", "payeeUsername");
114994
+ }
114995
+ return { ...options, payeeUsername, platform: "xmoney", label: "X Money" };
114996
+ }
114997
+ function getXMoneyConnectUrl(options) {
114998
+ return getMailboxConnectUrl(identity(options));
114999
+ }
115000
+ function openXMoneyConnect(options) {
115001
+ return openMailboxConnect({
115002
+ ...identity(options),
115003
+ popup: options.popup,
115004
+ ErrorClass: XMoneyConnectError
115005
+ });
115006
+ }
115007
+
114959
115008
  Object.defineProperty(exports, "createNitroAttestationClient", {
114960
115009
  enumerable: true,
114961
115010
  get: function () { return zkp2pAttestation.createNitroAttestationClient; }
@@ -114990,6 +115039,7 @@ exports.SPREAD_ORACLE_FEEDS = SPREAD_ORACLE_FEEDS;
114990
115039
  exports.SUPPORTED_CHAIN_IDS = SUPPORTED_CHAIN_IDS;
114991
115040
  exports.TOKEN_METADATA = TOKEN_METADATA;
114992
115041
  exports.VenmoGmailConnectError = VenmoGmailConnectError;
115042
+ exports.XMoneyConnectError = XMoneyConnectError;
114993
115043
  exports.ZERO_RATE_MANAGER_ID = ZERO_RATE_MANAGER_ID;
114994
115044
  exports.ZKP2P_ANDROID_REFERRER = ZKP2P_ANDROID_REFERRER;
114995
115045
  exports.ZKP2P_IOS_REFERRER = ZKP2P_IOS_REFERRER;
@@ -115058,6 +115108,7 @@ exports.getRateManagerContracts = getRateManagerContracts;
115058
115108
  exports.getSpreadOracleConfig = getSpreadOracleConfig;
115059
115109
  exports.getStakeVaultContract = getStakeVaultContract;
115060
115110
  exports.getVenmoGmailConnectUrl = getVenmoGmailConnectUrl;
115111
+ exports.getXMoneyConnectUrl = getXMoneyConnectUrl;
115061
115112
  exports.hasIntentGuardian = hasIntentGuardian;
115062
115113
  exports.isMailboxSellerCredentialType = isMailboxSellerCredentialType;
115063
115114
  exports.isPeerExtensionAvailable = isPeerExtensionAvailable;
@@ -115073,6 +115124,7 @@ exports.normalizeReferralCode = normalizeReferralCode;
115073
115124
  exports.normalizeRegistry = normalizeRegistry;
115074
115125
  exports.openPeerExtensionInstallPage = openPeerExtensionInstallPage;
115075
115126
  exports.openVenmoGmailConnect = openVenmoGmailConnect;
115127
+ exports.openXMoneyConnect = openXMoneyConnect;
115076
115128
  exports.parseDepositView = parseDepositView;
115077
115129
  exports.parseIntentView = parseIntentView;
115078
115130
  exports.parseReferrerFeeConfig = parseReferrerFeeConfig;