@invictus-group-ai/orchestra 0.5.1 → 0.7.1

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.
Files changed (65) hide show
  1. package/content-dist/README.md +1 -1
  2. package/content-dist/agents/README.md +3 -2
  3. package/content-dist/fragments/base.md +5 -4
  4. package/content-dist/fragments/index.json +3 -3
  5. package/content-dist/skills/fast-po/SKILL.md +145 -0
  6. package/content-dist/skills/fast-req/SKILL.md +129 -0
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +55 -6
  9. package/dist/cli.js.map +1 -1
  10. package/dist/commands/keys.d.ts +63 -15
  11. package/dist/commands/keys.d.ts.map +1 -1
  12. package/dist/commands/keys.js +209 -41
  13. package/dist/commands/keys.js.map +1 -1
  14. package/dist/commands/keysStatus.d.ts +69 -0
  15. package/dist/commands/keysStatus.d.ts.map +1 -0
  16. package/dist/commands/keysStatus.js +156 -0
  17. package/dist/commands/keysStatus.js.map +1 -0
  18. package/dist/commands/reqPull.d.ts +61 -0
  19. package/dist/commands/reqPull.d.ts.map +1 -0
  20. package/dist/commands/reqPull.js +165 -0
  21. package/dist/commands/reqPull.js.map +1 -0
  22. package/dist/commands/reqShare.d.ts +33 -0
  23. package/dist/commands/reqShare.d.ts.map +1 -0
  24. package/dist/commands/reqShare.js +53 -0
  25. package/dist/commands/reqShare.js.map +1 -0
  26. package/dist/commands/sync.d.ts +13 -0
  27. package/dist/commands/sync.d.ts.map +1 -1
  28. package/dist/commands/sync.js +64 -4
  29. package/dist/commands/sync.js.map +1 -1
  30. package/dist/commands/syncCommits.d.ts +1 -11
  31. package/dist/commands/syncCommits.d.ts.map +1 -1
  32. package/dist/commands/syncContext.d.ts +67 -0
  33. package/dist/commands/syncContext.d.ts.map +1 -0
  34. package/dist/commands/syncContext.js +135 -0
  35. package/dist/commands/syncContext.js.map +1 -0
  36. package/dist/content.d.ts +10 -72
  37. package/dist/content.d.ts.map +1 -1
  38. package/dist/credentials.d.ts +102 -0
  39. package/dist/credentials.d.ts.map +1 -0
  40. package/dist/credentials.js +203 -0
  41. package/dist/credentials.js.map +1 -0
  42. package/dist/i18n/en.d.ts +50 -0
  43. package/dist/i18n/en.d.ts.map +1 -1
  44. package/dist/i18n/en.js +51 -0
  45. package/dist/i18n/en.js.map +1 -1
  46. package/dist/i18n/pt-BR.d.ts.map +1 -1
  47. package/dist/i18n/pt-BR.js +51 -0
  48. package/dist/i18n/pt-BR.js.map +1 -1
  49. package/dist/identity.d.ts +27 -3
  50. package/dist/identity.d.ts.map +1 -1
  51. package/dist/identity.js +45 -9
  52. package/dist/identity.js.map +1 -1
  53. package/dist/index.d.ts +4 -0
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +2 -0
  56. package/dist/index.js.map +1 -1
  57. package/dist/inventory.d.ts +11 -43
  58. package/dist/inventory.d.ts.map +1 -1
  59. package/dist/render/agents.d.ts +34 -160
  60. package/dist/render/agents.d.ts.map +1 -1
  61. package/dist/render/transparency.js +26 -2
  62. package/dist/render/transparency.js.map +1 -1
  63. package/dist/tasks.d.ts +35 -60
  64. package/dist/tasks.d.ts.map +1 -1
  65. package/package.json +4 -4
@@ -2,15 +2,46 @@
2
2
  * `invi keys provision` — kit-side counterpart of the platform auth model
3
3
  * (docs/PLATFORM-API.md):
4
4
  *
5
+ * invi keys provision --code <enr_…> --platform-url <url> [--rederive]
5
6
  * invi keys provision --client <id> --master-key <hex> --platform-url <url> [--rederive]
7
+ * invi keys provision --client <id> (second repository: no network)
6
8
  *
