@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
|
@@ -221,41 +221,41 @@ function _ts_generator(thisArg, body) {
|
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
describe(
|
|
224
|
+
describe('Tokenizer Request Plugin', function() {
|
|
225
225
|
var options;
|
|
226
226
|
var tokenizedOptions = {
|
|
227
|
-
url:
|
|
227
|
+
url: 'http://test.com/path/$pathParamToken$',
|
|
228
228
|
queryParams: {
|
|
229
|
-
classicParam:
|
|
230
|
-
sensitiveParam:
|
|
229
|
+
classicParam: 'classicParamValue',
|
|
230
|
+
sensitiveParam: '$sensitiveParamToken$'
|
|
231
231
|
},
|
|
232
232
|
values: {
|
|
233
|
-
$pathParamToken$:
|
|
234
|
-
$sensitiveParamToken$:
|
|
233
|
+
$pathParamToken$: 'pathParamValue',
|
|
234
|
+
$sensitiveParamToken$: 'sensitiveParamValue'
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
237
|
beforeEach(function() {
|
|
238
238
|
options = {
|
|
239
|
-
method:
|
|
239
|
+
method: 'get',
|
|
240
240
|
headers: new Headers(),
|
|
241
|
-
basePath:
|
|
241
|
+
basePath: 'http://test.com/path/pathParamValue',
|
|
242
242
|
queryParams: {
|
|
243
|
-
classicParam:
|
|
244
|
-
sensitiveParam:
|
|
243
|
+
classicParam: 'classicParamValue',
|
|
244
|
+
sensitiveParam: 'sensitiveParamValue'
|
|
245
245
|
}
|
|
246
246
|
};
|
|
247
|
-
jest.spyOn(console,
|
|
247
|
+
jest.spyOn(console, 'error');
|
|
248
248
|
});
|
|
249
249
|
afterEach(function() {
|
|
250
250
|
jest.restoreAllMocks();
|
|
251
251
|
});
|
|
252
|
-
it(
|
|
252
|
+
it('should replace sensitive parameters with tokens', /*#__PURE__*/ _async_to_generator(function() {
|
|
253
253
|
var plugin, runner, result;
|
|
254
254
|
return _ts_generator(this, function(_state) {
|
|
255
255
|
switch(_state.label){
|
|
256
256
|
case 0:
|
|
257
257
|
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
258
|
-
applicationId:
|
|
258
|
+
applicationId: 'app-id'
|
|
259
259
|
});
|
|
260
260
|
runner = plugin.load();
|
|
261
261
|
return [
|
|
@@ -266,24 +266,24 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
266
266
|
];
|
|
267
267
|
case 1:
|
|
268
268
|
result = _state.sent();
|
|
269
|
-
expect(result.basePath).toEqual(
|
|
270
|
-
expect(result.queryParams.classicParam).toEqual(
|
|
271
|
-
expect(result.queryParams.sensitiveParam).toEqual(
|
|
272
|
-
expect(result.headers.get(
|
|
269
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
270
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
271
|
+
expect(result.queryParams.sensitiveParam).toEqual('$sensitiveParamToken$');
|
|
272
|
+
expect(result.headers.get('ama-client-facts')).not.toBeNull();
|
|
273
273
|
return [
|
|
274
274
|
2
|
|
275
275
|
];
|
|
276
276
|
}
|
|
277
277
|
});
|
|
278
278
|
}));
|
|
279
|
-
it(
|
|
279
|
+
it('should put token-value associations in custom header if provided', /*#__PURE__*/ _async_to_generator(function() {
|
|
280
280
|
var plugin, runner, result;
|
|
281
281
|
return _ts_generator(this, function(_state) {
|
|
282
282
|
switch(_state.label){
|
|
283
283
|
case 0:
|
|
284
284
|
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
285
|
-
applicationId:
|
|
286
|
-
headerName:
|
|
285
|
+
applicationId: 'app-id',
|
|
286
|
+
headerName: 'custom-header'
|
|
287
287
|
});
|
|
288
288
|
runner = plugin.load();
|
|
289
289
|
return [
|
|
@@ -294,21 +294,21 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
294
294
|
];
|
|
295
295
|
case 1:
|
|
296
296
|
result = _state.sent();
|
|
297
|
-
expect(result.headers.get(
|
|
298
|
-
expect(result.headers.get(
|
|
297
|
+
expect(result.headers.get('ama-client-facts')).toBeNull();
|
|
298
|
+
expect(result.headers.get('custom-header')).not.toBeNull();
|
|
299
299
|
return [
|
|
300
300
|
2
|
|
301
301
|
];
|
|
302
302
|
}
|
|
303
303
|
});
|
|
304
304
|
}));
|
|
305
|
-
it(
|
|
305
|
+
it('should keep default parameters and print an error if tokenization is disabled', /*#__PURE__*/ _async_to_generator(function() {
|
|
306
306
|
var plugin, runner, result;
|
|
307
307
|
return _ts_generator(this, function(_state) {
|
|
308
308
|
switch(_state.label){
|
|
309
309
|
case 0:
|
|
310
310
|
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
311
|
-
applicationId:
|
|
311
|
+
applicationId: 'app-id'
|
|
312
312
|
});
|
|
313
313
|
runner = plugin.load();
|
|
314
314
|
return [
|
|
@@ -317,10 +317,10 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
317
317
|
];
|
|
318
318
|
case 1:
|
|
319
319
|
result = _state.sent();
|
|
320
|
-
expect(result.basePath).toEqual(
|
|
321
|
-
expect(result.queryParams.classicParam).toEqual(
|
|
322
|
-
expect(result.queryParams.sensitiveParam).toEqual(
|
|
323
|
-
expect(result.headers.get(
|
|
320
|
+
expect(result.basePath).toEqual('http://test.com/path/pathParamValue');
|
|
321
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
322
|
+
expect(result.queryParams.sensitiveParam).toEqual('sensitiveParamValue');
|
|
323
|
+
expect(result.headers.get('ama-client-facts')).toBeNull();
|
|
324
324
|
// eslint-disable-next-line no-console
|
|
325
325
|
expect(console.error).toHaveBeenCalled();
|
|
326
326
|
return [
|
|
@@ -329,13 +329,13 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
329
329
|
}
|
|
330
330
|
});
|
|
331
331
|
}));
|
|
332
|
-
it(
|
|
332
|
+
it('should keep default parameters if no token-value associations is provided', /*#__PURE__*/ _async_to_generator(function() {
|
|
333
333
|
var plugin, runner, result;
|
|
334
334
|
return _ts_generator(this, function(_state) {
|
|
335
335
|
switch(_state.label){
|
|
336
336
|
case 0:
|
|
337
337
|
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
338
|
-
applicationId:
|
|
338
|
+
applicationId: 'app-id'
|
|
339
339
|
});
|
|
340
340
|
runner = plugin.load();
|
|
341
341
|
return [
|
|
@@ -348,10 +348,10 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
348
348
|
];
|
|
349
349
|
case 1:
|
|
350
350
|
result = _state.sent();
|
|
351
|
-
expect(result.basePath).toEqual(
|
|
352
|
-
expect(result.queryParams.classicParam).toEqual(
|
|
353
|
-
expect(result.queryParams.sensitiveParam).toEqual(
|
|
354
|
-
expect(result.headers.get(
|
|
351
|
+
expect(result.basePath).toEqual('http://test.com/path/pathParamValue');
|
|
352
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
353
|
+
expect(result.queryParams.sensitiveParam).toEqual('sensitiveParamValue');
|
|
354
|
+
expect(result.headers.get('ama-client-facts')).toBeNull();
|
|
355
355
|
// eslint-disable-next-line no-console
|
|
356
356
|
expect(console.error).not.toHaveBeenCalled();
|
|
357
357
|
return [
|
|
@@ -360,15 +360,15 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
360
360
|
}
|
|
361
361
|
});
|
|
362
362
|
}));
|
|
363
|
-
it(
|
|
363
|
+
it('should use JWT if no key specified', /*#__PURE__*/ _async_to_generator(function() {
|
|
364
364
|
var mockJweEncoder, mockJwtEncoder, plugin, runner;
|
|
365
365
|
return _ts_generator(this, function(_state) {
|
|
366
366
|
switch(_state.label){
|
|
367
367
|
case 0:
|
|
368
|
-
mockJweEncoder = jest.spyOn(_jsontoken,
|
|
369
|
-
mockJwtEncoder = jest.spyOn(_jsontoken,
|
|
368
|
+
mockJweEncoder = jest.spyOn(_jsontoken, 'createJweEncoder');
|
|
369
|
+
mockJwtEncoder = jest.spyOn(_jsontoken, 'createJwtEncoder');
|
|
370
370
|
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
371
|
-
applicationId:
|
|
371
|
+
applicationId: 'app-id'
|
|
372
372
|
});
|
|
373
373
|
runner = plugin.load();
|
|
374
374
|
return [
|
|
@@ -387,25 +387,25 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
389
|
}));
|
|
390
|
-
it(
|
|
390
|
+
it('should use JWE if a key is specified', /*#__PURE__*/ _async_to_generator(function() {
|
|
391
391
|
var key, mockJweEncoder, mockJwtEncoder, plugin, runner, result, expectedJwePayload;
|
|
392
392
|
return _ts_generator(this, function(_state) {
|
|
393
393
|
switch(_state.label){
|
|
394
394
|
case 0:
|
|
395
|
-
jest.spyOn(Date,
|
|
395
|
+
jest.spyOn(Date, 'now').mockImplementation(function() {
|
|
396
396
|
return 0;
|
|
397
397
|
});
|
|
398
398
|
key = {
|
|
399
|
-
publicKey:
|
|
400
|
-
keyId:
|
|
399
|
+
publicKey: 'myPublicKey',
|
|
400
|
+
keyId: 'TEST'
|
|
401
401
|
};
|
|
402
|
-
mockJweEncoder = jest.fn().mockResolvedValue(
|
|
403
|
-
jest.spyOn(_jsontoken,
|
|
402
|
+
mockJweEncoder = jest.fn().mockResolvedValue('myJweToken');
|
|
403
|
+
jest.spyOn(_jsontoken, 'createJweEncoder').mockImplementation(function() {
|
|
404
404
|
return mockJweEncoder;
|
|
405
405
|
});
|
|
406
|
-
mockJwtEncoder = jest.spyOn(_jsontoken,
|
|
406
|
+
mockJwtEncoder = jest.spyOn(_jsontoken, 'createJwtEncoder');
|
|
407
407
|
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
408
|
-
applicationId:
|
|
408
|
+
applicationId: 'app-id',
|
|
409
409
|
key: key
|
|
410
410
|
});
|
|
411
411
|
runner = plugin.load();
|
|
@@ -419,19 +419,19 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
419
419
|
result = _state.sent();
|
|
420
420
|
expectedJwePayload = {
|
|
421
421
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
422
|
-
|
|
423
|
-
$pathParamToken$:
|
|
424
|
-
$sensitiveParamToken$:
|
|
422
|
+
'ama-tokens': {
|
|
423
|
+
$pathParamToken$: 'pathParamValue',
|
|
424
|
+
$sensitiveParamToken$: 'sensitiveParamValue'
|
|
425
425
|
},
|
|
426
426
|
exp: 3600,
|
|
427
427
|
iat: 0,
|
|
428
|
-
iss:
|
|
429
|
-
sub:
|
|
428
|
+
iss: 'app-id',
|
|
429
|
+
sub: 'pii'
|
|
430
430
|
};
|
|
431
|
-
expect(result.headers.get(
|
|
431
|
+
expect(result.headers.get('ama-client-facts')).toEqual('myJweToken');
|
|
432
432
|
expect(mockJweEncoder).toHaveBeenCalledWith(key, expectedJwePayload, [
|
|
433
|
-
|
|
434
|
-
|
|
433
|
+
'iss',
|
|
434
|
+
'sub'
|
|
435
435
|
]);
|
|
436
436
|
expect(mockJwtEncoder).not.toHaveBeenCalled();
|
|
437
437
|
return [
|
|
@@ -440,21 +440,21 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
440
440
|
}
|
|
441
441
|
});
|
|
442
442
|
}));
|
|
443
|
-
it(
|
|
443
|
+
it('should throw by default if an exception is raised for JWE encoder', /*#__PURE__*/ _async_to_generator(function() {
|
|
444
444
|
var key, mockJweEncoder, plugin, runner;
|
|
445
445
|
return _ts_generator(this, function(_state) {
|
|
446
446
|
switch(_state.label){
|
|
447
447
|
case 0:
|
|
448
448
|
key = {
|
|
449
|
-
publicKey:
|
|
450
|
-
keyId:
|
|
449
|
+
publicKey: 'myPublicKey',
|
|
450
|
+
keyId: 'TEST'
|
|
451
451
|
};
|
|
452
|
-
mockJweEncoder = jest.fn().mockRejectedValue(
|
|
453
|
-
jest.spyOn(_jsontoken,
|
|
452
|
+
mockJweEncoder = jest.fn().mockRejectedValue('Error creating JWE');
|
|
453
|
+
jest.spyOn(_jsontoken, 'createJweEncoder').mockImplementation(function() {
|
|
454
454
|
return mockJweEncoder;
|
|
455
455
|
});
|
|
456
456
|
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
457
|
-
applicationId:
|
|
457
|
+
applicationId: 'app-id',
|
|
458
458
|
key: key
|
|
459
459
|
});
|
|
460
460
|
runner = plugin.load();
|
|
@@ -475,21 +475,21 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
475
475
|
}
|
|
476
476
|
});
|
|
477
477
|
}));
|
|
478
|
-
it(
|
|
478
|
+
it('should handle errors silently if an exception is raised for JWE encoder', /*#__PURE__*/ _async_to_generator(function() {
|
|
479
479
|
var key, mockJweEncoder, plugin, runner;
|
|
480
480
|
return _ts_generator(this, function(_state) {
|
|
481
481
|
switch(_state.label){
|
|
482
482
|
case 0:
|
|
483
483
|
key = {
|
|
484
|
-
publicKey:
|
|
485
|
-
keyId:
|
|
484
|
+
publicKey: 'myPublicKey',
|
|
485
|
+
keyId: 'TEST'
|
|
486
486
|
};
|
|
487
|
-
mockJweEncoder = jest.fn().mockRejectedValue(
|
|
488
|
-
jest.spyOn(_jsontoken,
|
|
487
|
+
mockJweEncoder = jest.fn().mockRejectedValue('Error creating JWE');
|
|
488
|
+
jest.spyOn(_jsontoken, 'createJweEncoder').mockImplementation(function() {
|
|
489
489
|
return mockJweEncoder;
|
|
490
490
|
});
|
|
491
491
|
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
492
|
-
applicationId:
|
|
492
|
+
applicationId: 'app-id',
|
|
493
493
|
key: key,
|
|
494
494
|
silent: true
|
|
495
495
|
});
|
|
@@ -511,25 +511,25 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
511
511
|
}
|
|
512
512
|
});
|
|
513
513
|
}));
|
|
514
|
-
it(
|
|
514
|
+
it('should skip PII tokenization and put DeepLink token in corresponding header when DeepLink token is provided', /*#__PURE__*/ _async_to_generator(function() {
|
|
515
515
|
var plugin, runner, deepLinkOptions, metadata, result;
|
|
516
516
|
return _ts_generator(this, function(_state) {
|
|
517
517
|
switch(_state.label){
|
|
518
518
|
case 0:
|
|
519
519
|
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
520
|
-
applicationId:
|
|
520
|
+
applicationId: 'app-id'
|
|
521
521
|
});
|
|
522
522
|
runner = plugin.load();
|
|
523
523
|
deepLinkOptions = {
|
|
524
|
-
token:
|
|
524
|
+
token: 'myDeepLinkToken'
|
|
525
525
|
};
|
|
526
526
|
metadata = {
|
|
527
527
|
deepLinkOptions: deepLinkOptions
|
|
528
528
|
};
|
|
529
|
-
options.basePath =
|
|
529
|
+
options.basePath = 'http://test.com/path/$pathParamToken$';
|
|
530
530
|
options.queryParams = {
|
|
531
|
-
classicParam:
|
|
532
|
-
sensitiveParam:
|
|
531
|
+
classicParam: 'classicParamValue',
|
|
532
|
+
sensitiveParam: '$sensitiveParamToken$'
|
|
533
533
|
};
|
|
534
534
|
return [
|
|
535
535
|
4,
|
|
@@ -542,10 +542,10 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
542
542
|
];
|
|
543
543
|
case 1:
|
|
544
544
|
result = _state.sent();
|
|
545
|
-
expect(result.basePath).toEqual(
|
|
546
|
-
expect(result.queryParams.classicParam).toEqual(
|
|
547
|
-
expect(result.queryParams.sensitiveParam).toEqual(
|
|
548
|
-
expect(result.headers.get(
|
|
545
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
546
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
547
|
+
expect(result.queryParams.sensitiveParam).toEqual('$sensitiveParamToken$');
|
|
548
|
+
expect(result.headers.get('ama-client-facts')).toEqual('myDeepLinkToken');
|
|
549
549
|
// eslint-disable-next-line no-console
|
|
550
550
|
expect(console.error).not.toHaveBeenCalled();
|
|
551
551
|
return [
|
|
@@ -554,28 +554,28 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
554
554
|
}
|
|
555
555
|
});
|
|
556
556
|
}));
|
|
557
|
-
it(
|
|
557
|
+
it('should put DeepLink challenge answers in corresponding header when provided', /*#__PURE__*/ _async_to_generator(function() {
|
|
558
558
|
var plugin, runner, deepLinkOptions, metadata, result;
|
|
559
559
|
return _ts_generator(this, function(_state) {
|
|
560
560
|
switch(_state.label){
|
|
561
561
|
case 0:
|
|
562
562
|
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
563
|
-
applicationId:
|
|
563
|
+
applicationId: 'app-id'
|
|
564
564
|
});
|
|
565
565
|
runner = plugin.load();
|
|
566
566
|
deepLinkOptions = {
|
|
567
|
-
token:
|
|
567
|
+
token: 'myDeepLinkToken',
|
|
568
568
|
challengeAnswers: {
|
|
569
|
-
lastName:
|
|
569
|
+
lastName: 'Doe'
|
|
570
570
|
}
|
|
571
571
|
};
|
|
572
572
|
metadata = {
|
|
573
573
|
deepLinkOptions: deepLinkOptions
|
|
574
574
|
};
|
|
575
|
-
options.basePath =
|
|
575
|
+
options.basePath = 'http://test.com/path/$pathParamToken$';
|
|
576
576
|
options.queryParams = {
|
|
577
|
-
classicParam:
|
|
578
|
-
sensitiveParam:
|
|
577
|
+
classicParam: 'classicParamValue',
|
|
578
|
+
sensitiveParam: '$sensitiveParamToken$'
|
|
579
579
|
};
|
|
580
580
|
return [
|
|
581
581
|
4,
|
|
@@ -588,29 +588,29 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
588
588
|
];
|
|
589
589
|
case 1:
|
|
590
590
|
result = _state.sent();
|
|
591
|
-
expect(result.basePath).toEqual(
|
|
592
|
-
expect(result.queryParams.classicParam).toEqual(
|
|
593
|
-
expect(result.queryParams.sensitiveParam).toEqual(
|
|
594
|
-
expect(result.headers.get(
|
|
595
|
-
expect(result.headers.get(
|
|
591
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
592
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
593
|
+
expect(result.queryParams.sensitiveParam).toEqual('$sensitiveParamToken$');
|
|
594
|
+
expect(result.headers.get('ama-client-facts')).toEqual('myDeepLinkToken');
|
|
595
|
+
expect(result.headers.get('ama-client-facts-challenge')).toEqual('{"lastName":"Doe"}');
|
|
596
596
|
return [
|
|
597
597
|
2
|
|
598
598
|
];
|
|
599
599
|
}
|
|
600
600
|
});
|
|
601
601
|
}));
|
|
602
|
-
it(
|
|
602
|
+
it('Should not loose additional parameters not expected for the actual request', /*#__PURE__*/ _async_to_generator(function() {
|
|
603
603
|
var plugin, runner, result;
|
|
604
604
|
return _ts_generator(this, function(_state) {
|
|
605
605
|
switch(_state.label){
|
|
606
606
|
case 0:
|
|
607
607
|
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
608
|
-
applicationId:
|
|
608
|
+
applicationId: 'app-id'
|
|
609
609
|
});
|
|
610
610
|
runner = plugin.load();
|
|
611
|
-
options.basePath =
|
|
611
|
+
options.basePath = 'http://test.com/path/pathParamValue';
|
|
612
612
|
options.queryParams = _object_spread_props(_object_spread({}, options.queryParams), {
|
|
613
|
-
additionalParam:
|
|
613
|
+
additionalParam: 'foo'
|
|
614
614
|
});
|
|
615
615
|
return [
|
|
616
616
|
4,
|
|
@@ -620,8 +620,8 @@ describe("Tokenizer Request Plugin", function() {
|
|
|
620
620
|
];
|
|
621
621
|
case 1:
|
|
622
622
|
result = _state.sent();
|
|
623
|
-
expect(result.basePath).toEqual(
|
|
624
|
-
expect(result.queryParams.additionalParam).toEqual(
|
|
623
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
624
|
+
expect(result.queryParams.additionalParam).toEqual('foo');
|
|
625
625
|
return [
|
|
626
626
|
2
|
|
627
627
|
];
|
|
@@ -128,9 +128,9 @@ function _ts_generator(thisArg, body) {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
describe(
|
|
131
|
+
describe('Raw response info Reply plugin', function() {
|
|
132
132
|
var reviver = jest.fn();
|
|
133
|
-
it(
|
|
133
|
+
it('should add response object', /*#__PURE__*/ _async_to_generator(function() {
|
|
134
134
|
var plugin, runner, data, newData;
|
|
135
135
|
return _ts_generator(this, function(_state) {
|
|
136
136
|
switch(_state.label){
|
|
@@ -141,7 +141,7 @@ describe("Raw response info Reply plugin", function() {
|
|
|
141
141
|
apiType: _api.ApiTypes.DEFAULT,
|
|
142
142
|
response: {
|
|
143
143
|
headers: new Headers(),
|
|
144
|
-
test:
|
|
144
|
+
test: 'OK'
|
|
145
145
|
}
|
|
146
146
|
});
|
|
147
147
|
data = {};
|
|
@@ -152,14 +152,14 @@ describe("Raw response info Reply plugin", function() {
|
|
|
152
152
|
case 1:
|
|
153
153
|
newData = _state.sent();
|
|
154
154
|
expect(newData.responseInfo).toBeDefined();
|
|
155
|
-
expect(newData.responseInfo.test).toBe(
|
|
155
|
+
expect(newData.responseInfo.test).toBe('OK');
|
|
156
156
|
return [
|
|
157
157
|
2
|
|
158
158
|
];
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
161
|
}));
|
|
162
|
-
it(
|
|
162
|
+
it('should keep original data', /*#__PURE__*/ _async_to_generator(function() {
|
|
163
163
|
var plugin, runner, data, newData;
|
|
164
164
|
return _ts_generator(this, function(_state) {
|
|
165
165
|
switch(_state.label){
|
|
@@ -170,11 +170,11 @@ describe("Raw response info Reply plugin", function() {
|
|
|
170
170
|
apiType: _api.ApiTypes.DEFAULT,
|
|
171
171
|
response: {
|
|
172
172
|
headers: new Headers(),
|
|
173
|
-
test:
|
|
173
|
+
test: 'OK'
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
176
|
data = {
|
|
177
|
-
originalData:
|
|
177
|
+
originalData: 'OK'
|
|
178
178
|
};
|
|
179
179
|
return [
|
|
180
180
|
4,
|
|
@@ -182,22 +182,22 @@ describe("Raw response info Reply plugin", function() {
|
|
|
182
182
|
];
|
|
183
183
|
case 1:
|
|
184
184
|
newData = _state.sent();
|
|
185
|
-
expect(newData.originalData).toBe(
|
|
185
|
+
expect(newData.originalData).toBe('OK');
|
|
186
186
|
return [
|
|
187
187
|
2
|
|
188
188
|
];
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
191
|
}));
|
|
192
|
-
it(
|
|
192
|
+
it('should invalidate response info', function() {
|
|
193
193
|
var data = {
|
|
194
|
-
originalData:
|
|
194
|
+
originalData: 'OK'
|
|
195
195
|
};
|
|
196
196
|
expect(_rawresponseinforeply.RawResponseInfoReply.hasResponseInfo(data)).toBeFalsy();
|
|
197
197
|
});
|
|
198
|
-
it(
|
|
198
|
+
it('should validate response info', function() {
|
|
199
199
|
var data = {
|
|
200
|
-
originalData:
|
|
200
|
+
originalData: 'OK',
|
|
201
201
|
responseInfo: {
|
|
202
202
|
headers: new Headers()
|
|
203
203
|
}
|