@ama-sdk/core 10.3.0-prerelease.9 → 11.0.0-next.1
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
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* @param pathObjects the list of available path objects
|
|
19
19
|
* @param method the optional HTTP method used in case of several matches
|
|
20
20
|
*/ export function getPath(requestUrl, pathObjects, method) {
|
|
21
|
-
var pathName = new URL(requestUrl, requestUrl.startsWith(
|
|
21
|
+
var pathName = new URL(requestUrl, requestUrl.startsWith('/') ? 'http://example.com' : undefined).pathname;
|
|
22
22
|
if (!pathName) {
|
|
23
23
|
throw new Error("Couldn't parse url ".concat(requestUrl));
|
|
24
24
|
}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
if (pathObject.regexp.test(pathName)) {
|
|
28
28
|
newMatches.push({
|
|
29
29
|
index: index,
|
|
30
|
-
segments: pathObject.path.split(
|
|
30
|
+
segments: pathObject.path.split('/'),
|
|
31
31
|
methods: pathObject.operations.map(function(operation) {
|
|
32
32
|
return operation.method;
|
|
33
33
|
})
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
while(matches.length > 1){
|
|
41
41
|
matches = matches.reduce(function(newMatches, match) {
|
|
42
42
|
var newIndex = match.segments.findIndex(function(segment) {
|
|
43
|
-
return segment.startsWith(
|
|
43
|
+
return segment.startsWith('{') && segment.endsWith('}');
|
|
44
44
|
}, lastIndex + 1);
|
|
45
45
|
// Complete static match so use some value that can't be exceeded
|
|
46
46
|
if (newIndex === -1) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
1
|
+
export * from './alf-mock-adapter';
|
|
2
|
+
export * from './encoded-api-request';
|
|
3
|
+
export * from './mock-adapter';
|
|
4
|
+
export * from './mock';
|
|
5
|
+
export * from './operation';
|
|
6
|
+
export * from './path-object';
|
|
7
|
+
export * from './base-mock-adapter';
|
|
8
|
+
export * from './helpers';
|
|
9
|
+
export * from './random-mock-adapter';
|
|
10
|
+
export * from './sequential-mock-adapter';
|
|
@@ -96,7 +96,7 @@ function _create_super(Derived) {
|
|
|
96
96
|
return _possible_constructor_return(this, result);
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
import { BaseMockAdapter } from
|
|
99
|
+
import { BaseMockAdapter } from './base-mock-adapter';
|
|
100
100
|
/**
|
|
101
101
|
* Mock adapter that, for each operation, runs through the list of mocks randomly
|
|
102
102
|
*/ export var RandomMockAdapter = /*#__PURE__*/ function(BaseMockAdapter) {
|
|
@@ -96,7 +96,7 @@ function _create_super(Derived) {
|
|
|
96
96
|
return _possible_constructor_return(this, result);
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
import { BaseMockAdapter } from
|
|
99
|
+
import { BaseMockAdapter } from './base-mock-adapter';
|
|
100
100
|
/**
|
|
101
101
|
* Mock adapter that, for each operation, runs through the list of mocks sequentially.
|
|
102
102
|
* Once reaching the end of the list, the counter resets to the beginning.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { reviveArray, reviveDictionarizedArray, reviveMap } from
|
|
2
|
-
describe(
|
|
3
|
-
it(
|
|
1
|
+
import { reviveArray, reviveDictionarizedArray, reviveMap } from './Reviver';
|
|
2
|
+
describe('Revivers :', function() {
|
|
3
|
+
it('reviveDictionarizedArray', function() {
|
|
4
4
|
var dictionary = {
|
|
5
5
|
id1: {
|
|
6
|
-
p1:
|
|
6
|
+
p1: 'v1'
|
|
7
7
|
},
|
|
8
8
|
id2: {
|
|
9
|
-
p2:
|
|
9
|
+
p2: 'v2'
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
12
|
expect(reviveDictionarizedArray(undefined, {}, function(data) {
|
|
@@ -16,8 +16,8 @@ describe("Revivers :", function() {
|
|
|
16
16
|
return data;
|
|
17
17
|
})).toEqual({});
|
|
18
18
|
expect(reviveDictionarizedArray([
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
'id1',
|
|
20
|
+
'id2'
|
|
21
21
|
], {}, function(data) {
|
|
22
22
|
return data;
|
|
23
23
|
})).toEqual({
|
|
@@ -28,19 +28,19 @@ describe("Revivers :", function() {
|
|
|
28
28
|
return data;
|
|
29
29
|
})).toEqual({});
|
|
30
30
|
var result = reviveDictionarizedArray([
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
'id1',
|
|
32
|
+
'id2'
|
|
33
33
|
], dictionary, function(data) {
|
|
34
34
|
return data;
|
|
35
35
|
});
|
|
36
36
|
expect(result.id1).toEqual({
|
|
37
|
-
p1:
|
|
37
|
+
p1: 'v1'
|
|
38
38
|
});
|
|
39
39
|
expect(result.id2).toEqual({
|
|
40
|
-
p2:
|
|
40
|
+
p2: 'v2'
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
|
-
it(
|
|
43
|
+
it('should reviveArray propagate the options', function() {
|
|
44
44
|
var reviver = jest.fn();
|
|
45
45
|
var options = {
|
|
46
46
|
logger: jest.fn()
|
|
@@ -50,30 +50,30 @@ describe("Revivers :", function() {
|
|
|
50
50
|
], null, reviver, options);
|
|
51
51
|
expect(reviver).toHaveBeenCalledWith(1, null, options);
|
|
52
52
|
});
|
|
53
|
-
it(
|
|
53
|
+
it('should reviveDictionarizedArray propagate the options', function() {
|
|
54
54
|
var reviver = jest.fn();
|
|
55
55
|
var options = {
|
|
56
56
|
logger: jest.fn()
|
|
57
57
|
};
|
|
58
58
|
var dictionary = {
|
|
59
|
-
key:
|
|
59
|
+
key: 'test'
|
|
60
60
|
};
|
|
61
61
|
reviveDictionarizedArray([
|
|
62
|
-
|
|
62
|
+
'key'
|
|
63
63
|
], dictionary, reviver, options);
|
|
64
|
-
expect(reviver).toHaveBeenCalledWith(
|
|
64
|
+
expect(reviver).toHaveBeenCalledWith('test', dictionary, options);
|
|
65
65
|
});
|
|
66
|
-
it(
|
|
66
|
+
it('should reviveMap propagate the options', function() {
|
|
67
67
|
var reviver = jest.fn();
|
|
68
68
|
var options = {
|
|
69
69
|
logger: jest.fn()
|
|
70
70
|
};
|
|
71
71
|
var dictionary = {
|
|
72
|
-
key:
|
|
72
|
+
key: 'test'
|
|
73
73
|
};
|
|
74
74
|
reviveMap([
|
|
75
|
-
|
|
75
|
+
'key'
|
|
76
76
|
], dictionary, reviver, options);
|
|
77
|
-
expect(reviver).toHaveBeenCalledWith(
|
|
77
|
+
expect(reviver).toHaveBeenCalledWith('key', dictionary, options);
|
|
78
78
|
});
|
|
79
79
|
});
|
|
@@ -45,7 +45,7 @@ function _object_spread(target) {
|
|
|
45
45
|
}
|
|
46
46
|
return target;
|
|
47
47
|
}
|
|
48
|
-
import { isStringOrUndefined } from
|
|
48
|
+
import { isStringOrUndefined } from './additional-params.request';
|
|
49
49
|
/**
|
|
50
50
|
* Plugin to add (or change) the request parameters
|
|
51
51
|
*/ export var AdditionalParamsSyncRequest = /*#__PURE__*/ function() {
|
|
@@ -62,8 +62,8 @@ import { isStringOrUndefined } from "./additional-params.request";
|
|
|
62
62
|
var _this = this;
|
|
63
63
|
return {
|
|
64
64
|
transform: function(data) {
|
|
65
|
-
var queryParams = typeof _this.additionalParams.queryParams ===
|
|
66
|
-
var headers = typeof _this.additionalParams.headers ===
|
|
65
|
+
var queryParams = typeof _this.additionalParams.queryParams === 'function' ? _this.additionalParams.queryParams(data.queryParams) : _this.additionalParams.queryParams;
|
|
66
|
+
var headers = typeof _this.additionalParams.headers === 'function' ? _this.additionalParams.headers(data.headers) : _this.additionalParams.headers;
|
|
67
67
|
var body = _this.additionalParams.body && isStringOrUndefined(data.body) ? _this.additionalParams.body(data.body) : undefined;
|
|
68
68
|
if (queryParams) {
|
|
69
69
|
data.queryParams = _object_spread({}, data.queryParams, queryParams);
|
|
@@ -179,7 +179,7 @@ function _ts_generator(thisArg, body) {
|
|
|
179
179
|
* @param value
|
|
180
180
|
*/ export function isStringOrUndefined(value) {
|
|
181
181
|
var type = typeof value === "undefined" ? "undefined" : _type_of(value);
|
|
182
|
-
return type ===
|
|
182
|
+
return type === 'undefined' || type === 'string';
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
185
|
* Plugin to add (or change) the request parameters
|
|
@@ -202,7 +202,7 @@ function _ts_generator(thisArg, body) {
|
|
|
202
202
|
return _ts_generator(this, function(_state) {
|
|
203
203
|
switch(_state.label){
|
|
204
204
|
case 0:
|
|
205
|
-
if (!(typeof _this.additionalParams.queryParams ===
|
|
205
|
+
if (!(typeof _this.additionalParams.queryParams === 'function')) return [
|
|
206
206
|
3,
|
|
207
207
|
2
|
|
208
208
|
];
|
|
@@ -221,7 +221,7 @@ function _ts_generator(thisArg, body) {
|
|
|
221
221
|
_state.label = 3;
|
|
222
222
|
case 3:
|
|
223
223
|
queryParams = _tmp;
|
|
224
|
-
if (!(typeof _this.additionalParams.headers ===
|
|
224
|
+
if (!(typeof _this.additionalParams.headers === 'function')) return [
|
|
225
225
|
3,
|
|
226
226
|
5
|
|
227
227
|
];
|
|
@@ -122,35 +122,35 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { AdditionalParamsSyncRequest } from
|
|
126
|
-
import { AdditionalParamsRequest } from
|
|
127
|
-
describe(
|
|
125
|
+
import { AdditionalParamsSyncRequest } from './additional-params-sync.request';
|
|
126
|
+
import { AdditionalParamsRequest } from './additional-params.request';
|
|
127
|
+
describe('Additional Params Request Plugin', function() {
|
|
128
128
|
var additionalGetParams = jest.fn().mockReturnValue({
|
|
129
|
-
test:
|
|
129
|
+
test: 'ok'
|
|
130
130
|
});
|
|
131
|
-
var additionalBody = jest.fn().mockReturnValue(
|
|
131
|
+
var additionalBody = jest.fn().mockReturnValue('newBody');
|
|
132
132
|
var defaultGetParams = {
|
|
133
|
-
defaultTest:
|
|
133
|
+
defaultTest: 'ok'
|
|
134
134
|
};
|
|
135
|
-
var defaultBody =
|
|
135
|
+
var defaultBody = 'default';
|
|
136
136
|
var options;
|
|
137
137
|
beforeEach(function() {
|
|
138
138
|
options = {
|
|
139
|
-
method:
|
|
139
|
+
method: 'get',
|
|
140
140
|
queryParams: defaultGetParams,
|
|
141
141
|
headers: new Headers(),
|
|
142
142
|
body: defaultBody,
|
|
143
|
-
basePath:
|
|
143
|
+
basePath: 'http://test.com/truc'
|
|
144
144
|
};
|
|
145
145
|
});
|
|
146
|
-
it(
|
|
146
|
+
it('should add a specified query param', /*#__PURE__*/ _async_to_generator(function() {
|
|
147
147
|
var plugin, runner, result;
|
|
148
148
|
return _ts_generator(this, function(_state) {
|
|
149
149
|
switch(_state.label){
|
|
150
150
|
case 0:
|
|
151
151
|
plugin = new AdditionalParamsRequest({
|
|
152
152
|
queryParams: {
|
|
153
|
-
test:
|
|
153
|
+
test: 'ok'
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
runner = plugin.load();
|
|
@@ -160,14 +160,14 @@ describe("Additional Params Request Plugin", function() {
|
|
|
160
160
|
];
|
|
161
161
|
case 1:
|
|
162
162
|
result = _state.sent();
|
|
163
|
-
expect(result.queryParams.test).toBe(
|
|
163
|
+
expect(result.queryParams.test).toBe('ok');
|
|
164
164
|
return [
|
|
165
165
|
2
|
|
166
166
|
];
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
169
|
}));
|
|
170
|
-
it(
|
|
170
|
+
it('should add the query params returned by a function', /*#__PURE__*/ _async_to_generator(function() {
|
|
171
171
|
var plugin, runner, result;
|
|
172
172
|
return _ts_generator(this, function(_state) {
|
|
173
173
|
switch(_state.label){
|
|
@@ -183,14 +183,14 @@ describe("Additional Params Request Plugin", function() {
|
|
|
183
183
|
case 1:
|
|
184
184
|
result = _state.sent();
|
|
185
185
|
expect(additionalGetParams).toHaveBeenCalledWith(defaultGetParams);
|
|
186
|
-
expect(result.queryParams.test).toBe(
|
|
186
|
+
expect(result.queryParams.test).toBe('ok');
|
|
187
187
|
return [
|
|
188
188
|
2
|
|
189
189
|
];
|
|
190
190
|
}
|
|
191
191
|
});
|
|
192
192
|
}));
|
|
193
|
-
it(
|
|
193
|
+
it('should modify body', /*#__PURE__*/ _async_to_generator(function() {
|
|
194
194
|
var plugin, runner, result;
|
|
195
195
|
return _ts_generator(this, function(_state) {
|
|
196
196
|
switch(_state.label){
|
|
@@ -206,9 +206,9 @@ describe("Additional Params Request Plugin", function() {
|
|
|
206
206
|
case 1:
|
|
207
207
|
result = _state.sent();
|
|
208
208
|
expect(result.queryParams.test).toBeUndefined();
|
|
209
|
-
expect(result.queryParams.defaultTest).toBe(
|
|
209
|
+
expect(result.queryParams.defaultTest).toBe('ok');
|
|
210
210
|
expect(additionalBody).toHaveBeenCalledWith(defaultBody);
|
|
211
|
-
expect(result.body).toBe(
|
|
211
|
+
expect(result.body).toBe('newBody');
|
|
212
212
|
return [
|
|
213
213
|
2
|
|
214
214
|
];
|
|
@@ -216,53 +216,53 @@ describe("Additional Params Request Plugin", function() {
|
|
|
216
216
|
});
|
|
217
217
|
}));
|
|
218
218
|
});
|
|
219
|
-
describe(
|
|
219
|
+
describe('Additional Params Request Sync Plugin', function() {
|
|
220
220
|
var additionalGetParams = jest.fn().mockReturnValue({
|
|
221
|
-
test:
|
|
221
|
+
test: 'ok'
|
|
222
222
|
});
|
|
223
|
-
var additionalBody = jest.fn().mockReturnValue(
|
|
223
|
+
var additionalBody = jest.fn().mockReturnValue('newBody');
|
|
224
224
|
var defaultGetParams = {
|
|
225
|
-
defaultTest:
|
|
225
|
+
defaultTest: 'ok'
|
|
226
226
|
};
|
|
227
|
-
var defaultBody =
|
|
227
|
+
var defaultBody = 'default';
|
|
228
228
|
var options;
|
|
229
229
|
beforeEach(function() {
|
|
230
230
|
options = {
|
|
231
|
-
method:
|
|
231
|
+
method: 'get',
|
|
232
232
|
queryParams: defaultGetParams,
|
|
233
233
|
headers: new Headers(),
|
|
234
234
|
body: defaultBody,
|
|
235
|
-
basePath:
|
|
235
|
+
basePath: 'http://test.com/truc'
|
|
236
236
|
};
|
|
237
237
|
});
|
|
238
|
-
it(
|
|
238
|
+
it('should add a specified query param', function() {
|
|
239
239
|
var plugin = new AdditionalParamsSyncRequest({
|
|
240
240
|
queryParams: {
|
|
241
|
-
test:
|
|
241
|
+
test: 'ok'
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
244
|
var runner = plugin.load();
|
|
245
245
|
var result = runner.transform(options);
|
|
246
|
-
expect(result.queryParams.test).toBe(
|
|
246
|
+
expect(result.queryParams.test).toBe('ok');
|
|
247
247
|
});
|
|
248
|
-
it(
|
|
248
|
+
it('should add the query params returned by a function', function() {
|
|
249
249
|
var plugin = new AdditionalParamsSyncRequest({
|
|
250
250
|
queryParams: additionalGetParams
|
|
251
251
|
});
|
|
252
252
|
var runner = plugin.load();
|
|
253
253
|
var result = runner.transform(options);
|
|
254
254
|
expect(additionalGetParams).toHaveBeenCalledWith(defaultGetParams);
|
|
255
|
-
expect(result.queryParams.test).toBe(
|
|
255
|
+
expect(result.queryParams.test).toBe('ok');
|
|
256
256
|
});
|
|
257
|
-
it(
|
|
257
|
+
it('should modify body', function() {
|
|
258
258
|
var plugin = new AdditionalParamsSyncRequest({
|
|
259
259
|
body: additionalBody
|
|
260
260
|
});
|
|
261
261
|
var runner = plugin.load();
|
|
262
262
|
var result = runner.transform(options);
|
|
263
263
|
expect(result.queryParams.test).toBeUndefined();
|
|
264
|
-
expect(result.queryParams.defaultTest).toBe(
|
|
264
|
+
expect(result.queryParams.defaultTest).toBe('ok');
|
|
265
265
|
expect(additionalBody).toHaveBeenCalledWith(defaultBody);
|
|
266
|
-
expect(result.body).toBe(
|
|
266
|
+
expect(result.body).toBe('newBody');
|
|
267
267
|
});
|
|
268
268
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './additional-params.request';
|
|
2
|
+
export * from './additional-params-sync.request';
|
|
@@ -161,7 +161,7 @@ function _ts_generator(thisArg, body) {
|
|
|
161
161
|
*/ export var ApiConfigurationOverride = /*#__PURE__*/ function() {
|
|
162
162
|
"use strict";
|
|
163
163
|
function ApiConfigurationOverride(jws) {
|
|
164
|
-
var headerName = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
164
|
+
var headerName = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'ama-client-facts';
|
|
165
165
|
_class_call_check(this, ApiConfigurationOverride);
|
|
166
166
|
_define_property(this, "jws", void 0);
|
|
167
167
|
_define_property(this, "headerName", void 0);
|
|
@@ -182,7 +182,7 @@ function _ts_generator(thisArg, body) {
|
|
|
182
182
|
case 0:
|
|
183
183
|
return [
|
|
184
184
|
4,
|
|
185
|
-
typeof _this.jws ===
|
|
185
|
+
typeof _this.jws === 'function' ? _this.jws() : _this.jws
|
|
186
186
|
];
|
|
187
187
|
case 1:
|
|
188
188
|
jws = _state.sent();
|
|
@@ -140,8 +140,8 @@ function _ts_generator(thisArg, body) {
|
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
import { ApiConfigurationOverride } from
|
|
144
|
-
describe(
|
|
143
|
+
import { ApiConfigurationOverride } from './api-configuration-override.request';
|
|
144
|
+
describe('ApiConfigurationOverride Plugin', function() {
|
|
145
145
|
var options;
|
|
146
146
|
var FakeHeader = function FakeHeader() {
|
|
147
147
|
"use strict";
|
|
@@ -160,17 +160,17 @@ describe("ApiConfigurationOverride Plugin", function() {
|
|
|
160
160
|
};
|
|
161
161
|
beforeEach(function() {
|
|
162
162
|
options = {
|
|
163
|
-
method:
|
|
163
|
+
method: 'get',
|
|
164
164
|
headers: new FakeHeader(),
|
|
165
|
-
basePath:
|
|
165
|
+
basePath: 'http://test.com/api'
|
|
166
166
|
};
|
|
167
167
|
});
|
|
168
|
-
it(
|
|
168
|
+
it('should add a specified string JWS', /*#__PURE__*/ _async_to_generator(function() {
|
|
169
169
|
var plugin, runner, result;
|
|
170
170
|
return _ts_generator(this, function(_state) {
|
|
171
171
|
switch(_state.label){
|
|
172
172
|
case 0:
|
|
173
|
-
plugin = new ApiConfigurationOverride(
|
|
173
|
+
plugin = new ApiConfigurationOverride('fakeJWS');
|
|
174
174
|
runner = plugin.load();
|
|
175
175
|
return [
|
|
176
176
|
4,
|
|
@@ -178,19 +178,19 @@ describe("ApiConfigurationOverride Plugin", function() {
|
|
|
178
178
|
];
|
|
179
179
|
case 1:
|
|
180
180
|
result = _state.sent();
|
|
181
|
-
expect(result.headers.get(
|
|
181
|
+
expect(result.headers.get('ama-client-facts')).toBe('fakeJWS');
|
|
182
182
|
return [
|
|
183
183
|
2
|
|
184
184
|
];
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
187
|
}));
|
|
188
|
-
it(
|
|
188
|
+
it('should add a specified string JWS with a custom header name', /*#__PURE__*/ _async_to_generator(function() {
|
|
189
189
|
var plugin, runner, result;
|
|
190
190
|
return _ts_generator(this, function(_state) {
|
|
191
191
|
switch(_state.label){
|
|
192
192
|
case 0:
|
|
193
|
-
plugin = new ApiConfigurationOverride(
|
|
193
|
+
plugin = new ApiConfigurationOverride('fakeJWS', 'my-header');
|
|
194
194
|
runner = plugin.load();
|
|
195
195
|
return [
|
|
196
196
|
4,
|
|
@@ -198,21 +198,21 @@ describe("ApiConfigurationOverride Plugin", function() {
|
|
|
198
198
|
];
|
|
199
199
|
case 1:
|
|
200
200
|
result = _state.sent();
|
|
201
|
-
expect(result.headers.get(
|
|
201
|
+
expect(result.headers.get('my-header')).toBe('fakeJWS');
|
|
202
202
|
return [
|
|
203
203
|
2
|
|
204
204
|
];
|
|
205
205
|
}
|
|
206
206
|
});
|
|
207
207
|
}));
|
|
208
|
-
it(
|
|
208
|
+
it('should add a specified dynamic JWS', /*#__PURE__*/ _async_to_generator(function() {
|
|
209
209
|
var counter, dynamicJws, plugin, runner, result;
|
|
210
210
|
return _ts_generator(this, function(_state) {
|
|
211
211
|
switch(_state.label){
|
|
212
212
|
case 0:
|
|
213
213
|
counter = 0;
|
|
214
214
|
dynamicJws = function() {
|
|
215
|
-
return Promise.resolve(
|
|
215
|
+
return Promise.resolve('dynamicJWS' + counter.toString());
|
|
216
216
|
};
|
|
217
217
|
plugin = new ApiConfigurationOverride(dynamicJws);
|
|
218
218
|
runner = plugin.load();
|
|
@@ -222,7 +222,7 @@ describe("ApiConfigurationOverride Plugin", function() {
|
|
|
222
222
|
];
|
|
223
223
|
case 1:
|
|
224
224
|
result = _state.sent();
|
|
225
|
-
expect(result.headers.get(
|
|
225
|
+
expect(result.headers.get('ama-client-facts')).toBe('dynamicJWS0');
|
|
226
226
|
counter++;
|
|
227
227
|
runner = plugin.load();
|
|
228
228
|
return [
|
|
@@ -231,7 +231,7 @@ describe("ApiConfigurationOverride Plugin", function() {
|
|
|
231
231
|
];
|
|
232
232
|
case 2:
|
|
233
233
|
result = _state.sent();
|
|
234
|
-
expect(result.headers.get(
|
|
234
|
+
expect(result.headers.get('ama-client-facts')).toContain('dynamicJWS1');
|
|
235
235
|
return [
|
|
236
236
|
2
|
|
237
237
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './api-configuration-override.request';
|
|
@@ -159,7 +159,7 @@ function _ts_generator(thisArg, body) {
|
|
|
159
159
|
*/ export var ApiKeyRequest = /*#__PURE__*/ function() {
|
|
160
160
|
"use strict";
|
|
161
161
|
function ApiKeyRequest(apiKey) {
|
|
162
|
-
var apiKeyHeader = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
162
|
+
var apiKeyHeader = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'apiKey';
|
|
163
163
|
_class_call_check(this, ApiKeyRequest);
|
|
164
164
|
_define_property(this, "apiKey", void 0);
|
|
165
165
|
_define_property(this, "apiKeyHeader", void 0);
|
|
@@ -178,7 +178,7 @@ function _ts_generator(thisArg, body) {
|
|
|
178
178
|
return _ts_generator(this, function(_state) {
|
|
179
179
|
switch(_state.label){
|
|
180
180
|
case 0:
|
|
181
|
-
if (!(typeof _this.apiKey ===
|
|
181
|
+
if (!(typeof _this.apiKey === 'string')) return [
|
|
182
182
|
3,
|
|
183
183
|
1
|
|
184
184
|
];
|
|
@@ -122,24 +122,24 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { ApiKeyRequest } from
|
|
126
|
-
describe(
|
|
125
|
+
import { ApiKeyRequest } from './api-key.request';
|
|
126
|
+
describe('Api Key Request Plugin', function() {
|
|
127
127
|
var options;
|
|
128
128
|
beforeEach(function() {
|
|
129
129
|
var headers = new Headers();
|
|
130
|
-
jest.spyOn(headers,
|
|
130
|
+
jest.spyOn(headers, 'append');
|
|
131
131
|
options = {
|
|
132
132
|
headers: headers,
|
|
133
|
-
basePath:
|
|
134
|
-
method:
|
|
133
|
+
basePath: 'http://test.com/truc',
|
|
134
|
+
method: 'get'
|
|
135
135
|
};
|
|
136
136
|
});
|
|
137
|
-
it(
|
|
137
|
+
it('should add the API Key to the headers', /*#__PURE__*/ _async_to_generator(function() {
|
|
138
138
|
var plugin, runner;
|
|
139
139
|
return _ts_generator(this, function(_state) {
|
|
140
140
|
switch(_state.label){
|
|
141
141
|
case 0:
|
|
142
|
-
plugin = new ApiKeyRequest(
|
|
142
|
+
plugin = new ApiKeyRequest('test', 'testKey');
|
|
143
143
|
runner = plugin.load();
|
|
144
144
|
return [
|
|
145
145
|
4,
|
|
@@ -147,21 +147,21 @@ describe("Api Key Request Plugin", function() {
|
|
|
147
147
|
];
|
|
148
148
|
case 1:
|
|
149
149
|
_state.sent();
|
|
150
|
-
expect(options.headers.append).toHaveBeenCalledWith(
|
|
150
|
+
expect(options.headers.append).toHaveBeenCalledWith('testKey', 'test');
|
|
151
151
|
return [
|
|
152
152
|
2
|
|
153
153
|
];
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
}));
|
|
157
|
-
it(
|
|
157
|
+
it('should execute the function to add the API Key to the headers', /*#__PURE__*/ _async_to_generator(function() {
|
|
158
158
|
var plugin, runner;
|
|
159
159
|
return _ts_generator(this, function(_state) {
|
|
160
160
|
switch(_state.label){
|
|
161
161
|
case 0:
|
|
162
162
|
plugin = new ApiKeyRequest(function() {
|
|
163
|
-
return Promise.resolve(
|
|
164
|
-
},
|
|
163
|
+
return Promise.resolve('test');
|
|
164
|
+
}, 'testKey');
|
|
165
165
|
runner = plugin.load();
|
|
166
166
|
return [
|
|
167
167
|
4,
|
|
@@ -169,7 +169,7 @@ describe("Api Key Request Plugin", function() {
|
|
|
169
169
|
];
|
|
170
170
|
case 1:
|
|
171
171
|
_state.sent();
|
|
172
|
-
expect(options.headers.append).toHaveBeenCalledWith(
|
|
172
|
+
expect(options.headers.append).toHaveBeenCalledWith('testKey', 'test');
|
|
173
173
|
return [
|
|
174
174
|
2
|
|
175
175
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './api-key.request';
|
|
@@ -162,8 +162,8 @@ function _ts_generator(thisArg, body) {
|
|
|
162
162
|
* @param tokenTimeout How long the ABP script will wait for a new token before rejecting the promise
|
|
163
163
|
*/ export function impervaProtectionRetrieverFactory(protectionTimeout, tokenTimeout) {
|
|
164
164
|
var protection;
|
|
165
|
-
if (typeof window ===
|
|
166
|
-
throw new Error(
|
|
165
|
+
if (typeof window === 'undefined') {
|
|
166
|
+
throw new Error('impervaProtectionRetrieverFactory should be used in a browser context.');
|
|
167
167
|
}
|
|
168
168
|
var getProtection = function() {
|
|
169
169
|
return new Promise(function(resolve, reject) {
|
|
@@ -229,7 +229,7 @@ function _ts_generator(thisArg, body) {
|
|
|
229
229
|
];
|
|
230
230
|
case 6:
|
|
231
231
|
e1 = _state.sent();
|
|
232
|
-
(logger || console).error(
|
|
232
|
+
(logger || console).error('[SDK][Plug-in][BotProtectionFingerprintRequest] Timeout: no Token was received in time.');
|
|
233
233
|
return [
|
|
234
234
|
2
|
|
235
235
|
];
|
|
@@ -250,9 +250,9 @@ function _ts_generator(thisArg, body) {
|
|
|
250
250
|
* Will return the telemetry, or undefined if bmak object is not found
|
|
251
251
|
* @param bmakOpt BMak object from Akamai. Default to `window.bmak` on browser if not provided.
|
|
252
252
|
*/ export function akamaiTelemetryRetrieverFactory(bmakOpt) {
|
|
253
|
-
var bmak = bmakOpt || (typeof window !==
|
|
253
|
+
var bmak = bmakOpt || (typeof window !== 'undefined' ? window.bmak : undefined);
|
|
254
254
|
return function() {
|
|
255
|
-
if (!bmak || !(typeof bmak.get_telemetry ===
|
|
255
|
+
if (!bmak || !(typeof bmak.get_telemetry === 'function')) {
|
|
256
256
|
return;
|
|
257
257
|
}
|
|
258
258
|
return bmak.get_telemetry();
|