applesauce-signers 0.0.0-next-20250828144630 → 0.0.0-next-20250913205403

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.
@@ -251,9 +251,12 @@ export class NostrConnectProvider {
251
251
  const providerPubkey = await this.signer.getPublicKey();
252
252
  if (target !== providerPubkey)
253
253
  throw new Error("Invalid target pubkey");
254
- // If a secret is set, check that if matches
255
- if (this.secret && this.secret !== secret)
256
- throw new Error("Invalid secret");
254
+ // If the client is already known, ensure that it matches the new client
255
+ if (this.client && this.client !== client)
256
+ throw new Error("Only one client can connect at a time");
257
+ // If this is the first `connect` request, check that the secret matches
258
+ if (this.secret && !this.client && this.secret !== secret)
259
+ throw new Error("Invalid connection secret");
257
260
  // Handle authorization if callback is provided
258
261
  if (this.onConnect) {
259
262
  const authorized = await this.onConnect(client, permissions);
@@ -169,6 +169,7 @@ export class SerialPortSigner {
169
169
  const sharedSecret = hexToBytes(sharedSecretStr);
170
170
  let iv = Uint8Array.from(randomBytes(16));
171
171
  let plaintext = utf8Encoder.encode(text);
172
+ // @ts-ignore
172
173
  let cryptoKey = await crypto.subtle.importKey("raw", sharedSecret, { name: "AES-CBC" }, false, ["encrypt"]);
173
174
  let ciphertext = await crypto.subtle.encrypt({ name: "AES-CBC", iv }, cryptoKey, plaintext);
174
175
  let ctb64 = base64.encode(new Uint8Array(ciphertext));
@@ -179,9 +180,11 @@ export class SerialPortSigner {
179
180
  let [ctb64, ivb64] = data.split("?iv=");
180
181
  const sharedSecretStr = await this.callMethodOnDevice(SerialPortSigner.METHOD_SHARED_SECRET, [xOnlyToXY(pubkey)]);
181
182
  const sharedSecret = hexToBytes(sharedSecretStr);
183
+ // @ts-ignore
182
184
  let cryptoKey = await crypto.subtle.importKey("raw", sharedSecret, { name: "AES-CBC" }, false, ["decrypt"]);
183
185
  let ciphertext = base64.decode(ctb64);
184
186
  let iv = base64.decode(ivb64);
187
+ // @ts-ignore
185
188
  let plaintext = await crypto.subtle.decrypt({ name: "AES-CBC", iv }, cryptoKey, ciphertext);
186
189
  let text = utf8Decoder.decode(plaintext);
187
190
  return text;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-signers",
3
- "version": "0.0.0-next-20250828144630",
3
+ "version": "0.0.0-next-20250913205403",
4
4
  "description": "Signer classes for applesauce",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -14,8 +14,7 @@
14
14
  "author": "hzrd149",
15
15
  "license": "MIT",
16
16
  "files": [
17
- "dist",
18
- "applesauce"
17
+ "dist"
19
18
  ],
20
19
  "exports": {
21
20
  ".": {
@@ -32,13 +31,23 @@
32
31
  "import": "./dist/signers/*.js",
33
32
  "require": "./dist/signers/*.js",
34
33
  "types": "./dist/signers/*.d.ts"
34
+ },
35
+ "./helpers": {
36
+ "import": "./dist/helpers/index.js",
37
+ "require": "./dist/helpers/index.js",
38
+ "types": "./dist/helpers/index.d.ts"
39
+ },
40
+ "./helpers/*": {
41
+ "import": "./dist/helpers/*.js",
42
+ "require": "./dist/helpers/*.js",
43
+ "types": "./dist/helpers/*.d.ts"
35
44
  }
36
45
  },
37
46
  "dependencies": {
38
47
  "@noble/hashes": "^1.7.1",
39
48
  "@noble/secp256k1": "^1.7.1",
40
49
  "@scure/base": "^1.2.4",
41
- "applesauce-core": "0.0.0-next-20250828144630",
50
+ "applesauce-core": "0.0.0-next-20250913205403",
42
51
  "debug": "^4.4.0",
43
52
  "nanoid": "^5.0.9",
44
53
  "nostr-tools": "~2.15",