@intellifend/requestshieldjs 2.0.0-qat.204 → 2.0.0-qat.219

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/README.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  The RequestShield Browser SDK obtains single-use proof-of-work tokens and either attaches them automatically to configured Fetch and asynchronous XHR requests or returns them for application-controlled transport. The customer backend remains the authority that verifies a token and decides how to handle a missing token.
4
4
 
5
+ ## Choose integration modes
6
+
7
+ Choose the frontend and backend modes independently:
8
+
9
+ | Side | Seamless | Manual |
10
+ | --- | --- | --- |
11
+ | Frontend (Browser SDK) | Configure `protect`; the SDK obtains and attaches a token to matching Fetch and asynchronous XHR requests. | Call `getToken()` and attach the returned token in application code. |
12
+ | Java backend | Use the Spring Boot 3 MVC starter and annotate the protected handler; the starter extracts the header, verifies the token and applies its enforcement policy. | Extract the token, call the Java core SDK's `verify(token)` and apply `VerificationResult` before the protected operation. |
13
+
14
+ For a new integration, prefer Seamless on both sides when the browser transport
15
+ is supported and the backend uses Spring Boot 3 MVC. Otherwise, prefer Manual
16
+ on both sides. All four combinations are supported, so an existing combination
17
+ or an explicit choice can be kept. Backend Seamless requires the token in
18
+ `X-IntelliFend-Token`, including when the frontend uses Manual mode.
19
+
20
+ `BLOCK` and `MONITOR` are Spring starter enforcement policies, separate from these
21
+ integration modes. Choosing frontend Seamless does not enable backend protection.
22
+
5
23
  ## Install
6
24
 
7
25
  ### npm / ESM
@@ -29,6 +47,11 @@ IntelliFend supplies a different endpoint for your application, set it explicitl
29
47
  Pin the resolved version
30
48
  in your application's lockfile for reproducible installations.
31
49
 
50
+ This SDK uses API v2 by default. Select API v1 with `apiVersion: "v1"` or
51
+ `data-api-version="v1"` on the script tag. The version is
52
+ separate from the service base URL; do not append `/v1` or `/v2` to
53
+ `challengeUrl`. Both versions use the same app key and backend token transport.
54
+
32
55
  The ESM entry point exports `IntelliFend`, `IntelliFendError`, `VERSION`, and
33
56
  TypeScript types. It does not attach a global or initialize itself. Use it in
34
57
  browser applications with an ESM-capable toolchain.
@@ -117,15 +140,21 @@ await fetch("/api/register", {
117
140
  | Option | Required | Description |
118
141
  | --- | --- | --- |
119
142
  | `appKey` | Yes | Public app key supplied by IntelliFend. |
143
+ | `apiVersion` | No | Challenge API version: `"v1"` or `"v2"`. Defaults to `"v2"`. |
120
144
  | `challengeUrl` | No | Absolute Challenge Server base URL. Defaults to `https://challenge.intellifend.ai`. It must use HTTP(S) and contain no credentials, query, or fragment. |
121
145
  | `fallbackChallengeUrl` | No | Approved absolute HTTPS secondary base URL, without credentials, query, or fragment. Omitted by default. An identical normalized primary URL adds no alternate endpoint. |
122
146
  | `timeoutMs` | No | Positive whole-flow time budget for create, solve, verify, and retries. Defaults to 5,000 ms. |
123
147
  | `protect` | No | Exact endpoint path or URL strings for Seamless mode. Omit or pass an empty list for Manual-only operation. |
124
- | `telemetry` | No | Enables the optional browser signal collection described below. Default `false`. |
148
+ | `telemetry` | No | Enables the optional browser signal collection on API v2. Default `false`; collection stays disabled on v1. |
125
149
 
126
150
  `init()` validates synchronously and throws `IntelliFendError` with code `invalid_config` for invalid input. Reinitialization replaces the previous valid configuration; a failing reinitialization leaves that configuration in place. Unknown configuration keys are ignored.
127
151
 
128
- Script-tag integrations use the equivalent attributes `data-app-key`, `data-challenge-url`, `data-protect`, and `data-fallback-challenge-url`. `data-protect` must be a JSON array of strings. The collector accepts only the exact `data-telemetry="true"` and `data-telemetry="false"` values; invalid supplied values use the same sanitized `invalid_config` auto-init warning.
152
+ Script-tag integrations use the equivalent attributes `data-app-key`, `data-api-version`, `data-challenge-url`, `data-protect`, and `data-fallback-challenge-url`. `data-api-version` accepts exactly `"v1"` or `"v2"`; omitting it selects v2. `data-protect` must be a JSON array of strings. The collector accepts only the exact `data-telemetry="true"` and `data-telemetry="false"` values; invalid supplied values use the same sanitized `invalid_config` auto-init warning.
153
+
154
+ Each token flow retains its API version through create, solve, verify, retries,
155
+ and endpoint fallback, including when the SDK is reinitialized during that flow.
156
+ This SDK requires WebAssembly and the documented CSP permissions with either
157
+ API version. Integrations pinned to Browser SDK 1.0.0 continue using API v1.
129
158
 
130
159
  ### Optional secondary domain
131
160
 
@@ -145,10 +174,11 @@ The SDK can retry eligible connection failures through the alternate service.
145
174
  All attempts share the configured token timeout, which defaults to 5,000 ms.
146
175
  Switching services does not restart that timeout. No cookies or browser storage
147
176
  are used. `getToken()` returns a token or `""` if acquisition fails.
177
+ Both services use the selected API version; a v2 failure never retries through v1.
148
178
 
149
179
  ### Optional browser signal collection
150
180
 
151
- `telemetry: true` collects a bounded summary of browser
181
+ On API v2, `telemetry: true` collects a bounded summary of browser
152
182
  interaction and timezone information in page memory for up to five minutes.
153
183
  This summary accompanies token requests and includes timezone information.
154
184
 
@@ -200,7 +230,11 @@ For a cross-origin protected application API, allow the `X-IntelliFend-Token` re
200
230
 
201
231
  ### Manual transport
202
232
 
203
- `X-IntelliFend-Token` is the recommended Manual-mode carrier. A dedicated request-body or form field is also valid when the backend extracts it before verification. Never place a token in a URL path, query string, or fragment because those locations are commonly logged and cached.
233
+ `X-IntelliFend-Token` is the recommended carrier for frontend Manual mode and is
234
+ required by backend Seamless. A dedicated request-body or form field is also
235
+ valid with backend Manual, where application code extracts it before verification.
236
+ Never place a token in a URL path, query string, or fragment because those
237
+ locations are commonly logged and cached.
204
238
 
205
239
  ### Challenge Server proxies
206
240
 
@@ -1,18 +1,18 @@
1
1
  {
2
- "version": "2.0.0-qat.204",
2
+ "version": "2.0.0-qat.219",
3
3
  "algorithm": "sha384",
4
4
  "bundles": [
5
5
  {
6
6
  "name": "intellifend",
7
7
  "path": "intellifend.js",
8
- "version": "2.0.0-qat.204",
9
- "integrity": "sha384-EiSYGXAoIbbj/1cSFLfbnq9Kr9AuVRah2wcs27G6c/En4WaTzpvBs7wkvwQt5zPz"
8
+ "version": "2.0.0-qat.219",
9
+ "integrity": "sha384-VVNJr29GfJQ+cLKOyYVrTq4XZYzOOHe2V4XLuNonViFiN6YU1+orLXupWdvnHFVm"
10
10
  },
11
11
  {
12
12
  "name": "intellifend-esm",
13
13
  "path": "intellifend.mjs",
14
- "version": "2.0.0-qat.204",
15
- "integrity": "sha384-yyh4+YzCrfeKv/qw4ClpSQzcP6R5Kk2/C3WfrG9bMR1rzpFB4vZyiQNAhOgbuWxY"
14
+ "version": "2.0.0-qat.219",
15
+ "integrity": "sha384-nDFntCKrjZArukMLpKcNVXk0PV5wJGdMXfzW0x9GlsbRId6WjAopiWIATb6AKxX7"
16
16
  }
17
17
  ]
18
18
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
+ export type ApiVersion = "v1" | "v2";
1
2
  export interface InitConfig {
2
3
  /** Public site key (`pk_...`). Required. */
3
4
  appKey: string;
5
+ /** Challenge API version. Defaults to v2; v1 preserves the legacy policy. */
6
+ apiVersion?: ApiVersion;
4
7
  /** Challenge Server HTTP(S) base URL. Defaults to https://challenge.intellifend.ai. */
5
8
  challengeUrl?: string;
6
9
  /** Optional HTTPS service base URL used when the preferred endpoint is unavailable. */