grantex

package module
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

README

Grantex Go SDK

Official Go SDK for the Grantex delegated authorization protocol — OAuth 2.0 for AI agents.

Installation

go get github.com/mishrasanjeev/grantex-go

Requires Go 1.26.1 or newer, matching the module's go.mod directive.

Quick Start

package main

import (
    "context"
    "fmt"
    "log"

    grantex "github.com/mishrasanjeev/grantex-go"
)

func main() {
    ctx := context.Background()
    client := grantex.NewClient("your-api-key")

    // Register an agent
    agent, err := client.Agents.Register(ctx, grantex.RegisterAgentParams{
        Name:        "Email Assistant",
        Description: "Reads and sends emails on behalf of users",
        Scopes:      []string{"read:email", "send:email"},
    })
    if err != nil {
        log.Fatal(err)
    }

    // Create authorization request
    authReq, err := client.Authorize(ctx, grantex.AuthorizeParams{
        AgentID:     agent.ID,
        PrincipalID: "user-123",
        Scopes:      []string{"read:email", "send:email"},
        Audience:    "https://mail-api.example.com",
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Send user to: %s\n", authReq.ConsentURL)

    // Exchange code for token (after user consents)
    tokenResp, err := client.Tokens.Exchange(ctx, grantex.ExchangeTokenParams{
        Code:    "authorization-code",
        AgentID: agent.ID,
    })
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Grant token: %s\n", tokenResp.GrantToken)
}

Configuration

client := grantex.NewClient("api-key",
    grantex.WithBaseURL("https://your-instance.example.com"),
    grantex.WithTimeout(60 * time.Second),
    grantex.WithHTTPClient(customClient),
)

Available Resources

Service Methods
client.Agents Register, Get, List, Update, Delete
client.Tokens Exchange, Refresh, Verify, Revoke
client.Grants Get, List, Revoke, Delegate
client.Audit Log, List, Get
client.Webhooks Create, List, Delete
client.Billing GetSubscription, CreateCheckout, CreatePortal
client.Policies Create, List, Get, Update, Delete
client.Compliance GetSummary, ExportGrants, ExportAudit, EvidencePack
client.Anomalies Detect, List, Acknowledge
client.SCIM CreateToken, ListTokens, RevokeToken, ListUsers, GetUser, CreateUser, ReplaceUser, UpdateUser, DeleteUser
client.SSO Enterprise connections, enforcement, sessions, login, OIDC/SAML/LDAP callbacks, and legacy config methods
client.PrincipalSessions Create
client.Budgets Allocate, Debit, Balance, Allocations, Transactions
client.Events Stream
client.Usage Current, History
client.Domains Create, List, Verify, Delete
client.WebAuthn RegisterOptions, RegisterVerify, ListCredentials, DeleteCredential
client.Credentials Get, List, Verify, Present
client.Passports Issue, Get, List, Revoke
client.Vault Store, List, Get, Delete, Exchange
client.DPDP Consent records/notices, grievances, erasure, principal records, exports
client.Commerce GetProfile, SearchCatalog, CreateCart, CreatePaymentIntent, CreateCheckoutLink, GetOpsHealth

Commerce V1 / OACP

profile, err := client.Commerce.GetProfile(ctx, "mch_shopify_mgx0n6_22")
products, err := client.Commerce.SearchCatalog(ctx, grantex.CommerceRecord{
    "merchant_id": "mch_shopify_mgx0n6_22",
    "limit":       3,
})

Standalone Functions

// Local JWT verification using remotely retrieved JWKS
grant, err := grantex.VerifyGrantToken(ctx, token, grantex.VerifyOptions{
    JwksURI:        "https://api.grantex.dev/.well-known/jwks.json",
    RequiredScopes: []string{"read:email"},
    Audience:       "https://api.example.com",
})

// PKCE challenge generation
pkce, err := grantex.GeneratePKCE()

// Webhook signature verification
valid := grantex.VerifyWebhookSignature(payload, signature, secret)

// Developer signup (no API key needed)
resp, err := grantex.Signup(ctx, grantex.SignupParams{Name: "My App"})

VerifyGrantToken always validates the RS256 signature, expiry, issuer, and the required Grantex claims (jti, sub, agt, dev, scp, iat, and exp). The hosted JWKS URL is automatically mapped to the canonical https://grantex.dev issuer. For custom deployments, set Issuer explicitly or set IssuerDID to a did:web identifier; otherwise the issuer is derived from JwksURI. Audience and RequiredScopes add application-specific checks.

Error Handling

agent, err := client.Agents.Get(ctx, "id")
if err != nil {
    switch e := err.(type) {
    case *grantex.AuthError:
        // 401/403
    case *grantex.APIError:
        // Other HTTP errors
    case *grantex.NetworkError:
        // Connection/timeout
    case *grantex.TokenError:
        // JWT verification errors
    }
}

Documentation

Full documentation at docs.grantex.dev.

License

Apache 2.0

Documentation

Overview

Package grantex provides a Go SDK for the Grantex delegated authorization protocol.

Create a client with NewClient and use its resource services (Agents, Tokens, Grants, etc.) to interact with the Grantex API.

client := grantex.NewClient("your-api-key")
agent, err := client.Agents.Register(ctx, grantex.RegisterAgentParams{
    Name:        "My Agent",
    Description: "An AI assistant",
    Scopes:      []string{"read:email", "send:email"},
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyWebhookSignature

func VerifyWebhookSignature(payload []byte, signature string, secret string) bool

VerifyWebhookSignature verifies an HMAC-SHA256 webhook signature. The signature should be in "sha256=<hex>" format.

Types

type APIError

type APIError struct {
	StatusCode int
	Body       json.RawMessage
	Code       string
	RequestID  string
	Message    string
	RateLimit  *RateLimit
}

APIError represents a non-2xx HTTP response from the Grantex API.

func (*APIError) Error

func (e *APIError) Error() string

type Agent

type Agent struct {
	ID          string   `json:"id"`
	DID         string   `json:"did"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Scopes      []string `json:"scopes"`
	Status      string   `json:"status"`
	DeveloperID string   `json:"developerId"`
	CreatedAt   string   `json:"createdAt"`
	UpdatedAt   string   `json:"updatedAt"`
}

Agent represents a registered agent.

type AgentsService

type AgentsService struct {
	// contains filtered or unexported fields
}

AgentsService handles agent registration and management.

func (*AgentsService) Delete

func (s *AgentsService) Delete(ctx context.Context, agentID string) error

Delete removes an agent.

func (*AgentsService) Get

func (s *AgentsService) Get(ctx context.Context, agentID string) (*Agent, error)

Get retrieves an agent by ID.

func (*AgentsService) List

List retrieves all agents for the current developer.

func (*AgentsService) Register

func (s *AgentsService) Register(ctx context.Context, params RegisterAgentParams) (*Agent, error)

Register creates a new agent.

func (*AgentsService) Update

func (s *AgentsService) Update(ctx context.Context, agentID string, params UpdateAgentParams) (*Agent, error)

Update modifies an existing agent.

type AllocateBudgetParams added in v0.1.3

type AllocateBudgetParams struct {
	GrantID       string  `json:"grantId"`
	InitialBudget float64 `json:"initialBudget"`
}

AllocateBudgetParams contains the parameters for allocating a budget.

type AnomaliesService

type AnomaliesService struct {
	// contains filtered or unexported fields
}

AnomaliesService handles anomaly detection and management.

func (*AnomaliesService) Acknowledge

func (s *AnomaliesService) Acknowledge(ctx context.Context, anomalyID string) (*Anomaly, error)

Acknowledge marks an anomaly as acknowledged.

func (*AnomaliesService) Detect

Detect triggers anomaly detection and returns results.

func (*AnomaliesService) List

List retrieves anomalies with optional filters.

type Anomaly

type Anomaly struct {
	ID             string                 `json:"id"`
	Type           string                 `json:"type"`
	Severity       string                 `json:"severity"`
	AgentID        *string                `json:"agentId"`
	PrincipalID    *string                `json:"principalId"`
	Description    string                 `json:"description"`
	Metadata       map[string]interface{} `json:"metadata"`
	DetectedAt     string                 `json:"detectedAt"`
	AcknowledgedAt *string                `json:"acknowledgedAt"`
}

Anomaly represents a detected anomaly.

type AuditEntry

type AuditEntry struct {
	EntryID     string                 `json:"entryId"`
	AgentID     string                 `json:"agentId"`
	AgentDID    string                 `json:"agentDid"`
	GrantID     string                 `json:"grantId"`
	PrincipalID string                 `json:"principalId"`
	Action      string                 `json:"action"`
	Metadata    map[string]interface{} `json:"metadata"`
	Hash        string                 `json:"hash"`
	PrevHash    *string                `json:"prevHash"`
	Timestamp   string                 `json:"timestamp"`
	Status      string                 `json:"status"`
}

AuditEntry represents an audit log entry.

type AuditService

type AuditService struct {
	// contains filtered or unexported fields
}

AuditService handles audit logging and retrieval.

func (*AuditService) Get

func (s *AuditService) Get(ctx context.Context, entryID string) (*AuditEntry, error)

Get retrieves a single audit entry by ID.

func (*AuditService) List

List retrieves audit log entries with optional filters.

func (*AuditService) Log

func (s *AuditService) Log(ctx context.Context, params LogAuditParams) (*AuditEntry, error)

Log creates an audit log entry.

type AuthError

type AuthError struct {
	*APIError
}

AuthError represents a 401 or 403 response.

func (*AuthError) Error

func (e *AuthError) Error() string

type AuthorizationRequest

type AuthorizationRequest struct {
	AuthRequestID string   `json:"authRequestId"`
	ConsentURL    string   `json:"consentUrl"`
	AgentID       string   `json:"agentId"`
	PrincipalID   string   `json:"principalId"`
	Scopes        []string `json:"scopes"`
	ExpiresIn     string   `json:"expiresIn"`
	ExpiresAt     string   `json:"expiresAt"`
	Status        string   `json:"status"`
	CreatedAt     string   `json:"createdAt"`
}

AuthorizationRequest is the response from creating an authorization request.

type AuthorizeParams

type AuthorizeParams struct {
	Audience            string   `json:"audience,omitempty"`
	AgentID             string   `json:"agentId"`
	PrincipalID         string   `json:"principalId"`
	Scopes              []string `json:"scopes"`
	ExpiresIn           string   `json:"expiresIn,omitempty"`
	RedirectURI         string   `json:"redirectUri,omitempty"`
	CodeChallenge       string   `json:"codeChallenge,omitempty"`
	CodeChallengeMethod string   `json:"codeChallengeMethod,omitempty"`
}

AuthorizeParams are the parameters for creating an authorization request.

type BillingService

type BillingService struct {
	// contains filtered or unexported fields
}

BillingService handles subscription and billing operations.

func (*BillingService) CreateCheckout

func (s *BillingService) CreateCheckout(ctx context.Context, params CreateCheckoutParams) (*CheckoutResponse, error)

CreateCheckout creates a checkout session for upgrading.

func (*BillingService) CreatePortal

func (s *BillingService) CreatePortal(ctx context.Context, params CreatePortalParams) (*PortalResponse, error)

CreatePortal creates a billing portal session.

func (*BillingService) GetSubscription

func (s *BillingService) GetSubscription(ctx context.Context) (*SubscriptionStatus, error)

GetSubscription retrieves the current subscription status.

type BudgetAllocation added in v0.1.3

type BudgetAllocation struct {
	ID              string `json:"id"`
	GrantID         string `json:"grantId"`
	DeveloperID     string `json:"developerId"`
	InitialBudget   string `json:"initialBudget"`
	RemainingBudget string `json:"remainingBudget"`
	Currency        string `json:"currency"`
	CreatedAt       string `json:"createdAt"`
	UpdatedAt       string `json:"updatedAt"`
}

BudgetAllocation represents a budget allocation record.

type BudgetTransaction added in v0.1.3

type BudgetTransaction struct {
	ID           string                 `json:"id"`
	GrantID      string                 `json:"grantId"`
	AllocationID string                 `json:"allocationId"`
	Amount       string                 `json:"amount"`
	Description  string                 `json:"description"`
	Metadata     map[string]interface{} `json:"metadata"`
	CreatedAt    string                 `json:"createdAt"`
}

BudgetTransaction represents a single budget transaction.

type BudgetsService added in v0.1.3

type BudgetsService struct {
	// contains filtered or unexported fields
}

BudgetsService handles budget allocation and tracking.

func (*BudgetsService) Allocate added in v0.1.3

Allocate creates a new budget allocation for a grant.

func (*BudgetsService) Allocations added in v0.1.3

func (s *BudgetsService) Allocations(ctx context.Context) ([]BudgetAllocation, error)

Allocations lists all budget allocations.

func (*BudgetsService) Balance added in v0.1.3

func (s *BudgetsService) Balance(ctx context.Context, grantID string) (*BudgetAllocation, error)

Balance retrieves the current budget balance for a grant.

func (*BudgetsService) Debit added in v0.1.3

Debit debits an amount from a grant's budget.

func (*BudgetsService) Transactions added in v0.1.3

func (s *BudgetsService) Transactions(ctx context.Context, grantID string) ([]BudgetTransaction, error)

Transactions lists budget transactions for a grant.

type ChainIntegrity

type ChainIntegrity struct {
	Valid          bool    `json:"valid"`
	CheckedEntries int     `json:"checkedEntries"`
	FirstBrokenAt  *string `json:"firstBrokenAt"`
}

ChainIntegrity represents audit chain integrity check results.

type CheckoutResponse

type CheckoutResponse struct {
	CheckoutURL string `json:"checkoutUrl"`
}

CheckoutResponse is the response from creating a checkout.

type Client

type Client struct {
	Agents            *AgentsService
	Tokens            *TokensService
	Grants            *GrantsService
	Audit             *AuditService
	Webhooks          *WebhooksService
	Billing           *BillingService
	Policies          *PoliciesService
	Compliance        *ComplianceService
	Anomalies         *AnomaliesService
	SCIM              *SCIMService
	SSO               *SSOService
	PrincipalSessions *PrincipalSessionsService
	Budgets           *BudgetsService
	Events            *EventsService
	Usage             *UsageService
	Domains           *DomainsService
	WebAuthn          *WebAuthnService
	Credentials       *CredentialsService
	Passports         *PassportsService
	Vault             *VaultService
	DPDP              *DPDPService
	Commerce          *CommerceService
	// contains filtered or unexported fields
}

Client is the main entry point for the Grantex SDK.

func NewClient

func NewClient(apiKey string, opts ...Option) *Client

NewClient creates a new Grantex API client.

func (*Client) Authorize

func (c *Client) Authorize(ctx context.Context, params AuthorizeParams) (*AuthorizationRequest, error)

Authorize creates an authorization request for a user to grant permissions to an agent.

func (*Client) LastRateLimit added in v0.1.1

func (c *Client) LastRateLimit() *RateLimit

LastRateLimit returns the rate limit metadata from the most recent API response, or nil if unavailable.

func (*Client) RotateKey

func (c *Client) RotateKey(ctx context.Context) (*RotateKeyResponse, error)

RotateKey rotates the developer API key.

type CommerceDataResponse added in v0.1.10

type CommerceDataResponse struct {
	Data         CommerceRecord `json:"data,omitempty"`
	AuditEventID string         `json:"audit_event_id,omitempty"`
}

CommerceDataResponse is the common Commerce response shape for write/read resources.

type CommerceListResponse added in v0.1.10

type CommerceListResponse struct {
	Items      []CommerceRecord `json:"items"`
	NextCursor *string          `json:"next_cursor,omitempty"`
}

CommerceListResponse is the common Commerce list response shape.

type CommerceProfile added in v0.1.10

type CommerceProfile struct {
	Version        string           `json:"version,omitempty"`
	Merchant       CommerceRecord   `json:"merchant,omitempty"`
	SupportedTools []string         `json:"supported_tools,omitempty"`
	Capabilities   []CommerceRecord `json:"capabilities,omitempty"`
}

CommerceProfile is the public Commerce V1/OACP merchant discovery profile.

type CommerceRecord added in v0.1.10

type CommerceRecord map[string]interface{}

CommerceRecord is a flexible Commerce V1 JSON object.

type CommerceService added in v0.1.10

type CommerceService struct {
	// contains filtered or unexported fields
}

CommerceService handles Commerce V1/OACP operations.

func (*CommerceService) ActivatePolicy added in v0.1.10

func (s *CommerceService) ActivatePolicy(ctx context.Context, policyID string) (*CommerceDataResponse, error)

func (*CommerceService) BindDeveloperTenant added in v0.1.10

func (s *CommerceService) BindDeveloperTenant(ctx context.Context, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) BulkUpsertCatalogProducts added in v0.1.10

func (s *CommerceService) BulkUpsertCatalogProducts(ctx context.Context, params CommerceRecord) (*CommerceRecord, error)

func (*CommerceService) CreateAgent added in v0.1.10

func (s *CommerceService) CreateAgent(ctx context.Context, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) CreateCart added in v0.1.10

func (s *CommerceService) CreateCart(ctx context.Context, params CommerceRecord, idempotencyKey string) (*CommerceDataResponse, error)

func (*CommerceService) CreateCatalogProduct added in v0.1.10

func (s *CommerceService) CreateCatalogProduct(ctx context.Context, params CommerceRecord) (*CommerceDataResponse, error)
func (s *CommerceService) CreateCheckoutLink(ctx context.Context, paymentIntentID string, params CommerceRecord, idempotencyKey string) (*CommerceDataResponse, error)

func (*CommerceService) CreateConsentRequest added in v0.1.10

func (s *CommerceService) CreateConsentRequest(ctx context.Context, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) CreateMerchant added in v0.1.10

func (s *CommerceService) CreateMerchant(ctx context.Context, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) CreatePaymentIntent added in v0.1.10

func (s *CommerceService) CreatePaymentIntent(ctx context.Context, params CommerceRecord, idempotencyKey string) (*CommerceDataResponse, error)

func (*CommerceService) CreatePolicy added in v0.1.10

func (s *CommerceService) CreatePolicy(ctx context.Context, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) CreateProviderCredential added in v0.1.10

func (s *CommerceService) CreateProviderCredential(ctx context.Context, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) CreateTenant added in v0.1.10

func (s *CommerceService) CreateTenant(ctx context.Context, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) CreateWebhookSource added in v0.1.10

func (s *CommerceService) CreateWebhookSource(ctx context.Context, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) DeleteCatalogProduct added in v0.1.10

func (s *CommerceService) DeleteCatalogProduct(ctx context.Context, productID string) (*CommerceDataResponse, error)

func (*CommerceService) EvaluatePolicy added in v0.1.10

func (s *CommerceService) EvaluatePolicy(ctx context.Context, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) ExchangeConsentForPassport added in v0.1.10

func (s *CommerceService) ExchangeConsentForPassport(ctx context.Context, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) GetAgent added in v0.1.10

func (s *CommerceService) GetAgent(ctx context.Context, agentID string) (*CommerceDataResponse, error)

func (*CommerceService) GetCart added in v0.1.10

func (s *CommerceService) GetCart(ctx context.Context, cartID string) (*CommerceDataResponse, error)

func (*CommerceService) GetCatalogProduct added in v0.1.10

func (s *CommerceService) GetCatalogProduct(ctx context.Context, productID string, params map[string]string) (*CommerceDataResponse, error)

func (*CommerceService) GetMerchant added in v0.1.10

func (s *CommerceService) GetMerchant(ctx context.Context, merchantID string) (*CommerceDataResponse, error)

func (*CommerceService) GetOpsHealth added in v0.1.10

func (s *CommerceService) GetOpsHealth(ctx context.Context, params map[string]string) (*CommerceRecord, error)

func (*CommerceService) GetPaymentIntent added in v0.1.10

func (s *CommerceService) GetPaymentIntent(ctx context.Context, paymentIntentID string) (*CommerceDataResponse, error)

func (*CommerceService) GetPolicy added in v0.1.10

func (s *CommerceService) GetPolicy(ctx context.Context, policyID string) (*CommerceDataResponse, error)

func (*CommerceService) GetProfile added in v0.1.10

func (s *CommerceService) GetProfile(ctx context.Context, merchantID string) (*CommerceProfile, error)

func (*CommerceService) HandleProviderWebhook added in v0.1.10

func (s *CommerceService) HandleProviderWebhook(ctx context.Context, providerKey string, payload CommerceRecord, headers map[string]string) (*CommerceDataResponse, error)

func (*CommerceService) ListAgents added in v0.1.10

func (s *CommerceService) ListAgents(ctx context.Context, params map[string]string) (*CommerceListResponse, error)

func (*CommerceService) ListAuditEvents added in v0.1.10

func (s *CommerceService) ListAuditEvents(ctx context.Context, params map[string]string) (*CommerceListResponse, error)

func (*CommerceService) ListCatalogProducts added in v0.1.10

func (s *CommerceService) ListCatalogProducts(ctx context.Context, params map[string]string) (*CommerceListResponse, error)

func (*CommerceService) ListPassports added in v0.1.10

func (s *CommerceService) ListPassports(ctx context.Context) (*CommerceListResponse, error)

func (*CommerceService) ListPaymentIntents added in v0.1.10

func (s *CommerceService) ListPaymentIntents(ctx context.Context, params map[string]string) (*CommerceListResponse, error)

func (*CommerceService) ListPolicies added in v0.1.10

func (s *CommerceService) ListPolicies(ctx context.Context, params map[string]string) (*CommerceListResponse, error)

func (*CommerceService) ListProviderCredentials added in v0.1.10

func (s *CommerceService) ListProviderCredentials(ctx context.Context, params map[string]string) (*CommerceListResponse, error)

func (*CommerceService) ListProviderWebhookEvents added in v0.1.10

func (s *CommerceService) ListProviderWebhookEvents(ctx context.Context, params map[string]string) (*CommerceListResponse, error)

func (*CommerceService) ListTenants added in v0.1.10

func (s *CommerceService) ListTenants(ctx context.Context) (*CommerceListResponse, error)

func (*CommerceService) ListWebhookSources added in v0.1.10

func (s *CommerceService) ListWebhookSources(ctx context.Context, params map[string]string) (*CommerceListResponse, error)

func (*CommerceService) MCP added in v0.1.10

func (*CommerceService) PatchProviderCredential added in v0.1.10

func (s *CommerceService) PatchProviderCredential(ctx context.Context, credentialID string, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) ReconcilePaymentIntent added in v0.1.10

func (s *CommerceService) ReconcilePaymentIntent(ctx context.Context, paymentIntentID string) (*CommerceDataResponse, error)

func (*CommerceService) ReplayProviderWebhookEvent added in v0.1.10

func (s *CommerceService) ReplayProviderWebhookEvent(ctx context.Context, eventID string, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) RevokePassport added in v0.1.10

func (s *CommerceService) RevokePassport(ctx context.Context, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) RotateWebhookSourceSecret added in v0.1.10

func (s *CommerceService) RotateWebhookSourceSecret(ctx context.Context, sourceKey string) (*CommerceDataResponse, error)

func (*CommerceService) SearchCatalog added in v0.1.10

func (s *CommerceService) SearchCatalog(ctx context.Context, params CommerceRecord) (*CommerceListResponse, error)

func (*CommerceService) UpdateAgent added in v0.1.10

func (s *CommerceService) UpdateAgent(ctx context.Context, agentID string, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) UpdateCatalogProduct added in v0.1.10

func (s *CommerceService) UpdateCatalogProduct(ctx context.Context, productID string, params CommerceRecord, query map[string]string) (*CommerceDataResponse, error)

func (*CommerceService) UpdateMerchant added in v0.1.10

func (s *CommerceService) UpdateMerchant(ctx context.Context, merchantID string, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) UpdateTenant added in v0.1.10

func (s *CommerceService) UpdateTenant(ctx context.Context, tenantID string, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) UpdateWebhookSource added in v0.1.10

func (s *CommerceService) UpdateWebhookSource(ctx context.Context, sourceKey string, params CommerceRecord) (*CommerceDataResponse, error)

func (*CommerceService) ValidateProviderCredential added in v0.1.10

func (s *CommerceService) ValidateProviderCredential(ctx context.Context, credentialID string) (*CommerceDataResponse, error)

func (*CommerceService) VerifyPassport added in v0.1.10

func (s *CommerceService) VerifyPassport(ctx context.Context, params CommerceRecord) (*CommerceDataResponse, error)

type ComplianceAuditExport

type ComplianceAuditExport struct {
	GeneratedAt string       `json:"generatedAt"`
	Total       int          `json:"total"`
	Entries     []AuditEntry `json:"entries"`
}

ComplianceAuditExport is the exported audit data.

type ComplianceExport added in v0.1.10

type ComplianceExport struct {
	ExportID    string                 `json:"exportId"`
	Type        string                 `json:"type"`
	Status      string                 `json:"status,omitempty"`
	Format      string                 `json:"format,omitempty"`
	RecordCount int                    `json:"recordCount,omitempty"`
	Data        map[string]interface{} `json:"data,omitempty"`
	DateFrom    string                 `json:"dateFrom,omitempty"`
	DateTo      string                 `json:"dateTo,omitempty"`
	ExpiresAt   string                 `json:"expiresAt,omitempty"`
	CreatedAt   string                 `json:"createdAt,omitempty"`
}

ComplianceExport represents a DPDP compliance export.

type ComplianceExportAuditParams

type ComplianceExportAuditParams struct {
	Since   string `json:"since,omitempty"`
	Until   string `json:"until,omitempty"`
	AgentID string `json:"agentId,omitempty"`
	Status  string `json:"status,omitempty"`
}

ComplianceExportAuditParams are the parameters for exporting audit entries.

type ComplianceExportGrantsParams

type ComplianceExportGrantsParams struct {
	Since  string `json:"since,omitempty"`
	Until  string `json:"until,omitempty"`
	Status string `json:"status,omitempty"`
}

ComplianceExportGrantsParams are the parameters for exporting grants.

type ComplianceGrantsExport

type ComplianceGrantsExport struct {
	GeneratedAt string  `json:"generatedAt"`
	Total       int     `json:"total"`
	Grants      []Grant `json:"grants"`
}

ComplianceGrantsExport is the exported grants data.

type ComplianceService

type ComplianceService struct {
	// contains filtered or unexported fields
}

ComplianceService handles compliance reporting and evidence exports.

func (*ComplianceService) EvidencePack

func (s *ComplianceService) EvidencePack(ctx context.Context, params *EvidencePackParams) (*EvidencePack, error)

EvidencePack generates a compliance evidence package.

func (*ComplianceService) ExportAudit

ExportAudit exports audit data for compliance.

func (*ComplianceService) ExportGrants

ExportGrants exports grants data for compliance.

func (*ComplianceService) GetSummary

GetSummary retrieves a compliance summary.

type ComplianceSummary

type ComplianceSummary struct {
	GeneratedAt  string                        `json:"generatedAt"`
	Since        *string                       `json:"since,omitempty"`
	Until        *string                       `json:"until,omitempty"`
	Agents       ComplianceSummaryAgents       `json:"agents"`
	Grants       ComplianceSummaryGrants       `json:"grants"`
	AuditEntries ComplianceSummaryAuditEntries `json:"auditEntries"`
	Policies     ComplianceSummaryPolicies     `json:"policies"`
	Plan         string                        `json:"plan"`
}

ComplianceSummary is the compliance overview.

type ComplianceSummaryAgents

type ComplianceSummaryAgents struct {
	Total     int `json:"total"`
	Active    int `json:"active"`
	Suspended int `json:"suspended"`
	Revoked   int `json:"revoked"`
}

ComplianceSummaryAgents is agent stats in a compliance summary.

type ComplianceSummaryAuditEntries

type ComplianceSummaryAuditEntries struct {
	Total   int `json:"total"`
	Success int `json:"success"`
	Failure int `json:"failure"`
	Blocked int `json:"blocked"`
}

ComplianceSummaryAuditEntries is audit stats in a compliance summary.

type ComplianceSummaryGrants

type ComplianceSummaryGrants struct {
	Total   int `json:"total"`
	Active  int `json:"active"`
	Revoked int `json:"revoked"`
	Expired int `json:"expired"`
}

ComplianceSummaryGrants is grant stats in a compliance summary.

type ComplianceSummaryParams

type ComplianceSummaryParams struct {
	Since string `json:"since,omitempty"`
	Until string `json:"until,omitempty"`
}

ComplianceSummaryParams are the parameters for getting a compliance summary.

type ComplianceSummaryPolicies

type ComplianceSummaryPolicies struct {
	Total int `json:"total"`
}

ComplianceSummaryPolicies is policy stats in a compliance summary.

type ConsentNotice added in v0.1.10

type ConsentNotice struct {
	ID          string `json:"id"`
	NoticeID    string `json:"noticeId"`
	Version     string `json:"version"`
	Language    string `json:"language"`
	ContentHash string `json:"contentHash"`
	CreatedAt   string `json:"createdAt"`
}

ConsentNotice represents a registered consent notice version.

type ConsentPurpose added in v0.1.10

type ConsentPurpose struct {
	Code        string `json:"code"`
	Description string `json:"description"`
}

ConsentPurpose describes a data processing purpose for DPDP consent.

type ConsentRecord added in v0.1.10

type ConsentRecord struct {
	RecordID            string                 `json:"recordId"`
	GrantID             string                 `json:"grantId"`
	DataPrincipalID     string                 `json:"dataPrincipalId"`
	Status              string                 `json:"status"`
	ConsentNoticeHash   string                 `json:"consentNoticeHash,omitempty"`
	ConsentProof        map[string]interface{} `json:"consentProof,omitempty"`
	ProcessingExpiresAt string                 `json:"processingExpiresAt,omitempty"`
	RetentionUntil      string                 `json:"retentionUntil,omitempty"`
	DataFiduciaryName   string                 `json:"dataFiduciaryName,omitempty"`
	Purposes            []ConsentPurpose       `json:"purposes,omitempty"`
	Scopes              []string               `json:"scopes,omitempty"`
	ConsentNoticeID     string                 `json:"consentNoticeId,omitempty"`
	ConsentGivenAt      string                 `json:"consentGivenAt,omitempty"`
	AccessCount         int                    `json:"accessCount,omitempty"`
	LastAccessedAt      string                 `json:"lastAccessedAt,omitempty"`
	WithdrawnAt         *string                `json:"withdrawnAt"`
	WithdrawnReason     *string                `json:"withdrawnReason"`
	CreatedAt           string                 `json:"createdAt,omitempty"`
}

ConsentRecord represents a DPDP consent record.

type CreateCheckoutParams

type CreateCheckoutParams struct {
	Plan       string `json:"plan"`
	SuccessURL string `json:"successUrl"`
	CancelURL  string `json:"cancelUrl"`
}

CreateCheckoutParams are the parameters for creating a checkout session.

type CreateConsentNoticeParams added in v0.1.10

type CreateConsentNoticeParams struct {
	NoticeID             string            `json:"noticeId"`
	Version              string            `json:"version"`
	Title                string            `json:"title"`
	Content              string            `json:"content"`
	Purposes             []ConsentPurpose  `json:"purposes"`
	Language             string            `json:"language,omitempty"`
	DataFiduciaryContact string            `json:"dataFiduciaryContact,omitempty"`
	GrievanceOfficer     *GrievanceOfficer `json:"grievanceOfficer,omitempty"`
}

CreateConsentNoticeParams contains the parameters for creating a consent notice.

type CreateConsentRecordParams added in v0.1.10

type CreateConsentRecordParams struct {
	GrantID             string           `json:"grantId"`
	DataPrincipalID     string           `json:"dataPrincipalId"`
	Purposes            []ConsentPurpose `json:"purposes"`
	ConsentNoticeID     string           `json:"consentNoticeId"`
	ProcessingExpiresAt string           `json:"processingExpiresAt"`
}

CreateConsentRecordParams contains the parameters for creating a consent record.

type CreateDomainParams added in v0.1.3

type CreateDomainParams struct {
	Domain string `json:"domain"`
}

CreateDomainParams contains the parameters for creating a custom domain.

type CreateExportParams added in v0.1.10

type CreateExportParams struct {
	Type                  string `json:"type"`
	DateFrom              string `json:"dateFrom"`
	DateTo                string `json:"dateTo"`
	Format                string `json:"format,omitempty"`
	IncludeActionLog      *bool  `json:"includeActionLog,omitempty"`
	IncludeConsentRecords *bool  `json:"includeConsentRecords,omitempty"`
	DataPrincipalID       string `json:"dataPrincipalId,omitempty"`
}

CreateExportParams contains the parameters for creating a compliance export.

type CreatePolicyParams

type CreatePolicyParams struct {
	Name           string   `json:"name"`
	Effect         string   `json:"effect"`
	Priority       *int     `json:"priority,omitempty"`
	AgentID        string   `json:"agentId,omitempty"`
	PrincipalID    string   `json:"principalId,omitempty"`
	Scopes         []string `json:"scopes,omitempty"`
	TimeOfDayStart string   `json:"timeOfDayStart,omitempty"`
	TimeOfDayEnd   string   `json:"timeOfDayEnd,omitempty"`
}

CreatePolicyParams are the parameters for creating a policy.

type CreatePortalParams

type CreatePortalParams struct {
	ReturnURL string `json:"returnUrl"`
}

CreatePortalParams are the parameters for creating a billing portal session.

type CreatePrincipalSessionParams

type CreatePrincipalSessionParams struct {
	PrincipalID string `json:"principalId"`
	ExpiresIn   string `json:"expiresIn,omitempty"`
}

CreatePrincipalSessionParams are the parameters for creating a principal session.

type CreateScimTokenParams

type CreateScimTokenParams struct {
	Label string `json:"label"`
}

CreateScimTokenParams are the parameters for creating a SCIM token.

type CreateScimUserParams

type CreateScimUserParams struct {
	UserName    string      `json:"userName"`
	DisplayName string      `json:"displayName,omitempty"`
	ExternalID  string      `json:"externalId,omitempty"`
	Emails      []ScimEmail `json:"emails,omitempty"`
	Active      *bool       `json:"active,omitempty"`
}

CreateScimUserParams are the parameters for creating a SCIM user.

type CreateSsoConfigParams

type CreateSsoConfigParams struct {
	IssuerURL    string `json:"issuerUrl"`
	ClientID     string `json:"clientId"`
	ClientSecret string `json:"clientSecret"`
	RedirectURI  string `json:"redirectUri"`
}

CreateSsoConfigParams are the parameters for creating an SSO configuration.

type CreateSsoConnectionParams added in v0.1.4

type CreateSsoConnectionParams struct {
	Name                  string              `json:"name"`
	Protocol              string              `json:"protocol"`
	IssuerURL             string              `json:"issuerUrl,omitempty"`
	ClientID              string              `json:"clientId,omitempty"`
	ClientSecret          string              `json:"clientSecret,omitempty"`
	IdpEntityID           string              `json:"idpEntityId,omitempty"`
	IdpSsoURL             string              `json:"idpSsoUrl,omitempty"`
	IdpCertificate        string              `json:"idpCertificate,omitempty"`
	LdapURL               string              `json:"ldapUrl,omitempty"`
	LdapBindDN            string              `json:"ldapBindDn,omitempty"`
	LdapBindPassword      string              `json:"ldapBindPassword,omitempty"`
	LdapSearchBase        string              `json:"ldapSearchBase,omitempty"`
	LdapSearchFilter      string              `json:"ldapSearchFilter,omitempty"`
	LdapGroupSearchBase   string              `json:"ldapGroupSearchBase,omitempty"`
	LdapGroupSearchFilter string              `json:"ldapGroupSearchFilter,omitempty"`
	LdapTlsEnabled        bool                `json:"ldapTlsEnabled,omitempty"`
	Domains               []string            `json:"domains,omitempty"`
	JitProvisioning       bool                `json:"jitProvisioning,omitempty"`
	GroupAttribute        string              `json:"groupAttribute,omitempty"`
	GroupMappings         map[string][]string `json:"groupMappings,omitempty"`
	DefaultScopes         []string            `json:"defaultScopes,omitempty"`
}

CreateSsoConnectionParams are the parameters for creating an SSO connection.

type CreateWebhookParams

type CreateWebhookParams struct {
	URL    string   `json:"url"`
	Events []string `json:"events"`
}

CreateWebhookParams are the parameters for creating a webhook.

type CredentialsService added in v0.1.3

type CredentialsService struct {
	// contains filtered or unexported fields
}

CredentialsService handles Verifiable Credential operations.

func (*CredentialsService) Get added in v0.1.3

Get retrieves a Verifiable Credential by ID.

func (*CredentialsService) List added in v0.1.3

List retrieves Verifiable Credentials with optional filters.

func (*CredentialsService) Present added in v0.1.3

Present creates an SD-JWT presentation with selective disclosure.

func (*CredentialsService) Verify added in v0.1.3

Verify verifies a VC-JWT.

type DPDPService added in v0.1.10

type DPDPService struct {
	// contains filtered or unexported fields
}

DPDPService handles DPDP (Digital Personal Data Protection Act 2023) operations.

func (*DPDPService) CreateConsentNotice added in v0.1.10

func (s *DPDPService) CreateConsentNotice(ctx context.Context, params CreateConsentNoticeParams) (*ConsentNotice, error)

CreateConsentNotice registers a consent notice version.

func (*DPDPService) CreateConsentRecord added in v0.1.10

func (s *DPDPService) CreateConsentRecord(ctx context.Context, params CreateConsentRecordParams) (*ConsentRecord, error)

CreateConsentRecord creates a DPDP consent record linked to a Grantex grant.

func (*DPDPService) CreateExport added in v0.1.10

func (s *DPDPService) CreateExport(ctx context.Context, params CreateExportParams) (*ComplianceExport, error)

CreateExport generates a compliance export (DPDP audit, GDPR Article 15, EU AI Act).

func (*DPDPService) FileGrievance added in v0.1.10

func (s *DPDPService) FileGrievance(ctx context.Context, params FileGrievanceParams) (*Grievance, error)

FileGrievance files a grievance under DPDP section 13(6).

func (*DPDPService) GetConsentRecord added in v0.1.10

func (s *DPDPService) GetConsentRecord(ctx context.Context, recordID string) (*ConsentRecord, error)

GetConsentRecord fetches a single consent record by ID.

func (*DPDPService) GetExport added in v0.1.10

func (s *DPDPService) GetExport(ctx context.Context, exportID string) (*ComplianceExport, error)

GetExport retrieves an export by ID.

func (*DPDPService) GetGrievance added in v0.1.10

func (s *DPDPService) GetGrievance(ctx context.Context, grievanceID string) (*Grievance, error)

GetGrievance retrieves a grievance by ID.

func (*DPDPService) ListConsentRecords added in v0.1.10

func (s *DPDPService) ListConsentRecords(ctx context.Context, principalID string) ([]ConsentRecord, error)

ListConsentRecords lists consent records, optionally filtered by data principal ID.

func (*DPDPService) ListPrincipalRecords added in v0.1.10

func (s *DPDPService) ListPrincipalRecords(ctx context.Context, principalID string) (*PrincipalRecordsResponse, error)

ListPrincipalRecords lists all consent records for a data principal (right to access).

func (*DPDPService) RequestErasure added in v0.1.10

func (s *DPDPService) RequestErasure(ctx context.Context, principalID string) (*ErasureResponse, error)

RequestErasure submits a data erasure request for a data principal.

func (*DPDPService) WithdrawConsent added in v0.1.10

func (s *DPDPService) WithdrawConsent(ctx context.Context, recordID string, params WithdrawConsentParams) (*WithdrawConsentResponse, error)

WithdrawConsent withdraws consent for a consent record.

type DebitBudgetParams added in v0.1.3

type DebitBudgetParams struct {
	GrantID     string  `json:"grantId"`
	Amount      float64 `json:"amount"`
	Description string  `json:"description,omitempty"`
}

DebitBudgetParams contains the parameters for debiting a budget.

type DebitBudgetResponse added in v0.1.3

type DebitBudgetResponse struct {
	Remaining     string `json:"remaining"`
	TransactionID string `json:"transactionId"`
}

DebitBudgetResponse is the response from a budget debit operation.

type DelegateParams

type DelegateParams struct {
	ParentGrantToken string   `json:"parentGrantToken"`
	SubAgentID       string   `json:"subAgentId"`
	Scopes           []string `json:"scopes"`
	ExpiresIn        string   `json:"expiresIn,omitempty"`
}

DelegateParams are the parameters for grant delegation.

type DelegateResponse

type DelegateResponse struct {
	GrantToken string   `json:"grantToken"`
	ExpiresAt  string   `json:"expiresAt"`
	Scopes     []string `json:"scopes"`
	GrantID    string   `json:"grantId"`
}

DelegateResponse is the response from grant delegation.

type DetectAnomaliesResponse

type DetectAnomaliesResponse struct {
	DetectedAt string    `json:"detectedAt"`
	Total      int       `json:"total"`
	Anomalies  []Anomaly `json:"anomalies"`
}

DetectAnomaliesResponse is the response from anomaly detection.

type Domain added in v0.1.3

type Domain struct {
	ID                string `json:"id"`
	Domain            string `json:"domain"`
	Verified          bool   `json:"verified"`
	VerificationToken string `json:"verificationToken"`
	Instructions      string `json:"instructions"`
	CreatedAt         string `json:"createdAt"`
}

Domain represents a custom domain record.

type DomainsService added in v0.1.3

type DomainsService struct {
	// contains filtered or unexported fields
}

DomainsService handles custom domain management.

func (*DomainsService) Create added in v0.1.3

func (s *DomainsService) Create(ctx context.Context, params CreateDomainParams) (*Domain, error)

Create registers a new custom domain.

func (*DomainsService) Delete added in v0.1.3

func (s *DomainsService) Delete(ctx context.Context, id string) error

Delete removes a custom domain.

func (*DomainsService) List added in v0.1.3

func (s *DomainsService) List(ctx context.Context) ([]Domain, error)

List retrieves all registered custom domains.

func (*DomainsService) Verify added in v0.1.3

Verify triggers DNS verification for a domain.

type ErasureResponse added in v0.1.10

type ErasureResponse struct {
	RequestID            string `json:"requestId"`
	DataPrincipalID      string `json:"dataPrincipalId"`
	Status               string `json:"status"`
	RecordsErased        int    `json:"recordsErased"`
	GrantsRevoked        int    `json:"grantsRevoked"`
	SubmittedAt          string `json:"submittedAt"`
	ExpectedCompletionBy string `json:"expectedCompletionBy"`
}

ErasureResponse is the result of a data erasure request.

type Event added in v0.1.3

type Event struct {
	Type    string                 `json:"type"`
	Payload map[string]interface{} `json:"payload"`
}

Event represents a server-sent event.

type EventsService added in v0.1.3

type EventsService struct {
	// contains filtered or unexported fields
}

EventsService handles real-time event streaming.

func (*EventsService) Stream added in v0.1.3

func (s *EventsService) Stream(ctx context.Context, ch chan<- Event) error

Stream opens an SSE connection and sends events to the provided channel. It blocks until the context is cancelled or the connection is closed.

type EvidencePack

type EvidencePack struct {
	Meta           EvidencePackMeta  `json:"meta"`
	Summary        ComplianceSummary `json:"summary"`
	Grants         []Grant           `json:"grants"`
	AuditEntries   []AuditEntry      `json:"auditEntries"`
	Policies       []Policy          `json:"policies"`
	ChainIntegrity ChainIntegrity    `json:"chainIntegrity"`
}

EvidencePack is a compliance evidence package.

type EvidencePackMeta

type EvidencePackMeta struct {
	SchemaVersion string  `json:"schemaVersion"`
	GeneratedAt   string  `json:"generatedAt"`
	Since         *string `json:"since,omitempty"`
	Until         *string `json:"until,omitempty"`
	Framework     string  `json:"framework"`
}

EvidencePackMeta is metadata for an evidence pack.

type EvidencePackParams

type EvidencePackParams struct {
	Since     string `json:"since,omitempty"`
	Until     string `json:"until,omitempty"`
	Framework string `json:"framework,omitempty"`
}

EvidencePackParams are the parameters for generating an evidence pack.

type ExchangeCredentialParams added in v0.1.4

type ExchangeCredentialParams struct {
	Service string `json:"service"`
}

ExchangeCredentialParams contains the parameters for exchanging a grant token for a credential.

type ExchangeCredentialResponse added in v0.1.4

type ExchangeCredentialResponse struct {
	AccessToken    string                 `json:"accessToken"`
	Service        string                 `json:"service"`
	CredentialType string                 `json:"credentialType"`
	TokenExpiresAt *string                `json:"tokenExpiresAt"`
	Metadata       map[string]interface{} `json:"metadata"`
}

ExchangeCredentialResponse is the response from exchanging a grant token for a credential.

type ExchangeTokenParams

type ExchangeTokenParams struct {
	Code         string `json:"code"`
	AgentID      string `json:"agentId"`
	CodeVerifier string `json:"codeVerifier,omitempty"`
}

ExchangeTokenParams are the parameters for exchanging an authorization code.

type ExchangeTokenResponse

type ExchangeTokenResponse struct {
	GrantToken   string   `json:"grantToken"`
	ExpiresAt    string   `json:"expiresAt"`
	Scopes       []string `json:"scopes"`
	RefreshToken string   `json:"refreshToken"`
	GrantID      string   `json:"grantId"`
}

ExchangeTokenResponse is the response from token exchange or refresh.

type FileGrievanceParams added in v0.1.10

type FileGrievanceParams struct {
	DataPrincipalID string                 `json:"dataPrincipalId"`
	Type            string                 `json:"type"`
	Description     string                 `json:"description"`
	RecordID        string                 `json:"recordId,omitempty"`
	Evidence        map[string]interface{} `json:"evidence,omitempty"`
}

FileGrievanceParams contains the parameters for filing a DPDP grievance.

type GetPassportResponse added in v0.1.4

type GetPassportResponse struct {
	Status string `json:"status"`
}

GetPassportResponse is the response from getting a passport by ID.

type Grant

type Grant struct {
	ID          string   `json:"grantId"`
	AgentID     string   `json:"agentId"`
	AgentDID    string   `json:"agentDid"`
	PrincipalID string   `json:"principalId"`
	DeveloperID string   `json:"developerId"`
	Scopes      []string `json:"scopes"`
	Status      string   `json:"status"`
	IssuedAt    string   `json:"issuedAt"`
	ExpiresAt   string   `json:"expiresAt"`
	RevokedAt   *string  `json:"revokedAt,omitempty"`
}

Grant represents an authorization grant.

type GrantsService

type GrantsService struct {
	// contains filtered or unexported fields
}

GrantsService handles grant management and delegation.

func (*GrantsService) Delegate

func (s *GrantsService) Delegate(ctx context.Context, params DelegateParams) (*DelegateResponse, error)

Delegate creates a delegated grant for a sub-agent.

func (*GrantsService) Get

func (s *GrantsService) Get(ctx context.Context, grantID string) (*Grant, error)

Get retrieves a grant by ID.

func (*GrantsService) List

List retrieves grants with optional filters.

func (*GrantsService) Revoke

func (s *GrantsService) Revoke(ctx context.Context, grantID string) error

Revoke revokes a grant by ID.

type Grievance added in v0.1.10

type Grievance struct {
	GrievanceID          string                 `json:"grievanceId"`
	Status               string                 `json:"status"`
	Type                 string                 `json:"type,omitempty"`
	ReferenceNumber      string                 `json:"referenceNumber,omitempty"`
	DataPrincipalID      string                 `json:"dataPrincipalId,omitempty"`
	RecordID             *string                `json:"recordId"`
	Description          string                 `json:"description,omitempty"`
	Evidence             map[string]interface{} `json:"evidence,omitempty"`
	ExpectedResolutionBy string                 `json:"expectedResolutionBy,omitempty"`
	ResolvedAt           *string                `json:"resolvedAt"`
	Resolution           *string                `json:"resolution"`
	CreatedAt            string                 `json:"createdAt,omitempty"`
}

Grievance represents a DPDP grievance.

type GrievanceOfficer added in v0.1.10

type GrievanceOfficer struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Phone string `json:"phone,omitempty"`
}

GrievanceOfficer represents the grievance officer contact info in a consent notice.

type IssuePassportParams added in v0.1.4

type IssuePassportParams struct {
	AgentID              string            `json:"agentId"`
	GrantID              string            `json:"grantId"`
	AllowedMPPCategories []string          `json:"allowedMPPCategories"`
	MaxTransactionAmount TransactionAmount `json:"maxTransactionAmount"`
	PaymentRails         []string          `json:"paymentRails,omitempty"`
	ExpiresIn            string            `json:"expiresIn,omitempty"`
	ParentPassportID     string            `json:"parentPassportId,omitempty"`
}

IssuePassportParams contains the parameters for issuing an agent passport.

type IssuedPassportResponse added in v0.1.4

type IssuedPassportResponse struct {
	PassportID        string                 `json:"passportId"`
	Credential        map[string]interface{} `json:"credential"`
	EncodedCredential string                 `json:"encodedCredential"`
	ExpiresAt         string                 `json:"expiresAt"`
}

IssuedPassportResponse is the response from issuing an agent passport.

type ListAgentsResponse

type ListAgentsResponse struct {
	Agents   []Agent `json:"agents"`
	Total    int     `json:"total"`
	Page     int     `json:"page"`
	PageSize int     `json:"pageSize"`
}

ListAgentsResponse is the response from listing agents.

type ListAnomaliesParams

type ListAnomaliesParams struct {
	Unacknowledged *bool `json:"unacknowledged,omitempty"`
}

ListAnomaliesParams are the parameters for listing anomalies.

type ListAnomaliesResponse

type ListAnomaliesResponse struct {
	Anomalies []Anomaly `json:"anomalies"`
	Total     int       `json:"total"`
}

ListAnomaliesResponse is the response from listing anomalies.

type ListAuditParams

type ListAuditParams struct {
	AgentID     string `json:"agentId,omitempty"`
	GrantID     string `json:"grantId,omitempty"`
	PrincipalID string `json:"principalId,omitempty"`
	Action      string `json:"action,omitempty"`
	Since       string `json:"since,omitempty"`
	Until       string `json:"until,omitempty"`
	Page        int    `json:"page,omitempty"`
	PageSize    int    `json:"pageSize,omitempty"`
}

ListAuditParams are the parameters for listing audit entries.

type ListAuditResponse

type ListAuditResponse struct {
	Entries  []AuditEntry `json:"entries"`
	Total    int          `json:"total"`
	Page     int          `json:"page"`
	PageSize int          `json:"pageSize"`
}

ListAuditResponse is the response from listing audit entries.

type ListCredentialsParams added in v0.1.3

type ListCredentialsParams struct {
	GrantID string
	Status  string
}

ListCredentialsParams contains optional filters for listing credentials.

type ListGrantsParams

type ListGrantsParams struct {
	AgentID     string `json:"agentId,omitempty"`
	PrincipalID string `json:"principalId,omitempty"`
	Status      string `json:"status,omitempty"`
	Page        int    `json:"page,omitempty"`
	PageSize    int    `json:"pageSize,omitempty"`
}

ListGrantsParams are the parameters for listing grants.

type ListGrantsResponse

type ListGrantsResponse struct {
	Grants   []Grant `json:"grants"`
	Total    int     `json:"total"`
	Page     int     `json:"page"`
	PageSize int     `json:"pageSize"`
}

ListGrantsResponse is the response from listing grants.

type ListPassportsParams added in v0.1.4

type ListPassportsParams struct {
	AgentID string
	GrantID string
	Status  string
}

ListPassportsParams contains optional filters for listing passports.

type ListPoliciesResponse

type ListPoliciesResponse struct {
	Policies []Policy `json:"policies"`
	Total    int      `json:"total"`
}

ListPoliciesResponse is the response from listing policies.

type ListScimTokensResponse

type ListScimTokensResponse struct {
	Tokens []ScimToken `json:"tokens"`
}

ListScimTokensResponse is the response from listing SCIM tokens.

type ListScimUsersParams

type ListScimUsersParams struct {
	StartIndex int `json:"startIndex,omitempty"`
	Count      int `json:"count,omitempty"`
}

ListScimUsersParams are the parameters for listing SCIM users.

type ListSsoConnectionsResponse added in v0.1.4

type ListSsoConnectionsResponse struct {
	Connections []SsoConnection `json:"connections"`
}

ListSsoConnectionsResponse is the response from listing SSO connections.

type ListSsoSessionsResponse added in v0.1.4

type ListSsoSessionsResponse struct {
	Sessions []SsoSession `json:"sessions"`
}

ListSsoSessionsResponse is the response from listing SSO sessions.

type ListVaultCredentialsParams added in v0.1.4

type ListVaultCredentialsParams struct {
	PrincipalID string
	Service     string
}

ListVaultCredentialsParams contains optional filters for listing vault credentials.

type ListWebhooksResponse

type ListWebhooksResponse struct {
	Webhooks []WebhookEndpoint `json:"webhooks"`
}

ListWebhooksResponse is the response from listing webhooks.

type LogAuditParams

type LogAuditParams struct {
	AgentID  string                 `json:"agentId"`
	GrantID  string                 `json:"grantId"`
	Action   string                 `json:"action"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
	Status   string                 `json:"status,omitempty"`
}

LogAuditParams are the parameters for logging an audit entry.

type NetworkError

type NetworkError struct {
	Message string
	Cause   error
}

NetworkError represents a network-level failure (DNS, timeout, connection refused).

func (*NetworkError) Error

func (e *NetworkError) Error() string

func (*NetworkError) Unwrap

func (e *NetworkError) Unwrap() error

type Option

type Option func(*clientConfig)

Option configures a Grantex client.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL sets the API base URL. Defaults to "https://api.grantex.dev".

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets a custom http.Client for requests.

func WithMaxRetries added in v0.1.5

func WithMaxRetries(n int) Option

WithMaxRetries sets the maximum number of retry attempts for transient failures (HTTP 429, 502, 503, 504, and network errors). Defaults to 3. Set to 0 to disable retries.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the HTTP request timeout. Defaults to 30 seconds.

type PKCEChallenge

type PKCEChallenge struct {
	CodeVerifier        string
	CodeChallenge       string
	CodeChallengeMethod string // Always "S256"
}

PKCEChallenge holds a PKCE code verifier and its S256 challenge.

func GeneratePKCE

func GeneratePKCE() (*PKCEChallenge, error)

GeneratePKCE creates a new PKCE code verifier and S256 challenge pair.

type PassportsService added in v0.1.4

type PassportsService struct {
	// contains filtered or unexported fields
}

PassportsService handles Agent Passport Credential operations.

func (*PassportsService) Get added in v0.1.4

func (s *PassportsService) Get(ctx context.Context, passportID string) (*GetPassportResponse, error)

Get retrieves a passport by ID.

func (*PassportsService) Issue added in v0.1.4

Issue creates a new Agent Passport Credential.

func (*PassportsService) List added in v0.1.4

List retrieves passports with optional filters.

func (*PassportsService) Revoke added in v0.1.4

func (s *PassportsService) Revoke(ctx context.Context, passportID string) (*RevokePassportResponse, error)

Revoke revokes a passport by ID.

type PoliciesService

type PoliciesService struct {
	// contains filtered or unexported fields
}

PoliciesService handles access policy management.

func (*PoliciesService) Create

func (s *PoliciesService) Create(ctx context.Context, params CreatePolicyParams) (*Policy, error)

Create creates a new access policy.

func (*PoliciesService) Delete

func (s *PoliciesService) Delete(ctx context.Context, policyID string) error

Delete removes a policy.

func (*PoliciesService) Get

func (s *PoliciesService) Get(ctx context.Context, policyID string) (*Policy, error)

Get retrieves a policy by ID.

func (*PoliciesService) List

List retrieves all policies.

func (*PoliciesService) Update

func (s *PoliciesService) Update(ctx context.Context, policyID string, params UpdatePolicyParams) (*Policy, error)

Update modifies an existing policy.

type Policy

type Policy struct {
	ID             string   `json:"id"`
	Name           string   `json:"name"`
	Effect         string   `json:"effect"`
	Priority       int      `json:"priority"`
	AgentID        *string  `json:"agentId"`
	PrincipalID    *string  `json:"principalId"`
	Scopes         []string `json:"scopes"`
	TimeOfDayStart *string  `json:"timeOfDayStart"`
	TimeOfDayEnd   *string  `json:"timeOfDayEnd"`
	CreatedAt      string   `json:"createdAt"`
	UpdatedAt      string   `json:"updatedAt"`
}

Policy represents an access policy.

type PortalResponse

type PortalResponse struct {
	PortalURL string `json:"portalUrl"`
}

PortalResponse is the response from creating a portal session.

type PrincipalRecordsResponse added in v0.1.10

type PrincipalRecordsResponse struct {
	DataPrincipalID string          `json:"dataPrincipalId"`
	Records         []ConsentRecord `json:"records"`
	TotalRecords    int             `json:"totalRecords"`
}

PrincipalRecordsResponse contains the consent records for a data principal.

type PrincipalSessionResponse

type PrincipalSessionResponse struct {
	SessionToken string `json:"sessionToken"`
	DashboardURL string `json:"dashboardUrl"`
	ExpiresAt    string `json:"expiresAt"`
}

PrincipalSessionResponse is the response from creating a principal session.

type PrincipalSessionsService

type PrincipalSessionsService struct {
	// contains filtered or unexported fields
}

PrincipalSessionsService handles principal session management.

func (*PrincipalSessionsService) Create

Create creates a new principal session for end-user dashboard access.

type RateLimit added in v0.1.1

type RateLimit struct {
	Limit      int
	Remaining  int
	Reset      int64
	RetryAfter int // 0 = not present
}

RateLimit contains rate limit metadata parsed from response headers.

type RefreshTokenParams

type RefreshTokenParams struct {
	RefreshToken string `json:"refreshToken"`
	AgentID      string `json:"agentId"`
}

RefreshTokenParams are the parameters for refreshing a token.

type RegisterAgentParams

type RegisterAgentParams struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Scopes      []string `json:"scopes"`
}

RegisterAgentParams are the parameters for registering an agent.

type RevokePassportResponse added in v0.1.4

type RevokePassportResponse struct {
	Revoked   bool   `json:"revoked"`
	RevokedAt string `json:"revokedAt"`
}

RevokePassportResponse is the response from revoking a passport.

type RotateKeyResponse

type RotateKeyResponse struct {
	APIKey    string `json:"apiKey"`
	RotatedAt string `json:"rotatedAt"`
}

RotateKeyResponse is returned from RotateKey.

type SCIMService

type SCIMService struct {
	// contains filtered or unexported fields
}

SCIMService handles SCIM 2.0 provisioning operations.

func (*SCIMService) CreateToken

func (s *SCIMService) CreateToken(ctx context.Context, label string) (*ScimTokenWithSecret, error)

CreateToken creates a new SCIM provisioning token.

func (*SCIMService) CreateUser

func (s *SCIMService) CreateUser(ctx context.Context, params CreateScimUserParams) (*ScimUser, error)

CreateUser creates a new SCIM user.

func (*SCIMService) DeleteUser

func (s *SCIMService) DeleteUser(ctx context.Context, userID string) error

DeleteUser removes a SCIM user.

func (*SCIMService) GetUser

func (s *SCIMService) GetUser(ctx context.Context, userID string) (*ScimUser, error)

GetUser retrieves a SCIM user by ID.

func (*SCIMService) ListTokens

func (s *SCIMService) ListTokens(ctx context.Context) (*ListScimTokensResponse, error)

ListTokens retrieves all SCIM provisioning tokens.

func (*SCIMService) ListUsers

func (s *SCIMService) ListUsers(ctx context.Context, params *ListScimUsersParams) (*ScimListResponse, error)

ListUsers retrieves SCIM users with optional pagination.

func (*SCIMService) ReplaceUser

func (s *SCIMService) ReplaceUser(ctx context.Context, userID string, params CreateScimUserParams) (*ScimUser, error)

ReplaceUser replaces a SCIM user (PUT).

func (*SCIMService) RevokeToken

func (s *SCIMService) RevokeToken(ctx context.Context, tokenID string) error

RevokeToken revokes a SCIM provisioning token.

func (*SCIMService) UpdateUser

func (s *SCIMService) UpdateUser(ctx context.Context, userID string, ops []ScimOperation) (*ScimUser, error)

UpdateUser performs a SCIM PATCH operation on a user.

type SDJWTPresentParams added in v0.1.3

type SDJWTPresentParams struct {
	SDJWT           string   `json:"sdJwt"`
	DisclosedClaims []string `json:"disclosedClaims"`
}

SDJWTPresentParams contains the parameters for creating an SD-JWT presentation.

type SDJWTPresentResult added in v0.1.3

type SDJWTPresentResult struct {
	Presentation string `json:"presentation"`
}

SDJWTPresentResult is the result of creating an SD-JWT presentation.

type SSOService

type SSOService struct {
	// contains filtered or unexported fields
}

SSOService handles SSO configuration, connections, and authentication.

func (*SSOService) CreateConfig

func (s *SSOService) CreateConfig(ctx context.Context, params CreateSsoConfigParams) (*SsoConfig, error)

CreateConfig creates an SSO configuration. Deprecated: Use CreateConnection for enterprise SSO.

func (*SSOService) CreateConnection added in v0.1.4

func (s *SSOService) CreateConnection(ctx context.Context, params CreateSsoConnectionParams) (*SsoConnection, error)

CreateConnection creates a new SSO connection (OIDC or SAML).

func (*SSOService) DeleteConfig

func (s *SSOService) DeleteConfig(ctx context.Context) error

DeleteConfig removes the SSO configuration. Deprecated: Use DeleteConnection for enterprise SSO.

func (*SSOService) DeleteConnection added in v0.1.4

func (s *SSOService) DeleteConnection(ctx context.Context, id string) error

DeleteConnection deletes an SSO connection.

func (*SSOService) GetConfig

func (s *SSOService) GetConfig(ctx context.Context) (*SsoConfig, error)

GetConfig retrieves the current SSO configuration. Deprecated: Use ListConnections for enterprise SSO.

func (*SSOService) GetConnection added in v0.1.4

func (s *SSOService) GetConnection(ctx context.Context, id string) (*SsoConnection, error)

GetConnection retrieves an SSO connection by ID.

func (*SSOService) GetLoginURL

func (s *SSOService) GetLoginURL(ctx context.Context, org string, domain ...string) (*SsoLoginResponse, error)

GetLoginURL gets the SSO login URL for an organization, with an optional domain hint.

func (*SSOService) HandleCallback

func (s *SSOService) HandleCallback(ctx context.Context, code string, state string) (*SsoCallbackResponse, error)

HandleCallback processes an SSO callback. Deprecated: Use HandleOidcCallback or HandleSamlCallback for enterprise SSO.

func (*SSOService) HandleLdapCallback added in v0.1.4

func (s *SSOService) HandleLdapCallback(ctx context.Context, params SsoLdapCallbackParams) (*SsoCallbackResult, error)

HandleLdapCallback processes an LDAP SSO callback with bind authentication.

func (*SSOService) HandleOidcCallback added in v0.1.4

func (s *SSOService) HandleOidcCallback(ctx context.Context, params SsoOidcCallbackParams) (*SsoCallbackResult, error)

HandleOidcCallback processes an OIDC SSO callback.

func (*SSOService) HandleSamlCallback added in v0.1.4

func (s *SSOService) HandleSamlCallback(ctx context.Context, params SsoSamlCallbackParams) (*SsoCallbackResult, error)

HandleSamlCallback processes a SAML SSO callback.

func (*SSOService) ListConnections added in v0.1.4

func (s *SSOService) ListConnections(ctx context.Context) (*ListSsoConnectionsResponse, error)

ListConnections lists all SSO connections.

func (*SSOService) ListSessions added in v0.1.4

func (s *SSOService) ListSessions(ctx context.Context) (*ListSsoSessionsResponse, error)

ListSessions lists active SSO sessions.

func (*SSOService) RevokeSession added in v0.1.4

func (s *SSOService) RevokeSession(ctx context.Context, id string) error

RevokeSession revokes an SSO session by ID.

func (*SSOService) SetEnforcement added in v0.1.4

func (s *SSOService) SetEnforcement(ctx context.Context, params SsoEnforcementParams) (*SsoEnforcementResponse, error)

SetEnforcement configures SSO enforcement settings.

func (*SSOService) TestConnection added in v0.1.4

func (s *SSOService) TestConnection(ctx context.Context, id string) (*SsoConnectionTestResult, error)

TestConnection tests an SSO connection's configuration.

func (*SSOService) UpdateConnection added in v0.1.4

func (s *SSOService) UpdateConnection(ctx context.Context, id string, params UpdateSsoConnectionParams) (*SsoConnection, error)

UpdateConnection updates an existing SSO connection.

type ScimEmail

type ScimEmail struct {
	Value   string `json:"value"`
	Primary bool   `json:"primary,omitempty"`
}

ScimEmail represents an email in SCIM format.

type ScimListResponse

type ScimListResponse struct {
	TotalResults int        `json:"totalResults"`
	StartIndex   int        `json:"startIndex"`
	ItemsPerPage int        `json:"itemsPerPage"`
	Resources    []ScimUser `json:"Resources"`
}

ScimListResponse is the SCIM list response.

type ScimOperation

type ScimOperation struct {
	Op    string      `json:"op"`
	Path  string      `json:"path,omitempty"`
	Value interface{} `json:"value,omitempty"`
}

ScimOperation represents a SCIM PATCH operation.

type ScimToken

type ScimToken struct {
	ID         string  `json:"id"`
	Label      string  `json:"label"`
	CreatedAt  string  `json:"createdAt"`
	LastUsedAt *string `json:"lastUsedAt"`
}

ScimToken represents a SCIM provisioning token.

type ScimTokenWithSecret

type ScimTokenWithSecret struct {
	ID         string  `json:"id"`
	Label      string  `json:"label"`
	CreatedAt  string  `json:"createdAt"`
	LastUsedAt *string `json:"lastUsedAt"`
	Token      string  `json:"token"`
}

ScimTokenWithSecret is a SCIM token that includes the secret value.

type ScimUser

type ScimUser struct {
	ID          string       `json:"id"`
	ExternalID  *string      `json:"externalId,omitempty"`
	UserName    string       `json:"userName"`
	DisplayName *string      `json:"displayName,omitempty"`
	Active      bool         `json:"active"`
	Emails      []ScimEmail  `json:"emails"`
	Meta        ScimUserMeta `json:"meta"`
}

ScimUser represents a SCIM-provisioned user.

type ScimUserMeta

type ScimUserMeta struct {
	ResourceType string `json:"resourceType"`
	Created      string `json:"created"`
	LastModified string `json:"lastModified"`
}

ScimUserMeta is SCIM user metadata.

type SignupParams

type SignupParams struct {
	Name  string `json:"name"`
	Email string `json:"email,omitempty"`
}

SignupParams are the parameters for developer registration.

type SignupResponse

type SignupResponse struct {
	DeveloperID string  `json:"developerId"`
	APIKey      string  `json:"apiKey"`
	Name        string  `json:"name"`
	Email       *string `json:"email"`
	Mode        string  `json:"mode"`
	CreatedAt   string  `json:"createdAt"`
}

SignupResponse is returned from Signup.

func Signup

func Signup(ctx context.Context, params SignupParams, opts ...Option) (*SignupResponse, error)

Signup registers a new developer account. This is a static operation that does not require an API key.

type SsoCallbackResponse

type SsoCallbackResponse struct {
	Email       *string `json:"email"`
	Name        *string `json:"name"`
	Sub         *string `json:"sub"`
	DeveloperID string  `json:"developerId"`
}

SsoCallbackResponse is the response from handling an SSO callback. Deprecated: Use SsoCallbackResult for enterprise SSO.

type SsoCallbackResult added in v0.1.4

type SsoCallbackResult struct {
	SessionID    string   `json:"sessionId"`
	Email        *string  `json:"email"`
	Name         *string  `json:"name"`
	Sub          *string  `json:"sub"`
	Groups       []string `json:"groups"`
	MappedScopes []string `json:"mappedScopes"`
	PrincipalID  *string  `json:"principalId"`
	DeveloperID  string   `json:"developerId"`
	ExpiresAt    string   `json:"expiresAt"`
}

SsoCallbackResult is the result from an enterprise SSO callback (OIDC, SAML, or LDAP).

type SsoConfig

type SsoConfig struct {
	IssuerURL   string `json:"issuerUrl"`
	ClientID    string `json:"clientId"`
	RedirectURI string `json:"redirectUri"`
	CreatedAt   string `json:"createdAt"`
	UpdatedAt   string `json:"updatedAt"`
}

SsoConfig represents an SSO configuration.

type SsoConnection added in v0.1.4

type SsoConnection struct {
	ID                    string              `json:"id"`
	DeveloperID           string              `json:"developerId"`
	Name                  string              `json:"name"`
	Protocol              string              `json:"protocol"`
	Status                string              `json:"status"`
	IssuerURL             string              `json:"issuerUrl,omitempty"`
	ClientID              string              `json:"clientId,omitempty"`
	IdpEntityID           string              `json:"idpEntityId,omitempty"`
	IdpSsoURL             string              `json:"idpSsoUrl,omitempty"`
	SpEntityID            string              `json:"spEntityId,omitempty"`
	SpAcsURL              string              `json:"spAcsUrl,omitempty"`
	LdapURL               string              `json:"ldapUrl,omitempty"`
	LdapBindDN            string              `json:"ldapBindDn,omitempty"`
	LdapSearchBase        string              `json:"ldapSearchBase,omitempty"`
	LdapSearchFilter      string              `json:"ldapSearchFilter,omitempty"`
	LdapGroupSearchBase   string              `json:"ldapGroupSearchBase,omitempty"`
	LdapGroupSearchFilter string              `json:"ldapGroupSearchFilter,omitempty"`
	LdapTlsEnabled        bool                `json:"ldapTlsEnabled,omitempty"`
	Domains               []string            `json:"domains"`
	JitProvisioning       bool                `json:"jitProvisioning"`
	Enforce               bool                `json:"enforce"`
	GroupAttribute        string              `json:"groupAttribute,omitempty"`
	GroupMappings         map[string][]string `json:"groupMappings"`
	DefaultScopes         []string            `json:"defaultScopes"`
	CreatedAt             string              `json:"createdAt"`
	UpdatedAt             string              `json:"updatedAt"`
}

SsoConnection represents an enterprise SSO connection (OIDC, SAML, or LDAP).

type SsoConnectionTestResult added in v0.1.4

type SsoConnectionTestResult struct {
	Success  bool     `json:"success"`
	Protocol string   `json:"protocol"`
	Issuer   string   `json:"issuer,omitempty"`
	Error    string   `json:"error,omitempty"`
	Details  []string `json:"details,omitempty"`
}

SsoConnectionTestResult is the result of testing an SSO connection.

type SsoEnforcementParams added in v0.1.4

type SsoEnforcementParams struct {
	Enforce bool `json:"enforce"`
}

SsoEnforcementParams are the parameters for configuring SSO enforcement.

type SsoEnforcementResponse added in v0.1.4

type SsoEnforcementResponse struct {
	Enforce     bool   `json:"enforce"`
	DeveloperID string `json:"developerId"`
}

SsoEnforcementResponse is the response from setting SSO enforcement.

type SsoLdapCallbackParams added in v0.1.4

type SsoLdapCallbackParams struct {
	Username     string `json:"username"`
	Password     string `json:"password"`
	ConnectionID string `json:"connectionId"`
	Org          string `json:"org"`
}

SsoLdapCallbackParams are the parameters for handling an LDAP SSO callback.

type SsoLoginResponse

type SsoLoginResponse struct {
	AuthorizeURL string `json:"authorizeUrl"`
}

SsoLoginResponse is the response from getting an SSO login URL.

type SsoOidcCallbackParams added in v0.1.4

type SsoOidcCallbackParams struct {
	Code        string `json:"code"`
	State       string `json:"state"`
	RedirectURI string `json:"redirect_uri,omitempty"`
}

SsoOidcCallbackParams are the parameters for handling an OIDC SSO callback.

type SsoSamlCallbackParams added in v0.1.4

type SsoSamlCallbackParams struct {
	SAMLResponse string `json:"SAMLResponse"`
	RelayState   string `json:"RelayState"`
}

SsoSamlCallbackParams are the parameters for handling a SAML SSO callback.

type SsoSession added in v0.1.4

type SsoSession struct {
	ID           string `json:"id"`
	DeveloperID  string `json:"developerId"`
	ConnectionID string `json:"connectionId"`
	Email        string `json:"email"`
	ExpiresAt    string `json:"expiresAt"`
	CreatedAt    string `json:"createdAt"`
}

SsoSession represents an active SSO session.

type StoreCredentialParams added in v0.1.4

type StoreCredentialParams struct {
	PrincipalID    string                 `json:"principalId"`
	Service        string                 `json:"service"`
	CredentialType string                 `json:"credentialType,omitempty"`
	AccessToken    string                 `json:"accessToken"`
	RefreshToken   string                 `json:"refreshToken,omitempty"`
	TokenExpiresAt string                 `json:"tokenExpiresAt,omitempty"`
	Metadata       map[string]interface{} `json:"metadata,omitempty"`
}

StoreCredentialParams contains the parameters for storing a credential in the vault.

type StoreCredentialResponse added in v0.1.4

type StoreCredentialResponse struct {
	ID             string `json:"id"`
	PrincipalID    string `json:"principalId"`
	Service        string `json:"service"`
	CredentialType string `json:"credentialType"`
	CreatedAt      string `json:"createdAt"`
}

StoreCredentialResponse is the response from storing a credential.

type SubscriptionStatus

type SubscriptionStatus struct {
	Plan             string  `json:"plan"`
	Status           string  `json:"status"`
	CurrentPeriodEnd *string `json:"currentPeriodEnd"`
}

SubscriptionStatus represents the current subscription.

type TokenError

type TokenError struct {
	Message string
	Cause   error
}

TokenError represents a token verification or decoding error.

func (*TokenError) Error

func (e *TokenError) Error() string

func (*TokenError) Unwrap

func (e *TokenError) Unwrap() error

type TokensService

type TokensService struct {
	// contains filtered or unexported fields
}

TokensService handles token exchange, refresh, verification, and revocation.

func (*TokensService) Exchange

Exchange trades an authorization code for a grant token.

func (*TokensService) Refresh

Refresh exchanges a refresh token for a new grant token.

func (*TokensService) Revoke

func (s *TokensService) Revoke(ctx context.Context, tokenID string) error

Revoke revokes a token by its ID.

func (*TokensService) Verify

func (s *TokensService) Verify(ctx context.Context, token string) (*VerifyTokenResponse, error)

Verify performs online token verification.

type TransactionAmount added in v0.1.4

type TransactionAmount struct {
	Amount   float64 `json:"amount"`
	Currency string  `json:"currency"`
}

TransactionAmount represents a monetary amount with currency.

type UpdateAgentParams

type UpdateAgentParams struct {
	Name        *string  `json:"name,omitempty"`
	Description *string  `json:"description,omitempty"`
	Scopes      []string `json:"scopes,omitempty"`
}

UpdateAgentParams are the parameters for updating an agent.

type UpdatePolicyParams

type UpdatePolicyParams struct {
	Name           *string  `json:"name,omitempty"`
	Effect         *string  `json:"effect,omitempty"`
	Priority       *int     `json:"priority,omitempty"`
	AgentID        *string  `json:"agentId,omitempty"`
	PrincipalID    *string  `json:"principalId,omitempty"`
	Scopes         []string `json:"scopes,omitempty"`
	TimeOfDayStart *string  `json:"timeOfDayStart,omitempty"`
	TimeOfDayEnd   *string  `json:"timeOfDayEnd,omitempty"`
}

UpdatePolicyParams are the parameters for updating a policy.

type UpdateSsoConnectionParams added in v0.1.4

type UpdateSsoConnectionParams struct {
	Name                  *string              `json:"name,omitempty"`
	Status                *string              `json:"status,omitempty"`
	IssuerURL             *string              `json:"issuerUrl,omitempty"`
	ClientID              *string              `json:"clientId,omitempty"`
	ClientSecret          *string              `json:"clientSecret,omitempty"`
	IdpEntityID           *string              `json:"idpEntityId,omitempty"`
	IdpSsoURL             *string              `json:"idpSsoUrl,omitempty"`
	IdpCertificate        *string              `json:"idpCertificate,omitempty"`
	LdapURL               *string              `json:"ldapUrl,omitempty"`
	LdapBindDN            *string              `json:"ldapBindDn,omitempty"`
	LdapBindPassword      *string              `json:"ldapBindPassword,omitempty"`
	LdapSearchBase        *string              `json:"ldapSearchBase,omitempty"`
	LdapSearchFilter      *string              `json:"ldapSearchFilter,omitempty"`
	LdapGroupSearchBase   *string              `json:"ldapGroupSearchBase,omitempty"`
	LdapGroupSearchFilter *string              `json:"ldapGroupSearchFilter,omitempty"`
	LdapTlsEnabled        *bool                `json:"ldapTlsEnabled,omitempty"`
	Domains               []string             `json:"domains,omitempty"`
	JitProvisioning       *bool                `json:"jitProvisioning,omitempty"`
	GroupAttribute        *string              `json:"groupAttribute,omitempty"`
	GroupMappings         *map[string][]string `json:"groupMappings,omitempty"`
	DefaultScopes         []string             `json:"defaultScopes,omitempty"`
}

UpdateSsoConnectionParams are the parameters for updating an SSO connection.

type UsageHistoryEntry added in v0.1.3

type UsageHistoryEntry struct {
	Date           string `json:"date"`
	TokenExchanges int    `json:"tokenExchanges"`
	Authorizations int    `json:"authorizations"`
	Verifications  int    `json:"verifications"`
	TotalRequests  int    `json:"totalRequests"`
}

UsageHistoryEntry represents a single day's usage metrics.

type UsageResponse added in v0.1.3

type UsageResponse struct {
	DeveloperID    string `json:"developerId"`
	Period         string `json:"period"`
	TokenExchanges int    `json:"tokenExchanges"`
	Authorizations int    `json:"authorizations"`
	Verifications  int    `json:"verifications"`
	TotalRequests  int    `json:"totalRequests"`
}

UsageResponse represents the current usage metrics.

type UsageService added in v0.1.3

type UsageService struct {
	// contains filtered or unexported fields
}

UsageService handles usage metering operations.

func (*UsageService) Current added in v0.1.3

func (s *UsageService) Current(ctx context.Context) (*UsageResponse, error)

Current retrieves the current period's usage metrics.

func (*UsageService) History added in v0.1.3

func (s *UsageService) History(ctx context.Context, days int) ([]UsageHistoryEntry, error)

History retrieves usage history for the specified number of days.

type VCVerificationResult added in v0.1.3

type VCVerificationResult struct {
	Valid             bool                   `json:"valid"`
	CredentialSubject map[string]interface{} `json:"credentialSubject"`
	Issuer            string                 `json:"issuer"`
	Error             string                 `json:"error,omitempty"`
}

VCVerificationResult is the result of verifying a Verifiable Credential.

type VaultCredential added in v0.1.4

type VaultCredential struct {
	ID             string                 `json:"id"`
	PrincipalID    string                 `json:"principalId"`
	Service        string                 `json:"service"`
	CredentialType string                 `json:"credentialType"`
	TokenExpiresAt *string                `json:"tokenExpiresAt"`
	Metadata       map[string]interface{} `json:"metadata"`
	CreatedAt      string                 `json:"createdAt"`
	UpdatedAt      string                 `json:"updatedAt"`
}

VaultCredential represents a credential record in the vault.

type VaultService added in v0.1.4

type VaultService struct {
	// contains filtered or unexported fields
}

VaultService handles credential vault operations.

func (*VaultService) Delete added in v0.1.4

func (s *VaultService) Delete(ctx context.Context, credentialID string) error

Delete removes a credential from the vault.

func (*VaultService) Exchange added in v0.1.4

Exchange trades a grant token for an upstream service credential. Unlike other methods, this uses the grant token (not the API key) as the Bearer token.

func (*VaultService) Get added in v0.1.4

func (s *VaultService) Get(ctx context.Context, credentialID string) (*VaultCredential, error)

Get retrieves credential metadata by ID (no raw token).

func (*VaultService) List added in v0.1.4

List retrieves credential metadata (no raw tokens).

func (*VaultService) Store added in v0.1.4

Store saves an encrypted credential in the vault (upserts on principal+service).

type VerifiableCredentialRecord added in v0.1.3

type VerifiableCredentialRecord struct {
	ID           string   `json:"id"`
	Type         []string `json:"type"`
	Issuer       string   `json:"issuer"`
	Subject      string   `json:"subject"`
	GrantID      string   `json:"grantId"`
	Status       string   `json:"status"`
	IssuanceDate string   `json:"issuanceDate"`
	JWT          string   `json:"jwt"`
}

VerifiableCredentialRecord represents a Verifiable Credential record.

type VerifiedGrant

type VerifiedGrant struct {
	TokenID         string   `json:"tokenId"`
	GrantID         string   `json:"grantId"`
	PrincipalID     string   `json:"principalId"`
	AgentDID        string   `json:"agentDid"`
	DeveloperID     string   `json:"developerId"`
	Scopes          []string `json:"scopes"`
	IssuedAt        int64    `json:"issuedAt"`
	ExpiresAt       int64    `json:"expiresAt"`
	ParentAgentDID  *string  `json:"parentAgentDid,omitempty"`
	ParentGrantID   *string  `json:"parentGrantId,omitempty"`
	DelegationDepth *int     `json:"delegationDepth,omitempty"`
}

VerifiedGrant represents a verified JWT grant token's claims.

func VerifyGrantToken

func VerifyGrantToken(ctx context.Context, token string, opts VerifyOptions) (*VerifiedGrant, error)

VerifyGrantToken performs local JWT verification using JWKS retrieved from JwksURI. It verifies the RS256 signature, expiration, issuer, required grant claims, and optionally checks required scopes and audience.

type VerifyDomainResponse added in v0.1.3

type VerifyDomainResponse struct {
	Verified bool `json:"verified"`
}

VerifyDomainResponse is the response from a domain verification operation.

type VerifyOptions

type VerifyOptions struct {
	// JwksURI is the URL to fetch the JSON Web Key Set from.
	JwksURI string

	// Issuer is the expected issuer claim. When empty, it is derived from
	// IssuerDID or JwksURI. The hosted Grantex JWKS maps to https://grantex.dev.
	Issuer string

	// IssuerDID resolves a did:web identifier to its JWKS URL and issuer.
	// It takes precedence over JwksURI when set to a did:web value.
	IssuerDID string

	// RequiredScopes are scopes the token must contain. If empty, scope checking is skipped.
	RequiredScopes []string

	// Audience is the expected audience claim. If empty, audience checking is skipped.
	Audience string

	// ClockTolerance allows for clock skew between servers. Defaults to 0.
	ClockTolerance time.Duration
}

VerifyOptions configures local grant token verification using remotely retrieved JWKS.

type VerifyTokenResponse

type VerifyTokenResponse struct {
	Valid     bool     `json:"valid"`
	GrantID   *string  `json:"grantId,omitempty"`
	Scopes    []string `json:"scopes,omitempty"`
	Principal *string  `json:"principal,omitempty"`
	Agent     *string  `json:"agent,omitempty"`
	ExpiresAt *string  `json:"expiresAt,omitempty"`
}

VerifyTokenResponse is the response from online token verification.

type WebAuthnCredential added in v0.1.3

type WebAuthnCredential struct {
	ID           string   `json:"id"`
	CredentialID string   `json:"credentialId"`
	PublicKey    string   `json:"publicKey"`
	Counter      int      `json:"counter"`
	Transports   []string `json:"transports"`
	CreatedAt    string   `json:"createdAt"`
}

WebAuthnCredential represents a registered FIDO2 credential.

type WebAuthnRegisterOptionsParams added in v0.1.3

type WebAuthnRegisterOptionsParams struct {
	PrincipalID string `json:"principalId"`
}

WebAuthnRegisterOptionsParams contains the parameters for requesting registration options.

type WebAuthnRegisterVerifyParams added in v0.1.3

type WebAuthnRegisterVerifyParams struct {
	ChallengeID string      `json:"challengeId"`
	Response    interface{} `json:"response"`
}

WebAuthnRegisterVerifyParams contains the parameters for verifying a registration response.

type WebAuthnRegistrationOptions added in v0.1.3

type WebAuthnRegistrationOptions struct {
	ChallengeID string                 `json:"challengeId"`
	Options     map[string]interface{} `json:"options"`
}

WebAuthnRegistrationOptions contains the challenge and options for WebAuthn registration.

type WebAuthnService added in v0.1.3

type WebAuthnService struct {
	// contains filtered or unexported fields
}

WebAuthnService handles FIDO2/WebAuthn credential management.

func (*WebAuthnService) DeleteCredential added in v0.1.3

func (s *WebAuthnService) DeleteCredential(ctx context.Context, id string) error

DeleteCredential removes a WebAuthn credential by ID.

func (*WebAuthnService) ListCredentials added in v0.1.3

func (s *WebAuthnService) ListCredentials(ctx context.Context, principalID string) ([]WebAuthnCredential, error)

ListCredentials lists all WebAuthn credentials for a principal.

func (*WebAuthnService) RegisterOptions added in v0.1.3

RegisterOptions requests WebAuthn registration options for a principal.

func (*WebAuthnService) RegisterVerify added in v0.1.3

RegisterVerify verifies a WebAuthn registration response.

type WebhookEndpoint

type WebhookEndpoint struct {
	ID        string   `json:"id"`
	URL       string   `json:"url"`
	Events    []string `json:"events"`
	CreatedAt string   `json:"createdAt"`
}

WebhookEndpoint represents a webhook endpoint.

type WebhookEndpointWithSecret

type WebhookEndpointWithSecret struct {
	ID        string   `json:"id"`
	URL       string   `json:"url"`
	Events    []string `json:"events"`
	CreatedAt string   `json:"createdAt"`
	Secret    string   `json:"secret"`
}

WebhookEndpointWithSecret is a webhook endpoint that includes the signing secret.

type WebhooksService

type WebhooksService struct {
	// contains filtered or unexported fields
}

WebhooksService handles webhook endpoint management.

func (*WebhooksService) Create

Create registers a new webhook endpoint.

func (*WebhooksService) Delete

func (s *WebhooksService) Delete(ctx context.Context, webhookID string) error

Delete removes a webhook endpoint.

func (*WebhooksService) List

List retrieves all webhook endpoints.

type WithdrawConsentParams added in v0.1.10

type WithdrawConsentParams struct {
	Reason              string `json:"reason"`
	RevokeGrant         bool   `json:"revokeGrant,omitempty"`
	DeleteProcessedData bool   `json:"deleteProcessedData,omitempty"`
}

WithdrawConsentParams contains the parameters for withdrawing consent.

type WithdrawConsentResponse added in v0.1.10

type WithdrawConsentResponse struct {
	RecordID     string `json:"recordId"`
	Status       string `json:"status"`
	WithdrawnAt  string `json:"withdrawnAt"`
	GrantRevoked bool   `json:"grantRevoked"`
	DataDeleted  bool   `json:"dataDeleted"`
}

WithdrawConsentResponse is the result of withdrawing consent.

Jump to

Keyboard shortcuts

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