Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scim-patch

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scim-patch - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

.nyc_output/022cf7b4-de7d-49d0-bad2-76eda8d7b6b5.json

2

.nyc_output/processinfo/index.json

@@ -1,1 +0,1 @@

{"processes":{"42546ea1-57f6-49b7-8028-c9dcca83ec34":{"parent":null,"children":[]}},"files":{"/home/travis/build/thomaspoignant/scim-patch/lib/src/scimPatch.js":["42546ea1-57f6-49b7-8028-c9dcca83ec34"],"/home/travis/build/thomaspoignant/scim-patch/lib/src/errors/scimErrors.js":["42546ea1-57f6-49b7-8028-c9dcca83ec34"]},"externalIds":{}}
{"processes":{"022cf7b4-de7d-49d0-bad2-76eda8d7b6b5":{"parent":null,"children":[]}},"files":{"/home/travis/build/thomaspoignant/scim-patch/lib/src/scimPatch.js":["022cf7b4-de7d-49d0-bad2-76eda8d7b6b5"],"/home/travis/build/thomaspoignant/scim-patch/lib/src/errors/scimErrors.js":["022cf7b4-de7d-49d0-bad2-76eda8d7b6b5"]},"externalIds":{}}

@@ -100,3 +100,2 @@ "use strict";

function applyRemoveOperation(scimResource, patch) {
var _a;
// We manipulate the object directly without knowing his property, that's why we use any.

@@ -106,3 +105,3 @@ let resource = scimResource;

// Path is supposed to be set, there are a validation in the validateOperation function.
const paths = ((_a = patch.path) === null || _a === void 0 ? void 0 : _a.split('.')) || [];
const paths = patch.path.split('.');
resource = navigate(resource, paths);

@@ -149,5 +148,5 @@ // Dealing with the last element of the path.

}
// We are sure to find an index because matchFilter comes from array.
const index = array.findIndex(item => matchFilter.includes(item));
if (index !== -1)
array[index] = addOrReplaceAttribute(array[index], patch);
array[index] = addOrReplaceAttribute(array[index], patch);
return scimResource;

@@ -186,8 +185,7 @@ }

try {
// Get the list of items who are successful for the search query.
// Get the item who is successful for the search query.
const matchFilter = filterWithQuery(array, valuePath);
// We iterate over the array to find the matching element.
for (let j = 0; j < array.length && matchFilter.length > 0; j++)
if (matchFilter.includes(array[j]))
schema = array[j];
// We are sure to find an index because matchFilter comes from array.
const index = array.findIndex(item => matchFilter.includes(item));
schema = array[index];
}

@@ -194,0 +192,0 @@ catch (error) {

@@ -160,3 +160,3 @@ "use strict";

});
it('ADD: add a non object value to an object key', done => {
it('REPLACE: add a non object value to an object key', done => {
const expected = 'BATMAN';

@@ -168,2 +168,20 @@ const patch = { op: 'replace', path: 'name', value: expected };

});
it('REPLACE: should not modify anything if element not found', done => {
scimUser.name.nestedArray = [{ primary: true, value: 'value1' }];
const patch1 = {
op: 'replace', value: {
newProperty1: 'toto'
}, path: 'name.nestedArray[toto eq true]'
};
const afterPatch = scimPatch_1.scimPatch(scimUser, [patch1]);
chai_1.expect(afterPatch.name.nestedArray).to.be.eq(scimUser.name.nestedArray);
return done();
});
it('REPLACE: XXX', done => {
const patch1 = { op: 'remove', path: 'emails[primary eq true].value' };
const afterPatch = scimPatch_1.scimPatch(scimUser, [patch1]);
chai_1.expect(afterPatch.emails[0].value).not.to.exist;
chai_1.expect(afterPatch.emails[0].primary).to.eq(true);
return done();
});
});

@@ -329,2 +347,13 @@ describe('add', () => {

});
it('ADD: should not modify anything if element not found', done => {
scimUser.name.nestedArray = [{ primary: true, value: 'value1' }];
const patch1 = {
op: 'add', value: {
newProperty1: 'toto'
}, path: 'name.nestedArray[toto eq true]'
};
const afterPatch = scimPatch_1.scimPatch(scimUser, [patch1]);
chai_1.expect(afterPatch.name.nestedArray).to.be.eq(scimUser.name.nestedArray);
return done();
});
});

