vite-plugin-rpx 0.11.33 → 0.11.35
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.
- package/dist/index.js +70 -41
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -23434,6 +23434,7 @@ function chunkedStream(pool, conn, closeConn) {
|
|
|
23434
23434
|
conn.streamingBody = true;
|
|
23435
23435
|
let remaining = 0;
|
|
23436
23436
|
let needTrailerCrlf = false;
|
|
23437
|
+
let cancelled = false;
|
|
23437
23438
|
async function readLine() {
|
|
23438
23439
|
for (;; ) {
|
|
23439
23440
|
for (let i2 = conn.pos;i2 + 1 < conn.len; i2++) {
|
|
@@ -23452,52 +23453,59 @@ function chunkedStream(pool, conn, closeConn) {
|
|
|
23452
23453
|
}
|
|
23453
23454
|
return new ReadableStream({
|
|
23454
23455
|
async pull(controller) {
|
|
23455
|
-
|
|
23456
|
-
|
|
23457
|
-
if (
|
|
23458
|
-
if (conn.
|
|
23459
|
-
|
|
23460
|
-
|
|
23461
|
-
|
|
23456
|
+
try {
|
|
23457
|
+
for (;; ) {
|
|
23458
|
+
if (remaining > 0) {
|
|
23459
|
+
if (conn.len === conn.pos) {
|
|
23460
|
+
if (conn.closed) {
|
|
23461
|
+
pool.destroy(conn);
|
|
23462
|
+
controller.error(new Error("upstream closed mid-chunk"));
|
|
23463
|
+
return;
|
|
23464
|
+
}
|
|
23465
|
+
await conn.waitForData(conn.len);
|
|
23466
|
+
continue;
|
|
23462
23467
|
}
|
|
23463
|
-
|
|
23464
|
-
|
|
23468
|
+
const take = Math.min(remaining, conn.len - conn.pos);
|
|
23469
|
+
controller.enqueue(conn.buf.slice(conn.pos, conn.pos + take));
|
|
23470
|
+
conn.pos += take;
|
|
23471
|
+
remaining -= take;
|
|
23472
|
+
conn.resumeIfDrained();
|
|
23473
|
+
if (remaining === 0)
|
|
23474
|
+
needTrailerCrlf = true;
|
|
23475
|
+
return;
|
|
23465
23476
|
}
|
|
23466
|
-
|
|
23467
|
-
|
|
23468
|
-
|
|
23469
|
-
remaining -= take;
|
|
23470
|
-
conn.resumeIfDrained();
|
|
23471
|
-
if (remaining === 0)
|
|
23472
|
-
needTrailerCrlf = true;
|
|
23473
|
-
return;
|
|
23474
|
-
}
|
|
23475
|
-
if (needTrailerCrlf) {
|
|
23476
|
-
await readLine();
|
|
23477
|
-
needTrailerCrlf = false;
|
|
23478
|
-
}
|
|
23479
|
-
const sizeLine = await readLine();
|
|
23480
|
-
const semi = sizeLine.indexOf(";");
|
|
23481
|
-
const size = Number.parseInt(semi === -1 ? sizeLine : sizeLine.slice(0, semi), 16);
|
|
23482
|
-
if (!Number.isInteger(size) || size < 0) {
|
|
23483
|
-
pool.destroy(conn);
|
|
23484
|
-
controller.error(new Error("upstream sent malformed chunk size"));
|
|
23485
|
-
return;
|
|
23486
|
-
}
|
|
23487
|
-
if (size === 0) {
|
|
23488
|
-
for (;; ) {
|
|
23489
|
-
const t2 = await readLine();
|
|
23490
|
-
if (t2 === "")
|
|
23491
|
-
break;
|
|
23477
|
+
if (needTrailerCrlf) {
|
|
23478
|
+
await readLine();
|
|
23479
|
+
needTrailerCrlf = false;
|
|
23492
23480
|
}
|
|
23493
|
-
|
|
23494
|
-
|
|
23495
|
-
|
|
23481
|
+
const sizeLine = await readLine();
|
|
23482
|
+
const semi = sizeLine.indexOf(";");
|
|
23483
|
+
const size = Number.parseInt(semi === -1 ? sizeLine : sizeLine.slice(0, semi), 16);
|
|
23484
|
+
if (!Number.isInteger(size) || size < 0) {
|
|
23485
|
+
pool.destroy(conn);
|
|
23486
|
+
controller.error(new Error("upstream sent malformed chunk size"));
|
|
23487
|
+
return;
|
|
23488
|
+
}
|
|
23489
|
+
if (size === 0) {
|
|
23490
|
+
for (;; ) {
|
|
23491
|
+
const t2 = await readLine();
|
|
23492
|
+
if (t2 === "")
|
|
23493
|
+
break;
|
|
23494
|
+
}
|
|
23495
|
+
finishConn(pool, conn, closeConn);
|
|
23496
|
+
controller.close();
|
|
23497
|
+
return;
|
|
23498
|
+
}
|
|
23499
|
+
remaining = size;
|
|
23496
23500
|
}
|
|
23497
|
-
|
|
23501
|
+
} catch (error) {
|
|
23502
|
+
pool.destroy(conn);
|
|
23503
|
+
if (!cancelled)
|
|
23504
|
+
controller.error(error);
|
|
23498
23505
|
}
|
|
23499
23506
|
},
|
|
23500
23507
|
cancel() {
|
|
23508
|
+
cancelled = true;
|
|
23501
23509
|
pool.destroy(conn);
|
|
23502
23510
|
}
|
|
23503
23511
|
});
|
|
@@ -24202,6 +24210,7 @@ class OnDemandCertManager {
|
|
|
24202
24210
|
certs = new Map;
|
|
24203
24211
|
inFlight = new Map;
|
|
24204
24212
|
negativeCache = new Map;
|
|
24213
|
+
accountKeyPem;
|
|
24205
24214
|
constructor(opts) {
|
|
24206
24215
|
this.config = opts.config;
|
|
24207
24216
|
this.certsDir = opts.certsDir;
|
|
@@ -24274,13 +24283,16 @@ class OnDemandCertManager {
|
|
|
24274
24283
|
}
|
|
24275
24284
|
try {
|
|
24276
24285
|
debugLog("on-demand", `issuing cert for ${host} (staging=${this.config.staging ?? false})`, this.verbose);
|
|
24286
|
+
this.accountKeyPem ??= await this.loadAccountKey();
|
|
24277
24287
|
const result = await this.issuer({
|
|
24278
24288
|
domains: [host],
|
|
24279
24289
|
method: "http-01",
|
|
24280
24290
|
http01Store: this.http01Store,
|
|
24281
24291
|
email: this.config.email,
|
|
24282
|
-
|
|
24292
|
+
accountKeyPem: this.accountKeyPem,
|
|
24293
|
+
staging: this.config.staging ?? false
|
|
24283
24294
|
});
|
|
24295
|
+
await this.saveAccountKey(result.accountKeyPem);
|
|
24284
24296
|
await this.persist(host, result.fullChainPem, result.keyPem);
|
|
24285
24297
|
const entry = { serverName: host, cert: result.fullChainPem, key: result.keyPem };
|
|
24286
24298
|
this.certs.set(host, entry);
|
|
@@ -24339,8 +24351,25 @@ class OnDemandCertManager {
|
|
|
24339
24351
|
fsp2.writeFile(keyPath, keyPem, { encoding: "utf8", mode: 384 })
|
|
24340
24352
|
]);
|
|
24341
24353
|
}
|
|
24354
|
+
get accountKeyPath() {
|
|
24355
|
+
return path5.join(this.certsDir, ACCOUNT_KEY_FILE);
|
|
24356
|
+
}
|
|
24357
|
+
async loadAccountKey() {
|
|
24358
|
+
try {
|
|
24359
|
+
return await fsp2.readFile(this.accountKeyPath, "utf8");
|
|
24360
|
+
} catch {
|
|
24361
|
+
return;
|
|
24362
|
+
}
|
|
24363
|
+
}
|
|
24364
|
+
async saveAccountKey(pem) {
|
|
24365
|
+
if (!pem || this.accountKeyPem === pem)
|
|
24366
|
+
return;
|
|
24367
|
+
this.accountKeyPem = pem;
|
|
24368
|
+
await fsp2.mkdir(this.certsDir, { recursive: true }).catch(() => {});
|
|
24369
|
+
await fsp2.writeFile(this.accountKeyPath, pem, { encoding: "utf8", mode: 384 }).catch(() => {});
|
|
24370
|
+
}
|
|
24342
24371
|
}
|
|
24343
|
-
var DEFAULT_NEGATIVE_CACHE_MS = 60000, MAX_NEGATIVE_CACHE = 4096;
|
|
24372
|
+
var ACCOUNT_KEY_FILE = "acme-account.key", DEFAULT_NEGATIVE_CACHE_MS = 60000, MAX_NEGATIVE_CACHE = 4096;
|
|
24344
24373
|
var init_on_demand = __esm(() => {
|
|
24345
24374
|
init_src();
|
|
24346
24375
|
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.
|
|
4
|
+
"version": "0.11.35",
|
|
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.
|
|
50
|
+
"@stacksjs/rpx": "0.11.35",
|
|
51
51
|
"@stacksjs/tlsx": "^0.13.13"
|
|
52
52
|
},
|
|
53
53
|
"simple-git-hooks": {
|