@1claw/sdk 0.44.1 → 0.45.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/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # @1claw/sdk
2
2
 
3
- TypeScript SDK for **1Claw Vault** — HSM-backed secret management for AI agents and humans.
3
+ TypeScript/JavaScript client for the 1Claw Vault API.
4
+
5
+ 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.
6
+
7
+ Agent keys auto-exchange for JWTs and refresh before expiry. If you're wiring an AI agent in Cursor or Claude Desktop, you probably want [@1claw/mcp](https://www.npmjs.com/package/@1claw/mcp) instead. If you're building a web app or backend service in TypeScript, start here.
4
8
 
5
9
  ## Install
6
10
 
@@ -93,7 +97,7 @@ await client.auth.verifyEmailChange({ code: "123456" });
93
97
  | `client.billing` | `usage`, `history`, `llmTokenBilling`, `subscribeLlmTokenBilling`, `disableLlmTokenBilling` (LLM token billing / Stripe AI Gateway) |
94
98
  | `client.audit` | `query` |
95
99
  | `client.org` | `listMembers`, `getAgentKeysVault`, `updateMemberRole`, `removeMember` |
96
- | `client.auth` | `login`, `signup`, `agentToken`, `apiKeyToken`, `google`, `socialLogin`, `sendEmailOtp`, `verifyEmailOtp`, `exchangeOAuthCode`, `changePassword`, `setPassword`, `changeEmail`, `verifyEmailChange`, `forgotPassword`, `resetPassword`, `exportData`, `exchangeFederatedToken`, `logout`, `getMe`, `updateMe`, `deleteMe` |
100
+ | `client.auth` | `login`, `signup`, `agentToken`, `apiKeyToken`, `google`, `socialLogin`, `sendEmailOtp`, `verifyEmailOtp`, `exchangeOAuthCode`, `revokeToken`, `revokeConsent`, `getUserInfo`, `changePassword`, `setPassword`, `changeEmail`, `verifyEmailChange`, `forgotPassword`, `resetPassword`, `exportData`, `exchangeFederatedToken`, `logout`, `getMe`, `updateMe`, `deleteMe` |
97
101
  | `client.apiKeys` | `create`, `list`, `revoke` |
98
102
  | `client.treasury` | `create`, `list`, `get`, `update`, `delete`, `addSigner`, `removeSigner`, `requestAccess`, `listAccessRequests`, `approveAccess`, `denyAccess`, `propose`, `listProposals`, `getProposal`, `signProposal`, `executeProposal` |
99
103
  | `client.treasuryWallets` | `generateWallets`, `listWallets`, `getWallet`, `getWalletBalance`, `sendFromWallet`, `swapFromWallet`, `exportWallet`, `rotateWallet`, `deactivateWallet`, `getEffectiveSpendPolicy` |
@@ -102,7 +106,7 @@ await client.auth.verifyEmailChange({ code: "123456" });
102
106
  | `client.fiat` | `createOnrampSession`, `initiateOfframp` |
103
107
  | `client.signingKeys` | `create`, `list`, `rotate`, `deactivate`, `export` |
104
108
  | `client.agents` (Bankr) | `leaseBankrKey`, `listBankrKeys`, `revokeBankrKey` — privileged; `api_key` omitted for agent JWTs (use Shroud) |
105
- | `client.platform` | `createApp`, `listApps`, `getApp`, `updateApp`, `deleteApp`, `rotateKey`, `createTemplate`, `listTemplates`, `upsertUser`, `listUsers`, `bootstrapUser`, `reissueClaim`, `claimPreview`, `claimRedeem`, `listConnectedApps`, `disconnectApp`, `grantAccess`, `listGrants`, `revokeGrant`, `createSpendPolicy`, `listSpendPolicies`, `setUserSpendPolicy`, `deleteSpendPolicy`, `updateConnectionDelegation` |
109
+ | `client.platform` | `createApp`, `listApps`, `getApp`, `updateApp`, `deleteApp`, `rotateKey`, `rotateWebhookSecret`, `getAppStats`, `marketplace`, `createTemplate`, `listTemplates`, `upsertUser`, `listUsers`, `bootstrapUser`, `reissueClaim`, `claimPreview`, `claimRedeem`, `listConnectedApps`, `disconnectApp`, `grantAccess`, `listGrants`, `revokeGrant`, `createSpendPolicy`, `listSpendPolicies`, `setUserSpendPolicy`, `deleteSpendPolicy`, `updateConnectionDelegation` |
106
110
  | `client.devices` | `register`, `list`, `delete`, `challenge`, `attest`, `setPushToken` |
