authsignal-ruby 0.1.6 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 553049be926d596da10a2e826338db41bd2a9a8a3fa2dbbf545b4b7d2850d828
4
- data.tar.gz: 0d510dfa15063a1730f6490d93aed9614f4e88167eb44c76309460632d9cc499
3
+ metadata.gz: 561440221a5ef9e66e1b0094958c6ea9b74e6299579bdcf3d38882de19f40f9c
4
+ data.tar.gz: c364e721d2726a9f59fa3e2fb807bd14e4397c73664a73acd4929edcb693e3fd
5
5
  SHA512:
6
- metadata.gz: 90bbb9bb3d7c738995816d34a1cdd7a251edb593dca9f87698d1bcddcbcc4da77d4eb529b17297ed322f2a6bd564909eeb8cf7b6722b4200acacd09e139c7877
7
- data.tar.gz: 1dc7095f53fb925f7702207b34a13bd052e9d4b835ea4880968d54027b70254aa3b69332debbc8c407994d918eb3e653f96f58741fd0eeac77c338114d247021
6
+ metadata.gz: 0af6f0ee6b672e2694fb3fcb4d26084c160d34a25a279b8ac3e4272d207f63f75bf5f1a9e5a9990921ee853813bc738cc5e53620cf34413088fbb2f9734e6948
7
+ data.tar.gz: b069887fc72d20b96ccc369a50749dac540ffebfbf03bf5e104132def1a99cdf78ed7172d0e2f4b6289752ce1db664c77d0548432e44d0203dfd71c37547f0ac
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in authsignal-ruby.gemspec
6
6
  gemspec
7
+
8
+ gem 'jwt'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authsignal-ruby (0.1.6)
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 `track_action`, `get_action`, `get_user`, `enrol_authenticator`.
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#track_action).
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
 
@@ -19,7 +19,7 @@ module Authsignal
19
19
  end
20
20
 
21
21
  def track(action, options = {})
22
- actionCode = action[:actionCode]
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 enrol_authenticator(user_id, authenticator)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Authsignal
4
- VERSION = "0.1.6"
4
+ VERSION = "1.0.0"
5
5
  end
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 identify(user_id:, user:)
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.enrol_authenticator(user_id, authenticator)
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 track_action(event, options={})
53
- raise ArgumentError, "Action Code is required" unless event[:action_code].to_s.length > 0
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 user_id != decoded_user_id
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.1.6
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-08-24 00:00:00.000000000 Z
11
+ date: 2023-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty