selfsdk 0.0.190 → 0.0.193

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: d16f8c244c41090b46bc5e5be876eba62f19372fdfb22cb361f72d88b996d23f
4
- data.tar.gz: a1f36f9f44ac9728e4ae4c8aaf0320a20e6c5d85596543bdd4726236736b8d29
3
+ metadata.gz: ce09c8f8b8cb4daafea4f4d94f2d1110fd376e8811a9e30f2703a8add593d5ab
4
+ data.tar.gz: 44d649bce5e7f0d0789954fdde6bbc47896b474a95af8eb536913f1bf5ef8712
5
5
  SHA512:
6
- metadata.gz: 7847fc87f5cb7af079ad0c38f8ce674d9aaeb0742303636aa41d8ffe86323a3f9ed7279c006b0376919cbae142c9fd9e362b0c571ed687047b1d42aae8308995
7
- data.tar.gz: 9d6e5afdb845e57d02ce888b2e6e7e986118bf9b507313d1f19eea5abd80fe68c5585c6f93124626df5a3ba5b329ae7ead891f06e2dde2737e9e2b8617cbf02b
6
+ metadata.gz: 26aad938c2d5c2e0cc2328eb9639f2e15b46805de03f97456cead55d005a21942f13078db7ce75ad6507d134777040e1698a17cab8c9caf075d52407f48222b3
7
+ data.tar.gz: 39ebfd842ec43b0b425b843dc9cfbf557dff14d5aa411ebd0fb8645ab7f09e81fcb5d71dd134154d9b0d80c6b891416309adf4d2ef285f8f9203cbbd80c834dc
@@ -6,14 +6,14 @@ require 'open-uri'
6
6
  module SelfSDK
7
7
  module Chat
8
8
  class FileObject
9
- attr_accessor :link, :mime, :content, :key, :nonce, :ciphertext
9
+ attr_accessor :name, :link, :mime, :content, :key, :nonce, :ciphertext
10
10
 
11
11
  def initialize(token, url)
12
12
  @token = token
13
13
  @url = url
14
14
  end
15
15
 
16
- def build_from_data(name, data, mime)
16
+ def build_from_data(name, data, mime, opts = {})
17
17
  @key = SelfCrypto::Util.aead_xchacha20poly1305_ietf_keygen
18
18
  @nonce = SelfCrypto::Util.aead_xchacha20poly1305_ietf_nonce
19
19
  @content = data
@@ -25,7 +25,8 @@ module SelfSDK
25
25
 
26
26
  # Upload
27
27
  remote_object = upload(ciphertext)
28
- @link = "#{@url}/v1/objects/#{remote_object["id"]}"
28
+ public_url = opts[:public_url] || @url
29
+ @link = "#{public_url}/v1/objects/#{remote_object["id"]}"
29
30
  @expires = remote_object["expires"]
30
31
 
31
32
  self
@@ -34,7 +35,20 @@ module SelfSDK
34
35
  # Incoming objects
35
36
  def build_from_object(input)
36
37
  # Download from CDN
37
- ciphertext = URI.open(input[:link], "Authorization" => "Bearer #{@token}").read
38
+ ciphertext = ""
39
+ 5.times do
40
+ begin
41
+ ciphertext = URI.open(input[:link], "Authorization" => "Bearer #{@token}").read
42
+ break
43
+ rescue
44
+ sleep 1
45
+ end
46
+ end
47
+
48
+ if ciphertext.empty?
49
+ SelfSDK.logger.warn "unable to process incoming object"
50
+ return
51
+ end
38
52
 
39
53
  @content = ciphertext
40
54
  @key = nil
data/lib/crypto.rb CHANGED
@@ -151,7 +151,7 @@ module SelfSDK
151
151
  # if there is no session, create one
152
152
  # if there is an existing session and we are sent a one time key message, check
153
153
  # if it belongs to this current session and create a new inbound session if it doesn't
154
- if session_with_bob.nil? || m.instance_of?(SelfCrypto::PreKeyMessage) and !session_with_bob.will_receive?(m)
154
+ if session_with_bob.nil? || m.instance_of?(SelfCrypto::PreKeyMessage) && !session_with_bob.will_receive?(m)
155
155
  # 7b-ii) use the initial message to create a session for bob or carol
156
156
  session_with_bob = @account.inbound_session(m)
157
157
 
data/lib/services/docs.rb CHANGED
@@ -28,7 +28,7 @@ module SelfSDK
28
28
  # @param objects [Array] array of objects to be signed. provide an empty array if
29
29
  # you just want the body to be signed.
30
30
  # @yield [request] Invokes the given block when a response is received.
31
- def request_signature(recipient, body, objects, &block)
31
+ def request_signature(recipient, body, objects, opts = {}, &block)
32
32
  jti = SecureRandom.uuid
33
33
  req = {
34
34
  jti: jti,
@@ -43,7 +43,8 @@ module SelfSDK
43
43
  req[:objects] << SelfSDK::Chat::FileObject.new(auth_token, @self_url).build_from_data(
44
44
  o[:name],
45
45
  o[:data],
46
- o[:mime]
46
+ o[:mime],
47
+ opts
47
48
  ).to_payload
48
49
  end
49
50
 
@@ -62,6 +62,10 @@ module SelfSDK
62
62
  return req.send_message
63
63
  end
64
64
 
65
+ if opts[:async] == true
66
+ return req.send_message
67
+ end
68
+
65
69
  # Otherwise the request is synchronous
66
70
  req.request
67
71
  end
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.190
4
+ version: 0.0.193
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldgate Ventures