Merge branch 'nostrify' into 'main'
Switch NSpec to Nostrify, update imports See merge request soapbox-pub/ditto!168
This commit is contained in:
commit
11e81f0000
|
@ -11,7 +11,11 @@
|
||||||
"nsec": "deno run scripts/nsec.ts"
|
"nsec": "deno run scripts/nsec.ts"
|
||||||
},
|
},
|
||||||
"exclude": ["./public"],
|
"exclude": ["./public"],
|
||||||
"imports": { "@/": "./src/", "@soapbox/nspec": "jsr:@soapbox/nspec@^0.8.1", "~/fixtures/": "./fixtures/" },
|
"imports": {
|
||||||
|
"@/": "./src/",
|
||||||
|
"@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.9.7",
|
||||||
|
"~/fixtures/": "./fixtures/"
|
||||||
|
},
|
||||||
"lint": {
|
"lint": {
|
||||||
"include": ["src/", "scripts/"],
|
"include": ["src/", "scripts/"],
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import '@/cron.ts';
|
import '@/cron.ts';
|
||||||
import { type User } from '@/db/users.ts';
|
import { type User } from '@/db/users.ts';
|
||||||
|
@ -10,7 +12,6 @@ import {
|
||||||
type HonoEnv,
|
type HonoEnv,
|
||||||
logger,
|
logger,
|
||||||
type MiddlewareHandler,
|
type MiddlewareHandler,
|
||||||
type NostrEvent,
|
|
||||||
sentryMiddleware,
|
sentryMiddleware,
|
||||||
serveStatic,
|
serveStatic,
|
||||||
} from '@/deps.ts';
|
} from '@/deps.ts';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { NostrFilter } from '@soapbox/nspec';
|
import { NostrFilter } from '@nostrify/nostrify';
|
||||||
import { type AppController } from '@/app.ts';
|
import { type AppController } from '@/app.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { nip19, z } from '@/deps.ts';
|
import { nip19, z } from '@/deps.ts';
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { NostrFilter } from '@soapbox/nspec';
|
import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
||||||
import { AppController } from '@/app.ts';
|
import { AppController } from '@/app.ts';
|
||||||
import { nip19, type NostrEvent, z } from '@/deps.ts';
|
import { nip19, z } from '@/deps.ts';
|
||||||
import { booleanParamSchema } from '@/schema.ts';
|
import { booleanParamSchema } from '@/schema.ts';
|
||||||
import { nostrIdSchema } from '@/schemas/nostr.ts';
|
import { nostrIdSchema } from '@/schemas/nostr.ts';
|
||||||
import { searchStore } from '@/storages.ts';
|
import { searchStore } from '@/storages.ts';
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
import { NIP05, NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
||||||
import { type AppController } from '@/app.ts';
|
import { type AppController } from '@/app.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { getUnattachedMediaByIds } from '@/db/unattached-media.ts';
|
import { getUnattachedMediaByIds } from '@/db/unattached-media.ts';
|
||||||
import { ISO6391, NIP05, nip19, type NostrEvent, NostrFilter, z } from '@/deps.ts';
|
import { ISO6391, nip19, z } from '@/deps.ts';
|
||||||
import { getAncestors, getAuthor, getDescendants, getEvent } from '@/queries.ts';
|
import { getAncestors, getAuthor, getDescendants, getEvent } from '@/queries.ts';
|
||||||
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
||||||
import { addTag, deleteTag } from '@/tags.ts';
|
import { addTag, deleteTag } from '@/tags.ts';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { NostrFilter } from '@soapbox/nspec';
|
import { NostrFilter } from '@nostrify/nostrify';
|
||||||
import { type AppController } from '@/app.ts';
|
import { type AppController } from '@/app.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { Debug, z } from '@/deps.ts';
|
import { Debug, z } from '@/deps.ts';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { NostrFilter } from '@soapbox/nspec';
|
import { NostrFilter } from '@nostrify/nostrify';
|
||||||
import { type AppContext, type AppController } from '@/app.ts';
|
import { type AppContext, type AppController } from '@/app.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { z } from '@/deps.ts';
|
import { z } from '@/deps.ts';
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
||||||
import { relayInfoController } from '@/controllers/nostr/relay-info.ts';
|
import { relayInfoController } from '@/controllers/nostr/relay-info.ts';
|
||||||
import { eventsDB } from '@/storages.ts';
|
import { eventsDB } from '@/storages.ts';
|
||||||
import * as pipeline from '@/pipeline.ts';
|
import * as pipeline from '@/pipeline.ts';
|
||||||
|
@ -13,7 +14,6 @@ import {
|
||||||
import { Sub } from '@/subs.ts';
|
import { Sub } from '@/subs.ts';
|
||||||
|
|
||||||
import type { AppController } from '@/app.ts';
|
import type { AppController } from '@/app.ts';
|
||||||
import type { NostrEvent, NostrFilter } from '@/deps.ts';
|
|
||||||
|
|
||||||
/** Limit of initial events returned for a subscription. */
|
/** Limit of initial events returned for a subscription. */
|
||||||
const FILTER_LIMIT = 100;
|
const FILTER_LIMIT = 100;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
import { NostrFilter } from '@nostrify/nostrify';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { Debug, type NostrFilter } from '@/deps.ts';
|
import { Debug } from '@/deps.ts';
|
||||||
import * as pipeline from '@/pipeline.ts';
|
import * as pipeline from '@/pipeline.ts';
|
||||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||||
import { eventsDB } from '@/storages.ts';
|
import { eventsDB } from '@/storages.ts';
|
||||||
|
|
13
src/deps.ts
13
src/deps.ts
|
@ -79,19 +79,6 @@ export { EventEmitter } from 'npm:tseep@^1.1.3';
|
||||||
export { default as stringifyStable } from 'npm:fast-stable-stringify@^1.0.0';
|
export { default as stringifyStable } from 'npm:fast-stable-stringify@^1.0.0';
|
||||||
export { default as Debug } from 'https://gitlab.com/soapbox-pub/stickynotes/-/raw/v0.3.0/debug.ts';
|
export { default as Debug } from 'https://gitlab.com/soapbox-pub/stickynotes/-/raw/v0.3.0/debug.ts';
|
||||||
export { Stickynotes } from 'https://gitlab.com/soapbox-pub/stickynotes/-/raw/v0.3.0/mod.ts';
|
export { Stickynotes } from 'https://gitlab.com/soapbox-pub/stickynotes/-/raw/v0.3.0/mod.ts';
|
||||||
export {
|
|
||||||
LNURL,
|
|
||||||
type LNURLDetails,
|
|
||||||
NCache,
|
|
||||||
NIP05,
|
|
||||||
type NostrEvent,
|
|
||||||
type NostrFilter,
|
|
||||||
type NostrSigner,
|
|
||||||
NSecSigner,
|
|
||||||
NSet,
|
|
||||||
type NStore,
|
|
||||||
type NStoreOpts,
|
|
||||||
} from 'https://gitlab.com/soapbox-pub/NSpec/-/raw/v0.3.0/mod.ts';
|
|
||||||
|
|
||||||
export type * as TypeFest from 'npm:type-fest@^4.3.0';
|
export type * as TypeFest from 'npm:type-fest@^4.3.0';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { type NostrEvent, type NostrFilter, stringifyStable, z } from '@/deps.ts';
|
import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
||||||
|
import { stringifyStable, z } from '@/deps.ts';
|
||||||
import { isReplaceableKind } from '@/kinds.ts';
|
import { isReplaceableKind } from '@/kinds.ts';
|
||||||
import { nostrIdSchema } from '@/schemas/nostr.ts';
|
import { nostrIdSchema } from '@/schemas/nostr.ts';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Debug, type NostrEvent } from '@/deps.ts';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
import { Debug } from '@/deps.ts';
|
||||||
import { activeRelays, pool } from '@/pool.ts';
|
import { activeRelays, pool } from '@/pool.ts';
|
||||||
import { nostrNow } from '@/utils.ts';
|
import { nostrNow } from '@/utils.ts';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { type NostrEvent } from '@/deps.ts';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
|
||||||
/** Ditto internal stats for the event's author. */
|
/** Ditto internal stats for the event's author. */
|
||||||
export interface AuthorStats {
|
export interface AuthorStats {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { type NostrEvent } from '@/deps.ts';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||||
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
|
||||||
|
|
||||||
/** Additional properties that may be added by Ditto to events. */
|
/** Additional properties that may be added by Ditto to events. */
|
||||||
export type DittoRelation = Exclude<keyof DittoEvent, keyof NostrEvent>;
|
export type DittoRelation = Exclude<keyof DittoEvent, keyof NostrEvent>;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
import { type AppContext, type AppMiddleware } from '@/app.ts';
|
import { type AppContext, type AppMiddleware } from '@/app.ts';
|
||||||
import { HTTPException, type NostrEvent } from '@/deps.ts';
|
import { HTTPException } from '@/deps.ts';
|
||||||
import {
|
import {
|
||||||
buildAuthEventTemplate,
|
buildAuthEventTemplate,
|
||||||
parseAuthRequest,
|
parseAuthRequest,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { NSchema as n } from '@soapbox/nspec';
|
import { LNURL, NostrEvent, NSchema as n } from '@nostrify/nostrify';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { db } from '@/db.ts';
|
import { db } from '@/db.ts';
|
||||||
import { addRelays } from '@/db/relays.ts';
|
import { addRelays } from '@/db/relays.ts';
|
||||||
import { deleteAttachedMedia } from '@/db/unattached-media.ts';
|
import { deleteAttachedMedia } from '@/db/unattached-media.ts';
|
||||||
import { Debug, LNURL, type NostrEvent, sql } from '@/deps.ts';
|
import { Debug, sql } from '@/deps.ts';
|
||||||
import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||||
import { isEphemeralKind } from '@/kinds.ts';
|
import { isEphemeralKind } from '@/kinds.ts';
|
||||||
import { DVM } from '@/pipeline/DVM.ts';
|
import { DVM } from '@/pipeline/DVM.ts';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { NIP05, NostrEvent } from '@soapbox/nspec';
|
import { NIP05, NostrEvent } from '@nostrify/nostrify';
|
||||||
|
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import * as pipeline from '@/pipeline.ts';
|
import * as pipeline from '@/pipeline.ts';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { eventsDB, optimizer } from '@/storages.ts';
|
import { eventsDB, optimizer } from '@/storages.ts';
|
||||||
import { Debug, type NostrEvent, type NostrFilter } from '@/deps.ts';
|
import { Debug } from '@/deps.ts';
|
||||||
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||||
import { type DittoRelation } from '@/interfaces/DittoFilter.ts';
|
import { type DittoRelation } from '@/interfaces/DittoFilter.ts';
|
||||||
import { findReplyTag, getTagSet } from '@/tags.ts';
|
import { findReplyTag, getTagSet } from '@/tags.ts';
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
import { NostrEvent, NostrSigner, NSecSigner } from '@nostrify/nostrify';
|
||||||
import { type AppContext } from '@/app.ts';
|
import { type AppContext } from '@/app.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { HTTPException, type NostrEvent, type NostrSigner, NSecSigner, Stickynotes } from '@/deps.ts';
|
import { HTTPException, Stickynotes } from '@/deps.ts';
|
||||||
import { connectResponseSchema } from '@/schemas/nostr.ts';
|
import { connectResponseSchema } from '@/schemas/nostr.ts';
|
||||||
import { jsonSchema } from '@/schema.ts';
|
import { jsonSchema } from '@/schema.ts';
|
||||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import { NSecSigner } from '@nostrify/nostrify';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { NSecSigner } from '@/deps.ts';
|
|
||||||
|
|
||||||
/** Sign events as the Ditto server. */
|
/** Sign events as the Ditto server. */
|
||||||
export class AdminSigner extends NSecSigner {
|
export class AdminSigner extends NSecSigner {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
import { type AuthorStatsRow, db, type DittoDB, type EventStatsRow } from '@/db.ts';
|
import { type AuthorStatsRow, db, type DittoDB, type EventStatsRow } from '@/db.ts';
|
||||||
import { Debug, type InsertQueryBuilder, type NostrEvent } from '@/deps.ts';
|
import { Debug, type InsertQueryBuilder } from '@/deps.ts';
|
||||||
import { eventsDB } from '@/storages.ts';
|
import { eventsDB } from '@/storages.ts';
|
||||||
import { findReplyTag } from '@/tags.ts';
|
import { findReplyTag } from '@/tags.ts';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
import { NCache } from '@nostrify/nostrify';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { db } from '@/db.ts';
|
import { db } from '@/db.ts';
|
||||||
import { NCache } from '@/deps.ts';
|
|
||||||
import * as pipeline from '@/pipeline.ts';
|
import * as pipeline from '@/pipeline.ts';
|
||||||
import { activeRelays, pool } from '@/pool.ts';
|
import { activeRelays, pool } from '@/pool.ts';
|
||||||
import { EventsDB } from '@/storages/events-db.ts';
|
import { EventsDB } from '@/storages/events-db.ts';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { NIP50, NostrFilter } from '@soapbox/nspec';
|
import { NIP50, NostrEvent, NostrFilter, NStore } from '@nostrify/nostrify';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { type DittoDB } from '@/db.ts';
|
import { type DittoDB } from '@/db.ts';
|
||||||
import { Debug, Kysely, type NostrEvent, type NStore, type NStoreOpts, type SelectQueryBuilder } from '@/deps.ts';
|
import { Debug, Kysely, type SelectQueryBuilder } from '@/deps.ts';
|
||||||
import { normalizeFilters } from '@/filter.ts';
|
import { normalizeFilters } from '@/filter.ts';
|
||||||
import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||||
import { isDittoInternalKind, isParameterizedReplaceableKind, isReplaceableKind } from '@/kinds.ts';
|
import { isDittoInternalKind, isParameterizedReplaceableKind, isReplaceableKind } from '@/kinds.ts';
|
||||||
|
@ -66,7 +66,7 @@ class EventsDB implements NStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Insert an event (and its tags) into the database. */
|
/** Insert an event (and its tags) into the database. */
|
||||||
async event(event: NostrEvent, _opts?: NStoreOpts): Promise<void> {
|
async event(event: NostrEvent, _opts?: { signal?: AbortSignal }): Promise<void> {
|
||||||
event = purifyEvent(event);
|
event = purifyEvent(event);
|
||||||
this.#debug('EVENT', JSON.stringify(event));
|
this.#debug('EVENT', JSON.stringify(event));
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ class EventsDB implements NStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get events for filters from the database. */
|
/** Get events for filters from the database. */
|
||||||
async query(filters: NostrFilter[], opts: NStoreOpts = {}): Promise<DittoEvent[]> {
|
async query(filters: NostrFilter[], opts: { signal?: AbortSignal; limit?: number } = {}): Promise<DittoEvent[]> {
|
||||||
filters = await this.expandFilters(filters);
|
filters = await this.expandFilters(filters);
|
||||||
|
|
||||||
if (opts.signal?.aborted) return Promise.resolve([]);
|
if (opts.signal?.aborted) return Promise.resolve([]);
|
||||||
|
@ -328,7 +328,7 @@ class EventsDB implements NStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Delete events based on filters from the database. */
|
/** Delete events based on filters from the database. */
|
||||||
async remove(filters: NostrFilter[], _opts?: NStoreOpts): Promise<void> {
|
async remove(filters: NostrFilter[], _opts?: { signal?: AbortSignal }): Promise<void> {
|
||||||
if (!filters.length) return Promise.resolve();
|
if (!filters.length) return Promise.resolve();
|
||||||
this.#debug('DELETE', JSON.stringify(filters));
|
this.#debug('DELETE', JSON.stringify(filters));
|
||||||
|
|
||||||
|
@ -336,7 +336,10 @@ class EventsDB implements NStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get number of events that would be returned by filters. */
|
/** Get number of events that would be returned by filters. */
|
||||||
async count(filters: NostrFilter[], opts: NStoreOpts = {}): Promise<{ count: number; approximate: boolean }> {
|
async count(
|
||||||
|
filters: NostrFilter[],
|
||||||
|
opts: { signal?: AbortSignal } = {},
|
||||||
|
): Promise<{ count: number; approximate: boolean }> {
|
||||||
if (opts.signal?.aborted) return Promise.reject(abortError());
|
if (opts.signal?.aborted) return Promise.reject(abortError());
|
||||||
if (!filters.length) return Promise.resolve({ count: 0, approximate: false });
|
if (!filters.length) return Promise.resolve({ count: 0, approximate: false });
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
import { NostrEvent, NStore } from '@nostrify/nostrify';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { db } from '@/db.ts';
|
import { db } from '@/db.ts';
|
||||||
import { type NostrEvent, type NStore } from '@/deps.ts';
|
|
||||||
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||||
import { type DittoRelation } from '@/interfaces/DittoFilter.ts';
|
import { type DittoRelation } from '@/interfaces/DittoFilter.ts';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { NostrFilter } from '@soapbox/nspec';
|
import { NostrFilter, NSet, NStore } from '@nostrify/nostrify';
|
||||||
import { Debug, NSet, type NStore, type NStoreOpts } from '@/deps.ts';
|
import { Debug } from '@/deps.ts';
|
||||||
import { normalizeFilters } from '@/filter.ts';
|
import { normalizeFilters } from '@/filter.ts';
|
||||||
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||||
import { abortError } from '@/utils/abort.ts';
|
import { abortError } from '@/utils/abort.ts';
|
||||||
|
@ -23,7 +23,7 @@ class Optimizer implements NStore {
|
||||||
this.#client = opts.client;
|
this.#client = opts.client;
|
||||||
}
|
}
|
||||||
|
|
||||||
async event(event: DittoEvent, opts?: NStoreOpts): Promise<void> {
|
async event(event: DittoEvent, opts?: { signal?: AbortSignal }): Promise<void> {
|
||||||
if (opts?.signal?.aborted) return Promise.reject(abortError());
|
if (opts?.signal?.aborted) return Promise.reject(abortError());
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
@ -32,7 +32,7 @@ class Optimizer implements NStore {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async query(filters: NostrFilter[], opts: NStoreOpts = {}): Promise<DittoEvent[]> {
|
async query(filters: NostrFilter[], opts: { signal?: AbortSignal; limit?: number } = {}): Promise<DittoEvent[]> {
|
||||||
if (opts?.signal?.aborted) return Promise.reject(abortError());
|
if (opts?.signal?.aborted) return Promise.reject(abortError());
|
||||||
|
|
||||||
filters = normalizeFilters(filters);
|
filters = normalizeFilters(filters);
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
import {
|
import { NostrEvent, NostrFilter, NSet, NStore } from '@nostrify/nostrify';
|
||||||
Debug,
|
import { Debug, matchFilters, type RelayPoolWorker } from '@/deps.ts';
|
||||||
matchFilters,
|
|
||||||
type NostrEvent,
|
|
||||||
type NostrFilter,
|
|
||||||
NSet,
|
|
||||||
type NStore,
|
|
||||||
type NStoreOpts,
|
|
||||||
type RelayPoolWorker,
|
|
||||||
} from '@/deps.ts';
|
|
||||||
import { normalizeFilters } from '@/filter.ts';
|
import { normalizeFilters } from '@/filter.ts';
|
||||||
import { purifyEvent } from '@/storages/hydrate.ts';
|
import { purifyEvent } from '@/storages/hydrate.ts';
|
||||||
import { abortError } from '@/utils/abort.ts';
|
import { abortError } from '@/utils/abort.ts';
|
||||||
|
@ -36,7 +28,7 @@ class PoolStore implements NStore {
|
||||||
this.#publisher = opts.publisher;
|
this.#publisher = opts.publisher;
|
||||||
}
|
}
|
||||||
|
|
||||||
async event(event: NostrEvent, opts: NStoreOpts = {}): Promise<void> {
|
async event(event: NostrEvent, opts: { signal?: AbortSignal } = {}): Promise<void> {
|
||||||
if (opts.signal?.aborted) return Promise.reject(abortError());
|
if (opts.signal?.aborted) return Promise.reject(abortError());
|
||||||
|
|
||||||
const relaySet = await getRelays(event.pubkey);
|
const relaySet = await getRelays(event.pubkey);
|
||||||
|
@ -51,7 +43,7 @@ class PoolStore implements NStore {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
query(filters: NostrFilter[], opts: NStoreOpts = {}): Promise<NostrEvent[]> {
|
query(filters: NostrFilter[], opts: { signal?: AbortSignal; limit?: number } = {}): Promise<NostrEvent[]> {
|
||||||
if (opts.signal?.aborted) return Promise.reject(abortError());
|
if (opts.signal?.aborted) return Promise.reject(abortError());
|
||||||
|
|
||||||
filters = normalizeFilters(filters);
|
filters = normalizeFilters(filters);
|
||||||
|
@ -63,7 +55,7 @@ class PoolStore implements NStore {
|
||||||
|
|
||||||
const unsub = this.#pool.subscribe(
|
const unsub = this.#pool.subscribe(
|
||||||
filters,
|
filters,
|
||||||
opts.relays ?? this.#relays,
|
this.#relays,
|
||||||
(event: NostrEvent | null) => {
|
(event: NostrEvent | null) => {
|
||||||
if (event && matchFilters(filters, event)) {
|
if (event && matchFilters(filters, event)) {
|
||||||
this.#publisher.handleEvent(event, AbortSignal.timeout(1000)).catch(() => {});
|
this.#publisher.handleEvent(event, AbortSignal.timeout(1000)).catch(() => {});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Debug, EventEmitter, type NostrEvent, type NostrFilter, type NStore, type NStoreOpts } from '@/deps.ts';
|
import { NostrEvent, NostrFilter, NStore } from '@nostrify/nostrify';
|
||||||
|
import { Debug, EventEmitter } from '@/deps.ts';
|
||||||
import { eventToMicroFilter, getFilterId, isMicrofilter, type MicroFilter } from '@/filter.ts';
|
import { eventToMicroFilter, getFilterId, isMicrofilter, type MicroFilter } from '@/filter.ts';
|
||||||
import { Time } from '@/utils/time.ts';
|
import { Time } from '@/utils/time.ts';
|
||||||
import { abortError } from '@/utils/abort.ts';
|
import { abortError } from '@/utils/abort.ts';
|
||||||
|
@ -110,7 +111,7 @@ class Reqmeister extends EventEmitter<{ [filterId: string]: (event: NostrEvent)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
event(event: NostrEvent, _opts?: NStoreOpts): Promise<void> {
|
event(event: NostrEvent, _opts?: { signal?: AbortSignal }): Promise<void> {
|
||||||
const filterId = getFilterId(eventToMicroFilter(event));
|
const filterId = getFilterId(eventToMicroFilter(event));
|
||||||
this.#queue = this.#queue.filter(([id]) => id !== filterId);
|
this.#queue = this.#queue.filter(([id]) => id !== filterId);
|
||||||
this.emit(filterId, event);
|
this.emit(filterId, event);
|
||||||
|
@ -122,7 +123,7 @@ class Reqmeister extends EventEmitter<{ [filterId: string]: (event: NostrEvent)
|
||||||
return this.#queue.some(([id]) => id === filterId);
|
return this.#queue.some(([id]) => id === filterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
query(filters: NostrFilter[], opts?: NStoreOpts): Promise<NostrEvent[]> {
|
query(filters: NostrFilter[], opts?: { signal?: AbortSignal }): Promise<NostrEvent[]> {
|
||||||
if (opts?.signal?.aborted) return Promise.reject(abortError());
|
if (opts?.signal?.aborted) return Promise.reject(abortError());
|
||||||
|
|
||||||
this.#debug('REQ', JSON.stringify(filters));
|
this.#debug('REQ', JSON.stringify(filters));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { NostrFilter, NRelay1 } from '@soapbox/nspec';
|
import { NostrEvent, NostrFilter, NRelay1, NStore } from '@nostrify/nostrify';
|
||||||
import { Debug, type NostrEvent, type NStore, type NStoreOpts } from '@/deps.ts';
|
import { Debug } from '@/deps.ts';
|
||||||
import { normalizeFilters } from '@/filter.ts';
|
import { normalizeFilters } from '@/filter.ts';
|
||||||
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||||
import { hydrateEvents } from '@/storages/hydrate.ts';
|
import { hydrateEvents } from '@/storages/hydrate.ts';
|
||||||
|
@ -27,11 +27,11 @@ class SearchStore implements NStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event(_event: NostrEvent, _opts?: NStoreOpts): Promise<void> {
|
event(_event: NostrEvent, _opts?: { signal?: AbortSignal }): Promise<void> {
|
||||||
return Promise.reject(new Error('EVENT not implemented.'));
|
return Promise.reject(new Error('EVENT not implemented.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
async query(filters: NostrFilter[], opts?: NStoreOpts): Promise<DittoEvent[]> {
|
async query(filters: NostrFilter[], opts?: { signal?: AbortSignal; limit?: number }): Promise<DittoEvent[]> {
|
||||||
filters = normalizeFilters(filters);
|
filters = normalizeFilters(filters);
|
||||||
|
|
||||||
if (opts?.signal?.aborted) return Promise.reject(abortError());
|
if (opts?.signal?.aborted) return Promise.reject(abortError());
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { NostrFilter } from '@soapbox/nspec';
|
import { NostrFilter } from '@nostrify/nostrify';
|
||||||
import { Debug } from '@/deps.ts';
|
import { Debug } from '@/deps.ts';
|
||||||
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||||
import { Subscription } from '@/subscription.ts';
|
import { Subscription } from '@/subscription.ts';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { NIP50, NostrFilter } from '@soapbox/nspec';
|
import { NIP50, NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
||||||
import { Machina, matchFilter, type NostrEvent } from '@/deps.ts';
|
import { Machina, matchFilter } from '@/deps.ts';
|
||||||
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
import { type DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||||
|
|
||||||
class Subscription implements AsyncIterable<NostrEvent> {
|
class Subscription implements AsyncIterable<NostrEvent> {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { type EventTemplate, getEventHash, nip19, type NostrEvent, z } from '@/deps.ts';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
import { type EventTemplate, getEventHash, nip19, z } from '@/deps.ts';
|
||||||
import { nostrIdSchema } from '@/schemas/nostr.ts';
|
import { nostrIdSchema } from '@/schemas/nostr.ts';
|
||||||
|
|
||||||
/** Get the current time in Nostr format. */
|
/** Get the current time in Nostr format. */
|
||||||
|
|
|
@ -1,16 +1,7 @@
|
||||||
|
import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
||||||
import { type AppContext } from '@/app.ts';
|
import { type AppContext } from '@/app.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import {
|
import { type Context, Debug, EventTemplate, HTTPException, parseFormData, type TypeFest, z } from '@/deps.ts';
|
||||||
type Context,
|
|
||||||
Debug,
|
|
||||||
EventTemplate,
|
|
||||||
HTTPException,
|
|
||||||
type NostrEvent,
|
|
||||||
NostrFilter,
|
|
||||||
parseFormData,
|
|
||||||
type TypeFest,
|
|
||||||
z,
|
|
||||||
} from '@/deps.ts';
|
|
||||||
import * as pipeline from '@/pipeline.ts';
|
import * as pipeline from '@/pipeline.ts';
|
||||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||||
import { APISigner } from '@/signers/APISigner.ts';
|
import { APISigner } from '@/signers/APISigner.ts';
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Debug, LNURL, type LNURLDetails } from '@/deps.ts';
|
import { LNURL, LNURLDetails } from '@nostrify/nostrify';
|
||||||
|
import { Debug } from '@/deps.ts';
|
||||||
import { SimpleLRU } from '@/utils/SimpleLRU.ts';
|
import { SimpleLRU } from '@/utils/SimpleLRU.ts';
|
||||||
import { Time } from '@/utils/time.ts';
|
import { Time } from '@/utils/time.ts';
|
||||||
import { fetchWorker } from '@/workers/fetch.ts';
|
import { fetchWorker } from '@/workers/fetch.ts';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { type NostrEvent } from '@/deps.ts';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
import { getAuthor } from '@/queries.ts';
|
import { getAuthor } from '@/queries.ts';
|
||||||
import { bech32ToPubkey } from '@/utils.ts';
|
import { bech32ToPubkey } from '@/utils.ts';
|
||||||
import { nip05Cache } from '@/utils/nip05.ts';
|
import { nip05Cache } from '@/utils/nip05.ts';
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
import { NIP05 } from '@nostrify/nostrify';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { Debug, NIP05, nip19 } from '@/deps.ts';
|
import { Debug, nip19 } from '@/deps.ts';
|
||||||
import { SimpleLRU } from '@/utils/SimpleLRU.ts';
|
import { SimpleLRU } from '@/utils/SimpleLRU.ts';
|
||||||
import { Time } from '@/utils/time.ts';
|
import { Time } from '@/utils/time.ts';
|
||||||
import { eventsDB } from '@/storages.ts';
|
import { eventsDB } from '@/storages.ts';
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { type EventTemplate, nip13, type NostrEvent } from '@/deps.ts';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
import { type EventTemplate, nip13 } from '@/deps.ts';
|
||||||
import { decode64Schema, jsonSchema } from '@/schema.ts';
|
import { decode64Schema, jsonSchema } from '@/schema.ts';
|
||||||
import { signedEventSchema } from '@/schemas/nostr.ts';
|
import { signedEventSchema } from '@/schemas/nostr.ts';
|
||||||
import { eventAge, findTag, nostrNow, sha256 } from '@/utils.ts';
|
import { eventAge, findTag, nostrNow, sha256 } from '@/utils.ts';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import { NostrFilter } from '@nostrify/nostrify';
|
||||||
import { AppContext } from '@/app.ts';
|
import { AppContext } from '@/app.ts';
|
||||||
import { type NostrFilter } from '@/deps.ts';
|
|
||||||
import { eventsDB } from '@/storages.ts';
|
import { eventsDB } from '@/storages.ts';
|
||||||
import { renderAccount } from '@/views/mastodon/accounts.ts';
|
import { renderAccount } from '@/views/mastodon/accounts.ts';
|
||||||
import { renderStatus } from '@/views/mastodon/statuses.ts';
|
import { renderStatus } from '@/views/mastodon/statuses.ts';
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Conf } from '@/config.ts';
|
||||||
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
||||||
import { getPublicKeyPem } from '@/utils/rsa.ts';
|
import { getPublicKeyPem } from '@/utils/rsa.ts';
|
||||||
|
|
||||||
import type { NostrEvent } from '@/deps.ts';
|
import type { NostrEvent } from '@nostrify/nostrify';
|
||||||
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. */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { type NostrEvent } from '@/deps.ts';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
import { getAuthor } from '@/queries.ts';
|
import { getAuthor } from '@/queries.ts';
|
||||||
import { nostrDate } from '@/utils.ts';
|
import { nostrDate } from '@/utils.ts';
|
||||||
import { accountFromPubkey } from '@/views/mastodon/accounts.ts';
|
import { accountFromPubkey } from '@/views/mastodon/accounts.ts';
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Comlink, type NostrEvent } from '@/deps.ts';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
import { Comlink } from '@/deps.ts';
|
||||||
|
|
||||||
import type { VerifyWorker } from './verify.worker.ts';
|
import type { VerifyWorker } from './verify.worker.ts';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Comlink, type NostrEvent, type VerifiedEvent, verifyEvent } from '@/deps.ts';
|
import { NostrEvent } from '@nostrify/nostrify';
|
||||||
|
import { Comlink, type VerifiedEvent, verifyEvent } from '@/deps.ts';
|
||||||
|
|
||||||
export const VerifyWorker = {
|
export const VerifyWorker = {
|
||||||
verifyEvent(event: NostrEvent): event is VerifiedEvent {
|
verifyEvent(event: NostrEvent): event is VerifiedEvent {
|
||||||
|
|
Loading…
Reference in New Issue