git ssb

1+

Dominic / ssb-keys



Commit d4ef8dce83a1e51aa27265e0b3b23692cdfb3793

Avoid reserved keywords in storage.js

To support environments like React Native's packager, which checks for strict mode, we need to avoid keywords like `private` or `public`.
André Staltz authored on 3/17/2017, 6:51:13 PM
GitHub committed on 3/17/2017, 6:51:13 PM
Parent: 1f80eb811659fb473d6119b6cb642a511ad9466f

Files changed

storage.jschanged
storage.jsView
@@ -48,30 +48,30 @@
4848 ].join('\n')
4949 }
5050
5151 function reconstructKeys(keyfile) {
52- var private = keyfile
52 + var privateKey = keyfile
5353 .replace(/\s*\#[^\n]*/g, '')
5454 .split('\n').filter(empty).join('')
5555
5656 //if the key is in JSON format, we are good.
5757 try {
58- var keys = JSON.parse(private)
58 + var keys = JSON.parse(privateKey)
5959 if(!u.hasSigil(keys.id)) keys.id = '@' + keys.public
6060 return keys
6161 } catch (_) { console.error(_.stack) }
6262
6363 //else, reconstruct legacy curve...
6464
65- var curve = u.getTag(private)
65 + var curve = u.getTag(privateKey)
6666
6767 if(curve !== 'k256')
6868 throw new Error('expected legacy curve (k256) but found:' + curve)
6969
7070 var fool_browserify = require
7171 var ecc = fool_browserify('./eccjs')
7272
73- return u.keysToJSON(ecc.restore(u.toBuffer(private)), 'k256')
73 + return u.keysToJSON(ecc.restore(u.toBuffer(privateKey)), 'k256')
7474 }
7575
7676 exports.load = function(filename, cb) {
7777 filename = toFile(filename, 'secret')

Built with git-ssb-web