/** * Offline verification of decision grants (PRD G-3). * * Verification proves that a decision grant is authentic, unexpired and * approves exactly the action about to be performed on the current case * version, and, for four eyes, that two different people approved it. It does * not prove that the grant has not been used: that needs the issuer's atomic * consumption (`grantex.decisions.consume()`), which `enforce()` performs * before it allows the call. The Python SDK implements the same rules * (`grantex.decisions`); the token profile is `spec/decision-grant.md`. */ import { type JWTVerifyGetKey } from 'jose'; import { DecisionSubReason } from '../denials.js'; import { type DecisionAction } from './action.js'; export declare const DECISION_GRANT_TYP = "decision+jwt"; export declare const DECISION_GRANT_AUDIENCE = "urn:grantex:decision"; /** A decision grant is absent, unusable or does not match the call. */ export declare class DecisionGrantError extends Error { readonly subReason: DecisionSubReason; constructor(subReason: DecisionSubReason, message: string); } export interface FourEyes { approvalsRequired: 2; position: 1 | 2; firstJti?: string; firstSub?: string; } /** The verified claims of one decision grant. */ export interface DecisionGrant { token: string; jti: string; iss: string; sub: string; dev: string; idp: string; approverAuth: string; acr?: string; amr: string[]; authTime: number; action: DecisionAction; actionHash: string; connector: string; caseVersion: string; dwellMs: number; /** Always `server`: the issuer measured the dwell time. */ dwellSource: 'server'; decisionRequest: string; memoHash: string; policyScoreHash: string; iat: number; exp: number; memoRef?: string; policyScoreRef?: string; fourEyes?: FourEyes; } /** Decision grants that together authorise one action. */ export interface DecisionGrantSet { grants: DecisionGrant[]; action: DecisionAction; actionHash: string; caseVersion: string; approvalsRequired: 1 | 2; } /** A verification key, or a resolver that picks one from the protected header. */ export type DecisionKey = CryptoKey | Uint8Array | JWTVerifyGetKey; export interface VerifyDecisionGrantOptions { /** Expected `iss`. */ issuer: string; /** JWKS URL of the issuer; used when `key` is not given. */ jwksUri?: string; /** Verification key or resolver; overrides `jwksUri`. */ key?: DecisionKey; /** The grant must have been issued to this developer (`dev`). */ developerId?: string; /** The grant must be for this connector. */ connector?: string; /** Accepted algorithms, a subset of RS256 and ES256. Default both. */ algorithms?: string[]; /** Seconds of clock tolerance. Default 0. */ clockTolerance?: number; /** Current time in seconds (for tests). */ now?: number; /** * Fetch the issuer's JWK Set from `jwksUri` within the bounds that * `verifyGrantToken`'s `boundedJwksFetch` applies: HTTP 200 only, * `application/json` or `application/jwk-set+json`, at most 64 KiB and 128 * keys, 5 seconds for the whole exchange. Defaults to `false`; a later * major release makes `true` the default, with `false` as the opt-out. */ boundedJwksFetch?: boolean; } export interface VerifyDecisionGrantsOptions extends VerifyDecisionGrantOptions { /** 2 when the manifest lists the decision in `four_eyes_on`. Default 1. */ approvalsRequired?: 1 | 2; } /** * Verifies one decision grant against the action about to be performed. * Refusals (`DecisionGrantError.subReason`): `malformed` (type, signature, * issuer, audience, claims, or an `action_hash` that is not the hash of the * `action` claim), `unknown_grant` (another developer), `wrong_case`, * `action_mismatch` (another action or connector), `case_changed`, `expired`. * Single use is not checked here. */ export declare function verifyDecisionGrant(token: string, expectedAction: DecisionAction, caseVersion: string, options: VerifyDecisionGrantOptions): Promise; /** * Verifies the decision grants for one action, including four eyes: with two * approvals required (from the manifest, or because a grant says so) exactly * two grants with different `sub` are needed, the second naming the first. */ export declare function verifyDecisionGrants(tokens: readonly string[], expectedAction: DecisionAction, caseVersion: string, options: VerifyDecisionGrantsOptions): Promise; //# sourceMappingURL=verify.d.ts.map