@hideguard/sdk 0.0.0-stage → 1.11.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/LICENSE +44 -0
- package/README.md +62 -2
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.mjs +2 -0
- package/package.json +39 -6
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* Generated from src/sdk/module-types.ts. Run npm run sdk:package. */
|
|
2
|
+
/**
|
|
3
|
+
* The public types of the module doors — the ESM link (`/sdk/v1.mjs`) and `@hideguard/sdk`.
|
|
4
|
+
*
|
|
5
|
+
* Declarations only. `scripts/build-sdk.mjs` writes this file, as it is, into the npm package's
|
|
6
|
+
* `index.d.ts` together with the two exported declarations, so what a customer's editor shows
|
|
7
|
+
* is what `module-entry.ts` is typed against. Anything added here is public API.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The options `start()` takes — the attributes of the `<script>` tag, as an object. Every field
|
|
12
|
+
* is optional except the site key, and every default is the tag's except `auto` and `endpoint`
|
|
13
|
+
* (see the header).
|
|
14
|
+
*/
|
|
15
|
+
export interface StartOptions {
|
|
16
|
+
/** The site's **public** key (`pk_live_…` / `pk_test_…`). Never the secret. */
|
|
17
|
+
siteKey: string;
|
|
18
|
+
/** The collector's origin. Defaults to `https://hideguard.io`. */
|
|
19
|
+
endpoint?: string;
|
|
20
|
+
/** Collect as soon as the page is ready. Off by default in a module: call `get()`. */
|
|
21
|
+
auto?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* `false` never draws the block screen, `true` draws it on every block, left out the reply
|
|
24
|
+
* decides (an operator's own blocklist entry draws it). While only collecting, pass `false`.
|
|
25
|
+
*/
|
|
26
|
+
block?: boolean;
|
|
27
|
+
cookie?: boolean;
|
|
28
|
+
heartbeat?: boolean;
|
|
29
|
+
behavior?: boolean;
|
|
30
|
+
/** Wraps the page's `fetch` and `XMLHttpRequest` to record its requests. Opt-in. */
|
|
31
|
+
requests?: boolean;
|
|
32
|
+
localIp?: boolean;
|
|
33
|
+
activeProbes?: boolean;
|
|
34
|
+
/** `false` turns the SYN check off; a URL names your own capture host. */
|
|
35
|
+
synCheck?: false | string;
|
|
36
|
+
/** `false` turns the latency series off; a URL names your own host. */
|
|
37
|
+
latencyCheck?: false | string;
|
|
38
|
+
/** A second "which address do I arrive with" host. Off unless named. */
|
|
39
|
+
ipCheck?: string;
|
|
40
|
+
ipCheckKey?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** One reason behind the verdict, as the collector sends it to the visitor's page. */
|
|
44
|
+
export interface HideGuardReason {
|
|
45
|
+
code: string;
|
|
46
|
+
category?: string;
|
|
47
|
+
severity?: string;
|
|
48
|
+
weight?: number;
|
|
49
|
+
detail?: string | null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* What `get()` resolves with: the collector's reply. `requestId` is what your server sends to
|
|
54
|
+
* `POST /api/v1/verdict` (or `@hideguard/node`'s `verdict()`) — never act on `verdict` in the
|
|
55
|
+
* page, which the visitor controls.
|
|
56
|
+
*/
|
|
57
|
+
export interface HideGuardResult {
|
|
58
|
+
/** The visit's id. Send it to your server with the request it belongs to. */
|
|
59
|
+
requestId: string;
|
|
60
|
+
visitorId: string;
|
|
61
|
+
verdict: "allow" | "challenge" | "block";
|
|
62
|
+
score: number;
|
|
63
|
+
reasons: HideGuardReason[];
|
|
64
|
+
siteId: string;
|
|
65
|
+
environment: string;
|
|
66
|
+
/** Ed25519 signature over the reply, when the collector has a signing key. */
|
|
67
|
+
signature?: string;
|
|
68
|
+
presenceToken?: string | null;
|
|
69
|
+
[field: string]: unknown;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** What the page tells the collector about its own location prompt. */
|
|
73
|
+
export type GeolocationAnswer = GeolocationPosition | GeolocationPositionError | "declined";
|
|
74
|
+
|
|
75
|
+
export interface HideGuardAgent {
|
|
76
|
+
/**
|
|
77
|
+
* Measures the browser and posts the reading; resolves with the reply. Every call measures
|
|
78
|
+
* afresh; a call made while one is in flight shares it. Rejects on a network failure or a
|
|
79
|
+
* refused site key — catch it, and let the checkout go on without a `requestId`.
|
|
80
|
+
*/
|
|
81
|
+
get(): Promise<HideGuardResult>;
|
|
82
|
+
/** The page's answer to its own location prompt. The SDK never asks for the location. */
|
|
83
|
+
reportGeolocation(answer: GeolocationAnswer): Promise<boolean>;
|
|
84
|
+
/** Stops the presence heartbeat for good. */
|
|
85
|
+
stopHeartbeat(): void;
|
|
86
|
+
readonly version: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The collector's version. */
|
|
90
|
+
export declare const version: string;
|
|
91
|
+
|
|
92
|
+
/** Boots the collector on this page (once) and returns its agent. Browser only. */
|
|
93
|
+
export declare function start(options: StartOptions): HideGuardAgent;
|