@commit451/salamander 1.1.1 → 1.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 +42 -42
- package/bin/salamander.js +1 -1
- package/dist/commands/create-runner.d.ts.map +1 -1
- package/dist/commands/create-runner.js +18 -3
- package/dist/commands/create-runner.js.map +1 -1
- package/dist/commands/delete-runner.d.ts.map +1 -1
- package/dist/commands/delete-runner.js +6 -0
- package/dist/commands/delete-runner.js.map +1 -1
- package/dist/commands/runner-selection.d.ts.map +1 -1
- package/dist/commands/runner-selection.js +2 -2
- package/dist/commands/runner-selection.js.map +1 -1
- package/dist/services/api.d.ts +2 -0
- package/dist/services/api.d.ts.map +1 -1
- package/dist/services/api.js.map +1 -1
- package/dist/services/auth.js +36 -36
- package/dist/services/command-listener.d.ts +4 -1
- package/dist/services/command-listener.d.ts.map +1 -1
- package/dist/services/command-listener.js +78 -41
- package/dist/services/command-listener.js.map +1 -1
- package/dist/services/executor.d.ts +2 -0
- package/dist/services/executor.d.ts.map +1 -1
- package/dist/services/executor.js +45 -10
- package/dist/services/executor.js.map +1 -1
- package/dist/services/runner.d.ts +1 -1
- package/dist/services/runner.d.ts.map +1 -1
- package/dist/services/runner.js +17 -3
- package/dist/services/runner.js.map +1 -1
- package/dist/types/runner.d.ts +1 -0
- package/dist/types/runner.d.ts.map +1 -1
- package/package.json +52 -52
- package/dist/services/crypto.d.ts +0 -52
- package/dist/services/crypto.d.ts.map +0 -1
- package/dist/services/crypto.js +0 -104
- package/dist/services/crypto.js.map +0 -1
- package/dist/services/key-manager.d.ts +0 -45
- package/dist/services/key-manager.d.ts.map +0 -1
- package/dist/services/key-manager.js +0 -123
- package/dist/services/key-manager.js.map +0 -1
- package/dist/services/multi-device-key-manager.d.ts +0 -56
- package/dist/services/multi-device-key-manager.d.ts.map +0 -1
- package/dist/services/multi-device-key-manager.js +0 -159
- package/dist/services/multi-device-key-manager.js.map +0 -1
|
@@ -9,14 +9,23 @@ export class CommandExecutor {
|
|
|
9
9
|
console.log(chalk.gray(`Type: ${runner.runnerType}\n`));
|
|
10
10
|
const startTime = Date.now();
|
|
11
11
|
try {
|
|
12
|
-
const
|
|
12
|
+
const rawOutput = this.executeRunnerCommand(runner, command);
|
|
13
13
|
const executionTime = Date.now() - startTime;
|
|
14
|
+
// Parse Codex output if needed
|
|
15
|
+
let output = rawOutput;
|
|
16
|
+
let threadId;
|
|
17
|
+
if (runner.runnerType === RunnerType.CODEX) {
|
|
18
|
+
const parsed = this.parseCodexOutput(rawOutput);
|
|
19
|
+
output = parsed.output;
|
|
20
|
+
threadId = parsed.threadId;
|
|
21
|
+
}
|
|
14
22
|
console.log(chalk.green('✅ Command completed successfully'));
|
|
15
23
|
console.log(chalk.grey(output));
|
|
16
24
|
return {
|
|
17
25
|
output: output || 'Command executed successfully (no output)',
|
|
18
26
|
success: true,
|
|
19
|
-
executionTime
|
|
27
|
+
executionTime,
|
|
28
|
+
threadId
|
|
20
29
|
};
|
|
21
30
|
}
|
|
22
31
|
catch (error) {
|
|
@@ -60,15 +69,41 @@ export class CommandExecutor {
|
|
|
60
69
|
case RunnerType.GEMINI:
|
|
61
70
|
return `gemini -p "${escapedInput}" --yolo`;
|
|
62
71
|
case RunnerType.CODEX:
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
// Build base command
|
|
73
|
+
let codexCmd = `codex exec "${escapedInput}" --experimental-json --full-auto --skip-git-repo-check`;
|
|
74
|
+
// Add resume with threadId if we have one
|
|
75
|
+
if (runner.threadId) {
|
|
76
|
+
codexCmd += ` resume "${runner.threadId}"`;
|
|
77
|
+
}
|
|
78
|
+
return codexCmd;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
static parseCodexOutput(rawOutput) {
|
|
82
|
+
const lines = rawOutput.trim().split('\n');
|
|
83
|
+
const agentMessages = [];
|
|
84
|
+
let threadId;
|
|
85
|
+
for (const line of lines) {
|
|
86
|
+
try {
|
|
87
|
+
const event = JSON.parse(line);
|
|
88
|
+
// Extract thread ID from thread.started event
|
|
89
|
+
if (event.type === 'thread.started' && event.thread_id) {
|
|
90
|
+
threadId = event.thread_id;
|
|
91
|
+
}
|
|
92
|
+
// Extract agent messages from item.completed events
|
|
93
|
+
if (event.type === 'item.completed' && event.item?.type === 'agent_message') {
|
|
94
|
+
agentMessages.push(event.item.text);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// Ignore lines that aren't valid JSON
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
71
101
|
}
|
|
102
|
+
// Combine all agent messages
|
|
103
|
+
const output = agentMessages.length > 0
|
|
104
|
+
? agentMessages.join('\n\n')
|
|
105
|
+
: rawOutput; // Fallback to raw output if no agent messages found
|
|
106
|
+
return { output, threadId };
|
|
72
107
|
}
|
|
73
108
|
static getToolName(runnerType) {
|
|
74
109
|
switch (runnerType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/services/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAc,UAAU,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/services/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAc,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAmB3D,MAAM,OAAO,eAAe;IACxB,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,MAAc,EAAE,OAAe;QACvD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,sCAA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AK,gBAAgB,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,KAAK,eAAe,EAAE,CAAC;oBAC1E,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACxC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACL,sCAAsC;gBACtC,SAAS;YACb,CAAC;QACL,CAAC;QAED,6BAA6B;QAC7B,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,GAAG,CAAC;YACnC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;YAC5B,CAAC,CAAC,SAAS,CAAC,CAAC,oDAAoD;QAErE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAChC,CAAC;IAEO,MAAM,CAAC,WAAW,CAAC,UAAsB;QAC7C,QAAQ,UAAU,EAAE,CAAC;YACjB,KAAK,UAAU,CAAC,MAAM;gBAClB,OAAO,QAAQ,CAAC;YACpB,KAAK,UAAU,CAAC,MAAM;gBAClB,OAAO,QAAQ,CAAC;YACpB,KAAK,UAAU,CAAC,KAAK;gBACjB,OAAO,OAAO,CAAC;YACnB;gBACI,OAAO,QAAQ,CAAC;QACxB,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -6,7 +6,7 @@ export declare class RunnerService {
|
|
|
6
6
|
static createRunner(data: CreateRunnerData): Promise<Runner>;
|
|
7
7
|
static deleteRunner(runnerId: string): Promise<void>;
|
|
8
8
|
static clearPendingCommand(runnerId: string): Promise<void>;
|
|
9
|
-
static updateRunnerAfterCommand(runnerId: string, result: string): Promise<void>;
|
|
9
|
+
static updateRunnerAfterCommand(runnerId: string, result: string, threadId?: string): Promise<void>;
|
|
10
10
|
static updateRunner(runnerId: string, pendingCommand: string): Promise<void>;
|
|
11
11
|
static createMessage(runnerId: string, data: CreateMessageRequest): Promise<void>;
|
|
12
12
|
static listenToRunner(runnerId: string, callback: (runner: Runner | null) => void): () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/services/runner.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,oBAAoB,EAAC,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAC,KAAK,gBAAgB,EAAE,KAAK,MAAM,EAAa,MAAM,oBAAoB,CAAC;AAKlF,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAa;WAE1C,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;WAkBlC,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/services/runner.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,oBAAoB,EAAC,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAC,KAAK,gBAAgB,EAAE,KAAK,MAAM,EAAa,MAAM,oBAAoB,CAAC;AAKlF,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAa;WAE1C,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;WAkBlC,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;WAmDrD,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAK7C,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAMpD,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAQ5F,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAOrE,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAavF,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI;IA6B9F,OAAO,CAAC,MAAM,CAAC,WAAW;IAiB1B,OAAO,CAAC,MAAM,CAAC,eAAe;CAWjC"}
|
package/dist/services/runner.js
CHANGED
|
@@ -45,7 +45,8 @@ export class RunnerService {
|
|
|
45
45
|
directory: data.directory,
|
|
46
46
|
machineId: deviceId,
|
|
47
47
|
machineName: deviceName,
|
|
48
|
-
encryptionVerification
|
|
48
|
+
encryptionVerification: encryptionVerification,
|
|
49
|
+
runnerType: data.runnerType,
|
|
49
50
|
});
|
|
50
51
|
const runnerId = response.id;
|
|
51
52
|
return {
|
|
@@ -69,10 +70,11 @@ export class RunnerService {
|
|
|
69
70
|
clearPendingCommand: true
|
|
70
71
|
});
|
|
71
72
|
}
|
|
72
|
-
static async updateRunnerAfterCommand(runnerId, result) {
|
|
73
|
+
static async updateRunnerAfterCommand(runnerId, result, threadId) {
|
|
73
74
|
await ApiService.updateRunner(runnerId, {
|
|
74
75
|
updateLastUsed: true,
|
|
75
|
-
lastMessage: result ?? ''
|
|
76
|
+
lastMessage: result ?? '',
|
|
77
|
+
threadId: threadId
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
80
|
static async updateRunner(runnerId, pendingCommand) {
|
|
@@ -100,6 +102,17 @@ export class RunnerService {
|
|
|
100
102
|
else {
|
|
101
103
|
callback(null);
|
|
102
104
|
}
|
|
105
|
+
},
|
|
106
|
+
// Swallow transient NOT_FOUND/unlisten race errors from Firestore stream restarts
|
|
107
|
+
(error) => {
|
|
108
|
+
const msg = String(error?.message || '');
|
|
109
|
+
if (error?.code === 'not-found' ||
|
|
110
|
+
msg.includes('Target id not found')) {
|
|
111
|
+
// no-op; listener cleanup or document delete races can cause this
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
// Re-throw other errors so they bubble and can be handled upstream
|
|
115
|
+
throw error;
|
|
103
116
|
});
|
|
104
117
|
}
|
|
105
118
|
static docToRunner(data, id) {
|
|
@@ -115,6 +128,7 @@ export class RunnerService {
|
|
|
115
128
|
machineName: data.machineName || undefined,
|
|
116
129
|
machineId: data.machineId || undefined,
|
|
117
130
|
pendingCommand: data.pendingCommand || undefined,
|
|
131
|
+
threadId: data.threadId || undefined,
|
|
118
132
|
};
|
|
119
133
|
}
|
|
120
134
|
static parseRunnerType(type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/services/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAE,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAC,EAAE,EAAC,MAAM,uBAAuB,CAAC;AACzC,OAAO,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,EAAC,UAAU,EAAuB,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAqC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAC,gBAAgB,EAAE,oBAAoB,EAAC,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAEnE,MAAM,OAAO,aAAa;IACd,MAAM,CAAU,kBAAkB,GAAG,SAAS,CAAC;IAEvD,MAAM,CAAC,KAAK,CAAC,aAAa;QACtB,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;QAClC,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAC;QACpC,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC9C,C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AE,IAAI,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/types/runner.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IAClB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,MAAM,WAAW;CACpB;AAED,MAAM,WAAW,MAAM;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,UAAU,CAAC;CAC1B;AAED,MAAM,WAAW,IAAI;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB,EAAE,MAAM,CAAC;CAC5B"}
|
package/package.json
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@commit451/salamander",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Never be AFK",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"bin": {
|
|
8
|
-
"salamander": "bin/salamander.js"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "tsc",
|
|
12
|
-
"dev": "tsx src/index.ts",
|
|
13
|
-
"start": "node dist/index.js",
|
|
14
|
-
"prepare": "npm run build",
|
|
15
|
-
"pub": "npm publish --access public"
|
|
16
|
-
},
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": ">=18.0.0"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"@inquirer/prompts": "^7.8.6",
|
|
22
|
-
"chalk": "^5.6.2",
|
|
23
|
-
"commander": "^14.0.1",
|
|
24
|
-
"firebase": "^12.3.0"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@types/node": "^24.5.2",
|
|
28
|
-
"tsx": "^4.20.5",
|
|
29
|
-
"typescript": "^5.9.2"
|
|
30
|
-
},
|
|
31
|
-
"keywords": [
|
|
32
|
-
"cli",
|
|
33
|
-
"afk",
|
|
34
|
-
"automation",
|
|
35
|
-
"tool"
|
|
36
|
-
],
|
|
37
|
-
"author": "",
|
|
38
|
-
"license": "ISC",
|
|
39
|
-
"repository": {
|
|
40
|
-
"type": "git",
|
|
41
|
-
"url": ""
|
|
42
|
-
},
|
|
43
|
-
"homepage": "",
|
|
44
|
-
"bugs": {
|
|
45
|
-
"url": ""
|
|
46
|
-
},
|
|
47
|
-
"files": [
|
|
48
|
-
"dist/**/*",
|
|
49
|
-
"bin/**/*",
|
|
50
|
-
"README.md"
|
|
51
|
-
]
|
|
52
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@commit451/salamander",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Never be AFK",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"salamander": "bin/salamander.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsx src/index.ts",
|
|
13
|
+
"start": "node dist/index.js",
|
|
14
|
+
"prepare": "npm run build",
|
|
15
|
+
"pub": "npm publish --access public"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18.0.0"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@inquirer/prompts": "^7.8.6",
|
|
22
|
+
"chalk": "^5.6.2",
|
|
23
|
+
"commander": "^14.0.1",
|
|
24
|
+
"firebase": "^12.3.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^24.5.2",
|
|
28
|
+
"tsx": "^4.20.5",
|
|
29
|
+
"typescript": "^5.9.2"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"cli",
|
|
33
|
+
"afk",
|
|
34
|
+
"automation",
|
|
35
|
+
"tool"
|
|
36
|
+
],
|
|
37
|
+
"author": "",
|
|
38
|
+
"license": "ISC",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": ""
|
|
42
|
+
},
|
|
43
|
+
"homepage": "",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": ""
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"dist/**/*",
|
|
49
|
+
"bin/**/*",
|
|
50
|
+
"README.md"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export interface KeyPair {
|
|
2
|
-
publicKey: string;
|
|
3
|
-
privateKey: string;
|
|
4
|
-
}
|
|
5
|
-
export interface EncryptedMessage {
|
|
6
|
-
encryptedData: string;
|
|
7
|
-
iv: string;
|
|
8
|
-
tag: string;
|
|
9
|
-
}
|
|
10
|
-
export declare class CryptoService {
|
|
11
|
-
private static readonly ALGORITHM;
|
|
12
|
-
private static readonly IV_LENGTH;
|
|
13
|
-
private static readonly TAG_LENGTH;
|
|
14
|
-
private static readonly KEY_LENGTH;
|
|
15
|
-
/**
|
|
16
|
-
* Generate an ECDH key pair for key exchange
|
|
17
|
-
*/
|
|
18
|
-
static generateECDHKeyPair(): KeyPair;
|
|
19
|
-
/**
|
|
20
|
-
* Derive a shared secret from ECDH key exchange
|
|
21
|
-
*/
|
|
22
|
-
static deriveSharedSecret(privateKey: string, publicKey: string): string;
|
|
23
|
-
/**
|
|
24
|
-
* Encrypt a message using AES-256-GCM
|
|
25
|
-
*/
|
|
26
|
-
static encrypt(message: string, key: string): EncryptedMessage;
|
|
27
|
-
/**
|
|
28
|
-
* Decrypt a message using AES-256-GCM
|
|
29
|
-
*/
|
|
30
|
-
static decrypt(encryptedMessage: EncryptedMessage, key: string): string;
|
|
31
|
-
/**
|
|
32
|
-
* Generate a random 256-bit key for symmetric encryption
|
|
33
|
-
*/
|
|
34
|
-
static generateRandomKey(): string;
|
|
35
|
-
/**
|
|
36
|
-
* Check if a message appears to be encrypted
|
|
37
|
-
*/
|
|
38
|
-
static isEncrypted(message: string): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Safely encrypt a message, handling both string and object inputs
|
|
41
|
-
*/
|
|
42
|
-
static safeEncrypt(data: any, key: string): string;
|
|
43
|
-
/**
|
|
44
|
-
* Safely decrypt a message, throwing error if decryption fails
|
|
45
|
-
*/
|
|
46
|
-
static safeDecrypt(encryptedData: string, key: string): string;
|
|
47
|
-
/**
|
|
48
|
-
* Create a hash of the key for identification purposes
|
|
49
|
-
*/
|
|
50
|
-
static createKeyHash(key: string): string;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/services/crypto.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,OAAO;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAClD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAM;IACvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAM;IACxC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAM;IAExC;;OAEG;IACH,MAAM,CAAC,mBAAmB,IAAI,OAAO;IAUrC;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAYxE;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB;IAmB9D;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAevE;;OAEG;IACH,MAAM,CAAC,iBAAiB,IAAI,MAAM;IAKlC;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAS5C;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAMlD;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAS9D;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAG5C"}
|
package/dist/services/crypto.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import * as crypto from 'node:crypto';
|
|
2
|
-
export class CryptoService {
|
|
3
|
-
static ALGORITHM = 'aes-256-gcm';
|
|
4
|
-
static IV_LENGTH = 16;
|
|
5
|
-
static TAG_LENGTH = 16;
|
|
6
|
-
static KEY_LENGTH = 32;
|
|
7
|
-
/**
|
|
8
|
-
* Generate an ECDH key pair for key exchange
|
|
9
|
-
*/
|
|
10
|
-
static generateECDHKeyPair() {
|
|
11
|
-
const ecdh = crypto.createECDH('secp256k1');
|
|
12
|
-
ecdh.generateKeys();
|
|
13
|
-
return {
|
|
14
|
-
publicKey: ecdh.getPublicKey('base64'),
|
|
15
|
-
privateKey: ecdh.getPrivateKey('base64')
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Derive a shared secret from ECDH key exchange
|
|
20
|
-
*/
|
|
21
|
-
static deriveSharedSecret(privateKey, publicKey) {
|
|
22
|
-
const ecdh = crypto.createECDH('secp256k1');
|
|
23
|
-
ecdh.setPrivateKey(privateKey, 'base64');
|
|
24
|
-
const sharedSecret = ecdh.computeSecret(publicKey, 'base64');
|
|
25
|
-
// Use HKDF to derive a proper encryption key
|
|
26
|
-
const derivedKey = crypto.hkdfSync('sha256', sharedSecret, '', 'salamander-e2e-encryption', CryptoService.KEY_LENGTH);
|
|
27
|
-
return Buffer.from(derivedKey).toString('base64');
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Encrypt a message using AES-256-GCM
|
|
31
|
-
*/
|
|
32
|
-
static encrypt(message, key) {
|
|
33
|
-
const keyBuffer = Buffer.from(key, 'base64');
|
|
34
|
-
const iv = crypto.randomBytes(CryptoService.IV_LENGTH);
|
|
35
|
-
const cipher = crypto.createCipheriv(CryptoService.ALGORITHM, keyBuffer, iv);
|
|
36
|
-
cipher.setAAD(Buffer.from('salamander'));
|
|
37
|
-
let encryptedData = cipher.update(message, 'utf8', 'base64');
|
|
38
|
-
encryptedData += cipher.final('base64');
|
|
39
|
-
const tag = cipher.getAuthTag();
|
|
40
|
-
return {
|
|
41
|
-
encryptedData,
|
|
42
|
-
iv: iv.toString('base64'),
|
|
43
|
-
tag: tag.toString('base64')
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Decrypt a message using AES-256-GCM
|
|
48
|
-
*/
|
|
49
|
-
static decrypt(encryptedMessage, key) {
|
|
50
|
-
const keyBuffer = Buffer.from(key, 'base64');
|
|
51
|
-
const iv = Buffer.from(encryptedMessage.iv, 'base64');
|
|
52
|
-
const tag = Buffer.from(encryptedMessage.tag, 'base64');
|
|
53
|
-
const decipher = crypto.createDecipheriv(CryptoService.ALGORITHM, keyBuffer, iv);
|
|
54
|
-
decipher.setAAD(Buffer.from('salamander'));
|
|
55
|
-
decipher.setAuthTag(tag);
|
|
56
|
-
let decryptedData = decipher.update(encryptedMessage.encryptedData, 'base64', 'utf8');
|
|
57
|
-
decryptedData += decipher.final('utf8');
|
|
58
|
-
return decryptedData;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Generate a random 256-bit key for symmetric encryption
|
|
62
|
-
*/
|
|
63
|
-
static generateRandomKey() {
|
|
64
|
-
const key = crypto.randomBytes(CryptoService.KEY_LENGTH);
|
|
65
|
-
return key.toString('base64');
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Check if a message appears to be encrypted
|
|
69
|
-
*/
|
|
70
|
-
static isEncrypted(message) {
|
|
71
|
-
try {
|
|
72
|
-
const parsed = JSON.parse(message);
|
|
73
|
-
return parsed.encryptedData && parsed.iv && parsed.tag;
|
|
74
|
-
}
|
|
75
|
-
catch {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Safely encrypt a message, handling both string and object inputs
|
|
81
|
-
*/
|
|
82
|
-
static safeEncrypt(data, key) {
|
|
83
|
-
const message = typeof data === 'string' ? data : JSON.stringify(data);
|
|
84
|
-
const encrypted = this.encrypt(message, key);
|
|
85
|
-
return JSON.stringify(encrypted);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Safely decrypt a message, throwing error if decryption fails
|
|
89
|
-
*/
|
|
90
|
-
static safeDecrypt(encryptedData, key) {
|
|
91
|
-
if (!this.isEncrypted(encryptedData)) {
|
|
92
|
-
throw new Error('Message is not encrypted - encryption is required');
|
|
93
|
-
}
|
|
94
|
-
const encryptedMessage = JSON.parse(encryptedData);
|
|
95
|
-
return this.decrypt(encryptedMessage, key);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Create a hash of the key for identification purposes
|
|
99
|
-
*/
|
|
100
|
-
static createKeyHash(key) {
|
|
101
|
-
return crypto.createHash('sha256').update(key).digest('hex').substring(0, 16);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=crypto.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/services/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAatC,MAAM,OAAO,aAAa;IACd,MAAM,CAAU,SAAS,GAAG,aAAa,CAAC;IAC1C,MAAM,CAAU,SAAS,GAAG,EAAE,CAAC;IAC/B,MAAM,CAAU,UAAU,GAAG,EAAE,CAAC;IAChC,MAAM,CAAU,UAAU,GAAG,EAAE,CAAC;IAExC;;OAEG;IACH,MAAM,CAAC,mBAAmB;QACtB,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC5C,IAAI,CAAC,YAAY,EAAE,CAAC;QAEpB,OAAO;YACH,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;YACtC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;SAC3C,CAAC;IACN,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAkB,EAAE,SAAiB;QAC3D,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC5C,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,C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C,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACvE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,aAAqB,EAAE,GAAW;QACjD,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACzE,CAAC;QAED,MAAM,gBAAgB,GAAqB,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,GAAW;QAC5B,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAClF,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { KeyPair } from './crypto.js';
|
|
2
|
-
export declare class KeyManagerService {
|
|
3
|
-
private static readonly KEYS_STORAGE_KEY;
|
|
4
|
-
private static readonly KEY_EXPIRY_DAYS;
|
|
5
|
-
/**
|
|
6
|
-
* Initialize keys for a new runner
|
|
7
|
-
*/
|
|
8
|
-
static initializeRunnerKeys(runnerId: string): Promise<KeyPair>;
|
|
9
|
-
/**
|
|
10
|
-
* Complete the key exchange with the Flutter app's public key
|
|
11
|
-
*/
|
|
12
|
-
static completeKeyExchange(runnerId: string, flutterPublicKey: string): Promise<string>;
|
|
13
|
-
/**
|
|
14
|
-
* Get the shared secret for encryption/decryption
|
|
15
|
-
*/
|
|
16
|
-
static getSharedSecret(runnerId: string): Promise<string | null>;
|
|
17
|
-
/**
|
|
18
|
-
* Get the CLI's public key for a runner
|
|
19
|
-
*/
|
|
20
|
-
static getPublicKey(runnerId: string): Promise<string | null>;
|
|
21
|
-
/**
|
|
22
|
-
* Check if keys exist and are properly initialized for a runner
|
|
23
|
-
*/
|
|
24
|
-
static hasValidKeys(runnerId: string): Promise<boolean>;
|
|
25
|
-
/**
|
|
26
|
-
* Rotate keys for a runner (generate new key pair)
|
|
27
|
-
*/
|
|
28
|
-
static rotateKeys(runnerId: string): Promise<KeyPair>;
|
|
29
|
-
/**
|
|
30
|
-
* Remove keys for a runner (when runner is deleted)
|
|
31
|
-
*/
|
|
32
|
-
static removeRunnerKeys(runnerId: string): Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* Get all runners that have encryption keys
|
|
35
|
-
*/
|
|
36
|
-
static getEncryptedRunnerIds(): Promise<string[]>;
|
|
37
|
-
/**
|
|
38
|
-
* Cleanup expired keys
|
|
39
|
-
*/
|
|
40
|
-
static cleanupExpiredKeys(): Promise<number>;
|
|
41
|
-
private static getRunnerKeys;
|
|
42
|
-
private static storeRunnerKeys;
|
|
43
|
-
private static getAllStoredKeys;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=key-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"key-manager.d.ts","sourceRoot":"","sources":["../../src/services/key-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,OAAO,EAAC,MAAM,aAAa,CAAC;AAUnD,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAA4B;IACpE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAM;IAE7C;;OAEG;WACU,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYrE;;OAEG;WACU,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoB7F;;OAEG;WACU,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAetE;;OAEG;WACU,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKnE;;OAEG;WACU,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK7D;;OAEG;WACU,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK3D;;OAEG;WACU,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM9D;;OAEG;WACU,qBAAqB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAQvD;;OAEG;WACU,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;mBAwB7B,aAAa;mBAKb,eAAe;mBAMf,gBAAgB;CAGxC"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { CryptoService } from './crypto.js';
|
|
2
|
-
import { StorageService } from '../utils/storage.js';
|
|
3
|
-
export class KeyManagerService {
|
|
4
|
-
static KEYS_STORAGE_KEY = 'salamander_runner_keys';
|
|
5
|
-
static KEY_EXPIRY_DAYS = 30;
|
|
6
|
-
/**
|
|
7
|
-
* Initialize keys for a new runner
|
|
8
|
-
*/
|
|
9
|
-
static async initializeRunnerKeys(runnerId) {
|
|
10
|
-
const ecdhKeyPair = CryptoService.generateECDHKeyPair();
|
|
11
|
-
const runnerKeys = {
|
|
12
|
-
ecdhKeyPair,
|
|
13
|
-
createdAt: Date.now()
|
|
14
|
-
};
|
|
15
|
-
await this.storeRunnerKeys(runnerId, runnerKeys);
|
|
16
|
-
return ecdhKeyPair;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Complete the key exchange with the Flutter app's public key
|
|
20
|
-
*/
|
|
21
|
-
static async completeKeyExchange(runnerId, flutterPublicKey) {
|
|
22
|
-
const runnerKeys = await this.getRunnerKeys(runnerId);
|
|
23
|
-
if (!runnerKeys) {
|
|
24
|
-
throw new Error(`No keys found for runner ${runnerId}`);
|
|
25
|
-
}
|
|
26
|
-
// Derive shared secret using our private key and Flutter's public key
|
|
27
|
-
const sharedSecret = CryptoService.deriveSharedSecret(runnerKeys.ecdhKeyPair.privateKey, flutterPublicKey);
|
|
28
|
-
// Update stored keys with shared secret
|
|
29
|
-
runnerKeys.sharedSecret = sharedSecret;
|
|
30
|
-
runnerKeys.keyHash = CryptoService.createKeyHash(sharedSecret);
|
|
31
|
-
await this.storeRunnerKeys(runnerId, runnerKeys);
|
|
32
|
-
return sharedSecret;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Get the shared secret for encryption/decryption
|
|
36
|
-
*/
|
|
37
|
-
static async getSharedSecret(runnerId) {
|
|
38
|
-
const runnerKeys = await this.getRunnerKeys(runnerId);
|
|
39
|
-
if (!runnerKeys?.sharedSecret) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
// Check if keys are expired
|
|
43
|
-
const daysSinceCreation = (Date.now() - runnerKeys.createdAt) / (1000 * 60 * 60 * 24);
|
|
44
|
-
if (daysSinceCreation > this.KEY_EXPIRY_DAYS) {
|
|
45
|
-
console.warn(`Keys for runner ${runnerId} have expired. Consider key rotation.`);
|
|
46
|
-
}
|
|
47
|
-
return runnerKeys.sharedSecret;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Get the CLI's public key for a runner
|
|
51
|
-
*/
|
|
52
|
-
static async getPublicKey(runnerId) {
|
|
53
|
-
const runnerKeys = await this.getRunnerKeys(runnerId);
|
|
54
|
-
return runnerKeys?.ecdhKeyPair.publicKey ?? null;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Check if keys exist and are properly initialized for a runner
|
|
58
|
-
*/
|
|
59
|
-
static async hasValidKeys(runnerId) {
|
|
60
|
-
const runnerKeys = await this.getRunnerKeys(runnerId);
|
|
61
|
-
return !!(runnerKeys?.ecdhKeyPair && runnerKeys?.sharedSecret);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Rotate keys for a runner (generate new key pair)
|
|
65
|
-
*/
|
|
66
|
-
static async rotateKeys(runnerId) {
|
|
67
|
-
console.log(`Rotating keys for runner ${runnerId}`);
|
|
68
|
-
return await this.initializeRunnerKeys(runnerId);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Remove keys for a runner (when runner is deleted)
|
|
72
|
-
*/
|
|
73
|
-
static async removeRunnerKeys(runnerId) {
|
|
74
|
-
const allKeys = await this.getAllStoredKeys();
|
|
75
|
-
delete allKeys[runnerId];
|
|
76
|
-
await StorageService.set(this.KEYS_STORAGE_KEY, allKeys);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Get all runners that have encryption keys
|
|
80
|
-
*/
|
|
81
|
-
static async getEncryptedRunnerIds() {
|
|
82
|
-
const allKeys = await this.getAllStoredKeys();
|
|
83
|
-
return Object.keys(allKeys).filter(runnerId => {
|
|
84
|
-
const keys = allKeys[runnerId];
|
|
85
|
-
return keys?.sharedSecret;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Cleanup expired keys
|
|
90
|
-
*/
|
|
91
|
-
static async cleanupExpiredKeys() {
|
|
92
|
-
const allKeys = await this.getAllStoredKeys();
|
|
93
|
-
const now = Date.now();
|
|
94
|
-
let cleanedCount = 0;
|
|
95
|
-
const updatedKeys = {};
|
|
96
|
-
for (const [runnerId, keys] of Object.entries(allKeys)) {
|
|
97
|
-
const daysSinceCreation = (now - keys.createdAt) / (1000 * 60 * 60 * 24);
|
|
98
|
-
if (daysSinceCreation <= this.KEY_EXPIRY_DAYS) {
|
|
99
|
-
updatedKeys[runnerId] = keys;
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
cleanedCount++;
|
|
103
|
-
console.log(`Cleaned up expired keys for runner ${runnerId}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
await StorageService.set(this.KEYS_STORAGE_KEY, updatedKeys);
|
|
107
|
-
return cleanedCount;
|
|
108
|
-
}
|
|
109
|
-
// Private helper methods
|
|
110
|
-
static async getRunnerKeys(runnerId) {
|
|
111
|
-
const allKeys = await this.getAllStoredKeys();
|
|
112
|
-
return allKeys[runnerId] ?? null;
|
|
113
|
-
}
|
|
114
|
-
static async storeRunnerKeys(runnerId, keys) {
|
|
115
|
-
const allKeys = await this.getAllStoredKeys();
|
|
116
|
-
allKeys[runnerId] = keys;
|
|
117
|
-
await StorageService.set(this.KEYS_STORAGE_KEY, allKeys);
|
|
118
|
-
}
|
|
119
|
-
static async getAllStoredKeys() {
|
|
120
|
-
return (await StorageService.get(this.KEYS_STORAGE_KEY)) ?? {};
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=key-manager.js.map
|