@@ -6,7 +6,7 @@ import fs from "fs/promises"
66export namespace AuthAnthropic {
77 const CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e"
88
9- const file = Bun . file ( path . join ( Global . Path . data , "auth" , "anthropic.json" ) )
9+ const filepath = path . join ( Global . Path . data , "auth" , "anthropic.json" )
1010
1111 export async function authorize ( ) {
1212 const pkce = await generatePKCE ( )
@@ -48,15 +48,15 @@ export namespace AuthAnthropic {
4848 } ) ,
4949 } )
5050 if ( ! result . ok ) throw new ExchangeFailed ( )
51+ const file = Bun . file ( filepath )
5152 await Bun . write ( file , result )
5253 await fs . chmod ( file . name ! , 0o600 )
5354 }
5455
55- export const exists = file . exists
56-
5756 export async function access ( ) {
58- if ( ! ( await file . exists ( ) ) ) return
59- const result = await file . json ( )
57+ const file = Bun . file ( filepath )
58+ const result = await file . json ( ) . catch ( ( ) => ( { } ) )
59+ if ( ! result ) return
6060 const refresh = result . refresh_token
6161 const response = await fetch (
6262 "https://console.anthropic.com/v1/oauth/token" ,
0 commit comments