@asgardeo/react 0.3.0 → 0.4.0
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 +5 -1
- package/dist/AsgardeoReactClient.d.ts +3 -2
- package/dist/__temp__/api.d.ts +17 -18
- package/dist/__temp__/models.d.ts +13 -21
- package/dist/cjs/index.js +17252 -1209
- package/dist/cjs/index.js.map +4 -4
- package/dist/components/actions/SignInButton/BaseSignInButton.d.ts +4 -3
- package/dist/components/actions/SignInButton/SignInButton.d.ts +21 -2
- package/dist/components/actions/SignOutButton/BaseSignOutButton.d.ts +4 -3
- package/dist/components/actions/SignOutButton/SignOutButton.d.ts +22 -1
- package/dist/components/actions/SignUpButton/BaseSignUpButton.d.ts +2 -1
- package/dist/components/actions/SignUpButton/SignUpButton.d.ts +21 -0
- package/dist/components/factories/FieldFactory.d.ts +107 -0
- package/dist/components/presentation/SignIn/BaseSignIn.d.ts +125 -0
- package/dist/components/presentation/SignIn/SignIn.d.ts +62 -0
- package/dist/components/presentation/SignIn/options/EmailOtp.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/FacebookButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/GitHubButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/GoogleButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/IdentifierFirst.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/LinkedInButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/MicrosoftButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/MultiOptionButton.d.ts +26 -0
- package/dist/components/presentation/SignIn/options/SignInOptionFactory.d.ts +76 -0
- package/dist/components/presentation/SignIn/options/SignInWithEthereumButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/SmsOtp.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/SocialButton.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/Totp.d.ts +25 -0
- package/dist/components/presentation/SignIn/options/UsernamePassword.d.ts +25 -0
- package/dist/components/presentation/SignIn/types.d.ts +124 -0
- package/dist/components/presentation/User/BaseUser.d.ts +66 -0
- package/dist/components/presentation/{User.d.ts → User/User.d.ts} +9 -4
- package/dist/components/presentation/UserDropdown/BaseUserDropdown.d.ts +1 -1
- package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +23 -2
- package/dist/components/primitives/Alert/Alert.d.ts +74 -0
- package/dist/components/primitives/Button/Button.d.ts +83 -0
- package/dist/components/primitives/Card/Card.d.ts +133 -0
- package/dist/components/primitives/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/primitives/DatePicker/DatePicker.d.ts +1 -1
- package/dist/components/primitives/Divider/Divider.d.ts +58 -0
- package/dist/components/primitives/FormControl/FormControl.d.ts +50 -0
- package/dist/components/primitives/Icons/CircleAlert.d.ts +23 -0
- package/dist/components/primitives/Icons/CircleCheck.d.ts +23 -0
- package/dist/components/primitives/Icons/Eye.d.ts +23 -0
- package/dist/components/primitives/Icons/EyeOff.d.ts +23 -0
- package/dist/components/primitives/Icons/Info.d.ts +23 -0
- package/dist/components/primitives/Icons/TriangleAlert.d.ts +23 -0
- package/dist/components/primitives/InputLabel/InputLabel.d.ts +46 -0
- package/dist/components/primitives/OtpField/OtpField.d.ts +86 -0
- package/dist/components/primitives/PasswordField/PasswordField.d.ts +31 -0
- package/dist/components/primitives/Popover/Popover.d.ts +71 -34
- package/dist/components/primitives/Select/Select.d.ts +1 -1
- package/dist/components/primitives/Spinner/Spinner.d.ts +54 -0
- package/dist/components/primitives/TextField/TextField.d.ts +18 -2
- package/dist/components/primitives/Typography/Typography.d.ts +81 -0
- package/dist/contexts/{AsgardeoContext.d.ts → Asgardeo/AsgardeoContext.d.ts} +1 -0
- package/dist/{providers → contexts/Asgardeo}/AsgardeoProvider.d.ts +1 -1
- package/dist/{hooks → contexts/Asgardeo}/useAsgardeo.d.ts +1 -1
- package/dist/contexts/Flow/FlowContext.d.ts +73 -0
- package/dist/contexts/Flow/FlowProvider.d.ts +46 -0
- package/dist/contexts/Flow/useFlow.d.ts +48 -0
- package/dist/contexts/I18n/I18nContext.d.ts +42 -0
- package/dist/contexts/I18n/I18nProvider.d.ts +31 -0
- package/dist/contexts/I18n/useI18n.d.ts +27 -0
- package/dist/{theme → contexts/Theme}/ThemeProvider.d.ts +2 -1
- package/dist/{theme → contexts/Theme}/useTheme.d.ts +2 -1
- package/dist/contexts/User/UserContext.d.ts +32 -0
- package/dist/contexts/User/UserProvider.d.ts +55 -0
- package/dist/contexts/User/useUser.d.ts +94 -0
- package/dist/hooks/useForm.d.ts +192 -0
- package/dist/hooks/useTranslation.d.ts +52 -0
- package/dist/index.d.ts +94 -9
- package/dist/index.js +17242 -1113
- package/dist/index.js.map +4 -4
- package/dist/utils/getMappedUserProfileValue.d.ts +33 -1
- package/package.json +6 -5
- package/dist/utils/getUserProfile.d.ts +0 -59
- /package/dist/{theme → contexts/Theme}/ThemeContext.d.ts +0 -0
- /package/dist/{theme → contexts/Theme}/types.d.ts +0 -0
package/README.md
CHANGED
|
@@ -124,6 +124,10 @@ function App() {
|
|
|
124
124
|
}
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
+
## Documentation
|
|
128
|
+
|
|
129
|
+
For complete API documentation including all components, hooks, and customization options, see [API.md](./API.md).
|
|
130
|
+
|
|
127
131
|
## License
|
|
128
132
|
|
|
129
|
-
Apache
|
|
133
|
+
Licenses this source under the Apache License, Version 2.0 [LICENSE](../../LICENSE), You may not use this file except in compliance with the License.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { AsgardeoBrowserClient, SignInOptions, SignOutOptions, User } from '@asgardeo/browser';
|
|
18
|
+
import { AsgardeoBrowserClient, UserProfile, SignInOptions, SignOutOptions, User } from '@asgardeo/browser';
|
|
19
19
|
import { AsgardeoReactConfig } from './models/config';
|
|
20
20
|
/**
|
|
21
21
|
* Client for mplementing Asgardeo in React applications.
|
|
@@ -27,7 +27,8 @@ declare class AsgardeoReactClient<T extends AsgardeoReactConfig = AsgardeoReactC
|
|
|
27
27
|
private asgardeo;
|
|
28
28
|
constructor();
|
|
29
29
|
initialize(config: T): Promise<boolean>;
|
|
30
|
-
getUser(): Promise<
|
|
30
|
+
getUser(): Promise<User>;
|
|
31
|
+
getUserProfile(): Promise<UserProfile>;
|
|
31
32
|
isLoading(): boolean;
|
|
32
33
|
isSignedIn(): Promise<boolean>;
|
|
33
34
|
signIn(options?: SignInOptions): Promise<User>;
|
package/dist/__temp__/api.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { AsgardeoSPAClient, AuthClientConfig,
|
|
18
|
+
import { AsgardeoSPAClient, AuthClientConfig, User, LegacyConfig as Config, IdTokenPayload, Hooks, HttpClientInstance, HttpRequestConfig, HttpResponse, OIDCEndpoints, SignInConfig, SPACustomGrantConfig } from '@asgardeo/browser';
|
|
19
19
|
import { AuthStateInterface } from './models';
|
|
20
20
|
declare class AuthAPI {
|
|
21
21
|
static DEFAULT_STATE: AuthStateInterface;
|
|
@@ -25,7 +25,6 @@ declare class AuthAPI {
|
|
|
25
25
|
constructor(spaClient?: AsgardeoSPAClient);
|
|
26
26
|
_setIsLoading(isLoading: boolean): void;
|
|
27
27
|
_getIsLoading(): boolean;
|
|
28
|
-
isSignedIn(): Promise<boolean>;
|
|
29
28
|
isLoading(): boolean;
|
|
30
29
|
/**
|
|
31
30
|
* Method to return Auth Client instance authentication state.
|
|
@@ -52,9 +51,9 @@ declare class AuthAPI {
|
|
|
52
51
|
* @param {AuthStateInterface} state - Current authentication state in React Auth Context.
|
|
53
52
|
* @param {any} callback - Action to trigger on successful sign in.
|
|
54
53
|
*/
|
|
55
|
-
signIn(config: SignInConfig, authorizationCode?: string, sessionState?: string, authState?: string, callback?: (response:
|
|
54
|
+
signIn(config: SignInConfig, authorizationCode?: string, sessionState?: string, authState?: string, callback?: (response: User) => void, tokenRequestConfig?: {
|
|
56
55
|
params: Record<string, unknown>;
|
|
57
|
-
}): Promise<
|
|
56
|
+
}): Promise<any>;
|
|
58
57
|
/**
|
|
59
58
|
* Method to handle user Sign Out requests.
|
|
60
59
|
*
|
|
@@ -72,9 +71,9 @@ declare class AuthAPI {
|
|
|
72
71
|
/**
|
|
73
72
|
* This method returns a Promise that resolves with the basic user information obtained from the ID token.
|
|
74
73
|
*
|
|
75
|
-
* @return {Promise<
|
|
74
|
+
* @return {Promise<User>} - A promise that resolves with the user information.
|
|
76
75
|
*/
|
|
77
|
-
|
|
76
|
+
getUser(): Promise<User>;
|
|
78
77
|
/**
|
|
79
78
|
* This method sends an API request to a protected endpoint.
|
|
80
79
|
* The access token is automatically attached to the header of the request.
|
|
@@ -83,7 +82,7 @@ declare class AuthAPI {
|
|
|
83
82
|
*
|
|
84
83
|
* @param {HttpRequestConfig} config - The config object containing attributes necessary to send a request.
|
|
85
84
|
*
|
|
86
|
-
* @return {Promise<
|
|
85
|
+
* @return {Promise<Response>} - Returns a Promise that resolves with the response to the request.
|
|
87
86
|
*/
|
|
88
87
|
httpRequest(config: HttpRequestConfig): Promise<HttpResponse<any>>;
|
|
89
88
|
/**
|
|
@@ -94,7 +93,7 @@ declare class AuthAPI {
|
|
|
94
93
|
*
|
|
95
94
|
* @param {HttpRequestConfig[]} config - The config object containing attributes necessary to send a request.
|
|
96
95
|
*
|
|
97
|
-
* @return {Promise<
|
|
96
|
+
* @return {Promise<Response>} - Returns a Promise that resolves with the responses to the requests.
|
|
98
97
|
*/
|
|
99
98
|
httpRequestAll(configs: HttpRequestConfig[]): Promise<HttpResponse<any>[]>;
|
|
100
99
|
/**
|
|
@@ -102,10 +101,10 @@ declare class AuthAPI {
|
|
|
102
101
|
*
|
|
103
102
|
* @param {CustomGrantRequestParams} config - The request parameters.
|
|
104
103
|
*
|
|
105
|
-
* @return {Promise<
|
|
104
|
+
* @return {Promise<Response | SignInResponse>} - A Promise that resolves with
|
|
106
105
|
* the value returned by the custom grant request.
|
|
107
106
|
*/
|
|
108
|
-
|
|
107
|
+
exchangeToken(config: SPACustomGrantConfig, callback: (response: User | Response) => void, dispatch: (state: AuthStateInterface) => void): Promise<User | Response>;
|
|
109
108
|
/**
|
|
110
109
|
* This method ends a user session. The access token is revoked and the session information is destroyed.
|
|
111
110
|
*
|
|
@@ -117,7 +116,7 @@ declare class AuthAPI {
|
|
|
117
116
|
*
|
|
118
117
|
* @return {Promise<ServiceResourcesType} - A Promise that resolves with an object containing the service endpoints.
|
|
119
118
|
*/
|
|
120
|
-
|
|
119
|
+
getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
|
|
121
120
|
/**
|
|
122
121
|
* This methods returns the Axios http client.
|
|
123
122
|
*
|
|
@@ -130,7 +129,7 @@ declare class AuthAPI {
|
|
|
130
129
|
* @return {Promise<DecodedIDTokenPayloadInterface>} - A Promise that resolves with
|
|
131
130
|
* the decoded payload of the id token.
|
|
132
131
|
*/
|
|
133
|
-
|
|
132
|
+
getDecodedIdToken(): Promise<IdTokenPayload>;
|
|
134
133
|
/**
|
|
135
134
|
* This method decodes the payload of the idp id token and returns it.
|
|
136
135
|
*
|
|
@@ -143,7 +142,7 @@ declare class AuthAPI {
|
|
|
143
142
|
*
|
|
144
143
|
* @return {Promise<string>} - A Promise that resolves with the id token.
|
|
145
144
|
*/
|
|
146
|
-
|
|
145
|
+
getIdToken(): Promise<string>;
|
|
147
146
|
/**
|
|
148
147
|
* This method return a Promise that resolves with the access token.
|
|
149
148
|
*
|
|
@@ -167,13 +166,13 @@ declare class AuthAPI {
|
|
|
167
166
|
* @return {TokenResponseInterface} - A Promise that resolves with an object containing
|
|
168
167
|
* information about the refreshed access token.
|
|
169
168
|
*/
|
|
170
|
-
refreshAccessToken(): Promise<
|
|
169
|
+
refreshAccessToken(): Promise<User>;
|
|
171
170
|
/**
|
|
172
171
|
* This method specifies if the user is authenticated or not.
|
|
173
172
|
*
|
|
174
173
|
* @return {Promise<boolean>} - A Promise that resolves with `true` if teh user is authenticated.
|
|
175
174
|
*/
|
|
176
|
-
|
|
175
|
+
isSignedIn(): Promise<boolean>;
|
|
177
176
|
/**
|
|
178
177
|
* This method specifies if the session is active or not.
|
|
179
178
|
*
|
|
@@ -198,7 +197,7 @@ declare class AuthAPI {
|
|
|
198
197
|
*
|
|
199
198
|
* @param {Partial<AuthClientConfig<T>>} config - A config object to update the SDK configurations with.
|
|
200
199
|
*/
|
|
201
|
-
|
|
200
|
+
reInitialize(config: Partial<AuthClientConfig<Config>>): Promise<void>;
|
|
202
201
|
/**
|
|
203
202
|
* This method attaches a callback function to an event hook that fires the callback when the event happens.
|
|
204
203
|
*
|
|
@@ -214,7 +213,7 @@ declare class AuthAPI {
|
|
|
214
213
|
* First, this method sends a prompt none request to see if there is an active user session in the identity server.
|
|
215
214
|
* If there is one, then it requests the access token and stores it. Else, it returns false.
|
|
216
215
|
*
|
|
217
|
-
* @return {Promise<
|
|
216
|
+
* @return {Promise<User | boolean>} - A Promise that resolves with the user information after signing in
|
|
218
217
|
* or with `false` if the user is not signed in.
|
|
219
218
|
*
|
|
220
219
|
* @example
|
|
@@ -224,6 +223,6 @@ declare class AuthAPI {
|
|
|
224
223
|
*/
|
|
225
224
|
trySignInSilently(state: AuthStateInterface, dispatch: (state: AuthStateInterface) => void, additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: {
|
|
226
225
|
params: Record<string, unknown>;
|
|
227
|
-
}): Promise<
|
|
226
|
+
}): Promise<User | boolean | undefined>;
|
|
228
227
|
}
|
|
229
228
|
export default AuthAPI;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { AsgardeoAuthException, AuthClientConfig, AuthSPAClientConfig,
|
|
18
|
+
import { AsgardeoAuthException, AuthClientConfig, AuthSPAClientConfig, Config, TokenExchangeRequestConfig, IdTokenPayload, Hooks, HttpClientInstance, HttpRequestConfig, HttpResponse, OIDCEndpoints, SignInConfig, User } from '@asgardeo/browser';
|
|
19
19
|
export interface ReactConfig {
|
|
20
20
|
/**
|
|
21
21
|
* The SDK's `AuthProvider` by default is listening to the URL changes to see
|
|
@@ -36,10 +36,6 @@ export type AuthReactConfig = AuthSPAClientConfig & ReactConfig;
|
|
|
36
36
|
* via `state` object from `useAuthContext` hook.
|
|
37
37
|
*/
|
|
38
38
|
export interface AuthStateInterface {
|
|
39
|
-
/**
|
|
40
|
-
* The scopes that are allowed for the user.
|
|
41
|
-
*/
|
|
42
|
-
allowedScopes: string;
|
|
43
39
|
/**
|
|
44
40
|
* The display name of the user.
|
|
45
41
|
*/
|
|
@@ -51,44 +47,40 @@ export interface AuthStateInterface {
|
|
|
51
47
|
/**
|
|
52
48
|
* Specifies if the user is authenticated or not.
|
|
53
49
|
*/
|
|
54
|
-
|
|
50
|
+
isSignedIn: boolean;
|
|
55
51
|
/**
|
|
56
52
|
* Are the Auth requests loading.
|
|
57
53
|
*/
|
|
58
54
|
isLoading: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* The uid corresponding to the user who the ID token belonged to.
|
|
61
|
-
*/
|
|
62
|
-
sub?: string;
|
|
63
55
|
/**
|
|
64
56
|
* The username of the user.
|
|
65
57
|
*/
|
|
66
58
|
username?: string;
|
|
67
59
|
}
|
|
68
60
|
export interface AuthContextInterface {
|
|
69
|
-
signIn: (config?: SignInConfig, authorizationCode?: string, sessionState?: string, state?: string, callback?: (response:
|
|
61
|
+
signIn: (config?: SignInConfig, authorizationCode?: string, sessionState?: string, state?: string, callback?: (response: User) => void, tokenRequestConfig?: {
|
|
70
62
|
params: Record<string, unknown>;
|
|
71
|
-
}) => Promise<
|
|
63
|
+
}) => Promise<User>;
|
|
72
64
|
signOut: (callback?: (response: boolean) => void) => Promise<boolean>;
|
|
73
|
-
|
|
65
|
+
getUser(): Promise<User>;
|
|
74
66
|
httpRequest(config: HttpRequestConfig): Promise<HttpResponse<any>>;
|
|
75
67
|
httpRequestAll(configs: HttpRequestConfig[]): Promise<HttpResponse<any>[]>;
|
|
76
|
-
|
|
68
|
+
exchangeToken(config: TokenExchangeRequestConfig, callback?: (response: User | Response) => void): void;
|
|
77
69
|
revokeAccessToken(): Promise<boolean>;
|
|
78
|
-
|
|
70
|
+
getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
|
|
79
71
|
getHttpClient(): Promise<HttpClientInstance>;
|
|
80
72
|
getDecodedIDPIDToken(): Promise<IdTokenPayload>;
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
getDecodedIdToken(): Promise<IdTokenPayload>;
|
|
74
|
+
getIdToken(): Promise<string>;
|
|
83
75
|
getAccessToken(): Promise<string>;
|
|
84
|
-
refreshAccessToken(): Promise<
|
|
85
|
-
|
|
76
|
+
refreshAccessToken(): Promise<User>;
|
|
77
|
+
isSignedIn(): Promise<boolean>;
|
|
86
78
|
enableHttpHandler(): Promise<boolean>;
|
|
87
79
|
disableHttpHandler(): Promise<boolean>;
|
|
88
|
-
|
|
80
|
+
reInitialize(config: Partial<AuthClientConfig<Config>>): Promise<void>;
|
|
89
81
|
trySignInSilently: (additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: {
|
|
90
82
|
params: Record<string, unknown>;
|
|
91
|
-
}) => Promise<boolean |
|
|
83
|
+
}) => Promise<boolean | User>;
|
|
92
84
|
on(hook: Hooks.CustomGrant, callback: (response?: any) => void, id: string): void;
|
|
93
85
|
on(hook: Exclude<Hooks, Hooks.CustomGrant>, callback: (response?: any) => void): void;
|
|
94
86
|
on(hook: Hooks, callback: (response?: any) => void, id?: string): void;
|