feat(delegation): make model(s) unexported
This commit is contained in:
@@ -88,14 +88,14 @@ func (d *View) ToIPLD(privKey crypto.PrivKey) (datamodel.Node, error) {
|
||||
exp = &u
|
||||
}
|
||||
|
||||
model := &PayloadModel{
|
||||
model := &tokenPayloadModel{
|
||||
Iss: d.Issuer.String(),
|
||||
Aud: d.Audience.String(),
|
||||
Sub: sub,
|
||||
Cmd: d.Command.String(),
|
||||
Pol: pol,
|
||||
Nonce: d.Nonce,
|
||||
Meta: MetaModel{
|
||||
Meta: metaModel{
|
||||
Keys: metaKeys,
|
||||
Values: d.Meta,
|
||||
},
|
||||
@@ -159,10 +159,10 @@ func FromDagJsonReader(r io.Reader) (*View, error) {
|
||||
// An error is returned if the conversion fails, or if the resulting
|
||||
// View is invalid.
|
||||
func FromIPLD(node datamodel.Node) (*View, error) {
|
||||
tkn, _, err := envelope.FromIPLD[*PayloadModel](node) // TODO add CID to view
|
||||
tkn, _, err := envelope.FromIPLD[*tokenPayloadModel](node) // TODO add CID to view
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ViewFromModel(*tkn)
|
||||
return viewFromModel(*tkn)
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ func mustLoadSchema() *schema.TypeSystem {
|
||||
return ts
|
||||
}
|
||||
|
||||
func PayloadType() schema.Type {
|
||||
func payloadType() schema.Type {
|
||||
return mustLoadSchema().TypeByName("Payload")
|
||||
}
|
||||
|
||||
var _ envelope.Tokener = (*PayloadModel)(nil)
|
||||
var _ envelope.Tokener = (*tokenPayloadModel)(nil)
|
||||
|
||||
type PayloadModel struct {
|
||||
type tokenPayloadModel struct {
|
||||
// Issuer DID (sender)
|
||||
Iss string
|
||||
// Audience DID (receiver)
|
||||
@@ -59,7 +59,7 @@ type PayloadModel struct {
|
||||
|
||||
// Arbitrary Metadata
|
||||
// optional: can be nil
|
||||
Meta MetaModel
|
||||
Meta metaModel
|
||||
|
||||
// "Not before" UTC Unix Timestamp in seconds (valid from), 53-bits integer
|
||||
// optional: can be nil
|
||||
@@ -69,15 +69,15 @@ type PayloadModel struct {
|
||||
Exp *int64
|
||||
}
|
||||
|
||||
func (e *PayloadModel) Prototype() schema.TypedPrototype {
|
||||
return bindnode.Prototype((*PayloadModel)(nil), PayloadType())
|
||||
func (e *tokenPayloadModel) Prototype() schema.TypedPrototype {
|
||||
return bindnode.Prototype((*tokenPayloadModel)(nil), payloadType())
|
||||
}
|
||||
|
||||
func (*PayloadModel) Tag() string {
|
||||
func (*tokenPayloadModel) Tag() string {
|
||||
return Tag
|
||||
}
|
||||
|
||||
type MetaModel struct {
|
||||
type metaModel struct {
|
||||
Keys []string
|
||||
Values map[string]datamodel.Node
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ type View struct {
|
||||
Expiration *time.Time
|
||||
}
|
||||
|
||||
// ViewFromModel build a decoded view of the raw IPLD data.
|
||||
// viewFromModel build a decoded view of the raw IPLD data.
|
||||
// This function also serves as validation.
|
||||
func ViewFromModel(m PayloadModel) (*View, error) {
|
||||
func viewFromModel(m tokenPayloadModel) (*View, error) {
|
||||
var view View
|
||||
var err error
|
||||
|
||||
|
||||
Reference in New Issue
Block a user