trustid_sdk 0.2.1 → 0.3.0

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: 859be1d591ba0d789cde0a331e0f91d0aa31482cf65b6533485177b831ce57fd
4
- data.tar.gz: '0987f36c03253670c9d1e71c2197a4cdae34db043888a7d40fe365e849996483'
3
+ metadata.gz: 1784174ed6fda6a0941467202249c83025bb1f33b1eb1da298f310987c21b3ea
4
+ data.tar.gz: bcbfaec98385fba2cac95392d1f8c1df26e92de4fac3e41d52bc6434ab8de037
5
5
  SHA512:
6
- metadata.gz: 63681452a6f1c9aef4a3931b090527cba3445f016d901ef6e4985d1def9c69cadbc274e2601c656b4b5feeaff04ea3c609949cd0459238ca023704b4ca512938
7
- data.tar.gz: 53306ffe7ae8eb2214c370689754e476e01972e0b4a9c8c827b2092e9c75ffb97b016e553c8025caa8c1c89e2951d8433693e7c4426f56eee00b82b974fc94f1
6
+ metadata.gz: 65d30c498e8f91a5a98fdee954360d23ff5d30344cef36e22483e454e8b5be7ee7e073be74cd3a6ea638e8744934a0353d7aab68431ce9ece28c5c3990e89e99
7
+ data.tar.gz: 22395cea2bbb3864c402979af7bc33d80fdaf05845c8f7e193ad59417a0d71eee61abc6a67fa816aad32b37112d589eb9b2d0046dc73b7ae4f151c0981d52a18
data/README.md CHANGED
@@ -39,6 +39,8 @@ end
39
39
 
40
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
+ The SDK stores the current `TrustID::Client` on **`TrustID.client`**, which is **thread-local**. Each Ruby thread has its own client slot, so multi-threaded servers can run separate TrustID sessions in parallel without cross-thread session mix-ups.
43
+
42
44
  ```ruby
43
45
  require 'securerandom'
44
46
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TrustID
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
data/lib/trustid_sdk.rb CHANGED
@@ -17,7 +17,19 @@ Dir[File.join(__dir__, 'trustid_sdk/models/**/*.rb')].each { |f| require_relativ
17
17
  Dir[File.join(__dir__, 'trustid_sdk/services/**/*.rb')].each { |f| require_relative f.sub("#{__dir__}/", '') }
18
18
 
19
19
  module TrustID
20
+ # Isolates the active client per Ruby thread so concurrent TrustID::Client instances
21
+ # (e.g. Puma / Sidekiq threads) do not overwrite each other's session and device pair.
22
+ CLIENT_THREAD_KEY = :trustid_sdk_client
23
+
20
24
  class << self
21
- attr_accessor :client, :debug_mode
25
+ attr_accessor :debug_mode
26
+
27
+ def client
28
+ Thread.current[CLIENT_THREAD_KEY]
29
+ end
30
+
31
+ def client=(instance)
32
+ Thread.current[CLIENT_THREAD_KEY] = instance
33
+ end
22
34
  end
23
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trustid_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomislav Simnett