@ama-sdk/core 11.0.0-next.0 → 11.0.0-next.2
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/README.md +4 -1
- package/cjs/clients/api-angular-client.js +45 -23
- package/cjs/clients/api-beacon-client.js +64 -20
- package/cjs/clients/api-fetch-client.js +66 -21
- package/cjs/fwk/Reviver.js +7 -7
- 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 +46 -10
- 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 +6 -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.fetch.js +1 -0
- 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 +32 -40
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +30 -26
- 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.reply.js +35 -2
- package/cjs/plugins/reviver/reviver.spec.js +6 -6
- package/cjs/plugins/session-id/session-id.request.js +7 -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 +12 -10
- 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/files-pack.cjs +12 -12
- package/cli/files-pack.cjs.map +1 -1
- package/esm2015/clients/api-angular-client.js +49 -27
- package/esm2015/clients/api-beacon-client.js +65 -21
- package/esm2015/clients/api-fetch-client.js +70 -25
- package/esm2015/clients/index.js +2 -2
- package/esm2015/fwk/Reviver.js +10 -7
- 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 +47 -11
- 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 +6 -6
- 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.fetch.js +1 -0
- 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 +34 -42
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +32 -28
- 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.reply.js +35 -2
- package/esm2015/plugins/reviver/reviver.spec.js +8 -8
- package/esm2015/plugins/session-id/index.js +1 -1
- package/esm2015/plugins/session-id/session-id.request.js +8 -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 +13 -11
- 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 +67 -40
- package/schematics/ng-add/index.d.ts +4 -2
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +58 -40
- package/schematics/ng-add/index.js.map +1 -1
- 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 +31 -16
- 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 +24 -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 +26 -14
- package/src/clients/api-fetch-client.js.map +1 -1
- package/src/fwk/Reviver.d.ts +16 -4
- package/src/fwk/Reviver.d.ts.map +1 -1
- package/src/fwk/Reviver.js +9 -6
- package/src/fwk/Reviver.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/fwk/date.js.map +1 -1
- package/src/fwk/mocks/alf-mock-adapter.js.map +1 -1
- package/src/fwk/mocks/base-mock-adapter.js.map +1 -1
- package/src/fwk/mocks/helpers.js.map +1 -1
- package/src/fwk/mocks/random-mock-adapter.js.map +1 -1
- package/src/fwk/mocks/sequential-mock-adapter.js.map +1 -1
- package/src/plugins/additional-params/additional-params-sync.request.js.map +1 -1
- package/src/plugins/additional-params/additional-params.request.js.map +1 -1
- package/src/plugins/api-configuration-override/api-configuration-override.request.js.map +1 -1
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.d.ts +1 -1
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.d.ts.map +1 -1
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +1 -1
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js.map +1 -1
- package/src/plugins/client-facts/client-facts.request.js.map +1 -1
- package/src/plugins/concurrent/concurrent.fetch.d.ts.map +1 -1
- package/src/plugins/concurrent/concurrent.fetch.js +1 -0
- package/src/plugins/concurrent/concurrent.fetch.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/plugins/core/request-plugin.d.ts +2 -0
- package/src/plugins/core/request-plugin.d.ts.map +1 -1
- package/src/plugins/exception/exception.reply.js.map +1 -1
- package/src/plugins/fetch-cache/fetch-cache.request.js.map +1 -1
- package/src/plugins/json-token/json-token.reply.js.map +1 -1
- package/src/plugins/json-token/json-token.request.js.map +1 -1
- package/src/plugins/keepalive/keepalive.request.js.map +1 -1
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.d.ts +2 -2
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.d.ts.map +1 -1
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +26 -28
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.fetch.js.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.request.js.map +1 -1
- package/src/plugins/perf-metric/perf-metric.fetch.js.map +1 -1
- package/src/plugins/pii-tokenizer/pii-tokenizer.request.d.ts.map +1 -1
- package/src/plugins/pii-tokenizer/pii-tokenizer.request.js.map +1 -1
- package/src/plugins/raw-response-info/raw-response-info.reply.js.map +1 -1
- package/src/plugins/retry/retry.fetch.js.map +1 -1
- package/src/plugins/reviver/reviver.reply.d.ts +7 -0
- package/src/plugins/reviver/reviver.reply.d.ts.map +1 -1
- package/src/plugins/reviver/reviver.reply.js +12 -1
- package/src/plugins/reviver/reviver.reply.js.map +1 -1
- package/src/plugins/session-id/session-id.request.d.ts +1 -0
- package/src/plugins/session-id/session-id.request.d.ts.map +1 -1
- package/src/plugins/session-id/session-id.request.js +1 -0
- package/src/plugins/session-id/session-id.request.js.map +1 -1
- package/src/plugins/si-token/si-token.request.js.map +1 -1
- package/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js.map +1 -1
- package/src/plugins/timeout/timeout.fetch.d.ts.map +1 -1
- package/src/plugins/timeout/timeout.fetch.js +2 -0
- package/src/plugins/timeout/timeout.fetch.js.map +1 -1
- package/src/plugins/wait-for/wait-for.fetch.js.map +1 -1
- package/src/utils/crypto.js.map +1 -1
- package/src/utils/encoder.js.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
- package/src/utils/json-token.d.ts.map +1 -1
- package/src/utils/json-token.js.map +1 -1
|
@@ -156,35 +156,35 @@ function _ts_generator(thisArg, body) {
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
var defaultFacts = {
|
|
159
|
-
foo:
|
|
160
|
-
bar:
|
|
159
|
+
foo: 'one',
|
|
160
|
+
bar: 'two'
|
|
161
161
|
};
|
|
162
162
|
var specificFacts = {
|
|
163
|
-
bar:
|
|
164
|
-
specific:
|
|
163
|
+
bar: 'three',
|
|
164
|
+
specific: 'I am specific'
|
|
165
165
|
};
|
|
166
|
-
var encryptedPrivateFacts =
|
|
166
|
+
var encryptedPrivateFacts = 'GuTVpr8JxjTj1Umlmph5h5sP00c2RfIUjJIw5iYMHarSXA8sYUIuEKTUDdC5fVkcmKXi4qd3W5y/VGQcKCo0bba3JlfBGviegpGVRvug/vfH2VYTsUyAyBFdcG+CiI4dY+0/Nn48G656KxRygBkxmg==';
|
|
167
167
|
var jwtFactsEncoder = (0, _clientfactsrequest.createJwtFactsEncoder)();
|
|
168
|
-
var defaultHeader =
|
|
169
|
-
describe(
|
|
168
|
+
var defaultHeader = 'ama-client-facts';
|
|
169
|
+
describe('Client Facts request plugin', function() {
|
|
170
170
|
var options;
|
|
171
171
|
var specificOptions;
|
|
172
172
|
beforeEach(function() {
|
|
173
173
|
options = {
|
|
174
|
-
basePath:
|
|
174
|
+
basePath: 'dummypath',
|
|
175
175
|
headers: new Headers(),
|
|
176
|
-
method:
|
|
176
|
+
method: 'GET'
|
|
177
177
|
};
|
|
178
178
|
specificOptions = {
|
|
179
|
-
basePath:
|
|
179
|
+
basePath: '/order',
|
|
180
180
|
headers: new Headers(),
|
|
181
|
-
method:
|
|
181
|
+
method: 'POST'
|
|
182
182
|
};
|
|
183
183
|
});
|
|
184
|
-
it(
|
|
185
|
-
expect(jwtFactsEncoder(defaultFacts)).toEqual(
|
|
184
|
+
it('Should encode the public facts as unsecured JWT', function() {
|
|
185
|
+
expect(jwtFactsEncoder(defaultFacts)).toEqual('eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJmYWN0IiwiZm9vIjoib25lIiwiYmFyIjoidHdvIn0.');
|
|
186
186
|
});
|
|
187
|
-
it(
|
|
187
|
+
it('Should apply global facts to every requests to the default header', /*#__PURE__*/ _async_to_generator(function() {
|
|
188
188
|
var plugin, firstOptions, secondOptions;
|
|
189
189
|
return _ts_generator(this, function(_state) {
|
|
190
190
|
switch(_state.label){
|
|
@@ -215,14 +215,14 @@ describe("Client Facts request plugin", function() {
|
|
|
215
215
|
}
|
|
216
216
|
});
|
|
217
217
|
}));
|
|
218
|
-
it(
|
|
218
|
+
it('Should allow to configure header name', /*#__PURE__*/ _async_to_generator(function() {
|
|
219
219
|
var plugin, newOptions;
|
|
220
220
|
return _ts_generator(this, function(_state) {
|
|
221
221
|
switch(_state.label){
|
|
222
222
|
case 0:
|
|
223
223
|
plugin = new _clientfactsrequest.ClientFactsRequestPlugin({
|
|
224
224
|
initialGlobalFacts: defaultFacts,
|
|
225
|
-
headerName:
|
|
225
|
+
headerName: 'dummy'
|
|
226
226
|
});
|
|
227
227
|
return [
|
|
228
228
|
4,
|
|
@@ -230,7 +230,7 @@ describe("Client Facts request plugin", function() {
|
|
|
230
230
|
];
|
|
231
231
|
case 1:
|
|
232
232
|
newOptions = _state.sent();
|
|
233
|
-
expect(newOptions.headers.has(
|
|
233
|
+
expect(newOptions.headers.has('dummy')).toBeTruthy();
|
|
234
234
|
expect(newOptions.headers.has(defaultHeader)).toBeFalsy();
|
|
235
235
|
return [
|
|
236
236
|
2
|
|
@@ -238,7 +238,7 @@ describe("Client Facts request plugin", function() {
|
|
|
238
238
|
}
|
|
239
239
|
});
|
|
240
240
|
}));
|
|
241
|
-
it(
|
|
241
|
+
it('Should allow to change facts via a function', /*#__PURE__*/ _async_to_generator(function() {
|
|
242
242
|
var plugin, newOptions;
|
|
243
243
|
return _ts_generator(this, function(_state) {
|
|
244
244
|
switch(_state.label){
|
|
@@ -247,7 +247,7 @@ describe("Client Facts request plugin", function() {
|
|
|
247
247
|
initialGlobalFacts: defaultFacts
|
|
248
248
|
});
|
|
249
249
|
plugin.setGlobalFacts({
|
|
250
|
-
foo:
|
|
250
|
+
foo: 'bar'
|
|
251
251
|
});
|
|
252
252
|
return [
|
|
253
253
|
4,
|
|
@@ -257,7 +257,7 @@ describe("Client Facts request plugin", function() {
|
|
|
257
257
|
newOptions = _state.sent();
|
|
258
258
|
expect(newOptions.headers.has(defaultHeader)).toBeTruthy();
|
|
259
259
|
expect(newOptions.headers.get(defaultHeader)).toEqual(jwtFactsEncoder({
|
|
260
|
-
foo:
|
|
260
|
+
foo: 'bar'
|
|
261
261
|
}));
|
|
262
262
|
return [
|
|
263
263
|
2
|
|
@@ -265,14 +265,14 @@ describe("Client Facts request plugin", function() {
|
|
|
265
265
|
}
|
|
266
266
|
});
|
|
267
267
|
}));
|
|
268
|
-
it(
|
|
268
|
+
it('Should allow to return facts only for specific requests thanks to factories', /*#__PURE__*/ _async_to_generator(function() {
|
|
269
269
|
var plugin, newOptions, newSpecificOptions;
|
|
270
270
|
return _ts_generator(this, function(_state) {
|
|
271
271
|
switch(_state.label){
|
|
272
272
|
case 0:
|
|
273
273
|
plugin = new _clientfactsrequest.ClientFactsRequestPlugin({
|
|
274
274
|
factsFactory: function(request) {
|
|
275
|
-
if (request.basePath.includes(
|
|
275
|
+
if (request.basePath.includes('/order') && request.method !== 'GET') {
|
|
276
276
|
return specificFacts;
|
|
277
277
|
}
|
|
278
278
|
return {};
|
|
@@ -299,7 +299,7 @@ describe("Client Facts request plugin", function() {
|
|
|
299
299
|
}
|
|
300
300
|
});
|
|
301
301
|
}));
|
|
302
|
-
it(
|
|
302
|
+
it('Should allow to set private facts', /*#__PURE__*/ _async_to_generator(function() {
|
|
303
303
|
var plugin, newOptions;
|
|
304
304
|
return _ts_generator(this, function(_state) {
|
|
305
305
|
switch(_state.label){
|
|
@@ -321,7 +321,7 @@ describe("Client Facts request plugin", function() {
|
|
|
321
321
|
}
|
|
322
322
|
});
|
|
323
323
|
}));
|
|
324
|
-
it(
|
|
324
|
+
it('Specific facts should have priority over global facts', /*#__PURE__*/ _async_to_generator(function() {
|
|
325
325
|
var plugin, newSpecificOptions;
|
|
326
326
|
return _ts_generator(this, function(_state) {
|
|
327
327
|
switch(_state.label){
|
|
@@ -329,7 +329,7 @@ describe("Client Facts request plugin", function() {
|
|
|
329
329
|
plugin = new _clientfactsrequest.ClientFactsRequestPlugin({
|
|
330
330
|
initialGlobalFacts: defaultFacts,
|
|
331
331
|
factsFactory: function(request) {
|
|
332
|
-
if (request.basePath.includes(
|
|
332
|
+
if (request.basePath.includes('/order') && request.method !== 'GET') {
|
|
333
333
|
return specificFacts;
|
|
334
334
|
}
|
|
335
335
|
return {};
|
|
@@ -349,14 +349,14 @@ describe("Client Facts request plugin", function() {
|
|
|
349
349
|
}
|
|
350
350
|
});
|
|
351
351
|
}));
|
|
352
|
-
it(
|
|
352
|
+
it('Factories should be allowed to be asynchronous and return a Promise of facts', /*#__PURE__*/ _async_to_generator(function() {
|
|
353
353
|
var plugin, promise, newSpecificOptions;
|
|
354
354
|
return _ts_generator(this, function(_state) {
|
|
355
355
|
switch(_state.label){
|
|
356
356
|
case 0:
|
|
357
357
|
plugin = new _clientfactsrequest.ClientFactsRequestPlugin({
|
|
358
358
|
factsFactory: function(request) {
|
|
359
|
-
if (request.basePath.includes(
|
|
359
|
+
if (request.basePath.includes('/order') && request.method !== 'GET') {
|
|
360
360
|
return new Promise(function(resolve) {
|
|
361
361
|
return setTimeout(function() {
|
|
362
362
|
return resolve(specificFacts);
|
|
@@ -235,6 +235,7 @@ var ConcurrentFetch = /*#__PURE__*/ function() {
|
|
|
235
235
|
e = _state.sent();
|
|
236
236
|
throw e;
|
|
237
237
|
case 4:
|
|
238
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
238
239
|
_this1.pool = _this1.pool.filter(function(call) {
|
|
239
240
|
return call !== fetchCall;
|
|
240
241
|
});
|
|
@@ -127,8 +127,8 @@ function _ts_generator(thisArg, body) {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
describe(
|
|
131
|
-
it(
|
|
130
|
+
describe('Concurrent Fetch Plugin', function() {
|
|
131
|
+
it('should start if the limit is not reach', /*#__PURE__*/ _async_to_generator(function() {
|
|
132
132
|
var plugin, runner, canStart;
|
|
133
133
|
return _ts_generator(this, function(_state) {
|
|
134
134
|
switch(_state.label){
|
|
@@ -149,7 +149,7 @@ describe("Concurrent Fetch Plugin", function() {
|
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
151
|
}));
|
|
152
|
-
it(
|
|
152
|
+
it('should retrieve the fetchcall in the pool', function() {
|
|
153
153
|
var plugin = new _concurrentfetch.ConcurrentFetch(3);
|
|
154
154
|
var call = new Promise(function(resolve) {
|
|
155
155
|
return setTimeout(function() {
|
|
@@ -166,7 +166,7 @@ describe("Concurrent Fetch Plugin", function() {
|
|
|
166
166
|
void plugin.load({}).transform(test);
|
|
167
167
|
expect(plugin.pool[2]).toBe(test);
|
|
168
168
|
});
|
|
169
|
-
it(
|
|
169
|
+
it('should start only when the pool is available', /*#__PURE__*/ _async_to_generator(function() {
|
|
170
170
|
var plugin, resolves, call0, call1, result, runner1, canStart1, runner2, pCanStart2;
|
|
171
171
|
return _ts_generator(this, function(_state) {
|
|
172
172
|
switch(_state.label){
|
|
@@ -128,14 +128,14 @@ function _ts_generator(thisArg, body) {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
describe(
|
|
132
|
-
it(
|
|
131
|
+
describe('Custom info reply plugin', function() {
|
|
132
|
+
it('should add the content of the custom information in the reply', /*#__PURE__*/ _async_to_generator(function() {
|
|
133
133
|
var customInfo, plugin, runner, newData;
|
|
134
134
|
return _ts_generator(this, function(_state) {
|
|
135
135
|
switch(_state.label){
|
|
136
136
|
case 0:
|
|
137
137
|
customInfo = {
|
|
138
|
-
key:
|
|
138
|
+
key: 'value',
|
|
139
139
|
nested: {
|
|
140
140
|
field: 10
|
|
141
141
|
}
|
|
@@ -152,7 +152,7 @@ describe("Custom info reply plugin", function() {
|
|
|
152
152
|
case 1:
|
|
153
153
|
newData = _state.sent();
|
|
154
154
|
expect(newData.customInfo).toEqual({
|
|
155
|
-
key:
|
|
155
|
+
key: 'value',
|
|
156
156
|
nested: {
|
|
157
157
|
field: 10
|
|
158
158
|
}
|
|
@@ -163,18 +163,18 @@ describe("Custom info reply plugin", function() {
|
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
165
|
}));
|
|
166
|
-
it(
|
|
166
|
+
it('should merge the contents of the two custom info', /*#__PURE__*/ _async_to_generator(function() {
|
|
167
167
|
var customInfo1, plugin1, customInfo2, plugin2, runner1, runner2, newData, _;
|
|
168
168
|
return _ts_generator(this, function(_state) {
|
|
169
169
|
switch(_state.label){
|
|
170
170
|
case 0:
|
|
171
171
|
customInfo1 = {
|
|
172
|
-
key0:
|
|
173
|
-
key1:
|
|
172
|
+
key0: 'dummy',
|
|
173
|
+
key1: 'value'
|
|
174
174
|
};
|
|
175
175
|
plugin1 = new _custominforeply.CustomInfoReply(customInfo1);
|
|
176
176
|
customInfo2 = {
|
|
177
|
-
key1:
|
|
177
|
+
key1: 'override',
|
|
178
178
|
key2: 42
|
|
179
179
|
};
|
|
180
180
|
plugin2 = new _custominforeply.CustomInfoReply(customInfo2);
|
|
@@ -201,8 +201,8 @@ describe("Custom info reply plugin", function() {
|
|
|
201
201
|
case 2:
|
|
202
202
|
newData = _state.sent();
|
|
203
203
|
expect(newData.customInfo).toEqual({
|
|
204
|
-
key0:
|
|
205
|
-
key1:
|
|
204
|
+
key0: 'dummy',
|
|
205
|
+
key1: 'override',
|
|
206
206
|
key2: 42
|
|
207
207
|
});
|
|
208
208
|
return [
|
|
@@ -211,19 +211,19 @@ describe("Custom info reply plugin", function() {
|
|
|
211
211
|
}
|
|
212
212
|
});
|
|
213
213
|
}));
|
|
214
|
-
it(
|
|
214
|
+
it('should invalidate custom info', function() {
|
|
215
215
|
var plugin = new _custominforeply.CustomInfoReply({});
|
|
216
216
|
var data = {
|
|
217
|
-
originalData:
|
|
217
|
+
originalData: 'OK'
|
|
218
218
|
};
|
|
219
219
|
expect(plugin.hasCustomInfo(data)).toBeFalsy();
|
|
220
220
|
});
|
|
221
|
-
it(
|
|
221
|
+
it('should validate custom info', function() {
|
|
222
222
|
var plugin = new _custominforeply.CustomInfoReply({});
|
|
223
223
|
var data = {
|
|
224
|
-
originalData:
|
|
224
|
+
originalData: 'OK',
|
|
225
225
|
customInfo: {
|
|
226
|
-
a:
|
|
226
|
+
a: 'b'
|
|
227
227
|
}
|
|
228
228
|
};
|
|
229
229
|
expect(plugin.hasCustomInfo(data)).toBeTruthy();
|
|
@@ -67,8 +67,8 @@ var ExceptionReply = /*#__PURE__*/ function() {
|
|
|
67
67
|
};
|
|
68
68
|
var error;
|
|
69
69
|
if (!context.response) {
|
|
70
|
-
error = new _errors.EmptyResponseError(
|
|
71
|
-
} else if (context.apiType === _api.ApiTypes.DAPI && context.response.status === 200 && (!res || !res.data && typeof res.errors !==
|
|
70
|
+
error = new _errors.EmptyResponseError('Fail to Fetch', undefined, errorContext);
|
|
71
|
+
} else if (context.apiType === _api.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
|
|
72
72
|
)) {
|
|
73
73
|
error = new _errors.EmptyResponseError(context.response.statusText, res, errorContext);
|
|
74
74
|
} else if (!context.response.ok) {
|
|
@@ -33,13 +33,13 @@ function _object_spread(target) {
|
|
|
33
33
|
}
|
|
34
34
|
return target;
|
|
35
35
|
}
|
|
36
|
-
describe(
|
|
36
|
+
describe('Exception Reply Plugin', function() {
|
|
37
37
|
var reviver = jest.fn();
|
|
38
38
|
var contextError = {
|
|
39
|
-
apiName:
|
|
40
|
-
operationId:
|
|
39
|
+
apiName: 'api',
|
|
40
|
+
operationId: 'ope'
|
|
41
41
|
};
|
|
42
|
-
it(
|
|
42
|
+
it('should throw on empty data and contains errors key if DAPI', function() {
|
|
43
43
|
var plugin = new _exceptionreply.ExceptionReply();
|
|
44
44
|
var runner = plugin.load(_object_spread({
|
|
45
45
|
reviver: reviver,
|
|
@@ -47,7 +47,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
47
47
|
response: {
|
|
48
48
|
ok: true,
|
|
49
49
|
status: 200,
|
|
50
|
-
statusText:
|
|
50
|
+
statusText: 'test'
|
|
51
51
|
}
|
|
52
52
|
}, contextError));
|
|
53
53
|
var data = {
|
|
@@ -55,9 +55,9 @@ describe("Exception Reply Plugin", function() {
|
|
|
55
55
|
};
|
|
56
56
|
expect(function() {
|
|
57
57
|
return runner.transform(data);
|
|
58
|
-
}).toThrow(new _errors.EmptyResponseError(
|
|
58
|
+
}).toThrow(new _errors.EmptyResponseError('test', data, contextError));
|
|
59
59
|
});
|
|
60
|
-
it(
|
|
60
|
+
it('should not throw on empty data and no errors key if DAPI', function() {
|
|
61
61
|
var plugin = new _exceptionreply.ExceptionReply();
|
|
62
62
|
var runner = plugin.load({
|
|
63
63
|
reviver: reviver,
|
|
@@ -65,7 +65,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
65
65
|
response: {
|
|
66
66
|
ok: true,
|
|
67
67
|
status: 200,
|
|
68
|
-
statusText:
|
|
68
|
+
statusText: 'test'
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
var data = {};
|
|
@@ -73,7 +73,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
73
73
|
return runner.transform(data);
|
|
74
74
|
}).not.toThrow();
|
|
75
75
|
});
|
|
76
|
-
it(
|
|
76
|
+
it('should not throw on empty data if not DAPI', function() {
|
|
77
77
|
var plugin = new _exceptionreply.ExceptionReply();
|
|
78
78
|
var runner = plugin.load({
|
|
79
79
|
reviver: reviver,
|
|
@@ -81,7 +81,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
81
81
|
response: {
|
|
82
82
|
ok: true,
|
|
83
83
|
status: 200,
|
|
84
|
-
statusText:
|
|
84
|
+
statusText: 'test'
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
var data = {};
|
|
@@ -89,7 +89,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
89
89
|
return runner.transform(data);
|
|
90
90
|
}).not.toThrow();
|
|
91
91
|
});
|
|
92
|
-
it(
|
|
92
|
+
it('should throw on nok status', function() {
|
|
93
93
|
var plugin = new _exceptionreply.ExceptionReply();
|
|
94
94
|
var runner = plugin.load(_object_spread({
|
|
95
95
|
reviver: reviver,
|
|
@@ -97,7 +97,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
97
97
|
response: {
|
|
98
98
|
ok: false,
|
|
99
99
|
status: 444,
|
|
100
|
-
statusText:
|
|
100
|
+
statusText: 'test'
|
|
101
101
|
}
|
|
102
102
|
}, contextError));
|
|
103
103
|
var data = {
|
|
@@ -105,9 +105,9 @@ describe("Exception Reply Plugin", function() {
|
|
|
105
105
|
};
|
|
106
106
|
expect(function() {
|
|
107
107
|
return runner.transform(data);
|
|
108
|
-
}).toThrow(new _errors.RequestFailedError(
|
|
108
|
+
}).toThrow(new _errors.RequestFailedError('test', 444, data, contextError));
|
|
109
109
|
});
|
|
110
|
-
it(
|
|
110
|
+
it('should not throw if there is already an exception', function() {
|
|
111
111
|
var plugin = new _exceptionreply.ExceptionReply();
|
|
112
112
|
var runner = plugin.load({
|
|
113
113
|
reviver: reviver,
|
|
@@ -115,7 +115,7 @@ describe("Exception Reply Plugin", function() {
|
|
|
115
115
|
response: {
|
|
116
116
|
ok: false,
|
|
117
117
|
status: 444,
|
|
118
|
-
statusText:
|
|
118
|
+
statusText: 'test'
|
|
119
119
|
},
|
|
120
120
|
exception: new Error()
|
|
121
121
|
});
|
|
@@ -94,7 +94,7 @@ var FetchCacheRequest = /*#__PURE__*/ function() {
|
|
|
94
94
|
*/ _define_property(this, "shouldAddCacheControlHeaders", void 0);
|
|
95
95
|
this.fetchCache = fetchCache;
|
|
96
96
|
this.cacheControl = cacheControl;
|
|
97
|
-
this.shouldAddCacheControlHeaders = typeof shouldAddCacheControlHeaders !==
|
|
97
|
+
this.shouldAddCacheControlHeaders = typeof shouldAddCacheControlHeaders !== 'undefined' ? shouldAddCacheControlHeaders : typeof fetch === 'undefined' || fetch.polyfill;
|
|
98
98
|
}
|
|
99
99
|
_create_class(FetchCacheRequest, [
|
|
100
100
|
{
|
|
@@ -104,9 +104,9 @@ var FetchCacheRequest = /*#__PURE__*/ function() {
|
|
|
104
104
|
return {
|
|
105
105
|
transform: function(data) {
|
|
106
106
|
if (_this.cacheControl && _this.shouldAddCacheControlHeaders) {
|
|
107
|
-
data.headers.set(
|
|
108
|
-
if (_this.cacheControl ===
|
|
109
|
-
data.headers.set(
|
|
107
|
+
data.headers.set('Cache-Control', "".concat(_this.cacheControl));
|
|
108
|
+
if (_this.cacheControl === 'no-cache') {
|
|
109
|
+
data.headers.set('Pragma', 'no-cache');
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
return _object_spread_props(_object_spread({}, data), {
|
|
@@ -127,7 +127,7 @@ function _ts_generator(thisArg, body) {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
describe(
|
|
130
|
+
describe('Fetch API cache Request Plugin', function() {
|
|
131
131
|
var globalFetchBackup;
|
|
132
132
|
beforeEach(function() {
|
|
133
133
|
globalFetchBackup = fetch;
|
|
@@ -135,88 +135,88 @@ describe("Fetch API cache Request Plugin", function() {
|
|
|
135
135
|
afterEach(function() {
|
|
136
136
|
global.fetch = globalFetchBackup;
|
|
137
137
|
});
|
|
138
|
-
it(
|
|
138
|
+
it('cache should be set correctly', /*#__PURE__*/ _async_to_generator(function() {
|
|
139
139
|
var options, plugin, cache;
|
|
140
140
|
return _ts_generator(this, function(_state) {
|
|
141
141
|
switch(_state.label){
|
|
142
142
|
case 0:
|
|
143
143
|
options = {
|
|
144
144
|
headers: new Headers(),
|
|
145
|
-
basePath:
|
|
146
|
-
method:
|
|
145
|
+
basePath: 'http://test.com/truc',
|
|
146
|
+
method: 'get'
|
|
147
147
|
};
|
|
148
|
-
plugin = new _fetchcacherequest.FetchCacheRequest(
|
|
148
|
+
plugin = new _fetchcacherequest.FetchCacheRequest('force-cache');
|
|
149
149
|
return [
|
|
150
150
|
4,
|
|
151
151
|
plugin.load().transform(options)
|
|
152
152
|
];
|
|
153
153
|
case 1:
|
|
154
154
|
cache = _state.sent().cache;
|
|
155
|
-
expect(cache).toBe(
|
|
155
|
+
expect(cache).toBe('force-cache');
|
|
156
156
|
return [
|
|
157
157
|
2
|
|
158
158
|
];
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
161
|
}));
|
|
162
|
-
it(
|
|
162
|
+
it('should set Cache-Control and Pragma header to no-cache in the request', /*#__PURE__*/ _async_to_generator(function() {
|
|
163
163
|
var options, plugin, headerCacheControl, headerPragma;
|
|
164
164
|
return _ts_generator(this, function(_state) {
|
|
165
165
|
switch(_state.label){
|
|
166
166
|
case 0:
|
|
167
167
|
options = {
|
|
168
168
|
headers: new Headers(),
|
|
169
|
-
basePath:
|
|
170
|
-
method:
|
|
169
|
+
basePath: 'http://test.com/truc',
|
|
170
|
+
method: 'get'
|
|
171
171
|
};
|
|
172
172
|
global.fetch = {
|
|
173
173
|
polyfill: true
|
|
174
174
|
};
|
|
175
|
-
plugin = new _fetchcacherequest.FetchCacheRequest(
|
|
175
|
+
plugin = new _fetchcacherequest.FetchCacheRequest('force-cache', 'no-cache');
|
|
176
176
|
return [
|
|
177
177
|
4,
|
|
178
178
|
plugin.load().transform(options)
|
|
179
179
|
];
|
|
180
180
|
case 1:
|
|
181
|
-
headerCacheControl = _state.sent().headers.get(
|
|
181
|
+
headerCacheControl = _state.sent().headers.get('Cache-Control');
|
|
182
182
|
return [
|
|
183
183
|
4,
|
|
184
184
|
plugin.load().transform(options)
|
|
185
185
|
];
|
|
186
186
|
case 2:
|
|
187
|
-
headerPragma = _state.sent().headers.get(
|
|
188
|
-
expect(headerCacheControl).toEqual(
|
|
189
|
-
expect(headerPragma).toEqual(
|
|
187
|
+
headerPragma = _state.sent().headers.get('Pragma');
|
|
188
|
+
expect(headerCacheControl).toEqual('no-cache');
|
|
189
|
+
expect(headerPragma).toEqual('no-cache');
|
|
190
190
|
return [
|
|
191
191
|
2
|
|
192
192
|
];
|
|
193
193
|
}
|
|
194
194
|
});
|
|
195
195
|
}));
|
|
196
|
-
it(
|
|
196
|
+
it('should not set Cache-Control header in the request', /*#__PURE__*/ _async_to_generator(function() {
|
|
197
197
|
var options, plugin, headerCacheControl, headerPragma;
|
|
198
198
|
return _ts_generator(this, function(_state) {
|
|
199
199
|
switch(_state.label){
|
|
200
200
|
case 0:
|
|
201
201
|
options = {
|
|
202
202
|
headers: new Headers(),
|
|
203
|
-
basePath:
|
|
204
|
-
method:
|
|
203
|
+
basePath: 'http://test.com/truc',
|
|
204
|
+
method: 'get'
|
|
205
205
|
};
|
|
206
206
|
global.fetch = function() {};
|
|
207
|
-
plugin = new _fetchcacherequest.FetchCacheRequest(
|
|
207
|
+
plugin = new _fetchcacherequest.FetchCacheRequest('force-cache', 'no-cache');
|
|
208
208
|
return [
|
|
209
209
|
4,
|
|
210
210
|
plugin.load().transform(options)
|
|
211
211
|
];
|
|
212
212
|
case 1:
|
|
213
|
-
headerCacheControl = _state.sent().headers.get(
|
|
213
|
+
headerCacheControl = _state.sent().headers.get('Cache-Control');
|
|
214
214
|
return [
|
|
215
215
|
4,
|
|
216
216
|
plugin.load().transform(options)
|
|
217
217
|
];
|
|
218
218
|
case 2:
|
|
219
|
-
headerPragma = _state.sent().headers.get(
|
|
219
|
+
headerPragma = _state.sent().headers.get('Pragma');
|
|
220
220
|
expect(headerCacheControl).toBeNull();
|
|
221
221
|
expect(headerPragma).toBeNull();
|
|
222
222
|
return [
|
|
@@ -43,7 +43,7 @@ function _define_property(obj, key, value) {
|
|
|
43
43
|
var FetchCredentialsRequest = /*#__PURE__*/ function() {
|
|
44
44
|
"use strict";
|
|
45
45
|
function FetchCredentialsRequest() {
|
|
46
|
-
var credentialsValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] :
|
|
46
|
+
var credentialsValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 'same-origin';
|
|
47
47
|
_class_call_check(this, FetchCredentialsRequest);
|
|
48
48
|
/**
|
|
49
49
|
* Value that will be set as the "credentials" option of the fetch API.
|
|
@@ -127,13 +127,13 @@ function _ts_generator(thisArg, body) {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
describe(
|
|
130
|
+
describe('Fetch API credentials Request Plugin', function() {
|
|
131
131
|
var options = {
|
|
132
132
|
headers: new Headers(),
|
|
133
|
-
basePath:
|
|
134
|
-
method:
|
|
133
|
+
basePath: 'http://test.com/truc',
|
|
134
|
+
method: 'get'
|
|
135
135
|
};
|
|
136
|
-
it(
|
|
136
|
+
it('credentials should be set to same-origin by default', /*#__PURE__*/ _async_to_generator(function() {
|
|
137
137
|
var plugin, runner, cred;
|
|
138
138
|
return _ts_generator(this, function(_state) {
|
|
139
139
|
switch(_state.label){
|
|
@@ -152,19 +152,19 @@ describe("Fetch API credentials Request Plugin", function() {
|
|
|
152
152
|
];
|
|
153
153
|
case 2:
|
|
154
154
|
cred = _state.sent().credentials;
|
|
155
|
-
expect(cred).toBe(
|
|
155
|
+
expect(cred).toBe('same-origin');
|
|
156
156
|
return [
|
|
157
157
|
2
|
|
158
158
|
];
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
161
|
}));
|
|
162
|
-
it(
|
|
162
|
+
it('credentials should be set correctly', /*#__PURE__*/ _async_to_generator(function() {
|
|
163
163
|
var plugin, runner, cred;
|
|
164
164
|
return _ts_generator(this, function(_state) {
|
|
165
165
|
switch(_state.label){
|
|
166
166
|
case 0:
|
|
167
|
-
plugin = new _fetchcredentialsrequest.FetchCredentialsRequest(
|
|
167
|
+
plugin = new _fetchcredentialsrequest.FetchCredentialsRequest('include');
|
|
168
168
|
runner = plugin.load();
|
|
169
169
|
return [
|
|
170
170
|
4,
|
|
@@ -178,7 +178,7 @@ describe("Fetch API credentials Request Plugin", function() {
|
|
|
178
178
|
];
|
|
179
179
|
case 2:
|
|
180
180
|
cred = _state.sent().credentials;
|
|
181
|
-
expect(cred).toBe(
|
|
181
|
+
expect(cred).toBe('include');
|
|
182
182
|
return [
|
|
183
183
|
2
|
|
184
184
|
];
|
|
@@ -43,7 +43,7 @@ function _define_property(obj, key, value) {
|
|
|
43
43
|
var JsonTokenReply = /*#__PURE__*/ function() {
|
|
44
44
|
"use strict";
|
|
45
45
|
function JsonTokenReply() {
|
|
46
|
-
var storageTokenKey = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] :
|
|
46
|
+
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] : {};
|
|
47
47
|
_class_call_check(this, JsonTokenReply);
|
|
48
48
|
_define_property(this, "storageTokenKey", void 0);
|
|
49
49
|
_define_property(this, "sharedMemory", void 0);
|
|
@@ -60,15 +60,15 @@ var JsonTokenReply = /*#__PURE__*/ function() {
|
|
|
60
60
|
if (!context.response) {
|
|
61
61
|
return data;
|
|
62
62
|
}
|
|
63
|
-
if (context.response.headers.has(
|
|
64
|
-
var token = context.response.headers.get(
|
|
65
|
-
if (typeof sessionStorage !==
|
|
63
|
+
if (context.response.headers.has('Authorization')) {
|
|
64
|
+
var token = context.response.headers.get('Authorization');
|
|
65
|
+
if (typeof sessionStorage !== 'undefined') {
|
|
66
66
|
sessionStorage.setItem(_this.storageTokenKey, token);
|
|
67
67
|
} else {
|
|
68
68
|
_this.sharedMemory[_this.storageTokenKey] = token;
|
|
69
69
|
}
|
|
70
70
|
} else {
|
|
71
|
-
if (typeof sessionStorage !==
|
|
71
|
+
if (typeof sessionStorage !== 'undefined') {
|
|
72
72
|
sessionStorage.removeItem(_this.storageTokenKey);
|
|
73
73
|
} else {
|
|
74
74
|
_this.sharedMemory[_this.storageTokenKey] = undefined;
|