UNPKG

pkcs-ts

Version:

PKCS #1 through #15 (Except #11) - Private and Public Keys, Certificates, and More

103 lines 5.66 kB
"use strict"; 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; const tslib_1 = require("tslib"); const asn1_ts_1 = require("asn1-ts"); const $ = tslib_1.__importStar(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"); class CommonObjectAttributes { constructor(label, flags, authId, userConsent, accessControlRules, _unrecognizedExtensionsList = []) { this.label = label; this.flags = flags; this.authId = authId; this.userConsent = userConsent; this.accessControlRules = accessControlRules; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } static _from_object(_o) { return new CommonObjectAttributes(_o.label, _o.flags, _o.authId, _o.userConsent, _o.accessControlRules, _o._unrecognizedExtensionsList); } } exports.CommonObjectAttributes = CommonObjectAttributes; 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), ]; exports._root_component_type_list_2_spec_for_CommonObjectAttributes = []; 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), ]; let _cached_decoder_for_CommonObjectAttributes = null; function _decode_CommonObjectAttributes(el) { if (!_cached_decoder_for_CommonObjectAttributes) { _cached_decoder_for_CommonObjectAttributes = function (el) { let label; let flags; let authId; let userConsent; let accessControlRules; let _unrecognizedExtensionsList = []; 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); }, }; $._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(label, flags, authId, userConsent, accessControlRules, _unrecognizedExtensionsList); }; } return _cached_decoder_for_CommonObjectAttributes(el); } exports._decode_CommonObjectAttributes = _decode_CommonObjectAttributes; let _cached_encoder_for_CommonObjectAttributes = null; function _encode_CommonObjectAttributes(value, elGetter) { if (!_cached_encoder_for_CommonObjectAttributes) { _cached_encoder_for_CommonObjectAttributes = function (value, elGetter) { return $._encodeSequence([] .concat([ value.label === undefined ? undefined : Label_ta_1._encode_Label(value.label, $.BER), value.flags === undefined ? undefined : CommonObjectFlags_ta_1._encode_CommonObjectFlags(value.flags, $.BER), value.authId === undefined ? undefined : Identifier_ta_1._encode_Identifier(value.authId, $.BER), ], [ value.userConsent === undefined ? undefined : $._encodeInteger(value.userConsent, $.BER), 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; //# sourceMappingURL=CommonObjectAttributes.ta.js.map