Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { LoggerController } from './Controllers/LoggerController';
import { HooksController } from './Controllers/HooksController';

import requiredParameter from './requiredParameter';
import { randomString } from './cryptoUtils';
// Mutate the Parse object to add the Cloud Code handlers
addParseCloud();

Expand Down Expand Up @@ -79,7 +80,7 @@ function ParseServer({
cloud,
collectionPrefix = '',
clientKey = '',
javascriptKey = '',
javascriptKey = randomString(20),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to cause a problem. If any client key is set (clientKey, javascriptKey, restAPIKey, dotNetKey) then all requests to the server must use a valid client key... What was the actual issue, something with the SDK initialization?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue was that when you omit the javascriptKey the parse SDK gets initialized wig an '' and doesn't like it when communicating with cloud code. If a user don't pass a JS key, the it means he doesn't want to use the JS SDK, so I init it to a random string. Actually, because it's init as an empty string, all the JS calls would have failed already as it would expect a javascriptKey header to be set to something empty and not undefined.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to fix this a different way, like passing an unused key to the SDK. We can't require client keys, and this change will do that..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that's not ideal, but the cloud code SDK breaks when no JS key is set, we could throw if JS key is not set and .cloud is set

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm suggesting #680...

dotNetKey = '',
restAPIKey = '',
fileKey = 'invalid-file-key',
Expand Down Expand Up @@ -227,4 +228,4 @@ function getClassName(parseClass) {
module.exports = {
ParseServer: ParseServer,
S3Adapter: S3Adapter
};
};