File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -35,16 +35,19 @@ export namespace Auth {
3535 const filepath = path . join ( Global . Path . data , "auth.json" )
3636
3737 export async function get ( providerID : string ) {
38- const file = Bun . file ( filepath )
39- return file
40- . json ( )
41- . catch ( ( ) => ( { } ) )
42- . then ( ( x ) => x [ providerID ] as Info | undefined )
38+ const auth = await all ( )
39+ return auth [ providerID ]
4340 }
4441
4542 export async function all ( ) : Promise < Record < string , Info > > {
4643 const file = Bun . file ( filepath )
47- return file . json ( ) . catch ( ( ) => ( { } ) )
44+ const data = await file . json ( ) . catch ( ( ) => ( { } as Record < string , unknown > ) )
45+ return Object . entries ( data ) . reduce ( ( acc , [ key , value ] ) => {
46+ const parsed = Info . safeParse ( value )
47+ if ( ! parsed . success ) return acc
48+ acc [ key ] = parsed . data
49+ return acc
50+ } , { } as Record < string , Info > )
4851 }
4952
5053 export async function set ( key : string , info : Info ) {
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ export const AuthListCommand = cmd({
2929 const homedir = os . homedir ( )
3030 const displayPath = authPath . startsWith ( homedir ) ? authPath . replace ( homedir , "~" ) : authPath
3131 prompts . intro ( `Credentials ${ UI . Style . TEXT_DIM } ${ displayPath } ` )
32- const results = await Auth . all ( ) . then ( ( x ) => Object . entries ( x ) )
32+ const results = Object . entries ( await Auth . all ( ) )
3333 const database = await ModelsDev . get ( )
3434
3535 for ( const [ providerID , result ] of results ) {
You can’t perform that action at this time.
0 commit comments