decidim-bulletin_board 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +3 -0
- data/.rubocop.yml +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +108 -0
- data/README.md +43 -0
- data/Rakefile +8 -0
- data/bin/console +16 -0
- data/bin/setup +10 -0
- data/decidim-bulletin_board.gemspec +34 -0
- data/lib/decidim/bulletin_board.rb +46 -0
- data/lib/decidim/bulletin_board/client.rb +51 -0
- data/lib/decidim/bulletin_board/create_election.rb +51 -0
- data/lib/decidim/bulletin_board/graphql/client.rb +17 -0
- data/lib/decidim/bulletin_board/jwk_utils.rb +49 -0
- data/lib/decidim/bulletin_board/version.rb +7 -0
- metadata +168 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 32b8c4fc3efdcc66c1d25c784627d955c52c2a3343fd0d1c6863ae89082e6a91
|
4
|
+
data.tar.gz: da628db5ef6520f1958691654a91105cc0eda053ee58a25cfd4f5b4f927d791c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 846a287aa3d3b31fd177ae29eaa9ff3b2de65b5f9507ed85c30f6c8cba45e1cfbf6f72a4bb3cb4b870f07af2ccf86f18bbfa782e247f2d3934794ff776297b96
|
7
|
+
data.tar.gz: c28b71b323024e6f92846b6bcb345bf07712a6ed2970ba17684fcb8b970785aea3230f2d039d8dbf10e5ca9c07a6945b57b980c78a9ca192a33a23f4151ec943
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: https://raw.githubusercontent.com/decidim/decidim/develop/.rubocop_ruby.yml
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.6
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at david@codegram.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
decidim-bulletin_board (0.1.0)
|
5
|
+
activesupport (~> 5.0, >= 5.0.0.1)
|
6
|
+
byebug (~> 11.0)
|
7
|
+
graphlient (~> 0.4.0)
|
8
|
+
jwt
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activesupport (5.2.4.4)
|
14
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
+
i18n (>= 0.7, < 2)
|
16
|
+
minitest (~> 5.1)
|
17
|
+
tzinfo (~> 1.1)
|
18
|
+
addressable (2.7.0)
|
19
|
+
public_suffix (>= 2.0.2, < 5.0)
|
20
|
+
ast (2.4.1)
|
21
|
+
byebug (11.1.3)
|
22
|
+
concurrent-ruby (1.1.7)
|
23
|
+
crack (0.4.4)
|
24
|
+
diff-lcs (1.4.4)
|
25
|
+
faker (2.15.1)
|
26
|
+
i18n (>= 1.6, < 2)
|
27
|
+
faraday (1.1.0)
|
28
|
+
multipart-post (>= 1.2, < 3)
|
29
|
+
ruby2_keywords
|
30
|
+
faraday_middleware (1.0.0)
|
31
|
+
faraday (~> 1.0)
|
32
|
+
graphlient (0.4.0)
|
33
|
+
faraday (>= 1.0)
|
34
|
+
faraday_middleware
|
35
|
+
graphql-client
|
36
|
+
graphql (1.11.6)
|
37
|
+
graphql-client (0.16.0)
|
38
|
+
activesupport (>= 3.0)
|
39
|
+
graphql (~> 1.8)
|
40
|
+
hashdiff (1.0.1)
|
41
|
+
i18n (1.8.5)
|
42
|
+
concurrent-ruby (~> 1.0)
|
43
|
+
jwt (2.2.2)
|
44
|
+
minitest (5.14.2)
|
45
|
+
multipart-post (2.1.1)
|
46
|
+
parallel (1.20.1)
|
47
|
+
parser (2.7.2.0)
|
48
|
+
ast (~> 2.4.1)
|
49
|
+
public_suffix (4.0.6)
|
50
|
+
rainbow (3.0.0)
|
51
|
+
rake (13.0.1)
|
52
|
+
regexp_parser (2.0.0)
|
53
|
+
rexml (3.2.4)
|
54
|
+
rspec (3.9.0)
|
55
|
+
rspec-core (~> 3.9.0)
|
56
|
+
rspec-expectations (~> 3.9.0)
|
57
|
+
rspec-mocks (~> 3.9.0)
|
58
|
+
rspec-core (3.9.3)
|
59
|
+
rspec-support (~> 3.9.3)
|
60
|
+
rspec-expectations (3.9.4)
|
61
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
62
|
+
rspec-support (~> 3.9.0)
|
63
|
+
rspec-mocks (3.9.1)
|
64
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
65
|
+
rspec-support (~> 3.9.0)
|
66
|
+
rspec-support (3.9.4)
|
67
|
+
rubocop (0.92.0)
|
68
|
+
parallel (~> 1.10)
|
69
|
+
parser (>= 2.7.1.5)
|
70
|
+
rainbow (>= 2.2.2, < 4.0)
|
71
|
+
regexp_parser (>= 1.7)
|
72
|
+
rexml
|
73
|
+
rubocop-ast (>= 0.5.0)
|
74
|
+
ruby-progressbar (~> 1.7)
|
75
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
76
|
+
rubocop-ast (1.2.0)
|
77
|
+
parser (>= 2.7.1.5)
|
78
|
+
rubocop-faker (1.1.0)
|
79
|
+
faker (>= 2.12.0)
|
80
|
+
rubocop (>= 0.82.0)
|
81
|
+
rubocop-rspec (1.44.1)
|
82
|
+
rubocop (~> 0.87)
|
83
|
+
rubocop-ast (>= 0.7.1)
|
84
|
+
ruby-progressbar (1.10.1)
|
85
|
+
ruby2_keywords (0.0.2)
|
86
|
+
thread_safe (0.3.6)
|
87
|
+
tzinfo (1.2.8)
|
88
|
+
thread_safe (~> 0.1)
|
89
|
+
unicode-display_width (1.7.0)
|
90
|
+
webmock (3.10.0)
|
91
|
+
addressable (>= 2.3.6)
|
92
|
+
crack (>= 0.3.2)
|
93
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
94
|
+
|
95
|
+
PLATFORMS
|
96
|
+
ruby
|
97
|
+
|
98
|
+
DEPENDENCIES
|
99
|
+
decidim-bulletin_board!
|
100
|
+
rake (~> 13.0)
|
101
|
+
rspec (~> 3.7)
|
102
|
+
rubocop (~> 0.92.0)
|
103
|
+
rubocop-faker
|
104
|
+
rubocop-rspec (~> 1.21)
|
105
|
+
webmock (~> 3.6)
|
106
|
+
|
107
|
+
BUNDLED WITH
|
108
|
+
2.1.4
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Decidim::BulletinBoard
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/decidim/bulletin_board`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'decidim-bulletin_board'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install decidim-bulletin_board
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
See [Decidim](https://github.com/decidim/decidim).
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
See [Decidim](https://github.com/decidim/decidim).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
See [Decidim](https://github.com/decidim/decidim).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#!/usr/bin/env ruby
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'decidim/bulletin_board'
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
|
11
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
12
|
+
# require "pry"
|
13
|
+
# Pry.start
|
14
|
+
|
15
|
+
require 'irb'
|
16
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/decidim/bulletin_board/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "decidim-bulletin_board"
|
7
|
+
s.version = Decidim::BulletinBoard::VERSION
|
8
|
+
s.authors = ["David Morcillo", "Svenja Schäfer"]
|
9
|
+
s.email = ["david@codegram.com", "svenja@codegram.com"]
|
10
|
+
|
11
|
+
s.summary = ""
|
12
|
+
s.description = ""
|
13
|
+
s.homepage = "https://github.com"
|
14
|
+
s.license = "AGPL-3.0"
|
15
|
+
s.required_ruby_version = Gem::Requirement.new(">= 2.6.6")
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
s.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
s.bindir = "exe"
|
23
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
|
26
|
+
s.add_dependency "activesupport", "~> 5.0", ">= 5.0.0.1"
|
27
|
+
s.add_dependency "byebug", "~> 11.0"
|
28
|
+
s.add_dependency "graphlient", "~> 0.4.0"
|
29
|
+
s.add_dependency "jwt"
|
30
|
+
|
31
|
+
s.add_development_dependency "rake", "~> 13.0"
|
32
|
+
s.add_development_dependency "rspec", "~> 3.7"
|
33
|
+
s.add_development_dependency "webmock", "~> 3.6"
|
34
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "decidim/bulletin_board/version"
|
4
|
+
require "graphlient"
|
5
|
+
require "decidim/bulletin_board/jwk_utils"
|
6
|
+
require "decidim/bulletin_board/client"
|
7
|
+
require "decidim/bulletin_board/graphql/client"
|
8
|
+
require "decidim/bulletin_board/create_election"
|
9
|
+
require "active_support/configurable"
|
10
|
+
require "jwt"
|
11
|
+
|
12
|
+
module Decidim
|
13
|
+
# This module holds all the logic for the Bulletin Board Ruby Client to connect
|
14
|
+
# a Decidim instance with a Bulletin Board server
|
15
|
+
module BulletinBoard
|
16
|
+
include ActiveSupport::Configurable
|
17
|
+
|
18
|
+
# Configure the following variables inside your
|
19
|
+
# decidim_bulletin_board.rb initializer
|
20
|
+
|
21
|
+
# The BulletinBoard server (String)
|
22
|
+
config_accessor :server
|
23
|
+
|
24
|
+
# The api key generated by the Bulletin Board for the Decidim authority (String)
|
25
|
+
config_accessor :api_key
|
26
|
+
|
27
|
+
# The scheme: scheme name and scheme parameters, e.g. quorum for Electionguard
|
28
|
+
# Example:
|
29
|
+
# {
|
30
|
+
# name: "Dummy",
|
31
|
+
# parameters: {
|
32
|
+
# quorum: 2
|
33
|
+
# }
|
34
|
+
# }
|
35
|
+
config_accessor :scheme
|
36
|
+
|
37
|
+
# The authority name (String)
|
38
|
+
config_accessor :authority_name
|
39
|
+
|
40
|
+
# The number of trustees for an election (Int). Must be higher than the schemes' quorum
|
41
|
+
config_accessor :number_of_trustees
|
42
|
+
|
43
|
+
# The identification private key (JSON) for your Decidim instance
|
44
|
+
config_accessor :identification_private_key
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module BulletinBoard
|
5
|
+
# The Bulletin Board client
|
6
|
+
class Client
|
7
|
+
def initialize
|
8
|
+
@server = BulletinBoard.server.presence
|
9
|
+
@api_key = BulletinBoard.api_key.presence
|
10
|
+
@scheme = BulletinBoard.scheme.presence
|
11
|
+
@authority_name = BulletinBoard.authority_name.presence
|
12
|
+
@number_of_trustees = BulletinBoard.number_of_trustees.presence
|
13
|
+
@identification_private_key = BulletinBoard.identification_private_key.presence
|
14
|
+
@private_key = identification_private_key_content if identification_private_key
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :server, :scheme, :api_key, :number_of_trustees, :authority_name
|
18
|
+
|
19
|
+
def quorum
|
20
|
+
return 0 if @scheme.dig(:parameters, :quorum).blank?
|
21
|
+
|
22
|
+
@scheme.dig(:parameters, :quorum)
|
23
|
+
end
|
24
|
+
|
25
|
+
def authority_slug
|
26
|
+
@authority_slug ||= authority_name.parameterize
|
27
|
+
end
|
28
|
+
|
29
|
+
def public_key
|
30
|
+
private_key&.export
|
31
|
+
end
|
32
|
+
|
33
|
+
def configured?
|
34
|
+
private_key && server && api_key
|
35
|
+
end
|
36
|
+
|
37
|
+
def setup_election(election_data)
|
38
|
+
message_id = "#{election_data[:election_id]}.create_election+a.#{authority_slug}"
|
39
|
+
Decidim::BulletinBoard::CreateElection.call(election_data, message_id)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
attr_reader :identification_private_key, :private_key
|
45
|
+
|
46
|
+
def identification_private_key_content
|
47
|
+
@identification_private_key_content ||= JwkUtils.import_private_key(identification_private_key)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module BulletinBoard
|
5
|
+
# This class handles the creation of an election.
|
6
|
+
class CreateElection
|
7
|
+
def initialize(election_data, message_id)
|
8
|
+
@client = BulletinBoard::Graphql::Client.client
|
9
|
+
@election_data = election_data
|
10
|
+
@message_id = message_id
|
11
|
+
@private_key = private_key
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.call(election_data, message_id)
|
15
|
+
new(election_data, message_id).call
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
19
|
+
args = {
|
20
|
+
message_id: message_id,
|
21
|
+
signed_data: encode_data(election_data)
|
22
|
+
}
|
23
|
+
|
24
|
+
response = client.query do
|
25
|
+
mutation do
|
26
|
+
createElection(messageId: args[:message_id], signedData: args[:signed_data]) do
|
27
|
+
election do
|
28
|
+
status
|
29
|
+
end
|
30
|
+
error
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
response.data.create_election
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
attr_reader :client, :election_data, :message_id
|
41
|
+
|
42
|
+
def private_key
|
43
|
+
@private_key ||= JwkUtils.import_private_key(BulletinBoard.identification_private_key)
|
44
|
+
end
|
45
|
+
|
46
|
+
def encode_data(election_data)
|
47
|
+
JWT.encode(election_data, private_key.keypair, "RS256")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module BulletinBoard
|
5
|
+
module Graphql
|
6
|
+
# The Bulletin Board GraphQL Client
|
7
|
+
class Client
|
8
|
+
def self.client
|
9
|
+
@client ||= Graphlient::Client.new(BulletinBoard.server,
|
10
|
+
headers: {
|
11
|
+
"Authorization" => BulletinBoard.api_key
|
12
|
+
})
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module BulletinBoard
|
5
|
+
module JwkUtils
|
6
|
+
JWK_PRIVATE_FIELDS = [:d, :p, :q, :dp, :dq, :qi].freeze
|
7
|
+
|
8
|
+
def self.thumbprint(json)
|
9
|
+
Base64.urlsafe_encode64(Digest::SHA256.digest(json.slice(:e, :kty, :n).to_json), padding: false)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.private_key?(json)
|
13
|
+
(json.keys & JWK_PRIVATE_FIELDS).any?
|
14
|
+
end
|
15
|
+
|
16
|
+
# TODO: remove everything below here when https://github.com/jwt/ruby-jwt/pull/375 is released
|
17
|
+
def self.import_private_key(json)
|
18
|
+
jwk = JWT::JWK.import(json)
|
19
|
+
jwk.keypair.set_key(decode_open_ssl_bn(json[:n]), decode_open_ssl_bn(json[:e]), decode_open_ssl_bn(json[:d]))
|
20
|
+
jwk.keypair.set_factors(decode_open_ssl_bn(json[:p]), decode_open_ssl_bn(json[:q]))
|
21
|
+
jwk.keypair.set_crt_params(decode_open_ssl_bn(json[:dp]), decode_open_ssl_bn(json[:dq]), decode_open_ssl_bn(json[:qi]))
|
22
|
+
jwk
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.private_export(jwk)
|
26
|
+
raise "Not a private key" unless jwk.private?
|
27
|
+
|
28
|
+
jwk.export.merge(
|
29
|
+
d: encode_open_ssl_bn(jwk.keypair.d),
|
30
|
+
p: encode_open_ssl_bn(jwk.keypair.p),
|
31
|
+
q: encode_open_ssl_bn(jwk.keypair.q),
|
32
|
+
dp: encode_open_ssl_bn(jwk.keypair.dmp1),
|
33
|
+
dq: encode_open_ssl_bn(jwk.keypair.dmq1),
|
34
|
+
qi: encode_open_ssl_bn(jwk.keypair.iqmp)
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.encode_open_ssl_bn(key_part)
|
39
|
+
::Base64.urlsafe_encode64(key_part.to_s(2), padding: false)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.decode_open_ssl_bn(jwk_data)
|
43
|
+
return nil unless jwk_data
|
44
|
+
|
45
|
+
OpenSSL::BN.new(::Base64.urlsafe_decode64(jwk_data), 2)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: decidim-bulletin_board
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Morcillo
|
8
|
+
- Svenja Schäfer
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-12-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '5.0'
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 5.0.0.1
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - "~>"
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '5.0'
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 5.0.0.1
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: byebug
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '11.0'
|
41
|
+
type: :runtime
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '11.0'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: graphlient
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.4.0
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.4.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: jwt
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
type: :runtime
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: rake
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '13.0'
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '13.0'
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: rspec
|
92
|
+
requirement: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.7'
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.7'
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: webmock
|
106
|
+
requirement: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.6'
|
111
|
+
type: :development
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.6'
|
118
|
+
description: ''
|
119
|
+
email:
|
120
|
+
- david@codegram.com
|
121
|
+
- svenja@codegram.com
|
122
|
+
executables: []
|
123
|
+
extensions: []
|
124
|
+
extra_rdoc_files: []
|
125
|
+
files:
|
126
|
+
- ".gitignore"
|
127
|
+
- ".rspec"
|
128
|
+
- ".rubocop.yml"
|
129
|
+
- ".ruby-version"
|
130
|
+
- ".travis.yml"
|
131
|
+
- CODE_OF_CONDUCT.md
|
132
|
+
- Gemfile
|
133
|
+
- Gemfile.lock
|
134
|
+
- README.md
|
135
|
+
- Rakefile
|
136
|
+
- bin/console
|
137
|
+
- bin/setup
|
138
|
+
- decidim-bulletin_board.gemspec
|
139
|
+
- lib/decidim/bulletin_board.rb
|
140
|
+
- lib/decidim/bulletin_board/client.rb
|
141
|
+
- lib/decidim/bulletin_board/create_election.rb
|
142
|
+
- lib/decidim/bulletin_board/graphql/client.rb
|
143
|
+
- lib/decidim/bulletin_board/jwk_utils.rb
|
144
|
+
- lib/decidim/bulletin_board/version.rb
|
145
|
+
homepage: https://github.com
|
146
|
+
licenses:
|
147
|
+
- AGPL-3.0
|
148
|
+
metadata: {}
|
149
|
+
post_install_message:
|
150
|
+
rdoc_options: []
|
151
|
+
require_paths:
|
152
|
+
- lib
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 2.6.6
|
158
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
requirements: []
|
164
|
+
rubygems_version: 3.0.3
|
165
|
+
signing_key:
|
166
|
+
specification_version: 4
|
167
|
+
summary: ''
|
168
|
+
test_files: []
|