axvault 1.1.0 → 1.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.
- package/README.md +41 -8
- package/dist/cli.js +19 -2
- package/dist/commands/key-create.d.ts +13 -0
- package/dist/commands/key-create.js +99 -0
- package/dist/commands/key-list.d.ts +9 -0
- package/dist/commands/key-list.js +43 -0
- package/dist/commands/key-revoke.d.ts +8 -0
- package/dist/commands/key-revoke.js +47 -0
- package/dist/commands/key-update.d.ts +15 -0
- package/dist/commands/key-update.js +109 -0
- package/dist/commands/key.d.ts +6 -18
- package/dist/commands/key.js +6 -154
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/migrations.js +39 -1
- package/dist/db/repositories/api-keys.d.ts +11 -1
- package/dist/db/repositories/api-keys.js +34 -5
- package/dist/db/repositories/audit-log.d.ts +1 -1
- package/dist/db/repositories/credentials-queries.d.ts +8 -0
- package/dist/db/repositories/credentials-queries.js +19 -0
- package/dist/db/repositories/credentials.d.ts +3 -25
- package/dist/db/repositories/credentials.js +12 -54
- package/dist/db/repositories/parse-credential-row.d.ts +33 -0
- package/dist/db/repositories/parse-credential-row.js +39 -0
- package/dist/db/types.d.ts +1 -0
- package/dist/handlers/get-credential.js +2 -1
- package/dist/handlers/put-credential.js +5 -3
- package/dist/lib/format.d.ts +1 -0
- package/dist/lib/format.js +2 -1
- package/dist/lib/parse-access-options.d.ts +37 -0
- package/dist/lib/parse-access-options.js +84 -0
- package/dist/refresh/check-refresh.js +2 -2
- package/dist/refresh/refresh-manager.d.ts +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse and validate access list options from CLI flags.
|
|
3
|
+
*/
|
|
4
|
+
interface ParsedAccessOptions {
|
|
5
|
+
addRead: string[];
|
|
6
|
+
addWrite: string[];
|
|
7
|
+
addGrant: string[];
|
|
8
|
+
removeRead: string[];
|
|
9
|
+
removeWrite: string[];
|
|
10
|
+
removeGrant: string[];
|
|
11
|
+
}
|
|
12
|
+
interface AccessOptions {
|
|
13
|
+
addRead?: string;
|
|
14
|
+
addWrite?: string;
|
|
15
|
+
addGrant?: string;
|
|
16
|
+
removeRead?: string;
|
|
17
|
+
removeWrite?: string;
|
|
18
|
+
removeGrant?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Parse all access list options and validate them.
|
|
22
|
+
* Returns parsed entries or logs error and sets exit code.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseAccessOptions(options: AccessOptions): ParsedAccessOptions | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Compute updated access list by adding and removing entries.
|
|
27
|
+
*/
|
|
28
|
+
export declare function computeUpdatedAccess(current: string[], toAdd: string[], toRemove: string[]): string[];
|
|
29
|
+
/**
|
|
30
|
+
* Normalize all access lists and print warnings.
|
|
31
|
+
*/
|
|
32
|
+
export declare function normalizeAllAccess(readAccess: string[], writeAccess: string[], grantAccess: string[]): {
|
|
33
|
+
read: string[];
|
|
34
|
+
write: string[];
|
|
35
|
+
grant: string[];
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse and validate access list options from CLI flags.
|
|
3
|
+
*/
|
|
4
|
+
import { getAccessListErrorMessage, normalizeAccessList, parseAccessList, } from "./format.js";
|
|
5
|
+
/**
|
|
6
|
+
* Parse all access list options and validate them.
|
|
7
|
+
* Returns parsed entries or logs error and sets exit code.
|
|
8
|
+
*/
|
|
9
|
+
export function parseAccessOptions(options) {
|
|
10
|
+
const addReadResult = parseAccessList(options.addRead);
|
|
11
|
+
const addWriteResult = parseAccessList(options.addWrite);
|
|
12
|
+
const addGrantResult = parseAccessList(options.addGrant);
|
|
13
|
+
const removeReadResult = parseAccessList(options.removeRead);
|
|
14
|
+
const removeWriteResult = parseAccessList(options.removeWrite);
|
|
15
|
+
const removeGrantResult = parseAccessList(options.removeGrant);
|
|
16
|
+
if (addReadResult.error) {
|
|
17
|
+
console.error(`Error in --add-read: ${getAccessListErrorMessage(addReadResult.error)}`);
|
|
18
|
+
process.exitCode = 2;
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
if (addWriteResult.error) {
|
|
22
|
+
console.error(`Error in --add-write: ${getAccessListErrorMessage(addWriteResult.error)}`);
|
|
23
|
+
process.exitCode = 2;
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
if (addGrantResult.error) {
|
|
27
|
+
console.error(`Error in --add-grant: ${getAccessListErrorMessage(addGrantResult.error)}`);
|
|
28
|
+
process.exitCode = 2;
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
if (removeReadResult.error) {
|
|
32
|
+
console.error(`Error in --remove-read: ${getAccessListErrorMessage(removeReadResult.error)}`);
|
|
33
|
+
process.exitCode = 2;
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
if (removeWriteResult.error) {
|
|
37
|
+
console.error(`Error in --remove-write: ${getAccessListErrorMessage(removeWriteResult.error)}`);
|
|
38
|
+
process.exitCode = 2;
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
if (removeGrantResult.error) {
|
|
42
|
+
console.error(`Error in --remove-grant: ${getAccessListErrorMessage(removeGrantResult.error)}`);
|
|
43
|
+
process.exitCode = 2;
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
addRead: addReadResult.entries,
|
|
48
|
+
addWrite: addWriteResult.entries,
|
|
49
|
+
addGrant: addGrantResult.entries,
|
|
50
|
+
removeRead: removeReadResult.entries,
|
|
51
|
+
removeWrite: removeWriteResult.entries,
|
|
52
|
+
removeGrant: removeGrantResult.entries,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Compute updated access list by adding and removing entries.
|
|
57
|
+
*/
|
|
58
|
+
export function computeUpdatedAccess(current, toAdd, toRemove) {
|
|
59
|
+
const set = new Set(current);
|
|
60
|
+
for (const entry of toAdd)
|
|
61
|
+
set.add(entry);
|
|
62
|
+
for (const entry of toRemove)
|
|
63
|
+
set.delete(entry);
|
|
64
|
+
return [...set];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Normalize all access lists and print warnings.
|
|
68
|
+
*/
|
|
69
|
+
export function normalizeAllAccess(readAccess, writeAccess, grantAccess) {
|
|
70
|
+
const readNorm = normalizeAccessList(readAccess, "read");
|
|
71
|
+
const writeNorm = normalizeAccessList(writeAccess, "write");
|
|
72
|
+
const grantNorm = normalizeAccessList(grantAccess, "grant");
|
|
73
|
+
if (readNorm.warning)
|
|
74
|
+
console.warn(`Warning: ${readNorm.warning}`);
|
|
75
|
+
if (writeNorm.warning)
|
|
76
|
+
console.warn(`Warning: ${writeNorm.warning}`);
|
|
77
|
+
if (grantNorm.warning)
|
|
78
|
+
console.warn(`Warning: ${grantNorm.warning}`);
|
|
79
|
+
return {
|
|
80
|
+
read: readNorm.normalized,
|
|
81
|
+
write: writeNorm.normalized,
|
|
82
|
+
grant: grantNorm.normalized,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -50,10 +50,10 @@ function toAxauthCredentials(agent, data) {
|
|
|
50
50
|
if (!VALID_AGENTS.has(agent)) {
|
|
51
51
|
return undefined;
|
|
52
52
|
}
|
|
53
|
-
// Only OAuth credentials can be refreshed
|
|
53
|
+
// Only OAuth credentials with refresh tokens can be refreshed
|
|
54
54
|
return {
|
|
55
55
|
agent: agent,
|
|
56
|
-
type: "oauth",
|
|
56
|
+
type: "oauth-credentials",
|
|
57
57
|
data,
|
|
58
58
|
};
|
|
59
59
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* with axauth's refresh functionality.
|
|
6
6
|
*/
|
|
7
7
|
import type Database from "better-sqlite3";
|
|
8
|
-
import type { CredentialType } from "
|
|
8
|
+
import type { CredentialType } from "axshared";
|
|
9
9
|
/** Key for credential-specific mutex */
|
|
10
10
|
type CredentialKey = `${string}/${string}`;
|
|
11
11
|
/** Result type for the full refresh operation */
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "axvault",
|
|
3
3
|
"author": "Łukasz Jerciński",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.3.0",
|
|
6
6
|
"description": "Remote credential storage server for axkit",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@commander-js/extra-typings": "^14.0.0",
|
|
52
|
-
"axauth": "^1.
|
|
53
|
-
"axshared": "
|
|
54
|
-
"better-sqlite3": "^12.
|
|
52
|
+
"axauth": "^1.9.0",
|
|
53
|
+
"axshared": "1.9.0",
|
|
54
|
+
"better-sqlite3": "^12.6.0",
|
|
55
55
|
"commander": "^14.0.2",
|
|
56
56
|
"express": "^5.2.1"
|
|
57
57
|
},
|
|
@@ -78,13 +78,13 @@
|
|
|
78
78
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
79
79
|
"@types/better-sqlite3": "^7.6.13",
|
|
80
80
|
"@types/express": "^5.0.6",
|
|
81
|
-
"@types/node": "^25.0.
|
|
81
|
+
"@types/node": "^25.0.5",
|
|
82
82
|
"@vitest/coverage-v8": "^4.0.16",
|
|
83
83
|
"eslint": "^9.39.2",
|
|
84
84
|
"eslint-config-axkit": "^1.0.0",
|
|
85
85
|
"fta-check": "^1.5.1",
|
|
86
86
|
"fta-cli": "^3.0.0",
|
|
87
|
-
"knip": "^5.80.
|
|
87
|
+
"knip": "^5.80.2",
|
|
88
88
|
"prettier": "3.7.4",
|
|
89
89
|
"semantic-release": "^25.0.2",
|
|
90
90
|
"typescript": "^5.9.3",
|