authsignal-ruby 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69b244aee6e940441e952ba9fb62b4952e8da7b9ff29ac87893eedc87c042bbe
4
- data.tar.gz: 21ae8f3d6d312308ffebc53a69eb6b23ce3e32d364b8c1a148826d8d1e68468e
3
+ metadata.gz: 553049be926d596da10a2e826338db41bd2a9a8a3fa2dbbf545b4b7d2850d828
4
+ data.tar.gz: 0d510dfa15063a1730f6490d93aed9614f4e88167eb44c76309460632d9cc499
5
5
  SHA512:
6
- metadata.gz: 6fd2f1e28877868372c8f7992cb7d5a3d0b30dd4c9119d0329302d7bb9c64e5c48b2d9a212b4376ee5132ea11d1bdbe766fa69c38e00908b2cddb5e9140127c9
7
- data.tar.gz: e59793ce77aa8e3e0f8387ff9fbcce36d97b1a68166b4d31758bddd3fe490b0cb210b7913961feff50ecb97ceb19b2374d5982a305295edce0e06f42c533a450
6
+ metadata.gz: 90bbb9bb3d7c738995816d34a1cdd7a251edb593dca9f87698d1bcddcbcc4da77d4eb529b17297ed322f2a6bd564909eeb8cf7b6722b4200acacd09e139c7877
7
+ data.tar.gz: 1dc7095f53fb925f7702207b34a13bd052e9d4b835ea4880968d54027b70254aa3b69332debbc8c407994d918eb3e653f96f58741fd0eeac77c338114d247021
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authsignal-ruby (0.1.3)
4
+ authsignal-ruby (0.1.6)
5
5
  httparty (~> 0.21.0)
6
6
 
7
7
  GEM
@@ -16,7 +16,7 @@ GEM
16
16
  httparty (0.21.0)
17
17
  mini_mime (>= 1.0.0)
18
18
  multi_xml (>= 0.5.2)
19
- mini_mime (1.1.2)
19
+ mini_mime (1.1.5)
20
20
  multi_xml (0.6.0)
21
21
  public_suffix (4.0.7)
22
22
  rake (13.0.6)
data/Rakefile CHANGED
@@ -5,4 +5,4 @@ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- task default: :spec
8
+ task default: :spec
data/RakefileRelease ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require_relative 'lib/authsignal/version'
6
+
7
+ task default: :build_and_push_gem
8
+
9
+ RSpec::Core::RakeTask.new(:build_and_push_gem) do |task|
10
+ version = Authsignal::VERSION
11
+ puts "Building gem..."
12
+ sh "gem build authsignal-ruby.gemspec"
13
+ puts "Pushing authsignal-ruby-#{version} gem..."
14
+ sh "gem push authsignal-ruby-#{version}.gem"
15
+ puts "Gem authsignal-ruby-#{version} has been pushed."
16
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Authsignal
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.6"
5
5
  end
data/lib/authsignal.rb CHANGED
@@ -69,6 +69,35 @@ module Authsignal
69
69
  false
70
70
  end
71
71
 
72
+ def validate_challenge(user_id:, token:)
73
+ begin
74
+ decoded_token = JWT.decode(token, Authsignal.configuration.api_secret_key)[0]
75
+ rescue JWT::DecodeError
76
+ puts 'Token verification failed'
77
+ end
78
+
79
+ decoded_user_id = decoded_token["other"]["userId"]
80
+ action_code = decoded_token["other"]["actionCode"]
81
+ idempotency_key = decoded_token["other"]["idempotencyKey"]
82
+
83
+ if user_id != decoded_user_id
84
+ return { user_id: decoded_user_id, success: false, state: nil }
85
+ end
86
+
87
+ if action_code && idempotency_key
88
+ action_result = get_action(user_id: decoded_user_id, action_code: action_code, idempotency_key: idempotency_key)
89
+
90
+ if action_result
91
+ state = action_result[:state]
92
+ success = state == "CHALLENGE_SUCCEEDED"
93
+
94
+ return { user_id: decoded_user_id, success: success, state: state, action: action_code }
95
+ end
96
+ end
97
+
98
+ { user_id: decoded_user_id, success: false, state: nil }
99
+ end
100
+
72
101
  private
73
102
  def underscore(string)
74
103
  string.gsub(/::/, '/').
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.4
4
+ version: 0.1.6
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-02 00:00:00.000000000 Z
11
+ date: 2023-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -81,6 +81,7 @@ files:
81
81
  - LICENSE.txt
82
82
  - README.md
83
83
  - Rakefile
84
+ - RakefileRelease
84
85
  - bin/console
85
86
  - bin/setup
86
87
  - lib/authsignal.rb
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  requirements: []
111
- rubygems_version: 3.2.32
112
+ rubygems_version: 3.4.10
112
113
  signing_key:
113
114
  specification_version: 4
114
115
  summary: The Authsignal ruby server side signal API.