UNPKG

xiot-core-spec-ts

Version:
27 lines (26 loc) 862 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.JwtRsaImplCodec = void 0; const JwtRsaImpl_1 = require("../../../typedef/jwt/impl/JwtRsaImpl"); const Jwt_1 = require("../../../typedef/jwt/Jwt"); class JwtRsaImplCodec { 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_RSA_SIGNATURE_ALGORITHM) { o.algorithm = x.algorithm; } return o; } static decode(o) { const publicKey = o['public-key']; const privateKey = o['private-key']; return new JwtRsaImpl_1.JwtRsaImpl(publicKey, privateKey); } } exports.JwtRsaImplCodec = JwtRsaImplCodec;