All files / output cl_sec_sxml_writer.clas.mjs

34.32% Statements 23/67
100% Branches 2/2
7.69% Functions 1/13
34.32% Lines 23/67

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 671x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                   1x       1x     1x                                                             1x 1x 1x 1x 1x 1x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// cl_sec_sxml_writer.clas.abap
class cl_sec_sxml_writer {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'CL_SEC_SXML_WRITER';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {"CO_AES128_ALGORITHM": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "U", "is_constant": "X", "is_class": "X"},
  "CO_AES192_ALGORITHM": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "U", "is_constant": "X", "is_class": "X"},
  "CO_AES256_ALGORITHM": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "U", "is_constant": "X", "is_class": "X"}};
  static METHODS = {"CRYPT_AES_CTR": {"visibility": "U", "parameters": {"INPUT": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " "}, "KEY": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " "}, "IV": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " "}, "ALGORITHM": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "RESULT": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " "}}}};
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
    };
    this.co_aes128_algorithm = cl_sec_sxml_writer.co_aes128_algorithm;
    this.co_aes192_algorithm = cl_sec_sxml_writer.co_aes192_algorithm;
    this.co_aes256_algorithm = cl_sec_sxml_writer.co_aes256_algorithm;
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async crypt_aes_ctr(INPUT) {
    return cl_sec_sxml_writer.crypt_aes_ctr(INPUT);
  }
  static async crypt_aes_ctr(INPUT) {
    let input = INPUT?.input;
    if (input?.getQualifiedName === undefined || input.getQualifiedName() !== "XSTRING") { input = undefined; }
    if (input === undefined) { input = new abap.types.XString({qualifiedName: "XSTRING"}).set(INPUT.input); }
    let key = INPUT?.key;
    if (key?.getQualifiedName === undefined || key.getQualifiedName() !== "XSTRING") { key = undefined; }
    if (key === undefined) { key = new abap.types.XString({qualifiedName: "XSTRING"}).set(INPUT.key); }
    let iv = INPUT?.iv;
    if (iv?.getQualifiedName === undefined || iv.getQualifiedName() !== "XSTRING") { iv = undefined; }
    if (iv === undefined) { iv = new abap.types.XString({qualifiedName: "XSTRING"}).set(INPUT.iv); }
    let algorithm = new abap.types.String({qualifiedName: "STRING"});
    if (INPUT && INPUT.algorithm) {algorithm.set(INPUT.algorithm);}
    if (INPUT === undefined || INPUT.algorithm === undefined) {algorithm = this.co_aes128_algorithm;}
    let result = INPUT?.result || new abap.types.XString({qualifiedName: "XSTRING"});
    let lv_algo = new abap.types.String({qualifiedName: "STRING"});
    let unique1243 = algorithm;
    if (abap.compare.eq(unique1243, cl_sec_sxml_writer.co_aes128_algorithm)) {
      lv_algo.set(abap.CharacterFactory.get(11, 'aes-128-ctr'));
    } else if (abap.compare.eq(unique1243, cl_sec_sxml_writer.co_aes256_algorithm)) {
      lv_algo.set(abap.CharacterFactory.get(11, 'aes-256-ctr'));
    } else {
      abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo')));
    }
    const crypto = await import("crypto");
    const js_key = Buffer.from(key.get(), "hex");
    const js_iv = Buffer.from(iv.get(), "hex");
    const js_input = Buffer.from(input.get(), "hex");
    const cipher = crypto.createDecipheriv(lv_algo.get(), js_key, js_iv);
    const encrypted = cipher.update(js_input);
    result.set(encrypted.toString("hex").toUpperCase());
  }
}
abap.Classes['CL_SEC_SXML_WRITER'] = cl_sec_sxml_writer;
cl_sec_sxml_writer.co_aes128_algorithm = new abap.types.String({qualifiedName: "STRING"});
cl_sec_sxml_writer.co_aes128_algorithm.set('http://www.w3.org/2001/04/xmlenc#aes128-cbc');
cl_sec_sxml_writer.co_aes192_algorithm = new abap.types.String({qualifiedName: "STRING"});
cl_sec_sxml_writer.co_aes192_algorithm.set('http://www.w3.org/2001/04/xmlenc#aes192-cbc');
cl_sec_sxml_writer.co_aes256_algorithm = new abap.types.String({qualifiedName: "STRING"});
cl_sec_sxml_writer.co_aes256_algorithm.set('http://www.w3.org/2001/04/xmlenc#aes256-cbc');
export {cl_sec_sxml_writer};