applesauce-wallet 0.0.0-next-20250313155042 → 0.0.0-next-20250313225050

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.
@@ -23,3 +23,4 @@ export declare function isHistoryContentLocked(history: NostrEvent): boolean;
23
23
  export declare function getHistoryContent(history: NostrEvent): HistoryContent | undefined;
24
24
  /** Decrypts a wallet history event */
25
25
  export declare function unlockHistoryContent(history: NostrEvent, signer: HiddenContentSigner): Promise<HistoryContent>;
26
+ export declare function lockHistoryContent(history: NostrEvent): void;
@@ -1,4 +1,4 @@
1
- import { getHiddenTags, getOrComputeCachedValue, isETag, isHiddenContentLocked, isHiddenTagsLocked, unlockHiddenTags, } from "applesauce-core/helpers";
1
+ import { getHiddenTags, getOrComputeCachedValue, isETag, isHiddenContentLocked, isHiddenTagsLocked, lockHiddenTags, unlockHiddenTags, } from "applesauce-core/helpers";
2
2
  export const WALLET_HISTORY_KIND = 7376;
3
3
  export const HistoryContentSymbol = Symbol.for("history-content");
4
4
  /** returns an array of redeemed event ids in a history event */
@@ -39,3 +39,7 @@ export async function unlockHistoryContent(history, signer) {
39
39
  await unlockHiddenTags(history, signer);
40
40
  return getHistoryContent(history);
41
41
  }
42
+ export function lockHistoryContent(history) {
43
+ Reflect.deleteProperty(history, HistoryContentSymbol);
44
+ lockHiddenTags(history);
45
+ }
@@ -27,6 +27,8 @@ export declare function getTokenContent(token: NostrEvent): TokenContent | undef
27
27
  export declare function isTokenContentLocked(token: NostrEvent): boolean;
28
28
  /** Decrypts a k:7375 token event */
29
29
  export declare function unlockTokenContent(token: NostrEvent, signer: HiddenContentSigner): Promise<TokenContent>;
30
+ /** Removes the unencrypted hidden content */
31
+ export declare function lockTokenContent(token: NostrEvent): void;
30
32
  /** Gets the totaled amount of proofs in a token event */
31
33
  export declare function getTokenProofsTotal(token: NostrEvent): number | undefined;
32
34
  /**
@@ -1,4 +1,4 @@
1
- import { getHiddenContent, getOrComputeCachedValue, isHiddenContentLocked, isHiddenTagsLocked, unlockHiddenContent, } from "applesauce-core/helpers";
1
+ import { getHiddenContent, getOrComputeCachedValue, isHiddenContentLocked, isHiddenTagsLocked, lockHiddenContent, unlockHiddenContent, } from "applesauce-core/helpers";
2
2
  export const WALLET_TOKEN_KIND = 7375;
3
3
  export const TokenContentSymbol = Symbol.for("token-content");
4
4
  export const TokenProofsTotalSymbol = Symbol.for("token-proofs-total");
@@ -33,6 +33,12 @@ export async function unlockTokenContent(token, signer) {
33
33
  await unlockHiddenContent(token, signer);
34
34
  return getTokenContent(token);
35
35
  }
36
+ /** Removes the unencrypted hidden content */
37
+ export function lockTokenContent(token) {
38
+ Reflect.deleteProperty(token, TokenContentSymbol);
39
+ Reflect.deleteProperty(token, TokenProofsTotalSymbol);
40
+ lockHiddenContent(token);
41
+ }
36
42
  /** Gets the totaled amount of proofs in a token event */
