selfsdk 0.0.201 → 0.0.204
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/messages/message.rb +24 -0
- data/lib/messages/voice_accept.rb +19 -0
- data/lib/messages/voice_busy.rb +19 -0
- data/lib/messages/voice_setup.rb +19 -0
- data/lib/messages/voice_start.rb +19 -0
- data/lib/messages/voice_stop.rb +19 -0
- data/lib/messages/voice_summary.rb +19 -0
- data/lib/messaging.rb +2 -0
- data/lib/selfsdk.rb +6 -0
- data/lib/services/facts.rb +43 -3
- data/lib/services/voice.rb +147 -0
- data/lib/sources.rb +6 -0
- metadata +8 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e43ffd18c6b77a9d2c4be2a20e99f634f2c4c4b16e5192ef095ba728fedf04c3
|
4
|
+
data.tar.gz: 07a2dd57e3d9dc547e56357043656f86e8018022a156c506cfecf040d8a6d1ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc3ef76d0c8556b4a569ee7d0e8eacc9d35d519dd0dd2612155a622db1affe85ea393b47963c8b1eb4e47cb619a72b4d6e2976dfd3cc57690d75ed6846868e34
|
7
|
+
data.tar.gz: beea6022c1e6510fea1e6a293d678af1d9b85e892a7e654327dbecd93150f616dd812ec52c9ea7290a9ef74f9fd0f65225c607610c528b66b8b20c9cf9f3a444
|
data/lib/messages/message.rb
CHANGED
@@ -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
@@ -414,6 +414,8 @@ module SelfSDK
|
|
414
414
|
SelfSDK.logger.warn "error on #{hdr.id}"
|
415
415
|
e = SelfMsg::Notification.new(data: data)
|
416
416
|
SelfSDK.logger.warn "#{e.error}"
|
417
|
+
@messages[hdr.id][:response] = {error: e.error}
|
418
|
+
mark_as_acknowledged(hdr.id)
|
417
419
|
mark_as_arrived(hdr.id)
|
418
420
|
when SelfMsg::MsgTypeACL
|
419
421
|
SelfSDK.logger.info "ACL received"
|
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)
|
data/lib/services/facts.rb
CHANGED
@@ -116,16 +116,20 @@ module SelfSDK
|
|
116
116
|
class Fact
|
117
117
|
attr_accessor :key, :value, :group
|
118
118
|
|
119
|
-
|
119
|
+
|
120
|
+
def initialize(key, value, source, opts = {})
|
120
121
|
@key = key
|
121
122
|
@value = value
|
122
123
|
@source = source
|
123
|
-
@
|
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
|
@@ -0,0 +1,147 @@
|
|
1
|
+
# Copyright 2020 Self Group Ltd. All Rights Reserved.
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'self_crypto'
|
6
|
+
require_relative '../chat/file_object'
|
7
|
+
require_relative '../chat/group'
|
8
|
+
require_relative '../chat/message'
|
9
|
+
require_relative "../messages/connection_request"
|
10
|
+
|
11
|
+
module SelfSDK
|
12
|
+
module Services
|
13
|
+
class Voice
|
14
|
+
attr_accessor :app_id
|
15
|
+
|
16
|
+
def initialize(messaging)
|
17
|
+
@messaging = messaging
|
18
|
+
end
|
19
|
+
|
20
|
+
# Sends a chat.voice.setup message to setup a delegated call.
|
21
|
+
def setup(recipient, name, cid)
|
22
|
+
payload = { typ: SelfSDK::Messages::VoiceSetup::MSG_TYPE }
|
23
|
+
payload[:cid] = cid
|
24
|
+
payload[:data] = { name: name }
|
25
|
+
|
26
|
+
send([recipient], payload)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Subscribes to chat.voice.setup messages.
|
30
|
+
def on_setup(&block)
|
31
|
+
@messaging.subscribe :voice_setup do |msg|
|
32
|
+
block.call(msg.payload[:iss], msg.payload[:cid], msg.payload[:data])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Sends a chat.voice.start message with the details for starting a call.
|
37
|
+
def start(recipient, cid, call_id, peer_info, data)
|
38
|
+
send([recipient],
|
39
|
+
typ: SelfSDK::Messages::VoiceStart::MSG_TYPE,
|
40
|
+
cid: cid,
|
41
|
+
call_id: call_id,
|
42
|
+
peer_info: peer_info,
|
43
|
+
data: data)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Subscribes to chat.voice.start messages.
|
47
|
+
def on_start(&block)
|
48
|
+
@messaging.subscribe :voice_start do |msg|
|
49
|
+
block.call(msg.payload[:iss],
|
50
|
+
cid: msg.payload[:cid],
|
51
|
+
call_id: msg.payload[:call_id],
|
52
|
+
peer_info: msg.payload[:peer_info],
|
53
|
+
data: msg.payload[:data])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Sends a chat.voice.accept message accepting a specific call.
|
58
|
+
def accept(recipient, cid, call_id, peer_info)
|
59
|
+
payload = {
|
60
|
+
typ: SelfSDK::Messages::VoiceAccept::MSG_TYPE,
|
61
|
+
cid: cid,
|
62
|
+
call_id: call_id,
|
63
|
+
peer_info: peer_info,
|
64
|
+
}
|
65
|
+
send([recipient], payload)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Subscribes to chat.voice.accept messages.
|
69
|
+
def on_accept(&block)
|
70
|
+
@messaging.subscribe :voice_accept do |msg|
|
71
|
+
block.call(msg.payload[:iss],
|
72
|
+
cid: msg.payload[:cid],
|
73
|
+
call_id: msg.payload[:call_id],
|
74
|
+
peer_info: msg.payload[:peer_info])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Sends a chat.voice.accept message finishing the call.
|
79
|
+
def stop(recipient, cid, call_id)
|
80
|
+
payload = {
|
81
|
+
typ: SelfSDK::Messages::VoiceStop::MSG_TYPE,
|
82
|
+
cid: cid,
|
83
|
+
call_id: call_id,
|
84
|
+
}
|
85
|
+
send([recipient], payload)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Subscribes to chat.voice.stop messages.
|
89
|
+
def on_stop(&block)
|
90
|
+
@messaging.subscribe :voice_stop do |msg|
|
91
|
+
block.call(msg.payload[:iss],
|
92
|
+
cid: msg.payload[:cid],
|
93
|
+
call_id: msg.payload[:call_id],
|
94
|
+
peer_info: msg.payload[:peer_info])
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Sends a chat.voice.busy message finishing the call.
|
99
|
+
def busy(recipient, cid, call_id)
|
100
|
+
send([recipient],
|
101
|
+
typ: SelfSDK::Messages::VoiceBusy::MSG_TYPE,
|
102
|
+
cid: cid,
|
103
|
+
call_id: call_id)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Subscribes to chat.voice.busy messages.
|
107
|
+
def on_busy(&block)
|
108
|
+
@messaging.subscribe :voice_busy do |msg|
|
109
|
+
block.call(msg.payload[:iss],
|
110
|
+
cid: msg.payload[:cid],
|
111
|
+
call_id: msg.payload[:call_id],
|
112
|
+
peer_info: msg.payload[:peer_info])
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Sends a chat.voice.summary message Sending details about the call.
|
117
|
+
def summary(recipient, cid, call_id)
|
118
|
+
send([recipient],
|
119
|
+
typ: SelfSDK::Messages::VoiceSummary::MSG_TYPE,
|
120
|
+
cid: cid,
|
121
|
+
call_id: call_id)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Subscribes to chat.voice.summary messages.
|
125
|
+
def on_summary(&block)
|
126
|
+
@messaging.subscribe :voice_summary do |msg|
|
127
|
+
block.call(msg.payload[:iss],
|
128
|
+
cid: msg.payload[:cid],
|
129
|
+
call_id: msg.payload[:call_id],
|
130
|
+
peer_info: msg.payload[:peer_info])
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
# sends a message to a list of recipients.
|
137
|
+
def send(recipients, body)
|
138
|
+
recipients = [recipients] if recipients.is_a? String
|
139
|
+
m = []
|
140
|
+
recipients.each do |r|
|
141
|
+
m << @messaging.send(r, body)
|
142
|
+
end
|
143
|
+
m
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
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.
|
4
|
+
version: 0.0.204
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aldgate Ventures
|
@@ -376,6 +376,12 @@ files:
|
|
376
376
|
- lib/messages/fact_request.rb
|
377
377
|
- lib/messages/fact_response.rb
|
378
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
|
379
385
|
- lib/messaging.rb
|
380
386
|
- lib/ntptime.rb
|
381
387
|
- lib/selfsdk.rb
|
@@ -386,6 +392,7 @@ files:
|
|
386
392
|
- lib/services/identity.rb
|
387
393
|
- lib/services/messaging.rb
|
388
394
|
- lib/services/requester.rb
|
395
|
+
- lib/services/voice.rb
|
389
396
|
- lib/signature_graph.rb
|
390
397
|
- lib/source_definition.rb
|
391
398
|
- lib/sources.rb
|