passageidentity 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +18 -61
  4. data/docs/custom/AuthApi.md +141 -0
  5. data/docs/custom/ClientApi.md +107 -0
  6. data/docs/custom/UserApi.md +419 -0
  7. data/docs/generated/AppInfo.md +94 -0
  8. data/docs/generated/AppResponse.md +18 -0
  9. data/docs/generated/AppsApi.md +77 -0
  10. data/docs/generated/AuthMethods.md +22 -0
  11. data/docs/generated/CreateMagicLinkRequest.md +36 -0
  12. data/docs/generated/CreateUserRequest.md +22 -0
  13. data/docs/generated/ElementCustomization.md +56 -0
  14. data/docs/generated/FontFamily.md +15 -0
  15. data/docs/generated/LayoutConfig.md +26 -0
  16. data/docs/generated/Layouts.md +20 -0
  17. data/docs/generated/ListDevicesResponse.md +18 -0
  18. data/docs/generated/MagicLink.md +36 -0
  19. data/docs/generated/MagicLinkAuthMethod.md +22 -0
  20. data/docs/generated/MagicLinkChannel.md +15 -0
  21. data/docs/generated/MagicLinkResponse.md +18 -0
  22. data/docs/generated/MagicLinkType.md +15 -0
  23. data/docs/generated/MagicLinksApi.md +79 -0
  24. data/docs/generated/Model400Error.md +20 -0
  25. data/docs/generated/Model401Error.md +20 -0
  26. data/docs/generated/Model404Error.md +20 -0
  27. data/docs/generated/Model500Error.md +20 -0
  28. data/docs/generated/OtpAuthMethod.md +22 -0
  29. data/docs/generated/PasskeysAuthMethod.md +18 -0
  30. data/docs/generated/Technologies.md +15 -0
  31. data/docs/generated/TokensApi.md +78 -0
  32. data/docs/generated/TtlDisplayUnit.md +15 -0
  33. data/docs/generated/UpdateMagicLinkAuthMethod.md +22 -0
  34. data/docs/generated/UpdateOtpAuthMethod.md +22 -0
  35. data/docs/generated/UpdatePasskeysAuthMethod.md +18 -0
  36. data/docs/generated/UpdateUserRequest.md +22 -0
  37. data/docs/generated/UserDevicesApi.md +152 -0
  38. data/docs/generated/UserEventInfo.md +26 -0
  39. data/docs/generated/UserInfo.md +46 -0
  40. data/docs/generated/UserMetadataField.md +28 -0
  41. data/docs/generated/UserMetadataFieldType.md +15 -0
  42. data/docs/generated/UserResponse.md +18 -0
  43. data/docs/generated/UserStatus.md +15 -0
  44. data/docs/generated/UsersApi.md +440 -0
  45. data/docs/generated/WebAuthnDevices.md +34 -0
  46. data/docs/generated/WebAuthnIcons.md +20 -0
  47. data/docs/generated/WebAuthnType.md +15 -0
  48. data/generate.sh +31 -0
  49. data/lib/openapi_client/api/apps_api.rb +85 -0
  50. data/lib/openapi_client/api/magic_links_api.rb +96 -0
  51. data/lib/openapi_client/api/tokens_api.rb +91 -0
  52. data/lib/openapi_client/api/user_devices_api.rb +166 -0
  53. data/lib/openapi_client/api/users_api.rb +452 -0
  54. data/lib/openapi_client/api_client.rb +431 -0
  55. data/lib/openapi_client/api_error.rb +58 -0
  56. data/lib/openapi_client/configuration.rb +383 -0
  57. data/lib/openapi_client/models/app_info.rb +853 -0
  58. data/lib/openapi_client/models/app_response.rb +221 -0
  59. data/lib/openapi_client/models/auth_methods.rb +254 -0
  60. data/lib/openapi_client/models/create_magic_link_request.rb +374 -0
  61. data/lib/openapi_client/models/create_user_request.rb +234 -0
  62. data/lib/openapi_client/models/element_customization.rb +457 -0
  63. data/lib/openapi_client/models/font_family.rb +58 -0
  64. data/lib/openapi_client/models/layout_config.rb +285 -0
  65. data/lib/openapi_client/models/layouts.rb +241 -0
  66. data/lib/openapi_client/models/list_devices_response.rb +223 -0
  67. data/lib/openapi_client/models/magic_link.rb +387 -0
  68. data/lib/openapi_client/models/magic_link_auth_method.rb +302 -0
  69. data/lib/openapi_client/models/magic_link_channel.rb +40 -0
  70. data/lib/openapi_client/models/magic_link_response.rb +221 -0
  71. data/lib/openapi_client/models/magic_link_type.rb +40 -0
  72. data/lib/openapi_client/models/model400_error.rb +271 -0
  73. data/lib/openapi_client/models/model401_error.rb +271 -0
  74. data/lib/openapi_client/models/model404_error.rb +271 -0
  75. data/lib/openapi_client/models/model500_error.rb +271 -0
  76. data/lib/openapi_client/models/otp_auth_method.rb +302 -0
  77. data/lib/openapi_client/models/passkeys_auth_method.rb +228 -0
  78. data/lib/openapi_client/models/technologies.rb +46 -0
  79. data/lib/openapi_client/models/ttl_display_unit.rb +42 -0
  80. data/lib/openapi_client/models/update_magic_link_auth_method.rb +276 -0
  81. data/lib/openapi_client/models/update_otp_auth_method.rb +276 -0
  82. data/lib/openapi_client/models/update_passkeys_auth_method.rb +216 -0
  83. data/lib/openapi_client/models/update_user_request.rb +232 -0
  84. data/lib/openapi_client/models/user_event_info.rb +285 -0
  85. data/lib/openapi_client/models/user_info.rb +470 -0
  86. data/lib/openapi_client/models/user_metadata_field.rb +323 -0
  87. data/lib/openapi_client/models/user_metadata_field_type.rb +44 -0
  88. data/lib/openapi_client/models/user_response.rb +221 -0
  89. data/lib/openapi_client/models/user_status.rb +41 -0
  90. data/lib/openapi_client/models/web_authn_devices.rb +378 -0
  91. data/lib/openapi_client/models/web_authn_icons.rb +230 -0
  92. data/lib/openapi_client/models/web_authn_type.rb +41 -0
  93. data/lib/openapi_client/version.rb +15 -0
  94. data/lib/openapi_client.rb +74 -0
  95. data/lib/passageidentity/auth.rb +32 -5
  96. data/lib/passageidentity/client.rb +17 -121
  97. data/lib/passageidentity/user_api.rb +29 -131
  98. data/lib/passageidentity/version.rb +5 -0
  99. data/openapitools.json +7 -0
  100. data/passageidentity.gemspec +3 -1
  101. data/tests/auth_test.rb +6 -1
  102. data/tests/magic_link_test.rb +5 -4
  103. data/tests/user_api_test.rb +2 -2
  104. metadata +96 -2
