testing/cross_backend/narrowed_api_token.ts

Mint a narrowed (method-scoped) api token through the production account_token_create path, for suites that probe what a narrowed token is refused.

Minted rather than seeded: the token comes out of the same handler a real minter uses, on whichever account owns the session the caller passes — so a suite can put a narrowed token on an account that lacks a gating role, and the mint itself asserts that a narrowed scope is accepted at the mint boundary, not merely stored.

view source

Declarations
#

2 declarations

mint_narrowed_api_token
#

testing/cross_backend/narrowed_api_token.ts view source

(options: MintNarrowedApiTokenOptions): Promise<string> import {mint_narrowed_api_token} from '@fuzdev/fuz_app/testing/cross_backend/narrowed_api_token.js';

Mint a narrowed api token and return its raw bearer value.

options

returns

Promise<string>

the raw token, for an Authorization: Bearer header

throws

  • Error - when the mint is refused, naming the status and error

MintNarrowedApiTokenOptions
#

testing/cross_backend/narrowed_api_token.ts view source

MintNarrowedApiTokenOptions import type {MintNarrowedApiTokenOptions} from '@fuzdev/fuz_app/testing/cross_backend/narrowed_api_token.js';

app

Transport the mint goes over — it must carry an allowed Origin (the default rpc_call one does).

type RpcCallApp

readonly

rpc_path

RPC endpoint path account_token_create is mounted on.

type string

readonly

session_headers

Session credential headers of the account that owns the token — the mint is session-only.

type Record<string, string>

readonly

methods

The RPC methods the token admits; every other method and every non-RPC surface refuses it.

type readonly string[]

readonly

name?

Token label. Default 'narrowed test token'.

type string

readonly

Depends on
#

Imported by
#