profilemetadata

package
v1.0.63 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package profilemetadata owns non-sensitive profile data and pure selector rules. It has no dependency on authentication, credential stores, or command execution.

Index

Constants

View Source
const (
	MaxVersion               = 3
	UnresolvedSelectorPrefix = "@legacy/"
	ProfileStatusActive      = "active"
)

Variables

This section is empty.

Functions

func ExactProfileSelectorForCorp

func ExactProfileSelectorForCorp(cfg *ProfilesConfig, corpID, selector string) string

func IdentitySelector

func IdentitySelector(corpID, userID string) string

func LocalProfileSelectorIsSafe

func LocalProfileSelectorIsSafe(cfg *ProfilesConfig, profile *Profile, name string) bool

func Normalize

func Normalize(cfg *ProfilesConfig)

func ParseIdentitySelector

func ParseIdentitySelector(selector string) (corpID, userID string, ok bool)

ParseIdentitySelector splits corpId:userId composite selectors. Both trimmed segments must be non-empty: a missing colon or either empty segment is not a composite selector.

func ParseUnresolvedProfileSelector

func ParseUnresolvedProfileSelector(selector string) (string, bool)

func ProfileIdentityKey

func ProfileIdentityKey(corpID, userID string) string

func ProfileIndexByIdentity

func ProfileIndexByIdentity(cfg *ProfilesConfig, corpID, userID string) int

func ProfileNameTakenByOtherIdentity

func ProfileNameTakenByOtherIdentity(cfg *ProfilesConfig, name, corpID, userID string) bool

func ProfileSelector

func ProfileSelector(profile Profile) string

func ProfileSelectorCandidates

func ProfileSelectorCandidates(profiles []*Profile) []string

func ProfileSelectorReferenceExists

func ProfileSelectorReferenceExists(cfg *ProfilesConfig, selector string) bool

func ResolveOrganizationCorpID

func ResolveOrganizationCorpID(cfg *ProfilesConfig, selector string) (string, error)

func SameProfileIdentity

func SameProfileIdentity(leftCorpID, leftUserID, rightCorpID, rightUserID string) bool

func StoredProfileSelector

func StoredProfileSelector(cfg *ProfilesConfig, profile *Profile) string

func UnresolvedProfileSelector

func UnresolvedProfileSelector(corpID string) string

Types

type Profile

type Profile struct {
	Name              string   `json:"name"`
	CorpID            string   `json:"corpId"`
	CorpName          string   `json:"corpName,omitempty"`
	UserID            string   `json:"userId,omitempty"`
	UserName          string   `json:"userName,omitempty"`
	ClientID          string   `json:"clientId,omitempty"`
	Status            string   `json:"status,omitempty"`
	AuthorizedDomains []string `json:"authorizedDomains,omitempty"`
	ExpiresAt         string   `json:"expiresAt,omitempty"`
	RefreshExpAt      string   `json:"refreshExpAt,omitempty"`
	LastLoginAt       string   `json:"lastLoginAt,omitempty"`
	LastUsedAt        string   `json:"lastUsedAt,omitempty"`
	UpdatedAt         string   `json:"updatedAt,omitempty"`
}

func FindExactProfile

func FindExactProfile(cfg *ProfilesConfig, corpID, userID string) *Profile

func ProfilesForCorpID

func ProfilesForCorpID(cfg *ProfilesConfig, corpID string) []*Profile

func ResolveOrganizationDefault

func ResolveOrganizationDefault(cfg *ProfilesConfig, corpID, displaySelector string, profiles []*Profile) (*Profile, bool, error)

func ResolveSelection

func ResolveSelection(_ string, cfg *ProfilesConfig, selector string) (*Profile, bool, error)

func UnresolvedProfileForCorp

func UnresolvedProfileForCorp(cfg *ProfilesConfig, corpID string) *Profile

func UnresolvedProfileForLocalName

func UnresolvedProfileForLocalName(cfg *ProfilesConfig, name string) *Profile

type ProfileMetadata

type ProfileMetadata struct {
	UserID   string
	UserName string
	CorpID   string
}

ProfileMetadata is the minimal, non-sensitive identity projection exposed to telemetry callers. It intentionally excludes profile names, client IDs, organization names, token material, and credential status.

func ResolveReadOnly

func ResolveReadOnly(configDir, selector string) (*ProfileMetadata, error)

ResolveReadOnly resolves one identity exclusively from the non-sensitive profiles.json metadata. It deliberately avoids auth locks, token stores, Keychain access, migrations, quarantine renames, and writes. A missing metadata file or an empty current profile returns (nil, nil).

func ResolveReadOnlyWithReader

func ResolveReadOnlyWithReader(configDir, selector string, readFile func(string) ([]byte, error)) (*ProfileMetadata, error)

ResolveReadOnlyWithReader allows auth's existing filesystem seam to use the same reader and pure selection rules without depending on credential code.

type ProfilesConfig

type ProfilesConfig struct {
	Version            int               `json:"version"`
	PrimaryProfile     string            `json:"primaryProfile,omitempty"`
	CurrentProfile     string            `json:"currentProfile,omitempty"`
	PreviousProfile    string            `json:"previousProfile,omitempty"`
	OrgCurrentProfiles map[string]string `json:"orgCurrentProfiles,omitempty"`
	Profiles           []Profile         `json:"profiles,omitempty"`
}

Jump to

Keyboard shortcuts

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