@monocloud/auth-nextjs 0.1.4 → 0.1.6

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 CHANGED
@@ -1,4 +1,21 @@
1
- ![MonoCloud Logo](https://raw.githubusercontent.com/monocloud/auth-js/refs/heads/main/MonoCloud.png)
1
+ <div align="center">
2
+ <a href="https://www.monocloud.com?utm_source=github&utm_medium=auth_js" target="_blank" rel="noopener noreferrer">
3
+ <picture>
4
+ <img src="https://raw.githubusercontent.com/monocloud/auth-js/refs/heads/main/packages/nextjs/banner.svg" alt="MonoCloud Banner">
5
+ </picture>
6
+ </a>
7
+ <div align="right">
8
+ <a href="https://www.npmjs.com/package/@monocloud/auth-nextjs" target="_blank">
9
+ <img src="https://img.shields.io/npm/v/@monocloud/auth-nextjs" alt="NPM" />
10
+ </a>
11
+ <a href="https://opensource.org/licenses/MIT">
12
+ <img src="https://img.shields.io/:license-MIT-blue.svg?style=flat" alt="License: MIT" />
13
+ </a>
14
+ <a href="https://github.com/monocloud/auth-js/actions/workflows/build.yml">
15
+ <img src="https://github.com/monocloud/auth-js/actions/workflows/build.yml/badge.svg" alt="Build Status" />
16
+ </a>
17
+ </div>
18
+ </div>
2
19
 
3
20
  ## Introduction
4
21
 
@@ -11,8 +28,8 @@ This SDK is designed specifically for **Next.js**, providing first-class integra
11
28
  ## 📘 Documentation
12
29
 
13
30
  - **Documentation:** [https://www.monocloud.com/docs](https://www.monocloud.com/docs?utm_source=github&utm_medium=auth_js)
14
- - **Quickstart:** [https://www.monocloud.com/docs/quickstarts/nextjs-app-router](https://www.monocloud.com/docs/quickstarts/nextjs-app-router?utm_source=github&utm_medium=auth_js)
15
- - **SDK Reference:** [https://www.monocloud.com/docs/sdk-reference/nextjs](https://www.monocloud.com/docs/sdk-reference/nextjs/index?utm_source=github&utm_medium=auth_js)
31
+ - **Quickstart:** [https://www.monocloud.com/docs/quickstarts/nextjs-app-router](https://www.monocloud.com/docs/quickstarts/nextjs-app-router?utm_source=github&utm_medium=auth_js)
32
+ - **SDK Reference:** [https://www.monocloud.com/docs/sdk-reference/nextjs](https://www.monocloud.com/docs/sdk-reference/nextjs/index?utm_source=github&utm_medium=auth_js)
16
33
  - **API Reference:** [https://monocloud.github.io/auth-js](https://monocloud.github.io/auth-js?utm_source=github&utm_medium=auth_js)
17
34
 
18
35
  ## Supported Platforms
@@ -1,4 +1,4 @@
1
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,4 +1,5 @@
1
- const require_client = require('../client-Be6A2vEn.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_protect = require('../protect-BCIji2i7.cjs');
2
3
 
3
- exports.protectPage = require_client.protectPage;
4
- exports.useAuth = require_client.useAuth;
4
+ exports.protectPage = require_protect.protectPage;
5
+ exports.useAuth = require_protect.useAuth;
@@ -1,6 +1,6 @@
1
- import { a as GroupOptions, i as ExtraAuthParams } from "../types-DOfZTKa6.mjs";
1
+ import { a as GroupOptions, i as ExtraAuthParams } from "../types-Cx32VRoI.mjs";
2
2
  import { MonoCloudUser } from "@monocloud/auth-node-core";
3
- import React, { ComponentType, JSX } from "react";
3
+ import React, { ComponentType } from "react";
4
4
 
5
5
  //#region src/client/use-auth.d.ts
6
6
  /**
@@ -120,9 +120,13 @@ type ProtectPageOptions = {
120
120
  */
121
121
  returnUrl?: string;
122
122
  /**
123
- * A custom react element to render when the user is not authenticated or is not a member of the specified groups.
123
+ * A custom react element to render when the user is not authenticated.
124
124
  */
125
- onAccessDenied?: (user?: MonoCloudUser) => JSX.Element;
125
+ onAccessDenied?: () => React.ReactNode;
126
+ /**
127
+ * A custom react element to render when the user is authenticated but does not belong to the required groups.
128
+ */
129
+ onGroupAccessDenied?: (user: MonoCloudUser) => React.ReactNode;
126
130
  /**
127
131
  * Authorization parameters to be used during authentication.
128
132
  */
@@ -134,7 +138,7 @@ type ProtectPageOptions = {
134
138
  * @param error - The error object.
135
139
  * @returns JSX element to handle the error.
136
140
  */
137
- onError?: (error: Error) => JSX.Element;
141
+ onError?: (error: Error) => React.ReactNode;
138
142
  } & GroupOptions;
139
143
  /**
140
144
  * Function to protect a client rendered page component.
@@ -175,8 +179,42 @@ type ProtectPageOptions = {
175
179
  * { returnUrl: "/dashboard", authParams: { loginHint: "username" } }
176
180
  * );
177
181
  * ```
178
-
179
- * @example Pages Router
182
+ * @example Fallback with onAccessDenied
183
+ *
184
+ * ```tsx
185
+ * "use client";
186
+ *
187
+ * import { protectPage } from "@monocloud/auth-nextjs/client";
188
+ *
189
+ * export default protectPage(
190
+ * function Home() {
191
+ * return <>You are signed in</>;
192
+ * },
193
+ * {
194
+ * onAccessDenied: () => <div>Please sign in to continue</div>
195
+ * }
196
+ * );
197
+ * ```
198
+ *
199
+ * @example Group Protection with onGroupAccessDenied
200
+ *
201
+ * ```tsx
202
+ * "use client";
203
+ *
204
+ * import { protectPage } from "@monocloud/auth-nextjs/client";
205
+ *
206
+ * export default protectPage(
207
+ * function Home() {
208
+ * return <>Welcome Admin</>;
209
+ * },
210
+ * {
211
+ * groups: ["admin"],
212
+ * onGroupAccessDenied: (user) => <div>User {user.email} is not an admin</div>
213
+ * }
214
+ * );
215
+ * ```
216
+ *
217
+ * @example Pages Router
180
218
  *
181
219
  * ```tsx
182
220
  * import { protectPage } from "@monocloud/auth-nextjs/client";
@@ -1,3 +1,3 @@
1
- import { r as useAuth, t as protectPage } from "../client-CnvBgZM-.mjs";
1
+ import { r as useAuth, t as protectPage } from "../protect-K9srvUkq.mjs";
2
2
 
3
3
  export { protectPage, useAuth };
@@ -1,5 +1,7 @@
1
- const require_chunk = require('../../chunk-CbDLau6x.cjs');
2
- const require_client = require('../../client-Be6A2vEn.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_chunk = require('../../chunk-C0xms8kb.cjs');
3
+ const require_protect = require('../../protect-BCIji2i7.cjs');
4
+ require('../../client/index.cjs');
3
5
  let _monocloud_auth_node_core_utils = require("@monocloud/auth-node-core/utils");
4
6
  let react = require("react");
5
7
  react = require_chunk.__toESM(react);
@@ -92,7 +94,7 @@ react = require_chunk.__toESM(react);
92
94
  */
93
95
  const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
94
96
  (0, react.useEffect)(() => {
95
- require_client.redirectToSignIn({
97
+ require_protect.redirectToSignIn({
96
98
  returnUrl,
97
99
  ...authParams
98
100
  });
@@ -110,7 +112,7 @@ const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
110
112
  *
111
113
  * @param props - Props for customizing the Protected component.
112
114
  *
113
- * @returns The children if authorized, the `onAccessDenied` content if unauthorized,
115
+ * @returns The children if authorized, the `fallback` or `onGroupAccessDenied` content if unauthenticated or unauthorized,
114
116
  * or `null` while loading.
115
117
  *
116
118
  * @example App Router
@@ -122,7 +124,7 @@ const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
122
124
  *
123
125
  * export default function Home() {
124
126
  * return (
125
- * <Protected onAccessDenied={<>Sign in to view the message.</>}>
127
+ * <Protected fallback={<>Sign in to view the message.</>}>
126
128
  * <>You are breathtaking</>
127
129
  * </Protected>
128
130
  * );
@@ -141,7 +143,7 @@ const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
141
143
  * export default function Home() {
142
144
  * return (
143
145
  * <Protected
144
- * onAccessDenied={<>Only admins are allowed.</>}
146
+ * onGroupAccessDenied={() => <>Only admins are allowed.</>}
145
147
  * groups={["admin"]}
146
148
  * >
147
149
  * <>Signed in as admin</>
@@ -157,7 +159,7 @@ const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
157
159
  *
158
160
  * export default function Home() {
159
161
  * return (
160
- * <Protected onAccessDenied={<>Sign in to view the message.</>}>
162
+ * <Protected fallback={<>Sign in to view the message.</>}>
161
163
  * <>You are breathtaking</>
162
164
  * </Protected>
163
165
  * );
@@ -174,7 +176,7 @@ const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
174
176
  * export default function Home() {
175
177
  * return (
176
178
  * <Protected
177
- * onAccessDenied={<>Only admins are allowed.</>}
179
+ * onGroupAccessDenied={(user) => <>User {user?.email} is not allowed.</>}
178
180
  * groups={["admin"]}
179
181
  * >
180
182
  * <>Signed in as admin</>
@@ -184,14 +186,14 @@ const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
184
186
  * ```
185
187
  *
186
188
  */
187
- const Protected = ({ children, groups, groupsClaim, matchAllGroups = false, onAccessDenied = null }) => {
188
- const { isLoading, error, isAuthenticated, user } = require_client.useAuth();
189
+ const Protected = ({ children, groups, groupsClaim, matchAllGroups = false, fallback = null, onGroupAccessDenied = () => /* @__PURE__ */ react.default.createElement(react.default.Fragment, null) }) => {
190
+ const { isLoading, error, isAuthenticated, user } = require_protect.useAuth();
189
191
  if (isLoading) return null;
190
192
  if (error || !isAuthenticated || !user) {
191
- if (onAccessDenied) return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, onAccessDenied);
193
+ if (fallback) return fallback;
192
194
  return null;
193
195
  }
194
- return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, !groups || (0, _monocloud_auth_node_core_utils.isUserInGroup)(user, groups, groupsClaim ?? process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_GROUPS_CLAIM, matchAllGroups) ? children : onAccessDenied);
196
+ return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, !groups || (0, _monocloud_auth_node_core_utils.isUserInGroup)(user, groups, groupsClaim ?? process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_GROUPS_CLAIM, matchAllGroups) ? children : onGroupAccessDenied(user));
195
197
  };
196
198
 
197
199
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["useAuth"],"sources":["../../../src/components/client/redirect-to-signin.tsx","../../../src/components/client/protected.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { redirectToSignIn } from '../../client/protect';\nimport { ExtraAuthParams } from '../../types';\n\n/**\n * Props for the `<RedirectToSignIn />` Component\n */\nexport interface RedirectToSignInProps extends ExtraAuthParams {\n /**\n * The url where the user will be redirected to after sign in.\n */\n returnUrl?: string;\n}\n\n/**\n * A client side component that will redirect users to the sign in page.\n *\n * **Note⚠️: Since `window.location` is set as `returnUrl` query param by default, you need to set the env `MONOCLOUD_AUTH_ALLOW_QUERY_PARAM_OVERRIDES=true` or `allowQueryParamOverrides` should be `true` in the client initialization for returning to the same page.**\n *\n * @param props - The props for customizing RedirectToSignIn\n *\n * @returns\n *\n * @example App Router\n *\n * ```tsx\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 App Router with options\n *\n * You can customize the authorization request by passing in props. See {@link RedirectToSignInProps}.\n *\n * ```tsx\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 returnUrl=\"/dashboard\" loginHint=\"username\" />;\n * }\n *\n * return <>You are signed in</>;\n * }\n * ```\n *\n * @example Pages Router\n *\n * ```tsx\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 Pages Router with options\n *\n * You can customize the authorization request by passing in props. See {@link RedirectToSignInProps}.\n *\n * ```tsx\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 returnUrl=\"/dashboard\" loginHint=\"username\" />;\n * }\n *\n * return <>You are signed in</>;\n * }\n * ```\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","import { isUserInGroup } from '@monocloud/auth-node-core/utils';\nimport React, { JSX } from 'react';\nimport { useAuth } from '../../client';\n\nexport interface ProtectedComponentProps {\n /**\n * Components that should be rendered if the user is authenticated.\n */\n children: React.ReactNode;\n\n /**\n * A list of group names or IDs to which the user must belong to. The user should belong to atleast one of the specified groups.\n */\n groups?: string[];\n\n /**\n * Name of the claim of user's groups. default: `groups`.\n */\n groupsClaim?: string;\n\n /**\n * Flag indicating if all groups specified should be present in the users profile. default: false.\n */\n matchAllGroups?: boolean;\n\n /**\n * A fallback component that should render if the user is not authenticated.\n */\n onAccessDenied?: React.ReactNode;\n}\n\n/**\n * A wrapper component that conditionally renders its children based on the user's authentication\n * status and group membership.\n *\n * **Note⚠️: The component is hidden from view. The data is present in the browser. Use server side `protectPage()` for protecting components before that data is sent to the client.**\n *\n * @param props - Props for customizing the Protected component.\n *\n * @returns The children if authorized, the `onAccessDenied` content if unauthorized,\n * or `null` while loading.\n *\n * @example App Router\n *\n * ```tsx\n * \"use client\";\n *\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected onAccessDenied={<>Sign in to view the message.</>}>\n * <>You are breathtaking</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example App Router with group options\n *\n * See {@link ProtectedComponentProps}.\n *\n * ```tsx\n * \"use client\";\n *\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected\n * onAccessDenied={<>Only admins are allowed.</>}\n * groups={[\"admin\"]}\n * >\n * <>Signed in as admin</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example Pages Router\n *\n * ```tsx\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected onAccessDenied={<>Sign in to view the message.</>}>\n * <>You are breathtaking</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example Pages Router with group options\n *\n * See {@link ProtectedComponentProps}.\n *\n * ```tsx\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected\n * onAccessDenied={<>Only admins are allowed.</>}\n * groups={[\"admin\"]}\n * >\n * <>Signed in as admin</>\n * </Protected>\n * );\n * }\n * ```\n *\n */\nexport const Protected = ({\n children,\n groups,\n groupsClaim,\n matchAllGroups = false,\n onAccessDenied = null,\n}: ProtectedComponentProps): JSX.Element | null => {\n const { isLoading, error, isAuthenticated, user } = useAuth();\n\n if (isLoading) {\n return null;\n }\n\n if (error || !isAuthenticated || !user) {\n if (onAccessDenied) {\n return <>{onAccessDenied}</>;\n }\n\n return null;\n }\n\n return (\n <>\n {!groups ||\n isUserInGroup(\n user,\n groups,\n groupsClaim ?? process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_GROUPS_CLAIM,\n matchAllGroups\n )\n ? children\n : onAccessDenied}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,MAAa,oBAAoB,EAC/B,WACA,GAAG,iBAC8B;AACjC,4BAAgB;AACd,kCAAiB;GAAE;GAAW,GAAG;GAAY,CAAC;IAC7C,CAAC,YAAY,UAAU,CAAC;AAC3B,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACKT,MAAa,aAAa,EACxB,UACA,QACA,aACA,iBAAiB,OACjB,iBAAiB,WACgC;CACjD,MAAM,EAAE,WAAW,OAAO,iBAAiB,SAASA,wBAAS;AAE7D,KAAI,UACF,QAAO;AAGT,KAAI,SAAS,CAAC,mBAAmB,CAAC,MAAM;AACtC,MAAI,eACF,QAAO,0EAAG,eAAkB;AAG9B,SAAO;;AAGT,QACE,0EACG,CAAC,6DAEA,MACA,QACA,eAAe,QAAQ,IAAI,yCAC3B,eACD,GACG,WACA,eACH"}
1
+ {"version":3,"file":"index.cjs","names":["useAuth"],"sources":["../../../src/components/client/redirect-to-signin.tsx","../../../src/components/client/protected.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { redirectToSignIn } from '../../client/protect';\nimport { ExtraAuthParams } from '../../types';\n\n/**\n * Props for the `<RedirectToSignIn />` Component\n */\nexport interface RedirectToSignInProps extends ExtraAuthParams {\n /**\n * The url where the user will be redirected to after sign in.\n */\n returnUrl?: string;\n}\n\n/**\n * A client side component that will redirect users to the sign in page.\n *\n * **Note⚠️: Since `window.location` is set as `returnUrl` query param by default, you need to set the env `MONOCLOUD_AUTH_ALLOW_QUERY_PARAM_OVERRIDES=true` or `allowQueryParamOverrides` should be `true` in the client initialization for returning to the same page.**\n *\n * @param props - The props for customizing RedirectToSignIn\n *\n * @returns\n *\n * @example App Router\n *\n * ```tsx\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 App Router with options\n *\n * You can customize the authorization request by passing in props. See {@link RedirectToSignInProps}.\n *\n * ```tsx\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 returnUrl=\"/dashboard\" loginHint=\"username\" />;\n * }\n *\n * return <>You are signed in</>;\n * }\n * ```\n *\n * @example Pages Router\n *\n * ```tsx\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 Pages Router with options\n *\n * You can customize the authorization request by passing in props. See {@link RedirectToSignInProps}.\n *\n * ```tsx\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 returnUrl=\"/dashboard\" loginHint=\"username\" />;\n * }\n *\n * return <>You are signed in</>;\n * }\n * ```\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","import { isUserInGroup } from '@monocloud/auth-node-core/utils';\nimport React from 'react';\nimport { useAuth } from '../../client';\nimport type { MonoCloudUser } from '@monocloud/auth-node-core';\n\nexport interface ProtectedComponentProps {\n /**\n * Components that should be rendered if the user is authenticated.\n */\n children: React.ReactNode;\n\n /**\n * A list of group names or IDs to which the user must belong to. The user should belong to atleast one of the specified groups.\n */\n groups?: string[];\n\n /**\n * Name of the claim of user's groups. default: `groups`.\n */\n groupsClaim?: string;\n\n /**\n * Flag indicating if all groups specified should be present in the users profile. default: false.\n */\n matchAllGroups?: boolean;\n\n /**\n * A fallback component that should render if the user is not authenticated.\n */\n fallback?: React.ReactNode;\n\n /**\n * A fallback component that should render if the user is authenticated but does not belong to the required groups.\n */\n onGroupAccessDenied?: (user?: MonoCloudUser) => React.ReactNode;\n}\n\n/**\n * A wrapper component that conditionally renders its children based on the user's authentication\n * status and group membership.\n *\n * **Note⚠️: The component is hidden from view. The data is present in the browser. Use server side `protectPage()` for protecting components before that data is sent to the client.**\n *\n * @param props - Props for customizing the Protected component.\n *\n * @returns The children if authorized, the `fallback` or `onGroupAccessDenied` content if unauthenticated or unauthorized,\n * or `null` while loading.\n *\n * @example App Router\n *\n * ```tsx\n * \"use client\";\n *\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected fallback={<>Sign in to view the message.</>}>\n * <>You are breathtaking</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example App Router with group options\n *\n * See {@link ProtectedComponentProps}.\n *\n * ```tsx\n * \"use client\";\n *\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected\n * onGroupAccessDenied={() => <>Only admins are allowed.</>}\n * groups={[\"admin\"]}\n * >\n * <>Signed in as admin</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example Pages Router\n *\n * ```tsx\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected fallback={<>Sign in to view the message.</>}>\n * <>You are breathtaking</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example Pages Router with group options\n *\n * See {@link ProtectedComponentProps}.\n *\n * ```tsx\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected\n * onGroupAccessDenied={(user) => <>User {user?.email} is not allowed.</>}\n * groups={[\"admin\"]}\n * >\n * <>Signed in as admin</>\n * </Protected>\n * );\n * }\n * ```\n *\n */\nexport const Protected = ({\n children,\n groups,\n groupsClaim,\n matchAllGroups = false,\n fallback = null,\n onGroupAccessDenied = (): React.ReactNode => <></>,\n}: ProtectedComponentProps): React.ReactNode | null => {\n const { isLoading, error, isAuthenticated, user } = useAuth();\n\n if (isLoading) {\n return null;\n }\n\n if (error || !isAuthenticated || !user) {\n if (fallback) {\n return fallback;\n }\n\n return null;\n }\n\n return (\n <>\n {!groups ||\n isUserInGroup(\n user,\n groups,\n groupsClaim ?? process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_GROUPS_CLAIM,\n matchAllGroups\n )\n ? children\n : onGroupAccessDenied(user)}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,MAAa,oBAAoB,EAC/B,WACA,GAAG,iBAC8B;AACjC,4BAAgB;AACd,mCAAiB;GAAE;GAAW,GAAG;GAAY,CAAC;IAC7C,CAAC,YAAY,UAAU,CAAC;AAC3B,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACWT,MAAa,aAAa,EACxB,UACA,QACA,aACA,iBAAiB,OACjB,WAAW,MACX,4BAA6C,yEAAK,OACG;CACrD,MAAM,EAAE,WAAW,OAAO,iBAAiB,SAASA,yBAAS;AAE7D,KAAI,UACF,QAAO;AAGT,KAAI,SAAS,CAAC,mBAAmB,CAAC,MAAM;AACtC,MAAI,SACF,QAAO;AAGT,SAAO;;AAGT,QACE,0EACG,CAAC,6DAEA,MACA,QACA,eAAe,QAAQ,IAAI,yCAC3B,eACD,GACG,WACA,oBAAoB,KAAK,CAC5B"}
@@ -1,5 +1,6 @@
1
- import { i as ExtraAuthParams } from "../../types-DOfZTKa6.mjs";
2
- import React, { JSX } from "react";
1
+ import { i as ExtraAuthParams } from "../../types-Cx32VRoI.mjs";
2
+ import { MonoCloudUser } from "@monocloud/auth-node-core";
3
+ import React from "react";
3
4
 
4
5
  //#region src/components/client/redirect-to-signin.d.ts
5
6
  /**
@@ -122,7 +123,11 @@ interface ProtectedComponentProps {
122
123
  /**
123
124
  * A fallback component that should render if the user is not authenticated.
124
125
  */
125
- onAccessDenied?: React.ReactNode;
126
+ fallback?: React.ReactNode;
127
+ /**
128
+ * A fallback component that should render if the user is authenticated but does not belong to the required groups.
129
+ */
130
+ onGroupAccessDenied?: (user?: MonoCloudUser) => React.ReactNode;
126
131
  }
127
132
  /**
128
133
  * A wrapper component that conditionally renders its children based on the user's authentication
@@ -132,7 +137,7 @@ interface ProtectedComponentProps {
132
137
  *
133
138
  * @param props - Props for customizing the Protected component.
134
139
  *
135
- * @returns The children if authorized, the `onAccessDenied` content if unauthorized,
140
+ * @returns The children if authorized, the `fallback` or `onGroupAccessDenied` content if unauthenticated or unauthorized,
136
141
  * or `null` while loading.
137
142
  *
138
143
  * @example App Router
@@ -144,7 +149,7 @@ interface ProtectedComponentProps {
144
149
  *
145
150
  * export default function Home() {
146
151
  * return (
147
- * <Protected onAccessDenied={<>Sign in to view the message.</>}>
152
+ * <Protected fallback={<>Sign in to view the message.</>}>
148
153
  * <>You are breathtaking</>
149
154
  * </Protected>
150
155
  * );
@@ -163,7 +168,7 @@ interface ProtectedComponentProps {
163
168
  * export default function Home() {
164
169
  * return (
165
170
  * <Protected
166
- * onAccessDenied={<>Only admins are allowed.</>}
171
+ * onGroupAccessDenied={() => <>Only admins are allowed.</>}
167
172
  * groups={["admin"]}
168
173
  * >
169
174
  * <>Signed in as admin</>
@@ -179,7 +184,7 @@ interface ProtectedComponentProps {
179
184
  *
180
185
  * export default function Home() {
181
186
  * return (
182
- * <Protected onAccessDenied={<>Sign in to view the message.</>}>
187
+ * <Protected fallback={<>Sign in to view the message.</>}>
183
188
  * <>You are breathtaking</>
184
189
  * </Protected>
185
190
  * );
@@ -196,7 +201,7 @@ interface ProtectedComponentProps {
196
201
  * export default function Home() {
197
202
  * return (
198
203
  * <Protected
199
- * onAccessDenied={<>Only admins are allowed.</>}
204
+ * onGroupAccessDenied={(user) => <>User {user?.email} is not allowed.</>}
200
205
  * groups={["admin"]}
201
206
  * >
202
207
  * <>Signed in as admin</>
@@ -211,8 +216,9 @@ declare const Protected: ({
211
216
  groups,
212
217
  groupsClaim,
213
218
  matchAllGroups,
214
- onAccessDenied
215
- }: ProtectedComponentProps) => JSX.Element | null;
219
+ fallback,
220
+ onGroupAccessDenied
221
+ }: ProtectedComponentProps) => React.ReactNode | null;
216
222
  //#endregion
217
223
  export { Protected, type ProtectedComponentProps, RedirectToSignIn, type RedirectToSignInProps };
218
224
  //# sourceMappingURL=index.d.mts.map
@@ -1,4 +1,5 @@
1
- import { n as redirectToSignIn, r as useAuth } from "../../client-CnvBgZM-.mjs";
1
+ import { n as redirectToSignIn, r as useAuth } from "../../protect-K9srvUkq.mjs";
2
+ import "../../client/index.mjs";
2
3
  import { isUserInGroup } from "@monocloud/auth-node-core/utils";
3
4
  import React, { useEffect } from "react";
4
5
 
@@ -108,7 +109,7 @@ const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
108
109
  *
109
110
  * @param props - Props for customizing the Protected component.
110
111
  *
111
- * @returns The children if authorized, the `onAccessDenied` content if unauthorized,
112
+ * @returns The children if authorized, the `fallback` or `onGroupAccessDenied` content if unauthenticated or unauthorized,
112
113
  * or `null` while loading.
113
114
  *
114
115
  * @example App Router
@@ -120,7 +121,7 @@ const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
120
121
  *
121
122
  * export default function Home() {
122
123
  * return (
123
- * <Protected onAccessDenied={<>Sign in to view the message.</>}>
124
+ * <Protected fallback={<>Sign in to view the message.</>}>
124
125
  * <>You are breathtaking</>
125
126
  * </Protected>
126
127
  * );
@@ -139,7 +140,7 @@ const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
139
140
  * export default function Home() {
140
141
  * return (
141
142
  * <Protected
142
- * onAccessDenied={<>Only admins are allowed.</>}
143
+ * onGroupAccessDenied={() => <>Only admins are allowed.</>}
143
144
  * groups={["admin"]}
144
145
  * >
145
146
  * <>Signed in as admin</>
@@ -155,7 +156,7 @@ const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
155
156
  *
156
157
  * export default function Home() {
157
158
  * return (
158
- * <Protected onAccessDenied={<>Sign in to view the message.</>}>
159
+ * <Protected fallback={<>Sign in to view the message.</>}>
159
160
  * <>You are breathtaking</>
160
161
  * </Protected>
161
162
  * );
@@ -172,7 +173,7 @@ const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
172
173
  * export default function Home() {
173
174
  * return (
174
175
  * <Protected
175
- * onAccessDenied={<>Only admins are allowed.</>}
176
+ * onGroupAccessDenied={(user) => <>User {user?.email} is not allowed.</>}
176
177
  * groups={["admin"]}
177
178
  * >
178
179
  * <>Signed in as admin</>
@@ -182,14 +183,14 @@ const RedirectToSignIn = ({ returnUrl, ...authParams }) => {
182
183
  * ```
183
184
  *
184
185
  */
185
- const Protected = ({ children, groups, groupsClaim, matchAllGroups = false, onAccessDenied = null }) => {
186
+ const Protected = ({ children, groups, groupsClaim, matchAllGroups = false, fallback = null, onGroupAccessDenied = () => /* @__PURE__ */ React.createElement(React.Fragment, null) }) => {
186
187
  const { isLoading, error, isAuthenticated, user } = useAuth();
187
188
  if (isLoading) return null;
188
189
  if (error || !isAuthenticated || !user) {
189
- if (onAccessDenied) return /* @__PURE__ */ React.createElement(React.Fragment, null, onAccessDenied);
190
+ if (fallback) return fallback;
190
191
  return null;
191
192
  }
192
- return /* @__PURE__ */ React.createElement(React.Fragment, null, !groups || isUserInGroup(user, groups, groupsClaim ?? process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_GROUPS_CLAIM, matchAllGroups) ? children : onAccessDenied);
193
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, !groups || isUserInGroup(user, groups, groupsClaim ?? process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_GROUPS_CLAIM, matchAllGroups) ? children : onGroupAccessDenied(user));
193
194
  };
194
195
 
195
196
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/client/redirect-to-signin.tsx","../../../src/components/client/protected.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { redirectToSignIn } from '../../client/protect';\nimport { ExtraAuthParams } from '../../types';\n\n/**\n * Props for the `<RedirectToSignIn />` Component\n */\nexport interface RedirectToSignInProps extends ExtraAuthParams {\n /**\n * The url where the user will be redirected to after sign in.\n */\n returnUrl?: string;\n}\n\n/**\n * A client side component that will redirect users to the sign in page.\n *\n * **Note⚠️: Since `window.location` is set as `returnUrl` query param by default, you need to set the env `MONOCLOUD_AUTH_ALLOW_QUERY_PARAM_OVERRIDES=true` or `allowQueryParamOverrides` should be `true` in the client initialization for returning to the same page.**\n *\n * @param props - The props for customizing RedirectToSignIn\n *\n * @returns\n *\n * @example App Router\n *\n * ```tsx\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 App Router with options\n *\n * You can customize the authorization request by passing in props. See {@link RedirectToSignInProps}.\n *\n * ```tsx\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 returnUrl=\"/dashboard\" loginHint=\"username\" />;\n * }\n *\n * return <>You are signed in</>;\n * }\n * ```\n *\n * @example Pages Router\n *\n * ```tsx\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 Pages Router with options\n *\n * You can customize the authorization request by passing in props. See {@link RedirectToSignInProps}.\n *\n * ```tsx\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 returnUrl=\"/dashboard\" loginHint=\"username\" />;\n * }\n *\n * return <>You are signed in</>;\n * }\n * ```\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","import { isUserInGroup } from '@monocloud/auth-node-core/utils';\nimport React, { JSX } from 'react';\nimport { useAuth } from '../../client';\n\nexport interface ProtectedComponentProps {\n /**\n * Components that should be rendered if the user is authenticated.\n */\n children: React.ReactNode;\n\n /**\n * A list of group names or IDs to which the user must belong to. The user should belong to atleast one of the specified groups.\n */\n groups?: string[];\n\n /**\n * Name of the claim of user's groups. default: `groups`.\n */\n groupsClaim?: string;\n\n /**\n * Flag indicating if all groups specified should be present in the users profile. default: false.\n */\n matchAllGroups?: boolean;\n\n /**\n * A fallback component that should render if the user is not authenticated.\n */\n onAccessDenied?: React.ReactNode;\n}\n\n/**\n * A wrapper component that conditionally renders its children based on the user's authentication\n * status and group membership.\n *\n * **Note⚠️: The component is hidden from view. The data is present in the browser. Use server side `protectPage()` for protecting components before that data is sent to the client.**\n *\n * @param props - Props for customizing the Protected component.\n *\n * @returns The children if authorized, the `onAccessDenied` content if unauthorized,\n * or `null` while loading.\n *\n * @example App Router\n *\n * ```tsx\n * \"use client\";\n *\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected onAccessDenied={<>Sign in to view the message.</>}>\n * <>You are breathtaking</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example App Router with group options\n *\n * See {@link ProtectedComponentProps}.\n *\n * ```tsx\n * \"use client\";\n *\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected\n * onAccessDenied={<>Only admins are allowed.</>}\n * groups={[\"admin\"]}\n * >\n * <>Signed in as admin</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example Pages Router\n *\n * ```tsx\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected onAccessDenied={<>Sign in to view the message.</>}>\n * <>You are breathtaking</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example Pages Router with group options\n *\n * See {@link ProtectedComponentProps}.\n *\n * ```tsx\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected\n * onAccessDenied={<>Only admins are allowed.</>}\n * groups={[\"admin\"]}\n * >\n * <>Signed in as admin</>\n * </Protected>\n * );\n * }\n * ```\n *\n */\nexport const Protected = ({\n children,\n groups,\n groupsClaim,\n matchAllGroups = false,\n onAccessDenied = null,\n}: ProtectedComponentProps): JSX.Element | null => {\n const { isLoading, error, isAuthenticated, user } = useAuth();\n\n if (isLoading) {\n return null;\n }\n\n if (error || !isAuthenticated || !user) {\n if (onAccessDenied) {\n return <>{onAccessDenied}</>;\n }\n\n return null;\n }\n\n return (\n <>\n {!groups ||\n isUserInGroup(\n user,\n groups,\n groupsClaim ?? process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_GROUPS_CLAIM,\n matchAllGroups\n )\n ? children\n : onAccessDenied}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,MAAa,oBAAoB,EAC/B,WACA,GAAG,iBAC8B;AACjC,iBAAgB;AACd,mBAAiB;GAAE;GAAW,GAAG;GAAY,CAAC;IAC7C,CAAC,YAAY,UAAU,CAAC;AAC3B,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACKT,MAAa,aAAa,EACxB,UACA,QACA,aACA,iBAAiB,OACjB,iBAAiB,WACgC;CACjD,MAAM,EAAE,WAAW,OAAO,iBAAiB,SAAS,SAAS;AAE7D,KAAI,UACF,QAAO;AAGT,KAAI,SAAS,CAAC,mBAAmB,CAAC,MAAM;AACtC,MAAI,eACF,QAAO,0DAAG,eAAkB;AAG9B,SAAO;;AAGT,QACE,0DACG,CAAC,UACF,cACE,MACA,QACA,eAAe,QAAQ,IAAI,yCAC3B,eACD,GACG,WACA,eACH"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/client/redirect-to-signin.tsx","../../../src/components/client/protected.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { redirectToSignIn } from '../../client/protect';\nimport { ExtraAuthParams } from '../../types';\n\n/**\n * Props for the `<RedirectToSignIn />` Component\n */\nexport interface RedirectToSignInProps extends ExtraAuthParams {\n /**\n * The url where the user will be redirected to after sign in.\n */\n returnUrl?: string;\n}\n\n/**\n * A client side component that will redirect users to the sign in page.\n *\n * **Note⚠️: Since `window.location` is set as `returnUrl` query param by default, you need to set the env `MONOCLOUD_AUTH_ALLOW_QUERY_PARAM_OVERRIDES=true` or `allowQueryParamOverrides` should be `true` in the client initialization for returning to the same page.**\n *\n * @param props - The props for customizing RedirectToSignIn\n *\n * @returns\n *\n * @example App Router\n *\n * ```tsx\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 App Router with options\n *\n * You can customize the authorization request by passing in props. See {@link RedirectToSignInProps}.\n *\n * ```tsx\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 returnUrl=\"/dashboard\" loginHint=\"username\" />;\n * }\n *\n * return <>You are signed in</>;\n * }\n * ```\n *\n * @example Pages Router\n *\n * ```tsx\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 Pages Router with options\n *\n * You can customize the authorization request by passing in props. See {@link RedirectToSignInProps}.\n *\n * ```tsx\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 returnUrl=\"/dashboard\" loginHint=\"username\" />;\n * }\n *\n * return <>You are signed in</>;\n * }\n * ```\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","import { isUserInGroup } from '@monocloud/auth-node-core/utils';\nimport React from 'react';\nimport { useAuth } from '../../client';\nimport type { MonoCloudUser } from '@monocloud/auth-node-core';\n\nexport interface ProtectedComponentProps {\n /**\n * Components that should be rendered if the user is authenticated.\n */\n children: React.ReactNode;\n\n /**\n * A list of group names or IDs to which the user must belong to. The user should belong to atleast one of the specified groups.\n */\n groups?: string[];\n\n /**\n * Name of the claim of user's groups. default: `groups`.\n */\n groupsClaim?: string;\n\n /**\n * Flag indicating if all groups specified should be present in the users profile. default: false.\n */\n matchAllGroups?: boolean;\n\n /**\n * A fallback component that should render if the user is not authenticated.\n */\n fallback?: React.ReactNode;\n\n /**\n * A fallback component that should render if the user is authenticated but does not belong to the required groups.\n */\n onGroupAccessDenied?: (user?: MonoCloudUser) => React.ReactNode;\n}\n\n/**\n * A wrapper component that conditionally renders its children based on the user's authentication\n * status and group membership.\n *\n * **Note⚠️: The component is hidden from view. The data is present in the browser. Use server side `protectPage()` for protecting components before that data is sent to the client.**\n *\n * @param props - Props for customizing the Protected component.\n *\n * @returns The children if authorized, the `fallback` or `onGroupAccessDenied` content if unauthenticated or unauthorized,\n * or `null` while loading.\n *\n * @example App Router\n *\n * ```tsx\n * \"use client\";\n *\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected fallback={<>Sign in to view the message.</>}>\n * <>You are breathtaking</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example App Router with group options\n *\n * See {@link ProtectedComponentProps}.\n *\n * ```tsx\n * \"use client\";\n *\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected\n * onGroupAccessDenied={() => <>Only admins are allowed.</>}\n * groups={[\"admin\"]}\n * >\n * <>Signed in as admin</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example Pages Router\n *\n * ```tsx\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected fallback={<>Sign in to view the message.</>}>\n * <>You are breathtaking</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example Pages Router with group options\n *\n * See {@link ProtectedComponentProps}.\n *\n * ```tsx\n * import { Protected } from \"@monocloud/auth-nextjs/components/client\";\n *\n * export default function Home() {\n * return (\n * <Protected\n * onGroupAccessDenied={(user) => <>User {user?.email} is not allowed.</>}\n * groups={[\"admin\"]}\n * >\n * <>Signed in as admin</>\n * </Protected>\n * );\n * }\n * ```\n *\n */\nexport const Protected = ({\n children,\n groups,\n groupsClaim,\n matchAllGroups = false,\n fallback = null,\n onGroupAccessDenied = (): React.ReactNode => <></>,\n}: ProtectedComponentProps): React.ReactNode | null => {\n const { isLoading, error, isAuthenticated, user } = useAuth();\n\n if (isLoading) {\n return null;\n }\n\n if (error || !isAuthenticated || !user) {\n if (fallback) {\n return fallback;\n }\n\n return null;\n }\n\n return (\n <>\n {!groups ||\n isUserInGroup(\n user,\n groups,\n groupsClaim ?? process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_GROUPS_CLAIM,\n matchAllGroups\n )\n ? children\n : onGroupAccessDenied(user)}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,MAAa,oBAAoB,EAC/B,WACA,GAAG,iBAC8B;AACjC,iBAAgB;AACd,mBAAiB;GAAE;GAAW,GAAG;GAAY,CAAC;IAC7C,CAAC,YAAY,UAAU,CAAC;AAC3B,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACWT,MAAa,aAAa,EACxB,UACA,QACA,aACA,iBAAiB,OACjB,WAAW,MACX,4BAA6C,yDAAK,OACG;CACrD,MAAM,EAAE,WAAW,OAAO,iBAAiB,SAAS,SAAS;AAE7D,KAAI,UACF,QAAO;AAGT,KAAI,SAAS,CAAC,mBAAmB,CAAC,MAAM;AACtC,MAAI,SACF,QAAO;AAGT,SAAO;;AAGT,QACE,0DACG,CAAC,UACF,cACE,MACA,QACA,eAAe,QAAQ,IAAI,yCAC3B,eACD,GACG,WACA,oBAAoB,KAAK,CAC5B"}
@@ -1,4 +1,5 @@
1
- const require_chunk = require('../chunk-CbDLau6x.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_chunk = require('../chunk-C0xms8kb.cjs');
2
3
  let react = require("react");
3
4
  react = require_chunk.__toESM(react);
4
5
 
@@ -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, { JSX } from 'react';\nimport { ExtraAuthParams } from '../types';\n\nexport interface SignInProps extends ExtraAuthParams {\n children: React.ReactNode;\n /**\n * URL to redirect to after a successful sign-in.\n */\n returnUrl?: string;\n}\n\n/**\n * A component that renders an anchor tag configured to initiate the sign-in flow.\n *\n * @param props - Properties for the SignIn component.\n *\n * @returns An anchor element that links to the sign-in endpoint with the specified parameters.\n *\n * @example App Router and Pages Router\n *\n * **Sign-in component works on both the server and the client in pages router and app router.**\n *\n * ```tsx\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 in props. See {@link SignInProps}.\n *\n * **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**\n *\n * ```tsx\n * import { SignIn } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return (\n * <SignIn loginHint=\"username\" authenticatorHint=\"password\">\n * Sign In\n * </SignIn>\n * );\n * }\n * ```\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 >): JSX.Element => {\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, { JSX } from 'react';\nimport { ExtraAuthParams } from '../types';\n\nexport interface SignUpProps extends Omit<\n ExtraAuthParams,\n 'authenticatorHint' | 'loginHint' | 'prompt'\n> {\n /**\n * URL to redirect to after a successful sign-up.\n */\n returnUrl?: string;\n}\n\n/**\n * A component that renders an anchor tag configured to initiate the sign-up flow.\n * * It functions similarly to the SignIn component but explicitly sets the `prompt` parameter to `create`.\n *\n * @param props - Properties for the SignUp component.\n *\n * @returns An anchor element that links to the sign-in endpoint with the prompt set to 'create'.\n *\n * @example App Router and Pages Router\n *\n * **Sign-up component works on both the server and the client in pages router and app router.**\n *\n * ```tsx\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. See {@link SignUpProps}.\n *\n * **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**\n *\n * ```tsx\n * import { SignUp } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignUp returnUrl=\"/dashboard\">Sign Up</SignUp>;\n * }\n * ```\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 >): JSX.Element => {\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, { JSX } from 'react';\n\nexport interface SignOutProps {\n /** URL to redirect the user to after they have been signed out. */\n postLogoutUrl?: string;\n\n /** Whether to also sign out the user from MonoCloud */\n federated?: boolean;\n}\n\n/**\n * A component that renders an anchor tag configured to initiate the sign-out flow.\n *\n * @param props - Properties for the SignOut component.\n *\n * @returns An anchor element that links to the sign-out endpoint.\n *\n * @example App Router and Pages Router\n *\n * **Sign-out component works on both the server and the client in pages router and app router.**\n *\n * ```tsx\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 request\n *\n * You can customize the request by passing in props. See {@link SignOutProps}.\n *\n * **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**\n *\n * ```tsx\n * import { SignOut } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignOut federated={true}>Sign Out</SignOut>;\n * }\n * ```\n */\nexport const SignOut = ({\n children,\n postLogoutUrl,\n federated,\n ...props\n}: SignOutProps &\n React.AnchorHTMLAttributes<HTMLAnchorElement>): JSX.Element => {\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,UAAU,EACrB,UACA,mBACA,WACA,QACA,SACA,WACA,QACA,WACA,UACA,QACA,WACA,GAAG,YAKgB;CACnB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACxER,MAAa,UAAU,EACrB,UACA,WACA,WACA,SACA,QACA,UACA,QACA,WACA,GAAG,YAKgB;CACnB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC/DR,MAAa,WAAW,EACtB,UACA,eACA,WACA,GAAG,YAE4D;CAC/D,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
+ {"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 a successful sign-in.\n */\n returnUrl?: string;\n}\n\n/**\n * A component that renders an anchor tag configured to initiate the sign-in flow.\n *\n * @param props - Properties for the SignIn component.\n *\n * @returns An anchor element that links to the sign-in endpoint with the specified parameters.\n *\n * @example App Router and Pages Router\n *\n * **Sign-in component works on both the server and the client in pages router and app router.**\n *\n * ```tsx\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 in props. See {@link SignInProps}.\n *\n * **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**\n *\n * ```tsx\n * import { SignIn } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return (\n * <SignIn loginHint=\"username\" authenticatorHint=\"password\">\n * Sign In\n * </SignIn>\n * );\n * }\n * ```\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\nexport interface SignUpProps extends Omit<\n ExtraAuthParams,\n 'authenticatorHint' | 'loginHint' | 'prompt'\n> {\n /**\n * URL to redirect to after a successful sign-up.\n */\n returnUrl?: string;\n}\n\n/**\n * A component that renders an anchor tag configured to initiate the sign-up flow.\n * * It functions similarly to the SignIn component but explicitly sets the `prompt` parameter to `create`.\n *\n * @param props - Properties for the SignUp component.\n *\n * @returns An anchor element that links to the sign-in endpoint with the prompt set to 'create'.\n *\n * @example App Router and Pages Router\n *\n * **Sign-up component works on both the server and the client in pages router and app router.**\n *\n * ```tsx\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. See {@link SignUpProps}.\n *\n * **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**\n *\n * ```tsx\n * import { SignUp } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignUp returnUrl=\"/dashboard\">Sign Up</SignUp>;\n * }\n * ```\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\nexport interface SignOutProps {\n /** URL to redirect the user to after they have been signed out. */\n postLogoutUrl?: string;\n\n /** Whether to also sign out the user from MonoCloud */\n federated?: boolean;\n}\n\n/**\n * A component that renders an anchor tag configured to initiate the sign-out flow.\n *\n * @param props - Properties for the SignOut component.\n *\n * @returns An anchor element that links to the sign-out endpoint.\n *\n * @example App Router and Pages Router\n *\n * **Sign-out component works on both the server and the client in pages router and app router.**\n *\n * ```tsx\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 request\n *\n * You can customize the request by passing in props. See {@link SignOutProps}.\n *\n * **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**\n *\n * ```tsx\n * import { SignOut } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignOut federated={true}>Sign Out</SignOut>;\n * }\n * ```\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACxER,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC/DR,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,5 +1,5 @@
1
- import { i as ExtraAuthParams } from "../types-DOfZTKa6.mjs";
2
- import React, { JSX } from "react";
1
+ import { i as ExtraAuthParams } from "../types-Cx32VRoI.mjs";
2
+ import React from "react";
3
3
 
4
4
  //#region src/components/signin.d.ts
5
5
  interface SignInProps extends ExtraAuthParams {
@@ -59,7 +59,7 @@ declare const SignIn: ({
59
59
  maxAge,
60
60
  returnUrl,
61
61
  ...props
62
- }: SignInProps & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "resource">) => JSX.Element;
62
+ }: SignInProps & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "resource">) => React.ReactNode;
63
63
  //#endregion
64
64
  //#region src/components/signup.d.ts
65
65
  interface SignUpProps extends Omit<ExtraAuthParams, 'authenticatorHint' | 'loginHint' | 'prompt'> {
@@ -112,7 +112,7 @@ declare const SignUp: ({
112
112
  scopes,
113
113
  uiLocales,
114
114
  ...props
115
- }: SignUpProps & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "resource">) => JSX.Element;
115
+ }: SignUpProps & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "resource">) => React.ReactNode;
116
116
  //#endregion
117
117
  //#region src/components/signout.d.ts
118
118
  interface SignOutProps {
@@ -159,7 +159,7 @@ declare const SignOut: ({
159
159
  postLogoutUrl,
160
160
  federated,
161
161
  ...props
162
- }: SignOutProps & React.AnchorHTMLAttributes<HTMLAnchorElement>) => JSX.Element;
162
+ }: SignOutProps & React.AnchorHTMLAttributes<HTMLAnchorElement>) => React.ReactNode;
163
163
  //#endregion
164
164
  export { SignIn, type SignInProps, SignOut, type SignOutProps, SignUp, type SignUpProps };
165
165
  //# sourceMappingURL=index.d.mts.map
@@ -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, { JSX } from 'react';\nimport { ExtraAuthParams } from '../types';\n\nexport interface SignInProps extends ExtraAuthParams {\n children: React.ReactNode;\n /**\n * URL to redirect to after a successful sign-in.\n */\n returnUrl?: string;\n}\n\n/**\n * A component that renders an anchor tag configured to initiate the sign-in flow.\n *\n * @param props - Properties for the SignIn component.\n *\n * @returns An anchor element that links to the sign-in endpoint with the specified parameters.\n *\n * @example App Router and Pages Router\n *\n * **Sign-in component works on both the server and the client in pages router and app router.**\n *\n * ```tsx\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 in props. See {@link SignInProps}.\n *\n * **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**\n *\n * ```tsx\n * import { SignIn } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return (\n * <SignIn loginHint=\"username\" authenticatorHint=\"password\">\n * Sign In\n * </SignIn>\n * );\n * }\n * ```\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 >): JSX.Element => {\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, { JSX } from 'react';\nimport { ExtraAuthParams } from '../types';\n\nexport interface SignUpProps extends Omit<\n ExtraAuthParams,\n 'authenticatorHint' | 'loginHint' | 'prompt'\n> {\n /**\n * URL to redirect to after a successful sign-up.\n */\n returnUrl?: string;\n}\n\n/**\n * A component that renders an anchor tag configured to initiate the sign-up flow.\n * * It functions similarly to the SignIn component but explicitly sets the `prompt` parameter to `create`.\n *\n * @param props - Properties for the SignUp component.\n *\n * @returns An anchor element that links to the sign-in endpoint with the prompt set to 'create'.\n *\n * @example App Router and Pages Router\n *\n * **Sign-up component works on both the server and the client in pages router and app router.**\n *\n * ```tsx\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. See {@link SignUpProps}.\n *\n * **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**\n *\n * ```tsx\n * import { SignUp } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignUp returnUrl=\"/dashboard\">Sign Up</SignUp>;\n * }\n * ```\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 >): JSX.Element => {\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, { JSX } from 'react';\n\nexport interface SignOutProps {\n /** URL to redirect the user to after they have been signed out. */\n postLogoutUrl?: string;\n\n /** Whether to also sign out the user from MonoCloud */\n federated?: boolean;\n}\n\n/**\n * A component that renders an anchor tag configured to initiate the sign-out flow.\n *\n * @param props - Properties for the SignOut component.\n *\n * @returns An anchor element that links to the sign-out endpoint.\n *\n * @example App Router and Pages Router\n *\n * **Sign-out component works on both the server and the client in pages router and app router.**\n *\n * ```tsx\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 request\n *\n * You can customize the request by passing in props. See {@link SignOutProps}.\n *\n * **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**\n *\n * ```tsx\n * import { SignOut } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignOut federated={true}>Sign Out</SignOut>;\n * }\n * ```\n */\nexport const SignOut = ({\n children,\n postLogoutUrl,\n federated,\n ...props\n}: SignOutProps &\n React.AnchorHTMLAttributes<HTMLAnchorElement>): JSX.Element => {\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,UAAU,EACrB,UACA,mBACA,WACA,QACA,SACA,WACA,QACA,WACA,UACA,QACA,WACA,GAAG,YAKgB;CACnB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACxER,MAAa,UAAU,EACrB,UACA,WACA,WACA,SACA,QACA,UACA,QACA,WACA,GAAG,YAKgB;CACnB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC/DR,MAAa,WAAW,EACtB,UACA,eACA,WACA,GAAG,YAE4D;CAC/D,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"}
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 a successful sign-in.\n */\n returnUrl?: string;\n}\n\n/**\n * A component that renders an anchor tag configured to initiate the sign-in flow.\n *\n * @param props - Properties for the SignIn component.\n *\n * @returns An anchor element that links to the sign-in endpoint with the specified parameters.\n *\n * @example App Router and Pages Router\n *\n * **Sign-in component works on both the server and the client in pages router and app router.**\n *\n * ```tsx\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 in props. See {@link SignInProps}.\n *\n * **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**\n *\n * ```tsx\n * import { SignIn } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return (\n * <SignIn loginHint=\"username\" authenticatorHint=\"password\">\n * Sign In\n * </SignIn>\n * );\n * }\n * ```\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\nexport interface SignUpProps extends Omit<\n ExtraAuthParams,\n 'authenticatorHint' | 'loginHint' | 'prompt'\n> {\n /**\n * URL to redirect to after a successful sign-up.\n */\n returnUrl?: string;\n}\n\n/**\n * A component that renders an anchor tag configured to initiate the sign-up flow.\n * * It functions similarly to the SignIn component but explicitly sets the `prompt` parameter to `create`.\n *\n * @param props - Properties for the SignUp component.\n *\n * @returns An anchor element that links to the sign-in endpoint with the prompt set to 'create'.\n *\n * @example App Router and Pages Router\n *\n * **Sign-up component works on both the server and the client in pages router and app router.**\n *\n * ```tsx\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. See {@link SignUpProps}.\n *\n * **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**\n *\n * ```tsx\n * import { SignUp } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignUp returnUrl=\"/dashboard\">Sign Up</SignUp>;\n * }\n * ```\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\nexport interface SignOutProps {\n /** URL to redirect the user to after they have been signed out. */\n postLogoutUrl?: string;\n\n /** Whether to also sign out the user from MonoCloud */\n federated?: boolean;\n}\n\n/**\n * A component that renders an anchor tag configured to initiate the sign-out flow.\n *\n * @param props - Properties for the SignOut component.\n *\n * @returns An anchor element that links to the sign-out endpoint.\n *\n * @example App Router and Pages Router\n *\n * **Sign-out component works on both the server and the client in pages router and app router.**\n *\n * ```tsx\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 request\n *\n * You can customize the request by passing in props. See {@link SignOutProps}.\n *\n * **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**\n *\n * ```tsx\n * import { SignOut } from \"@monocloud/auth-nextjs/components\";\n *\n * export default function Home() {\n * return <SignOut federated={true}>Sign Out</SignOut>;\n * }\n * ```\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACxER,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC/DR,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"}