@nostrify/nostrify 0.47.0 â 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 +68 -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/NIP98Client.d.ts +14 -0
- package/dist/NIP98Client.d.ts.map +1 -0
- package/dist/NIP98Client.js +22 -0
- package/dist/NIP98Client.ts +36 -0
- package/dist/mod.d.ts +1 -0
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +2 -0
- package/dist/mod.ts +1 -0
- 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,23 @@
|
|
|
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
|
+
|
|
15
|
+
## 0.47.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- rebuild package for NIP98Client member
|
|
20
|
+
|
|
3
21
|
## 0.47.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -65,7 +83,8 @@
|
|
|
65
83
|
All notable changes to this project will be documented in this file.
|
|
66
84
|
|
|
67
85
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
68
|
-
and this project adheres to
|
|
86
|
+
and this project adheres to
|
|
87
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
69
88
|
|
|
70
89
|
## 0.46.4 - 2025-07-15
|
|
71
90
|
|
|
@@ -77,7 +96,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
77
96
|
|
|
78
97
|
### Fixed
|
|
79
98
|
|
|
80
|
-
- Fix fetch calls in browser by binding globalThis (NIP05, LNURL,
|
|
99
|
+
- Fix fetch calls in browser by binding globalThis (NIP05, LNURL,
|
|
100
|
+
BlossomUploader).
|
|
81
101
|
- BlossomUploader: use a browser-supported file hashing method.
|
|
82
102
|
|
|
83
103
|
## 0.46.0 - 2025-05-10
|
|
@@ -102,7 +122,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
102
122
|
|
|
103
123
|
### Changed
|
|
104
124
|
|
|
105
|
-
- 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`.
|
|
106
127
|
|
|
107
128
|
## 0.44.0 - 2025-04-23
|
|
108
129
|
|
|
@@ -114,7 +135,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
114
135
|
|
|
115
136
|
### Changed
|
|
116
137
|
|
|
117
|
-
- Moved `NSeedSigner`, `NPhraseSigner`, and `NCustodial` into a separate
|
|
138
|
+
- Moved `NSeedSigner`, `NPhraseSigner`, and `NCustodial` into a separate
|
|
139
|
+
`@nostrify/seed` package.
|
|
118
140
|
|
|
119
141
|
## 0.42.1 - 2025-04-10
|
|
120
142
|
|
|
@@ -149,7 +171,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
149
171
|
|
|
150
172
|
### Added
|
|
151
173
|
|
|
152
|
-
- 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.
|
|
153
176
|
|
|
154
177
|
## 0.40.0 - 2025-03-26
|
|
155
178
|
|
|
@@ -248,7 +271,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
248
271
|
|
|
249
272
|
### Added
|
|
250
273
|
|
|
251
|
-
- NRelay1: added `idleTimeout` option to automatically close inactive
|
|
274
|
+
- NRelay1: added `idleTimeout` option to automatically close inactive
|
|
275
|
+
connections.
|
|
252
276
|
- NRelay1: support `await using` syntax.
|
|
253
277
|
|
|
254
278
|
## 0.31.0 - 2024-09-09
|
|
@@ -256,11 +280,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
256
280
|
### Added
|
|
257
281
|
|
|
258
282
|
- Added ReplyBotPolicy to block replies from bots in the same second.
|
|
259
|
-
- 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.
|
|
260
285
|
|
|
261
286
|
### Changed
|
|
262
287
|
|
|
263
|
-
- 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.
|
|
264
291
|
|
|
265
292
|
### Fixed
|
|
266
293
|
|
|
@@ -300,7 +327,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
300
327
|
|
|
301
328
|
### Changed
|
|
302
329
|
|
|
303
|
-
- 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.
|
|
304
333
|
|
|
305
334
|
## [0.26.3] - 2024-07-18
|
|
306
335
|
|
|
@@ -324,7 +353,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
324
353
|
|
|
325
354
|
### Changed
|
|
326
355
|
|
|
327
|
-
- BREAKING: NPool: remove `reqRelays` option, add `reqRouter`. Rename
|
|
356
|
+
- BREAKING: NPool: remove `reqRelays` option, add `reqRouter`. Rename
|
|
357
|
+
`eventRelays` to `eventRouter`.
|
|
328
358
|
|
|
329
359
|
## [0.25.0] - 2024-06-29
|
|
330
360
|
|
|
@@ -342,7 +372,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
342
372
|
|
|
343
373
|
### Fixed
|
|
344
374
|
|
|
345
|
-
- 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.
|
|
346
377
|
|
|
347
378
|
## [0.23.2] - 2024-06-13
|
|
348
379
|
|
|
@@ -385,7 +416,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
385
416
|
|
|
386
417
|
### Fixed
|
|
387
418
|
|
|
388
|
-
- NostrMetadata: added `website` field so `NSchema.metadata()` returns the
|
|
419
|
+
- NostrMetadata: added `website` field so `NSchema.metadata()` returns the
|
|
420
|
+
correct type.
|
|
389
421
|
|
|
390
422
|
### Changed
|
|
391
423
|
|
|
@@ -410,7 +442,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
410
442
|
|
|
411
443
|
### Added
|
|
412
444
|
|
|
413
|
-
- `NUploader` interface and two uploader classes under
|
|
445
|
+
- `NUploader` interface and two uploader classes under
|
|
446
|
+
`@nostrify/nostrify/uploaders`.
|
|
414
447
|
- Blossom uploader (`BlossomUploader`) to upload files to Blossom servers.
|
|
415
448
|
- nostr.build uploader (`NostrBuildUploader`) to upload files to nostr.build.
|
|
416
449
|
- `NIP98` module to verify NIP-98 Requests.
|
|
@@ -425,11 +458,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
425
458
|
|
|
426
459
|
### Added
|
|
427
460
|
|
|
428
|
-
- NConnectSigner: NIP-44 encryption support by setting `{ encryption: 'nip44' }`
|
|
461
|
+
- NConnectSigner: NIP-44 encryption support by setting `{ encryption: 'nip44' }`
|
|
462
|
+
in the constructor.
|
|
429
463
|
|
|
430
464
|
### Fixed
|
|
431
465
|
|
|
432
|
-
- 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.
|
|
433
468
|
|
|
434
469
|
## [0.20.0] - 2024-05-16
|
|
435
470
|
|
|
@@ -439,7 +474,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
439
474
|
|
|
440
475
|
### Changed
|
|
441
476
|
|
|
442
|
-
- 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'`.
|
|
443
479
|
|
|
444
480
|
## [0.19.2] - 2024-05-16
|
|
445
481
|
|
|
@@ -451,14 +487,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
451
487
|
|
|
452
488
|
### Fixed
|
|
453
489
|
|
|
454
|
-
- 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.
|
|
455
492
|
|
|
456
493
|
## [0.19.0] - 2024-05-13
|
|
457
494
|
|
|
458
495
|
### Fixed
|
|
459
496
|
|
|
460
497
|
- Improved performance of NDatabase when querying replaceable events by author.
|
|
461
|
-
- 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.
|
|
462
500
|
|
|
463
501
|
## [0.18.0] - 2024-05-04
|
|
464
502
|
|
|
@@ -468,13 +506,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
468
506
|
|
|
469
507
|
## [0.17.1] - 2024-04-29
|
|
470
508
|
|
|
471
|
-
Redeploy to JSR (to hopefully fix
|
|
509
|
+
Redeploy to JSR (to hopefully fix
|
|
510
|
+
[npm compatibility](https://github.com/jsr-io/jsr/issues/446)).
|
|
472
511
|
|
|
473
512
|
## [0.17.0] - 2024-04-28
|
|
474
513
|
|
|
475
514
|
### Changed
|
|
476
515
|
|
|
477
|
-
- 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.
|
|
478
518
|
|
|
479
519
|
## [0.16.0] - 2024-04-25
|
|
480
520
|
|
|
@@ -498,7 +538,8 @@ Redeploy to JSR (to hopefully fix [npm compatibility](https://github.com/jsr-io/
|
|
|
498
538
|
|
|
499
539
|
### Fixed
|
|
500
540
|
|
|
501
|
-
- `NConnectSigner` - fixed race condition between sending messages and receiving
|
|
541
|
+
- `NConnectSigner` - fixed race condition between sending messages and receiving
|
|
542
|
+
responses.
|
|
502
543
|
|
|
503
544
|
## [0.14.1] - 2024-04-24
|
|
504
545
|
|
|
@@ -510,7 +551,8 @@ Redeploy to JSR (to hopefully fix [npm compatibility](https://github.com/jsr-io/
|
|
|
510
551
|
|
|
511
552
|
### Fixed
|
|
512
553
|
|
|
513
|
-
- 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).
|
|
514
556
|
|
|
515
557
|
## [0.13.0] - 2024-04-24
|
|
516
558
|
|
|
@@ -528,7 +570,8 @@ Redeploy to JSR (to hopefully fix [npm compatibility](https://github.com/jsr-io/
|
|
|
528
570
|
|
|
529
571
|
### Added
|
|
530
572
|
|
|
531
|
-
- 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.
|
|
532
575
|
|
|
533
576
|
### Changed
|
|
534
577
|
|
|
@@ -538,7 +581,8 @@ Redeploy to JSR (to hopefully fix [npm compatibility](https://github.com/jsr-io/
|
|
|
538
581
|
|
|
539
582
|
### Added
|
|
540
583
|
|
|
541
|
-
- Added moderation policies. Including the `NPolicy` interface and several
|
|
584
|
+
- Added moderation policies. Including the `NPolicy` interface and several
|
|
585
|
+
policies.
|
|
542
586
|
|
|
543
587
|
## [0.10.2] - 2024-04-21
|
|
544
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"}
|