@oxyhq/services 5.16.18 → 5.16.20
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 +7 -8
- package/lib/commonjs/crypto/index.js +0 -7
- package/lib/commonjs/crypto/index.js.map +1 -1
- package/lib/commonjs/crypto/keyManager.js +2 -2
- package/lib/commonjs/crypto/polyfill.js +4 -4
- package/lib/commonjs/crypto/types.js +2 -0
- package/lib/commonjs/crypto/types.js.map +1 -0
- package/lib/commonjs/i18n/locales/en-US.json +1 -1
- package/lib/commonjs/index.js +0 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +54 -11
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +56 -15
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSessionSocket.js +52 -2
- package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/module/crypto/index.js +2 -4
- package/lib/module/crypto/index.js.map +1 -1
- package/lib/module/crypto/keyManager.js +2 -2
- package/lib/module/crypto/polyfill.js +4 -4
- package/lib/module/crypto/types.js +2 -0
- package/lib/module/crypto/types.js.map +1 -0
- package/lib/module/i18n/locales/en-US.json +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +49 -6
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +56 -16
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/module/ui/hooks/useSessionSocket.js +52 -2
- package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/typescript/crypto/index.d.ts +2 -2
- package/lib/typescript/crypto/index.d.ts.map +1 -1
- package/lib/typescript/crypto/keyManager.d.ts +2 -2
- package/lib/typescript/crypto/polyfill.d.ts +2 -2
- package/lib/typescript/crypto/types.d.ts +18 -0
- package/lib/typescript/crypto/types.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts +2 -2
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +3 -3
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useSessionSocket.d.ts +7 -1
- package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/crypto/index.ts +3 -6
- package/src/crypto/keyManager.ts +2 -2
- package/src/crypto/polyfill.ts +4 -4
- package/src/crypto/types.ts +19 -0
- package/src/i18n/locales/en-US.json +1 -1
- package/src/index.ts +2 -4
- package/src/ui/context/OxyContext.tsx +63 -7
- package/src/ui/context/hooks/useAuthOperations.ts +67 -17
- package/src/ui/hooks/useSessionSocket.ts +62 -2
- package/lib/commonjs/crypto/recoveryPhrase.js +0 -152
- package/lib/commonjs/crypto/recoveryPhrase.js.map +0 -1
- package/lib/commonjs/ui/hooks/useIdentityMutations.js +0 -111
- package/lib/commonjs/ui/hooks/useIdentityMutations.js.map +0 -1
- package/lib/module/crypto/recoveryPhrase.js +0 -147
- package/lib/module/crypto/recoveryPhrase.js.map +0 -1
- package/lib/module/ui/hooks/useIdentityMutations.js +0 -105
- package/lib/module/ui/hooks/useIdentityMutations.js.map +0 -1
- package/lib/typescript/crypto/recoveryPhrase.d.ts +0 -59
- package/lib/typescript/crypto/recoveryPhrase.d.ts.map +0 -1
- package/lib/typescript/types/bip39.d.ts +0 -32
- package/lib/typescript/ui/hooks/useIdentityMutations.d.ts +0 -29
- package/lib/typescript/ui/hooks/useIdentityMutations.d.ts.map +0 -1
- package/src/crypto/recoveryPhrase.ts +0 -166
- package/src/types/bip39.d.ts +0 -32
- package/src/ui/hooks/useIdentityMutations.ts +0 -115
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useCreateIdentity = useCreateIdentity;
|
|
7
|
-
exports.useImportIdentity = useImportIdentity;
|
|
8
|
-
exports.useSyncIdentity = useSyncIdentity;
|
|
9
|
-
var _reactQuery = require("@tanstack/react-query");
|
|
10
|
-
/**
|
|
11
|
-
* TanStack Query mutations for identity operations
|
|
12
|
-
* Provides offline-first mutations for identity creation, import, and sync
|
|
13
|
-
* Never deletes identity on errors - preserves user data
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Hook for creating a new identity with offline support
|
|
18
|
-
* Never deletes identity on error - preserves user data
|
|
19
|
-
*/
|
|
20
|
-
function useCreateIdentity(createIdentityFn) {
|
|
21
|
-
const queryClient = (0, _reactQuery.useQueryClient)();
|
|
22
|
-
return (0, _reactQuery.useMutation)({
|
|
23
|
-
mutationFn: createIdentityFn,
|
|
24
|
-
onSuccess: data => {
|
|
25
|
-
// Invalidate user queries to refetch after identity creation
|
|
26
|
-
queryClient.invalidateQueries({
|
|
27
|
-
queryKey: ['user']
|
|
28
|
-
});
|
|
29
|
-
queryClient.invalidateQueries({
|
|
30
|
-
queryKey: ['identity']
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
onError: error => {
|
|
34
|
-
// Never delete identity on error - just log it
|
|
35
|
-
// User can recover using recovery phrase
|
|
36
|
-
if (__DEV__) {
|
|
37
|
-
console.warn('[useCreateIdentity] Identity creation error (identity may still exist):', error);
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
retry: false,
|
|
41
|
-
// Don't retry identity creation
|
|
42
|
-
networkMode: 'offlineFirst'
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Hook for importing an identity from recovery phrase
|
|
48
|
-
* Never deletes identity on error - preserves user data
|
|
49
|
-
*/
|
|
50
|
-
function useImportIdentity(importIdentityFn) {
|
|
51
|
-
const queryClient = (0, _reactQuery.useQueryClient)();
|
|
52
|
-
return (0, _reactQuery.useMutation)({
|
|
53
|
-
mutationFn: importIdentityFn,
|
|
54
|
-
onSuccess: data => {
|
|
55
|
-
queryClient.invalidateQueries({
|
|
56
|
-
queryKey: ['user']
|
|
57
|
-
});
|
|
58
|
-
queryClient.invalidateQueries({
|
|
59
|
-
queryKey: ['identity']
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
onError: error => {
|
|
63
|
-
// Never delete identity on error - just log it
|
|
64
|
-
if (__DEV__) {
|
|
65
|
-
console.warn('[useImportIdentity] Identity import error (identity may still exist):', error);
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
retry: false,
|
|
69
|
-
networkMode: 'offlineFirst'
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Hook for syncing identity with server
|
|
75
|
-
* Never deletes identity on error - only logs and allows retry
|
|
76
|
-
*/
|
|
77
|
-
function useSyncIdentity(syncIdentityFn) {
|
|
78
|
-
const queryClient = (0, _reactQuery.useQueryClient)();
|
|
79
|
-
return (0, _reactQuery.useMutation)({
|
|
80
|
-
mutationFn: syncIdentityFn,
|
|
81
|
-
onSuccess: user => {
|
|
82
|
-
// Update user cache
|
|
83
|
-
queryClient.setQueryData(['user', 'current'], user);
|
|
84
|
-
queryClient.invalidateQueries({
|
|
85
|
-
queryKey: ['user']
|
|
86
|
-
});
|
|
87
|
-
queryClient.invalidateQueries({
|
|
88
|
-
queryKey: ['identity']
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
onError: error => {
|
|
92
|
-
// Never delete identity on error - just log it
|
|
93
|
-
// User can retry sync later or use recovery phrase
|
|
94
|
-
if (__DEV__) {
|
|
95
|
-
console.warn('[useSyncIdentity] Sync failed, but identity is preserved:', error);
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
retry: (failureCount, error) => {
|
|
99
|
-
// Retry up to 2 times for sync operations
|
|
100
|
-
// Don't retry if it's a network error - user can retry when online
|
|
101
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
102
|
-
const isNetworkError = errorMessage.includes('Network') || errorMessage.includes('Failed to fetch') || error?.code === 'NETWORK_ERROR';
|
|
103
|
-
if (isNetworkError) {
|
|
104
|
-
return false; // Don't retry network errors - user will retry when online
|
|
105
|
-
}
|
|
106
|
-
return failureCount < 2;
|
|
107
|
-
},
|
|
108
|
-
networkMode: 'offlineFirst'
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=useIdentityMutations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactQuery","require","useCreateIdentity","createIdentityFn","queryClient","useQueryClient","useMutation","mutationFn","onSuccess","data","invalidateQueries","queryKey","onError","error","__DEV__","console","warn","retry","networkMode","useImportIdentity","importIdentityFn","useSyncIdentity","syncIdentityFn","user","setQueryData","failureCount","errorMessage","Error","message","String","isNetworkError","includes","code"],"sourceRoot":"../../../../src","sources":["ui/hooks/useIdentityMutations.ts"],"mappings":";;;;;;;;AAMA,IAAAA,WAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAC/BC,gBAAqD,EACrD;EACA,MAAMC,WAAW,GAAG,IAAAC,0BAAc,EAAC,CAAC;EAEpC,OAAO,IAAAC,uBAAW,EAAC;IACjBC,UAAU,EAAEJ,gBAAgB;IAC5BK,SAAS,EAAGC,IAAI,IAAK;MACnB;MACAL,WAAW,CAACM,iBAAiB,CAAC;QAAEC,QAAQ,EAAE,CAAC,MAAM;MAAE,CAAC,CAAC;MACrDP,WAAW,CAACM,iBAAiB,CAAC;QAAEC,QAAQ,EAAE,CAAC,UAAU;MAAE,CAAC,CAAC;IAC3D,CAAC;IACDC,OAAO,EAA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C,UAAU;MAAE,CAAC,CAAC;IAC3D,CAAC;IACDC,OAAO,EAAGC,KAAK,IAAK;MAClB;MACA;MACA,IAAIC,OAAO,EAAE;QACXC,OAAO,CAACC,IAAI,CAAC,2DAA2D,EAAEH,KAAK,CAAC;MAClF;IACF,CAAC;IACDI,KAAK,EAAEA,CAACQ,YAAY,EAAEZ,KAAU,KAAK;MACnC;MACA;MACA,MAAMa,YAAY,GAAGb,KAAK,YAAYc,KAAK,GAAGd,KAAK,CAACe,OAAO,GAAGC,MAAM,CAAChB,KAAK,CAAC;MAC3E,MAAMiB,cAAc,GAClBJ,YAAY,CAACK,QAAQ,CAAC,SAAS,CAAC,IAChCL,YAAY,CAACK,QAAQ,CAAC,iBAAiB,CAAC,IACxClB,KAAK,EAAEmB,IAAI,KAAK,eAAe;MAEjC,IAAIF,cAAc,EAAE;QAClB,OAAO,KAAK,CAAC,CAAC;MAChB;MAEA,OAAOL,YAAY,GAAG,CAAC;IACzB,CAAC;IACDP,WAAW,EAAE;EACf,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Recovery Phrase Service - BIP39 Mnemonic Generation
|
|
5
|
-
*
|
|
6
|
-
* Handles generation and restoration of recovery phrases (mnemonic seeds)
|
|
7
|
-
* for backing up and restoring user identities.
|
|
8
|
-
*
|
|
9
|
-
* Note: This module requires the polyfill to be loaded first (done via crypto/index.ts)
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import * as bip39 from 'bip39';
|
|
13
|
-
import { KeyManager } from './keyManager';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Convert Uint8Array or array-like to hexadecimal string
|
|
17
|
-
* Works in both Node.js and React Native without depending on Buffer
|
|
18
|
-
*/
|
|
19
|
-
function toHex(data) {
|
|
20
|
-
// Convert to array of numbers if needed
|
|
21
|
-
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
22
|
-
return Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
|
|
23
|
-
}
|
|
24
|
-
export class RecoveryPhraseService {
|
|
25
|
-
/**
|
|
26
|
-
* Generate a new identity with a recovery phrase
|
|
27
|
-
* Returns the mnemonic phrase (should only be shown once to the user)
|
|
28
|
-
*/
|
|
29
|
-
static async generateIdentityWithRecovery() {
|
|
30
|
-
// Generate 128-bit entropy for 12-word mnemonic
|
|
31
|
-
const mnemonic = bip39.generateMnemonic(128);
|
|
32
|
-
|
|
33
|
-
// Derive private key from mnemonic
|
|
34
|
-
// Using the seed directly as the private key (simplified approach)
|
|
35
|
-
const seed = await bip39.mnemonicToSeed(mnemonic);
|
|
36
|
-
|
|
37
|
-
// Use first 32 bytes of seed as private key
|
|
38
|
-
const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
|
|
39
|
-
const privateKeyHex = toHex(seedSlice);
|
|
40
|
-
|
|
41
|
-
// Import the derived key pair
|
|
42
|
-
const publicKey = await KeyManager.importKeyPair(privateKeyHex);
|
|
43
|
-
return {
|
|
44
|
-
phrase: mnemonic,
|
|
45
|
-
words: mnemonic.split(' '),
|
|
46
|
-
publicKey
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Generate a 24-word recovery phrase for higher security
|
|
52
|
-
*/
|
|
53
|
-
static async generateIdentityWithRecovery24() {
|
|
54
|
-
// Generate 256-bit entropy for 24-word mnemonic
|
|
55
|
-
const mnemonic = bip39.generateMnemonic(256);
|
|
56
|
-
const seed = await bip39.mnemonicToSeed(mnemonic);
|
|
57
|
-
const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
|
|
58
|
-
const privateKeyHex = toHex(seedSlice);
|
|
59
|
-
const publicKey = await KeyManager.importKeyPair(privateKeyHex);
|
|
60
|
-
return {
|
|
61
|
-
phrase: mnemonic,
|
|
62
|
-
words: mnemonic.split(' '),
|
|
63
|
-
publicKey
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Restore an identity from a recovery phrase
|
|
69
|
-
*/
|
|
70
|
-
static async restoreFromPhrase(phrase) {
|
|
71
|
-
// Normalize and validate the phrase
|
|
72
|
-
const normalizedPhrase = phrase.trim().toLowerCase();
|
|
73
|
-
if (!bip39.validateMnemonic(normalizedPhrase)) {
|
|
74
|
-
throw new Error('Invalid recovery phrase. Please check the words and try again.');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Derive the same private key from the mnemonic
|
|
78
|
-
const seed = await bip39.mnemonicToSeed(normalizedPhrase);
|
|
79
|
-
const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
|
|
80
|
-
const privateKeyHex = toHex(seedSlice);
|
|
81
|
-
|
|
82
|
-
// Import and store the key pair
|
|
83
|
-
const publicKey = await KeyManager.importKeyPair(privateKeyHex);
|
|
84
|
-
return publicKey;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Validate a recovery phrase without importing it
|
|
89
|
-
*/
|
|
90
|
-
static validatePhrase(phrase) {
|
|
91
|
-
const normalizedPhrase = phrase.trim().toLowerCase();
|
|
92
|
-
return bip39.validateMnemonic(normalizedPhrase);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Get the word list for autocomplete/validation
|
|
97
|
-
*/
|
|
98
|
-
static getWordList() {
|
|
99
|
-
return bip39.wordlists.english;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Check if a word is valid in the BIP39 word list
|
|
104
|
-
*/
|
|
105
|
-
static isValidWord(word) {
|
|
106
|
-
return bip39.wordlists.english.includes(word.toLowerCase());
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Get suggestions for a partial word
|
|
111
|
-
*/
|
|
112
|
-
static getSuggestions(partial, limit = 5) {
|
|
113
|
-
const lowerPartial = partial.toLowerCase();
|
|
114
|
-
return bip39.wordlists.english.filter(word => word.startsWith(lowerPartial)).slice(0, limit);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Derive the public key from a phrase without storing
|
|
119
|
-
* Useful for verification before importing
|
|
120
|
-
*/
|
|
121
|
-
static async derivePublicKeyFromPhrase(phrase) {
|
|
122
|
-
const normalizedPhrase = phrase.trim().toLowerCase();
|
|
123
|
-
if (!bip39.validateMnemonic(normalizedPhrase)) {
|
|
124
|
-
throw new Error('Invalid recovery phrase');
|
|
125
|
-
}
|
|
126
|
-
const seed = await bip39.mnemonicToSeed(normalizedPhrase);
|
|
127
|
-
const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
|
|
128
|
-
const privateKeyHex = toHex(seedSlice);
|
|
129
|
-
return KeyManager.derivePublicKey(privateKeyHex);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Convert a phrase to its word array
|
|
134
|
-
*/
|
|
135
|
-
static phraseToWords(phrase) {
|
|
136
|
-
return phrase.trim().toLowerCase().split(/\s+/);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Convert a word array to a phrase string
|
|
141
|
-
*/
|
|
142
|
-
static wordsToPhrase(words) {
|
|
143
|
-
return words.map(w => w.toLowerCase().trim()).join(' ');
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
export default RecoveryPhraseService;
|
|
147
|
-
//# sourceMappingURL=recoveryPhrase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["bip39","KeyManager","toHex","data","bytes","Uint8Array","Array","from","map","b","toString","padStart","join","RecoveryPhraseService","generateIdentityWithRecovery","mnemonic","generateMnemonic","seed","mnemonicToSeed","seedSlice","subarray","slice","privateKeyHex","publicKey","importKeyPair","phrase","words","split","generateIdentityWithRecovery24","restoreFromPhrase","normalizedPhrase","trim","toLowerCase","validateMnemonic","Error","validatePhrase","getWordList","wordlists","english","isValidWord","word","includes","getSuggestions","partial","limit","lowerPartial","filter","startsWith","derivePublicKeyFromPhrase","derivePublicKey","phraseToWords","wordsToPhrase","w"],"sourceRoot":"../../../src","sources":["crypto/recoveryPhrase.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,UAAU,QAAQ,cAAc;;AAEzC;AACA;AACA;AACA;AACA,SAASC,KAAKA,CAACC,IAAoC,EAAU;EAC3D;EACA,MAAMC,KAAK,GAAGD,IAAI,YAAYE,UAAU,GAAGF,IAAI,GAAG,IAAIE,UAAU,CAACF,IAAI,CAAC;EACtE,OAAOG,KAAK,CAACC,IAAI,CAACH,KAAK,CAAC,CACrBI,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CACzCC,IAAI,CAAC,EAAE,CAAC;AACb;AAQA,OAAO,MAAMC,qBAAqB,CAAC;EACjC;AACF;AACA;AACA;EACE,aAAaC,4BAA4BA,CAAA,EAAkC;IACzE;IACA,MAAMC,QAAQ,GAAGf,KAAK,CAACgB,gBAAgB,CAAC,GAAG,CAAC;;IAE5C;IACA;IACA,MAAMC,IAAI,GAAG,MAAMjB,KAAK,CAACkB,cAAc,CAACH,QAAQ,CAAC;;IAEjD;IACA,MAAMI,SAAS,GAAGF,IAAI,CAACG,QAAQ,GAAGH,IAAI,CAACG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,GAAGH,IAAI,CAACI,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;IAC1E,MAAMC,aAAa,GAAGpB,KAAK,CAACiB,SAAS,CAAC;;IAEtC;IACA,MAAMI,SAAS,GAAG,MAAMtB,UAAU,CAACuB,aAAa,CAACF,aAAa,CAAC;IAE/D,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B,KAAK,CAACkB,cAAc,CAACY,gBAAgB,CAAC;IACzD,MAAMX,SAAS,GAAGF,IAAI,CAACG,QAAQ,GAAGH,IAAI,CAACG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,GAAGH,IAAI,CAACI,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;IAC1E,MAAMC,aAAa,GAAGpB,KAAK,CAACiB,SAAS,CAAC;IAEtC,OAAOlB,UAAU,CAACgD,eAAe,CAAC3B,aAAa,CAAC;EAClD;;EAEA;AACF;AACA;EACE,OAAO4B,aAAaA,CAACzB,MAAc,EAAY;IAC7C,OAAOA,MAAM,CAACM,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAACL,KAAK,CAAC,KAAK,CAAC;EACjD;;EAEA;AACF;AACA;EACE,OAAOwB,aAAaA,CAACzB,KAAe,EAAU;IAC5C,OAAOA,KAAK,CAAClB,GAAG,CAAC4C,CAAC,IAAIA,CAAC,CAACpB,WAAW,CAAC,CAAC,CAACD,IAAI,CAAC,CAAC,CAAC,CAACnB,IAAI,CAAC,GAAG,CAAC;EACzD;AACF;AAEA,eAAeC,qBAAqB","ignoreList":[]}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* TanStack Query mutations for identity operations
|
|
5
|
-
* Provides offline-first mutations for identity creation, import, and sync
|
|
6
|
-
* Never deletes identity on errors - preserves user data
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
10
|
-
/**
|
|
11
|
-
* Hook for creating a new identity with offline support
|
|
12
|
-
* Never deletes identity on error - preserves user data
|
|
13
|
-
*/
|
|
14
|
-
export function useCreateIdentity(createIdentityFn) {
|
|
15
|
-
const queryClient = useQueryClient();
|
|
16
|
-
return useMutation({
|
|
17
|
-
mutationFn: createIdentityFn,
|
|
18
|
-
onSuccess: data => {
|
|
19
|
-
// Invalidate user queries to refetch after identity creation
|
|
20
|
-
queryClient.invalidateQueries({
|
|
21
|
-
queryKey: ['user']
|
|
22
|
-
});
|
|
23
|
-
queryClient.invalidateQueries({
|
|
24
|
-
queryKey: ['identity']
|
|
25
|
-
});
|
|
26
|
-
},
|
|
27
|
-
onError: error => {
|
|
28
|
-
// Never delete identity on error - just log it
|
|
29
|
-
// User can recover using recovery phrase
|
|
30
|
-
if (__DEV__) {
|
|
31
|
-
console.warn('[useCreateIdentity] Identity creation error (identity may still exist):', error);
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
retry: false,
|
|
35
|
-
// Don't retry identity creation
|
|
36
|
-
networkMode: 'offlineFirst'
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Hook for importing an identity from recovery phrase
|
|
42
|
-
* Never deletes identity on error - preserves user data
|
|
43
|
-
*/
|
|
44
|
-
export function useImportIdentity(importIdentityFn) {
|
|
45
|
-
const queryClient = useQueryClient();
|
|
46
|
-
return useMutation({
|
|
47
|
-
mutationFn: importIdentityFn,
|
|
48
|
-
onSuccess: data => {
|
|
49
|
-
queryClient.invalidateQueries({
|
|
50
|
-
queryKey: ['user']
|
|
51
|
-
});
|
|
52
|
-
queryClient.invalidateQueries({
|
|
53
|
-
queryKey: ['identity']
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
onError: error => {
|
|
57
|
-
// Never delete identity on error - just log it
|
|
58
|
-
if (__DEV__) {
|
|
59
|
-
console.warn('[useImportIdentity] Identity import error (identity may still exist):', error);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
retry: false,
|
|
63
|
-
networkMode: 'offlineFirst'
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Hook for syncing identity with server
|
|
69
|
-
* Never deletes identity on error - only logs and allows retry
|
|
70
|
-
*/
|
|
71
|
-
export function useSyncIdentity(syncIdentityFn) {
|
|
72
|
-
const queryClient = useQueryClient();
|
|
73
|
-
return useMutation({
|
|
74
|
-
mutationFn: syncIdentityFn,
|
|
75
|
-
onSuccess: user => {
|
|
76
|
-
// Update user cache
|
|
77
|
-
queryClient.setQueryData(['user', 'current'], user);
|
|
78
|
-
queryClient.invalidateQueries({
|
|
79
|
-
queryKey: ['user']
|
|
80
|
-
});
|
|
81
|
-
queryClient.invalidateQueries({
|
|
82
|
-
queryKey: ['identity']
|
|
83
|
-
});
|
|
84
|
-
},
|
|
85
|
-
onError: error => {
|
|
86
|
-
// Never delete identity on error - just log it
|
|
87
|
-
// User can retry sync later or use recovery phrase
|
|
88
|
-
if (__DEV__) {
|
|
89
|
-
console.warn('[useSyncIdentity] Sync failed, but identity is preserved:', error);
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
retry: (failureCount, error) => {
|
|
93
|
-
// Retry up to 2 times for sync operations
|
|
94
|
-
// Don't retry if it's a network error - user can retry when online
|
|
95
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
96
|
-
const isNetworkError = errorMessage.includes('Network') || errorMessage.includes('Failed to fetch') || error?.code === 'NETWORK_ERROR';
|
|
97
|
-
if (isNetworkError) {
|
|
98
|
-
return false; // Don't retry network errors - user will retry when online
|
|
99
|
-
}
|
|
100
|
-
return failureCount < 2;
|
|
101
|
-
},
|
|
102
|
-
networkMode: 'offlineFirst'
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
//# sourceMappingURL=useIdentityMutations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useMutation","useQueryClient","useCreateIdentity","createIdentityFn","queryClient","mutationFn","onSuccess","data","invalidateQueries","queryKey","onError","error","__DEV__","console","warn","retry","networkMode","useImportIdentity","importIdentityFn","useSyncIdentity","syncIdentityFn","user","setQueryData","failureCount","errorMessage","Error","message","String","isNetworkError","includes","code"],"sourceRoot":"../../../../src","sources":["ui/hooks/useIdentityMutations.ts"],"mappings":";;AAAA;AACA;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oration of recovery phrases (mnemonic seeds)
|
|
5
|
-
* for backing up and restoring user identities.
|
|
6
|
-
*
|
|
7
|
-
* Note: This module requires the polyfill to be loaded first (done via crypto/index.ts)
|
|
8
|
-
*/
|
|
9
|
-
export interface RecoveryPhraseResult {
|
|
10
|
-
phrase: string;
|
|
11
|
-
words: string[];
|
|
12
|
-
publicKey: string;
|
|
13
|
-
}
|
|
14
|
-
export declare class RecoveryPhraseService {
|
|
15
|
-
/**
|
|
16
|
-
* Generate a new identity with a recovery phrase
|
|
17
|
-
* Returns the mnemonic phrase (should only be shown once to the user)
|
|
18
|
-
*/
|
|
19
|
-
static generateIdentityWithRecovery(): Promise<RecoveryPhraseResult>;
|
|
20
|
-
/**
|
|
21
|
-
* Generate a 24-word recovery phrase for higher security
|
|
22
|
-
*/
|
|
23
|
-
static generateIdentityWithRecovery24(): Promise<RecoveryPhraseResult>;
|
|
24
|
-
/**
|
|
25
|
-
* Restore an identity from a recovery phrase
|
|
26
|
-
*/
|
|
27
|
-
static restoreFromPhrase(phrase: string): Promise<string>;
|
|
28
|
-
/**
|
|
29
|
-
* Validate a recovery phrase without importing it
|
|
30
|
-
*/
|
|
31
|
-
static validatePhrase(phrase: string): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Get the word list for autocomplete/validation
|
|
34
|
-
*/
|
|
35
|
-
static getWordList(): string[];
|
|
36
|
-
/**
|
|
37
|
-
* Check if a word is valid in the BIP39 word list
|
|
38
|
-
*/
|
|
39
|
-
static isValidWord(word: string): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Get suggestions for a partial word
|
|
42
|
-
*/
|
|
43
|
-
static getSuggestions(partial: string, limit?: number): string[];
|
|
44
|
-
/**
|
|
45
|
-
* Derive the public key from a phrase without storing
|
|
46
|
-
* Useful for verification before importing
|
|
47
|
-
*/
|
|
48
|
-
static derivePublicKeyFromPhrase(phrase: string): Promise<string>;
|
|
49
|
-
/**
|
|
50
|
-
* Convert a phrase to its word array
|
|
51
|
-
*/
|
|
52
|
-
static phraseToWords(phrase: string): string[];
|
|
53
|
-
/**
|
|
54
|
-
* Convert a word array to a phrase string
|
|
55
|
-
*/
|
|
56
|
-
static wordsToPhrase(words: string[]): string;
|
|
57
|
-
}
|
|
58
|
-
export default RecoveryPhraseService;
|
|
59
|
-
//# sourceMappingURL=recoveryPhrase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recoveryPhrase.d.ts","sourceRoot":"","sources":["../../../src/crypto/recoveryPhrase.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,qBAAqB;IAChC;;;OAGG;WACU,4BAA4B,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAsB1E;;OAEG;WACU,8BAA8B,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAgB5E;;OAEG;WACU,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmB/D;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAK9C;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,MAAM,EAAE;IAI9B;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIzC;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,MAAM,EAAE;IAOnE;;;OAGG;WACU,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAcvE;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAI9C;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;CAG9C;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
declare module 'bip39' {
|
|
2
|
-
export interface Wordlist {
|
|
3
|
-
[index: number]: string;
|
|
4
|
-
length: number;
|
|
5
|
-
getWord(index: number): string;
|
|
6
|
-
getWordIndex(word: string): number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const wordlists: {
|
|
10
|
-
english: string[];
|
|
11
|
-
chinese_simplified: string[];
|
|
12
|
-
chinese_traditional: string[];
|
|
13
|
-
french: string[];
|
|
14
|
-
italian: string[];
|
|
15
|
-
japanese: string[];
|
|
16
|
-
korean: string[];
|
|
17
|
-
spanish: string[];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// Use Uint8Array instead of Buffer for React Native compatibility
|
|
21
|
-
// In Node.js, Buffer extends Uint8Array so this is compatible
|
|
22
|
-
export function generateMnemonic(strength?: number, rng?: (size: number) => Uint8Array, wordlist?: string[]): string;
|
|
23
|
-
export function mnemonicToSeed(mnemonic: string, passphrase?: string): Promise<Uint8Array>;
|
|
24
|
-
export function mnemonicToSeedSync(mnemonic: string, passphrase?: string): Uint8Array;
|
|
25
|
-
export function mnemonicToEntropy(mnemonic: string, wordlist?: string[]): string;
|
|
26
|
-
export function entropyToMnemonic(entropy: string, wordlist?: string[]): string;
|
|
27
|
-
export function validateMnemonic(mnemonic: string, wordlist?: string[]): boolean;
|
|
28
|
-
export function mnemonicToSeedHex(mnemonic: string, passphrase?: string): Promise<string>;
|
|
29
|
-
export function mnemonicToSeedHexSync(mnemonic: string, passphrase?: string): string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TanStack Query mutations for identity operations
|
|
3
|
-
* Provides offline-first mutations for identity creation, import, and sync
|
|
4
|
-
* Never deletes identity on errors - preserves user data
|
|
5
|
-
*/
|
|
6
|
-
import type { User } from '../../models/interfaces';
|
|
7
|
-
export interface CreateIdentityResult {
|
|
8
|
-
recoveryPhrase: string[];
|
|
9
|
-
synced: boolean;
|
|
10
|
-
}
|
|
11
|
-
export interface ImportIdentityResult {
|
|
12
|
-
synced: boolean;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Hook for creating a new identity with offline support
|
|
16
|
-
* Never deletes identity on error - preserves user data
|
|
17
|
-
*/
|
|
18
|
-
export declare function useCreateIdentity(createIdentityFn: () => Promise<CreateIdentityResult>): import("@tanstack/react-query").UseMutationResult<CreateIdentityResult, Error, void, unknown>;
|
|
19
|
-
/**
|
|
20
|
-
* Hook for importing an identity from recovery phrase
|
|
21
|
-
* Never deletes identity on error - preserves user data
|
|
22
|
-
*/
|
|
23
|
-
export declare function useImportIdentity(importIdentityFn: (phrase: string) => Promise<ImportIdentityResult>): import("@tanstack/react-query").UseMutationResult<ImportIdentityResult, Error, string, unknown>;
|
|
24
|
-
/**
|
|
25
|
-
* Hook for syncing identity with server
|
|
26
|
-
* Never deletes identity on error - only logs and allows retry
|
|
27
|
-
*/
|
|
28
|
-
export declare function useSyncIdentity(syncIdentityFn: () => Promise<User>): import("@tanstack/react-query").UseMutationResult<User, Error, void, unknown>;
|
|
29
|
-
//# sourceMappingURL=useIdentityMutations.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIdentityMutations.d.ts","sourceRoot":"","sources":["../../../../src/ui/hooks/useIdentityMutations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,gBAAgB,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC,iGAqBtD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,mGAmBpE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,iFAoCpC"}
|