@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
186 lines • 7.72 kB
JavaScript
;
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;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = 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; } });
/* START_OF_SYMBOL_DEFINITION AuthKeyAttributes */
/**
* @summary AuthKeyAttributes
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* AuthKeyAttributes ::= SEQUENCE {
* derivedKey BOOLEAN DEFAULT TRUE,
* authKeyId Identifier,
* ... -- For future extensions
* }
* ```
*
* @class
*/
class AuthKeyAttributes {
constructor(
/**
* @summary `derivedKey`.
* @public
* @readonly
*/
derivedKey,
/**
* @summary `authKeyId`.
* @public
* @readonly
*/
authKeyId,
/**
* @summary Extensions that are not recognized.
* @public
* @readonly
*/
_unrecognizedExtensionsList = []) {
this.derivedKey = derivedKey;
this.authKeyId = authKeyId;
this._unrecognizedExtensionsList = _unrecognizedExtensionsList;
}
/**
* @summary Restructures an object into a AuthKeyAttributes
* @description
*
* This takes an `object` and converts it to a `AuthKeyAttributes`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `AuthKeyAttributes`.
* @returns {AuthKeyAttributes}
*/
static _from_object(_o) {
return new AuthKeyAttributes(_o.derivedKey, _o.authKeyId, _o._unrecognizedExtensionsList);
}
/**
* @summary Getter that returns the default value for `derivedKey`.
* @public
* @static
* @method
*/
static get _default_value_for_derivedKey() {
return false;
}
}
exports.AuthKeyAttributes = AuthKeyAttributes;
/* END_OF_SYMBOL_DEFINITION AuthKeyAttributes */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_AuthKeyAttributes */
/**
* @summary The Leading Root Component Types of AuthKeyAttributes
* @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_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),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_AuthKeyAttributes */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_AuthKeyAttributes */
/**
* @summary The Trailing Root Component Types of AuthKeyAttributes
* @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_AuthKeyAttributes = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_AuthKeyAttributes */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_AuthKeyAttributes */
/**
* @summary The Extension Addition Component Types of AuthKeyAttributes
* @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_AuthKeyAttributes = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_AuthKeyAttributes */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_AuthKeyAttributes */
let _cached_decoder_for_AuthKeyAttributes = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_AuthKeyAttributes */
/* START_OF_SYMBOL_DEFINITION _decode_AuthKeyAttributes */
/**
* @summary Decodes an ASN.1 element into a(n) AuthKeyAttributes
* @function
* @param {_Element} el The element being decoded.
* @returns {AuthKeyAttributes} The decoded data structure.
*/
function _decode_AuthKeyAttributes(el) {
if (!_cached_decoder_for_AuthKeyAttributes) {
_cached_decoder_for_AuthKeyAttributes = function (el) {
/* START_OF_SEQUENCE_COMPONENT_DECLARATIONS */
let derivedKey = AuthKeyAttributes._default_value_for_derivedKey;
let authKeyId;
let _unrecognizedExtensionsList = [];
/* END_OF_SEQUENCE_COMPONENT_DECLARATIONS */
/* START_OF_CALLBACKS_MAP */
const callbacks = {
derivedKey: (_el) => {
derivedKey = $._decodeBoolean(_el);
},
authKeyId: (_el) => {
authKeyId = Identifier_ta_1._decode_Identifier(_el);
},
};
/* END_OF_CALLBACKS_MAP */
$._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(
/* SEQUENCE_CONSTRUCTOR_CALL */ derivedKey, authKeyId, _unrecognizedExtensionsList);
};
}
return _cached_decoder_for_AuthKeyAttributes(el);
}
exports._decode_AuthKeyAttributes = _decode_AuthKeyAttributes;
/* END_OF_SYMBOL_DEFINITION _decode_AuthKeyAttributes */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_AuthKeyAttributes */
let _cached_encoder_for_AuthKeyAttributes = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_AuthKeyAttributes */
/* START_OF_SYMBOL_DEFINITION _encode_AuthKeyAttributes */
/**
* @summary Encodes a(n) AuthKeyAttributes 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 AuthKeyAttributes, encoded as an ASN.1 Element.
*/
function _encode_AuthKeyAttributes(value, elGetter) {
if (!_cached_encoder_for_AuthKeyAttributes) {
_cached_encoder_for_AuthKeyAttributes = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* IF_DEFAULT */ value.derivedKey === undefined ||
$.deepEq(value.derivedKey, AuthKeyAttributes._default_value_for_derivedKey)
? undefined
: $._encodeBoolean(value.derivedKey, $.BER),
/* REQUIRED */ 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;
/* END_OF_SYMBOL_DEFINITION _encode_AuthKeyAttributes */
/* eslint-enable */
//# sourceMappingURL=AuthKeyAttributes.ta.js.map