mirror of
https://github.com/unraid/api.git
synced 2026-04-28 03:01:12 -05:00
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(() => '');
|
|
};
|