@kryklin/darkstar-crypt-node 1.0.0 → 1.0.2

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 ADDED
@@ -0,0 +1,70 @@
1
+ # @kryklin/darkstar-crypt-node
2
+
3
+ > **Darkstar V2 Encryption Protocol - Node.js Implementation**
4
+
5
+ A high-performance, standalone implementation of the Darkstar V2 security protocol for Node.js. Designed for web backends and desktop applications requiring defense-in-depth for sensitive mnemonic assets.
6
+
7
+ ## 🛡️ Security Features
8
+
9
+ - **Dynamic Obfuscation Pool**: 12-stage transformation pipeline seeded by password and data.
10
+ - **AES-256-CBC**: Encapsulated with 600,000 PBKDF2 iterations.
11
+ - **Stateless Reversal**: Requires a "Reverse Key" produced during encryption for decryption.
12
+ - **Native Performance**: Leverages the Node.js `crypto` module.
13
+
14
+ ## 🚀 Installation
15
+
16
+ ```bash
17
+ npm install @kryklin/darkstar-crypt-node
18
+ ```
19
+
20
+ ## 💻 Usage
21
+
22
+ ### Library Usage
23
+
24
+ ```javascript
25
+ import { DarkstarCrypt } from '@kryklin/darkstar-crypt-node';
26
+
27
+ const crypt = new DarkstarCrypt();
28
+
29
+ // Encrypt
30
+ const { encryptedData, reverseKey } = await crypt.encrypt("my secret phrase", "password123");
31
+ console.log('Encrypted:', encryptedData);
32
+ console.log('Reverse Key:', reverseKey);
33
+
34
+ // Decrypt
35
+ const decrypted = await crypt.decrypt(encryptedData, "password123", reverseKey);
36
+ console.log('Decrypted:', decrypted);
37
+ ```
38
+
39
+ ### CLI Usage
40
+
41
+ The package includes a CLI tool that can be run via `npx`.
42
+
43
+ ```bash
44
+ # Encrypt
45
+ npx darkstar-crypt encrypt "secret message" "password"
46
+
47
+ # Decrypt
48
+ npx darkstar-crypt decrypt '{"v":2,"data":"..."}' "password" "REVERSE_KEY_B64"
49
+
50
+ # Run internal tests
51
+ npx darkstar-crypt test
52
+ ```
53
+
54
+ ## 📜 Data Format
55
+
56
+ Standard output is a JSON-encapsulated object:
57
+
58
+ ```json
59
+ {
60
+ "v": 2,
61
+ "data": "SALT(32)IV(32)CIPHERTEXT(B64)"
62
+ }
63
+ ```
64
+
65
+ > [!IMPORTANT]
66
+ > The **Reverse Key** is essential for decryption. It must be stored securely alongside the encrypted data.
67
+
68
+ ## ⚖️ License
69
+
70
+ MIT © Victor Kane
package/darkstar_crypt.js CHANGED
@@ -233,7 +233,7 @@ export class DarkstarCrypt {
233
233
  const saltHex = this.buf2hex(salt);
234
234
  const ivHex = this.buf2hex(iv);
235
235
  const ciphertextBase64 = this.buf2base64(encrypted);
236
-
236
+
237
237
  return saltHex + ivHex + ciphertextBase64;
238
238
  }
239
239
 
@@ -557,3 +557,53 @@ export class DarkstarCrypt {
557
557
  };
558
558
  }
559
559
  }
560
+
561
+ // --- CLI Support ---
562
+
563
+ import { fileURLToPath } from 'node:url';
564
+ import { resolve } from 'node:path';
565
+
566
+ const __filename = fileURLToPath(import.meta.url);
567
+ const isMain = process.argv[1] && resolve(process.argv[1]) === resolve(__filename);
568
+
569
+ if (isMain) {
570
+ const args = process.argv.slice(2);
571
+ const command = args[0];
572
+ const crypt = new DarkstarCrypt();
573
+
574
+ if (command === 'encrypt') {
575
+ const mnemonic = args[1];
576
+ const password = args[2];
577
+ crypt.encrypt(mnemonic, password).then(res => {
578
+ console.log(JSON.stringify(res));
579
+ }).catch(err => {
580
+ console.error(err);
581
+ process.exit(1);
582
+ });
583
+ } else if (command === 'decrypt') {
584
+ const data = args[1];
585
+ const rk = args[2];
586
+ const password = args[3];
587
+ crypt.decrypt(data, rk, password).then(res => {
588
+ console.log(res);
589
+ }).catch(err => {
590
+ console.error(err);
591
+ process.exit(1);
592
+ });
593
+ } else if (command === 'test') {
594
+ const mnemonic = "cat dog fish bird";
595
+ const password = "MySecre!Password123";
596
+ crypt.encrypt(mnemonic, password).then(res => {
597
+ return crypt.decrypt(res.encryptedData, res.reverseKey, password);
598
+ }).then(decrypted => {
599
+ if (decrypted === "cat dog fish bird") {
600
+ console.log("Test Passed!");
601
+ } else {
602
+ console.error("Test Failed!");
603
+ process.exit(1);
604
+ }
605
+ });
606
+ } else {
607
+ console.log("Usage: node darkstar_crypt.js <encrypt|decrypt|test> ...");
608
+ }
609
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kryklin/darkstar-crypt-node",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Standalone Node.js implementation of Darkstar Encryption",
5
5
  "main": "darkstar_crypt.js",
6
6
  "type": "module",