OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-wallet-lib commits / 4eb36c0

Initial commit: shared identity and secure-storage modules
4eb36c062547f6852a47b08f2399f2c3e081311d
by plankatron <fleeky@gmail.com> · 2026-01-30T21:57:56.000Z

Changed files (5) +118 -0

.gitignore +2 -0
……@@ -0,0 +1,2 @@
1node_modules/
2package-lock.json
identity.js +47 -0
……@@ -0,0 +1,47 @@
1// identity.js - Identity Management Wrapper
2//
3// Wraps keet-identity-key for consistent API
4
5import KeetIdentityKey from 'keet-identity-key'
6
7/**
8 * Identity wrapper
9 * Provides consistent API for identity management and exposes mnemonic for WDK
10 */
11class 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
47export default IdentityKey
index.js +6 -0
……@@ -0,0 +1,6 @@
1// hyper-wallet-lib - Shared library for hyper-wallet
2//
3// Provides identity management and secure storage
4
5export { default as IdentityKey } from './identity.js'
6export * from './secure-storage.js'
package.json +20 -0
……@@ -0,0 +1,20 @@
1{
2 "name": "hyper-wallet-lib",
3 "version": "1.0.0",
4 "description": "Shared library for hyper-wallet - identity and secure storage",
5 "type": "module",
6 "main": "index.js",
7 "exports": {
8 ".": "./index.js",
9 "./identity": "./identity.js",
10 "./secure-storage": "./secure-storage.js"
11 },
12 "dependencies": {
13 "keet-identity-key": "^3.1.0",
14 "keytar": "^7.9.0"
15 },
16 "peerDependencies": {
17 "bare-fs": "*",
18 "bare-path": "*"
19 }
20}
secure-storage.js +43 -0
……@@ -0,0 +1,43 @@
1// 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
8import keytar from 'keytar'
9
10const SERVICE_NAME = 'hyper-wallet'
11const ACCOUNT_NAME = 'mnemonic'
12
13/**
14 * Store mnemonic securely in OS keychain
15 * @param {String} mnemonic - BIP39 mnemonic phrase
16 */
17export 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 */
25export async function loadMnemonic() {
26 return await keytar.getPassword(SERVICE_NAME, ACCOUNT_NAME)
27}
28
29/**
30 * Delete mnemonic from OS keychain
31 */
32export 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 */
40export async function isInitialized() {
41 const mnemonic = await loadMnemonic()
42 return mnemonic !== null
43}