107
111
  | `client.passkeys` | `list`, `registerBegin`, `registerComplete`, `assertBegin`, `assertComplete`, `delete` |
108
112
  | `client.risk` | `listEvents`, `getVerdict`, `listVerdicts`, `createHoneytoken`, `listHoneytokens`, `deleteHoneytoken` |
@@ -352,6 +356,44 @@ console.log(agent.data?.tx_count_today); // e.g. 42
352
356
  console.log(agent.data?.tx_overhead_today_by_chain); // e.g. { "solana": "0.12" }
353
357
  ```
354
358
 
359
+ ## OAuth2 / PKCE ("Sign in with 1Claw")
360
+
361
+ The SDK provides helpers for implementing the full OAuth2 PKCE flow and managing tokens/consent:
362
+
363
+ ```typescript
364
+ import { generatePKCE, buildAuthorizeUrl, createClient } from "@1claw/sdk";
365
+
366
+ // 1. Generate PKCE pair
367
+ const pkce = await generatePKCE();
368
+
369
+ // 2. Build the authorize URL
370
+ const authUrl = buildAuthorizeUrl("https://1claw.xyz", {
371
+ clientId: "your-platform-app-slug",
372
+ redirectUri: "https://yourapp.com/callback",
373
+ scopes: ["openid", "profile", "email"],
374
+ state: "random-state",
375
+ codeChallenge: pkce.codeChallenge,
376
+ });
377
+
378
+ // 3. After redirect, exchange the code for tokens
379
+ const client = createClient({ baseUrl: "https://api.1claw.xyz" });
380
+ const tokens = await client.auth.exchangeOAuthCode({
381
+ code: "authorization-code-from-callback",
382
+ client_id: "your-platform-app-slug",
383
+ redirect_uri: "https://yourapp.com/callback",
384
+ code_verifier: pkce.codeVerifier,
385
+ });
386
+
387
+ // 4. Fetch user info
388
+ const userInfo = await client.auth.getUserInfo(tokens.data?.access_token);
389
+
390
+ // 5. Revoke a token (RFC 7009)
391
+ await client.auth.revokeToken({ token: "...", token_type_hint: "refresh_token" });
392
+
393
+ // 6. Revoke consent for an app (invalidates all tokens)
394
+ await client.auth.revokeConsent("platform-app-id");
395
+ ```
396
+
355
397
  ## OIDC Federation (Anthropic WIF, GCP STS, AWS STS)
356
398
 
357
399
  `https://api.1claw.xyz` 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:
@@ -3221,6 +3221,46 @@ export interface paths {
3221
3221
  patch?: never;
3222
3222
  trace?: never;
3223
3223
  };
