@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
|
@@ -122,9 +122,9 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { RetryFetch } from
|
|
126
|
-
describe(
|
|
127
|
-
it(
|
|
125
|
+
import { RetryFetch } from './retry.fetch';
|
|
126
|
+
describe('Retry Fetch Plugin', function() {
|
|
127
|
+
it('should not retry on success', /*#__PURE__*/ _async_to_generator(function() {
|
|
128
128
|
var condition, plugin, runner, call, res, ret;
|
|
129
129
|
return _ts_generator(this, function(_state) {
|
|
130
130
|
switch(_state.label){
|
|
@@ -132,11 +132,11 @@ describe("Retry Fetch Plugin", function() {
|
|
|
132
132
|
condition = jest.fn().mockReturnValue(true);
|
|
133
133
|
plugin = new RetryFetch(1, condition);
|
|
134
134
|
runner = plugin.load({
|
|
135
|
-
url:
|
|
135
|
+
url: 'http://www.test.com',
|
|
136
136
|
fetchPlugins: []
|
|
137
137
|
});
|
|
138
138
|
call = Promise.resolve({
|
|
139
|
-
text:
|
|
139
|
+
text: 'test',
|
|
140
140
|
ok: true
|
|
141
141
|
});
|
|
142
142
|
res = runner.transform(call);
|
|
@@ -148,7 +148,7 @@ describe("Retry Fetch Plugin", function() {
|
|
|
148
148
|
case 1:
|
|
149
149
|
ret = _state.sent();
|
|
150
150
|
expect(ret).toEqual({
|
|
151
|
-
text:
|
|
151
|
+
text: 'test',
|
|
152
152
|
ok: true
|
|
153
153
|
});
|
|
154
154
|
return [
|
|
@@ -157,7 +157,7 @@ describe("Retry Fetch Plugin", function() {
|
|
|
157
157
|
}
|
|
158
158
|
});
|
|
159
159
|
}));
|
|
160
|
-
it(
|
|
160
|
+
it('should not retry if refused by the condition', /*#__PURE__*/ _async_to_generator(function() {
|
|
161
161
|
var conditionFalsy, plugin, runner, call, res;
|
|
162
162
|
return _ts_generator(this, function(_state) {
|
|
163
163
|
switch(_state.label){
|
|
@@ -165,11 +165,11 @@ describe("Retry Fetch Plugin", function() {
|
|
|
165
165
|
conditionFalsy = jest.fn().mockReturnValue(false);
|
|
166
166
|
plugin = new RetryFetch(3, conditionFalsy);
|
|
167
167
|
runner = plugin.load({
|
|
168
|
-
url:
|
|
168
|
+
url: 'http://www.test.com',
|
|
169
169
|
fetchPlugins: []
|
|
170
170
|
});
|
|
171
171
|
call = Promise.resolve({
|
|
172
|
-
text:
|
|
172
|
+
text: 'test',
|
|
173
173
|
ok: false,
|
|
174
174
|
clone: function() {
|
|
175
175
|
return {};
|
|
@@ -189,7 +189,7 @@ describe("Retry Fetch Plugin", function() {
|
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
191
|
}));
|
|
192
|
-
it(
|
|
192
|
+
it('should retry on fetch rejection', /*#__PURE__*/ _async_to_generator(function() {
|
|
193
193
|
var condition, plugin, runners, runner, call, callback;
|
|
194
194
|
return _ts_generator(this, function(_state) {
|
|
195
195
|
switch(_state.label){
|
|
@@ -198,12 +198,12 @@ describe("Retry Fetch Plugin", function() {
|
|
|
198
198
|
plugin = new RetryFetch(2, condition);
|
|
199
199
|
runners = [];
|
|
200
200
|
runner = plugin.load({
|
|
201
|
-
url:
|
|
201
|
+
url: 'not an url',
|
|
202
202
|
fetchPlugins: runners
|
|
203
203
|
});
|
|
204
204
|
runners.push(runner);
|
|
205
205
|
call = Promise.reject({
|
|
206
|
-
text:
|
|
206
|
+
text: 'test',
|
|
207
207
|
ok: true
|
|
208
208
|
});
|
|
209
209
|
callback = jest.fn();
|
|
@@ -222,7 +222,7 @@ describe("Retry Fetch Plugin", function() {
|
|
|
222
222
|
}
|
|
223
223
|
});
|
|
224
224
|
}));
|
|
225
|
-
it(
|
|
225
|
+
it('should retry on fetch rejection with wait', /*#__PURE__*/ _async_to_generator(function() {
|
|
226
226
|
var condition, delay, plugin, runners, runner, call, callback;
|
|
227
227
|
return _ts_generator(this, function(_state) {
|
|
228
228
|
switch(_state.label){
|
|
@@ -234,12 +234,12 @@ describe("Retry Fetch Plugin", function() {
|
|
|
234
234
|
});
|
|
235
235
|
runners = [];
|
|
236
236
|
runner = plugin.load({
|
|
237
|
-
url:
|
|
237
|
+
url: 'not an url',
|
|
238
238
|
fetchPlugins: runners
|
|
239
239
|
});
|
|
240
240
|
runners.push(runner);
|
|
241
241
|
call = Promise.reject({
|
|
242
|
-
text:
|
|
242
|
+
text: 'test',
|
|
243
243
|
ok: true
|
|
244
244
|
});
|
|
245
245
|
callback = jest.fn();
|
|
@@ -265,7 +265,7 @@ describe("Retry Fetch Plugin", function() {
|
|
|
265
265
|
}
|
|
266
266
|
});
|
|
267
267
|
}));
|
|
268
|
-
it(
|
|
268
|
+
it('should retry on not ok call', /*#__PURE__*/ _async_to_generator(function() {
|
|
269
269
|
var condition, plugin, runners, runner, call, callback;
|
|
270
270
|
return _ts_generator(this, function(_state) {
|
|
271
271
|
switch(_state.label){
|
|
@@ -274,12 +274,12 @@ describe("Retry Fetch Plugin", function() {
|
|
|
274
274
|
plugin = new RetryFetch(3, condition);
|
|
275
275
|
runners = [];
|
|
276
276
|
runner = plugin.load({
|
|
277
|
-
url:
|
|
277
|
+
url: 'not an url',
|
|
278
278
|
fetchPlugins: runners
|
|
279
279
|
});
|
|
280
280
|
runners.push(runner);
|
|
281
281
|
call = Promise.resolve({
|
|
282
|
-
text:
|
|
282
|
+
text: 'test',
|
|
283
283
|
ok: false
|
|
284
284
|
});
|
|
285
285
|
callback = jest.fn();
|
|
@@ -298,7 +298,7 @@ describe("Retry Fetch Plugin", function() {
|
|
|
298
298
|
}
|
|
299
299
|
});
|
|
300
300
|
}));
|
|
301
|
-
it(
|
|
301
|
+
it('should retry on not ok call with wait', /*#__PURE__*/ _async_to_generator(function() {
|
|
302
302
|
var condition, delay, plugin, runners, runner, call, callback;
|
|
303
303
|
return _ts_generator(this, function(_state) {
|
|
304
304
|
switch(_state.label){
|
|
@@ -310,12 +310,12 @@ describe("Retry Fetch Plugin", function() {
|
|
|
310
310
|
});
|
|
311
311
|
runners = [];
|
|
312
312
|
runner = plugin.load({
|
|
313
|
-
url:
|
|
313
|
+
url: 'not an url',
|
|
314
314
|
fetchPlugins: runners
|
|
315
315
|
});
|
|
316
316
|
runners.push(runner);
|
|
317
317
|
call = Promise.resolve({
|
|
318
|
-
text:
|
|
318
|
+
text: 'test',
|
|
319
319
|
ok: false
|
|
320
320
|
});
|
|
321
321
|
callback = jest.fn();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './reviver.reply';
|
|
@@ -122,11 +122,11 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { ApiTypes } from
|
|
126
|
-
import { ReviverReply } from
|
|
127
|
-
describe(
|
|
125
|
+
import { ApiTypes } from '../../fwk/api';
|
|
126
|
+
import { ReviverReply } from './reviver.reply';
|
|
127
|
+
describe('Reviver Reply Plugin', function() {
|
|
128
128
|
var reviver = jest.fn();
|
|
129
|
-
it(
|
|
129
|
+
it('should revive a specific data', /*#__PURE__*/ _async_to_generator(function() {
|
|
130
130
|
var plugin, runner, data;
|
|
131
131
|
return _ts_generator(this, function(_state) {
|
|
132
132
|
switch(_state.label){
|
|
@@ -151,7 +151,7 @@ describe("Reviver Reply Plugin", function() {
|
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
153
|
}));
|
|
154
|
-
it(
|
|
154
|
+
it('should revive a specific data and dictionary', /*#__PURE__*/ _async_to_generator(function() {
|
|
155
155
|
var dictionaries, plugin, runner, data;
|
|
156
156
|
return _ts_generator(this, function(_state) {
|
|
157
157
|
switch(_state.label){
|
|
@@ -178,7 +178,7 @@ describe("Reviver Reply Plugin", function() {
|
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
180
|
}));
|
|
181
|
-
it(
|
|
181
|
+
it('should revive empty object in case of undefined data', /*#__PURE__*/ _async_to_generator(function() {
|
|
182
182
|
var dictionaries, plugin, runner, transformedData;
|
|
183
183
|
return _ts_generator(this, function(_state) {
|
|
184
184
|
switch(_state.label){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './session-id.request';
|
|
@@ -30,7 +30,7 @@ function _define_property(obj, key, value) {
|
|
|
30
30
|
}
|
|
31
31
|
return obj;
|
|
32
32
|
}
|
|
33
|
-
import { v4 } from
|
|
33
|
+
import { v4 } from 'uuid';
|
|
34
34
|
/**
|
|
35
35
|
* Plugin to add a header with an ID that can be used to track all the calls done by one or several APIs of the SDK.
|
|
36
36
|
*
|
|
@@ -43,7 +43,7 @@ import { v4 } from "uuid";
|
|
|
43
43
|
*/ export var SessionIdRequest = /*#__PURE__*/ function() {
|
|
44
44
|
"use strict";
|
|
45
45
|
function SessionIdRequest() {
|
|
46
|
-
var sessionIdHeader = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] :
|
|
46
|
+
var sessionIdHeader = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 'Ama-Client-Ref', activateRequestId = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
47
47
|
_class_call_check(this, SessionIdRequest);
|
|
48
48
|
/**
|
|
49
49
|
* The request header in which the ID will be added. Use the same in multiple APIs if you want to aggregate logs
|
|
@@ -91,7 +91,7 @@ import { v4 } from "uuid";
|
|
|
91
91
|
return SessionIdRequest.sharedMemory[this.sessionIdHeader];
|
|
92
92
|
}
|
|
93
93
|
// if not, check if we have one in session storage
|
|
94
|
-
if (typeof sessionStorage !==
|
|
94
|
+
if (typeof sessionStorage !== 'undefined') {
|
|
95
95
|
var sessionIdObjectFromStorage = sessionStorage.getItem(this.sessionIdHeader);
|
|
96
96
|
if (sessionIdObjectFromStorage) {
|
|
97
97
|
try {
|
|
@@ -110,7 +110,7 @@ import { v4 } from "uuid";
|
|
|
110
110
|
this.logSessionId(sessionId, generatedTime, logger);
|
|
111
111
|
// and store it
|
|
112
112
|
SessionIdRequest.sharedMemory[this.sessionIdHeader] = sessionId;
|
|
113
|
-
if (typeof sessionStorage !==
|
|
113
|
+
if (typeof sessionStorage !== 'undefined') {
|
|
114
114
|
sessionStorage.setItem(this.sessionIdHeader, JSON.stringify({
|
|
115
115
|
id: sessionId,
|
|
116
116
|
generatedTime: generatedTime
|
|
@@ -124,19 +124,19 @@ import { v4 } from "uuid";
|
|
|
124
124
|
value: /**
|
|
125
125
|
* Generates a request ID.
|
|
126
126
|
*/ function generateRequestId() {
|
|
127
|
-
var requestCountKey = this.sessionIdHeader +
|
|
127
|
+
var requestCountKey = this.sessionIdHeader + '-Request-Count';
|
|
128
128
|
var requestCount = NaN;
|
|
129
129
|
// Check if we already have a request count in the shared memory or session storage
|
|
130
130
|
if (SessionIdRequest.sharedMemory[requestCountKey] !== undefined) {
|
|
131
131
|
requestCount = SessionIdRequest.sharedMemory[requestCountKey];
|
|
132
|
-
} else if (typeof sessionStorage !==
|
|
132
|
+
} else if (typeof sessionStorage !== 'undefined') {
|
|
133
133
|
requestCount = +(sessionStorage.getItem(requestCountKey) || NaN);
|
|
134
134
|
}
|
|
135
135
|
// If the request count is not defined yet or if it has been corrupted somehow, we start at 0.
|
|
136
136
|
requestCount = requestCount + 1 || 0;
|
|
137
137
|
// Store the new request count
|
|
138
138
|
SessionIdRequest.sharedMemory[requestCountKey] = requestCount;
|
|
139
|
-
if (typeof sessionStorage !==
|
|
139
|
+
if (typeof sessionStorage !== 'undefined') {
|
|
140
140
|
sessionStorage.setItem(requestCountKey, requestCount.toString());
|
|
141
141
|
}
|
|
142
142
|
return requestCount.toString(36);
|
|
@@ -122,19 +122,19 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { SessionIdRequest } from
|
|
126
|
-
describe(
|
|
125
|
+
import { SessionIdRequest } from './session-id.request';
|
|
126
|
+
describe('Session ID Request Plugin', function() {
|
|
127
127
|
var options;
|
|
128
|
-
var TEST_KEY =
|
|
129
|
-
var TEST_KEY2 =
|
|
128
|
+
var TEST_KEY = 'testKey';
|
|
129
|
+
var TEST_KEY2 = 'testKey2';
|
|
130
130
|
beforeEach(function() {
|
|
131
131
|
options = {
|
|
132
132
|
headers: new Headers(),
|
|
133
|
-
basePath:
|
|
134
|
-
method:
|
|
133
|
+
basePath: 'http://test.com/truc',
|
|
134
|
+
method: 'get'
|
|
135
135
|
};
|
|
136
136
|
});
|
|
137
|
-
it(
|
|
137
|
+
it('should have the default id to Ama-Client-Ref', /*#__PURE__*/ _async_to_generator(function() {
|
|
138
138
|
var plugin, runner, sessionId;
|
|
139
139
|
return _ts_generator(this, function(_state) {
|
|
140
140
|
switch(_state.label){
|
|
@@ -148,14 +148,14 @@ describe("Session ID Request Plugin", function() {
|
|
|
148
148
|
];
|
|
149
149
|
case 1:
|
|
150
150
|
_state.sent();
|
|
151
|
-
expect(options.headers.get(
|
|
151
|
+
expect(options.headers.get('Ama-Client-Ref')).toContain(sessionId);
|
|
152
152
|
return [
|
|
153
153
|
2
|
|
154
154
|
];
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
157
|
}));
|
|
158
|
-
it(
|
|
158
|
+
it('should add the session ID to the headers', /*#__PURE__*/ _async_to_generator(function() {
|
|
159
159
|
var plugin, runner, sessionId;
|
|
160
160
|
return _ts_generator(this, function(_state) {
|
|
161
161
|
switch(_state.label){
|
|
@@ -176,21 +176,21 @@ describe("Session ID Request Plugin", function() {
|
|
|
176
176
|
}
|
|
177
177
|
});
|
|
178
178
|
}));
|
|
179
|
-
it(
|
|
179
|
+
it('second plugin with same header should use the ID that\'s already in memory', function() {
|
|
180
180
|
var plugin = new SessionIdRequest(TEST_KEY);
|
|
181
181
|
var plugin2 = new SessionIdRequest(TEST_KEY);
|
|
182
182
|
plugin.load();
|
|
183
183
|
plugin2.load();
|
|
184
184
|
expect(plugin.sessionId).toBe(plugin2.sessionId);
|
|
185
185
|
});
|
|
186
|
-
it(
|
|
186
|
+
it('second plugin with different header should generate a new session ID', function() {
|
|
187
187
|
var plugin = new SessionIdRequest(TEST_KEY);
|
|
188
188
|
var plugin2 = new SessionIdRequest(TEST_KEY2);
|
|
189
189
|
plugin.load();
|
|
190
190
|
plugin2.load();
|
|
191
191
|
expect(plugin.sessionId).not.toBe(plugin2.sessionId);
|
|
192
192
|
});
|
|
193
|
-
it(
|
|
193
|
+
it('should generate a correctly formatted ID', /*#__PURE__*/ _async_to_generator(function() {
|
|
194
194
|
var plugin, runner, sessionId;
|
|
195
195
|
return _ts_generator(this, function(_state) {
|
|
196
196
|
switch(_state.label){
|
|
@@ -205,14 +205,14 @@ describe("Session ID Request Plugin", function() {
|
|
|
205
205
|
case 1:
|
|
206
206
|
_state.sent();
|
|
207
207
|
expect(sessionId).toMatch(/[a-zA-Z0-9-]{10,48}/);
|
|
208
|
-
expect(options.headers.get(
|
|
208
|
+
expect(options.headers.get('Ama-Client-Ref')).toMatch(new RegExp(sessionId + ':[0-9a-zA-Z]{1,10}'));
|
|
209
209
|
return [
|
|
210
210
|
2
|
|
211
211
|
];
|
|
212
212
|
}
|
|
213
213
|
});
|
|
214
214
|
}));
|
|
215
|
-
it(
|
|
215
|
+
it('should be possible to deactivate the request ID part', /*#__PURE__*/ _async_to_generator(function() {
|
|
216
216
|
var plugin, runner, sessionId;
|
|
217
217
|
return _ts_generator(this, function(_state) {
|
|
218
218
|
switch(_state.label){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './si-token.request';
|
|
@@ -82,7 +82,7 @@ function _create_super(Derived) {
|
|
|
82
82
|
return _possible_constructor_return(this, result);
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
import { AdditionalParamsRequest } from
|
|
85
|
+
import { AdditionalParamsRequest } from '../additional-params';
|
|
86
86
|
/**
|
|
87
87
|
* Plugin to send the SI Tokens with the request
|
|
88
88
|
*/ export var SiTokenRequest = /*#__PURE__*/ function(AdditionalParamsRequest) {
|
|
@@ -122,28 +122,28 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { SiTokenRequest } from
|
|
126
|
-
describe(
|
|
125
|
+
import { SiTokenRequest } from './si-token.request';
|
|
126
|
+
describe('SI Token Request Plugin', function() {
|
|
127
127
|
var defaultGetParams = {
|
|
128
|
-
defaultTest:
|
|
128
|
+
defaultTest: 'ok'
|
|
129
129
|
};
|
|
130
|
-
var defaultBody =
|
|
130
|
+
var defaultBody = 'default';
|
|
131
131
|
var options;
|
|
132
132
|
beforeEach(function() {
|
|
133
133
|
options = {
|
|
134
|
-
method:
|
|
134
|
+
method: 'get',
|
|
135
135
|
queryParams: defaultGetParams,
|
|
136
136
|
headers: new Headers(),
|
|
137
137
|
body: defaultBody,
|
|
138
|
-
basePath:
|
|
138
|
+
basePath: 'http://test.com/truc'
|
|
139
139
|
};
|
|
140
140
|
});
|
|
141
|
-
it(
|
|
141
|
+
it('should add a specified SI Tokens in query params', /*#__PURE__*/ _async_to_generator(function() {
|
|
142
142
|
var plugin, runner, result;
|
|
143
143
|
return _ts_generator(this, function(_state) {
|
|
144
144
|
switch(_state.label){
|
|
145
145
|
case 0:
|
|
146
|
-
plugin = new SiTokenRequest(
|
|
146
|
+
plugin = new SiTokenRequest('SIToken1', 'SIToken2');
|
|
147
147
|
runner = plugin.load();
|
|
148
148
|
return [
|
|
149
149
|
4,
|
|
@@ -151,8 +151,8 @@ describe("SI Token Request Plugin", function() {
|
|
|
151
151
|
];
|
|
152
152
|
case 1:
|
|
153
153
|
result = _state.sent();
|
|
154
|
-
expect(result.queryParams.SITK).toBe(
|
|
155
|
-
expect(result.queryParams.SITK2).toBe(
|
|
154
|
+
expect(result.queryParams.SITK).toBe('SIToken1');
|
|
155
|
+
expect(result.queryParams.SITK2).toBe('SIToken2');
|
|
156
156
|
return [
|
|
157
157
|
2
|
|
158
158
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './simple-api-key-authentication.request';
|
package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js
CHANGED
|
@@ -169,12 +169,12 @@ function _ts_generator(thisArg, body) {
|
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
import { createJwtEncoder } from
|
|
172
|
+
import { createJwtEncoder } from '../../utils/json-token';
|
|
173
173
|
/**
|
|
174
174
|
* Default values of optional parameters
|
|
175
175
|
*/ var DEFAULT_OPTION = {
|
|
176
|
-
apiKeyHeader:
|
|
177
|
-
contextHeader:
|
|
176
|
+
apiKeyHeader: 'x-api-key',
|
|
177
|
+
contextHeader: 'ama-ctx'
|
|
178
178
|
};
|
|
179
179
|
/**
|
|
180
180
|
* Plugin to handle the Simple API key authentication with Apigee.
|
|
@@ -266,7 +266,7 @@ import { createJwtEncoder } from "../../utils/json-token";
|
|
|
266
266
|
_tmp = [
|
|
267
267
|
_this.options.apiKeyHeader
|
|
268
268
|
];
|
|
269
|
-
if (!(typeof _this.apiKey ===
|
|
269
|
+
if (!(typeof _this.apiKey === 'string')) return [
|
|
270
270
|
3,
|
|
271
271
|
1
|
|
272
272
|
];
|
|
@@ -291,7 +291,7 @@ import { createJwtEncoder } from "../../utils/json-token";
|
|
|
291
291
|
3,
|
|
292
292
|
7
|
|
293
293
|
];
|
|
294
|
-
if (!(typeof _this.options.officeId ===
|
|
294
|
+
if (!(typeof _this.options.officeId === 'string')) return [
|
|
295
295
|
3,
|
|
296
296
|
4
|
|
297
297
|
];
|