stytch 6.4.0 → 9.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,23 +16,31 @@ module Stytch
16
16
  @connection = connection
17
17
  end
18
18
 
19
- # Initiate the process of creating a new WebAuthn registration. 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.
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 value 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+.
40
+ # return_passkey_credential_options::
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
+ #
43
+ # The type of this field is nilable +Boolean+.
36
44
  #
37
45
  # == Returns:
38
46
  # An object with the following fields:
@@ -43,7 +51,7 @@ module Stytch
43
51
  # The unique ID of the affected User.
44
52
  # The type of this field is +String+.
45
53
  # public_key_credential_creation_options::
46
- # Options used for WebAuthn registration.
54
+ # Options used for Passkey or WebAuthn registration.
47
55
  # The type of this field is +String+.
48
56
  # status_code::
49
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.
@@ -52,16 +60,19 @@ module Stytch
52
60
  user_id:,
53
61
  domain:,
54
62
  user_agent: nil,
55
- authenticator_type: nil
63
+ authenticator_type: nil,
64
+ return_passkey_credential_options: nil
56
65
  )
66
+ headers = {}
57
67
  request = {
58
68
  user_id: user_id,
59
69
  domain: domain
60
70
  }
61
71
  request[:user_agent] = user_agent unless user_agent.nil?
62
72
  request[:authenticator_type] = authenticator_type unless authenticator_type.nil?
73
+ request[:return_passkey_credential_options] = return_passkey_credential_options unless return_passkey_credential_options.nil?
63
74
 
64
- post_request('/v1/webauthn/register/start', request)
75
+ post_request('/v1/webauthn/register/start', request, headers)
65
76
  end
66
77
 
67
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.
@@ -70,11 +81,33 @@ module Stytch
70
81
  #
71
82
  # == Parameters:
72
83
  # user_id::
73
- # 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.
74
85
  # The type of this field is +String+.
75
86
  # public_key_credential::
76
87
  # The response of the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential).
77
88
  # The type of this field is +String+.
89
+ # session_token::
90
+ # The `session_token` associated with a User's existing Session.
91
+ # The type of this field is nilable +String+.
92
+ # session_duration_minutes::
93
+ # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
94
+ # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
95
+ # five minutes regardless of the underlying session duration, and will need to be refreshed over time.
96
+ #
97
+ # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
98
+ #
99
+ # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
100
+ #
101
+ # If the `session_duration_minutes` parameter is not specified, a Stytch session will not be created.
102
+ # The type of this field is nilable +Integer+.
103
+ # session_jwt::
104
+ # The `session_jwt` associated with a User's existing Session.
105
+ # The type of this field is nilable +String+.
106
+ # session_custom_claims::
107
+ # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To delete a key, supply a null value.
108
+ #
109
+ # Custom claims made with reserved claims ("iss", "sub", "aud", "exp", "nbf", "iat", "jti") will be ignored. Total custom claims size cannot exceed four kilobytes.
110
+ # The type of this field is nilable +object+.
78
111
  #
79
112
  # == Returns:
80
113
  # An object with the following fields:
@@ -85,34 +118,66 @@ module Stytch
85
118
  # The unique ID of the affected User.
86
119
  # The type of this field is +String+.
87
120
  # webauthn_registration_id::
88
- # The unique ID for the WebAuthn registration.
121
+ # The unique ID for the Passkey or WebAuthn registration.
89
122
  # The type of this field is +String+.
123
+ # session_token::
124
+ # A secret token for a given Stytch Session.
125
+ # The type of this field is +String+.
126
+ # session_jwt::
127
+ # The JSON Web Token (JWT) for a given Stytch Session.
128
+ # The type of this field is +String+.
129
+ # user::
130
+ # (no documentation yet)
131
+ # The type of this field is +User+ (+object+).
90
132
  # status_code::
91
133
  # 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.
92
134
  # The type of this field is +Integer+.
135
+ # session::
136
+ # If you initiate a Session, by including `session_duration_minutes` in your authenticate call, you'll receive a full Session object in the response.
137
+ #
138
+ # See [GET sessions](https://stytch.com/docs/api/session-get) for complete response fields.
139
+ #
140
+ # The type of this field is nilable +Session+ (+object+).
93
141
  def register(
94
142
  user_id:,
95
- public_key_credential:
143
+ public_key_credential:,
144
+ session_token: nil,
145
+ session_duration_minutes: nil,
146
+ session_jwt: nil,
147
+ session_custom_claims: nil
96
148
  )
