cloudflare
Version:
The official TypeScript library for the Cloudflare API
108 lines • 4.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SAMLCertificates = exports.BaseSAMLCertificates = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const pagination_1 = require("../../../core/pagination.js");
const headers_1 = require("../../../internal/headers.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseSAMLCertificates = /* @__PURE__ */ (() => {
class BaseSAMLCertificates extends resource_1.APIResource {
/**
* Returns a paginated list of the organization's SAML encryption certificate sets.
* Each certificate set includes the current and (if present) previous
* certificates.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const samlCertificateListResponse of client.zeroTrust.access.samlCertificates.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/access/saml_certificates`, (pagination_1.V4PagePaginationArray), { query, ...options });
}
/**
* Retrieves a specific SAML encryption certificate set by its UID, including both
* current and previous certificates if available.
*
* @example
* ```ts
* const samlCertificate =
* await client.zeroTrust.access.samlCertificates.get(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(samlCERTSetID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/access/saml_certificates/${samlCERTSetID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Downloads the current SAML encryption certificate's public key in PEM format for
* the specified certificate set. This endpoint is useful for providing the
* certificate to Identity Providers for SAML assertion encryption configuration.
*
* @example
* ```ts
* const response =
* await client.zeroTrust.access.samlCertificates.getPem(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
*
* const content = await response.blob();
* console.log(content);
* ```
*/
getPem(samlCERTSetID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/access/saml_certificates/${samlCERTSetID}/pem`, {
...options,
headers: (0, headers_1.buildHeaders)([{ Accept: 'application/x-pem-file' }, options?.headers]),
__binaryResponse: true,
});
}
/**
* Rotates the SAML encryption certificates within the specified certificate set.
* This generates a new certificate and moves the current certificate to the
* previous slot. If a previous certificate exists, it will be deactivated and
* removed.
*
* This endpoint ensures zero-downtime rotation by maintaining both current and
* previous certificates during the transition period, allowing IdPs time to update
* their configurations. Automated rotation happens 30 days before a current
* certificate's expiration.
*
* @example
* ```ts
* const response =
* await client.zeroTrust.access.samlCertificates.rotate(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
rotate(samlCERTSetID, params, options) {
const { account_id } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/access/saml_certificates/${samlCERTSetID}/rotate`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseSAMLCertificates._key = Object.freeze([
'zeroTrust',
'access',
'samlCertificates',
]);
return BaseSAMLCertificates;
})();
exports.BaseSAMLCertificates = BaseSAMLCertificates;
class SAMLCertificates extends BaseSAMLCertificates {
}
exports.SAMLCertificates = SAMLCertificates;
//# sourceMappingURL=saml-certificates.js.map