passkeys-rails 0.2.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d6b32ba5bcfa9553687bb70a01ba4e1b9211ab50336e62f3f7eae7033c3f689
4
- data.tar.gz: e53cc11ffec79936ec74319fb1ec6d47cd74d67f4f56ff0c2d234abf8800b1f3
3
+ metadata.gz: 666859b1227428b580202f3c2f9822cf937db0ecaf26381dddefd45b6d8e9b3e
4
+ data.tar.gz: 7cbce30a6f2efb7eb15aa4a747156da1e355c795ca346fdc8af2ecad6af837d6
5
5
  SHA512:
6
- metadata.gz: 87cb708335cfae465b142633dc829c92ac16c4d9d958807cbb682caf455ca18e2b13a24ad30b1bb3020f3493b6dd924151269eb37ba2eaeb09508d5b350a9572
7
- data.tar.gz: 04fcd5259c6fe2b1d06f289254817fc1baee73e5d7c7d2aee3476a2155e02e2cb4c40c02deab4285a602bbe9c51806a3e90c5f15ed2b3de928ca9843b0f9fd14
6
+ metadata.gz: d0bff5cc099209252fa1853c9e75e8f23edce8de4ac910f2e958e9279ec81a4452074fa6611d42424e4809fc010a129072e7d719e9de8b4e0a3e40e7619ad7f9
7
+ data.tar.gz: 98e62cd971c37781aecadc0dbe09b1c32d6aa2e0837f24c816971c660d8d00c19c738a339a43f021a4a27e843b79b04b3128f65f7ff21b971289fa232dd0df75
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Gem Version](https://badge.fury.io/rb/passkeys-rails.svg?cachebust=7)](https://badge.fury.io/rb/passkeys-rails)
1
+ [![Gem Version](https://badge.fury.io/rb/passkeys-rails.svg?cachebust=0.2.1)](https://badge.fury.io/rb/passkeys-rails)
2
2
  [![Build Status](https://app.travis-ci.com/alliedcode/passkeys-rails.svg?branch=main)](https://travis-ci.org/alliedcode/passkeys-rails)
3
3
  [![codecov](https://codecov.io/gh/alliedcode/passkeys-rails/branch/main/graph/badge.svg?token=UHSNJDUL21)](https://codecov.io/gh/alliedcode/passkeys-rails)
4
4
 
@@ -7,6 +7,7 @@ module PasskeysRails
7
7
  included do
8
8
  has_one :agent, as: :authenticatable, class_name: "PasskeysRails::Agent"
9
9
 
10
+ delegate :username, to: :agent, allow_nil: true
10
11
  delegate :registered?, to: :agent, allow_nil: true
11
12
 
12
13
  def registering_with(_params)
@@ -53,6 +53,8 @@ module PasskeysRails
53
53
 
54
54
  # Returns an Interactor::Context that indicates if the request is authentic.
55
55
  #
56
+ # `request` can be a String on an Http Request
57
+ #
56
58
  # .success? is true if authentic
57
59
  # .agent is the Passkey::Agent on success
58
60
  #
@@ -60,10 +62,19 @@ module PasskeysRails
60
62
  # .code is the error code on failure
61
63
  # .message is the human readable error message on failure
62
64
  def self.authenticate(request)
63
- PasskeysRails::ValidateAuthToken.call(auth_token: request.headers['X-Auth'])
65
+ auth_token = if request.is_a?(String)
66
+ request
67
+ elsif request.respond_to?(:headers)
68
+ request.headers['X-Auth']
69
+ else
70
+ ""
71
+ end
72
+
73
+ PasskeysRails::ValidateAuthToken.call(auth_token:)
64
74
  end
65
75
 
66
76
  # Raises a PasskeysRails::Error exception if the request is not authentic.
77
+ # `request` can be a String on an Http Request
67
78
  def self.authenticate!(request)
68
79
  auth = authenticate(request)
69
80
  return if auth.success?
@@ -1,3 +1,3 @@
1
1
  module PasskeysRails
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.2.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passkeys-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Troy Anderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-28 00:00:00.000000000 Z
11
+ date: 2023-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails