selfsdk 0.0.131 → 0.0.136
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 +4 -4
- data/lib/acl.rb +1 -5
- data/lib/messaging.rb +3 -2
- data/lib/selfsdk.rb +2 -2
- data/lib/services/auth.rb +6 -4
- data/lib/services/facts.rb +6 -4
- data/lib/services/messaging.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80d405628b95421e76e1461dcff31f3351109cd009c7b0b677ce29d27ecf133d
|
4
|
+
data.tar.gz: 20235912eef39c3a084dd7afeab7cbb9d050d1649d02a45acdcf1a4403519e7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 734d43a91a7485370a5aa3a16fc56f2d097fc510aef007b25ad63645cf255629f286213371f787e7d2bd1e07d22ab7640a55b50b55518927a34c70dd72227d93
|
7
|
+
data.tar.gz: 9c7484084c68f95078154b2d21884c9a333a7388213fa0782ac6de7b236bedc5c5a6683fb9e62ed1e52c6c31bd63dc46cff159f977aac51886161dfbc5bec169
|
data/lib/acl.rb
CHANGED
@@ -14,11 +14,7 @@ module SelfSDK
|
|
14
14
|
# Lists allowed connections.
|
15
15
|
def list
|
16
16
|
SelfSDK.logger.info "Listing allowed connections"
|
17
|
-
|
18
|
-
@messaging.list_acl_rules.each do |c|
|
19
|
-
rules[c['acl_source']] = DateTime.parse(c['acl_exp'])
|
20
|
-
end
|
21
|
-
rules
|
17
|
+
@messaging.list_acl_rules
|
22
18
|
end
|
23
19
|
|
24
20
|
# Allows incomming messages from the given identity.
|
data/lib/messaging.rb
CHANGED
@@ -367,6 +367,8 @@ module SelfSDK
|
|
367
367
|
|
368
368
|
def process_incomming_message(input)
|
369
369
|
message = SelfSDK::Messages.parse(input, self)
|
370
|
+
@offset = input.offset
|
371
|
+
write_offset(@offset)
|
370
372
|
|
371
373
|
if @messages.include? message.id
|
372
374
|
message.validate! @messages[message.id][:original_message]
|
@@ -378,8 +380,6 @@ module SelfSDK
|
|
378
380
|
notify_observer(message)
|
379
381
|
end
|
380
382
|
|
381
|
-
@offset = input.offset
|
382
|
-
write_offset(@offset)
|
383
383
|
rescue StandardError => e
|
384
384
|
p "Error processing incoming message #{input.to_json}"
|
385
385
|
SelfSDK.logger.info e
|
@@ -434,6 +434,7 @@ module SelfSDK
|
|
434
434
|
|
435
435
|
def write_offset(offset)
|
436
436
|
File.open(@offset_file, 'wb') do |f|
|
437
|
+
f.flock(File::LOCK_EX)
|
437
438
|
f.write([offset].pack('q'))
|
438
439
|
end
|
439
440
|
end
|
data/lib/selfsdk.rb
CHANGED
@@ -61,12 +61,12 @@ module SelfSDK
|
|
61
61
|
|
62
62
|
# Provides access to SelfSDK::Services::Facts service
|
63
63
|
def facts
|
64
|
-
@facts ||= SelfSDK::Services::Facts.new(
|
64
|
+
@facts ||= SelfSDK::Services::Facts.new(messaging, @client)
|
65
65
|
end
|
66
66
|
|
67
67
|
# Provides access to SelfSDK::Services::Authentication service
|
68
68
|
def authentication
|
69
|
-
@authentication ||= SelfSDK::Services::Authentication.new(
|
69
|
+
@authentication ||= SelfSDK::Services::Authentication.new(messaging, @client)
|
70
70
|
end
|
71
71
|
|
72
72
|
# Provides access to SelfSDK::Services::Identity service
|
data/lib/services/auth.rb
CHANGED
@@ -15,7 +15,8 @@ module SelfSDK
|
|
15
15
|
#
|
16
16
|
# @return [SelfSDK::Services::Authentication] authentication service.
|
17
17
|
def initialize(messaging, client)
|
18
|
-
@messaging = messaging
|
18
|
+
@messaging = messaging.client
|
19
|
+
@messaging_service = messaging
|
19
20
|
@client = client
|
20
21
|
end
|
21
22
|
|
@@ -38,6 +39,7 @@ module SelfSDK
|
|
38
39
|
# @return [String, String] conversation id or encoded body.
|
39
40
|
def request(selfid, opts = {}, &block)
|
40
41
|
SelfSDK.logger.info "authenticating #{selfid}"
|
42
|
+
raise "You're not permitting connections from #{selfid}" unless @messaging_service.is_permitted?(selfid)
|
41
43
|
|
42
44
|
req = SelfSDK::Messages::AuthenticationReq.new(@messaging)
|
43
45
|
req.populate(selfid, opts)
|
@@ -82,11 +84,11 @@ module SelfSDK
|
|
82
84
|
body = @client.jwt.encode(request(selfid, opts))
|
83
85
|
|
84
86
|
if @client.env.empty?
|
85
|
-
return "https://
|
87
|
+
return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app"
|
86
88
|
elsif @client.env == 'development'
|
87
|
-
return "https://
|
89
|
+
return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.dev"
|
88
90
|
end
|
89
|
-
"https://
|
91
|
+
"https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.#{@client.env}"
|
90
92
|
end
|
91
93
|
|
92
94
|
# Adds an observer for an authentication response
|
data/lib/services/facts.rb
CHANGED
@@ -17,7 +17,8 @@ module SelfSDK
|
|
17
17
|
#
|
18
18
|
# @return [SelfSDK::Services::Facts] facts service.
|
19
19
|
def initialize(messaging, client)
|
20
|
-
@messaging = messaging
|
20
|
+
@messaging = messaging.client
|
21
|
+
@messaging_service = messaging
|
21
22
|
@client = client
|
22
23
|
end
|
23
24
|
|
@@ -40,6 +41,7 @@ module SelfSDK
|
|
40
41
|
# @return [Object] SelfSDK:::Messages::FactRequest
|
41
42
|
def request(selfid, facts, opts = {}, &block)
|
42
43
|
SelfSDK.logger.info "authenticating #{selfid}"
|
44
|
+
raise "You're not permitting connections from #{selfid}" unless @messaging_service.is_permitted?(selfid)
|
43
45
|
|
44
46
|
req = SelfSDK::Messages::FactRequest.new(@messaging)
|
45
47
|
req.populate(selfid, prepare_facts(facts), opts)
|
@@ -108,11 +110,11 @@ module SelfSDK
|
|
108
110
|
body = @client.jwt.encode(request(selfid, facts, opts))
|
109
111
|
|
110
112
|
if @client.env.empty?
|
111
|
-
return "https://
|
113
|
+
return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app"
|
112
114
|
elsif @client.env == 'development'
|
113
|
-
return "https://
|
115
|
+
return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.dev"
|
114
116
|
end
|
115
|
-
"https://
|
117
|
+
"https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.#{@client.env}"
|
116
118
|
end
|
117
119
|
|
118
120
|
private
|
data/lib/services/messaging.rb
CHANGED
@@ -44,6 +44,15 @@ module SelfSDK
|
|
44
44
|
acl.list
|
45
45
|
end
|
46
46
|
|
47
|
+
# Checks if you're permitting messages from a specific self identifier
|
48
|
+
# @return [Boolean] yes|no
|
49
|
+
def is_permitted?(id)
|
50
|
+
conns = allowed_connections
|
51
|
+
return true if conns.include? "*"
|
52
|
+
return true if conns.include? id
|
53
|
+
return false
|
54
|
+
end
|
55
|
+
|
47
56
|
# Revokes incoming messages from the given identity.
|
48
57
|
#
|
49
58
|
# @param [String] selfid to be denied
|