UNPKG

@oada/certs

Version:

Generate and verify JWT signatures (OAuth dynamic client registration certificates and Trellis document integrity signatures) in the Open Ag Data Alliance (OADA) and Trellis ecosystems

37 lines 1.39 kB
"use strict"; /** * @license * Copyright 2022 Qlever LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.pubFromPriv = exports.create = void 0; const node_jose_1 = require("node-jose"); const uuid_1 = require("uuid"); async function create() { const k = await node_jose_1.JWK.createKey('RSA', 2048, { kid: (0, uuid_1.v4)().replace(/-/g, ''), }); // Assign a random string ID (I don't like the dashes in uuids) return { public: k.toJSON(), private: k.toJSON(true), }; } exports.create = create; async function pubFromPriv(...parameters) { const k = await node_jose_1.JWK.asKey(...parameters); return k.toJSON(); // If you don't pass true to this function, you get back just the public key } exports.pubFromPriv = pubFromPriv; //# sourceMappingURL=keys.js.map