Skip to content
Open
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
7 changes: 5 additions & 2 deletions src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { hideBin } from 'yargs/helpers';
import chalk from 'chalk';
import { ensureAuthenticated } from './lib/ensure-auth.js';
import { checkForUpdates } from './lib/version-check.js';
import type { ArgumentsCamelCase } from 'yargs';
import type { InstallArgs } from './commands/install.js';

const NODE_VERSION_RANGE = getConfig().nodeVersion;

Expand Down Expand Up @@ -274,7 +276,8 @@ yargs(hideBin(process.argv))
},
)
.command('list', 'List configured environments', {}, async (argv) => {
await applyInsecureStorage((argv as any).insecureStorage);
const typedArgv = argv as { insecureStorage?: boolean };
await applyInsecureStorage(typedArgv.insecureStorage);
const { runEnvList } = await import('./commands/env.js');
await runEnvList();
})
Expand Down Expand Up @@ -502,7 +505,7 @@ yargs(hideBin(process.argv))
await ensureAuthenticated();

const { handleInstall } = await import('./commands/install.js');
await handleInstall({ dashboard: false } as any);
await handleInstall({ dashboard: false } as ArgumentsCamelCase<InstallArgs>);
process.exit(0);
},
)
Expand Down
12 changes: 6 additions & 6 deletions src/commands/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import clack from '../utils/clack.js';
import chalk from 'chalk';
import type { ArgumentsCamelCase } from 'yargs';

interface InstallArgs {
export interface InstallArgs {
debug?: boolean;
local?: boolean;
ci?: boolean;
Expand Down Expand Up @@ -49,16 +49,16 @@ export async function handleInstall(argv: ArgumentsCamelCase<InstallArgs>): Prom
clack.intro(chalk.inverse('WorkOS AuthKit Installer'));
clack.log.error(
'This installer requires an interactive terminal (TTY) to run.\n' +
'It appears you are running in a non-interactive environment.\n' +
'Please run the installer in an interactive terminal.\n\n' +
'For CI/CD environments, use --ci mode:\n' +
' workos install --ci --api-key sk_xxx --client-id client_xxx',
'It appears you are running in a non-interactive environment.\n' +
'Please run the installer in an interactive terminal.\n\n' +
'For CI/CD environments, use --ci mode:\n' +
' workos install --ci --api-key sk_xxx --client-id client_xxx',
);
process.exit(1);
}

try {
await runInstaller(options as unknown as InstallerOptions);
await runInstaller(options);
process.exit(0);
} catch (err) {
const { getLogFilePath } = await import('../utils/debug.js');
Expand Down
15 changes: 13 additions & 2 deletions src/utils/clack-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ import { analytics } from './analytics.js';
import clack from './clack.js';
import { INTEGRATION_CONFIG } from '../lib/config.js';

/**
* Redact sensitive info (API keys, client secrets) from a string.
*/
export function redactSensitiveInfo(str: string): string {
if (!str) return str;
// Redact WorkOS API keys (sk_...), client secrets, etc.
return str
.replace(/sk_[a-zA-Z0-9]+/g, 'sk_***')
.replace(/client_[a-zA-Z0-9]+/g, 'client_***');
}

interface ProjectData {
projectApiKey: string;
accessToken: string;
Expand Down Expand Up @@ -329,8 +340,8 @@ export async function installPackage({
fs.writeFileSync(
join(process.cwd(), `workos-installation-error-${Date.now()}.log`),
JSON.stringify({
stdout,
stderr,
stdout: redactSensitiveInfo(stdout),
stderr: redactSensitiveInfo(stderr),
}),
{ encoding: 'utf8' },
);
Expand Down