@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
40 lines (36 loc) • 2.26 kB
JavaScript
import { _classPrivateFieldInitSpec } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/classPrivateFieldInitSpec.mjs";
import { _classPrivateFieldSet2 } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/classPrivateFieldSet2.mjs";
import { _classPrivateFieldGet2 } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/classPrivateFieldGet2.mjs";
import { X509Certificate } from "./X509Certificate.mjs";
//#region src/modules/x509/X509ModuleConfig.ts
var _trustedCertificates = /* @__PURE__ */ new WeakMap();
var _getTrustedCertificatesForVerification = /* @__PURE__ */ new WeakMap();
var X509ModuleConfig = class {
constructor(options) {
_classPrivateFieldInitSpec(this, _trustedCertificates, void 0);
_classPrivateFieldInitSpec(this, _getTrustedCertificatesForVerification, void 0);
this.setTrustedCertificates(options?.trustedCertificates);
if (options?.getTrustedCertificatesForVerification) this.setTrustedCertificatesForVerification(options.getTrustedCertificatesForVerification);
}
get trustedCertificates() {
return _classPrivateFieldGet2(_trustedCertificates, this)?.map((cert) => cert.toString("pem"));
}
get getTrustedCertificatesForVerification() {
return _classPrivateFieldGet2(_getTrustedCertificatesForVerification, this);
}
setTrustedCertificatesForVerification(fn) {
_classPrivateFieldSet2(_getTrustedCertificatesForVerification, this, fn);
}
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