@oxyhq/services 5.17.8 → 5.17.10

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.
Files changed (97) hide show
  1. package/lib/commonjs/crypto/index.js +0 -23
  2. package/lib/commonjs/crypto/index.js.map +1 -1
  3. package/lib/commonjs/index.js +0 -15
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/ui/components/Icon.js.map +1 -1
  6. package/lib/commonjs/ui/components/IconButton/utils.js.map +1 -1
  7. package/lib/commonjs/ui/components/TextField/Adornment/utils.js.map +1 -1
  8. package/lib/commonjs/ui/components/TextField/helpers.js.map +1 -1
  9. package/lib/commonjs/ui/components/TouchableRipple/utils.js.map +1 -1
  10. package/lib/commonjs/ui/components/Typography/AnimatedText.js.map +1 -1
  11. package/lib/commonjs/ui/context/OxyContext.js +20 -35
  12. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  13. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +41 -118
  14. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  15. package/lib/commonjs/ui/hooks/useSessionSocket.js +2 -26
  16. package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
  17. package/lib/commonjs/ui/screens/OxyAuthScreen.js +0 -1
  18. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
  19. package/lib/commonjs/ui/stores/authStore.js +33 -13
  20. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  21. package/lib/commonjs/ui/utils/avatarUtils.js +2 -32
  22. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  23. package/lib/module/crypto/index.js +4 -6
  24. package/lib/module/crypto/index.js.map +1 -1
  25. package/lib/module/index.js +6 -3
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/module/ui/components/Icon.js.map +1 -1
  28. package/lib/module/ui/components/IconButton/utils.js.map +1 -1
  29. package/lib/module/ui/components/TextField/Adornment/utils.js.map +1 -1
  30. package/lib/module/ui/components/TextField/helpers.js.map +1 -1
  31. package/lib/module/ui/components/TouchableRipple/utils.js.map +1 -1
  32. package/lib/module/ui/components/Typography/AnimatedText.js.map +1 -1
  33. package/lib/module/ui/context/OxyContext.js +20 -36
  34. package/lib/module/ui/context/OxyContext.js.map +1 -1
  35. package/lib/module/ui/context/hooks/useAuthOperations.js +41 -118
  36. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  37. package/lib/module/ui/hooks/useSessionSocket.js +2 -26
  38. package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
  39. package/lib/module/ui/screens/OxyAuthScreen.js +0 -1
  40. package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
  41. package/lib/module/ui/stores/authStore.js +33 -13
  42. package/lib/module/ui/stores/authStore.js.map +1 -1
  43. package/lib/module/ui/utils/avatarUtils.js +2 -32
  44. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  45. package/lib/typescript/crypto/index.d.ts +2 -5
  46. package/lib/typescript/crypto/index.d.ts.map +1 -1
  47. package/lib/typescript/crypto/types.d.ts +2 -2
  48. package/lib/typescript/index.d.ts +4 -2
  49. package/lib/typescript/index.d.ts.map +1 -1
  50. package/lib/typescript/ui/components/IconButton/utils.d.ts +1 -1
  51. package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts +1 -1
  52. package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts.map +1 -1
  53. package/lib/typescript/ui/components/TextField/helpers.d.ts +6 -6
  54. package/lib/typescript/ui/components/types.d.ts +0 -4
  55. package/lib/typescript/ui/components/types.d.ts.map +1 -1
  56. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  57. package/lib/typescript/ui/context/OxyContextBase.d.ts +2 -2
  58. package/lib/typescript/ui/context/OxyContextBase.d.ts.map +1 -1
  59. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +2 -9
  60. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  61. package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
  62. package/lib/typescript/ui/stores/authStore.d.ts +5 -3
  63. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  64. package/lib/typescript/ui/utils/avatarUtils.d.ts +0 -2
  65. package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
  66. package/package.json +2 -2
  67. package/src/crypto/index.ts +3 -11
  68. package/src/crypto/types.ts +2 -2
  69. package/src/index.ts +6 -11
  70. package/src/ui/components/Icon.tsx +1 -1
  71. package/src/ui/components/IconButton/utils.ts +1 -1
  72. package/src/ui/components/TextField/Adornment/utils.ts +2 -2
  73. package/src/ui/components/TextField/helpers.tsx +8 -8
  74. package/src/ui/components/TouchableRipple/utils.ts +2 -2
  75. package/src/ui/components/Typography/AnimatedText.tsx +2 -2
  76. package/src/ui/components/types.tsx +0 -6
  77. package/src/ui/context/OxyContext.tsx +22 -27
  78. package/src/ui/context/OxyContextBase.tsx +4 -4
  79. package/src/ui/context/hooks/useAuthOperations.ts +61 -140
  80. package/src/ui/hooks/useSessionSocket.ts +3 -21
  81. package/src/ui/screens/OxyAuthScreen.tsx +1 -1
  82. package/src/ui/stores/authStore.ts +39 -18
  83. package/src/ui/utils/avatarUtils.ts +4 -36
  84. package/lib/commonjs/crypto/keyManager.js +0 -356
  85. package/lib/commonjs/crypto/keyManager.js.map +0 -1
  86. package/lib/commonjs/crypto/signatureService.js +0 -269
  87. package/lib/commonjs/crypto/signatureService.js.map +0 -1
  88. package/lib/module/crypto/keyManager.js +0 -353
  89. package/lib/module/crypto/keyManager.js.map +0 -1
  90. package/lib/module/crypto/signatureService.js +0 -266
  91. package/lib/module/crypto/signatureService.js.map +0 -1
  92. package/lib/typescript/crypto/keyManager.d.ts +0 -80
  93. package/lib/typescript/crypto/keyManager.d.ts.map +0 -1
  94. package/lib/typescript/crypto/signatureService.d.ts +0 -77
  95. package/lib/typescript/crypto/signatureService.d.ts.map +0 -1
  96. package/src/crypto/keyManager.ts +0 -379
  97. package/src/crypto/signatureService.ts +0 -301
