selfsdk 0.0.199 → 0.0.202

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5efd422cc1411e12df47ec16ef2ec8a78e44b8782f3a194f24aab016a7bbb9a
4
- data.tar.gz: 0b369f48bd99e6f6d409b3d182f6a2e5fbb0b53c4ac0f45078bd7d0f75b81044
3
+ metadata.gz: 74920fded29921c1b8b2556d0b1bc3e2e364a98e1f7bc186b90662985c5e6ddc
4
+ data.tar.gz: f9f99f488a85b1b34d55fecff7c7f32bdc8090238c517883e62067cb21116490
5
5
  SHA512:
6
- metadata.gz: 15fcfc3946c7a78f4cf947425bc04522194d5324d19c70c243bb1601918dc80d9c99a6e8b7e59e4d2e5600b9691c2d078ad286ad461fb0a55fd41c505150452e
7
- data.tar.gz: 497392f70dfc1d9e12bdaa6999aea6dd6f43a4c0e50db723d581cb2d6aced23e289585a469196fc2420958b760a136c0e9b834b38052464efd503abd43fc54e9
6
+ metadata.gz: 1b71aaf4e476242853c61942d4e4cf45033b151647e2a1b2a84d6895f1194f8d04b00db543a3135735ec3628344618c8b541b3abdb7dc58ed810eec5833343ba
7
+ data.tar.gz: f4d53c796139927947f2d20e2c75e5bd5b5002785ceaad2d3200c698e3115f91e212165d136ab8e0641848a69f67c6213e471bc11c4e40211beb019c30a8d71f
data/lib/messages/base.rb CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  module SelfSDK
6
6
  module Messages
7
+
8
+ PRIORITY_VISIBLE = 1
9
+ PRIORITY_INVISIBLE = 2
10
+
7
11
  class Base
8
12
  attr_accessor :from, :from_device, :to, :to_device, :expires, :id,
9
13
  :fields, :typ, :payload, :status, :input, :intermediary,
@@ -57,6 +57,8 @@ module SelfSDK
57
57
  m.sender = "#{@jwt.id}:#{@messaging.device_id}"
58
58
  m.recipient = recipient
59
59
  m.ciphertext = ciphertext
60
+ m.message_type = MSG_TYPE
61
+ m.priority = SelfSDK::Messages::PRIORITY_VISIBLE
60
62
  m
61
63
  end
62
64
  end
@@ -57,6 +57,8 @@ module SelfSDK
57
57
  m.sender = "#{@jwt.id}:#{@messaging.device_id}"
58
58
  m.recipient = recipient
59
59
  m.ciphertext = ciphertext
60
+ m.message_type = MSG_TYPE
61
+ m.priority = SelfSDK::Messages::PRIORITY_VISIBLE
60
62
  m
61
63
  end
62
64
 
