mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-25 03:17:38 -07:00
Revert "[backend] Improve JSON-LD context size limiter"
This reverts commit 9a8b7efcd6
.
This commit is contained in:
parent
e9f776c7b2
commit
5c659b1306
1 changed files with 5 additions and 7 deletions
|
@ -122,12 +122,11 @@ export class LdSignature {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async fetchDocument(url: string) {
|
private async fetchDocument(url: string) {
|
||||||
const ctrl = new AbortController();
|
const json = await fetch(url, {
|
||||||
return await fetch(url, {
|
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/ld+json, application/json",
|
Accept: "application/ld+json, application/json",
|
||||||
},
|
},
|
||||||
signal: ctrl.signal,
|
size: 1024 * 1024, // 1MiB
|
||||||
// TODO
|
// TODO
|
||||||
//timeout: this.loderTimeout,
|
//timeout: this.loderTimeout,
|
||||||
agent: (u) => (u.protocol === "http:" ? httpAgent : httpsAgent),
|
agent: (u) => (u.protocol === "http:" ? httpAgent : httpsAgent),
|
||||||
|
@ -135,12 +134,11 @@ export class LdSignature {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error(`${res.status} ${res.statusText}`);
|
throw new Error(`${res.status} ${res.statusText}`);
|
||||||
} else {
|
} else {
|
||||||
if (res.size < 1024 * 1024) // 1MiB
|
|
||||||
return res.json();
|
return res.json();
|
||||||
ctrl.abort();
|
|
||||||
throw new Error('Size exceeded 1MiB');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
public sha256(data: string): string {
|
public sha256(data: string): string {
|
||||||
|
|
Loading…
Reference in a new issue