@fingerly/web-js 0.1.2 → 0.3.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.
package/dist/index.d.cts CHANGED
@@ -1,62 +1,78 @@
1
1
  import { Source, SignalOutcome, IntegrityReport, FingerlyClientOptions, FingerlyClient } from '@fingerly/core';
2
- export { Confidence, ConsentError, ConsentState, FingerlyClient, FingerlyEvent, FingerlyWebEvent, IdentifyOptions, IdentifyResult, IntegrityReport, Lie, SOURCE, SignalOutcome, SignalReport, SignalStatus, TransportError, isSuspiciousLevel } from '@fingerly/core';
2
+ export { CollectOptions, Confidence, ConsentError, ConsentState, FingerlyClient, IdentifyOptions, IdentifyResult, IdentifySubmission, IdentifyTrigger, IncognitoDetection, IntegrityReport, Lie, LieKind, RiskSignal, SOURCE, SignalOutcome, SignalReport, SignalStatus, SourceOptIn, SourceStage, SuspectLevel, TransportError, WorkerRealmSignal, isSuspiciousLevel } from '@fingerly/core';
3
3
 
4
4
  /**
5
- * The browser source set.
6
- *
7
- * Order within a tier does not matter - the scheduler runs them concurrently up
8
- * to its cap - but the tier does. `fast` sources are cheap reads that a page
9
- * can afford to block a click on; `deferred` sources render, measure layout or
10
- * await hardware, and are worth having only because the budget bounds them.
5
+ * The single-pass two-stage browser source set (`prerequisite` -> `collect`).
11
6
  */
12
7
 
13
8
  declare const browserSources: readonly Source[];
14
9
 
15
10
  /**
16
- * The tamper layer.
11
+ * Is this page running inside an app?
12
+ *
13
+ * A page inside a customer's own app is the app reading the device. Apple's
14
+ * agreement forbids an app to "derive any data from a device for the purpose
15
+ * of uniquely identifying it", naming the properties of a web browser among
16
+ * that data, so the browser SDK runs no device-fingerprinting source there.
17
+ * Use the iOS or Android SDK in an app instead.
18
+ *
19
+ * What it does collect in an app is the embedded profile
20
+ * (`EMBEDDED_SAFE_SOURCES` in `@fingerly/core`), which exists so the server
21
+ * can tell a genuine app WebView from a desktop or automated browser that
22
+ * claims to be one:
23
+ *
24
+ * - `embedding`: the kind of app detected (`{ kind }`), nothing else.
25
+ * - `engine`, `math`, `errors`: how the JavaScript engine behaves (error
26
+ * message lengths, maths results, CSS support), no device values.
27
+ * - `navigator`: `user_agent`, `platform` and `webdriver` only.
28
+ * - `worker_realm`: the worker's `user_agent` and `platform` only.
29
+ * - `automation`: `webdriver` and the names of automation globals present.
30
+ * - the integrity block: which natives and descriptors were tampered with.
31
+ *
32
+ * Core count, device memory, languages, time zone, plugins, screen, GPU,
33
+ * canvas, audio, fonts and storage are not read in an app.
17
34
  *
18
- * Runs after collection, over the outcomes, and produces the
19
- * [[IntegrityReport]] that goes on the wire beside them. It is not a source,
20
- * for two reasons: it reads what the other sources produced, so it cannot run
21
- * beside them; and a tamper check that competed for the budget could be starved
22
- * by a slow source, which is precisely the outcome an attacker would arrange.
35
+ * The rules are the table in the server's ADR 0024 (Appendix B), which the
36
+ * server applies to every report as well. Rows shared with the server are
37
+ * copied literally into `tests/embedding.test.ts`; change both together.
23
38
  *
24
- * What it reports is raw: which natives are patched, which properties were
25
- * redefined. Whether the reported values contradict each other - a user agent
26
- * claiming a phone that hovers, a language that is not the first of its own
27
- * languages - is the server's reading of the same sources, not something the
28
- * page decides.
39
+ * Reading the user agent, `location` and a few globals is itself a read of the
40
+ * device, so this runs only once consent is granted, from `identify()` and
41
+ * `collect()` and the guarded sources.
42
+ */
43
+ /** What the page can see of where it runs. Defaults to the real page. */
44
+ interface EmbeddingEnvironment {
45
+ userAgent?: string;
46
+ protocol?: string;
47
+ window?: Record<string, unknown>;
48
+ }
49
+ /**
50
+ * The kind of app this page runs in, or undefined in a browser.
51
+ *
52
+ * Order: the page's own scheme, then a bridge, then the user agent. The first
53
+ * two are checked before the third-party exception, because either proves the
54
+ * page belongs to the customer's app.
55
+ */
56
+ declare function detectEmbedding(environment?: EmbeddingEnvironment): string | undefined;
57
+
58
+ /**
59
+ * The tamper layer (`F-11`).
60
+ *
61
+ * Runs after collection over the gathered outcomes and produces the
62
+ * [[IntegrityReport]] that goes on the wire alongside `sources`.
29
63
  */
30
64
 
31
65
  declare function inspectIntegrity(sources: Record<string, SignalOutcome>): IntegrityReport;
32
66
 
33
67
  /**
34
- * @fingerly/web-js - the browser SDK.
68
+ * @fingerly/web-js - the browser SDK (`v: 3`, single-pass).
35
69
  *
36
70
  * Wires the browser source set and the tamper layer into `@fingerly/core`'s
37
- * client. Everything platform-specific is in this package; scheduling and
38
- * transport are in the kernel, and scoring is on the server, where customers
39
- * set the weights and a page cannot read or edit them.
40
- *
41
- * ```ts
42
- * import { load } from '@fingerly/web-js'
43
- *
44
- * const fingerly = await load({ apiKey: 'fly_pk_production_…' })
45
- * const { visitorId, visitorIsNew, suspectLevel } = await fingerly.identify()
46
- *
47
- * // The server's answer, in the same round trip. Everything about the score
48
- * // lives on the server, under the weights you set. `suspectLevel` is null
49
- * // when absent, which is not a clean result. Signals are read on your backend.
50
- * if (suspectLevel === 'high') {
51
- * // step up to a challenge
52
- * }
53
- * ```
54
- *
55
- * Nothing about that decision happens in the page. This package collects and
56
- * submits; the server scores.
71
+ * single-pass v3 client. Everything platform-specific is in this package;
72
+ * scheduling and transport are in the kernel, and scoring is on the server.
57
73
  */
58
74
 
