Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-amplify/core

Package Overview
Dependencies
Maintainers
5
Versions
2033
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-amplify/core - npm Package Compare versions

Comparing version 1.0.1-unstable.0 to 1.0.1-unstable.1

10

CHANGELOG.md

@@ -6,4 +6,12 @@ # Change Log

<a name="1.0.1-unstable.1"></a>
## [1.0.1-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/core@1.0.1...@aws-amplify/core@1.0.1-unstable.1) (2018-07-18)
**Note:** Version bump only for package @aws-amplify/core
<a name="1.0.1-unstable.0"></a>
## [1.0.1-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/core@1.0.1...@aws-amplify/core@1.0.1-unstable.0) (2018-07-13)
## [1.0.1-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/core@1.0.1...@aws-amplify/core@1.0.1-unstable.0) (2018-07-18)

@@ -10,0 +18,0 @@

@@ -7,2 +7,4 @@ export declare class Credentials {

private _refreshHandlers;
private _storage;
private _storageSync;
constructor(config: any);

@@ -9,0 +11,0 @@ getCredSource(): any;

@@ -74,2 +74,10 @@ "use strict";

}
this._storage = this._config.storage;
if (!this._storage) {
this._storage = new StorageHelper_1.default().getStorage();
}
this._storageSync = Promise.resolve();
if (typeof this._storage['sync'] === 'function') {
this._storageSync = this._storage['sync']();
}
return this._config;

