@usdctofiat/offramp 3.1.0 → 4.0.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,121 +1,4 @@
1
- import { PeerOnrampPreparedTransactionCallback, PeerOnrampPreparedTransactionResult, PeerExtensionOnrampParams, CuratorSellerCredentialUploadResponse, currencyInfo } from '@zkp2p/sdk';
2
-
3
- /**
4
- * Peer browser-extension surface for PayPal + Wise makers. Drive the
5
- * headless metadata bridge via `usePeerExtensionRegistration` in
6
- * `@usdctofiat/offramp/react`, or manually:
7
- *
8
- * ```ts
9
- * import {
10
- * completePeerExtensionRegistration,
11
- * isPeerExtensionMetadataBridgeAvailable,
12
- * peerExtensionSdk,
13
- * } from "@usdctofiat/offramp";
14
- *
15
- * const state = await peerExtensionSdk.getState();
16
- * if (state === "needs_install" || !isPeerExtensionMetadataBridgeAvailable()) {
17
- * peerExtensionSdk.openInstallPage();
18
- * } else if (state === "needs_connection") {
19
- * await peerExtensionSdk.requestConnection();
20
- * } else {
21
- * peerExtensionSdk.authenticate({
22
- * actionType: "transfer_paypal",
23
- * captureMode: "sellerCredential",
24
- * platform: "paypal",
25
- * });
26
- * // Pass the captured metadata to completePeerExtensionRegistration(...), then retry.
27
- * }
28
- * ```
29
- */
30
-
31
- type PeerConnectionStatus = "connected" | "disconnected" | "pending";
32
- type PeerMetadataCaptureMode = "buyerTee" | "sellerCredential";
33
- type PeerMetadataProviderConfig = Record<string, unknown>;
34
- type PeerAuthenticateParams = {
35
- actionType: string;
36
- attestationActionType?: string | null;
37
- attestationServiceUrl?: string | null;
38
- captureMode?: PeerMetadataCaptureMode;
39
- platform: string;
40
- providerConfig?: PeerMetadataProviderConfig;
41
- };
42
- type PeerBuyerTeePaymentParams = Record<string, string | number | boolean>;
43
- type PeerBuyerTeePaymentCapture = {
44
- encryptedSessionMaterial: string;
45
- params?: PeerBuyerTeePaymentParams[];
46
- };
47
- type PeerSarCredentialBundle = {
48
- bundleSignature: string;
49
- credentialExpiresAt: string | null;
50
- credentialType: string;
51
- credentialValidatedAt: string;
52
- encryptedBlob: string;
53
- encryptedDataKey: string;
54
- nonce: string;
55
- payeeIdHash: `0x${string}`;
56
- platform: string;
57
- };
58
- type PeerSarCredentialCapture = {
59
- credentialBundle: PeerSarCredentialBundle;
60
- offchainId: string;
61
- };
62
- type PeerMetadataRow = {
63
- amount?: string;
64
- currency?: string;
65
- date?: string;
66
- hidden: boolean;
67
- originalIndex: number;
68
- params?: PeerBuyerTeePaymentParams;
69
- paymentId?: string;
70
- recipient?: string;
71
- [key: string]: unknown;
72
- };
73
- type PeerMetadataMessage = {
74
- buyerTeeCapture?: PeerBuyerTeePaymentCapture | null;
75
- errorMessage?: string;
76
- expiresAt: number;
77
- metadata: PeerMetadataRow[];
78
- platform: string;
79
- requestId: string;
80
- sarCredentialCapture?: PeerSarCredentialCapture | null;
81
- };
82
- type PeerMetadataMessageCallback = (message: PeerMetadataMessage) => void;
83
- type PeerExtensionApi = {
84
- requestConnection(): Promise<boolean>;
85
- checkConnectionStatus(): Promise<PeerConnectionStatus>;
86
- getVersion(): Promise<string>;
87
- authenticate?: (params: PeerAuthenticateParams) => void;
88
- onMetadataMessage?: (callback: PeerMetadataMessageCallback) => () => void;
89
- openSidebar?: (route: string) => void;
90
- onramp?: (queryString: string, callback: PeerOnrampPreparedTransactionCallback) => void;
91
- getOnrampTransaction?: (intentHash: string) => Promise<PeerOnrampPreparedTransactionResult | null>;
92
- };
93
- type PeerExtensionWindow = Window & {
94
- peer?: PeerExtensionApi;
95
- };
96
- type PeerExtensionSdkOptions = {
97
- window?: PeerExtensionWindow;
98
- };
99
- type PeerExtensionSdk = {
100
- requestConnection(): Promise<boolean>;
101
- checkConnectionStatus(): Promise<PeerConnectionStatus>;
102
- getVersion(): Promise<string>;
103
- authenticate(params: PeerAuthenticateParams): void;
104
- onMetadataMessage(callback: PeerMetadataMessageCallback): () => void;
105
- openSidebar(route: string): void;
106
- onramp(params: PeerExtensionOnrampParams, callback: PeerOnrampPreparedTransactionCallback): void;
107
- getOnrampTransaction(intentHash: string): Promise<PeerOnrampPreparedTransactionResult | null>;
108
- isAvailable(): boolean;
109
- openInstallPage(): void;
110
- getState(): Promise<PeerExtensionState>;
111
- };
112
- type PeerExtensionState = "needs_install" | "needs_connection" | "ready";
113
- declare const isPeerExtensionAvailable: (options?: PeerExtensionSdkOptions) => boolean;
114
- declare const isPeerExtensionMetadataBridgeAvailable: (options?: PeerExtensionSdkOptions) => boolean;
115
- declare const openPeerExtensionInstallPage: (options?: PeerExtensionSdkOptions) => void;
116
- declare const getPeerExtensionState: (options?: PeerExtensionSdkOptions) => Promise<PeerExtensionState>;
117
- declare const createPeerExtensionSdk: (options?: PeerExtensionSdkOptions) => PeerExtensionSdk;
118
- declare const peerExtensionSdk: PeerExtensionSdk;
1
+ import { PeerMetadataMessage, CuratorSellerCredentialUploadResponse, PeerAuthenticateParams, currencyInfo } from '@zkp2p/sdk';
119
2
 
