Skip to content
Merged
Show file tree
Hide file tree
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
30 changes: 15 additions & 15 deletions ClearBlade.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (!window.console) {
* This is the base module for the ClearBlade Platform API
* @namespace ClearBlade
* @example <caption>Initialize ClearBladeAPI</caption>
* initOptions = {appKey: 'asdfknafikjasd3853n34kj2vc', appSecret: 'SHHG245F6GH7SDFG823HGSDFG9'};
* initOptions = {systemKey: 'asdfknafikjasd3853n34kj2vc', systemSecret: 'SHHG245F6GH7SDFG823HGSDFG9'};
* ClearBlade.init(initOptions);
*
*/
Expand Down Expand Up @@ -54,11 +54,11 @@ if (!window.console) {
if (!options || typeof options !== 'object')
throw new Error('Options must be an object or it is undefined');

if (!options.appKey || typeof options.appKey !== 'string')
throw new Error('appKey must be defined/a string');
if (!options.systemKey || typeof options.systemKey !== 'string')
throw new Error('systemKey must be defined/a string');

if (!options.appSecret || typeof options.appSecret !== 'string')
throw new Error('appSecret must be defined/a string');
if (!options.systemSecret || typeof options.systemSecret !== 'string')
throw new Error('systemSecret must be defined/a string');

//check for optional params.
if (options.logging && typeof options.logging !== 'boolean')
Expand Down Expand Up @@ -102,16 +102,16 @@ if (!window.console) {
// store keys
/**
* This is the app key that will identify your app in order to connect to the Platform
* @property appKey
* @property systemKey
* @type String
*/
ClearBlade.appKey = options.appKey;
ClearBlade.systemKey = options.systemKey;
/**
* This is the app secret that will be used in combination with the appKey to authenticate your app
* @property appSecret
* This is the app secret that will be used in combination with the systemKey to authenticate your app
* @property systemSecret
* @type String
*/
ClearBlade.appSecret = options.appSecret;
ClearBlade.systemSecret = options.systemSecret;
/**
* This is the master secret that is used during development to test many apps at a time
* This is not currently not in use
Expand Down Expand Up @@ -398,8 +398,8 @@ if (!window.console) {
if (authToken) {
httpRequest.setRequestHeader("CLEARBLADE-USERTOKEN", authToken);
} else {
httpRequest.setRequestHeader("ClearBlade-SystemKey", ClearBlade.appKey);
httpRequest.setRequestHeader("ClearBlade-SystemSecret", ClearBlade.appSecret);
httpRequest.setRequestHeader("ClearBlade-SystemKey", ClearBlade.systemKey);
httpRequest.setRequestHeader("ClearBlade-SystemSecret", ClearBlade.systemSecret);
}

if (!isObjectEmpty(body) || params) {
Expand All @@ -415,7 +415,7 @@ if (!window.console) {
//set Authorization header
if (typeof ClearBlade.masterSecret === 'String') {
// if masterSecret exists as a string use it for Authorization
httpRequest.setRequestHeader("Authorization", "Basic " + window.btoa(ClearBlade.appKey + ':' + ClearBlade.masterSecret));
httpRequest.setRequestHeader("Authorization", "Basic " + window.btoa(ClearBlade.systemKey + ':' + ClearBlade.masterSecret));
} else if (currentUser && currentUser.getToken()) {
// if there is a current user then use the current Access token
httpRequest.setRequestHeader("Authorization", "Bearer " + self.getToken());
Expand Down Expand Up @@ -1106,7 +1106,7 @@ if (!window.console) {
ClearBlade.Code.execute = function(name, params, callback){
var reqOptions = {
method: 'POST',
endpoint: 'api/v/1/code/' + ClearBlade.appKey + '/' + name,
endpoint: 'api/v/1/code/' + ClearBlade.systemKey + '/' + name,
body: params
};
if (typeof callback === 'function') {
Expand Down Expand Up @@ -1176,7 +1176,7 @@ if (!window.console) {
//roll through the config
var conf = {};
conf.userName = ClearBlade.user.authToken;
conf.password = ClearBlade.appSecret;
conf.password = ClearBlade.systemSecret;
conf.cleanSession = options.cleanSession || true;
conf.useSSL = options.useSSL || false; //up for debate. ole' perf vs sec argument
conf.hosts = options.hosts || [ClearBlade.messagingURI];
Expand Down
68 changes: 34 additions & 34 deletions test/ClearBladeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ var RTP_INFO = {
serverAddress: "https://rtp.clearblade.com",
messagingURI: "rtp.clearblade.com",
messagingPort: 8904,
noAuthAppKey: "8cc896b40a82d0d2b4e18bbbed0f",
noAuthAppSecret: "8CC896B40A90DEA898C197B5E357",
noAuthsystemKey: "8cc896b40a82d0d2b4e18bbbed0f",
noAuthsystemSecret: "8CC896B40A90DEA898C197B5E357",
safariNoAuthCollection: "ccc896b40ae083ea8af480d4868401",
chromeNoAuthCollection: "e8c896b40a90bfcd9bc78df5ca5d",
generalNoAuthCollection: "82c996b40a90fab0dbf7ff83e312",
firefoxNoAuthCollection: "a8c996b40aacdd919dadce92c430",
appKey: "d6d096b40ab4f3c7ddb4899b8a30",
appSecret: "D6D096B40ADAA885E0BF8F8D93CB01",
systemKey: "d6d096b40ab4f3c7ddb4899b8a30",
systemSecret: "D6D096B40ADAA885E0BF8F8D93CB01",
safariCollection: "84d196b40aa883bec8cfdaf697df01",
firefoxCollection: "9ed196b40a8083efa485e58aa9b901",
generalCollection: "9cd296b40acac5e2f797a485ec8e01",
Expand All @@ -29,14 +29,14 @@ var STAGING_INFO = {
serverAddress: "https://staging.clearblade.com",
messagingURI: "staging.clearblade.com",
messagingPort: 8904,
noAuthAppKey: "e6a1c1ba0a8690f7a6aaacde9fff01",
noAuthAppSecret: "E6A1C1BA0A98E3D384D7D8F6C6F901",
noAuthsystemKey: "e6a1c1ba0a8690f7a6aaacde9fff01",
noAuthsystemSecret: "E6A1C1BA0A98E3D384D7D8F6C6F901",
safariNoAuthCollection: "bea3c1ba0ae8cc97f2d0e897e6cb01",
chromeNoAuthCollection: "aea2c1ba0a8495d2bdb7d0e3bca701",
generalNoAuthCollection: "90a3c1ba0ab2e3dcfccab5d8bbb101",
firefoxNoAuthCollection: "dca2c1ba0aa0ecd89bbe80ba8b8501",
appKey: "8c9ac1ba0adeb7f68fced7fb9049",
appSecret: "8C9AC1BA0AE2D697A0DCA78DC179",
systemKey: "8c9ac1ba0adeb7f68fced7fb9049",
systemSecret: "8C9AC1BA0AE2D697A0DCA78DC179",
safariCollection: "d49dc1ba0a8ae8dfb5b5f6a996c301",
firefoxCollection: "fe9bc1ba0af08893def9f9fceeef01",
generalCollection: "b49cc1ba0adac69fc9f4d8a0fe52",
Expand All @@ -45,10 +45,10 @@ var STAGING_INFO = {
var PLATFORM_INFO = {
serverAddress: "https://platform.clearblade.com",
messagingURI: "platform.clearblade.com",
appKey: 'f2f5f8aa0aba8bc7e4bdcd8ef142',
appSecret: 'F2F5F8AA0AB4F2C4A4E1C387F3F801',
noAuthAppKey: "b48abbb10af2f9bfffd9f793dc9a01",
noAuthAppSecret: "B48ABBB10AE8EB9AD7D1B3B7FC62",
systemKey: 'f2f5f8aa0aba8bc7e4bdcd8ef142',
systemSecret: 'F2F5F8AA0AB4F2C4A4E1C387F3F801',
noAuthsystemKey: "b48abbb10af2f9bfffd9f793dc9a01",
noAuthsystemSecret: "B48ABBB10AE8EB9AD7D1B3B7FC62",
safariCollection: "82f7f8aa0ab8929ab1c3cad7e534",
chromeCollection:"84f6f8aa0abcf9fbb6ae97a6c9da01",
firefoxCollection:"d8f6f8aa0ababdbbc5b8fdf49356",
Expand All @@ -71,8 +71,8 @@ describe("ClearBlade initialization should", function () {
beforeEach(function () {
var isClearBladeInit = false;
var initOptions = {
appKey: TargetPlatform.noAuthAppKey,
appSecret: TargetPlatform.noAuthAppSecret,
systemKey: TargetPlatform.noAuthsystemKey,
systemSecret: TargetPlatform.noAuthsystemSecret,
URI: TargetPlatform.serverAddress,
messagingURI: TargetPlatform.messagingURI,
callback: function(err, user) {
Expand All @@ -86,12 +86,12 @@ describe("ClearBlade initialization should", function () {
}, "ClearBlade should be initialized", TEST_TIMEOUT);
});

it("have the appKey stored", function () {
expect(ClearBlade.appKey).toEqual(TargetPlatform.noAuthAppKey);
it("have the systemKey stored", function () {
expect(ClearBlade.systemKey).toEqual(TargetPlatform.noAuthsystemKey);
});

it("have the appSecret stored", function () {
expect(ClearBlade.appSecret).toEqual(TargetPlatform.noAuthAppSecret);
it("have the systemSecret stored", function () {
expect(ClearBlade.systemSecret).toEqual(TargetPlatform.noAuthsystemSecret);
});

// it("have defaulted the URI to the Platform", function () {
Expand All @@ -115,8 +115,8 @@ describe("ClearBlade users should", function () {
var initOptions;
beforeEach(function () {
initOptions = {
appKey: TargetPlatform.appKey,
appSecret: TargetPlatform.appSecret,
systemKey: TargetPlatform.systemKey,
systemSecret: TargetPlatform.systemSecret,
URI: TargetPlatform.serverAddress,
messagingURI: TargetPlatform.messagingURI,
};
Expand Down Expand Up @@ -155,8 +155,8 @@ describe("ClearBlade anonymous users", function () {
var initOptions;
beforeEach(function () {
initOptions = {
appKey: TargetPlatform.noAuthAppKey,
appSecret: TargetPlatform.noAuthAppSecret,
systemKey: TargetPlatform.noAuthsystemKey,
systemSecret: TargetPlatform.noAuthsystemSecret,
URI: TargetPlatform.serverAddress,
messagingURI: TargetPlatform.messagingURI,
};
Expand All @@ -180,8 +180,8 @@ describe("ClearBlade collection fetching with users", function () {
var flag, returnedData, isAaronCreated;
var isClearBladeInit = false;
var initOptions = {
appKey: TargetPlatform.appKey,
appSecret: TargetPlatform.appSecret,
systemKey: TargetPlatform.systemKey,
systemSecret: TargetPlatform.systemSecret,
URI: TargetPlatform.serverAddress,
messagingURI: TargetPlatform.messagingURI,
email: "test_" + Math.floor(Math.random() * 10000) + "@test.com",
Expand Down Expand Up @@ -242,8 +242,8 @@ describe("ClearBlade Query usage with anonymous user", function() {
beforeEach(function () {
var isClearBladeInit = false;
var initOptions = {
appKey: TargetPlatform.noAuthAppKey,
appSecret: TargetPlatform.noAuthAppSecret,
systemKey: TargetPlatform.noAuthsystemKey,
systemSecret: TargetPlatform.noAuthsystemSecret,
URI: TargetPlatform.serverAddress,
messagingURI: TargetPlatform.messagingURI,
callback: function(err, user) {
Expand Down Expand Up @@ -461,8 +461,8 @@ describe("ClearBlade collections fetching", function () {
beforeEach(function () {
var isClearBladeInit = false;
var initOptions = {
appKey: TargetPlatform.noAuthAppKey,
appSecret: TargetPlatform.noAuthAppSecret,
systemKey: TargetPlatform.noAuthsystemKey,
systemSecret: TargetPlatform.noAuthsystemSecret,
URI: TargetPlatform.serverAddress,
messagingURI: TargetPlatform.messagingURI,
callback: function(err, user) {
Expand Down Expand Up @@ -535,8 +535,8 @@ describe("ClearBlade collections CRUD should", function () {
beforeEach(function () {
var finishedRemoval = false;
var initOptions = {
appKey: TargetPlatform.noAuthAppKey,
appSecret: TargetPlatform.noAuthAppSecret,
systemKey: TargetPlatform.noAuthsystemKey,
systemSecret: TargetPlatform.noAuthsystemSecret,
URI: TargetPlatform.serverAddress,
messagingURI: TargetPlatform.messagingURI,
callback: function (err, user) {
Expand Down Expand Up @@ -684,8 +684,8 @@ describe("Query objects should", function () {
beforeEach(function () {
var isJohnInserted = false;
var initOptions = {
appKey: TargetPlatform.noAuthAppKey,
appSecret: TargetPlatform.noAuthAppSecret,
systemKey: TargetPlatform.noAuthsystemKey,
systemSecret: TargetPlatform.noAuthsystemSecret,
URI: TargetPlatform.serverAddress,
messagingURI: TargetPlatform.messagingURI,
callback: function (err, user) {
Expand Down Expand Up @@ -811,8 +811,8 @@ describe("The ClearBlade Messaging module", function() {
beforeEach(function () {
var isClearBladeInit = false;
var initOptions = {
appKey: TargetPlatform.noAuthAppKey,
appSecret: TargetPlatform.noAuthAppSecret,
systemKey: TargetPlatform.noAuthsystemKey,
systemSecret: TargetPlatform.noAuthsystemSecret,
URI: TargetPlatform.serverAddress,
messagingURI: TargetPlatform.messagingURI,
callback: function(err, user) {
Expand Down