fix(delegation): meta is optional
This commit is contained in:
@@ -79,6 +79,10 @@ func New(privKey crypto.PrivKey, aud did.DID, cmd command.Command, pol policy.Po
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(tkn.meta.Keys) < 1 {
|
||||||
|
tkn.meta = nil
|
||||||
|
}
|
||||||
|
|
||||||
if err := tkn.validate(); err != nil {
|
if err := tkn.validate(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -213,7 +217,7 @@ func tokenFromModel(m tokenPayloadModel) (*Token, error) {
|
|||||||
}
|
}
|
||||||
tkn.nonce = m.Nonce
|
tkn.nonce = m.Nonce
|
||||||
|
|
||||||
tkn.meta = &m.Meta
|
tkn.meta = m.Meta
|
||||||
|
|
||||||
if m.Nbf != nil {
|
if m.Nbf != nil {
|
||||||
t := time.Unix(*m.Nbf, 0)
|
t := time.Unix(*m.Nbf, 0)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type Payload struct {
|
|||||||
nonce Bytes
|
nonce Bytes
|
||||||
|
|
||||||
# Arbitrary Metadata
|
# Arbitrary Metadata
|
||||||
meta {String : Any}
|
meta optional {String : Any}
|
||||||
|
|
||||||
# "Not before" UTC Unix Timestamp in seconds (valid from), 53-bits integer
|
# "Not before" UTC Unix Timestamp in seconds (valid from), 53-bits integer
|
||||||
nbf optional Int
|
nbf optional Int
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ func (t *Token) toIPLD(privKey crypto.PrivKey) (datamodel.Node, error) {
|
|||||||
Cmd: t.command.String(),
|
Cmd: t.command.String(),
|
||||||
Pol: pol,
|
Pol: pol,
|
||||||
Nonce: t.nonce,
|
Nonce: t.nonce,
|
||||||
Meta: *t.meta,
|
Meta: t.meta,
|
||||||
Nbf: nbf,
|
Nbf: nbf,
|
||||||
Exp: exp,
|
Exp: exp,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ type tokenPayloadModel struct {
|
|||||||
Nonce []byte
|
Nonce []byte
|
||||||
|
|
||||||
// Arbitrary Metadata
|
// Arbitrary Metadata
|
||||||
Meta meta.Meta
|
Meta *meta.Meta
|
||||||
|
|
||||||
// "Not before" UTC Unix Timestamp in seconds (valid from), 53-bits integer
|
// "Not before" UTC Unix Timestamp in seconds (valid from), 53-bits integer
|
||||||
// optional: can be nil
|
// optional: can be nil
|
||||||
|
|||||||
Reference in New Issue
Block a user