mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-22 16:29:09 +01:00
PM-4382 minor cleanup around the passkey popup (#6629)
This commit is contained in:
parent
5dd2e3a1e3
commit
fbe960e760
@ -235,6 +235,27 @@ export class BrowserApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static messageListener$() {
|
||||||
|
return new Observable<unknown>((subscriber) => {
|
||||||
|
const handler = (message: unknown) => {
|
||||||
|
subscriber.next(message);
|
||||||
|
};
|
||||||
|
|
||||||
|
BrowserApi.messageListener("message", handler);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
chrome.runtime.onMessage.removeListener(handler);
|
||||||
|
|
||||||
|
if (BrowserApi.isSafariApi) {
|
||||||
|
const index = BrowserApi.registeredMessageListeners.indexOf(handler);
|
||||||
|
if (index !== -1) {
|
||||||
|
BrowserApi.registeredMessageListeners.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
static storageChangeListener(
|
static storageChangeListener(
|
||||||
callback: Parameters<typeof chrome.storage.onChanged.addListener>[0]
|
callback: Parameters<typeof chrome.storage.onChanged.addListener>[0]
|
||||||
) {
|
) {
|
||||||
@ -262,27 +283,6 @@ export class BrowserApi {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static messageListener$() {
|
|
||||||
return new Observable<unknown>((subscriber) => {
|
|
||||||
const handler = (message: unknown) => {
|
|
||||||
subscriber.next(message);
|
|
||||||
};
|
|
||||||
|
|
||||||
BrowserApi.messageListener("message", handler);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
chrome.runtime.onMessage.removeListener(handler);
|
|
||||||
|
|
||||||
if (BrowserApi.isSafariApi) {
|
|
||||||
const index = BrowserApi.registeredMessageListeners.indexOf(handler);
|
|
||||||
if (index !== -1) {
|
|
||||||
BrowserApi.registeredMessageListeners.splice(index, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static sendMessage(subscriber: string, arg: any = {}) {
|
static sendMessage(subscriber: string, arg: any = {}) {
|
||||||
const message = Object.assign({}, { command: subscriber }, arg);
|
const message = Object.assign({}, { command: subscriber }, arg);
|
||||||
return chrome.runtime.sendMessage(message);
|
return chrome.runtime.sendMessage(message);
|
||||||
|
@ -14,7 +14,7 @@ export class Fido2CipherRowComponent {
|
|||||||
@Input() isSearching: boolean;
|
@Input() isSearching: boolean;
|
||||||
@Input() isSelected: boolean;
|
@Input() isSelected: boolean;
|
||||||
|
|
||||||
selectCipher(c: CipherView) {
|
protected selectCipher(c: CipherView) {
|
||||||
this.onSelected.emit(c);
|
this.onSelected.emit(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ import {
|
|||||||
templateUrl: "fido2-use-browser-link.component.html",
|
templateUrl: "fido2-use-browser-link.component.html",
|
||||||
})
|
})
|
||||||
export class Fido2UseBrowserLinkComponent {
|
export class Fido2UseBrowserLinkComponent {
|
||||||
fido2PopoutSessionData$ = fido2PopoutSessionData$();
|
protected fido2PopoutSessionData$ = fido2PopoutSessionData$();
|
||||||
|
|
||||||
async abort() {
|
protected async abort() {
|
||||||
const sessionData = await firstValueFrom(this.fido2PopoutSessionData$);
|
const sessionData = await firstValueFrom(this.fido2PopoutSessionData$);
|
||||||
BrowserFido2UserInterfaceSession.abortPopout(sessionData.sessionId, true);
|
BrowserFido2UserInterfaceSession.abortPopout(sessionData.sessionId, true);
|
||||||
return;
|
return;
|
||||||
|
@ -7,13 +7,13 @@
|
|||||||
<i class="bwi bwi-shield"></i>
|
<i class="bwi bwi-shield"></i>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container *ngIf="data.message.type == 'PickCredentialRequest'">
|
<ng-container *ngIf="data.message.type === 'PickCredentialRequest'">
|
||||||
<div class="logo">
|
<div class="logo">
|
||||||
<i class="bwi bwi-shield"></i><span><strong>bit</strong>warden</span>
|
<i class="bwi bwi-shield"></i><span><strong>bit</strong>warden</span>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
<ng-container *ngIf="data.message.type == 'ConfirmNewCredentialRequest'">
|
<ng-container *ngIf="data.message.type === 'ConfirmNewCredentialRequest'">
|
||||||
<div class="search">
|
<div class="search">
|
||||||
<input
|
<input
|
||||||
type="{{ searchTypeSearch ? 'search' : 'text' }}"
|
type="{{ searchTypeSearch ? 'search' : 'text' }}"
|
||||||
@ -100,7 +100,7 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container *ngIf="data.message.type == 'InformExcludedCredentialRequest'">
|
<ng-container *ngIf="data.message.type === 'InformExcludedCredentialRequest'">
|
||||||
<div class="auth-flow">
|
<div class="auth-flow">
|
||||||
<p class="subtitle">{{ "passkeyAlreadyExists" | i18n }}</p>
|
<p class="subtitle">{{ "passkeyAlreadyExists" | i18n }}</p>
|
||||||
<div class="box list">
|
<div class="box list">
|
||||||
@ -120,7 +120,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container *ngIf="data.message.type == 'InformCredentialNotFoundRequest'">
|
<ng-container *ngIf="data.message.type === 'InformCredentialNotFoundRequest'">
|
||||||
<div class="auth-flow">
|
<div class="auth-flow">
|
||||||
<p class="subtitle">{{ "noPasskeysFoundForThisApplication" | i18n }}</p>
|
<p class="subtitle">{{ "noPasskeysFoundForThisApplication" | i18n }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -217,7 +217,7 @@ export class Fido2Component implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
protected async submit() {
|
||||||
const data = this.message$.value;
|
const data = this.message$.value;
|
||||||
if (data?.type === "PickCredentialRequest") {
|
if (data?.type === "PickCredentialRequest") {
|
||||||
const userVerified = await this.handleUserVerification(data.userVerification, this.cipher);
|
const userVerified = await this.handleUserVerification(data.userVerification, this.cipher);
|
||||||
@ -254,7 +254,7 @@ export class Fido2Component implements OnInit, OnDestroy {
|
|||||||
this.loading = true;
|
this.loading = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveNewLogin() {
|
protected async saveNewLogin() {
|
||||||
const data = this.message$.value;
|
const data = this.message$.value;
|
||||||
if (data?.type === "ConfirmNewCredentialRequest") {
|
if (data?.type === "ConfirmNewCredentialRequest") {
|
||||||
let userVerified = false;
|
let userVerified = false;
|
||||||
|
@ -168,13 +168,12 @@ export class AddEditComponent extends BaseAddEditComponent {
|
|||||||
async submit(): Promise<boolean> {
|
async submit(): Promise<boolean> {
|
||||||
const fido2SessionData = await firstValueFrom(this.fido2PopoutSessionData$);
|
const fido2SessionData = await firstValueFrom(this.fido2PopoutSessionData$);
|
||||||
// Would be refactored after rework is done on the windows popout service
|
// Would be refactored after rework is done on the windows popout service
|
||||||
|
|
||||||
|
const { isFido2Session, sessionId, userVerification } = fido2SessionData;
|
||||||
if (
|
if (
|
||||||
this.inPopout &&
|
this.inPopout &&
|
||||||
fido2SessionData.isFido2Session &&
|
isFido2Session &&
|
||||||
!(await this.handleFido2UserVerification(
|
!(await this.handleFido2UserVerification(sessionId, userVerification))
|
||||||
fido2SessionData.sessionId,
|
|
||||||
fido2SessionData.userVerification
|
|
||||||
))
|
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -184,11 +183,11 @@ export class AddEditComponent extends BaseAddEditComponent {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.inPopout && fido2SessionData.isFido2Session) {
|
if (this.inPopout && isFido2Session) {
|
||||||
BrowserFido2UserInterfaceSession.confirmNewCredentialResponse(
|
BrowserFido2UserInterfaceSession.confirmNewCredentialResponse(
|
||||||
fido2SessionData.sessionId,
|
sessionId,
|
||||||
this.cipher.id,
|
this.cipher.id,
|
||||||
fido2SessionData.userVerification
|
userVerification
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user