@fingerly/web-js 0.0.0-stage → 0.1.1
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/LICENSE +202 -0
- package/README.md +112 -2
- package/dist/browser.global.js +1 -0
- package/dist/index.cjs +1806 -0
- package/dist/index.d.cts +83 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +1783 -0
- package/package.json +42 -3
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
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';
|
|
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
|
+
* 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.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
declare function inspectIntegrity(sources: Record<string, SignalOutcome>): IntegrityReport;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @fingerly/web-js - the browser SDK.
|
|
35
|
+
*
|
|
36
|
+
* 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.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
interface FingerlyOptions extends Omit<FingerlyClientOptions, 'sources' | 'integrity' | 'platform'> {
|
|
60
|
+
/**
|
|
61
|
+
* Replace the source set. Intended for tests and for a caller who has a
|
|
62
|
+
* reason to run a subset; the default is every browser source.
|
|
63
|
+
*/
|
|
64
|
+
sources?: FingerlyClientOptions['sources'];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 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
|
+
*/
|
|
81
|
+
declare function load(options: FingerlyOptions): Promise<FingerlyClient>;
|
|
82
|
+
|
|
83
|
+
export { type FingerlyOptions, browserSources, inspectIntegrity, load };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
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';
|
|
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
|
+
* 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.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
declare function inspectIntegrity(sources: Record<string, SignalOutcome>): IntegrityReport;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @fingerly/web-js - the browser SDK.
|
|
35
|
+
*
|
|
36
|
+
* 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.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
interface FingerlyOptions extends Omit<FingerlyClientOptions, 'sources' | 'integrity' | 'platform'> {
|
|
60
|
+
/**
|
|
61
|
+
* Replace the source set. Intended for tests and for a caller who has a
|
|
62
|
+
* reason to run a subset; the default is every browser source.
|
|
63
|
+
*/
|
|
64
|
+
sources?: FingerlyClientOptions['sources'];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 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
|
+
*/
|
|
81
|
+
declare function load(options: FingerlyOptions): Promise<FingerlyClient>;
|
|
82
|
+
|
|
83
|
+
export { type FingerlyOptions, browserSources, inspectIntegrity, load };
|