@dereekb/dbx-cli 14.3.0 → 14.4.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 +3 -3
- package/firebase-api-manifest/package.json +3 -3
- 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 +222 -666
- 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/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/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.4.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.4.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.4.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.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",
|
|
14
15
|
"ts-morph": "^28.0.0"
|
|
15
16
|
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@dereekb/firebase": "14.4.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.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"@dereekb/util": "14.
|
|
7
|
+
"@dereekb/util": "14.4.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.4.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.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",
|
|
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.4.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.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"
|
|
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;
|
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;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { type FirestoreModelKey, type FirestoreModelType } from '@dereekb/firebase';
|
|
2
2
|
import { type Maybe } from '@dereekb/util';
|
|
3
|
+
import { type FirebaseClientFirestoreIdentityContext, type FirebaseClientFirestoreIdentityProblem, type FirebaseClientFirestoreIdentityReport, type FirebaseClientFirestoreSdkModuleIdentity } from '@dereekb/oauth-resource/firebase';
|
|
3
4
|
/**
|
|
4
|
-
* The `drivers.firestoreDriverIdentifier` a client-SDK `FirestoreContext` reports.
|
|
5
|
-
*
|
|
6
|
-
* `clientFirebaseFirestoreContextFactory` stamps this; the server's
|
|
7
|
-
* `googleCloudFirestoreContextFactory` stamps `@google-cloud/firestore` instead. Comparing against
|
|
8
|
-
* it is how {@link inspectCliFirestoreSdkIdentity} tells an admin-SDK context handed to the CLI apart
|
|
9
|
-
* from a genuinely broken client one.
|
|
5
|
+
* The `drivers.firestoreDriverIdentifier` a client-SDK `FirestoreContext` reports. See
|
|
6
|
+
* {@link CLIENT_FIRESTORE_DRIVER_IDENTIFIER}.
|
|
10
7
|
*/
|
|
11
8
|
export declare const CLI_CLIENT_FIRESTORE_DRIVER_IDENTIFIER = "@firebase/firestore";
|
|
12
9
|
/**
|
|
@@ -22,94 +19,31 @@ export declare const FIRESTORE_SDK_IDENTITY_STAGE = "firestore-sdk-identity";
|
|
|
22
19
|
*/
|
|
23
20
|
export declare const FIRESTORE_SDK_INSTANCE_MISMATCH_CODE = "FIRESTORE_SDK_INSTANCE_MISMATCH";
|
|
24
21
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
export type CliFirestoreSdkIdentityProblem =
|
|
29
|
-
/**
|
|
30
|
-
* `firestoreContext` is absent, or its `firestore` is null/undefined. Every `collection()` call
|
|
31
|
-
* built off it throws `Expected first argument to collection() to be a CollectionReference, a
|
|
32
|
-
* DocumentReference or FirebaseFirestore` — the SDK's message for ANY non-Firestore first
|
|
33
|
-
* argument, which is why it never named this.
|
|
34
|
-
*/
|
|
35
|
-
'no-firestore-handle'
|
|
36
|
-
/**
|
|
37
|
-
* The context reports a driver other than {@link CLI_CLIENT_FIRESTORE_DRIVER_IDENTIFIER} — an
|
|
38
|
-
* admin/`@google-cloud/firestore` context reached the client-SDK read path.
|
|
39
|
-
*/
|
|
40
|
-
| 'unexpected-driver'
|
|
41
|
-
/**
|
|
42
|
-
* Two copies of `@firebase/firestore` are loaded, so the handle minted by one fails the other's
|
|
43
|
-
* brand check.
|
|
22
|
+
* `CliError` code for a collection/document reference the SDK refused to build for a reason the
|
|
23
|
+
* wiring identity check cannot explain — a bad `--parent`, or an app collection whose own
|
|
24
|
+
* construction is broken.
|
|
44
25
|
*/
|
|
45
|
-
|
|
26
|
+
export declare const FIRESTORE_COLLECTION_UNRESOLVABLE_CODE = "FIRESTORE_COLLECTION_UNRESOLVABLE";
|
|
46
27
|
/**
|
|
47
|
-
* The
|
|
48
|
-
*
|
|
28
|
+
* The distinct ways a session's Firestore handle can be unusable. See
|
|
29
|
+
* {@link FirebaseClientFirestoreIdentityProblem}.
|
|
49
30
|
*/
|
|
50
|
-
|
|
31
|
+
export type CliFirestoreSdkIdentityProblem = FirebaseClientFirestoreIdentityProblem;
|
|
51
32
|
/**
|
|
52
|
-
* Where one consumer resolved `@firebase/firestore` to, and at which version.
|
|
53
|
-
*
|
|
54
|
-
* Reported for both `@dereekb/dbx-cli` and `@dereekb/firebase` because the whole point of the
|
|
55
|
-
* duplicated-SDK hypothesis is that those two answers can differ.
|
|
33
|
+
* Where one consumer resolved `@firebase/firestore` to, and at which version. See
|
|
34
|
+
* {@link FirebaseClientFirestoreSdkModuleIdentity}.
|
|
56
35
|
*/
|
|
57
|
-
export
|
|
58
|
-
/**
|
|
59
|
-
* The resolved package directory, or `undefined` when resolution failed.
|
|
60
|
-
*/
|
|
61
|
-
readonly packageDir?: Maybe<string>;
|
|
62
|
-
readonly version?: Maybe<string>;
|
|
63
|
-
/**
|
|
64
|
-
* Why resolution failed, when it did.
|
|
65
|
-
*/
|
|
66
|
-
readonly error?: Maybe<string>;
|
|
67
|
-
}
|
|
36
|
+
export type CliFirestoreSdkModuleIdentity = FirebaseClientFirestoreSdkModuleIdentity;
|
|
68
37
|
/**
|
|
69
|
-
* The provenance + brand-check report {@link inspectCliFirestoreSdkIdentity} produces.
|
|
70
|
-
*
|
|
71
|
-
* Everything here is reported whether or not the check passed: a `sdkDuplicated: true` alongside
|
|
72
|
-
* `ok: true` is a latent hazard worth seeing before it becomes an outage.
|
|
38
|
+
* The provenance + brand-check report {@link inspectCliFirestoreSdkIdentity} produces. See
|
|
39
|
+
* {@link FirebaseClientFirestoreIdentityReport}.
|
|
73
40
|
*/
|
|
74
|
-
export
|
|
75
|
-
readonly ok: boolean;
|
|
76
|
-
readonly problem?: CliFirestoreSdkIdentityProblem;
|
|
77
|
-
readonly firestorePresent: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Whether the handle passes `instanceof Firestore` against the copy of `@firebase/firestore` THIS
|
|
80
|
-
* package loaded.
|
|
81
|
-
*/
|
|
82
|
-
readonly firestoreIsSdkInstance: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* The handle's constructor name, which distinguishes a duplicate `Firestore` (same name, different
|
|
85
|
-
* class) from a genuinely foreign object.
|
|
86
|
-
*/
|
|
87
|
-
readonly firestoreConstructor?: Maybe<string>;
|
|
88
|
-
readonly firestoreDriverIdentifier?: Maybe<string>;
|
|
89
|
-
/**
|
|
90
|
-
* The version of the `firebase` umbrella package resolved at runtime.
|
|
91
|
-
*/
|
|
92
|
-
readonly firebaseVersion?: Maybe<string>;
|
|
93
|
-
readonly sdkFromDbxCli: CliFirestoreSdkModuleIdentity;
|
|
94
|
-
readonly sdkFromDbxFirebase: CliFirestoreSdkModuleIdentity;
|
|
95
|
-
/**
|
|
96
|
-
* True when the two resolutions above name DIFFERENT package directories.
|
|
97
|
-
*/
|
|
98
|
-
readonly sdkDuplicated: boolean;
|
|
99
|
-
}
|
|
41
|
+
export type CliFirestoreSdkIdentityReport = FirebaseClientFirestoreIdentityReport;
|
|
100
42
|
/**
|
|
101
|
-
* The slice of a session context {@link inspectCliFirestoreSdkIdentity} reads.
|
|
102
|
-
*
|
|
103
|
-
* Deliberately looser than `FirestoreContext`: this check exists precisely for the case where the
|
|
104
|
-
* object is not the shape its declared type claims, so narrowing it here would assume away the
|
|
105
|
-
* failure. A real `CliFirestoreSessionContext['firestoreContext']` is structurally assignable.
|
|
43
|
+
* The slice of a session context {@link inspectCliFirestoreSdkIdentity} reads. See
|
|
44
|
+
* {@link FirebaseClientFirestoreIdentityContext}.
|
|
106
45
|
*/
|
|
107
|
-
export
|
|
108
|
-
readonly firestore?: unknown;
|
|
109
|
-
readonly drivers?: {
|
|
110
|
-
readonly firestoreDriverIdentifier?: unknown;
|
|
111
|
-
};
|
|
112
|
-
}
|
|
46
|
+
export type CliFirestoreSdkIdentityContext = FirebaseClientFirestoreIdentityContext;
|
|
113
47
|
/**
|
|
114
48
|
* Input for {@link inspectCliFirestoreSdkIdentity}.
|
|
115
49
|
*/
|
|
@@ -117,20 +51,12 @@ export interface InspectCliFirestoreSdkIdentityInput {
|
|
|
117
51
|
readonly firestoreContext?: Maybe<CliFirestoreSdkIdentityContext>;
|
|
118
52
|
}
|
|
119
53
|
/**
|
|
120
|
-
* Checks that a session's Firestore handle is one
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* Exists because `collection()` refuses any non-`Firestore` first argument with one message —
|
|
124
|
-
* `Expected first argument to collection() to be a CollectionReference, a DocumentReference or
|
|
125
|
-
* FirebaseFirestore` — that names neither the model, nor the collection, nor which of the three
|
|
126
|
-
* distinct causes ({@link CliFirestoreSdkIdentityProblem}) produced it. Every downstream CLI built on
|
|
127
|
-
* `@dereekb/dbx-cli` shares that hazard, so the diagnosis belongs here rather than in an app.
|
|
54
|
+
* Checks that a session's Firestore handle is one the loaded client SDK will accept, and reports
|
|
55
|
+
* where every consumer resolved the SDK from.
|
|
128
56
|
*
|
|
129
|
-
* The
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* `firestore.error.ts`, which narrows a thrown `FirebaseError` structurally — there the goal is to
|
|
133
|
-
* classify an error even when copies differ, so the tradeoff runs the other way.)
|
|
57
|
+
* The CLI wrapper over {@link inspectFirebaseClientFirestoreIdentity}: it supplies this package's own
|
|
58
|
+
* `require` as the resolution root and names the CLI in the report, so `doctor`'s output is unchanged
|
|
59
|
+
* by the move of the inspection core into `@dereekb/oauth-resource/firebase`.
|
|
134
60
|
*
|
|
135
61
|
* @param input - The session's `firestoreContext`, when one was built.
|
|
136
62
|
* @returns The provenance + brand-check report.
|
|
@@ -149,12 +75,6 @@ export declare function inspectCliFirestoreSdkIdentity(input: InspectCliFirestor
|
|
|
149
75
|
* @__NO_SIDE_EFFECTS__
|
|
150
76
|
*/
|
|
151
77
|
export declare function cliFirestoreSdkIdentitySuggestion(report: CliFirestoreSdkIdentityReport): Maybe<string>;
|
|
152
|
-
/**
|
|
153
|
-
* `CliError` code for a collection/document reference the SDK refused to build for a reason the
|
|
154
|
-
* wiring identity check cannot explain — a bad `--parent`, or an app collection whose own
|
|
155
|
-
* construction is broken.
|
|
156
|
-
*/
|
|
157
|
-
export declare const FIRESTORE_COLLECTION_UNRESOLVABLE_CODE = "FIRESTORE_COLLECTION_UNRESOLVABLE";
|
|
158
78
|
/**
|
|
159
79
|
* Input for {@link cliFirestoreWiringError}.
|
|
160
80
|
*/
|