statelydb 0.12.0 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14c7769c562abe9ba0294a0d3ec4a1c7a620f9233f35209d39766331f3dd73e5
4
- data.tar.gz: db2562de5584684ef9baf9de405b38112a43eb123aa3826ae4e563c6cfa0c1d0
3
+ metadata.gz: 8446a58ed766b26aeb2effbbbe422d1b809eb9d1833f51c8b0d9309c7787e4a3
4
+ data.tar.gz: 1de0251f91a6bd26399ed57999f09d3f1c27f11faecbc9335216d3c986d58d81
5
5
  SHA512:
6
- metadata.gz: 4ba09f8776771bb4b6fc078e32255a272d986e6983737e1df9fe71bf95e685484ce6d20a91f16c96973bc89f7c9c79d1c0b9411f4a683430581bbc1e27a17468
7
- data.tar.gz: cf612cf68f6c714ba7e79d328ab2b18236c711dbe806a6fb9714dd93eb163ac9899a415bb6c5d4861d24f103bc3844dff40cde27c4eca37eecf1ac3304298f93
6
+ metadata.gz: 7194ac043df22729233b6d76e1517e3a34710d68f9c9d486aa1f849489c9bab435f767a1a805287e7cf85d3324bfedce744339aabdb3c03a6ff6a793aaa36b84
7
+ data.tar.gz: 02c00886f4704f8d0af5f8a7d885a906034238d924ec30c2fb46543bbce1a8bc646e64ceea8803604b0cb41fa87878a186968e901b320e6bfcf455d4ab8a73cd
@@ -23,19 +23,19 @@ module StatelyDB
23
23
  # It will default to using the values of `STATELY_CLIENT_ID` and `STATELY_CLIENT_SECRET` if
24
24
  # no credentials are explicitly passed and will throw an error if none are found.
25
25
  class Auth0TokenProvider < TokenProvider
26
- # @param [Endpoint] domain The domain of the OAuth server
26
+ # @param [String] origin The origin of the OAuth server
27
27
  # @param [String] audience The OAuth Audience for the token
28
28
  # @param [String] client_secret The StatelyDB client secret credential
29
29
  # @param [String] client_id The StatelyDB client ID credential
30
30
  def initialize(
31
- domain: "https://oauth.stately.cloud",
31
+ origin: "https://oauth.stately.cloud",
32
32
  audience: "api.stately.cloud",
33
33
  client_secret: ENV.fetch("STATELY_CLIENT_SECRET"),
34
34
  client_id: ENV.fetch("STATELY_CLIENT_ID")
35
35
  )
36
36
  super()
37
- @actor = Async::Actor.new(Actor.new(domain: domain, audience: audience, client_secret: client_secret,
38
- client_id: client_id))
37
+ @actor = Async::Actor.new(Actor.new(origin: origin, audience: audience,
38
+ client_secret: client_secret, client_id: client_id))
39
39
  # this initialization cannot happen in the constructor because it is async and must run on the event loop
40
40
  # which is not available in the constructor
41
41
  @actor.init
@@ -56,24 +56,24 @@ module StatelyDB
56
56
  # Actor for managing the token refresh
57
57
  # This is designed to be used with Async::Actor and run on a dedicated thread.
58
58
  class Actor
59
- # @param [Endpoint] domain The domain of the OAuth server
59
+ # @param [String] origin The origin of the OAuth server
60
60
  # @param [String] audience The OAuth Audience for the token
61
61
  # @param [String] client_secret The StatelyDB client secret credential
62
62
  # @param [String] client_id The StatelyDB client ID credential
63
63
  def initialize(
64
- domain: "https://oauth.stately.cloud",
65
- audience: "api.stately.cloud",
66
- client_secret: ENV.fetch("STATELY_CLIENT_SECRET"),
67
- client_id: ENV.fetch("STATELY_CLIENT_ID")
64
+ origin:,
65
+ audience:,
66
+ client_secret:,
67
+ client_id:
68
68
  )
69
69
  super()
70
- @client = Async::HTTP::Client.new(Async::HTTP::Endpoint.parse(domain))
70
+ @client = Async::HTTP::Client.new(Async::HTTP::Endpoint.parse(origin))
71
71
  @client_id = client_id
72
72
  @client_secret = client_secret
73
73
  @audience = audience
74
74
 
75
75
  @access_token = nil
76
- @expires_at_secs = nil
76
+ @expires_at_unix_secs = nil
77
77
  @pending_refresh = nil
78
78
  end
79
79
 
@@ -95,7 +95,7 @@ module StatelyDB
95
95
  def get_token(force: false)
96
96
  if force
97
97
  @access_token = nil
98
- @expires_at_secs = nil
98
+ @expires_at_unix_secs = nil
99
99
  else
100
100
  token, ok = valid_access_token
101
101
  return token if ok
@@ -108,8 +108,8 @@ module StatelyDB
108
108
  # @return [Array] The current access token and whether it is valid
109
109
  def valid_access_token
110
110
  return "", false if @access_token.nil?
111
- return "", false if @expires_at_secs.nil?
112
- return "", false if @expires_at_secs < Time.now.to_i
111
+ return "", false if @expires_at_unix_secs.nil?
112
+ return "", false if @expires_at_unix_secs < Time.now.to_i
113
113
 
114
114
  [@access_token, true]
115
115
  end
@@ -155,15 +155,15 @@ module StatelyDB
155
155
 
156
156
  new_access_token = resp_data["access_token"]
157
157
  new_expires_in_secs = resp_data["expires_in"]
158
- new_expires_at_secs = Time.now.to_i + new_expires_in_secs
159
- if @expires_at_secs.nil? || new_expires_at_secs > @expires_at_secs
158
+ new_expires_at_unix_secs = Time.now.to_i + new_expires_in_secs
159
+ if @expires_at_unix_secs.nil? || new_expires_at_unix_secs > @expires_at_unix_secs
160
160
 
161
161
  @access_token = new_access_token
162
- @expires_at_secs = new_expires_at_secs
162
+ @expires_at_unix_secs = new_expires_at_unix_secs
163
163
  else
164
164
 
165
165
  new_access_token = @access_token
166
- new_expires_in_secs = @expires_at_secs - Time.now.to_i
166
+ new_expires_in_secs = @expires_at_unix_secs - Time.now.to_i
167
167
  end
168
168
 
169
169
  # Schedule a refresh of the token ahead of the expiry time
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statelydb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stately Cloud, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-04 00:00:00.000000000 Z
11
+ date: 2024-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async