@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
|
@@ -26,16 +26,16 @@ function _object_spread(target) {
|
|
|
26
26
|
}
|
|
27
27
|
return target;
|
|
28
28
|
}
|
|
29
|
-
import { ApiTypes } from
|
|
30
|
-
import { EmptyResponseError, RequestFailedError } from
|
|
31
|
-
import { ExceptionReply } from
|
|
32
|
-
describe(
|
|
29
|
+
import { ApiTypes } from '../../fwk/api';
|
|
30
|
+
import { EmptyResponseError, RequestFailedError } from '../../fwk/errors';
|
|
31
|
+
import { ExceptionReply } from './exception.reply';
|
|
32
|
+
describe('Exception Reply Plugin', function() {
|
|
33
33
|
var reviver = jest.fn();
|
|
34
34
|
var contextError = {
|
|
35
|
-
apiName:
|
|
36
|
-
operationId:
|
|
35
|
+
apiName: 'api',
|
|
36
|
+
operationId: 'ope'
|
|
37
37
|
};
|
|
38
|
-
it(
|
|
38
|
+
it('should throw on empty data and contains errors key if DAPI', function() {
|
|
39
39
|
var plugin = new ExceptionReply();
|
|
40
40
|
var runner = plugin.load(_object_spread({
|
|
41
41
|
reviver: reviver,
|
|
@@ -43,7 +43,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
43
43
|
response: {
|
|
44
44
|
ok: true,
|
|
45
45
|
status: 200,
|
|
46
|
-
statusText:
|
|
46
|
+
statusText: 'test'
|
|
47
47
|
}
|
|
48
48
|
}, contextError));
|
|
49
49
|
var data = {
|
|
@@ -51,9 +51,9 @@ describe("Exception Reply Plugin", function() {
|
|
|
51
51
|
};
|
|
52
52
|
expect(function() {
|
|
53
53
|
return runner.transform(data);
|
|
54
|
-
}).toThrow(new EmptyResponseError(
|
|
54
|
+
}).toThrow(new EmptyResponseError('test', data, contextError));
|
|
55
55
|
});
|
|
56
|
-
it(
|
|
56
|
+
it('should not throw on empty data and no errors key if DAPI', function() {
|
|
57
57
|
var plugin = new ExceptionReply();
|
|
58
58
|
var runner = plugin.load({
|
|
59
59
|
reviver: reviver,
|
|
@@ -61,7 +61,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
61
61
|
response: {
|
|
62
62
|
ok: true,
|
|
63
63
|
status: 200,
|
|
64
|
-
statusText:
|
|
64
|
+
statusText: 'test'
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
var data = {};
|
|
@@ -69,7 +69,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
69
69
|
return runner.transform(data);
|
|
70
70
|
}).not.toThrow();
|
|
71
71
|
});
|
|
72
|
-
it(
|
|
72
|
+
it('should not throw on empty data if not DAPI', function() {
|
|
73
73
|
var plugin = new ExceptionReply();
|
|
74
74
|
var runner = plugin.load({
|
|
75
75
|
reviver: reviver,
|
|
@@ -77,7 +77,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
77
77
|
response: {
|
|
78
78
|
ok: true,
|
|
79
79
|
status: 200,
|
|
80
|
-
statusText:
|
|
80
|
+
statusText: 'test'
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
var data = {};
|
|
@@ -85,7 +85,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
85
85
|
return runner.transform(data);
|
|
86
86
|
}).not.toThrow();
|
|
87
87
|
});
|
|
88
|
-
it(
|
|
88
|
+
it('should throw on nok status', function() {
|
|
89
89
|
var plugin = new ExceptionReply();
|
|
90
90
|
var runner = plugin.load(_object_spread({
|
|
91
91
|
reviver: reviver,
|
|
@@ -93,7 +93,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
93
93
|
response: {
|
|
94
94
|
ok: false,
|
|
95
95
|
status: 444,
|
|
96
|
-
statusText:
|
|
96
|
+
statusText: 'test'
|
|
97
97
|
}
|
|
98
98
|
}, contextError));
|
|
99
99
|
var data = {
|
|
@@ -101,9 +101,9 @@ describe("Exception Reply Plugin", function() {
|
|
|
101
101
|
};
|
|
102
102
|
expect(function() {
|
|
103
103
|
return runner.transform(data);
|
|
104
|
-
}).toThrow(new RequestFailedError(
|
|
104
|
+
}).toThrow(new RequestFailedError('test', 444, data, contextError));
|
|
105
105
|
});
|
|
106
|
-
it(
|
|
106
|
+
it('should not throw if there is already an exception', function() {
|
|
107
107
|
var plugin = new ExceptionReply();
|
|
108
108
|
var runner = plugin.load({
|
|
109
109
|
reviver: reviver,
|
|
@@ -111,7 +111,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
111
111
|
response: {
|
|
112
112
|
ok: false,
|
|
113
113
|
status: 444,
|
|
114
|
-
statusText:
|
|
114
|
+
statusText: 'test'
|
|
115
115
|
},
|
|
116
116
|
exception: new Error()
|
|
117
117
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './exception.reply';
|
|
@@ -93,7 +93,7 @@ function _object_spread_props(target, source) {
|
|
|
93
93
|
*/ _define_property(this, "shouldAddCacheControlHeaders", void 0);
|
|
94
94
|
this.fetchCache = fetchCache;
|
|
95
95
|
this.cacheControl = cacheControl;
|
|
96
|
-
this.shouldAddCacheControlHeaders = typeof shouldAddCacheControlHeaders !==
|
|
96
|
+
this.shouldAddCacheControlHeaders = typeof shouldAddCacheControlHeaders !== 'undefined' ? shouldAddCacheControlHeaders : typeof fetch === 'undefined' || fetch.polyfill;
|
|
97
97
|
}
|
|
98
98
|
_create_class(FetchCacheRequest, [
|
|
99
99
|
{
|
|
@@ -103,9 +103,9 @@ function _object_spread_props(target, source) {
|
|
|
103
103
|
return {
|
|
104
104
|
transform: function(data) {
|
|
105
105
|
if (_this.cacheControl && _this.shouldAddCacheControlHeaders) {
|
|
106
|
-
data.headers.set(
|
|
107
|
-
if (_this.cacheControl ===
|
|
108
|
-
data.headers.set(
|
|
106
|
+
data.headers.set('Cache-Control', "".concat(_this.cacheControl));
|
|
107
|
+
if (_this.cacheControl === 'no-cache') {
|
|
108
|
+
data.headers.set('Pragma', 'no-cache');
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
return _object_spread_props(_object_spread({}, data), {
|
|
@@ -122,8 +122,8 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { FetchCacheRequest } from
|
|
126
|
-
describe(
|
|
125
|
+
import { FetchCacheRequest } from './fetch-cache.request';
|
|
126
|
+
describe('Fetch API cache Request Plugin', function() {
|
|
127
127
|
var globalFetchBackup;
|
|
128
128
|
beforeEach(function() {
|
|
129
129
|
globalFetchBackup = fetch;
|
|
@@ -131,88 +131,88 @@ describe("Fetch API cache Request Plugin", function() {
|
|
|
131
131
|
afterEach(function() {
|
|
132
132
|
global.fetch = globalFetchBackup;
|
|
133
133
|
});
|
|
134
|
-
it(
|
|
134
|
+
it('cache should be set correctly', /*#__PURE__*/ _async_to_generator(function() {
|
|
135
135
|
var options, plugin, cache;
|
|
136
136
|
return _ts_generator(this, function(_state) {
|
|
137
137
|
switch(_state.label){
|
|
138
138
|
case 0:
|
|
139
139
|
options = {
|
|
140
140
|
headers: new Headers(),
|
|
141
|
-
basePath:
|
|
142
|
-
method:
|
|
141
|
+
basePath: 'http://test.com/truc',
|
|
142
|
+
method: 'get'
|
|
143
143
|
};
|
|
144
|
-
plugin = new FetchCacheRequest(
|
|
144
|
+
plugin = new FetchCacheRequest('force-cache');
|
|
145
145
|
return [
|
|
146
146
|
4,
|
|
147
147
|
plugin.load().transform(options)
|
|
148
148
|
];
|
|
149
149
|
case 1:
|
|
150
150
|
cache = _state.sent().cache;
|
|
151
|
-
expect(cache).toBe(
|
|
151
|
+
expect(cache).toBe('force-cache');
|
|
152
152
|
return [
|
|
153
153
|
2
|
|
154
154
|
];
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
157
|
}));
|
|
158
|
-
it(
|
|
158
|
+
it('should set Cache-Control and Pragma header to no-cache in the request', /*#__PURE__*/ _async_to_generator(function() {
|
|
159
159
|
var options, plugin, headerCacheControl, headerPragma;
|
|
160
160
|
return _ts_generator(this, function(_state) {
|
|
161
161
|
switch(_state.label){
|
|
162
162
|
case 0:
|
|
163
163
|
options = {
|
|
164
164
|
headers: new Headers(),
|
|
165
|
-
basePath:
|
|
166
|
-
method:
|
|
165
|
+
basePath: 'http://test.com/truc',
|
|
166
|
+
method: 'get'
|
|
167
167
|
};
|
|
168
168
|
global.fetch = {
|
|
169
169
|
polyfill: true
|
|
170
170
|
};
|
|
171
|
-
plugin = new FetchCacheRequest(
|
|
171
|
+
plugin = new FetchCacheRequest('force-cache', 'no-cache');
|
|
172
172
|
return [
|
|
173
173
|
4,
|
|
174
174
|
plugin.load().transform(options)
|
|
175
175
|
];
|
|
176
176
|
case 1:
|
|
177
|
-
headerCacheControl = _state.sent().headers.get(
|
|
177
|
+
headerCacheControl = _state.sent().headers.get('Cache-Control');
|
|
178
178
|
return [
|
|
179
179
|
4,
|
|
180
180
|
plugin.load().transform(options)
|
|
181
181
|
];
|
|
182
182
|
case 2:
|
|
183
|
-
headerPragma = _state.sent().headers.get(
|
|
184
|
-
expect(headerCacheControl).toEqual(
|
|
185
|
-
expect(headerPragma).toEqual(
|
|
183
|
+
headerPragma = _state.sent().headers.get('Pragma');
|
|
184
|
+
expect(headerCacheControl).toEqual('no-cache');
|
|
185
|
+
expect(headerPragma).toEqual('no-cache');
|
|
186
186
|
return [
|
|
187
187
|
2
|
|
188
188
|
];
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
191
|
}));
|
|
192
|
-
it(
|
|
192
|
+
it('should not set Cache-Control header in the request', /*#__PURE__*/ _async_to_generator(function() {
|
|
193
193
|
var options, plugin, headerCacheControl, headerPragma;
|
|
194
194
|
return _ts_generator(this, function(_state) {
|
|
195
195
|
switch(_state.label){
|
|
196
196
|
case 0:
|
|
197
197
|
options = {
|
|
198
198
|
headers: new Headers(),
|
|
199
|
-
basePath:
|
|
200
|
-
method:
|
|
199
|
+
basePath: 'http://test.com/truc',
|
|
200
|
+
method: 'get'
|
|
201
201
|
};
|
|
202
202
|
global.fetch = function() {};
|
|
203
|
-
plugin = new FetchCacheRequest(
|
|
203
|
+
plugin = new FetchCacheRequest('force-cache', 'no-cache');
|
|
204
204
|
return [
|
|
205
205
|
4,
|
|
206
206
|
plugin.load().transform(options)
|
|
207
207
|
];
|
|
208
208
|
case 1:
|
|
209
|
-
headerCacheControl = _state.sent().headers.get(
|
|
209
|
+
headerCacheControl = _state.sent().headers.get('Cache-Control');
|
|
210
210
|
return [
|
|
211
211
|
4,
|
|
212
212
|
plugin.load().transform(options)
|
|
213
213
|
];
|
|
214
214
|
case 2:
|
|
215
|
-
headerPragma = _state.sent().headers.get(
|
|
215
|
+
headerPragma = _state.sent().headers.get('Pragma');
|
|
216
216
|
expect(headerCacheControl).toBeNull();
|
|
217
217
|
expect(headerPragma).toBeNull();
|
|
218
218
|
return [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './fetch-cache.request';
|
|
@@ -35,7 +35,7 @@ function _define_property(obj, key, value) {
|
|
|
35
35
|
*/ export var FetchCredentialsRequest = /*#__PURE__*/ function() {
|
|
36
36
|
"use strict";
|
|
37
37
|
function FetchCredentialsRequest() {
|
|
38
|
-
var credentialsValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] :
|
|
38
|
+
var credentialsValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 'same-origin';
|
|
39
39
|
_class_call_check(this, FetchCredentialsRequest);
|
|
40
40
|
/**
|
|
41
41
|
* Value that will be set as the "credentials" option of the fetch API.
|
|
@@ -122,14 +122,14 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { FetchCredentialsRequest } from
|
|
126
|
-
describe(
|
|
125
|
+
import { FetchCredentialsRequest } from './fetch-credentials.request';
|
|
126
|
+
describe('Fetch API credentials Request Plugin', function() {
|
|
127
127
|
var options = {
|
|
128
128
|
headers: new Headers(),
|
|
129
|
-
basePath:
|
|
130
|
-
method:
|
|
129
|
+
basePath: 'http://test.com/truc',
|
|
130
|
+
method: 'get'
|
|
131
131
|
};
|
|
132
|
-
it(
|
|
132
|
+
it('credentials should be set to same-origin by default', /*#__PURE__*/ _async_to_generator(function() {
|
|
133
133
|
var plugin, runner, cred;
|
|
134
134
|
return _ts_generator(this, function(_state) {
|
|
135
135
|
switch(_state.label){
|
|
@@ -148,19 +148,19 @@ describe("Fetch API credentials Request Plugin", function() {
|
|
|
148
148
|
];
|
|
149
149
|
case 2:
|
|
150
150
|
cred = _state.sent().credentials;
|
|
151
|
-
expect(cred).toBe(
|
|
151
|
+
expect(cred).toBe('same-origin');
|
|
152
152
|
return [
|
|
153
153
|
2
|
|
154
154
|
];
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
157
|
}));
|
|
158
|
-
it(
|
|
158
|
+
it('credentials should be set correctly', /*#__PURE__*/ _async_to_generator(function() {
|
|
159
159
|
var plugin, runner, cred;
|
|
160
160
|
return _ts_generator(this, function(_state) {
|
|
161
161
|
switch(_state.label){
|
|
162
162
|
case 0:
|
|
163
|
-
plugin = new FetchCredentialsRequest(
|
|
163
|
+
plugin = new FetchCredentialsRequest('include');
|
|
164
164
|
runner = plugin.load();
|
|
165
165
|
return [
|
|
166
166
|
4,
|
|
@@ -174,7 +174,7 @@ describe("Fetch API credentials Request Plugin", function() {
|
|
|
174
174
|
];
|
|
175
175
|
case 2:
|
|
176
176
|
cred = _state.sent().credentials;
|
|
177
|
-
expect(cred).toBe(
|
|
177
|
+
expect(cred).toBe('include');
|
|
178
178
|
return [
|
|
179
179
|
2
|
|
180
180
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './fetch-credentials.request';
|
package/esm2015/plugins/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
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
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
25
|
-
export * from
|
|
1
|
+
export * from './additional-params/index';
|
|
2
|
+
export * from './api-configuration-override/index';
|
|
3
|
+
export * from './api-key/index';
|
|
4
|
+
export * from './bot-protection-fingerprint/index';
|
|
5
|
+
export * from './concurrent/index';
|
|
6
|
+
export * from './core/index';
|
|
7
|
+
export * from './client-facts/index';
|
|
8
|
+
export * from './custom-info/index';
|
|
9
|
+
export * from './exception/index';
|
|
10
|
+
export * from './fetch-cache/index';
|
|
11
|
+
export * from './fetch-credentials/index';
|
|
12
|
+
export * from './json-token/index';
|
|
13
|
+
export * from './keepalive/index';
|
|
14
|
+
export * from './mock-intercept/index';
|
|
15
|
+
export * from './perf-metric/index';
|
|
16
|
+
export * from './pii-tokenizer/index';
|
|
17
|
+
export * from './raw-response-info/index';
|
|
18
|
+
export * from './retry/index';
|
|
19
|
+
export * from './reviver/index';
|
|
20
|
+
export * from './session-id/index';
|
|
21
|
+
export * from './si-token/index';
|
|
22
|
+
export * from './simple-api-key-authentication/index';
|
|
23
|
+
export * from './url-rewrite/index';
|
|
24
|
+
export * from './wait-for/index';
|
|
25
|
+
export * from './timeout/index';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './json-token.reply';
|
|
2
|
+
export * from './json-token.request';
|
|
@@ -35,7 +35,7 @@ function _define_property(obj, key, value) {
|
|
|
35
35
|
*/ export var JsonTokenReply = /*#__PURE__*/ function() {
|
|
36
36
|
"use strict";
|
|
37
37
|
function JsonTokenReply() {
|
|
38
|
-
var storageTokenKey = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] :
|
|
38
|
+
var storageTokenKey = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 'DP_SDK_AUTH_TOKEN', sharedMemory = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
39
39
|
_class_call_check(this, JsonTokenReply);
|
|
40
40
|
_define_property(this, "storageTokenKey", void 0);
|
|
41
41
|
_define_property(this, "sharedMemory", void 0);
|
|
@@ -52,15 +52,15 @@ function _define_property(obj, key, value) {
|
|
|
52
52
|
if (!context.response) {
|
|
53
53
|
return data;
|
|
54
54
|
}
|
|
55
|
-
if (context.response.headers.has(
|
|
56
|
-
var token = context.response.headers.get(
|
|
57
|
-
if (typeof sessionStorage !==
|
|
55
|
+
if (context.response.headers.has('Authorization')) {
|
|
56
|
+
var token = context.response.headers.get('Authorization');
|
|
57
|
+
if (typeof sessionStorage !== 'undefined') {
|
|
58
58
|
sessionStorage.setItem(_this.storageTokenKey, token);
|
|
59
59
|
} else {
|
|
60
60
|
_this.sharedMemory[_this.storageTokenKey] = token;
|
|
61
61
|
}
|
|
62
62
|
} else {
|
|
63
|
-
if (typeof sessionStorage !==
|
|
63
|
+
if (typeof sessionStorage !== 'undefined') {
|
|
64
64
|
sessionStorage.removeItem(_this.storageTokenKey);
|
|
65
65
|
} else {
|
|
66
66
|
_this.sharedMemory[_this.storageTokenKey] = undefined;
|
|
@@ -35,7 +35,7 @@ function _define_property(obj, key, value) {
|
|
|
35
35
|
*/ export var JsonTokenRequest = /*#__PURE__*/ function() {
|
|
36
36
|
"use strict";
|
|
37
37
|
function JsonTokenRequest() {
|
|
38
|
-
var storageTokenKey = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] :
|
|
38
|
+
var storageTokenKey = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 'DP_SDK_AUTH_TOKEN', sharedMemory = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
39
39
|
_class_call_check(this, JsonTokenRequest);
|
|
40
40
|
_define_property(this, "storageTokenKey", void 0);
|
|
41
41
|
_define_property(this, "sharedMemory", void 0);
|
|
@@ -50,10 +50,10 @@ function _define_property(obj, key, value) {
|
|
|
50
50
|
return {
|
|
51
51
|
transform: function(data) {
|
|
52
52
|
// Handle Authorization Tokens
|
|
53
|
-
var token = typeof sessionStorage !==
|
|
53
|
+
var token = typeof sessionStorage !== 'undefined' ? sessionStorage.getItem(_this.storageTokenKey) : _this.sharedMemory[_this.storageTokenKey];
|
|
54
54
|
if (token) {
|
|
55
|
-
data.credentials =
|
|
56
|
-
data.headers.append(
|
|
55
|
+
data.credentials = 'same-origin';
|
|
56
|
+
data.headers.append('Authorization', token);
|
|
57
57
|
}
|
|
58
58
|
return data;
|
|
59
59
|
}
|
|
@@ -122,28 +122,28 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { ApiTypes } from
|
|
126
|
-
import { JsonTokenReply } from
|
|
127
|
-
import { JsonTokenRequest } from
|
|
128
|
-
describe(
|
|
129
|
-
var tokenValue =
|
|
130
|
-
var tokenKey =
|
|
131
|
-
describe(
|
|
125
|
+
import { ApiTypes } from '../../fwk/api';
|
|
126
|
+
import { JsonTokenReply } from './json-token.reply';
|
|
127
|
+
import { JsonTokenRequest } from './json-token.request';
|
|
128
|
+
describe('Json Token', function() {
|
|
129
|
+
var tokenValue = 'tokenValue';
|
|
130
|
+
var tokenKey = 'testToken';
|
|
131
|
+
describe('request plugin', function() {
|
|
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 Authorization header', /*#__PURE__*/ _async_to_generator(function() {
|
|
147
147
|
var memory, plugin, runner, result;
|
|
148
148
|
return _ts_generator(this, function(_state) {
|
|
149
149
|
switch(_state.label){
|
|
@@ -153,8 +153,8 @@ describe("Json Token", function() {
|
|
|
153
153
|
};
|
|
154
154
|
plugin = new JsonTokenRequest(tokenKey, memory);
|
|
155
155
|
runner = plugin.load();
|
|
156
|
-
if (typeof window !==
|
|
157
|
-
jest.spyOn(window.sessionStorage,
|
|
156
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
157
|
+
jest.spyOn(window.sessionStorage, 'getItem').mockImplementation(function() {
|
|
158
158
|
return tokenValue;
|
|
159
159
|
});
|
|
160
160
|
}
|
|
@@ -164,18 +164,18 @@ describe("Json Token", function() {
|
|
|
164
164
|
];
|
|
165
165
|
case 1:
|
|
166
166
|
result = _state.sent();
|
|
167
|
-
if (typeof window !==
|
|
167
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
168
168
|
expect(window.sessionStorage.getItem).toHaveBeenCalledWith(tokenKey);
|
|
169
169
|
}
|
|
170
|
-
expect(result.credentials).toBe(
|
|
171
|
-
expect(result.headers.get(
|
|
170
|
+
expect(result.credentials).toBe('same-origin');
|
|
171
|
+
expect(result.headers.get('Authorization')).toBe(tokenValue);
|
|
172
172
|
return [
|
|
173
173
|
2
|
|
174
174
|
];
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
177
|
}));
|
|
178
|
-
it(
|
|
178
|
+
it('should not add Authorization if no token', /*#__PURE__*/ _async_to_generator(function() {
|
|
179
179
|
var memory, plugin, runner, result;
|
|
180
180
|
return _ts_generator(this, function(_state) {
|
|
181
181
|
switch(_state.label){
|
|
@@ -185,8 +185,8 @@ describe("Json Token", function() {
|
|
|
185
185
|
};
|
|
186
186
|
plugin = new JsonTokenRequest(tokenKey, memory);
|
|
187
187
|
runner = plugin.load();
|
|
188
|
-
if (typeof window !==
|
|
189
|
-
jest.spyOn(window.sessionStorage,
|
|
188
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
189
|
+
jest.spyOn(window.sessionStorage, 'getItem').mockImplementation();
|
|
190
190
|
}
|
|
191
191
|
return [
|
|
192
192
|
4,
|
|
@@ -194,11 +194,11 @@ describe("Json Token", function() {
|
|
|
194
194
|
];
|
|
195
195
|
case 1:
|
|
196
196
|
result = _state.sent();
|
|
197
|
-
if (typeof window !==
|
|
197
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
198
198
|
expect(window.sessionStorage.getItem).toHaveBeenCalledWith(tokenKey);
|
|
199
199
|
}
|
|
200
200
|
expect(result.credentials).toBeUndefined();
|
|
201
|
-
expect(result.headers.get(
|
|
201
|
+
expect(result.headers.get('Authorization')).toBeNull();
|
|
202
202
|
return [
|
|
203
203
|
2
|
|
204
204
|
];
|
|
@@ -206,9 +206,9 @@ describe("Json Token", function() {
|
|
|
206
206
|
});
|
|
207
207
|
}));
|
|
208
208
|
});
|
|
209
|
-
describe(
|
|
209
|
+
describe('reply plugin', function() {
|
|
210
210
|
var reviver = jest.fn();
|
|
211
|
-
it(
|
|
211
|
+
it('should store the received token', /*#__PURE__*/ _async_to_generator(function() {
|
|
212
212
|
var memory, plugin, runner, data;
|
|
213
213
|
return _ts_generator(this, function(_state) {
|
|
214
214
|
switch(_state.label){
|
|
@@ -228,8 +228,8 @@ describe("Json Token", function() {
|
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
230
|
data = {};
|
|
231
|
-
if (typeof window !==
|
|
232
|
-
jest.spyOn(window.sessionStorage,
|
|
231
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
232
|
+
jest.spyOn(window.sessionStorage, 'setItem').mockImplementation();
|
|
233
233
|
}
|
|
234
234
|
return [
|
|
235
235
|
4,
|
|
@@ -237,7 +237,7 @@ describe("Json Token", function() {
|
|
|
237
237
|
];
|
|
238
238
|
case 1:
|
|
239
239
|
_state.sent();
|
|
240
|
-
if (typeof window !==
|
|
240
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
241
241
|
expect(window.sessionStorage.setItem).toHaveBeenCalledWith(tokenKey, tokenValue);
|
|
242
242
|
} else {
|
|
243
243
|
expect(memory.testToken).toBe(tokenValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './keepalive.request';
|
|
@@ -224,7 +224,7 @@ function _ts_generator(thisArg, body) {
|
|
|
224
224
|
switch(_state.label){
|
|
225
225
|
case 0:
|
|
226
226
|
customHeaders = new Headers();
|
|
227
|
-
customHeaders.set(
|
|
227
|
+
customHeaders.set('Content-Type', 'application/json');
|
|
228
228
|
_state.label = 1;
|
|
229
229
|
case 1:
|
|
230
230
|
_state.trys.push([
|
|
@@ -235,7 +235,7 @@ function _ts_generator(thisArg, body) {
|
|
|
235
235
|
]);
|
|
236
236
|
return [
|
|
237
237
|
4,
|
|
238
|
-
fetch(
|
|
238
|
+
fetch('', {
|
|
239
239
|
headers: customHeaders,
|
|
240
240
|
keepalive: true
|
|
241
241
|
})
|
|
@@ -122,14 +122,14 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { KeepaliveRequest } from
|
|
126
|
-
describe(
|
|
125
|
+
import { KeepaliveRequest } from './keepalive.request';
|
|
126
|
+
describe('Keepalive Request Plugin', function() {
|
|
127
127
|
var options = {
|
|
128
128
|
headers: new Headers(),
|
|
129
|
-
basePath:
|
|
130
|
-
method:
|
|
129
|
+
basePath: 'http://test.com/truc',
|
|
130
|
+
method: 'get'
|
|
131
131
|
};
|
|
132
|
-
it(
|
|
132
|
+
it('keepalive should be set to true', /*#__PURE__*/ _async_to_generator(function() {
|
|
133
133
|
var plugin, runner, keepalive;
|
|
134
134
|
return _ts_generator(this, function(_state) {
|
|
135
135
|
switch(_state.label){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './mgw-mdw-auth.request';
|