@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
194 lines • 7.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_DIRRecord = exports._decode_DIRRecord = exports._extension_additions_list_spec_for_DIRRecord = exports._root_component_type_list_2_spec_for_DIRRecord = exports._root_component_type_list_1_spec_for_DIRRecord = exports.DIRRecord = exports._encode_DDO = exports._decode_DDO = exports.DDO = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const DDO_ta_1 = require("../PKCS-15/DDO.ta");
var DDO_ta_2 = require("../PKCS-15/DDO.ta");
Object.defineProperty(exports, "DDO", { enumerable: true, get: function () { return DDO_ta_2.DDO; } });
Object.defineProperty(exports, "_decode_DDO", { enumerable: true, get: function () { return DDO_ta_2._decode_DDO; } });
Object.defineProperty(exports, "_encode_DDO", { enumerable: true, get: function () { return DDO_ta_2._encode_DDO; } });
/* START_OF_SYMBOL_DEFINITION DIRRecord */
/**
* @summary DIRRecord
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* DIRRecord ::= [APPLICATION 1] SEQUENCE {
* aid [APPLICATION 15] OCTET STRING,
* label [APPLICATION 16] UTF8String OPTIONAL,
* path [APPLICATION 17] OCTET STRING,
* ddo [APPLICATION 19] DDO OPTIONAL
* }
* ```
*
* @class
*/
class DIRRecord {
constructor(
/**
* @summary `aid`.
* @public
* @readonly
*/
aid,
/**
* @summary `label`.
* @public
* @readonly
*/
label,
/**
* @summary `path`.
* @public
* @readonly
*/
path,
/**
* @summary `ddo`.
* @public
* @readonly
*/
ddo) {
this.aid = aid;
this.label = label;
this.path = path;
this.ddo = ddo;
}
/**
* @summary Restructures an object into a DIRRecord
* @description
*
* This takes an `object` and converts it to a `DIRRecord`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `DIRRecord`.
* @returns {DIRRecord}
*/
static _from_object(_o) {
return new DIRRecord(_o.aid, _o.label, _o.path, _o.ddo);
}
}
exports.DIRRecord = DIRRecord;
/* END_OF_SYMBOL_DEFINITION DIRRecord */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_DIRRecord */
/**
* @summary The Leading Root Component Types of DIRRecord
* @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_DIRRecord = [
new $.ComponentSpec("aid", false, $.hasTag(asn1_ts_1.ASN1TagClass.application, 15), undefined, undefined),
new $.ComponentSpec("label", true, $.hasTag(asn1_ts_1.ASN1TagClass.application, 16), undefined, undefined),
new $.ComponentSpec("path", false, $.hasTag(asn1_ts_1.ASN1TagClass.application, 17), undefined, undefined),
new $.ComponentSpec("ddo", true, $.hasTag(asn1_ts_1.ASN1TagClass.application, 19), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_DIRRecord */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_DIRRecord */
/**
* @summary The Trailing Root Component Types of DIRRecord
* @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_DIRRecord = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_DIRRecord */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_DIRRecord */
/**
* @summary The Extension Addition Component Types of DIRRecord
* @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_DIRRecord = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_DIRRecord */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_DIRRecord */
let _cached_decoder_for_DIRRecord = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_DIRRecord */
/* START_OF_SYMBOL_DEFINITION _decode_DIRRecord */
/**
* @summary Decodes an ASN.1 element into a(n) DIRRecord
* @function
* @param {_Element} el The element being decoded.
* @returns {DIRRecord} The decoded data structure.
*/
function _decode_DIRRecord(el) {
if (!_cached_decoder_for_DIRRecord) {
_cached_decoder_for_DIRRecord = $._decode_implicit(() => function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let aid;
let label;
let path;
let ddo;
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
aid: (_el) => {
aid = $._decode_implicit(() => $._decodeOctetString)(_el);
},
label: (_el) => {
label = $._decode_implicit(() => $._decodeUTF8String)(_el);
},
path: (_el) => {
path = $._decode_implicit(() => $._decodeOctetString)(_el);
},
ddo: (_el) => {
ddo = $._decode_implicit(() => DDO_ta_1._decode_DDO)(_el);
},
};
/* END_OF_CALLBACKS_MAP */
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_DIRRecord, exports._extension_additions_list_spec_for_DIRRecord, exports._root_component_type_list_2_spec_for_DIRRecord, undefined);
return new DIRRecord(
/* SEQUENCE_CONSTRUCTOR_CALL */ aid, label, path, ddo);
});
}
return _cached_decoder_for_DIRRecord(el);
}
exports._decode_DIRRecord = _decode_DIRRecord;
/* END_OF_SYMBOL_DEFINITION _decode_DIRRecord */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_DIRRecord */
let _cached_encoder_for_DIRRecord = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_DIRRecord */
/* START_OF_SYMBOL_DEFINITION _encode_DIRRecord */
/**
* @summary Encodes a(n) DIRRecord 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 DIRRecord, encoded as an ASN.1 Element.
*/
function _encode_DIRRecord(value, elGetter) {
if (!_cached_encoder_for_DIRRecord) {
_cached_encoder_for_DIRRecord = $._encode_implicit(asn1_ts_1.ASN1TagClass.application, 1, () => function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ $._encode_implicit(asn1_ts_1.ASN1TagClass.application, 15, () => $._encodeOctetString, $.BER)(value.aid, $.BER),
/* IF_ABSENT */ value.label === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.application, 16, () => $._encodeUTF8String, $.BER)(value.label, $.BER),
/* REQUIRED */ $._encode_implicit(asn1_ts_1.ASN1TagClass.application, 17, () => $._encodeOctetString, $.BER)(value.path, $.BER),
/* IF_ABSENT */ value.ddo === undefined
? undefined
: $._encode_implicit(asn1_ts_1.ASN1TagClass.application, 19, () => DDO_ta_1._encode_DDO, $.BER)(value.ddo, $.BER),
])
.filter((c) => !!c), $.BER);
}, $.BER);
}
return _cached_encoder_for_DIRRecord(value, elGetter);
}
exports._encode_DIRRecord = _encode_DIRRecord;
/* END_OF_SYMBOL_DEFINITION _encode_DIRRecord */
/* eslint-enable */
//# sourceMappingURL=DIRRecord.ta.js.map