@anybuild-ai/ab 0.6.0 → 0.7.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 (42) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +85 -7
  3. package/dist/api/entity-api.d.ts +2 -0
  4. package/dist/api/entity-api.d.ts.map +1 -1
  5. package/dist/api/entity-api.js +9 -0
  6. package/dist/api/entity-api.js.map +1 -1
  7. package/dist/commands/api-key.d.ts.map +1 -1
  8. package/dist/commands/api-key.js +332 -19
  9. package/dist/commands/api-key.js.map +1 -1
  10. package/dist/commands/index.d.ts.map +1 -1
  11. package/dist/commands/index.js +2 -0
  12. package/dist/commands/index.js.map +1 -1
  13. package/dist/commands/status.js +1 -1
  14. package/dist/commands/status.js.map +1 -1
  15. package/dist/commands/user.d.ts +3 -0
  16. package/dist/commands/user.d.ts.map +1 -0
  17. package/dist/commands/user.js +254 -0
  18. package/dist/commands/user.js.map +1 -0
  19. package/dist/config/types.d.ts +2 -2
  20. package/dist/export/import-batch.d.ts.map +1 -1
  21. package/dist/export/import-batch.js +6 -1
  22. package/dist/export/import-batch.js.map +1 -1
  23. package/dist/export/schema-json.d.ts +2 -1
  24. package/dist/export/schema-json.d.ts.map +1 -1
  25. package/dist/export/schema-json.js +19 -1
  26. package/dist/export/schema-json.js.map +1 -1
  27. package/dist/export/status.js +2 -2
  28. package/dist/export/status.js.map +1 -1
  29. package/dist/export/working-dirs.d.ts +4 -1
  30. package/dist/export/working-dirs.d.ts.map +1 -1
  31. package/dist/export/working-dirs.js +13 -1
  32. package/dist/export/working-dirs.js.map +1 -1
  33. package/dist/export/working-tree-validation.js +1 -1
  34. package/dist/export/working-tree-validation.js.map +1 -1
  35. package/dist/identity/identity-api.d.ts +4 -0
  36. package/dist/identity/identity-api.d.ts.map +1 -0
  37. package/dist/identity/identity-api.js +52 -0
  38. package/dist/identity/identity-api.js.map +1 -0
  39. package/dist/router.d.ts.map +1 -1
  40. package/dist/router.js +2 -1
  41. package/dist/router.js.map +1 -1
  42. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0
4
+
5
+ - Writable `be/scheduled_jobs/*.json` (cron jobs): create/update/delete on push. A job runs a PLV8 function or a Node module. Push takes the version live, which registers cron; delete unschedules it. `run_as` is the user the job runs as. Sent after function files in the same push.
6
+ - `anybuild user roles | list | show | create | activate | deactivate | role` maintains users with the login session. The server rejects the call unless that user is a security administrator. `create --kind person` reads the password from a hidden prompt and fails without a terminal. `create --kind service` has no password.
7
+ - `anybuild api-key create --name <name> [--user <user_id>] [--expires <iso>] [--unscoped] [--scope <METHOD> <path> …] [--use] [--allow-writes | --read-only]` creates a key. Omitted `--user` is `ai_agent`. The secret is printed once. `--use` stores it for `anybuild api` with no prompt; writes stay off unless `--allow-writes`.
8
+ - `anybuild api-key list [--user <user_id>]` and `anybuild api-key revoke <api_key_id>` list and revoke keys. They never print a secret.
9
+ - `anybuild api-key scope list | add | remove` changes route scopes. The target is the stored key unless `--id <api_key_id>` is set. `add` and `remove` take one or more `METHOD path` pairs (same path form as `anybuild api`, including a template such as `my_app/invoice(*)`). An unscoped key already reaches every route, so these commands report that and do not change it.
10
+ - Host routes, secured and token-only (not API-key auth): `POST /api/cli/v1/identity/user`, `POST /api/cli/v1/identity/key`, `POST /api/cli/v1/identity/scope`.
11
+
3
12
  ## 0.6.0
4
13
 
5
14
  - `anybuild create <url>/<application_id> [--name <display name>] [--debug] [directory]` creates a blank application on the host (same URL shape as clone) and clones it locally. `--name` is optional and defaults to the application_id. Rejects if that id already exists (clone it instead). No `--force`.
package/README.md CHANGED
@@ -82,24 +82,25 @@ Pass `-m` / `--message` to record an optional note on the server **Push History*
82
82
  | `be/views/` | Custom view authoring JSON |
83
83
  | `be/auto_increments/` | Auto-increment sequence JSON |
84
84
  | `be/field_types/` | Current-application field type JSON (storage and lookups) |
85
+ | `be/scheduled_jobs/` | Scheduled job (cron) JSON. Runs a PLV8 function or a Node module |
85
86
  | `be/scenarios/` | AnyInput scenarios (readable JSON) |
86
87
  | `be/capability_profiles/` | AnyInput capability profiles (`<type>.<name>.json`) |
87
88
  | `be/scenario_tests/` | AnyInput scenario test suites (`<suite_id>.json`), run with `anybuild test scenarios` |
88
89
 
