requestshield 0.1.4 → 0.1.6

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.
Files changed (37) hide show
  1. package/README.md +421 -85
  2. package/config/.env.prod +7 -0
  3. package/package.json +21 -12
  4. package/skills/requestshield/SKILL.md +299 -307
  5. package/skills/requestshield/assets/AGENTS.codex.md +62 -62
  6. package/skills/requestshield/references/backend-java-core.md +128 -128
  7. package/skills/requestshield/references/backend-spring-boot.md +145 -145
  8. package/skills/requestshield/references/browser-manual.md +210 -210
  9. package/skills/requestshield/references/browser-seamless.md +156 -164
  10. package/skills/requestshield/references/cli.md +107 -182
  11. package/skills/requestshield/references/integration-planning.md +362 -389
  12. package/skills/requestshield/references/troubleshooting.md +114 -118
  13. package/src/agent-detector.mjs +102 -74
  14. package/src/api-client.mjs +115 -79
  15. package/src/args.mjs +140 -80
  16. package/src/browser-opener.mjs +32 -0
  17. package/src/cli.mjs +277 -51
  18. package/src/commands/agent-setup.mjs +182 -185
  19. package/src/commands/application-mutations.mjs +33 -0
  20. package/src/commands/application-response.mjs +55 -0
  21. package/src/commands/apps-get.mjs +20 -0
  22. package/src/commands/apps-list.mjs +94 -0
  23. package/src/commands/auth-status.mjs +37 -0
  24. package/src/commands/keys-create.mjs +7 -38
  25. package/src/commands/mutation-support.mjs +110 -0
  26. package/src/commands/secret-commands.mjs +45 -0
  27. package/src/commands/signin.mjs +70 -57
  28. package/src/commands/signout.mjs +9 -0
  29. package/src/commands/update-check.mjs +12 -4
  30. package/src/config.mjs +150 -0
  31. package/src/entrypoint.mjs +24 -0
  32. package/src/errors.mjs +3 -1
  33. package/src/main.mjs +5 -24
  34. package/src/oauth-client.mjs +153 -0
  35. package/src/oauth-loopback.mjs +120 -0
  36. package/src/session-files.mjs +213 -0
  37. package/src/session-store.mjs +177 -64
@@ -1,307 +1,299 @@
1
- ---
2
- name: requestshield
3
- description: Install, verify, troubleshoot, or remove IntelliFend RequestShield bot protection in a customer codebase — the browser SDK in Seamless or Manual mode, plus Java backend enforcement via the Spring Boot 3 starter or the Java core SDK — driving the `requestshield` CLI for sign-in, app keys, the integration contract, and traffic checks. Use this skill whenever the user mentions RequestShield, IntelliFend, `X-IntelliFend-Token`, `IntelliFend.getToken()`, `data-protect`, `@RequestShieldProtected`, App Key or API Secret setup, or asks to protect an endpoint such as registration, sign-in, password reset, checkout, or form submission from bots, scripted abuse, or credential stuffing — even when they never name the product. Also use it before hand-editing any file that already contains a RequestShield script tag, `verify()` call, or protection annotation.
4
- ---
5
-
6
- # RequestShield integration
7
-
8
- Every RequestShield integration has two halves, and the split is the thing to
9
- understand before writing any code:
10
-
11
- 1. **The browser** obtains a short-lived token and transports it with the protected
12
- request, as the `X-IntelliFend-Token` header.
13
- 2. **The backend** evaluates that token and enforces the decision before the protected
14
- operation runs.
15
-
16
- The browser half is a *transport*, never a gate. A page that obtains tokens whose
17
- backend never verifies them has zero protection while looking fully integrated — the
18
- most common way this integration silently fails. Equally, an annotation on a handler
19
- creates no browser configuration. **Browser configuration and backend protection are
20
- configured independently, and neither one implies the other.** Land both halves in the
21
- same change and verify both.
22
-
23
- Protect the operation that performs the business mutation — registration, sign-in,
24
- password reset, checkout, form submission — not a read-only route in front of it.
25
-
26
- ## Before touching integration files
27
-
28
- ```bash
29
- requestshield --version # is the CLI present?
30
- requestshield auth status # {"authenticated":true,...} most commands need this
31
- ```
32
-
33
-
34
- If `requestshield --version` fails, the CLI is not installed. **Stop and say so.** Ask
35
- the user to install it; do not substitute hand-crafted HTTP calls, and do not fall back
36
- to the example values in this skill the contract is the only authoritative source for
37
- the script URL, header name, and released modes, and a guessed script URL produces a
38
- page that silently loads nothing.
39
-
40
- If `auth status` shows the user signed out, ask them to run `requestshield signin`
41
- themselves it is interactive. Never script around it or ask for credentials.
42
-
43
- Those commands are the preflight for integration-changing work. For read-only CLI
44
- questions, go to **Classify the request** and run only the matching command.
45
-
46
- ## Classify the request
47
-
48
- Only **Install** and **Uninstall** are step-locked sequences. Every other intent is a
49
- single CLI call or a short answer. Match on what the user wants, not on exact wording.
50
-
51
- | Intent | Sounds like | Do this |
52
- | --- | --- | --- |
53
- | **General info** | "what version", "is there a newer CLI", "am I up to date" | `requestshield --version`, then `requestshield update check`. Report both and the gap between them. No credentials check, no repo scan. |
54
- | **Authentication** | "sign me in", or preflight `auth status` came back unauthenticated | Ask the user to run `requestshield signin` in their own terminal, and wait. It is interactive — never automate it, never run it for them, never ask for credentials. Re-run `auth status` once they confirm. |
55
- | **Key / secret management** | "create an app key", "I need an API Secret", "rotate the secret", "deactivate a key" | **Hand the command over; do not run it.** → "Key and secret management" below. |
56
- | **Install** | "add RequestShield", "protect /api/register" | `references/integration-planning.md` full flow → **Installing** → **Verifying** → **Negative test**. Do not reorder or skip a step. |
57
- | **Uninstall** | "remove it", "roll it back" | `references/integration-planning.md` (Detect existing integration only) → **Uninstalling**. |
58
- | **Verify / troubleshoot** | "is it set up right?", "why is it not blocking?", a reason code | `references/integration-planning.md` (Detect existing integration only) → **Verifying**. For a reason code, also read `references/troubleshooting.md`. |
59
- | **Challenge volume** | "how much traffic", "how many challenges", "show me the volume" | Ask for the time range first. `challenge volume` takes `--from`/`--to`/`--granularity`; a guessed window produces a confident wrong answer. Then run it with the App Key. |
60
- | **Billing** | "am I being charged", "what plan", "what are my limits" | `requestshield get billing`. |
61
- | **Service health** | "is the service up", "is it degraded" | `requestshield server`. |
62
- | **Agent setup** | "set this up for Codex too", "install the skill for Claude" | Run `requestshield agent setup` for auto-detection, or pass the requested agent: `--agent codex` or `--agent claude`. This installs agent guidance; it does not mint keys or edit customer application code. |
63
- | **Anything else** | | Look the command up in `references/cli.md`. If it is not there, run `requestshield --help` rather than guessing at a flag. |
64
-
65
- Full CLI surface, output shapes, and which commands need auth: `references/cli.md`.
66
-
67
-
68
- For Install, `references/integration-planning.md` owns the full planning sequence:
69
- Credentials check, Detect existing integration, Contract check, Gate, Then act on what
70
- you found, and Choosing the mode. Keep the browser-mode and backend-path decisions
71
- independent.
72
-
73
- ## Key and secret management
74
-
75
- `keys create`, `app key rotate`, and `keys deactive` are the one place you do **not**
76
- drive the CLI. Two independent reasons, and each is sufficient on its own:
77
-
78
- - `keys create` and `app key rotate` print the API Secret to stdout exactly once. A
79
- command you run puts that value in your tool output and transcript.
80
- - `keys deactive` and `app key rotate` change state for a live App Key. Deactivating the
81
- wrong one stops verifying real traffic.
82
-
83
- So hand it over. Tell the user which command to run in their own terminal:
84
-
85
- ```bash
86
- requestshield keys create --app-name <name> # new App Key + API Secret pair
87
- requestshield app key rotate --app-key <app-key> # new secret, App Key unchanged
88
- requestshield keys deactive --app-key <app-key> # stops verification for that key
89
- ```
90
-
91
- Warn them **before** they run secret creation or rotation that the secret appears once
92
- and they need somewhere to put it. Afterwards, confirm by presence only and use
93
- `requestshield credentials status <app-key>` for the server-side view. Never ask the
94
- user to paste the secret back, and never read it out of a file or the environment.
95
-
96
- A lost or exposed secret cannot be re-displayed. The fix is `app key rotate`, run by
97
- the user. Deleting a leaked value from a repo, log, artifact, or transcript does not
98
- un-expose it.
99
-
100
- ## Installing
101
-
102
- For Install, run the full planning flow in `references/integration-planning.md` before
103
- writing integration code: **Credentials check** → **Detect existing integration** →
104
- **Contract check** → **Gate** → **Then act on what you found** → **Choosing the mode**.
105
- It must settle the App Key, the existing-integration state, the contract values, the
106
- backend path, and the browser mode before step 1 below.
107
-
108
- 1. **Browser side** — add the hosted script once in `<head>`, using the `script_url`
109
- from `requestshield contract`, then follow the chosen browser reference:
110
- - Seamless → `references/browser-seamless.md`
111
- - Manual → `references/browser-manual.md`
112
- 2. **Backend side** — add the dependency, configure `app-key` and `api-secret` from
113
- environment variables, and enforce the decision before the mutation:
114
- - Spring Boot 3 starter → `references/backend-spring-boot.md`
115
- - Java core SDK → `references/backend-java-core.md`
116
- 3. **Cross-origin API**, if the protected endpoint is on another origin — its CORS
117
- response must allow the page origin, intended methods, and `X-IntelliFend-Token`.
118
- 4. **CSP**, if the app sends one — merge, never replace. See
119
- `references/browser-manual.md`.
120
- 5. **Verify** — run the checklist below, then the negative test when safe.
121
-
122
- ## Handling the App Key and API Secret
123
-
124
- These two values have opposite handling rules:
125
-
126
- - **App Key** is public. It belongs in the browser script tag and backend configuration.
127
- The same value must appear on both sides or every token fails.
128
- - **API Secret** is backend-only. It must reach the backend through an environment
129
- variable or secret manager. Never write it into a source file, a committed `.env`, an
130
- image layer, a CI config in the repo, or the chat transcript — and never echo it back
131
- after reading it.
132
-
133
- You never run the commands that display the API Secret, and you never read it back. The
134
- hand-off and warning are in **Key and secret management** above. Afterwards refer to it
135
- only as "the secret you just received".
136
-
137
- If a secret has already reached a repo, a log, an artifact, or this transcript, the fix
138
- is `requestshield app key rotate --app-key <app-key>`, run by the user.
139
-
140
- ## Verifying
141
-
142
- For standalone Verify / Troubleshoot, first run **Detect existing integration only** in
143
- `references/integration-planning.md`. You are observing which browser mode and backend
144
- path are in use, not choosing them — **Credentials check**, **Contract check**,
145
- **Gate**, and **Choosing the mode** belong to the Install flow unless troubleshooting
146
- evidence specifically points to a credential failure or an unreleased mode.
147
-
148
- Then the static checks. They are deterministic and catch most real breakage.
149
-
150
- - Exactly **one** SDK script tag, in `<head>`, loaded before any bundle that can issue a
151
- protected request, with a real `data-app-key`.
152
- - Seamless: every protected endpoint appears in `data-protect`, spelled as the exact
153
- origin and pathname the browser actually requests — case and trailing slash included.
154
- - Manual: every protected call site obtains a fresh token immediately before the request
155
- and attaches it, including retry paths.
156
- - Neither mode applied twice to the same operation.
157
- - Backend: the dependency resolves, the App Key matches the browser's, the secret comes
158
- from the environment, and the decision gates the mutation rather than only being
159
- logged. Exactly one verification path per request.
160
- - Cross-origin endpoints: CORS allows `X-IntelliFend-Token`.
161
- - No token or secret in logs, analytics, URLs, or error reporting.
162
-
163
- Structural correctness is not proof of enforcement. For runtime evidence, exercise the
164
- endpoint and confirm the platform saw the traffic:
165
-
166
- ```bash
167
- requestshield challenge volume <app-key> \
168
- --from <start> \
169
- --to <end> \
170
- --granularity hour
171
- ```
172
-
173
- Report static correctness and platform traffic separately. A flat zero after real
174
- traffic means the browser half is not firing; go back to the selected browser reference
175
- before changing backend code.
176
-
177
- ### The negative test the only proof of enforcement
178
-
179
- Neither static checks nor `challenge volume` can prove the backend refuses a tokenless
180
- mutation. The proof is a request the backend should reject.
181
-
182
- Before running it, establish:
183
-
184
- 1. `requestshield server` is healthy. This reports platform health only; it does not prove
185
- that the backend under test can reach the Challenge Server or that its local circuit
186
- has closed. A healthy platform can still produce a degraded result at that backend.
187
- 2. The endpoint's effective mode is `BLOCK`, not `MONITOR`. Include any method-level
188
- override when resolving the effective mode. `MONITOR` allows every request by design.
189
- 3. A valid control request is available. Its authentication, session, CSRF state, route,
190
- method, and body must remain valid during the comparison.
191
- 4. Establish a way to observe degradation for the backend instance and App Key under
192
- test. For the Spring Boot starter, use the `intellifend.requestshield.requests` metric and distinguish
193
- `outcome=allowed, reason=ok` from `outcome=degraded, reason=service_unavailable`. For
194
- the Java core SDK, use existing safe metrics or logs derived from `isDegraded()` and
195
- `getReason().getCode()`. Never log the raw token, API Secret, session, or CSRF value.
196
-
197
- **Confirm with the user before running this anywhere shared.** It exercises a real
198
- mutation, so use a local or staging environment, or an endpoint whose write can be
199
- undone. Do not fire it at production to "just check", and do not invent a body that
200
- could create a real account.
201
-
202
- First, send the control request through the normal integrated path with a fresh
203
- RequestShield token. Confirm that it succeeds, reaches the intended mutation, and records
204
- a non-degraded `ok` decision at the backend. A successful response produced by degraded
205
- fail-open is not a valid control. Use a new token for every control attempt because
206
- RequestShield tokens are single-use.
207
-
208
- Then repeat the same request while preserving its valid authentication, session, CSRF
209
- state, route, method, body, and other relevant headers. Remove only
210
- `X-IntelliFend-Token`. Send it through a client that bypasses the Browser SDK so Seamless
211
- mode cannot attach another token:
212
-
213
- ```bash
214
- curl -i -X POST https://<host>/api/register \
215
- -H '<the same valid authentication and CSRF context>' \
216
- -H 'Content-Type: application/json' \
217
- -d '{ ...the same valid test body... }'
218
- ```
219
-
220
- Attribute the result to RequestShield rather than treating every 4xx as a pass.
221
- Authentication, authorization, CSRF, and request validation can independently return a
222
- 401, 403, or 400 before the protected mutation.
223
-
224
- - **Spring Boot 3 starter:** pass only when the response is HTTP 403 with
225
- `CHALLENGE_FAILED` and reason `missing_token`, and the handler produced no side effect.
226
- - **Java core SDK:** read the handler before testing. Confirm that its
227
- `!result.isAllowed()` branch rejects before the mutation, then verify that the
228
- observed rejection corresponds to RequestShield's `missing_token` decision and
229
- produced no side effect.
230
- - **Any unrelated or unattributable 4xx:** inconclusive, not a pass. Fix the control
231
- request or add safe RequestShield-specific observability before drawing a conclusion.
232
- - **Any backend-specific degraded evidence, including `service_unavailable`:**
233
- inconclusive. The SDK intentionally allows the request under its availability policy;
234
- restore the backend's Challenge Server connectivity, wait for its circuit to recover,
235
- and repeat with a new control token.
236
-
237
- A `2xx`, or evidence that the mutation happened, is a confirmed missing-token
238
- enforcement bypass only when backend-specific degradation has been ruled out for that
239
- request. If backend-specific degradation evidence is absent or cannot be checked,
240
- report the test as inconclusive—not as proof that enforcement is absent. When degradation
241
- is ruled out, treat the bypass as the finding and go to `references/troubleshooting.md`.
242
-
243
- ## Uninstalling
244
-
245
- Run `references/integration-planning.md` Detect existing integration only before this
246
- section. Remove only what RequestShield introduced, and confirm the list with the user
247
- first:
248
-
249
- 1. The script tag, including `data-protect` and any other RequestShield attributes.
250
- 2. Manual-mode `getToken()` calls and the header lines they feed — leave the surrounding
251
- request intact.
252
- 3. The backend dependency, client configuration, and the enforcement: `verify()` calls
253
- or `@RequestShieldProtected` annotations.
254
- 4. RequestShield entries in the CSP header and in CORS allowed headers — leave every
255
- other source and header in place.
256
- 5. Configuration keys and environment variable references.
257
-
258
- Then ask whether to also deactivate the keys server-side:
259
- `requestshield keys deactive --app-key <app-key>`. That is not reversible the way a
260
- code edit is, so it stays the user's explicit call.
261
-
262
- ## Non-negotiables
263
-
264
- These separate an integration that protects traffic from one that only looks like it:
265
-
266
- - **Enforcement lives in the backend.** Application code in the browser must never
267
- decide to allow, block, retry around, or interpret a token.
268
- - **Browser configuration and backend protection are independent.** Neither implies the
269
- other.
270
- - **One browser mode and one backend path are selected independently.** Seamless is not
271
- Spring Boot, and Manual is not Java core. Either browser mode may pair with either
272
- supported backend path.
273
- - **One token per protected request; a new token before every retry.** Tokens are
274
- single-use; replaying one returns `token_replayed` and blocks the request.
275
- - **One verification per request.** Never combine `@RequestShieldProtected` with a
276
- manual `RequestShieldClient.verify()` on the same handler.
277
- - **Forward a non-empty token unchanged.** Do not trim, re-encode, inspect, cache,
278
- persist, log, or place it in a URL.
279
- - When `getToken()` returns an empty string in Manual mode, omit the header and let the
280
- backend apply its configured policy.
281
- - **The API Secret stays at the backend.** Never put it in browser code,
282
- client-visible responses, source control, logs, build artifacts, or chat transcripts.
283
- - **You never run a command that mints, rotates, or deactivates a key.** Hand those
284
- commands to the user and verify by presence only.
285
-
286
- ## Reference files
287
-
288
- | File | Read it when |
289
- | --- | --- |
290
- | `references/cli.md` | Any CLI invocation — exact syntax, output shape, auth requirements |
291
- | `references/integration-planning.md` | Credentials check, existing-integration detection, the contract check, backend gating (Java version, Spring Boot 3 MVC vs WebFlux, other frameworks), and browser-mode selection |
292
- | `references/browser-manual.md` | Installing or auditing Manual mode; CSP rules |
293
- | `references/browser-seamless.md` | Installing or auditing Seamless mode; matching and coverage limits |
294
- | `references/backend-spring-boot.md` | Backend work on Spring Boot 3 MVC the annotation path |
295
- | `references/backend-java-core.md` | Backend work on any other Java 17 backend — the `verify()` path |
296
- | `references/troubleshooting.md` | A block, a degraded result, or a reason code to explain |
297
-
298
- ## For agent setup
299
-
300
- `requestshield agent setup` installs this skill for the detected or requested agent.
301
- Use `--agent codex` or `--agent claude` when the user names the target agent. For Codex
302
- repositories that also use `AGENTS.md`, the CLI can write the managed block from
303
- `assets/AGENTS.codex.md` so repo-local guidance points back to the installed skill and
304
- the same reference files.
305
-
306
- Agent setup installs guidance only. It does not mint keys, rotate secrets, deactivate
307
- keys, or edit customer application code.
1
+ ---
2
+ name: requestshield
3
+ description: Install, verify, troubleshoot, or remove IntelliFend RequestShield bot protection in a customer codebase — the browser SDK in Seamless or Manual mode, plus Java backend enforcement via the Spring Boot 3 starter or the Java core SDK — using the `requestshield` CLI for sign-in, applications and credentials, with SDK documentation and runtime observations for integration checks. Use this skill whenever the user mentions RequestShield, IntelliFend, `X-IntelliFend-Token`, `IntelliFend.getToken()`, `data-protect`, `@RequestShieldProtected`, App Key or API Secret setup, or asks to protect an endpoint such as registration, sign-in, password reset, checkout, or form submission from bots, scripted abuse, or credential stuffing — even when they never name the product. Also use it before hand-editing any file that already contains a RequestShield script tag, `verify()` call, or protection annotation.
4
+ ---
5
+
6
+ # RequestShield integration
7
+
8
+ Every RequestShield integration has two halves, and the split is the thing to
9
+ understand before writing any code:
10
+
11
+ 1. **The browser** obtains a short-lived token and transports it with the protected
12
+ request, as the `X-IntelliFend-Token` header.
13
+ 2. **The backend** evaluates that token and enforces the decision before the protected
14
+ operation runs.
15
+
16
+ The browser half is a *transport*, never a gate. A page that obtains tokens whose
17
+ backend never verifies them has zero protection while looking fully integrated — the
18
+ most common way this integration silently fails. Equally, an annotation on a handler
19
+ creates no browser configuration. **Browser configuration and backend protection are
20
+ configured independently, and neither one implies the other.** Land both halves in the
21
+ same change and verify both.
22
+
23
+ Protect the operation that performs the business mutation — registration, sign-in,
24
+ password reset, checkout, form submission — not a read-only route in front of it.
25
+
26
+ ## Before touching integration files
27
+
28
+ ```bash
29
+ requestshield --version # is the CLI present?
30
+ requestshield auth status --json # local session metadata, no provider check
31
+ ```
32
+
33
+
34
+ If `requestshield --version` fails, explain that CLI account/app operations need
35
+ an installed compatible version. Do not substitute invented HTTP calls. SDK URLs,
36
+ headers, modes and backend requirements come from the customer documentation for
37
+ the chosen SDK release; the integration-contract CLI command is unavailable.
38
+
39
+ If local status is `signed_out`, ask the user to complete `requestshield signin`
40
+ themselves. Never ask for credentials. `valid` is a local state only; an expired
41
+ session may refresh during the next authenticated command.
42
+
43
+ Those commands are the preflight for integration-changing work. For read-only CLI
44
+ questions, go to **Classify the request** and run only the matching command.
45
+
46
+ ## Classify the request
47
+
48
+ Only **Install** and **Uninstall** are step-locked sequences. Every other intent is a
49
+ single CLI call or a short answer. Match on what the user wants, not on exact wording.
50
+
51
+ | Intent | Sounds like | Do this |
52
+ | --- | --- | --- |
53
+ | **General info** | "what version", "is there a newer CLI", "am I up to date" | Use `requestshield --version`. For an explicitly requested update check, explain that production `update check` can offer a global npm installation; accept it only within the user’s requested scope. |
54
+ | **Authentication** | "sign me in", or preflight `auth status` came back unauthenticated | Ask the user to run `requestshield signin` in their own terminal, and wait. It is interactive — never automate it, never run it for them, never ask for credentials. Re-run `auth status` once they confirm. |
55
+ | **Key / secret management** | "create an app key", "I need an API Secret", "rotate the secret", "deactivate a key" | **Hand the command over; do not run it.** → "Key and secret management" below. |
56
+ | **Install** | "add RequestShield", "protect /api/register" | `references/integration-planning.md` full flow → **Installing** → **Verifying** → **Negative test**. Do not reorder or skip a step. |
57
+ | **Uninstall** | "remove it", "roll it back" | `references/integration-planning.md` (Detect existing integration only) → **Uninstalling**. |
58
+ | **Verify / troubleshoot** | "is it set up right?", "why is it not blocking?", a reason code | `references/integration-planning.md` (Detect existing integration only) → **Verifying**. For a reason code, also read `references/troubleshooting.md`. |
59
+ | **Challenge volume** | "how much traffic", "how many challenges" | Explain that the CLI analytics command is unavailable. Use existing authorized monitoring; do not infer volume from app status. |
60
+ | **Billing** | "am I being charged", "what plan", "what are my limits" | Explain that billing is unavailable in this CLI; use the customer’s established billing/support channel. |
61
+ | **Service health** | "is the service up", "is it degraded" | No service-health CLI command exists. Inspect authorized health/monitoring evidence without exposing credentials. |
62
+ | **Agent setup** | "set this up for Codex too", "install the skill for Claude" | Run `requestshield agent setup` for auto-detection, or pass the requested agent: `--codex` or `--claude`. This installs agent guidance; it does not mint keys or edit customer application code. |
63
+ | **Anything else** | | Look the command up in `references/cli.md`. If it is not there, run `requestshield --help` rather than guessing at a flag. |
64
+
65
+ Full CLI surface, output shapes, and which commands need auth: `references/cli.md`.
66
+
67
+
68
+ For Install, `references/integration-planning.md` owns the full planning sequence:
69
+ Credentials check, Detect existing integration, Contract check, Gate, Then act on what
70
+ you found, and Choosing the mode. Keep the browser-mode and backend-path decisions
71
+ independent.
72
+
73
+ ## Key and secret management
74
+
75
+ Commands that display API secrets should run in the user's terminal so their
76
+ values never enter the agent's tool output or conversation. State-changing
77
+ commands must match the user's requested application and action.
78
+
79
+ ```console
80
+ requestshield keys create --app-name <name>
81
+ requestshield keys rotate <app-key>
82
+ requestshield keys reveal <app-key>
83
+ requestshield keys revoke <app-key>
84
+ requestshield apps disable <app-key>
85
+ ```
86
+
87
+ Create makes a new application. Rotate keeps the App Key and replaces its secret.
88
+ Reveal retrieves the current active secret when a prior response was lost; an
89
+ exposed secret instead requires rotation. Revoke invalidates the secret, while
90
+ application disable retains it. Acceptance is asynchronous, not proof of immediate
91
+ propagation. Explain the impact and storage requirement before the user runs a
92
+ command, then confirm secret presence only. Never ask them to paste a secret back.
93
+
94
+ Create/rename/enable do not prompt. Disable/rotate/revoke/reveal require confirmation
95
+ or `--yes`. Mutations other than reveal accept `--idempotency-key`; uncertain results
96
+ must be retried with identical arguments and the same key within seven days, never
97
+ a fresh key. A replay may return `apiSecret: null`; use explicit reveal rather than
98
+ automatically creating or rotating again. See `references/cli.md`.
99
+
100
+ ## Installing
101
+
102
+ For Install, run the full planning flow in `references/integration-planning.md` before
103
+ writing integration code: **Credentials check** → **Detect existing integration** →
104
+ **Contract check** → **Gate** → **Then act on what you found** → **Choosing the mode**.
105
+ It must settle the App Key, the existing-integration state, the contract values, the
106
+ backend path, and the browser mode before step 1 below.
107
+
108
+ 1. **Browser side** — add the hosted script once in `<head>`, using the `script_url`
109
+ from the published customer documentation for that SDK release, then follow the chosen browser reference:
110
+ - Seamless → `references/browser-seamless.md`
111
+ - Manual → `references/browser-manual.md`
112
+ 2. **Backend side** — add the dependency, configure `app-key` and `api-secret` from
113
+ environment variables, and enforce the decision before the mutation:
114
+ - Spring Boot 3 starter → `references/backend-spring-boot.md`
115
+ - Java core SDK → `references/backend-java-core.md`
116
+ 3. **Cross-origin API**, if the protected endpoint is on another origin — its CORS
117
+ response must allow the page origin, intended methods, and `X-IntelliFend-Token`.
118
+ 4. **CSP**, if the app sends one — merge, never replace. See
119
+ `references/browser-manual.md`.
120
+ 5. **Verify** — run the checklist below, then the negative test when safe.
121
+
122
+ ## Handling the App Key and API Secret
123
+
124
+ These two values have opposite handling rules:
125
+
126
+ - **App Key** is public. It belongs in the browser script tag and backend configuration.
127
+ The same value must appear on both sides or every token fails.
128
+ - **API Secret** is backend-only. It must reach the backend through an environment
129
+ variable or secret manager. Never write it into a source file, a committed `.env`, an
130
+ image layer, a CI config in the repo, or the chat transcript — and never echo it back
131
+ after reading it.
132
+
133
+ You never run the commands that display the API Secret, and you never read it back. The
134
+ hand-off and warning are in **Key and secret management** above. Afterwards refer to it
135
+ only as "the secret you just received".
136
+
137
+ If a secret has already reached a repo, a log, an artifact, or this transcript, the fix
138
+ is `requestshield keys rotate <app-key>`, run by the user.
139
+
140
+ ## Verifying
141
+
142
+ For standalone Verify / Troubleshoot, first run **Detect existing integration only** in
143
+ `references/integration-planning.md`. You are observing which browser mode and backend
144
+ path are in use, not choosing them — **Credentials check**, **Contract check**,
145
+ **Gate**, and **Choosing the mode** belong to the Install flow unless troubleshooting
146
+ evidence specifically points to a credential failure or an unreleased mode.
147
+
148
+ Then the static checks. They are deterministic and catch most real breakage.
149
+
150
+ - Exactly **one** SDK script tag, in `<head>`, loaded before any bundle that can issue a
151
+ protected request, with a real `data-app-key`.
152
+ - Seamless: every protected endpoint appears in `data-protect`, spelled as the exact
153
+ origin and pathname the browser actually requests — case and trailing slash included.
154
+ - Manual: every protected call site obtains a fresh token immediately before the request
155
+ and attaches it, including retry paths.
156
+ - Neither mode applied twice to the same operation.
157
+ - Backend: the dependency resolves, the App Key matches the browser's, the secret comes
158
+ from the environment, and the decision gates the mutation rather than only being
159
+ logged. Exactly one verification path per request.
160
+ - Cross-origin endpoints: CORS allows `X-IntelliFend-Token`.
161
+ - No token or secret in logs, analytics, URLs, or error reporting.
162
+
163
+ Structural correctness is not proof of enforcement. For runtime evidence,
164
+ exercise the endpoint in an authorized environment and inspect the browser request
165
+ and backend decision without recording tokens. The CLI challenge-volume command
166
+ is unavailable, and application status does not establish traffic. Report static
167
+ checks, observed requests and backend enforcement separately.
168
+
169
+ ### The negative test — the only proof of enforcement
170
+
171
+ Neither static checks nor observed browser traffic can prove the backend refuses a
172
+ tokenless mutation. The proof is a request the backend should reject.
173
+
174
+ Before running it, establish:
175
+
176
+ 1. The backend under test can reach its configured verification service and safe
177
+ metrics show a non-degraded control request. A platform-wide health report alone
178
+ would not establish that this backend’s local circuit has closed.
179
+ 2. The endpoint's effective mode is `BLOCK`, not `MONITOR`. Include any method-level
180
+ override when resolving the effective mode. `MONITOR` allows every request by design.
181
+ 3. A valid control request is available. Its authentication, session, CSRF state, route,
182
+ method, and body must remain valid during the comparison.
183
+ 4. Establish a way to observe degradation for the backend instance and App Key under
184
+ test. For the Spring Boot starter, use the `intellifend.requestshield.requests` metric and distinguish
185
+ `outcome=allowed, reason=ok` from `outcome=degraded, reason=service_unavailable`. For
186
+ the Java core SDK, use existing safe metrics or logs derived from `isDegraded()` and
187
+ `getReason().getCode()`. Never log the raw token, API Secret, session, or CSRF value.
188
+
189
+ **Confirm with the user before running this anywhere shared.** It exercises a real
190
+ mutation, so use a local or staging environment, or an endpoint whose write can be
191
+ undone. Do not fire it at production to "just check", and do not invent a body that
192
+ could create a real account.
193
+
194
+ First, send the control request through the normal integrated path with a fresh
195
+ RequestShield token. Confirm that it succeeds, reaches the intended mutation, and records
196
+ a non-degraded `ok` decision at the backend. A successful response produced by degraded
197
+ fail-open is not a valid control. Use a new token for every control attempt because
198
+ RequestShield tokens are single-use.
199
+
200
+ Then repeat the same request while preserving its valid authentication, session, CSRF
201
+ state, route, method, body, and other relevant headers. Remove only
202
+ `X-IntelliFend-Token`. Send it through a client that bypasses the Browser SDK so Seamless
203
+ mode cannot attach another token:
204
+
205
+ ```bash
206
+ curl -i -X POST https://<host>/api/register \
207
+ -H '<the same valid authentication and CSRF context>' \
208
+ -H 'Content-Type: application/json' \
209
+ -d '{ ...the same valid test body... }'
210
+ ```
211
+
212
+ Attribute the result to RequestShield rather than treating every 4xx as a pass.
213
+ Authentication, authorization, CSRF, and request validation can independently return a
214
+ 401, 403, or 400 before the protected mutation.
215
+
216
+ - **Spring Boot 3 starter:** pass only when the response is HTTP 403 with
217
+ `CHALLENGE_FAILED` and reason `missing_token`, and the handler produced no side effect.
218
+ - **Java core SDK:** read the handler before testing. Confirm that its
219
+ `!result.isAllowed()` branch rejects before the mutation, then verify that the
220
+ observed rejection corresponds to RequestShield's `missing_token` decision and
221
+ produced no side effect.
222
+ - **Any unrelated or unattributable 4xx:** inconclusive, not a pass. Fix the control
223
+ request or add safe RequestShield-specific observability before drawing a conclusion.
224
+ - **Any backend-specific degraded evidence, including `service_unavailable`:**
225
+ inconclusive. The SDK intentionally allows the request under its availability policy;
226
+ restore the backend's Challenge Server connectivity, wait for its circuit to recover,
227
+ and repeat with a new control token.
228
+
229
+ A `2xx`, or evidence that the mutation happened, is a confirmed missing-token
230
+ enforcement bypass only when backend-specific degradation has been ruled out for that
231
+ request. If backend-specific degradation evidence is absent or cannot be checked,
232
+ report the test as inconclusive—not as proof that enforcement is absent. When degradation
233
+ is ruled out, treat the bypass as the finding and go to `references/troubleshooting.md`.
234
+
235
+ ## Uninstalling
236
+
237
+ Run `references/integration-planning.md` Detect existing integration only before this
238
+ section. Remove only what RequestShield introduced, and confirm the list with the user
239
+ first:
240
+
241
+ 1. The script tag, including `data-protect` and any other RequestShield attributes.
242
+ 2. Manual-mode `getToken()` calls and the header lines they feed — leave the surrounding
243
+ request intact.
244
+ 3. The backend dependency, client configuration, and the enforcement: `verify()` calls
245
+ or `@RequestShieldProtected` annotations.
246
+ 4. RequestShield entries in the CSP header and in CORS allowed headers leave every
247
+ other source and header in place.
248
+ 5. Configuration keys and environment variable references.
249
+
250
+ Application disable is a separate action: `requestshield apps disable <app-key>`.
251
+ Perform or hand it off only when the user requested that live-state change; removing
252
+ integration code does not itself authorize revocation or disable.
253
+
254
+ ## Non-negotiables
255
+
256
+ These separate an integration that protects traffic from one that only looks like it:
257
+
258
+ - **Enforcement lives in the backend.** Application code in the browser must never
259
+ decide to allow, block, retry around, or interpret a token.
260
+ - **Browser configuration and backend protection are independent.** Neither implies the
261
+ other.
262
+ - **One browser mode and one backend path are selected independently.** Seamless is not
263
+ Spring Boot, and Manual is not Java core. Either browser mode may pair with either
264
+ supported backend path.
265
+ - **One token per protected request; a new token before every retry.** Tokens are
266
+ single-use; replaying one returns `token_replayed` and blocks the request.
267
+ - **One verification per request.** Never combine `@RequestShieldProtected` with a
268
+ manual `RequestShieldClient.verify()` on the same handler.
269
+ - **Forward a non-empty token unchanged.** Do not trim, re-encode, inspect, cache,
270
+ persist, log, or place it in a URL.
271
+ - When `getToken()` returns an empty string in Manual mode, omit the header and let the
272
+ backend apply its configured policy.
273
+ - **The API Secret stays at the backend.** Never put it in browser code,
274
+ client-visible responses, source control, logs, build artifacts, or chat transcripts.
275
+ - **Keep displayed secrets out of tool output.** Hand create/rotate/reveal to the
276
+ user and verify by presence only. Match other live-state changes to user intent.
277
+
278
+ ## Reference files
279
+
280
+ | File | Read it when |
281
+ | --- | --- |
282
+ | `references/cli.md` | Any CLI invocation — exact syntax, output shape, auth requirements |
283
+ | `references/integration-planning.md` | Credentials check, existing-integration detection, the contract check, backend gating (Java version, Spring Boot 3 MVC vs WebFlux, other frameworks), and browser-mode selection |
284
+ | `references/browser-manual.md` | Installing or auditing Manual mode; CSP rules |
285
+ | `references/browser-seamless.md` | Installing or auditing Seamless mode; matching and coverage limits |
286
+ | `references/backend-spring-boot.md` | Backend work on Spring Boot 3 MVC — the annotation path |
287
+ | `references/backend-java-core.md` | Backend work on any other Java 17 backend — the `verify()` path |
288
+ | `references/troubleshooting.md` | A block, a degraded result, or a reason code to explain |
289
+
290
+ ## For agent setup
291
+
292
+ `requestshield agent setup` installs this skill for the detected or requested agent.
293
+ Use `--codex` or `--claude` when the user names the target agent. Setup installs
294
+ into the agent’s personal skill directory; it does not edit repository `AGENTS.md`.
295
+ `assets/AGENTS.codex.md` is an optional template for a separately requested
296
+ repository instruction change.
297
+
298
+ Agent setup installs guidance only. It does not mint keys, rotate secrets, deactivate
299
+ keys, or edit customer application code.