applesauce-common 0.0.0-next-20251209200210 → 0.0.0-next-20251220152312
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/blueprints/__register__.d.ts +6 -0
- package/dist/blueprints/__register__.js +7 -0
- package/dist/blueprints/group-mangement.d.ts +25 -0
- package/dist/blueprints/group-mangement.js +40 -0
- package/dist/blueprints/index.d.ts +1 -0
- package/dist/blueprints/index.js +1 -0
- package/dist/casts/article.d.ts +17 -0
- package/dist/casts/article.js +41 -0
- package/dist/casts/bookmarks.d.ts +35 -0
- package/dist/casts/bookmarks.js +79 -0
- package/dist/casts/cast.d.ts +30 -0
- package/dist/casts/cast.js +67 -0
- package/dist/casts/comment.d.ts +16 -0
- package/dist/casts/comment.js +49 -0
- package/dist/casts/index.d.ts +12 -0
- package/dist/casts/index.js +12 -0
- package/dist/casts/mutes.d.ts +23 -0
- package/dist/casts/mutes.js +54 -0
- package/dist/casts/note.d.ts +17 -0
- package/dist/casts/note.js +46 -0
- package/dist/casts/profile.d.ts +16 -0
- package/dist/casts/profile.js +40 -0
- package/dist/casts/relay-lists.d.ts +33 -0
- package/dist/casts/relay-lists.js +72 -0
- package/dist/casts/share.d.ts +13 -0
- package/dist/casts/share.js +28 -0
- package/dist/casts/stream.d.ts +43 -0
- package/dist/casts/stream.js +116 -0
- package/dist/casts/user.d.ts +38 -0
- package/dist/casts/user.js +169 -0
- package/dist/casts/zap.d.ts +17 -0
- package/dist/casts/zap.js +47 -0
- package/dist/helpers/bookmark.d.ts +18 -17
- package/dist/helpers/bookmark.js +36 -49
- package/dist/helpers/encrypted-content-cache.js +23 -25
- package/dist/helpers/gift-wrap.js +11 -5
- package/dist/helpers/groups.d.ts +118 -6
- package/dist/helpers/groups.js +287 -10
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/lists.d.ts +0 -1
- package/dist/helpers/lists.js +4 -5
- package/dist/helpers/mute.d.ts +14 -11
- package/dist/helpers/mute.js +9 -4
- package/dist/helpers/relay-list.d.ts +14 -0
- package/dist/helpers/relay-list.js +18 -0
- package/dist/helpers/stream-chat.d.ts +4 -1
- package/dist/helpers/stream-chat.js +4 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/models/__register__.d.ts +5 -0
- package/dist/models/__register__.js +6 -0
- package/dist/models/bookmarks.d.ts +3 -5
- package/dist/models/bookmarks.js +2 -10
- package/dist/models/index.d.ts +3 -1
- package/dist/models/index.js +4 -1
- package/dist/models/mutes.d.ts +5 -5
- package/dist/models/{relays.js → relay-lists.js} +2 -1
- package/dist/models/shares.d.ts +3 -0
- package/dist/models/shares.js +5 -0
- package/dist/models/thread.js +30 -24
- package/dist/observable/cast-stream.d.ts +8 -0
- package/dist/observable/cast-stream.js +29 -0
- package/dist/observable/chainable.d.ts +50 -0
- package/dist/observable/chainable.js +79 -0
- package/dist/observable/index.d.ts +2 -0
- package/dist/observable/index.js +2 -0
- package/dist/operations/group.d.ts +14 -1
- package/dist/operations/group.js +42 -4
- package/dist/operations/index.d.ts +1 -1
- package/dist/operations/index.js +1 -1
- package/dist/operations/tag/bookmarks.d.ts +3 -2
- package/dist/operations/tag/bookmarks.js +34 -14
- package/dist/register.d.ts +2 -11
- package/dist/register.js +2 -11
- package/package.json +12 -2
- package/dist/helpers/mailboxes.d.ts +0 -7
- package/dist/helpers/mailboxes.js +0 -49
- /package/dist/models/{relays.d.ts → relay-lists.d.ts} +0 -0
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
1
|
+
import { kinds, KnownEvent, NostrEvent } from "applesauce-core/helpers/event";
|
|
2
2
|
import { HiddenContentSigner } from "applesauce-core/helpers/hidden-content";
|
|
3
3
|
import { AddressPointer, EventPointer } from "applesauce-core/helpers/pointers";
|
|
4
|
+
/** Type for a validated bookmark list event */
|
|
5
|
+
export type BookmarkListEvent = KnownEvent<kinds.BookmarkList>;
|
|
6
|
+
/** Type for a validated bookmark set event */
|
|
7
|
+
export type BookmarkSetEvent = KnownEvent<kinds.Bookmarksets>;
|
|
8
|
+
/** Validates that an event is a valid bookmark list (kind 10000) */
|
|
9
|
+
export declare function isValidBookmarkList(event: NostrEvent): event is BookmarkListEvent;
|
|
10
|
+
/** Validates that an event is a valid bookmark set (kind 30003) */
|
|
11
|
+
export declare function isValidBookmarkSet(event: NostrEvent): event is BookmarkSetEvent;
|
|
4
12
|
export declare const BookmarkPublicSymbol: unique symbol;
|
|
5
13
|
export declare const BookmarkHiddenSymbol: unique symbol;
|
|
14
|
+
export type BookmarkPointer = EventPointer | AddressPointer;
|
|
6
15
|
/** Type for unlocked bookmarks events */
|
|
7
16
|
export type UnlockedBookmarks = {
|
|
8
|
-
[BookmarkHiddenSymbol]:
|
|
9
|
-
};
|
|
10
|
-
export type Bookmarks = {
|
|
11
|
-
notes: EventPointer[];
|
|
12
|
-
articles: AddressPointer[];
|
|
13
|
-
hashtags: string[];
|
|
14
|
-
urls: string[];
|
|
17
|
+
[BookmarkHiddenSymbol]: BookmarkPointer[];
|
|
15
18
|
};
|
|
16
19
|
/** Parses an array of tags into a {@link Bookmarks} object */
|
|
17
|
-
export declare function parseBookmarkTags(tags: string[][]):
|
|
20
|
+
export declare function parseBookmarkTags(tags: string[][]): BookmarkPointer[];
|
|
18
21
|
/** Merges any number of {@link Bookmarks} objects */
|
|
19
|
-
export declare function mergeBookmarks(...bookmarks: (
|
|
20
|
-
/** Returns
|
|
21
|
-
export declare function getBookmarks(bookmark: NostrEvent):
|
|
22
|
-
/** Returns the public bookmarks of the event */
|
|
23
|
-
export declare function getPublicBookmarks(bookmark: NostrEvent): Bookmarks;
|
|
22
|
+
export declare function mergeBookmarks(...bookmarks: (BookmarkPointer[] | undefined)[]): BookmarkPointer[];
|
|
23
|
+
/** Returns the bookmarks of the event */
|
|
24
|
+
export declare function getBookmarks(bookmark: NostrEvent): BookmarkPointer[];
|
|
24
25
|
/** Checks if the hidden bookmarks are unlocked */
|
|
25
26
|
export declare function isHiddenBookmarksUnlocked<T extends NostrEvent>(bookmark: T): bookmark is T & UnlockedBookmarks;
|
|
26
27
|
/** Returns the bookmarks of the event if its unlocked */
|
|
27
|
-
export declare function getHiddenBookmarks<T extends NostrEvent & UnlockedBookmarks>(bookmark: T):
|
|
28
|
-
export declare function getHiddenBookmarks<T extends NostrEvent>(bookmark: T):
|
|
28
|
+
export declare function getHiddenBookmarks<T extends NostrEvent & UnlockedBookmarks>(bookmark: T): BookmarkPointer[];
|
|
29
|
+
export declare function getHiddenBookmarks<T extends NostrEvent>(bookmark: T): BookmarkPointer[] | undefined;
|
|
29
30
|
/** Unlocks the hidden bookmarks on a bookmarks event */
|
|
30
|
-
export declare function unlockHiddenBookmarks(bookmark: NostrEvent, signer: HiddenContentSigner): Promise<
|
|
31
|
+
export declare function unlockHiddenBookmarks(bookmark: NostrEvent, signer: HiddenContentSigner): Promise<BookmarkPointer[]>;
|
package/dist/helpers/bookmark.js
CHANGED
|
@@ -1,78 +1,65 @@
|
|
|
1
|
-
import { getOrComputeCachedValue, notifyEventUpdate } from "applesauce-core/helpers";
|
|
1
|
+
import { getOrComputeCachedValue, isATag, isETag, notifyEventUpdate, processTags } from "applesauce-core/helpers";
|
|
2
2
|
import { kinds } from "applesauce-core/helpers/event";
|
|
3
3
|
import { getHiddenTags, isHiddenTagsUnlocked, unlockHiddenTags } from "applesauce-core/helpers/hidden-tags";
|
|
4
|
-
import { getAddressPointerFromATag, getReplaceableAddressFromPointer,
|
|
4
|
+
import { getAddressPointerFromATag, getEventPointerFromETag, getReplaceableAddressFromPointer, isAddressPointer, isEventPointer, mergeAddressPointers, mergeEventPointers, } from "applesauce-core/helpers/pointers";
|
|
5
|
+
/** Validates that an event is a valid bookmark list (kind 10000) */
|
|
6
|
+
export function isValidBookmarkList(event) {
|
|
7
|
+
return event.kind === kinds.BookmarkList;
|
|
8
|
+
}
|
|
9
|
+
/** Validates that an event is a valid bookmark set (kind 30003) */
|
|
10
|
+
export function isValidBookmarkSet(event) {
|
|
11
|
+
return event.kind === kinds.Bookmarksets;
|
|
12
|
+
}
|
|
5
13
|
export const BookmarkPublicSymbol = Symbol.for("bookmark-public");
|
|
6
14
|
export const BookmarkHiddenSymbol = Symbol.for("bookmark-hidden");
|
|
7
15
|
/** Parses an array of tags into a {@link Bookmarks} object */
|
|
8
16
|
export function parseBookmarkTags(tags) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
return processTags(tags, (t) => {
|
|
18
|
+
if (isETag(t))
|
|
19
|
+
return getEventPointerFromETag(t) ?? undefined;
|
|
20
|
+
if (isATag(t)) {
|
|
21
|
+
const pointer = getAddressPointerFromATag(t) ?? undefined;
|
|
22
|
+
// Ensure the address pointer is a long form article
|
|
23
|
+
if (pointer?.kind !== kinds.LongFormArticle)
|
|
24
|
+
return undefined;
|
|
25
|
+
return pointer;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
});
|
|
21
29
|
}
|
|
22
30
|
/** Merges any number of {@link Bookmarks} objects */
|
|
23
31
|
export function mergeBookmarks(...bookmarks) {
|
|
24
32
|
const notes = new Map();
|
|
25
33
|
const articles = new Map();
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (!bookmark)
|
|
30
|
-
continue;
|
|
31
|
-
for (const note of bookmark.notes) {
|
|
32
|
-
const existing = notes.get(note.id);
|
|
34
|
+
for (const pointer of bookmarks.flat()) {
|
|
35
|
+
if (isEventPointer(pointer)) {
|
|
36
|
+
const existing = notes.get(pointer.id);
|
|
33
37
|
if (existing)
|
|
34
|
-
notes.set(
|
|
38
|
+
notes.set(pointer.id, mergeEventPointers(existing, pointer));
|
|
35
39
|
else
|
|
36
|
-
notes.set(
|
|
40
|
+
notes.set(pointer.id, pointer);
|
|
37
41
|
}
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
const existing = articles.get(
|
|
42
|
+
else if (isAddressPointer(pointer)) {
|
|
43
|
+
const address = getReplaceableAddressFromPointer(pointer);
|
|
44
|
+
const existing = articles.get(address);
|
|
41
45
|
if (existing)
|
|
42
|
-
articles.set(
|
|
46
|
+
articles.set(address, mergeAddressPointers(existing, pointer));
|
|
43
47
|
else
|
|
44
|
-
articles.set(
|
|
48
|
+
articles.set(address, pointer);
|
|
45
49
|
}
|
|
46
|
-
for (const hashtag of bookmark.hashtags)
|
|
47
|
-
hashtags.add(hashtag);
|
|
48
|
-
for (const url of bookmark.urls)
|
|
49
|
-
urls.add(url);
|
|
50
50
|
}
|
|
51
|
-
return
|
|
52
|
-
notes: Array.from(notes.values()),
|
|
53
|
-
articles: Array.from(articles.values()),
|
|
54
|
-
hashtags: Array.from(hashtags),
|
|
55
|
-
urls: Array.from(urls),
|
|
56
|
-
};
|
|
51
|
+
return [...notes.values(), ...articles.values()];
|
|
57
52
|
}
|
|
58
|
-
/** Returns
|
|
53
|
+
/** Returns the bookmarks of the event */
|
|
59
54
|
export function getBookmarks(bookmark) {
|
|
60
|
-
const hidden = getHiddenBookmarks(bookmark);
|
|
61
|
-
if (hidden)
|
|
62
|
-
return mergeBookmarks(hidden, getPublicBookmarks(bookmark));
|
|
63
|
-
else
|
|
64
|
-
return getPublicBookmarks(bookmark);
|
|
65
|
-
}
|
|
66
|
-
/** Returns the public bookmarks of the event */
|
|
67
|
-
export function getPublicBookmarks(bookmark) {
|
|
68
55
|
return getOrComputeCachedValue(bookmark, BookmarkPublicSymbol, () => parseBookmarkTags(bookmark.tags));
|
|
69
56
|
}
|
|
70
57
|
/** Checks if the hidden bookmarks are unlocked */
|
|
71
58
|
export function isHiddenBookmarksUnlocked(bookmark) {
|
|
72
|
-
return isHiddenTagsUnlocked(bookmark) &&
|
|
59
|
+
return (isHiddenTagsUnlocked(bookmark) && (BookmarkHiddenSymbol in bookmark || getHiddenBookmarks(bookmark) !== undefined));
|
|
73
60
|
}
|
|
74
61
|
export function getHiddenBookmarks(bookmark) {
|
|
75
|
-
if (
|
|
62
|
+
if (BookmarkHiddenSymbol in bookmark)
|
|
76
63
|
return bookmark[BookmarkHiddenSymbol];
|
|
77
64
|
//get hidden tags
|
|
78
65
|
const tags = getHiddenTags(bookmark);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { logger } from "applesauce-core";
|
|
2
2
|
import { canHaveEncryptedContent, getEncryptedContent, isEncryptedContentUnlocked, setEncryptedContentCache, } from "applesauce-core/helpers/encrypted-content";
|
|
3
3
|
import { kinds, notifyEventUpdate } from "applesauce-core/helpers/event";
|
|
4
|
-
import { catchError, combineLatest, distinct, EMPTY, filter, isObservable, map, merge, mergeMap, of, switchMap, } from "rxjs";
|
|
5
|
-
import { getGiftWrapSeal, getSealGiftWrap, getSealRumor } from "./gift-wrap.js";
|
|
4
|
+
import { catchError, combineLatest, combineLatestWith, distinct, EMPTY, filter, isObservable, map, merge, mergeMap, of, switchMap, } from "rxjs";
|
|
5
|
+
import { getGiftWrapSeal, getSealGiftWrap, getSealRumor, isGiftWrapUnlocked } from "./gift-wrap.js";
|
|
6
6
|
/** A symbol that is used to mark encrypted content as being from a cache */
|
|
7
7
|
export const EncryptedContentFromCacheSymbol = Symbol.for("encrypted-content-from-cache");
|
|
8
8
|
/** Marks the encrypted content as being from a cache */
|
|
@@ -32,15 +32,20 @@ export function persistEncryptedContent(eventStore, storage, fallback) {
|
|
|
32
32
|
.pipe(
|
|
33
33
|
// Look for events that support encrypted content and are locked
|
|
34
34
|
filter((e) => canHaveEncryptedContent(e.kind) && isEncryptedContentUnlocked(e) === false),
|
|
35
|
+
// Get the storage
|
|
36
|
+
combineLatestWith(storage$),
|
|
35
37
|
// Get the encrypted content from storage
|
|
36
|
-
mergeMap((event) =>
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
mergeMap(([event, storage]) =>
|
|
39
|
+
// Get content from storage
|
|
40
|
+
combineLatest([
|
|
41
|
+
of(event),
|
|
42
|
+
getItem(storage, event).catch((error) => {
|
|
43
|
+
log(`Failed to restore encrypted content for ${event.id}`, error);
|
|
44
|
+
return of(null);
|
|
45
|
+
}),
|
|
46
|
+
])))
|
|
42
47
|
.subscribe(async ([event, content]) => {
|
|
43
|
-
if (
|
|
48
|
+
if (typeof content !== "string")
|
|
44
49
|
return;
|
|
45
50
|
// Restore the encrypted content and set it as from a cache
|
|
46
51
|
markEncryptedContentFromCache(event);
|
|
@@ -79,14 +84,16 @@ export function persistEncryptedContent(eventStore, storage, fallback) {
|
|
|
79
84
|
log(`Restored encrypted content for ${seal.id}`);
|
|
80
85
|
});
|
|
81
86
|
// Persist encrypted content when it is updated or inserted
|
|
82
|
-
const persist =
|
|
87
|
+
const persist = merge(eventStore.update$, eventStore.insert$)
|
|
83
88
|
.pipe(
|
|
84
89
|
// Look for events that support encrypted content and are unlocked and not from the cache
|
|
85
|
-
filter((
|
|
90
|
+
filter((event) => canHaveEncryptedContent(event.kind) &&
|
|
86
91
|
isEncryptedContentUnlocked(event) &&
|
|
87
|
-
|
|
92
|
+
isEncryptedContentFromCache(event) === false),
|
|
88
93
|
// Only persist the encrypted content once
|
|
89
|
-
distinct((
|
|
94
|
+
distinct((event) => event.id),
|
|
95
|
+
// get the storage
|
|
96
|
+
combineLatestWith(storage$))
|
|
90
97
|
.subscribe(async ([event, storage]) => {
|
|
91
98
|
try {
|
|
92
99
|
const content = getEncryptedContent(event);
|
|
@@ -102,18 +109,9 @@ export function persistEncryptedContent(eventStore, storage, fallback) {
|
|
|
102
109
|
});
|
|
103
110
|
// Persist seals when the gift warp is unlocked or inserted unlocked
|
|
104
111
|
// This relies on the gift wrap event being updated when a seal is unlocked
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
filter(([event]) => event.kind === kinds.GiftWrap && isEncryptedContentUnlocked(event)),
|
|
109
|
-
// Get the seal event
|
|
110
|
-
map(([gift, storage]) => [getGiftWrapSeal(gift), storage]),
|
|
111
|
-
// Make sure the seal is defined
|
|
112
|
-
filter(([seal]) => seal !== undefined),
|
|
113
|
-
// Make sure seal is unlocked and not from cache
|
|
114
|
-
filter(([seal]) => isEncryptedContentUnlocked(seal) && !isEncryptedContentFromCache(seal)),
|
|
115
|
-
// Only persist the seal once
|
|
116
|
-
distinct(([seal]) => seal.id))
|
|
112
|
+
const unlockedSeals$ = merge(eventStore.update$, eventStore.insert$).pipe(filter((event) => event.kind === kinds.GiftWrap), filter(isGiftWrapUnlocked), map((gift) => getGiftWrapSeal(gift)), distinct((seal) => seal.id));
|
|
113
|
+
const persistSeals = unlockedSeals$
|
|
114
|
+
.pipe(filter((seal) => isEncryptedContentFromCache(seal) === false), combineLatestWith(storage$))
|
|
117
115
|
.subscribe(async ([seal, storage]) => {
|
|
118
116
|
if (!seal)
|
|
119
117
|
return;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventMemory } from "applesauce-core/event-store";
|
|
2
|
+
import { safeParse } from "applesauce-core/helpers";
|
|
2
3
|
import { getEncryptedContent, isEncryptedContentUnlocked, lockEncryptedContent, unlockEncryptedContent, } from "applesauce-core/helpers/encrypted-content";
|
|
3
4
|
import { kinds, notifyEventUpdate, verifyWrappedEvent, } from "applesauce-core/helpers/event";
|
|
4
5
|
/**
|
|
@@ -64,7 +65,7 @@ export function getRumorGiftWraps(rumor) {
|
|
|
64
65
|
}
|
|
65
66
|
/** Checks if a seal event is locked and casts it to the {@link UnlockedSeal} type */
|
|
66
67
|
export function isSealUnlocked(seal) {
|
|
67
|
-
return isEncryptedContentUnlocked(seal) === true &&
|
|
68
|
+
return RumorSymbol in seal || (isEncryptedContentUnlocked(seal) === true && getSealRumor(seal) !== undefined);
|
|
68
69
|
}
|
|
69
70
|
/** Returns if a gift-wrap event or gift-wrap seal is locked */
|
|
70
71
|
export function isGiftWrapUnlocked(gift) {
|
|
@@ -84,7 +85,7 @@ export function getSealRumor(seal) {
|
|
|
84
85
|
if (seal.kind !== kinds.Seal)
|
|
85
86
|
return undefined;
|
|
86
87
|
// If unlocked return the rumor
|
|
87
|
-
if (
|
|
88
|
+
if (RumorSymbol in seal)
|
|
88
89
|
return seal[RumorSymbol];
|
|
89
90
|
// Get the encrypted content plaintext
|
|
90
91
|
const content = getEncryptedContent(seal);
|
|
@@ -92,7 +93,12 @@ export function getSealRumor(seal) {
|
|
|
92
93
|
if (!content)
|
|
93
94
|
return undefined;
|
|
94
95
|
// Parse the content as a rumor event
|
|
95
|
-
let rumor =
|
|
96
|
+
let rumor = safeParse(content);
|
|
97
|
+
// Failed to parse rumor, save undefined and return undefined
|
|
98
|
+
if (!rumor) {
|
|
99
|
+
Reflect.set(seal, RumorSymbol, undefined);
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
96
102
|
// Check if the rumor event already exists in the internal event set
|
|
97
103
|
const existing = internalGiftWrapEvents.getEvent(rumor.id);
|
|
98
104
|
if (existing)
|
|
@@ -112,8 +118,8 @@ export function getSealRumor(seal) {
|
|
|
112
118
|
}
|
|
113
119
|
export function getGiftWrapSeal(gift) {
|
|
114
120
|
// Returned cached seal if it exists (downstream)
|
|
115
|
-
if (
|
|
116
|
-
return
|
|
121
|
+
if (SealSymbol in gift)
|
|
122
|
+
return gift[SealSymbol];
|
|
117
123
|
// Get the encrypted content
|
|
118
124
|
const content = getEncryptedContent(gift);
|
|
119
125
|
// Return undefined if the content is not found
|
package/dist/helpers/groups.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
2
|
-
import { NameValueTag } from "applesauce-core/helpers/tags";
|
|
3
2
|
export declare const GROUPS_LIST_KIND = 10009;
|
|
4
3
|
export declare const GROUP_MESSAGE_KIND = 9;
|
|
4
|
+
export declare const GROUP_METADATA_KIND = 39000;
|
|
5
|
+
export declare const GROUP_ADMINS_KIND = 39001;
|
|
6
|
+
export declare const GROUP_MEMBERS_KIND = 39002;
|
|
7
|
+
export declare const GROUP_ROLES_KIND = 39003;
|
|
8
|
+
export declare const JOIN_REQUEST_KIND = 9021;
|
|
9
|
+
export declare const LEAVE_REQUEST_KIND = 9022;
|
|
10
|
+
export declare const PUT_USER_KIND = 9000;
|
|
11
|
+
export declare const REMOVE_USER_KIND = 9001;
|
|
12
|
+
export declare const EDIT_METADATA_KIND = 9002;
|
|
13
|
+
export declare const DELETE_EVENT_KIND = 9005;
|
|
14
|
+
export declare const CREATE_GROUP_KIND = 9007;
|
|
15
|
+
export declare const DELETE_GROUP_KIND = 9008;
|
|
16
|
+
export declare const CREATE_INVITE_KIND = 9009;
|
|
5
17
|
/** NIP-29 group pointer */
|
|
6
18
|
export type GroupPointer = {
|
|
7
19
|
/** the id of the group */
|
|
@@ -18,16 +30,116 @@ export declare function encodeGroupPointer(pointer: GroupPointer): string;
|
|
|
18
30
|
export declare const GroupsPublicSymbol: unique symbol;
|
|
19
31
|
export declare const GroupsHiddenSymbol: unique symbol;
|
|
20
32
|
/** gets a {@link GroupPointer} from a "h" tag if it has a relay hint */
|
|
21
|
-
export declare function getGroupPointerFromHTag(tag: string[]): GroupPointer | undefined;
|
|
33
|
+
export declare function getGroupPointerFromHTag(tag: string[], hint?: string): GroupPointer | undefined;
|
|
22
34
|
/** gets a {@link GroupPointer} from a "group" tag */
|
|
23
35
|
export declare function getGroupPointerFromGroupTag(tag: string[]): GroupPointer;
|
|
24
36
|
/** Returns all the public groups from a k:10009 list */
|
|
25
37
|
export declare function getPublicGroups(bookmark: NostrEvent): GroupPointer[];
|
|
26
38
|
/** Returns all the hidden groups from a k:10009 list */
|
|
27
39
|
export declare function getHiddenGroups(bookmark: NostrEvent): GroupPointer[] | undefined;
|
|
40
|
+
/** Gets a {@link GroupPointer} from a group event by reading the "h" tag */
|
|
41
|
+
export declare function getGroupPointer(event: NostrEvent, relay?: string): GroupPointer | undefined;
|
|
42
|
+
/** Gets the group id from a group event by reading the "h" tag */
|
|
43
|
+
export declare function getGroupId(event: NostrEvent): string | undefined;
|
|
28
44
|
/** Gets a {@link GroupPointer} from a kind 39000 group metadata event */
|
|
29
45
|
export declare function getGroupPointerFromMetadata(event: NostrEvent, relay: string): GroupPointer | undefined;
|
|
30
|
-
/**
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
46
|
+
/** Group metadata structure from kind 39000 */
|
|
47
|
+
export type GroupMetadata = {
|
|
48
|
+
id: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
picture?: string;
|
|
51
|
+
about?: string;
|
|
52
|
+
isPublic: boolean;
|
|
53
|
+
isPrivate: boolean;
|
|
54
|
+
isOpen: boolean;
|
|
55
|
+
isClosed: boolean;
|
|
56
|
+
};
|
|
57
|
+
/** Group admin with roles from kind 39001 */
|
|
58
|
+
export type GroupAdmin = {
|
|
59
|
+
pubkey: string;
|
|
60
|
+
roles: string[];
|
|
61
|
+
};
|
|
62
|
+
/** Group role definition from kind 39003 */
|
|
63
|
+
export type GroupRole = {
|
|
64
|
+
name: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
};
|
|
67
|
+
/** Join request event information (kind 9021) */
|
|
68
|
+
export type GroupJoinRequestInfo = {
|
|
69
|
+
groupId: string;
|
|
70
|
+
reason?: string;
|
|
71
|
+
inviteCode?: string;
|
|
72
|
+
};
|
|
73
|
+
/** Leave request event information (kind 9022) */
|
|
74
|
+
export type GroupLeaveRequestInfo = {
|
|
75
|
+
groupId: string;
|
|
76
|
+
reason?: string;
|
|
77
|
+
};
|
|
78
|
+
/** Put user event information (kind 9000) */
|
|
79
|
+
export type GroupPutUserInfo = {
|
|
80
|
+
groupId: string;
|
|
81
|
+
pubkey: string;
|
|
82
|
+
roles?: string[];
|
|
83
|
+
reason?: string;
|
|
84
|
+
};
|
|
85
|
+
/** Remove user event information (kind 9001) */
|
|
86
|
+
export type GroupRemoveUserInfo = {
|
|
87
|
+
groupId: string;
|
|
88
|
+
pubkey: string;
|
|
89
|
+
reason?: string;
|
|
90
|
+
};
|
|
91
|
+
/** Edit metadata event information (kind 9002) */
|
|
92
|
+
export type GroupEditMetadataInfo = {
|
|
93
|
+
groupId: string;
|
|
94
|
+
metadataFields: Partial<GroupMetadata>;
|
|
95
|
+
reason?: string;
|
|
96
|
+
};
|
|
97
|
+
/** Delete event information (kind 9005) */
|
|
98
|
+
export type GroupDeleteEventInfo = {
|
|
99
|
+
groupId: string;
|
|
100
|
+
eventId: string;
|
|
101
|
+
reason?: string;
|
|
102
|
+
};
|
|
103
|
+
/** Create group event information (kind 9007) */
|
|
104
|
+
export type GroupCreateGroupInfo = {
|
|
105
|
+
groupId: string;
|
|
106
|
+
reason?: string;
|
|
107
|
+
};
|
|
108
|
+
/** Delete group event information (kind 9008) */
|
|
109
|
+
export type GroupDeleteGroupInfo = {
|
|
110
|
+
groupId: string;
|
|
111
|
+
reason?: string;
|
|
112
|
+
};
|
|
113
|
+
/** Create invite event information (kind 9009) */
|
|
114
|
+
export type GroupCreateInviteInfo = {
|
|
115
|
+
groupId: string;
|
|
116
|
+
reason?: string;
|
|
117
|
+
};
|
|
118
|
+
/** Gets group metadata from a kind 39000 event */
|
|
119
|
+
export declare function getGroupMetadata(event: NostrEvent): GroupMetadata | undefined;
|
|
120
|
+
/** Gets group admins from a kind 39001 event */
|
|
121
|
+
export declare function getGroupAdmins(event: NostrEvent): GroupAdmin[] | undefined;
|
|
122
|
+
/** Gets group members from a kind 39002 event */
|
|
123
|
+
export declare function getGroupMembers(event: NostrEvent): string[] | undefined;
|
|
124
|
+
/** Gets group roles from a kind 39003 event */
|
|
125
|
+
export declare function getGroupRoles(event: NostrEvent): GroupRole[] | undefined;
|
|
126
|
+
/** Gets join request information from a kind 9021 event */
|
|
127
|
+
export declare function getGroupJoinRequestInfo(event: NostrEvent): GroupJoinRequestInfo | undefined;
|
|
128
|
+
/** Gets leave request information from a kind 9022 event */
|
|
129
|
+
export declare function getGroupLeaveRequestInfo(event: NostrEvent): GroupLeaveRequestInfo | undefined;
|
|
130
|
+
/** Gets put user event information from a kind 9000 event */
|
|
131
|
+
export declare function getGroupPutUserInfo(event: NostrEvent): GroupPutUserInfo | undefined;
|
|
132
|
+
/** Gets remove user event information from a kind 9001 event */
|
|
133
|
+
export declare function getGroupRemoveUserInfo(event: NostrEvent): GroupRemoveUserInfo | undefined;
|
|
134
|
+
/** Gets edit metadata event information from a kind 9002 event */
|
|
135
|
+
export declare function getGroupEditMetadataInfo(event: NostrEvent): GroupEditMetadataInfo | undefined;
|
|
136
|
+
/** Gets delete event information from a kind 9005 event */
|
|
137
|
+
export declare function getGroupDeleteEventInfo(event: NostrEvent): GroupDeleteEventInfo | undefined;
|
|
138
|
+
/** Gets create group event information from a kind 9007 event */
|
|
139
|
+
export declare function getGroupCreateGroupInfo(event: NostrEvent): GroupCreateGroupInfo | undefined;
|
|
140
|
+
/** Gets delete group event information from a kind 9008 event */
|
|
141
|
+
export declare function getGroupDeleteGroupInfo(event: NostrEvent): GroupDeleteGroupInfo | undefined;
|
|
142
|
+
/** Gets create invite event information from a kind 9009 event */
|
|
143
|
+
export declare function getGroupCreateInviteInfo(event: NostrEvent): GroupCreateInviteInfo | undefined;
|
|
144
|
+
/** Checks group membership status from kind 9000/9001 events */
|
|
145
|
+
export declare function checkGroupMembership(events: NostrEvent[], pubkey: string): boolean | undefined;
|