updates
This commit is contained in:
@@ -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