mirror of
https://github.com/fleetdm/fleet
synced 2026-05-11 19:19:03 +00:00
67 lines
1 KiB
JavaScript
Vendored
67 lines
1 KiB
JavaScript
Vendored
module.exports = {
|
|
|
|
|
|
friendlyName: 'Create license key',
|
|
|
|
|
|
description: '',
|
|
|
|
|
|
inputs: {
|
|
|
|
numberOfHosts: {
|
|
type: 'number',
|
|
required: true,
|
|
},
|
|
|
|
organization: {
|
|
type: 'string',
|
|
required: true,
|
|
},
|
|
|
|
validTo: {
|
|
type: 'number',
|
|
required: true,
|
|
description: 'A JS Timestamp representing when this license will expire.'
|
|
}
|
|
|
|
},
|
|
|
|
|
|
exits: {
|
|
|
|
success: {
|
|
outputType: 'string',
|
|
},
|
|
|
|
},
|
|
|
|
|
|
fn: async function (inputs) {
|
|
|
|
let jwt = require('jsonwebtoken');
|
|
|
|
let token = jwt.sign(
|
|
{
|
|
iss: 'Fleet Device Management Inc.',
|
|
exp: inputs.validTo,
|
|
sub: inputs.organization,
|
|
devices: inputs.numberOfHosts,
|
|
note: 'Created with Fleet License key dispenser',
|
|
tier: 'premium',
|
|
},
|
|
{
|
|
key: sails.config.custom.licenseKeyGeneratorPrivateKey,
|
|
passphrase: sails.config.custom.licenseKeyGeneratorPassphrase
|
|
},
|
|
{ algorithm: 'ES256' }
|
|
);
|
|
|
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|