@welshman/net 0.1.1 → 0.1.2
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/LICENSE +21 -0
- package/dist/lib/src/Deferred.d.ts +21 -0
- package/dist/lib/src/Deferred.d.ts.map +1 -0
- package/dist/lib/src/Deferred.js +21 -0
- package/dist/lib/src/Deferred.js.map +1 -0
- package/dist/lib/src/Emitter.d.ts +14 -0
- package/dist/lib/src/Emitter.d.ts.map +1 -0
- package/dist/lib/src/Emitter.js +18 -0
- package/dist/lib/src/Emitter.js.map +1 -0
- package/dist/lib/src/LRUCache.d.ts +42 -0
- package/dist/lib/src/LRUCache.d.ts.map +1 -0
- package/dist/lib/src/LRUCache.js +62 -0
- package/dist/lib/src/LRUCache.js.map +1 -0
- package/dist/lib/src/TaskQueue.d.ts +18 -0
- package/dist/lib/src/TaskQueue.d.ts.map +1 -0
- package/dist/lib/src/TaskQueue.js +47 -0
- package/dist/lib/src/TaskQueue.js.map +1 -0
- package/dist/lib/src/Tools.d.ts +630 -0
- package/dist/lib/src/Tools.d.ts.map +1 -0
- package/dist/lib/src/Tools.js +1061 -0
- package/dist/lib/src/Tools.js.map +1 -0
- package/dist/lib/src/index.d.ts +7 -0
- package/dist/lib/src/index.d.ts.map +1 -0
- package/dist/lib/src/index.js +7 -0
- package/dist/lib/src/index.js.map +1 -0
- package/dist/lib/src/normalize-url/index.d.ts +286 -0
- package/dist/lib/src/normalize-url/index.d.ts.map +1 -0
- package/dist/lib/src/normalize-url/index.js +252 -0
- package/dist/lib/src/normalize-url/index.js.map +1 -0
- package/{build → dist/net}/src/adapter.d.ts +5 -7
- package/dist/net/src/adapter.d.ts.map +1 -0
- package/dist/net/src/adapter.js.map +1 -0
- package/{build → dist/net}/src/auth.d.ts +6 -21
- package/dist/net/src/auth.d.ts.map +1 -0
- package/{build → dist/net}/src/auth.js +21 -58
- package/dist/net/src/auth.js.map +1 -0
- package/{build → dist/net}/src/context.d.ts +3 -0
- package/dist/net/src/context.d.ts.map +1 -0
- package/dist/net/src/context.js.map +1 -0
- package/{build → dist/net}/src/diff.d.ts +3 -4
- package/dist/net/src/diff.d.ts.map +1 -0
- package/{build → dist/net}/src/diff.js +0 -1
- package/dist/net/src/diff.js.map +1 -0
- package/{build → dist/net}/src/index.d.ts +1 -0
- package/dist/net/src/index.d.ts.map +1 -0
- package/dist/net/src/index.js.map +1 -0
- package/{build → dist/net}/src/message.d.ts +1 -0
- package/dist/net/src/message.d.ts.map +1 -0
- package/dist/net/src/message.js.map +1 -0
- package/{build → dist/net}/src/negentropy.d.ts +2 -1
- package/dist/net/src/negentropy.d.ts.map +1 -0
- package/{build → dist/net}/src/negentropy.js +42 -18
- package/dist/net/src/negentropy.js.map +1 -0
- package/{build → dist/net}/src/policy.d.ts +16 -8
- package/dist/net/src/policy.d.ts.map +1 -0
- package/{build → dist/net}/src/policy.js +61 -83
- package/dist/net/src/policy.js.map +1 -0
- package/{build → dist/net}/src/pool.d.ts +1 -0
- package/dist/net/src/pool.d.ts.map +1 -0
- package/{build → dist/net}/src/pool.js +7 -7
- package/dist/net/src/pool.js.map +1 -0
- package/{build → dist/net}/src/publish.d.ts +6 -21
- package/dist/net/src/publish.d.ts.map +1 -0
- package/{build → dist/net}/src/publish.js +8 -3
- package/dist/net/src/publish.js.map +1 -0
- package/{build → dist/net}/src/request.d.ts +23 -13
- package/dist/net/src/request.d.ts.map +1 -0
- package/{build → dist/net}/src/request.js +19 -10
- package/dist/net/src/request.js.map +1 -0
- package/{build → dist/net}/src/socket.d.ts +11 -9
- package/dist/net/src/socket.d.ts.map +1 -0
- package/{build → dist/net}/src/socket.js +15 -8
- package/dist/net/src/socket.js.map +1 -0
- package/{build → dist/net}/src/tracker.d.ts +1 -0
- package/dist/net/src/tracker.d.ts.map +1 -0
- package/dist/net/src/tracker.js.map +1 -0
- package/dist/net/src/util.d.ts +2 -0
- package/dist/net/src/util.d.ts.map +1 -0
- package/{build → dist/net}/src/util.js.map +1 -1
- package/dist/relay/src/index.d.ts +3 -0
- package/dist/relay/src/index.d.ts.map +1 -0
- package/dist/relay/src/index.js +3 -0
- package/dist/relay/src/index.js.map +1 -0
- package/dist/relay/src/relay.d.ts +13 -0
- package/dist/relay/src/relay.d.ts.map +1 -0
- package/dist/relay/src/relay.js +48 -0
- package/dist/relay/src/relay.js.map +1 -0
- package/dist/relay/src/repository.d.ts +63 -0
- package/dist/relay/src/repository.d.ts.map +1 -0
- package/dist/relay/src/repository.js +270 -0
- package/dist/relay/src/repository.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/util/src/Address.d.ts +21 -0
- package/dist/util/src/Address.d.ts.map +1 -0
- package/dist/util/src/Address.js +43 -0
- package/dist/util/src/Address.js.map +1 -0
- package/dist/util/src/Encryptable.d.ts +34 -0
- package/dist/util/src/Encryptable.d.ts.map +1 -0
- package/dist/util/src/Encryptable.js +52 -0
- package/dist/util/src/Encryptable.js.map +1 -0
- package/dist/util/src/Events.d.ts +77 -0
- package/dist/util/src/Events.d.ts.map +1 -0
- package/dist/util/src/Events.js +62 -0
- package/dist/util/src/Events.js.map +1 -0
- package/dist/util/src/Filters.d.ts +48 -0
- package/dist/util/src/Filters.d.ts.map +1 -0
- package/dist/util/src/Filters.js +185 -0
- package/dist/util/src/Filters.js.map +1 -0
- package/dist/util/src/Handler.d.ts +17 -0
- package/dist/util/src/Handler.d.ts.map +1 -0
- package/dist/util/src/Handler.js +33 -0
- package/dist/util/src/Handler.js.map +1 -0
- package/dist/util/src/Kinds.d.ts +159 -0
- package/dist/util/src/Kinds.d.ts.map +1 -0
- package/dist/util/src/Kinds.js +160 -0
- package/dist/util/src/Kinds.js.map +1 -0
- package/dist/util/src/Links.d.ts +3 -0
- package/dist/util/src/Links.d.ts.map +1 -0
- package/dist/util/src/Links.js +3 -0
- package/dist/util/src/Links.js.map +1 -0
- package/dist/util/src/List.d.ts +32 -0
- package/dist/util/src/List.d.ts.map +1 -0
- package/dist/util/src/List.js +67 -0
- package/dist/util/src/List.js.map +1 -0
- package/dist/util/src/Profile.d.ts +33 -0
- package/dist/util/src/Profile.d.ts.map +1 -0
- package/dist/util/src/Profile.js +49 -0
- package/dist/util/src/Profile.js.map +1 -0
- package/dist/util/src/Relay.d.ts +26 -0
- package/dist/util/src/Relay.d.ts.map +1 -0
- package/dist/util/src/Relay.js +42 -0
- package/dist/util/src/Relay.js.map +1 -0
- package/dist/util/src/Tags.d.ts +32 -0
- package/dist/util/src/Tags.d.ts.map +1 -0
- package/dist/util/src/Tags.js +74 -0
- package/dist/util/src/Tags.js.map +1 -0
- package/dist/util/src/Zaps.d.ts +20 -0
- package/dist/util/src/Zaps.d.ts.map +1 -0
- package/dist/util/src/Zaps.js +93 -0
- package/dist/util/src/Zaps.js.map +1 -0
- package/dist/util/src/index.d.ts +13 -0
- package/dist/util/src/index.d.ts.map +1 -0
- package/dist/util/src/index.js +13 -0
- package/dist/util/src/index.js.map +1 -0
- package/package.json +17 -21
- package/README.md +0 -61
- package/build/src/adapter.js.map +0 -1
- package/build/src/auth.js.map +0 -1
- package/build/src/context.js.map +0 -1
- package/build/src/diff.js.map +0 -1
- package/build/src/index.js.map +0 -1
- package/build/src/message.js.map +0 -1
- package/build/src/negentropy.js.map +0 -1
- package/build/src/policy.js.map +0 -1
- package/build/src/pool.js.map +0 -1
- package/build/src/publish.js.map +0 -1
- package/build/src/request.js.map +0 -1
- package/build/src/socket.js.map +0 -1
- package/build/src/tracker.js.map +0 -1
- package/build/src/util.d.ts +0 -3
- package/build/tsconfig.tsbuildinfo +0 -1
- /package/{build → dist/net}/src/adapter.js +0 -0
- /package/{build → dist/net}/src/context.js +0 -0
- /package/{build → dist/net}/src/index.js +0 -0
- /package/{build → dist/net}/src/message.js +0 -0
- /package/{build → dist/net}/src/tracker.js +0 -0
- /package/{build → dist/net}/src/util.js +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { decode, naddrEncode } from "nostr-tools/nip19";
|
|
2
|
+
export class Address {
|
|
3
|
+
kind;
|
|
4
|
+
pubkey;
|
|
5
|
+
identifier;
|
|
6
|
+
relays;
|
|
7
|
+
constructor(kind, pubkey, identifier, relays = []) {
|
|
8
|
+
this.kind = kind;
|
|
9
|
+
this.pubkey = pubkey;
|
|
10
|
+
this.identifier = identifier;
|
|
11
|
+
this.relays = relays;
|
|
12
|
+
}
|
|
13
|
+
static isAddress(address) {
|
|
14
|
+
return Boolean(address.match(/^\d+:\w+:.*$/));
|
|
15
|
+
}
|
|
16
|
+
static from(address, relays = []) {
|
|
17
|
+
const [kind, pubkey, identifier = ""] = address.match(/^(\d+):(\w+):(.*)$/).slice(1);
|
|
18
|
+
return new Address(parseInt(kind), pubkey, identifier, relays);
|
|
19
|
+
}
|
|
20
|
+
static fromNaddr(naddr) {
|
|
21
|
+
let decoded;
|
|
22
|
+
try {
|
|
23
|
+
decoded = decode(naddr);
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
// pass
|
|
27
|
+
}
|
|
28
|
+
if (decoded?.type !== "naddr") {
|
|
29
|
+
throw new Error(`Invalid naddr ${naddr}`);
|
|
30
|
+
}
|
|
31
|
+
const { kind, pubkey, identifier, relays } = decoded.data;
|
|
32
|
+
return new Address(kind, pubkey, identifier, relays);
|
|
33
|
+
}
|
|
34
|
+
static fromEvent(event, relays = []) {
|
|
35
|
+
const identifier = event.tags.find(t => t[0] === "d")?.[1] || "";
|
|
36
|
+
return new Address(event.kind, event.pubkey, identifier, relays);
|
|
37
|
+
}
|
|
38
|
+
toString = () => `${this.kind}:${this.pubkey}:${this.identifier}`;
|
|
39
|
+
toNaddr = () => naddrEncode(this);
|
|
40
|
+
}
|
|
41
|
+
// Utils
|
|
42
|
+
export const getAddress = (e) => Address.fromEvent(e).toString();
|
|
43
|
+
//# sourceMappingURL=Address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Address.js","sourceRoot":"","sources":["../../../../util/src/Address.ts"],"names":[],"m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,MAAM,CAAC,CAAA;IACtD,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,KAAuB,EAAE,SAAmB,EAAE;QAC7D,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;QAEhE,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAAA;IAClE,CAAC;IAED,QAAQ,GAAG,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE,CAAA;IAEjE,OAAO,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;CAClC;AAED,QAAQ;AAER,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAmB,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { EventContent, TrustedEvent, EventTemplate } from "./Events.js";
|
|
2
|
+
export type Encrypt = (x: string) => Promise<string>;
|
|
3
|
+
export type EncryptableUpdates = Partial<EventContent>;
|
|
4
|
+
export type DecryptedEvent = TrustedEvent & {
|
|
5
|
+
plaintext: EncryptableUpdates;
|
|
6
|
+
};
|
|
7
|
+
export declare const asDecryptedEvent: (event: TrustedEvent, plaintext?: EncryptableUpdates) => DecryptedEvent;
|
|
8
|
+
/**
|
|
9
|
+
* Represents an encryptable event with optional updates.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Encryptable<T extends EventTemplate> {
|
|
12
|
+
readonly event: Partial<T>;
|
|
13
|
+
readonly updates: EncryptableUpdates;
|
|
14
|
+
/**
|
|
15
|
+
* Creates an instance of Encryptable.
|
|
16
|
+
* @param event - An EventTemplate with optional tags and content.
|
|
17
|
+
* @param updates - Plaintext updates to be applied to the event content.
|
|
18
|
+
* @example
|
|
19
|
+
* Here's an example which enables updating a private mute list:
|
|
20
|
+
* ```
|
|
21
|
+
* const event = {kind: 10000, content: "", tags: []} // An event, only kind is required
|
|
22
|
+
* const encryptable = new Encryptable(event, {content: JSON.stringify([["e", "bad word"]])})
|
|
23
|
+
* const eventTemplate = await encryptable.reconcile(myEncryptFunction)
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
constructor(event: Partial<T>, updates: EncryptableUpdates);
|
|
27
|
+
/**
|
|
28
|
+
* Encrypts plaintext updates and merges them into the event template.
|
|
29
|
+
* @param encrypt - The encryption function to be used.
|
|
30
|
+
* @returns A promise that resolves to the reconciled and encrypted event.
|
|
31
|
+
*/
|
|
32
|
+
reconcile(encrypt: Encrypt): Promise<T>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=Encryptable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Encryptable.d.ts","sourceRoot":"","sources":["../../../../util/src/Encryptable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,aAAa,CAAA;AAE1E,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;AAEpD,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AAEtD,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG;IAC1C,SAAS,EAAE,kBAAkB,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,YAAY,EAAE,YAAW,kBAAuB,KAC3D,cAAc,CAAA;AAE3C;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC,SAAS,aAAa;IAc5C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,kBAAkB;IAdtC;;;;;;;;;;;OAWG;gBAEQ,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,EACjB,OAAO,EAAE,kBAAkB;IAGtC;;;;OAIG;IACG,SAAS,CAAC,OAAO,EAAE,OAAO;CA4BjC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export const asDecryptedEvent = (event, plaintext = {}) => ({ ...event, plaintext });
|
|
2
|
+
/**
|
|
3
|
+
* Represents an encryptable event with optional updates.
|
|
4
|
+
*/
|
|
5
|
+
export class Encryptable {
|
|
6
|
+
event;
|
|
7
|
+
updates;
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of Encryptable.
|
|
10
|
+
* @param event - An EventTemplate with optional tags and content.
|
|
11
|
+
* @param updates - Plaintext updates to be applied to the event content.
|
|
12
|
+
* @example
|
|
13
|
+
* Here's an example which enables updating a private mute list:
|
|
14
|
+
* ```
|
|
15
|
+
* const event = {kind: 10000, content: "", tags: []} // An event, only kind is required
|
|
16
|
+
* const encryptable = new Encryptable(event, {content: JSON.stringify([["e", "bad word"]])})
|
|
17
|
+
* const eventTemplate = await encryptable.reconcile(myEncryptFunction)
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
constructor(event, updates) {
|
|
21
|
+
this.event = event;
|
|
22
|
+
this.updates = updates;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Encrypts plaintext updates and merges them into the event template.
|
|
26
|
+
* @param encrypt - The encryption function to be used.
|
|
27
|
+
* @returns A promise that resolves to the reconciled and encrypted event.
|
|
28
|
+
*/
|
|
29
|
+
async reconcile(encrypt) {
|
|
30
|
+
const encryptContent = () => {
|
|
31
|
+
if (!this.updates.content)
|
|
32
|
+
return null;
|
|
33
|
+
return encrypt(this.updates.content);
|
|
34
|
+
};
|
|
35
|
+
const encryptTags = () => {
|
|
36
|
+
if (!this.updates.tags)
|
|
37
|
+
return null;
|
|
38
|
+
return Promise.all(this.updates.tags.map(async (tag) => {
|
|
39
|
+
tag[1] = await encrypt(tag[1]);
|
|
40
|
+
return tag;
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
const [content, tags] = await Promise.all([encryptContent(), encryptTags()]);
|
|
44
|
+
// Updates are optional. If not provided, fall back to the event's content and tags.
|
|
45
|
+
return {
|
|
46
|
+
...this.event,
|
|
47
|
+
tags: tags || this.event.tags || [],
|
|
48
|
+
content: content || this.event.content || "",
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=Encryptable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Encryptable.js","sourceRoot":"","sources":["../../../../util/src/Encryptable.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAmB,EAAE,YAAgC,EAAE,EAAE,EAAE,CAC1F,CAAC,EAAC,GAAG,KAAK,EAAE,SAAS,EAAC,CAAmB,CAAA;AAE3C;;GAEG;AACH,MAAM,OAAO,WAAW;IAcX;IACA;IAdX;;;;;;;;;;;OAWG;IACH,YACW,KAAiB,EACjB,OAA2B;QAD3B,UAAK,GAAL,KAAK,CAAY;QACjB,YAAO,GAAP,OAAO,CAAoB;IACnC,CAAC;IAEJ;;;;OAIG;IACH,KAAK,CAAC,SAAS,CAAC,OAAgB;QAC9B,MAAM,cAAc,GAAG,GAAG,EAAE;YAC1B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO;gBAAE,OAAO,IAAI,CAAA;YAEtC,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QACtC,CAAC,CAAA;QAED,MAAM,WAAW,GAAG,GAAG,EAAE;YACvB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI;gBAAE,OAAO,IAAI,CAAA;YAEnC,OAAO,OAAO,CAAC,GAAG,CAChB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAC,GAAG,EAAC,EAAE;gBAChC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;gBAE9B,OAAO,GAAG,CAAA;YACZ,CAAC,CAAC,CACH,CAAA;QACH,CAAC,CAAA;QAED,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,CAAA;QAE5E,oFAAoF;QACpF,OAAO;YACL,GAAG,IAAI,CAAC,KAAK;YACb,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE;YACnC,OAAO,EAAE,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE;SACxC,CAAA;IACR,CAAC;CACF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { verifiedSymbol } from "nostr-tools/pure";
|
|
2
|
+
export type EventContent = {
|
|
3
|
+
tags: string[][];
|
|
4
|
+
content: string;
|
|
5
|
+
};
|
|
6
|
+
export type EventTemplate = EventContent & {
|
|
7
|
+
kind: number;
|
|
8
|
+
};
|
|
9
|
+
export type StampedEvent = EventTemplate & {
|
|
10
|
+
created_at: number;
|
|
11
|
+
};
|
|
12
|
+
export type OwnedEvent = StampedEvent & {
|
|
13
|
+
pubkey: string;
|
|
14
|
+
};
|
|
15
|
+
export type HashedEvent = OwnedEvent & {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
export type SignedEvent = HashedEvent & {
|
|
19
|
+
sig: string;
|
|
20
|
+
[verifiedSymbol]?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type UnwrappedEvent = HashedEvent & {
|
|
23
|
+
wrap: SignedEvent;
|
|
24
|
+
};
|
|
25
|
+
export type TrustedEvent = HashedEvent & {
|
|
26
|
+
sig?: string;
|
|
27
|
+
wrap?: SignedEvent;
|
|
28
|
+
[verifiedSymbol]?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export type MakeEventOpts = {
|
|
31
|
+
content?: string;
|
|
32
|
+
tags?: string[][];
|
|
33
|
+
created_at?: number;
|
|
34
|
+
};
|
|
35
|
+
export declare const makeEvent: (kind: number, { content, tags, created_at }?: MakeEventOpts) => {
|
|
36
|
+
kind: number;
|
|
37
|
+
content: string;
|
|
38
|
+
tags: string[][];
|
|
39
|
+
created_at: number;
|
|
40
|
+
};
|
|
41
|
+
export declare const createEvent: (kind: number, { content, tags, created_at }?: MakeEventOpts) => {
|
|
42
|
+
kind: number;
|
|
43
|
+
content: string;
|
|
44
|
+
tags: string[][];
|
|
45
|
+
created_at: number;
|
|
46
|
+
};
|
|
47
|
+
export declare const verifyEvent: (event: TrustedEvent) => boolean | "" | undefined;
|
|
48
|
+
export declare const isEventTemplate: (e: EventTemplate) => e is EventTemplate;
|
|
49
|
+
export declare const isStampedEvent: (e: StampedEvent) => e is StampedEvent;
|
|
50
|
+
export declare const isOwnedEvent: (e: OwnedEvent) => e is OwnedEvent;
|
|
51
|
+
export declare const isHashedEvent: (e: HashedEvent) => e is HashedEvent;
|
|
52
|
+
export declare const isSignedEvent: (e: TrustedEvent) => e is SignedEvent;
|
|
53
|
+
export declare const isUnwrappedEvent: (e: TrustedEvent) => e is UnwrappedEvent;
|
|
54
|
+
export declare const isTrustedEvent: (e: TrustedEvent) => e is TrustedEvent;
|
|
55
|
+
export declare const asEventTemplate: (e: EventTemplate) => EventTemplate;
|
|
56
|
+
export declare const asStampedEvent: (e: StampedEvent) => StampedEvent;
|
|
57
|
+
export declare const asOwnedEvent: (e: OwnedEvent) => OwnedEvent;
|
|
58
|
+
export declare const asHashedEvent: (e: HashedEvent) => HashedEvent;
|
|
59
|
+
export declare const asSignedEvent: (e: SignedEvent) => SignedEvent;
|
|
60
|
+
export declare const asUnwrappedEvent: (e: UnwrappedEvent) => UnwrappedEvent;
|
|
61
|
+
export declare const asTrustedEvent: (e: TrustedEvent) => TrustedEvent;
|
|
62
|
+
export declare const getIdentifier: (e: EventTemplate) => string | undefined;
|
|
63
|
+
export declare const getIdOrAddress: (e: HashedEvent) => string;
|
|
64
|
+
export declare const getIdAndAddress: (e: HashedEvent) => string[];
|
|
65
|
+
export declare const isEphemeral: (e: EventTemplate) => boolean;
|
|
66
|
+
export declare const isReplaceable: (e: EventTemplate) => boolean;
|
|
67
|
+
export declare const isPlainReplaceable: (e: EventTemplate) => boolean;
|
|
68
|
+
export declare const isParameterizedReplaceable: (e: EventTemplate) => boolean;
|
|
69
|
+
export declare const getAncestors: ({ kind, tags }: EventTemplate) => Record<string, string[]>;
|
|
70
|
+
export declare const getParentIdsAndAddrs: (event: EventTemplate) => string[];
|
|
71
|
+
export declare const getParentIdOrAddr: (event: EventTemplate) => string | undefined;
|
|
72
|
+
export declare const getParentIds: (event: EventTemplate) => string[];
|
|
73
|
+
export declare const getParentId: (event: EventTemplate) => string | undefined;
|
|
74
|
+
export declare const getParentAddrs: (event: EventTemplate) => string[];
|
|
75
|
+
export declare const getParentAddr: (event: EventTemplate) => string | undefined;
|
|
76
|
+
export declare const isChildOf: (child: EventTemplate, parent: HashedEvent) => boolean;
|
|
77
|
+
//# sourceMappingURL=Events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Events.d.ts","sourceRoot":"","sources":["../../../../util/src/Events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAiC,MAAM,kBAAkB,CAAA;AAc/E,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG;IACzC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG;IACzC,UAAU,EAA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O,MAAM,YAAY,GAAI,OAAO,aAAa,aAOhD,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,aAAa,uBAA+B,CAAA;AAE/E,eAAO,MAAM,cAAc,GAAI,OAAO,aAAa,aAOlD,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,OAAO,aAAa,uBAAiC,CAAA;AAEnF,eAAO,MAAM,SAAS,GAAI,OAAO,aAAa,EAAE,QAAQ,WAAW,YAIlE,CAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { verifiedSymbol, verifyEvent as verifyEventPure } from "nostr-tools/pure";
|
|
2
|
+
import { setNostrWasm, verifyEvent as verifyEventWasm } from "nostr-tools/wasm";
|
|
3
|
+
import { initNostrWasm } from "nostr-wasm";
|
|
4
|
+
import { mapVals, noop, first, pick, now } from "@welshman/lib";
|
|
5
|
+
import { getReplyTagValues, getCommentTagValues } from "./Tags.js";
|
|
6
|
+
import { getAddress, Address } from "./Address.js";
|
|
7
|
+
import { COMMENT, isEphemeralKind, isReplaceableKind, isPlainReplaceableKind, isParameterizedReplaceableKind, } from "./Kinds.js";
|
|
8
|
+
export const makeEvent = (kind, { content = "", tags = [], created_at = now() } = {}) => ({ kind, content, tags, created_at });
|
|
9
|
+
export const createEvent = makeEvent;
|
|
10
|
+
export const verifyEvent = (() => {
|
|
11
|
+
let verify = verifyEventPure;
|
|
12
|
+
if (typeof WebAssembly === "object") {
|
|
13
|
+
initNostrWasm()
|
|
14
|
+
.then(setNostrWasm, noop)
|
|
15
|
+
.then(() => {
|
|
16
|
+
verify = verifyEventWasm;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return (event) => event.sig && (event[verifiedSymbol] || verify(event));
|
|
20
|
+
})();
|
|
21
|
+
export const isEventTemplate = (e) => Boolean(typeof e.kind === "number" && Array.isArray(e.tags) && typeof e.content === "string");
|
|
22
|
+
export const isStampedEvent = (e) => Boolean(isEventTemplate(e) && e.created_at >= 0);
|
|
23
|
+
export const isOwnedEvent = (e) => Boolean(isStampedEvent(e) && e.pubkey);
|
|
24
|
+
export const isHashedEvent = (e) => Boolean(isOwnedEvent(e) && e.id);
|
|
25
|
+
export const isSignedEvent = (e) => Boolean(isHashedEvent(e) && e.sig);
|
|
26
|
+
export const isUnwrappedEvent = (e) => Boolean(isHashedEvent(e) && e.wrap);
|
|
27
|
+
export const isTrustedEvent = (e) => isSignedEvent(e) || isUnwrappedEvent(e);
|
|
28
|
+
export const asEventTemplate = (e) => pick(["kind", "tags", "content"], e);
|
|
29
|
+
export const asStampedEvent = (e) => pick(["kind", "tags", "content", "created_at"], e);
|
|
30
|
+
export const asOwnedEvent = (e) => pick(["kind", "tags", "content", "created_at", "pubkey"], e);
|
|
31
|
+
export const asHashedEvent = (e) => pick(["kind", "tags", "content", "created_at", "pubkey", "id"], e);
|
|
32
|
+
export const asSignedEvent = (e) => pick(["kind", "tags", "content", "created_at", "pubkey", "id", "sig"], e);
|
|
33
|
+
export const asUnwrappedEvent = (e) => pick(["kind", "tags", "content", "created_at", "pubkey", "id", "wrap"], e);
|
|
34
|
+
export const asTrustedEvent = (e) => pick(["kind", "tags", "content", "created_at", "pubkey", "id", "sig", "wrap"], e);
|
|
35
|
+
export const getIdentifier = (e) => e.tags.find(t => t[0] === "d")?.[1];
|
|
36
|
+
export const getIdOrAddress = (e) => (isReplaceable(e) ? getAddress(e) : e.id);
|
|
37
|
+
export const getIdAndAddress = (e) => isReplaceable(e) ? [e.id, getAddress(e)] : [e.id];
|
|
38
|
+
export const isEphemeral = (e) => isEphemeralKind(e.kind);
|
|
39
|
+
export const isReplaceable = (e) => isReplaceableKind(e.kind);
|
|
40
|
+
export const isPlainReplaceable = (e) => isPlainReplaceableKind(e.kind);
|
|
41
|
+
export const isParameterizedReplaceable = (e) => isParameterizedReplaceableKind(e.kind);
|
|
42
|
+
export const getAncestors = ({ kind, tags }) => kind === COMMENT ? getCommentTagValues(tags) : getReplyTagValues(tags);
|
|
43
|
+
export const getParentIdsAndAddrs = (event) => {
|
|
44
|
+
const { roots, replies } = getAncestors(event);
|
|
45
|
+
return replies.length > 0 ? replies : roots;
|
|
46
|
+
};
|
|
47
|
+
export const getParentIdOrAddr = (event) => first(getParentIdsAndAddrs(event));
|
|
48
|
+
export const getParentIds = (event) => {
|
|
49
|
+
const { roots, replies } = mapVals(ids => ids.filter(id => !Address.isAddress(id)), getAncestors(event));
|
|
50
|
+
return replies.length > 0 ? replies : roots;
|
|
51
|
+
};
|
|
52
|
+
export const getParentId = (event) => first(getParentIds(event));
|
|
53
|
+
export const getParentAddrs = (event) => {
|
|
54
|
+
const { roots, replies } = mapVals(ids => ids.filter(id => Address.isAddress(id)), getAncestors(event));
|
|
55
|
+
return replies.length > 0 ? replies : roots;
|
|
56
|
+
};
|
|
57
|
+
export const getParentAddr = (event) => first(getParentAddrs(event));
|
|
58
|
+
export const isChildOf = (child, parent) => {
|
|
59
|
+
const idsAndAddrs = getParentIdsAndAddrs(child);
|
|
60
|
+
return getIdAndAddress(parent).some(x => idsAndAddrs.includes(x));
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=Events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Events.js","sourceRoot":"","sources":["../../../../util/src/Events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,WAAW,IAAI,eAAe,EAAC,MAAM,kBAAkB,CAAA;AAC/E,OAAO,EAAC,YAAY,EAAE,WAAW,IAAI,eAAe,EAAC,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAA;AACxC,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAC,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAC,iBAAiB,EAAE,mBAAmB,EAAC,MAAM,WAAW,CAAA;AAChE,OAAO,EAAC,UAAU,EAAE,OAAO,EAAC,MAAM,cAAc,CAAA;AAChD,OAAO,EACL,O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48 @@
|
|
|
1
|
+
import type { HashedEvent, TrustedEvent } from "./Events.js";
|
|
2
|
+
export declare const EPOCH = 1609459200;
|
|
3
|
+
export declare const neverFilter: {
|
|
4
|
+
ids: never[];
|
|
5
|
+
};
|
|
6
|
+
export type Filter = {
|
|
7
|
+
ids?: string[];
|
|
8
|
+
kinds?: number[];
|
|
9
|
+
authors?: string[];
|
|
10
|
+
since?: number;
|
|
11
|
+
until?: number;
|
|
12
|
+
limit?: number;
|
|
13
|
+
search?: string;
|
|
14
|
+
[key: `#${string}`]: string[];
|
|
15
|
+
};
|
|
16
|
+
export declare const matchFilter: <E extends HashedEvent>(filter: Filter, event: E) => boolean;
|
|
17
|
+
export declare const matchFilters: <E extends HashedEvent>(filters: Filter[], event: E) => boolean;
|
|
18
|
+
export declare const getFilterId: (filter: Filter) => string;
|
|
19
|
+
export declare const calculateFilterGroup: ({ since, until, limit, search, ...filter }: Filter) => string;
|
|
20
|
+
export declare const unionFilters: (filters: Filter[]) => Filter[];
|
|
21
|
+
export declare const intersectFilters: (groups: Filter[][]) => Filter[];
|
|
22
|
+
export declare const getIdFilters: (idsOrAddresses: string[]) => Filter[];
|
|
23
|
+
export declare const getReplyFilters: (events: TrustedEvent[], filter?: Filter) => ({
|
|
24
|
+
"#a": string[];
|
|
25
|
+
ids?: string[];
|
|
26
|
+
kinds?: number[];
|
|
27
|
+
authors?: string[];
|
|
28
|
+
since?: number;
|
|
29
|
+
until?: number;
|
|
30
|
+
limit?: number;
|
|
31
|
+
search?: string;
|
|
32
|
+
} | {
|
|
33
|
+
"#e": string[];
|
|
34
|
+
ids?: string[];
|
|
35
|
+
kinds?: number[];
|
|
36
|
+
authors?: string[];
|
|
37
|
+
since?: number;
|
|
38
|
+
until?: number;
|
|
39
|
+
limit?: number;
|
|
40
|
+
search?: string;
|
|
41
|
+
})[];
|
|
42
|
+
export declare const addRepostFilters: (filters: Filter[]) => Filter[];
|
|
43
|
+
export declare const getFilterGenerality: (filter: Filter) => number;
|
|
44
|
+
export declare const guessFilterDelta: (filters: Filter[], max?: number) => number;
|
|
45
|
+
export declare const getFilterResultCardinality: (filter: Filter) => number | undefined;
|
|
46
|
+
export declare const trimFilter: (filter: Filter) => Filter;
|
|
47
|
+
export declare const trimFilters: (filters: Filter[]) => Filter[];
|
|
48
|
+
//# sourceMappingURL=Filters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Filters.d.ts","sourceRoot":"","sources":["../../../../util/src/Filters.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAC,WAAW,EAAE,YAAY,EAAc,MAAM,aAAa,CAAA;AAIvE,eAAO,MAAM,KAAK,aAAa,CAAA;AAE/B,eAAO,MAAM,WAAW;;CAAY,CAAA;AAEpC,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,CAAC,GAAG,EAAE,IAAI,MAAM,EAAE,GAAG,MAAM,EAAE,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,WAAW,EAAE,QAAQ,MAAM,EAAE,OAAO,CAAC,YAmB1E,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,WAAW,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,CAAC,YAQ9E,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,WAczC,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,4CAA0C,MAAM,WASpF,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,EAAE,aAmB7C,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,EAAE,aA8BlD,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,gBAAgB,MAAM,EAAE,aAyBpD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,QAAQ,YAAY,EAAE,EAAE,SAAQ,MAAW;;UApJnE,MAAM,EAAE;YACN,MAAM,EAAE;cACN,MAAM,EAAE;YACV,MAAM;YACN,MAAM;YACN,MAAM;aACL,MAAM;;;UANT,MAAM,EAAE;YACN,MAAM,EAAE;cACN,MAAM,EAAE;YACV,MAAM;YACN,MAAM;YACN,MAAM;aACL,MAAM;IAyKhB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,SAAS,MAAM,EAAE,aAmB9C,CAAA;AAEJ,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,WAgBjD,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,SAAS,MAAM,EAAE,EAAE,YAAkB,WACO,CAAA;AAG7E,eAAO,MAAM,0BAA0B,GAAI,QAAQ,MAAM,uBAMxD,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,KAAG,MAI/B,CAAA;AAEb,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,EAAE,aAA4B,CAAA"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { matchFilter as nostrToolsMatchFilter } from "nostr-tools/filter";
|
|
2
|
+
import { without, uniqBy, prop, mapVals, shuffle, avg, hash, groupBy, randomId, uniq, } from "@welshman/lib";
|
|
3
|
+
import { isReplaceableKind } from "./Kinds.js";
|
|
4
|
+
import { Address, getAddress } from "./Address.js";
|
|
5
|
+
export const EPOCH = 1609459200;
|
|
6
|
+
export const neverFilter = { ids: [] };
|
|
7
|
+
export const matchFilter = (filter, event) => {
|
|
8
|
+
if (!nostrToolsMatchFilter(filter, event)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (filter.search) {
|
|
12
|
+
const content = event.content.toLowerCase();
|
|
13
|
+
const terms = filter.search.toLowerCase().split(/\s+/g);
|
|
14
|
+
for (const term of terms) {
|
|
15
|
+
if (content.includes(term)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
};
|
|
23
|
+
export const matchFilters = (filters, event) => {
|
|
24
|
+
for (const filter of filters) {
|
|
25
|
+
if (matchFilter(filter, event)) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
};
|
|
31
|
+
export const getFilterId = (filter) => {
|
|
32
|
+
const keys = Object.keys(filter);
|
|
33
|
+
keys.sort();
|
|
34
|
+
const parts = [];
|
|
35
|
+
for (const k of keys) {
|
|
36
|
+
const v = filter[k];
|
|
37
|
+
const s = Array.isArray(v) ? v.join(",") : v;
|
|
38
|
+
parts.push(`${k}:${s}`);
|
|
39
|
+
}
|
|
40
|
+
return hash(parts.join("|"));
|
|
41
|
+
};
|
|
42
|
+
export const calculateFilterGroup = ({ since, until, limit, search, ...filter }) => {
|
|
43
|
+
const group = Object.keys(filter);
|
|
44
|
+
if (since)
|
|
45
|
+
group.push(`since:${since}`);
|
|
46
|
+
if (until)
|
|
47
|
+
group.push(`until:${until}`);
|
|
48
|
+
if (limit)
|
|
49
|
+
group.push(`limit:${randomId()}`);
|
|
50
|
+
if (search)
|
|
51
|
+
group.push(`search:${search}`);
|
|
52
|
+
return group.sort().join("-");
|
|
53
|
+
};
|
|
54
|
+
export const unionFilters = (filters) => {
|
|
55
|
+
const result = [];
|
|
56
|
+
// Group, but also get unique filters by ids because duplicates can come through subscribe
|
|
57
|
+
for (const group of groupBy(calculateFilterGroup, uniqBy(getFilterId, filters)).values()) {
|
|
58
|
+
const newFilter = {};
|
|
59
|
+
for (const k of Object.keys(group[0])) {
|
|
60
|
+
if (["since", "until", "limit", "search"].includes(k)) {
|
|
61
|
+
newFilter[k] = group[0][k];
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
newFilter[k] = uniq(group.flatMap(prop(k)));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
result.push(newFilter);
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
};
|
|
71
|
+
export const intersectFilters = (groups) => {
|
|
72
|
+
let result = groups[0];
|
|
73
|
+
for (const filters of groups.slice(1)) {
|
|
74
|
+
result = result.flatMap(f1 => {
|
|
75
|
+
return filters.map(f2 => {
|
|
76
|
+
const f3 = {};
|
|
77
|
+
for (const k of uniq([...Object.keys(f1), ...Object.keys(f2)])) {
|
|
78
|
+
if (k === "since" || k === "limit") {
|
|
79
|
+
f3[k] = Math.max(f1[k] || 0, f2[k] || 0);
|
|
80
|
+
}
|
|
81
|
+
else if (k === "until") {
|
|
82
|
+
f3[k] = Math.min(f1[k] || f2[k] || 0, f2[k] || f1[k] || 0);
|
|
83
|
+
}
|
|
84
|
+
else if (k === "search") {
|
|
85
|
+
if (f1[k] && f2[k] && f1[k] !== f2[k]) {
|
|
86
|
+
f3[k] = [f1[k], f2[k]].join(" ");
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
f3[k] = f1[k] || f2[k];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
f3[k] = uniq([...(f1[k] || []), ...(f2[k] || [])]);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return f3;
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return unionFilters(result);
|
|
101
|
+
};
|
|
102
|
+
export const getIdFilters = (idsOrAddresses) => {
|
|
103
|
+
const ids = [];
|
|
104
|
+
const aFilters = [];
|
|
105
|
+
for (const idOrAddress of idsOrAddresses) {
|
|
106
|
+
if (Address.isAddress(idOrAddress)) {
|
|
107
|
+
const { kind, pubkey, identifier } = Address.from(idOrAddress);
|
|
108
|
+
if (identifier) {
|
|
109
|
+
aFilters.push({ kinds: [kind], authors: [pubkey], "#d": [identifier] });
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
aFilters.push({ kinds: [kind], authors: [pubkey] });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
ids.push(idOrAddress);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const filters = unionFilters(aFilters);
|
|
120
|
+
if (ids.length > 0) {
|
|
121
|
+
filters.push({ ids });
|
|
122
|
+
}
|
|
123
|
+
return filters;
|
|
124
|
+
};
|
|
125
|
+
export const getReplyFilters = (events, filter = {}) => {
|
|
126
|
+
const a = [];
|
|
127
|
+
const e = [];
|
|
128
|
+
for (const event of events) {
|
|
129
|
+
e.push(event.id);
|
|
130
|
+
if (isReplaceableKind(event.kind)) {
|
|
131
|
+
a.push(getAddress(event));
|
|
132
|
+
}
|
|
133
|
+
if (event.wrap) {
|
|
134
|
+
e.push(event.wrap.id);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const filters = [];
|
|
138
|
+
if (a.length > 0) {
|
|
139
|
+
filters.push({ ...filter, "#a": a });
|
|
140
|
+
}
|
|
141
|
+
if (e.length > 0) {
|
|
142
|
+
filters.push({ ...filter, "#e": e });
|
|
143
|
+
}
|
|
144
|
+
return filters;
|
|
145
|
+
};
|
|
146
|
+
export const addRepostFilters = (filters) => filters.flatMap(original => {
|
|
147
|
+
const filterChunk = [original];
|
|
148
|
+
if (!original.kinds) {
|
|
149
|
+
filterChunk.push({ ...original, kinds: [6, 16] });
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
if (original.kinds.includes(1)) {
|
|
153
|
+
filterChunk.push({ ...original, kinds: [6] });
|
|
154
|
+
}
|
|
155
|
+
const otherKinds = without([1], original.kinds);
|
|
156
|
+
if (otherKinds.length > 0) {
|
|
157
|
+
filterChunk.push({ ...original, kinds: [16], "#k": otherKinds.map(String) });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return filterChunk;
|
|
161
|
+
});
|
|
162
|
+
export const getFilterGenerality = (filter) => {
|
|
163
|
+
if (filter.ids || filter["#e"] || filter["#a"]) {
|
|
164
|
+
return 0;
|
|
165
|
+
}
|
|
166
|
+
const hasTags = Object.keys(filter).find((k) => k.startsWith("#"));
|
|
167
|
+
if (filter.authors && hasTags) {
|
|
168
|
+
return 0.2;
|
|
169
|
+
}
|
|
170
|
+
if (filter.authors) {
|
|
171
|
+
return Math.min(1, filter.authors.length / 300);
|
|
172
|
+
}
|
|
173
|
+
return 1;
|
|
174
|
+
};
|
|
175
|
+
export const guessFilterDelta = (filters, max = 60 * 60 * 24) => Math.round(max * Math.max(0.01, 1 - avg(filters.map(getFilterGenerality))));
|
|
176
|
+
// If a filter is specifying ids, we know how many results to expect
|
|
177
|
+
export const getFilterResultCardinality = (filter) => {
|
|
178
|
+
if (filter.ids) {
|
|
179
|
+
return filter.ids.length;
|
|
180
|
+
}
|
|
181
|
+
return undefined;
|
|
182
|
+
};
|
|
183
|
+
export const trimFilter = (filter) => mapVals(v => (Array.isArray(v) && v.length > 1000 ? shuffle(v).slice(0, 1000) : v), filter);
|
|
184
|
+
export const trimFilters = (filters) => filters.map(trimFilter);
|
|
185
|
+
//# sourceMappingURL=Filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Filters.js","sourceRoot":"","sources":["../../../../util/src/Filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,IAAI,qBAAqB,EAAC,MAAM,oBAAoB,CAAA;AACvE,OAAO,EACL,OAAO,EACP,MAAM,EACN,IAAI,EACJ,OAAO,EACP,OAAO,EACP,GAAG,EACH,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,IAAI,GACL,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,cAAc,CAAA;AAEhD,MAAM,CAAC,MAAM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C,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAA;AAE7E,oEAAoE;AACpE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,MAAc,EAAE,EAAE;IAC3D,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAA;IAC1B,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAc,EAAU,EAAE,CACnD,OAAO,CACL,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAa,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACtF,MAAM,CACG,CAAA;AAEb,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAiB,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TrustedEvent } from "./Events.js";
|
|
2
|
+
export type Handler = {
|
|
3
|
+
kind: number;
|
|
4
|
+
name: string;
|
|
5
|
+
about: string;
|
|
6
|
+
image: string;
|
|
7
|
+
identifier: string;
|
|
8
|
+
event: TrustedEvent;
|
|
9
|
+
website?: string;
|
|
10
|
+
lud16?: string;
|
|
11
|
+
nip05?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const readHandlers: (event: TrustedEvent) => Handler[];
|
|
14
|
+
export declare const getHandlerKey: (handler: Handler) => string;
|
|
15
|
+
export declare const displayHandler: (handler?: Handler, fallback?: string) => string;
|
|
16
|
+
export declare const getHandlerAddress: (event: TrustedEvent) => string | undefined;
|
|
17
|
+
//# sourceMappingURL=Handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Handler.d.ts","sourceRoot":"","sources":["../../../../util/src/Handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAA;AAE7C,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,YAAY,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,YAAY,cAuB/C,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,SAAS,OAAO,WAAmD,CAAA;AAEjG,eAAO,MAAM,cAAc,GAAI,UAAU,OAAO,EAAE,iBAAa,WAA8B,CAAA;AAE7F,eAAO,MAAM,iBAAiB,GAAI,OAAO,YAAY,uBAKpD,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { fromPairs, last, first, parseJson } from "@welshman/lib";
|
|
2
|
+
import { getAddress } from "./Address.js";
|
|
3
|
+
import { getAddressTags, getKindTagValues } from "./Tags.js";
|
|
4
|
+
export const readHandlers = (event) => {
|
|
5
|
+
const { d: identifier } = fromPairs(event.tags);
|
|
6
|
+
const meta = parseJson(event.content);
|
|
7
|
+
const normalizedMeta = {
|
|
8
|
+
name: meta?.name || meta?.display_name || "",
|
|
9
|
+
image: meta?.image || meta?.picture || "",
|
|
10
|
+
about: meta?.about || "",
|
|
11
|
+
website: meta?.website || "",
|
|
12
|
+
lud16: meta?.lud16 || "",
|
|
13
|
+
nip05: meta?.nip05 || "",
|
|
14
|
+
};
|
|
15
|
+
// If our meta is missing important stuff, don't bother showing it
|
|
16
|
+
if (!normalizedMeta.name || !normalizedMeta.image) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
return getKindTagValues(event.tags).map(kind => ({
|
|
20
|
+
...normalizedMeta,
|
|
21
|
+
kind,
|
|
22
|
+
identifier,
|
|
23
|
+
event,
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
export const getHandlerKey = (handler) => `${handler.kind}:${getAddress(handler.event)}`;
|
|
27
|
+
export const displayHandler = (handler, fallback = "") => handler?.name || fallback;
|
|
28
|
+
export const getHandlerAddress = (event) => {
|
|
29
|
+
const tags = getAddressTags(event.tags);
|
|
30
|
+
const tag = tags.find(t => last(t) === "web") || first(tags);
|
|
31
|
+
return tag?.[1];
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=Handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Handler.js","sourceRoot":"","sources":["../../../../util/src/Handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAC,MAAM,eAAe,CAAA;AAC/D,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,WAAW,CAAA;AAe1D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAmB,EAAE,EAAE;IAClD,MAAM,EAAC,CAAC,EAAE,UAAU,EAAC,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC7C,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACrC,MAAM,cAAc,GAAG;QACrB,IAAI,EAAE,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,YAAY,IAAI,EAAE;QAC5C,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,OAAO,IAAI,EAAE;QACzC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,EAAE;QAC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