stytch 5.0.2 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,53 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # !!!
4
+ # WARNING: This file is autogenerated
5
+ # Only modify code within MANUAL() sections
6
+ # or your changes may be overwritten later!
7
+ # !!!
8
+
3
9
  require_relative 'request_helper'
4
10
 
5
11
  module Stytch
6
12
  class WebAuthn
7
13
  include Stytch::RequestHelper
8
14
 
9
- PATH = '/v1/webauthn'
10
-
11
15
  def initialize(connection)
12
16
  @connection = connection
13
17
  end
14
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.
20
+ #
21
+ # 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
+ #
23
+ # == Parameters:
24
+ # user_id::
25
+ # The `user_id` of an active user the WebAuthn registration should be tied to.
26
+ # The type of this field is +String+.
27
+ # domain::
28
+ # The domain for WebAuthn. Defaults to `window.location.hostname`.
29
+ # The type of this field is +String+.
30
+ # user_agent::
31
+ # The user agent of the User.
32
+ # The type of this field is nilable +String+.
33
+ # 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.
35
+ # The type of this field is nilable +String+.
36
+ #
37
+ # == Returns:
38
+ # An object with the following fields:
39
+ # request_id::
40
+ # 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.
41
+ # The type of this field is +String+.
42
+ # user_id::
43
+ # The unique ID of the affected User.
44
+ # The type of this field is +String+.
45
+ # public_key_credential_creation_options::
46
+ # Options used for WebAuthn registration.
47
+ # The type of this field is +String+.
48
+ # status_code::
49
+ # 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.
50
+ # The type of this field is +Integer+.
15
51
  def register_start(
16
52
  user_id:,
17
53
  domain:,
@@ -22,13 +58,38 @@ module Stytch
22
58
  user_id: user_id,
23
59
  domain: domain
24
60
  }
25
-
26
61
  request[:user_agent] = user_agent unless user_agent.nil?
27
62
  request[:authenticator_type] = authenticator_type unless authenticator_type.nil?
28
63
 
29
- post_request("#{PATH}/register/start", request)
64
+ post_request('/v1/webauthn/register/start', request)
30
65
  end
31
66
 
67
+ # 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.
68
+ #
69
+ # If the [webauthn-json](https://github.com/github/webauthn-json) library's `create()` method was used, the response can be passed directly to the [register endpoint](https://stytch.com/docs/api/webauthn-register). If not, some fields (the client data and the attestation object) from the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential) response will need to be converted from array buffers to strings and marshalled into JSON.
70
+ #
71
+ # == Parameters:
72
+ # user_id::
73
+ # The `user_id` of an active user the WebAuthn registration should be tied to.
74
+ # The type of this field is +String+.
75
+ # public_key_credential::
76
+ # The response of the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential).
77
+ # The type of this field is +String+.
78
+ #
79
+ # == Returns:
80
+ # An object with the following fields:
81
+ # request_id::
82
+ # 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.
83
+ # The type of this field is +String+.
84
+ # user_id::
85
+ # The unique ID of the affected User.
86
+ # The type of this field is +String+.
87
+ # webauthn_registration_id::
88
+ # The unique ID for the WebAuthn registration.
89
+ # The type of this field is +String+.
90
+ # status_code::
91
+ # 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
+ # The type of this field is +Integer+.
32
93
  def register(
33
94
  user_id:,
34
95
  public_key_credential:
@@ -38,9 +99,35 @@ module Stytch
38
99
  public_key_credential: public_key_credential
39
100
  }
40
101
 
41
- post_request("#{PATH}/register", request)
102
+ post_request('/v1/webauthn/register', request)
42
103
  end
43
104
 
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.
106
+ #
107
+ # 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
+ #
109
+ # == 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
+ # domain::
114
+ # The domain for WebAuthn. Defaults to `window.location.hostname`.
115
+ # The type of this field is +String+.
116
+ #
117
+ # == Returns:
118
+ # An object with the following fields:
119
+ # request_id::
120
+ # 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.
121
+ # The type of this field is +String+.
122
+ # user_id::
123
+ # The unique ID of the affected User.
124
+ # The type of this field is +String+.
125
+ # public_key_credential_request_options::
126
+ # Options used for WebAuthn authentication.
127
+ # The type of this field is +String+.
128
+ # status_code::
129
+ # 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
+ # The type of this field is +Integer+.
44
131
  def authenticate_start(
45
132
  user_id:,
46
133
  domain:
@@ -50,26 +137,85 @@ module Stytch
50
137
  domain: domain
51
138
  }
