import type { CapsMeter, CapsMode } from './caps/meter.js'; import type { RevocationCheckMode, RevocationFeedOptions } from './revocations/index.js'; import type { DecisionConsumer } from './resources/decisions.js'; export interface RateLimit { limit: number; remaining: number; reset: number; retryAfter?: number; } export interface GrantexClientOptions { /** Grantex API key. Defaults to GRANTEX_API_KEY env variable. */ apiKey?: string; /** Base URL for the Grantex API. Defaults to https://api.grantex.dev */ baseUrl?: string; /** Override the JWKS URL used for local signature verification. The verifier retrieves keys from this URL. */ jwksUri?: string; /** Expected JWT issuer for local signature verification. Set this when tokens use a canonical domain different from `baseUrl`. */ issuer?: string; /** Request timeout in milliseconds. Defaults to 30000. */ timeout?: number; /** Maximum number of retries for transient failures (429, 502, 503, 504). Defaults to 3. Set to 0 to disable. */ maxRetries?: number; /** Meter for tools and grants that declare caps; without one such calls are denied. */ capsMeter?: CapsMeter; /** * Whether `enforce()` reads legacy grant token claim aliases. Defaults to * `true` in 0.6 and `false` from 0.7; see `VerifyGrantTokenOptions.legacyClaims`. */ legacyClaims?: boolean; /** `enforce` (default) denies over-cap calls, `warn` allows them and reports `wouldDeny` / `wouldDenyAll`, `off` skips caps. */ capsMode?: CapsMode; /** * Read the tool segment of `tool:::` scopes in `enforce()`. * On, a tool's permission comes from connector-level scopes and scopes naming that tool, * and a connector whose scopes all name other tools denies with `tool_not_granted` / * `tool_scope_missing`. Off (the default in this release) reads a tool-qualified scope as * the connector permission, as earlier releases did. */ toolQualifiedScopes?: boolean; /** * How `enforce()` finds out about revocations (PRD G-6). `online` (the * default) asks the auth service about every call, and denies if it cannot. * `feed` follows the revocation feed and denies within seconds, failing * closed when the feed goes stale. `offline` is the explicit opt-out: a * revoked grant's token stays valid until it expires. */ revocationCheck?: RevocationCheckMode; /** Settings for `revocationCheck: 'feed'`. */ revocationFeed?: RevocationFeedOptions; /** * `enforce` (default) denies a `requires_decision` call without a valid, consumed decision * grant; `warn` allows it and reports `wouldDeny` / `wouldDenyAll`. Platforms map their `decisions.required` * flag to `enforce` (on) or `warn` (off). */ decisionsMode?: 'enforce' | 'warn'; /** Consumes decision grants at their issuer. Defaults to `grantex.decisions` (the auth service). */ decisionConsumer?: DecisionConsumer; /** Algorithms accepted on decision grants, a subset of RS256 and ES256. Default both. */ decisionAlgorithms?: readonly ('RS256' | 'ES256')[]; /** * The grant token audience `enforce()` expects (RFC 7519 section 4.1.3). A token * whose `aud` does not contain it, or that has no `aud`, is denied with * `token_invalid` / `audience_mismatch`. `enforce({ audience })` overrides it per call. */ audience?: string; /** * `on` (default) checks the grant token's `aud` in `enforce()`: without an expected * audience, a token that carries `aud` is denied with `token_invalid` / * `audience_unconfigured`. `off` ignores `aud`, as releases before the check did, * and cannot be combined with `audience`. Audience denials are not relaxed by * `enforceMode: 'permissive'`: they stay `allowed: false` in every enforce mode. */ audienceCheck?: 'on' | 'off'; /** * The data region this relying party processes data in (for example `in`). With * `dataRegionCheck: 'on'`, a grant whose tools entry for the connector names another * region is denied with `region_mismatch` / `region_mismatch`, and one that names a * region when no region is configured with `region_mismatch` / `region_unconfigured`. * Compared after trimming and lowercasing. `enforce({ dataRegion })` overrides it per call. */ dataRegion?: string; /** * `off` (the default in this release) ignores a grant's `data_region`, as earlier * releases did; `on` checks it in `enforce()`. Cannot be `off` with `dataRegion` set. * Region denials are not relaxed by `enforceMode: 'permissive'`. */ dataRegionCheck?: 'on' | 'off'; } export interface SignupParams { name: string; email?: string; mode?: 'live' | 'sandbox'; } export interface SignupResponse { developerId: string; apiKey: string; name: string; email: string | null; mode: 'live' | 'sandbox'; createdAt: string; } export interface RotateKeyResponse { apiKey: string; rotatedAt: string; } export interface RegisterAgentParams { name: string; description: string; scopes: string[]; /** Exact callback URIs accepted for this Agent. */ redirectUris?: string[]; /** RFC 8707 resource identifiers this Agent may request. */ resourceServers?: string[]; /** Public asymmetric JWK used to bind grants to the Agent key. */ publicJwk?: Record; /** Lifecycle state at registration: `draft` (registered, not yet usable) or `active` (the default). */ status?: 'draft' | 'active'; } export interface UpdateAgentParams { name?: string; description?: string; scopes?: string[]; redirectUris?: string[]; resourceServers?: string[]; publicJwk?: Record; /** Lifecycle: draft becomes active; active and suspended swap; either retires; retired is final. */ status?: 'draft' | 'active' | 'suspended' | 'retired'; /** Why the status changed; recorded on the agent. */ statusReason?: string; } export interface Agent { /** Stable SDK identifier (normalized from the API's `agentId` field). */ id: string; /** Identifier as named by the HTTP API. Equal to `id`. */ agentId: string; did: string; name: string; description: string; scopes: string[]; status: 'draft' | 'active' | 'suspended' | 'retired' | 'revoked'; statusChangedAt?: string | null; statusReason?: string | null; retiredAt?: string | null; developerId: string; createdAt: string; updatedAt: string; redirectUris?: string[]; resourceServers?: string[]; publicJwk?: Record | null; keyThumbprint?: string | null; keyBindingConfigured?: boolean; } export interface ListAgentsResponse { agents: Agent[]; } export interface AuthorizeParams { agentId: string; /** Your app's user identifier — mapped to principalId in the request body. */ userId: string; scopes: string[]; /** Intended recipient of the grant token (`aud` claim). */ audience?: string; expiresIn?: string; redirectUri?: string; /** Opaque CSRF correlation value; required when redirectUri is used. */ state?: string; /** PKCE S256 code challenge (from generatePkce()) */ codeChallenge?: string; /** Must be 'S256' when codeChallenge is provided */ codeChallengeMethod?: string; /** Purpose of the grant, e.g. `aml.cdd.onboarding` (see `PURPOSE_VOCABULARY`). */ purpose?: string; /** * The data region the grant's data may be processed in (`in`, `eu`, ...). Carried in the * token's `urn:grantex:tools:v1` entries; relying parties with `dataRegionCheck: 'on'` refuse * the token outside it. Needs at least one `tool::` scope. */ dataRegion?: string; } export interface AuthorizationRequest { authRequestId: string; consentUrl: string; agentId: string; principalId: string; scopes: string[]; expiresIn: string; expiresAt: string; status: 'pending' | 'approved' | 'denied' | 'expired'; createdAt: string; /** Returned when sandbox mode or policy auto-approve */ code?: string; /** Returned when sandbox mode is active */ sandbox?: boolean; /** Returned when a policy was enforced */ policyEnforced?: boolean; /** Returned when a policy was enforced */ effect?: 'allow' | 'deny'; /** Purpose the request binds the grant to, when one was given. */ purpose?: string; /** Data region the request binds the grant to (lowercased), when one was given. */ dataRegion?: string; } export interface Grant { id: string; agentId: string; agentDid: string; principalId: string; developerId: string; scopes: string[]; status: 'active' | 'revoked' | 'expired'; issuedAt: string; expiresAt: string; revokedAt?: string; /** Purpose the grant is bound to, when it has one. */ purpose?: string; webauthnEvidence?: WebAuthnGrantEvidence; } export interface ListGrantsParams { agentId?: string; principalId?: string; status?: 'active' | 'revoked' | 'expired'; page?: number; pageSize?: number; } export interface ListGrantsResponse { grants: Grant[]; } /** Issuer-signed reference to the WebAuthn assertion evidence in an opt-in VC. */ export interface WebAuthnGrantEvidence { type: 'GrantexWebAuthnAssertion'; version: 1; authRequestId: string; rpId: string; origin: string; userVerified: boolean; assertedAt: string; digest: string; } export interface VerifiedGrant { /** Signed issuer URL, retained for binding online authority responses. */ issuer?: string; /** Grant/token unique ID (jti claim) */ tokenId: string; /** Grant record ID */ grantId: string; /** The end-user who authorized this agent (sub claim) */ principalId: string; /** The agent's DID (agt claim) */ agentDid: string; /** Developer org (dev claim) */ developerId: string; /** OAuth client registration identifier (`client_id` claim), when present. */ clientId?: string; /** Granted scopes (scp claim) */ scopes: string[]; /** Token issued-at timestamp (seconds since epoch) */ issuedAt: number; /** Token expiry timestamp (seconds since epoch) */ expiresAt: number; /** Parent agent DID (delegated grants only) */ parentAgentDid?: string; /** Parent grant ID (delegated grants only) */ parentGrantId?: string; /** Delegation depth (0 = root, n = nth-level delegation) */ delegationDepth?: number; /** Raw `authorization_details` claim (RFC 9396), when present. */ authorizationDetails?: unknown; /** RFC 8693 `act` claim: the delegating actor, with earlier actors nested. */ act?: ActorClaim; /** Confirmation claim (`cnf`), e.g. `{ jkt }` for a DPoP-bound token. */ cnf?: { jkt?: string; [member: string]: unknown; }; /** Audience (`aud`), when the grant is bound to a resource. */ audience?: string | string[]; /** A signed evidence reference, not the raw assertion. Match digest to a VC and verify both. */ webauthnEvidence?: WebAuthnGrantEvidence; /** * Legacy claim aliases this result was read from because the token had no * standard claim for them (for example `scp` without `scope`). Empty for * standard-claim tokens. Reading aliases is deprecated; disable legacyClaims * to require standard claims. */ legacyClaimsUsed?: string[]; } /** RFC 8693 actor claim. Nested `act` members are earlier actors. */ export interface ActorClaim { sub: string; act?: ActorClaim; [member: string]: unknown; } export interface DelegateParams { parentGrantToken: string; subAgentId: string; scopes: string[]; expiresIn?: string; } export interface ExchangeTokenParams { code: string; agentId: string; /** PKCE code verifier (from generatePkce()) — required if codeChallenge was sent in authorize */ codeVerifier?: string; /** Must exactly match the URI used in authorize when one was supplied. */ redirectUri?: string; /** Request a verifiable credential alongside the grant token */ credentialFormat?: 'jwt' | 'vc-jwt' | 'both'; } export interface ExchangeTokenResponse { grantToken: string; expiresAt: string; scopes: string[]; refreshToken: string; grantId: string; /** SD-JWT verifiable credential (present when credentialFormat was requested) */ verifiableCredential?: string; } export interface RefreshTokenParams { refreshToken: string; agentId: string; /** Stable across a retry of a response-lost refresh request. Generated when omitted. */ idempotencyKey?: string; } export interface VerifyTokenResponse { valid: boolean; grantId?: string; scopes?: string[]; principal?: string; agent?: string; expiresAt?: string; } export interface CreatePrincipalSessionParams { principalId: string; expiresIn?: string; } export interface PrincipalSessionResponse { sessionToken: string; dashboardUrl: string; expiresAt: string; } export interface LogAuditParams { agentId: string; agentDid: string; grantId: string; principalId: string; action: string; metadata?: Record; status?: 'success' | 'failure' | 'blocked'; } export interface AuditEntry { entryId: string; agentId: string; agentDid: string; grantId: string; principalId: string; action: string; metadata: Record; hash: string; prevHash: string | null; timestamp: string; status: 'success' | 'failure' | 'blocked'; /** Purpose of the grant the entry was recorded under, when it has one. */ purpose?: string; } export interface ListAuditParams { agentId?: string; grantId?: string; principalId?: string; action?: string; since?: string; until?: string; page?: number; pageSize?: number; } export interface ListAuditResponse { entries: AuditEntry[]; } export interface AuditCheckpoint { checkpointId: string; headEntryId: string; headHash: string; headTimestamp: string; entryCount: number; signedCheckpoint: string; witnessRequired: true; } export type WebhookEventType = 'grant.created' | 'grant.revoked' | 'token.issued'; export interface CreateWebhookParams { url: string; events: WebhookEventType[]; } export interface WebhookEndpoint { id: string; url: string; events: WebhookEventType[]; createdAt: string; } export interface WebhookEndpointWithSecret extends WebhookEndpoint { secret: string; } export interface ListWebhooksResponse { webhooks: WebhookEndpoint[]; } export interface VerifyGrantTokenOptions { /** Opt-in online authority check, called for every verification, never cached. Requires audience. */ currentAuthority?: (token: string) => Promise; /** Trusted host-session identity, not an agent-supplied OAuth client ID. */ expectedPrincipalId?: string; /** Trusted expected agent identity, separate from the human principal. */ expectedAgentDid?: string; jwksUri: string; requiredScopes?: string[]; audience?: string; /** Expected issuer URL. Production JWKS uses https://grantex.dev; custom URLs derive the issuer from issuerDid or jwksUri. */ issuer?: string; /** * A `did:web` issuer. When set, the JWK Set is read from * `https://[:][/]/.well-known/jwks.json` instead of * `jwksUri`, and the expected issuer defaults to that location without the * suffix. `null`, like leaving it out, means no DID, as `None` does in the * Python SDK. * * With `boundedJwksFetch: true` it must name a fully qualified public * domain, written in ASCII (an internationalized name in its `xn--` form): * an IP address, a local or private name (`localhost`, `.local`, * `.home.arpa`, `.internal`), a single label, user information, a non-ASCII * character or another DID method is refused with `GrantexTokenError`. * Without it, a value that does not start with `did:web:` is ignored and * the rest of the identifier is used as written, with each `:` read as `/`. */ issuerDid?: string | null; /** * Fetch the JWK Set within fixed bounds and check `issuerDid` against the * did:web method before anything is fetched. The response must be an HTTP * 200 (redirects are not followed) served as `application/json` or * `application/jwk-set+json`, at most 64 KiB, with at most 128 keys, within * one 5-second deadline for the whole exchange; otherwise verification * fails with `GrantexTokenError` and nothing is cached. * * Defaults to `false`: a later major release makes `true` the default, with * `false` as the opt-out. */ boundedJwksFetch?: boolean; /** @internal override clock for testing */ clockTolerance?: number; /** * Signature algorithms to accept, a subset of `['RS256', 'ES256']` (the * default). Any other value is rejected. */ algorithms?: Array<'RS256' | 'ES256'>; /** * Read legacy claim aliases (`agt`, `dev`, `grnt`, `scp`, `parentAgt`, * `parentGrnt`, `delegationDepth`) when a token lacks the standard claim. * Defaults to `true`, with a deprecation warning when an alias is * used. With `false`, only standard * claims are read and the token must have `typ: at+jwt`. */ legacyClaims?: boolean; /** * RFC 7638 thumbprint of the key the caller proved possession of (for * example with a verified DPoP proof). When set, the token's `cnf.jkt` must * equal it. The verifier does not check DPoP proofs itself. */ proofJkt?: string; /** Fail closed unless `proofJkt` is given and matches `cnf.jkt`. Without it, `cnf` is returned but not enforced. */ requireProofOfPossession?: boolean; } export interface GrantTokenPayload { iss: string; sub: string; aud?: string | string[]; client_id?: string; /** Granted scopes, space-delimited. */ scope?: string; iat: number; exp: number; jti: string; cnf?: { jkt?: string; [member: string]: unknown; }; act?: ActorClaim; authorization_details?: unknown; /** Grantex grant record fields (collision-resistant claim name). */ 'urn:grantex:grant'?: { grant_id?: string; agent_did?: string; developer_id?: string; parent_grant_id?: string; delegation_depth?: number; webauthn?: WebAuthnGrantEvidence; }; /** @deprecated Legacy alias of `urn:grantex:grant.agent_did`; not issued from 0.7. */ agt?: string; /** @deprecated Legacy alias of `urn:grantex:grant.developer_id`; not issued from 0.7. */ dev?: string; /** @deprecated Legacy alias of `scope`; not issued from 0.7. */ scp?: string[]; /** @deprecated Legacy alias of `urn:grantex:grant.grant_id`; not issued from 0.7. */ grnt?: string; /** @deprecated Legacy alias of `act.sub`; not issued from 0.7. */ parentAgt?: string; /** @deprecated Legacy alias of `urn:grantex:grant.parent_grant_id`; not issued from 0.7. */ parentGrnt?: string; /** @deprecated Legacy alias of `urn:grantex:grant.delegation_depth`; not issued from 0.7. */ delegationDepth?: number; } export interface SubscriptionStatus { plan: 'free' | 'pro' | 'enterprise'; status: 'active' | 'past_due' | 'canceled'; currentPeriodEnd: string | null; } export interface CreateCheckoutParams { plan: 'pro' | 'enterprise'; successUrl: string; cancelUrl: string; } export interface CheckoutResponse { checkoutUrl: string; } export interface CreatePortalParams { returnUrl: string; } export interface PortalResponse { portalUrl: string; } export interface Policy { id: string; name: string; effect: 'allow' | 'deny'; priority: number; agentId: string | null; principalId: string | null; scopes: string[] | null; timeOfDayStart: string | null; timeOfDayEnd: string | null; createdAt: string; updatedAt: string; } export interface CreatePolicyParams { name: string; effect: 'allow' | 'deny'; priority?: number; agentId?: string; principalId?: string; scopes?: string[]; timeOfDayStart?: string; timeOfDayEnd?: string; } export interface UpdatePolicyParams { name?: string; effect?: 'allow' | 'deny'; priority?: number; agentId?: string | null; principalId?: string | null; scopes?: string[] | null; timeOfDayStart?: string | null; timeOfDayEnd?: string | null; } export interface ListPoliciesResponse { policies: Policy[]; total: number; } export interface ComplianceSummary { generatedAt: string; since?: string; until?: string; agents: { total: number; active: number; suspended: number; revoked: number; }; grants: { total: number; active: number; revoked: number; expired: number; }; auditEntries: { total: number; success: number; failure: number; blocked: number; }; policies: { total: number; }; plan: string; } export interface ComplianceExportGrantsParams { since?: string; until?: string; status?: 'active' | 'revoked' | 'expired'; } export interface ComplianceExportAuditParams { since?: string; until?: string; agentId?: string; status?: 'success' | 'failure' | 'blocked'; } export interface ComplianceGrantsExport { generatedAt: string; total: number; grants: Grant[]; } export interface ComplianceAuditExport { generatedAt: string; total: number; entries: AuditEntry[]; } export interface EvidencePackParams { since?: string; until?: string; framework?: 'soc2' | 'gdpr' | 'all'; } export interface ChainIntegrity { valid: boolean; checkedEntries: number; firstBrokenAt: string | null; } export interface EvidencePack { meta: { schemaVersion: '1.0'; generatedAt: string; since?: string; until?: string; framework: 'soc2' | 'gdpr' | 'all'; }; summary: { agents: { total: number; active: number; suspended: number; revoked: number; }; grants: { total: number; active: number; revoked: number; expired: number; }; auditEntries: { total: number; success: number; failure: number; blocked: number; }; policies: { total: number; }; plan: string; }; grants: Grant[]; auditEntries: AuditEntry[]; policies: Policy[]; chainIntegrity: ChainIntegrity; } export type AnomalyType = 'rate_spike' | 'high_failure_rate' | 'new_principal' | 'off_hours_activity'; export type AnomalySeverity = 'low' | 'medium' | 'high'; export interface Anomaly { id: string; type: AnomalyType; severity: AnomalySeverity; agentId: string | null; principalId: string | null; description: string; metadata: Record; detectedAt: string; acknowledgedAt: string | null; } export interface DetectAnomaliesResponse { detectedAt: string; total: number; anomalies: Anomaly[]; responseMode?: 'alert_only' | 'revoke_agent_grants'; autoRevokedGrants?: number; } export type IrregularityResponseMode = 'alert_only' | 'revoke_agent_grants'; export interface IrregularityResponsePolicy { mode: IrregularityResponseMode; } export interface ListAnomaliesResponse { anomalies: Anomaly[]; total: number; } export interface ScimEmail { value: string; primary?: boolean; } export interface ScimUserMeta { resourceType: string; created: string; lastModified: string; } export interface ScimUser { id: string; externalId?: string; userName: string; displayName?: string; active: boolean; emails: ScimEmail[]; meta: ScimUserMeta; } export interface ScimListResponse { totalResults: number; startIndex: number; itemsPerPage: number; Resources: ScimUser[]; } export interface CreateScimUserParams { userName: string; displayName?: string; externalId?: string; emails?: ScimEmail[]; active?: boolean; } export interface UpdateScimUserParams { userName?: string; displayName?: string; active?: boolean; emails?: ScimEmail[]; } export interface ScimToken { id: string; label: string; createdAt: string; lastUsedAt: string | null; } export interface ScimTokenWithSecret extends ScimToken { token: string; } export interface CreateScimTokenParams { label: string; } export interface ListScimTokensResponse { tokens: ScimToken[]; } export interface SsoConfig { issuerUrl: string; clientId: string; redirectUri: string; createdAt: string; updatedAt: string; } export interface CreateSsoConfigParams { issuerUrl: string; clientId: string; clientSecret: string; redirectUri: string; } export interface SsoLoginResponse { authorizeUrl: string; protocol?: 'oidc' | 'saml' | 'ldap'; connectionId?: string; } export interface SsoCallbackResponse { email: string | null; name: string | null; sub: string | null; developerId: string; } export interface SsoConnection { id: string; developerId: string; name: string; protocol: 'oidc' | 'saml' | 'ldap'; status: 'active' | 'inactive' | 'testing'; issuerUrl?: string; clientId?: string; idpEntityId?: string; idpSsoUrl?: string; spEntityId?: string; spAcsUrl?: string; ldapUrl?: string; ldapBindDn?: string; ldapSearchBase?: string; ldapSearchFilter?: string; ldapGroupSearchBase?: string; ldapGroupSearchFilter?: string; ldapTlsEnabled?: boolean; domains: string[]; jitProvisioning: boolean; enforce: boolean; groupAttribute?: string; groupMappings: Record; defaultScopes: string[]; createdAt: string; updatedAt: string; } export interface CreateSsoConnectionParams { name: string; protocol: 'oidc' | 'saml' | 'ldap'; issuerUrl?: string; clientId?: string; clientSecret?: string; idpEntityId?: string; idpSsoUrl?: string; idpCertificate?: string; spEntityId?: string; spAcsUrl?: string; ldapUrl?: string; ldapBindDn?: string; ldapBindPassword?: string; ldapSearchBase?: string; ldapSearchFilter?: string; ldapGroupSearchBase?: string; ldapGroupSearchFilter?: string; ldapTlsEnabled?: boolean; domains?: string[]; jitProvisioning?: boolean; enforce?: boolean; groupAttribute?: string; groupMappings?: Record; defaultScopes?: string[]; } export interface UpdateSsoConnectionParams { name?: string; status?: 'active' | 'inactive' | 'testing'; issuerUrl?: string; clientId?: string; clientSecret?: string; idpEntityId?: string; idpSsoUrl?: string; idpCertificate?: string; spEntityId?: string; spAcsUrl?: string; ldapUrl?: string; ldapBindDn?: string; ldapBindPassword?: string; ldapSearchBase?: string; ldapSearchFilter?: string; ldapGroupSearchBase?: string; ldapGroupSearchFilter?: string; ldapTlsEnabled?: boolean; domains?: string[]; jitProvisioning?: boolean; enforce?: boolean; groupAttribute?: string; groupMappings?: Record; defaultScopes?: string[]; } export interface SsoConnectionListResponse { connections: SsoConnection[]; } export interface SsoLdapCallbackParams { username: string; password: string; connectionId: string; org: string; } export interface SsoConnectionTestResult { success: boolean; protocol: 'oidc' | 'saml' | 'ldap'; issuer?: string; authorizationEndpoint?: string; tokenEndpoint?: string; jwksUri?: string; idpEntityId?: string; idpSsoUrl?: string; error?: string; } export interface SsoEnforcementParams { enforce: boolean; } export interface SsoEnforcementResponse { enforce: boolean; developerId: string; } export interface SsoSession { id: string; connectionId: string; principalId: string | null; email: string | null; name: string | null; idpSubject: string; groups: string[]; mappedScopes: string[]; expiresAt: string; createdAt: string; } export interface SsoSessionListResponse { sessions: SsoSession[]; } export interface SsoOidcCallbackParams { code: string; state: string; redirect_uri?: string; } export interface SsoSamlCallbackParams { SAMLResponse: string; RelayState: string; } export interface SsoCallbackResult { sessionId: string; /** Opaque bearer credential, returned only when human SSO sessions are enabled. Keep secret. */ sessionToken?: string; email: string | null; name: string | null; sub: string | null; groups: string[]; mappedScopes: string[]; principalId: string | null; developerId: string; expiresAt: string; } export interface StoreCredentialParams { principalId: string; service: string; credentialType?: string; accessToken: string; refreshToken?: string; tokenExpiresAt?: string; metadata?: Record; } export interface VaultCredential { id: string; principalId: string; service: string; credentialType: string; tokenExpiresAt: string | null; metadata: Record; createdAt: string; updatedAt: string; } export interface StoreCredentialResponse { id: string; principalId: string; service: string; credentialType: string; createdAt: string; } export interface ListVaultCredentialsParams { principalId?: string; service?: string; } export interface ListVaultCredentialsResponse { credentials: VaultCredential[]; } export interface ExchangeCredentialParams { service: string; } export interface ExchangeCredentialResponse { accessToken: string; service: string; credentialType: string; tokenExpiresAt: string | null; metadata: Record; } export interface ExchangeCredentialReferenceParams { service: string; } /** A credential handed out by reference: the relying party resolves it; the agent never holds the secret. */ export interface ExchangeCredentialReferenceResponse { credentialRef: string; service: string; credentialType: string; tokenExpiresAt: string | null; metadata: Record; referenceExpiresAt: string; } export interface AllocateBudgetParams { grantId: string; initialBudget: number; currency?: string; } export interface BudgetAllocation { id: string; grantId: string; developerId: string; initialBudget: string; remainingBudget: string; currency: string; createdAt: string; updatedAt: string; } export interface DebitBudgetParams { grantId: string; amount: number; description?: string; metadata?: Record; } export interface DebitBudgetResponse { remaining: string; transactionId: string; } export interface BudgetTransaction { id: string; grantId: string; allocationId: string; amount: string; description: string; metadata: Record; createdAt: string; } export interface BudgetTransactionsResponse { transactions: BudgetTransaction[]; total: number; } export interface GrantexStreamEvent { id: string; type: string; createdAt: string; data: Record; } export interface UsageResponse { developerId: string; period: string; tokenExchanges: number; authorizations: number; verifications: number; totalRequests: number; } export interface UsageHistoryEntry { date: string; tokenExchanges: number; authorizations: number; verifications: number; totalRequests: number; } export interface UsageHistoryResponse { developerId: string; days: number; entries: UsageHistoryEntry[]; } export interface CreateDomainParams { domain: string; } export interface CreateDomainResponse { id: string; domain: string; verified: boolean; verificationToken: string; instructions: string; } export interface DomainEntry { id: string; domain: string; verified: boolean; verifiedAt: string | null; createdAt: string; } export interface ListDomainsResponse { domains: DomainEntry[]; } export interface VerifyDomainResponse { verified: boolean; message: string; } export interface WebAuthnRegistrationOptions { challengeId: string; publicKey: Record; } export interface WebAuthnEnrollmentSession { enrollmentUrl: string; expiresAt: string; } export interface WebAuthnRegistrationVerifyParams { challengeId: string; response: Record; deviceName?: string; } export interface WebAuthnCredential { id: string; principalId: string; deviceName: string | null; backedUp: boolean; transports: string[]; createdAt: string; lastUsedAt: string | null; } export interface ListWebAuthnCredentialsResponse { credentials: WebAuthnCredential[]; } export interface VerifiableCredentialRecord { id: string; grantId: string; credentialType: string; format: string; credential: string; status: string; issuedAt: string; expiresAt: string; } export interface ListCredentialsParams { grantId?: string; principalId?: string; status?: string; } export interface ListCredentialsResponse { credentials: VerifiableCredentialRecord[]; } export interface VCVerificationResult { valid: boolean; vcId?: string; payload?: Record; revoked?: boolean; expired?: boolean; error?: string; /** True only when the embedded WebAuthn assertion was cryptographically verified. */ webauthnVerified?: boolean; /** @deprecated The service returns issuer under payload.iss. */ issuer?: string; /** @deprecated The service returns subject under payload.vc.credentialSubject. */ subject?: Record; /** @deprecated The service returns types under payload.vc.type. */ credentialType?: string; /** @deprecated The service returns expiry under payload.exp. */ expiresAt?: string; } export interface SDJWTPresentParams { sdJwt: string; nonce?: string; audience?: string; } export interface SDJWTPresentResult { valid: boolean; disclosedClaims?: Record; error?: string; } export interface DpdpPurpose { code: string; description: string; } /** Consent record lifecycle. */ export type ConsentRecordStatus = 'active' | 'withdrawn' | 'erased' | 'expired'; /** Grievance lifecycle: submitted -> in_review -> resolved | rejected. */ export type GrievanceStatus = 'submitted' | 'in_review' | 'resolved' | 'rejected'; /** `complete` on GET; an expired export answers 410 GONE instead. */ export type DpdpExportStatus = 'complete' | 'expired'; export interface CreateConsentRecordParams { grantId: string; dataPrincipalId: string; purposes: DpdpPurpose[]; consentNoticeId: string; /** Notice version to bind; the server uses the latest version when omitted. */ consentNoticeVersion?: string; processingExpiresAt: string; } /** Detached EdDSA proof over the consent record, returned only by create. */ export interface DpdpConsentProof { type: 'JWS-EdDSA'; alg: 'EdDSA'; kid: string | null; /** * `'persistent'` when the signing key comes from the server's configuration; * `'ephemeral'` when it was generated in-process, so the proof cannot be * verified on another instance or after a restart. Absent from older servers. */ keyPersistence?: 'persistent' | 'ephemeral'; proofJwt: string; jwksUri: string; signedAt: string; } export interface ConsentRecord { recordId: string; grantId: string; dataPrincipalId: string; /** Not sent by create. */ dataFiduciaryName?: string; /** Not sent by create. */ purposes?: DpdpPurpose[]; /** Not sent by create. */ scopes?: string[]; consentNoticeId?: string; /** `null` on records written before notice versions were tracked. */ consentNoticeVersion?: string | null; /** Only sent by create. */ consentNoticeHash?: string; /** Only sent by create. */ consentProof?: DpdpConsentProof; status: ConsentRecordStatus; /** Not sent by create. */ consentGivenAt?: string; processingExpiresAt?: string; retentionUntil?: string; accessCount?: number; lastAccessedAt?: string | null; withdrawnAt?: string | null; withdrawnReason?: string | null; erasedAt?: string | null; createdAt: string; } /** The 201 body of `POST /v1/dpdp/consent-records`. */ export interface CreateConsentRecordResponse extends ConsentRecord { consentNoticeHash: string; consentProof: DpdpConsentProof; } /** * Cursor pagination: `limit` 1..200 (server default 50), `cursor` = previous `nextCursor`. * The two consent-record lists paginate only when `limit` or `cursor` is sent; without either they return the newest 100 records (every match when filtered by principal, and every record on the principal-records route) with `nextCursor: null`. */ export interface DpdpPageParams { limit?: number; cursor?: string; } export interface ListConsentRecordsParams extends DpdpPageParams { dataPrincipalId?: string; } export interface ListConsentRecordsResponse { records: ConsentRecord[]; totalRecords: number; /** `null` on the last page; absent on servers without pagination. */ nextCursor?: string | null; } export interface WithdrawConsentParams { reason: string; /** Omit to use the server default. */ revokeGrant?: boolean; /** Records a deletion request for the Data Fiduciary; Grantex deletes nothing itself. */ deleteProcessedData?: boolean; } export interface WithdrawConsentResponse { recordId: string; status: 'withdrawn'; withdrawnAt: string; grantRevoked: boolean; /** Always `false`: see `dataDeletionRequested`. */ dataDeleted: boolean; dataDeletionRequested?: boolean; } export interface PrincipalRecordsResponse { dataPrincipalId: string; records: ConsentRecord[]; totalRecords: number; nextCursor?: string | null; } export interface ErasureRetainedCategory { category: string; count?: number; reason: string; } export interface ErasureResponse { requestId: string; dataPrincipalId: string; status: 'completed'; recordsErased: number; grantsRevoked: number; delegatedGrantsRevoked: number; grievancesRedacted: number; exportsDeleted: number; retained: ErasureRetainedCategory[]; submittedAt: string; completedAt: string; /** @deprecated Equal to `completedAt`; erasure completes synchronously. */ expectedCompletionBy?: string; } export interface DpdpGrievanceOfficer { name: string; email: string; phone?: string; } export interface CreateConsentNoticeParams { noticeId: string; version: string; title: string; content: string; purposes: DpdpPurpose[]; language?: string; dataFiduciaryContact?: string; grievanceOfficer?: DpdpGrievanceOfficer; } /** The 201 body of `POST /v1/dpdp/consent-notices`. */ export interface ConsentNotice { id: string; noticeId: string; version: string; language: string; contentHash: string; createdAt: string; } export interface ConsentNoticeSummary extends ConsentNotice { title: string; } export interface ListConsentNoticesResponse { notices: ConsentNoticeSummary[]; nextCursor: string | null; } export interface ConsentNoticeVersion { id: string; version: string; language: string; title: string; content: string; purposes: DpdpPurpose[]; dataFiduciaryContact: string | null; grievanceOfficer: DpdpGrievanceOfficer | null; contentHash: string; createdAt: string; } export interface ConsentNoticeDetail { noticeId: string; /** Newest first. */ versions: ConsentNoticeVersion[]; } export interface FileGrievanceParams { dataPrincipalId: string; /** Free text up to 128 characters, e.g. `consent-violation`, `data-breach`, `unauthorized-processing`. */ type: string; description: string; recordId?: string; evidence?: Record; /** 1..90 days; the server default is 7 (a product default, not a statutory period). */ responsePeriodDays?: number; } export interface Grievance { grievanceId: string; /** Not sent by file (202). */ dataPrincipalId?: string; recordId?: string | null; type: string; /** Only on the single-grievance routes. */ description?: string; /** Only on the single-grievance routes. */ evidence?: Record; status: GrievanceStatus; referenceNumber: string; expectedResolutionBy: string; responsePeriodDays?: number; resolvedAt?: string | null; resolution?: string | null; createdAt: string; updatedAt?: string | null; } export interface ListGrievancesParams extends DpdpPageParams { status?: GrievanceStatus; dataPrincipalId?: string; } export interface ListGrievancesResponse { grievances: Grievance[]; nextCursor: string | null; } export interface UpdateGrievanceParams { status: Exclude; /** Required for `resolved` and `rejected`. */ resolution?: string; } export type DpdpExportType = 'dpdp-audit' | 'gdpr-article-15' | 'eu-ai-act-conformance'; export interface CreateDpdpExportParams { type: DpdpExportType; /** ISO date-time. A bare YYYY-MM-DD means 00:00Z of that day. */ dateFrom: string; /** ISO date-time. Send an end-of-day time to include the whole last day. */ dateTo: string; /** Only `json` is produced. */ format?: string; includeActionLog?: boolean; includeConsentRecords?: boolean; dataPrincipalId?: string; } export interface DpdpExport { exportId: string; type: DpdpExportType; format?: string; /** GET only. */ dateFrom?: string; /** GET only. */ dateTo?: string; recordCount?: number; /** True when the audit log hit `auditLogLimit` and was cut off. */ truncated?: boolean; auditLogLimit?: number; dataPrincipalId?: string | null; data?: Record; /** GET only; the create response has no status. */ status?: DpdpExportStatus; expiresAt?: string; createdAt: string; } /** Alias matching the Python and Go SDK name. */ export type ComplianceExport = DpdpExport; export interface UpdateDeveloperSettingsParams { fidoRequired?: boolean; fidoRpName?: string; } export interface UpdateDeveloperSettingsResponse { updated: boolean; } //# sourceMappingURL=types.d.ts.map