pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
60 lines • 2.91 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_CredentialIdentifier = exports._decode_CredentialIdentifier = exports._extension_additions_list_spec_for_CredentialIdentifier = exports._root_component_type_list_2_spec_for_CredentialIdentifier = exports._root_component_type_list_1_spec_for_CredentialIdentifier = exports.CredentialIdentifier = void 0;
const tslib_1 = require("tslib");
const asn1_ts_1 = require("asn1-ts");
const $ = tslib_1.__importStar(require("asn1-ts/dist/node/functional"));
class CredentialIdentifier {
constructor(idType, idValue) {
this.idType = idType;
this.idValue = idValue;
}
static _from_object(_o) {
return new CredentialIdentifier(_o.idType, _o.idValue);
}
}
exports.CredentialIdentifier = CredentialIdentifier;
exports._root_component_type_list_1_spec_for_CredentialIdentifier = [
new $.ComponentSpec("idType", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("idValue", false, $.hasAnyTag, undefined, undefined),
];
exports._root_component_type_list_2_spec_for_CredentialIdentifier = [];
exports._extension_additions_list_spec_for_CredentialIdentifier = [];
let _cached_decoder_for_CredentialIdentifier = null;
function _decode_CredentialIdentifier(el) {
if (!_cached_decoder_for_CredentialIdentifier) {
_cached_decoder_for_CredentialIdentifier = function (el) {
const sequence = el.sequence;
if (sequence.length < 2) {
throw new asn1_ts_1.ASN1ConstructionError("CredentialIdentifier contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "idType";
sequence[1].name = "idValue";
let idType;
let idValue;
idType = $._decodeInteger(sequence[0]);
idValue = $._decodeAny(sequence[1]);
return new CredentialIdentifier(idType, idValue);
};
}
return _cached_decoder_for_CredentialIdentifier(el);
}
exports._decode_CredentialIdentifier = _decode_CredentialIdentifier;
let _cached_encoder_for_CredentialIdentifier = null;
function _encode_CredentialIdentifier(value, elGetter) {
if (!_cached_encoder_for_CredentialIdentifier) {
_cached_encoder_for_CredentialIdentifier = function (value, elGetter) {
return $._encodeSequence([]
.concat([
$._encodeInteger(value.idType, $.BER),
$._encodeAny(value.idValue, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_CredentialIdentifier(value, elGetter);
}
exports._encode_CredentialIdentifier = _encode_CredentialIdentifier;
//# sourceMappingURL=CredentialIdentifier.ta.js.map