@nostrify/nostrify 0.49.1 → 0.49.2

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.
@@ -7,7 +7,7 @@ npm warn Unknown env config "_jsr-registry". This will stop working in the next
7
7
  Building with esbuild...
8
8
 
9
9
  dist/NRelay1.js 8.9kb
10
- dist/NSchema.js 5.8kb
10
+ dist/NSchema.js 5.7kb
11
11
  dist/NPool.js 5.4kb
12
12
  dist/test/TestRelayServer.js 4.4kb
13
13
  dist/NSet.js 4.1kb
@@ -28,5 +28,5 @@ Building with esbuild...
28
28
  dist/test/mod.js 701b
29
29
  ...and 11 more output files...
30
30
 
31
- ⚡ Done in 18ms
31
+ ⚡ Done in 15ms
32
32
  Done!
@@ -1,96 +1,96 @@
1
1
 
2
2
 
3
- > @nostrify/nostrify@0.49.0 test /home/alex/Projects/nostrify/packages/nostrify
3
+ > @nostrify/nostrify@0.49.1 test /home/alex/Projects/nostrify/packages/nostrify
4
4
  > node --test "**/*.test.ts"
5
5
 
6
- ✔ BunkerURI (6.500947ms)
7
- ✔ BunkerURI.fromJSON (0.697366ms)
8
- ✔ NBrowserSigner - without extension (6.845626ms)
9
- ✔ NBrowserSigner - with extension polyfill (145.570371ms)
10
- ✔ NBrowserSigner.nip44 - with extension polyfill (41.798097ms)
11
- ✔ NBrowserSigner.nip04 - with extension polyfill (24.715886ms)
12
- ✔ NBrowserSigner.getRelays - with extension polyfill (1.481235ms)
13
- ✔ NBrowserSigner - missing nip44 support (0.488973ms)
14
- ✔ NBrowserSigner - missing nip04 support (0.305216ms)
15
- ✔ NBrowserSigner - feature detection (0.494443ms)
16
- ✔ NCache (4.851615ms)
17
- ✔ NConnectSigner.signEvent with nip04 encryption (263.040731ms)
18
- ✔ NConnectSigner.signEvent with nip44 encryption (65.206185ms)
19
- ✔ NIP05.lookup (66.927232ms)
20
- ✔ NIP05.lookup with invalid values but valid profile pointer (6.26454ms)
21
- ✔ NIP05.lookup with invalid document (6.817544ms)
22
- ✔ NIP50.parseInput (3.842521ms)
23
- ✔ NIP50.parseInput with negated token (0.457102ms)
24
- ✔ NIP98.template (5.687631ms)
25
- ✔ NIP98.template with payload (26.300896ms)
26
- ✔ NIP98.verify (133.933063ms)
27
- ✔ NIP98.verify fails with missing header (2.675358ms)
28
- ✔ NIP98.verify fails with missing token (1.837347ms)
29
- ✔ NIP98.verify fails with invalid token (1.68541ms)
30
- ✔ NIP98.verify fails with invalid event (22.562873ms)
31
- ✔ NIP98.verify fails with wrong event kind (25.930437ms)
32
- ✔ NIP98.verify fails with wrong request URL (18.756591ms)
33
- ✔ NIP98.verify fails with wrong request method (26.4621ms)
34
- ✔ NIP98.verify fails with expired event (12.038465ms)
35
- ✔ NIP98.verify fails with invalid payload (30.221524ms)
36
- ✔ NIP98Client.fetch - basic GET request (154.787833ms)
37
- ✔ NIP98Client.fetch - POST request with body (47.56551ms)
38
- ✔ NIP98Client.fetch - with Request object input (24.533651ms)
39
- ✔ NIP98Client.fetch - with URL object input (18.555061ms)
40
- ✔ NIP98Client.fetch - uses default fetch when not provided (5.830762ms)
41
- ✔ NIP98Client.fetch - preserves existing headers (7.498448ms)
42
- ✔ NIP98Client.fetch - event can be verified with NIP98.verify (23.18142ms)
43
- ✔ NIP98Client.fetch - handles different HTTP methods (54.413802ms)
44
- ✔ NKinds (2.313314ms)
45
- ✔ NPool.query (304.805977ms)
46
- ✔ NPool.req (71.883744ms)
47
- ✔ NPool.event (36.152295ms)
48
- ✔ NPool.query with eoseTimeout (556.472837ms)
49
- ✔ NPool.query with eoseTimeout disabled (518.148304ms)
50
- ✔ NRelay1.query (214.373313ms)
51
- ✔ NRelay1.query mismatched filter (26.656267ms)
52
- ✔ NRelay1.req (62.61191ms)
53
- ✔ NRelay1.event (15.013378ms)
54
- ﹣ NRelay1 backoff (0.284747ms) # SKIP
6
+ ✔ BunkerURI (2.855929ms)
7
+ ✔ BunkerURI.fromJSON (0.647302ms)
8
+ ✔ NBrowserSigner - without extension (5.614283ms)
9
+ ✔ NBrowserSigner - with extension polyfill (162.64428ms)
10
+ ✔ NBrowserSigner.nip44 - with extension polyfill (35.751206ms)
11
+ ✔ NBrowserSigner.nip04 - with extension polyfill (24.897688ms)
12
+ ✔ NBrowserSigner.getRelays - with extension polyfill (1.639964ms)
13
+ ✔ NBrowserSigner - missing nip44 support (0.681486ms)
14
+ ✔ NBrowserSigner - missing nip04 support (0.334181ms)
15
+ ✔ NBrowserSigner - feature detection (2.345656ms)
16
+ ✔ NCache (4.846063ms)
17
+ ✔ NConnectSigner.signEvent with nip04 encryption (284.998411ms)
18
+ ✔ NConnectSigner.signEvent with nip44 encryption (79.574293ms)
19
+ ✔ NIP05.lookup (94.266524ms)
20
+ ✔ NIP05.lookup with invalid values but valid profile pointer (6.109077ms)
21
+ ✔ NIP05.lookup with invalid document (7.362813ms)
22
+ ✔ NIP50.parseInput (6.692668ms)
23
+ ✔ NIP50.parseInput with negated token (0.459908ms)
24
+ ✔ NIP98.template (7.800118ms)
25
+ ✔ NIP98.template with payload (57.504461ms)
26
+ ✔ NIP98.verify (167.402989ms)
27
+ ✔ NIP98.verify fails with missing header (1.462579ms)
28
+ ✔ NIP98.verify fails with missing token (1.026357ms)
29
+ ✔ NIP98.verify fails with invalid token (1.318398ms)
30
+ ✔ NIP98.verify fails with invalid event (15.517318ms)
31
+ ✔ NIP98.verify fails with wrong event kind (15.461533ms)
32
+ ✔ NIP98.verify fails with wrong request URL (12.774894ms)
33
+ ✔ NIP98.verify fails with wrong request method (15.755518ms)
34
+ ✔ NIP98.verify fails with expired event (11.549622ms)
35
+ ✔ NIP98.verify fails with invalid payload (25.108065ms)
36
+ ✔ NIP98Client.fetch - basic GET request (152.34065ms)
37
+ ✔ NIP98Client.fetch - POST request with body (48.046766ms)
38
+ ✔ NIP98Client.fetch - with Request object input (22.539248ms)
39
+ ✔ NIP98Client.fetch - with URL object input (14.907818ms)
40
+ ✔ NIP98Client.fetch - uses default fetch when not provided (11.87691ms)
41
+ ✔ NIP98Client.fetch - preserves existing headers (16.091842ms)
42
+ ✔ NIP98Client.fetch - event can be verified with NIP98.verify (20.434596ms)
43
+ ✔ NIP98Client.fetch - handles different HTTP methods (54.082414ms)
44
+ ✔ NKinds (5.032997ms)
45
+ ✔ NPool.query (378.702333ms)
46
+ ✔ NPool.req (77.556426ms)
47
+ ✔ NPool.event (32.572729ms)
48
+ ✔ NPool.query with eoseTimeout (559.204759ms)
49
+ ✔ NPool.query with eoseTimeout disabled (519.68897ms)
50
+ ✔ NRelay1.query (226.319484ms)
51
+ ✔ NRelay1.query mismatched filter (27.633319ms)
52
+ ✔ NRelay1.req (66.241496ms)
53
+ ✔ NRelay1.event (12.452346ms)
54
+ ﹣ NRelay1 backoff (0.21217ms) # SKIP
55
55
  ▶ NRelay1 idleTimeout
