applesauce-signers 0.0.0-next-20250916134023 → 0.0.0-next-20250919114711

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-signers",
3
- "version": "0.0.0-next-20250916134023",
3
+ "version": "0.0.0-next-20250919114711",
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": "0.0.0-next-20250916134023",
50
+ "applesauce-core": "0.0.0-next-20250919114711",
51
51
  "debug": "^4.4.0",
52
52
  "nanoid": "^5.0.9",
53
53
  "nostr-tools": "~2.15",
@@ -56,6 +56,7 @@
56
56
  "devDependencies": {
57
57
  "@types/debug": "^4.1.12",
58
58
  "@types/dom-serial": "^1.0.6",
59
+ "rimraf": "^6.0.1",
59
60
  "typescript": "^5.8.3",
60
61
  "vitest": "^3.1.3",
61
62
  "vitest-websocket-mock": "^0.5.0"
@@ -65,6 +66,7 @@
65
66
  "url": "lightning:nostrudel@geyser.fund"
66
67
  },
67
68
  "scripts": {
69
+ "prebuild": "rimraf dist",
68
70
  "build": "tsc",
69
71
  "watch:build": "tsc --watch > /dev/null",
70
72
  "test": "vitest run --passWithNoTests",
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import * as exports from "../index.js";
3
- describe("exports", () => {
4
- it("should export the expected functions", () => {
5
- expect(Object.keys(exports).sort()).toMatchInlineSnapshot(`
6
- [
7
- "AmberClipboardSigner",
8
- "ExtensionMissingError",
9
- "ExtensionSigner",
10
- "Helpers",
11
- "NostrConnectMethod",
12
- "NostrConnectSigner",
13
- "PasswordSigner",
14
- "Permission",
15
- "ReadonlySigner",
16
- "SerialPortSigner",
17
- "SimpleSigner",
18
- "isErrorResponse",
19
- ]
20
- `);
21
- });
22
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import * as exports from "../index.js";
3
- describe("exports", () => {
4
- it("should export the expected functions", () => {
5
- expect(Object.keys(exports).sort()).toMatchInlineSnapshot(`
6
- [
7
- "isNIP04",
8
- ]
9
- `);
10
- });
11
- });
@@ -1,11 +0,0 @@
1
- export interface Unsubscribable {
2
- unsubscribe(): void;
3
- }
4
- export interface Observer<T> {
5
- next: (value: T) => void;
6
- error: (err: any) => void;
7
- complete: () => void;
8
- }
9
- export type Subscribable<T extends unknown> = {
10
- subscribe: (observer: Partial<Observer<T>>) => Unsubscribable;
11
- };
@@ -1,2 +0,0 @@
1
- // Simple types copied from rxjs
2
- export {};
@@ -1,15 +0,0 @@
1
- import { EventTemplate, NostrEvent } from "nostr-tools";
2
- export type ISigner = {
3
- getPublicKey: () => Promise<string>;
4
- signEvent: (template: EventTemplate) => Promise<NostrEvent>;
5
- nip04?: {
6
- encrypt: (pubkey: string, plaintext: string) => Promise<string>;
7
- decrypt: (pubkey: string, ciphertext: string) => Promise<string>;
8
- };
9
- nip44?: {
10
- encrypt: (pubkey: string, plaintext: string) => Promise<string>;
11
- decrypt: (pubkey: string, ciphertext: string) => Promise<string>;
12
- };
13
- };
14
- /** @deprecated Use ISigner instead */
15
- export type Nip07Interface = ISigner;
package/dist/interface.js DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/logger.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import debug from "debug";
2
- export declare const logger: debug.Debugger;
package/dist/logger.js DELETED
@@ -1,2 +0,0 @@
1
- import debug from "debug";
2
- export const logger = debug("applesauce:signer");
package/dist/nip-07.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import { EventTemplate, NostrEvent } from "nostr-tools";
2
- export type Nip07Interface = {
3
- getPublicKey: () => Promise<string> | string;
4
- signEvent: (template: EventTemplate) => Promise<NostrEvent> | NostrEvent;
5
- getRelays?: () => Record<string, {
6
- read: boolean;
7
- write: boolean;
8
- }> | Promise<Record<string, {
9
- read: boolean;
10
- write: boolean;
11
- }>>;
12
- nip04?: {
13
- encrypt: (pubkey: string, plaintext: string) => Promise<string> | string;
14
- decrypt: (pubkey: string, ciphertext: string) => Promise<string> | string;
15
- };
16
- nip44?: {
17
- encrypt: (pubkey: string, plaintext: string) => Promise<string> | string;
18
- decrypt: (pubkey: string, ciphertext: string) => Promise<string> | string;
19
- };
20
- };
package/dist/nip-07.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import * as exports from "../index.js";
3
- describe("exports", () => {
4
- it("should export the expected functions", () => {
5
- expect(Object.keys(exports).sort()).toMatchInlineSnapshot(`
6
- [
7
- "AmberClipboardSigner",
8
- "ExtensionMissingError",
9
- "ExtensionSigner",
10
- "NostrConnectMethod",
11
- "NostrConnectSigner",
12
- "PasswordSigner",
13
- "Permission",
14
- "ReadonlySigner",
15
- "SerialPortSigner",
16
- "SimpleSigner",
17
- "isErrorResponse",
18
- ]
19
- `);
20
- });
21
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,66 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest";
2
- import { NostrConnectSigner } from "../nostr-connect-signer.js";
3
- import { SimpleSigner } from "../simple-signer.js";
4
- const relays = ["wss://relay.signer.com"];
5
- const client = new SimpleSigner();
6
- const remote = new SimpleSigner();
7
- const observable = { unsubscribe: vi.fn() };
8
- const req = { subscribe: vi.fn().mockReturnValue(observable) };
9
- const subscriptionMethod = vi.fn().mockReturnValue(req);
10
- const publishMethod = vi.fn(async () => { });
11
- let signer;
12
- beforeEach(async () => {
13
- observable.unsubscribe.mockClear();
14
- req.subscribe.mockClear();
15
- subscriptionMethod.mockClear();
16
- publishMethod.mockClear();
17
- signer = new NostrConnectSigner({
18
- relays,
19
- remote: await remote.getPublicKey(),
20
- signer: client,
21
- subscriptionMethod,
22
- publishMethod,
23
- });
24
- });
25
- describe("connection", () => {
26
- it("should call subscription method with filters", async () => {
27
- signer.connect();
28
- expect(subscriptionMethod).toHaveBeenCalledWith(relays, [{ "#p": [await client.getPublicKey()], kinds: [24133] }]);
29
- });
30
- });
31
- describe("open", () => {
32
- it("should call subscription method with filters", async () => {
33
- signer.open();
34
- expect(subscriptionMethod).toHaveBeenCalledWith(relays, [{ "#p": [await client.getPublicKey()], kinds: [24133] }]);
35
- });
36
- });
37
- describe("waitForSigner", () => {
38
- it("should accept an abort signal", async () => {
39
- const signer = new NostrConnectSigner({
40
- relays: ["wss://relay.signer.com"],
41
- signer: client,
42
- subscriptionMethod,
43
- publishMethod,
44
- });
45
- const controller = new AbortController();
46
- const p = signer.waitForSigner(controller.signal);
47
- setTimeout(() => {
48
- controller.abort();
49
- }, 10);
50
- await expect(p).rejects.toThrow("Aborted");
51
- expect(signer.listening).toBe(false);
52
- });
53
- });
54
- describe("close", () => {
55
- it("should close the connection", async () => {
56
- await signer.open();
57
- expect(req.subscribe).toHaveBeenCalled();
58
- await signer.close();
59
- expect(observable.unsubscribe).toHaveBeenCalled();
60
- });
61
- it("it should cancel waiting for signer promie", async () => {
62
- const p = signer.waitForSigner();
63
- await signer.close();
64
- await expect(p).rejects.toThrow("Closed");
65
- });
66
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,23 +0,0 @@
1
- import { describe, expect, it, vi } from "vitest";
2
- import { NostrConnectSigner } from "./nostr-connect-signer.js";
3
- import { SimpleSigner } from "./simple-signer.js";
4
- describe("NostrConnectSigner", () => {
5
- describe("connection", () => {
6
- it("should call subscription method with filters", async () => {
7
- const relays = ["wss://relay.signer.com"];
8
- const subscription = vi.fn().mockReturnValue({ subscribe: vi.fn() });
9
- const publish = vi.fn(async () => { });
10
- const client = new SimpleSigner();
11
- const remote = new SimpleSigner();
12
- const signer = new NostrConnectSigner({
13
- relays,
14
- remote: await remote.getPublicKey(),
15
- signer: client,
16
- subscriptionMethod: subscription,
17
- publishMethod: publish,
18
- });
19
- signer.connect();
20
- expect(subscription).toHaveBeenCalledWith([{ "#p": [await client.getPublicKey()], kinds: [24133] }], relays);
21
- });
22
- });
23
- });