@zkp2p/sdk 0.14.9 → 0.14.11-rc.0

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-ERJIIFAV.mjs';
3
- //# sourceMappingURL=currency-AGVR2YDU.mjs.map
4
- //# sourceMappingURL=currency-AGVR2YDU.mjs.map
2
+ import './chunk-IYYNDUDP.mjs';
3
+ //# sourceMappingURL=currency-224A3JT3.mjs.map
4
+ //# sourceMappingURL=currency-224A3JT3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"currency-AGVR2YDU.mjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"currency-224A3JT3.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: "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" } } };
24
+ define_ZKP2P_SDK_BUILD_METADATA_default = { schemaVersion: 2, source: { repository: "zkp2p/zkp2p-clients", commitSha: "26dc03c06a65c8c09395cb30fc341aa20f550bf9", kind: "github", distributable: true }, sdkPackageVersion: "0.14.11-rc.0", 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
 
@@ -102767,7 +102767,10 @@ init_errors();
102767
102767
 
102768
102768
  // src/adapters/attestationTransport.ts
102769
102769
  init_define_ZKP2P_SDK_BUILD_METADATA();
102770
- var DEFAULT_ATTESTATION_PROXY_URL = "https://attestation-service-proxy.up.railway.app";
102770
+ var ATTESTATION_PROXY_URLS = {
102771
+ "https://attestation-service.zkp2p.xyz": "https://attestation-proxy.zkp2p.xyz",
102772
+ "https://attestation-service-staging.zkp2p.xyz": "https://api-staging.zkp2p.xyz/attestation"
102773
+ };
102771
102774
  function normalizeOptionalString(value) {
102772
102775
  if (typeof value !== "string") {
102773
102776
  return null;
@@ -102783,7 +102786,8 @@ function normalizeAttestationBaseUrl(value, label) {
102783
102786
  return normalized;
102784
102787
  }
102785
102788
  function resolveFallbackUrls(primaryBaseUrl, fallbackUrls) {
102786
- const rawFallbackUrls = fallbackUrls == null ? [DEFAULT_ATTESTATION_PROXY_URL] : fallbackUrls;
102789
+ const proxyUrl = ATTESTATION_PROXY_URLS[primaryBaseUrl];
102790
+ const rawFallbackUrls = fallbackUrls ?? (proxyUrl ? [proxyUrl] : []);
102787
102791
  const normalized = rawFallbackUrls.map((url) => normalizeOptionalString(url)?.replace(/\/+$/u, "") ?? null).filter((url) => Boolean(url));
102788
102792
  return Array.from(new Set(normalized)).filter((url) => url !== primaryBaseUrl);
102789
102793
  }
@@ -102819,6 +102823,7 @@ function rewriteInputBaseUrl(input, primaryBaseUrl, targetBaseUrl) {
102819
102823
  if (url.origin === primaryUrl.origin) {
102820
102824
  url.protocol = targetUrl.protocol;
102821
102825
  url.host = targetUrl.host;
102826
+ url.pathname = `${targetUrl.pathname.replace(/\/$/u, "")}${url.pathname}`;
102822
102827
  }
102823
102828
  if (typeof Request !== "undefined" && input instanceof Request) {
102824
102829
  return new Request(url.toString(), input.clone());
@@ -110410,15 +110415,15 @@ var DisputeProtectionReadinessReader = class {
110410
110415
  async verifyRuntimeIdentities(names, blockNumber) {
110411
110416
  await Promise.all(
110412
110417
  names.map(async (name) => {
110413
- const identity = this.config.manifest.runtimeIdentities[name];
110418
+ const identity2 = this.config.manifest.runtimeIdentities[name];
110414
110419
  const bytecode = await this.config.publicClient.getBytecode({
110415
- address: identity.address,
110420
+ address: identity2.address,
110416
110421
  blockNumber
110417
110422
  });
110418
110423
  if (!bytecode || bytecode === "0x") {
110419
110424
  throw new ReadinessMismatch(`${name} runtime bytecode unavailable`);
110420
110425
  }
110421
- if (viem.keccak256(bytecode).toLowerCase() !== identity.runtimeCodeHash.toLowerCase()) {
110426
+ if (viem.keccak256(bytecode).toLowerCase() !== identity2.runtimeCodeHash.toLowerCase()) {
110422
110427
  throw new ReadinessMismatch(`${name} runtime code hash mismatch`);
110423
110428
  }
110424
110429
  })
@@ -111103,11 +111108,15 @@ async function uploadICloudMailSellerCredential(params, context) {
111103
111108
  const payeeId = suppliedPayeeId ?? await resolveVenmoPayeeId(payeeDetails, mailboxEmail, context);
111104
111109
  let bundle;
111105
111110
  try {
111111
+ const attestationTransport = createAttestationTransport(context.attestationServiceUrl, {
111112
+ fetch: context.attestationRuntime?.fetch
111113
+ });
111106
111114
  const nitro = zkp2pAttestation.createNitroAttestationClient({
111107
111115
  environment,
111108
111116
  attestationServiceUrl: context.attestationServiceUrl,
111109
111117
  timeoutMs: ATTESTOR_TIMEOUT_MS,
111110
- ...context.attestationRuntime
111118
+ ...context.attestationRuntime,
111119
+ fetch: attestationTransport.fetch
111111
111120
  });
111112
111121
  bundle = await nitro.uploadSellerCredential({
111113
111122
  platform,
@@ -114461,9 +114470,11 @@ var Zkp2pClient = class {
114461
114470
  /**
114462
114471
  * Connect an iCloud Mail receipt inbox for PayPal, Venmo or X Money seller automated
114463
114472
  * release. The app-specific password is encrypted to the attested enclave and
114464
- * posted directly to the attestor (no proxy, no retry). The returned bundle is
114465
- * verified against the pinned enclave signer, platform and registered maker,
114466
- * then stored unchanged for that maker; the maker is not re-registered.
114473
+ * posted to the attestor. A request that fails at the network layer is sent
114474
+ * once through that attestor's proxy; nothing else is retried. The returned
114475
+ * bundle is verified against the pinned enclave signer, platform and
114476
+ * registered maker, then stored unchanged for that maker; the maker is not
114477
+ * re-registered.
114467
114478
  *
114468
114479
  * Rejects with `ICloudMailCredentialError` (`reason` names the failure)
114469
114480
  * before any mailbox work when the payee does not hash to `payeeDetails`,
@@ -114782,6 +114793,9 @@ var getDelegationRoute = (_client, _escrow) => "v2";
114782
114793
 
114783
114794
  // src/venmoGmail.ts
114784
114795
  init_define_ZKP2P_SDK_BUILD_METADATA();
114796
+
114797
+ // src/mailboxConnect.ts
114798
+ init_define_ZKP2P_SDK_BUILD_METADATA();
114785
114799
  init_errors();
114786
114800
 
114787
114801
  // src/venmoGmailAppearance.ts
@@ -114853,22 +114867,18 @@ function getVenmoGmailPopupSize(popup = {}) {
114853
114867
  return { width, height };
114854
114868
  }
114855
114869
 
114856
- // src/venmoGmail.ts
114857
- var VenmoGmailConnectError = class extends Error {
114858
- constructor(code, message) {
114859
- super(message);
114860
- this.code = code;
114861
- this.name = "VenmoGmailConnectError";
114862
- }
114863
- };
114864
- function getVenmoGmailConnectUrl({
114870
+ // src/mailboxConnect.ts
114871
+ function getMailboxConnectUrl({
114865
114872
  payeeDetails,
114873
+ platform,
114874
+ label,
114875
+ payeeUsername,
114866
114876
  peerOrigin = "https://app.peer.xyz",
114867
114877
  appearance,
114868
114878
  returnUrl
114869
114879
  }) {
114870
114880
  if (!/^0x[0-9a-f]{64}$/i.test(payeeDetails)) {
114871
- throw new exports.ValidationError("Expected a Venmo payee hash", "payeeDetails");
114881
+ throw new exports.ValidationError(`Expected a ${label} payee hash`, "payeeDetails");
114872
114882
  }
114873
114883
  let origin;
114874
114884
  try {
@@ -114879,7 +114889,7 @@ function getVenmoGmailConnectUrl({
114879
114889
  if (origin.protocol !== "https:" && !(origin.protocol === "http:" && origin.hostname === "localhost") || origin.pathname !== "/" || origin.search || origin.hash || origin.username || origin.password) {
114880
114890
  throw new exports.ValidationError("Expected an HTTPS Peer web origin", "peerOrigin");
114881
114891
  }
114882
- const url = new URL("/connect/venmo", origin);
114892
+ const url = new URL(`/connect/${platform}`, origin);
114883
114893
  if (returnUrl) {
114884
114894
  try {
114885
114895
  new URL(returnUrl);
@@ -114890,11 +114900,11 @@ function getVenmoGmailConnectUrl({
114890
114900
  }
114891
114901
  if (appearance)
114892
114902
  url.searchParams.set("appearance", JSON.stringify(parseVenmoGmailAppearance(appearance)));
114893
- url.hash = payeeDetails;
114903
+ url.hash = payeeUsername === void 0 ? payeeDetails : new URLSearchParams({ payeeDetails, payeeUsername }).toString();
114894
114904
  return url.toString();
114895
114905
  }
114896
- function openVenmoGmailConnect(options) {
114897
- const url = new URL(getVenmoGmailConnectUrl(options));
114906
+ function openMailboxConnect(options) {
114907
+ const url = new URL(getMailboxConnectUrl(options));
114898
114908
  const { width, height } = getVenmoGmailPopupSize(options.popup);
114899
114909
  const requestId = window.crypto.randomUUID();
114900
114910
  url.searchParams.set("requestId", requestId);
@@ -114909,9 +114919,9 @@ function openVenmoGmailConnect(options) {
114909
114919
  }
114910
114920
  if (!popup) {
114911
114921
  reject(
114912
- new VenmoGmailConnectError(
114922
+ new options.ErrorClass(
114913
114923
  "popup_blocked",
114914
- "Allow popups for this site, then link Venmo again."
114924
+ `Allow popups for this site, then link ${options.label} again.`
114915
114925
  )
114916
114926
  );
114917
114927
  return;
@@ -114928,18 +114938,19 @@ function openVenmoGmailConnect(options) {
114928
114938
  const data150 = event.data;
114929
114939
  if (typeof data150 !== "object" || !data150) return;
114930
114940
  const result = data150;
114931
- if (result.type !== "peer:venmo-connect" || result.requestId !== requestId) return;
114941
+ if (result.type !== `peer:${options.platform}-connect` || result.requestId !== requestId)
114942
+ return;
114932
114943
  if (result.status === "connected" && typeof result.payeeDetails === "string" && result.payeeDetails.toLowerCase() === options.payeeDetails.toLowerCase()) {
114933
114944
  finish();
114934
114945
  } else if (result.status === "error" && typeof result.code === "string" && typeof result.message === "string") {
114935
- finish(new VenmoGmailConnectError(result.code, result.message));
114946
+ finish(new options.ErrorClass(result.code, result.message));
114936
114947
  }
114937
114948
  };
114938
114949
  const timeout = window.setTimeout(
114939
114950
  () => finish(
114940
- new VenmoGmailConnectError(
114951
+ new options.ErrorClass(
114941
114952
  "connection_timeout",
114942
- "Venmo linking timed out. Check the connection status before trying again."
114953
+ `${options.label} linking timed out. Check the connection status before trying again.`
114943
114954
  )
114944
114955
  ),
114945
114956
  10 * 60 * 1e3
@@ -114947,7 +114958,7 @@ function openVenmoGmailConnect(options) {
114947
114958
  const closedCheck = window.setInterval(() => {
114948
114959
  if (popup.closed)
114949
114960
  finish(
114950
- new VenmoGmailConnectError(
114961
+ new options.ErrorClass(
114951
114962
  "connection_closed",
114952
114963
  "The linking window closed or became unavailable. Check the connection status before trying again."
114953
114964
  )
@@ -114957,6 +114968,54 @@ function openVenmoGmailConnect(options) {
114957
114968
  });
114958
114969
  }
114959
114970
 
114971
+ // src/venmoGmail.ts
114972
+ var VenmoGmailConnectError = class extends Error {
114973
+ constructor(code, message) {
114974
+ super(message);
114975
+ this.code = code;
114976
+ this.name = "VenmoGmailConnectError";
114977
+ }
114978
+ };
114979
+ function getVenmoGmailConnectUrl(options) {
114980
+ return getMailboxConnectUrl({ ...options, platform: "venmo", label: "Venmo" });
114981
+ }
114982
+ function openVenmoGmailConnect(options) {
114983
+ return openMailboxConnect({
114984
+ ...options,
114985
+ platform: "venmo",
114986
+ label: "Venmo",
114987
+ ErrorClass: VenmoGmailConnectError
114988
+ });
114989
+ }
114990
+
114991
+ // src/xMoneyConnect.ts
114992
+ init_define_ZKP2P_SDK_BUILD_METADATA();
114993
+ init_errors();
114994
+ var XMoneyConnectError = class extends Error {
114995
+ constructor(code, message) {
114996
+ super(message);
114997
+ this.code = code;
114998
+ this.name = "XMoneyConnectError";
114999
+ }
115000
+ };
115001
+ function identity(options) {
115002
+ const payeeUsername = options.payeeUsername.trim().replace(/^@/u, "").toLowerCase();
115003
+ if (!payeeUsername || viem.keccak256(viem.stringToBytes(payeeUsername)) !== options.payeeDetails.toLowerCase()) {
115004
+ throw new exports.ValidationError("X username must match the registered payee hash", "payeeUsername");
115005
+ }
115006
+ return { ...options, payeeUsername, platform: "xmoney", label: "X Money" };
115007
+ }
115008
+ function getXMoneyConnectUrl(options) {
115009
+ return getMailboxConnectUrl(identity(options));
115010
+ }
115011
+ function openXMoneyConnect(options) {
115012
+ return openMailboxConnect({
115013
+ ...identity(options),
115014
+ popup: options.popup,
115015
+ ErrorClass: XMoneyConnectError
115016
+ });
115017
+ }
115018
+
114960
115019
  Object.defineProperty(exports, "createNitroAttestationClient", {
114961
115020
  enumerable: true,
114962
115021
  get: function () { return zkp2pAttestation.createNitroAttestationClient; }
@@ -114991,6 +115050,7 @@ exports.SPREAD_ORACLE_FEEDS = SPREAD_ORACLE_FEEDS;
114991
115050
  exports.SUPPORTED_CHAIN_IDS = SUPPORTED_CHAIN_IDS;
114992
115051
  exports.TOKEN_METADATA = TOKEN_METADATA;
114993
115052
  exports.VenmoGmailConnectError = VenmoGmailConnectError;
115053
+ exports.XMoneyConnectError = XMoneyConnectError;
114994
115054
  exports.ZERO_RATE_MANAGER_ID = ZERO_RATE_MANAGER_ID;
114995
115055
  exports.ZKP2P_ANDROID_REFERRER = ZKP2P_ANDROID_REFERRER;
114996
115056
  exports.ZKP2P_IOS_REFERRER = ZKP2P_IOS_REFERRER;
@@ -115059,6 +115119,7 @@ exports.getRateManagerContracts = getRateManagerContracts;
115059
115119
  exports.getSpreadOracleConfig = getSpreadOracleConfig;
115060
115120
  exports.getStakeVaultContract = getStakeVaultContract;
115061
115121
  exports.getVenmoGmailConnectUrl = getVenmoGmailConnectUrl;
115122
+ exports.getXMoneyConnectUrl = getXMoneyConnectUrl;
115062
115123
  exports.hasIntentGuardian = hasIntentGuardian;
115063
115124
  exports.isMailboxSellerCredentialType = isMailboxSellerCredentialType;
115064
115125
  exports.isPeerExtensionAvailable = isPeerExtensionAvailable;
@@ -115074,6 +115135,7 @@ exports.normalizeReferralCode = normalizeReferralCode;
115074
115135
  exports.normalizeRegistry = normalizeRegistry;
115075
115136
  exports.openPeerExtensionInstallPage = openPeerExtensionInstallPage;
115076
115137
  exports.openVenmoGmailConnect = openVenmoGmailConnect;
115138
+ exports.openXMoneyConnect = openXMoneyConnect;
115077
115139
  exports.parseDepositView = parseDepositView;
115078
115140
  exports.parseIntentView = parseIntentView;
115079
115141
  exports.parseReferrerFeeConfig = parseReferrerFeeConfig;