Comparing version 0.2.2 to 0.2.3
@@ -6,3 +6,3 @@ const cose = require('../'); | ||
'p': {'alg': 'A128GCM'}, | ||
'u': {'kid':'our-secret'} | ||
'u': {'kid': 'our-secret'} | ||
}; | ||
@@ -19,11 +19,10 @@ const recipients = [{ | ||
console.log('Encrypted message: ' + buf.toString('hex')); | ||
}).catch((error)=>{ | ||
}).catch((error) => { | ||
console.log(error); | ||
}); | ||
const key = Buffer.from('231f4c4d4d3051fdc2ec0a3851d5b383', 'hex'); | ||
const COSEMessage = Buffer.from('d8608443a10101a2044a6f75722d736563726574054c291a40271067ff57b1623c30581f23b663aaf9dfb91c5a39a175118ad7d72d416385b1b610e28b3b3fd824a397818340a040', 'hex'); | ||
const key = Buffer.from('231f4c4d4d3051fdc2ec0a3851d5b383', 'hex') | ||
const COSEMessage = Buffer.from('d8608443a10101a2044a6f75722d736563726574054c291a40271067ff57b1623c30581f23b663aaf9dfb91c5a39a175118ad7d72d416385b1b610e28b3b3fd824a397818340a040', 'hex'); | ||
return cose.encrypt.read( | ||
cose.encrypt.read( | ||
COSEMessage, | ||
@@ -33,4 +32,4 @@ key) | ||
console.log('Protected message: ' + buf.toString('utf8')); | ||
}).catch((error)=>{ | ||
}).catch((error) => { | ||
console.log(error); | ||
}); |
const cose = require('../'); | ||
const plaintext = "Important message!" | ||
const plaintext = 'Important message!'; | ||
const headers = { | ||
'p': {'alg': 'SHA-256_64'}, | ||
'u': {'kid':'our-secret'} | ||
'u': {'kid': 'our-secret'} | ||
}; | ||
@@ -18,7 +18,6 @@ const recipent = { | ||
console.log('MACed message: ' + buf.toString('hex')); | ||
}).catch((error)=>{ | ||
}).catch((error) => { | ||
console.log(error); | ||
}); | ||
const key = Buffer.from('231f4c4d4d3051fdc2ec0a3851d5b383', 'hex'); | ||
@@ -31,4 +30,4 @@ const COSEMessage = Buffer.from('d18443a10104a1044a6f75722d73656372657472496d706f7274616e74206d65737361676521488894981d4aa5d614', 'hex'); | ||
console.log('Verified message: ' + buf.toString('utf8')); | ||
}).catch((error)=>{ | ||
}).catch((error) => { | ||
console.log(error); | ||
}); |
const cose = require('../'); | ||
const plaintext = "Important message!"; | ||
const plaintext = 'Important message!'; | ||
const headers = { | ||
@@ -20,8 +20,6 @@ 'p': {'alg': 'ES256'}, | ||
console.log('Signed message: ' + buf.toString('hex')); | ||
}).catch((error)=>{ | ||
}).catch((error) => { | ||
console.log(error); | ||
}); | ||
const verifier = { | ||
@@ -33,3 +31,3 @@ 'key': { | ||
}; | ||
const COSEMessage = Buffer.from('d28443a10126a10442313172496d706f7274616e74206d6573736167652158404c2b6b66dfedc4cfef0f221cf7ac7f95087a4c4245fef0063a0fd4014b670f642d31e26d38345bb4efcdc7ded3083ab4fe71b62a23f766d83785f044b20534f9','hex'); | ||
const COSEMessage = Buffer.from('d28443a10126a10442313172496d706f7274616e74206d6573736167652158404c2b6b66dfedc4cfef0f221cf7ac7f95087a4c4245fef0063a0fd4014b670f642d31e26d38345bb4efcdc7ded3083ab4fe71b62a23f766d83785f044b20534f9', 'hex'); | ||
@@ -41,4 +39,4 @@ cose.sign.verify( | ||
console.log('Verified message: ' + buf.toString('utf8')); | ||
}).catch((error)=>{ | ||
}).catch((error) => { | ||
console.log(error); | ||
}); |
{ | ||
"name": "cose-js", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "JavaScript COSE implementation", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -9,6 +9,6 @@ [![Build Status](https://travis-ci.org/erdtman/cose-js.svg?branch=master)](https://travis-ci.org/erdtman/cose-js) | ||
const plaintext = "Important message!" | ||
const plaintext = 'Important message!'; | ||
const headers = { | ||
'p': {'alg': 'SHA-256_64'}, | ||
'u': {'kid':'our-secret'} | ||
'u': {'kid': 'our-secret'} | ||
}; | ||
@@ -25,6 +25,5 @@ const recipent = { | ||
console.log('MACed message: ' + buf.toString('hex')); | ||
}).catch((error)=>{ | ||
}).catch((error) => { | ||
console.log(error); | ||
}); | ||
``` | ||
@@ -35,5 +34,5 @@ ## Verify MAC | ||
const key = Buffer.from('231f4c4d4d3051fdc2ec0a3851d5b383', 'hex'); | ||
const COSEMessage = Buffer.from('d18443a10104a1044a6f75722d73656372657472496d706f7274616e74206d65737361676521488894981d4aa5d614', 'hex'); | ||
cose.mac.read( | ||
@@ -44,3 +43,3 @@ COSEMessage, | ||
console.log('Verified message: ' + buf.toString('utf8')); | ||
}).catch((error)=>{ | ||
}).catch((error) => { | ||
console.log(error); | ||
@@ -53,3 +52,3 @@ }); | ||
const plaintext = "Important message!"; | ||
const plaintext = 'Important message!'; | ||
const headers = { | ||
@@ -68,7 +67,6 @@ 'p': {'alg': 'ES256'}, | ||
plaintext, | ||
signer | ||
) | ||
signer) | ||
.then((buf) => { | ||
console.log('Signed message: ' + buf.toString('hex')); | ||
}).catch((error)=>{ | ||
}).catch((error) => { | ||
console.log(error); | ||
@@ -87,3 +85,3 @@ }); | ||
}; | ||
const COSEMessage = Buffer.from('d28443a10126a10442313172496d706f7274616e74206d6573736167652158404c2b6b66dfedc4cfef0f221cf7ac7f95087a4c4245fef0063a0fd4014b670f642d31e26d38345bb4efcdc7ded3083ab4fe71b62a23f766d83785f044b20534f9','hex'); | ||
const COSEMessage = Buffer.from('d28443a10126a10442313172496d706f7274616e74206d6573736167652158404c2b6b66dfedc4cfef0f221cf7ac7f95087a4c4245fef0063a0fd4014b670f642d31e26d38345bb4efcdc7ded3083ab4fe71b62a23f766d83785f044b20534f9', 'hex'); | ||
@@ -95,3 +93,3 @@ cose.sign.verify( | ||
console.log('Verified message: ' + buf.toString('utf8')); | ||
}).catch((error)=>{ | ||
}).catch((error) => { | ||
console.log(error); | ||
@@ -107,3 +105,3 @@ }); | ||
'p': {'alg': 'A128GCM'}, | ||
'u': {'kid':'our-secret'} | ||
'u': {'kid': 'our-secret'} | ||
}; | ||
@@ -114,3 +112,3 @@ const recipients = [{ | ||
return cose.encrypt.create( | ||
cose.encrypt.create( | ||
headers, | ||
@@ -121,3 +119,3 @@ plaintext, | ||
console.log('Encrypted message: ' + buf.toString('hex')); | ||
}).catch((error)=>{ | ||
}).catch((error) => { | ||
console.log(error); | ||
@@ -128,3 +126,5 @@ }); | ||
```js | ||
const key = Buffer.from('231f4c4d4d3051fdc2ec0a3851d5b383', 'hex') | ||
const cose = require('../'); | ||
const key = Buffer.from('231f4c4d4d3051fdc2ec0a3851d5b383', 'hex'); | ||
const COSEMessage = Buffer.from('d8608443a10101a2044a6f75722d736563726574054c291a40271067ff57b1623c30581f23b663aaf9dfb91c5a39a175118ad7d72d416385b1b610e28b3b3fd824a397818340a040', 'hex'); | ||
@@ -137,3 +137,3 @@ | ||
console.log('Protected message: ' + buf.toString('utf8')); | ||
}).catch((error)=>{ | ||
}).catch((error) => { | ||
console.log(error); | ||
@@ -140,0 +140,0 @@ }); |
635496