@swype-org/react-sdk 0.1.2 → 0.1.3

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.d.cts CHANGED
@@ -27,11 +27,6 @@ interface WalletSource {
27
27
  token: WalletToken;
28
28
  balance: TokenBalance;
29
29
  }
30
- /** Token + chain most recently authorized via Permit2 for a wallet */
31
- interface LastAuthorizedToken {
32
- symbol: string;
33
- chainName: string;
34
- }
35
30
  /** Full wallet with chain, balance, and token sources */
36
31
  interface Wallet {
37
32
  id: string;
@@ -43,8 +38,8 @@ interface Wallet {
43
38
  id: string;
44
39
  name: string;
45
40
  };
46
- /** The token+chain most recently authorized via Permit2, if any. */
47
- lastAuthorizedToken?: LastAuthorizedToken | null;
41
+ /** The smart account type (e.g. 'metamask'), if the wallet has been upgraded. */
42
+ smartAccountType?: string | null;
48
43
  createDate: string;
49
44
  updateDate: string;
50
45
  authorizationSessions?: AuthorizationSession[];
@@ -94,6 +89,17 @@ interface TransferDestination {
94
89
  };
95
90
  amount: Amount;
96
91
  }
92
+ /** Sign payload containing the unsigned UserOp and bridge/relay metadata */
93
+ interface TransferSignPayload {
94
+ userOp: Record<string, unknown>;
95
+ /** ERC-4337 UserOp hash — used as the WebAuthn challenge for on-chain verification. */
96
+ userOpHash: string;
97
+ bridgeRelayAddress: string;
98
+ tokenSymbol: string;
99
+ chainName: string;
100
+ amount: string;
101
+ estimatedFeeUsd: string;
102
+ }
97
103
  /** Transfer object returned by the API */
