@@ -10,7 +10,7 @@ var LedgerArk = function(comm) {
10
10
11
11
LedgerArk . prototype . getAddress_async = function ( path ) {
12
12
var splitPath = utils . splitPath ( path ) ;
13
- var buffer = new Buffer ( 5 + 1 + splitPath . length * 4 ) ;
13
+ var buffer = Buffer . alloc ( 5 + 1 + splitPath . length * 4 ) ;
14
14
buffer [ 0 ] = 0xe0 ;
15
15
buffer [ 1 ] = 0x02 ;
16
16
buffer [ 2 ] = 0x00 ;
@@ -23,7 +23,7 @@ LedgerArk.prototype.getAddress_async = function(path) {
23
23
return this . comm . exchange ( buffer . toString ( 'hex' ) , [ 0x9000 ] ) . then ( function ( response ) {
24
24
var result = { } ;
25
25
//console.log(response);
26
- var response = new Buffer ( response , 'hex' ) ;
26
+ var response = Buffer . from ( response , 'hex' ) ;
27
27
var publicKeyLength = response [ 0 ] ;
28
28
var addressLength = response [ 1 + publicKeyLength ] ;
29
29
result [ 'publicKey' ] = response . slice ( 1 , 1 + publicKeyLength ) . toString ( 'hex' ) ;
@@ -34,18 +34,18 @@ LedgerArk.prototype.getAddress_async = function(path) {
34
34
35
35
LedgerArk . prototype . signTransaction_async = function ( path , rawTxHex ) {
36
36
var splitPath = utils . splitPath ( path ) ;
37
- var rawTx = new Buffer ( rawTxHex , 'hex' ) ;
37
+ var rawTx = Buffer . from ( rawTxHex , 'hex' ) ;
38
38
var self = this ;
39
39
40
40
var data1 , data2 ;
41
- var data1_headerlength = new Buffer ( 2 ) ;
42
- var data2_headerlength = new Buffer ( 1 ) ;
41
+ var data1_headerlength = Buffer . alloc ( 2 ) ;
42
+ var data2_headerlength = Buffer . alloc ( 1 ) ;
43
43
var pathLength = 4 * splitPath . length + 1 ;
44
44
var apdus = [ ] ;
45
45
var p1 ;
46
46
var response ;
47
47
48
- path = new Buffer ( pathLength - 1 ) ;
48
+ path = Buffer . alloc ( pathLength - 1 ) ;
49
49
splitPath . forEach ( function ( element , index ) {
50
50
path . writeUInt32BE ( element , 4 * index ) ;
51
51
} ) ;
@@ -91,15 +91,15 @@ LedgerArk.prototype.signTransaction_async = function(path, rawTxHex) {
91
91
}
92
92
93
93
LedgerArk . prototype . getAppConfiguration_async = function ( ) {
94
- var buffer = new Buffer ( 5 ) ;
94
+ var buffer = Buffer . alloc ( 5 ) ;
95
95
buffer [ 0 ] = 0xe0 ;
96
96
buffer [ 1 ] = 0x06 ;
97
97
buffer [ 2 ] = 0x00 ;
98
98
buffer [ 3 ] = 0x00 ;
99
99
buffer [ 4 ] = 0x00 ;
100
100
return this . comm . exchange ( buffer . toString ( 'hex' ) , [ 0x9000 ] ) . then ( function ( response ) {
101
101
var result = { } ;
102
- var response = new Buffer ( response , 'hex' ) ;
102
+ var response = Buffer . from ( response , 'hex' ) ;
103
103
result [ 'arbitraryDataEnabled' ] = ( response [ 0 ] & 0x01 ) ;
104
104
result [ 'version' ] = "" + response [ 1 ] + '.' + response [ 2 ] + '.' + response [ 3 ] ;
105
105
return result ;
@@ -109,14 +109,14 @@ LedgerArk.prototype.getAppConfiguration_async = function() {
109
109
LedgerArk . prototype . signPersonalMessage_async = function ( path , messageHex ) {
110
110
var splitPath = utils . splitPath ( path ) ;
111
111
var offset = 0 ;
112
- var message = new Buffer ( messageHex , 'hex' ) ;
112
+ var message = Buffer . from ( messageHex , 'hex' ) ;
113
113
var apdus = [ ] ;
114
114
var response = [ ] ;
115
115
var self = this ;
116
116
while ( offset != message . length ) {
117
117
var maxChunkSize = ( offset == 0 ? ( 150 - 1 - splitPath . length * 4 - 4 ) : 150 )
118
118
var chunkSize = ( offset + maxChunkSize > message . length ? message . length - offset : maxChunkSize ) ;
119
- var buffer = new Buffer ( offset == 0 ? 5 + 1 + splitPath . length * 4 + 4 + chunkSize : 5 + chunkSize ) ;
119
+ var buffer = Buffer . alloc ( offset == 0 ? 5 + 1 + splitPath . length * 4 + 4 + chunkSize : 5 + chunkSize ) ;
120
120
buffer [ 0 ] = 0xe0 ;
121
121
buffer [ 1 ] = 0x08 ;
122
122
buffer [ 2 ] = ( offset == 0 ? 0x00 : 0x80 ) ;
@@ -141,7 +141,7 @@ LedgerArk.prototype.signPersonalMessage_async = function(path, messageHex) {
141
141
response = apduResponse ;
142
142
} )
143
143
} ) . then ( function ( ) {
144
- response = new Buffer ( response , 'hex' ) ;
144
+ response = Buffer . from ( response , 'hex' ) ;
145
145
var result = { } ;
146
146
result [ 'v' ] = response [ 0 ] ;
147
147
result [ 'r' ] = response . slice ( 1 , 1 + 32 ) . toString ( 'hex' ) ;
0 commit comments