@credo-ts/core
Version:
<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1
52 lines (51 loc) • 2.82 kB
JavaScript
import _classPrivateFieldInitSpec from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/classPrivateFieldInitSpec.mjs";
import _classPrivateFieldGet2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/classPrivateFieldGet2.mjs";
import _classPrivateFieldSet2 from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/classPrivateFieldSet2.mjs";
import { X509Certificate } from "./X509Certificate.mjs";
//#region src/modules/x509/X509ModuleConfig.ts
var _trustedCertificates = /* @__PURE__ */ new WeakMap();
var _getTrustedCertificatesForVerification = /* @__PURE__ */ new WeakMap();
var _revocationCheck = /* @__PURE__ */ new WeakMap();
var X509ModuleConfig = class {
constructor(options) {
_classPrivateFieldInitSpec(this, _trustedCertificates, void 0);
_classPrivateFieldInitSpec(this, _getTrustedCertificatesForVerification, void 0);
_classPrivateFieldInitSpec(this, _revocationCheck, void 0);
this.setTrustedCertificates(options?.trustedCertificates);
if (options?.getTrustedCertificatesForVerification) this.setTrustedCertificatesForVerification(options.getTrustedCertificatesForVerification);
if (options?.revocationCheck) _classPrivateFieldSet2(_revocationCheck, this, options.revocationCheck);
}
get trustedCertificates() {
return _classPrivateFieldGet2(_trustedCertificates, this)?.map((cert) => cert.toString("pem"));
}
/**
* @deprecated use the global `getTrustedIssuersForVerification` instead
*/
get getTrustedCertificatesForVerification() {
return _classPrivateFieldGet2(_getTrustedCertificatesForVerification, this);
}
/**
* @deprecated use the global `getTrustedIssuersForVerification` instead
*/
setTrustedCertificatesForVerification(fn) {
_classPrivateFieldSet2(_getTrustedCertificatesForVerification, this, fn);
}
get revocationCheck() {
return _classPrivateFieldGet2(_revocationCheck, this);
}
setRevocationCheck(options) {
_classPrivateFieldSet2(_revocationCheck, this, options);
}
setTrustedCertificates(trustedCertificates) {
const certificateInstances = trustedCertificates?.map((trustedCertificate) => typeof trustedCertificate === "string" ? X509Certificate.fromEncodedCertificate(trustedCertificate) : trustedCertificate);
_classPrivateFieldSet2(_trustedCertificates, this, trustedCertificates?.length ? certificateInstances : void 0);
}
addTrustedCertificate(trustedCertificate) {
const certificateInstance = typeof trustedCertificate === "string" ? X509Certificate.fromEncodedCertificate(trustedCertificate) : trustedCertificate;
if (!_classPrivateFieldGet2(_trustedCertificates, this)) _classPrivateFieldSet2(_trustedCertificates, this, []);
_classPrivateFieldGet2(_trustedCertificates, this).push(certificateInstance);
}
};
//#endregion
export { X509ModuleConfig };
//# sourceMappingURL=X509ModuleConfig.mjs.map