@shardflux/sdk 0.7.0 → 0.9.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.
@@ -0,0 +1,469 @@
1
+ /**
2
+ * The account plane with a user session (0.9.0; contracts §30): what a person does in the web app, from code.
3
+ *
4
+ * // Before a session exists (no token needed)
5
+ * await ShardfluxAccount.register({ email, password, displayName });
6
+ * await ShardfluxAccount.verifyEmail(linkFromTheEmail);
7
+ * const { account, result } = await ShardfluxAccount.login({ email, password, onSessionToken: (s) => save(s.token) });
8
+ * if (result.status === 'mfa_required') await account.auth.completeMfa({ code });
9
+ *
10
+ * // Later, with the saved token
11
+ * const account = new ShardfluxAccount({ sessionToken: 'sfu_...', onSessionToken: (s) => save(s.token) });
12
+ * const org = await account.organizations.create({ name: 'Acme' });
13
+ *
14
+ * A CLI session token (`sfu_<43 base64url chars>`) is sent as `Authorization: Bearer` on /v1. The API rotates it on
15
+ * login completion, step-up, password change and TOTP confirm/disable (the previous token is revoked):
16
+ * `account.sessionToken` always holds the current one, and `onSessionToken` is called with each new token. Methods
17
+ * that need a recent password check answer 403 `step_up_required` (call `auth.stepUp()` and retry); a session still
18
+ * waiting for its second factor gets 403 `mfa_required`, an unverified email 403 `email_unverified`.
19
+ */
20
+ import type { operations } from './generated/app-api.js';
21
+ import { BillingApi, WorkspacesApi } from './client.js';
22
+ import type { ClientContext, Me, WorkspaceView } from './client.js';
23
+ import type { RequestOptions } from './http.js';
24
+ import { AuditApi } from './audit.js';
25
+ import type { AuditFilters } from './audit.js';
26
+ import { EgressPolicyApi } from './egress.js';
27
+ import type { AccountFeedbackParams, FeedbackReceipt } from './feedback.js';
28
+ import { SecretsApi } from './secrets.js';
29
+ import { TemplatesApi } from './templates.js';
30
+ import type { TemplateDetail } from './templates.js';
31
+ import { UsageApi } from './usage.js';
32
+ import type { SpendPolicy } from './usage.js';
33
+ import { VolumesApi } from './volumes.js';
34
+ import type { VersionCheckOption } from './version-check.js';
35
+ import type { ProgressListener } from './progress.js';
36
+ type JsonOf<R> = R extends {
37
+ content: {
38
+ 'application/json': infer T;
39
+ };
40
+ } ? T : never;
41
+ type Ok<Op> = Op extends {
42
+ responses: infer R;
43
+ } ? {
44
+ [K in keyof R]: K extends 200 | 201 | 202 ? JsonOf<R[K]> : never;
45
+ }[keyof R] : never;
46
+ export type RegisterResult = Ok<operations['postV1AuthRegister']>;
47
+ export type VerifyEmailResult = Ok<operations['postV1AuthVerifyEmail']>;
48
+ export type PasswordResetRequestResult = Ok<operations['postV1AuthPasswordResetRequest']>;
49
+ export type PasswordResetConfirmResult = Ok<operations['postV1AuthPasswordResetConfirm']>;
50
+ export type EmailChangeResult = Ok<operations['postV1AuthEmailChange']>;
51
+ export type EmailChangeConfirmResult = Ok<operations['postV1AuthEmailChangeConfirm']>;
52
+ export type ResendVerificationResult = Ok<operations['postV1AuthVerifyEmailResend']>;
53
+ /** Login (and MFA challenge) answer: `status` `authenticated` or `mfa_required`, with the new `session_token`. */
54
+ export type LoginResult = Ok<operations['postV1AuthLogin']>;
55
+ export type MfaChallengeResult = Ok<operations['postV1AuthMfaChallenge']>;
56
+ export type AuthUser = NonNullable<LoginResult['user']>;
57
+ /** GET /v1/auth/session: `state` anonymous | mfa_required | authenticated, the user and the session. */
58
+ export type AuthSessionState = Ok<operations['getV1AuthSession']>;
59
+ export type AuthSessionPage = Ok<operations['getV1AuthSessions']>;
60
+ /** One of the user's sessions (`client`: browser or cli; `current`: the one making the request). */
61
+ export type AuthSessionInfo = AuthSessionPage['data'][number];
62
+ export type StepUpResult = Ok<operations['postV1AuthStepUp']>;
63
+ export type PasswordChangeResult = Ok<operations['postV1AuthPasswordChange']>;
64
+ export type TotpEnrollment = Ok<operations['postV1AuthMfaTotpEnroll']>;
65
+ export type TotpConfirmResult = Ok<operations['postV1AuthMfaTotpConfirm']>;
66
+ export type TotpDisableResult = Ok<operations['postV1AuthMfaTotpDisable']>;
67
+ export type RecoveryCodes = Ok<operations['postV1AuthMfaRecoveryCodes']>;
68
+ export type Organization = Ok<operations['getV1OrganizationsOrganizationId']>;
69
+ export type OrganizationPage = Ok<operations['getV1Organizations']>;
70
+ export type OrganizationRole = Organization['role'];
71
+ export type OrganizationDeletion = Ok<operations['getV1OrganizationsOrganizationIdDeletion']>;
72
+ export type OrganizationDeletionResult = Ok<operations['postV1OrganizationsOrganizationIdDeletion']>;
73
+ /** An account or organization data export (JSON; `state` ready | expired). */
74
+ export type DataExport = Ok<operations['getV1AccountExportsExportId']>;
75
+ export type OrganizationWorkspacePage = Ok<operations['getV1OrganizationsOrganizationIdWorkspaces']>;
76
+ export type Project = Ok<operations['getV1ProjectsProjectId']>;
77
+ export type ProjectPage = Ok<operations['getV1OrganizationsOrganizationIdProjects']>;
78
+ export type ApiKeyPage = Ok<operations['getV1ProjectsProjectIdApiKeys']>;
79
+ export type ApiKey = ApiKeyPage['data'][number];
80
+ /** The created key (`api_key`) and its `secret` (the `sfk_...` key, shown once). */
81
+ export type CreatedApiKey = Ok<operations['postV1ProjectsProjectIdApiKeys']>;
82
+ export type ApiKeyToolPermission = ApiKey['tool_permissions'][number];
83
+ export type MemberPage = Ok<operations['getV1OrganizationsOrganizationIdMembers']>;
84
+ export type Member = MemberPage['data'][number];
85
+ export type MemberRole = Member['role'];
86
+ export type InvitationPage = Ok<operations['getV1OrganizationsOrganizationIdInvitations']>;
87
+ export type Invitation = InvitationPage['data'][number];
88
+ /** A Checkout intent: `url` is where a person pays; `subscription_active` turns true once the webhook activated it. */
89
+ export type CheckoutStatus = Ok<operations['getV1OrganizationsOrganizationIdBillingCheckoutSessionsCheckoutId']>;
90
+ export type BillingPortalSession = Ok<operations['postV1OrganizationsOrganizationIdBillingPortalSessions']>;
91
+ export type BillingInvoicePage = Ok<operations['getV1OrganizationsOrganizationIdBillingInvoices']>;
92
+ export type AccountDeletion = Ok<operations['getV1AccountDeletion']>;
93
+ export type AccountDeletionScheduled = Ok<operations['postV1AccountDeletion']>;
94
+ export type AccountDeletionCanceled = Ok<operations['deleteV1AccountDeletion']>;
95
+ /** A new session token and when it expires (idle expiry, sliding). */
96
+ export interface SessionTokenUpdate {
97
+ token: string;
98
+ expiresAt: string;
99
+ }
100
+ export interface ShardfluxAccountOptions {
101
+ /** A CLI session token, `sfu_<token>`. Omitted: only the pre-session calls work until `login` gives one. */
102
+ sessionToken?: string;
103
+ /** Default https://api.shardflux.dev. */
104
+ baseUrl?: string;
105
+ /** Default: the runtime's fetch, with `Connection: close` on Node 26 (see defaultFetch in http.ts). */
106
+ fetch?: typeof fetch;
107
+ userAgent?: string;
108
+ /** Per-request timeout (ms), default 30 s. */
109
+ timeoutMs?: number;
110
+ /** Retries of safe/idempotent requests on transient failures, default 2. */
111
+ maxRetries?: number;
112
+ /** Injected for tests; defaults to setTimeout. */
113
+ sleep?: (ms: number) => Promise<void>;
114
+ /**
115
+ * Called with every new token (login, completeMfa, stepUp, changePassword, totp.confirm, totp.disable), after
116
+ * `sessionToken` changed; the previous token no longer works. A returned promise is awaited, and an error from the
117
+ * callback rejects the call that rotated the token (the rotation itself already happened).
118
+ */
119
+ onSessionToken?: (session: SessionTokenUpdate) => void | Promise<void>;
120
+ /** The automatic version check (see ShardfluxOptions.versionCheck). */
121
+ versionCheck?: VersionCheckOption;
122
+ /** Progress of traced calls (volume and workspace operation waits). */
123
+ onProgress?: ProgressListener;
124
+ }
125
+ /** Client options of the static pre-session calls. */
126
+ export type AccountClientOptions = Omit<ShardfluxAccountOptions, 'sessionToken'>;
127
+ export interface PageParams {
128
+ limit?: number;
129
+ cursor?: string;
130
+ }
131
+ /** The shape of a CLI session token. */
132
+ export declare const SESSION_TOKEN_PATTERN: RegExp;
133
+ /** True when `value` has the shape of a CLI session token (`sfu_` + 43 base64url characters). */
134
+ export declare function isSessionToken(value: unknown): value is string;
135
+ /**
136
+ * The token of an emailed link (`<app>/auth/verify-email#token=...`, `/auth/reset-password#token=...`,
137
+ * `/auth/confirm-email-change#token=...`, `/invitations/accept#token=...`): the `token` of its `#` fragment, else of
138
+ * its `?` query, percent-decoded. Input that is not a link is the token itself (trimmed). Throws for an empty input
139
+ * and for a link without a token.
140
+ */
141
+ export declare function parseEmailToken(input: string): string;
142
+ /** Internal wiring shared with the namespaces of one ShardfluxAccount. */
143
+ export interface AccountCore {
144
+ ctx: () => ClientContext;
145
+ /** Adopts the `session_token` of a response (rotation), then calls onSessionToken. */
146
+ adopt<T>(body: T): Promise<T>;
147
+ }
148
+ export declare class AccountTotpApi {
149
+ #private;
150
+ constructor(core: AccountCore);
151
+ /** Starts TOTP enrollment: the `secret` and `otpauth_uri` for an authenticator app (confirm with a code). */
152
+ enroll(): Promise<TotpEnrollment>;
153
+ /** Confirms enrollment with a current code: returns the recovery codes (shown once). Rotates the session token. */
154
+ confirm(code: string): Promise<TotpConfirmResult>;
155
+ /** Turns TOTP off (needs a recent step-up). Rotates the session token. */
156
+ disable(): Promise<TotpDisableResult>;
157
+ /** New recovery codes (the old ones stop working; needs a recent step-up). */
158
+ regenerateRecoveryCodes(): Promise<RecoveryCodes>;
159
+ }
160
+ export declare class AccountAuthApi {
161
+ #private;
162
+ /** Authenticator-app second factor. */
163
+ readonly totp: AccountTotpApi;
164
+ constructor(core: AccountCore);
165
+ /** The session's state (`anonymous`, `mfa_required`, `authenticated`), its user and expiry. */
166
+ session(): Promise<AuthSessionState>;
167
+ /** Completes a login that answered `mfa_required`, with a TOTP code or a recovery code. Rotates the session token. */
168
+ completeMfa(params: {
169
+ code: string;
170
+ } | {
171
+ recoveryCode: string;
172
+ }): Promise<MfaChallengeResult>;
173
+ /** Ends this session (the token stops working; `sessionToken` keeps the revoked value). */
174
+ logout(): Promise<void>;
175
+ /** Ends every session of the user, this one included. */
176
+ logoutAll(): Promise<void>;
177
+ /** The user's sessions (browser and CLI; `current` marks this one). */
178
+ sessions(): Promise<AuthSessionPage>;
179
+ revokeSession(sessionId: string): Promise<void>;
180
+ /**
181
+ * Confirms the password (and a code when MFA is on) for the calls that need a recent check (403
182
+ * `step_up_required`). Rotates the session token.
183
+ */
184
+ stepUp(params: {
185
+ password: string;
186
+ code?: string;
187
+ recoveryCode?: string;
188
+ }): Promise<StepUpResult>;
189
+ /** Changes the password; every other session is revoked. Rotates the session token. */
190
+ changePassword(params: {
191
+ currentPassword: string;
192
+ newPassword: string;
193
+ }): Promise<PasswordChangeResult>;
194
+ /** Sends a confirmation link to the new address (confirm with ShardfluxAccount.confirmEmailChange). */
195
+ changeEmail(newEmail: string): Promise<EmailChangeResult>;
196
+ /** Sends the verification email again. */
197
+ resendVerification(): Promise<ResendVerificationResult>;
198
+ }
199
+ export declare class OrganizationExportsApi {
200
+ #private;
201
+ constructor(core: AccountCore);
202
+ /** Builds a JSON export of the organization (owners/admins; needs a recent step-up). */
203
+ create(organizationId: string): Promise<DataExport>;
204
+ get(organizationId: string, exportId: string): Promise<DataExport>;
205
+ /** The export document (JSON text). */
206
+ download(organizationId: string, exportId: string, opts?: {
207
+ signal?: AbortSignal;
208
+ }): Promise<string>;
209
+ }
210
+ export interface OrganizationWorkspacesParams extends PageParams {
211
+ projectId?: string;
212
+ state?: WorkspaceView['observed_state'];
213
+ desiredState?: WorkspaceView['desired_state'];
214
+ keyPrefix?: string;
215
+ includeDeleted?: boolean;
216
+ lifetime?: 'persistent' | 'session' | 'any';
217
+ purpose?: 'standard' | 'template_draft' | 'template_test' | 'any';
218
+ }
219
+ export declare class AccountOrganizationsApi {
220
+ #private;
221
+ /** Data exports of an organization. */
222
+ readonly exports: OrganizationExportsApi;
223
+ constructor(core: AccountCore);
224
+ /** One page of the user's organizations (with the user's `role`). */
225
+ list(params?: PageParams): Promise<OrganizationPage>;
226
+ /** Every organization of the user, following next_cursor. */
227
+ listAll(params?: {
228
+ limit?: number;
229
+ }): AsyncGenerator<Organization>;
230
+ /** Creates an organization; the user becomes its owner. */
231
+ create(params: {
232
+ name: string;
233
+ slug?: string;
234
+ }): Promise<Organization>;
235
+ get(organizationId: string): Promise<Organization>;
236
+ /** The organization's plan, allowances and limits. */
237
+ entitlements(organizationId: string): Promise<Ok<operations['getV1OrganizationsOrganizationIdEntitlements']>>;
238
+ /** The deletion state: a scheduled request, what blocks it (an active subscription) and what would be removed. */
239
+ deletion(organizationId: string): Promise<OrganizationDeletion>;
240
+ /** Deletes the organization (owners; needs a recent step-up). `confirmation` is the organization's slug. */
241
+ delete(organizationId: string, params: {
242
+ confirmation: string;
243
+ }): Promise<OrganizationDeletionResult>;
244
+ /** One page of the organization's workspaces (views, across its projects unless `projectId`). */
245
+ workspaces(organizationId: string, params?: OrganizationWorkspacesParams): Promise<OrganizationWorkspacePage>;
246
+ }
247
+ export declare class AccountProjectsApi {
248
+ #private;
249
+ constructor(core: AccountCore);
250
+ list(organizationId: string, params?: PageParams): Promise<ProjectPage>;
251
+ /** Every project of the organization, following next_cursor. */
252
+ listAll(organizationId: string, params?: {
253
+ limit?: number;
254
+ }): AsyncGenerator<Project>;
255
+ create(organizationId: string, params: {
256
+ name: string;
257
+ slug?: string;
258
+ }): Promise<Project>;
259
+ get(projectId: string): Promise<Project>;
260
+ }
261
+ /** Every tool permission an API key can carry (pass it as `toolPermissions` for a key with every tool). */
262
+ export declare const API_KEY_TOOL_PERMISSIONS: readonly ApiKeyToolPermission[];
263
+ export interface CreateApiKeyParams {
264
+ name: string;
265
+ /**
266
+ * The workspace tools the key may use (a subset of API_KEY_TOOL_PERMISSIONS). Default [] (no tools: read-only API
267
+ * use). Billing members may only create keys without tools.
268
+ */
269
+ toolPermissions?: readonly ApiKeyToolPermission[];
270
+ /** Between 1 minute and 366 days from now; omitted: the key does not expire. */
271
+ expiresAt?: string | Date;
272
+ /** Default: a fresh key per call, so a transport retry replays the creation (and returns the same secret) instead of creating a second key. */
273
+ idempotencyKey?: string;
274
+ }
275
+ export declare class AccountApiKeysApi {
276
+ #private;
277
+ constructor(core: AccountCore);
278
+ list(projectId: string, params?: PageParams): Promise<ApiKeyPage>;
279
+ /** Creates a project API key: `secret` is the `sfk_...` key, shown once (an Idempotency-Key replay within 24 h returns it again). */
280
+ create(projectId: string, params: CreateApiKeyParams): Promise<CreatedApiKey>;
281
+ revoke(projectId: string, apiKeyId: string): Promise<void>;
282
+ }
283
+ export declare class AccountMembersApi {
284
+ #private;
285
+ constructor(core: AccountCore);
286
+ list(organizationId: string, params?: PageParams): Promise<MemberPage>;
287
+ update(organizationId: string, userId: string, params: {
288
+ role: MemberRole;
289
+ }): Promise<Member>;
290
+ remove(organizationId: string, userId: string): Promise<void>;
291
+ }
292
+ export declare class AccountInvitationsApi {
293
+ #private;
294
+ constructor(core: AccountCore);
295
+ list(organizationId: string, params?: PageParams): Promise<InvitationPage>;
296
+ /** Invites an email address (the invitee gets a link; accept with invitations.accept). */
297
+ create(organizationId: string, params: {
298
+ email: string;
299
+ role: MemberRole;
300
+ }): Promise<Invitation>;
301
+ revoke(organizationId: string, invitationId: string): Promise<void>;
302
+ /** Accepts an invitation with the emailed link (or its token): returns the organization joined. */
303
+ accept(linkOrToken: string): Promise<Organization>;
304
+ }
305
+ export interface WaitForCheckoutOptions {
306
+ /** Give up after this long (default 900 000 ms = 15 min): CheckoutTimeoutError. The checkout stays open. */
307
+ timeoutMs?: number;
308
+ /** Delay between polls (default 2000 ms). */
309
+ intervalMs?: number;
310
+ signal?: AbortSignal;
311
+ }
312
+ /**
313
+ * waitForCheckout gave up (0.9.0): nobody paid within `timeoutMs`, or the payment's webhook has not activated the
314
+ * subscription yet. The checkout stays usable; `checkout` is its last status.
315
+ */
316
+ export declare class CheckoutTimeoutError extends Error {
317
+ readonly checkout: CheckoutStatus;
318
+ readonly waitedMs: number;
319
+ constructor(checkout: CheckoutStatus, waitedMs: number);
320
+ }
321
+ /**
322
+ * Billing with a user session: the catalog and subscription (as for API keys) plus Checkout, the Stripe portal,
323
+ * invoices and usage alert thresholds (owner/billing members).
324
+ */
325
+ export declare class AccountBillingApi extends BillingApi {
326
+ #private;
327
+ constructor(core: AccountCore);
328
+ /**
329
+ * Starts (or reuses) a Stripe Checkout for `planKey`: a person pays at `url`. 409 `subscription_exists` when the
330
+ * organization already has a subscription (change plans in the portal).
331
+ */
332
+ checkout(organizationId: string, params: {
333
+ planKey: string;
334
+ }): Promise<CheckoutStatus>;
335
+ checkoutStatus(organizationId: string, checkoutId: string): Promise<CheckoutStatus>;
336
+ /**
337
+ * Polls the checkout until the subscription is active (`subscription_active`) or the checkout ended without one
338
+ * (`expired`, `canceled`, `failed`) and returns that final status. Throws CheckoutTimeoutError after `timeoutMs`,
339
+ * and the signal's reason when aborted.
340
+ */
341
+ waitForCheckout(organizationId: string, checkoutId: string, opts?: WaitForCheckoutOptions): Promise<CheckoutStatus>;
342
+ /** A Stripe customer portal link (plan changes, payment methods, cancellation). */
343
+ portal(organizationId: string): Promise<BillingPortalSession>;
344
+ invoices(organizationId: string, params?: PageParams): Promise<BillingInvoicePage>;
345
+ /** Usage alert thresholds. */
346
+ spendPolicy(organizationId: string): Promise<SpendPolicy>;
347
+ /** Sets the usage alert thresholds (percent of the allowance, 1..100, at most 5; [] turns alerts off). */
348
+ setSpendPolicy(organizationId: string, params: {
349
+ alertThresholdsPercent: number[];
350
+ }): Promise<SpendPolicy>;
351
+ }
352
+ export declare class AccountExportsApi {
353
+ #private;
354
+ constructor(core: AccountCore);
355
+ /** Builds a JSON export of the user's own data (needs a recent step-up). */
356
+ create(): Promise<DataExport>;
357
+ get(exportId: string): Promise<DataExport>;
358
+ /** The export document (JSON text; needs a recent step-up). */
359
+ download(exportId: string, opts?: {
360
+ signal?: AbortSignal;
361
+ }): Promise<string>;
362
+ }
363
+ /** The signed-in person: account deletion and data export. */
364
+ export declare class AccountUserApi {
365
+ #private;
366
+ readonly exports: AccountExportsApi;
367
+ constructor(core: AccountCore);
368
+ /** The deletion state: a scheduled request, the organizations that block it, the API keys that survive it. */
369
+ deletion(): Promise<AccountDeletion>;
370
+ /** Schedules deletion of the account after the grace period (needs a recent step-up). `confirmation` is the user's email. */
371
+ scheduleDeletion(params: {
372
+ confirmation: string;
373
+ }): Promise<AccountDeletionScheduled>;
374
+ cancelDeletion(): Promise<AccountDeletionCanceled>;
375
+ }
376
+ /** Organization templates with a user session: everything of TemplatesApi (pass `organizationId`) plus publish/archive. */
377
+ export declare class AccountTemplatesApi extends TemplatesApi {
378
+ #private;
379
+ constructor(core: AccountCore);
380
+ /** Publishes a registered version (owners/admins): `open` may use it. */
381
+ publishVersion(organizationId: string, slug: string, version: number): Promise<TemplateDetail>;
382
+ /** Archives a version (owners/admins): new opens stop using it; existing workspaces keep it. */
383
+ archiveVersion(organizationId: string, slug: string, version: number): Promise<TemplateDetail>;
384
+ }
385
+ export interface AuditExportParams extends AuditFilters {
386
+ /** Default `ndjson` (parse with parseAuditNdjson). */
387
+ format?: 'csv' | 'ndjson';
388
+ signal?: AbortSignal;
389
+ /** Request timeout (ms), default 120 s (an export is at most 50 000 rows over at most 90 days). */
390
+ timeoutMs?: number;
391
+ }
392
+ /** The organization audit log (owners/admins) plus its CSV/NDJSON export. */
393
+ export declare class AccountAuditApi extends AuditApi {
394
+ #private;
395
+ constructor(core: AccountCore);
396
+ /** The export as text: NDJSON (one AuditEvent per line) or CSV with a header row. */
397
+ export(organizationId: string, params?: AuditExportParams): Promise<string>;
398
+ }
399
+ type PreSession<P> = P & AccountClientOptions;
400
+ /**
401
+ * A user (CLI) session on the Shardflux API: accounts, organizations, projects, API keys, members, invitations,
402
+ * billing, audit, data export and deletion, plus the project namespaces (usage, secrets, egress, volumes) with explicit
403
+ * organization/project ids. See the module comment for the token lifecycle.
404
+ */
405
+ export declare class ShardfluxAccount {
406
+ #private;
407
+ readonly auth: AccountAuthApi;
408
+ readonly organizations: AccountOrganizationsApi;
409
+ readonly projects: AccountProjectsApi;
410
+ readonly apiKeys: AccountApiKeysApi;
411
+ readonly members: AccountMembersApi;
412
+ readonly invitations: AccountInvitationsApi;
413
+ readonly billing: AccountBillingApi;
414
+ /** The signed-in person (account deletion, data export). */
415
+ readonly user: AccountUserApi;
416
+ readonly templates: AccountTemplatesApi;
417
+ readonly audit: AccountAuditApi;
418
+ readonly usage: UsageApi;
419
+ readonly secrets: SecretsApi;
420
+ readonly egress: EgressPolicyApi;
421
+ readonly volumes: VolumesApi;
422
+ /** Workspace routes with the session (pass `projectId` where a route needs a project, e.g. open). */
423
+ readonly workspaces: WorkspacesApi;
424
+ constructor(opts?: ShardfluxAccountOptions);
425
+ /** The current session token (rotations replace it), or null before login. */
426
+ get sessionToken(): string | null;
427
+ /** The signed-in user and their memberships. */
428
+ me(): Promise<Me>;
429
+ /**
430
+ * Send feedback straight to the Shardflux founder as the signed-in user (0.9.0+; POST /v1/feedback), optionally about
431
+ * one of your organizations (`organizationId`). Otherwise the same as `Shardflux.sendFeedback`: use it while you work,
432
+ * returns `{ id, receivedAt, duplicate }`, never retried, 429 `rate_limited` per user.
433
+ */
434
+ sendFeedback(params: AccountFeedbackParams): Promise<FeedbackReceipt>;
435
+ /** Raw access to any /v1 endpoint with the session's authentication and the SDK's error handling. */
436
+ request<T>(method: string, path: string, init?: RequestOptions): Promise<T>;
437
+ /** Creates an account; a verification link is emailed (`{ status: 'accepted' }` also when the email is taken). */
438
+ static register(params: PreSession<{
439
+ email: string;
440
+ password: string;
441
+ displayName?: string;
442
+ }>): Promise<RegisterResult>;
443
+ /**
444
+ * Verifies the email with the emailed link (or its token). `password_reset_required` (with `reset_token`): the
445
+ * account must set a password first (confirmPasswordReset with that token).
446
+ */
447
+ static verifyEmail(linkOrToken: string, opts?: AccountClientOptions): Promise<VerifyEmailResult>;
448
+ /** Emails a password reset link (`{ status: 'accepted' }` whether or not the account exists). */
449
+ static requestPasswordReset(email: string, opts?: AccountClientOptions): Promise<PasswordResetRequestResult>;
450
+ /** Sets a new password with the emailed reset link (or its token); every session is revoked. */
451
+ static confirmPasswordReset(params: {
452
+ token: string;
453
+ newPassword: string;
454
+ }, opts?: AccountClientOptions): Promise<PasswordResetConfirmResult>;
455
+ /** Confirms an email change with the link sent to the new address (or its token). */
456
+ static confirmEmailChange(linkOrToken: string, opts?: AccountClientOptions): Promise<EmailChangeConfirmResult>;
457
+ /**
458
+ * Signs in: `account` holds the new session (onSessionToken is called with it). `result.status` `mfa_required`: the
459
+ * session is pending until `account.auth.completeMfa({ code })` (which rotates the token).
460
+ */
461
+ static login(params: PreSession<{
462
+ email: string;
463
+ password: string;
464
+ }>): Promise<{
465
+ account: ShardfluxAccount;
466
+ result: LoginResult;
467
+ }>;
468
+ }
469
+ export {};