UNPKG

@syncfusion/ej2-pdf

Version:

Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.

64 lines (63 loc) 2.58 kB
import { _ConstructionType, _TagClassType, _UniversalType } from '../asn1/enumerator'; import { _PdfAbstractSyntaxElement } from '../asn1/abstract-syntax'; import { _PdfUniqueEncodingElement } from '../asn1/unique-encoding-element'; import { _PdfAlgorithms } from './x509-algorithm'; import { _PdfUniqueBitString } from './x509-bit-string-handler'; import { _PdfSignedCertificate } from './x509-signed-certificate'; /** * Representation of the top-level X.509 certificate structure (tbsCertificate + signature). * * @private */ var _PdfX509CertificateStructure = /** @class */ (function () { function _PdfX509CertificateStructure(seq) { if (seq) { if (!Array.isArray(seq) || seq.length !== 3) { throw new Error("Invalid certificate sequence length: " + seq.length); } this._sequence = seq; this._toBeSignedCertificate = new _PdfSignedCertificate(seq[0]); this._signatureAlgorithmIdentifier = new _PdfAlgorithms(seq[1]); this._signature = new _PdfUniqueBitString(seq[2]._getValue()); } } /** * Return the parsed `ToBeSigned` certificate wrapper. * * @private * @returns {_PdfSignedCertificate} The signed certificate component. */ _PdfX509CertificateStructure.prototype._getSignedCertificate = function () { return this._toBeSignedCertificate; }; /** * Construct an instance from an ASN.1 sequence array if valid. * * @private * @param {any} obj - Candidate sequence array. * @returns {_PdfX509CertificateStructure} New structure instance or null. */ _PdfX509CertificateStructure.prototype._getInstance = function (obj) { if (Array.isArray(obj) && obj.every(function (e) { return e instanceof _PdfAbstractSyntaxElement; })) { var seq = obj; return new _PdfX509CertificateStructure(seq); } return null; }; /** * Produce DER encoded bytes for the entire certificate structure. * * @private * @returns {Uint8Array} DER-encoded certificate bytes. */ _PdfX509CertificateStructure.prototype._getDerEncoded = function () { var der = new _PdfUniqueEncodingElement(); der._tagClass = _TagClassType.universal; der._construction = _ConstructionType.constructed; der._setTagNumber(_UniversalType.sequence); der._setSequence(this._sequence); return der._toBytes(); }; return _PdfX509CertificateStructure; }()); export { _PdfX509CertificateStructure };