bitbucketapp

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// StaleAfter is how long SuperPlane waits for another Forge delivery
	// before it treats the cached system token as unusable.
	StaleAfter = 3 * time.Hour
)

Variables

View Source
var ErrReconnect = errors.New(reconnect)

ErrReconnect means the cached Forge token is missing, expired, or stale.

Functions

func CurrentSystemToken

func CurrentSystemToken(installationID string) (string, time.Time, error)

CurrentSystemToken returns the cached bot token for one Forge installation.

func LoadSystemToken

func LoadSystemToken(ctx context.Context, tx *gorm.DB, encryptor crypto.Encryptor, installationID string, now time.Time) (string, time.Time, error)

LoadSystemToken reads and decrypts the token stored for an installation.

func RSAPublicKey

func RSAPublicKey(modulus, exponent string) (*rsa.PublicKey, error)

RSAPublicKey builds a verification key from a JWKS entry.

func SetSystemTokenSource

func SetSystemTokenSource(source SystemTokenSource)

SetSystemTokenSource installs the process-wide reader for Forge system tokens. The Bitbucket integration calls it when a runner needs credentials.

func ShouldReplaceToken

func ShouldReplaceToken(currentExpiry, deliveredExpiry time.Time) bool

ShouldReplaceToken reports whether a newly delivered token expires later than the one already cached. A near-expiry token must not overwrite a longer-lived one.

func VerificationKeyfunc

func VerificationKeyfunc(ctx context.Context, jwksURL string) (jwtlib.Keyfunc, error)

VerificationKeyfunc verifies Forge Invocation Tokens with the published JWKS. Keys are cached. A missing key id refreshes the cache once.

Types

type Invocation

type Invocation struct {
	AppID              string
	InstallationID     string
	APIBaseURL         string
	WorkspaceUUID      string
	InstallerAccountID string
	EventType          string
	SystemToken        string
	SystemTokenExpires time.Time
}

Invocation is a verified Forge call to SuperPlane.

func ParseInvocation

func ParseInvocation(fit, systemToken, expectedAppID string, keyfunc jwtlib.Keyfunc) (Invocation, error)

ParseInvocation verifies a Forge Invocation Token and reads the system token expiry. The system token itself stays opaque except for the exp claim, which Forge documents as the way to know how long the token remains valid.

type SystemTokenSource

type SystemTokenSource func(installationID string) (token string, expiresAt time.Time, err error)

Jump to

Keyboard shortcuts

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