//=========================================== // THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template //=========================================== import { KnownErrors } from "@hexclave/shared"; import type { RequestListener } from "@hexclave/shared/dist/interface/client-interface"; import { CurrentUserCrud } from "@hexclave/shared/dist/interface/crud/current-user"; import { Result } from "@hexclave/shared/dist/utils/results"; import { AsyncStoreProperty, AuthLike, GetCurrentPartialUserOptions, GetCurrentUserOptions, HandlerUrlOptions, HandlerUrls, hexclaveAppInternalsSymbol, OAuthScopesOnSignIn, RedirectMethod, RedirectToOptions, ResolvedHandlerUrls, TokenStoreInit } from "../../common"; import { CustomerInvoicesList, CustomerInvoicesRequestOptions, CustomerProductsList, CustomerProductsRequestOptions, Item } from "../../customers"; import { Project } from "../../projects"; import { ProjectCurrentUser, SyncedPartialUser, TokenPartialUser } from "../../users"; import { _HexclaveClientAppImpl } from "../implementations"; import { AnalyticsOptions } from "../implementations/session-replay"; /** @deprecated Use `HexclaveClientAppConstructorOptions` from the `@hexclave/*` package instead — same symbol, new brand name. See https://docs.hexclave.com/migration. */ export type StackClientAppConstructorOptions = { baseUrl?: string | { browser: string, server: string }, extraRequestHeaders?: Record, projectId?: ProjectId, publishableClientKey?: string, urls?: HandlerUrlOptions, oauthScopesOnSignIn?: Partial, tokenStore?: TokenStoreInit, redirectMethod?: RedirectMethod, inheritsFrom?: StackClientApp, /** * Whether to show the Hexclave dev tool indicator in browser-like environments. * * - `true`: always show * - `false`: never show * - `"auto"` (default): show based on NODE_ENV or origin heuristics */ devTool?: boolean | "auto", /** * By default, the Stack app will automatically prefetch some data from Stack's server when this app is first * constructed. This improves the performance of your app, but will create network requests that are unnecessary if * the app is never used or disposed of immediately. To disable this behavior, set this option to true. */ noAutomaticPrefetch?: boolean, /** * Whether the constructor starts browser integrations and other automatic side effects. Defaults to `true`. * * Set this to `false` when the app is instantiated inside a custom dashboard. Explicit method calls remain * available and can still perform their documented side effects. */ automaticSideEffects?: boolean, /** * Options for analytics and session recording. Replays are enabled by default; * set `{ replays: { enabled: false } }` to opt out. */ analytics?: AnalyticsOptions, } & ( { tokenStore: TokenStoreInit } | { tokenStore?: undefined, inheritsFrom: StackClientApp } ) & ( string extends ProjectId ? unknown : ({ projectId: ProjectId } | { inheritsFrom: StackClientApp }) ); /** @deprecated Use `HexclaveClientAppJson` from the `@hexclave/*` package instead — same symbol, new brand name. See https://docs.hexclave.com/migration. */ export type StackClientAppJson = StackClientAppConstructorOptions & { inheritsFrom?: undefined } & { uniqueIdentifier: string, // note: if you add more fields here, make sure to ensure the checkString in the constructor has/doesn't have them }; /** @deprecated Use `HexclaveClientApp` from the `@hexclave/*` package instead — same symbol, new brand name. See https://docs.hexclave.com/migration. */ export type StackClientApp = ( & { readonly projectId: ProjectId, /** * The version of the Hexclave SDK. */ readonly version: string, /** * @deprecated Do not use `app.urls` for navigation. It is static and does not include runtime redirect-back, * cross-domain auth, or sign-out state. Use the matching `redirectToXyz()` method instead, for example * `redirectToSignIn()`, `redirectToSignUp()`, `redirectToSignOut()`, or `redirectToAccountSettings()`. */ readonly urls: Readonly, signInWithOAuth(provider: string, options?: { returnTo?: string }): Promise, signInWithCredential(options: { email: string, password: string, noRedirect?: boolean }): Promise>, signUpWithCredential(options: { email: string, password: string, noRedirect?: boolean, } & ({ noVerificationCallback: true } | { noVerificationCallback?: false, verificationCallbackUrl?: string })): Promise>, signInWithPasskey(): Promise>, callOAuthCallback(): Promise, promptCliLogin(options: { appUrl: string, expiresInMillis?: number, anonRefreshToken?: string, promptLink?: (url: string, loginCode: string) => void }): Promise>, sendForgotPasswordEmail(email: string, options?: { callbackUrl?: string }): Promise>, sendMagicLinkEmail(email: string, options?: { callbackUrl?: string }): Promise>, resetPassword(options: { code: string, password: string }): Promise>, verifyPasswordResetCode(code: string): Promise>, verifyTeamInvitationCode(code: string): Promise>, acceptTeamInvitation(code: string): Promise>, getTeamInvitationDetails(code: string): Promise>, verifyEmail(code: string): Promise>, signInWithMagicLink(code: string, options?: { noRedirect?: boolean }): Promise>, signInWithMfa(otp: string, code: string, options?: { noRedirect?: boolean }): Promise>, redirectToOAuthCallback(): Promise, getConvexClientAuth(options: HasTokenStore extends false ? { tokenStore: TokenStoreInit } : { tokenStore?: TokenStoreInit }): (args: { forceRefreshToken: boolean }) => Promise, getConvexHttpClientAuth(options: { tokenStore: TokenStoreInit }): Promise, getUser(options: GetCurrentUserOptions & { or: 'redirect' }): Promise>, getUser(options: GetCurrentUserOptions & { or: 'throw' }): Promise>, getUser(options: GetCurrentUserOptions & { or: 'anonymous' }): Promise>, getUser(options?: GetCurrentUserOptions): Promise | null>, cancelSubscription(options: { productId: string, subscriptionId?: string } | { productId: string, subscriptionId?: string, teamId: string }): Promise, // note: we don't special-case 'anonymous' here to return non-null, see GetPartialUserOptions for more details getPartialUser(options: GetCurrentPartialUserOptions & { from: 'token' }): Promise, getPartialUser(options: GetCurrentPartialUserOptions & { from: 'convex' }): Promise, getPartialUser(options: GetCurrentPartialUserOptions): Promise, [hexclaveAppInternalsSymbol]: { toClientJson(): StackClientAppJson, setCurrentUser(userJsonPromise: Promise): void, getConstructorOptions(): StackClientAppConstructorOptions & { inheritsFrom?: undefined }, sendSessionReplayBatch(body: string, options: { keepalive: boolean }): Promise>, sendAnalyticsEventBatch(body: string, options: { keepalive: boolean }): Promise>, addRequestListener(listener: RequestListener): () => void, sendRequest(path: string, requestOptions: RequestInit, requestType?: "client" | "server" | "admin"): Promise, getUrls(): Readonly, getRedirectMethod(): RedirectMethod, redirectToUrl(url: string | URL, options?: { replace?: boolean }): Promise, getRedirectToHandlerUrl(handlerName: keyof HandlerUrls, options?: RedirectToOptions): Promise, redirectToHandler(handlerName: keyof HandlerUrls, options?: RedirectToOptions): Promise, /** Raw flow metadata only. Never navigate to this value without normal redirect validation. */ getRawAfterAuthReturnTo(): string | null, signInWithTokens(tokens: { accessToken: string, refreshToken: string }): Promise, awaitPendingAuthResolutions(): Promise, isTrustedRedirectUrl(url: string): Promise, }, } & AsyncStoreProperty<"project", [], Project, false> & AsyncStoreProperty< "item", [{ itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }], Item, false > & AsyncStoreProperty< "products", [options: CustomerProductsRequestOptions], CustomerProductsList, true > & AsyncStoreProperty< "invoices", [options: CustomerInvoicesRequestOptions], CustomerInvoicesList, true > & { [K in `redirectTo${Capitalize>}`]: (options?: RedirectToOptions) => Promise } & AuthLike ); /** @deprecated Use `HexclaveClientAppConstructor` from the `@hexclave/*` package instead — same symbol, new brand name. See https://docs.hexclave.com/migration. */ export type StackClientAppConstructor = { new < TokenStoreType extends string, HasTokenStore extends (TokenStoreType extends {} ? true : boolean), ProjectId extends string >(options: StackClientAppConstructorOptions): StackClientApp, new(options: StackClientAppConstructorOptions): StackClientApp, [hexclaveAppInternalsSymbol]: { fromClientJson( json: StackClientAppJson ): StackClientApp, }, }; export type HexclaveClientAppConstructorOptions = StackClientAppConstructorOptions; export type HexclaveClientAppJson = StackClientAppJson; export type HexclaveClientApp = StackClientApp; export type HexclaveClientAppConstructor = StackClientAppConstructor; export const HexclaveClientApp: HexclaveClientAppConstructor = _HexclaveClientAppImpl; /** @deprecated Use `HexclaveClientApp` from the `@hexclave/*` package instead — same symbol, new brand name. See https://docs.hexclave.com/migration. */ export const StackClientApp: StackClientAppConstructor = HexclaveClientApp;