From 7779cec445496cf1854dc56bc328d8e400db8fb7 Mon Sep 17 00:00:00 2001 From: vbasiuk Date: Wed, 20 Nov 2024 18:09:16 +0200 Subject: [PATCH] DIDComm alignement: expires_time & created_time --- message.go | 3 +++ protocol/auth.go | 6 ++++++ protocol/contract_invoke.go | 3 +++ protocol/credentials.go | 33 +++++++++++++++++++++++++++++++++ protocol/devices.go | 3 +++ protocol/messages.go | 3 +++ protocol/payment.go | 6 ++++++ protocol/payment_test.go | 14 ++++++++++---- protocol/problem_report.go | 3 +++ protocol/proof.go | 6 ++++++ protocol/revocation.go | 6 ++++++ 11 files changed, 82 insertions(+), 4 deletions(-) diff --git a/message.go b/message.go index 732504b..0f43abd 100644 --- a/message.go +++ b/message.go @@ -15,6 +15,9 @@ type BasicMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // ProtocolMessage is IDEN3Comm message diff --git a/protocol/auth.go b/protocol/auth.go index b3f2d70..98c6704 100644 --- a/protocol/auth.go +++ b/protocol/auth.go @@ -26,6 +26,9 @@ type AuthorizationResponseMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // AuthorizationMessageResponseBody is struct the represents authorization response data @@ -45,6 +48,9 @@ type AuthorizationRequestMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // AuthorizationRequestMessageBody is body for authorization request diff --git a/protocol/contract_invoke.go b/protocol/contract_invoke.go index 5a817a7..524aec4 100644 --- a/protocol/contract_invoke.go +++ b/protocol/contract_invoke.go @@ -21,6 +21,9 @@ type ContractInvokeRequestMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // ContractInvokeRequestMessageBody is body for contract invoke request diff --git a/protocol/credentials.go b/protocol/credentials.go index 2781f6d..5643981 100644 --- a/protocol/credentials.go +++ b/protocol/credentials.go @@ -98,6 +98,9 @@ type CredentialIssuanceRequestMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // CredentialIssuanceRequestMessageBody represents data for credential issuance request @@ -118,6 +121,9 @@ type CredentialsOfferMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // CredentialsOfferMessageBody is struct the represents offer message @@ -144,6 +150,9 @@ type CredentialIssuanceMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // IssuanceMessageBody is struct the represents message when credential is issued @@ -161,6 +170,9 @@ type CredentialFetchRequestMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // CredentialFetchRequestMessageBody is msg body for fetch request @@ -186,6 +198,9 @@ type CredentialStatusUpdateMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // CredentialStatusUpdateMessageBody the structure that represents the body of credential status update message @@ -205,6 +220,9 @@ type CredentialRefreshMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // CredentialRefreshMessageBody is msg body for refresh message @@ -224,6 +242,9 @@ type CredentialsOnchainOfferMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // CredentialsOnchainOfferMessageBody is struct the represents onchain offer message @@ -247,6 +268,9 @@ type CredentialsProposalRequestMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // CredentialsProposalMessage represents Iden3message for credential proposal @@ -264,6 +288,9 @@ type CredentialsProposalMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // CredentialsProposalRequestBody is msg body for proposal requests @@ -334,6 +361,9 @@ type CredentialPaymentRequestMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // CredentialPaymentRequestBody is msg body for payment requests @@ -389,6 +419,9 @@ type CredentialPaymentMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // CredentialPaymentBody is msg body for payment diff --git a/protocol/devices.go b/protocol/devices.go index 9ff1d24..00be20a 100644 --- a/protocol/devices.go +++ b/protocol/devices.go @@ -18,6 +18,9 @@ type DeviceRegistrationRequestMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // DeviceRegistrationRequestMessageBody is struct the represents body for register device request request diff --git a/protocol/messages.go b/protocol/messages.go index 16b39a5..3348c58 100644 --- a/protocol/messages.go +++ b/protocol/messages.go @@ -18,6 +18,9 @@ type MessageFetchRequestMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // MessageFetchRequestMessageBody is struct the represents body for message fetch request. diff --git a/protocol/payment.go b/protocol/payment.go index 5cfb0a4..4b737f4 100644 --- a/protocol/payment.go +++ b/protocol/payment.go @@ -59,6 +59,9 @@ type PaymentRequestMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // PaymentRequestMessageBody represents the body of the PaymentRequestMessage. @@ -334,6 +337,9 @@ type PaymentMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // PaymentMessageBody represents the body of the PaymentMessage. diff --git a/protocol/payment_test.go b/protocol/payment_test.go index b63fe83..cd10d7f 100644 --- a/protocol/payment_test.go +++ b/protocol/payment_test.go @@ -39,7 +39,8 @@ func TestPaymentRequestMessagePaymentTypeUnmarshall(t *testing.T) { ] }, "to": "did:polygonid:polygon:mumbai:2qJUZDSCFtpR8QvHyBC4eFm6ab9sJo5rqPbcaeyGC4", - "from": "did:iden3:polygon:mumbai:x3HstHLj2rTp6HHXk2WczYP7w3rpCsRbwCMeaQ2H2" + "from": "did:iden3:polygon:mumbai:x3HstHLj2rTp6HHXk2WczYP7w3rpCsRbwCMeaQ2H2", + "created_time": 1732111531 } ` @@ -51,6 +52,7 @@ func TestPaymentRequestMessagePaymentTypeUnmarshall(t *testing.T) { "to": "did:iden3:polygon:amoy:x7Z95VkUuyo6mqraJw2VGwCfqTzdqhM1RVjRHzcpK", "typ": "application/iden3comm-plain-json", "type": "https://iden3-communication.io/credentials/0.1/payment-request", + "created_time": 1732111531, "body": { "agent": "", "payments": [ @@ -170,6 +172,7 @@ func TestPaymentRequestMessagePaymentTypeUnmarshall(t *testing.T) { "from": "did:iden3:polygon:amoy:xCRp75DgAdS63W65fmXHz6p9DwdonuRU9e46DifhX", "to": "did:iden3:polygon:amoy:x7Z95VkUuyo6mqraJw2VGwCfqTzdqhM1RVjRHzcpK", "typ": "application/iden3comm-plain-json", + "created_time": 1732111531, "type": "https://iden3-communication.io/credentials/0.1/payment-request", "body": { "agent": "agent.example.com", @@ -547,7 +550,8 @@ func TestPaymentMarshalUnmarshal(t *testing.T) { ] }, "to": "did:polygonid:polygon:mumbai:2qJUZDSCFtpR8QvHyBC4eFm6ab9sJo5rqPbcaeyGC4", - "from": "did:iden3:polygon:mumbai:x3HstHLj2rTp6HHXk2WczYP7w3rpCsRbwCMeaQ2H2" + "from": "did:iden3:polygon:mumbai:x3HstHLj2rTp6HHXk2WczYP7w3rpCsRbwCMeaQ2H2", + "created_time": 1732111531 } ` const paymentNative = ` @@ -570,7 +574,8 @@ func TestPaymentMarshalUnmarshal(t *testing.T) { ] }, "to": "did:polygonid:polygon:mumbai:2qJUZDSCFtpR8QvHyBC4eFm6ab9sJo5rqPbcaeyGC4", - "from": "did:iden3:polygon:mumbai:x3HstHLj2rTp6HHXk2WczYP7w3rpCsRbwCMeaQ2H2" + "from": "did:iden3:polygon:mumbai:x3HstHLj2rTp6HHXk2WczYP7w3rpCsRbwCMeaQ2H2", + "created_time": 1732111531 } ` const paymentERC20 = ` @@ -594,7 +599,8 @@ func TestPaymentMarshalUnmarshal(t *testing.T) { ] }, "to": "did:polygonid:polygon:mumbai:2qJUZDSCFtpR8QvHyBC4eFm6ab9sJo5rqPbcaeyGC4", - "from": "did:iden3:polygon:mumbai:x3HstHLj2rTp6HHXk2WczYP7w3rpCsRbwCMeaQ2H2" + "from": "did:iden3:polygon:mumbai:x3HstHLj2rTp6HHXk2WczYP7w3rpCsRbwCMeaQ2H2", + "created_time": 1732111531 } ` diff --git a/protocol/problem_report.go b/protocol/problem_report.go index 178c8d7..34980b1 100644 --- a/protocol/problem_report.go +++ b/protocol/problem_report.go @@ -58,6 +58,9 @@ type ProblemReportMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // ProblemReportMessageBody is struct the represents body for problem report diff --git a/protocol/proof.go b/protocol/proof.go index 09ca0f0..a67315a 100644 --- a/protocol/proof.go +++ b/protocol/proof.go @@ -22,6 +22,9 @@ type ProofGenerationRequestMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // ProofGenerationRequestMessageBody is struct the represents body for proof generation request @@ -40,6 +43,9 @@ type ProofGenerationResponseMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // ResponseMessageBody is struct the represents request for revocation status diff --git a/protocol/revocation.go b/protocol/revocation.go index 7ffac0a..2f4a75a 100644 --- a/protocol/revocation.go +++ b/protocol/revocation.go @@ -22,6 +22,9 @@ type RevocationStatusRequestMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // RevocationStatusRequestMessageBody is struct the represents request for revocation status @@ -40,6 +43,9 @@ type RevocationStatusResponseMessage struct { From string `json:"from,omitempty"` To string `json:"to,omitempty"` + + CreatedTime *int64 `json:"created_time,omitempty"` + ExpiresTime *int64 `json:"expires_time,omitempty"` } // RevocationStatusResponseMessageBody is struct the represents request for revocation status