Skip to content

Commit 815a636

Browse files
committed
format other relevant mdx files
1 parent 40e6887 commit 815a636

8 files changed

Lines changed: 40 additions & 98 deletions

File tree

src/content/docs/api-shield/security/jwt-validation/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
DashButton,
1515
} from "~/components";
1616

17-
{/* prettier-ignore */}
1817
<GlossaryTooltip term="JSON web token (JWT)">JSON web tokens (JWT)</GlossaryTooltip> are often used as part of an authentication component on many web applications today. Since JWTs are crucial to identifying users and their access, ensuring the token’s integrity is important.
1918

2019
API Shield’s JWT validation stops JWT replay attacks and JWT tampering by cryptographically verifying incoming JWTs before they are passed to your API origin. JWT validation will also stop requests with expired tokens or tokens that are not yet valid.
@@ -126,7 +125,7 @@ API Shield will verify JSON Web Tokens regardless of whether or not they have th
126125

127126
### Ignore `OPTIONS` pre-flight CORS requests
128127

129-
Due to cross-origin resource sharing (CORS) security, web browsers will send "pre-flight" requests using the `OPTIONS` verb to API endpoints before sending a `GET` (or other verb) request. By definition, `OPTIONS` requests do not include headers or cookies and are anonymous.
128+
Due to cross-origin resource sharing (CORS) security, web browsers will send "pre-flight" requests using the `OPTIONS` verb to API endpoints before sending a `GET` (or other verb) request. By definition, `OPTIONS` requests do not include headers or cookies and are anonymous.
130129

131130
If you expect web browsers to be valid clients of your API, and to prevent blocking `OPTIONS` requests from those browsers, Cloudflare recommends adding `or http.request.method eq "OPTIONS"` to your JWT validation rules.
132131

@@ -137,6 +136,7 @@ If you expect web browsers to be valid clients of your API, and to prevent block
137136
JWT validation is available for all API Shield customers. Enterprise customers who have not purchased API Shield can preview [API Shield as a non-contract service](https://dash.cloudflare.com/?to=/:account/:zone/security/api-shield) in the Cloudflare dashboard or by contacting your account team.
138137

139138
---
139+
140140
## Limitations
141141

142142
Currently, the following known limitations exist:

src/content/docs/api-shield/security/schema-validation/index.mdx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ You can migrate to Schema validation 2.0 manually by uploading your schemas to t
2929

3030
## Process
3131

32-
{/* prettier-ignore */}
3332
<GlossaryTooltip term="API endpoint">Endpoints</GlossaryTooltip> must be added to [Endpoint Management](/api-shield/management-and-monitoring/endpoint-management/) for Schema validation to protect them. Uploading a schema via the Cloudflare dashboard will automatically add endpoints, or you can manually add them from [API Discovery](/api-shield/security/api-discovery/).
3433

3534
If you are uploading a schema via the API or Terraform, you must parse the schema and add your endpoints manually.
@@ -434,12 +433,12 @@ Schema validation inspects request bodies up to a maximum size that depends on y
434433

435434
The default body size limits are:
436435

437-
| Plan | Default body size limit |
438-
| --- | --- |
439-
| Free | 1 KB |
440-
| Pro | 8 KB |
441-
| Business | 8 KB |
442-
| Enterprise | 128 KB |
436+
| Plan | Default body size limit |
437+
| ---------- | ----------------------- |
438+
| Free | 1 KB |
439+
| Pro | 8 KB |
440+
| Business | 8 KB |
441+
| Enterprise | 128 KB |
443442

444443
:::note
445444
This limit is separate from the [WAF maximum body inspection size](/waf/managed-rules/#maximum-body-size), which controls how much of the request payload the WAF scans. Increasing one does not affect the other.

src/content/docs/durable-objects/api/base.mdx

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ class MyDurableObject(DurableObject):
5656
5757
### `fetch`
5858
59-
- <code>
60-
fetch(request <Type text="Request" />)
61-
</code>
59+
- <code>fetch(request <Type text="Request" />)</code>
6260
: <Type text="Response" /> | <Type text="Promise<Response>" />- Takes an HTTP
6361
[Request](https://developers.cloudflare.com/workers/runtime-apis/request/) and
6462
returns an HTTP
@@ -93,16 +91,11 @@ export class MyDurableObject extends DurableObject<Env> {
9391

9492
### `alarm`
9593

96-
- <code>
97-
alarm(alarmInfo? <Type text="AlarmInvocationInfo" />)
98-
</code>
94+
- <code>alarm(alarmInfo? <Type text="AlarmInvocationInfo" />)</code>
9995
: <Type text="void" /> | <Type text="Promise<void>" />
10096
- Called by the system when a scheduled alarm time is reached.
101-
10297
- The `alarm()` handler has guaranteed at-least-once execution and will be retried upon failure using exponential backoff, starting at two second delays for up to six retries. Retries will be performed if the method fails with an uncaught exception.
103-
10498
- This method can be `async`.
105-
10699
- Refer to [Alarms](/durable-objects/api/alarms/) for more information.
107100

108101
#### Parameters
@@ -132,10 +125,7 @@ export class MyDurableObject extends DurableObject<Env> {
132125

133126
### `webSocketMessage`
134127

135-
- <code>
136-
webSocketMessage(ws <Type text="WebSocket" />, message{" "}
137-
<Type text="string | ArrayBuffer" />)
138-
</code>
128+
- <code>webSocketMessage(ws <Type text="WebSocket" />, message <Type text="string | ArrayBuffer" />)</code>
139129
: <Type text="void" /> | <Type text="Promise<void>" />- Called by the system
140130
when an accepted WebSocket receives a message. - This method is not called for
141131
WebSocket control frames. The system will respond to an incoming [WebSocket
@@ -170,10 +160,7 @@ export class MyDurableObject extends DurableObject<Env> {
170160

171161
### `webSocketClose`
172162

173-
- <code>
174-
webSocketClose(ws <Type text="WebSocket" />, code <Type text="number" />,
175-
reason <Type text="string" />, wasClean <Type text="boolean" />)
176-
</code>
163+
- <code>webSocketClose(ws <Type text="WebSocket" />, code <Type text="number" />, reason <Type text="string" />, wasClean <Type text="boolean" />)</code>
177164
: <Type text="void" /> | <Type text="Promise<void>" />- Called by the system
178165
when a WebSocket connection is closed.
179166
- With the [`web_socket_auto_reply_to_close`](/workers/configuration/compatibility-flags/#websocket-auto-reply-to-close) compatibility flag (enabled by default on compatibility dates on or after `2026-04-07`), the runtime automatically sends a reciprocal Close frame and transitions `readyState` to `CLOSED` before this handler is called. You do not need to call `ws.close()` — but doing so is safe (the call is silently ignored).
@@ -209,9 +196,7 @@ export class MyDurableObject extends DurableObject<Env> {
209196

210197
### `webSocketError`
211198

212-
- <code>
213-
webSocketError(ws <Type text="WebSocket" />, error <Type text="unknown" />)
214-
</code>
199+
- <code>webSocketError(ws <Type text="WebSocket" />, error <Type text="unknown" />)</code>
215200
: <Type text="void" /> | <Type text="Promise<void>" />- Called by the system
216201
when a non-disconnection error occurs on a WebSocket connection. - This method
217202
can be `async`.

src/content/docs/durable-objects/best-practices/websockets.mdx

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,7 @@ The following methods are available on the Hibernation WebSocket API. Use them t
321321

322322
#### `WebSocket.serializeAttachment`
323323

324-
- <code>
325-
serializeAttachment(value <Type text="any" />)
326-
</code>
324+
- <code>serializeAttachment(value <Type text="any" />)</code>
327325
: <Type text="void" />
328326

329327
Keeps a copy of `value` associated with the WebSocket connection.
@@ -362,34 +360,35 @@ export class WebSocketServer extends DurableObject<Env> {
362360
const url = new URL(request.url);
363361
const orderId = url.searchParams.get("orderId") ?? "anonymous";
364362

365-
const webSocketPair = new WebSocketPair();
366-
const [client, server] = Object.values(webSocketPair);
363+
const webSocketPair = new WebSocketPair();
364+
const [client, server] = Object.values(webSocketPair);
367365

368-
this.ctx.acceptWebSocket(server);
366+
this.ctx.acceptWebSocket(server);
369367

370-
// Persist per-connection state that survives hibernation
371-
const state: ConnectionState = {
372-
orderId,
373-
joinedAt: Date.now(),
374-
};
375-
server.serializeAttachment(state);
368+
// Persist per-connection state that survives hibernation
369+
const state: ConnectionState = {
370+
orderId,
371+
joinedAt: Date.now(),
372+
};
373+
server.serializeAttachment(state);
376374

377-
return new Response(null, { status: 101, webSocket: client });
378-
}
375+
return new Response(null, { status: 101, webSocket: client });
376+
}
379377

380-
async webSocketMessage(ws: WebSocket, message: string | ArrayBuffer) {
381-
// Restore state after potential hibernation
382-
const state = ws.deserializeAttachment() as ConnectionState;
383-
ws.send(`Hello ${state.orderId}, you joined at ${state.joinedAt}`);
384-
}
378+
async webSocketMessage(ws: WebSocket, message: string | ArrayBuffer) {
379+
// Restore state after potential hibernation
380+
const state = ws.deserializeAttachment() as ConnectionState;
381+
ws.send(`Hello ${state.orderId}, you joined at ${state.joinedAt}`);
382+
}
383+
384+
async webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean) {
385+
const state = ws.deserializeAttachment() as ConnectionState;
386+
console.log(`${state.orderId} disconnected`);
387+
// With web_socket_auto_reply_to_close (compat date >= 2026-04-07), the runtime
388+
// auto-replies to Close frames. Calling close() is safe but no longer required.
389+
ws.close(code, reason);
390+
}
385391

386-
async webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean) {
387-
const state = ws.deserializeAttachment() as ConnectionState;
388-
console.log(`${state.orderId} disconnected`);
389-
// With web_socket_auto_reply_to_close (compat date >= 2026-04-07), the runtime
390-
// auto-replies to Close frames. Calling close() is safe but no longer required.
391-
ws.close(code, reason);
392-
}
393392
}
394393

395394
````

0 commit comments

Comments
 (0)