@bytescale/sdk 3.60.0 → 3.62.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/README.md +91 -0
- package/dist/browser/cjs/main.js +508 -161
- package/dist/browser/esm/main.mjs +508 -161
- package/dist/node/cjs/main.js +351 -97
- package/dist/node/esm/main.mjs +351 -97
- package/dist/types/private/AuthSessionState.d.ts +2 -0
- package/dist/types/private/Scheduler.d.ts +12 -3
- package/dist/types/private/dtos/AuthSwConfigEntryDto.d.ts +3 -1
- package/dist/types/private/model/AuthSession.d.ts +4 -0
- package/dist/types/private/model/AuthSessionConfigBase.d.ts +8 -0
- package/dist/types/public/browser/AuthManagerBrowser.d.ts +3 -0
- package/dist/types/public/shared/generated/runtime.d.ts +6 -0
- package/dist/worker/cjs/main.js +351 -97
- package/dist/worker/esm/main.mjs +351 -97
- package/package.json +1 -1
- package/tests/ApiClientAuth.test.ts +115 -2
- package/tests/AuthManagerBrowser.test.ts +145 -2
- package/tests/AuthServiceWorkerRequestScope.test.ts +259 -0
- package/tests/AuthServiceWorkerRewrite.test.ts +17 -152
- package/tests/Scheduler.test.ts +135 -0
- package/tests/UploadManagerAuth.test.ts +30 -0
- package/tests/fixtures/auth-sw-3.61.0.js +272 -0
- package/tests/utils/AuthServiceWorkerHarness.ts +183 -0
package/dist/node/esm/main.mjs
CHANGED
|
@@ -155,6 +155,177 @@ var FairMutex = /*#__PURE__*/function () {
|
|
|
155
155
|
}]);
|
|
156
156
|
}();
|
|
157
157
|
;// ./src/private/AuthSessionState.ts
|
|
158
|
+
function AuthSessionState_empty() {}
|
|
159
|
+
function AuthSessionState_awaitIgnored(value, direct) {
|
|
160
|
+
if (!direct) {
|
|
161
|
+
return value && value.then ? value.then(AuthSessionState_empty) : Promise.resolve();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function AuthSessionState_invoke(body, then) {
|
|
165
|
+
var result = body();
|
|
166
|
+
if (result && result.then) {
|
|
167
|
+
return result.then(then);
|
|
168
|
+
}
|
|
169
|
+
return then(result);
|
|
170
|
+
}
|
|
171
|
+
function _settle(pact, state, value) {
|
|
172
|
+
if (!pact.s) {
|
|
173
|
+
if (value instanceof _Pact) {
|
|
174
|
+
if (value.s) {
|
|
175
|
+
if (state & 1) {
|
|
176
|
+
state = value.s;
|
|
177
|
+
}
|
|
178
|
+
value = value.v;
|
|
179
|
+
} else {
|
|
180
|
+
value.o = _settle.bind(null, pact, state);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (value && value.then) {
|
|
185
|
+
value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
pact.s = state;
|
|
189
|
+
pact.v = value;
|
|
190
|
+
var observer = pact.o;
|
|
191
|
+
if (observer) {
|
|
192
|
+
observer(pact);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
var _Pact = /*#__PURE__*/function () {
|
|
197
|
+
function _Pact() {}
|
|
198
|
+
_Pact.prototype.then = function (onFulfilled, onRejected) {
|
|
199
|
+
var result = new _Pact();
|
|
200
|
+
var state = this.s;
|
|
201
|
+
if (state) {
|
|
202
|
+
var callback = state & 1 ? onFulfilled : onRejected;
|
|
203
|
+
if (callback) {
|
|
204
|
+
try {
|
|
205
|
+
_settle(result, 1, callback(this.v));
|
|
206
|
+
} catch (e) {
|
|
207
|
+
_settle(result, 2, e);
|
|
208
|
+
}
|
|
209
|
+
return result;
|
|
210
|
+
} else {
|
|
211
|
+
return this;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
this.o = function (_this) {
|
|
215
|
+
try {
|
|
216
|
+
var value = _this.v;
|
|
217
|
+
if (_this.s & 1) {
|
|
218
|
+
_settle(result, 1, onFulfilled ? onFulfilled(value) : value);
|
|
219
|
+
} else if (onRejected) {
|
|
220
|
+
_settle(result, 1, onRejected(value));
|
|
221
|
+
} else {
|
|
222
|
+
_settle(result, 2, value);
|
|
223
|
+
}
|
|
224
|
+
} catch (e) {
|
|
225
|
+
_settle(result, 2, e);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
return result;
|
|
229
|
+
};
|
|
230
|
+
return _Pact;
|
|
231
|
+
}();
|
|
232
|
+
function _isSettledPact(thenable) {
|
|
233
|
+
return thenable instanceof _Pact && thenable.s & 1;
|
|
234
|
+
}
|
|
235
|
+
function _for(test, update, body) {
|
|
236
|
+
var stage;
|
|
237
|
+
for (;;) {
|
|
238
|
+
var shouldContinue = test();
|
|
239
|
+
if (_isSettledPact(shouldContinue)) {
|
|
240
|
+
shouldContinue = shouldContinue.v;
|
|
241
|
+
}
|
|
242
|
+
if (!shouldContinue) {
|
|
243
|
+
return result;
|
|
244
|
+
}
|
|
245
|
+
if (shouldContinue.then) {
|
|
246
|
+
stage = 0;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
var result = body();
|
|
250
|
+
if (result && result.then) {
|
|
251
|
+
if (_isSettledPact(result)) {
|
|
252
|
+
result = result.s;
|
|
253
|
+
} else {
|
|
254
|
+
stage = 1;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (update) {
|
|
259
|
+
var updateValue = update();
|
|
260
|
+
if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
|
|
261
|
+
stage = 2;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
var pact = new _Pact();
|
|
267
|
+
var reject = _settle.bind(null, pact, 2);
|
|
268
|
+
(stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
|
|
269
|
+
return pact;
|
|
270
|
+
function _resumeAfterBody(value) {
|
|
271
|
+
result = value;
|
|
272
|
+
do {
|
|
273
|
+
if (update) {
|
|
274
|
+
updateValue = update();
|
|
275
|
+
if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
|
|
276
|
+
updateValue.then(_resumeAfterUpdate).then(void 0, reject);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
shouldContinue = test();
|
|
281
|
+
if (!shouldContinue || _isSettledPact(shouldContinue) && !shouldContinue.v) {
|
|
282
|
+
_settle(pact, 1, result);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (shouldContinue.then) {
|
|
286
|
+
shouldContinue.then(_resumeAfterTest).then(void 0, reject);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
result = body();
|
|
290
|
+
if (_isSettledPact(result)) {
|
|
291
|
+
result = result.v;
|
|
292
|
+
}
|
|
293
|
+
} while (!result || !result.then);
|
|
294
|
+
result.then(_resumeAfterBody).then(void 0, reject);
|
|
295
|
+
}
|
|
296
|
+
function _resumeAfterTest(shouldContinue) {
|
|
297
|
+
if (shouldContinue) {
|
|
298
|
+
result = body();
|
|
299
|
+
if (result && result.then) {
|
|
300
|
+
result.then(_resumeAfterBody).then(void 0, reject);
|
|
301
|
+
} else {
|
|
302
|
+
_resumeAfterBody(result);
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
_settle(pact, 1, result);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function _resumeAfterUpdate() {
|
|
309
|
+
if (shouldContinue = test()) {
|
|
310
|
+
if (shouldContinue.then) {
|
|
311
|
+
shouldContinue.then(_resumeAfterTest).then(void 0, reject);
|
|
312
|
+
} else {
|
|
313
|
+
_resumeAfterTest(shouldContinue);
|
|
314
|
+
}
|
|
315
|
+
} else {
|
|
316
|
+
_settle(pact, 1, result);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function AuthSessionState_await(value, then, direct) {
|
|
321
|
+
if (direct) {
|
|
322
|
+
return then ? then(value) : value;
|
|
323
|
+
}
|
|
324
|
+
if (!value || !value.then) {
|
|
325
|
+
value = Promise.resolve(value);
|
|
326
|
+
}
|
|
327
|
+
return then ? value.then(then) : value;
|
|
328
|
+
}
|
|
158
329
|
function AuthSessionState_typeof(o) { "@babel/helpers - typeof"; return AuthSessionState_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, AuthSessionState_typeof(o); }
|
|
159
330
|
function AuthSessionState_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
160
331
|
function AuthSessionState_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, AuthSessionState_toPropertyKey(o.key), o); } }
|
|
@@ -261,6 +432,54 @@ var AuthSessionState = /*#__PURE__*/function () {
|
|
|
261
432
|
jwt: undefined
|
|
262
433
|
};
|
|
263
434
|
}
|
|
435
|
+
/** Waits for request-time auth to be current before resolving it. */
|
|
436
|
+
}, {
|
|
437
|
+
key: "resolveAuthConfigAsync",
|
|
438
|
+
value: function resolveAuthConfigAsync(authConfigId, requireReadyDefault) {
|
|
439
|
+
try {
|
|
440
|
+
var _exit = false;
|
|
441
|
+
var _a, _b;
|
|
442
|
+
if (authConfigId === false) {
|
|
443
|
+
return AuthSessionState_await(undefined);
|
|
444
|
+
}
|
|
445
|
+
return AuthSessionState_await(_for(function () {
|
|
446
|
+
return !_exit;
|
|
447
|
+
}, void 0, function () {
|
|
448
|
+
var session = AuthSessionState.getSession();
|
|
449
|
+
if (session === undefined || !session.isActive || !Array.isArray(session.authConfigs)) {
|
|
450
|
+
var _AuthSessionState$res = AuthSessionState.resolveAuthConfig(authConfigId, requireReadyDefault);
|
|
451
|
+
_exit = true;
|
|
452
|
+
return _AuthSessionState$res;
|
|
453
|
+
}
|
|
454
|
+
var state = session.authConfigs.find(function (config) {
|
|
455
|
+
return config.config.authConfigId === authConfigId;
|
|
456
|
+
});
|
|
457
|
+
if (state === undefined) {
|
|
458
|
+
var _AuthSessionState$res2 = AuthSessionState.resolveAuthConfig(authConfigId, requireReadyDefault);
|
|
459
|
+
_exit = true;
|
|
460
|
+
return _AuthSessionState$res2;
|
|
461
|
+
}
|
|
462
|
+
var authenticationPromise = (_a = state.authenticationPromise) !== null && _a !== void 0 ? _a : state.refreshPromise;
|
|
463
|
+
return AuthSessionState_invoke(function () {
|
|
464
|
+
if (authenticationPromise !== undefined) {
|
|
465
|
+
return AuthSessionState_awaitIgnored(authenticationPromise);
|
|
466
|
+
}
|
|
467
|
+
}, function () {
|
|
468
|
+
if (AuthSessionState.getSession() !== session || !session.isActive) {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
var currentAuthenticationPromise = (_b = state.authenticationPromise) !== null && _b !== void 0 ? _b : state.refreshPromise;
|
|
472
|
+
if (currentAuthenticationPromise === undefined || currentAuthenticationPromise === authenticationPromise) {
|
|
473
|
+
var _AuthSessionState$res3 = AuthSessionState.resolveAuthConfig(authConfigId, true);
|
|
474
|
+
_exit = true;
|
|
475
|
+
return _AuthSessionState$res3;
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
}));
|
|
479
|
+
} catch (e) {
|
|
480
|
+
return Promise.reject(e);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
264
483
|
}]);
|
|
265
484
|
}();
|
|
266
485
|
AuthSessionState.stateKey = "BytescaleSessionState";
|
|
@@ -406,12 +625,43 @@ var BytescaleApiClientConfigUtils = /*#__PURE__*/function () {
|
|
|
406
625
|
value: function getAccountId(config) {
|
|
407
626
|
return BytescaleApiClientConfigUtils.resolveAuthentication(config).accountId;
|
|
408
627
|
}
|
|
628
|
+
}, {
|
|
629
|
+
key: "getAccountIdAsync",
|
|
630
|
+
value: function getAccountIdAsync(config) {
|
|
631
|
+
try {
|
|
632
|
+
return runtime_await(BytescaleApiClientConfigUtils.resolveAuthenticationAsync(config), function (_BytescaleApiClientCo) {
|
|
633
|
+
return _BytescaleApiClientCo.accountId;
|
|
634
|
+
});
|
|
635
|
+
} catch (e) {
|
|
636
|
+
return Promise.reject(e);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
409
639
|
}, {
|
|
410
640
|
key: "resolveAuthentication",
|
|
411
641
|
value: function resolveAuthentication(config) {
|
|
412
|
-
var _a
|
|
642
|
+
var _a;
|
|
413
643
|
var apiKey = (_a = config.apiKey) !== null && _a !== void 0 ? _a : undefined;
|
|
414
644
|
var authConfig = AuthSessionState.resolveAuthConfig(config.authConfigId, apiKey === undefined);
|
|
645
|
+
return BytescaleApiClientConfigUtils.resolveAuthenticationWithAuthConfig(config, authConfig);
|
|
646
|
+
}
|
|
647
|
+
}, {
|
|
648
|
+
key: "resolveAuthenticationAsync",
|
|
649
|
+
value: function resolveAuthenticationAsync(config) {
|
|
650
|
+
try {
|
|
651
|
+
var _a;
|
|
652
|
+
var apiKey = (_a = config.apiKey) !== null && _a !== void 0 ? _a : undefined;
|
|
653
|
+
return runtime_await(AuthSessionState.resolveAuthConfigAsync(config.authConfigId, apiKey === undefined), function (authConfig) {
|
|
654
|
+
return BytescaleApiClientConfigUtils.resolveAuthenticationWithAuthConfig(config, authConfig);
|
|
655
|
+
});
|
|
656
|
+
} catch (e) {
|
|
657
|
+
return Promise.reject(e);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}, {
|
|
661
|
+
key: "resolveAuthenticationWithAuthConfig",
|
|
662
|
+
value: function resolveAuthenticationWithAuthConfig(config, authConfig) {
|
|
663
|
+
var _a, _b;
|
|
664
|
+
var apiKey = (_a = config.apiKey) !== null && _a !== void 0 ? _a : undefined;
|
|
415
665
|
var apiKeyAccountId = apiKey === undefined ? undefined : BytescaleApiClientConfigUtils.getApiKeyAccountId(apiKey);
|
|
416
666
|
if (apiKeyAccountId !== undefined && authConfig !== undefined && apiKeyAccountId !== authConfig.accountId) {
|
|
417
667
|
throw new Error("The API key belongs to account '".concat(apiKeyAccountId, "', but AuthManager configuration '").concat((_b = config.authConfigId) !== null && _b !== void 0 ? _b : "default", "' belongs to account '").concat(authConfig.accountId, "'."));
|
|
@@ -498,7 +748,6 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
498
748
|
try {
|
|
499
749
|
var _this = this;
|
|
500
750
|
var _a;
|
|
501
|
-
Object.assign(context.headers, BytescaleApiClientConfigUtils.resolveAuthentication(_this.config).headers);
|
|
502
751
|
// Key: any possible value for 'baseUrlOverride'
|
|
503
752
|
// Value: user-overridden value for that base URL from the config.
|
|
504
753
|
var nonDefaultBasePaths = _defineProperty({}, BytescaleApiClientConfigUtils.defaultCdnUrl, BytescaleApiClientConfigUtils.getCdnUrl(_this.config));
|
|
@@ -539,44 +788,48 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
539
788
|
}
|
|
540
789
|
var configHeaders = _this2.config.headers;
|
|
541
790
|
return runtime_await(runtime_await(configHeaders === undefined ? {} : typeof configHeaders === "function" ? configHeaders() : configHeaders, function (resolvedConfigHeaders) {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
791
|
+
var _context$headers = context.headers;
|
|
792
|
+
return runtime_await(BytescaleApiClientConfigUtils.resolveAuthenticationAsync(_this2.config), function (_BytescaleApiClientCo2) {
|
|
793
|
+
Object.assign(_context$headers, _BytescaleApiClientCo2.headers);
|
|
794
|
+
for (var _i = 0, _Object$keys = Object.keys(resolvedConfigHeaders); _i < _Object$keys.length; _i++) {
|
|
795
|
+
var key = _Object$keys[_i];
|
|
796
|
+
if (key.toLowerCase() === "authorization" || key.toLowerCase() === "authorization-token") {
|
|
797
|
+
for (var _i2 = 0, _Object$keys2 = Object.keys(context.headers); _i2 < _Object$keys2.length; _i2++) {
|
|
798
|
+
var generatedKey = _Object$keys2[_i2];
|
|
799
|
+
if (generatedKey.toLowerCase() === key.toLowerCase()) {
|
|
800
|
+
// Custom auth headers have documented precedence; remove the generated spelling to make that deterministic.
|
|
801
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
802
|
+
delete context.headers[generatedKey];
|
|
803
|
+
}
|
|
551
804
|
}
|
|
552
805
|
}
|
|
553
806
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
return headers[key] === undefined ? delete headers[key] : {};
|
|
558
|
-
});
|
|
559
|
-
var initOverrideFn = typeof initOverrides === "function" ? initOverrides : function () {
|
|
560
|
-
return runtime_await(initOverrides);
|
|
561
|
-
};
|
|
562
|
-
var initParams = {
|
|
563
|
-
method: context.method,
|
|
564
|
-
headers: headers,
|
|
565
|
-
body: context.body
|
|
566
|
-
};
|
|
567
|
-
var _Object$assign = Object.assign({}, initParams);
|
|
568
|
-
return runtime_await(initOverrideFn({
|
|
569
|
-
init: initParams,
|
|
570
|
-
context: context
|
|
571
|
-
}), function (_initOverrideFn) {
|
|
572
|
-
var overriddenInit = Object.assign(_Object$assign, _initOverrideFn);
|
|
573
|
-
var init = Object.assign(Object.assign({}, overriddenInit), {
|
|
574
|
-
body: JSON.stringify(overriddenInit.body)
|
|
807
|
+
var headers = Object.assign(Object.assign({}, context.headers), resolvedConfigHeaders);
|
|
808
|
+
Object.keys(headers).forEach(function (key) {
|
|
809
|
+
return headers[key] === undefined ? delete headers[key] : {};
|
|
575
810
|
});
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
init: init
|
|
811
|
+
var initOverrideFn = typeof initOverrides === "function" ? initOverrides : function () {
|
|
812
|
+
return runtime_await(initOverrides);
|
|
579
813
|
};
|
|
814
|
+
var initParams = {
|
|
815
|
+
method: context.method,
|
|
816
|
+
headers: headers,
|
|
817
|
+
body: context.body
|
|
818
|
+
};
|
|
819
|
+
var _Object$assign = Object.assign({}, initParams);
|
|
820
|
+
return runtime_await(initOverrideFn({
|
|
821
|
+
init: initParams,
|
|
822
|
+
context: context
|
|
823
|
+
}), function (_initOverrideFn) {
|
|
824
|
+
var overriddenInit = Object.assign(_Object$assign, _initOverrideFn);
|
|
825
|
+
var init = Object.assign(Object.assign({}, overriddenInit), {
|
|
826
|
+
body: JSON.stringify(overriddenInit.body)
|
|
827
|
+
});
|
|
828
|
+
return {
|
|
829
|
+
url: url,
|
|
830
|
+
init: init
|
|
831
|
+
};
|
|
832
|
+
});
|
|
580
833
|
});
|
|
581
834
|
}, configHeaders === undefined || !(typeof configHeaders === "function")));
|
|
582
835
|
} catch (e) {
|
|
@@ -604,8 +857,8 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
604
857
|
// unless the following is set.
|
|
605
858
|
// https://github.com/nodejs/node/issues/46221#issuecomment-1383246036
|
|
606
859
|
duplex: "half"
|
|
607
|
-
})), function (
|
|
608
|
-
response =
|
|
860
|
+
})), function (_BytescaleApiClientCo3) {
|
|
861
|
+
response = _BytescaleApiClientCo3;
|
|
609
862
|
});
|
|
610
863
|
}, function (e) {
|
|
611
864
|
// Network-level errors, CORS errors, or HTTP-level errors from intermediary services (e.g. AWS or the user's own infrastructure/proxies).
|
|
@@ -2016,21 +2269,21 @@ function _invokeIgnored(body) {
|
|
|
2016
2269
|
return result.then(UploadManagerBase_empty);
|
|
2017
2270
|
}
|
|
2018
2271
|
}
|
|
2019
|
-
function
|
|
2272
|
+
function UploadManagerBase_settle(pact, state, value) {
|
|
2020
2273
|
if (!pact.s) {
|
|
2021
|
-
if (value instanceof
|
|
2274
|
+
if (value instanceof UploadManagerBase_Pact) {
|
|
2022
2275
|
if (value.s) {
|
|
2023
2276
|
if (state & 1) {
|
|
2024
2277
|
state = value.s;
|
|
2025
2278
|
}
|
|
2026
2279
|
value = value.v;
|
|
2027
2280
|
} else {
|
|
2028
|
-
value.o =
|
|
2281
|
+
value.o = UploadManagerBase_settle.bind(null, pact, state);
|
|
2029
2282
|
return;
|
|
2030
2283
|
}
|
|
2031
2284
|
}
|
|
2032
2285
|
if (value && value.then) {
|
|
2033
|
-
value.then(
|
|
2286
|
+
value.then(UploadManagerBase_settle.bind(null, pact, state), UploadManagerBase_settle.bind(null, pact, 2));
|
|
2034
2287
|
return;
|
|
2035
2288
|
}
|
|
2036
2289
|
pact.s = state;
|
|
@@ -2041,7 +2294,7 @@ function _settle(pact, state, value) {
|
|
|
2041
2294
|
}
|
|
2042
2295
|
}
|
|
2043
2296
|
}
|
|
2044
|
-
var
|
|
2297
|
+
var UploadManagerBase_Pact = /*#__PURE__*/function () {
|
|
2045
2298
|
function _Pact() {}
|
|
2046
2299
|
_Pact.prototype.then = function (onFulfilled, onRejected) {
|
|
2047
2300
|
var result = new _Pact();
|
|
@@ -2050,9 +2303,9 @@ var _Pact = /*#__PURE__*/function () {
|
|
|
2050
2303
|
var callback = state & 1 ? onFulfilled : onRejected;
|
|
2051
2304
|
if (callback) {
|
|
2052
2305
|
try {
|
|
2053
|
-
|
|
2306
|
+
UploadManagerBase_settle(result, 1, callback(this.v));
|
|
2054
2307
|
} catch (e) {
|
|
2055
|
-
|
|
2308
|
+
UploadManagerBase_settle(result, 2, e);
|
|
2056
2309
|
}
|
|
2057
2310
|
return result;
|
|
2058
2311
|
} else {
|
|
@@ -2063,28 +2316,28 @@ var _Pact = /*#__PURE__*/function () {
|
|
|
2063
2316
|
try {
|
|
2064
2317
|
var value = _this.v;
|
|
2065
2318
|
if (_this.s & 1) {
|
|
2066
|
-
|
|
2319
|
+
UploadManagerBase_settle(result, 1, onFulfilled ? onFulfilled(value) : value);
|
|
2067
2320
|
} else if (onRejected) {
|
|
2068
|
-
|
|
2321
|
+
UploadManagerBase_settle(result, 1, onRejected(value));
|
|
2069
2322
|
} else {
|
|
2070
|
-
|
|
2323
|
+
UploadManagerBase_settle(result, 2, value);
|
|
2071
2324
|
}
|
|
2072
2325
|
} catch (e) {
|
|
2073
|
-
|
|
2326
|
+
UploadManagerBase_settle(result, 2, e);
|
|
2074
2327
|
}
|
|
2075
2328
|
};
|
|
2076
2329
|
return result;
|
|
2077
2330
|
};
|
|
2078
2331
|
return _Pact;
|
|
2079
2332
|
}();
|
|
2080
|
-
function
|
|
2081
|
-
return thenable instanceof
|
|
2333
|
+
function UploadManagerBase_isSettledPact(thenable) {
|
|
2334
|
+
return thenable instanceof UploadManagerBase_Pact && thenable.s & 1;
|
|
2082
2335
|
}
|
|
2083
|
-
function
|
|
2336
|
+
function UploadManagerBase_for(test, update, body) {
|
|
2084
2337
|
var stage;
|
|
2085
2338
|
for (;;) {
|
|
2086
2339
|
var shouldContinue = test();
|
|
2087
|
-
if (
|
|
2340
|
+
if (UploadManagerBase_isSettledPact(shouldContinue)) {
|
|
2088
2341
|
shouldContinue = shouldContinue.v;
|
|
2089
2342
|
}
|
|
2090
2343
|
if (!shouldContinue) {
|
|
@@ -2096,7 +2349,7 @@ function _for(test, update, body) {
|
|
|
2096
2349
|
}
|
|
2097
2350
|
var result = body();
|
|
2098
2351
|
if (result && result.then) {
|
|
2099
|
-
if (
|
|
2352
|
+
if (UploadManagerBase_isSettledPact(result)) {
|
|
2100
2353
|
result = result.s;
|
|
2101
2354
|
} else {
|
|
2102
2355
|
stage = 1;
|
|
@@ -2105,14 +2358,14 @@ function _for(test, update, body) {
|
|
|
2105
2358
|
}
|
|
2106
2359
|
if (update) {
|
|
2107
2360
|
var updateValue = update();
|
|
2108
|
-
if (updateValue && updateValue.then && !
|
|
2361
|
+
if (updateValue && updateValue.then && !UploadManagerBase_isSettledPact(updateValue)) {
|
|
2109
2362
|
stage = 2;
|
|
2110
2363
|
break;
|
|
2111
2364
|
}
|
|
2112
2365
|
}
|
|
2113
2366
|
}
|
|
2114
|
-
var pact = new
|
|
2115
|
-
var reject =
|
|
2367
|
+
var pact = new UploadManagerBase_Pact();
|
|
2368
|
+
var reject = UploadManagerBase_settle.bind(null, pact, 2);
|
|
2116
2369
|
(stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
|
|
2117
2370
|
return pact;
|
|
2118
2371
|
function _resumeAfterBody(value) {
|
|
@@ -2120,14 +2373,14 @@ function _for(test, update, body) {
|
|
|
2120
2373
|
do {
|
|
2121
2374
|
if (update) {
|
|
2122
2375
|
updateValue = update();
|
|
2123
|
-
if (updateValue && updateValue.then && !
|
|
2376
|
+
if (updateValue && updateValue.then && !UploadManagerBase_isSettledPact(updateValue)) {
|
|
2124
2377
|
updateValue.then(_resumeAfterUpdate).then(void 0, reject);
|
|
2125
2378
|
return;
|
|
2126
2379
|
}
|
|
2127
2380
|
}
|
|
2128
2381
|
shouldContinue = test();
|
|
2129
|
-
if (!shouldContinue ||
|
|
2130
|
-
|
|
2382
|
+
if (!shouldContinue || UploadManagerBase_isSettledPact(shouldContinue) && !shouldContinue.v) {
|
|
2383
|
+
UploadManagerBase_settle(pact, 1, result);
|
|
2131
2384
|
return;
|
|
2132
2385
|
}
|
|
2133
2386
|
if (shouldContinue.then) {
|
|
@@ -2135,7 +2388,7 @@ function _for(test, update, body) {
|
|
|
2135
2388
|
return;
|
|
2136
2389
|
}
|
|
2137
2390
|
result = body();
|
|
2138
|
-
if (
|
|
2391
|
+
if (UploadManagerBase_isSettledPact(result)) {
|
|
2139
2392
|
result = result.v;
|
|
2140
2393
|
}
|
|
2141
2394
|
} while (!result || !result.then);
|
|
@@ -2150,7 +2403,7 @@ function _for(test, update, body) {
|
|
|
2150
2403
|
_resumeAfterBody(result);
|
|
2151
2404
|
}
|
|
2152
2405
|
} else {
|
|
2153
|
-
|
|
2406
|
+
UploadManagerBase_settle(pact, 1, result);
|
|
2154
2407
|
}
|
|
2155
2408
|
}
|
|
2156
2409
|
function _resumeAfterUpdate() {
|
|
@@ -2161,7 +2414,7 @@ function _for(test, update, body) {
|
|
|
2161
2414
|
_resumeAfterTest(shouldContinue);
|
|
2162
2415
|
}
|
|
2163
2416
|
} else {
|
|
2164
|
-
|
|
2417
|
+
UploadManagerBase_settle(pact, 1, result);
|
|
2165
2418
|
}
|
|
2166
2419
|
}
|
|
2167
2420
|
}
|
|
@@ -2201,40 +2454,41 @@ var UploadManagerBase = /*#__PURE__*/function () {
|
|
|
2201
2454
|
try {
|
|
2202
2455
|
var _this = this;
|
|
2203
2456
|
_this.assertNotCancelled(request);
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2457
|
+
return UploadManagerBase_await(BytescaleApiClientConfigUtils.getAccountIdAsync(_this.config), function (accountId) {
|
|
2458
|
+
var source = _this.processUploadSource(request.data);
|
|
2459
|
+
var preUploadInfo = _this.getPreUploadInfo(request, source);
|
|
2460
|
+
var bytesTotal = preUploadInfo.size;
|
|
2461
|
+
var makeOnProgressForPart = _this.makeOnProgressForPartFactory(request, bytesTotal);
|
|
2462
|
+
var init = _this.preUpload(source);
|
|
2463
|
+
// Raise initial progress event SYNCHRONOUSLY.
|
|
2464
|
+
if (request.onProgress !== undefined) {
|
|
2465
|
+
request.onProgress(_this.makeProgressEvent(0, bytesTotal));
|
|
2466
|
+
}
|
|
2467
|
+
return UploadManagerBase_await(_this.beginUpload(request, preUploadInfo, accountId), function (uploadInfo) {
|
|
2468
|
+
var partCount = uploadInfo.uploadParts.count;
|
|
2469
|
+
var parts = UploadManagerBase_toConsumableArray(Array(partCount).keys());
|
|
2470
|
+
var _this$makeCancellatio = _this.makeCancellationMethods(),
|
|
2471
|
+
cancel = _this$makeCancellatio.cancel,
|
|
2472
|
+
addCancellationHandler = _this$makeCancellatio.addCancellationHandler;
|
|
2473
|
+
var intervalHandle = setInterval(_this.onIntervalTick(request, cancel), _this.intervalMs);
|
|
2474
|
+
var uploadedParts;
|
|
2475
|
+
return UploadManagerBase_continue(UploadManagerBase_finallyRethrows(function () {
|
|
2476
|
+
return UploadManagerBase_await(_this.mapAsync(parts, preUploadInfo.maxConcurrentUploadParts, _async(function (part) {
|
|
2477
|
+
return _this.uploadPart(request, source, part, uploadInfo, makeOnProgressForPart(), addCancellationHandler, accountId);
|
|
2478
|
+
})), function (_this$mapAsync) {
|
|
2479
|
+
uploadedParts = _this$mapAsync;
|
|
2480
|
+
return UploadManagerBase_awaitIgnored(_this.postUpload(init));
|
|
2481
|
+
});
|
|
2482
|
+
}, function (_wasThrown, _result) {
|
|
2483
|
+
clearInterval(intervalHandle);
|
|
2484
|
+
return UploadManagerBase_rethrow(_wasThrown, _result);
|
|
2485
|
+
}), function () {
|
|
2486
|
+
var etag = uploadedParts.flatMap(function (x) {
|
|
2487
|
+
return x.status === "Completed" ? [x.etag] : [];
|
|
2488
|
+
})[0];
|
|
2489
|
+
return Object.assign(Object.assign({}, uploadInfo.file), {
|
|
2490
|
+
etag: etag // The 'etag' in the original 'uploadInfo.file' will be null, so we set it to the final etag value here.
|
|
2491
|
+
});
|
|
2238
2492
|
});
|
|
2239
2493
|
});
|
|
2240
2494
|
});
|
|
@@ -2441,7 +2695,7 @@ var UploadManagerBase = /*#__PURE__*/function () {
|
|
|
2441
2695
|
var result = [];
|
|
2442
2696
|
var workQueue = UploadManagerBase_toConsumableArray(items);
|
|
2443
2697
|
return UploadManagerBase_await(Promise.all(UploadManagerBase_toConsumableArray(Array(concurrency).keys()).map(_async(function () {
|
|
2444
|
-
return _continueIgnored(
|
|
2698
|
+
return _continueIgnored(UploadManagerBase_for(function () {
|
|
2445
2699
|
return workQueue.length > 0;
|
|
2446
2700
|
}, void 0, function () {
|
|
2447
2701
|
var work = workQueue.shift(); // IMPORTANT: use 'shift' instead of 'pop' to ensure 'items' are processed in order when 'concurrency = 1'.
|
|
@@ -34,4 +34,6 @@ export declare class AuthSessionState {
|
|
|
34
34
|
static getSession(): AuthSession | undefined;
|
|
35
35
|
/** Resolves request-time auth while remaining compatible with the single-token session used by SDK 3.54.0. */
|
|
36
36
|
static resolveAuthConfig(authConfigId: string | false | undefined, requireReadyDefault: boolean): ResolvedAuthSessionConfig | undefined;
|
|
37
|
+
/** Waits for request-time auth to be current before resolving it. */
|
|
38
|
+
static resolveAuthConfigAsync(authConfigId: string | false | undefined, requireReadyDefault: boolean): Promise<ResolvedAuthSessionConfig | undefined>;
|
|
37
39
|
}
|
|
@@ -3,16 +3,25 @@
|
|
|
3
3
|
* Q: Why not use 'setTimeout'?
|
|
4
4
|
* -------------------------
|
|
5
5
|
* A: setTimeout can be paused (e.g., during hibernation), risking JWT expiration before it triggers.
|
|
6
|
-
* We therefore
|
|
6
|
+
* We therefore check wall-clock time every second and on browser resume events. A backwards clock adjustment runs
|
|
7
|
+
* scheduled callbacks immediately so authentication can be safely re-established against the server-provided TTL.
|
|
7
8
|
* -------------------------
|
|
8
9
|
*/
|
|
9
10
|
export declare class Scheduler {
|
|
11
|
+
private readonly clockRollbackToleranceMilliseconds;
|
|
10
12
|
private callbacks;
|
|
13
|
+
private documentEventTarget;
|
|
11
14
|
private nextId;
|
|
12
15
|
private intervalId;
|
|
16
|
+
private lastObservedEpoch;
|
|
17
|
+
private windowEventTarget;
|
|
13
18
|
schedule(epoch: number, callback: () => void): number;
|
|
14
19
|
unschedule(handle: number): void;
|
|
15
|
-
private
|
|
16
|
-
private
|
|
20
|
+
private readonly checkAfterResume;
|
|
21
|
+
private readonly checkAfterVisibilityChange;
|
|
22
|
+
private startMonitoring;
|
|
23
|
+
private stopMonitoring;
|
|
17
24
|
private checkCallbacks;
|
|
25
|
+
private startListeningForResume;
|
|
26
|
+
private stopListeningForResume;
|
|
18
27
|
}
|
|
@@ -4,8 +4,10 @@ export interface AuthSwConfigEntryDto {
|
|
|
4
4
|
expires: number | undefined;
|
|
5
5
|
/** Headers to add to matching requests. */
|
|
6
6
|
headers: AuthSwHeaderDto[];
|
|
7
|
+
/** Optional original resource URL prefixes, before rewriting. An empty array matches no requests. */
|
|
8
|
+
requestUrlPrefixes?: string[];
|
|
7
9
|
/** Optional page or iframe URL prefixes. An empty array matches no clients. */
|
|
8
10
|
sourceUrlPrefixes?: string[];
|
|
9
|
-
/**
|
|
11
|
+
/** Final destination URL prefix. Use the actual URL; AuthManager applies any internal compatibility marker. */
|
|
10
12
|
urlPrefix: string;
|
|
11
13
|
}
|