Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Allow credentials and region to be passed as options #63

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions src/CognitoSyncManager.js
Original file line number Diff line number Diff line change
@@ -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);

};
8 changes: 4 additions & 4 deletions src/CognitoSyncRemoteStorage.js
Original file line number Diff line number Diff line change
@@ -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;

})();
})();