@nostrify/policies 0.36.5 → 0.36.7

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 (133) hide show
  1. package/.turbo/turbo-build.log +24 -2
  2. package/.turbo/turbo-setup.log +22 -0
  3. package/.turbo/turbo-test.log +53 -0
  4. package/AntiDuplicationPolicy.test.ts +54 -41
  5. package/AntiDuplicationPolicy.ts +7 -3
  6. package/AnyPolicy.test.ts +15 -14
  7. package/AnyPolicy.ts +5 -2
  8. package/AuthorPolicy.test.ts +8 -7
  9. package/AuthorPolicy.ts +9 -3
  10. package/CHANGELOG.md +18 -0
  11. package/DomainPolicy.test.ts +130 -77
  12. package/DomainPolicy.ts +3 -3
  13. package/FiltersPolicy.test.ts +14 -7
  14. package/FiltersPolicy.ts +5 -2
  15. package/HashtagPolicy.test.ts +25 -14
  16. package/HashtagPolicy.ts +5 -2
  17. package/HellthreadPolicy.test.ts +10 -9
  18. package/HellthreadPolicy.ts +6 -3
  19. package/InvertPolicy.test.ts +10 -9
  20. package/InvertPolicy.ts +8 -2
  21. package/KeywordPolicy.test.ts +18 -12
  22. package/KeywordPolicy.ts +5 -2
  23. package/NoOpPolicy.test.ts +8 -7
  24. package/NoOpPolicy.ts +1 -1
  25. package/OpenAIPolicy.test.ts +22 -9
  26. package/OpenAIPolicy.ts +5 -2
  27. package/PipePolicy.test.ts +18 -17
  28. package/PipePolicy.ts +5 -2
  29. package/PowPolicy.test.ts +14 -13
  30. package/PowPolicy.ts +6 -3
  31. package/PubkeyBanPolicy.test.ts +15 -8
  32. package/PubkeyBanPolicy.ts +5 -2
  33. package/ReadOnlyPolicy.test.ts +9 -8
  34. package/ReadOnlyPolicy.ts +1 -1
  35. package/RegexPolicy.test.ts +19 -10
  36. package/RegexPolicy.ts +5 -2
  37. package/ReplyBotPolicy.test.ts +43 -27
  38. package/ReplyBotPolicy.ts +6 -3
  39. package/SizePolicy.test.ts +9 -8
  40. package/SizePolicy.ts +6 -2
  41. package/WhitelistPolicy.test.ts +15 -8
  42. package/WhitelistPolicy.ts +6 -2
  43. package/WoTPolicy.test.ts +48 -22
  44. package/WoTPolicy.ts +5 -2
  45. package/mod.ts +20 -20
  46. package/package.json +8 -6
  47. package/tsconfig.json +3 -1
  48. package/.turbo/daemon/7bb8240f68f7ad88-turbo.log.2025-07-29 +0 -0
  49. package/dist/AntiDuplicationPolicy.d.ts +0 -43
  50. package/dist/AntiDuplicationPolicy.d.ts.map +0 -1
  51. package/dist/AntiDuplicationPolicy.js +0 -59
  52. package/dist/AntiDuplicationPolicy.js.map +0 -1
  53. package/dist/AnyPolicy.d.ts +0 -8
  54. package/dist/AnyPolicy.d.ts.map +0 -1
  55. package/dist/AnyPolicy.js +0 -19
  56. package/dist/AnyPolicy.js.map +0 -1
  57. package/dist/AuthorPolicy.d.ts +0 -9
  58. package/dist/AuthorPolicy.d.ts.map +0 -1
  59. package/dist/AuthorPolicy.js +0 -23
  60. package/dist/AuthorPolicy.js.map +0 -1
  61. package/dist/DomainPolicy.d.ts +0 -21
  62. package/dist/DomainPolicy.d.ts.map +0 -1
  63. package/dist/DomainPolicy.js +0 -64
  64. package/dist/DomainPolicy.js.map +0 -1
  65. package/dist/FiltersPolicy.d.ts +0 -18
  66. package/dist/FiltersPolicy.d.ts.map +0 -1
  67. package/dist/FiltersPolicy.js +0 -26
  68. package/dist/FiltersPolicy.js.map +0 -1
  69. package/dist/HashtagPolicy.d.ts +0 -16
  70. package/dist/HashtagPolicy.d.ts.map +0 -1
  71. package/dist/HashtagPolicy.js +0 -25
  72. package/dist/HashtagPolicy.js.map +0 -1
  73. package/dist/HellthreadPolicy.d.ts +0 -14
  74. package/dist/HellthreadPolicy.d.ts.map +0 -1
  75. package/dist/HellthreadPolicy.js +0 -19
  76. package/dist/HellthreadPolicy.js.map +0 -1
  77. package/dist/InvertPolicy.d.ts +0 -9
  78. package/dist/InvertPolicy.d.ts.map +0 -1
  79. package/dist/InvertPolicy.js +0 -20
  80. package/dist/InvertPolicy.js.map +0 -1
  81. package/dist/KeywordPolicy.d.ts +0 -16
  82. package/dist/KeywordPolicy.d.ts.map +0 -1
  83. package/dist/KeywordPolicy.js +0 -25
  84. package/dist/KeywordPolicy.js.map +0 -1
  85. package/dist/NoOpPolicy.d.ts +0 -6
  86. package/dist/NoOpPolicy.d.ts.map +0 -1
  87. package/dist/NoOpPolicy.js +0 -8
  88. package/dist/NoOpPolicy.js.map +0 -1
  89. package/dist/OpenAIPolicy.d.ts +0 -80
  90. package/dist/OpenAIPolicy.d.ts.map +0 -1
  91. package/dist/OpenAIPolicy.js +0 -58
  92. package/dist/OpenAIPolicy.js.map +0 -1
  93. package/dist/PipePolicy.d.ts +0 -26
  94. package/dist/PipePolicy.d.ts.map +0 -1
  95. package/dist/PipePolicy.js +0 -35
  96. package/dist/PipePolicy.js.map +0 -1
  97. package/dist/PowPolicy.d.ts +0 -21
  98. package/dist/PowPolicy.d.ts.map +0 -1
  99. package/dist/PowPolicy.js +0 -32
  100. package/dist/PowPolicy.js.map +0 -1
  101. package/dist/PubkeyBanPolicy.d.ts +0 -15
  102. package/dist/PubkeyBanPolicy.d.ts.map +0 -1
  103. package/dist/PubkeyBanPolicy.js +0 -24
  104. package/dist/PubkeyBanPolicy.js.map +0 -1
  105. package/dist/ReadOnlyPolicy.d.ts +0 -6
  106. package/dist/ReadOnlyPolicy.d.ts.map +0 -1
  107. package/dist/ReadOnlyPolicy.js +0 -8
  108. package/dist/ReadOnlyPolicy.js.map +0 -1
  109. package/dist/RegexPolicy.d.ts +0 -15
  110. package/dist/RegexPolicy.d.ts.map +0 -1
  111. package/dist/RegexPolicy.js +0 -22
  112. package/dist/RegexPolicy.js.map +0 -1
  113. package/dist/ReplyBotPolicy.d.ts +0 -25
  114. package/dist/ReplyBotPolicy.d.ts.map +0 -1
  115. package/dist/ReplyBotPolicy.js +0 -41
  116. package/dist/ReplyBotPolicy.js.map +0 -1
  117. package/dist/SizePolicy.d.ts +0 -23
  118. package/dist/SizePolicy.d.ts.map +0 -1
  119. package/dist/SizePolicy.js +0 -27
  120. package/dist/SizePolicy.js.map +0 -1
  121. package/dist/WhitelistPolicy.d.ts +0 -16
  122. package/dist/WhitelistPolicy.d.ts.map +0 -1
  123. package/dist/WhitelistPolicy.js +0 -31
  124. package/dist/WhitelistPolicy.js.map +0 -1
  125. package/dist/WoTPolicy.d.ts +0 -26
  126. package/dist/WoTPolicy.d.ts.map +0 -1
  127. package/dist/WoTPolicy.js +0 -38
  128. package/dist/WoTPolicy.js.map +0 -1
  129. package/dist/mod.d.ts +0 -21
  130. package/dist/mod.d.ts.map +0 -1
  131. package/dist/mod.js +0 -21
  132. package/dist/mod.js.map +0 -1
  133. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,5 +1,27 @@