37
43
  export function getTokenProofsTotal(token) {
38
44
  if (isTokenContentLocked(token))
@@ -8,6 +8,7 @@ export declare const WalletMintsSymbol: unique symbol;
8
8
  export declare function isWalletLocked(wallet: NostrEvent): boolean;
9
9
  /** Unlocks a wallet and returns the hidden tags */
10
10
  export declare function unlockWallet(wallet: NostrEvent, signer: HiddenContentSigner): Promise<string[][]>;
11
+ export declare function lockWallet(wallet: NostrEvent): void;
11
12
  /** Returns the wallets mints */
12
13
  export declare function getWalletMints(wallet: NostrEvent): string[];
13
14
  /** Returns the wallets private key as a string */
@@ -1,5 +1,5 @@
1
1
  import { hexToBytes } from "@noble/hashes/utils";
2
- import { getHiddenTags, getOrComputeCachedValue, isHiddenTagsLocked, unlockHiddenTags, } from "applesauce-core/helpers";
2
+ import { getHiddenTags, getOrComputeCachedValue, isHiddenTagsLocked, lockHiddenTags, unlockHiddenTags, } from "applesauce-core/helpers";
3
3
  export const WALLET_KIND = 17375;
4
4
  export const WALLET_BACKUP_KIND = 375;
5
5
  export const WalletPrivateKeySymbol = Symbol.for("wallet-private-key");
@@ -12,6 +12,11 @@ export function isWalletLocked(wallet) {
12
12
  export async function unlockWallet(wallet, signer) {
13
13
  return await unlockHiddenTags(wallet, signer);
14
14
  }
15
+ export function lockWallet(wallet) {
16
+ Reflect.deleteProperty(wallet, WalletPrivateKeySymbol);
17
+ Reflect.deleteProperty(wallet, WalletMintsSymbol);
18
+ lockHiddenTags(wallet);
19
+ }
15
20
  /** Returns the wallets mints */
16
21
  export function getWalletMints(wallet) {
17
22
  return getOrComputeCachedValue(wallet, WalletMintsSymbol, () => {
@@ -6,7 +6,7 @@ import { subscribeSpyTo } from "@hirez_io/observer-spy";
6
6
  import { FakeUser } from "../../__tests__/fake-user.js";
7
7
  import { WalletBlueprint } from "../../blueprints/wallet.js";
8
8
  import { WalletQuery } from "../wallet.js";
9
- import { unlockWallet } from "../../helpers/wallet.js";
9
+ import { lockWallet, unlockWallet } from "../../helpers/wallet.js";
10
10
  const user = new FakeUser();
11
11
  const factory = new EventFactory({ signer: user });
12
12
  let events;
@@ -18,6 +18,7 @@ beforeEach(() => {
18
18
  describe("WalletQuery", () => {
19
19
  it("it should update when event is unlocked", async () => {
20
20
  const wallet = await user.signEvent(await factory.create(WalletBlueprint, generateSecretKey(), []));
21
+ lockWallet(wallet);
21
22
  events.add(wallet);
22
23
  const spy = subscribeSpyTo(queries.createQuery(WalletQuery, await user.getPublicKey()));
23
24
  await unlockWallet(wallet, user);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-wallet",
3
- "version": "0.0.0-next-20250313155042",
3
+ "version": "0.0.0-next-20250313225050",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -80,16 +80,16 @@
80
80
  "@cashu/cashu-ts": "2.0.0-rc1",
81
81
  "@gandlaf21/bc-ur": "^1.1.12",
82
82
  "@noble/hashes": "^1.7.1",
83
- "applesauce-actions": "0.0.0-next-20250313155042",
84
- "applesauce-core": "0.0.0-next-20250313155042",
85
- "applesauce-factory": "0.0.0-next-20250313155042",
83
+ "applesauce-actions": "0.0.0-next-20250313225050",
84
+ "applesauce-core": "0.0.0-next-20250313225050",
85
+ "applesauce-factory": "0.0.0-next-20250313225050",
86
86
  "nostr-tools": "^2.10.4",
87
87
  "rxjs": "^7.8.1"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@hirez_io/observer-spy": "^2.2.0",
91
91
  "@types/debug": "^4.1.12",
92
- "applesauce-signers": "0.0.0-next-20250313155042",
92
+ "applesauce-signers": "0.0.0-next-20250313225050",
93
93
  "typescript": "^5.7.3",
94
94
  "vitest": "^3.0.5"
95
95
  },