@dereekb/dbx-cli 13.11.3 → 13.11.4
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/index.cjs.js
CHANGED
|
@@ -4,6 +4,7 @@ var node_fs = require('node:fs');
|
|
|
4
4
|
var node_path = require('node:path');
|
|
5
5
|
var firebase = require('@dereekb/firebase');
|
|
6
6
|
var util = require('@dereekb/util');
|
|
7
|
+
var date = require('@dereekb/date');
|
|
7
8
|
var nestjs = require('@dereekb/nestjs');
|
|
8
9
|
var node_os = require('node:os');
|
|
9
10
|
var node_readline = require('node:readline');
|
|
@@ -2553,6 +2554,15 @@ function _ts_generator$a(thisArg, body) {
|
|
|
2553
2554
|
code_challenge_method: 'S256',
|
|
2554
2555
|
state: input.state
|
|
2555
2556
|
};
|
|
2557
|
+
if (input.requestedSessionTtlSeconds != null) {
|
|
2558
|
+
if (!Number.isInteger(input.requestedSessionTtlSeconds) || input.requestedSessionTtlSeconds <= 0) {
|
|
2559
|
+
throw new CliError({
|
|
2560
|
+
message: "requestedSessionTtlSeconds must be a positive integer (got ".concat(input.requestedSessionTtlSeconds, ")."),
|
|
2561
|
+
code: 'AUTH_LOGIN_FOR_INVALID'
|
|
2562
|
+
});
|
|
2563
|
+
}
|
|
2564
|
+
authParams.dbx_session_ttl = String(input.requestedSessionTtlSeconds);
|
|
2565
|
+
}
|
|
2556
2566
|
var endpoint;
|
|
2557
2567
|
if (input.appClientUrl) {
|
|
2558
2568
|
endpoint = rebaseUrlOrigin({
|
|
@@ -3332,11 +3342,14 @@ function maskEnv$1(env) {
|
|
|
3332
3342
|
type: 'boolean',
|
|
3333
3343
|
default: false,
|
|
3334
3344
|
describe: 'Drop model.create/model.update/model.delete from the requested scopes (keeps model.read and model.query)'
|
|
3345
|
+
}).option('login-for', {
|
|
3346
|
+
type: 'string',
|
|
3347
|
+
describe: 'Requested login duration with a unit (e.g. 30d, 12h, 3600s). Mixed units are allowed (e.g. "1h30m", "2d 12h"). Subject to server/client caps. Applied to Session, Grant, and RefreshToken.'
|
|
3335
3348
|
});
|
|
3336
3349
|
},
|
|
3337
3350
|
handler: function handler(argv) {
|
|
3338
3351
|
return _async_to_generator$9(function() {
|
|
3339
|
-
var _argv_code, _tokenResponse_expires_in, _ref, envName, env, meta, _ref1, codeVerifier, codeChallenge, state, requestedScopes, url, pasted, _tmp, code, tokenResponse, expiresAt, entry, e;
|
|
3352
|
+
var _argv_code, _tokenResponse_expires_in, _ref, envName, env, meta, _ref1, codeVerifier, codeChallenge, state, requestedScopes, requestedSessionTtlSeconds, ms, url, pasted, _tmp, code, tokenResponse, expiresAt, entry, e;
|
|
3340
3353
|
return _ts_generator$9(this, function(_state) {
|
|
3341
3354
|
switch(_state.label){
|
|
3342
3355
|
case 0:
|
|
@@ -3381,6 +3394,16 @@ function maskEnv$1(env) {
|
|
|
3381
3394
|
_ref1 = _state.sent(), codeVerifier = _ref1.codeVerifier, codeChallenge = _ref1.codeChallenge;
|
|
3382
3395
|
state = generateOAuthState();
|
|
3383
3396
|
requestedScopes = argv.readOnlyScopes ? filterReadOnlyModelScopes(env.scopes) : env.scopes;
|
|
3397
|
+
if (argv.loginFor) {
|
|
3398
|
+
ms = date.durationDataToMilliseconds(date.parseDurationString(argv.loginFor));
|
|
3399
|
+
if (ms <= 0) {
|
|
3400
|
+
throw new CliError({
|
|
3401
|
+
message: '--login-for: invalid duration "'.concat(argv.loginFor, '". Use formats like "30d", "12h", "3600s", or mixed units like "1h30m" or "2d 12h".'),
|
|
3402
|
+
code: 'AUTH_LOGIN_FOR_INVALID'
|
|
3403
|
+
});
|
|
3404
|
+
}
|
|
3405
|
+
requestedSessionTtlSeconds = Math.floor(ms / util.MS_IN_SECOND);
|
|
3406
|
+
}
|
|
3384
3407
|
url = buildAuthorizationUrl({
|
|
3385
3408
|
authorizationEndpoint: meta.authorization_endpoint,
|
|
3386
3409
|
apiBaseUrl: env.apiBaseUrl,
|
|
@@ -3389,7 +3412,8 @@ function maskEnv$1(env) {
|
|
|
3389
3412
|
redirectUri: env.redirectUri,
|
|
3390
3413
|
scopes: requestedScopes,
|
|
3391
3414
|
state: state,
|
|
3392
|
-
codeChallenge: codeChallenge
|
|
3415
|
+
codeChallenge: codeChallenge,
|
|
3416
|
+
requestedSessionTtlSeconds: requestedSessionTtlSeconds
|
|
3393
3417
|
});
|
|
3394
3418
|
// The CLI never opens a browser itself — it prints the URL and reads the redirect back.
|
|
3395
3419
|
// Emit the URL through a clearly-prefixed stderr line so JSON stdout stays parseable.
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, writeFileSync, appendFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
export { CALL_MODEL_APP_FUNCTION_KEY } from '@dereekb/firebase';
|
|
4
|
-
import { expirationDetails, generatePkceCodeVerifier, generatePkceCodeChallenge, noop } from '@dereekb/util';
|
|
4
|
+
import { expirationDetails, generatePkceCodeVerifier, generatePkceCodeChallenge, noop, MS_IN_SECOND } from '@dereekb/util';
|
|
5
|
+
import { durationDataToMilliseconds, parseDurationString } from '@dereekb/date';
|
|
5
6
|
import { readJsonFile, writeJsonFile, createMemoizedJsonFileAsyncKeyedValueCache } from '@dereekb/nestjs';
|
|
6
7
|
import { homedir } from 'node:os';
|
|
7
8
|
import { createInterface } from 'node:readline';
|
|
@@ -2551,6 +2552,15 @@ function _ts_generator$a(thisArg, body) {
|
|
|
2551
2552
|
code_challenge_method: 'S256',
|
|
2552
2553
|
state: input.state
|
|
2553
2554
|
};
|
|
2555
|
+
if (input.requestedSessionTtlSeconds != null) {
|
|
2556
|
+
if (!Number.isInteger(input.requestedSessionTtlSeconds) || input.requestedSessionTtlSeconds <= 0) {
|
|
2557
|
+
throw new CliError({
|
|
2558
|
+
message: "requestedSessionTtlSeconds must be a positive integer (got ".concat(input.requestedSessionTtlSeconds, ")."),
|
|
2559
|
+
code: 'AUTH_LOGIN_FOR_INVALID'
|
|
2560
|
+
});
|
|
2561
|
+
}
|
|
2562
|
+
authParams.dbx_session_ttl = String(input.requestedSessionTtlSeconds);
|
|
2563
|
+
}
|
|
2554
2564
|
var endpoint;
|
|
2555
2565
|
if (input.appClientUrl) {
|
|
2556
2566
|
endpoint = rebaseUrlOrigin({
|
|
@@ -3330,11 +3340,14 @@ function maskEnv$1(env) {
|
|
|
3330
3340
|
type: 'boolean',
|
|
3331
3341
|
default: false,
|
|
3332
3342
|
describe: 'Drop model.create/model.update/model.delete from the requested scopes (keeps model.read and model.query)'
|
|
3343
|
+
}).option('login-for', {
|
|
3344
|
+
type: 'string',
|
|
3345
|
+
describe: 'Requested login duration with a unit (e.g. 30d, 12h, 3600s). Mixed units are allowed (e.g. "1h30m", "2d 12h"). Subject to server/client caps. Applied to Session, Grant, and RefreshToken.'
|
|
3333
3346
|
});
|
|
3334
3347
|
},
|
|
3335
3348
|
handler: function handler(argv) {
|
|
3336
3349
|
return _async_to_generator$9(function() {
|
|
3337
|
-
var _argv_code, _tokenResponse_expires_in, _ref, envName, env, meta, _ref1, codeVerifier, codeChallenge, state, requestedScopes, url, pasted, _tmp, code, tokenResponse, expiresAt, entry, e;
|
|
3350
|
+
var _argv_code, _tokenResponse_expires_in, _ref, envName, env, meta, _ref1, codeVerifier, codeChallenge, state, requestedScopes, requestedSessionTtlSeconds, ms, url, pasted, _tmp, code, tokenResponse, expiresAt, entry, e;
|
|
3338
3351
|
return _ts_generator$9(this, function(_state) {
|
|
3339
3352
|
switch(_state.label){
|
|
3340
3353
|
case 0:
|
|
@@ -3379,6 +3392,16 @@ function maskEnv$1(env) {
|
|
|
3379
3392
|
_ref1 = _state.sent(), codeVerifier = _ref1.codeVerifier, codeChallenge = _ref1.codeChallenge;
|
|
3380
3393
|
state = generateOAuthState();
|
|
3381
3394
|
requestedScopes = argv.readOnlyScopes ? filterReadOnlyModelScopes(env.scopes) : env.scopes;
|
|
3395
|
+
if (argv.loginFor) {
|
|
3396
|
+
ms = durationDataToMilliseconds(parseDurationString(argv.loginFor));
|
|
3397
|
+
if (ms <= 0) {
|
|
3398
|
+
throw new CliError({
|
|
3399
|
+
message: '--login-for: invalid duration "'.concat(argv.loginFor, '". Use formats like "30d", "12h", "3600s", or mixed units like "1h30m" or "2d 12h".'),
|
|
3400
|
+
code: 'AUTH_LOGIN_FOR_INVALID'
|
|
3401
|
+
});
|
|
3402
|
+
}
|
|
3403
|
+
requestedSessionTtlSeconds = Math.floor(ms / MS_IN_SECOND);
|
|
3404
|
+
}
|
|
3382
3405
|
url = buildAuthorizationUrl({
|
|
3383
3406
|
authorizationEndpoint: meta.authorization_endpoint,
|
|
3384
3407
|
apiBaseUrl: env.apiBaseUrl,
|
|
@@ -3387,7 +3410,8 @@ function maskEnv$1(env) {
|
|
|
3387
3410
|
redirectUri: env.redirectUri,
|
|
3388
3411
|
scopes: requestedScopes,
|
|
3389
3412
|
state: state,
|
|
3390
|
-
codeChallenge: codeChallenge
|
|
3413
|
+
codeChallenge: codeChallenge,
|
|
3414
|
+
requestedSessionTtlSeconds: requestedSessionTtlSeconds
|
|
3391
3415
|
});
|
|
3392
3416
|
// The CLI never opens a browser itself — it prints the URL and reads the redirect back.
|
|
3393
3417
|
// Emit the URL through a clearly-prefixed stderr line so JSON stdout stays parseable.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli",
|
|
3
|
-
"version": "13.11.
|
|
3
|
+
"version": "13.11.4",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"bin": {
|
|
6
6
|
"dbx-cli-generate-firebase-api-manifest": "firebase-api-manifest/main.js"
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@dereekb/
|
|
28
|
-
"@dereekb/
|
|
29
|
-
"@dereekb/
|
|
27
|
+
"@dereekb/date": "13.11.4",
|
|
28
|
+
"@dereekb/firebase": "13.11.4",
|
|
29
|
+
"@dereekb/nestjs": "13.11.4",
|
|
30
|
+
"@dereekb/util": "13.11.4",
|
|
30
31
|
"arktype": "^2.2.0",
|
|
31
32
|
"yargs": "^18.0.0"
|
|
32
33
|
},
|
|
@@ -22,6 +22,13 @@ export interface BuildAuthorizationUrlInput {
|
|
|
22
22
|
readonly scopes?: string;
|
|
23
23
|
readonly state: string;
|
|
24
24
|
readonly codeChallenge: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional requested login duration in seconds. When set, the URL includes the
|
|
27
|
+
* `dbx_session_ttl=<seconds>` query param so the OIDC server applies the requested
|
|
28
|
+
* lifetime to the issued Session, Grant, and RefreshToken (subject to per-client and
|
|
29
|
+
* server caps).
|
|
30
|
+
*/
|
|
31
|
+
readonly requestedSessionTtlSeconds?: Maybe<number>;
|
|
25
32
|
}
|
|
26
33
|
/**
|
|
27
34
|
* Builds the authorization URL the user opens in a browser to start the PKCE flow.
|