89
90
  `meta/` is **read-only** (catalogs, generated schema dumps, default entity widgets, AI rule files). Do not put source entity/view JSON there.
90
91
 
91
- **Entities, views, auto-increments, field types, navigation, and portals**
92
+ **Entities, views, auto-increments, field types, scheduled jobs, navigation, and portals**
92
93
 
93
- - Files are simple JSON (`id` = thing UUID; `entity_id` / `view_id` / `auto_increment_id` / `field_id` / `navigation_id` / `application_id` stay inside the file as labels). View **sources** use target `id` (thing UUID), not `entity_id` / `view_id`, so they can point at objects in other applications. Format: `AGENTS.md` plus `meta/be/entities/RULES.md`, `meta/be/views/RULES.md`, `meta/be/auto_increments/RULES.md`, `meta/be/field_types/RULES.md`, `meta/ui/navigation/RULES.md`, and `meta/ui/portals/RULES.md` after clone/pull.
94
+ - Files are simple JSON (`id` = thing UUID; `entity_id` / `view_id` / `auto_increment_id` / `field_id` / `job_id` / `navigation_id` / `application_id` stay inside the file as labels). View **sources** use target `id` (thing UUID), not `entity_id` / `view_id`, so they can point at objects in other applications. Format: `AGENTS.md` plus `meta/be/entities/RULES.md`, `meta/be/views/RULES.md`, `meta/be/auto_increments/RULES.md`, `meta/be/field_types/RULES.md`, `meta/be/scheduled_jobs/RULES.md`, `meta/ui/navigation/RULES.md`, and `meta/ui/portals/RULES.md` after clone/pull.
94
95
  - New views are always **code mode** (SQL + named sources).
95
96
  - Custom **designer** views export as the same JSON. Editing one and pushing **converts it to code** on the server. Untouched designer views stay designer.
96
97
  - Default entity/component views are **not** under `be/views/` (they stay in `meta/`).
97
98
  - Default entity widgets (autogenerated list/create/edit) are **not** under `ui/lit/components/` (they stay in `meta/ui/lit/components/`). After pull, delete leftover copies from `ui/lit/components/` if they still appear as Added.
98
- - If two records share the same `entity_id` / `view_id` / `auto_increment_id` / `field_id` / `navigation_id` / `application_id`, files are `slug.json` and `slug.<thing_id>.json`. Push does **not** rename the live id from the filename.
99
- - Schema apply is one POST: auto-increments, then storage field types, then entities, then lookup field types, then views (source views before dependents). Each file saves and builds together. In a mixed push the order is widgets, then navigation, then portals, then auto-increments, then field types / schema.
99
+ - If two records share the same `entity_id` / `view_id` / `auto_increment_id` / `field_id` / `job_id` / `navigation_id` / `application_id`, files are `slug.json` and `slug.<thing_id>.json`. Push does **not** rename the live id from the filename.
100
+ - Schema apply is one POST: auto-increments, then storage field types, then entities, then lookup field types, then views (source views before dependents). Each file saves and builds together. In a mixed push the order is widgets and functions, then navigation, then portals, then auto-increments, then field types / schema, then scenarios. Scheduled jobs are a later POST, after those function files, so a PLV8 or Node module in the same push already exists.
100
101
  - After a schema, navigation, or portal push, run **`anybuild pull`**. Catalogs under `meta/be/catalog/` refresh only on pull.
101
102
 
102
- Checksums: `.json` under `ui/lit`, `ui/navigation`, `ui/portals`, `be/entities`, `be/views`, `be/auto_increments`, and `be/field_types` uses canonical JSON; other files use raw UTF-8.
103
+ Checksums: `.json` under `ui/lit`, `ui/navigation`, `ui/portals`, `be/entities`, `be/views`, `be/auto_increments`, `be/field_types`, and `be/scheduled_jobs` uses canonical JSON; other files use raw UTF-8.
103
104
 
104
105
  ## Commands
105
106
 
@@ -117,6 +118,10 @@ Checksums: `.json` under `ui/lit`, `ui/navigation`, `ui/portals`, `be/entities`,
117
118
  | `anybuild api <GET\|POST\|PATCH\|DELETE> <path> [--data <json> \| --data-file <file>]` | Call an entity endpoint (OData) of the project's host with the stored API key. `<path>` is relative to `/api/`. Body to stdout, status line to stderr, exit code 1 on HTTP errors |
118
119
  | `anybuild api-key set [--allow-writes \| --read-only]` | Store an API key for the project's host (hidden prompt, terminal only). Checks the key first; asks whether writes are allowed (default no) |
119
120
  | `anybuild api-key show` / `remove` | Show which key is stored (never the secret) / forget it |
121
+ | `anybuild api-key create --name <name> [--user <user_id>] [--scope <METHOD> <path> …] [--use]` | Create a key with the login session (security administrator). Omitted `--user` is `ai_agent`. Prints the secret once. `--use` stores it; writes stay off unless `--allow-writes`. Also `--expires`, `--unscoped` |
122
+ | `anybuild api-key list [--user <user_id>]` / `revoke <api_key_id>` | List a user's keys (default `ai_agent`) / revoke one. Never prints a secret |
123
+ | `anybuild api-key scope list \| add \| remove` | List or change what the stored key may call (`--id <api_key_id>` picks another). An unscoped key may already call everything |
124
+ | `anybuild user roles \| list \| show \| create \| activate \| deactivate \| role` | Maintain users with the login session. The server rejects the call unless that user is a security administrator |
120
125
 
