@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
|
@@ -53,7 +53,7 @@ function _define_property(obj, key, value) {
|
|
|
53
53
|
return obj;
|
|
54
54
|
}
|
|
55
55
|
function _ts_generator(thisArg, body) {
|
|
56
|
-
var f, y, t,
|
|
56
|
+
var f, y, t, _ = {
|
|
57
57
|
label: 0,
|
|
58
58
|
sent: function() {
|
|
59
59
|
if (t[0] & 1) throw t[1];
|
|
@@ -61,12 +61,8 @@ function _ts_generator(thisArg, body) {
|
|
|
61
61
|
},
|
|
62
62
|
trys: [],
|
|
63
63
|
ops: []
|
|
64
|
-
};
|
|
65
|
-
return g = {
|
|
66
|
-
next: verb(0),
|
|
67
|
-
"throw": verb(1),
|
|
68
|
-
"return": verb(2)
|
|
69
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
64
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
65
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
70
66
|
return this;
|
|
71
67
|
}), g;
|
|
72
68
|
function verb(n) {
|
|
@@ -79,7 +75,7 @@ function _ts_generator(thisArg, body) {
|
|
|
79
75
|
}
|
|
80
76
|
function step(op) {
|
|
81
77
|
if (f) throw new TypeError("Generator is already executing.");
|
|
82
|
-
while(_)try {
|
|
78
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
83
79
|
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;
|
|
84
80
|
if (y = 0, t) op = [
|
|
85
81
|
op[0] & 2,
|
|
@@ -191,200 +187,212 @@ describe('JSON auth token request plugin', function() {
|
|
|
191
187
|
afterAll(function() {
|
|
192
188
|
global.sessionStorage = undefined;
|
|
193
189
|
});
|
|
194
|
-
it('should add a Bearer in the header',
|
|
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
|
-
plugin.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
])
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
190
|
+
it('should add a Bearer in the header', function() {
|
|
191
|
+
return _async_to_generator(function() {
|
|
192
|
+
var _result_headers_get, plugin, result;
|
|
193
|
+
return _ts_generator(this, function(_state) {
|
|
194
|
+
switch(_state.label){
|
|
195
|
+
case 0:
|
|
196
|
+
plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
|
|
197
|
+
return [
|
|
198
|
+
4,
|
|
199
|
+
plugin.load().transform(options)
|
|
200
|
+
];
|
|
201
|
+
case 1:
|
|
202
|
+
result = _state.sent();
|
|
203
|
+
expect(result.headers.has(authHeaderKey)).toBeTruthy();
|
|
204
|
+
expect((_result_headers_get = result.headers.get(authHeaderKey)) === null || _result_headers_get === void 0 ? void 0 : _result_headers_get.startsWith(authHeaderPrefix)).toBeTruthy();
|
|
205
|
+
return [
|
|
206
|
+
2
|
|
207
|
+
];
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
})();
|
|
211
|
+
});
|
|
212
|
+
it('should check that the jws token is well formatted', function() {
|
|
213
|
+
return _async_to_generator(function() {
|
|
214
|
+
var plugin, result, token, tokenParts;
|
|
215
|
+
return _ts_generator(this, function(_state) {
|
|
216
|
+
switch(_state.label){
|
|
217
|
+
case 0:
|
|
218
|
+
plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
|
|
219
|
+
return [
|
|
220
|
+
4,
|
|
221
|
+
plugin.load().transform(options)
|
|
222
|
+
];
|
|
223
|
+
case 1:
|
|
224
|
+
result = _state.sent();
|
|
225
|
+
token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
|
|
226
|
+
tokenParts = token.split('.');
|
|
227
|
+
expect(token).toBeDefined();
|
|
228
|
+
expect(tokenParts.length).toEqual(3);
|
|
229
|
+
return [
|
|
230
|
+
2
|
|
231
|
+
];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
})();
|
|
235
|
+
});
|
|
236
|
+
it('should check that the header is properly set', function() {
|
|
237
|
+
return _async_to_generator(function() {
|
|
238
|
+
var base64URLDecoder, plugin, result, token, tokenParts, header;
|
|
239
|
+
return _ts_generator(this, function(_state) {
|
|
240
|
+
switch(_state.label){
|
|
241
|
+
case 0:
|
|
242
|
+
base64URLDecoder = (0, _jsontoken.createBase64UrlDecoder)();
|
|
243
|
+
plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
|
|
244
|
+
return [
|
|
245
|
+
4,
|
|
246
|
+
plugin.load().transform(options)
|
|
247
|
+
];
|
|
248
|
+
case 1:
|
|
249
|
+
result = _state.sent();
|
|
250
|
+
token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
|
|
251
|
+
expect(token).toBeDefined();
|
|
252
|
+
tokenParts = token.split('.');
|
|
253
|
+
header = JSON.parse(base64URLDecoder(tokenParts[0]));
|
|
254
|
+
expect(header.alg).toBeDefined();
|
|
255
|
+
expect(header.alg).toEqual('HS256');
|
|
256
|
+
expect(header.typ).toBeDefined();
|
|
257
|
+
expect(header.typ).toEqual('JWT');
|
|
258
|
+
return [
|
|
259
|
+
2
|
|
260
|
+
];
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
})();
|
|
264
|
+
});
|
|
265
|
+
it('should check that the payload is properly set', function() {
|
|
266
|
+
return _async_to_generator(function() {
|
|
267
|
+
var base64URLDecoder, base64Decoder, plugin, result, token, tokenParts, payload, context;
|
|
268
|
+
return _ts_generator(this, function(_state) {
|
|
269
|
+
switch(_state.label){
|
|
270
|
+
case 0:
|
|
271
|
+
base64URLDecoder = (0, _jsontoken.createBase64UrlDecoder)();
|
|
272
|
+
base64Decoder = (0, _jsontoken.createBase64Decoder)();
|
|
273
|
+
plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
|
|
274
|
+
return [
|
|
275
|
+
4,
|
|
276
|
+
plugin.load().transform(options)
|
|
277
|
+
];
|
|
278
|
+
case 1:
|
|
279
|
+
result = _state.sent();
|
|
280
|
+
token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
|
|
281
|
+
expect(token).toBeDefined();
|
|
282
|
+
tokenParts = token.split('.');
|
|
283
|
+
payload = JSON.parse(base64URLDecoder(tokenParts[1]));
|
|
284
|
+
expect(payload.jti).toBeDefined();
|
|
285
|
+
expect(payload.iat).toBeDefined();
|
|
286
|
+
expect(payload.exp).toBeDefined();
|
|
287
|
+
expect(payload.iss).toBeDefined();
|
|
288
|
+
expect(payload.iss).toEqual(jsonAuthTokenOptions.applicationId);
|
|
289
|
+
expect(payload.context).toBeDefined();
|
|
290
|
+
context = JSON.parse(base64Decoder(payload.context));
|
|
291
|
+
expect(context.oid).toBeDefined();
|
|
292
|
+
expect(context.oid).toEqual(jsonAuthTokenOptions.context.oid);
|
|
293
|
+
return [
|
|
294
|
+
2
|
|
295
|
+
];
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
})();
|
|
299
|
+
});
|
|
300
|
+
it('should check the signature validity', function() {
|
|
301
|
+
return _async_to_generator(function() {
|
|
302
|
+
var base64URLDecoder, base64UrlEncoder, plugin, result, token, tokenParts, header, payload, signature, secretKey, _, message, signCheck;
|
|
303
|
+
return _ts_generator(this, function(_state) {
|
|
304
|
+
switch(_state.label){
|
|
305
|
+
case 0:
|
|
306
|
+
base64URLDecoder = (0, _jsontoken.createBase64UrlDecoder)();
|
|
307
|
+
base64UrlEncoder = (0, _jsontoken.createBase64UrlEncoder)();
|
|
308
|
+
plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
|
|
309
|
+
return [
|
|
310
|
+
4,
|
|
311
|
+
plugin.load().transform(options)
|
|
312
|
+
];
|
|
313
|
+
case 1:
|
|
314
|
+
result = _state.sent();
|
|
315
|
+
token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
|
|
316
|
+
tokenParts = token.split('.');
|
|
317
|
+
header = JSON.parse(base64URLDecoder(tokenParts[0]));
|
|
318
|
+
payload = JSON.parse(base64URLDecoder(tokenParts[1]));
|
|
319
|
+
signature = tokenParts[2];
|
|
320
|
+
_ = jsonAuthTokenOptions.apiKey;
|
|
321
|
+
return [
|
|
322
|
+
4,
|
|
323
|
+
(0, _mgwmdwauthhelpers.sha256)(jsonAuthTokenOptions.secret + payload.jti + payload.iat + routePath)
|
|
324
|
+
];
|
|
325
|
+
case 2:
|
|
326
|
+
return [
|
|
327
|
+
4,
|
|
328
|
+
_mgwmdwauthhelpers.sha256.apply(void 0, [
|
|
329
|
+
_ + _state.sent()
|
|
330
|
+
])
|
|
331
|
+
];
|
|
332
|
+
case 3:
|
|
333
|
+
secretKey = _state.sent();
|
|
334
|
+
message = "".concat(base64UrlEncoder(JSON.stringify(header)), ".").concat(base64UrlEncoder(JSON.stringify(payload)));
|
|
335
|
+
return [
|
|
336
|
+
4,
|
|
337
|
+
(0, _mgwmdwauthhelpers.hmacSHA256)(message, secretKey)
|
|
338
|
+
];
|
|
339
|
+
case 4:
|
|
340
|
+
signCheck = _jsontoken.base64EncodeUrl.apply(void 0, [
|
|
341
|
+
_state.sent()
|
|
342
|
+
]);
|
|
343
|
+
expect(signature).toEqual(signCheck);
|
|
344
|
+
return [
|
|
345
|
+
2
|
|
346
|
+
];
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
})();
|
|
350
|
+
});
|
|
351
|
+
it('should have same hmacSHA256 of node implementation', function() {
|
|
352
|
+
return _async_to_generator(function() {
|
|
353
|
+
var base64URLDecoder, base64UrlEncoder, plugin, result, token, tokenParts, header, payload, secretKey, _, message;
|
|
354
|
+
return _ts_generator(this, function(_state) {
|
|
355
|
+
switch(_state.label){
|
|
356
|
+
case 0:
|
|
357
|
+
base64URLDecoder = (0, _jsontoken.createBase64UrlDecoder)();
|
|
358
|
+
base64UrlEncoder = (0, _jsontoken.createBase64UrlEncoder)();
|
|
359
|
+
plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
|
|
360
|
+
return [
|
|
361
|
+
4,
|
|
362
|
+
plugin.load().transform(options)
|
|
363
|
+
];
|
|
364
|
+
case 1:
|
|
365
|
+
result = _state.sent();
|
|
366
|
+
token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
|
|
367
|
+
tokenParts = token.split('.');
|
|
368
|
+
header = JSON.parse(base64URLDecoder(tokenParts[0]));
|
|
369
|
+
payload = JSON.parse(base64URLDecoder(tokenParts[1]));
|
|
370
|
+
_ = jsonAuthTokenOptions.apiKey;
|
|
371
|
+
return [
|
|
372
|
+
4,
|
|
373
|
+
(0, _mgwmdwauthhelpers.sha256)(jsonAuthTokenOptions.secret + payload.jti + payload.iat + routePath)
|
|
374
|
+
];
|
|
375
|
+
case 2:
|
|
376
|
+
return [
|
|
377
|
+
4,
|
|
378
|
+
_mgwmdwauthhelpers.sha256.apply(void 0, [
|
|
379
|
+
_ + _state.sent()
|
|
380
|
+
])
|
|
381
|
+
];
|
|
382
|
+
case 3:
|
|
383
|
+
secretKey = _state.sent();
|
|
384
|
+
message = "".concat(base64UrlEncoder(JSON.stringify(header)), ".").concat(base64UrlEncoder(JSON.stringify(payload)));
|
|
385
|
+
return [
|
|
386
|
+
4,
|
|
387
|
+
expect((0, _mgwmdwauthhelpers.hmacSHA256)(message, secretKey)).resolves.toBe(hmacSHA256NodeImplementation(message, secretKey))
|
|
388
|
+
];
|
|
389
|
+
case 4:
|
|
390
|
+
_state.sent();
|
|
391
|
+
return [
|
|
392
|
+
2
|
|
393
|
+
];
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
})();
|
|
397
|
+
});
|
|
390
398
|
});
|