nostr 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +1 -1
- data/.rubocop.yml +26 -0
- data/.tool-versions +2 -1
- data/CHANGELOG.md +65 -1
- data/README.md +96 -183
- data/Steepfile +2 -0
- data/docs/.gitignore +4 -0
- data/docs/.vitepress/config.mjs +112 -0
- data/docs/README.md +44 -0
- data/docs/api-examples.md +49 -0
- data/docs/bun.lockb +0 -0
- data/docs/common-use-cases/bech32-encoding-and-decoding-(NIP-19).md +190 -0
- data/docs/core/client.md +108 -0
- data/docs/core/keys.md +136 -0
- data/docs/core/user.md +43 -0
- data/docs/events/contact-list.md +29 -0
- data/docs/events/encrypted-direct-message.md +28 -0
- data/docs/events/recommend-server.md +32 -0
- data/docs/events/set-metadata.md +20 -0
- data/docs/events/text-note.md +15 -0
- data/docs/events.md +11 -0
- data/docs/getting-started/installation.md +21 -0
- data/docs/getting-started/overview.md +170 -0
- data/docs/implemented-nips.md +9 -0
- data/docs/index.md +44 -0
- data/docs/markdown-examples.md +85 -0
- data/docs/package.json +12 -0
- data/docs/relays/connecting-to-a-relay.md +21 -0
- data/docs/relays/publishing-events.md +29 -0
- data/docs/relays/receiving-events.md +6 -0
- data/docs/subscriptions/creating-a-subscription.md +49 -0
- data/docs/subscriptions/deleting-a-subscription.md +10 -0
- data/docs/subscriptions/filtering-subscription-events.md +115 -0
- data/docs/subscriptions/updating-a-subscription.md +4 -0
- data/lib/nostr/bech32.rb +203 -0
- data/lib/nostr/client.rb +2 -1
- data/lib/nostr/crypto.rb +147 -0
- data/lib/nostr/errors/error.rb +7 -0
- data/lib/nostr/errors/invalid_hrp_error.rb +21 -0
- data/lib/nostr/errors/invalid_key_format_error.rb +20 -0
- data/lib/nostr/errors/invalid_key_length_error.rb +20 -0
- data/lib/nostr/errors/invalid_key_type_error.rb +18 -0
- data/lib/nostr/errors/key_validation_error.rb +6 -0
- data/lib/nostr/errors.rb +8 -0
- data/lib/nostr/event.rb +157 -12
- data/lib/nostr/event_kind.rb +8 -0
- data/lib/nostr/events/encrypted_direct_message.rb +54 -0
- data/lib/nostr/filter.rb +4 -4
- data/lib/nostr/key.rb +100 -0
- data/lib/nostr/key_pair.rb +30 -6
- data/lib/nostr/keygen.rb +43 -4
- data/lib/nostr/private_key.rb +36 -0
- data/lib/nostr/public_key.rb +36 -0
- data/lib/nostr/relay_message_type.rb +18 -0
- data/lib/nostr/subscription.rb +2 -2
- data/lib/nostr/user.rb +17 -36
- data/lib/nostr/version.rb +1 -1
- data/lib/nostr.rb +8 -1
- data/nostr.gemspec +9 -9
- data/sig/nostr/bech32.rbs +14 -0
- data/sig/nostr/client.rbs +5 -5
- data/sig/nostr/crypto.rbs +16 -0
- data/sig/nostr/errors/error.rbs +4 -0
- data/sig/nostr/errors/invalid_hrb_error.rbs +6 -0
- data/sig/nostr/errors/invalid_key_format_error.rbs +5 -0
- data/sig/nostr/errors/invalid_key_length_error.rbs +5 -0
- data/sig/nostr/errors/invalid_key_type_error.rbs +5 -0
- data/sig/nostr/errors/key_validation_error.rbs +4 -0
- data/sig/nostr/event.rbs +24 -9
- data/sig/nostr/event_kind.rbs +1 -0
- data/sig/nostr/events/encrypted_direct_message.rbs +12 -0
- data/sig/nostr/filter.rbs +3 -12
- data/sig/nostr/key.rbs +16 -0
- data/sig/nostr/key_pair.rbs +7 -3
- data/sig/nostr/keygen.rbs +5 -2
- data/sig/nostr/private_key.rbs +4 -0
- data/sig/nostr/public_key.rbs +4 -0
- data/sig/nostr/relay_message_type.rbs +8 -0
- data/sig/nostr/user.rbs +4 -10
- data/sig/vendor/bech32/nostr/entity.rbs +41 -0
- data/sig/vendor/bech32/nostr/nip19.rbs +20 -0
- data/sig/vendor/bech32/segwit_addr.rbs +21 -0
- data/sig/vendor/bech32.rbs +25 -0
- data/sig/vendor/event_emitter.rbs +10 -3
- data/sig/vendor/event_machine/channel.rbs +1 -1
- data/sig/vendor/faye/websocket/api.rbs +45 -0
- data/sig/vendor/faye/websocket/client.rbs +43 -0
- data/sig/vendor/faye/websocket.rbs +30 -0
- metadata +83 -23
- data/lib/nostr/event_fragment.rb +0 -111
- data/sig/nostr/event_fragment.rbs +0 -12
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nostr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wilson Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bech32
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bip-schnorr
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: ecdsa
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,14 +226,14 @@ dependencies:
|
|
226
226
|
requirements:
|
227
227
|
- - "~>"
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: '
|
229
|
+
version: '6.4'
|
230
230
|
type: :development
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
234
|
- - "~>"
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version: '
|
236
|
+
version: '6.4'
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: rack
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -254,28 +254,28 @@ dependencies:
|
|
254
254
|
requirements:
|
255
255
|
- - "~>"
|
256
256
|
- !ruby/object:Gem::Version
|
257
|
-
version: '13.
|
257
|
+
version: '13.1'
|
258
258
|
type: :development
|
259
259
|
prerelease: false
|
260
260
|
version_requirements: !ruby/object:Gem::Requirement
|
261
261
|
requirements:
|
262
262
|
- - "~>"
|
263
263
|
- !ruby/object:Gem::Version
|
264
|
-
version: '13.
|
264
|
+
version: '13.1'
|
265
265
|
- !ruby/object:Gem::Dependency
|
266
266
|
name: rbs
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|
268
268
|
requirements:
|
269
269
|
- - "~>"
|
270
270
|
- !ruby/object:Gem::Version
|
271
|
-
version: '
|
271
|
+
version: '3.3'
|
272
272
|
type: :development
|
273
273
|
prerelease: false
|
274
274
|
version_requirements: !ruby/object:Gem::Requirement
|
275
275
|
requirements:
|
276
276
|
- - "~>"
|
277
277
|
- !ruby/object:Gem::Version
|
278
|
-
version: '
|
278
|
+
version: '3.3'
|
279
279
|
- !ruby/object:Gem::Dependency
|
280
280
|
name: rspec
|
281
281
|
requirement: !ruby/object:Gem::Requirement
|
@@ -296,14 +296,14 @@ dependencies:
|
|
296
296
|
requirements:
|
297
297
|
- - "~>"
|
298
298
|
- !ruby/object:Gem::Version
|
299
|
-
version: '1.
|
299
|
+
version: '1.57'
|
300
300
|
type: :development
|
301
301
|
prerelease: false
|
302
302
|
version_requirements: !ruby/object:Gem::Requirement
|
303
303
|
requirements:
|
304
304
|
- - "~>"
|
305
305
|
- !ruby/object:Gem::Version
|
306
|
-
version: '1.
|
306
|
+
version: '1.57'
|
307
307
|
- !ruby/object:Gem::Dependency
|
308
308
|
name: rubocop-rake
|
309
309
|
requirement: !ruby/object:Gem::Requirement
|
@@ -324,14 +324,14 @@ dependencies:
|
|
324
324
|
requirements:
|
325
325
|
- - '='
|
326
326
|
- !ruby/object:Gem::Version
|
327
|
-
version: '2.
|
327
|
+
version: '2.25'
|
328
328
|
type: :development
|
329
329
|
prerelease: false
|
330
330
|
version_requirements: !ruby/object:Gem::Requirement
|
331
331
|
requirements:
|
332
332
|
- - '='
|
333
333
|
- !ruby/object:Gem::Version
|
334
|
-
version: '2.
|
334
|
+
version: '2.25'
|
335
335
|
- !ruby/object:Gem::Dependency
|
336
336
|
name: simplecov
|
337
337
|
requirement: !ruby/object:Gem::Requirement
|
@@ -366,14 +366,14 @@ dependencies:
|
|
366
366
|
requirements:
|
367
367
|
- - "~>"
|
368
368
|
- !ruby/object:Gem::Version
|
369
|
-
version: '1.
|
369
|
+
version: '1.6'
|
370
370
|
type: :development
|
371
371
|
prerelease: false
|
372
372
|
version_requirements: !ruby/object:Gem::Requirement
|
373
373
|
requirements:
|
374
374
|
- - "~>"
|
375
375
|
- !ruby/object:Gem::Version
|
376
|
-
version: '1.
|
376
|
+
version: '1.6'
|
377
377
|
- !ruby/object:Gem::Dependency
|
378
378
|
name: typeprof
|
379
379
|
requirement: !ruby/object:Gem::Requirement
|
@@ -452,43 +452,103 @@ files:
|
|
452
452
|
- README.md
|
453
453
|
- Rakefile
|
454
454
|
- Steepfile
|
455
|
+
- docs/.gitignore
|
456
|
+
- docs/.vitepress/config.mjs
|
457
|
+
- docs/README.md
|
458
|
+
- docs/api-examples.md
|
459
|
+
- docs/bun.lockb
|
460
|
+
- docs/common-use-cases/bech32-encoding-and-decoding-(NIP-19).md
|
461
|
+
- docs/core/client.md
|
462
|
+
- docs/core/keys.md
|
463
|
+
- docs/core/user.md
|
464
|
+
- docs/events.md
|
465
|
+
- docs/events/contact-list.md
|
466
|
+
- docs/events/encrypted-direct-message.md
|
467
|
+
- docs/events/recommend-server.md
|
468
|
+
- docs/events/set-metadata.md
|
469
|
+
- docs/events/text-note.md
|
470
|
+
- docs/getting-started/installation.md
|
471
|
+
- docs/getting-started/overview.md
|
472
|
+
- docs/implemented-nips.md
|
473
|
+
- docs/index.md
|
474
|
+
- docs/markdown-examples.md
|
475
|
+
- docs/package.json
|
476
|
+
- docs/relays/connecting-to-a-relay.md
|
477
|
+
- docs/relays/publishing-events.md
|
478
|
+
- docs/relays/receiving-events.md
|
479
|
+
- docs/subscriptions/creating-a-subscription.md
|
480
|
+
- docs/subscriptions/deleting-a-subscription.md
|
481
|
+
- docs/subscriptions/filtering-subscription-events.md
|
482
|
+
- docs/subscriptions/updating-a-subscription.md
|
455
483
|
- lib/nostr.rb
|
484
|
+
- lib/nostr/bech32.rb
|
456
485
|
- lib/nostr/client.rb
|
457
486
|
- lib/nostr/client_message_type.rb
|
487
|
+
- lib/nostr/crypto.rb
|
488
|
+
- lib/nostr/errors.rb
|
489
|
+
- lib/nostr/errors/error.rb
|
490
|
+
- lib/nostr/errors/invalid_hrp_error.rb
|
491
|
+
- lib/nostr/errors/invalid_key_format_error.rb
|
492
|
+
- lib/nostr/errors/invalid_key_length_error.rb
|
493
|
+
- lib/nostr/errors/invalid_key_type_error.rb
|
494
|
+
- lib/nostr/errors/key_validation_error.rb
|
458
495
|
- lib/nostr/event.rb
|
459
|
-
- lib/nostr/event_fragment.rb
|
460
496
|
- lib/nostr/event_kind.rb
|
497
|
+
- lib/nostr/events/encrypted_direct_message.rb
|
461
498
|
- lib/nostr/filter.rb
|
499
|
+
- lib/nostr/key.rb
|
462
500
|
- lib/nostr/key_pair.rb
|
463
501
|
- lib/nostr/keygen.rb
|
502
|
+
- lib/nostr/private_key.rb
|
503
|
+
- lib/nostr/public_key.rb
|
464
504
|
- lib/nostr/relay.rb
|
505
|
+
- lib/nostr/relay_message_type.rb
|
465
506
|
- lib/nostr/subscription.rb
|
466
507
|
- lib/nostr/user.rb
|
467
508
|
- lib/nostr/version.rb
|
468
509
|
- nostr.gemspec
|
469
510
|
- sig/nostr.rbs
|
511
|
+
- sig/nostr/bech32.rbs
|
470
512
|
- sig/nostr/client.rbs
|
471
513
|
- sig/nostr/client_message_type.rbs
|
514
|
+
- sig/nostr/crypto.rbs
|
515
|
+
- sig/nostr/errors/error.rbs
|
516
|
+
- sig/nostr/errors/invalid_hrb_error.rbs
|
517
|
+
- sig/nostr/errors/invalid_key_format_error.rbs
|
518
|
+
- sig/nostr/errors/invalid_key_length_error.rbs
|
519
|
+
- sig/nostr/errors/invalid_key_type_error.rbs
|
520
|
+
- sig/nostr/errors/key_validation_error.rbs
|
472
521
|
- sig/nostr/event.rbs
|
473
|
-
- sig/nostr/event_fragment.rbs
|
474
522
|
- sig/nostr/event_kind.rbs
|
523
|
+
- sig/nostr/events/encrypted_direct_message.rbs
|
475
524
|
- sig/nostr/filter.rbs
|
525
|
+
- sig/nostr/key.rbs
|
476
526
|
- sig/nostr/key_pair.rbs
|
477
527
|
- sig/nostr/keygen.rbs
|
528
|
+
- sig/nostr/private_key.rbs
|
529
|
+
- sig/nostr/public_key.rbs
|
478
530
|
- sig/nostr/relay.rbs
|
531
|
+
- sig/nostr/relay_message_type.rbs
|
479
532
|
- sig/nostr/subscription.rbs
|
480
533
|
- sig/nostr/user.rbs
|
534
|
+
- sig/vendor/bech32.rbs
|
535
|
+
- sig/vendor/bech32/nostr/entity.rbs
|
536
|
+
- sig/vendor/bech32/nostr/nip19.rbs
|
537
|
+
- sig/vendor/bech32/segwit_addr.rbs
|
481
538
|
- sig/vendor/ecsda/group/secp256k1.rbs
|
482
539
|
- sig/vendor/event_emitter.rbs
|
483
540
|
- sig/vendor/event_machine.rbs
|
484
541
|
- sig/vendor/event_machine/channel.rbs
|
542
|
+
- sig/vendor/faye/websocket.rbs
|
543
|
+
- sig/vendor/faye/websocket/api.rbs
|
544
|
+
- sig/vendor/faye/websocket/client.rbs
|
485
545
|
- sig/vendor/schnorr.rbs
|
486
|
-
homepage: https://
|
546
|
+
homepage: https://nostr-ruby.com/
|
487
547
|
licenses:
|
488
548
|
- MIT
|
489
549
|
metadata:
|
490
550
|
rubygems_mfa_required: 'true'
|
491
|
-
homepage_uri: https://
|
551
|
+
homepage_uri: https://nostr-ruby.com/
|
492
552
|
source_code_uri: https://github.com/wilsonsilva/nostr
|
493
553
|
changelog_uri: https://github.com/wilsonsilva/nostr/blob/main/CHANGELOG.md
|
494
554
|
post_install_message:
|
@@ -506,7 +566,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
506
566
|
- !ruby/object:Gem::Version
|
507
567
|
version: '0'
|
508
568
|
requirements: []
|
509
|
-
rubygems_version: 3.4.
|
569
|
+
rubygems_version: 3.4.20
|
510
570
|
signing_key:
|
511
571
|
specification_version: 4
|
512
572
|
summary: Client and relay implementation of the Nostr protocol.
|
data/lib/nostr/event_fragment.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nostr
|
4
|
-
# Part of an +Event+. A complete +Event+ must have an +id+ and a +sig+.
|
5
|
-
class EventFragment
|
6
|
-
# 32-bytes hex-encoded public key of the event creator
|
7
|
-
#
|
8
|
-
# @api public
|
9
|
-
#
|
10
|
-
# @example
|
11
|
-
# event.pubkey # => '48df4af6e240ac5f7c5de89bf5941b249880be0e87d03685b178ccb1a315f52e'
|
12
|
-
#
|
13
|
-
# @return [String]
|
14
|
-
#
|
15
|
-
attr_reader :pubkey
|
16
|
-
|
17
|
-
# Date of the creation of the vent. A UNIX timestamp, in seconds
|
18
|
-
#
|
19
|
-
# @api public
|
20
|
-
#
|
21
|
-
# @example
|
22
|
-
# event.created_at # => 1230981305
|
23
|
-
#
|
24
|
-
# @return [Integer]
|
25
|
-
#
|
26
|
-
attr_reader :created_at
|
27
|
-
|
28
|
-
# The kind of the event. An integer from 0 to 3
|
29
|
-
#
|
30
|
-
# @api public
|
31
|
-
#
|
32
|
-
# @example
|
33
|
-
# event.kind # => 1
|
34
|
-
#
|
35
|
-
# @return [Integer]
|
36
|
-
#
|
37
|
-
attr_reader :kind
|
38
|
-
|
39
|
-
# An array of tags. Each tag is an array of strings
|
40
|
-
#
|
41
|
-
# @api public
|
42
|
-
#
|
43
|
-
# @example Tags referencing an event
|
44
|
-
# event.tags #=> [["e", "event_id", "relay URL"]]
|
45
|
-
#
|
46
|
-
# @example Tags referencing a key
|
47
|
-
# event.tags #=> [["p", "event_id", "relay URL"]]
|
48
|
-
#
|
49
|
-
# @return [Array<Array>]
|
50
|
-
#
|
51
|
-
attr_reader :tags
|
52
|
-
|
53
|
-
# An arbitrary string
|
54
|
-
#
|
55
|
-
# @api public
|
56
|
-
#
|
57
|
-
# @example
|
58
|
-
# event.content # => 'Your feedback is appreciated, now pay $8'
|
59
|
-
#
|
60
|
-
# @return [String]
|
61
|
-
#
|
62
|
-
attr_reader :content
|
63
|
-
|
64
|
-
# Instantiates a new EventFragment
|
65
|
-
#
|
66
|
-
# @api public
|
67
|
-
#
|
68
|
-
# @example
|
69
|
-
# Nostr::EventFragment.new(
|
70
|
-
# pubkey: 'ccf9fdf3e1466d7c20969c71ec98defcf5f54aee088513e1b73ccb7bd770d460',
|
71
|
-
# created_at: 1230981305,
|
72
|
-
# kind: 1,
|
73
|
-
# tags: [['e', '189df012cfff8a075785b884bd702025f4a7a37710f581c4ac9d33e24b585408']],
|
74
|
-
# content: 'Your feedback is appreciated, now pay $8'
|
75
|
-
# )
|
76
|
-
#
|
77
|
-
# @param pubkey [String] 32-bytes hex-encoded public key of the event creator.
|
78
|
-
# @param created_at [Integer] Date of the creation of the vent. A UNIX timestamp, in seconds.
|
79
|
-
# @param kind [Integer] The kind of the event. An integer from 0 to 3.
|
80
|
-
# @param tags [Array<Array>] An array of tags. Each tag is an array of strings.
|
81
|
-
# @param content [String] Arbitrary string.
|
82
|
-
#
|
83
|
-
def initialize(pubkey:, kind:, content:, created_at: Time.now.to_i, tags: [])
|
84
|
-
@pubkey = pubkey
|
85
|
-
@created_at = created_at
|
86
|
-
@kind = kind
|
87
|
-
@tags = tags
|
88
|
-
@content = content
|
89
|
-
end
|
90
|
-
|
91
|
-
# Serializes the event fragment, to obtain a SHA256 hash of it
|
92
|
-
#
|
93
|
-
# @api public
|
94
|
-
#
|
95
|
-
# @example Converting the event to a hash
|
96
|
-
# event_fragment.serialize
|
97
|
-
#
|
98
|
-
# @return [Array] The event fragment as an array.
|
99
|
-
#
|
100
|
-
def serialize
|
101
|
-
[
|
102
|
-
0,
|
103
|
-
pubkey,
|
104
|
-
created_at,
|
105
|
-
kind,
|
106
|
-
tags,
|
107
|
-
content
|
108
|
-
]
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module Nostr
|
2
|
-
class EventFragment
|
3
|
-
attr_reader pubkey: String
|
4
|
-
attr_reader created_at: Integer
|
5
|
-
attr_reader kind: Integer
|
6
|
-
attr_reader tags: Array[String]
|
7
|
-
attr_reader content: String
|
8
|
-
|
9
|
-
def initialize: (pubkey: String, kind: Integer, content: String, ?created_at: Integer, ?tags: Array[String]) -> void
|
10
|
-
def serialize: -> [Integer, String, Integer, Integer, Array[String], String]
|
11
|
-
end
|
12
|
-
end
|