UNPKG

idea-toolbox

Version:
36 lines (35 loc) 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Signature = void 0; const resource_model_1 = require("./resource.model"); /** * The signature, composed by a signatory and various dataURL formats. */ class Signature extends resource_model_1.Resource { load(x) { super.load(x); this.signatory = this.clean(x.signatory, String); this.timestamp = this.clean(x.timestamp, t => new Date(t).getTime(), Date.now()); this.pngURL = this.clean(x.pngURL, String); } validate() { const e = super.validate(); if (this.iE(this.signatory)) e.push('signatory'); if (this.iE(this.timestamp)) e.push('timestamp'); if (this.iE(this.pngURL)) e.push('pngURL'); return e; } /** * Check whether the signature object has the same content of another one. */ isSame(otherSignature, skipSignatory) { return (otherSignature && this.timestamp === otherSignature.timestamp && this.pngURL === otherSignature.pngURL && (skipSignatory || this.signatory === otherSignature.signatory)); } } exports.Signature = Signature;