authsignal-ruby 0.1.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +3 -1
- data/README.md +3 -3
- data/lib/authsignal/client.rb +2 -2
- data/lib/authsignal/version.rb +1 -1
- data/lib/authsignal.rb +6 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 561440221a5ef9e66e1b0094958c6ea9b74e6299579bdcf3d38882de19f40f9c
|
4
|
+
data.tar.gz: c364e721d2726a9f59fa3e2fb807bd14e4397c73664a73acd4929edcb693e3fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0af6f0ee6b672e2694fb3fcb4d26084c160d34a25a279b8ac3e4272d207f63f75bf5f1a9e5a9990921ee853813bc738cc5e53620cf34413088fbb2f9734e6948
|
7
|
+
data.tar.gz: b069887fc72d20b96ccc369a50749dac540ffebfbf03bf5e104132def1a99cdf78ed7172d0e2f4b6289752ce1db664c77d0548432e44d0203dfd71c37547f0ac
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
authsignal-ruby (0.
|
4
|
+
authsignal-ruby (1.0.0)
|
5
5
|
httparty (~> 0.21.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -16,6 +16,7 @@ GEM
|
|
16
16
|
httparty (0.21.0)
|
17
17
|
mini_mime (>= 1.0.0)
|
18
18
|
multi_xml (>= 0.5.2)
|
19
|
+
jwt (2.7.1)
|
19
20
|
mini_mime (1.1.5)
|
20
21
|
multi_xml (0.6.0)
|
21
22
|
public_suffix (4.0.7)
|
@@ -44,6 +45,7 @@ PLATFORMS
|
|
44
45
|
|
45
46
|
DEPENDENCIES
|
46
47
|
authsignal-ruby!
|
48
|
+
jwt
|
47
49
|
rake (~> 13.0)
|
48
50
|
rspec (~> 3.2)
|
49
51
|
webmock (~> 3.14.0)
|
data/README.md
CHANGED
@@ -53,13 +53,13 @@ end
|
|
53
53
|
|
54
54
|
## Usage
|
55
55
|
|
56
|
-
Authsignal's server side signal API has four main api calls `
|
56
|
+
Authsignal's server side signal API has four main api calls `track`, `get_action`, `get_user`, `enroll_verified_authenticator`.
|
57
57
|
|
58
|
-
For more details on these api calls, refer to our [official Ruby SDK docs](https://docs.authsignal.com/sdks/server/ruby#
|
58
|
+
For more details on these api calls, refer to our [official Ruby SDK docs](https://docs.authsignal.com/sdks/server/ruby#track).
|
59
59
|
|
60
60
|
## Development
|
61
61
|
|
62
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
62
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` or `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
63
63
|
|
64
64
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
65
65
|
|
data/lib/authsignal/client.rb
CHANGED
@@ -19,7 +19,7 @@ module Authsignal
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def track(action, options = {})
|
22
|
-
actionCode = action[:
|
22
|
+
actionCode = action[:action]
|
23
23
|
idempotencyKey = ERB::Util.url_encode(action[:idempotencyKey])
|
24
24
|
userId = ERB::Util.url_encode(action[:userId])
|
25
25
|
body = action.except(:userId, :actionCode)
|
@@ -45,7 +45,7 @@ module Authsignal
|
|
45
45
|
post("/users/#{ERB::Util.url_encode(user_id)}", body: JSON.generate(user_payload))
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
48
|
+
def enroll_verified_authenticator(user_id, authenticator)
|
49
49
|
post("/users/#{ERB::Util.url_encode(user_id)}/authenticators", body: JSON.generate(authenticator))
|
50
50
|
end
|
51
51
|
|
data/lib/authsignal/version.rb
CHANGED
data/lib/authsignal.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "httparty"
|
2
|
+
require 'jwt'
|
2
3
|
|
3
4
|
require "authsignal/version"
|
4
5
|
require "authsignal/client"
|
@@ -31,14 +32,9 @@ module Authsignal
|
|
31
32
|
response.transform_keys { |key| underscore(key) }.transform_keys(&:to_sym)
|
32
33
|
end
|
33
34
|
|
34
|
-
def
|
35
|
-
response = Client.new.identify(user_id, user)
|
36
|
-
response.transform_keys { |key| underscore(key) }.transform_keys(&:to_sym)
|
37
|
-
end
|
38
|
-
|
39
|
-
def enrol_authenticator(user_id:, authenticator:)
|
35
|
+
def enroll_verified_authenticator(user_id:, authenticator:)
|
40
36
|
authenticator = authenticator.transform_keys { |key| camelize(key) }
|
41
|
-
response = Client.new.
|
37
|
+
response = Client.new.enroll_verified_authenticator(user_id, authenticator)
|
42
38
|
|
43
39
|
if response["authenticator"]
|
44
40
|
response["authenticator"] = response["authenticator"].transform_keys { |key| underscore(key) }.transform_keys(&:to_sym)
|
@@ -49,8 +45,8 @@ module Authsignal
|
|
49
45
|
response
|
50
46
|
end
|
51
47
|
|
52
|
-
def
|
53
|
-
raise ArgumentError, "Action Code is required" unless event[:
|
48
|
+
def track(event, options={})
|
49
|
+
raise ArgumentError, "Action Code is required" unless event[:action].to_s.length > 0
|
54
50
|
raise ArgumentError, "User ID value" unless event[:user_id].to_s.length > 0
|
55
51
|
|
56
52
|
event = event.transform_keys { |key| camelize(key) }
|
@@ -80,7 +76,7 @@ module Authsignal
|
|
80
76
|
action_code = decoded_token["other"]["actionCode"]
|
81
77
|
idempotency_key = decoded_token["other"]["idempotencyKey"]
|
82
78
|
|
83
|
-
if
|
79
|
+
if user_id && user_id != decoded_user_id
|
84
80
|
return { user_id: decoded_user_id, success: false, state: nil }
|
85
81
|
end
|
86
82
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authsignal-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- justinsoong
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|