@monocloud/auth-react 0.1.1-canary-20260605042109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +189 -0
  3. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  4. package/dist/components/process-callback.cjs +62 -0
  5. package/dist/components/process-callback.cjs.map +1 -0
  6. package/dist/components/process-callback.d.mts +46 -0
  7. package/dist/components/process-callback.mjs +60 -0
  8. package/dist/components/process-callback.mjs.map +1 -0
  9. package/dist/components/protected.cjs +85 -0
  10. package/dist/components/protected.cjs.map +1 -0
  11. package/dist/components/protected.d.mts +113 -0
  12. package/dist/components/protected.mjs +83 -0
  13. package/dist/components/protected.mjs.map +1 -0
  14. package/dist/components/signin.cjs +69 -0
  15. package/dist/components/signin.cjs.map +1 -0
  16. package/dist/components/signin.d.mts +70 -0
  17. package/dist/components/signin.mjs +67 -0
  18. package/dist/components/signin.mjs.map +1 -0
  19. package/dist/components/signout.cjs +61 -0
  20. package/dist/components/signout.cjs.map +1 -0
  21. package/dist/components/signout.d.mts +62 -0
  22. package/dist/components/signout.mjs +59 -0
  23. package/dist/components/signout.mjs.map +1 -0
  24. package/dist/components/signup.cjs +68 -0
  25. package/dist/components/signup.cjs.map +1 -0
  26. package/dist/components/signup.d.mts +68 -0
  27. package/dist/components/signup.mjs +66 -0
  28. package/dist/components/signup.mjs.map +1 -0
  29. package/dist/context.cjs +12 -0
  30. package/dist/context.cjs.map +1 -0
  31. package/dist/context.mjs +10 -0
  32. package/dist/context.mjs.map +1 -0
  33. package/dist/index.cjs +79 -0
  34. package/dist/index.d.mts +11 -0
  35. package/dist/index.mjs +11 -0
  36. package/dist/monocloud-auth-provider.cjs +181 -0
  37. package/dist/monocloud-auth-provider.cjs.map +1 -0
  38. package/dist/monocloud-auth-provider.d.mts +64 -0
  39. package/dist/monocloud-auth-provider.mjs +179 -0
  40. package/dist/monocloud-auth-provider.mjs.map +1 -0
  41. package/dist/types.d.mts +107 -0
  42. package/dist/use-auth.cjs +63 -0
  43. package/dist/use-auth.cjs.map +1 -0
  44. package/dist/use-auth.d.mts +56 -0
  45. package/dist/use-auth.mjs +63 -0
  46. package/dist/use-auth.mjs.map +1 -0
  47. package/dist/use-monocloud-client.cjs +47 -0
  48. package/dist/use-monocloud-client.cjs.map +1 -0
  49. package/dist/use-monocloud-client.d.mts +40 -0
  50. package/dist/use-monocloud-client.mjs +47 -0
  51. package/dist/use-monocloud-client.mjs.map +1 -0
  52. package/dist/use-process-callback.cjs +14 -0
  53. package/dist/use-process-callback.cjs.map +1 -0
  54. package/dist/use-process-callback.mjs +14 -0
  55. package/dist/use-process-callback.mjs.map +1 -0
  56. package/package.json +67 -0
