mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
remove callbackUri input for fixed mobile uri (#1282)
This commit is contained in:
parent
278cf2ca40
commit
5b6fb16591
@ -11,7 +11,8 @@ let btnText: string = null;
|
|||||||
let btnReturnText: string = null;
|
let btnReturnText: string = null;
|
||||||
let parentUrl: string = null;
|
let parentUrl: string = null;
|
||||||
let parentOrigin: string = null;
|
let parentOrigin: string = null;
|
||||||
let callbackUri: string = null;
|
let mobileResponse = false;
|
||||||
|
let mobileCallbackUri = 'bitwarden://webauthn-callback';
|
||||||
let stopWebAuthn = false;
|
let stopWebAuthn = false;
|
||||||
let sentSuccess = false;
|
let sentSuccess = false;
|
||||||
let obj: any = null;
|
let obj: any = null;
|
||||||
@ -75,7 +76,14 @@ function parseParametersV1() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseParametersV2() {
|
function parseParametersV2() {
|
||||||
let dataObj: { data: any, headerText: string; btnText: string; btnReturnText: string; callbackUri?: string } = null;
|
let dataObj: {
|
||||||
|
data: any,
|
||||||
|
headerText: string;
|
||||||
|
btnText: string;
|
||||||
|
btnReturnText: string;
|
||||||
|
callbackUri?: string;
|
||||||
|
mobile?: boolean
|
||||||
|
} = null;
|
||||||
try {
|
try {
|
||||||
dataObj = JSON.parse(b64Decode(getQsParam('data')));
|
dataObj = JSON.parse(b64Decode(getQsParam('data')));
|
||||||
}
|
}
|
||||||
@ -84,7 +92,7 @@ function parseParametersV2() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callbackUri = dataObj.callbackUri;
|
mobileResponse = dataObj.callbackUri != null || dataObj.mobile === true;
|
||||||
webauthnJson = dataObj.data;
|
webauthnJson = dataObj.data;
|
||||||
headerText = dataObj.headerText;
|
headerText = dataObj.headerText;
|
||||||
btnText = dataObj.btnText;
|
btnText = dataObj.btnText;
|
||||||
@ -115,7 +123,7 @@ function start() {
|
|||||||
|
|
||||||
stopWebAuthn = false;
|
stopWebAuthn = false;
|
||||||
|
|
||||||
if (callbackUri != null || (navigator.userAgent.indexOf(' Safari/') !== -1 && navigator.userAgent.indexOf('Chrome') === -1)) {
|
if (mobileResponse || (navigator.userAgent.indexOf(' Safari/') !== -1 && navigator.userAgent.indexOf('Chrome') === -1)) {
|
||||||
// Safari and mobile chrome blocks non-user initiated WebAuthn requests.
|
// Safari and mobile chrome blocks non-user initiated WebAuthn requests.
|
||||||
} else {
|
} else {
|
||||||
executeWebAuthn();
|
executeWebAuthn();
|
||||||
@ -148,9 +156,9 @@ function onMessage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function error(message: string) {
|
function error(message: string) {
|
||||||
if (callbackUri) {
|
if (mobileResponse) {
|
||||||
document.location.replace(callbackUri + '?error=' + encodeURIComponent(message));
|
document.location.replace(mobileCallbackUri + '?error=' + encodeURIComponent(message));
|
||||||
returnButton(callbackUri + '?error=' + encodeURIComponent(message));
|
returnButton(mobileCallbackUri + '?error=' + encodeURIComponent(message));
|
||||||
} else {
|
} else {
|
||||||
parent.postMessage('error|' + message, parentUrl);
|
parent.postMessage('error|' + message, parentUrl);
|
||||||
}
|
}
|
||||||
@ -163,9 +171,9 @@ function success(assertedCredential: PublicKeyCredential) {
|
|||||||
|
|
||||||
const dataString = buildDataString(assertedCredential);
|
const dataString = buildDataString(assertedCredential);
|
||||||
|
|
||||||
if (callbackUri) {
|
if (mobileResponse) {
|
||||||
document.location.replace(callbackUri + '?data=' + encodeURIComponent(dataString));
|
document.location.replace(mobileCallbackUri + '?data=' + encodeURIComponent(dataString));
|
||||||
returnButton(callbackUri + '?data=' + encodeURIComponent(dataString));
|
returnButton(mobileCallbackUri + '?data=' + encodeURIComponent(dataString));
|
||||||
} else {
|
} else {
|
||||||
parent.postMessage('success|' + dataString, parentUrl);
|
parent.postMessage('success|' + dataString, parentUrl);
|
||||||
sentSuccess = true;
|
sentSuccess = true;
|
||||||
@ -173,7 +181,7 @@ function success(assertedCredential: PublicKeyCredential) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function info(message: string) {
|
function info(message: string) {
|
||||||
if (callbackUri) {
|
if (mobileResponse) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user