gd-sprest 9.4.0 → 9.4.2

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.
@@ -745,8 +745,12 @@ var _ContextInfo = /** @class */ (function () {
745
745
  url: url
746
746
  });
747
747
  };
748
- _ContextInfo.enableRefreshToken = function () {
748
+ _ContextInfo.enableRefreshToken = function (callback) {
749
749
  var _this = this;
750
+ // Set the refresh event
751
+ if (callback) {
752
+ this._onRefresh.push(callback);
753
+ }
750
754
  // See if the request digest exists
751
755
  if (this.formDigestValue == null) {
752
756
  return;
@@ -770,6 +774,8 @@ var _ContextInfo = /** @class */ (function () {
770
774
  // Update the context info
771
775
  _this._contextInfo.formDigestTimeoutSeconds = context.GetContextWebInformation.FormDigestTimeoutSeconds;
772
776
  _this._contextInfo.formDigestValue = context.GetContextWebInformation.FormDigestValue;
777
+ // Call the events
778
+ _this._onRefresh.forEach(function (callback) { callback(); });
773
779
  }, function () {
774
780
  // Log
775
781
  console.info("[gd-sprest] Unable to get the context information to refresh the token.");
@@ -844,6 +850,7 @@ var _ContextInfo = /** @class */ (function () {
844
850
  _a.enableRefreshToken();
845
851
  };
846
852
  _ContextInfo._loopId = null;
853
+ _ContextInfo._onRefresh = [];
847
854
  // Value in minutes to refresh the token
848
855
  // Default is 5 minutes prior to it expiring
849
856
  _ContextInfo._refreshToken = 5;
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.40,
12
+ __ver: 9.42,
13
13
  AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); },
14
14
  Apps: Lib.Apps,
15
15
  ContextInfo: Lib.ContextInfo,
@@ -510,7 +510,7 @@ exports.Request = {
510
510
  if (isBatchRequest === void 0) { isBatchRequest = false; }
511
511
  if (batchIdx === void 0) { batchIdx = 0; }
512
512
  // Ensure the request was successful
513
- if (base.status >= 200 && base.status < 300) {
513
+ if ((base.status >= 200 && base.status < 300) || (isBatchRequest && base.status == 422)) {
514
514
  // Return if we are expecting a buffer
515
515
  if (base.requestType == requestType_1.RequestType.GetBuffer) {
516
516
  return;