@@ -178,5 +186,6 @@ };

}
return [4 /*yield*/, StorageHelper_1.default.getItem('CognitoIdentityId-' + identityPoolId)];
return [4 /*yield*/, this._storageSync];
case 1:
identityId = _b.sent();
_b.sent();
identityId = this._storage.getItem('CognitoIdentityId-' + identityPoolId);
credentials = new Facet_1.AWS.CognitoIdentityCredentials({

@@ -272,2 +281,9 @@ IdentityPoolId: identityPoolId,

provider = info.provider, token = info.token, expires_at = info.expires_at, identity_id = info.identity_id;
this._storage.setItem('aws-amplify-federatedInfo', JSON.stringify({
provider: provider,
token: token,
user: user,
expires_at: expires_at,
identity_id: identity_id
}));
if (Amplify_1.default.Cache && typeof Amplify_1.default.Cache.setItem === 'function') {

@@ -290,5 +306,6 @@ Amplify_1.default.Cache.setItem('federatedInfo', {

_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, StorageHelper_1.default.setItem('CognitoIdentityId-' + identityPoolId, credentials.identityId)];
return [4 /*yield*/, this._storageSync];
case 2:
_a.sent();
this._storage.setItem('CognitoIdentityId-' + identityPoolId, credentials.identityId);
return [3 /*break*/, 4];

@@ -342,2 +359,3 @@ case 3:

this._credentials_source = null;
this._storage.removeItem('aws-amplify-federatedInfo');
if (!(Amplify_1.default.Cache && typeof Amplify_1.default.Cache.setItem === 'function')) return [3 /*break*/, 2];

@@ -344,0 +362,0 @@ return [4 /*yield*/, Amplify_1.default.Cache.removeItem('federatedInfo')];

@@ -1,3 +0,13 @@

import '../Polyfills';
declare const StorageHelper: Storage;
export default StorageHelper;
export default class StorageHelper {
private storageWindow;
/**
* This is used to get a storage object
* @returns {object} the storage
*/
constructor();
/**
* This is used to return the storage
* @returns {object} the storage
*/
getStorage(): any;
}

@@ -15,6 +15,69 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
// import polyfill for server environment
require("../Polyfills");
var StorageHelper = window.localStorage;
var dataMemory = {};
/** @class */
var MemoryStorage = /** @class */ (function () {
function MemoryStorage() {
}
/**
* This is used to set a specific item in storage
* @param {string} key - the key for the item
* @param {object} value - the value
* @returns {string} value that was set
*/
MemoryStorage.setItem = function (key, value) {
dataMemory[key] = value;
return dataMemory[key];
};
/**
* This is used to get a specific key from storage
* @param {string} key - the key for the item
* This is used to clear the storage
* @returns {string} the data item
*/
MemoryStorage.getItem = function (key) {
return Object.prototype.hasOwnProperty.call(dataMemory, key) ? dataMemory[key] : undefined;
};
/**
* This is used to remove an item from storage
* @param {string} key - the key being set
* @returns {string} value - value that was deleted
*/
MemoryStorage.removeItem = function (key) {
return delete dataMemory[key];
};
/**
* This is used to clear the storage
* @returns {string} nothing
*/
MemoryStorage.clear = function () {
dataMemory = {};
return dataMemory;
};
return MemoryStorage;
}());
var StorageHelper = /** @class */ (function () {
/**
* This is used to get a storage object
* @returns {object} the storage
*/
function StorageHelper() {
try {
this.storageWindow = window.localStorage;
this.storageWindow.setItem('aws.amplify.test-ls', 1);
this.storageWindow.removeItem('aws.amplify.test-ls');
}
catch (exception) {
this.storageWindow = MemoryStorage;
}
}
/**
* This is used to return the storage
* @returns {object} the storage
*/
StorageHelper.prototype.getStorage = function () {
return this.storageWindow;
};
return StorageHelper;
}());
exports.default = StorageHelper;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,14 @@

declare const StorageHelper: any;
export default StorageHelper;
/** @class */
export default class StorageHelper {
private storageWindow;
/**
* This is used to get a storage object
* @returns {object} the storage
*/
constructor();
/**
* This is used to return the storage
* @returns {object} the storage
*/
getStorage(): any;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/*

@@ -14,6 +15,91 @@ * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.

*/
Object.defineProperty(exports, "__esModule", { value: true });
var react_native_1 = require("react-native");
var StorageHelper = react_native_1.AsyncStorage;
var MEMORY_KEY_PREFIX = '@MemoryStorage:';
var dataMemory = {};
/** @class */
var MemoryStorage = /** @class */ (function () {
function MemoryStorage() {
}
/**
* This is used to set a specific item in storage
* @param {string} key - the key for the item
* @param {object} value - the value
* @returns {string} value that was set
*/
MemoryStorage.setItem = function (key, value) {
react_native_1.AsyncStorage.setItem(MEMORY_KEY_PREFIX + key, value);
dataMemory[key] = value;
return dataMemory[key];
};
/**
* This is used to get a specific key from storage
* @param {string} key - the key for the item
* This is used to clear the storage
* @returns {string} the data item
*/
MemoryStorage.getItem = function (key) {
return Object.prototype.hasOwnProperty.call(dataMemory, key) ? dataMemory[key] : undefined;
};
/**
* This is used to remove an item from storage
* @param {string} key - the key being set
* @returns {string} value - value that was deleted
*/
MemoryStorage.removeItem = function (key) {
react_native_1.AsyncStorage.removeItem(MEMORY_KEY_PREFIX + key);
return delete dataMemory[key];
};
/**
* This is used to clear the storage
* @returns {string} nothing
*/
MemoryStorage.clear = function () {
dataMemory = {};
return dataMemory;
};
/**
* Will sync the MemoryStorage data from AsyncStorage to storageWindow MemoryStorage
* @returns {void}
*/
MemoryStorage.sync = function () {
return new Promise(function (res, rej) {
react_native_1.AsyncStorage.getAllKeys(function (errKeys, keys) {
if (errKeys)
rej(errKeys);
var memoryKeys = keys.filter(function (key) { return key.startsWith(MEMORY_KEY_PREFIX); });
react_native_1.AsyncStorage.multiGet(memoryKeys, function (err, stores) {
if (err)
rej(err);
stores.map(function (result, index, store) {
var key = store[index][0];
var value = store[index][1];
var memoryKey = key.replace(MEMORY_KEY_PREFIX, '');
dataMemory[memoryKey] = value;
});
res();
});
});
});
};
return MemoryStorage;
}());
/** @class */
var StorageHelper = /** @class */ (function () {
/**
* This is used to get a storage object
* @returns {object} the storage
*/
function StorageHelper() {
this.storageWindow = MemoryStorage;
}
/**
* This is used to return the storage
* @returns {object} the storage
*/
StorageHelper.prototype.getStorage = function () {
return this.storageWindow;
};
return StorageHelper;
}());
exports.default = StorageHelper;
//# sourceMappingURL=reactnative.js.map

2

package.json
{
"name": "@aws-amplify/core",
"version": "1.0.1-unstable.0",
"version": "1.0.1-unstable.1",
"description": "Core category of aws-amplify",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc