UNPKG

@foal/jwt

Version:

Authentication with JWT for FoalTS

22 lines (21 loc) 830 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getSecretOrPublicKey = void 0; const core_1 = require("@foal/core"); function getSecretOrPublicKey() { const secret = core_1.Config.get('settings.jwt.secret', 'string'); if (secret) { const secretEncoding = core_1.Config.get('settings.jwt.secretEncoding', 'string'); if (secretEncoding) { return Buffer.from(secret, secretEncoding); } return secret; } const publicKey = core_1.Config.get('settings.jwt.publicKey', 'string'); if (publicKey) { return publicKey; } throw new Error('[CONFIG] You must provide at least one of these configuration keys: ' + 'settings.jwt.secret or settings.jwt.publicKey.'); } exports.getSecretOrPublicKey = getSecretOrPublicKey;