7
- * Writes, under the gitignored `.invictus/local/` only:
8
- * - `client.json` → `{ "clientId": "...", "platformUrl": "..." }`
9
- * - `dev.key` → hex of `deriveDevHmacKey(masterKey, devId)` for the
10
- * current git identity's devId (the sync bearer key)
11
- * - `salt` → the CLIENT-STABLE salt `deriveClientSalt(masterKey)`
12
- * (PLATFORM-API "stable dev IDs"), so the same git email
13
- * derives the same devId on every provisioned machine
9
+ * THREE WAYS IN, and the third one is why a one-time code stopped being a
10
+ * problem. The credentials are per developer per CLIENT, not per repository
11
+ * (see `../credentials.ts`), so the second, third and tenth repository of a
12
+ * client this machine already enrolled in need no code and no call: they read
13
+ * what the first enrolment stored and write only the repo pointer.
14
+ *
15
+ * The same rule protects the code when someone pastes it again out of habit:
16
+ * `/v1/enroll` opens the envelope without spending anything, and the bind call
17
+ * — the one that burns the code — is skipped entirely when the store already
18
+ * holds a key for the devId this repository resolves.
19
+ *
20
+ * TWO WAYS IN, and the first one is why this file changed. Handing a developer
21
+ * the master key hands them the value that derives EVERY dev key of that
22
+ * client: one leak is total, and rotating it invalidates the signatures of
23
+ * every event already sent. An enrolment code (`enr_<32 hex>`, minted in the
24
+ * panel for one seat, single-use, expiring) buys exactly one dev key for one
25
+ * seat, and revoking that seat closes it. The master key never leaves the
26
+ * platform.
27
+ *
28
+ * Both paths converge immediately: everything below — the version-control
29
+ * refusals, the legacy-devId rule, the manifest bookkeeping — runs the same
30
+ * either way, because the only thing that differs is WHERE the client salt and
31
+ * the dev key come from (see `Credentials`).
32
+ *
33
+ * Writes, in two places with two different jobs:
34
+ * - user store, `~/.config/invictus/clients/<clientId>.json` (0600): the
35
+ * client-stable salt `deriveClientSalt(masterKey)` (PLATFORM-API "stable
36
+ * dev IDs") and `deriveDevHmacKey(masterKey, devId)` under its devId —
37
+ * the two secrets, once per developer;
38
+ * - repository, gitignored `.invictus/local/client.json`: `{ clientId,
39
+ * platformUrl }`, the pointer saying which client this checkout belongs
40
+ * to. Neither value is a secret.
41
+ *
42
+ * Nothing secret is written into the repository any more. A machine
43
+ * provisioned by an older kit keeps working untouched: `invi sync` still reads
44
+ * `.invictus/local/dev.key` when the store has nothing to say.
14
45
  *
15
46
  * STABLE vs LEGACY devIds: when this machine already resolves a devId minted
16
47
  * from a pre-provision machine-local random salt, provision KEEPS it by
@@ -24,10 +55,11 @@
24
55
  * the platform treats devIds as opaque, so both simply coexist.
25
56
  *
26
57
  * The master key itself is NEVER persisted (nor echoed back): only values
27
- * derived from it (dev key, client salt) land on disk, all under the
28
- * gitignored `.invictus/local/`. The command refuses to write when the
29
- * destination could end up under version control — `.invictus/local/` must
30
- * be gitignored and must contain no already-tracked file.
58
+ * derived from it (dev key, client salt) land on disk. The command still
59
+ * refuses to write when the repository pointer could end up under version
60
+ * control — `.invictus/local/` must be gitignored and must contain no
61
+ * already-tracked file — because that check is also what protects the salt and
62
+ * key files an older kit already left there.
31
63
  */
32
64
  import type { Reporter } from '../util/out.js';
33
65
  export declare const CLIENT_JSON_REL = ".invictus/local/client.json";
@@ -35,25 +67,41 @@ export declare const DEV_KEY_REL = ".invictus/local/dev.key";
35
67
  export declare const SALT_REL = ".invictus/local/salt";
36
68
  export declare const DEV_JSON_REL = ".invictus/local/dev.json";
37
69
  export declare const MANIFEST_REL = ".invictus/manifest.json";
70
+ /** Same seam `invi sync` uses, so tests never touch a socket. */
71
+ export type ProvisionFetch = (url: string, init: RequestInit) => Promise<Response>;
38
72
  export interface KeysProvisionOptions {
39
73
  dir?: string;
40
74
  json?: boolean;
41
75
  /** Render-language override (flag > manifest.language.render > pt-BR). */
42
76
  lang?: string;
43
- client: string;
44
- masterKey: string;
45
- platformUrl: string;
77
+ /** Enrolment code from the panel. Replaces `client` + `masterKey`. */
78
+ code?: string;
79
+ client?: string;
80
+ masterKey?: string;
81
+ /** Required for the two network paths; defaulted from the store when linking. */
82
+ platformUrl?: string;
46
83
  /** Switch a legacy (machine-local-salt) devId to the client-stable one. */
47
84
  rederive?: boolean;
48
85
  reporter?: Reporter;
49
86
  env?: NodeJS.ProcessEnv;
50
87
  /** Test seam: git identity email. */
51
88
  gitEmail?: string;
89
+ /** Test seam: HTTP. */
90
+ fetchImpl?: ProvisionFetch;
52
91
  }
53
92
  export interface KeysProvisionResult {
54
93
  clientId: string;
55
94
  platformUrl: string;
56
95
  devId: string;
96
+ /**
97
+ * How the credentials were obtained: the panel, a master key in hand, or
98
+ * what this machine already stored for that client (no network at all).
99
+ */
100
+ via: 'enrolment-code' | 'master-key' | 'stored';
101
+ /** True when an enrolment code was presented and deliberately NOT spent. */
102
+ codeKept: boolean;
103
+ /** Absolute path of the user-store file the secrets went to. */
104
+ storePath: string;
57
105
  /** True when the resolved devId derives from the client-stable salt. */
58
106
  saltStable: boolean;
59
107
  /** True when --rederive replaced a legacy devId this run. */
@@ -64,5 +112,5 @@ export interface KeysProvisionResult {
64
112
  wrote: string[];
65
113
  gitignoreUpdated: boolean;
66
114
  }
67
- export declare function runKeysProvision(options: KeysProvisionOptions): KeysProvisionResult;
115
+ export declare function runKeysProvision(options: KeysProvisionOptions): Promise<KeysProvisionResult>;
68
116
  //# sourceMappingURL=keys.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/commands/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAmBH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,eAAO,MAAM,eAAe,gCAAgC,CAAC;AAC7D,eAAO,MAAM,WAAW,4BAA4B,CAAC;AACrD,eAAO,MAAM,QAAQ,yBAAyB,CAAC;AAC/C,eAAO,MAAM,YAAY,6BAA6B,CAAC;AACvD,eAAO,MAAM,YAAY,4BAA4B,CAAC;AAOtD,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAA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,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uBAAuB;IACvB,SAAS,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,GAAG,EAAE,gBAAgB,GAAG,YAAY,GAAG,QAAQ,CAAC;IAChD,4EAA4E;IAC5E,QAAQ,EAAE,OAAO,CAAC;IAClB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,UAAU,EAAE,OAAO,CAAC;IACpB,6DAA6D;IAC7D,SAAS,EAAE,OAAO,CAAC;IACnB,uEAAuE;IACvE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mEAAmE;IACnE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAuLD,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA2LlG"}
@@ -2,15 +2,46 @@
2
2
  * `invi keys provision` — kit-side counterpart of the platform auth model
3
3
  * (docs/PLATFORM-API.md):
4
4
  *
5
+ * invi keys provision --code <enr_…> --platform-url <url> [--rederive]
5
6
  * invi keys provision --client <id> --master-key <hex> --platform-url <url> [--rederive]
7
+ * invi keys provision --client <id> (second repository: no network)
6
8
  *
7
- * Writes, under the gitignored `.invictus/local/` only:
8
- * - `client.json` → `{ "clientId": "...", "platformUrl": "..." }`
9
- * - `dev.key` → hex of `deriveDevHmacKey(masterKey, devId)` for the
10
- * current git identity's devId (the sync bearer key)
11
- * - `salt` → the CLIENT-STABLE salt `deriveClientSalt(masterKey)`
12
- * (PLATFORM-API "stable dev IDs"), so the same git email
13
- * derives the same devId on every provisioned machine
9
+ * THREE WAYS IN, and the third one is why a one-time code stopped being a
10
+ * problem. The credentials are per developer per CLIENT, not per repository
11
+ * (see `../credentials.ts`), so the second, third and tenth repository of a
12
+ * client this machine already enrolled in need no code and no call: they read
13
+ * what the first enrolment stored and write only the repo pointer.
14
+ *
15
+ * The same rule protects the code when someone pastes it again out of habit:
16
+ * `/v1/enroll` opens the envelope without spending anything, and the bind call
17
+ * — the one that burns the code — is skipped entirely when the store already
18
+ * holds a key for the devId this repository resolves.
19
+ *
20
+ * TWO WAYS IN, and the first one is why this file changed. Handing a developer
21
+ * the master key hands them the value that derives EVERY dev key of that
22
+ * client: one leak is total, and rotating it invalidates the signatures of
23
+ * every event already sent. An enrolment code (`enr_<32 hex>`, minted in the
24
+ * panel for one seat, single-use, expiring) buys exactly one dev key for one
25
+ * seat, and revoking that seat closes it. The master key never leaves the
26
+ * platform.
27
+ *
28
+ * Both paths converge immediately: everything below — the version-control
29
+ * refusals, the legacy-devId rule, the manifest bookkeeping — runs the same
30
+ * either way, because the only thing that differs is WHERE the client salt and
31
+ * the dev key come from (see `Credentials`).
32
+ *
33
+ * Writes, in two places with two different jobs:
34
+ * - user store, `~/.config/invictus/clients/<clientId>.json` (0600): the
35
+ * client-stable salt `deriveClientSalt(masterKey)` (PLATFORM-API "stable
36
+ * dev IDs") and `deriveDevHmacKey(masterKey, devId)` under its devId —
37
+ * the two secrets, once per developer;
38
+ * - repository, gitignored `.invictus/local/client.json`: `{ clientId,
39
+ * platformUrl }`, the pointer saying which client this checkout belongs
40
+ * to. Neither value is a secret.
41
+ *
42
+ * Nothing secret is written into the repository any more. A machine
43
+ * provisioned by an older kit keeps working untouched: `invi sync` still reads
44
+ * `.invictus/local/dev.key` when the store has nothing to say.
14
45
  *
15
46
  * STABLE vs LEGACY devIds: when this machine already resolves a devId minted
16
47
  * from a pre-provision machine-local random salt, provision KEEPS it by
@@ -24,15 +55,17 @@
24
55
  * the platform treats devIds as opaque, so both simply coexist.
25
56
  *
26
57
  * The master key itself is NEVER persisted (nor echoed back): only values
27
- * derived from it (dev key, client salt) land on disk, all under the
28
- * gitignored `.invictus/local/`. The command refuses to write when the
29
- * destination could end up under version control — `.invictus/local/` must
30
- * be gitignored and must contain no already-tracked file.
58
+ * derived from it (dev key, client salt) land on disk. The command still
59
+ * refuses to write when the repository pointer could end up under version
60
+ * control — `.invictus/local/` must be gitignored and must contain no
61
+ * already-tracked file — because that check is also what protects the salt and
62
+ * key files an older kit already left there.
31
63
  */
32
64
  import { join, resolve } from 'node:path';
33
65
  import { execFileSync } from 'node:child_process';
34
66
  import { deriveClientSalt, deriveDevHmacKey, deriveDevId, hashGitEmail, isDevId, readManifest, writeManifest } from '@invictus-group-ai/core';
35
- import { ensureLocalGitignored, stateRepo, gitUserEmail, localDir, readSalt, resolveLocalDevId, writeSalt, } from '../identity.js';
67
+ import { ensureLocalGitignored, stateRepo, gitUserEmail, localDir, readSalt, resolveLocalDevId, resolveSalt, writeSalt, } from '../identity.js';
68
+ import { readClientCredentials, rememberDevKey, storedDevKey } from '../credentials.js';
36
69
  import { translatorFor } from '../i18n/index.js';
37
70
  import { isFile, writeFileEnsuring } from '../util/fsx.js';
38
71
  import { makeLocalizedReporter } from '../util/out.js';
@@ -45,6 +78,11 @@ export const MANIFEST_REL = '.invictus/manifest.json';
45
78
  const CLIENT_ID_RE = /^[a-z0-9_-]{1,32}$/;
46
79
  /** 32-byte master key, hex — exactly what POST /v1/clients returns. */
47
80
  const MASTER_KEY_RE = /^[0-9a-f]{64}$/i;
81
+ /** Enrolment code minted by the panel for one seat. */
82
+ const ENROL_CODE_RE = /^enr_[0-9a-f]{32}$/i;
83
+ /** The client salt the panel hands back: HKDF output, 32 bytes, hex. */
84
+ const CLIENT_SALT_RE = /^[0-9a-f]{64}$/i;
85
+ const defaultFetch = (url, init) => fetch(url, { ...init, signal: AbortSignal.timeout(15_000) });
48
86
  function gitLines(root, args) {
49
87
  try {
50
88
  return execFileSync('git', args, { cwd: root, stdio: 'pipe' })
@@ -115,33 +153,145 @@ function registerDevInManifest(root, devId, gitEmailHash) {
115
153
  writeManifest(root, { ...manifest, devs });
116
154
  return true;
117
155
  }
118
- export function runKeysProvision(options) {
156
+ /** POST JSON, and never let a failure echo the secret that was in the body. */
157
+ async function postJson(fetchImpl, url, body, t) {
158
+ let response;
159
+ try {
160
+ response = await fetchImpl(url, {
161
+ method: 'POST',
162
+ headers: { 'content-type': 'application/json' },
163
+ body: JSON.stringify(body),
164
+ });
165
+ }
166
+ catch (error) {
167
+ // The message carries the URL, never the payload: the payload is the code.
168
+ throw new Error(t('keys.err.unreachable', { url, reason: error instanceof Error ? error.message : String(error) }));
169
+ }
170
+ if (response.status === 401)
171
+ throw new Error(t('keys.err.codeRejected'));
172
+ if (response.status === 409)
173
+ throw new Error(t('keys.err.seatTaken'));
174
+ if (!response.ok) {
175
+ throw new Error(t('keys.err.enrolFailed', { status: String(response.status) }));
176
+ }
177
+ return (await response.json());
178
+ }
179
+ /** Exchange an enrolment code: the panel keeps the master key, we get one dev key. */
180
+ function enrolmentCredentials(code, platformUrl, fetchImpl, t) {
181
+ return async () => {
182
+ const opened = await postJson(fetchImpl, `${platformUrl}/v1/enroll`, { code }, t);
183
+ const clientId = typeof opened['clientId'] === 'string' ? opened['clientId'] : '';
184
+ const stableSalt = typeof opened['clientSalt'] === 'string' ? opened['clientSalt'].toLowerCase() : '';
185
+ if (!CLIENT_ID_RE.test(clientId) || !CLIENT_SALT_RE.test(stableSalt)) {
186
+ throw new Error(t('keys.err.enrolShape'));
187
+ }
188
+ return {
189
+ via: 'enrolment-code',
190
+ clientId,
191
+ stableSalt,
192
+ devKey: async (devId) => {
193
+ const bound = await postJson(fetchImpl, `${platformUrl}/v1/enroll/bind`, { code, devId }, t);
194
+ const devKey = typeof bound['devKey'] === 'string' ? bound['devKey'].toLowerCase() : '';
195
+ if (!MASTER_KEY_RE.test(devKey))
196
+ throw new Error(t('keys.err.enrolShape'));
197
+ return devKey;
198
+ },
199
+ };
200
+ };
201
+ }
202
+ /** The owner's own path: the master key is used here and then dropped. */
203
+ function masterKeyCredentials(clientId, masterKey) {
204
+ return async () => ({
205
+ via: 'master-key',
206
+ clientId,
207
+ stableSalt: deriveClientSalt(masterKey),
208
+ devKey: async (devId) => deriveDevHmacKey(masterKey, devId).toString('hex'),
209
+ });
210
+ }
211
+ /**
212
+ * The second repository: everything already sits in the user store.
213
+ *
214
+ * No code, no master key, no request — which is the point. A developer who
215
+ * enrolled once can bring the kit up in every other checkout of that client
216
+ * offline, and a one-time code stays one time.
217
+ */
218
+ function storedCredentials(clientId, env, t) {
219
+ return async () => {
220
+ const stored = readClientCredentials(clientId, env);
221
+ if (stored === null)
222
+ throw new Error(t('keys.err.noStored', { client: clientId }));
223
+ return {
224
+ via: 'stored',
225
+ clientId,
226
+ stableSalt: stored.salt,
227
+ devKey: async (devId) => {
228
+ const key = stored.keys[devId];
229
+ if (key === undefined)
230
+ throw new Error(t('keys.err.noStoredKey', { client: clientId, dev: devId }));
231
+ return key;
232
+ },
233
+ };
234
+ };
235
+ }
236
+ export async function runKeysProvision(options) {
119
237
  const root = resolve(options.dir ?? process.cwd());
120
238
  const t = translatorFor(root, options.lang);
121
239
  const out = options.reporter ?? makeLocalizedReporter(options.json ?? false, t);
122
240
  const env = options.env ?? process.env;
123
- const clientId = options.client.trim();
124
- if (!CLIENT_ID_RE.test(clientId)) {
125
- throw new Error(t('keys.err.clientId', { re: String(CLIENT_ID_RE), value: JSON.stringify(clientId) }));
241
+ // One way in, never two: a command that accepted both a code and a master
242
+ // key would leave "which one won?" to the reader of the flags.
243
+ const code = options.code?.trim() ?? '';
244
+ const hasCode = code !== '';
245
+ const clientFlag = (options.client ?? '').trim();
246
+ const masterFlag = (options.masterKey ?? '').trim();
247
+ const hasMaster = masterFlag !== '';
248
+ // --client alone is the third way: link this repository to credentials this
249
+ // machine already holds.
250
+ const hasLink = !hasCode && !hasMaster && clientFlag !== '';
251
+ if (hasCode && (hasMaster || clientFlag !== ''))
252
+ throw new Error(t('keys.err.bothWays'));
253
+ if (!hasCode && !hasMaster && !hasLink)
254
+ throw new Error(t('keys.err.neitherWay'));
255
+ if (hasMaster || hasLink) {
256
+ if (!CLIENT_ID_RE.test(clientFlag)) {
257
+ throw new Error(t('keys.err.clientId', { re: String(CLIENT_ID_RE), value: JSON.stringify(clientFlag) }));
258
+ }
126
259
  }
127
- const masterKey = options.masterKey.trim().toLowerCase();
128
- if (!MASTER_KEY_RE.test(masterKey)) {
260
+ if (hasCode && !ENROL_CODE_RE.test(code))
261
+ throw new Error(t('keys.err.code'));
262
+ if (hasMaster && !MASTER_KEY_RE.test(masterFlag.toLowerCase())) {
129
263
  throw new Error(t('keys.err.masterKey'));
130
264
  }
265
+ // The URL: required on the two network paths, defaulted from the store when
266
+ // linking — a developer linking their fourth repository should not have to
267
+ // remember a hostname the store already knows.
268
+ const urlFlag = options.platformUrl?.trim() ?? '';
269
+ const urlSource = urlFlag !== '' ? urlFlag : hasLink ? (readClientCredentials(clientFlag, env)?.platformUrl ?? '') : '';
270
+ if (urlSource === '') {
271
+ throw new Error(hasLink ? t('keys.err.noStored', { client: clientFlag }) : t('keys.err.platformUrlMissing'));
272
+ }
131
273
  let platformUrl;
132
274
  try {
133
- const parsed = new URL(options.platformUrl.trim());
275
+ const parsed = new URL(urlSource);
134
276
  if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
135
277
  throw new Error('unsupported protocol');
136
278
  }
137
279
  platformUrl = parsed.toString().replace(/\/+$/, '');
138
280
  }
139
281
  catch {
140
- throw new Error(t('keys.err.platformUrl', { value: JSON.stringify(options.platformUrl) }));
282
+ throw new Error(t('keys.err.platformUrl', { value: JSON.stringify(urlSource) }));
141
283
  }
142
- // Never let the destination be version-controlled.
284
+ const openCredentials = hasCode
285
+ ? enrolmentCredentials(code, platformUrl, options.fetchImpl ?? defaultFetch, t)
286
+ : hasMaster
287
+ ? masterKeyCredentials(clientFlag, masterFlag.toLowerCase())
288
+ : storedCredentials(clientFlag, env, t);
289
+ // Never let the destination be version-controlled. Checked BEFORE the code is
290
+ // spent: a refusal here must not cost the developer their one-time code.
143
291
  const gitignoreUpdated = ensureLocalGitignored(root);
144
292
  assertNotVersionControlled(root, out, t);
293
+ const credentials = await openCredentials();
294
+ const clientId = credentials.clientId;
145
295
  // Current git identity → pseudonymous devId (same resolution as the hooks),
146
296
  // plus the CLIENT-STABLE candidate derived from the master key. The raw
147
297
  // value keeps '' distinct (explicit "no email" test seam — it must NOT
@@ -152,7 +302,7 @@ export function runKeysProvision(options) {
152
302
  // stable salt replaces on fresh machines).
153
303
  const existingDevId = resolveLocalDevId(root, env, rawEmail, { createSalt: false });
154
304
  const gitEmail = rawEmail || undefined;
155
- const stableSalt = deriveClientSalt(masterKey);
305
+ const stableSalt = credentials.stableSalt;
156
306
  const stableDevId = gitEmail ? deriveDevId(stableSalt, gitEmail) : null;
157
307
  const wrote = [];
158
308
  let devId;
@@ -160,25 +310,20 @@ export function runKeysProvision(options) {
160
310
  let rederived = false;
161
311
  let previousDevId = null;
162
312
  if (existingDevId === null) {
163
- // Fresh machine, no identity yet — start directly on the stable salt.
313
+ // Fresh machine, no identity yet — start directly on the stable salt,
314
+ // which now lives in the user store rather than in this checkout.
164
315
  if (stableDevId === null)
165
316
  throw new Error(t('keys.err.noDevId'));
166
- writeSalt(root, stableSalt);
167
- wrote.push(SALT_REL);
168
317
  devId = stableDevId;
169
318
  saltStable = true;
170
319
  out.info(t('keys.saltStable'));
171
320
  }
172
321
  else if (stableDevId !== null && existingDevId === stableDevId) {
173
- // Already on the stable identity — make sure the salt file agrees
174
- // (resolution may have come from the manifest while the file was lost).
322
+ // Already on the stable identity: nothing to reconcile. The store write
323
+ // below carries the salt, so a lost repo-local copy is no longer a case
324
+ // that needs repairing here.
175
325
  devId = existingDevId;
176
326
  saltStable = true;
177
- if (readSalt(root) !== stableSalt) {
178
- writeSalt(root, stableSalt);
179
- wrote.push(SALT_REL);
180
- out.info(t('keys.saltStable'));
181
- }
182
327
  }
183
328
  else if (!options.rederive) {
184
329
  // A legacy devId (pre-provision machine-local salt, or env/dev.json
@@ -190,11 +335,16 @@ export function runKeysProvision(options) {
190
335
  out.warn(t('keys.warn.legacyDevId', { dev: existingDevId, stable: stableDevId ?? '?' }));
191
336
  }
192
337
  else {
193
- // --rederive: explicit switch to the client-stable identity.
338
+ // --rederive: explicit switch to the client-stable identity. The repo-local
339
+ // salt is overwritten here and only here — it already exists and it is what
340
+ // resolution reads first, so leaving the old value would re-derive the
341
+ // legacy id on the very next command.
194
342
  if (stableDevId === null)
195
343
  throw new Error(t('keys.err.rederiveNeedsEmail'));
196
- writeSalt(root, stableSalt);
197
- wrote.push(SALT_REL);
344
+ if (readSalt(root) !== null) {
345
+ writeSalt(root, stableSalt);
346
+ wrote.push(SALT_REL);
347
+ }
198
348
  if (isFile(join(localDir(root), 'dev.json'))) {
199
349
  // A dev.json pin outranks salt+manifest in resolution — re-point it too.
200
350
  writeFileEnsuring(join(localDir(root), 'dev.json'), JSON.stringify({ devId: stableDevId }, null, 2) + '\n', 0o600);
@@ -217,19 +367,37 @@ export function runKeysProvision(options) {
217
367
  wrote.push(MANIFEST_REL);
218
368
  out.info(t('keys.manifestDevRegistered', { dev: devId }));
219
369
  }
220
- // Derive and write. The master key is used here and then dropped.
221
- const devKeyHex = deriveDevHmacKey(masterKey, devId).toString('hex');
370
+ // Settle the key last. On the enrolment path this is the call that binds the
371
+ // seat and consumes the code, so it happens once, for the devId that was
372
+ // actually chosen — including when the legacy rule kept an older one.
373
+ //
374
+ // Unless this machine already has that key. Then the code is NOT spent: the
375
+ // developer is standing in their second repository with the same code in the
376
+ // clipboard, and refusing them (or burning a one-time code to re-derive a
377
+ // value we already hold) is the behaviour this whole change exists to end.
378
+ const alreadyStored = storedDevKey(clientId, devId, env);
379
+ const codeKept = alreadyStored !== null && credentials.via === 'enrolment-code';
380
+ const devKeyHex = alreadyStored ?? (await credentials.devKey(devId));
381
+ const storePath = rememberDevKey({ clientId, platformUrl, salt: stableSalt, devId, devKey: devKeyHex }, env);
222
382
  writeFileEnsuring(join(localDir(root), 'client.json'), JSON.stringify({ clientId, platformUrl }, null, 2) + '\n', 0o600);
223
- writeFileEnsuring(join(localDir(root), 'dev.key'), devKeyHex + '\n', 0o600);
224
- wrote.push(CLIENT_JSON_REL, DEV_KEY_REL);
225
- out.info(t('keys.provisioned', { client: clientId, url: platformUrl }));
383
+ wrote.push(CLIENT_JSON_REL);
384
+ out.info(credentials.via === 'enrolment-code'
385
+ ? t('keys.enrolled', { client: clientId, url: platformUrl })
386
+ : credentials.via === 'stored'
387
+ ? t('keys.linked', { client: clientId, url: platformUrl })
388
+ : t('keys.provisioned', { client: clientId, url: platformUrl }));
389
+ if (codeKept)
390
+ out.info(t('keys.codeKept'));
226
391
  out.info(t('keys.devId', { dev: devId }));
227
- out.info(t('keys.wrote', { clientJson: CLIENT_JSON_REL, devKey: DEV_KEY_REL }));
392
+ out.info(t('keys.wrote', { clientJson: CLIENT_JSON_REL, store: storePath }));
228
393
  out.info(t('keys.next'));
229
394
  return {
230
395
  clientId,
231
396
  platformUrl,
232
397
  devId,
398
+ codeKept,
399
+ storePath,
400
+ via: credentials.via,
233
401
  saltStable,
234
402
  rederived,
235
403
  previousDevId,
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/commands/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAA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AAC,GAAG,IAAI,EACzD,KAAK,CACN,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAE5B,GAAG,CAAC,IAAI,CACN,WAAW,CAAC,GAAG,KAAK,gBAAgB;QAClC,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;QAC5D,CAAC,CAAC,WAAW,CAAC,GAAG,KAAK,QAAQ;YAC5B,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;YAC1D,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CACpE,CAAC;IACF,IAAI,QAAQ;QAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;IAC3C,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC1C,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IAC7E,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;IAEzB,OAAO;QACL,QAAQ;QACR,WAAW;QACX,KAAK;QACL,QAAQ;QACR,SAAS;QACT,GAAG,EAAE,WAAW,CAAC,GAAG;QACpB,UAAU;QACV,SAAS;QACT,aAAa;QACb,KAAK;QACL,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * `invi keys status [--check]` — the answer to "did provisioning actually work?"
3
+ *
4
+ * Until now the only way to find out was to make real work and wait for it to
5
+ * show up on a dashboard, which is a terrible feedback loop: a developer who
6
+ * mistyped a URL, or whose repository is not on their seat, learns about it
7
+ * days later as an absence — the hardest thing to notice.
8
+ *
9
+ * Without `--check` this is a pure local report: which client this checkout
10
+ * belongs to, which identity it resolves, where the key is read from, and
11
+ * whether the store file is readable by other accounts on the machine.
12
+ *
13
+ * With `--check` it does the one round trip that settles it: POST an EMPTY
14
+ * batch to `/v1/ingest/events`. Empty is deliberate — it writes nothing, so it
15
+ * can be run as often as you like, and it still passes through authentication
16
+ * AND the seat's repository check. Three different failures therefore come
17
+ * back distinct:
18
+ *
19
+ * 401 → the key is wrong, or the seat was revoked
20
+ * 403 → the key is right and this REPOSITORY is not on the seat
21
+ * 200 → work from this checkout will land under this repo name
22
+ *
23
+ * The 403 is the valuable one. It is the silent failure the panel shows as
24
+ * "sem atividade ainda" forever, and it has never had a way to be seen from
25
+ * the machine where it happens.
26
+ */
27
+ import type { Reporter } from '../util/out.js';
28
+ /** Where the bearer key for `invi sync` is actually coming from. */
29
+ export type KeySource = 'env' | 'user-store' | 'repo-legacy' | 'none';
30
+ export interface KeysStatusCheck {
31
+ ok: boolean;
32
+ /** HTTP status, or null when the platform could not be reached at all. */
33
+ status: number | null;
34
+ /** One of: 'authenticated' | 'unauthorized' | 'repo-not-on-seat' | 'unreachable' | 'unexpected'. */
35
+ verdict: 'authenticated' | 'unauthorized' | 'repo-not-on-seat' | 'unreachable' | 'unexpected';
36
+ detail: string | null;
37
+ }
38
+ export interface KeysStatusResult {
39
+ clientId: string | null;
40
+ platformUrl: string | null;
41
+ devId: string | null;
42
+ /** The repo name every event and commit from this checkout is filed under. */
43
+ repo: string;
44
+ keySource: KeySource;
45
+ saltSource: 'repo-legacy' | 'user-store' | 'none';
46
+ storePath: string | null;
47
+ /** True when the store file is group- or world-readable. */
48
+ storeLoose: boolean;
49
+ /** Every client this machine holds credentials for. */
50
+ storedClients: string[];
51
+ /** True when a repo-local `dev.key` from an older kit is still on disk. */
52
+ legacyKeyFilePresent: boolean;
53
+ check: KeysStatusCheck | null;
54
+ configured: boolean;
55
+ }
56
+ export type StatusFetch = (url: string, init: RequestInit) => Promise<Response>;
57
+ export interface KeysStatusOptions {
58
+ dir?: string;
59
+ json?: boolean;
60
+ lang?: string;
61
+ /** Do the round trip that proves the key works for THIS repository. */
62
+ check?: boolean;
63
+ reporter?: Reporter;
64
+ env?: NodeJS.ProcessEnv;
65
+ gitEmail?: string;
66
+ fetchImpl?: StatusFetch;
67
+ }
68
+ export declare function runKeysStatus(options?: KeysStatusOptions): Promise<KeysStatusResult>;
69
+ //# sourceMappingURL=keysStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keysStatus.d.ts","sourceRoot":"","sources":["../../src/commands/keysStatus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAcH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C,oEAAoE;AACpE,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,YAAY,GAAG,aAAa,GAAG,MAAM,CAAC;AAEtE,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,OAAO,CAAC;IACZ,0EAA0E;IAC1E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,oGAAoG;IACpG,OAAO,EAAE,eAAe,GAAG,cAAc,GAAG,kBAAkB,GAAG,aAAa,GAAG,YAAY,CAAC;IAC9F,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,aAAa,GAAG,YAAY,GAAG,MAAM,CAAC;IAClD,SAAS,EAAE,MAAM,GAAG,IAAI,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