helpers

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package helpers hosts shared helper functions reused integration packages

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOAuthTokenMissing indicates the OAuth token is not present in the credential payload
	ErrOAuthTokenMissing = errors.New("helpers: oauth token missing")
	// ErrAccessTokenEmpty indicates the access token field is empty
	ErrAccessTokenEmpty = errors.New("helpers: access token empty")
	// ErrAPITokenMissing indicates the API token is not present in the credential payload
	ErrAPITokenMissing = errors.New("helpers: api token missing")
	// ErrHTTPRequestFailed indicates an HTTP request returned a non-2xx status
	ErrHTTPRequestFailed = errors.New("helpers: http request failed")
)

Functions

func APITokenFromPayload

func APITokenFromPayload(payload types.CredentialPayload, provider string) (string, error)

APITokenFromPayload extracts a raw API token from the credential payload.

func HTTPGetJSON

func HTTPGetJSON(ctx context.Context, client *http.Client, url string, bearer string, headers map[string]string, out any) error

HTTPGetJSON issues a GET request with the provided bearer token and decodes JSON responses.

func OAuthTokenFromPayload

func OAuthTokenFromPayload(payload types.CredentialPayload, provider string) (string, error)

OAuthTokenFromPayload extracts a usable access token from the credential payload.

func RandomState

func RandomState(bytes int) (string, error)

RandomState generates a URL-safe random string using crypto/rand

func SanitizeClientDescriptors

func SanitizeClientDescriptors(provider types.ProviderType, descriptors []types.ClientDescriptor) []types.ClientDescriptor

SanitizeClientDescriptors filters out invalid client descriptors and assigns provider type

func SanitizeOperationDescriptors

func SanitizeOperationDescriptors(provider types.ProviderType, descriptors []types.OperationDescriptor) []types.OperationDescriptor

SanitizeOperationDescriptors filters and cleans a slice of OperationDescriptor

func StringValue

func StringValue(data map[string]any, key string) string

StringValue extracts a string value from a map and returns it trimmed

Types

This section is empty.

Jump to

Keyboard shortcuts

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