decidim-bulletin_board 0.9.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +48 -0
- data/Gemfile.lock +60 -56
- data/app/assets/config/{decidim_bulletin_board_manifest.js → manifest.js} +0 -0
- data/app/assets/javascripts/decidim/bulletin_board/decidim-bulletin_board.js +279 -2
- data/bin/release +10 -0
- data/lib/decidim/bulletin_board.rb +16 -20
- data/lib/decidim/bulletin_board/authority/create_election.rb +100 -2
- data/lib/decidim/bulletin_board/authority/end_vote.rb +1 -1
- data/lib/decidim/bulletin_board/authority/get_election_results.rb +63 -0
- data/lib/decidim/bulletin_board/authority/get_election_status.rb +1 -1
- data/lib/decidim/bulletin_board/authority/publish_results.rb +1 -1
- data/lib/decidim/bulletin_board/authority/start_key_ceremony.rb +1 -1
- data/lib/decidim/bulletin_board/authority/start_tally.rb +1 -1
- data/lib/decidim/bulletin_board/authority/start_vote.rb +1 -1
- data/lib/decidim/bulletin_board/client.rb +40 -35
- data/lib/decidim/bulletin_board/command.rb +11 -26
- data/lib/decidim/bulletin_board/graphql/bb_schema.json +37 -1
- data/lib/decidim/bulletin_board/graphql/factory.rb +18 -0
- data/lib/decidim/bulletin_board/message_identifier.rb +7 -3
- data/lib/decidim/bulletin_board/settings.rb +41 -0
- data/lib/decidim/bulletin_board/version.rb +1 -1
- data/lib/decidim/bulletin_board/voter/cast_vote.rb +1 -1
- data/lib/decidim/bulletin_board/voter/get_pending_message_status.rb +1 -1
- metadata +10 -9
- data/lib/decidim/bulletin_board/authority.rb +0 -9
- data/lib/decidim/bulletin_board/graphql/client.rb +0 -18
- data/lib/decidim/bulletin_board/voter.rb +0 -4
@@ -1,21 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "decidim/bulletin_board/graphql/client"
|
4
|
-
|
5
3
|
module Decidim
|
6
4
|
module BulletinBoard
|
7
5
|
# The base class for all commands.
|
8
6
|
class Command
|
9
7
|
include Wisper::Publisher
|
10
8
|
|
11
|
-
|
9
|
+
attr_reader :settings, :graphql
|
12
10
|
|
13
|
-
def
|
14
|
-
|
11
|
+
def configure(settings, graphql)
|
12
|
+
@settings = settings
|
13
|
+
@graphql = graphql
|
15
14
|
end
|
16
15
|
|
17
|
-
def
|
18
|
-
|
16
|
+
def sign_message(message_id, message)
|
17
|
+
JWT.encode(complete_message(message_id, message), settings.authority_private_key.keypair, "RS256")
|
19
18
|
end
|
20
19
|
|
21
20
|
def complete_message(message_id, message)
|
@@ -25,26 +24,12 @@ module Decidim
|
|
25
24
|
})
|
26
25
|
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
def private_key
|
34
|
-
@private_key ||= JwkUtils.import_private_key(BulletinBoard.identification_private_key)
|
35
|
-
end
|
36
|
-
|
37
|
-
def authority_slug
|
38
|
-
@authority_slug ||= BulletinBoard.authority_name.parameterize
|
39
|
-
end
|
40
|
-
|
41
|
-
def unique_election_id(election_id)
|
42
|
-
Decidim::BulletinBoard::MessageIdentifier.unique_election_id(authority_slug, election_id)
|
43
|
-
end
|
27
|
+
def build_message_id(unique_election_id, type_subtype, voter_id = nil)
|
28
|
+
MessageIdentifier.format(unique_election_id, type_subtype, voter_id ? :voter : :authority, voter_id || settings.authority_slug)
|
29
|
+
end
|
44
30
|
|
45
|
-
|
46
|
-
|
47
|
-
end
|
31
|
+
def unique_election_id(election_id)
|
32
|
+
MessageIdentifier.unique_election_id(settings.authority_slug, election_id)
|
48
33
|
end
|
49
34
|
end
|
50
35
|
end
|
@@ -209,6 +209,24 @@
|
|
209
209
|
"ofType": null
|
210
210
|
},
|
211
211
|
"defaultValue": null
|
212
|
+
},
|
213
|
+
{
|
214
|
+
"name": "types",
|
215
|
+
"description": null,
|
216
|
+
"type": {
|
217
|
+
"kind": "LIST",
|
218
|
+
"name": null,
|
219
|
+
"ofType": {
|
220
|
+
"kind": "NON_NULL",
|
221
|
+
"name": null,
|
222
|
+
"ofType": {
|
223
|
+
"kind": "SCALAR",
|
224
|
+
"name": "String",
|
225
|
+
"ofType": null
|
226
|
+
}
|
227
|
+
}
|
228
|
+
},
|
229
|
+
"defaultValue": null
|
212
230
|
}
|
213
231
|
],
|
214
232
|
"type": {
|
@@ -260,7 +278,7 @@
|
|
260
278
|
"name": null,
|
261
279
|
"ofType": {
|
262
280
|
"kind": "SCALAR",
|
263
|
-
"name": "
|
281
|
+
"name": "JSON",
|
264
282
|
"ofType": null
|
265
283
|
}
|
266
284
|
},
|
@@ -417,6 +435,24 @@
|
|
417
435
|
"isDeprecated": false,
|
418
436
|
"deprecationReason": null
|
419
437
|
},
|
438
|
+
{
|
439
|
+
"name": "decodedData",
|
440
|
+
"description": null,
|
441
|
+
"args": [
|
442
|
+
|
443
|
+
],
|
444
|
+
"type": {
|
445
|
+
"kind": "NON_NULL",
|
446
|
+
"name": null,
|
447
|
+
"ofType": {
|
448
|
+
"kind": "SCALAR",
|
449
|
+
"name": "JSON",
|
450
|
+
"ofType": null
|
451
|
+
}
|
452
|
+
},
|
453
|
+
"isDeprecated": false,
|
454
|
+
"deprecationReason": null
|
455
|
+
},
|
420
456
|
{
|
421
457
|
"name": "election",
|
422
458
|
"description": null,
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module BulletinBoard
|
5
|
+
module Graphql
|
6
|
+
class Factory
|
7
|
+
# The Bulletin Board GraphQL client factory
|
8
|
+
def self.client_for(settings)
|
9
|
+
Graphlient::Client.new(settings.bulletin_board_server,
|
10
|
+
schema_path: File.join(__dir__, "bb_schema.json"),
|
11
|
+
headers: {
|
12
|
+
"Authorization" => settings.authority_api_key
|
13
|
+
})
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -41,15 +41,19 @@ module Decidim
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def election_id
|
44
|
-
@election_id
|
44
|
+
@election_id ||= elements[0..1].join(".")
|
45
45
|
end
|
46
46
|
|
47
47
|
def type
|
48
|
-
@type
|
48
|
+
@type ||= elements[2]
|
49
49
|
end
|
50
50
|
|
51
51
|
def subtype
|
52
|
-
@subtype
|
52
|
+
@subtype ||= elements[3]
|
53
|
+
end
|
54
|
+
|
55
|
+
def type_subtype
|
56
|
+
@type_subtype ||= [type, subtype].compact.join(".")
|
53
57
|
end
|
54
58
|
|
55
59
|
def to_s
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module BulletinBoard
|
5
|
+
# The Bulletin Board settings class
|
6
|
+
class Settings
|
7
|
+
def initialize(config)
|
8
|
+
@bulletin_board_server = config.bulletin_board_server.presence
|
9
|
+
@bulletin_board_public_key = config.bulletin_board_public_key.presence
|
10
|
+
|
11
|
+
@authority_api_key = config.authority_api_key.presence
|
12
|
+
@authority_name = config.authority_name.presence
|
13
|
+
@authority_private_key = JwkUtils.import_private_key(config.authority_private_key) if config.authority_private_key.present?
|
14
|
+
|
15
|
+
@scheme_name = config.scheme_name.presence
|
16
|
+
@number_of_trustees = config.number_of_trustees.presence
|
17
|
+
@quorum = config.quorum.presence || number_of_trustees
|
18
|
+
end
|
19
|
+
|
20
|
+
def configured?
|
21
|
+
bulletin_board_server && bulletin_board_public_key && authority_api_key && authority_name && authority_private_key && scheme_name && number_of_trustees
|
22
|
+
end
|
23
|
+
|
24
|
+
attr_reader :bulletin_board_server, :bulletin_board_public_key,
|
25
|
+
:authority_private_key, :authority_api_key, :authority_name,
|
26
|
+
:scheme_name, :number_of_trustees, :quorum
|
27
|
+
|
28
|
+
def bulletin_board_public_key_rsa
|
29
|
+
@bulletin_board_public_key_rsa ||= JWT::JWK::RSA.import(bulletin_board_public_key).public_key
|
30
|
+
end
|
31
|
+
|
32
|
+
def authority_slug
|
33
|
+
@authority_slug ||= authority_name.parameterize
|
34
|
+
end
|
35
|
+
|
36
|
+
def authority_public_key
|
37
|
+
@authority_public_key ||= authority_private_key&.export
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-bulletin_board
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Morcillo
|
8
8
|
- Svenja Schäfer
|
9
9
|
- Leonardo Diez
|
10
10
|
- Agustí B.R.
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2021-02-
|
14
|
+
date: 2021-02-18 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -160,15 +160,16 @@ files:
|
|
160
160
|
- Gemfile.lock
|
161
161
|
- README.md
|
162
162
|
- Rakefile
|
163
|
-
- app/assets/config/
|
163
|
+
- app/assets/config/manifest.js
|
164
164
|
- app/assets/javascripts/decidim/bulletin_board/decidim-bulletin_board.js
|
165
165
|
- bin/console
|
166
|
+
- bin/release
|
166
167
|
- bin/setup
|
167
168
|
- decidim-bulletin_board.gemspec
|
168
169
|
- lib/decidim/bulletin_board.rb
|
169
|
-
- lib/decidim/bulletin_board/authority.rb
|
170
170
|
- lib/decidim/bulletin_board/authority/create_election.rb
|
171
171
|
- lib/decidim/bulletin_board/authority/end_vote.rb
|
172
|
+
- lib/decidim/bulletin_board/authority/get_election_results.rb
|
172
173
|
- lib/decidim/bulletin_board/authority/get_election_status.rb
|
173
174
|
- lib/decidim/bulletin_board/authority/publish_results.rb
|
174
175
|
- lib/decidim/bulletin_board/authority/start_key_ceremony.rb
|
@@ -178,18 +179,18 @@ files:
|
|
178
179
|
- lib/decidim/bulletin_board/command.rb
|
179
180
|
- lib/decidim/bulletin_board/engine.rb
|
180
181
|
- lib/decidim/bulletin_board/graphql/bb_schema.json
|
181
|
-
- lib/decidim/bulletin_board/graphql/
|
182
|
+
- lib/decidim/bulletin_board/graphql/factory.rb
|
182
183
|
- lib/decidim/bulletin_board/jwk_utils.rb
|
183
184
|
- lib/decidim/bulletin_board/message_identifier.rb
|
185
|
+
- lib/decidim/bulletin_board/settings.rb
|
184
186
|
- lib/decidim/bulletin_board/version.rb
|
185
|
-
- lib/decidim/bulletin_board/voter.rb
|
186
187
|
- lib/decidim/bulletin_board/voter/cast_vote.rb
|
187
188
|
- lib/decidim/bulletin_board/voter/get_pending_message_status.rb
|
188
189
|
homepage: https://github.com
|
189
190
|
licenses:
|
190
191
|
- AGPL-3.0
|
191
192
|
metadata: {}
|
192
|
-
post_install_message:
|
193
|
+
post_install_message:
|
193
194
|
rdoc_options: []
|
194
195
|
require_paths:
|
195
196
|
- lib
|
@@ -205,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
206
|
version: '0'
|
206
207
|
requirements: []
|
207
208
|
rubygems_version: 3.0.3
|
208
|
-
signing_key:
|
209
|
+
signing_key:
|
209
210
|
specification_version: 4
|
210
211
|
summary: ''
|
211
212
|
test_files: []
|
@@ -1,9 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "decidim/bulletin_board/authority/create_election"
|
4
|
-
require "decidim/bulletin_board/authority/end_vote"
|
5
|
-
require "decidim/bulletin_board/authority/get_election_status"
|
6
|
-
require "decidim/bulletin_board/authority/start_key_ceremony"
|
7
|
-
require "decidim/bulletin_board/authority/start_tally"
|
8
|
-
require "decidim/bulletin_board/authority/start_vote"
|
9
|
-
require "decidim/bulletin_board/authority/publish_results"
|
@@ -1,18 +0,0 @@
|
|
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
|
-
schema_path: File.join(__dir__, "bb_schema.json"),
|
11
|
-
headers: {
|
12
|
-
"Authorization" => BulletinBoard.api_key
|
13
|
-
})
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|