59
- interface FingerlyOptions extends Omit<FingerlyClientOptions, 'sources' | 'integrity' | 'platform'> {
75
+ interface FingerlyOptions extends Omit<FingerlyClientOptions, 'sources' | 'integrity' | 'platform' | 'embedding'> {
60
76
  /**
61
77
  * Replace the source set. Intended for tests and for a caller who has a
62
78
  * reason to run a subset; the default is every browser source.
@@ -65,19 +81,7 @@ interface FingerlyOptions extends Omit<FingerlyClientOptions, 'sources' | 'integ
65
81
  }
66
82
  /**
67
83
  * Build a client with the browser sources installed.
68
- *
69
- * Async, and returns a promise, even though there is currently nothing to
70
- * await. That is deliberate: the shape callers write today is the shape that
71
- * still works when this needs to warm a worker or wait for a document to be
72
- * ready, and changing `load()` from sync to async later would break every
73
- * integration at once.
74
- *
75
- * Loading collects nothing and sends nothing, whatever `consent` is: no
76
- * source runs until `identify()` or `collect()` is called, and those refuse
77
- * while consent is not `granted`. Consent defaults to `pending`, so a page can
78
- * load early and call `setConsent('granted')` from its consent tool, or pass
79
- * `consent: 'granted'` once it already has consent (or another lawful basis).
80
84
  */
81
85
  declare function load(options: FingerlyOptions): Promise<FingerlyClient>;
82
86
 
83
- export { type FingerlyOptions, browserSources, inspectIntegrity, load };
87
+ export { type FingerlyOptions, browserSources, detectEmbedding, inspectIntegrity, load };
package/dist/index.d.ts CHANGED
@@ -1,62 +1,78 @@
1
1
  import { Source, SignalOutcome, IntegrityReport, FingerlyClientOptions, FingerlyClient } from '@fingerly/core';
2
- export { Confidence, ConsentError, ConsentState, FingerlyClient, FingerlyEvent, FingerlyWebEvent, IdentifyOptions, IdentifyResult, IntegrityReport, Lie, SOURCE, SignalOutcome, SignalReport, SignalStatus, TransportError, isSuspiciousLevel } from '@fingerly/core';
2
+ export { CollectOptions, Confidence, ConsentError, ConsentState, FingerlyClient, IdentifyOptions, IdentifyResult, IdentifySubmission, IdentifyTrigger, IncognitoDetection, IntegrityReport, Lie, LieKind, RiskSignal, SOURCE, SignalOutcome, SignalReport, SignalStatus, SourceOptIn, SourceStage, SuspectLevel, TransportError, WorkerRealmSignal, isSuspiciousLevel } from '@fingerly/core';
3
3
 
4
4
  /**
5
- * The browser source set.
6
- *
7
- * Order within a tier does not matter - the scheduler runs them concurrently up
8
- * to its cap - but the tier does. `fast` sources are cheap reads that a page
9
- * can afford to block a click on; `deferred` sources render, measure layout or
10
- * await hardware, and are worth having only because the budget bounds them.
5
+ * The single-pass two-stage browser source set (`prerequisite` -> `collect`).
11
6
  */
12
7
 
13
8
  declare const browserSources: readonly Source[];
14
9
 
15
10
  /**
16
- * The tamper layer.
11
+ * Is this page running inside an app?
12
+ *
13
+ * A page inside a customer's own app is the app reading the device. Apple's
14
+ * agreement forbids an app to "derive any data from a device for the purpose
15
+ * of uniquely identifying it", naming the properties of a web browser among
16
+ * that data, so the browser SDK runs no device-fingerprinting source there.
17
+ * Use the iOS or Android SDK in an app instead.
18
+ *
19
+ * What it does collect in an app is the embedded profile
20
+ * (`EMBEDDED_SAFE_SOURCES` in `@fingerly/core`), which exists so the server
21
+ * can tell a genuine app WebView from a desktop or automated browser that
22
+ * claims to be one:
23
+ *
24
+ * - `embedding`: the kind of app detected (`{ kind }`), nothing else.
25
+ * - `engine`, `math`, `errors`: how the JavaScript engine behaves (error
26
+ * message lengths, maths results, CSS support), no device values.
27
+ * - `navigator`: `user_agent`, `platform` and `webdriver` only.
28
+ * - `worker_realm`: the worker's `user_agent` and `platform` only.
29
+ * - `automation`: `webdriver` and the names of automation globals present.
30
+ * - the integrity block: which natives and descriptors were tampered with.
31
+ *
32
+ * Core count, device memory, languages, time zone, plugins, screen, GPU,
33
+ * canvas, audio, fonts and storage are not read in an app.
17
34
  *
18
- * Runs after collection, over the outcomes, and produces the
19
- * [[IntegrityReport]] that goes on the wire beside them. It is not a source,
20
- * for two reasons: it reads what the other sources produced, so it cannot run
21
- * beside them; and a tamper check that competed for the budget could be starved
22
- * by a slow source, which is precisely the outcome an attacker would arrange.
35
+ * The rules are the table in the server's ADR 0024 (Appendix B), which the
36
+ * server applies to every report as well. Rows shared with the server are
37
+ * copied literally into `tests/embedding.test.ts`; change both together.
23
38
  *
24
- * What it reports is raw: which natives are patched, which properties were
25
- * redefined. Whether the reported values contradict each other - a user agent
26
- * claiming a phone that hovers, a language that is not the first of its own
27
- * languages - is the server's reading of the same sources, not something the
28
- * page decides.
39
+ * Reading the user agent, `location` and a few globals is itself a read of the
40
+ * device, so this runs only once consent is granted, from `identify()` and
41
+ * `collect()` and the guarded sources.
42
+ */
43
+ /** What the page can see of where it runs. Defaults to the real page. */
44
+ interface EmbeddingEnvironment {
45
+ userAgent?: string;
46
+ protocol?: string;
47
+ window?: Record<string, unknown>;
48
+ }
49
+ /**
50
+ * The kind of app this page runs in, or undefined in a browser.
51
+ *
52
+ * Order: the page's own scheme, then a bridge, then the user agent. The first
53
+ * two are checked before the third-party exception, because either proves the
54
+ * page belongs to the customer's app.
55
+ */
56
+ declare function detectEmbedding(environment?: EmbeddingEnvironment): string | undefined;
57
+
58
+ /**
59
+ * The tamper layer (`F-11`).
60
+ *
61
+ * Runs after collection over the gathered outcomes and produces the
62
+ * [[IntegrityReport]] that goes on the wire alongside `sources`.
29
63
  */
30
64
 
31
65
  declare function inspectIntegrity(sources: Record<string, SignalOutcome>): IntegrityReport;
32
66
 
33
67
  /**
34
- * @fingerly/web-js - the browser SDK.
68
+ * @fingerly/web-js - the browser SDK (`v: 3`, single-pass).
35
69
  *
36
70
  * Wires the browser source set and the tamper layer into `@fingerly/core`'s
37
- * client. Everything platform-specific is in this package; scheduling and
38
- * transport are in the kernel, and scoring is on the server, where customers
39
- * set the weights and a page cannot read or edit them.
40
- *
41
- * ```ts
42
- * import { load } from '@fingerly/web-js'
43
- *
44
- * const fingerly = await load({ apiKey: 'fly_pk_production_…' })
45
- * const { visitorId, visitorIsNew, suspectLevel } = await fingerly.identify()
46
- *
47
- * // The server's answer, in the same round trip. Everything about the score
48
- * // lives on the server, under the weights you set. `suspectLevel` is null
49
- * // when absent, which is not a clean result. Signals are read on your backend.
50
- * if (suspectLevel === 'high') {
51
- * // step up to a challenge
52
- * }
53
- * ```
54
- *
55
- * Nothing about that decision happens in the page. This package collects and
56
- * submits; the server scores.
71
+ * single-pass v3 client. Everything platform-specific is in this package;
72
+ * scheduling and transport are in the kernel, and scoring is on the server.
57
73
  */
58
74
 
59
- interface FingerlyOptions extends Omit<FingerlyClientOptions, 'sources' | 'integrity' | 'platform'> {
75
+ interface FingerlyOptions extends Omit<FingerlyClientOptions, 'sources' | 'integrity' | 'platform' | 'embedding'> {
60
76
  /**
61
77
  * Replace the source set. Intended for tests and for a caller who has a
62
78
  * reason to run a subset; the default is every browser source.
@@ -65,19 +81,7 @@ interface FingerlyOptions extends Omit<FingerlyClientOptions, 'sources' | 'integ
65
81
  }
66
82
  /**
67
83
  * Build a client with the browser sources installed.
68
- *
69
- * Async, and returns a promise, even though there is currently nothing to
70
- * await. That is deliberate: the shape callers write today is the shape that
71
- * still works when this needs to warm a worker or wait for a document to be
72
- * ready, and changing `load()` from sync to async later would break every
73
- * integration at once.
74
- *
75
- * Loading collects nothing and sends nothing, whatever `consent` is: no
76
- * source runs until `identify()` or `collect()` is called, and those refuse
77
- * while consent is not `granted`. Consent defaults to `pending`, so a page can
78
- * load early and call `setConsent('granted')` from its consent tool, or pass
79
- * `consent: 'granted'` once it already has consent (or another lawful basis).
80
84
  */
81
85
  declare function load(options: FingerlyOptions): Promise<FingerlyClient>;
82
86
 
83
- export { type FingerlyOptions, browserSources, inspectIntegrity, load };
87
+ export { type FingerlyOptions, browserSources, detectEmbedding, inspectIntegrity, load };