@hakit/core
Version:
A collection of React hooks and helpers for Home Assistant to easily communicate with the Home Assistant WebSocket API.
3 lines (2 loc) • 885 B
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=typeof window<"u"?window.localStorage:null,n=o!==null;function t(){n?o.removeItem("hassTokens"):console.error("Local storage not supported on this device.")}function a(r){if(n)try{o.setItem("hassTokens",JSON.stringify(r))}catch(s){console.error("Failed to save tokens, probably due to private mode or storage full",s)}else console.error("Local storage not supported on this device.")}function c(r,s=!0){if(!n)return console.error("Local storage not supported on this device."),null;const l=o.getItem("hassTokens");if(l)try{const e=JSON.parse(l);if(e.hassUrl===r)return e;if(s)return t(),null}catch(e){return console.error("Error parsing stored tokens.",e?.message||""),t(),null}return null}exports.clearTokens=t;exports.loadTokens=c;exports.saveTokens=a;
//# sourceMappingURL=token-storage.js.map