mirror of
https://github.com/unraid/api.git
synced 2026-05-01 04:31:31 -05:00
010efe75bd
This reverts commit 4ef387b5bb.
16 lines
449 B
TypeScript
16 lines
449 B
TypeScript
import btoa from 'btoa';
|
|
import { promises } from 'fs';
|
|
import { varState } from '../../states';
|
|
|
|
// Get key file
|
|
export const getKeyFile = async function (regFile: string = varState.data.regFile) {
|
|
// Bail if key is missing
|
|
if (regFile.trim() === '') {
|
|
return '';
|
|
}
|
|
|
|
return promises.readFile(regFile, 'binary').then(keyFile => {
|
|
return btoa(keyFile).trim().replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
}).catch(() => '');
|
|
};
|