kinvey-flex-sdk
Advanced tools
Comparing version 2.0.4 to 2.0.5
## Changelog | ||
### 2.0.5 | ||
* Added NotImplementedHandler for FlexAuth requests that don't have a defined handler | ||
* Fixed shared secrets hanging the flex service | ||
* Fixed shared secrets not working locally if shared secret is defined | ||
* Bumped kinvey-code-task-runner to v2.2.0 to add mapping of tempObjectStore for external flex functions requests | ||
### 2.0.4 | ||
@@ -4,0 +10,0 @@ * Fixed bug in error response callback for stores (data, user, group) |
@@ -59,3 +59,3 @@ /** | ||
const taskReceivedCallback = ((task, completionCallback) => { | ||
if (this.sharedSecret && this.sharedSecret !== task.authKey) { | ||
if (this.sharedSecret != null && task.taskType !== 'serviceDiscovery' && task.taskType !== 'logger' && task.taskType !== 'moduleGenerator' && this.sharedSecret !== task.authKey) { | ||
task.response = task.response || {}; | ||
@@ -66,3 +66,4 @@ const result = task.response; | ||
delete result.body.statusCode; | ||
return completionCallback(task); | ||
task.response.continue = false; | ||
return completionCallback(null, task); | ||
} | ||
@@ -77,3 +78,4 @@ | ||
delete result.body.statusCode; | ||
return completionCallback(task); | ||
task.response.continue = false; | ||
return completionCallback(null, task); | ||
} | ||
@@ -80,0 +82,0 @@ |
@@ -114,2 +114,10 @@ /** | ||
}, | ||
notImplemented() { | ||
result.statusCode = 401; | ||
result.body = { | ||
error: 'server_error', | ||
error_description: 'The request invoked a method that is not implemented' | ||
}; | ||
return this; | ||
}, | ||
next() { | ||
@@ -116,0 +124,0 @@ if (!result.statusCode) { |
@@ -86,2 +86,3 @@ /** | ||
_id: task.appMetadata._id, | ||
applicationId: task.appMetadata.applicationId, | ||
blFlags: task.appMetadata.blFlags, | ||
@@ -98,3 +99,4 @@ appsecret: task.appMetadata.appsecret, | ||
clientAppVersion, | ||
customRequestProperties | ||
customRequestProperties, | ||
requestId: task.requestId | ||
}; | ||
@@ -124,7 +126,7 @@ const taskMetadata = { | ||
dataStore: dataStore(appMetadata, requestMetadata, taskMetadata), | ||
email: email(proxyURL, appMetadata, taskMetadata, proxyTaskEmitter), | ||
email: email(proxyURL, appMetadata, taskMetadata, requestMetadata, proxyTaskEmitter), | ||
groupStore: groupStore(appMetadata, requestMetadata, taskMetadata), | ||
kinveyEntity: entity(appMetadata._id, useBSONObjectId), | ||
kinveyDate, | ||
push: push(proxyURL, appMetadata, taskMetadata, proxyTaskEmitter), | ||
push: push(proxyURL, appMetadata, taskMetadata, requestMetadata, proxyTaskEmitter), | ||
Query, | ||
@@ -131,0 +133,0 @@ requestContext: requestContext(requestMetadata), |
@@ -18,3 +18,3 @@ /** | ||
function emailModule(proxyURL, appMetadata, taskMetadata, proxyTaskEmitter) { | ||
function emailModule(proxyURL, appMetadata, taskMetadata, requestMetadata, proxyTaskEmitter) { | ||
function send(from, to, subject, textBody, replyTo, htmlBody, cc, bcc, callback) { | ||
@@ -63,4 +63,4 @@ // Abort if required email field params are not specified | ||
headers: { | ||
'x-kinvey-app-id': appMetadata._id, | ||
'x-kinvey-container-id': taskMetadata.containerId, | ||
'x-kinvey-application-id': appMetadata.applicationId, | ||
'x-kinvey-request-id': requestMetadata.requestId, | ||
'x-kinvey-task-id': taskMetadata.taskId, | ||
@@ -67,0 +67,0 @@ 'x-kinvey-wait-for-confirmation': proxyShouldWaitForConfirmation |
@@ -22,3 +22,3 @@ /** | ||
function kinveyPushModule(proxyURL, appMetadata, taskMetadata, proxyTaskEmitter) { | ||
function kinveyPushModule(proxyURL, appMetadata, taskMetadata, requestMetadata, proxyTaskEmitter) { | ||
const authHeader = { | ||
@@ -44,4 +44,4 @@ user: appMetadata._id, | ||
headers: { | ||
'x-kinvey-app-id': appMetadata._id, | ||
'x-kinvey-container-id': taskMetadata.containerId, | ||
'x-kinvey-application-id': appMetadata.applicationId, | ||
'x-kinvey-request-id': requestMetadata.requestId, | ||
'x-kinvey-task-id': taskMetadata.taskId, | ||
@@ -80,4 +80,4 @@ 'x-kinvey-wait-for-confirmation': proxyShouldWaitForConfirmation | ||
headers: { | ||
'x-kinvey-app-id': appMetadata._id, | ||
'x-kinvey-container-id': taskMetadata.containerId, | ||
'x-kinvey-application-id': appMetadata.applicationId, | ||
'x-kinvey-request-id': requestMetadata.requestId, | ||
'x-kinvey-task-id': taskMetadata.taskId, | ||
@@ -84,0 +84,0 @@ 'x-kinvey-wait-for-confirmation': proxyShouldWaitForConfirmation |
{ | ||
"name": "kinvey-flex-sdk", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "SDK for creating Kinvey Flex Services", | ||
@@ -20,3 +20,3 @@ "engines": { | ||
"bson": "0.4.23", | ||
"kinvey-code-task-runner": "2.1.0", | ||
"kinvey-code-task-runner": "2.2.0", | ||
"kinvey-datalink-errors": "0.3.0", | ||
@@ -23,0 +23,0 @@ "lodash.forown": "4.2.0", |
@@ -223,3 +223,13 @@ /** | ||
}); | ||
it('should return a 401 not implemented', (done) => { | ||
const taskName = quickRandom(); | ||
const task = sampleTask(taskName); | ||
return auth.process(task, null, (err, result) => { | ||
should.not.exist(err); | ||
result.response.statusCode.should.eql(401); | ||
result.response.body.error.should.eql('server_error'); | ||
result.response.body.error_description.should.eql('The request invoked a method that is not implemented'); | ||
return done(); | ||
}); | ||
}); | ||
it('should process a next (continuation) handler', (done) => { | ||
@@ -226,0 +236,0 @@ const taskName = quickRandom(); |
@@ -230,8 +230,8 @@ /** | ||
mockTaskReceiver.taskReceived()(task, (err, result) => { | ||
err.response.body.error.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); | ||
result.response.body.error.should.eql('InvalidCredentials'); | ||
result.response.body.description.should.eql('Invalid credentials. Please retry your request with correct credentials.'); | ||
result.response.statusCode.should.eql(401); | ||
result.response.body.debug.should.eql('The Authorization Key was not valid or missing.'); | ||
should.not.exist(err); | ||
should.not.exist(result.response.body.foo); | ||
done(); | ||
@@ -275,8 +275,8 @@ }); | ||
mockTaskReceiver.taskReceived()(task, (err, result) => { | ||
err.response.body.error.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); | ||
result.response.body.error.should.eql('InvalidCredentials'); | ||
result.response.body.description.should.eql('Invalid credentials. Please retry your request with correct credentials.'); | ||
result.response.statusCode.should.eql(401); | ||
result.response.body.debug.should.eql('The Authorization Key was not valid or missing.'); | ||
should.not.exist(err); | ||
should.not.exist(result.response.body.foo); | ||
done(); | ||
@@ -287,2 +287,27 @@ }); | ||
it('should process a task if shared secret auth is enabled and the taskType is discovery', (done) => { | ||
sdk.service({ sharedSecret: uuid.v4() }, (err, flex) => { | ||
const task = { | ||
taskType: 'serviceDiscovery', | ||
}; | ||
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); | ||
should.exist(result.discoveryObjects); | ||
result.discoveryObjects.dataLink.should.be.an.Object(); | ||
result.discoveryObjects.businessLogic.should.be.an.Object(); | ||
result.discoveryObjects.auth.should.be.an.Object(); | ||
Array.isArray(result.discoveryObjects.dataLink.serviceObjects).should.eql(true); | ||
result.discoveryObjects.dataLink.serviceObjects.length.should.eql(1); | ||
result.discoveryObjects.dataLink.serviceObjects[0].should.eql('foo'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should process a task if shared secret auth is enabled and the authKey is included', (done) => { | ||
@@ -289,0 +314,0 @@ const authKey = uuid.v4(); |
@@ -21,2 +21,3 @@ /** | ||
_id: '12345', | ||
applicationId: 'abc123', | ||
appsecret: 'appsecret', | ||
@@ -23,0 +24,0 @@ mastersecret: 'mastersecret', |
@@ -28,8 +28,11 @@ /** | ||
_id: 'kid_abcd1234', | ||
applicationId: 'abc123', | ||
mastersecret: '12345' | ||
}; | ||
const taskMetadata = { | ||
taskId: 'abcd1234', | ||
containerId: 'wxyz9876' | ||
taskId: 'abcd1234' | ||
}; | ||
const requestMetadata = { | ||
requestId: 'ea85600029b04a18a754d57629cff62d' | ||
}; | ||
before((done) => { | ||
@@ -43,3 +46,3 @@ requestStub = { | ||
emailModule = require('../../../lib/service/modules/email'); | ||
emailInstance = emailModule(fakeProxyURL, appMetadata, taskMetadata, emitter); | ||
emailInstance = emailModule(fakeProxyURL, appMetadata, taskMetadata, requestMetadata, emitter); | ||
return done(); | ||
@@ -214,6 +217,8 @@ }); | ||
const outgoingRequestHeaders = requestStub.post.args[0][0].headers; | ||
outgoingRequestHeaders.should.have.property('x-kinvey-application-id'); | ||
outgoingRequestHeaders.should.have.property('x-kinvey-task-id'); | ||
outgoingRequestHeaders.should.have.property('x-kinvey-container-id'); | ||
outgoingRequestHeaders.should.have.property('x-kinvey-request-id'); | ||
outgoingRequestHeaders['x-kinvey-application-id'].should.equal(appMetadata.applicationId); | ||
outgoingRequestHeaders['x-kinvey-task-id'].should.equal(taskMetadata.taskId); | ||
outgoingRequestHeaders['x-kinvey-container-id'].should.equal(taskMetadata.containerId); | ||
outgoingRequestHeaders['x-kinvey-request-id'].should.equal(requestMetadata.requestId); | ||
return done(); | ||
@@ -220,0 +225,0 @@ }); |
@@ -38,8 +38,11 @@ /** | ||
_id: 'kid_abcd1234', | ||
applicationId: 'abc123', | ||
mastersecret: '12345' | ||
}; | ||
const taskMetadata = { | ||
taskId: 'abcd1234', | ||
containerId: 'wxyz9876' | ||
taskId: 'abcd1234' | ||
}; | ||
const requestMetadata = { | ||
requestId: 'ea85600029b04a18a754d57629cff62d' | ||
}; | ||
before((done) => { | ||
@@ -53,3 +56,3 @@ requestStub = { | ||
pushModule = require('../../../lib/service/modules/push'); | ||
pushInstance = pushModule(fakeProxyURL, appMetadata, taskMetadata, emitter); | ||
pushInstance = pushModule(fakeProxyURL, appMetadata, taskMetadata, requestMetadata, emitter); | ||
return done(); | ||
@@ -243,6 +246,8 @@ }); | ||
const outgoingRequestHeaders = requestStub.post.args[0][0].headers; | ||
outgoingRequestHeaders.should.have.property('x-kinvey-application-id'); | ||
outgoingRequestHeaders.should.have.property('x-kinvey-task-id'); | ||
outgoingRequestHeaders.should.have.property('x-kinvey-container-id'); | ||
outgoingRequestHeaders.should.have.property('x-kinvey-request-id'); | ||
outgoingRequestHeaders['x-kinvey-application-id'].should.equal(appMetadata.applicationId); | ||
outgoingRequestHeaders['x-kinvey-task-id'].should.equal(taskMetadata.taskId); | ||
outgoingRequestHeaders['x-kinvey-container-id'].should.equal(taskMetadata.containerId); | ||
outgoingRequestHeaders['x-kinvey-request-id'].should.equal(requestMetadata.requestId); | ||
return done(); | ||
@@ -334,6 +339,8 @@ }); | ||
const outgoingRequestHeaders = requestStub.post.args[0][0].headers; | ||
outgoingRequestHeaders.should.have.property('x-kinvey-application-id'); | ||
outgoingRequestHeaders.should.have.property('x-kinvey-task-id'); | ||
outgoingRequestHeaders.should.have.property('x-kinvey-container-id'); | ||
outgoingRequestHeaders.should.have.property('x-kinvey-request-id'); | ||
outgoingRequestHeaders['x-kinvey-application-id'].should.equal(appMetadata.applicationId); | ||
outgoingRequestHeaders['x-kinvey-task-id'].should.equal(taskMetadata.taskId); | ||
outgoingRequestHeaders['x-kinvey-container-id'].should.equal(taskMetadata.containerId); | ||
outgoingRequestHeaders['x-kinvey-request-id'].should.equal(requestMetadata.requestId); | ||
return done(); | ||
@@ -418,6 +425,8 @@ }); | ||
const outgoingRequestHeaders = requestStub.post.args[0][0].headers; | ||
outgoingRequestHeaders.should.have.property('x-kinvey-application-id'); | ||
outgoingRequestHeaders.should.have.property('x-kinvey-task-id'); | ||
outgoingRequestHeaders.should.have.property('x-kinvey-container-id'); | ||
outgoingRequestHeaders.should.have.property('x-kinvey-request-id'); | ||
outgoingRequestHeaders['x-kinvey-application-id'].should.equal(appMetadata.applicationId); | ||
outgoingRequestHeaders['x-kinvey-task-id'].should.equal(taskMetadata.taskId); | ||
outgoingRequestHeaders['x-kinvey-container-id'].should.equal(taskMetadata.containerId); | ||
outgoingRequestHeaders['x-kinvey-request-id'].should.equal(requestMetadata.requestId); | ||
return done(); | ||
@@ -424,0 +433,0 @@ }); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9333
431453
128
+ Addedkinvey-code-task-runner@2.2.0(transitive)
- Removedkinvey-code-task-runner@2.1.0(transitive)