Embed auth token into HTML
Summary: Auth token used be injected in the manifest file. Instead, have the server injected into the main HTML page. The main driver to this change are: - Simplify - There are instances in which for some reason reading/writing the token from the manifest fails. This will address that problem. Reviewed By: lblasa Differential Revision: D51160521 fbshipit-source-id: 4626fd8f56bc8b61182a53a5d9cf5acad1e723bc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
69378c4b09
commit
8ef29c8160
@@ -22,6 +22,7 @@ declare global {
|
||||
FLIPPER_APP_VERSION: string;
|
||||
FLIPPER_SESSION_ID: string;
|
||||
FLIPPER_UNIXNAME: string;
|
||||
FLIPPER_AUTH_TOKEN: string;
|
||||
|
||||
flipperShowMessage?(message: string): void;
|
||||
flipperHideMessage?(): void;
|
||||
|
||||
@@ -55,17 +55,12 @@ async function start() {
|
||||
const providerParams = new URL(location.href).searchParams;
|
||||
let token = providerParams.get('token');
|
||||
if (!token) {
|
||||
console.info(
|
||||
'[flipper-client][ui-browser] Get token from manifest instead',
|
||||
);
|
||||
try {
|
||||
const manifestResponse = await fetch('manifest.json');
|
||||
const manifest = await manifestResponse.json();
|
||||
token = manifest.token;
|
||||
} catch (e) {
|
||||
console.info('[flipper-client][ui-browser] Get token from HTML instead');
|
||||
token = window.FLIPPER_AUTH_TOKEN;
|
||||
if (!token || token === 'FLIPPER_AUTH_TOKEN_REPLACE_ME') {
|
||||
console.warn(
|
||||
'[flipper-client][ui-browser] Failed to get token from manifest. Error:',
|
||||
e.message,
|
||||
'[flipper-client][ui-browser] Failed to get token from HTML',
|
||||
token,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -73,6 +68,7 @@ async function start() {
|
||||
getLogger().info(
|
||||
'[flipper-client][ui-browser] Token is available: ',
|
||||
token?.length != 0,
|
||||
token?.length === 460,
|
||||
);
|
||||
|
||||
return token;
|
||||
|
||||
Reference in New Issue
Block a user