applesauce-common 6.1.0 → 7.0.0
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/README.md +1 -0
- package/dist/casts/_circular-import.d.ts +3 -0
- package/dist/casts/_circular-import.js +3 -0
- package/dist/casts/app-handler.d.ts +56 -0
- package/dist/casts/app-handler.js +105 -0
- package/dist/casts/app-recommendation.d.ts +26 -0
- package/dist/casts/app-recommendation.js +41 -0
- package/dist/casts/external-identities.d.ts +9 -0
- package/dist/casts/external-identities.js +14 -0
- package/dist/casts/forum-thread.d.ts +17 -0
- package/dist/casts/forum-thread.js +31 -0
- package/dist/casts/git-issue.d.ts +18 -0
- package/dist/casts/git-issue.js +26 -0
- package/dist/casts/git-patch.d.ts +49 -0
- package/dist/casts/git-patch.js +88 -0
- package/dist/casts/git-pull-request.d.ts +67 -0
- package/dist/casts/git-pull-request.js +122 -0
- package/dist/casts/git-repository.d.ts +9 -0
- package/dist/casts/git-repository.js +16 -0
- package/dist/casts/git-thread.d.ts +33 -0
- package/dist/casts/git-thread.js +65 -0
- package/dist/casts/index.d.ts +11 -0
- package/dist/casts/index.js +11 -0
- package/dist/casts/napplet.d.ts +98 -0
- package/dist/casts/napplet.js +196 -0
- package/dist/casts/note.d.ts +8 -0
- package/dist/casts/note.js +21 -1
- package/dist/casts/nsite.d.ts +134 -0
- package/dist/casts/nsite.js +249 -0
- package/dist/casts/profile.d.ts +20 -0
- package/dist/casts/profile.js +30 -0
- package/dist/casts/reaction.d.ts +1 -1
- package/dist/casts/relay-discovery.d.ts +4 -0
- package/dist/casts/relay-discovery.js +9 -1
- package/dist/casts/report.d.ts +28 -15
- package/dist/casts/report.js +42 -19
- package/dist/casts/share.d.ts +1 -1
- package/dist/casts/torrent.d.ts +5 -0
- package/dist/casts/torrent.js +8 -1
- package/dist/casts/trusted-assertions.d.ts +4 -2
- package/dist/casts/trusted-assertions.js +20 -19
- package/dist/casts/user-status.d.ts +33 -0
- package/dist/casts/user-status.js +69 -0
- package/dist/casts/user.d.ts +7 -0
- package/dist/casts/user.js +20 -1
- package/dist/factories/app-handler.d.ts +31 -0
- package/dist/factories/app-handler.js +50 -0
- package/dist/factories/app-recommendation.d.ts +21 -0
- package/dist/factories/app-recommendation.js +28 -0
- package/dist/factories/chat-message.d.ts +37 -0
- package/dist/factories/chat-message.js +56 -0
- package/dist/factories/comment.d.ts +8 -7
- package/dist/factories/comment.js +2 -2
- package/dist/factories/external-identities.d.ts +17 -0
- package/dist/factories/external-identities.js +28 -0
- package/dist/factories/forum-thread.d.ts +34 -0
- package/dist/factories/forum-thread.js +50 -0
- package/dist/factories/git-applied-status.d.ts +39 -0
- package/dist/factories/git-applied-status.js +53 -0
- package/dist/factories/git-closed-status.d.ts +18 -0
- package/dist/factories/git-closed-status.js +24 -0
- package/dist/factories/git-draft-status.d.ts +18 -0
- package/dist/factories/git-draft-status.js +24 -0
- package/dist/factories/git-issue.d.ts +19 -0
- package/dist/factories/git-issue.js +25 -0
- package/dist/factories/git-open-status.d.ts +18 -0
- package/dist/factories/git-open-status.js +22 -0
- package/dist/factories/git-patch.d.ts +59 -0
- package/dist/factories/git-patch.js +102 -0
- package/dist/factories/git-pull-request-update.d.ts +23 -0
- package/dist/factories/git-pull-request-update.js +33 -0
- package/dist/factories/git-pull-request.d.ts +39 -0
- package/dist/factories/git-pull-request.js +64 -0
- package/dist/factories/index.d.ts +23 -0
- package/dist/factories/index.js +23 -0
- package/dist/factories/internal/git-pull-request.d.ts +19 -0
- package/dist/factories/internal/git-pull-request.js +26 -0
- package/dist/factories/internal/git-status.d.ts +11 -0
- package/dist/factories/internal/git-status.js +12 -0
- package/dist/factories/internal/git-thread.d.ts +19 -0
- package/dist/factories/internal/git-thread.js +29 -0
- package/dist/factories/internal/napplet-manifest.d.ts +52 -0
- package/dist/factories/internal/napplet-manifest.js +85 -0
- package/dist/factories/internal/nsite-manifest.d.ts +45 -0
- package/dist/factories/internal/nsite-manifest.js +68 -0
- package/dist/factories/legacy-message.d.ts +2 -0
- package/dist/factories/legacy-message.js +9 -2
- package/dist/factories/named-napplet.d.ts +20 -0
- package/dist/factories/named-napplet.js +30 -0
- package/dist/factories/named-nsite.d.ts +28 -0
- package/dist/factories/named-nsite.js +53 -0
- package/dist/factories/napplet-snapshot.d.ts +18 -0
- package/dist/factories/napplet-snapshot.js +38 -0
- package/dist/factories/nostr-web-token.d.ts +39 -0
- package/dist/factories/nostr-web-token.js +95 -0
- package/dist/factories/nsite-snapshot.d.ts +18 -0
- package/dist/factories/nsite-snapshot.js +29 -0
- package/dist/factories/reaction.d.ts +3 -2
- package/dist/factories/report.d.ts +48 -0
- package/dist/factories/report.js +66 -0
- package/dist/factories/root-napplet.d.ts +18 -0
- package/dist/factories/root-napplet.js +24 -0
- package/dist/factories/root-nsite.d.ts +23 -0
- package/dist/factories/root-nsite.js +44 -0
- package/dist/factories/torrent.d.ts +24 -10
- package/dist/factories/torrent.js +48 -44
- package/dist/factories/trusted-provider-list.d.ts +23 -0
- package/dist/factories/trusted-provider-list.js +39 -0
- package/dist/factories/user-status.d.ts +26 -0
- package/dist/factories/user-status.js +52 -0
- package/dist/helpers/app-data.js +15 -7
- package/dist/helpers/app-handler.d.ts +43 -6
- package/dist/helpers/app-handler.js +53 -3
- package/dist/helpers/app-recommendation.d.ts +24 -0
- package/dist/helpers/app-recommendation.js +30 -0
- package/dist/helpers/bookmark.js +5 -2
- package/dist/helpers/comment.d.ts +11 -5
- package/dist/helpers/comment.js +7 -1
- package/dist/helpers/content.d.ts +3 -1
- package/dist/helpers/emoji-pack.js +11 -6
- package/dist/helpers/emoji.d.ts +2 -2
- package/dist/helpers/encrypted-content-cache.js +18 -1
- package/dist/helpers/external-id.d.ts +1 -0
- package/dist/helpers/external-id.js +21 -46
- package/dist/helpers/external-identities.d.ts +29 -0
- package/dist/helpers/external-identities.js +52 -0
- package/dist/helpers/file-metadata.js +5 -6
- package/dist/helpers/forum-thread.d.ts +10 -0
- package/dist/helpers/forum-thread.js +10 -0
- package/dist/helpers/gift-wrap.d.ts +40 -15
- package/dist/helpers/gift-wrap.js +110 -33
- package/dist/helpers/git-issue.d.ts +13 -0
- package/dist/helpers/git-issue.js +19 -0
- package/dist/helpers/git-patch.d.ts +41 -0
- package/dist/helpers/git-patch.js +73 -0
- package/dist/helpers/git-pull-request.d.ts +57 -0
- package/dist/helpers/git-pull-request.js +111 -0
- package/dist/helpers/git-repository.d.ts +4 -0
- package/dist/helpers/git-repository.js +16 -0
- package/dist/helpers/git-status.d.ts +44 -0
- package/dist/helpers/git-status.js +93 -0
- package/dist/helpers/git.d.ts +2 -0
- package/dist/helpers/git.js +4 -0
- package/dist/helpers/groups.d.ts +5 -2
- package/dist/helpers/groups.js +40 -18
- package/dist/helpers/hashtag.d.ts +4 -2
- package/dist/helpers/index.d.ts +11 -0
- package/dist/helpers/index.js +11 -0
- package/dist/helpers/lists.js +14 -2
- package/dist/helpers/lnurl.js +1 -1
- package/dist/helpers/mute.js +18 -7
- package/dist/helpers/napplet.d.ts +89 -0
- package/dist/helpers/napplet.js +144 -0
- package/dist/helpers/nostr-web-token.d.ts +54 -0
- package/dist/helpers/nostr-web-token.js +124 -0
- package/dist/helpers/nsite.d.ts +90 -0
- package/dist/helpers/nsite.js +217 -0
- package/dist/helpers/relay-discovery.d.ts +4 -0
- package/dist/helpers/relay-discovery.js +8 -0
- package/dist/helpers/reports.d.ts +35 -0
- package/dist/helpers/reports.js +36 -5
- package/dist/helpers/threading.d.ts +4 -2
- package/dist/helpers/torrent.d.ts +9 -6
- package/dist/helpers/torrent.js +23 -15
- package/dist/helpers/trusted-assertions.d.ts +7 -0
- package/dist/helpers/trusted-assertions.js +41 -2
- package/dist/helpers/user-status.d.ts +13 -1
- package/dist/helpers/user-status.js +15 -0
- package/dist/models/app-handler.d.ts +21 -0
- package/dist/models/app-handler.js +47 -0
- package/dist/models/git.d.ts +34 -0
- package/dist/models/git.js +144 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.js +3 -0
- package/dist/models/nsite.d.ts +22 -0
- package/dist/models/nsite.js +67 -0
- package/dist/models/thread.d.ts +4 -1
- package/dist/models/thread.js +34 -5
- package/dist/models/user-status.d.ts +8 -4
- package/dist/models/user-status.js +16 -22
- package/dist/observable/filter-timeline-by-mutes.d.ts +1 -1
- package/dist/observable/filter-timeline-by-mutes.js +5 -1
- package/dist/operations/app-handler.d.ts +24 -0
- package/dist/operations/app-handler.js +58 -0
- package/dist/operations/app-recommendation.d.ts +13 -0
- package/dist/operations/app-recommendation.js +40 -0
- package/dist/operations/calendar-event.js +3 -2
- package/dist/operations/chat-message.d.ts +9 -0
- package/dist/operations/chat-message.js +12 -0
- package/dist/operations/client.d.ts +1 -4
- package/dist/operations/client.js +1 -23
- package/dist/operations/comment.d.ts +9 -3
- package/dist/operations/comment.js +12 -9
- package/dist/operations/external-identities.d.ts +8 -0
- package/dist/operations/external-identities.js +23 -0
- package/dist/operations/forum-thread.d.ts +3 -0
- package/dist/operations/forum-thread.js +6 -0
- package/dist/operations/gift-wrap.js +38 -14
- package/dist/operations/git-issue.d.ts +18 -0
- package/dist/operations/git-issue.js +31 -0
- package/dist/operations/git-patch.d.ts +30 -0
- package/dist/operations/git-patch.js +75 -0
- package/dist/operations/git-pull-request.d.ts +29 -0
- package/dist/operations/git-pull-request.js +74 -0
- package/dist/operations/git-repository.js +4 -4
- package/dist/operations/git-status.d.ts +28 -0
- package/dist/operations/git-status.js +116 -0
- package/dist/operations/git-thread.d.ts +13 -0
- package/dist/operations/git-thread.js +39 -0
- package/dist/operations/index.d.ts +16 -0
- package/dist/operations/index.js +16 -0
- package/dist/operations/internal/git-commits.d.ts +2 -0
- package/dist/operations/internal/git-commits.js +16 -0
- package/dist/operations/napplet.d.ts +51 -0
- package/dist/operations/napplet.js +121 -0
- package/dist/operations/nostr-web-token.d.ts +27 -0
- package/dist/operations/nostr-web-token.js +58 -0
- package/dist/operations/nsite.d.ts +51 -0
- package/dist/operations/nsite.js +112 -0
- package/dist/operations/reaction.d.ts +12 -2
- package/dist/operations/reaction.js +1 -1
- package/dist/operations/report.d.ts +33 -0
- package/dist/operations/report.js +60 -0
- package/dist/operations/stream.js +5 -4
- package/dist/operations/torrent.d.ts +1 -4
- package/dist/operations/torrent.js +24 -11
- package/dist/operations/trusted-providers.d.ts +14 -0
- package/dist/operations/trusted-providers.js +33 -0
- package/dist/operations/user-status.d.ts +11 -0
- package/dist/operations/user-status.js +29 -0
- package/package.json +10 -10
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { KnownEvent, NostrEvent } from "applesauce-core/helpers/event";
|
|
2
|
+
import { Filter } from "applesauce-core/helpers/filter";
|
|
3
|
+
import { AddressPointer } from "applesauce-core/helpers/pointers";
|
|
4
|
+
import { HandlerLinkPlatform } from "./app-handler.js";
|
|
5
|
+
/** The event kind for NIP-89 handler recommendations */
|
|
6
|
+
export declare const APP_RECOMMENDATION_KIND = 31989;
|
|
7
|
+
/** A validated NIP-89 handler recommendation event */
|
|
8
|
+
export type AppRecommendationEvent = KnownEvent<typeof APP_RECOMMENDATION_KIND>;
|
|
9
|
+
/** A handler recommended for an event kind */
|
|
10
|
+
export interface RecommendedHandler {
|
|
11
|
+
/** The handler information address */
|
|
12
|
+
pointer: AddressPointer;
|
|
13
|
+
/** The platform the recommendation applies to */
|
|
14
|
+
platform?: HandlerLinkPlatform;
|
|
15
|
+
}
|
|
16
|
+
/** Returns a relay filter for recommendations for an event kind, optionally from a set of authors */
|
|
17
|
+
export declare function getAppRecommendationsFilter(kind: number, authors?: string[]): Filter;
|
|
18
|
+
/** Checks if an event is a valid NIP-89 handler recommendation (kind 31989) for a numeric event kind */
|
|
19
|
+
export declare function isValidAppRecommendation(event?: NostrEvent): event is AppRecommendationEvent;
|
|
20
|
+
/** Returns the event kind the recommendation applies to */
|
|
21
|
+
export declare function getRecommendationKind(recommendation: AppRecommendationEvent): number;
|
|
22
|
+
export declare function getRecommendationKind(recommendation: NostrEvent): number | undefined;
|
|
23
|
+
/** Returns the recommended handlers from the `a` tags */
|
|
24
|
+
export declare function getRecommendedHandlers(recommendation: NostrEvent): RecommendedHandler[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
|
|
2
|
+
import { getReplaceableIdentifier, kinds } from "applesauce-core/helpers/event";
|
|
3
|
+
import { getAddressPointerFromATag } from "applesauce-core/helpers/pointers";
|
|
4
|
+
import { processTags } from "applesauce-core/helpers/tags";
|
|
5
|
+
import { APP_HANDLER_KIND } from "./app-handler.js";
|
|
6
|
+
/** The event kind for NIP-89 handler recommendations */
|
|
7
|
+
export const APP_RECOMMENDATION_KIND = kinds.Handlerrecommendation;
|
|
8
|
+
const HandlersSymbol = Symbol.for("app-recommendation-handlers");
|
|
9
|
+
/** Returns a relay filter for recommendations for an event kind, optionally from a set of authors */
|
|
10
|
+
export function getAppRecommendationsFilter(kind, authors) {
|
|
11
|
+
return { kinds: [APP_RECOMMENDATION_KIND], "#d": [String(kind)], ...(authors ? { authors } : {}) };
|
|
12
|
+
}
|
|
13
|
+
/** Checks if an event is a valid NIP-89 handler recommendation (kind 31989) for a numeric event kind */
|
|
14
|
+
export function isValidAppRecommendation(event) {
|
|
15
|
+
return !!event && event.kind === APP_RECOMMENDATION_KIND && /^\d+$/.test(getReplaceableIdentifier(event));
|
|
16
|
+
}
|
|
17
|
+
export function getRecommendationKind(recommendation) {
|
|
18
|
+
return isValidAppRecommendation(recommendation) ? parseInt(getReplaceableIdentifier(recommendation)) : undefined;
|
|
19
|
+
}
|
|
20
|
+
/** Returns the recommended handlers from the `a` tags */
|
|
21
|
+
export function getRecommendedHandlers(recommendation) {
|
|
22
|
+
return getOrComputeCachedValue(recommendation, HandlersSymbol, () => processTags(recommendation.tags, (t) => {
|
|
23
|
+
if (t[0] !== "a")
|
|
24
|
+
return undefined;
|
|
25
|
+
const pointer = getAddressPointerFromATag(t);
|
|
26
|
+
if (pointer?.kind !== APP_HANDLER_KIND)
|
|
27
|
+
return undefined;
|
|
28
|
+
return t[3] ? { pointer, platform: t[3] } : { pointer };
|
|
29
|
+
}));
|
|
30
|
+
}
|
package/dist/helpers/bookmark.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getOrComputeCachedValue, isATag, isETag, notifyEventUpdate, processTags } from "applesauce-core/helpers";
|
|
2
|
+
import { setCachedValue } from "applesauce-core/helpers/cache";
|
|
2
3
|
import { kinds } from "applesauce-core/helpers/event";
|
|
3
4
|
import { getHiddenTags, isHiddenTagsUnlocked, unlockHiddenTags } from "applesauce-core/helpers/hidden-tags";
|
|
4
5
|
import { getAddressPointerFromATag, getEventPointerFromETag, getReplaceableAddressFromPointer, isAddressPointer, isEventPointer, mergeAddressPointers, mergeEventPointers, } from "applesauce-core/helpers/pointers";
|
|
@@ -67,8 +68,10 @@ export function getHiddenBookmarks(bookmark) {
|
|
|
67
68
|
return undefined;
|
|
68
69
|
// parse bookmarks
|
|
69
70
|
const bookmarks = parseBookmarkTags(tags);
|
|
70
|
-
//
|
|
71
|
-
|
|
71
|
+
// Derived from the event's own hidden tags — identity memo (see applesauce-core's cache.ts
|
|
72
|
+
// taxonomy). Written non-enumerable via setCachedValue (05.1-09) so a plain spread drops it
|
|
73
|
+
// instead of carrying a stale derivation onto a copy whose hidden tags differ.
|
|
74
|
+
setCachedValue(bookmark, BookmarkHiddenSymbol, bookmarks);
|
|
72
75
|
return bookmarks;
|
|
73
76
|
}
|
|
74
77
|
/** Unlocks the hidden bookmarks on a bookmarks event */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KnownEvent, NostrEvent } from "applesauce-core/helpers/event";
|
|
1
|
+
import { KnownEvent, NostrEvent, StoreEvent } from "applesauce-core/helpers/event";
|
|
2
2
|
import { ExternalIdentifiers, ExternalPointer } from "./external-id.js";
|
|
3
3
|
export declare const COMMENT_KIND = 1111;
|
|
4
4
|
/** Type for validated comment events */
|
|
@@ -32,9 +32,9 @@ export declare function getCommentAddressPointer(tags: string[][], root?: boolea
|
|
|
32
32
|
export declare function getCommentExternalPointer(tags: string[][], root?: boolean): CommentExternalPointer<keyof ExternalIdentifiers> | null;
|
|
33
33
|
/** Returns the root pointer for a comment */
|
|
34
34
|
export declare function getCommentRootPointer(comment: CommentEvent): CommentPointer;
|
|
35
|
-
export declare function getCommentRootPointer(comment:
|
|
35
|
+
export declare function getCommentRootPointer(comment: StoreEvent): CommentPointer | null;
|
|
36
36
|
/** Returns the reply pointer for a comment */
|
|
37
|
-
export declare function getCommentReplyPointer(comment:
|
|
37
|
+
export declare function getCommentReplyPointer(comment: StoreEvent): CommentPointer | null;
|
|
38
38
|
/** Checks if a pointer is a {@link CommentEventPointer} */
|
|
39
39
|
export declare function isCommentEventPointer(pointer: any): pointer is CommentEventPointer;
|
|
40
40
|
/** Checks if a pointer is a {@link CommentAddressPointer} */
|
|
@@ -45,5 +45,11 @@ export declare function isCommentExternalPointer(pointer: any): pointer is Comme
|
|
|
45
45
|
export declare function isValidComment(comment: NostrEvent): comment is CommentEvent;
|
|
46
46
|
/** Create a set fo tags for a single CommentPointer */
|
|
47
47
|
export declare function createCommentTagsFromCommentPointer(pointer: CommentPointer, root?: boolean): string[][];
|
|
48
|
-
/**
|
|
49
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Returns an array of NIP-22 tags for a kind 1111 comment event
|
|
50
|
+
* @param parent - The full parent event or {@link Rumor} being replied to. Only
|
|
51
|
+
* `id`/`kind`/`pubkey`/`tags` are read, so an unsigned rumor works the same as a
|
|
52
|
+
* signed event — the parent's own root tags are what make nested replies stay
|
|
53
|
+
* rooted on the original event.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createCommentTagsForEvent(parent: StoreEvent, relayHint?: string): string[][];
|
package/dist/helpers/comment.js
CHANGED
|
@@ -158,7 +158,13 @@ export function createCommentTagsFromCommentPointer(pointer, root = false) {
|
|
|
158
158
|
}
|
|
159
159
|
throw new Error("Unknown comment pointer kind");
|
|
160
160
|
}
|
|
161
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* Returns an array of NIP-22 tags for a kind 1111 comment event
|
|
163
|
+
* @param parent - The full parent event or {@link Rumor} being replied to. Only
|
|
164
|
+
* `id`/`kind`/`pubkey`/`tags` are read, so an unsigned rumor works the same as a
|
|
165
|
+
* signed event — the parent's own root tags are what make nested replies stay
|
|
166
|
+
* rooted on the original event.
|
|
167
|
+
*/
|
|
162
168
|
export function createCommentTagsForEvent(parent, relayHint) {
|
|
163
169
|
const tags = [];
|
|
164
170
|
let parentPointer;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
2
2
|
/** Returns the NIP-36 content-warning for an event. returns boolean if there is no "reason" */
|
|
3
|
-
export declare function getContentWarning
|
|
3
|
+
export declare function getContentWarning<E extends {
|
|
4
|
+
tags: string[][];
|
|
5
|
+
} = NostrEvent>(event: E): string | boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getOrComputeCachedValue, notifyEventUpdate } from "applesauce-core/helpers";
|
|
2
|
+
import { setCachedValue } from "applesauce-core/helpers/cache";
|
|
2
3
|
import { getReplaceableIdentifier, getTagValue, kinds } from "applesauce-core/helpers/event";
|
|
3
4
|
import { getHiddenTags, isHiddenTagsUnlocked, setHiddenTagsEncryptionMethod, unlockHiddenTags, } from "applesauce-core/helpers/hidden-tags";
|
|
4
5
|
import { getAddressPointerFromATag } from "applesauce-core/helpers/pointers";
|
|
@@ -69,7 +70,10 @@ export function getHiddenFavoriteEmojis(list) {
|
|
|
69
70
|
if (!tags)
|
|
70
71
|
return undefined;
|
|
71
72
|
const emojis = parseEmojiTags(tags);
|
|
72
|
-
|
|
73
|
+
// Derived from the list's own hidden tags — identity memo (see applesauce-core's cache.ts
|
|
74
|
+
// taxonomy). Written non-enumerable via setCachedValue (05.1-09) so a plain spread drops it
|
|
75
|
+
// instead of carrying a stale derivation onto a copy whose hidden tags differ.
|
|
76
|
+
setCachedValue(list, FavoriteEmojiPacksHiddenSymbol, emojis);
|
|
73
77
|
return emojis;
|
|
74
78
|
}
|
|
75
79
|
export function getHiddenFavoriteEmojiPackPointers(list) {
|
|
@@ -79,16 +83,17 @@ export function getHiddenFavoriteEmojiPackPointers(list) {
|
|
|
79
83
|
if (!tags)
|
|
80
84
|
return undefined;
|
|
81
85
|
const pointers = parseEmojiPackPointers(tags);
|
|
82
|
-
|
|
86
|
+
// Derived from the list's own hidden tags — identity memo (see applesauce-core's cache.ts
|
|
87
|
+
// taxonomy). Written non-enumerable via setCachedValue (05.1-09) so a plain spread drops it
|
|
88
|
+
// instead of carrying a stale derivation onto a copy whose hidden tags differ.
|
|
89
|
+
setCachedValue(list, FavoriteEmojiPacksHiddenPointersSymbol, pointers);
|
|
83
90
|
return pointers;
|
|
84
91
|
}
|
|
85
92
|
/** Checks if the hidden favorite emoji packs are unlocked */
|
|
86
93
|
export function isHiddenFavoriteEmojiPacksUnlocked(list) {
|
|
87
94
|
return (isHiddenTagsUnlocked(list) &&
|
|
88
|
-
(
|
|
89
|
-
|
|
90
|
-
getHiddenFavoriteEmojis(list) !== undefined ||
|
|
91
|
-
getHiddenFavoriteEmojiPackPointers(list) !== undefined));
|
|
95
|
+
getHiddenFavoriteEmojis(list) !== undefined &&
|
|
96
|
+
getHiddenFavoriteEmojiPackPointers(list) !== undefined);
|
|
92
97
|
}
|
|
93
98
|
/** Unlocks the hidden favorite emojis and pack pointers on a kind 10030 list */
|
|
94
99
|
export async function unlockHiddenFavoriteEmojiPacks(list, signer) {
|
package/dist/helpers/emoji.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NostrEvent } from "applesauce-core/helpers/event";
|
|
1
|
+
import { NostrEvent, StoreEvent } from "applesauce-core/helpers/event";
|
|
2
2
|
import { AddressPointer } from "applesauce-core/helpers/pointers";
|
|
3
3
|
export type Emoji = {
|
|
4
4
|
/** The emoji shortcode (without the ::) */
|
|
@@ -17,4 +17,4 @@ export declare function getEmojiFromTags(event: {
|
|
|
17
17
|
tags: string[][];
|
|
18
18
|
} | string[][], code: string): Emoji | undefined;
|
|
19
19
|
/** Returns the custom emoji for a reaction event */
|
|
20
|
-
export declare function getReactionEmoji(event:
|
|
20
|
+
export declare function getReactionEmoji<E extends StoreEvent = NostrEvent>(event: E): Emoji | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { logger } from "applesauce-core";
|
|
2
|
+
import { setCachedValue } from "applesauce-core/helpers/cache";
|
|
2
3
|
import { canHaveEncryptedContent, getEncryptedContent, isEncryptedContentUnlocked, setEncryptedContentCache, } from "applesauce-core/helpers/encrypted-content";
|
|
3
4
|
import { kinds, notifyEventUpdate } from "applesauce-core/helpers/event";
|
|
4
5
|
import { catchError, combineLatest, combineLatestWith, distinct, EMPTY, filter, isObservable, map, merge, mergeMap, of, switchMap, } from "rxjs";
|
|
@@ -7,7 +8,23 @@ import { getGiftWrapSeal, getSealGiftWrap, getSealRumor, isGiftWrapUnlocked } fr
|
|
|
7
8
|
export const EncryptedContentFromCacheSymbol = Symbol.for("encrypted-content-from-cache");
|
|
8
9
|
/** Marks the encrypted content as being from a cache */
|
|
9
10
|
export function markEncryptedContentFromCache(event) {
|
|
10
|
-
|
|
11
|
+
// A restore-provenance flag that is instance-local — unlike FromCacheSymbol, it is NOT a member
|
|
12
|
+
// of EventStore.copySymbolsToDuplicateEvent's merge list (see cache.ts taxonomy), so a
|
|
13
|
+
// duplicate-delivery merge never copies it onto another object. persistEncryptedContent's
|
|
14
|
+
// `persist` and `persistSeals` subscriptions both filter on isEncryptedContentFromCache(event)
|
|
15
|
+
// === false to avoid re-persisting content that was just restored from the cache: if a
|
|
16
|
+
// logically-identical event ever reached that filter as a distinct object lacking this flag, the
|
|
17
|
+
// filter would fail open and re-persist already-cached content. Whether that is reachable is
|
|
18
|
+
// unverified here: EventMemory.add keeps the originally-tracked object for a same-id duplicate
|
|
19
|
+
// and discards the newcomer entirely, so the ordinary EventStore.add duplicate-delivery path does
|
|
20
|
+
// not appear to replace the tracked instance — but replaceable-history and cross-store paths were
|
|
21
|
+
// not traced as part of this comment-only fix.
|
|
22
|
+
//
|
|
23
|
+
// Written non-enumerable via setCachedValue (05.1-09) so a plain spread drops it instead of
|
|
24
|
+
// carrying a stale provenance flag forward. isEncryptedContentFromCache's Reflect.has reader is
|
|
25
|
+
// enumerability-blind and still sees this write (WR-11's separate === true tightening stays
|
|
26
|
+
// deferred — D-10 — and is out of scope here).
|
|
27
|
+
setCachedValue(event, EncryptedContentFromCacheSymbol, true);
|
|
11
28
|
}
|
|
12
29
|
/** Checks if the encrypted content is from a cache */
|
|
13
30
|
export function isEncryptedContentFromCache(event) {
|
|
@@ -1,29 +1,16 @@
|
|
|
1
|
+
import { serializeURL } from "applesauce-core/helpers/url";
|
|
1
2
|
/** Casts a string to a valid external pointer */
|
|
2
3
|
export function isValidExternalPointer(identifier) {
|
|
3
4
|
return parseExternalPointer(identifier) !== null;
|
|
4
5
|
}
|
|
5
|
-
/**
|
|
6
|
-
* Normalizes a URL according to NIP-73:
|
|
7
|
-
* - Removes fragment
|
|
8
|
-
* - Returns the normalized URL string
|
|
9
|
-
*/
|
|
10
|
-
function normalizeUrl(url) {
|
|
11
|
-
try {
|
|
12
|
-
const urlObj = new URL(url);
|
|
13
|
-
urlObj.hash = ""; // Remove fragment
|
|
14
|
-
return urlObj.toString();
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
// If URL parsing fails, return original (will be caught by validation)
|
|
18
|
-
return url;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
6
|
export function parseExternalPointer(identifier) {
|
|
22
7
|
// Check explicit prefixes first (these take precedence over URL parsing)
|
|
23
8
|
if (identifier.startsWith("#"))
|
|
24
9
|
return { kind: "#", identifier: identifier };
|
|
25
10
|
if (identifier.startsWith("geo:"))
|
|
26
11
|
return { kind: "geo", identifier: identifier };
|
|
12
|
+
if (identifier.startsWith("iso3166:"))
|
|
13
|
+
return { kind: "iso3166", identifier: identifier };
|
|
27
14
|
if (identifier.startsWith("isbn:"))
|
|
28
15
|
return { kind: "isbn", identifier: identifier };
|
|
29
16
|
if (identifier.startsWith("podcast:guid:"))
|
|
@@ -37,40 +24,28 @@ export function parseExternalPointer(identifier) {
|
|
|
37
24
|
if (identifier.startsWith("doi:"))
|
|
38
25
|
return { kind: "doi", identifier: identifier };
|
|
39
26
|
// Check for blockchain identifiers
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return { kind:
|
|
46
|
-
}
|
|
47
|
-
// Ethereum: ethereum:<chainId>:tx:<txHash> or ethereum:<chainId>:address:<address>
|
|
48
|
-
const ethereumTxMatch = identifier.match(/^ethereum:(\d+):tx:(.+)$/);
|
|
49
|
-
if (ethereumTxMatch) {
|
|
50
|
-
return { kind: "ethereum:tx", identifier: identifier };
|
|
51
|
-
}
|
|
52
|
-
const ethereumAddressMatch = identifier.match(/^ethereum:(\d+):address:(.+)$/);
|
|
53
|
-
if (ethereumAddressMatch) {
|
|
54
|
-
return { kind: "ethereum:address", identifier: identifier };
|
|
55
|
-
}
|
|
56
|
-
// Other blockchains: <blockchain>:tx:<txid> or <blockchain>:address:<address>
|
|
57
|
-
// Exclude known prefixes to avoid false matches
|
|
58
|
-
const blockchainTxMatch = identifier.match(/^([a-z0-9]+):tx:(.+)$/);
|
|
59
|
-
if (blockchainTxMatch && !identifier.startsWith("bitcoin:") && !identifier.startsWith("ethereum:")) {
|
|
60
|
-
const blockchain = blockchainTxMatch[1];
|
|
61
|
-
return { kind: `${blockchain}:tx`, identifier: identifier };
|
|
62
|
-
}
|
|
63
|
-
const blockchainAddressMatch = identifier.match(/^([a-z0-9]+):address:(.+)$/);
|
|
64
|
-
if (blockchainAddressMatch && !identifier.startsWith("bitcoin:") && !identifier.startsWith("ethereum:")) {
|
|
65
|
-
const blockchain = blockchainAddressMatch[1];
|
|
66
|
-
return { kind: `${blockchain}:address`, identifier: identifier };
|
|
27
|
+
// Generic format (NIP-73): <blockchain>:[<chainId>:]tx:<txid> or <blockchain>:[<chainId>:]address:<address>
|
|
28
|
+
// The optional chainId (e.g. ethereum:1:tx:...) is not part of the "k" tag kind
|
|
29
|
+
const blockchainMatch = identifier.match(/^([a-z0-9]+):(?:\d+:)?(tx|address):.+$/);
|
|
30
|
+
if (blockchainMatch) {
|
|
31
|
+
const [, blockchain, type] = blockchainMatch;
|
|
32
|
+
return { kind: `${blockchain}:${type}`, identifier: identifier };
|
|
67
33
|
}
|
|
68
34
|
// Check for URL (must be a valid URL, normalized, no fragment)
|
|
69
35
|
// URLs don't have a prefix, so we check if it's a valid URL after checking all prefixes
|
|
70
36
|
try {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
37
|
+
let normalized;
|
|
38
|
+
if (/^(?:https?|wss?):\/\//i.test(identifier)) {
|
|
39
|
+
const serialized = serializeURL(identifier);
|
|
40
|
+
const hash = serialized.indexOf("#");
|
|
41
|
+
normalized = hash === -1 ? serialized : serialized.slice(0, hash);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// Removing a fragment can also trim opaque paths, so retain the native setter here.
|
|
45
|
+
const url = new URL(identifier);
|
|
46
|
+
url.hash = "";
|
|
47
|
+
normalized = url.href;
|
|
48
|
+
}
|
|
74
49
|
return { kind: "web", identifier: normalized };
|
|
75
50
|
}
|
|
76
51
|
catch {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { KnownEvent, NostrEvent } from "applesauce-core/helpers/event";
|
|
2
|
+
export declare const EXTERNAL_IDENTITIES_KIND = 10011;
|
|
3
|
+
export declare const ExternalIdentitiesSymbol: unique symbol;
|
|
4
|
+
export type ExternalIdentitiesEvent = KnownEvent<typeof EXTERNAL_IDENTITIES_KIND>;
|
|
5
|
+
/** An external identity claimed by a NIP-39 "i" tag */
|
|
6
|
+
export type ExternalIdentity = {
|
|
7
|
+
/** The platform name (github, twitter, mastodon, telegram, bluesky, discord, etc) */
|
|
8
|
+
platform: string;
|
|
9
|
+
/** The identity on the platform */
|
|
10
|
+
identity: string;
|
|
11
|
+
/** A platform specific pointer to the proof of ownership */
|
|
12
|
+
proof: string;
|
|
13
|
+
};
|
|
14
|
+
/** Checks if an event is a NIP-39 external identities list */
|
|
15
|
+
export declare function isValidExternalIdentities(event?: NostrEvent): event is ExternalIdentitiesEvent;
|
|
16
|
+
/** Parses a NIP-39 ["i", "platform:identity", "proof"] tag */
|
|
17
|
+
export declare function getExternalIdentityFromTag(tag: string[]): ExternalIdentity | undefined;
|
|
18
|
+
/** Creates a NIP-39 "i" tag for an external identity */
|
|
19
|
+
export declare function createExternalIdentityTag(identity: ExternalIdentity): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Returns the external identities from a NIP-39 identities list
|
|
22
|
+
* @see https://github.com/nostr-protocol/nips/blob/master/39.md
|
|
23
|
+
*/
|
|
24
|
+
export declare function getExternalIdentities(event?: NostrEvent): ExternalIdentity[];
|
|
25
|
+
/**
|
|
26
|
+
* Returns the URL of the proof for an external identity, or undefined for unknown platforms
|
|
27
|
+
* @see https://github.com/nostr-protocol/nips/blob/master/39.md
|
|
28
|
+
*/
|
|
29
|
+
export declare function getExternalIdentityProofUrl({ platform, identity, proof }: ExternalIdentity): string | undefined;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
|
|
2
|
+
import { processTags } from "applesauce-core/helpers/tags";
|
|
3
|
+
export const EXTERNAL_IDENTITIES_KIND = 10011;
|
|
4
|
+
export const ExternalIdentitiesSymbol = Symbol.for("external-identities");
|
|
5
|
+
/** Checks if an event is a NIP-39 external identities list */
|
|
6
|
+
export function isValidExternalIdentities(event) {
|
|
7
|
+
return !!event && event.kind === EXTERNAL_IDENTITIES_KIND;
|
|
8
|
+
}
|
|
9
|
+
/** Parses a NIP-39 ["i", "platform:identity", "proof"] tag */
|
|
10
|
+
export function getExternalIdentityFromTag(tag) {
|
|
11
|
+
if (tag[0] !== "i" || !tag[1] || !tag[2])
|
|
12
|
+
return undefined;
|
|
13
|
+
const index = tag[1].indexOf(":");
|
|
14
|
+
if (index <= 0 || index === tag[1].length - 1)
|
|
15
|
+
return undefined;
|
|
16
|
+
return { platform: tag[1].slice(0, index), identity: tag[1].slice(index + 1), proof: tag[2] };
|
|
17
|
+
}
|
|
18
|
+
/** Creates a NIP-39 "i" tag for an external identity */
|
|
19
|
+
export function createExternalIdentityTag(identity) {
|
|
20
|
+
return ["i", `${identity.platform}:${identity.identity}`, identity.proof];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the external identities from a NIP-39 identities list
|
|
24
|
+
* @see https://github.com/nostr-protocol/nips/blob/master/39.md
|
|
25
|
+
*/
|
|
26
|
+
export function getExternalIdentities(event) {
|
|
27
|
+
if (!isValidExternalIdentities(event))
|
|
28
|
+
return [];
|
|
29
|
+
return getOrComputeCachedValue(event, ExternalIdentitiesSymbol, () => processTags(event.tags, getExternalIdentityFromTag));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the URL of the proof for an external identity, or undefined for unknown platforms
|
|
33
|
+
* @see https://github.com/nostr-protocol/nips/blob/master/39.md
|
|
34
|
+
*/
|
|
35
|
+
export function getExternalIdentityProofUrl({ platform, identity, proof }) {
|
|
36
|
+
switch (platform) {
|
|
37
|
+
case "github":
|
|
38
|
+
return `https://gist.github.com/${identity}/${proof}`;
|
|
39
|
+
case "twitter":
|
|
40
|
+
return `https://twitter.com/${identity}/status/${proof}`;
|
|
41
|
+
case "mastodon":
|
|
42
|
+
return `https://${identity}/${proof}`;
|
|
43
|
+
case "telegram":
|
|
44
|
+
return `https://t.me/${proof}`;
|
|
45
|
+
case "bluesky":
|
|
46
|
+
return `https://bsky.app/profile/${identity}/post/${proof}`;
|
|
47
|
+
case "discord":
|
|
48
|
+
return `https://discord.com/channels/${proof}`;
|
|
49
|
+
default:
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getURLPathname } from "applesauce-core/helpers/url";
|
|
1
2
|
import { getTagValue } from "applesauce-core/helpers/event";
|
|
2
3
|
import { getOrComputeCachedValue } from "applesauce-core/helpers/cache";
|
|
3
4
|
/** Type guard for a valid kind 1063 file metadata event */
|
|
@@ -85,12 +86,10 @@ export function getFileMetadata(file) {
|
|
|
85
86
|
}
|
|
86
87
|
/** Returns the last 64 length hex string in a URL */
|
|
87
88
|
export function getSha256FromURL(url) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return hashes[hashes.length - 1][0];
|
|
93
|
-
return;
|
|
89
|
+
let hash;
|
|
90
|
+
for (const match of getURLPathname(url).matchAll(/[0-9a-f]{64}/gi))
|
|
91
|
+
hash = match[0];
|
|
92
|
+
return hash;
|
|
94
93
|
}
|
|
95
94
|
/** Creates tags for {@link FileMetadataFields} */
|
|
96
95
|
export function createFileMetadataTags(attachment) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KnownEvent, NostrEvent } from "applesauce-core/helpers/event";
|
|
2
|
+
/** NIP-7D forum thread kind (11) */
|
|
3
|
+
export declare const FORUM_THREAD_KIND = 11;
|
|
4
|
+
/** Type for a validated NIP-7D forum thread event */
|
|
5
|
+
export type ForumThreadEvent = KnownEvent<typeof FORUM_THREAD_KIND>;
|
|
6
|
+
/** Returns a forum thread's title, if it has one (NIP-7D `title` tag) */
|
|
7
|
+
export declare function getForumThreadTitle(thread: ForumThreadEvent): string;
|
|
8
|
+
export declare function getForumThreadTitle(thread: NostrEvent): string | undefined;
|
|
9
|
+
/** Validates that an event is a NIP-7D forum thread (kind 11) */
|
|
10
|
+
export declare function isValidForumThread(thread: NostrEvent): thread is ForumThreadEvent;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getTagValue, kinds } from "applesauce-core/helpers/event";
|
|
2
|
+
/** NIP-7D forum thread kind (11) */
|
|
3
|
+
export const FORUM_THREAD_KIND = kinds.ForumThread;
|
|
4
|
+
export function getForumThreadTitle(thread) {
|
|
5
|
+
return getTagValue(thread, "title");
|
|
6
|
+
}
|
|
7
|
+
/** Validates that an event is a NIP-7D forum thread (kind 11) */
|
|
8
|
+
export function isValidForumThread(thread) {
|
|
9
|
+
return thread.kind === FORUM_THREAD_KIND;
|
|
10
|
+
}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { EventMemory } from "applesauce-core/event-store";
|
|
2
2
|
import { EncryptedContentSigner } from "applesauce-core/helpers/encrypted-content";
|
|
3
|
-
import { kinds, KnownEvent, NostrEvent,
|
|
3
|
+
import { kinds, KnownEvent, NostrEvent, Rumor } from "applesauce-core/helpers/event";
|
|
4
|
+
import { GiftWrapSymbol, RumorSymbol, SealSymbol } from "applesauce-core/helpers/gift-wrap";
|
|
4
5
|
/**
|
|
5
6
|
* An internal event set to keep track of seals and rumors
|
|
6
7
|
* This is intentionally isolated from the main applications event store so to prevent seals and rumors from being leaked
|
|
7
8
|
*/
|
|
8
|
-
export declare const internalGiftWrapEvents: EventMemory
|
|
9
|
-
export type Rumor
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
/** Used to store a reference to the seal event on gift wraps (downstream) or the seal event on rumors (upstream[]) */
|
|
13
|
-
export declare const SealSymbol: unique symbol;
|
|
14
|
-
/** Used to store a reference to the rumor on seals (downstream) */
|
|
15
|
-
export declare const RumorSymbol: unique symbol;
|
|
16
|
-
/** Used to store a reference to the parent gift wrap event on seals (upstream) */
|
|
17
|
-
export declare const GiftWrapSymbol: unique symbol;
|
|
9
|
+
export declare const internalGiftWrapEvents: EventMemory<NostrEvent>;
|
|
10
|
+
export type { Rumor };
|
|
11
|
+
export { GiftWrapSymbol, RumorSymbol, SealSymbol };
|
|
18
12
|
/** A gift wrap event that knows its seal event */
|
|
19
13
|
export type UnlockedGiftWrapEvent = KnownEvent<kinds.GiftWrap> & {
|
|
20
14
|
/** Downstream seal event */
|
|
@@ -29,6 +23,20 @@ export type UnlockedSeal = KnownEvent<kinds.Seal> & {
|
|
|
29
23
|
};
|
|
30
24
|
/** Checks if an event is a rumor (normal event with "id" and no "sig") */
|
|
31
25
|
export declare function isRumor(event: any): event is Rumor;
|
|
26
|
+
/**
|
|
27
|
+
* Checks that an event is a seal and that its id and signature are valid.
|
|
28
|
+
*
|
|
29
|
+
* The seal's signature is the ONLY authorship proof in a NIP-59 envelope — the gift wrap is
|
|
30
|
+
* signed by a throwaway key that says nothing about who wrote the message, and the rumor is
|
|
31
|
+
* unsigned by definition. Everything downstream that attributes a rumor to an author (notably
|
|
32
|
+
* getSealRumor's `rumor.pubkey !== seal.pubkey` binding) rests on this check having passed.
|
|
33
|
+
*
|
|
34
|
+
* Cheap to repeat: verifyWrappedEvent -> nostr-tools' verifyEvent memoises both outcomes on the
|
|
35
|
+
* event via `verifiedSymbol`, so calls after the first are a symbol read. That is what makes it
|
|
36
|
+
* affordable to re-assert this at every boundary a seal can enter through rather than trusting
|
|
37
|
+
* the caller to have checked.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isValidSeal(event: NostrEvent): event is KnownEvent<kinds.Seal>;
|
|
32
40
|
/** Returns all the parent gift wraps for a seal event */
|
|
33
41
|
export declare function getSealGiftWrap(seal: UnlockedSeal): UnlockedGiftWrapEvent;
|
|
34
42
|
export declare function getSealGiftWrap(seal: NostrEvent): UnlockedGiftWrapEvent | undefined;
|
|
@@ -36,13 +44,22 @@ export declare function getSealGiftWrap(seal: NostrEvent): UnlockedGiftWrapEvent
|
|
|
36
44
|
export declare function getRumorSeals(rumor: Rumor): UnlockedSeal[];
|
|
37
45
|
/** Returns all the parent gift wraps for a rumor event */
|
|
38
46
|
export declare function getRumorGiftWraps(rumor: Rumor): UnlockedGiftWrapEvent[];
|
|
39
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Checks if a seal event is locked and casts it to the {@link UnlockedSeal} type
|
|
49
|
+
*
|
|
50
|
+
* The presence test is only sound because getSealRumor never writes an `undefined` RumorSymbol
|
|
51
|
+
* — see the invariant documented there. If it did, this would narrow a seal that never yielded
|
|
52
|
+
* a rumor to UnlockedSeal.
|
|
53
|
+
*/
|
|
40
54
|
export declare function isSealUnlocked(seal: NostrEvent): seal is UnlockedSeal;
|
|
41
55
|
/** Returns if a gift-wrap event or gift-wrap seal is locked */
|
|
42
56
|
export declare function isGiftWrapUnlocked(gift: NostrEvent): gift is UnlockedGiftWrapEvent;
|
|
43
57
|
/**
|
|
44
58
|
* Gets the rumor from a seal event
|
|
45
|
-
*
|
|
59
|
+
*
|
|
60
|
+
* Returns undefined for any seal that does not yield a usable rumor — an invalid seal signature,
|
|
61
|
+
* unparseable content, an invalid rumor id, or a rumor whose author does not match its seal.
|
|
62
|
+
* These are things a stranger can put in your inbox, so none of them throw.
|
|
46
63
|
*/
|
|
47
64
|
export declare function getSealRumor(seal: UnlockedSeal): Rumor;
|
|
48
65
|
export declare function getSealRumor(seal: NostrEvent): Rumor | undefined;
|
|
@@ -54,12 +71,20 @@ export declare function getGiftWrapRumor(gift: UnlockedGiftWrapEvent): Rumor;
|
|
|
54
71
|
export declare function getGiftWrapRumor(gift: NostrEvent): Rumor | undefined;
|
|
55
72
|
/**
|
|
56
73
|
* Unlocks a seal event and returns the rumor event
|
|
57
|
-
*
|
|
74
|
+
*
|
|
75
|
+
* Unlike the getters, this throws rather than returning undefined: it is an imperative operation
|
|
76
|
+
* on one caller-chosen event with a non-optional return type, not a read applied across a
|
|
77
|
+
* timeline, so there is no observable for a throw to tear down.
|
|
78
|
+
* @throws {Error} If the seal does not yield a usable rumor — including an invalid seal
|
|
79
|
+
* signature, unparseable content, or a rumor whose author does not match its seal
|
|
58
80
|
*/
|
|
59
81
|
export declare function unlockSeal(seal: NostrEvent, signer: EncryptedContentSigner): Promise<Rumor>;
|
|
60
82
|
/**
|
|
61
83
|
* Unlocks and returns the unsigned seal event in a gift-wrap
|
|
62
|
-
*
|
|
84
|
+
*
|
|
85
|
+
* Throws for the same reason unlockSeal does — see the note there.
|
|
86
|
+
* @throws {Error} If the gift wrap does not yield a usable rumor — including an invalid seal
|
|
87
|
+
* signature, unparseable content, or a rumor whose author does not match its seal
|
|
63
88
|
*/
|
|
64
89
|
export declare function unlockGiftWrap(gift: NostrEvent, signer: EncryptedContentSigner): Promise<Rumor>;
|
|
65
90
|
/** Locks a gift-wrap event and seals its seal event */
|