vite-plugin-rpx 0.11.33 → 0.11.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +23 -2
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -24202,6 +24202,7 @@ class OnDemandCertManager {
24202
24202
  certs = new Map;
24203
24203
  inFlight = new Map;
24204
24204
  negativeCache = new Map;
24205
+ accountKeyPem;
24205
24206
  constructor(opts) {
24206
24207
  this.config = opts.config;
24207
24208
  this.certsDir = opts.certsDir;
@@ -24274,13 +24275,16 @@ class OnDemandCertManager {
24274
24275
  }
24275
24276
  try {
24276
24277
  debugLog("on-demand", `issuing cert for ${host} (staging=${this.config.staging ?? false})`, this.verbose);
24278
+ this.accountKeyPem ??= await this.loadAccountKey();
24277
24279
  const result = await this.issuer({
24278
24280
  domains: [host],
24279
24281
  method: "http-01",
24280
24282
  http01Store: this.http01Store,
24281
24283
  email: this.config.email,
24282
- staging: this.config.staging
24284
+ accountKeyPem: this.accountKeyPem,
24285
+ staging: this.config.staging ?? false
24283
24286
  });
24287
+ await this.saveAccountKey(result.accountKeyPem);
24284
24288
  await this.persist(host, result.fullChainPem, result.keyPem);
24285
24289
  const entry = { serverName: host, cert: result.fullChainPem, key: result.keyPem };
24286
24290
  this.certs.set(host, entry);
@@ -24339,8 +24343,25 @@ class OnDemandCertManager {
24339
24343
  fsp2.writeFile(keyPath, keyPem, { encoding: "utf8", mode: 384 })
24340
24344
  ]);
24341
24345
  }
24346
+ get accountKeyPath() {
24347
+ return path5.join(this.certsDir, ACCOUNT_KEY_FILE);
24348
+ }
24349
+ async loadAccountKey() {
24350
+ try {
24351
+ return await fsp2.readFile(this.accountKeyPath, "utf8");
24352
+ } catch {
24353
+ return;
24354
+ }
24355
+ }
24356
+ async saveAccountKey(pem) {
24357
+ if (!pem || this.accountKeyPem === pem)
24358
+ return;
24359
+ this.accountKeyPem = pem;
24360
+ await fsp2.mkdir(this.certsDir, { recursive: true }).catch(() => {});
24361
+ await fsp2.writeFile(this.accountKeyPath, pem, { encoding: "utf8", mode: 384 }).catch(() => {});
24362
+ }
24342
24363
  }
24343
- var DEFAULT_NEGATIVE_CACHE_MS = 60000, MAX_NEGATIVE_CACHE = 4096;
24364
+ var ACCOUNT_KEY_FILE = "acme-account.key", DEFAULT_NEGATIVE_CACHE_MS = 60000, MAX_NEGATIVE_CACHE = 4096;
24344
24365
  var init_on_demand = __esm(() => {
24345
24366
  init_src();
24346
24367
  init_utils();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-plugin-rpx",
3
3
  "type": "module",
4
- "version": "0.11.33",
4
+ "version": "0.11.34",
5
5
  "description": "A modern and smart reverse proxy. Vite plugin.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -47,7 +47,7 @@
47
47
  "typecheck": "bunx tsc --noEmit"
48
48
  },
49
49
  "dependencies": {
50
- "@stacksjs/rpx": "0.11.33",
50
+ "@stacksjs/rpx": "0.11.34",
51
51
  "@stacksjs/tlsx": "^0.13.13"
52
52
  },
53
53
  "simple-git-hooks": {