MCPcopy
hub / github.com/wandb/openui / auth

Function auth

frontend/src/api/openui.ts:194–221  ·  view source on GitHub ↗
(username: string)

Source from the content-addressed store, hash-verified

192}
193
194export async function auth(username: string): Promise<boolean> {
195 const publicKey = (await getPublicKey(
196 username
197 )) as PublicKeyCredentialRequestOptions
198 console.log('auth get response:', publicKey)
199 publicKey.challenge = asArrayBuffer(publicKey.challenge as unknown as string)
200 if (
201 publicKey.allowCredentials !== undefined &&
202 publicKey.allowCredentials.length > 0
203 ) {
204 publicKey.allowCredentials[0].id = asArrayBuffer(
205 publicKey.allowCredentials[0].id as unknown as string
206 )
207 // TODO: if a user attempts to re-register they'll be given the option
208 // To scan a QR code to restore if any of the existing credentials don't
209 // Still exist. We may want to add the ability to register multiple passkeys.
210 // We might be able to use aaguid to determine machine uniqueness
211 }
212 let creds
213 try {
214 creds = await navigator.credentials.get({ publicKey })
215 } catch (error) {
216 console.error('refused:', error)
217 return false
218 }
219 await post(username, creds as PublicKeyCredential)
220 return true
221}

Callers

nothing calls this directly

Calls 4

getPublicKeyFunction · 0.85
asArrayBufferFunction · 0.85
postFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected