applesauce-core 0.0.0-next-20250313135311 → 0.0.0-next-20250313145241
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.
|
@@ -3,9 +3,9 @@ import { HiddenContentSigner } from "./hidden-content.js";
|
|
|
3
3
|
export declare const GiftWrapSealSymbol: unique symbol;
|
|
4
4
|
export declare const GiftWrapEventSymbol: unique symbol;
|
|
5
5
|
/** Returns the unsigned seal event in a gift-wrap event */
|
|
6
|
-
export declare function getGiftWrapSeal(gift: NostrEvent): NostrEvent;
|
|
6
|
+
export declare function getGiftWrapSeal(gift: NostrEvent): NostrEvent | undefined;
|
|
7
7
|
/** Returns the unsigned event in the gift-wrap seal */
|
|
8
|
-
export declare function getGiftWrapEvent(gift: NostrEvent): UnsignedEvent;
|
|
8
|
+
export declare function getGiftWrapEvent(gift: NostrEvent): UnsignedEvent | undefined;
|
|
9
9
|
/** Returns if a gift-wrap event or gift-wrap seal is locked */
|
|
10
10
|
export declare function isGiftWrapLocked(gift: NostrEvent): boolean;
|
|
11
11
|
/** Unlocks and returns the unsigned seal event in a gift-wrap */
|
|
@@ -5,6 +5,8 @@ export const GiftWrapSealSymbol = Symbol.for("gift-wrap-seal");
|
|
|
5
5
|
export const GiftWrapEventSymbol = Symbol.for("gift-wrap-event");
|
|
6
6
|
/** Returns the unsigned seal event in a gift-wrap event */
|
|
7
7
|
export function getGiftWrapSeal(gift) {
|
|
8
|
+
if (isHiddenContentLocked(gift))
|
|
9
|
+
return undefined;
|
|
8
10
|
return getOrComputeCachedValue(gift, GiftWrapSealSymbol, () => {
|
|
9
11
|
const plaintext = getHiddenContent(gift);
|
|
10
12
|
if (!plaintext)
|
|
@@ -17,8 +19,12 @@ export function getGiftWrapSeal(gift) {
|
|
|
17
19
|
}
|
|
18
20
|
/** Returns the unsigned event in the gift-wrap seal */
|
|
19
21
|
export function getGiftWrapEvent(gift) {
|
|
22
|
+
if (isHiddenContentLocked(gift))
|
|
23
|
+
return undefined;
|
|
20
24
|
return getOrComputeCachedValue(gift, GiftWrapEventSymbol, () => {
|
|
21
25
|
const seal = getGiftWrapSeal(gift);
|
|
26
|
+
if (!seal)
|
|
27
|
+
throw new Error("Gift is locked");
|
|
22
28
|
const plaintext = getHiddenContent(seal);
|
|
23
29
|
if (!plaintext)
|
|
24
30
|
throw new Error("Gift-wrap seal is locked");
|