applesauce-relay 0.0.0-next-20251117171749 → 0.0.0-next-20251205152544
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/group.d.ts +6 -7
- package/dist/group.js +2 -1
- package/dist/lib/negentropy.js +1 -1
- package/dist/negentropy.d.ts +3 -3
- package/dist/operators/complete-on-eose.d.ts +1 -1
- package/dist/operators/only-events.d.ts +1 -1
- package/dist/operators/to-event-store.d.ts +1 -1
- package/dist/pool.d.ts +7 -7
- package/dist/pool.js +3 -1
- package/dist/relay.d.ts +7 -8
- package/dist/relay.js +13 -5
- package/dist/types.d.ts +24 -14
- package/package.json +10 -5
package/dist/group.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAsyncEventStoreActions, IEventStoreActions } from "applesauce-core/event-store";
|
|
2
|
+
import type { Filter, NostrEvent } from "applesauce-core/helpers";
|
|
2
3
|
import { BehaviorSubject, MonoTypeOperatorFunction, Observable } from "rxjs";
|
|
3
|
-
import { IAsyncEventStoreActions, IAsyncEventStoreRead, IEventStoreActions, IEventStoreRead } from "applesauce-core";
|
|
4
|
-
import { type FilterWithAnd } from "applesauce-core/helpers";
|
|
5
4
|
import { NegentropySyncOptions, type ReconcileFunction } from "./negentropy.js";
|
|
6
5
|
import { SyncDirection } from "./relay.js";
|
|
7
|
-
import { CountResponse, FilterInput, IGroup, IGroupRelayInput, IRelay, PublishOptions, PublishResponse, RequestOptions, SubscriptionOptions, SubscriptionResponse } from "./types.js";
|
|
6
|
+
import { CountResponse, FilterInput, IGroup, IGroupRelayInput, IRelay, NegentropyReadStore, NegentropySyncStore, PublishOptions, PublishResponse, RequestOptions, SubscriptionOptions, SubscriptionResponse } from "./types.js";
|
|
8
7
|
/** Options for negentropy sync on a group of relays */
|
|
9
8
|
export type GroupNegentropySyncOptions = NegentropySyncOptions & {
|
|
10
9
|
/** Whether to sync in parallel (default true) */
|
|
@@ -47,7 +46,7 @@ export declare class RelayGroup implements IGroup {
|
|
|
47
46
|
/** Send an event to all relays */
|
|
48
47
|
event(event: NostrEvent): Observable<PublishResponse>;
|
|
49
48
|
/** Negentropy sync events with the relays and an event store */
|
|
50
|
-
negentropy(store:
|
|
49
|
+
negentropy(store: NegentropyReadStore, filter: Filter, reconcile: ReconcileFunction, opts?: GroupNegentropySyncOptions): Promise<boolean>;
|
|
51
50
|
/** Publish an event to all relays with retries ( default 3 retries ) */
|
|
52
51
|
publish(event: NostrEvent, opts?: PublishOptions): Promise<PublishResponse[]>;
|
|
53
52
|
/** Request events from all relays and complete on EOSE */
|
|
@@ -55,7 +54,7 @@ export declare class RelayGroup implements IGroup {
|
|
|
55
54
|
/** Open a subscription to all relays with retries ( default 3 retries ) */
|
|
56
55
|
subscription(filters: FilterInput, opts?: GroupSubscriptionOptions): Observable<SubscriptionResponse>;
|
|
57
56
|
/** Count events on all relays in the group */
|
|
58
|
-
count(filters:
|
|
57
|
+
count(filters: Filter | Filter[], id?: string): Observable<Record<string, CountResponse>>;
|
|
59
58
|
/** Negentropy sync events with the relays and an event store */
|
|
60
|
-
sync(store:
|
|
59
|
+
sync(store: NegentropySyncStore | NostrEvent[], filter: Filter, direction?: SyncDirection): Observable<NostrEvent>;
|
|
61
60
|
}
|
package/dist/group.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { EventMemory } from "applesauce-core/event-store";
|
|
2
|
+
import { filterDuplicateEvents } from "applesauce-core/observable";
|
|
1
3
|
import { nanoid } from "nanoid";
|
|
2
4
|
import { BehaviorSubject, catchError, combineLatest, defaultIfEmpty, defer, endWith, filter, from, identity, ignoreElements, lastValueFrom, map, merge, of, scan, share, switchMap, take, takeWhile, toArray, } from "rxjs";
|
|
3
|
-
import { EventMemory, filterDuplicateEvents, } from "applesauce-core";
|
|
4
5
|
import { completeOnEose } from "./operators/complete-on-eose.js";
|
|
5
6
|
import { onlyEvents } from "./operators/only-events.js";
|
|
6
7
|
import { reverseSwitchMap } from "./operators/reverse-switch-map.js";
|
package/dist/lib/negentropy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// (C) 2023 Doug Hoyte. MIT license
|
|
2
2
|
// Modified by hzrd149 to be TypeScript and work without the window.cyrpto.subtle API
|
|
3
|
-
import { sha256 } from "@noble/hashes/
|
|
3
|
+
import { sha256 } from "@noble/hashes/sha2";
|
|
4
4
|
const PROTOCOL_VERSION = 0x61; // Version 1
|
|
5
5
|
const ID_SIZE = 32;
|
|
6
6
|
const FINGERPRINT_SIZE = 16;
|
package/dist/negentropy.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IAsyncEventStoreRead, IEventStoreRead } from "applesauce-core";
|
|
2
|
-
import { type
|
|
2
|
+
import { type Filter } from "applesauce-core/helpers";
|
|
3
3
|
import { NegentropyStorageVector } from "./lib/negentropy.js";
|
|
4
4
|
import { MultiplexWebSocket } from "./types.js";
|
|
5
5
|
/**
|
|
@@ -15,7 +15,7 @@ export type NegentropySyncOptions = {
|
|
|
15
15
|
signal?: AbortSignal;
|
|
16
16
|
};
|
|
17
17
|
/** Creates a NegentropyStorageVector from an event store and filter */
|
|
18
|
-
export declare function buildStorageFromFilter(store: IEventStoreRead | IAsyncEventStoreRead, filter:
|
|
18
|
+
export declare function buildStorageFromFilter(store: IEventStoreRead | IAsyncEventStoreRead, filter: Filter): Promise<NegentropyStorageVector>;
|
|
19
19
|
/** Creates a NegentropyStorageVector from an array of items */
|
|
20
20
|
export declare function buildStorageVector(items: {
|
|
21
21
|
id: string;
|
|
@@ -28,4 +28,4 @@ export declare function buildStorageVector(items: {
|
|
|
28
28
|
*/
|
|
29
29
|
export declare function negentropySync(storage: NegentropyStorageVector, socket: MultiplexWebSocket & {
|
|
30
30
|
next: (msg: any) => void;
|
|
31
|
-
}, filter:
|
|
31
|
+
}, filter: Filter, reconcile: ReconcileFunction, opts?: NegentropySyncOptions): Promise<boolean>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MonoTypeOperatorFunction, OperatorFunction } from "rxjs";
|
|
2
|
-
import { NostrEvent } from "
|
|
2
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
3
|
import { SubscriptionResponse } from "../types.js";
|
|
4
4
|
export declare function completeOnEose(includeEose: true): MonoTypeOperatorFunction<SubscriptionResponse>;
|
|
5
5
|
export declare function completeOnEose(): OperatorFunction<SubscriptionResponse, NostrEvent>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OperatorFunction } from "rxjs";
|
|
2
|
-
import { NostrEvent } from "
|
|
2
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
3
|
import { SubscriptionResponse } from "../types.js";
|
|
4
4
|
/** Filter subscription responses and only return the events */
|
|
5
5
|
export declare function onlyEvents(): OperatorFunction<SubscriptionResponse, NostrEvent>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OperatorFunction } from "rxjs";
|
|
2
2
|
import { IEventStore } from "applesauce-core";
|
|
3
|
-
import { NostrEvent } from "
|
|
3
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
4
4
|
import { SubscriptionResponse } from "../types.js";
|
|
5
5
|
/**
|
|
6
6
|
* Adds all events to event store and returns a deduplicated timeline when EOSE is received
|
package/dist/pool.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { NostrEvent } from "applesauce-core/helpers/event";
|
|
2
|
+
import { Filter } from "applesauce-core/helpers/filter";
|
|
3
|
+
import { FilterMap, OutboxMap } from "applesauce-core/helpers/relay-selection";
|
|
4
4
|
import { BehaviorSubject, Observable, Subject } from "rxjs";
|
|
5
5
|
import { RelayGroup } from "./group.js";
|
|
6
6
|
import type { NegentropySyncOptions, ReconcileFunction } from "./negentropy.js";
|
|
7
7
|
import { Relay, SyncDirection, type RelayOptions } from "./relay.js";
|
|
8
|
-
import type { CountResponse, FilterInput, IPool, IPoolRelayInput, IRelay, PublishResponse, SubscriptionResponse } from "./types.js";
|
|
8
|
+
import type { CountResponse, FilterInput, IPool, IPoolRelayInput, IRelay, NegentropyReadStore, NegentropySyncStore, PublishResponse, SubscriptionResponse } from "./types.js";
|
|
9
9
|
export declare class RelayPool implements IPool {
|
|
10
10
|
options?: RelayOptions | undefined;
|
|
11
11
|
relays$: BehaviorSubject<Map<string, Relay>>;
|
|
@@ -26,7 +26,7 @@ export declare class RelayPool implements IPool {
|
|
|
26
26
|
/** Send an EVENT message to multiple relays */
|
|
27
27
|
event(relays: IPoolRelayInput, event: NostrEvent): Observable<PublishResponse>;
|
|
28
28
|
/** Negentropy sync event ids with the relays and an event store */
|
|
29
|
-
negentropy(relays: IPoolRelayInput, store:
|
|
29
|
+
negentropy(relays: IPoolRelayInput, store: NegentropyReadStore, filter: Filter, reconcile: ReconcileFunction, opts?: NegentropySyncOptions): Promise<boolean>;
|
|
30
30
|
/** Publish an event to multiple relays */
|
|
31
31
|
publish(relays: IPoolRelayInput, event: Parameters<RelayGroup["publish"]>[0], opts?: Parameters<RelayGroup["publish"]>[1]): Promise<PublishResponse[]>;
|
|
32
32
|
/** Request events from multiple relays */
|
|
@@ -38,7 +38,7 @@ export declare class RelayPool implements IPool {
|
|
|
38
38
|
/** Open a subscription for an {@link OutboxMap} and filter */
|
|
39
39
|
outboxSubscription(outboxes: OutboxMap | Observable<OutboxMap>, filter: Omit<Filter, "authors">, options?: Parameters<RelayGroup["subscription"]>[1]): Observable<SubscriptionResponse>;
|
|
40
40
|
/** Count events on multiple relays */
|
|
41
|
-
count(relays: IPoolRelayInput, filters:
|
|
41
|
+
count(relays: IPoolRelayInput, filters: Filter | Filter[], id?: string): Observable<Record<string, CountResponse>>;
|
|
42
42
|
/** Negentropy sync events with the relays and an event store */
|
|
43
|
-
sync(relays: IPoolRelayInput, store:
|
|
43
|
+
sync(relays: IPoolRelayInput, store: NegentropySyncStore | NostrEvent[], filter: Filter, direction?: SyncDirection): Observable<NostrEvent>;
|
|
44
44
|
}
|
package/dist/pool.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isFilterEqual } from "applesauce-core/helpers/filter";
|
|
2
|
+
import { createFilterMap } from "applesauce-core/helpers/relay-selection";
|
|
3
|
+
import { normalizeURL } from "applesauce-core/helpers/url";
|
|
2
4
|
import { BehaviorSubject, distinctUntilChanged, isObservable, map, of, Subject } from "rxjs";
|
|
3
5
|
import { RelayGroup } from "./group.js";
|
|
4
6
|
import { Relay } from "./relay.js";
|
package/dist/relay.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { RelayInformation } from "nostr-tools/nip11";
|
|
1
|
+
import { logger } from "applesauce-core";
|
|
2
|
+
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
3
|
+
import { Filter } from "applesauce-core/helpers/filter";
|
|
5
4
|
import { BehaviorSubject, MonoTypeOperatorFunction, Observable, RepeatConfig, RetryConfig, Subject } from "rxjs";
|
|
6
5
|
import { WebSocketSubject, WebSocketSubjectConfig } from "rxjs/webSocket";
|
|
7
6
|
import { type NegentropySyncOptions, type ReconcileFunction } from "./negentropy.js";
|
|
8
|
-
import { AuthSigner, CountResponse, FilterInput, IRelay, PublishOptions, PublishResponse, RequestOptions, SubscriptionOptions, SubscriptionResponse } from "./types.js";
|
|
7
|
+
import { AuthSigner, CountResponse, FilterInput, IRelay, NegentropyReadStore, NegentropySyncStore, PublishOptions, PublishResponse, RelayInformation, RequestOptions, SubscriptionOptions, SubscriptionResponse } from "./types.js";
|
|
9
8
|
/** Flags for the negentropy sync type */
|
|
10
9
|
export declare enum SyncDirection {
|
|
11
10
|
RECEIVE = 1,
|
|
@@ -106,13 +105,13 @@ export declare class Relay implements IRelay {
|
|
|
106
105
|
/** Create a REQ observable that emits events or "EOSE" or errors */
|
|
107
106
|
req(filters: FilterInput, id?: string): Observable<SubscriptionResponse>;
|
|
108
107
|
/** Create a COUNT observable that emits a single count response */
|
|
109
|
-
count(filters:
|
|
108
|
+
count(filters: Filter | Filter[], id?: string): Observable<CountResponse>;
|
|
110
109
|
/** Send an EVENT or AUTH message and return an observable of PublishResponse that completes or errors */
|
|
111
110
|
event(event: NostrEvent, verb?: "EVENT" | "AUTH"): Observable<PublishResponse>;
|
|
112
111
|
/** send and AUTH message */
|
|
113
112
|
auth(event: NostrEvent): Promise<PublishResponse>;
|
|
114
113
|
/** Negentropy sync event ids with the relay and an event store */
|
|
115
|
-
negentropy(store:
|
|
114
|
+
negentropy(store: NegentropyReadStore, filter: Filter, reconcile: ReconcileFunction, opts?: NegentropySyncOptions): Promise<boolean>;
|
|
116
115
|
/** Authenticate with the relay using a signer */
|
|
117
116
|
authenticate(signer: AuthSigner): Promise<PublishResponse>;
|
|
118
117
|
/** Internal operator for creating the retry() operator */
|
|
@@ -130,7 +129,7 @@ export declare class Relay implements IRelay {
|
|
|
130
129
|
/** Publishes an event to the relay and retries when relay errors or responds with auth-required ( default 3 retries ) */
|
|
131
130
|
publish(event: NostrEvent, opts?: PublishOptions): Promise<PublishResponse>;
|
|
132
131
|
/** Negentropy sync events with the relay and an event store */
|
|
133
|
-
sync(store:
|
|
132
|
+
sync(store: NegentropySyncStore, filter: Filter, direction?: SyncDirection): Observable<NostrEvent>;
|
|
134
133
|
/** Force close the connection */
|
|
135
134
|
close(): void;
|
|
136
135
|
/** An async method that returns the NIP-11 information document for the relay */
|
package/dist/relay.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { logger } from "applesauce-core";
|
|
2
|
-
import { ensureHttpURL } from "applesauce-core/helpers";
|
|
3
|
-
import { simpleTimeout } from "applesauce-core/observable";
|
|
2
|
+
import { ensureHttpURL } from "applesauce-core/helpers/url";
|
|
3
|
+
import { mapEventsToStore, simpleTimeout } from "applesauce-core/observable";
|
|
4
4
|
import { nanoid } from "nanoid";
|
|
5
|
-
import {
|
|
5
|
+
import { makeAuthEvent } from "nostr-tools/nip42";
|
|
6
6
|
import { BehaviorSubject, catchError, combineLatest, defer, endWith, filter, finalize, firstValueFrom, from, identity, ignoreElements, isObservable, lastValueFrom, map, merge, mergeMap, mergeWith, NEVER, Observable, of, repeat, retry, scan, share, shareReplay, Subject, switchMap, take, takeUntil, tap, throwError, timeout, timer, } from "rxjs";
|
|
7
7
|
import { webSocket } from "rxjs/webSocket";
|
|
8
8
|
import { completeOnEose } from "./operators/complete-on-eose.js";
|
|
@@ -410,7 +410,7 @@ export class Relay {
|
|
|
410
410
|
authenticate(signer) {
|
|
411
411
|
if (!this.challenge)
|
|
412
412
|
throw new Error("Have not received authentication challenge");
|
|
413
|
-
const p = signer.signEvent(
|
|
413
|
+
const p = signer.signEvent(makeAuthEvent(this.url, this.challenge));
|
|
414
414
|
const start = p instanceof Promise ? from(p) : of(p);
|
|
415
415
|
return lastValueFrom(start.pipe(switchMap((event) => this.auth(event))));
|
|
416
416
|
}
|
|
@@ -525,7 +525,15 @@ export class Relay {
|
|
|
525
525
|
}
|
|
526
526
|
// Fetch missing events from the relay
|
|
527
527
|
if (direction & SyncDirection.RECEIVE && need.length > 0) {
|
|
528
|
-
await lastValueFrom(this.req({ ids: need }).pipe(
|
|
528
|
+
await lastValueFrom(this.req({ ids: need }).pipe(
|
|
529
|
+
// Complete when EOSE is received
|
|
530
|
+
completeOnEose(),
|
|
531
|
+
// Add events to the store if its writable
|
|
532
|
+
Reflect.has(store, "add")
|
|
533
|
+
? mapEventsToStore(store)
|
|
534
|
+
: identity,
|
|
535
|
+
// Pass events to observer
|
|
536
|
+
tap((event) => observer.next(event))));
|
|
529
537
|
}
|
|
530
538
|
}, { signal: controller.signal })
|
|
531
539
|
// Complete the observable when the sync is complete
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IAsyncEventStoreRead, IEventStoreRead } from "applesauce-core";
|
|
2
|
-
import type {
|
|
3
|
-
import type { EventTemplate, NostrEvent } from "
|
|
4
|
-
import type { RelayInformation } from "nostr-tools/nip11";
|
|
1
|
+
import type { IAsyncEventStoreActions, IAsyncEventStoreRead, IEventStoreRead } from "applesauce-core/event-store";
|
|
2
|
+
import type { Filter } from "applesauce-core/helpers/filter";
|
|
3
|
+
import type { EventTemplate, NostrEvent } from "applesauce-core/helpers/event";
|
|
4
|
+
import type { RelayInformation as CoreRelayInformation } from "nostr-tools/nip11";
|
|
5
5
|
import type { Observable, repeat, retry } from "rxjs";
|
|
6
6
|
import type { WebSocketSubject } from "rxjs/webSocket";
|
|
7
7
|
import type { GroupNegentropySyncOptions, GroupRequestOptions, GroupSubscriptionOptions } from "./group.js";
|
|
@@ -60,7 +60,17 @@ export type AuthSigner = {
|
|
|
60
60
|
signEvent: (event: EventTemplate) => NostrEvent | Promise<NostrEvent>;
|
|
61
61
|
};
|
|
62
62
|
/** Filters that can be passed to request methods on the pool or relay */
|
|
63
|
-
export type FilterInput =
|
|
63
|
+
export type FilterInput = Filter | Filter[] | Observable<Filter | Filter[]> | ((relay: IRelay) => Filter | Filter[] | Observable<Filter | Filter[]>);
|
|
64
|
+
export type RelayInformation = CoreRelayInformation & {
|
|
65
|
+
/** An array of attributes that describe the relay type/characteristics */
|
|
66
|
+
attributes?: string[];
|
|
67
|
+
};
|
|
68
|
+
/** A read only event store for negentropy sync */
|
|
69
|
+
export type NegentropyReadStore = IEventStoreRead | IAsyncEventStoreRead | NostrEvent[];
|
|
70
|
+
/** A writeable event store for negentropy sync */
|
|
71
|
+
export type NegentropyWriteStore = (IAsyncEventStoreRead & IAsyncEventStoreActions) | (IEventStoreRead & IAsyncEventStoreActions);
|
|
72
|
+
/** An event store that can be used for negentropy sync */
|
|
73
|
+
export type NegentropySyncStore = NegentropyReadStore | NegentropyWriteStore;
|
|
64
74
|
export interface IRelay extends MultiplexWebSocket {
|
|
65
75
|
url: string;
|
|
66
76
|
message$: Observable<any>;
|
|
@@ -82,13 +92,13 @@ export interface IRelay extends MultiplexWebSocket {
|
|
|
82
92
|
/** Send a REQ message */
|
|
83
93
|
req(filters: FilterInput, id?: string): Observable<SubscriptionResponse>;
|
|
84
94
|
/** Send a COUNT message */
|
|
85
|
-
count(filters:
|
|
95
|
+
count(filters: Filter | Filter[], id?: string): Observable<CountResponse>;
|
|
86
96
|
/** Send an EVENT message */
|
|
87
97
|
event(event: NostrEvent): Observable<PublishResponse>;
|
|
88
98
|
/** Send an AUTH message */
|
|
89
99
|
auth(event: NostrEvent): Promise<PublishResponse>;
|
|
90
100
|
/** Negentropy sync event ids with the relay and an event store */
|
|
91
|
-
negentropy(store:
|
|
101
|
+
negentropy(store: NegentropyReadStore, filter: Filter, reconcile: ReconcileFunction, opts?: NegentropySyncOptions): Promise<boolean>;
|
|
92
102
|
/** Authenticate with the relay using a signer */
|
|
93
103
|
authenticate(signer: AuthSigner): Promise<PublishResponse>;
|
|
94
104
|
/** Send an EVENT message with retries */
|
|
@@ -98,7 +108,7 @@ export interface IRelay extends MultiplexWebSocket {
|
|
|
98
108
|
/** Open a subscription with retries */
|
|
99
109
|
subscription(filters: FilterInput, opts?: SubscriptionOptions): Observable<SubscriptionResponse>;
|
|
100
110
|
/** Negentropy sync events with the relay and an event store */
|
|
101
|
-
sync(store:
|
|
111
|
+
sync(store: NegentropySyncStore, filter: Filter, direction?: SyncDirection): Observable<NostrEvent>;
|
|
102
112
|
/** Get the NIP-11 information document for the relay */
|
|
103
113
|
getInformation(): Promise<RelayInformation | null>;
|
|
104
114
|
/** Get the limitations for the relay */
|
|
@@ -113,7 +123,7 @@ export interface IGroup {
|
|
|
113
123
|
/** Send an EVENT message */
|
|
114
124
|
event(event: Parameters<IRelay["event"]>[0]): Observable<PublishResponse>;
|
|
115
125
|
/** Negentropy sync event ids with the relays and an event store */
|
|
116
|
-
negentropy(store:
|
|
126
|
+
negentropy(store: NegentropyReadStore, filter: Filter, reconcile: ReconcileFunction, opts?: NegentropySyncOptions): Promise<boolean>;
|
|
117
127
|
/** Add a relay to the group */
|
|
118
128
|
add(relay: IRelay): void;
|
|
119
129
|
/** Remove a relay from the group */
|
|
@@ -127,9 +137,9 @@ export interface IGroup {
|
|
|
127
137
|
/** Open a subscription with retries */
|
|
128
138
|
subscription(filters: Parameters<IRelay["subscription"]>[0], opts?: GroupSubscriptionOptions): Observable<SubscriptionResponse>;
|
|
129
139
|
/** Count events on the relays and an event store */
|
|
130
|
-
count(filters:
|
|
140
|
+
count(filters: Filter | Filter[], id?: string): Observable<Record<string, CountResponse>>;
|
|
131
141
|
/** Negentropy sync events with the relay and an event store */
|
|
132
|
-
sync(store:
|
|
142
|
+
sync(store: NegentropySyncStore, filter: Filter, direction?: SyncDirection): Observable<NostrEvent>;
|
|
133
143
|
}
|
|
134
144
|
/** Signals emitted by the pool */
|
|
135
145
|
export interface IPoolSignals {
|
|
@@ -149,7 +159,7 @@ export interface IPool extends IPoolSignals {
|
|
|
149
159
|
/** Send an EVENT message */
|
|
150
160
|
event(relays: IPoolRelayInput, event: NostrEvent): Observable<PublishResponse>;
|
|
151
161
|
/** Negentropy sync event ids with the relays and an event store */
|
|
152
|
-
negentropy(relays: IPoolRelayInput, store:
|
|
162
|
+
negentropy(relays: IPoolRelayInput, store: NegentropyReadStore, filter: Filter, reconcile: ReconcileFunction, opts?: GroupNegentropySyncOptions): Promise<boolean>;
|
|
153
163
|
/** Send an EVENT message to relays with retries */
|
|
154
164
|
publish(relays: IPoolRelayInput, event: Parameters<IGroup["publish"]>[0], opts?: Parameters<IGroup["publish"]>[1]): Promise<PublishResponse[]>;
|
|
155
165
|
/** Send a REQ message to relays with retries */
|
|
@@ -157,7 +167,7 @@ export interface IPool extends IPoolSignals {
|
|
|
157
167
|
/** Open a subscription to relays with retries */
|
|
158
168
|
subscription(relays: IPoolRelayInput, filters: Parameters<IGroup["subscription"]>[0], opts?: Parameters<IGroup["subscription"]>[1]): Observable<SubscriptionResponse>;
|
|
159
169
|
/** Count events on the relays and an event store */
|
|
160
|
-
count(relays: IPoolRelayInput, filters:
|
|
170
|
+
count(relays: IPoolRelayInput, filters: Filter | Filter[], id?: string): Observable<Record<string, CountResponse>>;
|
|
161
171
|
/** Negentropy sync events with the relay and an event store */
|
|
162
|
-
sync(relays: IPoolRelayInput, store:
|
|
172
|
+
sync(relays: IPoolRelayInput, store: NegentropySyncStore, filter: Filter, direction?: SyncDirection): Observable<NostrEvent>;
|
|
163
173
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-relay",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20251205152544",
|
|
4
4
|
"description": "nostr relay communication framework built on rxjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,6 +24,11 @@
|
|
|
24
24
|
"require": "./dist/pool.js",
|
|
25
25
|
"types": "./dist/pool.d.ts"
|
|
26
26
|
},
|
|
27
|
+
"./group": {
|
|
28
|
+
"import": "./dist/group.js",
|
|
29
|
+
"require": "./dist/group.js",
|
|
30
|
+
"types": "./dist/group.d.ts"
|
|
31
|
+
},
|
|
27
32
|
"./relay": {
|
|
28
33
|
"import": "./dist/relay.js",
|
|
29
34
|
"require": "./dist/relay.js",
|
|
@@ -52,17 +57,17 @@
|
|
|
52
57
|
},
|
|
53
58
|
"dependencies": {
|
|
54
59
|
"@noble/hashes": "^1.7.1",
|
|
55
|
-
"applesauce-core": "0.0.0-next-
|
|
60
|
+
"applesauce-core": "0.0.0-next-20251205152544",
|
|
56
61
|
"nanoid": "^5.0.9",
|
|
57
|
-
"nostr-tools": "~2.
|
|
62
|
+
"nostr-tools": "~2.18",
|
|
58
63
|
"rxjs": "^7.8.1"
|
|
59
64
|
},
|
|
60
65
|
"devDependencies": {
|
|
61
66
|
"@hirez_io/observer-spy": "^2.2.0",
|
|
62
|
-
"applesauce-signers": "
|
|
67
|
+
"applesauce-signers": "0.0.0-next-20251205152544",
|
|
63
68
|
"rimraf": "^6.0.1",
|
|
64
69
|
"typescript": "^5.7.3",
|
|
65
|
-
"vitest": "^
|
|
70
|
+
"vitest": "^4.0.15",
|
|
66
71
|
"vitest-websocket-mock": "^0.5.0"
|
|
67
72
|
},
|
|
68
73
|
"funding": {
|