@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
|
@@ -33,7 +33,7 @@ function _async_to_generator(fn) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
function _ts_generator(thisArg, body) {
|
|
36
|
-
var f, y, t,
|
|
36
|
+
var f, y, t, _ = {
|
|
37
37
|
label: 0,
|
|
38
38
|
sent: function() {
|
|
39
39
|
if (t[0] & 1) throw t[1];
|
|
@@ -41,12 +41,8 @@ function _ts_generator(thisArg, body) {
|
|
|
41
41
|
},
|
|
42
42
|
trys: [],
|
|
43
43
|
ops: []
|
|
44
|
-
};
|
|
45
|
-
return g = {
|
|
46
|
-
next: verb(0),
|
|
47
|
-
"throw": verb(1),
|
|
48
|
-
"return": verb(2)
|
|
49
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
44
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
45
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
50
46
|
return this;
|
|
51
47
|
}), g;
|
|
52
48
|
function verb(n) {
|
|
@@ -59,7 +55,7 @@ function _ts_generator(thisArg, body) {
|
|
|
59
55
|
}
|
|
60
56
|
function step(op) {
|
|
61
57
|
if (f) throw new TypeError("Generator is already executing.");
|
|
62
|
-
while(_)try {
|
|
58
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
63
59
|
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;
|
|
64
60
|
if (y = 0, t) op = [
|
|
65
61
|
op[0] & 2,
|
|
@@ -135,94 +131,100 @@ describe('Fetch API cache Request Plugin', function() {
|
|
|
135
131
|
afterEach(function() {
|
|
136
132
|
global.fetch = globalFetchBackup;
|
|
137
133
|
});
|
|
138
|
-
it('cache should be set correctly',
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
plugin.
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
134
|
+
it('cache should be set correctly', function() {
|
|
135
|
+
return _async_to_generator(function() {
|
|
136
|
+
var options, plugin, cache;
|
|
137
|
+
return _ts_generator(this, function(_state) {
|
|
138
|
+
switch(_state.label){
|
|
139
|
+
case 0:
|
|
140
|
+
options = {
|
|
141
|
+
headers: new Headers(),
|
|
142
|
+
basePath: 'http://test.com/truc',
|
|
143
|
+
method: 'get'
|
|
144
|
+
};
|
|
145
|
+
plugin = new _fetchcacherequest.FetchCacheRequest('force-cache');
|
|
146
|
+
return [
|
|
147
|
+
4,
|
|
148
|
+
plugin.load().transform(options)
|
|
149
|
+
];
|
|
150
|
+
case 1:
|
|
151
|
+
cache = _state.sent().cache;
|
|
152
|
+
expect(cache).toBe('force-cache');
|
|
153
|
+
return [
|
|
154
|
+
2
|
|
155
|
+
];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
})();
|
|
159
|
+
});
|
|
160
|
+
it('should set Cache-Control and Pragma header to no-cache in the request', function() {
|
|
161
|
+
return _async_to_generator(function() {
|
|
162
|
+
var options, plugin, headerCacheControl, headerPragma;
|
|
163
|
+
return _ts_generator(this, function(_state) {
|
|
164
|
+
switch(_state.label){
|
|
165
|
+
case 0:
|
|
166
|
+
options = {
|
|
167
|
+
headers: new Headers(),
|
|
168
|
+
basePath: 'http://test.com/truc',
|
|
169
|
+
method: 'get'
|
|
170
|
+
};
|
|
171
|
+
global.fetch = {
|
|
172
|
+
polyfill: true
|
|
173
|
+
};
|
|
174
|
+
plugin = new _fetchcacherequest.FetchCacheRequest('force-cache', 'no-cache');
|
|
175
|
+
return [
|
|
176
|
+
4,
|
|
177
|
+
plugin.load().transform(options)
|
|
178
|
+
];
|
|
179
|
+
case 1:
|
|
180
|
+
headerCacheControl = _state.sent().headers.get('Cache-Control');
|
|
181
|
+
return [
|
|
182
|
+
4,
|
|
183
|
+
plugin.load().transform(options)
|
|
184
|
+
];
|
|
185
|
+
case 2:
|
|
186
|
+
headerPragma = _state.sent().headers.get('Pragma');
|
|
187
|
+
expect(headerCacheControl).toEqual('no-cache');
|
|
188
|
+
expect(headerPragma).toEqual('no-cache');
|
|
189
|
+
return [
|
|
190
|
+
2
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
})();
|
|
195
|
+
});
|
|
196
|
+
it('should not set Cache-Control header in the request', function() {
|
|
197
|
+
return _async_to_generator(function() {
|
|
198
|
+
var options, plugin, headerCacheControl, headerPragma;
|
|
199
|
+
return _ts_generator(this, function(_state) {
|
|
200
|
+
switch(_state.label){
|
|
201
|
+
case 0:
|
|
202
|
+
options = {
|
|
203
|
+
headers: new Headers(),
|
|
204
|
+
basePath: 'http://test.com/truc',
|
|
205
|
+
method: 'get'
|
|
206
|
+
};
|
|
207
|
+
global.fetch = function() {};
|
|
208
|
+
plugin = new _fetchcacherequest.FetchCacheRequest('force-cache', 'no-cache');
|
|
209
|
+
return [
|
|
210
|
+
4,
|
|
211
|
+
plugin.load().transform(options)
|
|
212
|
+
];
|
|
213
|
+
case 1:
|
|
214
|
+
headerCacheControl = _state.sent().headers.get('Cache-Control');
|
|
215
|
+
return [
|
|
216
|
+
4,
|
|
217
|
+
plugin.load().transform(options)
|
|
218
|
+
];
|
|
219
|
+
case 2:
|
|
220
|
+
headerPragma = _state.sent().headers.get('Pragma');
|
|
221
|
+
expect(headerCacheControl).toBeNull();
|
|
222
|
+
expect(headerPragma).toBeNull();
|
|
223
|
+
return [
|
|
224
|
+
2
|
|
225
|
+
];
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
})();
|
|
229
|
+
});
|
|
228
230
|
});
|
|
@@ -33,7 +33,7 @@ function _async_to_generator(fn) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
function _ts_generator(thisArg, body) {
|
|
36
|
-
var f, y, t,
|
|
36
|
+
var f, y, t, _ = {
|
|
37
37
|
label: 0,
|
|
38
38
|
sent: function() {
|
|
39
39
|
if (t[0] & 1) throw t[1];
|
|
@@ -41,12 +41,8 @@ function _ts_generator(thisArg, body) {
|
|
|
41
41
|
},
|
|
42
42
|
trys: [],
|
|
43
43
|
ops: []
|
|
44
|
-
};
|
|
45
|
-
return g = {
|
|
46
|
-
next: verb(0),
|
|
47
|
-
"throw": verb(1),
|
|
48
|
-
"return": verb(2)
|
|
49
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
44
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
45
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
50
46
|
return this;
|
|
51
47
|
}), g;
|
|
52
48
|
function verb(n) {
|
|
@@ -59,7 +55,7 @@ function _ts_generator(thisArg, body) {
|
|
|
59
55
|
}
|
|
60
56
|
function step(op) {
|
|
61
57
|
if (f) throw new TypeError("Generator is already executing.");
|
|
62
|
-
while(_)try {
|
|
58
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
63
59
|
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;
|
|
64
60
|
if (y = 0, t) op = [
|
|
65
61
|
op[0] & 2,
|
|
@@ -133,56 +129,60 @@ describe('Fetch API credentials Request Plugin', function() {
|
|
|
133
129
|
basePath: 'http://test.com/truc',
|
|
134
130
|
method: 'get'
|
|
135
131
|
};
|
|
136
|
-
it('credentials should be set to same-origin by default',
|
|
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
|
-
runner.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
132
|
+
it('credentials should be set to same-origin by default', function() {
|
|
133
|
+
return _async_to_generator(function() {
|
|
134
|
+
var plugin, runner, _ref, cred;
|
|
135
|
+
return _ts_generator(this, function(_state) {
|
|
136
|
+
switch(_state.label){
|
|
137
|
+
case 0:
|
|
138
|
+
plugin = new _fetchcredentialsrequest.FetchCredentialsRequest();
|
|
139
|
+
runner = plugin.load();
|
|
140
|
+
return [
|
|
141
|
+
4,
|
|
142
|
+
runner.transform(options)
|
|
143
|
+
];
|
|
144
|
+
case 1:
|
|
145
|
+
_state.sent();
|
|
146
|
+
return [
|
|
147
|
+
4,
|
|
148
|
+
plugin.load().transform(options)
|
|
149
|
+
];
|
|
150
|
+
case 2:
|
|
151
|
+
_ref = _state.sent(), cred = _ref.credentials;
|
|
152
|
+
expect(cred).toBe('same-origin');
|
|
153
|
+
return [
|
|
154
|
+
2
|
|
155
|
+
];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
})();
|
|
159
|
+
});
|
|
160
|
+
it('credentials should be set correctly', function() {
|
|
161
|
+
return _async_to_generator(function() {
|
|
162
|
+
var plugin, runner, _ref, cred;
|
|
163
|
+
return _ts_generator(this, function(_state) {
|
|
164
|
+
switch(_state.label){
|
|
165
|
+
case 0:
|
|
166
|
+
plugin = new _fetchcredentialsrequest.FetchCredentialsRequest('include');
|
|
167
|
+
runner = plugin.load();
|
|
168
|
+
return [
|
|
169
|
+
4,
|
|
170
|
+
runner.transform(options)
|
|
171
|
+
];
|
|
172
|
+
case 1:
|
|
173
|
+
_state.sent();
|
|
174
|
+
return [
|
|
175
|
+
4,
|
|
176
|
+
plugin.load().transform(options)
|
|
177
|
+
];
|
|
178
|
+
case 2:
|
|
179
|
+
_ref = _state.sent(), cred = _ref.credentials;
|
|
180
|
+
expect(cred).toBe('include');
|
|
181
|
+
return [
|
|
182
|
+
2
|
|
183
|
+
];
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
})();
|
|
187
|
+
});
|
|
188
188
|
});
|
|
@@ -35,7 +35,7 @@ function _async_to_generator(fn) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
function _ts_generator(thisArg, body) {
|
|
38
|
-
var f, y, t,
|
|
38
|
+
var f, y, t, _ = {
|
|
39
39
|
label: 0,
|
|
40
40
|
sent: function() {
|
|
41
41
|
if (t[0] & 1) throw t[1];
|
|
@@ -43,12 +43,8 @@ function _ts_generator(thisArg, body) {
|
|
|
43
43
|
},
|
|
44
44
|
trys: [],
|
|
45
45
|
ops: []
|
|
46
|
-
};
|
|
47
|
-
return g = {
|
|
48
|
-
next: verb(0),
|
|
49
|
-
"throw": verb(1),
|
|
50
|
-
"return": verb(2)
|
|
51
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
46
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
47
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
52
48
|
return this;
|
|
53
49
|
}), g;
|
|
54
50
|
function verb(n) {
|
|
@@ -61,7 +57,7 @@ function _ts_generator(thisArg, body) {
|
|
|
61
57
|
}
|
|
62
58
|
function step(op) {
|
|
63
59
|
if (f) throw new TypeError("Generator is already executing.");
|
|
64
|
-
while(_)try {
|
|
60
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
65
61
|
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;
|
|
66
62
|
if (y = 0, t) op = [
|
|
67
63
|
op[0] & 2,
|
|
@@ -147,108 +143,114 @@ describe('Json Token', function() {
|
|
|
147
143
|
basePath: 'http://test.com/truc'
|
|
148
144
|
};
|
|
149
145
|
});
|
|
150
|
-
it('should add Authorization header',
|
|
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
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
146
|
+
it('should add Authorization header', function() {
|
|
147
|
+
return _async_to_generator(function() {
|
|
148
|
+
var memory, plugin, runner, result;
|
|
149
|
+
return _ts_generator(this, function(_state) {
|
|
150
|
+
switch(_state.label){
|
|
151
|
+
case 0:
|
|
152
|
+
memory = {
|
|
153
|
+
testToken: tokenValue
|
|
154
|
+
};
|
|
155
|
+
plugin = new _jsontokenrequest.JsonTokenRequest(tokenKey, memory);
|
|
156
|
+
runner = plugin.load();
|
|
157
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
158
|
+
jest.spyOn(window.sessionStorage, 'getItem').mockImplementation(function() {
|
|
159
|
+
return tokenValue;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return [
|
|
163
|
+
4,
|
|
164
|
+
runner.transform(options)
|
|
165
|
+
];
|
|
166
|
+
case 1:
|
|
167
|
+
result = _state.sent();
|
|
168
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
169
|
+
/* eslint-disable jest/no-conditional-expect -- the same condition is verified above to set up the checked spy */ expect(window.sessionStorage.getItem).toHaveBeenCalledWith(tokenKey);
|
|
170
|
+
/* eslint-enable jest/no-conditional-expect */ }
|
|
171
|
+
expect(result.credentials).toBe('same-origin');
|
|
172
|
+
expect(result.headers.get('Authorization')).toBe(tokenValue);
|
|
173
|
+
return [
|
|
174
|
+
2
|
|
175
|
+
];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
})();
|
|
179
|
+
});
|
|
180
|
+
it('should not add Authorization if no token', function() {
|
|
181
|
+
return _async_to_generator(function() {
|
|
182
|
+
var memory, plugin, runner, result;
|
|
183
|
+
return _ts_generator(this, function(_state) {
|
|
184
|
+
switch(_state.label){
|
|
185
|
+
case 0:
|
|
186
|
+
memory = {
|
|
187
|
+
testToken: undefined
|
|
188
|
+
};
|
|
189
|
+
plugin = new _jsontokenrequest.JsonTokenRequest(tokenKey, memory);
|
|
190
|
+
runner = plugin.load();
|
|
191
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
192
|
+
jest.spyOn(window.sessionStorage, 'getItem').mockImplementation();
|
|
193
|
+
}
|
|
194
|
+
return [
|
|
195
|
+
4,
|
|
196
|
+
runner.transform(options)
|
|
197
|
+
];
|
|
198
|
+
case 1:
|
|
199
|
+
result = _state.sent();
|
|
200
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
201
|
+
/* eslint-disable jest/no-conditional-expect -- the same condition is verified above to set up the checked spy */ expect(window.sessionStorage.getItem).toHaveBeenCalledWith(tokenKey);
|
|
202
|
+
/* eslint-enable jest/no-conditional-expect */ }
|
|
203
|
+
expect(result.credentials).toBeUndefined();
|
|
204
|
+
expect(result.headers.get('Authorization')).toBeNull();
|
|
205
|
+
return [
|
|
206
|
+
2
|
|
207
|
+
];
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
})();
|
|
211
|
+
});
|
|
212
212
|
});
|
|
213
213
|
describe('reply plugin', function() {
|
|
214
214
|
var reviver = jest.fn();
|
|
215
|
-
it('should store the received token',
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
215
|
+
it('should store the received token', function() {
|
|
216
|
+
return _async_to_generator(function() {
|
|
217
|
+
var memory, plugin, runner, data;
|
|
218
|
+
return _ts_generator(this, function(_state) {
|
|
219
|
+
switch(_state.label){
|
|
220
|
+
case 0:
|
|
221
|
+
memory = {
|
|
222
|
+
testToken: undefined
|
|
223
|
+
};
|
|
224
|
+
plugin = new _jsontokenreply.JsonTokenReply(tokenKey, memory);
|
|
225
|
+
runner = plugin.load({
|
|
226
|
+
reviver: reviver,
|
|
227
|
+
apiType: _api.ApiTypes.DEFAULT,
|
|
228
|
+
response: {
|
|
229
|
+
headers: new Headers({
|
|
230
|
+
Authorization: tokenValue
|
|
231
|
+
})
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
data = {};
|
|
235
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
236
|
+
jest.spyOn(window.sessionStorage, 'setItem').mockImplementation();
|
|
231
237
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
];
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}));
|
|
238
|
+
return [
|
|
239
|
+
4,
|
|
240
|
+
runner.transform(data)
|
|
241
|
+
];
|
|
242
|
+
case 1:
|
|
243
|
+
_state.sent();
|
|
244
|
+
if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
|
|
245
|
+
/* 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);
|
|
246
|
+
/* eslint-enable jest/no-conditional-expect */ }
|
|
247
|
+
expect(memory.testToken).toBe(tokenValue);
|
|
248
|
+
return [
|
|
249
|
+
2
|
|
250
|
+
];
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
})();
|
|
254
|
+
});
|
|
253
255
|
});
|
|
254
256
|
});
|