UNPKG

myinvois-sdk

Version:

TypeScript SDK for interacting with the Malaysia e-invoicing system (MyInvois) API

161 lines (160 loc) 6.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SignatureInfo = void 0; const base_model_1 = require("./base-model"); const signed_properties_1 = require("./signed-properties"); /** * Represents the signature information for a document */ class SignatureInfo extends base_model_1.BaseModel { constructor() { super(...arguments); this._id = 'urn:oasis:names:specification:ubl:signature:1'; this._referencedSignatureID = 'urn:oasis:names:specification:ubl:signature:Invoice'; this._signatureValue = ''; this._documentHash = ''; this._signedPropertiesHash = ''; this._signedProperties = new signed_properties_1.SignedProperties(); this._certificateInfo = {}; } // Getter and Setter for id get id() { return this._id; } set id(value) { this._id = value; } // Getter and Setter for referencedSignatureID get referencedSignatureID() { return this._referencedSignatureID; } set referencedSignatureID(value) { this._referencedSignatureID = value; } // Getter and Setter for signatureValue get signatureValue() { return this._signatureValue; } set signatureValue(value) { this._signatureValue = value; } // Getter and Setter for documentHash get documentHash() { return this._documentHash; } set documentHash(value) { this._documentHash = value; } // Getter and Setter for signedPropertiesHash get signedPropertiesHash() { return this._signedPropertiesHash; } set signedPropertiesHash(value) { this._signedPropertiesHash = value; } // Getter and Setter for signedProperties get signedProperties() { return this._signedProperties; } set signedProperties(value) { this._signedProperties = value; } // Getter and Setter for certificateInfo get certificateInfo() { return this._certificateInfo; } set certificateInfo(value) { this._certificateInfo = value; } /** * Converts the signature information to a JSON representation */ toJSON() { return { "SignatureInformation": [ { "ID": [ { "_": this._id } ], "ReferencedSignatureID": [ { "_": this._referencedSignatureID } ], "Signature": [ { "Id": "signature", "Object": [ { "QualifyingProperties": [ { "Target": "signature", "SignedProperties": this._signedProperties.toJSON() } ] } ], "KeyInfo": [ { "X509Data": [ this._certificateInfo ] } ], "SignatureValue": [ { "_": this._signatureValue } ], "SignedInfo": [ { "SignatureMethod": [ { "_": "", "Algorithm": "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" } ], "Reference": [ { "Type": "http://uri.etsi.org/01903/v1.3.2#SignedProperties", "URI": `#${this._signedProperties.id}`, "DigestMethod": [ { "_": "", "Algorithm": "http://www.w3.org/2001/04/xmlenc#sha256" } ], "DigestValue": [ { "_": this._signedPropertiesHash } ] }, { "Type": "", "URI": "", "DigestMethod": [ { "_": "", "Algorithm": "http://www.w3.org/2001/04/xmlenc#sha256" } ], "DigestValue": [ { "_": this._documentHash } ] } ] } ] } ] } ] }; } } exports.SignatureInfo = SignatureInfo;