@monocloud/auth-nextjs 0.1.9 → 0.1.11

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 (97) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-C0xms8kb.cjs → _virtual/_rolldown/runtime.cjs} +1 -6
  3. package/dist/client/index.cjs +3 -2
  4. package/dist/client/index.d.mts +3 -203
  5. package/dist/client/index.mjs +2 -1
  6. package/dist/{protect-client-page-BdsnH8gs.cjs → client/protect-client-page.cjs} +9 -112
  7. package/dist/client/protect-client-page.cjs.map +1 -0
  8. package/dist/client/protect-client-page.d.mts +123 -0
  9. package/dist/{protect-client-page-BFVskb3X.mjs → client/protect-client-page.mjs} +5 -91
  10. package/dist/client/protect-client-page.mjs.map +1 -0
  11. package/dist/client/use-auth.cjs +96 -0
  12. package/dist/client/use-auth.cjs.map +1 -0
  13. package/dist/client/use-auth.d.mts +84 -0
  14. package/dist/client/use-auth.mjs +94 -0
  15. package/dist/client/use-auth.mjs.map +1 -0
  16. package/dist/components/client/index.cjs +4 -156
  17. package/dist/components/client/index.d.mts +3 -189
  18. package/dist/components/client/index.mjs +3 -153
  19. package/dist/components/client/protected.cjs +89 -0
  20. package/dist/components/client/protected.cjs.map +1 -0
  21. package/dist/components/client/protected.d.mts +114 -0
  22. package/dist/components/client/protected.mjs +87 -0
  23. package/dist/components/client/protected.mjs.map +1 -0
  24. package/dist/components/client/redirect-to-signin.cjs +77 -0
  25. package/dist/components/client/redirect-to-signin.cjs.map +1 -0
  26. package/dist/components/client/redirect-to-signin.d.mts +78 -0
  27. package/dist/components/client/redirect-to-signin.mjs +76 -0
  28. package/dist/components/client/redirect-to-signin.mjs.map +1 -0
  29. package/dist/components/index.cjs +6 -168
  30. package/dist/components/index.d.mts +4 -188
  31. package/dist/components/index.mjs +4 -164
  32. package/dist/components/signin.cjs +63 -0
  33. package/dist/components/signin.cjs.map +1 -0
  34. package/dist/components/signin.d.mts +72 -0
  35. package/dist/components/signin.mjs +61 -0
  36. package/dist/components/signin.mjs.map +1 -0
  37. package/dist/components/signout.cjs +49 -0
  38. package/dist/components/signout.cjs.map +1 -0
  39. package/dist/components/signout.d.mts +55 -0
  40. package/dist/components/signout.mjs +47 -0
  41. package/dist/components/signout.mjs.map +1 -0
  42. package/dist/components/signup.cjs +67 -0
  43. package/dist/components/signup.cjs.map +1 -0
  44. package/dist/components/signup.d.mts +70 -0
  45. package/dist/components/signup.mjs +65 -0
  46. package/dist/components/signup.mjs.map +1 -0
  47. package/dist/index.cjs +15 -1136
  48. package/dist/index.d.mts +5 -1681
  49. package/dist/index.mjs +4 -1125
  50. package/dist/initialize.cjs +284 -0
  51. package/dist/initialize.cjs.map +1 -0
  52. package/dist/initialize.d.mts +1383 -0
  53. package/dist/initialize.mjs +274 -0
  54. package/dist/initialize.mjs.map +1 -0
  55. package/dist/monocloud-next-client.cjs +600 -0
  56. package/dist/monocloud-next-client.cjs.map +1 -0
  57. package/dist/monocloud-next-client.d.mts +330 -0
  58. package/dist/monocloud-next-client.mjs +599 -0
  59. package/dist/monocloud-next-client.mjs.map +1 -0
  60. package/dist/requests/monocloud-app-router-request.cjs +32 -0
  61. package/dist/requests/monocloud-app-router-request.cjs.map +1 -0
  62. package/dist/requests/monocloud-app-router-request.mjs +31 -0
  63. package/dist/requests/monocloud-app-router-request.mjs.map +1 -0
  64. package/dist/requests/monocloud-cookie-request.cjs +22 -0
  65. package/dist/requests/monocloud-cookie-request.cjs.map +1 -0
  66. package/dist/requests/monocloud-cookie-request.mjs +21 -0
  67. package/dist/requests/monocloud-cookie-request.mjs.map +1 -0
  68. package/dist/requests/monocloud-page-router-request.cjs +37 -0
  69. package/dist/requests/monocloud-page-router-request.cjs.map +1 -0
  70. package/dist/requests/monocloud-page-router-request.mjs +36 -0
  71. package/dist/requests/monocloud-page-router-request.mjs.map +1 -0
  72. package/dist/responses/monocloud-app-router-response.cjs +67 -0
  73. package/dist/responses/monocloud-app-router-response.cjs.map +1 -0
  74. package/dist/responses/monocloud-app-router-response.mjs +66 -0
  75. package/dist/responses/monocloud-app-router-response.mjs.map +1 -0
  76. package/dist/responses/monocloud-cookie-response.cjs +20 -0
  77. package/dist/responses/monocloud-cookie-response.cjs.map +1 -0
  78. package/dist/responses/monocloud-cookie-response.mjs +19 -0
  79. package/dist/responses/monocloud-cookie-response.mjs.map +1 -0
  80. package/dist/responses/monocloud-page-router-response.cjs +54 -0
  81. package/dist/responses/monocloud-page-router-response.cjs.map +1 -0
  82. package/dist/responses/monocloud-page-router-response.mjs +53 -0
  83. package/dist/responses/monocloud-page-router-response.mjs.map +1 -0
  84. package/dist/{types-ClljFIvK.d.mts → types.d.mts} +2 -2
  85. package/dist/utils.cjs +89 -0
  86. package/dist/utils.cjs.map +1 -0
  87. package/dist/utils.mjs +80 -0
  88. package/dist/utils.mjs.map +1 -0
  89. package/package.json +3 -3
  90. package/dist/components/client/index.cjs.map +0 -1
  91. package/dist/components/client/index.mjs.map +0 -1
  92. package/dist/components/index.cjs.map +0 -1
  93. package/dist/components/index.mjs.map +0 -1
  94. package/dist/index.cjs.map +0 -1
  95. package/dist/index.mjs.map +0 -1
  96. package/dist/protect-client-page-BFVskb3X.mjs.map +0 -1
  97. package/dist/protect-client-page-BdsnH8gs.cjs.map +0 -1
