# State

The documents module keeps state of Documents and Document Receipts sharing.

# Store

# Documents tracking

The module appends in the store the shared document.

Key Value
docs:document:[documentID] Document

Also, the module appends to store the ID of the document, in the following lists:

Key Value
docs:documents:sent:[senderAddress]:[documentID] documentID
docs:documents:received:[receiverAddress]:[documentID] documentID

# Document Receipts tracking

The module appends in the store the shared document receipt

Key Value
docs:receipt:[receiptID] Receipt

Also, the module appends to store the ID of the document receipt, in the following lists:

Key Value
docs:receipts:sent:[senderAddress]:[receiptID] receiptID
docs:receipts:received:[receiverAddress]:[receiptID] receiptID
docs:receipts:documents:[documentID]:[receiptID] receiptID

# Type definitions

# The Document type

# Document definition

message Document {
  string sender = 1; 
  repeated string recipients = 2; 
  string UUID = 3; 
  documents.DocumentMetadata metadata = 4; 
  string contentURI = 5; 
  documents.DocumentChecksum checksum = 6; 
  documents.DocumentEncryptionData encryptionData = 7 [
    (gogoproto.moretags)   = "yaml:\"encryption_data\"",
    (gogoproto.customtype) = "DocumentEncryptionData",
    (gogoproto.nullable)   = true
  ]; 
  documents.DocumentDoSign doSign = 8 [
    (gogoproto.moretags)   = "yaml:\"do_sign\"",
    (gogoproto.customtype) = "DocumentDoSign",
    (gogoproto.nullable)   = true
  ];
}

# DocumentChecksum definition

message DocumentChecksum {
  string value = 1;
  string algorithm = 2;
}

# DocumentEncryptionData definition

message DocumentEncryptionData {
  repeated documents.DocumentEncryptionKey keys = 1;
  repeated string encryptedData = 2;
}
# DocumentEncryptionKey definition
message DocumentEncryptionKey {
  string recipient = 1;
  string Value = 2;
}

# DocumentMetadata definition

message DocumentMetadata {
	string contentURI = 1;
	DocumentMetadataSchema schema = 2;
}
# DocumentMetadataSchema definition
message DocumentMetadataSchema {
  string URI = 1;
  string version = 2;
}

# DocumentDoSign definition

message DocumentDoSign {
  string storageURI = 1;
  string signerInstance = 2;
  repeated string sdnData = 3; 
  string vcrID = 4;
  string certificateProfile = 5;
}

# TheDocumentReceipt type

Please note that the former sender of a document becomes the recipient for a DocumentReceipt. Conversely, one of the receivers (or it can be just one receiver) becomes the sender for a DocumentReceipt.

message DocumentReceipt {
    string UUID = 1; 
    string sender = 2; 
    string recipient = 3; 
    string txHash = 4; 
    string documentUUID = 5;
    string proof = 6;
}