@asgardeo/react 0.2.4 → 0.3.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.
Files changed (91) hide show
  1. package/README.md +108 -6
  2. package/dist/AsgardeoReactClient.d.ts +37 -0
  3. package/dist/__temp__/api.d.ts +229 -0
  4. package/dist/__temp__/models.d.ts +105 -0
  5. package/dist/api/scim2/getMeProfile.d.ts +39 -0
  6. package/dist/api/scim2/getSchemas.d.ts +39 -0
  7. package/dist/api/scim2/updateMeProfile.d.ts +38 -0
  8. package/dist/cjs/index.js +1955 -0
  9. package/dist/cjs/index.js.map +7 -0
  10. package/dist/components/actions/SignInButton/BaseSignInButton.d.ts +65 -0
  11. package/dist/components/actions/SignInButton/SignInButton.d.ts +46 -0
  12. package/dist/components/actions/SignOutButton/BaseSignOutButton.d.ts +65 -0
  13. package/dist/components/actions/SignOutButton/SignOutButton.d.ts +44 -0
  14. package/dist/components/actions/SignUpButton/BaseSignUpButton.d.ts +65 -0
  15. package/dist/components/actions/SignUpButton/SignUpButton.d.ts +45 -0
  16. package/dist/components/control/SignedIn.d.ts +45 -0
  17. package/dist/components/control/SignedOut.d.ts +45 -0
  18. package/dist/components/presentation/User.d.ts +57 -0
  19. package/dist/components/presentation/UserDropdown/BaseUserDropdown.d.ts +76 -0
  20. package/dist/components/presentation/UserDropdown/UserDropdown.d.ts +49 -0
  21. package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +42 -0
  22. package/dist/components/presentation/UserProfile/UserProfile.d.ts +49 -0
  23. package/dist/{esm/types/components/SignIn/SignIn.d.ts → components/primitives/Avatar/Avatar.d.ts} +25 -14
  24. package/dist/{esm/types/oxygen-ui-react-auth-components/models/component.d.ts → components/primitives/Checkbox/Checkbox.d.ts} +22 -7
  25. package/dist/components/primitives/DatePicker/DatePicker.d.ts +50 -0
  26. package/dist/components/primitives/Popover/Popover.d.ts +59 -0
  27. package/dist/components/primitives/Select/Select.d.ts +60 -0
  28. package/dist/components/primitives/TextField/TextField.d.ts +46 -0
  29. package/dist/contexts/AsgardeoContext.d.ts +56 -0
  30. package/dist/{esm/types/contexts/i18n-context.d.ts → hooks/useAsgardeo.d.ts} +4 -5
  31. package/dist/hooks/useBrowserUrl.d.ts +47 -0
  32. package/dist/index.d.ts +36 -348
  33. package/dist/index.js +1935 -0
  34. package/dist/index.js.map +7 -0
  35. package/dist/{esm/types/oxygen-ui-react-auth-components/index.d.ts → models/config.d.ts} +3 -3
  36. package/dist/{esm/types/hooks/use-config.d.ts → providers/AsgardeoProvider.d.ts} +7 -5
  37. package/dist/{esm/types/models/asgardeo-provider-props.d.ts → theme/ThemeContext.d.ts} +8 -7
  38. package/dist/{esm/types/models/branding-preference-provider-props.d.ts → theme/ThemeProvider.d.ts} +7 -5
  39. package/dist/{esm/types/models/use-on.d.ts → theme/types.d.ts} +22 -12
  40. package/dist/{esm/types/models/public-models.d.ts → theme/useTheme.d.ts} +3 -3
  41. package/dist/{esm/types/models/signed-props.d.ts → utils/getMappedUserProfileValue.d.ts} +3 -6
  42. package/dist/utils/getUserProfile.d.ts +59 -0
  43. package/package.json +55 -60
  44. package/dist/esm/index.js +0 -45278
  45. package/dist/esm/index.js.map +0 -1
  46. package/dist/esm/types/components/SignIn/fragments/BasicAuth.d.ts +0 -35
  47. package/dist/esm/types/components/SignIn/fragments/EmailOtp.d.ts +0 -32
  48. package/dist/esm/types/components/SignIn/fragments/IdentifierFirst.d.ts +0 -35
  49. package/dist/esm/types/components/SignIn/fragments/LoginOptionsBox.d.ts +0 -30
  50. package/dist/esm/types/components/SignIn/fragments/SmsOtp.d.ts +0 -21
  51. package/dist/esm/types/components/SignIn/fragments/Totp.d.ts +0 -33
  52. package/dist/esm/types/components/SignInButton/SignInButton.d.ts +0 -29
  53. package/dist/esm/types/components/SignOutButton/SignOutButton.d.ts +0 -27
  54. package/dist/esm/types/components/SignedIn/SignedIn.d.ts +0 -29
  55. package/dist/esm/types/components/SignedOut/SignedOut.d.ts +0 -29
  56. package/dist/esm/types/components/public-components.d.ts +0 -22
  57. package/dist/esm/types/contexts/asgardeo-context.d.ts +0 -21
  58. package/dist/esm/types/contexts/branding-preference-context.d.ts +0 -21
  59. package/dist/esm/types/hooks/use-authentication.d.ts +0 -27
  60. package/dist/esm/types/hooks/use-on.d.ts +0 -20
  61. package/dist/esm/types/hooks/use-translations.d.ts +0 -33
  62. package/dist/esm/types/index.d.ts +0 -22
  63. package/dist/esm/types/models/auth-context.d.ts +0 -43
  64. package/dist/esm/types/models/basic-auth-props.d.ts +0 -29
  65. package/dist/esm/types/models/email-otp-props.d.ts +0 -26
  66. package/dist/esm/types/models/i18n.d.ts +0 -34
  67. package/dist/esm/types/models/jwt-verify-options.d.ts +0 -25
  68. package/dist/esm/types/models/login-options-box-props.d.ts +0 -24
  69. package/dist/esm/types/models/sign-in.d.ts +0 -49
  70. package/dist/esm/types/models/totp-props.d.ts +0 -26
  71. package/dist/esm/types/models/use-authentication.d.ts +0 -29
  72. package/dist/esm/types/models/use-config.d.ts +0 -22
  73. package/dist/esm/types/models/use-translations.d.ts +0 -22
  74. package/dist/esm/types/oxygen-ui-react-auth-components/SignIn/SignIn.d.ts +0 -79
  75. package/dist/esm/types/oxygen-ui-react-auth-components/SignInAlert/SignInAlert.d.ts +0 -37
  76. package/dist/esm/types/oxygen-ui-react-auth-components/SignInButton/SignInButton.d.ts +0 -27
  77. package/dist/esm/types/oxygen-ui-react-auth-components/SignInDivider/SignInDivider.d.ts +0 -26
  78. package/dist/esm/types/oxygen-ui-react-auth-components/SignInFooter/SignInFooter.d.ts +0 -29
  79. package/dist/esm/types/oxygen-ui-react-auth-components/SignInImage/SignInImage.d.ts +0 -23
  80. package/dist/esm/types/oxygen-ui-react-auth-components/SignInLink/SignInLink.d.ts +0 -25
  81. package/dist/esm/types/oxygen-ui-react-auth-components/SignInPaper/SignInPaper.d.ts +0 -26
  82. package/dist/esm/types/oxygen-ui-react-auth-components/SignInPinInput/SignInPinInput.d.ts +0 -30
  83. package/dist/esm/types/oxygen-ui-react-auth-components/SignInTextField/SignInTextField.d.ts +0 -26
  84. package/dist/esm/types/oxygen-ui-react-auth-components/SignInTypography/SignInTypography.d.ts +0 -32
  85. package/dist/esm/types/providers/AsgardeoProvider.d.ts +0 -34
  86. package/dist/esm/types/providers/BrandingPreferenceProvider.d.ts +0 -32
  87. package/dist/esm/types/providers/I18nProvider.d.ts +0 -33
  88. package/dist/esm/types/theme/generate-theme-sign-in.d.ts +0 -28
  89. package/dist/esm/types/theme/generate-theme.d.ts +0 -30
  90. package/dist/esm/types/utils/crypto-utils.d.ts +0 -52
  91. package/dist/esm/types/utils/session-store.d.ts +0 -25
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <p align="center" style="color: #343a40">
2
2
  <h1 align="center">@asgardeo/react</h1>
