credential

package
v0.0.0-...-4b959bd Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package credential manages Slack credentials for slagent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir() string

Dir returns the credentials directory.

func Ensure

func Ensure(workspace string, extractFn func() error) error

Ensure loads credentials for the workspace. If none exist, it calls extractFn to obtain them (e.g. interactive auth). Returns an error if credentials are still unavailable after extraction.

func IsAuthError

func IsAuthError(err error) bool

IsAuthError returns true if the error is a Slack authentication failure (expired, revoked, or invalid token).

func ListWorkspaces

func ListWorkspaces() (names []string, defaultName string, err error)

ListWorkspaces returns all workspace names sorted, with the default first.

func Path

func Path() string

Path returns the path to the credentials file.

func Save

func Save(name string, creds *Credentials) error

Save writes credentials for a workspace. Does not change the default.

func SetDefault

func SetDefault(name string) error

SetDefault sets the default workspace.

Types

type Credentials

type Credentials struct {
	Token      string `json:"token,omitempty"`
	Type       string `json:"type,omitempty"`       // "bot", "user", or "session"
	Cookie     string `json:"cookie,omitempty"`     // xoxd-... for xoxc session tokens
	Enterprise bool   `json:"enterprise,omitempty"` // true for enterprise grid workspaces
}

Credentials holds the stored Slack token for one workspace.

func Load

func Load(workspace string) (*Credentials, error)

Load reads stored credentials. Empty workspace uses the default.

func (*Credentials) EffectiveToken

func (c *Credentials) EffectiveToken() string

EffectiveToken returns the token.

func (*Credentials) EffectiveType

func (c *Credentials) EffectiveType() string

EffectiveType returns the token type, inferring from prefix if not set.

type Result

type Result struct {
	Workspaces []Workspace
	Cookie     string // xoxd-... cookie, shared across all workspaces
}

Result holds the complete extraction result.

func Extract

func Extract() (*Result, error)

Extract finds Slack's data directories and extracts tokens + cookie.

type Workspace

type Workspace struct {
	ID    string
	Name  string
	URL   string
	Token string
}

Workspace represents a Slack workspace with its extracted token.

Jump to

Keyboard shortcuts

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