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.js | changed |
storage.js | |||
---|---|---|---|
@@ -48,30 +48,30 @@ | |||
48 | 48 … | ].join('\n') | |
49 | 49 … | } | |
50 | 50 … | ||
51 | 51 … | function reconstructKeys(keyfile) { | |
52 | - var private = keyfile | ||
52 … | + var privateKey = keyfile | ||
53 | 53 … | .replace(/\s*\#[^\n]*/g, '') | |
54 | 54 … | .split('\n').filter(empty).join('') | |
55 | 55 … | ||
56 | 56 … | //if the key is in JSON format, we are good. | |
57 | 57 … | try { | |
58 | - var keys = JSON.parse(private) | ||
58 … | + var keys = JSON.parse(privateKey) | ||
59 | 59 … | if(!u.hasSigil(keys.id)) keys.id = '@' + keys.public | |
60 | 60 … | return keys | |
61 | 61 … | } catch (_) { console.error(_.stack) } | |
62 | 62 … | ||
63 | 63 … | //else, reconstruct legacy curve... | |
64 | 64 … | ||
65 | - var curve = u.getTag(private) | ||
65 … | + var curve = u.getTag(privateKey) | ||
66 | 66 … | ||
67 | 67 … | if(curve !== 'k256') | |
68 | 68 … | throw new Error('expected legacy curve (k256) but found:' + curve) | |
69 | 69 … | ||
70 | 70 … | var fool_browserify = require | |
71 | 71 … | var ecc = fool_browserify('./eccjs') | |
72 | 72 … | ||
73 | - return u.keysToJSON(ecc.restore(u.toBuffer(private)), 'k256') | ||
73 … | + return u.keysToJSON(ecc.restore(u.toBuffer(privateKey)), 'k256') | ||
74 | 74 … | } | |
75 | 75 … | ||
76 | 76 … | exports.load = function(filename, cb) { | |
77 | 77 … | filename = toFile(filename, 'secret') |
Built with git-ssb-web