scimgateway 4.5.5 → 4.5.6

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/README.md CHANGED
@@ -1163,6 +1163,12 @@ MIT © [Jarle Elshaug](https://www.elshaug.xyz)
1163
1163
 
1164
1164
  ## Change log
1165
1165
 
1166
+ ### v4.5.6
1167
+
1168
+ [Improved]
1169
+
1170
+ - plugin-ldap preserve multivalue-attribute order on modify. Do not apply to groups/members.
1171
+
1166
1172
  ### v4.5.5
1167
1173
 
1168
1174
  [Fixed]
@@ -1110,7 +1110,15 @@ const doRequest = async (baseEntity, method, base, ldapOptions, ctx) => {
1110
1110
  for (const key in options.modification) {
1111
1111
  const mod = {}
1112
1112
  mod.type = key
1113
- if (Array.isArray(options.modification[key])) mod.values = options.modification[key]
1113
+ if (Array.isArray(options.modification[key])) {
1114
+ mod.values = options.modification[key]
1115
+ if (mod.values.length > 1) { // delete before replace to keep inbound order
1116
+ changes.push({
1117
+ operation: 'delete',
1118
+ modification: {type: key, values: []}
1119
+ })
1120
+ }
1121
+ }
1114
1122
  else {
1115
1123
  if (typeof options.modification[key] === 'string') mod.values = [options.modification[key]]
1116
1124
  else mod.values = [options.modification[key].toString()]
@@ -2543,18 +2543,20 @@ ScimGateway.prototype.endpointMapper = function endpointMapper (direction, parse
2543
2543
  let arrIndex = null
2544
2544
  const arr = key.split('.') // multivalue/array - servicePlan.0.value
2545
2545
  const keyOrg = key
2546
- if (arr[arr.length - 1] === 'value') {
2547
- if (!isNaN(arr[arr.length - 2])) { // servicePlan.0.value => servicePlan.0
2548
- for (let i = 0; i < (arr.length - 2); i++) {
2546
+ if (arr.length > 1 && arr[arr.length - 1] === 'value') {
2547
+ const secondLast = arr.length - 2
2548
+ if (!isNaN(arr[secondLast])) { // servicePlan.0.value => servicePlan.0
2549
+ for (let i = 0; i < (secondLast); i++) {
2549
2550
  if (i === 0) key = arr[i]
2550
2551
  else key += `.${arr[i]}`
2551
2552
  }
2552
- arrIndex = arr[arr.length - 2]
2553
- } else if (arr[arr.length - 2].slice(-1) === ']' && arr.length - 2 === 0) { // groups[0].value => groups.value
2554
- const startPos = arr[0].indexOf('[')
2553
+ arrIndex = arr[secondLast]
2554
+ } else if (arr[secondLast].slice(-1) === ']') { // groups[0].value => groups.value
2555
+ const prefix = arr.slice(0, -1).join('.')
2556
+ const startPos = prefix.indexOf('[')
2555
2557
  if (startPos > 0) {
2556
- key = arr[0].substring(0, startPos) + '.value' // groups.value
2557
- arrIndex = arr[0].substring(startPos + 1, arr[0].length - 1) // 1
2558
+ key = prefix.substring(0, startPos) + '.value' // groups.value
2559
+ arrIndex = prefix.substring(startPos + 1, prefix.length - 1) // 1
2558
2560
  }
2559
2561
  }
2560
2562
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scimgateway",
3
- "version": "4.5.5",
3
+ "version": "4.5.6",
4
4
  "description": "Using SCIM protocol as a gateway for user provisioning to other endpoints",
5
5
  "author": "Jarle Elshaug <jarle.elshaug@gmail.com> (https://elshaug.xyz)",
6
6
  "homepage": "https://elshaug.xyz",