@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
178 lines • 8.02 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;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = 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; } });
/* START_OF_SYMBOL_DEFINITION PKCS15Object */
/**
* @summary PKCS15Object
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* PKCS15Object {ClassAttributes, SubClassAttributes, TypeAttributes} ::= SEQUENCE {
* commonObjectAttributes CommonObjectAttributes,
* classAttributes ClassAttributes,
* subClassAttributes [0] SubClassAttributes OPTIONAL,
* typeAttributes [1] TypeAttributes
* }
* ```
*
* @class
*/
class PKCS15Object {
constructor(
/**
* @summary `commonObjectAttributes`.
* @public
* @readonly
*/
commonObjectAttributes,
/**
* @summary `classAttributes`.
* @public
* @readonly
*/
classAttributes,
/**
* @summary `subClassAttributes`.
* @public
* @readonly
*/
subClassAttributes,
/**
* @summary `typeAttributes`.
* @public
* @readonly
*/
typeAttributes) {
this.commonObjectAttributes = commonObjectAttributes;
this.classAttributes = classAttributes;
this.subClassAttributes = subClassAttributes;
this.typeAttributes = typeAttributes;
}
/**
* @summary Restructures an object into a PKCS15Object
* @description
*
* This takes an `object` and converts it to a `PKCS15Object`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `PKCS15Object`.
* @returns {PKCS15Object}
*/
static _from_object(_o) {
return new PKCS15Object(_o.commonObjectAttributes, _o.classAttributes, _o.subClassAttributes, _o.typeAttributes);
}
}
exports.PKCS15Object = PKCS15Object;
/* END_OF_SYMBOL_DEFINITION PKCS15Object */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PKCS15Object */
/**
* @summary The Leading Root Component Types of PKCS15Object
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE.
*
* @constant
*/
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),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PKCS15Object */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PKCS15Object */
/**
* @summary The Trailing Root Component Types of PKCS15Object
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE.
*
* @constant
*/
exports._root_component_type_list_2_spec_for_PKCS15Object = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PKCS15Object */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PKCS15Object */
/**
* @summary The Extension Addition Component Types of PKCS15Object
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE.
*
* @constant
*/
exports._extension_additions_list_spec_for_PKCS15Object = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PKCS15Object */
/* START_OF_SYMBOL_DEFINITION _get_decoder_for_PKCS15Object */
/**
* @summary Returns a function that will decode an ASN.1 element into a(n) PKCS15Object
* @function
* @param {_Element} el The element being decoded.
* @returns A function that will decode an ASN.1 element.
*/
function _get_decoder_for_PKCS15Object(_decode_ClassAttributes, _decode_SubClassAttributes, _decode_TypeAttributes) {
return function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let commonObjectAttributes;
let classAttributes;
let subClassAttributes;
let typeAttributes;
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
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);
},
};
/* END_OF_CALLBACKS_MAP */
$._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(
/* SEQUENCE_CONSTRUCTOR_CALL */ commonObjectAttributes, classAttributes, subClassAttributes, typeAttributes);
};
}
exports._get_decoder_for_PKCS15Object = _get_decoder_for_PKCS15Object;
/* END_OF_SYMBOL_DEFINITION _get_decoder_for_PKCS15Object */
/* START_OF_SYMBOL_DEFINITION _get_encoder_for_PKCS15Object */
/**
* @summary Returns a function that will encode a(n) PKCS15Object into an ASN.1 Element.
* @function
* @returns A function that will encode a(n) PKCS15Object as an ASN.1 element.
*/
function _get_encoder_for_PKCS15Object(_encode_ClassAttributes, _encode_SubClassAttributes, _encode_TypeAttributes) {
return function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ CommonObjectAttributes_ta_1._encode_CommonObjectAttributes(value.commonObjectAttributes, $.BER),
/* REQUIRED */ _encode_ClassAttributes(value.classAttributes, $.BER),
/* IF_ABSENT */ value.subClassAttributes === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => _encode_SubClassAttributes, $.BER)(value.subClassAttributes, $.BER),
/* REQUIRED */ $._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;
/* END_OF_SYMBOL_DEFINITION _get_encoder_for_PKCS15Object */
/* eslint-enable */
//# sourceMappingURL=PKCS15Object.ta.js.map