@hasna/connectors 1.3.28 → 1.3.29

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 CHANGED
@@ -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.28",
1912
+ version: "1.3.29",
1913
1913
  description: "Open source connector library - Install API connectors with a single command",
1914
1914
  type: "module",
1915
1915
  bin: {
@@ -34282,6 +34282,27 @@ function getOAuthTokenState(name) {
34282
34282
  })();
34283
34283
  return { hasTokens: true, expired: isExpired, expiresIn };
34284
34284
  }
34285
+ function getCurrentOAuthProfile(name, connectorsHome = getConnectorsHome()) {
34286
+ for (const dir of getConnectorConfigReadDirs(name, connectorsHome)) {
34287
+ const currentProfilePath = join20(dir, "current_profile");
34288
+ if (!existsSync20(currentProfilePath))
34289
+ continue;
34290
+ const profile = readFileSync11(currentProfilePath, "utf8").trim();
34291
+ if (profile)
34292
+ return profile;
34293
+ }
34294
+ return "default";
34295
+ }
34296
+ function getOAuthTokenPathsForProfile(name, connectorsHome = getConnectorsHome(), profile = getCurrentOAuthProfile(name, connectorsHome)) {
34297
+ return getConnectorConfigReadDirs(name, connectorsHome).map((dir) => join20(dir, "profiles", profile, "tokens.json"));
34298
+ }
34299
+ function hasOAuthTokenFileUpdatedSince(tokenPaths, sinceMs) {
34300
+ return tokenPaths.some((tokensPath) => {
34301
+ if (!existsSync20(tokensPath))
34302
+ return false;
34303
+ return statSync8(tokensPath).mtimeMs >= sinceMs;
34304
+ });
34305
+ }
34285
34306
  function registerCommands4(program2) {
34286
34307
  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) => {
34287
34308
  const meta = getConnector(connector);
@@ -34407,10 +34428,11 @@ ${meta.displayName} \u2014 Auth Configuration
34407
34428
  console.log(chalk5.dim(`Starting OAuth server on port ${port}...`));
34408
34429
  const { spawn: spawn3 } = await import("child_process");
34409
34430
  const scriptPath = process.argv[1];
34410
- const serverProc = spawn3("node", [scriptPath, "serve", "--port", String(port)], {
34431
+ const serverProc = spawn3(process.execPath, [scriptPath, "serve", "--port", String(port)], {
34411
34432
  detached: true,
34412
34433
  stdio: "ignore"
34413
34434
  });
34435
+ const startedAt = Date.now();
34414
34436
  serverProc.unref();
34415
34437
  await new Promise((resolve) => setTimeout(resolve, 2000));
34416
34438
  try {
@@ -34427,12 +34449,13 @@ ${meta.displayName} \u2014 Auth Configuration
34427
34449
  `);
34428
34450
  console.log(chalk5.dim("Waiting for authentication to complete..."));
34429
34451
  const connectorsHome = getConnectorsHome();
34430
- const tokenPaths = getConnectorConfigReadDirs(connector, connectorsHome).map((dir) => join20(dir, "profiles", "default", "tokens.json"));
34452
+ const activeProfile = getCurrentOAuthProfile(connector, connectorsHome);
34453
+ const tokenPaths = getOAuthTokenPathsForProfile(connector, connectorsHome, activeProfile);
34431
34454
  let attempts = 0;
34432
34455
  const maxAttempts = 360;
34433
34456
  while (attempts < maxAttempts) {
34434
34457
  await new Promise((resolve) => setTimeout(resolve, 500));
34435
- if (tokenPaths.some((tokensPath) => existsSync20(tokensPath))) {
34458
+ if (hasOAuthTokenFileUpdatedSince(tokenPaths, startedAt)) {
34436
34459
  break;
34437
34460
  }
34438
34461
  attempts++;
@@ -35586,7 +35609,6 @@ Testing connector credentials...
35586
35609
  init_registry2();
35587
35610
  init_auth();
35588
35611
  init_runner();
35589
- init_connector_resolver();
35590
35612
  import chalk7 from "chalk";
35591
35613
  function registerCommands6(program2) {
35592
35614
  program2.command("ops").description("List available API operations for a connector").argument("<name>", "Connector name (e.g. stripe, gmail)").argument("[command]", "Get detailed help for a specific subcommand").option("--json", "Output as JSON").action(async (name, command, options) => {
@@ -35750,13 +35772,12 @@ Setting up ${meta.displayName}...
35750
35772
  `);
35751
35773
  const { spawn: spawn3 } = await import("child_process");
35752
35774
  const { getConnectorsHome: getConnectorsHome2 } = await Promise.resolve().then(() => (init_database(), exports_database));
35753
- const { existsSync: existsSync8 } = await import("fs");
35754
- const { join: join8 } = await import("path");
35755
35775
  const scriptPath = process.argv[1];
35756
- const serverProc = spawn3("node", [scriptPath, "serve", "--port", String(port)], {
35776
+ const serverProc = spawn3(process.execPath, [scriptPath, "serve", "--port", String(port)], {
35757
35777
  detached: true,
35758
35778
  stdio: "ignore"
35759
35779
  });
35780
+ const startedAt = Date.now();
35760
35781
  serverProc.unref();
35761
35782
  await new Promise((resolve) => setTimeout(resolve, 2000));
35762
35783
  try {
@@ -35768,12 +35789,13 @@ Setting up ${meta.displayName}...
35768
35789
  }
35769
35790
  console.log(chalk7.dim(" Waiting for authentication to complete..."));
35770
35791
  const connectorsHome = getConnectorsHome2();
35771
- const tokenPaths = getConnectorConfigReadDirs(name, connectorsHome).map((dir) => join8(dir, "profiles", "default", "tokens.json"));
35792
+ const activeProfile = getCurrentOAuthProfile(name, connectorsHome);
35793
+ const tokenPaths = getOAuthTokenPathsForProfile(name, connectorsHome, activeProfile);
35772
35794
  let attempts = 0;
35773
35795
  const maxAttempts = 360;
35774
35796
  while (attempts < maxAttempts) {
35775
35797
  await new Promise((resolve) => setTimeout(resolve, 500));
35776
- if (tokenPaths.some((tokensPath) => existsSync8(tokensPath)))
35798
+ if (hasOAuthTokenFileUpdatedSince(tokenPaths, startedAt))
35777
35799
  break;
35778
35800
  attempts++;
35779
35801
  if (attempts % 6 === 0)
package/bin/mcp.js CHANGED
@@ -12240,7 +12240,7 @@ var package_default;
12240
12240
  var init_package = __esm(() => {
12241
12241
  package_default = {
12242
12242
  name: "@hasna/connectors",
12243
- version: "1.3.28",
12243
+ version: "1.3.29",
12244
12244
  description: "Open source connector library - Install API connectors with a single command",
12245
12245
  type: "module",
12246
12246
  bin: {
package/bin/serve.js CHANGED
@@ -15953,7 +15953,7 @@ function extractGoogleError(body) {
15953
15953
  // package.json
15954
15954
  var package_default = {
15955
15955
  name: "@hasna/connectors",
15956
- version: "1.3.28",
15956
+ version: "1.3.29",
15957
15957
  description: "Open source connector library - Install API connectors with a single command",
15958
15958
  type: "module",
15959
15959
  bin: {
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,5 @@
1
1
  import { Command } from "commander";
2
+ export declare function getCurrentOAuthProfile(name: string, connectorsHome?: string): string;
3
+ export declare function getOAuthTokenPathsForProfile(name: string, connectorsHome?: string, profile?: string): string[];
4
+ export declare function hasOAuthTokenFileUpdatedSince(tokenPaths: string[], sinceMs: number): boolean;
2
5
  export declare function registerCommands(program: Command): void;
package/dist/index.js CHANGED
@@ -5727,7 +5727,7 @@ function extractGoogleError(body) {
5727
5727
  // package.json
5728
5728
  var package_default = {
5729
5729
  name: "@hasna/connectors",
5730
- version: "1.3.28",
5730
+ version: "1.3.29",
5731
5731
  description: "Open source connector library - Install API connectors with a single command",
5732
5732
  type: "module",
5733
5733
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/connectors",
3
- "version": "1.3.28",
3
+ "version": "1.3.29",
4
4
  "description": "Open source connector library - Install API connectors with a single command",
5
5
  "type": "module",
6
6
  "bin": {