selfsdk 0.0.200 → 0.0.203

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74f1c051fdeb2d35ce3d50da6c0f84169f99ea0ad403c456a131a1b992da29ae
4
- data.tar.gz: a3a869a1ec7240c3bc0076d44540c53456438008636382bd165e1ab89a32e045
3
+ metadata.gz: ea79de24bb9968fdd994ea934e93665edbd640ab6eb69b129a692f3eee92ae90
4
+ data.tar.gz: 94bef0e9ad11a2bc9362d02105ef023ec7e635ae253d3b653c263d1130d21e52
5
5
  SHA512:
6
- metadata.gz: 8723dbb549e965ba752e20a35fddc93034ac9dc719344025858eee1c3c2050f411e93a4db48cd38102182d8a801f45c64cebe67aed45c33ad7196e95b764cb43
7
- data.tar.gz: 32971cdca3e179fc85ac190ad87fa5ba48fe92f1b63212f6cc948a6a2c989063c471a0dd65219036895a8a28441da99ed5b4ede67f88bf56c37f3aa4a9d5ca11
6
+ metadata.gz: b72a3aa8ba3d723404c59854a2d2b1fd96ab5954506f064fc1b34459c5b31cec20551664fd7133929777be3d2def925a2d3a8a991de9c2b76ab2f725a3572335
7
+ data.tar.gz: 3ef093c5fb94a36cb91ef2576eb5b38f9b401694d8464f35c588f6b45e29860251383fe697d655c66c5af9135b0af759bc6d82a5dea4363b48e1110245b9ad27
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
@@ -10,6 +10,12 @@ require_relative "chat_message_delivered"
10
10
  require_relative "chat_invite"
11
11
  require_relative "chat_join"
12
12
  require_relative "chat_remove"
13
+ require_relative "voice_setup"
14
+ require_relative "voice_start"
15
+ require_relative "voice_accept"
16
+ require_relative "voice_stop"
17
+ require_relative "voice_busy"
18
+ require_relative "voice_summary"
13
19
  require_relative "document_sign_resp"
14
20
  require_relative "connection_response"
15
21
 
@@ -59,6 +65,24 @@ module SelfSDK
59
65
  when SelfSDK::Messages::ConnectionResponse::MSG_TYPE
60
66
  m = ConnectionResponse.new(messaging)
61
67
  m.parse(body, envelope)
68
+ when SelfSDK::Messages::VoiceSetup::MSG_TYPE
69
+ m = VoiceSetup.new(messaging)
70
+ m.parse(body, envelope)
71
+ when SelfSDK::Messages::VoiceStart::MSG_TYPE
72
+ m = VoiceStart.new(messaging)
73
+ m.parse(body, envelope)
74
+ when SelfSDK::Messages::VoiceAccept::MSG_TYPE
75
+ m = VoiceAccept.new(messaging)
76
+ m.parse(body, envelope)
77
+ when SelfSDK::Messages::VoiceBusy::MSG_TYPE
78
+ m = VoiceBusy.new(messaging)
79
+ m.parse(body, envelope)
80
+ when SelfSDK::Messages::VoiceStop::MSG_TYPE
81
+ m = VoiceStop.new(messaging)
82
+ m.parse(body, envelope)
83
+ when SelfSDK::Messages::VoiceSummary::MSG_TYPE
84
+ m = VoiceSummary.new(messaging)
85
+ m.parse(body, envelope)
62
86
  else
63
87
  raise StandardError.new("Invalid message type #{payload[:typ]}.")
64
88
  end
@@ -0,0 +1,19 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require_relative 'chat'
6
+
7
+ module SelfSDK
8
+ module Messages
9
+ class VoiceAccept < Chat
10
+ MSG_TYPE = "chat.voice.accept"
11
+
12
+ def parse(input, envelope=nil)
13
+ super
14
+ @typ = MSG_TYPE
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require_relative 'chat'
6
+
7
+ module SelfSDK
8
+ module Messages
9
+ class VoiceBusy < Chat
10
+ MSG_TYPE = "chat.voice.busy"
11
+
12
+ def parse(input, envelope=nil)
13
+ super
14
+ @typ = MSG_TYPE
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require_relative 'chat'
6
+
7
+ module SelfSDK
8
+ module Messages
9
+ class VoiceSetup < Chat
10
+ MSG_TYPE = "chat.voice.setup"
11
+
12
+ def parse(input, envelope=nil)
13
+ super
14
+ @typ = MSG_TYPE
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require_relative 'chat'
6
+
7
+ module SelfSDK
8
+ module Messages
9
+ class VoiceStart < Chat
10
+ MSG_TYPE = "chat.voice.start"
11
+
12
+ def parse(input, envelope=nil)
13
+ super
14
+ @typ = MSG_TYPE
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require_relative 'chat'
6
+
7
+ module SelfSDK
8
+ module Messages
9
+ class VoiceStop < Chat
10
+ MSG_TYPE = "chat.voice.stop"
11
+
12
+ def parse(input, envelope=nil)
13
+ super
14
+ @typ = MSG_TYPE
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # Copyright 2020 Self Group Ltd. All Rights Reserved.
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require_relative 'chat'
6
+
7
+ module SelfSDK
8
+ module Messages
9
+ class VoiceSummary < Chat
10
+ MSG_TYPE = "chat.voice.summary"
11
+
12
+ def parse(input, envelope=nil)
13
+ super
14
+ @typ = MSG_TYPE
15
+ end
16
+
17
+ end
18
+ end
19
+ 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
@@ -394,6 +414,8 @@ module SelfSDK
394
414
  SelfSDK.logger.warn "error on #{hdr.id}"