@@ -0,0 +1,383 @@
1
+ =begin
2
+ #Passage Management API
3
+
4
+ #Passage's management API to manage your Passage apps and users.
5
+
6
+ The version of the OpenAPI document: 1
7
+ Contact: support@passage.id
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.1.0
10
+
11
+ =end
12
+
13
+ module OpenapiClient
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
36
+ # Defines API keys used with API Key authentications.
37
+ #
38
+ # @return [Hash] key: parameter name, value: parameter value (API key)
39
+ #
40
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
41
+ # config.api_key['api_key'] = 'xxx'
42
+ attr_accessor :api_key
43
+
44
+ # Defines API key prefixes used with API Key authentications.
45
+ #
46
+ # @return [Hash] key: parameter name, value: API key prefix
47
+ #
48
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
49
+ # config.api_key_prefix['api_key'] = 'Token'
50
+ attr_accessor :api_key_prefix
51
+
52
+ # Defines the username used with HTTP basic authentication.
53
+ #
54
+ # @return [String]
55
+ attr_accessor :username
56
+
57
+ # Defines the password used with HTTP basic authentication.
58
+ #
59
+ # @return [String]
60
+ attr_accessor :password
61
+
62
+ # Defines the access token (Bearer) used with OAuth2.
63
+ attr_accessor :access_token
64
+
65
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
66
+ # Overrides the access_token if set
67
+ # @return [Proc]
68
+ attr_accessor :access_token_getter
69
+
70
+ # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
71
+ # HTTP responses with return type `File` will be returned as a stream of binary data.
72
+ # Default to false.
73
+ attr_accessor :return_binary_data
74
+
75
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
76
+ # details will be logged with `logger.debug` (see the `logger` attribute).
77
+ # Default to false.
78
+ #
79
+ # @return [true, false]
80
+ attr_accessor :debugging
81
+
82
+ # Defines the logger used for debugging.
83
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
84
+ #
85
+ # @return [#debug]
86
+ attr_accessor :logger
87
+
88
+ # Defines the temporary folder to store downloaded files
89
+ # (for API endpoints that have file response).
90
+ # Default to use `Tempfile`.
91
+ #
92
+ # @return [String]
93
+ attr_accessor :temp_folder_path
94
+
95
+ # The time limit for HTTP request in seconds.
96
+ # Default to 0 (never times out).
97
+ attr_accessor :timeout
98
+
99
+ # Set this to false to skip client side validation in the operation.
100
+ # Default to true.
101
+ # @return [true, false]
102
+ attr_accessor :client_side_validation
103
+
104
+ ### TLS/SSL setting
105
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
106
+ # Default to true.
107
+ #
108
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
109
+ #
110
+ # @return [true, false]
111
+ attr_accessor :ssl_verify
112
+
113
+ ### TLS/SSL setting
114
+ # Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
115
+ #
116
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
117
+ #
118
+ attr_accessor :ssl_verify_mode
119
+
120
+ ### TLS/SSL setting
121
+ # Set this to customize the certificate file to verify the peer.
122
+ #
123
+ # @return [String] the path to the certificate file
124
+ attr_accessor :ssl_ca_file
125
+
126
+ ### TLS/SSL setting
127
+ # Client certificate file (for client certificate)
128
+ attr_accessor :ssl_client_cert
129
+
130
+ ### TLS/SSL setting
131
+ # Client private key file (for client certificate)
132
+ attr_accessor :ssl_client_key
133
+
134
+ ### Proxy setting
135
+ # HTTP Proxy settings
136
+ attr_accessor :proxy
137
+
138
+ # Set this to customize parameters encoder of array parameter.
139
+ # Default to nil. Faraday uses NestedParamsEncoder when nil.
140
+ #
141
+ # @see The params_encoder option of Faraday. Related source code:
142
+ # https://github.com/lostisland/faraday/tree/main/lib/faraday/encoders
143
+ attr_accessor :params_encoder
144
+
145
+
146
+ attr_accessor :inject_format
147
+
148
+ attr_accessor :force_ending_format
149
+
150
+ def initialize
151
+ @scheme = 'https'
152
+ @host = 'api.passage.id'
153
+ @base_path = '/v1'
154
+ @server_index = nil
155
+ @server_operation_index = {}
156
+ @server_variables = {}
157
+ @server_operation_variables = {}
158
+ @api_key = {}
159
+ @api_key_prefix = {}
160
+ @client_side_validation = true
161
+ @ssl_verify = true
162
+ @ssl_verify_mode = nil
163
+ @ssl_ca_file = nil
164
+ @ssl_client_cert = nil
165
+ @ssl_client_key = nil
166
+ @middlewares = Hash.new { |h, k| h[k] = [] }
167
+ @configure_connection_blocks = []
168
+ @timeout = 60
169
+ # return data as binary instead of file
170
+ @return_binary_data = false
171
+ @params_encoder = nil
172
+ @debugging = false
173
+ @inject_format = false
174
+ @force_ending_format = false
175
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
176
+
177
+ yield(self) if block_given?
178
+ end
179
+
180
+ # The default Configuration object.
181
+ def self.default
182
+ @@default ||= Configuration.new
183
+ end
184
+
185
+ def configure
186
+ yield(self) if block_given?
187
+ end
188
+
189
+ def scheme=(scheme)
190
+ # remove :// from scheme
191
+ @scheme = scheme.sub(/:\/\//, '')
192
+ end
193
+
194
+ def host=(host)
195
+ # remove http(s):// and anything after a slash
196
+ @host = host.sub(/https?:\/\//, '').split('/').first
197
+ end
198
+
199
+ def base_path=(base_path)
200
+ # Add leading and trailing slashes to base_path
201
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
202
+ @base_path = '' if @base_path == '/'
203
+ end
204
+
205
+ # Returns base URL for specified operation based on server settings
206
+ def base_url(operation = nil)
207
+ if operation_server_settings.key?(operation) then
208
+ index = server_operation_index.fetch(operation, server_index)
209
+ server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
210
+ else
211
+ server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
212
+ end
213
+ end
214
+
215
+ # Gets API key (with prefix if set).
216
+ # @param [String] param_name the parameter name of API key auth
217
+ def api_key_with_prefix(param_name, param_alias = nil)
218
+ key = @api_key[param_name]
219
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
220
+ if @api_key_prefix[param_name]
221
+ "#{@api_key_prefix[param_name]} #{key}"
222
+ else
223
+ key
224
+ end
225
+ end
226
+
227
+ # Gets access_token using access_token_getter or uses the static access_token
228
+ def access_token_with_refresh
229
+ return access_token if access_token_getter.nil?
230
+ access_token_getter.call
231
+ end
232
+
233
+ # Gets Basic Auth token string
234
+ def basic_auth_token
235
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
236
+ end
237
+
238
+ # Returns Auth Settings hash for api client.
239
+ def auth_settings
240
+ {
241
+ 'bearerAuth' =>
242
+ {
243
+ type: 'bearer',
244
+ in: 'header',
245
+ format: 'JWT',
246
+ key: 'Authorization',
247
+ value: "Bearer #{access_token_with_refresh}"
248
+ },
249
+ }
250
+ end
251
+
252
+ # Returns an array of Server setting
253
+ def server_settings
254
+ [
255
+ {
256
+ url: "https://api.passage.id/v1",
257
+ description: "No description provided",
258
+ }
259
+ ]
260
+ end
261
+
262
+ def operation_server_settings
263
+ {
264
+ }
265
+ end
266
+
267
+ # Returns URL based on server settings
268
+ #
269
+ # @param index array index of the server settings
270
+ # @param variables hash of variable and the corresponding value
271
+ def server_url(index, variables = {}, servers = nil)
272
+ servers = server_settings if servers == nil
273
+
274
+ # check array index out of bound
275
+ if (index.nil? || index < 0 || index >= servers.size)
276
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
277
+ end
278
+
279
+ server = servers[index]
280
+ url = server[:url]
281
+
282
+ return url unless server.key? :variables
283
+
284
+ # go through variable and assign a value
285
+ server[:variables].each do |name, variable|
286
+ if variables.key?(name)
287
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
288
+ url.gsub! "{" + name.to_s + "}", variables[name]
289
+ else
290
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
291
+ end
292
+ else
293
+ # use default value
294
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
295
+ end
296
+ end
297
+
298
+ url
299
+ end
300
+
301
+ # Configure Faraday connection directly.
302
+ #
303
+ # ```
304
+ # c.configure_faraday_connection do |conn|
305
+ # conn.use Faraday::HttpCache, shared_cache: false, logger: logger
306
+ # conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger|
307
+ # logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]')
308
+ # end
309
+ # end
310
+ #
311
+ # c.configure_faraday_connection do |conn|
312
+ # conn.adapter :typhoeus
313
+ # end
314
+ # ```
315
+ #
316
+ # @param block [Proc] `#call`able object that takes one arg, the connection
317
+ def configure_faraday_connection(&block)
318
+ @configure_connection_blocks << block
319
+ end
320
+
321
+ def configure_connection(conn)
322
+ @configure_connection_blocks.each do |block|
323
+ block.call(conn)
324
+ end
325
+ end
326
+
327
+ # Adds middleware to the stack
328
+ def use(*middleware)
329
+ set_faraday_middleware(:use, *middleware)
330
+ end
331
+
332
+ # Adds request middleware to the stack
333
+ def request(*middleware)
334
+ set_faraday_middleware(:request, *middleware)
335
+ end
336
+
337
+ # Adds response middleware to the stack
338
+ def response(*middleware)
339
+ set_faraday_middleware(:response, *middleware)
340
+ end
341
+
342
+ # Adds Faraday middleware setting information to the stack
343
+ #
344
+ # @example Use the `set_faraday_middleware` method to set middleware information
345
+ # config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503])
346
+ # config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug })
347
+ # config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false)
348
+ # config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 })
349
+ # config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger)
350
+ # config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware)
351
+ #
352
+ # @see https://github.com/lostisland/faraday/blob/v2.3.0/lib/faraday/rack_builder.rb#L92-L143
353
+ def set_faraday_middleware(operation, key, *args, &block)
354
+ unless [:request, :response, :use, :insert, :insert_before, :insert_after, :swap, :delete].include?(operation)
355
+ fail ArgumentError, "Invalid faraday middleware operation #{operation}. Must be" \
356
+ " :request, :response, :use, :insert, :insert_before, :insert_after, :swap or :delete."
357
+ end
358
+
359
+ @middlewares[operation] << [key, args, block]
360
+ end
361
+ ruby2_keywords(:set_faraday_middleware) if respond_to?(:ruby2_keywords, true)
362
+
363
+ # Set up middleware on the connection
364
+ def configure_middleware(connection)
365
+ return if @middlewares.empty?
366
+
367
+ [:request, :response, :use, :insert, :insert_before, :insert_after, :swap].each do |operation|
368
+ next unless @middlewares.key?(operation)
369
+
370
+ @middlewares[operation].each do |key, args, block|
371
+ connection.builder.send(operation, key, *args, &block)
372
+ end
373
+ end
374
+
375
+ if @middlewares.key?(:delete)
376
+ @middlewares[:delete].each do |key, _args, _block|
377
+ connection.builder.delete(key)
378
+ end
379
+ end
380
+ end
381
+
382
+ end
383
+ end