@microsoft/useragent-sdk
Version:
SDK for building decentralized identity wallets and enterprise agents.
40 lines • 1.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const typescript_map_1 = require("typescript-map");
const JoseConstants_1 = require("./JoseConstants");
const JoseProtocol_1 = require("./JoseProtocol");
const CryptoProtocolError_1 = require("../CryptoProtocolError");
/**
* Class to model JOSE tokens
*/
class JoseToken extends typescript_map_1.TSMap {
constructor(payloadProtectionProtocolOptions, payloadProtection, inputMap) {
super(inputMap);
this.payloadProtectionProtocolOptions = payloadProtectionProtocolOptions;
this.payloadProtection = payloadProtection || new JoseProtocol_1.default();
}
/**
* get the format of the crypto token
*/
tokenFormat() {
let format = this.get(JoseConstants_1.default.tokenFormat);
if (!format) {
throw new CryptoProtocolError_1.default('JOSE', `The token format is not found`);
}
return format.toString();
}
/**
* Serialize a a @interface ICryptoToken
*/
serialize() {
return this.payloadProtection.serialize(this, this.tokenFormat(), this.payloadProtectionProtocolOptions);
}
/**
* Convert token to json
*/
toJson() {
this.toJSON();
}
}
exports.default = JoseToken;
//# sourceMappingURL=JoseToken.js.map