Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 1x 1x 1x 48x 48x 48x | import { GaiaHubConfig } from '../storage/hub' import { InvalidStateError } from '../errors' import { UserData } from './authApp' const SESSION_VERSION = '1.0.0' export interface SessionOptions { coreNode?: string, userData?: UserData, transitKey?: string, localStorageKey?: string, storeOptions?: { localStorageKey?: string } } /** * @ignore */ export class SessionData { version: string transitKey?: string // using this in place of // window.localStorage.setItem(BLOCKSTACK_STORAGE_LABEL, JSON.stringify(userData)) userData?: UserData constructor(options: SessionOptions) { this.version = SESSION_VERSION this.userData = options.userData this.transitKey = options.transitKey } getGaiaHubConfig(): GaiaHubConfig { return this.userData && this.userData.gaiaHubConfig } setGaiaHubConfig(config: GaiaHubConfig): void { this.userData.gaiaHubConfig = config } static fromJSON(json: any): SessionData { if (json.version !== SESSION_VERSION) { throw new InvalidStateError(`JSON data version ${json.version} not supported by SessionData`) } const options: SessionOptions = { coreNode: json.coreNode, userData: json.userData, transitKey: json.transitKey } return new SessionData(options) } toString(): string { return JSON.stringify(this) } } |