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

kinvey-flex-sdk

Package Overview
Dependencies
Maintainers
1
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.0-b.9 to 2.0.0-b.10

lib/service/modules/groupStore.js

2

CHANGELOG.md

@@ -10,4 +10,6 @@ ## Changelog

* Added `useUserContext` option to userStore and dataStore. Set to `true` to execute the request under user's authentication context. Defaults to false.
* Added new `groupStore` module, for accessing Kinvey Groups API.
* dataStore and authStore now default to using mastersecret credentials and not executing business logic
* Circular requests to userStore/dataStore (e.g. saving back to the sae collection in a post hook) now must not execute BL and must be executed under masterSecret credentials.
* Added option to code-task-receiver to set max request body size, with the `requestBodyOptons` parameter. Defaulted to 26214400. (wongni)
* Some internal refactoring

@@ -14,0 +16,0 @@ * DEPRECATED: Passing the entity directly in the `complete()` method. Will be removed in future version.

@@ -48,4 +48,16 @@ /**

if (options.sharedSecret) {
this.sharedSecret = options.sharedSecret;
}
// TODO Remove legacy taskType values
const taskReceivedCallback = ((task, completionCallback) => {
if (this.sharedSecret && this.sharedSecret !== task.authKey) {
task.response = task.response || {};
const result = task.response;
result.body = kinveyErrors.generateKinveyError('Unauthorized', 'The Authorization Key was not valid or missing.');
result.statusCode = result.body.statusCode;
return completionCallback(task);
}
task.sdkVersion = this.version;

@@ -52,0 +64,0 @@ if ((!this[task.taskType] && task.taskType !== 'serviceDiscovery') || task.taskType === 'logger' || task.taskType === 'moduleGenerator') {

@@ -21,2 +21,3 @@ /**

const email = require('./modules/email');
const groupStore = require('./modules/groupStore');
const entity = require('./modules/kinveyEntity');

@@ -123,2 +124,3 @@ const kinveyDate = require('./modules/kinveyDate');

email: email(proxyURL, taskMetadata, proxyTaskEmitter),
groupStore: groupStore(appMetadata, requestMetadata, taskMetadata),
kinveyEntity: entity(appMetadata._id, useBSONObjectId),

@@ -125,0 +127,0 @@ kinveyDate,

5

package.json
{
"name": "kinvey-flex-sdk",
"version": "2.0.0-b.9",
"version": "2.0.0-b.10",
"description": "SDK for creating Kinvey Flex Services",

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

"bson": "0.4.23",
"kinvey-code-task-runner": "dev",
"kinvey-code-task-runner": "2.1.0",
"kinvey-datalink-errors": "0.2.2",

@@ -58,2 +58,3 @@ "lodash.forown": "4.2.0",

"test-email": "mocha test/lib/modules/email.test.js",
"test-groupStore": "mocha test/lib/modules/groupStore.test.js",
"test-entity": "mocha test/lib/modules/entity.test.js",

@@ -60,0 +61,0 @@ "test-kinveydate": "mocha test/lib/modules/kinveyDate.test.js",

@@ -19,2 +19,3 @@ /**

const sinon = require('sinon');
const uuid = require('uuid');

@@ -197,2 +198,135 @@ const mockTaskReceiver = require('./mocks/mockTaskReceiver.js');

});
it('should reject a task if shared secret auth is enabled and the authKey is not included', (done) => {
sdk.service({ sharedSecret: uuid.v4() }, (err, flex) => {
const task = {
appMetadata: {
_id: '12345',
appsecret: 'appsecret',
mastersecret: 'mastersecret',
pushService: void 0,
restrictions: {
level: 'starter'
},
API_version: 3,
name: 'DevApp',
platform: null
},
taskType: 'data',
method: 'GET',
request: {
method: 'GET',
headers: {},
body: {},
serviceObjectName: 'foo'
},
response: {}
};
flex.data.serviceObject('foo').onGetAll((context, complete) => {
const body = { foo: 'bar' };
complete().setBody(body).ok().done();
});
mockTaskReceiver.taskReceived()(task, (err, result) => {
err.response.body.message.should.eql('InvalidCredentials');
err.response.body.description.should.eql('Invalid credentials. Please retry your request with correct credentials.');
err.response.statusCode.should.eql(401);
err.response.body.debug.should.eql('The Authorization Key was not valid or missing.');
should.not.exist(result);
should.not.exist(err.response.body.foo);
done();
});
});
});
it('should reject a task if shared secret auth is enabled and the authKey does not match', (done) => {
sdk.service({ sharedSecret: uuid.v4() }, (err, flex) => {
const task = {
appMetadata: {
_id: '12345',
appsecret: 'appsecret',
mastersecret: 'mastersecret',
pushService: void 0,
restrictions: {
level: 'starter'
},
API_version: 3,
name: 'DevApp',
platform: null
},
authKey: uuid.v4(),
taskType: 'data',
method: 'GET',
request: {
method: 'GET',
headers: {},
body: {},
serviceObjectName: 'foo'
},
response: {}
};
flex.data.serviceObject('foo').onGetAll((context, complete) => {
const body = { foo: 'bar' };
complete().setBody(body).ok().done();
});
mockTaskReceiver.taskReceived()(task, (err, result) => {
err.response.body.message.should.eql('InvalidCredentials');
err.response.body.description.should.eql('Invalid credentials. Please retry your request with correct credentials.');
err.response.statusCode.should.eql(401);
err.response.body.debug.should.eql('The Authorization Key was not valid or missing.');
should.not.exist(result);
should.not.exist(err.response.body.foo);
done();
});
});
});
it('should process a task if shared secret auth is enabled and the authKey is included', (done) => {
const authKey = uuid.v4();
sdk.service({ sharedSecret: authKey }, (err, flex) => {
const task = {
appMetadata: {
_id: '12345',
appsecret: 'appsecret',
mastersecret: 'mastersecret',
pushService: void 0,
restrictions: {
level: 'starter'
},
API_version: 3,
name: 'DevApp',
platform: null
},
authKey,
taskType: 'data',
method: 'GET',
request: {
method: 'GET',
headers: {},
body: {},
serviceObjectName: 'foo'
},
response: {}
};
flex.data.serviceObject('foo').onGetAll((context, complete) => {
const body = { foo: 'bar' };
complete().setBody(body).ok().done();
});
mockTaskReceiver.taskReceived()(task, (err, result) => {
should.not.exist(err);
result.response.body.foo.should.eql('bar');
result.response.statusCode.should.eql(200);
should.not.exist(result.response.body.message);
should.not.exist(result.response.body.description);
should.not.exist(result.response.body.debug);
done();
});
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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