mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-31 22:51:28 +01:00
[EC-598] feat: implement calls to new service
This commit is contained in:
parent
e52e3dba45
commit
88ebb6a4b0
@ -9,6 +9,7 @@ import { CryptoFunctionService as CryptoFunctionServiceAbstraction } from "@bitw
|
||||
import { EncryptService } from "@bitwarden/common/abstractions/encrypt.service";
|
||||
import { EventService as EventServiceAbstraction } from "@bitwarden/common/abstractions/event.service";
|
||||
import { ExportService as ExportServiceAbstraction } from "@bitwarden/common/abstractions/export.service";
|
||||
import { Fido2Service as Fido2ServiceAbstraction } from "@bitwarden/common/abstractions/fido2/fido2.service.abstraction";
|
||||
import { FileUploadService as FileUploadServiceAbstraction } from "@bitwarden/common/abstractions/fileUpload.service";
|
||||
import { FolderApiServiceAbstraction } from "@bitwarden/common/abstractions/folder/folder-api.service.abstraction";
|
||||
import { InternalFolderService as InternalFolderServiceAbstraction } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
|
||||
@ -56,6 +57,7 @@ import { EncryptServiceImplementation } from "@bitwarden/common/services/cryptog
|
||||
import { MultithreadEncryptServiceImplementation } from "@bitwarden/common/services/cryptography/multithread-encrypt.service.implementation";
|
||||
import { EventService } from "@bitwarden/common/services/event.service";
|
||||
import { ExportService } from "@bitwarden/common/services/export.service";
|
||||
import { Fido2Service } from "@bitwarden/common/services/fido2/fido2.service";
|
||||
import { FileUploadService } from "@bitwarden/common/services/fileUpload.service";
|
||||
import { FolderApiService } from "@bitwarden/common/services/folder/folder-api.service";
|
||||
import { KeyConnectorService } from "@bitwarden/common/services/keyConnector.service";
|
||||
@ -165,6 +167,7 @@ export default class MainBackground {
|
||||
policyApiService: PolicyApiServiceAbstraction;
|
||||
userVerificationApiService: UserVerificationApiServiceAbstraction;
|
||||
syncNotifierService: SyncNotifierServiceAbstraction;
|
||||
fido2Service: Fido2ServiceAbstraction;
|
||||
|
||||
// Passed to the popup for Safari to workaround issues with theming, downloading, etc.
|
||||
backgroundWindow = window;
|
||||
@ -461,6 +464,8 @@ export default class MainBackground {
|
||||
this.userVerificationApiService
|
||||
);
|
||||
|
||||
this.fido2Service = new Fido2Service();
|
||||
|
||||
const systemUtilsServiceReloadCallback = () => {
|
||||
const forceWindowReload =
|
||||
this.platformUtilsService.isSafari() ||
|
||||
|
@ -204,6 +204,13 @@ export default class RuntimeBackground {
|
||||
case "getClickedElementResponse":
|
||||
this.platformUtilsService.copyToClipboard(msg.identifier, { window: window });
|
||||
break;
|
||||
case "fido2RegisterCredentialRequest":
|
||||
BrowserApi.tabSendMessageData(
|
||||
sender.tab,
|
||||
"fido2RegisterCredentialResponse",
|
||||
await this.main.fido2Service.createCredential(msg.data)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -12,6 +12,11 @@ const messenger = Messenger.createInExtensionContext(window, chrome.runtime.conn
|
||||
|
||||
messenger.addHandler(async (message) => {
|
||||
if (message.type === MessageType.CredentialCreationRequest) {
|
||||
chrome.runtime.sendMessage({
|
||||
command: "fido2RegisterCredentialRequest",
|
||||
data: message.data,
|
||||
});
|
||||
|
||||
return {
|
||||
type: MessageType.CredentialCreationResponse,
|
||||
approved: true,
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { CredentialRegistrationParams } from "@bitwarden/common/abstractions/fido2/fido2.service.abstraction";
|
||||
|
||||
export enum MessageType {
|
||||
CredentialCreationRequest,
|
||||
CredentialCreationResponse,
|
||||
@ -9,7 +11,7 @@ export enum MessageType {
|
||||
|
||||
export type CredentialCreationRequest = {
|
||||
type: MessageType.CredentialCreationRequest;
|
||||
rpId: string;
|
||||
data: CredentialRegistrationParams;
|
||||
};
|
||||
|
||||
export type CredentialCreationResponse = {
|
||||
|
@ -14,7 +14,11 @@ const messenger = Messenger.createInPageContext(window);
|
||||
navigator.credentials.create = async (options?: CredentialCreationOptions): Promise<Credential> => {
|
||||
await messenger.request({
|
||||
type: MessageType.CredentialCreationRequest,
|
||||
rpId: options.publicKey.rp.id,
|
||||
data: {
|
||||
rp: {
|
||||
id: options.publicKey.rp.id,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return await browserCredentials.create(options);
|
||||
|
@ -0,0 +1,10 @@
|
||||
export interface CredentialRegistrationParams {
|
||||
rp: {
|
||||
id?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export abstract class Fido2Service {
|
||||
createCredential: (params: CredentialRegistrationParams) => unknown;
|
||||
assertCredential: () => unknown;
|
||||
}
|
16
libs/common/src/services/fido2/fido2.service.ts
Normal file
16
libs/common/src/services/fido2/fido2.service.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import {
|
||||
CredentialRegistrationParams,
|
||||
Fido2Service as Fido2ServiceAbstraction,
|
||||
} from "../../abstractions/fido2/fido2.service.abstraction";
|
||||
|
||||
export class Fido2Service implements Fido2ServiceAbstraction {
|
||||
createCredential(params: CredentialRegistrationParams): unknown {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log("Fido2Service.registerCredential");
|
||||
return undefined;
|
||||
}
|
||||
|
||||
assertCredential(): unknown {
|
||||
return undefined;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user