fingerly 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7182eecce3bcb7d6d9ed8babc37422f6f2498a207906d8057dfdf6775545abdf
4
- data.tar.gz: 2dce022007bb882a80b0fde3c0fa57dbe7c97b1bd152b0d70b74c5fa21ecaae5
3
+ metadata.gz: 7d7f4cd60e48fb2080ce2dd2bdae50abd2e91b8af61c6409147c0ec09dc8becb
4
+ data.tar.gz: 7d5d627df6c78aebcb2938a9e4c6d18beee6be193dd3f7db583d80081eaee906
5
5
  SHA512:
6
- metadata.gz: 63cd4ba409c61117334625003a580411637fa51f0560c05ace89c89db190794a704b0c3d01cf628f11bebabd45848b4c4ceab3a4741cee6c0ca9c4e4652abb61
7
- data.tar.gz: c846c1af6a65a1f07524c3f12c955f2c0c63816c62eee2b7e86571600b9635dd9c4a0b08185a6d4c065437a9fc19646fb1b5dfefc79831b85eec3ae4b643929d
6
+ metadata.gz: 99e047e7a7902bf0a72b2d48994a25e1a4eb3f2d38935a292c4d06a4c35b45360465741b15590a3c76f82a88f3eb680c642863a526d885670396ef792959cd57
7
+ data.tar.gz: 21134cd3e6d92708da44002ec84fdfec40a4e208988860657b959540f83a9c71222060e38d3d0eb650f8263519d94798a0ba21527b5b113a4c76e301f3b541d3
data/README.md CHANGED
@@ -36,7 +36,7 @@ device behind each session and scores how suspicious it is.
36
36
  2. **Install.** Add it to your `Gemfile`:
37
37
 
38
38
  ```ruby
39
- gem "fingerly", "~> 0.3.0"
39
+ gem "fingerly", "~> 0.4.0"
40
40
  ```
41
41
 
42
42
  3. **Read an event.**
@@ -48,7 +48,7 @@ device behind each session and scores how suspicious it is.
48
48
 
49
49
  request_id = ARGV.fetch(0) # the requestId the browser SDK's identify() returned
50
50
  event = fingerly.events.get(request_id)
51
- page = fingerly.events.list(level: "high", limit: 50)
51
+ page = fingerly.events.list(level: Fingerly::SuspectLevel::HIGH, limit: 50)
52
52
  page.each { |row| puts "#{row.request_id} #{row.suspect_level}" }
53
53
  ```
54
54
 
@@ -160,19 +160,37 @@ genuine embedded WebView, or an unmatched high-risk Web payload),
160
160
  `event.visitor_id` is `""`; there are no `deferred_token`, `deferred_signals` or
161
161
  `supplements` fields in `v: 3`.
162
162
 
163
- `Fingerly::EventTrigger::V3_SIGNALS` groups the `v: 3` anti-spoofing and
164
- integrity signal constants on `Fingerly::EventTrigger`:
165
- `SIGNAL_ATTESTATION_FAILED` (`"attestation_failed"`),
166
- `SIGNAL_ATTESTATION_DOWNGRADE` (`"attestation_downgrade"`),
167
- `SIGNAL_DEVICE_INCONSISTENT` (`"device_inconsistent"`),
168
- `SIGNAL_REPORT_INCOMPLETE` (`"report_incomplete"`),
169
- `SIGNAL_PROBE_ERRORS` (`"probe_errors"`),
170
- `SIGNAL_FETCH_METADATA_MISSING` (`"fetch_metadata_missing"`),
171
- `SIGNAL_WEB_TICKET_MISSING` (`"web_ticket_missing"`),
172
- `SIGNAL_WEB_TICKET_INVALID` (`"web_ticket_invalid"`),
173
- `SIGNAL_TAMPERING` (`"tampering"`),
174
- `SIGNAL_CUSTOM_ROOT_CA` (`"custom_root_ca"`) and
175
- `SIGNAL_SECONDARY_USER_PROFILE` (`"secondary_user_profile"`).
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.
176
194
 
177
195
  ### Verify a backend action
178
196
 
@@ -186,7 +204,7 @@ def authorize_checkout(fingerly, request_id)
186
204
  return "refuse" unless result.ok? # result.reason names the failed check
187
205
 
188
206
  # The score policy is yours: verify never judges the score.
189
- result.event.suspect_level == "low" ? "allow" : "review"
207
+ result.event.suspect_level == Fingerly::SuspectLevel::LOW ? "allow" : "review"
190
208
  rescue Fingerly::APIError => e
191
209
  return "retry later" if e.pending? # not decided yet: read again after e.retry_after
192
210
 
@@ -196,7 +214,7 @@ end
196
214
 
197
215
  The checks run in this order and stop at the first failure, whose wire string
198
216
  is `result.reason` (`""` when `result.ok?`), with a constant on
199
- `Fingerly::EventVerification`:
217
+ `Fingerly::VerifyReason` (also on `Fingerly::EventVerification`):
200
218
 
201
219
  1. `not_found` (`NOT_FOUND`): the request id was never issued, or the event is
202
220
  past retention. `result.event` is `nil` for this reason only.
@@ -240,9 +258,9 @@ call site can help with.
240
258
  def decide(fingerly, request_id)
241
259
  event = fingerly.events.get(request_id)
242
260
  return "review" if event.visitor_id.empty? || !event.scored?
243
- return "refuse" if event.triggers.any? { |t| t.signal == Fingerly::EventTrigger::SIGNAL_ATTESTATION_FAILED }
261
+ return "refuse" if event.triggers.any? { |t| t.signal == Fingerly::Signal::ATTESTATION_FAILED }
244
262
 
245
- event.suspect_level == "low" ? "allow" : "review"
263
+ event.suspect_level == Fingerly::SuspectLevel::LOW ? "allow" : "review"
246
264
  rescue Fingerly::APIError => e
247
265
  return "retry later" if e.pending? # not decided yet: read again after e.retry_after
248
266
  return "refuse" if e.event_not_found?
@@ -373,7 +391,22 @@ reconstructed from parsed parameters is not.
373
391
  | Deduplication | persist processed `id` values to deduplicate deliveries |
374
392
 
375
393
  `WebhookEvent#data` stays a plain `Hash`, so a new event type needs no gem
