2017-01-25 18:51:41 +01:00
|
|
|
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
2016-11-06 12:51:53 +01:00
|
|
|
// This file is part of Parity.
|
|
|
|
|
|
|
|
// Parity is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// Parity is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-12-11 17:43:51 +01:00
|
|
|
import { inData, inNumber16, inOptions } from '../../format/input';
|
2016-11-06 12:51:53 +01:00
|
|
|
import { outSignerRequest } from '../../format/output';
|
|
|
|
|
|
|
|
export default class Signer {
|
2017-05-31 12:08:04 +02:00
|
|
|
constructor (provider) {
|
|
|
|
this._provider = provider;
|
2016-11-06 12:51:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
confirmRequest (requestId, options, password) {
|
2017-05-31 12:08:04 +02:00
|
|
|
return this._provider
|
|
|
|
.send('signer_confirmRequest', inNumber16(requestId), inOptions(options), password);
|
2016-11-06 12:51:53 +01:00
|
|
|
}
|
|
|
|
|
2016-11-10 11:27:05 +01:00
|
|
|
confirmRequestRaw (requestId, data) {
|
2017-05-31 12:08:04 +02:00
|
|
|
return this._provider
|
|
|
|
.send('signer_confirmRequestRaw', inNumber16(requestId), inData(data));
|
2016-11-10 11:27:05 +01:00
|
|
|
}
|
|
|
|
|
2017-02-01 10:58:09 +01:00
|
|
|
confirmRequestWithToken (requestId, options, password) {
|
2017-05-31 12:08:04 +02:00
|
|
|
return this._provider
|
|
|
|
.send('signer_confirmRequestWithToken', inNumber16(requestId), inOptions(options), password);
|
2017-02-01 10:58:09 +01:00
|
|
|
}
|
|
|
|
|
2016-11-06 12:51:53 +01:00
|
|
|
generateAuthorizationToken () {
|
2017-05-31 12:08:04 +02:00
|
|
|
return this._provider
|
|
|
|
.send('signer_generateAuthorizationToken');
|
2016-11-06 12:51:53 +01:00
|
|
|
}
|
|
|
|
|
2017-06-22 20:05:40 +02:00
|
|
|
generateWebProxyAccessToken (domain) {
|
2017-05-31 12:08:04 +02:00
|
|
|
return this._provider
|
2017-06-22 20:05:40 +02:00
|
|
|
.execute('signer_generateWebProxyAccessToken', domain);
|
2016-12-27 11:15:02 +01:00
|
|
|
}
|
|
|
|
|
2016-11-06 12:51:53 +01:00
|
|
|
rejectRequest (requestId) {
|
2017-05-31 12:08:04 +02:00
|
|
|
return this._provider
|
|
|
|
.send('signer_rejectRequest', inNumber16(requestId));
|
2016-11-06 12:51:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
requestsToConfirm () {
|
2017-05-31 12:08:04 +02:00
|
|
|
return this._provider
|
|
|
|
.send('signer_requestsToConfirm')
|
2016-11-06 12:51:53 +01:00
|
|
|
.then((requests) => (requests || []).map(outSignerRequest));
|
|
|
|
}
|
|
|
|
|
|
|
|
signerEnabled () {
|
2017-05-31 12:08:04 +02:00
|
|
|
return this._provider
|
|
|
|
.send('signer_signerEnabled');
|
2016-11-06 12:51:53 +01:00
|
|
|
}
|
|
|
|
}
|