bump go-ucan
This commit is contained in:
committed by
Michael Muré
parent
3b6d70f47a
commit
cf3eb1b3f7
@@ -38,6 +38,9 @@ type UcanCtx struct {
|
||||
infura *extargs.InfuraExtArgs
|
||||
}
|
||||
|
||||
// FromContainer prepare a UcanCtx from a UCAN container, for further evaluation in a server pipeline.
|
||||
// It is expected that the container holds a single invocation and the matching delegations. If not,
|
||||
// an error is returned.
|
||||
func FromContainer(cont container.Reader) (*UcanCtx, error) {
|
||||
inv, err := cont.GetInvocation()
|
||||
if err != nil {
|
||||
@@ -95,7 +98,7 @@ func (ctn UcanCtx) Policies() policy.Policy {
|
||||
}
|
||||
|
||||
// Meta returns all the meta values from the delegations.
|
||||
// They are accumulated from the root delegation to the leaf delegation, with no overwrite.
|
||||
// They are accumulated from the root delegation to the leaf delegation, with no overwriting.
|
||||
func (ctn UcanCtx) Meta() meta.ReadOnly {
|
||||
return ctn.meta.ReadOnly()
|
||||
}
|
||||
|
||||
@@ -57,13 +57,13 @@ func ExampleContext() {
|
||||
invocation.WithExpirationIn(10*time.Minute),
|
||||
invocation.WithArgument("myarg", "hello"), // we can specify invocation parameters
|
||||
)
|
||||
invBytes, invCid, _ := inv.ToSealed(user.PrivKey())
|
||||
invBytes, _, _ := inv.ToSealed(user.PrivKey())
|
||||
|
||||
// PACKAGING: no obligation for the transport, but the user needs to give the service the invocation
|
||||
// and all the proof delegations. We can use a container for that.
|
||||
cont := container.NewWriter()
|
||||
cont.AddSealed(dlgCid, dlgBytes)
|
||||
cont.AddSealed(invCid, invBytes)
|
||||
cont.AddSealed(dlgBytes)
|
||||
cont.AddSealed(invBytes)
|
||||
contBytes, _ := cont.ToBase64StdPadding()
|
||||
|
||||
// MAKING A REQUEST: we pass the container in the Bearer HTTP header
|
||||
|
||||
@@ -107,15 +107,15 @@ func TestHttp(t *testing.T) {
|
||||
// we don't test the args hash here
|
||||
emptyArgs := args.New().ReadOnly()
|
||||
|
||||
extArgs := NewHttpExtArgs(pol, emptyArgs, r)
|
||||
ctx := NewHttpExtArgs(pol, emptyArgs, r)
|
||||
|
||||
_, err := extArgs.Args()
|
||||
_, err := ctx.Args()
|
||||
require.NoError(t, err)
|
||||
|
||||
if tc.expected {
|
||||
require.NoError(t, extArgs.Verify())
|
||||
require.NoError(t, ctx.Verify())
|
||||
} else {
|
||||
require.Error(t, extArgs.Verify())
|
||||
require.Error(t, ctx.Verify())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,12 +173,12 @@ func TestHttpHash(t *testing.T) {
|
||||
err := invArgs.Add(HttpArgsKey, tc.hash)
|
||||
require.NoError(t, err)
|
||||
|
||||
extArgs := NewHttpExtArgs(pol, invArgs.ReadOnly(), req)
|
||||
ctx := NewHttpExtArgs(pol, invArgs.ReadOnly(), req)
|
||||
|
||||
if tc.expected {
|
||||
require.NoError(t, extArgs.Verify())
|
||||
require.NoError(t, ctx.Verify())
|
||||
} else {
|
||||
require.Error(t, extArgs.Verify())
|
||||
require.Error(t, ctx.Verify())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -97,15 +97,15 @@ func TestJsonRpc(t *testing.T) {
|
||||
// we don't test the args hash here
|
||||
emptyArgs := args.New().ReadOnly()
|
||||
|
||||
extArgs := NewJsonRpcExtArgs(tc.pol, emptyArgs, tc.req)
|
||||
ctx := NewJsonRpcExtArgs(tc.pol, emptyArgs, tc.req)
|
||||
|
||||
_, err := extArgs.Args()
|
||||
_, err := ctx.Args()
|
||||
require.NoError(t, err)
|
||||
|
||||
if tc.expected {
|
||||
require.NoError(t, extArgs.Verify())
|
||||
require.NoError(t, ctx.Verify())
|
||||
} else {
|
||||
require.Error(t, extArgs.Verify())
|
||||
require.Error(t, ctx.Verify())
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -152,12 +152,12 @@ func TestJsonRpcHash(t *testing.T) {
|
||||
err := invArgs.Add(JsonRpcArgsKey, tc.hash)
|
||||
require.NoError(t, err)
|
||||
|
||||
extArgs := NewJsonRpcExtArgs(pol, invArgs.ReadOnly(), req)
|
||||
ctx := NewJsonRpcExtArgs(pol, invArgs.ReadOnly(), req)
|
||||
|
||||
if tc.expected {
|
||||
require.NoError(t, extArgs.Verify())
|
||||
require.NoError(t, ctx.Verify())
|
||||
} else {
|
||||
require.Error(t, extArgs.Verify())
|
||||
require.Error(t, ctx.Verify())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user