gd-sprest 9.0.7 → 9.0.8

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.
@@ -483,6 +483,11 @@ export interface IContextInformation {
483
483
  */
484
484
  getWeb(url: string): IBaseExecution<{ GetContextWebInformation: ContextWebInformation }>;
485
485
 
486
+ /**
487
+ * Value in minutes, to refresh the token prior to it expiring
488
+ */
489
+ refreshToken: number;
490
+
486
491
  /**
487
492
  * Sets the page context information for modern pages.
488
493
  * @param spfxPageContext - The page context information variable from a SPFx project.
@@ -778,6 +778,12 @@ var _ContextInfo = /** @class */ (function () {
778
778
  });
779
779
  }, 500);
780
780
  };
781
+ Object.defineProperty(_ContextInfo, "refreshToken", {
782
+ get: function () { return this._refreshToken; },
783
+ set: function (value) { this._refreshToken = value; },
784
+ enumerable: false,
785
+ configurable: true
786
+ });
781
787
  // Method to validate the token
782
788
  _ContextInfo.validateToken = function (digestValue) {
783
789
  if (digestValue === void 0) { digestValue = this._contextInfo.formDigestValue; }
@@ -789,8 +795,8 @@ var _ContextInfo = /** @class */ (function () {
789
795
  var dtToken = new Date(digestValue.split(',')[1]);
790
796
  var timeout = this.formDigestTimeoutSeconds || 0;
791
797
  // Return true if it's still valid
792
- // Time the token was granted + Timeout in seconds - 1 min (60000)
793
- return Date.now() < dtToken.getTime() + timeout * 1000 - 60000;
798
+ // Time the token was granted + Timeout in seconds - (1 min (60000) * refresh token value)
799
+ return Date.now() < dtToken.getTime() + timeout * 1000 - (60000 * this.refreshToken);
794
800
  };
795
801
  var _a;
796
802
  _a = _ContextInfo;
@@ -804,6 +810,9 @@ var _ContextInfo = /** @class */ (function () {
804
810
  _a.enableRefreshToken();
805
811
  };
806
812
  _ContextInfo._loopId = null;
813
+ // Value in minutes to refresh the token
814
+ // Default is 5 minutes prior to it expiring
815
+ _ContextInfo._refreshToken = 5;
807
816
  return _ContextInfo;
808
817
  }());
809
818
  exports.ContextInfo = _ContextInfo;
package/build/rest.js CHANGED
@@ -9,7 +9,7 @@ var sptypes_1 = require("./sptypes");
9
9
  * SharePoint REST Library
10
10
  */
11
11
  exports.$REST = {
12
- __ver: 9.07,
12
+ __ver: 9.08,
13
13
  AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); },
14
14
  Apps: Lib.Apps,
15
15
  ContextInfo: Lib.ContextInfo,
@@ -978,6 +978,11 @@ declare module 'gd-sprest/lib/contextInfo' {
978
978
  */
979
979
  getWeb(url: string): IBaseExecution<{ GetContextWebInformation: ContextWebInformation }>;
980
980
 
981
+ /**
982
+ * Value in minutes, to refresh the token prior to it expiring
983
+ */
984
+ refreshToken: number;
985
+
981
986
  /**
982
987
  * Sets the page context information for modern pages.
983
988
  * @param spfxPageContext - The page context information variable from a SPFx project.