mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
[EC-598] chore: collect all passkeys stuff under common folder
This commit is contained in:
21
libs/common/src/webauthn/abstractions/fido2-utils.ts
Normal file
21
libs/common/src/webauthn/abstractions/fido2-utils.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user