UNPKG

myinvois-sdk

Version:

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

114 lines (113 loc) 4.16 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SignedProperties = void 0; const base_model_1 = require("./base-model"); const moment_timezone_1 = __importDefault(require("moment-timezone")); /** * Represents the signed properties for a document */ class SignedProperties extends base_model_1.BaseModel { constructor() { super(...arguments); this._id = 'id-xades-signed-props'; this._signingTime = new Date(); this._certificateHash = ''; this._issuerName = ''; this._serialNumber = ''; } // Getter and Setter for id get id() { return this._id; } set id(value) { this._id = value; } // Getter and Setter for signingTime get signingTime() { return this._signingTime; } set signingTime(value) { this._signingTime = value; } // Getter and Setter for certificateHash get certificateHash() { return this._certificateHash; } set certificateHash(value) { this._certificateHash = value; } // Getter and Setter for issuerName get issuerName() { return this._issuerName; } set issuerName(value) { this._issuerName = value; } // Getter and Setter for serialNumber get serialNumber() { return this._serialNumber; } set serialNumber(value) { this._serialNumber = value; } /** * Converts the signed properties to a JSON representation */ toJSON() { return [ { "Id": this._id, "SignedSignatureProperties": [ { "SigningTime": [ { "_": (0, moment_timezone_1.default)(this._signingTime).format("YYYY-MM-DDTHH:mm:ss") + "Z" } ], "SigningCertificate": [ { "Cert": [ { "CertDigest": [ { "DigestMethod": [ { "_": "", "Algorithm": "http://www.w3.org/2001/04/xmlenc#sha256" } ], "DigestValue": [ { "_": this._certificateHash } ] } ], "IssuerSerial": [ { "X509IssuerName": [ { "_": this._issuerName } ], "X509SerialNumber": [ { "_": this._serialNumber } ] } ] } ] } ] } ] } ]; } } exports.SignedProperties = SignedProperties;