UNPKG

pkcs-ts

Version:

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

75 lines 4.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_AuthKeyAttributes = exports._decode_AuthKeyAttributes = exports._extension_additions_list_spec_for_AuthKeyAttributes = exports._root_component_type_list_2_spec_for_AuthKeyAttributes = exports._root_component_type_list_1_spec_for_AuthKeyAttributes = exports.AuthKeyAttributes = exports._encode_Identifier = exports._decode_Identifier = 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 Identifier_ta_1 = require("../PKCS-15/Identifier.ta"); var Identifier_ta_2 = require("../PKCS-15/Identifier.ta"); Object.defineProperty(exports, "_decode_Identifier", { enumerable: true, get: function () { return Identifier_ta_2._decode_Identifier; } }); Object.defineProperty(exports, "_encode_Identifier", { enumerable: true, get: function () { return Identifier_ta_2._encode_Identifier; } }); class AuthKeyAttributes { constructor(derivedKey, authKeyId, _unrecognizedExtensionsList = []) { this.derivedKey = derivedKey; this.authKeyId = authKeyId; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } static _from_object(_o) { return new AuthKeyAttributes(_o.derivedKey, _o.authKeyId, _o._unrecognizedExtensionsList); } static get _default_value_for_derivedKey() { return false; } } exports.AuthKeyAttributes = AuthKeyAttributes; exports._root_component_type_list_1_spec_for_AuthKeyAttributes = [ new $.ComponentSpec("derivedKey", true, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 1), undefined, undefined), new $.ComponentSpec("authKeyId", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 4), undefined, undefined), ]; exports._root_component_type_list_2_spec_for_AuthKeyAttributes = []; exports._extension_additions_list_spec_for_AuthKeyAttributes = []; let _cached_decoder_for_AuthKeyAttributes = null; function _decode_AuthKeyAttributes(el) { if (!_cached_decoder_for_AuthKeyAttributes) { _cached_decoder_for_AuthKeyAttributes = function (el) { let derivedKey = AuthKeyAttributes._default_value_for_derivedKey; let authKeyId; let _unrecognizedExtensionsList = []; const callbacks = { derivedKey: (_el) => { derivedKey = $._decodeBoolean(_el); }, authKeyId: (_el) => { authKeyId = Identifier_ta_1._decode_Identifier(_el); }, }; $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_AuthKeyAttributes, exports._extension_additions_list_spec_for_AuthKeyAttributes, exports._root_component_type_list_2_spec_for_AuthKeyAttributes, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new AuthKeyAttributes(derivedKey, authKeyId, _unrecognizedExtensionsList); }; } return _cached_decoder_for_AuthKeyAttributes(el); } exports._decode_AuthKeyAttributes = _decode_AuthKeyAttributes; let _cached_encoder_for_AuthKeyAttributes = null; function _encode_AuthKeyAttributes(value, elGetter) { if (!_cached_encoder_for_AuthKeyAttributes) { _cached_encoder_for_AuthKeyAttributes = function (value, elGetter) { return $._encodeSequence([] .concat([ value.derivedKey === undefined || $.deepEq(value.derivedKey, AuthKeyAttributes._default_value_for_derivedKey) ? undefined : $._encodeBoolean(value.derivedKey, $.BER), Identifier_ta_1._encode_Identifier(value.authKeyId, $.BER), ], value._unrecognizedExtensionsList ? value._unrecognizedExtensionsList : []) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_AuthKeyAttributes(value, elGetter); } exports._encode_AuthKeyAttributes = _encode_AuthKeyAttributes; //# sourceMappingURL=AuthKeyAttributes.ta.js.map