UNPKG

pkcs-ts

Version:

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

71 lines 4.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._encode_CommonPrivateKeyAttributes = exports._decode_CommonPrivateKeyAttributes = exports._extension_additions_list_spec_for_CommonPrivateKeyAttributes = exports._root_component_type_list_2_spec_for_CommonPrivateKeyAttributes = exports._root_component_type_list_1_spec_for_CommonPrivateKeyAttributes = exports.CommonPrivateKeyAttributes = 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 Name_ta_1 = require("x500-ts/dist/node/modules/InformationFramework/Name.ta"); const CredentialIdentifier_ta_1 = require("../PKCS-15/CredentialIdentifier.ta"); class CommonPrivateKeyAttributes { constructor(subjectName, keyIdentifiers, _unrecognizedExtensionsList = []) { this.subjectName = subjectName; this.keyIdentifiers = keyIdentifiers; this._unrecognizedExtensionsList = _unrecognizedExtensionsList; } static _from_object(_o) { return new CommonPrivateKeyAttributes(_o.subjectName, _o.keyIdentifiers, _o._unrecognizedExtensionsList); } } exports.CommonPrivateKeyAttributes = CommonPrivateKeyAttributes; exports._root_component_type_list_1_spec_for_CommonPrivateKeyAttributes = [ new $.ComponentSpec("subjectName", true, $.hasAnyTag, undefined, undefined), new $.ComponentSpec("keyIdentifiers", true, $.hasTag(asn1_ts_1.ASN1TagClass.context, 0), undefined, undefined), ]; exports._root_component_type_list_2_spec_for_CommonPrivateKeyAttributes = []; exports._extension_additions_list_spec_for_CommonPrivateKeyAttributes = []; let _cached_decoder_for_CommonPrivateKeyAttributes = null; function _decode_CommonPrivateKeyAttributes(el) { if (!_cached_decoder_for_CommonPrivateKeyAttributes) { _cached_decoder_for_CommonPrivateKeyAttributes = function (el) { let subjectName; let keyIdentifiers; let _unrecognizedExtensionsList = []; const callbacks = { subjectName: (_el) => { subjectName = Name_ta_1._decode_Name(_el); }, keyIdentifiers: (_el) => { keyIdentifiers = $._decode_implicit(() => $._decodeSequenceOf(() => CredentialIdentifier_ta_1._decode_CredentialIdentifier))(_el); }, }; $._parse_sequence(el, callbacks, exports._root_component_type_list_1_spec_for_CommonPrivateKeyAttributes, exports._extension_additions_list_spec_for_CommonPrivateKeyAttributes, exports._root_component_type_list_2_spec_for_CommonPrivateKeyAttributes, (ext) => { _unrecognizedExtensionsList.push(ext); }); return new CommonPrivateKeyAttributes(subjectName, keyIdentifiers, _unrecognizedExtensionsList); }; } return _cached_decoder_for_CommonPrivateKeyAttributes(el); } exports._decode_CommonPrivateKeyAttributes = _decode_CommonPrivateKeyAttributes; let _cached_encoder_for_CommonPrivateKeyAttributes = null; function _encode_CommonPrivateKeyAttributes(value, elGetter) { if (!_cached_encoder_for_CommonPrivateKeyAttributes) { _cached_encoder_for_CommonPrivateKeyAttributes = function (value, elGetter) { return $._encodeSequence([] .concat([ value.subjectName === undefined ? undefined : Name_ta_1._encode_Name(value.subjectName, $.BER), value.keyIdentifiers === undefined ? undefined : $._encode_implicit(asn1_ts_1.ASN1TagClass.context, 0, () => $._encodeSequenceOf(() => CredentialIdentifier_ta_1._encode_CredentialIdentifier, $.BER), $.BER)(value.keyIdentifiers, $.BER), ], value._unrecognizedExtensionsList ? value._unrecognizedExtensionsList : []) .filter((c) => !!c), $.BER); }; } return _cached_encoder_for_CommonPrivateKeyAttributes(value, elGetter); } exports._encode_CommonPrivateKeyAttributes = _encode_CommonPrivateKeyAttributes; //# sourceMappingURL=CommonPrivateKeyAttributes.ta.js.map