mirror of
https://github.com/linuxserver/gclient.git
synced 2026-02-20 02:54:19 +08:00
24 lines
631 B
JavaScript
24 lines
631 B
JavaScript
const { clientOptions, connectionOptions } = require('./options');
|
|
const { encrypt, deepMerge } = require('./utils');
|
|
|
|
const makeToken = (credentials) => {
|
|
if (!('username' in credentials)) {
|
|
throw new Error('credential is missing `username`');
|
|
}
|
|
|
|
if (!('password' in credentials)) {
|
|
throw new Error('credential is missing `password`');
|
|
}
|
|
|
|
return encrypt(deepMerge(connectionOptions, {
|
|
connection: {
|
|
settings: {
|
|
username: credentials.username,
|
|
password: credentials.password,
|
|
},
|
|
},
|
|
}), clientOptions.crypt.cypher, clientOptions.crypt.key);
|
|
};
|
|
|
|
exports.makeToken = makeToken;
|