node/wallet: add cors option. see #397.
This commit is contained in:
parent
6c8cf8c56a
commit
c7d844ea37
@ -143,7 +143,8 @@ class FullNode extends Node {
|
||||
host: this.config.str('http-host'),
|
||||
port: this.config.uint('http-port'),
|
||||
apiKey: this.config.str('api-key'),
|
||||
noAuth: this.config.bool('no-auth')
|
||||
noAuth: this.config.bool('no-auth'),
|
||||
cors: this.config.bool('cors')
|
||||
});
|
||||
|
||||
this.init();
|
||||
|
||||
@ -80,7 +80,8 @@ class HTTP extends Server {
|
||||
*/
|
||||
|
||||
initRouter() {
|
||||
this.use(this.cors());
|
||||
if (this.options.cors)
|
||||
this.use(this.cors());
|
||||
|
||||
if (!this.options.noAuth) {
|
||||
this.use(this.basicAuth({
|
||||
@ -679,6 +680,7 @@ class HTTPOptions {
|
||||
this.apiKey = base58.encode(random.randomBytes(20));
|
||||
this.apiHash = sha256.digest(Buffer.from(this.apiKey, 'ascii'));
|
||||
this.noAuth = false;
|
||||
this.cors = false;
|
||||
|
||||
this.prefix = null;
|
||||
this.host = '127.0.0.1';
|
||||
@ -727,6 +729,11 @@ class HTTPOptions {
|
||||
this.noAuth = options.noAuth;
|
||||
}
|
||||
|
||||
if (options.cors != null) {
|
||||
assert(typeof options.cors === 'boolean');
|
||||
this.cors = options.cors;
|
||||
}
|
||||
|
||||
if (options.prefix != null) {
|
||||
assert(typeof options.prefix === 'string');
|
||||
this.prefix = options.prefix;
|
||||
|
||||
@ -91,7 +91,8 @@ class SPVNode extends Node {
|
||||
host: this.config.str('http-host'),
|
||||
port: this.config.uint('http-port'),
|
||||
apiKey: this.config.str('api-key'),
|
||||
noAuth: this.config.bool('no-auth')
|
||||
noAuth: this.config.bool('no-auth'),
|
||||
cors: this.config.bool('cors')
|
||||
});
|
||||
|
||||
this.rescanJob = null;
|
||||
|
||||
@ -78,7 +78,8 @@ class HTTP extends Server {
|
||||
*/
|
||||
|
||||
initRouter() {
|
||||
this.use(this.cors());
|
||||
if (this.options.cors)
|
||||
this.use(this.cors());
|
||||
|
||||
if (!this.options.noAuth) {
|
||||
this.use(this.basicAuth({
|
||||
@ -1041,6 +1042,7 @@ class HTTPOptions {
|
||||
this.adminToken = random.randomBytes(32);
|
||||
this.serviceHash = this.apiHash;
|
||||
this.noAuth = false;
|
||||
this.cors = false;
|
||||
this.walletAuth = false;
|
||||
|
||||
this.prefix = null;
|
||||
@ -1106,6 +1108,11 @@ class HTTPOptions {
|
||||
this.noAuth = options.noAuth;
|
||||
}
|
||||
|
||||
if (options.cors != null) {
|
||||
assert(typeof options.cors === 'boolean');
|
||||
this.cors = options.cors;
|
||||
}
|
||||
|
||||
if (options.walletAuth != null) {
|
||||
assert(typeof options.walletAuth === 'boolean');
|
||||
this.walletAuth = options.walletAuth;
|
||||
|
||||
@ -69,6 +69,7 @@ class WalletNode extends Node {
|
||||
apiKey: this.config.str('api-key'),
|
||||
walletAuth: this.config.bool('wallet-auth'),
|
||||
noAuth: this.config.bool('no-auth'),
|
||||
cors: this.config.bool('cors'),
|
||||
adminToken: this.config.str('admin-token')
|
||||
});
|
||||
|
||||
|
||||
@ -70,6 +70,7 @@ class Plugin extends EventEmitter {
|
||||
apiKey: this.config.str('api-key', node.config.str('api-key')),
|
||||
walletAuth: this.config.bool('wallet-auth'),
|
||||
noAuth: this.config.bool('no-auth'),
|
||||
cors: this.config.bool('cors'),
|
||||
adminToken: this.config.str('admin-token')
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user