host4datatug

package
v0.60.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 44 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Copyright 2026 Sneat.co

Package host4datatug holds the host adapters DataTug's checkout and project routes share across hosts: the verified-caller authenticators, the verified first-sign-in bootstrap, the personal-account and owner ports, the project contact and usage-actor ports and the reviewed plan settings. They bind the DataTug domain's narrow ports to Sneat Core, so a library cannot import a service repository and every host imports the same implementation.

Copyright 2026 Sneat.co

Index

Constants

View Source
const PlanSettingsEnv = "DATATUG_PERSONAL_PLAN_SETTINGS_JSON"

The reviewed deployment configuration is versioned and must supply every allowance and model choice. An absent or malformed value closes plan reads and new paid effects; it never invents an allowance.

Variables

This section is empty.

Functions

func BearerValue

func BearerValue(value string) (string, bool)

BearerValue extracts the token of a well-formed "Bearer <token>" header value.

func BusinessUsageActors

func BusinessUsageActors() businessUsageActors

BusinessUsageActors binds activity attribution to the verified request context preserved by DAL transaction callbacks.

func NewActiveAccountChecker

func NewActiveAccountChecker(db dal.DB, readUser func(context.Context, string) (*sneatauth.AuthUserInfo, error)) (func(context.Context, string) error, error)

NewActiveAccountChecker requires an explicitly initialized Firebase Admin user reader. It reads existing users only; it never bootstraps a Space or entitlement. Firebase verification is a preflight (including retries), never atomic with Firestore. Native fence callbacks reuse only their exact trusted owner reader; ordinary callers read the configured database in their own read transaction.

func NewInfrastructureRootMonitor

func NewInfrastructureRootMonitor(db dal.DB, observer bool, listRoots func(context.Context, string, string) ([]string, error)) (*infrastructureroots.Monitor, bool, error)

NewInfrastructureRootMonitor is shared by the scanner host and independent freshness host. Missing config disables it. No account or bot state is created.

func NewWatchIdentityReader

func NewWatchIdentityReader(readUser func(context.Context, string) (*sneatauth.AuthUserInfo, error)) (facade4datatug.WatchIdentityReader, error)

NewWatchIdentityReader never bootstraps accounts. Native status, personal account ownership and verified recipient evidence are reread in the caller's transaction; Firebase status is an additional bounded provider preflight.

func PersonalAccountForCheckout

func PersonalAccountForCheckout(ctx context.Context, db dal.DB, userID string, bootstrap *facade4auth.VerifiedPersonalBootstrap) (facade4datatug.PersonalAccount, error)

PersonalAccountForCheckout uses only an auth-account already verified by Firebase Admin for the signed-in buyer. The core resolver performs its own fresh provider match before creating a missing user.

func PersonalDirectory

func PersonalDirectory(db dal.DB) facade4datatug.PersonalAccountDirectory

PersonalDirectory binds the released personal-space authority to DataTug's account port. A missing user is deliberately refused until the host has a verified auth-account and request-client bootstrap seam.

func PersonalOwner

func PersonalOwner() facade4datatug.PersonalPlanOwnerPort

PersonalOwner verifies current ownership inside the caller's transaction.

func PlanConfiguration

func PlanConfiguration() facade4datatug.PlanConfigReader

func ProjectAccountOwner

func ProjectAccountOwner(db dal.DB) projectAccountOwner

ProjectAccountOwner keeps Paymentus's current owner fence in the same DataTug admission transaction. Checkout's wider writer adapter stays checkout-owned.

func ProjectContacts

func ProjectContacts() projectContacts

ProjectContacts binds DataTug's project-contact ports to current Contactus records. The DataTug service owns the assignment and reciprocal writes.

func ProjectRelationshipMutationPolicies

func ProjectRelationshipMutationPolicies(db dal.DB, businessReader facade4datatug.BusinessSharedProjectOptions) (*facade4linkage.RelationshipMutationPolicies, error)

ProjectRelationshipMutationPolicies builds the trusted server registry for both directions of Core Linkage's reciprocal project/contact mutations. Protection is declared before configuration is read, so any later startup failure leaves generic mutations fail-closed.

Any host that serves Core's /linkage/update_item_relationships endpoint MUST bind this registry to it (see WithLinkageMutationPolicies). Without it a DataTug project's roles fall back to Core's unprotected path.

func VerifiedPersonalBootstrap

func VerifiedPersonalBootstrap(ctx context.Context, actor string) (facade4auth.VerifiedPersonalBootstrap, error)

VerifiedPersonalBootstrap admits only a single Firebase Admin verified provider account and the actual request-derived client information.

func WithRemoteClient

func WithRemoteClient(next http.Handler) http.Handler

WithRemoteClient carries the actual request client through authenticated project and checkout requests for Core's first-sign-in Space bootstrap.

Types

type BusinessCheckoutCaller

type BusinessCheckoutCaller struct{}

BusinessCheckoutCaller verifies the same DataTug product, audience and current OAuth grant as the Pro caller, without requiring a project-write scope for a Space purchase.

func (BusinessCheckoutCaller) AuthenticateCheckout

func (BusinessCheckoutCaller) AuthenticateCheckout(ctx context.Context, bearer string) (subscriptions.BuyerIdentity, error)

type InfrastructureRootMonitorConfig

type InfrastructureRootMonitorConfig struct {
	RegistryDigest  string `json:"registryDigest"`
	CatalogArtifact []byte `json:"catalogArtifact"`
	CatalogDigest   string `json:"catalogDigest"`
	CatalogRevision string `json:"catalogRevision"`
	OperatorUserID  string `json:"operatorUserID"`
	TelegramChatID  int64  `json:"telegramChatID"`
	TelegramBotID   int64  `json:"telegramBotID"`
}

InfrastructureRootMonitorConfig is supplied by operator deployment only. CatalogArtifact is standard-base64 JSON bytes in the outer JSON object.

type PlanSettings

type PlanSettings struct {
	Version            string                    `json:"version"`
	ProjectGuestsKnown bool                      `json:"projectGuestsKnown"`
	Config             facade4datatug.PlanConfig `json:"config"`
}

func ReadPlanSettings

func ReadPlanSettings() (PlanSettings, error)

type VerifiedCaller

type VerifiedCaller struct{}

VerifiedCaller uses the host's Firebase signature and active OAuth-grant verification. The route-specific policy is bound before each verification; a caller-supplied site, body product or account never broadens it.

func (VerifiedCaller) AuthenticateCheckout

func (VerifiedCaller) AuthenticateCheckout(ctx context.Context, bearer string) (subscriptions.BuyerIdentity, error)

func (VerifiedCaller) VerifyPlanCaller

func (VerifiedCaller) VerifyPlanCaller(ctx context.Context, r *http.Request) (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL