/** * Read `urn:grantex:tools:v1` entries from a grant's `authorization_details`. * * This is the only place that interprets the `authorization_details` claim * (RFC 9396), so a change to the token format touches one function. Shape: * * ```json * "authorization_details": [{ * "type": "urn:grantex:tools:v1", * "connector": "acme_kyb", * "purpose": "aml.cdd.onboarding", * "data_region": "eu", * "tools": ["resolve_business", "verify_business", "screen_*"], * "caps": {"verify_business": {"per_hour": 50, "per_case": 3}, * "cost_units": {"per_day": 5000}} * }] * ``` * * Entries of other types are separate authorizations and are ignored here. A * tools entry constrains calls on its connector in addition to the grant's * scopes. Anything ambiguous (a claim that is not an array, an entry without * a string `type`, a tools entry with an unknown key, a value of the wrong * type, or two tools entries for one connector) throws * `AuthorizationDetailsError`, and `enforce()` denies. Mirrors the Python * SDK's `grantex._authorization_details`. * * `caps` is validated here, for every call on the connector: each key is an * exact tool name or `cost_units` (the connector's cost-unit budget), never a * wildcard, and each value is a non-empty object of `per_hour`, `per_day` and * `per_case` counts from 0 to 2147483647. */ export declare const TOOLS_DETAIL_TYPE = "urn:grantex:tools:v1"; declare const CAP_WINDOWS: readonly ['per_hour', 'per_day', 'per_case']; /** Key of the connector cost-unit budget in `caps`; reserved as a tool name. */ export declare const COST_UNITS_KEY = "cost_units"; export type CapWindowCounts = Partial>; export declare class AuthorizationDetailsError extends Error { constructor(message: string); } /** One `urn:grantex:tools:v1` entry. */ export interface ToolsAuthorization { connector: string; /** The grant's purpose for this connector, exactly as issued (not validated). */ purpose?: string; dataRegion?: string; /** Tool names, or prefixes ending in `*`; absent means every tool. */ tools?: readonly string[]; /** Validated caps: tool name (or `cost_units`) to window to count. */ caps?: Readonly>>; } /** Whether an entry's `tools` list (when present) names `tool`. */ export declare function toolsAuthorizationAllows(entry: ToolsAuthorization, tool: string): boolean; /** * Return the tools entries of an `authorization_details` claim by connector. * `undefined` or `null` (no claim) yields an empty map. * * @throws {AuthorizationDetailsError} the claim is malformed or ambiguous. */ export declare function parseToolsAuthorization(claim: unknown): Map; export declare const DECISION_DETAIL_TYPE = "urn:grantex:decision:v1"; /** * One `urn:grantex:decision:v1` entry: tools on a connector that need a * decision grant, and the decisions on each that need two approvers. * * ```json * {"type": "urn:grantex:decision:v1", "connector": "acme_kyb", * "tools": ["case_decision"], "four_eyes_on": {"case_decision": ["decline"]}} * ``` */ export interface DecisionReference { connector: string; tools: readonly string[]; fourEyesOn: Readonly>; } /** * Return the decision references of an `authorization_details` claim by * connector. `undefined` or `null` yields an empty map. Entries of other types * are ignored. * * @throws {AuthorizationDetailsError} an entry is malformed: an unknown key, no * tools, a tool name that is not a name, `four_eyes_on` naming a tool not in * `tools`, or two entries for one connector. */ export declare function parseDecisionReferences(claim: unknown): Map; export {}; //# sourceMappingURL=authorization-details.d.ts.map