applesauce-signers 0.11.0 → 0.12.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.
@@ -13,6 +13,7 @@ export declare class ExtensionSigner implements Nip07Interface {
13
13
  encrypt: (pubkey: string, plaintext: string) => Promise<string> | string;
14
14
  decrypt: (pubkey: string, ciphertext: string) => Promise<string> | string;
15
15
  } | undefined;
16
+ protected pubkey: string | undefined;
16
17
  getPublicKey(): string | Promise<string>;
17
18
  getRelays(): Record<string, {
18
19
  read: boolean;
@@ -9,10 +9,22 @@ export class ExtensionSigner {
9
9
  get nip44() {
10
10
  return window.nostr?.nip44;
11
11
  }
12
+ pubkey = undefined;
12
13
  getPublicKey() {
13
14
  if (!window.nostr)
14
15
  throw new ExtensionMissingError("Signer extension missing");
15
- return window.nostr.getPublicKey();
16
+ if (this.pubkey)
17
+ return this.pubkey;
18
+ const p = window.nostr.getPublicKey();
19
+ if (p instanceof Promise)
20
+ return p.then((pubkey) => {
21
+ this.pubkey = pubkey;
22
+ return pubkey;
23
+ });
24
+ else {
25
+ this.pubkey = p;
26
+ return p;
27
+ }
16
28
  }
17
29
  getRelays() {
18
30
  if (!window.nostr)
@@ -147,7 +147,7 @@ export class NostrConnectSigner {
147
147
  }
148
148
  }
149
149
  else
150
- p.reject(response);
150
+ p.reject(new Error(response.error));
151
151
  }
152
152
  else if (response.result) {
153
153
  this.log("Got Response", response.id, response.result);
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "applesauce-signers",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Signer classes for applesauce",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "keywords": [
9
- "nostr"
9
+ "nostr",
10
+ "applesauce"
10
11
  ],
11
12
  "author": "hzrd149",
12
13
  "license": "MIT",
@@ -35,7 +36,7 @@
35
36
  "@noble/hashes": "^1.7.1",
36
37
  "@noble/secp256k1": "^1.7.1",
37
38
  "@scure/base": "^1.2.4",
38
- "applesauce-core": "^0.11.0",
39
+ "applesauce-core": "^0.12.0",
39
40
  "debug": "^4.4.0",
40
41
  "nanoid": "^5.0.9",
41
42
  "nostr-tools": "^2.10.4"