376
- upgrade. `identification.completed` and `visitor.suspect` deliveries carry the
394
+ upgrade. Dispatch on `event.type` with `Fingerly::WebhookEventType`:
395
+
396
+ ```ruby
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
405
+ end
406
+ ```
407
+
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
377
410
  event's project as `data["project_id"]`; `identification.refused` carries it
378
411
  only when the refused request named a known key.
379
412
 
@@ -465,7 +498,7 @@ then sees a path that is not its own and answers `404`.
465
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. |
466
499
  | Body size | Bodies over 1 MiB get `413`, enforced while reading rather than after buffering. |
467
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-*`. |
468
- | Proxy identity | The proxy reports itself upstream as `ruby/0.3.0` in `x-fingerly-proxy-version`, which the dashboard shows per proxy. |
501
+ | Proxy identity | The proxy reports itself upstream as `ruby/0.4.0` in `x-fingerly-proxy-version`, which the dashboard shows per proxy. |
469
502
  | Fingerly unreachable | The visitor gets a gateway error rather than your application's `500`. |
470
503
  | Deadline passes | `504 Gateway timeout` when `timeout:` (5 seconds by default) passes. |
471
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. |
@@ -0,0 +1,282 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Named constants for the closed string sets the API sends.
4
+ #
5
+ # Every constant is the frozen wire string itself, so it compares equal to the
6
+ # field it names (+event.suspect_level == Fingerly::SuspectLevel::HIGH+) and
7
+ # the fields stay plain strings. A value the server adds after this SDK was
8
+ # released still arrives unchanged; it is only missing from +ALL+.
9
+ #
10
+ # Each module's +ALL+ is a frozen array of its values, in the order listed.
11
+ module Fingerly
12
+ # Identifiers a trigger's +signal+ (and +group+) can hold.
13
+ #
14
+ # Event reads report each trigger under its signal group, such as +vpn+;
15
+ # +visitor.suspect+ webhooks and the archived document's +risk.triggers+
16
+ # carry the detector, such as +vpn_public+, with its group beside it. Many
17
+ # groups share their detector's name, so each identifier is here once.
18
+ #
19
+ # Inside +module Fingerly+, this constant shadows Ruby's own +::Signal+.
20
+ module Signal
21
+ # Detectors every platform can produce.
22
+ HIGH_ACTIVITY = "high_activity"
23
+ TAMPERING = "tampering"
24
+ DEVICE_FARM = "device_farm"
25
+ DEVELOPER_TOOLS = "developer_tools"
26
+ GEO_MISMATCH = "geo_mismatch"
27
+ DEVICE_INCONSISTENT = "device_inconsistent"
28
+
29
+ # Detectors derived from the address a submission arrived from.
30
+ TOR = "tor"
31
+ PROXY = "proxy"
32
+ RESIDENTIAL_PROXY = "residential_proxy"
33
+ RESIDENTIAL_PROXY_LOW_CONFIDENCE = "residential_proxy_low_confidence"
34
+ RESIDENTIAL_PROXY_MEDIUM_CONFIDENCE = "residential_proxy_medium_confidence"
35
+ RESIDENTIAL_PROXY_HIGH_CONFIDENCE = "residential_proxy_high_confidence"
36
+ VPN_PUBLIC = "vpn_public"
37
+ VPN_TIMEZONE = "vpn_timezone"
38
+ VPN_RELAY = "vpn_relay"
39
+ VPN_MOBILE = "vpn_mobile"
40
+ VPN_OS_MISMATCH = "vpn_os_mismatch"
41
+ VPN_LOW_CONFIDENCE = "vpn_low_confidence"
42
+ VPN_MEDIUM_CONFIDENCE = "vpn_medium_confidence"
43
+ VPN_HIGH_CONFIDENCE = "vpn_high_confidence"
44
+ IP_BLOCKLIST_EMAIL_SPAM = "ip_blocklist_email_spam"
45
+ IP_BLOCKLIST_ATTACK_SOURCE = "ip_blocklist_attack_source"
46
+ IP_ABUSER = "ip_abuser"
47
+ DATACENTER_IP = "datacenter_ip"
48
+ BOGON_IP = "bogon_ip"
49
+ ANYCAST_IP = "anycast_ip"
50
+
51
+ # Detectors only a browser can produce.
52
+ INCOGNITO = "incognito"
53
+ BAD_BOT = "bad_bot"
54
+ AUTOMATION = "automation"
55
+ FETCH_METADATA_MISSING = "fetch_metadata_missing"
56
+ WEB_TICKET_MISSING = "web_ticket_missing"
57
+ WEB_TICKET_INVALID = "web_ticket_invalid"
58
+ ANTIDETECT_BROWSER = "antidetect_browser"
59
+ VIRTUAL_MACHINE = "virtual_machine"
60
+ FINGERPRINT_SUPPRESSED = "fingerprint_suppressed"
61
+ PRIVACY_SETTINGS = "privacy_settings"
62
+ EMBEDDED_WEB_VIEW = "embedded_web_view"
63
+ REMOTE_CONTROL = "remote_control"
64
+
65
+ # Detectors only a native application can produce.
66
+ EMULATOR = "emulator"
67
+ ROOT_APPS = "root_apps"
68
+ APP_CLONER = "app_cloner"
69
+ JAILBREAK = "jailbreak"
70
+ SIMULATOR = "simulator"
71
+ FRIDA = "frida"
72
+ MITM_ATTACK = "mitm_attack"
73
+ ACTIVE_CALL = "active_call"
74
+ ATTESTATION_MISSING = "attestation_missing"
75
+ ATTESTATION_DOWNGRADE = "attestation_downgrade"
76
+ REPEATED_REINSTALL = "repeated_reinstall"
77
+ DEVICE_ACTIVITY_HIGH = "device_activity_high"
78
+ DEVICE_ACTIVITY_VERY_HIGH = "device_activity_very_high"
79
+ PLAY_DEVICE_INTEGRITY_FAILED = "play_device_integrity_failed"
80
+ PLAY_APP_UNRECOGNIZED = "play_app_unrecognized"
81
+ ATTESTATION_FAILED = "attestation_failed"
82
+ REPORT_INCOMPLETE = "report_incomplete"
83
+ PROBE_ERRORS = "probe_errors"
84
+ CUSTOM_ROOT_CA = "custom_root_ca"
85
+ SECONDARY_USER_PROFILE = "secondary_user_profile"
86
+
87
+ # Signal groups whose name is not also a detector's.
88
+ DATACENTER_PROXY = "datacenter_proxy"
89
+ VPN = "vpn"
90
+ IP_BLOCKLIST = "ip_blocklist"
91
+ IP_REPUTATION = "ip_reputation"
92
+ NETWORK_ANOMALY = "network_anomaly"
93
+ LOCATION_SPOOFING = "location_spoofing"
94
+ IOS_SIMULATOR = "ios_simulator"
95
+ ANDROID_EMULATOR = "android_emulator"
96
+ JAILBROKEN_DEVICE = "jailbroken_device"
97
+ ROOTED_DEVICE = "rooted_device"
98
+ CLONED_APP = "cloned_app"
99
+ FRIDA_DETECTED = "frida_detected"
100
+ BROWSER_TAMPERING = "browser_tampering"
101
+ BOT = "bot"
102
+ INCOGNITO_MODE = "incognito_mode"
103
+
104
+ ALL = [
105
+ HIGH_ACTIVITY, TAMPERING, DEVICE_FARM, DEVELOPER_TOOLS, GEO_MISMATCH, DEVICE_INCONSISTENT,
106
+ TOR, PROXY, RESIDENTIAL_PROXY, RESIDENTIAL_PROXY_LOW_CONFIDENCE,
107
+ RESIDENTIAL_PROXY_MEDIUM_CONFIDENCE, RESIDENTIAL_PROXY_HIGH_CONFIDENCE, VPN_PUBLIC,
108
+ VPN_TIMEZONE, VPN_RELAY, VPN_MOBILE, VPN_OS_MISMATCH, VPN_LOW_CONFIDENCE,
109
+ VPN_MEDIUM_CONFIDENCE, VPN_HIGH_CONFIDENCE, IP_BLOCKLIST_EMAIL_SPAM,
110
+ IP_BLOCKLIST_ATTACK_SOURCE, IP_ABUSER, DATACENTER_IP, BOGON_IP, ANYCAST_IP, INCOGNITO,
111
+ BAD_BOT, AUTOMATION, FETCH_METADATA_MISSING, WEB_TICKET_MISSING, WEB_TICKET_INVALID,
112
+ ANTIDETECT_BROWSER, VIRTUAL_MACHINE, FINGERPRINT_SUPPRESSED, PRIVACY_SETTINGS,
113
+ EMBEDDED_WEB_VIEW, REMOTE_CONTROL, EMULATOR, ROOT_APPS, APP_CLONER, JAILBREAK, SIMULATOR,
114
+ FRIDA, MITM_ATTACK, ACTIVE_CALL, ATTESTATION_MISSING, ATTESTATION_DOWNGRADE,
115
+ REPEATED_REINSTALL, DEVICE_ACTIVITY_HIGH, DEVICE_ACTIVITY_VERY_HIGH,
116
+ PLAY_DEVICE_INTEGRITY_FAILED, PLAY_APP_UNRECOGNIZED, ATTESTATION_FAILED, REPORT_INCOMPLETE,
117
+ PROBE_ERRORS, CUSTOM_ROOT_CA, SECONDARY_USER_PROFILE, DATACENTER_PROXY, VPN, IP_BLOCKLIST,
118
+ IP_REPUTATION, NETWORK_ANOMALY, LOCATION_SPOOFING, IOS_SIMULATOR, ANDROID_EMULATOR,
119
+ JAILBROKEN_DEVICE, ROOTED_DEVICE, CLONED_APP, FRIDA_DETECTED, BROWSER_TAMPERING, BOT,
120
+ INCOGNITO_MODE
121
+ ].freeze
122
+ end
123
+
124
+ # An event's +suspect_level+, and the +level+ of identification webhooks:
125
+ # the score, banded.
126
+ module SuspectLevel
127
+ LOW = "low"
128
+ MEDIUM = "medium"
129
+ HIGH = "high"
130
+
131
+ ALL = [LOW, MEDIUM, HIGH].freeze
132
+ end
133
+
134
+ # How sure a detection is: {EventTrigger#confidence}.
135
+ module Confidence
136
+ LOW = "low"
137
+ MEDIUM = "medium"
138
+ HIGH = "high"
139
+
140
+ ALL = [LOW, MEDIUM, HIGH].freeze
141
+ end
142
+
143
+ # The server's verdict on a native event's hardware evidence: the archived
144
+ # document's +attestation.state+.
145
+ module AttestationState
146
+ ATTESTED = "attested"
147
+ NOT_ATTESTED = "not_attested"
148
+ FAILED = "failed"
149
+
150
+ ALL = [ATTESTED, NOT_ATTESTED, FAILED].freeze
151
+ end
152
+
153
+ # The detail behind {AttestationState}: the archived document's
154
+ # +attestation.status+.
155
+ module AttestationStatus
156
+ VERIFIED = "verified"
157
+ INDETERMINATE = "indeterminate"
158
+ INVALID = "invalid"
159
+ ABSENT = "absent"
160
+ UNCONFIGURED = "unconfigured"
161
+
162
+ ALL = [VERIFIED, INDETERMINATE, INVALID, ABSENT, UNCONFIGURED].freeze
163
+ end
164
+
165
+ # Why a native app sent no attestation: the archived document's
166
+ # +attestation.attest_skipped+. Diagnostic only; it never lowers the score.
167
+ module AttestSkippedReason
168
+ NOT_OFFERED = "not_offered"
169
+ UNSUPPORTED = "unsupported"
170
+ CHALLENGE_UNAVAILABLE = "challenge_unavailable"
171
+ KEY_ERROR = "key_error"
172
+ TIMEOUT = "timeout"
173
+ BACKOFF = "backoff"
174
+ INSTALL_UNAVAILABLE = "install_unavailable"
175
+
176
+ ALL = [
177
+ NOT_OFFERED, UNSUPPORTED, CHALLENGE_UNAVAILABLE, KEY_ERROR, TIMEOUT, BACKOFF,
178
+ INSTALL_UNAVAILABLE
179
+ ].freeze
180
+ end
181
+
182
+ # Why +fingerly.events.verify+ refused an event: {EventVerification#reason}.
183
+ # +OK+ is the +""+ of an event that passed; the failures follow in the order
184
+ # the checks run.
185
+ module VerifyReason
186
+ OK = ""
187
+ NOT_FOUND = "not_found"
188
+ TOO_OLD = "too_old"
189
+ TAG_MISMATCH = "tag_mismatch"
190
+ UNIDENTIFIABLE = "unidentifiable"
191
+ UNSCORED = "unscored"
192
+ ALREADY_CONSUMED = "already_consumed"
193
+
194
+ ALL = [OK, NOT_FOUND, TOO_OLD, TAG_MISMATCH, UNIDENTIFIABLE, UNSCORED, ALREADY_CONSUMED].freeze
195
+ end
196
+
197
+ # A webhook delivery's {WebhookEvent#type}. +WEBHOOK_TEST+ is sent to one
198
+ # endpoint on request and cannot be subscribed to.
199
+ module WebhookEventType
200
+ IDENTIFICATION_COMPLETED = "identification.completed"
201
+ IDENTIFICATION_REFUSED = "identification.refused"
202
+ VISITOR_SUSPECT = "visitor.suspect"
203
+ BILLING_STATUS_CHANGED = "billing.status_changed"
204
+ USAGE_DAILY_SETTLED = "usage.daily_settled"
205
+ WEBHOOK_TEST = "webhook.test"
206
+
207
+ ALL = [
208
+ IDENTIFICATION_COMPLETED, IDENTIFICATION_REFUSED, VISITOR_SUSPECT, BILLING_STATUS_CHANGED,
209
+ USAGE_DAILY_SETTLED, WEBHOOK_TEST
210
+ ].freeze
211
+ end
212
+
213
+ # A webhook delivery's {WebhookEvent#environment}.
214
+ module WebhookEnvironment
215
+ LIVE = "live"
216
+ TEST = "test"
217
+
218
+ ALL = [LIVE, TEST].freeze
219
+ end
220
+
221
+ # An event's +state+: enriched, or unavailable when the network lookup
222
+ # could not run. +PENDING+ is accepted and not yet written; an event read
223
+ # answers it as a pending error rather than as an event.
224
+ module EventState
225
+ PENDING = "pending"
226
+ ENRICHED = "enriched"
227
+ UNAVAILABLE = "unavailable"
228
+
229
+ ALL = [PENDING, ENRICHED, UNAVAILABLE].freeze
230
+ end
231
+
232
+ # The environment an event was recorded in: {Event}'s +environment+.
233
+ module Environment
234
+ PRODUCTION = "production"
235
+ STAGING = "staging"
236
+ DEVELOPMENT = "development"
237
+
238
+ ALL = [PRODUCTION, STAGING, DEVELOPMENT].freeze
239
+ end
240
+
241
+ # The scoring profile an event was scored under: {Event}'s +platform+.
242
+ # +sdk_platform+ is what the SDK called itself and is not limited to these.
243
+ module Platform
244
+ WEB = "web"
245
+ ANDROID = "android"
246
+ IOS = "ios"
247
+
248
+ ALL = [WEB, ANDROID, IOS].freeze
249
+ end
250
+
251
+ # The anonymity network an event's address belongs to: {Event}'s
252
+ # +anonymity_network+, nil on an ordinary connection.
253
+ module AnonymityNetwork
254
+ TOR = "tor"
255
+ RELAY = "relay"
256
+ VPN = "vpn"
257
+ PROXY = "proxy"
258
+ HOSTING = "hosting"
259
+
260
+ ALL = [TOR, RELAY, VPN, PROXY, HOSTING].freeze
261
+ end
262
+
263
+ # What the fingerprint was taken on: {Event}'s +device_kind+.
264
+ module DeviceKind
265
+ DESKTOP = "desktop"
266
+ MOBILE = "mobile"
267
+ TABLET = "tablet"
268
+ SERVER = "server"
269
+
270
+ ALL = [DESKTOP, MOBILE, TABLET, SERVER].freeze
271
+ end
272
+
273
+ # What is behind a submission: {Event}'s +visitor_kind+.
274
+ module VisitorKind
275
+ HUMAN = "human"
276
+ AI_BOT = "ai_bot"
277
+ AUTOMATION = "automation"
278
+ SEARCH_CRAWLER = "search_crawler"
279
+
280
+ ALL = [HUMAN, AI_BOT, AUTOMATION, SEARCH_CRAWLER].freeze
281
+ end
282
+ end
@@ -4,20 +4,22 @@ require "time"
4
4
 
5
5
  module Fingerly
6
6
  # One signal group that contributed to an event's suspect score.
7
+ #
8
+ # The +SIGNAL_*+ constants are the same strings as {Signal}'s.
7
9
  class EventTrigger
8
- SIGNAL_ATTESTATION_FAILED = "attestation_failed"
9
- SIGNAL_ATTESTATION_MISSING = "attestation_missing"
10
- SIGNAL_ATTESTATION_DOWNGRADE = "attestation_downgrade"
11
- SIGNAL_DEVICE_INCONSISTENT = "device_inconsistent"
12
- SIGNAL_REPORT_INCOMPLETE = "report_incomplete"
13
- SIGNAL_PROBE_ERRORS = "probe_errors"
14
- SIGNAL_FETCH_METADATA_MISSING = "fetch_metadata_missing"
15
- SIGNAL_WEB_TICKET_MISSING = "web_ticket_missing"
16
- SIGNAL_WEB_TICKET_INVALID = "web_ticket_invalid"
17
- SIGNAL_TAMPERING = "tampering"
18
- SIGNAL_BROWSER_TAMPERING = "browser_tampering"
19
- SIGNAL_CUSTOM_ROOT_CA = "custom_root_ca"
20
- SIGNAL_SECONDARY_USER_PROFILE = "secondary_user_profile"
10
+ SIGNAL_ATTESTATION_FAILED = Signal::ATTESTATION_FAILED
11
+ SIGNAL_ATTESTATION_MISSING = Signal::ATTESTATION_MISSING
12
+ SIGNAL_ATTESTATION_DOWNGRADE = Signal::ATTESTATION_DOWNGRADE
13
+ SIGNAL_DEVICE_INCONSISTENT = Signal::DEVICE_INCONSISTENT
14
+ SIGNAL_REPORT_INCOMPLETE = Signal::REPORT_INCOMPLETE
15
+ SIGNAL_PROBE_ERRORS = Signal::PROBE_ERRORS
16
+ SIGNAL_FETCH_METADATA_MISSING = Signal::FETCH_METADATA_MISSING
17
+ SIGNAL_WEB_TICKET_MISSING = Signal::WEB_TICKET_MISSING
18
+ SIGNAL_WEB_TICKET_INVALID = Signal::WEB_TICKET_INVALID
19
+ SIGNAL_TAMPERING = Signal::TAMPERING
20
+ SIGNAL_BROWSER_TAMPERING = Signal::BROWSER_TAMPERING
21
+ SIGNAL_CUSTOM_ROOT_CA = Signal::CUSTOM_ROOT_CA
22
+ SIGNAL_SECONDARY_USER_PROFILE = Signal::SECONDARY_USER_PROFILE
21
23
 
22
24
  V3_SIGNALS = [
23
25
  SIGNAL_ATTESTATION_FAILED,
@@ -33,13 +35,14 @@ module Fingerly
33
35
  SIGNAL_SECONDARY_USER_PROFILE
34
36
  ].freeze
35
37
 
36
- # @return [String, nil] the signal or signal group, such as +vpn+ or +attestation_failed+
38
+ # @return [String, nil] the signal or signal group, such as +vpn+ or
39
+ # +attestation_failed+; see {Signal}
37
40
  attr_reader :signal
38
41
  # @return [String, nil] optional group identifier when returned alongside a raw signal
39
42
  attr_reader :group
40
43
  # @return [Integer] the group's combined weight in this score
41
44
  attr_reader :weight
42
- # @return [String, nil] +low+, +medium+ or +high+
45
+ # @return [String, nil] +low+, +medium+ or +high+; see {Confidence}
43
46
  attr_reader :confidence
44
47
 
45
48
  # @api private
@@ -194,17 +197,17 @@ module Fingerly
194
197
  # The answer of +fingerly.events.verify+.
195
198
  #
196
199
  # {#reason} is +""+ when {#ok?}, and otherwise the first check that failed,
197
- # as one of the wire strings below. The score is not checked: apply your own
200
+ # as one of the {VerifyReason} strings. The score is not checked: apply your own
198
201
  # policy to {#event} after {#ok?}.
199
202
  class EventVerification
200
- NOT_FOUND = "not_found"
201
- TOO_OLD = "too_old"
202
- TAG_MISMATCH = "tag_mismatch"
203
- UNIDENTIFIABLE = "unidentifiable"
204
- UNSCORED = "unscored"
205
- ALREADY_CONSUMED = "already_consumed"
206
-
207
- # Every reason, in the order the checks run.
203
+ NOT_FOUND = VerifyReason::NOT_FOUND
204
+ TOO_OLD = VerifyReason::TOO_OLD
205
+ TAG_MISMATCH = VerifyReason::TAG_MISMATCH
206
+ UNIDENTIFIABLE = VerifyReason::UNIDENTIFIABLE
207
+ UNSCORED = VerifyReason::UNSCORED
208
+ ALREADY_CONSUMED = VerifyReason::ALREADY_CONSUMED
209
+
210
+ # Every failure reason, in the order the checks run.
208
211
  REASONS = [NOT_FOUND, TOO_OLD, TAG_MISMATCH, UNIDENTIFIABLE, UNSCORED, ALREADY_CONSUMED].freeze
209
212
 
210
213
  # @return [Boolean] whether every check passed
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Fingerly
4
4
  # The SDK version, reported to the API on every request.
5
- VERSION = "0.3.0"
5
+ VERSION = "0.4.0"
6
6
  end
data/lib/fingerly.rb CHANGED
@@ -4,6 +4,7 @@ require_relative "fingerly/version"
4
4
  require_relative "fingerly/errors"
5
5
  require_relative "fingerly/redacted"
6
6
  require_relative "fingerly/config"
7
+ require_relative "fingerly/enums"
7
8
  require_relative "fingerly/models"
8
9
  require_relative "fingerly/transport"
9
10
  require_relative "fingerly/client"
data/sig/fingerly.rbs CHANGED
@@ -74,6 +74,197 @@ module Fingerly
74
74
  class ConnectionError < Error
75
75
  end
76
76
 
77
+ module Signal
78
+ HIGH_ACTIVITY: String
79
+ TAMPERING: String
80
+ DEVICE_FARM: String
81
+ DEVELOPER_TOOLS: String
82
+ GEO_MISMATCH: String
83
+ DEVICE_INCONSISTENT: String
84
+ TOR: String
85
+ PROXY: String
86
+ RESIDENTIAL_PROXY: String
87
+ RESIDENTIAL_PROXY_LOW_CONFIDENCE: String
88
+ RESIDENTIAL_PROXY_MEDIUM_CONFIDENCE: String
89
+ RESIDENTIAL_PROXY_HIGH_CONFIDENCE: String
90
+ VPN_PUBLIC: String
91
+ VPN_TIMEZONE: String
92
+ VPN_RELAY: String
93
+ VPN_MOBILE: String
94
+ VPN_OS_MISMATCH: String
95
+ VPN_LOW_CONFIDENCE: String
96
+ VPN_MEDIUM_CONFIDENCE: String
97
+ VPN_HIGH_CONFIDENCE: String
98
+ IP_BLOCKLIST_EMAIL_SPAM: String
99
+ IP_BLOCKLIST_ATTACK_SOURCE: String
100
+ IP_ABUSER: String
101
+ DATACENTER_IP: String
102
+ BOGON_IP: String
103
+ ANYCAST_IP: String
104
+ INCOGNITO: String
105
+ BAD_BOT: String
106
+ AUTOMATION: String
107
+ FETCH_METADATA_MISSING: String
108
+ WEB_TICKET_MISSING: String
109
+ WEB_TICKET_INVALID: String
110
+ ANTIDETECT_BROWSER: String
111
+ VIRTUAL_MACHINE: String
112
+ FINGERPRINT_SUPPRESSED: String
113
+ PRIVACY_SETTINGS: String
114
+ EMBEDDED_WEB_VIEW: String
115
+ REMOTE_CONTROL: String
116
+ EMULATOR: String
117
+ ROOT_APPS: String
118
+ APP_CLONER: String
119
+ JAILBREAK: String
120
+ SIMULATOR: String
121
+ FRIDA: String
122
+ MITM_ATTACK: String
123
+ ACTIVE_CALL: String
124
+ ATTESTATION_MISSING: String
125
+ ATTESTATION_DOWNGRADE: String
126
+ REPEATED_REINSTALL: String
127
+ DEVICE_ACTIVITY_HIGH: String
128
+ DEVICE_ACTIVITY_VERY_HIGH: String
129
+ PLAY_DEVICE_INTEGRITY_FAILED: String
130
+ PLAY_APP_UNRECOGNIZED: String
131
+ ATTESTATION_FAILED: String
132
+ REPORT_INCOMPLETE: String
133
+ PROBE_ERRORS: String
134
+ CUSTOM_ROOT_CA: String
135
+ SECONDARY_USER_PROFILE: String
136
+ DATACENTER_PROXY: String
137
+ VPN: String
138
+ IP_BLOCKLIST: String
139
+ IP_REPUTATION: String
140
+ NETWORK_ANOMALY: String
141
+ LOCATION_SPOOFING: String
142
+ IOS_SIMULATOR: String
143
+ ANDROID_EMULATOR: String
144
+ JAILBROKEN_DEVICE: String
145
+ ROOTED_DEVICE: String
146
+ CLONED_APP: String
147
+ FRIDA_DETECTED: String
148
+ BROWSER_TAMPERING: String
149
+ BOT: String
150
+ INCOGNITO_MODE: String
151
+ ALL: Array[String]
152
+ end
153
+
154
+ module SuspectLevel
155
+ LOW: String
156
+ MEDIUM: String
157
+ HIGH: String
158
+ ALL: Array[String]
159
+ end
160
+
161
+ module Confidence
162
+ LOW: String
163
+ MEDIUM: String
164
+ HIGH: String
165
+ ALL: Array[String]
166
+ end
167
+
168
+ module AttestationState
169
+ ATTESTED: String
170
+ NOT_ATTESTED: String
171
+ FAILED: String
172
+ ALL: Array[String]
173
+ end
174
+
175
+ module AttestationStatus
176
+ VERIFIED: String
177
+ INDETERMINATE: String
178
+ INVALID: String
179
+ ABSENT: String
180
+ UNCONFIGURED: String
181
+ ALL: Array[String]
182
+ end
183
+
184
+ module AttestSkippedReason
185
+ NOT_OFFERED: String
186
+ UNSUPPORTED: String
187
+ CHALLENGE_UNAVAILABLE: String
188
+ KEY_ERROR: String
189
+ TIMEOUT: String
190
+ BACKOFF: String
191
+ INSTALL_UNAVAILABLE: String
192
+ ALL: Array[String]
193
+ end
194
+
195
+ module VerifyReason
196
+ OK: String
197
+ NOT_FOUND: String
198
+ TOO_OLD: String
199
+ TAG_MISMATCH: String
200
+ UNIDENTIFIABLE: String
201
+ UNSCORED: String
202
+ ALREADY_CONSUMED: String
203
+ ALL: Array[String]
204
+ end
205
+
206
+ module WebhookEventType
207
+ IDENTIFICATION_COMPLETED: String
208
+ IDENTIFICATION_REFUSED: String
209
+ VISITOR_SUSPECT: String
210
+ BILLING_STATUS_CHANGED: String
211
+ USAGE_DAILY_SETTLED: String
212
+ WEBHOOK_TEST: String
213
+ ALL: Array[String]
214
+ end
215
+
216
+ module WebhookEnvironment
217
+ LIVE: String
218
+ TEST: String
219
+ ALL: Array[String]
220
+ end
221
+
222
+ module EventState
223
+ PENDING: String
224
+ ENRICHED: String
225
+ UNAVAILABLE: String
226
+ ALL: Array[String]
227
+ end
228
+
229
+ module Environment
230
+ PRODUCTION: String
231
+ STAGING: String
232
+ DEVELOPMENT: String
233
+ ALL: Array[String]
234
+ end
235
+
236
+ module Platform
237
+ WEB: String
238
+ ANDROID: String
239
+ IOS: String
240
+ ALL: Array[String]
241
+ end
242
+
243
+ module AnonymityNetwork
244
+ TOR: String
245
+ RELAY: String
246
+ VPN: String
247
+ PROXY: String
248
+ HOSTING: String
249
+ ALL: Array[String]
250
+ end
251
+
252
+ module DeviceKind
253
+ DESKTOP: String
254
+ MOBILE: String
255
+ TABLET: String
256
+ SERVER: String
257
+ ALL: Array[String]
258
+ end
259
+
260
+ module VisitorKind
261
+ HUMAN: String
262
+ AI_BOT: String
263
+ AUTOMATION: String
264
+ SEARCH_CRAWLER: String
265
+ ALL: Array[String]
266
+ end
267
+
77
268
  class EventTrigger
78
269
  SIGNAL_ATTESTATION_FAILED: String
79
270
  SIGNAL_ATTESTATION_MISSING: String
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fingerly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fingerly
@@ -24,6 +24,7 @@ files:
24
24
  - lib/fingerly.rb
25
25
  - lib/fingerly/client.rb
26
26
  - lib/fingerly/config.rb
27
+ - lib/fingerly/enums.rb
27
28
  - lib/fingerly/errors.rb
28
29
  - lib/fingerly/models.rb
29
30
  - lib/fingerly/proxy.rb