@circleback/cli 0.1.8 → 0.1.10

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.
@@ -90,7 +90,7 @@ const refreshAccessToken = async (refreshToken, clientId) => {
90
90
  return tokenData;
91
91
  };
92
92
  exports.refreshAccessToken = refreshAccessToken;
93
- const login = async () => {
93
+ const login = async (options = {}) => {
94
94
  const { port, waitForCallback, shutdown } = await (0, server_1.startCallbackServer)();
95
95
  const redirectUri = `http://127.0.0.1:${port}`;
96
96
  try {
@@ -106,6 +106,7 @@ const login = async () => {
106
106
  authorizeUrl.searchParams.set('code_challenge', challenge);
107
107
  authorizeUrl.searchParams.set('code_challenge_method', 'S256');
108
108
  const url = authorizeUrl.toString();
109
+ options.onAuthorizeUrl?.(url);
109
110
  const isWindows = process.platform === 'win32';
110
111
  const escapedUrl = isWindows ? url.replace(/&/g, '^&') : url;
111
112
  const [command, ...arguments_] = isWindows
@@ -8,6 +8,24 @@ const commander_1 = require("commander");
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const oauth_1 = require("../auth/oauth");
10
10
  const tokenStorage_1 = require("../auth/tokenStorage");
11
+ const AUTHORIZATION_URL_FALLBACK_DELAY_MILLISECONDS = 500;
12
+ const getOpenUrlInstruction = () => process.platform === 'darwin' ? '⌘-click' : 'Ctrl-click';
13
+ const createAuthorizationUrlFallback = () => {
14
+ const abortController = new AbortController();
15
+ const schedule = (url) => {
16
+ const timeout = setTimeout(() => {
17
+ if (abortController.signal.aborted)
18
+ return;
19
+ console.log(`Browser didn't open? ${getOpenUrlInstruction()} the URL below to log in.\n`);
20
+ console.log(chalk_1.default.cyan(url));
21
+ }, AUTHORIZATION_URL_FALLBACK_DELAY_MILLISECONDS);
22
+ abortController.signal.addEventListener('abort', () => clearTimeout(timeout), { once: true });
23
+ };
24
+ return {
25
+ schedule,
26
+ cleanup: () => abortController.abort(),
27
+ };
28
+ };
11
29
  exports.loginCommand = new commander_1.Command('login')
12
30
  .description('Authenticate with Circleback via browser.')
13
31
  .action(async () => {
@@ -17,8 +35,16 @@ exports.loginCommand = new commander_1.Command('login')
17
35
  console.log(chalk_1.default.yellow('Already authenticated. Run `circleback logout` first to re-authenticate.'));
18
36
  return;
19
37
  }
20
- console.log('Opening browser for authentication…');
21
- await (0, oauth_1.login)();
38
+ console.log('Opening your browser for authentication…\n');
39
+ const authorizationUrlFallback = createAuthorizationUrlFallback();
40
+ try {
41
+ await (0, oauth_1.login)({
42
+ onAuthorizeUrl: authorizationUrlFallback.schedule,
43
+ });
44
+ }
45
+ finally {
46
+ authorizationUrlFallback.cleanup();
47
+ }
22
48
  console.log(chalk_1.default.green('Authentication successful.'));
23
49
  }
24
50
  catch (error) {
package/dist/constants.js CHANGED
@@ -8,7 +8,9 @@ const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const node_os_1 = __importDefault(require("node:os"));
10
10
  const packageJson = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(__dirname, '..', 'package.json'), 'utf-8'));
11
- exports.BASE_URL = 'https://app.circleback.ai';
11
+ // Mirrors APP_URL in packages/constants/url.ts. Hardcoded here because the CLI
12
+ // is published standalone to npm and can't depend on a workspace package.
13
+ exports.BASE_URL = 'https://circleback.ai';
12
14
  exports.CLIENT_NAME = 'Circleback CLI';
13
15
  exports.CLIENT_PACKAGE_NAME = '@circleback/cli';
14
16
  exports.CLIENT_VERSION = packageJson.version;
@@ -181,7 +181,7 @@ const formatProfiles = (profiles) => {
181
181
  profile.id,
182
182
  profile.email ?? '-',
183
183
  profile.title ?? '-',
184
- profile.company ?? '-',
184
+ profile.companyName ?? '-',
185
185
  ]));
186
186
  return `${chalk_1.default.bold(`${(0, string_1.pluralize)(profiles.length, 'person', 'people')} found`)}\n${table.toString()}`;
187
187
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@circleback/cli",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Circleback CLI. Search and access meetings, emails, calendar events, and more.",
5
5
  "license": "MIT",
6
6
  "author": "Circleback <support@circleback.ai> (https://circleback.ai)",