| … | … | @@ -0,0 +1,4 @@ |
| 1 | [submodule "lib/hyper-wallet-lib"] | |
| 2 | path = lib/hyper-wallet-lib | |
| 3 | url = https://7rnx.net/git/fleeky/hyper-wallet-lib.git | |
| 4 | # @pear: pear://3cf3266a57b3ef069b724a4330200d72b0ad81daea7311b7d2a2369b0469f199/hyper-wallet-lib |
| … | … | @@ -0,0 +1 @@ |
| 1 | Subproject commit 4eb36c062547f6852a47b08f2399f2c3e081311d |
| … | … | @@ -1,47 +1,2 @@ |
| 1 | // lib/identity.js - Identity Management Wrapper | |
| 2 | // | |
| 3 | // Wraps keet-identity-key for consistent API | |
| 4 | ||
| 5 | import KeetIdentityKey from 'keet-identity-key' | |
| 6 | ||
| 7 | /** | |
| 8 | * Identity wrapper | |
| 9 | * Provides consistent API for identity management and exposes mnemonic for WDK | |
| 10 | */ | |
| 11 | class IdentityKey { | |
| 12 | /** | |
| 13 | * Create identity from mnemonic | |
| 14 | * @param {Object} options - { mnemonic } | |
| 15 | * @returns {IdentityKey} - Identity instance with mnemonic exposed | |
| 16 | */ | |
| 17 | static async from({ mnemonic }) { | |
| 18 | const identity = await KeetIdentityKey.from({ mnemonic }) | |
| 19 | ||
| 20 | // Expose mnemonic for WDK (WDK needs the mnemonic to derive keys) | |
| 21 | identity.mnemonic = mnemonic | |
| 22 | ||
| 23 | return identity | |
| 24 | } | |
| 25 | ||
| 26 | /** | |
| 27 | * Verify device attestation proof | |
| 28 | * @param {Buffer} proof - Attestation proof | |
| 29 | * @returns {Boolean} - True if valid | |
| 30 | */ | |
| 31 | static verify(proof) { | |
| 32 | return KeetIdentityKey.verify(proof) | |
| 33 | } | |
| 34 | ||
| 35 | /** | |
| 36 | * Attest new device | |
| 37 | * @param {Buffer} devicePublicKey - Device public key | |
| 38 | * @param {Object} signingDevice - Device with signing authority | |
| 39 | * @param {Buffer} previousProof - Previous attestation proof | |
| 40 | * @returns {Buffer} - New attestation proof | |
| 41 | */ | |
| 42 | static attest(devicePublicKey, signingDevice, previousProof) { | |
| 43 | return KeetIdentityKey.attest(devicePublicKey, signingDevice, previousProof) | |
| 44 | } | |
| 45 | } | |
| 46 | ||
| 47 | export default IdentityKey | |
| 1 | // Re-export from hyper-wallet-lib | |
| 2 | export { default } from 'hyper-wallet-lib/identity' |
| … | … | @@ -1,43 +1,2 @@ |
| 1 | // lib/secure-storage.js - Secure Mnemonic Storage | |
| 2 | // | |
| 3 | // Uses OS keychain for secure mnemonic storage: | |
| 4 | // - macOS: Keychain Access | |
| 5 | // - Linux: libsecret (GNOME Keyring, KDE Wallet) | |
| 6 | // - Windows: Credential Vault | |
| 7 | ||
| 8 | import keytar from 'keytar' | |
| 9 | ||
| 10 | const SERVICE_NAME = 'hyper-wallet' | |
| 11 | const ACCOUNT_NAME = 'mnemonic' | |
| 12 | ||
| 13 | /** | |
| 14 | * Store mnemonic securely in OS keychain | |
| 15 | * @param {String} mnemonic - BIP39 mnemonic phrase | |
| 16 | */ | |
| 17 | export async function storeMnemonic(mnemonic) { | |
| 18 | await keytar.setPassword(SERVICE_NAME, ACCOUNT_NAME, mnemonic) | |
| 19 | } | |
| 20 | ||
| 21 | /** | |
| 22 | * Retrieve mnemonic from OS keychain | |
| 23 | * @returns {String|null} - Mnemonic or null if not found | |
| 24 | */ | |
| 25 | export async function loadMnemonic() { | |
| 26 | return await keytar.getPassword(SERVICE_NAME, ACCOUNT_NAME) | |
| 27 | } | |
| 28 | ||
| 29 | /** | |
| 30 | * Delete mnemonic from OS keychain | |
| 31 | */ | |
| 32 | export async function deleteMnemonic() { | |
| 33 | await keytar.deletePassword(SERVICE_NAME, ACCOUNT_NAME) | |
| 34 | } | |
| 35 | ||
| 36 | /** | |
| 37 | * Check if wallet is initialized (mnemonic exists in keychain) | |
| 38 | * @returns {Boolean} | |
| 39 | */ | |
| 40 | export async function isInitialized() { | |
| 41 | const mnemonic = await loadMnemonic() | |
| 42 | return mnemonic !== null | |
| 43 | } | |
| 1 | // Re-export from hyper-wallet-lib | |
| 2 | export * from 'hyper-wallet-lib/secure-storage' |
| … | … | @@ -30,6 +30,7 @@ |
| 30 | 30 | "postinstall": "bash scripts/setup-pear-compat.sh" |
| 31 | 31 | }, |
| 32 | 32 | "dependencies": { |
| 33 | "hyper-wallet-lib": "file:lib/hyper-wallet-lib", | |
| 33 | 34 | "@noble/hashes": "^1.8.0", |
| 34 | 35 | "@tetherto/wdk": "^1.0.0-beta.5", |
| 35 | 36 | "@tetherto/wdk-wallet-btc": "^1.0.0-beta.4", |