Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"@inquirer/input": "^5.0.10",
"@inquirer/password": "^5.0.10",
"@inquirer/select": "^5.1.2",
"@napi-rs/keyring": "^1.3.0",
"@root/walk": "~1.1.0",
"@sapphire/duration": "^1.2.0",
"@sapphire/result": "^2.8.0",
Expand Down
135 changes: 135 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/commands/actors/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class ActorsSearchCommand extends ApifyCommand<typeof ActorsSearchCommand
const { query } = this.args;
const { json, sortBy, category, username, pricingModel, limit, offset } = this.flags;

const clientOptions = getApifyClientOptions();
const clientOptions = await getApifyClientOptions();
delete clientOptions.token;
const client = new ApifyClient(clientOptions);

Expand Down
13 changes: 12 additions & 1 deletion src/commands/auth/login.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Server } from 'node:http';
import type { AddressInfo } from 'node:net';
import process from 'node:process';

import chalk from 'chalk';
import computerName from 'computer-name';
Expand All @@ -12,6 +13,7 @@ import { cryptoRandomObjectId } from '@apify/utilities';
import { ApifyCommand } from '../../lib/command-framework/apify-command.js';
import { Flags } from '../../lib/command-framework/flags.js';
import { AUTH_FILE_PATH } from '../../lib/consts.js';
import { getBackend } from '../../lib/credentials.js';
import { updateUserId } from '../../lib/hooks/telemetry/useTelemetryState.js';
import { useMaskedInput } from '../../lib/hooks/user-confirmations/useMaskedInput.js';
import { useSelectFromList } from '../../lib/hooks/user-confirmations/useSelectFromList.js';
Expand All @@ -34,8 +36,17 @@ const tryToLogin = async (token: string) => {
if (isUserLogged) {
await updateUserId(userInfo.id!);

const backend = await getBackend();
let tokenLocation: string;
if (backend === 'keyring') {
tokenLocation = 'your OS keyring';
} else if (process.env.APIFY_DISABLE_KEYRING === '1') {
tokenLocation = `${AUTH_FILE_PATH()} (OS keyring disabled via APIFY_DISABLE_KEYRING)`;
} else {
tokenLocation = `${AUTH_FILE_PATH()} (OS keyring unavailable; set APIFY_DISABLE_KEYRING=1 to silence)`;
}
success({
message: `You are logged in to Apify as ${userInfo.username || userInfo.id}. ${chalk.gray(`Your token is stored at ${AUTH_FILE_PATH()}.`)}`,
message: `You are logged in to Apify as ${userInfo.username || userInfo.id}. ${chalk.gray(`Your token is stored in ${tokenLocation}.`)}`,
});
} else {
error({
Expand Down
2 changes: 2 additions & 0 deletions src/commands/auth/logout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ApifyCommand } from '../../lib/command-framework/apify-command.js';
import { AUTH_FILE_PATH } from '../../lib/consts.js';
import { clearSecrets } from '../../lib/credentials.js';
import { rimrafPromised } from '../../lib/files.js';
import { updateUserId } from '../../lib/hooks/telemetry/useTelemetryState.js';
import { success } from '../../lib/outputs.js';
Expand All @@ -24,6 +25,7 @@ export class AuthLogoutCommand extends ApifyCommand<typeof AuthLogoutCommand> {
static override docsUrl = 'https://docs.apify.com/cli/docs/reference#apify-logout';

async run() {
await clearSecrets();
await rimrafPromised(AUTH_FILE_PATH());

await updateUserId(null);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const getApifyStorageClient = async (
const apifyToken = await getApifyTokenFromEnvOrAuthFile();

return new ApifyClient({
...getApifyClientOptions(apifyToken),
...(await getApifyClientOptions(apifyToken)),
...options,
});
};
Expand Down
Loading
Loading