From 566ea9a92c6fd73c7de8f7c17754b380e51eb53b Mon Sep 17 00:00:00 2001 From: Chathura Widanage Date: Wed, 2 May 2018 17:39:53 +0530 Subject: [PATCH 1/3] Allow credentials and region to be passed as options All most all other AWS SDK services support this feature. Since this is not provided in CognitoSyncManager, it becomes a problem, when we want to do concurrent API calls to multiple AWS regions with different sets of credentials. --- src/CognitoSyncManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CognitoSyncManager.js b/src/CognitoSyncManager.js index a2ecee7..a291a22 100644 --- a/src/CognitoSyncManager.js +++ b/src/CognitoSyncManager.js @@ -31,9 +31,9 @@ if (AWS === undefined) { var USER_AGENT = 'CognitoJavaScriptSDK/1'; - this.provider = AWS.config.credentials; + this.provider = options.credentials || AWS.config.credentials; this.identityPoolId = this.provider.params.IdentityPoolId; - this.region = AWS.config.region; + this.region = options.region || AWS.config.region; // Setup logger. this.logger = options.log; From 490e16130a636084dc865f50074373d9ba6a5d1e Mon Sep 17 00:00:00 2001 From: Chathura Widanage Date: Thu, 3 May 2018 14:27:34 +0530 Subject: [PATCH 2/3] Passing region to the RemoteStorage --- src/CognitoSyncManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CognitoSyncManager.js b/src/CognitoSyncManager.js index a291a22..690f245 100644 --- a/src/CognitoSyncManager.js +++ b/src/CognitoSyncManager.js @@ -46,7 +46,7 @@ if (AWS === undefined) { this.local = new AWS.CognitoSyncManager.LocalStorage({DataStore: options.DataStore ? options.DataStore : AWS.CognitoSyncManager.StoreLocalStorage}); // Initialize remote store. - this.remote = new AWS.CognitoSyncManager.RemoteStorage(this.identityPoolId, this.provider); + this.remote = new AWS.CognitoSyncManager.RemoteStorage(this.identityPoolId, this.provider, this.region); this.remote.setUserAgent(USER_AGENT); }; From 0f18460cf692cc9febb5f82b5e73b36c3204f281 Mon Sep 17 00:00:00 2001 From: Chathura Widanage Date: Thu, 3 May 2018 14:28:39 +0530 Subject: [PATCH 3/3] Using region to create the instance of CognitoSync --- src/CognitoSyncRemoteStorage.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CognitoSyncRemoteStorage.js b/src/CognitoSyncRemoteStorage.js index a1b7360..653bf68 100644 --- a/src/CognitoSyncRemoteStorage.js +++ b/src/CognitoSyncRemoteStorage.js @@ -27,12 +27,12 @@ AWS.CognitoSyncManager.RemoteStorage = (function() { * @constructor */ - var CognitoSyncRemoteStorage = function (identityPoolId, provider) { + var CognitoSyncRemoteStorage = function (identityPoolId, provider, region) { this.identityPoolId = identityPoolId; this.provider = provider; - this.client = new AWS.CognitoSync(); - + this.client = new AWS.CognitoSync({region: region, credentials: provider}); + }; CognitoSyncRemoteStorage.prototype.userAgent = ''; @@ -274,4 +274,4 @@ AWS.CognitoSyncManager.RemoteStorage = (function() { return CognitoSyncRemoteStorage; -})(); \ No newline at end of file +})();