@asgardeo/react 0.16.2 → 0.18.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/dist/AsgardeoReactClient.d.ts +2 -1
- package/dist/cjs/index.js +41 -21
- package/dist/cjs/index.js.map +2 -2
- package/dist/contexts/Asgardeo/AsgardeoContext.d.ts +12 -1
- package/dist/index.js +41 -21
- package/dist/index.js.map +2 -2
- package/package.json +2 -2
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { AsgardeoBrowserClient, UserProfile, SignInOptions, SignOutOptions, User, EmbeddedFlowExecuteResponse, SignUpOptions, EmbeddedFlowExecuteRequestPayload, EmbeddedSignInFlowHandleRequestPayload, Organization, IdToken, EmbeddedFlowExecuteRequestConfig, AllOrganizationsApiResponse, TokenResponse, HttpRequestConfig, HttpResponse, TokenExchangeRequestConfig } from '@asgardeo/browser';
|
|
18
|
+
import { AsgardeoBrowserClient, UserProfile, SignInOptions, SignOutOptions, User, EmbeddedFlowExecuteResponse, SignUpOptions, EmbeddedFlowExecuteRequestPayload, EmbeddedSignInFlowHandleRequestPayload, Organization, IdToken, EmbeddedFlowExecuteRequestConfig, AllOrganizationsApiResponse, TokenResponse, HttpRequestConfig, HttpResponse, TokenExchangeRequestConfig, OIDCDiscoveryApiResponse } from '@asgardeo/browser';
|
|
19
19
|
import { AsgardeoReactConfig } from './models/config';
|
|
20
20
|
/**
|
|
21
21
|
* Client for mplementing Asgardeo in React applications.
|
|
@@ -72,6 +72,7 @@ declare class AsgardeoReactClient<T extends AsgardeoReactConfig = AsgardeoReactC
|
|
|
72
72
|
signOut(options?: SignOutOptions, sessionId?: string, afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
|
|
73
73
|
signUp(options?: SignUpOptions): Promise<void>;
|
|
74
74
|
signUp(payload: EmbeddedFlowExecuteRequestPayload): Promise<EmbeddedFlowExecuteResponse>;
|
|
75
|
+
getDiscoveryResponse(): Promise<OIDCDiscoveryApiResponse | null>;
|
|
75
76
|
request(requestConfig?: HttpRequestConfig): Promise<HttpResponse<any>>;
|
|
76
77
|
requestAll(requestConfigs?: HttpRequestConfig[]): Promise<HttpResponse<any>[]>;
|
|
77
78
|
getAccessToken(sessionId?: string): Promise<string>;
|
package/dist/cjs/index.js
CHANGED
|
@@ -185,6 +185,9 @@ var AsgardeoContext = (0, import_react.createContext)({
|
|
|
185
185
|
clearSession: () => {
|
|
186
186
|
},
|
|
187
187
|
clientId: void 0,
|
|
188
|
+
discovery: {
|
|
189
|
+
wellKnown: null
|
|
190
|
+
},
|
|
188
191
|
exchangeToken: null,
|
|
189
192
|
getAccessToken: null,
|
|
190
193
|
getDecodedIdToken: null,
|
|
@@ -743,9 +746,10 @@ var AsgardeoReactClient = class extends import_browser6.AsgardeoBrowserClient {
|
|
|
743
746
|
if (!resolvedOrganizationHandle) {
|
|
744
747
|
resolvedOrganizationHandle = (0, import_browser6.deriveOrganizationHandleFromBaseUrl)(config?.baseUrl);
|
|
745
748
|
}
|
|
746
|
-
return this.withLoading(
|
|
747
|
-
|
|
748
|
-
|
|
749
|
+
return this.withLoading(async () => {
|
|
750
|
+
this.initializeConfig = { ...config, organizationHandle: resolvedOrganizationHandle };
|
|
751
|
+
return this.asgardeo.init(this.initializeConfig);
|
|
752
|
+
});
|
|
749
753
|
}
|
|
750
754
|
reInitialize(config) {
|
|
751
755
|
return this.withLoading(async () => {
|
|
@@ -1017,6 +1021,10 @@ var AsgardeoReactClient = class extends import_browser6.AsgardeoBrowserClient {
|
|
|
1017
1021
|
(0, import_browser6.navigate)((0, import_browser6.getRedirectBasedSignUpUrl)(config));
|
|
1018
1022
|
return void 0;
|
|
1019
1023
|
}
|
|
1024
|
+
async getDiscoveryResponse() {
|
|
1025
|
+
const storageManager = await this.asgardeo.getStorageManager();
|
|
1026
|
+
return storageManager.loadOpenIDProviderConfiguration();
|
|
1027
|
+
}
|
|
1020
1028
|
async request(requestConfig) {
|
|
1021
1029
|
return this.asgardeo.httpRequest(requestConfig);
|
|
1022
1030
|
}
|
|
@@ -2150,6 +2158,7 @@ var AsgardeoProvider = ({
|
|
|
2150
2158
|
...rest
|
|
2151
2159
|
});
|
|
2152
2160
|
const [isUpdatingSession, setIsUpdatingSession] = (0, import_react20.useState)(false);
|
|
2161
|
+
const [wellKnown, setWellKnown] = (0, import_react20.useState)(null);
|
|
2153
2162
|
const [brandingPreference, setBrandingPreference] = (0, import_react20.useState)(null);
|
|
2154
2163
|
const [isBrandingLoading, setIsBrandingLoading] = (0, import_react20.useState)(false);
|
|
2155
2164
|
const [brandingError, setBrandingError] = (0, import_react20.useState)(null);
|
|
@@ -2167,6 +2176,7 @@ var AsgardeoProvider = ({
|
|
|
2167
2176
|
await asgardeo.initialize(config);
|
|
2168
2177
|
const initializedConfig = await asgardeo.getConfiguration();
|
|
2169
2178
|
setConfig(initializedConfig);
|
|
2179
|
+
setWellKnown(await asgardeo.getDiscoveryResponse());
|
|
2170
2180
|
})();
|
|
2171
2181
|
}, []);
|
|
2172
2182
|
async function updateSession() {
|
|
@@ -2188,25 +2198,31 @@ var AsgardeoProvider = ({
|
|
|
2188
2198
|
schemas: []
|
|
2189
2199
|
});
|
|
2190
2200
|
} else {
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
setCurrentOrganization(fetchedOrganization);
|
|
2204
|
-
} catch (error) {
|
|
2201
|
+
const shouldFetchUserProfile = preferences?.user?.fetchUserProfile !== false;
|
|
2202
|
+
if (shouldFetchUserProfile) {
|
|
2203
|
+
try {
|
|
2204
|
+
const fetchedUser = await asgardeo.getUser({ baseUrl: resolvedBaseUrl });
|
|
2205
|
+
setUser(fetchedUser);
|
|
2206
|
+
} catch (error) {
|
|
2207
|
+
}
|
|
2208
|
+
try {
|
|
2209
|
+
const fetchedUserProfile = await asgardeo.getUserProfile({ baseUrl: resolvedBaseUrl });
|
|
2210
|
+
setUserProfile(fetchedUserProfile);
|
|
2211
|
+
} catch (error) {
|
|
2212
|
+
}
|
|
2205
2213
|
}
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2214
|
+
const shouldFetchOrganizations = preferences?.user?.fetchOrganizations !== false;
|
|
2215
|
+
if (shouldFetchOrganizations) {
|
|
2216
|
+
try {
|
|
2217
|
+
const fetchedOrganization = await asgardeo.getCurrentOrganization();
|
|
2218
|
+
setCurrentOrganization(fetchedOrganization);
|
|
2219
|
+
} catch (error) {
|
|
2220
|
+
}
|
|
2221
|
+
try {
|
|
2222
|
+
const fetchedMyOrganizations = await asgardeo.getMyOrganizations();
|
|
2223
|
+
setMyOrganizations(fetchedMyOrganizations);
|
|
2224
|
+
} catch (error) {
|
|
2225
|
+
}
|
|
2210
2226
|
}
|
|
2211
2227
|
}
|
|
2212
2228
|
const currentSignInStatus = await asgardeo.isSignedIn();
|
|
@@ -2485,6 +2501,9 @@ var AsgardeoProvider = ({
|
|
|
2485
2501
|
baseUrl,
|
|
2486
2502
|
clearSession,
|
|
2487
2503
|
clientId,
|
|
2504
|
+
discovery: {
|
|
2505
|
+
wellKnown
|
|
2506
|
+
},
|
|
2488
2507
|
exchangeToken,
|
|
2489
2508
|
getAccessToken,
|
|
2490
2509
|
getDecodedIdToken,
|
|
@@ -2521,6 +2540,7 @@ var AsgardeoProvider = ({
|
|
|
2521
2540
|
afterSignInUrl,
|
|
2522
2541
|
baseUrl,
|
|
2523
2542
|
clientId,
|
|
2543
|
+
wellKnown,
|
|
2524
2544
|
isInitializedSync,
|
|
2525
2545
|
isLoadingSync,
|
|
2526
2546
|
isSignedInSync,
|