@@ -0,0 +1,83 @@
1
+ "use client";
2
+ import { useAuth } from "../use-auth.mjs";
3
+ import React from "react";
4
+ import { isUserInGroup } from "@monocloud/auth-web-js/utils";
5
+ //#region src/components/protected.tsx
6
+ /**
7
+ * `<Protected>` conditionally renders its children based on the user’s authentication state and (optionally) group membership.
8
+ *
9
+ * > `<Protected>` runs on the client and only affects what is rendered. It does **not** prevent data from being sent to the browser. Always enforce authorization on your APIs as well.
10
+ *
11
+ * @example Basic Usage
12
+ *
13
+ * ```tsx:src/Home.tsx tab="Basic Usage" tab-group="Protected"
14
+ * "use client";
15
+ *
16
+ * import { Protected } from "@monocloud/auth-react";
17
+ *
18
+ * export default function Home() {
19
+ * return (
20
+ * <Protected fallback={<>Sign in to view the message.</>}>
21
+ * <>This is the protected content.</>
22
+ * </Protected>
23
+ * );
24
+ * }
25
+ * ```
26
+ *
27
+ * @example With Groups
28
+ *
29
+ * ```tsx:src/Home.tsx tab="With Groups" tab-group="Protected"
30
+ * "use client";
31
+ *
32
+ * import { Protected } from "@monocloud/auth-react";
33
+ *
34
+ * export default function Home() {
35
+ * return (
36
+ * <Protected
37
+ * groups={["admin"]}
38
+ * onGroupAccessDenied={(user) => <>User {user.email} is not allowed to access admin content.</>}
39
+ * >
40
+ * <>Signed in as admin</>
41
+ * </Protected>
42
+ * );
43
+ * }
44
+ * ```
45
+ *
46
+ * @example Requiring all groups
47
+ *
48
+ * ```tsx:src/Home.tsx tab="Requiring all groups" tab-group="Protected"
49
+ * "use client";
50
+ *
51
+ * import { Protected } from "@monocloud/auth-react";
52
+ *
53
+ * export default function Home() {
54
+ * return (
55
+ * <Protected
56
+ * groups={["admin", "billing"]}
57
+ * matchAllGroups
58
+ * onGroupAccessDenied={(user) => <>User {user.email} is not allowed to access billing content.</>}
59
+ * >
60
+ * <>Sensitive settings</>
61
+ * </Protected>
62
+ * );
63
+ * }
64
+ * ```
65
+ *
66
+ * @param props - Props for customizing the Protected component.
67
+ * @returns The children if authorized, the `fallback` or `onGroupAccessDenied` content if unauthenticated or unauthorized, or `null` while loading.
68
+ *
69
+ * @category Components
70
+ */
71
+ const Protected = ({ children, groups, groupsClaim, matchAllGroups = false, fallback = null, onGroupAccessDenied = () => /* @__PURE__ */ React.createElement(React.Fragment, null) }) => {
72
+ const { isLoading, error, isAuthenticated, user } = useAuth();
73
+ if (isLoading) return null;
74
+ if (error || !isAuthenticated || !user) {
75
+ if (fallback) return fallback;
76
+ return null;
77
+ }
78
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, !groups || isUserInGroup(user, groups, groupsClaim, matchAllGroups) ? children : onGroupAccessDenied(user));
79
+ };
80
+ //#endregion
81
+ export { Protected };
82
+
83
+ //# sourceMappingURL=protected.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protected.mjs","names":[],"sources":["../../src/components/protected.tsx"],"sourcesContent":["'use client';\n\nimport { isUserInGroup } from '@monocloud/auth-web-js/utils';\nimport React from 'react';\nimport type { MonoCloudUser } from '@monocloud/auth-web-js';\nimport { useAuth } from '../use-auth';\n\n/**\n * Props for the `<Protected />` component.\n *\n * @category Types\n */\nexport interface ProtectedComponentProps {\n /**\n * Content to render when access is allowed.\n */\n children: React.ReactNode;\n\n /**\n * Groups required to view the protected content. By default, the user must belong to **any** of the specified groups.\n */\n groups?: string[];\n\n /**\n * Name of the claim that contains groups in the user profile.\n * @defaultValue 'groups'\n */\n groupsClaim?: string;\n\n /**\n * If `true`, the user must belong to **all** specified `groups` (instead of any).\n * @defaultValue false\n */\n matchAllGroups?: boolean;\n\n /**\n * Content to render when the user is not authenticated.\n */\n fallback?: React.ReactNode;\n\n /**\n * Rendered when the user is authenticated but does not meet the `groups` requirement. If omitted, nothing is rendered (or `fallback` is used only for unauthenticated users).\n */\n onGroupAccessDenied?: (user: MonoCloudUser) => React.ReactNode;\n}\n\n/**\n * `<Protected>` conditionally renders its children based on the user’s authentication state and (optionally) group membership.\n *\n * > `<Protected>` runs on the client and only affects what is rendered. It does **not** prevent data from being sent to the browser. Always enforce authorization on your APIs as well.\n *\n * @example Basic Usage\n *\n * ```tsx:src/Home.tsx tab=\"Basic Usage\" tab-group=\"Protected\"\n * \"use client\";\n *\n * import { Protected } from \"@monocloud/auth-react\";\n *\n * export default function Home() {\n * return (\n * <Protected fallback={<>Sign in to view the message.</>}>\n * <>This is the protected content.</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example With Groups\n *\n * ```tsx:src/Home.tsx tab=\"With Groups\" tab-group=\"Protected\"\n * \"use client\";\n *\n * import { Protected } from \"@monocloud/auth-react\";\n *\n * export default function Home() {\n * return (\n * <Protected\n * groups={[\"admin\"]}\n * onGroupAccessDenied={(user) => <>User {user.email} is not allowed to access admin content.</>}\n * >\n * <>Signed in as admin</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @example Requiring all groups\n *\n * ```tsx:src/Home.tsx tab=\"Requiring all groups\" tab-group=\"Protected\"\n * \"use client\";\n *\n * import { Protected } from \"@monocloud/auth-react\";\n *\n * export default function Home() {\n * return (\n * <Protected\n * groups={[\"admin\", \"billing\"]}\n * matchAllGroups\n * onGroupAccessDenied={(user) => <>User {user.email} is not allowed to access billing content.</>}\n * >\n * <>Sensitive settings</>\n * </Protected>\n * );\n * }\n * ```\n *\n * @param props - Props for customizing the Protected component.\n * @returns The children if authorized, the `fallback` or `onGroupAccessDenied` content if unauthenticated or unauthorized, or `null` while loading.\n *\n * @category Components\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 || isUserInGroup(user, groups, groupsClaim, matchAllGroups)\n ? children\n : onGroupAccessDenied(user)}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GA,MAAa,aAAa,EACxB,UACA,QACA,aACA,iBAAiB,OACjB,WAAW,MACX,4BAA6C,sBAAA,cAAA,MAAA,UAAA,IAAI,QACI;CACrD,MAAM,EAAE,WAAW,OAAO,iBAAiB,SAAS,QAAQ;CAE5D,IAAI,WACF,OAAO;CAGT,IAAI,SAAS,CAAC,mBAAmB,CAAC,MAAM;EACtC,IAAI,UACF,OAAO;EAGT,OAAO;CACT;CAEA,OACE,sBAAA,cAAA,MAAA,UAAA,MACG,CAAC,UAAU,cAAc,MAAM,QAAQ,aAAa,cAAc,IAC/D,WACA,oBAAoB,IAAI,CAC5B;AAEN"}
@@ -0,0 +1,69 @@
1
+ "use client";
2
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_use_auth = require("../use-auth.cjs");
4
+ let react = require("react");
5
+ react = require_runtime.__toESM(react);
6
+ //#region src/components/signin.tsx
7
+ /**
8
+ * `<SignIn>` renders a button that starts the sign-in flow when clicked.
9
+ *
10
+ * @example Basic Usage
11
+ *
12
+ * ```tsx:src/SignInButton.tsx tab="Basic Usage" tab-group="SignIn"
13
+ * "use client";
14
+ *
15
+ * import { SignIn } from "@monocloud/auth-react";
16
+ *
17
+ * export default function Home() {
18
+ * return <SignIn>Sign In</SignIn>;
19
+ * }
20
+ * ```
21
+ *
22
+ * @example Customized
23
+ *
24
+ * ```tsx:src/SignInButton.tsx tab="Customized" tab-group="SignIn"
25
+ * "use client";
26
+ *
27
+ * import { SignIn } from "@monocloud/auth-react";
28
+ *
29
+ * export default function Home() {
30
+ * return (
31
+ * <SignIn authenticatorHint="google">
32
+ * Sign in with Google
33
+ * </SignIn>
34
+ * );
35
+ * }
36
+ * ```
37
+ *
38
+ * @param props - Sign-in options.
39
+ * @returns A button that triggers sign-in on click.
40
+ *
41
+ * @category Components
42
+ */
43
+ const SignIn = ({ children, authenticatorHint, maxAge, loginHint, uiLocales, mode, acrValues, display, prompt, resource, returnUrl, scopes, appState, ...props }) => {
44
+ const { signIn } = require_use_auth.useAuth();
45
+ return /* @__PURE__ */ react.default.createElement("button", {
46
+ ...props,
47
+ type: "button",
48
+ onClick: () => {
49
+ signIn({
50
+ authenticatorHint,
51
+ maxAge,
52
+ loginHint,
53
+ uiLocales,
54
+ mode,
55
+ acrValues,
56
+ display,
57
+ prompt,
58
+ resource,
59
+ returnUrl,
60
+ scopes,
61
+ appState
62
+ });
63
+ }
64
+ }, children);
65
+ };
66
+ //#endregion
67
+ exports.SignIn = SignIn;
68
+
69
+ //# sourceMappingURL=signin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signin.cjs","names":["useAuth"],"sources":["../../src/components/signin.tsx"],"sourcesContent":["'use client';\n\nimport type { SignInOptions } from '@monocloud/auth-web-js';\nimport React from 'react';\nimport { useAuth } from '../use-auth';\n\n/**\n * Props for the `<SignIn />` component.\n *\n * @category Types\n */\nexport interface SignInProps\n extends\n Omit<SignInOptions, 'signUp'>,\n React.ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * Content rendered inside the button.\n */\n children: React.ReactNode;\n}\n\n/**\n * `<SignIn>` renders a button that starts the sign-in flow when clicked.\n *\n * @example Basic Usage\n *\n * ```tsx:src/SignInButton.tsx tab=\"Basic Usage\" tab-group=\"SignIn\"\n * \"use client\";\n *\n * import { SignIn } from \"@monocloud/auth-react\";\n *\n * export default function Home() {\n * return <SignIn>Sign In</SignIn>;\n * }\n * ```\n *\n * @example Customized\n *\n * ```tsx:src/SignInButton.tsx tab=\"Customized\" tab-group=\"SignIn\"\n * \"use client\";\n *\n * import { SignIn } from \"@monocloud/auth-react\";\n *\n * export default function Home() {\n * return (\n * <SignIn authenticatorHint=\"google\">\n * Sign in with Google\n * </SignIn>\n * );\n * }\n * ```\n *\n * @param props - Sign-in options.\n * @returns A button that triggers sign-in on click.\n *\n * @category Components\n */\nexport const SignIn = ({\n children,\n authenticatorHint,\n maxAge,\n loginHint,\n uiLocales,\n mode,\n acrValues,\n display,\n prompt,\n resource,\n returnUrl,\n scopes,\n appState,\n ...props\n}: SignInProps): React.JSX.Element => {\n const { signIn } = useAuth();\n\n return (\n <button\n {...props}\n type=\"button\"\n onClick={() => {\n void signIn({\n authenticatorHint,\n maxAge,\n loginHint,\n uiLocales,\n mode,\n acrValues,\n display,\n prompt,\n resource,\n returnUrl,\n scopes,\n appState,\n });\n }}\n >\n {children}\n </button>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,MAAa,UAAU,EACrB,UACA,mBACA,QACA,WACA,WACA,MACA,WACA,SACA,QACA,UACA,WACA,QACA,UACA,GAAG,YACiC;CACpC,MAAM,EAAE,WAAWA,iBAAAA,QAAQ;CAE3B,OACE,sBAAA,QAAA,cAAC,UAAD;EACE,GAAI;EACJ,MAAK;EACL,eAAe;GACb,OAAY;IACV;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF,CAAC;EACH;CAGM,GADL,QACK;AAEZ"}
@@ -0,0 +1,70 @@
1
+ import { SignInOptions } from "@monocloud/auth-web-js";
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 Omit<SignInOptions, 'signUp'>, React.ButtonHTMLAttributes<HTMLButtonElement> {
11
+ /**
12
+ * Content rendered inside the button.
13
+ */
14
+ children: React.ReactNode;
15
+ }
16
+ /**
17
+ * `<SignIn>` renders a button that starts the sign-in flow when clicked.
18
+ *
19
+ * @example Basic Usage
20
+ *
21
+ * ```tsx:src/SignInButton.tsx tab="Basic Usage" tab-group="SignIn"
22
+ * "use client";
23
+ *
24
+ * import { SignIn } from "@monocloud/auth-react";
25
+ *
26
+ * export default function Home() {
27
+ * return <SignIn>Sign In</SignIn>;
28
+ * }
29
+ * ```
30
+ *
31
+ * @example Customized
32
+ *
33
+ * ```tsx:src/SignInButton.tsx tab="Customized" tab-group="SignIn"
34
+ * "use client";
35
+ *
36
+ * import { SignIn } from "@monocloud/auth-react";
37
+ *
38
+ * export default function Home() {
39
+ * return (
40
+ * <SignIn authenticatorHint="google">
41
+ * Sign in with Google
42
+ * </SignIn>
43
+ * );
44
+ * }
45
+ * ```
46
+ *
47
+ * @param props - Sign-in options.
48
+ * @returns A button that triggers sign-in on click.
49
+ *
50
+ * @category Components
51
+ */
52
+ declare const SignIn: ({
53
+ children,
54
+ authenticatorHint,
55
+ maxAge,
56
+ loginHint,
57
+ uiLocales,
58
+ mode,
59
+ acrValues,
60
+ display,
61
+ prompt,
62
+ resource,
63
+ returnUrl,
64
+ scopes,
65
+ appState,
66
+ ...props
67
+ }: SignInProps) => React.JSX.Element;
68
+ //#endregion
69
+ export { SignIn, SignInProps };
70
+ //# sourceMappingURL=signin.d.mts.map
@@ -0,0 +1,67 @@
1
+ "use client";
2
+ import { useAuth } from "../use-auth.mjs";
3
+ import React from "react";
4
+ //#region src/components/signin.tsx
5
+ /**
6
+ * `<SignIn>` renders a button that starts the sign-in flow when clicked.
7
+ *
8
+ * @example Basic Usage
9
+ *
10
+ * ```tsx:src/SignInButton.tsx tab="Basic Usage" tab-group="SignIn"
11
+ * "use client";
12
+ *
13
+ * import { SignIn } from "@monocloud/auth-react";
14
+ *
15
+ * export default function Home() {
16
+ * return <SignIn>Sign In</SignIn>;
17
+ * }
18
+ * ```
19
+ *
20
+ * @example Customized
21
+ *
22
+ * ```tsx:src/SignInButton.tsx tab="Customized" tab-group="SignIn"
23
+ * "use client";
24
+ *
25
+ * import { SignIn } from "@monocloud/auth-react";
26
+ *
27
+ * export default function Home() {
28
+ * return (
29
+ * <SignIn authenticatorHint="google">
30
+ * Sign in with Google
31
+ * </SignIn>
32
+ * );
33
+ * }
34
+ * ```
35
+ *
36
+ * @param props - Sign-in options.
37
+ * @returns A button that triggers sign-in on click.
38
+ *
39
+ * @category Components
40
+ */
41
+ const SignIn = ({ children, authenticatorHint, maxAge, loginHint, uiLocales, mode, acrValues, display, prompt, resource, returnUrl, scopes, appState, ...props }) => {
42
+ const { signIn } = useAuth();
43
+ return /* @__PURE__ */ React.createElement("button", {
44
+ ...props,
45
+ type: "button",
46
+ onClick: () => {
47
+ signIn({
48
+ authenticatorHint,
49
+ maxAge,
50
+ loginHint,
51
+ uiLocales,
52
+ mode,
53
+ acrValues,
54
+ display,
55
+ prompt,
56
+ resource,
57
+ returnUrl,
58
+ scopes,
59
+ appState
60
+ });
61
+ }
62
+ }, children);
63
+ };
64
+ //#endregion
65
+ export { SignIn };
66
+
67
+ //# sourceMappingURL=signin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signin.mjs","names":[],"sources":["../../src/components/signin.tsx"],"sourcesContent":["'use client';\n\nimport type { SignInOptions } from '@monocloud/auth-web-js';\nimport React from 'react';\nimport { useAuth } from '../use-auth';\n\n/**\n * Props for the `<SignIn />` component.\n *\n * @category Types\n */\nexport interface SignInProps\n extends\n Omit<SignInOptions, 'signUp'>,\n React.ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * Content rendered inside the button.\n */\n children: React.ReactNode;\n}\n\n/**\n * `<SignIn>` renders a button that starts the sign-in flow when clicked.\n *\n * @example Basic Usage\n *\n * ```tsx:src/SignInButton.tsx tab=\"Basic Usage\" tab-group=\"SignIn\"\n * \"use client\";\n *\n * import { SignIn } from \"@monocloud/auth-react\";\n *\n * export default function Home() {\n * return <SignIn>Sign In</SignIn>;\n * }\n * ```\n *\n * @example Customized\n *\n * ```tsx:src/SignInButton.tsx tab=\"Customized\" tab-group=\"SignIn\"\n * \"use client\";\n *\n * import { SignIn } from \"@monocloud/auth-react\";\n *\n * export default function Home() {\n * return (\n * <SignIn authenticatorHint=\"google\">\n * Sign in with Google\n * </SignIn>\n * );\n * }\n * ```\n *\n * @param props - Sign-in options.\n * @returns A button that triggers sign-in on click.\n *\n * @category Components\n */\nexport const SignIn = ({\n children,\n authenticatorHint,\n maxAge,\n loginHint,\n uiLocales,\n mode,\n acrValues,\n display,\n prompt,\n resource,\n returnUrl,\n scopes,\n appState,\n ...props\n}: SignInProps): React.JSX.Element => {\n const { signIn } = useAuth();\n\n return (\n <button\n {...props}\n type=\"button\"\n onClick={() => {\n void signIn({\n authenticatorHint,\n maxAge,\n loginHint,\n uiLocales,\n mode,\n acrValues,\n display,\n prompt,\n resource,\n returnUrl,\n scopes,\n appState,\n });\n }}\n >\n {children}\n </button>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,MAAa,UAAU,EACrB,UACA,mBACA,QACA,WACA,WACA,MACA,WACA,SACA,QACA,UACA,WACA,QACA,UACA,GAAG,YACiC;CACpC,MAAM,EAAE,WAAW,QAAQ;CAE3B,OACE,sBAAA,cAAC,UAAD;EACE,GAAI;EACJ,MAAK;EACL,eAAe;GACb,OAAY;IACV;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF,CAAC;EACH;CAGM,GADL,QACK;AAEZ"}
@@ -0,0 +1,61 @@
1
+ "use client";
2
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_use_auth = require("../use-auth.cjs");
4
+ let react = require("react");
5
+ react = require_runtime.__toESM(react);
6
+ //#region src/components/signout.tsx
7
+ /**
8
+ * `<SignOut>` renders a button that starts the sign-out flow when clicked.
9
+ *
10
+ * @example Basic Usage
11
+ *
12
+ * ```tsx:src/SignOutButton.tsx tab="Basic Usage" tab-group="SignOut"
13
+ * "use client";
14
+ *
15
+ * import { SignOut } from "@monocloud/auth-react";
16
+ *
17
+ * export default function Home() {
18
+ * return <SignOut>Sign Out</SignOut>;
19
+ * }
20
+ * ```
21
+ *
22
+ * @example Customized
23
+ *
24
+ * ```tsx:src/SignOutButton.tsx tab="Customized" tab-group="SignOut"
25
+ * "use client";
26
+ *
27
+ * import { SignOut } from "@monocloud/auth-react";
28
+ *
29
+ * export default function Home() {
30
+ * return (
31
+ * <SignOut federatedSignOut>
32
+ * Log out
33
+ * </SignOut>
34
+ * );
35
+ * }
36
+ * ```
37
+ *
38
+ * @param props - Sign-out options.
39
+ * @returns A button that triggers sign-out on click.
40
+ *
41
+ * @category Components
42
+ */
43
+ const SignOut = ({ children, postLogoutRedirectUri, mode, federatedSignOut, returnUrl, ...props }) => {
44
+ const { signOut } = require_use_auth.useAuth();
45
+ return /* @__PURE__ */ react.default.createElement("button", {
46
+ ...props,
47
+ type: "button",
48
+ onClick: () => {
49
+ signOut({
50
+ postLogoutRedirectUri,
51
+ mode,
52
+ federatedSignOut,
53
+ returnUrl
54
+ });
55
+ }
56
+ }, children);
57
+ };
58
+ //#endregion
59
+ exports.SignOut = SignOut;
60
+
61
+ //# sourceMappingURL=signout.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signout.cjs","names":["useAuth"],"sources":["../../src/components/signout.tsx"],"sourcesContent":["'use client';\n\nimport type { SignOutOptions } from '@monocloud/auth-web-js';\nimport React from 'react';\nimport { useAuth } from '../use-auth';\n\n/**\n * Props for the `<SignOut />` component.\n *\n * @category Types\n */\nexport interface SignOutProps\n extends SignOutOptions, React.ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * Content rendered inside the button.\n */\n children: React.ReactNode;\n}\n\n/**\n * `<SignOut>` renders a button that starts the sign-out flow when clicked.\n *\n * @example Basic Usage\n *\n * ```tsx:src/SignOutButton.tsx tab=\"Basic Usage\" tab-group=\"SignOut\"\n * \"use client\";\n *\n * import { SignOut } from \"@monocloud/auth-react\";\n *\n * export default function Home() {\n * return <SignOut>Sign Out</SignOut>;\n * }\n * ```\n *\n * @example Customized\n *\n * ```tsx:src/SignOutButton.tsx tab=\"Customized\" tab-group=\"SignOut\"\n * \"use client\";\n *\n * import { SignOut } from \"@monocloud/auth-react\";\n *\n * export default function Home() {\n * return (\n * <SignOut federatedSignOut>\n * Log out\n * </SignOut>\n * );\n * }\n * ```\n *\n * @param props - Sign-out options.\n * @returns A button that triggers sign-out on click.\n *\n * @category Components\n */\nexport const SignOut = ({\n children,\n postLogoutRedirectUri,\n mode,\n federatedSignOut,\n returnUrl,\n ...props\n}: SignOutProps): React.JSX.Element => {\n const { signOut } = useAuth();\n\n return (\n <button\n {...props}\n type=\"button\"\n onClick={() => {\n void signOut({\n postLogoutRedirectUri,\n mode,\n federatedSignOut,\n returnUrl,\n });\n }}\n >\n {children}\n </button>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAa,WAAW,EACtB,UACA,uBACA,MACA,kBACA,WACA,GAAG,YACkC;CACrC,MAAM,EAAE,YAAYA,iBAAAA,QAAQ;CAE5B,OACE,sBAAA,QAAA,cAAC,UAAD;EACE,GAAI;EACJ,MAAK;EACL,eAAe;GACb,QAAa;IACX;IACA;IACA;IACA;GACF,CAAC;EACH;CAGM,GADL,QACK;AAEZ"}
@@ -0,0 +1,62 @@
1
+ import { SignOutOptions } from "@monocloud/auth-web-js";
2
+ import React from "react";
3
+
4
+ //#region src/components/signout.d.ts
5
+ /**
6
+ * Props for the `<SignOut />` component.
7
+ *
8
+ * @category Types
9
+ */
10
+ interface SignOutProps extends SignOutOptions, React.ButtonHTMLAttributes<HTMLButtonElement> {
11
+ /**
12
+ * Content rendered inside the button.
13
+ */
14
+ children: React.ReactNode;
15
+ }
16
+ /**
17
+ * `<SignOut>` renders a button that starts the sign-out flow when clicked.
18
+ *
19
+ * @example Basic Usage
20
+ *
21
+ * ```tsx:src/SignOutButton.tsx tab="Basic Usage" tab-group="SignOut"
22
+ * "use client";
23
+ *
24
+ * import { SignOut } from "@monocloud/auth-react";
25
+ *
26
+ * export default function Home() {
27
+ * return <SignOut>Sign Out</SignOut>;
28
+ * }
29
+ * ```
30
+ *
31
+ * @example Customized
32
+ *
33
+ * ```tsx:src/SignOutButton.tsx tab="Customized" tab-group="SignOut"
34
+ * "use client";
35
+ *
36
+ * import { SignOut } from "@monocloud/auth-react";
37
+ *
38
+ * export default function Home() {
39
+ * return (
40
+ * <SignOut federatedSignOut>
41
+ * Log out
42
+ * </SignOut>
43
+ * );
44
+ * }
45
+ * ```
46
+ *
47
+ * @param props - Sign-out options.
48
+ * @returns A button that triggers sign-out on click.
49
+ *
50
+ * @category Components
51
+ */
52
+ declare const SignOut: ({
53
+ children,
54
+ postLogoutRedirectUri,
55
+ mode,
56
+ federatedSignOut,
57
+ returnUrl,
58
+ ...props
59
+ }: SignOutProps) => React.JSX.Element;
60
+ //#endregion
61
+ export { SignOut, SignOutProps };
62
+ //# sourceMappingURL=signout.d.mts.map
@@ -0,0 +1,59 @@
1
+ "use client";
2
+ import { useAuth } from "../use-auth.mjs";
3
+ import React from "react";
4
+ //#region src/components/signout.tsx
5
+ /**
6
+ * `<SignOut>` renders a button that starts the sign-out flow when clicked.
7
+ *
8
+ * @example Basic Usage
9
+ *
10
+ * ```tsx:src/SignOutButton.tsx tab="Basic Usage" tab-group="SignOut"
11
+ * "use client";
12
+ *
13
+ * import { SignOut } from "@monocloud/auth-react";
14
+ *
15
+ * export default function Home() {
16
+ * return <SignOut>Sign Out</SignOut>;
17
+ * }
18
+ * ```
19
+ *
20
+ * @example Customized
21
+ *
22
+ * ```tsx:src/SignOutButton.tsx tab="Customized" tab-group="SignOut"
23
+ * "use client";
24
+ *
25
+ * import { SignOut } from "@monocloud/auth-react";
26
+ *
27
+ * export default function Home() {
28
+ * return (
29
+ * <SignOut federatedSignOut>
30
+ * Log out
31
+ * </SignOut>
32
+ * );
33
+ * }
34
+ * ```
35
+ *
36
+ * @param props - Sign-out options.
37
+ * @returns A button that triggers sign-out on click.
38
+ *
39
+ * @category Components
40
+ */
41
+ const SignOut = ({ children, postLogoutRedirectUri, mode, federatedSignOut, returnUrl, ...props }) => {
42
+ const { signOut } = useAuth();
43
+ return /* @__PURE__ */ React.createElement("button", {
44
+ ...props,
45
+ type: "button",
46
+ onClick: () => {
47
+ signOut({
48
+ postLogoutRedirectUri,
49
+ mode,
50
+ federatedSignOut,
51
+ returnUrl
52
+ });
53
+ }
54
+ }, children);
55
+ };
56
+ //#endregion
57
+ export { SignOut };
58
+
59
+ //# sourceMappingURL=signout.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signout.mjs","names":[],"sources":["../../src/components/signout.tsx"],"sourcesContent":["'use client';\n\nimport type { SignOutOptions } from '@monocloud/auth-web-js';\nimport React from 'react';\nimport { useAuth } from '../use-auth';\n\n/**\n * Props for the `<SignOut />` component.\n *\n * @category Types\n */\nexport interface SignOutProps\n extends SignOutOptions, React.ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * Content rendered inside the button.\n */\n children: React.ReactNode;\n}\n\n/**\n * `<SignOut>` renders a button that starts the sign-out flow when clicked.\n *\n * @example Basic Usage\n *\n * ```tsx:src/SignOutButton.tsx tab=\"Basic Usage\" tab-group=\"SignOut\"\n * \"use client\";\n *\n * import { SignOut } from \"@monocloud/auth-react\";\n *\n * export default function Home() {\n * return <SignOut>Sign Out</SignOut>;\n * }\n * ```\n *\n * @example Customized\n *\n * ```tsx:src/SignOutButton.tsx tab=\"Customized\" tab-group=\"SignOut\"\n * \"use client\";\n *\n * import { SignOut } from \"@monocloud/auth-react\";\n *\n * export default function Home() {\n * return (\n * <SignOut federatedSignOut>\n * Log out\n * </SignOut>\n * );\n * }\n * ```\n *\n * @param props - Sign-out options.\n * @returns A button that triggers sign-out on click.\n *\n * @category Components\n */\nexport const SignOut = ({\n children,\n postLogoutRedirectUri,\n mode,\n federatedSignOut,\n returnUrl,\n ...props\n}: SignOutProps): React.JSX.Element => {\n const { signOut } = useAuth();\n\n return (\n <button\n {...props}\n type=\"button\"\n onClick={() => {\n void signOut({\n postLogoutRedirectUri,\n mode,\n federatedSignOut,\n returnUrl,\n });\n }}\n >\n {children}\n </button>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAa,WAAW,EACtB,UACA,uBACA,MACA,kBACA,WACA,GAAG,YACkC;CACrC,MAAM,EAAE,YAAY,QAAQ;CAE5B,OACE,sBAAA,cAAC,UAAD;EACE,GAAI;EACJ,MAAK;EACL,eAAe;GACb,QAAa;IACX;IACA;IACA;IACA;GACF,CAAC;EACH;CAGM,GADL,QACK;AAEZ"}
@@ -0,0 +1,68 @@
1
+ "use client";
2
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_use_auth = require("../use-auth.cjs");
4
+ let react = require("react");
5
+ react = require_runtime.__toESM(react);
6
+ //#region src/components/signup.tsx
7
+ /**
8
+ * `<SignUp>` renders a button that starts the sign-up (registration) flow when
9
+ * clicked.
10
+ *
11
+ * @example Basic Usage
12
+ *
13
+ * ```tsx:src/SignUpButton.tsx tab="Basic Usage" tab-group="SignUp"
14
+ * "use client";
15
+ *
16
+ * import { SignUp } from "@monocloud/auth-react";
17
+ *
18
+ * export default function Home() {
19
+ * return <SignUp>Create account</SignUp>;
20
+ * }
21
+ * ```
22
+ *
23
+ * @example Customized
24
+ *
25
+ * ```tsx:src/SignUpButton.tsx tab="Customized" tab-group="SignUp"
26
+ * "use client";
27
+ *
28
+ * import { SignUp } from "@monocloud/auth-react";
29
+ *
30
+ * export default function Home() {
31
+ * return (
32
+ * <SignUp returnUrl="/welcome">
33
+ * Sign-up now
34
+ * </SignUp>
35
+ * );
36
+ * }
37
+ * ```
38
+ *
39
+ * @param props - Sign-up options.
40
+ * @returns A button that triggers sign-up on click.
41
+ *
42
+ * @category Components
43
+ */
44
+ const SignUp = ({ children, maxAge, uiLocales, mode, acrValues, display, resource, returnUrl, scopes, appState, ...props }) => {
45
+ const { signIn } = require_use_auth.useAuth();
46
+ return /* @__PURE__ */ react.default.createElement("button", {
47
+ ...props,
48
+ type: "button",
49
+ onClick: () => {
50
+ signIn({
51
+ signUp: true,
52
+ maxAge,
53
+ uiLocales,
54
+ mode,
55
+ acrValues,
56
+ display,
57
+ resource,
58
+ returnUrl,
59
+ scopes,
60
+ appState
61
+ });
62
+ }
63
+ }, children);
64
+ };
65
+ //#endregion
66
+ exports.SignUp = SignUp;
67
+
68
+ //# sourceMappingURL=signup.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signup.cjs","names":["useAuth"],"sources":["../../src/components/signup.tsx"],"sourcesContent":["'use client';\n\nimport type { SignInOptions } from '@monocloud/auth-web-js';\nimport React from 'react';\nimport { useAuth } from '../use-auth';\n\n/**\n * Props for the `<SignUp />` component.\n *\n * @category Types\n */\nexport interface SignUpProps\n extends\n Omit<\n SignInOptions,\n 'signUp' | 'authenticatorHint' | 'loginHint' | 'prompt'\n >,\n React.ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * Content rendered inside the button.\n */\n children: React.ReactNode;\n}\n\n/**\n * `<SignUp>` renders a button that starts the sign-up (registration) flow when\n * clicked.\n *\n * @example Basic Usage\n *\n * ```tsx:src/SignUpButton.tsx tab=\"Basic Usage\" tab-group=\"SignUp\"\n * \"use client\";\n *\n * import { SignUp } from \"@monocloud/auth-react\";\n *\n * export default function Home() {\n * return <SignUp>Create account</SignUp>;\n * }\n * ```\n *\n * @example Customized\n *\n * ```tsx:src/SignUpButton.tsx tab=\"Customized\" tab-group=\"SignUp\"\n * \"use client\";\n *\n * import { SignUp } from \"@monocloud/auth-react\";\n *\n * export default function Home() {\n * return (\n * <SignUp returnUrl=\"/welcome\">\n * Sign-up now\n * </SignUp>\n * );\n * }\n * ```\n *\n * @param props - Sign-up options.\n * @returns A button that triggers sign-up on click.\n *\n * @category Components\n */\nexport const SignUp = ({\n children,\n maxAge,\n uiLocales,\n mode,\n acrValues,\n display,\n resource,\n returnUrl,\n scopes,\n appState,\n ...props\n}: SignUpProps): React.JSX.Element => {\n const { signIn } = useAuth();\n\n return (\n <button\n {...props}\n type=\"button\"\n onClick={() => {\n void signIn({\n signUp: true,\n maxAge,\n uiLocales,\n mode,\n acrValues,\n display,\n resource,\n returnUrl,\n scopes,\n appState,\n });\n }}\n >\n {children}\n </button>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAa,UAAU,EACrB,UACA,QACA,WACA,MACA,WACA,SACA,UACA,WACA,QACA,UACA,GAAG,YACiC;CACpC,MAAM,EAAE,WAAWA,iBAAAA,QAAQ;CAE3B,OACE,sBAAA,QAAA,cAAC,UAAD;EACE,GAAI;EACJ,MAAK;EACL,eAAe;GACb,OAAY;IACV,QAAQ;IACR;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF,CAAC;EACH;CAGM,GADL,QACK;AAEZ"}
@@ -0,0 +1,68 @@
1
+ import { SignInOptions } from "@monocloud/auth-web-js";
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<SignInOptions, 'signUp' | 'authenticatorHint' | 'loginHint' | 'prompt'>, React.ButtonHTMLAttributes<HTMLButtonElement> {
11
+ /**
12
+ * Content rendered inside the button.
13
+ */
14
+ children: React.ReactNode;
15
+ }
16
+ /**
17
+ * `<SignUp>` renders a button that starts the sign-up (registration) flow when
18
+ * clicked.
19
+ *
20
+ * @example Basic Usage
21
+ *
22
+ * ```tsx:src/SignUpButton.tsx tab="Basic Usage" tab-group="SignUp"
23
+ * "use client";
24
+ *
25
+ * import { SignUp } from "@monocloud/auth-react";
26
+ *
27
+ * export default function Home() {
28
+ * return <SignUp>Create account</SignUp>;
29
+ * }
30
+ * ```
31
+ *
32
+ * @example Customized
33
+ *
34
+ * ```tsx:src/SignUpButton.tsx tab="Customized" tab-group="SignUp"
35
+ * "use client";
36
+ *
37
+ * import { SignUp } from "@monocloud/auth-react";
38
+ *
39
+ * export default function Home() {
40
+ * return (
41
+ * <SignUp returnUrl="/welcome">
42
+ * Sign-up now
43
+ * </SignUp>
44
+ * );
45
+ * }
46
+ * ```
47
+ *
48
+ * @param props - Sign-up options.
49
+ * @returns A button that triggers sign-up on click.
50
+ *
51
+ * @category Components
52
+ */
53
+ declare const SignUp: ({
54
+ children,
55
+ maxAge,
56
+ uiLocales,
57
+ mode,
58
+ acrValues,
59
+ display,
60
+ resource,
61
+ returnUrl,
62
+ scopes,
63
+ appState,
64
+ ...props
65
+ }: SignUpProps) => React.JSX.Element;
66
+ //#endregion
67
+ export { SignUp, SignUpProps };
68
+ //# sourceMappingURL=signup.d.mts.map