@tiangong-lca/cli 0.1.6 → 0.1.7

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 (32) hide show
  1. package/README.md +3 -13
  2. package/dist/src/cli.js +20 -36
  3. package/dist/src/cli.js.map +1 -1
  4. package/dist/src/lib/auth-identity-receipt.d.ts +1 -2
  5. package/dist/src/lib/auth-identity-receipt.js +3 -20
  6. package/dist/src/lib/auth-identity-receipt.js.map +1 -1
  7. package/dist/src/lib/credential-safety.d.ts +7 -0
  8. package/dist/src/lib/credential-safety.js +28 -0
  9. package/dist/src/lib/credential-safety.js.map +1 -0
  10. package/dist/src/lib/dataset-save-draft-run.js +3 -1
  11. package/dist/src/lib/dataset-save-draft-run.js.map +1 -1
  12. package/dist/src/lib/env.d.ts +0 -2
  13. package/dist/src/lib/env.js +11 -19
  14. package/dist/src/lib/env.js.map +1 -1
  15. package/dist/src/lib/flow-publish-reviewed-data.js +1 -1
  16. package/dist/src/lib/flow-publish-reviewed-data.js.map +1 -1
  17. package/dist/src/lib/lifecyclemodel-resulting-process.js +2 -6
  18. package/dist/src/lib/lifecyclemodel-resulting-process.js.map +1 -1
  19. package/dist/src/lib/process-refresh-references.js +1 -1
  20. package/dist/src/lib/process-refresh-references.js.map +1 -1
  21. package/dist/src/lib/process-scope-statistics.js +1 -1
  22. package/dist/src/lib/process-scope-statistics.js.map +1 -1
  23. package/dist/src/lib/supabase-client.d.ts +1 -3
  24. package/dist/src/lib/supabase-client.js +5 -15
  25. package/dist/src/lib/supabase-client.js.map +1 -1
  26. package/dist/src/lib/supabase-session.d.ts +5 -14
  27. package/dist/src/lib/supabase-session.js +34 -113
  28. package/dist/src/lib/supabase-session.js.map +1 -1
  29. package/package.json +1 -2
  30. package/dist/src/lib/user-api-key.d.ts +0 -16
  31. package/dist/src/lib/user-api-key.js +0 -75
  32. package/dist/src/lib/user-api-key.js.map +0 -1
package/README.md CHANGED
@@ -28,18 +28,17 @@ checkPaths:
28
28
  - src/lib/oauth-pkce.ts
29
29
  - src/lib/supabase-session.ts
30
30
  - src/lib/lca-release.ts
31
- - scripts/run-auth-identity-production-case.ts
32
31
  - test/auth-identity*.test.ts
33
32
  - test/public-auth-identity-receipt.test.ts
34
33
  - test/lca-release*.test.ts
35
34
  lastReviewedAt: 2026-08-31
36
35
  lastReviewedCommit: 499c910d07bb6a5e2e1cd8e4403a5a617d4269bb
37
- lastReviewedNote: 'Reviewed for Issue #257: CLI 0.1.6 is the release identity for the merged latest-compatible dependency graph; commands, exports, OAuth/session behavior, dependencies, and lock bytes stay fixed.'
36
+ lastReviewedNote: 'Reviewed for Issue #260: CLI 0.1.7 removes the password-equivalent API-key bootstrap and historical runner; OAuth or an explicit verified headless token is required for every user-authenticated remote command.'
38
37
  ---
39
38
 
40
39
  # TianGong LCA CLI
41
40
 
42
- Package: `@tiangong-lca/cli` Executable: `tiangong-lca` Current package version: `0.1.6` Node: `24.19.0`
41
+ Package: `@tiangong-lca/cli` Executable: `tiangong-lca` Current package version: `0.1.7` Node: `24.19.0`
43
42
 
44
43
  Repository development is single-track on pnpm `11.24.0` and TypeScript `7.0.2`. The published package remains a clean, package-manager-neutral consumer artifact: it contains runtime files only, not pnpm, TypeScript, Oxlint, tests, source-only tooling, or repository lockfiles.
