@talken/talkenkit 2.3.10 → 2.3.11
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/__private__/index.d.ts +2 -2
- package/dist/components/ConnectOptions/AbcWaasAuth/AbcWaasAuthFlow.d.ts +83 -0
- package/dist/components/ConnectOptions/AbcWaasAuth/AbcWaasAuthSections.css.d.ts +8 -0
- package/dist/components/ConnectOptions/AbcWaasAuth/AbcWaasAuthSections.d.ts +25 -0
- package/dist/components/ConnectOptions/AbcWaasAuth/hooks/useAbcWaasAuth.d.ts +65 -0
- package/dist/components/ConnectOptions/AbcWaasAuth/hooks/useAbcWaasSocial.d.ts +58 -0
- package/dist/components/ConnectOptions/AbcWaasAuth/hooks/useUserTypeDetection.d.ts +0 -0
- package/dist/components/ConnectOptions/AbcWaasAuth/index.d.ts +6 -0
- package/dist/components/ConnectOptions/AbcWaasAuth/types.d.ts +29 -0
- package/dist/components/ConnectOptions/ConnectDetails.d.ts +1 -1
- package/dist/components/ConnectOptions/ConnectOptionsModal.css.d.ts +4 -0
- package/dist/components/ConnectOptions/ConnectOptionsModal.d.ts +26 -0
- package/dist/components/ConnectOptions/ExternalWallets/EthereumWallet/EthereumWalletList.d.ts +35 -0
- package/dist/components/ConnectOptions/ExternalWallets/EthereumWallet/index.d.ts +6 -0
- package/dist/components/ConnectOptions/ExternalWallets/Popular/PopularWalletList.d.ts +37 -0
- package/dist/components/ConnectOptions/ExternalWallets/Popular/index.d.ts +6 -0
- package/dist/components/ConnectOptions/ExternalWallets/SolanaWallet/SolanaWalletList.d.ts +37 -0
- package/dist/components/ConnectOptions/ExternalWallets/SolanaWallet/index.d.ts +6 -0
- package/dist/components/ConnectOptions/ExternalWallets/WalletList.d.ts +94 -0
- package/dist/components/ConnectOptions/ExternalWallets/hooks/useWalletConnection.d.ts +78 -0
- package/dist/components/ConnectOptions/ExternalWallets/index.d.ts +12 -0
- package/dist/components/ConnectOptions/ExternalWallets/shared/index.d.ts +7 -0
- package/dist/components/ConnectOptions/ExternalWallets/shared/types.d.ts +136 -0
- package/dist/components/ConnectOptions/ExternalWallets/shared/utils.d.ts +68 -0
- package/dist/components/ConnectOptions/PinAuth/PinAuthFlow.d.ts +127 -0
- package/dist/components/ConnectOptions/PinAuth/hooks/index.d.ts +10 -0
- package/dist/components/ConnectOptions/PinAuth/hooks/usePinCreation.d.ts +92 -0
- package/dist/components/ConnectOptions/PinAuth/hooks/usePinVerification.d.ts +114 -0
- package/dist/components/ConnectOptions/PinAuth/hooks/useWalletGeneration.d.ts +93 -0
- package/dist/components/ConnectOptions/PinAuth/index.d.ts +23 -0
- package/dist/index.css +27 -298
- package/dist/index.d.ts +0 -4
- package/dist/index.js +5525 -6410
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaWallet.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/api/index.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/index.js +20 -20
- package/dist/wallets/walletConnectors/berasigWallet/berasigWallet.js +2 -2
- package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
- package/dist/wallets/walletConnectors/binanceWallet/binanceWallet.js +2 -2
- package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
- package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
- package/dist/wallets/walletConnectors/chunk-24SQ562R.js +63 -0
- package/dist/wallets/walletConnectors/chunk-3UNSJDAS.js +63 -0
- package/dist/wallets/walletConnectors/chunk-6KUCZXJE.js +63 -0
- package/dist/wallets/walletConnectors/{chunk-34WMJDUY.js → chunk-75W4VLFA.js} +8 -7
- package/dist/wallets/walletConnectors/chunk-ASUECF4H.js +63 -0
- package/dist/wallets/walletConnectors/chunk-GLPRLW3S.js +63 -0
- package/dist/wallets/walletConnectors/chunk-GOPPX56D.js +63 -0
- package/dist/wallets/walletConnectors/chunk-I5V7LWJH.js +63 -0
- package/dist/wallets/walletConnectors/chunk-J4HQCVKX.js +63 -0
- package/dist/wallets/walletConnectors/chunk-PDWD3ZCR.js +63 -0
- package/dist/wallets/walletConnectors/chunk-PHD5KHRQ.js +63 -0
- package/dist/wallets/walletConnectors/chunk-PQJWUKUD.js +63 -0
- package/dist/wallets/walletConnectors/chunk-PZJYVPGG.js +63 -0
- package/dist/wallets/walletConnectors/chunk-Q5B5ICDI.js +63 -0
- package/dist/wallets/walletConnectors/chunk-RYXFFAB2.js +63 -0
- package/dist/wallets/walletConnectors/chunk-VXUJQQDI.js +63 -0
- package/dist/wallets/walletConnectors/chunk-WCPI7IUU.js +63 -0
- package/dist/wallets/walletConnectors/chunk-Z3WO2EBZ.js +63 -0
- package/dist/wallets/walletConnectors/chunk-ZADNKI5I.js +63 -0
- package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
- package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
- package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
- package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
- package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
- package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
- package/dist/wallets/walletConnectors/index.js +84 -84
- package/dist/wallets/walletConnectors/iopayWallet/iopayWallet.js +2 -2
- package/dist/wallets/walletConnectors/kaiaWallet/kaiaWallet.js +2 -2
- package/dist/wallets/walletConnectors/kaikasWallet/kaikasWallet.js +2 -2
- package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
- package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
- package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
- package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
- package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
- package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
- package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
- package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
- package/dist/wallets/walletConnectors/zealWallet/zealWallet.js +2 -2
- package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared TypeScript types for ExternalWallets module
|
|
3
|
+
*
|
|
4
|
+
* @module ExternalWallets/shared/types
|
|
5
|
+
*/
|
|
6
|
+
import type { Adapter } from '@solana/wallet-adapter-base';
|
|
7
|
+
import type { WalletConnector } from '../../../../wallets/useWalletConnectors';
|
|
8
|
+
/**
|
|
9
|
+
* Common wallet data structure for rendering
|
|
10
|
+
*/
|
|
11
|
+
export interface WalletItem {
|
|
12
|
+
/**
|
|
13
|
+
* Unique wallet identifier (id or adapter.name)
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
/**
|
|
17
|
+
* Display name
|
|
18
|
+
*/
|
|
19
|
+
name: string;
|
|
20
|
+
/**
|
|
21
|
+
* Icon URL or data URI
|
|
22
|
+
*/
|
|
23
|
+
iconUrl: string | (() => Promise<string>);
|
|
24
|
+
/**
|
|
25
|
+
* Icon background color (optional)
|
|
26
|
+
*/
|
|
27
|
+
iconBackground?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether wallet is ready/installed
|
|
30
|
+
*/
|
|
31
|
+
ready: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether this is a RainbowKit connector (vs EIP-6963)
|
|
34
|
+
*/
|
|
35
|
+
isRainbowKitConnector: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Wallet type (for rendering logic)
|
|
38
|
+
*/
|
|
39
|
+
type: 'evm' | 'solana';
|
|
40
|
+
/**
|
|
41
|
+
* Original connector or adapter reference
|
|
42
|
+
*/
|
|
43
|
+
source: WalletConnector | {
|
|
44
|
+
adapter: Adapter;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Solana wallet wrapper structure
|
|
49
|
+
*/
|
|
50
|
+
export interface SolanaWalletItem {
|
|
51
|
+
/**
|
|
52
|
+
* Solana wallet adapter
|
|
53
|
+
*/
|
|
54
|
+
adapter: Adapter;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Props for wallet list components
|
|
58
|
+
*/
|
|
59
|
+
export interface BaseWalletListProps {
|
|
60
|
+
/**
|
|
61
|
+
* Recent wallet IDs for prioritization
|
|
62
|
+
*/
|
|
63
|
+
recentWalletIds: string[];
|
|
64
|
+
/**
|
|
65
|
+
* Currently selected wallet ID
|
|
66
|
+
*/
|
|
67
|
+
selectedWalletId?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Callback when user selects a wallet
|
|
70
|
+
*/
|
|
71
|
+
onWalletSelect: (wallet: WalletConnector) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Compact mode for mobile
|
|
74
|
+
*/
|
|
75
|
+
compact?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Props for Ethereum wallet list
|
|
79
|
+
*/
|
|
80
|
+
export interface EthereumWalletListProps extends BaseWalletListProps {
|
|
81
|
+
/**
|
|
82
|
+
* Installed Ethereum wallet connectors
|
|
83
|
+
*/
|
|
84
|
+
wallets: WalletConnector[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Props for Solana wallet list
|
|
88
|
+
*/
|
|
89
|
+
export interface SolanaWalletListProps {
|
|
90
|
+
/**
|
|
91
|
+
* Solana wallet adapters
|
|
92
|
+
*/
|
|
93
|
+
solanaWallets: SolanaWalletItem[];
|
|
94
|
+
/**
|
|
95
|
+
* Recent Solana wallet IDs
|
|
96
|
+
*/
|
|
97
|
+
recentWalletIds: string[];
|
|
98
|
+
/**
|
|
99
|
+
* Currently connecting wallet name
|
|
100
|
+
*/
|
|
101
|
+
connectingSolanaWallet?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Connection in progress
|
|
104
|
+
*/
|
|
105
|
+
isSolanaConnecting?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Callback when user selects a Solana wallet
|
|
108
|
+
*/
|
|
109
|
+
onSolanaWalletClick?: (walletName: string) => void;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Props for Popular wallet list
|
|
113
|
+
*/
|
|
114
|
+
export interface PopularWalletListProps extends BaseWalletListProps {
|
|
115
|
+
/**
|
|
116
|
+
* Current wallet list (filtered)
|
|
117
|
+
*/
|
|
118
|
+
wallets: WalletConnector[];
|
|
119
|
+
/**
|
|
120
|
+
* Unfiltered wallet list for matching Popular group
|
|
121
|
+
*/
|
|
122
|
+
unfilteredWallets?: WalletConnector[];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Wallet sorting result
|
|
126
|
+
*/
|
|
127
|
+
export interface SortedWallets {
|
|
128
|
+
/**
|
|
129
|
+
* Most recent wallet (if exists)
|
|
130
|
+
*/
|
|
131
|
+
recent?: WalletConnector;
|
|
132
|
+
/**
|
|
133
|
+
* Remaining wallets in alphabetical order
|
|
134
|
+
*/
|
|
135
|
+
others: WalletConnector[];
|
|
136
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for ExternalWallets module
|
|
3
|
+
*
|
|
4
|
+
* @module ExternalWallets/shared/utils
|
|
5
|
+
*/
|
|
6
|
+
import type { WalletConnector } from '../../../../wallets/useWalletConnectors';
|
|
7
|
+
/**
|
|
8
|
+
* Sort wallets by recent priority
|
|
9
|
+
*
|
|
10
|
+
* Places the most recent wallet first, then sorts remaining alphabetically
|
|
11
|
+
*
|
|
12
|
+
* @param wallets - Array of wallet connectors to sort
|
|
13
|
+
* @param recentWalletIds - Array of recent wallet IDs (most recent first)
|
|
14
|
+
* @returns Sorted array with most recent first, then alphabetical
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const wallets = [
|
|
19
|
+
* { id: 'coinbase', name: 'Coinbase Wallet' },
|
|
20
|
+
* { id: 'metaMask', name: 'MetaMask' },
|
|
21
|
+
* { id: 'walletConnect', name: 'WalletConnect' },
|
|
22
|
+
* ];
|
|
23
|
+
* const sorted = sortWalletsByRecent(wallets, ['metaMask']);
|
|
24
|
+
* // Result: [MetaMask, Coinbase Wallet, WalletConnect]
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function sortWalletsByRecent(wallets: WalletConnector[], recentWalletIds: string[]): WalletConnector[];
|
|
28
|
+
/**
|
|
29
|
+
* Match Popular wallets from wagmi.ts configuration
|
|
30
|
+
*
|
|
31
|
+
* Auto-syncs with wagmi.ts Popular group, preserving order and handling
|
|
32
|
+
* EIP-6963 wallet ID changes (e.g., MetaMask via RDNS)
|
|
33
|
+
*
|
|
34
|
+
* @param unfilteredWallets - Original wallet list from wagmi.ts
|
|
35
|
+
* @param groupedWallets - Current grouped wallets (including Installed)
|
|
36
|
+
* @returns Popular wallets in wagmi.ts order
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const popularWallets = matchPopularWallets(
|
|
41
|
+
* unfilteredWallets,
|
|
42
|
+
* { 'Installed': [...], 'Popular': [...] }
|
|
43
|
+
* );
|
|
44
|
+
* // Result: Wallets matching Popular group, preserving wagmi.ts order
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function matchPopularWallets(unfilteredWallets: WalletConnector[] | undefined, groupedWallets: Record<string, WalletConnector[]>): WalletConnector[];
|
|
48
|
+
/**
|
|
49
|
+
* Group wallets by groupName
|
|
50
|
+
*
|
|
51
|
+
* @param wallets - Array of wallet connectors
|
|
52
|
+
* @returns Object with groupName keys and wallet arrays
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const grouped = groupWalletsByName(wallets);
|
|
57
|
+
* // Result: { 'Installed': [...], 'Popular': [...], 'Other': [...] }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function groupWalletsByName(wallets: WalletConnector[]): Record<string, WalletConnector[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Check if wallet is the most recent
|
|
63
|
+
*
|
|
64
|
+
* @param walletId - Wallet ID to check
|
|
65
|
+
* @param recentWalletIds - Array of recent wallet IDs
|
|
66
|
+
* @returns True if this is the most recent wallet
|
|
67
|
+
*/
|
|
68
|
+
export declare function isMostRecentWallet(walletId: string, recentWalletIds: string[]): boolean;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PinAuthFlow Component
|
|
3
|
+
*
|
|
4
|
+
* Orchestrator component for PIN authentication flows.
|
|
5
|
+
* Manages PIN creation, confirmation, and verification for ABC WaaS authentication.
|
|
6
|
+
*
|
|
7
|
+
* Responsibilities:
|
|
8
|
+
* 1. Coordinate PIN creation and confirmation modals
|
|
9
|
+
* 2. Integrate with wallet generation flow
|
|
10
|
+
* 3. Handle PIN verification for existing users
|
|
11
|
+
* 4. Display progress during wallet creation
|
|
12
|
+
* 5. Manage modal state transitions
|
|
13
|
+
*
|
|
14
|
+
* Flow Orchestration:
|
|
15
|
+
* - New User: Create PIN → Confirm PIN → Generate Wallets → Connect
|
|
16
|
+
* - Existing User: Verify PIN → Restore Wallet → Connect
|
|
17
|
+
*
|
|
18
|
+
* Integration:
|
|
19
|
+
* - Uses usePinCreation for PIN setup
|
|
20
|
+
* - Uses usePinVerification for PIN unlock
|
|
21
|
+
* - Uses useWalletGeneration for multi-chain wallet creation
|
|
22
|
+
* - Uses PinInputModal for all PIN input UI
|
|
23
|
+
*
|
|
24
|
+
* @packageDocumentation
|
|
25
|
+
*/
|
|
26
|
+
import React from 'react';
|
|
27
|
+
/**
|
|
28
|
+
* Props for PinAuthFlow component
|
|
29
|
+
*/
|
|
30
|
+
export interface PinAuthFlowProps {
|
|
31
|
+
/**
|
|
32
|
+
* Email for PIN association
|
|
33
|
+
* Used to identify wallet owner
|
|
34
|
+
*/
|
|
35
|
+
email: string;
|
|
36
|
+
/**
|
|
37
|
+
* Login data from ABC WaaS authentication
|
|
38
|
+
* Contains access_token, refresh_token, expires_in
|
|
39
|
+
*/
|
|
40
|
+
loginData: any;
|
|
41
|
+
/**
|
|
42
|
+
* Callback when wallet creation/verification is complete
|
|
43
|
+
* Called after successful wallet generation or PIN verification
|
|
44
|
+
*/
|
|
45
|
+
onComplete: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Callback to close and reset
|
|
48
|
+
* Called when user cancels PIN flow
|
|
49
|
+
*/
|
|
50
|
+
onCancel: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* wagmi connectors for wallet connection
|
|
53
|
+
* Used to find and connect ABC wallet connector
|
|
54
|
+
*/
|
|
55
|
+
connectors: readonly any[];
|
|
56
|
+
/**
|
|
57
|
+
* wagmi connect function
|
|
58
|
+
* Used to establish wallet connection
|
|
59
|
+
*/
|
|
60
|
+
connect: (args: {
|
|
61
|
+
connector: any;
|
|
62
|
+
}) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Storage prefix for localStorage
|
|
65
|
+
* @default 'talkenkit_abc_'
|
|
66
|
+
*/
|
|
67
|
+
storagePrefix?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Imperative handle for external control
|
|
71
|
+
*/
|
|
72
|
+
export interface PinAuthFlowHandle {
|
|
73
|
+
/**
|
|
74
|
+
* Show PIN creation modal
|
|
75
|
+
* Used when new user needs to create PIN
|
|
76
|
+
*/
|
|
77
|
+
showPinCreate: () => void;
|
|
78
|
+
/**
|
|
79
|
+
* Show PIN verification modal
|
|
80
|
+
* Used when existing user needs to unlock wallet
|
|
81
|
+
*/
|
|
82
|
+
showPinVerify: () => void;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* PinAuthFlow Orchestrator Component
|
|
86
|
+
*
|
|
87
|
+
* Coordinates all PIN-related authentication flows for ABC WaaS.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* // Basic usage
|
|
92
|
+
* <PinAuthFlow
|
|
93
|
+
* email="user@example.com"
|
|
94
|
+
* loginData={{ access_token: '...', refresh_token: '...', expires_in: 3600 }}
|
|
95
|
+
* onComplete={() => {
|
|
96
|
+
* console.log('Wallet ready!');
|
|
97
|
+
* closeModal();
|
|
98
|
+
* }}
|
|
99
|
+
* onCancel={() => {
|
|
100
|
+
* console.log('User cancelled');
|
|
101
|
+
* resetState();
|
|
102
|
+
* }}
|
|
103
|
+
* connectors={connectors}
|
|
104
|
+
* connect={connect}
|
|
105
|
+
* />
|
|
106
|
+
*
|
|
107
|
+
* // With ref for external control
|
|
108
|
+
* const pinAuthRef = useRef<PinAuthFlowHandle>(null);
|
|
109
|
+
*
|
|
110
|
+
* <PinAuthFlow
|
|
111
|
+
* ref={pinAuthRef}
|
|
112
|
+
* email={email}
|
|
113
|
+
* loginData={loginData}
|
|
114
|
+
* onComplete={handleComplete}
|
|
115
|
+
* onCancel={handleCancel}
|
|
116
|
+
* connectors={connectors}
|
|
117
|
+
* connect={connect}
|
|
118
|
+
* />
|
|
119
|
+
*
|
|
120
|
+
* // Trigger PIN creation externally
|
|
121
|
+
* pinAuthRef.current?.showPinCreate();
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @param props - Component configuration
|
|
125
|
+
* @returns PinAuthFlow component
|
|
126
|
+
*/
|
|
127
|
+
export declare const PinAuthFlow: React.ForwardRefExoticComponent<PinAuthFlowProps & React.RefAttributes<PinAuthFlowHandle>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PinAuth Hooks
|
|
3
|
+
*
|
|
4
|
+
* Custom hooks for PIN-based authentication flows.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export { usePinCreation, type UsePinCreationProps, type UsePinCreationReturn, } from './usePinCreation';
|
|
9
|
+
export { usePinVerification, type UsePinVerificationProps, type UsePinVerificationReturn, type ProgressStep, type ProgressStatus, } from './usePinVerification';
|
|
10
|
+
export { useWalletGeneration, type UseWalletGenerationProps, type UseWalletGenerationReturn, type WalletGenerationProgress, } from './useWalletGeneration';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* usePinCreation Hook
|
|
3
|
+
*
|
|
4
|
+
* Manages PIN creation and confirmation flow for ABC WaaS authentication.
|
|
5
|
+
*
|
|
6
|
+
* Flow:
|
|
7
|
+
* 1. User creates PIN � handlePinCreate
|
|
8
|
+
* 2. Trigger confirmation modal
|
|
9
|
+
* 3. User confirms PIN � handlePinConfirm
|
|
10
|
+
* 4. Hash PIN � Callback with hashed PIN
|
|
11
|
+
*
|
|
12
|
+
* Security:
|
|
13
|
+
* - Stores PIN temporarily in memory only
|
|
14
|
+
* - Validates PIN match before confirmation
|
|
15
|
+
* - Hashes PIN with SHA-256 before storage
|
|
16
|
+
* - Clears plain text PIN immediately after use
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Props for usePinCreation hook
|
|
22
|
+
*/
|
|
23
|
+
export interface UsePinCreationProps {
|
|
24
|
+
/**
|
|
25
|
+
* Callback when PIN is confirmed and ready for wallet generation
|
|
26
|
+
* @param pinHash - SHA-256 hash of the confirmed PIN
|
|
27
|
+
*/
|
|
28
|
+
onPinConfirmed: (pinHash: string) => Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Optional callback to show confirmation modal
|
|
31
|
+
* Called after PIN creation to trigger confirmation UI
|
|
32
|
+
*/
|
|
33
|
+
onShowConfirmModal?: () => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Return value from usePinCreation hook
|
|
37
|
+
*/
|
|
38
|
+
export interface UsePinCreationReturn {
|
|
39
|
+
/** Created PIN (stored temporarily for confirmation) */
|
|
40
|
+
pin: string;
|
|
41
|
+
/** Confirmed PIN (for validation) */
|
|
42
|
+
confirmPin: string;
|
|
43
|
+
/** Error message if PIN confirmation fails */
|
|
44
|
+
error: string;
|
|
45
|
+
/** Loading state during PIN confirmation */
|
|
46
|
+
isCreating: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Handle PIN creation
|
|
49
|
+
* @param pin - Plain text PIN from user input
|
|
50
|
+
*/
|
|
51
|
+
handlePinCreate: (pin: string) => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Handle PIN confirmation
|
|
54
|
+
* @param confirmPin - Confirmed PIN from user input
|
|
55
|
+
* @throws Error if PIN confirmation fails
|
|
56
|
+
*/
|
|
57
|
+
handlePinConfirm: (confirmPin: string) => Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Reset PIN state
|
|
60
|
+
* Clears all PIN data and errors
|
|
61
|
+
*/
|
|
62
|
+
resetPin: () => void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Hook for managing PIN creation and confirmation flow
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const pinCreation = usePinCreation({
|
|
70
|
+
* onPinConfirmed: async (pinHash) => {
|
|
71
|
+
* await generateWallet(pinHash);
|
|
72
|
+
* },
|
|
73
|
+
* onShowConfirmModal: () => {
|
|
74
|
+
* setIsPinConfirmModalOpen(true);
|
|
75
|
+
* }
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // In PIN creation modal
|
|
79
|
+
* <PinInput onSubmit={pinCreation.handlePinCreate} />
|
|
80
|
+
*
|
|
81
|
+
* // In PIN confirmation modal
|
|
82
|
+
* <PinInput
|
|
83
|
+
* onSubmit={pinCreation.handlePinConfirm}
|
|
84
|
+
* error={pinCreation.error}
|
|
85
|
+
* isLoading={pinCreation.isCreating}
|
|
86
|
+
* />
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @param props - Configuration options
|
|
90
|
+
* @returns PIN creation state and handlers
|
|
91
|
+
*/
|
|
92
|
+
export declare function usePinCreation(props: UsePinCreationProps): UsePinCreationReturn;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* usePinVerification Hook
|
|
3
|
+
*
|
|
4
|
+
* Manages PIN verification and wallet restoration flow for ABC WaaS authentication.
|
|
5
|
+
*
|
|
6
|
+
* Flow:
|
|
7
|
+
* 1. User enters PIN -> handlePinVerify
|
|
8
|
+
* 2. Hash PIN and verify against stored hash
|
|
9
|
+
* 3. Decrypt stored tokens with PIN
|
|
10
|
+
* 4. Check token expiration
|
|
11
|
+
* 5. Restore wallet state from localStorage
|
|
12
|
+
* 6. Generate missing wallets if needed (recovery scenario)
|
|
13
|
+
* 7. Callback with restored auth state
|
|
14
|
+
*
|
|
15
|
+
* Security:
|
|
16
|
+
* - Verifies PIN by decrypting stored data (not by comparing hashes)
|
|
17
|
+
* - Validates access token expiration
|
|
18
|
+
* - Clears expired sessions automatically
|
|
19
|
+
* - Re-encrypts sensitive data with PIN
|
|
20
|
+
*
|
|
21
|
+
* @packageDocumentation
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Progress step status
|
|
25
|
+
*/
|
|
26
|
+
export type ProgressStatus = 'pending' | 'active' | 'completed';
|
|
27
|
+
/**
|
|
28
|
+
* Progress step for wallet restoration
|
|
29
|
+
*/
|
|
30
|
+
export interface ProgressStep {
|
|
31
|
+
/** Step description */
|
|
32
|
+
label: string;
|
|
33
|
+
/** Current status */
|
|
34
|
+
status: ProgressStatus;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Props for usePinVerification hook
|
|
38
|
+
*/
|
|
39
|
+
export interface UsePinVerificationProps {
|
|
40
|
+
/**
|
|
41
|
+
* Email for PIN verification
|
|
42
|
+
* Used to validate wallet ownership
|
|
43
|
+
*/
|
|
44
|
+
email: string;
|
|
45
|
+
/**
|
|
46
|
+
* Callback when PIN is verified and wallet is restored
|
|
47
|
+
* Called after successful verification and wallet restoration
|
|
48
|
+
*/
|
|
49
|
+
onVerified: () => void;
|
|
50
|
+
/**
|
|
51
|
+
* Optional callback when session is expired
|
|
52
|
+
* Called when access token is expired and user needs to re-login
|
|
53
|
+
*/
|
|
54
|
+
onSessionExpired?: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* Storage prefix for localStorage keys
|
|
57
|
+
* @default 'talkenkit_abc_'
|
|
58
|
+
*/
|
|
59
|
+
storagePrefix?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Return value from usePinVerification hook
|
|
63
|
+
*/
|
|
64
|
+
export interface UsePinVerificationReturn {
|
|
65
|
+
/** Loading state during PIN verification */
|
|
66
|
+
isVerifying: boolean;
|
|
67
|
+
/** Error message if PIN verification fails */
|
|
68
|
+
error: string;
|
|
69
|
+
/** Progress steps for wallet restoration */
|
|
70
|
+
progress: ProgressStep[];
|
|
71
|
+
/**
|
|
72
|
+
* Handle PIN verification
|
|
73
|
+
* @param pin - Plain text PIN from user input
|
|
74
|
+
* @throws Error if PIN verification fails
|
|
75
|
+
*/
|
|
76
|
+
handlePinVerify: (pin: string) => Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Reset verification state
|
|
79
|
+
* Clears errors and resets progress
|
|
80
|
+
*/
|
|
81
|
+
resetVerification: () => void;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Hook for managing PIN verification and wallet restoration flow
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const pinVerification = usePinVerification({
|
|
89
|
+
* email: 'user@example.com',
|
|
90
|
+
* onVerified: () => {
|
|
91
|
+
* console.log('Wallet unlocked!');
|
|
92
|
+
* connectWallet();
|
|
93
|
+
* },
|
|
94
|
+
* onSessionExpired: () => {
|
|
95
|
+
* console.log('Session expired, re-login required');
|
|
96
|
+
* showLoginScreen();
|
|
97
|
+
* }
|
|
98
|
+
* });
|
|
99
|
+
*
|
|
100
|
+
* // In PIN unlock modal
|
|
101
|
+
* <PinInput
|
|
102
|
+
* onSubmit={pinVerification.handlePinVerify}
|
|
103
|
+
* error={pinVerification.error}
|
|
104
|
+
* isLoading={pinVerification.isVerifying}
|
|
105
|
+
* />
|
|
106
|
+
*
|
|
107
|
+
* // Show progress
|
|
108
|
+
* <ProgressIndicator steps={pinVerification.progress} />
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @param props - Configuration options
|
|
112
|
+
* @returns PIN verification state and handlers
|
|
113
|
+
*/
|
|
114
|
+
export declare function usePinVerification(props: UsePinVerificationProps): UsePinVerificationReturn;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet generation progress step
|
|
3
|
+
* Tracks the status of each wallet generation stage
|
|
4
|
+
*/
|
|
5
|
+
export interface WalletGenerationProgress {
|
|
6
|
+
/** Human-readable label for the step */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Current status of the step */
|
|
9
|
+
status: 'pending' | 'active' | 'completed';
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Hook return value for wallet generation
|
|
13
|
+
*/
|
|
14
|
+
export interface UseWalletGenerationReturn {
|
|
15
|
+
/** Whether wallet generation is in progress */
|
|
16
|
+
isGenerating: boolean;
|
|
17
|
+
/** Current progress steps for UI display */
|
|
18
|
+
progress: WalletGenerationProgress[];
|
|
19
|
+
/** Current status message */
|
|
20
|
+
statusMessage: string;
|
|
21
|
+
/** Function to start wallet generation process */
|
|
22
|
+
generateWallets: (params: {
|
|
23
|
+
hashedPin: string;
|
|
24
|
+
email: string;
|
|
25
|
+
loginData: any;
|
|
26
|
+
}) => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Hook props for wallet generation configuration
|
|
30
|
+
*/
|
|
31
|
+
export interface UseWalletGenerationProps {
|
|
32
|
+
/** wagmi connectors for ABC wallet connection */
|
|
33
|
+
connectors: readonly any[];
|
|
34
|
+
/** wagmi connect function */
|
|
35
|
+
connect: (args: {
|
|
36
|
+
connector: any;
|
|
37
|
+
}) => void;
|
|
38
|
+
/** Callback when wallet generation completes successfully */
|
|
39
|
+
onSuccess: () => void;
|
|
40
|
+
/** Storage prefix for localStorage keys */
|
|
41
|
+
storagePrefix?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Custom hook for multi-chain wallet generation (EVM, Solana, Bitcoin)
|
|
45
|
+
*
|
|
46
|
+
* Handles the complete wallet generation flow:
|
|
47
|
+
* 1. EVM wallet generation via ABC WaaS /wapi/v2/mpc/wallets
|
|
48
|
+
* 2. EVM public key retrieval via /wapi/v2/mpc/wallets/info
|
|
49
|
+
* 3. Solana wallet generation via /v3/wallet/generate (with 409 recovery fallback)
|
|
50
|
+
* 4. Solana address retrieval via /wapi/v2/solana/wallet/getAddress
|
|
51
|
+
* 5. Bitcoin address generation via /wapi/v2/btc/address (derived from EVM pubkey)
|
|
52
|
+
* 6. Progress tracking for all 4 steps
|
|
53
|
+
* 7. localStorage persistence (auth_state, wallet, tokens, etc.)
|
|
54
|
+
* 8. PIN hash storage
|
|
55
|
+
* 9. wagmi connector connection
|
|
56
|
+
*
|
|
57
|
+
* @param props - Configuration for wallet generation
|
|
58
|
+
* @returns Hook state and functions for wallet generation
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const walletGeneration = useWalletGeneration({
|
|
63
|
+
* connectors,
|
|
64
|
+
* connect,
|
|
65
|
+
* onSuccess: () => {
|
|
66
|
+
* // Close modals, reset state
|
|
67
|
+
* onClose();
|
|
68
|
+
* },
|
|
69
|
+
* storagePrefix: 'talkenkit_abc_',
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* // Display progress
|
|
73
|
+
* <ProgressSteps steps={walletGeneration.progress} />
|
|
74
|
+
* <StatusMessage>{walletGeneration.statusMessage}</StatusMessage>
|
|
75
|
+
*
|
|
76
|
+
* // Trigger generation
|
|
77
|
+
* await walletGeneration.generateWallets({
|
|
78
|
+
* hashedPin,
|
|
79
|
+
* email: 'user@example.com',
|
|
80
|
+
* loginData: { access_token, refresh_token, expires_in }
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* - EVM wallet uses secp256k1 curve (Ethereum standard)
|
|
86
|
+
* - Solana wallet uses Ed25519 curve (Solana standard)
|
|
87
|
+
* - Bitcoin wallet derives address from EVM public key (same curve)
|
|
88
|
+
* - All wallets share the same PIN hash for encryption
|
|
89
|
+
* - Wallet data encrypted with PIN-based AES-256-GCM
|
|
90
|
+
* - Progress updates occur before each major step
|
|
91
|
+
* - Errors are logged and re-thrown for caller to handle
|
|
92
|
+
*/
|
|
93
|
+
export declare function useWalletGeneration(props: UseWalletGenerationProps): UseWalletGenerationReturn;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PinAuth Module Exports
|
|
3
|
+
*
|
|
4
|
+
* Centralized exports for PIN authentication components and hooks.
|
|
5
|
+
*
|
|
6
|
+
* Components:
|
|
7
|
+
* - PinAuthFlow: Orchestrator for all PIN authentication flows
|
|
8
|
+
*
|
|
9
|
+
* Hooks:
|
|
10
|
+
* - usePinCreation: PIN creation and confirmation logic
|
|
11
|
+
* - usePinVerification: PIN unlock and verification logic
|
|
12
|
+
* - useWalletGeneration: Multi-chain wallet generation
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
export { PinAuthFlow } from './PinAuthFlow';
|
|
17
|
+
export type { PinAuthFlowProps, PinAuthFlowHandle } from './PinAuthFlow';
|
|
18
|
+
export { usePinCreation } from './hooks/usePinCreation';
|
|
19
|
+
export type { UsePinCreationProps, UsePinCreationReturn, } from './hooks/usePinCreation';
|
|
20
|
+
export { usePinVerification } from './hooks/usePinVerification';
|
|
21
|
+
export type { UsePinVerificationProps, UsePinVerificationReturn, ProgressStep, ProgressStatus, } from './hooks/usePinVerification';
|
|
22
|
+
export { useWalletGeneration } from './hooks/useWalletGeneration';
|
|
23
|
+
export type { UseWalletGenerationProps, UseWalletGenerationReturn, WalletGenerationProgress, } from './hooks/useWalletGeneration';
|