host4datatug

package
v0.72.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 56 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 InvitedFriendTitle = "Invited friend"

InvitedFriendTitle names the Space contact create_invite writes before the friend joins; the claim fills in the friend's own name.

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.

View Source
const ProjectJoinInviteGate = "datatug.project_join"

ProjectJoinInviteGate gates every invite into a dedicated project Space: create_cloud_project stamps it on the Space (SpaceDbo.InviteGate), invitus stamps it on every invite minted there by any route, and Sneat's generic accept_personal_invite refuses those with 403 invite_gated. A friend joins only through join_project, which checks their plan first and claims with AllowGate (founder 2026-10-29: "Gate the invites").

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 CloudProjectLifecycle added in v0.60.6

func CloudProjectLifecycle() facade4datatug.CloudProjectLifecycleOptions

CloudProjectLifecycle binds delete_project's ports for Space-backed cloud projects to Core: invitus revokes the dedicated Space's pending invites (facade4invitus.NewSpaceInvites), contactus' remove_space_member removes its other members (facade4contactus.RemoveSpaceMember), and Core's delete_space removes the emptied Space (facade4spaceus.DeleteSpace). The host passes it to SharedProjectService.ConfigureCloudProjectLifecycle.

func CloudProjectSpaces added in v0.60.6

func CloudProjectSpaces() cloudProjectSpaces

CloudProjectSpaces binds create_cloud_project's Space port to Core's facade4spaceus.CreateSpaceTxWorker. RegisterSpace is resumable but not atomic, so the worker runs inside DataTug's own create transaction. The Space type comes from DataTug's Space registration profile.

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), configJSON []byte) (*infrastructureroots.Monitor, bool, error)

NewInfrastructureRootMonitor is shared by the scanner host and independent freshness host. configJSON is the host's InfrastructureRootMonitorConfig JSON, normally embedded in its binary from the same commit (it holds no credential); empty disables the monitor. 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 ProjectInvites added in v0.60.6

func ProjectInvites(db dal.DB) facade4datatug.CloudProjectInvitePort

ProjectInvites binds DataTug's cloud-project invite port to the contactus create_member and remove_space_member and the invitus personal-invite facades, called in-process.

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 ReadPersonalAccountInTransaction added in v0.60.6

func ReadPersonalAccountInTransaction(ctx context.Context, tx dal.ReadTransaction, userID string) (facade4datatug.PersonalAccount, error)

ReadPersonalAccountInTransaction reads the user's one existing personal space through tx and verifies it as Core's resolver does. It never creates a user or a space: a user without one holds no personal plan (ErrPersonalAccountUnavailable). A storage failure is returned as is.

func RootSpaceLifecycle added in v0.63.0

func RootSpaceLifecycle() contract4spaceus.RootSpaceLifecycleAuthority

RootSpaceLifecycle returns Core's typed native root Space lifecycle authority. DataTug product code consumes the contract; epoch minting and archive/restore status policy stay in Core.

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