diff --git a/.gitignore b/.gitignore index 950ed49d9ed8088878a65f15bd45b6c7d6941e79..cd72380f25e64b8f60efc2499015bd127e039385 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules .idea yarn-error.log src/generated +dist diff --git a/dist/generated/qrcode_data_pb.d.ts b/dist/generated/qrcode_data_pb.d.ts deleted file mode 100644 index 7f27095a8764965aa7280f476097920049cf7258..0000000000000000000000000000000000000000 --- a/dist/generated/qrcode_data_pb.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export = $root; -declare var $root: {}; diff --git a/dist/generated/qrcode_data_pb.js b/dist/generated/qrcode_data_pb.js deleted file mode 100644 index d2aebc645751464f035f190b57cb97223649c4a9..0000000000000000000000000000000000000000 --- a/dist/generated/qrcode_data_pb.js +++ /dev/null @@ -1,1618 +0,0 @@ -/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ -"use strict"; -var $protobuf = require("protobufjs/minimal"); -// Common aliases -var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; -// Exported root namespace -var $root = $protobuf.roots.qr_code_data || ($protobuf.roots.qr_code_data = {}); -$root.vereign = (function () { - /** - * Namespace vereign. - * @exports vereign - * @namespace - */ - var vereign = {}; - vereign.protobuf = (function () { - /** - * Namespace protobuf. - * @memberof vereign - * @namespace - */ - var protobuf = {}; - protobuf.qrcode_data = (function () { - /** - * Namespace qrcode_data. - * @memberof vereign.protobuf - * @namespace - */ - var qrcode_data = {}; - qrcode_data.Participant_V1 = (function () { - /** - * Properties of a Participant_V1. - * @memberof vereign.protobuf.qrcode_data - * @interface IParticipant_V1 - * @property {string|null} [name] Participant_V1 name - * @property {string|null} [email] Participant_V1 email - */ - /** - * Constructs a new Participant_V1. - * @memberof vereign.protobuf.qrcode_data - * @classdesc Represents a Participant_V1. - * @implements IParticipant_V1 - * @constructor - * @param {vereign.protobuf.qrcode_data.IParticipant_V1=} [properties] Properties to set - */ - function Participant_V1(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - /** - * Participant_V1 name. - * @member {string} name - * @memberof vereign.protobuf.qrcode_data.Participant_V1 - * @instance - */ - Participant_V1.prototype.name = ""; - /** - * Participant_V1 email. - * @member {string} email - * @memberof vereign.protobuf.qrcode_data.Participant_V1 - * @instance - */ - Participant_V1.prototype.email = ""; - /** - * Creates a new Participant_V1 instance using the specified properties. - * @function create - * @memberof vereign.protobuf.qrcode_data.Participant_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IParticipant_V1=} [properties] Properties to set - * @returns {vereign.protobuf.qrcode_data.Participant_V1} Participant_V1 instance - */ - Participant_V1.create = function create(properties) { - return new Participant_V1(properties); - }; - /** - * Encodes the specified Participant_V1 message. Does not implicitly {@link vereign.protobuf.qrcode_data.Participant_V1.verify|verify} messages. - * @function encode - * @memberof vereign.protobuf.qrcode_data.Participant_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IParticipant_V1} message Participant_V1 message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Participant_V1.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.name != null && Object.hasOwnProperty.call(message, "name")) - writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name); - if (message.email != null && Object.hasOwnProperty.call(message, "email")) - writer.uint32(/* id 2, wireType 2 =*/ 18).string(message.email); - return writer; - }; - /** - * Encodes the specified Participant_V1 message, length delimited. Does not implicitly {@link vereign.protobuf.qrcode_data.Participant_V1.verify|verify} messages. - * @function encodeDelimited - * @memberof vereign.protobuf.qrcode_data.Participant_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IParticipant_V1} message Participant_V1 message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Participant_V1.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - /** - * Decodes a Participant_V1 message from the specified reader or buffer. - * @function decode - * @memberof vereign.protobuf.qrcode_data.Participant_V1 - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {vereign.protobuf.qrcode_data.Participant_V1} Participant_V1 - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Participant_V1.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.vereign.protobuf.qrcode_data.Participant_V1(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 2: - message.email = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - /** - * Decodes a Participant_V1 message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof vereign.protobuf.qrcode_data.Participant_V1 - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {vereign.protobuf.qrcode_data.Participant_V1} Participant_V1 - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Participant_V1.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - /** - * Verifies a Participant_V1 message. - * @function verify - * @memberof vereign.protobuf.qrcode_data.Participant_V1 - * @static - * @param {Object.<string,*>} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Participant_V1.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.name != null && message.hasOwnProperty("name")) - if (!$util.isString(message.name)) - return "name: string expected"; - if (message.email != null && message.hasOwnProperty("email")) - if (!$util.isString(message.email)) - return "email: string expected"; - return null; - }; - /** - * Creates a Participant_V1 message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof vereign.protobuf.qrcode_data.Participant_V1 - * @static - * @param {Object.<string,*>} object Plain object - * @returns {vereign.protobuf.qrcode_data.Participant_V1} Participant_V1 - */ - Participant_V1.fromObject = function fromObject(object) { - if (object instanceof $root.vereign.protobuf.qrcode_data.Participant_V1) - return object; - var message = new $root.vereign.protobuf.qrcode_data.Participant_V1(); - if (object.name != null) - message.name = String(object.name); - if (object.email != null) - message.email = String(object.email); - return message; - }; - /** - * Creates a plain object from a Participant_V1 message. Also converts values to other types if specified. - * @function toObject - * @memberof vereign.protobuf.qrcode_data.Participant_V1 - * @static - * @param {vereign.protobuf.qrcode_data.Participant_V1} message Participant_V1 - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.<string,*>} Plain object - */ - Participant_V1.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.name = ""; - object.email = ""; - } - if (message.name != null && message.hasOwnProperty("name")) - object.name = message.name; - if (message.email != null && message.hasOwnProperty("email")) - object.email = message.email; - return object; - }; - /** - * Converts this Participant_V1 to JSON. - * @function toJSON - * @memberof vereign.protobuf.qrcode_data.Participant_V1 - * @instance - * @returns {Object.<string,*>} JSON object - */ - Participant_V1.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - return Participant_V1; - })(); - qrcode_data.Attachment_V1 = (function () { - /** - * Properties of an Attachment_V1. - * @memberof vereign.protobuf.qrcode_data - * @interface IAttachment_V1 - * @property {string|null} [name] Attachment_V1 name - * @property {string|null} [url] Attachment_V1 url - * @property {number|null} [size] Attachment_V1 size - * @property {string|null} [hashAlg] Attachment_V1 hashAlg - * @property {Uint8Array|null} [hash] Attachment_V1 hash - * @property {Uint8Array|null} [signature] Attachment_V1 signature - */ - /** - * Constructs a new Attachment_V1. - * @memberof vereign.protobuf.qrcode_data - * @classdesc Represents an Attachment_V1. - * @implements IAttachment_V1 - * @constructor - * @param {vereign.protobuf.qrcode_data.IAttachment_V1=} [properties] Properties to set - */ - function Attachment_V1(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - /** - * Attachment_V1 name. - * @member {string} name - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @instance - */ - Attachment_V1.prototype.name = ""; - /** - * Attachment_V1 url. - * @member {string} url - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @instance - */ - Attachment_V1.prototype.url = ""; - /** - * Attachment_V1 size. - * @member {number} size - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @instance - */ - Attachment_V1.prototype.size = 0; - /** - * Attachment_V1 hashAlg. - * @member {string} hashAlg - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @instance - */ - Attachment_V1.prototype.hashAlg = ""; - /** - * Attachment_V1 hash. - * @member {Uint8Array} hash - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @instance - */ - Attachment_V1.prototype.hash = $util.newBuffer([]); - /** - * Attachment_V1 signature. - * @member {Uint8Array} signature - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @instance - */ - Attachment_V1.prototype.signature = $util.newBuffer([]); - /** - * Creates a new Attachment_V1 instance using the specified properties. - * @function create - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IAttachment_V1=} [properties] Properties to set - * @returns {vereign.protobuf.qrcode_data.Attachment_V1} Attachment_V1 instance - */ - Attachment_V1.create = function create(properties) { - return new Attachment_V1(properties); - }; - /** - * Encodes the specified Attachment_V1 message. Does not implicitly {@link vereign.protobuf.qrcode_data.Attachment_V1.verify|verify} messages. - * @function encode - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IAttachment_V1} message Attachment_V1 message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Attachment_V1.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.name != null && Object.hasOwnProperty.call(message, "name")) - writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name); - if (message.url != null && Object.hasOwnProperty.call(message, "url")) - writer.uint32(/* id 2, wireType 2 =*/ 18).string(message.url); - if (message.size != null && Object.hasOwnProperty.call(message, "size")) - writer.uint32(/* id 3, wireType 0 =*/ 24).int32(message.size); - if (message.hash != null && Object.hasOwnProperty.call(message, "hash")) - writer.uint32(/* id 4, wireType 2 =*/ 34).bytes(message.hash); - if (message.hashAlg != null && Object.hasOwnProperty.call(message, "hashAlg")) - writer.uint32(/* id 5, wireType 2 =*/ 42).string(message.hashAlg); - if (message.signature != null && Object.hasOwnProperty.call(message, "signature")) - writer.uint32(/* id 6, wireType 2 =*/ 50).bytes(message.signature); - return writer; - }; - /** - * Encodes the specified Attachment_V1 message, length delimited. Does not implicitly {@link vereign.protobuf.qrcode_data.Attachment_V1.verify|verify} messages. - * @function encodeDelimited - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IAttachment_V1} message Attachment_V1 message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Attachment_V1.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - /** - * Decodes an Attachment_V1 message from the specified reader or buffer. - * @function decode - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {vereign.protobuf.qrcode_data.Attachment_V1} Attachment_V1 - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Attachment_V1.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.vereign.protobuf.qrcode_data.Attachment_V1(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.name = reader.string(); - break; - case 2: - message.url = reader.string(); - break; - case 3: - message.size = reader.int32(); - break; - case 5: - message.hashAlg = reader.string(); - break; - case 4: - message.hash = reader.bytes(); - break; - case 6: - message.signature = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - /** - * Decodes an Attachment_V1 message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {vereign.protobuf.qrcode_data.Attachment_V1} Attachment_V1 - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Attachment_V1.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - /** - * Verifies an Attachment_V1 message. - * @function verify - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @static - * @param {Object.<string,*>} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Attachment_V1.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.name != null && message.hasOwnProperty("name")) - if (!$util.isString(message.name)) - return "name: string expected"; - if (message.url != null && message.hasOwnProperty("url")) - if (!$util.isString(message.url)) - return "url: string expected"; - if (message.size != null && message.hasOwnProperty("size")) - if (!$util.isInteger(message.size)) - return "size: integer expected"; - if (message.hashAlg != null && message.hasOwnProperty("hashAlg")) - if (!$util.isString(message.hashAlg)) - return "hashAlg: string expected"; - if (message.hash != null && message.hasOwnProperty("hash")) - if (!(message.hash && typeof message.hash.length === "number" || $util.isString(message.hash))) - return "hash: buffer expected"; - if (message.signature != null && message.hasOwnProperty("signature")) - if (!(message.signature && typeof message.signature.length === "number" || $util.isString(message.signature))) - return "signature: buffer expected"; - return null; - }; - /** - * Creates an Attachment_V1 message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @static - * @param {Object.<string,*>} object Plain object - * @returns {vereign.protobuf.qrcode_data.Attachment_V1} Attachment_V1 - */ - Attachment_V1.fromObject = function fromObject(object) { - if (object instanceof $root.vereign.protobuf.qrcode_data.Attachment_V1) - return object; - var message = new $root.vereign.protobuf.qrcode_data.Attachment_V1(); - if (object.name != null) - message.name = String(object.name); - if (object.url != null) - message.url = String(object.url); - if (object.size != null) - message.size = object.size | 0; - if (object.hashAlg != null) - message.hashAlg = String(object.hashAlg); - if (object.hash != null) - if (typeof object.hash === "string") - $util.base64.decode(object.hash, message.hash = $util.newBuffer($util.base64.length(object.hash)), 0); - else if (object.hash.length) - message.hash = object.hash; - if (object.signature != null) - if (typeof object.signature === "string") - $util.base64.decode(object.signature, message.signature = $util.newBuffer($util.base64.length(object.signature)), 0); - else if (object.signature.length) - message.signature = object.signature; - return message; - }; - /** - * Creates a plain object from an Attachment_V1 message. Also converts values to other types if specified. - * @function toObject - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @static - * @param {vereign.protobuf.qrcode_data.Attachment_V1} message Attachment_V1 - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.<string,*>} Plain object - */ - Attachment_V1.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.name = ""; - object.url = ""; - object.size = 0; - if (options.bytes === String) - object.hash = ""; - else { - object.hash = []; - if (options.bytes !== Array) - object.hash = $util.newBuffer(object.hash); - } - object.hashAlg = ""; - if (options.bytes === String) - object.signature = ""; - else { - object.signature = []; - if (options.bytes !== Array) - object.signature = $util.newBuffer(object.signature); - } - } - if (message.name != null && message.hasOwnProperty("name")) - object.name = message.name; - if (message.url != null && message.hasOwnProperty("url")) - object.url = message.url; - if (message.size != null && message.hasOwnProperty("size")) - object.size = message.size; - if (message.hash != null && message.hasOwnProperty("hash")) - object.hash = options.bytes === String ? $util.base64.encode(message.hash, 0, message.hash.length) : options.bytes === Array ? Array.prototype.slice.call(message.hash) : message.hash; - if (message.hashAlg != null && message.hasOwnProperty("hashAlg")) - object.hashAlg = message.hashAlg; - if (message.signature != null && message.hasOwnProperty("signature")) - object.signature = options.bytes === String ? $util.base64.encode(message.signature, 0, message.signature.length) : options.bytes === Array ? Array.prototype.slice.call(message.signature) : message.signature; - return object; - }; - /** - * Converts this Attachment_V1 to JSON. - * @function toJSON - * @memberof vereign.protobuf.qrcode_data.Attachment_V1 - * @instance - * @returns {Object.<string,*>} JSON object - */ - Attachment_V1.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - return Attachment_V1; - })(); - qrcode_data.Recipients_V1 = (function () { - /** - * Properties of a Recipients_V1. - * @memberof vereign.protobuf.qrcode_data - * @interface IRecipients_V1 - * @property {Array.<vereign.protobuf.qrcode_data.IParticipant_V1>|null} [to] Recipients_V1 to - * @property {Array.<vereign.protobuf.qrcode_data.IParticipant_V1>|null} [cc] Recipients_V1 cc - */ - /** - * Constructs a new Recipients_V1. - * @memberof vereign.protobuf.qrcode_data - * @classdesc Represents a Recipients_V1. - * @implements IRecipients_V1 - * @constructor - * @param {vereign.protobuf.qrcode_data.IRecipients_V1=} [properties] Properties to set - */ - function Recipients_V1(properties) { - this.to = []; - this.cc = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - /** - * Recipients_V1 to. - * @member {Array.<vereign.protobuf.qrcode_data.IParticipant_V1>} to - * @memberof vereign.protobuf.qrcode_data.Recipients_V1 - * @instance - */ - Recipients_V1.prototype.to = $util.emptyArray; - /** - * Recipients_V1 cc. - * @member {Array.<vereign.protobuf.qrcode_data.IParticipant_V1>} cc - * @memberof vereign.protobuf.qrcode_data.Recipients_V1 - * @instance - */ - Recipients_V1.prototype.cc = $util.emptyArray; - /** - * Creates a new Recipients_V1 instance using the specified properties. - * @function create - * @memberof vereign.protobuf.qrcode_data.Recipients_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IRecipients_V1=} [properties] Properties to set - * @returns {vereign.protobuf.qrcode_data.Recipients_V1} Recipients_V1 instance - */ - Recipients_V1.create = function create(properties) { - return new Recipients_V1(properties); - }; - /** - * Encodes the specified Recipients_V1 message. Does not implicitly {@link vereign.protobuf.qrcode_data.Recipients_V1.verify|verify} messages. - * @function encode - * @memberof vereign.protobuf.qrcode_data.Recipients_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IRecipients_V1} message Recipients_V1 message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Recipients_V1.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.to != null && message.to.length) - for (var i = 0; i < message.to.length; ++i) - $root.vereign.protobuf.qrcode_data.Participant_V1.encode(message.to[i], writer.uint32(/* id 1, wireType 2 =*/ 10).fork()).ldelim(); - if (message.cc != null && message.cc.length) - for (var i = 0; i < message.cc.length; ++i) - $root.vereign.protobuf.qrcode_data.Participant_V1.encode(message.cc[i], writer.uint32(/* id 2, wireType 2 =*/ 18).fork()).ldelim(); - return writer; - }; - /** - * Encodes the specified Recipients_V1 message, length delimited. Does not implicitly {@link vereign.protobuf.qrcode_data.Recipients_V1.verify|verify} messages. - * @function encodeDelimited - * @memberof vereign.protobuf.qrcode_data.Recipients_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IRecipients_V1} message Recipients_V1 message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Recipients_V1.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - /** - * Decodes a Recipients_V1 message from the specified reader or buffer. - * @function decode - * @memberof vereign.protobuf.qrcode_data.Recipients_V1 - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {vereign.protobuf.qrcode_data.Recipients_V1} Recipients_V1 - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Recipients_V1.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.vereign.protobuf.qrcode_data.Recipients_V1(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.to && message.to.length)) - message.to = []; - message.to.push($root.vereign.protobuf.qrcode_data.Participant_V1.decode(reader, reader.uint32())); - break; - case 2: - if (!(message.cc && message.cc.length)) - message.cc = []; - message.cc.push($root.vereign.protobuf.qrcode_data.Participant_V1.decode(reader, reader.uint32())); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - /** - * Decodes a Recipients_V1 message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof vereign.protobuf.qrcode_data.Recipients_V1 - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {vereign.protobuf.qrcode_data.Recipients_V1} Recipients_V1 - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Recipients_V1.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - /** - * Verifies a Recipients_V1 message. - * @function verify - * @memberof vereign.protobuf.qrcode_data.Recipients_V1 - * @static - * @param {Object.<string,*>} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Recipients_V1.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.to != null && message.hasOwnProperty("to")) { - if (!Array.isArray(message.to)) - return "to: array expected"; - for (var i = 0; i < message.to.length; ++i) { - var error = $root.vereign.protobuf.qrcode_data.Participant_V1.verify(message.to[i]); - if (error) - return "to." + error; - } - } - if (message.cc != null && message.hasOwnProperty("cc")) { - if (!Array.isArray(message.cc)) - return "cc: array expected"; - for (var i = 0; i < message.cc.length; ++i) { - var error = $root.vereign.protobuf.qrcode_data.Participant_V1.verify(message.cc[i]); - if (error) - return "cc." + error; - } - } - return null; - }; - /** - * Creates a Recipients_V1 message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof vereign.protobuf.qrcode_data.Recipients_V1 - * @static - * @param {Object.<string,*>} object Plain object - * @returns {vereign.protobuf.qrcode_data.Recipients_V1} Recipients_V1 - */ - Recipients_V1.fromObject = function fromObject(object) { - if (object instanceof $root.vereign.protobuf.qrcode_data.Recipients_V1) - return object; - var message = new $root.vereign.protobuf.qrcode_data.Recipients_V1(); - if (object.to) { - if (!Array.isArray(object.to)) - throw TypeError(".vereign.protobuf.qrcode_data.Recipients_V1.to: array expected"); - message.to = []; - for (var i = 0; i < object.to.length; ++i) { - if (typeof object.to[i] !== "object") - throw TypeError(".vereign.protobuf.qrcode_data.Recipients_V1.to: object expected"); - message.to[i] = $root.vereign.protobuf.qrcode_data.Participant_V1.fromObject(object.to[i]); - } - } - if (object.cc) { - if (!Array.isArray(object.cc)) - throw TypeError(".vereign.protobuf.qrcode_data.Recipients_V1.cc: array expected"); - message.cc = []; - for (var i = 0; i < object.cc.length; ++i) { - if (typeof object.cc[i] !== "object") - throw TypeError(".vereign.protobuf.qrcode_data.Recipients_V1.cc: object expected"); - message.cc[i] = $root.vereign.protobuf.qrcode_data.Participant_V1.fromObject(object.cc[i]); - } - } - return message; - }; - /** - * Creates a plain object from a Recipients_V1 message. Also converts values to other types if specified. - * @function toObject - * @memberof vereign.protobuf.qrcode_data.Recipients_V1 - * @static - * @param {vereign.protobuf.qrcode_data.Recipients_V1} message Recipients_V1 - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.<string,*>} Plain object - */ - Recipients_V1.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) { - object.to = []; - object.cc = []; - } - if (message.to && message.to.length) { - object.to = []; - for (var j = 0; j < message.to.length; ++j) - object.to[j] = $root.vereign.protobuf.qrcode_data.Participant_V1.toObject(message.to[j], options); - } - if (message.cc && message.cc.length) { - object.cc = []; - for (var j = 0; j < message.cc.length; ++j) - object.cc[j] = $root.vereign.protobuf.qrcode_data.Participant_V1.toObject(message.cc[j], options); - } - return object; - }; - /** - * Converts this Recipients_V1 to JSON. - * @function toJSON - * @memberof vereign.protobuf.qrcode_data.Recipients_V1 - * @instance - * @returns {Object.<string,*>} JSON object - */ - Recipients_V1.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - return Recipients_V1; - })(); - qrcode_data.EmailData_V1 = (function () { - /** - * Properties of an EmailData_V1. - * @memberof vereign.protobuf.qrcode_data - * @interface IEmailData_V1 - * @property {string|null} [statusId] EmailData_V1 statusId - * @property {vereign.protobuf.qrcode_data.IParticipant_V1|null} [sender] EmailData_V1 sender - * @property {string|null} [subject] EmailData_V1 subject - * @property {string|null} [date] EmailData_V1 date - * @property {vereign.protobuf.qrcode_data.IRecipients_V1|null} [recipients] EmailData_V1 recipients - * @property {Array.<vereign.protobuf.qrcode_data.IAttachment_V1>|null} [attachments] EmailData_V1 attachments - * @property {string|null} [senderPublicKeyUuid] EmailData_V1 senderPublicKeyUuid - * @property {string|null} [htmlPartRabinFingerprint] EmailData_V1 htmlPartRabinFingerprint - * @property {number|null} [htmlPartSize] EmailData_V1 htmlPartSize - * @property {string|null} [plainPartRabinFingerprint] EmailData_V1 plainPartRabinFingerprint - * @property {number|null} [plainPartSize] EmailData_V1 plainPartSize - */ - /** - * Constructs a new EmailData_V1. - * @memberof vereign.protobuf.qrcode_data - * @classdesc Represents an EmailData_V1. - * @implements IEmailData_V1 - * @constructor - * @param {vereign.protobuf.qrcode_data.IEmailData_V1=} [properties] Properties to set - */ - function EmailData_V1(properties) { - this.attachments = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - /** - * EmailData_V1 statusId. - * @member {string} statusId - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @instance - */ - EmailData_V1.prototype.statusId = ""; - /** - * EmailData_V1 sender. - * @member {vereign.protobuf.qrcode_data.IParticipant_V1|null|undefined} sender - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @instance - */ - EmailData_V1.prototype.sender = null; - /** - * EmailData_V1 subject. - * @member {string} subject - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @instance - */ - EmailData_V1.prototype.subject = ""; - /** - * EmailData_V1 date. - * @member {string} date - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @instance - */ - EmailData_V1.prototype.date = ""; - /** - * EmailData_V1 recipients. - * @member {vereign.protobuf.qrcode_data.IRecipients_V1|null|undefined} recipients - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @instance - */ - EmailData_V1.prototype.recipients = null; - /** - * EmailData_V1 attachments. - * @member {Array.<vereign.protobuf.qrcode_data.IAttachment_V1>} attachments - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @instance - */ - EmailData_V1.prototype.attachments = $util.emptyArray; - /** - * EmailData_V1 senderPublicKeyUuid. - * @member {string} senderPublicKeyUuid - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @instance - */ - EmailData_V1.prototype.senderPublicKeyUuid = ""; - /** - * EmailData_V1 htmlPartRabinFingerprint. - * @member {string} htmlPartRabinFingerprint - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @instance - */ - EmailData_V1.prototype.htmlPartRabinFingerprint = ""; - /** - * EmailData_V1 htmlPartSize. - * @member {number} htmlPartSize - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @instance - */ - EmailData_V1.prototype.htmlPartSize = 0; - /** - * EmailData_V1 plainPartRabinFingerprint. - * @member {string} plainPartRabinFingerprint - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @instance - */ - EmailData_V1.prototype.plainPartRabinFingerprint = ""; - /** - * EmailData_V1 plainPartSize. - * @member {number} plainPartSize - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @instance - */ - EmailData_V1.prototype.plainPartSize = 0; - /** - * Creates a new EmailData_V1 instance using the specified properties. - * @function create - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IEmailData_V1=} [properties] Properties to set - * @returns {vereign.protobuf.qrcode_data.EmailData_V1} EmailData_V1 instance - */ - EmailData_V1.create = function create(properties) { - return new EmailData_V1(properties); - }; - /** - * Encodes the specified EmailData_V1 message. Does not implicitly {@link vereign.protobuf.qrcode_data.EmailData_V1.verify|verify} messages. - * @function encode - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IEmailData_V1} message EmailData_V1 message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EmailData_V1.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.statusId != null && Object.hasOwnProperty.call(message, "statusId")) - writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.statusId); - if (message.sender != null && Object.hasOwnProperty.call(message, "sender")) - $root.vereign.protobuf.qrcode_data.Participant_V1.encode(message.sender, writer.uint32(/* id 2, wireType 2 =*/ 18).fork()).ldelim(); - if (message.subject != null && Object.hasOwnProperty.call(message, "subject")) - writer.uint32(/* id 3, wireType 2 =*/ 26).string(message.subject); - if (message.date != null && Object.hasOwnProperty.call(message, "date")) - writer.uint32(/* id 4, wireType 2 =*/ 34).string(message.date); - if (message.recipients != null && Object.hasOwnProperty.call(message, "recipients")) - $root.vereign.protobuf.qrcode_data.Recipients_V1.encode(message.recipients, writer.uint32(/* id 5, wireType 2 =*/ 42).fork()).ldelim(); - if (message.attachments != null && message.attachments.length) - for (var i = 0; i < message.attachments.length; ++i) - $root.vereign.protobuf.qrcode_data.Attachment_V1.encode(message.attachments[i], writer.uint32(/* id 6, wireType 2 =*/ 50).fork()).ldelim(); - if (message.senderPublicKeyUuid != null && Object.hasOwnProperty.call(message, "senderPublicKeyUuid")) - writer.uint32(/* id 7, wireType 2 =*/ 58).string(message.senderPublicKeyUuid); - if (message.htmlPartRabinFingerprint != null && Object.hasOwnProperty.call(message, "htmlPartRabinFingerprint")) - writer.uint32(/* id 8, wireType 2 =*/ 66).string(message.htmlPartRabinFingerprint); - if (message.htmlPartSize != null && Object.hasOwnProperty.call(message, "htmlPartSize")) - writer.uint32(/* id 9, wireType 0 =*/ 72).int32(message.htmlPartSize); - if (message.plainPartRabinFingerprint != null && Object.hasOwnProperty.call(message, "plainPartRabinFingerprint")) - writer.uint32(/* id 10, wireType 2 =*/ 82).string(message.plainPartRabinFingerprint); - if (message.plainPartSize != null && Object.hasOwnProperty.call(message, "plainPartSize")) - writer.uint32(/* id 11, wireType 0 =*/ 88).int32(message.plainPartSize); - return writer; - }; - /** - * Encodes the specified EmailData_V1 message, length delimited. Does not implicitly {@link vereign.protobuf.qrcode_data.EmailData_V1.verify|verify} messages. - * @function encodeDelimited - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IEmailData_V1} message EmailData_V1 message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EmailData_V1.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - /** - * Decodes an EmailData_V1 message from the specified reader or buffer. - * @function decode - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {vereign.protobuf.qrcode_data.EmailData_V1} EmailData_V1 - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EmailData_V1.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.vereign.protobuf.qrcode_data.EmailData_V1(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.statusId = reader.string(); - break; - case 2: - message.sender = $root.vereign.protobuf.qrcode_data.Participant_V1.decode(reader, reader.uint32()); - break; - case 3: - message.subject = reader.string(); - break; - case 4: - message.date = reader.string(); - break; - case 5: - message.recipients = $root.vereign.protobuf.qrcode_data.Recipients_V1.decode(reader, reader.uint32()); - break; - case 6: - if (!(message.attachments && message.attachments.length)) - message.attachments = []; - message.attachments.push($root.vereign.protobuf.qrcode_data.Attachment_V1.decode(reader, reader.uint32())); - break; - case 7: - message.senderPublicKeyUuid = reader.string(); - break; - case 8: - message.htmlPartRabinFingerprint = reader.string(); - break; - case 9: - message.htmlPartSize = reader.int32(); - break; - case 10: - message.plainPartRabinFingerprint = reader.string(); - break; - case 11: - message.plainPartSize = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - /** - * Decodes an EmailData_V1 message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {vereign.protobuf.qrcode_data.EmailData_V1} EmailData_V1 - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EmailData_V1.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - /** - * Verifies an EmailData_V1 message. - * @function verify - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @static - * @param {Object.<string,*>} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EmailData_V1.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.statusId != null && message.hasOwnProperty("statusId")) - if (!$util.isString(message.statusId)) - return "statusId: string expected"; - if (message.sender != null && message.hasOwnProperty("sender")) { - var error = $root.vereign.protobuf.qrcode_data.Participant_V1.verify(message.sender); - if (error) - return "sender." + error; - } - if (message.subject != null && message.hasOwnProperty("subject")) - if (!$util.isString(message.subject)) - return "subject: string expected"; - if (message.date != null && message.hasOwnProperty("date")) - if (!$util.isString(message.date)) - return "date: string expected"; - if (message.recipients != null && message.hasOwnProperty("recipients")) { - var error = $root.vereign.protobuf.qrcode_data.Recipients_V1.verify(message.recipients); - if (error) - return "recipients." + error; - } - if (message.attachments != null && message.hasOwnProperty("attachments")) { - if (!Array.isArray(message.attachments)) - return "attachments: array expected"; - for (var i = 0; i < message.attachments.length; ++i) { - var error = $root.vereign.protobuf.qrcode_data.Attachment_V1.verify(message.attachments[i]); - if (error) - return "attachments." + error; - } - } - if (message.senderPublicKeyUuid != null && message.hasOwnProperty("senderPublicKeyUuid")) - if (!$util.isString(message.senderPublicKeyUuid)) - return "senderPublicKeyUuid: string expected"; - if (message.htmlPartRabinFingerprint != null && message.hasOwnProperty("htmlPartRabinFingerprint")) - if (!$util.isString(message.htmlPartRabinFingerprint)) - return "htmlPartRabinFingerprint: string expected"; - if (message.htmlPartSize != null && message.hasOwnProperty("htmlPartSize")) - if (!$util.isInteger(message.htmlPartSize)) - return "htmlPartSize: integer expected"; - if (message.plainPartRabinFingerprint != null && message.hasOwnProperty("plainPartRabinFingerprint")) - if (!$util.isString(message.plainPartRabinFingerprint)) - return "plainPartRabinFingerprint: string expected"; - if (message.plainPartSize != null && message.hasOwnProperty("plainPartSize")) - if (!$util.isInteger(message.plainPartSize)) - return "plainPartSize: integer expected"; - return null; - }; - /** - * Creates an EmailData_V1 message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @static - * @param {Object.<string,*>} object Plain object - * @returns {vereign.protobuf.qrcode_data.EmailData_V1} EmailData_V1 - */ - EmailData_V1.fromObject = function fromObject(object) { - if (object instanceof $root.vereign.protobuf.qrcode_data.EmailData_V1) - return object; - var message = new $root.vereign.protobuf.qrcode_data.EmailData_V1(); - if (object.statusId != null) - message.statusId = String(object.statusId); - if (object.sender != null) { - if (typeof object.sender !== "object") - throw TypeError(".vereign.protobuf.qrcode_data.EmailData_V1.sender: object expected"); - message.sender = $root.vereign.protobuf.qrcode_data.Participant_V1.fromObject(object.sender); - } - if (object.subject != null) - message.subject = String(object.subject); - if (object.date != null) - message.date = String(object.date); - if (object.recipients != null) { - if (typeof object.recipients !== "object") - throw TypeError(".vereign.protobuf.qrcode_data.EmailData_V1.recipients: object expected"); - message.recipients = $root.vereign.protobuf.qrcode_data.Recipients_V1.fromObject(object.recipients); - } - if (object.attachments) { - if (!Array.isArray(object.attachments)) - throw TypeError(".vereign.protobuf.qrcode_data.EmailData_V1.attachments: array expected"); - message.attachments = []; - for (var i = 0; i < object.attachments.length; ++i) { - if (typeof object.attachments[i] !== "object") - throw TypeError(".vereign.protobuf.qrcode_data.EmailData_V1.attachments: object expected"); - message.attachments[i] = $root.vereign.protobuf.qrcode_data.Attachment_V1.fromObject(object.attachments[i]); - } - } - if (object.senderPublicKeyUuid != null) - message.senderPublicKeyUuid = String(object.senderPublicKeyUuid); - if (object.htmlPartRabinFingerprint != null) - message.htmlPartRabinFingerprint = String(object.htmlPartRabinFingerprint); - if (object.htmlPartSize != null) - message.htmlPartSize = object.htmlPartSize | 0; - if (object.plainPartRabinFingerprint != null) - message.plainPartRabinFingerprint = String(object.plainPartRabinFingerprint); - if (object.plainPartSize != null) - message.plainPartSize = object.plainPartSize | 0; - return message; - }; - /** - * Creates a plain object from an EmailData_V1 message. Also converts values to other types if specified. - * @function toObject - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @static - * @param {vereign.protobuf.qrcode_data.EmailData_V1} message EmailData_V1 - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.<string,*>} Plain object - */ - EmailData_V1.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.attachments = []; - if (options.defaults) { - object.statusId = ""; - object.sender = null; - object.subject = ""; - object.date = ""; - object.recipients = null; - object.senderPublicKeyUuid = ""; - object.htmlPartRabinFingerprint = ""; - object.htmlPartSize = 0; - object.plainPartRabinFingerprint = ""; - object.plainPartSize = 0; - } - if (message.statusId != null && message.hasOwnProperty("statusId")) - object.statusId = message.statusId; - if (message.sender != null && message.hasOwnProperty("sender")) - object.sender = $root.vereign.protobuf.qrcode_data.Participant_V1.toObject(message.sender, options); - if (message.subject != null && message.hasOwnProperty("subject")) - object.subject = message.subject; - if (message.date != null && message.hasOwnProperty("date")) - object.date = message.date; - if (message.recipients != null && message.hasOwnProperty("recipients")) - object.recipients = $root.vereign.protobuf.qrcode_data.Recipients_V1.toObject(message.recipients, options); - if (message.attachments && message.attachments.length) { - object.attachments = []; - for (var j = 0; j < message.attachments.length; ++j) - object.attachments[j] = $root.vereign.protobuf.qrcode_data.Attachment_V1.toObject(message.attachments[j], options); - } - if (message.senderPublicKeyUuid != null && message.hasOwnProperty("senderPublicKeyUuid")) - object.senderPublicKeyUuid = message.senderPublicKeyUuid; - if (message.htmlPartRabinFingerprint != null && message.hasOwnProperty("htmlPartRabinFingerprint")) - object.htmlPartRabinFingerprint = message.htmlPartRabinFingerprint; - if (message.htmlPartSize != null && message.hasOwnProperty("htmlPartSize")) - object.htmlPartSize = message.htmlPartSize; - if (message.plainPartRabinFingerprint != null && message.hasOwnProperty("plainPartRabinFingerprint")) - object.plainPartRabinFingerprint = message.plainPartRabinFingerprint; - if (message.plainPartSize != null && message.hasOwnProperty("plainPartSize")) - object.plainPartSize = message.plainPartSize; - return object; - }; - /** - * Converts this EmailData_V1 to JSON. - * @function toJSON - * @memberof vereign.protobuf.qrcode_data.EmailData_V1 - * @instance - * @returns {Object.<string,*>} JSON object - */ - EmailData_V1.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - return EmailData_V1; - })(); - qrcode_data.KeyData_V1 = (function () { - /** - * Properties of a KeyData_V1. - * @memberof vereign.protobuf.qrcode_data - * @interface IKeyData_V1 - * @property {Uint8Array|null} [key] KeyData_V1 key - * @property {Uint8Array|null} [data] KeyData_V1 data - */ - /** - * Constructs a new KeyData_V1. - * @memberof vereign.protobuf.qrcode_data - * @classdesc Represents a KeyData_V1. - * @implements IKeyData_V1 - * @constructor - * @param {vereign.protobuf.qrcode_data.IKeyData_V1=} [properties] Properties to set - */ - function KeyData_V1(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - /** - * KeyData_V1 key. - * @member {Uint8Array} key - * @memberof vereign.protobuf.qrcode_data.KeyData_V1 - * @instance - */ - KeyData_V1.prototype.key = $util.newBuffer([]); - /** - * KeyData_V1 data. - * @member {Uint8Array} data - * @memberof vereign.protobuf.qrcode_data.KeyData_V1 - * @instance - */ - KeyData_V1.prototype.data = $util.newBuffer([]); - /** - * Creates a new KeyData_V1 instance using the specified properties. - * @function create - * @memberof vereign.protobuf.qrcode_data.KeyData_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IKeyData_V1=} [properties] Properties to set - * @returns {vereign.protobuf.qrcode_data.KeyData_V1} KeyData_V1 instance - */ - KeyData_V1.create = function create(properties) { - return new KeyData_V1(properties); - }; - /** - * Encodes the specified KeyData_V1 message. Does not implicitly {@link vereign.protobuf.qrcode_data.KeyData_V1.verify|verify} messages. - * @function encode - * @memberof vereign.protobuf.qrcode_data.KeyData_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IKeyData_V1} message KeyData_V1 message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - KeyData_V1.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.key != null && Object.hasOwnProperty.call(message, "key")) - writer.uint32(/* id 1, wireType 2 =*/ 10).bytes(message.key); - if (message.data != null && Object.hasOwnProperty.call(message, "data")) - writer.uint32(/* id 2, wireType 2 =*/ 18).bytes(message.data); - return writer; - }; - /** - * Encodes the specified KeyData_V1 message, length delimited. Does not implicitly {@link vereign.protobuf.qrcode_data.KeyData_V1.verify|verify} messages. - * @function encodeDelimited - * @memberof vereign.protobuf.qrcode_data.KeyData_V1 - * @static - * @param {vereign.protobuf.qrcode_data.IKeyData_V1} message KeyData_V1 message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - KeyData_V1.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - /** - * Decodes a KeyData_V1 message from the specified reader or buffer. - * @function decode - * @memberof vereign.protobuf.qrcode_data.KeyData_V1 - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {vereign.protobuf.qrcode_data.KeyData_V1} KeyData_V1 - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - KeyData_V1.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.vereign.protobuf.qrcode_data.KeyData_V1(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.key = reader.bytes(); - break; - case 2: - message.data = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - /** - * Decodes a KeyData_V1 message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof vereign.protobuf.qrcode_data.KeyData_V1 - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {vereign.protobuf.qrcode_data.KeyData_V1} KeyData_V1 - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - KeyData_V1.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - /** - * Verifies a KeyData_V1 message. - * @function verify - * @memberof vereign.protobuf.qrcode_data.KeyData_V1 - * @static - * @param {Object.<string,*>} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - KeyData_V1.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.key != null && message.hasOwnProperty("key")) - if (!(message.key && typeof message.key.length === "number" || $util.isString(message.key))) - return "key: buffer expected"; - if (message.data != null && message.hasOwnProperty("data")) - if (!(message.data && typeof message.data.length === "number" || $util.isString(message.data))) - return "data: buffer expected"; - return null; - }; - /** - * Creates a KeyData_V1 message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof vereign.protobuf.qrcode_data.KeyData_V1 - * @static - * @param {Object.<string,*>} object Plain object - * @returns {vereign.protobuf.qrcode_data.KeyData_V1} KeyData_V1 - */ - KeyData_V1.fromObject = function fromObject(object) { - if (object instanceof $root.vereign.protobuf.qrcode_data.KeyData_V1) - return object; - var message = new $root.vereign.protobuf.qrcode_data.KeyData_V1(); - if (object.key != null) - if (typeof object.key === "string") - $util.base64.decode(object.key, message.key = $util.newBuffer($util.base64.length(object.key)), 0); - else if (object.key.length) - message.key = object.key; - if (object.data != null) - if (typeof object.data === "string") - $util.base64.decode(object.data, message.data = $util.newBuffer($util.base64.length(object.data)), 0); - else if (object.data.length) - message.data = object.data; - return message; - }; - /** - * Creates a plain object from a KeyData_V1 message. Also converts values to other types if specified. - * @function toObject - * @memberof vereign.protobuf.qrcode_data.KeyData_V1 - * @static - * @param {vereign.protobuf.qrcode_data.KeyData_V1} message KeyData_V1 - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.<string,*>} Plain object - */ - KeyData_V1.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if (options.bytes === String) - object.key = ""; - else { - object.key = []; - if (options.bytes !== Array) - object.key = $util.newBuffer(object.key); - } - if (options.bytes === String) - object.data = ""; - else { - object.data = []; - if (options.bytes !== Array) - object.data = $util.newBuffer(object.data); - } - } - if (message.key != null && message.hasOwnProperty("key")) - object.key = options.bytes === String ? $util.base64.encode(message.key, 0, message.key.length) : options.bytes === Array ? Array.prototype.slice.call(message.key) : message.key; - if (message.data != null && message.hasOwnProperty("data")) - object.data = options.bytes === String ? $util.base64.encode(message.data, 0, message.data.length) : options.bytes === Array ? Array.prototype.slice.call(message.data) : message.data; - return object; - }; - /** - * Converts this KeyData_V1 to JSON. - * @function toJSON - * @memberof vereign.protobuf.qrcode_data.KeyData_V1 - * @instance - * @returns {Object.<string,*>} JSON object - */ - KeyData_V1.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - return KeyData_V1; - })(); - qrcode_data.WrapperData = (function () { - /** - * Properties of a WrapperData. - * @memberof vereign.protobuf.qrcode_data - * @interface IWrapperData - * @property {Uint8Array|null} [data] WrapperData data - * @property {number|null} [version] WrapperData version - * @property {string|null} [className] WrapperData className - */ - /** - * Constructs a new WrapperData. - * @memberof vereign.protobuf.qrcode_data - * @classdesc Represents a WrapperData. - * @implements IWrapperData - * @constructor - * @param {vereign.protobuf.qrcode_data.IWrapperData=} [properties] Properties to set - */ - function WrapperData(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - /** - * WrapperData data. - * @member {Uint8Array} data - * @memberof vereign.protobuf.qrcode_data.WrapperData - * @instance - */ - WrapperData.prototype.data = $util.newBuffer([]); - /** - * WrapperData version. - * @member {number} version - * @memberof vereign.protobuf.qrcode_data.WrapperData - * @instance - */ - WrapperData.prototype.version = 0; - /** - * WrapperData className. - * @member {string} className - * @memberof vereign.protobuf.qrcode_data.WrapperData - * @instance - */ - WrapperData.prototype.className = ""; - /** - * Creates a new WrapperData instance using the specified properties. - * @function create - * @memberof vereign.protobuf.qrcode_data.WrapperData - * @static - * @param {vereign.protobuf.qrcode_data.IWrapperData=} [properties] Properties to set - * @returns {vereign.protobuf.qrcode_data.WrapperData} WrapperData instance - */ - WrapperData.create = function create(properties) { - return new WrapperData(properties); - }; - /** - * Encodes the specified WrapperData message. Does not implicitly {@link vereign.protobuf.qrcode_data.WrapperData.verify|verify} messages. - * @function encode - * @memberof vereign.protobuf.qrcode_data.WrapperData - * @static - * @param {vereign.protobuf.qrcode_data.IWrapperData} message WrapperData message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - WrapperData.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.data != null && Object.hasOwnProperty.call(message, "data")) - writer.uint32(/* id 1, wireType 2 =*/ 10).bytes(message.data); - if (message.version != null && Object.hasOwnProperty.call(message, "version")) - writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.version); - if (message.className != null && Object.hasOwnProperty.call(message, "className")) - writer.uint32(/* id 3, wireType 2 =*/ 26).string(message.className); - return writer; - }; - /** - * Encodes the specified WrapperData message, length delimited. Does not implicitly {@link vereign.protobuf.qrcode_data.WrapperData.verify|verify} messages. - * @function encodeDelimited - * @memberof vereign.protobuf.qrcode_data.WrapperData - * @static - * @param {vereign.protobuf.qrcode_data.IWrapperData} message WrapperData message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - WrapperData.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - /** - * Decodes a WrapperData message from the specified reader or buffer. - * @function decode - * @memberof vereign.protobuf.qrcode_data.WrapperData - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {vereign.protobuf.qrcode_data.WrapperData} WrapperData - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - WrapperData.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.vereign.protobuf.qrcode_data.WrapperData(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.data = reader.bytes(); - break; - case 2: - message.version = reader.int32(); - break; - case 3: - message.className = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - /** - * Decodes a WrapperData message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof vereign.protobuf.qrcode_data.WrapperData - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {vereign.protobuf.qrcode_data.WrapperData} WrapperData - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - WrapperData.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - /** - * Verifies a WrapperData message. - * @function verify - * @memberof vereign.protobuf.qrcode_data.WrapperData - * @static - * @param {Object.<string,*>} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - WrapperData.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.data != null && message.hasOwnProperty("data")) - if (!(message.data && typeof message.data.length === "number" || $util.isString(message.data))) - return "data: buffer expected"; - if (message.version != null && message.hasOwnProperty("version")) - if (!$util.isInteger(message.version)) - return "version: integer expected"; - if (message.className != null && message.hasOwnProperty("className")) - if (!$util.isString(message.className)) - return "className: string expected"; - return null; - }; - /** - * Creates a WrapperData message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof vereign.protobuf.qrcode_data.WrapperData - * @static - * @param {Object.<string,*>} object Plain object - * @returns {vereign.protobuf.qrcode_data.WrapperData} WrapperData - */ - WrapperData.fromObject = function fromObject(object) { - if (object instanceof $root.vereign.protobuf.qrcode_data.WrapperData) - return object; - var message = new $root.vereign.protobuf.qrcode_data.WrapperData(); - if (object.data != null) - if (typeof object.data === "string") - $util.base64.decode(object.data, message.data = $util.newBuffer($util.base64.length(object.data)), 0); - else if (object.data.length) - message.data = object.data; - if (object.version != null) - message.version = object.version | 0; - if (object.className != null) - message.className = String(object.className); - return message; - }; - /** - * Creates a plain object from a WrapperData message. Also converts values to other types if specified. - * @function toObject - * @memberof vereign.protobuf.qrcode_data.WrapperData - * @static - * @param {vereign.protobuf.qrcode_data.WrapperData} message WrapperData - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.<string,*>} Plain object - */ - WrapperData.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if (options.bytes === String) - object.data = ""; - else { - object.data = []; - if (options.bytes !== Array) - object.data = $util.newBuffer(object.data); - } - object.version = 0; - object.className = ""; - } - if (message.data != null && message.hasOwnProperty("data")) - object.data = options.bytes === String ? $util.base64.encode(message.data, 0, message.data.length) : options.bytes === Array ? Array.prototype.slice.call(message.data) : message.data; - if (message.version != null && message.hasOwnProperty("version")) - object.version = message.version; - if (message.className != null && message.hasOwnProperty("className")) - object.className = message.className; - return object; - }; - /** - * Converts this WrapperData to JSON. - * @function toJSON - * @memberof vereign.protobuf.qrcode_data.WrapperData - * @instance - * @returns {Object.<string,*>} JSON object - */ - WrapperData.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - return WrapperData; - })(); - return qrcode_data; - })(); - return protobuf; - })(); - return vereign; -})(); -module.exports = $root; diff --git a/dist/generated/statuses_pb.d.ts b/dist/generated/statuses_pb.d.ts deleted file mode 100644 index 7f27095a8764965aa7280f476097920049cf7258..0000000000000000000000000000000000000000 --- a/dist/generated/statuses_pb.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export = $root; -declare var $root: {}; diff --git a/dist/generated/statuses_pb.js b/dist/generated/statuses_pb.js deleted file mode 100644 index 52da84b01cbfa7a7d30fc454eaa1bc3a6f394823..0000000000000000000000000000000000000000 --- a/dist/generated/statuses_pb.js +++ /dev/null @@ -1,1220 +0,0 @@ -/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ -"use strict"; -var $protobuf = require("protobufjs/minimal"); -// Common aliases -var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; -// Exported root namespace -var $root = $protobuf.roots.statuses || ($protobuf.roots.statuses = {}); -$root.vereign = (function () { - /** - * Namespace vereign. - * @exports vereign - * @namespace - */ - var vereign = {}; - vereign.statuses = (function () { - /** - * Namespace statuses. - * @memberof vereign - * @namespace - */ - var statuses = {}; - /** - * MessageSignatureHashingAlgorithm enum. - * @name vereign.statuses.MessageSignatureHashingAlgorithm - * @enum {number} - * @property {number} MIME=0 MIME value - * @property {number} PARTS=1 PARTS value - */ - statuses.MessageSignatureHashingAlgorithm = (function () { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "MIME"] = 0; - values[valuesById[1] = "PARTS"] = 1; - return values; - })(); - /** - * SenderSystem enum. - * @name vereign.statuses.SenderSystem - * @enum {number} - * @property {number} GMAIL=0 GMAIL value - * @property {number} OUTLOOK=1 OUTLOOK value - * @property {number} ROUNDCUBE=2 ROUNDCUBE value - * @property {number} GENERIC_MIME=3 GENERIC_MIME value - */ - statuses.SenderSystem = (function () { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "GMAIL"] = 0; - values[valuesById[1] = "OUTLOOK"] = 1; - values[valuesById[2] = "ROUNDCUBE"] = 2; - values[valuesById[3] = "GENERIC_MIME"] = 3; - return values; - })(); - statuses.SenderStatusObject = (function () { - /** - * Properties of a SenderStatusObject. - * @memberof vereign.statuses - * @interface ISenderStatusObject - * @property {number|Long|null} [signatureTime] SenderStatusObject signatureTime - * @property {Uint8Array|null} [signatureTimeSignature] SenderStatusObject signatureTimeSignature - * @property {Uint8Array|null} [messageSignature] SenderStatusObject messageSignature - * @property {Object.<string,Uint8Array>|null} [attachmentsSignature] SenderStatusObject attachmentsSignature - * @property {vereign.statuses.MessageSignatureHashingAlgorithm|null} [messageSignatureHashingAlgorithm] SenderStatusObject messageSignatureHashingAlgorithm - * @property {vereign.statuses.SenderSystem|null} [senderSystem] SenderStatusObject senderSystem - */ - /** - * Constructs a new SenderStatusObject. - * @memberof vereign.statuses - * @classdesc Represents a SenderStatusObject. - * @implements ISenderStatusObject - * @constructor - * @param {vereign.statuses.ISenderStatusObject=} [properties] Properties to set - */ - function SenderStatusObject(properties) { - this.attachmentsSignature = {}; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - /** - * SenderStatusObject signatureTime. - * @member {number|Long} signatureTime - * @memberof vereign.statuses.SenderStatusObject - * @instance - */ - SenderStatusObject.prototype.signatureTime = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - /** - * SenderStatusObject signatureTimeSignature. - * @member {Uint8Array} signatureTimeSignature - * @memberof vereign.statuses.SenderStatusObject - * @instance - */ - SenderStatusObject.prototype.signatureTimeSignature = $util.newBuffer([]); - /** - * SenderStatusObject messageSignature. - * @member {Uint8Array} messageSignature - * @memberof vereign.statuses.SenderStatusObject - * @instance - */ - SenderStatusObject.prototype.messageSignature = $util.newBuffer([]); - /** - * SenderStatusObject attachmentsSignature. - * @member {Object.<string,Uint8Array>} attachmentsSignature - * @memberof vereign.statuses.SenderStatusObject - * @instance - */ - SenderStatusObject.prototype.attachmentsSignature = $util.emptyObject; - /** - * SenderStatusObject messageSignatureHashingAlgorithm. - * @member {vereign.statuses.MessageSignatureHashingAlgorithm} messageSignatureHashingAlgorithm - * @memberof vereign.statuses.SenderStatusObject - * @instance - */ - SenderStatusObject.prototype.messageSignatureHashingAlgorithm = 0; - /** - * SenderStatusObject senderSystem. - * @member {vereign.statuses.SenderSystem} senderSystem - * @memberof vereign.statuses.SenderStatusObject - * @instance - */ - SenderStatusObject.prototype.senderSystem = 0; - /** - * Creates a new SenderStatusObject instance using the specified properties. - * @function create - * @memberof vereign.statuses.SenderStatusObject - * @static - * @param {vereign.statuses.ISenderStatusObject=} [properties] Properties to set - * @returns {vereign.statuses.SenderStatusObject} SenderStatusObject instance - */ - SenderStatusObject.create = function create(properties) { - return new SenderStatusObject(properties); - }; - /** - * Encodes the specified SenderStatusObject message. Does not implicitly {@link vereign.statuses.SenderStatusObject.verify|verify} messages. - * @function encode - * @memberof vereign.statuses.SenderStatusObject - * @static - * @param {vereign.statuses.ISenderStatusObject} message SenderStatusObject message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - SenderStatusObject.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.signatureTime != null && Object.hasOwnProperty.call(message, "signatureTime")) - writer.uint32(/* id 1, wireType 0 =*/ 8).int64(message.signatureTime); - if (message.signatureTimeSignature != null && Object.hasOwnProperty.call(message, "signatureTimeSignature")) - writer.uint32(/* id 2, wireType 2 =*/ 18).bytes(message.signatureTimeSignature); - if (message.messageSignature != null && Object.hasOwnProperty.call(message, "messageSignature")) - writer.uint32(/* id 3, wireType 2 =*/ 26).bytes(message.messageSignature); - if (message.attachmentsSignature != null && Object.hasOwnProperty.call(message, "attachmentsSignature")) - for (var keys = Object.keys(message.attachmentsSignature), i = 0; i < keys.length; ++i) - writer.uint32(/* id 4, wireType 2 =*/ 34).fork().uint32(/* id 1, wireType 2 =*/ 10).string(keys[i]).uint32(/* id 2, wireType 2 =*/ 18).bytes(message.attachmentsSignature[keys[i]]).ldelim(); - if (message.messageSignatureHashingAlgorithm != null && Object.hasOwnProperty.call(message, "messageSignatureHashingAlgorithm")) - writer.uint32(/* id 5, wireType 0 =*/ 40).int32(message.messageSignatureHashingAlgorithm); - if (message.senderSystem != null && Object.hasOwnProperty.call(message, "senderSystem")) - writer.uint32(/* id 6, wireType 0 =*/ 48).int32(message.senderSystem); - return writer; - }; - /** - * Encodes the specified SenderStatusObject message, length delimited. Does not implicitly {@link vereign.statuses.SenderStatusObject.verify|verify} messages. - * @function encodeDelimited - * @memberof vereign.statuses.SenderStatusObject - * @static - * @param {vereign.statuses.ISenderStatusObject} message SenderStatusObject message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - SenderStatusObject.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - /** - * Decodes a SenderStatusObject message from the specified reader or buffer. - * @function decode - * @memberof vereign.statuses.SenderStatusObject - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {vereign.statuses.SenderStatusObject} SenderStatusObject - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - SenderStatusObject.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.vereign.statuses.SenderStatusObject(), key, value; - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.signatureTime = reader.int64(); - break; - case 2: - message.signatureTimeSignature = reader.bytes(); - break; - case 3: - message.messageSignature = reader.bytes(); - break; - case 4: - if (message.attachmentsSignature === $util.emptyObject) - message.attachmentsSignature = {}; - var end2 = reader.uint32() + reader.pos; - key = ""; - value = []; - while (reader.pos < end2) { - var tag2 = reader.uint32(); - switch (tag2 >>> 3) { - case 1: - key = reader.string(); - break; - case 2: - value = reader.bytes(); - break; - default: - reader.skipType(tag2 & 7); - break; - } - } - message.attachmentsSignature[key] = value; - break; - case 5: - message.messageSignatureHashingAlgorithm = reader.int32(); - break; - case 6: - message.senderSystem = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - /** - * Decodes a SenderStatusObject message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof vereign.statuses.SenderStatusObject - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {vereign.statuses.SenderStatusObject} SenderStatusObject - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - SenderStatusObject.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - /** - * Verifies a SenderStatusObject message. - * @function verify - * @memberof vereign.statuses.SenderStatusObject - * @static - * @param {Object.<string,*>} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - SenderStatusObject.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.signatureTime != null && message.hasOwnProperty("signatureTime")) - if (!$util.isInteger(message.signatureTime) && !(message.signatureTime && $util.isInteger(message.signatureTime.low) && $util.isInteger(message.signatureTime.high))) - return "signatureTime: integer|Long expected"; - if (message.signatureTimeSignature != null && message.hasOwnProperty("signatureTimeSignature")) - if (!(message.signatureTimeSignature && typeof message.signatureTimeSignature.length === "number" || $util.isString(message.signatureTimeSignature))) - return "signatureTimeSignature: buffer expected"; - if (message.messageSignature != null && message.hasOwnProperty("messageSignature")) - if (!(message.messageSignature && typeof message.messageSignature.length === "number" || $util.isString(message.messageSignature))) - return "messageSignature: buffer expected"; - if (message.attachmentsSignature != null && message.hasOwnProperty("attachmentsSignature")) { - if (!$util.isObject(message.attachmentsSignature)) - return "attachmentsSignature: object expected"; - var key = Object.keys(message.attachmentsSignature); - for (var i = 0; i < key.length; ++i) - if (!(message.attachmentsSignature[key[i]] && typeof message.attachmentsSignature[key[i]].length === "number" || $util.isString(message.attachmentsSignature[key[i]]))) - return "attachmentsSignature: buffer{k:string} expected"; - } - if (message.messageSignatureHashingAlgorithm != null && message.hasOwnProperty("messageSignatureHashingAlgorithm")) - switch (message.messageSignatureHashingAlgorithm) { - default: - return "messageSignatureHashingAlgorithm: enum value expected"; - case 0: - case 1: - break; - } - if (message.senderSystem != null && message.hasOwnProperty("senderSystem")) - switch (message.senderSystem) { - default: - return "senderSystem: enum value expected"; - case 0: - case 1: - case 2: - case 3: - break; - } - return null; - }; - /** - * Creates a SenderStatusObject message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof vereign.statuses.SenderStatusObject - * @static - * @param {Object.<string,*>} object Plain object - * @returns {vereign.statuses.SenderStatusObject} SenderStatusObject - */ - SenderStatusObject.fromObject = function fromObject(object) { - if (object instanceof $root.vereign.statuses.SenderStatusObject) - return object; - var message = new $root.vereign.statuses.SenderStatusObject(); - if (object.signatureTime != null) - if ($util.Long) - (message.signatureTime = $util.Long.fromValue(object.signatureTime)).unsigned = false; - else if (typeof object.signatureTime === "string") - message.signatureTime = parseInt(object.signatureTime, 10); - else if (typeof object.signatureTime === "number") - message.signatureTime = object.signatureTime; - else if (typeof object.signatureTime === "object") - message.signatureTime = new $util.LongBits(object.signatureTime.low >>> 0, object.signatureTime.high >>> 0).toNumber(); - if (object.signatureTimeSignature != null) - if (typeof object.signatureTimeSignature === "string") - $util.base64.decode(object.signatureTimeSignature, message.signatureTimeSignature = $util.newBuffer($util.base64.length(object.signatureTimeSignature)), 0); - else if (object.signatureTimeSignature.length) - message.signatureTimeSignature = object.signatureTimeSignature; - if (object.messageSignature != null) - if (typeof object.messageSignature === "string") - $util.base64.decode(object.messageSignature, message.messageSignature = $util.newBuffer($util.base64.length(object.messageSignature)), 0); - else if (object.messageSignature.length) - message.messageSignature = object.messageSignature; - if (object.attachmentsSignature) { - if (typeof object.attachmentsSignature !== "object") - throw TypeError(".vereign.statuses.SenderStatusObject.attachmentsSignature: object expected"); - message.attachmentsSignature = {}; - for (var keys = Object.keys(object.attachmentsSignature), i = 0; i < keys.length; ++i) - if (typeof object.attachmentsSignature[keys[i]] === "string") - $util.base64.decode(object.attachmentsSignature[keys[i]], message.attachmentsSignature[keys[i]] = $util.newBuffer($util.base64.length(object.attachmentsSignature[keys[i]])), 0); - else if (object.attachmentsSignature[keys[i]].length) - message.attachmentsSignature[keys[i]] = object.attachmentsSignature[keys[i]]; - } - switch (object.messageSignatureHashingAlgorithm) { - case "MIME": - case 0: - message.messageSignatureHashingAlgorithm = 0; - break; - case "PARTS": - case 1: - message.messageSignatureHashingAlgorithm = 1; - break; - } - switch (object.senderSystem) { - case "GMAIL": - case 0: - message.senderSystem = 0; - break; - case "OUTLOOK": - case 1: - message.senderSystem = 1; - break; - case "ROUNDCUBE": - case 2: - message.senderSystem = 2; - break; - case "GENERIC_MIME": - case 3: - message.senderSystem = 3; - break; - } - return message; - }; - /** - * Creates a plain object from a SenderStatusObject message. Also converts values to other types if specified. - * @function toObject - * @memberof vereign.statuses.SenderStatusObject - * @static - * @param {vereign.statuses.SenderStatusObject} message SenderStatusObject - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.<string,*>} Plain object - */ - SenderStatusObject.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.objects || options.defaults) - object.attachmentsSignature = {}; - if (options.defaults) { - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.signatureTime = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } - else - object.signatureTime = options.longs === String ? "0" : 0; - if (options.bytes === String) - object.signatureTimeSignature = ""; - else { - object.signatureTimeSignature = []; - if (options.bytes !== Array) - object.signatureTimeSignature = $util.newBuffer(object.signatureTimeSignature); - } - if (options.bytes === String) - object.messageSignature = ""; - else { - object.messageSignature = []; - if (options.bytes !== Array) - object.messageSignature = $util.newBuffer(object.messageSignature); - } - object.messageSignatureHashingAlgorithm = options.enums === String ? "MIME" : 0; - object.senderSystem = options.enums === String ? "GMAIL" : 0; - } - if (message.signatureTime != null && message.hasOwnProperty("signatureTime")) - if (typeof message.signatureTime === "number") - object.signatureTime = options.longs === String ? String(message.signatureTime) : message.signatureTime; - else - object.signatureTime = options.longs === String ? $util.Long.prototype.toString.call(message.signatureTime) : options.longs === Number ? new $util.LongBits(message.signatureTime.low >>> 0, message.signatureTime.high >>> 0).toNumber() : message.signatureTime; - if (message.signatureTimeSignature != null && message.hasOwnProperty("signatureTimeSignature")) - object.signatureTimeSignature = options.bytes === String ? $util.base64.encode(message.signatureTimeSignature, 0, message.signatureTimeSignature.length) : options.bytes === Array ? Array.prototype.slice.call(message.signatureTimeSignature) : message.signatureTimeSignature; - if (message.messageSignature != null && message.hasOwnProperty("messageSignature")) - object.messageSignature = options.bytes === String ? $util.base64.encode(message.messageSignature, 0, message.messageSignature.length) : options.bytes === Array ? Array.prototype.slice.call(message.messageSignature) : message.messageSignature; - var keys2; - if (message.attachmentsSignature && (keys2 = Object.keys(message.attachmentsSignature)).length) { - object.attachmentsSignature = {}; - for (var j = 0; j < keys2.length; ++j) - object.attachmentsSignature[keys2[j]] = options.bytes === String ? $util.base64.encode(message.attachmentsSignature[keys2[j]], 0, message.attachmentsSignature[keys2[j]].length) : options.bytes === Array ? Array.prototype.slice.call(message.attachmentsSignature[keys2[j]]) : message.attachmentsSignature[keys2[j]]; - } - if (message.messageSignatureHashingAlgorithm != null && message.hasOwnProperty("messageSignatureHashingAlgorithm")) - object.messageSignatureHashingAlgorithm = options.enums === String ? $root.vereign.statuses.MessageSignatureHashingAlgorithm[message.messageSignatureHashingAlgorithm] : message.messageSignatureHashingAlgorithm; - if (message.senderSystem != null && message.hasOwnProperty("senderSystem")) - object.senderSystem = options.enums === String ? $root.vereign.statuses.SenderSystem[message.senderSystem] : message.senderSystem; - return object; - }; - /** - * Converts this SenderStatusObject to JSON. - * @function toJSON - * @memberof vereign.statuses.SenderStatusObject - * @instance - * @returns {Object.<string,*>} JSON object - */ - SenderStatusObject.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - return SenderStatusObject; - })(); - statuses.RecipientStatusData = (function () { - /** - * Properties of a RecipientStatusData. - * @memberof vereign.statuses - * @interface IRecipientStatusData - * @property {number|Long|null} [creationDate] RecipientStatusData creationDate - * @property {Uint8Array|null} [gatewayDomainHash] RecipientStatusData gatewayDomainHash - * @property {Uint8Array|null} [randomToken] RecipientStatusData randomToken - * @property {Uint8Array|null} [emailHash] RecipientStatusData emailHash - */ - /** - * Constructs a new RecipientStatusData. - * @memberof vereign.statuses - * @classdesc Represents a RecipientStatusData. - * @implements IRecipientStatusData - * @constructor - * @param {vereign.statuses.IRecipientStatusData=} [properties] Properties to set - */ - function RecipientStatusData(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - /** - * RecipientStatusData creationDate. - * @member {number|Long} creationDate - * @memberof vereign.statuses.RecipientStatusData - * @instance - */ - RecipientStatusData.prototype.creationDate = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - /** - * RecipientStatusData gatewayDomainHash. - * @member {Uint8Array} gatewayDomainHash - * @memberof vereign.statuses.RecipientStatusData - * @instance - */ - RecipientStatusData.prototype.gatewayDomainHash = $util.newBuffer([]); - /** - * RecipientStatusData randomToken. - * @member {Uint8Array} randomToken - * @memberof vereign.statuses.RecipientStatusData - * @instance - */ - RecipientStatusData.prototype.randomToken = $util.newBuffer([]); - /** - * RecipientStatusData emailHash. - * @member {Uint8Array} emailHash - * @memberof vereign.statuses.RecipientStatusData - * @instance - */ - RecipientStatusData.prototype.emailHash = $util.newBuffer([]); - /** - * Creates a new RecipientStatusData instance using the specified properties. - * @function create - * @memberof vereign.statuses.RecipientStatusData - * @static - * @param {vereign.statuses.IRecipientStatusData=} [properties] Properties to set - * @returns {vereign.statuses.RecipientStatusData} RecipientStatusData instance - */ - RecipientStatusData.create = function create(properties) { - return new RecipientStatusData(properties); - }; - /** - * Encodes the specified RecipientStatusData message. Does not implicitly {@link vereign.statuses.RecipientStatusData.verify|verify} messages. - * @function encode - * @memberof vereign.statuses.RecipientStatusData - * @static - * @param {vereign.statuses.IRecipientStatusData} message RecipientStatusData message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - RecipientStatusData.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.creationDate != null && Object.hasOwnProperty.call(message, "creationDate")) - writer.uint32(/* id 1, wireType 0 =*/ 8).int64(message.creationDate); - if (message.gatewayDomainHash != null && Object.hasOwnProperty.call(message, "gatewayDomainHash")) - writer.uint32(/* id 2, wireType 2 =*/ 18).bytes(message.gatewayDomainHash); - if (message.randomToken != null && Object.hasOwnProperty.call(message, "randomToken")) - writer.uint32(/* id 3, wireType 2 =*/ 26).bytes(message.randomToken); - if (message.emailHash != null && Object.hasOwnProperty.call(message, "emailHash")) - writer.uint32(/* id 4, wireType 2 =*/ 34).bytes(message.emailHash); - return writer; - }; - /** - * Encodes the specified RecipientStatusData message, length delimited. Does not implicitly {@link vereign.statuses.RecipientStatusData.verify|verify} messages. - * @function encodeDelimited - * @memberof vereign.statuses.RecipientStatusData - * @static - * @param {vereign.statuses.IRecipientStatusData} message RecipientStatusData message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - RecipientStatusData.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - /** - * Decodes a RecipientStatusData message from the specified reader or buffer. - * @function decode - * @memberof vereign.statuses.RecipientStatusData - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {vereign.statuses.RecipientStatusData} RecipientStatusData - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - RecipientStatusData.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.vereign.statuses.RecipientStatusData(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.creationDate = reader.int64(); - break; - case 2: - message.gatewayDomainHash = reader.bytes(); - break; - case 3: - message.randomToken = reader.bytes(); - break; - case 4: - message.emailHash = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - /** - * Decodes a RecipientStatusData message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof vereign.statuses.RecipientStatusData - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {vereign.statuses.RecipientStatusData} RecipientStatusData - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - RecipientStatusData.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - /** - * Verifies a RecipientStatusData message. - * @function verify - * @memberof vereign.statuses.RecipientStatusData - * @static - * @param {Object.<string,*>} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - RecipientStatusData.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.creationDate != null && message.hasOwnProperty("creationDate")) - if (!$util.isInteger(message.creationDate) && !(message.creationDate && $util.isInteger(message.creationDate.low) && $util.isInteger(message.creationDate.high))) - return "creationDate: integer|Long expected"; - if (message.gatewayDomainHash != null && message.hasOwnProperty("gatewayDomainHash")) - if (!(message.gatewayDomainHash && typeof message.gatewayDomainHash.length === "number" || $util.isString(message.gatewayDomainHash))) - return "gatewayDomainHash: buffer expected"; - if (message.randomToken != null && message.hasOwnProperty("randomToken")) - if (!(message.randomToken && typeof message.randomToken.length === "number" || $util.isString(message.randomToken))) - return "randomToken: buffer expected"; - if (message.emailHash != null && message.hasOwnProperty("emailHash")) - if (!(message.emailHash && typeof message.emailHash.length === "number" || $util.isString(message.emailHash))) - return "emailHash: buffer expected"; - return null; - }; - /** - * Creates a RecipientStatusData message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof vereign.statuses.RecipientStatusData - * @static - * @param {Object.<string,*>} object Plain object - * @returns {vereign.statuses.RecipientStatusData} RecipientStatusData - */ - RecipientStatusData.fromObject = function fromObject(object) { - if (object instanceof $root.vereign.statuses.RecipientStatusData) - return object; - var message = new $root.vereign.statuses.RecipientStatusData(); - if (object.creationDate != null) - if ($util.Long) - (message.creationDate = $util.Long.fromValue(object.creationDate)).unsigned = false; - else if (typeof object.creationDate === "string") - message.creationDate = parseInt(object.creationDate, 10); - else if (typeof object.creationDate === "number") - message.creationDate = object.creationDate; - else if (typeof object.creationDate === "object") - message.creationDate = new $util.LongBits(object.creationDate.low >>> 0, object.creationDate.high >>> 0).toNumber(); - if (object.gatewayDomainHash != null) - if (typeof object.gatewayDomainHash === "string") - $util.base64.decode(object.gatewayDomainHash, message.gatewayDomainHash = $util.newBuffer($util.base64.length(object.gatewayDomainHash)), 0); - else if (object.gatewayDomainHash.length) - message.gatewayDomainHash = object.gatewayDomainHash; - if (object.randomToken != null) - if (typeof object.randomToken === "string") - $util.base64.decode(object.randomToken, message.randomToken = $util.newBuffer($util.base64.length(object.randomToken)), 0); - else if (object.randomToken.length) - message.randomToken = object.randomToken; - if (object.emailHash != null) - if (typeof object.emailHash === "string") - $util.base64.decode(object.emailHash, message.emailHash = $util.newBuffer($util.base64.length(object.emailHash)), 0); - else if (object.emailHash.length) - message.emailHash = object.emailHash; - return message; - }; - /** - * Creates a plain object from a RecipientStatusData message. Also converts values to other types if specified. - * @function toObject - * @memberof vereign.statuses.RecipientStatusData - * @static - * @param {vereign.statuses.RecipientStatusData} message RecipientStatusData - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.<string,*>} Plain object - */ - RecipientStatusData.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.creationDate = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } - else - object.creationDate = options.longs === String ? "0" : 0; - if (options.bytes === String) - object.gatewayDomainHash = ""; - else { - object.gatewayDomainHash = []; - if (options.bytes !== Array) - object.gatewayDomainHash = $util.newBuffer(object.gatewayDomainHash); - } - if (options.bytes === String) - object.randomToken = ""; - else { - object.randomToken = []; - if (options.bytes !== Array) - object.randomToken = $util.newBuffer(object.randomToken); - } - if (options.bytes === String) - object.emailHash = ""; - else { - object.emailHash = []; - if (options.bytes !== Array) - object.emailHash = $util.newBuffer(object.emailHash); - } - } - if (message.creationDate != null && message.hasOwnProperty("creationDate")) - if (typeof message.creationDate === "number") - object.creationDate = options.longs === String ? String(message.creationDate) : message.creationDate; - else - object.creationDate = options.longs === String ? $util.Long.prototype.toString.call(message.creationDate) : options.longs === Number ? new $util.LongBits(message.creationDate.low >>> 0, message.creationDate.high >>> 0).toNumber() : message.creationDate; - if (message.gatewayDomainHash != null && message.hasOwnProperty("gatewayDomainHash")) - object.gatewayDomainHash = options.bytes === String ? $util.base64.encode(message.gatewayDomainHash, 0, message.gatewayDomainHash.length) : options.bytes === Array ? Array.prototype.slice.call(message.gatewayDomainHash) : message.gatewayDomainHash; - if (message.randomToken != null && message.hasOwnProperty("randomToken")) - object.randomToken = options.bytes === String ? $util.base64.encode(message.randomToken, 0, message.randomToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.randomToken) : message.randomToken; - if (message.emailHash != null && message.hasOwnProperty("emailHash")) - object.emailHash = options.bytes === String ? $util.base64.encode(message.emailHash, 0, message.emailHash.length) : options.bytes === Array ? Array.prototype.slice.call(message.emailHash) : message.emailHash; - return object; - }; - /** - * Converts this RecipientStatusData to JSON. - * @function toJSON - * @memberof vereign.statuses.RecipientStatusData - * @instance - * @returns {Object.<string,*>} JSON object - */ - RecipientStatusData.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - return RecipientStatusData; - })(); - statuses.RecipientStatusObject = (function () { - /** - * Properties of a RecipientStatusObject. - * @memberof vereign.statuses - * @interface IRecipientStatusObject - * @property {Uint8Array|null} [iv] RecipientStatusObject iv - * @property {Uint8Array|null} [encryptedContent] RecipientStatusObject encryptedContent - * @property {Object.<string,Uint8Array>|null} [decryptors] RecipientStatusObject decryptors - */ - /** - * Constructs a new RecipientStatusObject. - * @memberof vereign.statuses - * @classdesc Represents a RecipientStatusObject. - * @implements IRecipientStatusObject - * @constructor - * @param {vereign.statuses.IRecipientStatusObject=} [properties] Properties to set - */ - function RecipientStatusObject(properties) { - this.decryptors = {}; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - /** - * RecipientStatusObject iv. - * @member {Uint8Array} iv - * @memberof vereign.statuses.RecipientStatusObject - * @instance - */ - RecipientStatusObject.prototype.iv = $util.newBuffer([]); - /** - * RecipientStatusObject encryptedContent. - * @member {Uint8Array} encryptedContent - * @memberof vereign.statuses.RecipientStatusObject - * @instance - */ - RecipientStatusObject.prototype.encryptedContent = $util.newBuffer([]); - /** - * RecipientStatusObject decryptors. - * @member {Object.<string,Uint8Array>} decryptors - * @memberof vereign.statuses.RecipientStatusObject - * @instance - */ - RecipientStatusObject.prototype.decryptors = $util.emptyObject; - /** - * Creates a new RecipientStatusObject instance using the specified properties. - * @function create - * @memberof vereign.statuses.RecipientStatusObject - * @static - * @param {vereign.statuses.IRecipientStatusObject=} [properties] Properties to set - * @returns {vereign.statuses.RecipientStatusObject} RecipientStatusObject instance - */ - RecipientStatusObject.create = function create(properties) { - return new RecipientStatusObject(properties); - }; - /** - * Encodes the specified RecipientStatusObject message. Does not implicitly {@link vereign.statuses.RecipientStatusObject.verify|verify} messages. - * @function encode - * @memberof vereign.statuses.RecipientStatusObject - * @static - * @param {vereign.statuses.IRecipientStatusObject} message RecipientStatusObject message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - RecipientStatusObject.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.iv != null && Object.hasOwnProperty.call(message, "iv")) - writer.uint32(/* id 1, wireType 2 =*/ 10).bytes(message.iv); - if (message.encryptedContent != null && Object.hasOwnProperty.call(message, "encryptedContent")) - writer.uint32(/* id 2, wireType 2 =*/ 18).bytes(message.encryptedContent); - if (message.decryptors != null && Object.hasOwnProperty.call(message, "decryptors")) - for (var keys = Object.keys(message.decryptors), i = 0; i < keys.length; ++i) - writer.uint32(/* id 3, wireType 2 =*/ 26).fork().uint32(/* id 1, wireType 2 =*/ 10).string(keys[i]).uint32(/* id 2, wireType 2 =*/ 18).bytes(message.decryptors[keys[i]]).ldelim(); - return writer; - }; - /** - * Encodes the specified RecipientStatusObject message, length delimited. Does not implicitly {@link vereign.statuses.RecipientStatusObject.verify|verify} messages. - * @function encodeDelimited - * @memberof vereign.statuses.RecipientStatusObject - * @static - * @param {vereign.statuses.IRecipientStatusObject} message RecipientStatusObject message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - RecipientStatusObject.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - /** - * Decodes a RecipientStatusObject message from the specified reader or buffer. - * @function decode - * @memberof vereign.statuses.RecipientStatusObject - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {vereign.statuses.RecipientStatusObject} RecipientStatusObject - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - RecipientStatusObject.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.vereign.statuses.RecipientStatusObject(), key, value; - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.iv = reader.bytes(); - break; - case 2: - message.encryptedContent = reader.bytes(); - break; - case 3: - if (message.decryptors === $util.emptyObject) - message.decryptors = {}; - var end2 = reader.uint32() + reader.pos; - key = ""; - value = []; - while (reader.pos < end2) { - var tag2 = reader.uint32(); - switch (tag2 >>> 3) { - case 1: - key = reader.string(); - break; - case 2: - value = reader.bytes(); - break; - default: - reader.skipType(tag2 & 7); - break; - } - } - message.decryptors[key] = value; - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - /** - * Decodes a RecipientStatusObject message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof vereign.statuses.RecipientStatusObject - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {vereign.statuses.RecipientStatusObject} RecipientStatusObject - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - RecipientStatusObject.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - /** - * Verifies a RecipientStatusObject message. - * @function verify - * @memberof vereign.statuses.RecipientStatusObject - * @static - * @param {Object.<string,*>} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - RecipientStatusObject.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.iv != null && message.hasOwnProperty("iv")) - if (!(message.iv && typeof message.iv.length === "number" || $util.isString(message.iv))) - return "iv: buffer expected"; - if (message.encryptedContent != null && message.hasOwnProperty("encryptedContent")) - if (!(message.encryptedContent && typeof message.encryptedContent.length === "number" || $util.isString(message.encryptedContent))) - return "encryptedContent: buffer expected"; - if (message.decryptors != null && message.hasOwnProperty("decryptors")) { - if (!$util.isObject(message.decryptors)) - return "decryptors: object expected"; - var key = Object.keys(message.decryptors); - for (var i = 0; i < key.length; ++i) - if (!(message.decryptors[key[i]] && typeof message.decryptors[key[i]].length === "number" || $util.isString(message.decryptors[key[i]]))) - return "decryptors: buffer{k:string} expected"; - } - return null; - }; - /** - * Creates a RecipientStatusObject message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof vereign.statuses.RecipientStatusObject - * @static - * @param {Object.<string,*>} object Plain object - * @returns {vereign.statuses.RecipientStatusObject} RecipientStatusObject - */ - RecipientStatusObject.fromObject = function fromObject(object) { - if (object instanceof $root.vereign.statuses.RecipientStatusObject) - return object; - var message = new $root.vereign.statuses.RecipientStatusObject(); - if (object.iv != null) - if (typeof object.iv === "string") - $util.base64.decode(object.iv, message.iv = $util.newBuffer($util.base64.length(object.iv)), 0); - else if (object.iv.length) - message.iv = object.iv; - if (object.encryptedContent != null) - if (typeof object.encryptedContent === "string") - $util.base64.decode(object.encryptedContent, message.encryptedContent = $util.newBuffer($util.base64.length(object.encryptedContent)), 0); - else if (object.encryptedContent.length) - message.encryptedContent = object.encryptedContent; - if (object.decryptors) { - if (typeof object.decryptors !== "object") - throw TypeError(".vereign.statuses.RecipientStatusObject.decryptors: object expected"); - message.decryptors = {}; - for (var keys = Object.keys(object.decryptors), i = 0; i < keys.length; ++i) - if (typeof object.decryptors[keys[i]] === "string") - $util.base64.decode(object.decryptors[keys[i]], message.decryptors[keys[i]] = $util.newBuffer($util.base64.length(object.decryptors[keys[i]])), 0); - else if (object.decryptors[keys[i]].length) - message.decryptors[keys[i]] = object.decryptors[keys[i]]; - } - return message; - }; - /** - * Creates a plain object from a RecipientStatusObject message. Also converts values to other types if specified. - * @function toObject - * @memberof vereign.statuses.RecipientStatusObject - * @static - * @param {vereign.statuses.RecipientStatusObject} message RecipientStatusObject - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.<string,*>} Plain object - */ - RecipientStatusObject.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.objects || options.defaults) - object.decryptors = {}; - if (options.defaults) { - if (options.bytes === String) - object.iv = ""; - else { - object.iv = []; - if (options.bytes !== Array) - object.iv = $util.newBuffer(object.iv); - } - if (options.bytes === String) - object.encryptedContent = ""; - else { - object.encryptedContent = []; - if (options.bytes !== Array) - object.encryptedContent = $util.newBuffer(object.encryptedContent); - } - } - if (message.iv != null && message.hasOwnProperty("iv")) - object.iv = options.bytes === String ? $util.base64.encode(message.iv, 0, message.iv.length) : options.bytes === Array ? Array.prototype.slice.call(message.iv) : message.iv; - if (message.encryptedContent != null && message.hasOwnProperty("encryptedContent")) - object.encryptedContent = options.bytes === String ? $util.base64.encode(message.encryptedContent, 0, message.encryptedContent.length) : options.bytes === Array ? Array.prototype.slice.call(message.encryptedContent) : message.encryptedContent; - var keys2; - if (message.decryptors && (keys2 = Object.keys(message.decryptors)).length) { - object.decryptors = {}; - for (var j = 0; j < keys2.length; ++j) - object.decryptors[keys2[j]] = options.bytes === String ? $util.base64.encode(message.decryptors[keys2[j]], 0, message.decryptors[keys2[j]].length) : options.bytes === Array ? Array.prototype.slice.call(message.decryptors[keys2[j]]) : message.decryptors[keys2[j]]; - } - return object; - }; - /** - * Converts this RecipientStatusObject to JSON. - * @function toJSON - * @memberof vereign.statuses.RecipientStatusObject - * @instance - * @returns {Object.<string,*>} JSON object - */ - RecipientStatusObject.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - return RecipientStatusObject; - })(); - statuses.WrapperData = (function () { - /** - * Properties of a WrapperData. - * @memberof vereign.statuses - * @interface IWrapperData - * @property {Uint8Array|null} [data] WrapperData data - * @property {number|null} [version] WrapperData version - * @property {string|null} [className] WrapperData className - */ - /** - * Constructs a new WrapperData. - * @memberof vereign.statuses - * @classdesc Represents a WrapperData. - * @implements IWrapperData - * @constructor - * @param {vereign.statuses.IWrapperData=} [properties] Properties to set - */ - function WrapperData(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - /** - * WrapperData data. - * @member {Uint8Array} data - * @memberof vereign.statuses.WrapperData - * @instance - */ - WrapperData.prototype.data = $util.newBuffer([]); - /** - * WrapperData version. - * @member {number} version - * @memberof vereign.statuses.WrapperData - * @instance - */ - WrapperData.prototype.version = 0; - /** - * WrapperData className. - * @member {string} className - * @memberof vereign.statuses.WrapperData - * @instance - */ - WrapperData.prototype.className = ""; - /** - * Creates a new WrapperData instance using the specified properties. - * @function create - * @memberof vereign.statuses.WrapperData - * @static - * @param {vereign.statuses.IWrapperData=} [properties] Properties to set - * @returns {vereign.statuses.WrapperData} WrapperData instance - */ - WrapperData.create = function create(properties) { - return new WrapperData(properties); - }; - /** - * Encodes the specified WrapperData message. Does not implicitly {@link vereign.statuses.WrapperData.verify|verify} messages. - * @function encode - * @memberof vereign.statuses.WrapperData - * @static - * @param {vereign.statuses.IWrapperData} message WrapperData message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - WrapperData.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.data != null && Object.hasOwnProperty.call(message, "data")) - writer.uint32(/* id 1, wireType 2 =*/ 10).bytes(message.data); - if (message.version != null && Object.hasOwnProperty.call(message, "version")) - writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.version); - if (message.className != null && Object.hasOwnProperty.call(message, "className")) - writer.uint32(/* id 3, wireType 2 =*/ 26).string(message.className); - return writer; - }; - /** - * Encodes the specified WrapperData message, length delimited. Does not implicitly {@link vereign.statuses.WrapperData.verify|verify} messages. - * @function encodeDelimited - * @memberof vereign.statuses.WrapperData - * @static - * @param {vereign.statuses.IWrapperData} message WrapperData message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - WrapperData.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - /** - * Decodes a WrapperData message from the specified reader or buffer. - * @function decode - * @memberof vereign.statuses.WrapperData - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {vereign.statuses.WrapperData} WrapperData - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - WrapperData.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.vereign.statuses.WrapperData(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.data = reader.bytes(); - break; - case 2: - message.version = reader.int32(); - break; - case 3: - message.className = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - /** - * Decodes a WrapperData message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof vereign.statuses.WrapperData - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {vereign.statuses.WrapperData} WrapperData - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - WrapperData.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - /** - * Verifies a WrapperData message. - * @function verify - * @memberof vereign.statuses.WrapperData - * @static - * @param {Object.<string,*>} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - WrapperData.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.data != null && message.hasOwnProperty("data")) - if (!(message.data && typeof message.data.length === "number" || $util.isString(message.data))) - return "data: buffer expected"; - if (message.version != null && message.hasOwnProperty("version")) - if (!$util.isInteger(message.version)) - return "version: integer expected"; - if (message.className != null && message.hasOwnProperty("className")) - if (!$util.isString(message.className)) - return "className: string expected"; - return null; - }; - /** - * Creates a WrapperData message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof vereign.statuses.WrapperData - * @static - * @param {Object.<string,*>} object Plain object - * @returns {vereign.statuses.WrapperData} WrapperData - */ - WrapperData.fromObject = function fromObject(object) { - if (object instanceof $root.vereign.statuses.WrapperData) - return object; - var message = new $root.vereign.statuses.WrapperData(); - if (object.data != null) - if (typeof object.data === "string") - $util.base64.decode(object.data, message.data = $util.newBuffer($util.base64.length(object.data)), 0); - else if (object.data.length) - message.data = object.data; - if (object.version != null) - message.version = object.version | 0; - if (object.className != null) - message.className = String(object.className); - return message; - }; - /** - * Creates a plain object from a WrapperData message. Also converts values to other types if specified. - * @function toObject - * @memberof vereign.statuses.WrapperData - * @static - * @param {vereign.statuses.WrapperData} message WrapperData - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.<string,*>} Plain object - */ - WrapperData.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if (options.bytes === String) - object.data = ""; - else { - object.data = []; - if (options.bytes !== Array) - object.data = $util.newBuffer(object.data); - } - object.version = 0; - object.className = ""; - } - if (message.data != null && message.hasOwnProperty("data")) - object.data = options.bytes === String ? $util.base64.encode(message.data, 0, message.data.length) : options.bytes === Array ? Array.prototype.slice.call(message.data) : message.data; - if (message.version != null && message.hasOwnProperty("version")) - object.version = message.version; - if (message.className != null && message.hasOwnProperty("className")) - object.className = message.className; - return object; - }; - /** - * Converts this WrapperData to JSON. - * @function toJSON - * @memberof vereign.statuses.WrapperData - * @instance - * @returns {Object.<string,*>} JSON object - */ - WrapperData.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - return WrapperData; - })(); - return statuses; - })(); - return vereign; -})(); -module.exports = $root; diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 14f53c3818abd72d6cf0a3eb08266d6db7db29f6..0000000000000000000000000000000000000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -export * from "./types"; -export * from "./utils/common"; -export { default as CloudflareService } from "./services/CloudflareService"; -export { default as VerificationService } from "./services/VerificationService"; -export { default as MimeVerificationService } from "./services/MimeVerificationService"; -export { default as StatusesService } from "./services/StatusesService"; -export { default as CommonUtils } from "./utils/common"; -export { default as QrCodeDataService } from "./services/QrCodeDataService"; -export { default as CryptoService } from "./services/CryptoService"; -export { default as VerificationError } from "./services/VerificationService/VerificationError"; -export { default as MailParser } from "./services/MailParser"; -export { default as QrCodeTemplate } from "./utils/qrCodeTemplateUtils"; -export { default as RKAUtility } from "./utils/rka"; -/** - * @deprecated Will be removed in version 1.0.1. Please use RKAUtility instead. - */ -export declare const RollingHash: { - getRabinFingerprint: (string: string) => string; - searchFingerprintInText: (text: string, keywordHashHexString: string, size: number) => number; - getRollingHash: (string: string) => string; - searchHashInText: (text: string, keywordHashHexString: string, size: number) => number; -}; -import CloudflareService from "./services/CloudflareService"; -/** - * @deprecated Will be removed in version 1.0.1. Please use CloudflareService instead. - */ -export declare const CDNService: typeof CloudflareService; diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5f74a6a4f7bf0d2e561984eb59b24089af832440..0000000000000000000000000000000000000000 --- a/dist/index.js +++ /dev/null @@ -1,47 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.CDNService = exports.RollingHash = exports.RKAUtility = exports.QrCodeTemplate = exports.MailParser = exports.VerificationError = exports.CryptoService = exports.QrCodeDataService = exports.CommonUtils = exports.StatusesService = exports.MimeVerificationService = exports.VerificationService = exports.CloudflareService = void 0; -__exportStar(require("./types"), exports); -__exportStar(require("./utils/common"), exports); -var CloudflareService_1 = require("./services/CloudflareService"); -Object.defineProperty(exports, "CloudflareService", { enumerable: true, get: function () { return CloudflareService_1.default; } }); -var VerificationService_1 = require("./services/VerificationService"); -Object.defineProperty(exports, "VerificationService", { enumerable: true, get: function () { return VerificationService_1.default; } }); -var MimeVerificationService_1 = require("./services/MimeVerificationService"); -Object.defineProperty(exports, "MimeVerificationService", { enumerable: true, get: function () { return MimeVerificationService_1.default; } }); -var StatusesService_1 = require("./services/StatusesService"); -Object.defineProperty(exports, "StatusesService", { enumerable: true, get: function () { return StatusesService_1.default; } }); -var common_1 = require("./utils/common"); -Object.defineProperty(exports, "CommonUtils", { enumerable: true, get: function () { return common_1.default; } }); -var QrCodeDataService_1 = require("./services/QrCodeDataService"); -Object.defineProperty(exports, "QrCodeDataService", { enumerable: true, get: function () { return QrCodeDataService_1.default; } }); -var CryptoService_1 = require("./services/CryptoService"); -Object.defineProperty(exports, "CryptoService", { enumerable: true, get: function () { return CryptoService_1.default; } }); -var VerificationError_1 = require("./services/VerificationService/VerificationError"); -Object.defineProperty(exports, "VerificationError", { enumerable: true, get: function () { return VerificationError_1.default; } }); -var MailParser_1 = require("./services/MailParser"); -Object.defineProperty(exports, "MailParser", { enumerable: true, get: function () { return MailParser_1.default; } }); -var qrCodeTemplateUtils_1 = require("./utils/qrCodeTemplateUtils"); -Object.defineProperty(exports, "QrCodeTemplate", { enumerable: true, get: function () { return qrCodeTemplateUtils_1.default; } }); -var rka_1 = require("./utils/rka"); -Object.defineProperty(exports, "RKAUtility", { enumerable: true, get: function () { return rka_1.default; } }); -const rka_2 = require("./utils/rka"); -/** - * @deprecated Will be removed in version 1.0.1. Please use RKAUtility instead. - */ -exports.RollingHash = rka_2.default; -const CloudflareService_2 = require("./services/CloudflareService"); -/** - * @deprecated Will be removed in version 1.0.1. Please use CloudflareService instead. - */ -exports.CDNService = CloudflareService_2.default; diff --git a/dist/services/AeternityService.d.ts b/dist/services/AeternityService.d.ts deleted file mode 100644 index c3f6a67fe5a147bb7ba55c363ecd648e16d21125..0000000000000000000000000000000000000000 --- a/dist/services/AeternityService.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { BlockData, TxData, TxMerkleTreeData } from "../types"; -declare class AeternityService { - private _nodeUrl; - private _compilerUrl; - private _contractBytecode; - constructor(nodeUrl: string, compilerUrl: string, contractBytecode: string); - getTxDataByHash(hash: string): Promise<TxData>; - decodeContractCallData(callData: string): Promise<TxMerkleTreeData>; - getBlockData(height: number): Promise<BlockData>; - getBlockhainHeight(): Promise<number>; -} -export default AeternityService; diff --git a/dist/services/AeternityService.js b/dist/services/AeternityService.js deleted file mode 100644 index fca65706bfce2d197e36e03ecdefe314ccc7fd6e..0000000000000000000000000000000000000000 --- a/dist/services/AeternityService.js +++ /dev/null @@ -1,83 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const axios_1 = require("axios"); -class AeternityService { - constructor(nodeUrl, compilerUrl, contractBytecode) { - this._nodeUrl = ""; - this._compilerUrl = ""; - this._contractBytecode = ""; - this._nodeUrl = nodeUrl; - this._compilerUrl = compilerUrl; - this._contractBytecode = contractBytecode; - if (!nodeUrl) { - throw new Error("Aeternity node URL not defined"); - } - if (!compilerUrl) { - throw new Error("Aeternity compiler URL not defined"); - } - if (!contractBytecode) { - throw new Error("Aeternity contract bytecode not defined"); - } - } - getTxDataByHash(hash) { - return __awaiter(this, void 0, void 0, function* () { - const { data } = yield axios_1.default(`${this._nodeUrl}/v2/transactions/${hash}`); - return { - hash: data.hash, - blockHeight: data.block_height, - tx: { - callData: data.tx.call_data, - }, - }; - }); - } - decodeContractCallData(callData) { - var _a, _b, _c, _d, _e, _f; - return __awaiter(this, void 0, void 0, function* () { - const { data } = yield axios_1.default({ - url: `${this._compilerUrl}/decode-calldata/bytecode/`, - method: "POST", - headers: { - "Content-Type": "application/json", - }, - data: { - calldata: callData, - bytecode: this._contractBytecode, - }, - }); - return { - merkleeTreeFileName: (_c = (_b = (_a = data.arguments[0]) === null || _a === void 0 ? void 0 : _a.value[0]) === null || _b === void 0 ? void 0 : _b.key) === null || _c === void 0 ? void 0 : _c.value, - rootNodeHash: (_f = (_e = (_d = data.arguments[0]) === null || _d === void 0 ? void 0 : _d.value[0]) === null || _e === void 0 ? void 0 : _e.val) === null || _f === void 0 ? void 0 : _f.value, - }; - }); - } - getBlockData(height) { - return __awaiter(this, void 0, void 0, function* () { - const [blockInfo, blockchainHeight] = yield Promise.all([ - axios_1.default(`${this._nodeUrl}/v2/key-blocks/height/${height}`).then(({ data }) => data), - this.getBlockhainHeight(), - ]); - return { - blockHeight: blockInfo.height, - timestamp: blockInfo.time, - confirmationsAmount: blockchainHeight - blockInfo.height, - }; - }); - } - getBlockhainHeight() { - return __awaiter(this, void 0, void 0, function* () { - const { data } = yield axios_1.default(`${this._nodeUrl}/v2/key-blocks/current/height`); - return data.height; - }); - } -} -exports.default = AeternityService; diff --git a/dist/services/CloudflareService.d.ts b/dist/services/CloudflareService.d.ts deleted file mode 100644 index 4ac219a57bb0af6d828af35245d9108951b6fbe1..0000000000000000000000000000000000000000 --- a/dist/services/CloudflareService.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { StatusData } from "../types"; -declare class CloudflareService { - private _cdnUrl; - private _defaultBucket; - private _statusesService; - constructor(cdnUrl: string, defaultBucket: string); - fetchFile(fileName: string, bucket?: string): Promise<unknown>; - fetchStatusData(statusFileName: string): Promise<StatusData>; - readStatuses(statusId: string): Promise<Array<StatusData>>; - getMerkleTree(fileName: string): Promise<Array<string>>; -} -export default CloudflareService; diff --git a/dist/services/CloudflareService.js b/dist/services/CloudflareService.js deleted file mode 100644 index 030480634d537fb310ea72ec9d667ea3dc02d404..0000000000000000000000000000000000000000 --- a/dist/services/CloudflareService.js +++ /dev/null @@ -1,100 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const axios_1 = require("axios"); -const StatusesService_1 = require("./StatusesService"); -const common_1 = require("../utils/common"); -const STATUS_FILE_PREFIX = "bs"; -class CloudflareService { - constructor(cdnUrl, defaultBucket) { - this._cdnUrl = ""; - this._defaultBucket = ""; - if (!cdnUrl) { - throw new Error("CDN URL Must not be empty"); - } - if (!defaultBucket) { - throw new Error("Default bucket must not be empty"); - } - this._cdnUrl = cdnUrl; - this._defaultBucket = defaultBucket; - this._statusesService = new StatusesService_1.default(); - } - fetchFile(fileName, bucket = this._defaultBucket) { - return __awaiter(this, void 0, void 0, function* () { - // v?= is a dirty fix to prevent caching of the CORS error response in case file is missing. - // Because of browser caching CORS error in case of missing file, it's not possible to retrieve it when it's being uploaded. - // Dig into https://www.backblaze.com/b2/docs/cors_rules.html and fix - const { data } = yield axios_1.default(`${this._cdnUrl}/file/${bucket}/${fileName}?v=${Math.random()}`); - return data; - }); - } - fetchStatusData(statusFileName) { - return __awaiter(this, void 0, void 0, function* () { - const rawStatusData = (yield this.fetchFile(statusFileName)); - let decodedResult; - try { - decodedResult = this._statusesService.decodeStatusObject(new Uint8Array(common_1.base64ToArrayBuffer(rawStatusData.Status))); - } - catch (e) { - throw new Error("Error decoding status object"); - } - return { - status: decodedResult.statusObject, - merkleTreeId: rawStatusData.MerkleTreeID, - transactionHash: rawStatusData.TransactionID, - statusRaw: rawStatusData.Status, - statusClassName: decodedResult.className, - }; - }); - } - readStatuses(statusId) { - return __awaiter(this, void 0, void 0, function* () { - let finished = false; - let currentIndex = 1; - const statuses = []; - while (!finished) { - try { - const statusData = yield this.fetchStatusData(`${STATUS_FILE_PREFIX}_${statusId}_${currentIndex}`); - statuses.push(statusData); - currentIndex++; - } - catch (error) { - // Axios error. Finishing fetching statuses. - if (error.isAxiosError) { - finished = true; - } - else { - throw error; - } - } - } - return statuses; - }); - } - getMerkleTree(fileName) { - return __awaiter(this, void 0, void 0, function* () { - const merkleTreeFileContents = (yield this.fetchFile(fileName)); - const statusesData = yield Promise.all(merkleTreeFileContents.map((statusFileName) => { - return this.fetchStatusData(statusFileName); - })); - const statusesMap = statusesData.reduce((acc, statusData, index) => { - Object.assign(acc, { - [merkleTreeFileContents[index].toLowerCase()]: statusData, - }); - return acc; - }, {}); - return Object.keys(statusesMap) - .sort() - .map((key) => statusesMap[key].statusRaw); - }); - } -} -exports.default = CloudflareService; diff --git a/dist/services/CryptoService/CryptoServiceNode.d.ts b/dist/services/CryptoService/CryptoServiceNode.d.ts deleted file mode 100644 index a476eb05720ababc4a9b14f1c39501fb4a8e14c9..0000000000000000000000000000000000000000 --- a/dist/services/CryptoService/CryptoServiceNode.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { ICryptoService } from "./ICryptoService"; -declare const implementation: ICryptoService; -export default implementation; diff --git a/dist/services/CryptoService/CryptoServiceNode.js b/dist/services/CryptoService/CryptoServiceNode.js deleted file mode 100644 index 82bda821892df2c592a76faf833530bc867ebe2e..0000000000000000000000000000000000000000 --- a/dist/services/CryptoService/CryptoServiceNode.js +++ /dev/null @@ -1,105 +0,0 @@ -"use strict"; -// All functions are async in order to be compatible with the ICryptoService API -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const crypto = require("crypto"); -const common_1 = require("../../utils/common"); -const AES_GCM_ALGO = "aes-256-gcm"; -const encryptAESGCM = (data) => __awaiter(void 0, void 0, void 0, function* () { - const key = crypto.randomBytes(32); - const iv = crypto.randomBytes(12); - const cipher = crypto.createCipheriv(AES_GCM_ALGO, key, iv); - const encrypted = cipher.update(data, "utf8"); - cipher.final(); - const authTag = cipher.getAuthTag(); - const encryptedWithTag = Buffer.concat([ - Buffer.from(encrypted), - Buffer.from(authTag), - ]); - return { - key: key.buffer, - iv: iv.buffer, - data: encryptedWithTag, - }; -}); -const decryptAESGCM = (data, key, iv) => __awaiter(void 0, void 0, void 0, function* () { - const decipher = crypto.createDecipheriv(AES_GCM_ALGO, Buffer.from(key), Buffer.from(iv)); - const authTag = data.slice(data.byteLength - 16, data.byteLength); - const encrypted = data.slice(0, data.byteLength - 16); - let str = decipher.update(common_1.arrayBufferToBase64(encrypted), "base64", "utf8"); - decipher.setAuthTag(Buffer.from(authTag)); - str += decipher.final("utf8"); - return str; -}); -const generateRSAKeys = () => __awaiter(void 0, void 0, void 0, function* () { - const { privateKey, publicKey } = crypto.generateKeyPairSync("rsa", { - modulusLength: 4096, - publicKeyEncoding: { - type: "spki", - format: "pem", - }, - privateKeyEncoding: { - type: "pkcs8", - format: "pem", - }, - }); - return { - publicKeyPEM: publicKey, - privateKeyPEM: privateKey, - }; -}); -const encryptRSA = (publicKeyPEM, data) => __awaiter(void 0, void 0, void 0, function* () { - const encryptedData = crypto.publicEncrypt({ - key: publicKeyPEM, - padding: crypto.constants.RSA_PKCS1_OAEP_PADDING, - oaepHash: "sha256", - }, - // We convert the data string to a buffer using `Buffer.from` - Buffer.from(data)); - return encryptedData.buffer; -}); -const decryptRSA = (privateKeyPEM, data) => __awaiter(void 0, void 0, void 0, function* () { - const encryptedData = crypto.privateDecrypt({ - key: privateKeyPEM, - padding: crypto.constants.RSA_PKCS1_OAEP_PADDING, - oaepHash: "sha256", - }, - // We convert the data string to a buffer using `Buffer.from` - Buffer.from(data)); - return encryptedData.buffer; -}); -const signRSA = (privateKeyPEM, data) => __awaiter(void 0, void 0, void 0, function* () { - const sign = crypto.createSign("SHA256"); - sign.update(Buffer.from(data)); - sign.end(); - return sign.sign(privateKeyPEM).buffer; -}); -const SHA256 = (string) => __awaiter(void 0, void 0, void 0, function* () { - return crypto.createHash("sha256").update(string, "utf8").digest(); -}); -const verifyRSASignature = (publicKeyPEM, data, signature) => __awaiter(void 0, void 0, void 0, function* () { - const verify = crypto.createVerify("SHA256"); - verify.update(Buffer.from(data)); - verify.end(); - const publicKey = crypto.createPublicKey(Buffer.from(publicKeyPEM, "utf-8")); - return verify.verify(publicKey, Buffer.from(signature)); -}); -const implementation = { - encryptAESGCM, - decryptAESGCM, - generateRSAKeys, - encryptRSA, - decryptRSA, - SHA256, - signRSA, - verifyRSASignature, -}; -exports.default = implementation; diff --git a/dist/services/CryptoService/CryptoServiceWeb.d.ts b/dist/services/CryptoService/CryptoServiceWeb.d.ts deleted file mode 100644 index 7fdeee9d024facc4f65ac4610858a01e283d5b80..0000000000000000000000000000000000000000 --- a/dist/services/CryptoService/CryptoServiceWeb.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { ICryptoService } from "./ICryptoService"; -export declare const verifyRSASignature: (publicKeyPEM: string, data: ArrayBuffer, signature: ArrayBuffer) => Promise<boolean>; -declare const implementation: ICryptoService; -export default implementation; diff --git a/dist/services/CryptoService/CryptoServiceWeb.js b/dist/services/CryptoService/CryptoServiceWeb.js deleted file mode 100644 index 03f65ec6309013b44e30bbc10ea47d0eea030fff..0000000000000000000000000000000000000000 --- a/dist/services/CryptoService/CryptoServiceWeb.js +++ /dev/null @@ -1,83 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.verifyRSASignature = void 0; -const common_1 = require("../../utils/common"); -function exportKey(key) { - return __awaiter(this, void 0, void 0, function* () { - return crypto.subtle.exportKey("raw", key); - }); -} -const convertPemToBinary = (pem) => { - const lines = pem.split("\n"); - let encoded = ""; - for (let i = 0; i < lines.length; i++) { - if (lines[i].trim().length > 0 && - lines[i].indexOf("-BEGIN PRIVATE KEY-") < 0 && - lines[i].indexOf("-BEGIN PUBLIC KEY-") < 0 && - lines[i].indexOf("-END PRIVATE KEY-") < 0 && - lines[i].indexOf("-END PUBLIC KEY-") < 0) { - encoded += lines[i].trim(); - } - } - return common_1.base64ToArrayBuffer(encoded); -}; -exports.verifyRSASignature = (publicKeyPEM, data, signature) => __awaiter(void 0, void 0, void 0, function* () { - const publicKey = yield crypto.subtle.importKey("spki", convertPemToBinary(publicKeyPEM), { - name: "RSASSA-PKCS1-v1_5", - hash: "SHA-256", - }, true, ["verify"]); - return yield crypto.subtle.verify({ - name: "RSASSA-PKCS1-v1_5", - hash: "SHA-256", - }, publicKey, signature, data); -}); -const encryptAESGCM = (data) => __awaiter(void 0, void 0, void 0, function* () { - const key = yield crypto.subtle.generateKey({ - name: "AES-GCM", - length: 256, - }, true, ["encrypt", "decrypt"]); - const encoded = new TextEncoder().encode(data); - const iv = crypto.getRandomValues(new Buffer(12)); - const encrypted = yield crypto.subtle.encrypt({ name: "AES-GCM", iv: iv }, key, encoded); - return { data: encrypted, key: yield exportKey(key), iv }; -}); -const decryptAESGCM = (data, key, iv) => __awaiter(void 0, void 0, void 0, function* () { - const importedKey = yield crypto.subtle.importKey("raw", key, { - name: "AES-GCM", - length: 256, - }, true, ["encrypt", "decrypt"]); - const decrypted = yield crypto.subtle.decrypt({ name: "AES-GCM", iv: iv }, importedKey, data); - return new TextDecoder().decode(decrypted); -}); -const SHA256 = (string) => __awaiter(void 0, void 0, void 0, function* () { - const encoder = new TextEncoder(); - return yield crypto.subtle.digest("SHA-256", encoder.encode(string)); -}); -const implementation = { - encryptAESGCM, - decryptAESGCM, - verifyRSASignature: exports.verifyRSASignature, - generateRSAKeys() { - throw new Error("Surprise. Not implemented yet :)"); - }, - encryptRSA(publicKeyPEM, data) { - throw new Error("Surprise. Not implemented yet :)"); - }, - decryptRSA(privateKeyPEM, data) { - throw new Error("Surprise. Not implemented yet :)"); - }, - signRSA(privateKeyPEM, data) { - throw new Error("Surprise. Not implemented yet :)"); - }, - SHA256, -}; -exports.default = implementation; diff --git a/dist/services/CryptoService/ICryptoService.d.ts b/dist/services/CryptoService/ICryptoService.d.ts deleted file mode 100644 index 68bbc4007a06a1ff647294aa18efd05f663d5cf2..0000000000000000000000000000000000000000 --- a/dist/services/CryptoService/ICryptoService.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -export interface AESGCMOutput { - data: ArrayBuffer; - key: ArrayBuffer; - iv: ArrayBuffer; -} -export interface RSAKeys { - publicKeyPEM: string; - privateKeyPEM: string; -} -export interface ICryptoService { - encryptAESGCM: (data: string) => Promise<AESGCMOutput>; - decryptAESGCM: (data: ArrayBuffer, key: ArrayBuffer, iv: ArrayBuffer) => Promise<string>; - generateRSAKeys: () => Promise<RSAKeys>; - encryptRSA: (publicKeyPEM: string, data: ArrayBuffer) => Promise<ArrayBuffer>; - decryptRSA: (privateKeyPEM: string, data: ArrayBuffer) => Promise<ArrayBuffer>; - signRSA: (privateKeyPEM: string, data: ArrayBuffer) => Promise<ArrayBuffer>; - verifyRSASignature: (publicKeyPEM: string, data: ArrayBuffer, signature: ArrayBuffer) => Promise<boolean>; - SHA256: (string: string) => Promise<ArrayBuffer>; -} diff --git a/dist/services/CryptoService/ICryptoService.js b/dist/services/CryptoService/ICryptoService.js deleted file mode 100644 index c8ad2e549bdc6801e0d1c80b0308d4b9bd4985ce..0000000000000000000000000000000000000000 --- a/dist/services/CryptoService/ICryptoService.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/services/CryptoService/index.d.ts b/dist/services/CryptoService/index.d.ts deleted file mode 100644 index 9db9c1b552f148203b72746e7994957cce6ab74f..0000000000000000000000000000000000000000 --- a/dist/services/CryptoService/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -declare const service: import("./ICryptoService").ICryptoService; -export default service; diff --git a/dist/services/CryptoService/index.js b/dist/services/CryptoService/index.js deleted file mode 100644 index 7166789d24364d957ede7760d163da5b1eb6329c..0000000000000000000000000000000000000000 --- a/dist/services/CryptoService/index.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const CryptoServiceNode_1 = require("./CryptoServiceNode"); -const CryptoServiceWeb_1 = require("./CryptoServiceWeb"); -const service = typeof crypto !== "undefined" && crypto.subtle - ? CryptoServiceWeb_1.default - : CryptoServiceNode_1.default; -exports.default = service; diff --git a/dist/services/MailParser/MailParser.d.ts b/dist/services/MailParser/MailParser.d.ts deleted file mode 100644 index b2d517cb5ed2b9d40713742e4e6e81eba53d8654..0000000000000000000000000000000000000000 --- a/dist/services/MailParser/MailParser.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -export function fixNewLines(mime: any): any; -export function extractMessageID(mime: any): any; -export function parseMIME(mime: any): any; -export function getHeaderValue(header: any, part: any): any; -export function getGlobalHeaderValue(header: any, parts: any): any; -export function getAttachments(mime: any, parts: any): any[]; -export function getAttachment(mime: any, part: any): { - contentType: any; - base64: any; - contentId: any; -}; -export function getFilenameFromHeaders(headers: any): string; -export function extractHtmlBodyFromString(string: any): any; -declare namespace _default { - export { parseMIME }; - export { getHTML }; - export { getPlain }; -} -export default _default; -declare function getHTML(mime: any, parts: any): any; -declare function getPlain(mime: any, parts: any): any; diff --git a/dist/services/MailParser/MailParser.js b/dist/services/MailParser/MailParser.js deleted file mode 100644 index 4276403ca18e9be05fc4c3cbef211ebf5b15a80f..0000000000000000000000000000000000000000 --- a/dist/services/MailParser/MailParser.js +++ /dev/null @@ -1,376 +0,0 @@ -"use strict"; -/* eslint-disable */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.extractHtmlBodyFromString = exports.getFilenameFromHeaders = exports.getAttachment = exports.getAttachments = exports.getGlobalHeaderValue = exports.getHeaderValue = exports.parseMIME = exports.extractMessageID = exports.fixNewLines = void 0; -const libmime = require("libmime"); -const libqp = require("libqp"); -const supportedEncodings = require("./supportedEncodings").default; -// import union from "lodash/union"; -// import { Buffer } from "buffer"; -const newline = /\r\n|\r|\n/g; -const DEFAULT_ATTACHMENT_NAME = "attachment"; -const SMIMEStart = "This is a cryptographically signed message in MIME format.\r\n\r\n"; -function findAllOccurences(text, subject, from, to) { - const result = []; - let index = text.indexOf(subject, from); - if (index < 0 || index > to) { - return result; - } - result.push(index + 2); - while (true) { - index = text.indexOf(subject, index + 1); - if (index < 0 || index > to) { - break; - } - else { - result.push(index + 2); - } - } - return result; -} -function findFirstBoundary(body, from, to) { - if (from >= to) { - return null; - } - const search = "\r\n--"; - let start = body.indexOf(search, from); - if (start < 0 || start > to) { - return null; - } - start += 2; - const end = body.indexOf("\r\n", start); - if (end < 0 || end > to) { - return null; - } - const boundary = body.substring(start, end); - const boundaryEnd = boundary + "--\r\n"; - const startBoundaryEnd = body.indexOf(boundaryEnd, end); - if (startBoundaryEnd < 0 || startBoundaryEnd > to) { - return findFirstBoundary(body, end + 2, to); - } - return boundary; -} -function calculateParts(body, from, to, previousBondary) { - let boundary = findFirstBoundary(body, from, to); - if (boundary == null) { - return [{ indices: { from, to }, boundary: previousBondary, leaf: true }]; - } - const realBoundary = boundary; - boundary = "\r\n" + boundary; - const boundaryPairs = []; - const boundaryIndices = findAllOccurences(body, boundary, from, to); - const boundaryIndicesLength = boundaryIndices.length; - for (let i = 0; i < boundaryIndicesLength; i++) { - const startBoundary = boundaryIndices[i]; - const endBoundary = body.indexOf("\r\n", startBoundary); - boundaryPairs.push({ start: startBoundary, end: endBoundary }); - } - let bodies = []; - if (previousBondary !== null) { - bodies.push({ - indices: { from, to }, - boundary: previousBondary, - leaf: false, - }); - } - for (let i = 0; i < boundaryIndicesLength - 1; i++) { - const firstPair = boundaryPairs[i]; - const secondPair = boundaryPairs[i + 1]; - const newFrom = firstPair.end + 2; - const newTo = secondPair.start - 2; - const bodyForBoundary = calculateParts(body, newFrom, newTo, realBoundary); - bodies = bodies.concat(bodyForBoundary); - } - return bodies; -} -function parsePartsHeaders(mimeBody, parts) { - const result = []; - for (let i = 0; i < parts.length; i++) { - const part = parts[i]; - const indices = part["indices"]; - let headersEnd = mimeBody - .substring(indices.from, indices.to) - .indexOf("\r\n\r\n"); - if (headersEnd < 0) { - headersEnd = indices.from; - } - else { - headersEnd = headersEnd + indices.from + 4; - } - part["indices"].headersEnd = headersEnd; - part["headers"] = libmime.decodeHeaders(mimeBody.substring(indices.from, headersEnd)); - result.push(part); - } - return result; -} -function fixNewLines(mime) { - return mime.replace(newline, "\r\n"); -} -exports.fixNewLines = fixNewLines; -function extractMessageID(mime) { - if (mime.startsWith("\r\n")) { - mime = mime.substring(2); //should not happen - } - const headersEndIndex = mime.indexOf("\r\n\r\n"); //the first empty line - if (headersEndIndex < 0) { - return null; - } - const mimeHeaders = mime.substring(0, headersEndIndex); - const headers = libmime.decodeHeaders(mimeHeaders); - let messageId = headers["message-id"]; - if (Array.isArray(messageId) && messageId.length > 0) { - messageId = messageId[0]; - } - if (messageId && typeof messageId === "string") { - messageId = messageId.replace(/^</, "").replace(/>$/, ""); - return messageId; - } - return null; -} -exports.extractMessageID = extractMessageID; -function parseMIME(mime) { - let mimeStart = 0; - const headersEnd = mime.indexOf("\r\n\r\n"); //the first empty line - let mimeBody = ""; - if (headersEnd < 0 && mime.startsWith("\r\n")) { - mime = mime.substring(2); //should not happen - mimeBody = mime; - mimeStart = 0; - } - else { - mimeBody = mime.substring(headersEnd + 4); - mimeStart = headersEnd + 4; - } - const headers = libmime.decodeHeaders(mime.substring(0, headersEnd)); - const indexOfSMIME = mimeBody.indexOf(SMIMEStart); - if (indexOfSMIME >= 0) { - mimeBody = mimeBody.substring(indexOfSMIME + SMIMEStart.length); - mimeStart += indexOfSMIME + SMIMEStart.length; - } - mimeBody = "\r\n" + mimeBody + "\r\n"; - const mimeBodyLen = mimeBody.length - 1; - let parts = calculateParts(mimeBody, 0, mimeBodyLen, null); - parts = parsePartsHeaders(mimeBody, parts); - for (let i = 0; i < parts.length; i++) { - parts[i].indices.from = parts[i].indices.from + (mimeStart - 2); - parts[i].indices.headersEnd = parts[i].indices.headersEnd + (mimeStart - 2); - parts[i].indices.to = parts[i].indices.to + (mimeStart - 2); - } - parts.push({ - indices: { from: 0, to: mime.length, headersEnd }, - headers, - boundary: "mimemessage", - leaf: false, - }); - return parts; -} -exports.parseMIME = parseMIME; -function getHeaderValue(header, part) { - if (part.headers && part.headers[header] && part.headers[header].length) { - return part.headers[header]; - } - return null; -} -exports.getHeaderValue = getHeaderValue; -function getGlobalHeaderValue(header, parts) { - for (let i = 0; i < parts.length; i++) { - if (parts[i].boundary === "mimemessage") { - return getHeaderValue(header, parts[i]); - } - } - return null; -} -exports.getGlobalHeaderValue = getGlobalHeaderValue; -function getBody(mime, part) { - if (part.indices === null || part.indices === undefined) { - return null; - } - const indices = part.indices; - return mime.substring(indices.headersEnd, indices.to); -} -function decodeMimeBody(descriptor, mimeString) { - const mimeBody = mimeString.slice(descriptor.indices.headersEnd, descriptor.indices.to); - let contentTransferEncoding = getHeaderValue("content-transfer-encoding", descriptor); - if (contentTransferEncoding) { - contentTransferEncoding = contentTransferEncoding[0]; - } - else { - return mimeBody; - } - let charset = "utf8"; - let contentType = getHeaderValue("content-type", descriptor); - if (contentType) { - contentType = contentType[0]; - const parsedContentType = libmime.parseHeaderValue(contentType); - //console.log("Charset candidate: " + parsedContentType.params.charset); - if (parsedContentType && - parsedContentType.params && - parsedContentType.params.charset) { - if (parsedContentType.params.charset.toLowerCase() === "us-ascii") { - charset = "ascii"; - } - else if (Buffer.isEncoding(parsedContentType.params.charset)) { - charset = parsedContentType.params.charset; - } - else { - //console.log(parsedContentType.params.charset); - //console.log(supportedEncodings[parsedContentType.params.charset]); - if (supportedEncodings[parsedContentType.params.charset] != "") { - charset = supportedEncodings[parsedContentType.params.charset]; - } - //TODO log the charset and make sure we can support it - } - } - } - //console.log("Charset for decoding: " + charset); - if (contentTransferEncoding.toLowerCase() === "quoted-printable") { - const buff = libqp.decode(mimeBody); - if (supportedEncodings[charset] != "") { - var decoder = new TextDecoder(charset); - return decoder.decode(buff.buffer); - } - return buff.toString(charset); - } - else if (contentTransferEncoding.toLowerCase() === "base64") { - const buff = Buffer.from(mimeBody, "base64"); - if (supportedEncodings[charset] != "") { - var decoder = new TextDecoder(charset); - return decoder.decode(buff.buffer); - } - return buff.toString(charset); - } - return mimeBody; -} -function getHTML(mime, parts) { - let html; - let htmlPart = null; - for (let i = 0; i < parts.length; i++) { - if (parts[i].boundary === "mimemessage") { - continue; - } - let contentType = getHeaderValue("content-type", parts[i]); - if (contentType === null || contentType === undefined) { - continue; - } - contentType = contentType[0]; - if (contentType.indexOf("text/html") >= 0) { - htmlPart = parts[i]; - break; - } - } - html = decodeMimeBody(htmlPart, mime); - return html; -} -function getPlain(mime, parts) { - let plain; - let plainPart = null; - for (let i = 0; i < parts.length; i++) { - let contentType = getHeaderValue("content-type", parts[i]); - if (contentType === null || contentType === undefined) { - continue; - } - contentType = contentType[0]; - if (contentType.indexOf("text/plain") >= 0) { - plainPart = parts[i]; - break; - } - } - if (!plainPart) { - return ""; - } - plain = decodeMimeBody(plainPart, mime); - return plain; -} -function getAttachments(mime, parts) { - const attachments = []; - for (let i = 0; i < parts.length; i++) { - let contentDisposition = getHeaderValue("content-disposition", parts[i]); - if (contentDisposition === null || contentDisposition === undefined) { - continue; - } - contentDisposition = contentDisposition[0]; - if (contentDisposition.indexOf("attachment") >= 0) { - attachments.push(parts[i]); - } - } - return attachments; -} -exports.getAttachments = getAttachments; -function getAttachment(mime, part) { - let contentId = null; - let contentType = getHeaderValue("content-type", part); - if (contentType === null || contentType === undefined) { - return null; - } - contentType = contentType[0]; - let contentTransferEncoding = getHeaderValue("content-transfer-encoding", part); - if (contentTransferEncoding) { - contentTransferEncoding = contentTransferEncoding[0]; - } - else { - return null; - } - let base64; - if (contentTransferEncoding.toLowerCase() === "base64") { - base64 = getBody(mime, part).replace(newline, ""); - } - else { - const body = decodeMimeBody(part, mime); - base64 = window.btoa(body); - } - contentId = getHeaderValue("content-id", part); - if (contentId) { - contentId = contentId[0]; - } - return { contentType, base64, contentId }; -} -exports.getAttachment = getAttachment; -/** - * Function extracts file name from content type header - * @param headers - * @returns {string} ('file.txt') - */ -exports.getFilenameFromHeaders = (headers) => { - const headersToSearch = ["content-type", "content-disposition"]; - const filename = headers && - Object.keys(headers) - .filter((key) => headersToSearch.includes(key)) - .reduce((result, key) => { - const headerValue = libmime.parseHeaderValue(headers[key][0]); - return result || headerValue.params.name || headerValue.params.filename; - }, ""); - return filename || DEFAULT_ATTACHMENT_NAME; -}; -// export const splitParticipants = participantsList => { -// if (!participantsList) { -// return []; -// } -// -// const participants = participantsList.map(participants => -// participants.split(",").map(p => p.trim()) -// ); -// return union.apply(null, participants); -// }; -/** - * Function extracts all tags within <body></body> from provided string - * and removes whitespaces between tags and HTML comments. - * @param string - * @returns {*} - */ -exports.extractHtmlBodyFromString = (string) => { - const extractBodyRegex = /<body.*?>([\s\S]+)<\/body>/gm; - const bodyMatch = extractBodyRegex.exec(string); - let body = string; - if (bodyMatch && bodyMatch[1]) { - body = bodyMatch[1]; - } - return body - .replace(/>\s+</gm, "><") - .replace(/<!--[\s\S]*?-->/gm, "") - .trim(); -}; -exports.default = { - parseMIME, - getHTML, - getPlain, -}; diff --git a/dist/services/MailParser/index.d.ts b/dist/services/MailParser/index.d.ts deleted file mode 100644 index 270da436503b5cb06c71fb4ebf33f96fd97e8de9..0000000000000000000000000000000000000000 --- a/dist/services/MailParser/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export default MailParser; -import MailParser from "./MailParser"; diff --git a/dist/services/MailParser/index.js b/dist/services/MailParser/index.js deleted file mode 100644 index e7532ba62c6f5ca8f838cc4d2c6dd0a037d735ab..0000000000000000000000000000000000000000 --- a/dist/services/MailParser/index.js +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const MailParser_1 = require("./MailParser"); -exports.default = MailParser_1.default; diff --git a/dist/services/MailParser/supportedEncodings.d.ts b/dist/services/MailParser/supportedEncodings.d.ts deleted file mode 100644 index 101507bdd9f846dc2d87a5c6fb1d2e17af09d553..0000000000000000000000000000000000000000 --- a/dist/services/MailParser/supportedEncodings.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export default supportedEncodings; -declare const supportedEncodings: typeof supportedEncodings; diff --git a/dist/services/MailParser/supportedEncodings.js b/dist/services/MailParser/supportedEncodings.js deleted file mode 100644 index 17300ee839e1adc9924930fdef0c3ffb7be27088..0000000000000000000000000000000000000000 --- a/dist/services/MailParser/supportedEncodings.js +++ /dev/null @@ -1,218 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const supportedEncodings = {}; -supportedEncodings["unicode-1-1-utf-8"] = "utf-8"; -supportedEncodings["utf-8"] = "utf-8"; -supportedEncodings["utf8"] = "utf-8"; -supportedEncodings["866"] = "ibm866"; -supportedEncodings["cp866"] = "ibm866"; -supportedEncodings["csibm866"] = "ibm866"; -supportedEncodings["ibm866"] = "ibm866"; -supportedEncodings["csisolatin2"] = "iso-8859-2"; -supportedEncodings["iso-8859-2"] = "iso-8859-2"; -supportedEncodings["iso-ir-101"] = "iso-8859-2"; -supportedEncodings["iso8859-2"] = "iso-8859-2"; -supportedEncodings["iso88592"] = "iso-8859-2"; -supportedEncodings["iso_8859-2"] = "iso-8859-2"; -supportedEncodings["iso_8859-2:1987"] = "iso-8859-2"; -supportedEncodings["l2"] = "iso-8859-2"; -supportedEncodings["latin2"] = "iso-8859-2"; -supportedEncodings["csisolatin3"] = "iso-8859-3"; -supportedEncodings["iso-8859-3"] = "iso-8859-3"; -supportedEncodings["iso-ir-109"] = "iso-8859-3"; -supportedEncodings["iso8859-3"] = "iso-8859-3"; -supportedEncodings["iso88593"] = "iso-8859-3"; -supportedEncodings["iso_8859-3"] = "iso-8859-3"; -supportedEncodings["iso_8859-3:1988"] = "iso-8859-3"; -supportedEncodings["l3"] = "iso-8859-3"; -supportedEncodings["latin3"] = "iso-8859-3"; -supportedEncodings["csisolatin4"] = "iso-8859-4"; -supportedEncodings["iso-8859-4"] = "iso-8859-4"; -supportedEncodings["iso-ir-110"] = "iso-8859-4"; -supportedEncodings["iso8859-4"] = "iso-8859-4"; -supportedEncodings["iso88594"] = "iso-8859-4"; -supportedEncodings["iso_8859-4"] = "iso-8859-4"; -supportedEncodings["iso_8859-4:1988"] = "iso-8859-4"; -supportedEncodings["l4"] = "iso-8859-4"; -supportedEncodings["latin4"] = "iso-8859-4"; -supportedEncodings["csisolatincyrillic"] = "iso-8859-5"; -supportedEncodings["cyrillic"] = "iso-8859-5"; -supportedEncodings["iso-8859-5"] = "iso-8859-5"; -supportedEncodings["iso-ir-144"] = "iso-8859-5"; -supportedEncodings["iso88595"] = "iso-8859-5"; -supportedEncodings["iso_8859-5"] = "iso-8859-5"; -supportedEncodings["iso_8859-5:1988"] = "iso-8859-5"; -supportedEncodings["arabic"] = "iso-8859-6"; -supportedEncodings["asmo-708"] = "iso-8859-6"; -supportedEncodings["csiso88596e"] = "iso-8859-6"; -supportedEncodings["csiso88596i"] = "iso-8859-6"; -supportedEncodings["csisolatinarabic"] = "iso-8859-6"; -supportedEncodings["ecma-114"] = "iso-8859-6"; -supportedEncodings["iso-8859-6"] = "iso-8859-6"; -supportedEncodings["iso-8859-6-e"] = "iso-8859-6"; -supportedEncodings["iso-8859-6-i"] = "iso-8859-6"; -supportedEncodings["iso-ir-127"] = "iso-8859-6"; -supportedEncodings["iso8859-6"] = "iso-8859-6"; -supportedEncodings["iso88596"] = "iso-8859-6"; -supportedEncodings["iso_8859-6"] = "iso-8859-6"; -supportedEncodings["iso_8859-6:1987"] = "iso-8859-6"; -supportedEncodings["csisolatingreek"] = "iso-8859-7"; -supportedEncodings["ecma-118"] = "iso-8859-7"; -supportedEncodings["elot_928"] = "iso-8859-7"; -supportedEncodings["greek"] = "iso-8859-7"; -supportedEncodings["greek8"] = "iso-8859-7"; -supportedEncodings["iso-8859-7"] = "iso-8859-7"; -supportedEncodings["iso-ir-126"] = "iso-8859-7"; -supportedEncodings["iso8859-7"] = "iso-8859-7"; -supportedEncodings["iso88597"] = "iso-8859-7"; -supportedEncodings["iso_8859-7"] = "iso-8859-7"; -supportedEncodings["iso_8859-7:1987"] = "iso-8859-7"; -supportedEncodings["sun_eu_greek"] = "iso-8859-7"; -supportedEncodings["csiso88598e"] = "iso-8859-8"; -supportedEncodings["csisolatinhebrew"] = "iso-8859-8"; -supportedEncodings["hebrew"] = "iso-8859-8"; -supportedEncodings["iso-8859-8"] = "iso-8859-8"; -supportedEncodings["iso-8859-8-e"] = "iso-8859-8"; -supportedEncodings["iso-ir-138"] = "iso-8859-8"; -supportedEncodings["iso8859-8"] = "iso-8859-8"; -supportedEncodings["iso88598"] = "iso-8859-8"; -supportedEncodings["iso_8859-8"] = "iso-8859-8"; -supportedEncodings["iso_8859-8:1988"] = "iso-8859-8"; -supportedEncodings["visual"] = "iso-8859-8"; -supportedEncodings["csiso88598i"] = "iso-8859-8i"; -supportedEncodings["iso-8859-8-i"] = "iso-8859-8i"; -supportedEncodings["logical"] = "iso-8859-8i"; -supportedEncodings["csisolatin6"] = "iso-8859-10"; -supportedEncodings["iso-8859-10"] = "iso-8859-10"; -supportedEncodings["iso-ir-157"] = "iso-8859-10"; -supportedEncodings["iso8859-10"] = "iso-8859-10"; -supportedEncodings["iso885910"] = "iso-8859-10"; -supportedEncodings["l6"] = "iso-8859-10"; -supportedEncodings["latin6"] = "iso-8859-10"; -supportedEncodings["iso-8859-13"] = "iso-8859-13"; -supportedEncodings["iso8859-13"] = "iso-8859-13"; -supportedEncodings["iso885913"] = "iso-8859-13"; -supportedEncodings["iso-8859-14"] = "iso-8859-14"; -supportedEncodings["iso8859-14"] = "iso-8859-14"; -supportedEncodings["iso885914"] = "iso-8859-14"; -supportedEncodings["csisolatin9"] = "iso-8859-15"; -supportedEncodings["iso-8859-15"] = "iso-8859-15"; -supportedEncodings["iso8859-15"] = "iso-8859-15"; -supportedEncodings["iso885915"] = "iso-8859-15"; -supportedEncodings["l9"] = "iso-8859-15"; -supportedEncodings["latin9"] = "iso-8859-15"; -supportedEncodings["iso-8859-16"] = "iso-8859-16"; -supportedEncodings["cskoi8r"] = "koi8-r"; -supportedEncodings["koi"] = "koi8-r"; -supportedEncodings["koi8"] = "koi8-r"; -supportedEncodings["koi8-r"] = "koi8-r"; -supportedEncodings["koi8_r"] = "koi8-r"; -supportedEncodings["koi8-u"] = "koi8-u"; -supportedEncodings["csmacintosh"] = "macintosh"; -supportedEncodings["mac"] = "macintosh"; -supportedEncodings["macintosh"] = "macintosh"; -supportedEncodings["x-mac-roman"] = "macintosh"; -supportedEncodings["dos-874"] = "windows-874"; -supportedEncodings["iso-8859-11"] = "windows-874"; -supportedEncodings["iso8859-11"] = "windows-874"; -supportedEncodings["iso885911"] = "windows-874"; -supportedEncodings["tis-620"] = "windows-874"; -supportedEncodings["windows-874"] = "windows-874"; -supportedEncodings["cp1250"] = "windows-1250"; -supportedEncodings["windows-1250"] = "windows-1250"; -supportedEncodings["x-cp1250"] = "windows-1250"; -supportedEncodings["cp1251"] = "windows-1251"; -supportedEncodings["windows-1251"] = "windows-1251"; -supportedEncodings["x-cp1251"] = "windows-1251"; -supportedEncodings["ansi_x3.4-1968"] = "windows-1252"; -supportedEncodings["ascii"] = "windows-1252"; -supportedEncodings["cp1252"] = "windows-1252"; -supportedEncodings["cp819"] = "windows-1252"; -supportedEncodings["csisolatin1"] = "windows-1252"; -supportedEncodings["ibm819"] = "windows-1252"; -supportedEncodings["iso-8859-1"] = "windows-1252"; -supportedEncodings["iso-ir-100"] = "windows-1252"; -supportedEncodings["iso8859-1"] = "windows-1252"; -supportedEncodings["iso88591"] = "windows-1252"; -supportedEncodings["iso_8859-1"] = "windows-1252"; -supportedEncodings["iso_8859-1:1987"] = "windows-1252"; -supportedEncodings["l1"] = "windows-1252"; -supportedEncodings["latin1"] = "windows-1252"; -supportedEncodings["us-ascii"] = "windows-1252"; -supportedEncodings["windows-1252"] = "windows-1252"; -supportedEncodings["x-cp1252"] = "windows-1252"; -supportedEncodings["cp1253"] = "windows-1253"; -supportedEncodings["windows-1253"] = "windows-1253"; -supportedEncodings["x-cp1253"] = "windows-1253"; -supportedEncodings["cp1254"] = "windows-1254"; -supportedEncodings["csisolatin5"] = "windows-1254"; -supportedEncodings["iso-8859-9"] = "windows-1254"; -supportedEncodings["iso-ir-148"] = "windows-1254"; -supportedEncodings["iso8859-9"] = "windows-1254"; -supportedEncodings["iso88599"] = "windows-1254"; -supportedEncodings["iso_8859-9"] = "windows-1254"; -supportedEncodings["iso_8859-9:1989"] = "windows-1254"; -supportedEncodings["l5"] = "windows-1254"; -supportedEncodings["latin5"] = "windows-1254"; -supportedEncodings["windows-1254"] = "windows-1254"; -supportedEncodings["x-cp1254"] = "windows-1254"; -supportedEncodings["cp1255"] = "windows-1255"; -supportedEncodings["windows-1255"] = "windows-1255"; -supportedEncodings["x-cp1255"] = "windows-1255"; -supportedEncodings["cp1256"] = "windows-1256"; -supportedEncodings["windows-1256"] = "windows-1256"; -supportedEncodings["x-cp1256"] = "windows-1256"; -supportedEncodings["cp1257"] = "windows-1257"; -supportedEncodings["windows-1257"] = "windows-1257"; -supportedEncodings["x-cp1257"] = "windows-1257"; -supportedEncodings["cp1258"] = "windows-1258"; -supportedEncodings["windows-1258"] = "windows-1258"; -supportedEncodings["x-cp1258"] = "windows-1258"; -supportedEncodings["x-mac-cyrillic"] = "x-mac-cyrillic"; -supportedEncodings["x-mac-ukrainian"] = "x-mac-cyrillic"; -supportedEncodings["chinese"] = "gbk"; -supportedEncodings["csgb2312"] = "gbk"; -supportedEncodings["csiso58gb231280"] = "gbk"; -supportedEncodings["gb2312"] = "gbk"; -supportedEncodings["gb_2312"] = "gbk"; -supportedEncodings["gb_2312-80"] = "gbk"; -supportedEncodings["gbk"] = "gbk"; -supportedEncodings["iso-ir-58"] = "gbk"; -supportedEncodings["x-gbk"] = "gbk"; -supportedEncodings["gb18030"] = "gb18030"; -supportedEncodings["hz-gb-2312"] = "hz-gb-2312"; -supportedEncodings["big5"] = "big5"; -supportedEncodings["big5-hkscs"] = "big5"; -supportedEncodings["cn-big5"] = "big5"; -supportedEncodings["csbig5"] = "big5"; -supportedEncodings["x-x-big5"] = "big5"; -supportedEncodings["cseucpkdfmtjapanese"] = "euc-jp"; -supportedEncodings["euc-jp"] = "euc-jp"; -supportedEncodings["x-euc-jp"] = "euc-jp"; -supportedEncodings["csiso2022jp"] = "iso-2022-jp"; -supportedEncodings["csshiftjis"] = "shift-jis"; -supportedEncodings["ms_kanji"] = "shift-jis"; -supportedEncodings["shift-jis"] = "shift-jis"; -supportedEncodings["shift_jis"] = "shift-jis"; -supportedEncodings["sjis"] = "shift-jis"; -supportedEncodings["windows-31j"] = "shift-jis"; -supportedEncodings["x-sjis"] = "shift-jis"; -supportedEncodings["cseuckr"] = "euc-kr"; -supportedEncodings["csksc56011987"] = "euc-kr"; -supportedEncodings["euc-kr"] = "euc-kr"; -supportedEncodings["iso-ir-149"] = "euc-kr"; -supportedEncodings["korean"] = "euc-kr"; -supportedEncodings["ks_c_5601-1987"] = "euc-kr"; -supportedEncodings["ks_c_5601-1989"] = "euc-kr"; -supportedEncodings["ksc5601"] = "euc-kr"; -supportedEncodings["ksc_5601"] = "euc-kr"; -supportedEncodings["windows-949"] = "euc-kr"; -supportedEncodings["csiso2022kr"] = "iso-2022-kr"; -supportedEncodings["iso-2022-kr"] = "iso-2022-kr"; -supportedEncodings["utf-16be"] = "utf-16be"; -supportedEncodings["utf-16"] = "utf-16le"; -supportedEncodings["utf-16le"] = "utf-16le"; -supportedEncodings["x-user-defined"] = "x-user-defined"; -supportedEncodings["iso-2022-cn"] = "replacement"; -supportedEncodings["iso-2022-cn-ext"] = "replacement"; -exports.default = supportedEncodings; diff --git a/dist/services/MimeVerificationService/MimeVerificationService.d.ts b/dist/services/MimeVerificationService/MimeVerificationService.d.ts deleted file mode 100644 index 1950ec939c54cc0ad198a28c53105e85f4cd0df9..0000000000000000000000000000000000000000 --- a/dist/services/MimeVerificationService/MimeVerificationService.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -declare const _default: { - normalizeVendorHtml: (htmlString: string, vendor: string) => string; - getMimeHtmlAndPlainParts: (mimeString: string) => { - htmlPart: string; - plainPart: string; - }; - preparePartsForSigning: (parts: string[], attachmentsHashes: string[]) => Promise<string>; - prepareMimeForPartsVerification: (mimeString: string, attachmentsHashes: string[], senderSystem: string, sourceHtmlRabinFingerprint: string, sourceHtmlSize: number, sourcePlainRabinFingerprint: string, sourcePlainSize: number) => Promise<string>; - getNormalizedMimeParts: (mimeString: string, senderSystem: string) => { - htmlPart: string; - plainPart: string; - }; - normalizePlainPart: (text: string) => string; -}; -export default _default; diff --git a/dist/services/MimeVerificationService/MimeVerificationService.js b/dist/services/MimeVerificationService/MimeVerificationService.js deleted file mode 100644 index 7c7d62478252d1b6c3dc1481cd89f338ea6d8b07..0000000000000000000000000000000000000000 --- a/dist/services/MimeVerificationService/MimeVerificationService.js +++ /dev/null @@ -1,144 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const normalizationStrategies_1 = require("./normalizationStrategies"); -const MailParser_1 = require("../MailParser/MailParser"); -const CryptoService_1 = require("../CryptoService"); -const StatusesService_1 = require("../StatusesService"); -const index_1 = require("./index"); -const rka_1 = require("../../utils/rka"); -const common_1 = require("../../utils/common"); -const VerificationError_1 = require("../VerificationService/VerificationError"); -const stringUtils_1 = require("../../utils/stringUtils"); -const utils_1 = require("./utils"); -const vendorAmendingFunctions = { - [StatusesService_1.EMAIL_VENDORS.GMAIL]: normalizationStrategies_1.amendGmailNodes, - [StatusesService_1.EMAIL_VENDORS.OUTLOOK]: normalizationStrategies_1.amendOutlookNodes, -}; -const vendorPruningFunctions = { - [StatusesService_1.EMAIL_VENDORS.GMAIL]: normalizationStrategies_1.pruneGmailElement, - [StatusesService_1.EMAIL_VENDORS.OUTLOOK]: normalizationStrategies_1.pruneOutlookElement, -}; -const vendorAttributesCleanupFunctions = { - [StatusesService_1.EMAIL_VENDORS.GMAIL]: normalizationStrategies_1.cleanupGMailElementAttributes, - [StatusesService_1.EMAIL_VENDORS.OUTLOOK]: normalizationStrategies_1.cleanupOutlookElementAttributes, -}; -const vendorPrintingFunctions = { - [StatusesService_1.EMAIL_VENDORS.OUTLOOK]: utils_1.printOutlookElement, -}; -// Load JSDOM dynamically for Node env only, because built CRA is crashing with it -let JSDOM; -const loadJSDOM = () => __awaiter(void 0, void 0, void 0, function* () { - if (!JSDOM) { - JSDOM = (yield Promise.resolve().then(() => require("jsdom"))).JSDOM; - } -}); -typeof window === "undefined" && loadJSDOM(); -const prepareMimeForPartsVerification = (mimeString, attachmentsHashes, senderSystem, sourceHtmlRabinFingerprint, sourceHtmlSize, sourcePlainRabinFingerprint, sourcePlainSize) => __awaiter(void 0, void 0, void 0, function* () { - const { htmlPart, plainPart } = getNormalizedMimeParts(mimeString, senderSystem); - const originalHtml = findSubstring(htmlPart, sourceHtmlRabinFingerprint, sourceHtmlSize); - if (originalHtml === null) { - throw new VerificationError_1.default("Unable to verify MIME. Source HTML part was not found."); - } - const originalPlain = findSubstring(plainPart, sourcePlainRabinFingerprint, sourcePlainSize); - if (originalPlain === null) { - throw new VerificationError_1.default("Unable to verify MIME. Source Plain part was not found."); - } - return yield index_1.default.preparePartsForSigning([originalHtml, originalPlain], attachmentsHashes); -}); -const getNormalizedMimeParts = (mimeString, senderSystem) => { - const { htmlPart, plainPart, } = index_1.default.getMimeHtmlAndPlainParts(mimeString); - const normalizedHtmlPart = index_1.default.normalizeVendorHtml(htmlPart, senderSystem); - const normalizedPlainPart = stringUtils_1.removeSpacesAndLinebreaks(plainPart); - return { - htmlPart: normalizedHtmlPart, - plainPart: normalizedPlainPart, - }; -}; -const findSubstring = (string, rabinFingerprint, substringSize) => { - if (!string.length) { - return ""; - } - const startingIndex = rka_1.default.searchFingerprintInText(string, rabinFingerprint, substringSize); - if (startingIndex === -1) { - return null; - } - return string.slice(startingIndex, startingIndex + substringSize); -}; -const getMimeHtmlAndPlainParts = (mimeString) => { - mimeString = MailParser_1.fixNewLines(mimeString); - const mimeParts = MailParser_1.default.parseMIME(mimeString); - // TODO: check, whether we need to support 2+ html/plain MIME parts. - const htmlPart = MailParser_1.default.getHTML(mimeString, mimeParts); - const plainPart = MailParser_1.default.getPlain(mimeString, mimeParts); - return { - htmlPart, - plainPart, - }; -}; -/** - * @param parts - html and plain parts strings - * @param attachmentsHashes - base64 strings of the attachments hashes - */ -const preparePartsForSigning = (parts, attachmentsHashes) => __awaiter(void 0, void 0, void 0, function* () { - let hashedParts = yield Promise.all(parts.map((part) => __awaiter(void 0, void 0, void 0, function* () { - return common_1.arrayBufferToBase64(yield CryptoService_1.default.SHA256(part)); - }))); - hashedParts = [...hashedParts, ...attachmentsHashes]; - return hashedParts.sort().join("\n"); -}); -const normalizeVendorHtml = (htmlString, vendor) => { - let document; - if (typeof DOMParser !== "undefined") { - const parser = new DOMParser(); - document = parser.parseFromString(htmlString, "text/html"); - } - else { - const { window } = new JSDOM(htmlString); - document = window.document; - } - const mimeBody = document.body; - const amendNodesFunction = vendorAmendingFunctions[vendor]; - if (amendNodesFunction) { - amendNodesFunction(document); - } - /** - * Remove unnecessary nodes - */ - const elementPruningFunction = vendorPruningFunctions[vendor]; - if (!elementPruningFunction) { - throw new Error(`Vendor "${vendor}" is not supported. Please, develop a pruning function for it.`); - } - utils_1.pruneHtmlNode(document, elementPruningFunction); - /** - * Cleanup unnecessary attributes of nodes - */ - const elementAttributesCleanupFunction = vendorAttributesCleanupFunctions[vendor]; - if (elementAttributesCleanupFunction) { - utils_1.cleanupHtmlNodeAttributes(document, elementAttributesCleanupFunction); - } - /** - * Print nodes - */ - const vendorPrintFunction = vendorPrintingFunctions[vendor]; - return utils_1.printHtmlChildren(mimeBody, vendorPrintFunction, 0); -}; -const normalizePlainPart = (text) => { - return stringUtils_1.removeSpacesAndLinebreaks(text); -}; -exports.default = { - normalizeVendorHtml, - getMimeHtmlAndPlainParts, - preparePartsForSigning, - prepareMimeForPartsVerification, - getNormalizedMimeParts, - normalizePlainPart, -}; diff --git a/dist/services/MimeVerificationService/constants.d.ts b/dist/services/MimeVerificationService/constants.d.ts deleted file mode 100644 index 4a520bb69e428ac729347a6bc91e3fee91e9ec06..0000000000000000000000000000000000000000 --- a/dist/services/MimeVerificationService/constants.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare const ELEMENT_NODE = 1; -export declare const TEXT_NODE = 3; -export declare const DOCUMENT_NODE = 9; diff --git a/dist/services/MimeVerificationService/constants.js b/dist/services/MimeVerificationService/constants.js deleted file mode 100644 index e9c1bf0cc929a004edaad04629ecf623d53ba94f..0000000000000000000000000000000000000000 --- a/dist/services/MimeVerificationService/constants.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.DOCUMENT_NODE = exports.TEXT_NODE = exports.ELEMENT_NODE = void 0; -exports.ELEMENT_NODE = 1; -exports.TEXT_NODE = 3; -exports.DOCUMENT_NODE = 9; diff --git a/dist/services/MimeVerificationService/index.d.ts b/dist/services/MimeVerificationService/index.d.ts deleted file mode 100644 index f4b50dea98a6bda8fa8126838aa1bbd4c6e83468..0000000000000000000000000000000000000000 --- a/dist/services/MimeVerificationService/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import MimeVerificationService from "./MimeVerificationService"; -export default MimeVerificationService; diff --git a/dist/services/MimeVerificationService/index.js b/dist/services/MimeVerificationService/index.js deleted file mode 100644 index 72233fee90db79ed77a6307312aa619bef36e67f..0000000000000000000000000000000000000000 --- a/dist/services/MimeVerificationService/index.js +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const MimeVerificationService_1 = require("./MimeVerificationService"); -exports.default = MimeVerificationService_1.default; diff --git a/dist/services/MimeVerificationService/normalizationStrategies.d.ts b/dist/services/MimeVerificationService/normalizationStrategies.d.ts deleted file mode 100644 index 6eb64216937bb4e03730bb151b5f4226c40f5f88..0000000000000000000000000000000000000000 --- a/dist/services/MimeVerificationService/normalizationStrategies.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -export declare const pruneGmailElement: (element: HTMLElement) => boolean; -/** - * Returns true if element should be completely removed - * @param element - */ -export declare const pruneOutlookElement: (element: HTMLElement) => boolean; -export declare const amendOutlookNodes: (document: HTMLDocument) => void; -export declare const amendGmailNodes: (document: HTMLDocument) => void; -export declare const cleanupGMailElementAttributes: (element: HTMLElement) => void; -export declare const cleanupOutlookElementAttributes: (element: HTMLElement) => void; diff --git a/dist/services/MimeVerificationService/normalizationStrategies.js b/dist/services/MimeVerificationService/normalizationStrategies.js deleted file mode 100644 index 2491cccb5fd9ea2b88fc30b639f5b8dfded01c5a..0000000000000000000000000000000000000000 --- a/dist/services/MimeVerificationService/normalizationStrategies.js +++ /dev/null @@ -1,149 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.cleanupOutlookElementAttributes = exports.cleanupGMailElementAttributes = exports.amendGmailNodes = exports.amendOutlookNodes = exports.pruneOutlookElement = exports.pruneGmailElement = void 0; -const DUMMY_QR_CODE_ID = "dummyQrCode"; -const elementsToRemove = { br: true, hr: true }; -const attributesToKeep = { - alt: true, - src: true, - cite: true, - data: true, - datetime: true, - href: true, - value: true, -}; -const isDummyQrCode = (element) => { - if (element.id === DUMMY_QR_CODE_ID) { - return true; - } -}; -const pruneElement = (element) => { - if (isDummyQrCode(element)) { - return true; - } - return !!elementsToRemove[element.nodeName.toLowerCase()]; -}; -exports.pruneGmailElement = (element) => { - return pruneElement(element); -}; -/** - * Returns true if element should be completely removed - * @param element - */ -exports.pruneOutlookElement = (element) => { - if (pruneElement(element)) { - return true; - } - // Remove Outlook generic <o:*> tags - return !!element.nodeName.toLowerCase().startsWith("o:"); -}; -const cloneAnchorFromPane = (a, pane) => { - try { - const url = new URL(a.href); - // If this is external url - if (url.host && url.protocol) { - pane.parentNode.insertBefore(a.cloneNode(false), pane); - } - } - catch (_a) { - return; - } -}; -exports.amendOutlookNodes = (document) => { - /** - * Get rid of attachments panes - */ - const attachmentsPanesConatiner = document.getElementById("OwaReferenceAttachments"); - const attachmentsPanesContainerEnd = document.getElementById("OwaReferenceAttachmentsEnd"); - if (attachmentsPanesConatiner) { - const as = attachmentsPanesConatiner.getElementsByTagName("a"); - Array.from(as).forEach((a) => { - cloneAnchorFromPane(a, attachmentsPanesConatiner); - }); - attachmentsPanesConatiner.parentNode.removeChild(attachmentsPanesConatiner); - } - attachmentsPanesContainerEnd && - attachmentsPanesContainerEnd.parentNode.removeChild(attachmentsPanesContainerEnd); - /** - * Unwind spans, because sometimes Outlook wraps everything into span after sending - */ - const spans = document.getElementsByTagName("span"); - /** - * Sort spans by depth to start unwinding the deepest ones, which does not contain nested spans - */ - const spansDepths = {}; - Array.from(spans).forEach((span) => { - let descendant = span; - let parent = descendant.parentNode; - let depth = 0; - while (parent && descendant !== parent) { - descendant = parent; - parent = descendant.parentNode; - depth++; - } - if (!spansDepths[depth]) { - spansDepths[depth] = []; - } - spansDepths[depth].push(span); - }); - Object.keys(spansDepths) - .sort((a, b) => parseInt(b) - parseInt(a)) - .forEach((depth) => { - spansDepths[depth].forEach((span) => { - let child = span.firstChild; - const parent = span.parentNode; - while (child) { - parent.insertBefore(child.cloneNode(true), span); - child = child.nextSibling; - } - span.parentNode.removeChild(span); - }); - }); -}; -exports.amendGmailNodes = (document) => { - /** - * Look for attachments panes and remove everything but liks - */ - const attachmentsPanes = Array.from(document.getElementsByClassName("gmail_chip")); - attachmentsPanes.forEach((pane) => { - const as = pane.querySelectorAll("a"); - as.forEach((a) => { - cloneAnchorFromPane(a, pane); - }); - }); - attachmentsPanes.forEach((pane) => { - pane.parentNode.removeChild(pane); - }); -}; -exports.cleanupGMailElementAttributes = (element) => { - if (element.attributes.length > 0) { - for (const attribute of element.attributes) { - if (attribute.name === "data-surl") { - element.setAttribute("src", attribute.value); - } - } - for (let i = 0; i < element.attributes.length; i++) { - const attribute = element.attributes[i]; - if (!attributesToKeep[attribute.name]) { - element.removeAttribute(attribute.name); - i--; - } - } - } -}; -exports.cleanupOutlookElementAttributes = (element) => { - if (element.attributes.length > 0) { - for (const attribute of element.attributes) { - let valueSplit = attribute.value.split(" "); - valueSplit = valueSplit.map((value) => value.startsWith("x_") ? value.replace("x_", "") : value); - element.setAttribute(attribute.name, valueSplit.join(" ")); - } - for (let i = 0; i < element.attributes.length; i++) { - const attribute = element.attributes[i]; - if (!attributesToKeep[attribute.name]) { - element.removeAttribute(attribute.name); - i--; - } - } - } -}; diff --git a/dist/services/MimeVerificationService/utils.d.ts b/dist/services/MimeVerificationService/utils.d.ts deleted file mode 100644 index 38abd0c4542eb14e90b3991abacd1ddf58d8ec5c..0000000000000000000000000000000000000000 --- a/dist/services/MimeVerificationService/utils.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare const printHtmlChildren: (node: Node, printFunction: (node: Node) => string, depth: number) => string; -export declare const printHtmlNode: (node: Node, printFunction: (node: Node) => string, depth: number) => string; -export declare const cleanupHtmlNodeAttributes: (node: Node, cleanupElementAttributes: (element: HTMLElement) => void) => void; -export declare const pruneHtmlNode: (node: Node, pruneElement: (element: HTMLElement) => boolean) => boolean; -export declare const printOutlookElement: (node: Node) => string; diff --git a/dist/services/MimeVerificationService/utils.js b/dist/services/MimeVerificationService/utils.js deleted file mode 100644 index fbbd9d9477188575f96f8cc7bc8640031d2a903f..0000000000000000000000000000000000000000 --- a/dist/services/MimeVerificationService/utils.js +++ /dev/null @@ -1,119 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.printOutlookElement = exports.pruneHtmlNode = exports.cleanupHtmlNodeAttributes = exports.printHtmlNode = exports.printHtmlChildren = void 0; -const stringUtils_1 = require("../../utils/stringUtils"); -const __1 = require("../.."); -const constants_1 = require("./constants"); -exports.printHtmlChildren = (node, printFunction, depth) => { - let child = node.firstChild; - if (!child) { - return ""; - } - if (child == node.lastChild && child.nodeType == constants_1.TEXT_NODE) { - return exports.printHtmlNode(child, printFunction, depth); - } - else { - let result = ""; - while (child) { - result = result.concat(exports.printHtmlNode(child, printFunction, depth)); - child = child.nextSibling; - } - return result; - } -}; -exports.printHtmlNode = (node, printFunction, depth) => { - let result = ""; - if (printFunction) { - const customPrintout = printFunction(node); - if (customPrintout) { - return customPrintout; - } - } - switch (node.nodeType) { - case constants_1.TEXT_NODE: { - const text = stringUtils_1.removeSpacesAndLinebreaks(node.textContent); - if (text.length) { - result += "<TEXT>"; - result += text; - result += "</TEXT>"; - result += "\n"; - } - break; - } - case constants_1.DOCUMENT_NODE: - result += exports.printHtmlChildren(node, printFunction, depth); - break; - case constants_1.ELEMENT_NODE: - result += "<" + node.nodeName; - Array.from(node.attributes) - .sort((a, b) => a.name.localeCompare(b.name)) - .forEach((attribute) => { - result += ` ${attribute.name}`; - if (attribute.value) { - result += `="${__1.escapeHtmlString(attribute.value)}"`; - } - }); - if (node.firstChild) { - result += ">"; - result += "\n"; - result += exports.printHtmlChildren(node, printFunction, depth + 1); - result += "</" + node.nodeName + ">"; - } - else { - result += "/>"; - } - result += "\n"; - break; - } - return result; -}; -exports.cleanupHtmlNodeAttributes = (node, cleanupElementAttributes) => { - if (node.nodeType === node.ELEMENT_NODE) { - cleanupElementAttributes(node); - } - let child = node.firstChild; - while (child) { - exports.cleanupHtmlNodeAttributes(child, cleanupElementAttributes); - child = child.nextSibling; - } -}; -exports.pruneHtmlNode = (node, pruneElement) => { - let toBeRemoved = false; - switch (node.nodeType) { - case node.COMMENT_NODE: - case node.DOCUMENT_TYPE_NODE: - toBeRemoved = true; - break; - case node.TEXT_NODE: { - const trimmedText = node.textContent.trim(); - if (trimmedText === "") { - toBeRemoved = true; - } - else { - node.textContent = trimmedText; - } - break; - } - case node.ELEMENT_NODE: - toBeRemoved = pruneElement(node); - } - if (toBeRemoved) { - return true; - } - const childrenToRemove = []; - let child = node.firstChild; - while (child) { - exports.pruneHtmlNode(child, pruneElement) && childrenToRemove.push(child); - child = child.nextSibling; - } - childrenToRemove.forEach((child) => node.removeChild(child)); - return false; -}; -// TODO: Move this logic to amendOutlookNodes -exports.printOutlookElement = (node) => { - if (node.nodeType === constants_1.ELEMENT_NODE) { - if (node.classList.contains("WordSection1")) { - return exports.printHtmlChildren(node, null, 0); - } - } -}; diff --git a/dist/services/QrCodeDataService.d.ts b/dist/services/QrCodeDataService.d.ts deleted file mode 100644 index 221534bdabc25ad4fa2e3121e3a6568bbfbefda2..0000000000000000000000000000000000000000 --- a/dist/services/QrCodeDataService.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { KeyDataPair, MessageData } from "../types"; -import CloudflareService from "./CloudflareService"; -import { ICryptoService } from "./CryptoService/ICryptoService"; -interface WithServices { - getMessageDataFromBase64: (base64: string) => Promise<MessageData>; -} -declare const _default: { - encodeEmailData: (emailData: MessageData) => string; - decodeEmailData: (binary: string | ArrayBuffer | Uint8Array) => MessageData; - encodeKeyDataPair: (keyData: KeyDataPair) => string; - decodeKeyDataPair: (binary: string | ArrayBuffer | Uint8Array) => KeyDataPair; - breakQrCodeData: (data: ArrayBuffer, headBytesSize?: number) => { - head: ArrayBuffer; - tail: ArrayBuffer; - }; - assembleQrCodeData: (head: ArrayBuffer, tail: ArrayBuffer) => ArrayBuffer; - withServices: (cloudFlareServiceInstance: CloudflareService, landingPageServiceUrl: string, cryptoService?: ICryptoService) => WithServices; -}; -export default _default; diff --git a/dist/services/QrCodeDataService.js b/dist/services/QrCodeDataService.js deleted file mode 100644 index 844b5258bbb50c2370bbaef913656653f11b96a3..0000000000000000000000000000000000000000 --- a/dist/services/QrCodeDataService.js +++ /dev/null @@ -1,133 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const axios_1 = require("axios"); -const qrcode_data_pb_1 = require("../generated/qrcode_data_pb"); -const common_1 = require("../utils/common"); -const CryptoService_1 = require("./CryptoService"); -const EmailDataMessageV1 = qrcode_data_pb_1.vereign.protobuf.qrcode_data.EmailData_V1; -const KeyDataMessageV1 = qrcode_data_pb_1.vereign.protobuf.qrcode_data.KeyData_V1; -const WrapperDataMessage = qrcode_data_pb_1.vereign.protobuf.qrcode_data.WrapperData; -const EMAIL_DATA_V1 = "EmailData_V1"; -const encodeEmailData = (emailData) => { - const emailDataMessage = EmailDataMessageV1.fromObject(emailData); - const emailDataBuffer = EmailDataMessageV1.encode(emailDataMessage).finish(); - const wrappedData = { - version: 1, - className: EMAIL_DATA_V1, - data: emailDataBuffer, - }; - const wrappedDataMessage = WrapperDataMessage.fromObject(wrappedData); - const wrappedDataBuffer = WrapperDataMessage.encode(wrappedDataMessage).finish(); - return common_1.arrayBufferToBase64(wrappedDataBuffer); -}; -const decodeEmailData = (binary) => { - const wrappedDataMessage = WrapperDataMessage.decode(common_1.ensureUint8Array(binary)); - const wrappedData = WrapperDataMessage.toObject(wrappedDataMessage); - if (wrappedData.className === EMAIL_DATA_V1) { - const emailDataMessage = EmailDataMessageV1.decode(common_1.ensureUint8Array(wrappedData.data)); - const messageData = EmailDataMessageV1.toObject(emailDataMessage, { - bytes: String, - }); - Object.assign(messageData, { - /** - * @deprecated Will be deleted in version 1.0.1. Use plainPartRabinFingerprint instead. - */ - plainPartRollingHash: messageData.plainPartRabinFingerprint, - /** - * @deprecated Will be deleted in version 1.0.1. Use htmlPartRabinFingerprint instead. - */ - htmlPartRollingHash: messageData.htmlPartRabinFingerprint, - }); - return messageData; - } - else { - return null; - } -}; -const encodeKeyDataPair = (keyData) => { - const keyDataMessage = KeyDataMessageV1.fromObject(keyData); - const buffer = KeyDataMessageV1.encode(keyDataMessage).finish(); - return common_1.arrayBufferToBase64(buffer); -}; -const decodeKeyDataPair = (binary) => { - const keyDataPairMessage = KeyDataMessageV1.decode(common_1.ensureUint8Array(binary)); - return KeyDataMessageV1.toObject(keyDataPairMessage, { - bytes: String, - }); -}; -const breakQrCodeData = (data, headBytesSize = 32) => { - if (data.byteLength <= headBytesSize) { - return { - head: data, - tail: null, - }; - } - else { - const dataUint8Array = new Uint8Array(data); - return { - head: dataUint8Array.slice(0, headBytesSize).buffer, - tail: dataUint8Array.slice(headBytesSize, dataUint8Array.length).buffer, - }; - } -}; -const assembleQrCodeData = (head, tail) => { - return Buffer.concat([Buffer.from(head), Buffer.from(tail)]); -}; -/** - * Higher order function to perform complex operations with the QR code data - * @param cloudFlareServiceInstance = new CloudflareService("CDN_RUL", "DEFAULT_BUCKET") - * @param landingPageServiceUrl - URL of the service responsible for RSA decryption - * @param cryptoService - instance of ICryptoService. Override only needed cryptographic functions. - * The rest will be filled with default ones from CryptoServiceWeb/CryptoServiceNode - */ -const withServices = (cloudFlareServiceInstance, landingPageServiceUrl, cryptoService) => { - if (cryptoService) { - cryptoService = Object.assign(Object.assign({}, CryptoService_1.default), cryptoService); - } - else { - cryptoService = CryptoService_1.default; - } - return { - getMessageDataFromBase64: (base64) => __awaiter(void 0, void 0, void 0, function* () { - const qrCodeDataPart = decodeKeyDataPair(base64); - const base64SHA256 = yield cryptoService.SHA256(base64); - const backblazeDataPart = (yield cloudFlareServiceInstance.fetchFile(`qrcode-${common_1.arrayBufferToHex(base64SHA256)}`)); - const assembledData = assembleQrCodeData(common_1.base64ToArrayBuffer(qrCodeDataPart.data), common_1.base64ToArrayBuffer(backblazeDataPart.qr_code_data)); - const { key: aesEncryptedSessionKey, data: storageIv, } = decodeKeyDataPair(backblazeDataPart.session_key); - const rsaEncryptedSessionKey = yield cryptoService.decryptAESGCM(common_1.base64ToArrayBuffer(aesEncryptedSessionKey), common_1.base64ToArrayBuffer(qrCodeDataPart.key), common_1.base64ToArrayBuffer(storageIv)); - const { data: { key: encodedSessionKey }, } = yield axios_1.default({ - url: `${landingPageServiceUrl}/api/hsm/decrypt`, - method: "POST", - headers: { - "Content-Type": "application/json", - }, - data: { - key_signature: backblazeDataPart.key_signature, - encrypted_key: rsaEncryptedSessionKey, - }, - }); - const decodedSessionKey = decodeKeyDataPair(encodedSessionKey); - const decryptedEmailData = yield cryptoService.decryptAESGCM(assembledData, common_1.base64ToArrayBuffer(decodedSessionKey.key), common_1.base64ToArrayBuffer(decodedSessionKey.data)); - const decompressedEmailData = common_1.decompressData(decryptedEmailData); - return decodeEmailData(decompressedEmailData); - }), - }; -}; -exports.default = { - encodeEmailData, - decodeEmailData, - encodeKeyDataPair, - decodeKeyDataPair, - breakQrCodeData, - assembleQrCodeData, - withServices, -}; diff --git a/dist/services/StatusesService.d.ts b/dist/services/StatusesService.d.ts deleted file mode 100644 index b60762608f177c16f13836472fb8c64257cae9ba..0000000000000000000000000000000000000000 --- a/dist/services/StatusesService.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { RecipientStatusObject, RecipientStatusObjectData, SenderStatusObject, StatusObject, WrapperData } from "../types"; -export declare const SENDER_CLASS_NAME = "SenderStatusObject"; -export declare const RECIPIENT_CLASS_NAME = "RecipientStatusObject"; -export declare const MIME_SIGNATURE_HASHING_ALGORITHMS: { - MIME: string; - PARTS: string; -}; -export declare const EMAIL_VENDORS: { - GMAIL: string; - OUTLOOK: string; - ROUNDCUBE: string; - GENERIC_MIME: string; -}; -declare class StatusesService { - static SENDER_CLASS_NAME: string; - static RECIPIENT_CLASS_NAME: string; - static EMAIL_VENDORS: { - GMAIL: string; - OUTLOOK: string; - ROUNDCUBE: string; - GENERIC_MIME: string; - }; - static MIME_SIGNATURE_HASHING_ALGORITHMS: { - MIME: string; - PARTS: string; - }; - encodeSenderStatusObject(signatureTime: number, signatureTimeSignature: ArrayBuffer | string, messageSignature: ArrayBuffer | string, attachmentsSignature: { - [key: string]: ArrayBuffer | string; - }, messageSignatureHashingAlgorithm: string, senderSystem: string): ArrayBuffer; - decodeSenderStatusObject(bytes: ArrayBuffer | string): SenderStatusObject; - encodeAndWrapSenderStatusObject(signatureTime: number, signatureTimeSignature: ArrayBuffer | string, messageSignature: ArrayBuffer | string, attachmentsSignature: { - [key: string]: ArrayBuffer | string; - }, messageSignatureHashingAlgorithm: string, senderSystem: string): ArrayBuffer; - encodeRecipientStatusObject(iv: ArrayBuffer | string, encryptedContent: string | ArrayBuffer, decryptors: { - [key: string]: string | ArrayBuffer; - }): ArrayBuffer; - decodeRecipientStatusObject(bytes: string | ArrayBuffer): RecipientStatusObject; - encodeAndWrapRecipientStatusObject(iv: ArrayBuffer | string, encryptedContent: string | ArrayBuffer, decryptors: { - [key: string]: string | ArrayBuffer; - }): ArrayBuffer; - encodeRecipientStatusData(creationDate: number, gatewayDomainHash: ArrayBuffer | string, randomToken: ArrayBuffer | string): ArrayBuffer; - decodeRecipientStatusData(bytes: ArrayBuffer): RecipientStatusObjectData; - encodeSenderWrapperData(statusObjectBytes: ArrayBuffer | string): ArrayBuffer; - encodeRecipientWrapperData(statusObjectBytes: ArrayBuffer | string): ArrayBuffer; - encodeWrapperData(data: ArrayBuffer | string, className: string, version?: number): ArrayBuffer; - decodeWrapperData(bytes: ArrayBuffer | string): WrapperData; - decodeStatusObject(wrapperDataBytes: ArrayBuffer | string): { - className: string; - statusObject: StatusObject; - }; -} -export default StatusesService; diff --git a/dist/services/StatusesService.js b/dist/services/StatusesService.js deleted file mode 100644 index 0df90235910389e2ce55393ddec73855df1bc08d..0000000000000000000000000000000000000000 --- a/dist/services/StatusesService.js +++ /dev/null @@ -1,123 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.EMAIL_VENDORS = exports.MIME_SIGNATURE_HASHING_ALGORITHMS = exports.RECIPIENT_CLASS_NAME = exports.SENDER_CLASS_NAME = void 0; -const common_1 = require("../utils/common"); -const statuses_pb_1 = require("../generated/statuses_pb"); -const SenderStatusObjectMessage = statuses_pb_1.vereign.statuses.SenderStatusObject; -const RecipientStatusDataMessage = statuses_pb_1.vereign.statuses.RecipientStatusData; -const RecipientStatusObjectMessage = statuses_pb_1.vereign.statuses.RecipientStatusObject; -const WrapperDataMessage = statuses_pb_1.vereign.statuses.WrapperData; -exports.SENDER_CLASS_NAME = "SenderStatusObject"; -exports.RECIPIENT_CLASS_NAME = "RecipientStatusObject"; -exports.MIME_SIGNATURE_HASHING_ALGORITHMS = { - MIME: "MIME", - PARTS: "PARTS", -}; -exports.EMAIL_VENDORS = { - GMAIL: "GMAIL", - OUTLOOK: "OUTLOOK", - ROUNDCUBE: "ROUNDCUBE", - GENERIC_MIME: "GENERIC_MIME", -}; -class StatusesService { - encodeSenderStatusObject(signatureTime, signatureTimeSignature, messageSignature, attachmentsSignature, messageSignatureHashingAlgorithm, senderSystem) { - const senderStatusObjectMessage = SenderStatusObjectMessage.fromObject({ - signatureTime, - signatureTimeSignature, - messageSignature, - attachmentsSignature, - messageSignatureHashingAlgorithm, - senderSystem, - }); - return SenderStatusObjectMessage.encode(senderStatusObjectMessage).finish(); - } - decodeSenderStatusObject(bytes) { - const senderStatusObjectMessage = SenderStatusObjectMessage.decode(common_1.ensureUint8Array(bytes)); - return SenderStatusObjectMessage.toObject(senderStatusObjectMessage, { - bytes: String, - longs: Number, - enums: String, - }); - } - encodeAndWrapSenderStatusObject(signatureTime, signatureTimeSignature, messageSignature, attachmentsSignature, messageSignatureHashingAlgorithm, senderSystem) { - const encodedSenderStatusObject = this.encodeSenderStatusObject(signatureTime, signatureTimeSignature, messageSignature, attachmentsSignature, messageSignatureHashingAlgorithm, senderSystem); - return this.encodeSenderWrapperData(encodedSenderStatusObject); - } - encodeRecipientStatusObject(iv, encryptedContent, decryptors) { - const recipientStatusObjectMessage = RecipientStatusObjectMessage.fromObject({ - iv, - encryptedContent, - decryptors, - }); - return RecipientStatusObjectMessage.encode(recipientStatusObjectMessage).finish(); - } - decodeRecipientStatusObject(bytes) { - const recipientStatusObjectMessage = RecipientStatusObjectMessage.decode(common_1.ensureUint8Array(bytes)); - return RecipientStatusObjectMessage.toObject(recipientStatusObjectMessage, { - bytes: String, - longs: Number, - }); - } - encodeAndWrapRecipientStatusObject(iv, encryptedContent, decryptors) { - const encodedSenderStatusObject = this.encodeRecipientStatusObject(iv, encryptedContent, decryptors); - return this.encodeRecipientWrapperData(encodedSenderStatusObject); - } - encodeRecipientStatusData(creationDate, gatewayDomainHash, randomToken) { - const recipientStatusDataMessage = RecipientStatusDataMessage.fromObject({ - creationDate, - gatewayDomainHash, - randomToken, - }); - return RecipientStatusDataMessage.encode(recipientStatusDataMessage).finish(); - } - decodeRecipientStatusData(bytes) { - const recipientStatusDataMessage = RecipientStatusDataMessage.decode(common_1.ensureUint8Array(bytes)); - return RecipientStatusDataMessage.toObject(recipientStatusDataMessage, { - bytes: String, - longs: Number, - }); - } - encodeSenderWrapperData(statusObjectBytes) { - return this.encodeWrapperData(statusObjectBytes, exports.SENDER_CLASS_NAME, 1); - } - encodeRecipientWrapperData(statusObjectBytes) { - return this.encodeWrapperData(statusObjectBytes, exports.RECIPIENT_CLASS_NAME, 1); - } - encodeWrapperData(data, className, version = 1) { - const wrapperDataMessage = WrapperDataMessage.fromObject({ - data, - className, - version, - }); - return WrapperDataMessage.encode(wrapperDataMessage).finish(); - } - decodeWrapperData(bytes) { - const wrappedDataMessage = WrapperDataMessage.decode(common_1.ensureUint8Array(bytes)); - return WrapperDataMessage.toObject(wrappedDataMessage, { - bytes: String, - }); - } - decodeStatusObject(wrapperDataBytes) { - const decodedWrapperData = this.decodeWrapperData(wrapperDataBytes); - if (decodedWrapperData.className === exports.SENDER_CLASS_NAME) { - return { - className: exports.SENDER_CLASS_NAME, - statusObject: this.decodeSenderStatusObject(decodedWrapperData.data), - }; - } - else if (decodedWrapperData.className === exports.RECIPIENT_CLASS_NAME) { - return { - className: exports.RECIPIENT_CLASS_NAME, - statusObject: this.decodeRecipientStatusObject(decodedWrapperData.data), - }; - } - else { - return null; - } - } -} -StatusesService.SENDER_CLASS_NAME = exports.SENDER_CLASS_NAME; -StatusesService.RECIPIENT_CLASS_NAME = exports.RECIPIENT_CLASS_NAME; -StatusesService.EMAIL_VENDORS = exports.EMAIL_VENDORS; -StatusesService.MIME_SIGNATURE_HASHING_ALGORITHMS = exports.MIME_SIGNATURE_HASHING_ALGORITHMS; -exports.default = StatusesService; diff --git a/dist/services/VerificationService/VerificationError.d.ts b/dist/services/VerificationService/VerificationError.d.ts deleted file mode 100644 index 6cd5a8752983209121f8f6b578ca2d074f11d19d..0000000000000000000000000000000000000000 --- a/dist/services/VerificationService/VerificationError.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare const VERIFICATION_ERROR = "VERIFICATION_ERROR"; -declare class VerificationError extends Error { - constructor(message: string); -} -export default VerificationError; diff --git a/dist/services/VerificationService/VerificationError.js b/dist/services/VerificationService/VerificationError.js deleted file mode 100644 index 97a65e74287dfcc68ff20faabd322bd17ec4de42..0000000000000000000000000000000000000000 --- a/dist/services/VerificationService/VerificationError.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.VERIFICATION_ERROR = void 0; -exports.VERIFICATION_ERROR = "VERIFICATION_ERROR"; -class VerificationError extends Error { - constructor(message) { - super(message); - this.name = exports.VERIFICATION_ERROR; - } -} -exports.default = VerificationError; diff --git a/dist/services/VerificationService/VerificationService.d.ts b/dist/services/VerificationService/VerificationService.d.ts deleted file mode 100644 index bee760c21e9e6253a20f27fc4e92678d8573c7c5..0000000000000000000000000000000000000000 --- a/dist/services/VerificationService/VerificationService.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -declare const EventEmitter: any; -import { BlockData, MerkleTree, StatusData, TxData, VerificationData } from "../../types"; -import { AxiosError } from "axios"; -export declare const TRANSACTION_RETRIEVED = "TRANSACTION_RETRIEVED"; -export declare const MERKLE_TREE_VERIFIED = "MERKLE_TREE_VERIFIED"; -export declare const BLOCK_DATA_RETRIEVED = "BLOCK_DATA_RETRIEVED"; -declare class VerificationService extends EventEmitter { - private _aeternityService; - private _cloudflareService; - constructor(cdnUrl?: string, cdnBucket?: string, aeternityNodeUrl?: string, aeternityCompilerUrl?: string, aeternityContractBytecode?: string); - getTransaction(hash: string): Promise<TxData>; - getBlockData(blockHeight: number): Promise<BlockData>; - verifyStatusData(statusData: StatusData): Promise<VerificationData>; - getMerkleTreeForTransaction(txData: TxData): Promise<MerkleTree>; - verifyMerkleTreeNode(nodeToVerify: string, merkleTree: MerkleTree): Promise<boolean>; - catchVerificationError(error: AxiosError, verificationFailureMessage: string): void; -} -export default VerificationService; diff --git a/dist/services/VerificationService/VerificationService.js b/dist/services/VerificationService/VerificationService.js deleted file mode 100644 index f04be31061855664b97a29bdf32b4a4e0da6f53c..0000000000000000000000000000000000000000 --- a/dist/services/VerificationService/VerificationService.js +++ /dev/null @@ -1,125 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.BLOCK_DATA_RETRIEVED = exports.MERKLE_TREE_VERIFIED = exports.TRANSACTION_RETRIEVED = void 0; -const index_1 = require("../../index"); -const EventEmitter = require("eventemitter2"); -const merkletreejs_1 = require("merkletreejs"); -const AeternityService_1 = require("../AeternityService"); -const CloudflareService_1 = require("../CloudflareService"); -const VerificationError_1 = require("./VerificationError"); -exports.TRANSACTION_RETRIEVED = "TRANSACTION_RETRIEVED"; -exports.MERKLE_TREE_VERIFIED = "MERKLE_TREE_VERIFIED"; -exports.BLOCK_DATA_RETRIEVED = "BLOCK_DATA_RETRIEVED"; -class VerificationService extends EventEmitter { - constructor(cdnUrl, cdnBucket, aeternityNodeUrl, aeternityCompilerUrl, aeternityContractBytecode) { - super(); - this._aeternityService = null; - this._cloudflareService = null; - this._aeternityService = new AeternityService_1.default(aeternityNodeUrl, aeternityCompilerUrl, aeternityContractBytecode); - this._cloudflareService = new CloudflareService_1.default(cdnUrl, cdnBucket); - } - getTransaction(hash) { - return __awaiter(this, void 0, void 0, function* () { - return this._aeternityService.getTxDataByHash(hash).catch((err) => { - this.catchVerificationError(err, `Error getting transaction`); - return null; - }); - }); - } - getBlockData(blockHeight) { - return __awaiter(this, void 0, void 0, function* () { - return this._aeternityService.getBlockData(blockHeight).catch((e) => { - this.catchVerificationError(e, `Error retrieving block`); - return null; - }); - }); - } - verifyStatusData(statusData) { - return __awaiter(this, void 0, void 0, function* () { - let verificationError; - let blockData; - let merkleTreeDetails; - let txData; - try { - txData = yield this.getTransaction(statusData.transactionHash); - this.emit(exports.TRANSACTION_RETRIEVED, txData); - const merkleTree = yield this.getMerkleTreeForTransaction(txData); - const statusVerified = yield this.verifyMerkleTreeNode(statusData.statusRaw, merkleTree); - merkleTreeDetails = { - verified: statusVerified, - treeSize: merkleTree.nodes.length, - statusPosition: merkleTree.nodes.indexOf(statusData.statusRaw) + 1, - rootHash: merkleTree.rootHash, - }; - this.emit(exports.MERKLE_TREE_VERIFIED, merkleTreeDetails); - blockData = yield this.getBlockData(txData.blockHeight); - this.emit(exports.BLOCK_DATA_RETRIEVED, blockData); - } - catch (e) { - if (e instanceof VerificationError_1.default) { - verificationError = e.message; - } - else { - throw e; - } - } - return { - statusData, - merkleTreeDetails, - blockData, - verificationError, - txData, - }; - }); - } - getMerkleTreeForTransaction(txData) { - var _a; - return __awaiter(this, void 0, void 0, function* () { - try { - const txMerkleTreeData = yield this._aeternityService.decodeContractCallData((_a = txData.tx) === null || _a === void 0 ? void 0 : _a.callData); - const merkleTreeNodes = yield this._cloudflareService.getMerkleTree(txMerkleTreeData.merkleeTreeFileName); - return { - nodes: merkleTreeNodes, - rootHash: txMerkleTreeData.rootNodeHash, - }; - } - catch (e) { - this.catchVerificationError(e, `Error extracting Merkle tree from transaction.`); - } - }); - } - verifyMerkleTreeNode(nodeToVerify, merkleTree) { - return __awaiter(this, void 0, void 0, function* () { - const leaves = yield Promise.all(merkleTree.nodes.map((x) => __awaiter(this, void 0, void 0, function* () { return yield index_1.CryptoService.SHA256(x); }))); - const tree = new merkletreejs_1.MerkleTree(leaves); - const leaf = yield index_1.CryptoService.SHA256(nodeToVerify); - const proof = tree.getProof(Buffer.from(leaf), merkleTree.nodes.indexOf(nodeToVerify)); - const verified = tree.verify(proof, Buffer.from(leaf), Buffer.from(merkleTree.rootHash, "base64")); - if (!verified) { - throw new VerificationError_1.default(`Merkle tree not verified.`); - } - return verified; - }); - } - catchVerificationError(error, verificationFailureMessage) { - if (error.response) { - throw new VerificationError_1.default(verificationFailureMessage); - } - else { - throw error; - } - } -} -VerificationService.TRANSACTION_RETRIEVED = exports.TRANSACTION_RETRIEVED; -VerificationService.MERKLE_TREE_VERIFIED = exports.MERKLE_TREE_VERIFIED; -VerificationService.BLOCK_DATA_RETRIEVED = exports.BLOCK_DATA_RETRIEVED; -exports.default = VerificationService; diff --git a/dist/services/VerificationService/index.d.ts b/dist/services/VerificationService/index.d.ts deleted file mode 100644 index 7cec859380df2e70b4463c6ca9fec8d8bd3e85d9..0000000000000000000000000000000000000000 --- a/dist/services/VerificationService/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import VerificationService from "./VerificationService"; -export default VerificationService; diff --git a/dist/services/VerificationService/index.js b/dist/services/VerificationService/index.js deleted file mode 100644 index 303dd41f6f5aa8677ef8bf5b9d6d8d15b4f88128..0000000000000000000000000000000000000000 --- a/dist/services/VerificationService/index.js +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const VerificationService_1 = require("./VerificationService"); -exports.default = VerificationService_1.default; diff --git a/dist/types.d.ts b/dist/types.d.ts deleted file mode 100644 index c4d2bebd1d09d141ee638abd9fc54cb20dd133e5..0000000000000000000000000000000000000000 --- a/dist/types.d.ts +++ /dev/null @@ -1,113 +0,0 @@ -export interface Participant { - name: string; - email: string; -} -export interface Attachment { - name: string; - url?: string; - size: number; - hash: string; - hashAlg: string; - signature: string; -} -export interface MessageData { - statusId: string; - sender: Participant; - subject: string; - date: string; - recipients: { - to: Array<Participant>; - cc?: Array<Participant>; - }; - attachments: Array<Attachment>; - senderPublicKeyUuid: string; - /** - * @deprecated Will be deleted in version 1.0.1. Use htmlPartRabinFingerprint instead. - */ - htmlPartRollingHash: string; - htmlPartRabinFingerprint: string; - htmlPartSize: number; - /** - * @deprecated Will be deleted in version 1.0.1. Use plainPartRabinFingerprint instead. - */ - plainPartRollingHash: string; - plainPartRabinFingerprint: string; - plainPartSize: number; -} -export interface StatusData { - status?: StatusObject; - statusRaw: string; - statusClassName?: string; - merkleTreeId: string; - transactionHash: string; -} -export interface MerkleTreeVerificationDetails { - statusPosition: number; - treeSize: number; - verified: boolean; - rootHash: string; -} -export interface MerkleTree { - rootHash: string; - nodes: Array<string>; -} -export interface VerificationData { - statusData?: StatusData; - blockData?: BlockData; - txData?: TxData; - merkleTreeDetails?: MerkleTreeVerificationDetails; - verificationError?: string; -} -export interface BlockData { - blockHeight: number; - timestamp: number; - confirmationsAmount: number; -} -export interface TxData { - hash: string; - blockHeight: number; - tx: { - callData: string; - }; -} -export interface TxMerkleTreeData { - merkleeTreeFileName: string; - rootNodeHash: string; -} -export interface SenderStatusObject { - signatureTime: number; - signatureTimeSignature: string; - messageSignature: string; - attachmentsSignature: { - [key: string]: string; - }; - messageSignatureHashingAlgorithm: string; - senderSystem: string; -} -export interface RecipientStatusObjectData { - creationDate: number; - gatewayDomainHash: string; - randomToken: string; -} -export interface RecipientStatusObject { - iv: string; - encryptedContent: string; - decryptors: { - [key: string]: string; - }; -} -export interface WrapperData { - data: string; - version: number; - className: string; -} -export interface QrCodeData { - encryptedKey: Uint8Array; - encryptedData: Uint8Array; - nonce: Uint8Array; -} -export declare type StatusObject = SenderStatusObject | RecipientStatusObject; -export interface KeyDataPair { - key: string; - data: string; -} diff --git a/dist/types.js b/dist/types.js deleted file mode 100644 index c8ad2e549bdc6801e0d1c80b0308d4b9bd4985ce..0000000000000000000000000000000000000000 --- a/dist/types.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/utils/common.d.ts b/dist/utils/common.d.ts deleted file mode 100644 index 714b3c6bc67c95dc9542529141d35ffb68ce77c9..0000000000000000000000000000000000000000 --- a/dist/utils/common.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -export declare const arrayBufferToBase64: (buffer: ArrayBuffer) => string; -export declare const base64ToArrayBuffer: (base64: string) => ArrayBuffer; -export declare const ensureBase64: (data: string | ArrayBuffer) => string; -export declare const ensureArrayBuffer: (data: string | ArrayBuffer) => ArrayBuffer; -export declare const ensureUint8Array: (data: string | ArrayBuffer | Uint8Array) => Uint8Array; -export declare const compressData: (binary: string | ArrayBuffer) => ArrayBuffer; -export declare const decompressData: (binary: string | ArrayBuffer) => ArrayBuffer; -export declare const arrayBufferToHex: (buffer: ArrayBuffer) => string; -export declare const escapeHtmlString: (string: string) => string; -declare const _default: { - compressData: (binary: string | ArrayBuffer) => ArrayBuffer; - decompressData: (binary: string | ArrayBuffer) => ArrayBuffer; - arrayBufferToHex: (buffer: ArrayBuffer) => string; - arrayBufferToBase64: (buffer: ArrayBuffer) => string; - base64ToArrayBuffer: (base64: string) => ArrayBuffer; - ensureUint8Array: (data: string | ArrayBuffer | Uint8Array) => Uint8Array; - ensureArrayBuffer: (data: string | ArrayBuffer) => ArrayBuffer; - ensureBase64: (data: string | ArrayBuffer) => string; - escapeHtmlString: (string: string) => string; -}; -export default _default; diff --git a/dist/utils/common.js b/dist/utils/common.js deleted file mode 100644 index 8314d0c5934df1050da51e875377fa79b97bec13..0000000000000000000000000000000000000000 --- a/dist/utils/common.js +++ /dev/null @@ -1,88 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.escapeHtmlString = exports.arrayBufferToHex = exports.decompressData = exports.compressData = exports.ensureUint8Array = exports.ensureArrayBuffer = exports.ensureBase64 = exports.base64ToArrayBuffer = exports.arrayBufferToBase64 = void 0; -const zlib_min_1 = require("zlibjs/bin/zlib.min"); -exports.arrayBufferToBase64 = (buffer) => { - return Buffer.from(buffer).toString("base64"); -}; -exports.base64ToArrayBuffer = (base64) => { - return Buffer.from(base64, "base64"); -}; -exports.ensureBase64 = (data) => { - return typeof data === "string" ? data : exports.arrayBufferToBase64(data); -}; -exports.ensureArrayBuffer = (data) => { - return typeof data === "string" ? exports.base64ToArrayBuffer(data) : data; -}; -exports.ensureUint8Array = (data) => { - return data instanceof Uint8Array - ? data - : typeof data === "string" - ? new Uint8Array(exports.base64ToArrayBuffer(data)) - : data instanceof ArrayBuffer - ? new Uint8Array(data) - : data; -}; -exports.compressData = (binary) => { - const deflate = new zlib_min_1.Zlib.Deflate(exports.ensureUint8Array(binary)); - return deflate.compress(); -}; -exports.decompressData = (binary) => { - const inflate = new zlib_min_1.Zlib.Inflate(exports.ensureUint8Array(binary)); - return inflate.decompress(); -}; -exports.arrayBufferToHex = (buffer) => { - return [...new Uint8Array(buffer)] - .map((b) => b.toString(16).padStart(2, "0")) - .join(""); -}; -exports.escapeHtmlString = (string) => { - const matchHtmlRegExp = /["'&<>]/; - const str = "" + string; - const match = matchHtmlRegExp.exec(str); - if (!match) { - return str; - } - let escape; - let html = ""; - let index = 0; - let lastIndex = 0; - for (index = match.index; index < str.length; index++) { - switch (str.charCodeAt(index)) { - case 34: // " - escape = """; - break; - case 38: // & - escape = "&"; - break; - case 39: // ' - escape = "'"; - break; - case 60: // < - escape = "<"; - break; - case 62: // > - escape = ">"; - break; - default: - continue; - } - if (lastIndex !== index) { - html += str.substring(lastIndex, index); - } - lastIndex = index + 1; - html += escape; - } - return lastIndex !== index ? html + str.substring(lastIndex, index) : html; -}; -exports.default = { - compressData: exports.compressData, - decompressData: exports.decompressData, - arrayBufferToHex: exports.arrayBufferToHex, - arrayBufferToBase64: exports.arrayBufferToBase64, - base64ToArrayBuffer: exports.base64ToArrayBuffer, - ensureUint8Array: exports.ensureUint8Array, - ensureArrayBuffer: exports.ensureArrayBuffer, - ensureBase64: exports.ensureBase64, - escapeHtmlString: exports.escapeHtmlString, -}; diff --git a/dist/utils/qrCodeTemplateUtils.d.ts b/dist/utils/qrCodeTemplateUtils.d.ts deleted file mode 100644 index 26ba313037201c52bb286870952ee60625eabbfe..0000000000000000000000000000000000000000 --- a/dist/utils/qrCodeTemplateUtils.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare const _default: { - putQrCodeOnChromakeyTemplate: (qrCodeImageBase64: string, templateImageBase64: string, placeholderWidth: number, placeholderHeight: number, scale?: number) => Promise<string>; -}; -export default _default; diff --git a/dist/utils/qrCodeTemplateUtils.js b/dist/utils/qrCodeTemplateUtils.js deleted file mode 100644 index d5c8821ed1ae55f137c1494245aee8861d2fd671..0000000000000000000000000000000000000000 --- a/dist/utils/qrCodeTemplateUtils.js +++ /dev/null @@ -1,131 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const findChromakeyBoundaries = (width, height, imageData, chromakeyWidth, chromakeyHeight) => { - const maskSizeX = chromakeyWidth; - const maskSizeY = chromakeyHeight; - const totalSum = maskSizeX * maskSizeY * 255; - const matrixR = []; - const matrixG = []; - const matrixB = []; - for (let i = 0; i < width; i++) { - matrixR[i] = []; - matrixG[i] = []; - matrixB[i] = []; - for (let j = 0; j < height; j++) { - matrixR[i][j] = 0; - matrixG[i][j] = 0; - matrixB[i][j] = 0; - } - } - const maxDistance = Math.sqrt(3 * totalSum * totalSum); - const suitableSimilarity = 0.6; - let bestSimilarity = 0; - let bestX = -1; - let bestY = -1; - for (let x = 0; x < width; x++) { - for (let y = 0; y < height; y++) { - const index = (y * width + x) * 4; - const r = imageData.data[index]; - const g = imageData.data[index + 1]; - const b = imageData.data[index + 2]; - matrixR[x][y] += r; - matrixG[x][y] += g; - matrixB[x][y] += b; - if (x - 1 >= 0) { - matrixR[x][y] += matrixR[x - 1][y]; - matrixG[x][y] += matrixG[x - 1][y]; - matrixB[x][y] += matrixB[x - 1][y]; - } - if (y - 1 >= 0) { - matrixR[x][y] += matrixR[x][y - 1]; - matrixG[x][y] += matrixG[x][y - 1]; - matrixB[x][y] += matrixB[x][y - 1]; - } - if (x - 1 >= 0 && y - 1 >= 0) { - matrixR[x][y] -= matrixR[x - 1][y - 1]; - matrixG[x][y] -= matrixG[x - 1][y - 1]; - matrixB[x][y] -= matrixB[x - 1][y - 1]; - } - if (x >= maskSizeX && y >= maskSizeY) { - const tempSumR = matrixR[x][y] + - matrixR[x - maskSizeX][y - maskSizeY] - - (matrixR[x - maskSizeX][y] + matrixR[x][y - maskSizeY]); - const tempSumG = matrixG[x][y] + - matrixG[x - maskSizeX][y - maskSizeY] - - (matrixG[x - maskSizeX][y] + matrixG[x][y - maskSizeY]); - const tempSumB = matrixB[x][y] + - matrixB[x - maskSizeX][y - maskSizeY] - - (matrixB[x - maskSizeX][y] + matrixB[x][y - maskSizeY]); - const distance = Math.sqrt(Math.pow(0 - tempSumR, 2) + - Math.pow(totalSum - tempSumG, 2) + - Math.pow(0 - tempSumB, 2)); - const similarity = 1 - distance / maxDistance; - if (similarity > bestSimilarity) { - bestX = x; - bestY = y; - bestSimilarity = similarity; - } - } - } - } - if (bestX >= 0 && bestY >= 0 && bestSimilarity > suitableSimilarity) { - return { - fromL: bestX - maskSizeX, - fromT: bestY - maskSizeY, - toL: bestX - maskSizeX + chromakeyWidth, - toT: bestY - maskSizeY + chromakeyHeight, - }; - } - return { fromL: -1, fromT: -1, toL: -1, toT: -1 }; -}; -const putQrCodeOnChromakeyTemplate = (qrCodeImageBase64, templateImageBase64, placeholderWidth, placeholderHeight, scale = 1) => __awaiter(void 0, void 0, void 0, function* () { - const qrCodeImage = yield loadImage(qrCodeImageBase64); - const templateImage = yield loadImage(templateImageBase64); - if (templateImage.width < placeholderWidth || - templateImage.height < placeholderHeight) { - throw new Error("Placeholder is bigger than image"); - } - const templateCanvas = document.createElement("canvas"); - templateCanvas.width = templateImage.width; - templateCanvas.height = templateImage.height; - const templateCtx = templateCanvas.getContext("2d"); - templateCtx.drawImage(templateImage, 0, 0, templateImage.width, templateImage.height); - const templateImgData = templateCtx.getImageData(0, 0, templateCanvas.width, templateCanvas.height); - const placeholderCoordinates = findChromakeyBoundaries(templateImage.width, templateImage.height, templateImgData, placeholderWidth, placeholderHeight); - // -2 is for QR to slightly cover borders. To avoid green mask bulging out - const scaleX = ((qrCodeImage.width - 2) / placeholderWidth) * scale; - const scaleY = ((qrCodeImage.height - 2) / placeholderHeight) * scale; - qrCodeImage.width *= scale; - qrCodeImage.height *= scale; - const bannerCanvas = document.createElement("canvas"); - const scaledTemplateW = Math.floor(templateImage.width * scaleX); - const scaledTemplateH = Math.floor(templateImage.height * scaleY); - bannerCanvas.width = scaledTemplateW; - bannerCanvas.height = scaledTemplateH; - const bannerCtx = bannerCanvas.getContext("2d"); - // bannerCtx - bannerCtx.drawImage(templateImage, 0, 0, templateImage.width, templateImage.height, 0, 0, scaledTemplateW, scaledTemplateH); - // +1 hides green border - bannerCtx.drawImage(qrCodeImage, placeholderCoordinates.fromL * scaleX, placeholderCoordinates.fromT * scaleY, qrCodeImage.width, qrCodeImage.height); - return bannerCanvas.toDataURL(); -}); -const loadImage = (imageSrc) => { - return new Promise((resolve, reject) => { - const templateImg = document.createElement("img"); - templateImg.src = imageSrc; - templateImg.onload = () => resolve(templateImg); - templateImg.onerror = () => reject(); - }); -}; -exports.default = { - putQrCodeOnChromakeyTemplate, -}; diff --git a/dist/utils/rka.d.ts b/dist/utils/rka.d.ts deleted file mode 100644 index d5f7c0664f026147240d636dba2ce12d75562b54..0000000000000000000000000000000000000000 --- a/dist/utils/rka.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Utility implementing Rabin-Karp algorithm - * https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm - */ -declare const _default: { - getRabinFingerprint: (string: string) => string; - searchFingerprintInText: (text: string, keywordHashHexString: string, size: number) => number; - /** - * @deprecated Will be deleted in version 1.0.1. Use getRabinFingerprint instead. - */ - getRollingHash: (string: string) => string; - /** - * @deprecated Will be deleted in version 1.0.1. Use searchFingerprintInText instead. - */ - searchHashInText: (text: string, keywordHashHexString: string, size: number) => number; -}; -export default _default; diff --git a/dist/utils/rka.js b/dist/utils/rka.js deleted file mode 100644 index f671a05192246fc35b4bd7409d7243fd1c476e7a..0000000000000000000000000000000000000000 --- a/dist/utils/rka.js +++ /dev/null @@ -1,71 +0,0 @@ -"use strict"; -/** - * Utility implementing Rabin-Karp algorithm - * https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm - */ -Object.defineProperty(exports, "__esModule", { value: true }); -// Do not use "import" directive. Does not work properly for both browser and Node JS -const jsbi = require("jsbi"); -const base = jsbi.BigInt("67280421310721"); -const prime = jsbi.BigInt("285542542228279613901563566102164008326164238644702889199247456602284400390600653875954571505539843239754513915896150297878399377056071435169747221107988791198200988477531339214282772016059009904586686254989084815735422480409022344297588352526004383890632616124076317387416881148592486188361873904175783145696016919574390765598280188599035578448591077683677175520434074287726578006266759615970759521327828555662781678385691581844436444812511562428136742490459363212810180276096088111401003377570363545725120924073646921576797146199387619296560302680261790118132925012323046444438622308877924609373773012481681672424493674474488537770155783006880852648161513067144814790288366664062257274665275787127374649231096375001170901890786263324619578795731425693805073056119677580338084333381987500902968831935913095269821311141322393356490178488728982288156282600813831296143663845945431144043753821542871277745606447858564159213328443580206422714694913091762716447041689678070096773590429808909616750452927258000843500344831628297089902728649981994387647234574276263729694848304750917174186181130688518792748622612293341368928056634384466646326572476167275660839105650528975713899320211121495795311427946254553305387067821067601768750977866100460014602138408448021225053689054793742003095722096732954750721718115531871310231057902608580607"); -const getRabinFingerprint = (string) => { - let hash = jsbi.BigInt(0); - for (let i = 0; i < string.length; i++) { - hash = jsbi.remainder(jsbi.multiply(hash, base), prime); - hash = jsbi.remainder(jsbi.add(hash, jsbi.BigInt(string.charCodeAt(i))), prime); - // TODO: Wait for a broader adoption of the native BigInt and use :) - // hash = (hash * base) % prime; - // hash = (hash + BigInt(string.charCodeAt(i))) % prime; - } - return "0x" + hash.toString(16); -}; -const searchFingerprintInText = (text, keywordHashHexString, size) => { - const keywordHash = jsbi.BigInt(keywordHashHexString); - if (size > text.length) { - return -1; - } - let leftHash = jsbi.BigInt(0); - let rightHash = jsbi.BigInt(0); - let powerOfBase = jsbi.BigInt(1); - for (let i = 0; i < size; i++) { - rightHash = jsbi.remainder(jsbi.multiply(rightHash, base), prime); - rightHash = jsbi.remainder(jsbi.add(rightHash, jsbi.BigInt(text.charCodeAt(i))), prime); - powerOfBase = jsbi.remainder(jsbi.multiply(powerOfBase, base), prime); - } - let index; - for (index = 0; index + size < text.length; index++) { - const hashCandidate = jsbi.remainder(jsbi.add(keywordHash, jsbi.multiply(leftHash, powerOfBase)), prime); - if (jsbi.equal(hashCandidate, rightHash)) { - return index; - } - rightHash = jsbi.remainder(jsbi.multiply(rightHash, base), prime); - rightHash = jsbi.remainder(jsbi.add(rightHash, jsbi.BigInt(text.charCodeAt(index + size))), prime); - leftHash = jsbi.remainder(jsbi.multiply(leftHash, base), prime); - leftHash = jsbi.remainder(jsbi.add(leftHash, jsbi.BigInt(text.charCodeAt(index))), prime); - } - const hashCandidate = jsbi.remainder(jsbi.add(keywordHash, jsbi.multiply(leftHash, powerOfBase)), prime); - if (jsbi.equal(hashCandidate, rightHash)) { - return index; - } - return -1; -}; -/** - * @deprecated Will be deleted in version 1.0.1. Use getRabinFingerprint instead. - */ -const getRollingHash = getRabinFingerprint; -/** - * @deprecated Will be deleted in version 1.0.1. Use searchFingerprintInText instead. - */ -const searchHashInText = searchFingerprintInText; -exports.default = { - getRabinFingerprint, - searchFingerprintInText, - /** - * @deprecated Will be deleted in version 1.0.1. Use getRabinFingerprint instead. - */ - getRollingHash, - /** - * @deprecated Will be deleted in version 1.0.1. Use searchFingerprintInText instead. - */ - searchHashInText, -}; diff --git a/dist/utils/stringUtils.d.ts b/dist/utils/stringUtils.d.ts deleted file mode 100644 index 4a534c0b2cea6597399f003f3872310489fc7306..0000000000000000000000000000000000000000 --- a/dist/utils/stringUtils.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare const removeSpacesAndLinebreaks: (s: string) => string; diff --git a/dist/utils/stringUtils.js b/dist/utils/stringUtils.js deleted file mode 100644 index 0ccda9acc2608da3538e1528b77f6ae11ce47093..0000000000000000000000000000000000000000 --- a/dist/utils/stringUtils.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.removeSpacesAndLinebreaks = void 0; -exports.removeSpacesAndLinebreaks = (s) => { - const regexNewlines = new RegExp(/[\r\n\v]+/g); - const regexSpaces = new RegExp(/\s+|\u200B/g); - return s.replace(regexNewlines, "").replace(regexSpaces, ""); -}; diff --git a/package.json b/package.json index 020e722980f6532298e22169a1b20218516f4a3d..8e91046b51b35c0dbc70f3a7b321d5086c6ef496 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "typescript": "^4.0.2" }, "scripts": { + "prepare": "yarn build", "start": "tsc --watch", "build": "tsc", "test": "jest",