@nylorun/admin 0.8.0-beta → 0.10.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,67 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.0-beta
4
+
5
+ ### Major Changes
6
+
7
+ - bd478ee: **Subject tokens, browser keys and derived principals leave open source (F9 I3, protocol 7).** Upgrade these with the Runtime: they speak protocol 7, which this Runtime serves beside 4, 5 and 6; protocol 6 clients keep working on every route that remains. Browsers and apps present a trusted issuer's token (F9 I2), servers an operator key (F9 I1), and a person's own credentials come from the operator's credential resolver (F9 C1). See MIGRATION.md.
8
+
9
+ - **Breaking (`@nylorun/runtime`, `@nylorun/core`): subject tokens are gone.** `POST /v1/tokens`, `POST /v1/access/revocations`, subject-token verification, revocation epochs and the `subject.revoked` stream signal are removed; the routes answer `404`, and a JWT no trusted issuer signed is the opaque `404`. A stream opened with a token now ends only at its expiry (`event: nylorun.closed`, reason `token_expired`; `StreamClosedFrame` loses `revoked`). Migration `0010_oss_auth_removals` drops the `subject_epochs`, `subject_usage` and `publishable_keys` tables. The `token` caller is a trusted issuer's token only: it loses `role`, `limits` and `epoch`, and `issuer` is always set; `GET /v1/me` no longer reports `via: token`. Core drops `SUBJECT_TOKEN_TYPE`, `SUBJECT_TOKEN_AUDIENCE`, `subjectTokenIssuer` (the Runtime's own tokens use `tenantTokenIssuer`, same value), `CreateTokenRequest`/`Response`, `RevokeSubject*`, `SubjectTokenClaims`, `TOKEN_TTL_MIN_SECONDS` and `TOKEN_TTL_DEFAULT_SECONDS`; `TOKEN_SCOPES` is `agents:read`, `sessions:own`, `sandboxes:write`.
10
+ - **Breaking (`@nylorun/runtime`, `@nylorun/core`): the access policy and role limits are gone.** `GET`/`PUT /v1/access/policy` answer `404`, a turn is never refused with `429 limit_exceeded` for a role (limit requests at your proxy), and an existing `access.policy` setting is ignored. Core drops `AccessPolicy*`, `AccessRole*`, `RoleLimits*`, `DEFAULT_ACCESS_POLICY`, `PutAccessPolicyRequest` and `ROLE_NAME_PATTERN`.
11
+ - **Breaking (`@nylorun/runtime`, `@nylorun/core`): publishable keys and the Runtime's CORS are gone.** `/v1/access/publishable-keys*` answer `404`, `Nylorun-Key` is ignored, `NYLORUN_BROWSER_ACCESS` and `browserAccess` (host.json, `createHost`, `startEphemeralRuntime`) are removed, and the Runtime sends no CORS headers. A request with `Origin` reaches the Tenant routes of the public listener with no toggle: a trusted issuer's token is served, an application key or delivery token is `403 origin_rejected`; admin routes, `/health`, `/ready` and the operator listener still refuse `Origin`. Any `OPTIONS` request is `204` with `Allow` and no CORS header: the operator's proxy answers preflights. Route declarations lose `browser` (`x-nylorun-browser` leaves the OpenAPI document) and the `publishable` credential; the token security scheme is `issuerToken`. Core drops `PUBLISHABLE_KEY_HEADER`, `PUBLISHABLE_KEY_PATTERN`, `PUBLISHABLE_KEY_ID_PATTERN`, `tenantOfPublishableKey`, `newPublishableKey`, `newPublishableKeyId`, `PublishableKey*`, `OriginEntrySchema`, `originAllowed` and `LOOPBACK_ORIGIN_WILDCARDS`.
12
+ - **Breaking (`@nylorun/runtime`, `@nylorun/core`, `@nylorun/agents`): vault routes are application-only, and `vaults:own` is retired.** Every `/v1/vaults` route takes an application key acting for no one (operator keys, Studio); a request acting for a subject or a trusted issuer's token gets `403 scope_required`. `vaults:own` leaves `SUBJECT_SCOPES`, `TOKEN_SCOPES` and the issuer scopes; `Nylorun-Scopes` may still name it and it grants nothing. Existing user vaults stay attachable to their own owner's sessions. `client.createVault` takes `{ scope: "installation" }` or `ownerUserId`, and `client.listVaults()` takes an optional owner.
13
+ - **Breaking (`@nylorun/runtime`, `@nylorun/core`, `@nylorun/admin`, `nylorun`): derived principals are gone.** Only Studio's key is derived from the admin key. `NYLORUN_DERIVED_PRINCIPALS` is ignored and no longer written, `hostPrincipals` takes no `derived`, `startEphemeralRuntime` no `derivedPrincipals`, and `@nylorun/admin` drops `deriveTenantKey`, `PROJECT_PRINCIPAL_ID` and `admin.deriveTenantKey`. Keys an earlier Host derived stay in the database and keep working as ordinary keys; replace them with operator keys. Core renames `DERIVED_PRINCIPAL_ID_PATTERN` to `APPLICATION_KEY_ID_PATTERN`.
14
+ - **Breaking (`@nylorun/agents`):** `createTokenEndpoint`, `createBrowserClient` and the `@nylorun/agents/browser` entry, `client.tokens`, `TokensClient`, `PublishableKeysClient`, `client.access.getPolicy`/`putPolicy`/`revokeSubject`/`publishableKeys` and `Destination.publishableKey` are removed. `client.access.signingKeys` and `client.access.jwks()` stay, and `Destination.token` takes a trusted issuer's tokens.
15
+ - **Breaking (`@nylorun/cli`):** `nylo access policy|keys|revoke|token` are removed and name what replaces them; `nylo access signing-keys list|rotate|revoke` stays.
16
+ - **Breaking (`@nylorun/core`, `@nylorun/agents`, `@nylorun/studio`): the Studio embed message `open.babai` is now `open.session`** (`{ sessionId }`): it asks the embedding app to open that session in its own UI. Studio sends no such message itself.
17
+ - **Breaking (`nylorun`): Studio embedding is opt-in.** No origin may frame Studio by default; list your app's origins with `nylorun start --studio-embed-origin <origin>`. A Tenant's `.env` from an earlier nylorun keeps the origins it had until `--studio-embed-origin-reset`.
18
+ - `PROTOCOL_VERSION` is 7 and `HOST_PROTOCOL` 4–7; the Host features `subject-tokens`, `browser-access` and `derived-principals` are removed. `@nylorun/studio` and `@nylorun/create-agent` speak protocol 7.
19
+
20
+ ### Minor Changes
21
+
22
+ - 5cfaed9: **Operator keys, and project links on them (F9 I1).** The Admin API manages the Tenant's application keys by name: `PUT /v1/admin/keys/{id}` creates a key or rotates it and returns it once, `GET /v1/admin/keys` lists every key's id, role and issue time (never the keys), and `DELETE /v1/admin/keys/{id}` removes one. A rotated or deleted key stops authenticating on its next request. Ids follow `^[a-z][a-z0-9-]{0,31}$`; `studio` (derived from the admin key) is refused. Keys keep today's format (64 hex) and only their SHA-256 is stored, in the existing principals table (no migration). Host feature `operator-keys` (additive, protocol unchanged); core adds the `OperatorKey`, `ListOperatorKeysResponse`, `PutOperatorKeyResponse` and `DeleteOperatorKeyResponse` schemas.
23
+
24
+ - `@nylorun/admin`: `admin.keys.put(id)`, `admin.keys.list()` and `admin.keys.delete(id)`; they refuse with `incompatible_host` when the Host lacks `operator-keys`.
25
+ - `nylorun key put|list|rm <id>` manages a running local Tenant's keys; `put` prints the key once on stdout.
26
+ - `nylorun start` no longer derives the project's key. It keeps `.nylorun/credentials.json` while its key still reaches the Tenant (one authenticated read); otherwise it gives the project the operator key `project`, which the Host root keeps in `project-credentials.json` (0600) so every checkout linked to the Tenant shares it. An existing derived project key keeps working and is adopted.
27
+ - `nylorun sandbox` uses the linked project's key, or the operator key `cli` it puts once and keeps in `<Host root>/cli-credentials.json` (0600).
28
+ - The ephemeral Runtime (`startEphemeralRuntime`) no longer registers the derived `project` principal; pass `derivedPrincipals: ["project"]` to keep it. Derived principals (`NYLORUN_DERIVED_PRINCIPALS`, `deriveTenantKey`) still work on a Host.
29
+
30
+ ### Patch Changes
31
+
32
+ - Pin core to the tested release.
33
+ - Updated dependencies [8773586]
34
+ - Updated dependencies [e1bfb4b]
35
+ - Updated dependencies [5cfaed9]
36
+ - Updated dependencies [bd478ee]
37
+ - Updated dependencies [c0b604e]
38
+ - @nylorun/core@0.13.0-beta
39
+
40
+ ## 0.9.0-beta
41
+
42
+ ### Major Changes
43
+
44
+ - b352feb: **File artifacts, message parts and capability links (protocol 6).** Upgrade these with the Runtime: they speak protocol 6, which this Runtime serves beside 4 and 5. See MIGRATION.md.
45
+
46
+ - **`@nylorun/runtime`: file artifacts.** A file is an artifact: an `af_` id, a name and numbered immutable versions, with rows in the new `artifacts` and `artifact_versions` tables (migration `0004_artifacts`) and bytes in the Object store (`BlobStore`). `POST /v1/artifacts?name=&sessionId=` uploads a file in one streamed request and `POST /v1/artifacts/{id}/versions` adds a version, within the Tenant's limits (`GET`/`PUT /v1/tenant/artifacts`: 100 MiB per file and 10 GiB in all by default); a body past either is `413 limit_exceeded`, refused mid-stream with nothing stored. `GET /v1/artifacts` lists them (by session), `GET /v1/artifacts/{id}` reads one with its versions, `GET /v1/artifacts/{id}/versions/{n|latest}/content` downloads through the Runtime with HTTP Range (`206`, `Content-Range`, `416`), and `DELETE /v1/artifacts/{id}` deletes it with its bytes. A session's artifacts go with it on a sessions reset, and appear in its history as `artifact.created`, `artifact.version.created` and `artifact.deleted` (new in the event catalog). A subject reaches only the artifacts of their own sessions.
47
+ - **`@nylorun/runtime`: capability links.** `POST /v1/artifacts/{id}/links` mints a short-lived path, `/v1/artifact-links/<token>`, that downloads one version (with Range) with no credential and no `Nylorun-Protocol`: an ES256 JWT (`typ: nylorun-artifact+jwt`) signed with the Tenant's signing key, at most 15 minutes, and dead once the artifact is deleted. The Host logs its path without the token.
48
+ - **Breaking (`@nylorun/core`, `@nylorun/runtime`): message `parts`.** A user message may carry `parts`: `text`, and `file` by `artifactId` (and `version`, else the latest, pinned when the message is accepted). Model-gate reads the file from the Object store: an image goes to the model as image input, a text file as text, and any other file fails the call (`invalid_request`). The record and the transcript hold only the reference. The gateway builds its `BlobStore` from `NYLORUN_OBJECT_STORE_*` (the Tenant's `fs` store without it). `PROTOCOL_VERSION` is 6; `HOST_PROTOCOL` is 4–6 and protocol 6 clients require the feature `artifacts`.
49
+ - **`@nylorun/runtime`: `save_artifact`.** A session with a sandbox gets the `nylorun.artifacts` capability, whose `save_artifact` tool saves a sandbox file (`path`) or text (`content`) as an artifact of the session, carrying the turn and tool call on its event.
50
+ - **Breaking (`@nylorun/runtime`): `MediaStore` is removed.** `MediaStore` and `localMedia` leave `@nylorun/runtime/node`, and `piModel` takes `files` (a resolver from an artifact reference to its bytes) instead of `media`; images are file artifacts. The image checks (`decodeImageBase64`, `validateImageBytes`, `IMAGE_MEDIA_TYPES`, `MAX_IMAGE_BYTES`) stay.
51
+ - **`@nylorun/agents`:** `client.artifacts` (`upload`, `uploadVersion`, `list`, `get`, `download` with a range, `link`, `delete`), also on `BrowserClient`, and `session.inputParts(parts)`. A request with a body of its own type keeps it.
52
+ - `@nylorun/admin`, `@nylorun/cli`, `nylorun`, `@nylorun/studio`: speak protocol 6.
53
+
54
+ ### Patch Changes
55
+
56
+ - Pin core to the tested release.
57
+ - Updated dependencies [b352feb]
58
+ - Updated dependencies [6077272]
59
+ - Updated dependencies [b6bf1f5]
60
+ - Updated dependencies [8ed4ea6]
61
+ - Updated dependencies [678e085]
62
+ - Updated dependencies [926711b]
63
+ - @nylorun/core@0.12.0-beta
64
+
3
65
  ## 0.8.0-beta
4
66
 
5
67
  ### Minor Changes
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # @nylorun/admin
2
2
 
3
3
  Admin API client for a Runtime installation: its status, with the one Tenant it
4
- serves, and the keys the admin key derives. Depends only on `@nylorun/core`.
4
+ serves, its operator keys, and the Studio key the admin key derives. Depends only on
5
+ `@nylorun/core`.
5
6
  Requires Node 24+. Vocabulary: [runtime/src/CONTEXT.md](../runtime/src/CONTEXT.md).
6
7
 
7
8
  ```ts
@@ -21,21 +22,26 @@ are no Tenant routes: `createTenant`, `listTenants`, `getTenant` and
21
22
  When the Tenant cannot be opened, `status.tenant.state` is `unavailable` and
22
23
  `cause` names why (`schema-too-new`, `kek-missing`, `database-layout-old`, …).
23
24
 
24
- Whoever holds the admin key can derive the keys of the Tenant's derived
25
- principals and of its Studio principal, so those clients store no key:
25
+ Operator keys (Host feature `operator-keys`) are the Tenant's revocable
26
+ application keys, managed by name. `put` creates a key or rotates it and returns
27
+ it once; a rotated or deleted key stops authenticating on its next request.
28
+ Ids match `^[a-z][a-z0-9-]{0,31}$`; `studio` is refused:
26
29
 
27
30
  ```ts
28
- const key = admin.deriveTenantKey(tenant.id!, "project");
29
- // deriveTenantKey(adminKey, tenantId, principalId) and
30
- // deriveStudioToken(adminKey, tenantId) are exported too.
31
+ const { key } = await admin.keys.put("backend"); // { id, role, createdAt, key, rotated }
32
+ await admin.keys.list(); // [{ id, role, createdAt }], never the keys
33
+ await admin.keys.delete("backend"); // true when it existed
31
34
  ```
32
35
 
33
- The Host registers the derived principals it is configured with
34
- (`NYLORUN_DERIVED_PRINCIPALS`, default `project`; Babai uses `project,babai`)
35
- when it creates its Tenant, and `studio` always. Ids match
36
- `^[a-z][a-z0-9-]{0,31}$`; `studio` is reserved. Only each key's hash is stored,
37
- so rotating the admin key rotates every derived key. `nylorun start` writes the
38
- `project` key into a Project's `.nylorun/credentials.json`.
36
+ `nylorun start` links a Project with the operator key `project`, and
37
+ `nylorun key put|list|rm` does the same from a terminal.
38
+
39
+ The one key the admin key derives is Studio's (`deriveStudioToken(adminKey,
40
+ tenantId)`): the Host registers `studio` by hash when it creates its Tenant, so
41
+ Studio, and an app embedding it, stores no key, and rotating the admin key
42
+ rotates it. Every other client holds an operator key. Since protocol 7 no other
43
+ key is derived; a key an earlier Host derived stays valid as an ordinary key
44
+ until you replace it with `admin.keys.put(<its id>)`.
39
45
 
40
46
  Local Host resolution reads `host.json` and `host-credentials.json` from the
41
47
  Host root: `options.home`, else `NYLORUN_HOME`, else the Tenant's Host root
@@ -52,8 +58,7 @@ Tenant.
52
58
 
53
59
  Errors are `AdminError` with a registry `code` from `@nylorun/core`
54
60
  (`ERROR_CODES`). Re-exports: `PROTOCOL_FEATURES`, `ERROR_CODES`,
55
- `compareVersions`, `deriveStudioToken`, `deriveTenantKey`, `tenantHostRoot`,
56
- `PROJECT_PRINCIPAL_ID`.
61
+ `compareVersions`, `deriveStudioToken`, `tenantHostRoot`, `OPERATOR_KEYS_FEATURE`.
57
62
 
58
63
  Developer applications do **not** depend on this package — only managing
59
64
  clients (CLI, desktop Runtime panel, CI) do.
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type AdminStatus } from "@nylorun/core/contracts";
1
+ import { type AdminStatus, type OperatorKey, type PutOperatorKeyResponse } from "@nylorun/core/contracts";
2
2
  export type AdminSource = "options" | "environment" | "local-host";
3
3
  export interface ResolvedAdmin {
4
4
  /** The Host's Tenant API URL (what a Project link names). */
@@ -29,25 +29,39 @@ export declare function tenantHostRoot(name: string): string;
29
29
  * Resolve Admin API connection once: options → environment → local Host.
30
30
  */
31
31
  export declare function resolveAdminConnection(options?: AdminConnectionOptions): ResolvedAdmin;
32
+ /** The Host feature `/v1/admin/keys` needs. */
33
+ export declare const OPERATOR_KEYS_FEATURE = "operator-keys";
34
+ /** The Tenant's operator keys (Host feature `operator-keys`), managed by name. */
35
+ export interface AdminKeys {
36
+ /**
37
+ * Creates key `id` (`^[a-z][a-z0-9-]{0,31}$`), or rotates it: the old key stops
38
+ * authenticating at once. The key is in the answer this once. `studio` is refused.
39
+ */
40
+ put(id: string): Promise<PutOperatorKeyResponse>;
41
+ /** Every key of the Tenant by id, with its role and when it was issued; never the keys. */
42
+ list(): Promise<OperatorKey[]>;
43
+ /** Deletes key `id`: true when it existed. `studio` is refused. */
44
+ delete(id: string): Promise<boolean>;
45
+ }
32
46
  export declare class AdminClient {
33
47
  /** The Host's Tenant API URL. */
34
48
  readonly url: string;
35
49
  /** Where Admin API requests go: the operator listener, or `url` on a single-port Host. */
36
50
  readonly adminUrl: string;
37
51
  readonly source: AdminSource;
52
+ /** The Tenant's operator keys. */
53
+ readonly keys: AdminKeys;
38
54
  private readonly key;
39
55
  private compatible;
56
+ /** The features the Host's `/health` advertised. */
57
+ private features;
40
58
  constructor(resolved: ResolvedAdmin);
59
+ /** Throws `incompatible_host` when the Host does not advertise `feature`. */
60
+ private requireFeature;
41
61
  private clearCompatibilityCache;
42
62
  private adminHeaders;
43
63
  private ensureCompatible;
44
64
  private request;
45
65
  private json;
46
66
  status(): Promise<AdminStatus>;
47
- /**
48
- * The key of derived principal `principalId` on `tenantId`, from this client's admin key.
49
- * Valid when the Host registered that principal (`NYLORUN_DERIVED_PRINCIPALS`, default
50
- * `project`) on its Tenant.
51
- */
52
- deriveTenantKey(tenantId: string, principalId: string): string;
53
67
  }
package/dist/client.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { readFileSync, realpathSync, statSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { dirname, join, parse, resolve } from "node:path";
4
- import { AdminStatusSchema, ProjectLinkFileSchema, RejectedResponseSchema, } from "@nylorun/core/contracts";
4
+ import { AdminStatusSchema, DeleteOperatorKeyResponseSchema, ListOperatorKeysResponseSchema, ProjectLinkFileSchema, PutOperatorKeyResponseSchema, RejectedResponseSchema, } from "@nylorun/core/contracts";
5
5
  import { PROTOCOL_FEATURES, PROTOCOL_HEADER, PROTOCOL_VERSION, checkCompatibility, } from "@nylorun/core/compatibility";
6
- import { deriveTenantKey } from "./derived-credentials.js";
7
6
  import { AdminError } from "./errors.js";
8
7
  function env(name) {
9
8
  const value = process.env[name];
@@ -238,19 +237,56 @@ async function readBody(response) {
238
237
  return text;
239
238
  }
240
239
  }
240
+ /** The Host feature `/v1/admin/keys` needs. */
241
+ export const OPERATOR_KEYS_FEATURE = "operator-keys";
241
242
  export class AdminClient {
242
243
  /** The Host's Tenant API URL. */
243
244
  url;
244
245
  /** Where Admin API requests go: the operator listener, or `url` on a single-port Host. */
245
246
  adminUrl;
246
247
  source;
248
+ /** The Tenant's operator keys. */
249
+ keys;
247
250
  key;
248
251
  compatible = false;
252
+ /** The features the Host's `/health` advertised. */
253
+ features = [];
249
254
  constructor(resolved) {
250
255
  this.url = resolved.url;
251
256
  this.adminUrl = resolved.adminUrl ?? resolved.url;
252
257
  this.source = resolved.source;
253
258
  this.key = resolved.key;
259
+ const path = (id) => `/v1/admin/keys/${encodeURIComponent(id)}`;
260
+ this.keys = {
261
+ put: async (id) => {
262
+ await this.requireFeature(OPERATOR_KEYS_FEATURE);
263
+ return PutOperatorKeyResponseSchema.parse(await this.json(path(id), "PUT"));
264
+ },
265
+ list: async () => {
266
+ await this.requireFeature(OPERATOR_KEYS_FEATURE);
267
+ return ListOperatorKeysResponseSchema.parse(await this.json("/v1/admin/keys"))
268
+ .keys;
269
+ },
270
+ delete: async (id) => {
271
+ await this.requireFeature(OPERATOR_KEYS_FEATURE);
272
+ try {
273
+ DeleteOperatorKeyResponseSchema.parse(await this.json(path(id), "DELETE"));
274
+ return true;
275
+ }
276
+ catch (error) {
277
+ // A missing key; an unknown route is the opaque 404 without this message.
278
+ if (error instanceof AdminError && error.status === 404 && error.message === `No key ${id}`)
279
+ return false;
280
+ throw error;
281
+ }
282
+ },
283
+ };
284
+ }
285
+ /** Throws `incompatible_host` when the Host does not advertise `feature`. */
286
+ async requireFeature(feature) {
287
+ await this.ensureCompatible();
288
+ if (!this.features.includes(feature))
289
+ throw new AdminError("incompatible_host", `The Host does not serve ${feature} (Host feature ${feature}): update it.`);
254
290
  }
255
291
  clearCompatibilityCache() {
256
292
  this.compatible = false;
@@ -289,6 +325,7 @@ export class AdminClient {
289
325
  : `Host is missing required features: ${result.missing.join(", ")}`;
290
326
  throw new AdminError("incompatible_host", `Incompatible Host: ${detail}`, { details: result });
291
327
  }
328
+ this.features = protocol.features;
292
329
  this.compatible = true;
293
330
  }
294
331
  async request(path, init = {}, options = {}) {
@@ -335,12 +372,4 @@ export class AdminClient {
335
372
  const body = await this.json("/v1/admin/status");
336
373
  return AdminStatusSchema.parse(body);
337
374
  }
338
- /**
339
- * The key of derived principal `principalId` on `tenantId`, from this client's admin key.
340
- * Valid when the Host registered that principal (`NYLORUN_DERIVED_PRINCIPALS`, default
341
- * `project`) on its Tenant.
342
- */
343
- deriveTenantKey(tenantId, principalId) {
344
- return deriveTenantKey(this.key, tenantId, principalId);
345
- }
346
375
  }
@@ -1,20 +1,7 @@
1
1
  /**
2
2
  * Deterministic Studio key for one Tenant, derived from the admin key.
3
3
  * Same admin key and Tenant always produce the same key. Studio derives it in
4
- * memory; the Tenant stores only its hash, as principal `studio`.
4
+ * memory; the Tenant stores only its hash, as principal `studio`. It is the only
5
+ * derived key: every other application key is an operator key (`admin.keys.put`).
5
6
  */
6
7
  export declare function deriveStudioToken(adminKey: string, tenantId: string): string;
7
- /**
8
- * The derived principal that Projects use. The Host registers it on its Tenant by default
9
- * (`NYLORUN_DERIVED_PRINCIPALS`), and `nylorun start` derives its key from the Tenant's admin
10
- * key into the Project's `.nylorun/credentials.json`.
11
- */
12
- export declare const PROJECT_PRINCIPAL_ID = "project";
13
- /**
14
- * Deterministic key of a derived principal (`principalId`, e.g. `babai`) on one Tenant,
15
- * derived from the admin key. The Tenant stores only its hash, registered when the Host creates
16
- * its Tenant with the principals it is configured with (`NYLORUN_DERIVED_PRINCIPALS`, feature
17
- * `derived-principals`); the client recomputes the key when it needs it and stores nothing.
18
- * Rotating the admin key rotates every derived key.
19
- */
20
- export declare function deriveTenantKey(adminKey: string, tenantId: string, principalId: string): string;
@@ -2,7 +2,8 @@ import { createHmac } from "node:crypto";
2
2
  /**
3
3
  * Deterministic Studio key for one Tenant, derived from the admin key.
4
4
  * Same admin key and Tenant always produce the same key. Studio derives it in
5
- * memory; the Tenant stores only its hash, as principal `studio`.
5
+ * memory; the Tenant stores only its hash, as principal `studio`. It is the only
6
+ * derived key: every other application key is an operator key (`admin.keys.put`).
6
7
  */
7
8
  export function deriveStudioToken(adminKey, tenantId) {
8
9
  const message = Buffer.concat([
@@ -14,28 +15,3 @@ export function deriveStudioToken(adminKey, tenantId) {
14
15
  .update(message)
15
16
  .digest("hex");
16
17
  }
17
- /**
18
- * The derived principal that Projects use. The Host registers it on its Tenant by default
19
- * (`NYLORUN_DERIVED_PRINCIPALS`), and `nylorun start` derives its key from the Tenant's admin
20
- * key into the Project's `.nylorun/credentials.json`.
21
- */
22
- export const PROJECT_PRINCIPAL_ID = "project";
23
- /**
24
- * Deterministic key of a derived principal (`principalId`, e.g. `babai`) on one Tenant,
25
- * derived from the admin key. The Tenant stores only its hash, registered when the Host creates
26
- * its Tenant with the principals it is configured with (`NYLORUN_DERIVED_PRINCIPALS`, feature
27
- * `derived-principals`); the client recomputes the key when it needs it and stores nothing.
28
- * Rotating the admin key rotates every derived key.
29
- */
30
- export function deriveTenantKey(adminKey, tenantId, principalId) {
31
- const message = Buffer.concat([
32
- Buffer.from("nylorun/principal/v1", "utf8"),
33
- Buffer.from([0]),
34
- Buffer.from(principalId, "utf8"),
35
- Buffer.from([0]),
36
- Buffer.from(tenantId, "utf8"),
37
- ]);
38
- return createHmac("sha256", Buffer.from(adminKey, "utf8"))
39
- .update(message)
40
- .digest("hex");
41
- }
package/dist/index.d.ts CHANGED
@@ -1,13 +1,14 @@
1
- import type { AdminStatus, HostTenant, TenantEnvelope } from "@nylorun/core/contracts";
1
+ import type { AdminStatus, HostTenant, OperatorKey, PutOperatorKeyResponse, TenantEnvelope } from "@nylorun/core/contracts";
2
2
  import { ERROR_CODES, PROTOCOL_FEATURES, compareVersions, type ErrorCode } from "@nylorun/core/compatibility";
3
- import { tenantHostRoot, type AdminConnectionOptions } from "./client.js";
4
- import { PROJECT_PRINCIPAL_ID, deriveStudioToken, deriveTenantKey } from "./derived-credentials.js";
3
+ import { OPERATOR_KEYS_FEATURE, tenantHostRoot, type AdminConnectionOptions, type AdminKeys } from "./client.js";
4
+ import { deriveStudioToken } from "./derived-credentials.js";
5
5
  import { AdminError } from "./errors.js";
6
6
  export { ERROR_CODES, PROTOCOL_FEATURES, compareVersions };
7
7
  export type { ErrorCode };
8
8
  export { AdminError };
9
- export { PROJECT_PRINCIPAL_ID, deriveStudioToken, deriveTenantKey, tenantHostRoot };
9
+ export { deriveStudioToken, tenantHostRoot };
10
10
  export { mintStudioLoginToken } from "./studio-login.js";
11
+ export { OPERATOR_KEYS_FEATURE };
11
12
  export interface Admin {
12
13
  /** The Host's Tenant API URL. */
13
14
  readonly url: string;
@@ -17,11 +18,10 @@ export interface Admin {
17
18
  /** The Host's status, with the one Tenant it serves (`status.tenant`). */
18
19
  status(): Promise<AdminStatus>;
19
20
  /**
20
- * The key of a derived principal on the Host's Tenant, from this client's admin key. The
21
- * Host registers the principals it is configured with (`NYLORUN_DERIVED_PRINCIPALS`, default
22
- * `project`) when it creates its Tenant.
21
+ * The Tenant's operator keys (Host feature `operator-keys`): revocable application keys by
22
+ * name. `keys.put("backend")` creates or rotates a key and returns it once.
23
23
  */
24
- deriveTenantKey(tenantId: string, principalId: string): string;
24
+ readonly keys: AdminKeys;
25
25
  }
26
26
  /**
27
27
  * Resolution: explicit `url` + `key` → `NYLORUN_ADMIN_URL` + `NYLORUN_ADMIN_KEY` → the local
@@ -29,4 +29,4 @@ export interface Admin {
29
29
  * `NYLORUN_TENANT` or the Project link under `cwd`: `~/.nylorun/tenants/<tenant>/`).
30
30
  */
31
31
  export declare function createAdmin(options?: AdminConnectionOptions): Admin;
32
- export type { AdminConnectionOptions, AdminStatus, HostTenant, TenantEnvelope };
32
+ export type { AdminConnectionOptions, AdminKeys, AdminStatus, HostTenant, OperatorKey, PutOperatorKeyResponse, TenantEnvelope, };
package/dist/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import { ERROR_CODES, PROTOCOL_FEATURES, compareVersions, } from "@nylorun/core/compatibility";
2
- import { AdminClient, resolveAdminConnection, tenantHostRoot, } from "./client.js";
3
- import { PROJECT_PRINCIPAL_ID, deriveStudioToken, deriveTenantKey, } from "./derived-credentials.js";
2
+ import { AdminClient, OPERATOR_KEYS_FEATURE, resolveAdminConnection, tenantHostRoot, } from "./client.js";
3
+ import { deriveStudioToken } from "./derived-credentials.js";
4
4
  import { AdminError } from "./errors.js";
5
5
  export { ERROR_CODES, PROTOCOL_FEATURES, compareVersions };
6
6
  export { AdminError };
7
- export { PROJECT_PRINCIPAL_ID, deriveStudioToken, deriveTenantKey, tenantHostRoot };
7
+ export { deriveStudioToken, tenantHostRoot };
8
8
  export { mintStudioLoginToken } from "./studio-login.js";
9
+ export { OPERATOR_KEYS_FEATURE };
9
10
  /**
10
11
  * Resolution: explicit `url` + `key` → `NYLORUN_ADMIN_URL` + `NYLORUN_ADMIN_KEY` → the local
11
12
  * Host's settings in its Host root (`home`, `NYLORUN_HOME`, or the Tenant named by `tenant`,
@@ -1,8 +1,8 @@
1
1
  import { type StudioLoginTokenResponse } from "@nylorun/core/contracts";
2
2
  /**
3
3
  * Mints a single-use Studio login token with the admin key (`POST
4
- * /_studio/login-tokens`, Studio §8.4). An app that embeds Studio, such as
5
- * Babai, calls this from its backend and hands only the token to its page,
4
+ * /_studio/login-tokens`, Studio §8.4). An app that embeds Studio calls this
5
+ * from its backend and hands only the token to its page,
6
6
  * which passes it to the framed Studio in `init`.
