toss-expo-sdk 0.1.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/LICENSE +20 -0
- package/README.md +292 -0
- package/lib/module/ble.js +103 -0
- package/lib/module/ble.js.map +1 -0
- package/lib/module/client/TossClient.js +324 -0
- package/lib/module/client/TossClient.js.map +1 -0
- package/lib/module/client/index.js +4 -0
- package/lib/module/client/index.js.map +1 -0
- package/lib/module/contexts/WalletContext.js +99 -0
- package/lib/module/contexts/WalletContext.js.map +1 -0
- package/lib/module/discovery.js +434 -0
- package/lib/module/discovery.js.map +1 -0
- package/lib/module/errors.js +47 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/examples/offlinePaymentFlow.js +234 -0
- package/lib/module/examples/offlinePaymentFlow.js.map +1 -0
- package/lib/module/index.js +32 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/intent.js +223 -0
- package/lib/module/intent.js.map +1 -0
- package/lib/module/intentManager.js +145 -0
- package/lib/module/intentManager.js.map +1 -0
- package/lib/module/internal/arciumHelper.js +50 -0
- package/lib/module/internal/arciumHelper.js.map +1 -0
- package/lib/module/nfc.js +54 -0
- package/lib/module/nfc.js.map +1 -0
- package/lib/module/noise.js +14 -0
- package/lib/module/noise.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/qr.js +57 -0
- package/lib/module/qr.js.map +1 -0
- package/lib/module/reconciliation.js +329 -0
- package/lib/module/reconciliation.js.map +1 -0
- package/lib/module/services/authService.js +205 -0
- package/lib/module/services/authService.js.map +1 -0
- package/lib/module/storage/secureStorage.js +89 -0
- package/lib/module/storage/secureStorage.js.map +1 -0
- package/lib/module/storage.js +16 -0
- package/lib/module/storage.js.map +1 -0
- package/lib/module/sync.js +64 -0
- package/lib/module/sync.js.map +1 -0
- package/lib/module/types/tossUser.js +41 -0
- package/lib/module/types/tossUser.js.map +1 -0
- package/lib/module/utils/nonceUtils.js +38 -0
- package/lib/module/utils/nonceUtils.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/__tests__/index.test.d.ts +1 -0
- package/lib/typescript/src/__tests__/index.test.d.ts.map +1 -0
- package/lib/typescript/src/__tests__/reconciliation.test.d.ts +6 -0
- package/lib/typescript/src/__tests__/reconciliation.test.d.ts.map +1 -0
- package/lib/typescript/src/ble.d.ts +10 -0
- package/lib/typescript/src/ble.d.ts.map +1 -0
- package/lib/typescript/src/client/TossClient.d.ts +110 -0
- package/lib/typescript/src/client/TossClient.d.ts.map +1 -0
- package/lib/typescript/src/client/index.d.ts +3 -0
- package/lib/typescript/src/client/index.d.ts.map +1 -0
- package/lib/typescript/src/contexts/WalletContext.d.ts +20 -0
- package/lib/typescript/src/contexts/WalletContext.d.ts.map +1 -0
- package/lib/typescript/src/discovery.d.ts +188 -0
- package/lib/typescript/src/discovery.d.ts.map +1 -0
- package/lib/typescript/src/errors.d.ts +27 -0
- package/lib/typescript/src/errors.d.ts.map +1 -0
- package/lib/typescript/src/examples/offlinePaymentFlow.d.ts +48 -0
- package/lib/typescript/src/examples/offlinePaymentFlow.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +13 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/intent.d.ts +84 -0
- package/lib/typescript/src/intent.d.ts.map +1 -0
- package/lib/typescript/src/intentManager.d.ts +46 -0
- package/lib/typescript/src/intentManager.d.ts.map +1 -0
- package/lib/typescript/src/internal/arciumHelper.d.ts +19 -0
- package/lib/typescript/src/internal/arciumHelper.d.ts.map +1 -0
- package/lib/typescript/src/nfc.d.ts +7 -0
- package/lib/typescript/src/nfc.d.ts.map +1 -0
- package/lib/typescript/src/noise.d.ts +5 -0
- package/lib/typescript/src/noise.d.ts.map +1 -0
- package/lib/typescript/src/qr.d.ts +6 -0
- package/lib/typescript/src/qr.d.ts.map +1 -0
- package/lib/typescript/src/reconciliation.d.ts +65 -0
- package/lib/typescript/src/reconciliation.d.ts.map +1 -0
- package/lib/typescript/src/services/authService.d.ts +55 -0
- package/lib/typescript/src/services/authService.d.ts.map +1 -0
- package/lib/typescript/src/storage/secureStorage.d.ts +7 -0
- package/lib/typescript/src/storage/secureStorage.d.ts.map +1 -0
- package/lib/typescript/src/storage.d.ts +4 -0
- package/lib/typescript/src/storage.d.ts.map +1 -0
- package/lib/typescript/src/sync.d.ts +40 -0
- package/lib/typescript/src/sync.d.ts.map +1 -0
- package/lib/typescript/src/types/tossUser.d.ts +39 -0
- package/lib/typescript/src/types/tossUser.d.ts.map +1 -0
- package/lib/typescript/src/utils/nonceUtils.d.ts +8 -0
- package/lib/typescript/src/utils/nonceUtils.d.ts.map +1 -0
- package/package.json +176 -0
- package/src/__tests__/index.test.tsx +1 -0
- package/src/__tests__/reconciliation.test.tsx +361 -0
- package/src/ble.ts +138 -0
- package/src/client/TossClient.ts +435 -0
- package/src/client/index.ts +2 -0
- package/src/contexts/WalletContext.tsx +127 -0
- package/src/discovery.ts +542 -0
- package/src/errors.ts +51 -0
- package/src/examples/offlinePaymentFlow.ts +331 -0
- package/src/index.tsx +61 -0
- package/src/intent.ts +328 -0
- package/src/intentManager.ts +164 -0
- package/src/internal/arciumHelper.ts +58 -0
- package/src/nfc.ts +57 -0
- package/src/noise.ts +9 -0
- package/src/qr.tsx +65 -0
- package/src/reconciliation.ts +421 -0
- package/src/services/authService.ts +238 -0
- package/src/storage/secureStorage.ts +100 -0
- package/src/storage.ts +17 -0
- package/src/sync.ts +101 -0
- package/src/types/tossUser.ts +81 -0
- package/src/utils/nonceUtils.ts +56 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
4
|
+
import { createIntent } from "../intent.js";
|
|
5
|
+
import { secureStoreIntent, getSecureIntent, getAllSecureIntents } from "../storage/secureStorage.js";
|
|
6
|
+
import { processIntentsForSync } from "../intentManager.js";
|
|
7
|
+
import { TossError, NetworkError, StorageError, ERROR_CODES } from "../errors.js";
|
|
8
|
+
import { createNonceAccount, getNonce } from "../utils/nonceUtils.js";
|
|
9
|
+
import { useWallet } from "../contexts/WalletContext.js";
|
|
10
|
+
import { syncToChain, checkSyncStatus } from "../sync.js";
|
|
11
|
+
import { detectConflicts, getReconciliationState } from "../reconciliation.js";
|
|
12
|
+
const DEFAULT_RETRY_OPTIONS = {
|
|
13
|
+
maxRetries: 3,
|
|
14
|
+
retryDelay: 1000 // 1 second
|
|
15
|
+
};
|
|
16
|
+
export class TossClient {
|
|
17
|
+
static createClient(config) {
|
|
18
|
+
return new TossClient(config);
|
|
19
|
+
}
|
|
20
|
+
constructor(config) {
|
|
21
|
+
this.config = {
|
|
22
|
+
projectId: config.projectId,
|
|
23
|
+
mode: config.mode || 'devnet',
|
|
24
|
+
privateTransactions: config.privateTransactions || false,
|
|
25
|
+
provider: config.provider,
|
|
26
|
+
sync: config.sync || {
|
|
27
|
+
syncBackupDb: false
|
|
28
|
+
},
|
|
29
|
+
rpcUrl: config.rpcUrl || this.getDefaultRpcUrl(config.mode || 'devnet'),
|
|
30
|
+
maxRetries: config.maxRetries ?? DEFAULT_RETRY_OPTIONS.maxRetries,
|
|
31
|
+
retryDelay: config.retryDelay ?? DEFAULT_RETRY_OPTIONS.retryDelay,
|
|
32
|
+
feePayer: config.feePayer
|
|
33
|
+
};
|
|
34
|
+
this.connection = new Connection(this.config.rpcUrl, 'confirmed');
|
|
35
|
+
this.walletContext = useWallet();
|
|
36
|
+
if (!this.walletContext) {
|
|
37
|
+
throw new Error('TossClient must be used within a WalletProvider');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
getDefaultRpcUrl(network) {
|
|
41
|
+
const urls = {
|
|
42
|
+
'devnet': 'https://api.devnet.solana.com',
|
|
43
|
+
'testnet': 'https://api.testnet.solana.com',
|
|
44
|
+
'mainnet-beta': 'https://api.mainnet-beta.solana.com'
|
|
45
|
+
};
|
|
46
|
+
return urls[network] || urls.devnet;
|
|
47
|
+
}
|
|
48
|
+
async withRetry(fn, context) {
|
|
49
|
+
let lastError = null;
|
|
50
|
+
const {
|
|
51
|
+
maxRetries,
|
|
52
|
+
retryDelay
|
|
53
|
+
} = this.config;
|
|
54
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
55
|
+
try {
|
|
56
|
+
return await fn();
|
|
57
|
+
} catch (error) {
|
|
58
|
+
lastError = error;
|
|
59
|
+
|
|
60
|
+
// Don't retry on validation errors
|
|
61
|
+
if (error instanceof TossError) {
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Exponential backoff
|
|
66
|
+
if (attempt < maxRetries) {
|
|
67
|
+
const delay = retryDelay * Math.pow(2, attempt - 1);
|
|
68
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
throw new NetworkError(`Failed after ${maxRetries} attempts: ${lastError?.message}`, {
|
|
73
|
+
context,
|
|
74
|
+
cause: lastError
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Initialize a nonce account for durable transactions
|
|
80
|
+
* @param amount SOL amount to fund the nonce account with (default: 1 SOL)
|
|
81
|
+
* @returns Object containing nonce account and authority public keys
|
|
82
|
+
*/
|
|
83
|
+
async initializeNonceAccount(amount = 1) {
|
|
84
|
+
if (!this.config.feePayer) {
|
|
85
|
+
throw new Error('Fee payer keypair is required for nonce account creation');
|
|
86
|
+
}
|
|
87
|
+
const {
|
|
88
|
+
nonceAccount,
|
|
89
|
+
nonceAuth
|
|
90
|
+
} = await createNonceAccount(this.connection, this.config.feePayer, undefined, amount * 1e9 // Convert SOL to lamports
|
|
91
|
+
);
|
|
92
|
+
this.nonceAccount = nonceAccount;
|
|
93
|
+
this.nonceAuth = nonceAuth;
|
|
94
|
+
return {
|
|
95
|
+
nonceAccount: nonceAccount.publicKey.toBase58(),
|
|
96
|
+
nonceAuth: nonceAuth.toBase58()
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get the current nonce value from the nonce account
|
|
102
|
+
* @returns The current nonce value as a base58 string
|
|
103
|
+
*/
|
|
104
|
+
async getCurrentNonce() {
|
|
105
|
+
if (!this.nonceAccount) {
|
|
106
|
+
throw new Error('Nonce account not initialized. Call initializeNonceAccount() first.');
|
|
107
|
+
}
|
|
108
|
+
return getNonce(this.connection, this.nonceAccount.publicKey);
|
|
109
|
+
}
|
|
110
|
+
async createIntent(sender, recipient, amount, feePayer, options = {}) {
|
|
111
|
+
return this.withRetry(async () => {
|
|
112
|
+
try {
|
|
113
|
+
if (!this.connection) {
|
|
114
|
+
throw new TossError('Connection not initialized', ERROR_CODES.NETWORK_ERROR);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Handle 'current' sender to use the wallet context
|
|
118
|
+
const senderKeypair = sender === 'current' ? this.walletContext.keypair : sender;
|
|
119
|
+
if (!senderKeypair) {
|
|
120
|
+
throw new TossError('No sender keypair provided and no wallet is connected', ERROR_CODES.SIGNATURE_VERIFICATION_FAILED);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Convert string addresses to PublicKey if needed
|
|
124
|
+
const recipientPubkey = typeof recipient === 'string' ? new PublicKey(recipient) : recipient;
|
|
125
|
+
const feePayerPubkey = feePayer ? typeof feePayer === 'string' ? new PublicKey(feePayer) : feePayer : senderKeypair.publicKey;
|
|
126
|
+
|
|
127
|
+
// Set up nonce account and auth if using durable nonce
|
|
128
|
+
if (options.useDurableNonce && this.nonceAccount && this.nonceAuth) {
|
|
129
|
+
// nonce account and auth are passed via options to createIntent
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Get the latest blockhash (no need to store it as it's handled internally)
|
|
133
|
+
await this.connection.getLatestBlockhash();
|
|
134
|
+
const intent = await createIntent(senderKeypair, recipientPubkey, amount, this.connection, {
|
|
135
|
+
...options,
|
|
136
|
+
feePayer: feePayerPubkey,
|
|
137
|
+
nonceAccount: options.useDurableNonce ? this.nonceAccount : undefined,
|
|
138
|
+
nonceAuth: options.useDurableNonce ? this.nonceAuth : undefined
|
|
139
|
+
});
|
|
140
|
+
await secureStoreIntent(intent);
|
|
141
|
+
return intent;
|
|
142
|
+
} catch (error) {
|
|
143
|
+
if (error instanceof TossError) throw error;
|
|
144
|
+
throw new TossError('Failed to create intent', ERROR_CODES.TRANSACTION_FAILED, {
|
|
145
|
+
cause: error
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}, 'createIntent');
|
|
149
|
+
}
|
|
150
|
+
async getIntents() {
|
|
151
|
+
return this.withRetry(async () => {
|
|
152
|
+
try {
|
|
153
|
+
return await getAllSecureIntents();
|
|
154
|
+
} catch (error) {
|
|
155
|
+
if (error instanceof TossError) throw error;
|
|
156
|
+
throw new StorageError('Failed to retrieve intents', {
|
|
157
|
+
cause: error
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}, 'getIntents');
|
|
161
|
+
}
|
|
162
|
+
async updateIntentStatus(intentId, status, error) {
|
|
163
|
+
return this.withRetry(async () => {
|
|
164
|
+
try {
|
|
165
|
+
const intent = await getSecureIntent(intentId);
|
|
166
|
+
if (!intent) return null;
|
|
167
|
+
|
|
168
|
+
// Ensure updatedAt is a number (timestamp)
|
|
169
|
+
const updatedAt = Date.now();
|
|
170
|
+
const updatedIntent = {
|
|
171
|
+
...intent,
|
|
172
|
+
status,
|
|
173
|
+
updatedAt,
|
|
174
|
+
...(error ? {
|
|
175
|
+
error
|
|
176
|
+
} : {})
|
|
177
|
+
};
|
|
178
|
+
await secureStoreIntent(updatedIntent);
|
|
179
|
+
return updatedIntent;
|
|
180
|
+
} catch (error) {
|
|
181
|
+
if (error instanceof TossError) throw error;
|
|
182
|
+
throw new StorageError('Failed to update intent status', {
|
|
183
|
+
cause: error,
|
|
184
|
+
intentId,
|
|
185
|
+
status
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}, 'updateIntentStatus');
|
|
189
|
+
}
|
|
190
|
+
async sync() {
|
|
191
|
+
return this.withRetry(async () => {
|
|
192
|
+
try {
|
|
193
|
+
const intents = await getAllSecureIntents();
|
|
194
|
+
if (!this.config.sync?.syncBackupDb || !this.config.sync.dbUrl) {
|
|
195
|
+
return intents;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Process intents for sync and update their statuses
|
|
199
|
+
const processedIntents = await processIntentsForSync(intents, this.connection);
|
|
200
|
+
|
|
201
|
+
// Save updated intents
|
|
202
|
+
await Promise.all(processedIntents.map(intent => secureStoreIntent(intent)));
|
|
203
|
+
return processedIntents;
|
|
204
|
+
} catch (error) {
|
|
205
|
+
if (error instanceof TossError) throw error;
|
|
206
|
+
throw new NetworkError('Failed to sync intents', {
|
|
207
|
+
cause: error
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}, 'sync');
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Full synchronisation with Solana blockchain (TOSS Section 9)
|
|
215
|
+
*
|
|
216
|
+
* Performs complete reconciliation:
|
|
217
|
+
* - Detects conflicts with onchain state
|
|
218
|
+
* - Settles all pending intents
|
|
219
|
+
* - Updates local state deterministically
|
|
220
|
+
*
|
|
221
|
+
* @returns Complete sync results including settlements, conflicts, and final state
|
|
222
|
+
*/
|
|
223
|
+
async fullSync() {
|
|
224
|
+
return this.withRetry(async () => {
|
|
225
|
+
try {
|
|
226
|
+
return await syncToChain(this.connection, this.config.feePayer?.publicKey);
|
|
227
|
+
} catch (error) {
|
|
228
|
+
if (error instanceof TossError) throw error;
|
|
229
|
+
throw new NetworkError('Full sync failed', {
|
|
230
|
+
cause: error
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}, 'fullSync');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Check synchronisation status without settling
|
|
238
|
+
*
|
|
239
|
+
* Lightweight operation to query current reconciliation state
|
|
240
|
+
* without committing any settlements to the blockchain.
|
|
241
|
+
*/
|
|
242
|
+
async checkSyncStatus() {
|
|
243
|
+
return this.withRetry(async () => {
|
|
244
|
+
return await checkSyncStatus(this.connection);
|
|
245
|
+
}, 'checkSyncStatus');
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Detect conflicts between local intents and onchain state
|
|
250
|
+
*
|
|
251
|
+
* Useful for monitoring and alerting users to potential issues
|
|
252
|
+
* before attempting settlement.
|
|
253
|
+
*/
|
|
254
|
+
async detectIntentConflicts() {
|
|
255
|
+
return this.withRetry(async () => {
|
|
256
|
+
return await detectConflicts(this.connection);
|
|
257
|
+
}, 'detectIntentConflicts');
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Get current reconciliation state
|
|
262
|
+
*
|
|
263
|
+
* Returns summary of processed, failed, and conflicting intents
|
|
264
|
+
* for UI updates or logging.
|
|
265
|
+
*/
|
|
266
|
+
async getReconciliationStatus() {
|
|
267
|
+
return this.withRetry(async () => {
|
|
268
|
+
return await getReconciliationState(this.connection);
|
|
269
|
+
}, 'getReconciliationStatus');
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Create an intent from the current user's wallet
|
|
274
|
+
*/
|
|
275
|
+
async createUserIntent(recipient, amount, options = {}) {
|
|
276
|
+
if (!this.walletContext.user) {
|
|
277
|
+
throw new TossError('No user is currently signed in', ERROR_CODES.SIGNATURE_VERIFICATION_FAILED);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Ensure wallet is unlocked
|
|
281
|
+
if (!this.walletContext.isUnlocked) {
|
|
282
|
+
const unlocked = await this.walletContext.unlockWallet();
|
|
283
|
+
if (!unlocked) {
|
|
284
|
+
throw new TossError('Wallet is locked', ERROR_CODES.SIGNATURE_VERIFICATION_FAILED);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const recipientPubkey = typeof recipient === 'string' ? new PublicKey(recipient) : recipient;
|
|
288
|
+
return this.createIntent('current',
|
|
289
|
+
// This will use the wallet context's keypair
|
|
290
|
+
recipientPubkey, amount, this.walletContext.user.wallet.publicKey, {
|
|
291
|
+
...options,
|
|
292
|
+
memo: options.memo || `TOSS transfer to ${recipientPubkey.toBase58()}`
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Get the current user's wallet address
|
|
298
|
+
*/
|
|
299
|
+
getCurrentUserAddress() {
|
|
300
|
+
return this.walletContext.user?.wallet.publicKey.toString() || null;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Check if the wallet is currently unlocked
|
|
305
|
+
*/
|
|
306
|
+
isWalletUnlocked() {
|
|
307
|
+
return this.walletContext.isUnlocked;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Lock the wallet
|
|
312
|
+
*/
|
|
313
|
+
async lockWallet() {
|
|
314
|
+
await this.walletContext.lockWallet();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Sign out the current user
|
|
319
|
+
*/
|
|
320
|
+
async signOut() {
|
|
321
|
+
await this.walletContext.signOut();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
//# sourceMappingURL=TossClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Connection","PublicKey","createIntent","secureStoreIntent","getSecureIntent","getAllSecureIntents","processIntentsForSync","TossError","NetworkError","StorageError","ERROR_CODES","createNonceAccount","getNonce","useWallet","syncToChain","checkSyncStatus","detectConflicts","getReconciliationState","DEFAULT_RETRY_OPTIONS","maxRetries","retryDelay","TossClient","createClient","config","constructor","projectId","mode","privateTransactions","provider","sync","syncBackupDb","rpcUrl","getDefaultRpcUrl","feePayer","connection","walletContext","Error","network","urls","devnet","withRetry","fn","context","lastError","attempt","error","delay","Math","pow","Promise","resolve","setTimeout","message","cause","initializeNonceAccount","amount","nonceAccount","nonceAuth","undefined","publicKey","toBase58","getCurrentNonce","sender","recipient","options","NETWORK_ERROR","senderKeypair","keypair","SIGNATURE_VERIFICATION_FAILED","recipientPubkey","feePayerPubkey","useDurableNonce","getLatestBlockhash","intent","TRANSACTION_FAILED","getIntents","updateIntentStatus","intentId","status","updatedAt","Date","now","updatedIntent","intents","dbUrl","processedIntents","all","map","fullSync","detectIntentConflicts","getReconciliationStatus","createUserIntent","user","isUnlocked","unlocked","unlockWallet","wallet","memo","getCurrentUserAddress","toString","isWalletUnlocked","lockWallet","signOut"],"sourceRoot":"../../../src","sources":["client/TossClient.ts"],"mappings":";;AAAA,SAASA,UAAU,EAAWC,SAAS,QAAQ,iBAAiB;AAEhE,SAASC,YAAY,QAAQ,cAAW;AACxC,SACEC,iBAAiB,EACjBC,eAAe,EACfC,mBAAmB,QACd,6BAA0B;AACjC,SAASC,qBAAqB,QAAQ,qBAAkB;AACxD,SAASC,SAAS,EAAEC,YAAY,EAAEC,YAAY,EAAEC,WAAW,QAAQ,cAAW;AAC9E,SAASC,kBAAkB,EAAEC,QAAQ,QAAQ,wBAAqB;AAClE,SAASC,SAAS,QAAQ,8BAA2B;AACrD,SAASC,WAAW,EAAEC,eAAe,QAAyB,YAAS;AACvE,SAASC,eAAe,EAAEC,sBAAsB,QAAQ,sBAAmB;AAiB3E,MAAMC,qBAAqB,GAAG;EAC5BC,UAAU,EAAE,CAAC;EACbC,UAAU,EAAE,IAAI,CAAE;AACpB,CAAC;AAED,OAAO,MAAMC,UAAU,CAAC;EAUtB,OAAOC,YAAYA,CAACC,MAAkB,EAAc;IAClD,OAAO,IAAIF,UAAU,CAACE,MAAM,CAAC;EAC/B;EAEQC,WAAWA,CAACD,MAAkB,EAAE;IACtC,IAAI,CAACA,MAAM,GAAG;MACZE,SAAS,EAAEF,MAAM,CAACE,SAAS;MAC3BC,IAAI,EAAEH,MAAM,CAACG,IAAI,IAAI,QAAQ;MAC7BC,m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AAE;MAClC,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAAC3D,aAAa,CAAC4D,YAAY,CAAC,CAAC;MACxD,IAAI,CAACD,QAAQ,EAAE;QACb,MAAM,IAAIvF,SAAS,CACjB,kBAAkB,EAClBG,WAAW,CAAC0D,6BACd,CAAC;MACH;IACF;IAEA,MAAMC,eAAe,GACnB,OAAON,SAAS,KAAK,QAAQ,GAAG,IAAI9D,SAAS,CAAC8D,SAAS,CAAC,GAAGA,SAAS;IAEtE,OAAO,IAAI,CAAC7D,YAAY,CACtB,SAAS;IAAE;IACXmE,eAAe,EACfd,MAAM,EACN,IAAI,CAACpB,aAAa,CAACyD,IAAI,CAACI,MAAM,CAACrC,SAAS,EACxC;MACE,GAAGK,OAAO;MACViC,IAAI,EAAEjC,OAAO,CAACiC,IAAI,IAAI,oBAAoB5B,eAAe,CAACT,QAAQ,CAAC,CAAC;IACtE,CACF,CAAC;EACH;;EAEA;AACF;AACA;EACEsC,qBAAqBA,CAAA,EAAkB;IACrC,OAAO,IAAI,CAAC/D,aAAa,CAACyD,IAAI,EAAEI,MAAM,CAACrC,SAAS,CAACwC,QAAQ,CAAC,CAAC,IAAI,IAAI;EACrE;;EAEA;AACF;AACA;EACEC,gBAAgBA,CAAA,EAAY;IAC1B,OAAO,IAAI,CAACjE,aAAa,CAAC0D,UAAU;EACtC;;EAEA;AACF;AACA;EACE,MAAMQ,UAAUA,CAAA,EAAkB;IAChC,MAAM,IAAI,CAAClE,aAAa,CAACkE,UAAU,CAAC,CAAC;EACvC;;EAEA;AACF;AACA;EACE,MAAMC,OAAOA,CAAA,EAAkB;IAC7B,MAAM,IAAI,CAACnE,aAAa,CAACmE,OAAO,CAAC,CAAC;EACpC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["client/index.ts"],"mappings":";;AAAA,cAAc,iBAAc","ignoreList":[]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, useState, useEffect } from 'react';
|
|
4
|
+
import { AuthService } from "../services/authService.js";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const WalletContext = /*#__PURE__*/createContext(undefined);
|
|
7
|
+
export const WalletProvider = ({
|
|
8
|
+
children
|
|
9
|
+
}) => {
|
|
10
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
11
|
+
const [isUnlocked, setIsUnlocked] = useState(false);
|
|
12
|
+
const [user, setUser] = useState(null);
|
|
13
|
+
const [keypair, setKeypair] = useState(null);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const checkAuth = async () => {
|
|
16
|
+
try {
|
|
17
|
+
const session = await AuthService.getSession();
|
|
18
|
+
if (session) {
|
|
19
|
+
// In a real app, you'd fetch the user from your backend
|
|
20
|
+
const {
|
|
21
|
+
user
|
|
22
|
+
} = await AuthService.signInWithWallet(session.walletAddress);
|
|
23
|
+
setUser(user);
|
|
24
|
+
setIsUnlocked(await AuthService.isWalletUnlocked());
|
|
25
|
+
}
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('Auth check failed:', error);
|
|
28
|
+
} finally {
|
|
29
|
+
setIsInitialized(true);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
checkAuth();
|
|
33
|
+
}, []);
|
|
34
|
+
const unlockWallet = async () => {
|
|
35
|
+
try {
|
|
36
|
+
// Biometric authentication REQUIRED - throws if not authorized
|
|
37
|
+
const unlockedKeypair = await AuthService.unlockWalletWithBiometrics();
|
|
38
|
+
if (unlockedKeypair) {
|
|
39
|
+
// Keypair held ONLY in React state memory (NOT persisted to disk)
|
|
40
|
+
setKeypair(unlockedKeypair);
|
|
41
|
+
setIsUnlocked(true);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Biometric authentication failed:', error);
|
|
47
|
+
setIsUnlocked(false);
|
|
48
|
+
setKeypair(null);
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const lockWallet = async () => {
|
|
53
|
+
// Clear keypair from memory (from React state)
|
|
54
|
+
// Encrypted keypair remains stored securely (requires biometric to re-unlock)
|
|
55
|
+
setKeypair(null);
|
|
56
|
+
setIsUnlocked(false);
|
|
57
|
+
};
|
|
58
|
+
const signIn = async (walletAddress, isTemporary = false) => {
|
|
59
|
+
const {
|
|
60
|
+
user
|
|
61
|
+
} = await AuthService.signInWithWallet(walletAddress, isTemporary);
|
|
62
|
+
setUser(user);
|
|
63
|
+
setIsUnlocked(true);
|
|
64
|
+
};
|
|
65
|
+
const signOut = async () => {
|
|
66
|
+
// Clear session from storage
|
|
67
|
+
await AuthService.signOut();
|
|
68
|
+
|
|
69
|
+
// Clear all memory (state)
|
|
70
|
+
setUser(null);
|
|
71
|
+
setKeypair(null); // Remove from RAM
|
|
72
|
+
setIsUnlocked(false);
|
|
73
|
+
|
|
74
|
+
// NOTE: Encrypted keypair remains in SecureStore
|
|
75
|
+
// It can only be accessed again with biometric authentication
|
|
76
|
+
};
|
|
77
|
+
return /*#__PURE__*/_jsx(WalletContext.Provider, {
|
|
78
|
+
value: {
|
|
79
|
+
isInitialized,
|
|
80
|
+
isUnlocked,
|
|
81
|
+
user,
|
|
82
|
+
keypair,
|
|
83
|
+
unlockWallet,
|
|
84
|
+
lockWallet,
|
|
85
|
+
signIn,
|
|
86
|
+
signOut
|
|
87
|
+
},
|
|
88
|
+
children: children
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
export const useWallet = () => {
|
|
92
|
+
const context = useContext(WalletContext);
|
|
93
|
+
if (context === undefined) {
|
|
94
|
+
throw new Error('useWallet must be used within a WalletProvider');
|
|
95
|
+
}
|
|
96
|
+
return context;
|
|
97
|
+
};
|
|
98
|
+
export default WalletContext;
|
|
99
|
+
//# sourceMappingURL=WalletContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","useContext","useState","useEffect","AuthService","jsx","_jsx","WalletContext","undefined","WalletProvider","children","isInitialized","setIsInitialized","isUnlocked","setIsUnlocked","user","setUser","keypair","setKeypair","checkAuth","session","getSession","signInWithWallet","walletAddress","isWalletUnlocked","error","console","unlockWallet","unlockedKeypair","unlockWalletWithBiometrics","lockWallet","signIn","isTemporary","signOut","Provider","value","useWallet","context","Error"],"sourceRoot":"../../../src","sources":["contexts/WalletContext.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAGtE,SAASC,WAAW,QAAQ,4BAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AActD,MAAMC,aAAa,gBAAGP,aAAa,CAAgCQ,SAAS,CAAC;AAE7E,OAAO,MAAMC,cAAiD,GAAGA,CAAC;EAChEC;AACF,CAAC,KAAK;EACJ,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGV,QAAQ,CAAC,KAAK,CAAC;EACzD,MAAM,CAACW,UAAU,EAAEC,aAAa,CAAC,GAAGZ,QAAQ,CAAC,KAAK,CAAC;EACnD,MAAM,CAACa,IAAI,EAAEC,OAAO,CAAC,GAAGd,QAAQ,CAAkB,IAAI,CAAC;EACvD,MAAM,CAACe,OAAO,EAAEC,UAAU,CAAC,GAAGhB,QAAQ,CAAiB,IAAI,CAAC;EAE5DC,SAAS,CAAC,MAAM;IACd,MAAMgB,SAAS,GAAG,MAAAA,CAAA,KAAY;MAC5B,IAAI;QACF,MAAMC,OAAO,GAAG,MAAMhB,WAAW,CAACiB,UAAU,CAAC,CAAC;QAC9C,IAAID,OAAO,EAAE;UACX;UACA,MAAM;YAAEL;UAAK,CAAC,GAAG,MAAMX,WAAW,CAACkB,gBAAgB,CACjDF,OAAO,CAACG,aACV,CAAC;UACDP,OAAO,CAACD,IAAI,CAAC;UACbD,aAAa,CAAC,MAAMV,WAAW,CAACoB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