@lizard-build/sdk 0.1.37 → 0.1.39

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
@@ -148,6 +148,14 @@ sandbox.process.exec_("lizard volume list")
148
148
 
149
149
  A key with **no** scope has full access to everything the creating account can reach — pass `workspaces` or `projects` unless you mean that.
150
150
 
151
+ ### What a scoped key deliberately cannot see
152
+
153
+ Billing is account-level: one balance, one ledger, one set of saved cards, shared by every workspace. There is no per-workspace view of it, so a scoped key is refused outright (403 `ACCOUNT_SCOPE_REQUIRED`) on `lizard.billing.*` and on account-wide usage, and `whoami()` returns only identity plus the key's own scopes — not the account's email, balance or plan.
154
+
155
+ That matters because of where these keys end up. A key you hand to a user, or inject into a sandbox with `lizardToken`, is readable by anything running there. It should not be a way to read your card details or spend against them.
156
+
157
+ For per-workspace spend, use `lizard.metrics` — that is scoped, and is what you would bill a user from.
158
+
151
159
  ## API
152
160
 
153
161
  ### `new Lizard({ project, apiKey?, apiUrl?, timeoutMs? })`
@@ -187,8 +195,8 @@ List all running sandboxes for the authenticated account.
187
195
  | `lizard.apiKeys` | `list()`, `create({ name, workspaces?, projects? })`, `delete(id)` |
188
196
  | `lizard.projects` | `list({ workspaceId? })`, `get(id)`, `create({ workspaceId, name })`, `update(id, { name })`, `delete(id)` |
189
197
  | `lizard.regions` | `list()` |
190
- | `lizard.billing` | `balance()`, `transactions({ limit?, cursor?, includeUsage? })`, `summary()`, `live()` |
191
- | `lizard.whoami()` | The account behind the credential — works for scoped keys too |
198
+ | `lizard.billing` | `balance()`, `transactions({ limit?, cursor?, includeUsage? })`, `summary()`, `live()` — **unscoped keys only** |
199
+ | `lizard.whoami()` | The account behind the credential; a scoped key gets identity and its own scopes, not the account's email or balance |
192
200
  | `lizard.platform` | The raw HTTP client, for endpoints not wrapped yet |
193
201
 
194
202
  `workspaces.delete()` is empty-only by default; the server refuses while any project, sandbox or volume remains. `{ force: true }` deletes the workspace and everything in it, irreversibly.
