@stackframe/stack 2.3.5 → 2.3.7

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.
Files changed (261) hide show
  1. package/dist/components/card-frame.d.mts +9 -0
  2. package/dist/components/card-frame.d.ts +8 -5
  3. package/dist/components/card-frame.js +58 -23
  4. package/dist/components/credential-sign-in.d.mts +5 -0
  5. package/dist/components/credential-sign-in.d.ts +5 -1
  6. package/dist/components/credential-sign-in.js +109 -41
  7. package/dist/components/credential-sign-up.d.mts +5 -0
  8. package/dist/components/credential-sign-up.d.ts +5 -1
  9. package/dist/components/credential-sign-up.js +140 -62
  10. package/dist/components/forgot-password.d.mts +7 -0
  11. package/dist/components/forgot-password.d.ts +6 -2
  12. package/dist/components/forgot-password.js +83 -26
  13. package/dist/components/form-warning.d.mts +7 -0
  14. package/dist/components/form-warning.d.ts +6 -2
  15. package/dist/components/form-warning.js +34 -8
  16. package/dist/components/magic-link-sign-in.d.mts +5 -0
  17. package/dist/components/magic-link-sign-in.d.ts +5 -1
  18. package/dist/components/magic-link-sign-in.js +89 -31
  19. package/dist/components/message-card.d.mts +10 -0
  20. package/dist/components/message-card.d.ts +8 -4
  21. package/dist/components/message-card.js +45 -6
  22. package/dist/components/oauth-button.d.mts +8 -0
  23. package/dist/components/oauth-button.d.ts +6 -2
  24. package/dist/components/oauth-button.js +142 -63
  25. package/dist/components/oauth-group.d.mts +7 -0
  26. package/dist/components/oauth-group.d.ts +6 -2
  27. package/dist/components/oauth-group.js +46 -8
  28. package/dist/components/password-field.d.mts +5 -0
  29. package/dist/components/password-field.d.ts +5 -3
  30. package/dist/components/password-field.js +111 -41
  31. package/dist/components/password-reset-inner.d.mts +8 -0
  32. package/dist/components/password-reset-inner.d.ts +6 -2
  33. package/dist/components/password-reset-inner.js +120 -58
  34. package/dist/components/redirect-message-card.d.mts +8 -0
  35. package/dist/components/redirect-message-card.d.ts +6 -2
  36. package/dist/components/redirect-message-card.js +110 -58
  37. package/dist/components/separator-with-text.d.mts +7 -0
  38. package/dist/components/separator-with-text.d.ts +6 -2
  39. package/dist/components/separator-with-text.js +35 -5
  40. package/dist/components/user-avatar.d.mts +13 -0
  41. package/dist/components/user-avatar.d.ts +11 -3
  42. package/dist/components/user-avatar.js +34 -6
  43. package/dist/components/user-button.d.mts +15 -0
  44. package/dist/components/user-button.d.ts +12 -3
  45. package/dist/components/user-button.js +156 -26
  46. package/dist/components-core/avatar.d.mts +8 -0
  47. package/dist/components-core/avatar.d.ts +7 -5
  48. package/dist/components-core/avatar.js +73 -18
  49. package/dist/components-core/button.d.mts +12 -0
  50. package/dist/components-core/button.d.ts +8 -6
  51. package/dist/components-core/button.js +177 -113
  52. package/dist/components-core/card.d.mts +8 -0
  53. package/dist/components-core/card.d.ts +4 -2
  54. package/dist/components-core/card.js +73 -22
  55. package/dist/components-core/collapsible.d.mts +8 -0
  56. package/dist/components-core/collapsible.d.ts +8 -6
  57. package/dist/components-core/collapsible.js +48 -5
  58. package/dist/components-core/container.d.mts +8 -0
  59. package/dist/components-core/container.d.ts +5 -3
  60. package/dist/components-core/container.js +61 -11
  61. package/dist/components-core/dropdown.d.mts +15 -0
  62. package/dist/components-core/dropdown.d.ts +10 -8
  63. package/dist/components-core/dropdown.js +108 -36
  64. package/dist/components-core/index.d.mts +59 -0
  65. package/dist/components-core/index.d.ts +51 -40
  66. package/dist/components-core/index.js +144 -46
  67. package/dist/components-core/input.d.mts +6 -0
  68. package/dist/components-core/input.d.ts +5 -3
  69. package/dist/components-core/input.js +97 -28
  70. package/dist/components-core/label.d.mts +6 -0
  71. package/dist/components-core/label.d.ts +5 -3
  72. package/dist/components-core/label.js +65 -15
  73. package/dist/components-core/link.d.mts +10 -0
  74. package/dist/components-core/link.d.ts +7 -6
  75. package/dist/components-core/link.js +72 -18
  76. package/dist/components-core/loading-indicator.d.mts +13 -0
  77. package/dist/components-core/loading-indicator.d.ts +11 -4
  78. package/dist/components-core/loading-indicator.js +46 -6
  79. package/dist/components-core/popover.d.mts +8 -0
  80. package/dist/components-core/popover.d.ts +8 -6
  81. package/dist/components-core/popover.js +72 -16
  82. package/dist/components-core/separator.d.mts +6 -0
  83. package/dist/components-core/separator.d.ts +5 -3
  84. package/dist/components-core/separator.js +66 -16
  85. package/dist/components-core/skeleton.d.mts +7 -0
  86. package/dist/components-core/skeleton.d.ts +5 -3
  87. package/dist/components-core/skeleton.js +75 -21
  88. package/dist/components-core/tabs.d.mts +9 -0
  89. package/dist/components-core/tabs.d.ts +8 -6
  90. package/dist/components-core/tabs.js +87 -20
  91. package/dist/components-core/text.d.mts +10 -0
  92. package/dist/components-core/text.d.ts +5 -3
  93. package/dist/components-core/text.js +95 -40
  94. package/dist/components-core-joy/button.d.mts +6 -0
  95. package/dist/components-core-joy/button.d.ts +6 -2
  96. package/dist/components-core-joy/button.js +86 -28
  97. package/dist/components-core-joy/input.d.mts +5 -0
  98. package/dist/components-core-joy/input.d.ts +5 -2
  99. package/dist/components-core-joy/input.js +51 -6
  100. package/dist/components-core-joy/separator.d.mts +6 -0
  101. package/dist/components-core-joy/separator.d.ts +6 -2
  102. package/dist/components-core-joy/separator.js +50 -6
  103. package/dist/components-core-joy/tabs.d.mts +9 -0
  104. package/dist/components-core-joy/tabs.d.ts +9 -5
  105. package/dist/components-core-joy/tabs.js +62 -16
  106. package/dist/components-core-joy/text.d.mts +9 -0
  107. package/dist/components-core-joy/text.d.ts +6 -3
  108. package/dist/components-core-joy/text.js +68 -28
  109. package/dist/components-page/account-settings.d.mts +7 -0
  110. package/dist/components-page/account-settings.d.ts +6 -2
  111. package/dist/components-page/account-settings.js +213 -81
  112. package/dist/components-page/auth-page.d.mts +8 -0
  113. package/dist/components-page/auth-page.d.ts +6 -2
  114. package/dist/components-page/auth-page.js +79 -19
  115. package/dist/components-page/email-verification.d.mts +8 -0
  116. package/dist/components-page/email-verification.d.ts +6 -2
  117. package/dist/components-page/email-verification.js +65 -28
  118. package/dist/components-page/forgot-password.d.mts +7 -0
  119. package/dist/components-page/forgot-password.d.ts +6 -2
  120. package/dist/components-page/forgot-password.js +64 -20
  121. package/dist/components-page/magic-link-callback.d.mts +8 -0
  122. package/dist/components-page/magic-link-callback.d.ts +6 -2
  123. package/dist/components-page/magic-link-callback.js +72 -34
  124. package/dist/components-page/oauth-callback.d.mts +5 -0
  125. package/dist/components-page/oauth-callback.d.ts +5 -1
  126. package/dist/components-page/oauth-callback.js +52 -16
  127. package/dist/components-page/password-reset.d.mts +8 -0
  128. package/dist/components-page/password-reset.d.ts +6 -2
  129. package/dist/components-page/password-reset.js +70 -34
  130. package/dist/components-page/sign-in.d.mts +7 -0
  131. package/dist/components-page/sign-in.d.ts +6 -2
  132. package/dist/components-page/sign-in.js +41 -5
  133. package/dist/components-page/sign-out.d.mts +5 -0
  134. package/dist/components-page/sign-out.d.ts +5 -1
  135. package/dist/components-page/sign-out.js +47 -11
  136. package/dist/components-page/sign-up.d.mts +7 -0
  137. package/dist/components-page/sign-up.d.ts +6 -2
  138. package/dist/components-page/sign-up.js +41 -5
  139. package/dist/components-page/stack-handler.d.mts +16 -0
  140. package/dist/components-page/stack-handler.d.ts +11 -3
  141. package/dist/components-page/stack-handler.js +102 -64
  142. package/dist/esm/components/card-frame.js +39 -0
  143. package/dist/esm/components/credential-sign-in.js +82 -0
  144. package/dist/esm/components/credential-sign-up.js +114 -0
  145. package/dist/esm/components/forgot-password.js +55 -0
  146. package/dist/esm/components/form-warning.js +15 -0
  147. package/dist/esm/components/magic-link-sign-in.js +61 -0
  148. package/dist/esm/components/message-card.js +16 -0
  149. package/dist/esm/components/oauth-button.js +124 -0
  150. package/dist/esm/components/oauth-group.js +17 -0
  151. package/dist/esm/components/password-field.js +82 -0
  152. package/dist/esm/components/password-reset-inner.js +93 -0
  153. package/dist/esm/components/redirect-message-card.js +83 -0
  154. package/dist/esm/components/separator-with-text.js +16 -0
  155. package/dist/esm/components/user-avatar.js +14 -0
  156. package/dist/esm/components/user-button.js +133 -0
  157. package/dist/esm/components-core/avatar.js +56 -0
  158. package/dist/esm/components-core/button.js +165 -0
  159. package/dist/esm/components-core/card.js +51 -0
  160. package/dist/esm/components-core/collapsible.js +13 -0
  161. package/dist/esm/components-core/container.js +35 -0
  162. package/dist/esm/components-core/dropdown.js +106 -0
  163. package/dist/esm/components-core/index.js +93 -0
  164. package/dist/esm/components-core/input.js +80 -0
  165. package/dist/esm/components-core/label.js +38 -0
  166. package/dist/esm/components-core/link.js +38 -0
  167. package/dist/esm/components-core/loading-indicator.js +27 -0
  168. package/dist/esm/components-core/popover.js +43 -0
  169. package/dist/esm/components-core/separator.js +36 -0
  170. package/dist/esm/components-core/skeleton.js +52 -0
  171. package/dist/esm/components-core/tabs.js +79 -0
  172. package/dist/esm/components-core/text.js +63 -0
  173. package/dist/esm/components-core-joy/button.js +53 -0
  174. package/dist/esm/components-core-joy/input.js +18 -0
  175. package/dist/esm/components-core-joy/separator.js +17 -0
  176. package/dist/esm/components-core-joy/tabs.js +29 -0
  177. package/dist/esm/components-core-joy/text.js +35 -0
  178. package/dist/esm/components-page/account-settings.js +197 -0
  179. package/dist/esm/components-page/auth-page.js +50 -0
  180. package/dist/esm/components-page/email-verification.js +36 -0
  181. package/dist/esm/components-page/forgot-password.js +35 -0
  182. package/dist/esm/components-page/magic-link-callback.js +43 -0
  183. package/dist/esm/components-page/oauth-callback.js +23 -0
  184. package/dist/esm/components-page/password-reset.js +42 -0
  185. package/dist/esm/components-page/sign-in.js +12 -0
  186. package/dist/esm/components-page/sign-out.js +18 -0
  187. package/dist/esm/components-page/sign-up.js +12 -0
  188. package/dist/esm/components-page/stack-handler.js +75 -0
  189. package/dist/esm/index.js +47 -0
  190. package/dist/esm/joy.js +5 -0
  191. package/dist/esm/lib/auth.js +62 -0
  192. package/dist/esm/lib/cookie.js +185 -0
  193. package/dist/esm/lib/hooks.js +29 -0
  194. package/dist/esm/lib/stack-app.js +940 -0
  195. package/dist/esm/providers/component-provider.js +76 -0
  196. package/dist/esm/providers/design-provider.js +36 -0
  197. package/dist/esm/providers/joy-provider.js +35 -0
  198. package/dist/esm/providers/stack-provider-client.js +31 -0
  199. package/dist/esm/providers/stack-provider.js +21 -0
  200. package/dist/esm/providers/styled-components-registry.js +24 -0
  201. package/dist/esm/providers/theme-provider.js +22 -0
  202. package/dist/esm/utils/browser-script.js +25 -0
  203. package/dist/esm/utils/constants.js +34 -0
  204. package/dist/esm/utils/email.js +10 -0
  205. package/dist/esm/utils/next.js +7 -0
  206. package/dist/esm/utils/url.js +21 -0
  207. package/dist/index.d.mts +37 -0
  208. package/dist/index.d.ts +37 -22
  209. package/dist/index.js +106 -21
  210. package/dist/joy.d.mts +16 -0
  211. package/dist/joy.d.ts +16 -1
  212. package/dist/joy.js +30 -1
  213. package/dist/lib/auth.d.mts +11 -0
  214. package/dist/lib/auth.d.ts +8 -4
  215. package/dist/lib/auth.js +83 -57
  216. package/dist/lib/cookie.d.mts +14 -0
  217. package/dist/lib/cookie.d.ts +8 -6
  218. package/dist/lib/cookie.js +217 -45
  219. package/dist/lib/hooks.d.mts +35 -0
  220. package/dist/lib/hooks.d.ts +14 -8
  221. package/dist/lib/hooks.js +53 -28
  222. package/dist/lib/stack-app.d.mts +227 -0
  223. package/dist/lib/stack-app.d.ts +43 -41
  224. package/dist/lib/stack-app.js +937 -849
  225. package/dist/providers/component-provider.d.mts +113 -0
  226. package/dist/providers/component-provider.d.ts +95 -77
  227. package/dist/providers/component-provider.js +92 -58
  228. package/dist/providers/design-provider.d.mts +34 -0
  229. package/dist/providers/design-provider.d.ts +16 -21
  230. package/dist/providers/design-provider.js +57 -58
  231. package/dist/providers/joy-provider.d.mts +36 -0
  232. package/dist/providers/joy-provider.d.ts +30 -14
  233. package/dist/providers/joy-provider.js +58 -30
  234. package/dist/providers/stack-provider-client.d.mts +20 -0
  235. package/dist/providers/stack-provider-client.d.ts +15 -8
  236. package/dist/providers/stack-provider-client.js +64 -20
  237. package/dist/providers/stack-provider.d.mts +14 -0
  238. package/dist/providers/stack-provider.d.ts +13 -5
  239. package/dist/providers/stack-provider.js +39 -8
  240. package/dist/providers/styled-components-registry.d.mts +8 -0
  241. package/dist/providers/styled-components-registry.d.ts +8 -4
  242. package/dist/providers/styled-components-registry.js +43 -17
  243. package/dist/providers/theme-provider.d.mts +22 -0
  244. package/dist/providers/theme-provider.d.ts +21 -9
  245. package/dist/providers/theme-provider.js +55 -19
  246. package/dist/utils/browser-script.d.mts +5 -0
  247. package/dist/utils/browser-script.d.ts +5 -0
  248. package/dist/utils/browser-script.js +50 -0
  249. package/dist/utils/constants.d.mts +48 -0
  250. package/dist/utils/constants.d.ts +11 -9
  251. package/dist/utils/constants.js +66 -21
  252. package/dist/utils/email.d.mts +3 -0
  253. package/dist/utils/email.d.ts +3 -1
  254. package/dist/utils/email.js +44 -6
  255. package/dist/utils/next.d.mts +3 -0
  256. package/dist/utils/next.d.ts +3 -1
  257. package/dist/utils/next.js +31 -3
  258. package/dist/utils/url.d.mts +4 -0
  259. package/dist/utils/url.d.ts +4 -2
  260. package/dist/utils/url.js +44 -13
  261. package/package.json +19 -10
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-page/forgot-password.tsx
5
+ import ForgotPasswordElement from "../components/forgot-password";
6
+ import CardFrame from "../components/card-frame";
7
+ import { useUser, useStackApp } from "..";
8
+ import RedirectMessageCard from "../components/redirect-message-card";
9
+ import { useState } from "react";
10
+ import { Link, Text } from "../components-core";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ function ForgotPassword({ fullPage = false }) {
13
+ const stackApp = useStackApp();
14
+ const user = useUser();
15
+ const [sent, setSent] = useState(false);
16
+ if (user) {
17
+ return /* @__PURE__ */ jsx(RedirectMessageCard, { type: "signedIn", fullPage });
18
+ }
19
+ if (sent) {
20
+ return /* @__PURE__ */ jsx(RedirectMessageCard, { type: "emailSent", fullPage });
21
+ }
22
+ return /* @__PURE__ */ jsxs(CardFrame, { fullPage, children: [
23
+ /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", marginBottom: "1.5rem" }, children: [
24
+ /* @__PURE__ */ jsx(Text, { size: "xl", as: "h2", children: "Reset Your Password" }),
25
+ /* @__PURE__ */ jsxs(Text, { children: [
26
+ "Don't need to reset? ",
27
+ /* @__PURE__ */ jsx(Link, { href: stackApp.urls["signUp"], children: "Sign In" })
28
+ ] })
29
+ ] }),
30
+ /* @__PURE__ */ jsx(ForgotPasswordElement, { onSent: () => setSent(true) })
31
+ ] });
32
+ }
33
+ export {
34
+ ForgotPassword as default
35
+ };
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-page/magic-link-callback.tsx
5
+ import { use } from "react";
6
+ import { useStackApp, useUser } from "..";
7
+ import MessageCard from "../components/message-card";
8
+ import RedirectMessageCard from "../components/redirect-message-card";
9
+ import { KnownErrors } from "@stackframe/stack-shared";
10
+ import { neverResolve } from "@stackframe/stack-shared/dist/utils/promises";
11
+ import { jsx } from "react/jsx-runtime";
12
+ function MagicLinkCallback({
13
+ searchParams: {
14
+ code = ""
15
+ } = {},
16
+ fullPage = false
17
+ }) {
18
+ const stackApp = useStackApp();
19
+ const user = useUser();
20
+ if (user) {
21
+ return /* @__PURE__ */ jsx(RedirectMessageCard, { type: "signedIn", fullPage });
22
+ }
23
+ const invalidJsx = /* @__PURE__ */ jsx(MessageCard, { title: "Invalid Magic Link", fullPage, children: /* @__PURE__ */ jsx("p", { children: "Please check if you have the correct link. If you continue to have issues, please contact support." }) });
24
+ const expiredJsx = /* @__PURE__ */ jsx(MessageCard, { title: "Expired Magic Link", fullPage, children: /* @__PURE__ */ jsx("p", { children: "Your magic link has expired. Please request a new magic link if you need to sign-in." }) });
25
+ const allredyUsedJsx = /* @__PURE__ */ jsx(MessageCard, { title: "Magic Link Already Used", fullPage, children: /* @__PURE__ */ jsx("p", { children: "The magic link has already been used. The link can only be used once. Please request a new magic link if you need to sign-in again." }) });
26
+ if (!code) {
27
+ return invalidJsx;
28
+ }
29
+ const error = use(stackApp.signInWithMagicLink(code));
30
+ if (error instanceof KnownErrors.MagicLinkCodeNotFound) {
31
+ return invalidJsx;
32
+ } else if (error instanceof KnownErrors.MagicLinkCodeExpired) {
33
+ return expiredJsx;
34
+ } else if (error instanceof KnownErrors.MagicLinkCodeAlreadyUsed) {
35
+ return allredyUsedJsx;
36
+ } else if (error) {
37
+ throw error;
38
+ }
39
+ use(neverResolve());
40
+ }
41
+ export {
42
+ MagicLinkCallback as default
43
+ };
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-page/oauth-callback.tsx
5
+ import { useRef, useEffect } from "react";
6
+ import { useStackApp } from "..";
7
+ import { runAsynchronously } from "@stackframe/stack-shared/dist/utils/promises";
8
+ import MessageCard from "../components/message-card";
9
+ import { jsx } from "react/jsx-runtime";
10
+ function OAuthCallback() {
11
+ const app = useStackApp();
12
+ const called = useRef(false);
13
+ useEffect(() => runAsynchronously(async () => {
14
+ if (called.current)
15
+ return;
16
+ called.current = true;
17
+ await app.callOAuthCallback();
18
+ }), []);
19
+ return /* @__PURE__ */ jsx(MessageCard, { title: "Redirecting...", fullPage: true });
20
+ }
21
+ export {
22
+ OAuthCallback as default
23
+ };
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-page/password-reset.tsx
5
+ import MessageCard from "../components/message-card";
6
+ import { useStackApp } from "..";
7
+ import { use } from "react";
8
+ import PasswordResetInner from "../components/password-reset-inner";
9
+ import { cacheFunction } from "@stackframe/stack-shared/dist/utils/caches";
10
+ import { Text } from "../components-core";
11
+ import { KnownErrors } from "@stackframe/stack-shared";
12
+ import { jsx } from "react/jsx-runtime";
13
+ var cachedVerifyPasswordResetCode = cacheFunction(async (stackApp, code) => {
14
+ return await stackApp.verifyPasswordResetCode(code);
15
+ });
16
+ function PasswordReset({
17
+ searchParams,
18
+ fullPage = false
19
+ }) {
20
+ const stackApp = useStackApp();
21
+ const invalidJsx = /* @__PURE__ */ jsx(MessageCard, { title: "Invalid Password Reset Link", fullPage, children: /* @__PURE__ */ jsx(Text, { children: "Please double check if you have the correct password reset link." }) });
22
+ const expiredJsx = /* @__PURE__ */ jsx(MessageCard, { title: "Expired Password Reset Link", fullPage, children: /* @__PURE__ */ jsx(Text, { children: "Your password reset link has expired. Please request a new password reset link from the login page." }) });
23
+ const usedJsx = /* @__PURE__ */ jsx(MessageCard, { title: "Used Password Reset Link", fullPage, children: /* @__PURE__ */ jsx(Text, { children: "This password reset link has already been used. If you need to reset your password again, please request a new password reset link from the login page." }) });
24
+ const code = searchParams?.code;
25
+ if (!code) {
26
+ return invalidJsx;
27
+ }
28
+ const error = use(cachedVerifyPasswordResetCode(stackApp, code));
29
+ if (error instanceof KnownErrors.PasswordResetCodeNotFound) {
30
+ return invalidJsx;
31
+ } else if (error instanceof KnownErrors.PasswordResetCodeExpired) {
32
+ return expiredJsx;
33
+ } else if (error instanceof KnownErrors.PasswordResetCodeAlreadyUsed) {
34
+ return usedJsx;
35
+ } else if (error) {
36
+ throw error;
37
+ }
38
+ return /* @__PURE__ */ jsx(PasswordResetInner, { code, fullPage });
39
+ }
40
+ export {
41
+ PasswordReset as default
42
+ };
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-page/sign-in.tsx
5
+ import AuthPage from "./auth-page";
6
+ import { jsx } from "react/jsx-runtime";
7
+ function SignIn({ fullPage = false }) {
8
+ return /* @__PURE__ */ jsx(AuthPage, { fullPage, type: "sign-in" });
9
+ }
10
+ export {
11
+ SignIn as default
12
+ };
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-page/sign-out.tsx
5
+ import { use } from "react";
6
+ import { useUser } from "..";
7
+ import GoHomeMessageCard from "../components/redirect-message-card";
8
+ import { jsx } from "react/jsx-runtime";
9
+ function Signout() {
10
+ const user = useUser();
11
+ if (user) {
12
+ use(user.signOut());
13
+ }
14
+ return /* @__PURE__ */ jsx(GoHomeMessageCard, { type: "signedOut", fullPage: true });
15
+ }
16
+ export {
17
+ Signout as default
18
+ };
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-page/sign-up.tsx
5
+ import AuthPage from "./auth-page";
6
+ import { jsx } from "react/jsx-runtime";
7
+ function SignUp({ fullPage = false }) {
8
+ return /* @__PURE__ */ jsx(AuthPage, { fullPage, type: "sign-up" });
9
+ }
10
+ export {
11
+ SignUp as default
12
+ };
@@ -0,0 +1,75 @@
1
+ // src/components-page/stack-handler.tsx
2
+ import SignUp from "./sign-up";
3
+ import SignIn from "./sign-in";
4
+ import { RedirectType, notFound, redirect } from "next/navigation";
5
+ import EmailVerification from "./email-verification";
6
+ import { PasswordReset } from "..";
7
+ import MessageCard from "../components/message-card";
8
+ import Signout from "./sign-out";
9
+ import ForgotPassword from "./forgot-password";
10
+ import OAuthCallback from "./oauth-callback";
11
+ import AccountSettings from "./account-settings";
12
+ import MagicLinkCallback from "./magic-link-callback";
13
+ import { jsx } from "react/jsx-runtime";
14
+ async function StackHandler({
15
+ app,
16
+ params: { stack } = {},
17
+ searchParams = {}
18
+ }) {
19
+ if (!stack) {
20
+ return /* @__PURE__ */ jsx(MessageCard, { title: "Invalid Stack Handler Setup", fullPage: true, children: /* @__PURE__ */ jsx("p", { children: "Can't use Stack handler at this location. Make sure that the file is in a folder called [...stack]." }) });
21
+ }
22
+ function redirectIfNotHandler(name) {
23
+ const url = app.urls[name];
24
+ const handlerUrl = app.urls.handler;
25
+ if (url.startsWith(handlerUrl)) {
26
+ return;
27
+ }
28
+ redirect(url, RedirectType.replace);
29
+ }
30
+ const path = stack.join("/");
31
+ switch (path) {
32
+ case "signin": {
33
+ redirectIfNotHandler("signIn");
34
+ return /* @__PURE__ */ jsx(SignIn, { fullPage: true });
35
+ }
36
+ case "signup": {
37
+ redirectIfNotHandler("signUp");
38
+ return /* @__PURE__ */ jsx(SignUp, { fullPage: true });
39
+ }
40
+ case "email-verification": {
41
+ redirectIfNotHandler("emailVerification");
42
+ return /* @__PURE__ */ jsx(EmailVerification, { searchParams, fullPage: true });
43
+ }
44
+ case "password-reset": {
45
+ redirectIfNotHandler("passwordReset");
46
+ return /* @__PURE__ */ jsx(PasswordReset, { searchParams, fullPage: true });
47
+ }
48
+ case "forgot-password": {
49
+ redirectIfNotHandler("forgotPassword");
50
+ return /* @__PURE__ */ jsx(ForgotPassword, { fullPage: true });
51
+ }
52
+ case "signout": {
53
+ redirectIfNotHandler("signOut");
54
+ return /* @__PURE__ */ jsx(Signout, {});
55
+ }
56
+ case "oauth-callback": {
57
+ redirectIfNotHandler("oauthCallback");
58
+ return /* @__PURE__ */ jsx(OAuthCallback, {});
59
+ }
60
+ case "account-settings": {
61
+ redirectIfNotHandler("accountSettings");
62
+ return /* @__PURE__ */ jsx(AccountSettings, { fullPage: true });
63
+ }
64
+ case "magic-link-callback": {
65
+ redirectIfNotHandler("magicLinkCallback");
66
+ return /* @__PURE__ */ jsx(MagicLinkCallback, { searchParams, fullPage: true });
67
+ }
68
+ default: {
69
+ return notFound();
70
+ }
71
+ }
72
+ }
73
+ export {
74
+ StackHandler as default
75
+ };
@@ -0,0 +1,47 @@
1
+ // src/index.tsx
2
+ import { default as default2 } from "./providers/stack-provider";
3
+ import { useUser, useStackApp } from "./lib/hooks";
4
+ import { StackClientApp, StackServerApp, StackAdminApp } from "./lib/stack-app";
5
+ import { default as default3 } from "./components-page/stack-handler";
6
+ import { default as default4 } from "./components-page/sign-in";
7
+ import { default as default5 } from "./components-page/sign-up";
8
+ import { default as default6 } from "./components-page/email-verification";
9
+ import { default as default7 } from "./components-page/password-reset";
10
+ import { default as default8 } from "./components-page/forgot-password";
11
+ import { default as default9 } from "./components/message-card";
12
+ import { default as default10 } from "./components/credential-sign-in";
13
+ import { default as default11 } from "./components/credential-sign-up";
14
+ import { default as default12 } from "./components/oauth-button";
15
+ import { default as default13 } from "./components/oauth-group";
16
+ import { default as default14 } from "./components/password-field";
17
+ import { default as default15 } from "./components/user-button";
18
+ import { default as default16 } from "./components-page/account-settings";
19
+ import { useDesign } from "./providers/design-provider";
20
+ import { useComponents } from "./providers/component-provider";
21
+ import { StackTheme } from "./providers/theme-provider";
22
+ export * from "./components-core";
23
+ export {
24
+ default16 as AccountSettings,
25
+ default10 as CredentialSignIn,
26
+ default11 as CredentialSignUp,
27
+ default6 as EmailVerification,
28
+ default8 as ForgotPassword,
29
+ default9 as MessageCard,
30
+ default12 as OAuthButton,
31
+ default13 as OAuthGroup,
32
+ default14 as PasswordField,
33
+ default7 as PasswordReset,
34
+ default4 as SignIn,
35
+ default5 as SignUp,
36
+ StackAdminApp,
37
+ StackClientApp,
38
+ default3 as StackHandler,
39
+ default2 as StackProvider,
40
+ StackServerApp,
41
+ StackTheme,
42
+ default15 as UserButton,
43
+ useComponents,
44
+ useDesign,
45
+ useStackApp,
46
+ useUser
47
+ };
@@ -0,0 +1,5 @@
1
+ // src/joy.tsx
2
+ import { StackJoyTheme } from "./providers/joy-provider";
3
+ export {
4
+ StackJoyTheme
5
+ };
@@ -0,0 +1,62 @@
1
+ // src/lib/auth.ts
2
+ import { saveVerifierAndState, getVerifierAndState } from "./cookie";
3
+ import { constructRedirectUrl } from "../utils/url";
4
+ import { neverResolve } from "@stackframe/stack-shared/dist/utils/promises";
5
+ import { StackAssertionError } from "@stackframe/stack-shared/dist/utils/errors";
6
+ async function signInWithOAuth(iface, {
7
+ provider,
8
+ redirectUrl
9
+ }) {
10
+ redirectUrl = constructRedirectUrl(redirectUrl);
11
+ const { codeChallenge, state } = await saveVerifierAndState();
12
+ const location = await iface.getOAuthUrl(
13
+ provider,
14
+ redirectUrl,
15
+ codeChallenge,
16
+ state
17
+ );
18
+ window.location.assign(location);
19
+ await neverResolve();
20
+ }
21
+ function consumeOAuthCallbackQueryParams(expectedState) {
22
+ const requiredParams = ["code", "state"];
23
+ const originalUrl = new URL(window.location.href);
24
+ for (const param of requiredParams) {
25
+ if (!originalUrl.searchParams.has(param)) {
26
+ return null;
27
+ }
28
+ }
29
+ if (expectedState !== originalUrl.searchParams.get("state")) {
30
+ return null;
31
+ }
32
+ const newUrl = new URL(originalUrl);
33
+ for (const param of requiredParams) {
34
+ newUrl.searchParams.delete(param);
35
+ }
36
+ window.history.replaceState({}, "", newUrl.toString());
37
+ return originalUrl;
38
+ }
39
+ async function callOAuthCallback(iface, tokenStore, redirectUrl) {
40
+ const { codeVerifier, state } = getVerifierAndState();
41
+ if (!codeVerifier || !state) {
42
+ throw new Error("Invalid OAuth callback URL parameters. It seems like the OAuth flow was interrupted, so please try again.");
43
+ }
44
+ const originalUrl = consumeOAuthCallbackQueryParams(state);
45
+ if (!originalUrl)
46
+ return null;
47
+ try {
48
+ return await iface.callOAuthCallback(
49
+ originalUrl.searchParams,
50
+ constructRedirectUrl(redirectUrl),
51
+ codeVerifier,
52
+ state,
53
+ tokenStore
54
+ );
55
+ } catch (e) {
56
+ throw new StackAssertionError("Error signing in during OAuth callback. Please try again.", { cause: e });
57
+ }
58
+ }
59
+ export {
60
+ callOAuthCallback,
61
+ signInWithOAuth
62
+ };
@@ -0,0 +1,185 @@
1
+ // ../../node_modules/.pnpm/oauth4webapi@2.10.3/node_modules/oauth4webapi/build/index.js
2
+ var USER_AGENT;
3
+ if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
4
+ const NAME = "oauth4webapi";
5
+ const VERSION = "v2.10.3";
6
+ USER_AGENT = `${NAME}/${VERSION}`;
7
+ }
8
+ var clockSkew = Symbol();
9
+ var clockTolerance = Symbol();
10
+ var customFetch = Symbol();
11
+ var useMtlsAlias = Symbol();
12
+ var encoder = new TextEncoder();
13
+ var decoder = new TextDecoder();
14
+ function buf(input) {
15
+ if (typeof input === "string") {
16
+ return encoder.encode(input);
17
+ }
18
+ return decoder.decode(input);
19
+ }
20
+ var CHUNK_SIZE = 32768;
21
+ function encodeBase64Url(input) {
22
+ if (input instanceof ArrayBuffer) {
23
+ input = new Uint8Array(input);
24
+ }
25
+ const arr = [];
26
+ for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) {
27
+ arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
28
+ }
29
+ return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
30
+ }
31
+ function decodeBase64Url(input) {
32
+ try {
33
+ const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
34
+ const bytes = new Uint8Array(binary.length);
35
+ for (let i = 0; i < binary.length; i++) {
36
+ bytes[i] = binary.charCodeAt(i);
37
+ }
38
+ return bytes;
39
+ } catch (cause) {
40
+ throw new OPE("The input to be decoded is not correctly encoded.", { cause });
41
+ }
42
+ }
43
+ function b64u(input) {
44
+ if (typeof input === "string") {
45
+ return decodeBase64Url(input);
46
+ }
47
+ return encodeBase64Url(input);
48
+ }
49
+ var LRU = class {
50
+ constructor(maxSize) {
51
+ this.cache = /* @__PURE__ */ new Map();
52
+ this._cache = /* @__PURE__ */ new Map();
53
+ this.maxSize = maxSize;
54
+ }
55
+ get(key) {
56
+ let v = this.cache.get(key);
57
+ if (v) {
58
+ return v;
59
+ }
60
+ if (v = this._cache.get(key)) {
61
+ this.update(key, v);
62
+ return v;
63
+ }
64
+ return void 0;
65
+ }
66
+ has(key) {
67
+ return this.cache.has(key) || this._cache.has(key);
68
+ }
69
+ set(key, value) {
70
+ if (this.cache.has(key)) {
71
+ this.cache.set(key, value);
72
+ } else {
73
+ this.update(key, value);
74
+ }
75
+ return this;
76
+ }
77
+ delete(key) {
78
+ if (this.cache.has(key)) {
79
+ return this.cache.delete(key);
80
+ }
81
+ if (this._cache.has(key)) {
82
+ return this._cache.delete(key);
83
+ }
84
+ return false;
85
+ }
86
+ update(key, value) {
87
+ this.cache.set(key, value);
88
+ if (this.cache.size >= this.maxSize) {
89
+ this._cache = this.cache;
90
+ this.cache = /* @__PURE__ */ new Map();
91
+ }
92
+ }
93
+ };
94
+ var OperationProcessingError = class extends Error {
95
+ constructor(message, options) {
96
+ super(message, options);
97
+ this.name = this.constructor.name;
98
+ Error.captureStackTrace?.(this, this.constructor);
99
+ }
100
+ };
101
+ var OPE = OperationProcessingError;
102
+ var dpopNonces = new LRU(100);
103
+ function validateString(input) {
104
+ return typeof input === "string" && input.length !== 0;
105
+ }
106
+ function randomBytes() {
107
+ return b64u(crypto.getRandomValues(new Uint8Array(32)));
108
+ }
109
+ function generateRandomCodeVerifier() {
110
+ return randomBytes();
111
+ }
112
+ function generateRandomState() {
113
+ return randomBytes();
114
+ }
115
+ async function calculatePKCECodeChallenge(codeVerifier) {
116
+ if (!validateString(codeVerifier)) {
117
+ throw new TypeError('"codeVerifier" must be a non-empty string');
118
+ }
119
+ return b64u(await crypto.subtle.digest("SHA-256", buf(codeVerifier)));
120
+ }
121
+ var skipSubjectCheck = Symbol();
122
+ var expectNoNonce = Symbol();
123
+ var skipAuthTimeCheck = Symbol();
124
+ var noSignatureCheck = Symbol();
125
+ var skipStateCheck = Symbol();
126
+ var expectNoState = Symbol();
127
+
128
+ // src/lib/cookie.ts
129
+ import Cookies from "js-cookie";
130
+ import { cookies as rscCookies } from "@stackframe/stack-sc";
131
+ function getCookie(name) {
132
+ if (rscCookies) {
133
+ return rscCookies().get(name)?.value ?? null;
134
+ } else {
135
+ return Cookies.get(name) ?? null;
136
+ }
137
+ }
138
+ function setOrDeleteCookie(name, value) {
139
+ if (value === null) {
140
+ deleteCookie(name);
141
+ } else {
142
+ setCookie(name, value);
143
+ }
144
+ }
145
+ function deleteCookie(name) {
146
+ if (rscCookies) {
147
+ rscCookies().delete(name);
148
+ } else {
149
+ Cookies.remove(name);
150
+ }
151
+ }
152
+ function setCookie(name, value) {
153
+ if (rscCookies) {
154
+ rscCookies().set(name, value);
155
+ } else {
156
+ Cookies.set(name, value, { secure: window.location.protocol === "https:" });
157
+ }
158
+ }
159
+ async function saveVerifierAndState() {
160
+ const codeVerifier = generateRandomCodeVerifier();
161
+ const codeChallenge = await calculatePKCECodeChallenge(codeVerifier);
162
+ const state = generateRandomState();
163
+ setCookie("stack-code-verifier", codeVerifier);
164
+ setCookie("stack-state", state);
165
+ return {
166
+ codeChallenge,
167
+ state
168
+ };
169
+ }
170
+ function getVerifierAndState() {
171
+ const codeVerifier = getCookie("stack-code-verifier");
172
+ const state = getCookie("stack-state");
173
+ return {
174
+ codeVerifier,
175
+ state
176
+ };
177
+ }
178
+ export {
179
+ deleteCookie,
180
+ getCookie,
181
+ getVerifierAndState,
182
+ saveVerifierAndState,
183
+ setCookie,
184
+ setOrDeleteCookie
185
+ };
@@ -0,0 +1,29 @@
1
+ // src/lib/hooks.ts
2
+ import { StackContext } from "../providers/stack-provider-client";
3
+ import { useContext } from "react";
4
+ function useUser(options = {}) {
5
+ const stackApp = useStackApp(options);
6
+ if (options.projectIdMustMatch && stackApp.projectId !== options.projectIdMustMatch) {
7
+ throw new Error("Unexpected project ID in useStackApp: " + stackApp.projectId);
8
+ }
9
+ if (options.projectIdMustMatch === "internal") {
10
+ return stackApp.useUser(options);
11
+ } else {
12
+ return stackApp.useUser(options);
13
+ }
14
+ }
15
+ function useStackApp(options = {}) {
16
+ const context = useContext(StackContext);
17
+ if (context === null) {
18
+ throw new Error("useStackApp must be used within a StackProvider");
19
+ }
20
+ const stackApp = context.app;
21
+ if (options.projectIdMustMatch && stackApp.projectId !== options.projectIdMustMatch) {
22
+ throw new Error("Unexpected project ID in useStackApp: " + stackApp.projectId);
23
+ }
24
+ return stackApp;
25
+ }
26
+ export {
27
+ useStackApp,
28
+ useUser
29
+ };