pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
64 lines • 3.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_Attribute = exports._decode_Attribute = exports._extension_additions_list_spec_for_Attribute = exports._root_component_type_list_2_spec_for_Attribute = exports._root_component_type_list_1_spec_for_Attribute = exports.Attribute = exports._encode_AttributeValue = exports._decode_AttributeValue = void 0;
const tslib_1 = require("tslib");
const asn1_ts_1 = require("asn1-ts");
const $ = tslib_1.__importStar(require("asn1-ts/dist/node/functional"));
const AttributeValue_ta_1 = require("../CryptographicMessageSyntax/AttributeValue.ta");
var AttributeValue_ta_2 = require("../CryptographicMessageSyntax/AttributeValue.ta");
Object.defineProperty(exports, "_decode_AttributeValue", { enumerable: true, get: function () { return AttributeValue_ta_2._decode_AttributeValue; } });
Object.defineProperty(exports, "_encode_AttributeValue", { enumerable: true, get: function () { return AttributeValue_ta_2._encode_AttributeValue; } });
class Attribute {
constructor(attrType, attrValues) {
this.attrType = attrType;
this.attrValues = attrValues;
}
static _from_object(_o) {
return new Attribute(_o.attrType, _o.attrValues);
}
}
exports.Attribute = Attribute;
exports._root_component_type_list_1_spec_for_Attribute = [
new $.ComponentSpec("attrType", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined),
new $.ComponentSpec("attrValues", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined),
];
exports._root_component_type_list_2_spec_for_Attribute = [];
exports._extension_additions_list_spec_for_Attribute = [];
let _cached_decoder_for_Attribute = null;
function _decode_Attribute(el) {
if (!_cached_decoder_for_Attribute) {
_cached_decoder_for_Attribute = function (el) {
const sequence = el.sequence;
if (sequence.length < 2) {
throw new asn1_ts_1.ASN1ConstructionError("Attribute contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "attrType";
sequence[1].name = "attrValues";
let attrType;
let attrValues;
attrType = $._decodeObjectIdentifier(sequence[0]);
attrValues = $._decodeSetOf(() => AttributeValue_ta_1._decode_AttributeValue)(sequence[1]);
return new Attribute(attrType, attrValues);
};
}
return _cached_decoder_for_Attribute(el);
}
exports._decode_Attribute = _decode_Attribute;
let _cached_encoder_for_Attribute = null;
function _encode_Attribute(value, elGetter) {
if (!_cached_encoder_for_Attribute) {
_cached_encoder_for_Attribute = function (value, elGetter) {
return $._encodeSequence([]
.concat([
$._encodeObjectIdentifier(value.attrType, $.BER),
$._encodeSetOf(() => AttributeValue_ta_1._encode_AttributeValue, $.BER)(value.attrValues, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_Attribute(value, elGetter);
}
exports._encode_Attribute = _encode_Attribute;
//# sourceMappingURL=Attribute.ta.js.map