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

kinvey-flex-sdk

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kinvey-flex-sdk - npm Package Compare versions

Comparing version 2.0.9 to 2.1.0

8

CHANGELOG.md
## Changelog
### 2.1.0
* Added role helper to kinveyEntity module (ronheiney)
* FLEX-212 Disable proxy for push and email modules
* FLEX-68 Disable proxy when using dataStore
* FLEX-204 Fixed errors for null or empty entityIds for dataStore, groupStore, and userStore
* Updated request module to 2.85.0
* Updated code-task-receiver to 2.2.3 to add response object parsing for FlexFunctions (FLEX-220)
### 2.0.9

@@ -4,0 +12,0 @@ * FLEX-173 Fix for content.objectName undefined if request.collectionName passed

3

lib/service/modules/baseStore.js

@@ -66,3 +66,4 @@ /**

headers,
json: true
json: true,
proxy: false
};

@@ -69,0 +70,0 @@

@@ -53,3 +53,3 @@ /**

if (!entityId || typeof entityId === 'function') {
callback = entityId;
callback = typeof entityId === 'function' ? entityId : callback;
const err = new Error('DataStoreError');

@@ -87,3 +87,3 @@ err.description = 'Bad Request';

if (!entityId || typeof entityId === 'function') {
callback = entityId;
callback = typeof entityId === 'function' ? entityId : callback;
const err = new Error('DataStoreError');

@@ -90,0 +90,0 @@ err.description = 'Bad Request';

@@ -76,3 +76,4 @@ /**

html: htmlBody
}
},
proxy: false
}, (err, res, body) => {

@@ -79,0 +80,0 @@ if (callback) {

@@ -83,3 +83,3 @@ /**

if (!groupId || typeof groupId === 'function') {
callback = groupId;
callback = typeof groupId === 'function' ? groupId : callback;
const err = new Error('GroupStoreError');

@@ -100,3 +100,3 @@ err.description = 'Bad Request';

if (!groupId || typeof groupId === 'function') {
callback = groupId;
callback = typeof groupId === 'function' ? groupId : callback;
const err = new Error('GroupStoreError');

@@ -103,0 +103,0 @@ err.description = 'Bad Request';

@@ -85,2 +85,14 @@ /**

function getReaderRoles() {
return getProp(_entity, ['_acl', 'roles', 'r'], []);
}
function getUpdateRoles() {
return getProp(_entity, ['_acl', 'roles', 'u'], []);
}
function getDeleteRoles() {
return getProp(_entity, ['_acl', 'roles', 'd'], []);
}
function addReader(userId) {

@@ -112,2 +124,23 @@ if (!(getProp(_entity, ['_acl', 'r']))) _entity._acl.r = [];

function addReaderRole(roleId) {
if (!(getProp(_entity, ['_acl', 'roles']))) _entity._acl.roles = {};
if (!(getProp(_entity, ['_acl', 'roles', 'r']))) _entity._acl.roles.r = [];
if (_entity._acl.roles.r.indexOf(roleId) === -1) _entity._acl.roles.r.push(roleId);
return aclFunctions;
}
function addUpdateRole(roleId) {
if (!(getProp(_entity, ['_acl', 'roles']))) _entity._acl.roles = {};
if (!(getProp(_entity, ['_acl', 'roles', 'u']))) _entity._acl.roles.u = [];
if (_entity._acl.roles.u.indexOf(roleId) === -1) _entity._acl.roles.u.push(roleId);
return aclFunctions;
}
function addDeleteRole(roleId) {
if (!(getProp(_entity, ['_acl', 'roles']))) _entity._acl.roles = {};
if (!(getProp(_entity, ['_acl', 'roles', 'd']))) _entity._acl.roles.d = [];
if (_entity._acl.roles.d.indexOf(roleId) === -1) _entity._acl.roles.d.push(roleId);
return aclFunctions;
}
function removeReader(userId) {

@@ -151,2 +184,33 @@ let userIx = (getProp(_entity, ['_acl', 'r'], [])).indexOf(userId);

function removeReaderRole(roleId) {
let roleIx = (getProp(_entity, ['_acl', 'roles', 'r'], [])).indexOf(roleId);
while (roleIx !== -1) {
_entity._acl.roles.r.splice(roleIx, 1);
roleIx = _entity._acl.roles.r.indexOf(roleId);
}
return aclFunctions;
}
function removeUpdateRole(roleId) {
let updates = getProp(_entity, ['_acl', 'roles', 'u'], []);
let roleIx = updates.indexOf(roleId);
while (roleIx !== -1) {
_entity._acl.roles.u.splice(roleIx, 1);
updates = getProp(_entity, ['_acl', 'roles', 'u'], []);
roleIx = updates.indexOf(roleId);
}
return aclFunctions;
}
function removeDeleteRole(roleId) {
let deletes = getProp(_entity, ['_acl', 'roles', 'd'], []);
let roleIx = deletes.indexOf(roleId);
while (roleIx !== -1) {
_entity._acl.roles.d.splice(roleIx, 1);
deletes = getProp(_entity, ['_acl', 'roles', 'd'], []);
roleIx = deletes.indexOf(roleId);
}
return aclFunctions;
}
function getGloballyReadable() {

@@ -178,2 +242,5 @@ if (typeof _entity._acl.gr === 'undefined') _entity._acl.gr = null;

getWriterGroups,
getReaderRoles,
getUpdateRoles,
getDeleteRoles,
addReader,

@@ -183,2 +250,5 @@ addWriter,

addWriterGroup,
addReaderRole,
addUpdateRole,
addDeleteRole,
removeReader,

@@ -188,2 +258,5 @@ removeWriter,

removeWriterGroup,
removeReaderRole,
removeUpdateRole,
removeDeleteRole,
getGloballyReadable,

@@ -190,0 +263,0 @@ getGloballyWritable,

@@ -51,3 +51,4 @@ /**

messageContent: message
}
},
proxy: false
}, (err, res, body) => {

@@ -54,0 +55,0 @@ if (!isNil(callback)) {

@@ -83,3 +83,3 @@ /**

if (!userId || typeof userId === 'function') {
callback = userId;
callback = typeof userId === 'function' ? userId : callback;
const err = new Error('UserStoreError');

@@ -121,3 +121,3 @@ err.description = 'Bad Request';

if (!userId || typeof userId === 'function') {
callback = userId;
callback = typeof userId === 'function' ? userId : callback;
const err = new Error('UserStoreError');

@@ -143,3 +143,3 @@ err.description = 'Bad Request';

if (!userId || typeof userId === 'function') {
callback = userId;
callback = typeof userId === 'function' ? userId : callback;
const err = new Error('UserStoreError');

@@ -165,3 +165,3 @@ err.description = 'Bad Request';

if (!userId || typeof userId === 'function') {
callback = userId;
callback = typeof userId === 'function' ? userId : callback;
const err = new Error('UserStoreError');

@@ -168,0 +168,0 @@ err.description = 'Bad Request';

{
"name": "kinvey-flex-sdk",
"version": "2.0.9",
"version": "2.1.0",
"description": "SDK for creating Kinvey Flex Services",

@@ -20,3 +20,3 @@ "engines": {

"bson": "0.4.23",
"kinvey-code-task-runner": "2.2.2",
"kinvey-code-task-runner": "2.2.3",
"kinvey-datalink-errors": "0.3.0",

@@ -31,3 +31,3 @@ "lodash.forown": "4.2.0",

"moment": "2.21.0",
"request": "2.72.0",
"request": "2.85.0",
"sift": "3.2.6"

@@ -34,0 +34,0 @@ },

@@ -508,2 +508,24 @@ /**

});
it('should return an error if null entityId', (done) => {
const collection = this.store().collection('myCollection');
collection.findById(null, (err, result) => {
should.not.exist(result);
err.message.should.eql('DataStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('entityId is required');
return done();
});
});
it('should return an error if blank entityId', (done) => {
const collection = this.store().collection('myCollection');
collection.findById('', (err, result) => {
should.not.exist(result);
err.message.should.eql('DataStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('entityId is required');
return done();
});
});
});

@@ -1041,2 +1063,24 @@ describe('save', () => {

});
it('should return an error if null entityId', (done) => {
const collection = this.store().collection('myCollection');
collection.removeById(null, (err, result) => {
should.not.exist(result);
err.message.should.eql('DataStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('entityId is required');
return done();
});
});
it('should return an error if blank entityId', (done) => {
const collection = this.store().collection('myCollection');
collection.removeById('', (err, result) => {
should.not.exist(result);
err.message.should.eql('DataStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('entityId is required');
return done();
});
});
});

@@ -1043,0 +1087,0 @@

@@ -150,3 +150,4 @@ /**

'removeReader',
'getWriters', 'addWriter',
'getWriters',
'addWriter',
'removeWriter',

@@ -162,3 +163,12 @@ 'getReaderGroups',

'setGloballyReadable',
'setGloballyWritable'
'setGloballyWritable',
'getReaderRoles',
'getUpdateRoles',
'getDeleteRoles',
'addReaderRole',
'addUpdateRole',
'addDeleteRole',
'removeReaderRole',
'removeUpdateRole',
'removeDeleteRole'
];

@@ -630,2 +640,362 @@ kinveyInstance.entity(testObject);

});
describe('getReaderRoles', () => {
it('returns empty array when no role readers', (done) => {
const ke = kinveyInstance.entity();
ke._acl.getReaderRoles().should.eql([]);
return done();
});
return it('returns correct value for entity with readers', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
r: [1, 2, 3]
}
}
});
ke._acl.getReaderRoles().should.eql([1, 2, 3]);
return done();
});
});
describe('addReaderRole', () => {
it('Adds a reader to an stub entity', (done) => {
const ke = kinveyInstance.entity();
ke._acl.addReaderRole('1');
ke._acl.getReaderRoles().should.eql(['1']);
return done();
});
it('wont add an existing reader id', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
r: [1, 2, 3]
}
}
});
ke._acl.addReaderRole(1);
ke._acl.getReaderRoles().should.eql([1, 2, 3]);
return done();
});
it('appends a role ID to existing list', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
r: [1, 2, 3]
}
}
});
ke._acl.addReaderRole(4);
ke._acl.getReaderRoles().should.eql([1, 2, 3, 4]);
return done();
});
return it('returns entity acls for method chaining', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
r: [1, 2, 3]
}
}
});
ke._acl.addReaderRole(4).getReaderRoles().should.eql([1, 2, 3, 4]);
return done();
});
});
describe('removeReaderRole', () => {
it('removes a reader role when a match is found', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
r: [1, 2, 3]
}
}
});
ke._acl.removeReaderRole(1);
ke._acl.getReaderRoles().should.eql([2, 3]);
return done();
});
it('does nothing when a match is not found', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
r: [1, 2, 3]
}
}
});
ke._acl.removeReaderRole(4);
ke._acl.getReaderRoles().should.eql([1, 2, 3]);
return done();
});
it('does nothing when no reader roles are defined', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {}
}
});
ke._acl.removeReaderRole(1);
ke._acl.getReaderRoles().should.eql([]);
return done();
});
it('will remove all instances of a role id', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
r: [1, 2, 3, 1]
}
}
});
ke._acl.removeReaderRole(1);
ke._acl.getReaderRoles().should.eql([2, 3]);
return done();
});
return it('returns entity acls for method chaining', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
r: [1, 2, 3, 1]
}
}
});
ke._acl.removeReaderRole(1).getReaderRoles().should.eql([2, 3]);
return done();
});
});
describe('getUpdateRoles', () => {
it('returns empty array when no role updates', (done) => {
const ke = kinveyInstance.entity();
ke._acl.getUpdateRoles().should.eql([]);
return done();
});
return it('returns correct value for entity with updates', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
u: [1, 2, 3]
}
}
});
ke._acl.getUpdateRoles().should.eql([1, 2, 3]);
return done();
});
});
describe('addUpdateRole', () => {
it('Adds a update to an stub entity', (done) => {
const ke = kinveyInstance.entity();
ke._acl.addUpdateRole('1');
ke._acl.getUpdateRoles().should.eql(['1']);
return done();
});
it('wont add an existing update id', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
u: [1, 2, 3]
}
}
});
ke._acl.addUpdateRole(1);
ke._acl.getUpdateRoles().should.eql([1, 2, 3]);
return done();
});
it('appends a role ID to existing list', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
u: [1, 2, 3]
}
}
});
ke._acl.addUpdateRole(4);
ke._acl.getUpdateRoles().should.eql([1, 2, 3, 4]);
return done();
});
return it('returns entity acls for method chaining', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
u: [1, 2, 3]
}
}
});
ke._acl.addUpdateRole(4).getUpdateRoles().should.eql([1, 2, 3, 4]);
return done();
});
});
describe('removeUpdateRole', () => {
it('removes a update role when a match is found', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
u: [1, 2, 3]
}
}
});
ke._acl.removeUpdateRole(1);
ke._acl.getUpdateRoles().should.eql([2, 3]);
return done();
});
it('does nothing when a match is not found', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
u: [1, 2, 3]
}
}
});
ke._acl.removeUpdateRole(4);
ke._acl.getUpdateRoles().should.eql([1, 2, 3]);
return done();
});
it('does nothing when no update roles are defined', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {}
}
});
ke._acl.removeUpdateRole(1);
ke._acl.getUpdateRoles().should.eql([]);
return done();
});
it('will remove all instances of a role id', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
u: [1, 2, 3, 1]
}
}
});
ke._acl.removeUpdateRole(1);
ke._acl.getUpdateRoles().should.eql([2, 3]);
return done();
});
return it('returns entity acls for method chaining', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
u: [1, 2, 3, 1]
}
}
});
ke._acl.removeUpdateRole(1).getUpdateRoles().should.eql([2, 3]);
return done();
});
});
describe('getDeleteRoles', () => {
it('returns empty array when no role deletes', (done) => {
const ke = kinveyInstance.entity();
ke._acl.getDeleteRoles().should.eql([]);
return done();
});
return it('returns correct value for entity with deletes', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
d: [1, 2, 3]
}
}
});
ke._acl.getDeleteRoles().should.eql([1, 2, 3]);
return done();
});
});
describe('addDeleteRole', () => {
it('Adds a delete to an stub entity', (done) => {
const ke = kinveyInstance.entity();
ke._acl.addDeleteRole('1');
ke._acl.getDeleteRoles().should.eql(['1']);
return done();
});
it('wont add an existing delete id', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
d: [1, 2, 3]
}
}
});
ke._acl.addDeleteRole(1);
ke._acl.getDeleteRoles().should.eql([1, 2, 3]);
return done();
});
it('appends a role ID to existing list', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
d: [1, 2, 3]
}
}
});
ke._acl.addDeleteRole(4);
ke._acl.getDeleteRoles().should.eql([1, 2, 3, 4]);
return done();
});
return it('returns entity acls for method chaining', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
d: [1, 2, 3]
}
}
});
ke._acl.addDeleteRole(4).getDeleteRoles().should.eql([1, 2, 3, 4]);
return done();
});
});
describe('removeDeleteRole', () => {
it('removes a delete role when a match is found', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
d: [1, 2, 3]
}
}
});
ke._acl.removeDeleteRole(1);
ke._acl.getDeleteRoles().should.eql([2, 3]);
return done();
});
it('does nothing when a match is not found', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
d: [1, 2, 3]
}
}
});
ke._acl.removeDeleteRole(4);
ke._acl.getDeleteRoles().should.eql([1, 2, 3]);
return done();
});
it('does nothing when no delete roles are defined', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {}
}
});
ke._acl.removeDeleteRole(1);
ke._acl.getDeleteRoles().should.eql([]);
return done();
});
it('will remove all instances of a role id', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
d: [1, 2, 3, 1]
}
}
});
ke._acl.removeDeleteRole(1);
ke._acl.getDeleteRoles().should.eql([2, 3]);
return done();
});
return it('returns entity acls for method chaining', (done) => {
const ke = kinveyInstance.entity({
_acl: {
roles: {
d: [1, 2, 3, 1]
}
}
});
ke._acl.removeDeleteRole(1).getDeleteRoles().should.eql([2, 3]);
return done();
});
});
describe('get global readability', () => {

@@ -632,0 +1002,0 @@ it('will return null when globally readable is not set', (done) => {

@@ -304,2 +304,22 @@ /**

});
it('should return an error if null group _id', (done) => {
this.store().findById(null, (err, result) => {
should.not.exist(result);
err.message.should.eql('GroupStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('groupId is required');
return done();
});
});
it('should return an error if blank group _id', (done) => {
this.store().findById('', (err, result) => {
should.not.exist(result);
err.message.should.eql('GroupStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('groupId is required');
return done();
});
});
});

@@ -716,3 +736,23 @@

});
it('should return an error if null groupId', (done) => {
this.store().remove(null, (err, result) => {
should.not.exist(result);
err.message.should.eql('GroupStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('groupId is required');
return done();
});
});
it('should return an error if blank groupId', (done) => {
this.store().remove('', (err, result) => {
should.not.exist(result);
err.message.should.eql('GroupStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('groupId is required');
return done();
});
});
});
});

@@ -451,3 +451,3 @@ /**

it('should return an error if missing user _id', (done) => {
this.store().findById((err, result) => {
this.store().findById(null, (err, result) => {
should.not.exist(result);

@@ -460,2 +460,12 @@ err.message.should.eql('UserStoreError');

});
it('should return an error if blank user _id', (done) => {
this.store().findById('', (err, result) => {
should.not.exist(result);
err.message.should.eql('UserStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('userId is required');
return done();
});
});
});

@@ -1000,2 +1010,22 @@

});
it('should return an error if null userId', (done) => {
this.store().remove(null, (err, result) => {
should.not.exist(result);
err.message.should.eql('UserStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('userId is required');
return done();
});
});
it('should return an error if blank userId', (done) => {
this.store().remove('', (err, result) => {
should.not.exist(result);
err.message.should.eql('UserStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('userId is required');
return done();
});
});
});

@@ -1288,2 +1318,22 @@

});
it('should return an error if null userId', (done) => {
this.store().suspend(null, (err, result) => {
should.not.exist(result);
err.message.should.eql('UserStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('userId is required');
return done();
});
});
it('should return an error if blank userId', (done) => {
this.store().suspend('', (err, result) => {
should.not.exist(result);
err.message.should.eql('UserStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('userId is required');
return done();
});
});
});

@@ -1418,3 +1468,23 @@

});
it('should return an error if null userId', (done) => {
this.store().suspend(null, (err, result) => {
should.not.exist(result);
err.message.should.eql('UserStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('userId is required');
return done();
});
});
it('should return an error if blank userId', (done) => {
this.store().suspend('', (err, result) => {
should.not.exist(result);
err.message.should.eql('UserStoreError');
err.description.should.eql('Bad Request');
err.debug.should.eql('userId is required');
return done();
});
});
});
});
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