fingerly 0.2.0 → 0.4.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.
data/README.md CHANGED
@@ -1,90 +1,253 @@
1
- # fingerly-ruby
1
+ <p align="center">
2
+ <a href="https://fingerly.io">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/fingerly-io/.github/main/assets/logo-dark.svg">
5
+ <img src="https://raw.githubusercontent.com/fingerly-io/.github/main/assets/logo-light.svg" alt="Fingerly" height="44">
6
+ </picture>
7
+ </a>
8
+ </p>
9
+
10
+ <p align="center"><b>Fingerly for Ruby</b><br>Read device intelligence events, verify webhooks and serve the browser SDK from your own domain.</p>
11
+
12
+ <p align="center">
13
+ <a href="https://rubygems.org/gems/fingerly"><img src="https://img.shields.io/gem/v/fingerly?style=flat-square" alt="Gem version"></a>
14
+ <a href="https://github.com/fingerly-io/sdk-ruby/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/fingerly-io/sdk-ruby/ci.yml?style=flat-square&label=ci" alt="CI status"></a>
15
+ <a href="https://github.com/fingerly-io/sdk-ruby/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License: Apache-2.0"></a>
16
+ <img src="https://img.shields.io/badge/ruby-%E2%89%A5%203.2-CC342D?style=flat-square" alt="Ruby 3.2 or newer">
17
+ <a href="https://docs.fingerly.io/docs/sdks/ruby"><img src="https://img.shields.io/badge/docs-docs.fingerly.io-111827?style=flat-square" alt="Documentation"></a>
18
+ </p>
19
+
20
+ <p align="center"><img src="https://raw.githubusercontent.com/fingerly-io/.github/main/assets/banner.webp" alt="Fingerly" width="100%"></p>
21
+
22
+ ## What is this
23
+
24
+ The `fingerly` gem is the server-side SDK for Ruby. It reads Fingerly events
25
+ with a secret key, verifies webhook signatures and relays the browser SDK's
26
+ traffic through your own domain with a same-origin Rack proxy. It has no
27
+ runtime dependencies and is for backends that protect signups, logins and
28
+ payments from fraud and abuse. [Fingerly](https://fingerly.io) identifies the
29
+ device behind each session and scores how suspicious it is.
30
+
31
+ ## Getting started
32
+
33
+ 1. **Prerequisites.** A Fingerly account and a secret key (`fly_sk_...`). See
34
+ [API keys and environments](https://docs.fingerly.io/docs/api-keys). Ruby
35
+ 3.2+.
36
+ 2. **Install.** Add it to your `Gemfile`:
37
+
38
+ ```ruby
39
+ gem "fingerly", "~> 0.4.0"
40
+ ```
41
+
42
+ 3. **Read an event.**
43
+
44
+ ```ruby
45
+ require "fingerly"
46
+
47
+ fingerly = Fingerly::Client.new(secret_key: ENV.fetch("FINGERLY_SECRET_KEY"))
48
+
49
+ request_id = ARGV.fetch(0) # the requestId the browser SDK's identify() returned
50
+ event = fingerly.events.get(request_id)
51
+ page = fingerly.events.list(level: Fingerly::SuspectLevel::HIGH, limit: 50)
52
+ page.each { |row| puts "#{row.request_id} #{row.suspect_level}" }
53
+ ```
54
+
55
+ 4. **Verify a webhook.**
56
+
57
+ ```ruby
58
+ class FingerlyWebhooksController < ActionController::API
59
+ def create
60
+ payload = request.raw_post
61
+
62
+ valid = Fingerly::Webhooks.verify(
63
+ secret: ENV.fetch("FINGERLY_WEBHOOK_SECRET"),
64
+ payload: payload,
65
+ timestamp: request.headers["x-fingerly-timestamp"],
66
+ signature: request.headers["x-fingerly-signature"]
67
+ )
68
+ return head :bad_request unless valid
69
+
70
+ event = Fingerly::Webhooks.parse(payload)
71
+ # Hand the work to your own job queue here, deduplicating on event.id.
72
+ Rails.logger.info("Fingerly webhook #{event.id} (#{event.type})")
73
+ head :no_content
74
+ end
75
+ end
76
+ ```
77
+
78
+ ```ruby
79
+ # config/routes.rb
80
+ post "/webhooks/fingerly", to: "fingerly_webhooks#create"
81
+ ```
82
+
83
+ Full guide: [docs.fingerly.io/docs/sdks/ruby](https://docs.fingerly.io/docs/sdks/ruby).
84
+
85
+ ## Choose what you need
86
+
87
+ | I want to | Use | Read |
88
+ | --- | --- | --- |
89
+ | Read an event after the browser identified a visitor | `Fingerly::Client` and `events.get` / `events.list` | [Read events](#read-events) |
90
+ | Let one event back one backend action | `events.verify` and `events.consume` | [Verify a backend action](#verify-a-backend-action) |
91
+ | Read or write an iOS device's DeviceCheck bits | `device_check.query` / `device_check.write` | [DeviceCheck bits](#devicecheck-bits) |
92
+ | Check a webhook delivery is genuine | `Fingerly::Webhooks.verify` and `.parse` | [Verify webhooks](#verify-webhooks) |
93
+ | Keep the browser SDK first-party, away from content blockers | `Fingerly::Proxy`, a Rack middleware | [First-party proxy](#first-party-proxy-same-origin) |
94
+
95
+ On this page: [Read events](#read-events) · [DeviceCheck bits](#devicecheck-bits) · [Verify webhooks](#verify-webhooks) · [First-party proxy](#first-party-proxy-same-origin) · [Threads, fibers and deadlines](#threads-fibers-and-deadlines) · [Requirements](#requirements) · [Development](#development-and-release-preparation) · [Documentation](#documentation) · [Help](#help) · [Licence](#licence)
96
+
97
+ ## Read events
2
98
 
3
- Server-side event reads, webhook verification and a same-origin proxy for
4
- Ruby.
5
-
6
- ```ruby
7
- gem "fingerly", "~> 0.1"
8
- ```
99
+ Event reads require `fly_sk_{production|staging|development}_` keys. Requests
100
+ go to `https://api.fingerly.io`; `endpoint:` overrides that with a bare
101
+ `https` origin, scheme, host and an optional port. A path, query, fragment,
102
+ credentials, whitespace, a control character or plain `http` is a
103
+ `ConfigurationError`, and the message never repeats the value. For a local
104
+ test API, `allow_insecure_loopback: true` accepts `http://127.0.0.1`,
105
+ `http://localhost` and `http://[::1]` (with any port); leave it off in
106
+ production. Public, proxy, management, malformed and unsupported keys are rejected
107
+ before network access, by the constructor rather than by the first call.
108
+ Requests do not follow redirects. `get` and `list` each perform one request
109
+ and never retry.
9
110
 
10
- ```ruby
11
- require "fingerly"
111
+ ### Unscored events
12
112
 
13
- fingerly = Fingerly::Client.new(secret_key: ENV.fetch("FINGERLY_SECRET_KEY"))
113
+ `event.suspect_score` is `nil` when the request was not scored. Never read nil
114
+ as zero: a visitor about whom nothing fired scores 0, while a submission that
115
+ was never enriched has no score at all. `scored?` states the distinction at
116
+ the call site.
14
117
 
15
- request_id = ARGV.fetch(0) # the requestId the browser SDK's identify() returned
16
- event = fingerly.events.get(request_id)
17
- page = fingerly.events.list(level: "high", limit: 50)
18
- page.each { |row| puts "#{row.request_id} #{row.suspect_level}" }
118
+ ```ruby
119
+ unless event.scored?
120
+ # Decide on something else; do not treat it as clean.
121
+ end
19
122
  ```
20
123
 
21
- Event reads require `fly_sk_{production|staging|development}_` keys. Requests
22
- go to `https://api.fingerly.io`; `endpoint:` overrides that for a local
23
- API. Public, proxy, management, malformed and unsupported keys are rejected
24
- before network access, by the constructor rather than by the first call.
25
- Requests do not follow redirects. `get` and `list` each perform one request
26
- and never retry.
124
+ `event.raw` keeps the response body exactly as it arrived, so a field the API
125
+ adds later is reachable without a gem upgrade.
27
126
 
28
- Requires Ruby 3.2+, which is what the gemspec declares, and fiber-scheduler
29
- support below needs nothing newer. No runtime dependencies: everything it
30
- needs is in the standard library. Rack is a contract rather than a
31
- dependency, so the proxy speaks it without loading it and cannot pin a version
32
- against your own.
127
+ `event.project_id` is the UUID string of the Fingerly project the event
128
+ belongs to, on both `events.get` and `events.list` rows; it is `nil` when an
129
+ older server does not send it.
33
130
 
34
- ## There is no asynchronous client, and none is needed
131
+ ### Read an event you just identified
35
132
 
36
- The Python SDK ships two clients because ASGI and WSGI are two live server
37
- standards, and a blocking call inside FastAPI stalls its event loop. Ruby has
38
- one server interface, Rack, and every framework on it calls your application
39
- synchronously.
133
+ An event is usually readable as soon as identification answers. If it is
134
+ still being recorded, the read raises a `Fingerly::APIError` whose `pending?`
135
+ is true and whose `retry_after` says when to read again:
40
136
 
41
- The stack that is not thread-per-request is covered anyway. On Ruby 3.2+,
42
- the floor this gem requires, `Net::HTTP` yields to a fiber scheduler, so under
43
- Falcon or the `async` gem the blocking reads in this SDK hand the thread back
44
- to the scheduler rather than holding it. Concurrent calls overlap without a
45
- second API to choose between, and there are tests asserting exactly that under
46
- both a fiber scheduler and plain threads.
137
+ ```ruby
138
+ # Returns the event, or nil while it is still being recorded.
139
+ def read_event(fingerly, request_id)
140
+ fingerly.events.get(request_id)
141
+ rescue Fingerly::APIError => e
142
+ raise unless e.pending?
47
143
 
48
- Where there is no fiber scheduler, a call holds its thread until it answers,
49
- for at most `timeout:`. That is what Puma and Unicorn expect. Do not call the
50
- client from an event loop that is not a fiber scheduler, such as an
51
- EventMachine reactor: there it would stall every connection the loop serves.
144
+ # Not recorded yet, so nothing is decided: read again after e.retry_after
145
+ # seconds (2 when nil), or verify asynchronously.
146
+ nil
147
+ end
148
+ ```
52
149
 
53
- Size the thread pool for the slow case, not the average one: while Fingerly is
54
- slow, every proxied request holds its thread for the whole `timeout:`. At 100
55
- proxied requests a second with 1% of them running into a 5 second timeout, that
56
- is 5 threads busy on average, before any fast request is served. Run more
57
- threads than that across your Puma or Unicorn workers, lower `timeout:` for the
58
- proxy, or serve with Falcon, where a waiting call holds no thread.
150
+ Retry a pending read a bounded number of times, for example from a background
151
+ job. `event_not_found?` means a request id that was never issued, or one past
152
+ retention, and is never pending.
59
153
 
60
- ## Deadlines
154
+ The archived document arrives moments after the event itself, so check
155
+ `has_document?` rather than assuming it is there, and read `event.document`
156
+ (`Hash` or `nil`, holding allow-listed `risk`, `attestation`, `ip_network` and
157
+ `velocity` fields without raw signals, user agent or address). When a submission
158
+ is unidentifiable (`identifiable == false`, such as insufficient entropy, a
159
+ genuine embedded WebView, or an unmatched high-risk Web payload),
160
+ `event.visitor_id` is `""`; there are no `deferred_token`, `deferred_signals` or
161
+ `supplements` fields in `v: 3`.
162
+
163
+ Compare fields against the named constants rather than raw strings. Each is
164
+ the frozen wire string itself, so `event.suspect_level ==
165
+ Fingerly::SuspectLevel::HIGH` is an ordinary string comparison, and every field
166
+ stays a `String`: a value the server adds later arrives unchanged, and is only
167
+ missing from the module's frozen `ALL` array.
168
+
169
+ | Module | Field | Values |
170
+ | --- | --- | --- |
171
+ | `Fingerly::Signal` | `EventTrigger#signal`, `#group` | every signal group and detector, such as `VPN`, `VPN_PUBLIC` and `FINGERPRINT_SUPPRESSED` |
172
+ | `Fingerly::SuspectLevel` | `Event#suspect_level`, webhook `data["level"]` | `LOW`, `MEDIUM`, `HIGH` |
173
+ | `Fingerly::Confidence` | `EventTrigger#confidence` | `LOW`, `MEDIUM`, `HIGH` |
174
+ | `Fingerly::EventState` | `Event#state` | `ENRICHED`, `UNAVAILABLE`, and `PENDING`, which a read raises as `pending?` |
175
+ | `Fingerly::Environment` | `Event#environment` | `PRODUCTION`, `STAGING`, `DEVELOPMENT` |
176
+ | `Fingerly::Platform` | `Event#platform` | `WEB`, `ANDROID`, `IOS` |
177
+ | `Fingerly::AnonymityNetwork` | `Event#anonymity_network` | `TOR`, `RELAY`, `VPN`, `PROXY`, `HOSTING` |
178
+ | `Fingerly::DeviceKind` | `Event#device_kind` | `DESKTOP`, `MOBILE`, `TABLET`, `SERVER` |
179
+ | `Fingerly::VisitorKind` | `Event#visitor_kind` | `HUMAN`, `AI_BOT`, `AUTOMATION`, `SEARCH_CRAWLER` |
180
+ | `Fingerly::AttestationState` | `event.document["attestation"]["state"]` | `ATTESTED`, `NOT_ATTESTED`, `FAILED` |
181
+ | `Fingerly::AttestationStatus` | `event.document["attestation"]["status"]` | `VERIFIED`, `INDETERMINATE`, `INVALID`, `ABSENT`, `UNCONFIGURED` |
182
+ | `Fingerly::AttestSkippedReason` | `event.document["attestation"]["attest_skipped"]` | `NOT_OFFERED`, `UNSUPPORTED`, `CHALLENGE_UNAVAILABLE`, `KEY_ERROR`, `TIMEOUT`, `BACKOFF`, `INSTALL_UNAVAILABLE` |
183
+ | `Fingerly::VerifyReason` | `EventVerification#reason` | `OK` (`""`) and the failures in [Verify a backend action](#verify-a-backend-action) |
184
+ | `Fingerly::WebhookEventType` | `WebhookEvent#type` | see [Verify webhooks](#verify-webhooks) |
185
+ | `Fingerly::WebhookEnvironment` | `WebhookEvent#environment` | `LIVE`, `TEST` |
186
+
187
+ A constant's name is its value upper-cased, with `.` as `_` (`VerifyReason::OK` is `""`). Event reads report
188
+ each trigger under its signal group (`Fingerly::Signal::VPN`), while
189
+ `visitor.suspect` webhooks and the archived document's `risk.triggers` carry
190
+ the detector (`Fingerly::Signal::VPN_PUBLIC`) with its group beside it. Inside
191
+ `module Fingerly`, `Signal` names `Fingerly::Signal`; write `::Signal` for
192
+ Ruby's own. The `SIGNAL_*` constants on `Fingerly::EventTrigger` and its
193
+ `V3_SIGNALS` list are the same strings.
194
+
195
+ ### Verify a backend action
196
+
197
+ `fingerly.events.verify` reads the event with the server-only key, checks
198
+ that it can back the action, and consumes it, so one event backs one
199
+ decision:
61
200
 
62
- `timeout:` bounds the whole exchange: connecting, sending, the response
63
- headers and the body.
201
+ ```ruby
202
+ def authorize_checkout(fingerly, request_id)
203
+ result = fingerly.events.verify(request_id, tag: "checkout") # max_age_seconds: 300, consume: true
204
+ return "refuse" unless result.ok? # result.reason names the failed check
64
205
 
65
- That takes care on this platform. `Net::HTTP` has `open_timeout`,
66
- `read_timeout` and `write_timeout`, but each bounds a single operation: a
67
- server that answers and then sends one byte a second would satisfy all three
68
- forever, and so would one that sends a header line a second, because each
69
- header line gets the full read timeout. The client shrinks the socket's own
70
- timeouts to whatever is left of the deadline before each step, and one
71
- `Timeout` around the whole exchange covers the header lines, so the bound is
72
- tight rather than a multiple of the timeout. Under a fiber scheduler that
73
- `Timeout` is the scheduler's own.
206
+ # The score policy is yours: verify never judges the score.
207
+ result.event.suspect_level == Fingerly::SuspectLevel::LOW ? "allow" : "review"
208
+ rescue Fingerly::APIError => e
209
+ return "retry later" if e.pending? # not decided yet: read again after e.retry_after
74
210
 
75
- Idle connections are kept in one pool per process and destination, shared by
76
- every client and proxy in it. `Net::HTTP` cannot be used by two threads or
77
- fibers at once, so each exchange checks a connection out and hands it back
78
- when it is done: a burst of a few hundred concurrent requests reuses its
79
- sockets rather than opening one each, and a fiber that ends (Falcon runs one
80
- per client connection) returns its socket instead of stranding it. At most
81
- 256 idle connections are kept per destination. A connection is reopened after
82
- 60 seconds, so DNS is asked again, and dropped after 15 seconds idle. One the
83
- other end closed while it was idle is reopened and the request sent again,
84
- but only for `GET`, because a `POST` that may already have arrived must never
85
- be sent twice. A forked worker starts with an empty pool.
211
+ raise
212
+ end
213
+ ```
86
214
 
87
- ## Errors
215
+ The checks run in this order and stop at the first failure, whose wire string
216
+ is `result.reason` (`""` when `result.ok?`), with a constant on
217
+ `Fingerly::VerifyReason` (also on `Fingerly::EventVerification`):
218
+
219
+ 1. `not_found` (`NOT_FOUND`): the request id was never issued, or the event is
220
+ past retention. `result.event` is `nil` for this reason only.
221
+ 2. `too_old` (`TOO_OLD`): the event occurred more than `max_age_seconds`
222
+ ago (300 by default), or carries no readable `occurred_at`.
223
+ 3. `tag_mismatch` (`TAG_MISMATCH`): `tag:` was given and the event's tag is not
224
+ exactly it. Without `tag:` nothing is compared; an empty tag raises
225
+ `Fingerly::ConfigurationError`.
226
+ 4. `unidentifiable` (`UNIDENTIFIABLE`): `event.visitor_id` is empty.
227
+ 5. `unscored` (`UNSCORED`): the event has no suspect score.
228
+ 6. `already_consumed` (`ALREADY_CONSUMED`): another call consumed the event
229
+ first.
230
+
231
+ The consume runs last, only when every other check passed, so a failed check
232
+ leaves the event unused. Pass `consume: false` to check without consuming. An
233
+ invalid option raises `Fingerly::ConfigurationError` before anything is sent.
234
+ Any other failure raises as it does for `events.get`. A pending event
235
+ (`pending?`) is not a verdict: retry after `retry_after` seconds or verify
236
+ asynchronously, rather than refusing the action.
237
+
238
+ `fingerly.events.consume(request_id)` is the consume on its own. It returns a
239
+ `Fingerly::EventConsumption` (`request_id`, `consumed_at`, `first?`) the first
240
+ time, is never retried, and raises `Fingerly::EventAlreadyConsumedError`, a
241
+ `Fingerly::APIError` with `event_already_consumed?` true and the first
242
+ `consumed_at`, every time after.
243
+
244
+ Do not authorize an action using scores or visitor identifiers supplied by the
245
+ browser. Tags correlate events; they do not replace your application's
246
+ authentication. A tag must never hold a personal identifier, such as a user
247
+ ID, email, install ID or advertising ID, because the server keeps tags in
248
+ long-lived rollups.
249
+
250
+ ### Errors
88
251
 
89
252
  Every runtime failure derives from `Fingerly::Error`. A bad option raises
90
253
  `Fingerly::ConfigurationError`, which is an `ArgumentError`: a key that was
@@ -94,7 +257,10 @@ call site can help with.
94
257
  ```ruby
95
258
  def decide(fingerly, request_id)
96
259
  event = fingerly.events.get(request_id)
97
- event.scored? && event.suspect_level == "low" ? "allow" : "review"
260
+ return "review" if event.visitor_id.empty? || !event.scored?
261
+ return "refuse" if event.triggers.any? { |t| t.signal == Fingerly::Signal::ATTESTATION_FAILED }
262
+
263
+ event.suspect_level == Fingerly::SuspectLevel::LOW ? "allow" : "review"
98
264
  rescue Fingerly::APIError => e
99
265
  return "retry later" if e.pending? # not decided yet: read again after e.retry_after
100
266
  return "refuse" if e.event_not_found?
@@ -104,134 +270,147 @@ rescue Fingerly::APIError => e
104
270
  end
105
271
  ```
106
272
 
107
- Every response outside 2xx, a redirect included, raises `Fingerly::APIError`.
108
- It carries `status`, and optional `code`, `details`, `request_id` and
109
- `retry_after`. The secret key is stripped from the first three, and the
110
- response body is never echoed. `request_id` falls back to the `x-request-id`
111
- header when the body is not an error envelope. `retry_after` is the
112
- `Retry-After` header in whole seconds, from either of its forms, or `nil`
273
+ | Error | Raised when |
274
+ | --- | --- |
275
+ | `Fingerly::ConfigurationError` (an `ArgumentError`) | A bad option, such as a key that was never valid. |
276
+ | `Fingerly::APIError` | Every response outside 2xx, a redirect included. Carries `status`, and optional `code`, `details`, `request_id` and `retry_after`. |
277
+ | `Fingerly::TimeoutError` | The deadline (`timeout:`) passed. |
278
+ | `Fingerly::ConnectionError` | The API is unreachable. |
279
+
280
+ On `APIError`, the secret key is stripped from the first three of those
281
+ fields, and the response body is never echoed. `request_id` falls back to the
282
+ `x-request-id` header when the body is not an error envelope. `retry_after` is
283
+ the `Retry-After` header in whole seconds, from either of its forms, or `nil`
113
284
  when there was none: on a `429` or a pending event, wait that long before
114
285
  reading again.
115
286
 
116
287
  A read answers `404` with one of two codes, each with its own predicate:
117
288
 
118
- - `pending?`: `event_pending`, the request id was accepted and the event is
119
- still being recorded. Nothing is decided yet: read again after
120
- `retry_after` seconds (the API sends `Retry-After: 2`), or verify
121
- asynchronously. Do not treat it as fraud.
122
- - `event_not_found?`: `event_not_found`, the request id was never issued, or
123
- the event is past retention.
289
+ | Predicate | Code | Meaning |
290
+ | --- | --- | --- |
291
+ | `pending?` | `event_pending` | The request id was accepted and the event is still being recorded. Nothing is decided yet: read again after `retry_after` seconds (the API sends `Retry-After: 2`), or verify asynchronously. Do not treat it as fraud. |
292
+ | `event_not_found?` | `event_not_found` | The request id was never issued, or the event is past retention. |
124
293
 
125
- The client never retries by itself. A deadline raises
126
- `Fingerly::TimeoutError`; an unreachable API raises
127
- `Fingerly::ConnectionError`.
294
+ The client never retries an event read by itself; only a
295
+ [DeviceCheck](#devicecheck-bits) call retries, and only the same request.
128
296
 
129
297
  No object in the SDK shows a credential. A client or proxy printed with
130
298
  `inspect`, `to_s`, `pp`, `to_json` or YAML shows `[redacted]` in place of its
131
299
  key, and `Marshal.dump` refuses it. The request handed to `client_ip` hides the
132
300
  visitor's cookies and authorization header the same way.
133
301
 
134
- ## Unscored events
302
+ ## DeviceCheck bits
135
303
 
136
- `event.suspect_score` is `nil` when the request was not scored. Never read nil
137
- as zero: a visitor about whom nothing fired scores 0, while a submission that
138
- was never enriched has no score at all. `scored?` states the distinction at
139
- the call site.
304
+ On iOS, Apple keeps two DeviceCheck bits per device for your developer team,
305
+ and they survive a reinstall. When DeviceCheck is on for the project's Apple
306
+ key, Fingerly holds the DeviceCheck token that came with an identification for
307
+ one hour, and your backend spends it once:
140
308
 
141
309
  ```ruby
142
- unless event.scored?
143
- # Decide on something else; do not treat it as clean.
144
- end
145
- ```
310
+ bits = fingerly.device_check.query(request_id) # Fingerly::DeviceCheckBits
311
+ bits.found # false when Apple holds no bits for the device yet
312
+ bits.bit0 # true or false
313
+ bits.last_update # "YYYY-MM", or nil when Apple holds no bits
146
314
 
147
- `event.raw` keeps the response body exactly as it arrived, so a field the API
148
- adds later is reachable without a gem upgrade.
315
+ written = fingerly.device_check.write(request_id, bit0: true) # Fingerly::DeviceCheckWrite
316
+ written.bit0 # true; a bit left out is nil, and keeps its value at Apple
317
+ ```
149
318
 
150
- `event.project_id` is the UUID string of the Fingerly project the event
151
- belongs to, on both `events.get` and `events.list` rows; it is `nil` when an
152
- older server does not send it.
319
+ Apple treats each DeviceCheck token as single-use, so one event pays for one
320
+ call: a read or a write, never both. A flow that checks and then marks a
321
+ device, such as a once-per-device free trial, takes two identifications:
153
322
 
154
- ## Read an event you just identified
155
-
156
- An event is usually readable as soon as identification answers. If it is
157
- still being recorded, the read raises a `Fingerly::APIError` whose `pending?`
158
- is true and whose `retry_after` says when to read again:
323
+ 1. Query on the identification that asks for the trial. If the bits say the
324
+ device already had one, refuse it.
325
+ 2. Otherwise grant the trial and record the grant in your own data.
326
+ 3. Write the bit on the next identification from that install, such as one
327
+ the app makes right after the grant. Until the write lands, your own record
328
+ of the grant is what stops a second trial.
159
329
 
160
330
  ```ruby
161
- # Returns the event, or nil while it is still being recorded.
162
- def read_event(fingerly, request_id)
163
- fingerly.events.get(request_id)
164
- rescue Fingerly::APIError => e
165
- raise unless e.pending?
331
+ # bit0 means "this device has had a free trial". The meaning is yours.
332
+ def start_trial(fingerly, account, request_id)
333
+ bits = begin
334
+ fingerly.device_check.query(request_id)
335
+ rescue Fingerly::DeviceCheckError => e
336
+ raise unless e.not_held? || e.spent? || e.apple_rejected?
337
+
338
+ nil # no answer, not a verdict: decide without the bits
339
+ end
340
+ return "offer-paid-plan" if bits&.bit0
166
341
 
167
- # Not recorded yet, so nothing is decided: read again after e.retry_after
168
- # seconds (2 when nil), or verify asynchronously.
169
- nil
342
+ Trial.grant(account, device_marked: false)
343
+ "granted"
170
344
  end
171
- ```
172
345
 
173
- Retry a pending read a bounded number of times, for example from a background
174
- job. `event_not_found?` means a request id that was never issued, or one past
175
- retention, and is never pending.
176
-
177
- The archived document arrives moments after the event itself, so check
178
- `has_document?` rather than assuming it is there.
179
-
180
- ## Verify a backend action
346
+ def mark_trial(fingerly, account, request_id)
347
+ fingerly.device_check.write(request_id, bit0: true)
348
+ Trial.update(account, device_marked: true)
349
+ rescue Fingerly::DeviceCheckError => e
350
+ raise unless e.not_held? || e.spent?
351
+ # Keep device_marked false and write at the install's next identification.
352
+ end
353
+ ```
181
354
 
182
- Read the event with a server-only key. Check that its tag matches your action,
183
- that it is recent, that its environment is correct, and that it was scored.
184
- Apply your own policy to the server's verdict. A pending event (`pending?`)
185
- is not a verdict: retry after `retry_after` seconds or verify asynchronously,
186
- rather than refusing the action. Do not authorize an action using scores or
187
- visitor identifiers supplied by the browser. Tags correlate events; they do
188
- not replace your application's authentication or replay protection. A tag must
189
- never hold a personal identifier, such as a user ID, email, install ID or
190
- advertising ID, because the server keeps tags in long-lived rollups.
355
+ A failure raises `Fingerly::DeviceCheckError`, a `Fingerly::APIError` with a
356
+ predicate per code:
357
+
358
+ | Status | Code | Predicate |
359
+ |---|---|---|
360
+ | 404 | `device_check_not_held` | `not_held?` |
361
+ | 409 | `device_check_spent` | `spent?` |
362
+ | 409 | `device_check_busy` | `busy?` |
363
+ | 409 | `credential_unavailable` | `credential_unavailable?` |
364
+ | 422 | `bits_required` | `bits_required?` |
365
+ | 422 | `apple_rejected` | `apple_rejected?`, with Apple's HTTP status in `apple_status` |
366
+ | 503 | `device_check_unavailable` | `unavailable?` |
367
+
368
+ A write that names neither bit raises `Fingerly::ConfigurationError` before
369
+ anything is sent.
370
+
371
+ The token may be retried only with the same request. After a `503` or a
372
+ transport failure the token is kept, so the client sends the identical request
373
+ again, up to three attempts in all; it retries nothing else. If you retry
374
+ later yourself, repeat the same call with the same bits: a read after a failed
375
+ write, or a write with other bits, answers `409 device_check_spent`. Apple asks
376
+ that DeviceCheck is never the only fraud check, and that users have a way to
377
+ have the bits reset.
378
+
379
+ ## Verify webhooks
380
+
381
+ The controller and route are in [Getting started](#getting-started). Verify the
382
+ exact raw bytes before parsing them. `request.raw_post` is those bytes; a body
383
+ reconstructed from parsed parameters is not.
384
+
385
+ | Behaviour | Detail |
386
+ | --- | --- |
387
+ | What a signature covers | the timestamp and the body |
388
+ | Replay tolerance | five minutes by default |
389
+ | Secret rotation | any matching signature in the comma-separated header is accepted; only the first 32 are read |
390
+ | Malformed or missing input | a false result, never an exception; a body that is not valid UTF-8 verifies rather than raising on concatenation |
391
+ | Deduplication | persist processed `id` values to deduplicate deliveries |
191
392
 
192
- ## Webhooks
393
+ `WebhookEvent#data` stays a plain `Hash`, so a new event type needs no gem
394
+ upgrade. Dispatch on `event.type` with `Fingerly::WebhookEventType`:
193
395
 
194
396
  ```ruby
195
- class FingerlyWebhooksController < ActionController::API
196
- def create
197
- payload = request.raw_post
198
-
199
- valid = Fingerly::Webhooks.verify(
200
- secret: ENV.fetch("FINGERLY_WEBHOOK_SECRET"),
201
- payload: payload,
202
- timestamp: request.headers["x-fingerly-timestamp"],
203
- signature: request.headers["x-fingerly-signature"]
204
- )
205
- return head :bad_request unless valid
206
-
207
- event = Fingerly::Webhooks.parse(payload)
208
- # Hand the work to your own job queue here, deduplicating on event.id.
209
- Rails.logger.info("Fingerly webhook #{event.id} (#{event.type})")
210
- head :no_content
211
- end
397
+ case event.type
398
+ when Fingerly::WebhookEventType::VISITOR_SUSPECT # sent for SuspectLevel::HIGH only
399
+ review(event.data["request_id"])
400
+ when Fingerly::WebhookEventType::IDENTIFICATION_COMPLETED,
401
+ Fingerly::WebhookEventType::IDENTIFICATION_REFUSED
402
+ record(event.data)
403
+ when Fingerly::WebhookEventType::WEBHOOK_TEST
404
+ nil # sent to one endpoint on request; nobody subscribes to it
212
405
  end
213
406
  ```
214
407
 
215
- ```ruby
216
- # config/routes.rb
217
- post "/webhooks/fingerly", to: "fingerly_webhooks#create"
218
- ```
219
-
220
- Verify the exact raw bytes before parsing them. `request.raw_post` is those
221
- bytes; a body reconstructed from parsed parameters is not. Signatures cover
222
- the timestamp and body. The default replay tolerance is five minutes; persist
223
- processed `id` values to deduplicate deliveries. During signing-secret
224
- rotation, any matching signature in the comma-separated header is accepted;
225
- only the first 32 are read.
226
- Malformed or missing input is a false result, never an exception, and a body
227
- that is not valid UTF-8 verifies rather than raising on concatenation.
228
-
229
- `WebhookEvent#data` stays a plain `Hash`, so a new event type needs no gem
230
- upgrade. `identification.completed` and `visitor.suspect` deliveries carry the
408
+ The other types are `BILLING_STATUS_CHANGED` (`billing.status_changed`) and
409
+ `USAGE_DAILY_SETTLED` (`usage.daily_settled`). `identification.completed` and `visitor.suspect` deliveries carry the
231
410
  event's project as `data["project_id"]`; `identification.refused` carries it
232
411
  only when the refused request named a known key.
233
412
 
234
- ## Same-origin proxy
413
+ ## First-party proxy (same-origin)
235
414
 
236
415
  Content blockers refuse browser requests to third-party APIs, and a refused
237
416
  identification is a visitor never identified. Mount the proxy on a path of
@@ -275,8 +454,21 @@ Put it first, ahead of authentication: the browser SDK sends no cookies and
275
454
  carries no user, and a filter that redirected it to a sign-in page would break
276
455
  identification for every signed-out visitor.
277
456
 
278
- Then point the browser SDK at the same path. Both of its calls go there, with
279
- nothing appended:
457
+ > **`client_ip` is the one thing you must get right.** Resolve it from a
458
+ > header your own infrastructure sets, such as your load balancer's or CDN's,
459
+ > and fall back to `request.peer_host`, the TCP peer, when it is absent, as in
460
+ > local development. Trust that header only when traffic can reach your
461
+ > application through that CDN alone; otherwise a visitor can set it. Never read
462
+ > the left-most `X-Forwarded-For` value: the visitor writes it.
463
+
464
+ `client_ip` must return exactly one IPv4 or IPv6 address. Anything else, `nil`
465
+ or an empty string, a list, a port, a prefix length, or an exception, is a
466
+ configuration mistake: the proxy sends nothing upstream, answers `500` with
467
+ "The client IP callback returned no valid address", and logs it once per
468
+ process rather than once per visitor.
469
+
470
+ Then point the client SDK at the same path. Browser and proxied native SDKs post
471
+ a single `v: 3` identification envelope there, with nothing appended:
280
472
 
281
473
  ```ts
282
474
  import { load } from '@fingerly/web-js'
@@ -284,65 +476,52 @@ import { load } from '@fingerly/web-js'
284
476
  const fingerly = await load({ apiKey: 'fly_pk_…', endpoints: '/k7x2qm4a' })
285
477
  ```
286
478
 
287
- `path` is optional where the framework already routes the path to the proxy,
288
- as a Rails `mount` or a `Rack::URLMap` entry does. Omit it there: the mount has
289
- already moved the path into `SCRIPT_NAME`. A mount matches a prefix, but the
290
- proxy still answers only the mount's exact path: `/k7x2qm4a/admin` or
291
- `/k7x2qm4a/` routed to it get `404`. Rails hands a mount the same `PATH_INFO`
292
- with and without a trailing slash, so the proxy tells them apart by the raw
293
- request line in `REQUEST_URI`, which Puma and Falcon provide.
294
-
295
- ```ruby
296
- # config/routes.rb
297
- mount Fingerly::Proxy.new(
298
- proxy_key: ENV.fetch("FINGERLY_PROXY_KEY"),
299
- client_ip: ->(request) { request.header("CF-Connecting-IP") || request.peer_host }
300
- ) => "/k7x2qm4a"
301
- ```
302
-
303
- As middleware it sees every request in the stack, so there `path` is required
304
- and its absence is a `ConfigurationError` at start-up.
479
+ `proxy_key` and `path` are required. A proxy key that is not
480
+ `fly_px_<environment>_...` for `production`, `staging` or `development`, or a
481
+ missing `path`, is a `ConfigurationError` at start-up. The proxy matches it
482
+ exactly against `PATH_INFO`, so use it as middleware, as above, or run it as
483
+ the whole application. Do not put it behind a Rails `mount` or a
484
+ `Rack::URLMap` entry: those move the path into `SCRIPT_NAME`, and the proxy
485
+ then sees a path that is not its own and answers `404`.
305
486
 
306
487
  ### What the proxy does
307
488
 
308
- It answers only the configured path, matched exactly and case-sensitively:
309
- `/k7x2qm4a/`, `//k7x2qm4a`, `/k7x2qm4a/.`, `/k7x2qm4a%2F` and `/k7x2qm4a/admin`
310
- are not its own. Anything else is passed along to
311
- your application, or answered `404` when the proxy has no application behind
312
- it. On its own path, anything but `POST` gets `405`. Every request it accepts
313
- goes to one URL, `https://api.fingerly.io/api/v1/ingest`, which tells the
314
- identification from the report that follows it by the body. Nothing else is
315
- reachable through it, event reads included: they need a secret key and stay
316
- unreachable from a browser by construction. `api_version:` changes only the
317
- version in that URL.
318
-
319
- The browser must present a public key from the same environment as the proxy
320
- key, or the request gets `401`. Bodies over 1 MiB get `413`,
321
- enforced while reading rather than after buffering. That bounds what the proxy
322
- holds. A server that buffers the whole request before calling the application,
323
- as Puma does, has already read it by then, so bound request bodies there with
324
- the server's or the load balancer's own limit as well. Falcon streams the body,
325
- so there the proxy stops reading at the limit. Only the content type, the
326
- visitor metadata Fingerly needs, and an `Idempotency-Key` are forwarded;
327
- customer cookies and authorization headers never are. The proxy reports itself
328
- upstream as `ruby/0.2.0` in `x-fingerly-proxy-version`, which the dashboard
329
- shows per proxy.
330
-
331
- When Fingerly cannot be reached, the visitor gets a gateway error rather than
332
- your application's `500`: `504 Gateway timeout` when `timeout:` (5 seconds by
333
- default) passes, and `502 Bad gateway` for anything else, whether the
334
- connection was refused or reset, the name did not resolve, or the answer was
335
- malformed, cut short or over 4 MiB. The whole answer is read before anything
336
- is written back, so a truncated response is never relayed as a success. Each
337
- failure logs one line, without a stack trace, to `logger:` when you pass one,
338
- to `rack.logger` when your server provides it, and to standard error
339
- otherwise.
340
-
341
- Only `content-type`, `x-request-id`, `ratelimit-limit`, `ratelimit-remaining`
342
- and `retry-after` are relayed back, plus `cache-control: no-store` set by the
343
- proxy. A content blocker can match a response header by name, and an
344
- allowlist keeps anything that names Fingerly off the response, whatever the
345
- API adds later.
489
+ | Rule | Behaviour |
490
+ | --- | --- |
491
+ | Path match | Only the configured path, matched exactly and case-sensitively: `/k7x2qm4a/`, `//k7x2qm4a`, `/k7x2qm4a/.`, `/k7x2qm4a%2F`, `/k7x2qm4a/admin` and retired `/supplement` paths are not its own. Anything else is passed along to your application, or answered `404` when the proxy has no application behind it. |
492
+ | Other methods | On its own path, anything but `POST` (plus `OPTIONS` when `allowed_origins:` is configured) gets `405`. Methods are compared exactly, so `post` gets `405` too. |
493
+ | Own answers | Every answer the proxy writes itself carries `cache-control: no-store`. |
494
+ | Upstream | Every request it accepts goes verbatim as raw bytes to one URL, `https://api.fingerly.io/api/v1/ingest`. `api_version:` changes only the version in that URL. |
495
+ | Event reads | Nothing else is reachable through it, event reads included: they need a secret key and stay unreachable from a browser by construction. |
496
+ | Public key | The caller must present a public key (`fly_pk_...`) from the same environment as the proxy key, or the request gets `401` and nothing is forwarded; a secret key is refused the same way. |
497
+ | Credentials upstream | Every request carries the proxy key as `X-Fingerly-Proxy-Key` and the caller's public key as `X-API-Key`, never a secret key. |
498
+ | Origin or platform | Requests without either `Origin` or a validated native `X-Fingerly-SDK-Platform` header (`ios`, `android`, `react-native`, `react-native-ios`, `react-native-android`, `flutter`, `flutter-ios`, `flutter-android`, `lynx-ios`, `lynx-android`, `capacitor`, `kotlin-multiplatform`) are rejected locally with `400` (`missing_origin`), and `x-fingerly-origin` is never synthesized from `Host`, `Referer` or the request URL. A request is forwarded on one channel only: with an `Origin` the proxy sends `x-fingerly-origin` and drops the platform header, and without one it sends the validated platform. |
499
+ | Body size | Bodies over 1 MiB get `413`, enforced while reading rather than after buffering. |
500
+ | Forwarded headers | All incoming `x-fingerly-*`, `cookie` and `authorization` headers are stripped, restoring only a validated `x-fingerly-sdk-platform` (when there is no `Origin`) alongside `x-fingerly-host`, `idempotency-key`, `sec-fetch-*` and `sec-ch-ua-*`. |
501
+ | Proxy identity | The proxy reports itself upstream as `ruby/0.4.0` in `x-fingerly-proxy-version`, which the dashboard shows per proxy. |
502
+ | Fingerly unreachable | The visitor gets a gateway error rather than your application's `500`. |
503
+ | Deadline passes | `504 Gateway timeout` when `timeout:` (5 seconds by default) passes. |
504
+ | Any other upstream failure | `502 Bad gateway`, whether the connection was refused or reset, the name did not resolve, or the answer was malformed, cut short or over 4 MiB. Redirects are never followed, and an upstream redirect or a status outside `200` to `599` is answered `502` as well. |
505
+ | Truncated answers | The whole answer is read before anything is written back, so a truncated response is never relayed as a success. |
506
+ | Failure logging | Each failure logs one line, without a stack trace, to `logger:` when you pass one, to `rack.logger` when your server provides it, and to standard error otherwise. The line names the kind of failure only, never the upstream address or a key. |
507
+ | Relayed back | Only `content-type`, `x-request-id`, `ratelimit-limit`, `ratelimit-remaining` and `retry-after`, plus `cache-control: no-store` set by the proxy. A content blocker can match a response header by name, and an allowlist keeps anything that names Fingerly off the response, whatever the API adds later. |
508
+ | Header shape | Relayed headers are lowercase and repeats joined with `", "`, which is the one shape Rack 2 and Rack 3 both accept: Rack 3 refuses an uppercase name outright, and Rack 2 refuses the array Rack 3 would rather have. |
509
+
510
+ The 1 MiB limit bounds what the proxy holds. A server that buffers the whole
511
+ request before calling the application, as Puma does, has already read it by
512
+ then, so bound request bodies there with the server's or the load balancer's own
513
+ limit as well. Falcon streams the body, so there the proxy stops reading at the
514
+ limit.
515
+
516
+ `upstream:` takes a bare origin, scheme, host and an optional port, such as
517
+ `https://api.fingerly.io`. A path, query, fragment, credentials, whitespace or
518
+ a control character is a `ConfigurationError`, and so is plain `http`. For a
519
+ local test API, `allow_insecure_loopback: true` accepts `http://127.0.0.1`,
520
+ `http://localhost` and `http://[::1]` (with any port), and nothing else; leave
521
+ it off in production.
522
+
523
+ <details>
524
+ <summary>Why the middleware decides from the path alone, and what <code>path</code> means</summary>
346
525
 
347
526
  The middleware decides from the path alone before it reads anything. It sees
348
527
  every request in the stack, and reading the body to find out whether one
@@ -356,25 +535,81 @@ means the same thing wherever the application is deployed. Use the one the
356
535
  dashboard issued rather than inventing one: blockers look for words such as
357
536
  `fingerprint`, `tracking` and `analytics` in a path.
358
537
 
359
- Relayed headers are lowercase and repeats joined with `", "`, which is the
360
- one shape Rack 2 and Rack 3 both accept: Rack 3 refuses an uppercase name
361
- outright, and Rack 2 refuses the array Rack 3 would rather have.
538
+ </details>
362
539
 
363
- > **`client_ip` is the one thing you must get right.** Resolve it from a
364
- > header your own infrastructure sets, such as your load balancer's or CDN's,
365
- > and fall back to `request.peer_host`, the TCP peer, when it is absent, as in
366
- > local development. Trust that header only when traffic can reach your
367
- > application through that CDN alone; otherwise a visitor can set it. Never read
368
- > the left-most `X-Forwarded-For` value: the visitor writes it.
540
+ ## Threads, fibers and deadlines
369
541
 
370
- `client_ip` must return exactly one IPv4 or IPv6 address. Anything else, `nil`
371
- or an empty string, a list, a port, a prefix length, or an exception, is a
372
- configuration mistake: the proxy sends nothing upstream, answers `500` with
373
- "The client IP callback returned no valid address", and logs it once per
374
- process rather than once per visitor.
542
+ There is no asynchronous client, and none is needed.
543
+
544
+ The Python SDK ships two clients because ASGI and WSGI are two live server
545
+ standards, and a blocking call inside FastAPI stalls its event loop. Ruby has
546
+ one server interface, Rack, and every framework on it calls your application
547
+ synchronously.
548
+
549
+ The stack that is not thread-per-request is covered anyway. On Ruby 3.2+,
550
+ the floor this gem requires, `Net::HTTP` yields to a fiber scheduler, so under
551
+ Falcon or the `async` gem the blocking reads in this SDK hand the thread back
552
+ to the scheduler rather than holding it. Concurrent calls overlap without a
553
+ second API to choose between, and there are tests asserting exactly that under
554
+ both a fiber scheduler and plain threads.
555
+
556
+ Where there is no fiber scheduler, a call holds its thread until it answers,
557
+ for at most `timeout:`. That is what Puma and Unicorn expect. Do not call the
558
+ client from an event loop that is not a fiber scheduler, such as an
559
+ EventMachine reactor: there it would stall every connection the loop serves.
560
+
561
+ Size the thread pool for the slow case, not the average one: while Fingerly is
562
+ slow, every proxied request holds its thread for the whole `timeout:`. At 100
563
+ proxied requests a second with 1% of them running into a 5 second timeout, that
564
+ is 5 threads busy on average, before any fast request is served. Run more
565
+ threads than that across your Puma or Unicorn workers, lower `timeout:` for the
566
+ proxy, or serve with Falcon, where a waiting call holds no thread.
567
+
568
+ ### Deadlines
569
+
570
+ `timeout:` bounds the whole exchange: connecting, sending, the response
571
+ headers and the body.
572
+
573
+ That takes care on this platform. `Net::HTTP` has `open_timeout`,
574
+ `read_timeout` and `write_timeout`, but each bounds a single operation: a
575
+ server that answers and then sends one byte a second would satisfy all three
576
+ forever, and so would one that sends a header line a second, because each
577
+ header line gets the full read timeout. The client shrinks the socket's own
578
+ timeouts to whatever is left of the deadline before each step, and one
579
+ `Timeout` around the whole exchange covers the header lines, so the bound is
580
+ tight rather than a multiple of the timeout. Under a fiber scheduler that
581
+ `Timeout` is the scheduler's own.
582
+
583
+ ### Connection pool
584
+
585
+ Idle connections are kept in one pool per process and destination, shared by
586
+ every client and proxy in it. `Net::HTTP` cannot be used by two threads or
587
+ fibers at once, so each exchange checks a connection out and hands it back
588
+ when it is done: a burst of a few hundred concurrent requests reuses its
589
+ sockets rather than opening one each, and a fiber that ends (Falcon runs one
590
+ per client connection) returns its socket instead of stranding it.
591
+
592
+ | Pool rule | Value |
593
+ | --- | --- |
594
+ | Idle connections kept | at most 256 per destination |
595
+ | Reopened after | 60 seconds, so DNS is asked again |
596
+ | Dropped after | 15 seconds idle |
597
+ | Closed while idle by the other end | reopened and the request sent again, but only for `GET`, because a `POST` that may already have arrived must never be sent twice |
598
+ | Forked worker | starts with an empty pool |
599
+
600
+ ## Requirements
601
+
602
+ Ruby 3.2+, which is what the gemspec declares (`required_ruby_version >= 3.2.0`),
603
+ and fiber-scheduler support needs nothing newer. CI runs Ruby 3.2, 3.3 and 3.4.
604
+ No runtime dependencies: everything it needs is in the standard library. Rack is
605
+ a contract rather than a dependency, so the proxy speaks it without loading it
606
+ and cannot pin a version against your own.
375
607
 
376
608
  ## Development and release preparation
377
609
 
610
+ <details>
611
+ <summary>Tests, signatures, contract snapshot, release, source structure</summary>
612
+
378
613
  ```sh
379
614
  bundle install
380
615
  bundle exec rake # tests, RuboCop and the RBS signatures
@@ -400,7 +635,7 @@ separate check step. Never put production secrets in fixtures.
400
635
  The gemspec sets `allowed_push_host` to RubyGems, so a push to any other host
401
636
  is refused.
402
637
 
403
- ## Source structure
638
+ ### Source structure
404
639
 
405
640
  `Client` holds the connection and the options; `Events` owns the reads and the
406
641
  list filters, and `Event`, `EventPage` and `EventTrigger` are what they speak
@@ -408,3 +643,22 @@ in. `Webhooks` verifies signatures. `Proxy` holds every proxy decision, with
408
643
  `ProxyRequest` as the shape `client_ip` is given. `Config` validates every
409
644
  caller-supplied option before any network access, and `Transport` is the one
410
645
  place that knows how to bound an exchange and reuse a socket.
646
+
647
+ </details>
648
+
649
+ ## Documentation
650
+
651
+ - [Ruby SDK guide](https://docs.fingerly.io/docs/sdks/ruby)
652
+ - [Webhooks](https://docs.fingerly.io/docs/webhooks)
653
+ - [Proxy integrations](https://docs.fingerly.io/docs/proxy-integrations)
654
+ - [API reference](https://docs.fingerly.io/reference/overview)
655
+
656
+ ## Help
657
+
658
+ Open an issue on [this repository](https://github.com/fingerly-io/sdk-ruby/issues), or write to
659
+ [support@fingerly.io](mailto:support@fingerly.io). Report security issues to
660
+ [security@fingerly.io](mailto:security@fingerly.io).
661
+
662
+ ## Licence
663
+
664
+ Apache-2.0. See [LICENSE](https://github.com/fingerly-io/sdk-ruby/blob/main/LICENSE).