@stackframe/stack 2.6.17 → 2.6.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,9 +38,20 @@ var import_sign_out = require("./sign-out");
38
38
  var import_team_invitation = require("./team-invitation");
39
39
  var import_objects = require("@stackframe/stack-shared/dist/utils/objects");
40
40
  var import_jsx_runtime = require("react/jsx-runtime");
41
+ var next15DeprecationWarning = "DEPRECATION WARNING: Next.js 15 disallows spreading the props argument of <StackHandler /> like `{...props}`, so you must now explicitly pass them in the `routeProps` argument: `routeProps={props}`";
41
42
  async function StackHandler(props) {
42
- if (!props.params?.stack) {
43
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_message_card.MessageCard, { title: "Invalid Stack Handler Setup", fullPage: props.fullPage, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Can't use Stack handler at this location. Make sure that the file is in a folder called [...stack]." }) });
43
+ if (!("routeProps" in props)) {
44
+ console.warn(next15DeprecationWarning);
45
+ }
46
+ const routeProps = "routeProps" in props ? props.routeProps : (0, import_objects.pick)(props, ["params", "searchParams"]);
47
+ const params = await routeProps.params;
48
+ const searchParams = await routeProps.searchParams;
49
+ if (!params?.stack) {
50
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_message_card.MessageCard, { title: "Invalid Stack Handler Setup", fullPage: props.fullPage, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
51
+ "Can't use ",
52
+ "<StackHandler />",
53
+ " at this location. Make sure that the file is in a folder called [...stack]."
54
+ ] }) });
44
55
  }
