diff --git a/__tests__/ObfuscationService.test.js b/__tests__/ObfuscationService.test.js index eac2ccee3d051d1a267cec0236eb98974dbe62ce..1f6374c237920f867989ba3f5452f37ee81f68f9 100644 --- a/__tests__/ObfuscationService.test.js +++ b/__tests__/ObfuscationService.test.js @@ -1,6 +1,5 @@ -/* eslint-disable no-undef */ import * as ObfuscationService from "../src/services/ObfuscationService"; -import { describe, test } from "@jest/globals"; +import { describe, test, expect } from "@jest/globals"; const encodeObject = (object) => { const enc = new TextEncoder(); // always utf-8 diff --git a/__tests__/StatusesService.test.js b/__tests__/StatusesService.test.js new file mode 100644 index 0000000000000000000000000000000000000000..785d747af37fe75b4d548b44e4bf570f612c6c11 --- /dev/null +++ b/__tests__/StatusesService.test.js @@ -0,0 +1,9 @@ +import { describe, test } from "@jest/globals"; +import StatusesService from "../src/services/StatusesService"; + +describe("StatusesService", () => { + test("test", async () => { + const statusesService = new StatusesService(); + statusesService.test(); + }); +}); diff --git a/package.json b/package.json index f7105ec0facaf636a33e06b5e61dcc8aab91df39..528837d8b15009f591a114e7f6bbe9f95906d94f 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ }, "dependencies": { "axios": "^0.20.0", + "google-protobuf": "^3.13.0", "merkletreejs": "^0.2.9" } } diff --git a/src/services/StatusesService/StatusesService.ts b/src/services/StatusesService/StatusesService.ts new file mode 100644 index 0000000000000000000000000000000000000000..7d67db923ad2cac393e10e2135f3e32ae070da0b --- /dev/null +++ b/src/services/StatusesService/StatusesService.ts @@ -0,0 +1,52 @@ +// const statuses = require("./objects/statuses_pb"); +// const { arrayBufferToBase64 } = require("../../../dist/utils"); + +// var message = new messages.MyMessage(); + +class StatusesService { + // test(): void { + // // console.log(goog); + // // console.log("Kaz", proto.vereign.statuses.SenderStatusObject); + // const senderStatus = new statuses.SenderStatusObject(); + // senderStatus.setSignaturetime(200); + // + // const string = "Test"; + // + // const enc = new TextEncoder(); // always utf-8 + // const encodedString = enc.encode(string); + // + // // const arrayBuffer = arrayBufferToBase64() + // + // senderStatus.setSignaturetimesignature( + // arrayBufferToBase64(encodedString.buffer) + // ); + // console.log(senderStatus.toObject()); + // const buffer = senderStatus.serializeBinary().buffer; + // + // const serialized = statuses.SenderStatusObject.deserializeBinary( + // new Uint8Array(buffer) + // ); + // // console.log(serialized.toObject()); + // // console.log(senderStatus.); + // // goog.nodeGlobalRequire("proto.vereign.statuses.SenderStatusObject"); + // // var sha1 = new goog.crypt.Sha1(); + // // sha1.update("foobar"); + // // var hash = sha1.digest(); + // // console.log(hash); + // } + /** + * + * @param signatureTime + * @param signatureTimeSignature + * @param messageSignature + * @param attachmentsSignature + */ + // createSenderStatusObject( + // signatureTime: number, + // signatureTimeSignature: string, + // messageSignature: string, + // attachmentsSignature: { [key: string]: string } + // ): string {} +} + +export default StatusesService; diff --git a/src/services/StatusesService/index.ts b/src/services/StatusesService/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..54fc9a6c30456d625fb6b3c5269cdc5708fef7a7 --- /dev/null +++ b/src/services/StatusesService/index.ts @@ -0,0 +1,3 @@ +import StatusesService from "./StatusesService"; + +export default StatusesService; diff --git a/src/services/StatusesService/objects/statuses_pb.js b/src/services/StatusesService/objects/statuses_pb.js new file mode 100644 index 0000000000000000000000000000000000000000..44a6a1650b96387f0ebca35da1c8e4e682c26b54 --- /dev/null +++ b/src/services/StatusesService/objects/statuses_pb.js @@ -0,0 +1,1084 @@ +/* eslint-disable */ + +/** + * @fileoverview + * @enhanceable + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! + +var jspb = require("google-protobuf"); +var goog = jspb; +var global = Function("return this")(); + +goog.exportSymbol("proto.vereign.statuses.RecipientStatusData", null, global); +goog.exportSymbol("proto.vereign.statuses.RecipientStatusObject", null, global); +goog.exportSymbol("proto.vereign.statuses.SenderStatusObject", null, global); +goog.exportSymbol("proto.vereign.statuses.WrapperData", null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.vereign.statuses.SenderStatusObject = function (opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.vereign.statuses.SenderStatusObject, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.vereign.statuses.SenderStatusObject.displayName = + "proto.vereign.statuses.SenderStatusObject"; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.vereign.statuses.RecipientStatusData = function (opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.vereign.statuses.RecipientStatusData, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.vereign.statuses.RecipientStatusData.displayName = + "proto.vereign.statuses.RecipientStatusData"; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.vereign.statuses.RecipientStatusObject = function (opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.vereign.statuses.RecipientStatusObject, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.vereign.statuses.RecipientStatusObject.displayName = + "proto.vereign.statuses.RecipientStatusObject"; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.vereign.statuses.WrapperData = function (opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.vereign.statuses.WrapperData, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.vereign.statuses.WrapperData.displayName = + "proto.vereign.statuses.WrapperData"; +} + +if (jspb.Message.GENERATE_TO_OBJECT) { + /** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ + proto.vereign.statuses.SenderStatusObject.prototype.toObject = function ( + opt_includeInstance + ) { + return proto.vereign.statuses.SenderStatusObject.toObject( + opt_includeInstance, + this + ); + }; + + /** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.vereign.statuses.SenderStatusObject} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + proto.vereign.statuses.SenderStatusObject.toObject = function ( + includeInstance, + msg + ) { + var f, + obj = { + signaturetime: + (f = jspb.Message.getFieldWithDefault(msg, 1, 0)) == null + ? undefined + : f, + signaturetimesignature: msg.getSignaturetimesignature_asB64(), + messagesignature: msg.getMessagesignature_asB64(), + attachmentssignatureMap: (f = msg.getAttachmentssignatureMap()) + ? f.toObject(includeInstance, undefined) + : [], + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; + }; +} + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.vereign.statuses.SenderStatusObject} + */ +proto.vereign.statuses.SenderStatusObject.deserializeBinary = function (bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.vereign.statuses.SenderStatusObject(); + return proto.vereign.statuses.SenderStatusObject.deserializeBinaryFromReader( + msg, + reader + ); +}; + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.vereign.statuses.SenderStatusObject} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.vereign.statuses.SenderStatusObject} + */ +proto.vereign.statuses.SenderStatusObject.deserializeBinaryFromReader = function ( + msg, + reader +) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt64()); + msg.setSignaturetime(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setSignaturetimesignature(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setMessagesignature(value); + break; + case 4: + var value = msg.getAttachmentssignatureMap(); + reader.readMessage(value, function (message, reader) { + jspb.Map.deserializeBinary( + message, + reader, + jspb.BinaryReader.prototype.readString, + jspb.BinaryReader.prototype.readBytes, + null, + "" + ); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.vereign.statuses.SenderStatusObject.prototype.serializeBinary = function () { + var writer = new jspb.BinaryWriter(); + proto.vereign.statuses.SenderStatusObject.serializeBinaryToWriter( + this, + writer + ); + return writer.getResultBuffer(); +}; + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.vereign.statuses.SenderStatusObject} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.vereign.statuses.SenderStatusObject.serializeBinaryToWriter = function ( + message, + writer +) { + var f = undefined; + f = message.getSignaturetime(); + if (f !== 0) { + writer.writeInt64(1, f); + } + f = message.getSignaturetimesignature_asU8(); + if (f.length > 0) { + writer.writeBytes(2, f); + } + f = message.getMessagesignature_asU8(); + if (f.length > 0) { + writer.writeBytes(3, f); + } + f = message.getAttachmentssignatureMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary( + 4, + writer, + jspb.BinaryWriter.prototype.writeString, + jspb.BinaryWriter.prototype.writeBytes + ); + } +}; + +/** + * optional int64 signatureTime = 1; + * @return {number} + */ +proto.vereign.statuses.SenderStatusObject.prototype.getSignaturetime = function () { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + +/** @param {number} value */ +proto.vereign.statuses.SenderStatusObject.prototype.setSignaturetime = function ( + value +) { + jspb.Message.setProto3IntField(this, 1, value); +}; + +/** + * optional bytes signatureTimeSignature = 2; + * @return {string} + */ +proto.vereign.statuses.SenderStatusObject.prototype.getSignaturetimesignature = function () { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + +/** + * optional bytes signatureTimeSignature = 2; + * This is a type-conversion wrapper around `getSignaturetimesignature()` + * @return {string} + */ +proto.vereign.statuses.SenderStatusObject.prototype.getSignaturetimesignature_asB64 = function () { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getSignaturetimesignature() + )); +}; + +/** + * optional bytes signatureTimeSignature = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getSignaturetimesignature()` + * @return {!Uint8Array} + */ +proto.vereign.statuses.SenderStatusObject.prototype.getSignaturetimesignature_asU8 = function () { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getSignaturetimesignature() + )); +}; + +/** @param {!(string|Uint8Array)} value */ +proto.vereign.statuses.SenderStatusObject.prototype.setSignaturetimesignature = function ( + value +) { + jspb.Message.setProto3BytesField(this, 2, value); +}; + +/** + * optional bytes messageSignature = 3; + * @return {string} + */ +proto.vereign.statuses.SenderStatusObject.prototype.getMessagesignature = function () { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + +/** + * optional bytes messageSignature = 3; + * This is a type-conversion wrapper around `getMessagesignature()` + * @return {string} + */ +proto.vereign.statuses.SenderStatusObject.prototype.getMessagesignature_asB64 = function () { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getMessagesignature() + )); +}; + +/** + * optional bytes messageSignature = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getMessagesignature()` + * @return {!Uint8Array} + */ +proto.vereign.statuses.SenderStatusObject.prototype.getMessagesignature_asU8 = function () { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getMessagesignature() + )); +}; + +/** @param {!(string|Uint8Array)} value */ +proto.vereign.statuses.SenderStatusObject.prototype.setMessagesignature = function ( + value +) { + jspb.Message.setProto3BytesField(this, 3, value); +}; + +/** + * map<string, bytes> attachmentsSignature = 4; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map<string,!(string|Uint8Array)>} + */ +proto.vereign.statuses.SenderStatusObject.prototype.getAttachmentssignatureMap = function ( + opt_noLazyCreate +) { + return /** @type {!jspb.Map<string,!(string|Uint8Array)>} */ (jspb.Message.getMapField( + this, + 4, + opt_noLazyCreate, + null + )); +}; + +/** + * Clears values from the map. The map will be non-null. + */ +proto.vereign.statuses.SenderStatusObject.prototype.clearAttachmentssignatureMap = function () { + this.getAttachmentssignatureMap().clear(); +}; + +if (jspb.Message.GENERATE_TO_OBJECT) { + /** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ + proto.vereign.statuses.RecipientStatusData.prototype.toObject = function ( + opt_includeInstance + ) { + return proto.vereign.statuses.RecipientStatusData.toObject( + opt_includeInstance, + this + ); + }; + + /** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.vereign.statuses.RecipientStatusData} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + proto.vereign.statuses.RecipientStatusData.toObject = function ( + includeInstance, + msg + ) { + var f, + obj = { + creationdate: + (f = jspb.Message.getFieldWithDefault(msg, 1, 0)) == null + ? undefined + : f, + gatewaydomainhash: msg.getGatewaydomainhash_asB64(), + randomtoken: msg.getRandomtoken_asB64(), + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; + }; +} + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.vereign.statuses.RecipientStatusData} + */ +proto.vereign.statuses.RecipientStatusData.deserializeBinary = function ( + bytes +) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.vereign.statuses.RecipientStatusData(); + return proto.vereign.statuses.RecipientStatusData.deserializeBinaryFromReader( + msg, + reader + ); +}; + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.vereign.statuses.RecipientStatusData} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.vereign.statuses.RecipientStatusData} + */ +proto.vereign.statuses.RecipientStatusData.deserializeBinaryFromReader = function ( + msg, + reader +) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt64()); + msg.setCreationdate(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setGatewaydomainhash(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setRandomtoken(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.vereign.statuses.RecipientStatusData.prototype.serializeBinary = function () { + var writer = new jspb.BinaryWriter(); + proto.vereign.statuses.RecipientStatusData.serializeBinaryToWriter( + this, + writer + ); + return writer.getResultBuffer(); +}; + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.vereign.statuses.RecipientStatusData} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.vereign.statuses.RecipientStatusData.serializeBinaryToWriter = function ( + message, + writer +) { + var f = undefined; + f = message.getCreationdate(); + if (f !== 0) { + writer.writeInt64(1, f); + } + f = message.getGatewaydomainhash_asU8(); + if (f.length > 0) { + writer.writeBytes(2, f); + } + f = message.getRandomtoken_asU8(); + if (f.length > 0) { + writer.writeBytes(3, f); + } +}; + +/** + * optional int64 creationDate = 1; + * @return {number} + */ +proto.vereign.statuses.RecipientStatusData.prototype.getCreationdate = function () { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + +/** @param {number} value */ +proto.vereign.statuses.RecipientStatusData.prototype.setCreationdate = function ( + value +) { + jspb.Message.setProto3IntField(this, 1, value); +}; + +/** + * optional bytes gatewayDomainHash = 2; + * @return {string} + */ +proto.vereign.statuses.RecipientStatusData.prototype.getGatewaydomainhash = function () { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + +/** + * optional bytes gatewayDomainHash = 2; + * This is a type-conversion wrapper around `getGatewaydomainhash()` + * @return {string} + */ +proto.vereign.statuses.RecipientStatusData.prototype.getGatewaydomainhash_asB64 = function () { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getGatewaydomainhash() + )); +}; + +/** + * optional bytes gatewayDomainHash = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getGatewaydomainhash()` + * @return {!Uint8Array} + */ +proto.vereign.statuses.RecipientStatusData.prototype.getGatewaydomainhash_asU8 = function () { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getGatewaydomainhash() + )); +}; + +/** @param {!(string|Uint8Array)} value */ +proto.vereign.statuses.RecipientStatusData.prototype.setGatewaydomainhash = function ( + value +) { + jspb.Message.setProto3BytesField(this, 2, value); +}; + +/** + * optional bytes randomToken = 3; + * @return {string} + */ +proto.vereign.statuses.RecipientStatusData.prototype.getRandomtoken = function () { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + +/** + * optional bytes randomToken = 3; + * This is a type-conversion wrapper around `getRandomtoken()` + * @return {string} + */ +proto.vereign.statuses.RecipientStatusData.prototype.getRandomtoken_asB64 = function () { + return /** @type {string} */ (jspb.Message.bytesAsB64(this.getRandomtoken())); +}; + +/** + * optional bytes randomToken = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getRandomtoken()` + * @return {!Uint8Array} + */ +proto.vereign.statuses.RecipientStatusData.prototype.getRandomtoken_asU8 = function () { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getRandomtoken() + )); +}; + +/** @param {!(string|Uint8Array)} value */ +proto.vereign.statuses.RecipientStatusData.prototype.setRandomtoken = function ( + value +) { + jspb.Message.setProto3BytesField(this, 3, value); +}; + +if (jspb.Message.GENERATE_TO_OBJECT) { + /** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ + proto.vereign.statuses.RecipientStatusObject.prototype.toObject = function ( + opt_includeInstance + ) { + return proto.vereign.statuses.RecipientStatusObject.toObject( + opt_includeInstance, + this + ); + }; + + /** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.vereign.statuses.RecipientStatusObject} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + proto.vereign.statuses.RecipientStatusObject.toObject = function ( + includeInstance, + msg + ) { + var f, + obj = { + iv: msg.getIv_asB64(), + encryptedcontent: msg.getEncryptedcontent_asB64(), + decryptorsMap: (f = msg.getDecryptorsMap()) + ? f.toObject(includeInstance, undefined) + : [], + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; + }; +} + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.vereign.statuses.RecipientStatusObject} + */ +proto.vereign.statuses.RecipientStatusObject.deserializeBinary = function ( + bytes +) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.vereign.statuses.RecipientStatusObject(); + return proto.vereign.statuses.RecipientStatusObject.deserializeBinaryFromReader( + msg, + reader + ); +}; + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.vereign.statuses.RecipientStatusObject} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.vereign.statuses.RecipientStatusObject} + */ +proto.vereign.statuses.RecipientStatusObject.deserializeBinaryFromReader = function ( + msg, + reader +) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setIv(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setEncryptedcontent(value); + break; + case 3: + var value = msg.getDecryptorsMap(); + reader.readMessage(value, function (message, reader) { + jspb.Map.deserializeBinary( + message, + reader, + jspb.BinaryReader.prototype.readString, + jspb.BinaryReader.prototype.readBytes, + null, + "" + ); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.vereign.statuses.RecipientStatusObject.prototype.serializeBinary = function () { + var writer = new jspb.BinaryWriter(); + proto.vereign.statuses.RecipientStatusObject.serializeBinaryToWriter( + this, + writer + ); + return writer.getResultBuffer(); +}; + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.vereign.statuses.RecipientStatusObject} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.vereign.statuses.RecipientStatusObject.serializeBinaryToWriter = function ( + message, + writer +) { + var f = undefined; + f = message.getIv_asU8(); + if (f.length > 0) { + writer.writeBytes(1, f); + } + f = message.getEncryptedcontent_asU8(); + if (f.length > 0) { + writer.writeBytes(2, f); + } + f = message.getDecryptorsMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary( + 3, + writer, + jspb.BinaryWriter.prototype.writeString, + jspb.BinaryWriter.prototype.writeBytes + ); + } +}; + +/** + * optional bytes iv = 1; + * @return {string} + */ +proto.vereign.statuses.RecipientStatusObject.prototype.getIv = function () { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + +/** + * optional bytes iv = 1; + * This is a type-conversion wrapper around `getIv()` + * @return {string} + */ +proto.vereign.statuses.RecipientStatusObject.prototype.getIv_asB64 = function () { + return /** @type {string} */ (jspb.Message.bytesAsB64(this.getIv())); +}; + +/** + * optional bytes iv = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getIv()` + * @return {!Uint8Array} + */ +proto.vereign.statuses.RecipientStatusObject.prototype.getIv_asU8 = function () { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8(this.getIv())); +}; + +/** @param {!(string|Uint8Array)} value */ +proto.vereign.statuses.RecipientStatusObject.prototype.setIv = function ( + value +) { + jspb.Message.setProto3BytesField(this, 1, value); +}; + +/** + * optional bytes encryptedContent = 2; + * @return {string} + */ +proto.vereign.statuses.RecipientStatusObject.prototype.getEncryptedcontent = function () { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + +/** + * optional bytes encryptedContent = 2; + * This is a type-conversion wrapper around `getEncryptedcontent()` + * @return {string} + */ +proto.vereign.statuses.RecipientStatusObject.prototype.getEncryptedcontent_asB64 = function () { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getEncryptedcontent() + )); +}; + +/** + * optional bytes encryptedContent = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getEncryptedcontent()` + * @return {!Uint8Array} + */ +proto.vereign.statuses.RecipientStatusObject.prototype.getEncryptedcontent_asU8 = function () { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getEncryptedcontent() + )); +}; + +/** @param {!(string|Uint8Array)} value */ +proto.vereign.statuses.RecipientStatusObject.prototype.setEncryptedcontent = function ( + value +) { + jspb.Message.setProto3BytesField(this, 2, value); +}; + +/** + * map<string, bytes> decryptors = 3; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map<string,!(string|Uint8Array)>} + */ +proto.vereign.statuses.RecipientStatusObject.prototype.getDecryptorsMap = function ( + opt_noLazyCreate +) { + return /** @type {!jspb.Map<string,!(string|Uint8Array)>} */ (jspb.Message.getMapField( + this, + 3, + opt_noLazyCreate, + null + )); +}; + +/** + * Clears values from the map. The map will be non-null. + */ +proto.vereign.statuses.RecipientStatusObject.prototype.clearDecryptorsMap = function () { + this.getDecryptorsMap().clear(); +}; + +if (jspb.Message.GENERATE_TO_OBJECT) { + /** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ + proto.vereign.statuses.WrapperData.prototype.toObject = function ( + opt_includeInstance + ) { + return proto.vereign.statuses.WrapperData.toObject( + opt_includeInstance, + this + ); + }; + + /** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.vereign.statuses.WrapperData} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + proto.vereign.statuses.WrapperData.toObject = function ( + includeInstance, + msg + ) { + var f, + obj = { + data: msg.getData_asB64(), + version: + (f = jspb.Message.getFieldWithDefault(msg, 2, 0)) == null + ? undefined + : f, + classname: + (f = jspb.Message.getFieldWithDefault(msg, 3, "")) == null + ? undefined + : f, + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; + }; +} + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.vereign.statuses.WrapperData} + */ +proto.vereign.statuses.WrapperData.deserializeBinary = function (bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.vereign.statuses.WrapperData(); + return proto.vereign.statuses.WrapperData.deserializeBinaryFromReader( + msg, + reader + ); +}; + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.vereign.statuses.WrapperData} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.vereign.statuses.WrapperData} + */ +proto.vereign.statuses.WrapperData.deserializeBinaryFromReader = function ( + msg, + reader +) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + case 2: + var value = /** @type {number} */ (reader.readInt32()); + msg.setVersion(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setClassname(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.vereign.statuses.WrapperData.prototype.serializeBinary = function () { + var writer = new jspb.BinaryWriter(); + proto.vereign.statuses.WrapperData.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.vereign.statuses.WrapperData} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.vereign.statuses.WrapperData.serializeBinaryToWriter = function ( + message, + writer +) { + var f = undefined; + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes(1, f); + } + f = message.getVersion(); + if (f !== 0) { + writer.writeInt32(2, f); + } + f = message.getClassname(); + if (f.length > 0) { + writer.writeString(3, f); + } +}; + +/** + * optional bytes data = 1; + * @return {string} + */ +proto.vereign.statuses.WrapperData.prototype.getData = function () { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + +/** + * optional bytes data = 1; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.vereign.statuses.WrapperData.prototype.getData_asB64 = function () { + return /** @type {string} */ (jspb.Message.bytesAsB64(this.getData())); +}; + +/** + * optional bytes data = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.vereign.statuses.WrapperData.prototype.getData_asU8 = function () { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8(this.getData())); +}; + +/** @param {!(string|Uint8Array)} value */ +proto.vereign.statuses.WrapperData.prototype.setData = function (value) { + jspb.Message.setProto3BytesField(this, 1, value); +}; + +/** + * optional int32 version = 2; + * @return {number} + */ +proto.vereign.statuses.WrapperData.prototype.getVersion = function () { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + +/** @param {number} value */ +proto.vereign.statuses.WrapperData.prototype.setVersion = function (value) { + jspb.Message.setProto3IntField(this, 2, value); +}; + +/** + * optional string className = 3; + * @return {string} + */ +proto.vereign.statuses.WrapperData.prototype.getClassname = function () { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + +/** @param {string} value */ +proto.vereign.statuses.WrapperData.prototype.setClassname = function (value) { + jspb.Message.setProto3StringField(this, 3, value); +}; + +goog.object.extend(exports, proto.vereign.statuses); diff --git a/src/types.ts b/src/types.ts index b35dd52f84b37d4a46f8b51aeb7ac5c9956480c7..bb658b59372144f5c93862bd907c845f0ef9e08c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -69,3 +69,28 @@ export interface TxMerkleeTreeData { merkleeTreeFileName: string; rootNodeHash: string; } + +export interface SenderStatusObject { + signatureTime: number; + signatureTimeSignature: Uint8Array; + messageSignature: Uint8Array; + attachmentsSignature: { [key: string]: Uint8Array }; +} + +export interface RecipientStatusObjectData { + creationData: number; + gatewayDomainHash: Uint8Array; + randomToken: Uint8Array; +} + +export interface RecipientStatusObject { + iv: Uint8Array; + encryptedContent: Uint8Array; + decryptors: { [key: string]: Uint8Array }; +} + +export interface WrapperData { + data: Uint8Array; + version: number; + className: string; +} diff --git a/yarn.lock b/yarn.lock index dd7fe4d7c75a34d308bcbf2ff8df3c4fbb8f9404..3e57b44f7ba59db27038896d158841e3b0460fb2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2485,6 +2485,11 @@ globals@^12.1.0: dependencies: type-fest "^0.8.1" +google-protobuf@^3.13.0: + version "3.13.0" + resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.13.0.tgz#909c5983d75dd6101ed57c79e0528d000cdc3251" + integrity sha512-ZIf3qfLFayVrPvAjeKKxO5FRF1/NwRxt6Dko+fWEMuHwHbZx8/fcaAao9b0wCM6kr8qeg2te8XTpyuvKuD9aKw== + graceful-fs@^4.2.4: version "4.2.4" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb"