package domains import ( "context" "net" "slices" "time" "atlas9.dev/c/core" "atlas9.dev/c/core/iam" ) type Store interface { Create(ctx context.Context, d *Domain) error SetVerifiedAt(ctx context.Context, tenant, id core.ID, verifiedAt time.Time) error Get(ctx context.Context, tenant, id core.ID, out *Domain) error GetByName(ctx context.Context, name string) (*Domain, error) List(ctx context.Context, tenant core.ID, page core.PageReq, out *core.Page[Domain]) error Delete(ctx context.Context, tenant, id core.ID) error } var ( Cap_Domain_Write = iam.NewCap("Cap_Domain_Write") Cap_Domain_Read = iam.NewCap("Cap_Domain_Read") ) type Domain struct { ID core.ID Tenant core.ID Domain string VerifiedAt *time.Time } func NewDomain(tenant core.ID, domain string) Domain { return Domain{ ID: core.NewID("dns"), Tenant: tenant, Domain: domain, VerifiedAt: nil, } } func VerifyDomain(domain, token string) (bool, error) { records, err := net.LookupTXT(domain) if err != nil { return false, err } if slices.Contains(records, token) { return true, nil } return false, nil }