@ama-sdk/core 10.3.0-prerelease.9 → 10.4.0-prerelease.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/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/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
|
@@ -174,43 +174,43 @@ function _ts_generator(thisArg, body) {
|
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
import * as jsonToken from
|
|
178
|
-
import { PiiTokenizerRequest } from
|
|
179
|
-
describe(
|
|
177
|
+
import * as jsonToken from '../../utils/json-token';
|
|
178
|
+
import { PiiTokenizerRequest } from './pii-tokenizer.request';
|
|
179
|
+
describe('Tokenizer Request Plugin', function() {
|
|
180
180
|
var options;
|
|
181
181
|
var tokenizedOptions = {
|
|
182
|
-
url:
|
|
182
|
+
url: 'http://test.com/path/$pathParamToken$',
|
|
183
183
|
queryParams: {
|
|
184
|
-
classicParam:
|
|
185
|
-
sensitiveParam:
|
|
184
|
+
classicParam: 'classicParamValue',
|
|
185
|
+
sensitiveParam: '$sensitiveParamToken$'
|
|
186
186
|
},
|
|
187
187
|
values: {
|
|
188
|
-
$pathParamToken$:
|
|
189
|
-
$sensitiveParamToken$:
|
|
188
|
+
$pathParamToken$: 'pathParamValue',
|
|
189
|
+
$sensitiveParamToken$: 'sensitiveParamValue'
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
192
|
beforeEach(function() {
|
|
193
193
|
options = {
|
|
194
|
-
method:
|
|
194
|
+
method: 'get',
|
|
195
195
|
headers: new Headers(),
|
|
196
|
-
basePath:
|
|
196
|
+
basePath: 'http://test.com/path/pathParamValue',
|
|
197
197
|
queryParams: {
|
|
198
|
-
classicParam:
|
|
199
|
-
sensitiveParam:
|
|
198
|
+
classicParam: 'classicParamValue',
|
|
199
|
+
sensitiveParam: 'sensitiveParamValue'
|
|
200
200
|
}
|
|
201
201
|
};
|
|
202
|
-
jest.spyOn(console,
|
|
202
|
+
jest.spyOn(console, 'error');
|
|
203
203
|
});
|
|
204
204
|
afterEach(function() {
|
|
205
205
|
jest.restoreAllMocks();
|
|
206
206
|
});
|
|
207
|
-
it(
|
|
207
|
+
it('should replace sensitive parameters with tokens', /*#__PURE__*/ _async_to_generator(function() {
|
|
208
208
|
var plugin, runner, result;
|
|
209
209
|
return _ts_generator(this, function(_state) {
|
|
210
210
|
switch(_state.label){
|
|
211
211
|
case 0:
|
|
212
212
|
plugin = new PiiTokenizerRequest({
|
|
213
|
-
applicationId:
|
|
213
|
+
applicationId: 'app-id'
|
|
214
214
|
});
|
|
215
215
|
runner = plugin.load();
|
|
216
216
|
return [
|
|
@@ -221,24 +221,24 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
221
221
|
];
|
|
222
222
|
case 1:
|
|
223
223
|
result = _state.sent();
|
|
224
|
-
expect(result.basePath).toEqual(
|
|
225
|
-
expect(result.queryParams.classicParam).toEqual(
|
|
226
|
-
expect(result.queryParams.sensitiveParam).toEqual(
|
|
227
|
-
expect(result.headers.get(
|
|
224
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
225
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
226
|
+
expect(result.queryParams.sensitiveParam).toEqual('$sensitiveParamToken$');
|
|
227
|
+
expect(result.headers.get('ama-client-facts')).not.toBeNull();
|
|
228
228
|
return [
|
|
229
229
|
2
|
|
230
230
|
];
|
|
231
231
|
}
|
|
232
232
|
});
|
|
233
233
|
}));
|
|
234
|
-
it(
|
|
234
|
+
it('should put token-value associations in custom header if provided', /*#__PURE__*/ _async_to_generator(function() {
|
|
235
235
|
var plugin, runner, result;
|
|
236
236
|
return _ts_generator(this, function(_state) {
|
|
237
237
|
switch(_state.label){
|
|
238
238
|
case 0:
|
|
239
239
|
plugin = new PiiTokenizerRequest({
|
|
240
|
-
applicationId:
|
|
241
|
-
headerName:
|
|
240
|
+
applicationId: 'app-id',
|
|
241
|
+
headerName: 'custom-header'
|
|
242
242
|
});
|
|
243
243
|
runner = plugin.load();
|
|
244
244
|
return [
|
|
@@ -249,21 +249,21 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
249
249
|
];
|
|
250
250
|
case 1:
|
|
251
251
|
result = _state.sent();
|
|
252
|
-
expect(result.headers.get(
|
|
253
|
-
expect(result.headers.get(
|
|
252
|
+
expect(result.headers.get('ama-client-facts')).toBeNull();
|
|
253
|
+
expect(result.headers.get('custom-header')).not.toBeNull();
|
|
254
254
|
return [
|
|
255
255
|
2
|
|
256
256
|
];
|
|
257
257
|
}
|
|
258
258
|
});
|
|
259
259
|
}));
|
|
260
|
-
it(
|
|
260
|
+
it('should keep default parameters and print an error if tokenization is disabled', /*#__PURE__*/ _async_to_generator(function() {
|
|
261
261
|
var plugin, runner, result;
|
|
262
262
|
return _ts_generator(this, function(_state) {
|
|
263
263
|
switch(_state.label){
|
|
264
264
|
case 0:
|
|
265
265
|
plugin = new PiiTokenizerRequest({
|
|
266
|
-
applicationId:
|
|
266
|
+
applicationId: 'app-id'
|
|
267
267
|
});
|
|
268
268
|
runner = plugin.load();
|
|
269
269
|
return [
|
|
@@ -272,10 +272,10 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
272
272
|
];
|
|
273
273
|
case 1:
|
|
274
274
|
result = _state.sent();
|
|
275
|
-
expect(result.basePath).toEqual(
|
|
276
|
-
expect(result.queryParams.classicParam).toEqual(
|
|
277
|
-
expect(result.queryParams.sensitiveParam).toEqual(
|
|
278
|
-
expect(result.headers.get(
|
|
275
|
+
expect(result.basePath).toEqual('http://test.com/path/pathParamValue');
|
|
276
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
277
|
+
expect(result.queryParams.sensitiveParam).toEqual('sensitiveParamValue');
|
|
278
|
+
expect(result.headers.get('ama-client-facts')).toBeNull();
|
|
279
279
|
// eslint-disable-next-line no-console
|
|
280
280
|
expect(console.error).toHaveBeenCalled();
|
|
281
281
|
return [
|
|
@@ -284,13 +284,13 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
284
284
|
}
|
|
285
285
|
});
|
|
286
286
|
}));
|
|
287
|
-
it(
|
|
287
|
+
it('should keep default parameters if no token-value associations is provided', /*#__PURE__*/ _async_to_generator(function() {
|
|
288
288
|
var plugin, runner, result;
|
|
289
289
|
return _ts_generator(this, function(_state) {
|
|
290
290
|
switch(_state.label){
|
|
291
291
|
case 0:
|
|
292
292
|
plugin = new PiiTokenizerRequest({
|
|
293
|
-
applicationId:
|
|
293
|
+
applicationId: 'app-id'
|
|
294
294
|
});
|
|
295
295
|
runner = plugin.load();
|
|
296
296
|
return [
|
|
@@ -303,10 +303,10 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
303
303
|
];
|
|
304
304
|
case 1:
|
|
305
305
|
result = _state.sent();
|
|
306
|
-
expect(result.basePath).toEqual(
|
|
307
|
-
expect(result.queryParams.classicParam).toEqual(
|
|
308
|
-
expect(result.queryParams.sensitiveParam).toEqual(
|
|
309
|
-
expect(result.headers.get(
|
|
306
|
+
expect(result.basePath).toEqual('http://test.com/path/pathParamValue');
|
|
307
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
308
|
+
expect(result.queryParams.sensitiveParam).toEqual('sensitiveParamValue');
|
|
309
|
+
expect(result.headers.get('ama-client-facts')).toBeNull();
|
|
310
310
|
// eslint-disable-next-line no-console
|
|
311
311
|
expect(console.error).not.toHaveBeenCalled();
|
|
312
312
|
return [
|
|
@@ -315,15 +315,15 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
315
315
|
}
|
|
316
316
|
});
|
|
317
317
|
}));
|
|
318
|
-
it(
|
|
318
|
+
it('should use JWT if no key specified', /*#__PURE__*/ _async_to_generator(function() {
|
|
319
319
|
var mockJweEncoder, mockJwtEncoder, plugin, runner;
|
|
320
320
|
return _ts_generator(this, function(_state) {
|
|
321
321
|
switch(_state.label){
|
|
322
322
|
case 0:
|
|
323
|
-
mockJweEncoder = jest.spyOn(jsonToken,
|
|
324
|
-
mockJwtEncoder = jest.spyOn(jsonToken,
|
|
323
|
+
mockJweEncoder = jest.spyOn(jsonToken, 'createJweEncoder');
|
|
324
|
+
mockJwtEncoder = jest.spyOn(jsonToken, 'createJwtEncoder');
|
|
325
325
|
plugin = new PiiTokenizerRequest({
|
|
326
|
-
applicationId:
|
|
326
|
+
applicationId: 'app-id'
|
|
327
327
|
});
|
|
328
328
|
runner = plugin.load();
|
|
329
329
|
return [
|
|
@@ -342,25 +342,25 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
342
342
|
}
|
|
343
343
|
});
|
|
344
344
|
}));
|
|
345
|
-
it(
|
|
345
|
+
it('should use JWE if a key is specified', /*#__PURE__*/ _async_to_generator(function() {
|
|
346
346
|
var key, mockJweEncoder, mockJwtEncoder, plugin, runner, result, expectedJwePayload;
|
|
347
347
|
return _ts_generator(this, function(_state) {
|
|
348
348
|
switch(_state.label){
|
|
349
349
|
case 0:
|
|
350
|
-
jest.spyOn(Date,
|
|
350
|
+
jest.spyOn(Date, 'now').mockImplementation(function() {
|
|
351
351
|
return 0;
|
|
352
352
|
});
|
|
353
353
|
key = {
|
|
354
|
-
publicKey:
|
|
355
|
-
keyId:
|
|
354
|
+
publicKey: 'myPublicKey',
|
|
355
|
+
keyId: 'TEST'
|
|
356
356
|
};
|
|
357
|
-
mockJweEncoder = jest.fn().mockResolvedValue(
|
|
358
|
-
jest.spyOn(jsonToken,
|
|
357
|
+
mockJweEncoder = jest.fn().mockResolvedValue('myJweToken');
|
|
358
|
+
jest.spyOn(jsonToken, 'createJweEncoder').mockImplementation(function() {
|
|
359
359
|
return mockJweEncoder;
|
|
360
360
|
});
|
|
361
|
-
mockJwtEncoder = jest.spyOn(jsonToken,
|
|
361
|
+
mockJwtEncoder = jest.spyOn(jsonToken, 'createJwtEncoder');
|
|
362
362
|
plugin = new PiiTokenizerRequest({
|
|
363
|
-
applicationId:
|
|
363
|
+
applicationId: 'app-id',
|
|
364
364
|
key: key
|
|
365
365
|
});
|
|
366
366
|
runner = plugin.load();
|
|
@@ -374,19 +374,19 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
374
374
|
result = _state.sent();
|
|
375
375
|
expectedJwePayload = {
|
|
376
376
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
377
|
-
|
|
378
|
-
$pathParamToken$:
|
|
379
|
-
$sensitiveParamToken$:
|
|
377
|
+
'ama-tokens': {
|
|
378
|
+
$pathParamToken$: 'pathParamValue',
|
|
379
|
+
$sensitiveParamToken$: 'sensitiveParamValue'
|
|
380
380
|
},
|
|
381
381
|
exp: 3600,
|
|
382
382
|
iat: 0,
|
|
383
|
-
iss:
|
|
384
|
-
sub:
|
|
383
|
+
iss: 'app-id',
|
|
384
|
+
sub: 'pii'
|
|
385
385
|
};
|
|
386
|
-
expect(result.headers.get(
|
|
386
|
+
expect(result.headers.get('ama-client-facts')).toEqual('myJweToken');
|
|
387
387
|
expect(mockJweEncoder).toHaveBeenCalledWith(key, expectedJwePayload, [
|
|
388
|
-
|
|
389
|
-
|
|
388
|
+
'iss',
|
|
389
|
+
'sub'
|
|
390
390
|
]);
|
|
391
391
|
expect(mockJwtEncoder).not.toHaveBeenCalled();
|
|
392
392
|
return [
|
|
@@ -395,21 +395,21 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
395
395
|
}
|
|
396
396
|
});
|
|
397
397
|
}));
|
|
398
|
-
it(
|
|
398
|
+
it('should throw by default if an exception is raised for JWE encoder', /*#__PURE__*/ _async_to_generator(function() {
|
|
399
399
|
var key, mockJweEncoder, plugin, runner;
|
|
400
400
|
return _ts_generator(this, function(_state) {
|
|
401
401
|
switch(_state.label){
|
|
402
402
|
case 0:
|
|
403
403
|
key = {
|
|
404
|
-
publicKey:
|
|
405
|
-
keyId:
|
|
404
|
+
publicKey: 'myPublicKey',
|
|
405
|
+
keyId: 'TEST'
|
|
406
406
|
};
|
|
407
|
-
mockJweEncoder = jest.fn().mockRejectedValue(
|
|
408
|
-
jest.spyOn(jsonToken,
|
|
407
|
+
mockJweEncoder = jest.fn().mockRejectedValue('Error creating JWE');
|
|
408
|
+
jest.spyOn(jsonToken, 'createJweEncoder').mockImplementation(function() {
|
|
409
409
|
return mockJweEncoder;
|
|
410
410
|
});
|
|
411
411
|
plugin = new PiiTokenizerRequest({
|
|
412
|
-
applicationId:
|
|
412
|
+
applicationId: 'app-id',
|
|
413
413
|
key: key
|
|
414
414
|
});
|
|
415
415
|
runner = plugin.load();
|
|
@@ -430,21 +430,21 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
430
430
|
}
|
|
431
431
|
});
|
|
432
432
|
}));
|
|
433
|
-
it(
|
|
433
|
+
it('should handle errors silently if an exception is raised for JWE encoder', /*#__PURE__*/ _async_to_generator(function() {
|
|
434
434
|
var key, mockJweEncoder, plugin, runner;
|
|
435
435
|
return _ts_generator(this, function(_state) {
|
|
436
436
|
switch(_state.label){
|
|
437
437
|
case 0:
|
|
438
438
|
key = {
|
|
439
|
-
publicKey:
|
|
440
|
-
keyId:
|
|
439
|
+
publicKey: 'myPublicKey',
|
|
440
|
+
keyId: 'TEST'
|
|
441
441
|
};
|
|
442
|
-
mockJweEncoder = jest.fn().mockRejectedValue(
|
|
443
|
-
jest.spyOn(jsonToken,
|
|
442
|
+
mockJweEncoder = jest.fn().mockRejectedValue('Error creating JWE');
|
|
443
|
+
jest.spyOn(jsonToken, 'createJweEncoder').mockImplementation(function() {
|
|
444
444
|
return mockJweEncoder;
|
|
445
445
|
});
|
|
446
446
|
plugin = new PiiTokenizerRequest({
|
|
447
|
-
applicationId:
|
|
447
|
+
applicationId: 'app-id',
|
|
448
448
|
key: key,
|
|
449
449
|
silent: true
|
|
450
450
|
});
|
|
@@ -466,25 +466,25 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
466
466
|
}
|
|
467
467
|
});
|
|
468
468
|
}));
|
|
469
|
-
it(
|
|
469
|
+
it('should skip PII tokenization and put DeepLink token in corresponding header when DeepLink token is provided', /*#__PURE__*/ _async_to_generator(function() {
|
|
470
470
|
var plugin, runner, deepLinkOptions, metadata, result;
|
|
471
471
|
return _ts_generator(this, function(_state) {
|
|
472
472
|
switch(_state.label){
|
|
473
473
|
case 0:
|
|
474
474
|
plugin = new PiiTokenizerRequest({
|
|
475
|
-
applicationId:
|
|
475
|
+
applicationId: 'app-id'
|
|
476
476
|
});
|
|
477
477
|
runner = plugin.load();
|
|
478
478
|
deepLinkOptions = {
|
|
479
|
-
token:
|
|
479
|
+
token: 'myDeepLinkToken'
|
|
480
480
|
};
|
|
481
481
|
metadata = {
|
|
482
482
|
deepLinkOptions: deepLinkOptions
|
|
483
483
|
};
|
|
484
|
-
options.basePath =
|
|
484
|
+
options.basePath = 'http://test.com/path/$pathParamToken$';
|
|
485
485
|
options.queryParams = {
|
|
486
|
-
classicParam:
|
|
487
|
-
sensitiveParam:
|
|
486
|
+
classicParam: 'classicParamValue',
|
|
487
|
+
sensitiveParam: '$sensitiveParamToken$'
|
|
488
488
|
};
|
|
489
489
|
return [
|
|
490
490
|
4,
|
|
@@ -497,10 +497,10 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
497
497
|
];
|
|
498
498
|
case 1:
|
|
499
499
|
result = _state.sent();
|
|
500
|
-
expect(result.basePath).toEqual(
|
|
501
|
-
expect(result.queryParams.classicParam).toEqual(
|
|
502
|
-
expect(result.queryParams.sensitiveParam).toEqual(
|
|
503
|
-
expect(result.headers.get(
|
|
500
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
501
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
502
|
+
expect(result.queryParams.sensitiveParam).toEqual('$sensitiveParamToken$');
|
|
503
|
+
expect(result.headers.get('ama-client-facts')).toEqual('myDeepLinkToken');
|
|
504
504
|
// eslint-disable-next-line no-console
|
|
505
505
|
expect(console.error).not.toHaveBeenCalled();
|
|
506
506
|
return [
|
|
@@ -509,28 +509,28 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
509
509
|
}
|
|
510
510
|
});
|
|
511
511
|
}));
|
|
512
|
-
it(
|
|
512
|
+
it('should put DeepLink challenge answers in corresponding header when provided', /*#__PURE__*/ _async_to_generator(function() {
|
|
513
513
|
var plugin, runner, deepLinkOptions, metadata, result;
|
|
514
514
|
return _ts_generator(this, function(_state) {
|
|
515
515
|
switch(_state.label){
|
|
516
516
|
case 0:
|
|
517
517
|
plugin = new PiiTokenizerRequest({
|
|
518
|
-
applicationId:
|
|
518
|
+
applicationId: 'app-id'
|
|
519
519
|
});
|
|
520
520
|
runner = plugin.load();
|
|
521
521
|
deepLinkOptions = {
|
|
522
|
-
token:
|
|
522
|
+
token: 'myDeepLinkToken',
|
|
523
523
|
challengeAnswers: {
|
|
524
|
-
lastName:
|
|
524
|
+
lastName: 'Doe'
|
|
525
525
|
}
|
|
526
526
|
};
|
|
527
527
|
metadata = {
|
|
528
528
|
deepLinkOptions: deepLinkOptions
|
|
529
529
|
};
|
|
530
|
-
options.basePath =
|
|
530
|
+
options.basePath = 'http://test.com/path/$pathParamToken$';
|
|
531
531
|
options.queryParams = {
|
|
532
|
-
classicParam:
|
|
533
|
-
sensitiveParam:
|
|
532
|
+
classicParam: 'classicParamValue',
|
|
533
|
+
sensitiveParam: '$sensitiveParamToken$'
|
|
534
534
|
};
|
|
535
535
|
return [
|
|
536
536
|
4,
|
|
@@ -543,29 +543,29 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
543
543
|
];
|
|
544
544
|
case 1:
|
|
545
545
|
result = _state.sent();
|
|
546
|
-
expect(result.basePath).toEqual(
|
|
547
|
-
expect(result.queryParams.classicParam).toEqual(
|
|
548
|
-
expect(result.queryParams.sensitiveParam).toEqual(
|
|
549
|
-
expect(result.headers.get(
|
|
550
|
-
expect(result.headers.get(
|
|
546
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
547
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
548
|
+
expect(result.queryParams.sensitiveParam).toEqual('$sensitiveParamToken$');
|
|
549
|
+
expect(result.headers.get('ama-client-facts')).toEqual('myDeepLinkToken');
|
|
550
|
+
expect(result.headers.get('ama-client-facts-challenge')).toEqual('{"lastName":"Doe"}');
|
|
551
551
|
return [
|
|
552
552
|
2
|
|
553
553
|
];
|
|
554
554
|
}
|
|
555
555
|
});
|
|
556
556
|
}));
|
|
557
|
-
it(
|
|
557
|
+
it('Should not loose additional parameters not expected for the actual request', /*#__PURE__*/ _async_to_generator(function() {
|
|
558
558
|
var plugin, runner, result;
|
|
559
559
|
return _ts_generator(this, function(_state) {
|
|
560
560
|
switch(_state.label){
|
|
561
561
|
case 0:
|
|
562
562
|
plugin = new PiiTokenizerRequest({
|
|
563
|
-
applicationId:
|
|
563
|
+
applicationId: 'app-id'
|
|
564
564
|
});
|
|
565
565
|
runner = plugin.load();
|
|
566
|
-
options.basePath =
|
|
566
|
+
options.basePath = 'http://test.com/path/pathParamValue';
|
|
567
567
|
options.queryParams = _object_spread_props(_object_spread({}, options.queryParams), {
|
|
568
|
-
additionalParam:
|
|
568
|
+
additionalParam: 'foo'
|
|
569
569
|
});
|
|
570
570
|
return [
|
|
571
571
|
4,
|
|
@@ -575,8 +575,8 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
575
575
|
];
|
|
576
576
|
case 1:
|
|
577
577
|
result = _state.sent();
|
|
578
|
-
expect(result.basePath).toEqual(
|
|
579
|
-
expect(result.queryParams.additionalParam).toEqual(
|
|
578
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
579
|
+
expect(result.queryParams.additionalParam).toEqual('foo');
|
|
580
580
|
return [
|
|
581
581
|
2
|
|
582
582
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './raw-response-info.reply';
|
|
@@ -122,11 +122,11 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { ApiTypes } from
|
|
126
|
-
import { RawResponseInfoReply } from
|
|
127
|
-
describe(
|
|
125
|
+
import { ApiTypes } from '../../fwk/api';
|
|
126
|
+
import { RawResponseInfoReply } from './raw-response-info.reply';
|
|
127
|
+
describe('Raw response info Reply plugin', function() {
|
|
128
128
|
var reviver = jest.fn();
|
|
129
|
-
it(
|
|
129
|
+
it('should add response object', /*#__PURE__*/ _async_to_generator(function() {
|
|
130
130
|
var plugin, runner, data, newData;
|
|
131
131
|
return _ts_generator(this, function(_state) {
|
|
132
132
|
switch(_state.label){
|
|
@@ -137,7 +137,7 @@ describe("Raw response info Reply plugin", function() {
|
|
|
137
137
|
apiType: ApiTypes.DEFAULT,
|
|
138
138
|
response: {
|
|
139
139
|
headers: new Headers(),
|
|
140
|
-
test:
|
|
140
|
+
test: 'OK'
|
|
141
141
|
}
|
|
142
142
|
});
|
|
143
143
|
data = {};
|
|
@@ -148,14 +148,14 @@ describe("Raw response info Reply plugin", function() {
|
|
|
148
148
|
case 1:
|
|
149
149
|
newData = _state.sent();
|
|
150
150
|
expect(newData.responseInfo).toBeDefined();
|
|
151
|
-
expect(newData.responseInfo.test).toBe(
|
|
151
|
+
expect(newData.responseInfo.test).toBe('OK');
|
|
152
152
|
return [
|
|
153
153
|
2
|
|
154
154
|
];
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
157
|
}));
|
|
158
|
-
it(
|
|
158
|
+
it('should keep original data', /*#__PURE__*/ _async_to_generator(function() {
|
|
159
159
|
var plugin, runner, data, newData;
|
|
160
160
|
return _ts_generator(this, function(_state) {
|
|
161
161
|
switch(_state.label){
|
|
@@ -166,11 +166,11 @@ describe("Raw response info Reply plugin", function() {
|
|
|
166
166
|
apiType: ApiTypes.DEFAULT,
|
|
167
167
|
response: {
|
|
168
168
|
headers: new Headers(),
|
|
169
|
-
test:
|
|
169
|
+
test: 'OK'
|
|
170
170
|
}
|
|
171
171
|
});
|
|
172
172
|
data = {
|
|
173
|
-
originalData:
|
|
173
|
+
originalData: 'OK'
|
|
174
174
|
};
|
|
175
175
|
return [
|
|
176
176
|
4,
|
|
@@ -178,22 +178,22 @@ describe("Raw response info Reply plugin", function() {
|
|
|
178
178
|
];
|
|
179
179
|
case 1:
|
|
180
180
|
newData = _state.sent();
|
|
181
|
-
expect(newData.originalData).toBe(
|
|
181
|
+
expect(newData.originalData).toBe('OK');
|
|
182
182
|
return [
|
|
183
183
|
2
|
|
184
184
|
];
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
187
|
}));
|
|
188
|
-
it(
|
|
188
|
+
it('should invalidate response info', function() {
|
|
189
189
|
var data = {
|
|
190
|
-
originalData:
|
|
190
|
+
originalData: 'OK'
|
|
191
191
|
};
|
|
192
192
|
expect(RawResponseInfoReply.hasResponseInfo(data)).toBeFalsy();
|
|
193
193
|
});
|
|
194
|
-
it(
|
|
194
|
+
it('should validate response info', function() {
|
|
195
195
|
var data = {
|
|
196
|
-
originalData:
|
|
196
|
+
originalData: 'OK',
|
|
197
197
|
responseInfo: {
|
|
198
198
|
headers: new Headers()
|
|
199
199
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './retry.fetch';
|
|
@@ -161,7 +161,7 @@ function _ts_generator(thisArg, body) {
|
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
import { CanceledCallError } from
|
|
164
|
+
import { CanceledCallError } from '../../fwk/errors';
|
|
165
165
|
/**
|
|
166
166
|
* Plugin to Retry a fetch call
|
|
167
167
|
*/ export var RetryFetch = /*#__PURE__*/ function() {
|