@ora-ai/cli 0.23.0 → 0.24.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.
Files changed (184) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +44 -13
  3. package/dist/agent-skills/skills-command.d.ts.map +1 -1
  4. package/dist/agent-skills/skills-command.js +2 -2
  5. package/dist/agent-skills/skills-command.js.map +1 -1
  6. package/dist/auth-commands.d.ts +25 -9
  7. package/dist/auth-commands.d.ts.map +1 -1
  8. package/dist/auth-commands.js +59 -49
  9. package/dist/auth-commands.js.map +1 -1
  10. package/dist/core/auth.d.ts +2 -2
  11. package/dist/core/auth.d.ts.map +1 -1
  12. package/dist/core/auth.js +5 -4
  13. package/dist/core/auth.js.map +1 -1
  14. package/dist/core/config.d.ts +10 -5
  15. package/dist/core/config.d.ts.map +1 -1
  16. package/dist/core/config.js +10 -7
  17. package/dist/core/config.js.map +1 -1
  18. package/dist/core/credentials/api-key-credential.d.ts +29 -0
  19. package/dist/core/credentials/api-key-credential.d.ts.map +1 -0
  20. package/dist/core/credentials/api-key-credential.js +58 -0
  21. package/dist/core/credentials/api-key-credential.js.map +1 -0
  22. package/dist/core/credentials/ci-oidc-credential.d.ts +44 -0
  23. package/dist/core/credentials/ci-oidc-credential.d.ts.map +1 -0
  24. package/dist/core/credentials/ci-oidc-credential.js +82 -0
  25. package/dist/core/credentials/ci-oidc-credential.js.map +1 -0
  26. package/dist/core/credentials/credential-chain.d.ts +25 -0
  27. package/dist/core/credentials/credential-chain.d.ts.map +1 -0
  28. package/dist/core/credentials/credential-chain.js +39 -0
  29. package/dist/core/credentials/credential-chain.js.map +1 -0
  30. package/dist/core/credentials/credential.d.ts +73 -0
  31. package/dist/core/credentials/credential.d.ts.map +1 -0
  32. package/dist/core/credentials/credential.js +9 -0
  33. package/dist/core/credentials/credential.js.map +1 -0
  34. package/dist/core/credentials/device-session-credential.d.ts +27 -0
  35. package/dist/core/credentials/device-session-credential.d.ts.map +1 -0
  36. package/dist/core/credentials/device-session-credential.js +78 -0
  37. package/dist/core/credentials/device-session-credential.js.map +1 -0
  38. package/dist/core/credentials/identity-lines.d.ts +14 -0
  39. package/dist/core/credentials/identity-lines.d.ts.map +1 -0
  40. package/dist/core/credentials/identity-lines.js +45 -0
  41. package/dist/core/credentials/identity-lines.js.map +1 -0
  42. package/dist/core/credentials/refusal-words.d.ts +15 -0
  43. package/dist/core/credentials/refusal-words.d.ts.map +1 -0
  44. package/dist/core/credentials/refusal-words.js +56 -0
  45. package/dist/core/credentials/refusal-words.js.map +1 -0
  46. package/dist/core/credentials/sign-in-areas.d.ts +18 -0
  47. package/dist/core/credentials/sign-in-areas.d.ts.map +1 -0
  48. package/dist/core/credentials/sign-in-areas.js +22 -0
  49. package/dist/core/credentials/sign-in-areas.js.map +1 -0
  50. package/dist/core/http.d.ts +10 -4
  51. package/dist/core/http.d.ts.map +1 -1
  52. package/dist/core/http.js +7 -5
  53. package/dist/core/http.js.map +1 -1
  54. package/dist/core/identity.d.ts +11 -0
  55. package/dist/core/identity.d.ts.map +1 -0
  56. package/dist/core/identity.js +21 -0
  57. package/dist/core/identity.js.map +1 -0
  58. package/dist/core/login.d.ts +5 -3
  59. package/dist/core/login.d.ts.map +1 -1
  60. package/dist/core/login.js +5 -3
  61. package/dist/core/login.js.map +1 -1
  62. package/dist/core/oauth/metadata.d.ts +24 -0
  63. package/dist/core/oauth/metadata.d.ts.map +1 -0
  64. package/dist/core/oauth/metadata.js +99 -0
  65. package/dist/core/oauth/metadata.js.map +1 -0
  66. package/dist/core/oauth/oauth-client.d.ts +70 -0
  67. package/dist/core/oauth/oauth-client.d.ts.map +1 -0
  68. package/dist/core/oauth/oauth-client.js +136 -0
  69. package/dist/core/oauth/oauth-client.js.map +1 -0
  70. package/dist/core/oauth/oauth-error.d.ts +18 -0
  71. package/dist/core/oauth/oauth-error.d.ts.map +1 -0
  72. package/dist/core/oauth/oauth-error.js +31 -0
  73. package/dist/core/oauth/oauth-error.js.map +1 -0
  74. package/dist/core/oauth/sign-in-error.d.ts +15 -0
  75. package/dist/core/oauth/sign-in-error.d.ts.map +1 -0
  76. package/dist/core/oauth/sign-in-error.js +21 -0
  77. package/dist/core/oauth/sign-in-error.js.map +1 -0
  78. package/dist/core/oauth/sign-in-target.d.ts +31 -0
  79. package/dist/core/oauth/sign-in-target.d.ts.map +1 -0
  80. package/dist/core/oauth/sign-in-target.js +44 -0
  81. package/dist/core/oauth/sign-in-target.js.map +1 -0
  82. package/dist/core/output.d.ts +14 -3
  83. package/dist/core/output.d.ts.map +1 -1
  84. package/dist/core/output.js +35 -31
  85. package/dist/core/output.js.map +1 -1
  86. package/dist/core/retry-after.d.ts +8 -0
  87. package/dist/core/retry-after.d.ts.map +1 -0
  88. package/dist/core/retry-after.js +18 -0
  89. package/dist/core/retry-after.js.map +1 -0
  90. package/dist/core/run-operation.d.ts +23 -9
  91. package/dist/core/run-operation.d.ts.map +1 -1
  92. package/dist/core/run-operation.js +25 -14
  93. package/dist/core/run-operation.js.map +1 -1
  94. package/dist/core/session/device-session-auth.d.ts +29 -0
  95. package/dist/core/session/device-session-auth.d.ts.map +1 -0
  96. package/dist/core/session/device-session-auth.js +92 -0
  97. package/dist/core/session/device-session-auth.js.map +1 -0
  98. package/dist/core/session/file-lock.d.ts +33 -0
  99. package/dist/core/session/file-lock.d.ts.map +1 -0
  100. package/dist/core/session/file-lock.js +145 -0
  101. package/dist/core/session/file-lock.js.map +1 -0
  102. package/dist/core/session/session-refusals.d.ts +22 -0
  103. package/dist/core/session/session-refusals.d.ts.map +1 -0
  104. package/dist/core/session/session-refusals.js +23 -0
  105. package/dist/core/session/session-refusals.js.map +1 -0
  106. package/dist/core/session/session-store.d.ts +53 -0
  107. package/dist/core/session/session-store.d.ts.map +1 -0
  108. package/dist/core/session/session-store.js +71 -0
  109. package/dist/core/session/session-store.js.map +1 -0
  110. package/dist/core/sign-in.d.ts +2 -2
  111. package/dist/core/sign-in.js +2 -2
  112. package/dist/core/token-expiry.d.ts +9 -0
  113. package/dist/core/token-expiry.d.ts.map +1 -0
  114. package/dist/core/token-expiry.js +11 -0
  115. package/dist/core/token-expiry.js.map +1 -0
  116. package/dist/core/url.d.ts +5 -0
  117. package/dist/core/url.d.ts.map +1 -0
  118. package/dist/core/url.js +17 -0
  119. package/dist/core/url.js.map +1 -0
  120. package/dist/generated/operations.d.ts +1 -1
  121. package/dist/generated/operations.js +2 -2
  122. package/dist/generated/types.d.ts +289 -0
  123. package/dist/generated/types.d.ts.map +1 -1
  124. package/dist/generated/types.js +1 -1
  125. package/dist/interactive/menu.d.ts.map +1 -1
  126. package/dist/interactive/menu.js +4 -2
  127. package/dist/interactive/menu.js.map +1 -1
  128. package/dist/interactive/session.d.ts.map +1 -1
  129. package/dist/interactive/session.js +13 -6
  130. package/dist/interactive/session.js.map +1 -1
  131. package/dist/login/browser-opener.d.ts +20 -0
  132. package/dist/login/browser-opener.d.ts.map +1 -0
  133. package/dist/login/browser-opener.js +43 -0
  134. package/dist/login/browser-opener.js.map +1 -0
  135. package/dist/login/device-flow.d.ts +60 -0
  136. package/dist/login/device-flow.d.ts.map +1 -0
  137. package/dist/login/device-flow.js +98 -0
  138. package/dist/login/device-flow.js.map +1 -0
  139. package/dist/login/device-login.d.ts +27 -0
  140. package/dist/login/device-login.d.ts.map +1 -0
  141. package/dist/login/device-login.js +148 -0
  142. package/dist/login/device-login.js.map +1 -0
  143. package/dist/login/device-presenter.d.ts +24 -0
  144. package/dist/login/device-presenter.d.ts.map +1 -0
  145. package/dist/login/device-presenter.js +69 -0
  146. package/dist/login/device-presenter.js.map +1 -0
  147. package/dist/login/login-command.d.ts +14 -0
  148. package/dist/login/login-command.d.ts.map +1 -0
  149. package/dist/login/login-command.js +73 -0
  150. package/dist/login/login-command.js.map +1 -0
  151. package/dist/login/login-deps.d.ts +17 -0
  152. package/dist/login/login-deps.d.ts.map +1 -0
  153. package/dist/login/login-deps.js +18 -0
  154. package/dist/login/login-deps.js.map +1 -0
  155. package/dist/login/piped-input.d.ts +23 -0
  156. package/dist/login/piped-input.d.ts.map +1 -0
  157. package/dist/login/piped-input.js +36 -0
  158. package/dist/login/piped-input.js.map +1 -0
  159. package/dist/login/requested-scopes.d.ts +22 -0
  160. package/dist/login/requested-scopes.d.ts.map +1 -0
  161. package/dist/login/requested-scopes.js +43 -0
  162. package/dist/login/requested-scopes.js.map +1 -0
  163. package/dist/program.d.ts +16 -5
  164. package/dist/program.d.ts.map +1 -1
  165. package/dist/program.js +15 -7
  166. package/dist/program.js.map +1 -1
  167. package/dist/study-ci/ci-command.d.ts.map +1 -1
  168. package/dist/study-ci/ci-command.js +2 -2
  169. package/dist/study-ci/ci-command.js.map +1 -1
  170. package/dist/study-ci/ci-rehearse-command.d.ts.map +1 -1
  171. package/dist/study-ci/ci-rehearse-command.js +2 -2
  172. package/dist/study-ci/ci-rehearse-command.js.map +1 -1
  173. package/dist/tunnel/connection-end.d.ts +30 -0
  174. package/dist/tunnel/connection-end.d.ts.map +1 -0
  175. package/dist/tunnel/connection-end.js +29 -0
  176. package/dist/tunnel/connection-end.js.map +1 -0
  177. package/dist/tunnel-command.d.ts.map +1 -1
  178. package/dist/tunnel-command.js +24 -8
  179. package/dist/tunnel-command.js.map +1 -1
  180. package/package.json +3 -2
  181. package/dist/core/credential-sources.d.ts +0 -45
  182. package/dist/core/credential-sources.d.ts.map +0 -1
  183. package/dist/core/credential-sources.js +0 -65
  184. package/dist/core/credential-sources.js.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,64 @@
