updates
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
// - https://docs.deno.com/runtime/fundamentals/testing/
|
||||
|
||||
import {decodeBase64, encodeBase64} from "jsr:@std/encoding/base64";
|
||||
import {dirname, fromFileUrl} from "https://deno.land/std/path/mod.ts";
|
||||
import {dirname, fromFileUrl} from "jsr:@std/path";
|
||||
import {toArrayBuffer} from "jsr:@std/streams";
|
||||
import {spawn, SpawnOptionsWithoutStdio} from "node:child_process";
|
||||
import {mkdir, readFile, readFileSync, rm, writeFile} from "node:fs";
|
||||
|
||||
@@ -22,6 +23,36 @@ export function osEnv(key: string): string | undefined {
|
||||
return isDeno() ? Deno.env.get(key) : process.env[key];
|
||||
}
|
||||
|
||||
export function stdin(): ReadableStream {
|
||||
return isDeno() ? Deno.stdin.readable : process.stdin;
|
||||
}
|
||||
|
||||
function streamToArrayBuffer(stream) {
|
||||
const chunks = [];
|
||||
return new Promise((resolve, reject) => {
|
||||
stream.on("error", (err) => reject(err));
|
||||
stream.on("data", (chunk) => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
stream.on("end", () => {
|
||||
const buffer = Buffer.concat(chunks);
|
||||
resolve(
|
||||
buffer.buffer.slice(
|
||||
buffer.byteOffset,
|
||||
buffer.byteOffset + buffer.byteLength,
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function stdinToArrayBuffer(): Promise<ArrayBuffer> {
|
||||
if (isDeno()) {
|
||||
return toArrayBuffer(Deno.stdin.readable);
|
||||
}
|
||||
return streamToArrayBuffer(process.stdin);
|
||||
}
|
||||
|
||||
export function exit(code?: number): never {
|
||||
isDeno() ? Deno.exit(code) : process.exit(code);
|
||||
}
|
||||
@@ -222,7 +253,7 @@ export function parseIntVal(val: any, defaultVal: number): number {
|
||||
}
|
||||
|
||||
export function getEnv(envKey: string): string | null {
|
||||
const homeDir = homeDir();
|
||||
const homeDir = getHomeDir();
|
||||
if ((homeDir !== null) && envKey) {
|
||||
const envValue = readFileToStringSync(
|
||||
`${homeDir}/.config/envs/${envKey}`,
|
||||
@@ -705,18 +736,18 @@ export function getHomeDirOrDie(): string {
|
||||
}
|
||||
|
||||
export function homeDirOrDie(): string {
|
||||
const homeDir = homeDir();
|
||||
const homeDir = getHomeDir();
|
||||
if (homeDir === null) {
|
||||
throw new Error("Cannot find home dir");
|
||||
}
|
||||
return homeDir;
|
||||
}
|
||||
|
||||
export function getHomeDir(): string | null {
|
||||
return homeDir();
|
||||
export function homeDir(): string | null {
|
||||
return getHomeDir();
|
||||
}
|
||||
|
||||
export function homeDir(): string | null {
|
||||
export function getHomeDir(): string | null {
|
||||
// if (Deno.build.os === "windows") {
|
||||
// const userProfile = osEnv("USERPROFILE");
|
||||
// if (userProfile) {
|
||||
@@ -734,7 +765,7 @@ export function homeDir(): string | null {
|
||||
|
||||
export function resolveFilename(filename: string): string {
|
||||
if (filename.startsWith("~/")) {
|
||||
return homeDir() + filename.substring(1);
|
||||
return getHomeDir() + filename.substring(1);
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
@@ -71,57 +71,57 @@
|
||||
},
|
||||
"decode-uri-component.ts": {
|
||||
"script_name": "decode-uri-component.ts",
|
||||
"script_length": 895,
|
||||
"script_sha256": "22af6c21359b50e8907ad2f25f5c1e42a0889c2415347cee5f693728f36931bf",
|
||||
"script_length": 826,
|
||||
"script_sha256": "c3a3adfa47d1d02552e470a54465d0879fc7c27a385eaeb05de0e390e8fac1a0",
|
||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/decode-uri-component.ts",
|
||||
"single_script_file": true,
|
||||
"publish_time": 1769010420928,
|
||||
"update_time": 1770820648012
|
||||
"update_time": 1770822121773
|
||||
},
|
||||
"decode-uri.ts": {
|
||||
"script_name": "decode-uri.ts",
|
||||
"script_length": 866,
|
||||
"script_sha256": "0e529a1df2a6290f48cef047c9670b36434a81784c86e33e93467d1c406fb9c2",
|
||||
"script_length": 797,
|
||||
"script_sha256": "0a1734bfd5915ddb57078700b331f7a8caef10e67155bca0c440268b45e4049a",
|
||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/decode-uri.ts",
|
||||
"single_script_file": true,
|
||||
"publish_time": 1769010420927,
|
||||
"update_time": 1770820648008
|
||||
"update_time": 1770822121766
|
||||
},
|
||||
"encode-uri-component.ts": {
|
||||
"script_name": "encode-uri-component.ts",
|
||||
"script_length": 895,
|
||||
"script_sha256": "f93d315d2b26474b1640c5f4ea4ddcb168dae85b9d1da4ed630cf76c0951dd2f",
|
||||
"script_length": 826,
|
||||
"script_sha256": "ad09cba79b7d73ba1d33392c11df30223468356e189b1f2ccaf50a13fc0e57a6",
|
||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/encode-uri-component.ts",
|
||||
"single_script_file": true,
|
||||
"publish_time": 1769010420927,
|
||||
"update_time": 1770820648008
|
||||
"update_time": 1770822121766
|
||||
},
|
||||
"encode-uri.ts": {
|
||||
"script_name": "encode-uri.ts",
|
||||
"script_length": 866,
|
||||
"script_sha256": "99051fb4754203c685de490cdbc0addd0203b0866cd902f760d6cc3d8a1305c2",
|
||||
"script_length": 797,
|
||||
"script_sha256": "9982989109d8b2963ea60204ec9d4a42b99b91fc0b8f2edc04a59f7e536528e4",
|
||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/encode-uri.ts",
|
||||
"single_script_file": true,
|
||||
"publish_time": 1769010420927,
|
||||
"update_time": 1770820648008
|
||||
"update_time": 1770822121767
|
||||
},
|
||||
"git-check.ts": {
|
||||
"script_name": "git-check.ts",
|
||||
"script_length": 3107,
|
||||
"script_sha256": "59eed22fad7b3a4f4ddb6c9c5ba6781771fbff6e0f7d30e869039ddc93f27d94",
|
||||
"script_sha256": "a407febeb4f00935f0de9bb02953b688016b2e1819627b88ab07ca08f2a68338",
|
||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/git-check.ts",
|
||||
"single_script_file": true,
|
||||
"publish_time": 1770541896791,
|
||||
"update_time": 1770566275385
|
||||
"update_time": 1770822121766
|
||||
},
|
||||
"hjson.ts": {
|
||||
"script_name": "hjson.ts",
|
||||
"script_length": 449,
|
||||
"script_sha256": "0ff4ae6601124b92936d76d32d27c882edfbb3af1613362e3c3d13cbde5cbed8",
|
||||
"script_length": 458,
|
||||
"script_sha256": "8ef093d380b802ddc88253d382a907042e0cdb84fdfb2a2602b5237dc843f494",
|
||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/hjson.ts",
|
||||
"single_script_file": true,
|
||||
"publish_time": 1737375737613,
|
||||
"update_time": 1737650670433
|
||||
"update_time": 1770822121766
|
||||
},
|
||||
"ip.ts": {
|
||||
"script_name": "ip.ts",
|
||||
@@ -134,12 +134,12 @@
|
||||
},
|
||||
"json5.ts": {
|
||||
"script_name": "json5.ts",
|
||||
"script_length": 449,
|
||||
"script_sha256": "b81ddc5b9f6f33df3521bda5f85e6378751356f104817d64b18272f839befbbf",
|
||||
"script_length": 459,
|
||||
"script_sha256": "42ec900affe351697490ae677bdd392ecccc2f27e453c3820e9e0a99a08bb135",
|
||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/json5.ts",
|
||||
"single_script_file": true,
|
||||
"publish_time": 1767969331870,
|
||||
"update_time": 1767969331870
|
||||
"update_time": 1770822121767
|
||||
},
|
||||
"jsr-std-http-file-server-bundle.ts": {
|
||||
"script_name": "jsr-std-http-file-server-bundle.ts",
|
||||
@@ -170,12 +170,12 @@
|
||||
},
|
||||
"post-note.ts": {
|
||||
"script_name": "post-note.ts",
|
||||
"script_length": 2030,
|
||||
"script_sha256": "9fc2c3223882a9040d3becc7d1c5dfc5c89dfb313fa05c8605e041629d887881",
|
||||
"script_length": 2049,
|
||||
"script_sha256": "37f1b50234e7f7d143c65f9d0d37d99ef148a33d87be364a43b8c136d95abc3f",
|
||||
"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": 1769525844426
|
||||
"update_time": 1770822121771
|
||||
},
|
||||
"print-env.ts": {
|
||||
"script_name": "print-env.ts",
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#!/usr/bin/env runts -- --allow-import
|
||||
|
||||
import {args, exit} from "https://script.hatter.ink/@41/deno-commons-mod.ts";
|
||||
import {args, exit, stdinToArrayBuffer,} from "https://script.hatter.ink/@41/deno-commons-mod.ts";
|
||||
import {parseArgs} from "jsr:@std/cli/parse-args";
|
||||
import {toArrayBuffer} from "https://deno.land/std@0.203.0/streams/mod.ts";
|
||||
|
||||
const flags = parseArgs(args(), {
|
||||
boolean: ["help"],
|
||||
@@ -22,11 +21,11 @@ let input;
|
||||
if (flags.value) {
|
||||
input = flags.value;
|
||||
} else {
|
||||
input = new TextDecoder().decode(await toArrayBuffer(Deno.stdin.readable));
|
||||
input = new TextDecoder().decode(await stdinToArrayBuffer());
|
||||
}
|
||||
const encoded = decodeURIComponent(input);
|
||||
|
||||
console.log(encoded);
|
||||
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260211T223654+08:00.MEQCIFtTTbxi8OppwMqWir2q
|
||||
// 0UbxQBHhtTORJyhDnU1vUfOTAiA31LMua+CE7wqry2JYMVikX0iE7e4c/gbuLIFj/KszEw==
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260211T225504+08:00.MEYCIQDKLbuD0sgzk3bG7F20
|
||||
// VvDZHp3Eb2Jtf5u7V6vZ3+TtRQIhAIAOTgX9h7pLbT3fTNmkY5tyAQToY2zDaJ+qzRW7OTmh
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#!/usr/bin/env runts -- --allow-import
|
||||
|
||||
import {args, exit} from "https://script.hatter.ink/@41/deno-commons-mod.ts";
|
||||
import {args, exit, stdinToArrayBuffer,} from "https://script.hatter.ink/@41/deno-commons-mod.ts";
|
||||
import {parseArgs} from "jsr:@std/cli/parse-args";
|
||||
import {toArrayBuffer} from "https://deno.land/std@0.203.0/streams/mod.ts";
|
||||
|
||||
const flags = parseArgs(args(), {
|
||||
boolean: ["help"],
|
||||
@@ -22,11 +21,11 @@ let input;
|
||||
if (flags.value) {
|
||||
input = flags.value;
|
||||
} else {
|
||||
input = new TextDecoder().decode(await toArrayBuffer(Deno.stdin.readable));
|
||||
input = new TextDecoder().decode(await stdinToArrayBuffer());
|
||||
}
|
||||
const encoded = decodeURI(input);
|
||||
|
||||
console.log(encoded);
|
||||
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260211T223656+08:00.MEUCIQD2Z+EYNFmlGJF1mRwZ
|
||||
// WtcimdYPCpkEiGWJ2nCoEFZhSAIgIcokRXUdswb+o/tjq098FbaBSRu2xk8t1qgKvBFp3hw=
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260211T225506+08:00.MEUCIDfr8u5mUsFF99o/bljU
|
||||
// QRarosqW3mkPVLil3xKqm9xbAiEAlE6HABKWVyN/vEIzW4H18Yz3nsoD9O+WlrvhoOzoDGk=
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#!/usr/bin/env runts -- --allow-import
|
||||
|
||||
import {args, exit} from "https://script.hatter.ink/@41/deno-commons-mod.ts";
|
||||
import {args, exit, stdinToArrayBuffer,} from "https://script.hatter.ink/@41/deno-commons-mod.ts";
|
||||
import {parseArgs} from "jsr:@std/cli/parse-args";
|
||||
import {toArrayBuffer} from "https://deno.land/std@0.203.0/streams/mod.ts";
|
||||
|
||||
const flags = parseArgs(args(), {
|
||||
boolean: ["help"],
|
||||
@@ -22,11 +21,11 @@ let input;
|
||||
if (flags.value) {
|
||||
input = flags.value;
|
||||
} else {
|
||||
input = new TextDecoder().decode(await toArrayBuffer(Deno.stdin.readable));
|
||||
input = new TextDecoder().decode(await stdinToArrayBuffer());
|
||||
}
|
||||
const encoded = encodeURIComponent(input);
|
||||
|
||||
console.log(encoded);
|
||||
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260211T223656+08:00.MEYCIQDWpN6TPlSUC2reXixQ
|
||||
// cAsopGtVR7O1eHOZ8yMXhXJamAIhAKHLwiUf97ArNi0fYjQ8pfEkRXA6kfxM41Uj3rgYj1X/
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260211T225507+08:00.MEYCIQDxWgMNdf4UdQgAbtSs
|
||||
// FHQ5RxsfUUsmwqPoDLDj2KYacwIhAKv/68f8WC3TFJ7v0Fli7djrRNt80lB+qkdHg6ROXaK6
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#!/usr/bin/env runts -- --allow-import
|
||||
|
||||
import {args, exit} from "https://script.hatter.ink/@41/deno-commons-mod.ts";
|
||||
import {args, exit, stdinToArrayBuffer,} from "https://script.hatter.ink/@43/deno-commons-mod.ts";
|
||||
import {parseArgs} from "jsr:@std/cli/parse-args";
|
||||
import {toArrayBuffer} from "https://deno.land/std@0.203.0/streams/mod.ts";
|
||||
|
||||
const flags = parseArgs(args(), {
|
||||
boolean: ["help"],
|
||||
@@ -22,11 +21,11 @@ let input;
|
||||
if (flags.value) {
|
||||
input = flags.value;
|
||||
} else {
|
||||
input = new TextDecoder().decode(await toArrayBuffer(Deno.stdin.readable));
|
||||
input = new TextDecoder().decode(await stdinToArrayBuffer());
|
||||
}
|
||||
const encoded = encodeURI(input);
|
||||
|
||||
console.log(encoded);
|
||||
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260211T223656+08:00.MEUCIHhfsF0mbPmh5MylnqPg
|
||||
// MEXtiFQ3ncpqJcQruOqdUViLAiEA77/M0NfgxlerlG0zjY/r0Etz7fQ0TyqX8B1Qe1iev8Q=
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260211T225148+08:00.MEUCIAwanQfv/7ixuUTMPJKh
|
||||
// eU5BnGTKB5PeqmPHPkq5BpoJAiEAjASLCxu/w1Dm/6lz8yPlc71mChWo1M1MxiyiM3MQ6Cs=
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#!/usr/bin/env runts -- --allow-all
|
||||
|
||||
import {
|
||||
args,
|
||||
execCommandAndStdout,
|
||||
exit,
|
||||
formatHumanTime,
|
||||
log,
|
||||
ProcessBar,
|
||||
@@ -10,12 +12,9 @@ import {
|
||||
term,
|
||||
uint8ArrayToHexString,
|
||||
writeStringToFile,
|
||||
} from "https://script.hatter.ink/@35/deno-commons-mod.ts";
|
||||
import {
|
||||
getGitLocalRev,
|
||||
getGitRemoteRev,
|
||||
} from "https://script.hatter.ink/@0/deno-git-mod.ts";
|
||||
import { parseArgs } from "jsr:@std/cli/parse-args";
|
||||
} from "https://script.hatter.ink/@41/deno-commons-mod.ts";
|
||||
import {getGitLocalRev, getGitRemoteRev,} from "https://script.hatter.ink/@0/deno-git-mod.ts";
|
||||
import {parseArgs} from "jsr:@std/cli/parse-args";
|
||||
|
||||
const MILLIS_OF_HOUR = 60 * 60 * 1000;
|
||||
|
||||
@@ -35,7 +34,7 @@ interface GitCheckCache {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const flags = parseArgs(Deno.args, {
|
||||
const flags = parseArgs(args(), {
|
||||
boolean: [
|
||||
"help",
|
||||
],
|
||||
@@ -95,11 +94,11 @@ git-check.ts [--interval NUMBER-OF-HOURS]`);
|
||||
log.error(
|
||||
`Check rev failed, local rev: ${localRev} vs remote rev: ${remoteRev}`,
|
||||
);
|
||||
Deno.exit(1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
await main();
|
||||
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260208T235727+08:00.MEUCIQDm/E1d7mGqJ4nbguao
|
||||
// +eFwlDMp/x7ZOWn95z2BSnIrfwIgJg0lHcBV8C2fQ5B/4Suvq7f9/f+M2CHrNn9CSzve4wA=
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260211T223841+08:00.MEYCIQDP6ccWgcPmrIdAWqjl
|
||||
// pS3koxJgYGPETuczjTbo+/PE/QIhAIHpiz8WCp+8hQ/oBOotIG/7Jfc9ky+R1tPi2fKdJ3Wb
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env runts -- --allow-env
|
||||
#!/usr/bin/env runts -- --allow-env --allow-import
|
||||
|
||||
import {stdinToArrayBuffer} from "https://script.hatter.ink/@43/deno-commons-mod.ts";
|
||||
import hjson from "npm:hjson";
|
||||
import { toArrayBuffer } from "https://deno.land/std@0.203.0/streams/mod.ts";
|
||||
|
||||
const input = new TextDecoder().decode(await toArrayBuffer(Deno.stdin.readable));
|
||||
const input = new TextDecoder().decode(await stdinToArrayBuffer());
|
||||
|
||||
console.log(JSON.stringify(hjson.parse(input), null, 4));
|
||||
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20250124T004244+08:00.MEUCIQCmHkkAiwvLHOZpwb+M
|
||||
// WLEa/guITGU2HD6ZD51SP/vwlgIgAIa/Pudrns1WkKMqn5VsR4/a6vDj1J52CUR/aN+bK8A=
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260211T225507+08:00.MEUCIGr7QsOMEjjLKp5AOPux
|
||||
// CtgKZemBdYsqPo8M7ieCmNriAiEA16LCcRqFGrgk7teLSkqICN7XuqJxvy0xCKb1Jz6sZxs=
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env runts -- --allow-env
|
||||
#!/usr/bin/env runts -- --allow-env --allow-import
|
||||
|
||||
import {stdinToArrayBuffer,} from "https://script.hatter.ink/@43/deno-commons-mod.ts";
|
||||
import josn5 from "npm:json5";
|
||||
import { toArrayBuffer } from "https://deno.land/std@0.203.0/streams/mod.ts";
|
||||
|
||||
const input = new TextDecoder().decode(await toArrayBuffer(Deno.stdin.readable));
|
||||
const input = new TextDecoder().decode(await stdinToArrayBuffer());
|
||||
|
||||
console.log(JSON.stringify(josn5.parse(input), null, 4));
|
||||
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260109T223356+08:00.MEQCIFVTrvVoTLkQgqdF+reR
|
||||
// O3fqk6XmeW4hNo/bmUqCpeYFAiBpyK4W7trjpLpV07N2Xb9T+11ok+mn+9qcPV61e3IoHw==
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260211T225421+08:00.MEQCIByockYjDjHyRGSS4tBa
|
||||
// tY2PjygZtm3vOmED9mNTJWxWAiApie4KjLckbi0LPqYXqyrBrELxAITeNS1ieW2T9IuDOQ==
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import {parseArgs} from "jsr:@std/cli/parse-args";
|
||||
import {encryptEcdhP256} from "https://global.hatter.ink/script/get/@0/deno-wrapkey-mod.ts";
|
||||
import {getEnv, log,} from "https://global.hatter.ink/script/get/@18/deno-commons-mod.ts";
|
||||
import {args, exit, getEnv, log,} from "https://global.hatter.ink/script/get/@44/deno-commons-mod.ts";
|
||||
import {fetchWithTimeoutAndAutoProxy} from "https://global.hatter.ink/script/get/@1/deno-fetch-auto-proxy-mod.ts";
|
||||
|
||||
const endpoint = getEnv("POST_ENCRYPTED_NOTE_ENDPOINT");
|
||||
@@ -16,49 +16,49 @@ if (!endpoint || !publicKeyPointHex) {
|
||||
if (!publicKeyPointHex) {
|
||||
log.info("ENCRYPTION_PUBLIC_KEY_POINT_HEX must be assigned.");
|
||||
}
|
||||
Deno.exit(1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
const flags = parseArgs(Deno.args, {
|
||||
const flags = parseArgs(args(), {
|
||||
boolean: ["help", "post-message"],
|
||||
string: ["title"],
|
||||
});
|
||||
|
||||
if (flags.help) {
|
||||
console.log("post-note.ts [--post-message] [--title <title>] <message>");
|
||||
Deno.exit(0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (flags._.length === 0) {
|
||||
log.error("Requires message.");
|
||||
Deno.exit(1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
const args = [];
|
||||
const fetchArgs = [];
|
||||
if (flags.title) {
|
||||
const encryptedTitle = await encryptEcdhP256(
|
||||
"k",
|
||||
publicKeyPointHex,
|
||||
new TextEncoder().encode(flags.title),
|
||||
);
|
||||
args.push(`title=${encodeURIComponent(encryptedTitle.toString())}`);
|
||||
fetchArgs.push(`title=${encodeURIComponent(encryptedTitle.toString())}`);
|
||||
}
|
||||
const encryptedMessage = await encryptEcdhP256(
|
||||
"k",
|
||||
publicKeyPointHex,
|
||||
new TextEncoder().encode(flags._.join("\n")),
|
||||
);
|
||||
args.push(`memo=${encodeURIComponent(encryptedMessage.toString())}`);
|
||||
fetchArgs.push(`memo=${encodeURIComponent(encryptedMessage.toString())}`);
|
||||
|
||||
if (flags["post-message"]) {
|
||||
args.push("postMessage=true");
|
||||
fetchArgs.push("postMessage=true");
|
||||
}
|
||||
|
||||
const response = await fetchWithTimeoutAndAutoProxy(
|
||||
`${endpoint}?${args.join("&")}`,
|
||||
`${endpoint}?${fetchArgs.join("&")}`,
|
||||
);
|
||||
|
||||
console.info(response.status, await response.json());
|
||||
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260127T225716+08:00.MEUCIEnxw6Q8UfPFWxfs+0Hq
|
||||
// dzR+nwQoChs/xwSyAm4wpd9DAiEAnOZ70FXyf0e0QQpHiYHFLYdMdMZZWhCKjv2ShguSoPg=
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260211T230055+08:00.MEYCIQDTM5393nrl6WXzDopn
|
||||
// 9FeMIl2z7QUoQVOHP4BHZVH4OgIhANMUWUtFZDuOVH0J9e1PyS0j690Z+8AlTry7r/UHYoIu
|
||||
|
||||
Reference in New Issue
Block a user