From 455634f4d02d1710e8f7f1116a3609b730fa8b9a Mon Sep 17 00:00:00 2001 From: Danilo Bispo Date: Fri, 27 Oct 2023 14:08:38 -0300 Subject: [PATCH] Corrections for linter --- index.js | 1 + lib/amplia-client.js | 106 +++++----- lib/certificate-model2.js | 398 +++++++++++++++++++------------------- 3 files changed, 253 insertions(+), 252 deletions(-) diff --git a/index.js b/index.js index 2ceb6d6..95602a2 100644 --- a/index.js +++ b/index.js @@ -93,6 +93,7 @@ exports.AmpliaErrorCodes = AmpliaErrorCodes; exports.HttpMethods = HttpMethods; exports.IssueCertificateRequest = IssueCertificateRequest; exports.IssuePkcs12CertificateRequest = IssuePkcs12CertificateRequest; +exports.IssuePkcs12CertificateResponse = IssuePkcs12CertificateResponse; exports.Order = Order; exports.OrderLocketError = OrderLocketError; exports.BaseOrder = BaseOrder; diff --git a/lib/amplia-client.js b/lib/amplia-client.js index ac84124..65e5be9 100644 --- a/lib/amplia-client.js +++ b/lib/amplia-client.js @@ -39,12 +39,12 @@ class AmpliaClient { } /** - * Creates a certificate order in Amplia - * - * @param {CreateOrderRequest} request the request containing information - * about the order to be created - * @returns {Order} the representation of the created order - */ + * Creates a certificate order in Amplia + * + * @param {CreateOrderRequest} request the request containing information + * about the order to be created + * @returns {Order} the representation of the created order + */ createOrder(request) { return new Promise((resolve, reject) => { if (!request) { @@ -70,12 +70,12 @@ class AmpliaClient { } /** - * Creates a RSA Key in Amplia - * - * @param {CreateKeyRequest} request the request containing information - * about the key to be created - * @returns {KeyModel} the representation of the created order - */ + * Creates a RSA Key in Amplia + * + * @param {CreateKeyRequest} request the request containing information + * about the key to be created + * @returns {KeyModel} the representation of the created order + */ async createRSAKey(request) { if (!request) { throw new Error('The request was not set'); @@ -93,12 +93,12 @@ class AmpliaClient { } /** - * Creates a RSA Protected Key in Amplia - * - * @param {CreateProtectedKeyRequest} request the request containing information - * about the key to be created - * @returns {KeyModel} the representation of the created order - */ + * Creates a RSA Protected Key in Amplia + * + * @param {CreateProtectedKeyRequest} request the request containing information + * about the key to be created + * @returns {KeyModel} the representation of the created order + */ async createRSAProtectedKey(request) { if (!request) { throw new Error('The request was not set'); @@ -116,13 +116,13 @@ class AmpliaClient { } /** - * Signs a hash with the assigned keyId - * - * @param {string} keyId the ID of the desired key - * @param {SignHashRequest} request the request containing info about - * the hash to be signed - * @returns {SignHashResponse} the response returned - */ + * Signs a hash with the assigned keyId + * + * @param {string} keyId the ID of the desired key + * @param {SignHashRequest} request the request containing info about + * the hash to be signed + * @returns {SignHashResponse} the response returned + */ signHashWithKey(keyId, request) { return new Promise((resolve, reject) => { if (!request) { @@ -145,11 +145,11 @@ class AmpliaClient { } /** - * Retrieves an order from Amplia - * - * @param {string} orderId the ID of the desired order - * @returns {Order} the desired order - */ + * Retrieves an order from Amplia + * + * @param {string} orderId the ID of the desired order + * @returns {Order} the desired order + */ getOrder(orderId) { return new Promise((resolve, reject) => { if (!orderId) { @@ -192,10 +192,10 @@ class AmpliaClient { } /** - * Deletes an order in Amplia - * - * @param {string} orderId the ID of the desired order - */ + * Deletes an order in Amplia + * + * @param {string} orderId the ID of the desired order + */ deleteOrder(orderId) { return new Promise((resolve, reject) => { if (!orderId) { @@ -211,12 +211,12 @@ class AmpliaClient { } /** - * Issues a certificate order from Amplia - * - * @param {string} orderId the ID of the desired order - * @returns {Order} the desired order - * @param {string} keyId the ID of the desired key - */ + * Issues a certificate order from Amplia + * + * @param {string} orderId the ID of the desired order + * @returns {Order} the desired order + * @param {string} keyId the ID of the desired key + */ issueCertificate(orderId, csr, keyMedia = null, keyId = null) { return new Promise((resolve, reject) => { let client = this._getRestClient(); @@ -234,17 +234,17 @@ class AmpliaClient { } /** - * Issues a PKCS#12 certificate order from Amplia - * - * @param {string} orderId the ID of the desired order - * @param {string} password the password for the PKCS#12 certificate + * Issues a PKCS#12 certificate order from Amplia + * + * @param {string} orderId the ID of the desired order + * @param {string} password the password for the PKCS#12 certificate * @param {number} keySize the size of the key for this certificate - * @returns {IssuePkcs12CertificateResponse} the response containing the .PFX file - */ - issuePkcs12Certificate(orderId, password, keySize = null) { + * @returns {IssuePkcs12CertificateResponse} the response containing the .PFX file + */ + issuePkcs12Certificate(orderId, password, keySize = null) { return new Promise((resolve, reject) => { let client = this._getRestClient(); - let request = new IssuePkcs12CertificateRequest({orderId, password, keySize}); + let request = new IssuePkcs12CertificateRequest({ orderId, password, keySize }); client .post('api/certificates/pkcs12', request) @@ -265,7 +265,7 @@ class AmpliaClient { return new Promise((resolve, reject) => { if ( searchParams && - !(searchParams instanceof PaginatedSearchParams) + !(searchParams instanceof PaginatedSearchParams) ) { throw new Error( 'The "searchParams" parameter is not a instance of the PaginatedSearchParams class.' @@ -325,10 +325,10 @@ class AmpliaClient { static _setPaginatedSearchParams(originalUri, searchParams) { return ( `${originalUri}?` + - `q=${encodeURIComponent(searchParams.getQ())}&` + - `limit=${searchParams.getLimit()}&` + - `offset=${searchParams.getOffset()}&` + - `order=${searchParams.getOrder()}` + `q=${encodeURIComponent(searchParams.getQ())}&` + + `limit=${searchParams.getLimit()}&` + + `offset=${searchParams.getOffset()}&` + + `order=${searchParams.getOrder()}` ); } diff --git a/lib/certificate-model2.js b/lib/certificate-model2.js index 7b88d89..d7ecf87 100644 --- a/lib/certificate-model2.js +++ b/lib/certificate-model2.js @@ -1,302 +1,302 @@ -'use strict' +'use strict'; class CertificateModel2 { - constructor({parameters, info, content, hasSignedAgreement, id, subscriptionId, caId, keyId, - dateIssued, dateEffective, dateExpires, dateRevoked, alias, subjectDisplayName, serialNumber, - isCA, kind, format, isPendingApproval} = {}) { - this._parameters = parameters || null; - this._info = info || null; - this._content = content || null; - this._hasSignedAgreement = hasSignedAgreement || null; - this._id = id || null; - this._subscriptionId = subscriptionId || null; - this._caId = caId || null; - this._keyId = keyId || null; - this._dateIssued = dateIssued || null; - this._dateEffective = dateEffective || null; - this._dateExpires = dateExpires || null; - this._dateRevoked = dateRevoked || null; - this._alias = alias || null; - this._subjectDisplayName = subjectDisplayName || null; - this._serialNumber = serialNumber || null; - this._isCA = isCA || null; - this._kind = kind || null; - this._format = format || null; - this._isPendingApproval = isPendingApproval || null; - } + constructor({parameters, info, content, hasSignedAgreement, id, subscriptionId, caId, keyId, + dateIssued, dateEffective, dateExpires, dateRevoked, alias, subjectDisplayName, serialNumber, + isCA, kind, format, isPendingApproval} = {}) { + this._parameters = parameters || null; + this._info = info || null; + this._content = content || null; + this._hasSignedAgreement = hasSignedAgreement || null; + this._id = id || null; + this._subscriptionId = subscriptionId || null; + this._caId = caId || null; + this._keyId = keyId || null; + this._dateIssued = dateIssued || null; + this._dateEffective = dateEffective || null; + this._dateExpires = dateExpires || null; + this._dateRevoked = dateRevoked || null; + this._alias = alias || null; + this._subjectDisplayName = subjectDisplayName || null; + this._serialNumber = serialNumber || null; + this._isCA = isCA || null; + this._kind = kind || null; + this._format = format || null; + this._isPendingApproval = isPendingApproval || null; + } -/** + /** * @return {Object} */ - getParameters() { - return this._parameters; - } + getParameters() { + return this._parameters; + } - /** + /** * @param {Object} parameters */ - setParameters(parameters) { - this._parameters = parameters; - } -/** + setParameters(parameters) { + this._parameters = parameters; + } + /** * @return {module:dist/amplia-client/CertificateInfo2} */ - getInfo() { - return this._info; - } + getInfo() { + return this._info; + } - /** + /** * @param {module:dist/amplia-client/CertificateInfo2} info */ - setInfo(info) { - this._info = info; - } -/** + setInfo(info) { + this._info = info; + } + /** * @return {Blob} */ - getContent() { - return this._content; - } + getContent() { + return this._content; + } - /** + /** * @param {Blob} content */ - setContent(content) { - this._content = content; - } -/** + setContent(content) { + this._content = content; + } + /** * @return {Boolean} */ - getHasSignedAgreement() { - return this._hasSignedAgreement; - } + getHasSignedAgreement() { + return this._hasSignedAgreement; + } - /** + /** * @param {Boolean} hasSignedAgreement */ - setHasSignedAgreement(hasSignedAgreement) { - this._hasSignedAgreement = hasSignedAgreement; - } -/** + setHasSignedAgreement(hasSignedAgreement) { + this._hasSignedAgreement = hasSignedAgreement; + } + /** * @return {String} */ - getId() { - return this._id; - } + getId() { + return this._id; + } - /** + /** * @param {String} id */ - setId(id) { - this._id = id; - } -/** + setId(id) { + this._id = id; + } + /** * @return {String} */ - getSubscriptionId() { - return this._subscriptionId; - } + getSubscriptionId() { + return this._subscriptionId; + } - /** + /** * @param {String} subscriptionId */ - setSubscriptionId(subscriptionId) { - this._subscriptionId = subscriptionId; - } -/** + setSubscriptionId(subscriptionId) { + this._subscriptionId = subscriptionId; + } + /** * @return {String} */ - getCaId() { - return this._caId; - } + getCaId() { + return this._caId; + } - /** + /** * @param {String} caId */ - setCaId(caId) { - this._caId = caId; - } -/** + setCaId(caId) { + this._caId = caId; + } + /** * @return {String} */ - getKeyId() { - return this._keyId; - } + getKeyId() { + return this._keyId; + } - /** + /** * @param {String} keyId */ - setKeyId(keyId) { - this._keyId = keyId; - } -/** + setKeyId(keyId) { + this._keyId = keyId; + } + /** * @return {Date} */ - getDateIssued() { - return this._dateIssued; - } + getDateIssued() { + return this._dateIssued; + } - /** + /** * @param {Date} dateIssued */ - setDateIssued(dateIssued) { - this._dateIssued = dateIssued; - } -/** + setDateIssued(dateIssued) { + this._dateIssued = dateIssued; + } + /** * @return {Date} */ - getDateEffective() { - return this._dateEffective; - } + getDateEffective() { + return this._dateEffective; + } - /** + /** * @param {Date} dateEffective */ - setDateEffective(dateEffective) { - this._dateEffective = dateEffective; - } -/** + setDateEffective(dateEffective) { + this._dateEffective = dateEffective; + } + /** * @return {Date} */ - getDateExpires() { - return this._dateExpires; - } + getDateExpires() { + return this._dateExpires; + } - /** + /** * @param {Date} dateExpires */ - setDateExpires(dateExpires) { - this._dateExpires = dateExpires; - } -/** + setDateExpires(dateExpires) { + this._dateExpires = dateExpires; + } + /** * @return {Date} */ - getDateRevoked() { - return this._dateRevoked; - } + getDateRevoked() { + return this._dateRevoked; + } - /** + /** * @param {Date} dateRevoked */ - setDateRevoked(dateRevoked) { - this._dateRevoked = dateRevoked; - } -/** + setDateRevoked(dateRevoked) { + this._dateRevoked = dateRevoked; + } + /** * @return {String} */ - getAlias() { - return this._alias; - } + getAlias() { + return this._alias; + } - /** + /** * @param {String} alias */ - setAlias(alias) { - this._alias = alias; - } -/** + setAlias(alias) { + this._alias = alias; + } + /** * @return {String} */ - getSubjectDisplayName() { - return this._subjectDisplayName; - } + getSubjectDisplayName() { + return this._subjectDisplayName; + } - /** + /** * @param {String} subjectDisplayName */ - setSubjectDisplayName(subjectDisplayName) { - this._subjectDisplayName = subjectDisplayName; - } -/** + setSubjectDisplayName(subjectDisplayName) { + this._subjectDisplayName = subjectDisplayName; + } + /** * @return {String} */ - getSerialNumber() { - return this._serialNumber; - } + getSerialNumber() { + return this._serialNumber; + } - /** + /** * @param {String} serialNumber */ - setSerialNumber(serialNumber) { - this._serialNumber = serialNumber; - } -/** + setSerialNumber(serialNumber) { + this._serialNumber = serialNumber; + } + /** * @return {Boolean} */ - getIsCA() { - return this._isCA; - } + getIsCA() { + return this._isCA; + } - /** + /** * @param {Boolean} isCA */ - setIsCA(isCA) { - this._isCA = isCA; - } -/** + setIsCA(isCA) { + this._isCA = isCA; + } + /** * @return {module:dist/amplia-client/CertificateKinds} */ - getKind() { - return this._kind; - } + getKind() { + return this._kind; + } - /** + /** * @param {module:dist/amplia-client/CertificateKinds} kind */ - setKind(kind) { - this._kind = kind; - } -/** + setKind(kind) { + this._kind = kind; + } + /** * @return {module:dist/amplia-client/CertificateFormats} */ - getFormat() { - return this._format; - } + getFormat() { + return this._format; + } - /** + /** * @param {module:dist/amplia-client/CertificateFormats} format */ - setFormat(format) { - this._format = format; - } -/** + setFormat(format) { + this._format = format; + } + /** * @return {Boolean} */ - getIsPendingApproval() { - return this._isPendingApproval; - } + getIsPendingApproval() { + return this._isPendingApproval; + } - /** + /** * @param {Boolean} isPendingApproval */ - setIsPendingApproval(isPendingApproval) { - this._isPendingApproval = isPendingApproval; - } + setIsPendingApproval(isPendingApproval) { + this._isPendingApproval = isPendingApproval; + } - toModel() { - return { - parameters: this._parameters, - info: this._info, - content: this._content, - hasSignedAgreement: this._hasSignedAgreement, - id: this._id, - subscriptionId: this._subscriptionId, - caId: this._caId, - keyId: this._keyId, - dateIssued: this._dateIssued, - dateEffective: this._dateEffective, - dateExpires: this._dateExpires, - dateRevoked: this._dateRevoked, - alias: this._alias, - subjectDisplayName: this._subjectDisplayName, - serialNumber: this._serialNumber, - isCA: this._isCA, - kind: this._kind, - format: this._format, - isPendingApproval: this._isPendingApproval - } - } + toModel() { + return { + parameters: this._parameters, + info: this._info, + content: this._content, + hasSignedAgreement: this._hasSignedAgreement, + id: this._id, + subscriptionId: this._subscriptionId, + caId: this._caId, + keyId: this._keyId, + dateIssued: this._dateIssued, + dateEffective: this._dateEffective, + dateExpires: this._dateExpires, + dateRevoked: this._dateRevoked, + alias: this._alias, + subjectDisplayName: this._subjectDisplayName, + serialNumber: this._serialNumber, + isCA: this._isCA, + kind: this._kind, + format: this._format, + isPendingApproval: this._isPendingApproval + }; + } } exports.CertificateModel2 = CertificateModel2;