@ama-sdk/core 11.2.0-prerelease.51 → 11.2.0-prerelease.53
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/plugins/index.js +1 -0
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js +238 -0
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +27 -59
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +61 -3
- package/esm2015/plugins/index.js +1 -0
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js +226 -0
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +22 -52
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +60 -2
- package/package.json +5 -5
- package/src/fwk/Reviver.d.ts +14 -0
- package/src/fwk/Reviver.d.ts.map +1 -1
- package/src/fwk/Reviver.js.map +1 -1
- package/src/plugins/index.d.ts +1 -0
- package/src/plugins/index.d.ts.map +1 -1
- package/src/plugins/index.js +1 -0
- package/src/plugins/index.js.map +1 -1
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.d.ts +14 -0
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.d.ts.map +1 -0
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js +29 -0
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js.map +1 -0
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.d.ts +0 -13
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.d.ts.map +1 -1
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +3 -37
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js.map +1 -1
package/cjs/plugins/index.js
CHANGED
|
@@ -16,6 +16,7 @@ _export_star(require("./fetch-cache/index"), exports);
|
|
|
16
16
|
_export_star(require("./fetch-credentials/index"), exports);
|
|
17
17
|
_export_star(require("./json-token/index"), exports);
|
|
18
18
|
_export_star(require("./keepalive/index"), exports);
|
|
19
|
+
_export_star(require("./mgw-mdw-auth/index"), exports);
|
|
19
20
|
_export_star(require("./mock-intercept/index"), exports);
|
|
20
21
|
_export_star(require("./perf-metric/index"), exports);
|
|
21
22
|
_export_star(require("./pii-tokenizer/index"), exports);
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the SHA256 digest of the given string
|
|
3
|
+
* @param value Value to hash
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
function _export(target, all) {
|
|
9
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: all[name]
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
_export(exports, {
|
|
15
|
+
hmacSHA256: function() {
|
|
16
|
+
return hmacSHA256;
|
|
17
|
+
},
|
|
18
|
+
sha256: function() {
|
|
19
|
+
return sha256;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
function _array_like_to_array(arr, len) {
|
|
23
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
24
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
25
|
+
return arr2;
|
|
26
|
+
}
|
|
27
|
+
function _array_without_holes(arr) {
|
|
28
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
29
|
+
}
|
|
30
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
31
|
+
try {
|
|
32
|
+
var info = gen[key](arg);
|
|
33
|
+
var value = info.value;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
reject(error);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (info.done) {
|
|
39
|
+
resolve(value);
|
|
40
|
+
} else {
|
|
41
|
+
Promise.resolve(value).then(_next, _throw);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function _async_to_generator(fn) {
|
|
45
|
+
return function() {
|
|
46
|
+
var self = this, args = arguments;
|
|
47
|
+
return new Promise(function(resolve, reject) {
|
|
48
|
+
var gen = fn.apply(self, args);
|
|
49
|
+
function _next(value) {
|
|
50
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
51
|
+
}
|
|
52
|
+
function _throw(err) {
|
|
53
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
54
|
+
}
|
|
55
|
+
_next(undefined);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function _iterable_to_array(iter) {
|
|
60
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
61
|
+
}
|
|
62
|
+
function _non_iterable_spread() {
|
|
63
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
64
|
+
}
|
|
65
|
+
function _to_consumable_array(arr) {
|
|
66
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
67
|
+
}
|
|
68
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
69
|
+
if (!o) return;
|
|
70
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
71
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
72
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
73
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
74
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
75
|
+
}
|
|
76
|
+
function _ts_generator(thisArg, body) {
|
|
77
|
+
var f, y, t, g, _ = {
|
|
78
|
+
label: 0,
|
|
79
|
+
sent: function() {
|
|
80
|
+
if (t[0] & 1) throw t[1];
|
|
81
|
+
return t[1];
|
|
82
|
+
},
|
|
83
|
+
trys: [],
|
|
84
|
+
ops: []
|
|
85
|
+
};
|
|
86
|
+
return g = {
|
|
87
|
+
next: verb(0),
|
|
88
|
+
"throw": verb(1),
|
|
89
|
+
"return": verb(2)
|
|
90
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
91
|
+
return this;
|
|
92
|
+
}), g;
|
|
93
|
+
function verb(n) {
|
|
94
|
+
return function(v) {
|
|
95
|
+
return step([
|
|
96
|
+
n,
|
|
97
|
+
v
|
|
98
|
+
]);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function step(op) {
|
|
102
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
103
|
+
while(_)try {
|
|
104
|
+
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;
|
|
105
|
+
if (y = 0, t) op = [
|
|
106
|
+
op[0] & 2,
|
|
107
|
+
t.value
|
|
108
|
+
];
|
|
109
|
+
switch(op[0]){
|
|
110
|
+
case 0:
|
|
111
|
+
case 1:
|
|
112
|
+
t = op;
|
|
113
|
+
break;
|
|
114
|
+
case 4:
|
|
115
|
+
_.label++;
|
|
116
|
+
return {
|
|
117
|
+
value: op[1],
|
|
118
|
+
done: false
|
|
119
|
+
};
|
|
120
|
+
case 5:
|
|
121
|
+
_.label++;
|
|
122
|
+
y = op[1];
|
|
123
|
+
op = [
|
|
124
|
+
0
|
|
125
|
+
];
|
|
126
|
+
continue;
|
|
127
|
+
case 7:
|
|
128
|
+
op = _.ops.pop();
|
|
129
|
+
_.trys.pop();
|
|
130
|
+
continue;
|
|
131
|
+
default:
|
|
132
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
133
|
+
_ = 0;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
137
|
+
_.label = op[1];
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
141
|
+
_.label = t[1];
|
|
142
|
+
t = op;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
if (t && _.label < t[2]) {
|
|
146
|
+
_.label = t[2];
|
|
147
|
+
_.ops.push(op);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
if (t[2]) _.ops.pop();
|
|
151
|
+
_.trys.pop();
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
op = body.call(thisArg, _);
|
|
155
|
+
} catch (e) {
|
|
156
|
+
op = [
|
|
157
|
+
6,
|
|
158
|
+
e
|
|
159
|
+
];
|
|
160
|
+
y = 0;
|
|
161
|
+
} finally{
|
|
162
|
+
f = t = 0;
|
|
163
|
+
}
|
|
164
|
+
if (op[0] & 5) throw op[1];
|
|
165
|
+
return {
|
|
166
|
+
value: op[0] ? op[1] : void 0,
|
|
167
|
+
done: true
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function sha256(value) {
|
|
172
|
+
return _sha256.apply(this, arguments);
|
|
173
|
+
}
|
|
174
|
+
function _sha256() {
|
|
175
|
+
_sha256 = _async_to_generator(function(value) {
|
|
176
|
+
var utf8, hashBuffer, hashArray, hashHex;
|
|
177
|
+
return _ts_generator(this, function(_state) {
|
|
178
|
+
switch(_state.label){
|
|
179
|
+
case 0:
|
|
180
|
+
utf8 = new TextEncoder().encode(value);
|
|
181
|
+
return [
|
|
182
|
+
4,
|
|
183
|
+
crypto.subtle.digest('SHA-256', utf8)
|
|
184
|
+
];
|
|
185
|
+
case 1:
|
|
186
|
+
hashBuffer = _state.sent();
|
|
187
|
+
hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
188
|
+
hashHex = hashArray.map(function(bytes) {
|
|
189
|
+
return bytes.toString(16).padStart(2, '0');
|
|
190
|
+
}).join('');
|
|
191
|
+
return [
|
|
192
|
+
2,
|
|
193
|
+
hashHex
|
|
194
|
+
];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
return _sha256.apply(this, arguments);
|
|
199
|
+
}
|
|
200
|
+
function hmacSHA256(value, secretKey) {
|
|
201
|
+
return _hmacSHA256.apply(this, arguments);
|
|
202
|
+
}
|
|
203
|
+
function _hmacSHA256() {
|
|
204
|
+
_hmacSHA256 = _async_to_generator(function(value, secretKey) {
|
|
205
|
+
var _String, enc, algorithm, key, signature, digest;
|
|
206
|
+
return _ts_generator(this, function(_state) {
|
|
207
|
+
switch(_state.label){
|
|
208
|
+
case 0:
|
|
209
|
+
enc = new TextEncoder();
|
|
210
|
+
algorithm = {
|
|
211
|
+
name: 'HMAC',
|
|
212
|
+
hash: 'SHA-256'
|
|
213
|
+
};
|
|
214
|
+
return [
|
|
215
|
+
4,
|
|
216
|
+
crypto.subtle.importKey('raw', enc.encode(secretKey), algorithm, false, [
|
|
217
|
+
'sign',
|
|
218
|
+
'verify'
|
|
219
|
+
])
|
|
220
|
+
];
|
|
221
|
+
case 1:
|
|
222
|
+
key = _state.sent();
|
|
223
|
+
return [
|
|
224
|
+
4,
|
|
225
|
+
crypto.subtle.sign(algorithm.name, key, enc.encode(value))
|
|
226
|
+
];
|
|
227
|
+
case 2:
|
|
228
|
+
signature = _state.sent();
|
|
229
|
+
digest = btoa((_String = String).fromCharCode.apply(_String, _to_consumable_array(new Uint8Array(signature))));
|
|
230
|
+
return [
|
|
231
|
+
2,
|
|
232
|
+
digest
|
|
233
|
+
];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
return _hmacSHA256.apply(this, arguments);
|
|
238
|
+
}
|
|
@@ -2,25 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
MicroGatewayMiddlewareAuthenticationRequest: function() {
|
|
5
|
+
Object.defineProperty(exports, "MicroGatewayMiddlewareAuthenticationRequest", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
13
8
|
return MicroGatewayMiddlewareAuthenticationRequest;
|
|
14
|
-
},
|
|
15
|
-
hmacSHA256: function() {
|
|
16
|
-
return hmacSHA256;
|
|
17
|
-
},
|
|
18
|
-
sha256: function() {
|
|
19
|
-
return sha256;
|
|
20
9
|
}
|
|
21
10
|
});
|
|
22
11
|
var _uuid = require("uuid");
|
|
23
12
|
var _jsontoken = require("../../utils/json-token");
|
|
13
|
+
var _mgwmdwauthhelpers = require("./mgw-mdw-auth.helpers");
|
|
24
14
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
25
15
|
try {
|
|
26
16
|
var info = gen[key](arg);
|
|
@@ -177,45 +167,6 @@ function _ts_generator(thisArg, body) {
|
|
|
177
167
|
};
|
|
178
168
|
}
|
|
179
169
|
}
|
|
180
|
-
function sha256(value) {
|
|
181
|
-
return _sha256.apply(this, arguments);
|
|
182
|
-
}
|
|
183
|
-
function _sha256() {
|
|
184
|
-
_sha256 = _async_to_generator(function(value) {
|
|
185
|
-
var utf8, hashBuffer, hashArray, hashHex;
|
|
186
|
-
return _ts_generator(this, function(_state) {
|
|
187
|
-
switch(_state.label){
|
|
188
|
-
case 0:
|
|
189
|
-
utf8 = new TextEncoder().encode(value);
|
|
190
|
-
return [
|
|
191
|
-
4,
|
|
192
|
-
(globalThis.crypto || require('node:crypto').webcrypto).subtle.digest('SHA-256', utf8)
|
|
193
|
-
];
|
|
194
|
-
case 1:
|
|
195
|
-
hashBuffer = _state.sent();
|
|
196
|
-
hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
197
|
-
hashHex = hashArray.map(function(bytes) {
|
|
198
|
-
return bytes.toString(16).padStart(2, '0');
|
|
199
|
-
}).join('');
|
|
200
|
-
return [
|
|
201
|
-
2,
|
|
202
|
-
hashHex
|
|
203
|
-
];
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
return _sha256.apply(this, arguments);
|
|
208
|
-
}
|
|
209
|
-
function hmacSHA256(value, secretKey) {
|
|
210
|
-
try {
|
|
211
|
-
// TODO: Use new Ecmascript crypto feature to avoid "require" call (issue #2110)
|
|
212
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
213
|
-
var createHmac = require('node:crypto').createHmac;
|
|
214
|
-
return createHmac('sha256', secretKey).update(value, 'latin1').digest('base64');
|
|
215
|
-
} catch (err) {
|
|
216
|
-
throw new Error('Crypto module is not available.');
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
170
|
/**
|
|
220
171
|
* Header definition of the JWS used for the API Manager authentication
|
|
221
172
|
*/ var jwsHeader = {
|
|
@@ -302,13 +253,13 @@ var MicroGatewayMiddlewareAuthenticationRequest = /*#__PURE__*/ function() {
|
|
|
302
253
|
_ = _this.apiKey;
|
|
303
254
|
return [
|
|
304
255
|
4,
|
|
305
|
-
sha256(subKeyString)
|
|
256
|
+
(0, _mgwmdwauthhelpers.sha256)(subKeyString)
|
|
306
257
|
];
|
|
307
258
|
case 1:
|
|
308
259
|
keyString = _ + _state.sent();
|
|
309
260
|
return [
|
|
310
261
|
2,
|
|
311
|
-
sha256(keyString)
|
|
262
|
+
(0, _mgwmdwauthhelpers.sha256)(keyString)
|
|
312
263
|
];
|
|
313
264
|
}
|
|
314
265
|
});
|
|
@@ -322,10 +273,27 @@ var MicroGatewayMiddlewareAuthenticationRequest = /*#__PURE__*/ function() {
|
|
|
322
273
|
* @param payload JWT payload
|
|
323
274
|
* @param secretKey secret key used to generate the signature
|
|
324
275
|
*/ function sign(payload, secretKey) {
|
|
325
|
-
var
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
276
|
+
var _this = this;
|
|
277
|
+
return _async_to_generator(function() {
|
|
278
|
+
var message, signature, encodedSignature;
|
|
279
|
+
return _ts_generator(this, function(_state) {
|
|
280
|
+
switch(_state.label){
|
|
281
|
+
case 0:
|
|
282
|
+
message = "".concat(_this.base64UrlEncoder(JSON.stringify(jwsHeader)), ".").concat(_this.base64UrlEncoder(JSON.stringify(payload)));
|
|
283
|
+
return [
|
|
284
|
+
4,
|
|
285
|
+
(0, _mgwmdwauthhelpers.hmacSHA256)(message, secretKey)
|
|
286
|
+
];
|
|
287
|
+
case 1:
|
|
288
|
+
signature = _state.sent();
|
|
289
|
+
encodedSignature = (0, _jsontoken.base64EncodeUrl)(signature);
|
|
290
|
+
return [
|
|
291
|
+
2,
|
|
292
|
+
"".concat(message, ".").concat(encodedSignature)
|
|
293
|
+
];
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
})();
|
|
329
297
|
}
|
|
330
298
|
},
|
|
331
299
|
{
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
var _jsontoken = require("../../utils/json-token");
|
|
6
|
+
var _mgwmdwauthhelpers = require("./mgw-mdw-auth.helpers");
|
|
6
7
|
var _mgwmdwauthrequest = require("./mgw-mdw-auth.request");
|
|
7
8
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
8
9
|
try {
|
|
@@ -175,6 +176,10 @@ var jsonAuthTokenOptions = {
|
|
|
175
176
|
oid: 'NCE1A0955'
|
|
176
177
|
}
|
|
177
178
|
};
|
|
179
|
+
var hmacSHA256NodeImplementation = function(value, secretKey) {
|
|
180
|
+
var createHmac = require('node:crypto').createHmac;
|
|
181
|
+
return createHmac('sha256', secretKey).update(value, 'latin1').digest('base64');
|
|
182
|
+
};
|
|
178
183
|
describe('JSON auth token request plugin', function() {
|
|
179
184
|
beforeEach(function() {
|
|
180
185
|
options = {
|
|
@@ -310,12 +315,12 @@ describe('JSON auth token request plugin', function() {
|
|
|
310
315
|
_ = jsonAuthTokenOptions.apiKey;
|
|
311
316
|
return [
|
|
312
317
|
4,
|
|
313
|
-
(0,
|
|
318
|
+
(0, _mgwmdwauthhelpers.sha256)(jsonAuthTokenOptions.secret + payload.jti + payload.iat + routePath)
|
|
314
319
|
];
|
|
315
320
|
case 2:
|
|
316
321
|
return [
|
|
317
322
|
4,
|
|
318
|
-
|
|
323
|
+
_mgwmdwauthhelpers.sha256.apply(void 0, [
|
|
319
324
|
_ + _state.sent()
|
|
320
325
|
])
|
|
321
326
|
];
|
|
@@ -323,7 +328,14 @@ describe('JSON auth token request plugin', function() {
|
|
|
323
328
|
secretKey = _state.sent();
|
|
324
329
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
325
330
|
message = "".concat(base64UrlEncoder(JSON.stringify(header)), ".").concat(base64UrlEncoder(JSON.stringify(payload)));
|
|
326
|
-
|
|
331
|
+
return [
|
|
332
|
+
4,
|
|
333
|
+
(0, _mgwmdwauthhelpers.hmacSHA256)(message, secretKey)
|
|
334
|
+
];
|
|
335
|
+
case 4:
|
|
336
|
+
signCheck = _jsontoken.base64EncodeUrl.apply(void 0, [
|
|
337
|
+
_state.sent()
|
|
338
|
+
]);
|
|
327
339
|
expect(signature).toEqual(signCheck);
|
|
328
340
|
return [
|
|
329
341
|
2
|
|
@@ -331,4 +343,50 @@ describe('JSON auth token request plugin', function() {
|
|
|
331
343
|
}
|
|
332
344
|
});
|
|
333
345
|
}));
|
|
346
|
+
it('should have same hmacSHA256 of node implementation', /*#__PURE__*/ _async_to_generator(function() {
|
|
347
|
+
var base64URLDecoder, base64UrlEncoder, plugin, result, token, tokenParts, header, payload, secretKey, _, message;
|
|
348
|
+
return _ts_generator(this, function(_state) {
|
|
349
|
+
switch(_state.label){
|
|
350
|
+
case 0:
|
|
351
|
+
base64URLDecoder = (0, _jsontoken.createBase64UrlDecoder)();
|
|
352
|
+
base64UrlEncoder = (0, _jsontoken.createBase64UrlEncoder)();
|
|
353
|
+
plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
|
|
354
|
+
return [
|
|
355
|
+
4,
|
|
356
|
+
plugin.load().transform(options)
|
|
357
|
+
];
|
|
358
|
+
case 1:
|
|
359
|
+
result = _state.sent();
|
|
360
|
+
token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
|
|
361
|
+
tokenParts = token.split('.');
|
|
362
|
+
header = JSON.parse(base64URLDecoder(tokenParts[0]));
|
|
363
|
+
payload = JSON.parse(base64URLDecoder(tokenParts[1]));
|
|
364
|
+
_ = jsonAuthTokenOptions.apiKey;
|
|
365
|
+
return [
|
|
366
|
+
4,
|
|
367
|
+
(0, _mgwmdwauthhelpers.sha256)(jsonAuthTokenOptions.secret + payload.jti + payload.iat + routePath)
|
|
368
|
+
];
|
|
369
|
+
case 2:
|
|
370
|
+
return [
|
|
371
|
+
4,
|
|
372
|
+
_mgwmdwauthhelpers.sha256.apply(void 0, [
|
|
373
|
+
_ + _state.sent()
|
|
374
|
+
])
|
|
375
|
+
];
|
|
376
|
+
case 3:
|
|
377
|
+
secretKey = _state.sent();
|
|
378
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
379
|
+
message = "".concat(base64UrlEncoder(JSON.stringify(header)), ".").concat(base64UrlEncoder(JSON.stringify(payload)));
|
|
380
|
+
return [
|
|
381
|
+
4,
|
|
382
|
+
expect((0, _mgwmdwauthhelpers.hmacSHA256)(message, secretKey)).resolves.toBe(hmacSHA256NodeImplementation(message, secretKey))
|
|
383
|
+
];
|
|
384
|
+
case 4:
|
|
385
|
+
_state.sent();
|
|
386
|
+
return [
|
|
387
|
+
2
|
|
388
|
+
];
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}));
|
|
334
392
|
});
|
package/esm2015/plugins/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export * from './fetch-cache/index';
|
|
|
12
12
|
export * from './fetch-credentials/index';
|
|
13
13
|
export * from './json-token/index';
|
|
14
14
|
export * from './keepalive/index';
|
|
15
|
+
export * from './mgw-mdw-auth/index';
|
|
15
16
|
export * from './mock-intercept/index';
|
|
16
17
|
export * from './perf-metric/index';
|
|
17
18
|
export * from './pii-tokenizer/index';
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the SHA256 digest of the given string
|
|
3
|
+
* @param value Value to hash
|
|
4
|
+
*/ function _array_like_to_array(arr, len) {
|
|
5
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
6
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
7
|
+
return arr2;
|
|
8
|
+
}
|
|
9
|
+
function _array_without_holes(arr) {
|
|
10
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
|
+
}
|
|
12
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13
|
+
try {
|
|
14
|
+
var info = gen[key](arg);
|
|
15
|
+
var value = info.value;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
reject(error);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (info.done) {
|
|
21
|
+
resolve(value);
|
|
22
|
+
} else {
|
|
23
|
+
Promise.resolve(value).then(_next, _throw);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function _async_to_generator(fn) {
|
|
27
|
+
return function() {
|
|
28
|
+
var self = this, args = arguments;
|
|
29
|
+
return new Promise(function(resolve, reject) {
|
|
30
|
+
var gen = fn.apply(self, args);
|
|
31
|
+
function _next(value) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
33
|
+
}
|
|
34
|
+
function _throw(err) {
|
|
35
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
36
|
+
}
|
|
37
|
+
_next(undefined);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function _iterable_to_array(iter) {
|
|
42
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
43
|
+
}
|
|
44
|
+
function _non_iterable_spread() {
|
|
45
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
46
|
+
}
|
|
47
|
+
function _to_consumable_array(arr) {
|
|
48
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
49
|
+
}
|
|
50
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
51
|
+
if (!o) return;
|
|
52
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
53
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
54
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
55
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
56
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
57
|
+
}
|
|
58
|
+
function _ts_generator(thisArg, body) {
|
|
59
|
+
var f, y, t, g, _ = {
|
|
60
|
+
label: 0,
|
|
61
|
+
sent: function() {
|
|
62
|
+
if (t[0] & 1) throw t[1];
|
|
63
|
+
return t[1];
|
|
64
|
+
},
|
|
65
|
+
trys: [],
|
|
66
|
+
ops: []
|
|
67
|
+
};
|
|
68
|
+
return g = {
|
|
69
|
+
next: verb(0),
|
|
70
|
+
"throw": verb(1),
|
|
71
|
+
"return": verb(2)
|
|
72
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
73
|
+
return this;
|
|
74
|
+
}), g;
|
|
75
|
+
function verb(n) {
|
|
76
|
+
return function(v) {
|
|
77
|
+
return step([
|
|
78
|
+
n,
|
|
79
|
+
v
|
|
80
|
+
]);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function step(op) {
|
|
84
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
85
|
+
while(_)try {
|
|
86
|
+
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;
|
|
87
|
+
if (y = 0, t) op = [
|
|
88
|
+
op[0] & 2,
|
|
89
|
+
t.value
|
|
90
|
+
];
|
|
91
|
+
switch(op[0]){
|
|
92
|
+
case 0:
|
|
93
|
+
case 1:
|
|
94
|
+
t = op;
|
|
95
|
+
break;
|
|
96
|
+
case 4:
|
|
97
|
+
_.label++;
|
|
98
|
+
return {
|
|
99
|
+
value: op[1],
|
|
100
|
+
done: false
|
|
101
|
+
};
|
|
102
|
+
case 5:
|
|
103
|
+
_.label++;
|
|
104
|
+
y = op[1];
|
|
105
|
+
op = [
|
|
106
|
+
0
|
|
107
|
+
];
|
|
108
|
+
continue;
|
|
109
|
+
case 7:
|
|
110
|
+
op = _.ops.pop();
|
|
111
|
+
_.trys.pop();
|
|
112
|
+
continue;
|
|
113
|
+
default:
|
|
114
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
115
|
+
_ = 0;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
119
|
+
_.label = op[1];
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
123
|
+
_.label = t[1];
|
|
124
|
+
t = op;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
if (t && _.label < t[2]) {
|
|
128
|
+
_.label = t[2];
|
|
129
|
+
_.ops.push(op);
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
if (t[2]) _.ops.pop();
|
|
133
|
+
_.trys.pop();
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
op = body.call(thisArg, _);
|
|
137
|
+
} catch (e) {
|
|
138
|
+
op = [
|
|
139
|
+
6,
|
|
140
|
+
e
|
|
141
|
+
];
|
|
142
|
+
y = 0;
|
|
143
|
+
} finally{
|
|
144
|
+
f = t = 0;
|
|
145
|
+
}
|
|
146
|
+
if (op[0] & 5) throw op[1];
|
|
147
|
+
return {
|
|
148
|
+
value: op[0] ? op[1] : void 0,
|
|
149
|
+
done: true
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
export function sha256(value) {
|
|
154
|
+
return _sha256.apply(this, arguments);
|
|
155
|
+
}
|
|
156
|
+
function _sha256() {
|
|
157
|
+
_sha256 = _async_to_generator(function(value) {
|
|
158
|
+
var utf8, hashBuffer, hashArray, hashHex;
|
|
159
|
+
return _ts_generator(this, function(_state) {
|
|
160
|
+
switch(_state.label){
|
|
161
|
+
case 0:
|
|
162
|
+
utf8 = new TextEncoder().encode(value);
|
|
163
|
+
return [
|
|
164
|
+
4,
|
|
165
|
+
crypto.subtle.digest('SHA-256', utf8)
|
|
166
|
+
];
|
|
167
|
+
case 1:
|
|
168
|
+
hashBuffer = _state.sent();
|
|
169
|
+
hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
170
|
+
hashHex = hashArray.map(function(bytes) {
|
|
171
|
+
return bytes.toString(16).padStart(2, '0');
|
|
172
|
+
}).join('');
|
|
173
|
+
return [
|
|
174
|
+
2,
|
|
175
|
+
hashHex
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
return _sha256.apply(this, arguments);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Generates hash-based message authentication code using cryptographic hash function HmacSHA256 and the provided
|
|
184
|
+
* secret key
|
|
185
|
+
* Should only be in a NodeJS MDW context
|
|
186
|
+
* @param value Value to hash
|
|
187
|
+
* @param secretKey Secret cryptographic key
|
|
188
|
+
*/ export function hmacSHA256(value, secretKey) {
|
|
189
|
+
return _hmacSHA256.apply(this, arguments);
|
|
190
|
+
}
|
|
191
|
+
function _hmacSHA256() {
|
|
192
|
+
_hmacSHA256 = _async_to_generator(function(value, secretKey) {
|
|
193
|
+
var _String, enc, algorithm, key, signature, digest;
|
|
194
|
+
return _ts_generator(this, function(_state) {
|
|
195
|
+
switch(_state.label){
|
|
196
|
+
case 0:
|
|
197
|
+
enc = new TextEncoder();
|
|
198
|
+
algorithm = {
|
|
199
|
+
name: 'HMAC',
|
|
200
|
+
hash: 'SHA-256'
|
|
201
|
+
};
|
|
202
|
+
return [
|
|
203
|
+
4,
|
|
204
|
+
crypto.subtle.importKey('raw', enc.encode(secretKey), algorithm, false, [
|
|
205
|
+
'sign',
|
|
206
|
+
'verify'
|
|
207
|
+
])
|
|
208
|
+
];
|
|
209
|
+
case 1:
|
|
210
|
+
key = _state.sent();
|
|
211
|
+
return [
|
|
212
|
+
4,
|
|
213
|
+
crypto.subtle.sign(algorithm.name, key, enc.encode(value))
|
|
214
|
+
];
|
|
215
|
+
case 2:
|
|
216
|
+
signature = _state.sent();
|
|
217
|
+
digest = btoa((_String = String).fromCharCode.apply(_String, _to_consumable_array(new Uint8Array(signature))));
|
|
218
|
+
return [
|
|
219
|
+
2,
|
|
220
|
+
digest
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
return _hmacSHA256.apply(this, arguments);
|
|
226
|
+
}
|
|
@@ -156,54 +156,7 @@ function _ts_generator(thisArg, body) {
|
|
|
156
156
|
}
|
|
157
157
|
import { v4 } from 'uuid';
|
|
158
158
|
import { base64EncodeUrl, createBase64Encoder, createBase64UrlEncoder } from '../../utils/json-token';
|
|
159
|
-
|
|
160
|
-
* Computes the SHA256 digest of the given string
|
|
161
|
-
* @param value Value to hash
|
|
162
|
-
*/ export function sha256(value) {
|
|
163
|
-
return _sha256.apply(this, arguments);
|
|
164
|
-
}
|
|
165
|
-
function _sha256() {
|
|
166
|
-
_sha256 = _async_to_generator(function(value) {
|
|
167
|
-
var utf8, hashBuffer, hashArray, hashHex;
|
|
168
|
-
return _ts_generator(this, function(_state) {
|
|
169
|
-
switch(_state.label){
|
|
170
|
-
case 0:
|
|
171
|
-
utf8 = new TextEncoder().encode(value);
|
|
172
|
-
return [
|
|
173
|
-
4,
|
|
174
|
-
(globalThis.crypto || require('node:crypto').webcrypto).subtle.digest('SHA-256', utf8)
|
|
175
|
-
];
|
|
176
|
-
case 1:
|
|
177
|
-
hashBuffer = _state.sent();
|
|
178
|
-
hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
179
|
-
hashHex = hashArray.map(function(bytes) {
|
|
180
|
-
return bytes.toString(16).padStart(2, '0');
|
|
181
|
-
}).join('');
|
|
182
|
-
return [
|
|
183
|
-
2,
|
|
184
|
-
hashHex
|
|
185
|
-
];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
return _sha256.apply(this, arguments);
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Generates hash-based message authentication code using cryptographic hash function HmacSHA256 and the provided
|
|
193
|
-
* secret key
|
|
194
|
-
* Should only be in a NodeJS MDW context
|
|
195
|
-
* @param value Value to hash
|
|
196
|
-
* @param secretKey Secret cryptographic key
|
|
197
|
-
*/ export function hmacSHA256(value, secretKey) {
|
|
198
|
-
try {
|
|
199
|
-
// TODO: Use new Ecmascript crypto feature to avoid "require" call (issue #2110)
|
|
200
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
201
|
-
var createHmac = require('node:crypto').createHmac;
|
|
202
|
-
return createHmac('sha256', secretKey).update(value, 'latin1').digest('base64');
|
|
203
|
-
} catch (err) {
|
|
204
|
-
throw new Error('Crypto module is not available.');
|
|
205
|
-
}
|
|
206
|
-
}
|
|
159
|
+
import { hmacSHA256, sha256 } from './mgw-mdw-auth.helpers';
|
|
207
160
|
/**
|
|
208
161
|
* Header definition of the JWS used for the API Manager authentication
|
|
209
162
|
*/ var jwsHeader = {
|
|
@@ -313,10 +266,27 @@ function _sha256() {
|
|
|
313
266
|
* @param payload JWT payload
|
|
314
267
|
* @param secretKey secret key used to generate the signature
|
|
315
268
|
*/ function sign(payload, secretKey) {
|
|
316
|
-
var
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
269
|
+
var _this = this;
|
|
270
|
+
return _async_to_generator(function() {
|
|
271
|
+
var message, signature, encodedSignature;
|
|
272
|
+
return _ts_generator(this, function(_state) {
|
|
273
|
+
switch(_state.label){
|
|
274
|
+
case 0:
|
|
275
|
+
message = "".concat(_this.base64UrlEncoder(JSON.stringify(jwsHeader)), ".").concat(_this.base64UrlEncoder(JSON.stringify(payload)));
|
|
276
|
+
return [
|
|
277
|
+
4,
|
|
278
|
+
hmacSHA256(message, secretKey)
|
|
279
|
+
];
|
|
280
|
+
case 1:
|
|
281
|
+
signature = _state.sent();
|
|
282
|
+
encodedSignature = base64EncodeUrl(signature);
|
|
283
|
+
return [
|
|
284
|
+
2,
|
|
285
|
+
"".concat(message, ".").concat(encodedSignature)
|
|
286
|
+
];
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
})();
|
|
320
290
|
}
|
|
321
291
|
},
|
|
322
292
|
{
|
|
@@ -141,7 +141,8 @@ function _ts_generator(thisArg, body) {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
import { base64EncodeUrl, createBase64Decoder, createBase64UrlDecoder, createBase64UrlEncoder } from '../../utils/json-token';
|
|
144
|
-
import { hmacSHA256,
|
|
144
|
+
import { hmacSHA256, sha256 } from './mgw-mdw-auth.helpers';
|
|
145
|
+
import { MicroGatewayMiddlewareAuthenticationRequest } from './mgw-mdw-auth.request';
|
|
145
146
|
var authHeaderKey = 'Authorization';
|
|
146
147
|
var authHeaderPrefix = 'Bearer ';
|
|
147
148
|
var baseUrl = 'https://domain.com';
|
|
@@ -171,6 +172,10 @@ var jsonAuthTokenOptions = {
|
|
|
171
172
|
oid: 'NCE1A0955'
|
|
172
173
|
}
|
|
173
174
|
};
|
|
175
|
+
var hmacSHA256NodeImplementation = function(value, secretKey) {
|
|
176
|
+
var createHmac = require('node:crypto').createHmac;
|
|
177
|
+
return createHmac('sha256', secretKey).update(value, 'latin1').digest('base64');
|
|
178
|
+
};
|
|
174
179
|
describe('JSON auth token request plugin', function() {
|
|
175
180
|
beforeEach(function() {
|
|
176
181
|
options = {
|
|
@@ -319,7 +324,14 @@ describe('JSON auth token request plugin', function() {
|
|
|
319
324
|
secretKey = _state.sent();
|
|
320
325
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
321
326
|
message = "".concat(base64UrlEncoder(JSON.stringify(header)), ".").concat(base64UrlEncoder(JSON.stringify(payload)));
|
|
322
|
-
|
|
327
|
+
return [
|
|
328
|
+
4,
|
|
329
|
+
hmacSHA256(message, secretKey)
|
|
330
|
+
];
|
|
331
|
+
case 4:
|
|
332
|
+
signCheck = base64EncodeUrl.apply(void 0, [
|
|
333
|
+
_state.sent()
|
|
334
|
+
]);
|
|
323
335
|
expect(signature).toEqual(signCheck);
|
|
324
336
|
return [
|
|
325
337
|
2
|
|
@@ -327,4 +339,50 @@ describe('JSON auth token request plugin', function() {
|
|
|
327
339
|
}
|
|
328
340
|
});
|
|
329
341
|
}));
|
|
342
|
+
it('should have same hmacSHA256 of node implementation', /*#__PURE__*/ _async_to_generator(function() {
|
|
343
|
+
var base64URLDecoder, base64UrlEncoder, plugin, result, token, tokenParts, header, payload, secretKey, _, message;
|
|
344
|
+
return _ts_generator(this, function(_state) {
|
|
345
|
+
switch(_state.label){
|
|
346
|
+
case 0:
|
|
347
|
+
base64URLDecoder = createBase64UrlDecoder();
|
|
348
|
+
base64UrlEncoder = createBase64UrlEncoder();
|
|
349
|
+
plugin = new MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
|
|
350
|
+
return [
|
|
351
|
+
4,
|
|
352
|
+
plugin.load().transform(options)
|
|
353
|
+
];
|
|
354
|
+
case 1:
|
|
355
|
+
result = _state.sent();
|
|
356
|
+
token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
|
|
357
|
+
tokenParts = token.split('.');
|
|
358
|
+
header = JSON.parse(base64URLDecoder(tokenParts[0]));
|
|
359
|
+
payload = JSON.parse(base64URLDecoder(tokenParts[1]));
|
|
360
|
+
_ = jsonAuthTokenOptions.apiKey;
|
|
361
|
+
return [
|
|
362
|
+
4,
|
|
363
|
+
sha256(jsonAuthTokenOptions.secret + payload.jti + payload.iat + routePath)
|
|
364
|
+
];
|
|
365
|
+
case 2:
|
|
366
|
+
return [
|
|
367
|
+
4,
|
|
368
|
+
sha256.apply(void 0, [
|
|
369
|
+
_ + _state.sent()
|
|
370
|
+
])
|
|
371
|
+
];
|
|
372
|
+
case 3:
|
|
373
|
+
secretKey = _state.sent();
|
|
374
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
375
|
+
message = "".concat(base64UrlEncoder(JSON.stringify(header)), ".").concat(base64UrlEncoder(JSON.stringify(payload)));
|
|
376
|
+
return [
|
|
377
|
+
4,
|
|
378
|
+
expect(hmacSHA256(message, secretKey)).resolves.toBe(hmacSHA256NodeImplementation(message, secretKey))
|
|
379
|
+
];
|
|
380
|
+
case 4:
|
|
381
|
+
_state.sent();
|
|
382
|
+
return [
|
|
383
|
+
2
|
|
384
|
+
];
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
}));
|
|
330
388
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ama-sdk/core",
|
|
3
|
-
"version": "11.2.0-prerelease.
|
|
3
|
+
"version": "11.2.0-prerelease.53",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@angular-devkit/schematics": "~18.2.0",
|
|
80
80
|
"@angular/cli": "~18.2.0",
|
|
81
81
|
"@angular/common": "~18.2.0",
|
|
82
|
-
"@o3r/schematics": "^11.2.0-prerelease.
|
|
82
|
+
"@o3r/schematics": "^11.2.0-prerelease.53",
|
|
83
83
|
"@schematics/angular": "~18.2.0",
|
|
84
84
|
"isomorphic-fetch": "^3.0.0",
|
|
85
85
|
"rxjs": "^7.8.1",
|
|
@@ -119,9 +119,9 @@
|
|
|
119
119
|
"@angular/core": "~18.2.0",
|
|
120
120
|
"@nx/eslint-plugin": "~19.5.0",
|
|
121
121
|
"@nx/jest": "~19.5.0",
|
|
122
|
-
"@o3r/build-helpers": "^11.2.0-prerelease.
|
|
123
|
-
"@o3r/eslint-plugin": "^11.2.0-prerelease.
|
|
124
|
-
"@o3r/test-helpers": "^11.2.0-prerelease.
|
|
122
|
+
"@o3r/build-helpers": "^11.2.0-prerelease.53",
|
|
123
|
+
"@o3r/eslint-plugin": "^11.2.0-prerelease.53",
|
|
124
|
+
"@o3r/test-helpers": "^11.2.0-prerelease.53",
|
|
125
125
|
"@schematics/angular": "~18.2.0",
|
|
126
126
|
"@stylistic/eslint-plugin-ts": "~2.4.0",
|
|
127
127
|
"@swc/cli": "~0.4.0",
|
package/src/fwk/Reviver.d.ts
CHANGED
|
@@ -6,6 +6,20 @@ export interface ReviverOptions {
|
|
|
6
6
|
* @default console
|
|
7
7
|
*/
|
|
8
8
|
logger?: Logger;
|
|
9
|
+
/**
|
|
10
|
+
* Determine if the fields from dictionary should be removed from the given object.
|
|
11
|
+
* This options affects dictionary fields only if no dictionary is provided to the reviver function
|
|
12
|
+
* @default false
|
|
13
|
+
* @example Clear Dictionary fields from Data object
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Revived Data:
|
|
16
|
+
* const revivedData = reviveMyModel<MyModel>(data, myDictionary);
|
|
17
|
+
*
|
|
18
|
+
* // Remove dictionary from revived data :
|
|
19
|
+
* reviveMyModel(revivedData, undefined, { clearDictionaryFields: true });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
clearDictionaryFields?: boolean;
|
|
9
23
|
}
|
|
10
24
|
/** Reviver type */
|
|
11
25
|
export type ReviverType<T, V extends {
|
package/src/fwk/Reviver.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Reviver.d.ts","sourceRoot":"","sources":["../../../src/fwk/Reviver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"Reviver.d.ts","sourceRoot":"","sources":["../../../src/fwk/Reviver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;;;;;;;OAYG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,mBAAmB;AACnB,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAAE,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,IAC7I,CAAC,IAAI,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,KAAK,CAAC,GAAG,SAAS,CAAC;AAEvE;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAAE,YAAY,EAAE,GAAU,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc;;cAYrI;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,GAAU,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,mBAMtH;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc;;cAM7H"}
|
package/src/fwk/Reviver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Reviver.js","sourceRoot":"","sources":["../../../src/fwk/Reviver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Reviver.js","sourceRoot":"","sources":["../../../src/fwk/Reviver.ts"],"names":[],"mappings":"AA8BA;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAI,IAA4B,EAAE,eAAoB,IAAI,EAAE,OAAuB,EAAE,OAAwB;IACpI,IAAI,CAAC,IAAI,EAAE,CAAC;QAAC,OAAO,SAAS,CAAC;IAAC,CAAC;IAEhC,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,iDAAiD;QACjD,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAI,IAAW,EAAE,eAAoB,IAAI,EAAE,OAAuB,EAAE,OAAwB;IACrH,IAAI,CAAC,IAAI,EAAE,CAAC;QAAC,OAAO,SAAS,CAAC;IAAC,CAAC;IAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,IAAW,CAAC;AACrB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAI,GAAa,EAAE,UAAe,EAAE,OAAwB,EAAE,OAAwB;IAC5H,IAAI,CAAC,GAAG,EAAE,CAAC;QAAC,OAAO,SAAS,CAAC;IAAC,CAAC;IAC/B,OAAO,GAAG,CAAC,MAAM,CAAiC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE;QAC5D,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QAClF,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC"}
|
package/src/plugins/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './fetch-cache/index';
|
|
|
12
12
|
export * from './fetch-credentials/index';
|
|
13
13
|
export * from './json-token/index';
|
|
14
14
|
export * from './keepalive/index';
|
|
15
|
+
export * from './mgw-mdw-auth/index';
|
|
15
16
|
export * from './mock-intercept/index';
|
|
16
17
|
export * from './perf-metric/index';
|
|
17
18
|
export * from './pii-tokenizer/index';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,iBAAiB,CAAC;AAChC,cAAc,oCAAoC,CAAC;AACnD,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uCAAuC,CAAC;AACtD,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,iBAAiB,CAAC;AAChC,cAAc,oCAAoC,CAAC;AACnD,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uCAAuC,CAAC;AACtD,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
package/src/plugins/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export * from './fetch-cache/index';
|
|
|
12
12
|
export * from './fetch-credentials/index';
|
|
13
13
|
export * from './json-token/index';
|
|
14
14
|
export * from './keepalive/index';
|
|
15
|
+
export * from './mgw-mdw-auth/index';
|
|
15
16
|
export * from './mock-intercept/index';
|
|
16
17
|
export * from './perf-metric/index';
|
|
17
18
|
export * from './pii-tokenizer/index';
|
package/src/plugins/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,iBAAiB,CAAC;AAChC,cAAc,oCAAoC,CAAC;AACnD,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uCAAuC,CAAC;AACtD,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,iBAAiB,CAAC;AAChC,cAAc,oCAAoC,CAAC;AACnD,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uCAAuC,CAAC;AACtD,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the SHA256 digest of the given string
|
|
3
|
+
* @param value Value to hash
|
|
4
|
+
*/
|
|
5
|
+
export declare function sha256(value: string): Promise<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Generates hash-based message authentication code using cryptographic hash function HmacSHA256 and the provided
|
|
8
|
+
* secret key
|
|
9
|
+
* Should only be in a NodeJS MDW context
|
|
10
|
+
* @param value Value to hash
|
|
11
|
+
* @param secretKey Secret cryptographic key
|
|
12
|
+
*/
|
|
13
|
+
export declare function hmacSHA256(value: string, secretKey: string): Promise<string>;
|
|
14
|
+
//# sourceMappingURL=mgw-mdw-auth.helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mgw-mdw-auth.helpers.d.ts","sourceRoot":"","sources":["../../../../src/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,MAAM,mBAQzC;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAQhE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the SHA256 digest of the given string
|
|
3
|
+
* @param value Value to hash
|
|
4
|
+
*/
|
|
5
|
+
export async function sha256(value) {
|
|
6
|
+
const utf8 = new TextEncoder().encode(value);
|
|
7
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', utf8);
|
|
8
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
9
|
+
const hashHex = hashArray
|
|
10
|
+
.map((bytes) => bytes.toString(16).padStart(2, '0'))
|
|
11
|
+
.join('');
|
|
12
|
+
return hashHex;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generates hash-based message authentication code using cryptographic hash function HmacSHA256 and the provided
|
|
16
|
+
* secret key
|
|
17
|
+
* Should only be in a NodeJS MDW context
|
|
18
|
+
* @param value Value to hash
|
|
19
|
+
* @param secretKey Secret cryptographic key
|
|
20
|
+
*/
|
|
21
|
+
export async function hmacSHA256(value, secretKey) {
|
|
22
|
+
const enc = new TextEncoder();
|
|
23
|
+
const algorithm = { name: 'HMAC', hash: 'SHA-256' };
|
|
24
|
+
const key = await crypto.subtle.importKey('raw', enc.encode(secretKey), algorithm, false, ['sign', 'verify']);
|
|
25
|
+
const signature = await crypto.subtle.sign(algorithm.name, key, enc.encode(value));
|
|
26
|
+
const digest = btoa(String.fromCharCode(...new Uint8Array(signature)));
|
|
27
|
+
return digest;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=mgw-mdw-auth.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mgw-mdw-auth.helpers.js","sourceRoot":"","sources":["../../../../src/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAa;IACxC,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,SAAS;SACtB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SACnD,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,KAAa,EAAE,SAAiB;IAC/D,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAEpD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC9G,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACnF,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACvE,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
import { PluginRunner, RequestOptions, RequestPlugin } from '../core';
|
|
2
|
-
/**
|
|
3
|
-
* Computes the SHA256 digest of the given string
|
|
4
|
-
* @param value Value to hash
|
|
5
|
-
*/
|
|
6
|
-
export declare function sha256(value: string): Promise<string>;
|
|
7
|
-
/**
|
|
8
|
-
* Generates hash-based message authentication code using cryptographic hash function HmacSHA256 and the provided
|
|
9
|
-
* secret key
|
|
10
|
-
* Should only be in a NodeJS MDW context
|
|
11
|
-
* @param value Value to hash
|
|
12
|
-
* @param secretKey Secret cryptographic key
|
|
13
|
-
*/
|
|
14
|
-
export declare function hmacSHA256(value: string, secretKey: string): string;
|
|
15
2
|
/**
|
|
16
3
|
* Type that represents context data.
|
|
17
4
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mgw-mdw-auth.request.d.ts","sourceRoot":"","sources":["../../../../src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"mgw-mdw-auth.request.d.ts","sourceRoot":"","sources":["../../../../src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGtE;;GAEG;AACH,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;AAU/D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;;;;;;;OAUG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,sDAAsD;IACrE;;;;;;;;;;OAUG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,OAAO,EAAE,WAAW,CAAC;IAErB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,qBAAa,2CAA4C,YAAW,aAAa;IAE/E;;;;;;;;;;OAUG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAE1C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IAEtC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IAElC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;IAE/B;;;OAGG;gBACS,OAAO,EAAE,sDAAsD;IAa3E;;OAEG;IACH,OAAO,CAAC,eAAe;IAcvB;;;;OAIG;YACW,8CAA8C;IAM5D;;;;OAIG;YACW,IAAI;IAOlB;;;OAGG;YACW,WAAW;IAOlB,IAAI,IAAI,YAAY,CAAC,cAAc,EAAE,cAAc,CAAC;CAW5D"}
|
|
@@ -1,40 +1,6 @@
|
|
|
1
1
|
import { v4 } from 'uuid';
|
|
2
2
|
import { base64EncodeUrl, createBase64Encoder, createBase64UrlEncoder } from '../../utils/json-token';
|
|
3
|
-
|
|
4
|
-
* Computes the SHA256 digest of the given string
|
|
5
|
-
* @param value Value to hash
|
|
6
|
-
*/
|
|
7
|
-
export async function sha256(value) {
|
|
8
|
-
const utf8 = new TextEncoder().encode(value);
|
|
9
|
-
// TODO: Use new Ecmascript crypto feature to avoid "require" call (issue #2110)
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
11
|
-
const hashBuffer = await (globalThis.crypto || require('node:crypto').webcrypto).subtle.digest('SHA-256', utf8);
|
|
12
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
13
|
-
const hashHex = hashArray
|
|
14
|
-
.map((bytes) => bytes.toString(16).padStart(2, '0'))
|
|
15
|
-
.join('');
|
|
16
|
-
return hashHex;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Generates hash-based message authentication code using cryptographic hash function HmacSHA256 and the provided
|
|
20
|
-
* secret key
|
|
21
|
-
* Should only be in a NodeJS MDW context
|
|
22
|
-
* @param value Value to hash
|
|
23
|
-
* @param secretKey Secret cryptographic key
|
|
24
|
-
*/
|
|
25
|
-
export function hmacSHA256(value, secretKey) {
|
|
26
|
-
try {
|
|
27
|
-
// TODO: Use new Ecmascript crypto feature to avoid "require" call (issue #2110)
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
29
|
-
const { createHmac } = require('node:crypto');
|
|
30
|
-
return createHmac('sha256', secretKey)
|
|
31
|
-
.update(value, 'latin1')
|
|
32
|
-
.digest('base64');
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
throw new Error('Crypto module is not available.');
|
|
36
|
-
}
|
|
37
|
-
}
|
|
3
|
+
import { hmacSHA256, sha256 } from './mgw-mdw-auth.helpers';
|
|
38
4
|
/**
|
|
39
5
|
* Header definition of the JWS used for the API Manager authentication
|
|
40
6
|
*/
|
|
@@ -94,9 +60,9 @@ export class MicroGatewayMiddlewareAuthenticationRequest {
|
|
|
94
60
|
* @param payload JWT payload
|
|
95
61
|
* @param secretKey secret key used to generate the signature
|
|
96
62
|
*/
|
|
97
|
-
sign(payload, secretKey) {
|
|
63
|
+
async sign(payload, secretKey) {
|
|
98
64
|
const message = `${this.base64UrlEncoder(JSON.stringify(jwsHeader))}.${this.base64UrlEncoder(JSON.stringify(payload))}`;
|
|
99
|
-
const signature = hmacSHA256(message, secretKey);
|
|
65
|
+
const signature = await hmacSHA256(message, secretKey);
|
|
100
66
|
const encodedSignature = base64EncodeUrl(signature);
|
|
101
67
|
return `${message}.${encodedSignature}`;
|
|
102
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mgw-mdw-auth.request.js","sourceRoot":"","sources":["../../../../src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"mgw-mdw-auth.request.js","sourceRoot":"","sources":["../../../../src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.ts"],"names":[],"mappings":"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"}
|