@adcp/sdk API Reference - v7.9.0
    Preparing search index...

    Function assertSandboxAccount

    • Throws an AdcpError('PERMISSION_DENIED') if the account is not in a non-production mode. Use to gate dispatch of test-only surfaces.

      Fail-closed semantics:

      • account === undefined (no resolved account): throws.
      • account.mode === 'live' or unspecified + no sandbox: true: throws.
      • account.mode === 'sandbox' | 'mock' (or legacy sandbox: true): no-op, dispatch proceeds.

      The details payload carries { scope: 'sandbox-gate', tool? } so dashboards can distinguish gate-rejections from other permission denials.

      Resolver discipline. The strength of this gate depends entirely on how the adopter's AccountStore.resolve constructs its return value. Resolvers MUST NOT spread untrusted input (request body, headers, ctx_metadata, query params) into the resolved account — doing so lets a buyer self-promote to mode: 'sandbox' and unlock test-only surfaces on a live principal. Source mode (and sandbox) from a trusted store keyed by the authenticated principal; never from request data.

      opts.message must be a static string literal. The message is echoed on the wire inside the error envelope. Interpolating user-controlled values into it creates a reflection sink (PII leakage, log injection, downstream HTML rendering). Pick from a fixed set of messages keyed by tool if you need variants.

      Parameters

      • account: unknown

        The resolved account (typically ctx.account inside a tool dispatch). Pass undefined if no account resolved — the helper fails closed.

      • opts: { tool?: string; message?: string } = {}
        • Optionaltool?: string

          Optional tool name to surface in the error details (e.g., 'comply_test_controller').

        • Optionalmessage?: string

          Optional override for the user-facing message. MUST be a static string literal — see "opts.message" note above.

      Returns void

      import { assertSandboxAccount } from '@adcp/sdk/server';

      sandboxGate: input => {
      const account = await resolveAccount(input);
      assertSandboxAccount(account, { tool: 'comply_test_controller' });
      return true;
      }