You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
38 lines
1.2 KiB
package locator
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"g.activething.com/go/DateKeys/extension"
|
|
"g.activething.com/go/DateKeys/profile"
|
|
"g.activething.com/go/DateKeys/provider"
|
|
)
|
|
|
|
// OpenLocator opens the sealed locator of the extension with the release of
|
|
// the round of its own DateKey, in the profile that DateKey names: a locator
|
|
// for another round or another chain does not open, and is unusable (spec
|
|
// v0.11, §44.1). It fails when the extension has no locator.
|
|
func (i *Info) OpenLocator(reg profile.Registry, release provider.Release) (*Locator, error) {
|
|
if i.Sealed == nil {
|
|
return nil, errors.New("locator: the extension has no locator")
|
|
}
|
|
if reg == nil {
|
|
return nil, errors.New("locator: no registry of pinned profiles")
|
|
}
|
|
p, ok := reg.Lookup(i.DateKey.ProfileID)
|
|
if !ok {
|
|
return nil, errors.New("locator: the profile of the DateKey is not pinned")
|
|
}
|
|
return Open(p, i.DateKey.Round, release, i.Sealed)
|
|
}
|
|
|
|
// Standard returns the registry of the extensions of spec v0.11 with the
|
|
// data of datekeys.capsule validated by ParseInfo, as spec §54 asks of a
|
|
// reader that knows an extension.
|
|
func Standard() extension.Standard {
|
|
return extension.Standard{ValidateCapsule: func(e extension.Extension) error {
|
|
_, err := ParseInfo(e)
|
|
return err
|
|
}}
|
|
}
|