2017-11-18 20:33:53 +00:00
|
|
|
import RPCNode from '../rpc';
|
|
|
|
import RPCClient from '../rpc/client';
|
2018-02-12 20:43:07 +00:00
|
|
|
import { CustomNodeConfig } from 'types/node';
|
|
|
|
import { Omit } from 'react-router';
|
2017-11-18 20:33:53 +00:00
|
|
|
|
|
|
|
export default class CustomNode extends RPCNode {
|
2018-02-12 20:43:07 +00:00
|
|
|
constructor(config: Omit<CustomNodeConfig, 'lib'>) {
|
|
|
|
super(config.id);
|
2017-11-18 20:33:53 +00:00
|
|
|
|
|
|
|
const headers: { [key: string]: string } = {};
|
|
|
|
if (config.auth) {
|
|
|
|
const { username, password } = config.auth;
|
|
|
|
headers.Authorization = `Basic ${btoa(`${username}:${password}`)}`;
|
|
|
|
}
|
|
|
|
|
2018-02-12 20:43:07 +00:00
|
|
|
this.client = new RPCClient(config.id, headers);
|
2017-11-18 20:33:53 +00:00
|
|
|
}
|
|
|
|
}
|