mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
added isNotIFrame method to page-script
This commit is contained in:
@@ -52,6 +52,14 @@ const browserCredentials = {
|
|||||||
|
|
||||||
const messenger = Messenger.forDOMCommunication(window);
|
const messenger = Messenger.forDOMCommunication(window);
|
||||||
|
|
||||||
|
const isNotIframeCheck = () => {
|
||||||
|
try {
|
||||||
|
return window.self === window.top;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
navigator.credentials.create = async (
|
navigator.credentials.create = async (
|
||||||
options?: CredentialCreationOptions,
|
options?: CredentialCreationOptions,
|
||||||
abortController?: AbortController
|
abortController?: AbortController
|
||||||
@@ -62,6 +70,8 @@ navigator.credentials.create = async (
|
|||||||
(options?.publicKey?.authenticatorSelection.authenticatorAttachment !== "platform" &&
|
(options?.publicKey?.authenticatorSelection.authenticatorAttachment !== "platform" &&
|
||||||
browserNativeWebauthnSupport);
|
browserNativeWebauthnSupport);
|
||||||
try {
|
try {
|
||||||
|
const isNotIframe = isNotIframeCheck();
|
||||||
|
|
||||||
const response = await messenger.request(
|
const response = await messenger.request(
|
||||||
{
|
{
|
||||||
type: MessageType.CredentialCreationRequest,
|
type: MessageType.CredentialCreationRequest,
|
||||||
@@ -69,7 +79,7 @@ navigator.credentials.create = async (
|
|||||||
data: WebauthnUtils.mapCredentialCreationOptions(
|
data: WebauthnUtils.mapCredentialCreationOptions(
|
||||||
options,
|
options,
|
||||||
window.location.origin,
|
window.location.origin,
|
||||||
true,
|
isNotIframe,
|
||||||
fallbackSupported
|
fallbackSupported
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -96,6 +106,8 @@ navigator.credentials.get = async (
|
|||||||
): Promise<Credential> => {
|
): Promise<Credential> => {
|
||||||
const fallbackSupported = browserNativeWebauthnSupport;
|
const fallbackSupported = browserNativeWebauthnSupport;
|
||||||
try {
|
try {
|
||||||
|
const isNotIframe = isNotIframeCheck();
|
||||||
|
|
||||||
const response = await messenger.request(
|
const response = await messenger.request(
|
||||||
{
|
{
|
||||||
type: MessageType.CredentialGetRequest,
|
type: MessageType.CredentialGetRequest,
|
||||||
@@ -103,7 +115,7 @@ navigator.credentials.get = async (
|
|||||||
data: WebauthnUtils.mapCredentialRequestOptions(
|
data: WebauthnUtils.mapCredentialRequestOptions(
|
||||||
options,
|
options,
|
||||||
window.location.origin,
|
window.location.origin,
|
||||||
true,
|
isNotIframe,
|
||||||
fallbackSupported
|
fallbackSupported
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user