45
44
 
@@ -154,7 +153,6 @@ Notes:
154
153
  - `TIANGONG_LCA_OAUTH_CLIENT_ID` is the environment-specific registered public CLI client; it is not a secret.
155
154
  - Run `tiangong-lca auth login` once in a trusted terminal. All Edge Function and direct Supabase commands then reuse the OAuth access token and rotate the refresh token on demand.
156
155
  - For approved headless execution, set `TIANGONG_LCA_AUTH_MODE=access-token` and inject one short-lived `TIANGONG_LCA_ACCESS_TOKEN`. It is verified online, kept only in process memory, and never refreshed.
157
- - Transition-only compatibility uses `TIANGONG_LCA_AUTH_MODE=legacy-user-api-key` plus `TIANGONG_LCA_API_KEY`. OAuth failures never fall back to this password-equivalent credential.
158
156
 
159
157
  Optional session control:
160
158
 
@@ -190,7 +188,7 @@ Use the identity receipt before a production-backed case or any later owner-draf
190
188
  tiangong-lca auth identity-receipt --expected-project-ref <project-ref> --expected-user-id <user-id> --json
191
189
  ```
192
190
 
193
- The command performs no dataset write. It resolves the selected OAuth, explicit headless, or transition-only legacy session, checks the canonical Supabase project, and makes a bounded live `GET /auth/v1/user`. A refreshable cached token that receives `401` or `403` may be refreshed and retried exactly once; an explicit headless access token is never refreshed. All other transport or response failures are terminal. A valid production guard requires:
191
+ The command performs no dataset write. It resolves the selected OAuth or explicit headless session, checks the canonical Supabase project, and makes a bounded live `GET /auth/v1/user`. A refreshable cached token that receives `401` or `403` may be refreshed and retried exactly once; an explicit headless access token is never refreshed. All other transport or response failures are terminal. A valid production guard requires:
194
192
 
195
193
  - `schema` exactly `tiangong-lca.auth-identity-receipt.v1`;
196
194
  - `status: "passed"`, `operation: "current-user-read"`, and `remote_write_mode: "read-only"`;
@@ -199,14 +197,6 @@ The command performs no dataset write. It resolves the selected OAuth, explicit
199
197
 
200
198
  Calling without expectations is allowed for discovery but produces `assertions.mode: "observed"`; it is not an authorization guard. The safe display email is masked and must not be used as the account key. The receipt deliberately excludes credentials, full email, session-file details, raw response metadata, and all credential/token/path-derived fingerprints.
201
199
 
202
- For the explicitly authorized local production read case from a validated repository checkout, invoke the narrow TypeScript runner with a new private output directory:
203
-
204
- ```text
205
- pnpm case:auth-identity:production -- --env-file <data-foundry-ignored-.env> --expected-project-ref <project-ref> --expected-user-id <user-id> --out-dir <new-private-case-directory>
206
- ```
207
-
208
- The historical production-case runner remains a transition-only legacy fixture: it reads only `TIANGONG_LCA_API_BASE_URL`, `TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY`, and `TIANGONG_LCA_TEST_API_KEY`; the last is mapped to the child process's explicit legacy variable. It does not accept an alternate CLI path. The pnpm command first performs a clean TS7 build without the production env. Its plain-Node runner then single-reads source/config/lock and the freshly generated `dist/src/**/*.js`, hashes the source tree, runner, runtime, exact entrypoint, and pnpm lock, and copies those exact built buffers into a private snapshot before exposing the key. It forces reauthentication with session cache disabled, runs only the built snapshot from an exclusively created clean directory with an argv array and `shell:false`, cleans the snapshot before publishing success artifacts, and persists only the parsed receipt and case manifest. POSIX creates the case directory as `0700` and files as `0600`; Windows inherits ACLs from the caller-selected parent, so use a user-restricted parent because mode bits are not an ACL guarantee. The runner never stores raw child stdout/stderr and is intentionally not wired to CI secrets. New automation should use OAuth/headless mode instead. This receipt is locally hash-verifiable, not server-signed attestation.
209
-
210
200
  ## LCI/LCIA Data Release
211
201
 
212
202
  The `release` command family is the authenticated transport used by the standalone release control plane. It does not introduce a TIDAS schema variant: result packages reuse the existing Process exchange structure for LCI and the existing Process LCIA result fields, with a LifecycleModel referencing the resulting Process.
package/dist/src/cli.js CHANGED
@@ -295,9 +295,6 @@ Required env:
295
295
  Headless alternative:
296
296
  TIANGONG_LCA_ACCESS_TOKEN (short-lived actor token; never cached or refreshed)
297
297
 
298
- Legacy compatibility:
299
- TIANGONG_LCA_AUTH_MODE=legacy-user-api-key plus TIANGONG_LCA_API_KEY
300
-
301
298
  Optional session env:
302
299
  TIANGONG_LCA_SESSION_FILE
303
300
  TIANGONG_LCA_DISABLE_SESSION_CACHE
@@ -321,7 +318,6 @@ Options:
321
318
  --input <file> JSON request file
322
319
  --json Print compact JSON
323
320
  --dry-run Print the planned HTTP request without sending it
324
- --api-key <key> Override TIANGONG_LCA_API_KEY
325
321
  --base-url <url> Override TIANGONG_LCA_API_BASE_URL
326
322
  --region <name> Override TIANGONG_LCA_REGION
327
323
  --timeout-ms <n> Request timeout in milliseconds
@@ -329,13 +325,12 @@ Options:
329
325
 
330
326
  Required env:
331
327
  TIANGONG_LCA_API_BASE_URL
332
- TIANGONG_LCA_API_KEY
333
328
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
329
+ TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
334
330
  TIANGONG_LCA_REGION (optional)
335
331
 
336
332
  Runtime note:
337
- The CLI decodes TIANGONG_LCA_API_KEY as a user API key bootstrap, exchanges it for a user session,
338
- and sends the resolved access token to Edge Functions.
333
+ The CLI resolves the OAuth session and sends only its access token to Edge Functions.
339
334
  `.trim();
