update post-note.ts
This commit is contained in:
@@ -17,15 +17,15 @@ export function getFetchAutoProxyInit(): RequestInit | undefined {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchWithTimoutAndAutoProxy(
|
export async function fetchWithTimeoutAndAutoProxy(
|
||||||
input: URL | Request | string,
|
input: URL | Request | string,
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
initCallback?: (init: RequestInit) => RequestInit,
|
initCallback?: (init: RequestInit) => RequestInit,
|
||||||
): Promise<Response> {
|
): Promise<Response> {
|
||||||
const fetchTimeout = timeout || 10000;
|
const fetchTimeout = timeout || 10000;
|
||||||
const abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
const timoutHandler = setTimeout(() => {
|
const timeoutHandler = setTimeout(() => {
|
||||||
abortController.abort(`Timout ${fetchTimeout} ms`);
|
abortController.abort(`Timeout ${fetchTimeout} ms`);
|
||||||
}, fetchTimeout);
|
}, fetchTimeout);
|
||||||
let init = getFetchAutoProxyInit() || {};
|
let init = getFetchAutoProxyInit() || {};
|
||||||
init.signal = abortController.signal;
|
init.signal = abortController.signal;
|
||||||
@@ -33,6 +33,6 @@ export async function fetchWithTimoutAndAutoProxy(
|
|||||||
init = initCallback(init);
|
init = initCallback(init);
|
||||||
}
|
}
|
||||||
const response = await fetch(input, init);
|
const response = await fetch(input, init);
|
||||||
clearTimeout(timoutHandler);
|
clearTimeout(timeoutHandler);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,12 +141,12 @@
|
|||||||
},
|
},
|
||||||
"post-note.ts": {
|
"post-note.ts": {
|
||||||
"script_name": "post-note.ts",
|
"script_name": "post-note.ts",
|
||||||
"script_length": 2025,
|
"script_length": 2019,
|
||||||
"script_sha256": "ed3d797d90c845b569c3280749cba07695951c555c99e70febd0fcc65de85db9",
|
"script_sha256": "75b2d9c0e0a42a4dd19896bfbdf973f2ad4e5e67aea76400920bfbf41d657bff",
|
||||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/post-note.ts",
|
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/post-note.ts",
|
||||||
"single_script_file": true,
|
"single_script_file": true,
|
||||||
"publish_time": 1737475603673,
|
"publish_time": 1737475603673,
|
||||||
"update_time": 1751675304726
|
"update_time": 1769525452943
|
||||||
},
|
},
|
||||||
"print-env.ts": {
|
"print-env.ts": {
|
||||||
"script_name": "print-env.ts",
|
"script_name": "print-env.ts",
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env runts -- --allow-env --allow-import --allow-net
|
#!/usr/bin/env runts -- --allow-env --allow-import --allow-net
|
||||||
|
|
||||||
import { parseArgs } from "jsr:@std/cli/parse-args";
|
import {parseArgs} from "jsr:@std/cli/parse-args";
|
||||||
import { encryptEcdhP256 } from "https://global.hatter.ink/script/get/@0/deno-wrapkey-mod.ts";
|
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 {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 {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 endpoint = Deno.env.get("POST_ENCRYPTED_NOTE_ENDPOINT");
|
||||||
const publicKeyPointHex = Deno.env.get("ENCRYPTION_PUBLIC_KEY_POINT_HEX");
|
const publicKeyPointHex = Deno.env.get("ENCRYPTION_PUBLIC_KEY_POINT_HEX");
|
||||||
@@ -54,11 +54,11 @@ if (flags["post-message"]) {
|
|||||||
args.push("postMessage=true");
|
args.push("postMessage=true");
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetchWithTimoutAndAutoProxy(
|
const response = await fetchWithTimeoutAndAutoProxy(
|
||||||
`${endpoint}?${args.join("&")}`,
|
`${endpoint}?${args.join("&")}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.info(response.status, await response.json());
|
console.info(response.status, await response.json());
|
||||||
|
|
||||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20250705T082352+08:00.MEUCIQCXIiNRCQYEV3S5tDmu
|
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260127T224542+08:00.MEUCIQDg4zKtOOdd95j7LqzA
|
||||||
// j/1mMjlNjHne9gWjxNJuJuz8pQIgNtTvQ4XwngDgNSAGYCUDCgB7abitnVUsG+NRVwJJurw=
|
// kNqHczlfJblEWj3Q6WE3RxzxKQIgJuopk5tUHS9Iyx/Sd85R+SbPA3axAaP8TVVMCZlFZso=
|
||||||
|
|||||||
Reference in New Issue
Block a user