| 1 | package protocol |
| 2 | |
| 3 | // Content DTOs: reading externalized content refs back from the host. Large |
| 4 | // externalizable payloads travel as content refs; the extension pages them |
| 5 | // through host/content/read. |
| 6 | |
| 7 | // ExternalizedField is the envelope descriptor for one externalizable field |
| 8 | // whose inline value exceeded ExternalizeFieldBytes: the field travels as null |
| 9 | // in its owner document and this descriptor names the content ref holding the |
| 10 | // real bytes. It is an optional addition to the owner DTOs that carry |
| 11 | // externalizable fields (InterceptParams, InterceptResult, EventParams), so |
| 12 | // peers predating it simply never externalize. |
| 13 | type ExternalizedField struct { |
| 14 | JSONPointer string `json:"jsonPointer" validate:"nonempty"` |
| 15 | ContentRef string `json:"contentRef" validate:"nonempty"` |
| 16 | TotalBytes int64 `json:"totalBytes" validate:"min=0"` |
| 17 | SHA256 string `json:"sha256" validate:"sha256"` |
| 18 | } |
| 19 | |
| 20 | // ContentReadParams pages one content ref. Offset is a byte position; the |
| 21 | // host answers with at most ContentRefChunkBytes of Base64-decoded data. |
| 22 | type ContentReadParams struct { |
| 23 | ContentRef string `json:"contentRef" validate:"nonempty"` |
| 24 | Offset int64 `json:"offset" validate:"min=0"` |
| 25 | } |
| 26 | |
| 27 | // ContentReadResult is one page of content ref data. NextOffset is null at |
| 28 | // end of object; TotalBytes and SHA256 describe the whole object so the |
| 29 | // extension can verify the reassembled bytes. |
| 30 | type ContentReadResult struct { |
| 31 | ContentRef string `json:"contentRef" validate:"nonempty"` |
| 32 | Offset int64 `json:"offset" validate:"min=0"` |
| 33 | DataBase64 string `json:"dataBase64"` |
| 34 | NextOffset *int64 `json:"nextOffset,omitempty" validate:"min=0"` |
| 35 | TotalBytes int64 `json:"totalBytes" validate:"min=0"` |
| 36 | SHA256 string `json:"sha256" validate:"sha256"` |
| 37 | Encoding ContentEncoding `json:"encoding"` |
| 38 | } |
| 39 |