From 929ab66208b4448106ae1639d20eb4cda09f0100 Mon Sep 17 00:00:00 2001 From: ruth0048 <31827673+ruth0048@users.noreply.github.com> Date: Mon, 23 Sep 2019 13:47:22 -0400 Subject: [PATCH 1/7] logs for wrapper authenticate --- src/brainCloudClient.js | 2 +- src/brainCloudWrapper.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/brainCloudClient.js b/src/brainCloudClient.js index 5e424ca..1650726 100644 --- a/src/brainCloudClient.js +++ b/src/brainCloudClient.js @@ -156,7 +156,7 @@ function BrainCloudClient() { } - bcc.version = "4.1.0"; + bcc.version = "4.2.0"; bcc.countryCode; bcc.languageCode; diff --git a/src/brainCloudWrapper.js b/src/brainCloudWrapper.js index 09896bc..8856069 100644 --- a/src/brainCloudWrapper.js +++ b/src/brainCloudWrapper.js @@ -108,6 +108,7 @@ function BrainCloudWrapper(wrapperName) { }; bcw._authResponseHandler = function(result) { + if (result.status == 200) { var profileId = result.data.profileId; bcw.setStoredProfileId(profileId); @@ -115,6 +116,9 @@ function BrainCloudWrapper(wrapperName) { var sessionId = result.data.sessionId; bcw.setStoredSessionId(sessionId); } + + console.log("PROFILE IDDDDDDDDD"); + console.log(profileId); }; /////////////////////////////////////////////////////////////////////////// @@ -198,7 +202,8 @@ function BrainCloudWrapper(wrapperName) { function(result) { bcw._authResponseHandler(result); responseHandler(result); - }); + } + ); }; /** From 329e45755ae15606c3f9b323d9c7c7c09e116b08 Mon Sep 17 00:00:00 2001 From: ruth0048 <31827673+ruth0048@users.noreply.github.com> Date: Mon, 23 Sep 2019 14:33:03 -0400 Subject: [PATCH 2/7] further test edit --- test/test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test.js b/test/test.js index 3f35ddb..1706c9a 100644 --- a/test/test.js +++ b/test/test.js @@ -4632,6 +4632,8 @@ async function testWrapper() await asyncTest("authenticateAnonymous()", 2, function() { + bc.resetStoredProfileId(); + bc.authenticateAnonymous(function(result) { ok(true, JSON.stringify(result)); equal(result.status, 200, "Expecting 200"); From 0a16fee11521a4dc8d21c22f62d2f09ec34fe46a Mon Sep 17 00:00:00 2001 From: ruth0048 <31827673+ruth0048@users.noreply.github.com> Date: Fri, 11 Oct 2019 14:57:21 -0400 Subject: [PATCH 3/7] Adding authsettophandoff, and postgroupdynamic, and fixing entity test, and adding handoff auths to wrapper --- src/brainCloudClient-authentication.js | 20 ++++++ src/brainCloudClient-social-leaderboards.js | 39 +++++++++++- src/brainCloudWrapper.js | 40 ++++++++++++ test/test.js | 67 ++++++++++++++++++--- 4 files changed, 157 insertions(+), 9 deletions(-) diff --git a/src/brainCloudClient-authentication.js b/src/brainCloudClient-authentication.js index 9d65268..2ef14e4 100644 --- a/src/brainCloudClient-authentication.js +++ b/src/brainCloudClient-authentication.js @@ -34,6 +34,7 @@ function BCAuthentication() { bc.authentication.AUTHENTICATION_TYPE_TWITTER = "Twitter"; bc.authentication.AUTHENTICATION_TYPE_PARSE = "Parse"; bc.authentication.AUTHENTICATION_TYPE_HANDOFF = "Handoff"; + bc.authentication.AUTHENTICATION_TYPE_SETTOP_HANDOFF = "SettopHandoff"; bc.authentication.profileId = ""; bc.authentication.anonymousId = ""; @@ -486,6 +487,25 @@ function BCAuthentication() { callback); }; + /** + * Authenticate a user with handoffCode + * + * Service Name - authenticationV2 + * Service Operation - AUTHENTICATE + * + * @param callback The method to be invoked when the server response is received + * + */ + bc.authentication.authenticateSettopHandoff= function(handoffCode, callback) { + bc.authentication.authenticate( + handoffCode, + "", + bc.authentication.AUTHENTICATION_TYPE_SETTOP_HANDOFF, + null, + false, + callback); + }; + /** Method allows a caller to authenticate with bc. Note that * callers should use the other authenticate methods in this class as * they incorporate the appropriate authenticationType and use better diff --git a/src/brainCloudClient-social-leaderboards.js b/src/brainCloudClient-social-leaderboards.js index 50af648..5e0f94d 100644 --- a/src/brainCloudClient-social-leaderboards.js +++ b/src/brainCloudClient-social-leaderboards.js @@ -31,8 +31,7 @@ function BCSocialLeaderboard() { bc.socialLeaderboard.OPERATION_REMOVE_GROUP_SCORE = "REMOVE_GROUP_SCORE"; bc.socialLeaderboard.OPERATION_GET_GROUP_LEADERBOARD_VIEW = "GET_GROUP_LEADERBOARD_VIEW"; bc.socialLeaderboard.OPERATION_GET_GROUP_LEADERBOARD_VIEW_BY_VERSION = "GET_GROUP_LEADERBOARD_VIEW_BY_VERSION"; - - + bc.socialLeaderboard.OPERATION_POST_SCORE_TO_DYNAMIC_GROUP_LEADERBOARD = "POST_GROUP_SCORE_DYNAMIC" @@ -741,6 +740,42 @@ function BCSocialLeaderboard() { callback : callback }); } + + /** + * Post the group score to the given group leaderboard and dynamically create if necessary. LeaderboardType, rotationType, rotationReset, and retainedCount are required. * + * Service Name - leaderboard + * Service Operation - POST_SCORE_TO_DYNAMIC_GROUP_LEADERBOARD + * + * @param leaderboardId the id of the leaderboard + * @param groupId the group's id + * @param score the sort order + * @param data extra data + * @param leaderboardType the type + * @param rotationType the type of tournamnet rotation + * @param rotationResetTime how often to reset + * @param retainedCount + * @param callback The method to be invoked when the server response is received + */ + bc.socialLeaderboard.postScoreToDynamicGroupLeaderboard = function(leaderboardId, groupId, score, data, leaderboardType, rotationType, rotationResetTime, retainedCount, callback) { + var message = { + leaderboardId : leaderboardId, + groupId : groupId, + score : score, + data : data, + leaderboardType : leaderboardType, + rotationType : rotationType, + rotationResetTime : rotationResetTime, + retainedCount : retainedCount + }; + + bc.brainCloudManager.sendRequest({ + service : bc.SERVICE_LEADERBOARD, + operation : bc.socialLeaderboard.OPERATION_POST_SCORE_TO_DYNAMIC_GROUP_LEADERBOARD, + data : message, + callback : callback + }); + } + } BCSocialLeaderboard.apply(window.brainCloudClient = window.brainCloudClient || {}); diff --git a/src/brainCloudWrapper.js b/src/brainCloudWrapper.js index 8856069..0e22cf4 100644 --- a/src/brainCloudWrapper.js +++ b/src/brainCloudWrapper.js @@ -421,6 +421,46 @@ function BrainCloudWrapper(wrapperName) { }); }; + /** + * Authenticate the user using a Pase userid and authentication token + * + * Service Name - Authenticate + * Service Operation - Authenticate + * + * @param handoffId braincloud handoff Id generated from cloud script + * @param securityToken The security token entered by the user + * @param callback The method to be invoked when the server response is received + */ + bcw.authenticateHandoff = function(handoffId, securityToken, callback) { + bcw.brainCloudClient.authentication.authenticateHandoff( + handoffId, + securityToken, + bc.authentication.AUTHENTICATION_TYPE_HANDOFF, + null, + false, + callback); + }; + + /** + * Authenticate a user with handoffCode + * + * Service Name - authenticationV2 + * Service Operation - AUTHENTICATE + * + * @param handoffCode generated via cloudcode + * @param callback The method to be invoked when the server response is received + * + */ + bcw.authenticateSettopHandoff= function(handoffCode, callback) { + bcw.brainCloudClient.authentication.authenticateSettopHandoff( + handoffCode, + "", + bc.authentication.AUTHENTICATION_TYPE_SETTOP_HANDOFF, + null, + false, + callback); + }; + /** * Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type. * In event the current session was previously an anonymous account, the smart switch will delete that profile. diff --git a/test/test.js b/test/test.js index 1706c9a..6baa7df 100644 --- a/test/test.js +++ b/test/test.js @@ -656,13 +656,49 @@ async function testAuthentication() { }); }); - await asyncTest("authenticateHandoff()", 2, function() { - bc.brainCloudClient.authentication.initialize("", bc.brainCloudClient.authentication.generateAnonymousId()); + await asyncTest("authenticateHandoff()", 3, function() { + bc.brainCloudClient.authentication.initialize("", bc.brainCloudClient.authentication.generateAnonymousId()); - bc.brainCloudClient.authentication.authenticateHandoff("_invalid_profileId_", "_invalid_handoff_token_", function(result) { - equal(result.status, bc.statusCodes.FORBIDDEN); - equal(result.reason_code, bc.reasonCodes.TOKEN_DOES_NOT_MATCH_USER); - resolve_test(); + var handoffId; + var handoffToken; + + bc.brainCloudClient.authentication.authenticateAnonymous( + true, function(result) { + equal(result.status, 200, JSON.stringify(result)); + + bc.brainCloudClient.script.runScript("createHandoffId", {}, function(result) { + equal(result.status, 200, JSON.stringify(result)); + var d = result.data; + handoffId = d.response.handoffId; + handoffToken = d.response.securityToken; + + bc.brainCloudClient.authentication.authenticateHandoff(handoffId, handoffToken, function(result) { + equal(result.status, 200, JSON.stringify(result)); + resolve_test(); + }); + }); + }); + }); + + await asyncTest("authenticateSettopHandoff()", 3, function() { + bc.brainCloudClient.authentication.initialize("", bc.brainCloudClient.authentication.generateAnonymousId()); + + var handoffCode + + bc.brainCloudClient.authentication.authenticateAnonymous( + true, function(result) { + equal(result.status, 200, JSON.stringify(result)); + + bc.brainCloudClient.script.runScript("CreateSettopHandoffCode", {}, function(result) { + equal(result.status, 200, JSON.stringify(result)); + var d = result.data; + handoffCode = d.response.handoffCode + + bc.brainCloudClient.authentication.authenticateSettopHandoff(handoffCode, function(result) { + equal(result.status, 200, JSON.stringify(result)); + resolve_test(); + }); + }); }); }); } @@ -938,7 +974,7 @@ async function testCustomEntity() { position : "forward", goals : 2, assists : 4 - }, { "other" : 2 }, null, false, function(result) { + }, { "other" : 2 }, null, true, function(result) { equal(result.status, 200, JSON.stringify(result)); entityId = result.data.entityId; resolve_test(); @@ -3943,6 +3979,23 @@ async function testSocialLeaderboard() { }); }); + await asyncTest("postScoreToDynamicGroupLeaderboard())", 2, function() { + bc.socialLeaderboard.postScoreToDynamicGroupLeaderboard( + groupLeaderboard, + groupId, + 0, + { test : "asdf"}, + "HIGH_VALUE", + "WEEKLY", + 1570818219096, + 2, + function(result) { + ok(true, JSON.stringify(result)); + equal(result.status, 200, "Expecting 200"); + resolve_test(); + }); + }); + await asyncTest("removeGroupScore())", 2, function() { bc.socialLeaderboard.removeGroupScore( groupLeaderboard, From f61f55f3147d6215ade7a3f4315b75b5d7c52e7d Mon Sep 17 00:00:00 2001 From: ruth0048 <31827673+ruth0048@users.noreply.github.com> Date: Mon, 21 Oct 2019 15:25:00 -0400 Subject: [PATCH 4/7] adding autoJoinGroupMulti and deprecate notice on resetMilestones --- src/brainCloudClient-gamification.js | 2 ++ src/brainCloudClient-group.js | 29 ++++++++++++++++++++++++++++ test/test.js | 13 +++++++++++++ 3 files changed, 44 insertions(+) diff --git a/src/brainCloudClient-gamification.js b/src/brainCloudClient-gamification.js index 86e1c1c..80bed3e 100644 --- a/src/brainCloudClient-gamification.js +++ b/src/brainCloudClient-gamification.js @@ -241,6 +241,8 @@ function BCGamification() { }; /** + * @deprecated + * * Resets the specified milestones' statuses to LOCKED. * * Service Name - Gamification diff --git a/src/brainCloudClient-group.js b/src/brainCloudClient-group.js index 53e103f..fe17078 100644 --- a/src/brainCloudClient-group.js +++ b/src/brainCloudClient-group.js @@ -10,6 +10,7 @@ function BCGroup() { bc.group.OPERATION_ADD_GROUP_MEMBER = "ADD_GROUP_MEMBER"; bc.group.OPERATION_APPROVE_GROUP_JOIN_REQUEST = "APPROVE_GROUP_JOIN_REQUEST"; bc.group.OPERATION_AUTO_JOIN_GROUP = "AUTO_JOIN_GROUP"; + bc.group.OPERATION_AUTO_JOIN_GROUP_MULTI = "AUTO_JOIN_GROUP_MULTI"; bc.group.OPERATION_CANCEL_GROUP_INVITATION = "CANCEL_GROUP_INVITATION"; bc.group.OPERATION_CREATE_GROUP = "CREATE_GROUP"; bc.group.OPERATION_CREATE_GROUP_ENTITY = "CREATE_GROUP_ENTITY"; @@ -154,6 +155,34 @@ function BCGroup() { }); }; + /** + * Find and join an open group in the pool of groups in multiple group types provided as input arguments. + * + * Service Name - group + * Service Operation - AUTO_JOIN_GROUP + * + * @param groupTypes Name of the associated group type. + * @param autoJoinStrategy Selection strategy to employ when there are multiple matches + * @param where Query parameters (optional) + * @param callback The method to be invoked when the server response is received + */ + bc.group.autoJoinGroupMulti = function(groupTypes, autoJoinStrategy, where, callback) { + var message = { + groupTypes : groupTypes, + autoJoinStrategy : autoJoinStrategy + }; + + if(where) message.where = where; + + bc.brainCloudManager.sendRequest({ + service : bc.SERVICE_GROUP, + operation : bc.group.OPERATION_AUTO_JOIN_GROUP_MULTI, + data : message, + callback : callback + }); + }; + + /** * Cancel an outstanding invitation to the group. * diff --git a/test/test.js b/test/test.js index 6baa7df..cf142b8 100644 --- a/test/test.js +++ b/test/test.js @@ -2264,6 +2264,19 @@ async function testGroup() { resolve_test(); }); }); + + var groupTypes = ["test"]; + + await asyncTest("autoJoinGroupMulti()", 2, function() { + bc.group.autoJoinGroupMulti(groupTypes, + bc.group.autoJoinStrategy.joinFirstGroup, + null, + function(result) { + ok(true, JSON.stringify(result)); + equal(result.status, 200, "Expecting 200"); + resolve_test(); + }); + }); await asyncTest("GetRandomGroupsMatching()", 2, function() { bc.group.getRandomGroupsMatching({ groupType : "BLUE"}, From 0b3956bf02bc6ad4288476d984dbdef68b3b7773 Mon Sep 17 00:00:00 2001 From: ruth0048 <31827673+ruth0048@users.noreply.github.com> Date: Thu, 24 Oct 2019 10:59:55 -0400 Subject: [PATCH 5/7] update timeout to 2 minutes, and version update to package.json --- deploy/node/package-lock.json | 2 +- deploy/node/package.json | 2 +- src/brainCloudBase.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deploy/node/package-lock.json b/deploy/node/package-lock.json index 318c7e3..979a8bf 100644 --- a/deploy/node/package-lock.json +++ b/deploy/node/package-lock.json @@ -1,6 +1,6 @@ { "name": "braincloud", - "version": "4.1.0", + "version": "4.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/deploy/node/package.json b/deploy/node/package.json index 8e6cc29..0dc85eb 100644 --- a/deploy/node/package.json +++ b/deploy/node/package.json @@ -1,6 +1,6 @@ { "name": "braincloud", - "version": "4.1.0", + "version": "4.2.0", "description": " brainCloud client for NodeJS", "main": "index.js", "react-native": "react-native.js", diff --git a/src/brainCloudBase.js b/src/brainCloudBase.js index da34111..db25691 100644 --- a/src/brainCloudBase.js +++ b/src/brainCloudBase.js @@ -20,7 +20,7 @@ function BrainCloudManager () bcm._rewardCallback = null; bcm._errorCallback = null; bcm._jsonedQueue = ""; - bcm._idleTimeout = 30; + bcm._idleTimeout = 120; bcm._heartBeatIntervalId = null; bcm._bundlerIntervalId = null; From c5144f0d3476b23a3344a815c857f7672052bc1c Mon Sep 17 00:00:00 2001 From: ruth0048 <31827673+ruth0048@users.noreply.github.com> Date: Mon, 11 Nov 2019 22:58:12 -0500 Subject: [PATCH 6/7] Fixing react-native script compatability with tools like browserify that do a hard check on require statements --- deploy/node/react-native.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/deploy/node/react-native.js b/deploy/node/react-native.js index 2c157cc..affa12d 100644 --- a/deploy/node/react-native.js +++ b/deploy/node/react-native.js @@ -1,7 +1,7 @@ -// Set up AsyncStorage. +//Set up AsyncStorage. var AsyncStorage = null; try { - AsyncStorage = require('@react-native-community/async-storage').default + AsyncStorage = useReactModule('@react-native-community/async-storage') } catch (er) { AsyncStorage = { getItem: function () { }, @@ -13,12 +13,18 @@ try { var BackgroundTimer = null; var customSetInterval = null; try { - BackgroundTimer = require('react-native-background-timer').default; + BackgroundTimer = useReactModule('react-native-background-timer') customSetInterval = function (func, interval) { BackgroundTimer.setInterval(func, interval); }; } catch (e) { customSetInterval = null; } +//Browserify processes only require() calls with literals, i.e. require('theplugin'); It will not include modules that can be required with functions. +//this is key because if you use regular requires, it will alwyas argue that the module is missing if it is not there and directed by a relative path. +function useReactModule(moduleName) { + require(moduleName).default; +} + /* * BrainCloudClient expect localStorage to be available as a * synchronous API, this will simulate the minimum required From 09eb7ac1aec8755863ef1b679153a382ec6fd830 Mon Sep 17 00:00:00 2001 From: ruth0048 <31827673+ruth0048@users.noreply.github.com> Date: Tue, 12 Nov 2019 12:51:11 -0500 Subject: [PATCH 7/7] updating versions --- deploy/node/package.json | 2 +- src/brainCloudClient.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/node/package.json b/deploy/node/package.json index 0dc85eb..dc52ef7 100644 --- a/deploy/node/package.json +++ b/deploy/node/package.json @@ -1,6 +1,6 @@ { "name": "braincloud", - "version": "4.2.0", + "version": "4.3.0", "description": " brainCloud client for NodeJS", "main": "index.js", "react-native": "react-native.js", diff --git a/src/brainCloudClient.js b/src/brainCloudClient.js index 1650726..3acc4c2 100644 --- a/src/brainCloudClient.js +++ b/src/brainCloudClient.js @@ -156,7 +156,7 @@ function BrainCloudClient() { } - bcc.version = "4.2.0"; + bcc.version = "4.3.0"; bcc.countryCode; bcc.languageCode;