56
- ✔ websocket opens (2.521237ms)
57
- ✔ websocket closes after idleTimeout (150.608267ms)
58
- ✔ websocket wakes up during activity (18.683393ms)
59
- ✔ NRelay1 idleTimeout (174.927484ms)
60
- ✔ NRelay1.count rejects when the server sends CLOSED (8.603564ms)
61
- ✔ NRelay1 closes when it receives a binary message (6.617717ms)
62
- ✔ n.id (13.522796ms)
63
- ✔ n.bech32 (3.250493ms)
64
- ✔ n.filter (54.632765ms)
65
- ✔ n.event (59.738558ms)
66
- ✔ n.metadata (111.976204ms)
67
- ✔ NSecSigner (139.725132ms)
68
- ✔ NSecSigner.nip44 (46.61682ms)
69
- ✔ NSet (19.968067ms)
70
- ✔ NSet.add (replaceable) (0.543556ms)
71
- ✔ NSet.add (parameterized) (0.852168ms)
72
- ✔ NSet.add (deletion) (0.422317ms)
73
- ✔ Construct a RelayError from the reason message (2.066149ms)
74
- ✔ Throw a new RelayError if the OK message is false (0.523077ms)
75
- ✔ LNURL.fromString (13.596875ms)
76
- ✔ LNURL.fromLightningAddress (1.670752ms)
77
- ✔ LNURL.toString (1.414138ms)
78
- ✔ LNURL.getDetails (125.620408ms)
79
- ✔ LNURL.getInvoice (14.385975ms)
80
- ✔ ErrorRelay (102.691184ms)
81
- ✔ MockRelay (3.336506ms)
82
- ✔ BlossomUploader.upload (643.516025ms)
83
- ✖ NostrBuildUploader.upload (12.243372ms)
84
- ✔ CircularSet (2.656663ms)
85
- ✔ push, iterate, & close (103.126316ms)
86
- ✔ close & reopen (0.403963ms)
87
- ✔ aborts with signal (51.238249ms)
88
- ✔ already aborted signal in constructor (0.399534ms)
89
- ✔ push after abort (0.518148ms)
90
- ✔ multiple messages in queue (0.23852ms)
91
- ✔ N64 (8.766331ms)
92
- ✔ N64.encodeEvent (0.227118ms)
93
- ✔ N64.decodeEvent (1.617352ms)
56
+ ✔ websocket opens (2.256778ms)
57
+ ✔ websocket closes after idleTimeout (150.482082ms)
58
+ ✔ websocket wakes up during activity (17.379211ms)
59
+ ✔ NRelay1 idleTimeout (173.173788ms)
60
+ ✔ NRelay1.count rejects when the server sends CLOSED (7.752588ms)
61
+ ✔ NRelay1 closes when it receives a binary message (5.304398ms)
62
+ ✔ n.id (11.977479ms)
63
+ ✔ n.bech32 (4.31372ms)
64
+ ✔ n.filter (83.609146ms)
65
+ ✔ n.event (39.732538ms)
66
+ ✔ n.metadata (67.78575ms)
67
+ ✔ NSecSigner (134.833466ms)
68
+ ✔ NSecSigner.nip44 (39.725124ms)
69
+ ✔ NSet (26.167433ms)
70
+ ✔ NSet.add (replaceable) (0.555688ms)
71
+ ✔ NSet.add (parameterized) (0.859632ms)
72
+ ✔ NSet.add (deletion) (0.659384ms)
73
+ ✔ Construct a RelayError from the reason message (2.48014ms)
74
+ ✔ Throw a new RelayError if the OK message is false (0.480627ms)
75
+ ✔ LNURL.fromString (7.853168ms)
76
+ ✔ LNURL.fromLightningAddress (1.565174ms)
77
+ ✔ LNURL.toString (1.207389ms)
78
+ ✔ LNURL.getDetails (61.890516ms)
79
+ ✔ LNURL.getInvoice (12.594574ms)
80
+ ✔ ErrorRelay (89.704386ms)
81
+ ✔ MockRelay (5.643569ms)
82
+ ✔ BlossomUploader.upload (685.760126ms)
83
+ ✖ NostrBuildUploader.upload (25.389164ms)
84
+ ✔ CircularSet (2.759166ms)
85
+ ✔ push, iterate, & close (103.744176ms)
86
+ ✔ close & reopen (0.695512ms)
87
+ ✔ aborts with signal (51.384223ms)
88
+ ✔ already aborted signal in constructor (0.622785ms)
89
+ ✔ push after abort (0.654174ms)
90
+ ✔ multiple messages in queue (0.316858ms)
91
+ ✔ N64 (18.170805ms)
92
+ ✔ N64.encodeEvent (0.414843ms)
93
+ ✔ N64.decodeEvent (4.505341ms)
94
94
  ℹ tests 87
95
95
  ℹ suites 0
96
96
  ℹ pass 85
@@ -98,12 +98,12 @@
98
98
  ℹ cancelled 0
99
99
  ℹ skipped 1
100
100
  ℹ todo 0
101
- ℹ duration_ms 3151.150695
101
+ ℹ duration_ms 3425.548766
102
102
 
103
103
  ✖ failing tests:
104
104
 
105
105
  test at uploaders/NostrBuildUploader.test.ts:12:7
106
- ✖ NostrBuildUploader.upload (12.243372ms)
106
+ ✖ NostrBuildUploader.upload (25.389164ms)
107
107
  Error: nostr.build with default uploader requires a secret key to be configured
108
108
  at TestContext.<anonymous> (file:///home/alex/Projects/nostrify/packages/nostrify/uploaders/NostrBuildUploader.test.ts:25:13)
109
109
   at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.49.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Simplify NSchema by removing explicit zod type annotations and leveraging type inference
8
+
3
9
  ## 0.49.1
4
10
 
5
11
  ### Patch Changes
package/NSchema.ts CHANGED
@@ -1,26 +1,6 @@
1
1
  import { z } from "zod";
2
2
 
3
- import type {
4
- NostrClientAUTH,
5
- NostrClientCLOSE,
6
- NostrClientCOUNT,
7
- NostrClientEVENT,
8
- NostrClientMsg,
9
- NostrClientREQ,
10
- NostrConnectRequest,
11
- NostrConnectResponse,
12
- NostrEvent,
13
- NostrFilter,
14
- NostrMetadata,
15
- NostrRelayAUTH,
16
- NostrRelayCLOSED,
17
- NostrRelayCOUNT,
18
- NostrRelayEOSE,
19
- NostrRelayEVENT,
20
- NostrRelayMsg,
21
- NostrRelayNOTICE,
22
- NostrRelayOK,
23
- } from "@nostrify/types";
3
+ import type { NostrFilter } from "@nostrify/types";
24
4
 
25
5
  /**
26
6
  * A suite of [zod](https://github.com/colinhacks/zod) schemas for Nostr.
@@ -36,12 +16,12 @@ import type {
36
16
  */
37
17
  class NSchema {
38
18
  /** Schema to validate Nostr hex IDs such as event IDs and pubkeys. */
39
- static id(): z.ZodString {
19
+ static id() {
40
20
  return z.string().regex(/^[0-9a-f]{64}$/);
41
21
  }
42
22
 
43
23
  /** Nostr event schema. */
44
- static event(): z.ZodType<NostrEvent> {
24
+ static event() {
45
25
  return z.object({
46
26
  id: NSchema.id(),
47
27
  kind: z.number().int().nonnegative(),
@@ -58,12 +38,12 @@ class NSchema {
58
38
  content: true,
59
39
  created_at: true,
60
40
  sig: true,
61
- }) as z.ZodType<NostrEvent>;
41
+ });
62
42
  }
63
43
 
64
44
  /** Nostr filter schema. */
65
- static filter(): z.ZodType<NostrFilter> {
66
- return z.object({
45
+ static filter() {
46
+ return z.looseObject({
67
47
  kinds: z.number().int().nonnegative().array().optional(),
68
48
  ids: NSchema.id().array().optional(),
69
49
  authors: NSchema.id().array().optional(),
@@ -72,7 +52,6 @@ class NSchema {
72
52
  limit: z.number().int().nonnegative().optional(),
73
53
  search: z.string().optional(),
74
54
  })
75
- .passthrough()
76
55
  .transform((value) => {
77
56
  const keys = [
78
57
  "kinds",
@@ -89,129 +68,116 @@ class NSchema {
89
68
  }
90
69
  return acc;
91
70
  }, {} as Record<string, unknown>) as NostrFilter;
92
- }) as z.ZodType<NostrFilter>;
71
+ });
93
72
  }
94
73
 
95
74
  /**
96
75
  * Bech32 string.
97
76
  * @see https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32
98
77
  */
99
- static bech32<P extends string>(prefix?: P): z.ZodType<`${P}1${string}`> {
78
+ static bech32<P extends string>(prefix?: P) {
100
79
  return z
101
80
  .string()
102
81
  .regex(/^[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}$/)
103
82
  .refine((value) =>
104
83
  prefix ? value.startsWith(`${prefix}1`) : true
105
- ) as z.ZodType<`${P}1${string}`>;
84
+ );
106
85
  }
107
86
 
108
87
  /** WebSocket URL starting with `ws://` or `wss://`. */
109
- static relayUrl(): z.ZodType<`ws://${string}` | `wss://${string}`> {
88
+ static relayUrl() {
110
89
  return z
111
- .string()
112
90
  .url()
113
- .regex(/^wss?:\/\//) as z.ZodType<`ws://${string}` | `wss://${string}`>;
91
+ .regex(/^wss?:\/\//);
114
92
  }
115
93
 
116
94
  /** NIP-01 `EVENT` message from client to relay. */
117
- static clientEVENT(): z.ZodType<NostrClientEVENT> {
95
+ static clientEVENT() {
118
96
  return z.tuple([
119
97
  z.literal("EVENT"),
120
98
  NSchema.event(),
121
- ]) as unknown as z.ZodType<
122
- NostrClientEVENT
123
- >;
99
+ ]);
124
100
  }
125
101
 
126
102
  /** NIP-01 `REQ` message from client to relay. */
127
- static clientREQ(): z.ZodType<NostrClientREQ> {
103
+ static clientREQ() {
128
104
  return z.tuple([z.literal("REQ"), z.string()]).rest(NSchema.filter());
129
105
  }
130
106
 
131
107
  /** NIP-45 `COUNT` message from client to relay. */
132
- static clientCOUNT(): z.ZodType<NostrClientCOUNT> {
108
+ static clientCOUNT() {
133
109
  return z.tuple([z.literal("COUNT"), z.string()]).rest(NSchema.filter());
134
110
  }
135
111
 
136
112
  /** NIP-01 `CLOSE` message from client to relay. */
137
- static clientCLOSE(): z.ZodType<NostrClientCLOSE> {
138
- return z.tuple([z.literal("CLOSE"), z.string()]) as unknown as z.ZodType<
139
- NostrClientCLOSE
140
- >;
113
+ static clientCLOSE() {
114
+ return z.tuple([z.literal("CLOSE"), z.string()]);
141
115
  }
142
116
 
143
117
  /** NIP-42 `AUTH` message from client to relay. */
144
- static clientAUTH(): z.ZodType<NostrClientAUTH> {
118
+ static clientAUTH() {
145
119
  return z.tuple([
146
120
  z.literal("AUTH"),
147
121
  NSchema.event(),
148
- ]) as unknown as z.ZodType<
149
- NostrClientAUTH
150
- >;
122
+ ]);
151
123
  }
152
124
 
153
125
  /** NIP-01 message from client to relay. */
154
- static clientMsg(): z.ZodType<NostrClientMsg> {
126
+ static clientMsg() {
155
127
  return z.union([
156
128
  NSchema.clientEVENT(),
157
129
  NSchema.clientREQ(),
158
130
  NSchema.clientCOUNT(),
159
131
  NSchema.clientCLOSE(),
160
132
  NSchema.clientAUTH(),
161
- ]) as z.ZodType<NostrClientMsg>;
133
+ ]);
162
134
  }
163
135
 
164
136
  /** NIP-01 `EVENT` message from relay to client. */
165
- static relayEVENT(): z.ZodType<NostrRelayEVENT> {
137
+ static relayEVENT() {
166
138
  return z.tuple([
167
139
  z.literal("EVENT"),
168
140
  z.string(),
169
141
  NSchema.event(),
170
- ]) as unknown as z.ZodType<NostrRelayEVENT>;
142
+ ]);
171
143
  }
172
144
 
173
145
  /** NIP-01 `OK` message from relay to client. */
174
- static relayOK(): z.ZodType<NostrRelayOK> {
146
+ static relayOK() {
175
147
  return z.tuple([
176
148
  z.literal("OK"),
177
149
  NSchema.id(),
178
150
  z.boolean(),
179
151
  z.string(),
180
- ]) as unknown as z.ZodType<NostrRelayOK>;
152
+ ]);
181
153
  }
182
154
 
183
155
  /** NIP-01 `EOSE` message from relay to client. */
184
- static relayEOSE(): z.ZodType<NostrRelayEOSE> {
185
- return z.tuple([z.literal("EOSE"), z.string()]) as unknown as z.ZodType<
186
- NostrRelayEOSE
187
- >;
156
+ static relayEOSE() {
157
+ return z.tuple([z.literal("EOSE"), z.string()]);
188
158
  }
189
159
 
190
160
  /** NIP-01 `NOTICE` message from relay to client. */
191
- static relayNOTICE(): z.ZodType<NostrRelayNOTICE> {
192
- return z.tuple([z.literal("NOTICE"), z.string()]) as unknown as z.ZodType<
193
- NostrRelayNOTICE
194
- >;
161
+ static relayNOTICE() {
162
+ return z.tuple([z.literal("NOTICE"), z.string()]);
195
163
  }
196
164
 
197
165
  /** NIP-01 `CLOSED` message from relay to client. */
198
- static relayCLOSED(): z.ZodType<NostrRelayCLOSED> {
166
+ static relayCLOSED() {
199
167
  return z.tuple([
200
168
  z.literal("CLOSED"),
201
169
  z.string(),
202
170
  z.string(),
203
- ]) as unknown as z.ZodType<NostrRelayCLOSED>;
171
+ ]);
204
172
  }
205
173
 
206
174
  /** NIP-42 `AUTH` message from relay to client. */
207
- static relayAUTH(): z.ZodType<NostrRelayAUTH> {
208
- return z.tuple([z.literal("AUTH"), z.string()]) as unknown as z.ZodType<
209
- NostrRelayAUTH
210
- >;
175
+ static relayAUTH() {
176
+ return z.tuple([z.literal("AUTH"), z.string()]);
211
177
  }
212
178
 
213
179
  /** NIP-45 `COUNT` message from relay to client. */
214
- static relayCOUNT(): z.ZodType<NostrRelayCOUNT> {
180
+ static relayCOUNT() {
215
181
  return z.tuple([
216
182
  z.literal("COUNT"),
217
183
  z.string(),
@@ -219,11 +185,11 @@ class NSchema {
219
185
  count: z.number().int().nonnegative(),
220
186
  approximate: z.boolean().optional(),
221
187
  }),
222
- ]) as unknown as z.ZodType<NostrRelayCOUNT>;
188
+ ]);
223
189
  }
224
190
 
225
191
  /** NIP-01 message from relay to client. */
226
- static relayMsg(): z.ZodType<NostrRelayMsg> {
192
+ static relayMsg() {
227
193
  return z.union([
228
194
  NSchema.relayEVENT(),
229
195
  NSchema.relayOK(),
@@ -236,37 +202,37 @@ class NSchema {
236
202
  }
237
203
 
238
204
  /** Kind 0 content schema. */
239
- static metadata(): z.ZodType<NostrMetadata> {
240
- return z.object({
205
+ static metadata() {
206
+ return z.looseObject({
241
207
  about: z.string().optional().catch(undefined),
242
- banner: z.string().url().optional().catch(undefined),
208
+ banner: z.url().optional().catch(undefined),
243
209
  bot: z.boolean().optional().catch(undefined),
244
210
  display_name: z.string().optional().catch(undefined),
245
211
  lud06: NSchema.bech32("lnurl").optional().catch(undefined),
246
- lud16: z.string().email().optional().catch(undefined),
212
+ lud16: z.email().optional().catch(undefined),
247
213
  name: z.string().optional().catch(undefined),
248
- nip05: z.string().email().optional().catch(undefined),
249
- picture: z.string().url().optional().catch(undefined),
250
- website: z.string().url().optional().catch(undefined),
251
- }).passthrough() as z.ZodType<NostrMetadata>;
214
+ nip05: z.email().optional().catch(undefined),
215
+ picture: z.url().optional().catch(undefined),
216
+ website: z.url().optional().catch(undefined),
217
+ });
252
218
  }
253
219
 
254
220
  /** NIP-46 request content schema. */
255
- static connectRequest(): z.ZodType<NostrConnectRequest> {
221
+ static connectRequest() {
256
222
  return z.object({
257
223
  id: z.string(),
258
224
  method: z.string(),
259
225
  params: z.string().array(),
260
- }) as z.ZodType<NostrConnectRequest>;
226
+ });
261
227
  }
262
228
 
263
229
  /** NIP-46 response content schema. */
264
- static connectResponse(): z.ZodType<NostrConnectResponse> {
230
+ static connectResponse() {
265
231
  return z.object({
266
232
  id: z.string(),
267
233
  result: z.string(),
268
234
  error: z.string().optional(),
269
- }) as z.ZodType<NostrConnectResponse>;
235
+ });
270
236
  }
271
237
 
272
238
  /**
@@ -276,11 +242,11 @@ class NSchema {
276
242
  * const event = NSchema.json().pipe(NSchema.event()).parse(data);
277
243
  * ```
278
244
  */
279
- static json(): z.ZodType<unknown> {
245
+ static json() {
280
246
  return z.string().transform((value, ctx) => {
281
247
  try {
282
248
  return JSON.parse(value) as unknown;
283
- } catch (_e) {
249
+ } catch {
284
250
  ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Invalid JSON" });
285
251
  return z.NEVER;
286
252
  }