passageidentity 0.7.1 → 1.0.1
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/lib/openapi_client/api/magic_links_api.rb +1 -1
- data/lib/openapi_client/api/tokens_api.rb +1 -1
- data/lib/openapi_client/api/user_devices_api.rb +1 -1
- data/lib/openapi_client/api/users_api.rb +19 -19
- data/lib/openapi_client/api_client.rb +1 -1
- data/lib/openapi_client/api_error.rb +1 -1
- data/lib/openapi_client/configuration.rb +1 -1
- data/lib/openapi_client/models/apple_user_social_connection.rb +1 -1
- data/lib/openapi_client/models/create_magic_link_request.rb +22 -3
- data/lib/openapi_client/models/{create_user_request.rb → create_user_args.rb} +4 -4
- data/lib/openapi_client/models/github_user_social_connection.rb +1 -1
- data/lib/openapi_client/models/google_user_social_connection.rb +1 -1
- data/lib/openapi_client/models/link.rb +1 -1
- data/lib/openapi_client/models/list_devices_response.rb +1 -1
- data/lib/openapi_client/models/list_paginated_users_item.rb +1 -1
- data/lib/openapi_client/models/list_paginated_users_response.rb +1 -1
- data/lib/openapi_client/models/magic_link.rb +2 -1
- data/lib/openapi_client/models/magic_link_channel.rb +1 -1
- data/lib/openapi_client/models/{theme_type.rb → magic_link_language.rb} +12 -8
- data/lib/openapi_client/models/magic_link_response.rb +1 -1
- data/lib/openapi_client/models/magic_link_type.rb +1 -1
- data/lib/openapi_client/models/model400_error.rb +1 -1
- data/lib/openapi_client/models/model401_error.rb +1 -1
- data/lib/openapi_client/models/model403_error.rb +1 -1
- data/lib/openapi_client/models/model404_error.rb +1 -1
- data/lib/openapi_client/models/model500_error.rb +1 -1
- data/lib/openapi_client/models/nonce.rb +1 -1
- data/lib/openapi_client/models/paginated_links.rb +1 -1
- data/lib/openapi_client/models/{user_info.rb → passage_user.rb} +4 -4
- data/lib/openapi_client/models/social_connection_type.rb +1 -1
- data/lib/openapi_client/models/{update_user_request.rb → update_user_args.rb} +4 -4
- data/lib/openapi_client/models/user_event_action.rb +1 -1
- data/lib/openapi_client/models/user_event_status.rb +1 -1
- data/lib/openapi_client/models/user_recent_event.rb +1 -1
- data/lib/openapi_client/models/user_response.rb +2 -2
- data/lib/openapi_client/models/user_social_connections.rb +1 -1
- data/lib/openapi_client/models/user_status.rb +1 -1
- data/lib/openapi_client/models/web_authn_devices.rb +1 -1
- data/lib/openapi_client/models/web_authn_icons.rb +1 -1
- data/lib/openapi_client/models/web_authn_type.rb +1 -1
- data/lib/openapi_client/version.rb +1 -1
- data/lib/openapi_client.rb +5 -20
- data/lib/passageidentity/auth.rb +43 -156
- data/lib/passageidentity/client.rb +16 -96
- data/lib/passageidentity/user.rb +246 -0
- data/lib/passageidentity/version.rb +1 -1
- metadata +42 -40
- data/lib/models/update_magic_link_auth_method.rb +0 -276
- data/lib/models/update_otp_auth_method.rb +0 -276
- data/lib/models/update_passkeys_auth_method.rb +0 -216
- data/lib/openapi_client/api/apps_api.rb +0 -85
- data/lib/openapi_client/models/app_info.rb +0 -886
- data/lib/openapi_client/models/app_response.rb +0 -221
- data/lib/openapi_client/models/auth_methods.rb +0 -254
- data/lib/openapi_client/models/element_customization.rb +0 -457
- data/lib/openapi_client/models/font_family.rb +0 -58
- data/lib/openapi_client/models/layout_config.rb +0 -285
- data/lib/openapi_client/models/layouts.rb +0 -241
- data/lib/openapi_client/models/magic_link_auth_method.rb +0 -295
- data/lib/openapi_client/models/otp_auth_method.rb +0 -295
- data/lib/openapi_client/models/passkeys_auth_method.rb +0 -221
- data/lib/openapi_client/models/technologies.rb +0 -46
- data/lib/openapi_client/models/ttl_display_unit.rb +0 -42
- data/lib/openapi_client/models/user_metadata_field.rb +0 -323
- data/lib/openapi_client/models/user_metadata_field_type.rb +0 -44
- data/lib/passageidentity/user_api.rb +0 -218
data/lib/openapi_client.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
The version of the OpenAPI document: 1
|
7
7
|
Contact: support@passage.id
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
Generator version: 7.11.0
|
9
|
+
Generator version: 7.11.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -17,25 +17,18 @@ require_relative 'openapi_client/version'
|
|
17
17
|
require_relative 'openapi_client/configuration'
|
18
18
|
|
19
19
|
# Models
|
20
|
-
require_relative 'openapi_client/models/app_info'
|
21
|
-
require_relative 'openapi_client/models/app_response'
|
22
20
|
require_relative 'openapi_client/models/apple_user_social_connection'
|
23
|
-
require_relative 'openapi_client/models/auth_methods'
|
24
21
|
require_relative 'openapi_client/models/create_magic_link_request'
|
25
|
-
require_relative 'openapi_client/models/
|
26
|
-
require_relative 'openapi_client/models/element_customization'
|
27
|
-
require_relative 'openapi_client/models/font_family'
|
22
|
+
require_relative 'openapi_client/models/create_user_args'
|
28
23
|
require_relative 'openapi_client/models/github_user_social_connection'
|
29
24
|
require_relative 'openapi_client/models/google_user_social_connection'
|
30
|
-
require_relative 'openapi_client/models/layout_config'
|
31
|
-
require_relative 'openapi_client/models/layouts'
|
32
25
|
require_relative 'openapi_client/models/link'
|
33
26
|
require_relative 'openapi_client/models/list_devices_response'
|
34
27
|
require_relative 'openapi_client/models/list_paginated_users_item'
|
35
28
|
require_relative 'openapi_client/models/list_paginated_users_response'
|
36
29
|
require_relative 'openapi_client/models/magic_link'
|
37
|
-
require_relative 'openapi_client/models/magic_link_auth_method'
|
38
30
|
require_relative 'openapi_client/models/magic_link_channel'
|
31
|
+
require_relative 'openapi_client/models/magic_link_language'
|
39
32
|
require_relative 'openapi_client/models/magic_link_response'
|
40
33
|
require_relative 'openapi_client/models/magic_link_type'
|
41
34
|
require_relative 'openapi_client/models/model400_error'
|
@@ -44,19 +37,12 @@ require_relative 'openapi_client/models/model403_error'
|
|
44
37
|
require_relative 'openapi_client/models/model404_error'
|
45
38
|
require_relative 'openapi_client/models/model500_error'
|
46
39
|
require_relative 'openapi_client/models/nonce'
|
47
|
-
require_relative 'openapi_client/models/otp_auth_method'
|
48
40
|
require_relative 'openapi_client/models/paginated_links'
|
49
|
-
require_relative 'openapi_client/models/
|
41
|
+
require_relative 'openapi_client/models/passage_user'
|
50
42
|
require_relative 'openapi_client/models/social_connection_type'
|
51
|
-
require_relative 'openapi_client/models/
|
52
|
-
require_relative 'openapi_client/models/theme_type'
|
53
|
-
require_relative 'openapi_client/models/ttl_display_unit'
|
54
|
-
require_relative 'openapi_client/models/update_user_request'
|
43
|
+
require_relative 'openapi_client/models/update_user_args'
|
55
44
|
require_relative 'openapi_client/models/user_event_action'
|
56
45
|
require_relative 'openapi_client/models/user_event_status'
|
57
|
-
require_relative 'openapi_client/models/user_info'
|
58
|
-
require_relative 'openapi_client/models/user_metadata_field'
|
59
|
-
require_relative 'openapi_client/models/user_metadata_field_type'
|
60
46
|
require_relative 'openapi_client/models/user_recent_event'
|
61
47
|
require_relative 'openapi_client/models/user_response'
|
62
48
|
require_relative 'openapi_client/models/user_social_connections'
|
@@ -66,7 +52,6 @@ require_relative 'openapi_client/models/web_authn_icons'
|
|
66
52
|
require_relative 'openapi_client/models/web_authn_type'
|
67
53
|
|
68
54
|
# APIs
|
69
|
-
require_relative 'openapi_client/api/apps_api'
|
70
55
|
require_relative 'openapi_client/api/magic_links_api'
|
71
56
|
require_relative 'openapi_client/api/tokens_api'
|
72
57
|
require_relative 'openapi_client/api/user_devices_api'
|
data/lib/passageidentity/auth.rb
CHANGED
@@ -2,139 +2,66 @@
|
|
2
2
|
|
3
3
|
require 'active_support'
|
4
4
|
require 'jwt'
|
5
|
-
require 'rubygems/deprecate'
|
6
|
-
require_relative 'client'
|
7
5
|
require_relative '../openapi_client'
|
8
6
|
|
9
7
|
module Passage
|
10
8
|
# The Passage::Auth class provides methods for authenticating requests and tokens
|
11
9
|
class Auth
|
12
|
-
|
13
|
-
|
14
|
-
def initialize(app_id, api_key, auth_strategy)
|
15
|
-
@app_cache = ActiveSupport::Cache::MemoryStore.new
|
10
|
+
def initialize(app_id:, req_opts:)
|
16
11
|
@app_id = app_id
|
17
|
-
@
|
18
|
-
@auth_strategy = auth_strategy
|
12
|
+
@req_opts = req_opts
|
19
13
|
|
14
|
+
@app_cache = ActiveSupport::Cache::MemoryStore.new
|
20
15
|
fetch_jwks
|
21
16
|
|
22
|
-
header_params = { 'Passage-Version' => "passage-ruby #{Passage::VERSION}" }
|
23
|
-
header_params['Authorization'] = "Bearer #{@api_key}" if @api_key != ''
|
24
|
-
|
25
|
-
@req_opts = {}
|
26
|
-
@req_opts[:header_params] = header_params
|
27
|
-
@req_opts[:debug_auth_names] = ['header']
|
28
|
-
|
29
|
-
@tokens_client = OpenapiClient::TokensApi.new
|
30
17
|
@magic_links_client = OpenapiClient::MagicLinksApi.new
|
31
18
|
end
|
32
19
|
|
33
|
-
def
|
34
|
-
|
35
|
-
if @auth_strategy == Passage::COOKIE_STRATEGY
|
36
|
-
unless request.cookies.key?('psg_auth_token')
|
37
|
-
raise PassageError.new(
|
38
|
-
status_code: 401,
|
39
|
-
body: {
|
40
|
-
error: 'missing authentication token: expected "psg_auth_token" cookie',
|
41
|
-
code: 'invalid_access_token'
|
42
|
-
}
|
43
|
-
)
|
44
|
-
end
|
45
|
-
@token = request.cookies['psg_auth_token']
|
46
|
-
else
|
47
|
-
headers = request.headers
|
48
|
-
unless headers.key?('Authorization')
|
49
|
-
raise PassageError.new(
|
50
|
-
status_code: 401,
|
51
|
-
body: {
|
52
|
-
error: 'no authentication token in header',
|
53
|
-
code: 'invalid_access_token'
|
54
|
-
}
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
@token = headers['Authorization'].split(' ').last
|
59
|
-
end
|
60
|
-
|
61
|
-
validate_jwt(@token)
|
62
|
-
end
|
63
|
-
|
64
|
-
def validate_jwt(token)
|
65
|
-
raise ArgumentError, 'jwt is required.' unless token && !token.empty?
|
66
|
-
|
67
|
-
begin
|
68
|
-
fetch_jwks
|
69
|
-
rescue Faraday::Error
|
70
|
-
raise PassageError.new(
|
71
|
-
status_code: 401,
|
72
|
-
body: {
|
73
|
-
error: 'invalid JWKs',
|
74
|
-
code: 'invalid_access_token'
|
75
|
-
}
|
76
|
-
)
|
77
|
-
end
|
20
|
+
def validate_jwt(jwt:)
|
21
|
+
raise ArgumentError, 'jwt is required.' unless jwt && !jwt.empty?
|
78
22
|
|
79
23
|
claims =
|
80
24
|
JWT.decode(
|
81
|
-
|
25
|
+
jwt,
|
82
26
|
nil,
|
83
27
|
true,
|
84
28
|
{
|
85
29
|
aud: @app_id,
|
86
30
|
verify_aud: true,
|
87
31
|
algorithms: ['RS256'],
|
88
|
-
jwks:
|
32
|
+
jwks: fetch_jwks
|
89
33
|
}
|
90
34
|
)
|
91
35
|
|
92
36
|
claims[0]['sub']
|
93
|
-
rescue JWT::InvalidIssuerError, JWT::InvalidAudError, JWT::ExpiredSignature, JWT::IncorrectAlgorithm,
|
94
|
-
JWT::DecodeError => e
|
95
|
-
raise PassageError.new(
|
96
|
-
status_code: 401,
|
97
|
-
body: {
|
98
|
-
error: e.message,
|
99
|
-
code: 'invalid_access_token'
|
100
|
-
}
|
101
|
-
)
|
102
37
|
end
|
103
38
|
|
104
|
-
def
|
105
|
-
warn 'NOTE: Passage::Auth#revoke_user_refresh_tokens is deprecated;
|
106
|
-
use Passage::User#revoke_refresh_tokens instead. It will be removed on or after 2024-12.'
|
107
|
-
user_exists?(user_id)
|
108
|
-
|
109
|
-
@tokens_client.revoke_user_refresh_tokens(@app_id, user_id, @req_opts)
|
110
|
-
rescue Faraday::Error => e
|
111
|
-
raise PassageError.new(
|
112
|
-
status_code: e.response[:status],
|
113
|
-
body: e.response[:body]
|
114
|
-
)
|
115
|
-
end
|
116
|
-
|
117
|
-
def create_magic_link_with_email(email, type, send, opts = {})
|
39
|
+
def create_magic_link_with_email(email:, type:, send:, opts: {})
|
118
40
|
args = {}
|
119
41
|
args['email'] = email
|
120
|
-
args['channel'] =
|
42
|
+
args['channel'] = 'email'
|
121
43
|
args['type'] = type
|
122
44
|
args['send'] = send
|
123
45
|
|
124
46
|
create_magic_link(args, opts)
|
125
47
|
end
|
126
48
|
|
127
|
-
def create_magic_link_with_phone(phone
|
49
|
+
def create_magic_link_with_phone(phone:, type:, send:, opts: {})
|
128
50
|
args = {}
|
129
51
|
args['phone'] = phone
|
130
|
-
args['channel'] =
|
52
|
+
args['channel'] = 'phone'
|
131
53
|
args['type'] = type
|
132
54
|
args['send'] = send
|
133
55
|
|
134
56
|
create_magic_link(args, opts)
|
135
57
|
end
|
136
58
|
|
137
|
-
def create_magic_link_with_user(user_id
|
59
|
+
def create_magic_link_with_user(user_id:, channel:, type:, send:, opts: {})
|
60
|
+
raise ArgumentError, "channel must be either 'email' or 'phone'" unless %w[
|
61
|
+
email
|
62
|
+
phone
|
63
|
+
].include?(channel)
|
64
|
+
|
138
65
|
args = {}
|
139
66
|
args['user_id'] = user_id
|
140
67
|
args['channel'] = channel
|
@@ -144,50 +71,34 @@ module Passage
|
|
144
71
|
create_magic_link(args, opts)
|
145
72
|
end
|
146
73
|
|
147
|
-
|
148
|
-
client = OpenapiClient::AppsApi.new
|
149
|
-
response = client.get_app(@app_id)
|
150
|
-
|
151
|
-
response.app
|
152
|
-
rescue Faraday::Error => e
|
153
|
-
raise PassageError.new(
|
154
|
-
status_code: e.response[:status],
|
155
|
-
body: e.response[:body]
|
156
|
-
)
|
157
|
-
end
|
74
|
+
private
|
158
75
|
|
159
76
|
def fetch_jwks
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
f.response :json
|
170
|
-
f.adapter :net_http
|
171
|
-
end
|
172
|
-
|
173
|
-
response =
|
174
|
-
auth_gw_connection.get("/v1/apps/#{@app_id}/.well-known/jwks.json")
|
175
|
-
|
176
|
-
if response.success?
|
177
|
-
@jwks = response.body
|
178
|
-
set_cache(key: @app_id, jwks: @jwks)
|
77
|
+
jwks = @app_cache.read(@app_id)
|
78
|
+
return jwks if jwks
|
79
|
+
|
80
|
+
auth_gw_connection =
|
81
|
+
Faraday.new(url: 'https://auth.passage.id') do |f|
|
82
|
+
f.request :json
|
83
|
+
f.response :raise_error
|
84
|
+
f.response :json
|
85
|
+
f.adapter :net_http
|
179
86
|
end
|
180
|
-
end
|
181
|
-
end
|
182
87
|
|
183
|
-
|
184
|
-
|
185
|
-
end
|
88
|
+
response = auth_gw_connection.get("/v1/apps/#{@app_id}/.well-known/jwks.json")
|
89
|
+
jwks = response.body
|
186
90
|
|
187
|
-
|
91
|
+
@app_cache.write(@app_id, jwks, expires_in: 86_400) # 24 hours in seconds
|
92
|
+
jwks
|
93
|
+
end
|
188
94
|
|
189
95
|
def create_magic_link(args, opts)
|
190
|
-
|
96
|
+
language = opts['language']
|
97
|
+
if language && !OpenapiClient::MagicLinkLanguage.all_vars.include?(language)
|
98
|
+
raise ArgumentError, "language must be one of #{OpenapiClient::MagicLinkLanguage.all_vars}"
|
99
|
+
end
|
100
|
+
|
101
|
+
args['language'] = language
|
191
102
|
args['magic_link_path'] = opts['magic_link_path']
|
192
103
|
args['redirect_url'] = opts['redirect_url']
|
193
104
|
args['ttl'] = opts['ttl']
|
@@ -197,16 +108,16 @@ module Passage
|
|
197
108
|
|
198
109
|
def handle_magic_link_creation(args)
|
199
110
|
@magic_links_client.create_magic_link(@app_id, args, @req_opts).magic_link
|
200
|
-
rescue Faraday::Error => e
|
201
|
-
raise PassageError.new(
|
202
|
-
status_code: e.response[:status],
|
203
|
-
body: e.response[:body]
|
204
|
-
)
|
205
111
|
rescue OpenapiClient::ApiError => e
|
206
112
|
raise PassageError.new(
|
207
113
|
status_code: e.code,
|
208
114
|
body: try_parse_json_string(e.response_body)
|
209
115
|
)
|
116
|
+
rescue Faraday::Error => e
|
117
|
+
raise PassageError.new(
|
118
|
+
status_code: e.response[:status],
|
119
|
+
body: e.response[:body]
|
120
|
+
)
|
210
121
|
end
|
211
122
|
|
212
123
|
def try_parse_json_string(string)
|
@@ -214,29 +125,5 @@ module Passage
|
|
214
125
|
rescue JSON::ParserError
|
215
126
|
string
|
216
127
|
end
|
217
|
-
|
218
|
-
def user_exists?(user_id)
|
219
|
-
return unless user_id.to_s.empty?
|
220
|
-
|
221
|
-
raise PassageError.new(
|
222
|
-
status_code: 400,
|
223
|
-
body: {
|
224
|
-
error: 'Must supply a valid user_id',
|
225
|
-
code: 'invalid_request'
|
226
|
-
}
|
227
|
-
)
|
228
|
-
end
|
229
|
-
|
230
|
-
def get_cache(key)
|
231
|
-
@app_cache.read(key)
|
232
|
-
end
|
233
|
-
|
234
|
-
def set_cache(key:, jwks:)
|
235
|
-
@app_cache.write(key, jwks, expires_in: 86_400)
|
236
|
-
end
|
237
|
-
deprecate(:authenticate_request, :validate_jwt, 2025, 1)
|
238
|
-
deprecate(:authenticate_token, :validate_jwt, 2025, 1)
|
239
|
-
deprecate(:fetch_app, :none, 2025, 1)
|
240
|
-
deprecate(:fetch_jwks, :none, 2025, 1)
|
241
128
|
end
|
242
129
|
end
|
@@ -1,113 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rubygems'
|
4
3
|
require_relative 'auth'
|
5
|
-
require_relative '
|
6
|
-
require_relative 'error'
|
4
|
+
require_relative 'user'
|
7
5
|
require_relative 'version'
|
8
|
-
require_relative '../openapi_client'
|
9
6
|
|
10
7
|
module Passage
|
11
|
-
COOKIE_STRATEGY = 0
|
12
|
-
HEADER_STRATEGY = 1
|
13
|
-
|
14
|
-
EMAIL_CHANNEL = 'email'
|
15
|
-
PHONE_CHANNEL = 'phone'
|
16
|
-
|
17
8
|
# The Passage::Client class provides methods for interacting with Passage
|
18
9
|
class Client
|
19
10
|
attr_reader :auth, :user
|
20
11
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
@api_key = api_key
|
26
|
-
|
27
|
-
# check for valid auth strategy
|
28
|
-
unless [COOKIE_STRATEGY, HEADER_STRATEGY].include? auth_strategy
|
29
|
-
raise PassageError.new(
|
30
|
-
status_code: 400,
|
31
|
-
body: {
|
32
|
-
error: 'Invalid auth strategy',
|
33
|
-
code: 'invalid_argument'
|
34
|
-
}
|
35
|
-
)
|
12
|
+
def initialize(app_id:, api_key:)
|
13
|
+
unless app_id && !app_id.empty?
|
14
|
+
raise ArgumentError,
|
15
|
+
'A Passage App ID is required. Please include (app_id: YOUR_APP_ID, api_key: YOUR_API_KEY).'
|
36
16
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
header_params = { 'Passage-Version' => "passage-ruby #{Passage::VERSION}" }
|
41
|
-
header_params['Authorization'] = "Bearer #{@api_key}" if @api_key != ''
|
42
|
-
|
43
|
-
@req_opts = {}
|
44
|
-
@req_opts[:header_params] = header_params
|
45
|
-
@req_opts[:debug_auth_names] = ['header']
|
46
|
-
|
47
|
-
# initialize auth class
|
48
|
-
@auth = Passage::Auth.new(@app_id, @api_key, @auth_strategy)
|
49
|
-
|
50
|
-
# initialize user class
|
51
|
-
@user = Passage::UserAPI.new(@app_id, @api_key)
|
52
|
-
|
53
|
-
@magic_links_client = OpenapiClient::MagicLinksApi.new
|
54
|
-
end
|
55
|
-
|
56
|
-
# rubocop:disable Naming/AccessorMethodName
|
57
|
-
def get_app
|
58
|
-
client = OpenapiClient::AppsApi.new
|
59
|
-
client.get_app(@app_id).app
|
60
|
-
rescue StandardError => e
|
61
|
-
raise e
|
62
|
-
end
|
63
|
-
# rubocop:enable Naming/AccessorMethodName
|
64
|
-
|
65
|
-
# rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
66
|
-
def create_magic_link(
|
67
|
-
user_id: '',
|
68
|
-
email: '',
|
69
|
-
phone: '',
|
70
|
-
channel: '',
|
71
|
-
send: false,
|
72
|
-
magic_link_path: '',
|
73
|
-
redirect_url: '',
|
74
|
-
language: '',
|
75
|
-
ttl: 60,
|
76
|
-
type: 'login'
|
77
|
-
)
|
78
|
-
args = {}
|
79
|
-
args['user_id'] = user_id unless user_id.empty?
|
80
|
-
args['email'] = email unless email.empty?
|
81
|
-
args['phone'] = phone unless phone.empty?
|
82
|
-
|
83
|
-
unless [PHONE_CHANNEL, EMAIL_CHANNEL].include? channel
|
84
|
-
raise PassageError.new(
|
85
|
-
message:
|
86
|
-
'channel: must be either Passage::EMAIL_CHANNEL or Passage::PHONE_CHANNEL'
|
87
|
-
)
|
17
|
+
unless api_key && !api_key.empty?
|
18
|
+
raise ArgumentError,
|
19
|
+
'A Passage API key is required. Please include (app_id: YOUR_APP_ID, api_key: YOUR_API_KEY).'
|
88
20
|
end
|
89
21
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
args['redirect_url'] = redirect_url unless redirect_url.empty?
|
97
|
-
args['ttl'] = ttl unless ttl.zero?
|
22
|
+
req_opts = {}
|
23
|
+
req_opts[:header_params] = {
|
24
|
+
'Passage-Version' => "passage-ruby #{Passage::VERSION}",
|
25
|
+
'Authorization' => "Bearer #{api_key}"
|
26
|
+
}
|
27
|
+
req_opts[:debug_auth_names] = ['header']
|
98
28
|
|
99
|
-
|
100
|
-
|
101
|
-
rescue Faraday::Error => e
|
102
|
-
raise PassageError.new(
|
103
|
-
status_code: e.response[:status],
|
104
|
-
body: e.response[:body]
|
105
|
-
)
|
106
|
-
end
|
29
|
+
@auth = Passage::Auth.new(app_id: app_id, req_opts: req_opts)
|
30
|
+
@user = Passage::User.new(app_id: app_id, req_opts: req_opts)
|
107
31
|
end
|
108
|
-
# rubocop:enable Metrics/ParameterLists, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
109
|
-
|
110
|
-
deprecate(:create_magic_link, 'Passage::Auth.create_magic_link', 2025, 1)
|
111
|
-
deprecate(:get_app, :none, 2025, 1)
|
112
32
|
end
|
113
33
|
end
|