1
+ # Changelog — `@ora-ai/cli`
2
+
3
+ The version of a release is its `cli-v*` tag (package.json stays `0.0.0-dev` in the repo;
4
+ `publish-oss.yaml` stamps the version at release time). Newest first.
5
+
6
+ ## Unreleased
7
+
8
+ Publish this only once the environment people use serves browser sign-in. Until then `ora login`
9
+ says the server does not offer it yet and points at `ora login --api-key`; api keys work either way.
10
+
11
+ ### Added
12
+
13
+ - **Browser sign-in.** `ora login` signs you in through your browser (the device flow, RFC 8628): it
14
+ prints a link and a code, opens the browser when it can, and waits for your approval. A new person
15
+ signs up on the same page. Approve only a sign-in you started yourself — the CLI says so with
16
+ every code. If a code expires first, a fresh one is shown; nothing to restart. Flags:
17
+ `--no-browser` (also implied in CI and over SSH), `--read-only` (ask for read permissions only),
18
+ `--json` (JSON lines for an agent driving the CLI), `--auth-url` (the sign-in server, when it is
19
+ not `account.<domain>` of the API URL; `ORA_AUTH_URL` does the same).
20
+ - The sign-in is stored at `~/.config/ora/session.json` (0600) and refreshed on its own; several
21
+ `ora` commands running at once take turns to refresh it. It asks for the permissions this CLI's
22
+ commands use, and the approval page decides which of them you grant.
23
+ - **A sign-in ends when your own access does.** "Log out everywhere" in ora, a changed or reset
24
+ password, and removal from the organization end it: the next command says to run `ora login`
25
+ again. Signing out of one browser does not. If your organization starts requiring two-factor
26
+ authentication and you have not set it up, commands are refused until you do.
27
+ - **`ora tunnel` works with a sign-in, and ends with it.** The server keeps asking whether the
28
+ sign-in still stands for as long as the tunnel is connected, and closes the tunnel within about
29
+ half a minute once it does not (disconnected in Connected apps, `ora logout` on another machine,
30
+ log out everywhere, removal from the organization). The CLI then says the sign-in no longer works
31
+ and to run `ora login` again, and exits with an error. A tunnel opened with an api key is as before.
32
+ - **`ora autopilot …` does not take a browser sign-in yet.** With a sign-in those commands say so
33
+ and point at an api key (`ora login --api-key`), and `ora login` does not ask for their
34
+ permissions. Everything else works with either.
35
+ - `ora whoami` for a sign-in shows your organization and its name, your email, the permissions you
36
+ granted, and `via: device sign-in`. `ora whoami --json` prints that identity as the API returns it.
37
+
38
+ ### Changed
39
+
40
+ - **`ora login` with no key now signs in through the browser**, where it used to ask you to paste
41
+ one. Every way of giving it a key works as before: `ora login --api-key ora_sk_…`,
42
+ `ORA_API_KEY`, and a key piped on stdin (`echo "$KEY" | ora login`). To paste a key at the
43
+ prompt, run `ora login --api-key`.
44
+ - In a script, CI job or agent harness (stdin is not a terminal), a bare `ora login` reads stdin to
45
+ its end first, as it always has, and starts the browser sign-in only when stdin held nothing.
46
+ `ora login --no-browser` (or `--json`) skips that read and goes straight to the link and code.
47
+ With no key and nobody to approve, the sign-in waits for its codes to expire (up to an hour)
48
+ and exits 1, where the old CLI failed at once: set `ORA_API_KEY` in CI.
49
+ - **`ora logout` revokes a browser sign-in** at the sign-in server, then removes what is stored
50
+ locally (the session, a stored api key and its cached token). If the server cannot be reached the
51
+ local sign-in is removed anyway.
52
+ - One stored credential at a time: signing in through the browser removes a stored api key (and
53
+ its cached token), and `ora login --api-key` revokes and removes a browser sign-in. `ORA_API_KEY`
54
+ still wins over anything stored, then a stored key, then a browser sign-in.
55
+ - A command the API refuses for a missing permission tells a browser sign-in to run `ora login`
56
+ again and allow that permission, naming it. An api key is told what it always was.
57
+ - "No api key configured" is now "Not signed in. Run `ora login` (or set ORA_API_KEY for CI)."
58
+
59
+ ### Unchanged
60
+
61
+ - **Api keys work exactly as before**, against any Ora server: the key is traded for a short-lived
62
+ token at `POST /auth/token`, the token is cached in `~/.config/ora/token.json`, and
63
+ `ora whoami` with a key prints the same lines. Nothing to change in CI or scripts that use
64
+ `ORA_API_KEY`, `ora login --api-key`, or a key piped into `ora login`.
package/README.md CHANGED
@@ -29,16 +29,42 @@ prints `--help` instead — nothing changes for existing scripts.
29
29
 
