Skip to content

Commit 3555dbc

Browse files
authored
fix: use shorter tokens without prefix (#147)
1 parent 272a3db commit 3555dbc

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/agent/router.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,13 +667,13 @@ export function createRouter(ctx: RouterContext) {
667667
const token = config.auth?.token;
668668
return {
669669
hasToken: !!token,
670-
tokenPreview: token ? `${token.slice(0, 10)}...${token.slice(-4)}` : undefined,
670+
tokenPreview: token ? `${token.slice(0, 4)}...${token.slice(-4)}` : undefined,
671671
};
672672
});
673673

674674
const generateAuthToken = os.output(z.object({ token: z.string() })).handler(async () => {
675675
const currentConfig = ctx.config.get();
676-
const token = `perry-${crypto.randomBytes(16).toString('hex')}`;
676+
const token = crypto.randomBytes(12).toString('hex');
677677
const newConfig = { ...currentConfig, auth: { ...currentConfig.auth, token } };
678678
ctx.config.set(newConfig);
679679
await saveAgentConfig(newConfig, ctx.configDir);

src/agent/run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ async function ensureAuthForNewInstalls(configDir: string): Promise<AgentConfig>
269269
const config = await loadAgentConfig(configDir);
270270

271271
if (!configExists && !config.auth?.token) {
272-
const token = `perry-${crypto.randomBytes(16).toString('hex')}`;
272+
const token = crypto.randomBytes(12).toString('hex');
273273
config.auth = { ...config.auth, token };
274274
await saveAgentConfig(config, configDir);
275275

src/cli/setup-wizard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ function SetupWizard() {
360360
};
361361

362362
const generateAuthToken = () => {
363-
const token = `perry-${crypto.randomBytes(16).toString('hex')}`;
363+
const token = crypto.randomBytes(12).toString('hex');
364364
setState((s) => ({
365365
...s,
366366
authToken: token,

src/commands/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function authInit(): Promise<void> {
1111
return;
1212
}
1313

14-
const token = `perry-${crypto.randomBytes(16).toString('hex')}`;
14+
const token = crypto.randomBytes(12).toString('hex');
1515
config.auth = { ...config.auth, token };
1616
await saveAgentConfig(config, configDir);
1717

0 commit comments

Comments
 (0)