applesauce-core 1.2.0 → 2.1.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 +7 -13
- package/dist/event-store/{database.d.ts → event-set.d.ts} +36 -21
- package/dist/event-store/{database.js → event-set.js} +98 -67
- package/dist/event-store/event-store.d.ts +64 -25
- package/dist/event-store/event-store.js +164 -207
- package/dist/event-store/index.d.ts +1 -1
- package/dist/event-store/index.js +1 -1
- package/dist/event-store/interface.d.ts +71 -13
- package/dist/helpers/app-handlers.d.ts +23 -0
- package/dist/helpers/app-handlers.js +68 -0
- package/dist/helpers/article.d.ts +9 -0
- package/dist/helpers/article.js +21 -0
- package/dist/helpers/bolt11.d.ts +1 -0
- package/dist/helpers/bolt11.js +2 -0
- package/dist/helpers/bookmarks.js +1 -2
- package/dist/helpers/emoji.d.ts +10 -2
- package/dist/helpers/emoji.js +21 -3
- package/dist/helpers/encrypted-content-cache.d.ts +15 -0
- package/dist/helpers/encrypted-content-cache.js +125 -0
- package/dist/helpers/encrypted-content.d.ts +48 -0
- package/dist/helpers/encrypted-content.js +65 -0
- package/dist/helpers/encryption.d.ts +5 -0
- package/dist/helpers/encryption.js +10 -0
- package/dist/helpers/event.d.ts +5 -8
- package/dist/helpers/event.js +25 -11
- package/dist/helpers/expiration.d.ts +6 -0
- package/dist/helpers/expiration.js +16 -0
- package/dist/helpers/filter.d.ts +1 -3
- package/dist/helpers/filter.js +1 -3
- package/dist/helpers/gift-wraps.d.ts +17 -5
- package/dist/helpers/gift-wraps.js +65 -27
- package/dist/helpers/groups.d.ts +5 -0
- package/dist/helpers/groups.js +12 -2
- package/dist/helpers/hidden-content.d.ts +27 -32
- package/dist/helpers/hidden-content.js +35 -65
- package/dist/helpers/hidden-tags.d.ts +23 -4
- package/dist/helpers/hidden-tags.js +39 -4
- package/dist/helpers/index.d.ts +11 -1
- package/dist/helpers/index.js +11 -1
- package/dist/helpers/legacy-messages.d.ts +21 -0
- package/dist/helpers/legacy-messages.js +39 -0
- package/dist/helpers/lists.d.ts +3 -1
- package/dist/helpers/lists.js +9 -3
- package/dist/helpers/messages.d.ts +11 -0
- package/dist/helpers/messages.js +19 -0
- package/dist/helpers/mutes.js +1 -1
- package/dist/helpers/pointers.d.ts +33 -9
- package/dist/helpers/pointers.js +80 -44
- package/dist/helpers/profile.d.ts +10 -2
- package/dist/helpers/profile.js +33 -4
- package/dist/helpers/reactions.d.ts +8 -0
- package/dist/helpers/reactions.js +56 -0
- package/dist/helpers/reports.d.ts +28 -0
- package/dist/helpers/reports.js +38 -0
- package/dist/helpers/share.d.ts +10 -1
- package/dist/helpers/share.js +22 -8
- package/dist/helpers/url.d.ts +4 -0
- package/dist/helpers/url.js +20 -0
- package/dist/helpers/user-status.js +2 -1
- package/dist/helpers/wrapped-messages.d.ts +23 -0
- package/dist/helpers/wrapped-messages.js +38 -0
- package/dist/helpers/zap.d.ts +8 -5
- package/dist/helpers/zap.js +11 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/models/blossom.d.ts +3 -0
- package/dist/models/blossom.js +8 -0
- package/dist/models/bookmarks.d.ts +8 -0
- package/dist/{queries → models}/bookmarks.js +9 -9
- package/dist/models/channels.d.ts +11 -0
- package/dist/{queries → models}/channels.js +9 -9
- package/dist/models/comments.d.ts +4 -0
- package/dist/models/comments.js +11 -0
- package/dist/models/common.d.ts +16 -0
- package/dist/models/common.js +176 -0
- package/dist/models/contacts.d.ts +8 -0
- package/dist/{queries → models}/contacts.js +10 -10
- package/dist/models/encrypted-content.d.ts +4 -0
- package/dist/models/encrypted-content.js +11 -0
- package/dist/models/gift-wrap.d.ts +7 -0
- package/dist/models/gift-wrap.js +20 -0
- package/dist/{queries → models}/index.d.ts +6 -2
- package/dist/{queries → models}/index.js +6 -2
- package/dist/models/legacy-messages.d.ts +8 -0
- package/dist/models/legacy-messages.js +29 -0
- package/dist/models/mailboxes.d.ts +6 -0
- package/dist/{queries → models}/mailboxes.js +2 -2
- package/dist/models/mutes.d.ts +8 -0
- package/dist/{queries → models}/mutes.js +9 -9
- package/dist/models/pins.d.ts +4 -0
- package/dist/{queries → models}/pins.js +3 -3
- package/dist/models/profile.d.ts +4 -0
- package/dist/models/profile.js +14 -0
- package/dist/models/reactions.d.ts +4 -0
- package/dist/{queries → models}/reactions.js +2 -2
- package/dist/models/relays.d.ts +27 -0
- package/dist/{queries → models}/relays.js +13 -13
- package/dist/{queries → models}/thread.d.ts +6 -5
- package/dist/{queries → models}/thread.js +4 -3
- package/dist/models/user-status.d.ts +11 -0
- package/dist/{queries → models}/user-status.js +5 -5
- package/dist/models/wrapped-messages.d.ts +25 -0
- package/dist/models/wrapped-messages.js +61 -0
- package/dist/models/zaps.d.ts +9 -0
- package/dist/{queries → models}/zaps.js +11 -3
- package/dist/observable/claim-events.d.ts +3 -3
- package/dist/observable/claim-events.js +4 -4
- package/dist/observable/claim-latest.d.ts +3 -3
- package/dist/observable/claim-latest.js +4 -4
- package/dist/observable/index.d.ts +3 -1
- package/dist/observable/index.js +3 -1
- package/dist/observable/map-events-timeline.d.ts +7 -0
- package/dist/observable/map-events-timeline.js +9 -0
- package/dist/observable/map-events-to-store.d.ts +5 -0
- package/dist/observable/map-events-to-store.js +12 -0
- package/dist/observable/simple-timeout.d.ts +1 -0
- package/dist/observable/simple-timeout.js +1 -0
- package/dist/observable/watch-event-updates.d.ts +7 -0
- package/dist/observable/watch-event-updates.js +25 -0
- package/package.json +11 -16
- package/dist/__tests__/exports.test.d.ts +0 -1
- package/dist/__tests__/exports.test.js +0 -17
- package/dist/__tests__/fixtures.d.ts +0 -8
- package/dist/__tests__/fixtures.js +0 -20
- package/dist/event-store/__tests__/event-store.test.d.ts +0 -1
- package/dist/event-store/__tests__/event-store.test.js +0 -354
- package/dist/helpers/__tests__/blossom.test.d.ts +0 -1
- package/dist/helpers/__tests__/blossom.test.js +0 -13
- package/dist/helpers/__tests__/bookmarks.test.d.ts +0 -1
- package/dist/helpers/__tests__/bookmarks.test.js +0 -88
- package/dist/helpers/__tests__/comment.test.d.ts +0 -1
- package/dist/helpers/__tests__/comment.test.js +0 -249
- package/dist/helpers/__tests__/contacts.test.d.ts +0 -1
- package/dist/helpers/__tests__/contacts.test.js +0 -34
- package/dist/helpers/__tests__/emoji.test.d.ts +0 -1
- package/dist/helpers/__tests__/emoji.test.js +0 -15
- package/dist/helpers/__tests__/event.test.d.ts +0 -1
- package/dist/helpers/__tests__/event.test.js +0 -36
- package/dist/helpers/__tests__/events.test.d.ts +0 -1
- package/dist/helpers/__tests__/events.test.js +0 -32
- package/dist/helpers/__tests__/exports.test.d.ts +0 -1
- package/dist/helpers/__tests__/exports.test.js +0 -220
- package/dist/helpers/__tests__/file-metadata.test.d.ts +0 -1
- package/dist/helpers/__tests__/file-metadata.test.js +0 -103
- package/dist/helpers/__tests__/hidden-tags.test.d.ts +0 -1
- package/dist/helpers/__tests__/hidden-tags.test.js +0 -29
- package/dist/helpers/__tests__/mailboxes.test.d.ts +0 -1
- package/dist/helpers/__tests__/mailboxes.test.js +0 -81
- package/dist/helpers/__tests__/mutes.test.d.ts +0 -1
- package/dist/helpers/__tests__/mutes.test.js +0 -55
- package/dist/helpers/__tests__/nip-19.test.d.ts +0 -1
- package/dist/helpers/__tests__/nip-19.test.js +0 -42
- package/dist/helpers/__tests__/relays.test.d.ts +0 -1
- package/dist/helpers/__tests__/relays.test.js +0 -21
- package/dist/helpers/__tests__/tags.test.d.ts +0 -1
- package/dist/helpers/__tests__/tags.test.js +0 -24
- package/dist/helpers/__tests__/threading.test.d.ts +0 -1
- package/dist/helpers/__tests__/threading.test.js +0 -41
- package/dist/helpers/direct-messages.d.ts +0 -4
- package/dist/helpers/direct-messages.js +0 -5
- package/dist/helpers/nip-19.d.ts +0 -18
- package/dist/helpers/nip-19.js +0 -56
- package/dist/observable/__tests__/claim-events.test.d.ts +0 -1
- package/dist/observable/__tests__/claim-events.test.js +0 -23
- package/dist/observable/__tests__/claim-latest.test.d.ts +0 -1
- package/dist/observable/__tests__/claim-latest.test.js +0 -37
- package/dist/observable/__tests__/exports.test.d.ts +0 -1
- package/dist/observable/__tests__/exports.test.js +0 -18
- package/dist/observable/__tests__/listen-latest-updates.test.d.ts +0 -1
- package/dist/observable/__tests__/listen-latest-updates.test.js +0 -55
- package/dist/observable/__tests__/simple-timeout.test.d.ts +0 -1
- package/dist/observable/__tests__/simple-timeout.test.js +0 -34
- package/dist/observable/listen-latest-updates.d.ts +0 -5
- package/dist/observable/listen-latest-updates.js +0 -12
- package/dist/promise/__tests__/exports.test.d.ts +0 -1
- package/dist/promise/__tests__/exports.test.js +0 -11
- package/dist/queries/__tests__/exports.test.d.ts +0 -1
- package/dist/queries/__tests__/exports.test.js +0 -41
- package/dist/queries/blossom.d.ts +0 -2
- package/dist/queries/blossom.js +0 -5
- package/dist/queries/bookmarks.d.ts +0 -8
- package/dist/queries/channels.d.ts +0 -11
- package/dist/queries/comments.d.ts +0 -4
- package/dist/queries/comments.js +0 -11
- package/dist/queries/contacts.d.ts +0 -8
- package/dist/queries/mailboxes.d.ts +0 -6
- package/dist/queries/mutes.d.ts +0 -8
- package/dist/queries/pins.d.ts +0 -4
- package/dist/queries/profile.d.ts +0 -4
- package/dist/queries/profile.js +0 -7
- package/dist/queries/reactions.d.ts +0 -4
- package/dist/queries/relays.d.ts +0 -27
- package/dist/queries/simple.d.ts +0 -16
- package/dist/queries/simple.js +0 -21
- package/dist/queries/user-status.d.ts +0 -11
- package/dist/queries/zaps.d.ts +0 -5
- package/dist/query-store/__tests__/exports.test.d.ts +0 -1
- package/dist/query-store/__tests__/exports.test.js +0 -12
- package/dist/query-store/__tests__/query-store.test.d.ts +0 -1
- package/dist/query-store/__tests__/query-store.test.js +0 -63
- package/dist/query-store/index.d.ts +0 -1
- package/dist/query-store/index.js +0 -1
- package/dist/query-store/query-store.d.ts +0 -54
- package/dist/query-store/query-store.js +0 -102
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { NostrEvent, UnsignedEvent } from "nostr-tools";
|
|
2
|
-
import {
|
|
2
|
+
import { EncryptedContentSigner } from "./encrypted-content.js";
|
|
3
|
+
export type Rumor = UnsignedEvent & {
|
|
4
|
+
id: string;
|
|
5
|
+
};
|
|
3
6
|
export declare const GiftWrapSealSymbol: unique symbol;
|
|
4
|
-
export declare const
|
|
7
|
+
export declare const GiftWrapRumorSymbol: unique symbol;
|
|
5
8
|
/** Returns the unsigned seal event in a gift-wrap event */
|
|
6
9
|
export declare function getGiftWrapSeal(gift: NostrEvent): NostrEvent | undefined;
|
|
7
|
-
/**
|
|
8
|
-
export declare function
|
|
10
|
+
/** Checks if a seal event is locked */
|
|
11
|
+
export declare function isSealLocked(seal: NostrEvent): boolean;
|
|
12
|
+
/** Gets the rumor from a seal event */
|
|
13
|
+
export declare function getSealRumor(seal: NostrEvent): Rumor | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the unsigned event in the gift-wrap seal
|
|
16
|
+
* @throws {Error} If the author of the rumor event does not match the author of the seal
|
|
17
|
+
*/
|
|
18
|
+
export declare function getGiftWrapRumor(gift: NostrEvent): Rumor | undefined;
|
|
9
19
|
/** Returns if a gift-wrap event or gift-wrap seal is locked */
|
|
10
20
|
export declare function isGiftWrapLocked(gift: NostrEvent): boolean;
|
|
11
21
|
/** Unlocks and returns the unsigned seal event in a gift-wrap */
|
|
12
|
-
export declare function unlockGiftWrap(gift: NostrEvent, signer:
|
|
22
|
+
export declare function unlockGiftWrap(gift: NostrEvent, signer: EncryptedContentSigner): Promise<UnsignedEvent>;
|
|
23
|
+
/** Locks a gift-wrap event by removing its cached seal and encrypted content */
|
|
24
|
+
export declare function lockGiftWrap(gift: NostrEvent): void;
|
|
@@ -1,49 +1,87 @@
|
|
|
1
1
|
import { verifyEvent } from "nostr-tools";
|
|
2
|
-
import { getHiddenContent, isHiddenContentLocked, unlockHiddenContent } from "./hidden-content.js";
|
|
3
2
|
import { getOrComputeCachedValue } from "./cache.js";
|
|
3
|
+
import { getEncryptedContent, isEncryptedContentLocked, lockEncryptedContent, unlockEncryptedContent, } from "./encrypted-content.js";
|
|
4
|
+
import { isEvent, notifyEventUpdate } from "./event.js";
|
|
4
5
|
export const GiftWrapSealSymbol = Symbol.for("gift-wrap-seal");
|
|
5
|
-
export const
|
|
6
|
+
export const GiftWrapRumorSymbol = Symbol.for("gift-wrap-rumor");
|
|
6
7
|
/** Returns the unsigned seal event in a gift-wrap event */
|
|
7
8
|
export function getGiftWrapSeal(gift) {
|
|
8
|
-
if (
|
|
9
|
+
if (isEncryptedContentLocked(gift))
|
|
10
|
+
return undefined;
|
|
11
|
+
const plaintext = getEncryptedContent(gift);
|
|
12
|
+
if (!plaintext)
|
|
9
13
|
return undefined;
|
|
10
14
|
return getOrComputeCachedValue(gift, GiftWrapSealSymbol, () => {
|
|
11
|
-
const plaintext = getHiddenContent(gift);
|
|
12
|
-
if (!plaintext)
|
|
13
|
-
throw new Error("Gift-wrap is locked");
|
|
14
15
|
const seal = JSON.parse(plaintext);
|
|
15
|
-
// verify the seal is valid
|
|
16
16
|
verifyEvent(seal);
|
|
17
17
|
return seal;
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
export function
|
|
22
|
-
|
|
20
|
+
/** Checks if a seal event is locked */
|
|
21
|
+
export function isSealLocked(seal) {
|
|
22
|
+
return isEncryptedContentLocked(seal);
|
|
23
|
+
}
|
|
24
|
+
/** Gets the rumor from a seal event */
|
|
25
|
+
export function getSealRumor(seal) {
|
|
26
|
+
if (isEncryptedContentLocked(seal))
|
|
23
27
|
return undefined;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
throw new Error("
|
|
31
|
-
|
|
32
|
-
if (event.pubkey !== seal.pubkey)
|
|
33
|
-
throw new Error("Seal author does not match content");
|
|
34
|
-
return event;
|
|
28
|
+
const plaintext = getEncryptedContent(seal);
|
|
29
|
+
if (!plaintext)
|
|
30
|
+
return undefined;
|
|
31
|
+
return getOrComputeCachedValue(seal, GiftWrapRumorSymbol, () => {
|
|
32
|
+
const rumor = JSON.parse(plaintext);
|
|
33
|
+
if (rumor.pubkey !== seal.pubkey)
|
|
34
|
+
throw new Error("Seal author does not match rumor author");
|
|
35
|
+
return rumor;
|
|
35
36
|
});
|
|
36
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the unsigned event in the gift-wrap seal
|
|
40
|
+
* @throws {Error} If the author of the rumor event does not match the author of the seal
|
|
41
|
+
*/
|
|
42
|
+
export function getGiftWrapRumor(gift) {
|
|
43
|
+
if (isEncryptedContentLocked(gift))
|
|
44
|
+
return undefined;
|
|
45
|
+
const seal = getGiftWrapSeal(gift);
|
|
46
|
+
if (!seal || isSealLocked(seal))
|
|
47
|
+
return undefined;
|
|
48
|
+
return getOrComputeCachedValue(gift, GiftWrapRumorSymbol, () => getSealRumor(seal));
|
|
49
|
+
}
|
|
37
50
|
/** Returns if a gift-wrap event or gift-wrap seal is locked */
|
|
38
51
|
export function isGiftWrapLocked(gift) {
|
|
39
|
-
|
|
52
|
+
if (isEncryptedContentLocked(gift))
|
|
53
|
+
return true;
|
|
54
|
+
else {
|
|
55
|
+
const seal = getGiftWrapSeal(gift);
|
|
56
|
+
if (!seal || isEncryptedContentLocked(seal))
|
|
57
|
+
return true;
|
|
58
|
+
else
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
40
61
|
}
|
|
41
62
|
/** Unlocks and returns the unsigned seal event in a gift-wrap */
|
|
42
63
|
export async function unlockGiftWrap(gift, signer) {
|
|
43
|
-
|
|
44
|
-
|
|
64
|
+
// First unlock the gift-wrap event
|
|
65
|
+
if (isEncryptedContentLocked(gift))
|
|
66
|
+
await unlockEncryptedContent(gift, gift.pubkey, signer);
|
|
67
|
+
// Next get and unlock the seal
|
|
45
68
|
const seal = getGiftWrapSeal(gift);
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
69
|
+
if (!seal)
|
|
70
|
+
throw new Error("Failed to read seal in gift wrap");
|
|
71
|
+
if (isEncryptedContentLocked(seal))
|
|
72
|
+
await unlockEncryptedContent(seal, seal.pubkey, signer);
|
|
73
|
+
// Finally get the rumor event
|
|
74
|
+
const rumor = getGiftWrapRumor(gift);
|
|
75
|
+
if (!rumor)
|
|
76
|
+
throw new Error("Failed to read rumor in gift wrap");
|
|
77
|
+
// if the event has been added to an event store, notify it
|
|
78
|
+
if (isEvent(gift))
|
|
79
|
+
notifyEventUpdate(gift);
|
|
80
|
+
return rumor;
|
|
81
|
+
}
|
|
82
|
+
/** Locks a gift-wrap event by removing its cached seal and encrypted content */
|
|
83
|
+
export function lockGiftWrap(gift) {
|
|
84
|
+
Reflect.deleteProperty(gift, GiftWrapSealSymbol);
|
|
85
|
+
Reflect.deleteProperty(gift, GiftWrapRumorSymbol);
|
|
86
|
+
lockEncryptedContent(gift);
|
|
49
87
|
}
|
package/dist/helpers/groups.d.ts
CHANGED
|
@@ -3,8 +3,11 @@ export declare const GROUPS_LIST_KIND = 10009;
|
|
|
3
3
|
export declare const GROUP_MESSAGE_KIND = 9;
|
|
4
4
|
/** NIP-29 group pointer */
|
|
5
5
|
export type GroupPointer = {
|
|
6
|
+
/** the id of the group */
|
|
6
7
|
id: string;
|
|
8
|
+
/** The url to the relay with wss:// or ws:// protocol */
|
|
7
9
|
relay: string;
|
|
10
|
+
/** The name of the group */
|
|
8
11
|
name?: string;
|
|
9
12
|
};
|
|
10
13
|
/**
|
|
@@ -16,6 +19,8 @@ export declare function decodeGroupPointer(str: string): GroupPointer;
|
|
|
16
19
|
export declare function encodeGroupPointer(pointer: GroupPointer): string;
|
|
17
20
|
export declare const GroupsPublicSymbol: unique symbol;
|
|
18
21
|
export declare const GroupsHiddenSymbol: unique symbol;
|
|
22
|
+
/** gets a {@link GroupPointer} from a "h" tag if it has a relay hint */
|
|
23
|
+
export declare function getGroupPointerFromHTag(tag: string[]): GroupPointer | undefined;
|
|
19
24
|
/** gets a {@link GroupPointer} from a "group" tag */
|
|
20
25
|
export declare function getGroupPointerFromGroupTag(tag: string[]): GroupPointer;
|
|
21
26
|
/** Returns all the public groups from a k:10009 list */
|
package/dist/helpers/groups.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getOrComputeCachedValue } from "./cache.js";
|
|
2
|
-
import { processTags } from "./tags.js";
|
|
3
2
|
import { getHiddenTags } from "./hidden-tags.js";
|
|
3
|
+
import { processTags } from "./tags.js";
|
|
4
4
|
export const GROUPS_LIST_KIND = 10009;
|
|
5
5
|
export const GROUP_MESSAGE_KIND = 9;
|
|
6
6
|
/**
|
|
@@ -8,9 +8,12 @@ export const GROUP_MESSAGE_KIND = 9;
|
|
|
8
8
|
* @throws
|
|
9
9
|
*/
|
|
10
10
|
export function decodeGroupPointer(str) {
|
|
11
|
-
|
|
11
|
+
let [relay, id] = str.split("'");
|
|
12
12
|
if (!relay)
|
|
13
13
|
throw new Error("Group pointer missing relay");
|
|
14
|
+
// Prepend wss:// if missing
|
|
15
|
+
if (!relay.match(/^wss?:/))
|
|
16
|
+
relay = `wss://${relay}`;
|
|
14
17
|
return { relay, id: id || "_" };
|
|
15
18
|
}
|
|
16
19
|
/** Converts a group pointer into a group identifier */
|
|
@@ -20,6 +23,13 @@ export function encodeGroupPointer(pointer) {
|
|
|
20
23
|
}
|
|
21
24
|
export const GroupsPublicSymbol = Symbol.for("groups-public");
|
|
22
25
|
export const GroupsHiddenSymbol = Symbol.for("groups-hidden");
|
|
26
|
+
/** gets a {@link GroupPointer} from a "h" tag if it has a relay hint */
|
|
27
|
+
export function getGroupPointerFromHTag(tag) {
|
|
28
|
+
const [_, id, relay] = tag;
|
|
29
|
+
if (!id || !relay)
|
|
30
|
+
return undefined;
|
|
31
|
+
return { id, relay };
|
|
32
|
+
}
|
|
23
33
|
/** gets a {@link GroupPointer} from a "group" tag */
|
|
24
34
|
export function getGroupPointerFromGroupTag(tag) {
|
|
25
35
|
const [_, id, relay, name] = tag;
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
/** Various event kinds that can have encrypted tags in their content and which encryption method they use */
|
|
13
|
-
export declare const EventContentEncryptionMethod: Record<number, "nip04" | "nip44">;
|
|
14
|
-
/** Sets the encryption method that is used for the contents of a specific event kind */
|
|
15
|
-
export declare function setEventContentEncryptionMethod(kind: number, method: "nip04" | "nip44"): void;
|
|
1
|
+
import { EncryptedContentSigner, getEncryptedContentEncryptionMethods } from "./encrypted-content.js";
|
|
2
|
+
export declare const HiddenContentSymbol: symbol;
|
|
3
|
+
export interface HiddenContentSigner extends EncryptedContentSigner {
|
|
4
|
+
}
|
|
5
|
+
export declare const getHiddenContentEncryptionMethods: typeof getEncryptedContentEncryptionMethods;
|
|
6
|
+
/** Various event kinds that can have hidden content */
|
|
7
|
+
export declare const HiddenContentKinds: Set<number>;
|
|
8
|
+
/** Sets the encryption method for hidden content on a kind */
|
|
9
|
+
export declare function setHiddenContentEncryptionMethod(kind: number, method: "nip04" | "nip44"): number;
|
|
16
10
|
/** Checks if an event can have hidden content */
|
|
17
11
|
export declare function canHaveHiddenContent(kind: number): boolean;
|
|
18
12
|
/** Checks if an event has hidden content */
|
|
@@ -20,29 +14,30 @@ export declare function hasHiddenContent<T extends {
|
|
|
20
14
|
kind: number;
|
|
21
15
|
content: string;
|
|
22
16
|
}>(event: T): boolean;
|
|
23
|
-
/**
|
|
24
|
-
export declare function getHiddenContent<T extends object>(event: T): string | undefined;
|
|
25
|
-
/** Checks if the hidden tags are locked */
|
|
17
|
+
/** Checks if the hidden content is locked */
|
|
26
18
|
export declare function isHiddenContentLocked<T extends object>(event: T): boolean;
|
|
27
|
-
/** Returns
|
|
28
|
-
export declare function
|
|
29
|
-
encrypt: (pubkey: string, plaintext: string) => Promise<string> | string;
|
|
30
|
-
decrypt: (pubkey: string, ciphertext: string) => Promise<string> | string;
|
|
31
|
-
} | {
|
|
32
|
-
encrypt: (pubkey: string, plaintext: string) => Promise<string> | string;
|
|
33
|
-
decrypt: (pubkey: string, ciphertext: string) => Promise<string> | string;
|
|
34
|
-
};
|
|
35
|
-
export type HiddenContentEvent = {
|
|
19
|
+
/** Returns the hidden content for an event if they are unlocked */
|
|
20
|
+
export declare function getHiddenContent<T extends {
|
|
36
21
|
kind: number;
|
|
37
|
-
pubkey: string;
|
|
38
22
|
content: string;
|
|
39
|
-
};
|
|
23
|
+
}>(event: T): string | undefined;
|
|
40
24
|
/**
|
|
41
|
-
* Unlocks the
|
|
25
|
+
* Unlocks the hidden content in the event
|
|
42
26
|
* @param event The event with content to decrypt
|
|
43
|
-
* @param signer A signer to use to decrypt the
|
|
27
|
+
* @param signer A signer to use to decrypt the content
|
|
28
|
+
* @throws
|
|
29
|
+
*/
|
|
30
|
+
export declare function unlockHiddenContent<T extends {
|
|
31
|
+
kind: number;
|
|
32
|
+
pubkey: string;
|
|
33
|
+
content: string;
|
|
34
|
+
}>(event: T, signer: EncryptedContentSigner): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Sets the hidden content on an event and updates it if its part of an event store
|
|
44
37
|
* @throws
|
|
45
38
|
*/
|
|
46
|
-
export declare function
|
|
39
|
+
export declare function setHiddenContentCache<T extends {
|
|
40
|
+
kind: number;
|
|
41
|
+
}>(event: T, plaintext: string): void;
|
|
47
42
|
/** Removes the unencrypted hidden content on an event */
|
|
48
43
|
export declare function lockHiddenContent<T extends object>(event: T): void;
|
|
@@ -1,88 +1,58 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export const HiddenContentSymbol =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// DMs
|
|
13
|
-
[kinds.EncryptedDirectMessage]: "nip04",
|
|
14
|
-
// Gift wraps
|
|
15
|
-
[kinds.GiftWrap]: "nip44",
|
|
16
|
-
// NIP-51 lists
|
|
17
|
-
[kinds.BookmarkList]: "nip04",
|
|
18
|
-
[kinds.InterestsList]: "nip04",
|
|
19
|
-
[kinds.Mutelist]: "nip04",
|
|
20
|
-
[kinds.CommunitiesList]: "nip04",
|
|
21
|
-
[kinds.PublicChatsList]: "nip04",
|
|
22
|
-
[kinds.SearchRelaysList]: "nip04",
|
|
23
|
-
[GROUPS_LIST_KIND]: "nip04",
|
|
24
|
-
// NIP-51 sets
|
|
25
|
-
[kinds.Bookmarksets]: "nip04",
|
|
26
|
-
[kinds.Relaysets]: "nip04",
|
|
27
|
-
[kinds.Followsets]: "nip04",
|
|
28
|
-
[kinds.Curationsets]: "nip04",
|
|
29
|
-
[kinds.Interestsets]: "nip04",
|
|
30
|
-
};
|
|
31
|
-
/** Sets the encryption method that is used for the contents of a specific event kind */
|
|
32
|
-
export function setEventContentEncryptionMethod(kind, method) {
|
|
33
|
-
EventContentEncryptionMethod[kind] = method;
|
|
1
|
+
import { kinds } from "nostr-tools";
|
|
2
|
+
import { canHaveEncryptedContent, EncryptedContentSymbol, getEncryptedContent, getEncryptedContentEncryptionMethods, hasEncryptedContent, isEncryptedContentLocked, lockEncryptedContent, setEncryptedContentCache, setEncryptedContentEncryptionMethod, } from "./encrypted-content.js";
|
|
3
|
+
// reexport from encrypted-content
|
|
4
|
+
export const HiddenContentSymbol = EncryptedContentSymbol;
|
|
5
|
+
export const getHiddenContentEncryptionMethods = getEncryptedContentEncryptionMethods;
|
|
6
|
+
/** Various event kinds that can have hidden content */
|
|
7
|
+
export const HiddenContentKinds = new Set([setEncryptedContentEncryptionMethod(kinds.DraftLong, "nip04")]);
|
|
8
|
+
/** Sets the encryption method for hidden content on a kind */
|
|
9
|
+
export function setHiddenContentEncryptionMethod(kind, method) {
|
|
10
|
+
HiddenContentKinds.add(setEncryptedContentEncryptionMethod(kind, method));
|
|
11
|
+
return kind;
|
|
34
12
|
}
|
|
35
13
|
/** Checks if an event can have hidden content */
|
|
36
14
|
export function canHaveHiddenContent(kind) {
|
|
37
|
-
return
|
|
15
|
+
return canHaveEncryptedContent(kind) && HiddenContentKinds.has(kind);
|
|
38
16
|
}
|
|
39
17
|
/** Checks if an event has hidden content */
|
|
40
18
|
export function hasHiddenContent(event) {
|
|
41
|
-
return canHaveHiddenContent(event.kind) && event
|
|
19
|
+
return canHaveHiddenContent(event.kind) && hasEncryptedContent(event);
|
|
42
20
|
}
|
|
43
|
-
/**
|
|
44
|
-
export function getHiddenContent(event) {
|
|
45
|
-
return Reflect.get(event, HiddenContentSymbol);
|
|
46
|
-
}
|
|
47
|
-
/** Checks if the hidden tags are locked */
|
|
21
|
+
/** Checks if the hidden content is locked */
|
|
48
22
|
export function isHiddenContentLocked(event) {
|
|
49
|
-
return
|
|
23
|
+
return isEncryptedContentLocked(event);
|
|
50
24
|
}
|
|
51
|
-
/** Returns
|
|
52
|
-
export function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
throw new Error(`Signer does not support ${method} encryption`);
|
|
57
|
-
return encryption;
|
|
25
|
+
/** Returns the hidden content for an event if they are unlocked */
|
|
26
|
+
export function getHiddenContent(event) {
|
|
27
|
+
if (!canHaveHiddenContent(event.kind) || isHiddenContentLocked(event))
|
|
28
|
+
return undefined;
|
|
29
|
+
return getEncryptedContent(event);
|
|
58
30
|
}
|
|
59
31
|
/**
|
|
60
|
-
* Unlocks the
|
|
32
|
+
* Unlocks the hidden content in the event
|
|
61
33
|
* @param event The event with content to decrypt
|
|
62
|
-
* @param signer A signer to use to decrypt the
|
|
34
|
+
* @param signer A signer to use to decrypt the content
|
|
63
35
|
* @throws
|
|
64
36
|
*/
|
|
65
37
|
export async function unlockHiddenContent(event, signer) {
|
|
66
38
|
if (!canHaveHiddenContent(event.kind))
|
|
67
39
|
throw new Error("Event kind does not support hidden content");
|
|
68
|
-
const encryption =
|
|
40
|
+
const encryption = getEncryptedContentEncryptionMethods(event.kind, signer);
|
|
69
41
|
const plaintext = await encryption.decrypt(event.pubkey, event.content);
|
|
70
|
-
|
|
71
|
-
// if the event has been added to an event store, notify it
|
|
72
|
-
if (isEvent(event)) {
|
|
73
|
-
const eventStore = getParentEventStore(event);
|
|
74
|
-
if (eventStore)
|
|
75
|
-
eventStore.update(event);
|
|
76
|
-
}
|
|
42
|
+
setHiddenContentCache(event, plaintext);
|
|
77
43
|
return plaintext;
|
|
78
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Sets the hidden content on an event and updates it if its part of an event store
|
|
47
|
+
* @throws
|
|
48
|
+
*/
|
|
49
|
+
export function setHiddenContentCache(event, plaintext) {
|
|
50
|
+
if (!canHaveHiddenContent(event.kind))
|
|
51
|
+
throw new Error("Event kind does not support hidden content");
|
|
52
|
+
// Set the encrypted content
|
|
53
|
+
setEncryptedContentCache(event, plaintext);
|
|
54
|
+
}
|
|
79
55
|
/** Removes the unencrypted hidden content on an event */
|
|
80
56
|
export function lockHiddenContent(event) {
|
|
81
|
-
|
|
82
|
-
// if the event has been added to an event store, notify it
|
|
83
|
-
if (isEvent(event)) {
|
|
84
|
-
const eventStore = getParentEventStore(event);
|
|
85
|
-
if (eventStore)
|
|
86
|
-
eventStore.update(event);
|
|
87
|
-
}
|
|
57
|
+
lockEncryptedContent(event);
|
|
88
58
|
}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HiddenContentSigner } from "./hidden-content.js";
|
|
2
2
|
export declare const HiddenTagsSymbol: unique symbol;
|
|
3
|
+
/** Various event kinds that can have hidden tags */
|
|
4
|
+
export declare const HiddenTagsKinds: Set<number>;
|
|
3
5
|
/** Checks if an event can have hidden tags */
|
|
4
6
|
export declare function canHaveHiddenTags(kind: number): boolean;
|
|
7
|
+
/** Sets the type of encryption to use for hidden tags on a kind */
|
|
8
|
+
export declare function setHiddenTagsEncryptionMethod(kind: number, method: "nip04" | "nip44"): number;
|
|
5
9
|
/** Checks if an event has hidden tags */
|
|
6
10
|
export declare function hasHiddenTags<T extends {
|
|
7
|
-
content: string;
|
|
8
11
|
kind: number;
|
|
12
|
+
content: string;
|
|
9
13
|
}>(event: T): boolean;
|
|
10
14
|
/** Returns the hidden tags for an event if they are unlocked */
|
|
11
|
-
export declare function getHiddenTags<T extends
|
|
15
|
+
export declare function getHiddenTags<T extends {
|
|
16
|
+
kind: number;
|
|
17
|
+
content: string;
|
|
18
|
+
}>(event: T): string[][] | undefined;
|
|
12
19
|
/** Checks if the hidden tags are locked */
|
|
13
20
|
export declare function isHiddenTagsLocked<T extends object>(event: T): boolean;
|
|
14
21
|
/** Returns either nip04 or nip44 encryption method depending on list kind */
|
|
@@ -26,5 +33,17 @@ export declare function getHiddenTagsEncryptionMethods(kind: number, signer: Hid
|
|
|
26
33
|
* @param store An optional EventStore to notify about the update
|
|
27
34
|
* @throws
|
|
28
35
|
*/
|
|
29
|
-
export declare function unlockHiddenTags<T extends
|
|
36
|
+
export declare function unlockHiddenTags<T extends {
|
|
37
|
+
kind: number;
|
|
38
|
+
pubkey: string;
|
|
39
|
+
content: string;
|
|
40
|
+
}>(event: T, signer: HiddenContentSigner): Promise<string[][]>;
|
|
41
|
+
/**
|
|
42
|
+
* Sets the hidden tags on an event and updates it if its part of an event store
|
|
43
|
+
* @throws
|
|
44
|
+
*/
|
|
45
|
+
export declare function setHiddenTagsCache<T extends {
|
|
46
|
+
kind: number;
|
|
47
|
+
}>(event: T, tags: string[][]): void;
|
|
48
|
+
/** Clears the cached hidden tags on an event */
|
|
30
49
|
export declare function lockHiddenTags<T extends object>(event: T): void;
|
|
@@ -1,17 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { kinds } from "nostr-tools";
|
|
2
2
|
import { getOrComputeCachedValue } from "./cache.js";
|
|
3
|
+
import { canHaveHiddenContent, getHiddenContent, getHiddenContentEncryptionMethods, hasHiddenContent, isHiddenContentLocked, lockHiddenContent, setHiddenContentCache, setHiddenContentEncryptionMethod, unlockHiddenContent, } from "./hidden-content.js";
|
|
4
|
+
import { GROUPS_LIST_KIND } from "./groups.js";
|
|
3
5
|
export const HiddenTagsSymbol = Symbol.for("hidden-tags");
|
|
6
|
+
/** Various event kinds that can have hidden tags */
|
|
7
|
+
export const HiddenTagsKinds = new Set([
|
|
8
|
+
// NIP-51 lists
|
|
9
|
+
setHiddenContentEncryptionMethod(kinds.BookmarkList, "nip04"),
|
|
10
|
+
setHiddenContentEncryptionMethod(kinds.InterestsList, "nip04"),
|
|
11
|
+
setHiddenContentEncryptionMethod(kinds.Mutelist, "nip04"),
|
|
12
|
+
setHiddenContentEncryptionMethod(kinds.CommunitiesList, "nip04"),
|
|
13
|
+
setHiddenContentEncryptionMethod(kinds.PublicChatsList, "nip04"),
|
|
14
|
+
setHiddenContentEncryptionMethod(kinds.SearchRelaysList, "nip04"),
|
|
15
|
+
setHiddenContentEncryptionMethod(GROUPS_LIST_KIND, "nip04"),
|
|
16
|
+
// NIP-51 sets
|
|
17
|
+
setHiddenContentEncryptionMethod(kinds.Bookmarksets, "nip04"),
|
|
18
|
+
setHiddenContentEncryptionMethod(kinds.Relaysets, "nip04"),
|
|
19
|
+
setHiddenContentEncryptionMethod(kinds.Followsets, "nip04"),
|
|
20
|
+
setHiddenContentEncryptionMethod(kinds.Curationsets, "nip04"),
|
|
21
|
+
setHiddenContentEncryptionMethod(kinds.Interestsets, "nip04"),
|
|
22
|
+
]);
|
|
4
23
|
/** Checks if an event can have hidden tags */
|
|
5
24
|
export function canHaveHiddenTags(kind) {
|
|
6
|
-
return canHaveHiddenContent(kind);
|
|
25
|
+
return canHaveHiddenContent(kind) && HiddenTagsKinds.has(kind);
|
|
26
|
+
}
|
|
27
|
+
/** Sets the type of encryption to use for hidden tags on a kind */
|
|
28
|
+
export function setHiddenTagsEncryptionMethod(kind, method) {
|
|
29
|
+
HiddenTagsKinds.add(setHiddenContentEncryptionMethod(kind, method));
|
|
30
|
+
return kind;
|
|
7
31
|
}
|
|
8
32
|
/** Checks if an event has hidden tags */
|
|
9
33
|
export function hasHiddenTags(event) {
|
|
10
|
-
return canHaveHiddenTags(event.kind) && event
|
|
34
|
+
return canHaveHiddenTags(event.kind) && hasHiddenContent(event);
|
|
11
35
|
}
|
|
12
36
|
/** Returns the hidden tags for an event if they are unlocked */
|
|
13
37
|
export function getHiddenTags(event) {
|
|
14
|
-
if (isHiddenTagsLocked(event))
|
|
38
|
+
if (!canHaveHiddenTags(event.kind) || isHiddenTagsLocked(event))
|
|
15
39
|
return undefined;
|
|
16
40
|
return getOrComputeCachedValue(event, HiddenTagsSymbol, () => {
|
|
17
41
|
const plaintext = getHiddenContent(event);
|
|
@@ -45,6 +69,17 @@ export async function unlockHiddenTags(event, signer) {
|
|
|
45
69
|
await unlockHiddenContent(event, signer);
|
|
46
70
|
return getHiddenTags(event);
|
|
47
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Sets the hidden tags on an event and updates it if its part of an event store
|
|
74
|
+
* @throws
|
|
75
|
+
*/
|
|
76
|
+
export function setHiddenTagsCache(event, tags) {
|
|
77
|
+
if (!canHaveHiddenTags(event.kind))
|
|
78
|
+
throw new Error("Event kind does not support hidden tags");
|
|
79
|
+
const plaintext = JSON.stringify(tags);
|
|
80
|
+
setHiddenContentCache(event, plaintext);
|
|
81
|
+
}
|
|
82
|
+
/** Clears the cached hidden tags on an event */
|
|
48
83
|
export function lockHiddenTags(event) {
|
|
49
84
|
Reflect.deleteProperty(event, HiddenTagsSymbol);
|
|
50
85
|
lockHiddenContent(event);
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export * from "./app-handlers.js";
|
|
2
|
+
export * from "./article.js";
|
|
1
3
|
export * from "./blossom.js";
|
|
2
4
|
export * from "./bolt11.js";
|
|
3
5
|
export * from "./bookmarks.js";
|
|
@@ -7,10 +9,13 @@ export * from "./comment.js";
|
|
|
7
9
|
export * from "./contacts.js";
|
|
8
10
|
export * from "./content.js";
|
|
9
11
|
export * from "./delete.js";
|
|
10
|
-
export * from "./direct-messages.js";
|
|
11
12
|
export * from "./dns-identity.js";
|
|
12
13
|
export * from "./emoji.js";
|
|
14
|
+
export * from "./encrypted-content-cache.js";
|
|
15
|
+
export * from "./encrypted-content.js";
|
|
16
|
+
export * from "./encryption.js";
|
|
13
17
|
export * from "./event.js";
|
|
18
|
+
export * from "./expiration.js";
|
|
14
19
|
export * from "./external-id.js";
|
|
15
20
|
export * from "./file-metadata.js";
|
|
16
21
|
export * from "./filter.js";
|
|
@@ -20,15 +25,19 @@ export * from "./hashtag.js";
|
|
|
20
25
|
export * from "./hidden-content.js";
|
|
21
26
|
export * from "./hidden-tags.js";
|
|
22
27
|
export * from "./json.js";
|
|
28
|
+
export * from "./legacy-messages.js";
|
|
23
29
|
export * from "./lists.js";
|
|
24
30
|
export * from "./lnurl.js";
|
|
25
31
|
export * from "./lru.js";
|
|
26
32
|
export * from "./mailboxes.js";
|
|
33
|
+
export * from "./messages.js";
|
|
27
34
|
export * from "./mutes.js";
|
|
28
35
|
export * from "./picture-post.js";
|
|
29
36
|
export * from "./pointers.js";
|
|
30
37
|
export * from "./profile.js";
|
|
38
|
+
export * from "./reactions.js";
|
|
31
39
|
export * from "./relays.js";
|
|
40
|
+
export * from "./reports.js";
|
|
32
41
|
export * from "./share.js";
|
|
33
42
|
export * from "./string.js";
|
|
34
43
|
export * from "./tags.js";
|
|
@@ -36,4 +45,5 @@ export * from "./threading.js";
|
|
|
36
45
|
export * from "./time.js";
|
|
37
46
|
export * from "./url.js";
|
|
38
47
|
export * from "./user-status.js";
|
|
48
|
+
export * from "./wrapped-messages.js";
|
|
39
49
|
export * from "./zap.js";
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export * from "./app-handlers.js";
|
|
2
|
+
export * from "./article.js";
|
|
1
3
|
export * from "./blossom.js";
|
|
2
4
|
export * from "./bolt11.js";
|
|
3
5
|
export * from "./bookmarks.js";
|
|
@@ -7,10 +9,13 @@ export * from "./comment.js";
|
|
|
7
9
|
export * from "./contacts.js";
|
|
8
10
|
export * from "./content.js";
|
|
9
11
|
export * from "./delete.js";
|
|
10
|
-
export * from "./direct-messages.js";
|
|
11
12
|
export * from "./dns-identity.js";
|
|
12
13
|
export * from "./emoji.js";
|
|
14
|
+
export * from "./encrypted-content-cache.js";
|
|
15
|
+
export * from "./encrypted-content.js";
|
|
16
|
+
export * from "./encryption.js";
|
|
13
17
|
export * from "./event.js";
|
|
18
|
+
export * from "./expiration.js";
|
|
14
19
|
export * from "./external-id.js";
|
|
15
20
|
export * from "./file-metadata.js";
|
|
16
21
|
export * from "./filter.js";
|
|
@@ -20,15 +25,19 @@ export * from "./hashtag.js";
|
|
|
20
25
|
export * from "./hidden-content.js";
|
|
21
26
|
export * from "./hidden-tags.js";
|
|
22
27
|
export * from "./json.js";
|
|
28
|
+
export * from "./legacy-messages.js";
|
|
23
29
|
export * from "./lists.js";
|
|
24
30
|
export * from "./lnurl.js";
|
|
25
31
|
export * from "./lru.js";
|
|
26
32
|
export * from "./mailboxes.js";
|
|
33
|
+
export * from "./messages.js";
|
|
27
34
|
export * from "./mutes.js";
|
|
28
35
|
export * from "./picture-post.js";
|
|
29
36
|
export * from "./pointers.js";
|
|
30
37
|
export * from "./profile.js";
|
|
38
|
+
export * from "./reactions.js";
|
|
31
39
|
export * from "./relays.js";
|
|
40
|
+
export * from "./reports.js";
|
|
32
41
|
export * from "./share.js";
|
|
33
42
|
export * from "./string.js";
|
|
34
43
|
export * from "./tags.js";
|
|
@@ -36,4 +45,5 @@ export * from "./threading.js";
|
|
|
36
45
|
export * from "./time.js";
|
|
37
46
|
export * from "./url.js";
|
|
38
47
|
export * from "./user-status.js";
|
|
48
|
+
export * from "./wrapped-messages.js";
|
|
39
49
|
export * from "./zap.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NostrEvent } from "nostr-tools";
|
|
2
|
+
import { EncryptedContentSigner } from "./encrypted-content.js";
|
|
3
|
+
/** Checks if a legacy direct message content is encrypted */
|
|
4
|
+
export declare function isLegacyMessageLocked(event: NostrEvent): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Returns the corraspondant of a legacy direct message
|
|
7
|
+
* @throws if no corraspondant is found
|
|
8
|
+
*/
|
|
9
|
+
export declare function getLegacyMessageCorraspondant(message: NostrEvent, self: string): string;
|
|
10
|
+
/** Returns the parent message id of a legacy message */
|
|
11
|
+
export declare function getLegacyMessageParent(message: NostrEvent): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the decrypted content of a direct message
|
|
14
|
+
* @param message - The message to decrypt
|
|
15
|
+
* @param self - The public key of the user
|
|
16
|
+
* @param signer - The signer to use to decrypt the message
|
|
17
|
+
* @returns The decrypted content of the message
|
|
18
|
+
*/
|
|
19
|
+
export declare function unlockLegacyMessage(message: NostrEvent, self: string, signer: EncryptedContentSigner): Promise<string>;
|
|
20
|
+
/** Clears the cached plaintext of a direct message */
|
|
21
|
+
export declare function lockLegacyMessage(message: NostrEvent): Promise<void>;
|