diff --git a/README.md b/README.md index 8c6aff8..adaa136 100644 --- a/README.md +++ b/README.md @@ -108,15 +108,15 @@ client, err := elydora.NewClient(&elydora.Config{ BaseURL: "https://...", // API base URL (default: https://api.elydora.com) TTLMs: 30000, // Operation TTL in ms (default: 30000) MaxRetries: 3, // Max retries on transient failures (default: 3) - Token: "", // JWT token for authenticated requests + Token: "", // API token for authenticated requests }) ``` ### Client Methods ```go -// Update the JWT token at runtime -client.SetToken("new-jwt-token") +// Update the API token at runtime +client.SetToken("new-api-token") ``` ### Authentication @@ -128,7 +128,7 @@ reg, err := elydora.Register(baseURL, email, password, elydora.WithOrgName("Acme Corp"), ) -// Login and receive a JWT +// Login and receive a session token auth, err := elydora.Login(baseURL, email, password) // Get current authenticated user profile diff --git a/auth.go b/auth.go index c5f72f1..1a6cb9e 100644 --- a/auth.go +++ b/auth.go @@ -49,7 +49,7 @@ func Register(baseURL, email, password string, opts ...RegisterOption) (*AuthReg return &result, nil } -// Login authenticates a user and returns a JWT token. +// Login authenticates a user and returns a session token. func Login(baseURL, email, password string) (*AuthLoginResponse, error) { if baseURL == "" { baseURL = defaultBaseURL diff --git a/client.go b/client.go index e51cb15..da15b37 100644 --- a/client.go +++ b/client.go @@ -24,7 +24,7 @@ type Config struct { BaseURL string // defaults to "https://api.elydora.com" TTLMs int // defaults to 30000 MaxRetries int // defaults to 3 - Token string // JWT token for authenticated requests + Token string // API token for authenticated requests } // Client is the Elydora SDK client. @@ -172,7 +172,7 @@ func (c *Client) doPost(path string, body interface{}, result interface{}) error return c.doRequest(http.MethodPost, path, body, result) } -// SetToken sets the JWT token used for authenticated API requests. +// SetToken sets the API token used for authenticated API requests. func (c *Client) SetToken(token string) { c.token = token } diff --git a/cmd/elydora/main.go b/cmd/elydora/main.go index 1d3960c..3d54412 100644 --- a/cmd/elydora/main.go +++ b/cmd/elydora/main.go @@ -69,7 +69,7 @@ func cmdInstall(args []string) { agentID := fs.String("agent-id", "", "Agent ID (required)") privateKey := fs.String("private-key", "", "Base64url-encoded Ed25519 private key seed (required)") kid := fs.String("kid", "", "Key ID (defaults to -key-1)") - token := fs.String("token", "", "JWT token for authenticated requests (optional)") + token := fs.String("token", "", "API token for authenticated requests (optional)") baseURL := fs.String("base-url", "https://api.elydora.com", "Elydora API base URL") fs.Parse(args) diff --git a/sdk_compat_integration_test.go b/sdk_compat_integration_test.go index 91a1ef8..8596fb1 100644 --- a/sdk_compat_integration_test.go +++ b/sdk_compat_integration_test.go @@ -6,10 +6,8 @@ import ( "encoding/base64" "encoding/hex" "fmt" - "net/http" "os" "testing" - "time" elydora "github.com/Elydora-Infrastructure/Elydora-Go-SDK" ) @@ -91,8 +89,8 @@ func TestSDKCompatibilityAgainstLatestAPI(t *testing.T) { if err != nil { t.Fatalf("rotate api token failed: %v", err) } - if rotateResp.Token == "" || rotateResp.PreviousTokenGraceUntil <= 0 { - t.Fatalf("rotate response incomplete: %+v", rotateResp) + if rotateResp.Token == "" { + t.Fatalf("rotate response missing token: %+v", rotateResp) } client.SetToken(rotateResp.Token) @@ -104,23 +102,6 @@ func TestSDKCompatibilityAgainstLatestAPI(t *testing.T) { t.Fatalf("rotated token org mismatch: got %s want %s", meWithRotated.User.OrgID, login.User.OrgID) } - // Old token should still be accepted during grace window. - req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/v1/auth/me", baseURL), nil) - if err != nil { - t.Fatalf("create old token request: %v", err) - } - req.Header.Set("Authorization", "Bearer "+oldToken) - req.Header.Set("Accept", "application/json") - httpClient := &http.Client{Timeout: 20 * time.Second} - oldTokenResp, err := httpClient.Do(req) - if err != nil { - t.Fatalf("old token grace request failed: %v", err) - } - oldTokenResp.Body.Close() - if oldTokenResp.StatusCode != http.StatusOK { - t.Fatalf("old token grace expected 200, got %d", oldTokenResp.StatusCode) - } - _, err = client.RegisterAgent(&elydora.RegisterAgentRequest{ AgentID: agentID, DisplayName: "Go SDK Compat Agent", diff --git a/types.go b/types.go index 5f9b7c8..1f7e32c 100644 --- a/types.go +++ b/types.go @@ -257,10 +257,9 @@ type IssueApiTokenResponse struct { } type RotateApiTokenResponse struct { - Token string `json:"token"` - ExpiresAt *int64 `json:"expires_at"` - TokenID string `json:"token_id"` - PreviousTokenGraceUntil int64 `json:"previous_token_grace_until"` + Token string `json:"token"` + ExpiresAt *int64 `json:"expires_at"` + TokenID string `json:"token_id"` } type HealthResponse struct {