-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac9e17e
commit b3a7170
Showing
12 changed files
with
269 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,64 @@ | ||
export const CLIENT_KEY = "client-key"; | ||
export const APP_URL = "app-url"; | ||
export const AUTHORIZED = "node-authorized"; | ||
|
||
export interface ClientKey { | ||
privateKey: string; | ||
publicKey: string; | ||
privateKey: string; | ||
publicKey: string; | ||
} | ||
|
||
export const setStorageClientKey = (clientKey: ClientKey) => { | ||
localStorage.setItem(CLIENT_KEY, JSON.stringify(clientKey)); | ||
localStorage.setItem(CLIENT_KEY, JSON.stringify(clientKey)); | ||
}; | ||
|
||
export const getStorageClientKey = (): ClientKey | null => { | ||
if (typeof window !== 'undefined' && window.localStorage) { | ||
let clientKeystore: ClientKey = JSON.parse(localStorage.getItem(CLIENT_KEY)); | ||
if (clientKeystore) { | ||
return clientKeystore; | ||
} | ||
if (typeof window !== "undefined" && window.localStorage) { | ||
let clientKeystore: ClientKey = JSON.parse( | ||
localStorage.getItem(CLIENT_KEY) | ||
); | ||
if (clientKeystore) { | ||
return clientKeystore; | ||
} | ||
return null; | ||
} | ||
return null; | ||
}; | ||
|
||
export const clearClientKey = () => { | ||
localStorage.removeItem(CLIENT_KEY); | ||
localStorage.removeItem(CLIENT_KEY); | ||
}; | ||
|
||
export const setStorageNodeAuthorized = () => { | ||
localStorage.setItem(AUTHORIZED, JSON.stringify(true)); | ||
localStorage.setItem(AUTHORIZED, JSON.stringify(true)); | ||
}; | ||
|
||
export const getStorageNodeAuthorized = (): boolean | null => { | ||
if (typeof window !== 'undefined' && window.localStorage) { | ||
let authorized: boolean = JSON.parse(localStorage.getItem(AUTHORIZED)); | ||
if (authorized) { | ||
return authorized; | ||
} | ||
if (typeof window !== "undefined" && window.localStorage) { | ||
let authorized: boolean = JSON.parse(localStorage.getItem(AUTHORIZED)); | ||
if (authorized) { | ||
return authorized; | ||
} | ||
return null; | ||
} | ||
return null; | ||
}; | ||
|
||
export const clearNodeAuthorized = () => { | ||
localStorage.removeItem(AUTHORIZED); | ||
}; | ||
localStorage.removeItem(AUTHORIZED); | ||
}; | ||
|
||
export const clearAppEndpoint = () => { | ||
localStorage.removeItem(APP_URL); | ||
}; | ||
|
||
export const setAppEndpointKey = (url: String) => { | ||
localStorage.setItem(APP_URL, JSON.stringify(url)); | ||
}; | ||
|
||
export const getAppEndpointKey = (): String | null => { | ||
if (typeof window !== "undefined" && window.localStorage) { | ||
let url: String = JSON.parse(localStorage.getItem(APP_URL)); | ||
if (url) { | ||
return url; | ||
} | ||
} | ||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.