Skip to content
Closed
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
131 changes: 131 additions & 0 deletions commands/ucan/cbor_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions commands/ucan/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,16 @@ func TestConcludeArgumentsEmpty(t *testing.T) {
require.NoError(t, outJSON.UnmarshalDagJSON(bytes.NewReader(jb.Bytes())))
require.Empty(t, outJSON.Receipts)
}

// TestRevokeBatchArguments pins the wire shape of a batch holding a direct
// revocation and one proven by a witness path.
func TestRevokeBatchArguments(t *testing.T) {
in := &ucancmds.RevokeBatchArguments{Revocations: []ucancmds.RevokeArguments{
{Revoke: rcptA},
{Revoke: rcptB, Path: []cid.Cid{rcptA, rcptB}},
}}
require.Equal(t,
`{"revocations":[{"path":[],"revoke":{"/":"`+rcptA.String()+`"}},`+
`{"path":[{"/":"`+rcptA.String()+`"},{"/":"`+rcptB.String()+`"}],"revoke":{"/":"`+rcptB.String()+`"}}]}`,
roundTrip(t, in))
}
1 change: 1 addition & 0 deletions commands/ucan/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func main() {
models := []any{
ucan.ConcludeArguments{},
ucan.RevokeArguments{},
ucan.RevokeBatchArguments{},
}
const (
cborFile = "../cbor_gen.go"
Expand Down
143 changes: 143 additions & 0 deletions commands/ucan/json_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions commands/ucan/revoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ import (
type RevokeOK = commands.Unit

var Revoke = binding.Bind[*RevokeArguments, *RevokeOK](command.MustParse("/ucan/revoke"))

type RevokeBatchOK = commands.Unit

var RevokeBatch = binding.Bind[*RevokeBatchArguments, *RevokeBatchOK](command.MustParse("/ucan/revoke/batch"))
7 changes: 7 additions & 0 deletions commands/ucan/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ type RevokeArguments struct {
// UCAN being revoked.
Path []cid.Cid `cborgen:"path" dagjsongen:"path"`
}

// RevokeBatchArguments revokes several delegations with one invocation, so
// the service can verify and store them as one unit. The service rejects the
// whole batch when any revocation in it is invalid.
type RevokeBatchArguments struct {
Revocations []RevokeArguments `cborgen:"revocations" dagjsongen:"revocations"`
}
Loading