mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
## Summary - Extract CLI auth confirmation into a `useCliAuthConfirmation()` hook (status / error / isLoading / authorize / retry) so custom pages don't have to reimplement the protocol; `CliAuthConfirmation` now consumes the hook. - Make `cliAuthConfirm` a first-class handler URL target — resolved via `resolveHandlerUrls`, customizable per project, and used by `promptCliLogin` through a new `buildCliAuthConfirmUrl()` helper. - Move `StackContext` to its own module so the hook can be unit-tested with a test double without tripping the client-version sentinel; register `cliAuthConfirm` in custom-page prompts and the dev-tool components tab; export the hook + types from `@stackframe/stack`. ## Test plan - [ ] `pnpm typecheck` - [ ] `pnpm lint` - [ ] `pnpm --filter @stackframe/stack test cli-auth-confirm url-targets` - [ ] Manually verify default `/handler/cli-auth-confirm` flow + a project with a custom `cliAuthConfirm` URL <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Adds a CLI authentication confirmation page with clear states (invalid, authorizing, redirecting, success, error), retry action, and flows for signed-in and anonymous users. * CLI login URL generation now derives from the configured handler target and app base, improving reliability. * CLI confirmation page exposed in the components/dev UI for previewing. * **Tests** * End-to-end and unit tests covering confirmation behaviors and URL generation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
/**
|
|
* @deprecated Plain string URLs are deprecated. Use `{ type: "custom", url: "...", version: 0 }` instead.
|
|
*/
|
|
type DeprecatedStringUrl = string;
|
|
|
|
export type HandlerPageUrls = Record<
|
|
| "handler"
|
|
| "signIn"
|
|
| "signUp"
|
|
| "signOut"
|
|
| "emailVerification"
|
|
| "passwordReset"
|
|
| "forgotPassword"
|
|
| "oauthCallback"
|
|
| "magicLinkCallback"
|
|
| "accountSettings"
|
|
| "teamInvitation"
|
|
| "cliAuthConfirm"
|
|
| "mfa"
|
|
| "error"
|
|
| "onboarding",
|
|
DeprecatedStringUrl | { type: "custom", url: string, version: number } | { type: "hosted" | "handler-component" }
|
|
>;
|
|
|
|
export type HandlerRedirectUrls = Record<
|
|
| "afterSignIn"
|
|
| "afterSignUp"
|
|
| "afterSignOut"
|
|
| "home",
|
|
string
|
|
>;
|
|
|
|
export type HandlerUrls = HandlerPageUrls & HandlerRedirectUrls;
|
|
export type HandlerUrlTarget = HandlerUrls[keyof HandlerUrls];
|
|
export type DefaultHandlerUrlTarget = string | { type: "hosted" | "handler-component" };
|
|
export type HandlerUrlOptions = Partial<HandlerUrls> & { default?: DefaultHandlerUrlTarget };
|
|
export type ResolvedHandlerUrls = {
|
|
[K in keyof HandlerUrls]: string;
|
|
};
|
|
|
|
export {
|
|
getCustomPagePrompts,
|
|
getLatestPageVersions,
|
|
type CustomPagePrompt,
|
|
type PageComponentKey,
|
|
type PageVersionEntry,
|
|
type PageVersions
|
|
} from "./page-component-versions";
|