@oxyhq/services 5.17.7 → 5.17.9
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/lib/commonjs/crypto/index.js +0 -23
- package/lib/commonjs/crypto/index.js.map +1 -1
- package/lib/commonjs/index.js +0 -15
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/components/Icon.js.map +1 -1
- package/lib/commonjs/ui/components/IconButton/utils.js.map +1 -1
- package/lib/commonjs/ui/components/TextField/Adornment/utils.js.map +1 -1
- package/lib/commonjs/ui/components/TextField/helpers.js.map +1 -1
- package/lib/commonjs/ui/components/TouchableRipple/utils.js.map +1 -1
- package/lib/commonjs/ui/components/Typography/AnimatedText.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +37 -589
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContextBase.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +60 -425
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +8 -112
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +2 -27
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +2 -27
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSessionSocket.js +2 -88
- package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/commonjs/ui/screens/OxyAuthScreen.js +0 -1
- package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/commonjs/ui/stores/authStore.js +52 -15
- package/lib/commonjs/ui/stores/authStore.js.map +1 -1
- package/lib/commonjs/ui/utils/avatarUtils.js +2 -32
- package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
- package/lib/module/crypto/index.js +4 -6
- package/lib/module/crypto/index.js.map +1 -1
- package/lib/module/index.js +6 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/components/Icon.js.map +1 -1
- package/lib/module/ui/components/IconButton/utils.js.map +1 -1
- package/lib/module/ui/components/TextField/Adornment/utils.js.map +1 -1
- package/lib/module/ui/components/TextField/helpers.js.map +1 -1
- package/lib/module/ui/components/TouchableRipple/utils.js.map +1 -1
- package/lib/module/ui/components/Typography/AnimatedText.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +35 -588
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/OxyContextBase.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +60 -424
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/module/ui/hooks/mutations/useAccountMutations.js +8 -112
- package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/module/ui/hooks/queries/useAccountQueries.js +2 -27
- package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/module/ui/hooks/queries/useServicesQueries.js +2 -27
- package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/module/ui/hooks/useSessionSocket.js +2 -88
- package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/module/ui/screens/OxyAuthScreen.js +0 -1
- package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/module/ui/stores/authStore.js +52 -15
- package/lib/module/ui/stores/authStore.js.map +1 -1
- package/lib/module/ui/utils/avatarUtils.js +2 -32
- package/lib/module/ui/utils/avatarUtils.js.map +1 -1
- package/lib/typescript/crypto/index.d.ts +2 -5
- package/lib/typescript/crypto/index.d.ts.map +1 -1
- package/lib/typescript/crypto/types.d.ts +6 -2
- package/lib/typescript/crypto/types.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +4 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/ui/components/IconButton/utils.d.ts +1 -1
- package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts +1 -1
- package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts.map +1 -1
- package/lib/typescript/ui/components/TextField/helpers.d.ts +6 -6
- package/lib/typescript/ui/components/types.d.ts +0 -4
- package/lib/typescript/ui/components/types.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContextBase.d.ts +2 -39
- package/lib/typescript/ui/context/OxyContextBase.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +10 -25
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useSessionSocket.d.ts +1 -14
- package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
- package/lib/typescript/ui/stores/authStore.d.ts +27 -4
- package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
- package/lib/typescript/ui/utils/avatarUtils.d.ts +0 -2
- package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/crypto/index.ts +3 -11
- package/src/crypto/types.ts +6 -2
- package/src/index.ts +6 -11
- package/src/ui/components/Icon.tsx +1 -1
- package/src/ui/components/IconButton/utils.ts +1 -1
- package/src/ui/components/TextField/Adornment/utils.ts +2 -2
- package/src/ui/components/TextField/helpers.tsx +8 -8
- package/src/ui/components/TouchableRipple/utils.ts +2 -2
- package/src/ui/components/Typography/AnimatedText.tsx +2 -2
- package/src/ui/components/types.tsx +0 -6
- package/src/ui/context/OxyContext.tsx +33 -637
- package/src/ui/context/OxyContextBase.tsx +5 -23
- package/src/ui/context/hooks/useAuthOperations.ts +84 -460
- package/src/ui/hooks/mutations/useAccountMutations.ts +12 -110
- package/src/ui/hooks/queries/useAccountQueries.ts +3 -27
- package/src/ui/hooks/queries/useServicesQueries.ts +3 -27
- package/src/ui/hooks/useSessionSocket.ts +2 -106
- package/src/ui/screens/OxyAuthScreen.tsx +1 -1
- package/src/ui/stores/authStore.ts +57 -18
- package/src/ui/utils/avatarUtils.ts +4 -36
- package/lib/commonjs/crypto/keyManager.js +0 -511
- package/lib/commonjs/crypto/keyManager.js.map +0 -1
- package/lib/commonjs/crypto/signatureService.js +0 -269
- package/lib/commonjs/crypto/signatureService.js.map +0 -1
- package/lib/module/crypto/keyManager.js +0 -508
- package/lib/module/crypto/keyManager.js.map +0 -1
- package/lib/module/crypto/signatureService.js +0 -266
- package/lib/module/crypto/signatureService.js.map +0 -1
- package/lib/typescript/crypto/keyManager.d.ts +0 -97
- package/lib/typescript/crypto/keyManager.d.ts.map +0 -1
- package/lib/typescript/crypto/signatureService.d.ts +0 -77
- package/lib/typescript/crypto/signatureService.d.ts.map +0 -1
- package/src/crypto/keyManager.ts +0 -545
- package/src/crypto/signatureService.ts +0 -301
|
@@ -1,508 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Key Manager - ECDSA secp256k1 Key Generation and Storage
|
|
5
|
-
*
|
|
6
|
-
* Handles secure generation, storage, and retrieval of cryptographic keys.
|
|
7
|
-
* Private keys are stored securely using expo-secure-store and never leave the device.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { ec as EC } from 'elliptic';
|
|
11
|
-
import { Platform } from 'react-native';
|
|
12
|
-
|
|
13
|
-
// Lazy imports for React Native specific modules
|
|
14
|
-
let SecureStore = null;
|
|
15
|
-
let ExpoCrypto = null;
|
|
16
|
-
const ec = new EC('secp256k1');
|
|
17
|
-
const STORAGE_KEYS = {
|
|
18
|
-
PRIVATE_KEY: 'oxy_identity_private_key',
|
|
19
|
-
PUBLIC_KEY: 'oxy_identity_public_key',
|
|
20
|
-
BACKUP_PRIVATE_KEY: 'oxy_identity_backup_private_key',
|
|
21
|
-
BACKUP_PUBLIC_KEY: 'oxy_identity_backup_public_key',
|
|
22
|
-
BACKUP_TIMESTAMP: 'oxy_identity_backup_timestamp'
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Initialize React Native specific modules
|
|
27
|
-
* This allows the module to work in both Node.js and React Native environments
|
|
28
|
-
*/
|
|
29
|
-
async function initSecureStore() {
|
|
30
|
-
if (!SecureStore) {
|
|
31
|
-
try {
|
|
32
|
-
SecureStore = await import('expo-secure-store');
|
|
33
|
-
} catch (error) {
|
|
34
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
35
|
-
throw new Error(`Failed to load expo-secure-store: ${errorMessage}. Make sure expo-secure-store is installed and properly configured.`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (!SecureStore) {
|
|
39
|
-
throw new Error('expo-secure-store module is not available');
|
|
40
|
-
}
|
|
41
|
-
return SecureStore;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Check if we're in a React Native environment
|
|
46
|
-
*/
|
|
47
|
-
function isReactNative() {
|
|
48
|
-
return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Check if we're in a Node.js environment
|
|
53
|
-
*/
|
|
54
|
-
function isNodeJS() {
|
|
55
|
-
return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Check if we're on web platform
|
|
60
|
-
* Identity storage is only available on native platforms (iOS/Android)
|
|
61
|
-
*/
|
|
62
|
-
function isWebPlatform() {
|
|
63
|
-
try {
|
|
64
|
-
return Platform.OS === 'web';
|
|
65
|
-
} catch {
|
|
66
|
-
// Fallback if Platform is not available
|
|
67
|
-
return typeof window !== 'undefined' && typeof navigator !== 'undefined' && navigator.product !== 'ReactNative';
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async function initExpoCrypto() {
|
|
71
|
-
if (!ExpoCrypto) {
|
|
72
|
-
ExpoCrypto = await import('expo-crypto');
|
|
73
|
-
}
|
|
74
|
-
return ExpoCrypto;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Convert Uint8Array to hexadecimal string
|
|
79
|
-
* Works in both Node.js and React Native
|
|
80
|
-
*/
|
|
81
|
-
function uint8ArrayToHex(bytes) {
|
|
82
|
-
return Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Generate cryptographically secure random bytes
|
|
87
|
-
*/
|
|
88
|
-
async function getSecureRandomBytes(length) {
|
|
89
|
-
// In React Native, always use expo-crypto
|
|
90
|
-
if (isReactNative() || !isNodeJS()) {
|
|
91
|
-
const Crypto = await initExpoCrypto();
|
|
92
|
-
return Crypto.getRandomBytes(length);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// In Node.js, use Node's crypto module
|
|
96
|
-
// Use Function constructor to prevent Metro bundler from statically analyzing this require
|
|
97
|
-
// This ensures the require is only evaluated in Node.js runtime, not during Metro bundling
|
|
98
|
-
try {
|
|
99
|
-
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
100
|
-
const getCrypto = new Function('return require("crypto")');
|
|
101
|
-
const crypto = getCrypto();
|
|
102
|
-
return new Uint8Array(crypto.randomBytes(length));
|
|
103
|
-
} catch (error) {
|
|
104
|
-
// Fallback to expo-crypto if Node crypto fails
|
|
105
|
-
const Crypto = await initExpoCrypto();
|
|
106
|
-
return Crypto.getRandomBytes(length);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
export class KeyManager {
|
|
110
|
-
// In-memory cache for identity state (invalidated on identity changes)
|
|
111
|
-
static cachedPublicKey = null;
|
|
112
|
-
static cachedHasIdentity = null;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Invalidate cached identity state
|
|
116
|
-
* Called internally when identity is created/deleted/imported
|
|
117
|
-
*/
|
|
118
|
-
static invalidateCache() {
|
|
119
|
-
KeyManager.cachedPublicKey = null;
|
|
120
|
-
KeyManager.cachedHasIdentity = null;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Generate a new ECDSA secp256k1 key pair
|
|
125
|
-
* Returns the keys in hexadecimal format
|
|
126
|
-
*/
|
|
127
|
-
static generateKeyPairSync() {
|
|
128
|
-
const keyPair = ec.genKeyPair();
|
|
129
|
-
return {
|
|
130
|
-
privateKey: keyPair.getPrivate('hex'),
|
|
131
|
-
publicKey: keyPair.getPublic('hex')
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Generate a new key pair using secure random bytes
|
|
137
|
-
*/
|
|
138
|
-
static async generateKeyPair() {
|
|
139
|
-
const randomBytes = await getSecureRandomBytes(32);
|
|
140
|
-
const privateKeyHex = uint8ArrayToHex(randomBytes);
|
|
141
|
-
const keyPair = ec.keyFromPrivate(privateKeyHex);
|
|
142
|
-
return {
|
|
143
|
-
privateKey: keyPair.getPrivate('hex'),
|
|
144
|
-
publicKey: keyPair.getPublic('hex')
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Generate and securely store a new key pair on the device
|
|
150
|
-
* Returns only the public key (private key is stored securely)
|
|
151
|
-
*/
|
|
152
|
-
static async createIdentity() {
|
|
153
|
-
if (isWebPlatform()) {
|
|
154
|
-
throw new Error('Identity creation is only available on native platforms (iOS/Android). Please use the native app to create your identity.');
|
|
155
|
-
}
|
|
156
|
-
const store = await initSecureStore();
|
|
157
|
-
const {
|
|
158
|
-
privateKey,
|
|
159
|
-
publicKey
|
|
160
|
-
} = await KeyManager.generateKeyPair();
|
|
161
|
-
await store.setItemAsync(STORAGE_KEYS.PRIVATE_KEY, privateKey, {
|
|
162
|
-
keychainAccessible: store.WHEN_UNLOCKED_THIS_DEVICE_ONLY
|
|
163
|
-
});
|
|
164
|
-
await store.setItemAsync(STORAGE_KEYS.PUBLIC_KEY, publicKey);
|
|
165
|
-
|
|
166
|
-
// Update cache
|
|
167
|
-
KeyManager.cachedPublicKey = publicKey;
|
|
168
|
-
KeyManager.cachedHasIdentity = true;
|
|
169
|
-
return publicKey;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Import an existing key pair (e.g., from backup file)
|
|
174
|
-
*/
|
|
175
|
-
static async importKeyPair(privateKey) {
|
|
176
|
-
if (isWebPlatform()) {
|
|
177
|
-
throw new Error('Identity import is only available on native platforms (iOS/Android). Please use the native app to import your identity.');
|
|
178
|
-
}
|
|
179
|
-
const store = await initSecureStore();
|
|
180
|
-
const keyPair = ec.keyFromPrivate(privateKey);
|
|
181
|
-
const publicKey = keyPair.getPublic('hex');
|
|
182
|
-
await store.setItemAsync(STORAGE_KEYS.PRIVATE_KEY, privateKey, {
|
|
183
|
-
keychainAccessible: store.WHEN_UNLOCKED_THIS_DEVICE_ONLY
|
|
184
|
-
});
|
|
185
|
-
await store.setItemAsync(STORAGE_KEYS.PUBLIC_KEY, publicKey);
|
|
186
|
-
|
|
187
|
-
// Update cache
|
|
188
|
-
KeyManager.cachedPublicKey = publicKey;
|
|
189
|
-
KeyManager.cachedHasIdentity = true;
|
|
190
|
-
return publicKey;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Get the stored private key
|
|
195
|
-
* WARNING: Only use this for signing operations within the app
|
|
196
|
-
*/
|
|
197
|
-
static async getPrivateKey() {
|
|
198
|
-
if (isWebPlatform()) {
|
|
199
|
-
return null; // Identity storage is only available on native platforms
|
|
200
|
-
}
|
|
201
|
-
try {
|
|
202
|
-
const store = await initSecureStore();
|
|
203
|
-
return await store.getItemAsync(STORAGE_KEYS.PRIVATE_KEY);
|
|
204
|
-
} catch (error) {
|
|
205
|
-
// If secure store is not available, return null (no identity)
|
|
206
|
-
// This allows the app to continue functioning even if secure store fails to load
|
|
207
|
-
if (__DEV__) {
|
|
208
|
-
console.warn('[KeyManager] Failed to access secure store:', error);
|
|
209
|
-
}
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Get the stored public key (cached for performance)
|
|
216
|
-
*/
|
|
217
|
-
static async getPublicKey() {
|
|
218
|
-
if (isWebPlatform()) {
|
|
219
|
-
return null; // Identity storage is only available on native platforms
|
|
220
|
-
}
|
|
221
|
-
if (KeyManager.cachedPublicKey !== null) {
|
|
222
|
-
return KeyManager.cachedPublicKey;
|
|
223
|
-
}
|
|
224
|
-
try {
|
|
225
|
-
const store = await initSecureStore();
|
|
226
|
-
const publicKey = await store.getItemAsync(STORAGE_KEYS.PUBLIC_KEY);
|
|
227
|
-
|
|
228
|
-
// Cache result (null is a valid cache value meaning no identity)
|
|
229
|
-
KeyManager.cachedPublicKey = publicKey;
|
|
230
|
-
return publicKey;
|
|
231
|
-
} catch (error) {
|
|
232
|
-
// If secure store is not available, return null (no identity)
|
|
233
|
-
// Cache null to avoid repeated failed attempts
|
|
234
|
-
KeyManager.cachedPublicKey = null;
|
|
235
|
-
if (__DEV__) {
|
|
236
|
-
console.warn('[KeyManager] Failed to access secure store:', error);
|
|
237
|
-
}
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Check if an identity (key pair) exists on this device (cached for performance)
|
|
244
|
-
*/
|
|
245
|
-
static async hasIdentity() {
|
|
246
|
-
if (isWebPlatform()) {
|
|
247
|
-
return false; // Identity storage is only available on native platforms
|
|
248
|
-
}
|
|
249
|
-
if (KeyManager.cachedHasIdentity !== null) {
|
|
250
|
-
return KeyManager.cachedHasIdentity;
|
|
251
|
-
}
|
|
252
|
-
try {
|
|
253
|
-
const privateKey = await KeyManager.getPrivateKey();
|
|
254
|
-
const hasIdentity = privateKey !== null;
|
|
255
|
-
|
|
256
|
-
// Cache result
|
|
257
|
-
KeyManager.cachedHasIdentity = hasIdentity;
|
|
258
|
-
return hasIdentity;
|
|
259
|
-
} catch (error) {
|
|
260
|
-
// If we can't check, assume no identity (safer default)
|
|
261
|
-
// Cache false to avoid repeated failed attempts
|
|
262
|
-
KeyManager.cachedHasIdentity = false;
|
|
263
|
-
if (__DEV__) {
|
|
264
|
-
console.warn('[KeyManager] Failed to check identity:', error);
|
|
265
|
-
}
|
|
266
|
-
return false;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Delete the stored identity (both keys)
|
|
272
|
-
* Use with EXTREME caution - this is irreversible without a backup file
|
|
273
|
-
* This should ONLY be called when explicitly requested by the user
|
|
274
|
-
* @param skipBackup - If true, skip backup before deletion (default: false)
|
|
275
|
-
* @param force - If true, skip confirmation checks (default: false)
|
|
276
|
-
* @param userConfirmed - If true, user has explicitly confirmed deletion (default: false)
|
|
277
|
-
*/
|
|
278
|
-
static async deleteIdentity(skipBackup = false, force = false, userConfirmed = false) {
|
|
279
|
-
if (isWebPlatform()) {
|
|
280
|
-
return; // Identity storage is only available on native platforms, nothing to delete
|
|
281
|
-
}
|
|
282
|
-
// CRITICAL SAFEGUARD: Require explicit user confirmation unless force is true
|
|
283
|
-
if (!force && !userConfirmed) {
|
|
284
|
-
throw new Error('Identity deletion requires explicit user confirmation. This is a safety measure to prevent accidental data loss.');
|
|
285
|
-
}
|
|
286
|
-
if (!force) {
|
|
287
|
-
const hasIdentity = await KeyManager.hasIdentity();
|
|
288
|
-
if (!hasIdentity) {
|
|
289
|
-
return; // Nothing to delete
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
const store = await initSecureStore();
|
|
293
|
-
|
|
294
|
-
// ALWAYS create backup before deletion unless explicitly skipped
|
|
295
|
-
if (!skipBackup) {
|
|
296
|
-
try {
|
|
297
|
-
const backupSuccess = await KeyManager.backupIdentity();
|
|
298
|
-
if (!backupSuccess && typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
299
|
-
console.warn('[KeyManager] Failed to backup identity before deletion - proceeding anyway');
|
|
300
|
-
}
|
|
301
|
-
} catch (backupError) {
|
|
302
|
-
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
303
|
-
console.warn('[KeyManager] Failed to backup identity before deletion:', backupError);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
await store.deleteItemAsync(STORAGE_KEYS.PRIVATE_KEY);
|
|
308
|
-
await store.deleteItemAsync(STORAGE_KEYS.PUBLIC_KEY);
|
|
309
|
-
|
|
310
|
-
// Invalidate cache
|
|
311
|
-
KeyManager.invalidateCache();
|
|
312
|
-
|
|
313
|
-
// Also clear backup if force deletion
|
|
314
|
-
if (force) {
|
|
315
|
-
try {
|
|
316
|
-
await store.deleteItemAsync(STORAGE_KEYS.BACKUP_PRIVATE_KEY);
|
|
317
|
-
await store.deleteItemAsync(STORAGE_KEYS.BACKUP_PUBLIC_KEY);
|
|
318
|
-
await store.deleteItemAsync(STORAGE_KEYS.BACKUP_TIMESTAMP);
|
|
319
|
-
} catch (error) {
|
|
320
|
-
// Ignore backup deletion errors
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Backup identity to SecureStore (separate backup storage)
|
|
327
|
-
* This provides a recovery mechanism if primary storage fails
|
|
328
|
-
*/
|
|
329
|
-
static async backupIdentity() {
|
|
330
|
-
if (isWebPlatform()) {
|
|
331
|
-
return false; // Identity storage is only available on native platforms
|
|
332
|
-
}
|
|
333
|
-
try {
|
|
334
|
-
const store = await initSecureStore();
|
|
335
|
-
const privateKey = await KeyManager.getPrivateKey();
|
|
336
|
-
const publicKey = await KeyManager.getPublicKey();
|
|
337
|
-
if (!privateKey || !publicKey) {
|
|
338
|
-
return false; // Nothing to backup
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Store backup in SecureStore (still secure, but separate from primary storage)
|
|
342
|
-
await store.setItemAsync(STORAGE_KEYS.BACKUP_PRIVATE_KEY, privateKey, {
|
|
343
|
-
keychainAccessible: store.WHEN_UNLOCKED_THIS_DEVICE_ONLY
|
|
344
|
-
});
|
|
345
|
-
await store.setItemAsync(STORAGE_KEYS.BACKUP_PUBLIC_KEY, publicKey);
|
|
346
|
-
await store.setItemAsync(STORAGE_KEYS.BACKUP_TIMESTAMP, Date.now().toString());
|
|
347
|
-
return true;
|
|
348
|
-
} catch (error) {
|
|
349
|
-
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
350
|
-
console.error('[KeyManager] Failed to backup identity:', error);
|
|
351
|
-
}
|
|
352
|
-
return false;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Verify identity integrity - checks if keys are valid and accessible
|
|
358
|
-
*/
|
|
359
|
-
static async verifyIdentityIntegrity() {
|
|
360
|
-
if (isWebPlatform()) {
|
|
361
|
-
return false; // Identity storage is only available on native platforms
|
|
362
|
-
}
|
|
363
|
-
try {
|
|
364
|
-
const privateKey = await KeyManager.getPrivateKey();
|
|
365
|
-
const publicKey = await KeyManager.getPublicKey();
|
|
366
|
-
if (!privateKey || !publicKey) {
|
|
367
|
-
return false;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// Validate private key format
|
|
371
|
-
if (!KeyManager.isValidPrivateKey(privateKey)) {
|
|
372
|
-
return false;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// Validate public key format
|
|
376
|
-
if (!KeyManager.isValidPublicKey(publicKey)) {
|
|
377
|
-
return false;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
// Verify public key can be derived from private key
|
|
381
|
-
const derivedPublicKey = KeyManager.derivePublicKey(privateKey);
|
|
382
|
-
if (derivedPublicKey !== publicKey) {
|
|
383
|
-
return false; // Keys don't match
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// Verify we can create a key pair object (tests elliptic curve operations)
|
|
387
|
-
const keyPair = await KeyManager.getKeyPairObject();
|
|
388
|
-
if (!keyPair) {
|
|
389
|
-
return false;
|
|
390
|
-
}
|
|
391
|
-
return true;
|
|
392
|
-
} catch (error) {
|
|
393
|
-
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
394
|
-
console.error('[KeyManager] Identity integrity check failed:', error);
|
|
395
|
-
}
|
|
396
|
-
return false;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Restore identity from backup if primary storage is corrupted
|
|
402
|
-
*/
|
|
403
|
-
static async restoreIdentityFromBackup() {
|
|
404
|
-
if (isWebPlatform()) {
|
|
405
|
-
return false; // Identity storage is only available on native platforms
|
|
406
|
-
}
|
|
407
|
-
try {
|
|
408
|
-
const store = await initSecureStore();
|
|
409
|
-
|
|
410
|
-
// Check if backup exists
|
|
411
|
-
const backupPrivateKey = await store.getItemAsync(STORAGE_KEYS.BACKUP_PRIVATE_KEY);
|
|
412
|
-
const backupPublicKey = await store.getItemAsync(STORAGE_KEYS.BACKUP_PUBLIC_KEY);
|
|
413
|
-
if (!backupPrivateKey || !backupPublicKey) {
|
|
414
|
-
return false; // No backup available
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
// Verify backup integrity
|
|
418
|
-
if (!KeyManager.isValidPrivateKey(backupPrivateKey)) {
|
|
419
|
-
return false;
|
|
420
|
-
}
|
|
421
|
-
if (!KeyManager.isValidPublicKey(backupPublicKey)) {
|
|
422
|
-
return false;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// Verify keys match
|
|
426
|
-
const derivedPublicKey = KeyManager.derivePublicKey(backupPrivateKey);
|
|
427
|
-
if (derivedPublicKey !== backupPublicKey) {
|
|
428
|
-
return false; // Backup keys don't match
|
|
429
|
-
}
|
|
430
|
-
await store.setItemAsync(STORAGE_KEYS.PRIVATE_KEY, backupPrivateKey, {
|
|
431
|
-
keychainAccessible: store.WHEN_UNLOCKED_THIS_DEVICE_ONLY
|
|
432
|
-
});
|
|
433
|
-
await store.setItemAsync(STORAGE_KEYS.PUBLIC_KEY, backupPublicKey);
|
|
434
|
-
const restored = await KeyManager.verifyIdentityIntegrity();
|
|
435
|
-
if (restored) {
|
|
436
|
-
// Update cache
|
|
437
|
-
KeyManager.cachedPublicKey = backupPublicKey;
|
|
438
|
-
KeyManager.cachedHasIdentity = true;
|
|
439
|
-
await store.setItemAsync(STORAGE_KEYS.BACKUP_TIMESTAMP, Date.now().toString());
|
|
440
|
-
return true;
|
|
441
|
-
}
|
|
442
|
-
return false;
|
|
443
|
-
} catch (error) {
|
|
444
|
-
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
445
|
-
console.error('[KeyManager] Failed to restore identity from backup:', error);
|
|
446
|
-
}
|
|
447
|
-
return false;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Get the elliptic curve key object from the stored private key
|
|
453
|
-
* Used internally for signing operations
|
|
454
|
-
*/
|
|
455
|
-
static async getKeyPairObject() {
|
|
456
|
-
if (isWebPlatform()) {
|
|
457
|
-
return null; // Identity storage is only available on native platforms
|
|
458
|
-
}
|
|
459
|
-
const privateKey = await KeyManager.getPrivateKey();
|
|
460
|
-
if (!privateKey) return null;
|
|
461
|
-
return ec.keyFromPrivate(privateKey);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Derive public key from a private key (without storing)
|
|
466
|
-
*/
|
|
467
|
-
static derivePublicKey(privateKey) {
|
|
468
|
-
const keyPair = ec.keyFromPrivate(privateKey);
|
|
469
|
-
return keyPair.getPublic('hex');
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* Validate that a string is a valid public key
|
|
474
|
-
*/
|
|
475
|
-
static isValidPublicKey(publicKey) {
|
|
476
|
-
try {
|
|
477
|
-
ec.keyFromPublic(publicKey, 'hex');
|
|
478
|
-
return true;
|
|
479
|
-
} catch {
|
|
480
|
-
return false;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Validate that a string is a valid private key
|
|
486
|
-
*/
|
|
487
|
-
static isValidPrivateKey(privateKey) {
|
|
488
|
-
try {
|
|
489
|
-
const keyPair = ec.keyFromPrivate(privateKey);
|
|
490
|
-
// Verify it can derive a public key
|
|
491
|
-
keyPair.getPublic('hex');
|
|
492
|
-
return true;
|
|
493
|
-
} catch {
|
|
494
|
-
return false;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* Get a shortened version of the public key for display
|
|
500
|
-
* Format: first 8 chars...last 8 chars
|
|
501
|
-
*/
|
|
502
|
-
static shortenPublicKey(publicKey) {
|
|
503
|
-
if (publicKey.length <= 20) return publicKey;
|
|
504
|
-
return `${publicKey.slice(0, 8)}...${publicKey.slice(-8)}`;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
export default KeyManager;
|
|
508
|
-
//# sourceMappingURL=keyManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ec","EC","Platform","SecureStore","ExpoCrypto","STORAGE_KEYS","PRIVATE_KEY","PUBLIC_KEY","BACKUP_PRIVATE_KEY","BACKUP_PUBLIC_KEY","BACKUP_TIMESTAMP","initSecureStore","error","errorMessage","Error","message","String","isReactNative","navigator","product","isNodeJS","process","versions","node","isWebPlatform","OS","window","initExpoCrypto","uint8ArrayToHex","bytes","Array","from","map","b","toString","padStart","join","getSecureRandomBytes","length","Crypto","getRandomBytes","getCrypto","Function","crypto","Uint8Array","randomBytes","KeyManager","cachedPublicKey","cachedHasIdentity","invalidateCache","generateKeyPairSync","keyPair","genKeyPair","privateKey","getPrivate","publicKey","getPublic","generateKeyPair","privateKeyHex","keyFromPrivate","createIdentity","store","setItemAsync","keychainAccessible","WHEN_UNLOCKED_THIS_DEVICE_ONLY","importKeyPair","getPrivateKey","getItemAsync","__DEV__","console","warn","getPublicKey","hasIdentity","deleteIdentity","skipBackup","force","userConfirmed","backupSuccess","backupIdentity","backupError","deleteItemAsync","Date","now","verifyIdentityIntegrity","isValidPrivateKey","isValidPublicKey","derivedPublicKey","derivePublicKey","getKeyPairObject","restoreIdentityFromBackup","backupPrivateKey","backupPublicKey","restored","keyFromPublic","shortenPublicKey","slice"],"sourceRoot":"../../../src","sources":["crypto/keyManager.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,EAAE,IAAIC,EAAE,QAAQ,UAAU;AAEnC,SAASC,QAAQ,QAAQ,cAAc;;AAEvC;AACA,IAAIC,WAAsD,GAAG,IAAI;AACjE,IAAIC,UAA+C,GAAG,IAAI;AAE1D,MAAMJ,EAAE,GAAG,IAAIC,EAAE,CAAC,WAAW,CAAC;AAE9B,MAAMI,YAAY,GAAG;EACnBC,WAAW,EAAE,0BAA0B;EACvCC,UAAU,EAAE,yBAAyB;EACrCC,kBAAkB,EAAE,iCAAiC;EACrDC,iBAAiB,EAAE,gCAAgC;EACnDC,gBAAgB,EAAE;AACpB,CAAU;;AAEV;AACA;AACA;AACA;AACA,eAAeC,eAAeA,CAAA,EAAgD;EAC5E,IAAI,CAACR,WAAW,EAAE;IAChB,IAAI;MACFA,WAAW,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC;IACjD,CAAC,CAAC,OAAOS,KAAK,EAAE;MACd,MAAMC,YAAY,GAAGD,KAAK,YAAYE,KAAK,GAAGF,KAAK,CAACG,OAAO,GAAGC,MAAM,CAACJ,KAAK,CAAC;MAC3E,MAAM,IAAIE,KAAK,CAAC,qCAAqCD,YAAY,qEAAqE,CAAC;IACzI;EACF;EACA,IAAI,CAACV,WAAW,EAAE;IAChB,MAAM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