reputable 0.1.3 → 0.1.5

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: ca78832e420ad0cacad0c44bbfbf2a682f1b9f702bbaf8aa07a44e4e04d7d53b
4
- data.tar.gz: 9e15f534984a4e3d67560a98cbede0c596d02d30fb7f7171b380b043b0781384
3
+ metadata.gz: 1d8e38d02c6ad20f915ff71f489780dea010d1304132ba5f1946082e023ff797
4
+ data.tar.gz: 712a5a0eeadd88a5127a0d9086c57d4566c6074440e93724deaf28186cf0c55d
5
5
  SHA512:
6
- metadata.gz: 23832e31d409bb3316c33c931e6207f24eb2ea078c2fa79d3d0c4618e4ffd3359f525d0c6b090344bb5d8e79cf9fdc714752ae09180ce973dd353d93015afb6c
7
- data.tar.gz: 9eb4a989b111a493e7555672057946c2928251a1112e7b75e011bf7183c329ee3b9c6c6cb0e34a163d3803cb5956321b443b25f2d9fcbfca5c90ad16b73cd766
6
+ metadata.gz: bbffa423a948e82c995e5cce48f93356cb0f44519106872e588637a11678b980a26a6290d59289851130ddba212897172b5aaa343ae6b73ebd7d39e15d8a53ce
7
+ data.tar.gz: c18bec4b986c8a83cba202130ee3dcfcc2f999256c36622020768112285309bf1aca4744518ed0edeed5423b4dc538edf86f5c4f2a4dd97112cde6602a09cc8c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- reputable (0.1.3)
4
+ reputable (0.1.4)
5
5
  connection_pool (~> 2.2)
6
6
  redis (>= 4.0, < 6.0)
7
7
 
data/README.md CHANGED
@@ -80,6 +80,9 @@ All configuration can be set via environment variables:
80
80
  # Required
81
81
  REPUTABLE_REDIS_URL=rediss://user:password@your-dragonfly.example.com:6379
82
82
 
83
+ # Optional: Base URL for verification and API endpoints (domain only)
84
+ REPUTABLE_BASE_URL=https://api.reputable.click
85
+
83
86
  # Optional: Disable entirely (useful for test environments)
84
87
  REPUTABLE_ENABLED=false
85
88
 
@@ -138,7 +141,7 @@ Reputable.configure do |config|
138
141
  # Verification Configuration
139
142
  # Supports comma-separated list in REPUTABLE_TRUSTED_KEYS or single key in REPUTABLE_TRUSTED_KEY
140
143
  config.trusted_keys = ENV['REPUTABLE_TRUSTED_KEYS']&.split(',') || ENV['REPUTABLE_TRUSTED_KEY']
141
- config.verification_base_url = ENV['REPUTABLE_VERIFY_URL'] # URL of your Reputable API verify endpoint
144
+ config.base_url = ENV['REPUTABLE_BASE_URL'] # Domain only
142
145
 
143
146
  # Error callback (optional)
144
147
  config.on_error = ->(error, context) {
@@ -14,7 +14,11 @@ module Reputable
14
14
  :default_ttls, :pool_size, :pool_timeout,
15
15
  :connect_timeout, :read_timeout, :write_timeout,
16
16
  :ssl_params, :trusted_proxies, :ip_header_priority,
17
- :on_error, :trusted_keys, :verification_base_url
17
+ :on_error, :trusted_keys, :base_url
18
+
19
+ # Alias for backward compatibility
20
+ alias_method :verification_base_url, :base_url
21
+ alias_method :verification_base_url=, :base_url=
18
22
 
19
23
  # Default TTLs in seconds (0 = forever)
20
24
  DEFAULT_TTLS = {
@@ -73,7 +77,7 @@ module Reputable
73
77
  elsif ENV["REPUTABLE_SECRET_KEY"]
74
78
  @trusted_keys = [ENV["REPUTABLE_SECRET_KEY"]]
75
79
  end
76
- @verification_base_url = ENV.fetch("REPUTABLE_VERIFY_URL", "https://api.reputable.click/_reputable/verify")
80
+ @base_url = ENV["REPUTABLE_BASE_URL"]
77
81
  end
78
82
 
79
83
  # Alias for backward compatibility
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Reputable
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
data/lib/reputable.rb CHANGED
@@ -130,18 +130,21 @@ module Reputable
130
130
  keys = configuration.trusted_keys
131
131
  if keys.nil? || keys.empty?
132
132
  logger&.warn "Reputable: Missing trusted_keys, cannot generate verification URL"
133
- return return_url
133
+ return return_url
134
134
  end
135
-
135
+
136
136
  # Use the first key for signing new requests
137
137
  secret = keys.first
138
-
139
- base_url = configuration.verification_base_url
140
-
138
+
139
+ base_url = configuration.base_url
140
+ # Ensure base_url doesn't have a trailing slash, then append the verify path
141
+ base_url = base_url.chomp("/")
142
+ verify_url = "#{base_url}/_reputable/verify"
143
+
141
144
  # JWT Header
142
145
  header = { alg: "HS256", typ: "JWT" }
143
146
  encoded_header = base64url_encode(JSON.generate(header))
144
-
147
+
145
148
  # JWT Payload
146
149
  payload = {
147
150
  returnUrl: return_url,
@@ -150,15 +153,15 @@ module Reputable
150
153
  iat: Time.now.to_i
151
154
  }
152
155
  encoded_payload = base64url_encode(JSON.generate(payload))
153
-
156
+
154
157
  # Signature
155
158
  data = "#{encoded_header}.#{encoded_payload}"
156
159
  signature = OpenSSL::HMAC.digest("SHA256", secret, data)
157
160
  encoded_signature = base64url_encode(signature)
158
-
161
+
159
162
  token = "#{data}.#{encoded_signature}"
160
-
161
- "#{base_url}?token=#{token}"
163
+
164
+ "#{verify_url}?token=#{token}"
162
165
  end
163
166
 
164
167
  # Verify the signature of a redirect return
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reputable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reputable