@cryptforge/auth 0.1.0 → 0.2.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.
package/README.md CHANGED
@@ -806,63 +806,6 @@ const signature = await auth.signMessage({
806
806
  // Server can verify ownership regardless of chain
807
807
  ```
808
808
 
809
- ## BIP44 Document ID
810
-
811
- Derives a deterministic document ID using BIP44-style hierarchical derivation.
812
-
813
- This creates chain-independent, deterministic document IDs that can be used with Automerge or any other document system. The ID is derived from your mnemonic using BIP44 HD key derivation, ensuring the same inputs always produce the same ID.
814
-
815
- **How it works:** `deriveBIP44DocumentID()` generates a 32-byte seed from your mnemonic. When passed to `store.create()` as the second parameter, Automerge uses this seed with UUID v5 to create a deterministic document URL. Same seed = same document every time!
816
-
817
- ### Path Structure
818
-
819
- `m/44'/[appId]'/[account]'/[purpose]/[index]`
820
-
821
- ### Purpose Parameter Guidance
822
-
823
- The `purpose` parameter (4th level) can represent document types or categories. This is flexible and application-specific. Examples:
824
-
825
- - 0: Profile/Settings
826
- - 1: Notes
827
- - 2: Tasks
828
- - 3: Documents
829
- - 100+: Custom types
830
-
831
- ### Parameters
832
-
833
- - `options.appId` - Application identifier (1000000+ recommended, will be hardened)
834
- - `options.account` - Account/workspace number (default: 0, hardened)
835
- - `options.purpose` - Document type/category (default: 0, non-hardened)
836
- - `options.index` - Document instance number (default: 0, non-hardened)
837
-
838
- ### Returns
839
-
840
- Hex-encoded document ID (32 bytes / 64 hex chars)
841
-
842
- ### Usage
843
-
844
- ```typescript
845
- // Derive document ID
846
- const docId = await auth.deriveBIP44DocumentID({
847
- appId: 1000000,
848
- purpose: 0, // Settings type
849
- index: 0, // First settings doc
850
- });
851
-
852
- // Create document with deterministic ID
853
- await store.create({ type: "settings", theme: "dark" }, docId);
854
-
855
- // Later, re-derive the same ID
856
- const sameId = await auth.deriveBIP44DocumentID({
857
- appId: 1000000,
858
- purpose: 0,
859
- index: 0,
860
- });
861
- const settings = await store.get(sameId); // Gets existing doc!
862
- ```
863
-
864
- See `BIP44_DOCUMENT_ID.md` for detailed documentation and examples.
865
-
866
809
  ## Browser Compatibility
867
810
 
868
811
  This package is **100% browser-compatible** with zero configuration:
@@ -892,6 +835,10 @@ This package is **100% browser-compatible** with zero configuration:
892
835
 
893
836
  All dependencies are browser-safe, audited, and actively maintained.
894
837
 
838
+ ## Additional Documentation
839
+
840
+ - **[DATA_ENCRYPTION.md](./DATA_ENCRYPTION.md)** - Detailed documentation on HKDF data encryption and master public key features for chain-independent encryption and identity verification
841
+
895
842
  ## Examples
896
843
 
897
844
  See the complete working example in `examples/vue-electron-example/src/AuthTest.vue`.
package/dist/index.d.mts CHANGED
@@ -93,20 +93,6 @@ declare class AuthClient implements AuthAdapter {
93
93
  address: string;
94
94
  path: string;
95
95
  }>;
96
- /**
97
- * Derives a deterministic document ID using BIP44-style hierarchical derivation.
98
- * Returns a hex-encoded ID (32 bytes / 64 hex characters).
99
- * Path: m/44'/[appId]'/[account]'/[purpose]/[index]
100
- * @param options - BIP44 derivation parameters (appId required, others default to 0)
101
- * @returns Promise resolving to hex-encoded document ID (64 characters)
102
- * @throws {Error} If wallet is locked or parameters are out of range
103
- */
104
- deriveBIP44DocumentID: (options: {
105
- appId: number;
106
- account?: number;
107
- purpose?: number;
108
- index?: number;
109
- }) => Promise<string>;
110
96
  /**
111
97
  * Derives a data encryption key using HKDF for encrypting/decrypting data.
112
98
  * This key is deterministic (derived from mnemonic) and chain-independent.
package/dist/index.d.ts CHANGED
@@ -93,20 +93,6 @@ declare class AuthClient implements AuthAdapter {
93
93
  address: string;
94
94
  path: string;
95
95
  }>;
96
- /**
97
- * Derives a deterministic document ID using BIP44-style hierarchical derivation.
98
- * Returns a hex-encoded ID (32 bytes / 64 hex characters).
99
- * Path: m/44'/[appId]'/[account]'/[purpose]/[index]
100
- * @param options - BIP44 derivation parameters (appId required, others default to 0)
101
- * @returns Promise resolving to hex-encoded document ID (64 characters)
102
- * @throws {Error} If wallet is locked or parameters are out of range
103
- */
104
- deriveBIP44DocumentID: (options: {
105
- appId: number;
106
- account?: number;
107
- purpose?: number;
108
- index?: number;
109
- }) => Promise<string>;
110
96
  /**
111
97
  * Derives a data encryption key using HKDF for encrypting/decrypting data.
112
98
  * This key is deterministic (derived from mnemonic) and chain-independent.
package/dist/index.js CHANGED
@@ -351,64 +351,6 @@ var AuthClient = class {
351
351
  path: keyData.path
352
352
  };
353
353
  };
354
- /**
355
- * Derives a deterministic document ID using BIP44-style hierarchical derivation.
356
- * Returns a hex-encoded ID (32 bytes / 64 hex characters).
357
- * Path: m/44'/[appId]'/[account]'/[purpose]/[index]
358
- * @param options - BIP44 derivation parameters (appId required, others default to 0)
359
- * @returns Promise resolving to hex-encoded document ID (64 characters)
360
- * @throws {Error} If wallet is locked or parameters are out of range
361
- */
362
- deriveBIP44DocumentID = async (options) => {
363
- if (this.state.isLocked || !this.decryptedMnemonic) {
364
- throw new Error(
365
- "Wallet is locked. Call unlock() first to derive document IDs."
366
- );
367
- }
368
- const { appId, account = 0, purpose = 0, index = 0 } = options;
369
- if (appId === void 0 || appId === null) {
370
- throw new Error(
371
- "appId is required but was undefined. Please provide a valid appId number."
372
- );
373
- }
374
- if (typeof appId !== "number" || isNaN(appId)) {
375
- throw new Error(
376
- `appId must be a valid number, received: ${typeof appId}`
377
- );
378
- }
379
- const MAX_HARDENED = 2147483647;
380
- if (appId < 0 || appId > MAX_HARDENED) {
381
- throw new Error(
382
- `Invalid appId: ${appId}. Must be between 0 and ${MAX_HARDENED}`
383
- );
384
- }
385
- if (account < 0 || account > MAX_HARDENED) {
386
- throw new Error(
387
- `Invalid account: ${account}. Must be between 0 and ${MAX_HARDENED}`
388
- );
389
- }
390
- if (purpose < 0 || purpose > MAX_HARDENED) {
391
- throw new Error(
392
- `Invalid purpose: ${purpose}. Must be between 0 and ${MAX_HARDENED}`
393
- );
394
- }
395
- if (index < 0 || index > MAX_HARDENED) {
396
- throw new Error(
397
- `Invalid index: ${index}. Must be between 0 and ${MAX_HARDENED}`
398
- );
399
- }
400
- const path = `m/44'/${appId}'/${account}'/${purpose}/${index}`;
401
- const seed = (0, import_bip39.mnemonicToSeedSync)(this.decryptedMnemonic);
402
- const masterKey = import_bip32.HDKey.fromMasterSeed(seed);
403
- const derivedKey = masterKey.derive(path);
404
- if (!derivedKey.publicKey) {
405
- throw new Error(`Failed to derive key at path: ${path}`);
406
- }
407
- const publicKeyBuffer = new Uint8Array(derivedKey.publicKey);
408
- const hashBuffer = await crypto.subtle.digest("SHA-256", publicKeyBuffer);
409
- const hash = new Uint8Array(hashBuffer);
410
- return bufferToHex(hash);
411
- };
412
354
  /**
413
355
  * Derives a data encryption key using HKDF for encrypting/decrypting data.
414
356
  * This key is deterministic (derived from mnemonic) and chain-independent.
package/dist/index.mjs CHANGED
@@ -328,64 +328,6 @@ var AuthClient = class {
328
328
  path: keyData.path
329
329
  };
330
330
  };
331
- /**
332
- * Derives a deterministic document ID using BIP44-style hierarchical derivation.
333
- * Returns a hex-encoded ID (32 bytes / 64 hex characters).
334
- * Path: m/44'/[appId]'/[account]'/[purpose]/[index]
335
- * @param options - BIP44 derivation parameters (appId required, others default to 0)
336
- * @returns Promise resolving to hex-encoded document ID (64 characters)
337
- * @throws {Error} If wallet is locked or parameters are out of range
338
- */
339
- deriveBIP44DocumentID = async (options) => {
340
- if (this.state.isLocked || !this.decryptedMnemonic) {
341
- throw new Error(
342
- "Wallet is locked. Call unlock() first to derive document IDs."
343
- );
344
- }
345
- const { appId, account = 0, purpose = 0, index = 0 } = options;
346
- if (appId === void 0 || appId === null) {
347
- throw new Error(
348
- "appId is required but was undefined. Please provide a valid appId number."
349
- );
350
- }
351
- if (typeof appId !== "number" || isNaN(appId)) {
352
- throw new Error(
353
- `appId must be a valid number, received: ${typeof appId}`
354
- );
355
- }
356
- const MAX_HARDENED = 2147483647;
357
- if (appId < 0 || appId > MAX_HARDENED) {
358
- throw new Error(
359
- `Invalid appId: ${appId}. Must be between 0 and ${MAX_HARDENED}`
360
- );
361
- }
362
- if (account < 0 || account > MAX_HARDENED) {
363
- throw new Error(
364
- `Invalid account: ${account}. Must be between 0 and ${MAX_HARDENED}`
365
- );
366
- }
367
- if (purpose < 0 || purpose > MAX_HARDENED) {
368
- throw new Error(
369
- `Invalid purpose: ${purpose}. Must be between 0 and ${MAX_HARDENED}`
370
- );
371
- }
372
- if (index < 0 || index > MAX_HARDENED) {
373
- throw new Error(
374
- `Invalid index: ${index}. Must be between 0 and ${MAX_HARDENED}`
375
- );
376
- }
377
- const path = `m/44'/${appId}'/${account}'/${purpose}/${index}`;
378
- const seed = mnemonicToSeedSync(this.decryptedMnemonic);
379
- const masterKey = HDKey.fromMasterSeed(seed);
380
- const derivedKey = masterKey.derive(path);
381
- if (!derivedKey.publicKey) {
382
- throw new Error(`Failed to derive key at path: ${path}`);
383
- }
384
- const publicKeyBuffer = new Uint8Array(derivedKey.publicKey);
385
- const hashBuffer = await crypto.subtle.digest("SHA-256", publicKeyBuffer);
386
- const hash = new Uint8Array(hashBuffer);
387
- return bufferToHex(hash);
388
- };
389
331
  /**
390
332
  * Derives a data encryption key using HKDF for encrypting/decrypting data.
391
333
  * This key is deterministic (derived from mnemonic) and chain-independent.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptforge/auth",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Browser-compatible authentication and key management for cryptocurrency wallets",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -34,7 +34,7 @@
34
34
  "README.md"
35
35
  ],
36
36
  "dependencies": {
37
- "@cryptforge/core": "^0.1.0",
37
+ "@cryptforge/core": "workspace:*",
38
38
  "@scure/bip32": "^2.0.1",
39
39
  "@scure/bip39": "^2.0.1"
40
40
  },