@1claw/sdk 0.59.5 → 0.59.6
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 +24 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @1claw/sdk (v0.59.4)
|
|
2
2
|
|
|
3
|
+
> ⭐ **Star [1clawAI/agent-templates](https://github.com/1clawAI/agent-templates)** — ready-to-run agent templates wired to 1Claw. It is our single starred repo.
|
|
4
|
+
|
|
3
5
|
TypeScript/JavaScript client for the 1Claw Vault API.
|
|
4
6
|
|
|
5
7
|
This is the official SDK for Node.js, Next.js, and browser apps that call 1Claw over HTTP. It covers vaults, secrets, agents, policies, treasury, Intents API signing, execution bindings, platform apps, billing, and x402 payments. Types are generated from the OpenAPI spec, so request shapes stay in sync with the API.
|
|
@@ -20,7 +22,7 @@ npm install @1claw/sdk
|
|
|
20
22
|
import { createClient } from "@1claw/sdk";
|
|
21
23
|
|
|
22
24
|
const client = createClient({
|
|
23
|
-
baseUrl: "https://api.1claw.
|
|
25
|
+
baseUrl: "https://api.1claw.co",
|
|
24
26
|
apiKey: "ocv_...", // auto-exchanges for a JWT
|
|
25
27
|
});
|
|
26
28
|
|
|
@@ -38,7 +40,7 @@ const secret = await client.secrets.get("vault-id", "OPENAI_KEY");
|
|
|
38
40
|
console.log(secret.data?.value);
|
|
39
41
|
```
|
|
40
42
|
|
|
41
|
-
**API contract:** This SDK is built from the **OpenAPI 3.1** spec. The canonical spec is published as [@1claw/openapi-spec](https://www.npmjs.com/package/@1claw/openapi-spec) (YAML/JSON). Types are generated with `npm run generate` (`openapi-typescript ../openapi-spec/openapi.yaml`). Run `generate` after spec changes, then `npm run build`. Shapes such as `LlmTokenBillingStatus` (including optional `credit_balance` and `billing_cycle_usage.metered_lines`) come from the generated `api-types.ts`. For a full endpoint list, see the [API reference](https://docs.1claw.
|
|
43
|
+
**API contract:** This SDK is built from the **OpenAPI 3.1** spec. The canonical spec is published as [@1claw/openapi-spec](https://www.npmjs.com/package/@1claw/openapi-spec) (YAML/JSON). Types are generated with `npm run generate` (`openapi-typescript ../openapi-spec/openapi.yaml`). Run `generate` after spec changes, then `npm run build`. Shapes such as `LlmTokenBillingStatus` (including optional `credit_balance` and `billing_cycle_usage.metered_lines`) come from the generated `api-types.ts`. For a full endpoint list, see the [API reference](https://docs.1claw.co/docs/reference/api-reference) or the spec.
|
|
42
44
|
|
|
43
45
|
## Authentication
|
|
44
46
|
|
|
@@ -49,20 +51,20 @@ The SDK supports three authentication modes:
|
|
|
49
51
|
```typescript
|
|
50
52
|
// 1. User API key (auto-authenticates)
|
|
51
53
|
const client = createClient({
|
|
52
|
-
baseUrl: "https://api.1claw.
|
|
54
|
+
baseUrl: "https://api.1claw.co",
|
|
53
55
|
apiKey: "ocv_...",
|
|
54
56
|
});
|
|
55
57
|
|
|
56
58
|
// 2. Agent with API key (auto-authenticates as agent)
|
|
57
59
|
const agent = createClient({
|
|
58
|
-
baseUrl: "https://api.1claw.
|
|
60
|
+
baseUrl: "https://api.1claw.co",
|
|
59
61
|
apiKey: "ocv_...",
|
|
60
62
|
agentId: "agent-uuid",
|
|
61
63
|
});
|
|
62
64
|
|
|
63
65
|
// 3. Pre-authenticated JWT
|
|
64
66
|
const authed = createClient({
|
|
65
|
-
baseUrl: "https://api.1claw.
|
|
67
|
+
baseUrl: "https://api.1claw.co",
|
|
66
68
|
token: "eyJ...",
|
|
67
69
|
});
|
|
68
70
|
|
|
@@ -396,7 +398,7 @@ await client.agents.submitTransaction(agentId, {
|
|
|
396
398
|
});
|
|
397
399
|
```
|
|
398
400
|
|
|
399
|
-
See the [Intents API guide](https://docs.1claw.
|
|
401
|
+
See the [Intents API guide](https://docs.1claw.co/docs/guides/intents-api#non-evm-transaction-signing) for full field reference.
|
|
400
402
|
|
|
401
403
|
Key properties:
|
|
402
404
|
|
|
@@ -418,13 +420,13 @@ await client.agents.update(agentId, {
|
|
|
418
420
|
```
|
|
419
421
|
|
|
420
422
|
When `intents_require_tee` is true:
|
|
421
|
-
- Transaction submit/sign requests to `api.1claw.
|
|
422
|
-
- Agents must route through `shroud.1claw.
|
|
423
|
+
- Transaction submit/sign requests to `api.1claw.co` are rejected (403)
|
|
424
|
+
- Agents must route through `shroud.1claw.co` where signing happens inside TEE memory
|
|
423
425
|
|
|
424
426
|
When `execution_require_tee` is true:
|
|
425
|
-
- Execute requests to `api.1claw.
|
|
427
|
+
- Execute requests to `api.1claw.co` are rejected (403)
|
|
426
428
|
- All direct secret reads by the agent are blocked — forces use of Execution Intent bindings
|
|
427
|
-
- Agents must route through `shroud.1claw.
|
|
429
|
+
- Agents must route through `shroud.1claw.co`
|
|
428
430
|
|
|
429
431
|
Both require `intents_api_enabled` / `execution_intents_enabled` to be on first.
|
|
430
432
|
|
|
@@ -498,7 +500,7 @@ import { generatePKCE, buildAuthorizeUrl, createClient } from "@1claw/sdk";
|
|
|
498
500
|
const pkce = await generatePKCE();
|
|
499
501
|
|
|
500
502
|
// 2. Build the authorize URL
|
|
501
|
-
const authUrl = buildAuthorizeUrl("https://1claw.
|
|
503
|
+
const authUrl = buildAuthorizeUrl("https://1claw.co", {
|
|
502
504
|
clientId: "your-platform-app-slug",
|
|
503
505
|
redirectUri: "https://yourapp.com/callback",
|
|
504
506
|
scopes: ["openid", "profile", "email"],
|
|
@@ -507,7 +509,7 @@ const authUrl = buildAuthorizeUrl("https://1claw.xyz", {
|
|
|
507
509
|
});
|
|
508
510
|
|
|
509
511
|
// 3. After redirect, exchange the code for tokens
|
|
510
|
-
const client = createClient({ baseUrl: "https://api.1claw.
|
|
512
|
+
const client = createClient({ baseUrl: "https://api.1claw.co" });
|
|
511
513
|
const tokens = await client.auth.exchangeOAuthCode({
|
|
512
514
|
code: "authorization-code-from-callback",
|
|
513
515
|
client_id: "your-platform-app-slug",
|
|
@@ -527,10 +529,10 @@ await client.auth.revokeConsent("platform-app-id");
|
|
|
527
529
|
|
|
528
530
|
## OIDC Federation (Anthropic WIF, GCP STS, AWS STS)
|
|
529
531
|
|
|
530
|
-
`https://api.1claw.
|
|
532
|
+
`https://api.1claw.co` is a fully OpenID Connect–compliant issuer. External relying parties — Anthropic Workload Identity Federation, GCP STS, AWS STS, Stytch, etc. — can validate 1claw-issued JWTs by fetching:
|
|
531
533
|
|
|
532
|
-
- `GET https://api.1claw.
|
|
533
|
-
- `GET https://api.1claw.
|
|
534
|
+
- `GET https://api.1claw.co/.well-known/openid-configuration`
|
|
535
|
+
- `GET https://api.1claw.co/.well-known/jwks.json`
|
|
534
536
|
|
|
535
537
|
The SDK exposes one method to mint a federation token:
|
|
536
538
|
|
|
@@ -618,7 +620,7 @@ When using agent credentials (`agentId` + `apiKey`), the SDK automatically refre
|
|
|
618
620
|
|
|
619
621
|
```typescript
|
|
620
622
|
const client = createClient({
|
|
621
|
-
baseUrl: "https://api.1claw.
|
|
623
|
+
baseUrl: "https://api.1claw.co",
|
|
622
624
|
apiKey: "ocv_...",
|
|
623
625
|
agentId: "agent-uuid",
|
|
624
626
|
});
|
|
@@ -631,7 +633,7 @@ Enable [DPoP (RFC 9449)](https://datatracker.ietf.org/doc/html/rfc9449) to bind
|
|
|
631
633
|
|
|
632
634
|
```typescript
|
|
633
635
|
const client = createClient({
|
|
634
|
-
baseUrl: "https://api.1claw.
|
|
636
|
+
baseUrl: "https://api.1claw.co",
|
|
635
637
|
apiKey: "ocv_...",
|
|
636
638
|
agentId: "agent-uuid",
|
|
637
639
|
dpop: true, // Generates ephemeral P-256 keypair, attaches DPoP proofs
|
|
@@ -646,7 +648,7 @@ import { DPoPManager } from "@1claw/sdk";
|
|
|
646
648
|
const dpop = new DPoPManager();
|
|
647
649
|
await dpop.init();
|
|
648
650
|
|
|
649
|
-
const proof = await dpop.generateProof("POST", "https://api.1claw.
|
|
651
|
+
const proof = await dpop.generateProof("POST", "https://api.1claw.co/v1/auth/agent-token");
|
|
650
652
|
const thumbprint = dpop.getThumbprint(); // JWK SHA-256 thumbprint (base64url)
|
|
651
653
|
```
|
|
652
654
|
|
|
@@ -699,7 +701,7 @@ const signer: X402Signer = {
|
|
|
699
701
|
};
|
|
700
702
|
|
|
701
703
|
const client = createClient({
|
|
702
|
-
baseUrl: "https://api.1claw.
|
|
704
|
+
baseUrl: "https://api.1claw.co",
|
|
703
705
|
apiKey: "ocv_...",
|
|
704
706
|
x402Signer: signer,
|
|
705
707
|
maxAutoPayUsd: 0.01, // auto-pay up to $0.01 per request
|
|
@@ -751,7 +753,7 @@ import { createClient } from "@1claw/sdk";
|
|
|
751
753
|
import type { CryptoProvider, AuditSink, PolicyEngine } from "@1claw/sdk";
|
|
752
754
|
|
|
753
755
|
const client = createClient({
|
|
754
|
-
baseUrl: "https://api.1claw.
|
|
756
|
+
baseUrl: "https://api.1claw.co",
|
|
755
757
|
apiKey: "ocv_...",
|
|
756
758
|
plugins: {
|
|
757
759
|
cryptoProvider: myAwsKmsProvider,
|
|
@@ -864,7 +866,7 @@ When making LLM requests to Shroud, specify the model in one of two ways:
|
|
|
864
866
|
|
|
865
867
|
**Option 1: Header**
|
|
866
868
|
```typescript
|
|
867
|
-
const res = await fetch("https://shroud.1claw.
|
|
869
|
+
const res = await fetch("https://shroud.1claw.co/v1/chat/completions", {
|
|
868
870
|
method: "POST",
|
|
869
871
|
headers: {
|
|
870
872
|
"X-Shroud-Agent-Key": `${agentId}:${agentApiKey}`,
|
|
@@ -888,7 +890,7 @@ body: JSON.stringify({
|
|
|
888
890
|
|
|
889
891
|
Shroud enforces the agent's `allowed_models` and `denied_models` restrictions automatically — requests using unauthorized models return **403 Forbidden**.
|
|
890
892
|
|
|
891
|
-
See the [Shroud Security Guide](https://docs.1claw.
|
|
893
|
+
See the [Shroud Security Guide](https://docs.1claw.co/docs/guides/shroud) for full configuration options.
|
|
892
894
|
|
|
893
895
|
## v0.48 — Cedar/OPA Enforcement v2
|
|
894
896
|
|