diff --git a/types/webappsec-credential-management/index.d.ts b/types/webappsec-credential-management/index.d.ts index c8fbf8ec60..ce3e7ef26c 100644 --- a/types/webappsec-credential-management/index.d.ts +++ b/types/webappsec-credential-management/index.d.ts @@ -494,7 +494,7 @@ interface AuthenticatorAttestationResponse extends AuthenticatorResponse { interface AuthenticatorAssertionResponse extends AuthenticatorResponse { readonly authenticatorData: ArrayBuffer; readonly signature: ArrayBuffer; - readonly userHandle?: ArrayBuffer; + readonly userHandle: ArrayBuffer | null; } /** diff --git a/types/webappsec-credential-management/webappsec-credential-management-tests.ts b/types/webappsec-credential-management/webappsec-credential-management-tests.ts index 1e0500dfce..15ae1c6b9e 100644 --- a/types/webappsec-credential-management/webappsec-credential-management-tests.ts +++ b/types/webappsec-credential-management/webappsec-credential-management-tests.ts @@ -5,7 +5,7 @@ function passwordBasedSignInDeprecated() { return; } - navigator.credentials.get({password: true}).then((credential) => { + navigator.credentials.get({ password: true }).then((credential) => { if (!credential) { return; } @@ -117,7 +117,7 @@ function federatedSignIn() { navigator.credentials .get({ password: true, - federated: {providers: ['https://federation.com']} + federated: { providers: ['https://federation.com'] } }) .then((credential) => { if (!credential) return; @@ -141,7 +141,7 @@ function federatedSignIn() { const pwCred = credential as PasswordCredential; fetch( 'https://example.com/loginEndpoint', - {credentials: pwCred, method: 'POST'}); + { credentials: pwCred, method: 'POST' }); } }); } @@ -159,7 +159,7 @@ function passwordPostSignInConfirmation() { const formElem = (e.target as HTMLFormElement); const c = new PasswordCredential(formElem); - fetch(formElem.action, {method: 'POST', credentials: c}).then(r => { + fetch(formElem.action, { method: 'POST', credentials: c }).then(r => { if (r.status === 200) { navigator.credentials!.store(c); } @@ -172,7 +172,7 @@ function passwordPostSignInConfirmation() { function federationPostSignInConfirmation() { if (navigator.credentials) { navigator.credentials.store(new FederatedCredential( - {id: 'username', provider: 'https://federation.com'})); + { id: 'username', provider: 'https://federation.com' })); } } @@ -188,7 +188,7 @@ function existingFormPost(credential: PasswordCredential) { credential.passwordName = 'p'; fetch( 'https://example.com/loginEndpoint', - {credentials: credential, method: 'POST'}); + { credentials: credential, method: 'POST' }); } function additionalDataPost(credential: PasswordCredential, token: string) { @@ -196,14 +196,14 @@ function additionalDataPost(credential: PasswordCredential, token: string) { credential.additionalData.append('csrf', token); fetch( 'https://example.com/loginEndpoint', - {credentials: credential, method: 'POST'}); + { credentials: credential, method: 'POST' }); } function formEncodedPost(credential: PasswordCredential, token: string) { credential.additionalData = new URLSearchParams(); fetch( 'https://example.com/loginEndpoint', - {credentials: credential, method: 'POST'}); + { credentials: credential, method: 'POST' }); } // requireUserMediation example: not included in the spec, but included here @@ -236,7 +236,7 @@ function createPasswordCredential() { } navigator.credentials.create({ - password: {id: 'username', password: 'password'} + password: { id: 'username', password: 'password' } }).then((credential) => { // Credential created! }); @@ -266,7 +266,7 @@ function createFederatedCredential() { } navigator.credentials.create({ - federated: {id: 'username', provider: 'provider'} + federated: { id: 'username', provider: 'provider' } }).then((credential) => { // Credential created! }); @@ -293,7 +293,7 @@ function webauthnRegister() { }, challenge, pubKeyCredParams: [ - {type: 'public-key', alg: -7}, + { type: 'public-key', alg: -7 }, ], excludeCredentials: [ { @@ -329,16 +329,18 @@ function webauthnAuthenticate() { const challenge = new Uint8Array(32); window.crypto.getRandomValues(challenge); - const authPromise = navigator.credentials.get({publicKey: { - challenge, - timeout: 5000, - rpId: document.domain, - allowCredentials: [{ - type: "public-key", - id: credentialID, - transports: ['internal', 'ble', 'nfc', 'usb'] - }], - }}); + const authPromise = navigator.credentials.get({ + publicKey: { + challenge, + timeout: 5000, + rpId: document.domain, + allowCredentials: [{ + type: "public-key", + id: credentialID, + transports: ['internal', 'ble', 'nfc', 'usb'] + }], + } + }); authPromise.then((cred) => { if (cred === null) { @@ -362,6 +364,7 @@ function mockAuthenticatorAssertionResponse() { clientDataJSON: new ArrayBuffer(0), authenticatorData: new ArrayBuffer(0), signature: new ArrayBuffer(0), + userHandle: null, }; sampleResponse.userHandle === undefined; }