authsignal-ruby 5.2.2 → 5.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 +4 -4
- data/.rubocop.yml +4 -1
- data/.ruby-version +1 -0
- data/Gemfile.lock +1 -1
- data/lib/authsignal/client.rb +142 -0
- data/lib/authsignal/version.rb +1 -1
- data/lib/authsignal.rb +66 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bf8ccfc3244f86d9e99c7c481d5c23fb9f341aad018e371522f3755908e9bc9d
|
|
4
|
+
data.tar.gz: c6b7cc9b3c50fcc043ffdd73cbd14dd7114fa8b7977f654f1ade619444061b9d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c83bb4ab1de9b24b12820ebe82328741150e7f3821e954588f79df4b8e8b2d4ccfc3b259c36a0b86d23424940e0dda04107b8dfd33bb0e2fee9514bed41a3f2a
|
|
7
|
+
data.tar.gz: 97b80dcf590ec5f8f0ffa196e908669dcfdefaf5ea90a8228e2378add33d522a565488373c8ac8884936f3119c91965c48ea2aa7df5d1f003aa309694399d846
|
data/.rubocop.yml
CHANGED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.6.10
|
data/Gemfile.lock
CHANGED
data/lib/authsignal/client.rb
CHANGED
|
@@ -52,6 +52,27 @@ module Authsignal
|
|
|
52
52
|
make_request(:delete, "users/#{url_encode(user_id)}")
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
def query_users(
|
|
56
|
+
username: nil,
|
|
57
|
+
email: nil,
|
|
58
|
+
phone_number: nil,
|
|
59
|
+
token: nil,
|
|
60
|
+
limit: nil,
|
|
61
|
+
last_evaluated_user_id: nil
|
|
62
|
+
)
|
|
63
|
+
params = {
|
|
64
|
+
username: username,
|
|
65
|
+
email: email,
|
|
66
|
+
phoneNumber: phone_number,
|
|
67
|
+
token: token,
|
|
68
|
+
limit: limit&.to_s,
|
|
69
|
+
lastEvaluatedUserId: last_evaluated_user_id
|
|
70
|
+
}.compact
|
|
71
|
+
|
|
72
|
+
path = params.empty? ? 'users' : "users?#{URI.encode_www_form(params)}"
|
|
73
|
+
make_request(:get, path)
|
|
74
|
+
end
|
|
75
|
+
|
|
55
76
|
def get_authenticators(user_id:)
|
|
56
77
|
make_request(:get, "users/#{url_encode(user_id)}/authenticators")
|
|
57
78
|
end
|
|
@@ -81,10 +102,131 @@ module Authsignal
|
|
|
81
102
|
make_request(:get, "users/#{url_encode(user_id)}/actions/#{action}/#{url_encode(idempotency_key)}")
|
|
82
103
|
end
|
|
83
104
|
|
|
105
|
+
def query_user_actions(
|
|
106
|
+
user_id:,
|
|
107
|
+
from_date: nil,
|
|
108
|
+
action_codes: [],
|
|
109
|
+
state: nil
|
|
110
|
+
)
|
|
111
|
+
params = {
|
|
112
|
+
fromDate: from_date,
|
|
113
|
+
codes: action_codes.empty? ? nil : action_codes.join(','),
|
|
114
|
+
state: state
|
|
115
|
+
}.compact
|
|
116
|
+
|
|
117
|
+
base_path = "users/#{url_encode(user_id)}/actions"
|
|
118
|
+
path = params.empty? ? base_path : "#{base_path}?#{URI.encode_www_form(params)}"
|
|
119
|
+
make_request(:get, path)
|
|
120
|
+
end
|
|
121
|
+
|
|
84
122
|
def update_action(user_id:, action:, idempotency_key:, attributes:)
|
|
85
123
|
make_request(:patch, "users/#{url_encode(user_id)}/actions/#{action}/#{url_encode(idempotency_key)}", body: attributes)
|
|
86
124
|
end
|
|
87
125
|
|
|
126
|
+
def challenge(
|
|
127
|
+
verification_method:,
|
|
128
|
+
action:,
|
|
129
|
+
idempotency_key: nil,
|
|
130
|
+
user_id: nil,
|
|
131
|
+
email: nil,
|
|
132
|
+
phone_number: nil,
|
|
133
|
+
sms_channel: nil,
|
|
134
|
+
locale: nil,
|
|
135
|
+
device_id: nil,
|
|
136
|
+
ip_address: nil,
|
|
137
|
+
user_agent: nil,
|
|
138
|
+
custom: nil,
|
|
139
|
+
scope: nil
|
|
140
|
+
)
|
|
141
|
+
body = {
|
|
142
|
+
verification_method: verification_method,
|
|
143
|
+
action: action,
|
|
144
|
+
idempotency_key: idempotency_key,
|
|
145
|
+
user_id: user_id,
|
|
146
|
+
email: email,
|
|
147
|
+
phone_number: phone_number,
|
|
148
|
+
sms_channel: sms_channel,
|
|
149
|
+
locale: locale,
|
|
150
|
+
device_id: device_id,
|
|
151
|
+
ip_address: ip_address,
|
|
152
|
+
user_agent: user_agent,
|
|
153
|
+
custom: custom,
|
|
154
|
+
scope: scope
|
|
155
|
+
}
|
|
156
|
+
make_request(:post, 'challenge', body: body)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def verify(challenge_id:, verification_code:)
|
|
160
|
+
body = {
|
|
161
|
+
challenge_id: challenge_id,
|
|
162
|
+
verification_code: verification_code
|
|
163
|
+
}
|
|
164
|
+
make_request(:post, 'verify', body: body)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def claim_challenge(
|
|
168
|
+
challenge_id:,
|
|
169
|
+
user_id:,
|
|
170
|
+
skip_verification_check: nil
|
|
171
|
+
)
|
|
172
|
+
body = {
|
|
173
|
+
challenge_id: challenge_id,
|
|
174
|
+
user_id: user_id,
|
|
175
|
+
skip_verification_check: skip_verification_check
|
|
176
|
+
}
|
|
177
|
+
make_request(:post, 'claim', body: body)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def get_challenge(
|
|
181
|
+
challenge_id: nil,
|
|
182
|
+
user_id: nil,
|
|
183
|
+
action: nil,
|
|
184
|
+
verification_method: nil
|
|
185
|
+
)
|
|
186
|
+
params = {}
|
|
187
|
+
params[:challengeId] = challenge_id if challenge_id
|
|
188
|
+
params[:userId] = user_id if user_id
|
|
189
|
+
params[:action] = action if action
|
|
190
|
+
params[:verificationMethod] = verification_method if verification_method
|
|
191
|
+
|
|
192
|
+
query_string = URI.encode_www_form(params) unless params.empty?
|
|
193
|
+
path = query_string ? "challenges?#{query_string}" : 'challenges'
|
|
194
|
+
|
|
195
|
+
make_request(:get, path)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def create_session(client_id:, token:, action: nil)
|
|
199
|
+
body = {
|
|
200
|
+
client_id: client_id,
|
|
201
|
+
token: token,
|
|
202
|
+
action: action
|
|
203
|
+
}.compact
|
|
204
|
+
make_request(:post, 'sessions', body: body)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def validate_session(access_token:, client_ids: nil)
|
|
208
|
+
body = {
|
|
209
|
+
access_token: access_token,
|
|
210
|
+
client_ids: client_ids
|
|
211
|
+
}.compact
|
|
212
|
+
make_request(:post, 'sessions/validate', body: body)
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def refresh_session(refresh_token:)
|
|
216
|
+
body = { refresh_token: refresh_token }
|
|
217
|
+
make_request(:post, 'sessions/refresh', body: body)
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def revoke_session(access_token:)
|
|
221
|
+
body = { access_token: access_token }
|
|
222
|
+
make_request(:post, 'sessions/revoke', body: body)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def revoke_user_sessions(user_id:)
|
|
226
|
+
body = { user_id: user_id }
|
|
227
|
+
make_request(:post, 'sessions/user/revoke', body: body)
|
|
228
|
+
end
|
|
229
|
+
|
|
88
230
|
##
|
|
89
231
|
# TODO: delete identify?
|
|
90
232
|
def identify(user_id, user_payload)
|
data/lib/authsignal/version.rb
CHANGED
data/lib/authsignal.rb
CHANGED
|
@@ -39,6 +39,12 @@ module Authsignal
|
|
|
39
39
|
handle_response(response)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
def query_users(**options)
|
|
43
|
+
response = Client.new.query_users(**options)
|
|
44
|
+
|
|
45
|
+
handle_response(response)
|
|
46
|
+
end
|
|
47
|
+
|
|
42
48
|
def update_user(user_id:, attributes:)
|
|
43
49
|
response = Client.new.update_user(user_id: user_id, attributes: attributes)
|
|
44
50
|
|
|
@@ -86,12 +92,72 @@ module Authsignal
|
|
|
86
92
|
handle_response(response)
|
|
87
93
|
end
|
|
88
94
|
|
|
95
|
+
def query_user_actions(user_id:, **options)
|
|
96
|
+
response = Client.new.query_user_actions(user_id: user_id, **options)
|
|
97
|
+
|
|
98
|
+
handle_response(response)
|
|
99
|
+
end
|
|
100
|
+
|
|
89
101
|
def update_action(user_id:, action:, idempotency_key:, attributes:)
|
|
90
102
|
response = Client.new.update_action(user_id: user_id, action: action, idempotency_key: idempotency_key, attributes: attributes)
|
|
91
103
|
|
|
92
104
|
handle_response(response)
|
|
93
105
|
end
|
|
94
106
|
|
|
107
|
+
def challenge(verification_method:, action:, **options)
|
|
108
|
+
response = Client.new.challenge(verification_method: verification_method, action: action, **options)
|
|
109
|
+
|
|
110
|
+
handle_response(response)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def verify(challenge_id:, verification_code:)
|
|
114
|
+
response = Client.new.verify(challenge_id: challenge_id, verification_code: verification_code)
|
|
115
|
+
|
|
116
|
+
handle_response(response)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def claim_challenge(challenge_id:, user_id:, **options)
|
|
120
|
+
response = Client.new.claim_challenge(challenge_id: challenge_id, user_id: user_id, **options)
|
|
121
|
+
|
|
122
|
+
handle_response(response)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def get_challenge(**options)
|
|
126
|
+
response = Client.new.get_challenge(**options)
|
|
127
|
+
|
|
128
|
+
handle_response(response)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def create_session(client_id:, token:, action: nil)
|
|
132
|
+
response = Client.new.create_session(client_id: client_id, token: token, action: action)
|
|
133
|
+
|
|
134
|
+
handle_response(response)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def validate_session(access_token:, client_ids: nil)
|
|
138
|
+
response = Client.new.validate_session(access_token: access_token, client_ids: client_ids)
|
|
139
|
+
|
|
140
|
+
handle_response(response)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def refresh_session(refresh_token:)
|
|
144
|
+
response = Client.new.refresh_session(refresh_token: refresh_token)
|
|
145
|
+
|
|
146
|
+
handle_response(response)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def revoke_session(access_token:)
|
|
150
|
+
response = Client.new.revoke_session(access_token: access_token)
|
|
151
|
+
|
|
152
|
+
handle_response(response)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def revoke_user_sessions(user_id:)
|
|
156
|
+
response = Client.new.revoke_user_sessions(user_id: user_id)
|
|
157
|
+
|
|
158
|
+
handle_response(response)
|
|
159
|
+
end
|
|
160
|
+
|
|
95
161
|
private
|
|
96
162
|
|
|
97
163
|
def handle_response(response)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: authsignal-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- justinsoong
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-01-
|
|
11
|
+
date: 2026-01-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -105,6 +105,7 @@ files:
|
|
|
105
105
|
- ".editorconfig"
|
|
106
106
|
- ".rspec"
|
|
107
107
|
- ".rubocop.yml"
|
|
108
|
+
- ".ruby-version"
|
|
108
109
|
- ".tool-versions"
|
|
109
110
|
- CHANGELOG.md
|
|
110
111
|
- Gemfile
|