3
3
  </p>
4
- <p align="center" style="font-size: 1.2rem;">React Wrapper to build customizable login UIs for Asgardeo or Identity Server</p>
4
+ <p align="center" style="font-size: 1.2rem;">React SDK for Asgardeo</p>
5
5
  <div align="center">
6
6
  <img alt="npm (scoped)" src="https://img.shields.io/npm/v/@asgardeo/react">
7
7
  <img alt="npm" src="https://img.shields.io/npm/dw/@asgardeo/react">
@@ -11,17 +11,119 @@
11
11
  ## Installation
12
12
 
13
13
  ```bash
14
- # With npm
14
+ # Using npm
15
15
  npm install @asgardeo/react
16
16
 
17
- # With pnpm
17
+ # or using pnpm
18
18
  pnpm add @asgardeo/react
19
19
 
20
- # With yarn
20
+ # or using yarn
21
21
  yarn add @asgardeo/react
22
22
  ```
23
23
 
24
+ ## Quick Start
25
+
26
+ 1. Add `<AsgardeoProvider />` to your app
27
+
28
+ ```tsx
29
+ import { StrictMode } from 'react'
30
+ import { createRoot } from 'react-dom/client'
31
+ import './index.css'
32
+ import App from './App.tsx'
33
+ import { AsgardeoProvider } from '@asgardeo/react'
34
+
35
+ createRoot(document.getElementById('root')).render(
36
+ <StrictMode>
37
+ <AsgardeoProvider
38
+ baseUrl: '<your-organization-name>'
39
+ clientId: '<your-app-client-id>'
40
+ >
41
+ <App />
42
+ </AsgardeoProvider>
43
+ </StrictMode>
44
+ )
45
+ ```
46
+
47
+ 2. Add signed-in and signed-out to your app
48
+
49
+ ```tsx
50
+ import { SignedIn, SignedOut, SignInButton, SignOutButton } from '@asgardeo/react'
51
+ import './App.css'
52
+
53
+ function App() {
54
+ return (
55
+ <>
56
+ <SignedIn>
57
+ <SignOutButton />
58
+ </SignedIn>
59
+ <SignedOut>
60
+ <SignInButton />
61
+ </SignedOut>
62
+ </>
63
+ )
64
+ }
65
+
66
+ export default App
67
+ ```
68
+
69
+ 3. Start using other drop-in components like `User`, `UserProfile`, etc.
70
+
71
+ ```tsx
72
+ import { User, UserProfile } from '@asgardeo/react'
73
+ import './App.css'
74
+
75
+ function App() {
76
+ return (
77
+ <>
78
+ <User>
79
+ {({ user }) => (
80
+ <div>
81
+ <h1>Welcome, {user.username}</h1>
82
+ <UserProfile />
83
+ </div>
84
+ )}
85
+ </User>
86
+
87
+ <UserProfile />
88
+ </>
89
+ )
90
+ }
91
+ export default App
92
+ ```
93
+
94
+ ## Using the `useAsgardeo` Hook (For Programmatic Control)
95
+
96
+ For more granular control, you can use the useAsgardeo hook. This hook provides direct access to SDK's functions and state:
97
+
98
+ ```tsx
99
+ import { useAsgardeo } from '@asgardeo/react'
100
+ import './App.css'
101
+
102
+ function App() {
103
+ const { user, signIn, signOut, isSignedIn, isLoading } = useAsgardeo()
104
+
105
+ if (isLoading) {
106
+ return <div>Loading...</div>
107
+ }
108
+
109
+ return (
110
+ <div>
111
+ {isSignedIn ? (
112
+ <div>
113
+ <div>
114
+ <img src={user.photourl} alt={user.username} />
115
+ <p>Welcome back, {user.givenname}</p>
116
+ </div>
117
+ <button onClick={() => signOut()}>Sign Out</button>
118
+ </div>
119
+ ) : (
120
+ <button onClick={() => signIn()}>Sign In</button>
121
+ )}
122
+ </div>
123
+ )
124
+ }
125
+ ```
126
+
24
127
  ## License
