2023-03-21 18:38:39 -03:00
|
|
|
/**
|
|
|
|
* @author n1474335 [n1474335@gmail.com]
|
|
|
|
* @copyright Crown Copyright 2023
|
|
|
|
* @license Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
import * as uuid from "uuid";
|
2025-04-03 14:54:49 +02:00
|
|
|
|
|
|
|
import Operation from "../Operation.mjs";
|
2023-03-21 18:38:39 -03:00
|
|
|
import OperationError from "../errors/OperationError.mjs";
|
|
|
|
|
|
|
|
/**
|
2025-04-03 14:54:49 +02:00
|
|
|
* Analyse UUID operation
|
2023-03-21 18:38:39 -03:00
|
|
|
*/
|
2025-04-03 14:54:49 +02:00
|
|
|
class AnalyseUUID extends Operation {
|
2023-03-21 18:38:39 -03:00
|
|
|
|
|
|
|
/**
|
2025-04-03 14:54:49 +02:00
|
|
|
* AnalyseUUID constructor
|
2023-03-21 18:38:39 -03:00
|
|
|
*/
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.name = "Analyse UUID";
|
|
|
|
this.module = "Crypto";
|
|
|
|
this.description = "Tries to determine information about a given UUID and suggests which version may have been used to generate it";
|
|
|
|
this.infoURL = "https://wikipedia.org/wiki/Universally_unique_identifier";
|
|
|
|
this.inputType = "string";
|
|
|
|
this.outputType = "string";
|
|
|
|
this.args = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} input
|
|
|
|
* @param {Object[]} args
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
run(input, args) {
|
|
|
|
try {
|
|
|
|
const uuidVersion = uuid.version(input);
|
|
|
|
return "UUID version: " + uuidVersion;
|
|
|
|
} catch (error) {
|
|
|
|
throw new OperationError("Invalid UUID");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2025-04-03 14:54:49 +02:00
|
|
|
export default AnalyseUUID;
|