import { Server } from 'http'; import { Writable } from 'stream'; /** * Derives a deterministic GraphiQL authentication key from the app's API secret and store FQDN. * The key is stable across dev server restarts (so browser tabs survive restarts) * but is not guessable without the app secret. * * @param apiSecret - The Partners app's client secret used as the HMAC key. * @param storeFqdn - The myshopify.com domain the GraphiQL session targets. * @returns A 64-character hex string suitable for use as the `?key=` query param. */ export declare function deriveGraphiQLKey(apiSecret: string, storeFqdn: string): string; /** * Resolves the GraphiQL authentication key. Uses the explicitly provided key * if non-empty, otherwise derives one deterministically from the app secret. * * @param providedKey - An explicit key supplied by the caller; takes precedence when non-empty. * @param apiSecret - The Partners app's client secret, used to derive a stable key as a fallback. * @param storeFqdn - The myshopify.com domain the GraphiQL session targets. * @returns The resolved key. */ export declare function resolveGraphiQLKey(providedKey: string | undefined, apiSecret: string, storeFqdn: string): string; /** * Pluggable strategy for obtaining and refreshing the Admin API access token * that the GraphiQL proxy injects into every request. * * - `getToken` may return a cached token; the proxy calls it for every request. * - `refreshToken` (optional) is invoked when the upstream Admin API returns 401. * When omitted, the proxy falls back to calling `getToken` again on 401. * * Implementations must throw `TokenRefreshError` (or any thrown error) when the * token cannot be obtained; the proxy renders the unauthorized template in that case. */ export interface TokenProvider { getToken: () => Promise; refreshToken?: () => Promise; } /** * Optional app-specific context, used to render the app pill and scopes note in the * GraphiQL header and to drive the deterministic key derivation. Pass when the GraphiQL * server is hosted as part of `shopify app dev`; omit for app-less use cases such as * `shopify store execute`. */ export interface GraphiQLAppContext { appName: string; appUrl: string; apiSecret: string; } export interface SetupGraphiQLServerOptions { stdout: Writable; port: number; storeFqdn: string; tokenProvider: TokenProvider; /** * Authentication key required as a `?key=` query string on every request. When omitted: * - if `appContext` is provided, derived deterministically from `apiSecret` + `storeFqdn` * so browser tabs survive dev server restarts. * - otherwise, generated randomly per process. */ key?: string; appContext?: GraphiQLAppContext; /** * When true, the proxy rejects mutation operations with HTTP 400 before forwarding * them to the Admin API. Use this to mirror non-interactive safety guarantees in the * interactive UI. */ protectMutations?: boolean; } export declare const MUTATIONS_BLOCKED_MESSAGE = "Mutations are disabled. Re-run with --allow-mutations to enable mutations."; /** * Starts a local HTTP server that hosts the GraphiQL UI and proxies requests to the * Admin API for the configured store. Authentication is delegated to the supplied * `tokenProvider`, so the same server can serve both `shopify app dev` and stored-session * use cases. * * @param options - Configuration for the server, including the target store, the * pluggable token provider, and the local port to bind to. * @returns The underlying Node `http.Server` instance, already listening on `options.port`. */ export declare function setupGraphiQLServer(options: SetupGraphiQLServerOptions): Server;