@@ -87,7 +87,7 @@ module SelfSDK
87
87
  b = {
88
88
  typ: MSG_TYPE,
89
89
  iss: @jwt.id,
90
- aud: @to,
90
+ aud: @intermediary ? @intermediary : @to,
91
91
  sub: @to,
92
92
  iat: SelfSDK::Time.now.strftime('%FT%TZ'),
93
93
  exp: (SelfSDK::Time.now + @exp_timeout).strftime('%FT%TZ'),
@@ -119,6 +119,8 @@ module SelfSDK
119
119
  m.sender = "#{@jwt.id}:#{@messaging.device_id}"
120
120
  m.recipient = recipient
121
121
  m.ciphertext = ciphertext
122
+ m.message_type = MSG_TYPE
123
+ m.priority = SelfSDK::Messages::PRIORITY_VISIBLE
122
124
  m
123
125
  end
124
126
  end
@@ -92,19 +92,6 @@ module SelfSDK
92
92
  def auth_response?
93
93
  @auth == true
94
94
  end
95
-
96
- protected
97
-
98
- def proto(to_device)
99
- @to_device = to_device
100
- Msgproto::Message.new(
101
- type: Msgproto::MsgType::MSG,
102
- id: SecureRandom.uuid,
103
- sender: "#{@jwt.id}:#{@messaging.device_id}",
104
- recipient: "#{@to}:#{@to_device}",
105
- ciphertext: encrypt_message(@jwt.prepare(body), [{id: @to, device_id: @to_device}])
106
- )
107
- end
108
95
  end
109
96
  end
110
97
  end
data/lib/messaging.rb CHANGED
@@ -17,6 +17,23 @@ module SelfSDK
17
17
  DEFAULT_STORAGE_DIR="./.self_storage"
18
18
  ON_DEMAND_CLOSE_CODE=3999
19
19
 
20
+ PRIORITIES = {
21
+ "chat.invite": SelfSDK::Messages::PRIORITY_VISIBLE,
22
+ "chat.join": SelfSDK::Messages::PRIORITY_INVISIBLE,
23
+ "chat.message": SelfSDK::Messages::PRIORITY_VISIBLE,
24
+ "chat.message.delete": SelfSDK::Messages::PRIORITY_INVISIBLE,
25
+ "chat.message.delivered": SelfSDK::Messages::PRIORITY_INVISIBLE,
26
+ "chat.message.edit": SelfSDK::Messages::PRIORITY_INVISIBLE,
27
+ "chat.message.read": SelfSDK::Messages::PRIORITY_INVISIBLE,
28
+ "chat.remove": SelfSDK::Messages::PRIORITY_INVISIBLE,
29
+ "document.sign.req": SelfSDK::Messages::PRIORITY_VISIBLE,
30
+ "identities.authenticate.req": SelfSDK::Messages::PRIORITY_VISIBLE,
31
+ "identities.connections.req": SelfSDK::Messages::PRIORITY_VISIBLE,
32
+ "identities.facts.query.req": SelfSDK::Messages::PRIORITY_VISIBLE,
33
+ "identities.facts.issue": SelfSDK::Messages::PRIORITY_VISIBLE,
34
+ "identities.notify": SelfSDK::Messages::PRIORITY_VISIBLE
35
+ }
36
+
20
37
  attr_accessor :client, :jwt, :device_id, :ack_timeout, :timeout, :type_observer, :uuid_observer, :encryption_client, :source
21
38
 
22
39
  # RestClient initializer
@@ -87,7 +104,8 @@ module SelfSDK
87
104
  m.id = SecureRandom.uuid
88
105
  m.sender = "#{@jwt.id}:#{@device_id}"
89
106
  m.recipient = "#{recipient}:#{recipient_device}"
90
- # TODO: this is unencrypted!!!
107
+ m.message_type = "identities.facts.query.resp"
108
+ m.priority = select_priority(m.message_type)
91
109
  m.ciphertext = @jwt.prepare(request)
92
110
 
93
111
  send_message m
@@ -133,6 +151,8 @@ module SelfSDK
133
151
  m.sender = current_device
134
152
  m.recipient = "#{r[:id]}:#{r[:device_id]}"
135
153
  m.ciphertext = ciphertext
154
+ m.message_type = r[:typ]
155
+ m.priority = select_priority(r[:typ])
136
156
 
137
157
  SelfSDK.logger.info " -> to #{m.recipient}"
138
158
  send_message m
@@ -514,5 +534,9 @@ module SelfSDK
514
534
  end
515
535
 
516
536
  end
537
+
538
+ def select_priority(mtype)
539
+ PRIORITIES[mtype] || SelfSDK::Messages::PRIORITY_VISIBLE
540
+ end
517
541
  end
518
542
  end
@@ -166,17 +166,18 @@ module SelfSDK
166
166
  def validate_fact!(f)
167
167
  errInvalidFactToSource = 'provided source does not support given fact'
168
168
  errInvalidSource = 'provided fact does not specify a valid source'
169
+ fact_name = f[:fact].to_s
169
170
 
170
- raise 'provided fact does not specify a name' if f[:fact].empty?
171
+ raise 'provided fact does not specify a name' if fact_name.empty?
171
172
  return unless f.has_key? :sources
172
173
  return if f.has_key? :issuers # skip the validation if is a custom fact
173
174
 
174
- raise "invalid fact '#{f[:fact]}'" unless @messaging.facts.include?(f[:fact])
175
+ raise "invalid fact '#{fact_name}'" unless @messaging.source.core_fact?(fact_name)
175
176
 
176
- spec = @messaging.sources
177
+ spec = @messaging.source.sources
177
178
  f[:sources].each do |s|
178
- raise errInvalidSource unless spec.key?(s)
179
- raise errInvalidFactToSource unless spec[s].include? f[:fact]
179
+ raise errInvalidSource unless spec.key?(s.to_s)
180
+ raise errInvalidFactToSource unless spec[s.to_s].include? fact_name.to_s
180
181
  end
181
182
  end
182
183
  end
data/lib/sources.rb CHANGED
@@ -6,8 +6,9 @@ require "json"
6
6
  require_relative "source_definition.rb"
7
7
 
8
8
  module SelfSDK
9
- attr_reader :sources, :facts
10
9
  class Sources
10
+ attr_reader :sources, :facts
11
+
11
12
  def initialize(sources_file)
12
13
  @sources = SOURCE_DATA["sources"]
13
14
  @facts = []
@@ -40,6 +41,10 @@ module SelfSDK
40
41
  get(operators, input, "operator")
41
42
  end
42
43
 
44
+ def core_fact?(fact)
45
+ @facts.include? fact.to_s
46
+ end
47
+
43
48
  def message_type(s)
44
49
  types = { fact_request: SelfSDK::Messages::FactRequest::MSG_TYPE,
45
50
  fact_response: SelfSDK::Messages::FactResponse::MSG_TYPE,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selfsdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.199
4
+ version: 0.0.202
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldgate Ventures
@@ -184,14 +184,20 @@ dependencies:
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '1.12'
187
+ version: '2.3'
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ version: 2.3.13
188
191
  type: :development
189
192
  prerelease: false
190
193
  version_requirements: !ruby/object:Gem::Requirement
191
194
  requirements:
192
195
  - - "~>"
193
196
  - !ruby/object:Gem::Version
194
- version: '1.12'
197
+ version: '2.3'
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: 2.3.13
195
201
  - !ruby/object:Gem::Dependency
196
202
  name: minitest
197
203
  requirement: !ruby/object:Gem::Requirement
@@ -318,6 +324,26 @@ dependencies:
318
324
  - - ">="
319
325
  - !ruby/object:Gem::Version
320
326
  version: '0'
327
+ - !ruby/object:Gem::Dependency
328
+ name: rexml
329
+ requirement: !ruby/object:Gem::Requirement
330
+ requirements:
331
+ - - "~>"
332
+ - !ruby/object:Gem::Version
333
+ version: '3.2'
334
+ - - ">="
335
+ - !ruby/object:Gem::Version
336
+ version: 3.2.5
337
+ type: :development
338
+ prerelease: false
339
+ version_requirements: !ruby/object:Gem::Requirement
340
+ requirements:
341
+ - - "~>"
342
+ - !ruby/object:Gem::Version
343
+ version: '3.2'
344
+ - - ">="
345
+ - !ruby/object:Gem::Version
346
+ version: 3.2.5
321
347
  description:
322
348
  email:
323
349
  executables: []
@@ -384,7 +410,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
384
410
  - !ruby/object:Gem::Version
385
411
  version: '0'
386
412
  requirements: []
387
- rubygems_version: 3.0.3
413
+ rubygems_version: 3.1.6
388
414
  signing_key:
389
415
  specification_version: 4
390
416
  summary: joinself sdk