@dereekb/dbx-cli 14.3.0 → 14.5.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.
- package/eslint/package.json +3 -3
- package/firebase-api-manifest/main.js +5 -7
- package/firebase-api-manifest/package.json +5 -7
- package/firestore-query-manifest/main.js +3 -3
- package/firestore-query-manifest/package.json +3 -3
- package/generate-firestore-indexes/main.js +2 -2
- package/generate-firestore-indexes/package.json +2 -2
- package/generate-mcp-manifest/package.json +3 -3
- package/generate-route-manifest/package.json +2 -2
- package/index.esm.js +1356 -1147
- package/lint-cache/package.json +2 -2
- package/manifest-extract/package.json +12 -8
- package/model-test/package.json +2 -2
- package/package.json +10 -7
- package/route/package.json +8 -7
- package/src/lib/api/firestore-session.client.d.ts +21 -27
- package/src/lib/auth/auth.command.factory.d.ts +28 -2
- package/src/lib/auth/cli-handoff.client.d.ts +62 -0
- package/src/lib/auth/index.d.ts +1 -0
- package/src/lib/config/cli.config.d.ts +8 -0
- package/src/lib/config/env.d.ts +13 -60
- package/src/lib/config/firestore-session.cache.d.ts +20 -49
- package/src/lib/firestore/firestore.sdk-identity.d.ts +24 -104
- package/src/lib/firestore/firestore.session.d.ts +19 -64
- package/src/lib/mcp-scan/scan/index.d.ts +1 -0
- package/src/lib/mcp-scan/scan/model-snapshot-fields-build-manifest.d.ts +6 -0
- package/src/lib/mcp-scan/scan/sanitize-type-text.d.ts +44 -0
- package/src/lib/mcp-scan/scan/utils-build-manifest.d.ts +6 -0
- package/test/package.json +10 -9
- package/validate/package.json +3 -3
package/lint-cache/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli-lint-cache",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.5.0",
|
|
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.
|
|
12
|
+
"@dereekb/util": "14.5.0",
|
|
13
13
|
"yargs": "^18.0.0"
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli/manifest-extract",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"@dereekb/date": "14.
|
|
8
|
-
"@dereekb/dbx-cli": "14.
|
|
9
|
-
"@dereekb/firebase": "14.
|
|
10
|
-
"@dereekb/model": "14.
|
|
11
|
-
"@dereekb/nestjs": "14.
|
|
12
|
-
"@dereekb/
|
|
13
|
-
"@dereekb/
|
|
7
|
+
"@dereekb/date": "14.5.0",
|
|
8
|
+
"@dereekb/dbx-cli": "14.5.0",
|
|
9
|
+
"@dereekb/firebase": "14.5.0",
|
|
10
|
+
"@dereekb/model": "14.5.0",
|
|
11
|
+
"@dereekb/nestjs": "14.5.0",
|
|
12
|
+
"@dereekb/oauth-resource": "14.5.0",
|
|
13
|
+
"@dereekb/rxjs": "14.5.0",
|
|
14
|
+
"@dereekb/util": "14.5.0",
|
|
14
15
|
"ts-morph": "^28.0.0"
|
|
15
16
|
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@dereekb/firebase": "14.5.0"
|
|
19
|
+
},
|
|
16
20
|
"exports": {
|
|
17
21
|
"./package.json": "./package.json",
|
|
18
22
|
".": {
|
package/model-test/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli/model-test",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"@dereekb/util": "14.
|
|
7
|
+
"@dereekb/util": "14.5.0",
|
|
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.
|
|
3
|
+
"version": "14.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"bin": {
|
|
@@ -66,11 +66,12 @@
|
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@dereekb/date": "14.
|
|
70
|
-
"@dereekb/firebase": "14.
|
|
71
|
-
"@dereekb/model": "14.
|
|
72
|
-
"@dereekb/nestjs": "14.
|
|
73
|
-
"@dereekb/
|
|
69
|
+
"@dereekb/date": "14.5.0",
|
|
70
|
+
"@dereekb/firebase": "14.5.0",
|
|
71
|
+
"@dereekb/model": "14.5.0",
|
|
72
|
+
"@dereekb/nestjs": "14.5.0",
|
|
73
|
+
"@dereekb/oauth-resource": "14.5.0",
|
|
74
|
+
"@dereekb/util": "14.5.0",
|
|
74
75
|
"@nestjs/common": "^12.0.1",
|
|
75
76
|
"arktype": "^2.2.0",
|
|
76
77
|
"firebase": "^12.18.0",
|
|
@@ -83,7 +84,9 @@
|
|
|
83
84
|
"devDependencies": {
|
|
84
85
|
"@angular/core": "22.1.4",
|
|
85
86
|
"@types/yargs": "^17.0.35",
|
|
86
|
-
"eslint": "
|
|
87
|
+
"@typescript-eslint/parser": "8.69.0",
|
|
88
|
+
"eslint": "10.9.1",
|
|
89
|
+
"firebase": "^12.18.0"
|
|
87
90
|
},
|
|
88
91
|
"module": "./index.esm.js",
|
|
89
92
|
"main": "./index.esm.js",
|
package/route/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli/route",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"@dereekb/date": "14.
|
|
8
|
-
"@dereekb/dbx-cli": "14.
|
|
9
|
-
"@dereekb/firebase": "14.
|
|
10
|
-
"@dereekb/model": "14.
|
|
11
|
-
"@dereekb/nestjs": "14.
|
|
12
|
-
"@dereekb/
|
|
7
|
+
"@dereekb/date": "14.5.0",
|
|
8
|
+
"@dereekb/dbx-cli": "14.5.0",
|
|
9
|
+
"@dereekb/firebase": "14.5.0",
|
|
10
|
+
"@dereekb/model": "14.5.0",
|
|
11
|
+
"@dereekb/nestjs": "14.5.0",
|
|
12
|
+
"@dereekb/oauth-resource": "14.5.0",
|
|
13
|
+
"@dereekb/util": "14.5.0"
|
|
13
14
|
},
|
|
14
15
|
"exports": {
|
|
15
16
|
"./package.json": "./package.json",
|
|
@@ -1,33 +1,20 @@
|
|
|
1
|
+
import { type FirestoreSessionCredentials, type FirestoreSessionErrorFactory } from '@dereekb/oauth-resource/firebase';
|
|
2
|
+
export { FIRESTORE_SESSION_API_PATH } from '@dereekb/oauth-resource/firebase';
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
* `@dereekb/firebase-server`'s `SessionApiController`.
|
|
4
|
+
* The credential bundle `GET <apiBaseUrl>/session/firestore` returns.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* The CLI's name for {@link FirestoreSessionCredentials}, which is the shared implementation in
|
|
7
|
+
* `@dereekb/oauth-resource/firebase`.
|
|
7
8
|
*/
|
|
8
|
-
export
|
|
9
|
+
export type CliFirestoreSession = FirestoreSessionCredentials;
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Maps a generic session failure onto a {@link CliError}, re-attaching the CLI-flavored remediation
|
|
12
|
+
* an operator can act on (`<cli> auth login --env <env>` and friends).
|
|
13
|
+
*
|
|
14
|
+
* @param input - The generic failure.
|
|
15
|
+
* @returns The `CliError` to throw.
|
|
11
16
|
*/
|
|
12
|
-
export
|
|
13
|
-
/**
|
|
14
|
-
* The uid the session was minted for.
|
|
15
|
-
*/
|
|
16
|
-
readonly uid: string;
|
|
17
|
-
/**
|
|
18
|
-
* A Firebase Auth custom token to exchange via `signInWithCustomToken`.
|
|
19
|
-
*/
|
|
20
|
-
readonly customToken: string;
|
|
21
|
-
/**
|
|
22
|
-
* An App Check attestation minted server-side for the project's registered web app. Absent when
|
|
23
|
-
* the API has no `appCheckAppId` configured (a project that does not enforce App Check).
|
|
24
|
-
*/
|
|
25
|
-
readonly appCheckToken?: string;
|
|
26
|
-
/**
|
|
27
|
-
* ISO timestamp at which the session's shortest-lived credential expires.
|
|
28
|
-
*/
|
|
29
|
-
readonly expiresAt: string;
|
|
30
|
-
}
|
|
17
|
+
export declare const cliFirestoreSessionErrorFactory: FirestoreSessionErrorFactory;
|
|
31
18
|
export interface FetchFirestoreSessionInput {
|
|
32
19
|
/**
|
|
33
20
|
* The API base URL — typically `<host>/<project>/us-central1/api` or `https://<domain>/api`.
|
|
@@ -44,11 +31,18 @@ export interface FetchFirestoreSessionInput {
|
|
|
44
31
|
/**
|
|
45
32
|
* Fetches a direct-Firestore session from the API with the cached Bearer access token.
|
|
46
33
|
*
|
|
47
|
-
* The
|
|
48
|
-
*
|
|
34
|
+
* The thin CLI wrapper over `@dereekb/oauth-resource/firebase`'s `fetchFirestoreSession`: it binds
|
|
35
|
+
* the CLI's `tracedFetch` (so `--verbose` and `--timeout` apply) and the `CliError` factory.
|
|
49
36
|
*
|
|
50
37
|
* @param input - The API target, access token, and optional fetch override.
|
|
51
38
|
* @returns The parsed {@link CliFirestoreSession}.
|
|
52
39
|
* @throws {CliError} When the endpoint answers non-2xx or returns an unusable body.
|
|
53
40
|
*/
|
|
54
41
|
export declare function fetchFirestoreSession(input: FetchFirestoreSessionInput): Promise<CliFirestoreSession>;
|
|
42
|
+
/**
|
|
43
|
+
* Binds the CLI's verbose-trace + `--timeout` fetch behavior onto the supplied (or global) fetch.
|
|
44
|
+
*
|
|
45
|
+
* @param fetcher - The underlying fetch impl, when one was injected.
|
|
46
|
+
* @returns A `fetch`-shaped function carrying the CLI's tracing.
|
|
47
|
+
*/
|
|
48
|
+
export declare function cliFirestoreSessionFetcher(fetcher?: typeof fetch): typeof fetch;
|
|
@@ -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
|
|
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>;
|
package/src/lib/auth/index.d.ts
CHANGED
|
@@ -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
|
*
|
package/src/lib/config/env.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Maybe, type OidcClientAuthMethod } from '@dereekb/util';
|
|
2
|
+
import { type FirebaseClientConfig, type FirebaseClientEmulatorsConfig, firebaseClientEmulatorsInUse, isFirebaseClientConfigComplete } from '@dereekb/oauth-resource/firebase';
|
|
2
3
|
import { type CliTokenEntry } from './token.cache';
|
|
3
4
|
/**
|
|
4
5
|
* The default OAuth/OIDC scopes requested by the CLI when none are configured.
|
|
@@ -117,67 +118,22 @@ export declare function mergeCliEnvWithDefault(input: MergeCliEnvWithDefaultInpu
|
|
|
117
118
|
*/
|
|
118
119
|
export declare function mergeCliFirebaseConfig(env: Maybe<CliFirebaseConfig>, defaultEnv: Maybe<CliFirebaseConfig>): CliFirebaseConfig | undefined;
|
|
119
120
|
/**
|
|
120
|
-
* Local Firebase emulator targets for a CLI env.
|
|
121
|
-
*
|
|
122
|
-
* Mirrors the semantics of `DbxFirebaseEmulatorsConfig` in `@dereekb/dbx-firebase` (whose parse
|
|
123
|
-
* helper is Angular-bound and not reusable here): the presence of this object means "use emulators"
|
|
124
|
-
* unless {@link useEmulators} is explicitly `false`.
|
|
125
|
-
*
|
|
126
|
-
* App Check is auto-disabled whenever emulators are in use — the emulators do not verify
|
|
127
|
-
* attestations, and `initializeAppCheck` against a fake project only gets in the way.
|
|
121
|
+
* Local Firebase emulator targets for a CLI env. The CLI's name for
|
|
122
|
+
* {@link FirebaseClientEmulatorsConfig}.
|
|
128
123
|
*/
|
|
129
|
-
export
|
|
130
|
-
/**
|
|
131
|
-
* Set `false` to keep the emulator targets configured but inactive. Defaults to `true`.
|
|
132
|
-
*/
|
|
133
|
-
readonly useEmulators?: boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Host the emulators are reachable at. Defaults to {@link DEFAULT_CLI_FIREBASE_EMULATOR_HOST}.
|
|
136
|
-
*/
|
|
137
|
-
readonly host?: string;
|
|
138
|
-
/**
|
|
139
|
-
* Port of the Auth emulator. When unset, Auth is not redirected to an emulator.
|
|
140
|
-
*/
|
|
141
|
-
readonly authPort?: number;
|
|
142
|
-
/**
|
|
143
|
-
* Port of the Firestore emulator. When unset, Firestore is not redirected to an emulator.
|
|
144
|
-
*/
|
|
145
|
-
readonly firestorePort?: number;
|
|
146
|
-
}
|
|
124
|
+
export type CliFirebaseEmulatorsConfig = FirebaseClientEmulatorsConfig;
|
|
147
125
|
/**
|
|
148
126
|
* Firebase client-SDK configuration for a CLI env, used only by the direct-Firestore session
|
|
149
127
|
* (`CliContext.getFirestoreContext`). Everything else the CLI does goes over the model HTTP API and
|
|
150
128
|
* needs none of this.
|
|
151
129
|
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* server mints its App Check attestation for that app.
|
|
130
|
+
* The CLI's name for {@link FirebaseClientConfig}: the same shape any resource server opening a
|
|
131
|
+
* user-scoped Firestore session supplies.
|
|
155
132
|
*/
|
|
156
|
-
export
|
|
157
|
-
/**
|
|
158
|
-
* The Firebase web API key.
|
|
159
|
-
*/
|
|
160
|
-
readonly apiKey?: string;
|
|
161
|
-
/**
|
|
162
|
-
* The project's auth domain (e.g. `my-project.firebaseapp.com`).
|
|
163
|
-
*/
|
|
164
|
-
readonly authDomain?: string;
|
|
165
|
-
/**
|
|
166
|
-
* The Firebase project id.
|
|
167
|
-
*/
|
|
168
|
-
readonly projectId?: string;
|
|
169
|
-
/**
|
|
170
|
-
* The registered **web** app id (e.g. `1:1234567890:web:abcdef`).
|
|
171
|
-
*/
|
|
172
|
-
readonly appId?: string;
|
|
173
|
-
/**
|
|
174
|
-
* Optional emulator targets for local development.
|
|
175
|
-
*/
|
|
176
|
-
readonly emulators?: CliFirebaseEmulatorsConfig;
|
|
177
|
-
}
|
|
133
|
+
export type CliFirebaseConfig = FirebaseClientConfig;
|
|
178
134
|
/**
|
|
179
135
|
* Default host used for Firebase emulator connections when a {@link CliFirebaseEmulatorsConfig}
|
|
180
|
-
* omits one.
|
|
136
|
+
* omits one. See {@link DEFAULT_FIREBASE_CLIENT_EMULATOR_HOST}.
|
|
181
137
|
*/
|
|
182
138
|
export declare const DEFAULT_CLI_FIREBASE_EMULATOR_HOST = "localhost";
|
|
183
139
|
/**
|
|
@@ -187,17 +143,14 @@ export declare const DEFAULT_CLI_FIREBASE_EMULATOR_HOST = "localhost";
|
|
|
187
143
|
* Deliberately separate from {@link isCliEnvConfigComplete}: the Firebase config is optional, and
|
|
188
144
|
* folding it into the general completeness check would break every CLI that only uses the model API.
|
|
189
145
|
*
|
|
190
|
-
* @
|
|
191
|
-
* @returns `true` when `apiKey`, `projectId`, and `appId` are all present and non-empty.
|
|
146
|
+
* See {@link isFirebaseClientConfigComplete}.
|
|
192
147
|
*/
|
|
193
|
-
export declare
|
|
148
|
+
export declare const isCliFirebaseConfigComplete: typeof isFirebaseClientConfigComplete;
|
|
194
149
|
/**
|
|
195
|
-
* Returns true when the env's emulator config is present and active.
|
|
196
|
-
*
|
|
197
|
-
* @param firebase - The env's Firebase client config, if any.
|
|
198
|
-
* @returns `true` when emulators are configured and not explicitly disabled.
|
|
150
|
+
* Returns true when the env's emulator config is present and active. See
|
|
151
|
+
* {@link firebaseClientEmulatorsInUse}.
|
|
199
152
|
*/
|
|
200
|
-
export declare
|
|
153
|
+
export declare const cliFirebaseEmulatorsInUse: typeof firebaseClientEmulatorsInUse;
|
|
201
154
|
/**
|
|
202
155
|
* The OAuth client's registered `token_endpoint_auth_method`, as far as the CLI needs to model it.
|
|
203
156
|
*
|
|
@@ -1,40 +1,19 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type CliFirestoreSession } from '../api/firestore-session.client';
|
|
1
|
+
import { type FirestoreSessionCacheEntry, type FirestoreSessionCredentialsCache, firestoreSessionEntryExpiresAt, isFirestoreSessionExpired } from '@dereekb/oauth-resource/firebase';
|
|
3
2
|
/**
|
|
4
3
|
* Hard ceiling on how long a minted direct-Firestore session may be reused, regardless of what the
|
|
5
|
-
* API reported in `expiresAt`.
|
|
6
|
-
*
|
|
7
|
-
* One hour, because that is the Firebase ceiling the credentials themselves sit under: a custom
|
|
8
|
-
* token is exchangeable for one hour, and the ID token it mints lives one hour. Holding a session
|
|
9
|
-
* past that buys nothing — the sign-in would fail — and re-minting is one HTTP round-trip.
|
|
4
|
+
* API reported in `expiresAt`. See {@link FIRESTORE_SESSION_MAX_CACHE_MS}.
|
|
10
5
|
*/
|
|
11
6
|
export declare const CLI_FIRESTORE_SESSION_MAX_CACHE_MS: number;
|
|
12
7
|
/**
|
|
13
|
-
* Default skew/latency buffer applied when deciding whether a cached session is still usable.
|
|
8
|
+
* Default skew/latency buffer applied when deciding whether a cached session is still usable. See
|
|
9
|
+
* {@link FIRESTORE_SESSION_EXPIRY_BUFFER_MS}.
|
|
14
10
|
*/
|
|
15
|
-
export declare const CLI_FIRESTORE_SESSION_EXPIRY_BUFFER_MS
|
|
11
|
+
export declare const CLI_FIRESTORE_SESSION_EXPIRY_BUFFER_MS: number;
|
|
16
12
|
/**
|
|
17
|
-
* A cached direct-Firestore session for a single env.
|
|
18
|
-
*
|
|
19
|
-
* Stores the credential envelope the API minted, not the live Firebase objects — those are
|
|
20
|
-
* per-process and cannot be serialized. A cache hit still signs in; it just skips the
|
|
21
|
-
* `GET /session/firestore` round-trip.
|
|
13
|
+
* A cached direct-Firestore session for a single env. The CLI's name for
|
|
14
|
+
* {@link FirestoreSessionCacheEntry}.
|
|
22
15
|
*/
|
|
23
|
-
export
|
|
24
|
-
/**
|
|
25
|
-
* The credential bundle returned by `GET /session/firestore`.
|
|
26
|
-
*/
|
|
27
|
-
readonly session: CliFirestoreSession;
|
|
28
|
-
/**
|
|
29
|
-
* Unix epoch milliseconds at which the entry was written.
|
|
30
|
-
*/
|
|
31
|
-
readonly cachedAt: number;
|
|
32
|
-
/**
|
|
33
|
-
* The uid the entry was minted for, denormalized so a stale entry belonging to a different user
|
|
34
|
-
* can be detected without parsing the custom token.
|
|
35
|
-
*/
|
|
36
|
-
readonly uid: string;
|
|
37
|
-
}
|
|
16
|
+
export type CliFirestoreSessionEntry = FirestoreSessionCacheEntry;
|
|
38
17
|
/**
|
|
39
18
|
* Firestore session cache shape on disk — keyed by env name.
|
|
40
19
|
*/
|
|
@@ -45,13 +24,18 @@ export type CliFirestoreSessionCache = Record<string, CliFirestoreSessionEntry>;
|
|
|
45
24
|
* Backed by a single JSON file with per-process in-memory memoization, exactly like the token
|
|
46
25
|
* cache — see {@link createMemoizedJsonFileAsyncKeyedValueCache}.
|
|
47
26
|
*/
|
|
48
|
-
export type CliFirestoreSessionCacheStore =
|
|
27
|
+
export type CliFirestoreSessionCacheStore = FirestoreSessionCredentialsCache;
|
|
49
28
|
export interface CreateCliFirestoreSessionCacheStoreInput {
|
|
50
29
|
readonly firestoreSessionCachePath: string;
|
|
51
30
|
}
|
|
52
31
|
/**
|
|
53
32
|
* Creates a per-env direct-Firestore session cache store backed by a single JSON file.
|
|
54
33
|
*
|
|
34
|
+
* The file-backed half of the session cache stays HERE rather than moving to
|
|
35
|
+
* `@dereekb/oauth-resource/firebase`: it depends on `@dereekb/nestjs`, and a Nest peer has no business
|
|
36
|
+
* in a package whose whole point is a clean install graph. Only the expiry policy and the
|
|
37
|
+
* {@link FirestoreSessionCredentialsCache} port are shared.
|
|
38
|
+
*
|
|
55
39
|
* Entries are written with mode 0o600 — they hold a Firebase custom token, which is a bearer
|
|
56
40
|
* credential for the user it was minted for.
|
|
57
41
|
*
|
|
@@ -62,25 +46,12 @@ export interface CreateCliFirestoreSessionCacheStoreInput {
|
|
|
62
46
|
*/
|
|
63
47
|
export declare function createCliFirestoreSessionCacheStore(input: CreateCliFirestoreSessionCacheStoreInput): CliFirestoreSessionCacheStore;
|
|
64
48
|
/**
|
|
65
|
-
* Resolves the epoch-millis instant at which a cached session stops being usable.
|
|
66
|
-
*
|
|
67
|
-
* The effective expiry is the EARLIER of the API-reported `expiresAt` and
|
|
68
|
-
* {@link CLI_FIRESTORE_SESSION_MAX_CACHE_MS} past the write. Taking the earlier of the two means a
|
|
69
|
-
* server that reports an over-long (or unparsable) window still cannot push a session past the
|
|
70
|
-
* Firebase credential ceiling.
|
|
71
|
-
*
|
|
72
|
-
* @param entry - The cached entry.
|
|
73
|
-
* @returns The effective expiry in unix epoch milliseconds.
|
|
74
|
-
*
|
|
75
|
-
* @__NO_SIDE_EFFECTS__
|
|
49
|
+
* Resolves the epoch-millis instant at which a cached session stops being usable. See
|
|
50
|
+
* {@link firestoreSessionEntryExpiresAt}.
|
|
76
51
|
*/
|
|
77
|
-
export declare
|
|
52
|
+
export declare const cliFirestoreSessionEntryExpiresAt: typeof firestoreSessionEntryExpiresAt;
|
|
78
53
|
/**
|
|
79
|
-
* Returns true when the cached session is at or near its effective expiry.
|
|
80
|
-
*
|
|
81
|
-
* @param entry - The cached entry (`null`/`undefined` is treated as expired).
|
|
82
|
-
* @param nowMs - The current time in unix epoch milliseconds. Defaults to `Date.now()`.
|
|
83
|
-
* @param bufferMs - Skew/latency buffer; the entry is treated as expired this far ahead of its effective expiry.
|
|
84
|
-
* @returns `true` when the entry is unusable, otherwise `false`.
|
|
54
|
+
* Returns true when the cached session is at or near its effective expiry. See
|
|
55
|
+
* {@link isFirestoreSessionExpired}.
|
|
85
56
|
*/
|
|
86
|
-
export declare
|
|
57
|
+
export declare const isCliFirestoreSessionExpired: typeof isFirestoreSessionExpired;
|