stytch 6.6.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/stytch/b2b_client.rb +9 -3
- data/lib/stytch/b2b_discovery.rb +24 -11
- data/lib/stytch/b2b_magic_links.rb +23 -7
- data/lib/stytch/b2b_oauth.rb +12 -2
- data/lib/stytch/b2b_organizations.rb +261 -41
- data/lib/stytch/b2b_otp.rb +4 -2
- data/lib/stytch/b2b_passwords.rb +35 -9
- data/lib/stytch/b2b_rbac.rb +48 -0
- data/lib/stytch/b2b_sessions.rb +106 -38
- data/lib/stytch/b2b_sso.rb +127 -21
- data/lib/stytch/client.rb +2 -2
- data/lib/stytch/crypto_wallets.rb +4 -2
- data/lib/stytch/errors.rb +14 -0
- data/lib/stytch/m2m.rb +16 -9
- data/lib/stytch/magic_links.rb +12 -6
- data/lib/stytch/method_options.rb +22 -0
- data/lib/stytch/oauth.rb +4 -2
- data/lib/stytch/otps.rb +14 -7
- data/lib/stytch/passwords.rb +16 -8
- data/lib/stytch/rbac_local.rb +58 -0
- data/lib/stytch/request_helper.rb +12 -8
- data/lib/stytch/sessions.rb +24 -11
- data/lib/stytch/totps.rb +8 -4
- data/lib/stytch/users.rb +29 -15
- data/lib/stytch/version.rb +1 -1
- data/lib/stytch/webauthn.rb +39 -24
- metadata +5 -2
data/lib/stytch/version.rb
CHANGED
data/lib/stytch/webauthn.rb
CHANGED
@@ -16,25 +16,30 @@ module Stytch
|
|
16
16
|
@connection = connection
|
17
17
|
end
|
18
18
|
|
19
|
-
# Initiate the process of creating a new WebAuthn registration.
|
19
|
+
# Initiate the process of creating a new Passkey or WebAuthn registration.
|
20
|
+
#
|
21
|
+
# To optimize for Passkeys, set the `return_passkey_credential_options` field to `true`.
|
22
|
+
#
|
23
|
+
# After calling this endpoint, the browser will need to call [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential) with the data from [public_key_credential_creation_options](https://w3c.github.io/webauthn/#dictionary-makecredentialoptions) passed to the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential) request via the public key argument. We recommend using the `create()` wrapper provided by the webauthn-json library.
|
20
24
|
#
|
21
25
|
# If you are not using the [webauthn-json](https://github.com/github/webauthn-json) library, the `public_key_credential_creation_options` will need to be converted to a suitable public key by unmarshalling the JSON, base64 decoding the user ID field, and converting user ID and the challenge fields into an array buffer.
|
22
26
|
#
|
23
27
|
# == Parameters:
|
24
28
|
# user_id::
|
25
|
-
# The `user_id` of an active user the WebAuthn registration should be tied to.
|
29
|
+
# The `user_id` of an active user the Passkey or WebAuthn registration should be tied to.
|
26
30
|
# The type of this field is +String+.
|
27
31
|
# domain::
|
28
|
-
# The domain for WebAuthn. Defaults to `window.location.hostname`.
|
32
|
+
# The domain for Passkeys or WebAuthn. Defaults to `window.location.hostname`.
|
29
33
|
# The type of this field is +String+.
|
30
34
|
# user_agent::
|
31
35
|
# The user agent of the User.
|
32
36
|
# The type of this field is nilable +String+.
|
33
37
|
# authenticator_type::
|
34
|
-
# The requested authenticator type of the WebAuthn device. The two valid values are platform and cross-platform. If no value passed, we assume both values are allowed.
|
38
|
+
# The requested authenticator type of the Passkey or WebAuthn device. The two valid values are platform and cross-platform. If no value passed, we assume both values are allowed.
|
35
39
|
# The type of this field is nilable +String+.
|
36
40
|
# return_passkey_credential_options::
|
37
|
-
# If true, the `public_key_credential_creation_options` returned will be optimized for Passkeys
|
41
|
+
# If true, the `public_key_credential_creation_options` returned will be optimized for Passkeys with `residentKey` set to `"required"` and `userVerification` set to `"preferred"`.
|
42
|
+
#
|
38
43
|
# The type of this field is nilable +Boolean+.
|
39
44
|
#
|
40
45
|
# == Returns:
|
@@ -46,7 +51,7 @@ module Stytch
|
|
46
51
|
# The unique ID of the affected User.
|
47
52
|
# The type of this field is +String+.
|
48
53
|
# public_key_credential_creation_options::
|
49
|
-
# Options used for WebAuthn registration.
|
54
|
+
# Options used for Passkey or WebAuthn registration.
|
50
55
|
# The type of this field is +String+.
|
51
56
|
# status_code::
|
52
57
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
@@ -58,6 +63,7 @@ module Stytch
|
|
58
63
|
authenticator_type: nil,
|
59
64
|
return_passkey_credential_options: nil
|
60
65
|
)
|
66
|
+
headers = {}
|
61
67
|
request = {
|
62
68
|
user_id: user_id,
|
63
69
|
domain: domain
|
@@ -66,7 +72,7 @@ module Stytch
|
|
66
72
|
request[:authenticator_type] = authenticator_type unless authenticator_type.nil?
|
67
73
|
request[:return_passkey_credential_options] = return_passkey_credential_options unless return_passkey_credential_options.nil?
|
68
74
|
|
69
|
-
post_request('/v1/webauthn/register/start', request)
|
75
|
+
post_request('/v1/webauthn/register/start', request, headers)
|
70
76
|
end
|
71
77
|
|
72
78
|
# Complete the creation of a WebAuthn registration by passing the response from the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential) request to this endpoint as the `public_key_credential` parameter.
|
@@ -75,7 +81,7 @@ module Stytch
|
|
75
81
|
#
|
76
82
|
# == Parameters:
|
77
83
|
# user_id::
|
78
|
-
# The `user_id` of an active user the WebAuthn registration should be tied to.
|
84
|
+
# The `user_id` of an active user the Passkey or WebAuthn registration should be tied to.
|
79
85
|
# The type of this field is +String+.
|
80
86
|
# public_key_credential::
|
81
87
|
# The response of the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential).
|
@@ -112,7 +118,7 @@ module Stytch
|
|
112
118
|
# The unique ID of the affected User.
|
113
119
|
# The type of this field is +String+.
|
114
120
|
# webauthn_registration_id::
|
115
|
-
# The unique ID for the WebAuthn registration.
|
121
|
+
# The unique ID for the Passkey or WebAuthn registration.
|
116
122
|
# The type of this field is +String+.
|
117
123
|
# session_token::
|
118
124
|
# A secret token for a given Stytch Session.
|
@@ -140,6 +146,7 @@ module Stytch
|
|
140
146
|
session_jwt: nil,
|
141
147
|
session_custom_claims: nil
|
142
148
|
)
|
149
|
+
headers = {}
|
143
150
|
request = {
|
144
151
|
user_id: user_id,
|
145
152
|
public_key_credential: public_key_credential
|
@@ -149,22 +156,27 @@ module Stytch
|
|
149
156
|
request[:session_jwt] = session_jwt unless session_jwt.nil?
|
150
157
|
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
151
158
|
|
152
|
-
post_request('/v1/webauthn/register', request)
|
159
|
+
post_request('/v1/webauthn/register', request, headers)
|
153
160
|
end
|
154
161
|
|
155
|
-
# Initiate the authentication of a WebAuthn registration.
|
162
|
+
# Initiate the authentication of a Passkey or WebAuthn registration.
|
163
|
+
#
|
164
|
+
# To optimize for Passkeys, set the `return_passkey_credential_options` field to `true`.
|
165
|
+
#
|
166
|
+
# After calling this endpoint, the browser will need to call [navigator.credentials.get()](https://www.w3.org/TR/webauthn-2/#sctn-getAssertion) with the data from `public_key_credential_request_options` passed to the [navigator.credentials.get()](https://www.w3.org/TR/webauthn-2/#sctn-getAssertion) request via the public key argument. We recommend using the `get()` wrapper provided by the webauthn-json library.
|
156
167
|
#
|
157
168
|
# If you are not using the [webauthn-json](https://github.com/github/webauthn-json) library, `the public_key_credential_request_options` will need to be converted to a suitable public key by unmarshalling the JSON and converting some the fields to array buffers.
|
158
169
|
#
|
159
170
|
# == Parameters:
|
160
171
|
# domain::
|
161
|
-
# The domain for WebAuthn. Defaults to `window.location.hostname`.
|
172
|
+
# The domain for Passkeys or WebAuthn. Defaults to `window.location.hostname`.
|
162
173
|
# The type of this field is +String+.
|
163
174
|
# user_id::
|
164
|
-
# The `user_id` of an active user the WebAuthn registration should be tied to.
|
175
|
+
# The `user_id` of an active user the Passkey or WebAuthn registration should be tied to.
|
165
176
|
# The type of this field is nilable +String+.
|
166
177
|
# return_passkey_credential_options::
|
167
|
-
# If true, the `public_key_credential_creation_options` returned will be optimized for Passkeys
|
178
|
+
# If true, the `public_key_credential_creation_options` returned will be optimized for Passkeys with `userVerification` set to `"preferred"`.
|
179
|
+
#
|
168
180
|
# The type of this field is nilable +Boolean+.
|
169
181
|
#
|
170
182
|
# == Returns:
|
@@ -176,7 +188,7 @@ module Stytch
|
|
176
188
|
# The unique ID of the affected User.
|
177
189
|
# The type of this field is +String+.
|
178
190
|
# public_key_credential_request_options::
|
179
|
-
# Options used for WebAuthn authentication.
|
191
|
+
# Options used for Passkey or WebAuthn authentication.
|
180
192
|
# The type of this field is +String+.
|
181
193
|
# status_code::
|
182
194
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
@@ -186,16 +198,17 @@ module Stytch
|
|
186
198
|
user_id: nil,
|
187
199
|
return_passkey_credential_options: nil
|
188
200
|
)
|
201
|
+
headers = {}
|
189
202
|
request = {
|
190
203
|
domain: domain
|
191
204
|
}
|
192
205
|
request[:user_id] = user_id unless user_id.nil?
|
193
206
|
request[:return_passkey_credential_options] = return_passkey_credential_options unless return_passkey_credential_options.nil?
|
194
207
|
|
195
|
-
post_request('/v1/webauthn/authenticate/start', request)
|
208
|
+
post_request('/v1/webauthn/authenticate/start', request, headers)
|
196
209
|
end
|
197
210
|
|
198
|
-
# Complete the authentication of a WebAuthn registration by passing the response from the [navigator.credentials.get()](https://www.w3.org/TR/webauthn-2/#sctn-getAssertion) request to the authenticate endpoint.
|
211
|
+
# Complete the authentication of a Passkey or WebAuthn registration by passing the response from the [navigator.credentials.get()](https://www.w3.org/TR/webauthn-2/#sctn-getAssertion) request to the authenticate endpoint.
|
199
212
|
#
|
200
213
|
# If the [webauthn-json](https://github.com/github/webauthn-json) library's `get()` method was used, the response can be passed directly to the [authenticate endpoint](https://stytch.com/docs/api/webauthn-authenticate). If not some fields from the [navigator.credentials.get()](https://www.w3.org/TR/webauthn-2/#sctn-getAssertion) response will need to be converted from array buffers to strings and marshalled into JSON.
|
201
214
|
#
|
@@ -235,7 +248,7 @@ module Stytch
|
|
235
248
|
# The unique ID of the affected User.
|
236
249
|
# The type of this field is +String+.
|
237
250
|
# webauthn_registration_id::
|
238
|
-
# The unique ID for the WebAuthn registration.
|
251
|
+
# The unique ID for the Passkey or WebAuthn registration.
|
239
252
|
# The type of this field is +String+.
|
240
253
|
# session_token::
|
241
254
|
# A secret token for a given Stytch Session.
|
@@ -262,6 +275,7 @@ module Stytch
|
|
262
275
|
session_jwt: nil,
|
263
276
|
session_custom_claims: nil
|
264
277
|
)
|
278
|
+
headers = {}
|
265
279
|
request = {
|
266
280
|
public_key_credential: public_key_credential
|
267
281
|
}
|
@@ -270,17 +284,17 @@ module Stytch
|
|
270
284
|
request[:session_jwt] = session_jwt unless session_jwt.nil?
|
271
285
|
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
272
286
|
|
273
|
-
post_request('/v1/webauthn/authenticate', request)
|
287
|
+
post_request('/v1/webauthn/authenticate', request, headers)
|
274
288
|
end
|
275
289
|
|
276
|
-
# Updates a WebAuthn registration.
|
290
|
+
# Updates a Passkey or WebAuthn registration.
|
277
291
|
#
|
278
292
|
# == Parameters:
|
279
293
|
# webauthn_registration_id::
|
280
|
-
# Globally unique UUID that identifies a WebAuthn registration in the Stytch API. The `webautn_registration_id` is used when you need to operate on a specific User's WebAuthn registartion.
|
294
|
+
# Globally unique UUID that identifies a Passkey or WebAuthn registration in the Stytch API. The `webautn_registration_id` is used when you need to operate on a specific User's WebAuthn registartion.
|
281
295
|
# The type of this field is +String+.
|
282
296
|
# name::
|
283
|
-
# The `name` of the WebAuthn registration.
|
297
|
+
# The `name` of the WebAuthn registration or Passkey.
|
284
298
|
# The type of this field is +String+.
|
285
299
|
#
|
286
300
|
# == Returns:
|
@@ -292,17 +306,18 @@ module Stytch
|
|
292
306
|
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
293
307
|
# The type of this field is +Integer+.
|
294
308
|
# webauthn_registration::
|
295
|
-
# A WebAuthn registration.
|
309
|
+
# A Passkey or WebAuthn registration.
|
296
310
|
# The type of this field is nilable +WebAuthnRegistration+ (+object+).
|
297
311
|
def update(
|
298
312
|
webauthn_registration_id:,
|
299
313
|
name:
|
300
314
|
)
|
315
|
+
headers = {}
|
301
316
|
request = {
|
302
317
|
name: name
|
303
318
|
}
|
304
319
|
|
305
|
-
put_request("/v1/webauthn/#{webauthn_registration_id}", request)
|
320
|
+
put_request("/v1/webauthn/#{webauthn_registration_id}", request, headers)
|
306
321
|
end
|
307
322
|
end
|
308
323
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stytch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- stytch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/stytch/b2b_organizations.rb
|
132
132
|
- lib/stytch/b2b_otp.rb
|
133
133
|
- lib/stytch/b2b_passwords.rb
|
134
|
+
- lib/stytch/b2b_rbac.rb
|
134
135
|
- lib/stytch/b2b_sessions.rb
|
135
136
|
- lib/stytch/b2b_sso.rb
|
136
137
|
- lib/stytch/client.rb
|
@@ -138,10 +139,12 @@ files:
|
|
138
139
|
- lib/stytch/errors.rb
|
139
140
|
- lib/stytch/m2m.rb
|
140
141
|
- lib/stytch/magic_links.rb
|
142
|
+
- lib/stytch/method_options.rb
|
141
143
|
- lib/stytch/middleware.rb
|
142
144
|
- lib/stytch/oauth.rb
|
143
145
|
- lib/stytch/otps.rb
|
144
146
|
- lib/stytch/passwords.rb
|
147
|
+
- lib/stytch/rbac_local.rb
|
145
148
|
- lib/stytch/request_helper.rb
|
146
149
|
- lib/stytch/sessions.rb
|
147
150
|
- lib/stytch/totps.rb
|