149
+ headers = {}
97
150
  request = {
98
151
  user_id: user_id,
99
152
  public_key_credential: public_key_credential
100
153
  }
154
+ request[:session_token] = session_token unless session_token.nil?
155
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
156
+ request[:session_jwt] = session_jwt unless session_jwt.nil?
157
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
101
158
 
102
- post_request('/v1/webauthn/register', request)
159
+ post_request('/v1/webauthn/register', request, headers)
103
160
  end
104
161
 
105
- # Initiate the authentication of a WebAuthn registration. 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.
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.
106
167
  #
107
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.
108
169
  #
109
170
  # == Parameters:
110
- # user_id::
111
- # The `user_id` of an active user the WebAuthn registration should be tied to.
112
- # The type of this field is +String+.
113
171
  # domain::
114
- # The domain for WebAuthn. Defaults to `window.location.hostname`.
172
+ # The domain for Passkeys or WebAuthn. Defaults to `window.location.hostname`.
115
173
  # The type of this field is +String+.
174
+ # user_id::
175
+ # The `user_id` of an active user the Passkey or WebAuthn registration should be tied to.
176
+ # The type of this field is nilable +String+.
177
+ # return_passkey_credential_options::
178
+ # If true, the `public_key_credential_creation_options` returned will be optimized for Passkeys with `userVerification` set to `"preferred"`.
179
+ #
180
+ # The type of this field is nilable +Boolean+.
116
181
  #
117
182
  # == Returns:
118
183
  # An object with the following fields:
@@ -123,24 +188,27 @@ module Stytch
123
188
  # The unique ID of the affected User.
124
189
  # The type of this field is +String+.
125
190
  # public_key_credential_request_options::
126
- # Options used for WebAuthn authentication.
191
+ # Options used for Passkey or WebAuthn authentication.
127
192
  # The type of this field is +String+.
128
193
  # status_code::
129
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.
130
195
  # The type of this field is +Integer+.
131
196
  def authenticate_start(
132
- user_id:,
133
- domain:
197
+ domain:,
198
+ user_id: nil,
199
+ return_passkey_credential_options: nil
134
200
  )
201
+ headers = {}
135
202
  request = {
136
- user_id: user_id,
137
203
  domain: domain
138
204
  }
205
+ request[:user_id] = user_id unless user_id.nil?
206
+ request[:return_passkey_credential_options] = return_passkey_credential_options unless return_passkey_credential_options.nil?
139
207
 
140
- post_request('/v1/webauthn/authenticate/start', request)
208
+ post_request('/v1/webauthn/authenticate/start', request, headers)
141
209
  end
142
210
 
143
- # 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.
144
212
  #
145
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.
146
214
  #
@@ -180,7 +248,7 @@ module Stytch
180
248
  # The unique ID of the affected User.
181
249
  # The type of this field is +String+.
182
250
  # webauthn_registration_id::
183
- # The unique ID for the WebAuthn registration.
251
+ # The unique ID for the Passkey or WebAuthn registration.
184
252
  # The type of this field is +String+.
185
253
  # session_token::
186
254
  # A secret token for a given Stytch Session.
@@ -207,6 +275,7 @@ module Stytch
207
275
  session_jwt: nil,
208
276
  session_custom_claims: nil
209
277
  )
278
+ headers = {}
210
279
  request = {
211
280
  public_key_credential: public_key_credential
212
281
  }
@@ -215,7 +284,40 @@ module Stytch
215
284
  request[:session_jwt] = session_jwt unless session_jwt.nil?
216
285
  request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
217
286
 
218
- post_request('/v1/webauthn/authenticate', request)
287
+ post_request('/v1/webauthn/authenticate', request, headers)
288
+ end
289
+
290
+ # Updates a Passkey or WebAuthn registration.
291
+ #
292
+ # == Parameters:
293
+ # webauthn_registration_id::
294
+ # Globally unique UUID that identifies a Passkey or WebAuthn registration in the Stytch API. The `webauthn_registration_id` is used when you need to operate on a specific User's WebAuthn registration.
295
+ # The type of this field is +String+.
296
+ # name::
297
+ # The `name` of the WebAuthn registration or Passkey.
298
+ # The type of this field is +String+.
299
+ #
300
+ # == Returns:
301
+ # An object with the following fields:
302
+ # request_id::
303
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
304
+ # The type of this field is +String+.
305
+ # status_code::
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.
307
+ # The type of this field is +Integer+.
308
+ # webauthn_registration::
309
+ # A Passkey or WebAuthn registration.
310
+ # The type of this field is nilable +WebAuthnRegistration+ (+object+).
311
+ def update(
312
+ webauthn_registration_id:,
313
+ name:
314
+ )
315
+ headers = {}
316
+ request = {
317
+ name: name
318
+ }
319
+
320
+ put_request("/v1/webauthn/#{webauthn_registration_id}", request, headers)
219
321
  end