@@ -0,0 +1,76 @@
1
+ 'use client';
2
+
3
+ import { redirectToSignIn } from "../../client/protect-client-page.mjs";
4
+ import { useEffect } from "react";
5
+
6
+ //#region src/components/client/redirect-to-signin.tsx
7
+ /**
8
+ * `<RedirectToSignIn>` is a **client-side component** that immediately redirects the user to the MonoCloud sign-in page when it is rendered.
9
+ *
10
+ * It does not render any UI.
11
+ *
12
+ * > This component must be used inside a Client Component (`"use client"`).
13
+ *
14
+ * @example Basic Usage
15
+ *
16
+ * ```tsx title="Basic Usage"
17
+ * "use client";
18
+ *
19
+ * import { useAuth } from "@monocloud/auth-nextjs/client";
20
+ * import { RedirectToSignIn } from "@monocloud/auth-nextjs/components/client";
21
+ *
22
+ * export default function Home() {
23
+ * const { isLoading, isAuthenticated } = useAuth();
24
+ *
25
+ * if (!isLoading && !isAuthenticated) {
26
+ * return <RedirectToSignIn />;
27
+ * }
28
+ *
29
+ * return <>You are signed in</>;
30
+ * }
31
+ * ```
32
+ *
33
+ * @example With Options
34
+ *
35
+ * You can customize the authorization request by passing in props.
36
+ *
37
+ * ```tsx title="With options"
38
+ * "use client";
39
+ *
40
+ * import { useAuth } from "@monocloud/auth-nextjs/client";
41
+ * import { RedirectToSignIn } from "@monocloud/auth-nextjs/components/client";
42
+ *
43
+ * export default function Home() {
44
+ * const { isLoading, isAuthenticated } = useAuth();
45
+ *
46
+ * if (!isLoading && !isAuthenticated) {
47
+ * return (
48
+ * <RedirectToSignIn
49
+ * returnUrl="/dashboard"
50
+ * loginHint="user@example.com"
51
+ * />
52
+ * );
53
+ * }
54
+ *
55
+ * return <>You are signed in</>;
56
+ * }
57
+ * ```
58
+ *
59
+ * @param props - The props for customizing RedirectToSignIn.
60
+ * @returns
61
+ *
62
+ * @category Components
63
+ */
64
+ const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
65
+ useEffect(() => {
66
+ redirectToSignIn({
67
+ returnUrl,
68
+ ...authParams
69
+ });
70
+ }, [authParams, returnUrl]);
71
+ return null;
72
+ };
73
+
74
+ //#endregion
75
+ export { RedirectToSignIn };
76
+ //# sourceMappingURL=redirect-to-signin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect-to-signin.mjs","names":[],"sources":["../../../src/components/client/redirect-to-signin.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { redirectToSignIn } from '../../client/protect-client-page';\nimport { ExtraAuthParams } from '../../types';\n\n/**\n * Props for the `<RedirectToSignIn />` Component\n *\n * @category Types\n */\nexport interface RedirectToSignInProps extends ExtraAuthParams {\n /**\n * The URL to return to after successful authentication. If not provided, the current URL is used.\n */\n returnUrl?: string;\n}\n\n/**\n * `<RedirectToSignIn>` is a **client-side component** that immediately redirects the user to the MonoCloud sign-in page when it is rendered.\n *\n * It does not render any UI.\n *\n * > This component must be used inside a Client Component (`\"use client\"`).\n *\n * @example Basic Usage\n *\n * ```tsx title=\"Basic Usage\"\n * \"use client\";\n *\n * import { useAuth } from \"@monocloud/auth-nextjs/client\";\n * import { RedirectToSignIn } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * const { isLoading, isAuthenticated } = useAuth();\n *\n * if (!isLoading && !isAuthenticated) {\n * return <RedirectToSignIn />;\n * }\n *\n * return <>You are signed in</>;\n * }\n * ```\n *\n * @example With Options\n *\n * You can customize the authorization request by passing in props.\n *\n * ```tsx title=\"With options\"\n * \"use client\";\n *\n * import { useAuth } from \"@monocloud/auth-nextjs/client\";\n * import { RedirectToSignIn } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * const { isLoading, isAuthenticated } = useAuth();\n *\n * if (!isLoading && !isAuthenticated) {\n * return (\n * <RedirectToSignIn\n * returnUrl=\"/dashboard\"\n * loginHint=\"user@example.com\"\n * />\n * );\n * }\n *\n * return <>You are signed in</>;\n * }\n * ```\n *\n * @param props - The props for customizing RedirectToSignIn.\n * @returns\n *\n * @category Components\n */\nexport const RedirectToSignIn = ({\n returnUrl,\n ...authParams\n}: RedirectToSignInProps): null => {\n useEffect(() => {\n redirectToSignIn({ returnUrl, ...authParams });\n }, [authParams, returnUrl]);\n return null;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAa,oBAAoB,EAC/B,WACA,GAAG,iBAC8B;AACjC,iBAAgB;AACd,mBAAiB;GAAE;GAAW,GAAG;GAAY,CAAC;IAC7C,CAAC,YAAY,UAAU,CAAC;AAC3B,QAAO"}
@@ -1,170 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_chunk = require('../chunk-C0xms8kb.cjs');
3
- let react = require("react");
4
- react = require_chunk.__toESM(react);
2
+ const require_signin = require('./signin.cjs');
3
+ const require_signup = require('./signup.cjs');
4
+ const require_signout = require('./signout.cjs');
5
5
 