45
56
  function redirectIfNotHandler(name) {
46
57
  const url = props.app.urls[name];
@@ -49,7 +60,7 @@ async function StackHandler(props) {
49
60
  return;
50
61
  }
51
62
  const urlObj = new URL(url, "http://example.com");
52
- for (const [key, value] of Object.entries(props.searchParams || {})) {
63
+ for (const [key, value] of Object.entries(routeProps.searchParams || {})) {
53
64
  urlObj.searchParams.set(key, value);
54
65
  }
55
66
  (0, import_navigation.redirect)((0, import_urls.getRelativePart)(urlObj), import_navigation.RedirectType.replace);
@@ -68,132 +79,141 @@ async function StackHandler(props) {
68
79
  accountSettings: "account-settings",
69
80
  error: "error"
70
81
  };
71
- const path = props.params.stack.join("/");
72
- switch (path) {
73
- case availablePaths.signIn: {
74
- redirectIfNotHandler("signIn");
75
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
76
- import__.SignIn,
77
- {
78
- fullPage: props.fullPage,
79
- automaticRedirect: true,
80
- ...filterUndefinedINU(props.componentProps?.SignIn)
81
- }
82
- );
83
- }
84
- case availablePaths.signUp: {
85
- redirectIfNotHandler("signUp");
86
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
87
- import__.SignUp,
88
- {
89
- fullPage: props.fullPage,
90
- automaticRedirect: true,
91
- ...filterUndefinedINU(props.componentProps?.SignUp)
92
- }
93
- );
94
- }
95
- case availablePaths.emailVerification: {
96
- redirectIfNotHandler("emailVerification");
97
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
- import_email_verification.EmailVerification,
99
- {
100
- searchParams: props.searchParams,
101
- fullPage: props.fullPage,
102
- ...filterUndefinedINU(props.componentProps?.EmailVerification)
103
- }
104
- );
105
- }
106
- case availablePaths.passwordReset: {
107
- redirectIfNotHandler("passwordReset");
108
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
109
- import_password_reset.PasswordReset,
110
- {
111
- searchParams: props.searchParams || {},
112
- fullPage: props.fullPage,
113
- ...filterUndefinedINU(props.componentProps?.PasswordReset)
114
- }
115
- );
116
- }
117
- case availablePaths.forgotPassword: {
118
- redirectIfNotHandler("forgotPassword");
119
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
120
- import_forgot_password.ForgotPassword,
121
- {
122
- fullPage: props.fullPage,
123
- ...filterUndefinedINU(props.componentProps?.ForgotPassword)
124
- }
125
- );
126
- }
127
- case availablePaths.signOut: {
128
- redirectIfNotHandler("signOut");
129
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
130
- import_sign_out.SignOut,
131
- {
132
- fullPage: props.fullPage,
133
- ...filterUndefinedINU(props.componentProps?.SignOut)
134
- }
135
- );
136
- }
137
- case availablePaths.oauthCallback: {
138
- redirectIfNotHandler("oauthCallback");
139
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
140
- import_oauth_callback.OAuthCallback,
141
- {
142
- fullPage: props.fullPage,
143
- ...filterUndefinedINU(props.componentProps?.OAuthCallback)
144
- }
145
- );
146
- }
147
- case availablePaths.magicLinkCallback: {
148
- redirectIfNotHandler("magicLinkCallback");
149
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
150
- import_magic_link_callback.MagicLinkCallback,
151
- {
152
- searchParams: props.searchParams || {},
153
- fullPage: props.fullPage,
154
- ...filterUndefinedINU(props.componentProps?.MagicLinkCallback)
155
- }
156
- );
157
- }
158
- case availablePaths.teamInvitation: {
159
- redirectIfNotHandler("teamInvitation");
160
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
161
- import_team_invitation.TeamInvitation,
162
- {
163
- searchParams: props.searchParams || {},
164
- fullPage: props.fullPage,
165
- ...filterUndefinedINU(props.componentProps?.TeamInvitation)
166
- }
167
- );
168
- }
169
- case availablePaths.accountSettings: {
170
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
171
- import_account_settings.AccountSettings,
172
- {
173
- fullPage: props.fullPage,
174
- ...filterUndefinedINU(props.componentProps?.AccountSettings)
175
- }
176
- );
177
- }
178
- case availablePaths.error: {
179
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
180
- import_error_page.ErrorPage,
181
- {
182
- searchParams: props.searchParams || {},
183
- fullPage: props.fullPage,
184
- ...filterUndefinedINU(props.componentProps?.ErrorPage)
185
- }
186
- );
187
- }
188
- default: {
189
- for (const [key, value] of Object.entries(availablePaths)) {
190
- if (path === value.replaceAll("-", "")) {
191
- (0, import_navigation.redirect)(`${props.app.urls.handler}/${value}`, import_navigation.RedirectType.replace);
82
+ const path = params.stack.join("/");
83
+ const render = () => {
84
+ switch (path) {
85
+ case availablePaths.signIn: {
86
+ redirectIfNotHandler("signIn");
87
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
88
+ import__.SignIn,
89
+ {
90
+ fullPage: props.fullPage,
91
+ automaticRedirect: true,
92
+ ...filterUndefinedINU(props.componentProps?.SignIn)
93
+ }
94
+ );
95
+ }
96
+ case availablePaths.signUp: {
97
+ redirectIfNotHandler("signUp");
98
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
99
+ import__.SignUp,
100
+ {
101
+ fullPage: props.fullPage,
102
+ automaticRedirect: true,
103
+ ...filterUndefinedINU(props.componentProps?.SignUp)
104
+ }
105
+ );
106
+ }
107
+ case availablePaths.emailVerification: {
108
+ redirectIfNotHandler("emailVerification");
109
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
110
+ import_email_verification.EmailVerification,
111
+ {
112
+ searchParams,
113
+ fullPage: props.fullPage,
114
+ ...filterUndefinedINU(props.componentProps?.EmailVerification)
115
+ }
116
+ );
117
+ }
118
+ case availablePaths.passwordReset: {
119
+ redirectIfNotHandler("passwordReset");
120
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
121
+ import_password_reset.PasswordReset,
122
+ {
123
+ searchParams: searchParams || {},
124
+ fullPage: props.fullPage,
125
+ ...filterUndefinedINU(props.componentProps?.PasswordReset)
126
+ }
127
+ );
128
+ }
129
+ case availablePaths.forgotPassword: {
130
+ redirectIfNotHandler("forgotPassword");
131
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
132
+ import_forgot_password.ForgotPassword,
133
+ {
134
+ fullPage: props.fullPage,
135
+ ...filterUndefinedINU(props.componentProps?.ForgotPassword)
136
+ }
137
+ );
138
+ }
139
+ case availablePaths.signOut: {
140
+ redirectIfNotHandler("signOut");
141
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
142
+ import_sign_out.SignOut,
143
+ {
144
+ fullPage: props.fullPage,
145
+ ...filterUndefinedINU(props.componentProps?.SignOut)
146
+ }
147
+ );
148
+ }
149
+ case availablePaths.oauthCallback: {
150
+ redirectIfNotHandler("oauthCallback");
151
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
152
+ import_oauth_callback.OAuthCallback,
153
+ {
154
+ fullPage: props.fullPage,
155
+ ...filterUndefinedINU(props.componentProps?.OAuthCallback)
156
+ }
157
+ );
158
+ }
159
+ case availablePaths.magicLinkCallback: {
160
+ redirectIfNotHandler("magicLinkCallback");
161
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
162
+ import_magic_link_callback.MagicLinkCallback,
163
+ {
164
+ searchParams: searchParams || {},
165
+ fullPage: props.fullPage,
166
+ ...filterUndefinedINU(props.componentProps?.MagicLinkCallback)
167
+ }
168
+ );
169
+ }
170
+ case availablePaths.teamInvitation: {
171
+ redirectIfNotHandler("teamInvitation");
172
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
173
+ import_team_invitation.TeamInvitation,
174
+ {
175
+ searchParams: searchParams || {},
176
+ fullPage: props.fullPage,
177
+ ...filterUndefinedINU(props.componentProps?.TeamInvitation)
178
+ }
179
+ );
180
+ }
181
+ case availablePaths.accountSettings: {
182
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
183
+ import_account_settings.AccountSettings,
184
+ {
185
+ fullPage: props.fullPage,
186
+ ...filterUndefinedINU(props.componentProps?.AccountSettings)
187
+ }
188
+ );
189
+ }
190
+ case availablePaths.error: {
191
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
192
+ import_error_page.ErrorPage,
193
+ {
194
+ searchParams: searchParams || {},
195
+ fullPage: props.fullPage,
196
+ ...filterUndefinedINU(props.componentProps?.ErrorPage)
197
+ }
198
+ );
199
+ }
200
+ default: {
201
+ for (const [key, value] of Object.entries(availablePaths)) {
202
+ if (path === value.replaceAll("-", "")) {
203
+ (0, import_navigation.redirect)(`${props.app.urls.handler}/${value}`, import_navigation.RedirectType.replace);
204
+ }
192
205
  }
206
+ return (0, import_navigation.notFound)();
193
207
  }
194
- return (0, import_navigation.notFound)();
195
208
  }
196
- }
209
+ };
210
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
211
+ process.env.NODE_ENV === "development" && !("routeProps" in props) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: { color: "red" }, children: [
212
+ next15DeprecationWarning,
213
+ ". This warning will not be shown in production."
214
+ ] }),
215
+ render()
216
+ ] });
197
217
  }
198
218
  function filterUndefinedINU(value) {
199
219
  return value === void 0 ? value : (0, import_objects.filterUndefined)(value);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components-page/stack-handler.tsx"],"sourcesContent":["import { getRelativePart } from \"@stackframe/stack-shared/dist/utils/urls\";\nimport { RedirectType, notFound, redirect } from 'next/navigation';\nimport { SignIn, SignUp, StackServerApp } from \"..\";\nimport { MessageCard } from \"../components/message-cards/message-card\";\nimport { HandlerUrls } from \"../lib/stack-app\";\nimport { AccountSettings } from \"./account-settings\";\nimport { EmailVerification } from \"./email-verification\";\nimport { ErrorPage } from \"./error-page\";\nimport { ForgotPassword } from \"./forgot-password\";\nimport { MagicLinkCallback } from \"./magic-link-callback\";\nimport { OAuthCallback } from \"./oauth-callback\";\nimport { PasswordReset } from \"./password-reset\";\nimport { SignOut } from \"./sign-out\";\nimport { TeamInvitation } from \"./team-invitation\";\nimport { FilterUndefined, filterUndefined } from \"@stackframe/stack-shared/dist/utils/objects\";\n\ntype Components = {\n SignIn: typeof SignIn,\n SignUp: typeof SignUp,\n EmailVerification: typeof EmailVerification,\n PasswordReset: typeof PasswordReset,\n ForgotPassword: typeof ForgotPassword,\n SignOut: typeof SignOut,\n OAuthCallback: typeof OAuthCallback,\n MagicLinkCallback: typeof MagicLinkCallback,\n TeamInvitation: typeof TeamInvitation,\n ErrorPage: typeof ErrorPage,\n AccountSettings: typeof AccountSettings,\n};\n\n\nexport default async function StackHandler<HasTokenStore extends boolean>(props: {\n app: StackServerApp<HasTokenStore>,\n params?: { stack?: string[] },\n searchParams?: Record<string, string>,\n fullPage: boolean,\n componentProps?: {\n [K in keyof Components]?: Parameters<Components[K]>;\n },\n}) {\n if (!props.params?.stack) {\n return (\n <MessageCard title=\"Invalid Stack Handler Setup\" fullPage={props.fullPage}>\n <p>Can't use Stack handler at this location. Make sure that the file is in a folder called [...stack].</p>\n </MessageCard>\n );\n }\n\n function redirectIfNotHandler(name: keyof HandlerUrls) {\n const url = props.app.urls[name];\n const handlerUrl = props.app.urls.handler;\n\n if (url !== handlerUrl && url.startsWith(handlerUrl + \"/\")) {\n // don't redirect if the url is a handler url\n return;\n }\n\n const urlObj = new URL(url, \"http://example.com\");\n for (const [key, value] of Object.entries(props.searchParams || {})) {\n urlObj.searchParams.set(key, value);\n }\n\n redirect(getRelativePart(urlObj), RedirectType.replace);\n };\n\n const availablePaths = {\n signIn: 'sign-in',\n signUp: 'sign-up',\n emailVerification: 'email-verification',\n passwordReset: 'password-reset',\n forgotPassword: 'forgot-password',\n signOut: 'sign-out',\n oauthCallback: 'oauth-callback',\n magicLinkCallback: 'magic-link-callback',\n teamInvitation: 'team-invitation',\n accountSettings: 'account-settings',\n error: 'error',\n };\n\n const path = props.params.stack.join('/');\n\n switch (path) {\n case availablePaths.signIn: {\n redirectIfNotHandler('signIn');\n return <SignIn\n fullPage={props.fullPage}\n automaticRedirect\n {...filterUndefinedINU(props.componentProps?.SignIn)}\n />;\n }\n case availablePaths.signUp: {\n redirectIfNotHandler('signUp');\n return <SignUp\n fullPage={props.fullPage}\n automaticRedirect\n {...filterUndefinedINU(props.componentProps?.SignUp)}\n />;\n }\n case availablePaths.emailVerification: {\n redirectIfNotHandler('emailVerification');\n return <EmailVerification\n searchParams={props.searchParams}\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.EmailVerification)}\n />;\n }\n case availablePaths.passwordReset: {\n redirectIfNotHandler('passwordReset');\n return <PasswordReset\n searchParams={props.searchParams || {}}\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.PasswordReset)}\n />;\n }\n case availablePaths.forgotPassword: {\n redirectIfNotHandler('forgotPassword');\n return <ForgotPassword\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.ForgotPassword)}\n />;\n }\n case availablePaths.signOut: {\n redirectIfNotHandler('signOut');\n return <SignOut\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.SignOut)}\n />;\n }\n case availablePaths.oauthCallback: {\n redirectIfNotHandler('oauthCallback');\n return <OAuthCallback\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.OAuthCallback)}\n />;\n }\n case availablePaths.magicLinkCallback: {\n redirectIfNotHandler('magicLinkCallback');\n return <MagicLinkCallback\n searchParams={props.searchParams || {}}\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.MagicLinkCallback)}\n />;\n }\n case availablePaths.teamInvitation: {\n redirectIfNotHandler('teamInvitation');\n return <TeamInvitation\n searchParams={props.searchParams || {}}\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.TeamInvitation)}\n />;\n }\n case availablePaths.accountSettings: {\n return <AccountSettings\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.AccountSettings)}\n />;\n }\n case availablePaths.error: {\n return <ErrorPage\n searchParams={props.searchParams || {}}\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.ErrorPage)}\n />;\n }\n default: {\n for (const [key, value] of Object.entries(availablePaths)) {\n if (path === value.replaceAll('-', '')) {\n redirect(`${props.app.urls.handler}/${value}`, RedirectType.replace);\n }\n }\n return notFound();\n }\n }\n}\n\n\nfunction filterUndefinedINU<T extends {}>(value: T | undefined): FilterUndefined<T> | undefined {\n return value === undefined ? value : filterUndefined(value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAgC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AAAA,IACA,KAAK,eAAe,mBAAmB;AACrC,2BAAqB,mBAAmB;AACxC,aAAO;AAAA,QAAC;AAAA;AAAA,UACN,cAAc,MAAM,gBAAgB,CAAC;AAAA,UACrC,UAAU,MAAM;AAAA,UACf,GAAG,mBAAmB,MAAM,gBAAgB,iBAAiB;AAAA;AAAA,MAChE;AAAA,IACF;AAAA,IACA,KAAK,eAAe,gBAAgB;AAClC,2BAAqB,gBAAgB;AACrC,aAAO;AAAA,QAAC;AAAA;AAAA,UACN,cAAc,MAAM,gBAAgB,CAAC;AAAA,UACrC,UAAU,MAAM;AAAA,UACf,GAAG,mBAAmB,MAAM,gBAAgB,cAAc;AAAA;AAAA,MAC7D;AAAA,IACF;AAAA,IACA,KAAK,eAAe,iBAAiB;AACnC,aAAO;AAAA,QAAC;AAAA;AAAA,UACN,UAAU,MAAM;AAAA,UACf,GAAG,mBAAmB,MAAM,gBAAgB,eAAe;AAAA;AAAA,MAC9D;AAAA,IACF;AAAA,IACA,KAAK,eAAe,OAAO;AACzB,aAAO;AAAA,QAAC;AAAA;AAAA,UACN,cAAc,MAAM,gBAAgB,CAAC;AAAA,UACrC,UAAU,MAAM;AAAA,UACf,GAAG,mBAAmB,MAAM,gBAAgB,SAAS;AAAA;AAAA,MACxD;AAAA,IACF;AAAA,IACA,SAAS;AACP,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,cAAc,GAAG;AACzD,YAAI,SAAS,MAAM,WAAW,KAAK,EAAE,GAAG;AACtC,0CAAS,GAAG,MAAM,IAAI,KAAK,OAAO,IAAI,KAAK,IAAI,+BAAa,OAAO;AAAA,QACrE;AAAA,MACF;AACA,iBAAO,4BAAS;AAAA,IAClB;AAAA,EACF;AACF;AAGA,SAAS,mBAAiC,OAAsD;AAC9F,SAAO,UAAU,SAAY,YAAQ,gCAAgB,KAAK;AAC5D;","names":[]}
