crypt

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateKey

func CreateKey() string

func Decrypt

func Decrypt(key string, text string) string

func DecryptB64

func DecryptB64(key string, text string) string

func DecryptB64Safe added in v0.25.0

func DecryptB64Safe(key string, text string) string

func Encrypt

func Encrypt(key string, text string) string

func EncryptB64

func EncryptB64(key string, text string) string

func EncryptB64Safe added in v0.25.0

func EncryptB64Safe(key string, text string) string

func ExtractSpaceIdFromToken added in v0.23.0

func ExtractSpaceIdFromToken(token string) string

ExtractSpaceIdFromToken extracts the space ID from an agent token without validation. Returns empty string if token format is invalid.

func GenerateAPIKey

func GenerateAPIKey() (string, error)

func GenerateAgentToken added in v0.23.0

func GenerateAgentToken(spaceId, userId, zone, encryptionKey string) (string, error)

GenerateAgentToken creates a deterministic authentication token for an agent using HMAC-SHA256. The token format is: agt_<spaceId>_<signature>

Parameters:

  • spaceId: The ID of the space the agent is running in
  • userId: The ID of the user who owns the space
  • zone: The zone/region name where the server is located
  • encryptionKey: The server's encryption key used as the HMAC secret

Returns a token in the format: "agt_<spaceId>_<signature>"

func IsAgentToken added in v0.23.0

func IsAgentToken(token string) bool

IsAgentToken checks if a token is an agent token (vs a regular API token)

func ValidateAgentToken added in v0.23.0

func ValidateAgentToken(token, spaceId, userId, zone, encryptionKey string) bool

ValidateAgentToken validates an agent token and extracts the space ID. The caller must look up the space to get userId and zone for verification.

Parameters:

  • token: The agent token to validate
  • spaceId: The space ID from the token (for DB lookup)
  • userId: The user ID from the space record
  • zone: The zone from server config
  • encryptionKey: The server's encryption key used to verify the signature

Returns: true if the signature is valid

Types

This section is empty.

Jump to

Keyboard shortcuts

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