@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
230 lines • 9.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_CommonObjectAttributes = exports._decode_CommonObjectAttributes = exports._extension_additions_list_spec_for_CommonObjectAttributes = exports._root_component_type_list_2_spec_for_CommonObjectAttributes = exports._root_component_type_list_1_spec_for_CommonObjectAttributes = exports.CommonObjectAttributes = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const AccessControlRule_ta_1 = require("../PKCS-15/AccessControlRule.ta");
const CommonObjectFlags_ta_1 = require("../PKCS-15/CommonObjectFlags.ta");
const Identifier_ta_1 = require("../PKCS-15/Identifier.ta");
const Label_ta_1 = require("../PKCS-15/Label.ta");
/* START_OF_SYMBOL_DEFINITION CommonObjectAttributes */
/**
* @summary CommonObjectAttributes
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* CommonObjectAttributes ::= SEQUENCE {
* label Label OPTIONAL,
* flags CommonObjectFlags OPTIONAL,
* authId Identifier OPTIONAL,
* ...,
* userConsent INTEGER (1..pkcs15-ub-userConsent) OPTIONAL,
* accessControlRules SEQUENCE SIZE (1..MAX) OF AccessControlRule OPTIONAL
* } (CONSTRAINED BY {-- authId should be present in the IC card case if flags.private is set.
* -- It must equal an authID in one AuthRecord in the AODF -- })
* ```
*
* @class
*/
class CommonObjectAttributes {
constructor(
/**
* @summary `label`.
* @public
* @readonly
*/
label,
/**
* @summary `flags`.
* @public
* @readonly
*/
flags,
/**
* @summary `authId`.
* @public
* @readonly
*/
authId,
/**
* @summary `userConsent`.
* @public
* @readonly
*/
userConsent,
/**
* @summary `accessControlRules`.
* @public
* @readonly
*/
accessControlRules,
/**
* @summary Extensions that are not recognized.
* @public
* @readonly
*/
_unrecognizedExtensionsList = []) {
this.label = label;
this.flags = flags;
this.authId = authId;
this.userConsent = userConsent;
this.accessControlRules = accessControlRules;
this._unrecognizedExtensionsList = _unrecognizedExtensionsList;
}
/**
* @summary Restructures an object into a CommonObjectAttributes
* @description
*
* This takes an `object` and converts it to a `CommonObjectAttributes`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `CommonObjectAttributes`.
* @returns {CommonObjectAttributes}
*/
static _from_object(_o) {
return new CommonObjectAttributes(_o.label, _o.flags, _o.authId, _o.userConsent, _o.accessControlRules, _o._unrecognizedExtensionsList);
}
}
exports.CommonObjectAttributes = CommonObjectAttributes;
/* END_OF_SYMBOL_DEFINITION CommonObjectAttributes */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CommonObjectAttributes */
/**
* @summary The Leading Root Component Types of CommonObjectAttributes
* @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_CommonObjectAttributes = [
new $.ComponentSpec("label", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 12), undefined, undefined),
new $.ComponentSpec("flags", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 3), undefined, undefined),
new $.ComponentSpec("authId", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_CommonObjectAttributes */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CommonObjectAttributes */
/**
* @summary The Trailing Root Component Types of CommonObjectAttributes
* @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_CommonObjectAttributes = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_CommonObjectAttributes */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CommonObjectAttributes */
/**
* @summary The Extension Addition Component Types of CommonObjectAttributes
* @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_CommonObjectAttributes = [
new $.ComponentSpec("userConsent", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 2), undefined, undefined),
new $.ComponentSpec("accessControlRules", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_CommonObjectAttributes */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_CommonObjectAttributes */
let _cached_decoder_for_CommonObjectAttributes = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_CommonObjectAttributes */
/* START_OF_SYMBOL_DEFINITION _decode_CommonObjectAttributes */
/**
* @summary Decodes an ASN.1 element into a(n) CommonObjectAttributes
* @function
* @param {_Element} el The element being decoded.
* @returns {CommonObjectAttributes} The decoded data structure.
*/
function _decode_CommonObjectAttributes(el) {
if (!_cached_decoder_for_CommonObjectAttributes) {
_cached_decoder_for_CommonObjectAttributes = function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let label;
let flags;
let authId;
let userConsent;
let accessControlRules;
let _unrecognizedExtensionsList = [];
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
label: (_el) => {
label = Label_ta_1._decode_Label(_el);
},
flags: (_el) => {
flags = CommonObjectFlags_ta_1._decode_CommonObjectFlags(_el);
},
authId: (_el) => {
authId = Identifier_ta_1._decode_Identifier(_el);
},
userConsent: (_el) => {
userConsent = $._decodeInteger(_el);
},
accessControlRules: (_el) => {
accessControlRules = $._decodeSequenceOf(() => AccessControlRule_ta_1._decode_AccessControlRule)(_el);
},
};
/* END_OF_CALLBACKS_MAP */
$._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_CommonObjectAttributes, exports._extension_additions_list_spec_for_CommonObjectAttributes, exports._root_component_type_list_2_spec_for_CommonObjectAttributes, (ext) => {
_unrecognizedExtensionsList.push(ext);
});
return new CommonObjectAttributes(
/* SEQUENCE_CONSTRUCTOR_CALL */ label, flags, authId, userConsent, accessControlRules, _unrecognizedExtensionsList);
};
}
return _cached_decoder_for_CommonObjectAttributes(el);
}
exports._decode_CommonObjectAttributes = _decode_CommonObjectAttributes;
/* END_OF_SYMBOL_DEFINITION _decode_CommonObjectAttributes */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_CommonObjectAttributes */
let _cached_encoder_for_CommonObjectAttributes = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_CommonObjectAttributes */
/* START_OF_SYMBOL_DEFINITION _encode_CommonObjectAttributes */
/**
* @summary Encodes a(n) CommonObjectAttributes 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 CommonObjectAttributes, encoded as an ASN.1 Element.
*/
function _encode_CommonObjectAttributes(value, elGetter) {
if (!_cached_encoder_for_CommonObjectAttributes) {
_cached_encoder_for_CommonObjectAttributes = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* IF_ABSENT */ value.label === undefined
? undefined
: Label_ta_1._encode_Label(value.label, $.BER),
/* IF_ABSENT */ value.flags === undefined
? undefined
: CommonObjectFlags_ta_1._encode_CommonObjectFlags(value.flags, $.BER),
/* IF_ABSENT */ value.authId === undefined
? undefined
: Identifier_ta_1._encode_Identifier(value.authId, $.BER),
], [
/* IF_ABSENT */ value.userConsent === undefined
? undefined
: $._encodeInteger(value.userConsent, $.BER),
/* IF_ABSENT */ value.accessControlRules ===
undefined
? undefined
: $._encodeSequenceOf(() => AccessControlRule_ta_1._encode_AccessControlRule, $.BER)(value.accessControlRules, $.BER),
], value._unrecognizedExtensionsList
? value._unrecognizedExtensionsList
: [])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_CommonObjectAttributes(value, elGetter);
}
exports._encode_CommonObjectAttributes = _encode_CommonObjectAttributes;
/* END_OF_SYMBOL_DEFINITION _encode_CommonObjectAttributes */
/* eslint-enable */
//# sourceMappingURL=CommonObjectAttributes.ta.js.map