this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bug fixes and performance improvements

thanks mary

futurGH 254a5c14 206d2296

+10 -10
+1
.eslintrc.json
··· 9 9 "@typescript-eslint/no-explicit-any": "off", 10 10 "@typescript-eslint/no-misused-promises": "off", 11 11 "@typescript-eslint/no-non-null-assertion": "off", 12 + "@typescript-eslint/no-throw-literal": "off", 12 13 "@typescript-eslint/no-unnecessary-condition": "off", 13 14 "@typescript-eslint/no-unsafe-argument": "off", 14 15 "@typescript-eslint/no-unsafe-assignment": "off",
+6 -6
src/LabelerServer.ts
··· 1 1 import "@atcute/ozone/lexicons"; 2 + import { fromBytes } from "@atcute/cbor"; 2 3 import { XRPCError } from "@atcute/client"; 3 4 import type { 4 5 At, ··· 8 9 import { fastifyWebsocket } from "@fastify/websocket"; 9 10 import fastify, { type FastifyInstance, type FastifyRequest } from "fastify"; 10 11 import Database, { type Database as SQLiteDatabase } from "libsql"; 11 - import { fromString as ui8FromString } from "uint8arrays"; 12 12 import type { WebSocket } from "ws"; 13 13 import { verifyJwt } from "./util/crypto.js"; 14 14 import { formatLabel, labelIsSigned, signLabel } from "./util/labels.js"; ··· 81 81 this.did = options.did as At.DID; 82 82 this.auth = options.auth ?? ((did) => did === this.did); 83 83 84 - if (options.signingKey.startsWith("did:key:")) { 85 - throw new Error(INVALID_SIGNING_KEY_ERROR); 86 - } 87 - this.#signingKey = ui8FromString(options.signingKey, "hex"); 88 - if (this.#signingKey.byteLength !== 32) { 84 + try { 85 + if (options.signingKey.startsWith("did:key:")) throw 0; 86 + this.#signingKey = fromBytes({ $bytes: options.signingKey }); 87 + if (this.#signingKey.byteLength !== 32) throw 0; 88 + } catch (e) { 89 89 throw new Error(INVALID_SIGNING_KEY_ERROR); 90 90 } 91 91
+3 -4
src/util/labels.ts
··· 1 - import { encode as cborEncode } from "@atcute/cbor"; 1 + import { encode as cborEncode, toBytes } from "@atcute/cbor"; 2 2 import type { At } from "@atcute/client/lexicons"; 3 - import { toString as ui8ToString } from "uint8arrays"; 4 3 import { k256Sign } from "./crypto.js"; 5 4 import type { FormattedLabel, SignedLabel, UnsignedLabel } from "./types.js"; 6 5 import { excludeNullish } from "./util.js"; ··· 15 14 label: UnsignedLabel & { sig?: ArrayBuffer | Uint8Array | At.Bytes }, 16 15 ): FormattedLabel { 17 16 const sig = label.sig instanceof ArrayBuffer 18 - ? { $bytes: ui8ToString(new Uint8Array(label.sig), "base64") } 17 + ? toBytes(new Uint8Array(label.sig)) 19 18 : label.sig instanceof Uint8Array 20 - ? { $bytes: ui8ToString(label.sig, "base64") } 19 + ? toBytes(label.sig) 21 20 : label.sig; 22 21 if (!sig || !("$bytes" in sig)) { 23 22 throw new Error("Expected sig to be an object with base64 $bytes, got " + sig);