mirror of
https://github.com/bitwarden/browser
synced 2026-02-01 09:13:54 +00:00
Fix types and tests
This commit is contained in:
@@ -365,3 +365,5 @@ const mockPublicKeyCredential: CustomPublicKeyCredential = {
|
||||
response: mockAuthenticatorAssertionResponse,
|
||||
prf: randomBytes(32),
|
||||
};
|
||||
|
||||
export { mockPublicKeyCredential };
|
||||
|
||||
@@ -15,10 +15,7 @@ import { PasswordLoginStrategyData } from "../../login-strategies/password-login
|
||||
import { SsoLoginStrategyData } from "../../login-strategies/sso-login.strategy";
|
||||
import { UserApiLoginStrategyData } from "../../login-strategies/user-api-login.strategy";
|
||||
import { WebAuthnLoginStrategyData } from "../../login-strategies/webauthn-login.strategy";
|
||||
import {
|
||||
MockAuthenticatorAssertionResponse,
|
||||
MockPublicKeyCredential,
|
||||
} from "../../login-strategies/webauthn-login.strategy.spec";
|
||||
import { mockPublicKeyCredential } from "../../login-strategies/webauthn-login.strategy.spec";
|
||||
import { AuthRequestLoginCredentials, WebAuthnLoginCredentials } from "../../models";
|
||||
|
||||
import { CACHE_KEY } from "./login-strategy.state";
|
||||
@@ -104,9 +101,8 @@ describe("LOGIN_STRATEGY_CACHE_KEY", () => {
|
||||
});
|
||||
|
||||
it("should correctly deserialize WebAuthnLoginStrategyData", () => {
|
||||
global.AuthenticatorAssertionResponse = MockAuthenticatorAssertionResponse;
|
||||
const actual = { webAuthn: new WebAuthnLoginStrategyData() };
|
||||
const publicKeyCredential = new MockPublicKeyCredential();
|
||||
const publicKeyCredential = mockPublicKeyCredential;
|
||||
const deviceResponse = new WebAuthnLoginAssertionResponseRequest(publicKeyCredential);
|
||||
const prfKey = new SymmetricCryptoKey(new Uint8Array(64)) as PrfKey;
|
||||
actual.webAuthn.credentials = new WebAuthnLoginCredentials("TOKEN", deviceResponse, prfKey);
|
||||
|
||||
@@ -23,7 +23,7 @@ export class DefaultNavigatorCredentialsService implements NavigatorCredentialsS
|
||||
const response: AuthenticatorAssertionResponse =
|
||||
result.response as AuthenticatorAssertionResponse;
|
||||
return {
|
||||
authenticatorAttachment: result!.authenticatorAttachment,
|
||||
authenticatorAttachment: result!.authenticatorAttachment!,
|
||||
id: result.id,
|
||||
rawId: new Uint8Array(result.rawId),
|
||||
response: {
|
||||
@@ -42,9 +42,9 @@ export class DefaultNavigatorCredentialsService implements NavigatorCredentialsS
|
||||
}
|
||||
}
|
||||
|
||||
function bufferSourceToUint8Array(source: BufferSource | null): Uint8Array | null {
|
||||
if (source === null) {
|
||||
return null;
|
||||
function bufferSourceToUint8Array(source: BufferSource | undefined): Uint8Array | undefined {
|
||||
if (source === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (source instanceof ArrayBuffer) {
|
||||
|
||||
Reference in New Issue
Block a user