Verify token before return
Summary: If the token has already expired, generate another one. Reviewed By: aigoncharov Differential Revision: D50410431 fbshipit-source-id: 108a3b344a1bcafd93a8d9bc94cba5c133d099d7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f10ea61ffc
commit
8b24560bc0
@@ -338,6 +338,17 @@ export const getAuthToken = async (): Promise<string> => {
|
||||
}
|
||||
|
||||
const token = await fs.readFile(serverAuthToken);
|
||||
|
||||
try {
|
||||
console.info('Verify authentication token');
|
||||
const serverCertificate = await fs.readFile(serverCert);
|
||||
jwt.verify(token.toString(), serverCertificate);
|
||||
console.info('Token verification succeeded');
|
||||
} catch (_) {
|
||||
console.warn('Either token has expired or is invalid');
|
||||
return generateAuthToken();
|
||||
}
|
||||
|
||||
return token.toString();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user