Merge pull request #113 from SuperTux88/update-dependencies
Update dependencies and remove old versions
This commit is contained in:
commit
56385a14c1
266 changed files with 2323 additions and 2100 deletions
1
.envrc
1
.envrc
|
|
@ -1 +0,0 @@
|
|||
PATH_add bin
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -22,6 +22,7 @@ doc
|
|||
# dummmy app
|
||||
test/dummy/log/*.log
|
||||
test/dummy/log/*.log*
|
||||
test/dummy/tmp
|
||||
|
||||
rspec-persistence.txt
|
||||
|
||||
|
|
|
|||
17
.rubocop.yml
17
.rubocop.yml
|
|
@ -1,5 +1,7 @@
|
|||
require: rubocop-rails
|
||||
|
||||
AllCops:
|
||||
TargetRubyVersion: 2.1
|
||||
TargetRubyVersion: 2.5
|
||||
Exclude:
|
||||
- "bin/**/*"
|
||||
- "test/dummy/bin/**/*"
|
||||
|
|
@ -199,16 +201,3 @@ Style/DateTime:
|
|||
Exclude:
|
||||
- "lib/diaspora_federation/discovery/xrd_document.rb"
|
||||
- "spec/lib/diaspora_federation/discovery/xrd_document_spec.rb"
|
||||
|
||||
### backward compatibility
|
||||
|
||||
# only with ruby >= 2.3
|
||||
Layout/IndentHeredoc:
|
||||
Enabled: false
|
||||
Layout/ClosingHeredocIndentation:
|
||||
Enabled: false
|
||||
|
||||
# for rails 4 and ruby < 2.2.2
|
||||
Rails/HttpPositionalArguments:
|
||||
Exclude:
|
||||
- "spec/controllers/diaspora_federation/rails4_spec.rb"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
2.4
|
||||
2.6
|
||||
|
|
|
|||
13
.travis.yml
13
.travis.yml
|
|
@ -1,21 +1,12 @@
|
|||
language: ruby
|
||||
|
||||
rvm:
|
||||
- 2.5.5
|
||||
- 2.4.5
|
||||
- 2.3.8
|
||||
- 2.2.10
|
||||
- 2.1
|
||||
- 2.6.5
|
||||
- 2.5.7
|
||||
gemfile:
|
||||
- Gemfile
|
||||
- test/gemfiles/rails4.Gemfile
|
||||
- test/gemfiles/no-rails.Gemfile
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- rvm: 2.1
|
||||
gemfile: Gemfile
|
||||
|
||||
sudo: false
|
||||
cache:
|
||||
bundler: true
|
||||
|
|
|
|||
19
Gemfile
19
Gemfile
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
# Declare your gem's dependencies in diaspora_federation.gemspec.
|
||||
|
|
@ -17,9 +19,10 @@ end
|
|||
|
||||
group :development do
|
||||
# code style
|
||||
gem "pronto", "0.9.5", require: false
|
||||
gem "pronto-rubocop", "0.9.1", require: false
|
||||
gem "rubocop", "0.57.2", require: false
|
||||
gem "pronto", "0.10.0", require: false
|
||||
gem "pronto-rubocop", "0.10.0", require: false
|
||||
gem "rubocop", "0.75.1", require: false
|
||||
gem "rubocop-rails", "2.3.2", require: false
|
||||
|
||||
# automatic test runs
|
||||
gem "guard-rspec", require: false
|
||||
|
|
@ -40,16 +43,16 @@ end
|
|||
|
||||
group :test do
|
||||
# rspec formatter
|
||||
gem "fuubar", "2.3.2", require: false
|
||||
gem "fuubar", "2.4.1", require: false
|
||||
gem "nyan-cat-formatter", require: false
|
||||
|
||||
# test coverage
|
||||
gem "simplecov", "0.16.1", require: false
|
||||
gem "simplecov", "0.17.1", require: false
|
||||
gem "simplecov-rcov", "0.2.3", require: false
|
||||
|
||||
# test helpers
|
||||
gem "json-schema-rspec", "0.0.4"
|
||||
gem "rspec-collection_matchers", "~> 1.1.2"
|
||||
gem "rspec-collection_matchers", "~> 1.2.0"
|
||||
gem "rspec-json_expectations", "~> 2.1"
|
||||
gem "webmock", "~> 3.0"
|
||||
end
|
||||
|
|
@ -58,6 +61,6 @@ group :development, :test do
|
|||
gem "rake"
|
||||
|
||||
# unit tests
|
||||
gem "rspec", "~> 3.8.0"
|
||||
gem "rspec-rails", "~> 3.8.0"
|
||||
gem "rspec", "~> 3.9.0"
|
||||
gem "rspec-rails", "~> 3.9.0"
|
||||
end
|
||||
|
|
|
|||
204
Gemfile.lock
204
Gemfile.lock
|
|
@ -2,14 +2,14 @@ PATH
|
|||
remote: .
|
||||
specs:
|
||||
diaspora_federation (0.2.6)
|
||||
faraday (>= 0.9.0, < 0.16.0)
|
||||
faraday (>= 0.9.0, < 0.18.0)
|
||||
faraday_middleware (>= 0.10.0, < 0.14.0)
|
||||
nokogiri (~> 1.6, >= 1.6.8)
|
||||
typhoeus (~> 1.0)
|
||||
valid (~> 1.0)
|
||||
diaspora_federation-json_schema (0.2.6)
|
||||
diaspora_federation-rails (0.2.6)
|
||||
actionpack (>= 4.2, < 6)
|
||||
actionpack (>= 5, < 7)
|
||||
diaspora_federation (= 0.2.6)
|
||||
diaspora_federation-test (0.2.6)
|
||||
diaspora_federation (= 0.2.6)
|
||||
|
|
@ -19,26 +19,27 @@ PATH
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionpack (5.2.2.1)
|
||||
actionview (= 5.2.2.1)
|
||||
activesupport (= 5.2.2.1)
|
||||
actionpack (6.0.0)
|
||||
actionview (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
rack (~> 2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.2.2.1)
|
||||
activesupport (= 5.2.2.1)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||
actionview (6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activesupport (5.2.2.1)
|
||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||
activesupport (6.0.0)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
addressable (2.5.2)
|
||||
public_suffix (>= 2.0.2, < 4.0)
|
||||
zeitwerk (~> 2.1, >= 2.1.8)
|
||||
addressable (2.7.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
ast (2.4.0)
|
||||
builder (3.2.3)
|
||||
byebug (11.0.1)
|
||||
|
|
@ -46,26 +47,26 @@ GEM
|
|||
concurrent-ruby (1.1.5)
|
||||
crack (0.4.3)
|
||||
safe_yaml (~> 1.0.0)
|
||||
crass (1.0.4)
|
||||
crass (1.0.5)
|
||||
diff-lcs (1.3)
|
||||
docile (1.3.1)
|
||||
erubi (1.8.0)
|
||||
docile (1.3.2)
|
||||
erubi (1.9.0)
|
||||
ethon (0.12.0)
|
||||
ffi (>= 1.3.0)
|
||||
fabrication (2.20.1)
|
||||
faraday (0.15.4)
|
||||
fabrication (2.20.2)
|
||||
faraday (0.17.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faraday_middleware (0.13.1)
|
||||
faraday (>= 0.7.4, < 1.0)
|
||||
ffi (1.10.0)
|
||||
ffi (1.11.1)
|
||||
formatador (0.2.5)
|
||||
fuubar (2.3.2)
|
||||
fuubar (2.4.1)
|
||||
rspec-core (~> 3.0)
|
||||
ruby-progressbar (~> 1.4)
|
||||
gitlab (4.10.0)
|
||||
gitlab (4.12.0)
|
||||
httparty (~> 0.14, >= 0.14.0)
|
||||
terminal-table (~> 1.5, >= 1.5.1)
|
||||
guard (2.15.0)
|
||||
guard (2.15.1)
|
||||
formatador (>= 0.2.4)
|
||||
listen (>= 2.7, < 4.0)
|
||||
lumberjack (>= 1.0.12, < 2.0)
|
||||
|
|
@ -82,60 +83,58 @@ GEM
|
|||
guard-rubocop (1.3.0)
|
||||
guard (~> 2.0)
|
||||
rubocop (~> 0.20)
|
||||
hashdiff (0.3.8)
|
||||
httparty (0.16.4)
|
||||
hashdiff (1.0.0)
|
||||
httparty (0.17.1)
|
||||
mime-types (~> 3.0)
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (1.4.0)
|
||||
i18n (1.7.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jaro_winkler (1.5.2)
|
||||
jaro_winkler (1.5.3)
|
||||
json (2.2.0)
|
||||
json-schema (2.8.1)
|
||||
addressable (>= 2.4)
|
||||
json-schema-rspec (0.0.4)
|
||||
json-schema (~> 2.5)
|
||||
rspec
|
||||
listen (3.1.5)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
ruby_dep (~> 1.2)
|
||||
loofah (2.2.3)
|
||||
listen (3.2.0)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
loofah (2.3.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
lumberjack (1.0.13)
|
||||
macaddr (1.7.1)
|
||||
systemu (~> 2.6.2)
|
||||
macaddr (1.7.2)
|
||||
systemu (~> 2.6.5)
|
||||
method_source (0.9.2)
|
||||
mime-types (3.2.2)
|
||||
mime-types (3.3)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2018.0812)
|
||||
mime-types-data (3.2019.1009)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.11.3)
|
||||
minitest (5.12.2)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
multipart-post (2.1.1)
|
||||
nenv (0.3.0)
|
||||
nokogiri (1.9.1)
|
||||
nokogiri (1.10.4)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
notiffany (0.1.1)
|
||||
notiffany (0.1.3)
|
||||
nenv (~> 0.1)
|
||||
shellany (~> 0.0)
|
||||
nyan-cat-formatter (0.12.0)
|
||||
rspec (>= 2.99, >= 2.14.2, < 4)
|
||||
octokit (4.13.0)
|
||||
octokit (4.14.0)
|
||||
sawyer (~> 0.8.0, >= 0.5.3)
|
||||
parallel (1.14.0)
|
||||
parser (2.6.2.0)
|
||||
parallel (1.18.0)
|
||||
parser (2.6.5.0)
|
||||
ast (~> 2.4.0)
|
||||
powerpack (0.1.2)
|
||||
pronto (0.9.5)
|
||||
pronto (0.10.0)
|
||||
gitlab (~> 4.0, >= 4.0.0)
|
||||
httparty (>= 0.13.7)
|
||||
octokit (~> 4.7, >= 4.7.0)
|
||||
rainbow (~> 2.1)
|
||||
rainbow (>= 2.2, < 4.0)
|
||||
rugged (~> 0.24, >= 0.23.0)
|
||||
thor (~> 0.19.0)
|
||||
pronto-rubocop (0.9.1)
|
||||
pronto (~> 0.9.0)
|
||||
thor (~> 0.20.0)
|
||||
pronto-rubocop (0.10.0)
|
||||
pronto (~> 0.10.0)
|
||||
rubocop (~> 0.50, >= 0.49.1)
|
||||
pry (0.12.2)
|
||||
coderay (~> 1.1.0)
|
||||
|
|
@ -143,76 +142,75 @@ GEM
|
|||
pry-byebug (3.7.0)
|
||||
byebug (~> 11.0)
|
||||
pry (~> 0.10)
|
||||
public_suffix (3.0.3)
|
||||
rack (2.0.6)
|
||||
public_suffix (4.0.1)
|
||||
rack (2.0.7)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.4)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
railties (5.2.2.1)
|
||||
actionpack (= 5.2.2.1)
|
||||
activesupport (= 5.2.2.1)
|
||||
rails-html-sanitizer (1.3.0)
|
||||
loofah (~> 2.3)
|
||||
railties (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.19.0, < 2.0)
|
||||
rainbow (2.2.2)
|
||||
rake
|
||||
rake (12.3.2)
|
||||
thor (>= 0.20.3, < 2.0)
|
||||
rainbow (3.0.0)
|
||||
rake (13.0.0)
|
||||
rb-fsevent (0.10.3)
|
||||
rb-inotify (0.10.0)
|
||||
ffi (~> 1.0)
|
||||
rspec (3.8.0)
|
||||
rspec-core (~> 3.8.0)
|
||||
rspec-expectations (~> 3.8.0)
|
||||
rspec-mocks (~> 3.8.0)
|
||||
rspec-collection_matchers (1.1.3)
|
||||
rspec (3.9.0)
|
||||
rspec-core (~> 3.9.0)
|
||||
rspec-expectations (~> 3.9.0)
|
||||
rspec-mocks (~> 3.9.0)
|
||||
rspec-collection_matchers (1.2.0)
|
||||
rspec-expectations (>= 2.99.0.beta1)
|
||||
rspec-core (3.8.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-expectations (3.8.2)
|
||||
rspec-core (3.9.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-expectations (3.9.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-json_expectations (2.1.0)
|
||||
rspec-mocks (3.8.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-json_expectations (2.2.0)
|
||||
rspec-mocks (3.9.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-rails (3.8.2)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-rails (3.9.0)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 3.8.0)
|
||||
rspec-expectations (~> 3.8.0)
|
||||
rspec-mocks (~> 3.8.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-support (3.8.0)
|
||||
rubocop (0.57.2)
|
||||
rspec-core (~> 3.9.0)
|
||||
rspec-expectations (~> 3.9.0)
|
||||
rspec-mocks (~> 3.9.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-support (3.9.0)
|
||||
rubocop (0.75.1)
|
||||
jaro_winkler (~> 1.5.1)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.5)
|
||||
powerpack (~> 0.1)
|
||||
parser (>= 2.6)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||
ruby-progressbar (1.10.0)
|
||||
ruby_dep (1.5.0)
|
||||
rugged (0.28.1)
|
||||
unicode-display_width (>= 1.4.0, < 1.7)
|
||||
rubocop-rails (2.3.2)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 0.72.0)
|
||||
ruby-progressbar (1.10.1)
|
||||
rugged (0.28.3.1)
|
||||
safe_yaml (1.0.5)
|
||||
sawyer (0.8.1)
|
||||
addressable (>= 2.3.5, < 2.6)
|
||||
faraday (~> 0.8, < 1.0)
|
||||
sawyer (0.8.2)
|
||||
addressable (>= 2.3.5)
|
||||
faraday (> 0.8, < 2.0)
|
||||
shellany (0.0.1)
|
||||
simplecov (0.16.1)
|
||||
simplecov (0.17.1)
|
||||
docile (~> 1.1)
|
||||
json (>= 1.8, < 3)
|
||||
simplecov-html (~> 0.10.0)
|
||||
simplecov-html (0.10.2)
|
||||
simplecov-rcov (0.2.3)
|
||||
simplecov (>= 0.4.1)
|
||||
spring (2.0.2)
|
||||
activesupport (>= 4.2)
|
||||
spring (2.1.0)
|
||||
spring-commands-rspec (1.0.4)
|
||||
spring (>= 0.9.1)
|
||||
spring-watcher-listen (2.0.1)
|
||||
|
|
@ -221,21 +219,22 @@ GEM
|
|||
systemu (2.6.5)
|
||||
terminal-table (1.8.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
thor (0.19.4)
|
||||
thor (0.20.3)
|
||||
thread_safe (0.3.6)
|
||||
typhoeus (1.3.1)
|
||||
ethon (>= 0.9.0)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
unicode-display_width (1.5.0)
|
||||
unicode-display_width (1.6.0)
|
||||
uuid (2.3.9)
|
||||
macaddr (~> 1.0)
|
||||
valid (1.2.0)
|
||||
webmock (3.5.1)
|
||||
webmock (3.7.6)
|
||||
addressable (>= 2.3.6)
|
||||
crack (>= 0.3.2)
|
||||
hashdiff
|
||||
hashdiff (>= 0.4.0, < 2.0.0)
|
||||
yard (0.9.20)
|
||||
zeitwerk (2.2.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
|
@ -245,22 +244,23 @@ DEPENDENCIES
|
|||
diaspora_federation-json_schema!
|
||||
diaspora_federation-rails!
|
||||
diaspora_federation-test!
|
||||
fuubar (= 2.3.2)
|
||||
fuubar (= 2.4.1)
|
||||
guard-rspec
|
||||
guard-rubocop
|
||||
json-schema-rspec (= 0.0.4)
|
||||
nyan-cat-formatter
|
||||
pronto (= 0.9.5)
|
||||
pronto-rubocop (= 0.9.1)
|
||||
pronto (= 0.10.0)
|
||||
pronto-rubocop (= 0.10.0)
|
||||
pry
|
||||
pry-byebug
|
||||
rake
|
||||
rspec (~> 3.8.0)
|
||||
rspec-collection_matchers (~> 1.1.2)
|
||||
rspec (~> 3.9.0)
|
||||
rspec-collection_matchers (~> 1.2.0)
|
||||
rspec-json_expectations (~> 2.1)
|
||||
rspec-rails (~> 3.8.0)
|
||||
rubocop (= 0.57.2)
|
||||
simplecov (= 0.16.1)
|
||||
rspec-rails (~> 3.9.0)
|
||||
rubocop (= 0.75.1)
|
||||
rubocop-rails (= 2.3.2)
|
||||
simplecov (= 0.17.1)
|
||||
simplecov-rcov (= 0.2.3)
|
||||
spring
|
||||
spring-commands-rspec
|
||||
|
|
@ -269,4 +269,4 @@ DEPENDENCIES
|
|||
yard
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
2.0.2
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
guard :rspec, cmd: "NO_COVERAGE=true bin/rspec" do
|
||||
require "guard/rspec/dsl"
|
||||
dsl = Guard::RSpec::Dsl.new(self)
|
||||
|
|
|
|||
2
Rakefile
2
Rakefile
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
begin
|
||||
require "bundler/setup"
|
||||
rescue LoadError
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
# Base controller for all DiasporaFederation controllers
|
||||
class ApplicationController < ActionController::Base
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_dependency "diaspora_federation/application_controller"
|
||||
|
||||
module DiasporaFederation
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_dependency "diaspora_federation/application_controller"
|
||||
|
||||
module DiasporaFederation
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_dependency "diaspora_federation/application_controller"
|
||||
|
||||
module DiasporaFederation
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_dependency "diaspora_federation/application_controller"
|
||||
|
||||
module DiasporaFederation
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Don't log received xml data.
|
||||
Rails.application.config.filter_parameters += %i[xml aes_key encrypted_magic_envelope]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# mime types for webfinger
|
||||
Mime::Type.register "application/jrd+json", :jrd
|
||||
Mime::Type.register "application/xrd+xml", :xrd
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
DiasporaFederation::Engine.routes.draw do
|
||||
controller :receive do
|
||||
post "receive/public" => :public, :as => "receive_public"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Spring.application_root = "./test/dummy"
|
||||
|
||||
root_path = Pathname.new(File.expand_path("."))
|
||||
Spring.watcher = Spring::Watcher::Listen.new(root_path, 0.2)
|
||||
|
||||
Spring.watch("./lib/")
|
||||
Spring.watch(
|
||||
"./lib/",
|
||||
".ruby-version"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
||||
|
||||
# Maintain your gem's version:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
||||
|
||||
# Maintain your gem's version:
|
||||
|
|
@ -17,9 +19,9 @@ Gem::Specification.new do |s|
|
|||
s.files = Dir["app/**/*", "config/routes.rb", "config/initializers/*",
|
||||
"lib/diaspora_federation/{engine,rails}.rb", "LICENSE", "README.md", "Changelog.md"]
|
||||
|
||||
s.required_ruby_version = "~> 2.1"
|
||||
s.required_ruby_version = "~> 2.5"
|
||||
|
||||
s.add_dependency "actionpack", ">= 4.2", "< 6"
|
||||
s.add_dependency "actionpack", ">= 5", "< 7"
|
||||
|
||||
s.add_dependency "diaspora_federation", DiasporaFederation::VERSION
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
||||
|
||||
# Maintain your gem's version:
|
||||
|
|
@ -17,7 +19,7 @@ Gem::Specification.new do |s|
|
|||
|
||||
s.files = Dir["lib/diaspora_federation/test.rb", "lib/diaspora_federation/test/*"]
|
||||
|
||||
s.required_ruby_version = "~> 2.1"
|
||||
s.required_ruby_version = "~> 2.5"
|
||||
|
||||
s.add_dependency "diaspora_federation", DiasporaFederation::VERSION
|
||||
s.add_dependency "fabrication", "~> 2.16"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
||||
|
||||
# Maintain your gem's version:
|
||||
|
|
@ -22,9 +24,9 @@ Gem::Specification.new do |s|
|
|||
"lib/diaspora_federation/test/*",
|
||||
"lib/tasks/*.rake"]
|
||||
|
||||
s.required_ruby_version = "~> 2.1"
|
||||
s.required_ruby_version = "~> 2.5"
|
||||
|
||||
s.add_dependency "faraday", ">= 0.9.0", "< 0.16.0"
|
||||
s.add_dependency "faraday", ">= 0.9.0", "< 0.18.0"
|
||||
s.add_dependency "faraday_middleware", ">= 0.10.0", "< 0.14.0"
|
||||
s.add_dependency "nokogiri", "~> 1.6", ">= 1.6.8"
|
||||
s.add_dependency "typhoeus", "~> 1.0"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "nokogiri"
|
||||
require "openssl"
|
||||
|
||||
|
|
@ -256,6 +258,7 @@ module DiasporaFederation
|
|||
configuration_error "http_timeout: please configure a number" unless @http_timeout.is_a?(Integer)
|
||||
|
||||
return unless !@http_verbose.is_a?(TrueClass) && !@http_verbose.is_a?(FalseClass)
|
||||
|
||||
configuration_error "http_verbose: please configure a boolean"
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
# Callbacks are used to communicate with the application. They are called to
|
||||
# fetch data and after data is received.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
# This module provides the namespace for the various classes implementing
|
||||
# WebFinger and other protocols used for metadata discovery on remote servers
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Discovery
|
||||
# This class contains the logic to fetch all data for the given diaspora* ID.
|
||||
|
|
@ -35,6 +37,7 @@ module DiasporaFederation
|
|||
def validate_diaspora_id
|
||||
# Validates if the diaspora* ID matches the diaspora* ID in the webfinger response
|
||||
return if diaspora_id == clean_diaspora_id(webfinger.acct_uri)
|
||||
|
||||
raise DiscoveryError, "diaspora* ID does not match: Wanted #{diaspora_id} but got" \
|
||||
" #{clean_diaspora_id(webfinger.acct_uri)}"
|
||||
end
|
||||
|
|
@ -47,15 +50,13 @@ module DiasporaFederation
|
|||
logger.info "Fetching #{url} for #{diaspora_id}"
|
||||
response = HttpClient.get(url)
|
||||
raise "Failed to fetch #{url}: #{response.status}" unless response.success?
|
||||
|
||||
response.body
|
||||
rescue => e # rubocop:disable Style/RescueStandardError
|
||||
unless http_fallback && url.start_with?("https://")
|
||||
raise DiscoveryError, "Failed to fetch #{url} for #{diaspora_id}: #{e.class}: #{e.message}"
|
||||
end
|
||||
raise DiscoveryError, "Failed to fetch #{url} for #{diaspora_id}: #{e.class}: #{e.message}" unless http_fallback
|
||||
|
||||
logger.warn "Retry with http: #{url} for #{diaspora_id}: #{e.class}: #{e.message}"
|
||||
url.sub!("https://", "http://")
|
||||
retry
|
||||
get(url.sub("https://", "http://"))
|
||||
end
|
||||
|
||||
def domain
|
||||
|
|
@ -74,6 +75,7 @@ module DiasporaFederation
|
|||
|
||||
def webfinger
|
||||
return @webfinger if @webfinger
|
||||
|
||||
webfinger_url = "https://#{domain}/.well-known/webfinger?resource=#{acct_parameter}"
|
||||
|
||||
# This tries the WebFinger URL with https first, then falls back to http if webfinger_http_fallback is enabled.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Discovery
|
||||
# Raised, if there is an error while discover a new person
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Discovery
|
||||
# This class provides the means of generating and parsing account data to and
|
||||
|
|
@ -260,6 +262,7 @@ module DiasporaFederation
|
|||
|
||||
doc = Nokogiri::HTML::Document.parse(html_string)
|
||||
raise InvalidData, "hcard html incomplete" unless html_document_complete?(doc)
|
||||
|
||||
doc
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Discovery
|
||||
# Generates and parses Host Meta documents.
|
||||
|
|
@ -25,7 +27,7 @@ module DiasporaFederation
|
|||
end
|
||||
|
||||
# URL fragment to append to the base URL
|
||||
WEBFINGER_SUFFIX = "/.well-known/webfinger.xml?resource={uri}".freeze
|
||||
WEBFINGER_SUFFIX = "/.well-known/webfinger.xml?resource={uri}"
|
||||
|
||||
# Returns the WebFinger URL that was used to build this instance (either from
|
||||
# xml or by giving a base URL).
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Discovery
|
||||
# The WebFinger document used for diaspora* user discovery is based on an
|
||||
|
|
@ -69,23 +71,23 @@ module DiasporaFederation
|
|||
property :subscribe_url, :string, optional: true
|
||||
|
||||
# +hcard_url+ link relation
|
||||
REL_HCARD = "http://microformats.org/profile/hcard".freeze
|
||||
REL_HCARD = "http://microformats.org/profile/hcard"
|
||||
|
||||
# +seed_url+ link relation
|
||||
REL_SEED = "http://joindiaspora.com/seed_location".freeze
|
||||
REL_SEED = "http://joindiaspora.com/seed_location"
|
||||
|
||||
# +profile_url+ link relation.
|
||||
# @note This might just as well be an +Alias+ instead of a +Link+.
|
||||
REL_PROFILE = "http://webfinger.net/rel/profile-page".freeze
|
||||
REL_PROFILE = "http://webfinger.net/rel/profile-page"
|
||||
|
||||
# +atom_url+ link relation
|
||||
REL_ATOM = "http://schemas.google.com/g/2010#updates-from".freeze
|
||||
REL_ATOM = "http://schemas.google.com/g/2010#updates-from"
|
||||
|
||||
# +salmon_url+ link relation
|
||||
REL_SALMON = "salmon".freeze
|
||||
REL_SALMON = "salmon"
|
||||
|
||||
# +subscribe_url+ link relation
|
||||
REL_SUBSCRIBE = "http://ostatus.org/schema/1.0/subscribe".freeze
|
||||
REL_SUBSCRIBE = "http://ostatus.org/schema/1.0/subscribe"
|
||||
|
||||
# Additional WebFinger data
|
||||
# @return [Hash] additional elements
|
||||
|
|
@ -110,7 +112,7 @@ module DiasporaFederation
|
|||
to_xrd.to_xml
|
||||
end
|
||||
|
||||
def to_json
|
||||
def to_json(*_args)
|
||||
to_xrd.to_json
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Discovery
|
||||
# This class implements basic handling of XRD documents as far as it is
|
||||
|
|
@ -29,13 +31,13 @@ module DiasporaFederation
|
|||
# @see http://docs.oasis-open.org/xri/xrd/v1.0/xrd-1.0.html Extensible Resource Descriptor (XRD) Version 1.0
|
||||
class XrdDocument
|
||||
# xml namespace url
|
||||
XMLNS = "http://docs.oasis-open.org/ns/xri/xrd-1.0".freeze
|
||||
XMLNS = "http://docs.oasis-open.org/ns/xri/xrd-1.0"
|
||||
|
||||
# +Link+ element attributes
|
||||
LINK_ATTRS = %i[rel type href template].freeze
|
||||
|
||||
# format string for datetime (+Expires+ element)
|
||||
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ".freeze
|
||||
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
|
||||
|
||||
# The <Expires> element contains a time value which specifies the instant at
|
||||
# and after which the document has expired and SHOULD NOT be used.
|
||||
|
|
@ -80,7 +82,7 @@ module DiasporaFederation
|
|||
}.to_xml
|
||||
end
|
||||
|
||||
def to_json
|
||||
def to_json(*_args)
|
||||
{
|
||||
subject: subject,
|
||||
expires: (expires.strftime(DATETIME_FORMAT) if expires.instance_of?(DateTime)),
|
||||
|
|
@ -146,6 +148,7 @@ module DiasporaFederation
|
|||
def add_aliases_to(xml)
|
||||
aliases.each do |a|
|
||||
next if !a.instance_of?(String) || a.empty?
|
||||
|
||||
xml.Alias(a.to_s)
|
||||
end
|
||||
end
|
||||
|
|
@ -171,6 +174,7 @@ module DiasporaFederation
|
|||
|
||||
doc = Nokogiri::XML(xrd_doc)
|
||||
raise InvalidDocument, "Not an XRD document" if !doc.root || doc.root.name != "XRD"
|
||||
|
||||
doc
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
# diaspora* federation rails engine
|
||||
class Engine < ::Rails::Engine
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
# This namespace contains all the entities used to encapsulate data that is
|
||||
# passed around in the diaspora* network as part of the federation protocol.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity is sent when an account was deleted on a remote pod.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity is sent when a person changes their diaspora* ID (e.g. when a user migration
|
||||
|
|
@ -37,13 +39,14 @@ module DiasporaFederation
|
|||
# @return [String] diaspora* ID of the old person identity
|
||||
def old_identity
|
||||
return @old_identity if author_is_new_id?
|
||||
|
||||
author
|
||||
end
|
||||
|
||||
# Returns diaspora* ID of the new person identity.
|
||||
# @return [String] diaspora* ID of the new person identity
|
||||
def new_identity
|
||||
profile.author if profile
|
||||
profile&.author
|
||||
end
|
||||
|
||||
# @return [String] string representation of this object
|
||||
|
|
@ -85,6 +88,7 @@ module DiasporaFederation
|
|||
def sign_with_respective_key
|
||||
privkey = DiasporaFederation.callbacks.trigger(:fetch_private_key, signer_id)
|
||||
raise PrivateKeyNotFound, "signer=#{signer_id} obj=#{self}" if privkey.nil?
|
||||
|
||||
sign_with_key(privkey).tap do
|
||||
logger.info "event=sign status=complete signature=signature signer=#{signer_id} obj=#{self}"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
class AccountMigration < Entity
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a comment to some kind of post (e.g. status message).
|
||||
|
|
@ -5,7 +7,7 @@ module DiasporaFederation
|
|||
# @see Validators::CommentValidator
|
||||
class Comment < Entity
|
||||
# The {Comment} parent is a {Post}
|
||||
PARENT_TYPE = "Post".freeze
|
||||
PARENT_TYPE = "Post"
|
||||
|
||||
include Relayable
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a contact with another person. A user issues it
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a private conversation between users.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity is used to specify embed information about an URL that should be embedded.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents an event and it is federated as a part of a status message.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a participation in an event, i.e. it is issued when a user responds to en event.
|
||||
|
|
@ -5,7 +7,7 @@ module DiasporaFederation
|
|||
# @see Validators::EventParticipationValidator
|
||||
class EventParticipation < Entity
|
||||
# The {EventParticipation} parent is an {Event}
|
||||
PARENT_TYPE = "Event".freeze
|
||||
PARENT_TYPE = "Event"
|
||||
|
||||
include Relayable
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a like to some kind of post (e.g. status message).
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity is used to specify location data and used embedded in a status message.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a private message exchanged in private conversation.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# Participation is sent to subscribe a user on updates for some post.
|
||||
|
|
@ -35,7 +37,7 @@ module DiasporaFederation
|
|||
# Validates that the parent exists and the parent author is local
|
||||
def validate_parent
|
||||
parent = DiasporaFederation.callbacks.trigger(:fetch_related_entity, parent_type, parent_guid)
|
||||
raise ParentNotLocal, "obj=#{self}" unless parent && parent.local
|
||||
raise ParentNotLocal, "obj=#{self}" unless parent&.local
|
||||
end
|
||||
|
||||
# Validate that the parent is local.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity contains the base data of a person.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a photo and it is federated as a part of a status message.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a poll and it is federated as an optional part of a status message.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a poll answer and is federated as a part of the Poll entity.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a participation in poll, i.e. it is issued when a user votes for an answer in a poll.
|
||||
|
|
@ -5,7 +7,7 @@ module DiasporaFederation
|
|||
# @see Validators::PollParticipationValidator
|
||||
class PollParticipation < Entity
|
||||
# The {PollParticipation} parent is a {Poll}
|
||||
PARENT_TYPE = "Poll".freeze
|
||||
PARENT_TYPE = "Poll"
|
||||
|
||||
include Relayable
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This is a module that defines common properties for a post which
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity contains all the profile data of a person.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# Entity meta informations for a related entity (parent or target of
|
||||
|
|
@ -50,7 +52,7 @@ module DiasporaFederation
|
|||
end
|
||||
|
||||
# never add {RelatedEntity} to json
|
||||
def to_json
|
||||
def to_json(*_args)
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This is a module that defines common properties for relayable entities
|
||||
|
|
@ -88,7 +90,7 @@ module DiasporaFederation
|
|||
"#{super}#{":#{parent_type}" if respond_to?(:parent_type)}:#{parent_guid}"
|
||||
end
|
||||
|
||||
def to_json
|
||||
def to_json(*_args)
|
||||
super.merge!(property_order: signature_order).tap {|json_hash|
|
||||
missing_properties = json_hash[:property_order] - json_hash[:entity_data].keys
|
||||
missing_properties.each {|property|
|
||||
|
|
@ -113,6 +115,7 @@ module DiasporaFederation
|
|||
def sign_with_author
|
||||
privkey = DiasporaFederation.callbacks.trigger(:fetch_private_key, author)
|
||||
raise AuthorPrivateKeyNotFound, "author=#{author} obj=#{self}" if privkey.nil?
|
||||
|
||||
sign_with_key(privkey).tap do
|
||||
logger.info "event=sign status=complete signature=author_signature author=#{author} obj=#{self}"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a claim of deletion of a previously federated
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a sharing request for a user. A user issues it
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents the fact that a user reshared another user's post.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a claim of deletion of a previously federated entity.
|
||||
|
|
@ -28,7 +30,7 @@ module DiasporaFederation
|
|||
def sender_valid?(sender)
|
||||
case target_type
|
||||
when "Comment", "Like", "PollParticipation"
|
||||
sender == target.author || sender == target.root.author
|
||||
[target.root.author, target.author].include?(sender)
|
||||
else
|
||||
sender == target.author
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# Signable is a module that encapsulates basic signature generation/verification flow for entities.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a claim of deletion of a previously federated
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a status message sent by a user.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
# +Entity+ is the base class for all other objects used to encapsulate data
|
||||
# for federation messages in the diaspora* network.
|
||||
|
|
@ -38,10 +40,10 @@ module DiasporaFederation
|
|||
|
||||
# Invalid XML characters
|
||||
# @see https://www.w3.org/TR/REC-xml/#charsets "Extensible Markup Language (XML) 1.0"
|
||||
INVALID_XML_REGEX = /[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}]/
|
||||
INVALID_XML_REGEX = /[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}]/.freeze
|
||||
|
||||
# Regex to validate and find entity names
|
||||
ENTITY_NAME_REGEX = "[a-z]*(?:_[a-z]*)*".freeze
|
||||
ENTITY_NAME_REGEX = "[a-z]*(?:_[a-z]*)*"
|
||||
|
||||
# Initializes the Entity with the given attribute hash and freezes the created
|
||||
# instance it returns.
|
||||
|
|
@ -149,6 +151,7 @@ module DiasporaFederation
|
|||
# @return [Class] entity class
|
||||
def self.entity_class(entity_name)
|
||||
raise InvalidEntityName, "'#{entity_name}' is invalid" unless entity_name =~ /\A#{ENTITY_NAME_REGEX}\z/
|
||||
|
||||
class_name = entity_name.sub(/\A[a-z]/, &:upcase)
|
||||
class_name.gsub!(/_([a-z])/) { Regexp.last_match[1].upcase }
|
||||
|
||||
|
|
@ -169,7 +172,7 @@ module DiasporaFederation
|
|||
|
||||
# Renders entity to a hash representation of the entity JSON format
|
||||
# @return [Hash] Returns a hash that is equal by structure to the entity in JSON format
|
||||
def to_json
|
||||
def to_json(*_args)
|
||||
{
|
||||
entity_type: self.class.entity_name,
|
||||
entity_data: json_data
|
||||
|
|
@ -231,12 +234,14 @@ module DiasporaFederation
|
|||
|
||||
def nilify(value)
|
||||
return nil if value.respond_to?(:empty?) && value.empty? && !value.instance_of?(Array)
|
||||
|
||||
value
|
||||
end
|
||||
|
||||
def instantiate_nested(name, value)
|
||||
if value.instance_of?(Array)
|
||||
return value unless value.first.instance_of?(Hash)
|
||||
|
||||
value.map {|hash| self.class.class_props[name].first.new(hash) }
|
||||
elsif value.instance_of?(Hash)
|
||||
self.class.class_props[name].new(value)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
# This module contains the federation logic
|
||||
module Federation
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Federation
|
||||
# This module is for parsing and fetching linked entities.
|
||||
|
|
@ -10,7 +12,7 @@ module DiasporaFederation
|
|||
(#{Validation::Rule::DiasporaId::DIASPORA_ID_REGEX})/
|
||||
(#{Entity::ENTITY_NAME_REGEX})/
|
||||
(#{Validation::Rule::Guid::VALID_CHARS})
|
||||
}ux
|
||||
}ux.freeze
|
||||
|
||||
# Parses all diaspora:// URLs from the text and fetches the entities from
|
||||
# the remote server if needed.
|
||||
|
|
@ -25,6 +27,7 @@ module DiasporaFederation
|
|||
private_class_method def self.fetch_entity(author, type, guid)
|
||||
class_name = Entity.entity_class(type).to_s.rpartition("::").last
|
||||
return if DiasporaFederation.callbacks.trigger(:fetch_related_entity, class_name, guid)
|
||||
|
||||
Fetcher.fetch_public(author, type, guid)
|
||||
rescue => e # rubocop:disable Style/RescueStandardError
|
||||
logger.error "Failed to fetch linked entity #{type}:#{guid}: #{e.class}: #{e.message}"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Federation
|
||||
# This module is for fetching entities from other pods.
|
||||
|
|
@ -10,6 +12,7 @@ module DiasporaFederation
|
|||
def self.fetch_public(author, entity_type, guid)
|
||||
type = entity_name(entity_type).to_s
|
||||
raise "Already fetching ..." if fetching[type].include?(guid)
|
||||
|
||||
fetch_from_url(author, type, guid)
|
||||
rescue => e # rubocop:disable Style/RescueStandardError
|
||||
raise NotFetchable, "Failed to fetch #{entity_type}:#{guid} from #{author}: #{e.class}: #{e.message}"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Federation
|
||||
# This module parses and receives entities.
|
||||
|
|
@ -29,6 +31,7 @@ module DiasporaFederation
|
|||
# @param [Boolean] legacy use old slap parser
|
||||
def self.receive_private(data, recipient_private_key, recipient_id, legacy=false)
|
||||
raise ArgumentError, "no recipient key provided" unless recipient_private_key.instance_of?(OpenSSL::PKey::RSA)
|
||||
|
||||
magic_env = if legacy
|
||||
Salmon::EncryptedSlap.from_xml(data, recipient_private_key)
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Federation
|
||||
module Receiver
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Federation
|
||||
module Receiver
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Federation
|
||||
module Receiver
|
||||
|
|
@ -7,6 +9,7 @@ module DiasporaFederation
|
|||
|
||||
def validate
|
||||
raise RecipientRequired if recipient_id.nil?
|
||||
|
||||
super
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Federation
|
||||
module Receiver
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Federation
|
||||
# Federation logic to send messages to other pods
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "typhoeus"
|
||||
|
||||
module DiasporaFederation
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "faraday"
|
||||
require "faraday_middleware/response/follow_redirects"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
# Logging module for the diaspora* federation
|
||||
#
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
# This namespace contains parsers which are used to deserialize federation entities
|
||||
# objects from supported formats (XML, JSON) to objects of DiasporaFederation::Entity
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Parsers
|
||||
# +BaseParser+ is an abstract class which is used for defining parsers for different
|
||||
|
|
@ -36,6 +38,7 @@ module DiasporaFederation
|
|||
text.to_i if text =~ /\A\d+\z/
|
||||
when :boolean
|
||||
return true if text =~ /\A(true|t|yes|y|1)\z/i
|
||||
|
||||
false if text =~ /\A(false|f|no|n|0)\z/i
|
||||
else
|
||||
text
|
||||
|
|
@ -44,6 +47,7 @@ module DiasporaFederation
|
|||
|
||||
def assert_parsability_of(entity_class)
|
||||
return if entity_class == entity_type.entity_name
|
||||
|
||||
raise InvalidRootNode, "'#{entity_class}' can't be parsed by #{entity_type.name}"
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Parsers
|
||||
# This is a parser of JSON serialized object. JSON object format is defined by
|
||||
|
|
@ -30,12 +32,14 @@ module DiasporaFederation
|
|||
|
||||
def parse_element_from_value(type, value)
|
||||
return if value.nil?
|
||||
|
||||
if %i[integer boolean timestamp].include?(type) && !value.is_a?(String)
|
||||
value
|
||||
elsif type.instance_of?(Symbol)
|
||||
parse_string(type, value)
|
||||
elsif type.instance_of?(Array)
|
||||
raise DeserializationError, "Expected array for #{type}" unless value.respond_to?(:map)
|
||||
|
||||
value.map {|element|
|
||||
type.first.from_json(element)
|
||||
}
|
||||
|
|
@ -49,6 +53,7 @@ module DiasporaFederation
|
|||
prop if json_hash[prop].nil?
|
||||
}.compact.join(", ")
|
||||
raise DeserializationError, "Required properties are missing in JSON object: #{missing}" unless missing.empty?
|
||||
|
||||
assert_parsability_of(json_hash["entity_type"])
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Parsers
|
||||
# This is a parser of JSON serialized object, that is normally used for parsing data of relayables.
|
||||
|
|
@ -18,6 +20,7 @@ module DiasporaFederation
|
|||
def from_json_sanity_validation(json_hash)
|
||||
super
|
||||
return unless json_hash["property_order"].nil?
|
||||
|
||||
raise DeserializationError, "Required property is missing in JSON object: property_order"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Parsers
|
||||
# This is a parser of XML serialized object that is normally used for parsing data of relayables.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Parsers
|
||||
# This is a parser of XML serialized object.
|
||||
|
|
@ -77,6 +79,7 @@ module DiasporaFederation
|
|||
|
||||
def from_xml_sanity_validation(root_node)
|
||||
raise ArgumentError, "only Nokogiri::XML::Element allowed" unless root_node.instance_of?(Nokogiri::XML::Element)
|
||||
|
||||
assert_parsability_of(root_node.name)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
# Provides a simple DSL for specifying {Entity} properties during class
|
||||
# definition.
|
||||
|
|
@ -69,6 +71,7 @@ module DiasporaFederation
|
|||
if class_prop_aliases.has_key? name
|
||||
prop_name = class_prop_aliases[name]
|
||||
raise InvalidData, "only use '#{name}' OR '#{prop_name}'" if data.has_key? prop_name
|
||||
|
||||
[prop_name, value]
|
||||
else
|
||||
[name, value]
|
||||
|
|
@ -86,7 +89,7 @@ module DiasporaFederation
|
|||
# @param [String] xml_name name of the property from the received xml
|
||||
# @return [Hash] the property data
|
||||
def find_property_for_xml_name(xml_name)
|
||||
class_props.keys.find {|name| name.to_s == xml_name || xml_names[name].to_s == xml_name }
|
||||
class_props.keys.find {|name| [name.to_s, xml_names[name].to_s].include?(xml_name) }
|
||||
end
|
||||
|
||||
private
|
||||
|
|
@ -100,6 +103,7 @@ module DiasporaFederation
|
|||
if type.instance_of?(Symbol)
|
||||
if opts.has_key? :xml_name
|
||||
raise InvalidName, "invalid xml_name" unless name_valid?(opts[:xml_name])
|
||||
|
||||
opts[:xml_name]
|
||||
else
|
||||
name
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "diaspora_federation/engine"
|
||||
|
||||
require "diaspora_federation"
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
# This module contains a diaspora*-specific implementation of parts of the
|
||||
# {http://www.salmon-protocol.org/ Salmon Protocol}.
|
||||
module Salmon
|
||||
# XML namespace url
|
||||
XMLNS = "https://joindiaspora.com/protocol".freeze
|
||||
XMLNS = "https://joindiaspora.com/protocol"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Salmon
|
||||
# Class for AES encryption and decryption
|
||||
class AES
|
||||
# OpenSSL aes cipher definition
|
||||
CIPHER = "AES-256-CBC".freeze
|
||||
CIPHER = "AES-256-CBC"
|
||||
|
||||
# Generates a random AES key and initialization vector
|
||||
# @return [Hash] { key: "...", iv: "..." }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Salmon
|
||||
# This is a simple crypt-wrapper for {MagicEnvelope}.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "json"
|
||||
|
||||
module DiasporaFederation
|
||||
|
|
@ -67,10 +69,12 @@ module DiasporaFederation
|
|||
# @raise [MissingMagicEnvelope] if the +me:env+ element is missing in the XML
|
||||
def self.from_xml(slap_xml, privkey)
|
||||
raise ArgumentError unless slap_xml.instance_of?(String) && privkey.instance_of?(OpenSSL::PKey::RSA)
|
||||
|
||||
doc = Nokogiri::XML(slap_xml)
|
||||
|
||||
header_elem = doc.at_xpath("d:diaspora/d:encrypted_header", Slap::NS)
|
||||
raise MissingHeader if header_elem.nil?
|
||||
|
||||
header = header_data(header_elem.content, privkey)
|
||||
sender = header[:author_id]
|
||||
cipher_params = {key: Base64.decode64(header[:aes_key]), iv: Base64.decode64(header[:iv])}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Salmon
|
||||
# Raised, if the element containing the Magic Envelope is missing from the XML
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Salmon
|
||||
# Represents a Magic Envelope for diaspora* federation messages
|
||||
|
|
@ -24,19 +26,19 @@ module DiasporaFederation
|
|||
include Logging
|
||||
|
||||
# Encoding used for the payload data
|
||||
ENCODING = "base64url".freeze
|
||||
ENCODING = "base64url"
|
||||
|
||||
# Algorithm used for signing the payload data
|
||||
ALGORITHM = "RSA-SHA256".freeze
|
||||
ALGORITHM = "RSA-SHA256"
|
||||
|
||||
# Mime type describing the payload data
|
||||
DATA_TYPE = "application/xml".freeze
|
||||
DATA_TYPE = "application/xml"
|
||||
|
||||
# Digest instance used for signing
|
||||
DIGEST = OpenSSL::Digest::SHA256.new
|
||||
|
||||
# XML namespace url
|
||||
XMLNS = "http://salmon-protocol.org/ns/magic-env".freeze
|
||||
XMLNS = "http://salmon-protocol.org/ns/magic-env"
|
||||
|
||||
# The payload entity of the magic envelope
|
||||
# @return [Entity] payload entity
|
||||
|
|
@ -153,6 +155,7 @@ module DiasporaFederation
|
|||
# @raise [InvalidEnvelope] if the envelope XML structure is malformed
|
||||
private_class_method def self.validate_envelope(env)
|
||||
raise InvalidEnvelope unless env.instance_of?(Nokogiri::XML::Element) && env.name == "env"
|
||||
|
||||
validate_element(env, "me:data")
|
||||
validate_element(env, "me:sig")
|
||||
end
|
||||
|
|
@ -188,6 +191,7 @@ module DiasporaFederation
|
|||
private_class_method def self.sender(env)
|
||||
key_id = env.at_xpath("me:sig")["key_id"]
|
||||
raise InvalidEnvelope, "no key_id" unless key_id # TODO: move to `envelope_valid?`
|
||||
|
||||
Base64.urlsafe_decode64(key_id)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Salmon
|
||||
# +Slap+ provides class methods to create unencrypted Slap XML from payload
|
||||
|
|
@ -33,10 +35,12 @@ module DiasporaFederation
|
|||
# @raise [MissingMagicEnvelope] if the +me:env+ element is missing from the XML
|
||||
def self.from_xml(slap_xml)
|
||||
raise ArgumentError unless slap_xml.instance_of?(String)
|
||||
|
||||
doc = Nokogiri::XML(slap_xml)
|
||||
|
||||
author_elem = doc.at_xpath("d:diaspora/d:header/d:author_id", Slap::NS)
|
||||
raise MissingAuthor if author_elem.nil? || author_elem.content.empty?
|
||||
|
||||
sender = author_elem.content
|
||||
|
||||
MagicEnvelope.unenvelop(magic_env_from_doc(doc), sender)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Salmon
|
||||
# +XmlPayload+ provides methods to wrap a XML-serialized {Entity} inside a
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "pathname"
|
||||
require "json"
|
||||
|
||||
|
|
@ -5,7 +7,7 @@ module DiasporaFederation
|
|||
# A helper class to access the JSON schema.
|
||||
module Schemas
|
||||
# federation_entities schema uri
|
||||
FEDERATION_ENTITIES_URI = "https://diaspora.github.io/diaspora_federation/schemas/federation_entities.json".freeze
|
||||
FEDERATION_ENTITIES_URI = "https://diaspora.github.io/diaspora_federation/schemas/federation_entities.json"
|
||||
|
||||
# Parsed federation_entities schema
|
||||
def self.federation_entities
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "fabrication"
|
||||
|
||||
require "diaspora_federation"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Test
|
||||
# Generator to instantiate entities
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "uuid"
|
||||
require "securerandom"
|
||||
require "diaspora_federation/test"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "validation"
|
||||
require "validation/rule/regular_expression"
|
||||
require "validation/rule/length"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Validators
|
||||
# This validates a {Entities::AccountDeletion}.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Validators
|
||||
# This validates a {Entities::AccountMigration}.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Validators
|
||||
# This validates a {Entities::Comment}.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Validators
|
||||
# This validates a {Entities::Contact}.
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue