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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de6c98236b7c43869701b0d8d538e309c432104a7ff793dcff59f34b01615adf
4
- data.tar.gz: da9ba6706eaf3ca113dd4c38a3b633a13850947c0cbfefe70ca1ce05b012e539
3
+ metadata.gz: 80d405628b95421e76e1461dcff31f3351109cd009c7b0b677ce29d27ecf133d
4
+ data.tar.gz: 20235912eef39c3a084dd7afeab7cbb9d050d1649d02a45acdcf1a4403519e7f
5
5
  SHA512:
6
- metadata.gz: 9fffb2a10a98443d6396d2c0a108522c403e1b625c51b088e470996632749fc2368ec74238d82418c15fbe6bf1cdae3d8e3e454767e314f4dfc1b9e25fe3a6b7
7
- data.tar.gz: 64ff7184a0235b16164476259987df92bbfb60f25cfeb9751ff9a838cb7aaf83d7fe7fdc06e8ade67a6c70ed3eaf19b4b04c33e2bd548e95d2eb66b074b9f4ad
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
- rules = {}
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.
@@ -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
@@ -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(@messaging_client, @client)
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(@messaging_client, @client)
69
+ @authentication ||= SelfSDK::Services::Authentication.new(messaging, @client)
70
70
  end
71
71
 
72
72
  # Provides access to SelfSDK::Services::Identity service
@@ -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://selfid.page.link/?link=#{callback}%3Fqr=#{body}&apn=net.selfid.app"
87
+ return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app"
86
88
  elsif @client.env == 'development'
87
- return "https://selfid.page.link/?link=#{callback}%3Fqr=#{body}&apn=net.selfid.app.dev"
89
+ return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.dev"
88
90
  end
89
- "https://selfid.page.link/?link=#{callback}%3Fqr=#{body}&apn=net.selfid.app.#{@client.env}"
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
@@ -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://selfid.page.link/?link=#{callback}%3Fqr=#{body}&apn=net.selfid.app"
113
+ return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app"
112
114
  elsif @client.env == 'development'
113
- return "https://selfid.page.link/?link=#{callback}%3Fqr=#{body}&apn=net.selfid.app.dev"
115
+ return "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.dev"
114
116
  end
115
- "https://selfid.page.link/?link=#{callback}%3Fqr=#{body}&apn=net.selfid.app.#{@client.env}"
117
+ "https://joinself.page.link/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.#{@client.env}"
116
118
  end
117
119
 
118
120
  private
@@ -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
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.131
4
+ version: 0.0.136
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldgate Ventures