@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.
Files changed (119) 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 +37 -589
  12. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  13. package/lib/commonjs/ui/context/OxyContextBase.js.map +1 -1
  14. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +60 -425
  15. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  16. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +8 -112
  17. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  18. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +2 -27
  19. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  20. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +2 -27
  21. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
  22. package/lib/commonjs/ui/hooks/useSessionSocket.js +2 -88
  23. package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
  24. package/lib/commonjs/ui/screens/OxyAuthScreen.js +0 -1
  25. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
  26. package/lib/commonjs/ui/stores/authStore.js +52 -15
  27. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  28. package/lib/commonjs/ui/utils/avatarUtils.js +2 -32
  29. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  30. package/lib/module/crypto/index.js +4 -6
  31. package/lib/module/crypto/index.js.map +1 -1
  32. package/lib/module/index.js +6 -3
  33. package/lib/module/index.js.map +1 -1
  34. package/lib/module/ui/components/Icon.js.map +1 -1
  35. package/lib/module/ui/components/IconButton/utils.js.map +1 -1
  36. package/lib/module/ui/components/TextField/Adornment/utils.js.map +1 -1
  37. package/lib/module/ui/components/TextField/helpers.js.map +1 -1
  38. package/lib/module/ui/components/TouchableRipple/utils.js.map +1 -1
  39. package/lib/module/ui/components/Typography/AnimatedText.js.map +1 -1
  40. package/lib/module/ui/context/OxyContext.js +35 -588
  41. package/lib/module/ui/context/OxyContext.js.map +1 -1
  42. package/lib/module/ui/context/OxyContextBase.js.map +1 -1
  43. package/lib/module/ui/context/hooks/useAuthOperations.js +60 -424
  44. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  45. package/lib/module/ui/hooks/mutations/useAccountMutations.js +8 -112
  46. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  47. package/lib/module/ui/hooks/queries/useAccountQueries.js +2 -27
  48. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  49. package/lib/module/ui/hooks/queries/useServicesQueries.js +2 -27
  50. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
  51. package/lib/module/ui/hooks/useSessionSocket.js +2 -88
  52. package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
  53. package/lib/module/ui/screens/OxyAuthScreen.js +0 -1
  54. package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
  55. package/lib/module/ui/stores/authStore.js +52 -15
  56. package/lib/module/ui/stores/authStore.js.map +1 -1
  57. package/lib/module/ui/utils/avatarUtils.js +2 -32
  58. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  59. package/lib/typescript/crypto/index.d.ts +2 -5
  60. package/lib/typescript/crypto/index.d.ts.map +1 -1
  61. package/lib/typescript/crypto/types.d.ts +6 -2
  62. package/lib/typescript/crypto/types.d.ts.map +1 -1
  63. package/lib/typescript/index.d.ts +4 -2
  64. package/lib/typescript/index.d.ts.map +1 -1
  65. package/lib/typescript/ui/components/IconButton/utils.d.ts +1 -1
  66. package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts +1 -1
  67. package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts.map +1 -1
  68. package/lib/typescript/ui/components/TextField/helpers.d.ts +6 -6
  69. package/lib/typescript/ui/components/types.d.ts +0 -4
  70. package/lib/typescript/ui/components/types.d.ts.map +1 -1
  71. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  72. package/lib/typescript/ui/context/OxyContextBase.d.ts +2 -39
  73. package/lib/typescript/ui/context/OxyContextBase.d.ts.map +1 -1
  74. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +10 -25
  75. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  76. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  77. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  78. package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  79. package/lib/typescript/ui/hooks/useSessionSocket.d.ts +1 -14
  80. package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
  81. package/lib/typescript/ui/stores/authStore.d.ts +27 -4
  82. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  83. package/lib/typescript/ui/utils/avatarUtils.d.ts +0 -2
  84. package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
  85. package/package.json +2 -2
  86. package/src/crypto/index.ts +3 -11
  87. package/src/crypto/types.ts +6 -2
  88. package/src/index.ts +6 -11
  89. package/src/ui/components/Icon.tsx +1 -1
  90. package/src/ui/components/IconButton/utils.ts +1 -1
  91. package/src/ui/components/TextField/Adornment/utils.ts +2 -2
  92. package/src/ui/components/TextField/helpers.tsx +8 -8
  93. package/src/ui/components/TouchableRipple/utils.ts +2 -2
  94. package/src/ui/components/Typography/AnimatedText.tsx +2 -2
  95. package/src/ui/components/types.tsx +0 -6
  96. package/src/ui/context/OxyContext.tsx +33 -637
  97. package/src/ui/context/OxyContextBase.tsx +5 -23
  98. package/src/ui/context/hooks/useAuthOperations.ts +84 -460
  99. package/src/ui/hooks/mutations/useAccountMutations.ts +12 -110
  100. package/src/ui/hooks/queries/useAccountQueries.ts +3 -27
  101. package/src/ui/hooks/queries/useServicesQueries.ts +3 -27
  102. package/src/ui/hooks/useSessionSocket.ts +2 -106
  103. package/src/ui/screens/OxyAuthScreen.tsx +1 -1
  104. package/src/ui/stores/authStore.ts +57 -18
  105. package/src/ui/utils/avatarUtils.ts +4 -36
  106. package/lib/commonjs/crypto/keyManager.js +0 -511
  107. package/lib/commonjs/crypto/keyManager.js.map +0 -1
  108. package/lib/commonjs/crypto/signatureService.js +0 -269
  109. package/lib/commonjs/crypto/signatureService.js.map +0 -1
  110. package/lib/module/crypto/keyManager.js +0 -508
  111. package/lib/module/crypto/keyManager.js.map +0 -1
  112. package/lib/module/crypto/signatureService.js +0 -266
  113. package/lib/module/crypto/signatureService.js.map +0 -1
  114. package/lib/typescript/crypto/keyManager.d.ts +0 -97
  115. package/lib/typescript/crypto/keyManager.d.ts.map +0 -1
  116. package/lib/typescript/crypto/signatureService.d.ts +0 -77
  117. package/lib/typescript/crypto/signatureService.d.ts.map +0 -1
  118. package/src/crypto/keyManager.ts +0 -545
  119. package/src/crypto/signatureService.ts +0 -301
