@atproto/xrpc-server 0.4.2 → 0.4.3
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/CHANGELOG.md +7 -0
- package/LICENSE.txt +1 -1
- package/dist/auth.d.ts +2 -2
- package/dist/index.js +327 -22
- package/dist/index.js.map +3 -3
- package/dist/rate-limiter.d.ts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/stream/server.d.ts +1 -1
- package/dist/stream/types.d.ts +4 -4
- package/dist/types.d.ts +52 -34
- package/dist/util.d.ts +2 -2
- package/package.json +4 -4
- package/src/rate-limiter.ts +3 -0
- package/src/server.ts +43 -4
- package/src/types.ts +22 -10
- package/src/util.ts +3 -3
package/CHANGELOG.md
CHANGED
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Dual MIT/Apache-2.0 License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022-
|
|
3
|
+
Copyright (c) 2022-2024 Bluesky PBC, and Contributors
|
|
4
4
|
|
|
5
5
|
Except as otherwise noted in individual files, this software is licensed under the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>).
|
|
6
6
|
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as crypto from '@atproto/crypto';
|
|
2
|
-
|
|
2
|
+
type ServiceJwtPayload = {
|
|
3
3
|
iss: string;
|
|
4
4
|
aud: string;
|
|
5
5
|
exp?: number;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type ServiceJwtParams = ServiceJwtPayload & {
|
|
8
8
|
keypair: crypto.Keypair;
|
|
9
9
|
};
|
|
10
10
|
export declare const createServiceJwt: (params: ServiceJwtParams) => Promise<string>;
|
package/dist/index.js
CHANGED
|
@@ -9551,30 +9551,292 @@ var require_dist = __commonJS({
|
|
|
9551
9551
|
}
|
|
9552
9552
|
});
|
|
9553
9553
|
|
|
9554
|
-
// ../../node_modules/.pnpm/
|
|
9554
|
+
// ../../node_modules/.pnpm/detect-libc@2.0.2/node_modules/detect-libc/lib/process.js
|
|
9555
|
+
var require_process = __commonJS({
|
|
9556
|
+
"../../node_modules/.pnpm/detect-libc@2.0.2/node_modules/detect-libc/lib/process.js"(exports, module2) {
|
|
9557
|
+
"use strict";
|
|
9558
|
+
var isLinux = () => process.platform === "linux";
|
|
9559
|
+
var report = null;
|
|
9560
|
+
var getReport = () => {
|
|
9561
|
+
if (!report) {
|
|
9562
|
+
report = isLinux() && process.report ? process.report.getReport() : {};
|
|
9563
|
+
}
|
|
9564
|
+
return report;
|
|
9565
|
+
};
|
|
9566
|
+
module2.exports = { isLinux, getReport };
|
|
9567
|
+
}
|
|
9568
|
+
});
|
|
9569
|
+
|
|
9570
|
+
// ../../node_modules/.pnpm/detect-libc@2.0.2/node_modules/detect-libc/lib/filesystem.js
|
|
9571
|
+
var require_filesystem = __commonJS({
|
|
9572
|
+
"../../node_modules/.pnpm/detect-libc@2.0.2/node_modules/detect-libc/lib/filesystem.js"(exports, module2) {
|
|
9573
|
+
"use strict";
|
|
9574
|
+
var fs = require("fs");
|
|
9575
|
+
var LDD_PATH = "/usr/bin/ldd";
|
|
9576
|
+
var readFileSync = (path) => fs.readFileSync(path, "utf-8");
|
|
9577
|
+
var readFile = (path) => new Promise((resolve, reject) => {
|
|
9578
|
+
fs.readFile(path, "utf-8", (err, data) => {
|
|
9579
|
+
if (err) {
|
|
9580
|
+
reject(err);
|
|
9581
|
+
} else {
|
|
9582
|
+
resolve(data);
|
|
9583
|
+
}
|
|
9584
|
+
});
|
|
9585
|
+
});
|
|
9586
|
+
module2.exports = {
|
|
9587
|
+
LDD_PATH,
|
|
9588
|
+
readFileSync,
|
|
9589
|
+
readFile
|
|
9590
|
+
};
|
|
9591
|
+
}
|
|
9592
|
+
});
|
|
9593
|
+
|
|
9594
|
+
// ../../node_modules/.pnpm/detect-libc@2.0.2/node_modules/detect-libc/lib/detect-libc.js
|
|
9595
|
+
var require_detect_libc = __commonJS({
|
|
9596
|
+
"../../node_modules/.pnpm/detect-libc@2.0.2/node_modules/detect-libc/lib/detect-libc.js"(exports, module2) {
|
|
9597
|
+
"use strict";
|
|
9598
|
+
var childProcess = require("child_process");
|
|
9599
|
+
var { isLinux, getReport } = require_process();
|
|
9600
|
+
var { LDD_PATH, readFile, readFileSync } = require_filesystem();
|
|
9601
|
+
var cachedFamilyFilesystem;
|
|
9602
|
+
var cachedVersionFilesystem;
|
|
9603
|
+
var command = "getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true";
|
|
9604
|
+
var commandOut = "";
|
|
9605
|
+
var safeCommand = () => {
|
|
9606
|
+
if (!commandOut) {
|
|
9607
|
+
return new Promise((resolve) => {
|
|
9608
|
+
childProcess.exec(command, (err, out) => {
|
|
9609
|
+
commandOut = err ? " " : out;
|
|
9610
|
+
resolve(commandOut);
|
|
9611
|
+
});
|
|
9612
|
+
});
|
|
9613
|
+
}
|
|
9614
|
+
return commandOut;
|
|
9615
|
+
};
|
|
9616
|
+
var safeCommandSync = () => {
|
|
9617
|
+
if (!commandOut) {
|
|
9618
|
+
try {
|
|
9619
|
+
commandOut = childProcess.execSync(command, { encoding: "utf8" });
|
|
9620
|
+
} catch (_err) {
|
|
9621
|
+
commandOut = " ";
|
|
9622
|
+
}
|
|
9623
|
+
}
|
|
9624
|
+
return commandOut;
|
|
9625
|
+
};
|
|
9626
|
+
var GLIBC = "glibc";
|
|
9627
|
+
var RE_GLIBC_VERSION = /GLIBC\s(\d+\.\d+)/;
|
|
9628
|
+
var MUSL = "musl";
|
|
9629
|
+
var GLIBC_ON_LDD = GLIBC.toUpperCase();
|
|
9630
|
+
var MUSL_ON_LDD = MUSL.toLowerCase();
|
|
9631
|
+
var isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
|
|
9632
|
+
var familyFromReport = () => {
|
|
9633
|
+
const report = getReport();
|
|
9634
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
9635
|
+
return GLIBC;
|
|
9636
|
+
}
|
|
9637
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
9638
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
9639
|
+
return MUSL;
|
|
9640
|
+
}
|
|
9641
|
+
}
|
|
9642
|
+
return null;
|
|
9643
|
+
};
|
|
9644
|
+
var familyFromCommand = (out) => {
|
|
9645
|
+
const [getconf, ldd1] = out.split(/[\r\n]+/);
|
|
9646
|
+
if (getconf && getconf.includes(GLIBC)) {
|
|
9647
|
+
return GLIBC;
|
|
9648
|
+
}
|
|
9649
|
+
if (ldd1 && ldd1.includes(MUSL)) {
|
|
9650
|
+
return MUSL;
|
|
9651
|
+
}
|
|
9652
|
+
return null;
|
|
9653
|
+
};
|
|
9654
|
+
var getFamilyFromLddContent = (content) => {
|
|
9655
|
+
if (content.includes(MUSL_ON_LDD)) {
|
|
9656
|
+
return MUSL;
|
|
9657
|
+
}
|
|
9658
|
+
if (content.includes(GLIBC_ON_LDD)) {
|
|
9659
|
+
return GLIBC;
|
|
9660
|
+
}
|
|
9661
|
+
return null;
|
|
9662
|
+
};
|
|
9663
|
+
var familyFromFilesystem = async () => {
|
|
9664
|
+
if (cachedFamilyFilesystem !== void 0) {
|
|
9665
|
+
return cachedFamilyFilesystem;
|
|
9666
|
+
}
|
|
9667
|
+
cachedFamilyFilesystem = null;
|
|
9668
|
+
try {
|
|
9669
|
+
const lddContent = await readFile(LDD_PATH);
|
|
9670
|
+
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
|
9671
|
+
} catch (e) {
|
|
9672
|
+
}
|
|
9673
|
+
return cachedFamilyFilesystem;
|
|
9674
|
+
};
|
|
9675
|
+
var familyFromFilesystemSync = () => {
|
|
9676
|
+
if (cachedFamilyFilesystem !== void 0) {
|
|
9677
|
+
return cachedFamilyFilesystem;
|
|
9678
|
+
}
|
|
9679
|
+
cachedFamilyFilesystem = null;
|
|
9680
|
+
try {
|
|
9681
|
+
const lddContent = readFileSync(LDD_PATH);
|
|
9682
|
+
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
|
9683
|
+
} catch (e) {
|
|
9684
|
+
}
|
|
9685
|
+
return cachedFamilyFilesystem;
|
|
9686
|
+
};
|
|
9687
|
+
var family = async () => {
|
|
9688
|
+
let family2 = null;
|
|
9689
|
+
if (isLinux()) {
|
|
9690
|
+
family2 = await familyFromFilesystem();
|
|
9691
|
+
if (!family2) {
|
|
9692
|
+
family2 = familyFromReport();
|
|
9693
|
+
}
|
|
9694
|
+
if (!family2) {
|
|
9695
|
+
const out = await safeCommand();
|
|
9696
|
+
family2 = familyFromCommand(out);
|
|
9697
|
+
}
|
|
9698
|
+
}
|
|
9699
|
+
return family2;
|
|
9700
|
+
};
|
|
9701
|
+
var familySync = () => {
|
|
9702
|
+
let family2 = null;
|
|
9703
|
+
if (isLinux()) {
|
|
9704
|
+
family2 = familyFromFilesystemSync();
|
|
9705
|
+
if (!family2) {
|
|
9706
|
+
family2 = familyFromReport();
|
|
9707
|
+
}
|
|
9708
|
+
if (!family2) {
|
|
9709
|
+
const out = safeCommandSync();
|
|
9710
|
+
family2 = familyFromCommand(out);
|
|
9711
|
+
}
|
|
9712
|
+
}
|
|
9713
|
+
return family2;
|
|
9714
|
+
};
|
|
9715
|
+
var isNonGlibcLinux = async () => isLinux() && await family() !== GLIBC;
|
|
9716
|
+
var isNonGlibcLinuxSync = () => isLinux() && familySync() !== GLIBC;
|
|
9717
|
+
var versionFromFilesystem = async () => {
|
|
9718
|
+
if (cachedVersionFilesystem !== void 0) {
|
|
9719
|
+
return cachedVersionFilesystem;
|
|
9720
|
+
}
|
|
9721
|
+
cachedVersionFilesystem = null;
|
|
9722
|
+
try {
|
|
9723
|
+
const lddContent = await readFile(LDD_PATH);
|
|
9724
|
+
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
|
9725
|
+
if (versionMatch) {
|
|
9726
|
+
cachedVersionFilesystem = versionMatch[1];
|
|
9727
|
+
}
|
|
9728
|
+
} catch (e) {
|
|
9729
|
+
}
|
|
9730
|
+
return cachedVersionFilesystem;
|
|
9731
|
+
};
|
|
9732
|
+
var versionFromFilesystemSync = () => {
|
|
9733
|
+
if (cachedVersionFilesystem !== void 0) {
|
|
9734
|
+
return cachedVersionFilesystem;
|
|
9735
|
+
}
|
|
9736
|
+
cachedVersionFilesystem = null;
|
|
9737
|
+
try {
|
|
9738
|
+
const lddContent = readFileSync(LDD_PATH);
|
|
9739
|
+
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
|
9740
|
+
if (versionMatch) {
|
|
9741
|
+
cachedVersionFilesystem = versionMatch[1];
|
|
9742
|
+
}
|
|
9743
|
+
} catch (e) {
|
|
9744
|
+
}
|
|
9745
|
+
return cachedVersionFilesystem;
|
|
9746
|
+
};
|
|
9747
|
+
var versionFromReport = () => {
|
|
9748
|
+
const report = getReport();
|
|
9749
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
9750
|
+
return report.header.glibcVersionRuntime;
|
|
9751
|
+
}
|
|
9752
|
+
return null;
|
|
9753
|
+
};
|
|
9754
|
+
var versionSuffix = (s) => s.trim().split(/\s+/)[1];
|
|
9755
|
+
var versionFromCommand = (out) => {
|
|
9756
|
+
const [getconf, ldd1, ldd2] = out.split(/[\r\n]+/);
|
|
9757
|
+
if (getconf && getconf.includes(GLIBC)) {
|
|
9758
|
+
return versionSuffix(getconf);
|
|
9759
|
+
}
|
|
9760
|
+
if (ldd1 && ldd2 && ldd1.includes(MUSL)) {
|
|
9761
|
+
return versionSuffix(ldd2);
|
|
9762
|
+
}
|
|
9763
|
+
return null;
|
|
9764
|
+
};
|
|
9765
|
+
var version2 = async () => {
|
|
9766
|
+
let version3 = null;
|
|
9767
|
+
if (isLinux()) {
|
|
9768
|
+
version3 = await versionFromFilesystem();
|
|
9769
|
+
if (!version3) {
|
|
9770
|
+
version3 = versionFromReport();
|
|
9771
|
+
}
|
|
9772
|
+
if (!version3) {
|
|
9773
|
+
const out = await safeCommand();
|
|
9774
|
+
version3 = versionFromCommand(out);
|
|
9775
|
+
}
|
|
9776
|
+
}
|
|
9777
|
+
return version3;
|
|
9778
|
+
};
|
|
9779
|
+
var versionSync = () => {
|
|
9780
|
+
let version3 = null;
|
|
9781
|
+
if (isLinux()) {
|
|
9782
|
+
version3 = versionFromFilesystemSync();
|
|
9783
|
+
if (!version3) {
|
|
9784
|
+
version3 = versionFromReport();
|
|
9785
|
+
}
|
|
9786
|
+
if (!version3) {
|
|
9787
|
+
const out = safeCommandSync();
|
|
9788
|
+
version3 = versionFromCommand(out);
|
|
9789
|
+
}
|
|
9790
|
+
}
|
|
9791
|
+
return version3;
|
|
9792
|
+
};
|
|
9793
|
+
module2.exports = {
|
|
9794
|
+
GLIBC,
|
|
9795
|
+
MUSL,
|
|
9796
|
+
family,
|
|
9797
|
+
familySync,
|
|
9798
|
+
isNonGlibcLinux,
|
|
9799
|
+
isNonGlibcLinuxSync,
|
|
9800
|
+
version: version2,
|
|
9801
|
+
versionSync
|
|
9802
|
+
};
|
|
9803
|
+
}
|
|
9804
|
+
});
|
|
9805
|
+
|
|
9806
|
+
// ../../node_modules/.pnpm/node-gyp-build-optional-packages@5.1.1/node_modules/node-gyp-build-optional-packages/index.js
|
|
9555
9807
|
var require_node_gyp_build_optional_packages = __commonJS({
|
|
9556
|
-
"../../node_modules/.pnpm/node-gyp-build-optional-packages@5.
|
|
9808
|
+
"../../node_modules/.pnpm/node-gyp-build-optional-packages@5.1.1/node_modules/node-gyp-build-optional-packages/index.js"(exports, module2) {
|
|
9557
9809
|
var fs = require("fs");
|
|
9558
9810
|
var path = require("path");
|
|
9559
|
-
var
|
|
9811
|
+
var url = require("url");
|
|
9560
9812
|
var vars = process.config && process.config.variables || {};
|
|
9561
9813
|
var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
|
|
9562
|
-
var
|
|
9814
|
+
var versions = process.versions;
|
|
9815
|
+
var abi = versions.modules;
|
|
9816
|
+
if (versions.deno || process.isBun) {
|
|
9817
|
+
abi = "unsupported";
|
|
9818
|
+
}
|
|
9563
9819
|
var runtime = isElectron() ? "electron" : "node";
|
|
9564
9820
|
var arch = process.arch;
|
|
9565
9821
|
var platform = process.platform;
|
|
9566
|
-
var libc = process.env.LIBC || (
|
|
9822
|
+
var libc = process.env.LIBC || (isMusl(platform) ? "musl" : "glibc");
|
|
9567
9823
|
var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
|
|
9568
|
-
var uv = (
|
|
9824
|
+
var uv = (versions.uv || "").split(".")[0];
|
|
9569
9825
|
module2.exports = load;
|
|
9570
9826
|
function load(dir) {
|
|
9571
|
-
|
|
9827
|
+
if (typeof __webpack_require__ === "function")
|
|
9828
|
+
return __non_webpack_require__(load.path(dir));
|
|
9829
|
+
else
|
|
9830
|
+
return require(load.path(dir));
|
|
9572
9831
|
}
|
|
9573
9832
|
load.path = function(dir) {
|
|
9574
9833
|
dir = path.resolve(dir || ".");
|
|
9575
|
-
var packageName;
|
|
9834
|
+
var packageName = "";
|
|
9576
9835
|
try {
|
|
9577
|
-
|
|
9836
|
+
if (typeof __webpack_require__ === "function")
|
|
9837
|
+
packageName = __non_webpack_require__(path.join(dir, "package.json")).name;
|
|
9838
|
+
else
|
|
9839
|
+
packageName = require(path.join(dir, "package.json")).name;
|
|
9578
9840
|
var varName = packageName.toUpperCase().replace(/-/g, "_") + "_PREBUILD";
|
|
9579
9841
|
if (process.env[varName])
|
|
9580
9842
|
dir = process.env[varName];
|
|
@@ -9596,7 +9858,7 @@ var require_node_gyp_build_optional_packages = __commonJS({
|
|
|
9596
9858
|
return nearby;
|
|
9597
9859
|
var platformPackage = (packageName[0] == "@" ? "" : "@" + packageName + "/") + packageName + "-" + platform + "-" + arch;
|
|
9598
9860
|
try {
|
|
9599
|
-
var prebuildPackage = path.dirname(require("module").createRequire(path.join(dir, "package.json")).resolve(platformPackage));
|
|
9861
|
+
var prebuildPackage = path.dirname(require("module").createRequire(url.pathToFileURL(path.join(dir, "package.json"))).resolve(platformPackage));
|
|
9600
9862
|
return resolveFile(prebuildPackage);
|
|
9601
9863
|
} catch (error) {
|
|
9602
9864
|
}
|
|
@@ -9612,7 +9874,7 @@ var require_node_gyp_build_optional_packages = __commonJS({
|
|
|
9612
9874
|
process.versions.electron ? "electron=" + process.versions.electron : "",
|
|
9613
9875
|
typeof __webpack_require__ === "function" ? "webpack=true" : ""
|
|
9614
9876
|
].filter(Boolean).join(" ");
|
|
9615
|
-
throw new Error("No native build was found for " + target2 + "\n
|
|
9877
|
+
throw new Error("No native build was found for " + target2 + "\n attempted loading from: " + dir + " and package: " + platformPackage + "\n");
|
|
9616
9878
|
function resolve(dir2) {
|
|
9617
9879
|
var tuples = readdirSync(path.join(dir2, "prebuilds")).map(parseTuple);
|
|
9618
9880
|
var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
|
|
@@ -9735,8 +9997,11 @@ var require_node_gyp_build_optional_packages = __commonJS({
|
|
|
9735
9997
|
return true;
|
|
9736
9998
|
return typeof window !== "undefined" && window.process && window.process.type === "renderer";
|
|
9737
9999
|
}
|
|
9738
|
-
function
|
|
9739
|
-
|
|
10000
|
+
function isMusl(platform2) {
|
|
10001
|
+
if (platform2 !== "linux")
|
|
10002
|
+
return false;
|
|
10003
|
+
const { familySync, MUSL } = require_detect_libc();
|
|
10004
|
+
return familySync() === MUSL;
|
|
9740
10005
|
}
|
|
9741
10006
|
load.parseTags = parseTags;
|
|
9742
10007
|
load.matchTags = matchTags;
|
|
@@ -9747,9 +10012,9 @@ var require_node_gyp_build_optional_packages = __commonJS({
|
|
|
9747
10012
|
}
|
|
9748
10013
|
});
|
|
9749
10014
|
|
|
9750
|
-
// ../../node_modules/.pnpm/cbor-extract@2.
|
|
10015
|
+
// ../../node_modules/.pnpm/cbor-extract@2.2.0/node_modules/cbor-extract/index.js
|
|
9751
10016
|
var require_cbor_extract = __commonJS({
|
|
9752
|
-
"../../node_modules/.pnpm/cbor-extract@2.
|
|
10017
|
+
"../../node_modules/.pnpm/cbor-extract@2.2.0/node_modules/cbor-extract/index.js"(exports, module2) {
|
|
9753
10018
|
module2.exports = require_node_gyp_build_optional_packages()(__dirname);
|
|
9754
10019
|
}
|
|
9755
10020
|
});
|
|
@@ -28171,7 +28436,7 @@ var require_object_inspect = __commonJS({
|
|
|
28171
28436
|
if (isBoolean(obj)) {
|
|
28172
28437
|
return markBoxed(booleanValueOf.call(obj));
|
|
28173
28438
|
}
|
|
28174
|
-
if (
|
|
28439
|
+
if (isString2(obj)) {
|
|
28175
28440
|
return markBoxed(inspect(String(obj)));
|
|
28176
28441
|
}
|
|
28177
28442
|
if (!isDate(obj) && !isRegExp(obj)) {
|
|
@@ -28210,7 +28475,7 @@ var require_object_inspect = __commonJS({
|
|
|
28210
28475
|
function isError(obj) {
|
|
28211
28476
|
return toStr(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
28212
28477
|
}
|
|
28213
|
-
function
|
|
28478
|
+
function isString2(obj) {
|
|
28214
28479
|
return toStr(obj) === "[object String]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
|
|
28215
28480
|
}
|
|
28216
28481
|
function isNumber(obj) {
|
|
@@ -39777,6 +40042,7 @@ __export(src_exports5, {
|
|
|
39777
40042
|
handlerAuth: () => handlerAuth,
|
|
39778
40043
|
handlerError: () => handlerError,
|
|
39779
40044
|
handlerInput: () => handlerInput,
|
|
40045
|
+
handlerPipeThrough: () => handlerPipeThrough,
|
|
39780
40046
|
handlerSuccess: () => handlerSuccess,
|
|
39781
40047
|
isHandlerError: () => isHandlerError,
|
|
39782
40048
|
isShared: () => isShared,
|
|
@@ -46270,6 +46536,11 @@ var handlerSuccess = z.object({
|
|
|
46270
46536
|
body: z.any(),
|
|
46271
46537
|
headers: z.record(z.string()).optional()
|
|
46272
46538
|
});
|
|
46539
|
+
var handlerPipeThrough = z.object({
|
|
46540
|
+
encoding: z.string(),
|
|
46541
|
+
buffer: z.instanceof(ArrayBuffer),
|
|
46542
|
+
headers: z.record(z.string()).optional()
|
|
46543
|
+
});
|
|
46273
46544
|
var handlerError = z.object({
|
|
46274
46545
|
status: z.number(),
|
|
46275
46546
|
error: z.string().optional(),
|
|
@@ -52574,7 +52845,7 @@ function validateInput(nsid2, def2, req, opts, lexicons) {
|
|
|
52574
52845
|
if (req.readableEnded) {
|
|
52575
52846
|
body = req.body;
|
|
52576
52847
|
} else {
|
|
52577
|
-
body = decodeBodyStream(req, opts.
|
|
52848
|
+
body = decodeBodyStream(req, opts.blobLimit);
|
|
52578
52849
|
}
|
|
52579
52850
|
return {
|
|
52580
52851
|
encoding: inputEncoding,
|
|
@@ -52720,6 +52991,9 @@ var RateLimiter = class {
|
|
|
52720
52991
|
return null;
|
|
52721
52992
|
}
|
|
52722
52993
|
const key = opts?.calcKey ? opts.calcKey(ctx) : this.calcKey(ctx);
|
|
52994
|
+
if (key === null) {
|
|
52995
|
+
return null;
|
|
52996
|
+
}
|
|
52723
52997
|
const points = opts?.calcPoints ? opts.calcPoints(ctx) : this.calcPoints(ctx);
|
|
52724
52998
|
if (points < 1) {
|
|
52725
52999
|
return null;
|
|
@@ -52883,7 +53157,7 @@ var Server = class {
|
|
|
52883
53157
|
middleware.push(this.middleware.text);
|
|
52884
53158
|
}
|
|
52885
53159
|
this.setupRouteRateLimits(nsid2, config2);
|
|
52886
|
-
this.routes[verb](`/xrpc/${nsid2}`, ...middleware, this.createHandler(nsid2, def2, config2
|
|
53160
|
+
this.routes[verb](`/xrpc/${nsid2}`, ...middleware, this.createHandler(nsid2, def2, config2));
|
|
52887
53161
|
}
|
|
52888
53162
|
async catchall(req, _res, next) {
|
|
52889
53163
|
const def2 = this.lex.getDef(req.params.methodId);
|
|
@@ -52897,8 +53171,11 @@ var Server = class {
|
|
|
52897
53171
|
}
|
|
52898
53172
|
return next();
|
|
52899
53173
|
}
|
|
52900
|
-
createHandler(nsid2, def2,
|
|
52901
|
-
const
|
|
53174
|
+
createHandler(nsid2, def2, routeCfg) {
|
|
53175
|
+
const routeOpts = {
|
|
53176
|
+
blobLimit: routeCfg.opts?.blobLimit ?? this.options.payload?.blobLimit
|
|
53177
|
+
};
|
|
53178
|
+
const validateReqInput = (req) => validateInput(nsid2, def2, req, routeOpts, this.lex);
|
|
52902
53179
|
const validateResOutput = this.options.validateResponse === false ? (output2) => output2 : (output2) => validateOutput(nsid2, def2, output2, this.lex);
|
|
52903
53180
|
const assertValidXrpcParams2 = (params2) => this.lex.assertValidXrpcParams(nsid2, params2);
|
|
52904
53181
|
const rlFns = this.routeRateLimiterFns[nsid2] ?? [];
|
|
@@ -52927,10 +53204,19 @@ var Server = class {
|
|
|
52927
53204
|
if (result instanceof RateLimitExceededError) {
|
|
52928
53205
|
return next(result);
|
|
52929
53206
|
}
|
|
52930
|
-
const outputUnvalidated = await handler(reqCtx);
|
|
53207
|
+
const outputUnvalidated = await routeCfg.handler(reqCtx);
|
|
52931
53208
|
if (isHandlerError(outputUnvalidated)) {
|
|
52932
53209
|
throw XRPCError2.fromError(outputUnvalidated);
|
|
52933
53210
|
}
|
|
53211
|
+
if (outputUnvalidated && isHandlerPipeThrough(outputUnvalidated)) {
|
|
53212
|
+
if (outputUnvalidated?.headers) {
|
|
53213
|
+
Object.entries(outputUnvalidated.headers).forEach(([name2, val]) => {
|
|
53214
|
+
res.header(name2, val);
|
|
53215
|
+
});
|
|
53216
|
+
}
|
|
53217
|
+
res.header("Content-Type", outputUnvalidated.encoding).status(200).send(Buffer.from(outputUnvalidated.buffer));
|
|
53218
|
+
return;
|
|
53219
|
+
}
|
|
52934
53220
|
if (!outputUnvalidated || isHandlerSuccess(outputUnvalidated)) {
|
|
52935
53221
|
const output2 = validateResOutput(outputUnvalidated);
|
|
52936
53222
|
if (output2?.headers) {
|
|
@@ -53072,6 +53358,24 @@ var Server = class {
|
|
|
53072
53358
|
function isHandlerSuccess(v) {
|
|
53073
53359
|
return handlerSuccess.safeParse(v).success;
|
|
53074
53360
|
}
|
|
53361
|
+
function isHandlerPipeThrough(v) {
|
|
53362
|
+
if (v === null || typeof v !== "object") {
|
|
53363
|
+
return false;
|
|
53364
|
+
}
|
|
53365
|
+
if (!isString(v["encoding"]) || !(v["buffer"] instanceof ArrayBuffer)) {
|
|
53366
|
+
return false;
|
|
53367
|
+
}
|
|
53368
|
+
if (v["headers"] !== void 0) {
|
|
53369
|
+
if (v["headers"] === null || typeof v["headers"] !== "object") {
|
|
53370
|
+
return false;
|
|
53371
|
+
}
|
|
53372
|
+
if (!Object.values(v["headers"]).every(isString)) {
|
|
53373
|
+
return false;
|
|
53374
|
+
}
|
|
53375
|
+
}
|
|
53376
|
+
return true;
|
|
53377
|
+
}
|
|
53378
|
+
var isString = (val) => typeof val === "string";
|
|
53075
53379
|
var kRequestLocals = Symbol("requestLocals");
|
|
53076
53380
|
function createLocalsMiddleware(nsid2) {
|
|
53077
53381
|
return function(req, _res, next) {
|
|
@@ -53151,6 +53455,7 @@ var errorMiddleware = function(err, req, res, next) {
|
|
|
53151
53455
|
handlerAuth,
|
|
53152
53456
|
handlerError,
|
|
53153
53457
|
handlerInput,
|
|
53458
|
+
handlerPipeThrough,
|
|
53154
53459
|
handlerSuccess,
|
|
53155
53460
|
isHandlerError,
|
|
53156
53461
|
isShared,
|