30
30
  ## Authenticate
31
31
 
32
- Mint an api key in the ora dashboard (Settings → API keys), then:
32
+ Sign in with your browser (a new person signs up on the same page):
33
33
 
34
- ora login # paste the key (masked), or:
35
- ora login --api-key ora_sk_...
34
+ ora login # prints a link and a code, opens your browser
36
35
  ora whoami
37
36
 
38
- In CI, skip login and export `ORA_API_KEY` (prefer short-expiry keys). The
39
- key is stored at `~/.config/ora/config.json` (0600) and exchanged for a
40
- short-lived token on every call — the key itself never travels beyond the
41
- token exchange.
37
+ `ora login` is device sign-in (RFC 8628): approve the CLI in the browser and it
38
+ stays signed in on this machine — `~/.config/ora/session.json` (0600), refreshed
39
+ on its own — until `ora logout`, which also revokes it. Approve only a sign-in
40
+ you started yourself: a link and code someone sends you would sign *their*
41
+ terminal in as you. If a code expires before you approve it, the CLI shows a
42
+ fresh one; nothing to restart. Over SSH, in CI, or with `--no-browser` it only
43
+ prints the link. `ora login --read-only` asks for read permissions only, and
44
+ `ora login --json` prints JSON lines (the code to show, then who signed in) for
45
+ an agent driving the CLI.
46
+
47
+ The sign-in asks for the permissions this CLI's commands use; the approval page
48
+ shows them and you decide which to grant. A command that needs one you did not
49
+ grant says which, and `ora login` again lets you allow it. One exception:
50
+ `ora autopilot …` does not take a browser sign-in yet and needs an API key.
51
+
52
+ API keys are for CI and scripts. Mint one in the ora dashboard (Settings → API
53
+ keys), then:
54
+
55
+ ora login --api-key ora_sk_... # or `ora login --api-key` to paste it (masked)
56
+ echo "$KEY" | ora login # a key piped on stdin
57
+ ORA_API_KEY=ora_sk_... ora whoami
58
+
59
+ In CI, skip login and export `ORA_API_KEY` (prefer short-expiry keys); it wins
60
+ over anything stored. A stored key lives in `~/.config/ora/config.json` (0600)
61
+ and is exchanged for a short-lived token on every call — the key itself never
62
+ travels beyond the token exchange. Keys work exactly as they always have, also
63
+ against a server that does not offer browser sign-in yet (there, `ora login`
64
+ says so and points here).
65
+
66
+ One credential is stored at a time: signing in through the browser removes a
67
+ stored key, and `ora login --api-key` revokes and removes a browser sign-in.
42
68
 
