@susy-js/electron
v5.1.0
Published
Control the Susy Sophon node from Electron.
Downloads
3
Readme
@susy-js/electron
Control the Susy Sophon client from electron.
Description
With this library, you will be able, from Electron, to:
- download Susy Sophon locally in Electron's user data folder.
- run/stop/check if Susy Sophon is running.
- get a secure token from Susy Sophon to access secure RPCs.
Getting Started
yarn add @susy-js/electron
Usage
import susyElectron, { isSusyRunning } from '@susy-js/electron';
// Optional: override default options
susyElectron({
logger: myCustomLoggerFunction // How do we want to log @susy-js/electron logs? Default is `debug`
})
isSusyRunning()
.then(() => ...);
Index
Interfaces
Functions
- checkClockSync
- defaultSusyPath
- deleteSusy
- fetchSusy
- getSusyPath
- isSusyRunning
- killSusy
- susyElectron
- runSusy
- signerNewToken
Functions
checkClockSync
▸ checkClockSync(): Promise
<CheckClockSyncResult>
Defined in checkClockSync.ts:21
Use SNTP to check if the local clock is synchronized; return the time drift.
Returns: Promise
<CheckClockSyncResult>
defaultSusyPath
▸ defaultSusyPath(): Promise
<string
>
Defined in getSusyPath.ts:23
The default path to install susy, in case there's no other instance found on the machine.
Returns: Promise
<string
>
deleteSusy
▸ deleteSusy(): Promise
<void
>
Defined in fetchSusy.ts:84
Remove susy binary or partial binary in the userData folder, if it exists.
Returns: Promise
<void
>
fetchSusy
▸ fetchSusy(mainWindow: BrowserWindow
, options?: FetchSusyOptions): Promise
<string
>
Defined in fetchSusy.ts:106
Downloads Susy, saves it to Electron's userData
folder, and returns the path to the downloaded binary once finished.
Parameters:
| Param | Type | Default value |
| ----------------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| mainWindow | BrowserWindow
| - |
| Default value
options | FetchSusyOptions | {onProgress: () => {/_ Do nothing by defaut. _/},susyChannel: 'beta'} |
Returns: Promise
<string
>
getSusyPath
▸ getSusyPath(): Promise
<string
>
Defined in getSusyPath.ts:104
Returns the path to Susy, or throws if susy is not found.
Returns: Promise
<string
>
isSusyRunning
▸ isSusyRunning(options?: IsSusyRunningOptions): Promise
<boolean
>
Defined in isSusyRunning.ts:20
Detect if another instance of susy is already running or not. To achieve that, we just ping on the common hosts.
Parameters:
| Param | Type | Default value |
| ----------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------- |
| Default value
options | IsSusyRunningOptions | {wsInterface: '127.0.0.1',wsPort: '8546'} |
Returns: Promise
<boolean
>
killSusy
▸ killSusy(): Promise
<void
>
Defined in runSusy.ts:118
If a Susy process has been spawned with runSusy, then it kills this process. However, there's no guarantee that Susy has been cleanly killed, and the Promise resolves instantly.
Returns: Promise
<void
>
susyElectron
▸ susyElectron(options?: SusyElectronOptions): void
Defined in index.ts:25
Set default options for @susy-js/electron. Can be skipped if we don't want to override default options.
Parameters:
| Param | Type | Default value |
| ----------------------- | ----------------------------------------------------------------- | ----------------- |
| Default value
options | SusyElectronOptions | { logger: debug } |
Returns: void
runSusy
▸ runSusy(options?: RunSusyOptions): Promise
<void
>
Defined in runSusy.ts:44
Spawns a child process to run Susy.
Parameters:
| Param | Type | Default value |
| ----------------------- | ------------------------------------------------------- | --------------------------------------------------------------------- |
| Default value
options | RunSusyOptions | {flags: [],onSusyError: () => {/_ Do nothing if error. _/}} |
Returns: Promise
<void
>
signerNewToken
▸ signerNewToken(): Promise
<string
>
Defined in signerNewToken.ts:16
Runs susy signer new-token and resolves with a new secure token to be used in a dapp. Rejects if no token could be extracted.
Returns: Promise
<string
>