@nostrify/nostrify 0.49.0 → 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.
- package/.turbo/turbo-build.log +3 -3
- package/.turbo/turbo-test.log +113 -112
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +12 -0
- package/NSchema.ts +50 -84
- package/dist/NSchema.d.ts +189 -23
- package/dist/NSchema.d.ts.map +1 -1
- package/dist/NSchema.js +11 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/NSchema.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import type {
|
|
2
|
+
import type { NostrFilter } from "@nostrify/types";
|
|
3
3
|
/**
|
|
4
4
|
* A suite of [zod](https://github.com/colinhacks/zod) schemas for Nostr.
|
|
5
5
|
*
|
|
@@ -16,50 +16,216 @@ declare class NSchema {
|
|
|
16
16
|
/** Schema to validate Nostr hex IDs such as event IDs and pubkeys. */
|
|
17
17
|
static id(): z.ZodString;
|
|
18
18
|
/** Nostr event schema. */
|
|
19
|
-
static event(): z.
|
|
19
|
+
static event(): z.ZodObject<{
|
|
20
|
+
id: z.ZodNonOptional<z.ZodString>;
|
|
21
|
+
kind: z.ZodNonOptional<z.ZodNumber>;
|
|
22
|
+
pubkey: z.ZodNonOptional<z.ZodString>;
|
|
23
|
+
tags: z.ZodNonOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
|
|
24
|
+
content: z.ZodNonOptional<z.ZodString>;
|
|
25
|
+
created_at: z.ZodNonOptional<z.ZodNumber>;
|
|
26
|
+
sig: z.ZodNonOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>;
|
|
20
28
|
/** Nostr filter schema. */
|
|
21
|
-
static filter(): z.
|
|
29
|
+
static filter(): z.ZodPipe<z.ZodObject<{
|
|
30
|
+
kinds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
31
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
32
|
+
authors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
|
+
since: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
until: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
search: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.core.$loose>, z.ZodTransform<NostrFilter, {
|
|
38
|
+
[x: string]: unknown;
|
|
39
|
+
kinds?: number[] | undefined;
|
|
40
|
+
ids?: string[] | undefined;
|
|
41
|
+
authors?: string[] | undefined;
|
|
42
|
+
since?: number | undefined;
|
|
43
|
+
until?: number | undefined;
|
|
44
|
+
limit?: number | undefined;
|
|
45
|
+
search?: string | undefined;
|
|
46
|
+
}>>;
|
|
22
47
|
/**
|
|
23
48
|
* Bech32 string.
|
|
24
49
|
* @see https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32
|
|
25
50
|
*/
|
|
26
|
-
static bech32<P extends string>(prefix?: P): z.
|
|
51
|
+
static bech32<P extends string>(prefix?: P): z.ZodString;
|
|
27
52
|
/** WebSocket URL starting with `ws://` or `wss://`. */
|
|
28
|
-
static relayUrl(): z.
|
|
53
|
+
static relayUrl(): z.ZodURL;
|
|
29
54
|
/** NIP-01 `EVENT` message from client to relay. */
|
|
30
|
-
static clientEVENT(): z.
|
|
55
|
+
static clientEVENT(): z.ZodTuple<[z.ZodLiteral<"EVENT">, z.ZodObject<{
|
|
56
|
+
id: z.ZodNonOptional<z.ZodString>;
|
|
57
|
+
kind: z.ZodNonOptional<z.ZodNumber>;
|
|
58
|
+
pubkey: z.ZodNonOptional<z.ZodString>;
|
|
59
|
+
tags: z.ZodNonOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
|
|
60
|
+
content: z.ZodNonOptional<z.ZodString>;
|
|
61
|
+
created_at: z.ZodNonOptional<z.ZodNumber>;
|
|
62
|
+
sig: z.ZodNonOptional<z.ZodString>;
|
|
63
|
+
}, z.core.$strip>], null>;
|
|
31
64
|
/** NIP-01 `REQ` message from client to relay. */
|
|
32
|
-
static clientREQ(): z.
|
|
65
|
+
static clientREQ(): z.ZodTuple<[z.ZodLiteral<"REQ">, z.ZodString], z.ZodPipe<z.ZodObject<{
|
|
66
|
+
kinds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
67
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
68
|
+
authors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
|
+
since: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
until: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
search: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, z.core.$loose>, z.ZodTransform<NostrFilter, {
|
|
74
|
+
[x: string]: unknown;
|
|
75
|
+
kinds?: number[] | undefined;
|
|
76
|
+
ids?: string[] | undefined;
|
|
77
|
+
authors?: string[] | undefined;
|
|
78
|
+
since?: number | undefined;
|
|
79
|
+
until?: number | undefined;
|
|
80
|
+
limit?: number | undefined;
|
|
81
|
+
search?: string | undefined;
|
|
82
|
+
}>>>;
|
|
33
83
|
/** NIP-45 `COUNT` message from client to relay. */
|
|
34
|
-
static clientCOUNT(): z.
|
|
84
|
+
static clientCOUNT(): z.ZodTuple<[z.ZodLiteral<"COUNT">, z.ZodString], z.ZodPipe<z.ZodObject<{
|
|
85
|
+
kinds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
86
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
87
|
+
authors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
88
|
+
since: z.ZodOptional<z.ZodNumber>;
|
|
89
|
+
until: z.ZodOptional<z.ZodNumber>;
|
|
90
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
91
|
+
search: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$loose>, z.ZodTransform<NostrFilter, {
|
|
93
|
+
[x: string]: unknown;
|
|
94
|
+
kinds?: number[] | undefined;
|
|
95
|
+
ids?: string[] | undefined;
|
|
96
|
+
authors?: string[] | undefined;
|
|
97
|
+
since?: number | undefined;
|
|
98
|
+
until?: number | undefined;
|
|
99
|
+
limit?: number | undefined;
|
|
100
|
+
search?: string | undefined;
|
|
101
|
+
}>>>;
|
|
35
102
|
/** NIP-01 `CLOSE` message from client to relay. */
|
|
36
|
-
static clientCLOSE(): z.
|
|
103
|
+
static clientCLOSE(): z.ZodTuple<[z.ZodLiteral<"CLOSE">, z.ZodString], null>;
|
|
37
104
|
/** NIP-42 `AUTH` message from client to relay. */
|
|
38
|
-
static clientAUTH(): z.
|
|
105
|
+
static clientAUTH(): z.ZodTuple<[z.ZodLiteral<"AUTH">, z.ZodObject<{
|
|
106
|
+
id: z.ZodNonOptional<z.ZodString>;
|
|
107
|
+
kind: z.ZodNonOptional<z.ZodNumber>;
|
|
108
|
+
pubkey: z.ZodNonOptional<z.ZodString>;
|
|
109
|
+
tags: z.ZodNonOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
|
|
110
|
+
content: z.ZodNonOptional<z.ZodString>;
|
|
111
|
+
created_at: z.ZodNonOptional<z.ZodNumber>;
|
|
112
|
+
sig: z.ZodNonOptional<z.ZodString>;
|
|
113
|
+
}, z.core.$strip>], null>;
|
|
39
114
|
/** NIP-01 message from client to relay. */
|
|
40
|
-
static clientMsg(): z.
|
|
115
|
+
static clientMsg(): z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"EVENT">, z.ZodObject<{
|
|
116
|
+
id: z.ZodNonOptional<z.ZodString>;
|
|
117
|
+
kind: z.ZodNonOptional<z.ZodNumber>;
|
|
118
|
+
pubkey: z.ZodNonOptional<z.ZodString>;
|
|
119
|
+
tags: z.ZodNonOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
|
|
120
|
+
content: z.ZodNonOptional<z.ZodString>;
|
|
121
|
+
created_at: z.ZodNonOptional<z.ZodNumber>;
|
|
122
|
+
sig: z.ZodNonOptional<z.ZodString>;
|
|
123
|
+
}, z.core.$strip>], null>, z.ZodTuple<[z.ZodLiteral<"REQ">, z.ZodString], z.ZodPipe<z.ZodObject<{
|
|
124
|
+
kinds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
125
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
126
|
+
authors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
127
|
+
since: z.ZodOptional<z.ZodNumber>;
|
|
128
|
+
until: z.ZodOptional<z.ZodNumber>;
|
|
129
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
search: z.ZodOptional<z.ZodString>;
|
|
131
|
+
}, z.core.$loose>, z.ZodTransform<NostrFilter, {
|
|
132
|
+
[x: string]: unknown;
|
|
133
|
+
kinds?: number[] | undefined;
|
|
134
|
+
ids?: string[] | undefined;
|
|
135
|
+
authors?: string[] | undefined;
|
|
136
|
+
since?: number | undefined;
|
|
137
|
+
until?: number | undefined;
|
|
138
|
+
limit?: number | undefined;
|
|
139
|
+
search?: string | undefined;
|
|
140
|
+
}>>>, z.ZodTuple<[z.ZodLiteral<"COUNT">, z.ZodString], z.ZodPipe<z.ZodObject<{
|
|
141
|
+
kinds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
142
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
143
|
+
authors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
144
|
+
since: z.ZodOptional<z.ZodNumber>;
|
|
145
|
+
until: z.ZodOptional<z.ZodNumber>;
|
|
146
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
147
|
+
search: z.ZodOptional<z.ZodString>;
|
|
148
|
+
}, z.core.$loose>, z.ZodTransform<NostrFilter, {
|
|
149
|
+
[x: string]: unknown;
|
|
150
|
+
kinds?: number[] | undefined;
|
|
151
|
+
ids?: string[] | undefined;
|
|
152
|
+
authors?: string[] | undefined;
|
|
153
|
+
since?: number | undefined;
|
|
154
|
+
until?: number | undefined;
|
|
155
|
+
limit?: number | undefined;
|
|
156
|
+
search?: string | undefined;
|
|
157
|
+
}>>>, z.ZodTuple<[z.ZodLiteral<"CLOSE">, z.ZodString], null>, z.ZodTuple<[z.ZodLiteral<"AUTH">, z.ZodObject<{
|
|
158
|
+
id: z.ZodNonOptional<z.ZodString>;
|
|
159
|
+
kind: z.ZodNonOptional<z.ZodNumber>;
|
|
160
|
+
pubkey: z.ZodNonOptional<z.ZodString>;
|
|
161
|
+
tags: z.ZodNonOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
|
|
162
|
+
content: z.ZodNonOptional<z.ZodString>;
|
|
163
|
+
created_at: z.ZodNonOptional<z.ZodNumber>;
|
|
164
|
+
sig: z.ZodNonOptional<z.ZodString>;
|
|
165
|
+
}, z.core.$strip>], null>]>;
|
|
41
166
|
/** NIP-01 `EVENT` message from relay to client. */
|
|
42
|
-
static relayEVENT(): z.
|
|
167
|
+
static relayEVENT(): z.ZodTuple<[z.ZodLiteral<"EVENT">, z.ZodString, z.ZodObject<{
|
|
168
|
+
id: z.ZodNonOptional<z.ZodString>;
|
|
169
|
+
kind: z.ZodNonOptional<z.ZodNumber>;
|
|
170
|
+
pubkey: z.ZodNonOptional<z.ZodString>;
|
|
171
|
+
tags: z.ZodNonOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
|
|
172
|
+
content: z.ZodNonOptional<z.ZodString>;
|
|
173
|
+
created_at: z.ZodNonOptional<z.ZodNumber>;
|
|
174
|
+
sig: z.ZodNonOptional<z.ZodString>;
|
|
175
|
+
}, z.core.$strip>], null>;
|
|
43
176
|
/** NIP-01 `OK` message from relay to client. */
|
|
44
|
-
static relayOK(): z.
|
|
177
|
+
static relayOK(): z.ZodTuple<[z.ZodLiteral<"OK">, z.ZodString, z.ZodBoolean, z.ZodString], null>;
|
|
45
178
|
/** NIP-01 `EOSE` message from relay to client. */
|
|
46
|
-
static relayEOSE(): z.
|
|
179
|
+
static relayEOSE(): z.ZodTuple<[z.ZodLiteral<"EOSE">, z.ZodString], null>;
|
|
47
180
|
/** NIP-01 `NOTICE` message from relay to client. */
|
|
48
|
-
static relayNOTICE(): z.
|
|
181
|
+
static relayNOTICE(): z.ZodTuple<[z.ZodLiteral<"NOTICE">, z.ZodString], null>;
|
|
49
182
|
/** NIP-01 `CLOSED` message from relay to client. */
|
|
50
|
-
static relayCLOSED(): z.
|
|
183
|
+
static relayCLOSED(): z.ZodTuple<[z.ZodLiteral<"CLOSED">, z.ZodString, z.ZodString], null>;
|
|
51
184
|
/** NIP-42 `AUTH` message from relay to client. */
|
|
52
|
-
static relayAUTH(): z.
|
|
185
|
+
static relayAUTH(): z.ZodTuple<[z.ZodLiteral<"AUTH">, z.ZodString], null>;
|
|
53
186
|
/** NIP-45 `COUNT` message from relay to client. */
|
|
54
|
-
static relayCOUNT(): z.
|
|
187
|
+
static relayCOUNT(): z.ZodTuple<[z.ZodLiteral<"COUNT">, z.ZodString, z.ZodObject<{
|
|
188
|
+
count: z.ZodNumber;
|
|
189
|
+
approximate: z.ZodOptional<z.ZodBoolean>;
|
|
190
|
+
}, z.core.$strip>], null>;
|
|
55
191
|
/** NIP-01 message from relay to client. */
|
|
56
|
-
static relayMsg(): z.
|
|
192
|
+
static relayMsg(): z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"EVENT">, z.ZodString, z.ZodObject<{
|
|
193
|
+
id: z.ZodNonOptional<z.ZodString>;
|
|
194
|
+
kind: z.ZodNonOptional<z.ZodNumber>;
|
|
195
|
+
pubkey: z.ZodNonOptional<z.ZodString>;
|
|
196
|
+
tags: z.ZodNonOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
|
|
197
|
+
content: z.ZodNonOptional<z.ZodString>;
|
|
198
|
+
created_at: z.ZodNonOptional<z.ZodNumber>;
|
|
199
|
+
sig: z.ZodNonOptional<z.ZodString>;
|
|
200
|
+
}, z.core.$strip>], null>, z.ZodTuple<[z.ZodLiteral<"OK">, z.ZodString, z.ZodBoolean, z.ZodString], null>, z.ZodTuple<[z.ZodLiteral<"EOSE">, z.ZodString], null>, z.ZodTuple<[z.ZodLiteral<"NOTICE">, z.ZodString], null>, z.ZodTuple<[z.ZodLiteral<"CLOSED">, z.ZodString, z.ZodString], null>, z.ZodTuple<[z.ZodLiteral<"AUTH">, z.ZodString], null>, z.ZodTuple<[z.ZodLiteral<"COUNT">, z.ZodString, z.ZodObject<{
|
|
201
|
+
count: z.ZodNumber;
|
|
202
|
+
approximate: z.ZodOptional<z.ZodBoolean>;
|
|
203
|
+
}, z.core.$strip>], null>]>;
|
|
57
204
|
/** Kind 0 content schema. */
|
|
58
|
-
static metadata(): z.
|
|
205
|
+
static metadata(): z.ZodObject<{
|
|
206
|
+
about: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
207
|
+
banner: z.ZodCatch<z.ZodOptional<z.ZodURL>>;
|
|
208
|
+
bot: z.ZodCatch<z.ZodOptional<z.ZodBoolean>>;
|
|
209
|
+
display_name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
210
|
+
lud06: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
211
|
+
lud16: z.ZodCatch<z.ZodOptional<z.ZodEmail>>;
|
|
212
|
+
name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
213
|
+
nip05: z.ZodCatch<z.ZodOptional<z.ZodEmail>>;
|
|
214
|
+
picture: z.ZodCatch<z.ZodOptional<z.ZodURL>>;
|
|
215
|
+
website: z.ZodCatch<z.ZodOptional<z.ZodURL>>;
|
|
216
|
+
}, z.core.$loose>;
|
|
59
217
|
/** NIP-46 request content schema. */
|
|
60
|
-
static connectRequest(): z.
|
|
218
|
+
static connectRequest(): z.ZodObject<{
|
|
219
|
+
id: z.ZodString;
|
|
220
|
+
method: z.ZodString;
|
|
221
|
+
params: z.ZodArray<z.ZodString>;
|
|
222
|
+
}, z.core.$strip>;
|
|
61
223
|
/** NIP-46 response content schema. */
|
|
62
|
-
static connectResponse(): z.
|
|
224
|
+
static connectResponse(): z.ZodObject<{
|
|
225
|
+
id: z.ZodString;
|
|
226
|
+
result: z.ZodString;
|
|
227
|
+
error: z.ZodOptional<z.ZodString>;
|
|
228
|
+
}, z.core.$strip>;
|
|
63
229
|
/**
|
|
64
230
|
* Helper schema to parse a JSON string. It should then be piped into another schema. For example:
|
|
65
231
|
*
|
|
@@ -67,7 +233,7 @@ declare class NSchema {
|
|
|
67
233
|
* const event = NSchema.json().pipe(NSchema.event()).parse(data);
|
|
68
234
|
* ```
|
|
69
235
|
*/
|
|
70
|
-
static json(): z.
|
|
236
|
+
static json(): z.ZodPipe<z.ZodString, z.ZodTransform<unknown, string>>;
|
|
71
237
|
}
|
|
72
238
|
export { NSchema, z };
|
|
73
239
|
//# sourceMappingURL=NSchema.d.ts.map
|
package/dist/NSchema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NSchema.d.ts","sourceRoot":"","sources":["../NSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"NSchema.d.ts","sourceRoot":"","sources":["../NSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,cAAM,OAAO;IACX,sEAAsE;IACtE,MAAM,CAAC,EAAE;IAIT,0BAA0B;IAC1B,MAAM,CAAC,KAAK;;;;;;;;;IAoBZ,2BAA2B;IAC3B,MAAM,CAAC,MAAM;;;;;;;;;;;;;;;;;;IA6Bb;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAS1C,uDAAuD;IACvD,MAAM,CAAC,QAAQ;IAMf,mDAAmD;IACnD,MAAM,CAAC,WAAW;;;;;;;;;IAOlB,iDAAiD;IACjD,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;;;;IAIhB,mDAAmD;IACnD,MAAM,CAAC,WAAW;;;;;;;;;;;;;;;;;;IAIlB,mDAAmD;IACnD,MAAM,CAAC,WAAW;IAIlB,kDAAkD;IAClD,MAAM,CAAC,UAAU;;;;;;;;;IAOjB,2CAA2C;IAC3C,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAUhB,mDAAmD;IACnD,MAAM,CAAC,UAAU;;;;;;;;;IAQjB,gDAAgD;IAChD,MAAM,CAAC,OAAO;IASd,kDAAkD;IAClD,MAAM,CAAC,SAAS;IAIhB,oDAAoD;IACpD,MAAM,CAAC,WAAW;IAIlB,oDAAoD;IACpD,MAAM,CAAC,WAAW;IAQlB,kDAAkD;IAClD,MAAM,CAAC,SAAS;IAIhB,mDAAmD;IACnD,MAAM,CAAC,UAAU;;;;IAWjB,2CAA2C;IAC3C,MAAM,CAAC,QAAQ;;;;;;;;;;;;IAYf,6BAA6B;IAC7B,MAAM,CAAC,QAAQ;;;;;;;;;;;;IAef,qCAAqC;IACrC,MAAM,CAAC,cAAc;;;;;IAQrB,sCAAsC;IACtC,MAAM,CAAC,eAAe;;;;;IAQtB;;;;;;OAMG;IACH,MAAM,CAAC,IAAI;CAUZ;AAED,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC"}
|
package/dist/NSchema.js
CHANGED
|
@@ -26,7 +26,7 @@ class NSchema {
|
|
|
26
26
|
}
|
|
27
27
|
/** Nostr filter schema. */
|
|
28
28
|
static filter() {
|
|
29
|
-
return z.
|
|
29
|
+
return z.looseObject({
|
|
30
30
|
kinds: z.number().int().nonnegative().array().optional(),
|
|
31
31
|
ids: NSchema.id().array().optional(),
|
|
32
32
|
authors: NSchema.id().array().optional(),
|
|
@@ -34,7 +34,7 @@ class NSchema {
|
|
|
34
34
|
until: z.number().int().nonnegative().optional(),
|
|
35
35
|
limit: z.number().int().nonnegative().optional(),
|
|
36
36
|
search: z.string().optional()
|
|
37
|
-
}).
|
|
37
|
+
}).transform((value) => {
|
|
38
38
|
const keys = [
|
|
39
39
|
"kinds",
|
|
40
40
|
"ids",
|
|
@@ -63,7 +63,7 @@ class NSchema {
|
|
|
63
63
|
}
|
|
64
64
|
/** WebSocket URL starting with `ws://` or `wss://`. */
|
|
65
65
|
static relayUrl() {
|
|
66
|
-
return z.
|
|
66
|
+
return z.url().regex(/^wss?:\/\//);
|
|
67
67
|
}
|
|
68
68
|
/** NIP-01 `EVENT` message from client to relay. */
|
|
69
69
|
static clientEVENT() {
|
|
@@ -163,18 +163,18 @@ class NSchema {
|
|
|
163
163
|
}
|
|
164
164
|
/** Kind 0 content schema. */
|
|
165
165
|
static metadata() {
|
|
166
|
-
return z.
|
|
166
|
+
return z.looseObject({
|
|
167
167
|
about: z.string().optional().catch(void 0),
|
|
168
|
-
banner: z.
|
|
168
|
+
banner: z.url().optional().catch(void 0),
|
|
169
169
|
bot: z.boolean().optional().catch(void 0),
|
|
170
170
|
display_name: z.string().optional().catch(void 0),
|
|
171
171
|
lud06: NSchema.bech32("lnurl").optional().catch(void 0),
|
|
172
|
-
lud16: z.
|
|
172
|
+
lud16: z.email().optional().catch(void 0),
|
|
173
173
|
name: z.string().optional().catch(void 0),
|
|
174
|
-
nip05: z.
|
|
175
|
-
picture: z.
|
|
176
|
-
website: z.
|
|
177
|
-
})
|
|
174
|
+
nip05: z.email().optional().catch(void 0),
|
|
175
|
+
picture: z.url().optional().catch(void 0),
|
|
176
|
+
website: z.url().optional().catch(void 0)
|
|
177
|
+
});
|
|
178
178
|
}
|
|
179
179
|
/** NIP-46 request content schema. */
|
|
180
180
|
static connectRequest() {
|
|
@@ -203,7 +203,7 @@ class NSchema {
|
|
|
203
203
|
return z.string().transform((value, ctx) => {
|
|
204
204
|
try {
|
|
205
205
|
return JSON.parse(value);
|
|
206
|
-
} catch
|
|
206
|
+
} catch {
|
|
207
207
|
ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Invalid JSON" });
|
|
208
208
|
return z.NEVER;
|
|
209
209
|
}
|