UNPKG

@c8y/client

Version:

Client application programming interface to access the Cumulocity IoT-Platform REST services.

91 lines 2.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CrlService = void 0; const tslib_1 = require("tslib"); const form_data_1 = tslib_1.__importDefault(require("form-data")); const core_1 = require("../core"); /** * This class allows for managing a list of certificate revocations. */ class CrlService extends core_1.Service { get baseUrl() { return `/tenant/trusted-certificates/settings/crl`; } /** * Uploads a list of certificate revocations. * Adds new entries to the certificate revocation list, * the ones that already exist are updated. * No entries are removed from the certificate revocation list. * * @returns Returns a status object. * * **Example** * ```typescript * * const crls: ICertificateRevocation[] = [ * { serialNumberInHex: '24234', revocationDate: '2023-01-13T23:00:00.000Z' } * ]; * * (async () => { * const { res } = await crlService.uploadCrls(crls); * })(); * ``` */ async uploadCrls(crls) { const method = 'PUT'; const headers = { 'content-type': 'application/json', Accept: 'application/json' }; const body = JSON.stringify({ crls }); const res = await this.fetch('', { method, body, headers }); return { res, data: null }; } /** * Uploads a csv file containing a list of certificate revocations. * Adds new entries to the certificate revocation list, * the ones that already exist are updated. * No entries are removed from the certificate revocation list. * * File format: * SERIALNO,DATE * 1234567890abcdef,2023-01-01T00:00:00.000Z * * @returns Returns a status object. * * **Example** * ```typescript * * (async () => { * const { res } = await crlService.uploadCrlFile( file ); * })(); * ``` */ async uploadCrlFile(file) { const method = 'PUT'; const body = new form_data_1.default(); body.append('file', file); const headers = { accept: 'application/json' }; const res = await this.fetch('', { method, body, headers }); return { res, data: null }; } /** * Downloads a certificate revocation list file. * To open the downloaded file please use command: openssl crl -inform DER -text -noout -in fileName.crl * * @returns Returns a arrayBuffer wrapped in [[IFetchResponse]]. * * **Example** * ```typescript * * (async () => { * const res = await this.crlService.downloadCrlFile(); * const arrayBuffer = await res.arrayBuffer(); * })(); * ``` */ async downloadCrlFile(init) { return await this.fetch('', init); } } exports.CrlService = CrlService; //# sourceMappingURL=CrlService.js.map