121
126
  Also: `anybuild help`, `anybuild -v` / `--version`.
122
127
 
@@ -155,7 +160,80 @@ Good to know:
155
160
 
156
161
  - The key belongs to the host, not to one project: every project on that host on this machine uses it.
157
162
  - To replace the key or change the write setting, run `anybuild api-key set` again.
158
- - When you are done: `anybuild api-key remove`, then revoke the key on the Identities page.
163
+ - When you are done: `anybuild api-key remove`, then `anybuild api-key revoke <api_key_id>` (or revoke it on the Identities page).
164
+
165
+ #### Users, keys, and scopes
166
+
167
+ These commands use the login of a security administrator. Run them inside a project directory (the folder that contains `.ab/`). Anyone else is rejected.
168
+
169
+ Two different logins are involved:
170
+
171
+ - The **signed-in user** is the administrator. That login creates users, creates and revokes keys, and changes what a key is allowed to call.
172
+ - The **stored API key** is what `anybuild api` sends. `api-key scope` changes that key unless you pass `--id <api_key_id>`. The key itself does not have to belong to an administrator.
173
+
174
+ ##### Users
175
+
176
+ ```bash
177
+ anybuild user roles
178
+ anybuild user list
179
+ anybuild user show someone@example.com
180
+ anybuild user create --id someone@example.com --role "Regular User" --kind person
181
+ anybuild user create --id billing-bot --role "Regular User" --kind service
182
+ anybuild user role someone@example.com "Security Administrator"
183
+ anybuild user deactivate someone@example.com
184
+ anybuild user activate someone@example.com
185
+ ```
186
+
187
+ - `user roles` prints `role_id`, `role_name`, and whether the role is a security administrator or a system designer. The first column is the role id you pass to `create` and `role`. Quote it when it contains a space (`"Security Administrator"`).
188
+ - `user list` and `user show` print `user_id`, kind (`person` or `service`), role name, and whether the user is active.
189
+ - A **person** needs an email as `--id`. The password is typed at a hidden `Password:` prompt. There is no password flag, and the command fails when stdin is not a terminal. `--first` and `--last` are optional.
190
+ - A **service** account takes `--id` and `--role` only. It has no password. `--first` and `--last` are rejected.
191
+ - `user role` replaces the user's single role. `activate` and `deactivate` change whether the account can be used.
192
+
193
+ ##### API keys
194
+
195
+ `api-key create` and `api-key list` use the predefined user `ai_agent` when `--user` is omitted. If that user is missing or inactive, the command fails. Do not create `ai_agent` from the CLI. `--user <user_id>` selects someone else.
196
+
197
+ ```bash
198
+ anybuild api-key create --name agent --user someone@example.com \
199
+ --scope GET 'my_app/invoice' --scope GET 'my_app/invoice(*)'
200
+ anybuild api-key list --user someone@example.com
201
+ anybuild api-key revoke <api_key_id>
202
+ ```
203
+
204
+ - `create` prints the secret once, on stdout (`odk_<api_key_id>_<secret>`). It is not shown again. Progress stays on stderr.
205
+ - `--use` stores that secret for `anybuild api` with no prompt. Writes stay off unless `--allow-writes`. `--read-only` is the explicit alternative and applies only together with `--use`. Allowing save, submit, or delete on the key is not enough for `anybuild api` to send those calls: the stored key must also have writes turned on. `anybuild api-key set --allow-writes` does that, and asks for the secret again.
206
+ - `--expires <iso>` sets an expiry. `--unscoped` lets the key call every open endpoint, and cannot be combined with `--scope`.
207
+ - `list` prints `api_key_id`, name, whether the key is unscoped, and expiry. It never prints a secret. `revoke` takes that `api_key_id`, not the secret. Revoking does not forget a key already stored on this machine; `anybuild api-key remove` does that.
208
+
209
+ ##### What a key is allowed to call
210
+
211
+ A key is allowed to call specific actions on an entity: read, save, submit, and delete. Each action is named with the same method and path you would pass to `anybuild api`. The path is `<app>/<entity>`. Quote a path that contains `(*)`.
212
+
213
+ `(*)` means one existing record. Without it, the path means the list of records. Submit is the same path with `/submit` added.
214
+
215
+ | You want the key to | Pass these |
216
+ | --- | --- |
217
+ | Read the list and one record | `GET my_app/invoice` and `GET 'my_app/invoice(*)'` |
218
+ | Save a new record and change one | `POST my_app/invoice` and `PATCH 'my_app/invoice(*)'` |
219
+ | Submit the list and one record | `POST my_app/invoice/submit` and `POST 'my_app/invoice(*)/submit'` |
220
+ | Delete one record | `DELETE 'my_app/invoice(*)'` |
221
+
222
+ The entity must already be open for that action. If it is not, the command fails and names the missing call.
223
+
224
+ `scope list`, `scope add`, and `scope remove` change the stored key. `--id <api_key_id>` picks another key, using the id from `api-key list` (not the secret). `add` and `remove` take one or more method-and-path pairs. `remove` fails if the key was not allowed to make that call. The command then prints what the key is allowed to call.
225
+
226
+ ```bash
227
+ anybuild api-key scope list
228
+ anybuild api-key scope add \
229
+ GET my_app/invoice GET 'my_app/invoice(*)' \
230
+ POST my_app/invoice PATCH 'my_app/invoice(*)' \
231
+ POST my_app/invoice/submit POST 'my_app/invoice(*)/submit' \
232
+ DELETE 'my_app/invoice(*)'
233
+ anybuild api-key scope remove --id <api_key_id> DELETE 'my_app/invoice(*)'
234
+ ```
235
+
236
+ An unscoped key may already call every open endpoint. `scope list` says so, and `scope add` / `scope remove` leave the key unchanged.
159
237
 
