@civic/auth 0.0.1-beta.2 → 0.0.1-beta.21

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 (84) hide show
  1. package/README.md +26 -0
  2. package/dist/AuthProvider-Bj_Prt1x.d.ts +21 -0
  3. package/dist/AuthProvider-DUAoX4G9.d.mts +21 -0
  4. package/dist/UserProvider-CMLaYOUD.d.ts +16 -0
  5. package/dist/UserProvider-Cbm8MZkJ.d.mts +16 -0
  6. package/dist/chunk-4PLCDPEN.mjs +599 -0
  7. package/dist/chunk-4PLCDPEN.mjs.map +1 -0
  8. package/dist/chunk-5UQQYXCX.js +1 -0
  9. package/dist/chunk-5UQQYXCX.js.map +1 -0
  10. package/dist/chunk-6RFRDWIP.js +223 -0
  11. package/dist/chunk-6RFRDWIP.js.map +1 -0
  12. package/dist/chunk-7K3QN2AT.js +599 -0
  13. package/dist/chunk-7K3QN2AT.js.map +1 -0
  14. package/dist/chunk-AP4627CS.mjs +223 -0
  15. package/dist/chunk-AP4627CS.mjs.map +1 -0
  16. package/dist/chunk-CRTRMMJ7.js.map +1 -1
  17. package/dist/chunk-CTVJJBBA.js +118 -0
  18. package/dist/chunk-CTVJJBBA.js.map +1 -0
  19. package/dist/chunk-FHRZSX3C.js +710 -0
  20. package/dist/chunk-FHRZSX3C.js.map +1 -0
  21. package/dist/chunk-JDZPCA3P.js +173 -0
  22. package/dist/chunk-JDZPCA3P.js.map +1 -0
  23. package/dist/chunk-MK7557NR.mjs +118 -0
  24. package/dist/chunk-MK7557NR.mjs.map +1 -0
  25. package/dist/chunk-NLRREFOX.mjs +710 -0
  26. package/dist/chunk-NLRREFOX.mjs.map +1 -0
  27. package/dist/chunk-O3WGNLRO.mjs +173 -0
  28. package/dist/chunk-O3WGNLRO.mjs.map +1 -0
  29. package/dist/chunk-PMJAV4JJ.mjs +1 -0
  30. package/dist/chunk-PMJAV4JJ.mjs.map +1 -0
  31. package/dist/index.css +63 -70
  32. package/dist/index.css.map +1 -1
  33. package/dist/index.d.mts +3 -1
  34. package/dist/index.d.ts +3 -1
  35. package/dist/index.js +2 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/index.mjs +1 -0
  38. package/dist/nextjs/client.css +335 -0
  39. package/dist/nextjs/client.css.map +1 -0
  40. package/dist/nextjs/client.d.mts +12 -0
  41. package/dist/nextjs/client.d.ts +12 -0
  42. package/dist/nextjs/client.js +179 -0
  43. package/dist/nextjs/client.js.map +1 -0
  44. package/dist/nextjs/client.mjs +179 -0
  45. package/dist/nextjs/client.mjs.map +1 -0
  46. package/dist/nextjs.d.mts +67 -15
  47. package/dist/nextjs.d.ts +67 -15
  48. package/dist/nextjs.js +158 -180
  49. package/dist/nextjs.js.map +1 -1
  50. package/dist/nextjs.mjs +155 -177
  51. package/dist/nextjs.mjs.map +1 -1
  52. package/dist/react.d.mts +31 -81
  53. package/dist/react.d.ts +31 -81
  54. package/dist/react.js +35 -634
  55. package/dist/react.js.map +1 -1
  56. package/dist/react.mjs +65 -664
  57. package/dist/react.mjs.map +1 -1
  58. package/dist/server.d.mts +14 -34
  59. package/dist/server.d.ts +14 -34
  60. package/dist/server.js +4 -185
  61. package/dist/server.js.map +1 -1
  62. package/dist/server.mjs +10 -191
  63. package/dist/server.mjs.map +1 -1
  64. package/dist/storage-B2eAQNdv.d.ts +25 -0
  65. package/dist/storage-BJPUpxhm.d.mts +25 -0
  66. package/dist/types-Bqm9OCZN.d.mts +22 -0
  67. package/dist/types-Bqm9OCZN.d.ts +22 -0
  68. package/dist/types-HdCjGldB.d.mts +58 -0
  69. package/dist/types-HdCjGldB.d.ts +58 -0
  70. package/package.json +26 -17
  71. package/dist/chunk-5NUJ7LFF.mjs +0 -17
  72. package/dist/chunk-5NUJ7LFF.mjs.map +0 -1
  73. package/dist/chunk-KS7ERXGZ.js +0 -481
  74. package/dist/chunk-KS7ERXGZ.js.map +0 -1
  75. package/dist/chunk-NINRO7GS.js +0 -209
  76. package/dist/chunk-NINRO7GS.js.map +0 -1
  77. package/dist/chunk-NXBKSUKI.mjs +0 -481
  78. package/dist/chunk-NXBKSUKI.mjs.map +0 -1
  79. package/dist/chunk-T7HUHQ3J.mjs +0 -209
  80. package/dist/chunk-T7HUHQ3J.mjs.map +0 -1
  81. package/dist/chunk-WZLC5B4C.js +0 -17
  82. package/dist/chunk-WZLC5B4C.js.map +0 -1
  83. package/dist/index-DoDoIY_K.d.mts +0 -79
  84. package/dist/index-DoDoIY_K.d.ts +0 -79
