Skip to content

Commit

Permalink
Merge pull request #155 from xmtp/nm/prototype-identity-apis
Browse files Browse the repository at this point in the history
Prototype identity apis
  • Loading branch information
neekolas authored Apr 9, 2024
2 parents 5f7216e + 42d6c47 commit 74e4e67
Show file tree
Hide file tree
Showing 23 changed files with 259 additions and 22 deletions.
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test
./dev/go/generate
. "$(dirname -- "$0")/_/husky.sh"
2 changes: 1 addition & 1 deletion go/keystore_api/v1/keystore.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/message_api/v1/authn.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/message_api/v1/message_api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/message_api/v1/message_api_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/message_contents/ciphertext.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/message_contents/composite.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/message_contents/contact.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/message_contents/content.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/message_contents/conversation_reference.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/message_contents/invitation.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/message_contents/message.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/message_contents/private_key.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/message_contents/public_key.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/message_contents/signature.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/mls/api/v1/mls.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/mls/api/v1/mls_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/mls_validation/v1/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/mls_validation/v1/service_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions proto/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ lint:
- message_contents/content.proto
RPC_REQUEST_RESPONSE_UNIQUE:
- message_api/v1/message_api.proto
- identity/api/v1/identity.proto
- mls/api/v1/mls.proto
RPC_RESPONSE_STANDARD_NAME:
- message_api/v1/message_api.proto
- identity/api/v1/identity.proto
- mls/api/v1/mls.proto
except:
- PACKAGE_DIRECTORY_MATCH
- PACKAGE_VERSION_SUFFIX
Expand Down
105 changes: 105 additions & 0 deletions proto/identity/api/v1/identity.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Message API
syntax = "proto3";
package xmtp.identity.api.v1;

import "google/api/annotations.proto";
import "identity/associations/association.proto";
import "protoc-gen-openapiv2/options/annotations.proto";

option go_package = "github.com/xmtp/proto/v3/go/mls/api/v1";
option java_package = "org.xmtp.proto.mls.api.v1";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "IdentityApi";
version: "1.0";
};
};

// RPCs for the new MLS API
service IdentityApi {
// Publishes an identity update for an XID or wallet. An identity update may
// consist of multiple identity actions that have been batch signed.
rpc PublishIdentityUpdate(PublishIdentityUpdateRequest) returns (PublishIdentityUpdateResponse) {
option (google.api.http) = {
post: "/identity/v1/publish-identity-update"
body: "*"
};
}

// Used to check for changes related to members of a group.
// Would return an array of any new installations associated with the wallet
// address, and any revocations that have happened.
rpc GetIdentityUpdates(GetIdentityUpdatesRequest) returns (GetIdentityUpdatesResponse) {
option (google.api.http) = {
post: "/identity/v1/get-identity-updates"
body: "*"
};
}

// Retrieve the XIDs for the given addresses
rpc GetInboxIds(GetInboxIdsRequest) returns (GetInboxIdsResponse) {
option (google.api.http) = {
post: "/identity/v1/get-inbox-ids"
body: "*"
};
}
}

// Publishes an identity update to the network
message PublishIdentityUpdateRequest {
xmtp.identity.associations.IdentityUpdate identity_update = 1;
}

// The response when an identity update is published
message PublishIdentityUpdateResponse {}

// Get all updates for an identity since the specified time
message GetIdentityUpdatesRequest {
// Points to the last entry the client has received. The sequence_id should be
// set to 0 if the client has not received anything.
message Request {
string inbox_id = 1;
uint64 sequence_id = 2;
}

repeated Request requests = 1;
}

// Returns all log entries for the requested identities
message GetIdentityUpdatesResponse {
// A single entry in the XID log on the server.
message IdentityUpdateLog {
uint64 sequence_id = 1;
uint64 server_timestamp_ns = 2;
xmtp.identity.associations.IdentityUpdate update = 3;
}

// The update log for a single identity, starting after the last cursor
message Response {
string inbox_id = 1;
repeated IdentityUpdateLog updates = 2;
}

repeated Response responses = 1;
}

// Request to retrieve the XIDs for the given addresses
message GetInboxIdsRequest {
// A single request for a given address
message Request {
string address = 1;
}

repeated Request requests = 1;
}

// Response with the XIDs for the requested addresses
message GetInboxIdsResponse {
// A single response for a given address
message Response {
string address = 1;
optional string inbox_id = 2;
}

repeated Response responses = 1;
}
74 changes: 74 additions & 0 deletions proto/identity/associations/association.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Payloads to be signed for identity associations
syntax = "proto3";

package xmtp.identity.associations;

import "identity/associations/signature.proto";

option go_package = "github.com/xmtp/proto/v3/go/identity/associations";
option java_package = "org.xmtp.proto.identity.associations";

// The identifier for a member of an XID
message MemberIdentifier {
oneof kind {
string address = 1;
bytes installation_public_key = 2;
}
}

// The first entry of any XID log. The XID must be deterministically derivable
// from the address and nonce.
// The recovery address defaults to the initial associated_address unless
// there is a subsequent ChangeRecoveryAddress in the log.
message CreateInbox {
string initial_address = 1;
uint64 nonce = 2;
Signature initial_address_signature = 3; // Must be an addressable member
}

// Adds a new member for an XID - either an addressable member such as a
// wallet, or an installation acting on behalf of an address.
// A key-pair that has been associated with one role MUST not be permitted to be
// associated with a different role.
message AddAssociation {
MemberIdentifier new_member_identifier = 1;
Signature existing_member_signature = 2;
Signature new_member_signature = 3;
}

// Revokes a member from an XID. The recovery address must sign the revocation.
message RevokeAssociation {
MemberIdentifier member_to_revoke = 1;
Signature recovery_address_signature = 2;
}

// Changes the recovery address for an XID. The recovery address is not required
// to be a member of the XID. In addition to being able to add members, the
// recovery address can also revoke members.
message ChangeRecoveryAddress {
string new_recovery_address = 1;
Signature existing_recovery_address_signature = 2;
}

// A single identity operation
message IdentityAction {
oneof kind {
CreateInbox create_inbox = 1;
AddAssociation add = 2;
RevokeAssociation revoke = 3;
ChangeRecoveryAddress change_recovery_address = 4;
}
}

// One or more identity actions that were signed together.
// Example: [CreateXid, AddAssociation, ChangeRecoveryAddress]
// 1. The batched signature text is created by concatenating the signature text
// of each association together with a separator, '\n\n\n'.
// 2. The user signs this concatenated result.
// 3. The resulting signature is added to each association proto where relevant.
// The same signature may be used for multiple associations in the array.
message IdentityUpdate {
repeated IdentityAction actions = 1;
uint64 client_timestamp_ns = 2;
string inbox_id = 3;
}
Loading

0 comments on commit 74e4e67

Please sign in to comment.