package/dist/index.d.mts CHANGED
@@ -1098,6 +1098,12 @@ interface ListTransactionsOpts {
1098
1098
  * a user bills to the account that owns the key. That is what makes per-user
1099
1099
  * workspaces a safe pattern — your users get isolation, you keep one bill — and also
1100
1100
  * what makes {@link Balance.runwayHours} worth watching before you provision more.
1101
+ *
1102
+ * **Requires an unscoped key.** A scoped key is refused with 403
1103
+ * `ACCOUNT_SCOPE_REQUIRED`, because there is no workspace-scoped view of one shared
1104
+ * balance, ledger and set of saved cards — and because a scoped key is meant to be
1105
+ * handed to an end user, who should not be reading your card details or spending
1106
+ * against them. For per-workspace spend, use {@link MetricsAPI.cost} instead.
1101
1107
  */
1102
1108
  declare class BillingAPI {
1103
1109
  private readonly client;
@@ -1125,6 +1131,7 @@ interface VolumeInfo {
1125
1131
  createdAt: number;
1126
1132
  }
1127
1133
  interface CreateVolumeOpts extends ConnectionOpts {
1134
+ /** Whole GB, default 5. New volumes allow 1–50 GB unless the server config sets another maximum. Existing volumes are never resized. */
1128
1135
  sizeGb?: number;
1129
1136
  /**
1130
1137
  * Region to place the volume in, e.g. `'us-east-1'`. A volume is node-local, so
@@ -1281,19 +1288,36 @@ declare class Lizard {
1281
1288
  /**
1282
1289
  * The account this credential belongs to — the SDK's `lizard whoami`.
1283
1290
  *
1284
- * Works for a scoped key as well as a full one: the identity is the account that
1285
- * created the key, which is what the key's usage bills to.
1291
+ * A **scoped** key gets identity only: `id`, `username`, `avatarUrl`, `scoped: true`
1292
+ * and the key's own `scopes`. The account's email, balance, plan and billing status
1293
+ * are withheld — they belong to the account, not to the key holder, and a scoped key
1294
+ * is meant to be handed to an end user or injected into a sandbox. An unscoped key
1295
+ * or a session sees the full account.
1296
+ *
1297
+ * Reading back `scopes` is the cheapest way to answer "what can this key reach".
1286
1298
  */
1287
1299
  whoami(): Promise<Account>;
1288
1300
  /** The underlying HTTP client, for endpoints this SDK does not wrap yet. */
1289
1301
  get platform(): PlatformClient;
1290
1302
  }
1291
- /** The account behind a credential — see {@link Lizard.whoami}. */
1303
+ /**
1304
+ * The account behind a credential — see {@link Lizard.whoami}.
1305
+ *
1306
+ * Everything past `avatarUrl` is present only for an unscoped key or a session; a
1307
+ * scoped key gets `scoped: true` and `scopes` in their place.
1308
+ */
1292
1309
  interface Account {
1293
1310
  id: string;
1294
1311
  username: string;
1295
- email?: string | null;
1296
1312
  avatarUrl?: string | null;
1313
+ /** True when the calling key is scoped, meaning the account fields below are absent. */
1314
+ scoped?: boolean;
1315
+ /** What the calling key may reach. Present when `scoped` is true. */
1316
+ scopes?: Array<{
1317
+ type: 'workspace' | 'project';
1318
+ id: string;
1319
+ }>;
1320
+ email?: string | null;
1297
1321
  plan?: string;
1298
1322
  billingStatus?: string;
1299
1323
  balanceCents?: number;
package/dist/index.d.ts CHANGED
@@ -1098,6 +1098,12 @@ interface ListTransactionsOpts {
1098
1098
  * a user bills to the account that owns the key. That is what makes per-user
1099
1099
  * workspaces a safe pattern — your users get isolation, you keep one bill — and also
1100
1100
  * what makes {@link Balance.runwayHours} worth watching before you provision more.
1101
+ *
1102
+ * **Requires an unscoped key.** A scoped key is refused with 403
1103
+ * `ACCOUNT_SCOPE_REQUIRED`, because there is no workspace-scoped view of one shared
1104
+ * balance, ledger and set of saved cards — and because a scoped key is meant to be
1105
+ * handed to an end user, who should not be reading your card details or spending
1106
+ * against them. For per-workspace spend, use {@link MetricsAPI.cost} instead.
1101
1107
  */
1102
1108
  declare class BillingAPI {
1103
1109
  private readonly client;
@@ -1125,6 +1131,7 @@ interface VolumeInfo {
1125
1131
  createdAt: number;
1126
1132
  }
1127
1133
  interface CreateVolumeOpts extends ConnectionOpts {
1134
+ /** Whole GB, default 5. New volumes allow 1–50 GB unless the server config sets another maximum. Existing volumes are never resized. */
1128
1135
  sizeGb?: number;
1129
1136
  /**
1130
1137
  * Region to place the volume in, e.g. `'us-east-1'`. A volume is node-local, so
@@ -1281,19 +1288,36 @@ declare class Lizard {
1281
1288
  /**
1282
1289
  * The account this credential belongs to — the SDK's `lizard whoami`.
1283
1290
  *
1284
- * Works for a scoped key as well as a full one: the identity is the account that
1285
- * created the key, which is what the key's usage bills to.
1291
+ * A **scoped** key gets identity only: `id`, `username`, `avatarUrl`, `scoped: true`
1292
+ * and the key's own `scopes`. The account's email, balance, plan and billing status
1293
+ * are withheld — they belong to the account, not to the key holder, and a scoped key
1294
+ * is meant to be handed to an end user or injected into a sandbox. An unscoped key
1295
+ * or a session sees the full account.
1296
+ *
1297
+ * Reading back `scopes` is the cheapest way to answer "what can this key reach".
1286
1298
  */
1287
1299
  whoami(): Promise<Account>;
1288
1300
  /** The underlying HTTP client, for endpoints this SDK does not wrap yet. */
1289
1301
  get platform(): PlatformClient;
1290
1302
  }
1291
- /** The account behind a credential — see {@link Lizard.whoami}. */
1303
+ /**
1304
+ * The account behind a credential — see {@link Lizard.whoami}.
1305
+ *
1306
+ * Everything past `avatarUrl` is present only for an unscoped key or a session; a
1307
+ * scoped key gets `scoped: true` and `scopes` in their place.
1308
+ */
1292
1309
  interface Account {
1293
1310
  id: string;
1294
1311
  username: string;
1295
- email?: string | null;
1296
1312
  avatarUrl?: string | null;
1313
+ /** True when the calling key is scoped, meaning the account fields below are absent. */
1314
+ scoped?: boolean;
1315
+ /** What the calling key may reach. Present when `scoped` is true. */
1316
+ scopes?: Array<{
1317
+ type: 'workspace' | 'project';
1318
+ id: string;
1319
+ }>;
1320
+ email?: string | null;
1297
1321
  plan?: string;
1298
1322
  billingStatus?: string;
1299
1323
  balanceCents?: number;
package/dist/index.js CHANGED
@@ -1354,8 +1354,13 @@ var Lizard = class {
1354
1354
  /**
1355
1355
  * The account this credential belongs to — the SDK's `lizard whoami`.
1356
1356
  *
1357
- * Works for a scoped key as well as a full one: the identity is the account that
1358
- * created the key, which is what the key's usage bills to.
1357
+ * A **scoped** key gets identity only: `id`, `username`, `avatarUrl`, `scoped: true`
1358
+ * and the key's own `scopes`. The account's email, balance, plan and billing status
1359
+ * are withheld — they belong to the account, not to the key holder, and a scoped key
1360
+ * is meant to be handed to an end user or injected into a sandbox. An unscoped key
1361
+ * or a session sees the full account.
1362
+ *
1363
+ * Reading back `scopes` is the cheapest way to answer "what can this key reach".
1359
1364
  */
1360
1365
  async whoami() {
1361
1366
  return this.platform.get("/api/auth/me");
package/dist/index.mjs CHANGED
@@ -1307,8 +1307,13 @@ var Lizard = class {
1307
1307
  /**
1308
1308
  * The account this credential belongs to — the SDK's `lizard whoami`.
1309
1309
  *
1310
- * Works for a scoped key as well as a full one: the identity is the account that
1311
- * created the key, which is what the key's usage bills to.
1310
+ * A **scoped** key gets identity only: `id`, `username`, `avatarUrl`, `scoped: true`
1311
+ * and the key's own `scopes`. The account's email, balance, plan and billing status
1312
+ * are withheld — they belong to the account, not to the key holder, and a scoped key
1313
+ * is meant to be handed to an end user or injected into a sandbox. An unscoped key
1314
+ * or a session sees the full account.
1315
+ *
1316
+ * Reading back `scopes` is the cheapest way to answer "what can this key reach".
1312
1317
  */
1313
1318
  async whoami() {
1314
1319
  return this.platform.get("/api/auth/me");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lizard-build/sdk",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
4
4
  "description": "Firecracker microVM sandboxes for AI agents — boot Linux in milliseconds, run code, write files, expose ports over HTTPS, then pause a session with memory intact and resume it later. TypeScript SDK for Lizard Sandboxes (lizard.build).",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",