@@ -406,4 +435,13 @@ describe('remove', () => {

});
it('INVALID: invalid parameter in scim filter', done => {
const patch = {
op: 'replace',
value: true,
path: 'emails[\' eq true].value'
};
chai_1.expect(() => scimPatch_1.scimPatch(scimUser, [patch])).to.throw(scimPatch_1.InvalidScimPatchOp);
return done();
});
});
});
//# sourceMappingURL=scimPatch.test.js.map
{
"name": "scim-patch",
"version": "0.1.3",
"version": "0.1.4",
"description": "SCIM Patch operation (rfc7644).",

@@ -5,0 +5,0 @@ "main": "lib/src/scimPatch.js",

@@ -151,3 +151,3 @@ import {

// Path is supposed to be set, there are a validation in the validateOperation function.
const paths = patch.path?.split('.') || [];
const paths = patch.path.split('.');
resource = navigate(resource, paths);

@@ -208,5 +208,5 @@

// We are sure to find an index because matchFilter comes from array.
const index = array.findIndex(item => matchFilter.includes(item));
if (index !== -1)
array[index] = addOrReplaceAttribute(array[index], patch);
array[index] = addOrReplaceAttribute(array[index], patch);

@@ -253,10 +253,7 @@ return scimResource;

try {
// Get the list of items who are successful for the search query.
// Get the item who is successful for the search query.
const matchFilter = filterWithQuery<any>(array, valuePath);
// We iterate over the array to find the matching element.
for (let j = 0; j < array.length && matchFilter.length > 0; j++)
if (matchFilter.includes(array[j]))
schema = array[j];
// We are sure to find an index because matchFilter comes from array.
const index = array.findIndex(item => matchFilter.includes(item));
schema = array[index];
} catch (error) {

@@ -263,0 +260,0 @@ throw new InvalidScimPatchOp(error);

@@ -178,3 +178,3 @@ import {

it('ADD: add a non object value to an object key', done => {
it('REPLACE: add a non object value to an object key', done => {
const expected = 'BATMAN';

@@ -186,2 +186,22 @@ const patch: ScimPatchAddReplaceOperation = {op: 'replace', path: 'name', value: expected};

});
it('REPLACE: should not modify anything if element not found', done => {
scimUser.name.nestedArray = [{primary: true, value: 'value1'}];
const patch1: ScimPatchAddReplaceOperation = {
op: 'replace', value: {
newProperty1: 'toto'
}, path: 'name.nestedArray[toto eq true]'
};
const afterPatch: ScimUser = <ScimUser>scimPatch(scimUser, [patch1]);
expect(afterPatch.name.nestedArray).to.be.eq(scimUser.name.nestedArray);
return done();
});
it('REPLACE: XXX', done => {
const patch1: ScimPatchRemoveOperation = {op: 'remove', path: 'emails[primary eq true].value'};
const afterPatch: ScimUser = <ScimUser>scimPatch(scimUser, [patch1]);
expect(afterPatch.emails[0].value).not.to.exist;
expect(afterPatch.emails[0].primary).to.eq(true);
return done();
});
});

@@ -359,2 +379,14 @@

});
it('ADD: should not modify anything if element not found', done => {
scimUser.name.nestedArray = [{primary: true, value: 'value1'}];
const patch1: ScimPatchAddReplaceOperation = {
op: 'add', value: {
newProperty1: 'toto'
}, path: 'name.nestedArray[toto eq true]'
};
const afterPatch: ScimUser = <ScimUser>scimPatch(scimUser, [patch1]);
expect(afterPatch.name.nestedArray).to.be.eq(scimUser.name.nestedArray);
return done();
});
});

@@ -446,3 +478,13 @@ describe('remove', () => {

});
it('INVALID: invalid parameter in scim filter', done => {
const patch: ScimPatchAddReplaceOperation = {
op: 'replace',
value: true,
path: 'emails[\' eq true].value'
};
expect(() => scimPatch(scimUser, [patch])).to.throw(InvalidScimPatchOp);
return done();
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc