@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
153 lines • 5.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_PKCS12Attribute = exports._decode_PKCS12Attribute = exports._extension_additions_list_spec_for_PKCS12Attribute = exports._root_component_type_list_2_spec_for_PKCS12Attribute = exports._root_component_type_list_1_spec_for_PKCS12Attribute = exports.PKCS12Attribute = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
/* START_OF_SYMBOL_DEFINITION PKCS12Attribute */
/**
* @summary PKCS12Attribute
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* PKCS12Attribute ::= SEQUENCE {
* attrId ATTRIBUTE.&id ({PKCS12AttrSet}),
* attrValues SET OF ATTRIBUTE.&Type ({PKCS12AttrSet}{@attrId})
* }
* ```
*
* @class
*/
class PKCS12Attribute {
constructor(
/**
* @summary `attrId`.
* @public
* @readonly
*/
attrId,
/**
* @summary `attrValues`.
* @public
* @readonly
*/
attrValues) {
this.attrId = attrId;
this.attrValues = attrValues;
}
/**
* @summary Restructures an object into a PKCS12Attribute
* @description
*
* This takes an `object` and converts it to a `PKCS12Attribute`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `PKCS12Attribute`.
* @returns {PKCS12Attribute}
*/
static _from_object(_o) {
return new PKCS12Attribute(_o.attrId, _o.attrValues);
}
}
exports.PKCS12Attribute = PKCS12Attribute;
/* END_OF_SYMBOL_DEFINITION PKCS12Attribute */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PKCS12Attribute */
/**
* @summary The Leading Root Component Types of PKCS12Attribute
* @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_PKCS12Attribute = [
new $.ComponentSpec("attrId", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 6), undefined, undefined),
new $.ComponentSpec("attrValues", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 17), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_PKCS12Attribute */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PKCS12Attribute */
/**
* @summary The Trailing Root Component Types of PKCS12Attribute
* @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_PKCS12Attribute = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_PKCS12Attribute */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PKCS12Attribute */
/**
* @summary The Extension Addition Component Types of PKCS12Attribute
* @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_PKCS12Attribute = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_PKCS12Attribute */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_PKCS12Attribute */
let _cached_decoder_for_PKCS12Attribute = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_PKCS12Attribute */
/* START_OF_SYMBOL_DEFINITION _decode_PKCS12Attribute */
/**
* @summary Decodes an ASN.1 element into a(n) PKCS12Attribute
* @function
* @param {_Element} el The element being decoded.
* @returns {PKCS12Attribute} The decoded data structure.
*/
function _decode_PKCS12Attribute(el) {
if (!_cached_decoder_for_PKCS12Attribute) {
_cached_decoder_for_PKCS12Attribute = function (el) {
const sequence = el.sequence;
if (sequence.length < 2) {
throw new asn1_ts_1.ASN1ConstructionError("PKCS12Attribute contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "attrId";
sequence[1].name = "attrValues";
let attrId;
let attrValues;
attrId = $._decodeObjectIdentifier(sequence[0]);
attrValues = $._decodeSetOf(() => $._decodeAny)(sequence[1]);
return new PKCS12Attribute(attrId, attrValues);
};
}
return _cached_decoder_for_PKCS12Attribute(el);
}
exports._decode_PKCS12Attribute = _decode_PKCS12Attribute;
/* END_OF_SYMBOL_DEFINITION _decode_PKCS12Attribute */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_PKCS12Attribute */
let _cached_encoder_for_PKCS12Attribute = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_PKCS12Attribute */
/* START_OF_SYMBOL_DEFINITION _encode_PKCS12Attribute */
/**
* @summary Encodes a(n) PKCS12Attribute into an ASN.1 Element.
* @function
* @param {value} el The element being decoded.
* @param elGetter A function that can be used to get new ASN.1 elements.
* @returns {_Element} The PKCS12Attribute, encoded as an ASN.1 Element.
*/
function _encode_PKCS12Attribute(value, elGetter) {
if (!_cached_encoder_for_PKCS12Attribute) {
_cached_encoder_for_PKCS12Attribute = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ $._encodeObjectIdentifier(value.attrId, $.BER),
/* REQUIRED */ $._encodeSetOf(() => $._encodeAny, $.BER)(value.attrValues, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_PKCS12Attribute(value, elGetter);
}
exports._encode_PKCS12Attribute = _encode_PKCS12Attribute;
/* END_OF_SYMBOL_DEFINITION _encode_PKCS12Attribute */
/* eslint-enable */
//# sourceMappingURL=PKCS12Attribute.ta.js.map