@nepopsx/cli 0.0.22 → 0.0.24
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/init.js +1 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +15 -8
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/login.d.ts +3 -3
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +14 -36
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +11 -4
- package/dist/commands/sync.js.map +1 -1
- package/dist/config/api-config.d.ts +9 -0
- package/dist/config/api-config.d.ts.map +1 -1
- package/dist/config/api-config.js +10 -1
- package/dist/config/api-config.js.map +1 -1
- package/dist/index.js +0 -6
- package/dist/index.js.map +1 -1
- package/dist/licensing/entitlement-cache.d.ts +25 -0
- package/dist/licensing/entitlement-cache.d.ts.map +1 -0
- package/dist/licensing/entitlement-cache.js +42 -0
- package/dist/licensing/entitlement-cache.js.map +1 -0
- package/dist/licensing/index.d.ts +2 -1
- package/dist/licensing/index.d.ts.map +1 -1
- package/dist/licensing/index.js +2 -1
- package/dist/licensing/index.js.map +1 -1
- package/dist/licensing/installer.d.ts +7 -8
- package/dist/licensing/installer.d.ts.map +1 -1
- package/dist/licensing/installer.js +9 -17
- package/dist/licensing/installer.js.map +1 -1
- package/dist/licensing/license-manager.d.ts +26 -41
- package/dist/licensing/license-manager.d.ts.map +1 -1
- package/dist/licensing/license-manager.js +67 -257
- package/dist/licensing/license-manager.js.map +1 -1
- package/dist/licensing/template-fetch.d.ts.map +1 -1
- package/dist/licensing/template-fetch.js +4 -0
- package/dist/licensing/template-fetch.js.map +1 -1
- package/dist/mcp/config-generator.d.ts +6 -6
- package/dist/mcp/config-generator.d.ts.map +1 -1
- package/dist/mcp/config-generator.js +4 -4
- package/dist/mcp/config-generator.js.map +1 -1
- package/dist/utils/disk-cache.d.ts +14 -0
- package/dist/utils/disk-cache.d.ts.map +1 -0
- package/dist/utils/disk-cache.js +53 -0
- package/dist/utils/disk-cache.js.map +1 -0
- package/dist/utils/fetch-plan-manifest.d.ts +20 -0
- package/dist/utils/fetch-plan-manifest.d.ts.map +1 -0
- package/dist/utils/fetch-plan-manifest.js +93 -0
- package/dist/utils/fetch-plan-manifest.js.map +1 -0
- package/dist/utils/handle-402.d.ts +17 -0
- package/dist/utils/handle-402.d.ts.map +1 -0
- package/dist/utils/handle-402.js +31 -0
- package/dist/utils/handle-402.js.map +1 -0
- package/package.json +2 -2
|
@@ -13,12 +13,21 @@ export function readLocalConfig(rootDir) {
|
|
|
13
13
|
}
|
|
14
14
|
try {
|
|
15
15
|
const raw = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
16
|
-
|
|
16
|
+
const out = {};
|
|
17
|
+
if (typeof raw.api_url === 'string')
|
|
18
|
+
out.api_url = raw.api_url;
|
|
19
|
+
if (raw.auth && typeof raw.auth.token === 'string')
|
|
20
|
+
out.auth = raw.auth;
|
|
21
|
+
return out;
|
|
17
22
|
}
|
|
18
23
|
catch {
|
|
19
24
|
return {};
|
|
20
25
|
}
|
|
21
26
|
}
|
|
27
|
+
/** The device token from `nepopsx login` — the one credential the CLI sends as a Bearer token. */
|
|
28
|
+
export function readDeviceToken(rootDir) {
|
|
29
|
+
return readLocalConfig(rootDir).auth?.token ?? null;
|
|
30
|
+
}
|
|
22
31
|
export function writeLocalConfig(rootDir, config) {
|
|
23
32
|
const configPath = getLocalConfigPath(rootDir);
|
|
24
33
|
mkdirSync(join(rootDir, NEPOPSX_DIR), { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-config.js","sourceRoot":"","sources":["../../src/config/api-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EA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,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC/C,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,WAAW,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAC7C,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,MAAc;IACxD,MAAM,UAAU,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAC1C,gBAAgB,CAAC,OAAO,EAAE;QACxB,GAAG,QAAQ;QACX,OAAO,EAAE,UAAU;KACpB,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACtB,OAAO;IACT,CAAC;IAED,MAAM,IAAI,GAAuB,EAAE,GAAG,QAAQ,EAAE,CAAC;IACjD,OAAO,IAAI,CAAC,OAAO,CAAC;IACpB,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,6 @@ import { upCommand } from './commands/up.js';
|
|
|
4
4
|
import { syncCommand } from './commands/sync.js';
|
|
5
5
|
import { doctorCommand } from './commands/doctor.js';
|
|
6
6
|
import { installCommand } from './commands/install.js';
|
|
7
|
-
import { activateCommand } from './commands/activate.js';
|
|
8
7
|
import { decodeCommand } from './commands/decode.js';
|
|
9
8
|
import { loginCommand } from './commands/login.js';
|
|
10
9
|
import { scanCommand } from './commands/scan.js';
|
|
@@ -57,11 +56,6 @@ program
|
|
|
57
56
|
.description('Validate workspace.yaml and check workspace health')
|
|
58
57
|
.option('-c, --config <path>', 'Path to workspace.yaml', '.nepopsx/workspace.yaml')
|
|
59
58
|
.action(doctorCommand);
|
|
60
|
-
program
|
|
61
|
-
.command('activate <key>')
|
|
62
|
-
.description('Activate an NEPOPSX license key for this machine')
|
|
63
|
-
.option('-c, --config <path>', 'Path to workspace.yaml', '.nepopsx/workspace.yaml')
|
|
64
|
-
.action(activateCommand);
|
|
65
59
|
program
|
|
66
60
|
.command('decode <file>')
|
|
67
61
|
.description('Forensic decode — extract fingerprint from a generated file')
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO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wB,CAAC;KAC7C,MAAM,CAAC,mBAAmB,EAAE,sDAAsD,CAAC;KACnF,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;KAC1C,MAAM,CAAC,kBAAkB,EAAE,4DAA4D,CAAC;KACxF,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,EAAE,OAAO,CAAC;KAChE,MAAM,CAAC,yBAAyB,EAAE,qCAAqC,EAAE,OAAO,CAAC;KACjF,MAAM,CAAC,gBAAgB,EAAE,6BAA6B,EAAE,GAAG,CAAC;KAC5D,MAAM,CAAC,WAAW,EAAE,yCAAyC,CAAC;KAC9D,MAAM,CAAC,WAAW,EAAE,wCAAwC,CAAC;KAC7D,MAAM,CAAC,eAAe,EAAE,oCAAoC,CAAC;KAC7D,MAAM,CAAC,kBAAkB,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,EAAE,CAAC;KAClF,MAAM,CAAC,SAAS,EAAE,2DAA2D,CAAC;KAC9E,MAAM,CAAC,gBAAgB,EAAE,qDAAqD,CAAC;KAC/E,MAAM,CAAC,UAAU,EAAE,mEAAmE,CAAC;KACvF,MAAM,CAAC,WAAW,CAAC,CAAC;AAEvB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Short-TTL disk cache for the org's resolved {@link Entitlement}.
|
|
3
|
+
*
|
|
4
|
+
* `validate`/`refresh` populate this; commands read it to display the current plan/limits
|
|
5
|
+
* without a network round-trip per invocation. Keyed by license key, so switching orgs/keys
|
|
6
|
+
* (or re-activating) invalidates automatically. Advisory/display only — never an enforcement
|
|
7
|
+
* authority (the server's 402 is the only hard gate).
|
|
8
|
+
*/
|
|
9
|
+
import type { Entitlement } from '@nepopsx/core';
|
|
10
|
+
/** Return the cached entitlement for `licenseKey`, or `null` on miss/expiry/key-mismatch. */
|
|
11
|
+
export declare function getCachedEntitlement(rootDir: string, licenseKey: string): Entitlement | null;
|
|
12
|
+
/** Cache `entitlement` against `licenseKey`. */
|
|
13
|
+
export declare function setCachedEntitlement(rootDir: string, licenseKey: string, entitlement: Entitlement): void;
|
|
14
|
+
/** Drop the cached entitlement (e.g. on logout / re-activate / org switch). */
|
|
15
|
+
export declare function clearCachedEntitlement(rootDir: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the backend is the entitlement authority for this license — true once a recent
|
|
18
|
+
* `validate`/`refresh` cached a resolved entitlement (a newer backend per ADR 0001).
|
|
19
|
+
*
|
|
20
|
+
* Commands use this to decide between *advisory* warnings (server enforces; let it 402) and
|
|
21
|
+
* the legacy *local* hard-blocks (older backend that does not enforce). This keeps the
|
|
22
|
+
* package-first rollout from regressing limit enforcement before the backend ships its gates.
|
|
23
|
+
*/
|
|
24
|
+
export declare function serverEnforces(rootDir: string, licenseKey: string): boolean;
|
|
25
|
+
//# sourceMappingURL=entitlement-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlement-cache.d.ts","sourceRoot":"","sources":["../../src/licensing/entitlement-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAiBjD,6FAA6F;AAC7F,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAI5F;AAED,gDAAgD;AAChD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAExG;AAED,+EAA+E;AAC/E,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAE3E"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Short-TTL disk cache for the org's resolved {@link Entitlement}.
|
|
3
|
+
*
|
|
4
|
+
* `validate`/`refresh` populate this; commands read it to display the current plan/limits
|
|
5
|
+
* without a network round-trip per invocation. Keyed by license key, so switching orgs/keys
|
|
6
|
+
* (or re-activating) invalidates automatically. Advisory/display only — never an enforcement
|
|
7
|
+
* authority (the server's 402 is the only hard gate).
|
|
8
|
+
*/
|
|
9
|
+
import { readDiskCache, writeDiskCache, clearDiskCache } from '../utils/disk-cache.js';
|
|
10
|
+
const ENTITLEMENT_CACHE_FILE = 'entitlement.json';
|
|
11
|
+
/** TTL mirrors the backend's resolved-entitlement cache; overridable for tests/dev. */
|
|
12
|
+
function ttlMs() {
|
|
13
|
+
const sec = Number(process.env.CLI_ENTITLEMENT_CACHE_TTL_SEC);
|
|
14
|
+
return (Number.isFinite(sec) && sec > 0 ? sec : 90) * 1000;
|
|
15
|
+
}
|
|
16
|
+
/** Return the cached entitlement for `licenseKey`, or `null` on miss/expiry/key-mismatch. */
|
|
17
|
+
export function getCachedEntitlement(rootDir, licenseKey) {
|
|
18
|
+
const cached = readDiskCache(rootDir, ENTITLEMENT_CACHE_FILE);
|
|
19
|
+
if (!cached || cached.key !== licenseKey)
|
|
20
|
+
return null;
|
|
21
|
+
return cached.entitlement;
|
|
22
|
+
}
|
|
23
|
+
/** Cache `entitlement` against `licenseKey`. */
|
|
24
|
+
export function setCachedEntitlement(rootDir, licenseKey, entitlement) {
|
|
25
|
+
writeDiskCache(rootDir, ENTITLEMENT_CACHE_FILE, { key: licenseKey, entitlement }, ttlMs());
|
|
26
|
+
}
|
|
27
|
+
/** Drop the cached entitlement (e.g. on logout / re-activate / org switch). */
|
|
28
|
+
export function clearCachedEntitlement(rootDir) {
|
|
29
|
+
clearDiskCache(rootDir, ENTITLEMENT_CACHE_FILE);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Whether the backend is the entitlement authority for this license — true once a recent
|
|
33
|
+
* `validate`/`refresh` cached a resolved entitlement (a newer backend per ADR 0001).
|
|
34
|
+
*
|
|
35
|
+
* Commands use this to decide between *advisory* warnings (server enforces; let it 402) and
|
|
36
|
+
* the legacy *local* hard-blocks (older backend that does not enforce). This keeps the
|
|
37
|
+
* package-first rollout from regressing limit enforcement before the backend ships its gates.
|
|
38
|
+
*/
|
|
39
|
+
export function serverEnforces(rootDir, licenseKey) {
|
|
40
|
+
return getCachedEntitlement(rootDir, licenseKey) !== null;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=entitlement-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlement-cache.js","sourceRoot":"","sources":["../../src/licensing/entitlement-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEvF,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAElD,uFAAuF;AACvF,SAAS,KAAK;IACZ,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC9D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;AAC7D,CAAC;AAQD,6FAA6F;AAC7F,MAAM,UAAU,oBAAoB,CAAC,OAAe,EAAE,UAAkB;IACtE,MAAM,MAAM,GAAG,aAAa,CAAoB,OAAO,EAAE,sBAAsB,CAAC,CAAC;IACjF,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,GAAG,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IACtD,OAAO,MAAM,CAAC,WAAW,CAAC;AAC5B,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,oBAAoB,CAAC,OAAe,EAAE,UAAkB,EAAE,WAAwB;IAChG,cAAc,CAAoB,OAAO,EAAE,sBAAsB,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAChH,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,cAAc,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,UAAkB;IAChE,OAAO,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;AAC5D,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Licensing barrel — re-export all licensing modules.
|
|
3
3
|
*/
|
|
4
|
-
export { readLicense, writeLicense, reconcileLicenseWorkspace,
|
|
4
|
+
export { readLicense, writeLicense, reconcileLicenseWorkspace, validateLicense, resolveEntitlement, enforceTierLimits, isDevMode, type TierViolation, } from './license-manager.js';
|
|
5
|
+
export { getCachedEntitlement, setCachedEntitlement, clearCachedEntitlement, serverEnforces, } from './entitlement-cache.js';
|
|
5
6
|
export { fetchRemoteTemplates, type TemplateBundle, } from './template-fetch.js';
|
|
6
7
|
export { applySteganography, decodeSteganography, forensicDecode, fingerprintToId, } from './fingerprint.js';
|
|
7
8
|
export { resolveWorkspaceName, readWorkspaceNameFromDisk, UNKNOWN_WORKSPACE, } from './workspace-name.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/licensing/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,WAAW,EACX,YAAY,EACZ,yBAAyB,EACzB,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/licensing/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,WAAW,EACX,YAAY,EACZ,yBAAyB,EACzB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACT,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,GACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC"}
|
package/dist/licensing/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Licensing barrel — re-export all licensing modules.
|
|
3
3
|
*/
|
|
4
|
-
export { readLicense, writeLicense, reconcileLicenseWorkspace,
|
|
4
|
+
export { readLicense, writeLicense, reconcileLicenseWorkspace, validateLicense, resolveEntitlement, enforceTierLimits, isDevMode, } from './license-manager.js';
|
|
5
|
+
export { getCachedEntitlement, setCachedEntitlement, clearCachedEntitlement, serverEnforces, } from './entitlement-cache.js';
|
|
5
6
|
export { fetchRemoteTemplates, } from './template-fetch.js';
|
|
6
7
|
export { applySteganography, decodeSteganography, forensicDecode, fingerprintToId, } from './fingerprint.js';
|
|
7
8
|
export { resolveWorkspaceName, readWorkspaceNameFromDisk, UNKNOWN_WORKSPACE, } from './workspace-name.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/licensing/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,WAAW,EACX,YAAY,EACZ,yBAAyB,EACzB,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/licensing/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,WAAW,EACX,YAAY,EACZ,yBAAyB,EACzB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,GAEV,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,oBAAoB,GAErB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Agent bundle installer — downloads,
|
|
2
|
+
* Agent bundle installer — downloads, decodes, verifies, and writes
|
|
3
3
|
* agent template files from the NEPOPSX API.
|
|
4
4
|
*
|
|
5
5
|
* Flow:
|
|
6
|
-
* 1. downloadBundle — POST /v1/templates/:agent/:version (auth: Bearer <
|
|
7
|
-
* 2. decryptBundle —
|
|
6
|
+
* 1. downloadBundle — POST /v1/templates/:agent/:version (auth: Bearer <device token>)
|
|
7
|
+
* 2. decryptBundle — base64-decode the plaintext payload (served over TLS)
|
|
8
8
|
* 3. verifyBundleSha — SHA-256 of raw JSON must match server-provided sha256
|
|
9
9
|
* 4. writeAgentFiles — atomic write via temp + rename into .github/<relative-path>
|
|
10
10
|
*/
|
|
@@ -12,8 +12,6 @@ import type { License, OutputProvider } from "@nepopsx/core";
|
|
|
12
12
|
import type { CustomInstruction } from "../generator/render.js";
|
|
13
13
|
export interface EncryptedBundle {
|
|
14
14
|
payload: string;
|
|
15
|
-
iv: string;
|
|
16
|
-
tag: string;
|
|
17
15
|
agent: string;
|
|
18
16
|
version: string;
|
|
19
17
|
sha256: string;
|
|
@@ -33,10 +31,11 @@ export interface AgentBootstrapConfig {
|
|
|
33
31
|
export declare function downloadBundle(cwd: string, license: License, agent: string, version: string, customInstructions?: CustomInstruction[], providers?: OutputProvider[]): Promise<EncryptedBundle>;
|
|
34
32
|
export declare function downloadBootstrapConfig(cwd: string, license: License, agent: string, version: string, customInstructions?: CustomInstruction[]): Promise<AgentBootstrapConfig>;
|
|
35
33
|
/**
|
|
36
|
-
*
|
|
37
|
-
* Returns the raw JSON string
|
|
34
|
+
* Decode a bundle payload. The backend now serves plaintext base64 over TLS to an
|
|
35
|
+
* authenticated request (no at-rest encryption). Returns the raw JSON string. The
|
|
36
|
+
* second arg is accepted-and-ignored for call-site compatibility.
|
|
38
37
|
*/
|
|
39
|
-
export declare function decryptBundle(bundle: EncryptedBundle,
|
|
38
|
+
export declare function decryptBundle(bundle: EncryptedBundle, _credential?: string): string;
|
|
40
39
|
/**
|
|
41
40
|
* Verify that the decrypted JSON matches the server's sha256.
|
|
42
41
|
* Throws if the digest does not match.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../src/licensing/installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAIhE,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../src/licensing/installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAIhE,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAID;;GAEG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,kBAAkB,GAAE,iBAAiB,EAAO,EAC5C,SAAS,GAAE,cAAc,EAAO,GAC/B,OAAO,CAAC,eAAe,CAAC,CA2B1B;AAED,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,kBAAkB,GAAE,iBAAiB,EAAO,GAC3C,OAAO,CAAC,oBAAoB,CAAC,CA6B/B;AAID;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnF;AAID;;;GAGG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAOhF;AAID;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,aAAa,EAAE,CAmBjB"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Agent bundle installer — downloads,
|
|
2
|
+
* Agent bundle installer — downloads, decodes, verifies, and writes
|
|
3
3
|
* agent template files from the NEPOPSX API.
|
|
4
4
|
*
|
|
5
5
|
* Flow:
|
|
6
|
-
* 1. downloadBundle — POST /v1/templates/:agent/:version (auth: Bearer <
|
|
7
|
-
* 2. decryptBundle —
|
|
6
|
+
* 1. downloadBundle — POST /v1/templates/:agent/:version (auth: Bearer <device token>)
|
|
7
|
+
* 2. decryptBundle — base64-decode the plaintext payload (served over TLS)
|
|
8
8
|
* 3. verifyBundleSha — SHA-256 of raw JSON must match server-provided sha256
|
|
9
9
|
* 4. writeAgentFiles — atomic write via temp + rename into .github/<relative-path>
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import { createHash } from "node:crypto";
|
|
12
12
|
import { existsSync, mkdirSync, renameSync, writeFileSync } from "node:fs";
|
|
13
13
|
import { dirname, join } from "node:path";
|
|
14
14
|
import { resolveApiBase } from "../config/api-config.js";
|
|
@@ -65,20 +65,12 @@ export async function downloadBootstrapConfig(cwd, license, agent, version, cust
|
|
|
65
65
|
}
|
|
66
66
|
// ─── Decrypt ────────────────────────────────────────────────
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
69
|
-
* Returns the raw JSON string
|
|
68
|
+
* Decode a bundle payload. The backend now serves plaintext base64 over TLS to an
|
|
69
|
+
* authenticated request (no at-rest encryption). Returns the raw JSON string. The
|
|
70
|
+
* second arg is accepted-and-ignored for call-site compatibility.
|
|
70
71
|
*/
|
|
71
|
-
export function decryptBundle(bundle,
|
|
72
|
-
|
|
73
|
-
.update(`${licenseKey}:nepopsx-template-key`)
|
|
74
|
-
.digest();
|
|
75
|
-
const iv = Buffer.from(bundle.iv, "base64");
|
|
76
|
-
const tag = Buffer.from(bundle.tag, "base64");
|
|
77
|
-
const encrypted = Buffer.from(bundle.payload, "base64");
|
|
78
|
-
const decipher = createDecipheriv("aes-256-gcm", key, iv);
|
|
79
|
-
decipher.setAuthTag(tag);
|
|
80
|
-
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
|
|
81
|
-
return decrypted.toString("utf-8");
|
|
72
|
+
export function decryptBundle(bundle, _credential) {
|
|
73
|
+
return Buffer.from(bundle.payload, "base64").toString("utf-8");
|
|
82
74
|
}
|
|
83
75
|
// ─── Verify ─────────────────────────────────────────────────
|
|
84
76
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../../src/licensing/installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../../src/licensing/installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAuB3D,+DAA+D;AAE/D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAW,EACX,OAAgB,EAChB,KAAa,EACb,OAAe,EACf,qBAA0C,EAAE,EAC5C,YAA8B,EAAE;IAEhC,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,GAAG,GAAG,GAAG,OAAO,cAAc,kBAAkB,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;IAE/F,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,GAAG,EAAE;QAC3C,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,OAAO,CAAC,GAAG,EAAE;YACtC,cAAc,EAAE,kBAAkB;SACnC;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AAC,CAAC;QAC9B,MAAM,GAAG,GAAG,GAAG,IAAI,MAAM,CAAC;QAE1B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACzB,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1C,CAAC;QAED,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACrC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAEtB,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,42 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Auth/session helpers. Post-migration the CLI has ONE credential: the opaque
|
|
3
|
+
* device token from `nepopsx login`, stored in `.nepopsx/config.json`. The
|
|
4
|
+
* `License` shape is kept as a thin compatibility view — `.key` IS the device
|
|
5
|
+
* token — so existing commands send the right Bearer credential unchanged. Auth
|
|
6
|
+
* and entitlement are server-authoritative now (the backend 401/402s); there is
|
|
7
|
+
* no license.json, no machine binding, and no online validate/refresh.
|
|
4
8
|
*/
|
|
5
|
-
import { type License, type LicenseStatus, type LicenseTier, type WorkspaceConfig } from '@nepopsx/core';
|
|
9
|
+
import { type License, type LicenseStatus, type LicenseTier, type WorkspaceConfig, type Entitlement } from '@nepopsx/core';
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
11
|
+
* Build a `License`-shaped view from the stored device token. `.key` IS the opaque
|
|
12
|
+
* `opsx_dvc_…` token sent as a Bearer credential; `org`/`tier` come from the plan
|
|
13
|
+
* captured at login; `workspace` is the live local name. Returns null if not
|
|
14
|
+
* logged in. (No license.json — the device token in config.json is the credential.)
|
|
8
15
|
*/
|
|
9
16
|
export declare function readLicense(rootDir: string): License | null;
|
|
17
|
+
/** No-op: the workspace is sourced live from disk in `readLicense` now. */
|
|
18
|
+
export declare function reconcileLicenseWorkspace<T extends License | null>(_rootDir: string, license: T): T;
|
|
19
|
+
/** No-op kept for callers: there is no license.json to write any more. */
|
|
20
|
+
export declare function writeLicense(_rootDir: string, _license: License): void;
|
|
10
21
|
/**
|
|
11
|
-
*
|
|
22
|
+
* Confirm a device token is present. Auth + entitlement are enforced by the
|
|
23
|
+
* backend (401/402) — this no longer calls the server.
|
|
12
24
|
*/
|
|
13
|
-
export declare function
|
|
25
|
+
export declare function validateLicense(rootDir: string, _config: WorkspaceConfig): Promise<LicenseStatus>;
|
|
14
26
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* `workspace: "unknown"`. Once the real config exists, reconcile the in-memory
|
|
19
|
-
* license (and persist it) so every downstream `license.workspace` read — and
|
|
20
|
-
* every backend call derived from it — uses the live workspace name instead of
|
|
21
|
-
* the stale snapshot. Best-effort: returns the license unchanged when the config
|
|
22
|
-
* is absent or already matches. Accepts/returns `null` for the no-license path.
|
|
27
|
+
* Resolve the org's entitlement for DISPLAY: cache → synthesized from the plan
|
|
28
|
+
* manifest + the session's plan. Advisory only — the backend's 402s are the hard
|
|
29
|
+
* authority. Never throws.
|
|
23
30
|
*/
|
|
24
|
-
export declare function
|
|
25
|
-
export interface ActivationResult {
|
|
26
|
-
success: boolean;
|
|
27
|
-
license?: License;
|
|
28
|
-
error?: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Activate a license key for this machine + workspace.
|
|
32
|
-
* Calls the remote API to validate the key and bind it.
|
|
33
|
-
*/
|
|
34
|
-
export declare function activateLicense(rootDir: string, licenseKey: string, workspaceName: string): Promise<ActivationResult>;
|
|
35
|
-
/**
|
|
36
|
-
* Validate the current license. Attempts online refresh if expired.
|
|
37
|
-
* Returns detailed status.
|
|
38
|
-
*/
|
|
39
|
-
export declare function validateLicense(rootDir: string, config: WorkspaceConfig): Promise<LicenseStatus>;
|
|
31
|
+
export declare function resolveEntitlement(rootDir: string, license: License): Promise<Entitlement>;
|
|
40
32
|
export interface TierViolation {
|
|
41
33
|
feature: string;
|
|
42
34
|
limit: string;
|
|
@@ -44,18 +36,11 @@ export interface TierViolation {
|
|
|
44
36
|
required_tier: LicenseTier;
|
|
45
37
|
}
|
|
46
38
|
/**
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* Only scale limits are enforced here — agent quality (customs, philosophy,
|
|
51
|
-
* prompts) is identical across all tiers. The differentiators are:
|
|
52
|
-
* - how many services / agent packages are allowed
|
|
53
|
-
* - access to LLM-powered scan (team+)
|
|
39
|
+
* Check whether the workspace config exceeds the tier's scale limits.
|
|
40
|
+
* **Advisory only** — the server is the enforcement authority (402). Surface as a
|
|
41
|
+
* warning + upgrade hint and proceed; never hard-block on this result.
|
|
54
42
|
*/
|
|
55
43
|
export declare function enforceTierLimits(config: WorkspaceConfig, tier: LicenseTier): TierViolation[];
|
|
56
|
-
/**
|
|
57
|
-
* Check if the CLI is running in dev mode (for NEPOPSX agent developers).
|
|
58
|
-
* Set NEPOPSX_DEV=1 to bypass license checks.
|
|
59
|
-
*/
|
|
44
|
+
/** Set NEPOPSX_DEV=1 to bypass auth checks (for NEPOPSX agent developers). */
|
|
60
45
|
export declare function isDevMode(): boolean;
|
|
61
46
|
//# sourceMappingURL=license-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"license-manager.d.ts","sourceRoot":"","sources":["../../src/licensing/license-manager.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"license-manager.d.ts","sourceRoot":"","sources":["../../src/licensing/license-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,WAAW,EAIjB,MAAM,eAAe,CAAC;AAQvB;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAc3D;AAED,2EAA2E;AAC3E,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,OAAO,GAAG,IAAI,EAChE,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,GACT,CAAC,CAEH;AAED,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAEtE;AAID;;;GAGG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,aAAa,CAAC,CA0BxB;AAID;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,WAAW,CAAC,CActB;AAID,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,WAAW,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,WAAW,GAChB,aAAa,EAAE,CA4BjB;AAID,8EAA8E;AAC9E,wBAAgB,SAAS,IAAI,OAAO,CAEnC"}
|