43
69
  ### Keyless sign-in from GitHub Actions
44
70
 
@@ -78,7 +104,11 @@ self-hosted ora, set the API base **once at login** — it's remembered in
78
104
  `~/.config/ora/config.json`:
79
105
 
80
106
  ora login --api-url https://api.staging.agentfront.sh # staging
81
- ora login --api-url http://api.localhost:8081 # local k3d dev
107
+ ora login --api-url http://api.ora.localhost:8081 # local k3d dev
108
+
109
+ Browser sign-in finds its sign-in server from that URL (`api.<domain>` →
110
+ `account.<domain>`); when yours lives elsewhere, name it with `--auth-url`
111
+ (or `ORA_AUTH_URL`).
82
112
 
83
113
  Precedence for every command: `--api-url` flag > `ORA_API_URL` env >
84
114
  `config.json` > the spec's default. So one-off calls can override without
@@ -221,7 +251,7 @@ After a run completes, read its artifacts:
221
251
  `ora-studio` is the Studio playbook: define the objective, create the intent, define the win, measure,
222
252
  read the results, improve, schedule, with a recipe per objective (be recommended, don't get steered
223
253
  away, book a demo, MCP discovery, MCP usage). It comes from your Studio account, so it needs the same
224
- API key as the other commands (scope `intents:read`).
254
+ sign-in or API key as the other commands (scope `intents:read`).
225
255
 
226
256
  ### MCP — give your coding agent the CLI's commands as tools
227
257
 
@@ -442,8 +472,8 @@ error, 2 usage error.
442
472
  With `--json`, a failure is JSON too: the API's error body, as sent, on one
443
473
  stderr line — `{error, code, details}`, the fields a client generated from the
444
474
  public API reads. An Autopilot refusal names its wave and blocker there. A
445
- failure the API did not answer in JSON (no key, an unreadable `--file`, a
446
- refused key exchange) prints `{error, code}`:
475
+ failure the API did not answer in JSON (not signed in, an unreadable `--file`,
476
+ a refused key exchange, a sign-in that did not complete) prints `{error, code}`:
447
477
 
448
478
  ora autopilot members add billing-crew --file member.json --json 2> err.json \
449
479
  || jq -r '.code, .details.issues[0].refusal.wave' err.json
@@ -463,5 +493,6 @@ the terminal's `COLORFGBG`. Set `ORA_THEME=light` or `ORA_THEME=dark` when your
463
493
  ## Errors that explain themselves
464
494
 
465
495
  - **402** — a plan limit was hit; the message names the dimension and where to upgrade.
