mirror of
https://github.com/bitwarden/browser
synced 2025-12-20 10:13:31 +00:00
[EC-598] chore: collect all passkeys stuff under common folder
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
export interface NewCredentialParams {
|
||||
credentialName: string;
|
||||
userName: string;
|
||||
}
|
||||
|
||||
export abstract class Fido2UserInterfaceService {
|
||||
confirmCredential: (cipherId: string, abortController?: AbortController) => Promise<boolean>;
|
||||
pickCredential: (cipherIds: string[], abortController?: AbortController) => Promise<string>;
|
||||
confirmNewCredential: (
|
||||
params: NewCredentialParams,
|
||||
abortController?: AbortController
|
||||
) => Promise<boolean>;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { Utils } from "../../misc/utils";
|
||||
|
||||
export class Fido2Utils {
|
||||
static bufferToString(bufferSource: BufferSource): string {
|
||||
const buffer = Fido2Utils.bufferSourceToUint8Array(bufferSource);
|
||||
|
||||
return Utils.fromBufferToUrlB64(buffer);
|
||||
}
|
||||
|
||||
static stringToBuffer(str: string): Uint8Array {
|
||||
return Utils.fromUrlB64ToArray(str);
|
||||
}
|
||||
|
||||
private static bufferSourceToUint8Array(bufferSource: BufferSource) {
|
||||
if (bufferSource instanceof ArrayBuffer) {
|
||||
return new Uint8Array(bufferSource);
|
||||
} else {
|
||||
return new Uint8Array(bufferSource.buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
export interface CredentialRegistrationParams {
|
||||
origin: string;
|
||||
attestation?: "direct" | "enterprise" | "indirect" | "none";
|
||||
authenticatorSelection?: {
|
||||
// authenticatorAttachment?: AuthenticatorAttachment; // not used
|
||||
requireResidentKey?: boolean;
|
||||
residentKey?: "discouraged" | "preferred" | "required";
|
||||
userVerification?: "discouraged" | "preferred" | "required";
|
||||
};
|
||||
challenge: string; // b64 encoded
|
||||
excludeCredentials?: {
|
||||
id: string; // b64 encoded
|
||||
transports?: ("ble" | "internal" | "nfc" | "usb")[];
|
||||
// type: "public-key"; // not used
|
||||
}[];
|
||||
extensions?: {
|
||||
appid?: string;
|
||||
appidExclude?: string;
|
||||
credProps?: boolean;
|
||||
uvm?: boolean;
|
||||
};
|
||||
pubKeyCredParams: {
|
||||
alg: number;
|
||||
// type: "public-key"; // not used
|
||||
}[];
|
||||
rp: {
|
||||
id?: string;
|
||||
name: string;
|
||||
};
|
||||
user: {
|
||||
id: string; // b64 encoded
|
||||
displayName: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface CredentialRegistrationResult {
|
||||
credentialId: string;
|
||||
clientDataJSON: string;
|
||||
attestationObject: string;
|
||||
authData: string;
|
||||
publicKeyAlgorithm: number;
|
||||
transports: string[];
|
||||
}
|
||||
|
||||
export interface CredentialAssertParams {
|
||||
allowedCredentialIds: string[];
|
||||
rpId: string;
|
||||
origin: string;
|
||||
challenge: string;
|
||||
}
|
||||
|
||||
export interface CredentialAssertResult {
|
||||
credentialId: string;
|
||||
clientDataJSON: string;
|
||||
authenticatorData: string;
|
||||
signature: string;
|
||||
userHandle: string;
|
||||
}
|
||||
|
||||
export class Fido2Error extends Error {
|
||||
constructor(message: string, readonly fallbackRequested = false) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
export class RequestAbortedError extends Fido2Error {
|
||||
constructor(fallbackRequested = false) {
|
||||
super("Fido2 request was aborted", fallbackRequested);
|
||||
}
|
||||
}
|
||||
|
||||
export class NoCredentialFoundError extends Fido2Error {
|
||||
constructor() {
|
||||
super("No valid credential found", true);
|
||||
}
|
||||
}
|
||||
|
||||
export class OriginMismatchError extends Fido2Error {
|
||||
constructor() {
|
||||
super(
|
||||
"Authentication requests must originate from the same source that created the credential.",
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class Fido2Service {
|
||||
createCredential: (
|
||||
params: CredentialRegistrationParams,
|
||||
abortController?: AbortController
|
||||
) => Promise<CredentialRegistrationResult>;
|
||||
assertCredential: (
|
||||
params: CredentialAssertParams,
|
||||
abortController?: AbortController
|
||||
) => Promise<CredentialAssertResult>;
|
||||
}
|
||||
Reference in New Issue
Block a user