bsv-bap 0.2.0 → 0.3.0

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.
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Touch ID vault integration for BAP identity protection.
3
+ *
4
+ * Architecture:
5
+ * - P-256 key generated INSIDE the macOS Secure Enclave (never leaves the chip)
6
+ * - Encryption uses ECIES (ECDH + AES-256-GCM) via the SE public key
7
+ * - Decryption requires Touch ID — SE performs ECDH internally
8
+ * - Encrypted data stored at ~/.secure-enclave-vault/bap-master.vault.json
9
+ * - Config stores sentinel "se:bap-master" in rootPkEncrypted
10
+ * - Plaintext WIF never touches disk when Touch ID is active
11
+ *
12
+ * Powered by @1sat/vault (Secure Enclave hardware vault).
13
+ */
14
+ /**
15
+ * Encrypt a WIF private key with the Secure Enclave.
16
+ *
17
+ * Touch ID is NOT required for encryption — only for decryption.
18
+ * Returns the sentinel string "se:bap-master" to store in config.
19
+ */
20
+ export declare function protectRootKey(wif: string): Promise<string>;
21
+ /**
22
+ * Decrypt the protected root key using Touch ID + Secure Enclave.
23
+ *
24
+ * The ECDH key agreement happens INSIDE the Secure Enclave hardware.
25
+ * The P-256 private key never leaves the chip.
26
+ */
27
+ export declare function unlockRootKey(sentinel: string): Promise<string>;
28
+ /**
29
+ * Remove the Secure Enclave key and vault file.
30
+ * After this, the encrypted rootPk becomes permanently undecryptable.
31
+ * The caller must replace rootPkEncrypted with rootPk before calling this.
32
+ */
33
+ export declare function removeProtection(): Promise<void>;
34
+ /**
35
+ * Check Touch ID availability and whether the identity is currently protected.
36
+ */
37
+ export declare function getTouchIDStatus(hasEncryptedKey: boolean): Promise<{
38
+ available: boolean;
39
+ biometryType: string;
40
+ protected: boolean;
41
+ }>;
42
+ /**
43
+ * Synchronous check for Secure Enclave support (macOS arm64).
44
+ */
45
+ export declare function isTouchIDSupported(): boolean;
package/dist/utils.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type PrivateKey } from "@bsv/sdk";
1
2
  import type { PathPrefix } from "./interface.js";
2
3
  /**
3
4
  * Derive a BAP ID from a Bitcoin address (rootAddress).
@@ -22,6 +23,17 @@ export declare function bapIdFromAddress(address: string): string;
22
23
  * so this correctly bridges BRC-31 auth to BAP identity lookups.
23
24
  */
24
25
  export declare function bapIdFromPubkey(pubkeyHex: string): string;
26
+ /**
27
+ * Derive the BAP identity-0 address from a BRC-100 wallet root private key.
28
+ *
29
+ * Matches @1sat/actions: derives the public key at protocolID `[1, "sigma"]`,
30
+ * keyID `"identity-0"`, counterparty `"self"` (forSelf=true), then converts to
31
+ * a P2PKH address. The bapId is computed from this address.
32
+ *
33
+ * BRC-100 wallets don't allow signing with the wallet root itself, so the
34
+ * "root" used for bapId derivation is this first standard-derived signing key.
35
+ */
36
+ export declare function deriveIdentity0Address(walletRoot: PrivateKey): string;
25
37
  export declare const Utils: {
26
38
  /**
27
39
  * Helper function to generate cryptographically secure random bytes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bsv-bap",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "BAP npm module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,6 +27,7 @@
27
27
  "dist/*.js.map",
28
28
  "dist/*.d.ts",
29
29
  "src/cli.ts",
30
+ "src/touchid.ts",
30
31
  "README.md",
31
32
  "LICENSE"
32
33
  ],
@@ -49,10 +50,14 @@
49
50
  "typescript": "^5.9.3"
50
51
  },
51
52
  "dependencies": {
53
+ "@1sat/vault": "0.0.3",
52
54
  "commander": "^14.0.3",
53
55
  "schema-dts": "^1.1.5"
54
56
  },
55
57
  "peerDependencies": {
56
58
  "@bsv/sdk": "^2.0.1"
57
- }
59
+ },
60
+ "trustedDependencies": [
61
+ "@1sat/vault"
62
+ ]
58
63
  }