@hasna/connectors 1.3.21 → 1.3.23
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/bin/index.js +274 -71
- package/bin/mcp.js +458 -197
- package/bin/serve.js +77 -33
- package/connectors/connect-dropbox/src/api/bulk.ts +285 -0
- package/connectors/connect-dropbox/src/api/index.ts +4 -0
- package/connectors/connect-dropbox/src/cli/index.ts +151 -0
- package/connectors/connect-github/src/api/bulk.ts +328 -0
- package/connectors/connect-github/src/api/index.ts +4 -0
- package/connectors/connect-github/src/cli/index.ts +145 -0
- package/connectors/connect-gmail/src/api/history.ts +82 -0
- package/connectors/connect-gmail/src/api/index.ts +12 -0
- package/connectors/connect-gmail/src/api/settings.ts +280 -0
- package/connectors/connect-gmail/src/api/watch.ts +40 -0
- package/connectors/connect-gmail/src/cli/index.ts +237 -0
- package/connectors/connect-googleads/src/api/bulk.ts +354 -0
- package/connectors/connect-googleads/src/api/index.ts +4 -0
- package/connectors/connect-googleads/src/cli/index.ts +192 -0
- package/connectors/connect-googlecalendar/src/api/acl.ts +66 -0
- package/connectors/connect-googlecalendar/src/api/bulk.ts +452 -0
- package/connectors/connect-googlecalendar/src/api/freebusy.ts +35 -0
- package/connectors/connect-googlecalendar/src/api/index.ts +9 -0
- package/connectors/connect-googlecalendar/src/cli/index.ts +522 -0
- package/connectors/connect-googlecalendar/src/types/index.ts +90 -0
- package/connectors/connect-googlecontacts/src/api/bulk.ts +365 -0
- package/connectors/connect-googlecontacts/src/api/groups.ts +164 -0
- package/connectors/connect-googlecontacts/src/api/index.ts +8 -0
- package/connectors/connect-googlecontacts/src/cli/index.ts +340 -0
- package/connectors/connect-googledocs/src/api/bulk.ts +301 -0
- package/connectors/connect-googledocs/src/api/index.ts +4 -0
- package/connectors/connect-googledocs/src/cli/index.ts +187 -0
- package/connectors/connect-googledrive/src/api/bulk.ts +505 -0
- package/connectors/connect-googledrive/src/api/changes.ts +139 -0
- package/connectors/connect-googledrive/src/api/client.ts +34 -0
- package/connectors/connect-googledrive/src/api/index.ts +12 -0
- package/connectors/connect-googledrive/src/api/revisions.ts +132 -0
- package/connectors/connect-googledrive/src/cli/index.ts +624 -0
- package/connectors/connect-googledrive/src/index.ts +2 -0
- package/connectors/connect-googlephotos/src/api/bulk.ts +455 -0
- package/connectors/connect-googlephotos/src/api/index.ts +8 -0
- package/connectors/connect-googlephotos/src/cli/index.ts +185 -0
- package/connectors/connect-googletasks/src/api/bulk.ts +359 -0
- package/connectors/connect-googletasks/src/api/index.ts +1 -0
- package/connectors/connect-googletasks/src/cli/index.ts +178 -0
- package/connectors/connect-linear/src/api/bulk.ts +219 -0
- package/connectors/connect-linear/src/api/index.ts +4 -0
- package/connectors/connect-linear/src/cli/index.ts +116 -0
- package/connectors/connect-shopify/src/api/bulk.ts +288 -0
- package/connectors/connect-shopify/src/api/index.ts +4 -0
- package/connectors/connect-shopify/src/cli/index.ts +108 -0
- package/connectors/connect-slack/src/api/bulk.ts +237 -0
- package/connectors/connect-slack/src/api/index.ts +4 -0
- package/connectors/connect-slack/src/cli/index.ts +157 -0
- package/connectors/connect-stripe/src/api/bulk.ts +488 -0
- package/connectors/connect-stripe/src/api/index.ts +4 -0
- package/connectors/connect-stripe/src/cli/index.ts +206 -0
- package/dist/index.js +75 -33
- package/dist/lib/runner.d.ts +15 -5
- package/dist/server/auth.d.ts +4 -0
- package/package.json +2 -2
- package/connectors/connect-cloudflare/bun.lock +0 -32
- package/connectors/connect-gmail/bin/index.js +0 -7027
- package/connectors/connect-gmail/dist/cli/index.js +0 -7035
- package/connectors/connect-gmail/dist/index.js +0 -2174
- package/dist/server/server.test.d.ts +0 -1
package/bin/index.js
CHANGED
|
@@ -65,7 +65,7 @@ var __export = (target, all) => {
|
|
|
65
65
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
66
66
|
var __require = import.meta.require;
|
|
67
67
|
|
|
68
|
-
// node_modules/commander/lib/error.js
|
|
68
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/lib/error.js
|
|
69
69
|
var require_error = __commonJS((exports) => {
|
|
70
70
|
class CommanderError extends Error {
|
|
71
71
|
constructor(exitCode, code, message) {
|
|
@@ -89,7 +89,7 @@ var require_error = __commonJS((exports) => {
|
|
|
89
89
|
exports.InvalidArgumentError = InvalidArgumentError;
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
// node_modules/commander/lib/argument.js
|
|
92
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/lib/argument.js
|
|
93
93
|
var require_argument = __commonJS((exports) => {
|
|
94
94
|
var { InvalidArgumentError } = require_error();
|
|
95
95
|
|
|
@@ -168,7 +168,7 @@ var require_argument = __commonJS((exports) => {
|
|
|
168
168
|
exports.humanReadableArgName = humanReadableArgName;
|
|
169
169
|
});
|
|
170
170
|
|
|
171
|
-
// node_modules/commander/lib/help.js
|
|
171
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/lib/help.js
|
|
172
172
|
var require_help = __commonJS((exports) => {
|
|
173
173
|
var { humanReadableArgName } = require_argument();
|
|
174
174
|
|
|
@@ -417,7 +417,7 @@ var require_help = __commonJS((exports) => {
|
|
|
417
417
|
exports.Help = Help;
|
|
418
418
|
});
|
|
419
419
|
|
|
420
|
-
// node_modules/commander/lib/option.js
|
|
420
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/lib/option.js
|
|
421
421
|
var require_option = __commonJS((exports) => {
|
|
422
422
|
var { InvalidArgumentError } = require_error();
|
|
423
423
|
|
|
@@ -568,7 +568,7 @@ var require_option = __commonJS((exports) => {
|
|
|
568
568
|
exports.DualOptions = DualOptions;
|
|
569
569
|
});
|
|
570
570
|
|
|
571
|
-
// node_modules/commander/lib/suggestSimilar.js
|
|
571
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/lib/suggestSimilar.js
|
|
572
572
|
var require_suggestSimilar = __commonJS((exports) => {
|
|
573
573
|
var maxDistance = 3;
|
|
574
574
|
function editDistance(a, b) {
|
|
@@ -641,7 +641,7 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
641
641
|
exports.suggestSimilar = suggestSimilar;
|
|
642
642
|
});
|
|
643
643
|
|
|
644
|
-
// node_modules/commander/lib/command.js
|
|
644
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/lib/command.js
|
|
645
645
|
var require_command = __commonJS((exports) => {
|
|
646
646
|
var EventEmitter = __require("events").EventEmitter;
|
|
647
647
|
var childProcess = __require("child_process");
|
|
@@ -1884,7 +1884,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1884
1884
|
exports.Command = Command;
|
|
1885
1885
|
});
|
|
1886
1886
|
|
|
1887
|
-
// node_modules/commander/index.js
|
|
1887
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/index.js
|
|
1888
1888
|
var require_commander = __commonJS((exports) => {
|
|
1889
1889
|
var { Argument } = require_argument();
|
|
1890
1890
|
var { Command } = require_command();
|
|
@@ -1909,7 +1909,7 @@ var package_default;
|
|
|
1909
1909
|
var init_package = __esm(() => {
|
|
1910
1910
|
package_default = {
|
|
1911
1911
|
name: "@hasna/connectors",
|
|
1912
|
-
version: "1.3.
|
|
1912
|
+
version: "1.3.23",
|
|
1913
1913
|
description: "Open source connector library - Install API connectors with a single command",
|
|
1914
1914
|
type: "module",
|
|
1915
1915
|
bin: {
|
|
@@ -1940,7 +1940,7 @@ var init_package = __esm(() => {
|
|
|
1940
1940
|
typecheck: "tsc --noEmit",
|
|
1941
1941
|
test: "bun test",
|
|
1942
1942
|
"sdk:build": "cd sdk && bun run build",
|
|
1943
|
-
prepublishOnly: "bun
|
|
1943
|
+
prepublishOnly: "bun run build && bun test"
|
|
1944
1944
|
},
|
|
1945
1945
|
keywords: [
|
|
1946
1946
|
"connectors",
|
|
@@ -2081,7 +2081,7 @@ var init_registry = __esm(() => {
|
|
|
2081
2081
|
init_connector();
|
|
2082
2082
|
});
|
|
2083
2083
|
|
|
2084
|
-
// node_modules/zod/v3/helpers/util.js
|
|
2084
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/helpers/util.js
|
|
2085
2085
|
var util, objectUtil, ZodParsedType, getParsedType = (data) => {
|
|
2086
2086
|
const t = typeof data;
|
|
2087
2087
|
switch (t) {
|
|
@@ -2212,7 +2212,7 @@ var init_util = __esm(() => {
|
|
|
2212
2212
|
]);
|
|
2213
2213
|
});
|
|
2214
2214
|
|
|
2215
|
-
// node_modules/zod/v3/ZodError.js
|
|
2215
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/ZodError.js
|
|
2216
2216
|
var ZodIssueCode, quotelessJson = (obj) => {
|
|
2217
2217
|
const json = JSON.stringify(obj, null, 2);
|
|
2218
2218
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
@@ -2333,7 +2333,7 @@ var init_ZodError = __esm(() => {
|
|
|
2333
2333
|
};
|
|
2334
2334
|
});
|
|
2335
2335
|
|
|
2336
|
-
// node_modules/zod/v3/locales/en.js
|
|
2336
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/locales/en.js
|
|
2337
2337
|
var errorMap = (issue, _ctx) => {
|
|
2338
2338
|
let message;
|
|
2339
2339
|
switch (issue.code) {
|
|
@@ -2440,7 +2440,7 @@ var init_en = __esm(() => {
|
|
|
2440
2440
|
en_default = errorMap;
|
|
2441
2441
|
});
|
|
2442
2442
|
|
|
2443
|
-
// node_modules/zod/v3/errors.js
|
|
2443
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/errors.js
|
|
2444
2444
|
function setErrorMap(map) {
|
|
2445
2445
|
overrideErrorMap = map;
|
|
2446
2446
|
}
|
|
@@ -2453,7 +2453,7 @@ var init_errors2 = __esm(() => {
|
|
|
2453
2453
|
overrideErrorMap = en_default;
|
|
2454
2454
|
});
|
|
2455
2455
|
|
|
2456
|
-
// node_modules/zod/v3/helpers/parseUtil.js
|
|
2456
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/helpers/parseUtil.js
|
|
2457
2457
|
function addIssueToContext(ctx, issueData) {
|
|
2458
2458
|
const overrideMap = getErrorMap();
|
|
2459
2459
|
const issue = makeIssue({
|
|
@@ -2558,10 +2558,10 @@ var init_parseUtil = __esm(() => {
|
|
|
2558
2558
|
});
|
|
2559
2559
|
});
|
|
2560
2560
|
|
|
2561
|
-
// node_modules/zod/v3/helpers/typeAliases.js
|
|
2561
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/helpers/typeAliases.js
|
|
2562
2562
|
var init_typeAliases = () => {};
|
|
2563
2563
|
|
|
2564
|
-
// node_modules/zod/v3/helpers/errorUtil.js
|
|
2564
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/helpers/errorUtil.js
|
|
2565
2565
|
var errorUtil;
|
|
2566
2566
|
var init_errorUtil = __esm(() => {
|
|
2567
2567
|
(function(errorUtil2) {
|
|
@@ -2570,7 +2570,7 @@ var init_errorUtil = __esm(() => {
|
|
|
2570
2570
|
})(errorUtil || (errorUtil = {}));
|
|
2571
2571
|
});
|
|
2572
2572
|
|
|
2573
|
-
// node_modules/zod/v3/types.js
|
|
2573
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/types.js
|
|
2574
2574
|
class ParseInputLazyPath {
|
|
2575
2575
|
constructor(parent, value, path, key) {
|
|
2576
2576
|
this._cachedPath = [];
|
|
@@ -5921,7 +5921,7 @@ var init_types = __esm(() => {
|
|
|
5921
5921
|
NEVER = INVALID;
|
|
5922
5922
|
});
|
|
5923
5923
|
|
|
5924
|
-
// node_modules/zod/v3/external.js
|
|
5924
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/v3/external.js
|
|
5925
5925
|
var exports_external = {};
|
|
5926
5926
|
__export(exports_external, {
|
|
5927
5927
|
void: () => voidType,
|
|
@@ -6041,7 +6041,7 @@ var init_external = __esm(() => {
|
|
|
6041
6041
|
init_ZodError();
|
|
6042
6042
|
});
|
|
6043
6043
|
|
|
6044
|
-
// node_modules/zod/index.js
|
|
6044
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/zod/index.js
|
|
6045
6045
|
var init_zod = __esm(() => {
|
|
6046
6046
|
init_external();
|
|
6047
6047
|
init_external();
|
|
@@ -6913,7 +6913,7 @@ Commands:
|
|
|
6913
6913
|
});
|
|
6914
6914
|
});
|
|
6915
6915
|
|
|
6916
|
-
// node_modules/@hasna/cloud/dist/index.js
|
|
6916
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/@hasna/cloud/dist/index.js
|
|
6917
6917
|
var exports_dist = {};
|
|
6918
6918
|
__export(exports_dist, {
|
|
6919
6919
|
translateSql: () => translateSql,
|
|
@@ -26525,7 +26525,7 @@ var init_registry2 = __esm(() => {
|
|
|
26525
26525
|
];
|
|
26526
26526
|
});
|
|
26527
26527
|
|
|
26528
|
-
// node_modules/cli-spinners/spinners.json
|
|
26528
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/cli-spinners/spinners.json
|
|
26529
26529
|
var require_spinners = __commonJS((exports, module) => {
|
|
26530
26530
|
module.exports = {
|
|
26531
26531
|
dots: {
|
|
@@ -28151,7 +28151,7 @@ var require_spinners = __commonJS((exports, module) => {
|
|
|
28151
28151
|
};
|
|
28152
28152
|
});
|
|
28153
28153
|
|
|
28154
|
-
// node_modules/cli-spinners/index.js
|
|
28154
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/cli-spinners/index.js
|
|
28155
28155
|
var require_cli_spinners = __commonJS((exports, module) => {
|
|
28156
28156
|
var spinners = Object.assign({}, require_spinners());
|
|
28157
28157
|
var spinnersList = Object.keys(spinners);
|
|
@@ -29591,6 +29591,53 @@ function getConnectorCliPath(name) {
|
|
|
29591
29591
|
function hasConnectorCommandSurface(name) {
|
|
29592
29592
|
return Boolean(getInternalCommandRuntime(name)?.commands.length || getConnectorCliPath(name));
|
|
29593
29593
|
}
|
|
29594
|
+
function normalizeCommanderUsage(usage) {
|
|
29595
|
+
const commandToken = usage.trim().split(/\s+/)[0];
|
|
29596
|
+
if (!commandToken || commandToken === "help")
|
|
29597
|
+
return null;
|
|
29598
|
+
const aliases = commandToken.split("|").filter(Boolean);
|
|
29599
|
+
const [name, ...rest] = aliases;
|
|
29600
|
+
if (!name)
|
|
29601
|
+
return null;
|
|
29602
|
+
return {
|
|
29603
|
+
name,
|
|
29604
|
+
aliases: rest,
|
|
29605
|
+
usage: usage.trim()
|
|
29606
|
+
};
|
|
29607
|
+
}
|
|
29608
|
+
function parseCommanderHelpOperations(helpText) {
|
|
29609
|
+
const operations = [];
|
|
29610
|
+
const lines = helpText.split(`
|
|
29611
|
+
`);
|
|
29612
|
+
let inCommands = false;
|
|
29613
|
+
for (const line of lines) {
|
|
29614
|
+
if (line.trim().startsWith("Commands:")) {
|
|
29615
|
+
inCommands = true;
|
|
29616
|
+
continue;
|
|
29617
|
+
}
|
|
29618
|
+
if (!inCommands)
|
|
29619
|
+
continue;
|
|
29620
|
+
if (line.trim() === "") {
|
|
29621
|
+
if (operations.length > 0)
|
|
29622
|
+
inCommands = false;
|
|
29623
|
+
continue;
|
|
29624
|
+
}
|
|
29625
|
+
const row = line.match(/^ {2}(\S.*?)(?: {2,}(.+))?$/);
|
|
29626
|
+
if (!row)
|
|
29627
|
+
continue;
|
|
29628
|
+
const usage = row[1].trim();
|
|
29629
|
+
const summary = (row[2] ?? "").trim();
|
|
29630
|
+
const normalized = normalizeCommanderUsage(usage);
|
|
29631
|
+
if (!normalized)
|
|
29632
|
+
continue;
|
|
29633
|
+
operations.push({
|
|
29634
|
+
...normalized,
|
|
29635
|
+
summary,
|
|
29636
|
+
source: "cli"
|
|
29637
|
+
});
|
|
29638
|
+
}
|
|
29639
|
+
return operations;
|
|
29640
|
+
}
|
|
29594
29641
|
function runConnectorCommand2(name, args, timeoutMs = 30000) {
|
|
29595
29642
|
getConnectorsHome();
|
|
29596
29643
|
const internalRuntime = getInternalCommandRuntime(name);
|
|
@@ -29657,38 +29704,33 @@ function runLegacyConnectorCommand(name, args, timeoutMs = 30000) {
|
|
|
29657
29704
|
async function getConnectorOperations(name) {
|
|
29658
29705
|
const internalRuntime = getInternalCommandRuntime(name);
|
|
29659
29706
|
if (internalRuntime?.commands.length) {
|
|
29707
|
+
const operations2 = internalRuntime.commands.map((command) => ({
|
|
29708
|
+
name: command.name,
|
|
29709
|
+
aliases: [],
|
|
29710
|
+
usage: command.name,
|
|
29711
|
+
summary: command.summary,
|
|
29712
|
+
source: "internal"
|
|
29713
|
+
}));
|
|
29660
29714
|
return {
|
|
29661
|
-
commands:
|
|
29715
|
+
commands: operations2.map((operation) => operation.name),
|
|
29716
|
+
operations: operations2,
|
|
29662
29717
|
helpText: internalRuntime.helpText ?? buildInternalHelpText(name, internalRuntime.commands),
|
|
29663
29718
|
hasCli: true
|
|
29664
29719
|
};
|
|
29665
29720
|
}
|
|
29666
29721
|
const cliPath = getConnectorCliPath(name);
|
|
29667
29722
|
if (!cliPath) {
|
|
29668
|
-
return { commands: [], helpText: "", hasCli: false };
|
|
29723
|
+
return { commands: [], operations: [], helpText: "", hasCli: false };
|
|
29669
29724
|
}
|
|
29670
29725
|
const result = await runConnectorCommand2(name, ["--help"]);
|
|
29671
29726
|
const helpText = result.stdout || result.stderr;
|
|
29672
|
-
const
|
|
29673
|
-
|
|
29674
|
-
|
|
29675
|
-
|
|
29676
|
-
|
|
29677
|
-
|
|
29678
|
-
|
|
29679
|
-
continue;
|
|
29680
|
-
}
|
|
29681
|
-
if (inCommands) {
|
|
29682
|
-
const match = line.match(/^\s{2,}(\S+)/);
|
|
29683
|
-
if (match && match[1] !== "help") {
|
|
29684
|
-
commands.push(match[1]);
|
|
29685
|
-
}
|
|
29686
|
-
if (line.trim() === "" && commands.length > 0) {
|
|
29687
|
-
inCommands = false;
|
|
29688
|
-
}
|
|
29689
|
-
}
|
|
29690
|
-
}
|
|
29691
|
-
return { commands, helpText, hasCli: true };
|
|
29727
|
+
const operations = parseCommanderHelpOperations(helpText);
|
|
29728
|
+
return {
|
|
29729
|
+
commands: operations.map((operation) => operation.name),
|
|
29730
|
+
operations,
|
|
29731
|
+
helpText,
|
|
29732
|
+
hasCli: true
|
|
29733
|
+
};
|
|
29692
29734
|
}
|
|
29693
29735
|
async function getConnectorCommandHelp(name, command) {
|
|
29694
29736
|
const internalRuntime = getInternalCommandRuntime(name);
|
|
@@ -29951,7 +29993,9 @@ Dashboard not found at: ${dashboardDir}`);
|
|
|
29951
29993
|
return json({
|
|
29952
29994
|
connector: name,
|
|
29953
29995
|
displayName: meta.displayName,
|
|
29996
|
+
auth: getAuthStatus(name),
|
|
29954
29997
|
commands: ops.commands,
|
|
29998
|
+
operations: ops.operations,
|
|
29955
29999
|
helpText: ops.helpText
|
|
29956
30000
|
}, 200, port);
|
|
29957
30001
|
}
|
|
@@ -30524,7 +30568,7 @@ var init_serve = __esm(() => {
|
|
|
30524
30568
|
// src/cli/index.tsx
|
|
30525
30569
|
import { render as render2 } from "ink";
|
|
30526
30570
|
|
|
30527
|
-
// node_modules/commander/esm.mjs
|
|
30571
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/commander/esm.mjs
|
|
30528
30572
|
var import__ = __toESM(require_commander(), 1);
|
|
30529
30573
|
var {
|
|
30530
30574
|
program,
|
|
@@ -30548,11 +30592,11 @@ init_registry2();
|
|
|
30548
30592
|
import { useState as useState7 } from "react";
|
|
30549
30593
|
import { Box as Box8, Text as Text10, useApp, useInput as useInput5 } from "ink";
|
|
30550
30594
|
|
|
30551
|
-
// node_modules/ink-select-input/build/Indicator.js
|
|
30595
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-select-input/build/Indicator.js
|
|
30552
30596
|
import React from "react";
|
|
30553
30597
|
import { Box, Text } from "ink";
|
|
30554
30598
|
|
|
30555
|
-
// node_modules/is-unicode-supported/index.js
|
|
30599
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/is-unicode-supported/index.js
|
|
30556
30600
|
import process2 from "process";
|
|
30557
30601
|
function isUnicodeSupported() {
|
|
30558
30602
|
const { env } = process2;
|
|
@@ -30563,7 +30607,7 @@ function isUnicodeSupported() {
|
|
|
30563
30607
|
return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
30564
30608
|
}
|
|
30565
30609
|
|
|
30566
|
-
// node_modules/figures/index.js
|
|
30610
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/figures/index.js
|
|
30567
30611
|
var common = {
|
|
30568
30612
|
circleQuestionMark: "(?)",
|
|
30569
30613
|
questionMarkPrefix: "(?)",
|
|
@@ -30839,23 +30883,23 @@ var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
|
|
|
30839
30883
|
var figures_default = figures;
|
|
30840
30884
|
var replacements = Object.entries(specialMainSymbols);
|
|
30841
30885
|
|
|
30842
|
-
// node_modules/ink-select-input/build/Indicator.js
|
|
30886
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-select-input/build/Indicator.js
|
|
30843
30887
|
function Indicator({ isSelected = false }) {
|
|
30844
30888
|
return React.createElement(Box, { marginRight: 1 }, isSelected ? React.createElement(Text, { color: "blue" }, figures_default.pointer) : React.createElement(Text, null, " "));
|
|
30845
30889
|
}
|
|
30846
30890
|
var Indicator_default = Indicator;
|
|
30847
|
-
// node_modules/ink-select-input/build/Item.js
|
|
30891
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-select-input/build/Item.js
|
|
30848
30892
|
import * as React2 from "react";
|
|
30849
30893
|
import { Text as Text2 } from "ink";
|
|
30850
30894
|
function Item({ isSelected = false, label }) {
|
|
30851
30895
|
return React2.createElement(Text2, { color: isSelected ? "blue" : undefined }, label);
|
|
30852
30896
|
}
|
|
30853
30897
|
var Item_default = Item;
|
|
30854
|
-
// node_modules/ink-select-input/build/SelectInput.js
|
|
30898
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-select-input/build/SelectInput.js
|
|
30855
30899
|
import { isDeepStrictEqual } from "util";
|
|
30856
30900
|
import React3, { useState, useEffect, useRef, useCallback } from "react";
|
|
30857
30901
|
|
|
30858
|
-
// node_modules/to-rotated/index.js
|
|
30902
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/to-rotated/index.js
|
|
30859
30903
|
function toRotated(array, steps) {
|
|
30860
30904
|
if (!Array.isArray(array)) {
|
|
30861
30905
|
throw new TypeError(`Expected an array, got \`${typeof array}\`.`);
|
|
@@ -30877,7 +30921,7 @@ function toRotated(array, steps) {
|
|
|
30877
30921
|
];
|
|
30878
30922
|
}
|
|
30879
30923
|
|
|
30880
|
-
// node_modules/ink-select-input/build/SelectInput.js
|
|
30924
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-select-input/build/SelectInput.js
|
|
30881
30925
|
import { Box as Box2, useInput } from "ink";
|
|
30882
30926
|
function SelectInput({ items = [], isFocused = true, initialIndex = 0, indicatorComponent = Indicator_default, itemComponent = Item_default, limit: customLimit, onSelect, onHighlight }) {
|
|
30883
30927
|
const hasLimit = typeof customLimit === "number" && items.length > customLimit;
|
|
@@ -31290,7 +31334,7 @@ function ConnectorSelect({
|
|
|
31290
31334
|
import { useState as useState4, useEffect as useEffect3, useMemo as useMemo2 } from "react";
|
|
31291
31335
|
import { Box as Box6, Text as Text7, useInput as useInput4 } from "ink";
|
|
31292
31336
|
|
|
31293
|
-
// node_modules/ink-text-input/build/index.js
|
|
31337
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-text-input/build/index.js
|
|
31294
31338
|
import React5, { useState as useState3, useEffect as useEffect2 } from "react";
|
|
31295
31339
|
import { Text as Text6, useInput as useInput3 } from "ink";
|
|
31296
31340
|
import chalk from "chalk";
|
|
@@ -31678,7 +31722,7 @@ function SearchView({
|
|
|
31678
31722
|
import { useState as useState6, useEffect as useEffect5 } from "react";
|
|
31679
31723
|
import { Box as Box7, Text as Text9 } from "ink";
|
|
31680
31724
|
|
|
31681
|
-
// node_modules/ink-spinner/build/index.js
|
|
31725
|
+
// ../../../home/hasna/workspace/hasna/opensource/open-connectors/node_modules/ink-spinner/build/index.js
|
|
31682
31726
|
var import_cli_spinners = __toESM(require_cli_spinners(), 1);
|
|
31683
31727
|
import React7, { useState as useState5, useEffect as useEffect4 } from "react";
|
|
31684
31728
|
import { Text as Text8 } from "ink";
|
|
@@ -32762,6 +32806,8 @@ function registerCommands3(program2) {
|
|
|
32762
32806
|
const globalDirs = readdirSync12(configDir).filter((f) => {
|
|
32763
32807
|
if (!f.startsWith("connect-"))
|
|
32764
32808
|
return false;
|
|
32809
|
+
if (f.startsWith("connect-zzztest"))
|
|
32810
|
+
return false;
|
|
32765
32811
|
try {
|
|
32766
32812
|
return statSync7(join19(configDir, f)).isDirectory();
|
|
32767
32813
|
} catch {
|
|
@@ -33029,8 +33075,29 @@ function redactSecrets(obj) {
|
|
|
33029
33075
|
}
|
|
33030
33076
|
return obj;
|
|
33031
33077
|
}
|
|
33078
|
+
function getOAuthTokenState(name) {
|
|
33079
|
+
const tokens = loadTokens(name);
|
|
33080
|
+
if (!tokens?.accessToken && !tokens?.refreshToken) {
|
|
33081
|
+
return { hasTokens: false, expired: false };
|
|
33082
|
+
}
|
|
33083
|
+
if (!tokens.expiresAt) {
|
|
33084
|
+
return { hasTokens: true, expired: false };
|
|
33085
|
+
}
|
|
33086
|
+
const now3 = Date.now();
|
|
33087
|
+
const isExpired = now3 >= tokens.expiresAt - 60000;
|
|
33088
|
+
const expiresIn = isExpired ? undefined : (() => {
|
|
33089
|
+
const ms = tokens.expiresAt - now3;
|
|
33090
|
+
const mins = Math.floor(ms / 60000);
|
|
33091
|
+
if (mins < 1)
|
|
33092
|
+
return "less than a minute";
|
|
33093
|
+
if (mins < 60)
|
|
33094
|
+
return `${mins}m`;
|
|
33095
|
+
return `${Math.floor(mins / 60)}h ${mins % 60}m`;
|
|
33096
|
+
})();
|
|
33097
|
+
return { hasTokens: true, expired: isExpired, expiresIn };
|
|
33098
|
+
}
|
|
33032
33099
|
function registerCommands4(program2) {
|
|
33033
|
-
program2.command("auth").argument("<connector>", "Connector name to configure auth for").option("-k, --key <value>", "API key or bearer token value (non-interactive)").option("-f, --field <field>", "Which field to set (for multi-field connectors)").option("--json", "Output as JSON", false).option("--no-browser", "Print OAuth URL without opening a browser (agent-friendly)", false).description("Configure authentication for a connector").action(async (connector, options) => {
|
|
33100
|
+
program2.command("auth").argument("<connector>", "Connector name to configure auth for").option("-k, --key <value>", "API key or bearer token value (non-interactive)").option("-f, --field <field>", "Which field to set (for multi-field connectors)").option("--json", "Output as JSON", false).option("--no-browser", "Print OAuth URL without opening a browser (agent-friendly)", false).option("--refresh", "Refresh expired OAuth tokens", false).option("--port <port>", "OAuth server port (default: 9876)", "9876").description("Configure authentication for a connector").action(async (connector, options) => {
|
|
33034
33101
|
const meta = getConnector(connector);
|
|
33035
33102
|
if (!meta) {
|
|
33036
33103
|
if (options.json) {
|
|
@@ -33044,6 +33111,39 @@ function registerCommands4(program2) {
|
|
|
33044
33111
|
}
|
|
33045
33112
|
const authType = getAuthType(connector);
|
|
33046
33113
|
const statusBefore = getAuthStatus(connector);
|
|
33114
|
+
if (options.refresh) {
|
|
33115
|
+
if (authType !== "oauth") {
|
|
33116
|
+
if (options.json) {
|
|
33117
|
+
console.log(JSON.stringify({ error: `${connector} does not use OAuth. Refresh is only available for OAuth connectors.` }));
|
|
33118
|
+
} else {
|
|
33119
|
+
console.log(chalk5.red(`${meta.displayName} does not use OAuth. Refresh is only available for OAuth connectors.`));
|
|
33120
|
+
}
|
|
33121
|
+
process.exit(1);
|
|
33122
|
+
return;
|
|
33123
|
+
}
|
|
33124
|
+
try {
|
|
33125
|
+
const tokens = await refreshOAuthToken(connector);
|
|
33126
|
+
if (options.json) {
|
|
33127
|
+
console.log(JSON.stringify({ success: true, connector, tokenType: tokens.tokenType, scope: tokens.scope, expiresAt: tokens.expiresAt }));
|
|
33128
|
+
} else {
|
|
33129
|
+
console.log(chalk5.green(`
|
|
33130
|
+
\u2713 Refreshed ${meta.displayName} tokens.`));
|
|
33131
|
+
console.log(chalk5.dim(` Expires: ${new Date(tokens.expiresAt).toLocaleString()}`));
|
|
33132
|
+
}
|
|
33133
|
+
process.exit(0);
|
|
33134
|
+
return;
|
|
33135
|
+
} catch (err) {
|
|
33136
|
+
if (options.json) {
|
|
33137
|
+
console.log(JSON.stringify({ error: `Refresh failed: ${err instanceof Error ? err.message : String(err)}` }));
|
|
33138
|
+
} else {
|
|
33139
|
+
console.log(chalk5.red(`
|
|
33140
|
+
\u2717 Refresh failed: ${err instanceof Error ? err.message : String(err)}`));
|
|
33141
|
+
console.log(chalk5.dim("You may need to re-authenticate."));
|
|
33142
|
+
}
|
|
33143
|
+
process.exit(1);
|
|
33144
|
+
return;
|
|
33145
|
+
}
|
|
33146
|
+
}
|
|
33047
33147
|
if (!options.json) {
|
|
33048
33148
|
const statusLabel = statusBefore.configured ? chalk5.green("configured") : chalk5.red("not configured");
|
|
33049
33149
|
console.log(chalk5.bold(`
|
|
@@ -33051,6 +33151,14 @@ ${meta.displayName} \u2014 Auth Configuration
|
|
|
33051
33151
|
`));
|
|
33052
33152
|
console.log(` Auth type: ${authType === "oauth" ? "OAuth" : authType === "apikey" ? "API Key" : "Bearer Token"}`);
|
|
33053
33153
|
console.log(` Status: ${statusLabel}`);
|
|
33154
|
+
if (authType === "oauth" && statusBefore.configured) {
|
|
33155
|
+
const tokenState = getOAuthTokenState(connector);
|
|
33156
|
+
if (tokenState.hasTokens && !tokenState.expired) {
|
|
33157
|
+
console.log(` Token: ${chalk5.green("valid")} (expires in ${tokenState.expiresIn})`);
|
|
33158
|
+
} else if (tokenState.hasTokens && tokenState.expired) {
|
|
33159
|
+
console.log(` Token: ${chalk5.yellow("expired")} (run 'connectors auth ${connector} --refresh' or re-authenticate)`);
|
|
33160
|
+
}
|
|
33161
|
+
}
|
|
33054
33162
|
const envVars2 = getEnvVars(connector);
|
|
33055
33163
|
if (envVars2.length > 0) {
|
|
33056
33164
|
console.log(` Fields: ${envVars2.map((v) => v.variable).join(", ")}`);
|
|
@@ -33058,18 +33166,55 @@ ${meta.displayName} \u2014 Auth Configuration
|
|
|
33058
33166
|
console.log();
|
|
33059
33167
|
}
|
|
33060
33168
|
if (authType === "oauth") {
|
|
33169
|
+
const tokenState = getOAuthTokenState(connector);
|
|
33170
|
+
if (tokenState.hasTokens && !tokenState.expired) {
|
|
33171
|
+
if (options.json) {
|
|
33172
|
+
console.log(JSON.stringify({ connector, authType: "oauth", status: "authenticated", message: `Tokens are valid and not expired.` }));
|
|
33173
|
+
} else {
|
|
33174
|
+
console.log(chalk5.green(`
|
|
33175
|
+
\u2713 ${meta.displayName} is already authenticated (tokens valid, expires in ${tokenState.expiresIn}).`));
|
|
33176
|
+
console.log(chalk5.dim(`Use --refresh to renew tokens, or re-run auth to re-authenticate.`));
|
|
33177
|
+
}
|
|
33178
|
+
process.exit(0);
|
|
33179
|
+
return;
|
|
33180
|
+
}
|
|
33181
|
+
if (tokenState.hasTokens && tokenState.expired) {
|
|
33182
|
+
if (!options.json) {
|
|
33183
|
+
console.log(chalk5.dim("Tokens expired \u2014 attempting auto-refresh..."));
|
|
33184
|
+
}
|
|
33185
|
+
try {
|
|
33186
|
+
const tokens = await refreshOAuthToken(connector);
|
|
33187
|
+
if (options.json) {
|
|
33188
|
+
console.log(JSON.stringify({ connector, authType: "oauth", status: "refreshed", expiresAt: tokens.expiresAt }));
|
|
33189
|
+
} else {
|
|
33190
|
+
console.log(chalk5.green(`
|
|
33191
|
+
\u2713 Refreshed ${meta.displayName} tokens.`));
|
|
33192
|
+
console.log(chalk5.dim(` Expires: ${new Date(tokens.expiresAt).toLocaleString()}`));
|
|
33193
|
+
}
|
|
33194
|
+
process.exit(0);
|
|
33195
|
+
return;
|
|
33196
|
+
} catch {
|
|
33197
|
+
if (!options.json) {
|
|
33198
|
+
console.log(chalk5.yellow("Auto-refresh failed. Proceeding with OAuth flow..."));
|
|
33199
|
+
console.log();
|
|
33200
|
+
}
|
|
33201
|
+
}
|
|
33202
|
+
}
|
|
33061
33203
|
if (options.json) {
|
|
33204
|
+
const port2 = parseInt(options.port, 10) || 9876;
|
|
33205
|
+
const oauthUrl2 = `http://localhost:${port2}/oauth/${connector}/start`;
|
|
33062
33206
|
console.log(JSON.stringify({
|
|
33063
33207
|
connector,
|
|
33064
33208
|
authType: "oauth",
|
|
33065
|
-
message: "OAuth connectors require browser-based authentication. Use 'connectors serve' or pass --key to set tokens manually."
|
|
33209
|
+
message: "OAuth connectors require browser-based authentication. Use 'connectors serve' or pass --key to set tokens manually.",
|
|
33210
|
+
oauthUrl: oauthUrl2
|
|
33066
33211
|
}));
|
|
33067
33212
|
process.exit(0);
|
|
33068
33213
|
return;
|
|
33069
33214
|
}
|
|
33070
33215
|
console.log(chalk5.yellow("OAuth connectors require browser-based authentication."));
|
|
33071
33216
|
console.log();
|
|
33072
|
-
const port = 9876;
|
|
33217
|
+
const port = parseInt(options.port, 10) || 9876;
|
|
33073
33218
|
const oauthUrl = `http://localhost:${port}/oauth/${connector}/start`;
|
|
33074
33219
|
try {
|
|
33075
33220
|
if (!options.browser) {
|
|
@@ -33094,13 +33239,10 @@ ${meta.displayName} \u2014 Auth Configuration
|
|
|
33094
33239
|
`));
|
|
33095
33240
|
console.log(` ${chalk5.cyan(oauthUrl)}
|
|
33096
33241
|
`);
|
|
33097
|
-
console.log(chalk5.dim(
|
|
33098
|
-
|
|
33099
|
-
const { join: join8 } = await import("path");
|
|
33100
|
-
const { getConnectorsHome: getConnectorsHome2 } = await Promise.resolve().then(() => (init_database(), exports_database));
|
|
33101
|
-
const connectorsHome = getConnectorsHome2();
|
|
33242
|
+
console.log(chalk5.dim("Waiting for authentication to complete..."));
|
|
33243
|
+
const connectorsHome = getConnectorsHome();
|
|
33102
33244
|
const connectorDirName = connector.startsWith("connect-") ? connector : `connect-${connector}`;
|
|
33103
|
-
const tokensPath =
|
|
33245
|
+
const tokensPath = join20(connectorsHome, connectorDirName, "profiles", "default", "tokens.json");
|
|
33104
33246
|
let attempts = 0;
|
|
33105
33247
|
const maxAttempts = 360;
|
|
33106
33248
|
while (attempts < maxAttempts) {
|
|
@@ -33109,17 +33251,22 @@ ${meta.displayName} \u2014 Auth Configuration
|
|
|
33109
33251
|
break;
|
|
33110
33252
|
}
|
|
33111
33253
|
attempts++;
|
|
33254
|
+
if (attempts % 6 === 0) {
|
|
33255
|
+
process.stdout.write(".");
|
|
33256
|
+
}
|
|
33112
33257
|
}
|
|
33113
33258
|
try {
|
|
33114
33259
|
serverProc.kill("SIGTERM");
|
|
33115
33260
|
} catch {}
|
|
33116
33261
|
if (attempts >= maxAttempts) {
|
|
33262
|
+
console.log();
|
|
33117
33263
|
console.log(chalk5.yellow("Timed out waiting for OAuth callback. The auth may still be in progress."));
|
|
33118
33264
|
console.log(chalk5.dim(`Check ${tokensPath} for tokens.`));
|
|
33119
33265
|
console.log(chalk5.dim("You can stop the server manually: lsof -ti :${port} | xargs kill"));
|
|
33120
33266
|
process.exit(1);
|
|
33121
33267
|
return;
|
|
33122
33268
|
}
|
|
33269
|
+
console.log();
|
|
33123
33270
|
console.log(chalk5.green(`
|
|
33124
33271
|
\u2713 Connected! ${meta.displayName} is now authenticated.`));
|
|
33125
33272
|
process.exit(0);
|
|
@@ -34280,15 +34427,19 @@ ${meta.displayName} \u2192 ${command}
|
|
|
34280
34427
|
console.log(JSON.stringify({
|
|
34281
34428
|
connector: name,
|
|
34282
34429
|
displayName: meta.displayName,
|
|
34283
|
-
|
|
34430
|
+
auth: getAuthStatus(name),
|
|
34431
|
+
commands: ops.commands,
|
|
34432
|
+
operations: ops.operations
|
|
34284
34433
|
}, null, 2));
|
|
34285
34434
|
} else {
|
|
34286
34435
|
console.log(chalk7.bold(`
|
|
34287
34436
|
${meta.displayName} operations:
|
|
34288
34437
|
`));
|
|
34289
|
-
if (ops.
|
|
34290
|
-
for (const
|
|
34291
|
-
|
|
34438
|
+
if (ops.operations.length > 0) {
|
|
34439
|
+
for (const operation of ops.operations) {
|
|
34440
|
+
const aliases = operation.aliases.length > 0 ? chalk7.dim(` aliases: ${operation.aliases.join(", ")}`) : "";
|
|
34441
|
+
const summary = operation.summary ? chalk7.dim(` \u2014 ${operation.summary}`) : "";
|
|
34442
|
+
console.log(` ${chalk7.cyan(operation.name)}${aliases}${summary}`);
|
|
34292
34443
|
}
|
|
34293
34444
|
console.log(chalk7.dim(`
|
|
34294
34445
|
Run ${chalk7.white(`connectors ops ${name} <command>`)} for details`));
|
|
@@ -34324,7 +34475,7 @@ ${meta.displayName} operations:
|
|
|
34324
34475
|
}
|
|
34325
34476
|
process.exit(result.exitCode);
|
|
34326
34477
|
});
|
|
34327
|
-
program2.command("setup").argument("<name>", "Connector name to set up").option("-k, --key <value>", "API key or bearer token value").option("-f, --field <field>", "Which field to set (for multi-field connectors)").option("-o, --overwrite", "Overwrite existing installation", false).option("--json", "Output as JSON", false).description("Install, configure auth, and verify a connector in one step").action(async (name, options) => {
|
|
34478
|
+
program2.command("setup").argument("<name>", "Connector name to set up").option("-k, --key <value>", "API key or bearer token value").option("-f, --field <field>", "Which field to set (for multi-field connectors)").option("-o, --overwrite", "Overwrite existing installation", false).option("--json", "Output as JSON", false).option("--no-browser", "Print OAuth URL without opening a browser (agent-friendly)", false).description("Install, configure auth, and verify a connector in one step").action(async (name, options) => {
|
|
34328
34479
|
const meta = getConnector(name);
|
|
34329
34480
|
if (!meta) {
|
|
34330
34481
|
if (options.json) {
|
|
@@ -34399,11 +34550,63 @@ Setting up ${meta.displayName}...
|
|
|
34399
34550
|
return;
|
|
34400
34551
|
}
|
|
34401
34552
|
console.log(` ${chalk7.yellow("\u27F3")} OAuth authentication required \u2014 starting server...`);
|
|
34553
|
+
const port = 9876;
|
|
34554
|
+
const oauthUrl = `http://localhost:${port}/oauth/${name}/start`;
|
|
34555
|
+
if (!options.browser) {
|
|
34556
|
+
console.log(`
|
|
34557
|
+
${chalk7.bold("Open this URL to authenticate:")}`);
|
|
34558
|
+
console.log(` ${chalk7.cyan(oauthUrl)}
|
|
34559
|
+
`);
|
|
34560
|
+
const { spawn: spawn4 } = await import("child_process");
|
|
34561
|
+
const { getConnectorsHome: getConnectorsHome2 } = await Promise.resolve().then(() => (init_database(), exports_database));
|
|
34562
|
+
const { existsSync: existsSync8 } = await import("fs");
|
|
34563
|
+
const { join: join8 } = await import("path");
|
|
34564
|
+
const scriptPath = process.argv[1];
|
|
34565
|
+
const serverProc = spawn4("node", [scriptPath, "serve", "--port", String(port)], {
|
|
34566
|
+
detached: true,
|
|
34567
|
+
stdio: "ignore"
|
|
34568
|
+
});
|
|
34569
|
+
serverProc.unref();
|
|
34570
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
34571
|
+
try {
|
|
34572
|
+
await fetch(`http://localhost:${port}/api/connectors`);
|
|
34573
|
+
} catch {
|
|
34574
|
+
console.log(` ${chalk7.red("\u2717")} OAuth server failed to start on port ${port}.`);
|
|
34575
|
+
process.exit(1);
|
|
34576
|
+
return;
|
|
34577
|
+
}
|
|
34578
|
+
console.log(chalk7.dim(" Waiting for authentication to complete..."));
|
|
34579
|
+
const connectorsHome = getConnectorsHome2();
|
|
34580
|
+
const connectorDirName = name.startsWith("connect-") ? name : `connect-${name}`;
|
|
34581
|
+
const tokensPath = join8(connectorsHome, connectorDirName, "profiles", "default", "tokens.json");
|
|
34582
|
+
let attempts = 0;
|
|
34583
|
+
const maxAttempts = 360;
|
|
34584
|
+
while (attempts < maxAttempts) {
|
|
34585
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
34586
|
+
if (existsSync8(tokensPath))
|
|
34587
|
+
break;
|
|
34588
|
+
attempts++;
|
|
34589
|
+
if (attempts % 6 === 0)
|
|
34590
|
+
process.stdout.write(".");
|
|
34591
|
+
}
|
|
34592
|
+
try {
|
|
34593
|
+
serverProc.kill("SIGTERM");
|
|
34594
|
+
} catch {}
|
|
34595
|
+
if (attempts >= maxAttempts) {
|
|
34596
|
+
console.log();
|
|
34597
|
+
console.log(chalk7.yellow(" Timed out waiting for OAuth callback."));
|
|
34598
|
+
process.exit(1);
|
|
34599
|
+
return;
|
|
34600
|
+
}
|
|
34601
|
+
console.log();
|
|
34602
|
+
console.log(` ${chalk7.green("\u2713")} ${meta.displayName} is now authenticated.`);
|
|
34603
|
+
authConfigured = true;
|
|
34604
|
+
process.exit(0);
|
|
34605
|
+
return;
|
|
34606
|
+
}
|
|
34402
34607
|
try {
|
|
34403
|
-
const port = 9876;
|
|
34404
34608
|
const { startServer: startServer2 } = await Promise.resolve().then(() => (init_serve(), exports_serve));
|
|
34405
34609
|
await startServer2(port, { open: false, strict: true });
|
|
34406
|
-
const oauthUrl = `http://localhost:${port}/oauth/${name}/start`;
|
|
34407
34610
|
console.log(`
|
|
34408
34611
|
${chalk7.bold("Open this URL to authenticate:")}`);
|
|
34409
34612
|
console.log(` ${chalk7.cyan(oauthUrl)}
|