applesauce-accounts 0.0.0-next-20250128190416 → 0.0.0-next-20250129183155

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/manager.d.ts CHANGED
@@ -3,8 +3,8 @@ import { BehaviorSubject } from "rxjs";
3
3
  import { IAccount, IAccountConstructor, SerializedAccount } from "./types.js";
4
4
  export declare class AccountManager<Metadata extends unknown = any> {
5
5
  types: Map<string, IAccountConstructor<any, any, Metadata>>;
6
- active$: BehaviorSubject<IAccount<any, any, Metadata> | null>;
7
- get active(): IAccount<any, any, Metadata> | null;
6
+ active$: BehaviorSubject<IAccount<any, any, Metadata> | undefined>;
7
+ get active(): IAccount<any, any, Metadata> | undefined;
8
8
  accounts$: BehaviorSubject<IAccount<any, any, Metadata>[]>;
9
9
  get accounts(): IAccount<any, any, Metadata>[];
10
10
  /** Disable request queueing for any accounts added to this manager */
@@ -26,7 +26,7 @@ export declare class AccountManager<Metadata extends unknown = any> {
26
26
  /** Replaces an account with another */
27
27
  replaceAccount(old: string | IAccount<any, any, Metadata>, account: IAccount<any, any, Metadata>): void;
28
28
  /** Returns the currently active account */
29
- getActive(): IAccount<any, any, Metadata> | null;
29
+ getActive(): IAccount<any, any, Metadata> | undefined;
30
30
  /** Sets the currently active account */
31
31
  setActive(id: string | IAccount<any, any, Metadata>): void;
32
32
  /** Clears the currently active account */
@@ -38,7 +38,7 @@ export declare class AccountManager<Metadata extends unknown = any> {
38
38
  /** Removes all metadata on the account */
39
39
  clearAccountMetadata(id: string | IAccount<any, any, Metadata>): void;
40
40
  /** Returns an array of serialized accounts */
41
- toJSON(): SerializedAccount<any, Metadata>[];
41
+ toJSON(quite?: boolean): SerializedAccount<any, Metadata>[];
42
42
  /**
43
43
  * Restores all accounts from an array of serialized accounts
44
44
  * NOTE: this will clear all existing accounts
package/dist/manager.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { BehaviorSubject } from "rxjs";
2
2
  export class AccountManager {
3
3
  types = new Map();
4
- active$ = new BehaviorSubject(null);
4
+ active$ = new BehaviorSubject(undefined);
5
5
  get active() {
6
6
  return this.active$.value;
7
7
  }
@@ -82,7 +82,7 @@ export class AccountManager {
82
82
  }
83
83
  /** Clears the currently active account */
84
84
  clearActive() {
85
- this.active$.next(null);
85
+ this.active$.next(undefined);
86
86
  }
87
87
  // Metadata CRUD
88
88
  /** sets the metadata on an account */
@@ -108,8 +108,18 @@ export class AccountManager {
108
108
  }
109
109
  // Serialize / Deserialize
110
110
  /** Returns an array of serialized accounts */
111
- toJSON() {
112
- return Array.from(this.accounts$.value).map((account) => account.toJSON());
111
+ toJSON(quite = false) {
112
+ const accounts = [];
113
+ for (const account of this.accounts) {
114
+ try {
115
+ accounts.push(account.toJSON());
116
+ }
117
+ catch (error) {
118
+ if (!quite)
119
+ throw error;
120
+ }
121
+ }
122
+ return accounts;
113
123
  }
114
124
  /**
115
125
  * Restores all accounts from an array of serialized accounts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-accounts",
3
- "version": "0.0.0-next-20250128190416",
3
+ "version": "0.0.0-next-20250129183155",
4
4
  "description": "A simple nostr account management system",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@noble/hashes": "^1.5.0",
36
- "applesauce-signers": "0.0.0-next-20250128190416",
36
+ "applesauce-signers": "0.0.0-next-20250129183155",
37
37
  "nanoid": "^5.0.9",
38
38
  "nostr-tools": "^2.10.3",
39
39
  "rxjs": "^7.8.1"