466
- - **403 INSUFFICIENT_SCOPE** — the key lacks a scope; the message names it. Mint
467
- a key with that scope and `ora login` again.
496
+ - **403 INSUFFICIENT_SCOPE** — the credential lacks a scope; the message names
497
+ it. With a browser sign-in, run `ora login` again and allow that permission.
498
+ With an api key, mint a key with that scope and `ora login --api-key` again.
@@ -1 +1 @@
1
- {"version":3,"file":"skills-command.d.ts","sourceRoot":"","sources":["../../src/agent-skills/skills-command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAUhF,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,CAAC,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,KAAK,YAAwD,GACrH,IAAI,CA4BN"}
1
+ {"version":3,"file":"skills-command.d.ts","sourceRoot":"","sources":["../../src/agent-skills/skills-command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAUhF,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,CAAC,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,KAAK,YAAwD,GACrH,IAAI,CA6BN"}
@@ -1,5 +1,4 @@
1
1
  import { homedir } from "node:os";
2
- import { renderError } from "../core/output.js";
3
2
  import { credentials } from "../core/run-operation.js";
4
3
  import { olderThan } from "./cli-version.js";
5
4
  import { DEFAULT_TARGET_KEYS, resolveTargets } from "./install-targets.js";
@@ -31,7 +30,8 @@ export function attachSkillsAdd(program, deps, version, sourceOf = (client) => n
31
30
  }
32
31
  }
33
32
  catch (err) {
34
- deps.errOut(renderError(err));
33
+ // A refusal is told in the credential's own words: a browser sign-in is not told to mint an api key.
34
+ deps.errOut(creds.renderError(err));
35
35
  process.exitCode = 1;
36
36
  }
37
37
  });
