@axinom/mosaic-user-auth 0.3.7 → 0.3.8-rc.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/UserServiceClient/UserServiceClient.d.ts +1 -11
- package/dist/UserServiceClient/UserServiceClient.d.ts.map +1 -1
- package/dist/UserServiceProvider/UserServiceProvider.d.ts +2 -6
- package/dist/UserServiceProvider/UserServiceProvider.d.ts.map +1 -1
- package/dist/index.es.js +5 -24
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +4 -23
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2212,10 +2212,9 @@ class UserServiceClient {
|
|
|
2212
2212
|
* @param userServiceConfig Configuration values for the user service API
|
|
2213
2213
|
* @param tokenRenewalMethod Token renewal method to use
|
|
2214
2214
|
*/
|
|
2215
|
-
constructor(userAuthConfig, userServiceConfig,
|
|
2215
|
+
constructor(userAuthConfig, userServiceConfig, tokenRenewalMethod = exports.TokenRenewalMethod.ON_DEMAND) {
|
|
2216
2216
|
this.userAuthConfig = userAuthConfig;
|
|
2217
2217
|
this.userServiceConfig = userServiceConfig;
|
|
2218
|
-
this.setIsSignedIn = setIsSignedIn;
|
|
2219
2218
|
this.tokenRenewalMethod = tokenRenewalMethod;
|
|
2220
2219
|
this._tokenChangedHandlers = [];
|
|
2221
2220
|
this._tokenResponse = null;
|
|
@@ -2230,7 +2229,6 @@ class UserServiceClient {
|
|
|
2230
2229
|
try {
|
|
2231
2230
|
const userToken = yield fetchUserToken(this.userAuthConfig);
|
|
2232
2231
|
const userProfile = yield getUserProfile(this.userServiceConfig.userServiceBaseUrl, userToken.accessToken, userToken.profileId);
|
|
2233
|
-
this.setIsSignedIn(true);
|
|
2234
2232
|
return {
|
|
2235
2233
|
code: 'SUCCESS',
|
|
2236
2234
|
userToken,
|
|
@@ -2242,7 +2240,6 @@ class UserServiceClient {
|
|
|
2242
2240
|
};
|
|
2243
2241
|
}
|
|
2244
2242
|
catch (error) {
|
|
2245
|
-
this.setIsSignedIn(false);
|
|
2246
2243
|
assertError(error);
|
|
2247
2244
|
return {
|
|
2248
2245
|
code: 'ERROR',
|
|
@@ -2482,7 +2479,6 @@ class UserServiceClient {
|
|
|
2482
2479
|
(((_k = this.tokenResponse.userToken) === null || _k === void 0 ? void 0 : _k.expiresAt) === undefined ||
|
|
2483
2480
|
this.tokenResponse.userToken.expiresAt <= new Date(Date.now()))) {
|
|
2484
2481
|
this.tokenResponse = null;
|
|
2485
|
-
this.setIsSignedIn(false);
|
|
2486
2482
|
}
|
|
2487
2483
|
if (this.tokenResponse !== null && this.tokenResponse.code === 'SUCCESS') {
|
|
2488
2484
|
// We already have a valid token
|
|
@@ -2533,12 +2529,7 @@ class UserServiceClient {
|
|
|
2533
2529
|
this.tokenResponse = null;
|
|
2534
2530
|
// We want the user to be considered logged out, so we emit the TokenChanged here using 'null'
|
|
2535
2531
|
this.emitTokenChanged(null);
|
|
2536
|
-
|
|
2537
|
-
if (logoutStatus) {
|
|
2538
|
-
// Set the sign in status as false.
|
|
2539
|
-
this.setSignedInStatus(false);
|
|
2540
|
-
}
|
|
2541
|
-
return logoutStatus;
|
|
2532
|
+
return logoutUser(this.userAuthConfig);
|
|
2542
2533
|
});
|
|
2543
2534
|
/**
|
|
2544
2535
|
* Sets a given Profile ID as the active profile
|
|
@@ -2626,15 +2617,6 @@ class UserServiceClient {
|
|
|
2626
2617
|
const authUrl = getNativeAuthUrl(this.userAuthConfig, idpConnectionId, returnUrl, encryptionKey);
|
|
2627
2618
|
return authUrl;
|
|
2628
2619
|
};
|
|
2629
|
-
/**
|
|
2630
|
-
* Sets the sign in status explicitly, allowing to re-render any
|
|
2631
|
-
* React components with the UserServiceProvider.
|
|
2632
|
-
*
|
|
2633
|
-
* @param signInStatus
|
|
2634
|
-
*/
|
|
2635
|
-
this.setSignedInStatus = (signInStatus) => {
|
|
2636
|
-
this.setIsSignedIn(signInStatus);
|
|
2637
|
-
};
|
|
2638
2620
|
// asynchronously get the ROPC endpoints at client initialization
|
|
2639
2621
|
this.getROPCEndpoints();
|
|
2640
2622
|
}
|
|
@@ -2656,9 +2638,8 @@ const UserServiceContext = React.createContext(null);
|
|
|
2656
2638
|
* Provides the User Service Client that can be retrieved using the `useUserService` hook
|
|
2657
2639
|
*/
|
|
2658
2640
|
const UserServiceProvider = ({ children, userAuthConfig, userServiceConfig, tokenRenewalMethod = exports.TokenRenewalMethod.ON_DEMAND, }) => {
|
|
2659
|
-
const
|
|
2660
|
-
|
|
2661
|
-
return (React.createElement(UserServiceContext.Provider, { value: Object.assign({ isSignedIn }, client) }, children));
|
|
2641
|
+
const client = new UserServiceClient(userAuthConfig, userServiceConfig, tokenRenewalMethod);
|
|
2642
|
+
return (React.createElement(UserServiceContext.Provider, { value: client }, children));
|
|
2662
2643
|
};
|
|
2663
2644
|
/**
|
|
2664
2645
|
* Retrieves the User Service Client
|