6
- //#region src/components/signin.tsx
7
- /**
8
- * `<SignIn>` renders a link that initiates the MonoCloud sign-in flow.
9
- *
10
- * It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
11
- *
12
- * @example Basic Usage
13
- *
14
- * ```tsx title="Basic Usage"
15
- * import { SignIn } from "@monocloud/auth-nextjs/components";
16
- *
17
- * export default function Home() {
18
- * return <SignIn>Sign In</SignIn>;
19
- * }
20
- * ```
21
- *
22
- * @example Customize the authorization request
23
- *
24
- * You can customize the authorization request by passing props:
25
- *
26
- * ```tsx title="Customize the authorization request"
27
- * import { SignIn } from "@monocloud/auth-nextjs/components";
28
- *
29
- * export default function Home() {
30
- * return (
31
- * <SignIn loginHint="user@example.com" authenticatorHint="password" returnUrl="/dashboard">
32
- * Sign In
33
- * </SignIn>
34
- * );
35
- * }
36
- * ```
37
- *
38
- * @param props - Properties for the SignIn component.
39
- * @returns An anchor element that links to the sign-in endpoint with the specified parameters.
40
- *
41
- * @category Components
42
- */
43
- const SignIn = ({ children, authenticatorHint, loginHint, prompt, display, uiLocales, scopes, acrValues, resource, maxAge, returnUrl, ...props }) => {
44
- const signInUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signin`;
45
- const query = new URLSearchParams();
46
- if (authenticatorHint) query.set("authenticator_hint", authenticatorHint);
47
- if (prompt) query.set("prompt", prompt);
48
- if (display) query.set("display", display);
49
- if (uiLocales) query.set("ui_locales", uiLocales);
50
- if (scopes) query.set("scope", scopes);
51
- if (acrValues) query.set("acr_values", acrValues.join(" "));
52
- if (resource) query.set("resource", resource);
53
- if (maxAge) query.set("max_age", maxAge.toString());
54
- if (loginHint) query.set("login_hint", loginHint);
55
- if (returnUrl) query.set("return_url", returnUrl);
56
- return /* @__PURE__ */ react.default.createElement("a", {
57
- href: `${signInUrl}${query.size ? `?${query.toString()}` : ""}`,
58
- ...props
59
- }, children);
60
- };
61
-
62
- //#endregion
63
- //#region src/components/signup.tsx
64
- /**
65
- * `<SignUp>` renders a link that initiates the MonoCloud sign-up flow.
66
- *
67
- * It works in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
68
- *
69
- * Internally, it behaves like `<SignIn>` but sets `prompt=create` to start the registration flow.
70
- *
71
- * @example Basic usage
72
- *
73
- * ```tsx title="Basic Usage"
74
- * import { SignUp } from "@monocloud/auth-nextjs/components";
75
- *
76
- * export default function Home() {
77
- * return <SignUp>Sign Up</SignUp>;
78
- * }
79
- * ```
80
- *
81
- * @example Customize the authorization request
82
- *
83
- * You can customize the authorization request by passing in props.
84
- *
85
- * ```tsx title="Customize the authorization request"
86
- * import { SignUp } from "@monocloud/auth-nextjs/components";
87
- *
88
- * export default function Home() {
89
- * return (
90
- * <SignUp
91
- * returnUrl="/dashboard"
92
- * uiLocales="en"
93
- * >
94
- * Sign Up
95
- * </SignUp>
96
- * );
97
- * }
98
- * ```
99
- *
100
- * @param props - Properties for the SignUp component.
101
- * @returns An anchor element that links to the sign-in endpoint with the prompt set to 'create'.
102
- *
103
- * @category Components
104
- */
105
- const SignUp = ({ children, returnUrl, acrValues, display, maxAge, resource, scopes, uiLocales, ...props }) => {
106
- const signInUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signin`;
107
- const query = new URLSearchParams();
108
- query.set("prompt", "create");
109
- if (returnUrl) query.set("return_url", returnUrl);
110
- if (display) query.set("display", display);
111
- if (uiLocales) query.set("ui_locales", uiLocales);
112
- if (scopes) query.set("scope", scopes);
113
- if (acrValues) query.set("acr_values", acrValues.join(" "));
114
- if (resource) query.set("resource", resource);
115
- if (maxAge) query.set("max_age", maxAge.toString());
116
- if (returnUrl) query.set("return_url", returnUrl);
117
- return /* @__PURE__ */ react.default.createElement("a", {
118
- href: `${signInUrl}?${query.toString()}`,
119
- ...props
120
- }, children);
121
- };
122
-
123
- //#endregion
124
- //#region src/components/signout.tsx
125
- /**
126
- * `<SignOut>` renders a link that initiates the MonoCloud sign-out flow.
127
- *
128
- * It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
129
- *
130
- * @example Basic usage
131
- *
132
- * ```tsx title="Basic Usage"
133
- * import { SignOut } from "@monocloud/auth-nextjs/components";
134
- *
135
- * export default function Home() {
136
- * return <SignOut>Sign Out</SignOut>;
137
- * }
138
- * ```
139
- *
140
- * @example Customize the sign-out request
141
- *
142
- * ```tsx title="Customize the sign-out request"
143
- * import { SignOut } from "@monocloud/auth-nextjs/components";
144
- *
145
- * export default function Home() {
146
- * return <SignOut federated postLogoutUrl="/goodbye">Sign Out</SignOut>;
147
- * }
148
- * ```
149
- *
150
- * @param props - Properties for the SignOut component.
151
- * @returns An anchor element that links to the sign-out endpoint.
152
- *
153
- * @category Components
154
- */
155
- const SignOut = ({ children, postLogoutUrl, federated, ...props }) => {
156
- const signOutUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNOUT_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signout`;
157
- const query = new URLSearchParams();
158
- if (postLogoutUrl) query.set("post_logout_url", postLogoutUrl);
159
- if (typeof federated === "boolean") query.set("federated", federated.toString());
160
- return /* @__PURE__ */ react.default.createElement("a", {
161
- href: `${signOutUrl}${query.size ? `?${query.toString()}` : ""}`,
162
- ...props
163
- }, children);
164
- };
165
-
166
- //#endregion
167
- exports.SignIn = SignIn;
168
- exports.SignOut = SignOut;
169
- exports.SignUp = SignUp;
170
- //# sourceMappingURL=index.cjs.map
6
+ exports.SignIn = require_signin.SignIn;
7
+ exports.SignOut = require_signout.SignOut;
8
+ exports.SignUp = require_signup.SignUp;
@@ -1,188 +1,4 @@
1
- import { c as ExtraAuthParams } from "../types-ClljFIvK.mjs";
2
- import React from "react";
3
-
4
- //#region src/components/signin.d.ts
5
- /**
6
- * Props for the `<SignIn />` component.
7
- *
8
- * @category Types
9
- */
10
- interface SignInProps extends ExtraAuthParams {
11
- /**
12
- * Content rendered inside the link (for example, button text).
13
- */
14
- children: React.ReactNode;
15
- /**
16
- * URL to redirect to after successful sign-in.
17
- */
18
- returnUrl?: string;
19
- }
20
- /**
21
- * `<SignIn>` renders a link that initiates the MonoCloud sign-in flow.
22
- *
23
- * It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
24
- *
25
- * @example Basic Usage
26
- *
27
- * ```tsx title="Basic Usage"
28
- * import { SignIn } from "@monocloud/auth-nextjs/components";
29
- *
30
- * export default function Home() {
31
- * return <SignIn>Sign In</SignIn>;
32
- * }
33
- * ```
34
- *
35
- * @example Customize the authorization request
36
- *
37
- * You can customize the authorization request by passing props:
38
- *
39
- * ```tsx title="Customize the authorization request"
40
- * import { SignIn } from "@monocloud/auth-nextjs/components";
41
- *
42
- * export default function Home() {
43
- * return (
44
- * <SignIn loginHint="user@example.com" authenticatorHint="password" returnUrl="/dashboard">
45
- * Sign In
46
- * </SignIn>
47
- * );
48
- * }
49
- * ```
50
- *
51
- * @param props - Properties for the SignIn component.
52
- * @returns An anchor element that links to the sign-in endpoint with the specified parameters.
53
- *
54
- * @category Components
55
- */
56
- declare const SignIn: ({
57
- children,
58
- authenticatorHint,
59
- loginHint,
60
- prompt,
61
- display,
62
- uiLocales,
63
- scopes,
64
- acrValues,
65
- resource,
66
- maxAge,
67
- returnUrl,
68
- ...props
69
- }: SignInProps & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "resource">) => React.ReactNode;
70
- //#endregion
71
- //#region src/components/signup.d.ts
72
- /**
73
- * Props for the `<SignUp />` component.
74
- *
75
- * @category Types
76
- */
77
- interface SignUpProps extends Omit<ExtraAuthParams, 'authenticatorHint' | 'loginHint' | 'prompt'> {
78
- /**
79
- * URL to redirect to after successful sign-up.
80
- */
81
- returnUrl?: string;
82
- }
83
- /**
84
- * `<SignUp>` renders a link that initiates the MonoCloud sign-up flow.
85
- *
86
- * It works in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
87
- *
88
- * Internally, it behaves like `<SignIn>` but sets `prompt=create` to start the registration flow.
89
- *
90
- * @example Basic usage
91
- *
92
- * ```tsx title="Basic Usage"
93
- * import { SignUp } from "@monocloud/auth-nextjs/components";
94
- *
95
- * export default function Home() {
96
- * return <SignUp>Sign Up</SignUp>;
97
- * }
98
- * ```
99
- *
100
- * @example Customize the authorization request
101
- *
102
- * You can customize the authorization request by passing in props.
103
- *
104
- * ```tsx title="Customize the authorization request"
105
- * import { SignUp } from "@monocloud/auth-nextjs/components";
106
- *
107
- * export default function Home() {
108
- * return (
109
- * <SignUp
110
- * returnUrl="/dashboard"
111
- * uiLocales="en"
112
- * >
113
- * Sign Up
114
- * </SignUp>
115
- * );
116
- * }
117
- * ```
118
- *
119
- * @param props - Properties for the SignUp component.
120
- * @returns An anchor element that links to the sign-in endpoint with the prompt set to 'create'.
121
- *
122
- * @category Components
123
- */
124
- declare const SignUp: ({
125
- children,
126
- returnUrl,
127
- acrValues,
128
- display,
129
- maxAge,
130
- resource,
131
- scopes,
132
- uiLocales,
133
- ...props
134
- }: SignUpProps & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "resource">) => React.ReactNode;
135
- //#endregion
136
- //#region src/components/signout.d.ts
137
- /**
138
- * Props for the `<SignOut />` component.
139
- *
140
- * @category Types
141
- */
142
- interface SignOutProps {
143
- /** Content rendered inside the link (for example, button text). */
144
- children: React.ReactNode;
145
- /** URL to redirect the user to after they have been signed out. */
146
- postLogoutUrl?: string;
147
- /** If `true`, also signs the user out of the MonoCloud server session, ensuring the user is fully logged out of MonoCloud and not just your application. */
148
- federated?: boolean;
149
- }
150
- /**
151
- * `<SignOut>` renders a link that initiates the MonoCloud sign-out flow.
152
- *
153
- * It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
154
- *
155
- * @example Basic usage
156
- *
157
- * ```tsx title="Basic Usage"
158
- * import { SignOut } from "@monocloud/auth-nextjs/components";
159
- *
160
- * export default function Home() {
161
- * return <SignOut>Sign Out</SignOut>;
162
- * }
163
- * ```
164
- *
165
- * @example Customize the sign-out request
166
- *
167
- * ```tsx title="Customize the sign-out request"
168
- * import { SignOut } from "@monocloud/auth-nextjs/components";
169
- *
170
- * export default function Home() {
171
- * return <SignOut federated postLogoutUrl="/goodbye">Sign Out</SignOut>;
172
- * }
173
- * ```
174
- *
175
- * @param props - Properties for the SignOut component.
176
- * @returns An anchor element that links to the sign-out endpoint.
177
- *
178
- * @category Components
179
- */
180
- declare const SignOut: ({
181
- children,
182
- postLogoutUrl,
183
- federated,
184
- ...props
185
- }: SignOutProps & React.AnchorHTMLAttributes<HTMLAnchorElement>) => React.ReactNode;
186
- //#endregion
187
- export { SignIn, type SignInProps, SignOut, type SignOutProps, SignUp, type SignUpProps };
188
- //# sourceMappingURL=index.d.mts.map
1
+ import { SignIn, SignInProps } from "./signin.mjs";
2
+ import { SignUp, SignUpProps } from "./signup.mjs";
3
+ import { SignOut, SignOutProps } from "./signout.mjs";
4
+ export { SignIn, type SignInProps, SignOut, type SignOutProps, SignUp, type SignUpProps };
@@ -1,165 +1,5 @@
1
- import React from "react";
1
+ import { SignIn } from "./signin.mjs";
2
+ import { SignUp } from "./signup.mjs";
3
+ import { SignOut } from "./signout.mjs";
2
4
 
3
- //#region src/components/signin.tsx
4
- /**
5
- * `<SignIn>` renders a link that initiates the MonoCloud sign-in flow.
6
- *
7
- * It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
8
- *
9
- * @example Basic Usage
10
- *
11
- * ```tsx title="Basic Usage"
12
- * import { SignIn } from "@monocloud/auth-nextjs/components";
13
- *
14
- * export default function Home() {
15
- * return <SignIn>Sign In</SignIn>;
16
- * }
17
- * ```
18
- *
19
- * @example Customize the authorization request
20
- *
21
- * You can customize the authorization request by passing props:
22
- *
23
- * ```tsx title="Customize the authorization request"
24
- * import { SignIn } from "@monocloud/auth-nextjs/components";
25
- *
26
- * export default function Home() {
27
- * return (
28
- * <SignIn loginHint="user@example.com" authenticatorHint="password" returnUrl="/dashboard">
29
- * Sign In
30
- * </SignIn>
31
- * );
32
- * }
33
- * ```
34
- *
35
- * @param props - Properties for the SignIn component.
36
- * @returns An anchor element that links to the sign-in endpoint with the specified parameters.
37
- *
38
- * @category Components
39
- */
40
- const SignIn = ({ children, authenticatorHint, loginHint, prompt, display, uiLocales, scopes, acrValues, resource, maxAge, returnUrl, ...props }) => {
41
- const signInUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signin`;
42
- const query = new URLSearchParams();
43
- if (authenticatorHint) query.set("authenticator_hint", authenticatorHint);
44
- if (prompt) query.set("prompt", prompt);
45
- if (display) query.set("display", display);
46
- if (uiLocales) query.set("ui_locales", uiLocales);
47
- if (scopes) query.set("scope", scopes);
48
- if (acrValues) query.set("acr_values", acrValues.join(" "));
49
- if (resource) query.set("resource", resource);
50
- if (maxAge) query.set("max_age", maxAge.toString());
51
- if (loginHint) query.set("login_hint", loginHint);
52
- if (returnUrl) query.set("return_url", returnUrl);
53
- return /* @__PURE__ */ React.createElement("a", {
54
- href: `${signInUrl}${query.size ? `?${query.toString()}` : ""}`,
55
- ...props
56
- }, children);
57
- };
58
-
59
- //#endregion
60
- //#region src/components/signup.tsx
61
- /**
62
- * `<SignUp>` renders a link that initiates the MonoCloud sign-up flow.
63
- *
64
- * It works in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
65
- *
66
- * Internally, it behaves like `<SignIn>` but sets `prompt=create` to start the registration flow.
67
- *
68
- * @example Basic usage
69
- *
70
- * ```tsx title="Basic Usage"
71
- * import { SignUp } from "@monocloud/auth-nextjs/components";
72
- *
73
- * export default function Home() {
74
- * return <SignUp>Sign Up</SignUp>;
75
- * }
76
- * ```
77
- *
78
- * @example Customize the authorization request
79
- *
80
- * You can customize the authorization request by passing in props.
81
- *
82
- * ```tsx title="Customize the authorization request"
83
- * import { SignUp } from "@monocloud/auth-nextjs/components";
84
- *
85
- * export default function Home() {
86
- * return (
87
- * <SignUp
88
- * returnUrl="/dashboard"
89
- * uiLocales="en"
90
- * >
91
- * Sign Up
92
- * </SignUp>
93
- * );
94
- * }
95
- * ```
96
- *
97
- * @param props - Properties for the SignUp component.
98
- * @returns An anchor element that links to the sign-in endpoint with the prompt set to 'create'.
99
- *
100
- * @category Components
101
- */
102
- const SignUp = ({ children, returnUrl, acrValues, display, maxAge, resource, scopes, uiLocales, ...props }) => {
103
- const signInUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signin`;
104
- const query = new URLSearchParams();
105
- query.set("prompt", "create");
106
- if (returnUrl) query.set("return_url", returnUrl);
107
- if (display) query.set("display", display);
108
- if (uiLocales) query.set("ui_locales", uiLocales);
109
- if (scopes) query.set("scope", scopes);
110
- if (acrValues) query.set("acr_values", acrValues.join(" "));
111
- if (resource) query.set("resource", resource);
112
- if (maxAge) query.set("max_age", maxAge.toString());
113
- if (returnUrl) query.set("return_url", returnUrl);
114
- return /* @__PURE__ */ React.createElement("a", {
115
- href: `${signInUrl}?${query.toString()}`,
116
- ...props
117
- }, children);
118
- };
119
-
120
- //#endregion
121
- //#region src/components/signout.tsx
122
- /**
123
- * `<SignOut>` renders a link that initiates the MonoCloud sign-out flow.
124
- *
125
- * It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
126
- *
127
- * @example Basic usage
128
- *
129
- * ```tsx title="Basic Usage"
130
- * import { SignOut } from "@monocloud/auth-nextjs/components";
131
- *
132
- * export default function Home() {
133
- * return <SignOut>Sign Out</SignOut>;
134
- * }
135
- * ```
136
- *
137
- * @example Customize the sign-out request
138
- *
139
- * ```tsx title="Customize the sign-out request"
140
- * import { SignOut } from "@monocloud/auth-nextjs/components";
141
- *
142
- * export default function Home() {
143
- * return <SignOut federated postLogoutUrl="/goodbye">Sign Out</SignOut>;
144
- * }
145
- * ```
146
- *
147
- * @param props - Properties for the SignOut component.
148
- * @returns An anchor element that links to the sign-out endpoint.
149
- *
150
- * @category Components
151
- */
152
- const SignOut = ({ children, postLogoutUrl, federated, ...props }) => {
153
- const signOutUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNOUT_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signout`;
154
- const query = new URLSearchParams();
155
- if (postLogoutUrl) query.set("post_logout_url", postLogoutUrl);
156
- if (typeof federated === "boolean") query.set("federated", federated.toString());
157
- return /* @__PURE__ */ React.createElement("a", {
158
- href: `${signOutUrl}${query.size ? `?${query.toString()}` : ""}`,
159
- ...props
160
- }, children);
161
- };
162
-
163
- //#endregion
164
- export { SignIn, SignOut, SignUp };
165
- //# sourceMappingURL=index.mjs.map
5
+ export { SignIn, SignOut, SignUp };
@@ -0,0 +1,63 @@
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ let react = require("react");
3
+ react = require_runtime.__toESM(react);
4
+
5
+ //#region src/components/signin.tsx
6
+ /**
7
+ * `<SignIn>` renders a link that initiates the MonoCloud sign-in flow.
8
+ *
9
+ * It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
10
+ *
11
+ * @example Basic Usage
12
+ *
13
+ * ```tsx title="Basic Usage"
14
+ * import { SignIn } from "@monocloud/auth-nextjs/components";
15
+ *
16
+ * export default function Home() {
17
+ * return <SignIn>Sign In</SignIn>;
18
+ * }
19
+ * ```
20
+ *
21
+ * @example Customize the authorization request
22
+ *
23
+ * You can customize the authorization request by passing props:
24
+ *
25
+ * ```tsx title="Customize the authorization request"
26
+ * import { SignIn } from "@monocloud/auth-nextjs/components";
27
+ *
28
+ * export default function Home() {
29
+ * return (
30
+ * <SignIn loginHint="user@example.com" authenticatorHint="password" returnUrl="/dashboard">
31
+ * Sign In
32
+ * </SignIn>
33
+ * );
34
+ * }
35
+ * ```
36
+ *
37
+ * @param props - Properties for the SignIn component.
38
+ * @returns An anchor element that links to the sign-in endpoint with the specified parameters.
39
+ *
40
+ * @category Components
41
+ */
42
+ const SignIn = ({ children, authenticatorHint, loginHint, prompt, display, uiLocales, scopes, acrValues, resource, maxAge, returnUrl, ...props }) => {
43
+ const signInUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signin`;
44
+ const query = new URLSearchParams();
45
+ if (authenticatorHint) query.set("authenticator_hint", authenticatorHint);
46
+ if (prompt) query.set("prompt", prompt);
47
+ if (display) query.set("display", display);
48
+ if (uiLocales) query.set("ui_locales", uiLocales);
49
+ if (scopes) query.set("scope", scopes);
50
+ if (acrValues) query.set("acr_values", acrValues.join(" "));
51
+ if (resource) query.set("resource", resource);
52
+ if (maxAge) query.set("max_age", maxAge.toString());
53
+ if (loginHint) query.set("login_hint", loginHint);
54
+ if (returnUrl) query.set("return_url", returnUrl);
55
+ return /* @__PURE__ */ react.default.createElement("a", {
56
+ href: `${signInUrl}${query.size ? `?${query.toString()}` : ""}`,
57
+ ...props
58
+ }, children);
59
+ };
60
+
61
+ //#endregion
62
+ exports.SignIn = SignIn;
63
+ //# sourceMappingURL=signin.cjs.map