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

Function register

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

Source from the content-addressed store, hash-verified

165}
166
167export async function register(username: string): Promise<boolean> {
168 try {
169 const publicKey = (await getPublicKey(
170 username,
171 true
172 )) as PublicKeyCredentialCreationOptions
173 console.log('registration response:', publicKey.user, typeof publicKey.user)
174 publicKey.user.id = asArrayBuffer(publicKey.user.id as unknown as string)
175 publicKey.challenge = asArrayBuffer(
176 publicKey.challenge as unknown as string
177 )
178 const creds = await navigator.credentials.create({ publicKey })
179 await post(username, creds as PublicKeyCredential, true)
180 return true
181 } catch (error) {
182 if (error instanceof Error) {
183 // TODO: this is hacky but works
184 if (error.toString().includes('User already exists')) {
185 return false
186 }
187 throw error
188 } else {
189 throw new TypeError(`Unkown error: ${String(error)}`)
190 }
191 }
192}
193
194export async function auth(username: string): Promise<boolean> {
195 const publicKey = (await getPublicKey(

Callers

nothing calls this directly

Calls 3

getPublicKeyFunction · 0.85
asArrayBufferFunction · 0.85
postFunction · 0.85

Tested by

no test coverage detected