@nostrify/nostrify 0.46.7 → 0.46.8

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.
Files changed (154) hide show
  1. package/.turbo/turbo-build.log +28 -5
  2. package/.turbo/turbo-setup.log +13 -0
  3. package/.turbo/turbo-test.log +123 -0
  4. package/BunkerURI.test.ts +19 -14
  5. package/CHANGELOG.md +8 -0
  6. package/NBrowserSigner.test.ts +49 -34
  7. package/NCache.test.ts +14 -7
  8. package/NCache.ts +2 -2
  9. package/NConnectSigner.test.ts +48 -31
  10. package/NConnectSigner.ts +3 -3
  11. package/NIP05.test.ts +36 -44
  12. package/NIP05.ts +2 -2
  13. package/NIP50.test.ts +35 -34
  14. package/NIP98.test.ts +89 -76
  15. package/NIP98.ts +2 -2
  16. package/NKinds.test.ts +37 -36
  17. package/NPool.test.ts +35 -24
  18. package/NPool.ts +42 -23
  19. package/NRelay1.test.ts +100 -68
  20. package/NRelay1.ts +13 -6
  21. package/NSchema.test.ts +98 -56
  22. package/NSchema.ts +10 -14
  23. package/NSecSigner.test.ts +19 -10
  24. package/NSecSigner.ts +4 -3
  25. package/NSet.test.ts +123 -50
  26. package/NSet.ts +13 -6
  27. package/RelayError.test.ts +11 -10
  28. package/RelayError.ts +1 -1
  29. package/dist/BunkerURI.js +44 -44
  30. package/dist/NBrowserSigner.js +73 -83
  31. package/dist/NCache.d.ts +2 -2
  32. package/dist/NCache.d.ts.map +1 -1
  33. package/dist/NCache.js +35 -56
  34. package/dist/NConnectSigner.d.ts +1 -1
  35. package/dist/NConnectSigner.d.ts.map +1 -1
  36. package/dist/NConnectSigner.js +124 -117
  37. package/dist/NIP05.d.ts +1 -1
  38. package/dist/NIP05.d.ts.map +1 -1
  39. package/dist/NIP05.js +33 -33
  40. package/dist/NIP50.js +19 -20
  41. package/dist/NIP98.d.ts +1 -1
  42. package/dist/NIP98.d.ts.map +1 -1
  43. package/dist/NIP98.js +71 -64
  44. package/dist/NKinds.js +24 -22
  45. package/dist/NPool.d.ts +2 -2
  46. package/dist/NPool.d.ts.map +1 -1
  47. package/dist/NPool.js +143 -170
  48. package/dist/NRelay1.d.ts +5 -4
  49. package/dist/NRelay1.d.ts.map +1 -1
  50. package/dist/NRelay1.js +301 -315
  51. package/dist/NSchema.d.ts +1 -1
  52. package/dist/NSchema.d.ts.map +1 -1
  53. package/dist/NSchema.js +185 -208
  54. package/dist/NSecSigner.d.ts +1 -2
  55. package/dist/NSecSigner.d.ts.map +1 -1
  56. package/dist/NSecSigner.js +35 -46
  57. package/dist/NSet.d.ts +1 -1
  58. package/dist/NSet.d.ts.map +1 -1
  59. package/dist/NSet.js +138 -166
  60. package/dist/RelayError.d.ts +1 -1
  61. package/dist/RelayError.d.ts.map +1 -1
  62. package/dist/RelayError.js +18 -17
  63. package/dist/ln/LNURL.d.ts +4 -4
  64. package/dist/ln/LNURL.d.ts.map +1 -1
  65. package/dist/ln/LNURL.js +93 -93
  66. package/dist/ln/mod.d.ts +3 -3
  67. package/dist/ln/mod.js +4 -2
  68. package/dist/ln/mod.js.map +7 -1
  69. package/dist/ln/types/LNURLCallback.js +0 -2
  70. package/dist/ln/types/LNURLDetails.js +0 -2
  71. package/dist/mod.d.ts +14 -14
  72. package/dist/mod.js +30 -15
  73. package/dist/mod.js.map +7 -1
  74. package/dist/test/ErrorRelay.d.ts +1 -1
  75. package/dist/test/ErrorRelay.d.ts.map +1 -1
  76. package/dist/test/ErrorRelay.js +22 -21
  77. package/dist/test/MockRelay.d.ts +3 -3
  78. package/dist/test/MockRelay.d.ts.map +1 -1
  79. package/dist/test/MockRelay.js +56 -57
  80. package/dist/test/TestRelayServer.d.ts +6 -3
  81. package/dist/test/TestRelayServer.d.ts.map +1 -1
  82. package/dist/test/TestRelayServer.js +141 -122
  83. package/dist/test/mod.d.ts +3 -3
  84. package/dist/test/mod.d.ts.map +1 -1
  85. package/dist/test/mod.js +22 -19
  86. package/dist/test/mod.js.map +7 -1
  87. package/dist/tsconfig.tsbuildinfo +1 -1
  88. package/dist/uploaders/BlossomUploader.d.ts +1 -1
  89. package/dist/uploaders/BlossomUploader.d.ts.map +1 -1
  90. package/dist/uploaders/BlossomUploader.js +69 -66
  91. package/dist/uploaders/NostrBuildUploader.d.ts +1 -2
  92. package/dist/uploaders/NostrBuildUploader.d.ts.map +1 -1
  93. package/dist/uploaders/NostrBuildUploader.js +61 -59
  94. package/dist/uploaders/mod.d.ts +2 -2
  95. package/dist/uploaders/mod.js +6 -3
  96. package/dist/uploaders/mod.js.map +7 -1
  97. package/dist/utils/CircularSet.d.ts +1 -1
  98. package/dist/utils/CircularSet.d.ts.map +1 -1
  99. package/dist/utils/CircularSet.js +26 -28
  100. package/dist/utils/Machina.js +35 -59
  101. package/dist/utils/N64.d.ts +1 -1
  102. package/dist/utils/N64.d.ts.map +1 -1
  103. package/dist/utils/N64.js +16 -18
  104. package/dist/utils/mod.d.ts +2 -2
  105. package/dist/utils/mod.js +6 -3
  106. package/dist/utils/mod.js.map +7 -1
  107. package/ln/LNURL.test.ts +70 -52
  108. package/ln/LNURL.ts +15 -15
  109. package/ln/mod.ts +3 -3
  110. package/mod.ts +14 -14
  111. package/package.json +5 -3
  112. package/test/ErrorRelay.test.ts +11 -10
  113. package/test/ErrorRelay.ts +17 -5
  114. package/test/MockRelay.test.ts +15 -8
  115. package/test/MockRelay.ts +3 -3
  116. package/test/TestRelayServer.ts +46 -17
  117. package/test/mod.ts +4 -4
  118. package/tsconfig.json +5 -2
  119. package/uploaders/BlossomUploader.test.ts +39 -22
  120. package/uploaders/BlossomUploader.ts +2 -2
  121. package/uploaders/NostrBuildUploader.test.ts +36 -18
  122. package/uploaders/NostrBuildUploader.ts +4 -4
  123. package/uploaders/mod.ts +2 -2
  124. package/utils/CircularSet.test.ts +5 -4
  125. package/utils/CircularSet.ts +3 -1
  126. package/utils/Machina.test.ts +30 -19
  127. package/utils/N64.test.ts +12 -11
  128. package/utils/N64.ts +2 -2
  129. package/utils/mod.ts +2 -2
  130. package/dist/BunkerURI.js.map +0 -1
  131. package/dist/NBrowserSigner.js.map +0 -1
  132. package/dist/NCache.js.map +0 -1
  133. package/dist/NConnectSigner.js.map +0 -1
  134. package/dist/NIP05.js.map +0 -1
  135. package/dist/NIP50.js.map +0 -1
  136. package/dist/NIP98.js.map +0 -1
  137. package/dist/NKinds.js.map +0 -1
  138. package/dist/NPool.js.map +0 -1
  139. package/dist/NRelay1.js.map +0 -1
  140. package/dist/NSchema.js.map +0 -1
  141. package/dist/NSecSigner.js.map +0 -1
  142. package/dist/NSet.js.map +0 -1
  143. package/dist/RelayError.js.map +0 -1
  144. package/dist/ln/LNURL.js.map +0 -1
  145. package/dist/ln/types/LNURLCallback.js.map +0 -1
  146. package/dist/ln/types/LNURLDetails.js.map +0 -1
  147. package/dist/test/ErrorRelay.js.map +0 -1
  148. package/dist/test/MockRelay.js.map +0 -1
  149. package/dist/test/TestRelayServer.js.map +0 -1
  150. package/dist/uploaders/BlossomUploader.js.map +0 -1
  151. package/dist/uploaders/NostrBuildUploader.js.map +0 -1
  152. package/dist/utils/CircularSet.js.map +0 -1
  153. package/dist/utils/Machina.js.map +0 -1
  154. package/dist/utils/N64.js.map +0 -1