7
7
  *
8
8
  * - `tenant` names the Host's one Tenant, for embedders that pass it (the embed
@@ -2,8 +2,8 @@ import { StudioLoginTokenRequestSchema, StudioLoginTokenResponseSchema, } from "
2
2
  import { AdminError } from "./errors.js";
3
3
  /**
4
4
  * Mints a single-use Studio login token with the admin key (`POST
5
- * /_studio/login-tokens`, Studio §8.4). An app that embeds Studio, such as
6
- * Babai, calls this from its backend and hands only the token to its page,
5
+ * /_studio/login-tokens`, Studio §8.4). An app that embeds Studio calls this
6
+ * from its backend and hands only the token to its page,
7
7
  * which passes it to the framed Studio in `init`.
8
8
  *
9
9
  * - `tenant` names the Host's one Tenant, for embedders that pass it (the embed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/admin",
3
- "version": "0.8.0-beta",
3
+ "version": "0.10.0-beta",
4
4
  "description": "Nylorun Admin API client for Tenants and Host status",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -24,7 +24,7 @@
24
24
  "clean": "node -e \"import('node:fs').then(({rmSync})=>rmSync('dist',{recursive:true,force:true}))\""
25
25
  },
26
26
  "dependencies": {
27
- "@nylorun/core": "0.11.0-beta"
27
+ "@nylorun/core": "0.13.0-beta"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "zod": "^4.6.5"
@@ -32,7 +32,7 @@
32
32
  "devDependencies": {
33
33
  "@types/node": "^24.0.0",
34
34
  "typescript": "npm:@typescript/typescript6@^6.0.2",
35
- "vitest": "^5.0.1"
35
+ "vitest": "^5.0.2"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=24"