diff --git a/.protolintrc.yml b/.protolintrc.yml index b00ec52fec..8ee795aca4 100644 --- a/.protolintrc.yml +++ b/.protolintrc.yml @@ -6,3 +6,6 @@ lint: # disable some specific rules remove: - REPEATED_FIELD_NAMES_PLURALIZED + - ENUM_FIELD_NAMES_PREFIX + - ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH + - FIELD_NAMES_LOWER_SNAKE_CASE diff --git a/docs/guides/linting.md b/docs/guides/linting.md index b6c16e17f1..79f0b68500 100644 --- a/docs/guides/linting.md +++ b/docs/guides/linting.md @@ -260,8 +260,13 @@ Linter - Suggested Change: Customise *Change detail* -Add `.protolintrc.yml` used by `protolint` linter and configure it to disable `REPEATED_FIELD_NAMES_PLURALIZED` rule. -This rule should be disabled since it tries to pluralize the field name that doesn't conform to the spec submitted to W3C. +Add `.protolintrc.yml` used by `protolint` linter and configure it to disable the following rules +- `REPEATED_FIELD_NAMES_PLURALIZED` +- `ENUM_FIELD_NAMES_PREFIX` +- `ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH` +- `FIELD_NAMES_LOWER_SNAKE_CASE` + +These rules should be disabled since they try to rename some fields deviating from the spec submitted to W3C. --- diff --git a/prism-node/client/scala-client/api/grpc/node_models.proto b/prism-node/client/scala-client/api/grpc/node_models.proto index 3b4bbaa5c3..b6d2ee0c54 100644 --- a/prism-node/client/scala-client/api/grpc/node_models.proto +++ b/prism-node/client/scala-client/api/grpc/node_models.proto @@ -1,53 +1,53 @@ syntax = "proto3"; -option java_multiple_files = true; -option java_package = "io.iohk.atala.prism.protos"; - package io.iohk.atala.prism.protos; import "common_models.proto"; import "google/protobuf/timestamp.proto"; +option java_multiple_files = true; +option java_package = "io.iohk.atala.prism.protos"; + // Includes timestamping details about a blockchain's block. message TimestampInfo { - reserved 1; // Removed blockTimestamp_deprecated field - reserved "blockTimestamp_deprecated"; + reserved 1; // Removed blockTimestamp_deprecated field + reserved "blockTimestamp_deprecated"; - uint32 block_sequence_number = 2; // The transaction index inside the underlying block. - uint32 operation_sequence_number = 3; // The operation index inside the AtalaBlock. - google.protobuf.Timestamp block_timestamp = 4; // The timestamp provided from the underlying blockchain. + uint32 block_sequence_number = 2; // The transaction index inside the underlying block. + uint32 operation_sequence_number = 3; // The operation index inside the AtalaBlock. + google.protobuf.Timestamp block_timestamp = 4; // The timestamp provided from the underlying blockchain. } // Every key has a single purpose: enum KeyUsage { - // UNKNOWN_KEY is an invalid value - Protobuf uses 0 if no value is provided and we want the user to explicitly choose the usage. - UNKNOWN_KEY = 0; + // UNKNOWN_KEY is an invalid value - Protobuf uses 0 if no value is provided and we want the user to explicitly choose the usage. + UNKNOWN_KEY = 0; - // This is the most privileged key-type, when any other key is lost, you could use this to recover the others. - MASTER_KEY = 1; + // This is the most privileged key-type, when any other key is lost, you could use this to recover the others. + MASTER_KEY = 1; - // This key-type is used for issuing credentials only, it should be kept in a safe place - // to avoid malicious credentials being issued. - ISSUING_KEY = 2; + // This key-type is used for issuing credentials only, it should be kept in a safe place + // to avoid malicious credentials being issued. + ISSUING_KEY = 2; - // This key-type is used to establish a shared symmetric key for secure end-to end communication - // use this key-type to encrypt the content. - KEY_AGREEMENT_KEY = 3; + // This key-type is used to establish a shared symmetric key for secure end-to end communication + // use this key-type to encrypt the content. + KEY_AGREEMENT_KEY = 3; - // This key-type is used to authenticate requests or logging into services. - AUTHENTICATION_KEY = 4; + // This key-type is used to authenticate requests or logging into services. + AUTHENTICATION_KEY = 4; - // This key-type is used for revoking credentials only, it should be kept in a safe place - // to avoid malicious credentials being issued. - REVOCATION_KEY = 5; + // This key-type is used for revoking credentials only, it should be kept in a safe place + // to avoid malicious credentials being issued. + REVOCATION_KEY = 5; - // This key-type is used to specify a verification method that might be used by the DID subject to invoke a cryptographic capability, - // such as the authorization to update the DID Document. - CAPABILITY_INVOCATION_KEY = 6; + // This key-type is used to specify a verification method that might be used by the DID subject to invoke a cryptographic capability, + // such as the authorization to update the DID Document. + CAPABILITY_INVOCATION_KEY = 6; - // This is used to specify a mechanism that might be used by the DID subject to delegate a cryptographic capability to another party, - // such as delegating the authority to access a specific HTTP API to a subordinate. - CAPABILITY_DELEGATION_KEY = 7; + // This is used to specify a mechanism that might be used by the DID subject to delegate a cryptographic capability to another party, + // such as delegating the authority to access a specific HTTP API to a subordinate. + CAPABILITY_DELEGATION_KEY = 7; } /** @@ -55,9 +55,9 @@ enum KeyUsage { * @exclude TODO: Consider renaming this to ECPublicKeyData. */ message ECKeyData { - string curve = 1; // The curve name, like secp256k1. - bytes x = 2; // The x coordinate, represented as bytes. - bytes y = 3; // The y coordinate, represented as bytes. + string curve = 1; // The curve name, like secp256k1. + bytes x = 2; // The x coordinate, represented as bytes. + bytes y = 3; // The y coordinate, represented as bytes. } /** @@ -65,8 +65,8 @@ message ECKeyData { * @exclude TODO: Consider renaming this to CompressedECPublicKeyData. */ message CompressedECKeyData { - string curve = 1; // The curve name, like secp256k1. - bytes data = 2; // compressed Elliptic Curve (EC) public key data. + string curve = 1; // The curve name, like secp256k1. + bytes data = 2; // compressed Elliptic Curve (EC) public key data. } /** @@ -74,211 +74,221 @@ message CompressedECKeyData { * @exclude TODO: Consider renaming this to something more specific, like DIDPublicKey. */ message PublicKey { - reserved 3, 4; - string id = 1; // The key identifier within the DID Document. - KeyUsage usage = 2; // The key's purpose. - LedgerData added_on = 5; // The ledger details related to the event that added the key to the DID Document. - LedgerData revoked_on = 6; // The ledger details related to the event that revoked the key to the DID Document. - - // The key's representation. - oneof key_data { - ECKeyData ec_key_data = 8; // The Elliptic Curve (EC) key. - CompressedECKeyData compressed_ec_key_data = 9; // Compressed Elliptic Curve (EC) key. - }; + reserved 3, 4; + string id = 1; // The key identifier within the DID Document. + KeyUsage usage = 2; // The key's purpose. + LedgerData added_on = 5; // The ledger details related to the event that added the key to the DID Document. + LedgerData revoked_on = 6; // The ledger details related to the event that revoked the key to the DID Document. + + // The key's representation. + oneof key_data { + ECKeyData ec_key_data = 8; // The Elliptic Curve (EC) key. + CompressedECKeyData compressed_ec_key_data = 9; // Compressed Elliptic Curve (EC) key. + }; } // The DID Document's data. message DIDData { - string id = 1; // The DID suffix, where DID is in form did:prism:[DID suffix] - repeated PublicKey public_keys = 2; // The keys that belong to this DID Document. - repeated Service services = 3; // The list of services that belong to this DID Document. + string id = 1; // The DID suffix, where DID is in form did:prism:[DID suffix] + repeated PublicKey public_keys = 2; // The keys that belong to this DID Document. + repeated Service services = 3; // The list of services that belong to this DID Document. + repeated string context = 4; // The list of @context values to consider on JSON-LD representations } // The operation to create a public DID. message CreateDIDOperation { - DIDCreationData did_data = 1; // DIDCreationData with public keys and services + DIDCreationData did_data = 1; // DIDCreationData with public keys and services - // The data necessary to create a DID. - message DIDCreationData { - reserved 1; // Removed DID id field which is empty on creation - repeated PublicKey public_keys = 2; // The keys that belong to this DID Document. - repeated Service services = 3; // The list of services that belong to this DID Document. - } + // The data necessary to create a DID. + message DIDCreationData { + reserved 1; // Removed DID id field which is empty on creation + repeated PublicKey public_keys = 2; // The keys that belong to this DID Document. + repeated Service services = 3; // The list of services that belong to this DID Document. + repeated string context = 4; // The list of @context values to consider on JSON-LD representations + } } // The necessary data to add a key to a DID. message AddKeyAction { - PublicKey key = 1; // The key to include. + PublicKey key = 1; // The key to include. } // The necessary data to remove a key from a DID. message RemoveKeyAction { - string keyId = 1; // the key id to remove + string keyId = 1; // the key id to remove } message AddServiceAction { - Service service = 1; + Service service = 1; } message RemoveServiceAction { - string serviceId = 1; + string serviceId = 1; } message UpdateServiceAction { - string serviceId = 1; // scoped to the did, unique per did - string type = 2; // new type if provided - // Will replace all existing service endpoints of the service with provided ones - repeated string service_endpoints = 3; + string service_id = 1; // scoped to the did, unique per did + string type = 2; // new type if provided + // Will replace all existing service endpoints of the service with provided ones + repeated string service_endpoints = 3; +} + +message PatchContextAction { + repeated string context = 1; // The list of strings to use by resolvers during resolution when producing a JSON-LD output } // The potential details that can be updated in a DID. message UpdateDIDAction { - // The action to perform. - oneof action { - AddKeyAction add_key = 1; // Used to add a new key to the DID. - RemoveKeyAction remove_key = 2; // Used to remove a key from the DID. - AddServiceAction add_service = 3; // Used to add a new service to a DID, - RemoveServiceAction remove_service = 4; // Used to remove an existing service from a DID, - UpdateServiceAction update_service = 5; // Used to Update a list of service endpoints of a given service on a given DID. - } + // The action to perform. + oneof action { + AddKeyAction add_key = 1; // Used to add a new key to the DID. + RemoveKeyAction remove_key = 2; // Used to remove a key from the DID. + AddServiceAction add_service = 3; // Used to add a new service to a DID, + RemoveServiceAction remove_service = 4; // Used to remove an existing service from a DID, + UpdateServiceAction update_service = 5; // Used to Update a list of service endpoints of a given service on a given DID. + PatchContextAction patch_context = 6; // Used to Update a list of `@context` strings used during resolution for a given DID. + } } // Specifies the necessary data to update a public DID. message UpdateDIDOperation { - bytes previous_operation_hash = 1; // The hash of the operation that issued the DID. - string id = 2; // @exclude TODO: To be redefined after we start using this operation. - repeated UpdateDIDAction actions = 3; // The actual updates to perform on the DID. + bytes previous_operation_hash = 1; // The hash of the operation that issued the DID. + string id = 2; // @exclude TODO: To be redefined after we start using this operation. + repeated UpdateDIDAction actions = 3; // The actual updates to perform on the DID. } // Represents a credential's batch. // // Check the protocol docs to understand it. message CredentialBatchData { - string issuer_did = 1; // The DID suffix that issues the credential's batch. - bytes merkle_root = 2; // The Merkle root for the credential's batch. + string issuer_did = 1; // The DID suffix that issues the credential's batch. + bytes merkle_root = 2; // The Merkle root for the credential's batch. } // Specifies the data to issue a credential batch. message IssueCredentialBatchOperation { - CredentialBatchData credential_batch_data = 1; // The actual credential batch data. + CredentialBatchData credential_batch_data = 1; // The actual credential batch data. } // Specifies the credentials to revoke (the whole batch, or just a subset of it). message RevokeCredentialsOperation { - bytes previous_operation_hash = 1; // The hash of the operation that issued the batch. - string credential_batch_id = 2; // The corresponding batch ID, as returned in IssueCredentialBatchResponse. - repeated bytes credentials_to_revoke = 3; // The hashes of the credentials to revoke. If empty, the full batch is revoked. + bytes previous_operation_hash = 1; // The hash of the operation that issued the batch. + string credential_batch_id = 2; // The corresponding batch ID, as returned in IssueCredentialBatchResponse. + repeated bytes credentials_to_revoke = 3; // The hashes of the credentials to revoke. If empty, the full batch is revoked. } // Specifies the protocol version update message ProtocolVersionUpdateOperation { - string proposer_did = 1; // The DID suffix that proposes the protocol update. - ProtocolVersionInfo version = 2; // Information of the new version + string proposer_did = 1; // The DID suffix that proposes the protocol update. + ProtocolVersionInfo version = 2; // Information of the new version } - message ProtocolVersion { - // Represent the major version - int32 major_version = 1; - // Represent the minor version - int32 minor_version = 2; + // Represent the major version + int32 major_version = 1; + // Represent the minor version + int32 minor_version = 2; } message ProtocolVersionInfo { - reserved 2, 3; - string version_name = 1; // (optional) name of the version - int32 effective_since = 4; // Cardano block number that tells since which block the update is enforced - - // New major and minor version to be announced, - // If major value changes, the node MUST stop issuing and reading operations, and upgrade before `effective_since` because the new protocol version. - // If minor value changes, the node can opt to not update. All events _published_ by this node would be also - // understood by other nodes with the same major version. However, there may be new events that this node won't _read_ - ProtocolVersion protocol_version = 5; + reserved 2, 3; + string version_name = 1; // (optional) name of the version + int32 effective_since = 4; // Cardano block number that tells since which block the update is enforced + + // New major and minor version to be announced, + // If major value changes, the node MUST stop issuing and reading operations, and upgrade before `effective_since` because the new protocol version. + // If minor value changes, the node can opt to not update. All events _published_ by this node would be also + // understood by other nodes with the same major version. However, there may be new events that this node won't _read_ + ProtocolVersion protocol_version = 5; } message DeactivateDIDOperation { - bytes previous_operation_hash = 1; // The hash of the operation that issued the DID. - string id = 2; // DID Suffix of the DID to be deactivated + bytes previous_operation_hash = 1; // The hash of the operation that issued the DID. + string id = 2; // DID Suffix of the DID to be deactivated } // The possible operations affecting the blockchain. message AtalaOperation { - // The actual operation. - oneof operation { - // Used to create a public DID. - CreateDIDOperation create_did = 1; + // The actual operation. + oneof operation { + // Used to create a public DID. + CreateDIDOperation create_did = 1; - // Used to update an existing public DID. - UpdateDIDOperation update_did = 2; + // Used to update an existing public DID. + UpdateDIDOperation update_did = 2; - // Used to issue a batch of credentials. - IssueCredentialBatchOperation issue_credential_batch = 3; + // Used to issue a batch of credentials. + IssueCredentialBatchOperation issue_credential_batch = 3; - // Used to revoke a credential batch. - RevokeCredentialsOperation revoke_credentials = 4; + // Used to revoke a credential batch. + RevokeCredentialsOperation revoke_credentials = 4; - // Used to announce new protocol update - ProtocolVersionUpdateOperation protocol_version_update = 5; + // Used to announce new protocol update + ProtocolVersionUpdateOperation protocol_version_update = 5; - // Used to deactivate DID - DeactivateDIDOperation deactivate_did = 6; - }; + // Used to deactivate DID + DeactivateDIDOperation deactivate_did = 6; + }; } // A signed operation, necessary to post anything on the blockchain. message SignedAtalaOperation { - string signed_with = 1; // The key ID used to sign the operation, it must belong to the DID that signs the operation. - bytes signature = 2; // The actual signature. - AtalaOperation operation = 3; // The operation that was signed. + string signed_with = 1; // The key ID used to sign the operation, it must belong to the DID that signs the operation. + bytes signature = 2; // The actual signature. + AtalaOperation operation = 3; // The operation that was signed. } // Ledger data associated to a protocol event. // Note that the difference with TransactionInfo is that this message contains a full // timestamp, and there is no expectation for it to be optional. message LedgerData { - string transaction_id = 1; // ID of the transaction. - Ledger ledger = 2; // Ledger the transaction was published to. - TimestampInfo timestamp_info = 3; // The timestamp of the protocol event. + string transaction_id = 1; // ID of the transaction. + Ledger ledger = 2; // Ledger the transaction was published to. + TimestampInfo timestamp_info = 3; // The timestamp of the protocol event. } // Used to encode the responses of the operations issued in an AtalaBlock. message OperationOutput { - oneof result { - // Represents the response provided by IssueCredentialBatchOperation. - IssueCredentialBatchOutput batch_output = 1; - // Represents the response provided by CreateDIDOperation. - CreateDIDOutput create_did_output = 2; - // Represents the response provided by UpdateDIDOperation. - UpdateDIDOutput update_did_output = 3; - // Represents the response provided by RevokeCredentialOperation. - RevokeCredentialsOutput revoke_credentials_output = 4; - // Represents the response provided by ProtocolVersionUpdateOperation. - ProtocolVersionUpdateOutput protocol_version_update_output = 7; - DeactivateDIDOutput deactivate_did_output = 8; - } - oneof operation_maybe { - bytes operation_id = 5; // Operation identifier. - string error = 6; // Error description if PRISM Node service haven't scheduled the operation. - } + oneof result { + // Represents the response provided by IssueCredentialBatchOperation. + IssueCredentialBatchOutput batch_output = 1; + // Represents the response provided by CreateDIDOperation. + CreateDIDOutput create_did_output = 2; + // Represents the response provided by UpdateDIDOperation. + UpdateDIDOutput update_did_output = 3; + // Represents the response provided by RevokeCredentialOperation. + RevokeCredentialsOutput revoke_credentials_output = 4; + // Represents the response provided by ProtocolVersionUpdateOperation. + ProtocolVersionUpdateOutput protocol_version_update_output = 7; + DeactivateDIDOutput deactivate_did_output = 8; + } + oneof operation_maybe { + bytes operation_id = 5; // Operation identifier. + string error = 6; // Error description if PRISM Node service haven't scheduled the operation. + } } message IssueCredentialBatchOutput { - string batch_id = 1; + string batch_id = 1; } message CreateDIDOutput { - string did_suffix = 1; + string did_suffix = 1; +} +message UpdateDIDOutput { +} +message RevokeCredentialsOutput { +} +message ProtocolVersionUpdateOutput { +} +message DeactivateDIDOutput { } -message UpdateDIDOutput {} -message RevokeCredentialsOutput {} -message ProtocolVersionUpdateOutput {} -message DeactivateDIDOutput {} message Service { - string id = 1; - string type = 2; + string id = 1; + string type = 2; - repeated string service_endpoint = 3; - LedgerData added_on = 4; // (when present) The ledger details related to the event that added the service. - LedgerData deleted_on = 5; // (when present) The ledger details related to the event that revoked the service. + repeated string service_endpoint = 3; + LedgerData added_on = 4; // (when present) The ledger details related to the event that added the service. + LedgerData deleted_on = 5; // (when present) The ledger details related to the event that revoked the service. } diff --git a/prism-node/client/scala-client/build.sbt b/prism-node/client/scala-client/build.sbt index 430b0120bf..33ae988c67 100644 --- a/prism-node/client/scala-client/build.sbt +++ b/prism-node/client/scala-client/build.sbt @@ -51,5 +51,8 @@ lazy val root = project libraryDependencies ++= rootDependencies, // gRPC settings Compile / PB.targets := Seq(scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"), - Compile / PB.protoSources := Seq(apiBaseDirectory.value / "grpc") + Compile / PB.protoSources := Seq( + apiBaseDirectory.value / "grpc", + (Compile / resourceDirectory).value // includes package wide scalapb codegen config + ) ) diff --git a/prism-node/client/scala-client/src/main/resources/package.proto b/prism-node/client/scala-client/src/main/resources/package.proto new file mode 100644 index 0000000000..c871a620f7 --- /dev/null +++ b/prism-node/client/scala-client/src/main/resources/package.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package io.iohk.atala.prism.protos; + +import "scalapb/scalapb.proto"; + +option (scalapb.options) = { + scope: PACKAGE + no_default_values_in_constructor: true +};