jawere 1.0.13
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/LICENSE +21 -0
- package/README.md +101 -0
- package/bin/jawere.js +5 -0
- package/dist/agent.d.ts +15 -0
- package/dist/agent.js +321 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +53 -0
- package/dist/convex-client.d.ts +41 -0
- package/dist/convex-client.js +99 -0
- package/dist/crypto.d.ts +12 -0
- package/dist/crypto.js +79 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15529 -0
- package/dist/prompt.d.ts +9 -0
- package/dist/prompt.js +325 -0
- package/dist/scanner.d.ts +29 -0
- package/dist/scanner.js +520 -0
- package/dist/spinner.d.ts +23 -0
- package/dist/spinner.js +83 -0
- package/dist/system-prompt.d.ts +1 -0
- package/dist/system-prompt.js +115 -0
- package/dist/tools.d.ts +22 -0
- package/dist/tools.js +551 -0
- package/package.json +43 -0
package/dist/crypto.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Encrypt a string and return base64-encoded ciphertext (iv + tag + data). */
|
|
2
|
+
export declare function encrypt(plaintext: string): string;
|
|
3
|
+
/** Decrypt a base64-encoded ciphertext. Returns null if decryption fails. */
|
|
4
|
+
export declare function decrypt(encoded: string): string | null;
|
|
5
|
+
/** Save encrypted API key to ~/.jawere/key.enc */
|
|
6
|
+
export declare function saveKey(apiKey: string): Promise<void>;
|
|
7
|
+
/** Load and decrypt API key from ~/.jawere/key.enc. Returns null if not found or corrupt. */
|
|
8
|
+
export declare function loadKey(): Promise<string | null>;
|
|
9
|
+
/** Check if a saved key exists */
|
|
10
|
+
export declare function hasKey(): Promise<boolean>;
|
|
11
|
+
/** Delete the saved key */
|
|
12
|
+
export declare function deleteKey(): Promise<void>;
|
package/dist/crypto.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { createCipheriv, createDecipheriv, randomBytes, scryptSync } from 'crypto';
|
|
2
|
+
import { readFile, writeFile, mkdir, access } from 'fs/promises';
|
|
3
|
+
import { constants } from 'fs';
|
|
4
|
+
import { homedir, hostname, userInfo } from 'os';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
const ALGORITHM = 'aes-256-gcm';
|
|
7
|
+
const IV_LENGTH = 16;
|
|
8
|
+
const TAG_LENGTH = 16;
|
|
9
|
+
const SALT = 'jawere-agent-key-vault-2026';
|
|
10
|
+
/** Derive a 256-bit key from machine identity. Not perfect security but better than plaintext. */
|
|
11
|
+
function deriveKey() {
|
|
12
|
+
const machineId = `${hostname()}-${userInfo().username}-jawere`;
|
|
13
|
+
return scryptSync(machineId, SALT, 32);
|
|
14
|
+
}
|
|
15
|
+
/** Encrypt a string and return base64-encoded ciphertext (iv + tag + data). */
|
|
16
|
+
export function encrypt(plaintext) {
|
|
17
|
+
const key = deriveKey();
|
|
18
|
+
const iv = randomBytes(IV_LENGTH);
|
|
19
|
+
const cipher = createCipheriv(ALGORITHM, key, iv);
|
|
20
|
+
const encrypted = Buffer.concat([cipher.update(plaintext, 'utf-8'), cipher.final()]);
|
|
21
|
+
const tag = cipher.getAuthTag();
|
|
22
|
+
// Format: iv (16) + tag (16) + ciphertext
|
|
23
|
+
return Buffer.concat([iv, tag, encrypted]).toString('base64');
|
|
24
|
+
}
|
|
25
|
+
/** Decrypt a base64-encoded ciphertext. Returns null if decryption fails. */
|
|
26
|
+
export function decrypt(encoded) {
|
|
27
|
+
try {
|
|
28
|
+
const key = deriveKey();
|
|
29
|
+
const buf = Buffer.from(encoded, 'base64');
|
|
30
|
+
const iv = buf.subarray(0, IV_LENGTH);
|
|
31
|
+
const tag = buf.subarray(IV_LENGTH, IV_LENGTH + TAG_LENGTH);
|
|
32
|
+
const encrypted = buf.subarray(IV_LENGTH + TAG_LENGTH);
|
|
33
|
+
const decipher = createDecipheriv(ALGORITHM, key, iv);
|
|
34
|
+
decipher.setAuthTag(tag);
|
|
35
|
+
return decipher.update(encrypted) + decipher.final('utf-8');
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const KEY_FILE = join(homedir(), '.jawere', 'key.enc');
|
|
42
|
+
/** Save encrypted API key to ~/.jawere/key.enc */
|
|
43
|
+
export async function saveKey(apiKey) {
|
|
44
|
+
const dir = join(homedir(), '.jawere');
|
|
45
|
+
await mkdir(dir, { recursive: true });
|
|
46
|
+
const encrypted = encrypt(apiKey.trim());
|
|
47
|
+
await writeFile(KEY_FILE, encrypted, 'utf-8');
|
|
48
|
+
}
|
|
49
|
+
/** Load and decrypt API key from ~/.jawere/key.enc. Returns null if not found or corrupt. */
|
|
50
|
+
export async function loadKey() {
|
|
51
|
+
try {
|
|
52
|
+
await access(KEY_FILE, constants.R_OK);
|
|
53
|
+
const encrypted = await readFile(KEY_FILE, 'utf-8');
|
|
54
|
+
return decrypt(encrypted.trim());
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Check if a saved key exists */
|
|
61
|
+
export async function hasKey() {
|
|
62
|
+
try {
|
|
63
|
+
await access(KEY_FILE, constants.R_OK);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** Delete the saved key */
|
|
71
|
+
export async function deleteKey() {
|
|
72
|
+
try {
|
|
73
|
+
const { unlink } = await import('fs/promises');
|
|
74
|
+
await unlink(KEY_FILE);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// Ignore if not found
|
|
78
|
+
}
|
|
79
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|