@usdctofiat/offramp 4.0.0 → 4.2.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
@@ -31,9 +31,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  CURRENCIES: () => CURRENCIES,
34
+ DEFAULT_EXTENSION_INSTALL_URL: () => DEFAULT_EXTENSION_INSTALL_URL,
34
35
  ESCROW_ADDRESS: () => ESCROW_ADDRESS,
35
36
  MakersCreateError: () => MakersCreateError,
37
+ OFFRAMP_DEVELOPER_RESOURCES: () => OFFRAMP_DEVELOPER_RESOURCES,
36
38
  OFFRAMP_ERROR_CODES: () => OFFRAMP_ERROR_CODES,
39
+ OFFRAMP_INTEGRATION_PLAYBOOKS: () => OFFRAMP_INTEGRATION_PLAYBOOKS,
40
+ OFFRAMP_RESOURCE_LINKS: () => OFFRAMP_RESOURCE_LINKS,
37
41
  Offramp: () => Offramp,
38
42
  OfframpError: () => OfframpError,
39
43
  PEER_EXTENSION_CHROME_URL: () => import_sdk7.PEER_EXTENSION_CHROME_URL,
@@ -49,6 +53,7 @@ __export(index_exports, {
49
53
  disableOtc: () => disableOtc,
50
54
  emitEvent: () => emitEvent,
51
55
  enableOtc: () => enableOtc,
56
+ getOfframpDeveloperResources: () => getOfframpDeveloperResources,
52
57
  getOtcLink: () => getOtcLink,
53
58
  getPeerExtensionRegistrationAuthParams: () => getPeerExtensionRegistrationAuthParams,
54
59
  getPeerExtensionRegistrationInfo: () => getPeerExtensionRegistrationInfo,
@@ -75,7 +80,7 @@ var import_sdk5 = require("@zkp2p/sdk");
75
80
 
76
81
  // src/config.ts
77
82
  var import_sdk = require("@zkp2p/sdk");
78
- var SDK_VERSION = "4.0.0";
83
+ var SDK_VERSION = "4.2.0";
79
84
  var BASE_CHAIN_ID = 8453;
80
85
  var RUNTIME_ENV = "production";
81
86
  var API_BASE_URL = "https://api.zkp2p.xyz";
@@ -322,8 +327,7 @@ var BLUEPRINTS = {
322
327
  extensionRegistration: {
323
328
  providerId: "wise",
324
329
  requiredPrompt: "This Wisetag is not registered yet. Register it with PeerAuth, then retry with the same Wisetag.",
325
- ctaLabel: "Register Wisetag",
326
- minExtensionVersion: "0.5.0"
330
+ ctaLabel: "Register Wisetag"
327
331
  }
328
332
  },
329
333
  mercadopago: {
@@ -361,8 +365,7 @@ var BLUEPRINTS = {
361
365
  providerId: "paypal",
362
366
  requiredPrompt: "This PayPal username is not registered yet. Register it with PeerAuth, then retry with the same PayPal username.",
363
367
  ctaLabel: "Register PayPal Username",
364
- ctaSubtext: "PayPal Business accounts are not supported at this time.",
365
- minExtensionVersion: "0.5.0"
368
+ ctaSubtext: "PayPal Business accounts are not supported at this time."
366
369
  }
367
370
  },
368
371
  monzo: {
@@ -1666,6 +1669,7 @@ var OFFRAMP_ERROR_CODES = {
1666
1669
 
1667
1670
  // src/extension.ts
1668
1671
  var import_sdk7 = require("@zkp2p/sdk");
1672
+ var DEFAULT_EXTENSION_INSTALL_URL = "https://chromewebstore.google.com/detail/usdctofiat-verify/lfkmdfifolhcfjmhklmckigfngghmpdf";
1669
1673
  var resolveWindow = (options) => {
1670
1674
  if (options?.window) {
1671
1675
  return options.window;
@@ -1706,7 +1710,8 @@ var openPeerExtensionInstallPage = (options) => {
1706
1710
  if (!resolvedWindow) {
1707
1711
  throw new Error("Peer extension SDK requires a browser window.");
1708
1712
  }
1709
- resolvedWindow.open(import_sdk7.PEER_EXTENSION_CHROME_URL, "_blank", "noopener,noreferrer");
1713
+ const installUrl = options?.installUrl ?? DEFAULT_EXTENSION_INSTALL_URL;
1714
+ resolvedWindow.open(installUrl, "_blank", "noopener,noreferrer");
1710
1715
  };
1711
1716
  var getPeerExtensionState = async (options) => {
1712
1717
  if (!isPeerExtensionAvailable(options)) {
@@ -1728,17 +1733,300 @@ var createPeerExtensionSdk = (options = {}) => {
1728
1733
  getVersion: () => requirePeer(options).getVersion(),
1729
1734
  authenticate: (params) => requirePeerMetadataBridge(options).authenticate(params),
1730
1735
  onMetadataMessage: (callback) => requirePeerMetadataBridge(options).onMetadataMessage(callback),
1731
- openInstallPage: () => sdk.openInstallPage(),
1736
+ openInstallPage: () => openPeerExtensionInstallPage(options),
1732
1737
  getState: () => sdk.getState()
1733
1738
  };
1734
1739
  };
1735
1740
  var peerExtensionSdk = createPeerExtensionSdk();
1741
+
1742
+ // src/resources.ts
1743
+ var OFFRAMP_RESOURCE_LINKS = {
1744
+ developerPortal: "https://usdctofiat.xyz/developers/",
1745
+ sdkGuide: "https://usdctofiat.xyz/developers/offramp-sdk/",
1746
+ appGuide: "https://usdctofiat.xyz/developers/apps/",
1747
+ botGuide: "https://usdctofiat.xyz/developers/bots/",
1748
+ agentGuide: "https://usdctofiat.xyz/developers/agents/",
1749
+ webhooksGuide: "https://usdctofiat.xyz/developers/webhooks/",
1750
+ privateOtcGuide: "https://usdctofiat.xyz/developers/private-otc/",
1751
+ peerlyticsGuide: "https://usdctofiat.xyz/developers/peerlytics/",
1752
+ agentSkill: "https://usdctofiat.xyz/skills/usdctofiat.md",
1753
+ shortMachineReference: "https://usdctofiat.xyz/llms.txt",
1754
+ fullMachineReference: "https://usdctofiat.xyz/llms-full.txt",
1755
+ starters: "https://github.com/ADWilkinson/usdctofiat-peerlytics-starters",
1756
+ peerlyticsDevelopers: "https://peerlytics.xyz/developers",
1757
+ peerlyticsPricing: "https://peerlytics.xyz/pricing",
1758
+ npm: "https://www.npmjs.com/package/@usdctofiat/offramp"
1759
+ };
1760
+ var sharedResources = [
1761
+ {
1762
+ label: "Developer portal",
1763
+ href: OFFRAMP_RESOURCE_LINKS.developerPortal,
1764
+ description: "Human-readable hub for SDK, webhooks, OTC, bots, agents, and Peerlytics."
1765
+ },
1766
+ {
1767
+ label: "Starter templates",
1768
+ href: OFFRAMP_RESOURCE_LINKS.starters,
1769
+ description: "Next.js, Vite, Telegram-bot, scripts, and HMAC webhook receivers."
1770
+ },
1771
+ {
1772
+ label: "Agent skill",
1773
+ href: OFFRAMP_RESOURCE_LINKS.agentSkill,
1774
+ description: "Drop-in skill file for coding agents integrating the off-ramp."
1775
+ }
1776
+ ];
1777
+ var OFFRAMP_INTEGRATION_PLAYBOOKS = [
1778
+ {
1779
+ profile: "app",
1780
+ title: "Wallet app",
1781
+ summary: "Add a sell-USDC button to a user-facing web app.",
1782
+ steps: [
1783
+ {
1784
+ title: "Collect route inputs",
1785
+ detail: "Ask for amount, platform, currency, and the platform-specific payout identifier."
1786
+ },
1787
+ {
1788
+ title: "Call useOfframp or createOfframp",
1789
+ detail: "Pass the user's viem WalletClient so the user signs approval, deposit, and delegation."
1790
+ },
1791
+ {
1792
+ title: "Handle PayPal and Wise registration",
1793
+ detail: "Catch EXTENSION_REGISTRATION_REQUIRED and drive usePeerExtensionRegistration."
1794
+ },
1795
+ {
1796
+ title: "Reconcile state",
1797
+ detail: "Use deposits(address) and webhooks rather than assuming the browser stayed open."
1798
+ }
1799
+ ],
1800
+ resources: [
1801
+ ...sharedResources,
1802
+ {
1803
+ label: "App integration guide",
1804
+ href: OFFRAMP_RESOURCE_LINKS.appGuide,
1805
+ description: "User-facing app flow, React hooks, and wallet-state guidance."
1806
+ },
1807
+ {
1808
+ label: "SDK guide",
1809
+ href: OFFRAMP_RESOURCE_LINKS.sdkGuide,
1810
+ description: "Core SDK exports, resumability, errors, and examples."
1811
+ }
1812
+ ]
1813
+ },
1814
+ {
1815
+ profile: "bot",
1816
+ title: "Bot or backend worker",
1817
+ summary: "Create delegated deposits from a server wallet or automation wallet.",
1818
+ steps: [
1819
+ {
1820
+ title: "Own duplicate prevention",
1821
+ detail: "Before creating, call deposits(address) and reuse open inventory when possible."
1822
+ },
1823
+ {
1824
+ title: "Pass stable attribution",
1825
+ detail: "Use integratorId and referralId so telemetry can separate automated flows."
1826
+ },
1827
+ {
1828
+ title: "Use OTC when a buyer is known",
1829
+ detail: "Pass otcTaker to avoid exposing known-counterparty liquidity publicly."
1830
+ },
1831
+ {
1832
+ title: "Subscribe to lifecycle state",
1833
+ detail: "Register HMAC webhooks so fills and closes survive process restarts."
1834
+ }
1835
+ ],
1836
+ resources: [
1837
+ ...sharedResources,
1838
+ {
1839
+ label: "Bot guide",
1840
+ href: OFFRAMP_RESOURCE_LINKS.botGuide,
1841
+ description: "Server-wallet, retry, idempotency, and OTC patterns."
1842
+ },
1843
+ {
1844
+ label: "Webhooks guide",
1845
+ href: OFFRAMP_RESOURCE_LINKS.webhooksGuide,
1846
+ description: "HMAC verification and lifecycle event names."
1847
+ }
1848
+ ]
1849
+ },
1850
+ {
1851
+ profile: "agent",
1852
+ title: "Coding agent",
1853
+ summary: "Give an agent enough canonical context to build without guessing protocol details.",
1854
+ steps: [
1855
+ {
1856
+ title: "Load the skill",
1857
+ detail: "Point the agent at /skills/usdctofiat.md before it writes integration code."
1858
+ },
1859
+ {
1860
+ title: "Use the machine references",
1861
+ detail: "Feed llms.txt or llms-full.txt when the agent needs routes, contracts, and rules."
1862
+ },
1863
+ {
1864
+ title: "Scaffold first",
1865
+ detail: "Use create-offramp-app or starters before asking the agent to invent wiring."
1866
+ },
1867
+ {
1868
+ title: "Verify delegation",
1869
+ detail: "Check getVaultStatus() and the returned deposit state; SDK deposits must delegate."
1870
+ }
1871
+ ],
1872
+ resources: [
1873
+ ...sharedResources,
1874
+ {
1875
+ label: "Agent guide",
1876
+ href: OFFRAMP_RESOURCE_LINKS.agentGuide,
1877
+ description: "Context-pack and prompt sequence for AI-assisted integration."
1878
+ },
1879
+ {
1880
+ label: "Full machine reference",
1881
+ href: OFFRAMP_RESOURCE_LINKS.fullMachineReference,
1882
+ description: "Canonical routes, contracts, fees, and extractable answers."
1883
+ }
1884
+ ]
1885
+ },
1886
+ {
1887
+ profile: "private-otc",
1888
+ title: "Private OTC flow",
1889
+ summary: "Restrict a delegated deposit to one approved taker wallet.",
1890
+ steps: [
1891
+ {
1892
+ title: "Create with otcTaker",
1893
+ detail: "Pass the buyer wallet in the original offramp() call when the counterparty is known."
1894
+ },
1895
+ {
1896
+ title: "Share the returned otcLink",
1897
+ detail: "The link is convenience; the whitelist hook is the onchain enforcement."
1898
+ },
1899
+ {
1900
+ title: "Rotate when needed",
1901
+ detail: "Use enableOtc, disableOtc, and getOtcLink on existing deposits."
1902
+ }
1903
+ ],
1904
+ resources: [
1905
+ ...sharedResources,
1906
+ {
1907
+ label: "Private OTC guide",
1908
+ href: OFFRAMP_RESOURCE_LINKS.privateOtcGuide,
1909
+ description: "Whitelist hook model and helper exports."
1910
+ }
1911
+ ]
1912
+ },
1913
+ {
1914
+ profile: "webhooks",
1915
+ title: "Lifecycle webhooks",
1916
+ summary: "Receive deposit and OTC lifecycle state with HMAC verification.",
1917
+ steps: [
1918
+ {
1919
+ title: "Create a Peerlytics API key",
1920
+ detail: "One key authenticates both Peerlytics and USDCtoFiat developer surfaces."
1921
+ },
1922
+ {
1923
+ title: "Register an endpoint",
1924
+ detail: "Point the console at an HTTPS endpoint that can read the raw request body."
1925
+ },
1926
+ {
1927
+ title: "Verify before parsing",
1928
+ detail: "Compute HMAC-SHA256 over timestamp.rawBody and compare to v1 in constant time."
1929
+ },
1930
+ {
1931
+ title: "Reconcile important state",
1932
+ detail: "Treat events as hints and call deposits(address) or your indexer for hard state."
1933
+ }
1934
+ ],
1935
+ resources: [
1936
+ ...sharedResources,
1937
+ {
1938
+ label: "Webhooks guide",
1939
+ href: OFFRAMP_RESOURCE_LINKS.webhooksGuide,
1940
+ description: "Event names, headers, and replay-window guidance."
1941
+ },
1942
+ {
1943
+ label: "Peerlytics console",
1944
+ href: OFFRAMP_RESOURCE_LINKS.peerlyticsDevelopers,
1945
+ description: "API keys, credits, and endpoint management."
1946
+ }
1947
+ ]
1948
+ },
1949
+ {
1950
+ profile: "peerlytics",
1951
+ title: "Peerlytics expansion",
1952
+ summary: "Add market data, explorer reads, analytics, and credit-backed API access.",
1953
+ steps: [
1954
+ {
1955
+ title: "Start with deposits",
1956
+ detail: "@usdctofiat/offramp creates delegated seller inventory without an API key."
1957
+ },
1958
+ {
1959
+ title: "Add the paid API",
1960
+ detail: "Use @peerlytics/sdk when the product needs orderbook, analytics, and webhooks."
1961
+ },
1962
+ {
1963
+ title: "Buy credits as usage grows",
1964
+ detail: "Peerlytics credits back deeper API calls and Pro webhook access."
1965
+ }
1966
+ ],
1967
+ resources: [
1968
+ ...sharedResources,
1969
+ {
1970
+ label: "Peerlytics expansion guide",
1971
+ href: OFFRAMP_RESOURCE_LINKS.peerlyticsGuide,
1972
+ description: "When to add the paid protocol API alongside the free deposit SDK."
1973
+ },
1974
+ {
1975
+ label: "Peerlytics pricing",
1976
+ href: OFFRAMP_RESOURCE_LINKS.peerlyticsPricing,
1977
+ description: "Credit packs, Free and Pro plans, and API limits."
1978
+ }
1979
+ ]
1980
+ }
1981
+ ];
1982
+ var OFFRAMP_DEVELOPER_RESOURCES = {
1983
+ packageName: "@usdctofiat/offramp",
1984
+ sdkVersion: SDK_VERSION,
1985
+ chain: "base-mainnet",
1986
+ chainId: 8453,
1987
+ referrer: REFERRER,
1988
+ delegation: {
1989
+ required: true,
1990
+ rateManagerId: DELEGATE_RATE_MANAGER_ID,
1991
+ rateManagerAddress: RATE_MANAGER_REGISTRY_ADDRESS,
1992
+ feeRateBps: DELEGATE_MANAGER_FEE_BPS,
1993
+ escrow: ESCROW_ADDRESS
1994
+ },
1995
+ links: {
1996
+ developerPortal: OFFRAMP_RESOURCE_LINKS.developerPortal,
1997
+ sdkGuide: OFFRAMP_RESOURCE_LINKS.sdkGuide,
1998
+ appGuide: OFFRAMP_RESOURCE_LINKS.appGuide,
1999
+ botGuide: OFFRAMP_RESOURCE_LINKS.botGuide,
2000
+ agentGuide: OFFRAMP_RESOURCE_LINKS.agentGuide,
2001
+ webhooksGuide: OFFRAMP_RESOURCE_LINKS.webhooksGuide,
2002
+ privateOtcGuide: OFFRAMP_RESOURCE_LINKS.privateOtcGuide,
2003
+ peerlyticsGuide: OFFRAMP_RESOURCE_LINKS.peerlyticsGuide,
2004
+ agentSkill: OFFRAMP_RESOURCE_LINKS.agentSkill,
2005
+ shortMachineReference: OFFRAMP_RESOURCE_LINKS.shortMachineReference,
2006
+ fullMachineReference: OFFRAMP_RESOURCE_LINKS.fullMachineReference,
2007
+ starters: OFFRAMP_RESOURCE_LINKS.starters,
2008
+ peerlyticsDevelopers: OFFRAMP_RESOURCE_LINKS.peerlyticsDevelopers,
2009
+ peerlyticsPricing: OFFRAMP_RESOURCE_LINKS.peerlyticsPricing,
2010
+ npm: OFFRAMP_RESOURCE_LINKS.npm
2011
+ },
2012
+ playbooks: OFFRAMP_INTEGRATION_PLAYBOOKS
2013
+ };
2014
+ function getOfframpDeveloperResources(profile) {
2015
+ if (!profile) return OFFRAMP_DEVELOPER_RESOURCES;
2016
+ const playbook = OFFRAMP_INTEGRATION_PLAYBOOKS.find((entry) => entry.profile === profile);
2017
+ if (!playbook) return OFFRAMP_DEVELOPER_RESOURCES;
2018
+ return playbook;
2019
+ }
1736
2020
  // Annotate the CommonJS export names for ESM import in node:
1737
2021
  0 && (module.exports = {
1738
2022
  CURRENCIES,
2023
+ DEFAULT_EXTENSION_INSTALL_URL,
1739
2024
  ESCROW_ADDRESS,
1740
2025
  MakersCreateError,
2026
+ OFFRAMP_DEVELOPER_RESOURCES,
1741
2027
  OFFRAMP_ERROR_CODES,
2028
+ OFFRAMP_INTEGRATION_PLAYBOOKS,
2029
+ OFFRAMP_RESOURCE_LINKS,
1742
2030
  Offramp,
1743
2031
  OfframpError,
1744
2032
  PEER_EXTENSION_CHROME_URL,
@@ -1754,6 +2042,7 @@ var peerExtensionSdk = createPeerExtensionSdk();
1754
2042
  disableOtc,
1755
2043
  emitEvent,
1756
2044
  enableOtc,
2045
+ getOfframpDeveloperResources,
1757
2046
  getOtcLink,
1758
2047
  getPeerExtensionRegistrationAuthParams,
1759
2048
  getPeerExtensionRegistrationInfo,