applesauce-signers 4.1.0 → 4.2.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.
@@ -1,4 +1,5 @@
1
1
  import { verifyEvent } from "nostr-tools";
2
+ import { isHexKey } from "applesauce-core/helpers";
2
3
  /** AN error that is throw when the window.nostr extension is missing */
3
4
  export class ExtensionMissingError extends Error {
4
5
  }
@@ -16,7 +17,10 @@ export class ExtensionSigner {
16
17
  throw new ExtensionMissingError("Signer extension missing");
17
18
  if (this.pubkey)
18
19
  return this.pubkey;
19
- this.pubkey = await window.nostr.getPublicKey();
20
+ const key = await window.nostr.getPublicKey();
21
+ if (!isHexKey(key))
22
+ throw new Error("Extension returned an invalid public key");
23
+ this.pubkey = key;
20
24
  return this.pubkey;
21
25
  }
22
26
  async signEvent(template) {
@@ -1,5 +1,5 @@
1
1
  import { logger } from "applesauce-core";
2
- import { getHiddenContent, unixNow } from "applesauce-core/helpers";
2
+ import { getHiddenContent, isHexKey, unixNow } from "applesauce-core/helpers";
3
3
  import { createDefer } from "applesauce-core/promise";
4
4
  import { PrivateKeySigner, getConnectionMethods, } from "applesauce-signers";
5
5
  import { nanoid } from "nanoid";
@@ -265,7 +265,10 @@ export class NostrConnectSigner {
265
265
  if (this.pubkey)
266
266
  return this.pubkey;
267
267
  await this.requireConnection();
268
- return this.makeRequest(NostrConnectMethod.GetPublicKey, []);
268
+ const key = await this.makeRequest(NostrConnectMethod.GetPublicKey, []);
269
+ if (!isHexKey(key))
270
+ throw new Error("Remote signer returned an invalid public key");
271
+ return key;
269
272
  }
270
273
  /** Request to sign an event */
271
274
  async signEvent(template) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-signers",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "Signer classes for applesauce",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -47,7 +47,7 @@
47
47
  "@noble/hashes": "^1.7.1",
48
48
  "@noble/secp256k1": "^1.7.1",
49
49
  "@scure/base": "^1.2.4",
50
- "applesauce-core": "^4.1.0",
50
+ "applesauce-core": "^4.2.0",
51
51
  "debug": "^4.4.0",
52
52
  "nanoid": "^5.0.9",
53
53
  "nostr-tools": "~2.17",