UNPKG

@authup/server-api

Version:

This is a standalone application.

31 lines 1.14 kB
"use strict"; /* * Copyright (c) 2022-2022. * Author Peter Placzek (tada5hi) * For the full copyright and license information, * view the LICENSE file that was distributed with this source code. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.signOAuth2TokenWithKey = void 0; const server_core_1 = require("@authup/server-core"); const core_1 = require("@authup/core"); async function signOAuth2TokenWithKey(payload, entity, options) { if (entity.type === core_1.KeyType.OCT) { return (0, server_core_1.signToken)(payload, { type: core_1.KeyType.OCT, secret: Buffer.from(entity.decryption_key, 'base64'), ...options, }); } return (0, server_core_1.signToken)(payload, { type: entity.type, keyPair: { publicKey: (0, core_1.wrapPublicKeyPem)(entity.encryption_key), privateKey: (0, core_1.wrapPrivateKeyPem)(entity.decryption_key), }, algorithm: entity.signature_algorithm, ...options, }); } exports.signOAuth2TokenWithKey = signOAuth2TokenWithKey; //# sourceMappingURL=sign.js.map