@ama-sdk/core 12.1.8 → 12.1.11
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 +13 -18
- package/cjs/clients/api-fetch-client.js +16 -21
- package/cjs/fwk/api.helpers.js +11 -11
- package/cjs/fwk/date.js +5 -5
- package/cjs/fwk/errors.js +7 -7
- package/cjs/fwk/mocks/alf-mock-adapter.js +58 -60
- package/cjs/fwk/mocks/base-mock-adapter.js +15 -19
- package/cjs/fwk/mocks/helpers.js +3 -3
- package/cjs/fwk/param-serialization.js +6 -6
- package/cjs/fwk/reviver.js +4 -4
- package/cjs/plugins/abort/abort.spec.js +83 -81
- package/cjs/plugins/additional-params/additional-params.request.js +18 -25
- package/cjs/plugins/additional-params/additional-params.spec.js +194 -186
- package/cjs/plugins/api-configuration-override/api-configuration-override.request.js +10 -17
- package/cjs/plugins/api-configuration-override/api-configuration-override.spec.js +83 -81
- package/cjs/plugins/api-key/api-key.request.js +12 -19
- package/cjs/plugins/api-key/api-key.spec.js +50 -50
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +25 -36
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +343 -327
- package/cjs/plugins/client-facts/client-facts.request.js +18 -25
- package/cjs/plugins/client-facts/client-facts.spec.js +218 -208
- package/cjs/plugins/concurrent/concurrent.fetch.js +12 -20
- package/cjs/plugins/concurrent/concurrent.spec.js +99 -99
- package/cjs/plugins/custom-info/custom-info.spec.js +90 -90
- package/cjs/plugins/fetch-cache/fetch-cache.spec.js +100 -98
- package/cjs/plugins/fetch-credentials/fetch-credentials.spec.js +60 -60
- package/cjs/plugins/json-token/json-token.spec.js +109 -107
- package/cjs/plugins/keepalive/keepalive.request.js +7 -12
- package/cjs/plugins/keepalive/keepalive.spec.js +32 -34
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js +11 -23
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +18 -28
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +212 -204
- package/cjs/plugins/mock-intercept/mock-intercept.angular.js +94 -100
- package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +15 -22
- package/cjs/plugins/mock-intercept/mock-intercept.interface.js +3 -3
- package/cjs/plugins/mock-intercept/mock-intercept.request.js +12 -19
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +245 -237
- package/cjs/plugins/perf-metric/perf-metric.fetch.js +11 -18
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.request.js +19 -27
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.spec.js +404 -386
- package/cjs/plugins/raw-response-info/raw-response-info.spec.js +67 -67
- package/cjs/plugins/retry/retry.fetch.js +18 -27
- package/cjs/plugins/retry/retry.spec.js +233 -225
- package/cjs/plugins/reviver/reviver.spec.js +88 -86
- package/cjs/plugins/session-id/session-id.spec.js +98 -94
- package/cjs/plugins/si-token/si-token.spec.js +27 -29
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +17 -24
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +199 -191
- package/cjs/plugins/timeout/timeout.fetch.js +16 -22
- package/cjs/plugins/timeout/timeout.spec.js +211 -205
- package/cjs/plugins/url-rewrite/url-rewrite.request.js +9 -16
- package/cjs/plugins/url-rewrite/url-rewrite.spec.js +48 -48
- package/cjs/plugins/wait-for/wait-for.fetch.js +19 -29
- package/cjs/plugins/wait-for/wait-for.spec.js +211 -203
- package/cjs/utils/crypto.js +15 -27
- package/cjs/utils/generic-api.js +9 -14
- package/cjs/utils/json-token.js +19 -26
- package/cjs/utils/json-token.spec.js +495 -497
- package/cjs/utils/mime-types.js +3 -3
- package/esm2015/clients/api-angular-client.js +13 -18
- package/esm2015/clients/api-fetch-client.js +16 -21
- package/esm2015/fwk/mocks/alf-mock-adapter.js +58 -60
- package/esm2015/fwk/mocks/base-mock-adapter.js +15 -19
- package/esm2015/plugins/abort/abort.spec.js +83 -81
- package/esm2015/plugins/additional-params/additional-params.request.js +15 -22
- package/esm2015/plugins/additional-params/additional-params.spec.js +194 -186
- package/esm2015/plugins/api-configuration-override/api-configuration-override.request.js +10 -17
- package/esm2015/plugins/api-configuration-override/api-configuration-override.spec.js +83 -81
- package/esm2015/plugins/api-key/api-key.request.js +12 -19
- package/esm2015/plugins/api-key/api-key.spec.js +50 -50
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +21 -32
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +343 -327
- package/esm2015/plugins/client-facts/client-facts.request.js +15 -22
- package/esm2015/plugins/client-facts/client-facts.spec.js +218 -208
- package/esm2015/plugins/concurrent/concurrent.fetch.js +12 -20
- package/esm2015/plugins/concurrent/concurrent.spec.js +99 -99
- package/esm2015/plugins/custom-info/custom-info.spec.js +90 -90
- package/esm2015/plugins/fetch-cache/fetch-cache.spec.js +100 -98
- package/esm2015/plugins/fetch-credentials/fetch-credentials.spec.js +60 -60
- package/esm2015/plugins/json-token/json-token.spec.js +109 -107
- package/esm2015/plugins/keepalive/keepalive.request.js +7 -12
- package/esm2015/plugins/keepalive/keepalive.spec.js +32 -34
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js +8 -20
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +18 -28
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +212 -204
- package/esm2015/plugins/mock-intercept/mock-intercept.angular.js +94 -100
- package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +15 -22
- package/esm2015/plugins/mock-intercept/mock-intercept.request.js +12 -19
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +245 -237
- package/esm2015/plugins/perf-metric/perf-metric.fetch.js +11 -18
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.request.js +15 -23
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.spec.js +404 -386
- package/esm2015/plugins/raw-response-info/raw-response-info.spec.js +67 -67
- package/esm2015/plugins/retry/retry.fetch.js +18 -27
- package/esm2015/plugins/retry/retry.spec.js +233 -225
- package/esm2015/plugins/reviver/reviver.spec.js +88 -86
- package/esm2015/plugins/session-id/session-id.spec.js +98 -94
- package/esm2015/plugins/si-token/si-token.spec.js +27 -29
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +17 -24
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +199 -191
- package/esm2015/plugins/timeout/timeout.fetch.js +13 -19
- package/esm2015/plugins/timeout/timeout.spec.js +211 -205
- package/esm2015/plugins/url-rewrite/url-rewrite.request.js +9 -16
- package/esm2015/plugins/url-rewrite/url-rewrite.spec.js +48 -48
- package/esm2015/plugins/wait-for/wait-for.fetch.js +19 -29
- package/esm2015/plugins/wait-for/wait-for.spec.js +211 -203
- package/esm2015/utils/crypto.js +8 -20
- package/esm2015/utils/generic-api.js +9 -14
- package/esm2015/utils/json-token.js +10 -17
- package/esm2015/utils/json-token.spec.js +495 -497
- package/package.json +6 -6
|
@@ -28,7 +28,7 @@ function _async_to_generator(fn) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
function _ts_generator(thisArg, body) {
|
|
31
|
-
var f, y, t,
|
|
31
|
+
var f, y, t, _ = {
|
|
32
32
|
label: 0,
|
|
33
33
|
sent: function() {
|
|
34
34
|
if (t[0] & 1) throw t[1];
|
|
@@ -36,12 +36,8 @@ function _ts_generator(thisArg, body) {
|
|
|
36
36
|
},
|
|
37
37
|
trys: [],
|
|
38
38
|
ops: []
|
|
39
|
-
};
|
|
40
|
-
return g = {
|
|
41
|
-
next: verb(0),
|
|
42
|
-
"throw": verb(1),
|
|
43
|
-
"return": verb(2)
|
|
44
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
39
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
40
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
45
41
|
return this;
|
|
46
42
|
}), g;
|
|
47
43
|
function verb(n) {
|
|
@@ -54,7 +50,7 @@ function _ts_generator(thisArg, body) {
|
|
|
54
50
|
}
|
|
55
51
|
function step(op) {
|
|
56
52
|
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
-
while(_)try {
|
|
53
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
58
54
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
59
55
|
if (y = 0, t) op = [
|
|
60
56
|
op[0] & 2,
|
|
@@ -131,94 +127,100 @@ describe('Fetch API cache Request Plugin', function() {
|
|
|
131
127
|
afterEach(function() {
|
|
132
128
|
global.fetch = globalFetchBackup;
|
|
133
129
|
});
|
|
134
|
-
it('cache should be set correctly',
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
plugin
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
130
|
+
it('cache should be set correctly', function() {
|
|
131
|
+
return _async_to_generator(function() {
|
|
132
|
+
var options, plugin, cache;
|
|
133
|
+
return _ts_generator(this, function(_state) {
|
|
134
|
+
switch(_state.label){
|
|
135
|
+
case 0:
|
|
136
|
+
options = {
|
|
137
|
+
headers: new Headers(),
|
|
138
|
+
basePath: 'http://test.com/truc',
|
|
139
|
+
method: 'get'
|
|
140
|
+
};
|
|
141
|
+
plugin = new FetchCacheRequest('force-cache');
|
|
142
|
+
return [
|
|
143
|
+
4,
|
|
144
|
+
plugin.load().transform(options)
|
|
145
|
+
];
|
|
146
|
+
case 1:
|
|
147
|
+
cache = _state.sent().cache;
|
|
148
|
+
expect(cache).toBe('force-cache');
|
|
149
|
+
return [
|
|
150
|
+
2
|
|
151
|
+
];
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
})();
|
|
155
|
+
});
|
|
156
|
+
it('should set Cache-Control and Pragma header to no-cache in the request', function() {
|
|
157
|
+
return _async_to_generator(function() {
|
|
158
|
+
var options, plugin, headerCacheControl, headerPragma;
|
|
159
|
+
return _ts_generator(this, function(_state) {
|
|
160
|
+
switch(_state.label){
|
|
161
|
+
case 0:
|
|
162
|
+
options = {
|
|
163
|
+
headers: new Headers(),
|
|
164
|
+
basePath: 'http://test.com/truc',
|
|
165
|
+
method: 'get'
|
|
166
|
+
};
|
|
167
|
+
global.fetch = {
|
|
168
|
+
polyfill: true
|
|
169
|
+
};
|
|
170
|
+
plugin = new FetchCacheRequest('force-cache', 'no-cache');
|
|
171
|
+
return [
|
|
172
|
+
4,
|
|
173
|
+
plugin.load().transform(options)
|
|
174
|
+
];
|
|
175
|
+
case 1:
|
|
176
|
+
headerCacheControl = _state.sent().headers.get('Cache-Control');
|
|
177
|
+
return [
|
|
178
|
+
4,
|
|
179
|
+
plugin.load().transform(options)
|
|
180
|
+
];
|
|
181
|
+
case 2:
|
|
182
|
+
headerPragma = _state.sent().headers.get('Pragma');
|
|
183
|
+
expect(headerCacheControl).toEqual('no-cache');
|
|
184
|
+
expect(headerPragma).toEqual('no-cache');
|
|
185
|
+
return [
|
|
186
|
+
2
|
|
187
|
+
];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
})();
|
|
191
|
+
});
|
|
192
|
+
it('should not set Cache-Control header in the request', function() {
|
|
193
|
+
return _async_to_generator(function() {
|
|
194
|
+
var options, plugin, headerCacheControl, headerPragma;
|
|
195
|
+
return _ts_generator(this, function(_state) {
|
|
196
|
+
switch(_state.label){
|
|
197
|
+
case 0:
|
|
198
|
+
options = {
|
|
199
|
+
headers: new Headers(),
|
|
200
|
+
basePath: 'http://test.com/truc',
|
|
201
|
+
method: 'get'
|
|
202
|
+
};
|
|
203
|
+
global.fetch = function() {};
|
|
204
|
+
plugin = new FetchCacheRequest('force-cache', 'no-cache');
|
|
205
|
+
return [
|
|
206
|
+
4,
|
|
207
|
+
plugin.load().transform(options)
|
|
208
|
+
];
|
|
209
|
+
case 1:
|
|
210
|
+
headerCacheControl = _state.sent().headers.get('Cache-Control');
|
|
211
|
+
return [
|
|
212
|
+
4,
|
|
213
|
+
plugin.load().transform(options)
|
|
214
|
+
];
|
|
215
|
+
case 2:
|
|
216
|
+
headerPragma = _state.sent().headers.get('Pragma');
|
|
217
|
+
expect(headerCacheControl).toBeNull();
|
|
218
|
+
expect(headerPragma).toBeNull();
|
|
219
|
+
return [
|
|
220
|
+
2
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
})();
|
|
225
|
+
});
|
|
224
226
|
});
|
|
@@ -28,7 +28,7 @@ function _async_to_generator(fn) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
function _ts_generator(thisArg, body) {
|
|
31
|
-
var f, y, t,
|
|
31
|
+
var f, y, t, _ = {
|
|
32
32
|
label: 0,
|
|
33
33
|
sent: function() {
|
|
34
34
|
if (t[0] & 1) throw t[1];
|
|
@@ -36,12 +36,8 @@ function _ts_generator(thisArg, body) {
|
|
|
36
36
|
},
|
|
37
37
|
trys: [],
|
|
38
38
|
ops: []
|
|
39
|
-
};
|
|
40
|
-
return g = {
|
|
41
|
-
next: verb(0),
|
|
42
|
-
"throw": verb(1),
|
|
43
|
-
"return": verb(2)
|
|
44
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
39
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
40
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
45
41
|
return this;
|
|
46
42
|
}), g;
|
|
47
43
|
function verb(n) {
|
|
@@ -54,7 +50,7 @@ function _ts_generator(thisArg, body) {
|
|
|
54
50
|
}
|
|
55
51
|
function step(op) {
|
|
56
52
|
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
-
while(_)try {
|
|
53
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
58
54
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
59
55
|
if (y = 0, t) op = [
|
|
60
56
|
op[0] & 2,
|
|
@@ -129,56 +125,60 @@ describe('Fetch API credentials Request Plugin', function() {
|
|
|
129
125
|
basePath: 'http://test.com/truc',
|
|
130
126
|
method: 'get'
|
|
131
127
|
};
|
|
132
|
-
it('credentials should be set to same-origin by default',
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
runner.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
128
|
+
it('credentials should be set to same-origin by default', function() {
|
|
129
|
+
return _async_to_generator(function() {
|
|
130
|
+
var plugin, runner, _ref, cred;
|
|
131
|
+
return _ts_generator(this, function(_state) {
|
|
132
|
+
switch(_state.label){
|
|
133
|
+
case 0:
|
|
134
|
+
plugin = new FetchCredentialsRequest();
|
|
135
|
+
runner = plugin.load();
|
|
136
|
+
return [
|
|
137
|
+
4,
|
|
138
|
+
runner.transform(options)
|
|
139
|
+
];
|
|
140
|
+
case 1:
|
|
141
|
+
_state.sent();
|
|
142
|
+
return [
|
|
143
|
+
4,
|
|
144
|
+
plugin.load().transform(options)
|
|
145
|
+
];
|
|
146
|
+
case 2:
|
|
147
|
+
_ref = _state.sent(), cred = _ref.credentials;
|
|
148
|
+
expect(cred).toBe('same-origin');
|
|
149
|
+
return [
|
|
150
|
+
2
|
|
151
|
+
];
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
})();
|
|
155
|
+
});
|
|
156
|
+
it('credentials should be set correctly', function() {
|
|
157
|
+
return _async_to_generator(function() {
|
|
158
|
+
var plugin, runner, _ref, cred;
|
|
159
|
+
return _ts_generator(this, function(_state) {
|
|
160
|
+
switch(_state.label){
|
|
161
|
+
case 0:
|
|
162
|
+
plugin = new FetchCredentialsRequest('include');
|
|
163
|
+
runner = plugin.load();
|
|
164
|
+
return [
|
|
165
|
+
4,
|
|
166
|
+
runner.transform(options)
|
|
167
|
+
];
|
|
168
|
+
case 1:
|
|
169
|
+
_state.sent();
|
|
170
|
+
return [
|
|
171
|
+
4,
|
|
172
|
+
plugin.load().transform(options)
|
|
173
|
+
];
|
|
174
|
+
case 2:
|
|
175
|
+
_ref = _state.sent(), cred = _ref.credentials;
|
|
176
|
+
expect(cred).toBe('include');
|
|
177
|
+
return [
|
|
178
|
+
2
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
})();
|
|
183
|
+
});
|
|
184
184
|
});
|
|
@@ -28,7 +28,7 @@ function _async_to_generator(fn) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
function _ts_generator(thisArg, body) {
|
|
31
|
-
var f, y, t,
|
|
31
|
+
var f, y, t, _ = {
|
|
32
32
|
label: 0,
|
|
33
33
|
sent: function() {
|
|
34
34
|
if (t[0] & 1) throw t[1];
|
|
@@ -36,12 +36,8 @@ function _ts_generator(thisArg, body) {
|
|
|
36
36
|
},
|
|
37
37
|
trys: [],
|
|
38
38
|
ops: []
|
|
39
|
-
};
|
|
40
|
-
return g = {
|
|
41
|
-
next: verb(0),
|
|
42
|
-
"throw": verb(1),
|
|
43
|
-
"return": verb(2)
|
|
44
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
39
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
40
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
45
41
|
return this;
|
|
46
42
|
}), g;
|
|
47
43
|
function verb(n) {
|
|
@@ -54,7 +50,7 @@ function _ts_generator(thisArg, body) {
|
|
|
54
50
|
}
|
|
55
51
|
function step(op) {
|
|
56
52
|
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
-
while(_)try {
|
|
53
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
58
54
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
59
55
|
if (y = 0, t) op = [
|
|
60
56
|
op[0] & 2,
|
|
@@ -143,108 +139,114 @@ describe('Json Token', function() {
|
|
|
143
139
|
basePath: 'http://test.com/truc'
|
|
144
140
|
};
|
|
145
141
|
});
|
|
146
|
-
it('should add Authorization header',
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
142
|
+
it('should add Authorization header', function() {
|
|
143
|
+
return _async_to_generator(function() {
|
|
144
|
+
var memory, plugin, runner, result;
|
|
145
|
+
return _ts_generator(this, function(_state) {
|
|
146
|
+
switch(_state.label){
|
|
147
|
+
case 0:
|
|
148
|
+
memory = {
|
|
149
|
+
testToken: tokenValue
|
|
150
|
+
};
|
|
151
|
+
plugin = new JsonTokenRequest(tokenKey, memory);
|
|
152
|
+
runner = plugin.load();
|
|
153
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
154
|
+
jest.spyOn(window.sessionStorage, 'getItem').mockImplementation(function() {
|
|
155
|
+
return tokenValue;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return [
|
|
159
|
+
4,
|
|
160
|
+
runner.transform(options)
|
|
161
|
+
];
|
|
162
|
+
case 1:
|
|
163
|
+
result = _state.sent();
|
|
164
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
165
|
+
/* eslint-disable jest/no-conditional-expect -- the same condition is verified above to set up the checked spy */ expect(window.sessionStorage.getItem).toHaveBeenCalledWith(tokenKey);
|
|
166
|
+
/* eslint-enable jest/no-conditional-expect */ }
|
|
167
|
+
expect(result.credentials).toBe('same-origin');
|
|
168
|
+
expect(result.headers.get('Authorization')).toBe(tokenValue);
|
|
169
|
+
return [
|
|
170
|
+
2
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
})();
|
|
175
|
+
});
|
|
176
|
+
it('should not add Authorization if no token', function() {
|
|
177
|
+
return _async_to_generator(function() {
|
|
178
|
+
var memory, plugin, runner, result;
|
|
179
|
+
return _ts_generator(this, function(_state) {
|
|
180
|
+
switch(_state.label){
|
|
181
|
+
case 0:
|
|
182
|
+
memory = {
|
|
183
|
+
testToken: undefined
|
|
184
|
+
};
|
|
185
|
+
plugin = new JsonTokenRequest(tokenKey, memory);
|
|
186
|
+
runner = plugin.load();
|
|
187
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
188
|
+
jest.spyOn(window.sessionStorage, 'getItem').mockImplementation();
|
|
189
|
+
}
|
|
190
|
+
return [
|
|
191
|
+
4,
|
|
192
|
+
runner.transform(options)
|
|
193
|
+
];
|
|
194
|
+
case 1:
|
|
195
|
+
result = _state.sent();
|
|
196
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
197
|
+
/* eslint-disable jest/no-conditional-expect -- the same condition is verified above to set up the checked spy */ expect(window.sessionStorage.getItem).toHaveBeenCalledWith(tokenKey);
|
|
198
|
+
/* eslint-enable jest/no-conditional-expect */ }
|
|
199
|
+
expect(result.credentials).toBeUndefined();
|
|
200
|
+
expect(result.headers.get('Authorization')).toBeNull();
|
|
201
|
+
return [
|
|
202
|
+
2
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
})();
|
|
207
|
+
});
|
|
208
208
|
});
|
|
209
209
|
describe('reply plugin', function() {
|
|
210
210
|
var reviver = jest.fn();
|
|
211
|
-
it('should store the received token',
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
211
|
+
it('should store the received token', function() {
|
|
212
|
+
return _async_to_generator(function() {
|
|
213
|
+
var memory, plugin, runner, data;
|
|
214
|
+
return _ts_generator(this, function(_state) {
|
|
215
|
+
switch(_state.label){
|
|
216
|
+
case 0:
|
|
217
|
+
memory = {
|
|
218
|
+
testToken: undefined
|
|
219
|
+
};
|
|
220
|
+
plugin = new JsonTokenReply(tokenKey, memory);
|
|
221
|
+
runner = plugin.load({
|
|
222
|
+
reviver: reviver,
|
|
223
|
+
apiType: ApiTypes.DEFAULT,
|
|
224
|
+
response: {
|
|
225
|
+
headers: new Headers({
|
|
226
|
+
Authorization: tokenValue
|
|
227
|
+
})
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
data = {};
|
|
231
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
232
|
+
jest.spyOn(window.sessionStorage, 'setItem').mockImplementation();
|
|
227
233
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
];
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
}));
|
|
234
|
+
return [
|
|
235
|
+
4,
|
|
236
|
+
runner.transform(data)
|
|
237
|
+
];
|
|
238
|
+
case 1:
|
|
239
|
+
_state.sent();
|
|
240
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
241
|
+
/* eslint-disable jest/no-conditional-expect -- the same condition is verified above to set up the checked spy */ expect(window.sessionStorage.setItem).toHaveBeenCalledWith(tokenKey, tokenValue);
|
|
242
|
+
/* eslint-enable jest/no-conditional-expect */ }
|
|
243
|
+
expect(memory.testToken).toBe(tokenValue);
|
|
244
|
+
return [
|
|
245
|
+
2
|
|
246
|
+
];
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
})();
|
|
250
|
+
});
|
|
249
251
|
});
|
|
250
252
|
});
|