Issue 991: Add CBOR Decode operation

This commit is contained in:
71819 2020-03-28 20:13:49 +00:00
parent ae70cb89ed
commit 209fc07eac
4 changed files with 190 additions and 1 deletions

View file

@ -0,0 +1,42 @@
/**
* @author Danh4 [dan.h4@ncsc.gov.uk]
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import Operation from "../Operation.mjs";
import Cbor from "cbor";
/**
* CBOR Decode operation
*/
class CBORDecode extends Operation {
/**
* CBORDecode constructor
*/
constructor() {
super();
this.name = "CBOR Decode";
this.module = "Default";
this.description = "Decode Concise Binary Object Representation (CBOR) data format (RFC7049) to JSON.";
this.infoURL = "https://cbor.io";
this.inputType = "ArrayBuffer";
this.outputType = "JSON";
this.args = [
];
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {JSON}
*/
run(input, args) {
return Cbor.decodeFirstSync(Buffer.from(input).toString("hex"));
}
}
export default CBORDecode;