Added 'AMF Encode' and 'AMF Decode' operations

This commit is contained in:
n1474335 2022-12-09 11:39:22 +00:00
parent ba12ad8e7c
commit 760eff49b5
5 changed files with 153 additions and 0 deletions

45
package-lock.json generated
View File

@ -10,6 +10,7 @@
"hasInstallScript": true, "hasInstallScript": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@astronautlabs/amf": "^0.0.6",
"@babel/polyfill": "^7.12.1", "@babel/polyfill": "^7.12.1",
"@blu3r4y/lzma": "^2.3.3", "@blu3r4y/lzma": "^2.3.3",
"arrive": "^2.4.1", "arrive": "^2.4.1",
@ -75,6 +76,7 @@
"process": "^0.11.10", "process": "^0.11.10",
"protobufjs": "^6.11.3", "protobufjs": "^6.11.3",
"qr-image": "^3.2.0", "qr-image": "^3.2.0",
"reflect-metadata": "^0.1.13",
"scryptsy": "^2.1.0", "scryptsy": "^2.1.0",
"snackbarjs": "^1.1.0", "snackbarjs": "^1.1.0",
"sortablejs": "^1.15.0", "sortablejs": "^1.15.0",
@ -151,6 +153,25 @@
"node": ">=6.0.0" "node": ">=6.0.0"
} }
}, },
"node_modules/@astronautlabs/amf": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/@astronautlabs/amf/-/amf-0.0.6.tgz",
"integrity": "sha512-cJgbXW45TIDLQf2hiHqDoRfmeRy5u9Z4npr7sZfBThvbp5cbqDieTWaJTu91cUAj35/u87OHZijLTbMO18ZIow==",
"dependencies": {
"@astronautlabs/bitstream": "^4.0.0"
},
"engines": {
"node": "^14"
}
},
"node_modules/@astronautlabs/bitstream": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/@astronautlabs/bitstream/-/bitstream-4.1.3.tgz",
"integrity": "sha512-4X5cmrB5I5g/ifKXwoVc5JwAYgn372kS0AsTdVQYY+OzlSZ92ANEHj6W5MW5haYSQbbBZ9XK55rdy6NnXOyRgA==",
"peerDependencies": {
"reflect-metadata": "^0.1.13"
}
},
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {
"version": "7.16.7", "version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz",
@ -11914,6 +11935,11 @@
"node": ">= 0.10" "node": ">= 0.10"
} }
}, },
"node_modules/reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg=="
},
"node_modules/regenerate": { "node_modules/regenerate": {
"version": "1.4.2", "version": "1.4.2",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz",
@ -14346,6 +14372,20 @@
"@jridgewell/trace-mapping": "^0.3.0" "@jridgewell/trace-mapping": "^0.3.0"
} }
}, },
"@astronautlabs/amf": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/@astronautlabs/amf/-/amf-0.0.6.tgz",
"integrity": "sha512-cJgbXW45TIDLQf2hiHqDoRfmeRy5u9Z4npr7sZfBThvbp5cbqDieTWaJTu91cUAj35/u87OHZijLTbMO18ZIow==",
"requires": {
"@astronautlabs/bitstream": "^4.0.0"
}
},
"@astronautlabs/bitstream": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/@astronautlabs/bitstream/-/bitstream-4.1.3.tgz",
"integrity": "sha512-4X5cmrB5I5g/ifKXwoVc5JwAYgn372kS0AsTdVQYY+OzlSZ92ANEHj6W5MW5haYSQbbBZ9XK55rdy6NnXOyRgA==",
"requires": {}
},
"@babel/code-frame": { "@babel/code-frame": {
"version": "7.16.7", "version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz",
@ -23359,6 +23399,11 @@
"resolve": "^1.9.0" "resolve": "^1.9.0"
} }
}, },
"reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg=="
},
"regenerate": { "regenerate": {
"version": "1.4.2", "version": "1.4.2",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz",

View File

@ -86,6 +86,7 @@
"worker-loader": "^3.0.8" "worker-loader": "^3.0.8"
}, },
"dependencies": { "dependencies": {
"@astronautlabs/amf": "^0.0.6",
"@babel/polyfill": "^7.12.1", "@babel/polyfill": "^7.12.1",
"@blu3r4y/lzma": "^2.3.3", "@blu3r4y/lzma": "^2.3.3",
"arrive": "^2.4.1", "arrive": "^2.4.1",
@ -151,6 +152,7 @@
"process": "^0.11.10", "process": "^0.11.10",
"protobufjs": "^6.11.3", "protobufjs": "^6.11.3",
"qr-image": "^3.2.0", "qr-image": "^3.2.0",
"reflect-metadata": "^0.1.13",
"scryptsy": "^2.1.0", "scryptsy": "^2.1.0",
"snackbarjs": "^1.1.0", "snackbarjs": "^1.1.0",
"sortablejs": "^1.15.0", "sortablejs": "^1.15.0",

View File

@ -46,6 +46,8 @@
"From Quoted Printable", "From Quoted Printable",
"To Punycode", "To Punycode",
"From Punycode", "From Punycode",
"AMF Encode",
"AMF Decode",
"To Hex Content", "To Hex Content",
"From Hex Content", "From Hex Content",
"PEM to Hex", "PEM to Hex",

View File

@ -0,0 +1,52 @@
/**
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import Operation from "../Operation.mjs";
import "reflect-metadata"; // Required as a shim for the amf library
import { AMF0, AMF3 } from "@astronautlabs/amf";
/**
* AMF Decode operation
*/
class AMFDecode extends Operation {
/**
* AMFDecode constructor
*/
constructor() {
super();
this.name = "AMF Decode";
this.module = "Encodings";
this.description = "Action Message Format (AMF) is a binary format used to serialize object graphs such as ActionScript objects and XML, or send messages between an Adobe Flash client and a remote service, usually a Flash Media Server or third party alternatives.";
this.infoURL = "https://wikipedia.org/wiki/Action_Message_Format";
this.inputType = "ArrayBuffer";
this.outputType = "JSON";
this.args = [
{
name: "Format",
type: "option",
value: ["AMF0", "AMF3"],
defaultIndex: 1
}
];
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {JSON}
*/
run(input, args) {
const [format] = args;
const handler = format === "AMF0" ? AMF0 : AMF3;
const encoded = new Uint8Array(input);
return handler.Value.deserialize(encoded);
}
}
export default AMFDecode;

View File

@ -0,0 +1,52 @@
/**
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import Operation from "../Operation.mjs";
import "reflect-metadata"; // Required as a shim for the amf library
import { AMF0, AMF3 } from "@astronautlabs/amf";
/**
* AMF Encode operation
*/
class AMFEncode extends Operation {
/**
* AMFEncode constructor
*/
constructor() {
super();
this.name = "AMF Encode";
this.module = "Encodings";
this.description = "Action Message Format (AMF) is a binary format used to serialize object graphs such as ActionScript objects and XML, or send messages between an Adobe Flash client and a remote service, usually a Flash Media Server or third party alternatives.";
this.infoURL = "https://wikipedia.org/wiki/Action_Message_Format";
this.inputType = "JSON";
this.outputType = "ArrayBuffer";
this.args = [
{
name: "Format",
type: "option",
value: ["AMF0", "AMF3"],
defaultIndex: 1
}
];
}
/**
* @param {JSON} input
* @param {Object[]} args
* @returns {ArrayBuffer}
*/
run(input, args) {
const [format] = args;
const handler = format === "AMF0" ? AMF0 : AMF3;
const output = handler.Value.any(input).serialize();
return output.buffer;
}
}
export default AMFEncode;