340
335
  }
341
336
  function renderAdminHelp() {
@@ -346,19 +341,17 @@ Options:
346
341
  --input <file> JSON request file
347
342
  --json Print compact JSON
348
343
  --dry-run Print the planned HTTP request without sending it
349
- --api-key <key> Override TIANGONG_LCA_API_KEY
350
344
  --base-url <url> Override TIANGONG_LCA_API_BASE_URL
351
345
  --timeout-ms <n> Request timeout in milliseconds
352
346
  -h, --help
353
347
 
354
348
  Required env:
355
349
  TIANGONG_LCA_API_BASE_URL
356
- TIANGONG_LCA_API_KEY
357
350
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
351
+ TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
358
352
 
359
353
  Runtime note:
360
- The CLI decodes TIANGONG_LCA_API_KEY as a user API key bootstrap, exchanges it for a user session,
361
- and sends the resolved access token to Edge Functions.
354
+ The CLI resolves the OAuth session and sends only its access token to Edge Functions.
362
355
  `.trim();
363
356
  }
364
357
  function renderLcaReleaseHelp() {
@@ -391,19 +384,18 @@ Options:
391
384
  --force Replace an existing output file
392
385
  --dry-run Validate and print the masked planned request without network writes
393
386
  --json Print the stable compact JSON report; otherwise print Summary and Next
394
- --api-key <key> Override TIANGONG_LCA_API_KEY; environment use is preferred
395
387
  --base-url <url> Override TIANGONG_LCA_API_BASE_URL
396
388
  --timeout-ms <n> Request timeout in milliseconds (default 60000)
397
389
  -h, --help
398
390
 
399
391
  Required environment:
400
392
  TIANGONG_LCA_API_BASE_URL
401
- TIANGONG_LCA_API_KEY
402
393
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
394
+ TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
403
395
 
404
396
  Authorization and safety:
405
- The User API key is exchanged for a user session. Database RPCs then check that the live account
406
- has data_product_manager. The service-role key never enters this CLI. Large bundle projections,
397
+ The OAuth session identifies the live account, and Database RPCs check that it has
398
+ data_product_manager. The service-role key never enters this CLI. Large bundle projections,
407
399
  ZIPs, and chunks are written to files and verified against exact byte size and SHA-256.
408
400
 
409
401
  Examples:
@@ -1057,7 +1049,7 @@ Options:
1057
1049
  -h, --help
1058
1050
 
1059
1051
  Environment:
1060
- TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_API_KEY, and TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
1052
+ TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY, and a configured OAuth session
1061
1053
 
1062
1054
  Outputs written under --out-dir:
1063
1055
  - outputs/remote-verification-report.json
@@ -1273,7 +1265,7 @@ Options:
1273
1265
 
1274
1266
  Environment:
1275
1267
  none for local dry-run
1276
- TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_API_KEY, and TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
1268
+ TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY, and a configured OAuth session
1277
1269
  when --commit executes remote writes
1278
1270
 
1279
1271
  Outputs written under --out-dir:
@@ -1389,7 +1381,7 @@ Options:
1389
1381
 
1390
1382
  Required env:
1391
1383
  TIANGONG_LCA_API_BASE_URL
1392
- TIANGONG_LCA_API_KEY
1384
+ TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1393
1385
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
1394
1386
 
1395
1387
  Runtime note:
@@ -1417,7 +1409,7 @@ Options:
1417
1409
 
1418
1410
  Required env:
1419
1411
  TIANGONG_LCA_API_BASE_URL
1420
- TIANGONG_LCA_API_KEY
1412
+ TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1421
1413
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
1422
1414
 
1423
1415
  Runtime note:
@@ -1458,7 +1450,7 @@ Options:
1458
1450
 
1459
1451
  Required env:
1460
1452
  TIANGONG_LCA_API_BASE_URL
1461
- TIANGONG_LCA_API_KEY
1453
+ TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1462
1454
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
1463
1455
 
1464
1456
  Outputs written under --out-dir:
@@ -1505,7 +1497,7 @@ Options:
1505
1497
 
1506
1498
  Environment:
1507
1499
  TIANGONG_LCA_API_BASE_URL
1508
- TIANGONG_LCA_API_KEY
1500
+ TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1509
1501
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
1510
1502
 
1511
1503
  Outputs written under --out-dir:
@@ -1535,7 +1527,7 @@ Options:
1535
1527
 
1536
1528
  Environment:
1537
1529
  none for local dry-run
1538
- TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_API_KEY, and TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
1530
+ TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY, and a configured OAuth session
1539
1531
  when --commit publishes prepared rows
1540
1532
 
1541
1533
  Outputs written under --out-dir:
@@ -1770,7 +1762,7 @@ Options:
1770
1762
 
1771
1763
  Remote lookup env (only when process_sources.allow_remote_lookup=true):
1772
1764
  TIANGONG_LCA_API_BASE_URL
1773
- TIANGONG_LCA_API_KEY
1765
+ TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1774
1766
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
1775
1767
  `.trim();
1776
1768
  }
