Add 7 missing SDK methods and document all exports
- Add listAgents, unfreezeAgent, deleteAgent, getMe, issueApiToken, downloadExport, health methods - Add corresponding response types to types.ts - Export new types from index.ts - Document all previously undocumented exports in README Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
8a2e34eac2
commit
cb7a6320d5
4 files changed
+141
No files matched your search
@@ -99,6 +99,12 @@ const auth = await ElydoraClient.login(baseUrl, email, password);
|
|||||||
|
|
||||||
// Set token on client
|
// Set token on client
|
||||||
client.setToken(auth.token);
|
client.setToken(auth.token);
|
||||||
|
|
||||||
|
// Get current authenticated user profile
|
||||||
|
const { user } = await client.getMe();
|
||||||
|
|
||||||
|
// Issue a new API token (with optional TTL in seconds)
|
||||||
|
const { token, expires_at } = await client.issueApiToken(3600);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Operations
|
### Operations
|
||||||
@@ -141,6 +147,15 @@ await client.freezeAgent(agentId, 'security review');
|
|||||||
|
|
||||||
// Revoke a key
|
// Revoke a key
|
||||||
await client.revokeKey(agentId, kid, 'key rotation');
|
await client.revokeKey(agentId, kid, 'key rotation');
|
||||||
|
|
||||||
|
// List all agents in the organization
|
||||||
|
const { agents } = await client.listAgents();
|
||||||
|
|
||||||
|
// Unfreeze a previously frozen agent
|
||||||
|
await client.unfreezeAgent(agentId, 'review complete');
|
||||||
|
|
||||||
|
// Delete an agent permanently
|
||||||
|
const { deleted } = await client.deleteAgent(agentId);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Audit
|
### Audit
|
||||||
@@ -173,6 +188,9 @@ const { export: exp } = await client.createExport({
|
|||||||
|
|
||||||
const { exports } = await client.listExports();
|
const { exports } = await client.listExports();
|
||||||
const { export: detail, download_url } = await client.getExport(exportId);
|
const { export: detail, download_url } = await client.getExport(exportId);
|
||||||
|
|
||||||
|
// Download export file data
|
||||||
|
const data = await client.downloadExport(exportId);
|
||||||
```
|
```
|
||||||
|
|
||||||
### JWKS
|
### JWKS
|
||||||
@@ -181,6 +199,24 @@ const { export: detail, download_url } = await client.getExport(exportId);
|
|||||||
const { keys } = await client.getJWKS();
|
const { keys } = await client.getJWKS();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Health
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Check API health (no authentication required)
|
||||||
|
const health = await client.health();
|
||||||
|
// health.status, health.version, health.protocol_version, health.timestamp
|
||||||
|
```
|
||||||
|
|
||||||
|
### Client State
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Get the current chain hash (useful for debugging/inspection)
|
||||||
|
const chainHash = client.getChainHash();
|
||||||
|
|
||||||
|
// Get the Ed25519 public key derived from the configured private key
|
||||||
|
const publicKey = client.getPublicKey();
|
||||||
|
```
|
||||||
|
|
||||||
### Crypto Utilities
|
### Crypto Utilities
|
||||||
|
|
||||||
The SDK exports low-level cryptographic primitives for advanced use:
|
The SDK exports low-level cryptographic primitives for advanced use:
|
||||||
@@ -197,6 +233,17 @@ import {
|
|||||||
} from '@elydora/sdk';
|
} from '@elydora/sdk';
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Utility Functions
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import {
|
||||||
|
uuidv7, // Generate a UUIDv7 (time-ordered, RFC 9562)
|
||||||
|
generateNonce, // Generate a 16-byte random nonce (base64url)
|
||||||
|
base64urlEncode, // Encode Buffer/Uint8Array to base64url (no padding)
|
||||||
|
base64urlDecode, // Decode base64url string to Buffer
|
||||||
|
} from '@elydora/sdk';
|
||||||
|
```
|
||||||
|
|
||||||
## Error Handling
|
## Error Handling
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import type {
|
|||||||
RegisterAgentRequest,
|
RegisterAgentRequest,
|
||||||
RegisterAgentResponse,
|
RegisterAgentResponse,
|
||||||
GetAgentResponse,
|
GetAgentResponse,
|
||||||
|
ListAgentsResponse,
|
||||||
|
UnfreezeAgentResponse,
|
||||||
|
DeleteAgentResponse,
|
||||||
SubmitOperationResponse,
|
SubmitOperationResponse,
|
||||||
GetOperationResponse,
|
GetOperationResponse,
|
||||||
VerifyOperationResponse,
|
VerifyOperationResponse,
|
||||||
@@ -16,7 +19,10 @@ import type {
|
|||||||
CreateExportResponse,
|
CreateExportResponse,
|
||||||
ListExportsResponse,
|
ListExportsResponse,
|
||||||
GetExportResponse,
|
GetExportResponse,
|
||||||
|
GetMeResponse,
|
||||||
|
IssueApiTokenResponse,
|
||||||
JWKSResponse,
|
JWKSResponse,
|
||||||
|
HealthResponse,
|
||||||
AuthRegisterResponse,
|
AuthRegisterResponse,
|
||||||
AuthLoginResponse,
|
AuthLoginResponse,
|
||||||
ErrorResponse,
|
ErrorResponse,
|
||||||
@@ -119,6 +125,18 @@ export class ElydoraClient {
|
|||||||
return handleResponse<AuthLoginResponse>(res);
|
return handleResponse<AuthLoginResponse>(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// Auth (instance methods — require token)
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
async getMe(): Promise<GetMeResponse> {
|
||||||
|
return this.request<GetMeResponse>('GET', '/v1/auth/me');
|
||||||
|
}
|
||||||
|
|
||||||
|
async issueApiToken(ttlSeconds?: number | null): Promise<IssueApiTokenResponse> {
|
||||||
|
return this.request<IssueApiTokenResponse>('POST', '/v1/auth/token', { ttl_seconds: ttlSeconds ?? null });
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Agent management
|
// Agent management
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -135,6 +153,18 @@ export class ElydoraClient {
|
|||||||
await this.request<unknown>('POST', `/v1/agents/${encodeURIComponent(agentId)}/freeze`, { reason });
|
await this.request<unknown>('POST', `/v1/agents/${encodeURIComponent(agentId)}/freeze`, { reason });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async listAgents(): Promise<ListAgentsResponse> {
|
||||||
|
return this.request<ListAgentsResponse>('GET', '/v1/agents');
|
||||||
|
}
|
||||||
|
|
||||||
|
async unfreezeAgent(agentId: string, reason: string): Promise<UnfreezeAgentResponse> {
|
||||||
|
return this.request<UnfreezeAgentResponse>('POST', `/v1/agents/${encodeURIComponent(agentId)}/unfreeze`, { reason });
|
||||||
|
}
|
||||||
|
|
||||||
|
async deleteAgent(agentId: string): Promise<DeleteAgentResponse> {
|
||||||
|
return this.request<DeleteAgentResponse>('DELETE', `/v1/agents/${encodeURIComponent(agentId)}`);
|
||||||
|
}
|
||||||
|
|
||||||
async revokeKey(agentId: string, kid: string, reason: string): Promise<void> {
|
async revokeKey(agentId: string, kid: string, reason: string): Promise<void> {
|
||||||
await this.request<unknown>('POST', `/v1/agents/${encodeURIComponent(agentId)}/revoke`, { kid, reason });
|
await this.request<unknown>('POST', `/v1/agents/${encodeURIComponent(agentId)}/revoke`, { kid, reason });
|
||||||
}
|
}
|
||||||
@@ -250,6 +280,23 @@ export class ElydoraClient {
|
|||||||
return this.request<GetExportResponse>('GET', `/v1/exports/${encodeURIComponent(exportId)}`);
|
return this.request<GetExportResponse>('GET', `/v1/exports/${encodeURIComponent(exportId)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async downloadExport(exportId: string): Promise<ArrayBuffer> {
|
||||||
|
const url = `${this.baseUrl}/v1/exports/${encodeURIComponent(exportId)}/download`;
|
||||||
|
const headers: Record<string, string> = {};
|
||||||
|
|
||||||
|
if (this.token) {
|
||||||
|
headers['Authorization'] = `Bearer ${this.token}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await fetch(url, { method: 'GET', headers });
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
return handleResponse<never>(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.arrayBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// JWKS
|
// JWKS
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -263,6 +310,19 @@ export class ElydoraClient {
|
|||||||
return handleResponse<JWKSResponse>(res);
|
return handleResponse<JWKSResponse>(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// Health
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
async health(): Promise<HealthResponse> {
|
||||||
|
const url = `${this.baseUrl}/v1/health`;
|
||||||
|
const res = await fetch(url, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: { 'Accept': 'application/json' },
|
||||||
|
});
|
||||||
|
return handleResponse<HealthResponse>(res);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Internal HTTP helpers
|
// Internal HTTP helpers
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ export type {
|
|||||||
RegisterAgentRequest,
|
RegisterAgentRequest,
|
||||||
RegisterAgentResponse,
|
RegisterAgentResponse,
|
||||||
GetAgentResponse,
|
GetAgentResponse,
|
||||||
|
ListAgentsResponse,
|
||||||
|
UnfreezeAgentResponse,
|
||||||
|
DeleteAgentResponse,
|
||||||
SubmitOperationResponse,
|
SubmitOperationResponse,
|
||||||
GetOperationResponse,
|
GetOperationResponse,
|
||||||
VerifyOperationResponse,
|
VerifyOperationResponse,
|
||||||
@@ -57,8 +60,11 @@ export type {
|
|||||||
CreateExportResponse,
|
CreateExportResponse,
|
||||||
GetExportResponse,
|
GetExportResponse,
|
||||||
ListExportsResponse,
|
ListExportsResponse,
|
||||||
|
GetMeResponse,
|
||||||
|
IssueApiTokenResponse,
|
||||||
JWK,
|
JWK,
|
||||||
JWKSResponse,
|
JWKSResponse,
|
||||||
|
HealthResponse,
|
||||||
AuthRegisterResponse,
|
AuthRegisterResponse,
|
||||||
AuthLoginResponse,
|
AuthLoginResponse,
|
||||||
ErrorResponse,
|
ErrorResponse,
|
||||||
|
|||||||
@@ -247,6 +247,34 @@ export interface ListExportsResponse {
|
|||||||
readonly exports: Export[];
|
readonly exports: Export[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ListAgentsResponse {
|
||||||
|
readonly agents: Agent[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UnfreezeAgentResponse {
|
||||||
|
readonly agent: Agent;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeleteAgentResponse {
|
||||||
|
readonly deleted: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetMeResponse {
|
||||||
|
readonly user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IssueApiTokenResponse {
|
||||||
|
readonly token: string;
|
||||||
|
readonly expires_at: number | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HealthResponse {
|
||||||
|
readonly status: string;
|
||||||
|
readonly version: string;
|
||||||
|
readonly protocol_version: string;
|
||||||
|
readonly timestamp: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface JWK {
|
export interface JWK {
|
||||||
readonly kty: string;
|
readonly kty: string;
|
||||||
readonly crv?: string;
|
readonly crv?: string;
|
||||||
|
|||||||
Reference in new issue
Block a user