applesauce-accounts 0.0.0-next-20250128182541 → 0.0.0-next-20250128204825

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.
@@ -6,4 +6,5 @@ export declare class ReadonlyAccount<Metadata extends unknown> extends BaseAccou
6
6
  static readonly type = "readonly";
7
7
  toJSON(): SerializedAccount<void, Metadata>;
8
8
  static fromJSON<Metadata extends unknown>(json: SerializedAccount<void, Metadata>): ReadonlyAccount<Metadata>;
9
+ static fromPubkey(pubkey: string): ReadonlyAccount<unknown>;
9
10
  }
@@ -12,4 +12,7 @@ export class ReadonlyAccount extends BaseAccount {
12
12
  const account = new ReadonlyAccount(json.pubkey, new ReadonlySigner(json.pubkey));
13
13
  return super.loadCommonFields(account, json);
14
14
  }
15
+ static fromPubkey(pubkey) {
16
+ return new ReadonlyAccount(pubkey, new ReadonlySigner(pubkey));
17
+ }
15
18
  }
package/dist/manager.d.ts CHANGED
@@ -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
@@ -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/dist/types.d.ts CHANGED
@@ -23,7 +23,7 @@ export interface IAccount<Signer extends Nip07Interface = Nip07Interface, Signer
23
23
  pubkey: string;
24
24
  metadata?: Metadata;
25
25
  signer: Signer;
26
- readonly type: string;
26
+ type: string;
27
27
  disableQueue?: boolean;
28
28
  toJSON(): SerializedAccount<SignerData, Metadata>;
29
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-accounts",
3
- "version": "0.0.0-next-20250128182541",
3
+ "version": "0.0.0-next-20250128204825",
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-20250128182541",
36
+ "applesauce-signers": "0.0.0-next-20250128204825",
37
37
  "nanoid": "^5.0.9",
38
38
  "nostr-tools": "^2.10.3",
39
39
  "rxjs": "^7.8.1"