@usdctofiat/offramp 4.3.1 → 4.4.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.
package/dist/index.cjs CHANGED
@@ -41,7 +41,7 @@ __export(index_exports, {
41
41
  OFFRAMP_RESOURCE_LINKS: () => OFFRAMP_RESOURCE_LINKS,
42
42
  Offramp: () => Offramp,
43
43
  OfframpError: () => OfframpError,
44
- PEER_EXTENSION_CHROME_URL: () => import_sdk7.PEER_EXTENSION_CHROME_URL,
44
+ PEER_EXTENSION_CHROME_URL: () => import_sdk8.PEER_EXTENSION_CHROME_URL,
45
45
  PLATFORMS: () => PLATFORMS,
46
46
  PLATFORM_LIMITS: () => PLATFORM_LIMITS,
47
47
  close: () => close,
@@ -54,6 +54,7 @@ __export(index_exports, {
54
54
  disableOtc: () => disableOtc,
55
55
  emitEvent: () => emitEvent,
56
56
  enableOtc: () => enableOtc,
57
+ findTakerPlatformLimit: () => findTakerPlatformLimit,
57
58
  getOfframpAgentPrompt: () => getOfframpAgentPrompt,
58
59
  getOfframpDeveloperResources: () => getOfframpDeveloperResources,
59
60
  getOtcLink: () => getOtcLink,
@@ -61,6 +62,7 @@ __export(index_exports, {
61
62
  getPeerExtensionRegistrationInfo: () => getPeerExtensionRegistrationInfo,
62
63
  getPeerExtensionState: () => getPeerExtensionState,
63
64
  getPlatformLimits: () => getPlatformLimits,
65
+ getTakerTier: () => getTakerTier,
64
66
  isPeerExtensionAvailable: () => isPeerExtensionAvailable,
65
67
  isPeerExtensionMetadataBridgeAvailable: () => isPeerExtensionMetadataBridgeAvailable,
66
68
  isPeerExtensionRegistrationError: () => isPeerExtensionRegistrationError,
@@ -68,6 +70,7 @@ __export(index_exports, {
68
70
  offramp: () => offramp,
69
71
  openPeerExtensionInstallPage: () => openPeerExtensionInstallPage,
70
72
  peerExtensionSdk: () => peerExtensionSdk,
73
+ resolveTakerPlatformLimit: () => resolveTakerPlatformLimit,
71
74
  sanitizeAttributionId: () => sanitizeAttributionId,
72
75
  sendTelemetryEvent: () => sendTelemetryEvent,
73
76
  undelegate: () => undelegate
@@ -81,7 +84,7 @@ var import_sdk5 = require("@zkp2p/sdk");
81
84
 
82
85
  // src/config.ts
83
86
  var import_sdk = require("@zkp2p/sdk");
84
- var SDK_VERSION = "4.3.0";
87
+ var SDK_VERSION = "4.4.0";
85
88
  var BASE_CHAIN_ID = 8453;
86
89
  var RUNTIME_ENV = "production";
87
90
  var API_BASE_URL = "https://api.zkp2p.xyz";
@@ -268,7 +271,12 @@ var BLUEPRINTS = {
268
271
  placeholder: "venmo username (no @)",
269
272
  helperText: "Username without @ (publicly discoverable)",
270
273
  validation: import_zod.z.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),
271
- transform: (v) => v.replace(/^@+/, "")
274
+ transform: (v) => v.replace(/^@+/, ""),
275
+ extensionRegistration: {
276
+ providerId: "venmo",
277
+ requiredPrompt: "This Venmo username is not registered yet. Register it with PeerAuth, then retry with the same Venmo username.",
278
+ ctaLabel: "Register Venmo Username"
279
+ }
272
280
  },
273
281
  cashapp: {
274
282
  id: "cashapp",
@@ -277,7 +285,12 @@ var BLUEPRINTS = {
277
285
  placeholder: "cashtag (no $)",
278
286
  helperText: "Cashtag without $ (publicly discoverable)",
279
287
  validation: import_zod.z.string().min(1).regex(/^[a-zA-Z0-9]+$/),
280
- transform: (v) => v.replace(/^\$+/, "")
288
+ transform: (v) => v.replace(/^\$+/, ""),
289
+ extensionRegistration: {
290
+ providerId: "cashapp",
291
+ requiredPrompt: "This Cash App cashtag is not registered yet. Register it with PeerAuth, then retry with the same cashtag.",
292
+ ctaLabel: "Register Cash App Cashtag"
293
+ }
281
294
  },
282
295
  chime: {
283
296
  id: "chime",
@@ -480,7 +493,7 @@ function getPeerExtensionRegistrationAuthParams(platform, options = {}) {
480
493
  }
481
494
  function resolveRegistrationProcessor(platform) {
482
495
  const info = getPeerExtensionRegistrationInfo(platform.id);
483
- if (info?.providerId === "paypal" || info?.providerId === "wise") {
496
+ if (info?.providerId === "paypal" || info?.providerId === "wise" || info?.providerId === "venmo" || info?.providerId === "cashapp") {
484
497
  return info.providerId;
485
498
  }
486
499
  throw new Error(`${platform.name} does not require Peer extension registration.`);
@@ -1608,6 +1621,42 @@ function createOfframp(options) {
1608
1621
  return new Offramp(options);
1609
1622
  }
1610
1623
 
1624
+ // src/taker-tier.ts
1625
+ var import_sdk7 = require("@zkp2p/sdk");
1626
+ async function getTakerTier({
1627
+ owner,
1628
+ chainId = BASE_CHAIN_ID,
1629
+ apiBaseUrl = API_BASE_URL,
1630
+ timeoutMs = PAYEE_REGISTRATION_TIMEOUT_MS
1631
+ }) {
1632
+ const response = await (0, import_sdk7.apiGetTakerTier)({ owner, chainId }, apiBaseUrl, timeoutMs);
1633
+ if (!response.success || !response.responseObject) {
1634
+ throw new Error(response.message || "Failed to load taker tier.");
1635
+ }
1636
+ return response.responseObject;
1637
+ }
1638
+ function findTakerPlatformLimit(tier, lookup) {
1639
+ const limits = tier?.platformLimits ?? [];
1640
+ const platform = lookup.platform?.trim().toLowerCase() || null;
1641
+ const paymentMethodHash = lookup.paymentMethodHash?.trim().toLowerCase() || null;
1642
+ if (!platform && !paymentMethodHash) return null;
1643
+ return limits.find((limit) => {
1644
+ const limitHash = limit.paymentMethodHash?.trim().toLowerCase();
1645
+ if (paymentMethodHash && limitHash === paymentMethodHash) return true;
1646
+ const limitPlatform = limit.platformName?.trim().toLowerCase();
1647
+ if (!platform || !limitPlatform) return false;
1648
+ if (limitPlatform === platform) return true;
1649
+ return platform.startsWith("zelle") && limitPlatform.startsWith("zelle");
1650
+ }) ?? null;
1651
+ }
1652
+ function resolveTakerPlatformLimit(tier, lookup) {
1653
+ if (!tier) return null;
1654
+ return {
1655
+ tier: tier.tier,
1656
+ limit: findTakerPlatformLimit(tier, lookup)
1657
+ };
1658
+ }
1659
+
1611
1660
  // src/types.ts
1612
1661
  var OFFRAMP_ERROR_CODES = {
1613
1662
  VALIDATION: "VALIDATION",
@@ -1630,7 +1679,7 @@ var OFFRAMP_ERROR_CODES = {
1630
1679
  };
1631
1680
 
1632
1681
  // src/extension.ts
1633
- var import_sdk7 = require("@zkp2p/sdk");
1682
+ var import_sdk8 = require("@zkp2p/sdk");
1634
1683
  var DEFAULT_EXTENSION_INSTALL_URL = "https://chromewebstore.google.com/detail/usdctofiat-verify/lfkmdfifolhcfjmhklmckigfngghmpdf";
1635
1684
  var resolveWindow = (options) => {
1636
1685
  if (options?.window) {
@@ -1687,7 +1736,7 @@ var getPeerExtensionState = async (options) => {
1687
1736
  }
1688
1737
  };
1689
1738
  var createPeerExtensionSdk = (options = {}) => {
1690
- const sdk = (0, import_sdk7.createPeerExtensionSdk)(options);
1739
+ const sdk = (0, import_sdk8.createPeerExtensionSdk)(options);
1691
1740
  return {
1692
1741
  isAvailable: () => isPeerExtensionAvailable(options),
1693
1742
  requestConnection: () => requirePeer(options).requestConnection(),
@@ -1751,7 +1800,7 @@ var OFFRAMP_INTEGRATION_PLAYBOOKS = [
1751
1800
  detail: "Pass the user's viem WalletClient so the user signs approval, deposit, and delegation."
1752
1801
  },
1753
1802
  {
1754
- title: "Handle PayPal and Wise registration",
1803
+ title: "Handle SAR registration",
1755
1804
  detail: "Catch EXTENSION_REGISTRATION_REQUIRED and drive usePeerExtensionRegistration."
1756
1805
  },
1757
1806
  {
@@ -2017,7 +2066,7 @@ function getOfframpAgentPrompt(profile = "app") {
2017
2066
  "Before coding, read https://usdctofiat.xyz/skills/usdctofiat.md and https://usdctofiat.xyz/llms.txt.",
2018
2067
  "Use Base mainnet chainId 8453 and a viem WalletClient; do not invent a sandbox.",
2019
2068
  "Do not add manual rate controls; SDK-created deposits must delegate to the Delegate vault.",
2020
- "For PayPal and Wise, recover EXTENSION_REGISTRATION_REQUIRED through the Peer extension registration flow.",
2069
+ "For PayPal, Wise, Venmo, and Cash App, recover EXTENSION_REGISTRATION_REQUIRED through the Peer extension registration flow.",
2021
2070
  "For bots/workers, deduplicate with deposits(address) plus your own order database; do not rely on idempotencyKey.",
2022
2071
  "For webhooks, verify the raw request body before parsing JSON.",
2023
2072
  ...steps ?? []
@@ -2049,6 +2098,7 @@ function getOfframpAgentPrompt(profile = "app") {
2049
2098
  disableOtc,
2050
2099
  emitEvent,
2051
2100
  enableOtc,
2101
+ findTakerPlatformLimit,
2052
2102
  getOfframpAgentPrompt,
2053
2103
  getOfframpDeveloperResources,
2054
2104
  getOtcLink,
@@ -2056,6 +2106,7 @@ function getOfframpAgentPrompt(profile = "app") {
2056
2106
  getPeerExtensionRegistrationInfo,
2057
2107
  getPeerExtensionState,
2058
2108
  getPlatformLimits,
2109
+ getTakerTier,
2059
2110
  isPeerExtensionAvailable,
2060
2111
  isPeerExtensionMetadataBridgeAvailable,
2061
2112
  isPeerExtensionRegistrationError,
@@ -2063,6 +2114,7 @@ function getOfframpAgentPrompt(profile = "app") {
2063
2114
  offramp,
2064
2115
  openPeerExtensionInstallPage,
2065
2116
  peerExtensionSdk,
2117
+ resolveTakerPlatformLimit,
2066
2118
  sanitizeAttributionId,
2067
2119
  sendTelemetryEvent,
2068
2120
  undelegate