diff --git a/doc/PROTO.md b/doc/PROTO.md index 327dec7..af1d118 100644 --- a/doc/PROTO.md +++ b/doc/PROTO.md @@ -522,6 +522,7 @@ Used to submit a request to Keystore RPC | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | +| requestType | [KSREQTYPE](#pb.KSREQTYPE) | | indicates the request type being performed | | name | [string](#string) | | name of the key the request is for sent by: KS_HAS, KS_GET, KS_PUT, KS_DELETE | | privateKey | [bytes](#bytes) | | the actual private key bytes sent by: KS_PUT | @@ -538,6 +539,7 @@ Used in response to a Keystore RPC | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | +| requestType | [KSREQTYPE](#pb.KSREQTYPE) | | indicates the request type being performed | | privateKey | [bytes](#bytes) | | the private key bytes sent by: KS_GET | | keyNames | [string](#string) | repeated | contains all known key names sent by: KS_LIST | | has | [bool](#bool) | | indicates if we have the key in our keystore sent by: KS_HAS | diff --git a/go/keystore.pb.go b/go/keystore.pb.go index 9ca5cfb..24c803a 100644 --- a/go/keystore.pb.go +++ b/go/keystore.pb.go @@ -69,12 +69,14 @@ func (KSREQTYPE) EnumDescriptor() ([]byte, []int) { // Used to submit a request to Keystore RPC type KeystoreRequest struct { + // indicates the request type being performed + RequestType KSREQTYPE `protobuf:"varint,1,opt,name=requestType,proto3,enum=pb.KSREQTYPE" json:"requestType,omitempty"` // name of the key the request is for // sent by: KS_HAS, KS_GET, KS_PUT, KS_DELETE - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // the actual private key bytes // sent by: KS_PUT - PrivateKey []byte `protobuf:"bytes,2,opt,name=privateKey,proto3" json:"privateKey,omitempty"` + PrivateKey []byte `protobuf:"bytes,3,opt,name=privateKey,proto3" json:"privateKey,omitempty"` } func (m *KeystoreRequest) Reset() { *m = KeystoreRequest{} } @@ -110,6 +112,13 @@ func (m *KeystoreRequest) XXX_DiscardUnknown() { var xxx_messageInfo_KeystoreRequest proto.InternalMessageInfo +func (m *KeystoreRequest) GetRequestType() KSREQTYPE { + if m != nil { + return m.RequestType + } + return KSREQTYPE_KS_HAS +} + func (m *KeystoreRequest) GetName() string { if m != nil { return m.Name @@ -126,15 +135,17 @@ func (m *KeystoreRequest) GetPrivateKey() []byte { // Used in response to a Keystore RPC type KeystoreResponse struct { + // indicates the request type being performed + RequestType KSREQTYPE `protobuf:"varint,1,opt,name=requestType,proto3,enum=pb.KSREQTYPE" json:"requestType,omitempty"` // the private key bytes // sent by: KS_GET - PrivateKey []byte `protobuf:"bytes,1,opt,name=privateKey,proto3" json:"privateKey,omitempty"` + PrivateKey []byte `protobuf:"bytes,2,opt,name=privateKey,proto3" json:"privateKey,omitempty"` // contains all known key names // sent by: KS_LIST - KeyNames []string `protobuf:"bytes,2,rep,name=keyNames,proto3" json:"keyNames,omitempty"` + KeyNames []string `protobuf:"bytes,3,rep,name=keyNames,proto3" json:"keyNames,omitempty"` // indicates if we have the key in our keystore // sent by: KS_HAS - Has bool `protobuf:"varint,3,opt,name=has,proto3" json:"has,omitempty"` + Has bool `protobuf:"varint,4,opt,name=has,proto3" json:"has,omitempty"` } func (m *KeystoreResponse) Reset() { *m = KeystoreResponse{} } @@ -170,6 +181,13 @@ func (m *KeystoreResponse) XXX_DiscardUnknown() { var xxx_messageInfo_KeystoreResponse proto.InternalMessageInfo +func (m *KeystoreResponse) GetRequestType() KSREQTYPE { + if m != nil { + return m.RequestType + } + return KSREQTYPE_KS_HAS +} + func (m *KeystoreResponse) GetPrivateKey() []byte { if m != nil { return m.PrivateKey @@ -200,25 +218,27 @@ func init() { func init() { proto.RegisterFile("keystore.proto", fileDescriptor_ac3dafe49d0dc795) } var fileDescriptor_ac3dafe49d0dc795 = []byte{ - // 280 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcb, 0x4e, 0xad, 0x2c, - 0x2e, 0xc9, 0x2f, 0x4a, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2a, 0x48, 0x52, 0x72, - 0xe5, 0xe2, 0xf7, 0x86, 0x8a, 0x06, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x08, 0x09, 0x71, 0xb1, - 0xe4, 0x25, 0xe6, 0xa6, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x81, 0xd9, 0x42, 0x72, 0x5c, - 0x5c, 0x05, 0x45, 0x99, 0x65, 0x89, 0x25, 0xa9, 0xde, 0xa9, 0x95, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, - 0x3c, 0x41, 0x48, 0x22, 0x4a, 0x09, 0x5c, 0x02, 0x08, 0x63, 0x8a, 0x0b, 0xf2, 0xf3, 0x8a, 0xd1, - 0xf5, 0x30, 0xa2, 0xeb, 0x11, 0x92, 0xe2, 0xe2, 0xc8, 0x4e, 0xad, 0xf4, 0x4b, 0xcc, 0x4d, 0x2d, - 0x96, 0x60, 0x52, 0x60, 0xd6, 0xe0, 0x0c, 0x82, 0xf3, 0x85, 0x04, 0xb8, 0x98, 0x33, 0x12, 0x8b, - 0x25, 0x98, 0x15, 0x18, 0x35, 0x38, 0x82, 0x40, 0x4c, 0x2d, 0x6f, 0x2e, 0x4e, 0xef, 0xe0, 0x20, - 0xd7, 0xc0, 0x90, 0xc8, 0x00, 0x57, 0x21, 0x2e, 0x2e, 0x36, 0xef, 0xe0, 0x78, 0x0f, 0xc7, 0x60, - 0x01, 0x06, 0x28, 0xdb, 0xdd, 0x35, 0x44, 0x80, 0x11, 0xca, 0x0e, 0x08, 0x0d, 0x11, 0x60, 0x12, - 0xe2, 0x05, 0x69, 0x88, 0x77, 0x71, 0xf5, 0x71, 0x0d, 0x71, 0x15, 0x60, 0x16, 0xe2, 0xe6, 0x62, - 0xf7, 0x0e, 0x8e, 0xf7, 0xf1, 0x0c, 0x0e, 0x11, 0x60, 0x31, 0x72, 0xe3, 0xe2, 0x86, 0x39, 0xd7, - 0x31, 0xc0, 0x53, 0xc8, 0x9c, 0x8b, 0x03, 0xc6, 0x15, 0x12, 0xd6, 0x2b, 0x48, 0xd2, 0x43, 0x0b, - 0x12, 0x29, 0x11, 0x54, 0x41, 0x88, 0x07, 0x95, 0x18, 0x9c, 0x24, 0x4e, 0x3c, 0x92, 0x63, 0xbc, - 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, - 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x89, 0x0d, 0x1c, 0xc4, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x89, 0x40, 0xe1, 0x31, 0x74, 0x01, 0x00, 0x00, + // 309 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xbd, 0x4e, 0x32, 0x41, + 0x14, 0x86, 0x77, 0x76, 0x09, 0x1f, 0x1c, 0x3e, 0x70, 0x72, 0xb4, 0xd8, 0x50, 0x4c, 0x36, 0x54, + 0x1b, 0x0b, 0x4c, 0xb0, 0xb0, 0xc6, 0x38, 0x2a, 0x19, 0x62, 0x70, 0x76, 0x2c, 0xac, 0xc8, 0x92, + 0x4c, 0xa2, 0x21, 0xb0, 0xe3, 0xce, 0x4a, 0xb2, 0x77, 0xa1, 0x77, 0x65, 0x49, 0x69, 0x69, 0xe0, + 0x46, 0x0c, 0xbf, 0xb2, 0x76, 0x76, 0xcf, 0x79, 0x33, 0x93, 0x27, 0xe7, 0x3d, 0xd0, 0x18, 0xeb, + 0xdc, 0x66, 0x49, 0xaa, 0xdb, 0x26, 0x4d, 0xb2, 0x04, 0x5d, 0x33, 0x6a, 0xcd, 0xe0, 0x48, 0x6c, + 0x53, 0xa9, 0x5f, 0x5e, 0xb5, 0xcd, 0xf0, 0x0c, 0x6a, 0xe9, 0x06, 0x55, 0x6e, 0xb4, 0x4f, 0x02, + 0x12, 0x36, 0x3a, 0xf5, 0xb6, 0x19, 0xb5, 0x45, 0x24, 0xf9, 0xbd, 0x7a, 0x1c, 0x70, 0x79, 0xf8, + 0x02, 0x11, 0x4a, 0xd3, 0x78, 0xa2, 0x7d, 0x37, 0x20, 0x61, 0x55, 0xae, 0x19, 0x19, 0x80, 0x49, + 0x9f, 0x67, 0x71, 0xa6, 0x85, 0xce, 0x7d, 0x2f, 0x20, 0xe1, 0x7f, 0x79, 0x90, 0xb4, 0xde, 0x09, + 0xd0, 0x1f, 0xb1, 0x35, 0xc9, 0xd4, 0xea, 0xbf, 0x9b, 0x8b, 0x16, 0xf7, 0xb7, 0x05, 0x9b, 0x50, + 0x19, 0xeb, 0xfc, 0x2e, 0x9e, 0x68, 0xeb, 0x7b, 0x81, 0x17, 0x56, 0xe5, 0x7e, 0x46, 0x0a, 0xde, + 0x53, 0x6c, 0xfd, 0x52, 0x40, 0xc2, 0x8a, 0x5c, 0xe1, 0xa9, 0x80, 0xea, 0xde, 0x83, 0x00, 0x65, + 0x11, 0x0d, 0x6f, 0xbb, 0x11, 0x75, 0xb6, 0x7c, 0xc3, 0x15, 0x25, 0x5b, 0x1e, 0x3c, 0x28, 0xea, + 0x62, 0x7d, 0xf5, 0x61, 0x78, 0xc5, 0xfb, 0x5c, 0x71, 0xea, 0x61, 0x0d, 0xfe, 0x89, 0x68, 0xd8, + 0xef, 0x45, 0x8a, 0x96, 0x3a, 0xd7, 0x50, 0xdb, 0xed, 0xd7, 0x1d, 0xf4, 0xf0, 0x02, 0x2a, 0xbb, + 0x11, 0x8f, 0xd7, 0x1b, 0x15, 0x5b, 0x6f, 0x9e, 0x14, 0xc3, 0x4d, 0x23, 0x2d, 0xe7, 0xd2, 0xff, + 0x58, 0x30, 0x32, 0x5f, 0x30, 0xf2, 0xb5, 0x60, 0xe4, 0x6d, 0xc9, 0x9c, 0xf9, 0x92, 0x39, 0x9f, + 0x4b, 0xe6, 0x8c, 0xca, 0xeb, 0x2b, 0x9e, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x06, 0x47, 0x3e, + 0x74, 0xd7, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -328,14 +348,19 @@ func (m *KeystoreRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.PrivateKey) i = encodeVarintKeystore(dAtA, i, uint64(len(m.PrivateKey))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } if len(m.Name) > 0 { i -= len(m.Name) copy(dAtA[i:], m.Name) i = encodeVarintKeystore(dAtA, i, uint64(len(m.Name))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + if m.RequestType != 0 { + i = encodeVarintKeystore(dAtA, i, uint64(m.RequestType)) + i-- + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -368,7 +393,7 @@ func (m *KeystoreResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if len(m.KeyNames) > 0 { for iNdEx := len(m.KeyNames) - 1; iNdEx >= 0; iNdEx-- { @@ -376,7 +401,7 @@ func (m *KeystoreResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.KeyNames[iNdEx]) i = encodeVarintKeystore(dAtA, i, uint64(len(m.KeyNames[iNdEx]))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } } if len(m.PrivateKey) > 0 { @@ -384,7 +409,12 @@ func (m *KeystoreResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.PrivateKey) i = encodeVarintKeystore(dAtA, i, uint64(len(m.PrivateKey))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + if m.RequestType != 0 { + i = encodeVarintKeystore(dAtA, i, uint64(m.RequestType)) + i-- + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -406,6 +436,9 @@ func (m *KeystoreRequest) Size() (n int) { } var l int _ = l + if m.RequestType != 0 { + n += 1 + sovKeystore(uint64(m.RequestType)) + } l = len(m.Name) if l > 0 { n += 1 + l + sovKeystore(uint64(l)) @@ -423,6 +456,9 @@ func (m *KeystoreResponse) Size() (n int) { } var l int _ = l + if m.RequestType != 0 { + n += 1 + sovKeystore(uint64(m.RequestType)) + } l = len(m.PrivateKey) if l > 0 { n += 1 + l + sovKeystore(uint64(l)) @@ -475,6 +511,25 @@ func (m *KeystoreRequest) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestType", wireType) + } + m.RequestType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeystore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestType |= KSREQTYPE(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } @@ -506,7 +561,7 @@ func (m *KeystoreRequest) Unmarshal(dAtA []byte) error { } m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PrivateKey", wireType) } @@ -594,6 +649,25 @@ func (m *KeystoreResponse) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestType", wireType) + } + m.RequestType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowKeystore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestType |= KSREQTYPE(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PrivateKey", wireType) } @@ -627,7 +701,7 @@ func (m *KeystoreResponse) Unmarshal(dAtA []byte) error { m.PrivateKey = []byte{} } iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field KeyNames", wireType) } @@ -659,7 +733,7 @@ func (m *KeystoreResponse) Unmarshal(dAtA []byte) error { } m.KeyNames = append(m.KeyNames, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Has", wireType) } diff --git a/js/keystore_pb.js b/js/keystore_pb.js index 4e8d04f..313f312 100644 --- a/js/keystore_pb.js +++ b/js/keystore_pb.js @@ -89,7 +89,8 @@ proto.pb.KeystoreRequest.prototype.toObject = function(opt_includeInstance) { */ proto.pb.KeystoreRequest.toObject = function(includeInstance, msg) { var f, obj = { - name: jspb.Message.getFieldWithDefault(msg, 1, ""), + requesttype: jspb.Message.getFieldWithDefault(msg, 1, 0), + name: jspb.Message.getFieldWithDefault(msg, 2, ""), privatekey: msg.getPrivatekey_asB64() }; @@ -128,10 +129,14 @@ proto.pb.KeystoreRequest.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: + var value = /** @type {!proto.pb.KSREQTYPE} */ (reader.readEnum()); + msg.setRequesttype(value); + break; + case 2: var value = /** @type {string} */ (reader.readString()); msg.setName(value); break; - case 2: + case 3: var value = /** @type {!Uint8Array} */ (reader.readBytes()); msg.setPrivatekey(value); break; @@ -164,17 +169,24 @@ proto.pb.KeystoreRequest.prototype.serializeBinary = function() { */ proto.pb.KeystoreRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; + f = message.getRequesttype(); + if (f !== 0.0) { + writer.writeEnum( + 1, + f + ); + } f = message.getName(); if (f.length > 0) { writer.writeString( - 1, + 2, f ); } f = message.getPrivatekey_asU8(); if (f.length > 0) { writer.writeBytes( - 2, + 3, f ); } @@ -182,11 +194,29 @@ proto.pb.KeystoreRequest.serializeBinaryToWriter = function(message, writer) { /** - * optional string name = 1; + * optional KSREQTYPE requestType = 1; + * @return {!proto.pb.KSREQTYPE} + */ +proto.pb.KeystoreRequest.prototype.getRequesttype = function() { + return /** @type {!proto.pb.KSREQTYPE} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {!proto.pb.KSREQTYPE} value + * @return {!proto.pb.KeystoreRequest} returns this + */ +proto.pb.KeystoreRequest.prototype.setRequesttype = function(value) { + return jspb.Message.setProto3EnumField(this, 1, value); +}; + + +/** + * optional string name = 2; * @return {string} */ proto.pb.KeystoreRequest.prototype.getName = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; @@ -195,21 +225,21 @@ proto.pb.KeystoreRequest.prototype.getName = function() { * @return {!proto.pb.KeystoreRequest} returns this */ proto.pb.KeystoreRequest.prototype.setName = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); + return jspb.Message.setProto3StringField(this, 2, value); }; /** - * optional bytes privateKey = 2; + * optional bytes privateKey = 3; * @return {!(string|Uint8Array)} */ proto.pb.KeystoreRequest.prototype.getPrivatekey = function() { - return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 2, "")); + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 3, "")); }; /** - * optional bytes privateKey = 2; + * optional bytes privateKey = 3; * This is a type-conversion wrapper around `getPrivatekey()` * @return {string} */ @@ -220,7 +250,7 @@ proto.pb.KeystoreRequest.prototype.getPrivatekey_asB64 = function() { /** - * optional bytes privateKey = 2; + * optional bytes privateKey = 3; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array * This is a type-conversion wrapper around `getPrivatekey()` @@ -237,7 +267,7 @@ proto.pb.KeystoreRequest.prototype.getPrivatekey_asU8 = function() { * @return {!proto.pb.KeystoreRequest} returns this */ proto.pb.KeystoreRequest.prototype.setPrivatekey = function(value) { - return jspb.Message.setProto3BytesField(this, 2, value); + return jspb.Message.setProto3BytesField(this, 3, value); }; @@ -247,7 +277,7 @@ proto.pb.KeystoreRequest.prototype.setPrivatekey = function(value) { * @private {!Array} * @const */ -proto.pb.KeystoreResponse.repeatedFields_ = [2]; +proto.pb.KeystoreResponse.repeatedFields_ = [3]; @@ -280,9 +310,10 @@ proto.pb.KeystoreResponse.prototype.toObject = function(opt_includeInstance) { */ proto.pb.KeystoreResponse.toObject = function(includeInstance, msg) { var f, obj = { + requesttype: jspb.Message.getFieldWithDefault(msg, 1, 0), privatekey: msg.getPrivatekey_asB64(), - keynamesList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f, - has: jspb.Message.getBooleanFieldWithDefault(msg, 3, false) + keynamesList: (f = jspb.Message.getRepeatedField(msg, 3)) == null ? undefined : f, + has: jspb.Message.getBooleanFieldWithDefault(msg, 4, false) }; if (includeInstance) { @@ -320,14 +351,18 @@ proto.pb.KeystoreResponse.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: + var value = /** @type {!proto.pb.KSREQTYPE} */ (reader.readEnum()); + msg.setRequesttype(value); + break; + case 2: var value = /** @type {!Uint8Array} */ (reader.readBytes()); msg.setPrivatekey(value); break; - case 2: + case 3: var value = /** @type {string} */ (reader.readString()); msg.addKeynames(value); break; - case 3: + case 4: var value = /** @type {boolean} */ (reader.readBool()); msg.setHas(value); break; @@ -360,24 +395,31 @@ proto.pb.KeystoreResponse.prototype.serializeBinary = function() { */ proto.pb.KeystoreResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; + f = message.getRequesttype(); + if (f !== 0.0) { + writer.writeEnum( + 1, + f + ); + } f = message.getPrivatekey_asU8(); if (f.length > 0) { writer.writeBytes( - 1, + 2, f ); } f = message.getKeynamesList(); if (f.length > 0) { writer.writeRepeatedString( - 2, + 3, f ); } f = message.getHas(); if (f) { writer.writeBool( - 3, + 4, f ); } @@ -385,16 +427,34 @@ proto.pb.KeystoreResponse.serializeBinaryToWriter = function(message, writer) { /** - * optional bytes privateKey = 1; + * optional KSREQTYPE requestType = 1; + * @return {!proto.pb.KSREQTYPE} + */ +proto.pb.KeystoreResponse.prototype.getRequesttype = function() { + return /** @type {!proto.pb.KSREQTYPE} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {!proto.pb.KSREQTYPE} value + * @return {!proto.pb.KeystoreResponse} returns this + */ +proto.pb.KeystoreResponse.prototype.setRequesttype = function(value) { + return jspb.Message.setProto3EnumField(this, 1, value); +}; + + +/** + * optional bytes privateKey = 2; * @return {!(string|Uint8Array)} */ proto.pb.KeystoreResponse.prototype.getPrivatekey = function() { - return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** - * optional bytes privateKey = 1; + * optional bytes privateKey = 2; * This is a type-conversion wrapper around `getPrivatekey()` * @return {string} */ @@ -405,7 +465,7 @@ proto.pb.KeystoreResponse.prototype.getPrivatekey_asB64 = function() { /** - * optional bytes privateKey = 1; + * optional bytes privateKey = 2; * Note that Uint8Array is not supported on all browsers. * @see http://caniuse.com/Uint8Array * This is a type-conversion wrapper around `getPrivatekey()` @@ -422,16 +482,16 @@ proto.pb.KeystoreResponse.prototype.getPrivatekey_asU8 = function() { * @return {!proto.pb.KeystoreResponse} returns this */ proto.pb.KeystoreResponse.prototype.setPrivatekey = function(value) { - return jspb.Message.setProto3BytesField(this, 1, value); + return jspb.Message.setProto3BytesField(this, 2, value); }; /** - * repeated string keyNames = 2; + * repeated string keyNames = 3; * @return {!Array} */ proto.pb.KeystoreResponse.prototype.getKeynamesList = function() { - return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 3)); }; @@ -440,7 +500,7 @@ proto.pb.KeystoreResponse.prototype.getKeynamesList = function() { * @return {!proto.pb.KeystoreResponse} returns this */ proto.pb.KeystoreResponse.prototype.setKeynamesList = function(value) { - return jspb.Message.setField(this, 2, value || []); + return jspb.Message.setField(this, 3, value || []); }; @@ -450,7 +510,7 @@ proto.pb.KeystoreResponse.prototype.setKeynamesList = function(value) { * @return {!proto.pb.KeystoreResponse} returns this */ proto.pb.KeystoreResponse.prototype.addKeynames = function(value, opt_index) { - return jspb.Message.addToRepeatedField(this, 2, value, opt_index); + return jspb.Message.addToRepeatedField(this, 3, value, opt_index); }; @@ -464,11 +524,11 @@ proto.pb.KeystoreResponse.prototype.clearKeynamesList = function() { /** - * optional bool has = 3; + * optional bool has = 4; * @return {boolean} */ proto.pb.KeystoreResponse.prototype.getHas = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 4, false)); }; @@ -477,7 +537,7 @@ proto.pb.KeystoreResponse.prototype.getHas = function() { * @return {!proto.pb.KeystoreResponse} returns this */ proto.pb.KeystoreResponse.prototype.setHas = function(value) { - return jspb.Message.setProto3BooleanField(this, 3, value); + return jspb.Message.setProto3BooleanField(this, 4, value); }; diff --git a/pb/keystore.proto b/pb/keystore.proto index 5d070f1..77286ac 100644 --- a/pb/keystore.proto +++ b/pb/keystore.proto @@ -24,23 +24,27 @@ enum KSREQTYPE { // Used to submit a request to Keystore RPC message KeystoreRequest { + // indicates the request type being performed + KSREQTYPE requestType = 1; // name of the key the request is for // sent by: KS_HAS, KS_GET, KS_PUT, KS_DELETE - string name = 1; + string name = 2; // the actual private key bytes // sent by: KS_PUT - bytes privateKey = 2; + bytes privateKey = 3; } // Used in response to a Keystore RPC message KeystoreResponse { + // indicates the request type being performed + KSREQTYPE requestType = 1; // the private key bytes // sent by: KS_GET - bytes privateKey = 1; + bytes privateKey = 2; // contains all known key names // sent by: KS_LIST - repeated string keyNames = 2; + repeated string keyNames = 3; // indicates if we have the key in our keystore // sent by: KS_HAS - bool has = 3; + bool has = 4; } \ No newline at end of file diff --git a/py/keystore_pb2.py b/py/keystore_pb2.py index 1cd0dd2..f2e1cb1 100644 --- a/py/keystore_pb2.py +++ b/py/keystore_pb2.py @@ -21,7 +21,7 @@ package='pb', syntax='proto3', serialized_options=None, - serialized_pb=_b('\n\x0ekeystore.proto\x12\x02pb\"3\n\x0fKeystoreRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\nprivateKey\x18\x02 \x01(\x0c\"E\n\x10KeystoreResponse\x12\x12\n\nprivateKey\x18\x01 \x01(\x0c\x12\x10\n\x08keyNames\x18\x02 \x03(\t\x12\x0b\n\x03has\x18\x03 \x01(\x08*K\n\tKSREQTYPE\x12\n\n\x06KS_HAS\x10\x00\x12\n\n\x06KS_GET\x10\x01\x12\n\n\x06KS_PUT\x10\x02\x12\r\n\tKS_DELETE\x10\x03\x12\x0b\n\x07KS_LIST\x10\x04\x32\x46\n\x0bKeystoreAPI\x12\x37\n\x08Keystore\x12\x13.pb.KeystoreRequest\x1a\x14.pb.KeystoreResponse\"\x00\x62\x06proto3') + serialized_pb=_b('\n\x0ekeystore.proto\x12\x02pb\"W\n\x0fKeystoreRequest\x12\"\n\x0brequestType\x18\x01 \x01(\x0e\x32\r.pb.KSREQTYPE\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x12\n\nprivateKey\x18\x03 \x01(\x0c\"i\n\x10KeystoreResponse\x12\"\n\x0brequestType\x18\x01 \x01(\x0e\x32\r.pb.KSREQTYPE\x12\x12\n\nprivateKey\x18\x02 \x01(\x0c\x12\x10\n\x08keyNames\x18\x03 \x03(\t\x12\x0b\n\x03has\x18\x04 \x01(\x08*K\n\tKSREQTYPE\x12\n\n\x06KS_HAS\x10\x00\x12\n\n\x06KS_GET\x10\x01\x12\n\n\x06KS_PUT\x10\x02\x12\r\n\tKS_DELETE\x10\x03\x12\x0b\n\x07KS_LIST\x10\x04\x32\x46\n\x0bKeystoreAPI\x12\x37\n\x08Keystore\x12\x13.pb.KeystoreRequest\x1a\x14.pb.KeystoreResponse\"\x00\x62\x06proto3') ) _KSREQTYPE = _descriptor.EnumDescriptor( @@ -53,8 +53,8 @@ ], containing_type=None, serialized_options=None, - serialized_start=146, - serialized_end=221, + serialized_start=218, + serialized_end=293, ) _sym_db.RegisterEnumDescriptor(_KSREQTYPE) @@ -75,15 +75,22 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='name', full_name='pb.KeystoreRequest.name', index=0, - number=1, type=9, cpp_type=9, label=1, + name='requestType', full_name='pb.KeystoreRequest.requestType', index=0, + number=1, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='name', full_name='pb.KeystoreRequest.name', index=1, + number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( - name='privateKey', full_name='pb.KeystoreRequest.privateKey', index=1, - number=2, type=12, cpp_type=9, label=1, + name='privateKey', full_name='pb.KeystoreRequest.privateKey', index=2, + number=3, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, @@ -101,7 +108,7 @@ oneofs=[ ], serialized_start=22, - serialized_end=73, + serialized_end=109, ) @@ -113,22 +120,29 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='privateKey', full_name='pb.KeystoreResponse.privateKey', index=0, - number=1, type=12, cpp_type=9, label=1, + name='requestType', full_name='pb.KeystoreResponse.requestType', index=0, + number=1, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='privateKey', full_name='pb.KeystoreResponse.privateKey', index=1, + number=2, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( - name='keyNames', full_name='pb.KeystoreResponse.keyNames', index=1, - number=2, type=9, cpp_type=9, label=3, + name='keyNames', full_name='pb.KeystoreResponse.keyNames', index=2, + number=3, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, serialized_options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( - name='has', full_name='pb.KeystoreResponse.has', index=2, - number=3, type=8, cpp_type=7, label=1, + name='has', full_name='pb.KeystoreResponse.has', index=3, + number=4, type=8, cpp_type=7, label=1, has_default_value=False, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, @@ -145,10 +159,12 @@ extension_ranges=[], oneofs=[ ], - serialized_start=75, - serialized_end=144, + serialized_start=111, + serialized_end=216, ) +_KEYSTOREREQUEST.fields_by_name['requestType'].enum_type = _KSREQTYPE +_KEYSTORERESPONSE.fields_by_name['requestType'].enum_type = _KSREQTYPE DESCRIPTOR.message_types_by_name['KeystoreRequest'] = _KEYSTOREREQUEST DESCRIPTOR.message_types_by_name['KeystoreResponse'] = _KEYSTORERESPONSE DESCRIPTOR.enum_types_by_name['KSREQTYPE'] = _KSREQTYPE @@ -176,8 +192,8 @@ file=DESCRIPTOR, index=0, serialized_options=None, - serialized_start=223, - serialized_end=293, + serialized_start=295, + serialized_end=365, methods=[ _descriptor.MethodDescriptor( name='Keystore', diff --git a/ts/keystore_pb.d.ts b/ts/keystore_pb.d.ts index 65bf79c..ab8ef79 100644 --- a/ts/keystore_pb.d.ts +++ b/ts/keystore_pb.d.ts @@ -4,6 +4,9 @@ import * as jspb from "google-protobuf"; export class KeystoreRequest extends jspb.Message { + getRequesttype(): KSREQTYPEMap[keyof KSREQTYPEMap]; + setRequesttype(value: KSREQTYPEMap[keyof KSREQTYPEMap]): void; + getName(): string; setName(value: string): void; @@ -24,12 +27,16 @@ export class KeystoreRequest extends jspb.Message { export namespace KeystoreRequest { export type AsObject = { + requesttype: KSREQTYPEMap[keyof KSREQTYPEMap], name: string, privatekey: Uint8Array | string, } } export class KeystoreResponse extends jspb.Message { + getRequesttype(): KSREQTYPEMap[keyof KSREQTYPEMap]; + setRequesttype(value: KSREQTYPEMap[keyof KSREQTYPEMap]): void; + getPrivatekey(): Uint8Array | string; getPrivatekey_asU8(): Uint8Array; getPrivatekey_asB64(): string; @@ -55,6 +62,7 @@ export class KeystoreResponse extends jspb.Message { export namespace KeystoreResponse { export type AsObject = { + requesttype: KSREQTYPEMap[keyof KSREQTYPEMap], privatekey: Uint8Array | string, keynamesList: Array, has: boolean,