@asgardeo/react 0.3.0 → 0.5.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 +12 -4
- package/dist/__temp__/api.d.ts +26 -21
- package/dist/__temp__/models.d.ts +14 -22
- package/dist/api/scim2/createOrganization.d.ts +74 -0
- package/dist/api/scim2/getAllOrganizations.d.ts +56 -0
- package/dist/api/scim2/getMeOrganizations.d.ts +52 -0
- package/dist/api/scim2/getOrganization.d.ts +61 -0
- package/dist/api/scim2/updateOrganization.d.ts +74 -0
- package/dist/cjs/index.js +9863 -1190
- package/dist/cjs/index.js.map +4 -4
- package/dist/components/actions/SignInButton/BaseSignInButton.d.ts +7 -6
- package/dist/components/actions/SignInButton/SignInButton.d.ts +21 -2
- package/dist/components/actions/SignOutButton/BaseSignOutButton.d.ts +7 -6
- package/dist/components/actions/SignOutButton/SignOutButton.d.ts +22 -1
- package/dist/components/actions/SignUpButton/BaseSignUpButton.d.ts +6 -5
- package/dist/components/actions/SignUpButton/SignUpButton.d.ts +21 -0
- package/dist/components/control/AsgardeoLoading.d.ts +45 -0
- package/dist/components/factories/FieldFactory.d.ts +107 -0
- package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.d.ts +53 -0
- package/dist/components/presentation/CreateOrganization/CreateOrganization.d.ts +67 -0
- package/dist/components/presentation/Organization/BaseOrganization.d.ts +66 -0
- package/dist/components/presentation/Organization/Organization.d.ts +66 -0
- package/dist/components/presentation/OrganizationList/BaseOrganizationList.d.ts +117 -0
- package/dist/components/presentation/OrganizationList/OrganizationList.d.ts +93 -0
- package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.d.ts +153 -0
- package/dist/components/presentation/OrganizationProfile/OrganizationProfile.d.ts +119 -0
- package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.d.ts +141 -0
- package/dist/components/presentation/OrganizationSwitcher/OrganizationSwitcher.d.ts +70 -0
- package/dist/components/presentation/SignIn/BaseSignIn.d.ts +114 -0
- package/dist/components/presentation/SignIn/SignIn.d.ts +63 -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/SignUp/BaseSignUp.d.ts +126 -0
- package/dist/components/presentation/SignUp/SignUp.d.ts +55 -0
- package/dist/components/presentation/SignUp/options/CheckboxInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/DateInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/DividerComponent.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/EmailInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/FormContainer.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/GoogleButton.d.ts +25 -0
- package/dist/components/presentation/SignUp/options/ImageComponent.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/NumberInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/PasswordInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/SignUpOptionFactory.d.ts +100 -0
- package/dist/components/presentation/SignUp/options/SocialButton.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/SubmitButton.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/TelephoneInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/TextInput.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/Typography.d.ts +24 -0
- package/dist/components/presentation/SignUp/options/index.d.ts +26 -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 +34 -22
- package/dist/components/presentation/UserDropdown/UserDropdown.d.ts +60 -4
- package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +34 -11
- package/dist/components/presentation/UserProfile/UserProfile.d.ts +1 -1
- package/dist/components/primitives/Alert/Alert.d.ts +74 -0
- package/dist/components/primitives/Avatar/Avatar.d.ts +21 -8
- package/dist/components/primitives/Button/Button.d.ts +83 -0
- package/dist/components/primitives/Card/Card.d.ts +132 -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/Building.d.ts +40 -0
- package/dist/components/primitives/Icons/BuildingAlt.d.ts +40 -0
- package/dist/components/primitives/Icons/Check.d.ts +40 -0
- package/dist/components/primitives/Icons/ChevronDown.d.ts +40 -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/LogOut.d.ts +23 -0
- package/dist/components/primitives/Icons/Plus.d.ts +23 -0
- package/dist/components/primitives/Icons/Settings.d.ts +0 -0
- package/dist/components/primitives/Icons/TriangleAlert.d.ts +23 -0
- package/dist/components/primitives/Icons/User.d.ts +23 -0
- package/dist/components/primitives/Icons/X.d.ts +23 -0
- package/dist/components/primitives/Icons/index.d.ts +27 -0
- package/dist/components/primitives/InputLabel/InputLabel.d.ts +46 -0
- package/dist/components/primitives/KeyValueInput/KeyValueInput.d.ts +123 -0
- package/dist/components/primitives/KeyValueInput/index.d.ts +0 -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 +73 -36
- 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} +3 -1
- 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/contexts/Organization/OrganizationContext.d.ts +74 -0
- package/dist/contexts/Organization/OrganizationProvider.d.ts +90 -0
- package/dist/contexts/Organization/useOrganization.d.ts +104 -0
- package/dist/{theme → contexts/Theme}/ThemeProvider.d.ts +2 -1
- package/dist/{theme → contexts/Theme}/types.d.ts +38 -9
- package/dist/{theme → contexts/Theme}/useTheme.d.ts +2 -1
- package/dist/contexts/User/UserContext.d.ts +33 -0
- package/dist/contexts/User/UserProvider.d.ts +56 -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 +133 -9
- package/dist/index.js +9949 -1203
- 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/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, EmbeddedFlowExecuteResponse, SignUpOptions, EmbeddedFlowExecuteRequestPayload, EmbeddedSignInFlowHandleRequestPayload, Organization, EmbeddedFlowExecuteRequestConfig } from '@asgardeo/browser';
|
|
19
19
|
import { AsgardeoReactConfig } from './models/config';
|
|
20
20
|
/**
|
|
21
21
|
* Client for mplementing Asgardeo in React applications.
|
|
@@ -26,12 +26,20 @@ import { AsgardeoReactConfig } from './models/config';
|
|
|
26
26
|
declare class AsgardeoReactClient<T extends AsgardeoReactConfig = AsgardeoReactConfig> extends AsgardeoBrowserClient<T> {
|
|
27
27
|
private asgardeo;
|
|
28
28
|
constructor();
|
|
29
|
-
initialize(config:
|
|
30
|
-
getUser(): Promise<
|
|
29
|
+
initialize(config: AsgardeoReactConfig): Promise<boolean>;
|
|
30
|
+
getUser(): Promise<User>;
|
|
31
|
+
getUserProfile(): Promise<UserProfile>;
|
|
32
|
+
getOrganizations(): Promise<Organization[]>;
|
|
33
|
+
getCurrentOrganization(): Promise<Organization | null>;
|
|
34
|
+
switchOrganization(organization: Organization): Promise<void>;
|
|
31
35
|
isLoading(): boolean;
|
|
36
|
+
isInitialized(): Promise<boolean>;
|
|
32
37
|
isSignedIn(): Promise<boolean>;
|
|
33
|
-
signIn(options?: SignInOptions): Promise<User>;
|
|
38
|
+
signIn(options?: SignInOptions, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
|
|
39
|
+
signIn(payload: EmbeddedSignInFlowHandleRequestPayload, request: EmbeddedFlowExecuteRequestConfig, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
|
|
34
40
|
signOut(options?: SignOutOptions, afterSignOut?: (redirectUrl: string) => void): Promise<string>;
|
|
35
41
|
signOut(options?: SignOutOptions, sessionId?: string, afterSignOut?: (redirectUrl: string) => void): Promise<string>;
|
|
42
|
+
signUp(options?: SignUpOptions): Promise<void>;
|
|
43
|
+
signUp(payload: EmbeddedFlowExecuteRequestPayload): Promise<EmbeddedFlowExecuteResponse>;
|
|
36
44
|
}
|
|
37
45
|
export default AsgardeoReactClient;
|
package/dist/__temp__/api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c) 2025, WSO2
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
3
|
*
|
|
4
|
-
* WSO2
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
5
|
* Version 2.0 (the "License"); you may not use this file except
|
|
6
6
|
* in compliance with the License.
|
|
7
7
|
* You may obtain a copy of the License at
|
|
@@ -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, IdToken, 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.
|
|
@@ -45,6 +44,12 @@ declare class AuthAPI {
|
|
|
45
44
|
* @returns {Promise<AuthClientConfig<Config>>} - A promise that resolves with the configuration data.
|
|
46
45
|
*/
|
|
47
46
|
getConfigData(): Promise<AuthClientConfig<Config>>;
|
|
47
|
+
/**
|
|
48
|
+
* Method to get the configuration data.
|
|
49
|
+
*
|
|
50
|
+
* @returns {Promise<AuthClientConfig<Config>>} - A promise that resolves with the configuration data.
|
|
51
|
+
*/
|
|
52
|
+
isInitialized(): Promise<boolean>;
|
|
48
53
|
/**
|
|
49
54
|
* Method to handle user Sign In requests.
|
|
50
55
|
*
|
|
@@ -52,9 +57,9 @@ declare class AuthAPI {
|
|
|
52
57
|
* @param {AuthStateInterface} state - Current authentication state in React Auth Context.
|
|
53
58
|
* @param {any} callback - Action to trigger on successful sign in.
|
|
54
59
|
*/
|
|
55
|
-
signIn(config: SignInConfig, authorizationCode?: string, sessionState?: string, authState?: string, callback?: (response:
|
|
60
|
+
signIn(config: SignInConfig, authorizationCode?: string, sessionState?: string, authState?: string, callback?: (response: User) => void, tokenRequestConfig?: {
|
|
56
61
|
params: Record<string, unknown>;
|
|
57
|
-
}): Promise<
|
|
62
|
+
}): Promise<any>;
|
|
58
63
|
/**
|
|
59
64
|
* Method to handle user Sign Out requests.
|
|
60
65
|
*
|
|
@@ -72,9 +77,9 @@ declare class AuthAPI {
|
|
|
72
77
|
/**
|
|
73
78
|
* This method returns a Promise that resolves with the basic user information obtained from the ID token.
|
|
74
79
|
*
|
|
75
|
-
* @return {Promise<
|
|
80
|
+
* @return {Promise<User>} - A promise that resolves with the user information.
|
|
76
81
|
*/
|
|
77
|
-
|
|
82
|
+
getUser(): Promise<User>;
|
|
78
83
|
/**
|
|
79
84
|
* This method sends an API request to a protected endpoint.
|
|
80
85
|
* The access token is automatically attached to the header of the request.
|
|
@@ -83,7 +88,7 @@ declare class AuthAPI {
|
|
|
83
88
|
*
|
|
84
89
|
* @param {HttpRequestConfig} config - The config object containing attributes necessary to send a request.
|
|
85
90
|
*
|
|
86
|
-
* @return {Promise<
|
|
91
|
+
* @return {Promise<Response>} - Returns a Promise that resolves with the response to the request.
|
|
87
92
|
*/
|
|
88
93
|
httpRequest(config: HttpRequestConfig): Promise<HttpResponse<any>>;
|
|
89
94
|
/**
|
|
@@ -94,7 +99,7 @@ declare class AuthAPI {
|
|
|
94
99
|
*
|
|
95
100
|
* @param {HttpRequestConfig[]} config - The config object containing attributes necessary to send a request.
|
|
96
101
|
*
|
|
97
|
-
* @return {Promise<
|
|
102
|
+
* @return {Promise<Response>} - Returns a Promise that resolves with the responses to the requests.
|
|
98
103
|
*/
|
|
99
104
|
httpRequestAll(configs: HttpRequestConfig[]): Promise<HttpResponse<any>[]>;
|
|
100
105
|
/**
|
|
@@ -102,10 +107,10 @@ declare class AuthAPI {
|
|
|
102
107
|
*
|
|
103
108
|
* @param {CustomGrantRequestParams} config - The request parameters.
|
|
104
109
|
*
|
|
105
|
-
* @return {Promise<
|
|
110
|
+
* @return {Promise<Response | SignInResponse>} - A Promise that resolves with
|
|
106
111
|
* the value returned by the custom grant request.
|
|
107
112
|
*/
|
|
108
|
-
|
|
113
|
+
exchangeToken(config: SPACustomGrantConfig, callback: (response: User | Response) => void, dispatch: (state: AuthStateInterface) => void): Promise<User | Response>;
|
|
109
114
|
/**
|
|
110
115
|
* This method ends a user session. The access token is revoked and the session information is destroyed.
|
|
111
116
|
*
|
|
@@ -117,7 +122,7 @@ declare class AuthAPI {
|
|
|
117
122
|
*
|
|
118
123
|
* @return {Promise<ServiceResourcesType} - A Promise that resolves with an object containing the service endpoints.
|
|
119
124
|
*/
|
|
120
|
-
|
|
125
|
+
getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>;
|
|
121
126
|
/**
|
|
122
127
|
* This methods returns the Axios http client.
|
|
123
128
|
*
|
|
@@ -130,20 +135,20 @@ declare class AuthAPI {
|
|
|
130
135
|
* @return {Promise<DecodedIDTokenPayloadInterface>} - A Promise that resolves with
|
|
131
136
|
* the decoded payload of the id token.
|
|
132
137
|
*/
|
|
133
|
-
|
|
138
|
+
getDecodedIdToken(): Promise<IdToken>;
|
|
134
139
|
/**
|
|
135
140
|
* This method decodes the payload of the idp id token and returns it.
|
|
136
141
|
*
|
|
137
142
|
* @return {Promise<DecodedIDTokenPayloadInterface>} - A Promise that resolves with
|
|
138
143
|
* the decoded payload of the idp id token.
|
|
139
144
|
*/
|
|
140
|
-
getDecodedIDPIDToken(): Promise<
|
|
145
|
+
getDecodedIDPIDToken(): Promise<IdToken>;
|
|
141
146
|
/**
|
|
142
147
|
* This method returns the ID token.
|
|
143
148
|
*
|
|
144
149
|
* @return {Promise<string>} - A Promise that resolves with the id token.
|
|
145
150
|
*/
|
|
146
|
-
|
|
151
|
+
getIdToken(): Promise<string>;
|
|
147
152
|
/**
|
|
148
153
|
* This method return a Promise that resolves with the access token.
|
|
149
154
|
*
|
|
@@ -167,13 +172,13 @@ declare class AuthAPI {
|
|
|
167
172
|
* @return {TokenResponseInterface} - A Promise that resolves with an object containing
|
|
168
173
|
* information about the refreshed access token.
|
|
169
174
|
*/
|
|
170
|
-
refreshAccessToken(): Promise<
|
|
175
|
+
refreshAccessToken(): Promise<User>;
|
|
171
176
|
/**
|
|
172
177
|
* This method specifies if the user is authenticated or not.
|
|
173
178
|
*
|
|
174
179
|
* @return {Promise<boolean>} - A Promise that resolves with `true` if teh user is authenticated.
|
|
175
180
|
*/
|
|
176
|
-
|
|
181
|
+
isSignedIn(): Promise<boolean>;
|
|
177
182
|
/**
|
|
178
183
|
* This method specifies if the session is active or not.
|
|
179
184
|
*
|
|
@@ -198,7 +203,7 @@ declare class AuthAPI {
|
|
|
198
203
|
*
|
|
199
204
|
* @param {Partial<AuthClientConfig<T>>} config - A config object to update the SDK configurations with.
|
|
200
205
|
*/
|
|
201
|
-
|
|
206
|
+
reInitialize(config: Partial<AuthClientConfig<Config>>): Promise<void>;
|
|
202
207
|
/**
|
|
203
208
|
* This method attaches a callback function to an event hook that fires the callback when the event happens.
|
|
204
209
|
*
|
|
@@ -214,7 +219,7 @@ declare class AuthAPI {
|
|
|
214
219
|
* First, this method sends a prompt none request to see if there is an active user session in the identity server.
|
|
215
220
|
* If there is one, then it requests the access token and stores it. Else, it returns false.
|
|
216
221
|
*
|
|
217
|
-
* @return {Promise<
|
|
222
|
+
* @return {Promise<User | boolean>} - A Promise that resolves with the user information after signing in
|
|
218
223
|
* or with `false` if the user is not signed in.
|
|
219
224
|
*
|
|
220
225
|
* @example
|
|
@@ -224,6 +229,6 @@ declare class AuthAPI {
|
|
|
224
229
|
*/
|
|
225
230
|
trySignInSilently(state: AuthStateInterface, dispatch: (state: AuthStateInterface) => void, additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: {
|
|
226
231
|
params: Record<string, unknown>;
|
|
227
|
-
}): Promise<
|
|
232
|
+
}): Promise<User | boolean | undefined>;
|
|
228
233
|
}
|
|
229
234
|
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, IdToken, 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
|
-
getDecodedIDPIDToken(): Promise<
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
getDecodedIDPIDToken(): Promise<IdToken>;
|
|
73
|
+
getDecodedIdToken(): Promise<IdToken>;
|
|
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;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { Organization } from '@asgardeo/browser';
|
|
19
|
+
/**
|
|
20
|
+
* Interface for organization creation payload.
|
|
21
|
+
*/
|
|
22
|
+
export interface CreateOrganizationPayload {
|
|
23
|
+
/**
|
|
24
|
+
* Organization description.
|
|
25
|
+
*/
|
|
26
|
+
description: string;
|
|
27
|
+
/**
|
|
28
|
+
* Organization handle/slug.
|
|
29
|
+
*/
|
|
30
|
+
orgHandle?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Organization name.
|
|
33
|
+
*/
|
|
34
|
+
name: string;
|
|
35
|
+
/**
|
|
36
|
+
* Parent organization ID.
|
|
37
|
+
*/
|
|
38
|
+
parentId: string;
|
|
39
|
+
/**
|
|
40
|
+
* Organization type.
|
|
41
|
+
*/
|
|
42
|
+
type: 'TENANT';
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new organization.
|
|
46
|
+
*
|
|
47
|
+
* @param config - Configuration object containing baseUrl, payload and optional request config.
|
|
48
|
+
* @returns A promise that resolves with the created organization information.
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* try {
|
|
52
|
+
* const organization = await createOrganization({
|
|
53
|
+
* baseUrl: "https://api.asgardeo.io/t/<ORGANIZATION>",
|
|
54
|
+
* payload: {
|
|
55
|
+
* description: "Share your screens",
|
|
56
|
+
* name: "Team Viewer",
|
|
57
|
+
* orgHandle: "team-viewer",
|
|
58
|
+
* parentId: "f4825104-4948-40d9-ab65-a960eee3e3d5",
|
|
59
|
+
* type: "TENANT"
|
|
60
|
+
* }
|
|
61
|
+
* });
|
|
62
|
+
* console.log(organization);
|
|
63
|
+
* } catch (error) {
|
|
64
|
+
* if (error instanceof AsgardeoAPIError) {
|
|
65
|
+
* console.error('Failed to create organization:', error.message);
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare const createOrganization: ({ baseUrl, payload, ...requestConfig }: Partial<Request> & {
|
|
71
|
+
baseUrl: string;
|
|
72
|
+
payload: CreateOrganizationPayload;
|
|
73
|
+
}) => Promise<Organization>;
|
|
74
|
+
export default createOrganization;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { Organization } from '@asgardeo/browser';
|
|
19
|
+
/**
|
|
20
|
+
* Interface for paginated organization response.
|
|
21
|
+
*/
|
|
22
|
+
export interface PaginatedOrganizationsResponse {
|
|
23
|
+
hasMore?: boolean;
|
|
24
|
+
nextCursor?: string;
|
|
25
|
+
organizations: Organization[];
|
|
26
|
+
totalCount?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves all organizations with pagination support.
|
|
30
|
+
*
|
|
31
|
+
* @param config - Configuration object containing baseUrl, optional query parameters, and request config.
|
|
32
|
+
* @returns A promise that resolves with the paginated organizations information.
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* try {
|
|
36
|
+
* const response = await getAllOrganizations({
|
|
37
|
+
* baseUrl: "https://api.asgardeo.io/t/<ORGANIZATION>",
|
|
38
|
+
* filter: "",
|
|
39
|
+
* limit: 10,
|
|
40
|
+
* recursive: false
|
|
41
|
+
* });
|
|
42
|
+
* console.log(response.organizations);
|
|
43
|
+
* } catch (error) {
|
|
44
|
+
* if (error instanceof AsgardeoAPIError) {
|
|
45
|
+
* console.error('Failed to get organizations:', error.message);
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare const getAllOrganizations: ({ baseUrl, filter, limit, recursive, ...requestConfig }: Partial<Request> & {
|
|
51
|
+
baseUrl: string;
|
|
52
|
+
filter?: string;
|
|
53
|
+
limit?: number;
|
|
54
|
+
recursive?: boolean;
|
|
55
|
+
}) => Promise<PaginatedOrganizationsResponse>;
|
|
56
|
+
export default getAllOrganizations;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { Organization } from '@asgardeo/browser';
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves the organizations associated with the current user.
|
|
21
|
+
*
|
|
22
|
+
* @param config - Configuration object containing baseUrl, optional query parameters, and request config.
|
|
23
|
+
* @returns A promise that resolves with the organizations information.
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* try {
|
|
27
|
+
* const organizations = await getMeOrganizations({
|
|
28
|
+
* baseUrl: "https://api.asgardeo.io/t/<ORGANIZATION>",
|
|
29
|
+
* after: "",
|
|
30
|
+
* before: "",
|
|
31
|
+
* filter: "",
|
|
32
|
+
* limit: 10,
|
|
33
|
+
* recursive: false
|
|
34
|
+
* });
|
|
35
|
+
* console.log(organizations);
|
|
36
|
+
* } catch (error) {
|
|
37
|
+
* if (error instanceof AsgardeoAPIError) {
|
|
38
|
+
* console.error('Failed to get organizations:', error.message);
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare const getMeOrganizations: ({ baseUrl, after, authorizedAppName, before, filter, limit, recursive, ...requestConfig }: Partial<Request> & {
|
|
44
|
+
baseUrl: string;
|
|
45
|
+
after?: string;
|
|
46
|
+
authorizedAppName?: string;
|
|
47
|
+
before?: string;
|
|
48
|
+
filter?: string;
|
|
49
|
+
limit?: number;
|
|
50
|
+
recursive?: boolean;
|
|
51
|
+
}) => Promise<Organization[]>;
|
|
52
|
+
export default getMeOrganizations;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Extended organization interface with additional properties
|
|
20
|
+
*/
|
|
21
|
+
export interface OrganizationDetails {
|
|
22
|
+
attributes?: Record<string, any>;
|
|
23
|
+
created?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
id: string;
|
|
26
|
+
lastModified?: string;
|
|
27
|
+
name: string;
|
|
28
|
+
orgHandle: string;
|
|
29
|
+
parent?: {
|
|
30
|
+
id: string;
|
|
31
|
+
ref: string;
|
|
32
|
+
};
|
|
33
|
+
permissions?: string[];
|
|
34
|
+
status?: string;
|
|
35
|
+
type?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves detailed information for a specific organization.
|
|
39
|
+
*
|
|
40
|
+
* @param config - Configuration object containing baseUrl, organizationId, and request config.
|
|
41
|
+
* @returns A promise that resolves with the organization details.
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* try {
|
|
45
|
+
* const organization = await getOrganization({
|
|
46
|
+
* baseUrl: "https://api.asgardeo.io/t/dxlab",
|
|
47
|
+
* organizationId: "0d5e071b-d3d3-475d-b3c6-1a20ee2fa9b1"
|
|
48
|
+
* });
|
|
49
|
+
* console.log(organization);
|
|
50
|
+
* } catch (error) {
|
|
51
|
+
* if (error instanceof AsgardeoAPIError) {
|
|
52
|
+
* console.error('Failed to get organization:', error.message);
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare const getOrganization: ({ baseUrl, organizationId, ...requestConfig }: Partial<Request> & {
|
|
58
|
+
baseUrl: string;
|
|
59
|
+
organizationId: string;
|
|
60
|
+
}) => Promise<OrganizationDetails>;
|
|
61
|
+
export default getOrganization;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { OrganizationDetails } from './getOrganization';
|
|
19
|
+
/**
|
|
20
|
+
* Updates the organization information using the Organizations Management API.
|
|
21
|
+
*
|
|
22
|
+
* @param baseUrl - The base URL for the API.
|
|
23
|
+
* @param organizationId - The ID of the organization to update.
|
|
24
|
+
* @param operations - Array of patch operations to apply.
|
|
25
|
+
* @param requestConfig - Additional request config if needed.
|
|
26
|
+
* @returns A promise that resolves with the updated organization information.
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* // Using the helper function to create operations automatically
|
|
30
|
+
* const operations = createPatchOperations({
|
|
31
|
+
* name: "Updated Organization Name", // Will use REPLACE
|
|
32
|
+
* description: "", // Will use REMOVE (empty string)
|
|
33
|
+
* customField: "Some value" // Will use REPLACE
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* await updateOrganization({
|
|
37
|
+
* baseUrl: "https://api.asgardeo.io/t/<ORG>",
|
|
38
|
+
* organizationId: "0d5e071b-d3d3-475d-b3c6-1a20ee2fa9b1",
|
|
39
|
+
* operations
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // Or manually specify operations
|
|
43
|
+
* await updateOrganization({
|
|
44
|
+
* baseUrl: "https://api.asgardeo.io/t/<ORG>",
|
|
45
|
+
* organizationId: "0d5e071b-d3d3-475d-b3c6-1a20ee2fa9b1",
|
|
46
|
+
* operations: [
|
|
47
|
+
* { operation: "REPLACE", path: "/name", value: "Updated Organization Name" },
|
|
48
|
+
* { operation: "REMOVE", path: "/description" }
|
|
49
|
+
* ]
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare const updateOrganization: ({ baseUrl, organizationId, operations, ...requestConfig }: {
|
|
54
|
+
baseUrl: string;
|
|
55
|
+
organizationId: string;
|
|
56
|
+
operations: Array<{
|
|
57
|
+
operation: "REPLACE" | "ADD" | "REMOVE";
|
|
58
|
+
path: string;
|
|
59
|
+
value?: any;
|
|
60
|
+
}>;
|
|
61
|
+
} & Partial<Request>) => Promise<OrganizationDetails>;
|
|
62
|
+
/**
|
|
63
|
+
* Helper function to convert field updates to patch operations format.
|
|
64
|
+
* Uses REMOVE operation when the value is empty, otherwise uses REPLACE.
|
|
65
|
+
*
|
|
66
|
+
* @param payload - Object containing field updates
|
|
67
|
+
* @returns Array of patch operations
|
|
68
|
+
*/
|
|
69
|
+
export declare const createPatchOperations: (payload: Record<string, any>) => Array<{
|
|
70
|
+
operation: "REPLACE" | "REMOVE";
|
|
71
|
+
path: string;
|
|
72
|
+
value?: any;
|
|
73
|
+
}>;
|
|
74
|
+
export default updateOrganization;
|