UNPKG

@stacks/auth

Version:

Authentication for Stacks apps.

30 lines 990 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SessionData = void 0; const common_1 = require("@stacks/common"); const SESSION_VERSION = '1.0.0'; class SessionData { constructor(options) { this.version = SESSION_VERSION; this.userData = options.userData; this.transitKey = options.transitKey; this.etags = options.etags ? options.etags : {}; } static fromJSON(json) { if (json.version !== SESSION_VERSION) { throw new common_1.InvalidStateError(`JSON data version ${json.version} not supported by SessionData`); } const options = { coreNode: json.coreNode, userData: json.userData, transitKey: json.transitKey, etags: json.etags, }; return new SessionData(options); } toString() { return JSON.stringify(this); } } exports.SessionData = SessionData; //# sourceMappingURL=sessionData.js.map