@ama-sdk/core 10.3.0-prerelease.66 → 10.3.0-prerelease.67
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/cjs/clients/api-angular-client.js +4 -4
- package/cjs/clients/api-beacon-client.js +4 -4
- package/cjs/clients/api-fetch-client.js +4 -4
- package/cjs/fwk/api.helper.spec.js +20 -20
- package/cjs/fwk/api.helpers.js +13 -13
- package/cjs/fwk/core/api-client.js +1 -1
- package/cjs/fwk/core/base-api-constructor.js +1 -1
- package/cjs/fwk/date.js +9 -9
- package/cjs/fwk/date.spec.js +25 -25
- package/cjs/fwk/errors.js +3 -3
- package/cjs/fwk/mocks/alf-mock-adapter.js +4 -4
- package/cjs/fwk/mocks/base-mock-adapter.js +2 -2
- package/cjs/fwk/mocks/helpers.js +3 -3
- package/cjs/fwk/reviver.spec.js +19 -19
- package/cjs/plugins/additional-params/additional-params-sync.request.js +2 -2
- package/cjs/plugins/additional-params/additional-params.request.js +3 -3
- package/cjs/plugins/additional-params/additional-params.spec.js +30 -30
- package/cjs/plugins/api-configuration-override/api-configuration-override.request.js +2 -2
- package/cjs/plugins/api-configuration-override/api-configuration-override.spec.js +13 -13
- package/cjs/plugins/api-key/api-key.request.js +2 -2
- package/cjs/plugins/api-key/api-key.spec.js +11 -11
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +5 -5
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +33 -33
- package/cjs/plugins/client-facts/client-facts.request.js +3 -3
- package/cjs/plugins/client-facts/client-facts.spec.js +27 -27
- package/cjs/plugins/concurrent/concurrent.spec.js +4 -4
- package/cjs/plugins/custom-info/custom-info.spec.js +15 -15
- package/cjs/plugins/exception/exception.reply.js +2 -2
- package/cjs/plugins/exception/exception.spec.js +15 -15
- package/cjs/plugins/fetch-cache/fetch-cache.request.js +4 -4
- package/cjs/plugins/fetch-cache/fetch-cache.spec.js +20 -20
- package/cjs/plugins/fetch-credentials/fetch-credentials.request.js +1 -1
- package/cjs/plugins/fetch-credentials/fetch-credentials.spec.js +8 -8
- package/cjs/plugins/json-token/json-token.reply.js +5 -5
- package/cjs/plugins/json-token/json-token.request.js +4 -4
- package/cjs/plugins/json-token/json-token.spec.js +24 -24
- package/cjs/plugins/keepalive/keepalive.request.js +2 -2
- package/cjs/plugins/keepalive/keepalive.spec.js +4 -4
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +11 -11
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +25 -25
- package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +3 -3
- package/cjs/plugins/mock-intercept/mock-intercept.interface.js +2 -2
- package/cjs/plugins/mock-intercept/mock-intercept.request.js +3 -3
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +28 -28
- package/cjs/plugins/perf-metric/perf-metric.fetch.js +1 -1
- package/cjs/plugins/perf-metric/perf-metric.probe.spec.js +9 -9
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.request.js +11 -11
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.spec.js +94 -94
- package/cjs/plugins/raw-response-info/raw-response-info.spec.js +12 -12
- package/cjs/plugins/retry/retry.spec.js +20 -20
- package/cjs/plugins/reviver/reviver.spec.js +4 -4
- package/cjs/plugins/session-id/session-id.request.js +6 -6
- package/cjs/plugins/session-id/session-id.spec.js +13 -13
- package/cjs/plugins/si-token/si-token.spec.js +9 -9
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +4 -4
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +44 -44
- package/cjs/plugins/timeout/timeout.fetch.js +11 -11
- package/cjs/plugins/timeout/timeout.spec.js +13 -13
- package/cjs/plugins/url-rewrite/url-rewrite.spec.js +9 -9
- package/cjs/plugins/wait-for/wait-for.spec.js +9 -9
- package/cjs/utils/crypto.js +14 -14
- package/cjs/utils/generic-api.js +4 -4
- package/cjs/utils/json-token.js +30 -30
- package/cjs/utils/json-token.spec.js +31 -31
- package/esm2015/clients/api-angular-client.js +8 -8
- package/esm2015/clients/api-beacon-client.js +5 -5
- package/esm2015/clients/api-fetch-client.js +8 -8
- package/esm2015/clients/index.js +2 -2
- package/esm2015/fwk/api.helper.spec.js +21 -21
- package/esm2015/fwk/api.helpers.js +13 -13
- package/esm2015/fwk/core/api-client.js +1 -1
- package/esm2015/fwk/core/base-api-constructor.js +1 -1
- package/esm2015/fwk/core/index.js +2 -2
- package/esm2015/fwk/date.js +9 -9
- package/esm2015/fwk/date.spec.js +26 -26
- package/esm2015/fwk/errors.js +3 -3
- package/esm2015/fwk/index.js +10 -10
- package/esm2015/fwk/mocks/alf-mock-adapter.js +6 -6
- package/esm2015/fwk/mocks/base-mock-adapter.js +3 -3
- package/esm2015/fwk/mocks/helpers.js +3 -3
- package/esm2015/fwk/mocks/index.js +10 -10
- package/esm2015/fwk/mocks/random-mock-adapter.js +1 -1
- package/esm2015/fwk/mocks/sequential-mock-adapter.js +1 -1
- package/esm2015/fwk/reviver.spec.js +20 -20
- package/esm2015/plugins/additional-params/additional-params-sync.request.js +3 -3
- package/esm2015/plugins/additional-params/additional-params.request.js +3 -3
- package/esm2015/plugins/additional-params/additional-params.spec.js +32 -32
- package/esm2015/plugins/additional-params/index.js +2 -2
- package/esm2015/plugins/api-configuration-override/api-configuration-override.request.js +2 -2
- package/esm2015/plugins/api-configuration-override/api-configuration-override.spec.js +14 -14
- package/esm2015/plugins/api-configuration-override/index.js +1 -1
- package/esm2015/plugins/api-key/api-key.request.js +2 -2
- package/esm2015/plugins/api-key/api-key.spec.js +12 -12
- package/esm2015/plugins/api-key/index.js +1 -1
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +5 -5
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +34 -34
- package/esm2015/plugins/bot-protection-fingerprint/index.js +1 -1
- package/esm2015/plugins/client-facts/client-facts.request.js +4 -4
- package/esm2015/plugins/client-facts/client-facts.spec.js +28 -28
- package/esm2015/plugins/client-facts/index.js +1 -1
- package/esm2015/plugins/concurrent/concurrent.spec.js +5 -5
- package/esm2015/plugins/concurrent/index.js +1 -1
- package/esm2015/plugins/core/index.js +4 -4
- package/esm2015/plugins/custom-info/custom-info.spec.js +17 -17
- package/esm2015/plugins/custom-info/index.js +1 -1
- package/esm2015/plugins/exception/exception.reply.js +4 -4
- package/esm2015/plugins/exception/exception.spec.js +18 -18
- package/esm2015/plugins/exception/index.js +1 -1
- package/esm2015/plugins/fetch-cache/fetch-cache.request.js +4 -4
- package/esm2015/plugins/fetch-cache/fetch-cache.spec.js +21 -21
- package/esm2015/plugins/fetch-cache/index.js +1 -1
- package/esm2015/plugins/fetch-credentials/fetch-credentials.request.js +1 -1
- package/esm2015/plugins/fetch-credentials/fetch-credentials.spec.js +9 -9
- package/esm2015/plugins/fetch-credentials/index.js +1 -1
- package/esm2015/plugins/index.js +25 -25
- package/esm2015/plugins/json-token/index.js +2 -2
- package/esm2015/plugins/json-token/json-token.reply.js +5 -5
- package/esm2015/plugins/json-token/json-token.request.js +4 -4
- package/esm2015/plugins/json-token/json-token.spec.js +27 -27
- package/esm2015/plugins/keepalive/index.js +1 -1
- package/esm2015/plugins/keepalive/keepalive.request.js +2 -2
- package/esm2015/plugins/keepalive/keepalive.spec.js +5 -5
- package/esm2015/plugins/mgw-mdw-auth/index.js +1 -1
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +13 -13
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +27 -27
- package/esm2015/plugins/mock-intercept/index.js +2 -2
- package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +5 -5
- package/esm2015/plugins/mock-intercept/mock-intercept.interface.js +2 -2
- package/esm2015/plugins/mock-intercept/mock-intercept.request.js +4 -4
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +32 -32
- package/esm2015/plugins/perf-metric/index.js +1 -1
- package/esm2015/plugins/perf-metric/perf-metric.fetch.js +2 -2
- package/esm2015/plugins/perf-metric/perf-metric.probe.spec.js +10 -10
- package/esm2015/plugins/pii-tokenizer/index.js +1 -1
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.request.js +12 -12
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.spec.js +96 -96
- package/esm2015/plugins/raw-response-info/index.js +1 -1
- package/esm2015/plugins/raw-response-info/raw-response-info.spec.js +14 -14
- package/esm2015/plugins/retry/index.js +1 -1
- package/esm2015/plugins/retry/retry.fetch.js +1 -1
- package/esm2015/plugins/retry/retry.spec.js +21 -21
- package/esm2015/plugins/reviver/index.js +1 -1
- package/esm2015/plugins/reviver/reviver.spec.js +6 -6
- package/esm2015/plugins/session-id/index.js +1 -1
- package/esm2015/plugins/session-id/session-id.request.js +7 -7
- package/esm2015/plugins/session-id/session-id.spec.js +14 -14
- package/esm2015/plugins/si-token/index.js +1 -1
- package/esm2015/plugins/si-token/si-token.request.js +1 -1
- package/esm2015/plugins/si-token/si-token.spec.js +10 -10
- package/esm2015/plugins/simple-api-key-authentication/index.js +1 -1
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +5 -5
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +46 -46
- package/esm2015/plugins/timeout/index.js +1 -1
- package/esm2015/plugins/timeout/timeout.fetch.js +12 -12
- package/esm2015/plugins/timeout/timeout.spec.js +15 -15
- package/esm2015/plugins/url-rewrite/index.js +1 -1
- package/esm2015/plugins/url-rewrite/url-rewrite.spec.js +10 -10
- package/esm2015/plugins/wait-for/index.js +1 -1
- package/esm2015/plugins/wait-for/wait-for.spec.js +10 -10
- package/esm2015/public_api.js +4 -4
- package/esm2015/utils/crypto.js +15 -15
- package/esm2015/utils/generic-api.js +5 -5
- package/esm2015/utils/index.js +6 -6
- package/esm2015/utils/json-token.js +32 -32
- package/esm2015/utils/json-token.spec.js +32 -32
- package/package.json +5 -5
|
@@ -177,7 +177,7 @@ function _ts_generator(thisArg, body) {
|
|
|
177
177
|
* Check if a message can be cast as an {@link ImpervaCaptchaMessage}
|
|
178
178
|
* @param message
|
|
179
179
|
*/ function isImpervaCaptchaMessage(message) {
|
|
180
|
-
return Object.prototype.hasOwnProperty.call(message,
|
|
180
|
+
return Object.prototype.hasOwnProperty.call(message, 'impervaChallenge') && Object.prototype.hasOwnProperty.call(message.impervaChallenge, 'status') && Object.prototype.hasOwnProperty.call(message.impervaChallenge, 'type') && message.impervaChallenge.type === 'captcha';
|
|
181
181
|
}
|
|
182
182
|
var impervaCaptchaEventHandlerFactory = function(config) {
|
|
183
183
|
return function(timeoutPauseCallback) {
|
|
@@ -186,14 +186,14 @@ var impervaCaptchaEventHandlerFactory = function(config) {
|
|
|
186
186
|
if (originHostname !== location.hostname && ((config === null || config === void 0 ? void 0 : config.whiteListedHostNames) || []).indexOf(originHostname) === -1) {
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
|
-
var message = typeof event.data ===
|
|
189
|
+
var message = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;
|
|
190
190
|
if (message && isImpervaCaptchaMessage(message)) {
|
|
191
|
-
timeoutPauseCallback(message.impervaChallenge.status ===
|
|
191
|
+
timeoutPauseCallback(message.impervaChallenge.status === 'started' ? 'timeoutStopped' : 'timeoutStarted');
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
|
-
addEventListener(
|
|
194
|
+
addEventListener('message', onImpervaCaptcha);
|
|
195
195
|
return function() {
|
|
196
|
-
removeEventListener(
|
|
196
|
+
removeEventListener('message', onImpervaCaptcha);
|
|
197
197
|
};
|
|
198
198
|
};
|
|
199
199
|
};
|
|
@@ -209,7 +209,7 @@ var TimeoutFetch = /*#__PURE__*/ function() {
|
|
|
209
209
|
_define_property(this, "timerPauseState", void 0);
|
|
210
210
|
this.timeoutPauseEvent = timeoutPauseEvent;
|
|
211
211
|
this.timerSubscription = [];
|
|
212
|
-
this.timerPauseState =
|
|
212
|
+
this.timerPauseState = 'timeoutStarted';
|
|
213
213
|
this.timeout = timeout;
|
|
214
214
|
if (this.timeoutPauseEvent) {
|
|
215
215
|
this.timeoutPauseEvent(function(pausedStatus) {
|
|
@@ -240,15 +240,15 @@ var TimeoutFetch = /*#__PURE__*/ function() {
|
|
|
240
240
|
reject(new _errors.ResponseTimeoutError("in ".concat(_this.timeout, "ms")));
|
|
241
241
|
(_context_controller = context.controller) === null || _context_controller === void 0 ? void 0 : _context_controller.abort();
|
|
242
242
|
};
|
|
243
|
-
timer = _this.timerPauseState ===
|
|
243
|
+
timer = _this.timerPauseState === 'timeoutStopped' ? undefined : setTimeout(timeoutCallback, _this.timeout);
|
|
244
244
|
timerCallback = function(pauseStatus) {
|
|
245
|
-
if (timer && pauseStatus ===
|
|
245
|
+
if (timer && pauseStatus === 'timeoutStopped') {
|
|
246
246
|
clearTimeout(timer);
|
|
247
|
-
(context.logger || console).log(
|
|
247
|
+
(context.logger || console).log('[SDK Plugins] Timeout cancelled.');
|
|
248
248
|
timer = undefined;
|
|
249
|
-
} else if (!timer && pauseStatus ===
|
|
249
|
+
} else if (!timer && pauseStatus === 'timeoutStarted') {
|
|
250
250
|
timer = setTimeout(timeoutCallback, _this.timeout);
|
|
251
|
-
(context.logger || console).log(
|
|
251
|
+
(context.logger || console).log('[SDK Plugins] Timeout restarted.');
|
|
252
252
|
}
|
|
253
253
|
};
|
|
254
254
|
_this.timerSubscription.push(timerCallback);
|
|
@@ -128,8 +128,8 @@ function _ts_generator(thisArg, body) {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
describe(
|
|
132
|
-
it(
|
|
131
|
+
describe('Timeout Fetch Plugin', function() {
|
|
132
|
+
it('should reject on timeout', /*#__PURE__*/ _async_to_generator(function() {
|
|
133
133
|
var plugin, runner, call, callback;
|
|
134
134
|
return _ts_generator(this, function(_state) {
|
|
135
135
|
switch(_state.label){
|
|
@@ -158,14 +158,14 @@ describe("Timeout Fetch Plugin", function() {
|
|
|
158
158
|
];
|
|
159
159
|
case 2:
|
|
160
160
|
_state.sent();
|
|
161
|
-
expect(callback).toHaveBeenCalledWith(new _errors.ResponseTimeoutError(
|
|
161
|
+
expect(callback).toHaveBeenCalledWith(new _errors.ResponseTimeoutError('in 100ms'));
|
|
162
162
|
return [
|
|
163
163
|
2
|
|
164
164
|
];
|
|
165
165
|
}
|
|
166
166
|
});
|
|
167
167
|
}));
|
|
168
|
-
it(
|
|
168
|
+
it('should not reject on fetch rejection', /*#__PURE__*/ _async_to_generator(function() {
|
|
169
169
|
var plugin, runner, call, callback;
|
|
170
170
|
return _ts_generator(this, function(_state) {
|
|
171
171
|
switch(_state.label){
|
|
@@ -176,7 +176,7 @@ describe("Timeout Fetch Plugin", function() {
|
|
|
176
176
|
});
|
|
177
177
|
call = new Promise(function(_resolve, reject) {
|
|
178
178
|
return setTimeout(function() {
|
|
179
|
-
return reject(new _errors.EmptyResponseError(
|
|
179
|
+
return reject(new _errors.EmptyResponseError(''));
|
|
180
180
|
}, 100);
|
|
181
181
|
});
|
|
182
182
|
callback = jest.fn();
|
|
@@ -187,14 +187,14 @@ describe("Timeout Fetch Plugin", function() {
|
|
|
187
187
|
];
|
|
188
188
|
case 1:
|
|
189
189
|
_state.sent();
|
|
190
|
-
expect(callback).toHaveBeenCalledWith(new _errors.EmptyResponseError(
|
|
190
|
+
expect(callback).toHaveBeenCalledWith(new _errors.EmptyResponseError(''));
|
|
191
191
|
return [
|
|
192
192
|
2
|
|
193
193
|
];
|
|
194
194
|
}
|
|
195
195
|
});
|
|
196
196
|
}));
|
|
197
|
-
it(
|
|
197
|
+
it('should forward the fetch response', /*#__PURE__*/ _async_to_generator(function() {
|
|
198
198
|
var plugin, runner, call, promise;
|
|
199
199
|
return _ts_generator(this, function(_state) {
|
|
200
200
|
switch(_state.label){
|
|
@@ -233,7 +233,7 @@ describe("Timeout Fetch Plugin", function() {
|
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
235
|
}));
|
|
236
|
-
it(
|
|
236
|
+
it('should not reject if the timeout has been paused and reject if restarted', /*#__PURE__*/ _async_to_generator(function() {
|
|
237
237
|
var timeoutPauseEvent, plugin, runner, call, callback;
|
|
238
238
|
return _ts_generator(this, function(_state) {
|
|
239
239
|
switch(_state.label){
|
|
@@ -258,28 +258,28 @@ describe("Timeout Fetch Plugin", function() {
|
|
|
258
258
|
});
|
|
259
259
|
callback = jest.fn();
|
|
260
260
|
runner.transform(call).catch(callback);
|
|
261
|
-
timeoutPauseEvent.emitEvent(
|
|
261
|
+
timeoutPauseEvent.emitEvent('timeoutStopped');
|
|
262
262
|
return [
|
|
263
263
|
4,
|
|
264
264
|
jest.advanceTimersByTimeAsync(200)
|
|
265
265
|
];
|
|
266
266
|
case 1:
|
|
267
267
|
_state.sent();
|
|
268
|
-
timeoutPauseEvent.emitEvent(
|
|
268
|
+
timeoutPauseEvent.emitEvent('timeoutStarted');
|
|
269
269
|
return [
|
|
270
270
|
4,
|
|
271
271
|
jest.advanceTimersByTimeAsync(200)
|
|
272
272
|
];
|
|
273
273
|
case 2:
|
|
274
274
|
_state.sent();
|
|
275
|
-
expect(callback).toHaveBeenCalledWith(new _errors.ResponseTimeoutError(
|
|
275
|
+
expect(callback).toHaveBeenCalledWith(new _errors.ResponseTimeoutError('in 100ms'));
|
|
276
276
|
return [
|
|
277
277
|
2
|
|
278
278
|
];
|
|
279
279
|
}
|
|
280
280
|
});
|
|
281
281
|
}));
|
|
282
|
-
it(
|
|
282
|
+
it('should take into account pause events triggered before the call', /*#__PURE__*/ _async_to_generator(function() {
|
|
283
283
|
var timeoutPauseEvent, plugin, runner, call, promise;
|
|
284
284
|
return _ts_generator(this, function(_state) {
|
|
285
285
|
switch(_state.label){
|
|
@@ -302,7 +302,7 @@ describe("Timeout Fetch Plugin", function() {
|
|
|
302
302
|
});
|
|
303
303
|
}, 500);
|
|
304
304
|
});
|
|
305
|
-
timeoutPauseEvent.emitEvent(
|
|
305
|
+
timeoutPauseEvent.emitEvent('timeoutStopped');
|
|
306
306
|
promise = runner.transform(call);
|
|
307
307
|
return [
|
|
308
308
|
4,
|
|
@@ -127,24 +127,24 @@ function _ts_generator(thisArg, body) {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
describe(
|
|
131
|
-
var urlRewriter = jest.fn().mockReturnValue(
|
|
130
|
+
describe('URL Rewrite Request Plugin', function() {
|
|
131
|
+
var urlRewriter = jest.fn().mockReturnValue('http://ok');
|
|
132
132
|
var defaultGetParams = {
|
|
133
|
-
defaultTest:
|
|
133
|
+
defaultTest: 'ok'
|
|
134
134
|
};
|
|
135
|
-
var defaultBody =
|
|
136
|
-
var defaultUrl =
|
|
135
|
+
var defaultBody = 'default';
|
|
136
|
+
var defaultUrl = 'http://test.com/truc';
|
|
137
137
|
var options;
|
|
138
138
|
beforeEach(function() {
|
|
139
139
|
options = {
|
|
140
|
-
method:
|
|
140
|
+
method: 'get',
|
|
141
141
|
queryParams: defaultGetParams,
|
|
142
142
|
headers: new Headers(),
|
|
143
143
|
body: defaultBody,
|
|
144
144
|
basePath: defaultUrl
|
|
145
145
|
};
|
|
146
146
|
});
|
|
147
|
-
it(
|
|
147
|
+
it('should call the URL rewriter', /*#__PURE__*/ _async_to_generator(function() {
|
|
148
148
|
var plugin, runner;
|
|
149
149
|
return _ts_generator(this, function(_state) {
|
|
150
150
|
switch(_state.label){
|
|
@@ -164,7 +164,7 @@ describe("URL Rewrite Request Plugin", function() {
|
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
166
|
}));
|
|
167
|
-
it(
|
|
167
|
+
it('should have updated the url', /*#__PURE__*/ _async_to_generator(function() {
|
|
168
168
|
var plugin, runner, result;
|
|
169
169
|
return _ts_generator(this, function(_state) {
|
|
170
170
|
switch(_state.label){
|
|
@@ -177,7 +177,7 @@ describe("URL Rewrite Request Plugin", function() {
|
|
|
177
177
|
];
|
|
178
178
|
case 1:
|
|
179
179
|
result = _state.sent();
|
|
180
|
-
expect(result.basePath).toBe(
|
|
180
|
+
expect(result.basePath).toBe('http://ok');
|
|
181
181
|
return [
|
|
182
182
|
2
|
|
183
183
|
];
|
|
@@ -179,9 +179,9 @@ function _ts_generator(thisArg, body) {
|
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
describe(
|
|
182
|
+
describe('Wait For Fetch Plugin', function() {
|
|
183
183
|
var defaultContext = {};
|
|
184
|
-
it(
|
|
184
|
+
it('should not start if timeout', /*#__PURE__*/ _async_to_generator(function() {
|
|
185
185
|
var plugin, runner, canStart;
|
|
186
186
|
return _ts_generator(this, function(_state) {
|
|
187
187
|
switch(_state.label){
|
|
@@ -217,7 +217,7 @@ describe("Wait For Fetch Plugin", function() {
|
|
|
217
217
|
}
|
|
218
218
|
});
|
|
219
219
|
}));
|
|
220
|
-
it(
|
|
220
|
+
it('should start if promise condition passed', /*#__PURE__*/ _async_to_generator(function() {
|
|
221
221
|
var plugin, runner, canStart;
|
|
222
222
|
return _ts_generator(this, function(_state) {
|
|
223
223
|
switch(_state.label){
|
|
@@ -241,7 +241,7 @@ describe("Wait For Fetch Plugin", function() {
|
|
|
241
241
|
}
|
|
242
242
|
});
|
|
243
243
|
}));
|
|
244
|
-
it(
|
|
244
|
+
it('should start if condition passed', /*#__PURE__*/ _async_to_generator(function() {
|
|
245
245
|
var plugin, runner, canStart;
|
|
246
246
|
return _ts_generator(this, function(_state) {
|
|
247
247
|
switch(_state.label){
|
|
@@ -265,7 +265,7 @@ describe("Wait For Fetch Plugin", function() {
|
|
|
265
265
|
}
|
|
266
266
|
});
|
|
267
267
|
}));
|
|
268
|
-
it(
|
|
268
|
+
it('should call the callback function on success', /*#__PURE__*/ _async_to_generator(function() {
|
|
269
269
|
var callback, plugin, runner, response, fetchCall;
|
|
270
270
|
return _ts_generator(this, function(_state) {
|
|
271
271
|
switch(_state.label){
|
|
@@ -294,7 +294,7 @@ describe("Wait For Fetch Plugin", function() {
|
|
|
294
294
|
}
|
|
295
295
|
});
|
|
296
296
|
}));
|
|
297
|
-
it(
|
|
297
|
+
it('should call the callback function with the correct data', /*#__PURE__*/ _async_to_generator(function() {
|
|
298
298
|
var callback, plugin, runner, response, fetchCall;
|
|
299
299
|
return _ts_generator(this, function(_state) {
|
|
300
300
|
switch(_state.label){
|
|
@@ -303,7 +303,7 @@ describe("Wait For Fetch Plugin", function() {
|
|
|
303
303
|
plugin = new _waitforfetch.WaitForFetch(function() {
|
|
304
304
|
return {
|
|
305
305
|
result: true,
|
|
306
|
-
data:
|
|
306
|
+
data: 'test'
|
|
307
307
|
};
|
|
308
308
|
}, 100, callback);
|
|
309
309
|
runner = plugin.load(defaultContext);
|
|
@@ -324,7 +324,7 @@ describe("Wait For Fetch Plugin", function() {
|
|
|
324
324
|
case 2:
|
|
325
325
|
_state.sent();
|
|
326
326
|
expect(callback).toHaveBeenCalledWith(expect.objectContaining(_object_spread_props(_object_spread({}, defaultContext), {
|
|
327
|
-
data:
|
|
327
|
+
data: 'test'
|
|
328
328
|
})), fetchCall, response);
|
|
329
329
|
return [
|
|
330
330
|
2
|
|
@@ -332,7 +332,7 @@ describe("Wait For Fetch Plugin", function() {
|
|
|
332
332
|
}
|
|
333
333
|
});
|
|
334
334
|
}));
|
|
335
|
-
it(
|
|
335
|
+
it('should call the callback function on failure', /*#__PURE__*/ _async_to_generator(function() {
|
|
336
336
|
var callback, plugin, runner, response, fetchCall, e;
|
|
337
337
|
return _ts_generator(this, function(_state) {
|
|
338
338
|
switch(_state.label){
|
package/cjs/utils/crypto.js
CHANGED
|
@@ -165,23 +165,23 @@ function str2ab(str) {
|
|
|
165
165
|
return buf;
|
|
166
166
|
}
|
|
167
167
|
function generateContentEncryptionKey() {
|
|
168
|
-
if (typeof window.msCrypto !==
|
|
168
|
+
if (typeof window.msCrypto !== 'undefined') {
|
|
169
169
|
return (0, _ie11.promisifyMsCrypto)(window.msCrypto.subtle.generateKey({
|
|
170
|
-
name:
|
|
170
|
+
name: 'AES-GCM',
|
|
171
171
|
length: 256
|
|
172
172
|
}, true, [
|
|
173
|
-
|
|
173
|
+
'encrypt'
|
|
174
174
|
]));
|
|
175
175
|
}
|
|
176
176
|
return window.crypto.subtle.generateKey({
|
|
177
|
-
name:
|
|
177
|
+
name: 'AES-GCM',
|
|
178
178
|
length: 256
|
|
179
179
|
}, true, [
|
|
180
|
-
|
|
180
|
+
'encrypt'
|
|
181
181
|
]);
|
|
182
182
|
}
|
|
183
183
|
function generateIV() {
|
|
184
|
-
if (typeof window.msCrypto !==
|
|
184
|
+
if (typeof window.msCrypto !== 'undefined') {
|
|
185
185
|
return window.msCrypto.getRandomValues(new Uint8Array(12));
|
|
186
186
|
}
|
|
187
187
|
return window.crypto.getRandomValues(new Uint8Array(12));
|
|
@@ -195,13 +195,13 @@ function _wrapContentEncryptionKey() {
|
|
|
195
195
|
return _ts_generator(this, function(_state) {
|
|
196
196
|
switch(_state.label){
|
|
197
197
|
case 0:
|
|
198
|
-
if (!(typeof window.msCrypto !==
|
|
198
|
+
if (!(typeof window.msCrypto !== 'undefined')) return [
|
|
199
199
|
3,
|
|
200
200
|
2
|
|
201
201
|
];
|
|
202
202
|
return [
|
|
203
203
|
4,
|
|
204
|
-
(0, _ie11.promisifyMsCrypto)(window.msCrypto.subtle.exportKey(
|
|
204
|
+
(0, _ie11.promisifyMsCrypto)(window.msCrypto.subtle.exportKey('raw', contentEncryptionKey))
|
|
205
205
|
];
|
|
206
206
|
case 1:
|
|
207
207
|
bufferCek = _state.sent();
|
|
@@ -209,15 +209,15 @@ function _wrapContentEncryptionKey() {
|
|
|
209
209
|
return [
|
|
210
210
|
2,
|
|
211
211
|
(0, _ie11.promisifyMsCrypto)(window.msCrypto.subtle.encrypt({
|
|
212
|
-
name:
|
|
213
|
-
hash:
|
|
212
|
+
name: 'RSA-OAEP',
|
|
213
|
+
hash: 'SHA-256'
|
|
214
214
|
}, publicKey, new Uint8Array(bufferCek)))
|
|
215
215
|
];
|
|
216
216
|
case 2:
|
|
217
217
|
return [
|
|
218
218
|
2,
|
|
219
|
-
window.crypto.subtle.wrapKey(
|
|
220
|
-
name:
|
|
219
|
+
window.crypto.subtle.wrapKey('raw', contentEncryptionKey, publicKey, {
|
|
220
|
+
name: 'RSA-OAEP'
|
|
221
221
|
})
|
|
222
222
|
];
|
|
223
223
|
}
|
|
@@ -235,14 +235,14 @@ function _encryptPayload() {
|
|
|
235
235
|
switch(_state.label){
|
|
236
236
|
case 0:
|
|
237
237
|
aesParams = {
|
|
238
|
-
name:
|
|
238
|
+
name: 'AES-GCM',
|
|
239
239
|
iv: iv,
|
|
240
240
|
tagLength: authenticationTagLength
|
|
241
241
|
};
|
|
242
242
|
if (additionalAuthenticatedData) {
|
|
243
243
|
aesParams.additionalData = additionalAuthenticatedData;
|
|
244
244
|
}
|
|
245
|
-
if (!(typeof window.msCrypto !==
|
|
245
|
+
if (!(typeof window.msCrypto !== 'undefined')) return [
|
|
246
246
|
3,
|
|
247
247
|
2
|
|
248
248
|
];
|
package/cjs/utils/generic-api.js
CHANGED
|
@@ -201,12 +201,12 @@ var GenericApi = /*#__PURE__*/ function() {
|
|
|
201
201
|
return _ts_generator(this, function(_state) {
|
|
202
202
|
switch(_state.label){
|
|
203
203
|
case 0:
|
|
204
|
-
metadataHeaderAccept = ((_requestOptions_metadata = requestOptions.metadata) === null || _requestOptions_metadata === void 0 ? void 0 : _requestOptions_metadata.headerAccept) ||
|
|
204
|
+
metadataHeaderAccept = ((_requestOptions_metadata = requestOptions.metadata) === null || _requestOptions_metadata === void 0 ? void 0 : _requestOptions_metadata.headerAccept) || 'application/json';
|
|
205
205
|
headers = _object_spread({
|
|
206
206
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
207
|
-
|
|
207
|
+
'Content-Type': ((_requestOptions_metadata1 = requestOptions.metadata) === null || _requestOptions_metadata1 === void 0 ? void 0 : _requestOptions_metadata1.headerContentType) || 'application/json'
|
|
208
208
|
}, metadataHeaderAccept ? {
|
|
209
|
-
|
|
209
|
+
'Accept': metadataHeaderAccept
|
|
210
210
|
} : {});
|
|
211
211
|
requestParameters = _object_spread({
|
|
212
212
|
api: _this,
|
|
@@ -250,4 +250,4 @@ var GenericApi = /*#__PURE__*/ function() {
|
|
|
250
250
|
]);
|
|
251
251
|
return GenericApi;
|
|
252
252
|
}();
|
|
253
|
-
/** API name */ _define_property(GenericApi, "apiName",
|
|
253
|
+
/** API name */ _define_property(GenericApi, "apiName", 'GenericApi');
|
package/cjs/utils/json-token.js
CHANGED
|
@@ -169,11 +169,11 @@ function _ts_generator(thisArg, body) {
|
|
|
169
169
|
// encodeURI escape all non-ASCII characters but we don't want to escape latin non-ascii characters
|
|
170
170
|
// (charCode between 128 and 255).
|
|
171
171
|
return window.btoa(encodeURI(str).replace(/%C2%([89AB][0-9A-F])/g, function(_match, p1) {
|
|
172
|
-
return String.fromCharCode(parseInt(
|
|
172
|
+
return String.fromCharCode(parseInt('0x' + p1, 16));
|
|
173
173
|
}).replace(/%C3%([89AB][0-9A-F])/g, function(_match, p1) {
|
|
174
|
-
return String.fromCharCode(parseInt(
|
|
174
|
+
return String.fromCharCode(parseInt('0xc0', 16) + parseInt('0x' + p1, 16) - parseInt('0x80', 16));
|
|
175
175
|
}).replace(/%([0-9A-F]{2})/g, function(_match, p1) {
|
|
176
|
-
return String.fromCharCode(parseInt(
|
|
176
|
+
return String.fromCharCode(parseInt('0x' + p1, 16));
|
|
177
177
|
}));
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
@@ -183,83 +183,83 @@ function _ts_generator(thisArg, body) {
|
|
|
183
183
|
// Once the provided string is decoded from based64, we convert each character in its hexadecimal
|
|
184
184
|
// value prefixed with the % character to make it URI compatible.
|
|
185
185
|
var hexString = window.atob(str).replace(/./g, function(match) {
|
|
186
|
-
return
|
|
186
|
+
return '%' + match.charCodeAt(0).toString(16);
|
|
187
187
|
});
|
|
188
188
|
return decodeURI(hexString);
|
|
189
189
|
}
|
|
190
190
|
function base64EncodeUrl(str) {
|
|
191
|
-
return str.replace(/\+/g,
|
|
191
|
+
return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
192
192
|
}
|
|
193
193
|
function base64DecodeUrl(str) {
|
|
194
194
|
// Pad out with standard base64 required padding characters
|
|
195
|
-
str = (str +
|
|
196
|
-
return str.replace(/-/g,
|
|
195
|
+
str = (str + '===').slice(0, str.length + str.length % 4);
|
|
196
|
+
return str.replace(/-/g, '+').replace(/_/g, '/');
|
|
197
197
|
}
|
|
198
198
|
function createBase64Encoder() {
|
|
199
199
|
// Web browsers
|
|
200
|
-
if (typeof window !==
|
|
200
|
+
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
201
201
|
return function(data) {
|
|
202
202
|
return base64EncodeUnicode(data);
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
205
|
// NodeJS
|
|
206
|
-
if (typeof Buffer ===
|
|
206
|
+
if (typeof Buffer === 'function') {
|
|
207
207
|
return function(data) {
|
|
208
|
-
return Buffer.from(data).toString(
|
|
208
|
+
return Buffer.from(data).toString('base64');
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
-
throw new Error(
|
|
211
|
+
throw new Error('Cannot convert string to base64, both btoa and Buffer are undefined.');
|
|
212
212
|
}
|
|
213
213
|
function createBase64Decoder() {
|
|
214
214
|
// Web browsers
|
|
215
|
-
if (typeof window !==
|
|
215
|
+
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
216
216
|
return function(data) {
|
|
217
217
|
return base64DecodeUnicode(data);
|
|
218
218
|
};
|
|
219
219
|
}
|
|
220
220
|
// NodeJS
|
|
221
|
-
if (typeof Buffer ===
|
|
221
|
+
if (typeof Buffer === 'function') {
|
|
222
222
|
return function(data) {
|
|
223
|
-
return Buffer.from(data,
|
|
223
|
+
return Buffer.from(data, 'base64').toString();
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
|
-
throw new Error(
|
|
226
|
+
throw new Error('Cannot convert base64 to string, both atob and Buffer are undefined.');
|
|
227
227
|
}
|
|
228
228
|
function createBase64UrlEncoder() {
|
|
229
229
|
// Web browsers
|
|
230
|
-
if (typeof window !==
|
|
230
|
+
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
231
231
|
return function(data) {
|
|
232
232
|
return base64EncodeUrl(base64EncodeUnicode(data));
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
235
|
// NodeJS
|
|
236
|
-
if (typeof Buffer ===
|
|
236
|
+
if (typeof Buffer === 'function') {
|
|
237
237
|
return function(data) {
|
|
238
|
-
return base64EncodeUrl(Buffer.from(data).toString(
|
|
238
|
+
return base64EncodeUrl(Buffer.from(data).toString('base64'));
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
|
-
throw new Error(
|
|
241
|
+
throw new Error('Cannot convert string to base64, both btoa and Buffer are undefined.');
|
|
242
242
|
}
|
|
243
243
|
function createBase64UrlDecoder() {
|
|
244
244
|
// Web browsers
|
|
245
|
-
if (typeof window !==
|
|
245
|
+
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
246
246
|
return function(data) {
|
|
247
247
|
return base64DecodeUnicode(base64DecodeUrl(data));
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
250
|
// NodeJS
|
|
251
|
-
if (typeof Buffer ===
|
|
251
|
+
if (typeof Buffer === 'function') {
|
|
252
252
|
return function(data) {
|
|
253
|
-
return Buffer.from(base64DecodeUrl(data),
|
|
253
|
+
return Buffer.from(base64DecodeUrl(data), 'base64').toString();
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
|
-
throw new Error(
|
|
256
|
+
throw new Error('Cannot convert base64 to string, both atob and Buffer are undefined.');
|
|
257
257
|
}
|
|
258
258
|
function createJwtEncoder() {
|
|
259
259
|
var encoder = createBase64UrlEncoder();
|
|
260
260
|
var jwtHeader = {
|
|
261
|
-
alg:
|
|
262
|
-
typ:
|
|
261
|
+
alg: 'none',
|
|
262
|
+
typ: 'JWT'
|
|
263
263
|
};
|
|
264
264
|
return function(jwtPayload) {
|
|
265
265
|
return "".concat(encoder(JSON.stringify(jwtHeader)), ".").concat(encoder(JSON.stringify(jwtPayload)), ".");
|
|
@@ -268,7 +268,7 @@ function createJwtEncoder() {
|
|
|
268
268
|
function createJweEncoder() {
|
|
269
269
|
var aesTagLengthInBits = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 128, useHeaderAsAAD = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
270
270
|
var base64Encoder = createBase64UrlEncoder();
|
|
271
|
-
var stringEncoder = typeof window.TextEncoder !==
|
|
271
|
+
var stringEncoder = typeof window.TextEncoder !== 'undefined' ? new TextEncoder() : new _encoder.Encoder();
|
|
272
272
|
return function() {
|
|
273
273
|
var _ref = _async_to_generator(function(param, jwePayload, publicProperties) {
|
|
274
274
|
var publicKey, keyId, jweHeader, cek, wrappedCek, iv, serializedHeader, _ref, ciphertext, authenticationTag;
|
|
@@ -277,9 +277,9 @@ function createJweEncoder() {
|
|
|
277
277
|
case 0:
|
|
278
278
|
publicKey = param.publicKey, keyId = param.keyId;
|
|
279
279
|
jweHeader = {
|
|
280
|
-
alg:
|
|
281
|
-
enc:
|
|
282
|
-
typ:
|
|
280
|
+
alg: 'RSA-OAEP-256',
|
|
281
|
+
enc: 'A256GCM',
|
|
282
|
+
typ: 'JWE',
|
|
283
283
|
kid: keyId
|
|
284
284
|
};
|
|
285
285
|
publicProperties.forEach(function(property) {
|
|
@@ -317,7 +317,7 @@ function createJweEncoder() {
|
|
|
317
317
|
_ref = _state.sent(), ciphertext = _ref.ciphertext, authenticationTag = _ref.authenticationTag;
|
|
318
318
|
return [
|
|
319
319
|
2,
|
|
320
|
-
serializedHeader +
|
|
320
|
+
serializedHeader + '.' + base64Encoder((0, _crypto.ab2str)(wrappedCek)) + '.' + base64Encoder((0, _crypto.ab2str)(iv.buffer)) + '.' + base64Encoder((0, _crypto.ab2str)(ciphertext)) + '.' + base64Encoder((0, _crypto.ab2str)(authenticationTag))
|
|
321
321
|
];
|
|
322
322
|
}
|
|
323
323
|
});
|