Export to manifest on get
Summary: Every time the token is returned, export it to the manifest. This covers the case in which the token found in the manifest has already expired. Reviewed By: antonk52 Differential Revision: D50419458 fbshipit-source-id: 8eefa0e97e234985b34f824190b208bf74e2d8ec
This commit is contained in:
committed by
Facebook GitHub Bot
parent
82f0c0eb9e
commit
f6de499171
@@ -332,6 +332,18 @@ export const generateAuthToken = async () => {
|
|||||||
return token;
|
return token;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the client authentication token. If there is no existing token,
|
||||||
|
* it generates one, export it to the manifest file and returns it.
|
||||||
|
*
|
||||||
|
* Additionally, it must check the token's validity before returning it.
|
||||||
|
* If the token is invalid, it regenerates it and exports it to the manifest file.
|
||||||
|
*
|
||||||
|
* Finally, the token is also exported to the manifest, on every get as to
|
||||||
|
* ensure it is always up to date.
|
||||||
|
*
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export const getAuthToken = async (): Promise<string> => {
|
export const getAuthToken = async (): Promise<string> => {
|
||||||
if (!(await hasAuthToken())) {
|
if (!(await hasAuthToken())) {
|
||||||
return generateAuthToken();
|
return generateAuthToken();
|
||||||
@@ -349,6 +361,12 @@ export const getAuthToken = async (): Promise<string> => {
|
|||||||
return generateAuthToken();
|
return generateAuthToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const config = getFlipperServerConfig();
|
||||||
|
if (config.environmentInfo.isHeadlessBuild) {
|
||||||
|
console.info('Token exported to manifest');
|
||||||
|
await exportTokenToManifest(config, token.toString());
|
||||||
|
}
|
||||||
|
|
||||||
return token.toString();
|
return token.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user