@genspark/cli 1.7.0 → 1.7.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.
- package/README.md +21 -9
- package/dist/commands/aidrive-download.d.ts +7 -0
- package/dist/commands/aidrive-download.d.ts.map +1 -1
- package/dist/commands/aidrive-download.js +17 -1
- package/dist/commands/aidrive-download.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -44
- package/dist/index.js.map +1 -1
- package/docs/skills.md +3 -3
- package/package.json +1 -1
- package/skills/gsk-aidrive/SKILL.md +38 -24
- package/skills/gsk-batch-crawl-url-and-answer/SKILL.md +7 -7
- package/skills/gsk-genteam/SKILL.md +24 -18
- package/skills/gsk-google-chat/SKILL.md +2 -0
- package/skills/gsk-hub/SKILL.md +1 -1
- package/skills/gsk-meeting/SKILL.md +8 -2
- package/skills/gsk-microsoft-teams/SKILL.md +4 -3
- package/skills/gsk-phone-call/SKILL.md +19 -11
- package/skills/gsk-sharepoint/SKILL.md +1 -1
- package/skills/gsk-slack/SKILL.md +3 -2
- package/skills/gsk-video-generation/SKILL.md +3 -3
- package/skills/gsk-youtube/SKILL.md +11 -4
package/README.md
CHANGED
|
@@ -394,12 +394,19 @@ gsk transcribe -i ./meeting.wav -m "whisper-large-v3"
|
|
|
394
394
|
|
|
395
395
|
### aidrive (alias: `drive`)
|
|
396
396
|
|
|
397
|
-
AI-Drive file storage and management.
|
|
397
|
+
AI-Drive file storage and management. Canonical workspaces are `my_drive`,
|
|
398
|
+
`shared_with_me`, and `shared_drive`. Run `ls` on a shared workspace first, then pass
|
|
399
|
+
the returned stable `source_id` to work inside one source. `shared_with_me` is
|
|
400
|
+
an ACL-filtered view and does not own bytes or quota.
|
|
398
401
|
|
|
399
402
|
```bash
|
|
400
403
|
# List files in root directory
|
|
401
|
-
gsk drive ls
|
|
402
|
-
gsk drive ls -p "/documents" -f file
|
|
404
|
+
gsk drive ls --workspace my_drive
|
|
405
|
+
gsk drive ls --workspace my_drive -p "/documents" -f file
|
|
406
|
+
|
|
407
|
+
# Discover and read a source shared with you
|
|
408
|
+
gsk drive ls --workspace shared_with_me
|
|
409
|
+
gsk drive ls --workspace shared_with_me --source "<source_id>"
|
|
403
410
|
|
|
404
411
|
# Create directory
|
|
405
412
|
gsk drive mkdir -p "/my-folder"
|
|
@@ -407,10 +414,13 @@ gsk drive mkdir -p "/my-folder"
|
|
|
407
414
|
# Move file
|
|
408
415
|
gsk drive move -p "/old-path/file.txt" --target_path "/new-path/file.txt"
|
|
409
416
|
|
|
410
|
-
# Download video/audio/file
|
|
417
|
+
# Download an external video/audio/file into AI-Drive (the "download for me" actions)
|
|
411
418
|
gsk drive download_video --video_url "https://example.com/video.mp4" --target_folder "/videos"
|
|
412
419
|
gsk drive download_file --file_url "https://example.com/doc.pdf" --target_folder "/docs"
|
|
413
420
|
|
|
421
|
+
# Download an AI-Drive file to the local machine
|
|
422
|
+
gsk drive download "/docs/report.pdf" ./report.pdf
|
|
423
|
+
|
|
414
424
|
# Upload inline text content to AI-Drive
|
|
415
425
|
gsk drive upload --file_content "Hello World" --upload_path "/notes/hello.txt"
|
|
416
426
|
|
|
@@ -427,15 +437,17 @@ gsk drive get_readable_url -p "/documents/report.pdf"
|
|
|
427
437
|
|
|
428
438
|
| Option | Default | Description |
|
|
429
439
|
|--------|---------|-------------|
|
|
440
|
+
| `--workspace <name>` | `my_drive` | `my_drive`, `shared_with_me`, or `shared_drive` |
|
|
441
|
+
| `--source <id>` | — | Stable source ID returned by listing a shared workspace |
|
|
430
442
|
| `-p, --path <path>` | — | File or directory path in AI-Drive |
|
|
431
443
|
| `-f, --filter_type <type>` | `all` | Filter: `all`, `file`, `directory` |
|
|
432
444
|
| `--file_type <type>` | `all` | File type filter: `all`, `audio`, `video`, `image` |
|
|
433
445
|
| `--target_path <path>` | — | Target path for move operations |
|
|
434
|
-
| `--target_folder <path>` | — | Target folder for
|
|
435
|
-
| `--video_url <url>` | — |
|
|
436
|
-
| `--audio_url <url>` | — |
|
|
437
|
-
| `--file_url <url>` | — |
|
|
438
|
-
| `--file_name <name>` | — | Custom
|
|
446
|
+
| `--target_folder <path>` | — | Target folder for `download_video`, `download_audio`, or `download_file` |
|
|
447
|
+
| `--video_url <url>` | — | External video URL for `download_video` |
|
|
448
|
+
| `--audio_url <url>` | — | External audio/video URL for `download_audio` |
|
|
449
|
+
| `--file_url <url>` | — | External file URL for `download_file` |
|
|
450
|
+
| `--file_name <name>` | — | Custom filename for `download_file` |
|
|
439
451
|
| `--file_content <text>` | — | Inline text content to upload |
|
|
440
452
|
| `--local_file <path>` | — | Local file path to upload directly to AI-Drive (streaming, no size limit) |
|
|
441
453
|
| `--upload_path <path>` | — | Destination path for upload (defaults to `/<filename>` for `--local_file`) |
|
|
@@ -20,4 +20,11 @@ export declare function normalizeDrivePath(pathOrUrl: string): string;
|
|
|
20
20
|
* be parsed; the structured value lives in `session_state.aidrive_result`.
|
|
21
21
|
*/
|
|
22
22
|
export declare function extractReadableUrl(response: Pick<ApiResponse, 'status' | 'session_state'>): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* A file-wrapper URL carrying its own access token is already the final,
|
|
25
|
+
* fetchable URL. Sending it through `/file/download` re-checks ownership and
|
|
26
|
+
* incorrectly rejects files the caller may read through a Drive share.
|
|
27
|
+
* Token-less wrapper URLs still need the resolver used by other CLI exports.
|
|
28
|
+
*/
|
|
29
|
+
export declare function shouldResolveFileWrapperUrl(url: string): boolean;
|
|
23
30
|
//# sourceMappingURL=aidrive-download.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aidrive-download.d.ts","sourceRoot":"","sources":["../../src/commands/aidrive-download.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,iBAAiB,CAAC,EAAE,MAAM,GACzB;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAQ5C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,eAAe,CAAC,GACtD,MAAM,GAAG,SAAS,CAMpB"}
|
|
1
|
+
{"version":3,"file":"aidrive-download.d.ts","sourceRoot":"","sources":["../../src/commands/aidrive-download.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,iBAAiB,CAAC,EAAE,MAAM,GACzB;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAQ5C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,eAAe,CAAC,GACtD,MAAM,GAAG,SAAS,CAMpB;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOhE"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* `--path`/`-p`, the first operand is the destination instead.
|
|
5
5
|
*/
|
|
6
6
|
export function resolveAidriveDownloadOperands(operands, explicitDrivePath) {
|
|
7
|
-
const bareOperands = operands.filter(
|
|
7
|
+
const bareOperands = operands.filter(operand => operand.length > 0 && !operand.startsWith('-'));
|
|
8
8
|
if (explicitDrivePath) {
|
|
9
9
|
return { drivePath: explicitDrivePath, localPath: bareOperands[0] };
|
|
10
10
|
}
|
|
@@ -33,4 +33,20 @@ export function extractReadableUrl(response) {
|
|
|
33
33
|
const url = aidriveResult.readable_url;
|
|
34
34
|
return typeof url === 'string' && url ? url : undefined;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* A file-wrapper URL carrying its own access token is already the final,
|
|
38
|
+
* fetchable URL. Sending it through `/file/download` re-checks ownership and
|
|
39
|
+
* incorrectly rejects files the caller may read through a Drive share.
|
|
40
|
+
* Token-less wrapper URLs still need the resolver used by other CLI exports.
|
|
41
|
+
*/
|
|
42
|
+
export function shouldResolveFileWrapperUrl(url) {
|
|
43
|
+
if (!url.includes('/api/files/'))
|
|
44
|
+
return false;
|
|
45
|
+
try {
|
|
46
|
+
return !new URL(url, 'https://local.invalid').searchParams.has('token');
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
36
52
|
//# sourceMappingURL=aidrive-download.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aidrive-download.js","sourceRoot":"","sources":["../../src/commands/aidrive-download.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,QAA2B,EAC3B,iBAA0B;IAE1B,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAClC,
|
|
1
|
+
{"version":3,"file":"aidrive-download.js","sourceRoot":"","sources":["../../src/commands/aidrive-download.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,QAA2B,EAC3B,iBAA0B;IAE1B,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAClC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAC1D,CAAA;IACD,IAAI,iBAAiB,EAAE,CAAC;QACtB,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAA;IACrE,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAA;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAClD,kEAAkE;IAClE,OAAO,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAuD;IAEvD,IAAI,QAAQ,CAAC,MAAM,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IAC9C,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,EAAE,cAAc,CAAA;IAC5D,IAAI,CAAC,aAAa,IAAI,OAAO,aAAa,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAA;IACzE,MAAM,GAAG,GAAI,aAAyC,CAAC,YAAY,CAAA;IACnE,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAA;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,GAAW;IACrD,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAC;QAAE,OAAO,KAAK,CAAA;IAC9C,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACzE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;AAkRH,KAAK,oBAAoB,GAAG,kBAAkB,GAAG,SAAS,GAAG,SAAS,CAAA;AAEtE,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,oBAAoB,CAAA;CAC3B;AAED,kFAAkF;AAClF,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EAAE,GACb,mBAAmB,EAAE,CAqBvB"}
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ import { shimLegacyTaskInvocation } from './task-shim.js';
|
|
|
38
38
|
import { getSandboxRuntime } from './runtime.js';
|
|
39
39
|
import { registerDesignCommand } from './commands/design.js';
|
|
40
40
|
import { collectUploadFiles, pickExistingUploadOperand, } from './commands/aidrive-upload.js';
|
|
41
|
-
import { resolveAidriveDownloadOperands, normalizeDrivePath, extractReadableUrl, } from './commands/aidrive-download.js';
|
|
41
|
+
import { resolveAidriveDownloadOperands, normalizeDrivePath, extractReadableUrl, shouldResolveFileWrapperUrl, } from './commands/aidrive-download.js';
|
|
42
42
|
import { parseLastSeenIndex, eventStdoutLine } from './commands/chat-events.js';
|
|
43
43
|
import { mediaItemsKeyFor, mediaSummaryLines } from './mediaSummary.js';
|
|
44
44
|
import { registerMeshCommand, getMeshInvocation, runMesh, } from './commands/mesh.js';
|
|
@@ -359,7 +359,7 @@ async function uploadLocalFile(filePath, client) {
|
|
|
359
359
|
*
|
|
360
360
|
* This avoids the roundabout blob-upload + download_file two-step approach.
|
|
361
361
|
*/
|
|
362
|
-
async function uploadToAiDrive(filePath, uploadPath, override = false, workspace = '
|
|
362
|
+
async function uploadToAiDrive(filePath, uploadPath, override = false, workspace = 'my_drive', source) {
|
|
363
363
|
const fileName = pathModule.basename(filePath);
|
|
364
364
|
const ext = pathModule.extname(filePath).toLowerCase();
|
|
365
365
|
const contentType = CONTENT_TYPE_MAP[ext] || 'application/octet-stream';
|
|
@@ -367,7 +367,15 @@ async function uploadToAiDrive(filePath, uploadPath, override = false, workspace
|
|
|
367
367
|
info(`Uploading ${fileName} (${formatFileSize(fileSize)}, ${contentType}) directly to AI Drive...`);
|
|
368
368
|
const globalOpts = getGlobalOptions();
|
|
369
369
|
const baseUrl = globalOpts.baseUrl.replace(/\/$/, '');
|
|
370
|
-
const
|
|
370
|
+
const uploadQuery = new URLSearchParams({
|
|
371
|
+
upload_path: uploadPath,
|
|
372
|
+
workspace,
|
|
373
|
+
});
|
|
374
|
+
if (override)
|
|
375
|
+
uploadQuery.set('override', 'true');
|
|
376
|
+
if (source)
|
|
377
|
+
uploadQuery.set('source', source);
|
|
378
|
+
const uploadUrl = `${baseUrl}/api/tool_cli/aidrive/upload?${uploadQuery.toString()}`;
|
|
371
379
|
const headers = { 'Content-Type': contentType };
|
|
372
380
|
if (globalOpts.apiKey)
|
|
373
381
|
headers['X-Api-Key'] = globalOpts.apiKey;
|
|
@@ -385,8 +393,10 @@ async function uploadToAiDrive(filePath, uploadPath, override = false, workspace
|
|
|
385
393
|
async function downloadToFile(url, savePath, client) {
|
|
386
394
|
info(`Downloading to ${savePath}...`);
|
|
387
395
|
let downloadUrl = url;
|
|
388
|
-
//
|
|
389
|
-
|
|
396
|
+
// Token-less file wrappers need `/file/download`; a signed wrapper is
|
|
397
|
+
// already fetchable and must keep its share token (important for Drive
|
|
398
|
+
// files whose storage owner is not the caller).
|
|
399
|
+
if (shouldResolveFileWrapperUrl(url)) {
|
|
390
400
|
const result = await client.getDownloadUrl({ file_wrapper_url: url });
|
|
391
401
|
if (result.status !== 'ok' || !result.data)
|
|
392
402
|
throw new Error(`Failed to get download URL: ${result.message}`);
|
|
@@ -831,7 +841,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
831
841
|
// upload and by `download`'s local destination.
|
|
832
842
|
if (tool.name === 'aidrive') {
|
|
833
843
|
if (!Object.hasOwn(props, 'workspace')) {
|
|
834
|
-
cmd.option('--workspace <value>', 'AI Drive workspace:
|
|
844
|
+
cmd.option('--workspace <value>', 'AI Drive workspace: my_drive, shared_with_me, or shared_drive');
|
|
835
845
|
}
|
|
836
846
|
cmd.option('--local_file <path>', 'upload: local file path to upload to AI Drive (supports files >5 MB; ' +
|
|
837
847
|
'alternative to --file_content). download: local destination path ' +
|
|
@@ -1224,9 +1234,12 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1224
1234
|
// rather than making the caller strip the scheme.
|
|
1225
1235
|
const drivePath = normalizeDrivePath(sourceOperand);
|
|
1226
1236
|
const urlResult = await client.executeTool('aidrive', {
|
|
1237
|
+
// Use the established wire spelling; both older backends and the
|
|
1238
|
+
// current canonical contract recognize it.
|
|
1227
1239
|
action: 'get_readable_url',
|
|
1228
1240
|
path: drivePath,
|
|
1229
1241
|
workspace: args.workspace,
|
|
1242
|
+
source: args.source,
|
|
1230
1243
|
share: args.share,
|
|
1231
1244
|
});
|
|
1232
1245
|
const readableUrl = extractReadableUrl(urlResult);
|
|
@@ -1280,7 +1293,9 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1280
1293
|
opts.local_file) {
|
|
1281
1294
|
const localFilePath = opts.local_file;
|
|
1282
1295
|
const override = !!opts.override;
|
|
1283
|
-
const workspace = args.workspace || '
|
|
1296
|
+
const workspace = args.workspace || 'my_drive';
|
|
1297
|
+
const source = args.source ||
|
|
1298
|
+
args.share;
|
|
1284
1299
|
if (!fs.existsSync(localFilePath)) {
|
|
1285
1300
|
logError(`File not found: ${localFilePath}`);
|
|
1286
1301
|
process.exit(1);
|
|
@@ -1303,7 +1318,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1303
1318
|
const uploaded = [];
|
|
1304
1319
|
for (const file of files) {
|
|
1305
1320
|
const destination = pathModule.posix.join(uploadPath, file.relativePath);
|
|
1306
|
-
const result = await uploadToAiDrive(file.absolutePath, destination, override, workspace);
|
|
1321
|
+
const result = await uploadToAiDrive(file.absolutePath, destination, override, workspace, source);
|
|
1307
1322
|
if (result.status !== 'ok') {
|
|
1308
1323
|
output(result);
|
|
1309
1324
|
process.exit(1);
|
|
@@ -1318,7 +1333,7 @@ function registerToolCommand(parentProgram, tool, clientFactory, vdProjectIdDefa
|
|
|
1318
1333
|
}
|
|
1319
1334
|
else {
|
|
1320
1335
|
// Stream directly to AI Drive — single request, no blob middleman
|
|
1321
|
-
const result = await uploadToAiDrive(localFilePath, uploadPath, override, workspace);
|
|
1336
|
+
const result = await uploadToAiDrive(localFilePath, uploadPath, override, workspace, source);
|
|
1322
1337
|
output(result);
|
|
1323
1338
|
}
|
|
1324
1339
|
return;
|
|
@@ -1748,7 +1763,8 @@ program
|
|
|
1748
1763
|
program
|
|
1749
1764
|
.command('login')
|
|
1750
1765
|
.description('Log in to Genspark via browser to obtain an API key')
|
|
1751
|
-
.
|
|
1766
|
+
.option('--no-open', 'Print the login URL without opening a browser')
|
|
1767
|
+
.action(async (loginOpts) => {
|
|
1752
1768
|
const globalOpts = getGlobalOptions();
|
|
1753
1769
|
setDebugEnabled(globalOpts.debug);
|
|
1754
1770
|
setOutputFormat(globalOpts.output);
|
|
@@ -1758,44 +1774,52 @@ program
|
|
|
1758
1774
|
info('Requesting device code...');
|
|
1759
1775
|
const deviceResp = await unauthenticatedRequest(baseUrl, '/api/cli_auth/device_code', 'POST');
|
|
1760
1776
|
const { device_code, auth_url, poll_interval, expires_in } = deviceResp;
|
|
1761
|
-
// Step 2: Open browser
|
|
1762
|
-
|
|
1777
|
+
// Step 2: Open browser unless the caller explicitly opted out. Tests
|
|
1778
|
+
// and headless automation use --no-open so a mock URL never escapes
|
|
1779
|
+
// into the user's desktop session.
|
|
1780
|
+
if (loginOpts.open !== false)
|
|
1781
|
+
info('Opening browser for login...');
|
|
1763
1782
|
info(`Login URL: ${auth_url}`);
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
cmd
|
|
1779
|
-
args
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1783
|
+
if (loginOpts.open === false) {
|
|
1784
|
+
info('Browser opening disabled; open the URL above manually.');
|
|
1785
|
+
}
|
|
1786
|
+
else {
|
|
1787
|
+
// Validate auth_url is a same-origin HTTP(S) URL before passing to spawn
|
|
1788
|
+
try {
|
|
1789
|
+
const parsed = new URL(auth_url);
|
|
1790
|
+
const base = new URL(baseUrl);
|
|
1791
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
1792
|
+
throw new Error('auth_url is not http(s)');
|
|
1793
|
+
}
|
|
1794
|
+
if (parsed.host !== base.host) {
|
|
1795
|
+
throw new Error('auth_url host does not match baseUrl host');
|
|
1796
|
+
}
|
|
1797
|
+
let cmd;
|
|
1798
|
+
let args;
|
|
1799
|
+
if (process.platform === 'win32') {
|
|
1800
|
+
// Avoid cmd.exe which interprets & in URLs as command separators
|
|
1801
|
+
cmd = 'rundll32';
|
|
1802
|
+
args = ['url.dll,FileProtocolHandler', auth_url];
|
|
1803
|
+
}
|
|
1804
|
+
else if (process.platform === 'darwin') {
|
|
1805
|
+
cmd = 'open';
|
|
1806
|
+
args = [auth_url];
|
|
1807
|
+
}
|
|
1808
|
+
else {
|
|
1809
|
+
cmd = 'xdg-open';
|
|
1810
|
+
args = [auth_url];
|
|
1811
|
+
}
|
|
1812
|
+
const child = spawn(cmd, args, { stdio: 'ignore', detached: true });
|
|
1813
|
+
child.on('error', () => {
|
|
1814
|
+
info('Could not open browser automatically.');
|
|
1815
|
+
info('Please open the URL above manually.');
|
|
1816
|
+
});
|
|
1817
|
+
child.unref();
|
|
1788
1818
|
}
|
|
1789
|
-
|
|
1790
|
-
child.on('error', () => {
|
|
1819
|
+
catch {
|
|
1791
1820
|
info('Could not open browser automatically.');
|
|
1792
1821
|
info('Please open the URL above manually.');
|
|
1793
|
-
}
|
|
1794
|
-
child.unref();
|
|
1795
|
-
}
|
|
1796
|
-
catch {
|
|
1797
|
-
info('Could not open browser automatically.');
|
|
1798
|
-
info('Please open the URL above manually.');
|
|
1822
|
+
}
|
|
1799
1823
|
}
|
|
1800
1824
|
info(`Waiting for authorization (expires in ${expires_in}s, press Ctrl+C to cancel)...`);
|
|
1801
1825
|
// Step 3: Poll for token
|