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

Function post

frontend/src/api/openui.ts:133–165  ·  view source on GitHub ↗
(
	username: string,
	creds: PublicKeyCredential,
	create = false
)

Source from the content-addressed store, hash-verified

131}
132
133async function post(
134 username: string,
135 creds: PublicKeyCredential,
136 create = false
137) {
138 const { attestationObject, clientDataJSON, signature, authenticatorData } =
139 creds.response as AuthResponse
140 const data = {
141 id: creds.id,
142 raw_id: asBase64(creds.rawId),
143 response: {
144 attestation_object: asBase64(attestationObject),
145 client_data_json: asBase64(clientDataJSON),
146 signature: asBase64(signature),
147 authenticator_data: asBase64(authenticatorData)
148 }
149 }
150 const req = await fetch(
151 `${API_HOST}/${create ? 'register' : 'auth'}/${encodeURIComponent(
152 username
153 )}`,
154 {
155 credentials: 'same-origin',
156 method: 'POST',
157 body: JSON.stringify(data),
158 headers: { 'content-type': 'application/json' }
159 }
160 )
161
162 if (req.status !== 200) {
163 throw new Error(`Unexpected response ${req.status}: ${await req.text()}`)
164 }
165}
166
167export async function register(username: string): Promise<boolean> {
168 try {

Callers 2

registerFunction · 0.85
authFunction · 0.85

Calls 1

asBase64Function · 0.85

Tested by

no test coverage detected