pkcs-ts
Version:
PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More
72 lines • 4.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._get_encoder_for_PKCS15Object = exports._get_decoder_for_PKCS15Object = exports._extension_additions_list_spec_for_PKCS15Object = exports._root_component_type_list_2_spec_for_PKCS15Object = exports._root_component_type_list_1_spec_for_PKCS15Object = exports.PKCS15Object = exports._encode_CommonObjectAttributes = exports._decode_CommonObjectAttributes = exports.CommonObjectAttributes = 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 CommonObjectAttributes_ta_1 = require("../PKCS-15/CommonObjectAttributes.ta");
var CommonObjectAttributes_ta_2 = require("../PKCS-15/CommonObjectAttributes.ta");
Object.defineProperty(exports, "CommonObjectAttributes", { enumerable: true, get: function () { return CommonObjectAttributes_ta_2.CommonObjectAttributes; } });
Object.defineProperty(exports, "_decode_CommonObjectAttributes", { enumerable: true, get: function () { return CommonObjectAttributes_ta_2._decode_CommonObjectAttributes; } });
Object.defineProperty(exports, "_encode_CommonObjectAttributes", { enumerable: true, get: function () { return CommonObjectAttributes_ta_2._encode_CommonObjectAttributes; } });
class PKCS15Object {
constructor(commonObjectAttributes, classAttributes, subClassAttributes, typeAttributes) {
this.commonObjectAttributes = commonObjectAttributes;
this.classAttributes = classAttributes;
this.subClassAttributes = subClassAttributes;
this.typeAttributes = typeAttributes;
}
static _from_object(_o) {
return new PKCS15Object(_o.commonObjectAttributes, _o.classAttributes, _o.subClassAttributes, _o.typeAttributes);
}
}
exports.PKCS15Object = PKCS15Object;
exports._root_component_type_list_1_spec_for_PKCS15Object = [
new $.ComponentSpec("commonObjectAttributes", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
new $.ComponentSpec("classAttributes", false, $.hasAnyTag, undefined, undefined),
new $.ComponentSpec("subClassAttributes", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined),
new $.ComponentSpec("typeAttributes", false, $.hasTag(asn1_ts_1.ASN1TagClass.context, 1), undefined, undefined),
];
exports._root_component_type_list_2_spec_for_PKCS15Object = [];
exports._extension_additions_list_spec_for_PKCS15Object = [];
function _get_decoder_for_PKCS15Object(_decode_ClassAttributes, _decode_SubClassAttributes, _decode_TypeAttributes) {
return function (el) {
let commonObjectAttributes;
let classAttributes;
let subClassAttributes;
let typeAttributes;
const callbacks = {
commonObjectAttributes: (_el) => {
commonObjectAttributes = CommonObjectAttributes_ta_1._decode_CommonObjectAttributes(_el);
},
classAttributes: (_el) => {
classAttributes = _decode_ClassAttributes(_el);
},
subClassAttributes: (_el) => {
subClassAttributes = $._decode_implicit(() => _decode_SubClassAttributes)(_el);
},
typeAttributes: (_el) => {
typeAttributes = $._decode_implicit(() => _decode_TypeAttributes)(_el);
},
};
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_PKCS15Object, exports._extension_additions_list_spec_for_PKCS15Object, exports._root_component_type_list_2_spec_for_PKCS15Object, undefined);
return new PKCS15Object(commonObjectAttributes, classAttributes, subClassAttributes, typeAttributes);
};
}
exports._get_decoder_for_PKCS15Object = _get_decoder_for_PKCS15Object;
function _get_encoder_for_PKCS15Object(_encode_ClassAttributes, _encode_SubClassAttributes, _encode_TypeAttributes) {
return function (value, elGetter) {
return $._encodeSequence([]
.concat([
CommonObjectAttributes_ta_1._encode_CommonObjectAttributes(value.commonObjectAttributes, $.BER),
_encode_ClassAttributes(value.classAttributes, $.BER),
value.subClassAttributes === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => _encode_SubClassAttributes, $.BER)(value.subClassAttributes, $.BER),
$._encode_implicit(asn1_ts_1.ASN1TagClass.context, 1, () => _encode_TypeAttributes, $.BER)(value.typeAttributes, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
exports._get_encoder_for_PKCS15Object = _get_encoder_for_PKCS15Object;
//# sourceMappingURL=PKCS15Object.ta.js.map