mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-16 08:58:30 +01:00
821dd9c48c
and i'm too burnt out to figure out why
45 lines
996 B
JavaScript
45 lines
996 B
JavaScript
/**
|
|
* @author Matt C [matt@artemisbot.uk]
|
|
* @copyright Crown Copyright 2018
|
|
* @license Apache-2.0
|
|
*/
|
|
|
|
import Operation from "../Operation";
|
|
import OperationError from "../errors/OperationError";
|
|
import notepack from "notepack.io";
|
|
|
|
/**
|
|
* From MessagePack operation
|
|
*/
|
|
class FromMessagePack extends Operation {
|
|
|
|
/**
|
|
* FromMessagePack constructor
|
|
*/
|
|
constructor() {
|
|
super();
|
|
|
|
this.name = "From MessagePack";
|
|
this.module = "Code";
|
|
this.description = "Converts MessagePack encoded data to JSON";
|
|
this.inputType = "ArrayBuffer";
|
|
this.outputType = "JSON";
|
|
this.args = [];
|
|
}
|
|
|
|
/**
|
|
* @param {byteArray} input
|
|
* @param {Object[]} args
|
|
* @returns {JSON}
|
|
*/
|
|
run(input, args) {
|
|
try {
|
|
return notepack.decode(input);
|
|
} catch (err) {
|
|
throw new OperationError(`Could not decode MessagePack to JSON: ${err}`);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
export default FromMessagePack;
|