@nostrify/nostrify 0.47.1 â 0.48.1
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 +22 -9
- package/.turbo/turbo-test.log +89 -81
- package/CHANGELOG.md +62 -24
- package/NIP98.test.ts +1 -3
- package/NIP98.ts +41 -27
- package/NRelay1.test.ts +5 -2
- package/dist/NIP98.d.ts +2 -2
- package/dist/NIP98.d.ts.map +1 -1
- package/dist/NIP98.js +14 -4
- package/dist/NIP98.ts +41 -27
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/uploaders/BlossomUploader.d.ts +3 -3
- package/dist/uploaders/BlossomUploader.d.ts.map +1 -1
- package/dist/uploaders/BlossomUploader.js +5 -3
- package/dist/uploaders/BlossomUploader.ts +24 -22
- package/dist/uploaders/NostrBuildUploader.d.ts +4 -4
- package/dist/uploaders/NostrBuildUploader.d.ts.map +1 -1
- package/dist/uploaders/NostrBuildUploader.ts +19 -19
- package/dist/utils/N64.d.ts +1 -1
- package/dist/utils/N64.js +3 -3
- package/dist/utils/N64.ts +5 -5
- package/package.json +6 -5
- package/uploaders/BlossomUploader.ts +24 -22
- package/uploaders/NostrBuildUploader.test.ts +16 -1
- package/uploaders/NostrBuildUploader.ts +19 -19
- package/utils/N64.ts +5 -5
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @nostrify/nostrify@0.
|
|
3
|
+
> @nostrify/nostrify@0.48.0 build /home/sid/repos/nostrify/packages/nostrify
|
|
4
4
|
> npx tsc -p tsconfig.json && node ../../esbuild.config.js --package ./
|
|
5
5
|
|
|
6
6
|
[1mnpm[22m [33mwarn[39m [94mUnknown env config "verify-deps-before-run". This will stop working in the next major version of npm.[39m
|
|
7
7
|
[1mnpm[22m [33mwarn[39m [94mUnknown env config "_jsr-registry". This will stop working in the next major version of npm.[39m
|
|
8
|
-
[1G[0K[1G[0Kâ [1G[0KBuilding with esbuild...
|
|
8
|
+
[1G[0Kâ [1G[0K[1G[0Kâ [1G[0KBuilding with esbuild...
|
|
9
9
|
|
|
10
|
-
[37mdist/[0m[1mNRelay1.js[0m
|
|
11
|
-
[37mdist/[0m[1mNSchema.js[0m
|
|
12
|
-
[37mdist/[0m[1mNPool.js[0m
|
|
13
|
-
[37mdist/test/[0m[1mTestRelayServer.js[0m
|
|
14
|
-
[37mdist/[0m[1mNSet.js[0m
|
|
15
|
-
[
|
|
10
|
+
[37mdist/[0m[1mNRelay1.js[0m [36m8.9kb[0m
|
|
11
|
+
[37mdist/[0m[1mNSchema.js[0m [36m5.8kb[0m
|
|
12
|
+
[37mdist/[0m[1mNPool.js[0m [36m5.0kb[0m
|
|
13
|
+
[37mdist/test/[0m[1mTestRelayServer.js[0m [36m4.4kb[0m
|
|
14
|
+
[37mdist/[0m[1mNSet.js[0m [36m4.1kb[0m
|
|
15
|
+
[37mdist/[0m[1mNConnectSigner.js[0m [36m3.9kb[0m
|
|
16
|
+
[37mdist/ln/[0m[1mLNURL.js[0m [36m3.3kb[0m
|
|
17
|
+
[37mdist/[0m[1mNIP98.js[0m [36m2.7kb[0m
|
|
18
|
+
[37mdist/[0m[1mNBrowserSigner.js[0m [36m2.6kb[0m
|
|
19
|
+
[37mdist/uploaders/[0m[1mBlossomUploader.js[0m [36m1.9kb[0m
|
|
20
|
+
[37mdist/uploaders/[0m[1mNostrBuildUploader.js[0m [36m1.9kb[0m
|
|
21
|
+
[37mdist/test/[0m[1mMockRelay.js[0m [36m1.4kb[0m
|
|
22
|
+
[37mdist/[0m[1mBunkerURI.js[0m [36m1.4kb[0m
|
|
23
|
+
[37mdist/[0m[1mNKinds.js[0m [36m1.1kb[0m
|
|
24
|
+
[37mdist/[0m[1mNIP05.js[0m [36m1.1kb[0m
|
|
25
|
+
[37mdist/[0m[1mNSecSigner.js[0m [36m1.1kb[0m
|
|
26
|
+
[37mdist/utils/[0m[1mMachina.js[0m [36m925b [0m
|
|
27
|
+
[37mdist/[0m[1mNCache.js[0m [36m828b [0m
|
|
28
|
+
[37m...and 13 more output files...[0m
|
|
16
29
|
|
|
17
|
-
âĦ [32mDone in
|
|
30
|
+
âĦ [32mDone in 27ms[0m
|
|
18
31
|
Copying source files...
|
|
19
32
|
Done!
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,91 +1,99 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @nostrify/nostrify@0.
|
|
3
|
+
> @nostrify/nostrify@0.48.0 test /home/sid/repos/nostrify/packages/nostrify
|
|
4
4
|
> node --test "**/*.test.ts"
|
|
5
5
|
|
|
6
|
-
â BunkerURI (
|
|
7
|
-
â BunkerURI.fromJSON (
|
|
8
|
-
â NBrowserSigner - without extension (
|
|
9
|
-
â NBrowserSigner - with extension polyfill (
|
|
10
|
-
â NBrowserSigner.nip44 - with extension polyfill (
|
|
11
|
-
â NBrowserSigner.nip04 - with extension polyfill (
|
|
12
|
-
â NBrowserSigner.getRelays - with extension polyfill (
|
|
13
|
-
â NBrowserSigner - missing nip44 support (
|
|
14
|
-
â NBrowserSigner - missing nip04 support (0.
|
|
15
|
-
â NBrowserSigner - feature detection (
|
|
16
|
-
â NCache (
|
|
17
|
-
â NConnectSigner.signEvent with nip04 encryption (
|
|
18
|
-
â NConnectSigner.signEvent with nip44 encryption (
|
|
19
|
-
â NIP05.lookup (
|
|
20
|
-
â NIP05.lookup with invalid values but valid profile pointer (
|
|
21
|
-
â NIP05.lookup with invalid document (
|
|
22
|
-
â NIP50.parseInput (
|
|
23
|
-
â NIP50.parseInput with negated token (0.
|
|
24
|
-
â NIP98.template (
|
|
25
|
-
â NIP98.template with payload (
|
|
26
|
-
â NIP98.verify (
|
|
27
|
-
â NIP98.verify fails with missing header (
|
|
28
|
-
â NIP98.verify fails with missing token (
|
|
29
|
-
â NIP98.verify fails with invalid token (
|
|
30
|
-
â NIP98.verify fails with invalid event (
|
|
31
|
-
â NIP98.verify fails with wrong event kind (
|
|
32
|
-
â NIP98.verify fails with wrong request URL (
|
|
33
|
-
â NIP98.verify fails with wrong request method (
|
|
34
|
-
â NIP98.verify fails with expired event (
|
|
35
|
-
â NIP98.verify fails with invalid payload (
|
|
36
|
-
â
|
|
37
|
-
â
|
|
38
|
-
â
|
|
39
|
-
â
|
|
40
|
-
â
|
|
41
|
-
â
|
|
42
|
-
â
|
|
43
|
-
â
|
|
44
|
-
|
|
6
|
+
â BunkerURI (8.032428ms)
|
|
7
|
+
â BunkerURI.fromJSON (1.011522ms)
|
|
8
|
+
â NBrowserSigner - without extension (10.371695ms)
|
|
9
|
+
â NBrowserSigner - with extension polyfill (329.050343ms)
|
|
10
|
+
â NBrowserSigner.nip44 - with extension polyfill (188.734388ms)
|
|
11
|
+
â NBrowserSigner.nip04 - with extension polyfill (70.232955ms)
|
|
12
|
+
â NBrowserSigner.getRelays - with extension polyfill (2.229952ms)
|
|
13
|
+
â NBrowserSigner - missing nip44 support (5.683803ms)
|
|
14
|
+
â NBrowserSigner - missing nip04 support (0.456198ms)
|
|
15
|
+
â NBrowserSigner - feature detection (4.388092ms)
|
|
16
|
+
â NCache (28.041794ms)
|
|
17
|
+
â NConnectSigner.signEvent with nip04 encryption (357.348402ms)
|
|
18
|
+
â NConnectSigner.signEvent with nip44 encryption (179.341911ms)
|
|
19
|
+
â NIP05.lookup (110.840506ms)
|
|
20
|
+
â NIP05.lookup with invalid values but valid profile pointer (6.688672ms)
|
|
21
|
+
â NIP05.lookup with invalid document (6.384854ms)
|
|
22
|
+
â NIP50.parseInput (5.363623ms)
|
|
23
|
+
â NIP50.parseInput with negated token (0.425237ms)
|
|
24
|
+
â NIP98.template (26.510529ms)
|
|
25
|
+
â NIP98.template with payload (57.914746ms)
|
|
26
|
+
â NIP98.verify (172.889905ms)
|
|
27
|
+
â NIP98.verify fails with missing header (2.182248ms)
|
|
28
|
+
â NIP98.verify fails with missing token (1.647725ms)
|
|
29
|
+
â NIP98.verify fails with invalid token (1.945311ms)
|
|
30
|
+
â NIP98.verify fails with invalid event (49.451318ms)
|
|
31
|
+
â NIP98.verify fails with wrong event kind (70.598745ms)
|
|
32
|
+
â NIP98.verify fails with wrong request URL (86.043572ms)
|
|
33
|
+
â NIP98.verify fails with wrong request method (52.311711ms)
|
|
34
|
+
â NIP98.verify fails with expired event (70.877534ms)
|
|
35
|
+
â NIP98.verify fails with invalid payload (235.890385ms)
|
|
36
|
+
â NIP98Client.fetch - basic GET request (204.607488ms)
|
|
37
|
+
â NIP98Client.fetch - POST request with body (224.461879ms)
|
|
38
|
+
â NIP98Client.fetch - with Request object input (110.155447ms)
|
|
39
|
+
â NIP98Client.fetch - with URL object input (69.82442ms)
|
|
40
|
+
â NIP98Client.fetch - uses default fetch when not provided (43.370412ms)
|
|
41
|
+
â NIP98Client.fetch - preserves existing headers (75.087655ms)
|
|
42
|
+
â NIP98Client.fetch - event can be verified with NIP98.verify (76.739559ms)
|
|
43
|
+
â NIP98Client.fetch - handles different HTTP methods (226.588206ms)
|
|
44
|
+
â NKinds (15.675591ms)
|
|
45
|
+
â NPool.query (635.444667ms)
|
|
46
|
+
â NPool.req (107.060121ms)
|
|
47
|
+
â NPool.event (66.952535ms)
|
|
48
|
+
â NRelay1.query (538.03435ms)
|
|
49
|
+
â NRelay1.query mismatched filter (133.455243ms)
|
|
50
|
+
â NRelay1.req (141.418776ms)
|
|
51
|
+
â NRelay1.event (32.63963ms)
|
|
52
|
+
ïı£ NRelay1 backoff (1.106008ms) # SKIP
|
|
45
53
|
âĥ NRelay1 idleTimeout
|
|
46
|
-
â websocket opens (
|
|
47
|
-
â websocket closes after idleTimeout (150.
|
|
48
|
-
â websocket wakes up during activity (
|
|
49
|
-
â NRelay1 idleTimeout (
|
|
50
|
-
â NRelay1.count rejects when the server sends CLOSED (
|
|
51
|
-
â NRelay1 closes when it receives a binary message (
|
|
52
|
-
â n.id (
|
|
53
|
-
â n.bech32 (
|
|
54
|
-
â n.filter (
|
|
55
|
-
â n.event (
|
|
56
|
-
â n.metadata (
|
|
57
|
-
â NSecSigner (
|
|
58
|
-
â NSecSigner.nip44 (
|
|
59
|
-
â NSet (
|
|
60
|
-
â NSet.add (replaceable) (0.
|
|
61
|
-
â NSet.add (parameterized) (
|
|
62
|
-
â NSet.add (deletion) (0.
|
|
63
|
-
â Construct a RelayError from the reason message (
|
|
64
|
-
â Throw a new RelayError if the OK message is false (0.
|
|
65
|
-
â LNURL.fromString (
|
|
66
|
-
â LNURL.fromLightningAddress (
|
|
67
|
-
â LNURL.toString (
|
|
68
|
-
â LNURL.getDetails (
|
|
69
|
-
â LNURL.getInvoice (
|
|
70
|
-
â ErrorRelay (
|
|
71
|
-
â MockRelay (
|
|
72
|
-
ïı£ BlossomUploader.upload (1.
|
|
73
|
-
ïı£ NostrBuildUploader.upload (2.
|
|
74
|
-
â CircularSet (
|
|
75
|
-
â push, iterate, & close (
|
|
76
|
-
â close & reopen (0.
|
|
77
|
-
â aborts with signal (
|
|
78
|
-
â already aborted signal in constructor (
|
|
79
|
-
â push after abort (
|
|
80
|
-
â multiple messages in queue (0.
|
|
81
|
-
â N64 (
|
|
82
|
-
â N64.encodeEvent (0.
|
|
83
|
-
â N64.decodeEvent (1.
|
|
84
|
-
âı tests
|
|
54
|
+
â websocket opens (13.835447ms)
|
|
55
|
+
â websocket closes after idleTimeout (150.566912ms)
|
|
56
|
+
â websocket wakes up during activity (27.121071ms)
|
|
57
|
+
â NRelay1 idleTimeout (204.19181ms)
|
|
58
|
+
â NRelay1.count rejects when the server sends CLOSED (16.828862ms)
|
|
59
|
+
â NRelay1 closes when it receives a binary message (11.148585ms)
|
|
60
|
+
â n.id (8.094721ms)
|
|
61
|
+
â n.bech32 (5.484882ms)
|
|
62
|
+
â n.filter (18.52384ms)
|
|
63
|
+
â n.event (4.463901ms)
|
|
64
|
+
â n.metadata (24.462155ms)
|
|
65
|
+
â NSecSigner (219.082425ms)
|
|
66
|
+
â NSecSigner.nip44 (37.591612ms)
|
|
67
|
+
â NSet (24.542373ms)
|
|
68
|
+
â NSet.add (replaceable) (0.656583ms)
|
|
69
|
+
â NSet.add (parameterized) (1.209522ms)
|
|
70
|
+
â NSet.add (deletion) (0.555925ms)
|
|
71
|
+
â Construct a RelayError from the reason message (2.598397ms)
|
|
72
|
+
â Throw a new RelayError if the OK message is false (0.892217ms)
|
|
73
|
+
â LNURL.fromString (21.686509ms)
|
|
74
|
+
â LNURL.fromLightningAddress (6.521633ms)
|
|
75
|
+
â LNURL.toString (2.187929ms)
|
|
76
|
+
â LNURL.getDetails (149.682932ms)
|
|
77
|
+
â LNURL.getInvoice (7.231692ms)
|
|
78
|
+
â ErrorRelay (189.467472ms)
|
|
79
|
+
â MockRelay (4.420616ms)
|
|
80
|
+
ïı£ BlossomUploader.upload (1.337574ms) # SKIP
|
|
81
|
+
ïı£ NostrBuildUploader.upload (2.212377ms) # SKIP
|
|
82
|
+
â CircularSet (14.732834ms)
|
|
83
|
+
â push, iterate, & close (109.180767ms)
|
|
84
|
+
â close & reopen (0.918119ms)
|
|
85
|
+
â aborts with signal (53.398331ms)
|
|
86
|
+
â already aborted signal in constructor (0.819754ms)
|
|
87
|
+
â push after abort (1.01538ms)
|
|
88
|
+
â multiple messages in queue (0.693816ms)
|
|
89
|
+
â N64 (13.23745ms)
|
|
90
|
+
â N64.encodeEvent (0.744977ms)
|
|
91
|
+
â N64.decodeEvent (1.885313ms)
|
|
92
|
+
âı tests 85
|
|
85
93
|
âı suites 0
|
|
86
|
-
âı pass
|
|
94
|
+
âı pass 82
|
|
87
95
|
âı fail 0
|
|
88
96
|
âı cancelled 0
|
|
89
97
|
âı skipped 3
|
|
90
98
|
âı todo 0
|
|
91
|
-
âı duration_ms
|
|
99
|
+
âı duration_ms 2367.358539
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.48.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- remove happy-dom dependency, fix improper test in NRelay1
|
|
8
|
+
|
|
9
|
+
## 0.48.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Remove all JSR imports
|
|
14
|
+
|
|
3
15
|
## 0.47.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -71,7 +83,8 @@
|
|
|
71
83
|
All notable changes to this project will be documented in this file.
|
|
72
84
|
|
|
73
85
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
74
|
-
and this project adheres to
|
|
86
|
+
and this project adheres to
|
|
87
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
75
88
|
|
|
76
89
|
## 0.46.4 - 2025-07-15
|
|
77
90
|
|
|
@@ -83,7 +96,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
83
96
|
|
|
84
97
|
### Fixed
|
|
85
98
|
|
|
86
|
-
- Fix fetch calls in browser by binding globalThis (NIP05, LNURL,
|
|
99
|
+
- Fix fetch calls in browser by binding globalThis (NIP05, LNURL,
|
|
100
|
+
BlossomUploader).
|
|
87
101
|
- BlossomUploader: use a browser-supported file hashing method.
|
|
88
102
|
|
|
89
103
|
## 0.46.0 - 2025-05-10
|
|
@@ -108,7 +122,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
108
122
|
|
|
109
123
|
### Changed
|
|
110
124
|
|
|
111
|
-
- BREAKING: Redesign the `LNURL` module to be a stateful class, more similar to
|
|
125
|
+
- BREAKING: Redesign the `LNURL` module to be a stateful class, more similar to
|
|
126
|
+
`URL`.
|
|
112
127
|
|
|
113
128
|
## 0.44.0 - 2025-04-23
|
|
114
129
|
|
|
@@ -120,7 +135,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
120
135
|
|
|
121
136
|
### Changed
|
|
122
137
|
|
|
123
|
-
- Moved `NSeedSigner`, `NPhraseSigner`, and `NCustodial` into a separate
|
|
138
|
+
- Moved `NSeedSigner`, `NPhraseSigner`, and `NCustodial` into a separate
|
|
139
|
+
`@nostrify/seed` package.
|
|
124
140
|
|
|
125
141
|
## 0.42.1 - 2025-04-10
|
|
126
142
|
|
|
@@ -155,7 +171,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
155
171
|
|
|
156
172
|
### Added
|
|
157
173
|
|
|
158
|
-
- NRelay1: batch ids-only filters and filters for replaceable events by
|
|
174
|
+
- NRelay1: batch ids-only filters and filters for replaceable events by
|
|
175
|
+
author/kind within the same event loop.
|
|
159
176
|
|
|
160
177
|
## 0.40.0 - 2025-03-26
|
|
161
178
|
|
|
@@ -254,7 +271,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
254
271
|
|
|
255
272
|
### Added
|
|
256
273
|
|
|
257
|
-
- NRelay1: added `idleTimeout` option to automatically close inactive
|
|
274
|
+
- NRelay1: added `idleTimeout` option to automatically close inactive
|
|
275
|
+
connections.
|
|
258
276
|
- NRelay1: support `await using` syntax.
|
|
259
277
|
|
|
260
278
|
## 0.31.0 - 2024-09-09
|
|
@@ -262,11 +280,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
262
280
|
### Added
|
|
263
281
|
|
|
264
282
|
- Added ReplyBotPolicy to block replies from bots in the same second.
|
|
265
|
-
- Added AuthorPolicy to reject events from authors without a kind 0, or with a
|
|
283
|
+
- Added AuthorPolicy to reject events from authors without a kind 0, or with a
|
|
284
|
+
particular kind 0.
|
|
266
285
|
|
|
267
286
|
### Changed
|
|
268
287
|
|
|
269
|
-
- BREAKING: Moved moderation policies to the `@nostrify/policies` package.
|
|
288
|
+
- BREAKING: Moved moderation policies to the `@nostrify/policies` package.
|
|
289
|
+
Replace `@nostrify/nostrify/policies` with `@nostrify/policies` in your
|
|
290
|
+
project.
|
|
270
291
|
|
|
271
292
|
### Fixed
|
|
272
293
|
|
|
@@ -306,7 +327,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
306
327
|
|
|
307
328
|
### Changed
|
|
308
329
|
|
|
309
|
-
- BREAKING: NDatabase: add kind, pubkey, and created_at columns to nostr_tags
|
|
330
|
+
- BREAKING: NDatabase: add kind, pubkey, and created_at columns to nostr_tags
|
|
331
|
+
table. These columns are non-nullable, so the old database will need to be
|
|
332
|
+
deleted or manually migrated.
|
|
310
333
|
|
|
311
334
|
## [0.26.3] - 2024-07-18
|
|
312
335
|
|
|
@@ -330,7 +353,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
330
353
|
|
|
331
354
|
### Changed
|
|
332
355
|
|
|
333
|
-
- BREAKING: NPool: remove `reqRelays` option, add `reqRouter`. Rename
|
|
356
|
+
- BREAKING: NPool: remove `reqRelays` option, add `reqRouter`. Rename
|
|
357
|
+
`eventRelays` to `eventRouter`.
|
|
334
358
|
|
|
335
359
|
## [0.25.0] - 2024-06-29
|
|
336
360
|
|
|
@@ -348,7 +372,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
348
372
|
|
|
349
373
|
### Fixed
|
|
350
374
|
|
|
351
|
-
- NDatabase: add intrinsic limits to filters when applicable, skip 0 limit
|
|
375
|
+
- NDatabase: add intrinsic limits to filters when applicable, skip 0 limit
|
|
376
|
+
filters.
|
|
352
377
|
|
|
353
378
|
## [0.23.2] - 2024-06-13
|
|
354
379
|
|
|
@@ -391,7 +416,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
391
416
|
|
|
392
417
|
### Fixed
|
|
393
418
|
|
|
394
|
-
- NostrMetadata: added `website` field so `NSchema.metadata()` returns the
|
|
419
|
+
- NostrMetadata: added `website` field so `NSchema.metadata()` returns the
|
|
420
|
+
correct type.
|
|
395
421
|
|
|
396
422
|
### Changed
|
|
397
423
|
|
|
@@ -416,7 +442,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
416
442
|
|
|
417
443
|
### Added
|
|
418
444
|
|
|
419
|
-
- `NUploader` interface and two uploader classes under
|
|
445
|
+
- `NUploader` interface and two uploader classes under
|
|
446
|
+
`@nostrify/nostrify/uploaders`.
|
|
420
447
|
- Blossom uploader (`BlossomUploader`) to upload files to Blossom servers.
|
|
421
448
|
- nostr.build uploader (`NostrBuildUploader`) to upload files to nostr.build.
|
|
422
449
|
- `NIP98` module to verify NIP-98 Requests.
|
|
@@ -431,11 +458,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
431
458
|
|
|
432
459
|
### Added
|
|
433
460
|
|
|
434
|
-
- NConnectSigner: NIP-44 encryption support by setting `{ encryption: 'nip44' }`
|
|
461
|
+
- NConnectSigner: NIP-44 encryption support by setting `{ encryption: 'nip44' }`
|
|
462
|
+
in the constructor.
|
|
435
463
|
|
|
436
464
|
### Fixed
|
|
437
465
|
|
|
438
|
-
- NDatabase: Postgres FTS now correctly uses the `searchText` option to create
|
|
466
|
+
- NDatabase: Postgres FTS now correctly uses the `searchText` option to create
|
|
467
|
+
the search index.
|
|
439
468
|
|
|
440
469
|
## [0.20.0] - 2024-05-16
|
|
441
470
|
|
|
@@ -445,7 +474,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
445
474
|
|
|
446
475
|
### Changed
|
|
447
476
|
|
|
448
|
-
- BREAKING: NDatabase `fts5` option has been renamed to `fts`, and now accepts a
|
|
477
|
+
- BREAKING: NDatabase `fts5` option has been renamed to `fts`, and now accepts a
|
|
478
|
+
string of either `'sqlite'` or `'postgres'`.
|
|
449
479
|
|
|
450
480
|
## [0.19.2] - 2024-05-16
|
|
451
481
|
|
|
@@ -457,14 +487,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
457
487
|
|
|
458
488
|
### Fixed
|
|
459
489
|
|
|
460
|
-
- NDatabase: fix deleting everything for the author when they delete a single
|
|
490
|
+
- NDatabase: fix deleting everything for the author when they delete a single
|
|
491
|
+
event.
|
|
461
492
|
|
|
462
493
|
## [0.19.0] - 2024-05-13
|
|
463
494
|
|
|
464
495
|
### Fixed
|
|
465
496
|
|
|
466
497
|
- Improved performance of NDatabase when querying replaceable events by author.
|
|
467
|
-
- NConnect.signEvent now throws if the connect message was rejected by the
|
|
498
|
+
- NConnect.signEvent now throws if the connect message was rejected by the
|
|
499
|
+
relay.
|
|
468
500
|
|
|
469
501
|
## [0.18.0] - 2024-05-04
|
|
470
502
|
|
|
@@ -474,13 +506,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
474
506
|
|
|
475
507
|
## [0.17.1] - 2024-04-29
|
|
476
508
|
|
|
477
|
-
Redeploy to JSR (to hopefully fix
|
|
509
|
+
Redeploy to JSR (to hopefully fix
|
|
510
|
+
[npm compatibility](https://github.com/jsr-io/jsr/issues/446)).
|
|
478
511
|
|
|
479
512
|
## [0.17.0] - 2024-04-28
|
|
480
513
|
|
|
481
514
|
### Changed
|
|
482
515
|
|
|
483
|
-
- BREAKING: change `NRelay.req` return type from an AsyncGenerator to an
|
|
516
|
+
- BREAKING: change `NRelay.req` return type from an AsyncGenerator to an
|
|
517
|
+
AsyncIterable.
|
|
484
518
|
|
|
485
519
|
## [0.16.0] - 2024-04-25
|
|
486
520
|
|
|
@@ -504,7 +538,8 @@ Redeploy to JSR (to hopefully fix [npm compatibility](https://github.com/jsr-io/
|
|
|
504
538
|
|
|
505
539
|
### Fixed
|
|
506
540
|
|
|
507
|
-
- `NConnectSigner` - fixed race condition between sending messages and receiving
|
|
541
|
+
- `NConnectSigner` - fixed race condition between sending messages and receiving
|
|
542
|
+
responses.
|
|
508
543
|
|
|
509
544
|
## [0.14.1] - 2024-04-24
|
|
510
545
|
|
|
@@ -516,7 +551,8 @@ Redeploy to JSR (to hopefully fix [npm compatibility](https://github.com/jsr-io/
|
|
|
516
551
|
|
|
517
552
|
### Fixed
|
|
518
553
|
|
|
519
|
-
- BREAKING: fixed `NConnectSigner.connect` method signature (it doesn't need to
|
|
554
|
+
- BREAKING: fixed `NConnectSigner.connect` method signature (it doesn't need to
|
|
555
|
+
accept a pubkey).
|
|
520
556
|
|
|
521
557
|
## [0.13.0] - 2024-04-24
|
|
522
558
|
|
|
@@ -534,7 +570,8 @@ Redeploy to JSR (to hopefully fix [npm compatibility](https://github.com/jsr-io/
|
|
|
534
570
|
|
|
535
571
|
### Added
|
|
536
572
|
|
|
537
|
-
- Added `AnyPolicy` policy, a pipeline policy which rejects only if all policies
|
|
573
|
+
- Added `AnyPolicy` policy, a pipeline policy which rejects only if all policies
|
|
574
|
+
reject.
|
|
538
575
|
|
|
539
576
|
### Changed
|
|
540
577
|
|
|
@@ -544,7 +581,8 @@ Redeploy to JSR (to hopefully fix [npm compatibility](https://github.com/jsr-io/
|
|
|
544
581
|
|
|
545
582
|
### Added
|
|
546
583
|
|
|
547
|
-
- Added moderation policies. Including the `NPolicy` interface and several
|
|
584
|
+
- Added moderation policies. Including the `NPolicy` interface and several
|
|
585
|
+
policies.
|
|
548
586
|
|
|
549
587
|
## [0.10.2] - 2024-04-21
|
|
550
588
|
|
package/NIP98.test.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { test } from "node:test";
|
|
2
2
|
import { deepStrictEqual, rejects } from "node:assert";
|
|
3
3
|
import { generateSecretKey } from "nostr-tools";
|
|
4
|
-
import { ZodError } from "zod";
|
|
5
|
-
|
|
6
4
|
import { NIP98 } from "./NIP98.ts";
|
|
7
5
|
import { NSecSigner } from "./NSecSigner.ts";
|
|
8
6
|
import { N64 } from "./utils/mod.ts";
|
|
@@ -78,7 +76,7 @@ await test("NIP98.verify fails with invalid token", async () => {
|
|
|
78
76
|
|
|
79
77
|
await rejects(
|
|
80
78
|
() => NIP98.verify(request),
|
|
81
|
-
|
|
79
|
+
(e) => e instanceof Error && e.message === "Invalid token",
|
|
82
80
|
);
|
|
83
81
|
});
|
|
84
82
|
|
package/NIP98.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { NostrEvent } from
|
|
2
|
-
import {
|
|
3
|
-
import { verifyEvent as _verifyEvent } from
|
|
1
|
+
import type { NostrEvent } from "@nostrify/types";
|
|
2
|
+
import { toHex } from "@smithy/util-hex-encoding";
|
|
3
|
+
import { verifyEvent as _verifyEvent } from "nostr-tools";
|
|
4
4
|
|
|
5
|
-
import { N64 } from
|
|
5
|
+
import { N64 } from "./utils/N64.ts";
|
|
6
6
|
|
|
7
7
|
/** [NIP-98](https://github.com/nostr-protocol/nips/blob/master/98.md) HTTP auth. */
|
|
8
8
|
export class NIP98 {
|
|
@@ -10,27 +10,27 @@ export class NIP98 {
|
|
|
10
10
|
static async template(
|
|
11
11
|
request: Request,
|
|
12
12
|
opts?: { validatePayload?: boolean },
|
|
13
|
-
): Promise<Omit<NostrEvent,
|
|
13
|
+
): Promise<Omit<NostrEvent, "id" | "pubkey" | "sig">> {
|
|
14
14
|
const {
|
|
15
|
-
validatePayload = [
|
|
15
|
+
validatePayload = ["POST", "PUT", "PATCH"].includes(request.method),
|
|
16
16
|
} = opts ?? {};
|
|
17
17
|
const { method, url } = request;
|
|
18
18
|
|
|
19
19
|
const tags = [
|
|
20
|
-
[
|
|
21
|
-
[
|
|
20
|
+
["method", method],
|
|
21
|
+
["u", url],
|
|
22
22
|
];
|
|
23
23
|
|
|
24
24
|
if (validatePayload) {
|
|
25
25
|
const buffer = await request.clone().arrayBuffer();
|
|
26
|
-
const digest = await crypto.subtle.digest(
|
|
26
|
+
const digest = await crypto.subtle.digest("SHA-256", buffer);
|
|
27
27
|
|
|
28
|
-
tags.push([
|
|
28
|
+
tags.push(["payload", toHex(new Uint8Array(digest))]);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
return {
|
|
32
32
|
kind: 27235,
|
|
33
|
-
content:
|
|
33
|
+
content: "",
|
|
34
34
|
tags,
|
|
35
35
|
created_at: Math.floor(Date.now() / 1000),
|
|
36
36
|
};
|
|
@@ -47,48 +47,62 @@ export class NIP98 {
|
|
|
47
47
|
): Promise<NostrEvent> {
|
|
48
48
|
const {
|
|
49
49
|
maxAge = 60_000,
|
|
50
|
-
validatePayload = [
|
|
50
|
+
validatePayload = ["POST", "PUT", "PATCH"].includes(request.method),
|
|
51
51
|
verifyEvent = _verifyEvent,
|
|
52
52
|
} = opts ?? {};
|
|
53
53
|
|
|
54
|
-
const header = request.headers.get(
|
|
54
|
+
const header = request.headers.get("authorization");
|
|
55
55
|
if (!header) {
|
|
56
|
-
throw new Error(
|
|
56
|
+
throw new Error("Missing Nostr authorization header");
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
const token = header.match(/^Nostr (.+)$/)?.[1];
|
|
60
60
|
if (!token) {
|
|
61
|
-
throw new Error(
|
|
61
|
+
throw new Error("Missing Nostr authorization token");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let event: NostrEvent;
|
|
65
|
+
try {
|
|
66
|
+
event = N64.decodeEvent(token);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
if (
|
|
69
|
+
e instanceof TypeError &&
|
|
70
|
+
e.message.includes("Incorrect padding on base64")
|
|
71
|
+
) {
|
|
72
|
+
throw new Error("Invalid token");
|
|
73
|
+
} else {
|
|
74
|
+
throw e;
|
|
75
|
+
}
|
|
62
76
|
}
|
|
63
77
|
|
|
64
|
-
const event = N64.decodeEvent(token);
|
|
65
78
|
if (!verifyEvent(event)) {
|
|
66
|
-
throw new Error(
|
|
79
|
+
throw new Error("Event signature is invalid");
|
|
67
80
|
}
|
|
68
81
|
|
|
69
82
|
const age = Date.now() - (event.created_at * 1_000);
|
|
70
|
-
const u = event.tags.find(([name]) => name ===
|
|
71
|
-
const method = event.tags.find(([name]) => name ===
|
|
72
|
-
const payload = event.tags.find(([name]) => name ===
|
|
83
|
+
const u = event.tags.find(([name]) => name === "u")?.[1];
|
|
84
|
+
const method = event.tags.find(([name]) => name === "method")?.[1];
|
|
85
|
+
const payload = event.tags.find(([name]) => name === "payload")?.[1];
|
|
73
86
|
|
|
74
87
|
if (event.kind !== 27235) {
|
|
75
|
-
throw new Error(
|
|
88
|
+
throw new Error("Event must be kind 27235");
|
|
76
89
|
}
|
|
77
90
|
if (u !== request.url) {
|
|
78
|
-
throw new Error(
|
|
91
|
+
throw new Error("Event URL does not match request URL");
|
|
79
92
|
}
|
|
80
93
|
if (method !== request.method) {
|
|
81
|
-
throw new Error(
|
|
94
|
+
throw new Error("Event method does not match HTTP request method");
|
|
82
95
|
}
|
|
83
96
|
if (age >= maxAge) {
|
|
84
|
-
throw new Error(
|
|
97
|
+
throw new Error("Event expired");
|
|
85
98
|
}
|
|
86
99
|
if (validatePayload && payload !== undefined) {
|
|
87
100
|
const buffer = await request.clone().arrayBuffer();
|
|
88
|
-
const digest = await crypto.subtle.digest(
|
|
101
|
+
const digest = await crypto.subtle.digest("SHA-256", buffer);
|
|
102
|
+
const hexed = toHex(new Uint8Array(digest));
|
|
89
103
|
|
|
90
|
-
if (
|
|
91
|
-
throw new Error(
|
|
104
|
+
if (hexed !== payload) {
|
|
105
|
+
throw new Error("Event payload does not match request body");
|
|
92
106
|
}
|
|
93
107
|
}
|
|
94
108
|
|
package/NRelay1.test.ts
CHANGED
|
@@ -157,9 +157,12 @@ await test("NRelay1 idleTimeout", async () => {
|
|
|
157
157
|
await using relay = new NRelay1(server.url, { idleTimeout: 100 });
|
|
158
158
|
|
|
159
159
|
await it("websocket opens", async () => {
|
|
160
|
-
await new Promise((resolve) =>
|
|
160
|
+
await new Promise((resolve) =>
|
|
161
|
+
relay.socket.addEventListener(WebsocketEvent.open, resolve, {
|
|
162
|
+
once: true,
|
|
163
|
+
})
|
|
164
|
+
);
|
|
161
165
|
deepStrictEqual(relay.socket.readyState, WebSocket.OPEN);
|
|
162
|
-
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
163
166
|
});
|
|
164
167
|
|
|
165
168
|
await it("websocket closes after idleTimeout", async () => {
|
package/dist/NIP98.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { NostrEvent } from
|
|
1
|
+
import type { NostrEvent } from "@nostrify/types";
|
|
2
2
|
/** [NIP-98](https://github.com/nostr-protocol/nips/blob/master/98.md) HTTP auth. */
|
|
3
3
|
export declare class NIP98 {
|
|
4
4
|
/** Generate an auth event template from a Request. */
|
|
5
5
|
static template(request: Request, opts?: {
|
|
6
6
|
validatePayload?: boolean;
|
|
7
|
-
}): Promise<Omit<NostrEvent,
|
|
7
|
+
}): Promise<Omit<NostrEvent, "id" | "pubkey" | "sig">>;
|
|
8
8
|
/** Compare the auth event with the request, throwing a human-readable error if validation fails. */
|
|
9
9
|
static verify(request: Request, opts?: {
|
|
10
10
|
maxAge?: number;
|
package/dist/NIP98.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NIP98.d.ts","sourceRoot":"","sources":["../NIP98.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMlD,oFAAoF;AACpF,qBAAa,KAAK;IAChB,sDAAsD;WACzC,QAAQ,CACnB,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE,GACnC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC,CAAC;IA0BrD,oGAAoG;WACvF,MAAM,CACjB,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC;KAC9C,GACA,OAAO,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"NIP98.d.ts","sourceRoot":"","sources":["../NIP98.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMlD,oFAAoF;AACpF,qBAAa,KAAK;IAChB,sDAAsD;WACzC,QAAQ,CACnB,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE,GACnC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,GAAG,QAAQ,GAAG,KAAK,CAAC,CAAC;IA0BrD,oGAAoG;WACvF,MAAM,CACjB,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC;KAC9C,GACA,OAAO,CAAC,UAAU,CAAC;CAgEvB"}
|