Files
ucan/token/internal/parse/parse.go
Prad Nukala 36717a0826
Some checks failed
go continuous benchmark / Run Go continuous benchmark (push) Has been cancelled
Go Test / ubuntu (go 1.22.x) (push) Has been cancelled
Go Test / ubuntu (go 1.23.x) (push) Has been cancelled
refactor(token): migrate from ucan-wg to code.sonr.org/go
2026-01-08 15:46:02 -05:00

31 lines
501 B
Go

package parse
import (
"fmt"
"time"
"code.sonr.org/go/did-it"
"code.sonr.org/go/ucan/pkg/policy/limits"
)
func OptionalDID(s *string) (did.DID, error) {
if s == nil {
return nil, nil
}
return did.Parse(*s)
}
func OptionalTimestamp(sec *int64) (*time.Time, error) {
if sec == nil {
return nil, nil
}
if *sec > limits.MaxInt53 || *sec < limits.MinInt53 {
return nil, fmt.Errorf("timestamp value %d exceeds safe integer bounds", *sec)
}
t := time.Unix(*sec, 0)
return &t, nil
}