3224
+ "/v1/platform/apps/{appId}/stats": {
3225
+ parameters: {
3226
+ query?: never;
3227
+ header?: never;
3228
+ path?: never;
3229
+ cookie?: never;
3230
+ };
3231
+ /**
3232
+ * Get platform app statistics
3233
+ * @description Returns aggregate statistics about a platform app's connected users, bootstraps, and grants.
3234
+ */
3235
+ get: operations["getPlatformAppStats"];
3236
+ put?: never;
3237
+ post?: never;
3238
+ delete?: never;
3239
+ options?: never;
3240
+ head?: never;
3241
+ patch?: never;
3242
+ trace?: never;
3243
+ };
3244
+ "/v1/platform/apps/{appId}/rotate-webhook-secret": {
3245
+ parameters: {
3246
+ query?: never;
3247
+ header?: never;
3248
+ path?: never;
3249
+ cookie?: never;
3250
+ };
3251
+ get?: never;
3252
+ put?: never;
3253
+ /**
3254
+ * Rotate webhook secret
3255
+ * @description Generate a new webhook signing secret for the platform app. The old secret is immediately invalidated. Returns the new secret (one-time).
3256
+ */
3257
+ post: operations["rotatePlatformWebhookSecret"];
3258
+ delete?: never;
3259
+ options?: never;
3260
+ head?: never;
3261
+ patch?: never;
3262
+ trace?: never;
3263
+ };
3224
3264
  "/v1/platform/apps/{appId}/templates": {
3225
3265
  parameters: {
3226
3266
  query?: never;
@@ -4406,6 +4446,48 @@ export interface paths {
4406
4446
  patch?: never;
4407
4447
  trace?: never;
4408
4448
  };
4449
+ "/v1/oauth/revoke": {
4450
+ parameters: {
4451
+ query?: never;
4452
+ header?: never;
4453
+ path?: never;
4454
+ cookie?: never;
4455
+ };
4456
+ get?: never;
4457
+ put?: never;
4458
+ /**
4459
+ * Revoke an OAuth token (RFC 7009)
4460
+ * @description Revokes an access token or refresh token. The authorization server
4461
+ * invalidates the token so it can no longer be used. Follows RFC 7009.
4462
+ */
4463
+ post: operations["revokeOAuthToken"];
4464
+ delete?: never;
4465
+ options?: never;
4466
+ head?: never;
4467
+ patch?: never;
4468
+ trace?: never;
4469
+ };
4470
+ "/v1/oauth/consents/{app_id}": {
4471
+ parameters: {
4472
+ query?: never;
4473
+ header?: never;
4474
+ path?: never;
4475
+ cookie?: never;
4476
+ };
4477
+ get?: never;
4478
+ put?: never;
4479
+ post?: never;
4480
+ /**
4481
+ * Revoke consent for a platform app
4482
+ * @description Revokes the user's previously granted OAuth consent for a specific platform app.
4483
+ * All active tokens issued to the app are invalidated and the consent record is deleted.
4484
+ */
4485
+ delete: operations["revokeOAuthConsent"];
4486
+ options?: never;
4487
+ head?: never;
4488
+ patch?: never;
4489
+ trace?: never;
4490
+ };
4409
4491
  "/v1/risk/events": {
4410
4492
  parameters: {
4411
4493
  query?: never;
@@ -5227,6 +5309,28 @@ export interface paths {
5227
5309
  patch?: never;
5228
5310
  trace?: never;
5229
5311
  };
5312
+ "/v1/agents/org-directory": {
5313
+ parameters: {
5314
+ query?: never;
5315
+ header?: never;
5316
+ path?: never;
5317
+ cookie?: never;
5318
+ };
5319
+ /**
5320
+ * List org agents
5321
+ * @description List agents within the caller's organization for sub-agent discovery.
5322
+ * Returns agents with their capabilities, enabling agent-to-agent
5323
+ * coordination and discovery within an org. Requires authentication.
5324
+ */
5325
+ get: operations["listOrgDirectory"];
5326
+ put?: never;
5327
+ post?: never;
5328
+ delete?: never;
5329
+ options?: never;
5330
+ head?: never;
5331
+ patch?: never;
5332
+ trace?: never;
5333
+ };
5230
5334
  "/v1/agents/{agent_id}/discovery": {
5231
5335
  parameters: {
5232
5336
  query?: never;
@@ -5253,7 +5357,7 @@ export interface paths {
5253
5357
  };
5254
5358
  /**
5255
5359
  * Public marketplace
5256
- * @description Browse the public platform marketplace of agents and apps.
5360
+ * @description Browse the public platform marketplace of listed apps and agents. Returns approved platform apps with category, tags, pricing summaries, and screenshots.
5257
5361
  */
5258
5362
  get: operations["listMarketplace"];
5259
5363
  put?: never;
@@ -5277,6 +5381,11 @@ export interface paths {
5277
5381
  * Send chat message
5278
5382
  * @description Send a message to an agent and receive a response via Shroud LLM.
5279
5383
  * Supports SSE streaming when Accept: text/event-stream is set.
5384
+ *
5385
+ * Agents can call this endpoint on other agents within the same
5386
+ * organization for inter-agent communication (agent-to-agent chat).
5387
+ * The caller must be authenticated and belong to the same org as
5388
+ * the target agent.
5280
5389
  */
5281
5390
  post: operations["sendChatMessage"];
5282
5391
  delete?: never;
@@ -8211,6 +8320,8 @@ export interface components {
8211
8320
  vault_id?: string | null;
8212
8321
  /** Format: uuid */
8213
8322
  agent_id?: string | null;
8323
+ /** @description All agent IDs provisioned by the template (when multiple agents are defined) */
8324
+ agent_ids?: string[];
8214
8325
  policy_ids?: string[];
8215
8326
  /** @description Chains with provisioned signing keys */
8216
8327
  signing_key_chains?: string[];
@@ -8231,6 +8342,32 @@ export interface components {
8231
8342
  automation_ids?: string[];
8232
8343
  };
8233
8344
  };
8345
+ PlatformAppStatsResponse: {
8346
+ /** @description Total number of user connections (all statuses) */
8347
+ total_connections: number;
8348
+ /** @description Number of active connections */
8349
+ active_connections: number;
8350
+ /** @description Number of claimed connections */
8351
+ claimed_connections: number;
8352
+ /** @description Total bootstrap operations performed */
8353
+ total_bootstraps: number;
8354
+ /** @description Total resource grants issued */
8355
+ total_grants: number;
8356
+ };
8357
+ MarketplaceResponse: {
8358
+ apps?: {
8359
+ /** Format: uuid */
8360
+ id?: string;
8361
+ name?: string;
8362
+ slug?: string;
8363
+ description?: string;
8364
+ logo_url?: string | null;
8365
+ category?: string | null;
8366
+ listing_tags?: string[];
8367
+ listing_screenshots?: string[];
8368
+ pricing_summary?: string | null;
8369
+ }[];
8370
+ };
8234
8371
  ConnectedAppResponse: {
8235
8372
  /** Format: uuid */
8236
8373
  connection_id?: string;
@@ -8436,6 +8573,8 @@ export interface components {
8436
8573
  token_type: "Bearer";
8437
8574
  /** @description Token lifetime in seconds */
8438
8575
  expires_in: number;
8576
+ /** @description Refresh token for obtaining new access tokens (when offline_access scope was granted) */
8577
+ refresh_token?: string | null;
8439
8578
  /** @description OIDC ID token (when openid scope was granted) */
8440
8579
  id_token?: string | null;
8441
8580
  scope: string;
@@ -9057,6 +9196,25 @@ export interface components {
9057
9196
  page: number;
9058
9197
  per_page: number;
9059
9198
  };
9199
+ OrgDirectoryAgent: {
9200
+ /** Format: uuid */
9201
+ id: string;
9202
+ name: string;
9203
+ public_description?: string | null;
9204
+ public_tags?: string[];
9205
+ a2a_url?: string | null;
9206
+ mcp_url?: string | null;
9207
+ intents_api_enabled: boolean;
9208
+ execution_intents_enabled: boolean;
9209
+ memory_enabled: boolean;
9210
+ shroud_enabled: boolean;
9211
+ };
9212
+ OrgDirectoryResponse: {
9213
+ agents: components["schemas"]["OrgDirectoryAgent"][];
9214
+ total: number;
9215
+ page: number;
9216
+ page_size: number;
9217
+ };
9060
9218
  UpdateDiscoveryRequest: {
9061
9219
  discoverable?: boolean;
9062
9220
  public_description?: string;
@@ -9125,6 +9283,14 @@ export interface components {
9125
9283
  config: {
9126
9284
  [key: string]: string;
9127
9285
  };
9286
+ /** @description Enable slash commands on this channel */
9287
+ slash_commands_enabled?: boolean;
9288
+ /** @description Enable voice message transcription */
9289
+ voice_transcription_enabled?: boolean;
9290
+ /** @description List of allowed sender IDs */
9291
+ sender_allowlist?: string[];
9292
+ /** @description Enable auto-respond */
9293
+ auto_respond_enabled?: boolean;
9128
9294
  };
9129
9295
  UpdateChannelRequest: {
9130
9296
  channel_name?: string;
@@ -9132,6 +9298,10 @@ export interface components {
9132
9298
  config?: {
9133
9299
  [key: string]: string;
9134
9300
  };
9301
+ slash_commands_enabled?: boolean;
9302
+ voice_transcription_enabled?: boolean;
9303
+ sender_allowlist?: string[];
9304
+ auto_respond_enabled?: boolean;
9135
9305
  };
9136
9306
  ChannelResponse: {
9137
9307
  /** Format: uuid */
@@ -9154,6 +9324,21 @@ export interface components {
9154
9324
  config?: {
9155
9325
  [key: string]: unknown;
9156
9326
  } | null;
9327
+ /** @description Whether slash commands are enabled for this channel */
9328
+ slash_commands_enabled?: boolean;
9329
+ /** @description Whether voice message transcription is enabled */
9330
+ voice_transcription_enabled?: boolean;
9331
+ /**
9332
+ * Format: uuid
9333
+ * @description ID linking this channel to a unified cross-platform conversation
9334
+ */
9335
+ unified_conversation_id?: string | null;
9336
+ /** @description Whether this is the agent's home platform channel */
9337
+ is_home_platform?: boolean;
9338
+ /** @description List of allowed sender IDs for auto-respond */
9339
+ sender_allowlist?: string[] | null;
9340
+ /** @description Whether auto-respond is enabled for this channel */
9341
+ auto_respond_enabled?: boolean;
9157
9342
  /** Format: date-time */
9158
9343
  created_at?: string;
9159
9344
  /** Format: date-time */
@@ -9181,6 +9366,17 @@ export interface components {
9181
9366
  sender_name?: string;
9182
9367
  content?: string;
9183
9368
  media_url?: string;
9369
+ /** @description Whether this message was a voice message */
9370
+ is_voice_message?: boolean;
9371
+ /** @description Telegram voice file ID */
9372
+ voice_file_id?: string | null;
9373
+ /** @description Duration of voice message in seconds */
9374
+ voice_duration_secs?: number | null;
9375
+ /**
9376
+ * @description Status of voice transcription
9377
+ * @enum {string|null}
9378
+ */
9379
+ transcription_status?: "pending" | "completed" | "failed" | null;
9184
9380
  /** Format: date-time */
9185
9381
  created_at?: string;
9186
9382
  };
@@ -14072,6 +14268,64 @@ export interface operations {
14072
14268
  };
14073
14269
  };
14074
14270
  };
14271
+ getPlatformAppStats: {
14272
+ parameters: {
14273
+ query?: never;
14274
+ header?: never;
14275
+ path: {
14276
+ appId: string;
14277
+ };
14278
+ cookie?: never;
14279
+ };
14280
+ requestBody?: never;
14281
+ responses: {
14282
+ /** @description App statistics */
14283
+ 200: {
14284
+ headers: {
14285
+ [name: string]: unknown;
14286
+ };
14287
+ content: {
14288
+ "application/json": components["schemas"]["PlatformAppStatsResponse"];
14289
+ };
14290
+ };
14291
+ 401: components["responses"]["Unauthorized"];
14292
+ 404: components["responses"]["NotFound"];
14293
+ };
14294
+ };
14295
+ rotatePlatformWebhookSecret: {
14296
+ parameters: {
14297
+ query?: never;
14298
+ header?: never;
14299
+ path: {
14300
+ appId: string;
14301
+ };
14302
+ cookie?: never;
14303
+ };
14304
+ requestBody?: never;
14305
+ responses: {
14306
+ /** @description New webhook secret generated */
14307
+ 200: {
14308
+ headers: {
14309
+ [name: string]: unknown;
14310
+ };
14311
+ content: {
14312
+ "application/json": {
14313
+ /** @description The new webhook signing secret (shown once) */
14314
+ webhook_secret: string;
14315
+ };
14316
+ };
14317
+ };
14318
+ 401: components["responses"]["Unauthorized"];
14319
+ /** @description Only human users can rotate webhook secrets */
14320
+ 403: {
14321
+ headers: {
14322
+ [name: string]: unknown;
14323
+ };
14324
+ content?: never;
14325
+ };
14326
+ 404: components["responses"]["NotFound"];
14327
+ };
14328
+ };
14075
14329
  deletePlatformTemplate: {
14076
14330
  parameters: {
14077
14331
  query?: never;
@@ -15003,6 +15257,71 @@ export interface operations {
15003
15257
  401: components["responses"]["Unauthorized"];
15004
15258
  };
15005
15259
  };
15260
+ revokeOAuthToken: {
15261
+ parameters: {
15262
+ query?: never;
15263
+ header?: never;
15264
+ path?: never;
15265
+ cookie?: never;
15266
+ };
15267
+ requestBody: {
15268
+ content: {
15269
+ "application/json": {
15270
+ /** @description The token to revoke (access_token or refresh_token) */
15271
+ token: string;
15272
+ /**
15273
+ * @description Hint about the type of token being revoked
15274
+ * @enum {string}
15275
+ */
15276
+ token_type_hint?: "access_token" | "refresh_token";
15277
+ };
15278
+ };
15279
+ };
15280
+ responses: {
15281
+ /** @description Token revoked successfully (or was already invalid) */
15282
+ 200: {
15283
+ headers: {
15284
+ [name: string]: unknown;
15285
+ };
15286
+ content: {
15287
+ "application/json": {
15288
+ /** @example true */
15289
+ revoked?: boolean;
15290
+ };
15291
+ };
15292
+ };
15293
+ };
15294
+ };
15295
+ revokeOAuthConsent: {
15296
+ parameters: {
15297
+ query?: never;
15298
+ header?: never;
15299
+ path: {
15300
+ /** @description The platform app ID whose consent to revoke */
15301
+ app_id: string;
15302
+ };
15303
+ cookie?: never;
15304
+ };
15305
+ requestBody?: never;
15306
+ responses: {
15307
+ /** @description Consent revoked */
15308
+ 200: {
15309
+ headers: {
15310
+ [name: string]: unknown;
15311
+ };
15312
+ content: {
15313
+ "application/json": {
15314
+ /** @example true */
15315
+ revoked?: boolean;
15316
+ /** Format: uuid */
15317
+ app_id?: string;
15318
+ };
15319
+ };
15320
+ };
15321
+ 401: components["responses"]["Unauthorized"];
15322
+ 404: components["responses"]["NotFound"];
15323
+ };
15324
+ };
15006
15325
  listRiskEvents: {
15007
15326
  parameters: {
15008
15327
  query?: {
@@ -16375,6 +16694,34 @@ export interface operations {
16375
16694
  };
16376
16695
  };
16377
16696
  };
16697
+ listOrgDirectory: {
16698
+ parameters: {
16699
+ query?: {
16700
+ /** @description Search query to filter agents by name or description */
16701
+ q?: string;
16702
+ /** @description Comma-separated tag filter */
16703
+ tags?: string;
16704
+ page?: number;
16705
+ page_size?: number;
16706
+ };
16707
+ header?: never;
16708
+ path?: never;
16709
+ cookie?: never;
16710
+ };
16711
+ requestBody?: never;
16712
+ responses: {
16713
+ /** @description Org agent directory listing */
16714
+ 200: {
16715
+ headers: {
16716
+ [name: string]: unknown;
16717
+ };
16718
+ content: {
16719
+ "application/json": components["schemas"]["OrgDirectoryResponse"];
16720
+ };
16721
+ };
16722
+ 401: components["responses"]["Unauthorized"];
16723
+ };
16724
+ };
16378
16725
  updateDiscoverySettings: {
16379
16726
  parameters: {
16380
16727
  query?: never;
@@ -16411,6 +16758,8 @@ export interface operations {
16411
16758
  per_page?: number;
16412
16759
  /** @description Search query */
16413
16760
  q?: string;
16761
+ /** @description Filter by app category */
16762
+ category?: string;
16414
16763
  };
16415
16764
  header?: never;
16416
16765
  path?: never;
@@ -16424,7 +16773,7 @@ export interface operations {
16424
16773
  [name: string]: unknown;
16425
16774
  };
16426
16775
  content: {
16427
- "application/json": components["schemas"]["DirectoryResponse"];
16776
+ "application/json": components["schemas"]["MarketplaceResponse"];
16428
16777
  };
16429
16778
  };
16430
16779
  };