@@ -1800,7 +1792,7 @@ Options:
1800
1792
 
1801
1793
  Environment:
1802
1794
  none for local dry-run
1803
- TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_API_KEY, and TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
1795
+ TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY, and a configured OAuth session
1804
1796
  when --commit executes remote writes
1805
1797
 
1806
1798
  Local gate:
@@ -1966,7 +1958,7 @@ Options:
1966
1958
 
1967
1959
  Required env:
1968
1960
  TIANGONG_LCA_API_BASE_URL
1969
- TIANGONG_LCA_API_KEY
1961
+ TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1970
1962
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
1971
1963
 
1972
1964
  Runtime note:
@@ -1993,7 +1985,7 @@ Options:
1993
1985
 
1994
1986
  Required env:
1995
1987
  TIANGONG_LCA_API_BASE_URL
1996
- TIANGONG_LCA_API_KEY
1988
+ TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
1997
1989
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
1998
1990
 
1999
1991
  Runtime note:
@@ -2143,7 +2135,7 @@ Options:
2143
2135
 
2144
2136
  Environment:
2145
2137
  none for local dry-run
2146
- TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_API_KEY, and TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
2138
+ TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY, and a configured OAuth session
2147
2139
  when --commit executes remote writes
2148
2140
 
2149
2141
  Local gate:
@@ -2199,7 +2191,7 @@ Options:
2199
2191
 
2200
2192
  Required env:
2201
2193
  TIANGONG_LCA_API_BASE_URL
2202
- TIANGONG_LCA_API_KEY
2194
+ TIANGONG_LCA_OAUTH_CLIENT_ID and a prior "tiangong-lca auth login"
2203
2195
  TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
2204
2196
 
2205
2197
  Guardrails:
@@ -2551,7 +2543,6 @@ function parseRemoteFlags(args) {
2551
2543
  json: { type: 'boolean' },
2552
2544
  'dry-run': { type: 'boolean' },
2553
2545
  input: { type: 'string' },
2554
- 'api-key': { type: 'string' },
2555
2546
  'base-url': { type: 'string' },
2556
2547
  region: { type: 'string' },
2557
2548
  'timeout-ms': { type: 'string' },
@@ -2577,7 +2568,6 @@ function parseRemoteFlags(args) {
2577
2568
  json: Boolean(values.json),
2578
2569
  dryRun: Boolean(values['dry-run']),
2579
2570
  inputPath: typeof values.input === 'string' ? values.input : '',
2580
- apiKey: typeof values['api-key'] === 'string' ? values['api-key'] : null,
2581
2571
  apiBaseUrl: typeof values['base-url'] === 'string' ? values['base-url'] : null,
2582
2572
  region: typeof values.region === 'string' ? values.region : null,
2583
2573
  timeoutMs,
@@ -2601,7 +2591,6 @@ function parseLcaReleaseFlags(args) {
2601
2591
  'package-id': { type: 'string' },
2602
2592
  'artifact-id': { type: 'string' },
2603
2593
  'artifact-path': { type: 'string' },
2604
- 'api-key': { type: 'string' },
2605
2594
  'base-url': { type: 'string' },
2606
2595
  'timeout-ms': { type: 'string' },
2607
2596
  },
@@ -2633,7 +2622,6 @@ function parseLcaReleaseFlags(args) {
2633
2622
  packageId: optionalString(values['package-id']),
2634
2623
  artifactId: optionalString(values['artifact-id']),
2635
2624
  artifactPath: optionalString(values['artifact-path']),
2636
- apiKey: optionalString(values['api-key']),
2637
2625
  apiBaseUrl: optionalString(values['base-url']),
2638
2626
  timeoutMs,
2639
2627
  };
@@ -5705,7 +5693,6 @@ function applyRemoteOverrides(env, overrides) {
5705
5693
  return {
5706
5694
  ...env,
5707
5695
  TIANGONG_LCA_API_BASE_URL: overrides.apiBaseUrl ?? runtimeEnv.apiBaseUrl ?? undefined,
5708
- TIANGONG_LCA_API_KEY: overrides.apiKey ?? runtimeEnv.apiKey ?? undefined,
5709
5696
  TIANGONG_LCA_REGION: overrides.region ?? runtimeEnv.region,
5710
5697
  };
5711
5698
  }
@@ -7934,9 +7921,6 @@ export async function executeCli(argv, deps) {
7934
7921
  }
7935
7922
  const action = requireLcaReleaseAction(subcommand);
7936
7923
  const env = { ...deps.env };
7937
- if (releaseFlags.apiKey !== null) {
7938
- env.TIANGONG_LCA_API_KEY = releaseFlags.apiKey;
7939
- }
7940
7924
  if (releaseFlags.apiBaseUrl !== null) {
7941
7925
  env.TIANGONG_LCA_API_BASE_URL = releaseFlags.apiBaseUrl;
7942
7926
  }