52
139
 
53
- post_request("#{PATH}/authenticate/start", request)
140
+ post_request('/v1/webauthn/authenticate/start', request)
54
141
  end
55
142
 
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.
144
+ #
145
+ # 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
+ #
147
+ # == Parameters:
148
+ # public_key_credential::
149
+ # The response of the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential).
150
+ # The type of this field is +String+.
151
+ # session_token::
152
+ # The `session_token` associated with a User's existing Session.
153
+ # The type of this field is nilable +String+.
154
+ # session_duration_minutes::
155
+ # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
156
+ # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
157
+ # five minutes regardless of the underlying session duration, and will need to be refreshed over time.
158
+ #
159
+ # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
160
+ #
161
+ # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
162
+ #
163
+ # If the `session_duration_minutes` parameter is not specified, a Stytch session will not be created.
164
+ # The type of this field is nilable +Integer+.
165
+ # session_jwt::
166
+ # The `session_jwt` associated with a User's existing Session.
167
+ # The type of this field is nilable +String+.
168
+ # session_custom_claims::
169
+ # 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.
170
+ #
171
+ # Custom claims made with reserved claims ("iss", "sub", "aud", "exp", "nbf", "iat", "jti") will be ignored. Total custom claims size cannot exceed four kilobytes.
172
+ # The type of this field is nilable +object+.
173
+ #
174
+ # == Returns:
175
+ # An object with the following fields:
176
+ # request_id::
177
+ # 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.
178
+ # The type of this field is +String+.
179
+ # user_id::
180
+ # The unique ID of the affected User.
181
+ # The type of this field is +String+.
182
+ # webauthn_registration_id::
183
+ # The unique ID for the WebAuthn registration.
184
+ # The type of this field is +String+.
185
+ # session_token::
186
+ # A secret token for a given Stytch Session.
187
+ # The type of this field is +String+.
188
+ # session_jwt::
189
+ # The JSON Web Token (JWT) for a given Stytch Session.
190
+ # The type of this field is +String+.
191
+ # user::
192
+ # The `user` object affected by this API call. See the [Get user endpoint](https://stytch.com/docs/api/get-user) for complete response field details.
193
+ # The type of this field is +User+ (+object+).
194
+ # status_code::
195
+ # 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.
196
+ # The type of this field is +Integer+.
197
+ # session::
198
+ # If you initiate a Session, by including `session_duration_minutes` in your authenticate call, you'll receive a full Session object in the response.
199
+ #
200
+ # See [GET sessions](https://stytch.com/docs/api/session-get) for complete response fields.
201
+ #
202
+ # The type of this field is nilable +Session+ (+object+).
56
203
  def authenticate(
57
204
  public_key_credential:,
58
205
  session_token: nil,
59
- session_jwt: nil,
60
206
  session_duration_minutes: nil,
207
+ session_jwt: nil,
61
208
  session_custom_claims: nil
62
209
  )
63
210
  request = {
64
211
  public_key_credential: public_key_credential
65
212
  }
66
-
67
213
  request[:session_token] = session_token unless session_token.nil?
68
- request[:session_jwt] = session_jwt unless session_jwt.nil?
69
214
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
215
+ request[:session_jwt] = session_jwt unless session_jwt.nil?
70
216
  request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
71
217
 
72
- post_request("#{PATH}/authenticate", request)
218
+ post_request('/v1/webauthn/authenticate', request)
73
219
  end
74
220
  end
75
221
  end
data/lib/stytch.rb CHANGED
@@ -8,4 +8,5 @@ require_relative 'stytch/middleware'
8
8
  require_relative 'stytch/version'
9
9
 
10
10
  module Stytch end
11
+
11
12
  module StytchB2B 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: 5.0.2
4
+ version: 6.1.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-06-29 00:00:00.000000000 Z
11
+ date: 2023-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -97,7 +97,9 @@ files:
97
97
  - lib/stytch/b2b_client.rb
98
98
  - lib/stytch/b2b_discovery.rb
99
99
  - lib/stytch/b2b_magic_links.rb
100
+ - lib/stytch/b2b_oauth.rb
100
101
  - lib/stytch/b2b_organizations.rb
102
+ - lib/stytch/b2b_otp.rb
101
103
  - lib/stytch/b2b_passwords.rb
102
104
  - lib/stytch/b2b_sessions.rb
103
105
  - lib/stytch/b2b_sso.rb