Skip to content

Commit 659e313

Browse files
committed
invocation: add support for self-signed invocations (issuer=subject)
1 parent 6b8cb63 commit 659e313

17 files changed

+359
-139
lines changed

token/delegation/delegation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ func tokenFromModel(m tokenPayloadModel) (*Token, error) {
238238

239239
tkn.issuer, err = did.Parse(m.Iss)
240240
if err != nil {
241-
return nil, fmt.Errorf("parse iss: %w", err)
241+
return nil, fmt.Errorf("parse issuer: %w", err)
242242
}
243243

244244
if tkn.audience, err = did.Parse(m.Aud); err != nil {
337 Bytes
Binary file not shown.
337 Bytes
Binary file not shown.
337 Bytes
Binary file not shown.
337 Bytes
Binary file not shown.
337 Bytes
Binary file not shown.
337 Bytes
Binary file not shown.

token/delegation/delegationtest/generator/generator.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,25 @@ type generator struct {
7171
chains []proof
7272
}
7373

74+
func (g *generator) createSelfDelegations(personas []didtest.Persona) error {
75+
for _, persona := range personas {
76+
_, err := g.createDelegation(newDelegationParams{
77+
privKey: persona.PrivKey(),
78+
aud: persona.DID(),
79+
cmd: delegationtest.NominalCommand,
80+
pol: policytest.EmptyPolicy,
81+
sub: didtest.PersonaAlice.DID(),
82+
opts: []delegation.Option{
83+
delegation.WithNonce(constantNonce),
84+
},
85+
}, persona.Name()+persona.Name(), noopVariant())
86+
if err != nil {
87+
return err
88+
}
89+
}
90+
return nil
91+
}
92+
7493
func (g *generator) chainPersonas(personas []didtest.Persona, acc acc, vari variant) error {
7594
acc.name += personas[0].Name()
7695

token/delegation/delegationtest/generator/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import (
66

77
func main() {
88
gen := &generator{}
9-
err := gen.chainPersonas(didtest.Personas(), acc{}, noopVariant())
9+
err := gen.createSelfDelegations(didtest.Personas())
10+
if err != nil {
11+
panic(err)
12+
}
13+
err = gen.chainPersonas(didtest.Personas(), acc{}, noopVariant())
1014
if err != nil {
1115
panic(err)
1216
}

token/delegation/delegationtest/token_gen.go

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)