@monocloud/auth-nextjs 0.1.6 → 0.1.8
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.
- package/README.md +1 -1
- package/dist/client/index.cjs +3 -3
- package/dist/client/index.d.mts +68 -112
- package/dist/client/index.mjs +2 -2
- package/dist/components/client/index.cjs +40 -84
- package/dist/components/client/index.cjs.map +1 -1
- package/dist/components/client/index.d.mts +55 -90
- package/dist/components/client/index.mjs +38 -82
- package/dist/components/client/index.mjs.map +1 -1
- package/dist/components/index.cjs +44 -41
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.mts +68 -45
- package/dist/components/index.mjs +44 -41
- package/dist/components/index.mjs.map +1 -1
- package/dist/index.cjs +384 -365
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1545 -1833
- package/dist/index.mjs +380 -372
- package/dist/index.mjs.map +1 -1
- package/dist/{protect-K9srvUkq.mjs → protect-client-page-BFVskb3X.mjs} +58 -106
- package/dist/protect-client-page-BFVskb3X.mjs.map +1 -0
- package/dist/{protect-BCIji2i7.cjs → protect-client-page-BdsnH8gs.cjs} +59 -107
- package/dist/protect-client-page-BdsnH8gs.cjs.map +1 -0
- package/dist/types-ClljFIvK.d.mts +543 -0
- package/package.json +3 -2
- package/dist/protect-BCIji2i7.cjs.map +0 -1
- package/dist/protect-K9srvUkq.mjs.map +0 -1
- package/dist/types-Cx32VRoI.d.mts +0 -409
|
@@ -5,17 +5,13 @@ react = require_chunk.__toESM(react);
|
|
|
5
5
|
|
|
6
6
|
//#region src/components/signin.tsx
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* `<SignIn>` renders a link that initiates the MonoCloud sign-in flow.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @returns An anchor element that links to the sign-in endpoint with the specified parameters.
|
|
13
|
-
*
|
|
14
|
-
* @example App Router and Pages Router
|
|
10
|
+
* It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
15
11
|
*
|
|
16
|
-
*
|
|
12
|
+
* @example Basic Usage
|
|
17
13
|
*
|
|
18
|
-
* ```tsx
|
|
14
|
+
* ```tsx title="Basic Usage"
|
|
19
15
|
* import { SignIn } from "@monocloud/auth-nextjs/components";
|
|
20
16
|
*
|
|
21
17
|
* export default function Home() {
|
|
@@ -25,21 +21,24 @@ react = require_chunk.__toESM(react);
|
|
|
25
21
|
*
|
|
26
22
|
* @example Customize the authorization request
|
|
27
23
|
*
|
|
28
|
-
* You can customize the authorization request by passing
|
|
24
|
+
* You can customize the authorization request by passing props:
|
|
29
25
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* ```tsx
|
|
26
|
+
* ```tsx title="Customize the authorization request"
|
|
33
27
|
* import { SignIn } from "@monocloud/auth-nextjs/components";
|
|
34
28
|
*
|
|
35
29
|
* export default function Home() {
|
|
36
30
|
* return (
|
|
37
|
-
* <SignIn loginHint="
|
|
31
|
+
* <SignIn loginHint="user@example.com" authenticatorHint="password" returnUrl="/dashboard">
|
|
38
32
|
* Sign In
|
|
39
33
|
* </SignIn>
|
|
40
34
|
* );
|
|
41
35
|
* }
|
|
42
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
|
|
43
42
|
*/
|
|
44
43
|
const SignIn = ({ children, authenticatorHint, loginHint, prompt, display, uiLocales, scopes, acrValues, resource, maxAge, returnUrl, ...props }) => {
|
|
45
44
|
const signInUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signin`;
|
|
@@ -63,18 +62,15 @@ const SignIn = ({ children, authenticatorHint, loginHint, prompt, display, uiLoc
|
|
|
63
62
|
//#endregion
|
|
64
63
|
//#region src/components/signup.tsx
|
|
65
64
|
/**
|
|
66
|
-
*
|
|
67
|
-
* * It functions similarly to the SignIn component but explicitly sets the `prompt` parameter to `create`.
|
|
68
|
-
*
|
|
69
|
-
* @param props - Properties for the SignUp component.
|
|
65
|
+
* `<SignUp>` renders a link that initiates the MonoCloud sign-up flow.
|
|
70
66
|
*
|
|
71
|
-
*
|
|
67
|
+
* It works in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
72
68
|
*
|
|
73
|
-
*
|
|
69
|
+
* Internally, it behaves like `<SignIn>` but sets `prompt=create` to start the registration flow.
|
|
74
70
|
*
|
|
75
|
-
*
|
|
71
|
+
* @example Basic usage
|
|
76
72
|
*
|
|
77
|
-
* ```tsx
|
|
73
|
+
* ```tsx title="Basic Usage"
|
|
78
74
|
* import { SignUp } from "@monocloud/auth-nextjs/components";
|
|
79
75
|
*
|
|
80
76
|
* export default function Home() {
|
|
@@ -84,17 +80,27 @@ const SignIn = ({ children, authenticatorHint, loginHint, prompt, display, uiLoc
|
|
|
84
80
|
*
|
|
85
81
|
* @example Customize the authorization request
|
|
86
82
|
*
|
|
87
|
-
* You can customize the authorization request by passing in props.
|
|
83
|
+
* You can customize the authorization request by passing in props.
|
|
88
84
|
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* ```tsx
|
|
85
|
+
* ```tsx title="Customize the authorization request"
|
|
92
86
|
* import { SignUp } from "@monocloud/auth-nextjs/components";
|
|
93
87
|
*
|
|
94
88
|
* export default function Home() {
|
|
95
|
-
* return
|
|
89
|
+
* return (
|
|
90
|
+
* <SignUp
|
|
91
|
+
* returnUrl="/dashboard"
|
|
92
|
+
* uiLocales="en"
|
|
93
|
+
* >
|
|
94
|
+
* Sign Up
|
|
95
|
+
* </SignUp>
|
|
96
|
+
* );
|
|
96
97
|
* }
|
|
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
|
|
98
104
|
*/
|
|
99
105
|
const SignUp = ({ children, returnUrl, acrValues, display, maxAge, resource, scopes, uiLocales, ...props }) => {
|
|
100
106
|
const signInUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signin`;
|
|
@@ -117,17 +123,13 @@ const SignUp = ({ children, returnUrl, acrValues, display, maxAge, resource, sco
|
|
|
117
123
|
//#endregion
|
|
118
124
|
//#region src/components/signout.tsx
|
|
119
125
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* @param props - Properties for the SignOut component.
|
|
123
|
-
*
|
|
124
|
-
* @returns An anchor element that links to the sign-out endpoint.
|
|
126
|
+
* `<SignOut>` renders a link that initiates the MonoCloud sign-out flow.
|
|
125
127
|
*
|
|
126
|
-
*
|
|
128
|
+
* It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
127
129
|
*
|
|
128
|
-
*
|
|
130
|
+
* @example Basic usage
|
|
129
131
|
*
|
|
130
|
-
* ```tsx
|
|
132
|
+
* ```tsx title="Basic Usage"
|
|
131
133
|
* import { SignOut } from "@monocloud/auth-nextjs/components";
|
|
132
134
|
*
|
|
133
135
|
* export default function Home() {
|
|
@@ -135,19 +137,20 @@ const SignUp = ({ children, returnUrl, acrValues, display, maxAge, resource, sco
|
|
|
135
137
|
* }
|
|
136
138
|
* ```
|
|
137
139
|
*
|
|
138
|
-
* @example Customize the request
|
|
139
|
-
*
|
|
140
|
-
* You can customize the request by passing in props. See {@link SignOutProps}.
|
|
140
|
+
* @example Customize the sign-out request
|
|
141
141
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* ```tsx
|
|
142
|
+
* ```tsx title="Customize the sign-out request"
|
|
145
143
|
* import { SignOut } from "@monocloud/auth-nextjs/components";
|
|
146
144
|
*
|
|
147
145
|
* export default function Home() {
|
|
148
|
-
* return <SignOut federated=
|
|
146
|
+
* return <SignOut federated postLogoutUrl="/goodbye">Sign Out</SignOut>;
|
|
149
147
|
* }
|
|
150
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
|
|
151
154
|
*/
|
|
152
155
|
const SignOut = ({ children, postLogoutUrl, federated, ...props }) => {
|
|
153
156
|
const signOutUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNOUT_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signout`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/components/signin.tsx","../../src/components/signup.tsx","../../src/components/signout.tsx"],"sourcesContent":["import React from 'react';\nimport { ExtraAuthParams } from '../types';\n\nexport interface SignInProps extends ExtraAuthParams {\n children: React.ReactNode;\n /**\n * URL to redirect to after
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/components/signin.tsx","../../src/components/signup.tsx","../../src/components/signout.tsx"],"sourcesContent":["import React from 'react';\nimport { ExtraAuthParams } from '../types';\n\n/**\n * Props for the `<SignIn />` component.\n *\n * @category Types\n */\nexport interface SignInProps extends ExtraAuthParams {\n /**\n * Content rendered inside the link (for example, button text).\n */\n children: React.ReactNode;\n\n /**\n * URL to redirect to after successful sign-in.\n */\n returnUrl?: string;\n}\n\n/**\n * `<SignIn>` renders a link that initiates the MonoCloud sign-in flow.\n *\n * It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.\n *\n * @example Basic Usage\n *\n * ```tsx title=\"Basic Usage\"\n * import { SignIn } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignIn>Sign In</SignIn>;\n * }\n * ```\n *\n * @example Customize the authorization request\n *\n * You can customize the authorization request by passing props:\n *\n * ```tsx title=\"Customize the authorization request\"\n * import { SignIn } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return (\n * <SignIn loginHint=\"user@example.com\" authenticatorHint=\"password\" returnUrl=\"/dashboard\">\n * Sign In\n * </SignIn>\n * );\n * }\n * ```\n *\n * @param props - Properties for the SignIn component.\n * @returns An anchor element that links to the sign-in endpoint with the specified parameters.\n *\n * @category Components\n */\nexport const SignIn = ({\n children,\n authenticatorHint,\n loginHint,\n prompt,\n display,\n uiLocales,\n scopes,\n acrValues,\n resource,\n maxAge,\n returnUrl,\n ...props\n}: SignInProps &\n Omit<\n React.AnchorHTMLAttributes<HTMLAnchorElement>,\n 'resource'\n >): React.ReactNode => {\n const signInUrl =\n process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ??\n // eslint-disable-next-line no-underscore-dangle\n `${process.env.__NEXT_ROUTER_BASEPATH ?? ''}/api/auth/signin`;\n\n const query = new URLSearchParams();\n\n if (authenticatorHint) {\n query.set('authenticator_hint', authenticatorHint);\n }\n\n if (prompt) {\n query.set('prompt', prompt);\n }\n\n if (display) {\n query.set('display', display);\n }\n\n if (uiLocales) {\n query.set('ui_locales', uiLocales);\n }\n\n if (scopes) {\n query.set('scope', scopes);\n }\n\n if (acrValues) {\n query.set('acr_values', acrValues.join(' '));\n }\n\n if (resource) {\n query.set('resource', resource);\n }\n\n if (maxAge) {\n query.set('max_age', maxAge.toString());\n }\n\n if (loginHint) {\n query.set('login_hint', loginHint);\n }\n\n if (returnUrl) {\n query.set('return_url', returnUrl);\n }\n\n return (\n <a\n href={`${signInUrl}${query.size ? `?${query.toString()}` : ''}`}\n {...props}\n >\n {children}\n </a>\n );\n};\n","import React from 'react';\nimport { ExtraAuthParams } from '../types';\n\n/**\n * Props for the `<SignUp />` component.\n *\n * @category Types\n */\nexport interface SignUpProps extends Omit<\n ExtraAuthParams,\n 'authenticatorHint' | 'loginHint' | 'prompt'\n> {\n /**\n * URL to redirect to after successful sign-up.\n */\n returnUrl?: string;\n}\n\n/**\n * `<SignUp>` renders a link that initiates the MonoCloud sign-up flow.\n *\n * It works in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.\n *\n * Internally, it behaves like `<SignIn>` but sets `prompt=create` to start the registration flow.\n *\n * @example Basic usage\n *\n * ```tsx title=\"Basic Usage\"\n * import { SignUp } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignUp>Sign Up</SignUp>;\n * }\n * ```\n *\n * @example Customize the authorization request\n *\n * You can customize the authorization request by passing in props.\n *\n * ```tsx title=\"Customize the authorization request\"\n * import { SignUp } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return (\n * <SignUp\n * returnUrl=\"/dashboard\"\n * uiLocales=\"en\"\n * >\n * Sign Up\n * </SignUp>\n * );\n * }\n * ```\n *\n * @param props - Properties for the SignUp component.\n * @returns An anchor element that links to the sign-in endpoint with the prompt set to 'create'.\n *\n * @category Components\n */\nexport const SignUp = ({\n children,\n returnUrl,\n acrValues,\n display,\n maxAge,\n resource,\n scopes,\n uiLocales,\n ...props\n}: SignUpProps &\n Omit<\n React.AnchorHTMLAttributes<HTMLAnchorElement>,\n 'resource'\n >): React.ReactNode => {\n const signInUrl =\n process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ??\n // eslint-disable-next-line no-underscore-dangle\n `${process.env.__NEXT_ROUTER_BASEPATH ?? ''}/api/auth/signin`;\n\n const query = new URLSearchParams();\n\n query.set('prompt', 'create');\n\n if (returnUrl) {\n query.set('return_url', returnUrl);\n }\n\n if (display) {\n query.set('display', display);\n }\n\n if (uiLocales) {\n query.set('ui_locales', uiLocales);\n }\n\n if (scopes) {\n query.set('scope', scopes);\n }\n\n if (acrValues) {\n query.set('acr_values', acrValues.join(' '));\n }\n\n if (resource) {\n query.set('resource', resource);\n }\n\n if (maxAge) {\n query.set('max_age', maxAge.toString());\n }\n\n if (returnUrl) {\n query.set('return_url', returnUrl);\n }\n\n return (\n <a href={`${signInUrl}?${query.toString()}`} {...props}>\n {children}\n </a>\n );\n};\n","import React from 'react';\n\n/**\n * Props for the `<SignOut />` component.\n *\n * @category Types\n */\nexport interface SignOutProps {\n /** Content rendered inside the link (for example, button text). */\n children: React.ReactNode;\n\n /** URL to redirect the user to after they have been signed out. */\n postLogoutUrl?: string;\n\n /** 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. */\n federated?: boolean;\n}\n\n/**\n * `<SignOut>` renders a link that initiates the MonoCloud sign-out flow.\n *\n * It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.\n *\n * @example Basic usage\n *\n * ```tsx title=\"Basic Usage\"\n * import { SignOut } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignOut>Sign Out</SignOut>;\n * }\n * ```\n *\n * @example Customize the sign-out request\n *\n * ```tsx title=\"Customize the sign-out request\"\n * import { SignOut } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignOut federated postLogoutUrl=\"/goodbye\">Sign Out</SignOut>;\n * }\n * ```\n *\n * @param props - Properties for the SignOut component.\n * @returns An anchor element that links to the sign-out endpoint.\n *\n * @category Components\n */\nexport const SignOut = ({\n children,\n postLogoutUrl,\n federated,\n ...props\n}: SignOutProps &\n React.AnchorHTMLAttributes<HTMLAnchorElement>): React.ReactNode => {\n const signOutUrl =\n process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNOUT_URL ??\n // eslint-disable-next-line no-underscore-dangle\n `${process.env.__NEXT_ROUTER_BASEPATH ?? ''}/api/auth/signout`;\n\n const query = new URLSearchParams();\n\n if (postLogoutUrl) {\n query.set('post_logout_url', postLogoutUrl);\n }\n\n if (typeof federated === 'boolean') {\n query.set('federated', federated.toString());\n }\n\n return (\n <a\n href={`${signOutUrl}${query.size ? `?${query.toString()}` : ''}`}\n {...props}\n >\n {children}\n </a>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAa,UAAU,EACrB,UACA,mBACA,WACA,QACA,SACA,WACA,QACA,WACA,UACA,QACA,WACA,GAAG,YAKoB;CACvB,MAAM,YACJ,QAAQ,IAAI,yCAEZ,GAAG,QAAQ,IAAI,0BAA0B,GAAG;CAE9C,MAAM,QAAQ,IAAI,iBAAiB;AAEnC,KAAI,kBACF,OAAM,IAAI,sBAAsB,kBAAkB;AAGpD,KAAI,OACF,OAAM,IAAI,UAAU,OAAO;AAG7B,KAAI,QACF,OAAM,IAAI,WAAW,QAAQ;AAG/B,KAAI,UACF,OAAM,IAAI,cAAc,UAAU;AAGpC,KAAI,OACF,OAAM,IAAI,SAAS,OAAO;AAG5B,KAAI,UACF,OAAM,IAAI,cAAc,UAAU,KAAK,IAAI,CAAC;AAG9C,KAAI,SACF,OAAM,IAAI,YAAY,SAAS;AAGjC,KAAI,OACF,OAAM,IAAI,WAAW,OAAO,UAAU,CAAC;AAGzC,KAAI,UACF,OAAM,IAAI,cAAc,UAAU;AAGpC,KAAI,UACF,OAAM,IAAI,cAAc,UAAU;AAGpC,QACE,4CAAC;EACC,MAAM,GAAG,YAAY,MAAM,OAAO,IAAI,MAAM,UAAU,KAAK;EAC3D,GAAI;IAEH,SACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACpER,MAAa,UAAU,EACrB,UACA,WACA,WACA,SACA,QACA,UACA,QACA,WACA,GAAG,YAKoB;CACvB,MAAM,YACJ,QAAQ,IAAI,yCAEZ,GAAG,QAAQ,IAAI,0BAA0B,GAAG;CAE9C,MAAM,QAAQ,IAAI,iBAAiB;AAEnC,OAAM,IAAI,UAAU,SAAS;AAE7B,KAAI,UACF,OAAM,IAAI,cAAc,UAAU;AAGpC,KAAI,QACF,OAAM,IAAI,WAAW,QAAQ;AAG/B,KAAI,UACF,OAAM,IAAI,cAAc,UAAU;AAGpC,KAAI,OACF,OAAM,IAAI,SAAS,OAAO;AAG5B,KAAI,UACF,OAAM,IAAI,cAAc,UAAU,KAAK,IAAI,CAAC;AAG9C,KAAI,SACF,OAAM,IAAI,YAAY,SAAS;AAGjC,KAAI,OACF,OAAM,IAAI,WAAW,OAAO,UAAU,CAAC;AAGzC,KAAI,UACF,OAAM,IAAI,cAAc,UAAU;AAGpC,QACE,4CAAC;EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,UAAU;EAAI,GAAI;IAC9C,SACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACtER,MAAa,WAAW,EACtB,UACA,eACA,WACA,GAAG,YAEgE;CACnE,MAAM,aACJ,QAAQ,IAAI,0CAEZ,GAAG,QAAQ,IAAI,0BAA0B,GAAG;CAE9C,MAAM,QAAQ,IAAI,iBAAiB;AAEnC,KAAI,cACF,OAAM,IAAI,mBAAmB,cAAc;AAG7C,KAAI,OAAO,cAAc,UACvB,OAAM,IAAI,aAAa,UAAU,UAAU,CAAC;AAG9C,QACE,4CAAC;EACC,MAAM,GAAG,aAAa,MAAM,OAAO,IAAI,MAAM,UAAU,KAAK;EAC5D,GAAI;IAEH,SACC"}
|
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as ExtraAuthParams } from "../types-ClljFIvK.mjs";
|
|
2
2
|
import React from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/components/signin.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Props for the `<SignIn />` component.
|
|
7
|
+
*
|
|
8
|
+
* @category Types
|
|
9
|
+
*/
|
|
5
10
|
interface SignInProps extends ExtraAuthParams {
|
|
11
|
+
/**
|
|
12
|
+
* Content rendered inside the link (for example, button text).
|
|
13
|
+
*/
|
|
6
14
|
children: React.ReactNode;
|
|
7
15
|
/**
|
|
8
|
-
* URL to redirect to after
|
|
16
|
+
* URL to redirect to after successful sign-in.
|
|
9
17
|
*/
|
|
10
18
|
returnUrl?: string;
|
|
11
19
|
}
|
|
12
20
|
/**
|
|
13
|
-
*
|
|
21
|
+
* `<SignIn>` renders a link that initiates the MonoCloud sign-in flow.
|
|
14
22
|
*
|
|
15
|
-
*
|
|
23
|
+
* It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
16
24
|
*
|
|
17
|
-
* @
|
|
18
|
-
*
|
|
19
|
-
* @example App Router and Pages Router
|
|
20
|
-
*
|
|
21
|
-
* **Sign-in component works on both the server and the client in pages router and app router.**
|
|
25
|
+
* @example Basic Usage
|
|
22
26
|
*
|
|
23
|
-
* ```tsx
|
|
27
|
+
* ```tsx title="Basic Usage"
|
|
24
28
|
* import { SignIn } from "@monocloud/auth-nextjs/components";
|
|
25
29
|
*
|
|
26
30
|
* export default function Home() {
|
|
@@ -30,21 +34,24 @@ interface SignInProps extends ExtraAuthParams {
|
|
|
30
34
|
*
|
|
31
35
|
* @example Customize the authorization request
|
|
32
36
|
*
|
|
33
|
-
* You can customize the authorization request by passing
|
|
37
|
+
* You can customize the authorization request by passing props:
|
|
34
38
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* ```tsx
|
|
39
|
+
* ```tsx title="Customize the authorization request"
|
|
38
40
|
* import { SignIn } from "@monocloud/auth-nextjs/components";
|
|
39
41
|
*
|
|
40
42
|
* export default function Home() {
|
|
41
43
|
* return (
|
|
42
|
-
* <SignIn loginHint="
|
|
44
|
+
* <SignIn loginHint="user@example.com" authenticatorHint="password" returnUrl="/dashboard">
|
|
43
45
|
* Sign In
|
|
44
46
|
* </SignIn>
|
|
45
47
|
* );
|
|
46
48
|
* }
|
|
47
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
|
|
48
55
|
*/
|
|
49
56
|
declare const SignIn: ({
|
|
50
57
|
children,
|
|
@@ -62,25 +69,27 @@ declare const SignIn: ({
|
|
|
62
69
|
}: SignInProps & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "resource">) => React.ReactNode;
|
|
63
70
|
//#endregion
|
|
64
71
|
//#region src/components/signup.d.ts
|
|
72
|
+
/**
|
|
73
|
+
* Props for the `<SignUp />` component.
|
|
74
|
+
*
|
|
75
|
+
* @category Types
|
|
76
|
+
*/
|
|
65
77
|
interface SignUpProps extends Omit<ExtraAuthParams, 'authenticatorHint' | 'loginHint' | 'prompt'> {
|
|
66
78
|
/**
|
|
67
|
-
* URL to redirect to after
|
|
79
|
+
* URL to redirect to after successful sign-up.
|
|
68
80
|
*/
|
|
69
81
|
returnUrl?: string;
|
|
70
82
|
}
|
|
71
83
|
/**
|
|
72
|
-
*
|
|
73
|
-
* * It functions similarly to the SignIn component but explicitly sets the `prompt` parameter to `create`.
|
|
84
|
+
* `<SignUp>` renders a link that initiates the MonoCloud sign-up flow.
|
|
74
85
|
*
|
|
75
|
-
*
|
|
86
|
+
* It works in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
76
87
|
*
|
|
77
|
-
*
|
|
88
|
+
* Internally, it behaves like `<SignIn>` but sets `prompt=create` to start the registration flow.
|
|
78
89
|
*
|
|
79
|
-
* @example
|
|
90
|
+
* @example Basic usage
|
|
80
91
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* ```tsx
|
|
92
|
+
* ```tsx title="Basic Usage"
|
|
84
93
|
* import { SignUp } from "@monocloud/auth-nextjs/components";
|
|
85
94
|
*
|
|
86
95
|
* export default function Home() {
|
|
@@ -90,17 +99,27 @@ interface SignUpProps extends Omit<ExtraAuthParams, 'authenticatorHint' | 'login
|
|
|
90
99
|
*
|
|
91
100
|
* @example Customize the authorization request
|
|
92
101
|
*
|
|
93
|
-
* You can customize the authorization request by passing in props.
|
|
94
|
-
*
|
|
95
|
-
* **Note⚠️: You need to set the env `MONOCLOUD_AUTH_ALLOW_QUERY_PARAM_OVERRIDES=true` or `allowQueryParamOverrides` should be `true` in the client initialization for props to work**
|
|
102
|
+
* You can customize the authorization request by passing in props.
|
|
96
103
|
*
|
|
97
|
-
* ```tsx
|
|
104
|
+
* ```tsx title="Customize the authorization request"
|
|
98
105
|
* import { SignUp } from "@monocloud/auth-nextjs/components";
|
|
99
106
|
*
|
|
100
107
|
* export default function Home() {
|
|
101
|
-
* return
|
|
108
|
+
* return (
|
|
109
|
+
* <SignUp
|
|
110
|
+
* returnUrl="/dashboard"
|
|
111
|
+
* uiLocales="en"
|
|
112
|
+
* >
|
|
113
|
+
* Sign Up
|
|
114
|
+
* </SignUp>
|
|
115
|
+
* );
|
|
102
116
|
* }
|
|
103
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
|
|
104
123
|
*/
|
|
105
124
|
declare const SignUp: ({
|
|
106
125
|
children,
|
|
@@ -115,24 +134,27 @@ declare const SignUp: ({
|
|
|
115
134
|
}: SignUpProps & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "resource">) => React.ReactNode;
|
|
116
135
|
//#endregion
|
|
117
136
|
//#region src/components/signout.d.ts
|
|
137
|
+
/**
|
|
138
|
+
* Props for the `<SignOut />` component.
|
|
139
|
+
*
|
|
140
|
+
* @category Types
|
|
141
|
+
*/
|
|
118
142
|
interface SignOutProps {
|
|
143
|
+
/** Content rendered inside the link (for example, button text). */
|
|
144
|
+
children: React.ReactNode;
|
|
119
145
|
/** URL to redirect the user to after they have been signed out. */
|
|
120
146
|
postLogoutUrl?: string;
|
|
121
|
-
/**
|
|
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. */
|
|
122
148
|
federated?: boolean;
|
|
123
149
|
}
|
|
124
150
|
/**
|
|
125
|
-
*
|
|
151
|
+
* `<SignOut>` renders a link that initiates the MonoCloud sign-out flow.
|
|
126
152
|
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* @returns An anchor element that links to the sign-out endpoint.
|
|
153
|
+
* It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
130
154
|
*
|
|
131
|
-
* @example
|
|
155
|
+
* @example Basic usage
|
|
132
156
|
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* ```tsx
|
|
157
|
+
* ```tsx title="Basic Usage"
|
|
136
158
|
* import { SignOut } from "@monocloud/auth-nextjs/components";
|
|
137
159
|
*
|
|
138
160
|
* export default function Home() {
|
|
@@ -140,19 +162,20 @@ interface SignOutProps {
|
|
|
140
162
|
* }
|
|
141
163
|
* ```
|
|
142
164
|
*
|
|
143
|
-
* @example Customize the request
|
|
144
|
-
*
|
|
145
|
-
* You can customize the request by passing in props. See {@link SignOutProps}.
|
|
165
|
+
* @example Customize the sign-out request
|
|
146
166
|
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* ```tsx
|
|
167
|
+
* ```tsx title="Customize the sign-out request"
|
|
150
168
|
* import { SignOut } from "@monocloud/auth-nextjs/components";
|
|
151
169
|
*
|
|
152
170
|
* export default function Home() {
|
|
153
|
-
* return <SignOut federated=
|
|
171
|
+
* return <SignOut federated postLogoutUrl="/goodbye">Sign Out</SignOut>;
|
|
154
172
|
* }
|
|
155
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
|
|
156
179
|
*/
|
|
157
180
|
declare const SignOut: ({
|
|
158
181
|
children,
|
|
@@ -2,17 +2,13 @@ import React from "react";
|
|
|
2
2
|
|
|
3
3
|
//#region src/components/signin.tsx
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* `<SignIn>` renders a link that initiates the MonoCloud sign-in flow.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @returns An anchor element that links to the sign-in endpoint with the specified parameters.
|
|
10
|
-
*
|
|
11
|
-
* @example App Router and Pages Router
|
|
7
|
+
* It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
12
8
|
*
|
|
13
|
-
*
|
|
9
|
+
* @example Basic Usage
|
|
14
10
|
*
|
|
15
|
-
* ```tsx
|
|
11
|
+
* ```tsx title="Basic Usage"
|
|
16
12
|
* import { SignIn } from "@monocloud/auth-nextjs/components";
|
|
17
13
|
*
|
|
18
14
|
* export default function Home() {
|
|
@@ -22,21 +18,24 @@ import React from "react";
|
|
|
22
18
|
*
|
|
23
19
|
* @example Customize the authorization request
|
|
24
20
|
*
|
|
25
|
-
* You can customize the authorization request by passing
|
|
21
|
+
* You can customize the authorization request by passing props:
|
|
26
22
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* ```tsx
|
|
23
|
+
* ```tsx title="Customize the authorization request"
|
|
30
24
|
* import { SignIn } from "@monocloud/auth-nextjs/components";
|
|
31
25
|
*
|
|
32
26
|
* export default function Home() {
|
|
33
27
|
* return (
|
|
34
|
-
* <SignIn loginHint="
|
|
28
|
+
* <SignIn loginHint="user@example.com" authenticatorHint="password" returnUrl="/dashboard">
|
|
35
29
|
* Sign In
|
|
36
30
|
* </SignIn>
|
|
37
31
|
* );
|
|
38
32
|
* }
|
|
39
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
|
|
40
39
|
*/
|
|
41
40
|
const SignIn = ({ children, authenticatorHint, loginHint, prompt, display, uiLocales, scopes, acrValues, resource, maxAge, returnUrl, ...props }) => {
|
|
42
41
|
const signInUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signin`;
|
|
@@ -60,18 +59,15 @@ const SignIn = ({ children, authenticatorHint, loginHint, prompt, display, uiLoc
|
|
|
60
59
|
//#endregion
|
|
61
60
|
//#region src/components/signup.tsx
|
|
62
61
|
/**
|
|
63
|
-
*
|
|
64
|
-
* * It functions similarly to the SignIn component but explicitly sets the `prompt` parameter to `create`.
|
|
65
|
-
*
|
|
66
|
-
* @param props - Properties for the SignUp component.
|
|
62
|
+
* `<SignUp>` renders a link that initiates the MonoCloud sign-up flow.
|
|
67
63
|
*
|
|
68
|
-
*
|
|
64
|
+
* It works in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
69
65
|
*
|
|
70
|
-
*
|
|
66
|
+
* Internally, it behaves like `<SignIn>` but sets `prompt=create` to start the registration flow.
|
|
71
67
|
*
|
|
72
|
-
*
|
|
68
|
+
* @example Basic usage
|
|
73
69
|
*
|
|
74
|
-
* ```tsx
|
|
70
|
+
* ```tsx title="Basic Usage"
|
|
75
71
|
* import { SignUp } from "@monocloud/auth-nextjs/components";
|
|
76
72
|
*
|
|
77
73
|
* export default function Home() {
|
|
@@ -81,17 +77,27 @@ const SignIn = ({ children, authenticatorHint, loginHint, prompt, display, uiLoc
|
|
|
81
77
|
*
|
|
82
78
|
* @example Customize the authorization request
|
|
83
79
|
*
|
|
84
|
-
* You can customize the authorization request by passing in props.
|
|
80
|
+
* You can customize the authorization request by passing in props.
|
|
85
81
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* ```tsx
|
|
82
|
+
* ```tsx title="Customize the authorization request"
|
|
89
83
|
* import { SignUp } from "@monocloud/auth-nextjs/components";
|
|
90
84
|
*
|
|
91
85
|
* export default function Home() {
|
|
92
|
-
* return
|
|
86
|
+
* return (
|
|
87
|
+
* <SignUp
|
|
88
|
+
* returnUrl="/dashboard"
|
|
89
|
+
* uiLocales="en"
|
|
90
|
+
* >
|
|
91
|
+
* Sign Up
|
|
92
|
+
* </SignUp>
|
|
93
|
+
* );
|
|
93
94
|
* }
|
|
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
|
|
95
101
|
*/
|
|
96
102
|
const SignUp = ({ children, returnUrl, acrValues, display, maxAge, resource, scopes, uiLocales, ...props }) => {
|
|
97
103
|
const signInUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signin`;
|
|
@@ -114,17 +120,13 @@ const SignUp = ({ children, returnUrl, acrValues, display, maxAge, resource, sco
|
|
|
114
120
|
//#endregion
|
|
115
121
|
//#region src/components/signout.tsx
|
|
116
122
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* @param props - Properties for the SignOut component.
|
|
120
|
-
*
|
|
121
|
-
* @returns An anchor element that links to the sign-out endpoint.
|
|
123
|
+
* `<SignOut>` renders a link that initiates the MonoCloud sign-out flow.
|
|
122
124
|
*
|
|
123
|
-
*
|
|
125
|
+
* It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
124
126
|
*
|
|
125
|
-
*
|
|
127
|
+
* @example Basic usage
|
|
126
128
|
*
|
|
127
|
-
* ```tsx
|
|
129
|
+
* ```tsx title="Basic Usage"
|
|
128
130
|
* import { SignOut } from "@monocloud/auth-nextjs/components";
|
|
129
131
|
*
|
|
130
132
|
* export default function Home() {
|
|
@@ -132,19 +134,20 @@ const SignUp = ({ children, returnUrl, acrValues, display, maxAge, resource, sco
|
|
|
132
134
|
* }
|
|
133
135
|
* ```
|
|
134
136
|
*
|
|
135
|
-
* @example Customize the request
|
|
136
|
-
*
|
|
137
|
-
* You can customize the request by passing in props. See {@link SignOutProps}.
|
|
137
|
+
* @example Customize the sign-out request
|
|
138
138
|
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* ```tsx
|
|
139
|
+
* ```tsx title="Customize the sign-out request"
|
|
142
140
|
* import { SignOut } from "@monocloud/auth-nextjs/components";
|
|
143
141
|
*
|
|
144
142
|
* export default function Home() {
|
|
145
|
-
* return <SignOut federated=
|
|
143
|
+
* return <SignOut federated postLogoutUrl="/goodbye">Sign Out</SignOut>;
|
|
146
144
|
* }
|
|
147
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
|
|
148
151
|
*/
|
|
149
152
|
const SignOut = ({ children, postLogoutUrl, federated, ...props }) => {
|
|
150
153
|
const signOutUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNOUT_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signout`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/components/signin.tsx","../../src/components/signup.tsx","../../src/components/signout.tsx"],"sourcesContent":["import React from 'react';\nimport { ExtraAuthParams } from '../types';\n\nexport interface SignInProps extends ExtraAuthParams {\n children: React.ReactNode;\n /**\n * URL to redirect to after
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/components/signin.tsx","../../src/components/signup.tsx","../../src/components/signout.tsx"],"sourcesContent":["import React from 'react';\nimport { ExtraAuthParams } from '../types';\n\n/**\n * Props for the `<SignIn />` component.\n *\n * @category Types\n */\nexport interface SignInProps extends ExtraAuthParams {\n /**\n * Content rendered inside the link (for example, button text).\n */\n children: React.ReactNode;\n\n /**\n * URL to redirect to after successful sign-in.\n */\n returnUrl?: string;\n}\n\n/**\n * `<SignIn>` renders a link that initiates the MonoCloud sign-in flow.\n *\n * It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.\n *\n * @example Basic Usage\n *\n * ```tsx title=\"Basic Usage\"\n * import { SignIn } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignIn>Sign In</SignIn>;\n * }\n * ```\n *\n * @example Customize the authorization request\n *\n * You can customize the authorization request by passing props:\n *\n * ```tsx title=\"Customize the authorization request\"\n * import { SignIn } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return (\n * <SignIn loginHint=\"user@example.com\" authenticatorHint=\"password\" returnUrl=\"/dashboard\">\n * Sign In\n * </SignIn>\n * );\n * }\n * ```\n *\n * @param props - Properties for the SignIn component.\n * @returns An anchor element that links to the sign-in endpoint with the specified parameters.\n *\n * @category Components\n */\nexport const SignIn = ({\n children,\n authenticatorHint,\n loginHint,\n prompt,\n display,\n uiLocales,\n scopes,\n acrValues,\n resource,\n maxAge,\n returnUrl,\n ...props\n}: SignInProps &\n Omit<\n React.AnchorHTMLAttributes<HTMLAnchorElement>,\n 'resource'\n >): React.ReactNode => {\n const signInUrl =\n process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ??\n // eslint-disable-next-line no-underscore-dangle\n `${process.env.__NEXT_ROUTER_BASEPATH ?? ''}/api/auth/signin`;\n\n const query = new URLSearchParams();\n\n if (authenticatorHint) {\n query.set('authenticator_hint', authenticatorHint);\n }\n\n if (prompt) {\n query.set('prompt', prompt);\n }\n\n if (display) {\n query.set('display', display);\n }\n\n if (uiLocales) {\n query.set('ui_locales', uiLocales);\n }\n\n if (scopes) {\n query.set('scope', scopes);\n }\n\n if (acrValues) {\n query.set('acr_values', acrValues.join(' '));\n }\n\n if (resource) {\n query.set('resource', resource);\n }\n\n if (maxAge) {\n query.set('max_age', maxAge.toString());\n }\n\n if (loginHint) {\n query.set('login_hint', loginHint);\n }\n\n if (returnUrl) {\n query.set('return_url', returnUrl);\n }\n\n return (\n <a\n href={`${signInUrl}${query.size ? `?${query.toString()}` : ''}`}\n {...props}\n >\n {children}\n </a>\n );\n};\n","import React from 'react';\nimport { ExtraAuthParams } from '../types';\n\n/**\n * Props for the `<SignUp />` component.\n *\n * @category Types\n */\nexport interface SignUpProps extends Omit<\n ExtraAuthParams,\n 'authenticatorHint' | 'loginHint' | 'prompt'\n> {\n /**\n * URL to redirect to after successful sign-up.\n */\n returnUrl?: string;\n}\n\n/**\n * `<SignUp>` renders a link that initiates the MonoCloud sign-up flow.\n *\n * It works in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.\n *\n * Internally, it behaves like `<SignIn>` but sets `prompt=create` to start the registration flow.\n *\n * @example Basic usage\n *\n * ```tsx title=\"Basic Usage\"\n * import { SignUp } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignUp>Sign Up</SignUp>;\n * }\n * ```\n *\n * @example Customize the authorization request\n *\n * You can customize the authorization request by passing in props.\n *\n * ```tsx title=\"Customize the authorization request\"\n * import { SignUp } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return (\n * <SignUp\n * returnUrl=\"/dashboard\"\n * uiLocales=\"en\"\n * >\n * Sign Up\n * </SignUp>\n * );\n * }\n * ```\n *\n * @param props - Properties for the SignUp component.\n * @returns An anchor element that links to the sign-in endpoint with the prompt set to 'create'.\n *\n * @category Components\n */\nexport const SignUp = ({\n children,\n returnUrl,\n acrValues,\n display,\n maxAge,\n resource,\n scopes,\n uiLocales,\n ...props\n}: SignUpProps &\n Omit<\n React.AnchorHTMLAttributes<HTMLAnchorElement>,\n 'resource'\n >): React.ReactNode => {\n const signInUrl =\n process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ??\n // eslint-disable-next-line no-underscore-dangle\n `${process.env.__NEXT_ROUTER_BASEPATH ?? ''}/api/auth/signin`;\n\n const query = new URLSearchParams();\n\n query.set('prompt', 'create');\n\n if (returnUrl) {\n query.set('return_url', returnUrl);\n }\n\n if (display) {\n query.set('display', display);\n }\n\n if (uiLocales) {\n query.set('ui_locales', uiLocales);\n }\n\n if (scopes) {\n query.set('scope', scopes);\n }\n\n if (acrValues) {\n query.set('acr_values', acrValues.join(' '));\n }\n\n if (resource) {\n query.set('resource', resource);\n }\n\n if (maxAge) {\n query.set('max_age', maxAge.toString());\n }\n\n if (returnUrl) {\n query.set('return_url', returnUrl);\n }\n\n return (\n <a href={`${signInUrl}?${query.toString()}`} {...props}>\n {children}\n </a>\n );\n};\n","import React from 'react';\n\n/**\n * Props for the `<SignOut />` component.\n *\n * @category Types\n */\nexport interface SignOutProps {\n /** Content rendered inside the link (for example, button text). */\n children: React.ReactNode;\n\n /** URL to redirect the user to after they have been signed out. */\n postLogoutUrl?: string;\n\n /** 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. */\n federated?: boolean;\n}\n\n/**\n * `<SignOut>` renders a link that initiates the MonoCloud sign-out flow.\n *\n * It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.\n *\n * @example Basic usage\n *\n * ```tsx title=\"Basic Usage\"\n * import { SignOut } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignOut>Sign Out</SignOut>;\n * }\n * ```\n *\n * @example Customize the sign-out request\n *\n * ```tsx title=\"Customize the sign-out request\"\n * import { SignOut } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignOut federated postLogoutUrl=\"/goodbye\">Sign Out</SignOut>;\n * }\n * ```\n *\n * @param props - Properties for the SignOut component.\n * @returns An anchor element that links to the sign-out endpoint.\n *\n * @category Components\n */\nexport const SignOut = ({\n children,\n postLogoutUrl,\n federated,\n ...props\n}: SignOutProps &\n React.AnchorHTMLAttributes<HTMLAnchorElement>): React.ReactNode => {\n const signOutUrl =\n process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNOUT_URL ??\n // eslint-disable-next-line no-underscore-dangle\n `${process.env.__NEXT_ROUTER_BASEPATH ?? ''}/api/auth/signout`;\n\n const query = new URLSearchParams();\n\n if (postLogoutUrl) {\n query.set('post_logout_url', postLogoutUrl);\n }\n\n if (typeof federated === 'boolean') {\n query.set('federated', federated.toString());\n }\n\n return (\n <a\n href={`${signOutUrl}${query.size ? `?${query.toString()}` : ''}`}\n {...props}\n >\n {children}\n </a>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAa,UAAU,EACrB,UACA,mBACA,WACA,QACA,SACA,WACA,QACA,WACA,UACA,QACA,WACA,GAAG,YAKoB;CACvB,MAAM,YACJ,QAAQ,IAAI,yCAEZ,GAAG,QAAQ,IAAI,0BAA0B,GAAG;CAE9C,MAAM,QAAQ,IAAI,iBAAiB;AAEnC,KAAI,kBACF,OAAM,IAAI,sBAAsB,kBAAkB;AAGpD,KAAI,OACF,OAAM,IAAI,UAAU,OAAO;AAG7B,KAAI,QACF,OAAM,IAAI,WAAW,QAAQ;AAG/B,KAAI,UACF,OAAM,IAAI,cAAc,UAAU;AAGpC,KAAI,OACF,OAAM,IAAI,SAAS,OAAO;AAG5B,KAAI,UACF,OAAM,IAAI,cAAc,UAAU,KAAK,IAAI,CAAC;AAG9C,KAAI,SACF,OAAM,IAAI,YAAY,SAAS;AAGjC,KAAI,OACF,OAAM,IAAI,WAAW,OAAO,UAAU,CAAC;AAGzC,KAAI,UACF,OAAM,IAAI,cAAc,UAAU;AAGpC,KAAI,UACF,OAAM,IAAI,cAAc,UAAU;AAGpC,QACE,oCAAC;EACC,MAAM,GAAG,YAAY,MAAM,OAAO,IAAI,MAAM,UAAU,KAAK;EAC3D,GAAI;IAEH,SACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACpER,MAAa,UAAU,EACrB,UACA,WACA,WACA,SACA,QACA,UACA,QACA,WACA,GAAG,YAKoB;CACvB,MAAM,YACJ,QAAQ,IAAI,yCAEZ,GAAG,QAAQ,IAAI,0BAA0B,GAAG;CAE9C,MAAM,QAAQ,IAAI,iBAAiB;AAEnC,OAAM,IAAI,UAAU,SAAS;AAE7B,KAAI,UACF,OAAM,IAAI,cAAc,UAAU;AAGpC,KAAI,QACF,OAAM,IAAI,WAAW,QAAQ;AAG/B,KAAI,UACF,OAAM,IAAI,cAAc,UAAU;AAGpC,KAAI,OACF,OAAM,IAAI,SAAS,OAAO;AAG5B,KAAI,UACF,OAAM,IAAI,cAAc,UAAU,KAAK,IAAI,CAAC;AAG9C,KAAI,SACF,OAAM,IAAI,YAAY,SAAS;AAGjC,KAAI,OACF,OAAM,IAAI,WAAW,OAAO,UAAU,CAAC;AAGzC,KAAI,UACF,OAAM,IAAI,cAAc,UAAU;AAGpC,QACE,oCAAC;EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,UAAU;EAAI,GAAI;IAC9C,SACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACtER,MAAa,WAAW,EACtB,UACA,eACA,WACA,GAAG,YAEgE;CACnE,MAAM,aACJ,QAAQ,IAAI,0CAEZ,GAAG,QAAQ,IAAI,0BAA0B,GAAG;CAE9C,MAAM,QAAQ,IAAI,iBAAiB;AAEnC,KAAI,cACF,OAAM,IAAI,mBAAmB,cAAc;AAG7C,KAAI,OAAO,cAAc,UACvB,OAAM,IAAI,aAAa,UAAU,UAAU,CAAC;AAG9C,QACE,oCAAC;EACC,MAAM,GAAG,aAAa,MAAM,OAAO,IAAI,MAAM,UAAU,KAAK;EAC5D,GAAI;IAEH,SACC"}
|