98
104
  interface Transfer {
99
105
  id: string;
@@ -109,6 +115,7 @@ interface Transfer {
109
115
  createDate: string;
110
116
  updateDate: string;
111
117
  authorizationSessions: AuthorizationSession[];
118
+ signPayload?: TransferSignPayload | null;
112
119
  }
113
120
  /** Standard API error shape */
114
121
  interface ErrorResponse {
@@ -162,11 +169,6 @@ interface AdvancedSettings {
162
169
  /** Override chain name (e.g. 'Base', 'Ethereum'). Null = let backend decide. */
163
170
  chain: string | null;
164
171
  }
165
- /** User's top-up allowance selection for the SIGN_PERMIT2 action. */
166
- interface AllowanceSelection {
167
- /** Extra amount (in human-readable units, e.g. 100 = $100) to add on top of the transfer amount. */
168
- topUpAmount: number;
169
- }
170
172
 
171
173
  interface ThemeTokens {
172
174
  bg: string;
@@ -281,21 +283,23 @@ interface UseAuthorizationExecutorResult {
281
283
  executing: boolean;
282
284
  results: ActionExecutionResult[];
283
285
  error: string | null;
286
+ /** The current action being executed (for UI display). */
287
+ currentAction: AuthorizationAction | null;
284
288
  /** The SELECT_SOURCE action when paused for user selection, null otherwise. */
285
289
  pendingSelectSource: AuthorizationAction | null;
286
290
  /** Call this from the UI to provide the user's chain+token choice. */
287
291
  resolveSelectSource: (selection: SourceSelection) => void;
288
- /** The SIGN_PERMIT2 action when paused for allowance selection, null otherwise. */
289
- pendingAllowanceSelection: AuthorizationAction | null;
290
- /** Call this from the UI to provide the user's top-up allowance choice. */
291
- resolveAllowanceSelection: (selection: AllowanceSelection) => void;
292
292
  executeSession: (transfer: Transfer) => Promise<void>;
293
293
  }
294
294
  /**
295
295
  * Executes the full authorization flow for a transfer's first session:
296
296
  * fetches the session, walks through PENDING actions (OPEN_PROVIDER,
297
- * SELECT_SOURCE, SWITCH_CHAIN, APPROVE_PERMIT_2, SIGN_PERMIT2), reports
298
- * each completion to the server, and chains new actions that appear.
297
+ * REGISTER_PASSKEY, UPGRADE_SMART_ACCOUNT, GRANT_PERMISSIONS,
298
+ * SELECT_SOURCE), reports each completion to the server, and chains
299
+ * new actions that appear.
300
+ *
301
+ * Transfer signing (passkey) is handled separately via
302
+ * `useTransferSigning()` after the authorization flow completes.
299
303
  *
300
304
  * When a SELECT_SOURCE action is encountered, the executor pauses and
301
305
  * exposes the action via `pendingSelectSource`. The UI should display
@@ -316,6 +320,11 @@ interface CreateTransferParams {
316
320
  }
317
321
  declare function createTransfer(apiBaseUrl: string, token: string, params: CreateTransferParams): Promise<Transfer>;
318
322
  declare function fetchTransfer(apiBaseUrl: string, token: string, transferId: string): Promise<Transfer>;
323
+ /**
324
+ * Submit a passkey-signed UserOperation for a transfer.
325
+ * PATCH /v1/transfers/{transferId}
326
+ */
327
+ declare function signTransfer(apiBaseUrl: string, token: string, transferId: string, signedUserOp: Record<string, unknown>): Promise<Transfer>;
319
328
  declare function fetchAuthorizationSession(apiBaseUrl: string, sessionId: string): Promise<AuthorizationSessionDetail>;
320
329
  declare function updateUserConfig(apiBaseUrl: string, token: string, config: {
321
330
  defaultAllowance: number;
@@ -340,10 +349,11 @@ declare const api_fetchChains: typeof fetchChains;
340
349
  declare const api_fetchProviders: typeof fetchProviders;
341
350
  declare const api_fetchTransfer: typeof fetchTransfer;
342
351
  declare const api_reportActionCompletion: typeof reportActionCompletion;
352
+ declare const api_signTransfer: typeof signTransfer;
343
353
  declare const api_updateUserConfig: typeof updateUserConfig;
344
354
  declare const api_updateUserConfigBySession: typeof updateUserConfigBySession;
345
355
  declare namespace api {
346
- export { type api_CreateTransferParams as CreateTransferParams, api_createTransfer as createTransfer, api_fetchAccounts as fetchAccounts, api_fetchAuthorizationSession as fetchAuthorizationSession, api_fetchChains as fetchChains, api_fetchProviders as fetchProviders, api_fetchTransfer as fetchTransfer, api_reportActionCompletion as reportActionCompletion, api_updateUserConfig as updateUserConfig, api_updateUserConfigBySession as updateUserConfigBySession };
356
+ export { type api_CreateTransferParams as CreateTransferParams, api_createTransfer as createTransfer, api_fetchAccounts as fetchAccounts, api_fetchAuthorizationSession as fetchAuthorizationSession, api_fetchChains as fetchChains, api_fetchProviders as fetchProviders, api_fetchTransfer as fetchTransfer, api_reportActionCompletion as reportActionCompletion, api_signTransfer as signTransfer, api_updateUserConfig as updateUserConfig, api_updateUserConfigBySession as updateUserConfigBySession };
347
357
  }
348
358
 
349
359
  export { type Account, type ActionExecutionResult, type AdvancedSettings, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, type Destination, type ErrorResponse, type ListResponse, type PaymentStep, type Provider, type SourceType, SwypePayment, type SwypePaymentProps, SwypeProvider, type SwypeProviderProps, type ThemeMode, type ThemeTokens, type TokenBalance, type Transfer, type TransferDestination, type UserConfig, type Wallet, type WalletSource, type WalletToken, darkTheme, getTheme, lightTheme, api as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling };
package/dist/index.d.ts CHANGED
@@ -27,11 +27,6 @@ interface WalletSource {
27
27
  token: WalletToken;
28
28
  balance: TokenBalance;
29
29
  }
30
- /** Token + chain most recently authorized via Permit2 for a wallet */
31
- interface LastAuthorizedToken {
32
- symbol: string;
33
- chainName: string;
34
- }
35
30
  /** Full wallet with chain, balance, and token sources */
36
31
  interface Wallet {
37
32
  id: string;
@@ -43,8 +38,8 @@ interface Wallet {
43
38
  id: string;
44
39
  name: string;
45
40
  };
46
- /** The token+chain most recently authorized via Permit2, if any. */
47
- lastAuthorizedToken?: LastAuthorizedToken | null;
41
+ /** The smart account type (e.g. 'metamask'), if the wallet has been upgraded. */
42
+ smartAccountType?: string | null;
48
43
  createDate: string;
49
44
  updateDate: string;
50
45
  authorizationSessions?: AuthorizationSession[];
@@ -94,6 +89,17 @@ interface TransferDestination {
94
89
  };
95
90
  amount: Amount;
96
91
  }
92
+ /** Sign payload containing the unsigned UserOp and bridge/relay metadata */
93
+ interface TransferSignPayload {
94
+ userOp: Record<string, unknown>;
95
+ /** ERC-4337 UserOp hash — used as the WebAuthn challenge for on-chain verification. */
96
+ userOpHash: string;
97
+ bridgeRelayAddress: string;
98
+ tokenSymbol: string;
99
+ chainName: string;
100
+ amount: string;
101
+ estimatedFeeUsd: string;
102
+ }
97
103
  /** Transfer object returned by the API */
98
104
  interface Transfer {
99
105
  id: string;
@@ -109,6 +115,7 @@ interface Transfer {
109
115
  createDate: string;
110
116
  updateDate: string;
111
117
  authorizationSessions: AuthorizationSession[];
118
+ signPayload?: TransferSignPayload | null;
112
119
  }
113
120
  /** Standard API error shape */
114
121
  interface ErrorResponse {
@@ -162,11 +169,6 @@ interface AdvancedSettings {
162
169
  /** Override chain name (e.g. 'Base', 'Ethereum'). Null = let backend decide. */
163
170
  chain: string | null;
164
171
  }
165
- /** User's top-up allowance selection for the SIGN_PERMIT2 action. */
166
- interface AllowanceSelection {
167
- /** Extra amount (in human-readable units, e.g. 100 = $100) to add on top of the transfer amount. */
168
- topUpAmount: number;
169
- }
170
172
 
171
173
  interface ThemeTokens {
172
174
  bg: string;
@@ -281,21 +283,23 @@ interface UseAuthorizationExecutorResult {
281
283
  executing: boolean;
282
284
  results: ActionExecutionResult[];
283
285
  error: string | null;
286
+ /** The current action being executed (for UI display). */
287
+ currentAction: AuthorizationAction | null;
284
288
  /** The SELECT_SOURCE action when paused for user selection, null otherwise. */
285
289
  pendingSelectSource: AuthorizationAction | null;
286
290
  /** Call this from the UI to provide the user's chain+token choice. */
287
291
  resolveSelectSource: (selection: SourceSelection) => void;
288
- /** The SIGN_PERMIT2 action when paused for allowance selection, null otherwise. */
289
- pendingAllowanceSelection: AuthorizationAction | null;
290
- /** Call this from the UI to provide the user's top-up allowance choice. */
291
- resolveAllowanceSelection: (selection: AllowanceSelection) => void;
292
292
  executeSession: (transfer: Transfer) => Promise<void>;
293
293
  }
294
294
  /**
295
295
  * Executes the full authorization flow for a transfer's first session:
296
296
  * fetches the session, walks through PENDING actions (OPEN_PROVIDER,
297
- * SELECT_SOURCE, SWITCH_CHAIN, APPROVE_PERMIT_2, SIGN_PERMIT2), reports
298
- * each completion to the server, and chains new actions that appear.
297
+ * REGISTER_PASSKEY, UPGRADE_SMART_ACCOUNT, GRANT_PERMISSIONS,
298
+ * SELECT_SOURCE), reports each completion to the server, and chains
299
+ * new actions that appear.
300
+ *
301
+ * Transfer signing (passkey) is handled separately via
302
+ * `useTransferSigning()` after the authorization flow completes.
299
303
  *
300
304
  * When a SELECT_SOURCE action is encountered, the executor pauses and
301
305
  * exposes the action via `pendingSelectSource`. The UI should display
@@ -316,6 +320,11 @@ interface CreateTransferParams {
316
320
  }
317
321
  declare function createTransfer(apiBaseUrl: string, token: string, params: CreateTransferParams): Promise<Transfer>;
318
322
  declare function fetchTransfer(apiBaseUrl: string, token: string, transferId: string): Promise<Transfer>;
323
+ /**
324
+ * Submit a passkey-signed UserOperation for a transfer.
325
+ * PATCH /v1/transfers/{transferId}
326
+ */
327
+ declare function signTransfer(apiBaseUrl: string, token: string, transferId: string, signedUserOp: Record<string, unknown>): Promise<Transfer>;
319
328
  declare function fetchAuthorizationSession(apiBaseUrl: string, sessionId: string): Promise<AuthorizationSessionDetail>;
320
329
  declare function updateUserConfig(apiBaseUrl: string, token: string, config: {
321
330
  defaultAllowance: number;
@@ -340,10 +349,11 @@ declare const api_fetchChains: typeof fetchChains;
340
349
  declare const api_fetchProviders: typeof fetchProviders;
341
350
  declare const api_fetchTransfer: typeof fetchTransfer;
342
351
  declare const api_reportActionCompletion: typeof reportActionCompletion;
352
+ declare const api_signTransfer: typeof signTransfer;
343
353
  declare const api_updateUserConfig: typeof updateUserConfig;
344
354
  declare const api_updateUserConfigBySession: typeof updateUserConfigBySession;
345
355
  declare namespace api {
346
- export { type api_CreateTransferParams as CreateTransferParams, api_createTransfer as createTransfer, api_fetchAccounts as fetchAccounts, api_fetchAuthorizationSession as fetchAuthorizationSession, api_fetchChains as fetchChains, api_fetchProviders as fetchProviders, api_fetchTransfer as fetchTransfer, api_reportActionCompletion as reportActionCompletion, api_updateUserConfig as updateUserConfig, api_updateUserConfigBySession as updateUserConfigBySession };
356
+ export { type api_CreateTransferParams as CreateTransferParams, api_createTransfer as createTransfer, api_fetchAccounts as fetchAccounts, api_fetchAuthorizationSession as fetchAuthorizationSession, api_fetchChains as fetchChains, api_fetchProviders as fetchProviders, api_fetchTransfer as fetchTransfer, api_reportActionCompletion as reportActionCompletion, api_signTransfer as signTransfer, api_updateUserConfig as updateUserConfig, api_updateUserConfigBySession as updateUserConfigBySession };
347
357
  }
348
358
 
349
359
  export { type Account, type ActionExecutionResult, type AdvancedSettings, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, type Destination, type ErrorResponse, type ListResponse, type PaymentStep, type Provider, type SourceType, SwypePayment, type SwypePaymentProps, SwypeProvider, type SwypeProviderProps, type ThemeMode, type ThemeTokens, type TokenBalance, type Transfer, type TransferDestination, type UserConfig, type Wallet, type WalletSource, type WalletToken, darkTheme, getTheme, lightTheme, api as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling };