Skip to content

Commit

Permalink
Drop support for NIP-22 spec because anyway created_at is user-genera…
Browse files Browse the repository at this point in the history
…ted and always can be faked
  • Loading branch information
viktorvsk committed Nov 19, 2023
1 parent 1010104 commit 11a0580
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 44 deletions.
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ NIP_11_MAX_CONTENT_LENGTH=8196
NIP_11_MAX_MESSAGE_LENGTH=16384
NIP_12_MAX_SEARCHABLE_TAG_VALUE_LENGTH=1000
NIP_13_MIN_POW=0
NIP_22_CREATED_AT_IN_PAST=31556952 # 1 year
NIP_22_CREATED_AT_IN_FUTURE=7889238 # 3 months
NIP_42_RESTRICT_CHANGE_AUTH_PUBKEY=false
NIP_42_CHALLENGE_WINDOW_SECONDS=600
NIP_43_FAST_AUTH_WINDOW_SECONDS=80
Expand Down
2 changes: 0 additions & 2 deletions .env.test.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ SIDEKIQ_REDIS_URL=redis://localhost:63791
POSTGRES_PASSWORD=secret
RAILS_LOG_TO_STDOUT=true
PROVIDER_API_KEY_OPEN_NODE=invalid
NIP_22_CREATED_AT_IN_PAST=315569520
NIP_22_CREATED_AT_IN_FUTURE=78892380
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ This is an implementation of the [Nostr protocol](https://github.com/nostr-proto
* [NIP-09: Event Deletion](https://github.com/nostr-protocol/nips/blob/master/09.md)
* [NIP-11: Relay Information Document](https://github.com/nostr-protocol/nips/blob/master/11.md)
* [NIP-13: Proof of Work](https://github.com/nostr-protocol/nips/blob/master/13.md)
* [NIP-22: Event `created_at` Limits](https://github.com/nostr-protocol/nips/blob/master/22.md)
* [NIP-26: Delegated Event Signing](https://github.com/nostr-protocol/nips/blob/master/26.md)
* [NIP-28: Public Chat](https://github.com/nostr-protocol/nips/blob/master/28.md) Treats kind 41 event as replaceable
* [NIP-40: Expiration Timestamp](https://github.com/nostr-protocol/nips/blob/master/40.md)
Expand Down
9 changes: 0 additions & 9 deletions app/models/concerns/nostr/nip22.rb

This file was deleted.

1 change: 0 additions & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ class Event < ApplicationRecord
include Nostr::Nip1
include Nostr::Nip9
include Nostr::Nip13
include Nostr::Nip22
include Nostr::Nip26
include Nostr::Nip40
include Nostr::Nip42
Expand Down
10 changes: 1 addition & 9 deletions app/settings/relay_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def contact
end

def supported_nips
nips = Set.new(%w[1 2 5 9 11 13 15 22 26 28 40 42 43 45 50])
nips = Set.new(%w[1 2 5 9 11 13 15 26 28 40 42 43 45 50])
nips.add(4) if enforce_kind_4_authentication
nips.add(65) if kinds_exempt_of_auth.include?(10002)

Expand Down Expand Up @@ -166,14 +166,6 @@ def min_pow
ENV.fetch("NIP_13_MIN_POW", 0).to_i
end

def created_at_in_past
ENV.fetch("NIP_22_CREATED_AT_IN_PAST", 1.year.to_i).to_i
end

def created_at_in_future
ENV.fetch("NIP_22_CREATED_AT_IN_FUTURE", 3.months.to_i).to_i
end

def restrict_change_auth_pubkey
val = ENV.fetch("NIP_42_RESTRICT_CHANGE_AUTH_PUBKEY", false)
ActiveRecord::Type::Boolean.new.cast(val)
Expand Down
2 changes: 0 additions & 2 deletions demo/.env
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ NIP_11_MAX_CONTENT_LENGTH=81960
NIP_11_MAX_MESSAGE_LENGTH=163840
NIP_12_MAX_SEARCHABLE_TAG_VALUE_LENGTH=1000
NIP_13_MIN_POW=0
NIP_22_CREATED_AT_IN_PAST=31556952 # 1 year
NIP_22_CREATED_AT_IN_FUTURE=7889238 # 3 months
NIP_42_RESTRICT_CHANGE_AUTH_PUBKEY=false
NIP_42_CHALLENGE_WINDOW_SECONDS=600
NIP_43_FAST_AUTH_WINDOW_SECONDS=80
Expand Down
2 changes: 1 addition & 1 deletion spec/nips/nip01_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
context "with invalid data" do
it "doesn't delete existing events" do
e1 = create(:event, kind: 10001, pubkey: FAKE_CREDENTIALS[:alice][:pk])
e2 = build(:event, kind: 10001, pubkey: FAKE_CREDENTIALS[:alice][:pk], created_at: 100.year.from_now)
e2 = build(:event, kind: 10001, pubkey: FAKE_CREDENTIALS[:alice][:pk], tags: {})
refute e2.save
assert e1.reload.persisted?
assert e2.new_record?
Expand Down
2 changes: 1 addition & 1 deletion spec/nips/nip11_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe("NIP-11") do
describe "Nostr::Relay" do
it "responds to a non-websocket request" do
expected_json = %({"name":"","description":"","pubkey":"","contact":"","supported_nips":[1,2,4,5,9,11,13,15,22,26,28,40,42,43,45,50,65],"software":"https://github.com/viktorvsk/saltivka","version":null,"limitation":{"max_message_length":16384,"max_subscriptions":20,"max_filters":100,"max_limit":1000,"max_subid_length":64,"max_event_tags":100,"max_content_length":8196,"min_pow_difficulty":0,"auth_required":false,"payment_required":false},"relay_countries":["UK","UA","US"],"language_tags":["en","en-419"],"tags":[],"posting_policy":""})
expected_json = %({"name":"","description":"","pubkey":"","contact":"","supported_nips":[1,2,4,5,9,11,13,15,26,28,40,42,43,45,50,65],"software":"https://github.com/viktorvsk/saltivka","version":null,"limitation":{"max_message_length":16384,"max_subscriptions":20,"max_filters":100,"max_limit":1000,"max_subid_length":64,"max_event_tags":100,"max_content_length":8196,"min_pow_difficulty":0,"auth_required":false,"payment_required":false},"relay_countries":["UK","UA","US"],"language_tags":["en","en-419"],"tags":[],"posting_policy":""})
response = Nostr::Relay.call({})
expect(JSON.parse(response.last.first)).to eq(JSON.parse(expected_json))
expect(response).to match_array [200, {"Content-Type" => "application/json"}, [expected_json]]
Expand Down
16 changes: 0 additions & 16 deletions spec/nips/nip22_spec.rb

This file was deleted.

0 comments on commit 11a0580

Please sign in to comment.