@ama-sdk/core 10.3.0-prerelease.66 → 10.3.0-prerelease.67
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 +4 -4
- package/cjs/clients/api-beacon-client.js +4 -4
- package/cjs/clients/api-fetch-client.js +4 -4
- package/cjs/fwk/api.helper.spec.js +20 -20
- package/cjs/fwk/api.helpers.js +13 -13
- 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 +4 -4
- package/cjs/utils/json-token.js +30 -30
- package/cjs/utils/json-token.spec.js +31 -31
- package/esm2015/clients/api-angular-client.js +8 -8
- package/esm2015/clients/api-beacon-client.js +5 -5
- package/esm2015/clients/api-fetch-client.js +8 -8
- package/esm2015/clients/index.js +2 -2
- package/esm2015/fwk/api.helper.spec.js +21 -21
- package/esm2015/fwk/api.helpers.js +13 -13
- 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 +5 -5
- package/esm2015/utils/index.js +6 -6
- package/esm2015/utils/json-token.js +32 -32
- package/esm2015/utils/json-token.spec.js +32 -32
- package/package.json +5 -5
|
@@ -122,16 +122,16 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { ApiTypes } from
|
|
126
|
-
import { CustomInfoReply } from
|
|
127
|
-
describe(
|
|
128
|
-
it(
|
|
125
|
+
import { ApiTypes } from '../../fwk/api';
|
|
126
|
+
import { CustomInfoReply } from './custom-info.reply';
|
|
127
|
+
describe('Custom info reply plugin', function() {
|
|
128
|
+
it('should add the content of the custom information in the reply', /*#__PURE__*/ _async_to_generator(function() {
|
|
129
129
|
var customInfo, plugin, runner, newData;
|
|
130
130
|
return _ts_generator(this, function(_state) {
|
|
131
131
|
switch(_state.label){
|
|
132
132
|
case 0:
|
|
133
133
|
customInfo = {
|
|
134
|
-
key:
|
|
134
|
+
key: 'value',
|
|
135
135
|
nested: {
|
|
136
136
|
field: 10
|
|
137
137
|
}
|
|
@@ -148,7 +148,7 @@ describe("Custom info reply plugin", function() {
|
|
|
148
148
|
case 1:
|
|
149
149
|
newData = _state.sent();
|
|
150
150
|
expect(newData.customInfo).toEqual({
|
|
151
|
-
key:
|
|
151
|
+
key: 'value',
|
|
152
152
|
nested: {
|
|
153
153
|
field: 10
|
|
154
154
|
}
|
|
@@ -159,18 +159,18 @@ describe("Custom info reply plugin", function() {
|
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
161
|
}));
|
|
162
|
-
it(
|
|
162
|
+
it('should merge the contents of the two custom info', /*#__PURE__*/ _async_to_generator(function() {
|
|
163
163
|
var customInfo1, plugin1, customInfo2, plugin2, runner1, runner2, newData, _;
|
|
164
164
|
return _ts_generator(this, function(_state) {
|
|
165
165
|
switch(_state.label){
|
|
166
166
|
case 0:
|
|
167
167
|
customInfo1 = {
|
|
168
|
-
key0:
|
|
169
|
-
key1:
|
|
168
|
+
key0: 'dummy',
|
|
169
|
+
key1: 'value'
|
|
170
170
|
};
|
|
171
171
|
plugin1 = new CustomInfoReply(customInfo1);
|
|
172
172
|
customInfo2 = {
|
|
173
|
-
key1:
|
|
173
|
+
key1: 'override',
|
|
174
174
|
key2: 42
|
|
175
175
|
};
|
|
176
176
|
plugin2 = new CustomInfoReply(customInfo2);
|
|
@@ -197,8 +197,8 @@ describe("Custom info reply plugin", function() {
|
|
|
197
197
|
case 2:
|
|
198
198
|
newData = _state.sent();
|
|
199
199
|
expect(newData.customInfo).toEqual({
|
|
200
|
-
key0:
|
|
201
|
-
key1:
|
|
200
|
+
key0: 'dummy',
|
|
201
|
+
key1: 'override',
|
|
202
202
|
key2: 42
|
|
203
203
|
});
|
|
204
204
|
return [
|
|
@@ -207,19 +207,19 @@ describe("Custom info reply plugin", function() {
|
|
|
207
207
|
}
|
|
208
208
|
});
|
|
209
209
|
}));
|
|
210
|
-
it(
|
|
210
|
+
it('should invalidate custom info', function() {
|
|
211
211
|
var plugin = new CustomInfoReply({});
|
|
212
212
|
var data = {
|
|
213
|
-
originalData:
|
|
213
|
+
originalData: 'OK'
|
|
214
214
|
};
|
|
215
215
|
expect(plugin.hasCustomInfo(data)).toBeFalsy();
|
|
216
216
|
});
|
|
217
|
-
it(
|
|
217
|
+
it('should validate custom info', function() {
|
|
218
218
|
var plugin = new CustomInfoReply({});
|
|
219
219
|
var data = {
|
|
220
|
-
originalData:
|
|
220
|
+
originalData: 'OK',
|
|
221
221
|
customInfo: {
|
|
222
|
-
a:
|
|
222
|
+
a: 'b'
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
expect(plugin.hasCustomInfo(data)).toBeTruthy();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './custom-info.reply';
|
|
@@ -30,8 +30,8 @@ function _define_property(obj, key, value) {
|
|
|
30
30
|
}
|
|
31
31
|
return obj;
|
|
32
32
|
}
|
|
33
|
-
import { ApiTypes } from
|
|
34
|
-
import { EmptyResponseError, RequestFailedError } from
|
|
33
|
+
import { ApiTypes } from '../../fwk/api';
|
|
34
|
+
import { EmptyResponseError, RequestFailedError } from '../../fwk/errors';
|
|
35
35
|
/**
|
|
36
36
|
* Plugin to fire an exception on wrong response / data
|
|
37
37
|
*/ export var ExceptionReply = /*#__PURE__*/ function() {
|
|
@@ -59,8 +59,8 @@ import { EmptyResponseError, RequestFailedError } from "../../fwk/errors";
|
|
|
59
59
|
};
|
|
60
60
|
var error;
|
|
61
61
|
if (!context.response) {
|
|
62
|
-
error = new EmptyResponseError(
|
|
63
|
-
} else if (context.apiType === ApiTypes.DAPI && context.response.status === 200 && (!res || !res.data && typeof res.errors !==
|
|
62
|
+
error = new EmptyResponseError('Fail to Fetch', undefined, errorContext);
|
|
63
|
+
} else if (context.apiType === ApiTypes.DAPI && context.response.status === 200 && (!res || !res.data && typeof res.errors !== 'undefined' // Some DAPI replies have data as optional, so we only throw if response contains errors
|
|
64
64
|
)) {
|
|
65
65
|
error = new EmptyResponseError(context.response.statusText, res, errorContext);
|
|
66
66
|
} else if (!context.response.ok) {
|
|
@@ -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
|
}
|