@fingerly/web-js 0.0.0-stage → 0.1.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.
@@ -0,0 +1,78 @@
1
+ import { Source, SignalOutcome, IntegrityReport, FingerlyClientOptions, FingerlyClient } from '@fingerly/core';
2
+ export { Confidence, ConsentError, ConsentState, FingerlyClient, FingerlyEvent, FingerlyWebEvent, IdentifyOptions, IdentifyResult, IdentifyTrigger, IntegrityReport, Lie, SOURCE, SignalOutcome, SignalReport, SignalStatus, TransportError, Verdict, Verdicts } from '@fingerly/core';
3
+
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.
11
+ */
12
+
13
+ declare const browserSources: readonly Source[];
14
+
15
+ /**
16
+ * The tamper layer.
17
+ *
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.
23
+ */
24
+
25
+ declare function inspectIntegrity(sources: Record<string, SignalOutcome>): IntegrityReport;
26
+
27
+ /**
28
+ * @fingerly/web-js - the browser SDK.
29
+ *
30
+ * Wires the browser source set and the tamper layer into `@fingerly/core`'s
31
+ * client. Everything platform-specific is in this package; everything about
32
+ * scheduling, transport and scoring is in the kernel, which is what lets the
33
+ * same detectors run again on the server over a stored report.
34
+ *
35
+ * ```ts
36
+ * import { load } from '@fingerly/web-js'
37
+ *
38
+ * const fingerly = await load({ apiKey: 'fly_pk_production_…' })
39
+ * const { visitorId, visitorIsNew, suspectScore, verdicts } = await fingerly.identify()
40
+ *
41
+ * // The server's answer, in the same round trip.
42
+ * if (suspectScore !== null && suspectScore >= 30) {
43
+ * // step up to a challenge
44
+ * }
45
+ *
46
+ * // The local verdicts are still there, and are still advisory: they are
47
+ * // computed in the page, by code the visitor controls.
48
+ * if (verdicts.automation.value && verdicts.automation.confidence === 'high') {
49
+ * // ...
50
+ * }
51
+ * ```
52
+ */
53
+
54
+ interface FingerlyOptions extends Omit<FingerlyClientOptions, 'sources' | 'integrity' | 'platform'> {
55
+ /**
56
+ * Replace the source set. Intended for tests and for a caller who has a
57
+ * reason to run a subset; the default is every browser source.
58
+ */
59
+ sources?: FingerlyClientOptions['sources'];
60
+ }
61
+ /**
62
+ * Build a client with the browser sources installed.
63
+ *
64
+ * Async, and returns a promise, even though there is currently nothing to
65
+ * await. That is deliberate: the shape callers write today is the shape that
66
+ * still works when this needs to warm a worker or wait for a document to be
67
+ * ready, and changing `load()` from sync to async later would break every
68
+ * integration at once.
69
+ *
70
+ * Loading collects nothing and sends nothing, whatever `consent` is: no
71
+ * source runs until `identify()` or `collect()` is called, and those refuse
72
+ * while consent is not `granted`. Consent defaults to `pending`, so a page can
73
+ * load early and call `setConsent('granted')` from its consent tool, or pass
74
+ * `consent: 'granted'` once it already has consent (or another lawful basis).
75
+ */
76
+ declare function load(options: FingerlyOptions): Promise<FingerlyClient>;
77
+
78
+ export { type FingerlyOptions, browserSources, inspectIntegrity, load };
@@ -0,0 +1,78 @@
1
+ import { Source, SignalOutcome, IntegrityReport, FingerlyClientOptions, FingerlyClient } from '@fingerly/core';
2
+ export { Confidence, ConsentError, ConsentState, FingerlyClient, FingerlyEvent, FingerlyWebEvent, IdentifyOptions, IdentifyResult, IdentifyTrigger, IntegrityReport, Lie, SOURCE, SignalOutcome, SignalReport, SignalStatus, TransportError, Verdict, Verdicts } from '@fingerly/core';
3
+
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.
11
+ */
12
+
13
+ declare const browserSources: readonly Source[];
14
+
15
+ /**
16
+ * The tamper layer.
17
+ *
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.
23
+ */
24
+
25
+ declare function inspectIntegrity(sources: Record<string, SignalOutcome>): IntegrityReport;
26
+
27
+ /**
28
+ * @fingerly/web-js - the browser SDK.
29
+ *
30
+ * Wires the browser source set and the tamper layer into `@fingerly/core`'s
31
+ * client. Everything platform-specific is in this package; everything about
32
+ * scheduling, transport and scoring is in the kernel, which is what lets the
33
+ * same detectors run again on the server over a stored report.
34
+ *
35
+ * ```ts
36
+ * import { load } from '@fingerly/web-js'
37
+ *
38
+ * const fingerly = await load({ apiKey: 'fly_pk_production_…' })
39
+ * const { visitorId, visitorIsNew, suspectScore, verdicts } = await fingerly.identify()
40
+ *
41
+ * // The server's answer, in the same round trip.
42
+ * if (suspectScore !== null && suspectScore >= 30) {
43
+ * // step up to a challenge
44
+ * }
45
+ *
46
+ * // The local verdicts are still there, and are still advisory: they are
47
+ * // computed in the page, by code the visitor controls.
48
+ * if (verdicts.automation.value && verdicts.automation.confidence === 'high') {
49
+ * // ...
50
+ * }
51
+ * ```
52
+ */
53
+
54
+ interface FingerlyOptions extends Omit<FingerlyClientOptions, 'sources' | 'integrity' | 'platform'> {
55
+ /**
56
+ * Replace the source set. Intended for tests and for a caller who has a
57
+ * reason to run a subset; the default is every browser source.
58
+ */
59
+ sources?: FingerlyClientOptions['sources'];
60
+ }
61
+ /**
62
+ * Build a client with the browser sources installed.
63
+ *
64
+ * Async, and returns a promise, even though there is currently nothing to
65
+ * await. That is deliberate: the shape callers write today is the shape that
66
+ * still works when this needs to warm a worker or wait for a document to be
67
+ * ready, and changing `load()` from sync to async later would break every
68
+ * integration at once.
69
+ *
70
+ * Loading collects nothing and sends nothing, whatever `consent` is: no
71
+ * source runs until `identify()` or `collect()` is called, and those refuse
72
+ * while consent is not `granted`. Consent defaults to `pending`, so a page can
73
+ * load early and call `setConsent('granted')` from its consent tool, or pass
74
+ * `consent: 'granted'` once it already has consent (or another lawful basis).
75
+ */
76
+ declare function load(options: FingerlyOptions): Promise<FingerlyClient>;
77
+
78
+ export { type FingerlyOptions, browserSources, inspectIntegrity, load };