120
3
  type PlatformId = "venmo" | "cashapp" | "chime" | "revolut" | "wise" | "mercadopago" | "zelle" | "paypal" | "monzo" | "n26" | "luxon";
121
4
  /**
@@ -406,4 +289,4 @@ declare class OfframpError extends Error {
406
289
  });
407
290
  }
408
291
 
409
- export { isValidIBAN as $, type PeerExtensionState as A, type PeerExtensionWindow as B, CURRENCIES as C, type DepositInfo as D, type PeerMetadataCaptureMode as E, type PeerMetadataMessage as F, type PeerMetadataMessageCallback as G, type PeerMetadataProviderConfig as H, type PeerMetadataRow as I, type PeerSarCredentialBundle as J, type PeerSarCredentialCapture as K, type PlatformEntry as L, MakersCreateError as M, type PlatformKey as N, OFFRAMP_ERROR_CODES as O, PLATFORMS as P, type PlatformLimits as Q, type PlatformTier as R, completePeerExtensionRegistration as S, createPeerExtensionSdk as T, getPeerExtensionRegistrationAuthParams as U, getPeerExtensionRegistrationInfo as V, getPeerExtensionState as W, getPlatformLimits as X, isPeerExtensionAvailable as Y, isPeerExtensionMetadataBridgeAvailable as Z, isPeerExtensionRegistrationError as _, type CompletePeerExtensionRegistrationInput as a, normalizePaypalMeUsername as a0, openPeerExtensionInstallPage as a1, peerExtensionSdk as a2, type CompletePeerExtensionRegistrationResult as b, type CurrencyEntry as c, type DepositStatus as d, type OfframpCreateOptions as e, OfframpError as f, type OfframpErrorCode as g, type OfframpParams as h, type OfframpProgress as i, type OfframpQuote as j, type OfframpQuoteInput as k, type OfframpResult as l, type OfframpState as m, type OfframpStep as n, type OfframpVaultStatus as o, type OnProgress as p, PLATFORM_LIMITS as q, type PayeeDepositData as r, type PeerAuthenticateParams as s, type PeerBuyerTeePaymentCapture as t, type PeerBuyerTeePaymentParams as u, type PeerConnectionStatus as v, type PeerExtensionApi as w, type PeerExtensionRegistrationInfo as x, type PeerExtensionSdk as y, type PeerExtensionSdkOptions as z };
292
+ export { getPlatformLimits as A, isPeerExtensionRegistrationError as B, CURRENCIES as C, type DepositInfo as D, isValidIBAN as E, normalizePaypalMeUsername as F, MakersCreateError as M, OFFRAMP_ERROR_CODES as O, PLATFORMS as P, type CompletePeerExtensionRegistrationInput as a, type CompletePeerExtensionRegistrationResult as b, type CurrencyEntry as c, type DepositStatus as d, type OfframpCreateOptions as e, OfframpError as f, type OfframpErrorCode as g, type OfframpParams as h, type OfframpProgress as i, type OfframpQuote as j, type OfframpQuoteInput as k, type OfframpResult as l, type OfframpState as m, type OfframpStep as n, type OfframpVaultStatus as o, type OnProgress as p, PLATFORM_LIMITS as q, type PayeeDepositData as r, type PeerExtensionRegistrationInfo as s, type PlatformEntry as t, type PlatformKey as u, type PlatformLimits as v, type PlatformTier as w, completePeerExtensionRegistration as x, getPeerExtensionRegistrationAuthParams as y, getPeerExtensionRegistrationInfo as z };
package/dist/index.cjs CHANGED
@@ -75,7 +75,7 @@ var import_sdk5 = require("@zkp2p/sdk");
75
75
 
76
76
  // src/config.ts
77
77
  var import_sdk = require("@zkp2p/sdk");
78
- var SDK_VERSION = "3.1.0";
78
+ var SDK_VERSION = "4.0.0";
79
79
  var BASE_CHAIN_ID = 8453;
80
80
  var RUNTIME_ENV = "production";
81
81
  var API_BASE_URL = "https://api.zkp2p.xyz";
@@ -573,39 +573,9 @@ function requireSarCredentialCapture(capturedMetadata) {
573
573
  }
574
574
  return capture;
575
575
  }
576
- async function uploadSellerCredentialBundle(processorName, payeeHash, bundle) {
577
- const controller = new AbortController();
578
- const timeout = setTimeout(() => controller.abort(), PAYEE_REGISTRATION_TIMEOUT_MS);
579
- try {
580
- const res = await fetch(
581
- `${API_BASE_URL}/v2/makers/${encodeURIComponent(processorName)}/${encodeURIComponent(payeeHash)}/seller-credential`,
582
- {
583
- method: "POST",
584
- headers: { "Content-Type": "application/json" },
585
- body: JSON.stringify(bundle),
586
- signal: controller.signal
587
- }
588
- );
589
- if (!res.ok) {
590
- const txt = await res.text().catch(() => "");
591
- let detail = txt || res.statusText;
592
- try {
593
- const parsed = JSON.parse(txt);
594
- if (typeof parsed.message === "string" && parsed.message.trim()) {
595
- detail = parsed.message;
596
- }
597
- } catch {
598
- }
599
- throw new Error(`seller-credential upload failed (${res.status}): ${detail}`);
600
- }
601
- const json = await res.json();
602
- if (!json.success || !json.responseObject) {
603
- throw new Error(json.message || "seller-credential upload returned no status.");
604
- }
605
- return json;
606
- } finally {
607
- clearTimeout(timeout);
608
- }
576
+ async function uploadSellerCredentialBundle(processorName, offchainId, bundle) {
577
+ const params = processorName === "wise" ? { platform: "wise", bundle } : { platform: processorName, offchainId, bundle };
578
+ return (0, import_sdk2.apiUploadSellerCredentialBundle)(params, API_BASE_URL, PAYEE_REGISTRATION_TIMEOUT_MS);
609
579
  }
610
580
  async function completePeerExtensionRegistration(input) {
611
581
  const processorName = resolveRegistrationProcessor(input.platform);
@@ -627,13 +597,10 @@ async function completePeerExtensionRegistration(input) {
627
597
  if (payload.offchainId !== validation.normalized) {
628
598
  throw new Error("Seller credential offchainId does not match registration identifier.");
629
599
  }
630
- const hashedOnchainId = processorName === "wise" ? bundle.payeeIdHash : await postMakerCreate(processorName, payload);
631
- if (hashedOnchainId.toLowerCase() !== bundle.payeeIdHash.toLowerCase()) {
632
- throw new Error("Seller credential payee hash does not match registered payee details.");
633
- }
600
+ const hashedOnchainId = bundle.payeeIdHash;
634
601
  const sellerCredentialResponse = await uploadSellerCredentialBundle(
635
602
  processorName,
636
- hashedOnchainId,
603
+ payload.offchainId,
637
604
  bundle
638
605
  );
639
606
  return {
@@ -1753,9 +1720,7 @@ var getPeerExtensionState = async (options) => {
1753
1720
  }
1754
1721
  };
1755
1722
  var createPeerExtensionSdk = (options = {}) => {
1756
- const legacySdk = (0, import_sdk7.createPeerExtensionSdk)(
1757
- options
1758
- );
1723
+ const sdk = (0, import_sdk7.createPeerExtensionSdk)(options);
1759
1724
  return {
1760
1725
  isAvailable: () => isPeerExtensionAvailable(options),
1761
1726
  requestConnection: () => requirePeer(options).requestConnection(),
@@ -1763,11 +1728,8 @@ var createPeerExtensionSdk = (options = {}) => {
1763
1728
  getVersion: () => requirePeer(options).getVersion(),
1764
1729
  authenticate: (params) => requirePeerMetadataBridge(options).authenticate(params),
1765
1730
  onMetadataMessage: (callback) => requirePeerMetadataBridge(options).onMetadataMessage(callback),
1766
- openSidebar: (route) => legacySdk.openSidebar(route),
1767
- onramp: (params, callback) => legacySdk.onramp(params, callback),
1768
- getOnrampTransaction: (intentHash) => legacySdk.getOnrampTransaction(intentHash),
1769
- openInstallPage: () => openPeerExtensionInstallPage(options),
1770
- getState: () => getPeerExtensionState(options)
1731
+ openInstallPage: () => sdk.openInstallPage(),
1732
+ getState: () => sdk.getState()
1771
1733
  };
1772
1734
  };
1773
1735
  var peerExtensionSdk = createPeerExtensionSdk();