Module: Authsignal
- Defined in:
- lib/authsignal.rb,
lib/authsignal/client.rb,
lib/authsignal/version.rb,
lib/authsignal/webhook.rb,
lib/authsignal/api_error.rb,
lib/authsignal/configuration.rb,
lib/authsignal/invalid_signature_error.rb,
lib/authsignal/middleware/json_request.rb,
lib/authsignal/middleware/json_response.rb
Defined Under Namespace
Modules: Middleware
Classes: ApiError, Client, Configuration, InvalidSignatureError, Webhook
Constant Summary
collapse
- NON_API_METHODS =
%i[setup configuration default_configuration webhook].freeze
- VERSION =
'5.5.0'
- DEFAULT_TOLERANCE =
5
Class Attribute Summary collapse
Class Method Summary
collapse
-
.challenge(**options) ⇒ Object
-
.claim_challenge(challenge_id:, user_id:, **options) ⇒ Object
-
.create_session(client_id:, token:, action: nil) ⇒ Object
-
.default_configuration ⇒ Object
-
.delete_authenticator(user_id:, user_authenticator_id:) ⇒ Object
-
.delete_user(user_id:) ⇒ Object
-
.enroll_verified_authenticator(user_id:, attributes:) ⇒ Object
-
.get_action(user_id:, action:, idempotency_key:) ⇒ Object
-
.get_authenticators(user_id:) ⇒ Object
-
.get_challenge(**options) ⇒ Object
-
.get_user(user_id:) ⇒ Object
-
.query_user_actions(user_id:, **options) ⇒ Object
-
.query_users(**options) ⇒ Object
-
.refresh_session(refresh_token:) ⇒ Object
-
.revoke_session(access_token:) ⇒ Object
-
.revoke_user_sessions(user_id:) ⇒ Object
-
.setup {|configuration| ... } ⇒ Object
-
.track(user_id:, action:, attributes:) ⇒ Object
-
.update_action(user_id:, action:, idempotency_key:, attributes:) ⇒ Object
-
.update_user(user_id:, attributes:) ⇒ Object
-
.validate_challenge(token:, user_id: nil, action: nil) ⇒ Object
-
.validate_session(access_token:, client_ids: nil) ⇒ Object
-
.verify(challenge_id:, verification_code:) ⇒ Object
-
.webhook ⇒ Object
Class Method Details
.challenge(**options) ⇒ Object
107
108
109
110
111
|
# File 'lib/authsignal.rb', line 107
def challenge(**options)
response = Client.new.challenge(**options)
handle_response(response)
end
|
.claim_challenge(challenge_id:, user_id:, **options) ⇒ Object
119
120
121
122
123
|
# File 'lib/authsignal.rb', line 119
def claim_challenge(challenge_id:, user_id:, **options)
response = Client.new.claim_challenge(challenge_id: challenge_id, user_id: user_id, **options)
handle_response(response)
end
|
.create_session(client_id:, token:, action: nil) ⇒ Object
131
132
133
134
135
|
# File 'lib/authsignal.rb', line 131
def create_session(client_id:, token:, action: nil)
response = Client.new.create_session(client_id: client_id, token: token, action: action)
handle_response(response)
end
|
.default_configuration ⇒ Object
28
29
30
|
# File 'lib/authsignal.rb', line 28
def default_configuration
configuration.defaults
end
|
.delete_authenticator(user_id:, user_authenticator_id:) ⇒ Object
72
73
74
75
76
|
# File 'lib/authsignal.rb', line 72
def delete_authenticator(user_id:, user_authenticator_id:)
response = Client.new.delete_authenticator(user_id: user_id, user_authenticator_id: user_authenticator_id)
handle_response(response)
end
|
.delete_user(user_id:) ⇒ Object
54
55
56
57
58
|
# File 'lib/authsignal.rb', line 54
def delete_user(user_id:)
response = Client.new.delete_user(user_id: user_id)
handle_response(response)
end
|
.enroll_verified_authenticator(user_id:, attributes:) ⇒ Object
66
67
68
69
70
|
# File 'lib/authsignal.rb', line 66
def enroll_verified_authenticator(user_id:, attributes:)
response = Client.new.enroll_verified_authenticator(user_id: user_id, attributes: attributes)
handle_response(response)
end
|
.get_action(user_id:, action:, idempotency_key:) ⇒ Object
89
90
91
92
93
|
# File 'lib/authsignal.rb', line 89
def get_action(user_id:, action:, idempotency_key:)
response = Client.new.get_action(user_id: user_id, action: action, idempotency_key: idempotency_key)
handle_response(response)
end
|
.get_authenticators(user_id:) ⇒ Object
60
61
62
63
64
|
# File 'lib/authsignal.rb', line 60
def get_authenticators(user_id:)
response = Client.new.get_authenticators(user_id: user_id)
handle_response(response)
end
|
.get_challenge(**options) ⇒ Object
125
126
127
128
129
|
# File 'lib/authsignal.rb', line 125
def get_challenge(**options)
response = Client.new.get_challenge(**options)
handle_response(response)
end
|
.get_user(user_id:) ⇒ Object
36
37
38
39
40
|
# File 'lib/authsignal.rb', line 36
def get_user(user_id:)
response = Client.new.get_user(user_id: user_id)
handle_response(response)
end
|
.query_user_actions(user_id:, **options) ⇒ Object
95
96
97
98
99
|
# File 'lib/authsignal.rb', line 95
def query_user_actions(user_id:, **options)
response = Client.new.query_user_actions(user_id: user_id, **options)
handle_response(response)
end
|
.query_users(**options) ⇒ Object
42
43
44
45
46
|
# File 'lib/authsignal.rb', line 42
def query_users(**options)
response = Client.new.query_users(**options)
handle_response(response)
end
|
.refresh_session(refresh_token:) ⇒ Object
143
144
145
146
147
|
# File 'lib/authsignal.rb', line 143
def refresh_session(refresh_token:)
response = Client.new.refresh_session(refresh_token: refresh_token)
handle_response(response)
end
|
.revoke_session(access_token:) ⇒ Object
149
150
151
152
153
|
# File 'lib/authsignal.rb', line 149
def revoke_session(access_token:)
response = Client.new.revoke_session(access_token: access_token)
handle_response(response)
end
|
.revoke_user_sessions(user_id:) ⇒ Object
155
156
157
158
159
|
# File 'lib/authsignal.rb', line 155
def revoke_user_sessions(user_id:)
response = Client.new.revoke_user_sessions(user_id: user_id)
handle_response(response)
end
|
.setup {|configuration| ... } ⇒ Object
20
21
22
|
# File 'lib/authsignal.rb', line 20
def setup
yield(configuration)
end
|
.track(user_id:, action:, attributes:) ⇒ Object
78
79
80
81
|
# File 'lib/authsignal.rb', line 78
def track(user_id:, action:, attributes:)
response = Client.new.track(user_id: user_id, action: action, attributes: attributes)
handle_response(response)
end
|
.update_action(user_id:, action:, idempotency_key:, attributes:) ⇒ Object
101
102
103
104
105
|
# File 'lib/authsignal.rb', line 101
def update_action(user_id:, action:, idempotency_key:, attributes:)
response = Client.new.update_action(user_id: user_id, action: action, idempotency_key: idempotency_key, attributes: attributes)
handle_response(response)
end
|
.update_user(user_id:, attributes:) ⇒ Object
48
49
50
51
52
|
# File 'lib/authsignal.rb', line 48
def update_user(user_id:, attributes:)
response = Client.new.update_user(user_id: user_id, attributes: attributes)
handle_response(response)
end
|
.validate_challenge(token:, user_id: nil, action: nil) ⇒ Object
83
84
85
86
87
|
# File 'lib/authsignal.rb', line 83
def validate_challenge(token:, user_id: nil, action: nil)
response = Client.new.validate_challenge(token: token, user_id: user_id, action: action)
handle_response(response)
end
|
.validate_session(access_token:, client_ids: nil) ⇒ Object
137
138
139
140
141
|
# File 'lib/authsignal.rb', line 137
def validate_session(access_token:, client_ids: nil)
response = Client.new.validate_session(access_token: access_token, client_ids: client_ids)
handle_response(response)
end
|
.verify(challenge_id:, verification_code:) ⇒ Object
113
114
115
116
117
|
# File 'lib/authsignal.rb', line 113
def verify(challenge_id:, verification_code:)
response = Client.new.verify(challenge_id: challenge_id, verification_code: verification_code)
handle_response(response)
end
|
.webhook ⇒ Object
32
33
34
|
# File 'lib/authsignal.rb', line 32
def webhook
@webhook ||= Webhook.new(configuration.api_secret_key)
end
|