220
322
  end
221
323
  end
data/lib/stytch.rb CHANGED
@@ -4,6 +4,7 @@ require 'faraday'
4
4
 
5
5
  require_relative 'stytch/b2b_client'
6
6
  require_relative 'stytch/client'
7
+ require_relative 'stytch/method_options'
7
8
  require_relative 'stytch/middleware'
8
9
  require_relative 'stytch/version'
9
10
 
data/stytch.gemspec CHANGED
@@ -30,4 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency 'jwt', '>= 2.3.0'
31
31
 
32
32
  spec.add_development_dependency 'rspec', '~> 3.11.0'
33
+ spec.add_development_dependency 'rubocop', '1.64.1'
34
+ spec.add_development_dependency 'rubocop-rspec', '2.24.0'
33
35
  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: 6.4.0
4
+ version: 9.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - stytch
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-24 00:00:00.000000000 Z
11
+ date: 2024-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -72,7 +72,35 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: 3.11.0
75
- description:
75
+ - !ruby/object:Gem::Dependency
76
+ name: rubocop
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '='
80
+ - !ruby/object:Gem::Version
81
+ version: 1.64.1
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '='
87
+ - !ruby/object:Gem::Version
88
+ version: 1.64.1
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubocop-rspec
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '='
94
+ - !ruby/object:Gem::Version
95
+ version: 2.24.0
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '='
101
+ - !ruby/object:Gem::Version
102
+ version: 2.24.0
103
+ description:
76
104
  email:
77
105
  - support@stytch.com
78
106
  executables: []
@@ -84,6 +112,7 @@ files:
84
112
  - ".github/workflows/ruby.yml"
85
113
  - ".gitignore"
86
114
  - ".rspec"
115
+ - ".rubocop.yml"
87
116
  - ".travis.yml"
88
117
  - CODEOWNERS
89
118
  - CODE_OF_CONDUCT.md
@@ -102,17 +131,24 @@ files:
102
131
  - lib/stytch/b2b_organizations.rb
103
132
  - lib/stytch/b2b_otp.rb
104
133
  - lib/stytch/b2b_passwords.rb
134
+ - lib/stytch/b2b_rbac.rb
135
+ - lib/stytch/b2b_recovery_codes.rb
136
+ - lib/stytch/b2b_scim.rb
105
137
  - lib/stytch/b2b_sessions.rb
106
138
  - lib/stytch/b2b_sso.rb
139
+ - lib/stytch/b2b_totps.rb
107
140
  - lib/stytch/client.rb
108
141
  - lib/stytch/crypto_wallets.rb
109
142
  - lib/stytch/errors.rb
110
143
  - lib/stytch/m2m.rb
111
144
  - lib/stytch/magic_links.rb
145
+ - lib/stytch/method_options.rb
112
146
  - lib/stytch/middleware.rb
113
147
  - lib/stytch/oauth.rb
114
148
  - lib/stytch/otps.rb
115
149
  - lib/stytch/passwords.rb
150
+ - lib/stytch/project.rb
151
+ - lib/stytch/rbac_local.rb
116
152
  - lib/stytch/request_helper.rb
117
153
  - lib/stytch/sessions.rb
118
154
  - lib/stytch/totps.rb
@@ -126,7 +162,7 @@ licenses:
126
162
  metadata:
127
163
  homepage_uri: https://stytch.com
128
164
  source_code_uri: https://github.com/stytchauth/stytch-ruby
129
- post_install_message:
165
+ post_install_message:
130
166
  rdoc_options: []
131
167
  require_paths:
132
168
  - lib
@@ -142,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
178
  version: '0'
143
179
  requirements: []
144
180
  rubygems_version: 3.2.3
145
- signing_key:
181
+ signing_key:
146
182
  specification_version: 4
147
183
  summary: Stytch Ruby Gem
148
184
  test_files: []