skillvault-publisher 0.1.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/dist/commands/decrypt.d.ts +3 -0
- package/dist/commands/decrypt.d.ts.map +1 -0
- package/dist/commands/decrypt.js +152 -0
- package/dist/commands/decrypt.js.map +1 -0
- package/dist/commands/info.d.ts +3 -0
- package/dist/commands/info.d.ts.map +1 -0
- package/dist/commands/info.js +30 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +83 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +149 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/licenses.d.ts +3 -0
- package/dist/commands/licenses.d.ts.map +1 -0
- package/dist/commands/licenses.js +96 -0
- package/dist/commands/licenses.js.map +1 -0
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +89 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +3 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +11 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/publish.d.ts +3 -0
- package/dist/commands/publish.d.ts.map +1 -0
- package/dist/commands/publish.js +215 -0
- package/dist/commands/publish.js.map +1 -0
- package/dist/commands/report.d.ts +3 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +72 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/search.d.ts +3 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +79 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/update.d.ts +3 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +152 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/whoami.d.ts +3 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +128 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/credentials.d.ts +32 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +106 -0
- package/dist/credentials.js.map +1 -0
- package/dist/fingerprint.d.ts +18 -0
- package/dist/fingerprint.d.ts.map +1 -0
- package/dist/fingerprint.js +51 -0
- package/dist/fingerprint.js.map +1 -0
- package/dist/grant-cache.d.ts +40 -0
- package/dist/grant-cache.d.ts.map +1 -0
- package/dist/grant-cache.js +112 -0
- package/dist/grant-cache.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offline grant caching with TTL and grace periods.
|
|
3
|
+
* Cache file: ~/.skillvault/grants-cache.json
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync, writeFileSync, rmSync, existsSync } from 'node:fs';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { homedir } from 'node:os';
|
|
8
|
+
import { mkdirSync } from 'node:fs';
|
|
9
|
+
const CONFIG_DIR = join(homedir(), '.skillvault');
|
|
10
|
+
const CACHE_FILE = join(CONFIG_DIR, 'grants-cache.json');
|
|
11
|
+
/** Default TTL: 1 hour in milliseconds */
|
|
12
|
+
const DEFAULT_TTL_MS = 60 * 60 * 1000;
|
|
13
|
+
/** Soft grace: TTL + 10 minutes */
|
|
14
|
+
const SOFT_GRACE_MS = 10 * 60 * 1000;
|
|
15
|
+
/** Hard grace: TTL + 30 minutes */
|
|
16
|
+
const HARD_GRACE_MS = 30 * 60 * 1000;
|
|
17
|
+
function getTTL() {
|
|
18
|
+
const envTTL = process.env.SKILLVAULT_CACHE_TTL;
|
|
19
|
+
if (envTTL) {
|
|
20
|
+
const parsed = parseInt(envTTL, 10);
|
|
21
|
+
if (!isNaN(parsed) && parsed > 0)
|
|
22
|
+
return parsed;
|
|
23
|
+
}
|
|
24
|
+
return DEFAULT_TTL_MS;
|
|
25
|
+
}
|
|
26
|
+
function readCache() {
|
|
27
|
+
try {
|
|
28
|
+
if (!existsSync(CACHE_FILE))
|
|
29
|
+
return { grants: {} };
|
|
30
|
+
const raw = readFileSync(CACHE_FILE, 'utf8');
|
|
31
|
+
const data = JSON.parse(raw);
|
|
32
|
+
if (!data.grants || typeof data.grants !== 'object')
|
|
33
|
+
return { grants: {} };
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return { grants: {} };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function writeCache(data) {
|
|
41
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
42
|
+
writeFileSync(CACHE_FILE, JSON.stringify(data, null, 2));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Store a grant in the cache with a timestamp.
|
|
46
|
+
*/
|
|
47
|
+
export function cacheGrant(capability, grant) {
|
|
48
|
+
const data = readCache();
|
|
49
|
+
data.grants[capability] = {
|
|
50
|
+
capability,
|
|
51
|
+
grant,
|
|
52
|
+
cached_at: new Date().toISOString(),
|
|
53
|
+
};
|
|
54
|
+
writeCache(data);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Retrieve a cached grant if it exists and is within TTL.
|
|
58
|
+
* Returns null if missing or expired.
|
|
59
|
+
*/
|
|
60
|
+
export function getCachedGrant(capability) {
|
|
61
|
+
const data = readCache();
|
|
62
|
+
const entry = data.grants[capability];
|
|
63
|
+
if (!entry)
|
|
64
|
+
return null;
|
|
65
|
+
const age = Date.now() - new Date(entry.cached_at).getTime();
|
|
66
|
+
if (age > getTTL())
|
|
67
|
+
return null;
|
|
68
|
+
return entry.grant;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Check if a cached grant is within the soft grace period (TTL + 10 min).
|
|
72
|
+
* Returns true if the grant exists and is within soft grace, even if past TTL.
|
|
73
|
+
*/
|
|
74
|
+
export function isWithinSoftGrace(capability) {
|
|
75
|
+
const data = readCache();
|
|
76
|
+
const entry = data.grants[capability];
|
|
77
|
+
if (!entry)
|
|
78
|
+
return false;
|
|
79
|
+
const age = Date.now() - new Date(entry.cached_at).getTime();
|
|
80
|
+
return age <= getTTL() + SOFT_GRACE_MS;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Check if a cached grant is within the hard grace period (TTL + 30 min).
|
|
84
|
+
* Returns true if the grant exists and is within hard grace, even if past TTL.
|
|
85
|
+
*/
|
|
86
|
+
export function isWithinHardGrace(capability) {
|
|
87
|
+
const data = readCache();
|
|
88
|
+
const entry = data.grants[capability];
|
|
89
|
+
if (!entry)
|
|
90
|
+
return false;
|
|
91
|
+
const age = Date.now() - new Date(entry.cached_at).getTime();
|
|
92
|
+
return age <= getTTL() + HARD_GRACE_MS;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Remove the cache file entirely.
|
|
96
|
+
*/
|
|
97
|
+
export function clearCache() {
|
|
98
|
+
try {
|
|
99
|
+
rmSync(CACHE_FILE);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
/* ok if missing */
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** Exported for testing */
|
|
106
|
+
export const _internals = {
|
|
107
|
+
CACHE_FILE,
|
|
108
|
+
DEFAULT_TTL_MS,
|
|
109
|
+
SOFT_GRACE_MS,
|
|
110
|
+
HARD_GRACE_MS,
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=grant-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grant-cache.js","sourceRoot":"","sources":["../src/grant-cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,SAAS,CA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AAK;QAAE,OAAO,KAAK,CAAC;IAEzB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;IAC7D,OAAO,GAAG,IAAI,MAAM,EAAE,GAAG,aAAa,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,MAAM,IAAI,GAAG,SAAS,EAAE,CAAC;IACzB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEzB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;IAC7D,OAAO,GAAG,IAAI,MAAM,EAAE,GAAG,aAAa,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,IAAI,CAAC;QACH,MAAM,CAAC,UAAU,CAAC,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,mBAAmB;IACrB,CAAC;AACH,CAAC;AAED,2BAA2B;AAC3B,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,UAAU;IACV,cAAc;IACd,aAAa;IACb,aAAa;CACd,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { loginCommand } from './commands/login.js';
|
|
4
|
+
import { logoutCommand } from './commands/logout.js';
|
|
5
|
+
import { publishCommand } from './commands/publish.js';
|
|
6
|
+
import { installCommand } from './commands/install.js';
|
|
7
|
+
import { decryptCommand } from './commands/decrypt.js';
|
|
8
|
+
import { searchCommand } from './commands/search.js';
|
|
9
|
+
import { infoCommand } from './commands/info.js';
|
|
10
|
+
import { licensesCommand } from './commands/licenses.js';
|
|
11
|
+
import { updateCommand } from './commands/update.js';
|
|
12
|
+
import { whoamiCommand } from './commands/whoami.js';
|
|
13
|
+
import { reportCommand } from './commands/report.js';
|
|
14
|
+
import { initCommand } from './commands/init.js';
|
|
15
|
+
const program = new Command();
|
|
16
|
+
program
|
|
17
|
+
.name('skillvault-publisher')
|
|
18
|
+
.description('SkillVault publisher CLI — publish, manage, and distribute encrypted skills')
|
|
19
|
+
.version('0.1.0');
|
|
20
|
+
program.addCommand(loginCommand);
|
|
21
|
+
program.addCommand(logoutCommand);
|
|
22
|
+
program.addCommand(publishCommand);
|
|
23
|
+
program.addCommand(installCommand);
|
|
24
|
+
program.addCommand(decryptCommand);
|
|
25
|
+
program.addCommand(searchCommand);
|
|
26
|
+
program.addCommand(infoCommand);
|
|
27
|
+
program.addCommand(licensesCommand);
|
|
28
|
+
program.addCommand(updateCommand);
|
|
29
|
+
program.addCommand(whoamiCommand);
|
|
30
|
+
program.addCommand(reportCommand);
|
|
31
|
+
program.addCommand(initCommand);
|
|
32
|
+
program.parse();
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,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
4
|
+
"description": "SkillVault publisher CLI — publish, manage, and distribute encrypted skills",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"skillvault-publisher": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"typecheck": "tsc --noEmit"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"skillvault",
|
|
18
|
+
"claude",
|
|
19
|
+
"claude-code",
|
|
20
|
+
"ai-skills",
|
|
21
|
+
"skill-publisher",
|
|
22
|
+
"encrypted-skills"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"skillvault-shared": "*",
|
|
27
|
+
"chalk": "^5.4.0",
|
|
28
|
+
"commander": "^13.1.0",
|
|
29
|
+
"jose": "^6.2.2",
|
|
30
|
+
"ora": "^8.2.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"typescript": "^5.8.0"
|
|
34
|
+
}
|
|
35
|
+
}
|