@@ -1,5 +1,28 @@
1
-
2
-
3
- > @nostrify/nostrify@0.46.7 build /home/sid/repos/NSpec/packages/nostrify
4
- > tsc -p tsconfig.json
5
-
1
+
2
+ > @nostrify/nostrify@0.46.7 build /home/sid/repos/nostrify/packages/nostrify
3
+ > tsc -p tsconfig.json && node ../../esbuild.config.js --package ./
4
+
5
+
6
+ dist/NRelay1.js 8.9kb
7
+ dist/NSchema.js 5.6kb
8
+ dist/NPool.js 5.0kb
9
+ dist/test/TestRelayServer.js 4.4kb
10
+ dist/NSet.js 4.1kb
11
+ dist/NConnectSigner.js 3.9kb
12
+ dist/ln/LNURL.js 3.3kb
13
+ dist/NBrowserSigner.js 2.6kb
14
+ dist/NIP98.js 2.4kb
15
+ dist/uploaders/NostrBuildUploader.js 1.9kb
16
+ dist/uploaders/BlossomUploader.js 1.8kb
17
+ dist/test/MockRelay.js 1.4kb
18
+ dist/BunkerURI.js 1.4kb
19
+ dist/NKinds.js 1.1kb
20
+ dist/NIP05.js 1.1kb
21
+ dist/NSecSigner.js 1.1kb
22
+ dist/utils/Machina.js 925b
23
+ dist/NCache.js 828b
24
+ dist/mod.js 752b
25
+ dist/test/mod.js 701b
26
+ ...and 10 more output files...
27
+
28
+ ⚡ Done in 22ms
@@ -0,0 +1,13 @@
1
+
2
+
3
+ > @nostrify/nostrify@0.46.7 setup /home/sid/repos/nostrify/packages/nostrify
4
+ > pnpm i
5
+
6
+ (node:1234099) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
7
+ (Use `node --trace-deprecation ...` to show where the warning was created)
8
+ Scope: all 9 workspace projects
9
+ ../.. | Progress: resolved 1, reused 0, downloaded 0, added 0
10
+ ../.. | +1 +
11
+ ../.. | Progress: resolved 1, reused 0, downloaded 0, added 0
12
+ ../.. | Progress: resolved 1, reused 1, downloaded 0, added 0
13
+ ../.. | Progress: resolved 1, reused 1, downloaded 0, added 0, done
@@ -0,0 +1,123 @@
1
+
2
+ > @nostrify/nostrify@0.46.7 test /home/sid/repos/nostrify/packages/nostrify
3
+ > node --test "**/*.test.ts"
4
+
5
+ ✔ BunkerURI (3.139394ms)
6
+ ✔ BunkerURI.fromJSON (1.078848ms)
7
+ ✔ NBrowserSigner - without extension (6.464847ms)
8
+ ✔ NBrowserSigner - with extension polyfill (234.080428ms)
9
+ ✔ NBrowserSigner.nip44 - with extension polyfill (91.327807ms)
10
+ ✔ NBrowserSigner.nip04 - with extension polyfill (83.997199ms)
11
+ ✔ NBrowserSigner.getRelays - with extension polyfill (1.347041ms)
12
+ ✔ NBrowserSigner - missing nip44 support (7.24135ms)
13
+ ✔ NBrowserSigner - missing nip04 support (0.957463ms)
14
+ ✔ NBrowserSigner - feature detection (0.630183ms)
15
+ ✔ NCache (7.515339ms)
16
+ ✔ NConnectSigner.signEvent with nip04 encryption (279.362646ms)
17
+ ✔ NConnectSigner.signEvent with nip44 encryption (108.072198ms)
18
+ ✔ NIP05.lookup (127.775302ms)
19
+ ✔ NIP05.lookup with invalid values but valid profile pointer (11.722058ms)
20
+ ✔ NIP05.lookup with invalid document (13.281978ms)
21
+ ✔ NIP50.parseInput (3.655177ms)
22
+ ✔ NIP50.parseInput with negated token (0.487567ms)
23
+ ✔ NIP98.template (24.095253ms)
24
+ ✔ NIP98.template with payload (53.842113ms)
25
+ ✔ NIP98.verify (281.757944ms)
26
+ ✔ NIP98.verify fails with missing header (7.416304ms)
27
+ ✔ NIP98.verify fails with missing token (4.561446ms)
28
+ ✔ NIP98.verify fails with invalid token (9.659557ms)
29
+ ✔ NIP98.verify fails with invalid event (37.684884ms)
30
+ ✔ NIP98.verify fails with wrong event kind (62.228241ms)
31
+ ✔ NIP98.verify fails with wrong request URL (32.012672ms)
32
+ ✔ NIP98.verify fails with wrong request method (61.338176ms)
33
+ ✔ NIP98.verify fails with expired event (33.697888ms)
34
+ ✔ NIP98.verify fails with invalid payload (73.713885ms)
35
+ ✔ NKinds (2.137233ms)
36
+ ✔ NPool.query (1002.066008ms)
37
+ ✔ NPool.req (97.498969ms)
38
+ ✔ NPool.event (267.305626ms)
39
+ ✔ NRelay1.query (746.453455ms)
40
+ ✔ NRelay1.query mismatched filter (259.123715ms)
41
+ ✔ NRelay1.req (297.033979ms)
42
+ ✔ NRelay1.event (246.217138ms)
43
+ ﹣ NRelay1 backoff (1.75855ms) # SKIP
44
+ ▶ NRelay1 idleTimeout
45
+ ✔ websocket opens (43.318751ms)
46
+ ✔ websocket closes after idleTimeout (151.53622ms)
47
+ ✔ websocket wakes up during activity (20.337967ms)
48
+ ✔ NRelay1 idleTimeout (429.224616ms)
49
+ ✔ NRelay1.count rejects when the server sends CLOSED (223.243687ms)
50
+ ✔ NRelay1 closes when it receives a binary message (221.917598ms)
51
+ ✔ n.id (19.246617ms)
52
+ ✔ n.bech32 (5.666764ms)
53
+ ✔ n.filter (41.374213ms)
54
+ ✔ n.event (5.833826ms)
55
+ ✔ n.metadata (22.364081ms)
56
+ ✔ NSecSigner (265.119504ms)
57
+ ✔ NSecSigner.nip44 (70.579379ms)
58
+ ✔ NSet (36.583337ms)
59
+ ✔ NSet.add (replaceable) (0.930993ms)
60
+ ✔ NSet.add (parameterized) (1.035127ms)
61
+ ✔ NSet.add (deletion) (0.479884ms)
62
+ ✔ Construct a RelayError from the reason message (2.876998ms)
63
+ ✔ Throw a new RelayError if the OK message is false (0.544837ms)
64
+ ✔ LNURL.fromString (7.092726ms)
65
+ ✔ LNURL.fromLightningAddress (1.072702ms)
66
+ ✔ LNURL.toString (1.514522ms)
67
+ ✔ LNURL.getDetails (94.441569ms)
68
+ ✔ LNURL.getInvoice (8.24442ms)
69
+ ✔ ErrorRelay (123.796477ms)
70
+ ✔ MockRelay (3.191496ms)
71
+ ✔ BlossomUploader.upload (1004.663359ms)
72
+ {
73
+ status: 'error',
74
+ message: 'Unauthorized, please provide a valid nip-98 token',
75
+ data: {}
76
+ }
77
+ ✖ NostrBuildUploader.upload (1590.593336ms)
78
+ ✔ CircularSet (7.081691ms)
79
+ ✔ push, iterate, & close (104.057684ms)
80
+ ✔ close & reopen (0.858706ms)
81
+ ✔ aborts with signal (52.838065ms)
82
+ ✔ already aborted signal in constructor (0.887341ms)
83
+ ✔ push after abort (1.140029ms)
84
+ ✔ multiple messages in queue (0.695626ms)
85
+ ✔ N64 (8.897581ms)
86
+ ✔ N64.encodeEvent (0.552799ms)
87
+ ✔ N64.decodeEvent (1.49315ms)
88
+ ℹ tests 77
89
+ ℹ suites 0
90
+ ℹ pass 75
91
+ ℹ fail 1
92
+ ℹ cancelled 0
93
+ ℹ skipped 1
94
+ ℹ todo 0
95
+ ℹ duration_ms 3317.855572
96
+
97
+ ✖ failing tests:
98
+
99
+ test at uploaders/NostrBuildUploader.test.ts:10:7
100
+ ✖ NostrBuildUploader.upload (1590.593336ms)
101
+ Error [ZodError]: [
102
+ {
103
+ "code": "invalid_type",
104
+ "expected": "array",
105
+ "received": "object",
106
+ "path": [
107
+ "data"
108
+ ],
109
+ "message": "Expected array, received object"
110
+ }
111
+ ]
112
+ at get error (file:///home/sid/repos/nostrify/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js:39:31)
113
+ at ZodObject.parse (file:///home/sid/repos/nostrify/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js:114:22)
114
+ at NostrBuildUploader.upload (file:///home/sid/repos/nostrify/packages/nostrify/uploaders/NostrBuildUploader.ts:51:48)
115
+ at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
116
+ at async TestContext.<anonymous> (file:///home/sid/repos/nostrify/packages/nostrify/uploaders/NostrBuildUploader.test.ts:22:18)
117
+ at async Test.run (node:internal/test_runner/test:1088:7)
118
+ at async startSubtestAfterBootstrap (node:internal/test_runner/harness:332:3)
119
+ at async file:///home/sid/repos/nostrify/packages/nostrify/uploaders/NostrBuildUploader.test.ts:10:1 {
120
+ issues: [ { code: 'invalid_type', expected: 'array', received: 'object', path: [Array], message: 'Expected array, received object' } ],
121
+ [errors]: [ { code: 'invalid_type', expected: 'array', received: 'object', path: [Array], message: 'Expected array, received object' } ]
122
+ }
123
+  ELIFECYCLE  Test failed. See above for more details.
package/BunkerURI.test.ts CHANGED
@@ -1,28 +1,33 @@
1
- import { assertEquals, assertObjectMatch } from '@std/assert';
1
+ import { test } from "node:test";
2
+ import { deepStrictEqual } from "node:assert";
2
3
 
3
- import { BunkerURI } from './BunkerURI.ts';
4
+ import { BunkerURI } from "./BunkerURI.ts";
4
5
 
5
- Deno.test('BunkerURI', () => {
6
+ await test("BunkerURI", () => {
6
7
  const uri = new BunkerURI(
7
- 'bunker://79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798?relay=wss%3A%2F%2Fditto.pub%2Frelay&secret=piAuZsxgKlil',
8
+ "bunker://79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798?relay=wss%3A%2F%2Fditto.pub%2Frelay&secret=piAuZsxgKlil",
8
9
  );
9
10
 
10
- assertObjectMatch(uri, {
11
- pubkey: '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
12
- relays: ['wss://ditto.pub/relay'],
13
- secret: 'piAuZsxgKlil',
11
+ deepStrictEqual({
12
+ pubkey: uri.pubkey,
13
+ relays: uri.relays,
14
+ secret: uri.secret,
15
+ }, {
16
+ pubkey: "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
17
+ relays: ["wss://ditto.pub/relay"],
18
+ secret: "piAuZsxgKlil",
14
19
  });
15
20
  });
16
21
 
17
- Deno.test('BunkerURI.fromJSON', () => {
22
+ await test("BunkerURI.fromJSON", () => {
18
23
  const result = BunkerURI.fromJSON({
19
- pubkey: '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
20
- relays: ['wss://ditto.pub/relay'],
21
- secret: 'piAuZsxgKlil',
24
+ pubkey: "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
25
+ relays: ["wss://ditto.pub/relay"],
26
+ secret: "piAuZsxgKlil",
22
27
  });
23
28
 
24
29
  const expected =
25
- 'bunker://79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798?relay=wss%3A%2F%2Fditto.pub%2Frelay&secret=piAuZsxgKlil';
30
+ "bunker://79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798?relay=wss%3A%2F%2Fditto.pub%2Frelay&secret=piAuZsxgKlil";
26
31
 
27
- assertEquals(result.toString(), expected);
32
+ deepStrictEqual(result.toString(), expected);
28
33
  });
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.46.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Get tests passing in CI, use esbuild to build final JS files
8
+ - Updated dependencies
9
+ - @nostrify/types@0.36.4
10
+
3
11
  ## 0.46.7
4
12
 
5
13
  ### Patch Changes
@@ -1,31 +1,38 @@
1
- import { NSecSigner } from '@nostrify/nostrify';
2
- import { assertEquals, assertRejects } from '@std/assert';
3
- import { finalizeEvent, generateSecretKey, getPublicKey } from 'nostr-tools';
1
+ import { test } from "node:test";
2
+ import { NSecSigner } from "@nostrify/nostrify";
3
+ import { deepStrictEqual, rejects } from "node:assert";
4
+ import { finalizeEvent, generateSecretKey, getPublicKey } from "nostr-tools";
4
5
 
5
- import { NBrowserSigner } from './NBrowserSigner.ts';
6
+ import { NBrowserSigner } from "./NBrowserSigner.ts";
6
7
 
7
- import type { NostrEvent, NostrSigner } from '@nostrify/types';
8
+ import type { NostrEvent, NostrSigner } from "@nostrify/types";
8
9
 
9
- Deno.test('NBrowserSigner - without extension', async () => {
10
+ await test("NBrowserSigner - without extension", async () => {
10
11
  // Ensure no extension is available
11
12
  (globalThis as { nostr?: NostrSigner }).nostr = undefined;
12
13
 
13
14
  const signer = new NBrowserSigner();
14
15
 
15
- await assertRejects(
16
+ await rejects(
16
17
  () => signer.getPublicKey(),
17
18
  Error,
18
- 'Browser extension not available',
19
+ "Browser extension not available",
19
20
  );
20
21
 
21
- await assertRejects(
22
- () => signer.signEvent({ kind: 1, content: 'Hello, world!', tags: [], created_at: 0 }),
22
+ await rejects(
23
+ () =>
24
+ signer.signEvent({
25
+ kind: 1,
26
+ content: "Hello, world!",
27
+ tags: [],
28
+ created_at: 0,
29
+ }),
23
30
  Error,
24
- 'Browser extension not available',
31
+ "Browser extension not available",
25
32
  );
26
33
  });
27
34
 
28
- Deno.test('NBrowserSigner - with extension polyfill', async () => {
35
+ await test("NBrowserSigner - with extension polyfill", async () => {
29
36
  const secretKey = generateSecretKey();
30
37
  const mockExtension = new NSecSigner(secretKey);
31
38
 
@@ -35,17 +42,25 @@ Deno.test('NBrowserSigner - with extension polyfill', async () => {
35
42
  const signer = new NBrowserSigner();
36
43
 
37
44
  // Test getPublicKey
38
- assertEquals(await signer.getPublicKey(), getPublicKey(secretKey));
45
+ deepStrictEqual(await signer.getPublicKey(), getPublicKey(secretKey));
39
46
 
40
47
  // Test signEvent
41
- const template = { kind: 1, content: 'Hello, world!', tags: [], created_at: 0 };
42
- assertEquals(await signer.signEvent(template), finalizeEvent(template, secretKey));
48
+ const template = {
49
+ kind: 1,
50
+ content: "Hello, world!",
51
+ tags: [],
52
+ created_at: 0,
53
+ };
54
+ deepStrictEqual(
55
+ await signer.signEvent(template),
56
+ finalizeEvent(template, secretKey),
57
+ );
43
58
 
44
59
  // Clean up
45
60
  (globalThis as { nostr?: NostrSigner }).nostr = undefined;
46
61
  });
47
62
 
48
- Deno.test('NBrowserSigner.nip44 - with extension polyfill', async () => {
63
+ await test("NBrowserSigner.nip44 - with extension polyfill", async () => {
49
64
  const secretKey = generateSecretKey();
50
65
  const mockExtension = new NSecSigner(secretKey);
51
66
 
@@ -55,16 +70,16 @@ Deno.test('NBrowserSigner.nip44 - with extension polyfill', async () => {
55
70
  const signer = new NBrowserSigner();
56
71
 
57
72
  const pubkey = await signer.getPublicKey();
58
- const plaintext = 'Hello, world!';
73
+ const plaintext = "Hello, world!";
59
74
 
60
75
  const ciphertext = await signer.nip44!.encrypt(pubkey, plaintext);
61
- assertEquals(await signer.nip44!.decrypt(pubkey, ciphertext), plaintext);
76
+ deepStrictEqual(await signer.nip44!.decrypt(pubkey, ciphertext), plaintext);
62
77
 
63
78
  // Clean up
64
79
  (globalThis as { nostr?: NostrSigner }).nostr = undefined;
65
80
  });
66
81
 
67
- Deno.test('NBrowserSigner.nip04 - with extension polyfill', async () => {
82
+ await test("NBrowserSigner.nip04 - with extension polyfill", async () => {
68
83
  const secretKey = generateSecretKey();
69
84
  const mockExtension = new NSecSigner(secretKey);
70
85
 
@@ -74,16 +89,16 @@ Deno.test('NBrowserSigner.nip04 - with extension polyfill', async () => {
74
89
  const signer = new NBrowserSigner();
75
90
 
76
91
  const pubkey = await signer.getPublicKey();
77
- const plaintext = 'Hello, world!';
92
+ const plaintext = "Hello, world!";
78
93
 
79
94
  const ciphertext = await signer.nip04!.encrypt(pubkey, plaintext);
80
- assertEquals(await signer.nip04!.decrypt(pubkey, ciphertext), plaintext);
95
+ deepStrictEqual(await signer.nip04!.decrypt(pubkey, ciphertext), plaintext);
81
96
 
82
97
  // Clean up
83
98
  (globalThis as { nostr?: NostrSigner }).nostr = undefined;
84
99
  });
85
100
 
86
- Deno.test('NBrowserSigner.getRelays - with extension polyfill', async () => {
101
+ await test("NBrowserSigner.getRelays - with extension polyfill", async () => {
87
102
  const secretKey = generateSecretKey();
88
103
  const mockExtension = new NSecSigner(secretKey);
89
104
 
@@ -94,17 +109,17 @@ Deno.test('NBrowserSigner.getRelays - with extension polyfill', async () => {
94
109
 
95
110
  // Since NSecSigner doesn't implement getRelays, this should return empty object
96
111
  const relays = await signer.getRelays();
97
- assertEquals(relays, {});
112
+ deepStrictEqual(relays, {});
98
113
 
99
114
  // Clean up
100
115
  (globalThis as { nostr?: NostrSigner }).nostr = undefined;
101
116
  });
102
117
 
103
- Deno.test('NBrowserSigner - missing nip44 support', () => {
118
+ await test("NBrowserSigner - missing nip44 support", () => {
104
119
  // Create a mock extension without nip44 support
105
120
  const mockExtension = {
106
121
  // deno-lint-ignore require-await
107
- getPublicKey: async () => 'pubkey',
122
+ getPublicKey: async () => "pubkey",
108
123
  // deno-lint-ignore require-await
109
124
  signEvent: async (event: NostrEvent) => event,
110
125
  // No nip44 property
@@ -115,17 +130,17 @@ Deno.test('NBrowserSigner - missing nip44 support', () => {
115
130
  const signer = new NBrowserSigner();
116
131
 
117
132
  // Should return undefined when nip44 is not supported
118
- assertEquals(signer.nip44, undefined);
133
+ deepStrictEqual(signer.nip44, undefined);
119
134
 
120
135
  // Clean up
121
136
  (globalThis as { nostr?: NostrSigner }).nostr = undefined;
122
137
  });
123
138
 
124
- Deno.test('NBrowserSigner - missing nip04 support', () => {
139
+ await test("NBrowserSigner - missing nip04 support", () => {
125
140
  // Create a mock extension without nip04 support
126
141
  const mockExtension = {
127
142
  // deno-lint-ignore require-await
128
- getPublicKey: async () => 'pubkey',
143
+ getPublicKey: async () => "pubkey",
129
144
  // deno-lint-ignore require-await
130
145
  signEvent: async (event: NostrEvent) => event,
131
146
  // No nip04 property
@@ -136,13 +151,13 @@ Deno.test('NBrowserSigner - missing nip04 support', () => {
136
151
  const signer = new NBrowserSigner();
137
152
 
138
153
  // Should return undefined when nip04 is not supported
139
- assertEquals(signer.nip04, undefined);
154
+ deepStrictEqual(signer.nip04, undefined);
140
155
 
141
156
  // Clean up
142
157
  (globalThis as { nostr?: NostrSigner }).nostr = undefined;
143
158
  });
144
159
 
145
- Deno.test('NBrowserSigner - feature detection', () => {
160
+ await test("NBrowserSigner - feature detection", () => {
146
161
  const secretKey = generateSecretKey();
147
162
  const mockExtension = new NSecSigner(secretKey);
148
163
 
@@ -154,15 +169,15 @@ Deno.test('NBrowserSigner - feature detection', () => {
154
169
  // Should be able to detect nip44 support
155
170
  if (signer.nip44) {
156
171
  // This should work since NSecSigner supports nip44
157
- assertEquals(typeof signer.nip44.encrypt, 'function');
158
- assertEquals(typeof signer.nip44.decrypt, 'function');
172
+ deepStrictEqual(typeof signer.nip44.encrypt, "function");
173
+ deepStrictEqual(typeof signer.nip44.decrypt, "function");
159
174
  }
160
175
 
161
176
  // Should be able to detect nip04 support
162
177
  if (signer.nip04) {
163
178
  // This should work since NSecSigner supports nip04
164
- assertEquals(typeof signer.nip04.encrypt, 'function');
165
- assertEquals(typeof signer.nip04.decrypt, 'function');
179
+ deepStrictEqual(typeof signer.nip04.encrypt, "function");
180
+ deepStrictEqual(typeof signer.nip04.decrypt, "function");
166
181
  }
167
182
 
168
183
  // Clean up
package/NCache.test.ts CHANGED
@@ -1,22 +1,29 @@
1
- import { assertEquals } from '@std/assert';
1
+ import { test } from "node:test";
2
+ import { deepStrictEqual } from "node:assert";
2
3
 
3
- import { NCache } from './NCache.ts';
4
+ import { NCache } from "./NCache.ts";
4
5
 
5
- import event1 from '../../fixtures/event-1.json' with { type: 'json' };
6
+ import event1 from "../../fixtures/event-1.json" with { type: "json" };
6
7
 
7
- Deno.test('NCache', async () => {
8
+ await test("NCache", async () => {
8
9
  const cache = new NCache({
9
10
  max: 3000,
10
11
  maxEntrySize: 5000,
11
12
  sizeCalculation: (event) => JSON.stringify(event).length,
12
13
  });
13
14
 
14
- assertEquals(await cache.count([{ ids: [event1.id] }]), { count: 0, approximate: false });
15
+ deepStrictEqual(await cache.count([{ ids: [event1.id] }]), {
16
+ count: 0,
17
+ approximate: false,
18
+ });
15
19
 
16
20
  await cache.event(event1);
17
21
 
18
- assertEquals(await cache.count([{ ids: [event1.id] }]), { count: 1, approximate: false });
22
+ deepStrictEqual(await cache.count([{ ids: [event1.id] }]), {
23
+ count: 1,
24
+ approximate: false,
25
+ });
19
26
 
20
27
  const result = await cache.query([{ ids: [event1.id] }]);
21
- assertEquals(result[0], event1);
28
+ deepStrictEqual(result[0], event1);
22
29
  });
package/NCache.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  // deno-lint-ignore-file require-await
2
2
 
3
- import { NostrEvent, NostrFilter, NostrRelayCOUNT, NStore } from '@nostrify/types';
3
+ import type { NostrEvent, NostrFilter, NostrRelayCOUNT, NStore } from '@nostrify/types';
4
4
  import { LRUCache } from 'lru-cache';
5
5
  import { matchFilters } from 'nostr-tools';
6
6
 
7
- import { NSet } from './NSet.js';
7
+ import { NSet } from './NSet.ts';
8
8
 
9
9
  /**
10
10
  * Nostr LRU cache based on [`npm:lru-cache`](https://www.npmjs.com/package/lru-cache).
@@ -1,13 +1,14 @@
1
- import { NostrConnectResponse } from '@nostrify/types';
2
- import { assert, assertEquals } from '@std/assert';
3
- import { generateSecretKey, verifyEvent } from 'nostr-tools';
1
+ import { test } from "node:test";
2
+ import type { NostrConnectResponse } from "@nostrify/types";
3
+ import { deepStrictEqual, ok } from "node:assert";
4
+ import { generateSecretKey, verifyEvent } from "nostr-tools";
4
5
 
5
- import { MockRelay } from './test/MockRelay.ts';
6
- import { NConnectSigner } from './NConnectSigner.ts';
7
- import { NSchema as n } from './NSchema.ts';
8
- import { NSecSigner } from './NSecSigner.ts';
6
+ import { MockRelay } from "./test/MockRelay.ts";
7
+ import { NConnectSigner } from "./NConnectSigner.ts";
8
+ import { NSchema as n } from "./NSchema.ts";
9
+ import { NSecSigner } from "./NSecSigner.ts";
9
10
 
10
- Deno.test('NConnectSigner.signEvent with nip04 encryption', async () => {
11
+ await test("NConnectSigner.signEvent with nip04 encryption", async () => {
11
12
  const relay = new MockRelay();
12
13
  const remote = new NSecSigner(generateSecretKey());
13
14
  const pubkey = await remote.getPublicKey();
@@ -16,33 +17,41 @@ Deno.test('NConnectSigner.signEvent with nip04 encryption', async () => {
16
17
  relay,
17
18
  pubkey,
18
19
  signer: new NSecSigner(generateSecretKey()),
19
- encryption: 'nip04',
20
+ encryption: "nip04",
20
21
  });
21
22
 
22
- const req = relay.req([{ kinds: [24133], '#p': [pubkey] }]);
23
+ const req = relay.req([{ kinds: [24133], "#p": [pubkey] }]);
23
24
 
24
25
  const promise = connect.signEvent({
25
26
  kind: 1,
26
- content: 'hello world',
27
+ content: "hello world",
27
28
  tags: [],
28
29
  created_at: Math.floor(Date.now() / 1000),
29
30
  });
30
31
 
31
32
  for await (const msg of req) {
32
- if (msg[0] === 'EVENT') {
33
+ if (msg[0] === "EVENT") {
33
34
  const event = msg[2];
34
- const decrypted = await remote.nip04!.decrypt(event.pubkey, event.content);
35
+ const decrypted = await remote.nip04!.decrypt(
36
+ event.pubkey,
37
+ event.content,
38
+ );
35
39
  const request = n.json().pipe(n.connectRequest()).parse(decrypted);
36
- assertEquals(request.method, 'sign_event');
40
+ deepStrictEqual(request.method, "sign_event");
37
41
  const response: NostrConnectResponse = {
38
42
  id: request.id,
39
- result: JSON.stringify(await remote.signEvent(JSON.parse(request.params[0]))),
43
+ result: JSON.stringify(
44
+ await remote.signEvent(JSON.parse(request.params[0])),
45
+ ),
40
46
  };
41
47
  await relay.event(
42
48
  await remote.signEvent({
43
49
  kind: 24133,
44
- content: await remote.nip04!.encrypt(event.pubkey, JSON.stringify(response)),
45
- tags: [['p', event.pubkey]],
50
+ content: await remote.nip04!.encrypt(
51
+ event.pubkey,
52
+ JSON.stringify(response),
53
+ ),
54
+ tags: [["p", event.pubkey]],
46
55
  created_at: Math.floor(Date.now() / 1000),
47
56
  }),
48
57
  );
@@ -50,11 +59,11 @@ Deno.test('NConnectSigner.signEvent with nip04 encryption', async () => {
50
59
  }
51
60
  }
52
61
 
53
- assert(verifyEvent(await promise));
54
- assertEquals(relay.subs.size, 0); // cleanup
62
+ ok(verifyEvent(await promise));
63
+ deepStrictEqual(relay.subs.size, 0); // cleanup
55
64
  });
56
65
 
57
- Deno.test('NConnectSigner.signEvent with nip44 encryption', async () => {
66
+ await test("NConnectSigner.signEvent with nip44 encryption", async () => {
58
67
  const relay = new MockRelay();
59
68
  const remote = new NSecSigner(generateSecretKey());
60
69
  const pubkey = await remote.getPublicKey();
@@ -63,33 +72,41 @@ Deno.test('NConnectSigner.signEvent with nip44 encryption', async () => {
63
72
  relay,
64
73
  pubkey,
65
74
  signer: new NSecSigner(generateSecretKey()),
66
- encryption: 'nip44',
75
+ encryption: "nip44",
67
76
  });
68
77
 
69
- const req = relay.req([{ kinds: [24133], '#p': [pubkey] }]);
78
+ const req = relay.req([{ kinds: [24133], "#p": [pubkey] }]);
70
79
 
71
80
  const promise = connect.signEvent({
72
81
  kind: 1,
73
- content: 'hello world',
82
+ content: "hello world",
74
83
  tags: [],
75
84
  created_at: Math.floor(Date.now() / 1000),
76
85
  });
77
86
 
78
87
  for await (const msg of req) {
79
- if (msg[0] === 'EVENT') {
88
+ if (msg[0] === "EVENT") {
80
89
  const event = msg[2];
81
- const decrypted = await remote.nip44!.decrypt(event.pubkey, event.content);
90
+ const decrypted = await remote.nip44!.decrypt(
91
+ event.pubkey,
92
+ event.content,
93
+ );
82
94
  const request = n.json().pipe(n.connectRequest()).parse(decrypted);
83
- assertEquals(request.method, 'sign_event');
95
+ deepStrictEqual(request.method, "sign_event");
84
96
  const response: NostrConnectResponse = {
85
97
  id: request.id,
86
- result: JSON.stringify(await remote.signEvent(JSON.parse(request.params[0]))),
98
+ result: JSON.stringify(
99
+ await remote.signEvent(JSON.parse(request.params[0])),
100
+ ),
87
101
  };
88
102
  await relay.event(
89
103
  await remote.signEvent({
90
104
  kind: 24133,
91
- content: await remote.nip44!.encrypt(event.pubkey, JSON.stringify(response)),
92
- tags: [['p', event.pubkey]],
105
+ content: await remote.nip44!.encrypt(
106
+ event.pubkey,
107
+ JSON.stringify(response),
108
+ ),
109
+ tags: [["p", event.pubkey]],
93
110
  created_at: Math.floor(Date.now() / 1000),
94
111
  }),
95
112
  );
@@ -97,6 +114,6 @@ Deno.test('NConnectSigner.signEvent with nip44 encryption', async () => {
97
114
  }
98
115
  }
99
116
 
100
- assert(verifyEvent(await promise));
101
- assertEquals(relay.subs.size, 0); // cleanup
117
+ ok(verifyEvent(await promise));
118
+ deepStrictEqual(relay.subs.size, 0); // cleanup
102
119
  });
package/NConnectSigner.ts CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  import { z } from 'zod';
4
4
 
5
- import { NostrConnectRequest, NostrConnectResponse, NostrEvent, NostrSigner, NRelay } from '@nostrify/types';
5
+ import type { NostrConnectRequest, NostrConnectResponse, NostrEvent, NostrSigner, NRelay } from '@nostrify/types';
6
6
 
7
- import { NSchema as n } from './NSchema.js';
7
+ import { NSchema as n } from './NSchema.ts';
8
8
 
9
9
  /** Options for `NConnectSigner`. */
10
10
  export interface NConnectSignerOpts {
@@ -62,7 +62,7 @@ export class NConnectSigner implements NostrSigner {
62
62
  z.object({ read: z.boolean(), write: z.boolean() }),
63
63
  ),
64
64
  )
65
- .parse(result);
65
+ .parse(result) as Record<string, { read: boolean; write: boolean }>; // FIXME: hack!
66
66
  }
67
67
 
68
68
  readonly nip04 = {