trustid_sdk 0.2.0 → 0.2.1
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/README.md +2 -2
- data/lib/trustid_sdk/client.rb +3 -7
- data/lib/trustid_sdk/version.rb +1 -1
- 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: 859be1d591ba0d789cde0a331e0f91d0aa31482cf65b6533485177b831ce57fd
|
|
4
|
+
data.tar.gz: '0987f36c03253670c9d1e71c2197a4cdae34db043888a7d40fe365e849996483'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 63681452a6f1c9aef4a3931b090527cba3445f016d901ef6e4985d1def9c69cadbc274e2601c656b4b5feeaff04ea3c609949cd0459238ca023704b4ca512938
|
|
7
|
+
data.tar.gz: 53306ffe7ae8eb2214c370689754e476e01972e0b4a9c8c827b2092e9c75ffb97b016e553c8025caa8c1c89e2951d8433693e7c4426f56eee00b82b974fc94f1
|
data/README.md
CHANGED
|
@@ -35,9 +35,9 @@ end
|
|
|
35
35
|
|
|
36
36
|
### Device ID
|
|
37
37
|
|
|
38
|
-
`device_id` can be a string or a proc (or any object that responds to `call`). When it is a proc, it is invoked
|
|
38
|
+
`device_id` can be a string or a proc (or any object that responds to `call`). When it is a proc, it is invoked **once when the client is created** (at login), and that value is used for the lifetime of the client. The device ID is then static for all requests made with that client.
|
|
39
39
|
|
|
40
|
-
This is particularly useful for **parallel usage**: if you run multiple clients or workers, each needs a distinct device ID and session. If you reuse the same device ID, the next login for that device invalidates the previous session. Setting `device_id` to a proc that returns a new value per client (e.g. `-> { "prefix-#{SecureRandom.uuid}" }`) ensures each
|
|
40
|
+
This is particularly useful for **parallel usage**: if you run multiple clients or workers, each needs a distinct device ID and session. If you reuse the same device ID, the next login for that device invalidates the previous session. Setting `device_id` to a proc that returns a new value per client (e.g. `-> { "prefix-#{SecureRandom.uuid}" }`) ensures each client gets a unique ID and its own session, while keeping the same device ID for every request within that process.
|
|
41
41
|
|
|
42
42
|
```ruby
|
|
43
43
|
require 'securerandom'
|
data/lib/trustid_sdk/client.rb
CHANGED
|
@@ -2,20 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
module TrustID
|
|
4
4
|
class Client
|
|
5
|
-
attr_reader :server_url
|
|
5
|
+
attr_reader :device_id, :server_url
|
|
6
6
|
attr_accessor :session_id
|
|
7
7
|
|
|
8
8
|
def initialize
|
|
9
9
|
config = TrustID.config
|
|
10
|
-
|
|
10
|
+
raw = config.device_id
|
|
11
|
+
@device_id = raw.respond_to?(:call) ? raw.call : raw
|
|
11
12
|
@server_url = config.server_url
|
|
12
13
|
TrustID.client = self
|
|
13
14
|
Services::Authentication.new(config.username, config.password).login
|
|
14
15
|
end
|
|
15
|
-
|
|
16
|
-
def device_id
|
|
17
|
-
value = @device_id
|
|
18
|
-
value.respond_to?(:call) ? value.call : value
|
|
19
|
-
end
|
|
20
16
|
end
|
|
21
17
|
end
|
data/lib/trustid_sdk/version.rb
CHANGED