@@ -61,7 +61,6 @@ export function refreshAvatarInStore(
61
61
  * @param oxyServices - OxyServices instance
62
62
  * @param activeSessionId - Active session ID
63
63
  * @param queryClient - TanStack Query client
64
- * @param syncIdentity - Optional sync identity function for handling auth errors
65
64
  * @returns Promise that resolves with updated user data
66
65
  */
67
66
  export async function updateProfileWithAvatar(
@@ -69,29 +68,15 @@ export async function updateProfileWithAvatar(
69
68
  oxyServices: OxyServices,
70
69
  activeSessionId: string | null,
71
70
  queryClient: QueryClient,
72
- options?: { syncIdentity?: () => Promise<User>; deviceId?: string }
71
+ options?: { deviceId?: string }
73
72
  ): Promise<User> {
74
- const { syncIdentity, deviceId } = options || {};
73
+ const { deviceId } = options || {};
75
74
  // Ensure we have a valid token before making the request
76
75
  if (!oxyServices.hasValidToken() && activeSessionId) {
77
76
  try {
78
77
  await oxyServices.getTokenBySession(activeSessionId, deviceId);
79
78
  } catch (tokenError) {
80
- const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
81
- if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
82
- if (syncIdentity) {
83
- try {
84
- await syncIdentity();
85
- await oxyServices.getTokenBySession(activeSessionId, deviceId);
86
- } catch (syncError) {
87
- throw new Error('Session needs to be synced. Please try again.');
88
- }
89
- } else {
90
- throw tokenError;
91
- }
92
- } else {
93
- throw tokenError;
94
- }
79
+ throw tokenError;
95
80
  }
96
81
  }
97
82
 
@@ -120,24 +105,7 @@ export async function updateProfileWithAvatar(
120
105
 
121
106
  // Handle authentication errors
122
107
  if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
123
- if (activeSessionId && syncIdentity) {
124
- try {
125
- await syncIdentity();
126
- await oxyServices.getTokenBySession(activeSessionId, deviceId);
127
- // Retry the update after getting token
128
- return await updateProfileWithAvatar(
129
- updates,
130
- oxyServices,
131
- activeSessionId,
132
- queryClient,
133
- { syncIdentity, deviceId }
134
- );
135
- } catch (retryError) {
136
- throw new Error('Authentication failed. Please sign in again.');
137
- }
138
- } else {
139
- throw new Error('No active session. Please sign in.');
140
- }
108
+ throw new Error('Authentication failed. Please sign in again.');
141
109
  }
142
110
 
143
111
  throw error;
@@ -1,356 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.KeyManager = void 0;
7
- var _elliptic = require("elliptic");
8
- var _reactNative = require("react-native");
9
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } /**
10
- * Key Manager - ECDSA secp256k1 Key Generation and Storage
11
- *
12
- * Handles secure generation, storage, and retrieval of cryptographic keys.
13
- * Private keys are stored securely using expo-secure-store and never leave the device.
14
- */
15
- // Lazy imports for React Native specific modules
16
- let SecureStore = null;
17
- let ExpoCrypto = null;
18
- const ec = new _elliptic.ec('secp256k1');
19
- const STORAGE_KEYS = {
20
- PRIVATE_KEY: 'oxy_identity_private_key',
21
- PUBLIC_KEY: 'oxy_identity_public_key'
22
- };
23
-
24
- /**
25
- * Initialize React Native specific modules
26
- * This allows the module to work in both Node.js and React Native environments
27
- */
28
- async function initSecureStore() {
29
- if (!SecureStore) {
30
- try {
31
- SecureStore = await Promise.resolve().then(() => _interopRequireWildcard(require('expo-secure-store')));
32
- } catch (error) {
33
- const errorMessage = error instanceof Error ? error.message : String(error);
34
- throw new Error(`Failed to load expo-secure-store: ${errorMessage}. Make sure expo-secure-store is installed and properly configured.`);
35
- }
36
- }
37
- if (!SecureStore) {
38
- throw new Error('expo-secure-store module is not available');
39
- }
40
- return SecureStore;
41
- }
42
-
43
- /**
44
- * Check if we're in a React Native environment
45
- */
46
- function isReactNative() {
47
- return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
48
- }
49
-
50
- /**
51
- * Check if we're in a Node.js environment
52
- */
53
- function isNodeJS() {
54
- return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
55
- }
56
-
57
- /**
58
- * Check if we're on web platform
59
- * Identity storage is only available on native platforms (iOS/Android)
60
- */
61
- function isWebPlatform() {
62
- try {
63
- return _reactNative.Platform.OS === 'web';
64
- } catch {
65
- // Fallback if Platform is not available
66
- return typeof window !== 'undefined' && typeof navigator !== 'undefined' && navigator.product !== 'ReactNative';
67
- }
68
- }
69
- async function initExpoCrypto() {
70
- if (!ExpoCrypto) {
71
- ExpoCrypto = await Promise.resolve().then(() => _interopRequireWildcard(require('expo-crypto')));
72
- }
73
- return ExpoCrypto;
74
- }
75
-
76
- /**
77
- * Convert Uint8Array to hexadecimal string
78
- * Works in both Node.js and React Native
79
- */
80
- function uint8ArrayToHex(bytes) {
81
- return Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
82
- }
83
-
84
- /**
85
- * Generate cryptographically secure random bytes
86
- */
87
- async function getSecureRandomBytes(length) {
88
- // In React Native, always use expo-crypto
89
- if (isReactNative() || !isNodeJS()) {
90
- const Crypto = await initExpoCrypto();
91
- return Crypto.getRandomBytes(length);
92
- }
93
-
94
- // In Node.js, use Node's crypto module
95
- // Use Function constructor to prevent Metro bundler from statically analyzing this require
96
- // This ensures the require is only evaluated in Node.js runtime, not during Metro bundling
97
- try {
98
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
99
- const getCrypto = new Function('return require("crypto")');
100
- const crypto = getCrypto();
101
- return new Uint8Array(crypto.randomBytes(length));
102
- } catch (error) {
103
- // Fallback to expo-crypto if Node crypto fails
104
- const Crypto = await initExpoCrypto();
105
- return Crypto.getRandomBytes(length);
106
- }
107
- }
108
- class KeyManager {
109
- /**
110
- * Generate a new ECDSA secp256k1 key pair
111
- * Returns the keys in hexadecimal format
112
- */
113
- static generateKeyPairSync() {
114
- const keyPair = ec.genKeyPair();
115
- return {
116
- privateKey: keyPair.getPrivate('hex'),
117
- publicKey: keyPair.getPublic('hex')
118
- };
119
- }
120
-
121
- /**
122
- * Generate a new key pair using secure random bytes
123
- */
124
- static async generateKeyPair() {
125
- const randomBytes = await getSecureRandomBytes(32);
126
- const privateKeyHex = uint8ArrayToHex(randomBytes);
127
- const keyPair = ec.keyFromPrivate(privateKeyHex);
128
- return {
129
- privateKey: keyPair.getPrivate('hex'),
130
- publicKey: keyPair.getPublic('hex')
131
- };
132
- }
133
-
134
- /**
135
- * Generate and securely store a new key pair on the device
136
- * Returns only the public key (private key is stored securely)
137
- */
138
- static async createIdentity() {
139
- if (isWebPlatform()) {
140
- throw new Error('Identity creation is only available on native platforms (iOS/Android). Please use the native app to create your identity.');
141
- }
142
- const store = await initSecureStore();
143
- const {
144
- privateKey,
145
- publicKey
146
- } = await KeyManager.generateKeyPair();
147
- await store.setItemAsync(STORAGE_KEYS.PRIVATE_KEY, privateKey, {
148
- keychainAccessible: store.WHEN_UNLOCKED_THIS_DEVICE_ONLY
149
- });
150
- await store.setItemAsync(STORAGE_KEYS.PUBLIC_KEY, publicKey);
151
- return publicKey;
152
- }
153
-
154
- /**
155
- * Import an existing key pair (e.g., from backup file)
156
- */
157
- static async importKeyPair(privateKey) {
158
- if (isWebPlatform()) {
159
- throw new Error('Identity import is only available on native platforms (iOS/Android). Please use the native app to import your identity.');
160
- }
161
- const store = await initSecureStore();
162
- const keyPair = ec.keyFromPrivate(privateKey);
163
- const publicKey = keyPair.getPublic('hex');
164
- await store.setItemAsync(STORAGE_KEYS.PRIVATE_KEY, privateKey, {
165
- keychainAccessible: store.WHEN_UNLOCKED_THIS_DEVICE_ONLY
166
- });
167
- await store.setItemAsync(STORAGE_KEYS.PUBLIC_KEY, publicKey);
168
- return publicKey;
169
- }
170
-
171
- /**
172
- * Get the stored private key
173
- * WARNING: Only use this for signing operations within the app
174
- */
175
- static async getPrivateKey() {
176
- if (isWebPlatform()) {
177
- return null; // Identity storage is only available on native platforms
178
- }
179
- try {
180
- const store = await initSecureStore();
181
- return await store.getItemAsync(STORAGE_KEYS.PRIVATE_KEY);
182
- } catch (error) {
183
- // If secure store is not available, return null (no identity)
184
- // This allows the app to continue functioning even if secure store fails to load
185
- if (__DEV__) {
186
- console.warn('[KeyManager] Failed to access secure store:', error);
187
- }
188
- return null;
189
- }
190
- }
191
-
192
- /**
193
- * Get the stored public key
194
- */
195
- static async getPublicKey() {
196
- if (isWebPlatform()) {
197
- return null; // Identity storage is only available on native platforms
198
- }
199
- try {
200
- const store = await initSecureStore();
201
- return await store.getItemAsync(STORAGE_KEYS.PUBLIC_KEY);
202
- } catch (error) {
203
- if (__DEV__) {
204
- console.warn('[KeyManager] Failed to access secure store:', error);
205
- }
206
- return null;
207
- }
208
- }
209
-
210
- /**
211
- * Check if an identity (key pair) exists on this device
212
- */
213
- static async hasIdentity() {
214
- if (isWebPlatform()) {
215
- return false; // Identity storage is only available on native platforms
216
- }
217
- try {
218
- const privateKey = await KeyManager.getPrivateKey();
219
- return privateKey !== null;
220
- } catch (error) {
221
- if (__DEV__) {
222
- console.warn('[KeyManager] Failed to check identity:', error);
223
- }
224
- return false;
225
- }
226
- }
227
-
228
- /**
229
- * Delete the stored identity (both keys)
230
- * Use with EXTREME caution - this is irreversible without a backup file
231
- * This should ONLY be called when explicitly requested by the user
232
- * @param force - If true, skip confirmation checks (default: false)
233
- * @param userConfirmed - If true, user has explicitly confirmed deletion (default: false)
234
- */
235
- static async deleteIdentity(force = false, userConfirmed = false) {
236
- if (isWebPlatform()) {
237
- return; // Identity storage is only available on native platforms, nothing to delete
238
- }
239
- // CRITICAL SAFEGUARD: Require explicit user confirmation unless force is true
240
- if (!force && !userConfirmed) {
241
- throw new Error('Identity deletion requires explicit user confirmation. This is a safety measure to prevent accidental data loss.');
242
- }
243
- if (!force) {
244
- const hasIdentity = await KeyManager.hasIdentity();
245
- if (!hasIdentity) {
246
- return; // Nothing to delete
247
- }
248
- }
249
- const store = await initSecureStore();
250
- await store.deleteItemAsync(STORAGE_KEYS.PRIVATE_KEY);
251
- await store.deleteItemAsync(STORAGE_KEYS.PUBLIC_KEY);
252
- }
253
-
254
- /**
255
- * Verify identity integrity - checks if keys are valid and accessible
256
- */
257
- static async verifyIdentityIntegrity() {
258
- if (isWebPlatform()) {
259
- return false; // Identity storage is only available on native platforms
260
- }
261
- try {
262
- const privateKey = await KeyManager.getPrivateKey();
263
- const publicKey = await KeyManager.getPublicKey();
264
- if (!privateKey || !publicKey) {
265
- return false;
266
- }
267
-
268
- // Validate private key format
269
- if (!KeyManager.isValidPrivateKey(privateKey)) {
270
- return false;
271
- }
272
-
273
- // Validate public key format
274
- if (!KeyManager.isValidPublicKey(publicKey)) {
275
- return false;
276
- }
277
-
278
- // Verify public key can be derived from private key
279
- const derivedPublicKey = KeyManager.derivePublicKey(privateKey);
280
- if (derivedPublicKey !== publicKey) {
281
- return false; // Keys don't match
282
- }
283
-
284
- // Verify we can create a key pair object (tests elliptic curve operations)
285
- const keyPair = await KeyManager.getKeyPairObject();
286
- if (!keyPair) {
287
- return false;
288
- }
289
- return true;
290
- } catch (error) {
291
- if (typeof __DEV__ !== 'undefined' && __DEV__) {
292
- console.error('[KeyManager] Identity integrity check failed:', error);
293
- }
294
- return false;
295
- }
296
- }
297
-
298
- /**
299
- * Get the elliptic curve key object from the stored private key
300
- * Used internally for signing operations
301
- */
302
- static async getKeyPairObject() {
303
- if (isWebPlatform()) {
304
- return null; // Identity storage is only available on native platforms
305
- }
306
- const privateKey = await KeyManager.getPrivateKey();
307
- if (!privateKey) return null;
308
- return ec.keyFromPrivate(privateKey);
309
- }
310
-
311
- /**
312
- * Derive public key from a private key (without storing)
313
- */
314
- static derivePublicKey(privateKey) {
315
- const keyPair = ec.keyFromPrivate(privateKey);
316
- return keyPair.getPublic('hex');
317
- }
318
-
319
- /**
320
- * Validate that a string is a valid public key
321
- */
322
- static isValidPublicKey(publicKey) {
323
- try {
324
- ec.keyFromPublic(publicKey, 'hex');
325
- return true;
326
- } catch {
327
- return false;
328
- }
329
- }
330
-
331
- /**
332
- * Validate that a string is a valid private key
333
- */
334
- static isValidPrivateKey(privateKey) {
335
- try {
336
- const keyPair = ec.keyFromPrivate(privateKey);
337
- // Verify it can derive a public key
338
- keyPair.getPublic('hex');
339
- return true;
340
- } catch {
341
- return false;
342
- }
343
- }
344
-
345
- /**
346
- * Get a shortened version of the public key for display
347
- * Format: first 8 chars...last 8 chars
348
- */
349
- static shortenPublicKey(publicKey) {
350
- if (publicKey.length <= 20) return publicKey;
351
- return `${publicKey.slice(0, 8)}...${publicKey.slice(-8)}`;
352
- }
353
- }
354
- exports.KeyManager = KeyManager;
355
- var _default = exports.default = KeyManager;
356
- //# sourceMappingURL=keyManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_elliptic","require","_reactNative","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","SecureStore","ExpoCrypto","ec","EC","STORAGE_KEYS","PRIVATE_KEY","PUBLIC_KEY","initSecureStore","Promise","resolve","then","error","errorMessage","Error","message","String","isReactNative","navigator","product","isNodeJS","process","versions","node","isWebPlatform","Platform","OS","window","initExpoCrypto","uint8ArrayToHex","bytes","Array","from","map","b","toString","padStart","join","getSecureRandomBytes","length","Crypto","getRandomBytes","getCrypto","Function","crypto","Uint8Array","randomBytes","KeyManager","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","force","userConfirmed","deleteItemAsync","verifyIdentityIntegrity","isValidPrivateKey","isValidPublicKey","derivedPublicKey","derivePublicKey","getKeyPairObject","keyFromPublic","shortenPublicKey","slice","exports","_default"],"sourceRoot":"../../../src","sources":["crypto/keyManager.ts"],"mappings":";;;;;;AAOA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAAwC,SAAAE,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA,KATxC;AACA;AACA;AACA;AACA;A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