@1claw/sdk 0.2.0
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/LICENSE +133 -0
- package/README.md +246 -0
- package/dist/access.d.ts +35 -0
- package/dist/access.d.ts.map +1 -0
- package/dist/access.js +52 -0
- package/dist/access.js.map +1 -0
- package/dist/agents.d.ts +41 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +61 -0
- package/dist/agents.js.map +1 -0
- package/dist/api-keys.d.ts +20 -0
- package/dist/api-keys.d.ts.map +1 -0
- package/dist/api-keys.js +25 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/approvals.d.ts +45 -0
- package/dist/approvals.d.ts.map +1 -0
- package/dist/approvals.js +76 -0
- package/dist/approvals.js.map +1 -0
- package/dist/audit.d.ts +23 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +41 -0
- package/dist/audit.js.map +1 -0
- package/dist/auth.d.ts +42 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +79 -0
- package/dist/auth.js.map +1 -0
- package/dist/billing.d.ts +17 -0
- package/dist/billing.d.ts.map +1 -0
- package/dist/billing.js +22 -0
- package/dist/billing.js.map +1 -0
- package/dist/chains.d.ts +25 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/chains.js +39 -0
- package/dist/chains.js.map +1 -0
- package/dist/client.d.ts +99 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +116 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +56 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +115 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +42 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +145 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/handler.d.ts +40 -0
- package/dist/mcp/handler.d.ts.map +1 -0
- package/dist/mcp/handler.js +216 -0
- package/dist/mcp/handler.js.map +1 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/tools.d.ts +29 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +236 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/org.d.ts +16 -0
- package/dist/org.d.ts.map +1 -0
- package/dist/org.js +21 -0
- package/dist/org.js.map +1 -0
- package/dist/secrets.d.ts +42 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +48 -0
- package/dist/secrets.js.map +1 -0
- package/dist/sharing.d.ts +59 -0
- package/dist/sharing.d.ts.map +1 -0
- package/dist/sharing.js +69 -0
- package/dist/sharing.js.map +1 -0
- package/dist/types.d.ts +446 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/vault.d.ts +18 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/vault.js +30 -0
- package/dist/vault.js.map +1 -0
- package/dist/x402.d.ts +40 -0
- package/dist/x402.d.ts.map +1 -0
- package/dist/x402.js +129 -0
- package/dist/x402.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { HttpClient } from "./http";
|
|
2
|
+
import type { ApprovalRequest, CreateApprovalRequest, ApprovalListResponse, OneclawResponse } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Approvals resource — human-in-the-loop approval workflows.
|
|
5
|
+
*
|
|
6
|
+
* Agents can request human approval before accessing sensitive secrets.
|
|
7
|
+
* Humans review, approve, or deny requests through the dashboard or API.
|
|
8
|
+
*
|
|
9
|
+
* **Status**: These endpoints are planned for an upcoming API release.
|
|
10
|
+
* The SDK methods are provided for forward compatibility and will work
|
|
11
|
+
* once the backend endpoints are deployed.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ApprovalsResource {
|
|
14
|
+
private readonly http;
|
|
15
|
+
constructor(http: HttpClient);
|
|
16
|
+
/**
|
|
17
|
+
* Request human approval to access a secret.
|
|
18
|
+
* Typically called by an agent that encounters a gated secret.
|
|
19
|
+
*/
|
|
20
|
+
request(options: CreateApprovalRequest): Promise<OneclawResponse<ApprovalRequest>>;
|
|
21
|
+
/**
|
|
22
|
+
* List approval requests, optionally filtered by status.
|
|
23
|
+
* @param status - "pending", "approved", or "denied"
|
|
24
|
+
*/
|
|
25
|
+
list(status?: "pending" | "approved" | "denied"): Promise<OneclawResponse<ApprovalListResponse>>;
|
|
26
|
+
/** Approve a pending request. */
|
|
27
|
+
approve(requestId: string): Promise<OneclawResponse<ApprovalRequest>>;
|
|
28
|
+
/** Deny a pending request with an optional reason. */
|
|
29
|
+
deny(requestId: string, reason?: string): Promise<OneclawResponse<ApprovalRequest>>;
|
|
30
|
+
/**
|
|
31
|
+
* Poll for the status of a specific approval request.
|
|
32
|
+
* Returns the current state — useful for agents waiting on approval.
|
|
33
|
+
*/
|
|
34
|
+
check(requestId: string): Promise<OneclawResponse<ApprovalRequest>>;
|
|
35
|
+
/**
|
|
36
|
+
* Subscribe to approval events via polling.
|
|
37
|
+
* Calls the callback every `intervalMs` with new/changed approvals.
|
|
38
|
+
* Returns an unsubscribe function.
|
|
39
|
+
*/
|
|
40
|
+
subscribe(callback: (approvals: ApprovalRequest[]) => void, options?: {
|
|
41
|
+
status?: "pending" | "approved" | "denied";
|
|
42
|
+
intervalMs?: number;
|
|
43
|
+
}): () => void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=approvals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../src/approvals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EACR,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;GASG;AACH,qBAAa,iBAAiB;IACd,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;OAGG;IACG,OAAO,CACT,OAAO,EAAE,qBAAqB,GAC/B,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;IAM5C;;;OAGG;IACG,IAAI,CACN,MAAM,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,GAC3C,OAAO,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAMjD,iCAAiC;IAC3B,OAAO,CACT,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;IAO5C,sDAAsD;IAChD,IAAI,CACN,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;IAQ5C;;;OAGG;IACG,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;IAOzE;;;;OAIG;IACH,SAAS,CACL,QAAQ,EAAE,CAAC,SAAS,EAAE,eAAe,EAAE,KAAK,IAAI,EAChD,OAAO,GAAE;QACL,MAAM,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;QAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;KAClB,GACP,MAAM,IAAI;CAuBhB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approvals resource — human-in-the-loop approval workflows.
|
|
3
|
+
*
|
|
4
|
+
* Agents can request human approval before accessing sensitive secrets.
|
|
5
|
+
* Humans review, approve, or deny requests through the dashboard or API.
|
|
6
|
+
*
|
|
7
|
+
* **Status**: These endpoints are planned for an upcoming API release.
|
|
8
|
+
* The SDK methods are provided for forward compatibility and will work
|
|
9
|
+
* once the backend endpoints are deployed.
|
|
10
|
+
*/
|
|
11
|
+
export class ApprovalsResource {
|
|
12
|
+
constructor(http) {
|
|
13
|
+
this.http = http;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Request human approval to access a secret.
|
|
17
|
+
* Typically called by an agent that encounters a gated secret.
|
|
18
|
+
*/
|
|
19
|
+
async request(options) {
|
|
20
|
+
return this.http.request("POST", "/v1/approvals", {
|
|
21
|
+
body: options,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* List approval requests, optionally filtered by status.
|
|
26
|
+
* @param status - "pending", "approved", or "denied"
|
|
27
|
+
*/
|
|
28
|
+
async list(status) {
|
|
29
|
+
return this.http.request("GET", "/v1/approvals", {
|
|
30
|
+
query: status ? { status } : undefined,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** Approve a pending request. */
|
|
34
|
+
async approve(requestId) {
|
|
35
|
+
return this.http.request("POST", `/v1/approvals/${requestId}/approve`);
|
|
36
|
+
}
|
|
37
|
+
/** Deny a pending request with an optional reason. */
|
|
38
|
+
async deny(requestId, reason) {
|
|
39
|
+
return this.http.request("POST", `/v1/approvals/${requestId}/deny`, { body: reason ? { reason } : undefined });
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Poll for the status of a specific approval request.
|
|
43
|
+
* Returns the current state — useful for agents waiting on approval.
|
|
44
|
+
*/
|
|
45
|
+
async check(requestId) {
|
|
46
|
+
return this.http.request("GET", `/v1/approvals/${requestId}`);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Subscribe to approval events via polling.
|
|
50
|
+
* Calls the callback every `intervalMs` with new/changed approvals.
|
|
51
|
+
* Returns an unsubscribe function.
|
|
52
|
+
*/
|
|
53
|
+
subscribe(callback, options = {}) {
|
|
54
|
+
const interval = options.intervalMs ?? 3000;
|
|
55
|
+
let active = true;
|
|
56
|
+
const poll = async () => {
|
|
57
|
+
while (active) {
|
|
58
|
+
try {
|
|
59
|
+
const res = await this.list(options.status);
|
|
60
|
+
if (res.data?.approvals) {
|
|
61
|
+
callback(res.data.approvals);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
/* silently retry */
|
|
66
|
+
}
|
|
67
|
+
await new Promise((r) => setTimeout(r, interval));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
poll();
|
|
71
|
+
return () => {
|
|
72
|
+
active = false;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=approvals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approvals.js","sourceRoot":"","sources":["../src/approvals.ts"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH,MAAM,OAAO,iBAAiB;IAC1B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;OAGG;IACH,KAAK,CAAC,OAAO,CACT,OAA8B;QAE9B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAkB,MAAM,EAAE,eAAe,EAAE;YAC/D,IAAI,EAAE,OAAO;SAChB,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI,CACN,MAA0C;QAE1C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAuB,KAAK,EAAE,eAAe,EAAE;YACnE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS;SACzC,CAAC,CAAC;IACP,CAAC;IAED,iCAAiC;IACjC,KAAK,CAAC,OAAO,CACT,SAAiB;QAEjB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,MAAM,EACN,iBAAiB,SAAS,UAAU,CACvC,CAAC;IACN,CAAC;IAED,sDAAsD;IACtD,KAAK,CAAC,IAAI,CACN,SAAiB,EACjB,MAAe;QAEf,OAAO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awResponse } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Audit resource — query the immutable audit log of all vault operations.
|
|
5
|
+
*/
|
|
6
|
+
export declare class AuditResource {
|
|
7
|
+
private readonly http;
|
|
8
|
+
constructor(http: HttpClient);
|
|
9
|
+
/**
|
|
10
|
+
* Query audit events with optional filters.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const events = await client.audit.query({
|
|
15
|
+
* resource_id: vaultId,
|
|
16
|
+
* action: "secret.read",
|
|
17
|
+
* limit: 25,
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
query(filters?: AuditQuery): Promise<OneclawResponse<AuditEventsResponse>>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEhF;;GAEG;AACH,qBAAa,aAAa;IACV,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;OAWG;IACG,KAAK,CACP,OAAO,GAAE,UAAe,GACzB,OAAO,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;CAkBnD"}
|
package/dist/audit.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit resource — query the immutable audit log of all vault operations.
|
|
3
|
+
*/
|
|
4
|
+
export class AuditResource {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Query audit events with optional filters.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const events = await client.audit.query({
|
|
14
|
+
* resource_id: vaultId,
|
|
15
|
+
* action: "secret.read",
|
|
16
|
+
* limit: 25,
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
async query(filters = {}) {
|
|
21
|
+
const query = {};
|
|
22
|
+
if (filters.resource_id)
|
|
23
|
+
query.resource_id = filters.resource_id;
|
|
24
|
+
if (filters.actor_id)
|
|
25
|
+
query.actor_id = filters.actor_id;
|
|
26
|
+
if (filters.action)
|
|
27
|
+
query.action = filters.action;
|
|
28
|
+
if (filters.from)
|
|
29
|
+
query.from = filters.from;
|
|
30
|
+
if (filters.to)
|
|
31
|
+
query.to = filters.to;
|
|
32
|
+
if (filters.limit !== undefined)
|
|
33
|
+
query.limit = filters.limit;
|
|
34
|
+
if (filters.offset !== undefined)
|
|
35
|
+
query.offset = filters.offset;
|
|
36
|
+
return this.http.request("GET", "/v1/audit/events", {
|
|
37
|
+
query,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,OAAO,aAAa;IACtB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,KAAK,CACP,UAAsB,EAAE;QAExB,MAAM,KAAK,GAAgD,EAAE,CAAC;QAC9D,IAAI,OAAO,CAAC,WAAW;YAAE,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACjE,IAAI,OAAO,CAAC,QAAQ;YAAE,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACxD,IAAI,OAAO,CAAC,MAAM;YAAE,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAClD,IAAI,OAAO,CAAC,IAAI;YAAE,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC5C,IAAI,OAAO,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;QACtC,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;YAAE,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC7D,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;YAAE,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAEhE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,KAAK,EACL,kBAAkB,EAClB;YACI,KAAK;SACR,CACJ,CAAC;IACN,CAAC;CACJ"}
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { HttpClient } from "./http";
|
|
2
|
+
import type { TokenRequest, AgentTokenRequest, UserApiKeyTokenRequest, GoogleAuthRequest, SignupRequest, ChangePasswordRequest, TokenResponse, OneclawResponse } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Auth resource — authenticate users and agents, manage sessions.
|
|
5
|
+
* Successful authentication automatically stores the JWT on the client
|
|
6
|
+
* so subsequent requests are authenticated.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AuthResource {
|
|
9
|
+
private readonly http;
|
|
10
|
+
constructor(http: HttpClient);
|
|
11
|
+
/**
|
|
12
|
+
* Authenticate with email and password.
|
|
13
|
+
* Stores the resulting JWT for subsequent requests.
|
|
14
|
+
*/
|
|
15
|
+
login(credentials: TokenRequest): Promise<OneclawResponse<TokenResponse>>;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new account with email and password.
|
|
18
|
+
* Creates a new organization, returns a JWT, and automatically
|
|
19
|
+
* claims any pending email-based secret shares.
|
|
20
|
+
*/
|
|
21
|
+
signup(credentials: SignupRequest): Promise<OneclawResponse<TokenResponse>>;
|
|
22
|
+
/**
|
|
23
|
+
* Authenticate an agent using its ID and API key.
|
|
24
|
+
* Stores the resulting JWT for subsequent requests.
|
|
25
|
+
*/
|
|
26
|
+
agentToken(credentials: AgentTokenRequest): Promise<OneclawResponse<TokenResponse>>;
|
|
27
|
+
/**
|
|
28
|
+
* Authenticate with a user API key (prefix `ocv_`).
|
|
29
|
+
* Stores the resulting JWT for subsequent requests.
|
|
30
|
+
*/
|
|
31
|
+
apiKeyToken(credentials: UserApiKeyTokenRequest): Promise<OneclawResponse<TokenResponse>>;
|
|
32
|
+
/**
|
|
33
|
+
* Authenticate with a Google ID token (OAuth2 flow).
|
|
34
|
+
* Stores the resulting JWT for subsequent requests.
|
|
35
|
+
*/
|
|
36
|
+
google(credentials: GoogleAuthRequest): Promise<OneclawResponse<TokenResponse>>;
|
|
37
|
+
/** Change the current user's password. */
|
|
38
|
+
changePassword(request: ChangePasswordRequest): Promise<OneclawResponse<void>>;
|
|
39
|
+
/** Revoke the current session token. */
|
|
40
|
+
logout(): Promise<OneclawResponse<void>>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EACR,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,aAAa,EACb,eAAe,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;GAIG;AACH,qBAAa,YAAY;IACT,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;OAGG;IACG,KAAK,CACP,WAAW,EAAE,YAAY,GAC1B,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IAY1C;;;;OAIG;IACG,MAAM,CACR,WAAW,EAAE,aAAa,GAC3B,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IAY1C;;;OAGG;IACG,UAAU,CACZ,WAAW,EAAE,iBAAiB,GAC/B,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IAY1C;;;OAGG;IACG,WAAW,CACb,WAAW,EAAE,sBAAsB,GACpC,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IAY1C;;;OAGG;IACG,MAAM,CACR,WAAW,EAAE,iBAAiB,GAC/B,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IAY1C,0CAA0C;IACpC,cAAc,CAChB,OAAO,EAAE,qBAAqB,GAC/B,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAMjC,wCAAwC;IAClC,MAAM,IAAI,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;CAKjD"}
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth resource — authenticate users and agents, manage sessions.
|
|
3
|
+
* Successful authentication automatically stores the JWT on the client
|
|
4
|
+
* so subsequent requests are authenticated.
|
|
5
|
+
*/
|
|
6
|
+
export class AuthResource {
|
|
7
|
+
constructor(http) {
|
|
8
|
+
this.http = http;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Authenticate with email and password.
|
|
12
|
+
* Stores the resulting JWT for subsequent requests.
|
|
13
|
+
*/
|
|
14
|
+
async login(credentials) {
|
|
15
|
+
const res = await this.http.request("POST", "/v1/auth/token", { body: credentials });
|
|
16
|
+
if (res.data?.access_token) {
|
|
17
|
+
this.http.setToken(res.data.access_token);
|
|
18
|
+
}
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a new account with email and password.
|
|
23
|
+
* Creates a new organization, returns a JWT, and automatically
|
|
24
|
+
* claims any pending email-based secret shares.
|
|
25
|
+
*/
|
|
26
|
+
async signup(credentials) {
|
|
27
|
+
const res = await this.http.request("POST", "/v1/auth/signup", { body: credentials });
|
|
28
|
+
if (res.data?.access_token) {
|
|
29
|
+
this.http.setToken(res.data.access_token);
|
|
30
|
+
}
|
|
31
|
+
return res;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Authenticate an agent using its ID and API key.
|
|
35
|
+
* Stores the resulting JWT for subsequent requests.
|
|
36
|
+
*/
|
|
37
|
+
async agentToken(credentials) {
|
|
38
|
+
const res = await this.http.request("POST", "/v1/auth/agent-token", { body: credentials });
|
|
39
|
+
if (res.data?.access_token) {
|
|
40
|
+
this.http.setToken(res.data.access_token);
|
|
41
|
+
}
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Authenticate with a user API key (prefix `ocv_`).
|
|
46
|
+
* Stores the resulting JWT for subsequent requests.
|
|
47
|
+
*/
|
|
48
|
+
async apiKeyToken(credentials) {
|
|
49
|
+
const res = await this.http.request("POST", "/v1/auth/api-key-token", { body: credentials });
|
|
50
|
+
if (res.data?.access_token) {
|
|
51
|
+
this.http.setToken(res.data.access_token);
|
|
52
|
+
}
|
|
53
|
+
return res;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Authenticate with a Google ID token (OAuth2 flow).
|
|
57
|
+
* Stores the resulting JWT for subsequent requests.
|
|
58
|
+
*/
|
|
59
|
+
async google(credentials) {
|
|
60
|
+
const res = await this.http.request("POST", "/v1/auth/google", { body: credentials });
|
|
61
|
+
if (res.data?.access_token) {
|
|
62
|
+
this.http.setToken(res.data.access_token);
|
|
63
|
+
}
|
|
64
|
+
return res;
|
|
65
|
+
}
|
|
66
|
+
/** Change the current user's password. */
|
|
67
|
+
async changePassword(request) {
|
|
68
|
+
return this.http.request("POST", "/v1/auth/change-password", {
|
|
69
|
+
body: request,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** Revoke the current session token. */
|
|
73
|
+
async logout() {
|
|
74
|
+
const res = await this.http.request("DELETE", "/v1/auth/token");
|
|
75
|
+
this.http.setToken("");
|
|
76
|
+
return res;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,MAAM,OAAO,YAAY;IACrB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;OAGG;IACH,KAAK,CAAC,KAAK,CACP,WAAyB;QAEzB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAC/B,MAAM,EACN,gBAAgB,EAChB,EAAE,IAAI,EAAE,WAAW,EAAE,CACxB,CAAC;QACF,IAAI,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CACR,WAA0B;QAE1B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAC/B,MAAM,EACN,iBAAiB,EACjB,EAAE,IAAI,EAAE,WAAW,EAAE,CACxB,CAAC;QACF,IAAI,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU,CACZ,WAA8B;QAE9B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAC/B,MAAM,EACN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AI,CAAC,IAAI,CAAC,OAAO,CAAO,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QACtE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACvB,OAAO,GAAG,CAAC;IACf,CAAC;CACJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HttpClient } from "./http";
|
|
2
|
+
import type { UsageSummaryResponse, UsageHistoryResponse, OneclawResponse } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Billing resource — view API usage summaries and per-request history.
|
|
5
|
+
*/
|
|
6
|
+
export declare class BillingResource {
|
|
7
|
+
private readonly http;
|
|
8
|
+
constructor(http: HttpClient);
|
|
9
|
+
/** Get the current month's usage summary (free tier remaining, costs). */
|
|
10
|
+
usage(): Promise<OneclawResponse<UsageSummaryResponse>>;
|
|
11
|
+
/**
|
|
12
|
+
* Get per-request usage history.
|
|
13
|
+
* @param limit Maximum number of events to return (1–200, default 50).
|
|
14
|
+
*/
|
|
15
|
+
history(limit?: number): Promise<OneclawResponse<UsageHistoryResponse>>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=billing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../src/billing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EACR,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EAClB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,eAAe;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,0EAA0E;IACpE,KAAK,IAAI,OAAO,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAO7D;;;OAGG;IACG,OAAO,CACT,KAAK,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC;CASpD"}
|
package/dist/billing.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Billing resource — view API usage summaries and per-request history.
|
|
3
|
+
*/
|
|
4
|
+
export class BillingResource {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
/** Get the current month's usage summary (free tier remaining, costs). */
|
|
9
|
+
async usage() {
|
|
10
|
+
return this.http.request("GET", "/v1/billing/usage");
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get per-request usage history.
|
|
14
|
+
* @param limit Maximum number of events to return (1–200, default 50).
|
|
15
|
+
*/
|
|
16
|
+
async history(limit) {
|
|
17
|
+
return this.http.request("GET", "/v1/billing/history", {
|
|
18
|
+
query: limit !== undefined ? { limit } : undefined,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=billing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../src/billing.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,OAAO,eAAe;IACxB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,0EAA0E;IAC1E,KAAK,CAAC,KAAK;QACP,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,KAAK,EACL,mBAAmB,CACtB,CAAC;IACN,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CACT,KAAc;QAEd,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,KAAK,EACL,qBAAqB,EACrB;YACI,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS;SACrD,CACJ,CAAC;IACN,CAAC;CACJ"}
|
package/dist/chains.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HttpClient } from "./http";
|
|
2
|
+
import type { ChainResponse, ChainListResponse, CreateChainRequest, UpdateChainRequest, OneclawResponse } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Chains resource — list supported blockchains and manage chain configuration.
|
|
5
|
+
*
|
|
6
|
+
* Public endpoints let any authenticated user list enabled chains.
|
|
7
|
+
* Admin endpoints allow adding, updating (e.g. setting an RPC URL), and removing chains.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ChainsResource {
|
|
10
|
+
private readonly http;
|
|
11
|
+
constructor(http: HttpClient);
|
|
12
|
+
/** List all enabled chains. */
|
|
13
|
+
list(): Promise<OneclawResponse<ChainListResponse>>;
|
|
14
|
+
/** Get a chain by name (e.g. "base") or numeric chain ID (e.g. "8453"). */
|
|
15
|
+
get(identifier: string): Promise<OneclawResponse<ChainResponse>>;
|
|
16
|
+
/** List all chains including disabled ones (admin). */
|
|
17
|
+
adminList(): Promise<OneclawResponse<ChainListResponse>>;
|
|
18
|
+
/** Add a new chain to the registry (admin). */
|
|
19
|
+
create(chain: CreateChainRequest): Promise<OneclawResponse<ChainResponse>>;
|
|
20
|
+
/** Update chain configuration, e.g. set an RPC URL (admin). */
|
|
21
|
+
update(chainId: string, update: UpdateChainRequest): Promise<OneclawResponse<ChainResponse>>;
|
|
22
|
+
/** Remove a chain from the registry (admin). */
|
|
23
|
+
delete(chainId: string): Promise<OneclawResponse<void>>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=chains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EACR,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,qBAAa,cAAc;IACX,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,+BAA+B;IACzB,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;IAIzD,2EAA2E;IACrE,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IAStE,uDAAuD;IACjD,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;IAO9D,+CAA+C;IACzC,MAAM,CACR,KAAK,EAAE,kBAAkB,GAC1B,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IAM1C,+DAA+D;IACzD,MAAM,CACR,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,kBAAkB,GAC3B,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;IAQ1C,gDAAgD;IAC1C,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;CAMhE"}
|
package/dist/chains.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chains resource — list supported blockchains and manage chain configuration.
|
|
3
|
+
*
|
|
4
|
+
* Public endpoints let any authenticated user list enabled chains.
|
|
5
|
+
* Admin endpoints allow adding, updating (e.g. setting an RPC URL), and removing chains.
|
|
6
|
+
*/
|
|
7
|
+
export class ChainsResource {
|
|
8
|
+
constructor(http) {
|
|
9
|
+
this.http = http;
|
|
10
|
+
}
|
|
11
|
+
/** List all enabled chains. */
|
|
12
|
+
async list() {
|
|
13
|
+
return this.http.request("GET", "/v1/chains");
|
|
14
|
+
}
|
|
15
|
+
/** Get a chain by name (e.g. "base") or numeric chain ID (e.g. "8453"). */
|
|
16
|
+
async get(identifier) {
|
|
17
|
+
return this.http.request("GET", `/v1/chains/${identifier}`);
|
|
18
|
+
}
|
|
19
|
+
// ── Admin ──────────────────────────────────────────────────────
|
|
20
|
+
/** List all chains including disabled ones (admin). */
|
|
21
|
+
async adminList() {
|
|
22
|
+
return this.http.request("GET", "/v1/admin/chains");
|
|
23
|
+
}
|
|
24
|
+
/** Add a new chain to the registry (admin). */
|
|
25
|
+
async create(chain) {
|
|
26
|
+
return this.http.request("POST", "/v1/admin/chains", {
|
|
27
|
+
body: chain,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** Update chain configuration, e.g. set an RPC URL (admin). */
|
|
31
|
+
async update(chainId, update) {
|
|
32
|
+
return this.http.request("PUT", `/v1/admin/chains/${chainId}`, { body: update });
|
|
33
|
+
}
|
|
34
|
+
/** Remove a chain from the registry (admin). */
|
|
35
|
+
async delete(chainId) {
|
|
36
|
+
return this.http.request("DELETE", `/v1/admin/chains/${chainId}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=chains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACvB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,+BAA+B;IAC/B,KAAK,CAAC,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAoB,KAAK,EAAE,YAAY,CAAC,CAAC;IACrE,CAAC;IAED,2EAA2E;IAC3E,KAAK,CAAC,GAAG,CAAC,UAAkB;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,KAAK,EACL,cAAc,UAAU,EAAE,CAC7B,CAAC;IACN,CAAC;IAED,kEAAkE;IAElE,uDAAuD;IACvD,KAAK,CAAC,SAAS;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,KAAK,EACL,kBAAkB,CACrB,CAAC;IACN,CAAC;IAED,+CAA+C;IAC/C,KAAK,CAAC,MAAM,CACR,KAAyB;QAEzB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAgB,MAAM,EAAE,kBAAkB,EAAE;YAChE,IAAI,EAAE,KAAK;SACd,CAAC,CAAC;IACP,CAAC;IAED,+DAA+D;IAC/D,KAAK,CAAC,MAAM,CACR,OAAe,EACf,MAA0B;QAE1B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,KAAK,EACL,oBAAoB,OAAO,EAAE,EAC7B,EAAE,IAAI,EAAE,MAAM,EAAE,CACnB,CAAC;IACN,CAAC;IAED,gDAAgD;IAChD,KAAK,CAAC,MAAM,CAAC,OAAe;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CACpB,QAAQ,EACR,oBAAoB,OAAO,EAAE,CAChC,CAAC;IACN,CAAC;CACJ"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { OneclawClientConfig } from "./types";
|
|
2
|
+
import { VaultResource } from "./vault";
|
|
3
|
+
import { SecretsResource } from "./secrets";
|
|
4
|
+
import { AccessResource } from "./access";
|
|
5
|
+
import { AgentsResource } from "./agents";
|
|
6
|
+
import { SharingResource } from "./sharing";
|
|
7
|
+
import { ApprovalsResource } from "./approvals";
|
|
8
|
+
import { BillingResource } from "./billing";
|
|
9
|
+
import { AuditResource } from "./audit";
|
|
10
|
+
import { OrgResource } from "./org";
|
|
11
|
+
import { AuthResource } from "./auth";
|
|
12
|
+
import { ApiKeysResource } from "./api-keys";
|
|
13
|
+
import { ChainsResource } from "./chains";
|
|
14
|
+
import { X402Resource } from "./x402";
|
|
15
|
+
/**
|
|
16
|
+
* The main 1Claw SDK client. All API resources are exposed as
|
|
17
|
+
* namespaced properties for discoverability and tree-shaking.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { createClient } from "@1claw/sdk";
|
|
22
|
+
*
|
|
23
|
+
* const client = createClient({
|
|
24
|
+
* baseUrl: "https://api.1claw.xyz",
|
|
25
|
+
* apiKey: "ocv_...",
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // Authenticate (exchanges API key for a JWT)
|
|
29
|
+
* await client.auth.apiKeyToken({ api_key: "ocv_..." });
|
|
30
|
+
*
|
|
31
|
+
* // Use resources
|
|
32
|
+
* const vaults = await client.vault.list();
|
|
33
|
+
* const secret = await client.secrets.get(vaultId, "my-key");
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class OneclawClient {
|
|
37
|
+
private readonly http;
|
|
38
|
+
/** Vault management — create, list, get, delete vaults. */
|
|
39
|
+
readonly vault: VaultResource;
|
|
40
|
+
/** Secret management — store, retrieve, list, rotate, delete secrets. */
|
|
41
|
+
readonly secrets: SecretsResource;
|
|
42
|
+
/** Access control — grant/revoke policies for humans and agents. */
|
|
43
|
+
readonly access: AccessResource;
|
|
44
|
+
/** Agent management — register, update, delete agents and rotate keys. */
|
|
45
|
+
readonly agents: AgentsResource;
|
|
46
|
+
/** Secret sharing — create and manage time-limited share links. */
|
|
47
|
+
readonly sharing: SharingResource;
|
|
48
|
+
/** Human-in-the-loop approvals — request, review, approve/deny. */
|
|
49
|
+
readonly approvals: ApprovalsResource;
|
|
50
|
+
/** Billing and usage — view usage summaries and per-request history. */
|
|
51
|
+
readonly billing: BillingResource;
|
|
52
|
+
/** Audit log — query the immutable audit trail. */
|
|
53
|
+
readonly audit: AuditResource;
|
|
54
|
+
/** Organization — manage members and roles. */
|
|
55
|
+
readonly org: OrgResource;
|
|
56
|
+
/** Authentication — login, agent auth, API key auth, Google OAuth. */
|
|
57
|
+
readonly auth: AuthResource;
|
|
58
|
+
/** API keys — create, list, and revoke personal API keys. */
|
|
59
|
+
readonly apiKeys: ApiKeysResource;
|
|
60
|
+
/** Supported blockchains — list chains and manage RPC configuration. */
|
|
61
|
+
readonly chains: ChainsResource;
|
|
62
|
+
/** x402 payment protocol — inspect, pay, and verify micropayments. */
|
|
63
|
+
readonly x402: X402Resource;
|
|
64
|
+
constructor(config: OneclawClientConfig);
|
|
65
|
+
/**
|
|
66
|
+
* When an API key is provided without a pre-existing token, lazily
|
|
67
|
+
* exchange it for a JWT on construction. This is async but fires
|
|
68
|
+
* without blocking the constructor — the first actual request
|
|
69
|
+
* will await token resolution.
|
|
70
|
+
*/
|
|
71
|
+
private autoAuthenticate;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Factory function to create a new 1Claw SDK client.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* // User with API key
|
|
79
|
+
* const client = createClient({
|
|
80
|
+
* baseUrl: "https://api.1claw.xyz",
|
|
81
|
+
* apiKey: "ocv_...",
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* // Agent with API key
|
|
85
|
+
* const agent = createClient({
|
|
86
|
+
* baseUrl: "https://api.1claw.xyz",
|
|
87
|
+
* apiKey: "ocv_...",
|
|
88
|
+
* agentId: "agent-uuid",
|
|
89
|
+
* });
|
|
90
|
+
*
|
|
91
|
+
* // Pre-authenticated with JWT
|
|
92
|
+
* const authed = createClient({
|
|
93
|
+
* baseUrl: "https://api.1claw.xyz",
|
|
94
|
+
* token: "eyJ...",
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function createClient(config: OneclawClientConfig): OneclawClient;
|
|
99
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1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