Skip to content
View as Markdown
View as Markdown

@salesforce/b2c-tooling-sdk / clients / createSafetyMiddleware

Function: createSafetyMiddleware()

createSafetyMiddleware(guard): Middleware

Defined in: packages/b2c-tooling-sdk/src/clients/middleware.ts:563

Creates safety middleware that evaluates HTTP requests against a SafetyGuard.

This middleware intercepts HTTP requests BEFORE they are sent. It evaluates each request against the guard's rules and level, throwing:

  • SafetyBlockedError for blocked operations
  • SafetyConfirmationRequired for operations needing confirmation

Callers that want confirmation support should wrap their SDK calls with withSafetyConfirmation. Otherwise, both error types propagate as errors.

Parameters

guard

SafetyGuard

The SafetyGuard instance

Returns

Middleware

Middleware that evaluates operations against safety rules

Example

typescript
const guard = new SafetyGuard({ level: 'NO_DELETE' });
const client = createOdsClient(config, auth);
client.use(createSafetyMiddleware(guard));

Released under the Apache-2.0 License.