package/README.md CHANGED
@@ -118,6 +118,32 @@ function Header() {
118
118
  }
119
119
  ```
120
120
 
121
+ ### Embedding the login iframe in your page
122
+
123
+ The default displayMode for user login is 'iframe' which will show a modal containing the login page for users, when the `signIn` hook is called. If you want to customize where this page is shown and embed it into your page instead i.e. in the case where you have a landing page and don't want users to have to click on a 'sign-in' button, you can embed the login iframe directly inside your page and it will work just like in the modal, as long as it is a child of a <CivicAuthProvider>. In this mode, the iframe auto-loads the login page.
124
+
125
+ To enable this mode, you need to set the parameter 'modalIframe' to `false` (it defaults to `true` in normal operation).
126
+
127
+ The example below shows the iframe centered inside a div embedded on the page:
128
+ ```tsx
129
+ import { CivicAuthProvider } from "@civic/auth/react";
130
+
131
+ function App({ children }) {
132
+ return (
133
+ <CivicAuthProvider
134
+ clientId="your-client-id"
135
+ redirectUrl="https://your-app.com/callback"
136
+ modalIframe={false}
137
+ >
138
+ {children}
139
+ <div className="flex min-h-[200px] items-center justify-center">
140
+ <CivicAuthIframeContainer />
141
+ </div>
142
+ </CivicAuthProvider>
143
+ );
144
+ }
145
+ ```
146
+
121
147
  ### Token Management with useToken Hook
122
148
 
123
149
  The `useToken` hook can be used to access and manage tokens within your application. This hook provides the current access and ID tokens, a refresh function, and token loading/error states.
@@ -0,0 +1,21 @@
1
+ import { ReactNode } from 'react';
2
+ import { C as Config, S as SessionData } from './types-HdCjGldB.js';
3
+
4
+ interface PKCEConsumer {
5
+ getCodeChallenge(): Promise<string>;
6
+ }
7
+
8
+ type AuthProviderProps = {
9
+ children: ReactNode;
10
+ clientId: string;
11
+ redirectUrl?: string;
12
+ nonce?: string;
13
+ config?: Config;
14
+ onSignIn?: (error?: Error) => void;
15
+ onSignOut?: () => Promise<void>;
16
+ pkceConsumer?: PKCEConsumer;
17
+ modalIframe?: boolean;
18
+ sessionData?: SessionData;
19
+ };
20
+
21
+ export type { AuthProviderProps as A };
@@ -0,0 +1,21 @@
1
+ import { ReactNode } from 'react';
2
+ import { C as Config, S as SessionData } from './types-HdCjGldB.mjs';
3
+
4
+ interface PKCEConsumer {
5
+ getCodeChallenge(): Promise<string>;
6
+ }
7
+
8
+ type AuthProviderProps = {
9
+ children: ReactNode;
10
+ clientId: string;
11
+ redirectUrl?: string;
12
+ nonce?: string;
13
+ config?: Config;
14
+ onSignIn?: (error?: Error) => void;
15
+ onSignOut?: () => Promise<void>;
16
+ pkceConsumer?: PKCEConsumer;
17
+ modalIframe?: boolean;
18
+ sessionData?: SessionData;
19
+ };
20
+
21
+ export type { AuthProviderProps as A };
@@ -0,0 +1,16 @@
1
+ import { JWT } from 'oslo/jwt';
2
+ import { D as DisplayMode, U as User } from './types-HdCjGldB.js';
3
+
4
+ type AuthContextType = {
5
+ signIn: (displayMode?: DisplayMode) => Promise<void>;
6
+ isAuthenticated: boolean;
7
+ isLoading: boolean;
8
+ error: Error | null;
9
+ signOut: () => Promise<void>;
10
+ };
11
+
12
+ type UserContextType<T extends Record<string, unknown> & JWT["payload"] = Record<string, unknown> & JWT["payload"]> = {
13
+ user: User<T> | null;
14
+ } & Omit<AuthContextType, "isAuthenticated">;
15
+
16
+ export type { AuthContextType as A, UserContextType as U };
@@ -0,0 +1,16 @@
1
+ import { JWT } from 'oslo/jwt';
2
+ import { D as DisplayMode, U as User } from './types-HdCjGldB.mjs';
3
+
4
+ type AuthContextType = {
5
+ signIn: (displayMode?: DisplayMode) => Promise<void>;
6
+ isAuthenticated: boolean;
7
+ isLoading: boolean;
8
+ error: Error | null;
9
+ signOut: () => Promise<void>;
10
+ };
11
+
12
+ type UserContextType<T extends Record<string, unknown> & JWT["payload"] = Record<string, unknown> & JWT["payload"]> = {
13
+ user: User<T> | null;
14
+ } & Omit<AuthContextType, "isAuthenticated">;
15
+
16
+ export type { AuthContextType as A, UserContextType as U };