160
238
  #### Calling
161
239
 
@@ -193,7 +271,7 @@ Run project commands (`pull`, `push`, `status`, `validate`) from inside a cloned
193
271
  ## Security
194
272
 
195
273
  - Sessions and API keys live in `~/.ab/` with restrictive file permissions on Unix. Do not share or commit that folder.
196
- - `anybuild api-key set` only runs in a terminal (hidden input), so a key is always stored by a person. The CLI never prints a stored key.
274
+ - `anybuild api-key set` only runs in a terminal (hidden input). `api-key create` prints a new secret once; `show` never prints a stored key. `create --use` stores that key without a prompt, with writes off unless `--allow-writes`.
197
275
  - On shared machines, run `anybuild logout <host-url>` when done.
198
276
  - Avoid `--debug` in shared or CI logs.
199
277
 
@@ -6,6 +6,8 @@ export declare function isWriteMethod(method: ApiMethod): boolean;
6
6
  export declare function isValidApiKey(value: string): boolean;
7
7
  /** odk_<key id>_… — the key id is not secret, the rest is never shown. */
8
8
  export declare function maskApiKey(value: string): string;
9
+ /** The public id between `odk_` and the secret. It is not a secret. */
10
+ export declare function apiKeyId(value: string): string;
9
11
  /**
10
12
  * The URL is always `<api_url>/api/<path>` of the project, so a stored key is only ever sent to that host.
11
13
  * `path` may be given with or without the leading `/api/`; it may carry a query string.
@@ -1 +1 @@
1
- {"version":3,"file":"entity-api.d.ts","sourceRoot":"","sources":["../../src/api/entity-api.ts"],"names":[],"mappings":"AAGA,8GAA8G;AAC9G,eAAO,MAAM,WAAW,6CAA8C,CAAC;AACvE,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAMrD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CASnE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAExD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGhD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA2BhE;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CASlE;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAsB,aAAa,CACjC,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,I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,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAsB,aAAa,CACjC,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,EACD,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC,aAAa,CAAC,CA8CxB;AAED,4FAA4F;AAC5F,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAYxD;AAED,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAYtE"}
@@ -23,6 +23,15 @@ export function maskApiKey(value) {
23
23
  const match = /^(odk_[A-Za-z0-9-]+)_/.exec(value);
24
24
  return match ? `${match[1]}_…` : "odk_…";
25
25
  }
26
+ /** The public id between `odk_` and the secret. It is not a secret. */
27
+ export function apiKeyId(value) {
28
+ const match = /^odk_([A-Za-z0-9-]+)_[A-Za-z0-9_-]+$/.exec(value);
29
+ const id = match?.[1];
30
+ if (!id) {
31
+ throw new AbCliError("CONFIG", "That is not an Anybuild API key (expected odk_<id>_<secret>).");
32
+ }
33
+ return id;
34
+ }
26
35
  /**
27
36
  * The URL is always `<api_url>/api/<path>` of the project, so a stored key is only ever sent to that host.
28
37
  * `path` may be given with or without the leading `/api/`; it may carry a query string.
@@ -1 +1 @@
1
- {"version":3,"file":"entity-api.js","sourceRoot":"","sources":["../../src/api/entity-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEvD,8GAA8G;AAC9G,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,O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AAC,IAAI,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC1D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,YAAY,CAAC,MAAqB;IAChD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAsD,CAAC;QAC5F,IAAI,MAAM,EAAE,KAAK,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC9D,OAAO,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ;gBAC1C,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE;gBACjD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QAC3B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,WAAW;IACb,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/commands/api-key.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA0GjD,eAAO,MAAM,MAAM,EAAE,cAoBpB,CAAC"}
1
+ {"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/commands/api-key.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAuajD,eAAO,MAAM,MAAM,EAAE,cAyCpB,CAAC"}
@@ -1,29 +1,130 @@
1
- import { isValidApiKey, maskApiKey, callEntityApi, errorMessage } from "../api/entity-api.js";
1
+ import { apiKeyId, callEntityApi, errorMessage, isValidApiKey, maskApiKey, parseApiMethod, } from "../api/entity-api.js";
2
2
  import { getApiKeyFromGlobal, removeApiKeyFromGlobal, upsertApiKeyInGlobal, } from "../config/global-config.js";
3
3
  import { loadProjectConfigFromCwd } from "../config/project-config.js";
4
4
  import { sessionKey } from "../config/session-key.js";
5
5
  import { AbCliError, CLI_PROGRAM } from "../errors.js";
6
+ import { createClientForCwd } from "../http/client.js";
7
+ import { postIdentity } from "../identity/identity-api.js";
6
8
  import { confirmYesNo } from "../io/confirm-yes.js";
7
9
  import { readSecretHidden } from "../io/read-credentials.js";
8
10
  import { logProgress } from "../progress.js";
9
- function usage() {
10
- console.error(`Usage:
11
- ${CLI_PROGRAM} api-key set [--allow-writes | --read-only] Store an API key for this project's environment (asks for it, hidden)
12
- ${CLI_PROGRAM} api-key show Show which key is stored (never the secret)
13
- ${CLI_PROGRAM} api-key remove Forget the stored key
11
+ const USAGE = `Usage:
12
+ ${CLI_PROGRAM} api-key set [--allow-writes | --read-only]
13
+ ${CLI_PROGRAM} api-key show
14
+ ${CLI_PROGRAM} api-key remove
15
+ ${CLI_PROGRAM} api-key create --name <name> [--user <user_id>] [--expires <iso>] [--unscoped] [--scope <METHOD> <path> ...] [--use] [--allow-writes | --read-only]
16
+ ${CLI_PROGRAM} api-key list [--user <user_id>]
17
+ ${CLI_PROGRAM} api-key revoke <api_key_id>
18
+ ${CLI_PROGRAM} api-key scope list [--id <api_key_id>]
19
+ ${CLI_PROGRAM} api-key scope add [--id <api_key_id>] <METHOD> <path> [<METHOD> <path> ...]
20
+ ${CLI_PROGRAM} api-key scope remove [--id <api_key_id>] <METHOD> <path> [<METHOD> <path> ...]
14
21
 
15
- The key is used by "${CLI_PROGRAM} api" for every project on this host. Before "set":
16
- 1. Identities page → open the identity (preferably a service account) → API keys → Create API key
17
- (short expiry, not unscoped). Copy the key; it is shown only once.
18
- 2. Open the key and tick the endpoints it may use (Read / Save / Submit / Delete), then Save scopes.
19
- Run "set" in the project folder, paste the key (nothing is shown) and press Enter.
20
- Allow writes only on development or test environments.`);
22
+ "set", "show", and "remove" only change the key stored for "${CLI_PROGRAM} api" on this host.
23
+ "create", "list", "revoke", and "scope" use the login session. The server rejects them unless that user is a security administrator.
24
+ Omitted --user is ai_agent. "scope" changes the stored key unless --id is set.
25
+ "create" prints the secret once. --use stores it for "${CLI_PROGRAM} api" with no prompt; writes stay off unless --allow-writes.
26
+ An unscoped key already reaches every route, so "scope" does not change it.
27
+ Run this inside a project directory.`;
28
+ function usage() {
29
+ console.error(USAGE);
30
+ }
31
+ function asObject(value, label) {
32
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
33
+ throw new AbCliError("HTTP", `${label} must be a JSON object.`);
34
+ }
35
+ return value;
36
+ }
37
+ function requireString(record, field, label) {
38
+ const value = record[field];
39
+ if (typeof value !== "string" || !value.trim()) {
40
+ throw new AbCliError("HTTP", `${label} is missing ${field}.`);
41
+ }
42
+ return value;
43
+ }
44
+ function requireBoolean(record, field, label) {
45
+ const value = record[field];
46
+ if (typeof value !== "boolean") {
47
+ throw new AbCliError("HTTP", `${label} field ${field} must be true or false.`);
48
+ }
49
+ return value;
50
+ }
51
+ function expiresText(record, label) {
52
+ const value = record.expires_at;
53
+ if (value == null) {
54
+ return "-";
55
+ }
56
+ if (typeof value !== "string" || !value.trim()) {
57
+ throw new AbCliError("HTTP", `${label} field expires_at must be a string or null.`);
58
+ }
59
+ return value;
21
60
  }
22
61
  function requireTerminal() {
23
62
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
24
63
  throw new AbCliError("CONFIG", `${CLI_PROGRAM} api-key set must be run by a person in a terminal (it asks for the key with hidden input).`);
25
64
  }
26
65
  }
66
+ function takeFlag(args, flag) {
67
+ const rest = [];
68
+ let value;
69
+ for (let i = 0; i < args.length; i += 1) {
70
+ const arg = args[i] ?? "";
71
+ if (arg === flag) {
72
+ const next = args[i + 1];
73
+ if (next === undefined || !next.trim() || next.startsWith("--")) {
74
+ throw new AbCliError("CONFIG", `${flag} requires a value.\n${USAGE}`);
75
+ }
76
+ if (value !== undefined) {
77
+ throw new AbCliError("CONFIG", `${flag} was given twice.\n${USAGE}`);
78
+ }
79
+ value = next.trim();
80
+ i += 1;
81
+ continue;
82
+ }
83
+ if (arg.startsWith(`${flag}=`)) {
84
+ const inline = arg.slice(flag.length + 1).trim();
85
+ if (!inline) {
86
+ throw new AbCliError("CONFIG", `${flag} requires a value.\n${USAGE}`);
87
+ }
88
+ if (value !== undefined) {
89
+ throw new AbCliError("CONFIG", `${flag} was given twice.\n${USAGE}`);
90
+ }
91
+ value = inline;
92
+ continue;
93
+ }
94
+ rest.push(arg);
95
+ }
96
+ return { value, rest };
97
+ }
98
+ function rejectUnknown(args) {
99
+ const unknown = args.filter((arg) => arg.startsWith("--"));
100
+ if (unknown.length > 0) {
101
+ throw new AbCliError("CONFIG", `Unknown option ${unknown.join(", ")}.\n${USAGE}`);
102
+ }
103
+ }
104
+ function parseScopePairs(args) {
105
+ rejectUnknown(args);
106
+ if (args.length === 0 || args.length % 2 !== 0) {
107
+ throw new AbCliError("CONFIG", `Each scope is a METHOD and a path.\n${USAGE}`);
108
+ }
109
+ const scopes = [];
110
+ for (let i = 0; i < args.length; i += 2) {
111
+ scopes.push({
112
+ method: parseApiMethod(args[i]),
113
+ path: (args[i + 1] ?? "").trim(),
114
+ });
115
+ if (!scopes[scopes.length - 1]?.path) {
116
+ throw new AbCliError("CONFIG", `Each scope is a METHOD and a path.\n${USAGE}`);
117
+ }
118
+ }
119
+ return scopes;
120
+ }
121
+ function storedKeyId(project) {
122
+ const entry = getApiKeyFromGlobal(sessionKey(project.api_url, project.environment));
123
+ if (!entry) {
124
+ throw new AbCliError("CONFIG", `No API key stored for ${project.api_url}. Pass --id, or create one with --use.`);
125
+ }
126
+ return apiKeyId(entry.api_key);
127
+ }
27
128
  async function setKey(flags) {
28
129
  const allowFlag = flags.includes("--allow-writes");
29
130
  const readOnlyFlag = flags.includes("--read-only");
@@ -40,8 +141,12 @@ async function setKey(flags) {
40
141
  if (!isValidApiKey(apiKey)) {
41
142
  throw new AbCliError("CONFIG", "That is not an Anybuild API key (expected odk_<id>_<secret>). Nothing was stored.");
42
143
  }
43
- // the key is checked before it is stored: 401 means the server does not accept it; 403 only means it has no scope on $metadata
44
144
  logProgress("Checking the key…");
145
+ await noteKeyCheck(project, apiKey);
146
+ const allowWrites = await resolveAllowWrites(project, allowFlag, readOnlyFlag);
147
+ console.log(storeKey(project, key, apiKey, allowWrites));
148
+ }
149
+ async function noteKeyCheck(project, apiKey) {
45
150
  const check = await callEntityApi({
46
151
  apiUrl: project.api_url,
47
152
  path: `${project.application_id}/$metadata`,
@@ -52,21 +157,28 @@ async function setKey(flags) {
52
157
  throw new AbCliError("AUTH_LOGIN", `The server rejected the key (${errorMessage(check) ?? "401"}). Nothing was stored.`);
53
158
  }
54
159
  if (check.status === 403) {
55
- logProgress(`Note: the key is valid but has no scope on ${project.application_id}/$metadata. That is fine unless you need $metadata; grant endpoint scopes on the Identities page.`);
160
+ logProgress(`Note: the key is valid but has no scope on ${project.application_id}/$metadata. That is fine unless you need $metadata.`);
56
161
  }
57
162
  else if (check.status >= 400) {
58
163
  logProgress(`Note: checking the key returned HTTP ${check.status} (${errorMessage(check) ?? check.statusText}).`);
59
164
  }
60
- let allowWrites = allowFlag;
61
- if (!allowFlag && !readOnlyFlag) {
62
- allowWrites = await confirmYesNo(`Allow writes (POST / PATCH / DELETE) with this key on ${project.api_url}? Only for development or test data. [y/N] `);
165
+ }
166
+ async function resolveAllowWrites(project, allowFlag, readOnlyFlag) {
167
+ if (allowFlag) {
168
+ return true;
63
169
  }
170
+ if (readOnlyFlag) {
171
+ return false;
172
+ }
173
+ return confirmYesNo(`Allow writes (POST / PATCH / DELETE) with this key on ${project.api_url}? Only for development or test data. [y/N] `);
174
+ }
175
+ function storeKey(project, key, apiKey, allowWrites) {
64
176
  upsertApiKeyInGlobal(key, {
65
177
  api_key: apiKey,
66
178
  allow_writes: allowWrites,
67
179
  saved_at: new Date().toISOString(),
68
180
  });
69
- console.log(`Stored ${maskApiKey(apiKey)} for ${project.api_url} (environment: ${project.environment}), ${allowWrites ? "reads and writes" : "read only"}.`);
181
+ return `Stored ${maskApiKey(apiKey)} for ${project.api_url} (environment: ${project.environment}), ${allowWrites ? "reads and writes" : "read only"}.`;
70
182
  }
71
183
  function showKey() {
72
184
  const project = loadProjectConfigFromCwd();
@@ -81,11 +193,200 @@ function removeKey() {
81
193
  const project = loadProjectConfigFromCwd();
82
194
  const removed = removeApiKeyFromGlobal(sessionKey(project.api_url, project.environment));
83
195
  console.log(removed
84
- ? `Removed the API key for ${project.api_url}. Revoke it on the Identities page if it is no longer needed.`
196
+ ? `Removed the API key for ${project.api_url}. Revoke it with "${CLI_PROGRAM} api-key revoke" if it is no longer needed.`
85
197
  : `No API key stored for ${project.api_url}.`);
86
198
  }
199
+ function printKeyLine(record) {
200
+ const id = requireString(record, "api_key_id", "API key");
201
+ const name = requireString(record, "key_name", "API key");
202
+ const unscoped = requireBoolean(record, "is_unscoped_key", "API key");
203
+ console.log(`${id}\t${name}\tunscoped=${String(unscoped)}\texpires=${expiresText(record, "API key")}`);
204
+ }
205
+ function printScopeLines(record) {
206
+ if (!Array.isArray(record.scopes)) {
207
+ throw new AbCliError("HTTP", "Scope list is missing scopes.");
208
+ }
209
+ if (record.scopes.length === 0) {
210
+ console.log("No scopes.");
211
+ return;
212
+ }
213
+ for (const item of record.scopes) {
214
+ const scope = asObject(item, "Scope");
215
+ const method = requireString(scope, "method", "Scope");
216
+ const path = requireString(scope, "path", "Scope");
217
+ console.log(`${method}\t${path}`);
218
+ }
219
+ }
220
+ function printUnscoped(record, label) {
221
+ if (record.is_unscoped_key !== true) {
222
+ return false;
223
+ }
224
+ const message = requireString(record, "message", label);
225
+ console.log(message);
226
+ return true;
227
+ }
228
+ async function createKey(args) {
229
+ const use = args.includes("--use");
230
+ const unscoped = args.includes("--unscoped");
231
+ const allowFlag = args.includes("--allow-writes");
232
+ const readOnlyFlag = args.includes("--read-only");
233
+ let rest = args.filter((arg) => arg !== "--use" && arg !== "--unscoped" && arg !== "--allow-writes" && arg !== "--read-only");
234
+ if (allowFlag && readOnlyFlag) {
235
+ throw new AbCliError("CONFIG", `Use either --allow-writes or --read-only.\n${USAGE}`);
236
+ }
237
+ if ((allowFlag || readOnlyFlag) && !use) {
238
+ throw new AbCliError("CONFIG", `--allow-writes and --read-only apply with --use.\n${USAGE}`);
239
+ }
240
+ const nameFlag = takeFlag(rest, "--name");
241
+ rest = nameFlag.rest;
242
+ const userFlag = takeFlag(rest, "--user");
243
+ rest = userFlag.rest;
244
+ const expiresFlag = takeFlag(rest, "--expires");
245
+ rest = expiresFlag.rest;
246
+ const scopes = [];
247
+ const leftover = [];
248
+ for (let i = 0; i < rest.length; i += 1) {
249
+ const arg = rest[i] ?? "";
250
+ if (arg === "--scope") {
251
+ const method = rest[i + 1];
252
+ const path = rest[i + 2];
253
+ if (method === undefined || path === undefined || method.startsWith("--") || path.startsWith("--") || !path.trim()) {
254
+ throw new AbCliError("CONFIG", `--scope requires a METHOD and a path.\n${USAGE}`);
255
+ }
256
+ scopes.push({ method: parseApiMethod(method), path: path.trim() });
257
+ i += 2;
258
+ continue;
259
+ }
260
+ leftover.push(arg);
261
+ }
262
+ rejectUnknown(leftover);
263
+ if (leftover.length > 0) {
264
+ throw new AbCliError("CONFIG", USAGE);
265
+ }
266
+ if (!nameFlag.value) {
267
+ throw new AbCliError("CONFIG", `--name requires a value.\n${USAGE}`);
268
+ }
269
+ if (unscoped && scopes.length > 0) {
270
+ throw new AbCliError("CONFIG", "An unscoped API key does not take scopes.");
271
+ }
272
+ const body = {
273
+ command: "create",
274
+ key_name: nameFlag.value,
275
+ };
276
+ if (userFlag.value) {
277
+ body.user_id = userFlag.value;
278
+ }
279
+ if (expiresFlag.value) {
280
+ body.expires_at = expiresFlag.value;
281
+ }
282
+ if (unscoped) {
283
+ body.is_unscoped_key = true;
284
+ }
285
+ if (scopes.length > 0) {
286
+ body.scopes = scopes;
287
+ }
288
+ const project = loadProjectConfigFromCwd();
289
+ const client = await createClientForCwd();
290
+ const created = asObject(await postIdentity(client, "key", body), "Created API key");
291
+ const secret = requireString(created, "api_key", "Created API key");
292
+ const id = requireString(created, "api_key_id", "Created API key");
293
+ requireString(created, "thing_id", "Created API key");
294
+ if (!isValidApiKey(secret)) {
295
+ throw new AbCliError("HTTP", "Created API key secret is not an Anybuild API key.");
296
+ }
297
+ if (apiKeyId(secret) !== id) {
298
+ throw new AbCliError("HTTP", "Created API key id does not match the secret.");
299
+ }
300
+ console.log(secret);
301
+ logProgress(`Created API key ${id} (${nameFlag.value}).`);
302
+ if (!use) {
303
+ return;
304
+ }
305
+ logProgress("Checking the key…");
306
+ await noteKeyCheck(project, secret);
307
+ logProgress(storeKey(project, sessionKey(project.api_url, project.environment), secret, allowFlag));
308
+ }
309
+ async function listKeys(args) {
310
+ const userFlag = takeFlag(args, "--user");
311
+ rejectUnknown(userFlag.rest);
312
+ if (userFlag.rest.length > 0) {
313
+ throw new AbCliError("CONFIG", USAGE);
314
+ }
315
+ const body = { command: "list" };
316
+ if (userFlag.value) {
317
+ body.user_id = userFlag.value;
318
+ }
319
+ loadProjectConfigFromCwd();
320
+ const client = await createClientForCwd();
321
+ const listed = asObject(await postIdentity(client, "key", body), "API key list");
322
+ const userId = requireString(listed, "user_id", "API key list");
323
+ if (!Array.isArray(listed.keys)) {
324
+ throw new AbCliError("HTTP", "API key list is missing keys.");
325
+ }
326
+ console.log(userId);
327
+ if (listed.keys.length === 0) {
328
+ console.log("No API keys.");
329
+ return;
330
+ }
331
+ for (const item of listed.keys) {
332
+ printKeyLine(asObject(item, "API key"));
333
+ }
334
+ }
335
+ async function revokeKey(args) {
336
+ rejectUnknown(args);
337
+ const apiKey = args[0]?.trim();
338
+ if (!apiKey || args.length !== 1) {
339
+ throw new AbCliError("CONFIG", USAGE);
340
+ }
341
+ loadProjectConfigFromCwd();
342
+ const client = await createClientForCwd();
343
+ const revoked = asObject(await postIdentity(client, "key", { command: "revoke", api_key_id: apiKey }), "Revoke API key");
344
+ if (revoked.revoked !== true) {
345
+ throw new AbCliError("HTTP", "Revoke API key did not report revoked.");
346
+ }
347
+ const id = requireString(revoked, "api_key_id", "Revoke API key");
348
+ console.log(`Revoked ${id}.`);
349
+ }
350
+ async function scopeCommand(args) {
351
+ const [action, ...rest] = args;
352
+ if (action !== "list" && action !== "add" && action !== "remove") {
353
+ throw new AbCliError("CONFIG", USAGE);
354
+ }
355
+ const idFlag = takeFlag(rest, "--id");
356
+ const project = loadProjectConfigFromCwd();
357
+ const targetId = idFlag.value ?? storedKeyId(project);
358
+ const body = { command: action, api_key_id: targetId };
359
+ if (action === "list") {
360
+ rejectUnknown(idFlag.rest);
361
+ if (idFlag.rest.length > 0) {
362
+ throw new AbCliError("CONFIG", USAGE);
363
+ }
364
+ }
365
+ else {
366
+ body.scopes = parseScopePairs(idFlag.rest);
367
+ }
368
+ const client = await createClientForCwd();
369
+ const result = asObject(await postIdentity(client, "scope", body), "API key scope");
370
+ requireString(result, "api_key_id", "API key scope");
371
+ if (printUnscoped(result, "API key scope")) {
372
+ if (action !== "list" && result.changed !== false) {
373
+ throw new AbCliError("HTTP", "An unscoped API key scope change did not report changed: false.");
374
+ }
375
+ return;
376
+ }
377
+ printScopeLines(result);
378
+ }
87
379
  export const apiKey = async (args) => {
88
380
  const [sub, ...flags] = args;
381
+ if (sub === "--help" || sub === "-h" || sub === undefined) {
382
+ if (sub === "--help" || sub === "-h") {
383
+ console.log(USAGE);
384
+ return;
385
+ }
386
+ usage();
387
+ process.exitCode = 1;
388
+ return;
389
+ }
89
390
  try {
90
391
  if (sub === "set") {
91
392
  await setKey(flags);
@@ -96,6 +397,18 @@ export const apiKey = async (args) => {
96
397
  else if (sub === "remove" && flags.length === 0) {
97
398
  removeKey();
98
399
  }
400
+ else if (sub === "create") {
401
+ await createKey(flags);
402
+ }
403
+ else if (sub === "list") {
404
+ await listKeys(flags);
405
+ }
406
+ else if (sub === "revoke") {
407
+ await revokeKey(flags);
408
+ }
409
+ else if (sub === "scope") {
410
+ await scopeCommand(flags);
411
+ }
99
412
  else {
100
413
  usage();
101
414
  process.exitCode = 1;