@dereekb/dbx-cli 13.12.9 → 13.13.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/firebase-api-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/index.cjs.js +528 -163
- package/index.esm.js +525 -164
- package/lint-cache/package.json +2 -2
- package/manifest-extract/package.json +2 -2
- package/package.json +6 -6
- package/src/lib/auth/oidc.client.d.ts +35 -0
- package/src/lib/config/env.d.ts +45 -0
- package/src/lib/config/token.cache.d.ts +17 -0
- package/test/package.json +9 -9
package/lint-cache/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli-lint-cache",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.13.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devDependencies": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"eslint": "10.4.0"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"@dereekb/util": "13.
|
|
11
|
+
"@dereekb/util": "13.13.0",
|
|
12
12
|
"yargs": "^18.0.0"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli/manifest-extract",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.13.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"ts-morph": "^21.0.0"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@dereekb/firebase": "13.
|
|
9
|
+
"@dereekb/firebase": "13.13.0"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
"./package.json": "./package.json",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"bin": {
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@dereekb/date": "13.
|
|
45
|
-
"@dereekb/firebase": "13.
|
|
46
|
-
"@dereekb/model": "13.
|
|
47
|
-
"@dereekb/nestjs": "13.
|
|
48
|
-
"@dereekb/util": "13.
|
|
44
|
+
"@dereekb/date": "13.13.0",
|
|
45
|
+
"@dereekb/firebase": "13.13.0",
|
|
46
|
+
"@dereekb/model": "13.13.0",
|
|
47
|
+
"@dereekb/nestjs": "13.13.0",
|
|
48
|
+
"@dereekb/util": "13.13.0",
|
|
49
49
|
"@nestjs/common": "^11.1.19",
|
|
50
50
|
"arktype": "^2.2.0",
|
|
51
51
|
"jiti": "2.6.1",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Maybe } from '@dereekb/util';
|
|
1
2
|
/**
|
|
2
3
|
* The subset of fields we read from an OIDC discovery document.
|
|
3
4
|
*
|
|
@@ -137,3 +138,37 @@ export interface FetchUserInfoInput {
|
|
|
137
138
|
* @returns The parsed userinfo claims. Throws a {@link CliError} (`USERINFO_FAILED`) on a non-OK response.
|
|
138
139
|
*/
|
|
139
140
|
export declare function fetchUserInfo(input: FetchUserInfoInput): Promise<Record<string, unknown>>;
|
|
141
|
+
/**
|
|
142
|
+
* Session lifetime metadata returned by the `GET /oidc/session` route.
|
|
143
|
+
*/
|
|
144
|
+
export interface OidcSessionInfo {
|
|
145
|
+
readonly sub?: string;
|
|
146
|
+
readonly scope?: Maybe<string>;
|
|
147
|
+
/**
|
|
148
|
+
* Grant (session) expiry as unix epoch SECONDS, or `null` when the provider could not resolve it.
|
|
149
|
+
*/
|
|
150
|
+
readonly expiresAt?: Maybe<number>;
|
|
151
|
+
/**
|
|
152
|
+
* Whether refresh-token rotation is disabled for this grant (a long-lived service token).
|
|
153
|
+
*/
|
|
154
|
+
readonly rotationDisabled?: boolean;
|
|
155
|
+
}
|
|
156
|
+
export interface FetchSessionInfoInput {
|
|
157
|
+
/**
|
|
158
|
+
* The `GET /oidc/session` endpoint URL (typically `<oidcIssuer>/session`).
|
|
159
|
+
*/
|
|
160
|
+
readonly sessionEndpoint: string;
|
|
161
|
+
readonly accessToken: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Fetches the dbx-components `GET /oidc/session` route and returns the parsed session lifetime metadata.
|
|
165
|
+
*
|
|
166
|
+
* Mirrors {@link fetchUserInfo}, but reads the access token's baked-in session-lifetime claims
|
|
167
|
+
* (`dbx_session_expires_at` / `dbx_rotation_disabled`) which userinfo does not echo.
|
|
168
|
+
*
|
|
169
|
+
* @param input - The session request.
|
|
170
|
+
* @param input.sessionEndpoint - The `GET /oidc/session` endpoint URL.
|
|
171
|
+
* @param input.accessToken - The Bearer access token sent in the `Authorization` header.
|
|
172
|
+
* @returns The parsed {@link OidcSessionInfo}. Throws a {@link CliError} (`SESSION_INFO_FAILED`) on a non-OK response.
|
|
173
|
+
*/
|
|
174
|
+
export declare function fetchSessionInfo(input: FetchSessionInfoInput): Promise<OidcSessionInfo>;
|
package/src/lib/config/env.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Maybe } from '@dereekb/util';
|
|
2
|
+
import { type CliTokenEntry } from './token.cache';
|
|
2
3
|
/**
|
|
3
4
|
* The default OAuth/OIDC scopes requested by the CLI when none are configured.
|
|
4
5
|
*/
|
|
@@ -17,6 +18,15 @@ export declare const MODEL_WRITE_OIDC_SCOPES: readonly ["model.create", "model.u
|
|
|
17
18
|
* Opens up to nothing in the browser so the user can copy/paste the resulting token url back into the CLI.
|
|
18
19
|
*/
|
|
19
20
|
export declare const DEFAULT_CLI_REDIRECT_URI = "http://127.0.0.1:0/callback";
|
|
21
|
+
/**
|
|
22
|
+
* The generic OIDC scopes a `--service-token` login adds to the requested set.
|
|
23
|
+
*
|
|
24
|
+
* `token.service` triggers the admin-only, long-lived, non-rotating behavior server-side;
|
|
25
|
+
* `offline_access` is required so a refresh token is issued (the durable credential the server env
|
|
26
|
+
* consumes). The app's own resource scope (e.g. `demo`) is intentionally NOT included here — it
|
|
27
|
+
* already lives in the configured `env.scopes`, keeping this generic CLI app-agnostic.
|
|
28
|
+
*/
|
|
29
|
+
export declare const SERVICE_TOKEN_REQUIRED_OIDC_SCOPES: readonly ["token.service", "offline_access"];
|
|
20
30
|
/**
|
|
21
31
|
* Returns the input scope string with the `model.create`, `model.update`, and `model.delete`
|
|
22
32
|
* scopes removed, preserving every other scope (including `model.read` and `model.query`).
|
|
@@ -28,6 +38,17 @@ export declare const DEFAULT_CLI_REDIRECT_URI = "http://127.0.0.1:0/callback";
|
|
|
28
38
|
* @returns The filtered space-separated scope list.
|
|
29
39
|
*/
|
|
30
40
|
export declare function filterReadOnlyModelScopes(scopes: Maybe<string>): string;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the input scope string with the {@link SERVICE_TOKEN_REQUIRED_OIDC_SCOPES} unioned in
|
|
43
|
+
* (de-duplicated), preserving every other already-requested scope.
|
|
44
|
+
*
|
|
45
|
+
* Drives the `auth login --service-token` flag. Combinable with `filterReadOnlyModelScopes` — apply
|
|
46
|
+
* the read-only filter first, then this, so a service token can still be read-only.
|
|
47
|
+
*
|
|
48
|
+
* @param scopes - Space-separated scope list, or `undefined` to augment the default scopes.
|
|
49
|
+
* @returns The augmented space-separated scope list.
|
|
50
|
+
*/
|
|
51
|
+
export declare function withServiceTokenScopes(scopes: Maybe<string>): string;
|
|
31
52
|
/**
|
|
32
53
|
* A built-in env config preset shipped with a CLI app.
|
|
33
54
|
*
|
|
@@ -189,3 +210,27 @@ export declare function applyEnvVarOverrides(input: EnvVarOverrideInput): Maybe<
|
|
|
189
210
|
* @returns `true` when `apiBaseUrl`, `oidcIssuer`, `clientId`, `clientSecret`, and `redirectUri` are all present and non-empty.
|
|
190
211
|
*/
|
|
191
212
|
export declare function isCliEnvConfigComplete(env: Maybe<CliEnvConfig>): env is Required<Pick<CliEnvConfig, 'apiBaseUrl' | 'oidcIssuer' | 'clientId' | 'clientSecret' | 'redirectUri'>> & CliEnvConfig;
|
|
213
|
+
/**
|
|
214
|
+
* Inputs to {@link readEnvTokenEntry}.
|
|
215
|
+
*/
|
|
216
|
+
export interface ReadEnvTokenEntryInput {
|
|
217
|
+
readonly cliName: string;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Reads an OAuth token entry from environment variables, for non-interactive server consumption.
|
|
221
|
+
*
|
|
222
|
+
* Reads `<PREFIX>_REFRESH_TOKEN` (required) plus the optional `<PREFIX>_ACCESS_TOKEN` and
|
|
223
|
+
* `<PREFIX>_TOKEN_SCOPE`, where `PREFIX = cliName.replaceAll('-', '_').toUpperCase()` (the existing
|
|
224
|
+
* env-var prefix convention). The intended credential is a long-lived, non-rotating service token
|
|
225
|
+
* (see `auth login --service-token`).
|
|
226
|
+
*
|
|
227
|
+
* Returns `undefined` when no refresh token is present. When only a refresh token is supplied, the
|
|
228
|
+
* returned entry has `accessToken: ''` and `expiresAt: 0` so the first use is forced to mint an
|
|
229
|
+
* access token via a refresh. The entry is flagged `fromEnv: true` so the middleware does not write
|
|
230
|
+
* it back to the on-disk cache.
|
|
231
|
+
*
|
|
232
|
+
* @param input - The lookup inputs.
|
|
233
|
+
* @param input.cliName - The CLI name used to derive the env-var prefix (e.g. `demo-cli` → `DEMO_CLI`).
|
|
234
|
+
* @returns The env-sourced {@link CliTokenEntry}, or `undefined` when no refresh token is set.
|
|
235
|
+
*/
|
|
236
|
+
export declare function readEnvTokenEntry(input: ReadEnvTokenEntryInput): Maybe<CliTokenEntry>;
|
|
@@ -12,6 +12,23 @@ export interface CliTokenEntry {
|
|
|
12
12
|
readonly tokenType?: string;
|
|
13
13
|
readonly scope?: string;
|
|
14
14
|
readonly idToken?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Unix epoch SECONDS at which the underlying grant (session) expires, as reported by the OIDC
|
|
17
|
+
* `GET /oidc/session` route (`dbx_session_expires_at`). Distinct from {@link expiresAt}, which is
|
|
18
|
+
* the short-lived access token's expiry in milliseconds. Used to surface the session lifetime.
|
|
19
|
+
*/
|
|
20
|
+
readonly sessionExpiresAt?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Whether refresh-token rotation is disabled for this grant (a long-lived service token).
|
|
23
|
+
* Sourced from the `GET /oidc/session` route (`dbx_rotation_disabled`).
|
|
24
|
+
*/
|
|
25
|
+
readonly rotationDisabled?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Transient (never persisted) marker that this entry was sourced from environment variables rather
|
|
28
|
+
* than the on-disk cache. Env-sourced entries are not written back after a refresh — see the auth
|
|
29
|
+
* middleware. Set by `readEnvTokenEntry`.
|
|
30
|
+
*/
|
|
31
|
+
readonly fromEnv?: boolean;
|
|
15
32
|
}
|
|
16
33
|
/**
|
|
17
34
|
* Token cache shape on disk — keyed by env name.
|
package/test/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli/test",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.13.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/date": "13.
|
|
6
|
-
"@dereekb/dbx-cli": "13.
|
|
7
|
-
"@dereekb/firebase": "13.
|
|
8
|
-
"@dereekb/firebase-server/test": "13.
|
|
9
|
-
"@dereekb/model": "13.
|
|
10
|
-
"@dereekb/nestjs": "13.
|
|
11
|
-
"@dereekb/rxjs": "13.
|
|
12
|
-
"@dereekb/util": "13.
|
|
5
|
+
"@dereekb/date": "13.13.0",
|
|
6
|
+
"@dereekb/dbx-cli": "13.13.0",
|
|
7
|
+
"@dereekb/firebase": "13.13.0",
|
|
8
|
+
"@dereekb/firebase-server/test": "13.13.0",
|
|
9
|
+
"@dereekb/model": "13.13.0",
|
|
10
|
+
"@dereekb/nestjs": "13.13.0",
|
|
11
|
+
"@dereekb/rxjs": "13.13.0",
|
|
12
|
+
"@dereekb/util": "13.13.0",
|
|
13
13
|
"@nestjs/common": "^11.1.19",
|
|
14
14
|
"arktype": "^2.2.0",
|
|
15
15
|
"vitest": "4.1.5",
|