UNPKG

xiot-core-spec-ts

Version:
27 lines (26 loc) 853 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.JwtEsImplCodec = void 0; const JwtEsImpl_1 = require("../../../typedef/jwt/impl/JwtEsImpl"); const Jwt_1 = require("../../../typedef/jwt/Jwt"); class JwtEsImplCodec { static encode(x) { const o = { 'public-key': x.publicKey, 'private-key': x.privateKey, }; if (x.expiresInSeconds > 0) { o.expiresInSeconds = x.expiresInSeconds; } if (x.algorithm !== Jwt_1.DEFAULT_ES_SIGNATURE_ALGORITHM) { o.algorithm = x.algorithm; } return o; } static decode(o) { const publicKey = o['public-key']; const privateKey = o['private-key']; return new JwtEsImpl_1.JwtEsImpl(publicKey, privateKey); } } exports.JwtEsImplCodec = JwtEsImplCodec;