@monocloud/auth-nextjs 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunk-C0xms8kb.cjs → _virtual/_rolldown/runtime.cjs} +1 -6
- package/dist/client/index.cjs +3 -2
- package/dist/client/index.d.mts +3 -203
- package/dist/client/index.mjs +2 -1
- package/dist/{protect-client-page-BdsnH8gs.cjs → client/protect-client-page.cjs} +9 -112
- package/dist/client/protect-client-page.cjs.map +1 -0
- package/dist/client/protect-client-page.d.mts +123 -0
- package/dist/{protect-client-page-BFVskb3X.mjs → client/protect-client-page.mjs} +5 -91
- package/dist/client/protect-client-page.mjs.map +1 -0
- package/dist/client/use-auth.cjs +96 -0
- package/dist/client/use-auth.cjs.map +1 -0
- package/dist/client/use-auth.d.mts +84 -0
- package/dist/client/use-auth.mjs +94 -0
- package/dist/client/use-auth.mjs.map +1 -0
- package/dist/components/client/index.cjs +4 -156
- package/dist/components/client/index.d.mts +3 -189
- package/dist/components/client/index.mjs +3 -153
- package/dist/components/client/protected.cjs +89 -0
- package/dist/components/client/protected.cjs.map +1 -0
- package/dist/components/client/protected.d.mts +114 -0
- package/dist/components/client/protected.mjs +87 -0
- package/dist/components/client/protected.mjs.map +1 -0
- package/dist/components/client/redirect-to-signin.cjs +77 -0
- package/dist/components/client/redirect-to-signin.cjs.map +1 -0
- package/dist/components/client/redirect-to-signin.d.mts +78 -0
- package/dist/components/client/redirect-to-signin.mjs +76 -0
- package/dist/components/client/redirect-to-signin.mjs.map +1 -0
- package/dist/components/index.cjs +6 -168
- package/dist/components/index.d.mts +4 -188
- package/dist/components/index.mjs +4 -164
- package/dist/components/signin.cjs +63 -0
- package/dist/components/signin.cjs.map +1 -0
- package/dist/components/signin.d.mts +72 -0
- package/dist/components/signin.mjs +61 -0
- package/dist/components/signin.mjs.map +1 -0
- package/dist/components/signout.cjs +49 -0
- package/dist/components/signout.cjs.map +1 -0
- package/dist/components/signout.d.mts +55 -0
- package/dist/components/signout.mjs +47 -0
- package/dist/components/signout.mjs.map +1 -0
- package/dist/components/signup.cjs +67 -0
- package/dist/components/signup.cjs.map +1 -0
- package/dist/components/signup.d.mts +70 -0
- package/dist/components/signup.mjs +65 -0
- package/dist/components/signup.mjs.map +1 -0
- package/dist/index.cjs +15 -1136
- package/dist/index.d.mts +5 -1681
- package/dist/index.mjs +4 -1125
- package/dist/initialize.cjs +284 -0
- package/dist/initialize.cjs.map +1 -0
- package/dist/initialize.d.mts +1383 -0
- package/dist/initialize.mjs +274 -0
- package/dist/initialize.mjs.map +1 -0
- package/dist/monocloud-next-client.cjs +600 -0
- package/dist/monocloud-next-client.cjs.map +1 -0
- package/dist/monocloud-next-client.d.mts +330 -0
- package/dist/monocloud-next-client.mjs +599 -0
- package/dist/monocloud-next-client.mjs.map +1 -0
- package/dist/requests/monocloud-app-router-request.cjs +32 -0
- package/dist/requests/monocloud-app-router-request.cjs.map +1 -0
- package/dist/requests/monocloud-app-router-request.mjs +31 -0
- package/dist/requests/monocloud-app-router-request.mjs.map +1 -0
- package/dist/requests/monocloud-cookie-request.cjs +22 -0
- package/dist/requests/monocloud-cookie-request.cjs.map +1 -0
- package/dist/requests/monocloud-cookie-request.mjs +21 -0
- package/dist/requests/monocloud-cookie-request.mjs.map +1 -0
- package/dist/requests/monocloud-page-router-request.cjs +37 -0
- package/dist/requests/monocloud-page-router-request.cjs.map +1 -0
- package/dist/requests/monocloud-page-router-request.mjs +36 -0
- package/dist/requests/monocloud-page-router-request.mjs.map +1 -0
- package/dist/responses/monocloud-app-router-response.cjs +67 -0
- package/dist/responses/monocloud-app-router-response.cjs.map +1 -0
- package/dist/responses/monocloud-app-router-response.mjs +66 -0
- package/dist/responses/monocloud-app-router-response.mjs.map +1 -0
- package/dist/responses/monocloud-cookie-response.cjs +20 -0
- package/dist/responses/monocloud-cookie-response.cjs.map +1 -0
- package/dist/responses/monocloud-cookie-response.mjs +19 -0
- package/dist/responses/monocloud-cookie-response.mjs.map +1 -0
- package/dist/responses/monocloud-page-router-response.cjs +54 -0
- package/dist/responses/monocloud-page-router-response.cjs.map +1 -0
- package/dist/responses/monocloud-page-router-response.mjs +53 -0
- package/dist/responses/monocloud-page-router-response.mjs.map +1 -0
- package/dist/{types-ClljFIvK.d.mts → types.d.mts} +2 -2
- package/dist/utils.cjs +89 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.mjs +80 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/components/client/index.cjs.map +0 -1
- package/dist/components/client/index.mjs.map +0 -1
- package/dist/components/index.cjs.map +0 -1
- package/dist/components/index.mjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/protect-client-page-BFVskb3X.mjs.map +0 -1
- package/dist/protect-client-page-BdsnH8gs.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signin.cjs","names":[],"sources":["../../src/components/signin.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"],"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"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ExtraAuthParams } from "../types.mjs";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/signin.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Props for the `<SignIn />` component.
|
|
7
|
+
*
|
|
8
|
+
* @category Types
|
|
9
|
+
*/
|
|
10
|
+
interface SignInProps extends ExtraAuthParams {
|
|
11
|
+
/**
|
|
12
|
+
* Content rendered inside the link (for example, button text).
|
|
13
|
+
*/
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* URL to redirect to after successful sign-in.
|
|
17
|
+
*/
|
|
18
|
+
returnUrl?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* `<SignIn>` renders a link that initiates the MonoCloud sign-in flow.
|
|
22
|
+
*
|
|
23
|
+
* It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
24
|
+
*
|
|
25
|
+
* @example Basic Usage
|
|
26
|
+
*
|
|
27
|
+
* ```tsx title="Basic Usage"
|
|
28
|
+
* import { SignIn } from "@monocloud/auth-nextjs/components";
|
|
29
|
+
*
|
|
30
|
+
* export default function Home() {
|
|
31
|
+
* return <SignIn>Sign In</SignIn>;
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example Customize the authorization request
|
|
36
|
+
*
|
|
37
|
+
* You can customize the authorization request by passing props:
|
|
38
|
+
*
|
|
39
|
+
* ```tsx title="Customize the authorization request"
|
|
40
|
+
* import { SignIn } from "@monocloud/auth-nextjs/components";
|
|
41
|
+
*
|
|
42
|
+
* export default function Home() {
|
|
43
|
+
* return (
|
|
44
|
+
* <SignIn loginHint="user@example.com" authenticatorHint="password" returnUrl="/dashboard">
|
|
45
|
+
* Sign In
|
|
46
|
+
* </SignIn>
|
|
47
|
+
* );
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param props - Properties for the SignIn component.
|
|
52
|
+
* @returns An anchor element that links to the sign-in endpoint with the specified parameters.
|
|
53
|
+
*
|
|
54
|
+
* @category Components
|
|
55
|
+
*/
|
|
56
|
+
declare const SignIn: ({
|
|
57
|
+
children,
|
|
58
|
+
authenticatorHint,
|
|
59
|
+
loginHint,
|
|
60
|
+
prompt,
|
|
61
|
+
display,
|
|
62
|
+
uiLocales,
|
|
63
|
+
scopes,
|
|
64
|
+
acrValues,
|
|
65
|
+
resource,
|
|
66
|
+
maxAge,
|
|
67
|
+
returnUrl,
|
|
68
|
+
...props
|
|
69
|
+
}: SignInProps & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "resource">) => React.ReactNode;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { SignIn, SignInProps };
|
|
72
|
+
//# sourceMappingURL=signin.d.mts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/signin.tsx
|
|
4
|
+
/**
|
|
5
|
+
* `<SignIn>` renders a link that initiates the MonoCloud sign-in flow.
|
|
6
|
+
*
|
|
7
|
+
* It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
8
|
+
*
|
|
9
|
+
* @example Basic Usage
|
|
10
|
+
*
|
|
11
|
+
* ```tsx title="Basic Usage"
|
|
12
|
+
* import { SignIn } from "@monocloud/auth-nextjs/components";
|
|
13
|
+
*
|
|
14
|
+
* export default function Home() {
|
|
15
|
+
* return <SignIn>Sign In</SignIn>;
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example Customize the authorization request
|
|
20
|
+
*
|
|
21
|
+
* You can customize the authorization request by passing props:
|
|
22
|
+
*
|
|
23
|
+
* ```tsx title="Customize the authorization request"
|
|
24
|
+
* import { SignIn } from "@monocloud/auth-nextjs/components";
|
|
25
|
+
*
|
|
26
|
+
* export default function Home() {
|
|
27
|
+
* return (
|
|
28
|
+
* <SignIn loginHint="user@example.com" authenticatorHint="password" returnUrl="/dashboard">
|
|
29
|
+
* Sign In
|
|
30
|
+
* </SignIn>
|
|
31
|
+
* );
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @param props - Properties for the SignIn component.
|
|
36
|
+
* @returns An anchor element that links to the sign-in endpoint with the specified parameters.
|
|
37
|
+
*
|
|
38
|
+
* @category Components
|
|
39
|
+
*/
|
|
40
|
+
const SignIn = ({ children, authenticatorHint, loginHint, prompt, display, uiLocales, scopes, acrValues, resource, maxAge, returnUrl, ...props }) => {
|
|
41
|
+
const signInUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signin`;
|
|
42
|
+
const query = new URLSearchParams();
|
|
43
|
+
if (authenticatorHint) query.set("authenticator_hint", authenticatorHint);
|
|
44
|
+
if (prompt) query.set("prompt", prompt);
|
|
45
|
+
if (display) query.set("display", display);
|
|
46
|
+
if (uiLocales) query.set("ui_locales", uiLocales);
|
|
47
|
+
if (scopes) query.set("scope", scopes);
|
|
48
|
+
if (acrValues) query.set("acr_values", acrValues.join(" "));
|
|
49
|
+
if (resource) query.set("resource", resource);
|
|
50
|
+
if (maxAge) query.set("max_age", maxAge.toString());
|
|
51
|
+
if (loginHint) query.set("login_hint", loginHint);
|
|
52
|
+
if (returnUrl) query.set("return_url", returnUrl);
|
|
53
|
+
return /* @__PURE__ */ React.createElement("a", {
|
|
54
|
+
href: `${signInUrl}${query.size ? `?${query.toString()}` : ""}`,
|
|
55
|
+
...props
|
|
56
|
+
}, children);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { SignIn };
|
|
61
|
+
//# sourceMappingURL=signin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signin.mjs","names":[],"sources":["../../src/components/signin.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"],"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"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
let react = require("react");
|
|
3
|
+
react = require_runtime.__toESM(react);
|
|
4
|
+
|
|
5
|
+
//#region src/components/signout.tsx
|
|
6
|
+
/**
|
|
7
|
+
* `<SignOut>` renders a link that initiates the MonoCloud sign-out flow.
|
|
8
|
+
*
|
|
9
|
+
* It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
10
|
+
*
|
|
11
|
+
* @example Basic usage
|
|
12
|
+
*
|
|
13
|
+
* ```tsx title="Basic Usage"
|
|
14
|
+
* import { SignOut } from "@monocloud/auth-nextjs/components";
|
|
15
|
+
*
|
|
16
|
+
* export default function Home() {
|
|
17
|
+
* return <SignOut>Sign Out</SignOut>;
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example Customize the sign-out request
|
|
22
|
+
*
|
|
23
|
+
* ```tsx title="Customize the sign-out request"
|
|
24
|
+
* import { SignOut } from "@monocloud/auth-nextjs/components";
|
|
25
|
+
*
|
|
26
|
+
* export default function Home() {
|
|
27
|
+
* return <SignOut federated postLogoutUrl="/goodbye">Sign Out</SignOut>;
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param props - Properties for the SignOut component.
|
|
32
|
+
* @returns An anchor element that links to the sign-out endpoint.
|
|
33
|
+
*
|
|
34
|
+
* @category Components
|
|
35
|
+
*/
|
|
36
|
+
const SignOut = ({ children, postLogoutUrl, federated, ...props }) => {
|
|
37
|
+
const signOutUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNOUT_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signout`;
|
|
38
|
+
const query = new URLSearchParams();
|
|
39
|
+
if (postLogoutUrl) query.set("post_logout_url", postLogoutUrl);
|
|
40
|
+
if (typeof federated === "boolean") query.set("federated", federated.toString());
|
|
41
|
+
return /* @__PURE__ */ react.default.createElement("a", {
|
|
42
|
+
href: `${signOutUrl}${query.size ? `?${query.toString()}` : ""}`,
|
|
43
|
+
...props
|
|
44
|
+
}, children);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
exports.SignOut = SignOut;
|
|
49
|
+
//# sourceMappingURL=signout.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signout.cjs","names":[],"sources":["../../src/components/signout.tsx"],"sourcesContent":["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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,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"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/signout.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Props for the `<SignOut />` component.
|
|
6
|
+
*
|
|
7
|
+
* @category Types
|
|
8
|
+
*/
|
|
9
|
+
interface SignOutProps {
|
|
10
|
+
/** Content rendered inside the link (for example, button text). */
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
/** URL to redirect the user to after they have been signed out. */
|
|
13
|
+
postLogoutUrl?: string;
|
|
14
|
+
/** 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. */
|
|
15
|
+
federated?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `<SignOut>` renders a link that initiates the MonoCloud sign-out flow.
|
|
19
|
+
*
|
|
20
|
+
* It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
21
|
+
*
|
|
22
|
+
* @example Basic usage
|
|
23
|
+
*
|
|
24
|
+
* ```tsx title="Basic Usage"
|
|
25
|
+
* import { SignOut } from "@monocloud/auth-nextjs/components";
|
|
26
|
+
*
|
|
27
|
+
* export default function Home() {
|
|
28
|
+
* return <SignOut>Sign Out</SignOut>;
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example Customize the sign-out request
|
|
33
|
+
*
|
|
34
|
+
* ```tsx title="Customize the sign-out request"
|
|
35
|
+
* import { SignOut } from "@monocloud/auth-nextjs/components";
|
|
36
|
+
*
|
|
37
|
+
* export default function Home() {
|
|
38
|
+
* return <SignOut federated postLogoutUrl="/goodbye">Sign Out</SignOut>;
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param props - Properties for the SignOut component.
|
|
43
|
+
* @returns An anchor element that links to the sign-out endpoint.
|
|
44
|
+
*
|
|
45
|
+
* @category Components
|
|
46
|
+
*/
|
|
47
|
+
declare const SignOut: ({
|
|
48
|
+
children,
|
|
49
|
+
postLogoutUrl,
|
|
50
|
+
federated,
|
|
51
|
+
...props
|
|
52
|
+
}: SignOutProps & React.AnchorHTMLAttributes<HTMLAnchorElement>) => React.ReactNode;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { SignOut, SignOutProps };
|
|
55
|
+
//# sourceMappingURL=signout.d.mts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/signout.tsx
|
|
4
|
+
/**
|
|
5
|
+
* `<SignOut>` renders a link that initiates the MonoCloud sign-out flow.
|
|
6
|
+
*
|
|
7
|
+
* It can be used in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
8
|
+
*
|
|
9
|
+
* @example Basic usage
|
|
10
|
+
*
|
|
11
|
+
* ```tsx title="Basic Usage"
|
|
12
|
+
* import { SignOut } from "@monocloud/auth-nextjs/components";
|
|
13
|
+
*
|
|
14
|
+
* export default function Home() {
|
|
15
|
+
* return <SignOut>Sign Out</SignOut>;
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example Customize the sign-out request
|
|
20
|
+
*
|
|
21
|
+
* ```tsx title="Customize the sign-out request"
|
|
22
|
+
* import { SignOut } from "@monocloud/auth-nextjs/components";
|
|
23
|
+
*
|
|
24
|
+
* export default function Home() {
|
|
25
|
+
* return <SignOut federated postLogoutUrl="/goodbye">Sign Out</SignOut>;
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param props - Properties for the SignOut component.
|
|
30
|
+
* @returns An anchor element that links to the sign-out endpoint.
|
|
31
|
+
*
|
|
32
|
+
* @category Components
|
|
33
|
+
*/
|
|
34
|
+
const SignOut = ({ children, postLogoutUrl, federated, ...props }) => {
|
|
35
|
+
const signOutUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNOUT_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signout`;
|
|
36
|
+
const query = new URLSearchParams();
|
|
37
|
+
if (postLogoutUrl) query.set("post_logout_url", postLogoutUrl);
|
|
38
|
+
if (typeof federated === "boolean") query.set("federated", federated.toString());
|
|
39
|
+
return /* @__PURE__ */ React.createElement("a", {
|
|
40
|
+
href: `${signOutUrl}${query.size ? `?${query.toString()}` : ""}`,
|
|
41
|
+
...props
|
|
42
|
+
}, children);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { SignOut };
|
|
47
|
+
//# sourceMappingURL=signout.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signout.mjs","names":[],"sources":["../../src/components/signout.tsx"],"sourcesContent":["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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,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"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
let react = require("react");
|
|
3
|
+
react = require_runtime.__toESM(react);
|
|
4
|
+
|
|
5
|
+
//#region src/components/signup.tsx
|
|
6
|
+
/**
|
|
7
|
+
* `<SignUp>` renders a link that initiates the MonoCloud sign-up flow.
|
|
8
|
+
*
|
|
9
|
+
* It works in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
10
|
+
*
|
|
11
|
+
* Internally, it behaves like `<SignIn>` but sets `prompt=create` to start the registration flow.
|
|
12
|
+
*
|
|
13
|
+
* @example Basic usage
|
|
14
|
+
*
|
|
15
|
+
* ```tsx title="Basic Usage"
|
|
16
|
+
* import { SignUp } from "@monocloud/auth-nextjs/components";
|
|
17
|
+
*
|
|
18
|
+
* export default function Home() {
|
|
19
|
+
* return <SignUp>Sign Up</SignUp>;
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example Customize the authorization request
|
|
24
|
+
*
|
|
25
|
+
* You can customize the authorization request by passing in props.
|
|
26
|
+
*
|
|
27
|
+
* ```tsx title="Customize the authorization request"
|
|
28
|
+
* import { SignUp } from "@monocloud/auth-nextjs/components";
|
|
29
|
+
*
|
|
30
|
+
* export default function Home() {
|
|
31
|
+
* return (
|
|
32
|
+
* <SignUp
|
|
33
|
+
* returnUrl="/dashboard"
|
|
34
|
+
* uiLocales="en"
|
|
35
|
+
* >
|
|
36
|
+
* Sign Up
|
|
37
|
+
* </SignUp>
|
|
38
|
+
* );
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param props - Properties for the SignUp component.
|
|
43
|
+
* @returns An anchor element that links to the sign-in endpoint with the prompt set to 'create'.
|
|
44
|
+
*
|
|
45
|
+
* @category Components
|
|
46
|
+
*/
|
|
47
|
+
const SignUp = ({ children, returnUrl, acrValues, display, maxAge, resource, scopes, uiLocales, ...props }) => {
|
|
48
|
+
const signInUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signin`;
|
|
49
|
+
const query = new URLSearchParams();
|
|
50
|
+
query.set("prompt", "create");
|
|
51
|
+
if (returnUrl) query.set("return_url", returnUrl);
|
|
52
|
+
if (display) query.set("display", display);
|
|
53
|
+
if (uiLocales) query.set("ui_locales", uiLocales);
|
|
54
|
+
if (scopes) query.set("scope", scopes);
|
|
55
|
+
if (acrValues) query.set("acr_values", acrValues.join(" "));
|
|
56
|
+
if (resource) query.set("resource", resource);
|
|
57
|
+
if (maxAge) query.set("max_age", maxAge.toString());
|
|
58
|
+
if (returnUrl) query.set("return_url", returnUrl);
|
|
59
|
+
return /* @__PURE__ */ react.default.createElement("a", {
|
|
60
|
+
href: `${signInUrl}?${query.toString()}`,
|
|
61
|
+
...props
|
|
62
|
+
}, children);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
exports.SignUp = SignUp;
|
|
67
|
+
//# sourceMappingURL=signup.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signup.cjs","names":[],"sources":["../../src/components/signup.tsx"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,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"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ExtraAuthParams } from "../types.mjs";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/signup.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Props for the `<SignUp />` component.
|
|
7
|
+
*
|
|
8
|
+
* @category Types
|
|
9
|
+
*/
|
|
10
|
+
interface SignUpProps extends Omit<ExtraAuthParams, 'authenticatorHint' | 'loginHint' | 'prompt'> {
|
|
11
|
+
/**
|
|
12
|
+
* URL to redirect to after successful sign-up.
|
|
13
|
+
*/
|
|
14
|
+
returnUrl?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* `<SignUp>` renders a link that initiates the MonoCloud sign-up flow.
|
|
18
|
+
*
|
|
19
|
+
* It works in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
20
|
+
*
|
|
21
|
+
* Internally, it behaves like `<SignIn>` but sets `prompt=create` to start the registration flow.
|
|
22
|
+
*
|
|
23
|
+
* @example Basic usage
|
|
24
|
+
*
|
|
25
|
+
* ```tsx title="Basic Usage"
|
|
26
|
+
* import { SignUp } from "@monocloud/auth-nextjs/components";
|
|
27
|
+
*
|
|
28
|
+
* export default function Home() {
|
|
29
|
+
* return <SignUp>Sign Up</SignUp>;
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example Customize the authorization request
|
|
34
|
+
*
|
|
35
|
+
* You can customize the authorization request by passing in props.
|
|
36
|
+
*
|
|
37
|
+
* ```tsx title="Customize the authorization request"
|
|
38
|
+
* import { SignUp } from "@monocloud/auth-nextjs/components";
|
|
39
|
+
*
|
|
40
|
+
* export default function Home() {
|
|
41
|
+
* return (
|
|
42
|
+
* <SignUp
|
|
43
|
+
* returnUrl="/dashboard"
|
|
44
|
+
* uiLocales="en"
|
|
45
|
+
* >
|
|
46
|
+
* Sign Up
|
|
47
|
+
* </SignUp>
|
|
48
|
+
* );
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @param props - Properties for the SignUp component.
|
|
53
|
+
* @returns An anchor element that links to the sign-in endpoint with the prompt set to 'create'.
|
|
54
|
+
*
|
|
55
|
+
* @category Components
|
|
56
|
+
*/
|
|
57
|
+
declare const SignUp: ({
|
|
58
|
+
children,
|
|
59
|
+
returnUrl,
|
|
60
|
+
acrValues,
|
|
61
|
+
display,
|
|
62
|
+
maxAge,
|
|
63
|
+
resource,
|
|
64
|
+
scopes,
|
|
65
|
+
uiLocales,
|
|
66
|
+
...props
|
|
67
|
+
}: SignUpProps & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "resource">) => React.ReactNode;
|
|
68
|
+
//#endregion
|
|
69
|
+
export { SignUp, SignUpProps };
|
|
70
|
+
//# sourceMappingURL=signup.d.mts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/signup.tsx
|
|
4
|
+
/**
|
|
5
|
+
* `<SignUp>` renders a link that initiates the MonoCloud sign-up flow.
|
|
6
|
+
*
|
|
7
|
+
* It works in both **App Router** and **Pages Router**, and may be rendered from either **Server** or **Client Components**.
|
|
8
|
+
*
|
|
9
|
+
* Internally, it behaves like `<SignIn>` but sets `prompt=create` to start the registration flow.
|
|
10
|
+
*
|
|
11
|
+
* @example Basic usage
|
|
12
|
+
*
|
|
13
|
+
* ```tsx title="Basic Usage"
|
|
14
|
+
* import { SignUp } from "@monocloud/auth-nextjs/components";
|
|
15
|
+
*
|
|
16
|
+
* export default function Home() {
|
|
17
|
+
* return <SignUp>Sign Up</SignUp>;
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example Customize the authorization request
|
|
22
|
+
*
|
|
23
|
+
* You can customize the authorization request by passing in props.
|
|
24
|
+
*
|
|
25
|
+
* ```tsx title="Customize the authorization request"
|
|
26
|
+
* import { SignUp } from "@monocloud/auth-nextjs/components";
|
|
27
|
+
*
|
|
28
|
+
* export default function Home() {
|
|
29
|
+
* return (
|
|
30
|
+
* <SignUp
|
|
31
|
+
* returnUrl="/dashboard"
|
|
32
|
+
* uiLocales="en"
|
|
33
|
+
* >
|
|
34
|
+
* Sign Up
|
|
35
|
+
* </SignUp>
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param props - Properties for the SignUp component.
|
|
41
|
+
* @returns An anchor element that links to the sign-in endpoint with the prompt set to 'create'.
|
|
42
|
+
*
|
|
43
|
+
* @category Components
|
|
44
|
+
*/
|
|
45
|
+
const SignUp = ({ children, returnUrl, acrValues, display, maxAge, resource, scopes, uiLocales, ...props }) => {
|
|
46
|
+
const signInUrl = process.env.NEXT_PUBLIC_MONOCLOUD_AUTH_SIGNIN_URL ?? `${process.env.__NEXT_ROUTER_BASEPATH ?? ""}/api/auth/signin`;
|
|
47
|
+
const query = new URLSearchParams();
|
|
48
|
+
query.set("prompt", "create");
|
|
49
|
+
if (returnUrl) query.set("return_url", returnUrl);
|
|
50
|
+
if (display) query.set("display", display);
|
|
51
|
+
if (uiLocales) query.set("ui_locales", uiLocales);
|
|
52
|
+
if (scopes) query.set("scope", scopes);
|
|
53
|
+
if (acrValues) query.set("acr_values", acrValues.join(" "));
|
|
54
|
+
if (resource) query.set("resource", resource);
|
|
55
|
+
if (maxAge) query.set("max_age", maxAge.toString());
|
|
56
|
+
if (returnUrl) query.set("return_url", returnUrl);
|
|
57
|
+
return /* @__PURE__ */ React.createElement("a", {
|
|
58
|
+
href: `${signInUrl}?${query.toString()}`,
|
|
59
|
+
...props
|
|
60
|
+
}, children);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { SignUp };
|
|
65
|
+
//# sourceMappingURL=signup.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signup.mjs","names":[],"sources":["../../src/components/signup.tsx"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,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"}
|