@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.
- package/README.md +26 -0
- package/dist/AuthProvider-Bj_Prt1x.d.ts +21 -0
- package/dist/AuthProvider-DUAoX4G9.d.mts +21 -0
- package/dist/UserProvider-CMLaYOUD.d.ts +16 -0
- package/dist/UserProvider-Cbm8MZkJ.d.mts +16 -0
- package/dist/chunk-4PLCDPEN.mjs +599 -0
- package/dist/chunk-4PLCDPEN.mjs.map +1 -0
- package/dist/chunk-5UQQYXCX.js +1 -0
- package/dist/chunk-5UQQYXCX.js.map +1 -0
- package/dist/chunk-6RFRDWIP.js +223 -0
- package/dist/chunk-6RFRDWIP.js.map +1 -0
- package/dist/chunk-7K3QN2AT.js +599 -0
- package/dist/chunk-7K3QN2AT.js.map +1 -0
- package/dist/chunk-AP4627CS.mjs +223 -0
- package/dist/chunk-AP4627CS.mjs.map +1 -0
- package/dist/chunk-CRTRMMJ7.js.map +1 -1
- package/dist/chunk-CTVJJBBA.js +118 -0
- package/dist/chunk-CTVJJBBA.js.map +1 -0
- package/dist/chunk-FHRZSX3C.js +710 -0
- package/dist/chunk-FHRZSX3C.js.map +1 -0
- package/dist/chunk-JDZPCA3P.js +173 -0
- package/dist/chunk-JDZPCA3P.js.map +1 -0
- package/dist/chunk-MK7557NR.mjs +118 -0
- package/dist/chunk-MK7557NR.mjs.map +1 -0
- package/dist/chunk-NLRREFOX.mjs +710 -0
- package/dist/chunk-NLRREFOX.mjs.map +1 -0
- package/dist/chunk-O3WGNLRO.mjs +173 -0
- package/dist/chunk-O3WGNLRO.mjs.map +1 -0
- package/dist/chunk-PMJAV4JJ.mjs +1 -0
- package/dist/chunk-PMJAV4JJ.mjs.map +1 -0
- package/dist/index.css +63 -70
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/nextjs/client.css +335 -0
- package/dist/nextjs/client.css.map +1 -0
- package/dist/nextjs/client.d.mts +12 -0
- package/dist/nextjs/client.d.ts +12 -0
- package/dist/nextjs/client.js +179 -0
- package/dist/nextjs/client.js.map +1 -0
- package/dist/nextjs/client.mjs +179 -0
- package/dist/nextjs/client.mjs.map +1 -0
- package/dist/nextjs.d.mts +67 -15
- package/dist/nextjs.d.ts +67 -15
- package/dist/nextjs.js +158 -180
- package/dist/nextjs.js.map +1 -1
- package/dist/nextjs.mjs +155 -177
- package/dist/nextjs.mjs.map +1 -1
- package/dist/react.d.mts +31 -81
- package/dist/react.d.ts +31 -81
- package/dist/react.js +35 -634
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +65 -664
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +14 -34
- package/dist/server.d.ts +14 -34
- package/dist/server.js +4 -185
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +10 -191
- package/dist/server.mjs.map +1 -1
- package/dist/storage-B2eAQNdv.d.ts +25 -0
- package/dist/storage-BJPUpxhm.d.mts +25 -0
- package/dist/types-Bqm9OCZN.d.mts +22 -0
- package/dist/types-Bqm9OCZN.d.ts +22 -0
- package/dist/types-HdCjGldB.d.mts +58 -0
- package/dist/types-HdCjGldB.d.ts +58 -0
- package/package.json +26 -17
- package/dist/chunk-5NUJ7LFF.mjs +0 -17
- package/dist/chunk-5NUJ7LFF.mjs.map +0 -1
- package/dist/chunk-KS7ERXGZ.js +0 -481
- package/dist/chunk-KS7ERXGZ.js.map +0 -1
- package/dist/chunk-NINRO7GS.js +0 -209
- package/dist/chunk-NINRO7GS.js.map +0 -1
- package/dist/chunk-NXBKSUKI.mjs +0 -481
- package/dist/chunk-NXBKSUKI.mjs.map +0 -1
- package/dist/chunk-T7HUHQ3J.mjs +0 -209
- package/dist/chunk-T7HUHQ3J.mjs.map +0 -1
- package/dist/chunk-WZLC5B4C.js +0 -17
- package/dist/chunk-WZLC5B4C.js.map +0 -1
- package/dist/index-DoDoIY_K.d.mts +0 -79
- 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 };
|