@welshman/util 0.8.16 → 0.9.0-pre2
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/lib/src/Tools.d.ts +13 -0
- package/dist/lib/src/Tools.d.ts.map +1 -1
- package/dist/lib/src/Tools.js +30 -1
- package/dist/lib/src/Tools.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/util/src/Events.d.ts +0 -12
- package/dist/util/src/Events.d.ts.map +1 -1
- package/dist/util/src/Events.js +3 -25
- package/dist/util/src/Events.js.map +1 -1
- package/dist/util/src/Handles.d.ts +15 -0
- package/dist/util/src/Handles.d.ts.map +1 -0
- package/dist/util/src/Handles.js +25 -0
- package/dist/util/src/Handles.js.map +1 -0
- package/dist/util/src/Kinds.d.ts +6 -1
- package/dist/util/src/Kinds.d.ts.map +1 -1
- package/dist/util/src/Kinds.js +8 -2
- package/dist/util/src/Kinds.js.map +1 -1
- package/dist/util/src/Lightning.d.ts +6 -0
- package/dist/util/src/Lightning.d.ts.map +1 -0
- package/dist/util/src/Lightning.js +59 -0
- package/dist/util/src/Lightning.js.map +1 -0
- package/dist/util/src/Nip86.d.ts +75 -25
- package/dist/util/src/Nip86.d.ts.map +1 -1
- package/dist/util/src/Nip86.js +169 -24
- package/dist/util/src/Nip86.js.map +1 -1
- package/dist/util/src/Pow.js +2 -2
- package/dist/util/src/Pow.js.map +1 -1
- package/dist/util/src/Pubkey.d.ts.map +1 -1
- package/dist/util/src/Pubkey.js +2 -1
- package/dist/util/src/Pubkey.js.map +1 -1
- package/dist/util/src/Relay.d.ts +0 -29
- package/dist/util/src/Relay.d.ts.map +1 -1
- package/dist/util/src/Relay.js +0 -10
- package/dist/util/src/Relay.js.map +1 -1
- package/dist/util/src/RelaySelection.d.ts +101 -0
- package/dist/util/src/RelaySelection.d.ts.map +1 -0
- package/dist/util/src/RelaySelection.js +98 -0
- package/dist/util/src/RelaySelection.js.map +1 -0
- package/dist/util/src/Tags.d.ts +16 -35
- package/dist/util/src/Tags.d.ts.map +1 -1
- package/dist/util/src/Tags.js +23 -74
- package/dist/util/src/Tags.js.map +1 -1
- package/dist/util/src/Topics.d.ts +2 -0
- package/dist/util/src/Topics.d.ts.map +1 -0
- package/dist/util/src/Topics.js +2 -0
- package/dist/util/src/Topics.js.map +1 -0
- package/dist/util/src/index.d.ts +3 -6
- package/dist/util/src/index.d.ts.map +1 -1
- package/dist/util/src/index.js +3 -6
- package/dist/util/src/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/util/src/Encryptable.d.ts +0 -34
- package/dist/util/src/Encryptable.d.ts.map +0 -1
- package/dist/util/src/Encryptable.js +0 -52
- package/dist/util/src/Encryptable.js.map +0 -1
- package/dist/util/src/Handler.d.ts +0 -17
- package/dist/util/src/Handler.d.ts.map +0 -1
- package/dist/util/src/Handler.js +0 -33
- package/dist/util/src/Handler.js.map +0 -1
- package/dist/util/src/List.d.ts +0 -42
- package/dist/util/src/List.d.ts.map +0 -1
- package/dist/util/src/List.js +0 -86
- package/dist/util/src/List.js.map +0 -1
- package/dist/util/src/Profile.d.ts +0 -26
- package/dist/util/src/Profile.d.ts.map +0 -1
- package/dist/util/src/Profile.js +0 -50
- package/dist/util/src/Profile.js.map +0 -1
- package/dist/util/src/Room.d.ts +0 -63
- package/dist/util/src/Room.d.ts.map +0 -1
- package/dist/util/src/Room.js +0 -94
- package/dist/util/src/Room.js.map +0 -1
- package/dist/util/src/Zaps.d.ts +0 -55
- package/dist/util/src/Zaps.d.ts.map +0 -1
- package/dist/util/src/Zaps.js +0 -135
- package/dist/util/src/Zaps.js.map +0 -1
|
@@ -1,52 +0,0 @@
|
|
|
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 undefined;
|
|
33
|
-
return encrypt(this.updates.content);
|
|
34
|
-
};
|
|
35
|
-
const encryptTags = () => {
|
|
36
|
-
if (!this.updates.tags)
|
|
37
|
-
return undefined;
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{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AAI,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"}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Handler.d.ts","sourceRoot":"","sources":["../../../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"}
|
package/dist/util/src/Handler.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":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AG,OAAO,CAAC,IAAI,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAA;AAEjG,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAiB,EAAE,QAAQ,GAAG,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,IAAI,IAAI,QAAQ,CAAA;AAE7F,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAmB,EAAE,EAAE;IACvD,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAA;IAE5D,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAA"}
|
package/dist/util/src/List.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { RelayMode } from "./Relay.js";
|
|
2
|
-
import { Encryptable, DecryptedEvent } from "./Encryptable.js";
|
|
3
|
-
export type ListParams = {
|
|
4
|
-
kind: number;
|
|
5
|
-
};
|
|
6
|
-
export type List = ListParams & {
|
|
7
|
-
publicTags: string[][];
|
|
8
|
-
privateTags: string[][];
|
|
9
|
-
event?: DecryptedEvent;
|
|
10
|
-
};
|
|
11
|
-
export type PublishedList = Omit<List, "event"> & {
|
|
12
|
-
event: DecryptedEvent;
|
|
13
|
-
};
|
|
14
|
-
export declare const makeList: (list: ListParams & Partial<List>) => List;
|
|
15
|
-
export declare const readList: (event: DecryptedEvent) => PublishedList;
|
|
16
|
-
export declare const getListTags: (list: List | undefined) => string[][];
|
|
17
|
-
export declare const removeFromListByPredicate: (list: List, pred: (t: string[]) => boolean) => Encryptable<{
|
|
18
|
-
kind: number;
|
|
19
|
-
content: string;
|
|
20
|
-
tags: string[][];
|
|
21
|
-
}>;
|
|
22
|
-
export declare const removeFromList: (list: List, value: string) => Encryptable<{
|
|
23
|
-
kind: number;
|
|
24
|
-
content: string;
|
|
25
|
-
tags: string[][];
|
|
26
|
-
}>;
|
|
27
|
-
export declare const addToListPublicly: (list: List, ...tags: string[][]) => Encryptable<{
|
|
28
|
-
kind: number;
|
|
29
|
-
content: string;
|
|
30
|
-
tags: string[][];
|
|
31
|
-
}>;
|
|
32
|
-
export declare const addToListPrivately: (list: List, ...tags: string[][]) => Encryptable<import("./Events.js").EventTemplate>;
|
|
33
|
-
export declare const updateList: (list: List, { publicTags, privateTags }: {
|
|
34
|
-
publicTags?: string[][];
|
|
35
|
-
privateTags?: string[][];
|
|
36
|
-
}) => Encryptable<{
|
|
37
|
-
kind: number;
|
|
38
|
-
content: string;
|
|
39
|
-
tags: string[][];
|
|
40
|
-
}>;
|
|
41
|
-
export declare const getRelaysFromList: (list?: List, mode?: RelayMode) => string[];
|
|
42
|
-
//# sourceMappingURL=List.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../src/List.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,SAAS,EAAoB,MAAM,YAAY,CAAA;AACnE,OAAO,EAAC,WAAW,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAG5D,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG;IAC9B,UAAU,EAAE,MAAM,EAAE,EAAE,CAAA;IACtB,WAAW,EAAE,MAAM,EAAE,EAAE,CAAA;IACvB,KAAK,CAAC,EAAE,cAAc,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG;IAChD,KAAK,EAAE,cAAc,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,KAAG,IAI1D,CAAA;AAaF,eAAO,MAAM,QAAQ,GAAI,OAAO,cAAc,KAAG,aAMhD,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,MAAM,IAAI,GAAG,SAAS,eAGjD,CAAA;AAED,eAAO,MAAM,yBAAyB,GAAI,MAAM,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,OAAO;;;;EAcnF,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,MAAM,IAAI,EAAE,OAAO,MAAM;;;;EACN,CAAA;AAElD,eAAO,MAAM,iBAAiB,GAAI,MAAM,IAAI,EAAE,GAAG,MAAM,MAAM,EAAE,EAAE;;;;EAQhE,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,MAAM,IAAI,EAAE,GAAG,MAAM,MAAM,EAAE,EAAE,qDASjE,CAAA;AAED,eAAO,MAAM,UAAU,GACrB,MAAM,IAAI,EACV,6BAA2B;IAAC,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,CAAA;CAAC;;;;EAe/E,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,OAAO,IAAI,EAAE,OAAO,SAAS,KAAG,MAAM,EAQvE,CAAA"}
|
package/dist/util/src/List.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { parseJson, uniq, nthEq } from "@welshman/lib";
|
|
2
|
-
import { Address } from "./Address.js";
|
|
3
|
-
import { uniqTags, getRelayTags } from "./Tags.js";
|
|
4
|
-
import { isRelayUrl, normalizeRelayUrl } from "./Relay.js";
|
|
5
|
-
import { Encryptable } from "./Encryptable.js";
|
|
6
|
-
export const makeList = (list) => ({
|
|
7
|
-
publicTags: [],
|
|
8
|
-
privateTags: [],
|
|
9
|
-
...list,
|
|
10
|
-
});
|
|
11
|
-
const isValidTag = (tag) => {
|
|
12
|
-
if (tag[0] === "p")
|
|
13
|
-
return tag[1]?.length === 64;
|
|
14
|
-
if (tag[0] === "e")
|
|
15
|
-
return tag[1]?.length === 64;
|
|
16
|
-
if (tag[0] === "a")
|
|
17
|
-
return Address.isAddress(tag[1] || "");
|
|
18
|
-
if (tag[0] === "t")
|
|
19
|
-
return tag[1]?.length > 0;
|
|
20
|
-
if (tag[0] === "r")
|
|
21
|
-
return isRelayUrl(tag[1]);
|
|
22
|
-
if (tag[0] === "relay")
|
|
23
|
-
return isRelayUrl(tag[1]);
|
|
24
|
-
return true;
|
|
25
|
-
};
|
|
26
|
-
export const readList = (event) => {
|
|
27
|
-
const getTags = (tags) => (Array.isArray(tags) ? tags.filter(isValidTag) : []);
|
|
28
|
-
const privateTags = getTags(parseJson(event.plaintext?.content) || []);
|
|
29
|
-
const publicTags = getTags(event.tags);
|
|
30
|
-
return { event, kind: event.kind, publicTags, privateTags };
|
|
31
|
-
};
|
|
32
|
-
export const getListTags = (list) => [
|
|
33
|
-
...(list?.publicTags || []),
|
|
34
|
-
...(list?.privateTags || []),
|
|
35
|
-
];
|
|
36
|
-
export const removeFromListByPredicate = (list, pred) => {
|
|
37
|
-
const plaintext = {};
|
|
38
|
-
const template = {
|
|
39
|
-
kind: list.kind,
|
|
40
|
-
content: list.event?.content || "",
|
|
41
|
-
tags: list.publicTags.filter(t => !pred(t)),
|
|
42
|
-
};
|
|
43
|
-
// Avoid redundant encrypt calls if possible
|
|
44
|
-
if (list.privateTags.some(t => pred(t))) {
|
|
45
|
-
plaintext.content = JSON.stringify(list.privateTags.filter(t => !pred(t)));
|
|
46
|
-
}
|
|
47
|
-
return new Encryptable(template, plaintext);
|
|
48
|
-
};
|
|
49
|
-
export const removeFromList = (list, value) => removeFromListByPredicate(list, nthEq(1, value));
|
|
50
|
-
export const addToListPublicly = (list, ...tags) => {
|
|
51
|
-
const template = {
|
|
52
|
-
kind: list.kind,
|
|
53
|
-
content: list.event?.content || "",
|
|
54
|
-
tags: uniqTags([...list.publicTags, ...tags]),
|
|
55
|
-
};
|
|
56
|
-
return new Encryptable(template, {});
|
|
57
|
-
};
|
|
58
|
-
export const addToListPrivately = (list, ...tags) => {
|
|
59
|
-
const template = {
|
|
60
|
-
kind: list.kind,
|
|
61
|
-
tags: list.publicTags,
|
|
62
|
-
};
|
|
63
|
-
return new Encryptable(template, {
|
|
64
|
-
content: JSON.stringify(uniqTags([...list.privateTags, ...tags])),
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
export const updateList = (list, { publicTags, privateTags }) => {
|
|
68
|
-
const template = {
|
|
69
|
-
kind: list.kind,
|
|
70
|
-
content: list.event?.content || "",
|
|
71
|
-
tags: publicTags || list.publicTags,
|
|
72
|
-
};
|
|
73
|
-
const updates = {};
|
|
74
|
-
if (privateTags) {
|
|
75
|
-
updates.content = JSON.stringify(privateTags);
|
|
76
|
-
}
|
|
77
|
-
return new Encryptable(template, updates);
|
|
78
|
-
};
|
|
79
|
-
export const getRelaysFromList = (list, mode) => {
|
|
80
|
-
let tags = getRelayTags(getListTags(list));
|
|
81
|
-
if (mode) {
|
|
82
|
-
tags = tags.filter((t) => !t[2] || t[2] === mode);
|
|
83
|
-
}
|
|
84
|
-
return uniq(tags.map(t => normalizeRelayUrl(t[1])));
|
|
85
|
-
};
|
|
86
|
-
//# sourceMappingURL=List.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/List.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,eAAe,CAAA;AACpD,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AACpC,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAC,MAAM,WAAW,CAAA;AAChD,OAAO,EAAC,UAAU,EAAa,iBAAiB,EAAC,MAAM,YAAY,CAAA;AACnE,OAAO,EAAC,WAAW,EAAiB,MAAM,kBAAkB,CAAA;AAiB5D,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAgC,EAAQ,EAA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AC/C,CAAC;IAED,OAAO,IAAI,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AAC3C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAW,EAAE,IAAgB,EAAY,EAAE;IAC3E,IAAI,IAAI,GAAG,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;IAE1C,IAAI,IAAI,EAAE,CAAC;QACT,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAW,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAA;IAC7D,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACrD,CAAC,CAAA"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { TrustedEvent, EventTemplate } from "./Events.js";
|
|
2
|
-
export type Profile = {
|
|
3
|
-
name?: string;
|
|
4
|
-
nip05?: string;
|
|
5
|
-
lud06?: string;
|
|
6
|
-
lud16?: string;
|
|
7
|
-
lnurl?: string;
|
|
8
|
-
about?: string;
|
|
9
|
-
banner?: string;
|
|
10
|
-
picture?: string;
|
|
11
|
-
website?: string;
|
|
12
|
-
display_name?: string;
|
|
13
|
-
event?: TrustedEvent;
|
|
14
|
-
};
|
|
15
|
-
export type PublishedProfile = Omit<Profile, "event"> & {
|
|
16
|
-
event: TrustedEvent;
|
|
17
|
-
};
|
|
18
|
-
export declare const isPublishedProfile: (profile: Profile) => profile is PublishedProfile;
|
|
19
|
-
export declare const makeProfile: (profile?: Partial<Profile>) => Profile;
|
|
20
|
-
export declare const readProfile: (event: TrustedEvent) => PublishedProfile;
|
|
21
|
-
export declare const createProfile: ({ event, ...profile }: Profile) => EventTemplate;
|
|
22
|
-
export declare const editProfile: ({ event, ...profile }: PublishedProfile) => EventTemplate;
|
|
23
|
-
export declare const displayPubkey: (pubkey: string) => string;
|
|
24
|
-
export declare const displayProfile: (profile?: Profile, fallback?: string) => string;
|
|
25
|
-
export declare const profileHasName: (profile?: Profile) => boolean;
|
|
26
|
-
//# sourceMappingURL=Profile.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Profile.d.ts","sourceRoot":"","sources":["../../../src/Profile.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,aAAa,CAAA;AAIvD,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,YAAY,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG;IACtD,KAAK,EAAE,YAAY,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,gBACzC,CAAA;AAExB,eAAO,MAAM,WAAW,GAAI,UAAS,OAAO,CAAC,OAAO,CAAM,KAAG,OAkB5D,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,YAAY,KAAG,gBAGhD,CAAA;AAEF,eAAO,MAAM,aAAa,GAAI,uBAAqB,OAAO,KAAG,aAI3D,CAAA;AAEF,eAAO,MAAM,WAAW,GAAI,uBAAqB,gBAAgB,KAAG,aAIlE,CAAA;AAEF,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,WAI3C,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,UAAU,OAAO,EAAE,iBAAa,WAQ9D,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,UAAU,OAAO,YAAoD,CAAA"}
|
package/dist/util/src/Profile.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { npubEncode } from "nostr-tools/nip19";
|
|
2
|
-
import { ellipsize, parseJson } from "@welshman/lib";
|
|
3
|
-
import { getLnUrl } from "./Zaps.js";
|
|
4
|
-
import { PROFILE } from "./Kinds.js";
|
|
5
|
-
export const isPublishedProfile = (profile) => Boolean(profile.event);
|
|
6
|
-
export const makeProfile = (profile = {}) => {
|
|
7
|
-
if (typeof profile.lud06 === "string") {
|
|
8
|
-
const lnurl = getLnUrl(profile.lud06);
|
|
9
|
-
if (lnurl) {
|
|
10
|
-
profile = { ...profile, lnurl };
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
if (typeof profile.lud16 === "string") {
|
|
14
|
-
const lnurl = getLnUrl(profile.lud16);
|
|
15
|
-
if (lnurl) {
|
|
16
|
-
profile = { ...profile, lnurl };
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return profile;
|
|
20
|
-
};
|
|
21
|
-
export const readProfile = (event) => ({
|
|
22
|
-
...makeProfile(parseJson(event.content) || {}),
|
|
23
|
-
event,
|
|
24
|
-
});
|
|
25
|
-
export const createProfile = ({ event, ...profile }) => ({
|
|
26
|
-
kind: PROFILE,
|
|
27
|
-
content: JSON.stringify(profile),
|
|
28
|
-
tags: [],
|
|
29
|
-
});
|
|
30
|
-
export const editProfile = ({ event, ...profile }) => ({
|
|
31
|
-
kind: PROFILE,
|
|
32
|
-
content: JSON.stringify(profile),
|
|
33
|
-
tags: event.tags,
|
|
34
|
-
});
|
|
35
|
-
export const displayPubkey = (pubkey) => {
|
|
36
|
-
const d = npubEncode(pubkey);
|
|
37
|
-
return d.slice(0, 8) + "…" + d.slice(-5);
|
|
38
|
-
};
|
|
39
|
-
export const displayProfile = (profile, fallback = "") => {
|
|
40
|
-
const { display_name, name, event } = profile || {};
|
|
41
|
-
if (name)
|
|
42
|
-
return ellipsize(name, 60).trim();
|
|
43
|
-
if (display_name)
|
|
44
|
-
return ellipsize(display_name, 60).trim();
|
|
45
|
-
if (event)
|
|
46
|
-
return displayPubkey(event.pubkey).trim();
|
|
47
|
-
return fallback.trim();
|
|
48
|
-
};
|
|
49
|
-
export const profileHasName = (profile) => Boolean(profile?.name || profile?.display_name);
|
|
50
|
-
//# sourceMappingURL=Profile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Profile.js","sourceRoot":"","sources":["../../../src/Profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,eAAe,CAAA;AAElD,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAClC,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAA;AAoBlC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAgB,EAA+B,EAAE,CAClF,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,UAA4B,EAAE,EAAW,EAAE;IACrE,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAErC,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,GAAG,EAAC,GAAG,OAAO,EAAE,KAAK,EAAC,CAAA;QAC/B,CAAC;IACH,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QACtC,MAAM,KAA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AE,KAAK,EAAC,GAAG,OAAO,IAAI,EAAE,CAAA;IAEjD,IAAI,IAAI;QAAE,OAAO,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IAC3C,IAAI,YAAY;QAAE,OAAO,SAAS,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IAC3D,IAAI,KAAK;QAAE,OAAO,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;IAEpD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAiB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,YAAY,CAAC,CAAA"}
|
package/dist/util/src/Room.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { TrustedEvent } from "./Events.js";
|
|
2
|
-
export type RoomMeta = {
|
|
3
|
-
h: string;
|
|
4
|
-
name?: string;
|
|
5
|
-
about?: string;
|
|
6
|
-
picture?: string;
|
|
7
|
-
pictureMeta?: string[];
|
|
8
|
-
isClosed?: boolean;
|
|
9
|
-
isHidden?: boolean;
|
|
10
|
-
isPrivate?: boolean;
|
|
11
|
-
isRestricted?: boolean;
|
|
12
|
-
livekit?: boolean;
|
|
13
|
-
event?: TrustedEvent;
|
|
14
|
-
};
|
|
15
|
-
export type PublishedRoomMeta = Omit<RoomMeta, "event"> & {
|
|
16
|
-
event: TrustedEvent;
|
|
17
|
-
};
|
|
18
|
-
export declare const generateH: () => string;
|
|
19
|
-
export declare const makeRoomMeta: (room?: Partial<RoomMeta>) => RoomMeta;
|
|
20
|
-
export declare const readRoomMeta: (event: TrustedEvent) => PublishedRoomMeta;
|
|
21
|
-
export declare const makeRoomCreateEvent: (room: RoomMeta) => {
|
|
22
|
-
kind: number;
|
|
23
|
-
content: string;
|
|
24
|
-
tags: string[][];
|
|
25
|
-
created_at: number;
|
|
26
|
-
};
|
|
27
|
-
export declare const makeRoomDeleteEvent: (room: RoomMeta) => {
|
|
28
|
-
kind: number;
|
|
29
|
-
content: string;
|
|
30
|
-
tags: string[][];
|
|
31
|
-
created_at: number;
|
|
32
|
-
};
|
|
33
|
-
export declare const makeRoomEditEvent: (room: RoomMeta) => {
|
|
34
|
-
kind: number;
|
|
35
|
-
content: string;
|
|
36
|
-
tags: string[][];
|
|
37
|
-
created_at: number;
|
|
38
|
-
};
|
|
39
|
-
export declare const makeRoomJoinEvent: (room: RoomMeta) => {
|
|
40
|
-
kind: number;
|
|
41
|
-
content: string;
|
|
42
|
-
tags: string[][];
|
|
43
|
-
created_at: number;
|
|
44
|
-
};
|
|
45
|
-
export declare const makeRoomLeaveEvent: (room: RoomMeta) => {
|
|
46
|
-
kind: number;
|
|
47
|
-
content: string;
|
|
48
|
-
tags: string[][];
|
|
49
|
-
created_at: number;
|
|
50
|
-
};
|
|
51
|
-
export declare const makeRoomAddMemberEvent: (room: RoomMeta, pubkey: string) => {
|
|
52
|
-
kind: number;
|
|
53
|
-
content: string;
|
|
54
|
-
tags: string[][];
|
|
55
|
-
created_at: number;
|
|
56
|
-
};
|
|
57
|
-
export declare const makeRoomRemoveMemberEvent: (room: RoomMeta, pubkey: string) => {
|
|
58
|
-
kind: number;
|
|
59
|
-
content: string;
|
|
60
|
-
tags: string[][];
|
|
61
|
-
created_at: number;
|
|
62
|
-
};
|
|
63
|
-
//# sourceMappingURL=Room.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Room.d.ts","sourceRoot":"","sources":["../../../src/Room.ts"],"names":[],"mappings":"AAWA,OAAO,EAAY,YAAY,EAAgB,MAAM,aAAa,CAAA;AAGlE,MAAM,MAAM,QAAQ,GAAG;IACrB,CAAC,EAAE,MAAM,CAAA;IACT,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;I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OM_JOIN, ROOM_LEAVE, ROOM_ADD_MEMBER, ROOM_REMOVE_MEMBER, } from "./Kinds.js";
|
|
3
|
-
import { makeEvent, getIdentifier } from "./Events.js";
|
|
4
|
-
import { getTag, getTagValue } from "./Tags.js";
|
|
5
|
-
const vowels = "a,e,i,o,u,ay,ey,oy,ou,ia,ea,ough,oo,ee,argh".split(",");
|
|
6
|
-
const consonants = "p,b,t,d,k,g,ch,sh,th,f,v,s,z,l,r,m,n,pl,bl,cl,gl,pr,br,tr,dr,kr,gr,fl,sl,fr,thr,str,sk,sp,st".split(",");
|
|
7
|
-
export const generateH = () => {
|
|
8
|
-
const n = (6 + Math.random() * 2) | 0;
|
|
9
|
-
const s = [consonants, vowels];
|
|
10
|
-
if (Math.random() < 0.5) {
|
|
11
|
-
s.reverse();
|
|
12
|
-
}
|
|
13
|
-
return (Array.from({ length: n }, (_, i) => s[i % 2].splice((Math.random() * s[i % 2].length) | 0, 1)).join("") +
|
|
14
|
-
(1 + Math.floor(Math.random() * 9)));
|
|
15
|
-
};
|
|
16
|
-
export const makeRoomMeta = (room = {}) => {
|
|
17
|
-
return {
|
|
18
|
-
h: room.h ?? generateH(),
|
|
19
|
-
...room,
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export const readRoomMeta = (event) => {
|
|
23
|
-
if (event.kind !== ROOM_META) {
|
|
24
|
-
throw new Error("Invalid group meta event");
|
|
25
|
-
}
|
|
26
|
-
const h = getIdentifier(event);
|
|
27
|
-
if (!h) {
|
|
28
|
-
throw new Error("Group meta event had no d tag");
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
h,
|
|
32
|
-
event,
|
|
33
|
-
name: getTagValue("name", event.tags),
|
|
34
|
-
about: getTagValue("about", event.tags),
|
|
35
|
-
picture: getTagValue("picture", event.tags),
|
|
36
|
-
pictureMeta: getTag("picture", event.tags)?.slice(2),
|
|
37
|
-
isClosed: event.tags.some(spec(["closed"])),
|
|
38
|
-
isHidden: event.tags.some(spec(["hidden"])),
|
|
39
|
-
isPrivate: event.tags.some(spec(["private"])),
|
|
40
|
-
isRestricted: event.tags.some(spec(["restricted"])),
|
|
41
|
-
livekit: event.tags.some(spec(["livekit"])),
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
export const makeRoomCreateEvent = (room) => makeEvent(ROOM_CREATE, { tags: [["h", room.h]] });
|
|
45
|
-
export const makeRoomDeleteEvent = (room) => makeEvent(ROOM_DELETE, { tags: [["h", room.h]] });
|
|
46
|
-
export const makeRoomEditEvent = (room) => {
|
|
47
|
-
const tags = [["h", room.h]];
|
|
48
|
-
if (room.name)
|
|
49
|
-
tags.push(["name", room.name]);
|
|
50
|
-
if (room.about)
|
|
51
|
-
tags.push(["about", room.about]);
|
|
52
|
-
if (room.picture) {
|
|
53
|
-
const tag = ["picture", room.picture];
|
|
54
|
-
if (room.pictureMeta) {
|
|
55
|
-
tag.push(...room.pictureMeta);
|
|
56
|
-
}
|
|
57
|
-
tags.push(tag);
|
|
58
|
-
}
|
|
59
|
-
if (room.isClosed)
|
|
60
|
-
tags.push(["closed"]);
|
|
61
|
-
if (room.isHidden)
|
|
62
|
-
tags.push(["hidden"]);
|
|
63
|
-
if (room.isPrivate)
|
|
64
|
-
tags.push(["private"]);
|
|
65
|
-
if (room.isRestricted)
|
|
66
|
-
tags.push(["restricted"]);
|
|
67
|
-
if (room.livekit)
|
|
68
|
-
tags.push(["livekit"]);
|
|
69
|
-
if (room.event) {
|
|
70
|
-
for (const t of room.event.tags) {
|
|
71
|
-
if (tags.some(spec(t.slice(0, 1))))
|
|
72
|
-
continue;
|
|
73
|
-
if (["closed", "hidden", "private", "restricted", "livekit"].includes(t[0]))
|
|
74
|
-
continue;
|
|
75
|
-
tags.push(t);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return makeEvent(ROOM_EDIT_META, { tags });
|
|
79
|
-
};
|
|
80
|
-
export const makeRoomJoinEvent = (room) => makeEvent(ROOM_JOIN, { tags: [["h", room.h]] });
|
|
81
|
-
export const makeRoomLeaveEvent = (room) => makeEvent(ROOM_LEAVE, { tags: [["h", room.h]] });
|
|
82
|
-
export const makeRoomAddMemberEvent = (room, pubkey) => makeEvent(ROOM_ADD_MEMBER, {
|
|
83
|
-
tags: [
|
|
84
|
-
["h", room.h],
|
|
85
|
-
["p", pubkey],
|
|
86
|
-
],
|
|
87
|
-
});
|
|
88
|
-
export const makeRoomRemoveMemberEvent = (room, pubkey) => makeEvent(ROOM_REMOVE_MEMBER, {
|
|
89
|
-
tags: [
|
|
90
|
-
["h", room.h],
|
|
91
|
-
["p", pubkey],
|
|
92
|
-
],
|
|
93
|
-
});
|
|
94
|
-
//# sourceMappingURL=Room.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Room.js","sourceRoot":"","sources":["../../../src/Room.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAA;AAClC,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,cAAc,EACd,SAAS,EACT,UAAU,EACV,eAAe,EACf,kBAAkB,GACnB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAC,SAAS,EAAgB,aAAa,EAAC,MAAM,aAAa,CAAA;AAClE,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,WAAW,CAAA;AAoB7C,MAAM,MAAM,GAAG,6CAA6C,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AAEvE,MAAM,UAAU,GACd,8FAA8F,CAAC,KAAK,CAClG,GAAG,CACJ,CAAA;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;IACrC,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IAE9B,IAAI,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,E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CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAAE,SAAQ;YAErF,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACd,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC,cAAc,EAAE,EAAC,IAAI,EAAC,CAAC,CAAA;AAC1C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAc,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAC,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAA;AAElG,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAc,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAC,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAA;AAEpG,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,IAAc,EAAE,MAAc,EAAE,EAAE,CACvE,SAAS,CAAC,eAAe,EAAE;IACzB,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;QACb,CAAC,GAAG,EAAE,MAAM,CAAC;KACd;CACF,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,IAAc,EAAE,MAAc,EAAE,EAAE,CAC1E,SAAS,CAAC,kBAAkB,EAAE;IAC5B,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;QACb,CAAC,GAAG,EAAE,MAAM,CAAC;KACd;CACF,CAAC,CAAA"}
|
package/dist/util/src/Zaps.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { Filter } from "./Filters.js";
|
|
2
|
-
import type { TrustedEvent, SignedEvent } from "./Events.js";
|
|
3
|
-
export declare const toMsats: (sats: number) => number;
|
|
4
|
-
export declare const fromMsats: (msats: number) => number;
|
|
5
|
-
export declare const hrpToMillisat: (hrpString: string) => bigint;
|
|
6
|
-
export declare const getInvoiceAmount: (bolt11: string) => number;
|
|
7
|
-
export declare const getLnUrl: (address: string) => string | undefined;
|
|
8
|
-
export type Zapper = {
|
|
9
|
-
lnurl: string;
|
|
10
|
-
pubkey?: string;
|
|
11
|
-
callback?: string;
|
|
12
|
-
minSendable?: number;
|
|
13
|
-
maxSendable?: number;
|
|
14
|
-
nostrPubkey?: string;
|
|
15
|
-
allowsNostr?: boolean;
|
|
16
|
-
};
|
|
17
|
-
export type Zap = {
|
|
18
|
-
request: TrustedEvent;
|
|
19
|
-
response: TrustedEvent;
|
|
20
|
-
invoiceAmount: number;
|
|
21
|
-
};
|
|
22
|
-
export declare const zapFromEvent: (response: TrustedEvent, zapper: Zapper | undefined) => Zap | undefined;
|
|
23
|
-
export type ZapRequestParams = {
|
|
24
|
-
msats: number;
|
|
25
|
-
zapper: Zapper;
|
|
26
|
-
pubkey: string;
|
|
27
|
-
relays: string[];
|
|
28
|
-
content?: string;
|
|
29
|
-
eventId?: string;
|
|
30
|
-
anonymous?: boolean;
|
|
31
|
-
};
|
|
32
|
-
export declare const makeZapRequest: ({ msats, zapper, pubkey, relays, content, eventId, anonymous, }: ZapRequestParams) => {
|
|
33
|
-
kind: number;
|
|
34
|
-
content: string;
|
|
35
|
-
tags: string[][];
|
|
36
|
-
created_at: number;
|
|
37
|
-
};
|
|
38
|
-
export type RequestInvoiceParams = {
|
|
39
|
-
zapper: Zapper;
|
|
40
|
-
event: SignedEvent;
|
|
41
|
-
};
|
|
42
|
-
export declare const requestZap: ({ zapper, event }: RequestInvoiceParams) => Promise<{
|
|
43
|
-
invoice: any;
|
|
44
|
-
error?: undefined;
|
|
45
|
-
} | {
|
|
46
|
-
error: any;
|
|
47
|
-
invoice?: undefined;
|
|
48
|
-
}>;
|
|
49
|
-
export type ZapResponseFilterParams = {
|
|
50
|
-
zapper: Zapper;
|
|
51
|
-
pubkey: string;
|
|
52
|
-
eventId?: string;
|
|
53
|
-
};
|
|
54
|
-
export declare const getZapResponseFilter: ({ zapper, pubkey, eventId }: ZapResponseFilterParams) => Filter;
|
|
55
|
-
//# sourceMappingURL=Zaps.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Zaps.d.ts","sourceRoot":"","sources":["../../../src/Zaps.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAC,YAAY,EAAE,WAAW,EAAC,MAAM,aAAa,CAAA;AAc1D,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,WAAgB,CAAA;AAEpD,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,WAA6B,CAAA;AAEpE,eAAO,MAAM,aAAa,GAAI,WAAW,MAAM,WA2B9C,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,WAI9C,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,SAAS,MAAM,uBAqBvC,CAAA;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,GAAG,GAAG;IAChB,OAAO,EAAE,YAAY,CAAA;IACrB,QAAQ,EAAE,YAAY,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,UAAU,YAAY,EAAE,QAAQ,MAAM,GAAG,SAAS,oBA0C9E,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM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