1
+ {"version":3,"sources":["../../src/components-page/stack-handler.tsx"],"sourcesContent":["import { getRelativePart } from \"@stackframe/stack-shared/dist/utils/urls\";\nimport { RedirectType, notFound, redirect } from 'next/navigation';\nimport { SignIn, SignUp, StackServerApp } from \"..\";\nimport { MessageCard } from \"../components/message-cards/message-card\";\nimport { HandlerUrls } from \"../lib/stack-app\";\nimport { AccountSettings } from \"./account-settings\";\nimport { EmailVerification } from \"./email-verification\";\nimport { ErrorPage } from \"./error-page\";\nimport { ForgotPassword } from \"./forgot-password\";\nimport { MagicLinkCallback } from \"./magic-link-callback\";\nimport { OAuthCallback } from \"./oauth-callback\";\nimport { PasswordReset } from \"./password-reset\";\nimport { SignOut } from \"./sign-out\";\nimport { TeamInvitation } from \"./team-invitation\";\nimport { FilterUndefined, filterUndefined, pick } from \"@stackframe/stack-shared/dist/utils/objects\";\n\ntype Components = {\n SignIn: typeof SignIn,\n SignUp: typeof SignUp,\n EmailVerification: typeof EmailVerification,\n PasswordReset: typeof PasswordReset,\n ForgotPassword: typeof ForgotPassword,\n SignOut: typeof SignOut,\n OAuthCallback: typeof OAuthCallback,\n MagicLinkCallback: typeof MagicLinkCallback,\n TeamInvitation: typeof TeamInvitation,\n ErrorPage: typeof ErrorPage,\n AccountSettings: typeof AccountSettings,\n};\n\ntype RouteProps = {\n params: Promise<{ stack?: string[] }> | { stack?: string[] },\n searchParams: Promise<Record<string, string>> | Record<string, string>,\n};\n\nconst next15DeprecationWarning = \"DEPRECATION WARNING: Next.js 15 disallows spreading the props argument of <StackHandler /> like `{...props}`, so you must now explicitly pass them in the `routeProps` argument: `routeProps={props}`\";\n\nexport default async function StackHandler<HasTokenStore extends boolean>(props: {\n app: StackServerApp<HasTokenStore>,\n fullPage: boolean,\n componentProps?: {\n [K in keyof Components]?: Parameters<Components[K]>[0];\n },\n} & (\n | Partial<RouteProps>\n | {\n routeProps: RouteProps,\n }\n)): Promise<any> {\n if (!(\"routeProps\" in props)) {\n console.warn(next15DeprecationWarning);\n }\n\n const routeProps = \"routeProps\" in props ? props.routeProps : pick(props, [\"params\", \"searchParams\"] as any);\n const params = await routeProps.params;\n const searchParams = await routeProps.searchParams;\n if (!params?.stack) {\n return (\n <MessageCard title=\"Invalid Stack Handler Setup\" fullPage={props.fullPage}>\n <p>Can't use {\"<StackHandler />\"} at this location. Make sure that the file is in a folder called [...stack].</p>\n </MessageCard>\n );\n }\n\n function redirectIfNotHandler(name: keyof HandlerUrls) {\n const url = props.app.urls[name];\n const handlerUrl = props.app.urls.handler;\n\n if (url !== handlerUrl && url.startsWith(handlerUrl + \"/\")) {\n // don't redirect if the url is a handler url\n return;\n }\n\n const urlObj = new URL(url, \"http://example.com\");\n for (const [key, value] of Object.entries(routeProps.searchParams || {})) {\n urlObj.searchParams.set(key, value);\n }\n\n redirect(getRelativePart(urlObj), RedirectType.replace);\n };\n\n const availablePaths = {\n signIn: 'sign-in',\n signUp: 'sign-up',\n emailVerification: 'email-verification',\n passwordReset: 'password-reset',\n forgotPassword: 'forgot-password',\n signOut: 'sign-out',\n oauthCallback: 'oauth-callback',\n magicLinkCallback: 'magic-link-callback',\n teamInvitation: 'team-invitation',\n accountSettings: 'account-settings',\n error: 'error',\n };\n\n const path = params.stack.join('/');\n\n const render = () => {\n switch (path) {\n case availablePaths.signIn: {\n redirectIfNotHandler('signIn');\n return <SignIn\n fullPage={props.fullPage}\n automaticRedirect\n {...filterUndefinedINU(props.componentProps?.SignIn)}\n />;\n }\n case availablePaths.signUp: {\n redirectIfNotHandler('signUp');\n return <SignUp\n fullPage={props.fullPage}\n automaticRedirect\n {...filterUndefinedINU(props.componentProps?.SignUp)}\n />;\n }\n case availablePaths.emailVerification: {\n redirectIfNotHandler('emailVerification');\n return <EmailVerification\n searchParams={searchParams}\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.EmailVerification)}\n />;\n }\n case availablePaths.passwordReset: {\n redirectIfNotHandler('passwordReset');\n return <PasswordReset\n searchParams={searchParams || {}}\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.PasswordReset)}\n />;\n }\n case availablePaths.forgotPassword: {\n redirectIfNotHandler('forgotPassword');\n return <ForgotPassword\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.ForgotPassword)}\n />;\n }\n case availablePaths.signOut: {\n redirectIfNotHandler('signOut');\n return <SignOut\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.SignOut)}\n />;\n }\n case availablePaths.oauthCallback: {\n redirectIfNotHandler('oauthCallback');\n return <OAuthCallback\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.OAuthCallback)}\n />;\n }\n case availablePaths.magicLinkCallback: {\n redirectIfNotHandler('magicLinkCallback');\n return <MagicLinkCallback\n searchParams={searchParams || {}}\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.MagicLinkCallback)}\n />;\n }\n case availablePaths.teamInvitation: {\n redirectIfNotHandler('teamInvitation');\n return <TeamInvitation\n searchParams={searchParams || {}}\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.TeamInvitation)}\n />;\n }\n case availablePaths.accountSettings: {\n return <AccountSettings\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.AccountSettings)}\n />;\n }\n case availablePaths.error: {\n return <ErrorPage\n searchParams={searchParams || {}}\n fullPage={props.fullPage}\n {...filterUndefinedINU(props.componentProps?.ErrorPage)}\n />;\n }\n default: {\n for (const [key, value] of Object.entries(availablePaths)) {\n if (path === value.replaceAll('-', '')) {\n redirect(`${props.app.urls.handler}/${value}`, RedirectType.replace);\n }\n }\n return notFound();\n }\n }\n };\n\n return <>\n {process.env.NODE_ENV === \"development\" && !(\"routeProps\" in props) && (\n <span style={{ color: \"red\" }}>\n {next15DeprecationWarning}. This warning will not be shown in production.\n </span>\n )}\n {render()}\n </>;\n}\n\n\nfunction filterUndefinedINU<T extends {}>(value: T | undefined): FilterUndefined<T> | undefined {\n return value === undefined ? value : filterUndefined(value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAgC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AI,KAAK,IAAI,+BAAa,OAAO;AAAA,UACrE;AAAA,QACF;AACA,mBAAO,4BAAS;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AAEA,SAAO,4EACJ;AAAA,YAAQ,IAAI,aAAa,iBAAiB,EAAE,gBAAgB,UAC3D,6CAAC,UAAK,OAAO,EAAE,OAAO,MAAM,GACzB;AAAA;AAAA,MAAyB;AAAA,OAC5B;AAAA,IAED,OAAO;AAAA,KACV;AACF;AAGA,SAAS,mBAAiC,OAAsD;AAC9F,SAAO,UAAU,SAAY,YAAQ,gCAAgB,KAAK;AAC5D;","names":[]}
@@ -320,7 +320,7 @@ function usePasskeySection() {
320
320
  await user.registerPasskey();
321
321
  };
322
322
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Section, { title: t("Passkey"), description: hasPasskey ? t("Passkey registered") : t("Register a passkey"), children: /* @__PURE__ */ jsxs("div", { className: "flex md:justify-end gap-2", children: [
323
- !hasValidEmail && /* @__PURE__ */ jsx(Typography, { variant: "secondary", type: "label", children: t("To enable Passkey sign-in, please add a verified email and set it as your sign-in email.") }),
323
+ !hasValidEmail && /* @__PURE__ */ jsx(Typography, { variant: "secondary", type: "label", children: t("To enable Passkey sign-in, please add a verified sign-in email.") }),
324
324
  hasValidEmail && hasPasskey && isLastAuth && /* @__PURE__ */ jsx(Typography, { variant: "secondary", type: "label", children: t("Passkey sign-in is enabled and cannot be disabled as it is currently the only sign-in method") }),
325
325
  !hasPasskey && hasValidEmail && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, { onClick: handleAddNewPasskey, variant: "secondary", children: t("Add new passkey") }) }),
326
326
  hasValidEmail && hasPasskey && !isLastAuth && !showConfirmationModal && /* @__PURE__ */ jsx(
@@ -405,7 +405,7 @@ function useOtpSection() {
405
405
  },
406
406
  children: t("Enable OTP")
407
407
  }
408
- ) : /* @__PURE__ */ jsx(Typography, { variant: "secondary", type: "label", children: t("To enable OTP sign-in, please add a verified email and set it as your sign-in email.") }) }) });
408
+ ) : /* @__PURE__ */ jsx(Typography, { variant: "secondary", type: "label", children: t("To enable OTP sign-in, please add a verified sign-in email.") }) }) });
409
409
  }
