UNPKG

aladinnetwork-blockstack

Version:

The Aladin Javascript library for authentication, identity, and storage.

45 lines 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const errors_1 = require("../errors"); const SESSION_VERSION = '1.0.0'; /** * @ignore */ class SessionData { constructor(options) { this.version = SESSION_VERSION; this.appPrivateKey = options.appPrivateKey; this.identityAddress = options.identityAddress; this.username = options.username; this.coreNode = options.coreNode; this.hubUrl = options.hubUrl; this.userData = options.userData; this.transitKey = options.transitKey; } getGaiaHubConfig() { return this.userData && this.userData.gaiaHubConfig; } setGaiaHubConfig(config) { this.userData.gaiaHubConfig = config; } static fromJSON(json) { if (json.version !== SESSION_VERSION) { throw new errors_1.InvalidStateError(`JSON data version ${json.version} not supported by SessionData`); } const options = { appPrivateKey: json.appPrivateKey, identityAddress: json.identityAddress, username: json.username, coreNode: json.coreNode, hubUrl: json.hubUrl, userData: json.userData, transitKey: json.transitKey }; return new SessionData(options); } toString() { return JSON.stringify(this); } } exports.SessionData = SessionData; //# sourceMappingURL=sessionData.js.map