toss-expo-sdk 0.1.2 → 1.0.1
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/README.md +368 -15
- package/lib/module/ble.js +59 -4
- package/lib/module/ble.js.map +1 -1
- package/lib/module/client/BLETransactionHandler.js +277 -0
- package/lib/module/client/BLETransactionHandler.js.map +1 -0
- package/lib/module/client/NonceAccountManager.js +364 -0
- package/lib/module/client/NonceAccountManager.js.map +1 -0
- package/lib/module/client/TossClient.js +1 -1
- package/lib/module/client/TossClient.js.map +1 -1
- package/lib/module/hooks/useOfflineBLETransactions.js +314 -0
- package/lib/module/hooks/useOfflineBLETransactions.js.map +1 -0
- package/lib/module/index.js +12 -8
- package/lib/module/index.js.map +1 -1
- package/lib/module/intent.js +129 -0
- package/lib/module/intent.js.map +1 -1
- package/lib/module/noise.js +175 -0
- package/lib/module/noise.js.map +1 -1
- package/lib/module/reconciliation.js +155 -0
- package/lib/module/reconciliation.js.map +1 -1
- package/lib/module/services/authService.js +164 -1
- package/lib/module/services/authService.js.map +1 -1
- package/lib/module/storage/secureStorage.js +102 -0
- package/lib/module/storage/secureStorage.js.map +1 -1
- package/lib/module/sync.js +25 -1
- package/lib/module/sync.js.map +1 -1
- package/lib/module/types/nonceAccount.js +2 -0
- package/lib/module/types/nonceAccount.js.map +1 -0
- package/lib/module/types/tossUser.js +16 -1
- package/lib/module/types/tossUser.js.map +1 -1
- package/lib/typescript/src/__tests__/solana-program-simple.test.d.ts +8 -0
- package/lib/typescript/src/__tests__/solana-program-simple.test.d.ts.map +1 -0
- package/lib/typescript/src/ble.d.ts +31 -2
- package/lib/typescript/src/ble.d.ts.map +1 -1
- package/lib/typescript/src/client/BLETransactionHandler.d.ts +98 -0
- package/lib/typescript/src/client/BLETransactionHandler.d.ts.map +1 -0
- package/lib/typescript/src/client/NonceAccountManager.d.ts +82 -0
- package/lib/typescript/src/client/NonceAccountManager.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useOfflineBLETransactions.d.ts +91 -0
- package/lib/typescript/src/hooks/useOfflineBLETransactions.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/intent.d.ts +15 -0
- package/lib/typescript/src/intent.d.ts.map +1 -1
- package/lib/typescript/src/noise.d.ts +62 -0
- package/lib/typescript/src/noise.d.ts.map +1 -1
- package/lib/typescript/src/reconciliation.d.ts +6 -0
- package/lib/typescript/src/reconciliation.d.ts.map +1 -1
- package/lib/typescript/src/services/authService.d.ts +26 -1
- package/lib/typescript/src/services/authService.d.ts.map +1 -1
- package/lib/typescript/src/storage/secureStorage.d.ts +16 -0
- package/lib/typescript/src/storage/secureStorage.d.ts.map +1 -1
- package/lib/typescript/src/sync.d.ts +6 -1
- package/lib/typescript/src/sync.d.ts.map +1 -1
- package/lib/typescript/src/types/nonceAccount.d.ts +59 -0
- package/lib/typescript/src/types/nonceAccount.d.ts.map +1 -0
- package/lib/typescript/src/types/tossUser.d.ts +16 -0
- package/lib/typescript/src/types/tossUser.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/solana-program-simple.test.ts +256 -0
- package/src/ble.ts +105 -4
- package/src/client/BLETransactionHandler.ts +364 -0
- package/src/client/NonceAccountManager.ts +444 -0
- package/src/client/TossClient.ts +1 -1
- package/src/hooks/useOfflineBLETransactions.ts +438 -0
- package/src/index.tsx +40 -6
- package/src/intent.ts +166 -0
- package/src/noise.ts +238 -0
- package/src/reconciliation.ts +184 -0
- package/src/services/authService.ts +188 -1
- package/src/storage/secureStorage.ts +138 -0
- package/src/sync.ts +40 -0
- package/src/types/nonceAccount.ts +75 -0
- package/src/types/tossUser.ts +35 -2
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Device } from 'react-native-ble-plx';
|
|
2
|
+
import { Connection } from '@solana/web3.js';
|
|
3
|
+
import type { SolanaIntent } from '../intent';
|
|
4
|
+
import type { OfflineTransaction } from '../types/nonceAccount';
|
|
5
|
+
import type { TossUser } from '../types/tossUser';
|
|
6
|
+
import { NonceAccountManager } from '../client/NonceAccountManager';
|
|
7
|
+
/**
|
|
8
|
+
* State for BLE transaction transmission
|
|
9
|
+
*/
|
|
10
|
+
export interface BLETransmissionState {
|
|
11
|
+
isTransmitting: boolean;
|
|
12
|
+
progress: {
|
|
13
|
+
sentFragments: number;
|
|
14
|
+
totalFragments: number;
|
|
15
|
+
messageId?: string;
|
|
16
|
+
};
|
|
17
|
+
error?: string;
|
|
18
|
+
lastSent?: {
|
|
19
|
+
messageId: string;
|
|
20
|
+
timestamp: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* State for offline transaction preparation
|
|
25
|
+
*/
|
|
26
|
+
export interface OfflineTransactionState {
|
|
27
|
+
isPreparing: boolean;
|
|
28
|
+
transaction?: OfflineTransaction;
|
|
29
|
+
error?: string;
|
|
30
|
+
isReady: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* useOfflineTransaction Hook
|
|
34
|
+
* Manages offline transaction creation with nonce accounts
|
|
35
|
+
* Handles biometric protection and secure storage
|
|
36
|
+
*/
|
|
37
|
+
export declare function useOfflineTransaction(user: TossUser, connection: Connection): {
|
|
38
|
+
createOfflineTransaction: (instructions: any[], metadata?: {
|
|
39
|
+
description?: string;
|
|
40
|
+
tags?: string[];
|
|
41
|
+
}) => Promise<OfflineTransaction | null>;
|
|
42
|
+
clearTransaction: () => void;
|
|
43
|
+
nonceManager: NonceAccountManager | null;
|
|
44
|
+
isPreparing: boolean;
|
|
45
|
+
transaction?: OfflineTransaction;
|
|
46
|
+
error?: string;
|
|
47
|
+
isReady: boolean;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* useBLETransactionTransmission Hook
|
|
51
|
+
* Handles secure BLE transmission of fragmented transactions
|
|
52
|
+
* with Noise Protocol encryption
|
|
53
|
+
*/
|
|
54
|
+
export declare function useBLETransactionTransmission(platform?: 'android' | 'ios'): {
|
|
55
|
+
sendTransactionBLE: (device: Device, transaction: OfflineTransaction | SolanaIntent, sendFn: (deviceId: string, characteristicUUID: string, data: Buffer) => Promise<void>, noiseEncryptFn?: (data: Uint8Array) => Promise<any>, isIntent?: boolean) => Promise<boolean>;
|
|
56
|
+
receiveTransactionFragment: (fragment: any, noiseDecryptFn?: (encrypted: any) => Promise<Uint8Array>) => Promise<{
|
|
57
|
+
complete: boolean;
|
|
58
|
+
transaction?: OfflineTransaction | SolanaIntent;
|
|
59
|
+
progress: {
|
|
60
|
+
received: number;
|
|
61
|
+
total: number;
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
64
|
+
getMTUConfig: () => import("..").BLEMTUConfig;
|
|
65
|
+
setMTUConfig: (config: Partial<any>) => void;
|
|
66
|
+
isTransmitting: boolean;
|
|
67
|
+
progress: {
|
|
68
|
+
sentFragments: number;
|
|
69
|
+
totalFragments: number;
|
|
70
|
+
messageId?: string;
|
|
71
|
+
};
|
|
72
|
+
error?: string;
|
|
73
|
+
lastSent?: {
|
|
74
|
+
messageId: string;
|
|
75
|
+
timestamp: number;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* useNonceAccountManagement Hook
|
|
80
|
+
* Manages nonce account lifecycle: creation, renewal, revocation
|
|
81
|
+
*/
|
|
82
|
+
export declare function useNonceAccountManagement(user: TossUser, connection: Connection): {
|
|
83
|
+
isLoading: boolean;
|
|
84
|
+
error: string | undefined;
|
|
85
|
+
createNonceAccount: (userKeypair: any) => Promise<TossUser | null>;
|
|
86
|
+
renewNonceAccount: () => Promise<import("..").NonceAccountInfo | null>;
|
|
87
|
+
revokeNonceAccount: () => Promise<TossUser | null>;
|
|
88
|
+
isNonceAccountValid: () => boolean;
|
|
89
|
+
hasNonceAccount: boolean;
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=useOfflineBLETransactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOfflineBLETransactions.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useOfflineBLETransactions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EACV,kBAAkB,EAEnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGpE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE;QACR,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU;6CA4BxD,GAAG,EAAE,aACR;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,KACnD,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;;;iBAzC1B,OAAO;kBACN,kBAAkB;YACxB,MAAM;aACL,OAAO;EAyIjB;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,GAAE,SAAS,GAAG,KAAiB;iCAiB3B,MAAM,eACD,kBAAkB,GAAG,YAAY,UACtC,CACN,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,EAC1B,IAAI,EAAE,MAAM,KACT,OAAO,CAAC,IAAI,CAAC,mBACD,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,GAAG,CAAC,aACzC,OAAO,KAChB,OAAO,CAAC,OAAO,CAAC;2CA2DP,GAAG,mBACI,CAAC,SAAS,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,CAAC,KACvD,OAAO,CAAC;QACT,QAAQ,EAAE,OAAO,CAAC;QAClB,WAAW,CAAC,EAAE,kBAAkB,GAAG,YAAY,CAAC;QAChD,QAAQ,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;KAC/C,CAAC;;2BAuCsC,OAAO,CAAC,GAAG,CAAC;oBAvStC,OAAO;cACb;QACR,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB;YACO,MAAM;eACH;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB;EAwSF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,UAAU;;;sCAUA,GAAG;;;;;EAgG1B"}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
export { createIntent, createUserIntent, createSignedIntent, type SolanaIntent, type IntentStatus, } from './intent';
|
|
1
|
+
export { createIntent, createUserIntent, createSignedIntent, createOfflineIntent, type SolanaIntent, type IntentStatus, } from './intent';
|
|
2
|
+
export { NonceAccountManager } from './client/NonceAccountManager';
|
|
3
|
+
export type { NonceAccountInfo, NonceAccountCacheEntry, CreateNonceAccountOptions, OfflineTransaction, } from './types/nonceAccount';
|
|
4
|
+
export { BLETransactionHandler } from './client/BLETransactionHandler';
|
|
5
|
+
export type { BLEFragment, EncryptedBLEMessage, BLEMTUConfig, } from './client/BLETransactionHandler';
|
|
6
|
+
export { useOfflineTransaction, useBLETransactionTransmission, useNonceAccountManagement, } from './hooks/useOfflineBLETransactions';
|
|
7
|
+
export type { BLETransmissionState, OfflineTransactionState, } from './hooks/useOfflineBLETransactions';
|
|
2
8
|
export { verifyIntentSignature, isIntentExpired, updateIntentStatus, validateIntent, processIntentsForSync, filterExpiredIntents, } from './intentManager';
|
|
3
9
|
export { storePendingIntent, getPendingIntents, clearPendingIntents, } from './storage';
|
|
4
|
-
export { startTossScan, requestBLEPermissions } from './ble';
|
|
10
|
+
export { startTossScan, requestBLEPermissions, sendOfflineTransactionFragmented, receiveOfflineTransactionFragment, getBLEMTUConfig, setBLEMTUConfig, } from './ble';
|
|
5
11
|
export { initNFC, readNFCUser, writeUserToNFC, writeIntentToNFC } from './nfc';
|
|
6
12
|
export { QRScanner } from './qr';
|
|
7
13
|
export { TossClient, type TossConfig } from './client/TossClient';
|
|
8
14
|
export type { TossUser } from './types/tossUser';
|
|
9
15
|
export { WalletProvider, useWallet } from './contexts/WalletContext';
|
|
10
|
-
|
|
11
|
-
export declare const createClient: typeof TossClient.createClient;
|
|
16
|
+
export { AuthService } from './services/authService';
|
|
12
17
|
export { syncToChain, checkSyncStatus, type SyncResult } from './sync';
|
|
13
18
|
export { reconcilePendingIntents, settleIntent, validateIntentOnchain, buildTransactionFromIntent, submitTransactionToChain, detectConflicts, getReconciliationState, type SettlementResult, type ReconciliationState, } from './reconciliation';
|
|
14
19
|
export { DeviceDiscoveryService, IntentExchangeProtocol, IntentRoutingService, MultiDeviceConflictResolver, deviceDiscovery, intentExchange, intentRouting, type PeerDevice, type IntentExchangeRequest, type IntentExchangeResponse, } from './discovery';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AAGnB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,GACb,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EACV,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,gCAAgC,EAChC,iCAAiC,EACjC,eAAe,EACf,eAAe,GAChB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAClE,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGvE,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,qBAAqB,EACrB,0BAA0B,EAC1B,wBAAwB,EACxB,eAAe,EACf,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,2BAA2B,EAC3B,eAAe,EACf,cAAc,EACd,aAAa,EACb,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,aAAa,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PublicKey, Keypair, Connection } from '@solana/web3.js';
|
|
2
2
|
import type { TossUser, TossUserContext } from './types/tossUser';
|
|
3
|
+
import type { OfflineTransaction } from './types/nonceAccount';
|
|
3
4
|
import { type ArciumEncryptedOutput } from './internal/arciumHelper';
|
|
4
5
|
/**
|
|
5
6
|
* Status of an intent in its lifecycle
|
|
@@ -7,6 +8,7 @@ import { type ArciumEncryptedOutput } from './internal/arciumHelper';
|
|
|
7
8
|
export type IntentStatus = 'pending' | 'settled' | 'failed' | 'expired';
|
|
8
9
|
/**
|
|
9
10
|
* Core type for an offline intent following TOSS specification
|
|
11
|
+
* Enhanced with durable nonce account support
|
|
10
12
|
*/
|
|
11
13
|
export interface SolanaIntent {
|
|
12
14
|
id: string;
|
|
@@ -28,6 +30,10 @@ export interface SolanaIntent {
|
|
|
28
30
|
serialized?: string;
|
|
29
31
|
nonceAccount?: string;
|
|
30
32
|
nonceAuth?: string;
|
|
33
|
+
nonceAccountAddress?: string;
|
|
34
|
+
nonceAccountAuth?: string;
|
|
35
|
+
offlineTransaction?: OfflineTransaction;
|
|
36
|
+
requiresBiometric?: boolean;
|
|
31
37
|
encrypted?: ArciumEncryptedOutput;
|
|
32
38
|
}
|
|
33
39
|
/**
|
|
@@ -68,6 +74,8 @@ export declare const nonceManager: NonceManager;
|
|
|
68
74
|
/**
|
|
69
75
|
* Creates a signed intent between two TOSS users (User-centric API)
|
|
70
76
|
* Recommended for application developers - validates user wallets
|
|
77
|
+
*
|
|
78
|
+
* GAP #8 FIX: Requires biometric authentication for sensitive transactions
|
|
71
79
|
*/
|
|
72
80
|
export declare function createUserIntent(senderUser: TossUser, senderKeypair: Keypair, recipientUser: TossUser, amount: number, connection: Connection, options?: CreateIntentOptions): Promise<SolanaIntent>;
|
|
73
81
|
/**
|
|
@@ -91,5 +99,12 @@ export declare function isIntentExpired(intent: SolanaIntent): boolean;
|
|
|
91
99
|
* Updates the status of an intent
|
|
92
100
|
*/
|
|
93
101
|
export declare function updateIntentStatus(intent: SolanaIntent, status: IntentStatus, error?: string): SolanaIntent;
|
|
102
|
+
/**
|
|
103
|
+
* Creates an offline intent with durable nonce account support
|
|
104
|
+
* Enables replay-protected offline transactions using nonce accounts
|
|
105
|
+
* Requires biometric authentication for enhanced security
|
|
106
|
+
*/
|
|
107
|
+
export declare function createOfflineIntent(senderUser: TossUser, senderKeypair: Keypair, recipientUser: TossUser, amount: number, nonceAccountInfo: any, // NonceAccountInfo from NonceAccountManager
|
|
108
|
+
connection: Connection, options?: CreateIntentOptions): Promise<SolanaIntent>;
|
|
94
109
|
export {};
|
|
95
110
|
//# sourceMappingURL=intent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent.d.ts","sourceRoot":"","sources":["../../../src/intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMjE,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,yBAAyB,CAAC;AAGjC;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExE
|
|
1
|
+
{"version":3,"file":"intent.d.ts","sourceRoot":"","sources":["../../../src/intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMjE,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,yBAAyB,CAAC;AAGjC;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,YAAY;IAE3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IAEX,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SA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AAQ,EACvB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,GAAG,EAAE,4CAA4C;AACnE,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,YAAY,CAAC,CAuHvB"}
|
|
@@ -1,5 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noise Protocol Implementation for TOSS
|
|
3
|
+
* Per Section 5: "Transport reliability is explicitly not trusted.
|
|
4
|
+
* All security guarantees enforced at the cryptographic layer."
|
|
5
|
+
*
|
|
6
|
+
* GAP #4 FIX: Full Noise Protocol session lifecycle
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Noise session state
|
|
10
|
+
*/
|
|
11
|
+
export interface NoiseSession {
|
|
12
|
+
peerId: string;
|
|
13
|
+
sessionKey: Uint8Array;
|
|
14
|
+
encryptionCipher: any;
|
|
15
|
+
decryptionCipher: any;
|
|
16
|
+
createdAt: number;
|
|
17
|
+
expiresAt: number;
|
|
18
|
+
initiator: boolean;
|
|
19
|
+
}
|
|
1
20
|
/**
|
|
2
21
|
* Initialize Noise secure session with a static key.
|
|
22
|
+
* @deprecated Use performNoiseHandshake instead
|
|
3
23
|
*/
|
|
4
24
|
export declare function initNoiseSession(staticKey: Uint8Array): (components: import("@chainsafe/libp2p-noise").NoiseComponents) => import("@libp2p/interface").ConnectionEncrypter<import("@chainsafe/libp2p-noise").NoiseExtensions>;
|
|
25
|
+
/**
|
|
26
|
+
* GAP #4 FIX: Generate static keypair for long-term identity
|
|
27
|
+
*/
|
|
28
|
+
export declare function generateNoiseStaticKey(): {
|
|
29
|
+
publicKey: Uint8Array;
|
|
30
|
+
secretKey: Uint8Array;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* GAP #4 FIX: Perform Noise Protocol handshake
|
|
34
|
+
* Implements NN (no-pre-shared-knowledge) pattern for TOSS
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Perform Noise Protocol handshake between two peers
|
|
38
|
+
* Establishes encrypted session for device-to-device communication
|
|
39
|
+
*
|
|
40
|
+
* Security: Uses X25519 ECDH for key agreement, ChaCha20-Poly1305 for AEAD
|
|
41
|
+
*/
|
|
42
|
+
export declare function performNoiseHandshake(peerId: string, peerStaticKey: Uint8Array, _localStaticKey: Uint8Array, _localSecretKey: Uint8Array, initiator: boolean): Promise<NoiseSession>;
|
|
43
|
+
/**
|
|
44
|
+
* GAP #4 FIX: Encrypt message with Noise session
|
|
45
|
+
*/
|
|
46
|
+
export declare function noiseEncrypt(session: NoiseSession, plaintext: Uint8Array): Promise<Uint8Array>;
|
|
47
|
+
/**
|
|
48
|
+
* GAP #4 FIX: Decrypt message with Noise session
|
|
49
|
+
*/
|
|
50
|
+
export declare function noiseDecrypt(session: NoiseSession, ciphertext: Uint8Array): Promise<Uint8Array>;
|
|
51
|
+
/**
|
|
52
|
+
* GAP #4 FIX: Get active session or return null
|
|
53
|
+
*/
|
|
54
|
+
export declare function getNoiseSession(peerId: string): NoiseSession | null;
|
|
55
|
+
/**
|
|
56
|
+
* GAP #4 FIX: Rotate session key for forward secrecy
|
|
57
|
+
*/
|
|
58
|
+
export declare function rotateNoiseSessionKey(session: NoiseSession): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* GAP #4 FIX: Cleanup expired sessions
|
|
61
|
+
*/
|
|
62
|
+
export declare function cleanupExpiredNoiseSessions(): number;
|
|
63
|
+
/**
|
|
64
|
+
* GAP #4 FIX: Get all active sessions
|
|
65
|
+
*/
|
|
66
|
+
export declare function getActiveNoiseSessions(): NoiseSession[];
|
|
5
67
|
//# sourceMappingURL=noise.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noise.d.ts","sourceRoot":"","sources":["../../../src/noise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"noise.d.ts","sourceRoot":"","sources":["../../../src/noise.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;GAEG;AACH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
43
|
* Submits a transaction to the network with confirmation
|
|
44
44
|
*/
|
|
45
45
|
export declare function submitTransactionToChain(transaction: Transaction, connection: Connection, maxRetries?: number): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* GAP #7 FIX: Submit transaction to Arcium MXE program for confidential execution
|
|
48
|
+
* Per TOSS Paper Section 7: "Arcium operates strictly before onchain execution"
|
|
49
|
+
*/
|
|
50
|
+
export declare function submitTransactionToArciumMXE(intent: SolanaIntent, connection: Connection, mxeProgramId: PublicKey, provider: any, // AnchorProvider
|
|
51
|
+
maxRetries?: number): Promise<string>;
|
|
46
52
|
/**
|
|
47
53
|
* Attempts to settle a single intent and returns the result
|
|
48
54
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconciliation.d.ts","sourceRoot":"","sources":["../../../src/reconciliation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"reconciliation.d.ts","sourceRoot":"","sources":["../../../src/reconciliation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;AAe3D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,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,QAAQ,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAyBnD;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,mBAAmB,CAAC,CAiB9B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Keypair, PublicKey } from '@solana/web3.js';
|
|
1
|
+
import { Keypair, PublicKey, Connection } from '@solana/web3.js';
|
|
2
2
|
import type { TossUser } from '../types/tossUser';
|
|
3
3
|
export declare const SESSION_KEY = "toss_user_session";
|
|
4
4
|
type UserSession = {
|
|
@@ -50,6 +50,31 @@ export declare class AuthService {
|
|
|
50
50
|
* Only use for logout or account deletion
|
|
51
51
|
*/
|
|
52
52
|
static deleteWalletPermanently(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Create a secure durable nonce account for offline transactions
|
|
55
|
+
* REQUIRES biometric authentication for maximum security
|
|
56
|
+
*
|
|
57
|
+
* This creates a nonce account that enables:
|
|
58
|
+
* - Offline transaction creation (with replay protection)
|
|
59
|
+
* - Biometric-protected signing
|
|
60
|
+
* - Encrypted storage with Noise Protocol support
|
|
61
|
+
*/
|
|
62
|
+
static createSecureNonceAccount(user: TossUser, connection: Connection, userKeypair: Keypair): Promise<TossUser>;
|
|
63
|
+
/**
|
|
64
|
+
* Enable offline transactions for a user with nonce account support
|
|
65
|
+
* Ensures all security measures are in place
|
|
66
|
+
*/
|
|
67
|
+
static enableOfflineTransactions(user: TossUser): Promise<TossUser>;
|
|
68
|
+
/**
|
|
69
|
+
* Verify nonce account is accessible and valid
|
|
70
|
+
* Requires biometric authentication
|
|
71
|
+
*/
|
|
72
|
+
static verifyNonceAccountAccess(userId: string): Promise<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* Revoke nonce account (security measure)
|
|
75
|
+
* Requires biometric verification
|
|
76
|
+
*/
|
|
77
|
+
static revokeNonceAccount(userId: string, user: TossUser): Promise<TossUser>;
|
|
53
78
|
}
|
|
54
79
|
export {};
|
|
55
80
|
//# sourceMappingURL=authService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["../../../../src/services/authService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["../../../../src/services/authService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAIlD,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAK/C,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,qBAAa,WAAW;WACT,gBAAgB,CAC3B,aAAa,EAAE,MAAM,EACrB,WAAW,GAAE,OAAe,GAC3B,OAAO,CAAC;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,OAAO,EAAE,WAAW,CAAA;KAAE,CAAC;WA8CvC,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;WAIhD,UAAU,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;WAKzC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;WAKxB,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;WAQpC,0BAA0B,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IA2DlE;;;;;;;;;;;OAWG;WACU,qBAAqB,CAChC,OAAO,EAAE,OAAO,EAChB,aAAa,GAAE,OAAc,GAC5B,OAAO,CAAC,IAAI,CAAC;IAoChB;;;OAGG;WACU,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC;IAKxD;;;OAGG;WACU,uBAAuB,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAajE;;;OAGG;WACU,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKlD;;;OAGG;WACU,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrD;;;;;;;;OAQG;WACU,wBAAwB,CACnC,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,QAAQ,CAAC;IA2EpB;;;OAGG;WACU,yBAAyB,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAuBzE;;;OAGG;WACU,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAwBvE;;;OAGG;WACU,kBAAkB,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,QAAQ,CAAC;CA4BrB"}
|
|
@@ -4,4 +4,20 @@ export declare function getSecureIntent(intentId: string): Promise<SolanaIntent
|
|
|
4
4
|
export declare function getAllSecureIntents(): Promise<SolanaIntent[]>;
|
|
5
5
|
export declare function removeSecureIntent(intentId: string): Promise<void>;
|
|
6
6
|
export declare function clearAllSecureIntents(): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* GAP #1: Cleanup expired intents from local storage
|
|
9
|
+
* Per TOSS Paper Section 8: Local state is append-only until settlement confirmation
|
|
10
|
+
*/
|
|
11
|
+
export declare function cleanupExpiredIntents(): Promise<number>;
|
|
12
|
+
export interface ReconciliationStateData {
|
|
13
|
+
userId: string;
|
|
14
|
+
lastSyncTime: number;
|
|
15
|
+
lastSyncSlot: number;
|
|
16
|
+
processedIntents: string[];
|
|
17
|
+
failedIntents: string[];
|
|
18
|
+
conflictingIntents: string[];
|
|
19
|
+
}
|
|
20
|
+
export declare function saveReconciliationState(userId: string, state: Partial<ReconciliationStateData>): Promise<void>;
|
|
21
|
+
export declare function getReconciliationState(userId: string): Promise<ReconciliationStateData>;
|
|
22
|
+
export declare function updateReconciliationState(userId: string, intentId: string, status: 'processed' | 'failed' | 'conflicted'): Promise<void>;
|
|
7
23
|
//# sourceMappingURL=secureStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secureStorage.d.ts","sourceRoot":"","sources":["../../../../src/storage/secureStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAoB9C,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB3E;AAED,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAY9B;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAanE;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAexE;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAU3D"}
|
|
1
|
+
{"version":3,"file":"secureStorage.d.ts","sourceRoot":"","sources":["../../../../src/storage/secureStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAoB9C,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB3E;AAED,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAY9B;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAanE;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAexE;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAU3D;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC,CAmB7D;AAQD,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,CAAC,uBAAuB,CAAC,GACtC,OAAO,CAAC,IAAI,CAAC,CA4Bf;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,uBAAuB,CAAC,CAuBlC;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,YAAY,GAC5C,OAAO,CAAC,IAAI,CAAC,CAgCf"}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* Implements Section 9 of the TOSS Technical Paper:
|
|
5
5
|
* Upon regaining connectivity, devices initiate reconciliation with onchain state.
|
|
6
6
|
* All offline artifacts are verified onchain and settled with deterministic outcomes.
|
|
7
|
+
*
|
|
8
|
+
* GAP #2 FIX: Track synchronization state persistently
|
|
7
9
|
*/
|
|
8
10
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
9
11
|
import { type SettlementResult, type ReconciliationState } from './reconciliation';
|
|
@@ -27,11 +29,14 @@ export interface SyncResult {
|
|
|
27
29
|
* 2. Settle all pending intents
|
|
28
30
|
* 3. Update local state with results
|
|
29
31
|
*
|
|
32
|
+
* GAP #2 FIX: Persist reconciliation state for future queries
|
|
33
|
+
*
|
|
30
34
|
* @param connection Connection to Solana RPC
|
|
35
|
+
* @param userId User ID for state tracking (required for persistence)
|
|
31
36
|
* @param feePayer Optional fee payer keypair public key
|
|
32
37
|
* @returns Detailed sync results including conflicts and settlements
|
|
33
38
|
*/
|
|
34
|
-
export declare function syncToChain(connection: Connection, feePayer?: PublicKey): Promise<SyncResult>;
|
|
39
|
+
export declare function syncToChain(connection: Connection, userId?: string, feePayer?: PublicKey): Promise<SyncResult>;
|
|
35
40
|
/**
|
|
36
41
|
* Lightweight sync to check status without settling
|
|
37
42
|
* Useful for monitoring or UI updates without committing to settlements
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/sync.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACzB,MAAM,kBAAkB,CAAC;AAI1B,MAAM,WAAW,UAAU;IAEzB,qBAAqB,EAAE,gBAAgB,EAAE,CAAC;IAE1C,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IAEtC,iBAAiB,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAE5D,mBAAmB,EAAE,mBAAmB,CAAC;IAEzC,aAAa,EAAE,MAAM,CAAC;IAEtB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,UAAU,EACtB,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,SAAS,GACnB,OAAO,CAAC,UAAU,CAAC,CA0ErB;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,mBAAmB,CAAC,CAE9B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a durable nonce account for offline transaction support
|
|
3
|
+
* Enables secure offline transaction creation with replay protection
|
|
4
|
+
*/
|
|
5
|
+
export interface NonceAccountInfo {
|
|
6
|
+
address: string;
|
|
7
|
+
owner: string;
|
|
8
|
+
authorizedSigner: string;
|
|
9
|
+
currentNonce: number;
|
|
10
|
+
lastUsedNonce: number;
|
|
11
|
+
blockhash: string;
|
|
12
|
+
isBiometricProtected: boolean;
|
|
13
|
+
createdAt: number;
|
|
14
|
+
lastModified: number;
|
|
15
|
+
isStoredSecurely: boolean;
|
|
16
|
+
encryptedData?: string;
|
|
17
|
+
minRentLamports?: number;
|
|
18
|
+
status?: 'active' | 'expired' | 'revoked';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for creating a durable nonce account
|
|
22
|
+
*/
|
|
23
|
+
export interface CreateNonceAccountOptions {
|
|
24
|
+
requireBiometric?: boolean;
|
|
25
|
+
securityLevel?: 'standard' | 'high' | 'maximum';
|
|
26
|
+
minNonceCount?: number;
|
|
27
|
+
maxNonceCount?: number;
|
|
28
|
+
persistToSecureStorage?: boolean;
|
|
29
|
+
allowCloudBackup?: boolean;
|
|
30
|
+
autoRenew?: boolean;
|
|
31
|
+
expiryDays?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Nonce account cache entry for efficient offline usage
|
|
35
|
+
*/
|
|
36
|
+
export interface NonceAccountCacheEntry {
|
|
37
|
+
accountInfo: NonceAccountInfo;
|
|
38
|
+
nonces: number[];
|
|
39
|
+
expiresAt: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Represents a transaction prepared for offline use with nonce account
|
|
43
|
+
*/
|
|
44
|
+
export interface OfflineTransaction {
|
|
45
|
+
id: string;
|
|
46
|
+
nonceAccount: string;
|
|
47
|
+
nonce: number;
|
|
48
|
+
transaction: string;
|
|
49
|
+
signature?: string;
|
|
50
|
+
status: 'prepared' | 'signed' | 'submitted' | 'confirmed' | 'failed';
|
|
51
|
+
createdAt: number;
|
|
52
|
+
expiresAt: number;
|
|
53
|
+
metadata?: {
|
|
54
|
+
description?: string;
|
|
55
|
+
tags?: string[];
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=nonceAccount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nonceAccount.d.ts","sourceRoot":"","sources":["../../../../src/types/nonceAccount.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAE/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IAGzB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAGlB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IAGrB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IAExC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;IAGhD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAG3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,gBAAgB,CAAC;IAC9B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAC;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE;QACT,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
2
|
/**
|
|
3
3
|
* Represents a TOSS wallet user in the ecosystem
|
|
4
|
+
* Enhanced with secure nonce account support for offline transactions
|
|
4
5
|
*/
|
|
5
6
|
export type TossUser = {
|
|
6
7
|
userId: string;
|
|
@@ -11,12 +12,25 @@ export type TossUser = {
|
|
|
11
12
|
isVerified: boolean;
|
|
12
13
|
createdAt: string;
|
|
13
14
|
};
|
|
15
|
+
nonceAccount?: {
|
|
16
|
+
address: PublicKey;
|
|
17
|
+
authorizedSigner: PublicKey;
|
|
18
|
+
isBiometricProtected: boolean;
|
|
19
|
+
expiresAt?: number;
|
|
20
|
+
status: 'active' | 'expired' | 'revoked';
|
|
21
|
+
};
|
|
14
22
|
device: {
|
|
15
23
|
id: string;
|
|
16
24
|
name?: string;
|
|
17
25
|
lastActive: string;
|
|
18
26
|
client: 'mobile' | 'web' | 'desktop';
|
|
19
27
|
};
|
|
28
|
+
security: {
|
|
29
|
+
biometricEnabled: boolean;
|
|
30
|
+
biometricSalt?: string;
|
|
31
|
+
nonceAccountRequiresBiometric: boolean;
|
|
32
|
+
lastBiometricVerification?: number;
|
|
33
|
+
};
|
|
20
34
|
status: 'active' | 'inactive' | 'restricted';
|
|
21
35
|
lastSeen: string;
|
|
22
36
|
tossFeatures: {
|
|
@@ -24,6 +38,8 @@ export type TossUser = {
|
|
|
24
38
|
canReceive: boolean;
|
|
25
39
|
isPrivateTxEnabled: boolean;
|
|
26
40
|
maxTransactionAmount: number;
|
|
41
|
+
offlineTransactionsEnabled?: boolean;
|
|
42
|
+
nonceAccountEnabled?: boolean;
|
|
27
43
|
};
|
|
28
44
|
createdAt: string;
|
|
29
45
|
updatedAt: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tossUser.d.ts","sourceRoot":"","sources":["../../../../src/types/tossUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"tossUser.d.ts","sourceRoot":"","sources":["../../../../src/types/tossUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IAErB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,MAAM,EAAE;QACN,SAAS,EAAE,SAAS,CAAC;QACrB,UAAU,EAAE,OAAO,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAGF,YAAY,CAAC,EAAE;QACb,OAAO,EAAE,SAAS,CAAC;QACnB,gBAAgB,EAAE,SAAS,CAAC;QAC5B,oBAAoB,EAAE,OAAO,CAAC;QAC9B,SAAS,CAAC,EAAE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