@axinom/mosaic-user-auth 0.5.3-rc.8 → 0.5.3

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.
@@ -46,15 +46,12 @@ export declare class UserServiceClient implements IUserServiceClient {
46
46
  private get tokenResponse();
47
47
  private set tokenResponse(value);
48
48
  private emitTokenChanged;
49
+ private getAxAuthIdpConfig;
50
+ private getSignInWithCredentialsEndpoints;
49
51
  /**
50
52
  * Returns a new token by invoking the User API
51
53
  */
52
54
  private fetchToken;
53
- /**
54
- * Call the well-known endpoint of ax-user-service and retrieves endpoints related to AxAuth.
55
- * @returns SignInWithCredentialsEndpointResponse
56
- */
57
- private getSignInWithCredentialsEndpoints;
58
55
  private _recursiveRefreshActive;
59
56
  /**
60
57
  * Renews the token pre-emptively by recursively refreshing the cached token just before it's expiry
@@ -1 +1 @@
1
- {"version":3,"file":"UserServiceClient.d.ts","sourceRoot":"","sources":["../../src/UserServiceClient/UserServiceClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,6BAA6B,EAC7B,0BAA0B,EAC1B,6BAA6B,EAC7B,0BAA0B,EAE1B,2BAA2B,EAC3B,gBAAgB,EAChB,6BAA6B,EAE7B,cAAc,EAEd,kBAAkB,EAEnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,iCAAiC,EACjC,0BAA0B,EAC1B,iCAAiC,EACjC,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,mCAAmC,EAAE,MAAM,iDAAiD,CAAC;AAEtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EACL,sCAAsC,EACtC,aAAa,EAEb,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,2BAA2B,EAC3B,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,i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MAAM,KAChB,QAAQ,mBAAmB,CAAC,CAW7B;IAEF;;OAEG;IACH,eAAe,uBACO,MAAM,KACzB,QAAQ,oBAAoB,CAAC,CAU9B;IAEF;;OAEG;IACH,iBAAiB,uBACK,MAAM,eACb,MAAM,qBACA,MAAM,KACxB,QAAQ,yBAAyB,CAAC,CAYnC;IAEF;;;OAGG;IACH,iBAAiB,uBACK,MAAM,uBACL,sBAAsB,KAC1C,QAAQ,yBAAyB,CAAC,CAWnC;IAEF;;OAEG;IACH,iBAAiB,uBACK,MAAM,iBACX,MAAM,KACpB,QAAQ,yBAAyB,CAAC,CAWnC;IAEF;;;;OAIG;IACH,8BAA8B,0CACW,mCAAmC,KACzE,QAAQ,sCAAsC,CAAC,CAKhD;IAEF;;;;;OAKG;IACH,mBAAmB,oBACA,MAAM,OAClB,MAAM,KACV,QAAQ,2BAA2B,CAAC,CAMrC;IAEF;;;;;;OAMG;IACH,UAAU,oBAAqB,MAAM,aAAa,MAAM,KAAG,GAAG,CAE5D;IAEF;;;;;;;OAOG;IACH,gBAAgB,oBACG,MAAM,aACZ,MAAM,iBACF,MAAM,KACpB,GAAG,CAQJ;CACH"}
1
+ {"version":3,"file":"UserServiceClient.d.ts","sourceRoot":"","sources":["../../src/UserServiceClient/UserServiceClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,6BAA6B,EAC7B,0BAA0B,EAC1B,6BAA6B,EAC7B,0BAA0B,EAE1B,2BAA2B,EAC3B,gBAAgB,EAChB,6BAA6B,EAE7B,cAAc,EAEd,kBAAkB,EAEnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,iCAAiC,EACjC,0BAA0B,EAC1B,iCAAiC,EACjC,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,mCAAmC,EAAE,MAAM,iDAAiD,CAAC;AAEtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EACL,sCAAsC,EAC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AAC,CAM1D;IAEF;;OAEG;IACH,UAAU,QAAa,QAAQ,OAAO,CAAC,CAOrC;IAEF;;OAEG;IACH,gBAAgB,uBACM,MAAM,aACf,MAAM,KAChB,QAAQ,2BAA2B,CAAC,CAiBrC;IAEF;;OAEG;IACH,cAAc,uBACQ,MAAM,aACf,MAAM,KAChB,QAAQ,mBAAmB,CAAC,CAW7B;IAEF;;OAEG;IACH,eAAe,uBACO,MAAM,KACzB,QAAQ,oBAAoB,CAAC,CAU9B;IAEF;;OAEG;IACH,iBAAiB,uBACK,MAAM,eACb,MAAM,qBACA,MAAM,KACxB,QAAQ,yBAAyB,CAAC,CAYnC;IAEF;;;OAGG;IACH,iBAAiB,uBACK,MAAM,uBACL,sBAAsB,KAC1C,QAAQ,yBAAyB,CAAC,CAWnC;IAEF;;OAEG;IACH,iBAAiB,uBACK,MAAM,iBACX,MAAM,KACpB,QAAQ,yBAAyB,CAAC,CAWnC;IAEF;;;;OAIG;IACH,8BAA8B,0CACW,mCAAmC,KACzE,QAAQ,sCAAsC,CAAC,CAKhD;IAEF;;;;;OAKG;IACH,mBAAmB,oBACA,MAAM,OAClB,MAAM,KACV,QAAQ,2BAA2B,CAAC,CAMrC;IAEF;;;;;;OAMG;IACH,UAAU,oBAAqB,MAAM,aAAa,MAAM,KAAG,GAAG,CAE5D;IAEF;;;;;;;OAOG;IACH,gBAAgB,oBACG,MAAM,aACZ,MAAM,iBACF,MAAM,KACpB,GAAG,CAQJ;CACH"}
package/dist/index.es.js CHANGED
@@ -2504,10 +2504,37 @@ class UserServiceClient {
2504
2504
  this.tokenRenewalMethod = tokenRenewalMethod;
2505
2505
  this._tokenChangedHandlers = [];
2506
2506
  this._tokenResponse = null;
2507
- this._signInWithCredentialsEndpointResponse = null;
2507
+ this._signInWithCredentialsEndpointResponse = undefined;
2508
+ this._axAuthIdpConfig = undefined;
2508
2509
  this.emitTokenChanged = (token) => {
2509
2510
  this._tokenChangedHandlers.forEach((handler) => handler(token));
2510
2511
  };
2512
+ this.getAxAuthIdpConfig = () => __awaiter(this, void 0, void 0, function* () {
2513
+ // If _axAuthIdpConfig is not fetched previously, retrieve it.
2514
+ if (this._axAuthIdpConfig === undefined) {
2515
+ const idpConfigurations = yield getIdpConfigurations(this.userAuthConfig);
2516
+ const axAuthConfig = idpConfigurations.find((idpConfig) => idpConfig.providerId === 'AX_AUTH');
2517
+ if (axAuthConfig !== undefined) {
2518
+ this._axAuthIdpConfig = axAuthConfig;
2519
+ }
2520
+ else {
2521
+ this._axAuthIdpConfig = null;
2522
+ }
2523
+ }
2524
+ return this._axAuthIdpConfig;
2525
+ });
2526
+ this.getSignInWithCredentialsEndpoints = () => __awaiter(this, void 0, void 0, function* () {
2527
+ // If _signInWithCredentialsEndpointResponse is not fetched previously, retrieve it by calling the well-known endpoint of ax-user-service.
2528
+ if (this._signInWithCredentialsEndpointResponse === undefined) {
2529
+ const endpoints = yield getWellKnownEndpoints(this.userAuthConfig);
2530
+ this._signInWithCredentialsEndpointResponse = {
2531
+ code: 'SUCCESS',
2532
+ managementEndpoint: endpoints.axAuthManagementGQL,
2533
+ authEndpoint: endpoints.axAuthEndpoint,
2534
+ };
2535
+ }
2536
+ return this._signInWithCredentialsEndpointResponse;
2537
+ });
2511
2538
  /**
2512
2539
  * Returns a new token by invoking the User API
2513
2540
  */
@@ -2533,30 +2560,6 @@ class UserServiceClient {
2533
2560
  };
2534
2561
  }
2535
2562
  });
2536
- /**
2537
- * Call the well-known endpoint of ax-user-service and retrieves endpoints related to AxAuth.
2538
- * @returns SignInWithCredentialsEndpointResponse
2539
- */
2540
- this.getSignInWithCredentialsEndpoints = () => __awaiter(this, void 0, void 0, function* () {
2541
- try {
2542
- if (this._signInWithCredentialsEndpointResponse === null) {
2543
- const endpoints = yield getWellKnownEndpoints(this.userAuthConfig);
2544
- this._signInWithCredentialsEndpointResponse = {
2545
- code: 'SUCCESS',
2546
- managementEndpoint: endpoints.axAuthManagementGQL,
2547
- authEndpoint: endpoints.axAuthEndpoint,
2548
- };
2549
- }
2550
- return this._signInWithCredentialsEndpointResponse;
2551
- }
2552
- catch (error) {
2553
- assertError(error);
2554
- return {
2555
- code: 'ERROR',
2556
- message: error.message,
2557
- };
2558
- }
2559
- });
2560
2563
  // This is set to true when the token is being pre-emptively refreshed in `recursivelyRefreshToken` method.
2561
2564
  // It avoids `setTimeout` from being called multiple times.
2562
2565
  this._recursiveRefreshActive = false;
@@ -2585,9 +2588,8 @@ class UserServiceClient {
2585
2588
  * @returns a boolean indicating if the Mosaic application has an AxAuth IDP provider configured and it is enabled.
2586
2589
  */
2587
2590
  this.isDirectSignInConfigured = () => __awaiter(this, void 0, void 0, function* () {
2588
- const idpConfigurations = yield getIdpConfigurations(this.userAuthConfig);
2589
- this._axAuthIdpConfig = idpConfigurations.find((idpConfig) => idpConfig.providerId === 'AX_AUTH');
2590
- return this._axAuthIdpConfig !== undefined;
2591
+ const axAuthIdpConfig = yield this.getAxAuthIdpConfig();
2592
+ return axAuthIdpConfig !== null;
2591
2593
  });
2592
2594
  /**
2593
2595
  * Starts a SignInWithCredentials flow using the AX_AUTH IDP configured for the application.
@@ -2596,15 +2598,15 @@ class UserServiceClient {
2596
2598
  * @returns `SignInResponse`
2597
2599
  */
2598
2600
  this.signInWithCredentials = (signInRequest) => __awaiter(this, void 0, void 0, function* () {
2599
- var _b, _c;
2600
- if (((_b = this._axAuthIdpConfig) === null || _b === void 0 ? void 0 : _b.idpConnectionId) !== undefined) {
2601
- const result = yield performSignInWithCredentials(this.userAuthConfig, (_c = this._axAuthIdpConfig) === null || _c === void 0 ? void 0 : _c.idpConnectionId, signInRequest);
2601
+ const axAuthIdpConfig = yield this.getAxAuthIdpConfig();
2602
+ if (axAuthIdpConfig !== null) {
2603
+ const result = yield performSignInWithCredentials(this.userAuthConfig, axAuthIdpConfig.idpConnectionId, signInRequest);
2602
2604
  return result;
2603
2605
  }
2604
2606
  else {
2605
2607
  return {
2606
2608
  code: dist.SignInResponseCode.SERVICE_CONFIGURATION_ERROR,
2607
- message: 'No IDP has configured for sign in with credentials.',
2609
+ message: 'No IDP has been configured for sign in with credentials.',
2608
2610
  };
2609
2611
  }
2610
2612
  });
@@ -2615,17 +2617,13 @@ class UserServiceClient {
2615
2617
  * @returns `UserSignUpResponse`
2616
2618
  */
2617
2619
  this.initiateUserSignUp = (userSignUpRequest) => __awaiter(this, void 0, void 0, function* () {
2618
- var _d;
2619
- // If _axAuthIdpConfig is not fetched previously, retrieve it.
2620
- if (this._axAuthIdpConfig === undefined) {
2621
- yield this.getIdpConfigurations();
2622
- }
2623
- if (this._axAuthIdpConfig !== undefined &&
2624
- this._axAuthIdpConfig.clientId !== null &&
2625
- ((_d = this._signInWithCredentialsEndpointResponse) === null || _d === void 0 ? void 0 : _d.managementEndpoint) !==
2626
- undefined) {
2627
- const signUpRequest = Object.assign(Object.assign({}, userSignUpRequest), { oAuthClientId: this._axAuthIdpConfig.clientId });
2628
- const result = yield initiateUserSignUp(signUpRequest, this._signInWithCredentialsEndpointResponse.managementEndpoint);
2620
+ const axAuthIdpConfig = yield this.getAxAuthIdpConfig();
2621
+ const signInWithCredentialsEndpoints = yield this.getSignInWithCredentialsEndpoints();
2622
+ if (axAuthIdpConfig !== null &&
2623
+ axAuthIdpConfig.clientId !== null &&
2624
+ signInWithCredentialsEndpoints.managementEndpoint !== undefined) {
2625
+ const signUpRequest = Object.assign(Object.assign({}, userSignUpRequest), { oAuthClientId: axAuthIdpConfig.clientId });
2626
+ const result = yield initiateUserSignUp(signUpRequest, signInWithCredentialsEndpoints.managementEndpoint);
2629
2627
  return result;
2630
2628
  }
2631
2629
  else {
@@ -2642,16 +2640,12 @@ class UserServiceClient {
2642
2640
  * @returns `CheckUserSignUpOtpResponse`
2643
2641
  */
2644
2642
  this.checkUserSignUpOTP = (checkUserSignUpOtpRequest) => __awaiter(this, void 0, void 0, function* () {
2645
- var _e;
2646
- // If _axAuthIdpConfig is not fetched previously, retrieve it.
2647
- if (this._axAuthIdpConfig === undefined) {
2648
- yield this.getIdpConfigurations();
2649
- }
2650
- if (this._axAuthIdpConfig !== undefined &&
2651
- this._axAuthIdpConfig.clientId !== null &&
2652
- ((_e = this._signInWithCredentialsEndpointResponse) === null || _e === void 0 ? void 0 : _e.managementEndpoint) !==
2653
- undefined) {
2654
- const result = yield checkUserSignUpOtp(checkUserSignUpOtpRequest, this._signInWithCredentialsEndpointResponse.managementEndpoint);
2643
+ const axAuthIdpConfig = yield this.getAxAuthIdpConfig();
2644
+ const signInWithCredentialsEndpoints = yield this.getSignInWithCredentialsEndpoints();
2645
+ if (axAuthIdpConfig !== null &&
2646
+ axAuthIdpConfig.clientId !== null &&
2647
+ signInWithCredentialsEndpoints.managementEndpoint !== undefined) {
2648
+ const result = yield checkUserSignUpOtp(checkUserSignUpOtpRequest, signInWithCredentialsEndpoints.managementEndpoint);
2655
2649
  return result;
2656
2650
  }
2657
2651
  else {
@@ -2670,10 +2664,9 @@ class UserServiceClient {
2670
2664
  * @returns
2671
2665
  */
2672
2666
  this.completeUserSignUp = (completeUserSignUpRequest) => __awaiter(this, void 0, void 0, function* () {
2673
- var _f;
2674
- if (((_f = this._signInWithCredentialsEndpointResponse) === null || _f === void 0 ? void 0 : _f.managementEndpoint) !==
2675
- undefined) {
2676
- const result = yield completeUserSignUp(completeUserSignUpRequest, this._signInWithCredentialsEndpointResponse.managementEndpoint);
2667
+ const signInWithCredentialsEndpoints = yield this.getSignInWithCredentialsEndpoints();
2668
+ if (signInWithCredentialsEndpoints.managementEndpoint !== undefined) {
2669
+ const result = yield completeUserSignUp(completeUserSignUpRequest, signInWithCredentialsEndpoints.managementEndpoint);
2677
2670
  return result;
2678
2671
  }
2679
2672
  else {
@@ -2692,16 +2685,12 @@ class UserServiceClient {
2692
2685
  * @returns `InitiatePasswordResetResponse`
2693
2686
  */
2694
2687
  this.initiateResetPassword = (email) => __awaiter(this, void 0, void 0, function* () {
2695
- var _g;
2696
- // If _axAuthIdpConfig is not fetched previously, retrieve it.
2697
- if (this._axAuthIdpConfig === undefined) {
2698
- yield this.getIdpConfigurations();
2699
- }
2700
- if (this._axAuthIdpConfig !== undefined &&
2701
- this._axAuthIdpConfig.clientId !== null &&
2702
- ((_g = this._signInWithCredentialsEndpointResponse) === null || _g === void 0 ? void 0 : _g.managementEndpoint) !==
2703
- undefined) {
2704
- const result = yield initiatePasswordReset(email, this._axAuthIdpConfig.clientId, this._signInWithCredentialsEndpointResponse.managementEndpoint);
2688
+ const axAuthIdpConfig = yield this.getAxAuthIdpConfig();
2689
+ const signInWithCredentialsEndpoints = yield this.getSignInWithCredentialsEndpoints();
2690
+ if (axAuthIdpConfig !== null &&
2691
+ axAuthIdpConfig.clientId !== null &&
2692
+ signInWithCredentialsEndpoints.managementEndpoint !== undefined) {
2693
+ const result = yield initiatePasswordReset(email, axAuthIdpConfig.clientId, signInWithCredentialsEndpoints.managementEndpoint);
2705
2694
  return result;
2706
2695
  }
2707
2696
  else {
@@ -2718,16 +2707,12 @@ class UserServiceClient {
2718
2707
  * @returns `CheckPasswordResetOtpResponse`
2719
2708
  */
2720
2709
  this.checkResetPasswordOTP = (checkPasswordResetOtpRequest) => __awaiter(this, void 0, void 0, function* () {
2721
- var _h;
2722
- // If _axAuthIdpConfig is not fetched previously, retrieve it.
2723
- if (this._axAuthIdpConfig === undefined) {
2724
- yield this.getIdpConfigurations();
2725
- }
2726
- if (this._axAuthIdpConfig !== undefined &&
2727
- this._axAuthIdpConfig.clientId !== null &&
2728
- ((_h = this._signInWithCredentialsEndpointResponse) === null || _h === void 0 ? void 0 : _h.managementEndpoint) !==
2729
- undefined) {
2730
- const result = yield checkPasswordResetOtp(checkPasswordResetOtpRequest, this._signInWithCredentialsEndpointResponse.managementEndpoint);
2710
+ const axAuthIdpConfig = yield this.getAxAuthIdpConfig();
2711
+ const signInWithCredentialsEndpoints = yield this.getSignInWithCredentialsEndpoints();
2712
+ if (axAuthIdpConfig !== null &&
2713
+ axAuthIdpConfig.clientId !== null &&
2714
+ signInWithCredentialsEndpoints.managementEndpoint !== undefined) {
2715
+ const result = yield checkPasswordResetOtp(checkPasswordResetOtpRequest, signInWithCredentialsEndpoints.managementEndpoint);
2731
2716
  return result;
2732
2717
  }
2733
2718
  else {
@@ -2745,10 +2730,9 @@ class UserServiceClient {
2745
2730
  * @returns
2746
2731
  */
2747
2732
  this.completeResetPassword = (completePasswordResetRequest) => __awaiter(this, void 0, void 0, function* () {
2748
- var _j;
2749
- if (((_j = this._signInWithCredentialsEndpointResponse) === null || _j === void 0 ? void 0 : _j.managementEndpoint) !==
2750
- undefined) {
2751
- const result = yield completePasswordReset(completePasswordResetRequest, this._signInWithCredentialsEndpointResponse.managementEndpoint);
2733
+ const signInWithCredentialsEndpoints = yield this.getSignInWithCredentialsEndpoints();
2734
+ if (signInWithCredentialsEndpoints.managementEndpoint !== undefined) {
2735
+ const result = yield completePasswordReset(completePasswordResetRequest, signInWithCredentialsEndpoints.managementEndpoint);
2752
2736
  return result;
2753
2737
  }
2754
2738
  else {
@@ -2765,10 +2749,10 @@ class UserServiceClient {
2765
2749
  * When in need of a token, please call this method to get a new token.
2766
2750
  */
2767
2751
  this.getToken = () => __awaiter(this, void 0, void 0, function* () {
2768
- var _k;
2752
+ var _b;
2769
2753
  // Set token response to null if the token has expired.
2770
2754
  if (this.tokenResponse !== null &&
2771
- (((_k = this.tokenResponse.userToken) === null || _k === void 0 ? void 0 : _k.expiresAt) === undefined ||
2755
+ (((_b = this.tokenResponse.userToken) === null || _b === void 0 ? void 0 : _b.expiresAt) === undefined ||
2772
2756
  this.tokenResponse.userToken.expiresAt <= new Date(Date.now()))) {
2773
2757
  this.tokenResponse = null;
2774
2758
  }
@@ -2805,13 +2789,7 @@ class UserServiceClient {
2805
2789
  */
2806
2790
  this.getIdpConfigurations = () => __awaiter(this, void 0, void 0, function* () {
2807
2791
  // Extract the IDP Configuration for AX_AUTH and remove it from the ID Providers list.
2808
- const idpConfigurations = (yield getIdpConfigurations(this.userAuthConfig)).filter((idpConfig) => {
2809
- if (idpConfig.providerId === 'AX_AUTH') {
2810
- this._axAuthIdpConfig = idpConfig;
2811
- return;
2812
- }
2813
- return idpConfig;
2814
- });
2792
+ const idpConfigurations = (yield getIdpConfigurations(this.userAuthConfig)).filter((idpConfig) => idpConfig.providerId !== 'AX_AUTH');
2815
2793
  return idpConfigurations;
2816
2794
  });
2817
2795
  /**
@@ -2939,8 +2917,6 @@ class UserServiceClient {
2939
2917
  const authUrl = getNativeAuthUrl(this.userAuthConfig, idpConnectionId, returnUrl, encryptionKey);
2940
2918
  return authUrl;
2941
2919
  };
2942
- // asynchronously get the SignInWithCredentials endpoints at client initialization
2943
- this.getSignInWithCredentialsEndpoints();
2944
2920
  }
2945
2921
  get tokenResponse() {
2946
2922
  return this._tokenResponse;