1
1
 
2
2
 
3
- > @nostrify/policies@0.36.5 build /home/sid/repos/NSpec/packages/policies
4
- > tsc -p tsconfig.json
3
+ > @nostrify/policies@0.36.6 build /home/sid/repos/nostrify/packages/policies
4
+ > tsc -p tsconfig.json && node ../../esbuild.config.js --package ./
5
5
 
6
+
7
+ dist/DomainPolicy.js 2.1kb
8
+ dist/ReplyBotPolicy.js 1.4kb
9
+ dist/mod.js 1.3kb
10
+ dist/AntiDuplicationPolicy.js 1.2kb
11
+ dist/WoTPolicy.js 1.0kb
12
+ dist/OpenAIPolicy.js 985b 
13
+ dist/PowPolicy.js 667b 
14
+ dist/AuthorPolicy.js 640b 
15
+ dist/HellthreadPolicy.js 494b 
16
+ dist/WhitelistPolicy.js 490b 
17
+ dist/SizePolicy.js 453b 
18
+ dist/HashtagPolicy.js 425b 
19
+ dist/AnyPolicy.js 412b 
20
+ dist/KeywordPolicy.js 411b 
21
+ dist/FiltersPolicy.js 410b 
22
+ dist/InvertPolicy.js 385b 
23
+ dist/PipePolicy.js 383b 
24
+ dist/PubkeyBanPolicy.js 367b 
25
+ ...and 3 more output files...
26
+
27
+ ⚡ Done in 23ms
@@ -0,0 +1,22 @@
1
+
2
+
3
+ > @nostrify/policies@0.36.5 setup /home/sid/repos/nostrify/packages/policies
4
+ > pnpm i
5
+
6
+ (node:1234136) [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
14
+  WARN  Failed to create bin at /home/sid/repos/nostrify/node_modules/.pnpm/node_modules/.bin/semver. ENOENT: no such file or directory, chmod '/home/sid/repos/nostrify/node_modules/.pnpm/node_modules/.bin/semver'
15
+  WARN  Failed to create bin at /home/sid/repos/nostrify/node_modules/.pnpm/node_modules/.bin/arborist. ENOENT: no such file or directory, chmod '/home/sid/repos/nostrify/node_modules/.pnpm/node_modules/.bin/arborist'
16
+  WARN  Failed to create bin at /home/sid/repos/nostrify/node_modules/.pnpm/node_modules/.bin/vite. ENOENT: no such file or directory, chmod '/home/sid/repos/nostrify/node_modules/.pnpm/node_modules/.bin/vite'
17
+  WARN  Failed to create bin at /home/sid/repos/nostrify/node_modules/.pnpm/node_modules/.bin/color-support. ENOENT: no such file or directory, chmod '/home/sid/repos/nostrify/node_modules/.pnpm/node_modules/.bin/color-support'
18
+  WARN  Failed to create bin at /home/sid/repos/nostrify/node_modules/.pnpm/node_modules/.bin/uglifyjs. ENOENT: no such file or directory, chmod '/home/sid/repos/nostrify/node_modules/.pnpm/node_modules/.bin/uglifyjs'
19
+  WARN  1 other warnings
20
+  WARN  2 other warnings
21
+  WARN  3 other warnings
22
+  WARN  4 other warnings
@@ -0,0 +1,53 @@
1
+
2
+
3
+ > @nostrify/policies@0.36.6 test /home/sid/repos/nostrify/packages/policies
4
+ > node --test --test-concurrency=1 "**/*.test.ts"
5
+
6
+ ✔ AntiDuplicationPolicy (319.690432ms)
7
+ ✔ AntiDuplicationPolicy with deobfuscate (44.807015ms)
8
+ ✔ accepts when all policies accept (64.674178ms)
9
+ ✔ accepts when some policies reject (8.399958ms)
10
+ ✔ rejects when all policies reject (5.373917ms)
11
+ ✔ AuthorPolicy (48.081135ms)
12
+ ✔ DomainPolicy allows events from authors with a valid nip05 (46.436288ms)
13
+ ✔ DomainPolicy rejects events from authors without a kind 0 (4.13101ms)
14
+ ✔ DomainPolicy rejects events from authors with a missing nip05 (9.361192ms)
15
+ ✔ DomainPolicy rejects events from authors with a malformed nip05 (11.704458ms)
16
+ ✔ DomainPolicy rejects events from authors with an invalid nip05 (9.725418ms)
17
+ ✔ DomainPolicy rejects events from authors with a blacklisted nip05 domain (12.135733ms)
18
+ ✔ DomainPolicy rejects events from authors who aren't on a whitelisted domain (8.181353ms)
19
+ ✔ DomainPolicy allows events from authors who are on a whitelisted domain (9.511213ms)
20
+ ✔ DomainPolicy rejects events from authors with a subdomain of a blacklisted domain (8.78339ms)
21
+ ✔ DomainPolicy rejects events from authors with a deeply nested subdomain of a blacklisted domain (8.255036ms)
22
+ ✔ DomainPolicy allows events from authors with similar but not subdomain of blacklisted domain (8.391158ms)
23
+ ✔ FiltersPolicy (47.201126ms)
24
+ ✔ HashtagPolicy (57.834978ms)
25
+ ✔ HellthreadPolicy (47.231857ms)
26
+ ✔ InvertPolicy (39.831057ms)
27
+ ✔ KeywordPolicy (52.182532ms)
28
+ ✔ NoOpPolicy (38.95077ms)
29
+ ✔ rejects flagged events (95.404554ms)
30
+ ✔ accepts unflagged events (58.128733ms)
31
+ ✔ passes events through multiple policies (38.444137ms)
32
+ ✔ short-circuits on the first reject (5.71684ms)
33
+ ✔ accepts when all policies accept (4.445368ms)
34
+ ✔ blocks events without a nonce (37.656948ms)
35
+ ✔ accepts event with sufficient POW (0.213227ms)
36
+ ✔ PubkeyBanPolicy (52.882068ms)
37
+ ✔ ReadOnlyPolicy (37.273237ms)
38
+ ✔ RegexPolicy (42.23802ms)
39
+ ✔ ReplyBotPolicy blocks replies within the same second (44.754564ms)
40
+ ✔ ReplyBotPolicy allows replies after 1 second (9.42384ms)
41
+ ✔ ReplyBotPolicy allows replies within the same second from users who are tagged (11.768783ms)
42
+ ✔ SizePolicy (47.893399ms)
43
+ ✔ WhitelistPolicy (48.551241ms)
44
+ ✔ WoTPolicy (74.334084ms)
45
+ ✔ WoTPolicy constructor with error store (0.898097ms)
46
+ ℹ tests 40
47
+ ℹ suites 0
48
+ ℹ pass 40
49
+ ℹ fail 0
50
+ ℹ cancelled 0
51
+ ℹ skipped 0
52
+ ℹ todo 0
53
+ ℹ duration_ms 5386.054741
@@ -1,50 +1,63 @@
1
- import { genEvent } from '@nostrify/nostrify/test';
2
- import { assertEquals } from '@std/assert';
1
+ import { test } from "node:test";
2
+ import { genEvent } from "@nostrify/nostrify/test";
3
+ import { deepStrictEqual } from "node:assert";
4
+ import { openKv } from "@deno/kv";
3
5
 
4
- import { AntiDuplicationPolicy } from './AntiDuplicationPolicy.ts';
6
+ import { AntiDuplicationPolicy } from "./AntiDuplicationPolicy.ts";
5
7
 
6
- Deno.test('AntiDuplicationPolicy', async () => {
7
- using kv = await Deno.openKv(':memory:');
8
+ await test("AntiDuplicationPolicy", async () => {
9
+ const kv = await openKv(":memory:");
10
+ try {
11
+ const policy = new AntiDuplicationPolicy({ kv });
12
+ const content =
13
+ "Spicy peppermint apricot mediterranean ginger carrot spiced juice edamame hummus";
8
14
 
9
- const policy = new AntiDuplicationPolicy({ kv });
10
- const content = 'Spicy peppermint apricot mediterranean ginger carrot spiced juice edamame hummus';
15
+ const event1 = genEvent({ kind: 1, content });
11
16
 
12
- const event1 = genEvent({ kind: 1, content });
17
+ deepStrictEqual((await policy.call(event1))[2], true);
18
+ deepStrictEqual((await policy.call(event1))[2], false);
19
+ deepStrictEqual((await policy.call(event1))[2], false);
13
20
 
14
- assertEquals((await policy.call(event1))[2], true);
15
- assertEquals((await policy.call(event1))[2], false);
16
- assertEquals((await policy.call(event1))[2], false);
21
+ const event2 = genEvent({ kind: 1, content: "a" });
17
22
 
18
- const event2 = genEvent({ kind: 1, content: 'a' });
19
-
20
- assertEquals((await policy.call(event2))[2], true);
21
- assertEquals((await policy.call(event2))[2], true);
22
- assertEquals((await policy.call(event2))[2], true);
23
+ deepStrictEqual((await policy.call(event2))[2], true);
24
+ deepStrictEqual((await policy.call(event2))[2], true);
25
+ } finally {
26
+ await kv.close();
27
+ }
23
28
  });
24
29
 
25
- Deno.test('AntiDuplicationPolicy with deobfuscate', async () => {
26
- using kv = await Deno.openKv(':memory:');
27
-
28
- const policy = new AntiDuplicationPolicy({
29
- kv,
30
- deobfuscate: ({ content }) => (
31
- content
32
- .replace(/[\p{Emoji}\p{Emoji_Modifier}\p{Emoji_Component}\p{Emoji_Modifier_Base}\p{Emoji_Presentation}]/gu, '')
33
- .replace(/\s/g, '')
34
- .toLowerCase()
35
- ),
36
- });
37
-
38
- const event1 = genEvent({
39
- kind: 1,
40
- content: 'Spicy peppermint apricot mediterranean ginger carrot spiced juice edamame hummus',
41
- });
42
-
43
- const event2 = genEvent({
44
- kind: 1,
45
- content: 'Spicy 🌶️ peppermint apricot 🍑 mediterranean 🌊 ginger carrot 🥕 spiced 🌶️ juice 🥤 edamame 🌱 hummus ',
46
- });
47
-
48
- assertEquals((await policy.call(event1))[2], true);
49
- assertEquals((await policy.call(event2))[2], false);
30
+ await test("AntiDuplicationPolicy with deobfuscate", async () => {
31
+ const kv = await openKv(":memory:");
32
+ try {
33
+ const policy = new AntiDuplicationPolicy({
34
+ kv,
35
+ deobfuscate: ({ content }) => (
36
+ content
37
+ .replace(
38
+ /[\p{Emoji}\p{Emoji_Modifier}\p{Emoji_Component}\p{Emoji_Modifier_Base}\p{Emoji_Presentation}]/gu,
39
+ "",
40
+ )
41
+ .replace(/\s/g, "")
42
+ .toLowerCase()
43
+ ),
44
+ });
45
+
46
+ const event1 = genEvent({
47
+ kind: 1,
48
+ content:
49
+ "Spicy peppermint apricot mediterranean ginger carrot spiced juice edamame hummus",
50
+ });
51
+
52
+ const event2 = genEvent({
53
+ kind: 1,
54
+ content:
55
+ "Spicy 🌶️ peppermint apricot 🍑 mediterranean 🌊 ginger carrot 🥕 spiced 🌶️ juice 🥤 edamame 🌱 hummus ",
56
+ });
57
+
58
+ deepStrictEqual((await policy.call(event1))[2], true);
59
+ deepStrictEqual((await policy.call(event2))[2], false);
60
+ } finally {
61
+ await kv.close();
62
+ }
50
63
  });
@@ -1,5 +1,5 @@
1
- import { NostrEvent, NostrRelayOK, NPolicy } from '@nostrify/types';
2
- import { Kv, KvKey } from '@deno/kv';
1
+ import type { NostrEvent, NostrRelayOK, NPolicy } from '@nostrify/types';
2
+ import type { Kv, KvKey } from '@deno/kv';
3
3
 
4
4
  /** Policy options for `AntiDuplicationPolicy`. */
5
5
  interface AntiDuplicationPolicyOpts {
@@ -31,7 +31,11 @@ interface AntiDuplicationPolicyOpts {
31
31
  * ```
32
32
  */
33
33
  export class AntiDuplicationPolicy implements NPolicy {
34
- constructor(private opts: AntiDuplicationPolicyOpts) {}
34
+ private opts: AntiDuplicationPolicyOpts;
35
+
36
+ constructor(opts: AntiDuplicationPolicyOpts) {
37
+ this.opts = opts;
38
+ }
35
39
 
36
40
  async call(event: NostrEvent): Promise<NostrRelayOK> {
37
41
  const { id, kind } = event;
package/AnyPolicy.test.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { assertEquals } from '@std/assert';
2
- import { finalizeEvent, generateSecretKey } from 'nostr-tools';
1
+ import { test } from "node:test";
2
+ import { deepStrictEqual } from "node:assert";
3
+ import { finalizeEvent, generateSecretKey } from "nostr-tools";
3
4
 
4
- import { AnyPolicy } from './AnyPolicy.ts';
5
- import { NoOpPolicy } from './NoOpPolicy.ts';
6
- import { ReadOnlyPolicy } from './ReadOnlyPolicy.ts';
5
+ import { AnyPolicy } from "./AnyPolicy.ts";
6
+ import { NoOpPolicy } from "./NoOpPolicy.ts";
7
+ import { ReadOnlyPolicy } from "./ReadOnlyPolicy.ts";
7
8
 
8
- Deno.test('accepts when all policies accept', async () => {
9
+ await test("accepts when all policies accept", async () => {
9
10
  const policy = new AnyPolicy([
10
11
  new NoOpPolicy(),
11
12
  new NoOpPolicy(),
@@ -13,16 +14,16 @@ Deno.test('accepts when all policies accept', async () => {
13
14
  ]);
14
15
 
15
16
  const event = finalizeEvent(
16
- { kind: 1, content: '', tags: [], created_at: 0 },
17
+ { kind: 1, content: "", tags: [], created_at: 0 },
17
18
  generateSecretKey(),
18
19
  );
19
20
 
20
21
  const [_, _eventId, ok] = await policy.call(event);
21
22
 
22
- assertEquals(ok, true);
23
+ deepStrictEqual(ok, true);
23
24
  });
24
25
 
25
- Deno.test('accepts when some policies reject', async () => {
26
+ await test("accepts when some policies reject", async () => {
26
27
  const policy = new AnyPolicy([
27
28
  new NoOpPolicy(),
28
29
  new ReadOnlyPolicy(),
@@ -30,16 +31,16 @@ Deno.test('accepts when some policies reject', async () => {
30
31
  ]);
31
32
 
32
33
  const event = finalizeEvent(
33
- { kind: 1, content: '', tags: [], created_at: 0 },
34
+ { kind: 1, content: "", tags: [], created_at: 0 },
34
35
  generateSecretKey(),
35
36
  );
36
37
 
37
38
  const [_, _eventId, ok] = await policy.call(event);
38
39
 
39
- assertEquals(ok, true);
40
+ deepStrictEqual(ok, true);
40
41
  });
41
42
 
42
- Deno.test('rejects when all policies reject', async () => {
43
+ await test("rejects when all policies reject", async () => {
43
44
  const policy = new AnyPolicy([
44
45
  new ReadOnlyPolicy(),
45
46
  new ReadOnlyPolicy(),
@@ -47,11 +48,11 @@ Deno.test('rejects when all policies reject', async () => {
47
48
  ]);
48
49
 
49
50
  const event = finalizeEvent(
50
- { kind: 1, content: '', tags: [], created_at: 0 },
51
+ { kind: 1, content: "", tags: [], created_at: 0 },
51
52
  generateSecretKey(),
52
53
  );
53
54
 
54
55
  const [_, _eventId, ok] = await policy.call(event);
55
56
 
56
- assertEquals(ok, false);
57
+ deepStrictEqual(ok, false);
57
58
  });
package/AnyPolicy.ts CHANGED
@@ -1,8 +1,11 @@
1
- import { NostrEvent, NostrRelayOK, NPolicy } from '@nostrify/types';
1
+ import type { NostrEvent, NostrRelayOK, NPolicy } from '@nostrify/types';
2
2
 
3
3
  /** Similar to `PipePolicy`, but passes if at least one policy passes. */
4
4
  export class AnyPolicy implements NPolicy {
5
- constructor(private policies: NPolicy[]) {}
5
+ private policies: NPolicy[];
6
+ constructor(policies: NPolicy[]) {
7
+ this.policies = policies;
8
+ }
6
9
 
7
10
  async call(event: NostrEvent, signal?: AbortSignal): Promise<NostrRelayOK> {
8
11
  let result: NostrRelayOK = ['OK', event.id, false, 'blocked: no policy passed'];
@@ -1,10 +1,11 @@
1
- import { genEvent, MockRelay } from '@nostrify/nostrify/test';
2
- import { assertEquals } from '@std/assert';
3
- import { generateSecretKey } from 'nostr-tools';
1
+ import { test } from "node:test";
2
+ import { genEvent, MockRelay } from "@nostrify/nostrify/test";
3
+ import { deepStrictEqual } from "node:assert";
4
+ import { generateSecretKey } from "nostr-tools";
4
5
 
5
- import { AuthorPolicy } from './AuthorPolicy.ts';
6
+ import { AuthorPolicy } from "./AuthorPolicy.ts";
6
7
 
7
- Deno.test('AuthorPolicy', async () => {
8
+ await test("AuthorPolicy", async () => {
8
9
  const store = new MockRelay();
9
10
  const policy = new AuthorPolicy(store);
10
11
 
@@ -13,11 +14,11 @@ Deno.test('AuthorPolicy', async () => {
13
14
 
14
15
  const [, , ok1] = await policy.call(event);
15
16
 
16
- assertEquals(ok1, false);
17
+ deepStrictEqual(ok1, false);
17
18
 
18
19
  await store.event(genEvent({ kind: 0 }, sk));
19
20
 
20
21
  const [, , ok2] = await policy.call(event);
21
22
 
22
- assertEquals(ok2, true);
23
+ deepStrictEqual(ok2, true);
23
24
  });
package/AuthorPolicy.ts CHANGED
@@ -1,13 +1,19 @@
1
- import { NostrEvent, NostrRelayOK, NPolicy, NStore } from '@nostrify/types';
1
+ import type { NostrEvent, NostrRelayOK, NPolicy, NStore } from '@nostrify/types';
2
2
 
3
3
  /** Rejects events by authors without a kind 0, then optionally applies another policy to the kind 0. */
4
4
  export class AuthorPolicy implements NPolicy {
5
- constructor(private store: NStore, private policy?: NPolicy) {}
5
+ private store: NStore;
6
+ private policy?: NPolicy;
7
+
8
+ constructor(store: NStore, policy?: NPolicy) {
9
+ this.store = store;
10
+ this.policy = policy;
11
+ }
6
12
 
7
13
  async call(event: NostrEvent, signal?: AbortSignal): Promise<NostrRelayOK> {
8
14
  const author: NostrEvent | undefined = event.kind === 0 ? event : await this.store
9
15
  .query([{ kinds: [0], authors: [event.pubkey], limit: 1 }], { signal })
10
- .then(([event]) => event);
16
+ .then(([event]: NostrEvent[]) => event);
11
17
 
12
18
  if (!author) {
13
19
  return ['OK', event.id, false, 'blocked: author is missing a kind 0 event'];
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.36.7
4
+
5
+ ### Patch Changes
6
+
7
+ - tests should pass now
8
+ - Updated dependencies
9
+ - @nostrify/nostrify@0.46.9
10
+ - @nostrify/types@0.36.5
11
+
12
+ ## 0.36.6
13
+
14
+ ### Patch Changes
15
+
16
+ - Get tests passing in CI, use esbuild to build final JS files
17
+ - Updated dependencies
18
+ - @nostrify/nostrify@0.46.8
19
+ - @nostrify/types@0.36.4
20
+
3
21
  ## 0.36.5
4
22
 
5
23
  ### Patch Changes