@wildboar/pkcs
Version:
Public Key Cryptography Standard PDUs in TypeScript
155 lines • 6.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._encode_URL_urlWithDigest = exports._decode_URL_urlWithDigest = exports._extension_additions_list_spec_for_URL_urlWithDigest = exports._root_component_type_list_2_spec_for_URL_urlWithDigest = exports._root_component_type_list_1_spec_for_URL_urlWithDigest = exports.URL_urlWithDigest = exports._encode_DigestInfoWithDefault = exports._decode_DigestInfoWithDefault = exports.DigestInfoWithDefault = void 0;
/* eslint-disable */
const asn1_ts_1 = require("asn1-ts");
const $ = require("asn1-ts/dist/node/functional");
const DigestInfoWithDefault_ta_1 = require("../PKCS-15/DigestInfoWithDefault.ta");
var DigestInfoWithDefault_ta_2 = require("../PKCS-15/DigestInfoWithDefault.ta");
Object.defineProperty(exports, "DigestInfoWithDefault", { enumerable: true, get: function () { return DigestInfoWithDefault_ta_2.DigestInfoWithDefault; } });
Object.defineProperty(exports, "_decode_DigestInfoWithDefault", { enumerable: true, get: function () { return DigestInfoWithDefault_ta_2._decode_DigestInfoWithDefault; } });
Object.defineProperty(exports, "_encode_DigestInfoWithDefault", { enumerable: true, get: function () { return DigestInfoWithDefault_ta_2._encode_DigestInfoWithDefault; } });
/* START_OF_SYMBOL_DEFINITION URL_urlWithDigest */
/**
* @summary URL_urlWithDigest
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* URL-urlWithDigest ::= SEQUENCE { -- REMOVED_FROM_UNNESTING -- }
* ```
*
* @class
*/
class URL_urlWithDigest {
constructor(
/**
* @summary `url`.
* @public
* @readonly
*/
url,
/**
* @summary `digest`.
* @public
* @readonly
*/
digest) {
this.url = url;
this.digest = digest;
}
/**
* @summary Restructures an object into a URL_urlWithDigest
* @description
*
* This takes an `object` and converts it to a `URL_urlWithDigest`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `URL_urlWithDigest`.
* @returns {URL_urlWithDigest}
*/
static _from_object(_o) {
return new URL_urlWithDigest(_o.url, _o.digest);
}
}
exports.URL_urlWithDigest = URL_urlWithDigest;
/* END_OF_SYMBOL_DEFINITION URL_urlWithDigest */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_URL_urlWithDigest */
/**
* @summary The Leading Root Component Types of URL_urlWithDigest
* @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_URL_urlWithDigest = [
new $.ComponentSpec("url", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 22), undefined, undefined),
new $.ComponentSpec("digest", false, $.hasTag(asn1_ts_1.ASN1TagClass.universal, 16), undefined, undefined),
];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_1_spec_for_URL_urlWithDigest */
/* START_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_URL_urlWithDigest */
/**
* @summary The Trailing Root Component Types of URL_urlWithDigest
* @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_URL_urlWithDigest = [];
/* END_OF_SYMBOL_DEFINITION _root_component_type_list_2_spec_for_URL_urlWithDigest */
/* START_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_URL_urlWithDigest */
/**
* @summary The Extension Addition Component Types of URL_urlWithDigest
* @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_URL_urlWithDigest = [];
/* END_OF_SYMBOL_DEFINITION _extension_additions_list_spec_for_URL_urlWithDigest */
/* START_OF_SYMBOL_DEFINITION _cached_decoder_for_URL_urlWithDigest */
let _cached_decoder_for_URL_urlWithDigest = null;
/* END_OF_SYMBOL_DEFINITION _cached_decoder_for_URL_urlWithDigest */
/* START_OF_SYMBOL_DEFINITION _decode_URL_urlWithDigest */
/**
* @summary Decodes an ASN.1 element into a(n) URL_urlWithDigest
* @function
* @param {_Element} el The element being decoded.
* @returns {URL_urlWithDigest} The decoded data structure.
*/
function _decode_URL_urlWithDigest(el) {
if (!_cached_decoder_for_URL_urlWithDigest) {
_cached_decoder_for_URL_urlWithDigest = function (el) {
const sequence = el.sequence;
if (sequence.length < 2) {
throw new asn1_ts_1.ASN1ConstructionError("URL-urlWithDigest contained only " +
sequence.length.toString() +
" elements.");
}
sequence[0].name = "url";
sequence[1].name = "digest";
let url;
let digest;
url = $._decodeIA5String(sequence[0]);
digest = DigestInfoWithDefault_ta_1._decode_DigestInfoWithDefault(sequence[1]);
return new URL_urlWithDigest(url, digest);
};
}
return _cached_decoder_for_URL_urlWithDigest(el);
}
exports._decode_URL_urlWithDigest = _decode_URL_urlWithDigest;
/* END_OF_SYMBOL_DEFINITION _decode_URL_urlWithDigest */
/* START_OF_SYMBOL_DEFINITION _cached_encoder_for_URL_urlWithDigest */
let _cached_encoder_for_URL_urlWithDigest = null;
/* END_OF_SYMBOL_DEFINITION _cached_encoder_for_URL_urlWithDigest */
/* START_OF_SYMBOL_DEFINITION _encode_URL_urlWithDigest */
/**
* @summary Encodes a(n) URL_urlWithDigest 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 URL_urlWithDigest, encoded as an ASN.1 Element.
*/
function _encode_URL_urlWithDigest(value, elGetter) {
if (!_cached_encoder_for_URL_urlWithDigest) {
_cached_encoder_for_URL_urlWithDigest = function (value, elGetter) {
return $._encodeSequence([]
.concat([
/* REQUIRED */ $._encodeIA5String(value.url, $.BER),
/* REQUIRED */ DigestInfoWithDefault_ta_1._encode_DigestInfoWithDefault(value.digest, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_URL_urlWithDigest(value, elGetter);
}
exports._encode_URL_urlWithDigest = _encode_URL_urlWithDigest;
/* END_OF_SYMBOL_DEFINITION _encode_URL_urlWithDigest */
/* eslint-enable */
//# sourceMappingURL=URL-urlWithDigest.ta.js.map