25
128
 
26
- Licenses this source under the Apache License, Version 2.0 [LICENSE](./LICENSE), You may not use this file except in
27
- compliance with the License.
129
+ Apache-2.0
@@ -0,0 +1,37 @@
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 { AsgardeoBrowserClient, SignInOptions, SignOutOptions, User } from '@asgardeo/browser';
19
+ import { AsgardeoReactConfig } from './models/config';
20
+ /**
21
+ * Client for mplementing Asgardeo in React applications.
22
+ * This class provides the core functionality for managing user authentication and sessions.
23
+ *
24
+ * @typeParam T - Configuration type that extends AsgardeoReactConfig.
25
+ */
26
+ declare class AsgardeoReactClient<T extends AsgardeoReactConfig = AsgardeoReactConfig> extends AsgardeoBrowserClient<T> {
27
+ private asgardeo;
28
+ constructor();
29
+ initialize(config: T): Promise<boolean>;
30
+ getUser(): Promise<any>;
31
+ isLoading(): boolean;
32
+ isSignedIn(): Promise<boolean>;
33
+ signIn(options?: SignInOptions): Promise<User>;
34
+ signOut(options?: SignOutOptions, afterSignOut?: (redirectUrl: string) => void): Promise<string>;
35
+ signOut(options?: SignOutOptions, sessionId?: string, afterSignOut?: (redirectUrl: string) => void): Promise<string>;
36
+ }
37
+ export default AsgardeoReactClient;
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Copyright (c) 2025, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. 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 { AsgardeoSPAClient, AuthClientConfig, BasicUserInfo, LegacyConfig as Config, IdTokenPayload, FetchResponse, Hooks, HttpClientInstance, HttpRequestConfig, HttpResponse, OIDCEndpoints, SignInConfig, SPACustomGrantConfig } from '@asgardeo/browser';
19
+ import { AuthStateInterface } from './models';
20
+ declare class AuthAPI {
21
+ static DEFAULT_STATE: AuthStateInterface;
22
+ private _authState;
23
+ private _client;
24
+ private _isLoading;
25
+ constructor(spaClient?: AsgardeoSPAClient);
26
+ _setIsLoading(isLoading: boolean): void;
27
+ _getIsLoading(): boolean;
28
+ isSignedIn(): Promise<boolean>;
29
+ isLoading(): boolean;
30
+ /**
31
+ * Method to return Auth Client instance authentication state.
32
+ *
33
+ * @return {AuthStateInterface} Authentication State.
34
+ */
35
+ getState(): AuthStateInterface;
36
+ /**
37
+ * Method to initialize the AuthClient instance.
38
+ *
39
+ * @param {Config} config - `dispatch` function from React Auth Context.
40
+ */
41
+ init(config: AuthClientConfig<Config>): Promise<boolean>;
42
+ /**
43
+ * Method to get the configuration data.
44
+ *
45
+ * @returns {Promise<AuthClientConfig<Config>>} - A promise that resolves with the configuration data.
46
+ */
47
+ getConfigData(): Promise<AuthClientConfig<Config>>;
48
+ /**
49
+ * Method to handle user Sign In requests.
50
+ *
51
+ * @param {any} dispatch - `dispatch` function from React Auth Context.
52
+ * @param {AuthStateInterface} state - Current authentication state in React Auth Context.
53
+ * @param {any} callback - Action to trigger on successful sign in.
54
+ */
55
+ signIn(config: SignInConfig, authorizationCode?: string, sessionState?: string, authState?: string, callback?: (response: BasicUserInfo) => void, tokenRequestConfig?: {
56
+ params: Record<string, unknown>;
57
+ }): Promise<BasicUserInfo>;
58
+ /**
59
+ * Method to handle user Sign Out requests.
60
+ *
61
+ * @param {any} dispatch - `dispatch` function from React Auth Context.
62
+ * @param {AuthStateInterface} state - Current authentication state in React Auth Context.
63
+ * @param {any} callback - Action to trigger on successful sign out.
64
+ */
65
+ signOut(callback?: (response?: boolean) => void): Promise<boolean>;
66
+ /**
67
+ * Method to update Auth Client instance authentication state.
68
+ *
69
+ * @param {AuthStateInterface} state - State values to update in authentication state.
70
+ */
71
+ updateState(state: AuthStateInterface): void;
72
+ /**
73
+ * This method returns a Promise that resolves with the basic user information obtained from the ID token.
74
+ *
75
+ * @return {Promise<BasicUserInfo>} - A promise that resolves with the user information.
76
+ */
77
+ getBasicUserInfo(): Promise<BasicUserInfo>;
78
+ /**
79
+ * This method sends an API request to a protected endpoint.
80
+ * The access token is automatically attached to the header of the request.
81
+ * This is the only way by which protected endpoints can be accessed
82
+ * when the web worker is used to store session information.
83
+ *
84
+ * @param {HttpRequestConfig} config - The config object containing attributes necessary to send a request.
85
+ *
86
+ * @return {Promise<FetchResponse>} - Returns a Promise that resolves with the response to the request.
87
+ */
88
+ httpRequest(config: HttpRequestConfig): Promise<HttpResponse<any>>;
89
+ /**
90
+ * This method sends multiple API requests to a protected endpoint.
91
+ * The access token is automatically attached to the header of the request.
92
+ * This is the only way by which multiple requests can be sent to protected endpoints
93
+ * when the web worker is used to store session information.
94
+ *
95
+ * @param {HttpRequestConfig[]} config - The config object containing attributes necessary to send a request.
96
+ *
97
+ * @return {Promise<FetchResponse[]>} - Returns a Promise that resolves with the responses to the requests.
98
+ */
99
+ httpRequestAll(configs: HttpRequestConfig[]): Promise<HttpResponse<any>[]>;
100
+ /**
101
+ * This method allows you to send a request with a custom grant.
102
+ *
103
+ * @param {CustomGrantRequestParams} config - The request parameters.
104
+ *
105
+ * @return {Promise<FetchResponse<any> | SignInResponse>} - A Promise that resolves with
106
+ * the value returned by the custom grant request.
107
+ */
108
+ requestCustomGrant(config: SPACustomGrantConfig, callback: (response: BasicUserInfo | FetchResponse<any>) => void, dispatch: (state: AuthStateInterface) => void): Promise<BasicUserInfo | FetchResponse<any>>;
109
+ /**
110
+ * This method ends a user session. The access token is revoked and the session information is destroyed.
111
+ *
112
+ * @return {Promise<boolean>} - A promise that resolves with `true` if the process is successful.
113
+ */
114
+ revokeAccessToken(dispatch: (state: AuthStateInterface) => void): Promise<boolean>;
115
+ /**
116
+ * This method returns a Promise that resolves with an object containing the service endpoints.
117
+ *
118
+ * @return {Promise<ServiceResourcesType} - A Promise that resolves with an object containing the service endpoints.
119
+ */
120
+ getOIDCServiceEndpoints(): Promise<OIDCEndpoints>;
121
+ /**
122
+ * This methods returns the Axios http client.
123
+ *
124
+ * @return {HttpClientInstance} - The Axios HTTP client.
125
+ */
126
+ getHttpClient(): Promise<HttpClientInstance>;
127
+ /**
128
+ * This method decodes the payload of the id token and returns it.
129
+ *
130
+ * @return {Promise<DecodedIDTokenPayloadInterface>} - A Promise that resolves with
131
+ * the decoded payload of the id token.
132
+ */
133
+ getDecodedIDToken(): Promise<IdTokenPayload>;
134
+ /**
135
+ * This method decodes the payload of the idp id token and returns it.
136
+ *
137
+ * @return {Promise<DecodedIDTokenPayloadInterface>} - A Promise that resolves with
138
+ * the decoded payload of the idp id token.
139
+ */
140
+ getDecodedIDPIDToken(): Promise<IdTokenPayload>;
141
+ /**
142
+ * This method returns the ID token.
143
+ *
144
+ * @return {Promise<string>} - A Promise that resolves with the id token.
145
+ */
146
+ getIDToken(): Promise<string>;
147
+ /**
148
+ * This method return a Promise that resolves with the access token.
149
+ *
150
+ * **This method will not return the access token if the storage type is set to `webWorker`.**
151
+ *
152
+ * @return {Promise<string>} - A Promise that resolves with the access token.
153
+ */
154
+ getAccessToken(): Promise<string>;
155
+ /**
156
+ * This method return a Promise that resolves with the idp access token.
157
+ *
158
+ * **This method will not return the idp access token if the storage type is set to `webWorker`.**
159
+ * **This can be used to access the IDP access token when custom auth grant functionalities are used**
160
+ *
161
+ * @return {Promise<string>} - A Promise that resolves with the idp access token.
162
+ */
163
+ getIDPAccessToken(): Promise<string>;
164
+ /**
165
+ * This method refreshes the access token.
166
+ *
167
+ * @return {TokenResponseInterface} - A Promise that resolves with an object containing
168
+ * information about the refreshed access token.
169
+ */
170
+ refreshAccessToken(): Promise<BasicUserInfo>;
171
+ /**
172
+ * This method specifies if the user is authenticated or not.
173
+ *
174
+ * @return {Promise<boolean>} - A Promise that resolves with `true` if teh user is authenticated.
175
+ */
176
+ isAuthenticated(): Promise<boolean>;
177
+ /**
178
+ * This method specifies if the session is active or not.
179
+ *
180
+ * @return {Promise<boolean>} - A Promise that resolves with `true` if there is an active session.
181
+ */
182
+ isSessionActive(): Promise<boolean>;
183
+ /**
184
+ * This method enables callback functions attached to the http client.
185
+ *
186
+ * @return {Promise<boolean>} - A promise that resolves with True.
187
+ *
188
+ */
189
+ enableHttpHandler(): Promise<boolean>;
190
+ /**
191
+ * This method disables callback functions attached to the http client.
192
+ *
193
+ * @return {Promise<boolean>} - A promise that resolves with True.
194
+ */
195
+ disableHttpHandler(): Promise<boolean>;
196
+ /**
197
+ * This method updates the configuration that was passed into the constructor when instantiating this class.
198
+ *
199
+ * @param {Partial<AuthClientConfig<T>>} config - A config object to update the SDK configurations with.
200
+ */
201
+ updateConfig(config: Partial<AuthClientConfig<Config>>): Promise<void>;
202
+ /**
203
+ * This method attaches a callback function to an event hook that fires the callback when the event happens.
204
+ *
205
+ * @param {Hooks.CustomGrant} hook - The name of the hook.
206
+ * @param {(response?: any) => void} callback - The callback function.
207
+ * @param {string} id (optional) - The id of the hook. This is used when multiple custom grants are used.
208
+ *
209
+ */
210
+ on(hook: Hooks.CustomGrant, callback: (response?: any) => void, id: string): Promise<void>;
211
+ on(hook: Exclude<Hooks, Hooks.CustomGrant>, callback: (response?: any) => void): Promise<void>;
212
+ /**
213
+ * This method allows you to sign in silently.
214
+ * First, this method sends a prompt none request to see if there is an active user session in the identity server.
215
+ * If there is one, then it requests the access token and stores it. Else, it returns false.
216
+ *
217
+ * @return {Promise<BasicUserInfo | boolean>} - A Promise that resolves with the user information after signing in
218
+ * or with `false` if the user is not signed in.
219
+ *
220
+ * @example
221
+ *```
222
+ * client.trySignInSilently()
223
+ *```
224
+ */
225
+ trySignInSilently(state: AuthStateInterface, dispatch: (state: AuthStateInterface) => void, additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: {
226
+ params: Record<string, unknown>;
227
+ }): Promise<BasicUserInfo | boolean | undefined>;
228
+ }
229
+ export default AuthAPI;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3
+ *
4
+ * WSO2 Inc. 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 { AsgardeoAuthException, AuthClientConfig, AuthSPAClientConfig, BasicUserInfo, Config, CustomGrantConfig, IdTokenPayload, FetchResponse, Hooks, HttpClientInstance, HttpRequestConfig, HttpResponse, OIDCEndpoints, SignInConfig } from '@asgardeo/browser';
19
+ export interface ReactConfig {
20
+ /**
21
+ * The SDK's `AuthProvider` by default is listening to the URL changes to see
22
+ * if `code` & `session_state` search params are available so that it could perform
23
+ * token exchange. This option could be used to override that behaviour.
24
+ */
25
+ skipRedirectCallback?: boolean;
26
+ /**
27
+ * The `AuthProvider`, by default, looks for an active session in the server and updates the session information
28
+ * with the latest session information from the server. This option could be used to disable that behaviour.
29
+ */
30
+ disableTrySignInSilently?: boolean;
31
+ disableAutoSignIn?: boolean;
32
+ }
33
+ export type AuthReactConfig = AuthSPAClientConfig & ReactConfig;
34
+ /**
35
+ * Interface for the Authenticated state of the user which is exposed
36
+ * via `state` object from `useAuthContext` hook.
37
+ */
38
+ export interface AuthStateInterface {
39
+ /**
40
+ * The scopes that are allowed for the user.
41
+ */
42
+ allowedScopes: string;
43
+ /**
44
+ * The display name of the user.
45
+ */
46
+ displayName?: string;
47
+ /**
48
+ * The email address of the user.
49
+ */
50
+ email?: string;
51
+ /**
52
+ * Specifies if the user is authenticated or not.
53
+ */
54
+ isAuthenticated: boolean;
55
+ /**
56
+ * Are the Auth requests loading.
57
+ */
58
+ isLoading: boolean;
59
+ /**
60
+ * The uid corresponding to the user who the ID token belonged to.
61
+ */
62
+ sub?: string;
63
+ /**
64
+ * The username of the user.
65
+ */
66
+ username?: string;
67
+ }
68
+ export interface AuthContextInterface {
69
+ signIn: (config?: SignInConfig, authorizationCode?: string, sessionState?: string, state?: string, callback?: (response: BasicUserInfo) => void, tokenRequestConfig?: {
70
+ params: Record<string, unknown>;
71
+ }) => Promise<BasicUserInfo>;
72
+ signOut: (callback?: (response: boolean) => void) => Promise<boolean>;
73
+ getBasicUserInfo(): Promise<BasicUserInfo>;
74
+ httpRequest(config: HttpRequestConfig): Promise<HttpResponse<any>>;
75
+ httpRequestAll(configs: HttpRequestConfig[]): Promise<HttpResponse<any>[]>;
76
+ requestCustomGrant(config: CustomGrantConfig, callback?: (response: BasicUserInfo | FetchResponse<any>) => void): void;
77
+ revokeAccessToken(): Promise<boolean>;
78
+ getOIDCServiceEndpoints(): Promise<OIDCEndpoints>;
79
+ getHttpClient(): Promise<HttpClientInstance>;
80
+ getDecodedIDPIDToken(): Promise<IdTokenPayload>;
81
+ getDecodedIDToken(): Promise<IdTokenPayload>;
82
+ getIDToken(): Promise<string>;
83
+ getAccessToken(): Promise<string>;
84
+ refreshAccessToken(): Promise<BasicUserInfo>;
85
+ isAuthenticated(): Promise<boolean>;
86
+ enableHttpHandler(): Promise<boolean>;
87
+ disableHttpHandler(): Promise<boolean>;
88
+ updateConfig(config: Partial<AuthClientConfig<Config>>): Promise<void>;
89
+ trySignInSilently: (additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: {
90
+ params: Record<string, unknown>;
91
+ }) => Promise<boolean | BasicUserInfo>;
92
+ on(hook: Hooks.CustomGrant, callback: (response?: any) => void, id: string): void;
93
+ on(hook: Exclude<Hooks, Hooks.CustomGrant>, callback: (response?: any) => void): void;
94
+ on(hook: Hooks, callback: (response?: any) => void, id?: string): void;
95
+ state: AuthStateInterface;
96
+ error: AsgardeoAuthException;
97
+ }
98
+ /**
99
+ * The model of the object returned by the `getAuthParams` prop method of the `AuthProvider`.
100
+ */
101
+ export interface AuthParams {
102
+ authorizationCode?: string;
103
+ sessionState?: string;
104
+ state?: string;
105
+ }
@@ -0,0 +1,39 @@
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 { User } from '@asgardeo/browser';
19
+ /**
20
+ * Retrieves the user profile information from the specified selfcare profile endpoint.
21
+ *
22
+ * @param requestConfig - Request configuration object.
23
+ * @returns A promise that resolves with the user profile information.
24
+ * @example
25
+ * ```typescript
26
+ * try {
27
+ * const userProfile = await getUserProfile({
28
+ * url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Me",
29
+ * });
30
+ * console.log(userProfile);
31
+ * } catch (error) {
32
+ * if (error instanceof AsgardeoAPIError) {
33
+ * console.error('Failed to get user profile:', error.message);
34
+ * }
35
+ * }
36
+ * ```
37
+ */
38
+ declare const getMeProfile: ({ url, ...requestConfig }: Partial<Request>) => Promise<User>;
39
+ export default getMeProfile;
@@ -0,0 +1,39 @@
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 { Schema } from '@asgardeo/browser';
19
+ /**
20
+ * Retrieves the SCIM2 schemas from the specified endpoint.
21
+ *
22
+ * @param requestConfig - Request configuration object.
23
+ * @returns A promise that resolves with the SCIM2 schemas information.
24
+ * @example
25
+ * ```typescript
26
+ * try {
27
+ * const schemas = await getSchemas({
28
+ * url: "https://api.asgardeo.io/t/<ORGANIZATION>/scim2/Schemas",
29
+ * });
30
+ * console.log(schemas);
31
+ * } catch (error) {
32
+ * if (error instanceof AsgardeoAPIError) {
33
+ * console.error('Failed to get schemas:', error.message);
34
+ * }
35
+ * }
36
+ * ```
37
+ */
38
+ declare const getSchemas: ({ url }: Partial<Request>) => Promise<Schema[]>;
39
+ export default getSchemas;
@@ -0,0 +1,38 @@
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 { User } from '@asgardeo/browser';
19
+ /**
20
+ * Updates the user profile information at the specified SCIM2 Me endpoint.
21
+ *
22
+ * @param url - The SCIM2 Me endpoint URL.
23
+ * @param value - The value object to patch (SCIM2 PATCH value).
24
+ * @param requestConfig - Additional request config if needed.
25
+ * @returns A promise that resolves with the updated user profile information.
26
+ * @example
27
+ * ```typescript
28
+ * await updateMeProfile({
29
+ * url: "https://api.asgardeo.io/t/<ORG>/scim2/Me",
30
+ * value: { "urn:scim:wso2:schema": { mobileNumbers: ["0777933830"] } }
31
+ * });
32
+ * ```
33
+ */
34
+ declare const updateMeProfile: ({ url, payload, ...requestConfig }: {
35
+ url: string;
36
+ payload: any;
37
+ } & Partial<Request>) => Promise<User>;
38
+ export default updateMeProfile;