@itentialopensource/adapter-utils 4.45.6 → 4.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/lib/connectorRest.js +40 -6
- package/lib/translatorUtil.js +5 -4
- package/package.json +1 -1
- package/schemas/propertiesSchema.json +28 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,34 @@
|
|
|
1
1
|
|
|
2
|
+
## 4.47.0 [08-13-2022]
|
|
3
|
+
|
|
4
|
+
* Add SSO capability into service instance config
|
|
5
|
+
|
|
6
|
+
Closes ADAPT-2328
|
|
7
|
+
|
|
8
|
+
See merge request itentialopensource/adapter-utils!235
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 4.46.0 [07-27-2022]
|
|
13
|
+
|
|
14
|
+
* Added code to skip split string on dot for special cases
|
|
15
|
+
|
|
16
|
+
Closes ADAPT-2266
|
|
17
|
+
|
|
18
|
+
See merge request itentialopensource/adapter-utils!234
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 4.45.7 [07-25-2022]
|
|
23
|
+
|
|
24
|
+
* Fix issue on no token where it takes exception
|
|
25
|
+
|
|
26
|
+
Closes ADAPT-2244
|
|
27
|
+
|
|
28
|
+
See merge request itentialopensource/adapter-utils!233
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
2
32
|
## 4.45.6 [05-19-2022]
|
|
3
33
|
|
|
4
34
|
* Change for token request with Auth header and data
|
package/lib/connectorRest.js
CHANGED
|
@@ -62,6 +62,7 @@ let tokenTimeout = -1;
|
|
|
62
62
|
let tokenError = 401;
|
|
63
63
|
let tokenPath = null;
|
|
64
64
|
let tokenCache = 'local';
|
|
65
|
+
let sso = null;
|
|
65
66
|
const tokenList = [];
|
|
66
67
|
const tokenlock = 0;
|
|
67
68
|
let stub = false;
|
|
@@ -1646,6 +1647,28 @@ function buildTokenRequest(reqPath, reqBody, callProperties, callback) {
|
|
|
1646
1647
|
}
|
|
1647
1648
|
|
|
1648
1649
|
// specific token properties override everything (Single Sign On System)
|
|
1650
|
+
if (sso && sso.host) {
|
|
1651
|
+
options.hostname = sso.host;
|
|
1652
|
+
}
|
|
1653
|
+
if (sso && sso.port) {
|
|
1654
|
+
options.port = sso.port;
|
|
1655
|
+
}
|
|
1656
|
+
if (sso && sso.protocol) {
|
|
1657
|
+
// need to put protocol in token schema
|
|
1658
|
+
if (!tokenSchema) {
|
|
1659
|
+
tokenSchema = {
|
|
1660
|
+
sso: {
|
|
1661
|
+
protocol: sso.protocol
|
|
1662
|
+
}
|
|
1663
|
+
};
|
|
1664
|
+
} else if (tokenSchema && !tokenSchema.sso) {
|
|
1665
|
+
tokenSchema.sso = {
|
|
1666
|
+
protocol: sso.protocol
|
|
1667
|
+
};
|
|
1668
|
+
} else if (tokenSchema && tokenSchema.sso && !tokenSchema.sso.protocol) {
|
|
1669
|
+
tokenSchema.sso.protocol = sso.protocol;
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1649
1672
|
if (tokenSchema && tokenSchema.sso && tokenSchema.sso.host) {
|
|
1650
1673
|
options.hostname = tokenSchema.sso.host;
|
|
1651
1674
|
}
|
|
@@ -2124,6 +2147,9 @@ function getTokenItem(pathForToken, user, reqBody, invalidToken, callProperties,
|
|
|
2124
2147
|
if (berror) {
|
|
2125
2148
|
done(null, berror);
|
|
2126
2149
|
}
|
|
2150
|
+
if (!dyntoken) {
|
|
2151
|
+
done(null, 'No Token returned');
|
|
2152
|
+
}
|
|
2127
2153
|
|
|
2128
2154
|
let timeout = tokenTimeout;
|
|
2129
2155
|
|
|
@@ -2396,6 +2422,9 @@ function requestAuthenticate(request, entitySchema, invalidToken, callProperties
|
|
|
2396
2422
|
if (berror) {
|
|
2397
2423
|
return callback(null, berror);
|
|
2398
2424
|
}
|
|
2425
|
+
if (!dyntoken) {
|
|
2426
|
+
return callback(null, 'No Token returned');
|
|
2427
|
+
}
|
|
2399
2428
|
|
|
2400
2429
|
// format the authentication string
|
|
2401
2430
|
const tokenObj = {
|
|
@@ -3341,19 +3370,19 @@ class ConnectorRest {
|
|
|
3341
3370
|
tokenTimeout = Number(props.authentication.token_timeout);
|
|
3342
3371
|
}
|
|
3343
3372
|
|
|
3344
|
-
// set the token cache (
|
|
3373
|
+
// set the token cache (optional - default is local)
|
|
3345
3374
|
if (typeof props.authentication.token_cache === 'string') {
|
|
3346
3375
|
tokenCache = props.authentication.token_cache;
|
|
3347
3376
|
}
|
|
3348
3377
|
|
|
3349
|
-
// set the auth field (
|
|
3378
|
+
// set the auth field (optional - default is null)
|
|
3350
3379
|
if (typeof props.authentication.auth_field === 'string') {
|
|
3351
3380
|
authField = [props.authentication.auth_field];
|
|
3352
3381
|
} else if (Array.isArray(props.authentication.auth_field)) {
|
|
3353
3382
|
authField = props.authentication.auth_field;
|
|
3354
3383
|
}
|
|
3355
3384
|
|
|
3356
|
-
// set the auth format (
|
|
3385
|
+
// set the auth format (optional - default is null)
|
|
3357
3386
|
if (typeof props.authentication.auth_field_format === 'string') {
|
|
3358
3387
|
authFormat = [props.authentication.auth_field_format];
|
|
3359
3388
|
} else if (Array.isArray(props.authentication.auth_field_format)) {
|
|
@@ -3365,20 +3394,25 @@ class ConnectorRest {
|
|
|
3365
3394
|
authLogging = props.authentication.auth_logging;
|
|
3366
3395
|
}
|
|
3367
3396
|
|
|
3368
|
-
// set the client id (
|
|
3397
|
+
// set the client id (optional - default is null)
|
|
3369
3398
|
if (typeof props.authentication.client_id === 'string') {
|
|
3370
3399
|
clientId = props.authentication.client_id;
|
|
3371
3400
|
}
|
|
3372
3401
|
|
|
3373
|
-
// set the client secret (
|
|
3402
|
+
// set the client secret (optional - default is null)
|
|
3374
3403
|
if (typeof props.authentication.client_secret === 'string') {
|
|
3375
3404
|
clientSecret = props.authentication.client_secret;
|
|
3376
3405
|
}
|
|
3377
3406
|
|
|
3378
|
-
// set the grant type (
|
|
3407
|
+
// set the grant type (optional - default is null)
|
|
3379
3408
|
if (typeof props.authentication.grant_type === 'string') {
|
|
3380
3409
|
grantType = props.authentication.grant_type;
|
|
3381
3410
|
}
|
|
3411
|
+
|
|
3412
|
+
// set the sso (optional - default is null)
|
|
3413
|
+
if (props.authentication.sso && typeof props.authentication.sso === 'object') {
|
|
3414
|
+
sso = props.authentication.sso;
|
|
3415
|
+
}
|
|
3382
3416
|
}
|
|
3383
3417
|
|
|
3384
3418
|
// set the stub mode (optional - default is false)
|
package/lib/translatorUtil.js
CHANGED
|
@@ -247,6 +247,7 @@ function extractObject(dataObj, entitySchema, dynamicFields) {
|
|
|
247
247
|
log.trace(origin);
|
|
248
248
|
const returnObj = {};
|
|
249
249
|
let addFields = dynamicFields;
|
|
250
|
+
const regex = /(?<!\\)\./gm;
|
|
250
251
|
|
|
251
252
|
// if no translation needed - just return the object
|
|
252
253
|
if (Object.hasOwnProperty.call(entitySchema, 'translate')
|
|
@@ -278,7 +279,7 @@ function extractObject(dataObj, entitySchema, dynamicFields) {
|
|
|
278
279
|
// if the external name is something get that field
|
|
279
280
|
if (field.external_name) {
|
|
280
281
|
// need to determine the field in the incoming object where the data is
|
|
281
|
-
const externalPath = field.external_name.split('.');
|
|
282
|
+
const externalPath = field.external_name.split(regex).map((e) => (e.replace(/\\./g, '.')));
|
|
282
283
|
let location = dataObj;
|
|
283
284
|
let inField = null;
|
|
284
285
|
|
|
@@ -349,7 +350,7 @@ function extractObject(dataObj, entitySchema, dynamicFields) {
|
|
|
349
350
|
// if the field is not in the schema - we need to add it
|
|
350
351
|
// using the field name that came in since no translation
|
|
351
352
|
if (field.external_name) {
|
|
352
|
-
const externalPath = field.external_name.split('.');
|
|
353
|
+
const externalPath = field.external_name.split(regex).map((e) => (e.replace(/\\./g, '.')));
|
|
353
354
|
|
|
354
355
|
if (externalPath[externalPath.length - 1] === objectKeys[o]) {
|
|
355
356
|
found = true;
|
|
@@ -488,7 +489,7 @@ function extractJSONEntity(dataObj, entitySchema) {
|
|
|
488
489
|
function buildObject(dataObj, entitySchema, dynamicFields) {
|
|
489
490
|
const origin = `${id}-translatorUtil-buildObject`;
|
|
490
491
|
log.trace(origin);
|
|
491
|
-
|
|
492
|
+
const regex = /(?<!\\)\./gm;
|
|
492
493
|
const returnObj = {};
|
|
493
494
|
let addFields = dynamicFields;
|
|
494
495
|
|
|
@@ -531,7 +532,7 @@ function buildObject(dataObj, entitySchema, dynamicFields) {
|
|
|
531
532
|
// if in the data object, add to the system entity
|
|
532
533
|
if (fieldValue !== null) {
|
|
533
534
|
// need to determine the field in the object where the data should go
|
|
534
|
-
const externalPath = field.external_name.split('.');
|
|
535
|
+
const externalPath = field.external_name.split(regex).map((e) => (e.replace(/\\./g, '.')));
|
|
535
536
|
let location = returnObj;
|
|
536
537
|
|
|
537
538
|
// get to the field in the object
|
package/package.json
CHANGED
|
@@ -252,6 +252,34 @@
|
|
|
252
252
|
"type": "string",
|
|
253
253
|
"description": "The grant type for OAuth requests - can also provide in schema",
|
|
254
254
|
"default": ""
|
|
255
|
+
},
|
|
256
|
+
"sso": {
|
|
257
|
+
"type": "object",
|
|
258
|
+
"properties": {
|
|
259
|
+
"protocol": {
|
|
260
|
+
"type": "string",
|
|
261
|
+
"description": "the protocol to request token from system",
|
|
262
|
+
"default": "",
|
|
263
|
+
"enum": [
|
|
264
|
+
"http", "https", ""
|
|
265
|
+
]
|
|
266
|
+
},
|
|
267
|
+
"host": {
|
|
268
|
+
"type": "string",
|
|
269
|
+
"description": "hostname of the authentication system",
|
|
270
|
+
"default": "",
|
|
271
|
+
"examples": [
|
|
272
|
+
"systemx.customer.com"
|
|
273
|
+
]
|
|
274
|
+
},
|
|
275
|
+
"port": {
|
|
276
|
+
"type": "integer",
|
|
277
|
+
"description": "port on which to connect to the authentication system",
|
|
278
|
+
"default": 0,
|
|
279
|
+
"minimum": 0,
|
|
280
|
+
"maximum": 65535
|
|
281
|
+
}
|
|
282
|
+
}
|
|
255
283
|
}
|
|
256
284
|
},
|
|
257
285
|
"required": [
|