@@ -1,266 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Signature Service - ECDSA Digital Signatures
5
- *
6
- * Handles signing and verification of messages using ECDSA secp256k1.
7
- * Used for authenticating requests and proving identity ownership.
8
- */
9
-
10
- import { ec as EC } from 'elliptic';
11
- import { KeyManager } from './keyManager';
12
-
13
- // Lazy import for expo-crypto
14
- let ExpoCrypto = null;
15
- const ec = new EC('secp256k1');
16
-
17
- /**
18
- * Check if we're in a React Native environment
19
- */
20
- function isReactNative() {
21
- return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
22
- }
23
-
24
- /**
25
- * Check if we're in a Node.js environment
26
- */
27
- function isNodeJS() {
28
- return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
29
- }
30
-
31
- /**
32
- * Initialize expo-crypto module
33
- */
34
- async function initExpoCrypto() {
35
- if (!ExpoCrypto) {
36
- ExpoCrypto = await import('expo-crypto');
37
- }
38
- return ExpoCrypto;
39
- }
40
-
41
- /**
42
- * Compute SHA-256 hash of a string
43
- */
44
- async function sha256(message) {
45
- // In React Native, always use expo-crypto
46
- if (isReactNative() || !isNodeJS()) {
47
- const Crypto = await initExpoCrypto();
48
- return Crypto.digestStringAsync(Crypto.CryptoDigestAlgorithm.SHA256, message);
49
- }
50
-
51
- // In Node.js, use Node's crypto module
52
- // Use Function constructor to prevent Metro bundler from statically analyzing this require
53
- // This ensures the require is only evaluated in Node.js runtime, not during Metro bundling
54
- try {
55
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
56
- const getCrypto = new Function('return require("crypto")');
57
- const crypto = getCrypto();
58
- return crypto.createHash('sha256').update(message).digest('hex');
59
- } catch (error) {
60
- // Fallback to expo-crypto if Node crypto fails
61
- const Crypto = await initExpoCrypto();
62
- return Crypto.digestStringAsync(Crypto.CryptoDigestAlgorithm.SHA256, message);
63
- }
64
- }
65
- export class SignatureService {
66
- /**
67
- * Generate a random challenge string (for offline use)
68
- * Uses expo-crypto in React Native, crypto.randomBytes in Node.js
69
- */
70
- static async generateChallenge() {
71
- if (isReactNative() || !isNodeJS()) {
72
- // Use expo-crypto for React Native (expo-random is deprecated)
73
- const Crypto = await initExpoCrypto();
74
- const randomBytes = await Crypto.getRandomBytesAsync(32);
75
- return Array.from(randomBytes).map(b => b.toString(16).padStart(2, '0')).join('');
76
- }
77
-
78
- // Node.js fallback
79
- try {
80
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
81
- const getCrypto = new Function('return require("crypto")');
82
- const crypto = getCrypto();
83
- return crypto.randomBytes(32).toString('hex');
84
- } catch (error) {
85
- // Fallback to expo-crypto if Node crypto fails
86
- const Crypto = await initExpoCrypto();
87
- const randomBytes = await Crypto.getRandomBytesAsync(32);
88
- return Array.from(randomBytes).map(b => b.toString(16).padStart(2, '0')).join('');
89
- }
90
- }
91
-
92
- /**
93
- * Hash a message using SHA-256
94
- */
95
- static async hashMessage(message) {
96
- return sha256(message);
97
- }
98
-
99
- /**
100
- * Sign a message using the stored private key
101
- * Returns the signature in DER format (hex encoded)
102
- */
103
- static async sign(message) {
104
- const keyPair = await KeyManager.getKeyPairObject();
105
- if (!keyPair) {
106
- throw new Error('No identity found. Please create or import an identity first.');
107
- }
108
- const messageHash = await sha256(message);
109
- const signature = keyPair.sign(messageHash);
110
- return signature.toDER('hex');
111
- }
112
-
113
- /**
114
- * Sign a message with an explicit private key (without storing)
115
- * Useful for one-time operations or testing
116
- */
117
- static async signWithKey(message, privateKey) {
118
- const keyPair = ec.keyFromPrivate(privateKey);
119
- const messageHash = await sha256(message);
120
- const signature = keyPair.sign(messageHash);
121
- return signature.toDER('hex');
122
- }
123
-
124
- /**
125
- * Verify a signature against a message and public key
126
- */
127
- static async verify(message, signature, publicKey) {
128
- try {
129
- const key = ec.keyFromPublic(publicKey, 'hex');
130
- const messageHash = await sha256(message);
131
- return key.verify(messageHash, signature);
132
- } catch {
133
- return false;
134
- }
135
- }
136
-
137
- /**
138
- * Synchronous verification (for Node.js backend)
139
- * Uses crypto module directly for hashing
140
- * Note: This method should only be used in Node.js environments
141
- */
142
- static verifySync(message, signature, publicKey) {
143
- try {
144
- if (!isNodeJS()) {
145
- // In React Native, use async verify instead
146
- throw new Error('verifySync should only be used in Node.js. Use verify() in React Native.');
147
- }
148
- // Use Function constructor to prevent Metro bundler from statically analyzing this require
149
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
150
- const getCrypto = new Function('return require("crypto")');
151
- const crypto = getCrypto();
152
- const key = ec.keyFromPublic(publicKey, 'hex');
153
- const messageHash = crypto.createHash('sha256').update(message).digest('hex');
154
- return key.verify(messageHash, signature);
155
- } catch {
156
- return false;
157
- }
158
- }
159
-
160
- /**
161
- * Create a signed message object with metadata
162
- */
163
- static async createSignedMessage(message) {
164
- const publicKey = await KeyManager.getPublicKey();
165
- if (!publicKey) {
166
- throw new Error('No identity found. Please create or import an identity first.');
167
- }
168
- const timestamp = Date.now();
169
- const messageWithTimestamp = `${message}:${timestamp}`;
170
- const signature = await SignatureService.sign(messageWithTimestamp);
171
- return {
172
- message,
173
- signature,
174
- publicKey,
175
- timestamp
176
- };
177
- }
178
-
179
- /**
180
- * Verify a signed message object
181
- * Checks both signature validity and timestamp freshness
182
- */
183
- static async verifySignedMessage(signedMessage, maxAgeMs = 5 * 60 * 1000 // 5 minutes default
184
- ) {
185
- const {
186
- message,
187
- signature,
188
- publicKey,
189
- timestamp
190
- } = signedMessage;
191
-
192
- // Check timestamp freshness
193
- const now = Date.now();
194
- if (now - timestamp > maxAgeMs) {
195
- return false;
196
- }
197
-
198
- // Verify signature
199
- const messageWithTimestamp = `${message}:${timestamp}`;
200
- return SignatureService.verify(messageWithTimestamp, signature, publicKey);
201
- }
202
-
203
- /**
204
- * Create a signed authentication challenge response
205
- * Used for challenge-response authentication
206
- */
207
- static async signChallenge(challenge) {
208
- const publicKey = await KeyManager.getPublicKey();
209
- if (!publicKey) {
210
- throw new Error('No identity found. Please create or import an identity first.');
211
- }
212
- const timestamp = Date.now();
213
- const message = `auth:${publicKey}:${challenge}:${timestamp}`;
214
- const signature = await SignatureService.sign(message);
215
- return {
216
- challenge: signature,
217
- publicKey,
218
- timestamp
219
- };
220
- }
221
-
222
- /**
223
- * Verify a challenge response
224
- */
225
- static async verifyChallengeResponse(originalChallenge, response, maxAgeMs = 5 * 60 * 1000) {
226
- const {
227
- challenge: signature,
228
- publicKey,
229
- timestamp
230
- } = response;
231
-
232
- // Check timestamp freshness
233
- const now = Date.now();
234
- if (now - timestamp > maxAgeMs) {
235
- return false;
236
- }
237
- const message = `auth:${publicKey}:${originalChallenge}:${timestamp}`;
238
- return SignatureService.verify(message, signature, publicKey);
239
- }
240
-
241
- /**
242
- * Sign arbitrary data for API requests
243
- * Creates a canonical string representation and signs it
244
- */
245
- static async signRequestData(data) {
246
- const publicKey = await KeyManager.getPublicKey();
247
- if (!publicKey) {
248
- throw new Error('No identity found. Please create or import an identity first.');
249
- }
250
- const timestamp = Date.now();
251
-
252
- // Create canonical string representation
253
- const sortedKeys = Object.keys(data).sort();
254
- const canonicalParts = sortedKeys.map(key => `${key}:${JSON.stringify(data[key])}`);
255
- const canonicalString = canonicalParts.join('|');
256
- const message = `request:${publicKey}:${timestamp}:${canonicalString}`;
257
- const signature = await SignatureService.sign(message);
258
- return {
259
- signature,
260
- publicKey,
261
- timestamp
262
- };
263
- }
264
- }
265
- export default SignatureService;
266
- //# sourceMappingURL=signatureService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["ec","EC","KeyManager","ExpoCrypto","isReactNative","navigator","product","isNodeJS","process","versions","node","initExpoCrypto","sha256","message","Crypto","digestStringAsync","CryptoDigestAlgorithm","SHA256","getCrypto","Function","crypto","createHash","update","digest","error","SignatureService","generateChallenge","randomBytes","getRandomBytesAsync","Array","from","map","b","toString","padStart","join","hashMessage","sign","keyPair","getKeyPairObject","Error","messageHash","signature","toDER","signWithKey","privateKey","keyFromPrivate","verify","publicKey","key","keyFromPublic","verifySync","createSignedMessage","getPublicKey","timestamp","Date","now","messageWithTimestamp","verifySignedMessage","signedMessage","maxAgeMs","signChallenge","challenge","verifyChallengeResponse","originalChallenge","response","signRequestData","data","sortedKeys","Object","keys","sort","canonicalParts","JSON","stringify","canonicalString"],"sourceRoot":"../../../src","sources":["crypto/signatureService.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,EAAE,IAAIC,EAAE,QAAQ,U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M,CAAClC,OAAO,EAAE6B,SAAS,EAAEM,SAAS,CAAC;EAC/D;;EAEA;AACF;AACA;AACA;EACE,aAAakB,eAAeA,CAACC,IAA6B,EAIvD;IACD,MAAMnB,SAAS,GAAG,MAAM9C,UAAU,CAACmD,YAAY,CAAC,CAAC;IACjD,IAAI,CAACL,SAAS,EAAE;MACd,MAAM,IAAIR,KAAK,CAAC,+DAA+D,CAAC;IAClF;IAEA,MAAMc,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;;IAE5B;IACA,MAAMY,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC,CAACI,IAAI,CAAC,CAAC;IAC3C,MAAMC,cAAc,GAAGJ,UAAU,CAACrC,GAAG,CAACkB,GAAG,IAAI,GAAGA,GAAG,IAAIwB,IAAI,CAACC,SAAS,CAACP,IAAI,CAAClB,GAAG,CAAC,CAAC,EAAE,CAAC;IACnF,MAAM0B,eAAe,GAAGH,cAAc,CAACrC,IAAI,CAAC,GAAG,CAAC;IAEhD,MAAMtB,OAAO,GAAG,WAAWmC,SAAS,IAAIM,SAAS,IAAIqB,eAAe,EAAE;IACtE,MAAMjC,SAAS,GAAG,MAAMjB,gBAAgB,CAACY,IAAI,CAACxB,OAAO,CAAC;IAEtD,OAAO;MACL6B,SAAS;MACTM,SAAS;MACTM;IACF,CAAC;EACH;AACF;AAEA,eAAe7B,gBAAgB","ignoreList":[]}
@@ -1,97 +0,0 @@
1
- /**
2
- * Key Manager - ECDSA secp256k1 Key Generation and Storage
3
- *
4
- * Handles secure generation, storage, and retrieval of cryptographic keys.
5
- * Private keys are stored securely using expo-secure-store and never leave the device.
6
- */
7
- import type { ECKeyPair } from 'elliptic';
8
- export interface KeyPair {
9
- publicKey: string;
10
- privateKey: string;
11
- }
12
- export declare class KeyManager {
13
- private static cachedPublicKey;
14
- private static cachedHasIdentity;
15
- /**
16
- * Invalidate cached identity state
17
- * Called internally when identity is created/deleted/imported
18
- */
19
- private static invalidateCache;
20
- /**
21
- * Generate a new ECDSA secp256k1 key pair
22
- * Returns the keys in hexadecimal format
23
- */
24
- static generateKeyPairSync(): KeyPair;
25
- /**
26
- * Generate a new key pair using secure random bytes
27
- */
28
- static generateKeyPair(): Promise<KeyPair>;
29
- /**
30
- * Generate and securely store a new key pair on the device
31
- * Returns only the public key (private key is stored securely)
32
- */
33
- static createIdentity(): Promise<string>;
34
- /**
35
- * Import an existing key pair (e.g., from backup file)
36
- */
37
- static importKeyPair(privateKey: string): Promise<string>;
38
- /**
39
- * Get the stored private key
40
- * WARNING: Only use this for signing operations within the app
41
- */
42
- static getPrivateKey(): Promise<string | null>;
43
- /**
44
- * Get the stored public key (cached for performance)
45
- */
46
- static getPublicKey(): Promise<string | null>;
47
- /**
48
- * Check if an identity (key pair) exists on this device (cached for performance)
49
- */
50
- static hasIdentity(): Promise<boolean>;
51
- /**
52
- * Delete the stored identity (both keys)
53
- * Use with EXTREME caution - this is irreversible without a backup file
54
- * This should ONLY be called when explicitly requested by the user
55
- * @param skipBackup - If true, skip backup before deletion (default: false)
56
- * @param force - If true, skip confirmation checks (default: false)
57
- * @param userConfirmed - If true, user has explicitly confirmed deletion (default: false)
58
- */
59
- static deleteIdentity(skipBackup?: boolean, force?: boolean, userConfirmed?: boolean): Promise<void>;
60
- /**
61
- * Backup identity to SecureStore (separate backup storage)
62
- * This provides a recovery mechanism if primary storage fails
63
- */
64
- static backupIdentity(): Promise<boolean>;
65
- /**
66
- * Verify identity integrity - checks if keys are valid and accessible
67
- */
68
- static verifyIdentityIntegrity(): Promise<boolean>;
69
- /**
70
- * Restore identity from backup if primary storage is corrupted
71
- */
72
- static restoreIdentityFromBackup(): Promise<boolean>;
73
- /**
74
- * Get the elliptic curve key object from the stored private key
75
- * Used internally for signing operations
76
- */
77
- static getKeyPairObject(): Promise<ECKeyPair | null>;
78
- /**
79
- * Derive public key from a private key (without storing)
80
- */
81
- static derivePublicKey(privateKey: string): string;
82
- /**
83
- * Validate that a string is a valid public key
84
- */
85
- static isValidPublicKey(publicKey: string): boolean;
86
- /**
87
- * Validate that a string is a valid private key
88
- */
89
- static isValidPrivateKey(privateKey: string): boolean;
90
- /**
91
- * Get a shortened version of the public key for display
92
- * Format: first 8 chars...last 8 chars
93
- */
94
- static shortenPublicKey(publicKey: string): string;
95
- }
96
- export default KeyManager;
97
- //# sourceMappingURL=keyManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"keyManager.d.ts","sourceRoot":"","sources":["../../../src/crypto/keyManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAyG1C,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,UAAU;IAErB,OAAO,CAAC,MAAM,CAAC,eAAe,CAAuB;IACrD,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAwB;IAExD;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAK9B;;;OAGG;IACH,MAAM,CAAC,mBAAmB,IAAI,OAAO;IAQrC;;OAEG;WACU,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAWhD;;;OAGG;WACU,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAoB9C;;OAEG;WACU,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAqB/D;;;OAGG;WACU,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAiBpD;;OAEG;WACU,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA2BnD;;OAEG;WACU,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IA2B5C;;;;;;;OAOG;WACU,cAAc,CACzB,UAAU,GAAE,OAAe,EAC3B,KAAK,GAAE,OAAe,EACtB,aAAa,GAAE,OAAe,GAC7B,OAAO,CAAC,IAAI,CAAC;IAkDhB;;;OAGG;WACU,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IA6B/C;;OAEG;WACU,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC;IA2CxD;;OAEG;WACU,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC;IAsD1D;;;OAGG;WACU,gBAAgB,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAS1D;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAKlD;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IASnD;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAWrD;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;CAInD;AAED,eAAe,UAAU,CAAC"}
@@ -1,77 +0,0 @@
1
- /**
2
- * Signature Service - ECDSA Digital Signatures
3
- *
4
- * Handles signing and verification of messages using ECDSA secp256k1.
5
- * Used for authenticating requests and proving identity ownership.
6
- */
7
- export interface SignedMessage {
8
- message: string;
9
- signature: string;
10
- publicKey: string;
11
- timestamp: number;
12
- }
13
- export interface AuthChallenge {
14
- challenge: string;
15
- publicKey: string;
16
- timestamp: number;
17
- }
18
- export declare class SignatureService {
19
- /**
20
- * Generate a random challenge string (for offline use)
21
- * Uses expo-crypto in React Native, crypto.randomBytes in Node.js
22
- */
23
- static generateChallenge(): Promise<string>;
24
- /**
25
- * Hash a message using SHA-256
26
- */
27
- static hashMessage(message: string): Promise<string>;
28
- /**
29
- * Sign a message using the stored private key
30
- * Returns the signature in DER format (hex encoded)
31
- */
32
- static sign(message: string): Promise<string>;
33
- /**
34
- * Sign a message with an explicit private key (without storing)
35
- * Useful for one-time operations or testing
36
- */
37
- static signWithKey(message: string, privateKey: string): Promise<string>;
38
- /**
39
- * Verify a signature against a message and public key
40
- */
41
- static verify(message: string, signature: string, publicKey: string): Promise<boolean>;
42
- /**
43
- * Synchronous verification (for Node.js backend)
44
- * Uses crypto module directly for hashing
45
- * Note: This method should only be used in Node.js environments
46
- */
47
- static verifySync(message: string, signature: string, publicKey: string): boolean;
48
- /**
49
- * Create a signed message object with metadata
50
- */
51
- static createSignedMessage(message: string): Promise<SignedMessage>;
52
- /**
53
- * Verify a signed message object
54
- * Checks both signature validity and timestamp freshness
55
- */
56
- static verifySignedMessage(signedMessage: SignedMessage, maxAgeMs?: number): Promise<boolean>;
57
- /**
58
- * Create a signed authentication challenge response
59
- * Used for challenge-response authentication
60
- */
61
- static signChallenge(challenge: string): Promise<AuthChallenge>;
62
- /**
63
- * Verify a challenge response
64
- */
65
- static verifyChallengeResponse(originalChallenge: string, response: AuthChallenge, maxAgeMs?: number): Promise<boolean>;
66
- /**
67
- * Sign arbitrary data for API requests
68
- * Creates a canonical string representation and signs it
69
- */
70
- static signRequestData(data: Record<string, unknown>): Promise<{
71
- signature: string;
72
- publicKey: string;
73
- timestamp: number;
74
- }>;
75
- }
76
- export default SignatureService;
77
- //# sourceMappingURL=signatureService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signatureService.d.ts","sourceRoot":"","sources":["../../../src/crypto/signatureService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiEH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,gBAAgB;IAC3B;;;OAGG;WACU,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IA0BjD;;OAEG;WACU,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAA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