{"version":3,"sources":["../../src/session-relay/types.ts"],"sourcesContent":["import type { Web3SignedSignFn } from \"../auth/web3-signed-builder\";\n\n/** Deployment environment for Vana's Session Relay service. */\nexport type SessionRelayEnvironment = \"production\" | \"dev\";\n\n/** Minimal fetch signature accepted by the Session Relay clients. */\nexport type SessionRelayFetch = (\n  input: string,\n  init?: {\n    method?: string;\n    headers?: Record<string, string>;\n    body?: string;\n  },\n) => Promise<{\n  ok: boolean;\n  status: number;\n  statusText?: string;\n  json(): Promise<unknown>;\n  text?(): Promise<string>;\n}>;\n\n/** Shared Session Relay client options. */\nexport interface SessionRelayClientOptions {\n  /** Session Relay base URL. Defaults from `env` when omitted. */\n  baseUrl?: string;\n  /** Vana deployment environment. Defaults to `\"production\"`. */\n  env?: SessionRelayEnvironment;\n  /** Fetch implementation. Defaults to `globalThis.fetch`. */\n  fetchFn?: SessionRelayFetch;\n}\n\n/** Builder-side Session Relay options. */\nexport interface SessionRelayBuilderClientOptions extends SessionRelayClientOptions {\n  /** Builder/app address registered with the Vana builder registry. */\n  granteeAddress: `0x${string}`;\n  /** EIP-191 signer for Web3Signed Relay requests. */\n  signMessage: Web3SignedSignFn;\n  /** Clock source used for signed request freshness claims. */\n  now?: () => number;\n}\n\n/** Parameters for creating a Session Relay session. */\nexport interface SessionRelayInitParams {\n  /** Data scopes requested from the user. */\n  scopes: string[];\n  /** Public HTTPS callback URL for grant notifications. */\n  webhookUrl?: string;\n  /** App-owned user id for correlating the approved grant. */\n  appUserId?: string;\n}\n\n/** Raw Session Relay init result. */\nexport interface SessionRelayInitResult {\n  sessionId: string;\n  deepLinkUrl: string;\n  expiresAt: string;\n}\n\n/** Grant payload returned after a Relay session is approved. */\nexport interface SessionRelayGrantPayload {\n  grantId: string;\n  userAddress: string;\n  builderAddress: string;\n  scopes: string[];\n  serverAddress?: string;\n  appUserId?: string;\n}\n\n/** Session Relay poll result. */\nexport interface SessionRelayPollResult {\n  /**\n   * Current session status.\n   *\n   * @remarks\n   * Current Session Relay deployments may report expired sessions as a\n   * structured `SESSION_EXPIRED` error instead of a JSON body with\n   * `status: \"expired\"`. The `\"expired\"` status is accepted for deployments\n   * that return expiry as a terminal poll body.\n   */\n  status: \"pending\" | \"claimed\" | \"approved\" | \"denied\" | \"expired\";\n  grant?: SessionRelayGrantPayload;\n  reason?: string;\n}\n\n/** Desktop/app-side claim request. */\nexport interface SessionRelayClaimRequest {\n  sessionId: string;\n  secret: string;\n}\n\n/** Claimed session data returned to the app that completes user consent. */\nexport interface SessionRelayClaimResponse {\n  sessionId: string;\n  granteeAddress: string;\n  scopes: string[];\n  expiresAt: string;\n  webhookUrl?: string;\n  appUserId?: string;\n}\n\n/** Desktop/app-side approval request. */\nexport interface SessionRelayApproveRequest {\n  secret: string;\n  grantId: string;\n  userAddress: string;\n  serverAddress?: string;\n  scopes: string[];\n}\n\n/** Desktop/app-side denial request. */\nexport interface SessionRelayDenyRequest {\n  secret: string;\n  reason?: string;\n}\n\n/** Session Relay methods that do not require builder signing. */\nexport interface SessionRelayClient {\n  claimSession(\n    request: SessionRelayClaimRequest,\n  ): Promise<SessionRelayClaimResponse>;\n  approveSession(\n    sessionId: string,\n    request: SessionRelayApproveRequest,\n  ): Promise<void>;\n  denySession(\n    sessionId: string,\n    request: SessionRelayDenyRequest,\n  ): Promise<void>;\n  pollSession(sessionId: string): Promise<SessionRelayPollResult>;\n  pollUntilComplete(\n    sessionId: string,\n    opts?: { intervalMs?: number; timeoutMs?: number },\n  ): Promise<SessionRelayPollResult>;\n}\n\n/** Builder-side Session Relay methods. */\nexport interface SessionRelayBuilderClient {\n  initSession(params: SessionRelayInitParams): Promise<SessionRelayInitResult>;\n  pollSession(sessionId: string): Promise<SessionRelayPollResult>;\n  pollUntilComplete(\n    sessionId: string,\n    opts?: { intervalMs?: number; timeoutMs?: number },\n  ): Promise<SessionRelayPollResult>;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}