@dereekb/dbx-cli 14.4.0 → 14.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/dbx-cli-lint-cache",
3
- "version": "14.4.0",
3
+ "version": "14.5.1",
4
4
  "sideEffects": false,
5
5
  "private": true,
6
6
  "type": "module",
@@ -9,7 +9,7 @@
9
9
  "eslint": "10.9.1"
10
10
  },
11
11
  "peerDependencies": {
12
- "@dereekb/util": "14.4.0",
12
+ "@dereekb/util": "14.5.1",
13
13
  "yargs": "^18.0.0"
14
14
  }
15
15
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@dereekb/dbx-cli/manifest-extract",
3
- "version": "14.4.0",
3
+ "version": "14.5.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
- "@dereekb/date": "14.4.0",
8
- "@dereekb/dbx-cli": "14.4.0",
9
- "@dereekb/firebase": "14.4.0",
10
- "@dereekb/model": "14.4.0",
11
- "@dereekb/nestjs": "14.4.0",
12
- "@dereekb/oauth-resource": "14.4.0",
13
- "@dereekb/rxjs": "14.4.0",
14
- "@dereekb/util": "14.4.0",
7
+ "@dereekb/date": "14.5.1",
8
+ "@dereekb/dbx-cli": "14.5.1",
9
+ "@dereekb/firebase": "14.5.1",
10
+ "@dereekb/model": "14.5.1",
11
+ "@dereekb/nestjs": "14.5.1",
12
+ "@dereekb/oauth-resource": "14.5.1",
13
+ "@dereekb/rxjs": "14.5.1",
14
+ "@dereekb/util": "14.5.1",
15
15
  "ts-morph": "^28.0.0"
16
16
  },
17
17
  "devDependencies": {
18
- "@dereekb/firebase": "14.4.0"
18
+ "@dereekb/firebase": "14.5.1"
19
19
  },
20
20
  "exports": {
21
21
  "./package.json": "./package.json",
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dereekb/dbx-cli/model-test",
3
- "version": "14.4.0",
3
+ "version": "14.5.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
- "@dereekb/util": "14.4.0",
7
+ "@dereekb/util": "14.5.1",
8
8
  "ts-morph": "^28.0.0"
9
9
  },
10
10
  "exports": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/dbx-cli",
3
- "version": "14.4.0",
3
+ "version": "14.5.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "bin": {
@@ -66,12 +66,12 @@
66
66
  }
67
67
  },
68
68
  "peerDependencies": {
69
- "@dereekb/date": "14.4.0",
70
- "@dereekb/firebase": "14.4.0",
71
- "@dereekb/model": "14.4.0",
72
- "@dereekb/nestjs": "14.4.0",
73
- "@dereekb/oauth-resource": "14.4.0",
74
- "@dereekb/util": "14.4.0",
69
+ "@dereekb/date": "14.5.1",
70
+ "@dereekb/firebase": "14.5.1",
71
+ "@dereekb/model": "14.5.1",
72
+ "@dereekb/nestjs": "14.5.1",
73
+ "@dereekb/oauth-resource": "14.5.1",
74
+ "@dereekb/util": "14.5.1",
75
75
  "@nestjs/common": "^12.0.1",
76
76
  "arktype": "^2.2.0",
77
77
  "firebase": "^12.18.0",
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@dereekb/dbx-cli/route",
3
- "version": "14.4.0",
3
+ "version": "14.5.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
- "@dereekb/date": "14.4.0",
8
- "@dereekb/dbx-cli": "14.4.0",
9
- "@dereekb/firebase": "14.4.0",
10
- "@dereekb/model": "14.4.0",
11
- "@dereekb/nestjs": "14.4.0",
12
- "@dereekb/oauth-resource": "14.4.0",
13
- "@dereekb/util": "14.4.0"
7
+ "@dereekb/date": "14.5.1",
8
+ "@dereekb/dbx-cli": "14.5.1",
9
+ "@dereekb/firebase": "14.5.1",
10
+ "@dereekb/model": "14.5.1",
11
+ "@dereekb/nestjs": "14.5.1",
12
+ "@dereekb/oauth-resource": "14.5.1",
13
+ "@dereekb/util": "14.5.1"
14
14
  },
15
15
  "exports": {
16
16
  "./package.json": "./package.json",
@@ -13,13 +13,39 @@ export interface CreateAuthCommandInput {
13
13
  */
14
14
  readonly defaultEnvs?: readonly CliEnvDefault[];
15
15
  }
16
+ /**
17
+ * Env name a handoff falls back to when nothing else names one — no `--env`, no `envName` from the
18
+ * minting deployment, no active env, and no single built-in default to borrow a name from.
19
+ *
20
+ * Only reachable on an unconfigured machine redeeming against a server that declares no
21
+ * `CliTokenApiModuleConfig.envName`. A neutral name is better than refusing: the credential is
22
+ * already spent by this point, so failing here would burn a one-time code.
23
+ */
24
+ export declare const DEFAULT_HANDOFF_ENV_NAME = "default";
25
+ /**
26
+ * Whether two OIDC issuer URLs name the same provider, ignoring the differences that carry no
27
+ * meaning — a trailing slash, case in the scheme/host, and a default port for the scheme.
28
+ *
29
+ * Used to decide whether redeeming a claim would REPOINT an existing env at a different deployment.
30
+ * Anything unparseable falls back to a trimmed string compare rather than reporting a match, so a
31
+ * malformed value fails closed into the guard.
32
+ *
33
+ * @param a - The env's currently configured issuer.
34
+ * @param b - The issuer the claimed bundle came from.
35
+ * @returns True when both resolve to the same origin and path.
36
+ */
37
+ export declare function cliIssuersMatch(a: string, b: string): boolean;
16
38
  /**
17
39
  * Factory for the built-in `auth` command tree.
18
40
  *
19
- * Wires `setup`, `login`, `logout`, `status`, `show`, and `check` subcommands that drive the OIDC
20
- * PKCE flow against the active env, persist tokens via the per-CLI token cache, and print a
41
+ * Wires `setup`, `login`, `handoff`, `logout`, `status`, `show`, and `check` subcommands that drive
42
+ * the OIDC PKCE flow against the active env, persist tokens via the per-CLI token cache, and print a
21
43
  * structured envelope.
22
44
  *
45
+ * `handoff` is the non-interactive counterpart to `login`: it redeems a one-time claim code minted by
46
+ * an already-authenticated MCP session, so an agent can bring a CLI up on a bare machine with no
47
+ * browser and no prior `auth setup`.
48
+ *
23
49
  * @param input - Factory configuration.
24
50
  * @param input.cliName - The CLI's binary name. Used for the per-user config dir, env-var prefix, and error messages.
25
51
  * @param input.envVarName - Override for the env-name env var. Defaults to `<CLINAME>_ENV` (e.g. `DEMO_CLI_ENV`).
@@ -0,0 +1,62 @@
1
+ import { type ISO8601DateString } from '@dereekb/util';
2
+ /**
3
+ * Path, relative to the OIDC issuer, of the one-time claim redemption endpoint.
4
+ *
5
+ * Mirrors `FIREBASE_SERVER_CLI_TOKEN_CLAIM_PATH` on the server. Duplicated rather than imported so
6
+ * `@dereekb/dbx-cli` keeps taking no dependency on `@dereekb/firebase-server`.
7
+ */
8
+ export declare const CLI_TOKEN_CLAIM_ENDPOINT_PATH_PART = "/cli-token/claim";
9
+ /**
10
+ * The credential bundle `POST <issuer>/cli-token/claim` returns — everything a bare machine needs to
11
+ * create an env and be logged in.
12
+ *
13
+ * The server-side shape is `CliTokenHandoffBundle` in `@dereekb/firebase-server/oidc`.
14
+ */
15
+ export interface CliHandoffBundle {
16
+ readonly uid: string;
17
+ readonly issuer: string;
18
+ readonly apiBaseUrl?: string;
19
+ /**
20
+ * The env name the minting deployment says it is. Advisory — an explicit `--env` still wins — but
21
+ * it is what lets the rendered one-line handoff command work on a machine with no config at all.
22
+ */
23
+ readonly envName?: string;
24
+ readonly clientId: string;
25
+ readonly refreshToken: string;
26
+ readonly scope: string;
27
+ readonly expiresAt: ISO8601DateString;
28
+ }
29
+ /**
30
+ * Inputs to {@link claimCliHandoff}.
31
+ */
32
+ export interface ClaimCliHandoffInput {
33
+ /**
34
+ * The env's OIDC issuer URL, e.g. `https://example.com/oidc`.
35
+ */
36
+ readonly oidcIssuer: string;
37
+ /**
38
+ * The one-time claim code an MCP session's `cli-token` tool produced.
39
+ */
40
+ readonly code: string;
41
+ }
42
+ /**
43
+ * Builds the claim endpoint URL from an OIDC issuer.
44
+ *
45
+ * @param oidcIssuer - The env's OIDC issuer URL.
46
+ * @returns The claim endpoint URL.
47
+ * @__NO_SIDE_EFFECTS__
48
+ */
49
+ export declare function buildCliHandoffClaimEndpoint(oidcIssuer: string): string;
50
+ /**
51
+ * Redeems a one-time claim code for the credential bundle it wraps.
52
+ *
53
+ * The request carries no credential of its own — the code IS the credential, which is the entire
54
+ * point: the machine running this has nothing yet. The server answers every failure (unknown code,
55
+ * expired code, already-redeemed code) with the same generic error, so this reports one message too
56
+ * rather than inventing a distinction the server deliberately withholds.
57
+ *
58
+ * @param input - The issuer and the claim code.
59
+ * @returns The parsed {@link CliHandoffBundle}.
60
+ * @throws {CliError} `AUTH_HANDOFF_FAILED` when the code is rejected or the response is unusable.
61
+ */
62
+ export declare function claimCliHandoff(input: ClaimCliHandoffInput): Promise<CliHandoffBundle>;
@@ -1,4 +1,5 @@
1
1
  export * from './auth.command.factory';
2
+ export * from './cli-handoff.client';
2
3
  export * from './oidc.client';
3
4
  export * from './oidc.flow';
4
5
  export * from './oidc.loopback';
@@ -51,6 +51,14 @@ export interface SaveCliConfigInput extends LoadCliConfigInput {
51
51
  readonly configDir: string;
52
52
  readonly config: CliConfig;
53
53
  }
54
+ /**
55
+ * File mode `config.json` is written with.
56
+ *
57
+ * Owner-only, matching `.tokens.json`: the config holds `clientSecret` for a confidential client,
58
+ * which is every bit as sensitive as a cached token. It previously inherited the umask (0644 in the
59
+ * usual case), leaving a real credential world-readable on a shared machine.
60
+ */
61
+ export declare const CLI_CONFIG_FILE_MODE = 384;
54
62
  /**
55
63
  * Writes the full {@link CliConfig} to disk, creating the parent directory if needed.
56
64
  *
@@ -9,6 +9,7 @@
9
9
  export * from './scan-config-schema.js';
10
10
  export * from './extract.js';
11
11
  export * from './build-manifest.js';
12
+ export * from './sanitize-type-text.js';
12
13
  export * from './cli.js';
13
14
  export * from './filters-cli.js';
14
15
  export * from './filters-extract.js';
@@ -26,6 +26,12 @@ export type BuildModelSnapshotFieldsGlobber = ScanGlobber;
26
26
  export interface BuildModelSnapshotFieldsManifestInput {
27
27
  readonly projectRoot: string;
28
28
  readonly generator: string;
29
+ /**
30
+ * Absolute workspace root that absolute paths baked into type text are made
31
+ * relative to. Defaults to `process.cwd()`, which is the workspace root because
32
+ * the generate-* targets all run with `cwd: {workspaceRoot}`.
33
+ */
34
+ readonly workspaceRoot?: string;
29
35
  readonly now?: () => Date;
30
36
  readonly readFile?: BuildModelSnapshotFieldsReadFile;
31
37
  readonly globber?: BuildModelSnapshotFieldsGlobber;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Makes ts-morph type text reproducible across checkouts.
3
+ *
4
+ * TypeScript emits `import("<absolute path>").Type` for any type it cannot name
5
+ * from the enclosing scope, and ts-morph surfaces that text verbatim. The path is
6
+ * machine-specific: it is the host checkout on a developer's machine and `/code`
7
+ * inside the build container's bind mount.
8
+ *
9
+ * That difference is not cosmetic. The generated manifests are tracked files under
10
+ * `packages/dbx-cli/generated`, which is inside `dbx-cli`'s project root, and the
11
+ * workspace's `default` named input is `{projectRoot}/**\/*`. So an absolute path
12
+ * baked into a manifest invalidates the Nx cache for `dbx-cli` — and everything
13
+ * downstream of it — on every alternation between a host build and a container
14
+ * build, and leaves the git tree permanently dirty.
15
+ *
16
+ * Rewriting the path to be workspace-relative makes the emitted bytes identical
17
+ * everywhere the workspace is checked out.
18
+ */
19
+ /**
20
+ * Input to {@link sanitizeTypeText}.
21
+ */
22
+ export interface SanitizeTypeTextInput {
23
+ /**
24
+ * Type text as reported by the type checker, possibly containing one or more
25
+ * `import("<absolute path>")` segments.
26
+ */
27
+ readonly typeText: string;
28
+ /**
29
+ * Absolute path to the workspace root that emitted paths are made relative to.
30
+ */
31
+ readonly workspaceRoot: string;
32
+ }
33
+ /**
34
+ * Rewrites every absolute `import("…")` path in `typeText` to a workspace-relative,
35
+ * forward-slashed path.
36
+ *
37
+ * Paths that are already relative, or that resolve outside `workspaceRoot`, are left
38
+ * untouched — there is no stable shorter form for them, and rewriting to a `../`
39
+ * chain would reintroduce the machine dependence this exists to remove.
40
+ *
41
+ * @param input - The type text and the workspace root to relativize against.
42
+ * @returns The type text with workspace-internal absolute paths relativized.
43
+ */
44
+ export declare function sanitizeTypeText(input: SanitizeTypeTextInput): string;
@@ -25,6 +25,12 @@ export type BuildUtilsGlobber = ScanGlobber;
25
25
  export interface BuildUtilsManifestInput {
26
26
  readonly projectRoot: string;
27
27
  readonly generator: string;
28
+ /**
29
+ * Absolute workspace root that absolute paths baked into type text are made
30
+ * relative to. Defaults to `process.cwd()`, which is the workspace root because
31
+ * the generate-* targets all run with `cwd: {workspaceRoot}`.
32
+ */
33
+ readonly workspaceRoot?: string;
28
34
  readonly now?: () => Date;
29
35
  readonly readFile?: BuildUtilsReadFile;
30
36
  readonly globber?: BuildUtilsGlobber;
package/test/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@dereekb/dbx-cli/test",
3
- "version": "14.4.0",
3
+ "version": "14.5.1",
4
4
  "sideEffects": false,
5
5
  "type": "module",
6
6
  "peerDependencies": {
7
- "@dereekb/date": "14.4.0",
8
- "@dereekb/dbx-cli": "14.4.0",
9
- "@dereekb/firebase": "14.4.0",
10
- "@dereekb/firebase-server/test": "14.4.0",
11
- "@dereekb/model": "14.4.0",
12
- "@dereekb/nestjs": "14.4.0",
13
- "@dereekb/oauth-resource": "14.4.0",
14
- "@dereekb/rxjs": "14.4.0",
15
- "@dereekb/util": "14.4.0",
7
+ "@dereekb/date": "14.5.1",
8
+ "@dereekb/dbx-cli": "14.5.1",
9
+ "@dereekb/firebase": "14.5.1",
10
+ "@dereekb/firebase-server/test": "14.5.0",
11
+ "@dereekb/model": "14.5.1",
12
+ "@dereekb/nestjs": "14.5.1",
13
+ "@dereekb/oauth-resource": "14.5.1",
14
+ "@dereekb/rxjs": "14.5.1",
15
+ "@dereekb/util": "14.5.1",
16
16
  "@nestjs/common": "^12.0.1",
17
17
  "arktype": "^2.2.0",
18
18
  "vitest": "4.1.11",
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dereekb/dbx-cli/validate",
3
- "version": "14.4.0",
3
+ "version": "14.5.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
- "@dereekb/dbx-cli": "14.4.0",
8
- "@dereekb/util": "14.4.0",
7
+ "@dereekb/dbx-cli": "14.5.1",
8
+ "@dereekb/util": "14.5.1",
9
9
  "ts-morph": "^28.0.0"
10
10
  }
11
11
  }