395
415
  e = SelfMsg::Notification.new(data: data)
396
416
  SelfSDK.logger.warn "#{e.error}"
417
+ @messages[hdr.id][:response] = {error: e.error}
418
+ mark_as_acknowledged(hdr.id)
397
419
  mark_as_arrived(hdr.id)
398
420
  when SelfMsg::MsgTypeACL
399
421
  SelfSDK.logger.info "ACL received"
@@ -514,5 +536,9 @@ module SelfSDK
514
536
  end
515
537
 
516
538
  end
539
+
540
+ def select_priority(mtype)
541
+ PRIORITIES[mtype] || SelfSDK::Messages::PRIORITY_VISIBLE
542
+ end
517
543
  end
518
544
  end
data/lib/selfsdk.rb CHANGED
@@ -23,6 +23,7 @@ require_relative 'services/identity'
23
23
  require_relative 'services/messaging'
24
24
  require_relative 'services/chat'
25
25
  require_relative 'services/docs'
26
+ require_relative 'services/voice'
26
27
 
27
28
  # Namespace for classes and modules that handle Self interactions.
28
29
  module SelfSDK
@@ -90,6 +91,11 @@ module SelfSDK
90
91
  @chat ||= SelfSDK::Services::Chat.new(messaging, identity)
91
92
  end
92
93
 
94
+ # Provides access to SelfSDK::Services::Voice service
95
+ def voice
96
+ @voice ||= SelfSDK::Services::Voice.new(messaging)
97
+ end
98
+
93
99
  # Provides access to SelfSDK::Services::Docs service
94
100
  def docs
95
101
  @docs ||= SelfSDK::Services::Docs.new(messaging, @client.self_url)
@@ -116,16 +116,20 @@ module SelfSDK
116
116
  class Fact
117
117
  attr_accessor :key, :value, :group
118
118
 
119
- def initialize(key, value, source, group = nil)
119
+
120
+ def initialize(key, value, source, opts = {})
120
121
  @key = key
121
122
  @value = value
122
123
  @source = source
123
- @group = group
124
+ @display_name = opts.fetch(:display_name, "")
125
+ @group = opts.fetch(:group, nil)
126
+ @type = opts.fetch(:type, nil)
124
127
  end
125
128
 
126
129
  def to_hash
127
130
  b = { key: @key, value: @value, source: @source }
128
131
  b[:group] = @group.to_hash unless @group.nil?
132
+ b[:type] = @type unless @type.nil?
129
133
  b
130
134
  end
131
135
  end
@@ -144,6 +148,42 @@ module SelfSDK
144
148
  b
145
149
  end
146
150
  end
151
+
152
+ class Delegation
153
+ TYPE = 'delegation_certificate'
154
+ attr_accessor :subjects, :actions, :effect, :resources, :conditions, :description
155
+
156
+ def initialize(subjects, actions, effect, resources, opts = {})
157
+ @subjects = subjects
158
+ @actions = actions
159
+ @effect = effect
160
+ @resources = resources
161
+ @conditions = opts.fetch(:conditions, nil)
162
+ @description = opts.fetch(:description, nil)
163
+ end
164
+
165
+ def encode
166
+ cert = {
167
+ subjects: @subjects,
168
+ actions: @actions,
169
+ effect: @effect,
170
+ resources: @resources,
171
+ }.to_json
172
+
173
+ Base64.urlsafe_encode64(cert, padding: false)
174
+ end
175
+
176
+ def self.parse(input)
177
+ b = JSON.parse(Base64.urlsafe_decode64(input))
178
+ Delegation.new(
179
+ b['subjects'],
180
+ b['actions'],
181
+ b['effect'],
182
+ b['resources'],
183
+ conditions: b['conditions'],
184
+ description: b['description'])
185
+ end
186
+ end
147
187
  end
148
188
  end
149
- end
189
+ end
data/lib/sources.rb CHANGED
@@ -56,6 +56,12 @@ module SelfSDK
56
56
  chat_remove: SelfSDK::Messages::ChatRemove::MSG_TYPE,
57
57
  document_sign_response: SelfSDK::Messages::DocumentSignResponse::MSG_TYPE,
58
58
  connection_response: SelfSDK::Messages::ConnectionResponse::MSG_TYPE,
59
+ voice_setup: SelfSDK::Messages::VoiceSetup::MSG_TYPE,
60
+ voice_start: SelfSDK::Messages::VoiceStart::MSG_TYPE,
61
+ voice_accept: SelfSDK::Messages::VoiceAccept::MSG_TYPE,
62
+ voice_busy: SelfSDK::Messages::VoiceBusy::MSG_TYPE,
63
+ voice_stop: SelfSDK::Messages::VoiceStop::MSG_TYPE,
64
+ voice_summary: SelfSDK::Messages::VoiceSummary::MSG_TYPE,
59
65
  }
60
66
  raise "invalid message type '#{s}'" unless types.key? s
61
67
  return types[s]
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.203
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: []
@@ -356,6 +376,12 @@ files:
356
376
  - lib/messages/fact_request.rb
357
377
  - lib/messages/fact_response.rb
358
378
  - lib/messages/message.rb
379
+ - lib/messages/voice_accept.rb
380
+ - lib/messages/voice_busy.rb
381
+ - lib/messages/voice_setup.rb
382
+ - lib/messages/voice_start.rb
383
+ - lib/messages/voice_stop.rb
384
+ - lib/messages/voice_summary.rb
359
385
  - lib/messaging.rb
360
386
  - lib/ntptime.rb
361
387
  - lib/selfsdk.rb