selfsdk 0.0.200 → 0.0.201

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: 74f1c051fdeb2d35ce3d50da6c0f84169f99ea0ad403c456a131a1b992da29ae
4
- data.tar.gz: a3a869a1ec7240c3bc0076d44540c53456438008636382bd165e1ab89a32e045
3
+ metadata.gz: 8cb8631899d2a3a9bcd9d3dc58171fcdd6714de37995efe2984eaa1aa823e091
4
+ data.tar.gz: f0aa18f9e3eb660e1e644b261e271e36381a67a815fea054bc1a61a5826b63d0
5
5
  SHA512:
6
- metadata.gz: 8723dbb549e965ba752e20a35fddc93034ac9dc719344025858eee1c3c2050f411e93a4db48cd38102182d8a801f45c64cebe67aed45c33ad7196e95b764cb43
7
- data.tar.gz: 32971cdca3e179fc85ac190ad87fa5ba48fe92f1b63212f6cc948a6a2c989063c471a0dd65219036895a8a28441da99ed5b4ede67f88bf56c37f3aa4a9d5ca11
6
+ metadata.gz: 1f05d3278b9c176e19af9ee0a08e162091e67a4ea452b700f894bab0fb33c81c29748733ce0fc7052516c75eadcfd45c77dcf653ee455f7258ced4d60ed8a415
7
+ data.tar.gz: 30e56bd392849869232b1997a09d1c98fa8d2a0b825ac30f166b32c97813437d2aefc1613a1c9701ff356814dee21d8cff9668cdae7ba6baeadbbb5db41708e0
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
 
@@ -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
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.200
4
+ version: 0.0.201
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldgate Ventures
@@ -324,6 +324,26 @@ dependencies:
324
324
  - - ">="
325
325
  - !ruby/object:Gem::Version
326
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
327
347
  description:
328
348
  email:
329
349
  executables: []