mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-08 00:01:28 +01:00
[EC-598] feat: handle unsupported pinAuth
This commit is contained in:
parent
e1833ca352
commit
260ea22adb
@ -11,6 +11,7 @@ export enum Fido2AutenticatorErrorCode {
|
||||
CTAP2_ERR_CREDENTIAL_EXCLUDED,
|
||||
CTAP2_ERR_UNSUPPORTED_ALGORITHM,
|
||||
CTAP2_ERR_INVALID_OPTION,
|
||||
CTAP2_ERR_PIN_AUTH_INVALID,
|
||||
}
|
||||
|
||||
export class Fido2AutenticatorError extends Error {
|
||||
@ -59,4 +60,5 @@ export interface Fido2AuthenticatorMakeCredentialsParams {
|
||||
rk?: boolean;
|
||||
uv?: boolean;
|
||||
};
|
||||
pinAuth?: unknown;
|
||||
}
|
||||
|
@ -104,6 +104,25 @@ describe("FidoAuthenticatorService", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Spec: Optionally, if the extensions parameter is present, process any extensions that this authenticator supports.
|
||||
* Currently not supported.
|
||||
*/
|
||||
describe.skip("when extensions parameter is present", () => undefined);
|
||||
|
||||
/** Spec: If pinAuth parameter is present and the pinProtocol is not supported */
|
||||
describe("when pinAuth parameter is present", () => {
|
||||
it("should throw error", async () => {
|
||||
const params = await createCredentialParams({ pinAuth: { key: "value" } });
|
||||
|
||||
const result = async () => await authenticator.makeCredential(params);
|
||||
|
||||
await expect(result).rejects.toThrowError(
|
||||
Fido2AutenticatorErrorCode[Fido2AutenticatorErrorCode.CTAP2_ERR_PIN_AUTH_INVALID]
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -145,6 +164,7 @@ async function createCredentialParams(
|
||||
rk: false as boolean,
|
||||
uv: false as boolean,
|
||||
},
|
||||
pinAuth: params.pinAuth,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,10 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
|
||||
if (params.options?.uv != undefined && typeof params.options.uv !== "boolean") {
|
||||
throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.CTAP2_ERR_INVALID_OPTION);
|
||||
}
|
||||
|
||||
if (params.pinAuth != undefined) {
|
||||
throw new Fido2AutenticatorError(Fido2AutenticatorErrorCode.CTAP2_ERR_PIN_AUTH_INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
private async vaultContainsId(ids: string[]): Promise<boolean> {
|
||||
|
Loading…
Reference in New Issue
Block a user