selfsdk 0.0.205 → 0.0.207

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: aefa2c3a38cd8b027fb2095affee9bd67b74c1e1c417ffa9e028f656a3d28e34
4
- data.tar.gz: 7969b31c5f519a2d9c4a8a098d8862119dbdf4e0aba6dfa71b39dfb7e2d2d437
3
+ metadata.gz: 565f3e3071fcb9d7f8686480e0890af54c1b6ee55996453e24028f3c2050803e
4
+ data.tar.gz: 16ed62893ffd1f8ef278e8626f4fc26279fa71b77e40c2d7135f0f39ed9e660a
5
5
  SHA512:
6
- metadata.gz: f15414f199e776fb0bf7578226c00c8f9c649940fd9ac74d40b177e50a3acca0a48204c8e638a1bf15bc5c09e35a868c60f3833bfd778e8fe13161263d25b11d
7
- data.tar.gz: 5e6f46cad290c73094aa2697b63b154a79cd1f54610c7b8051a6b8ebf14e604432fb86ba6b45884aec90ad51c54cb1545bfe5fcb04012c8e6f8160caf7afc44e
6
+ metadata.gz: 58019c1d8e3c7ccb93b0dbdc9a577a662465628708baddbf26cf5f065c98094e187bb8b20b781d9715b51169b8e330f9d602e97b4d54cda45c7d8e57671b1de4
7
+ data.tar.gz: 644041c1d742e1a5886a981c744c31ac324ce1ddecdef842157babd82a796df8f1d921e6fe2a5379f4ef83267a245c6b59bb88321e8989668531f7b78ff7913c
@@ -36,12 +36,14 @@ module SelfSDK
36
36
  def build_from_object(input)
37
37
  # Download from CDN
38
38
  ciphertext = ""
39
+ link = input[:link]
39
40
  5.times do
40
41
  begin
41
- ciphertext = URI.open(input[:link], "Authorization" => "Bearer #{@token}").read
42
+ ciphertext = URI.open(link, "Authorization" => "Bearer #{@token}").read
42
43
  break
43
44
  rescue => e
44
45
  SelfSDK.logger.info "error fetching #{input[:link]} : #{e.message}"
46
+ link = link.replace("localhost:8080", "api:8080")
45
47
  sleep 1
46
48
  end
47
49
  end
data/lib/jwt_service.rb CHANGED
@@ -93,6 +93,21 @@ module SelfSDK
93
93
  "#{payload}.#{signature}"
94
94
  end
95
95
 
96
+ def build_dynamic_link(body, env, callback)
97
+ base_url = "https://#{env}.links.joinself.com"
98
+ portal_url = "https://developer.#{env}.joinself.com"
99
+ apn = "com.joinself.app.#{env}"
100
+
101
+ if env.empty? || env == 'development'
102
+ base_url = "https://links.joinself.com"
103
+ portal_url = "https://developer.joinself.com"
104
+ apn = "com.joinself.app"
105
+ end
106
+ apn = "com.joinself.app.dev" if env == 'development'
107
+
108
+ "#{base_url}?link=#{portal_url}/callback/#{callback}%3Fqr=#{body}&apn=#{apn}"
109
+ end
110
+
96
111
  private
97
112
 
98
113
  def header
data/lib/selfsdk.rb CHANGED
@@ -55,6 +55,7 @@ module SelfSDK
55
55
 
56
56
  SelfSDK.logger.debug "syncing ntp times #{SelfSDK::Time.now}"
57
57
  env = opts.fetch(:env, "")
58
+ env = "" if env == "production"
58
59
 
59
60
  @client = RestClient.new(base_url(opts), app_id, app_key, env)
60
61
  messaging_url = messaging_url(opts)
data/lib/services/auth.rb CHANGED
@@ -69,7 +69,7 @@ module SelfSDK
69
69
 
70
70
  # Generates a deep link to authenticate with self app.
71
71
  #
72
- # @param callback [String] the url you'll be redirected if the app is not installed.
72
+ # @param callback [String] the callback identifier you'll be redirected to if the app is not installed.
73
73
  # @option opts [String] :selfid the user selfid you want to authenticate.
74
74
  # @option opts [String] :cid The unique identifier of the authentication request.
75
75
  #
data/lib/services/chat.rb CHANGED
@@ -184,13 +184,7 @@ module SelfSDK
184
184
  body = @jwt.encode(body)
185
185
 
186
186
  env = @messaging.client.client.env
187
- if env.empty?
188
- return "https://links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app"
189
- elsif env == 'development'
190
- return "https://links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.dev"
191
- end
192
-
193
- "https://#{env}.links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.#{env}"
187
+ @jwt.build_dynamic_link(body, env, callback)
194
188
  end
195
189
 
196
190
  # Subscribes to a connection response
@@ -84,7 +84,7 @@ module SelfSDK
84
84
  # Generates a deep link to authenticate with self app.
85
85
  #
86
86
  # @param facts [Array] a list of facts to be requested.
87
- # @param callback [String] the url you'll be redirected if the app is not installed.
87
+ # @param callback [String] the callback identifier you'll be redirected to if the app is not installed.
88
88
  # @option opts [String] :selfid the user selfid you want to authenticate.
89
89
  # @option opts [String] :cid The unique identifier of the authentication request.
90
90
  #
@@ -124,7 +124,7 @@ module SelfSDK
124
124
  # Generates a deep link to authenticate with self app.
125
125
  #
126
126
  # @param facts [Array] a list of facts to be requested.
127
- # @param callback [String] the url you'll be redirected if the app is not installed.
127
+ # @param callback [String] the callback identifier you'll be redirected to if the app is not installed.
128
128
  # @option opts [String] :selfid the user selfid you want to authenticate.
129
129
  # @option opts [String] :cid The unique identifier of the authentication request.
130
130
  #
@@ -132,14 +132,9 @@ module SelfSDK
132
132
  def generate_deep_link(facts, callback, opts = {})
133
133
  opts[:request] = false
134
134
  selfid = opts.fetch(:selfid, "-")
135
- body = @client.jwt.encode(request(selfid, facts, opts))
136
135
 
137
- if @client.env.empty?
138
- return "https://links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app"
139
- elsif @client.env == 'development'
140
- return "https://links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.dev"
141
- end
142
- "https://#{@client.env}.links.joinself.com/?link=#{callback}%3Fqr=#{body}&apn=com.joinself.app.#{@client.env}"
136
+ body = @client.jwt.encode(request(selfid, facts, opts))
137
+ @client.jwt.build_dynamic_link(body, @client.env, callback)
143
138
  end
144
139
 
145
140
  private
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.205
4
+ version: 0.0.207
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldgate Ventures