|
360 | 360 | function registerResidentKey(event) {
|
361 | 361 | return register(event, true);
|
362 | 362 | }
|
363 |
| -function register(event, requireResidentKey) { |
| 363 | +async function register(event, requireResidentKey) { |
364 | 364 | const username = document.getElementById('username').value;
|
365 | 365 | const displayName = document.getElementById('displayName').value;
|
366 | 366 | const credentialNickname = document.getElementById('credentialNickname').value;
|
367 | 367 | const useU2f = document.getElementById('useU2f').checked;
|
368 | 368 |
|
369 | 369 | var request;
|
370 | 370 |
|
371 |
| - return performCeremony({ |
372 |
| - getIndexActions, |
373 |
| - getRequest: urls => getRegisterRequest(urls, username, displayName, credentialNickname, requireResidentKey), |
374 |
| - statusStrings: { |
375 |
| - init: 'Initiating registration ceremony with server...', |
376 |
| - authenticatorRequest: 'Asking authenticators to create credential...', |
377 |
| - success: 'Registration successful!', |
378 |
| - }, |
379 |
| - executeRequest: req => { |
380 |
| - request = req; |
381 |
| - return executeRegisterRequest(req, useU2f); |
382 |
| - }, |
383 |
| - useU2f, |
384 |
| - }) |
385 |
| - .then(data => { |
| 371 | + try { |
| 372 | + const data = await performCeremony({ |
| 373 | + getIndexActions, |
| 374 | + getRequest: urls => getRegisterRequest(urls, username, displayName, credentialNickname, requireResidentKey), |
| 375 | + statusStrings: { |
| 376 | + init: 'Initiating registration ceremony with server...', |
| 377 | + authenticatorRequest: 'Asking authenticators to create credential...', |
| 378 | + success: 'Registration successful!', |
| 379 | + }, |
| 380 | + executeRequest: req => { |
| 381 | + request = req; |
| 382 | + return executeRegisterRequest(req, useU2f); |
| 383 | + }, |
| 384 | + useU2f, |
| 385 | + }); |
| 386 | + |
386 | 387 | if (data.registration) {
|
387 | 388 | const nicknameInfo = {
|
388 | 389 | nickname: data.registration.credentialNickname,
|
|
401 | 402 | addMessage("Warning: Attestation is not trusted!");
|
402 | 403 | }
|
403 | 404 | }
|
404 |
| - }) |
405 |
| - .catch((err) => { |
| 405 | + |
| 406 | + } catch (err) { |
406 | 407 | setStatus('Registration failed.');
|
407 | 408 | console.error('Registration failed', err);
|
408 | 409 |
|
|
422 | 423 | addMessages(err.messages);
|
423 | 424 | }
|
424 | 425 | return rejected(err);
|
425 |
| - }); |
| 426 | + } |
426 | 427 | }
|
427 | 428 |
|
428 | 429 | function getAuthenticateRequest(urls, username) {
|
|
0 commit comments