410
410
  function SettingsPage() {
411
411
  const deleteAccountSection = useDeleteAccountSection();
@@ -439,7 +439,7 @@ function usePasswordSection() {
439
439
  const { register, handleSubmit, setError, formState: { errors }, clearErrors, reset } = useForm({
440
440
  resolver: yupResolver(passwordSchema)
441
441
  });
442
- const hasValidEmail = contactChannels.filter((x) => x.type === "email" && x.isVerified && x.usedForAuth).length > 0;
442
+ const hasValidEmail = contactChannels.filter((x) => x.type === "email" && x.usedForAuth).length > 0;
443
443
  const onSubmit = async (data) => {
444
444
  setLoading(true);
445
445
  try {
@@ -469,7 +469,7 @@ function usePasswordSection() {
469
469
  onClick: () => setChangingPassword(true),
470
470
  children: user.hasPassword ? t("Update password") : t("Set password")
471
471
  }
472
- ) : /* @__PURE__ */ jsx(Typography, { variant: "secondary", type: "label", children: t("To set a password, please add a verified email and set it as your sign-in email.") }) : /* @__PURE__ */ jsxs(
472
+ ) : /* @__PURE__ */ jsx(Typography, { variant: "secondary", type: "label", children: t("To set a password, please add a sign-in email.") }) : /* @__PURE__ */ jsxs(
473
473
  "form",
474
474
  {
475
475
  onSubmit: (e) => runAsynchronouslyWithAlert(handleSubmit(onSubmit)(e)),