Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions block_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ type BlockUploadInfo struct {
Size int64
EncSignature string
Hash string
Verifier BlockUploadVerifier `json:",omitempty"`
}

// BlockUploadVerifier holds the per-block verification token required by the
// Proton storage backend to authenticate that the block was correctly encrypted.
type BlockUploadVerifier struct {
Token string `json:",omitempty"`
}

// RevisionVerification is the response from the block upload verification endpoint.
type RevisionVerification struct {
VerificationCode string // Base64-encoded verification code XOR'd with each block
ContentKeyPacket string // Encrypted content session key (for client-side integrity check)
}

type BlockUploadLink struct {
Expand Down
23 changes: 23 additions & 0 deletions link_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@ import (
"github.com/go-resty/resty/v2"
)

// GetRevisionVerification fetches the verification code for a draft revision from the
// v2 volume-based API. The VerificationCode is XOR'd with each block's encrypted bytes
// to produce a per-block Verifier.Token that the storage backend requires.
func (c *Client) GetRevisionVerification(ctx context.Context, volumeID, linkID, revisionID string) (RevisionVerification, error) {
var res struct {
VerificationCode string
ContentKeyPacket string
}

if err := c.do(ctx, func(r *resty.Request) (*resty.Response, error) {
return r.SetResult(&res).Get(
"/drive/v2/volumes/" + volumeID + "/links/" + linkID + "/revisions/" + revisionID + "/verification",
)
}); err != nil {
return RevisionVerification{}, err
}

return RevisionVerification{
VerificationCode: res.VerificationCode,
ContentKeyPacket: res.ContentKeyPacket,
}, nil
}

func (c *Client) ListRevisions(ctx context.Context, shareID, linkID string) ([]RevisionMetadata, error) {
var res struct {
Revisions []RevisionMetadata
Expand Down