UNPKG

eosjs-ios-browser-signature-provider-interface

Version:

A Signature Provider Interface for communicating with an authenticator from iOS browsers using the EOSIO Authentication Transport Protocol Specification.

33 lines 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ExpiringLocalStorageProvider = /** @class */ (function () { function ExpiringLocalStorageProvider() { } ExpiringLocalStorageProvider.prototype.set = function (variable, value, expiryMs) { var data = { value: value, expiresAt: new Date().getTime() + expiryMs, }; window.localStorage.setItem(variable, JSON.stringify(data)); }; ExpiringLocalStorageProvider.prototype.get = function (variable) { var val = window.localStorage.getItem(variable) || ''; if (!val) { return null; } var data = JSON.parse(val); if (data && data.expiresAt && data.expiresAt > new Date().getTime()) { return data.value; } else { window.localStorage.removeItem(variable); } return null; }; ExpiringLocalStorageProvider.prototype.remove = function (variable) { window.localStorage.removeItem(variable); }; return ExpiringLocalStorageProvider; }()); exports.ExpiringLocalStorageProvider = ExpiringLocalStorageProvider; //# sourceMappingURL=ExpiringLocalStorageProvider.js.map