reputable 0.1.5 → 0.1.7

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: 1d8e38d02c6ad20f915ff71f489780dea010d1304132ba5f1946082e023ff797
4
- data.tar.gz: 712a5a0eeadd88a5127a0d9086c57d4566c6074440e93724deaf28186cf0c55d
3
+ metadata.gz: c5ea31e6c135265677697ac1411fb0d9308f6d4454f23a3d1558018eddfccb4a
4
+ data.tar.gz: 0aea9d057b70a2ca763f5e1f5e6b024d25d07d783feee0447bd311526a189574
5
5
  SHA512:
6
- metadata.gz: bbffa423a948e82c995e5cce48f93356cb0f44519106872e588637a11678b980a26a6290d59289851130ddba212897172b5aaa343ae6b73ebd7d39e15d8a53ce
7
- data.tar.gz: c18bec4b986c8a83cba202130ee3dcfcc2f999256c36622020768112285309bf1aca4744518ed0edeed5423b4dc538edf86f5c4f2a4dd97112cde6602a09cc8c
6
+ metadata.gz: f9621074b650d78f8ba44014f5df9880ee8431065f88a9cd6e3da467aef4885da7230851de5cfe316ef3d8162317bd43cba10fd943d87affbbb2ae11046901c9
7
+ data.tar.gz: 59c4953b9caaf151b3b8a97d057d90b9dab88bdfe71809460a588f35cc8ddc903dacc6805bb9b14ba39d70d203e7622331bbd469e7b870be1da968a8b74b3f77
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- reputable (0.1.4)
4
+ reputable (0.1.6)
5
5
  connection_pool (~> 2.2)
6
6
  redis (>= 4.0, < 6.0)
7
7
 
data/README.md CHANGED
@@ -381,13 +381,20 @@ if suspicious_activity_detected?
381
381
  redirect_url = Reputable.verification_url(
382
382
  return_url: request.original_url, # Where to send them back after verification
383
383
  failure_url: root_url, # Optional: where to send if they fail/garbage token
384
- session_id: session.id # Optional: link specific session
384
+ session_id: session.id, # Optional: link specific session
385
+ force_challenge: false # Optional: if true, always show CAPTCHA (for testing)
385
386
  )
386
387
 
387
388
  redirect_to redirect_url
388
389
  end
389
390
  ```
390
391
 
392
+ **Options:**
393
+ - `return_url` (required): Where to redirect after successful verification
394
+ - `failure_url` (optional): Where to redirect on failure (defaults to return_url)
395
+ - `session_id` (optional): Bind verification to a specific session
396
+ - `force_challenge` (optional): If `true`, always show CAPTCHA even for trusted users. Useful for testing the challenge flow.
397
+
391
398
  ### 2. Handling the Return Redirect
392
399
 
393
400
  When the user passes verification (or is determined to be already trusted/clean), they are immediately redirected back to your `return_url` with signed parameters.
@@ -435,6 +442,7 @@ The return URL will contain:
435
442
  - `reputable_outcome`: The specific reputation outcome (e.g., `trusted_verified`)
436
443
  - `reputable_ignore_analytics`: 'true'/'false' flag
437
444
  - `reputable_country`: ISO country code
445
+ - `reputable_challenge_passed`: 'true' when an interactive challenge was completed
438
446
  - `reputable_signature`: HMAC-SHA256 signature of the above
439
447
 
440
448
  ---
@@ -77,7 +77,7 @@ module Reputable
77
77
  elsif ENV["REPUTABLE_SECRET_KEY"]
78
78
  @trusted_keys = [ENV["REPUTABLE_SECRET_KEY"]]
79
79
  end
80
- @base_url = ENV["REPUTABLE_BASE_URL"]
80
+ @base_url = ENV.fetch("REPUTABLE_BASE_URL", "https://api.reputable.click")
81
81
  end
82
82
 
83
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.5"
4
+ VERSION = "0.1.7"
5
5
  end
data/lib/reputable.rb CHANGED
@@ -126,7 +126,12 @@ module Reputable
126
126
  end
127
127
 
128
128
  # Generate a signed verification URL
129
- def verification_url(return_url:, failure_url: nil, session_id: nil)
129
+ # @param return_url [String] URL to redirect to after successful verification
130
+ # @param failure_url [String, nil] URL to redirect to on failure (optional)
131
+ # @param session_id [String, nil] Session ID to bind the verification to (optional)
132
+ # @param force_challenge [Boolean] If true, always show CAPTCHA even for trusted users (default: false)
133
+ # @return [String] The signed verification URL
134
+ def verification_url(return_url:, failure_url: nil, session_id: nil, force_challenge: false)
130
135
  keys = configuration.trusted_keys
131
136
  if keys.nil? || keys.empty?
132
137
  logger&.warn "Reputable: Missing trusted_keys, cannot generate verification URL"
@@ -150,6 +155,7 @@ module Reputable
150
155
  returnUrl: return_url,
151
156
  failureUrl: failure_url,
152
157
  sessionId: session_id,
158
+ forceChallenge: force_challenge,
153
159
  iat: Time.now.to_i
154
160
  }
155
161
  encoded_payload = base64url_encode(JSON.generate(payload))
@@ -174,6 +180,7 @@ module Reputable
174
180
  outcome = params["reputable_outcome"]
175
181
  ignore_analytics = params["reputable_ignore_analytics"]
176
182
  country = params["reputable_country"] || ""
183
+ challenge_passed = params["reputable_challenge_passed"]
177
184
 
178
185
  return false unless status && session_id && signature
179
186
 
@@ -183,14 +190,15 @@ module Reputable
183
190
  return false
184
191
  end
185
192
 
186
- # Reconstruct data string: status:sessionId:outcome:ignoreAnalytics:country
193
+ # Reconstruct data string: status:sessionId:outcome:ignoreAnalytics:country:challengePassed
187
194
  # Note: optional params default to empty strings if missing in reconstruction logic on server
188
195
  data_parts = [
189
196
  status,
190
197
  session_id,
191
198
  outcome || "",
192
199
  ignore_analytics.nil? ? "" : ignore_analytics,
193
- country
200
+ country,
201
+ challenge_passed || ""
194
202
  ]
195
203
 
196
204
  data = data_parts.join(":")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reputable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reputable
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-12-26 00:00:00.000000000 Z
11
+ date: 2025-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis