@ama-sdk/core 10.3.0-prerelease.8 → 10.3.0-rc.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/cjs/clients/api-angular-client.js +36 -18
- package/cjs/clients/api-beacon-client.js +61 -19
- package/cjs/clients/api-fetch-client.js +60 -18
- package/cjs/fwk/api.helper.spec.js +20 -20
- package/cjs/fwk/api.helpers.js +14 -14
- 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 +253 -0
- package/cjs/utils/index.js +1 -0
- package/cjs/utils/json-token.js +30 -30
- package/cjs/utils/json-token.spec.js +31 -31
- package/cli/clear-index.cjs.map +1 -0
- package/cli/files-pack.cjs.map +1 -0
- package/esm2015/clients/api-angular-client.js +40 -22
- package/esm2015/clients/api-beacon-client.js +62 -20
- package/esm2015/clients/api-fetch-client.js +64 -22
- package/esm2015/clients/index.js +2 -2
- package/esm2015/fwk/api.helper.spec.js +21 -21
- package/esm2015/fwk/api.helpers.js +14 -14
- 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 +245 -0
- package/esm2015/utils/index.js +6 -5
- package/esm2015/utils/json-token.js +32 -32
- package/esm2015/utils/json-token.spec.js +32 -32
- package/package.json +7 -7
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/src/clients/api-angular-client.d.ts +6 -3
- package/src/clients/api-angular-client.d.ts.map +1 -1
- package/src/clients/api-angular-client.js +23 -11
- package/src/clients/api-angular-client.js.map +1 -1
- package/src/clients/api-beacon-client.d.ts +7 -5
- package/src/clients/api-beacon-client.d.ts.map +1 -1
- package/src/clients/api-beacon-client.js +22 -14
- package/src/clients/api-beacon-client.js.map +1 -1
- package/src/clients/api-fetch-client.d.ts +5 -3
- package/src/clients/api-fetch-client.d.ts.map +1 -1
- package/src/clients/api-fetch-client.js +22 -11
- package/src/clients/api-fetch-client.js.map +1 -1
- package/src/fwk/api.helpers.d.ts +1 -1
- package/src/fwk/api.helpers.d.ts.map +1 -1
- package/src/fwk/api.helpers.js +1 -1
- package/src/fwk/api.helpers.js.map +1 -1
- package/src/fwk/core/api-client.d.ts +36 -1
- package/src/fwk/core/api-client.d.ts.map +1 -1
- package/src/fwk/core/api-client.js.map +1 -1
- package/src/plugins/core/plugin.d.ts +6 -1
- package/src/plugins/core/plugin.d.ts.map +1 -1
- package/src/plugins/core/reply-plugin.d.ts +0 -2
- package/src/plugins/core/reply-plugin.d.ts.map +1 -1
- package/src/utils/generic-api.d.ts +39 -0
- package/src/utils/generic-api.d.ts.map +1 -0
- package/src/utils/generic-api.js +43 -0
- package/src/utils/generic-api.js.map +1 -0
- package/src/utils/index.d.ts +1 -0
- package/src/utils/index.d.ts.map +1 -1
- package/src/utils/index.js +1 -0
- package/src/utils/index.js.map +1 -1
|
@@ -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
|
];
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "GenericApi", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return GenericApi;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _fwk = require("../fwk");
|
|
12
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13
|
+
try {
|
|
14
|
+
var info = gen[key](arg);
|
|
15
|
+
var value = info.value;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
reject(error);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (info.done) {
|
|
21
|
+
resolve(value);
|
|
22
|
+
} else {
|
|
23
|
+
Promise.resolve(value).then(_next, _throw);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function _async_to_generator(fn) {
|
|
27
|
+
return function() {
|
|
28
|
+
var self = this, args = arguments;
|
|
29
|
+
return new Promise(function(resolve, reject) {
|
|
30
|
+
var gen = fn.apply(self, args);
|
|
31
|
+
function _next(value) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
33
|
+
}
|
|
34
|
+
function _throw(err) {
|
|
35
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
36
|
+
}
|
|
37
|
+
_next(undefined);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function _class_call_check(instance, Constructor) {
|
|
42
|
+
if (!(instance instanceof Constructor)) {
|
|
43
|
+
throw new TypeError("Cannot call a class as a function");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function _defineProperties(target, props) {
|
|
47
|
+
for(var i = 0; i < props.length; i++){
|
|
48
|
+
var descriptor = props[i];
|
|
49
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
50
|
+
descriptor.configurable = true;
|
|
51
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
52
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
56
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
57
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
58
|
+
return Constructor;
|
|
59
|
+
}
|
|
60
|
+
function _define_property(obj, key, value) {
|
|
61
|
+
if (key in obj) {
|
|
62
|
+
Object.defineProperty(obj, key, {
|
|
63
|
+
value: value,
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
obj[key] = value;
|
|
70
|
+
}
|
|
71
|
+
return obj;
|
|
72
|
+
}
|
|
73
|
+
function _object_spread(target) {
|
|
74
|
+
for(var i = 1; i < arguments.length; i++){
|
|
75
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
76
|
+
var ownKeys = Object.keys(source);
|
|
77
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
78
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
79
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
ownKeys.forEach(function(key) {
|
|
83
|
+
_define_property(target, key, source[key]);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return target;
|
|
87
|
+
}
|
|
88
|
+
function _ts_generator(thisArg, body) {
|
|
89
|
+
var f, y, t, g, _ = {
|
|
90
|
+
label: 0,
|
|
91
|
+
sent: function() {
|
|
92
|
+
if (t[0] & 1) throw t[1];
|
|
93
|
+
return t[1];
|
|
94
|
+
},
|
|
95
|
+
trys: [],
|
|
96
|
+
ops: []
|
|
97
|
+
};
|
|
98
|
+
return g = {
|
|
99
|
+
next: verb(0),
|
|
100
|
+
"throw": verb(1),
|
|
101
|
+
"return": verb(2)
|
|
102
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
103
|
+
return this;
|
|
104
|
+
}), g;
|
|
105
|
+
function verb(n) {
|
|
106
|
+
return function(v) {
|
|
107
|
+
return step([
|
|
108
|
+
n,
|
|
109
|
+
v
|
|
110
|
+
]);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function step(op) {
|
|
114
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
115
|
+
while(_)try {
|
|
116
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
117
|
+
if (y = 0, t) op = [
|
|
118
|
+
op[0] & 2,
|
|
119
|
+
t.value
|
|
120
|
+
];
|
|
121
|
+
switch(op[0]){
|
|
122
|
+
case 0:
|
|
123
|
+
case 1:
|
|
124
|
+
t = op;
|
|
125
|
+
break;
|
|
126
|
+
case 4:
|
|
127
|
+
_.label++;
|
|
128
|
+
return {
|
|
129
|
+
value: op[1],
|
|
130
|
+
done: false
|
|
131
|
+
};
|
|
132
|
+
case 5:
|
|
133
|
+
_.label++;
|
|
134
|
+
y = op[1];
|
|
135
|
+
op = [
|
|
136
|
+
0
|
|
137
|
+
];
|
|
138
|
+
continue;
|
|
139
|
+
case 7:
|
|
140
|
+
op = _.ops.pop();
|
|
141
|
+
_.trys.pop();
|
|
142
|
+
continue;
|
|
143
|
+
default:
|
|
144
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
145
|
+
_ = 0;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
149
|
+
_.label = op[1];
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
153
|
+
_.label = t[1];
|
|
154
|
+
t = op;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
if (t && _.label < t[2]) {
|
|
158
|
+
_.label = t[2];
|
|
159
|
+
_.ops.push(op);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
if (t[2]) _.ops.pop();
|
|
163
|
+
_.trys.pop();
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
op = body.call(thisArg, _);
|
|
167
|
+
} catch (e) {
|
|
168
|
+
op = [
|
|
169
|
+
6,
|
|
170
|
+
e
|
|
171
|
+
];
|
|
172
|
+
y = 0;
|
|
173
|
+
} finally{
|
|
174
|
+
f = t = 0;
|
|
175
|
+
}
|
|
176
|
+
if (op[0] & 5) throw op[1];
|
|
177
|
+
return {
|
|
178
|
+
value: op[0] ? op[1] : void 0,
|
|
179
|
+
done: true
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
var GenericApi = /*#__PURE__*/ function() {
|
|
184
|
+
"use strict";
|
|
185
|
+
function GenericApi(apiClient) {
|
|
186
|
+
_class_call_check(this, GenericApi);
|
|
187
|
+
/** @inheritDoc */ _define_property(this, "apiName", GenericApi.apiName);
|
|
188
|
+
/** @inheritDoc */ _define_property(this, "client", void 0);
|
|
189
|
+
this.client = apiClient;
|
|
190
|
+
}
|
|
191
|
+
_create_class(GenericApi, [
|
|
192
|
+
{
|
|
193
|
+
key: "request",
|
|
194
|
+
value: /**
|
|
195
|
+
* Process to request to the API in the context of the SDK
|
|
196
|
+
* @param requestOptions Option to provide to process to the call
|
|
197
|
+
*/ function request(requestOptions) {
|
|
198
|
+
var _this = this;
|
|
199
|
+
return _async_to_generator(function() {
|
|
200
|
+
var _requestOptions_metadata, _requestOptions_metadata1, metadataHeaderAccept, headers, requestParameters, options, _tmp, url, ret;
|
|
201
|
+
return _ts_generator(this, function(_state) {
|
|
202
|
+
switch(_state.label){
|
|
203
|
+
case 0:
|
|
204
|
+
metadataHeaderAccept = ((_requestOptions_metadata = requestOptions.metadata) === null || _requestOptions_metadata === void 0 ? void 0 : _requestOptions_metadata.headerAccept) || 'application/json';
|
|
205
|
+
headers = _object_spread({
|
|
206
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
207
|
+
'Content-Type': ((_requestOptions_metadata1 = requestOptions.metadata) === null || _requestOptions_metadata1 === void 0 ? void 0 : _requestOptions_metadata1.headerContentType) || 'application/json'
|
|
208
|
+
}, metadataHeaderAccept ? {
|
|
209
|
+
'Accept': metadataHeaderAccept
|
|
210
|
+
} : {});
|
|
211
|
+
requestParameters = _object_spread({
|
|
212
|
+
api: _this,
|
|
213
|
+
headers: headers
|
|
214
|
+
}, requestOptions);
|
|
215
|
+
if (!_this.client.getRequestOptions) return [
|
|
216
|
+
3,
|
|
217
|
+
2
|
|
218
|
+
];
|
|
219
|
+
return [
|
|
220
|
+
4,
|
|
221
|
+
_this.client.getRequestOptions(requestParameters)
|
|
222
|
+
];
|
|
223
|
+
case 1:
|
|
224
|
+
_tmp = _state.sent();
|
|
225
|
+
return [
|
|
226
|
+
3,
|
|
227
|
+
4
|
|
228
|
+
];
|
|
229
|
+
case 2:
|
|
230
|
+
return [
|
|
231
|
+
4,
|
|
232
|
+
_this.client.prepareOptions(requestParameters.basePath, requestParameters.method, requestParameters.queryParams || {}, requestParameters.headers)
|
|
233
|
+
];
|
|
234
|
+
case 3:
|
|
235
|
+
_tmp = _state.sent();
|
|
236
|
+
_state.label = 4;
|
|
237
|
+
case 4:
|
|
238
|
+
options = _tmp;
|
|
239
|
+
url = _this.client.prepareUrl(options.basePath, options.queryParams);
|
|
240
|
+
ret = _this.client.processCall(url, options, _fwk.ApiTypes.DEFAULT, requestOptions.api.apiName, requestOptions.revivers, requestOptions.operationId);
|
|
241
|
+
return [
|
|
242
|
+
2,
|
|
243
|
+
ret
|
|
244
|
+
];
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
})();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
]);
|
|
251
|
+
return GenericApi;
|
|
252
|
+
}();
|
|
253
|
+
/** API name */ _define_property(GenericApi, "apiName", 'GenericApi');
|
package/cjs/utils/index.js
CHANGED
|
@@ -7,6 +7,7 @@ _export_star(require("./encoder"), exports);
|
|
|
7
7
|
_export_star(require("./ie11"), exports);
|
|
8
8
|
_export_star(require("./json-token"), exports);
|
|
9
9
|
_export_star(require("./mime-types"), exports);
|
|
10
|
+
_export_star(require("./generic-api"), exports);
|
|
10
11
|
function _export_star(from, to) {
|
|
11
12
|
Object.keys(from).forEach(function(k) {
|
|
12
13
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|