update post-note.ts

This commit is contained in:
2026-01-27 22:51:04 +08:00
parent c1e2768139
commit 377eced510
3 changed files with 14 additions and 14 deletions

View File

@@ -17,15 +17,15 @@ export function getFetchAutoProxyInit(): RequestInit | undefined {
return undefined;
}
export async function fetchWithTimoutAndAutoProxy(
export async function fetchWithTimeoutAndAutoProxy(
input: URL | Request | string,
timeout?: number,
initCallback?: (init: RequestInit) => RequestInit,
): Promise<Response> {
const fetchTimeout = timeout || 10000;
const abortController = new AbortController();
const timoutHandler = setTimeout(() => {
abortController.abort(`Timout ${fetchTimeout} ms`);
const timeoutHandler = setTimeout(() => {
abortController.abort(`Timeout ${fetchTimeout} ms`);
}, fetchTimeout);
let init = getFetchAutoProxyInit() || {};
init.signal = abortController.signal;
@@ -33,6 +33,6 @@ export async function fetchWithTimoutAndAutoProxy(
init = initCallback(init);
}
const response = await fetch(input, init);
clearTimeout(timoutHandler);
clearTimeout(timeoutHandler);
return response;
}

View File

@@ -141,12 +141,12 @@
},
"post-note.ts": {
"script_name": "post-note.ts",
"script_length": 2025,
"script_sha256": "ed3d797d90c845b569c3280749cba07695951c555c99e70febd0fcc65de85db9",
"script_length": 2019,
"script_sha256": "75b2d9c0e0a42a4dd19896bfbdf973f2ad4e5e67aea76400920bfbf41d657bff",
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/post-note.ts",
"single_script_file": true,
"publish_time": 1737475603673,
"update_time": 1751675304726
"update_time": 1769525452943
},
"print-env.ts": {
"script_name": "print-env.ts",

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env runts -- --allow-env --allow-import --allow-net
import { parseArgs } from "jsr:@std/cli/parse-args";
import { encryptEcdhP256 } from "https://global.hatter.ink/script/get/@0/deno-wrapkey-mod.ts";
import { log } from "https://global.hatter.ink/script/get/@1/deno-commons-mod.ts";
import { fetchWithTimoutAndAutoProxy } from "https://global.hatter.ink/script/get/@0/deno-fetch-auto-proxy-mod.ts";
import {parseArgs} from "jsr:@std/cli/parse-args";
import {encryptEcdhP256} from "https://global.hatter.ink/script/get/@0/deno-wrapkey-mod.ts";
import {log} from "https://global.hatter.ink/script/get/@1/deno-commons-mod.ts";
import {fetchWithTimeoutAndAutoProxy} from "https://global.hatter.ink/script/get/@1/deno-fetch-auto-proxy-mod.ts";
const endpoint = Deno.env.get("POST_ENCRYPTED_NOTE_ENDPOINT");
const publicKeyPointHex = Deno.env.get("ENCRYPTION_PUBLIC_KEY_POINT_HEX");
@@ -54,11 +54,11 @@ if (flags["post-message"]) {
args.push("postMessage=true");
}
const response = await fetchWithTimoutAndAutoProxy(
const response = await fetchWithTimeoutAndAutoProxy(
`${endpoint}?${args.join("&")}`,
);
console.info(response.status, await response.json());
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20250705T082352+08:00.MEUCIQCXIiNRCQYEV3S5tDmu
// j/1mMjlNjHne9gWjxNJuJuz8pQIgNtTvQ4XwngDgNSAGYCUDCgB7abitnVUsG+NRVwJJurw=
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260127T224542+08:00.MEUCIQDg4zKtOOdd95j7LqzA
// kNqHczlfJblEWj3Q6WE3RxzxKQIgJuopk5tUHS9Iyx/Sd85R+SbPA3axAaP8TVVMCZlFZso=