diff --git a/src/CognitoSyncManager.js b/src/CognitoSyncManager.js index a2ecee7..690f245 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; @@ -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); }; 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 +})();