@@ -1 +1 @@
1
- {"version":3,"file":"skills-command.js","sourceRoot":"","sources":["../../src/agent-skills/skills-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OA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M,CAAC,gCAAgC,KAAK,CAAC,aAAa,uBAAuB,OAAO,uCAAuC,CAAC,CAAC;YACxI,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,qGAAqG;YACrG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;YACpC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,27 +1,38 @@
1
1
  /**
2
- * The three handwritten auth commands: login / logout / whoami — plus
3
- * performLogin/performWhoami, the cores shared verbatim with the interactive
4
- * session (interactive/session.ts imports both).
2
+ * The handwritten identity commands' cores: api-key login, whoami, logout —
3
+ * shared verbatim with the interactive session (interactive/session.ts
4
+ * imports performLogin, performWhoami and forgetStoredCredentials). `ora
5
+ * login` itself, which also runs the browser sign-in, is wired in
6
+ * login/login-command.ts.
5
7
  *
6
8
  * ResolvedDeps is imported type-only from program.ts — no runtime edge back
7
9
  * to program.ts (program.ts imports these attach* functions by value; see
8
10
  * that file's session-cycle doc comment for the same pattern).
9
11
  */
10
12
  import type { Command } from "commander";
13
+ import { type CallerCredentials } from "./core/run-operation.js";
11
14
  import type { ResolvedDeps } from "./program.js";
12
15
  /**
13
- * The login core: validate the `ora_sk_` prefix → store → verify by
16
+ * Who a caller is, asked of the server now, the way its credential is verified: an api key by trading it for a token
17
+ * (the program's `makeAuth`), a browser sign-in by asking the API (the program's `makeClient`). The credential picks
18
+ * its door (credentials/credential.ts); this only hands it the program's own, so tests fake them in one place.
19
+ */
20
+ export declare function callerIdentity(deps: Pick<ResolvedDeps, "makeAuth" | "makeClient">, creds: CallerCredentials): Promise<Record<string, unknown>>;
21
+ /**
22
+ * The api-key login core: validate the `ora_sk_` prefix → store → verify by
14
23
  * exchanging for a token → roll back the stored key on verification failure.
15
- * Shared verbatim by the scripted `login` action and (Task 4) the
16
- * interactive session — prints exactly the lines the action always printed
17
- * and returns whether login succeeded.
24
+ * The key becomes THE stored credential: a browser sign-in it replaces is
25
+ * revoked and removed once the key is verified. Shared verbatim by the
26
+ * scripted `login --api-key` action and the interactive session — prints
27
+ * exactly the lines the action always printed and returns whether login
28
+ * succeeded.
18
29
  */
19
30
  export declare function performLogin(deps: ResolvedDeps, opts: {
20
31
  apiKey?: string;
21
32
  apiUrl?: string;
22
33
  }): Promise<boolean>;
23
34
  /**
24
- * The whoami core: verify the configured key and print its identity. THE one
35
+ * The whoami core: verify the configured credential and print its identity. THE one
25
36
  * implementation — shared verbatim by the scripted `whoami` action and the
26
37
  * interactive session's whoami menu entry (interactive/session.ts) so the two
27
38
  * doors never drift apart. Returns whether it succeeded and never throws;
@@ -33,7 +44,12 @@ export declare function performWhoami(deps: ResolvedDeps, opts: {
33
44
  json?: boolean;
34
45
  apiUrlFlag?: string;
35
46
  }): Promise<boolean>;
36
- export declare function attachLogin(program: Command, deps: ResolvedDeps): void;
47
+ /**
48
+ * Every stored credential forgotten — a browser sign-in's grant revoked (best effort), an api key's cached token
49
+ * dropped — then the config dir's credential files removed. An `ORA_API_KEY` in the environment is not stored, so
50
+ * it is not touched.
51
+ */
52
+ export declare function forgetStoredCredentials(deps: ResolvedDeps): Promise<void>;
37
53
  export declare function attachLogout(program: Command, deps: ResolvedDeps): void;
38
54
  export declare function attachWhoami(program: Command, deps: ResolvedDeps): void;
39
55
  //# sourceMappingURL=auth-commands.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-commands.d.ts","sourceRoot":"","sources":["../src/auth-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,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Aa,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAoBvH;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAK/E;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CASvE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAUvE"}
@@ -1,25 +1,38 @@
1
1
  /**
2
- * The three handwritten auth commands: login / logout / whoami — plus
3
- * performLogin/performWhoami, the cores shared verbatim with the interactive
4
- * session (interactive/session.ts imports both).
2
+ * The handwritten identity commands' cores: api-key login, whoami, logout —
3
+ * shared verbatim with the interactive session (interactive/session.ts
4
+ * imports performLogin, performWhoami and forgetStoredCredentials). `ora
5
+ * login` itself, which also runs the browser sign-in, is wired in
6
+ * login/login-command.ts.
5
7
  *
6
8
  * ResolvedDeps is imported type-only from program.ts — no runtime edge back
7
9
  * to program.ts (program.ts imports these attach* functions by value; see
8
10
  * that file's session-cycle doc comment for the same pattern).
9
11
  */
10
- import { decodeClaims } from "./core/auth.js";
11
12
  import { clearCredentials, readConfig, resolveApiUrl, writeConfig } from "./core/config.js";
12
- import { promptForKey } from "./core/login.js";
13
+ import { ApiKeyCredential } from "./core/credentials/api-key-credential.js";
14
+ import { storedCredentials } from "./core/credentials/credential-chain.js";
15
+ import { revokeSession } from "./core/credentials/device-session-credential.js";
13
16
  import { renderError } from "./core/output.js";
14
- import { credentials } from "./core/run-operation.js";
15
- import { apiKeySignIn } from "./core/sign-in.js";
17
+ import { callerOf, credentials } from "./core/run-operation.js";
18
+ import { SessionStore } from "./core/session/session-store.js";
16
19
  import { SPEC } from "./generated/operations.js";
17
20
  /**
18
- * The login core: validate the `ora_sk_` prefix → store → verify by
21
+ * Who a caller is, asked of the server now, the way its credential is verified: an api key by trading it for a token
22
+ * (the program's `makeAuth`), a browser sign-in by asking the API (the program's `makeClient`). The credential picks
23
+ * its door (credentials/credential.ts); this only hands it the program's own, so tests fake them in one place.
24
+ */
25
+ export function callerIdentity(deps, creds) {
26
+ return creds.credential.readIdentity({ auth: () => deps.makeAuth(creds), client: () => deps.makeClient(creds) });
27
+ }
28
+ /**
29
+ * The api-key login core: validate the `ora_sk_` prefix → store → verify by
19
30
  * exchanging for a token → roll back the stored key on verification failure.
20
- * Shared verbatim by the scripted `login` action and (Task 4) the
21
- * interactive session — prints exactly the lines the action always printed
22
- * and returns whether login succeeded.
31
+ * The key becomes THE stored credential: a browser sign-in it replaces is
32
+ * revoked and removed once the key is verified. Shared verbatim by the
33
+ * scripted `login --api-key` action and the interactive session — prints
34
+ * exactly the lines the action always printed and returns whether login
35
+ * succeeded.
23
36
  */
24
37
  export async function performLogin(deps, opts) {
25
38
  const key = opts.apiKey ?? "";
@@ -34,30 +47,31 @@ export async function performLogin(deps, opts) {
34
47
  // failing against another must be self-diagnosing, never a mystery.
35
48
  deps.out(`Verifying against ${apiUrl}`);
36
49
  writeConfig({ ...previous, apiKey: key, ...(opts.apiUrl ? { apiUrl } : {}) }, deps.dir);
50
+ const caller = callerOf(apiUrl, new ApiKeyCredential(key, "config.json"));
37
51
  try {
38
- const token = await deps.makeAuth({ apiUrl, signIn: apiKeySignIn(key) }).forceRefresh();
39
- const claims = decodeClaims(token);
52
+ const claims = await callerIdentity(deps, caller);
53
+ await dropDeviceSession(deps);
40
54
  deps.out(`Logged in. org=${String(claims.org ?? claims.organizationId ?? "?")} subject=${String(claims.sub ?? "?")}`);
41
55
  return true;
42
56
  }
43
57
  catch (err) {
44
58
  writeConfig(previous, deps.dir); // verification failed — roll back
45
- deps.errOut(renderError(err));
59
+ deps.errOut(caller.renderError(err));
46
60
  process.exitCode = 1;
47
61
  return false;
48
62
  }
49
63
  }
50
- /** Which CI job signed in, when the token was minted for one (keyless sign-in). Display only. */
51
- function federationLine(federation) {
52
- if (!federation || typeof federation !== "object")
53
- return [];
54
- const { issuer, repository, ref } = federation;
55
- if (typeof repository !== "string")
56
- return [];
57
- return [`via: ${[issuer, repository, ref].filter((part) => typeof part === "string").join(" ")} (keyless CI sign-in)`];
64
+ /** A browser sign-in replaced by an api key: its grant revoked (best effort) and its session removed. */
65
+ async function dropDeviceSession(deps) {
66
+ const store = new SessionStore(deps.dir);
67
+ const session = store.read();
68
+ if (!session)
69
+ return;
70
+ await revokeSession(session, { fetchFn: deps.login.fetchFn, now: deps.login.now });
71
+ store.clear();
58
72
  }
59
73
  /**
60
- * The whoami core: verify the configured key and print its identity. THE one
74
+ * The whoami core: verify the configured credential and print its identity. THE one
61
75
  * implementation — shared verbatim by the scripted `whoami` action and the
62
76
  * interactive session's whoami menu entry (interactive/session.ts) so the two
63
77
  * doors never drift apart. Returns whether it succeeded and never throws;
@@ -71,54 +85,50 @@ export async function performWhoami(deps, opts) {
71
85
  if (!creds)
72
86
  return false;
73
87
  try {
74
- const token = await deps.makeAuth(creds).forceRefresh();
75
- const claims = decodeClaims(token);
88
+ const claims = await callerIdentity(deps, creds);
76
89
  if (opts.json) {
77
90
  deps.out(JSON.stringify(claims, null, 2));
78
91
  return true;
79
92
  }
80
- deps.out([
81
- `org: ${String(claims.org ?? claims.organizationId ?? "?")}`,
82
- `subject: ${String(claims.sub ?? "?")}`,
83
- ...(Array.isArray(claims.scopes) ? [`scopes: ${claims.scopes.join(", ")}`] : []),
84
- ...federationLine(claims.federation),
85
- `api: ${creds.apiUrl}`,
86
- ].join("\n"));
93
+ // Each credential words its own identity (credentials/identity-lines.ts): an api key's lines are the ones this
94
+ // command has always printed (a keyless CI job's add the job), a browser sign-in's also name the person and how
95
+ // they signed in.
96
+ deps.out(creds.credential.identityLines(claims, creds.apiUrl).join("\n"));
87
97
  return true;
88
98
  }
89
99
  catch (err) {
90
- deps.errOut(renderError(err, { mode }));
100
+ deps.errOut(creds.renderError(err, { mode }));
91
101
  process.exitCode = 1;
92
102
  return false;
93
103
  }
94
104
  }
95
- export function attachLogin(program, deps) {
96
- program
97
- .command("login")
98
- .description("Store an api key for ora (paste, --api-key, or ORA_API_KEY)")
99
- .option("--api-key <key>", "the ora_sk_… api key")
100
- .option("--api-url <url>", "override the API base URL")
101
- .addHelpText("after", "\nExamples:\n ora login --api-key ora_sk_…\n ORA_API_KEY=ora_sk_… ora login # non-interactive (CI)\n ora login --api-url http://api.localhost:8081 # dev cluster")
102
- .action(async (opts) => {
103
- const key = opts.apiKey ?? deps.env.ORA_API_KEY ?? (await promptForKey());
104
- await performLogin(deps, { apiKey: key, apiUrl: opts.apiUrl });
105
- });
105
+ /**
106
+ * Every stored credential forgotten — a browser sign-in's grant revoked (best effort), an api key's cached token
107
+ * dropped — then the config dir's credential files removed. An `ORA_API_KEY` in the environment is not stored, so
108
+ * it is not touched.
109
+ */
110
+ export async function forgetStoredCredentials(deps) {
111
+ const apiUrl = resolveApiUrl(readConfig(deps.dir), undefined, SPEC.server, deps.env);
112
+ const rt = { apiUrl, dir: deps.dir, env: deps.env, fetchFn: deps.login.fetchFn, now: deps.login.now };
113
+ for (const credential of storedCredentials({ env: deps.env, dir: deps.dir }))
114
+ await credential.forget(rt);
115
+ clearCredentials(deps.dir);
106
116
  }
107
117
  export function attachLogout(program, deps) {
108
118
  program
109
119
  .command("logout")
110
- .description("Delete the stored api key and cached token")
120
+ .description("Sign out: revoke a browser sign-in, delete the stored credentials and cached token")
111
121
  .addHelpText("after", "\nExamples:\n ora logout")
112
- .action(() => {
113
- clearCredentials(deps.dir);
122
+ .action(async () => {
123
+ await forgetStoredCredentials(deps);
114
124
  deps.out("Logged out — credentials removed.");
115
125
  });
116
126
  }
117
127
  export function attachWhoami(program, deps) {
118
128
  program
119
129
  .command("whoami")
120
- .description("Verify the configured key against the API and print its identity")
121
- .option("--json", "print the raw token claims")
130
+ .description("Verify the configured sign-in or api key against the API and print its identity")
131
+ .option("--json", "print the identity as JSON (an api key's token claims, a sign-in's verified identity)")
122
132
  .option("--api-url <url>", "override the API base URL")
123
133
  .addHelpText("after", "\nExamples:\n ora whoami\n ora whoami --json")
124
134
  .action(async (opts) => {
@@ -1 +1 @@
1
- {"version":3,"file":"auth-commands.js","sourceRoot":"","sources":["../src/auth-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAGjD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAkB,EAAE,IAA0C;IAC/F,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;IAC9B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC,CAAC,CAAC;QAC9G,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,I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AAE,CAAC;IACtG,KAAK,MAAM,UAAU,IAAI,iBAAiB,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;QAAE,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC1G,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAgB,EAAE,IAAkB;IAC/D,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,oFAAoF,CAAC;SACjG,WAAW,CAAC,OAAO,EAAE,2BAA2B,CAAC;SACjD,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,uBAAuB,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAgB,EAAE,IAAkB;IAC/D,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,iFAAiF,CAAC;SAC9F,MAAM,CAAC,QAAQ,EAAE,uFAAuF,CAAC;SACzG,MAAM,CAAC,iBAAiB,EAAE,2BAA2B,CAAC;SACtD,WAAW,CAAC,OAAO,EAAE,gDAAgD,CAAC;SACtE,MAAM,CAAC,KAAK,EAAE,IAAyC,EAAE,EAAE;QAC1D,MAAM,aAAa,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -5,8 +5,8 @@
5
5
  * or a CI job's identity token. Either way the credential travels ONLY as
6
6
  * "Authorization: Bearer <credential>" to POST /auth/token (the doc's own
7
7
  * rule: never in the request body). The response {token, expiresIn} is cached
8
- * on disk (0600) and reused until a 30s skew before expiry, so a token can't
9
- * die between "checked" and "used".
8
+ * on disk (0600) and reused while it is still fresh (token-expiry.ts: a skew
9
+ * before expiry), so a token can't die between "checked" and "used".
10
10
  *
11
11
  * The cache is keyed to (apiUrl, the sign-in's cache key) — pointing the CLI
12
12
  * at staging or switching credentials can never replay a token minted
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/core/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAKzD,qBAAa,SAAU,SAAQ,KAAK;IAGhC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAFrB,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM;CAKxB;AASD,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;gBAEvB,IAAI,EAAE,qBAAqB;IAQjC,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAM3B,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAuCrC,UAAU,IAAI,IAAI;IAIlB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,SAAS;CAUlB;AAED,MA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rC,UAAU,IAAI,IAAI;IAIlB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,SAAS;CAUlB;AAED,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAC;IAC3E,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qGAAqG;AACrG,qBAAa,UAAW,SAAQ,iBAAiB;gBACnC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc;CAGhD;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQnE"}
package/dist/core/auth.js CHANGED
@@ -5,8 +5,8 @@
5
5
  * or a CI job's identity token. Either way the credential travels ONLY as
6
6
  * "Authorization: Bearer <credential>" to POST /auth/token (the doc's own
7
7
  * rule: never in the request body). The response {token, expiresIn} is cached
8
- * on disk (0600) and reused until a 30s skew before expiry, so a token can't
9
- * die between "checked" and "used".
8
+ * on disk (0600) and reused while it is still fresh (token-expiry.ts: a skew
9
+ * before expiry), so a token can't die between "checked" and "used".
10
10
  *
11
11
  * The cache is keyed to (apiUrl, the sign-in's cache key) — pointing the CLI
12
12
  * at staging or switching credentials can never replay a token minted
@@ -17,7 +17,8 @@ import { chmodSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:
17
17
  import { join } from "node:path";
18
18
  import { configDir } from "./config.js";
19
19
  import { apiKeySignIn } from "./sign-in.js";
20
- const EXPIRY_SKEW_MS = 30_000;
20
+ import { stillFresh } from "./token-expiry.js";
21
+ /** A token response that names no lifetime is taken to last this long: the platform's own token lifetime. */
21
22
  const DEFAULT_EXPIRES_IN_S = 900;
22
23
  export class AuthError extends Error {
23
24
  status;
@@ -44,7 +45,7 @@ export class TokenExchangeAuth {
44
45
  }
45
46
  async getToken() {
46
47
  const cached = this.readCache();
47
- if (cached && cached.expiresAt - EXPIRY_SKEW_MS > this.now())
48
+ if (cached && stillFresh(cached.expiresAt, this.now()))
48
49
  return cached.token;
49
50
  return this.forceRefresh();
50
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/core/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAe,MAAM,cAAc,CAAC;AAEzD,MAAM,cAAc,GAAG,MAAM,CAAC;AAC9B,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,MAAM,OAAO,SAAU,SAAQ,KAAK;IAGvB;IACA;IAHX,YACE,OAAe,EACN,MAAc,EACd,IAAY;QAErB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAGrB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAiBD,MAAM,OAAO,iBAAiB;IACX,MAAM,CAAS;IACf,MAAM,CAAS;IACf,GAAG,CAAS;IACZ,OAAO,CAAe;IACtB,GAAG,CAAe;IAEnC,YAAY,IAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,SAAS,EAAE,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC;QACrC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IAClC,CAAC;I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pC,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAA4B,CAAC;IACnG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * Credential + endpoint configuration.
3
3
  *
4
- * ~/.config/ora (XDG-respecting) holds config.json (api key, api url) and
5
- * token.json (the cached short-lived token, owned by auth.ts). Both are 0600 in
6
- * a 0700 dir — the key is a secret. Every read degrades to "not configured"
7
- * rather than throwing: a corrupt file must never brick the CLI.
4
+ * ~/.config/ora (XDG-respecting) holds config.json (api key, api url, auth url),
5
+ * token.json (an api key's cached short-lived token, owned by auth.ts) and
6
+ * session.json (a browser sign-in, owned by session/session-store.ts). All are
7
+ * 0600 in a 0700 dir — keys and refresh tokens are secrets. Every read degrades
8
+ * to "not configured" rather than throwing: a corrupt file must never brick the CLI.
8
9
  *
9
10
  * Permissions are re-asserted on every write, not just on creation. This hardens
10
11
  * pre-existing insecure files (e.g. restored from dotfiles with loose modes).
@@ -12,15 +13,19 @@
12
13
  * Precedence (why: CI overrides laptops, flags override everything):
13
14
  * api key : ORA_API_KEY env > config.json
14
15
  * api url : --api-url flag > ORA_API_URL env > config.json > the spec's server
16
+ * An api key, wherever it comes from, wins over a browser sign-in
17
+ * (credentials/credential-chain.ts resolves which credential a command uses).
15
18
  */
16
19
  export interface OraConfig {
17
20
  apiKey?: string;
18
21
  apiUrl?: string;
22
+ /** The sign-in server's origin, remembered from `ora login --auth-url` (else derived from apiUrl). */
23
+ authUrl?: string;
19
24
  }
20
25
  export declare function configDir(env?: NodeJS.ProcessEnv): string;
21
26
  export declare function readConfig(dir?: string): OraConfig;
22
27
  export declare function writeConfig(cfg: OraConfig, dir?: string): void;
28
+ /** Removes every credential file — also one too damaged to be read back as a credential and forgotten properly. */
23
29
  export declare function clearCredentials(dir?: string): void;
24
- export declare function resolveApiKey(cfg: OraConfig, env?: NodeJS.ProcessEnv): string | undefined;
25
30
  export declare function resolveApiUrl(cfg: OraConfig, flagValue: string | undefined, embeddedDefault: string, env?: NodeJS.ProcessEnv): string;
26
31
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,SAAS,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAGtE;AAED,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAoB,GAAG,SAAS,CAU/D;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,GAAE,MAAoB,GAAG,IAAI,CAK3E;AAED,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAoB,GAAG,IAAI,CAGhE;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,GAAG,SAAS,CAEtG;AAED,wBAAgB,aAAa,CAC3B,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,eAAe,EAAE,MAAM,EACvB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,CAER"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sGA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