Merge branch 'maintenance' into 'develop'
Maintenance See merge request soapbox-pub/ditto!4
This commit is contained in:
commit
00fa037aaf
|
@ -1,4 +1,4 @@
|
||||||
image: denoland/deno:1.33.2
|
image: denoland/deno:1.36.0
|
||||||
|
|
||||||
default:
|
default:
|
||||||
interruptible: true
|
interruptible: true
|
||||||
|
@ -14,6 +14,10 @@ lint:
|
||||||
stage: test
|
stage: test
|
||||||
script: deno lint
|
script: deno lint
|
||||||
|
|
||||||
|
check:
|
||||||
|
stage: test
|
||||||
|
script: deno task check
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
script: deno task test
|
script: deno task test
|
|
@ -1 +1 @@
|
||||||
deno 1.33.2
|
deno 1.36.0
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
"$schema": "https://deno.land/x/deno@v1.32.3/cli/schemas/config-file.v1.json",
|
"$schema": "https://deno.land/x/deno@v1.32.3/cli/schemas/config-file.v1.json",
|
||||||
"lock": false,
|
"lock": false,
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"dev": "deno run --allow-read --allow-write --allow-env --allow-net --allow-ffi --unstable --watch src/server.ts",
|
"start": "deno run --allow-read --allow-write=data --allow-env --allow-net --unstable --watch src/server.ts",
|
||||||
"test": "deno test -A --unstable src"
|
"test": "deno test --allow-read --allow-write=data --allow-env --unstable src",
|
||||||
|
"check": "deno check --unstable src/server.ts"
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
"@/": "./src/"
|
"@/": "./src/"
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
import { nip19, secp } from '@/deps.ts';
|
import { dotenv, nip19, secp } from '@/deps.ts';
|
||||||
|
|
||||||
|
/** Load environment config from `.env` */
|
||||||
|
await dotenv.load({
|
||||||
|
export: true,
|
||||||
|
defaultsPath: null,
|
||||||
|
examplePath: null,
|
||||||
|
});
|
||||||
|
|
||||||
/** Application-wide configuration. */
|
/** Application-wide configuration. */
|
||||||
const Conf = {
|
const Conf = {
|
||||||
|
@ -22,7 +29,7 @@ const Conf = {
|
||||||
get cryptoKey() {
|
get cryptoKey() {
|
||||||
return crypto.subtle.importKey(
|
return crypto.subtle.importKey(
|
||||||
'raw',
|
'raw',
|
||||||
secp.utils.hexToBytes(Conf.seckey),
|
secp.etc.hexToBytes(Conf.seckey),
|
||||||
{ name: 'HMAC', hash: 'SHA-256' },
|
{ name: 'HMAC', hash: 'SHA-256' },
|
||||||
false,
|
false,
|
||||||
['sign', 'verify'],
|
['sign', 'verify'],
|
||||||
|
|
|
@ -12,7 +12,7 @@ const actorController: AppController = async (c) => {
|
||||||
const event = await getAuthor(user.pubkey);
|
const event = await getAuthor(user.pubkey);
|
||||||
if (!event) return notFound(c);
|
if (!event) return notFound(c);
|
||||||
|
|
||||||
const actor = await toActor(event);
|
const actor = await toActor(event, user.username);
|
||||||
if (!actor) return notFound(c);
|
if (!actor) return notFound(c);
|
||||||
|
|
||||||
return activityJson(c, actor);
|
return activityJson(c, actor);
|
||||||
|
|
29
src/deps.ts
29
src/deps.ts
|
@ -3,12 +3,12 @@ export {
|
||||||
type Env as HonoEnv,
|
type Env as HonoEnv,
|
||||||
type Handler,
|
type Handler,
|
||||||
Hono,
|
Hono,
|
||||||
|
HTTPException,
|
||||||
type MiddlewareHandler,
|
type MiddlewareHandler,
|
||||||
} from 'https://deno.land/x/hono@v3.0.2/mod.ts';
|
} from 'https://deno.land/x/hono@v3.3.4/mod.ts';
|
||||||
export { HTTPException } from 'https://deno.land/x/hono@v3.0.2/http-exception.ts';
|
export { cors, logger } from 'https://deno.land/x/hono@v3.3.4/middleware.ts';
|
||||||
export { cors, logger } from 'https://deno.land/x/hono@v3.0.2/middleware.ts';
|
|
||||||
export { z } from 'https://deno.land/x/zod@v3.21.4/mod.ts';
|
export { z } from 'https://deno.land/x/zod@v3.21.4/mod.ts';
|
||||||
export { Author, RelayPool } from 'https://dev.jspm.io/nostr-relaypool@0.5.3';
|
export { Author, RelayPool } from 'https://dev.jspm.io/nostr-relaypool@0.6.28';
|
||||||
export {
|
export {
|
||||||
type Filter,
|
type Filter,
|
||||||
finishEvent,
|
finishEvent,
|
||||||
|
@ -21,24 +21,23 @@ export {
|
||||||
nip19,
|
nip19,
|
||||||
nip21,
|
nip21,
|
||||||
verifySignature,
|
verifySignature,
|
||||||
} from 'npm:nostr-tools@^1.12.1';
|
} from 'npm:nostr-tools@^1.14.0';
|
||||||
export { findReplyTag } from 'https://gitlab.com/soapbox-pub/mostr/-/raw/c67064aee5ade5e01597c6d23e22e53c628ef0e2/src/nostr/tags.ts';
|
export { findReplyTag } from 'https://gitlab.com/soapbox-pub/mostr/-/raw/c67064aee5ade5e01597c6d23e22e53c628ef0e2/src/nostr/tags.ts';
|
||||||
export { parseFormData } from 'npm:formdata-helper@^0.3.0';
|
export { parseFormData } from 'npm:formdata-helper@^0.3.0';
|
||||||
// @deno-types="npm:@types/lodash@4.14.194"
|
// @deno-types="npm:@types/lodash@4.14.194"
|
||||||
export { default as lodash } from 'https://esm.sh/lodash@4.17.21';
|
export { default as lodash } from 'https://esm.sh/lodash@4.17.21';
|
||||||
export { default as linkify } from 'npm:linkifyjs@^4.1.0';
|
export { default as linkify } from 'npm:linkifyjs@^4.1.1';
|
||||||
export { default as linkifyStr } from 'npm:linkify-string@^4.1.0';
|
export { default as linkifyStr } from 'npm:linkify-string@^4.1.1';
|
||||||
import 'npm:linkify-plugin-hashtag@^4.1.0';
|
import 'npm:linkify-plugin-hashtag@^4.1.1';
|
||||||
// @deno-types="npm:@types/mime@3.0.0"
|
// @deno-types="npm:@types/mime@3.0.0"
|
||||||
export { default as mime } from 'npm:mime@^3.0.0';
|
export { default as mime } from 'npm:mime@^3.0.0';
|
||||||
export { unfurl } from 'npm:unfurl.js@^6.3.2';
|
export { unfurl } from 'npm:unfurl.js@^6.3.2';
|
||||||
export { default as TTLCache } from 'npm:@isaacs/ttlcache@^1.4.0';
|
export { default as TTLCache } from 'npm:@isaacs/ttlcache@^1.4.1';
|
||||||
export { default as uuid62 } from 'npm:uuid62@^1.0.2';
|
export { default as uuid62 } from 'npm:uuid62@^1.0.2';
|
||||||
// @deno-types="npm:@types/sanitize-html@2.9.0"
|
// @deno-types="npm:@types/sanitize-html@2.9.0"
|
||||||
export { default as sanitizeHtml } from 'npm:sanitize-html@^2.10.0';
|
export { default as sanitizeHtml } from 'npm:sanitize-html@^2.11.0';
|
||||||
export { default as ISO6391 } from 'npm:iso-639-1@2.1.15';
|
export { default as ISO6391 } from 'npm:iso-639-1@2.1.15';
|
||||||
export { Dongoose } from 'https://raw.githubusercontent.com/alexgleason/dongoose/68b7ad9dd7b6ec0615e246a9f1603123c1709793/mod.ts';
|
export { createPentagon } from 'https://deno.land/x/pentagon@v0.1.4/mod.ts';
|
||||||
export { createPentagon } from 'https://deno.land/x/pentagon@v0.1.1/mod.ts';
|
|
||||||
export {
|
export {
|
||||||
type ParsedSignature,
|
type ParsedSignature,
|
||||||
pemToPublicKey,
|
pemToPublicKey,
|
||||||
|
@ -47,7 +46,7 @@ export {
|
||||||
verifyRequest,
|
verifyRequest,
|
||||||
} from 'https://gitlab.com/soapbox-pub/fedisign/-/raw/v0.2.1/mod.ts';
|
} from 'https://gitlab.com/soapbox-pub/fedisign/-/raw/v0.2.1/mod.ts';
|
||||||
export { generateSeededRsa } from 'https://gitlab.com/soapbox-pub/seeded-rsa/-/raw/v1.0.0/mod.ts';
|
export { generateSeededRsa } from 'https://gitlab.com/soapbox-pub/seeded-rsa/-/raw/v1.0.0/mod.ts';
|
||||||
export * as secp from 'npm:@noble/secp256k1@^1.7.1';
|
export * as secp from 'npm:@noble/secp256k1@^2.0.0';
|
||||||
export { LRUCache } from 'npm:lru-cache@^10.0.0';
|
export { LRUCache } from 'npm:lru-cache@^10.0.0';
|
||||||
export { DB as Sqlite } from 'https://deno.land/x/sqlite@v3.7.0/mod.ts';
|
export { DB as Sqlite } from 'https://deno.land/x/sqlite@v3.7.3/mod.ts';
|
||||||
export { serve } from 'https://deno.land/std@0.177.0/http/server.ts';
|
export * as dotenv from 'https://deno.land/std@0.197.0/dotenv/mod.ts';
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
import 'https://deno.land/std@0.177.0/dotenv/load.ts';
|
|
||||||
import { serve } from '@/deps.ts';
|
|
||||||
|
|
||||||
import app from './app.ts';
|
import app from './app.ts';
|
||||||
|
|
||||||
serve(app.fetch);
|
Deno.serve(app.fetch);
|
||||||
|
|
|
@ -6,13 +6,9 @@ import type { Event } from '@/event.ts';
|
||||||
import type { Actor } from '@/schemas/activitypub.ts';
|
import type { Actor } from '@/schemas/activitypub.ts';
|
||||||
|
|
||||||
/** Nostr metadata event to ActivityPub actor. */
|
/** Nostr metadata event to ActivityPub actor. */
|
||||||
async function toActor(event: Event<0>): Promise<Actor | undefined> {
|
async function toActor(event: Event<0>, username: string): Promise<Actor | undefined> {
|
||||||
const content = parseMetaContent(event);
|
const content = parseMetaContent(event);
|
||||||
|
|
||||||
if (!content.nip05) return;
|
|
||||||
const [username, hostname] = content.nip05.split('@');
|
|
||||||
if (hostname !== Conf.url.hostname) return;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'Person',
|
type: 'Person',
|
||||||
id: Conf.local(`/users/${username}`),
|
id: Conf.local(`/users/${username}`),
|
||||||
|
|
|
@ -11,7 +11,7 @@ async function buildSeed(pubkey: string): Promise<string> {
|
||||||
const key = await Conf.cryptoKey;
|
const key = await Conf.cryptoKey;
|
||||||
const data = new TextEncoder().encode(pubkey);
|
const data = new TextEncoder().encode(pubkey);
|
||||||
const signature = await window.crypto.subtle.sign('HMAC', key, data);
|
const signature = await window.crypto.subtle.sign('HMAC', key, data);
|
||||||
return secp.utils.bytesToHex(new Uint8Array(signature));
|
return secp.etc.bytesToHex(new Uint8Array(signature));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPublicKeyPem(pubkey: string): Promise<string> {
|
async function getPublicKeyPem(pubkey: string): Promise<string> {
|
||||||
|
|
Loading…
Reference in New Issue