Skip to content

Commit

Permalink
Merge pull request #48 from D4ryl00/chore/move-push-into-berty
Browse files Browse the repository at this point in the history
Chore: move push notification stuff into berty messenger
  • Loading branch information
D4ryl00 committed Jul 21, 2023
2 parents aa44f7d + 827c8ea commit 89c06bb
Show file tree
Hide file tree
Showing 118 changed files with 3,552 additions and 17,815 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://github.com/berty/weshnet/blame/main/.tool-versions

#-----
# This is simply the most recent version available to date of the lowest
# This is simply the most recent version available to date of the lowest
# major version of Go which is allowed by kubo.
# There is no contraindication for updating it.
#-----
Expand Down
27 changes: 0 additions & 27 deletions api/protocol/errcode/errcode.proto
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,6 @@ enum ErrCode {
ErrMessageKeyPersistencePut = 1500;
ErrMessageKeyPersistenceGet = 1501;

// Services Auth

ErrServicesAuth = 4000;
ErrServicesAuthNotInitialized = 4001;
ErrServicesAuthWrongState = 4002;
ErrServicesAuthInvalidResponse = 4003;
ErrServicesAuthServer = 4004;
ErrServicesAuthCodeChallenge = 4005;
ErrServicesAuthServiceInvalidToken = 4006;
ErrServicesAuthServiceNotSupported = 4007;
ErrServicesAuthUnknownToken = 4008;
ErrServicesAuthInvalidURL = 4009;

// Services Replication

ErrServiceReplication = 4100;
Expand All @@ -157,20 +144,6 @@ enum ErrCode {
ErrServicesDirectoryInvalidVerifiedCredential = 4205;
ErrServicesDirectoryExpiredVerifiedCredential = 4206;
ErrServicesDirectoryInvalidVerifiedCredentialID = 4207;

// Services Push

ErrPush = 6000;
ErrPushWrongAccount = 6001;
ErrPushUnableToDecrypt = 6002;
ErrPushInvalidPayload = 6003;
ErrPushInvalidServerConfig = 6004;
ErrPushMissingBundleID = 6005;
ErrPushUnknownDestination = 6006;
ErrPushProvider = 6007;
ErrPushUnknownProvider = 6008;
ErrNoProvidersConfigured = 6009;
ErrInvalidPrivateKey = 6010;
}

message ErrDetails { repeated ErrCode codes = 1; }
20 changes: 20 additions & 0 deletions api/protocol/outofstoremessagetypes/outofstoremessage.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";

package weshnet.outofstoremessage.v1;

import "gogoproto/gogo.proto";
import "protocoltypes.proto";

option go_package = "berty.tech/weshnet/pkg/outofstoremessagetypes";

option (gogoproto.goproto_enum_prefix_all) = false;
option (gogoproto.marshaler_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.sizer_all) = true;

// OutOfStoreMessageService is the service used to open out-of-store messages (e.g. push notifications)
// It is used to open messages with a lightweight protocol service for mobile backgroup processes.
service OutOfStoreMessageService {
// OutOfStoreReceive parses a payload received outside a synchronized store
rpc OutOfStoreReceive(weshnet.protocol.v1.OutOfStoreReceive.Request) returns (weshnet.protocol.v1.OutOfStoreReceive.Reply);
}
185 changes: 25 additions & 160 deletions api/protocol/protocoltypes.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ syntax = "proto3";
package weshnet.protocol.v1;

import "gogoproto/gogo.proto";
import "pushtypes/pushtypes.proto";

option go_package = "berty.tech/weshnet/pkg/protocoltypes";

Expand Down Expand Up @@ -107,16 +106,8 @@ service ProtocolService {

rpc DebugGroup (DebugGroup.Request) returns (DebugGroup.Reply);

rpc DebugAuthServiceSetToken(DebugAuthServiceSetToken.Request) returns (DebugAuthServiceSetToken.Reply);

rpc SystemInfo (SystemInfo.Request) returns (SystemInfo.Reply);

// AuthServiceInitFlow Initialize an authentication flow
rpc AuthServiceInitFlow (AuthServiceInitFlow.Request) returns (AuthServiceInitFlow.Reply);

// AuthServiceCompleteFlow Completes an authentication flow
rpc AuthServiceCompleteFlow (AuthServiceCompleteFlow.Request) returns (AuthServiceCompleteFlow.Reply);

// CredentialVerificationServiceInitFlow Initialize a credential verification flow
rpc CredentialVerificationServiceInitFlow (CredentialVerificationServiceInitFlow.Request) returns (CredentialVerificationServiceInitFlow.Reply);

Expand All @@ -126,9 +117,6 @@ service ProtocolService {
// VerifiedCredentialsList Retrieves the list of verified credentials
rpc VerifiedCredentialsList (VerifiedCredentialsList.Request) returns (stream VerifiedCredentialsList.Reply);

// ServicesTokenList Retrieves the list of services tokens
rpc ServicesTokenList (ServicesTokenList.Request) returns (stream ServicesTokenList.Reply);

// ReplicationServiceRegisterGroup Asks a replication service to distribute a group contents
rpc ReplicationServiceRegisterGroup (ReplicationServiceRegisterGroup.Request) returns (ReplicationServiceRegisterGroup.Reply);

Expand Down Expand Up @@ -233,24 +221,9 @@ enum EventType {
// EventTypeMultiMemberGroupAdminRoleGranted indicates the payload includes that an admin of the group granted another member as an admin
EventTypeMultiMemberGroupAdminRoleGranted = 303;

// EventTypeAccountServiceTokenAdded indicates that a new service provider has been registered for this account
EventTypeAccountServiceTokenAdded = 401;

// EventTypeAccountServiceTokenRemoved indicates that a service provider is not available anymore
EventTypeAccountServiceTokenRemoved = 402;

// EventTypeGroupReplicating indicates that the group has been registered for replication on a server
EventTypeGroupReplicating = 403;

// EventTypePushMemberTokenUpdate
EventTypePushMemberTokenUpdate = 404;

// EventTypePushDeviceTokenRegistered
EventTypePushDeviceTokenRegistered = 405;

// EventTypePushDeviceServerRegistered
EventTypePushDeviceServerRegistered = 406;

// EventTypeAccountVerifiedCredentialRegistered
EventTypeAccountVerifiedCredentialRegistered = 500;

Expand Down Expand Up @@ -626,22 +599,6 @@ message AccountContactUnblocked {
bytes contact_pk = 2 [(gogoproto.customname) = "ContactPK"];
}

// AccountServiceTokenAdded indicates a token has been added to the account
message AccountServiceTokenAdded {
// device_pk is the device sending the event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

ServiceToken service_token = 2;
}

// AccountServiceTokenRemoved indicates a token has removed
message AccountServiceTokenRemoved {
// device_pk is the device sending the event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

string token_id = 2 [(gogoproto.customname) = "TokenID"];
}

message GroupReplicating {
// device_pk is the device sending the event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];
Expand Down Expand Up @@ -691,8 +648,6 @@ message ServiceGetConfiguration {
SettingState wifi_p2p_enabled = 7; // MultiPeerConnectivity for Darwin and Nearby for Android
SettingState mdns_enabled = 8;
SettingState relay_enabled = 9;
PushServiceReceiver device_push_token = 10;
PushServer device_push_server = 11;
}
}

Expand Down Expand Up @@ -1112,22 +1067,6 @@ message DebugGroup {
}
}

message AuthExchangeResponse {
string access_token = 1;
string scope = 2;
string error = 3;
string error_description = 4;
map<string, string> services = 5;
}

message DebugAuthServiceSetToken {
message Request {
AuthExchangeResponse token = 1;
string authentication_url = 2 [(gogoproto.customname) = "AuthenticationURL"];
}
message Reply {}
}

enum DebugInspectGroupLogType {
DebugInspectGroupLogTypeUndefined = 0;
DebugInspectGroupLogTypeMessage = 1;
Expand Down Expand Up @@ -1168,26 +1107,6 @@ message ServiceToken {
int64 expiration = 4;
}

message AuthServiceCompleteFlow {
message Request{
string callback_url = 1 [(gogoproto.customname) = "CallbackURL"];
}
message Reply{
string token_id = 1 [(gogoproto.customname) = "TokenID"];
}
}

message AuthServiceInitFlow {
message Request {
string auth_url = 1 [(gogoproto.customname) = "AuthURL"];
repeated string services = 3;
}
message Reply {
string url = 1 [(gogoproto.customname) = "URL"];
bool secure_url = 2 [(gogoproto.customname) = "SecureURL"];
}
}

message CredentialVerificationServiceInitFlow {
message Request {
string service_url = 1 [(gogoproto.customname) = "ServiceURL"];
Expand Down Expand Up @@ -1220,25 +1139,12 @@ message VerifiedCredentialsList {
}
}

message ServicesTokenList {
message Request{}
message Reply{
string token_id = 1 [(gogoproto.customname) = "TokenID"];
ServiceToken service = 2;
}
}

message ServicesTokenCode {
repeated string services = 1;
string code_challenge = 2;
string token_id = 3 [(gogoproto.customname) = "TokenID"];
}


message ReplicationServiceRegisterGroup {
message Request{
string token_id = 1 [(gogoproto.customname) = "TokenID"];
bytes group_pk = 2 [(gogoproto.customname) = "GroupPK"];
bytes group_pk = 1 [(gogoproto.customname) = "GroupPK"];
string token = 2;
string authentication_url = 3 [(gogoproto.customname) = "AuthenticationURL"];
string replication_server = 4;
}
message Reply{}
}
Expand Down Expand Up @@ -1380,11 +1286,6 @@ message Progress {
uint64 delay = 6;
}

message MemberWithDevices {
bytes member_pk = 1 [(gogoproto.customname) = "MemberPK"];
repeated bytes devices_pks = 2 [(gogoproto.customname) = "DevicePKs"];
}

message OutOfStoreMessage {
bytes cid = 1 [(gogoproto.customname) = "CID"];
bytes device_pk = 2 [(gogoproto.customname) = "DevicePK"];
Expand All @@ -1395,63 +1296,10 @@ message OutOfStoreMessage {
bytes nonce = 7;
}

message PushServiceReceiver {
// token_type is the type of the token used, it allows us to act as a proxy to the appropriate push server
push.v1.PushServiceTokenType token_type = 1;

// bundle_id is the app identifier
string bundle_id = 2 [(gogoproto.customname) = "BundleID"];

// token is the device identifier used
bytes token = 3;

// recipient_public_key is the public key which will be used to encrypt the payload
bytes recipient_public_key = 4;
}

message PushServer {
bytes server_key = 1;
string service_addr = 2;
}

message PushDeviceTokenRegistered {
PushServiceReceiver token = 1;

// device_pk is the public key of the device sending the message
bytes device_pk = 2 [(gogoproto.customname) = "DevicePK"];
}

message PushDeviceServerRegistered {
PushServer server = 1;

// device_pk is the public key of the device sending the message
bytes device_pk = 2 [(gogoproto.customname) = "DevicePK"];
}

message AccountVerifiedCredentialRegistered {
// device_pk is the public key of the device sending the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

bytes signed_identity_public_key = 2;

string verified_credential = 3;

int64 registration_date = 4;

int64 expiration_date = 5;

string identifier = 6;

string issuer = 7;
}

message PushMemberTokenUpdate {
PushServer server = 1;

bytes token = 2;

// device_pk is the public key of the device sending the message
bytes device_pk = 3 [(gogoproto.customname) = "DevicePK"];
message OutOfStoreMessageEnvelope {
bytes nonce = 1;
bytes box = 2;
bytes group_reference = 3;
}

message OutOfStoreReceive {
Expand All @@ -1476,6 +1324,23 @@ message OutOfStoreSeal {
}
}

message AccountVerifiedCredentialRegistered {
// device_pk is the public key of the device sending the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

bytes signed_identity_public_key = 2;

string verified_credential = 3;

int64 registration_date = 4;

int64 expiration_date = 5;

string identifier = 6;

string issuer = 7;
}

message FirstLastCounters {
uint64 first = 1;
uint64 last = 2;
Expand Down
Loading

0 comments on commit 89c06bb

Please sign in to comment.