@topolo/sdk 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/dist/index.cjs +258 -53
- package/dist/index.d.cts +76 -8
- package/dist/index.d.ts +76 -8
- package/dist/index.js +255 -53
- package/dist/node/credential-store.cjs +16 -5
- package/dist/node/credential-store.d.cts +3 -1
- package/dist/node/credential-store.d.ts +3 -1
- package/dist/node/credential-store.js +16 -5
- package/package.json +5 -4
- package/src/application-requirements.ts +0 -517
- package/src/applications.generated.ts +0 -1509
- package/src/auth.ts +0 -48
- package/src/client.test.ts +0 -894
- package/src/client.ts +0 -1025
- package/src/errors.ts +0 -39
- package/src/index.test.ts +0 -69
- package/src/index.ts +0 -125
- package/src/modules/crm.test.ts +0 -208
- package/src/modules/crm.ts +0 -110
- package/src/modules/identity.test.ts +0 -165
- package/src/modules/identity.ts +0 -18
- package/src/modules/p2p.test.ts +0 -540
- package/src/modules/p2p.ts +0 -448
- package/src/node/credential-store.ts +0 -378
- package/src/oauth.test.ts +0 -216
- package/src/oauth.ts +0 -138
- package/src/services.generated.ts +0 -55
- package/src/services.test.ts +0 -243
- package/src/services.ts +0 -138
- package/src/widgets.test.ts +0 -416
- package/src/widgets.ts +0 -362
package/src/auth.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auth credential types used by the SDK.
|
|
3
|
-
*
|
|
4
|
-
* Phase 1 supports two modes:
|
|
5
|
-
* - `api_key`: a single platform API key (service-scoped at issuance).
|
|
6
|
-
* Preferred for long-lived agent installs.
|
|
7
|
-
* - `access_token`: a short-lived JWT from the interactive login flow.
|
|
8
|
-
* Used by TopoloCli after `topolo auth login`.
|
|
9
|
-
*
|
|
10
|
-
* Phase 2 will add OAuth access tokens issued by the authorization-code +
|
|
11
|
-
* PKCE flow in TopoloAuth. Those will plug in as a third variant.
|
|
12
|
-
*/
|
|
13
|
-
export type TopoloCredential =
|
|
14
|
-
| { kind: 'api_key'; apiKey: string }
|
|
15
|
-
| { kind: 'access_token'; accessToken: string; refreshToken?: string; expiresAt?: number };
|
|
16
|
-
|
|
17
|
-
export interface AgentIdentity {
|
|
18
|
-
/** Display name of the agent or tool making requests. Included in audit headers. */
|
|
19
|
-
clientName: string;
|
|
20
|
-
/** Semver of the client. Included in audit headers. */
|
|
21
|
-
clientVersion: string;
|
|
22
|
-
/**
|
|
23
|
-
* Optional agent-assigned label (e.g. "claude-code", "codex-cli") used for
|
|
24
|
-
* multi-tenant audit attribution when the client is used by another agent.
|
|
25
|
-
*/
|
|
26
|
-
agentName?: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function applyAuthHeaders(headers: Headers, credential: TopoloCredential): void {
|
|
30
|
-
if (credential.kind === 'api_key') {
|
|
31
|
-
headers.set('X-Api-Key', credential.apiKey);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
headers.set('Authorization', `Bearer ${credential.accessToken}`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function applyAuditHeaders(headers: Headers, agent: AgentIdentity, requestId: string): void {
|
|
38
|
-
headers.set('X-Topolo-Client', `${agent.clientName}/${agent.clientVersion}`);
|
|
39
|
-
if (agent.agentName) headers.set('X-Topolo-Agent', agent.agentName);
|
|
40
|
-
headers.set('X-Topolo-Request-Id', requestId);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function generateRequestId(): string {
|
|
44
|
-
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
45
|
-
return crypto.randomUUID();
|
|
46
|
-
}
|
|
47
|
-
return `req_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
48
|
-
}
|