mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Merge branch 'safe-fetch' into 'main'
Upgrade safe-fetch See merge request soapbox-pub/ditto!586
This commit is contained in:
commit
8a46d399fd
6 changed files with 28 additions and 13 deletions
|
|
@ -50,6 +50,7 @@
|
|||
"@scure/base": "npm:@scure/base@^1.1.6",
|
||||
"@sentry/deno": "https://deno.land/x/sentry@7.112.2/index.mjs",
|
||||
"@soapbox/kysely-pglite": "jsr:@soapbox/kysely-pglite@^1.0.0",
|
||||
"@soapbox/safe-fetch": "jsr:@soapbox/safe-fetch@^2.0.0",
|
||||
"@soapbox/stickynotes": "jsr:@soapbox/stickynotes@^0.4.0",
|
||||
"@std/assert": "jsr:@std/assert@^0.225.1",
|
||||
"@std/cli": "jsr:@std/cli@^0.223.0",
|
||||
|
|
@ -63,7 +64,6 @@
|
|||
"comlink": "npm:comlink@^4.4.1",
|
||||
"comlink-async-generator": "npm:comlink-async-generator@^0.0.1",
|
||||
"commander": "npm:commander@12.1.0",
|
||||
"deno-safe-fetch/load": "https://gitlab.com/soapbox-pub/deno-safe-fetch/-/raw/v1.0.0/load.ts",
|
||||
"deno.json": "./deno.json",
|
||||
"entities": "npm:entities@^4.5.0",
|
||||
"fast-stable-stringify": "npm:fast-stable-stringify@^1.0.0",
|
||||
|
|
|
|||
20
deno.lock
generated
20
deno.lock
generated
|
|
@ -46,6 +46,7 @@
|
|||
"jsr:@nostrify/types@0.35": "0.35.0",
|
||||
"jsr:@nostrify/types@~0.30.1": "0.30.1",
|
||||
"jsr:@soapbox/kysely-pglite@1": "1.0.0",
|
||||
"jsr:@soapbox/safe-fetch@2": "2.0.0",
|
||||
"jsr:@soapbox/stickynotes@0.4": "0.4.0",
|
||||
"jsr:@std/assert@0.223": "0.223.0",
|
||||
"jsr:@std/assert@0.224": "0.224.0",
|
||||
|
|
@ -120,6 +121,7 @@
|
|||
"npm:prom-client@^15.1.2": "15.1.2",
|
||||
"npm:sharp@~0.33.5": "0.33.5",
|
||||
"npm:tldts@^6.0.14": "6.1.18",
|
||||
"npm:tldts@^6.1.61": "6.1.61",
|
||||
"npm:tseep@^1.2.1": "1.2.1",
|
||||
"npm:type-fest@^4.3.0": "4.18.2",
|
||||
"npm:unfurl.js@^6.4.0": "6.4.0",
|
||||
|
|
@ -483,6 +485,12 @@
|
|||
"npm:kysely@~0.27.4"
|
||||
]
|
||||
},
|
||||
"@soapbox/safe-fetch@2.0.0": {
|
||||
"integrity": "f451d686501c76a0faa058fe9d2073676282a8a42c3b93c59159eb9191f11b5f",
|
||||
"dependencies": [
|
||||
"npm:tldts@^6.1.61"
|
||||
]
|
||||
},
|
||||
"@soapbox/stickynotes@0.4.0": {
|
||||
"integrity": "60bfe61ab3d7e04bf708273b1e2d391a59534bdf29e54160e98d7afd328ca1ec"
|
||||
},
|
||||
|
|
@ -1522,6 +1530,9 @@
|
|||
"tldts-core@6.1.49": {
|
||||
"integrity": "sha512-ctRO/wzBasOCxAStJG/60Qe8/QpGmaVPsE8djdk0vioxN4uCOgKoveH71Qc2EOmVMIjVf0BjigI5p9ZDuLOygg=="
|
||||
},
|
||||
"tldts-core@6.1.61": {
|
||||
"integrity": "sha512-In7VffkDWUPgwa+c9picLUxvb0RltVwTkSgMNFgvlGSWveCzGBemBqTsgJCL4EDFWZ6WH0fKTsot6yNhzy3ZzQ=="
|
||||
},
|
||||
"tldts@6.1.18": {
|
||||
"integrity": "sha512-F+6zjPFnFxZ0h6uGb8neQWwHQm8u3orZVFribsGq4eBgEVrzSkHxzWS2l6aKr19T1vXiOMFjqfff4fQt+WgJFg==",
|
||||
"dependencies": [
|
||||
|
|
@ -1534,6 +1545,12 @@
|
|||
"tldts-core@6.1.49"
|
||||
]
|
||||
},
|
||||
"tldts@6.1.61": {
|
||||
"integrity": "sha512-rv8LUyez4Ygkopqn+M6OLItAOT9FF3REpPQDkdMx5ix8w4qkuE7Vo2o/vw1nxKQYmJDV8JpAMJQr1b+lTKf0FA==",
|
||||
"dependencies": [
|
||||
"tldts-core@6.1.61"
|
||||
]
|
||||
},
|
||||
"to-regex-range@5.0.1": {
|
||||
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
||||
"dependencies": [
|
||||
|
|
@ -2181,8 +2198,6 @@
|
|||
"https://deno.land/x/sentry@7.112.2/index.mjs": "04382d5c2f4e233ba389611db46f77943b2a7f6efbeaaf31193f6e586f4366ef",
|
||||
"https://esm.sh/kysely@0.17.1/dist/esm/index-nodeless.js": "9c23bfd307118e3ccd3a9f0ec1261fc3451fb5301aa34aa6f28e05156818755a",
|
||||
"https://esm.sh/v135/kysely@0.17.1/denonext/dist/esm/index-nodeless.js": "6f73bbf2d73bc7e96cdabf941c4ae8c12f58fd7b441031edec44c029aed9532b",
|
||||
"https://gitlab.com/soapbox-pub/deno-safe-fetch/-/raw/v1.0.0/load.ts": "3f74ab08cf97d4a3e6994cb79422e9b0069495e017416858121d5ff8ae04ac2a",
|
||||
"https://gitlab.com/soapbox-pub/deno-safe-fetch/-/raw/v1.0.0/mod.ts": "5f505cd265aefbcb687cde6f98c79344d3292ee1dd978e85e5ffa84a617c6682",
|
||||
"https://gitlab.com/soapbox-pub/kysely-deno-postgres/-/raw/b4725e74ad6ca359ba0e370b55dbb8bb845a8a83/deps.ts": "b3dbecae69c30a5f161323b8c8ebd91d9af1eceb98fafab3091c7281a4b64fed",
|
||||
"https://gitlab.com/soapbox-pub/kysely-deno-postgres/-/raw/b4725e74ad6ca359ba0e370b55dbb8bb845a8a83/mod.ts": "662438fd3909984bb8cbaf3fd44d2121e949d11301baf21d6c3f057ccf9887de",
|
||||
"https://gitlab.com/soapbox-pub/kysely-deno-postgres/-/raw/b4725e74ad6ca359ba0e370b55dbb8bb845a8a83/src/PostgreSQLDriver.ts": "ea5a523bceeed420858b744beeb95d48976cb2b0d3f519a68b65a8229036cf6a",
|
||||
|
|
@ -2272,6 +2287,7 @@
|
|||
"jsr:@nostrify/nostrify@0.36",
|
||||
"jsr:@nostrify/policies@0.35",
|
||||
"jsr:@soapbox/kysely-pglite@1",
|
||||
"jsr:@soapbox/safe-fetch@2",
|
||||
"jsr:@soapbox/stickynotes@0.4",
|
||||
"jsr:@std/assert@~0.225.1",
|
||||
"jsr:@std/cli@0.223",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import 'deno-safe-fetch/load';
|
||||
|
||||
import '@/precheck.ts';
|
||||
import '@/sentry.ts';
|
||||
import '@/nostr-wasm.ts';
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import { fetchWorker } from '@/workers/fetch.ts';
|
|||
Deno.test({
|
||||
name: 'fetchWorker',
|
||||
async fn() {
|
||||
const response = await fetchWorker('http://httpbin.org/get');
|
||||
const response = await fetchWorker('https://httpbingo.org/get');
|
||||
const json = await response.json();
|
||||
assertEquals(json.headers.Host, 'httpbin.org');
|
||||
assertEquals(json.headers.Host, ['httpbingo.org']);
|
||||
},
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
|
@ -19,7 +19,7 @@ Deno.test({
|
|||
const signal = controller.signal;
|
||||
|
||||
setTimeout(() => controller.abort(), 100);
|
||||
assertRejects(() => fetchWorker('http://httpbin.org/delay/10', { signal }));
|
||||
assertRejects(() => fetchWorker('https://httpbingo.org/delay/10', { signal }));
|
||||
|
||||
await new Promise<void>((resolve) => {
|
||||
signal.addEventListener('abort', () => resolve(), { once: true });
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
/// <reference lib="webworker" />
|
||||
|
||||
import Debug from '@soapbox/stickynotes/debug';
|
||||
import { safeFetch } from '@soapbox/safe-fetch';
|
||||
import { Stickynotes } from '@soapbox/stickynotes';
|
||||
import * as Comlink from 'comlink';
|
||||
|
||||
import '@/workers/handlers/abortsignal.ts';
|
||||
import '@/sentry.ts';
|
||||
|
||||
const debug = Debug('ditto:fetch.worker');
|
||||
const console = new Stickynotes('ditto:fetch.worker');
|
||||
|
||||
export const FetchWorker = {
|
||||
async fetch(
|
||||
|
|
@ -14,8 +15,8 @@ export const FetchWorker = {
|
|||
init: Omit<RequestInit, 'signal'>,
|
||||
signal: AbortSignal | null | undefined,
|
||||
): Promise<[BodyInit, ResponseInit]> {
|
||||
debug(init.method, url);
|
||||
const response = await fetch(url, { ...init, signal });
|
||||
console.debug(init.method, url);
|
||||
const response = await safeFetch(url, { ...init, signal });
|
||||
return [
|
||||
await response.arrayBuffer(),
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import 'deno-safe-fetch/load';
|
||||
import '@soapbox/safe-fetch/load';
|
||||
import { NostrEvent, NostrRelayOK, NPolicy } from '@nostrify/nostrify';
|
||||
import { ReadOnlyPolicy } from '@nostrify/policies';
|
||||
import * as Comlink from 'comlink';
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue