@sylphx/sdk 0.11.0 → 0.11.1
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/dist/index.d.ts +1588 -1226
- package/dist/index.mjs +2294 -1131
- package/dist/index.mjs.map +1 -1
- package/dist/nextjs/index.mjs +3 -0
- package/dist/nextjs/index.mjs.map +1 -1
- package/dist/react/index.mjs +57 -39
- package/dist/react/index.mjs.map +1 -1
- package/dist/server/index.d.ts +15 -1
- package/dist/server/index.mjs +34 -3
- package/dist/server/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export { DEFAULT_MACHINE_SIZE, MACHINE_CONFIGS, MACHINE_MAX_INSTANCES, MACHINE_RESOURCE_REQUIREMENTS, MACHINE_SIZES, MachineConfig, MachineResourceRequirements, MachineTierResources, isMachineSize, parseMachineSize, resolveMachineConfig, resolveMachineMaxInstances, resolveMachineResources, resolveMachineTierResources, toPublicMachineSize } from '@sylphx/contract/compute';
|
|
2
|
+
import { SdkBillingPlan, SdkBillingSubscription, BillingCheckoutRequest, BillingCheckoutResponse, BillingPortalRequest, BillingPortalResponse, BillingBalanceResponse, BillingUsageResponse, SdkConsentType, UserConsent as UserConsent$1, AIModel as AIModel$1, GetModelsResponse, GetRateLimitResponse, GetUsageResponse, ReferralLeaderboardEntry, ReferralRewardDefaults as ReferralRewardDefaults$1, WebhookDelivery as WebhookDelivery$1, OAuthTokenResponse, OAuthTokenErrorResponse, OAuthClientCredentialsResponse, LogoutInput, RefreshTokenInput, RefreshTokenResult, OAuthIntrospectResponse, PlatformPasswordChangeRequest, PlatformPasswordChangeResponse, PlatformPasswordSetRequest, PlatformPasswordSetResponse, PlatformPasswordStatusResponse, PlatformSessionRenameRequest, PlatformSessionRenameResponse, PlatformSessionRevokeAllResponse, PlatformSessionRevokeRequest, PlatformSessionRevokeOtherResponse, PlatformSessionRevokeResponse, PlatformSessionsListResponse, AuthUserDeleteRequest, AuthUserDeleteResponse, AuthUserExportResponse, DeviceApproveRequest, DeviceApproveResponse, DeviceDenyRequest, DeviceDenyResponse, DeviceInitResponse, DeviceInitRequest, DevicePollResponse, LoginRequest as LoginRequest$1, LoginResponse as LoginResponse$1, UserFullProfile as UserFullProfile$1, RegisterRequest as RegisterRequest$1, RegisterResponse as RegisterResponse$1, ResendEmailVerificationRequest as ResendEmailVerificationRequest$1, ResendEmailVerificationResponse as ResendEmailVerificationResponse$1, AuthTokensResponse, TwoFactorVerifyRequest as TwoFactorVerifyRequest$1, PlatformAuditQueryRequest, PlatformAuditQueryResponse, PlatformRateLimitStatusRequest, PlatformRateLimitStatusResponse, PlatformRateLimitStrategiesListRequest, PlatformRateLimitStrategiesListResponse, PlatformRateLimitStrategyDeleteRequest, PlatformRateLimitStrategyDeleteResponse, PlatformRateLimitStrategyUpsertRequest, PlatformRateLimitStrategyUpsertResponse, File as File$1, UploadId, FileId, TakedownFileRequest, TakedownFileResult, FileVersion, FileVersionId, CreateOrgInput as CreateOrgInput$1, InviteMemberInput as InviteMemberInput$1, OrgSdkRole, OrgInvitation, OrgMember, MembershipInfo, Organization, UpdateOrgInput as UpdateOrgInput$1, UserOrganizationMembership, UserOrganizationsResponse, MachineSize } from '@sylphx/contract';
|
|
2
3
|
export { BillingBalanceResponse as BalanceResponse, BillingCheckoutRequest as CheckoutRequest, BillingCheckoutResponse as CheckoutResponse, FileId, FileVersion, FileVersionId, FileVisibility, Organization, BillingPortalRequest as PortalRequest, BillingPortalResponse as PortalResponse, SignedUrlDisposition, File as StorageFile, UploadId, BillingUsageResponse as UsageResponse } from '@sylphx/contract';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -76,10 +77,80 @@ interface PlatformRealtimeDeleteChannelResult {
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
/**
|
|
79
|
-
*
|
|
80
|
+
* Database Pricing Configuration (SSOT)
|
|
81
|
+
*
|
|
82
|
+
* All database billing constants centralized here.
|
|
83
|
+
* Used by billing calculations, usage tracking, and cost display.
|
|
84
|
+
*
|
|
85
|
+
* Pricing Strategy:
|
|
86
|
+
* - Self-hosted infra on AX162-R: flat ~$270/month
|
|
87
|
+
* - Competitive pricing with 75-99% margins
|
|
88
|
+
*
|
|
89
|
+
* Customer Prices (updated for self-hosted, 2026-02):
|
|
90
|
+
* - Compute: $0.08/hour (25% below Neon $0.106/hr)
|
|
91
|
+
* - Storage: $0.25/GB-month (29% below Neon $0.35/GB)
|
|
92
|
+
* - Transfer: $0.09/GB (matches Supabase)
|
|
93
|
+
*/
|
|
94
|
+
/** Price per compute hour in microdollars ($0.08/hour = 80,000 microdollars) */
|
|
95
|
+
declare const COMPUTE_PRICE_PER_HOUR_MICRODOLLARS = 80000;
|
|
96
|
+
/** Free compute hours per month (platform free tier) */
|
|
97
|
+
declare const FREE_COMPUTE_HOURS = 3;
|
|
98
|
+
/** Price per GB-month in microdollars ($0.25/GB-month = 250,000 microdollars) */
|
|
99
|
+
declare const STORAGE_PRICE_PER_GB_MONTH_MICRODOLLARS = 250000;
|
|
100
|
+
/** Free storage in GB (256 MB) */
|
|
101
|
+
declare const FREE_STORAGE_GB = 0.25;
|
|
102
|
+
/** Price per GB data transfer ($0.09/GB = 90,000 microdollars) */
|
|
103
|
+
declare const TRANSFER_PRICE_PER_GB_MICRODOLLARS = 90000;
|
|
104
|
+
/** KV free storage in GB (256 MB) */
|
|
105
|
+
declare const KV_FREE_STORAGE_GB = 0.25;
|
|
106
|
+
/** Hours per month (AWS/GCP standard for billing) */
|
|
107
|
+
declare const HOURS_PER_MONTH = 730;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Referrals Configuration (SSOT)
|
|
111
|
+
*
|
|
112
|
+
* Single source of truth for referral system configuration.
|
|
113
|
+
* Used by: referral router, SDK referral endpoints
|
|
114
|
+
*/
|
|
115
|
+
/** Default points awarded per successful referral */
|
|
116
|
+
declare const DEFAULT_POINTS_REWARD = 100;
|
|
117
|
+
/** Number of months the referral discount is valid */
|
|
118
|
+
declare const DISCOUNT_DURATION_MONTHS = 3;
|
|
119
|
+
/** Default discount percentage */
|
|
120
|
+
declare const DISCOUNT_PERCENT = 20;
|
|
121
|
+
/** Premium trial days from referral */
|
|
122
|
+
declare const PREMIUM_TRIAL_DAYS = 7;
|
|
123
|
+
/**
|
|
124
|
+
* Generate a cryptographically secure referral code
|
|
125
|
+
*
|
|
126
|
+
* Uses crypto.getRandomValues for uniform random bytes (0-255).
|
|
127
|
+
* Since REFERRAL_CODE_CHARS has exactly 32 characters and 256 / 32 = 8,
|
|
128
|
+
* byte % 32 produces perfectly uniform distribution with zero modulo bias.
|
|
129
|
+
*
|
|
130
|
+
* Entropy: 8 chars * log2(32) = 40 bits (~1.1 trillion possible codes)
|
|
131
|
+
*
|
|
132
|
+
* Format: 8 uppercase alphanumeric characters (excluding ambiguous: 0, O, I, L, 1)
|
|
133
|
+
*/
|
|
134
|
+
declare function generateReferralCode(): string;
|
|
135
|
+
|
|
136
|
+
declare function getErrorMessage$1(error: unknown, fallback?: string): string;
|
|
137
|
+
interface ErrorDetails$1 {
|
|
138
|
+
message: string;
|
|
139
|
+
code?: string;
|
|
140
|
+
name?: string;
|
|
141
|
+
stack?: string;
|
|
142
|
+
status?: number;
|
|
143
|
+
cause?: unknown;
|
|
144
|
+
}
|
|
145
|
+
declare function getErrorDetails$1(error: unknown, fallbackMessage?: string): ErrorDetails$1;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Sylphx Connection URL — Single Source of Truth (ADR-123)
|
|
80
149
|
*
|
|
81
150
|
* Implements the canonical connection string format defined in ADR-055 §5.
|
|
82
|
-
* This is
|
|
151
|
+
* This module is the SDK-owned SSOT per ADR-123 (SDK/application boundary).
|
|
152
|
+
* Consuming applications MUST import from `@sylphx/sdk` rather than duplicating
|
|
153
|
+
* this logic.
|
|
83
154
|
*
|
|
84
155
|
* Hosted format:
|
|
85
156
|
* sylphx://{credential}@{tenant-slug}.api.sylphx.com[:port][/v{version}]
|
|
@@ -117,10 +188,38 @@ interface ParsedConnectionUrl {
|
|
|
117
188
|
/** Ready-to-use SDK base URL, always HTTPS (e.g. `https://bold-river-a1b2c3.api.sylphx.com/v1`) */
|
|
118
189
|
readonly apiBaseUrl: string;
|
|
119
190
|
}
|
|
191
|
+
interface BuildConnectionUrlInput {
|
|
192
|
+
/** Credential — must match the credential format regex */
|
|
193
|
+
readonly credential: string;
|
|
194
|
+
/** Resource slug — validated DNS label */
|
|
195
|
+
readonly slug: string;
|
|
196
|
+
/** SDK API domain suffix; defaults to `api.sylphx.com`. Use `sylphx.dev` for dev. */
|
|
197
|
+
readonly domain?: string;
|
|
198
|
+
/** API version suffix, e.g. `v1`. Defaults to `v1`. Pass empty string to omit. */
|
|
199
|
+
readonly version?: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Credential format — opaque token with type, env, optional project ref, and
|
|
203
|
+
* hex payload. Ref-scoped credentials are emitted by Platform app-env injection;
|
|
204
|
+
* legacy credentials without the ref remain valid for existing deploys.
|
|
205
|
+
*/
|
|
206
|
+
declare const CREDENTIAL_REGEX: RegExp;
|
|
120
207
|
declare class InvalidConnectionUrlError extends Error {
|
|
121
208
|
readonly code: "INVALID_CONNECTION_URL";
|
|
122
209
|
constructor(message: string);
|
|
123
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Build a canonical Sylphx connection URL.
|
|
213
|
+
*
|
|
214
|
+
* Throws `InvalidConnectionUrlError` if any component is malformed.
|
|
215
|
+
*/
|
|
216
|
+
declare function buildConnectionUrl(input: BuildConnectionUrlInput): string;
|
|
217
|
+
/**
|
|
218
|
+
* Parse a Sylphx connection URL into its structured components.
|
|
219
|
+
*
|
|
220
|
+
* Throws `InvalidConnectionUrlError` on any structural problem.
|
|
221
|
+
*/
|
|
222
|
+
declare function parseConnectionUrl(url: string): ParsedConnectionUrl;
|
|
124
223
|
|
|
125
224
|
/**
|
|
126
225
|
* SDK Configuration — ADR-055 Connection URL API
|
|
@@ -260,6 +359,666 @@ type SylphxConfigInput = string | SylphxClientInput;
|
|
|
260
359
|
*/
|
|
261
360
|
declare const createConfig: typeof createClient;
|
|
262
361
|
|
|
362
|
+
/**
|
|
363
|
+
* CSV utilities for browser and server SDK consumers.
|
|
364
|
+
*/
|
|
365
|
+
/**
|
|
366
|
+
* Escape a CSV field to handle commas, quotes, and newlines.
|
|
367
|
+
*
|
|
368
|
+
* Handles null/undefined by returning an empty field. Wraps values containing
|
|
369
|
+
* RFC 4180 special characters in double quotes and escapes internal quotes.
|
|
370
|
+
*/
|
|
371
|
+
declare function escapeCsvField(value: string | null | undefined): string;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Formatting Utilities
|
|
375
|
+
*
|
|
376
|
+
* Shared formatting functions for consistent display across the project.
|
|
377
|
+
*/
|
|
378
|
+
/**
|
|
379
|
+
* Calculate percentage with consistent rounding.
|
|
380
|
+
* SSOT for all success rate, completion rate calculations.
|
|
381
|
+
*
|
|
382
|
+
* @param count - The numerator (e.g., successful count)
|
|
383
|
+
* @param total - The denominator (e.g., total count)
|
|
384
|
+
* @param decimals - Number of decimal places (default: 2)
|
|
385
|
+
* @returns Percentage value (0-100)
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```ts
|
|
389
|
+
* calculatePercentage(75, 100) // 75
|
|
390
|
+
* calculatePercentage(1, 3) // 33.33
|
|
391
|
+
* calculatePercentage(0, 0) // 100 (safe division)
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
declare function calculatePercentage(count: number, total: number, decimals?: number): number;
|
|
395
|
+
/**
|
|
396
|
+
* Format microdollars to currency string
|
|
397
|
+
* @param microdollars Amount in microdollars (1 dollar = 1,000,000 microdollars)
|
|
398
|
+
* @param options Intl.NumberFormat options
|
|
399
|
+
*/
|
|
400
|
+
declare function formatMicrodollars(microdollars: number, options?: Intl.NumberFormatOptions): string;
|
|
401
|
+
/**
|
|
402
|
+
* Format cents to currency string
|
|
403
|
+
* @param cents Amount in cents (100 cents = 1 dollar)
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```ts
|
|
407
|
+
* formatCents(1999) // "$19.99"
|
|
408
|
+
* formatCents(100) // "$1.00"
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
declare function formatCents(cents: number): string;
|
|
412
|
+
/**
|
|
413
|
+
* Format dollars to currency string with optional compact notation
|
|
414
|
+
* @param amount Amount in dollars
|
|
415
|
+
* @param compact Use compact notation for large amounts (default: false)
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```ts
|
|
419
|
+
* formatCurrency(1999.99) // "$1,999.99"
|
|
420
|
+
* formatCurrency(1999.99, true) // "$2.0K"
|
|
421
|
+
* formatCurrency(1999.99, { currency: 'EUR' }) // "€1,999.99"
|
|
422
|
+
* formatCurrency(1999.99, { compact: true }) // "$2.0K"
|
|
423
|
+
* ```
|
|
424
|
+
*
|
|
425
|
+
* Second argument accepts either a bare `boolean` (back-compat for
|
|
426
|
+
* the historical `compact` flag) or an options object with
|
|
427
|
+
* `{ currency, compact }`. The options form is required for any UI
|
|
428
|
+
* surface that displays multi-currency amounts (billing, invoices,
|
|
429
|
+
* usage statements) — previously two local copies of this function
|
|
430
|
+
* lived in `billing-management.tsx` to work around the missing
|
|
431
|
+
* currency parameter.
|
|
432
|
+
*/
|
|
433
|
+
declare function formatCurrency(amount: number, optsOrCompact?: boolean | {
|
|
434
|
+
compact?: boolean;
|
|
435
|
+
currency?: string;
|
|
436
|
+
decimals?: number;
|
|
437
|
+
}): string;
|
|
438
|
+
/**
|
|
439
|
+
* Format percentage with sign for trend display
|
|
440
|
+
* @param value Percentage value (not multiplied by 100)
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```ts
|
|
444
|
+
* formatPercent(12.5) // "+12.5%"
|
|
445
|
+
* formatPercent(-5.2) // "-5.2%"
|
|
446
|
+
* formatPercent(0) // "+0.0%"
|
|
447
|
+
* ```
|
|
448
|
+
*/
|
|
449
|
+
declare function formatPercent(value: number): string;
|
|
450
|
+
/**
|
|
451
|
+
* Format number with abbreviated suffix (K, M, B) or compact notation
|
|
452
|
+
* @param num Number to format
|
|
453
|
+
* @param compact Use Intl compact notation (default: false, uses K/M/B suffix)
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* ```ts
|
|
457
|
+
* formatNumber(1234) // "1,234"
|
|
458
|
+
* formatNumber(1234567) // "1.2M"
|
|
459
|
+
* formatNumber(1234, true) // "1.2K" (Intl compact)
|
|
460
|
+
* ```
|
|
461
|
+
*/
|
|
462
|
+
declare function formatNumber(num: number, compact?: boolean): string;
|
|
463
|
+
/**
|
|
464
|
+
* Format duration in milliseconds to human-readable string.
|
|
465
|
+
* SSOT for latency display in traces, performance, and monitoring.
|
|
466
|
+
*
|
|
467
|
+
* @param ms Duration in milliseconds
|
|
468
|
+
* @returns Formatted string (e.g., "<1ms", "42ms", "1.23s")
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* ```ts
|
|
472
|
+
* formatDuration(0.5) // "<1ms"
|
|
473
|
+
* formatDuration(42) // "42ms"
|
|
474
|
+
* formatDuration(1500) // "1.50s"
|
|
475
|
+
* ```
|
|
476
|
+
*/
|
|
477
|
+
declare function formatDuration(ms: number): string;
|
|
478
|
+
/**
|
|
479
|
+
* Format bytes to human-readable string
|
|
480
|
+
* @param bytes Number of bytes
|
|
481
|
+
* @param decimals Number of decimal places (default: 1)
|
|
482
|
+
*/
|
|
483
|
+
declare function formatBytes(bytes: number | null | undefined, decimals?: number): string;
|
|
484
|
+
/** Badge variant type for consistency */
|
|
485
|
+
type BadgeVariant = 'default' | 'secondary' | 'success' | 'warning' | 'error' | 'outline';
|
|
486
|
+
/**
|
|
487
|
+
* Get billing status badge variant.
|
|
488
|
+
* Pure function — no side effects, deterministic output.
|
|
489
|
+
*
|
|
490
|
+
* @param status Billing account status
|
|
491
|
+
* @returns Badge variant for display
|
|
492
|
+
*/
|
|
493
|
+
declare function getBillingStatusVariant(status: string): BadgeVariant;
|
|
494
|
+
/**
|
|
495
|
+
* Get invoice status badge variant.
|
|
496
|
+
* Pure function — no side effects, deterministic output.
|
|
497
|
+
*
|
|
498
|
+
* @param status Invoice status
|
|
499
|
+
* @returns Badge variant for display
|
|
500
|
+
*/
|
|
501
|
+
declare function getInvoiceStatusVariant(status: string): BadgeVariant;
|
|
502
|
+
/**
|
|
503
|
+
* Format date for display
|
|
504
|
+
* @param date Date to format (null returns fallback)
|
|
505
|
+
* @param options Intl.DateTimeFormat options
|
|
506
|
+
* @param fallback Value to return when date is null (default: '-')
|
|
507
|
+
*/
|
|
508
|
+
declare function formatDate(date: Date | string | null, options?: Intl.DateTimeFormatOptions, fallback?: string): string;
|
|
509
|
+
/**
|
|
510
|
+
* Format date with time for display
|
|
511
|
+
* @param date Date to format (null returns fallback)
|
|
512
|
+
* @param options Override options
|
|
513
|
+
* @param fallback Value to return when date is null (default: '-')
|
|
514
|
+
*/
|
|
515
|
+
declare function formatDateTime(date: Date | string | null, options?: Intl.DateTimeFormatOptions, fallback?: string): string;
|
|
516
|
+
/**
|
|
517
|
+
* Format relative time (e.g., "2 hours ago")
|
|
518
|
+
*
|
|
519
|
+
* Uses native Intl.RelativeTimeFormat for proper localization.
|
|
520
|
+
*
|
|
521
|
+
* @param date Date to format (null returns 'Never')
|
|
522
|
+
*/
|
|
523
|
+
declare function formatRelativeTime(date: Date | string | null): string;
|
|
524
|
+
/**
|
|
525
|
+
* Format relative time in compact form (e.g., "2h ago", "3d ago").
|
|
526
|
+
* SSOT for dense UI contexts: tables, feeds, badges.
|
|
527
|
+
*
|
|
528
|
+
* Uses short suffixes (s/m/h/d/w) instead of Intl.RelativeTimeFormat words.
|
|
529
|
+
* For prose contexts, use {@link formatRelativeTime} instead.
|
|
530
|
+
*
|
|
531
|
+
* @param date Date to format (null returns 'Never')
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* ```ts
|
|
535
|
+
* formatRelativeTimeShort(new Date()) // "Just now"
|
|
536
|
+
* formatRelativeTimeShort('2024-01-01T00:00:00Z') // "3d ago"
|
|
537
|
+
* formatRelativeTimeShort(null) // "Never"
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
declare function formatRelativeTimeShort(date: Date | string | null): string;
|
|
541
|
+
/**
|
|
542
|
+
* Format month and year (e.g., "January 2024")
|
|
543
|
+
* SSOT for billing period display, invoice headers.
|
|
544
|
+
* @param date Date to format (null returns fallback)
|
|
545
|
+
* @param fallback Value to return when date is null
|
|
546
|
+
*/
|
|
547
|
+
declare function formatMonthYear(date: Date | string | null, fallback?: string): string;
|
|
548
|
+
/**
|
|
549
|
+
* Format time only (e.g., "2:30 PM")
|
|
550
|
+
* SSOT for log timestamps, activity feeds.
|
|
551
|
+
* @param date Date to format (null returns fallback)
|
|
552
|
+
* @param fallback Value to return when date is null
|
|
553
|
+
*/
|
|
554
|
+
declare function formatTime(date: Date | string | null, fallback?: string): string;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Safely parse a JSON string, returning a fallback value on failure instead of throwing.
|
|
558
|
+
*
|
|
559
|
+
* Use this when malformed input is a normal (non-exceptional) case — e.g. parsing
|
|
560
|
+
* user-provided data, localStorage values, or Redis cache entries where the caller
|
|
561
|
+
* simply wants a default on failure.
|
|
562
|
+
*
|
|
563
|
+
* For cases where parse failure is truly exceptional and the caller needs to handle
|
|
564
|
+
* the error explicitly, use a standard try-catch with proper logging instead.
|
|
565
|
+
*/
|
|
566
|
+
declare function safeJsonParse<T = unknown>(input: string, fallback?: T): T | null;
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* Utility Functions
|
|
570
|
+
*/
|
|
571
|
+
/**
|
|
572
|
+
* Get the base URL for API requests
|
|
573
|
+
*
|
|
574
|
+
* Use cases:
|
|
575
|
+
* - getBaseUrl(): For relative URLs in browser, absolute in SSR (tRPC, API calls)
|
|
576
|
+
* - getBaseUrl('origin'): For absolute URLs that need the actual origin (auth, sharing)
|
|
577
|
+
*
|
|
578
|
+
* Priority: NEXT_PUBLIC_APP_URL > localhost
|
|
579
|
+
*/
|
|
580
|
+
declare function getBaseUrl(mode?: 'relative' | 'origin'): string;
|
|
581
|
+
/**
|
|
582
|
+
* Escape HTML special characters to prevent XSS
|
|
583
|
+
*
|
|
584
|
+
* Uses single-pass regex replacement for efficiency.
|
|
585
|
+
*/
|
|
586
|
+
declare function escapeHtml(str: string): string;
|
|
587
|
+
/**
|
|
588
|
+
* Generate a URL-friendly slug from text
|
|
589
|
+
*
|
|
590
|
+
* @param text - Text to convert to slug
|
|
591
|
+
* @param maxLength - Optional maximum length (default: no limit)
|
|
592
|
+
* @returns Lowercase slug with hyphens
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* generateSlug('My Awesome App') // 'my-awesome-app'
|
|
596
|
+
* generateSlug('Hello World!') // 'hello-world'
|
|
597
|
+
* generateSlug('My Org Name', 48) // 'my-org-name' (max 48 chars)
|
|
598
|
+
*/
|
|
599
|
+
declare function generateSlug(text: string, maxLength?: number): string;
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* User Agent Parsing Utilities
|
|
603
|
+
*
|
|
604
|
+
* Extracts browser, OS, and device type from user agent strings.
|
|
605
|
+
* Simple implementation - no external dependencies.
|
|
606
|
+
*/
|
|
607
|
+
interface ParsedUserAgent {
|
|
608
|
+
browser: string | null;
|
|
609
|
+
os: string | null;
|
|
610
|
+
deviceType: 'desktop' | 'mobile' | 'tablet' | null;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Parse a user agent string to extract browser, OS, and device type.
|
|
614
|
+
* Returns null values if unable to determine.
|
|
615
|
+
*/
|
|
616
|
+
declare function parseUserAgent(ua: string): ParsedUserAgent;
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Authentication Configuration (SSOT)
|
|
620
|
+
*
|
|
621
|
+
* Single source of truth for authentication-related constants.
|
|
622
|
+
* Used by: validation schemas, auth forms, password policies
|
|
623
|
+
*/
|
|
624
|
+
/** Minimum password length */
|
|
625
|
+
declare const MIN_PASSWORD_LENGTH = 8;
|
|
626
|
+
/** Maximum password length */
|
|
627
|
+
declare const MAX_PASSWORD_LENGTH = 128;
|
|
628
|
+
/** Password requirements for display in UI */
|
|
629
|
+
declare const PASSWORD_REQUIREMENTS: {
|
|
630
|
+
readonly minLength: 8;
|
|
631
|
+
readonly maxLength: 128;
|
|
632
|
+
readonly description: "Must be at least 8 characters";
|
|
633
|
+
readonly placeholder: "Min. 8 characters";
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Billing Configuration (SSOT)
|
|
638
|
+
*
|
|
639
|
+
* Single source of truth for billing-related configuration.
|
|
640
|
+
* Used by: billing pages, usage tracking, invoicing
|
|
641
|
+
*/
|
|
642
|
+
/** Bytes per gigabyte — use instead of hardcoding 1024*1024*1024 */
|
|
643
|
+
declare const BYTES_PER_GB: number;
|
|
644
|
+
/** Microdollars per cent ($0.01 = 10,000 microdollars) */
|
|
645
|
+
declare const MICRODOLLARS_PER_CENT = 10000;
|
|
646
|
+
/** Invoice payment due after billing period ends (days) */
|
|
647
|
+
declare const INVOICE_DUE_DAYS = 15;
|
|
648
|
+
/**
|
|
649
|
+
* Billing metrics per service
|
|
650
|
+
* These are user-facing metric names (NOT technical terms like 'commands')
|
|
651
|
+
*/
|
|
652
|
+
declare const SERVICE_METRICS: {
|
|
653
|
+
readonly kv: {
|
|
654
|
+
readonly operations: "operations";
|
|
655
|
+
readonly storage: "storage";
|
|
656
|
+
};
|
|
657
|
+
readonly realtime: {
|
|
658
|
+
readonly messages: "messages";
|
|
659
|
+
readonly connections: "connections";
|
|
660
|
+
};
|
|
661
|
+
readonly ai: {
|
|
662
|
+
readonly tokens: "tokens";
|
|
663
|
+
};
|
|
664
|
+
readonly email: {
|
|
665
|
+
readonly emails: "emails";
|
|
666
|
+
readonly marketingEmails: "marketing_emails";
|
|
667
|
+
};
|
|
668
|
+
readonly notifications: {
|
|
669
|
+
readonly sends: "sends";
|
|
670
|
+
};
|
|
671
|
+
readonly analytics: {
|
|
672
|
+
readonly events: "events";
|
|
673
|
+
readonly forwarding: "forwarding";
|
|
674
|
+
};
|
|
675
|
+
readonly storage: {
|
|
676
|
+
readonly capacity: "capacity";
|
|
677
|
+
readonly uploads: "uploads";
|
|
678
|
+
readonly egress: "egress";
|
|
679
|
+
};
|
|
680
|
+
readonly auth: {
|
|
681
|
+
readonly mau: "mau";
|
|
682
|
+
};
|
|
683
|
+
readonly flags: {
|
|
684
|
+
readonly evaluations: "evaluations";
|
|
685
|
+
};
|
|
686
|
+
readonly consent: {
|
|
687
|
+
readonly records: "records";
|
|
688
|
+
};
|
|
689
|
+
readonly referrals: {
|
|
690
|
+
readonly conversions: "conversions";
|
|
691
|
+
};
|
|
692
|
+
readonly engagement: {
|
|
693
|
+
readonly operations: "operations";
|
|
694
|
+
};
|
|
695
|
+
readonly billing: {
|
|
696
|
+
readonly subscriptions: "subscriptions";
|
|
697
|
+
readonly usageRecords: "usage_records";
|
|
698
|
+
};
|
|
699
|
+
readonly search: {
|
|
700
|
+
readonly documents: "documents";
|
|
701
|
+
readonly searches: "searches";
|
|
702
|
+
};
|
|
703
|
+
readonly webhooks: {
|
|
704
|
+
readonly deliveries: "deliveries";
|
|
705
|
+
};
|
|
706
|
+
readonly monitoring: {
|
|
707
|
+
readonly errors: "errors";
|
|
708
|
+
};
|
|
709
|
+
readonly jobs: {
|
|
710
|
+
readonly invocations: "invocations";
|
|
711
|
+
readonly cronSchedules: "cron_schedules";
|
|
712
|
+
};
|
|
713
|
+
readonly database: {
|
|
714
|
+
readonly computeSeconds: "compute_seconds";
|
|
715
|
+
readonly storage: "storage";
|
|
716
|
+
readonly dataTransferBytes: "data_transfer_bytes";
|
|
717
|
+
};
|
|
718
|
+
readonly deploy: {
|
|
719
|
+
readonly buildMinutes: "build_minutes";
|
|
720
|
+
};
|
|
721
|
+
};
|
|
722
|
+
/** Active vCPU rate: $0.024/hr = $0.0004/min = 400 microdollars/min (ADR-034) */
|
|
723
|
+
declare const COMPUTE_VCPU_ACTIVE_RATE_MICRODOLLARS = 400;
|
|
724
|
+
/** Idle vCPU rate: $0.003/hr = $0.00005/min = 50 microdollars/min — 1/8 of active (ADR-034) */
|
|
725
|
+
declare const COMPUTE_VCPU_IDLE_RATE_MICRODOLLARS = 50;
|
|
726
|
+
/** RAM rate: $0.010/GB-hr = $0.000167/GB-min = 167 microdollars/GB-min (ADR-034) */
|
|
727
|
+
declare const COMPUTE_RAM_RATE_MICRODOLLARS = 167;
|
|
728
|
+
/** Build minute prices by machine type in microdollars per minute (ADR-034) */
|
|
729
|
+
declare const BUILD_MINUTE_PRICES: Record<string, number>;
|
|
730
|
+
/** Build minute size multipliers for quota tracking (ADR-034) */
|
|
731
|
+
declare const BUILD_SIZE_MULTIPLIERS: Record<string, number>;
|
|
732
|
+
/** Build minutes included per month by plan tier (ADR-034) */
|
|
733
|
+
declare const BUILD_MINUTES_INCLUDED: Record<string, number>;
|
|
734
|
+
/**
|
|
735
|
+
* @deprecated Use BUILD_MINUTE_PRICES.standard instead (ADR-034).
|
|
736
|
+
* Kept for backward compatibility with existing billing pipelines.
|
|
737
|
+
*
|
|
738
|
+
* CI compute-minute price in microdollars.
|
|
739
|
+
* Now references the standard build machine rate from ADR-034.
|
|
740
|
+
*/
|
|
741
|
+
declare const CI_BUILD_MINUTE_PRICE_MICRODOLLARS: number;
|
|
742
|
+
/**
|
|
743
|
+
* @deprecated Use BUILD_MINUTES_INCLUDED[plan] instead (ADR-034).
|
|
744
|
+
* Kept for backward compatibility. Maps to the `team` tier as the
|
|
745
|
+
* previous default (2,000 free minutes).
|
|
746
|
+
*/
|
|
747
|
+
declare const CI_FREE_MINUTES_PER_MONTH: number;
|
|
748
|
+
/**
|
|
749
|
+
* Size multipliers for CI compute-minute accounting (legacy GitHub labels).
|
|
750
|
+
*
|
|
751
|
+
* Keys are **GitHub Actions runner labels** (not build machine type names).
|
|
752
|
+
* These labels arrive on workflow_job webhooks and are stored as-is in
|
|
753
|
+
* githubCiJobs.resourceClass. The billing pipeline maps them to multipliers
|
|
754
|
+
* here; the build pipeline maps them to BuildMachineType via
|
|
755
|
+
* normalizeBuildMachineType() in build-machine.ts.
|
|
756
|
+
*
|
|
757
|
+
* @see BUILD_SIZE_MULTIPLIERS for canonical build machine multipliers (ADR-034).
|
|
758
|
+
*/
|
|
759
|
+
declare const CI_SIZE_MULTIPLIERS: Record<string, number>;
|
|
760
|
+
/** macOS runner per-size multipliers (ADR-035: per-tier billing) */
|
|
761
|
+
declare const CI_MACOS_SIZE_MULTIPLIERS: Record<string, number>;
|
|
762
|
+
/** @deprecated Use CI_MACOS_SIZE_MULTIPLIERS[size] instead. */
|
|
763
|
+
declare const CI_MACOS_MULTIPLIER: number;
|
|
764
|
+
type ServiceMetrics = typeof SERVICE_METRICS;
|
|
765
|
+
type KvMetric = keyof typeof SERVICE_METRICS.kv;
|
|
766
|
+
type RealtimeMetric = keyof typeof SERVICE_METRICS.realtime;
|
|
767
|
+
/** Credit expiry period in months */
|
|
768
|
+
declare const CREDIT_EXPIRY_MONTHS = 12;
|
|
769
|
+
/** Maximum payment retry attempts before suspending account */
|
|
770
|
+
declare const MAX_PAYMENT_ATTEMPTS = 3;
|
|
771
|
+
/** Roles that can access billing pages */
|
|
772
|
+
declare const BILLING_ALLOWED_ROLES: readonly ["super_admin", "admin", "billing"];
|
|
773
|
+
type BillingAllowedRole = (typeof BILLING_ALLOWED_ROLES)[number];
|
|
774
|
+
/** Check if a role has billing access */
|
|
775
|
+
declare function hasBillingAccess(role: string): boolean;
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Console SDK Key Utilities
|
|
779
|
+
*
|
|
780
|
+
* The Platform Console is Customer Zero — it uses the exact same key format
|
|
781
|
+
* as every other customer: pk_{env}_{ref}_{hex} / sk_{env}_{ref}_{hex}.
|
|
782
|
+
*
|
|
783
|
+
* No special key construction. No legacy app_* format. No special lookup paths.
|
|
784
|
+
*
|
|
785
|
+
* Keys are set via environment variables, just like any customer app:
|
|
786
|
+
* NEXT_PUBLIC_SYLPHX_KEY = pk_prod_nlbaz63pd2gz_97ef4f90c48e7378b0f00a1e2cb8c15e
|
|
787
|
+
* SYLPHX_SECRET_KEY = sk_prod_nlbaz63pd2gz_edea406b7988099f5826c143b0f6bd94...
|
|
788
|
+
*/
|
|
789
|
+
/** Console project slug — must match bootstrap.ts PLATFORM_CONSOLE_APP.slug */
|
|
790
|
+
declare const CONSOLE_APP_SLUG = "sylphx-console";
|
|
791
|
+
/**
|
|
792
|
+
* Determine environment prefix from build/runtime environment.
|
|
793
|
+
* Used by sdk-cookies.ts for cookie naming until it migrates to SDK-native getCookieNames().
|
|
794
|
+
* NOTE: still actively consumed by sdk-cookies.ts and sdk-login.ts — remove only after
|
|
795
|
+
* those modules parse the env prefix from NEXT_PUBLIC_SYLPHX_KEY directly.
|
|
796
|
+
*/
|
|
797
|
+
declare function getEnvPrefix(): 'dev' | 'stg' | 'prod';
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Platform Plan Tiers — SSOT
|
|
801
|
+
*
|
|
802
|
+
* Defines the Sylphx Platform plan tier system (ADR-034).
|
|
803
|
+
* NOTE: This is for *platform* plans (what the organization pays Sylphx for).
|
|
804
|
+
* It is separate from `plans` (which are in-app subscription products
|
|
805
|
+
* that customers create for their own end-users).
|
|
806
|
+
*
|
|
807
|
+
* All prices in cents (USD). Credits in microdollars (1 USD = 1,000,000 µ$).
|
|
808
|
+
*
|
|
809
|
+
* ADR-034 tiers: Free → Pro ($20/mo) → Team ($20/user/mo) → Enterprise (custom)
|
|
810
|
+
* The 'starter' tier is deprecated but kept in the type union for backward
|
|
811
|
+
* compatibility with existing database rows and API consumers.
|
|
812
|
+
*/
|
|
813
|
+
/**
|
|
814
|
+
* Platform plan identifiers.
|
|
815
|
+
* 'starter' is deprecated (ADR-034) — retained for backward compat with existing records.
|
|
816
|
+
*/
|
|
817
|
+
type PlatformPlanId = 'free' | 'starter' | 'pro' | 'team' | 'enterprise';
|
|
818
|
+
type BuildMachineTier = 'standard' | 'large' | 'xlarge';
|
|
819
|
+
interface PlatformPlanLimits {
|
|
820
|
+
/** Max projects across all environments */
|
|
821
|
+
maxProjects: number | null;
|
|
822
|
+
/** Max organization members */
|
|
823
|
+
maxMembers: number | null;
|
|
824
|
+
/** Max custom domains */
|
|
825
|
+
maxCustomDomains: number | null;
|
|
826
|
+
/** Max concurrent CI runners */
|
|
827
|
+
maxConcurrentRunners: number | null;
|
|
828
|
+
/** Max concurrent macOS CI runners */
|
|
829
|
+
maxMacosRunners: number | null;
|
|
830
|
+
/** Max managed databases */
|
|
831
|
+
maxDatabases: number | null;
|
|
832
|
+
/** CI job max duration in seconds */
|
|
833
|
+
ciMaxJobDurationSeconds: number;
|
|
834
|
+
/** API rate limit (requests per minute) */
|
|
835
|
+
apiRateLimitPerMin: number;
|
|
836
|
+
/** Audit log retention in days (0 = off) */
|
|
837
|
+
auditLogDays: number;
|
|
838
|
+
/** Max replicas per service (null = custom/negotiated) */
|
|
839
|
+
maxReplicas: number | null;
|
|
840
|
+
/** Included build minutes per billing period */
|
|
841
|
+
includedBuildMinutes: number;
|
|
842
|
+
/** Included outbound bandwidth in GB per billing period */
|
|
843
|
+
includedBandwidthGb: number;
|
|
844
|
+
/** Log retention in days */
|
|
845
|
+
logRetentionDays: number;
|
|
846
|
+
/** Build machine tier determining build speed */
|
|
847
|
+
buildMachineTier: BuildMachineTier;
|
|
848
|
+
}
|
|
849
|
+
interface PlatformPlanFeatures {
|
|
850
|
+
/** Custom domain support */
|
|
851
|
+
customDomains: boolean;
|
|
852
|
+
/** SSO / SAML support */
|
|
853
|
+
sso: boolean;
|
|
854
|
+
/** Priority CI queue */
|
|
855
|
+
priorityCi: boolean;
|
|
856
|
+
/** macOS CI runners */
|
|
857
|
+
macosCi: boolean;
|
|
858
|
+
/** Shared / Priority / Dedicated */
|
|
859
|
+
support: 'community' | 'email' | 'priority' | 'dedicated';
|
|
860
|
+
/** SLA uptime guarantee string (e.g. '99.9%') */
|
|
861
|
+
sla: string | null;
|
|
862
|
+
/** Role-based access control */
|
|
863
|
+
rbac: boolean;
|
|
864
|
+
/** Advanced analytics / insights */
|
|
865
|
+
advancedAnalytics: boolean;
|
|
866
|
+
/** White-label branding removal */
|
|
867
|
+
whiteLabel: boolean;
|
|
868
|
+
}
|
|
869
|
+
interface PlatformPlanDefinition {
|
|
870
|
+
id: PlatformPlanId;
|
|
871
|
+
name: string;
|
|
872
|
+
/** Monthly price in cents (0 = free, null = custom) */
|
|
873
|
+
priceMonthly: number | null;
|
|
874
|
+
/** Annual price in cents, ~20% discount (null = custom or N/A) */
|
|
875
|
+
priceAnnual: number | null;
|
|
876
|
+
/** Included platform compute credits per billing period (microdollars) */
|
|
877
|
+
includedCreditsMicrodollars: number;
|
|
878
|
+
/** Whether price is per seat (per member) — Team plan */
|
|
879
|
+
perSeat?: boolean;
|
|
880
|
+
features: PlatformPlanFeatures;
|
|
881
|
+
limits: PlatformPlanLimits;
|
|
882
|
+
/** Marketing bullet points for pricing cards */
|
|
883
|
+
highlights: string[];
|
|
884
|
+
/** Optional badge label (e.g. "Most Popular") */
|
|
885
|
+
badge?: string;
|
|
886
|
+
/** CTA button text */
|
|
887
|
+
cta: string;
|
|
888
|
+
/** Whether this is a custom/enterprise plan with contact sales flow */
|
|
889
|
+
isCustom?: boolean;
|
|
890
|
+
/**
|
|
891
|
+
* Deprecated plan — no longer available for new subscriptions.
|
|
892
|
+
* Existing subscribers are grandfathered until they change plans.
|
|
893
|
+
*/
|
|
894
|
+
deprecated?: boolean;
|
|
895
|
+
}
|
|
896
|
+
declare const PLATFORM_PLANS: Record<PlatformPlanId, PlatformPlanDefinition>;
|
|
897
|
+
/** Active (non-deprecated) plan IDs for display in pricing UI */
|
|
898
|
+
declare const PLATFORM_PLAN_ORDER: PlatformPlanId[];
|
|
899
|
+
/**
|
|
900
|
+
* Full plan order including deprecated tiers.
|
|
901
|
+
* Useful for admin screens and migration tooling that must handle legacy plans.
|
|
902
|
+
*/
|
|
903
|
+
declare const PLATFORM_PLAN_ORDER_ALL: PlatformPlanId[];
|
|
904
|
+
/** Check whether a plan is deprecated and should not be offered to new subscribers */
|
|
905
|
+
declare function isPlanDeprecated(planId: PlatformPlanId): boolean;
|
|
906
|
+
/** Get only active (non-deprecated) plan definitions, in display order */
|
|
907
|
+
declare function getActivePlans(): PlatformPlanDefinition[];
|
|
908
|
+
/** Convert microdollars to human-readable dollar string (e.g. "$5") */
|
|
909
|
+
declare function microsToDollars(microdollars: number): string;
|
|
910
|
+
/** Convert cents to human-readable dollar string (e.g. "$19") */
|
|
911
|
+
declare function centsToDollars(cents: number): string;
|
|
912
|
+
/** Get monthly price display string */
|
|
913
|
+
declare function getPlanMonthlyPrice(plan: PlatformPlanDefinition, annual?: boolean): string;
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Instance Type Catalog — SSOT
|
|
917
|
+
*
|
|
918
|
+
* Defines the compute instance types available for Sylphx platform workloads.
|
|
919
|
+
* Each instance type maps to Kubernetes resource requests/limits for kata-clh
|
|
920
|
+
* (Cloud Hypervisor) microVMs, along with billing rates and plan eligibility.
|
|
921
|
+
*
|
|
922
|
+
* Rates are in microdollars (1 USD = 1,000,000 µ$) per minute.
|
|
923
|
+
*
|
|
924
|
+
* Memory overcommit (ADR-028): CLH uses demand paging (mmap without MAP_POPULATE).
|
|
925
|
+
* Host physical RAM is allocated on-demand as guest pages are touched, NOT pre-allocated
|
|
926
|
+
* at VM boot. Verified 2026-03-30: a pod with limits=4Gi only consumed +8Mi host RAM
|
|
927
|
+
* when idle. Memory requests are set to 50% of limits (2x overcommit) for efficient
|
|
928
|
+
* scheduler bin-packing. CPU requests are 25% of limits (4x overcommit).
|
|
929
|
+
*
|
|
930
|
+
* ADR-034 T-shirt sizing: canonical names are xs/sm/md/lg/xl/2xl/4xl.
|
|
931
|
+
* Legacy names (starter-1x, standard-1x, etc.) are kept as aliases for backward
|
|
932
|
+
* compatibility with existing database values and API consumers.
|
|
933
|
+
*/
|
|
934
|
+
|
|
935
|
+
type InstanceTypeId = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '4xl' | 'starter-1x' | 'standard-1x' | 'standard-2x' | 'performance-m' | 'performance-l' | 'performance-xl';
|
|
936
|
+
interface InstanceTypeDefinition {
|
|
937
|
+
id: InstanceTypeId;
|
|
938
|
+
name: string;
|
|
939
|
+
/** Kubernetes CPU limit (e.g. '2000m') */
|
|
940
|
+
cpuLimit: string;
|
|
941
|
+
/** Kubernetes memory limit (e.g. '8Gi') */
|
|
942
|
+
memoryLimit: string;
|
|
943
|
+
/** Kubernetes CPU request (e.g. '500m') */
|
|
944
|
+
cpuRequest: string;
|
|
945
|
+
/** Kubernetes memory request (50% of limit — CLH demand paging, ADR-028) */
|
|
946
|
+
memoryRequest: string;
|
|
947
|
+
/** Billing vCPU count for metering denormalization */
|
|
948
|
+
vcpus: number;
|
|
949
|
+
/** Billing memory in MiB for metering denormalization */
|
|
950
|
+
memoryMib: number;
|
|
951
|
+
/** Rate per vCPU per minute in microdollars */
|
|
952
|
+
vcpuMinuteRateMicrodollars: number;
|
|
953
|
+
/** Rate per GiB per minute in microdollars */
|
|
954
|
+
gbMinuteRateMicrodollars: number;
|
|
955
|
+
/** Platform plans that may provision this instance type */
|
|
956
|
+
allowedPlans: PlatformPlanId[];
|
|
957
|
+
/**
|
|
958
|
+
* Maximum KEDA ScaledObject replica count for this instance type tier.
|
|
959
|
+
* Caps the ScaledObject maxReplicaCount to prevent runaway scaling
|
|
960
|
+
* on smaller tiers. Users can set a lower per-service max via scalingConfig.max,
|
|
961
|
+
* but never exceed this ceiling.
|
|
962
|
+
*/
|
|
963
|
+
maxReplicas: number;
|
|
964
|
+
/** Marketing bullet points for instance type cards */
|
|
965
|
+
highlights: string[];
|
|
966
|
+
/** Whether this instance type is deprecated (legacy name) */
|
|
967
|
+
deprecated?: boolean;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Maps legacy instance type names to their canonical T-shirt size equivalents (ADR-034).
|
|
971
|
+
*
|
|
972
|
+
* Database values and API consumers may still use old names — this mapping lets
|
|
973
|
+
* resolveInstanceType() transparently return the canonical definition without
|
|
974
|
+
* requiring a data migration.
|
|
975
|
+
*/
|
|
976
|
+
declare const INSTANCE_TYPE_ALIASES: Record<string, string>;
|
|
977
|
+
/**
|
|
978
|
+
* Resolve a potentially-aliased instance type ID to its canonical T-shirt size.
|
|
979
|
+
* Returns the input unchanged if it is already canonical or unknown.
|
|
980
|
+
*
|
|
981
|
+
* Use for display/UI and when accepting user input for NEW configurations.
|
|
982
|
+
* Do NOT use in runtime paths (billing, K8s reconciler) — both old and new names
|
|
983
|
+
* exist in INSTANCE_TYPES with their original specs, so direct lookup is correct
|
|
984
|
+
* and avoids changing billing/resource behavior for existing services.
|
|
985
|
+
*/
|
|
986
|
+
declare function resolveCanonicalInstanceType(id: string): string;
|
|
987
|
+
declare const INSTANCE_TYPES: Record<InstanceTypeId, InstanceTypeDefinition>;
|
|
988
|
+
/** Ordered list of canonical instance type IDs for display (smallest to largest) */
|
|
989
|
+
declare const INSTANCE_TYPE_ORDER: InstanceTypeId[];
|
|
990
|
+
/**
|
|
991
|
+
* @deprecated Use INSTANCE_TYPE_ORDER instead.
|
|
992
|
+
* Ordered list of legacy instance type IDs — kept for backward compat.
|
|
993
|
+
*/
|
|
994
|
+
declare const LEGACY_INSTANCE_TYPE_ORDER: InstanceTypeId[];
|
|
995
|
+
/** Get the default instance type for a given platform plan */
|
|
996
|
+
declare function getDefaultInstanceType(plan: PlatformPlanId): InstanceTypeId;
|
|
997
|
+
/** Get all canonical (non-deprecated) instance types available for a given platform plan, in display order */
|
|
998
|
+
declare function getAvailableInstanceTypes(plan: PlatformPlanId): InstanceTypeDefinition[];
|
|
999
|
+
/** Resolve Kubernetes resource spec for a given instance type (accepts aliases) */
|
|
1000
|
+
declare function resolveResources(id: InstanceTypeId): {
|
|
1001
|
+
requests: {
|
|
1002
|
+
cpu: string;
|
|
1003
|
+
memory: string;
|
|
1004
|
+
};
|
|
1005
|
+
limits: {
|
|
1006
|
+
cpu: string;
|
|
1007
|
+
memory: string;
|
|
1008
|
+
};
|
|
1009
|
+
};
|
|
1010
|
+
/** Resolve the KEDA ScaledObject maxReplicaCount ceiling for a given instance type */
|
|
1011
|
+
declare function resolveMaxReplicas(id: InstanceTypeId): number;
|
|
1012
|
+
/** Default KEDA maxReplicaCount when no instance type is resolved (legacy/unmanaged services) */
|
|
1013
|
+
declare const DEFAULT_MAX_REPLICAS = 10;
|
|
1014
|
+
/** Type guard: check if an arbitrary string is a valid InstanceTypeId (including legacy aliases) */
|
|
1015
|
+
declare function isValidInstanceType(id: string): id is InstanceTypeId;
|
|
1016
|
+
/** Validate that an instance type exists and is permitted for the given plan */
|
|
1017
|
+
declare function validateInstanceTypeForPlan(id: string, plan: PlatformPlanId): {
|
|
1018
|
+
valid: boolean;
|
|
1019
|
+
error?: string;
|
|
1020
|
+
};
|
|
1021
|
+
|
|
263
1022
|
/**
|
|
264
1023
|
* SDK Debug Mode
|
|
265
1024
|
*
|
|
@@ -874,11 +1633,22 @@ declare function isRetryableError(error: unknown): boolean;
|
|
|
874
1633
|
/**
|
|
875
1634
|
* Extract error message from any error type
|
|
876
1635
|
*/
|
|
877
|
-
declare function getErrorMessage(error: unknown): string;
|
|
1636
|
+
declare function getErrorMessage(error: unknown, fallback?: string): string;
|
|
878
1637
|
/**
|
|
879
1638
|
* Get error code from any error type
|
|
880
1639
|
*/
|
|
881
1640
|
declare function getErrorCode(error: unknown): SylphxErrorCode;
|
|
1641
|
+
interface ErrorDetails {
|
|
1642
|
+
readonly message: string;
|
|
1643
|
+
readonly code?: string;
|
|
1644
|
+
readonly name?: string;
|
|
1645
|
+
readonly stack?: string;
|
|
1646
|
+
readonly status?: number;
|
|
1647
|
+
readonly cause?: unknown;
|
|
1648
|
+
}
|
|
1649
|
+
declare function getErrorDetails(error: unknown, fallbackMessage?: string): ErrorDetails;
|
|
1650
|
+
declare function getSafeErrorMessage(error: unknown, fallback?: string): string;
|
|
1651
|
+
declare function isChallengeRequired(err: unknown): boolean;
|
|
882
1652
|
/**
|
|
883
1653
|
* Convert any error to SylphxError
|
|
884
1654
|
*/
|
|
@@ -1810,438 +2580,479 @@ interface PaginatedResponse<T> {
|
|
|
1810
2580
|
}
|
|
1811
2581
|
|
|
1812
2582
|
/**
|
|
1813
|
-
*
|
|
1814
|
-
*
|
|
1815
|
-
* Pure functions for authentication - no hidden state.
|
|
1816
|
-
* Each function takes config as the first parameter.
|
|
1817
|
-
*
|
|
1818
|
-
* Uses REST API at /api/sdk/auth/* for all operations.
|
|
2583
|
+
* DPoP — Demonstration of Proof-of-Possession (RFC 9449 / ADR-089 Phase 5.1e).
|
|
1819
2584
|
*
|
|
1820
|
-
*
|
|
1821
|
-
*
|
|
1822
|
-
* SDK-specific ergonomics (User brand swap, introspection result, invite
|
|
1823
|
-
* envelopes, org-token claims).
|
|
2585
|
+
* Client-side helpers for sender-constrained access tokens. Built on
|
|
2586
|
+
* `crypto.subtle` with no runtime dependencies.
|
|
1824
2587
|
*/
|
|
2588
|
+
declare const dpop: {
|
|
2589
|
+
/**
|
|
2590
|
+
* Generate a fresh ES256 key pair. Private key is non-extractable
|
|
2591
|
+
* (`extractable: false`) so it can be stored but never serialised.
|
|
2592
|
+
*/
|
|
2593
|
+
readonly generateKeyPair: () => Promise<{
|
|
2594
|
+
readonly privateKey: CryptoKey;
|
|
2595
|
+
readonly publicKey: CryptoKey;
|
|
2596
|
+
readonly thumbprint: string;
|
|
2597
|
+
}>;
|
|
2598
|
+
/**
|
|
2599
|
+
* Sign a DPoP proof JWT. When `accessToken` is provided, the proof
|
|
2600
|
+
* includes `ath = base64url(sha256(accessToken))` so the resource
|
|
2601
|
+
* server can bind the proof to the token being presented.
|
|
2602
|
+
*/
|
|
2603
|
+
readonly generateProof: (opts: {
|
|
2604
|
+
readonly privateKey: CryptoKey;
|
|
2605
|
+
readonly publicKey: CryptoKey;
|
|
2606
|
+
readonly method: string;
|
|
2607
|
+
readonly uri: string;
|
|
2608
|
+
readonly accessToken?: string;
|
|
2609
|
+
readonly nonce?: string;
|
|
2610
|
+
}) => Promise<string>;
|
|
2611
|
+
};
|
|
1825
2612
|
|
|
1826
|
-
type LoginRequest = LoginRequest$1;
|
|
1827
|
-
type LoginResponse = LoginResponse$1;
|
|
1828
|
-
type RegisterRequest = RegisterRequest$1;
|
|
1829
|
-
type RegisterResponse = RegisterResponse$1;
|
|
1830
|
-
type ResendEmailVerificationRequest = ResendEmailVerificationRequest$1;
|
|
1831
|
-
type ResendEmailVerificationResponse = ResendEmailVerificationResponse$1;
|
|
1832
2613
|
/**
|
|
1833
|
-
*
|
|
1834
|
-
*
|
|
1835
|
-
*
|
|
1836
|
-
*
|
|
1837
|
-
*
|
|
2614
|
+
* OAuth token endpoint contract helpers.
|
|
2615
|
+
*
|
|
2616
|
+
* Keeps RFC 6749/8628 request encoding, success decoding, and error decoding
|
|
2617
|
+
* type-bound to `@sylphx/contract` while using SDK-local runtime guards so the
|
|
2618
|
+
* published Promise SDK does not import Effect internals.
|
|
1838
2619
|
*/
|
|
1839
|
-
|
|
1840
|
-
|
|
2620
|
+
|
|
2621
|
+
type OAuthTokenResult = OAuthTokenResponse;
|
|
2622
|
+
type OAuthClientCredentialsResult = OAuthClientCredentialsResponse;
|
|
2623
|
+
type OAuthTokenEndpointError = OAuthTokenErrorResponse['error'];
|
|
2624
|
+
type OAuthPollError = OAuthTokenEndpointError | 'oauth_error';
|
|
2625
|
+
type OAuthPollResult = {
|
|
2626
|
+
readonly ok: true;
|
|
2627
|
+
readonly tokens: OAuthTokenResult;
|
|
2628
|
+
} | {
|
|
2629
|
+
readonly ok: false;
|
|
2630
|
+
readonly error: OAuthPollError;
|
|
2631
|
+
readonly status: number;
|
|
1841
2632
|
};
|
|
1842
|
-
|
|
2633
|
+
|
|
1843
2634
|
/**
|
|
1844
|
-
*
|
|
1845
|
-
* optional `emailVerified` flag the backend returns, so the SDK can just
|
|
1846
|
-
* alias the contract type directly.
|
|
2635
|
+
* Platform refresh-token rotation and logout SDK namespace.
|
|
1847
2636
|
*/
|
|
1848
|
-
|
|
2637
|
+
|
|
2638
|
+
type PlatformRefreshInput = RefreshTokenInput;
|
|
2639
|
+
type PlatformRefreshResult = RefreshTokenResult;
|
|
2640
|
+
type PlatformLogoutInput = LogoutInput;
|
|
2641
|
+
declare const platformAuth: {
|
|
2642
|
+
readonly refresh: (opts: {
|
|
2643
|
+
readonly baseUrl: string;
|
|
2644
|
+
readonly refreshToken: string;
|
|
2645
|
+
readonly userAgent?: string;
|
|
2646
|
+
/**
|
|
2647
|
+
* Path prefix between `baseUrl` and the resource path. Defaults
|
|
2648
|
+
* to `/api/v1` for back-compat with the admin-override host
|
|
2649
|
+
* (`sylphx.com`). Pass `/v1` when targeting the canonical host
|
|
2650
|
+
* (`api.sylphx.com`) per Rule 17.
|
|
2651
|
+
*/
|
|
2652
|
+
readonly urlPrefix?: string;
|
|
2653
|
+
}) => Promise<PlatformRefreshResult>;
|
|
2654
|
+
readonly logout: (opts: {
|
|
2655
|
+
readonly baseUrl: string;
|
|
2656
|
+
readonly refreshToken: string;
|
|
2657
|
+
readonly userAgent?: string;
|
|
2658
|
+
/** See `refresh.urlPrefix`. */
|
|
2659
|
+
readonly urlPrefix?: string;
|
|
2660
|
+
}) => Promise<void>;
|
|
2661
|
+
};
|
|
2662
|
+
|
|
1849
2663
|
/**
|
|
1850
|
-
*
|
|
2664
|
+
* Platform impersonation SDK namespace.
|
|
2665
|
+
*
|
|
2666
|
+
* Covers the ADR-089 Phase 3b legacy helpers and Phase 5.9 WebAuthn
|
|
2667
|
+
* step-up + target-consent workflow.
|
|
1851
2668
|
*/
|
|
1852
|
-
interface
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
/** User ID */
|
|
1858
|
-
sub?: string;
|
|
1859
|
-
/** User email */
|
|
1860
|
-
email?: string;
|
|
1861
|
-
/** User name */
|
|
1862
|
-
name?: string;
|
|
1863
|
-
/** App ID */
|
|
1864
|
-
client_id?: string;
|
|
1865
|
-
/** Audience */
|
|
1866
|
-
aud?: string;
|
|
1867
|
-
/** Issuer */
|
|
1868
|
-
iss?: string;
|
|
1869
|
-
/** Expiration time (Unix timestamp) */
|
|
1870
|
-
exp?: number;
|
|
1871
|
-
/** Issued at time (Unix timestamp) */
|
|
1872
|
-
iat?: number;
|
|
1873
|
-
/** User role */
|
|
1874
|
-
role?: string;
|
|
1875
|
-
/** Email verification status */
|
|
1876
|
-
email_verified?: boolean;
|
|
2669
|
+
interface ImpersonationStartResult {
|
|
2670
|
+
readonly success: true;
|
|
2671
|
+
readonly token: string;
|
|
2672
|
+
readonly sessionId: string;
|
|
2673
|
+
readonly expiresAt: string;
|
|
1877
2674
|
}
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
interface RevokeTokenOptions {
|
|
1882
|
-
/** Revoke all tokens for a user in this app */
|
|
1883
|
-
revokeAll?: boolean;
|
|
1884
|
-
/** User ID (required when revoking all) */
|
|
1885
|
-
userId?: string;
|
|
2675
|
+
interface ImpersonationEndResult {
|
|
2676
|
+
readonly success: boolean;
|
|
2677
|
+
readonly sessionsEnded: number;
|
|
1886
2678
|
}
|
|
1887
|
-
interface
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
emailVerified: boolean;
|
|
1894
|
-
} | null;
|
|
2679
|
+
interface ImpersonationInfo {
|
|
2680
|
+
readonly isImpersonation: true;
|
|
2681
|
+
readonly adminUserId: string;
|
|
2682
|
+
readonly adminEmail: string;
|
|
2683
|
+
readonly adminName: string | null;
|
|
2684
|
+
readonly impersonatedAt: string;
|
|
1895
2685
|
}
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
2686
|
+
interface ImpersonationActive {
|
|
2687
|
+
readonly sessionId: string;
|
|
2688
|
+
readonly adminUserId: string;
|
|
2689
|
+
readonly adminEmail: string;
|
|
2690
|
+
readonly adminName: string | null;
|
|
2691
|
+
readonly targetUserId: string;
|
|
2692
|
+
readonly targetEmail: string;
|
|
2693
|
+
readonly targetName: string | null;
|
|
2694
|
+
readonly impersonatedAt: string;
|
|
2695
|
+
readonly lastActiveAt: string;
|
|
1906
2696
|
}
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
*/
|
|
1914
|
-
interface OrgTokenPayload {
|
|
1915
|
-
org_id: string;
|
|
1916
|
-
org_slug: string;
|
|
1917
|
-
/** RBAC role key (e.g. "hr_manager", "admin"). Permissions resolved server-side. */
|
|
1918
|
-
org_role: string;
|
|
2697
|
+
interface ImpersonationStartChallengeInput {
|
|
2698
|
+
readonly baseUrl: string;
|
|
2699
|
+
readonly accessToken: string;
|
|
2700
|
+
readonly targetUserId: string;
|
|
2701
|
+
readonly reason: string;
|
|
2702
|
+
readonly userAgent?: string;
|
|
1919
2703
|
}
|
|
1920
|
-
interface
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
2704
|
+
interface ImpersonationChallenge {
|
|
2705
|
+
readonly requestId: string;
|
|
2706
|
+
readonly challengeKey: string;
|
|
2707
|
+
readonly webauthnOptions: {
|
|
2708
|
+
readonly challenge: string;
|
|
2709
|
+
readonly rpId?: string;
|
|
2710
|
+
readonly allowCredentials: ReadonlyArray<{
|
|
2711
|
+
readonly id: string;
|
|
2712
|
+
readonly type: 'public-key';
|
|
2713
|
+
readonly transports?: readonly string[];
|
|
2714
|
+
}>;
|
|
2715
|
+
readonly userVerification: 'required';
|
|
2716
|
+
readonly timeout: number;
|
|
2717
|
+
};
|
|
1931
2718
|
}
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
2719
|
+
interface ImpersonationStartStepupInput {
|
|
2720
|
+
readonly baseUrl: string;
|
|
2721
|
+
readonly accessToken: string;
|
|
2722
|
+
readonly requestId: string;
|
|
2723
|
+
readonly challengeKey: string;
|
|
2724
|
+
readonly assertion: unknown;
|
|
2725
|
+
readonly emergencyBypass?: boolean;
|
|
2726
|
+
readonly userAgent?: string;
|
|
1939
2727
|
}
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
expiresAt: string;
|
|
2728
|
+
type ImpersonationStartStepupResult = {
|
|
2729
|
+
readonly branch: 'emergency';
|
|
2730
|
+
readonly requestId: string;
|
|
2731
|
+
readonly token: string;
|
|
2732
|
+
readonly sessionId: string;
|
|
2733
|
+
readonly expiresAt: string;
|
|
2734
|
+
} | {
|
|
2735
|
+
readonly branch: 'awaiting-consent';
|
|
2736
|
+
readonly requestId: string;
|
|
2737
|
+
readonly consentDeadline: string;
|
|
2738
|
+
};
|
|
2739
|
+
type ImpersonationConsentDecision = 'approve' | 'deny';
|
|
2740
|
+
type ImpersonationConsentResponse = {
|
|
2741
|
+
readonly branch: 'approved';
|
|
2742
|
+
readonly requestId: string;
|
|
2743
|
+
readonly token: string;
|
|
2744
|
+
readonly sessionId: string;
|
|
2745
|
+
readonly expiresAt: string;
|
|
2746
|
+
} | {
|
|
2747
|
+
readonly branch: 'denied';
|
|
2748
|
+
readonly requestId: string;
|
|
2749
|
+
};
|
|
2750
|
+
interface ImpersonationRequestRow {
|
|
2751
|
+
readonly id: string;
|
|
2752
|
+
readonly operatorId: string;
|
|
2753
|
+
readonly targetUserId: string;
|
|
2754
|
+
readonly reason: string;
|
|
2755
|
+
readonly status: 'awaiting-stepup' | 'awaiting-consent' | 'active' | 'denied' | 'expired' | 'ended' | 'revoked';
|
|
2756
|
+
readonly emergencyBypass: boolean;
|
|
2757
|
+
readonly sessionId: string | null;
|
|
2758
|
+
readonly consentDeadline: string | null;
|
|
2759
|
+
readonly startedAt: string | null;
|
|
2760
|
+
readonly endedAt: string | null;
|
|
2761
|
+
readonly createdAt: string;
|
|
1946
2762
|
}
|
|
2763
|
+
declare const impersonation: {
|
|
2764
|
+
readonly start: (opts: {
|
|
2765
|
+
readonly baseUrl: string;
|
|
2766
|
+
readonly accessToken: string;
|
|
2767
|
+
readonly targetUserId: string;
|
|
2768
|
+
readonly ipAddress?: string;
|
|
2769
|
+
readonly userAgent?: string;
|
|
2770
|
+
}) => Promise<ImpersonationStartResult>;
|
|
2771
|
+
readonly end: (opts: {
|
|
2772
|
+
readonly baseUrl: string;
|
|
2773
|
+
readonly accessToken: string;
|
|
2774
|
+
readonly sessionId?: string;
|
|
2775
|
+
readonly userAgent?: string;
|
|
2776
|
+
}) => Promise<ImpersonationEndResult>;
|
|
2777
|
+
readonly info: (opts: {
|
|
2778
|
+
readonly baseUrl: string;
|
|
2779
|
+
readonly accessToken: string;
|
|
2780
|
+
readonly sessionId: string;
|
|
2781
|
+
readonly userAgent?: string;
|
|
2782
|
+
}) => Promise<ImpersonationInfo | null>;
|
|
2783
|
+
readonly active: (opts: {
|
|
2784
|
+
readonly baseUrl: string;
|
|
2785
|
+
readonly accessToken: string;
|
|
2786
|
+
readonly userAgent?: string;
|
|
2787
|
+
}) => Promise<readonly ImpersonationActive[]>;
|
|
2788
|
+
readonly startChallenge: (opts: ImpersonationStartChallengeInput) => Promise<ImpersonationChallenge>;
|
|
2789
|
+
readonly startStepup: (opts: ImpersonationStartStepupInput) => Promise<ImpersonationStartStepupResult>;
|
|
2790
|
+
readonly respondConsent: (opts: {
|
|
2791
|
+
readonly baseUrl: string;
|
|
2792
|
+
readonly accessToken: string;
|
|
2793
|
+
readonly requestId: string;
|
|
2794
|
+
readonly decision: ImpersonationConsentDecision;
|
|
2795
|
+
readonly userAgent?: string;
|
|
2796
|
+
}) => Promise<ImpersonationConsentResponse>;
|
|
2797
|
+
readonly listRequests: (opts: {
|
|
2798
|
+
readonly baseUrl: string;
|
|
2799
|
+
readonly accessToken: string;
|
|
2800
|
+
readonly filter?: {
|
|
2801
|
+
readonly operatorId?: string;
|
|
2802
|
+
readonly targetUserId?: string;
|
|
2803
|
+
readonly status?: ImpersonationRequestRow["status"];
|
|
2804
|
+
readonly limit?: number;
|
|
2805
|
+
};
|
|
2806
|
+
readonly userAgent?: string;
|
|
2807
|
+
}) => Promise<readonly ImpersonationRequestRow[]>;
|
|
2808
|
+
readonly endSession: (opts: {
|
|
2809
|
+
readonly baseUrl: string;
|
|
2810
|
+
readonly accessToken: string;
|
|
2811
|
+
readonly requestId: string;
|
|
2812
|
+
readonly userAgent?: string;
|
|
2813
|
+
}) => Promise<{
|
|
2814
|
+
success: true;
|
|
2815
|
+
requestId: string;
|
|
2816
|
+
sessionId: string | null;
|
|
2817
|
+
}>;
|
|
2818
|
+
};
|
|
2819
|
+
|
|
1947
2820
|
/**
|
|
1948
|
-
*
|
|
1949
|
-
*
|
|
1950
|
-
* @example
|
|
1951
|
-
* ```typescript
|
|
1952
|
-
* const result = await signIn(config, { email: 'user@example.com', password: 'secret' })
|
|
1953
|
-
* if (result.requiresTwoFactor) {
|
|
1954
|
-
* // Handle 2FA flow
|
|
1955
|
-
* } else {
|
|
1956
|
-
* // Save tokens
|
|
1957
|
-
* const authenticatedConfig = withToken(config, result.accessToken!)
|
|
1958
|
-
* }
|
|
1959
|
-
* ```
|
|
1960
|
-
*/
|
|
1961
|
-
declare function signIn(config: SylphxConfig, input: LoginRequest): Promise<LoginResponse>;
|
|
1962
|
-
/**
|
|
1963
|
-
* Sign up with email and password
|
|
1964
|
-
*
|
|
1965
|
-
* @example
|
|
1966
|
-
* ```typescript
|
|
1967
|
-
* const result = await signUp(config, {
|
|
1968
|
-
* email: 'user@example.com',
|
|
1969
|
-
* password: 'secret',
|
|
1970
|
-
* name: 'John Doe',
|
|
1971
|
-
* })
|
|
1972
|
-
* // User needs to verify email
|
|
1973
|
-
* ```
|
|
1974
|
-
*/
|
|
1975
|
-
declare function signUp(config: SylphxConfig, input: RegisterRequest): Promise<RegisterResponse>;
|
|
1976
|
-
/**
|
|
1977
|
-
* Sign out (revoke tokens)
|
|
1978
|
-
*
|
|
1979
|
-
* @example
|
|
1980
|
-
* ```typescript
|
|
1981
|
-
* await signOut(config)
|
|
1982
|
-
* ```
|
|
1983
|
-
*/
|
|
1984
|
-
declare function signOut(config: SylphxConfig): Promise<void>;
|
|
1985
|
-
/**
|
|
1986
|
-
* Refresh access token
|
|
1987
|
-
*
|
|
1988
|
-
* @example
|
|
1989
|
-
* ```typescript
|
|
1990
|
-
* const tokens = await refreshToken(config, refreshTokenString)
|
|
1991
|
-
* const newConfig = withToken(config, tokens.accessToken)
|
|
1992
|
-
* ```
|
|
1993
|
-
*/
|
|
1994
|
-
declare function refreshToken(config: SylphxConfig, token: string): Promise<TokenResponse>;
|
|
1995
|
-
/**
|
|
1996
|
-
* Verify email with token
|
|
1997
|
-
*
|
|
1998
|
-
* @example
|
|
1999
|
-
* ```typescript
|
|
2000
|
-
* await verifyEmail(config, token)
|
|
2001
|
-
* ```
|
|
2002
|
-
*/
|
|
2003
|
-
declare function verifyEmail(config: SylphxConfig, token: string): Promise<void>;
|
|
2004
|
-
/**
|
|
2005
|
-
* Request password reset email
|
|
2006
|
-
*
|
|
2007
|
-
* @example
|
|
2008
|
-
* ```typescript
|
|
2009
|
-
* await forgotPassword(config, 'user@example.com', {
|
|
2010
|
-
* redirectUrl: 'https://app.example.com/reset-password'
|
|
2011
|
-
* })
|
|
2012
|
-
* ```
|
|
2013
|
-
*/
|
|
2014
|
-
declare function forgotPassword(config: SylphxConfig, email: string, options?: {
|
|
2015
|
-
redirectUrl?: string;
|
|
2016
|
-
}): Promise<void>;
|
|
2017
|
-
/**
|
|
2018
|
-
* Request a verification email resend.
|
|
2019
|
-
*
|
|
2020
|
-
* The Platform response is intentionally privacy-preserving: it never
|
|
2021
|
-
* indicates whether the email exists or is already verified.
|
|
2022
|
-
*
|
|
2023
|
-
* @example
|
|
2024
|
-
* ```typescript
|
|
2025
|
-
* await resendVerificationEmail(config, 'user@example.com')
|
|
2026
|
-
* ```
|
|
2027
|
-
*/
|
|
2028
|
-
declare function resendVerificationEmail(config: SylphxConfig, email: string): Promise<void>;
|
|
2029
|
-
/**
|
|
2030
|
-
* Reset password with token
|
|
2031
|
-
*
|
|
2032
|
-
* @example
|
|
2033
|
-
* ```typescript
|
|
2034
|
-
* await resetPassword(config, { token, password: 'newpassword' })
|
|
2035
|
-
* ```
|
|
2036
|
-
*/
|
|
2037
|
-
declare function resetPassword(config: SylphxConfig, input: {
|
|
2038
|
-
token: string;
|
|
2039
|
-
password: string;
|
|
2040
|
-
}): Promise<void>;
|
|
2041
|
-
/**
|
|
2042
|
-
* Get current session (requires authenticated config)
|
|
2043
|
-
*
|
|
2044
|
-
* @example
|
|
2045
|
-
* ```typescript
|
|
2046
|
-
* const session = await getSession(authenticatedConfig)
|
|
2047
|
-
* if (session.user) {
|
|
2048
|
-
* console.log(`Logged in as ${session.user.email}`)
|
|
2049
|
-
* }
|
|
2050
|
-
* ```
|
|
2051
|
-
*/
|
|
2052
|
-
declare function getSession(config: SylphxConfig): Promise<SessionResult>;
|
|
2053
|
-
/**
|
|
2054
|
-
* Verify 2FA code (when signIn returns requiresTwoFactor: true)
|
|
2055
|
-
*
|
|
2056
|
-
* @example
|
|
2057
|
-
* ```typescript
|
|
2058
|
-
* const result = await signIn(config, credentials)
|
|
2059
|
-
* if (result.requiresTwoFactor) {
|
|
2060
|
-
* const tokens = await verifyTwoFactor(config, result.userId!, code)
|
|
2061
|
-
* }
|
|
2062
|
-
* ```
|
|
2063
|
-
*/
|
|
2064
|
-
declare function verifyTwoFactor(config: SylphxConfig, userId: string, code: string): Promise<TokenResponse>;
|
|
2065
|
-
/**
|
|
2066
|
-
* Introspect a token to check its validity (RFC 7662)
|
|
2067
|
-
*
|
|
2068
|
-
* Use this to verify token status without decoding. Essential for:
|
|
2069
|
-
* - Checking if a token has been revoked
|
|
2070
|
-
* - Validating tokens at the edge
|
|
2071
|
-
* - Security-critical operations
|
|
2072
|
-
*
|
|
2073
|
-
* @example
|
|
2074
|
-
* ```typescript
|
|
2075
|
-
* const result = await introspectToken(config, accessToken)
|
|
2076
|
-
* if (!result.active) {
|
|
2077
|
-
* // Token is invalid, revoked, or expired
|
|
2078
|
-
* await refreshTokens()
|
|
2079
|
-
* }
|
|
2080
|
-
* ```
|
|
2081
|
-
*/
|
|
2082
|
-
declare function introspectToken(config: SylphxConfig, token: string, tokenTypeHint?: 'access_token' | 'refresh_token'): Promise<TokenIntrospectionResult>;
|
|
2083
|
-
/**
|
|
2084
|
-
* Revoke a token (RFC 7009)
|
|
2085
|
-
*
|
|
2086
|
-
* Use cases:
|
|
2087
|
-
* - Sign out user from specific device
|
|
2088
|
-
* - Security response to compromised token
|
|
2089
|
-
* - User-initiated session termination
|
|
2090
|
-
*
|
|
2091
|
-
* @example
|
|
2092
|
-
* ```typescript
|
|
2093
|
-
* // Revoke single refresh token
|
|
2094
|
-
* await revokeToken(config, refreshToken)
|
|
2821
|
+
* Platform JWT verification and cookie-session resolution.
|
|
2095
2822
|
*
|
|
2096
|
-
*
|
|
2097
|
-
*
|
|
2098
|
-
* ```
|
|
2823
|
+
* This module owns the SDK's hot-path Platform auth helpers: cached JWKS
|
|
2824
|
+
* verification for bearer tokens and cached cookie-based user resolution.
|
|
2099
2825
|
*/
|
|
2100
|
-
declare function revokeToken(config: SylphxConfig, token: string, options?: RevokeTokenOptions): Promise<void>;
|
|
2101
2826
|
/**
|
|
2102
|
-
*
|
|
2103
|
-
*
|
|
2104
|
-
*
|
|
2105
|
-
*
|
|
2106
|
-
* @example
|
|
2107
|
-
* ```typescript
|
|
2108
|
-
* // After password change, revoke all sessions
|
|
2109
|
-
* await revokeAllTokens(config, userId)
|
|
2110
|
-
* ```
|
|
2827
|
+
* Reset the platform-JWKS cache. Tests should call this between cases
|
|
2828
|
+
* to avoid state bleed. Production code relies on the TTL-based
|
|
2829
|
+
* expiry.
|
|
2111
2830
|
*/
|
|
2112
|
-
declare function
|
|
2831
|
+
declare function resetPlatformJwksCache(): void;
|
|
2832
|
+
interface PlatformAccessTokenClaims {
|
|
2833
|
+
readonly sub: string;
|
|
2834
|
+
readonly pid?: string;
|
|
2835
|
+
readonly email: string;
|
|
2836
|
+
readonly name?: string;
|
|
2837
|
+
readonly picture?: string;
|
|
2838
|
+
readonly email_verified: boolean;
|
|
2839
|
+
readonly app_id: string;
|
|
2840
|
+
readonly role: string;
|
|
2841
|
+
readonly org_id?: string;
|
|
2842
|
+
readonly org_slug?: string;
|
|
2843
|
+
readonly org_role?: string;
|
|
2844
|
+
readonly iat?: number;
|
|
2845
|
+
readonly exp?: number;
|
|
2846
|
+
/**
|
|
2847
|
+
* RFC 7800 confirmation claim — present when the token is sender-
|
|
2848
|
+
* constrained. Today we emit this for DPoP-bound tokens (RFC 9449)
|
|
2849
|
+
* where `cnf.jkt` is the SHA-256 thumbprint of the client's DPoP
|
|
2850
|
+
* public key.
|
|
2851
|
+
*
|
|
2852
|
+
* Resource servers (e.g. apps/api Management plane) that want to
|
|
2853
|
+
* enforce DPoP MUST:
|
|
2854
|
+
* 1. Look up `oauth_clients.dpop_bound_access_tokens` on the
|
|
2855
|
+
* issuing client to know whether DPoP is required.
|
|
2856
|
+
* 2. If required AND `cnf.jkt` is absent, reject 401.
|
|
2857
|
+
* 3. If `cnf.jkt` is present, verify the inbound `DPoP` header's
|
|
2858
|
+
* proof JWT and assert its public-key thumbprint matches `jkt`.
|
|
2859
|
+
*
|
|
2860
|
+
* Pre-Wave-5.3 this field was stripped from `verifyAccessToken`'s
|
|
2861
|
+
* return value, making resource-side enforcement impossible without
|
|
2862
|
+
* decoding the JWT a second time. Exposing it preserves the wire
|
|
2863
|
+
* format and unlocks the resource-server DPoP middleware.
|
|
2864
|
+
*/
|
|
2865
|
+
readonly cnf?: {
|
|
2866
|
+
readonly jkt?: string;
|
|
2867
|
+
};
|
|
2868
|
+
}
|
|
2113
2869
|
/**
|
|
2114
|
-
*
|
|
2115
|
-
*
|
|
2116
|
-
* Use this instead of signUp() when you need to:
|
|
2117
|
-
* - Pass metadata on registration (e.g., org context, role, referral info)
|
|
2118
|
-
* - Register with an invitation token
|
|
2870
|
+
* `verifyAccessToken` — local JWT verification against cached JWKS.
|
|
2119
2871
|
*
|
|
2120
|
-
*
|
|
2121
|
-
*
|
|
2122
|
-
*
|
|
2123
|
-
* email: 'user@example.com',
|
|
2124
|
-
* password: 'secret',
|
|
2125
|
-
* name: 'John Doe',
|
|
2126
|
-
* metadata: { orgId: 'org-123', role: 'employee' },
|
|
2127
|
-
* invitationToken: 'inv_...',
|
|
2128
|
-
* })
|
|
2129
|
-
* ```
|
|
2130
|
-
*/
|
|
2131
|
-
declare function extendedSignUp(config: SylphxConfig, input: RegisterInput): Promise<RegisterResponse>;
|
|
2132
|
-
/**
|
|
2133
|
-
* Invite a user to sign up for this project.
|
|
2134
|
-
* Server-side only (requires secretKey).
|
|
2135
|
-
* Sends an email invitation; user signs up via signUp() or extendedSignUp() with the invitation token.
|
|
2872
|
+
* Designed for the Platform API's hot-path auth middleware: JWKS is
|
|
2873
|
+
* fetched once per process (1h TTL), signature/iss/aud/exp
|
|
2874
|
+
* verification is local `jose` — no per-request HTTPS hop.
|
|
2136
2875
|
*
|
|
2137
2876
|
* @example
|
|
2138
2877
|
* ```typescript
|
|
2139
|
-
* const
|
|
2140
|
-
*
|
|
2141
|
-
*
|
|
2142
|
-
* redirectUrl: 'https://app.example.com/signup',
|
|
2878
|
+
* const claims = await auth.verifyAccessToken(bearer, {
|
|
2879
|
+
* baseUrl: 'https://your-app.api.sylphx.com/v1',
|
|
2880
|
+
* audience: 'platform',
|
|
2143
2881
|
* })
|
|
2144
|
-
* console.log(invite.invitationToken, invite.expiresAt)
|
|
2145
2882
|
* ```
|
|
2146
2883
|
*/
|
|
2147
|
-
declare function
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
type DeviceApproveResult = DeviceApproveResponse;
|
|
2166
|
-
type DeviceDenyInput = DeviceDenyRequest;
|
|
2167
|
-
type DeviceDenyResult = DeviceDenyResponse;
|
|
2884
|
+
declare function verifyAccessToken(token: string, opts: {
|
|
2885
|
+
readonly baseUrl: string;
|
|
2886
|
+
readonly audience: string;
|
|
2887
|
+
}): Promise<PlatformAccessTokenClaims>;
|
|
2888
|
+
interface PlatformUserRecord {
|
|
2889
|
+
readonly id: string;
|
|
2890
|
+
readonly email: string;
|
|
2891
|
+
readonly name: string | null;
|
|
2892
|
+
readonly image: string | null;
|
|
2893
|
+
readonly emailVerified: boolean;
|
|
2894
|
+
readonly role: string;
|
|
2895
|
+
readonly twoFactorEnabled: boolean;
|
|
2896
|
+
}
|
|
2897
|
+
interface PlatformUserResolution {
|
|
2898
|
+
readonly user: PlatformUserRecord;
|
|
2899
|
+
readonly sessionId: string;
|
|
2900
|
+
}
|
|
2901
|
+
declare function resetPlatformCookieCache(): void;
|
|
2168
2902
|
/**
|
|
2169
|
-
* `
|
|
2170
|
-
*
|
|
2171
|
-
* Used by headless clients (CLI, TV apps, IoT) to authorise via a
|
|
2172
|
-
* companion browser instead of reading credentials from env vars.
|
|
2903
|
+
* `cookies` namespace — Platform cookie / session resolution for the
|
|
2904
|
+
* Platform API's hot-path auth middleware (ADR-089 Phase 3b).
|
|
2173
2905
|
*/
|
|
2174
|
-
declare const
|
|
2906
|
+
declare const cookies: {
|
|
2175
2907
|
/**
|
|
2176
|
-
*
|
|
2908
|
+
* Resolve a platform user from a forwarded `Cookie:` header.
|
|
2177
2909
|
*
|
|
2178
|
-
*
|
|
2179
|
-
*
|
|
2910
|
+
* Delegates to BaaS `/auth/platform-sessions/whoami`. Caches each
|
|
2911
|
+
* unique cookie string for 30s to avoid hammering BaaS on every
|
|
2912
|
+
* SSR request.
|
|
2180
2913
|
*
|
|
2181
2914
|
* @example
|
|
2182
2915
|
* ```typescript
|
|
2183
|
-
* const
|
|
2916
|
+
* const result = await auth.cookies.resolvePlatformUser({
|
|
2184
2917
|
* baseUrl: 'https://your-app.api.sylphx.com/v1',
|
|
2185
|
-
*
|
|
2186
|
-
* scope: ['org:read', 'project:*'],
|
|
2918
|
+
* cookieHeader: req.headers.get('cookie') ?? '',
|
|
2187
2919
|
* })
|
|
2188
|
-
*
|
|
2920
|
+
* if (!result) // unauthenticated
|
|
2189
2921
|
* ```
|
|
2190
2922
|
*/
|
|
2191
|
-
readonly
|
|
2923
|
+
readonly resolvePlatformUser: (opts: {
|
|
2192
2924
|
readonly baseUrl: string;
|
|
2193
|
-
readonly
|
|
2194
|
-
readonly scope?: readonly string[];
|
|
2925
|
+
readonly cookieHeader: string;
|
|
2195
2926
|
readonly userAgent?: string;
|
|
2196
|
-
}) => Promise<
|
|
2927
|
+
}) => Promise<PlatformUserResolution | null>;
|
|
2928
|
+
};
|
|
2929
|
+
|
|
2930
|
+
/**
|
|
2931
|
+
* Platform OAuth namespace.
|
|
2932
|
+
*
|
|
2933
|
+
* Backs `auth.oauth.*` while keeping OAuth AS protocol handling out of the
|
|
2934
|
+
* monolithic auth module. Public exports are re-exported from `auth.ts`.
|
|
2935
|
+
*/
|
|
2936
|
+
|
|
2937
|
+
type OAuthIntrospectResult = OAuthIntrospectResponse;
|
|
2938
|
+
interface MintAccessTokenClaims {
|
|
2939
|
+
readonly sub: string;
|
|
2940
|
+
readonly email: string;
|
|
2941
|
+
readonly name?: string;
|
|
2942
|
+
readonly email_verified: boolean;
|
|
2943
|
+
readonly app_id: string;
|
|
2944
|
+
readonly role: string;
|
|
2945
|
+
readonly org_id?: string;
|
|
2946
|
+
readonly org_slug?: string;
|
|
2947
|
+
readonly org_role?: string;
|
|
2948
|
+
readonly picture?: string;
|
|
2949
|
+
readonly pid?: string;
|
|
2950
|
+
}
|
|
2951
|
+
interface MintAccessTokenResult {
|
|
2952
|
+
readonly accessToken: string;
|
|
2953
|
+
readonly expiresIn: number;
|
|
2954
|
+
}
|
|
2955
|
+
interface OAuthClientCallOpts {
|
|
2956
|
+
readonly baseUrl: string;
|
|
2957
|
+
readonly clientId: string;
|
|
2958
|
+
readonly clientSecret?: string;
|
|
2959
|
+
readonly token: string;
|
|
2960
|
+
readonly tokenTypeHint?: 'access_token' | 'refresh_token';
|
|
2961
|
+
readonly userAgent?: string;
|
|
2962
|
+
}
|
|
2963
|
+
/**
|
|
2964
|
+
* `oauth` namespace — Platform OAuth operations backed by BaaS.
|
|
2965
|
+
*
|
|
2966
|
+
* Phase 3b adds `mintAccessToken` for the refresh handler migration;
|
|
2967
|
+
* Phase 5.1 layered in full authorization-server verbs
|
|
2968
|
+
* (`/oauth/token`, `/oauth/revoke`, `/oauth/introspect`).
|
|
2969
|
+
*/
|
|
2970
|
+
declare const oauth: {
|
|
2197
2971
|
/**
|
|
2198
|
-
*
|
|
2199
|
-
* 'denied' | 'expired'`. On `approved`, the result carries the OAuth
|
|
2200
|
-
* pair (access_token + refresh_token).
|
|
2972
|
+
* Mint a platform-audience access token from supplied claims.
|
|
2201
2973
|
*
|
|
2202
|
-
*
|
|
2203
|
-
*
|
|
2974
|
+
* Service-to-service call — authenticated via
|
|
2975
|
+
* `SYLPHX_INTERNAL_TOKEN` shared secret until ADR-068's
|
|
2976
|
+
* SPIFFE SVID mTLS platform-auth flip makes workload identity the
|
|
2977
|
+
* only accepted internal caller credential.
|
|
2204
2978
|
*/
|
|
2205
|
-
readonly
|
|
2979
|
+
readonly mintAccessToken: (opts: {
|
|
2980
|
+
readonly baseUrl: string;
|
|
2981
|
+
readonly internalToken: string;
|
|
2982
|
+
readonly claims: MintAccessTokenClaims;
|
|
2983
|
+
readonly userAgent?: string;
|
|
2984
|
+
}) => Promise<MintAccessTokenResult>;
|
|
2985
|
+
readonly exchangeAuthorizationCode: (opts: {
|
|
2986
|
+
readonly baseUrl: string;
|
|
2987
|
+
readonly clientId: string;
|
|
2988
|
+
readonly clientSecret?: string;
|
|
2989
|
+
readonly code: string;
|
|
2990
|
+
readonly redirectUri: string;
|
|
2991
|
+
readonly codeVerifier: string;
|
|
2992
|
+
}) => Promise<OAuthTokenResult>;
|
|
2993
|
+
readonly refreshAccessToken: (opts: {
|
|
2994
|
+
readonly baseUrl: string;
|
|
2995
|
+
readonly clientId: string;
|
|
2996
|
+
readonly clientSecret?: string;
|
|
2997
|
+
readonly refreshToken: string;
|
|
2998
|
+
readonly scope?: string;
|
|
2999
|
+
}) => Promise<OAuthTokenResult>;
|
|
3000
|
+
readonly pollDeviceToken: (opts: {
|
|
2206
3001
|
readonly baseUrl: string;
|
|
3002
|
+
readonly clientId: string;
|
|
2207
3003
|
readonly deviceCode: string;
|
|
3004
|
+
}) => Promise<OAuthPollResult>;
|
|
3005
|
+
readonly clientCredentialsToken: (opts: {
|
|
3006
|
+
readonly baseUrl: string;
|
|
3007
|
+
readonly clientId: string;
|
|
3008
|
+
readonly clientSecret: string;
|
|
3009
|
+
readonly scope?: string;
|
|
3010
|
+
}) => Promise<OAuthClientCredentialsResult>;
|
|
3011
|
+
readonly revokeToken: (opts: OAuthClientCallOpts) => Promise<void>;
|
|
3012
|
+
readonly introspectToken: (opts: OAuthClientCallOpts) => Promise<OAuthIntrospectResult>;
|
|
3013
|
+
};
|
|
3014
|
+
|
|
3015
|
+
/**
|
|
3016
|
+
* Platform password management SDK namespace.
|
|
3017
|
+
*
|
|
3018
|
+
* Backed by `/auth/platform-password/*` on the BaaS runtime. Crypto
|
|
3019
|
+
* primitives and breach checks stay server-side; callers only pass tokens
|
|
3020
|
+
* and plaintext password inputs over the established HTTPS boundary.
|
|
3021
|
+
*/
|
|
3022
|
+
|
|
3023
|
+
type PlatformPasswordStatusResult = PlatformPasswordStatusResponse;
|
|
3024
|
+
type PlatformPasswordSetInput = PlatformPasswordSetRequest;
|
|
3025
|
+
type PlatformPasswordSetResult = PlatformPasswordSetResponse;
|
|
3026
|
+
type PlatformPasswordChangeInput = PlatformPasswordChangeRequest;
|
|
3027
|
+
type PlatformPasswordChangeResult = PlatformPasswordChangeResponse;
|
|
3028
|
+
declare const password: {
|
|
3029
|
+
readonly status: (opts: {
|
|
3030
|
+
readonly baseUrl: string;
|
|
3031
|
+
readonly accessToken: string;
|
|
2208
3032
|
readonly userAgent?: string;
|
|
2209
|
-
}) => Promise<
|
|
2210
|
-
|
|
2211
|
-
* Browser leg — the approving user confirms the grant.
|
|
2212
|
-
*
|
|
2213
|
-
* Requires a valid platform-issued access token (`Authorization:
|
|
2214
|
-
* Bearer <accessToken>`) proving the user is logged in on the
|
|
2215
|
-
* Console. Typically called by the Console's `/device` verification
|
|
2216
|
-
* page server-side, forwarding the user's session JWT.
|
|
2217
|
-
*/
|
|
2218
|
-
readonly approve: (opts: {
|
|
3033
|
+
}) => Promise<PlatformPasswordStatusResult>;
|
|
3034
|
+
readonly set: (opts: {
|
|
2219
3035
|
readonly baseUrl: string;
|
|
2220
|
-
readonly userCode: string;
|
|
2221
3036
|
readonly accessToken: string;
|
|
3037
|
+
readonly password: string;
|
|
2222
3038
|
readonly userAgent?: string;
|
|
2223
|
-
}) => Promise<
|
|
2224
|
-
|
|
2225
|
-
* Browser leg — the user declines the grant.
|
|
2226
|
-
*
|
|
2227
|
-
* Requires a valid platform-issued access token just like `approve`.
|
|
2228
|
-
*/
|
|
2229
|
-
readonly deny: (opts: {
|
|
3039
|
+
}) => Promise<PlatformPasswordSetResult>;
|
|
3040
|
+
readonly change: (opts: {
|
|
2230
3041
|
readonly baseUrl: string;
|
|
2231
|
-
readonly userCode: string;
|
|
2232
3042
|
readonly accessToken: string;
|
|
3043
|
+
readonly currentPassword: string;
|
|
3044
|
+
readonly newPassword: string;
|
|
2233
3045
|
readonly userAgent?: string;
|
|
2234
|
-
}) => Promise<
|
|
3046
|
+
}) => Promise<PlatformPasswordChangeResult>;
|
|
2235
3047
|
};
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
}
|
|
3048
|
+
|
|
3049
|
+
/**
|
|
3050
|
+
* Platform session management SDK namespace.
|
|
3051
|
+
*
|
|
3052
|
+
* Backed by `/auth/platform-sessions/*` on the BaaS runtime. These helpers
|
|
3053
|
+
* accept platform-audience access tokens, not project `pk_`/`sk_` credentials.
|
|
3054
|
+
*/
|
|
3055
|
+
|
|
2245
3056
|
type PlatformSessionsListResult = PlatformSessionsListResponse;
|
|
2246
3057
|
type PlatformSessionRevokeInput = PlatformSessionRevokeRequest;
|
|
2247
3058
|
type PlatformSessionRevokeResult = PlatformSessionRevokeResponse;
|
|
@@ -2249,110 +3060,28 @@ type PlatformSessionRevokeOtherResult = PlatformSessionRevokeOtherResponse;
|
|
|
2249
3060
|
type PlatformSessionRevokeAllResult = PlatformSessionRevokeAllResponse;
|
|
2250
3061
|
type PlatformSessionRenameInput = PlatformSessionRenameRequest;
|
|
2251
3062
|
type PlatformSessionRenameResult = PlatformSessionRenameResponse;
|
|
2252
|
-
/**
|
|
2253
|
-
* `sessions` namespace — Platform-plane (Console / CLI) session
|
|
2254
|
-
* management. Backed by `/auth/platform-sessions/*` on the BaaS
|
|
2255
|
-
* runtime (ADR-089 Phase 2b). See module header for the full rationale.
|
|
2256
|
-
*/
|
|
2257
3063
|
declare const sessions: {
|
|
2258
|
-
/**
|
|
2259
|
-
* List every active platform session for the authenticated user.
|
|
2260
|
-
*
|
|
2261
|
-
* Ordering: most-recently-active first.
|
|
2262
|
-
*
|
|
2263
|
-
* @example
|
|
2264
|
-
* ```typescript
|
|
2265
|
-
* const { sessions } = await auth.sessions.list({
|
|
2266
|
-
* baseUrl: 'https://your-app.api.sylphx.com/v1',
|
|
2267
|
-
* accessToken: platformJwt,
|
|
2268
|
-
* })
|
|
2269
|
-
* ```
|
|
2270
|
-
*/
|
|
2271
3064
|
readonly list: (opts: {
|
|
2272
3065
|
readonly baseUrl: string;
|
|
2273
3066
|
readonly accessToken: string;
|
|
2274
3067
|
readonly userAgent?: string;
|
|
2275
3068
|
}) => Promise<PlatformSessionsListResult>;
|
|
2276
|
-
/**
|
|
2277
|
-
* Revoke a specific platform session by id.
|
|
2278
|
-
*
|
|
2279
|
-
* `sessionId` accepts either the prefixed TypeID (`sess_*`) or the
|
|
2280
|
-
* raw UUID — the BaaS side normalises via `parseIdOrError`.
|
|
2281
|
-
*
|
|
2282
|
-
* @example
|
|
2283
|
-
* ```typescript
|
|
2284
|
-
* await auth.sessions.revoke({
|
|
2285
|
-
* baseUrl,
|
|
2286
|
-
* accessToken,
|
|
2287
|
-
* sessionId: 'sess_01hxyz...',
|
|
2288
|
-
* })
|
|
2289
|
-
* ```
|
|
2290
|
-
*/
|
|
2291
3069
|
readonly revoke: (opts: {
|
|
2292
3070
|
readonly baseUrl: string;
|
|
2293
3071
|
readonly accessToken: string;
|
|
2294
3072
|
readonly sessionId: string;
|
|
2295
3073
|
readonly userAgent?: string;
|
|
2296
3074
|
}) => Promise<PlatformSessionRevokeResult>;
|
|
2297
|
-
/**
|
|
2298
|
-
* Revoke every platform session except the one presenting the
|
|
2299
|
-
* current access token. Used by "sign me out of all other devices".
|
|
2300
|
-
*
|
|
2301
|
-
* When the caller's JWT has no `sid` claim (pure-Bearer CLI/CI
|
|
2302
|
-
* flows), this degenerates to `revokeAll` — every session is
|
|
2303
|
-
* wiped — because there's no "current" row to keep.
|
|
2304
|
-
*
|
|
2305
|
-
* @example
|
|
2306
|
-
* ```typescript
|
|
2307
|
-
* const { revokedCount } = await auth.sessions.revokeOther({
|
|
2308
|
-
* baseUrl,
|
|
2309
|
-
* accessToken,
|
|
2310
|
-
* })
|
|
2311
|
-
* ```
|
|
2312
|
-
*/
|
|
2313
3075
|
readonly revokeOther: (opts: {
|
|
2314
3076
|
readonly baseUrl: string;
|
|
2315
3077
|
readonly accessToken: string;
|
|
2316
3078
|
readonly userAgent?: string;
|
|
2317
3079
|
}) => Promise<PlatformSessionRevokeOtherResult>;
|
|
2318
|
-
/**
|
|
2319
|
-
* Revoke every platform session for the user, including the
|
|
2320
|
-
* caller's own. Used by "sign me out everywhere" — after a
|
|
2321
|
-
* password change, a compromise scare, or GDPR-style erasure.
|
|
2322
|
-
*
|
|
2323
|
-
* The response includes the count of sessions that were
|
|
2324
|
-
* revoked so the caller can surface it in a toast or audit UI.
|
|
2325
|
-
*
|
|
2326
|
-
* @example
|
|
2327
|
-
* ```typescript
|
|
2328
|
-
* const { count } = await auth.sessions.revokeAll({
|
|
2329
|
-
* baseUrl,
|
|
2330
|
-
* accessToken,
|
|
2331
|
-
* })
|
|
2332
|
-
* ```
|
|
2333
|
-
*/
|
|
2334
3080
|
readonly revokeAll: (opts: {
|
|
2335
3081
|
readonly baseUrl: string;
|
|
2336
3082
|
readonly accessToken: string;
|
|
2337
3083
|
readonly userAgent?: string;
|
|
2338
3084
|
}) => Promise<PlatformSessionRevokeAllResult>;
|
|
2339
|
-
/**
|
|
2340
|
-
* Rename a platform session (device label).
|
|
2341
|
-
*
|
|
2342
|
-
* `sessionId` accepts either the prefixed TypeID or the raw UUID;
|
|
2343
|
-
* `name` is a user-supplied string (≤100 chars) surfaced in the
|
|
2344
|
-
* "Active sessions" Console UI.
|
|
2345
|
-
*
|
|
2346
|
-
* @example
|
|
2347
|
-
* ```typescript
|
|
2348
|
-
* await auth.sessions.rename({
|
|
2349
|
-
* baseUrl,
|
|
2350
|
-
* accessToken,
|
|
2351
|
-
* sessionId,
|
|
2352
|
-
* name: 'MacBook (work)',
|
|
2353
|
-
* })
|
|
2354
|
-
* ```
|
|
2355
|
-
*/
|
|
2356
3085
|
readonly rename: (opts: {
|
|
2357
3086
|
readonly baseUrl: string;
|
|
2358
3087
|
readonly accessToken: string;
|
|
@@ -2361,148 +3090,14 @@ declare const sessions: {
|
|
|
2361
3090
|
readonly userAgent?: string;
|
|
2362
3091
|
}) => Promise<PlatformSessionRenameResult>;
|
|
2363
3092
|
};
|
|
2364
|
-
|
|
2365
|
-
type PlatformRefreshResult = RefreshTokenResult;
|
|
2366
|
-
type PlatformLogoutInput = LogoutInput;
|
|
2367
|
-
/**
|
|
2368
|
-
* `platformAuth` namespace — Platform-plane refresh-token + logout
|
|
2369
|
-
* operations for CLI / Console operators. Body-authenticated via the
|
|
2370
|
-
* presented refresh token (no cookie, no Bearer).
|
|
2371
|
-
*/
|
|
2372
|
-
declare const platformAuth: {
|
|
2373
|
-
/**
|
|
2374
|
-
* Rotate a Platform refresh token. The presented token is consumed
|
|
2375
|
-
* single-use; the response carries a fresh access JWT plus the
|
|
2376
|
-
* rotated refresh token that supersedes it.
|
|
2377
|
-
*
|
|
2378
|
-
* On reuse-detection / expiry the server returns 401 — the SDK
|
|
2379
|
-
* preserves the upstream message so callers can pattern-match
|
|
2380
|
-
* `"reuse"` per RFC 6819 §5.2.2.3 and scrub local credentials.
|
|
2381
|
-
*
|
|
2382
|
-
* @example
|
|
2383
|
-
* ```typescript
|
|
2384
|
-
* const tokens = await auth.platformAuth.refresh({
|
|
2385
|
-
* baseUrl: 'https://sylphx.com',
|
|
2386
|
-
* refreshToken: stored.refreshToken,
|
|
2387
|
-
* })
|
|
2388
|
-
* ```
|
|
2389
|
-
*/
|
|
2390
|
-
readonly refresh: (opts: {
|
|
2391
|
-
readonly baseUrl: string;
|
|
2392
|
-
readonly refreshToken: string;
|
|
2393
|
-
readonly userAgent?: string;
|
|
2394
|
-
/**
|
|
2395
|
-
* Path prefix between `baseUrl` and the resource path. Defaults
|
|
2396
|
-
* to `/api/v1` for back-compat with the admin-override host
|
|
2397
|
-
* (`sylphx.com`). Pass `/v1` when targeting the canonical host
|
|
2398
|
-
* (`api.sylphx.com`) per Rule 17.
|
|
2399
|
-
*/
|
|
2400
|
-
readonly urlPrefix?: string;
|
|
2401
|
-
}) => Promise<PlatformRefreshResult>;
|
|
2402
|
-
/**
|
|
2403
|
-
* Revoke a Platform refresh token (logout). Server-side revocation
|
|
2404
|
-
* failure is the caller's call to surface — local-credential cleanup
|
|
2405
|
-
* is the CLI's responsibility (logout must succeed offline).
|
|
2406
|
-
*
|
|
2407
|
-
* @example
|
|
2408
|
-
* ```typescript
|
|
2409
|
-
* await auth.platformAuth.logout({
|
|
2410
|
-
* baseUrl: 'https://sylphx.com',
|
|
2411
|
-
* refreshToken: stored.refreshToken,
|
|
2412
|
-
* })
|
|
2413
|
-
* ```
|
|
2414
|
-
*/
|
|
2415
|
-
readonly logout: (opts: {
|
|
2416
|
-
readonly baseUrl: string;
|
|
2417
|
-
readonly refreshToken: string;
|
|
2418
|
-
readonly userAgent?: string;
|
|
2419
|
-
/** See `refresh.urlPrefix`. */
|
|
2420
|
-
readonly urlPrefix?: string;
|
|
2421
|
-
}) => Promise<void>;
|
|
2422
|
-
};
|
|
2423
|
-
type PlatformPasswordStatusResult = PlatformPasswordStatusResponse;
|
|
2424
|
-
type PlatformPasswordSetInput = PlatformPasswordSetRequest;
|
|
2425
|
-
type PlatformPasswordSetResult = PlatformPasswordSetResponse;
|
|
2426
|
-
type PlatformPasswordChangeInput = PlatformPasswordChangeRequest;
|
|
2427
|
-
type PlatformPasswordChangeResult = PlatformPasswordChangeResponse;
|
|
3093
|
+
|
|
2428
3094
|
/**
|
|
2429
|
-
*
|
|
2430
|
-
*
|
|
2431
|
-
*
|
|
3095
|
+
* Platform user GDPR export and erasure SDK namespace.
|
|
3096
|
+
*
|
|
3097
|
+
* These helpers are backed by `/auth/platform-user/*` on the BaaS runtime
|
|
3098
|
+
* and keep account data operations separate from generic auth/session helpers.
|
|
2432
3099
|
*/
|
|
2433
|
-
|
|
2434
|
-
/**
|
|
2435
|
-
* Check whether the authenticated platform user has a password set.
|
|
2436
|
-
*
|
|
2437
|
-
* Returns `{ hasPassword: true }` for users that signed up with
|
|
2438
|
-
* email+password (or later called `set`), `{ hasPassword: false }`
|
|
2439
|
-
* for OAuth-only users (e.g. signed up via Google/GitHub).
|
|
2440
|
-
*
|
|
2441
|
-
* @example
|
|
2442
|
-
* ```typescript
|
|
2443
|
-
* const { hasPassword } = await auth.password.status({
|
|
2444
|
-
* baseUrl: 'https://your-app.api.sylphx.com/v1',
|
|
2445
|
-
* accessToken: platformJwt,
|
|
2446
|
-
* })
|
|
2447
|
-
* ```
|
|
2448
|
-
*/
|
|
2449
|
-
readonly status: (opts: {
|
|
2450
|
-
readonly baseUrl: string;
|
|
2451
|
-
readonly accessToken: string;
|
|
2452
|
-
readonly userAgent?: string;
|
|
2453
|
-
}) => Promise<PlatformPasswordStatusResult>;
|
|
2454
|
-
/**
|
|
2455
|
-
* Set an initial password for an OAuth-only user.
|
|
2456
|
-
*
|
|
2457
|
-
* Fails with 400 if the user already has a password (use `change`
|
|
2458
|
-
* instead), if the password is <8 characters, or if HIBP reports
|
|
2459
|
-
* the password as breached. BaaS invalidates every other session
|
|
2460
|
-
* for the user (keeping the caller's current one) after a
|
|
2461
|
-
* successful set.
|
|
2462
|
-
*
|
|
2463
|
-
* @example
|
|
2464
|
-
* ```typescript
|
|
2465
|
-
* await auth.password.set({
|
|
2466
|
-
* baseUrl,
|
|
2467
|
-
* accessToken,
|
|
2468
|
-
* password: 'correct-horse-battery-staple',
|
|
2469
|
-
* })
|
|
2470
|
-
* ```
|
|
2471
|
-
*/
|
|
2472
|
-
readonly set: (opts: {
|
|
2473
|
-
readonly baseUrl: string;
|
|
2474
|
-
readonly accessToken: string;
|
|
2475
|
-
readonly password: string;
|
|
2476
|
-
readonly userAgent?: string;
|
|
2477
|
-
}) => Promise<PlatformPasswordSetResult>;
|
|
2478
|
-
/**
|
|
2479
|
-
* Change an existing password.
|
|
2480
|
-
*
|
|
2481
|
-
* Verifies `currentPassword` server-side; a mismatch returns 401.
|
|
2482
|
-
* OAuth-only users (no existing password) get 400 — use `set`
|
|
2483
|
-
* instead. New password must be ≥8 characters and must not be in
|
|
2484
|
-
* HIBP's breach database. BaaS invalidates every other session
|
|
2485
|
-
* for the user (keeping the caller's current one) after a
|
|
2486
|
-
* successful change.
|
|
2487
|
-
*
|
|
2488
|
-
* @example
|
|
2489
|
-
* ```typescript
|
|
2490
|
-
* await auth.password.change({
|
|
2491
|
-
* baseUrl,
|
|
2492
|
-
* accessToken,
|
|
2493
|
-
* currentPassword: 'old-plaintext',
|
|
2494
|
-
* newPassword: 'new-plaintext',
|
|
2495
|
-
* })
|
|
2496
|
-
* ```
|
|
2497
|
-
*/
|
|
2498
|
-
readonly change: (opts: {
|
|
2499
|
-
readonly baseUrl: string;
|
|
2500
|
-
readonly accessToken: string;
|
|
2501
|
-
readonly currentPassword: string;
|
|
2502
|
-
readonly newPassword: string;
|
|
2503
|
-
readonly userAgent?: string;
|
|
2504
|
-
}) => Promise<PlatformPasswordChangeResult>;
|
|
2505
|
-
};
|
|
3100
|
+
|
|
2506
3101
|
type PlatformUserExportResult = AuthUserExportResponse;
|
|
2507
3102
|
type PlatformUserDeleteInput = AuthUserDeleteRequest;
|
|
2508
3103
|
type PlatformUserDeleteResult = AuthUserDeleteResponse;
|
|
@@ -2520,15 +3115,6 @@ declare const user: {
|
|
|
2520
3115
|
* row, sessions, OAuth accounts, login history, security alerts,
|
|
2521
3116
|
* organization memberships, subscriptions, per-project memberships,
|
|
2522
3117
|
* and storage file metadata. Shape varies with customer provisioning.
|
|
2523
|
-
*
|
|
2524
|
-
* @example
|
|
2525
|
-
* ```typescript
|
|
2526
|
-
* const data = await auth.user.exportData({
|
|
2527
|
-
* baseUrl: 'https://your-app.api.sylphx.com/v1',
|
|
2528
|
-
* accessToken: platformJwt,
|
|
2529
|
-
* })
|
|
2530
|
-
* downloadAsJson(data, 'my-sylphx-data.json')
|
|
2531
|
-
* ```
|
|
2532
3118
|
*/
|
|
2533
3119
|
readonly exportData: (opts: {
|
|
2534
3120
|
readonly baseUrl: string;
|
|
@@ -2539,29 +3125,7 @@ declare const user: {
|
|
|
2539
3125
|
* Permanently delete the authenticated user's account (GDPR Article
|
|
2540
3126
|
* 17 — right to erasure). Cascades through every provisioned project
|
|
2541
3127
|
* DB, cancels Stripe subscriptions, deletes S3 blobs, and anonymises
|
|
2542
|
-
* billing transactions.
|
|
2543
|
-
* systems can clean up their own state.
|
|
2544
|
-
*
|
|
2545
|
-
* Returns `{ success: true, deletedData: [...] }` on success where
|
|
2546
|
-
* `deletedData` lists the resource kinds that were erased.
|
|
2547
|
-
*
|
|
2548
|
-
* @remarks
|
|
2549
|
-
* This operation is irreversible. Production callers SHOULD require
|
|
2550
|
-
* a challenge step (2FA / password confirm / WebAuthn) before
|
|
2551
|
-
* invoking this — the BaaS route does NOT perform challenge
|
|
2552
|
-
* verification in Phase 2d. ADR-089 Phase 5.11 lands passkey-primary
|
|
2553
|
-
* with WebAuthn-required step-up and will add the check at the
|
|
2554
|
-
* BaaS boundary.
|
|
2555
|
-
*
|
|
2556
|
-
* @example
|
|
2557
|
-
* ```typescript
|
|
2558
|
-
* const result = await auth.user.deleteAccount({
|
|
2559
|
-
* baseUrl,
|
|
2560
|
-
* accessToken,
|
|
2561
|
-
* reason: 'user_request',
|
|
2562
|
-
* })
|
|
2563
|
-
* if (result.success) signOutAndRedirect('/goodbye')
|
|
2564
|
-
* ```
|
|
3128
|
+
* billing transactions.
|
|
2565
3129
|
*/
|
|
2566
3130
|
readonly deleteAccount: (opts: {
|
|
2567
3131
|
readonly baseUrl: string;
|
|
@@ -2570,37 +3134,15 @@ declare const user: {
|
|
|
2570
3134
|
readonly userAgent?: string;
|
|
2571
3135
|
}) => Promise<PlatformUserDeleteResult>;
|
|
2572
3136
|
/**
|
|
2573
|
-
* Async GDPR Article 20 export job API (ADR-089 Phase 5.5).
|
|
2574
|
-
*
|
|
2575
|
-
* `user.exportData` above is the Phase 2d synchronous shortcut —
|
|
2576
|
-
* kept for backward compat but production callers SHOULD prefer the
|
|
2577
|
-
* async flow: large users routinely exceed a single HTTP deadline
|
|
2578
|
-
* during enumeration.
|
|
2579
|
-
*
|
|
2580
|
-
* Typical flow:
|
|
2581
|
-
*
|
|
2582
|
-
* ```ts
|
|
2583
|
-
* const job = await auth.user.exports.initiate({ baseUrl, accessToken })
|
|
2584
|
-
* // Poll until terminal:
|
|
2585
|
-
* while (true) {
|
|
2586
|
-
* const cur = await auth.user.exports.status({ baseUrl, accessToken, id: job.id })
|
|
2587
|
-
* if (cur.status === 'complete') break
|
|
2588
|
-
* if (cur.status === 'failed') throw new Error(cur.errorMessage ?? 'export failed')
|
|
2589
|
-
* await new Promise(r => setTimeout(r, 2000))
|
|
2590
|
-
* }
|
|
2591
|
-
* const blob = await auth.user.exports.download({ baseUrl, accessToken, id: job.id })
|
|
2592
|
-
* saveAs(blob, 'sylphx-export.json')
|
|
2593
|
-
* ```
|
|
3137
|
+
* Async GDPR Article 20 export job API (ADR-089 Phase 5.5).
|
|
2594
3138
|
*
|
|
2595
|
-
*
|
|
2596
|
-
*
|
|
3139
|
+
* `user.exportData` is the Phase 2d synchronous shortcut; production
|
|
3140
|
+
* callers should prefer the async flow for large accounts.
|
|
2597
3141
|
*/
|
|
2598
3142
|
readonly exports: {
|
|
2599
3143
|
/**
|
|
2600
|
-
* Kick off an export job.
|
|
2601
|
-
*
|
|
2602
|
-
* request but the payload is not yet materialized. Poll
|
|
2603
|
-
* `status({ id })` until `status === 'complete'`.
|
|
3144
|
+
* Kick off an export job. Poll `status({ id })` until
|
|
3145
|
+
* `status === 'complete'`.
|
|
2604
3146
|
*/
|
|
2605
3147
|
readonly initiate: (opts: {
|
|
2606
3148
|
readonly baseUrl: string;
|
|
@@ -2610,9 +3152,6 @@ declare const user: {
|
|
|
2610
3152
|
}) => Promise<DataExportJob>;
|
|
2611
3153
|
/**
|
|
2612
3154
|
* Read the current state of an in-flight or completed export job.
|
|
2613
|
-
* Returns 404 (via thrown `SylphxError`) if the job id is unknown
|
|
2614
|
-
* OR owned by a different user — cross-user probes can't
|
|
2615
|
-
* distinguish the two.
|
|
2616
3155
|
*/
|
|
2617
3156
|
readonly status: (opts: {
|
|
2618
3157
|
readonly baseUrl: string;
|
|
@@ -2622,12 +3161,8 @@ declare const user: {
|
|
|
2622
3161
|
}) => Promise<DataExportJob>;
|
|
2623
3162
|
/**
|
|
2624
3163
|
* Download the completed export payload. The BaaS route returns a
|
|
2625
|
-
* 302 to a freshly-signed object-storage URL;
|
|
2626
|
-
*
|
|
2627
|
-
*
|
|
2628
|
-
* The integrity headers `X-Sylphx-Export-Sha256` + `X-Sylphx-Export-Size`
|
|
2629
|
-
* are available on the final response — CLI consumers SHOULD verify
|
|
2630
|
-
* the SHA-256 client-side before handing the archive to the user.
|
|
3164
|
+
* 302 to a freshly-signed object-storage URL; `fetch` follows it
|
|
3165
|
+
* and resolves to the raw `Blob`.
|
|
2631
3166
|
*/
|
|
2632
3167
|
readonly download: (opts: {
|
|
2633
3168
|
readonly baseUrl: string;
|
|
@@ -2642,11 +3177,8 @@ declare const user: {
|
|
|
2642
3177
|
};
|
|
2643
3178
|
};
|
|
2644
3179
|
/**
|
|
2645
|
-
* Wire shape of a data-export job. `status` progresses through
|
|
2646
|
-
*
|
|
2647
|
-
* complete rows additionally carry `sizeBytes` + `sha256`, failed rows
|
|
2648
|
-
* carry `errorMessage`. `downloadUrl` is always null in this projection
|
|
2649
|
-
* — use `user.exports.download()` to obtain a freshly-signed URL.
|
|
3180
|
+
* Wire shape of a data-export job. `status` progresses through pending,
|
|
3181
|
+
* running, complete, or failed.
|
|
2650
3182
|
*/
|
|
2651
3183
|
interface DataExportJob {
|
|
2652
3184
|
readonly id: string;
|
|
@@ -2659,600 +3191,430 @@ interface DataExportJob {
|
|
|
2659
3191
|
readonly sha256: string | null;
|
|
2660
3192
|
readonly errorMessage: string | null;
|
|
2661
3193
|
}
|
|
3194
|
+
|
|
2662
3195
|
/**
|
|
2663
|
-
*
|
|
2664
|
-
*
|
|
2665
|
-
*
|
|
3196
|
+
* Auth Functions
|
|
3197
|
+
*
|
|
3198
|
+
* Pure functions for authentication - no hidden state.
|
|
3199
|
+
* Each function takes config as the first parameter.
|
|
3200
|
+
*
|
|
3201
|
+
* Uses REST API at /api/sdk/auth/* for all operations.
|
|
3202
|
+
*
|
|
3203
|
+
* Types are re-exported from `@sylphx/contract` (ADR-084). The contract is
|
|
3204
|
+
* the single source of truth for every wire shape — this module only adds
|
|
3205
|
+
* SDK-specific ergonomics (User brand swap, introspection result, invite
|
|
3206
|
+
* envelopes, org-token claims).
|
|
2666
3207
|
*/
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
3208
|
+
|
|
3209
|
+
type LoginRequest = LoginRequest$1;
|
|
3210
|
+
type LoginResponse = LoginResponse$1;
|
|
3211
|
+
type RegisterRequest = RegisterRequest$1;
|
|
3212
|
+
type RegisterResponse = RegisterResponse$1;
|
|
3213
|
+
type ResendEmailVerificationRequest = ResendEmailVerificationRequest$1;
|
|
3214
|
+
type ResendEmailVerificationResponse = ResendEmailVerificationResponse$1;
|
|
3215
|
+
/**
|
|
3216
|
+
* Token response — contract's `AuthTokensResponse.user` (optional `AuthUser`)
|
|
3217
|
+
* is re-mapped to the SDK's broader `User` type so legacy callers keep the
|
|
3218
|
+
* familiar brand. `AuthUser` and `User` are structurally identical, but
|
|
3219
|
+
* the SDK surface has wider reach (cookies, middleware, React hooks) and
|
|
3220
|
+
* renaming is out of scope for ADR-084 cleanup.
|
|
3221
|
+
*/
|
|
3222
|
+
type TokenResponse = Omit<AuthTokensResponse, 'user'> & {
|
|
3223
|
+
user: User;
|
|
3224
|
+
};
|
|
3225
|
+
type TwoFactorVerifyRequest = TwoFactorVerifyRequest$1;
|
|
3226
|
+
/**
|
|
3227
|
+
* `GET /auth/me` — contract's `UserFullProfile` already includes the
|
|
3228
|
+
* optional `emailVerified` flag the backend returns, so the SDK can just
|
|
3229
|
+
* alias the contract type directly.
|
|
3230
|
+
*/
|
|
3231
|
+
type MeResponse = UserFullProfile$1;
|
|
3232
|
+
/**
|
|
3233
|
+
* Token introspection result (RFC 7662)
|
|
3234
|
+
*/
|
|
3235
|
+
interface TokenIntrospectionResult {
|
|
3236
|
+
/** Whether the token is active/valid */
|
|
3237
|
+
active: boolean;
|
|
3238
|
+
/** Token type (access_token or refresh_token) */
|
|
3239
|
+
token_type?: 'access_token' | 'refresh_token';
|
|
3240
|
+
/** User ID */
|
|
3241
|
+
sub?: string;
|
|
3242
|
+
/** User email */
|
|
3243
|
+
email?: string;
|
|
3244
|
+
/** User name */
|
|
3245
|
+
name?: string;
|
|
3246
|
+
/** App ID */
|
|
3247
|
+
client_id?: string;
|
|
3248
|
+
/** Audience */
|
|
3249
|
+
aud?: string;
|
|
3250
|
+
/** Issuer */
|
|
3251
|
+
iss?: string;
|
|
3252
|
+
/** Expiration time (Unix timestamp) */
|
|
3253
|
+
exp?: number;
|
|
3254
|
+
/** Issued at time (Unix timestamp) */
|
|
3255
|
+
iat?: number;
|
|
3256
|
+
/** User role */
|
|
3257
|
+
role?: string;
|
|
3258
|
+
/** Email verification status */
|
|
3259
|
+
email_verified?: boolean;
|
|
3260
|
+
}
|
|
3261
|
+
/**
|
|
3262
|
+
* Token revocation options
|
|
3263
|
+
*/
|
|
3264
|
+
interface RevokeTokenOptions {
|
|
3265
|
+
/** Revoke all tokens for a user in this app */
|
|
3266
|
+
revokeAll?: boolean;
|
|
3267
|
+
/** User ID (required when revoking all) */
|
|
3268
|
+
userId?: string;
|
|
3269
|
+
}
|
|
3270
|
+
interface SessionResult {
|
|
3271
|
+
user: {
|
|
3272
|
+
id: string;
|
|
3273
|
+
email: string;
|
|
3274
|
+
name: string | null;
|
|
3275
|
+
image: string | null;
|
|
3276
|
+
emailVerified: boolean;
|
|
3277
|
+
} | null;
|
|
3278
|
+
}
|
|
3279
|
+
/**
|
|
3280
|
+
* Extended registration input with metadata and invitation token support.
|
|
3281
|
+
* Use extendedSignUp() when you need to pass metadata or an invitation token.
|
|
3282
|
+
*/
|
|
3283
|
+
interface RegisterInput {
|
|
3284
|
+
email: string;
|
|
3285
|
+
password: string;
|
|
3286
|
+
name?: string;
|
|
3287
|
+
metadata?: Record<string, unknown>;
|
|
3288
|
+
invitationToken?: string;
|
|
3289
|
+
}
|
|
3290
|
+
/**
|
|
3291
|
+
* Org context claims present in org-scoped tokens (after switch-org).
|
|
3292
|
+
*
|
|
3293
|
+
* The JWT carries the role key only. Permissions are resolved server-side
|
|
3294
|
+
* via cached role→permissions lookup (WorkOS pattern). This keeps
|
|
3295
|
+
* tokens small and ensures permission changes take effect without token refresh.
|
|
3296
|
+
*/
|
|
3297
|
+
interface OrgTokenPayload {
|
|
3298
|
+
org_id: string;
|
|
3299
|
+
org_slug: string;
|
|
3300
|
+
/** RBAC role key (e.g. "hr_manager", "admin"). Permissions resolved server-side. */
|
|
3301
|
+
org_role: string;
|
|
3302
|
+
}
|
|
3303
|
+
interface OrgScopedTokenResponse {
|
|
3304
|
+
/** Org-scoped access token. */
|
|
3305
|
+
token: string;
|
|
3306
|
+
/** Org-scoped access token, matching the SDK's token naming convention. */
|
|
3307
|
+
accessToken: string;
|
|
3308
|
+
/** Token lifetime in seconds, when provided by the runtime. */
|
|
3309
|
+
expiresIn?: number;
|
|
3310
|
+
/** Bearer token type, when provided by the runtime. */
|
|
3311
|
+
tokenType?: string;
|
|
3312
|
+
/** User envelope returned by the runtime for session hydration. */
|
|
3313
|
+
user?: User;
|
|
3314
|
+
}
|
|
3315
|
+
/**
|
|
3316
|
+
* Invite a user request payload.
|
|
3317
|
+
*/
|
|
3318
|
+
interface InviteUserRequest {
|
|
3319
|
+
email: string;
|
|
3320
|
+
metadata?: Record<string, unknown>;
|
|
3321
|
+
redirectUrl?: string;
|
|
3322
|
+
}
|
|
3323
|
+
/**
|
|
3324
|
+
* Response from inviteUser.
|
|
3325
|
+
*/
|
|
3326
|
+
interface InviteUserResponse {
|
|
3327
|
+
invitationToken: string;
|
|
3328
|
+
expiresAt: string;
|
|
2704
3329
|
}
|
|
2705
3330
|
/**
|
|
2706
|
-
*
|
|
3331
|
+
* Sign in with email and password
|
|
3332
|
+
*
|
|
3333
|
+
* @example
|
|
3334
|
+
* ```typescript
|
|
3335
|
+
* const result = await signIn(config, { email: 'user@example.com', password: 'secret' })
|
|
3336
|
+
* if (result.requiresTwoFactor) {
|
|
3337
|
+
* // Handle 2FA flow
|
|
3338
|
+
* } else {
|
|
3339
|
+
* // Save tokens
|
|
3340
|
+
* const authenticatedConfig = withToken(config, result.accessToken!)
|
|
3341
|
+
* }
|
|
3342
|
+
* ```
|
|
3343
|
+
*/
|
|
3344
|
+
declare function signIn(config: SylphxConfig, input: LoginRequest): Promise<LoginResponse>;
|
|
3345
|
+
/**
|
|
3346
|
+
* Sign up with email and password
|
|
3347
|
+
*
|
|
3348
|
+
* @example
|
|
3349
|
+
* ```typescript
|
|
3350
|
+
* const result = await signUp(config, {
|
|
3351
|
+
* email: 'user@example.com',
|
|
3352
|
+
* password: 'secret',
|
|
3353
|
+
* name: 'John Doe',
|
|
3354
|
+
* })
|
|
3355
|
+
* // User needs to verify email
|
|
3356
|
+
* ```
|
|
3357
|
+
*/
|
|
3358
|
+
declare function signUp(config: SylphxConfig, input: RegisterRequest): Promise<RegisterResponse>;
|
|
3359
|
+
/**
|
|
3360
|
+
* Sign out (revoke tokens)
|
|
3361
|
+
*
|
|
3362
|
+
* @example
|
|
3363
|
+
* ```typescript
|
|
3364
|
+
* await signOut(config)
|
|
3365
|
+
* ```
|
|
3366
|
+
*/
|
|
3367
|
+
declare function signOut(config: SylphxConfig): Promise<void>;
|
|
3368
|
+
/**
|
|
3369
|
+
* Refresh access token
|
|
3370
|
+
*
|
|
3371
|
+
* @example
|
|
3372
|
+
* ```typescript
|
|
3373
|
+
* const tokens = await refreshToken(config, refreshTokenString)
|
|
3374
|
+
* const newConfig = withToken(config, tokens.accessToken)
|
|
3375
|
+
* ```
|
|
3376
|
+
*/
|
|
3377
|
+
declare function refreshToken(config: SylphxConfig, token: string): Promise<TokenResponse>;
|
|
3378
|
+
/**
|
|
3379
|
+
* Verify email with token
|
|
3380
|
+
*
|
|
3381
|
+
* @example
|
|
3382
|
+
* ```typescript
|
|
3383
|
+
* await verifyEmail(config, token)
|
|
3384
|
+
* ```
|
|
3385
|
+
*/
|
|
3386
|
+
declare function verifyEmail(config: SylphxConfig, token: string): Promise<void>;
|
|
3387
|
+
/**
|
|
3388
|
+
* Request password reset email
|
|
3389
|
+
*
|
|
3390
|
+
* @example
|
|
3391
|
+
* ```typescript
|
|
3392
|
+
* await forgotPassword(config, 'user@example.com', {
|
|
3393
|
+
* redirectUrl: 'https://app.example.com/reset-password'
|
|
3394
|
+
* })
|
|
3395
|
+
* ```
|
|
3396
|
+
*/
|
|
3397
|
+
declare function forgotPassword(config: SylphxConfig, email: string, options?: {
|
|
3398
|
+
redirectUrl?: string;
|
|
3399
|
+
}): Promise<void>;
|
|
3400
|
+
/**
|
|
3401
|
+
* Request a verification email resend.
|
|
3402
|
+
*
|
|
3403
|
+
* The Platform response is intentionally privacy-preserving: it never
|
|
3404
|
+
* indicates whether the email exists or is already verified.
|
|
3405
|
+
*
|
|
3406
|
+
* @example
|
|
3407
|
+
* ```typescript
|
|
3408
|
+
* await resendVerificationEmail(config, 'user@example.com')
|
|
3409
|
+
* ```
|
|
3410
|
+
*/
|
|
3411
|
+
declare function resendVerificationEmail(config: SylphxConfig, email: string): Promise<void>;
|
|
3412
|
+
/**
|
|
3413
|
+
* Reset password with token
|
|
2707
3414
|
*
|
|
2708
|
-
*
|
|
2709
|
-
*
|
|
2710
|
-
*
|
|
3415
|
+
* @example
|
|
3416
|
+
* ```typescript
|
|
3417
|
+
* await resetPassword(config, { token, password: 'newpassword' })
|
|
3418
|
+
* ```
|
|
3419
|
+
*/
|
|
3420
|
+
declare function resetPassword(config: SylphxConfig, input: {
|
|
3421
|
+
token: string;
|
|
3422
|
+
password: string;
|
|
3423
|
+
}): Promise<void>;
|
|
3424
|
+
/**
|
|
3425
|
+
* Get current session (requires authenticated config)
|
|
2711
3426
|
*
|
|
2712
3427
|
* @example
|
|
2713
3428
|
* ```typescript
|
|
2714
|
-
* const
|
|
2715
|
-
*
|
|
2716
|
-
*
|
|
2717
|
-
* }
|
|
3429
|
+
* const session = await getSession(authenticatedConfig)
|
|
3430
|
+
* if (session.user) {
|
|
3431
|
+
* console.log(`Logged in as ${session.user.email}`)
|
|
3432
|
+
* }
|
|
2718
3433
|
* ```
|
|
2719
3434
|
*/
|
|
2720
|
-
declare function
|
|
2721
|
-
readonly baseUrl: string;
|
|
2722
|
-
readonly audience: string;
|
|
2723
|
-
}): Promise<PlatformAccessTokenClaims>;
|
|
2724
|
-
interface PlatformUserRecord {
|
|
2725
|
-
readonly id: string;
|
|
2726
|
-
readonly email: string;
|
|
2727
|
-
readonly name: string | null;
|
|
2728
|
-
readonly image: string | null;
|
|
2729
|
-
readonly emailVerified: boolean;
|
|
2730
|
-
readonly role: string;
|
|
2731
|
-
readonly twoFactorEnabled: boolean;
|
|
2732
|
-
}
|
|
2733
|
-
interface PlatformUserResolution {
|
|
2734
|
-
readonly user: PlatformUserRecord;
|
|
2735
|
-
readonly sessionId: string;
|
|
2736
|
-
}
|
|
2737
|
-
declare function resetPlatformCookieCache(): void;
|
|
3435
|
+
declare function getSession(config: SylphxConfig): Promise<SessionResult>;
|
|
2738
3436
|
/**
|
|
2739
|
-
*
|
|
2740
|
-
*
|
|
3437
|
+
* Verify 2FA code (when signIn returns requiresTwoFactor: true)
|
|
3438
|
+
*
|
|
3439
|
+
* @example
|
|
3440
|
+
* ```typescript
|
|
3441
|
+
* const result = await signIn(config, credentials)
|
|
3442
|
+
* if (result.requiresTwoFactor) {
|
|
3443
|
+
* const tokens = await verifyTwoFactor(config, result.userId!, code)
|
|
3444
|
+
* }
|
|
3445
|
+
* ```
|
|
2741
3446
|
*/
|
|
2742
|
-
declare
|
|
2743
|
-
/**
|
|
2744
|
-
* Resolve a platform user from a forwarded `Cookie:` header.
|
|
2745
|
-
*
|
|
2746
|
-
* Delegates to BaaS `/auth/platform-sessions/whoami`. Caches each
|
|
2747
|
-
* unique cookie string for 30s to avoid hammering BaaS on every
|
|
2748
|
-
* SSR request.
|
|
2749
|
-
*
|
|
2750
|
-
* @example
|
|
2751
|
-
* ```typescript
|
|
2752
|
-
* const result = await auth.cookies.resolvePlatformUser({
|
|
2753
|
-
* baseUrl: 'https://your-app.api.sylphx.com/v1',
|
|
2754
|
-
* cookieHeader: req.headers.get('cookie') ?? '',
|
|
2755
|
-
* })
|
|
2756
|
-
* if (!result) // unauthenticated
|
|
2757
|
-
* ```
|
|
2758
|
-
*/
|
|
2759
|
-
readonly resolvePlatformUser: (opts: {
|
|
2760
|
-
readonly baseUrl: string;
|
|
2761
|
-
readonly cookieHeader: string;
|
|
2762
|
-
readonly userAgent?: string;
|
|
2763
|
-
}) => Promise<PlatformUserResolution | null>;
|
|
2764
|
-
};
|
|
2765
|
-
interface MintAccessTokenClaims {
|
|
2766
|
-
readonly sub: string;
|
|
2767
|
-
readonly email: string;
|
|
2768
|
-
readonly name?: string;
|
|
2769
|
-
readonly email_verified: boolean;
|
|
2770
|
-
readonly app_id: string;
|
|
2771
|
-
readonly role: string;
|
|
2772
|
-
readonly org_id?: string;
|
|
2773
|
-
readonly org_slug?: string;
|
|
2774
|
-
readonly org_role?: string;
|
|
2775
|
-
readonly picture?: string;
|
|
2776
|
-
readonly pid?: string;
|
|
2777
|
-
}
|
|
2778
|
-
interface MintAccessTokenResult {
|
|
2779
|
-
readonly accessToken: string;
|
|
2780
|
-
readonly expiresIn: number;
|
|
2781
|
-
}
|
|
3447
|
+
declare function verifyTwoFactor(config: SylphxConfig, userId: string, code: string): Promise<TokenResponse>;
|
|
2782
3448
|
/**
|
|
2783
|
-
*
|
|
3449
|
+
* Introspect a token to check its validity (RFC 7662)
|
|
2784
3450
|
*
|
|
2785
|
-
*
|
|
2786
|
-
*
|
|
2787
|
-
*
|
|
3451
|
+
* Use this to verify token status without decoding. Essential for:
|
|
3452
|
+
* - Checking if a token has been revoked
|
|
3453
|
+
* - Validating tokens at the edge
|
|
3454
|
+
* - Security-critical operations
|
|
2788
3455
|
*
|
|
2789
|
-
*
|
|
2790
|
-
*
|
|
2791
|
-
*
|
|
2792
|
-
*
|
|
2793
|
-
*
|
|
2794
|
-
*
|
|
2795
|
-
*
|
|
2796
|
-
*
|
|
2797
|
-
* precedent). Until then, these two methods stay on explicit fetch().
|
|
3456
|
+
* @example
|
|
3457
|
+
* ```typescript
|
|
3458
|
+
* const result = await introspectToken(config, accessToken)
|
|
3459
|
+
* if (!result.active) {
|
|
3460
|
+
* // Token is invalid, revoked, or expired
|
|
3461
|
+
* await refreshTokens()
|
|
3462
|
+
* }
|
|
3463
|
+
* ```
|
|
2798
3464
|
*/
|
|
2799
|
-
declare
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
readonly redirectUri: string;
|
|
2850
|
-
readonly codeVerifier: string;
|
|
2851
|
-
}) => Promise<OAuthTokenResult>;
|
|
2852
|
-
/**
|
|
2853
|
-
* Refresh a platform access token using a refresh_token
|
|
2854
|
-
* (ADR-089 Phase 5.1b — RFC 6749 §6). Rotation is mandatory — the
|
|
2855
|
-
* presented refresh token is consumed and a new one returned.
|
|
2856
|
-
*
|
|
2857
|
-
* @example
|
|
2858
|
-
* ```typescript
|
|
2859
|
-
* const tokens = await auth.oauth.refreshAccessToken({
|
|
2860
|
-
* baseUrl: 'https://api.sylphx.com/v1',
|
|
2861
|
-
* clientId: 'sylphx-console',
|
|
2862
|
-
* clientSecret: process.env.CONSOLE_CLIENT_SECRET,
|
|
2863
|
-
* refreshToken: stored.refresh_token,
|
|
2864
|
-
* })
|
|
2865
|
-
* ```
|
|
2866
|
-
*/
|
|
2867
|
-
readonly refreshAccessToken: (opts: {
|
|
2868
|
-
readonly baseUrl: string;
|
|
2869
|
-
readonly clientId: string;
|
|
2870
|
-
readonly clientSecret?: string;
|
|
2871
|
-
readonly refreshToken: string;
|
|
2872
|
-
readonly scope?: string;
|
|
2873
|
-
}) => Promise<OAuthTokenResult>;
|
|
2874
|
-
/**
|
|
2875
|
-
* Poll the OAuth token endpoint for a device-code grant (ADR-089 Phase
|
|
2876
|
-
* 5.1c — RFC 8628 §3.4). The preferred way to exchange an approved
|
|
2877
|
-
* device grant for tokens — returns an RFC 6749 error envelope on the
|
|
2878
|
-
* `{pending, slow_down, denied, expired}` states so callers can
|
|
2879
|
-
* distinguish precisely without parsing Phase 2a's `/auth/device/poll`
|
|
2880
|
-
* status string.
|
|
2881
|
-
*
|
|
2882
|
-
* Returns `{ ok: true, tokens }` on success or `{ ok: false, error }`
|
|
2883
|
-
* for every RFC-defined polling outcome. Callers MUST honour the
|
|
2884
|
-
* polling `interval` returned by `/auth/device` — polling faster yields
|
|
2885
|
-
* `{ ok: false, error: 'slow_down' }`.
|
|
2886
|
-
*
|
|
2887
|
-
* @example
|
|
2888
|
-
* ```typescript
|
|
2889
|
-
* while (true) {
|
|
2890
|
-
* await sleep(interval * 1000)
|
|
2891
|
-
* const r = await auth.oauth.pollDeviceToken({
|
|
2892
|
-
* baseUrl: 'https://api.sylphx.com/v1',
|
|
2893
|
-
* clientId: 'sylphx-cli',
|
|
2894
|
-
* deviceCode,
|
|
2895
|
-
* })
|
|
2896
|
-
* if (r.ok) return r.tokens
|
|
2897
|
-
* if (r.error === 'authorization_pending' || r.error === 'slow_down') continue
|
|
2898
|
-
* throw new Error(r.error) // access_denied | expired_token
|
|
2899
|
-
* }
|
|
2900
|
-
* ```
|
|
2901
|
-
*/
|
|
2902
|
-
readonly pollDeviceToken: (opts: {
|
|
2903
|
-
readonly baseUrl: string;
|
|
2904
|
-
readonly clientId: string;
|
|
2905
|
-
readonly deviceCode: string;
|
|
2906
|
-
}) => Promise<OAuthPollResult>;
|
|
2907
|
-
/**
|
|
2908
|
-
* Mint a service-principal access token via the `client_credentials`
|
|
2909
|
-
* grant (ADR-089 Phase 5.1c — RFC 6749 §4.4). Requires a confidential
|
|
2910
|
-
* client (public clients cannot use this grant). No refresh token is
|
|
2911
|
-
* issued per §4.4.3 — callers re-run this exchange on expiry.
|
|
2912
|
-
*
|
|
2913
|
-
* Typical use: CI integrations, server-to-server automation that has
|
|
2914
|
-
* no human owner and cannot run a device flow.
|
|
2915
|
-
*
|
|
2916
|
-
* @example
|
|
2917
|
-
* ```typescript
|
|
2918
|
-
* const { access_token } = await auth.oauth.clientCredentialsToken({
|
|
2919
|
-
* baseUrl: 'https://api.sylphx.com/v1',
|
|
2920
|
-
* clientId: process.env.SYLPHX_CLIENT_ID!,
|
|
2921
|
-
* clientSecret: process.env.SYLPHX_CLIENT_SECRET!,
|
|
2922
|
-
* scope: 'tenants:provision',
|
|
2923
|
-
* })
|
|
2924
|
-
* ```
|
|
2925
|
-
*/
|
|
2926
|
-
readonly clientCredentialsToken: (opts: {
|
|
2927
|
-
readonly baseUrl: string;
|
|
2928
|
-
readonly clientId: string;
|
|
2929
|
-
readonly clientSecret: string;
|
|
2930
|
-
readonly scope?: string;
|
|
2931
|
-
}) => Promise<OAuthClientCredentialsResult>;
|
|
2932
|
-
/**
|
|
2933
|
-
* Revoke an OAuth access or refresh token (RFC 7009 — ADR-089 Phase 5.1d).
|
|
2934
|
-
*
|
|
2935
|
-
* Per §2.2 this always resolves successfully — the server returns 200
|
|
2936
|
-
* whether the token existed, was already revoked, or belonged to a
|
|
2937
|
-
* different client. Only true protocol-level failures (malformed
|
|
2938
|
-
* request, bad client credentials) throw.
|
|
2939
|
-
*
|
|
2940
|
-
* @example
|
|
2941
|
-
* ```typescript
|
|
2942
|
-
* await auth.oauth.revokeToken({
|
|
2943
|
-
* baseUrl: 'https://your-app.api.sylphx.com/v1',
|
|
2944
|
-
* clientId: 'sylphx-cli',
|
|
2945
|
-
* token: refreshToken,
|
|
2946
|
-
* tokenTypeHint: 'refresh_token',
|
|
2947
|
-
* })
|
|
2948
|
-
* ```
|
|
2949
|
-
*/
|
|
2950
|
-
readonly revokeToken: (opts: OAuthClientCallOpts) => Promise<void>;
|
|
2951
|
-
/**
|
|
2952
|
-
* Introspect an OAuth access or refresh token (RFC 7662 — ADR-089 Phase 5.1d).
|
|
2953
|
-
*
|
|
2954
|
-
* Returns `{ active: false }` for expired / revoked / unknown /
|
|
2955
|
-
* not-owned tokens (without revealing which); `{ active: true, ... }`
|
|
2956
|
-
* with full claims for live ones. Only protocol-level failures
|
|
2957
|
-
* (4xx on the revocation envelope itself) throw.
|
|
2958
|
-
*
|
|
2959
|
-
* @example
|
|
2960
|
-
* ```typescript
|
|
2961
|
-
* const result = await auth.oauth.introspectToken({
|
|
2962
|
-
* baseUrl: 'https://your-app.api.sylphx.com/v1',
|
|
2963
|
-
* clientId: 'gateway',
|
|
2964
|
-
* clientSecret: process.env.GATEWAY_SECRET,
|
|
2965
|
-
* token: accessToken,
|
|
2966
|
-
* })
|
|
2967
|
-
* if (!result.active) throw new Error('token not accepted')
|
|
2968
|
-
* ```
|
|
2969
|
-
*/
|
|
2970
|
-
readonly introspectToken: (opts: OAuthClientCallOpts) => Promise<OAuthIntrospectResult>;
|
|
2971
|
-
};
|
|
3465
|
+
declare function introspectToken(config: SylphxConfig, token: string, tokenTypeHint?: 'access_token' | 'refresh_token'): Promise<TokenIntrospectionResult>;
|
|
3466
|
+
/**
|
|
3467
|
+
* Revoke a token (RFC 7009)
|
|
3468
|
+
*
|
|
3469
|
+
* Use cases:
|
|
3470
|
+
* - Sign out user from specific device
|
|
3471
|
+
* - Security response to compromised token
|
|
3472
|
+
* - User-initiated session termination
|
|
3473
|
+
*
|
|
3474
|
+
* @example
|
|
3475
|
+
* ```typescript
|
|
3476
|
+
* // Revoke single refresh token
|
|
3477
|
+
* await revokeToken(config, refreshToken)
|
|
3478
|
+
*
|
|
3479
|
+
* // Revoke all tokens for a user (logout everywhere)
|
|
3480
|
+
* await revokeToken(config, '', { revokeAll: true, userId: 'user-123' })
|
|
3481
|
+
* ```
|
|
3482
|
+
*/
|
|
3483
|
+
declare function revokeToken(config: SylphxConfig, token: string, options?: RevokeTokenOptions): Promise<void>;
|
|
3484
|
+
/**
|
|
3485
|
+
* Revoke all tokens for a user (logout from all devices)
|
|
3486
|
+
*
|
|
3487
|
+
* Convenience wrapper around revokeToken with revokeAll option.
|
|
3488
|
+
*
|
|
3489
|
+
* @example
|
|
3490
|
+
* ```typescript
|
|
3491
|
+
* // After password change, revoke all sessions
|
|
3492
|
+
* await revokeAllTokens(config, userId)
|
|
3493
|
+
* ```
|
|
3494
|
+
*/
|
|
3495
|
+
declare function revokeAllTokens(config: SylphxConfig, userId: string): Promise<void>;
|
|
3496
|
+
/**
|
|
3497
|
+
* Sign up with extended input (metadata + invitation token support).
|
|
3498
|
+
*
|
|
3499
|
+
* Use this instead of signUp() when you need to:
|
|
3500
|
+
* - Pass metadata on registration (e.g., org context, role, referral info)
|
|
3501
|
+
* - Register with an invitation token
|
|
3502
|
+
*
|
|
3503
|
+
* @example
|
|
3504
|
+
* ```typescript
|
|
3505
|
+
* const result = await extendedSignUp(config, {
|
|
3506
|
+
* email: 'user@example.com',
|
|
3507
|
+
* password: 'secret',
|
|
3508
|
+
* name: 'John Doe',
|
|
3509
|
+
* metadata: { orgId: 'org-123', role: 'employee' },
|
|
3510
|
+
* invitationToken: 'inv_...',
|
|
3511
|
+
* })
|
|
3512
|
+
* ```
|
|
3513
|
+
*/
|
|
3514
|
+
declare function extendedSignUp(config: SylphxConfig, input: RegisterInput): Promise<RegisterResponse>;
|
|
2972
3515
|
/**
|
|
2973
|
-
*
|
|
2974
|
-
*
|
|
3516
|
+
* Invite a user to sign up for this project.
|
|
3517
|
+
* Server-side only (requires secretKey).
|
|
3518
|
+
* Sends an email invitation; user signs up via signUp() or extendedSignUp() with the invitation token.
|
|
2975
3519
|
*
|
|
2976
3520
|
* @example
|
|
2977
3521
|
* ```typescript
|
|
2978
|
-
*
|
|
2979
|
-
*
|
|
2980
|
-
*
|
|
2981
|
-
*
|
|
2982
|
-
* privateKey: kp.privateKey,
|
|
2983
|
-
* publicKey: kp.publicKey,
|
|
2984
|
-
* method: 'POST',
|
|
2985
|
-
* uri: 'https://api.sylphx.com/v1/oauth/token',
|
|
2986
|
-
* })
|
|
2987
|
-
* // later, calling a resource:
|
|
2988
|
-
* const resProof = await dpop.generateProof({
|
|
2989
|
-
* privateKey: kp.privateKey,
|
|
2990
|
-
* publicKey: kp.publicKey,
|
|
2991
|
-
* method: 'GET',
|
|
2992
|
-
* uri: 'https://api.sylphx.com/v1/me',
|
|
2993
|
-
* accessToken,
|
|
2994
|
-
* })
|
|
2995
|
-
* fetch('/v1/me', {
|
|
2996
|
-
* headers: { Authorization: `DPoP ${accessToken}`, DPoP: resProof },
|
|
3522
|
+
* const invite = await inviteUser(config, {
|
|
3523
|
+
* email: 'newemployee@company.com',
|
|
3524
|
+
* metadata: { role: 'employee', orgId: 'org-123' },
|
|
3525
|
+
* redirectUrl: 'https://app.example.com/signup',
|
|
2997
3526
|
* })
|
|
3527
|
+
* console.log(invite.invitationToken, invite.expiresAt)
|
|
2998
3528
|
* ```
|
|
2999
3529
|
*/
|
|
3000
|
-
declare
|
|
3001
|
-
/**
|
|
3002
|
-
* Generate a fresh ES256 key pair. Private key is non-extractable
|
|
3003
|
-
* (`extractable: false`) so it can be stored but never serialised —
|
|
3004
|
-
* the only legal operation is `sign`. Clients that need to
|
|
3005
|
-
* hibernate the keypair across restarts must use a host-provided
|
|
3006
|
-
* secure store (Keychain, Credential Manager, IndexedDB + CryptoKey
|
|
3007
|
-
* wrapping).
|
|
3008
|
-
*/
|
|
3009
|
-
readonly generateKeyPair: () => Promise<{
|
|
3010
|
-
readonly privateKey: CryptoKey;
|
|
3011
|
-
readonly publicKey: CryptoKey;
|
|
3012
|
-
readonly thumbprint: string;
|
|
3013
|
-
}>;
|
|
3014
|
-
/**
|
|
3015
|
-
* Sign a DPoP proof JWT. When `accessToken` is provided, the proof
|
|
3016
|
-
* includes `ath = base64url(sha256(accessToken))` so the resource
|
|
3017
|
-
* server can bind the proof to the token being presented (RFC 9449
|
|
3018
|
-
* §4.3 step 11).
|
|
3019
|
-
*/
|
|
3020
|
-
readonly generateProof: (opts: {
|
|
3021
|
-
readonly privateKey: CryptoKey;
|
|
3022
|
-
readonly publicKey: CryptoKey;
|
|
3023
|
-
readonly method: string;
|
|
3024
|
-
readonly uri: string;
|
|
3025
|
-
readonly accessToken?: string;
|
|
3026
|
-
readonly nonce?: string;
|
|
3027
|
-
}) => Promise<string>;
|
|
3028
|
-
};
|
|
3029
|
-
interface OAuthTokenResult {
|
|
3030
|
-
readonly access_token: string;
|
|
3031
|
-
readonly token_type: 'Bearer';
|
|
3032
|
-
readonly expires_in: number;
|
|
3033
|
-
readonly refresh_token: string;
|
|
3034
|
-
readonly scope: string;
|
|
3035
|
-
}
|
|
3530
|
+
declare function inviteUser(config: SylphxConfig, input: InviteUserRequest): Promise<InviteUserResponse>;
|
|
3036
3531
|
/**
|
|
3037
|
-
*
|
|
3038
|
-
*
|
|
3039
|
-
*
|
|
3532
|
+
* Exchange current user token for an org-scoped token.
|
|
3533
|
+
* The returned access_token JWT includes org_id, org_slug, org_role claims.
|
|
3534
|
+
*
|
|
3535
|
+
* @example
|
|
3536
|
+
* const { token } = await getOrgScopedToken(withToken(config, currentToken), 'org_xxx')
|
|
3040
3537
|
*/
|
|
3041
|
-
|
|
3042
|
-
readonly access_token: string;
|
|
3043
|
-
readonly token_type: 'Bearer';
|
|
3044
|
-
readonly expires_in: number;
|
|
3045
|
-
readonly scope: string;
|
|
3046
|
-
}
|
|
3538
|
+
declare function getOrgScopedToken(config: SylphxConfig, orgId: string): Promise<OrgScopedTokenResponse>;
|
|
3047
3539
|
/**
|
|
3048
|
-
*
|
|
3049
|
-
*
|
|
3050
|
-
* - `authorization_pending` + `slow_down` — keep polling (respect interval).
|
|
3051
|
-
* - `access_denied` — user declined; abort.
|
|
3052
|
-
* - `expired_token` — grant timed out; re-run `/auth/device`.
|
|
3053
|
-
* - others — unexpected; surface to the user.
|
|
3540
|
+
* @deprecated Use getOrgScopedToken(config, orgId). Kept as the shorter
|
|
3541
|
+
* organization switch alias for existing SDK callers.
|
|
3054
3542
|
*/
|
|
3055
|
-
|
|
3056
|
-
type
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
};
|
|
3064
|
-
interface ImpersonationStartResult {
|
|
3065
|
-
readonly success: true;
|
|
3066
|
-
readonly token: string;
|
|
3067
|
-
readonly sessionId: string;
|
|
3068
|
-
readonly expiresAt: string;
|
|
3069
|
-
}
|
|
3070
|
-
interface ImpersonationEndResult {
|
|
3071
|
-
readonly success: boolean;
|
|
3072
|
-
readonly sessionsEnded: number;
|
|
3073
|
-
}
|
|
3074
|
-
interface ImpersonationInfo {
|
|
3075
|
-
readonly isImpersonation: true;
|
|
3076
|
-
readonly adminUserId: string;
|
|
3077
|
-
readonly adminEmail: string;
|
|
3078
|
-
readonly adminName: string | null;
|
|
3079
|
-
readonly impersonatedAt: string;
|
|
3080
|
-
}
|
|
3081
|
-
interface ImpersonationActive {
|
|
3082
|
-
readonly sessionId: string;
|
|
3083
|
-
readonly adminUserId: string;
|
|
3084
|
-
readonly adminEmail: string;
|
|
3085
|
-
readonly adminName: string | null;
|
|
3086
|
-
readonly targetUserId: string;
|
|
3087
|
-
readonly targetEmail: string;
|
|
3088
|
-
readonly targetName: string | null;
|
|
3089
|
-
readonly impersonatedAt: string;
|
|
3090
|
-
readonly lastActiveAt: string;
|
|
3091
|
-
}
|
|
3092
|
-
interface ImpersonationStartChallengeInput {
|
|
3093
|
-
readonly baseUrl: string;
|
|
3094
|
-
readonly accessToken: string;
|
|
3095
|
-
readonly targetUserId: string;
|
|
3096
|
-
readonly reason: string;
|
|
3097
|
-
readonly userAgent?: string;
|
|
3098
|
-
}
|
|
3099
|
-
interface ImpersonationChallenge {
|
|
3100
|
-
readonly requestId: string;
|
|
3101
|
-
readonly challengeKey: string;
|
|
3102
|
-
readonly webauthnOptions: {
|
|
3103
|
-
readonly challenge: string;
|
|
3104
|
-
readonly rpId?: string;
|
|
3105
|
-
readonly allowCredentials: ReadonlyArray<{
|
|
3106
|
-
readonly id: string;
|
|
3107
|
-
readonly type: 'public-key';
|
|
3108
|
-
readonly transports?: readonly string[];
|
|
3109
|
-
}>;
|
|
3110
|
-
readonly userVerification: 'required';
|
|
3111
|
-
readonly timeout: number;
|
|
3112
|
-
};
|
|
3113
|
-
}
|
|
3114
|
-
interface ImpersonationStartStepupInput {
|
|
3115
|
-
readonly baseUrl: string;
|
|
3116
|
-
readonly accessToken: string;
|
|
3117
|
-
readonly requestId: string;
|
|
3118
|
-
readonly challengeKey: string;
|
|
3119
|
-
readonly assertion: unknown;
|
|
3120
|
-
readonly emergencyBypass?: boolean;
|
|
3121
|
-
readonly userAgent?: string;
|
|
3122
|
-
}
|
|
3123
|
-
type ImpersonationStartStepupResult = {
|
|
3124
|
-
readonly branch: 'emergency';
|
|
3125
|
-
readonly requestId: string;
|
|
3126
|
-
readonly token: string;
|
|
3127
|
-
readonly sessionId: string;
|
|
3128
|
-
readonly expiresAt: string;
|
|
3129
|
-
} | {
|
|
3130
|
-
readonly branch: 'awaiting-consent';
|
|
3131
|
-
readonly requestId: string;
|
|
3132
|
-
readonly consentDeadline: string;
|
|
3133
|
-
};
|
|
3134
|
-
type ImpersonationConsentDecision = 'approve' | 'deny';
|
|
3135
|
-
type ImpersonationConsentResponse = {
|
|
3136
|
-
readonly branch: 'approved';
|
|
3137
|
-
readonly requestId: string;
|
|
3138
|
-
readonly token: string;
|
|
3139
|
-
readonly sessionId: string;
|
|
3140
|
-
readonly expiresAt: string;
|
|
3141
|
-
} | {
|
|
3142
|
-
readonly branch: 'denied';
|
|
3143
|
-
readonly requestId: string;
|
|
3144
|
-
};
|
|
3145
|
-
interface ImpersonationRequestRow {
|
|
3146
|
-
readonly id: string;
|
|
3147
|
-
readonly operatorId: string;
|
|
3148
|
-
readonly targetUserId: string;
|
|
3149
|
-
readonly reason: string;
|
|
3150
|
-
readonly status: 'awaiting-stepup' | 'awaiting-consent' | 'active' | 'denied' | 'expired' | 'ended' | 'revoked';
|
|
3151
|
-
readonly emergencyBypass: boolean;
|
|
3152
|
-
readonly sessionId: string | null;
|
|
3153
|
-
readonly consentDeadline: string | null;
|
|
3154
|
-
readonly startedAt: string | null;
|
|
3155
|
-
readonly endedAt: string | null;
|
|
3156
|
-
readonly createdAt: string;
|
|
3157
|
-
}
|
|
3543
|
+
declare function switchOrg(config: SylphxConfig, orgId: string): Promise<OrgScopedTokenResponse>;
|
|
3544
|
+
type DeviceInitInput = DeviceInitRequest;
|
|
3545
|
+
type DeviceGrant = DeviceInitResponse;
|
|
3546
|
+
type DevicePollResult = DevicePollResponse;
|
|
3547
|
+
type DeviceApproveInput = DeviceApproveRequest;
|
|
3548
|
+
type DeviceApproveResult = DeviceApproveResponse;
|
|
3549
|
+
type DeviceDenyInput = DeviceDenyRequest;
|
|
3550
|
+
type DeviceDenyResult = DeviceDenyResponse;
|
|
3158
3551
|
/**
|
|
3159
|
-
* `
|
|
3160
|
-
*
|
|
3161
|
-
* (
|
|
3162
|
-
*
|
|
3163
|
-
* CAEP integration via the new `startChallenge` + `startStepup` +
|
|
3164
|
-
* `respondConsent` + `listRequests` + `endSession` methods.
|
|
3165
|
-
*
|
|
3166
|
-
* Migration from Phase 3b → 5.9:
|
|
3167
|
-
* - Old `start({targetUserId})` → new two-step flow:
|
|
3168
|
-
* 1. `startChallenge({targetUserId, reason})` returns WebAuthn
|
|
3169
|
-
* options + challengeKey.
|
|
3170
|
-
* 2. `startStepup({requestId, challengeKey, assertion})` verifies
|
|
3171
|
-
* the passkey and either mints the session (emergency bypass)
|
|
3172
|
-
* or transitions to awaiting-consent.
|
|
3173
|
-
* 3. Target calls `respondConsent(id, 'approve' | 'deny')`.
|
|
3174
|
-
* - Old `end({sessionId})` still works (legacy). New
|
|
3175
|
-
* `endSession(requestId)` preferred for sessions tracked via
|
|
3176
|
-
* `impersonation_requests`.
|
|
3552
|
+
* `device` namespace — RFC 8628 device authorization grant.
|
|
3553
|
+
*
|
|
3554
|
+
* Used by headless clients (CLI, TV apps, IoT) to authorise via a
|
|
3555
|
+
* companion browser instead of reading credentials from env vars.
|
|
3177
3556
|
*/
|
|
3178
|
-
declare const
|
|
3179
|
-
readonly start: (opts: {
|
|
3180
|
-
readonly baseUrl: string;
|
|
3181
|
-
readonly accessToken: string;
|
|
3182
|
-
readonly targetUserId: string;
|
|
3183
|
-
readonly ipAddress?: string;
|
|
3184
|
-
readonly userAgent?: string;
|
|
3185
|
-
}) => Promise<ImpersonationStartResult>;
|
|
3186
|
-
readonly end: (opts: {
|
|
3187
|
-
readonly baseUrl: string;
|
|
3188
|
-
readonly accessToken: string;
|
|
3189
|
-
readonly sessionId?: string;
|
|
3190
|
-
readonly userAgent?: string;
|
|
3191
|
-
}) => Promise<ImpersonationEndResult>;
|
|
3192
|
-
readonly info: (opts: {
|
|
3193
|
-
readonly baseUrl: string;
|
|
3194
|
-
readonly accessToken: string;
|
|
3195
|
-
readonly sessionId: string;
|
|
3196
|
-
readonly userAgent?: string;
|
|
3197
|
-
}) => Promise<ImpersonationInfo | null>;
|
|
3198
|
-
readonly active: (opts: {
|
|
3199
|
-
readonly baseUrl: string;
|
|
3200
|
-
readonly accessToken: string;
|
|
3201
|
-
readonly userAgent?: string;
|
|
3202
|
-
}) => Promise<readonly ImpersonationActive[]>;
|
|
3203
|
-
/**
|
|
3204
|
-
* Phase 5.9 step 1 of 2 — request a WebAuthn assertion challenge.
|
|
3205
|
-
* Returns the pending-request id plus options ready for
|
|
3206
|
-
* `navigator.credentials.get(...)`. Caller is expected to post the
|
|
3207
|
-
* resulting assertion to {@link impersonation.startStepup}.
|
|
3208
|
-
*/
|
|
3209
|
-
readonly startChallenge: (opts: ImpersonationStartChallengeInput) => Promise<ImpersonationChallenge>;
|
|
3557
|
+
declare const device: {
|
|
3210
3558
|
/**
|
|
3211
|
-
*
|
|
3212
|
-
*
|
|
3213
|
-
*
|
|
3214
|
-
*
|
|
3215
|
-
*
|
|
3559
|
+
* Start a device authorization grant.
|
|
3560
|
+
*
|
|
3561
|
+
* Returns a `DeviceGrant` with `verification_uri_complete` (open this
|
|
3562
|
+
* in the user's browser) and `device_code` (use for polling).
|
|
3563
|
+
*
|
|
3564
|
+
* @example
|
|
3565
|
+
* ```typescript
|
|
3566
|
+
* const grant = await device.init({
|
|
3567
|
+
* baseUrl: 'https://your-app.api.sylphx.com/v1',
|
|
3568
|
+
* clientId: 'sylphx-cli',
|
|
3569
|
+
* scope: ['org:read', 'project:*'],
|
|
3570
|
+
* })
|
|
3571
|
+
* openBrowser(grant.verification_uri_complete)
|
|
3572
|
+
* ```
|
|
3216
3573
|
*/
|
|
3217
|
-
readonly
|
|
3574
|
+
readonly init: (opts: {
|
|
3575
|
+
readonly baseUrl: string;
|
|
3576
|
+
readonly clientId: string;
|
|
3577
|
+
readonly scope?: readonly string[];
|
|
3578
|
+
readonly userAgent?: string;
|
|
3579
|
+
}) => Promise<DeviceGrant>;
|
|
3218
3580
|
/**
|
|
3219
|
-
*
|
|
3220
|
-
*
|
|
3581
|
+
* Poll a pending grant. Returns `status: 'pending' | 'approved' |
|
|
3582
|
+
* 'denied' | 'expired'`. On `approved`, the result carries the OAuth
|
|
3583
|
+
* pair (access_token + refresh_token).
|
|
3584
|
+
*
|
|
3585
|
+
* Callers MUST respect the `interval` returned by `init()` — polling
|
|
3586
|
+
* faster than that may return 429 slow_down (RFC 8628 §5.5).
|
|
3221
3587
|
*/
|
|
3222
|
-
readonly
|
|
3588
|
+
readonly poll: (opts: {
|
|
3223
3589
|
readonly baseUrl: string;
|
|
3224
|
-
readonly
|
|
3225
|
-
readonly requestId: string;
|
|
3226
|
-
readonly decision: ImpersonationConsentDecision;
|
|
3590
|
+
readonly deviceCode: string;
|
|
3227
3591
|
readonly userAgent?: string;
|
|
3228
|
-
}) => Promise<
|
|
3229
|
-
/**
|
|
3230
|
-
|
|
3592
|
+
}) => Promise<DevicePollResult>;
|
|
3593
|
+
/**
|
|
3594
|
+
* Browser leg — the approving user confirms the grant.
|
|
3595
|
+
*
|
|
3596
|
+
* Requires a valid platform-issued access token (`Authorization:
|
|
3597
|
+
* Bearer <accessToken>`) proving the user is logged in on the
|
|
3598
|
+
* Console. Typically called by the Console's `/device` verification
|
|
3599
|
+
* page server-side, forwarding the user's session JWT.
|
|
3600
|
+
*/
|
|
3601
|
+
readonly approve: (opts: {
|
|
3231
3602
|
readonly baseUrl: string;
|
|
3603
|
+
readonly userCode: string;
|
|
3232
3604
|
readonly accessToken: string;
|
|
3233
|
-
readonly filter?: {
|
|
3234
|
-
readonly operatorId?: string;
|
|
3235
|
-
readonly targetUserId?: string;
|
|
3236
|
-
readonly status?: ImpersonationRequestRow["status"];
|
|
3237
|
-
readonly limit?: number;
|
|
3238
|
-
};
|
|
3239
3605
|
readonly userAgent?: string;
|
|
3240
|
-
}) => Promise<
|
|
3606
|
+
}) => Promise<DeviceApproveResult>;
|
|
3241
3607
|
/**
|
|
3242
|
-
*
|
|
3243
|
-
*
|
|
3244
|
-
*
|
|
3608
|
+
* Browser leg — the user declines the grant.
|
|
3609
|
+
*
|
|
3610
|
+
* Requires a valid platform-issued access token just like `approve`.
|
|
3245
3611
|
*/
|
|
3246
|
-
readonly
|
|
3612
|
+
readonly deny: (opts: {
|
|
3247
3613
|
readonly baseUrl: string;
|
|
3614
|
+
readonly userCode: string;
|
|
3248
3615
|
readonly accessToken: string;
|
|
3249
|
-
readonly requestId: string;
|
|
3250
3616
|
readonly userAgent?: string;
|
|
3251
|
-
}) => Promise<
|
|
3252
|
-
success: true;
|
|
3253
|
-
requestId: string;
|
|
3254
|
-
sessionId: string | null;
|
|
3255
|
-
}>;
|
|
3617
|
+
}) => Promise<DeviceDenyResult>;
|
|
3256
3618
|
};
|
|
3257
3619
|
|
|
3258
3620
|
/**
|
|
@@ -9309,4 +9671,4 @@ declare const functions: {
|
|
|
9309
9671
|
};
|
|
9310
9672
|
};
|
|
9311
9673
|
|
|
9312
|
-
export { ACHIEVEMENT_TIER_CONFIG, type AIListModelsOptions, type AIListModelsResponse, type AIMessage, type AIMessageRole, type AIModel, type AIModelInfo, type AIModelsResponse, type AIProvider, type AIRateLimitInfo, type AIRateLimitResponse, type AIRequestType, type AIStreamChunk, type AITool, type AIToolCall, type AIUsageResponse, type AIUsageStats, type AccessTokenPayload, type AchievementCategory, type AchievementCriteria, type AchievementCriterion, type AchievementDefinition, type AchievementTier, type AchievementType, type AchievementUnlockEvent, type AdminUser, type AuditQueryFilter, type AuditQueryResult, AuthenticationError, AuthorizationError, type BackupCodesResult, type BatchEvent, type BatchIndexInput, type BatchIndexResult, type Breadcrumb, type BuildLog, type BuildLogHistoryResponse, type CaptureExceptionRequest, type CaptureMessageRequest, type ChallengeMethod, type ChallengeType, type ChallengeVerifyInput, type ChallengeVerifyResult, type ChatCompletionInput, type ChatCompletionResponse, type ChatInput, type ChatMessage, type ChatResult, type ChatStreamChunk, type CircuitBreakerConfig, CircuitBreakerOpenError, type CircuitState, type CommandResult, type ConsentCategory, type ConsentHistoryEntry, type ConsentHistoryResult, type ConsentPurposeDefaults, type ConsentType, type ContentPart, type CopyFileOptions, type CreateOrgInput, type CreatePermissionInput, type CreatePromoInput, type CreateRoleInput, type CreateRunOptions, type CreateTriggerOptions, type CriteriaOperator, type CronInput, type CronSchedule, type CronSource, type DatabaseConnectionInfo, type DatabaseStatus, type DatabaseStatusInfo, type DebugCategory, type DeduplicationConfig, type DeleteAccountResult, type DeleteDocumentInput, type DeployHistoryResponse, type DeployInfo, type DeployStatus, type DeviceApproveInput, type DeviceApproveResult, type DeviceDenyInput, type DeviceDenyResult, type DeviceGrant, type DeviceInitInput, type DevicePollResult, type DynamicRestClient, ERROR_CODE_STATUS, type EmailChangeInput, type EmailConfirmInput, type EmbedInput, type EmbedResult, type EmbeddingInput, type EmbeddingResponse, type LeaderboardEntry as EngagementLeaderboardEntry, type LeaderboardResult as EngagementLeaderboardResult, type EnvVar, type ErrorCode, type ErrorResponse, type EventSource, type ExceptionFrame, type ExceptionValue, type ExecEvent, type ExecOptions, type ExecResult, type FacetsResponse, type FileEvent, type FlagContext, type FlagResult, type GetConsentHistoryInput, type GetConsentsInput, type GetFacetsInput, type GetSecretInput, type GetSecretResult, type GetSecretsInput, type GetSecretsResult, type HttpTarget, type IdentifyInput, type ImpersonationActive, type ImpersonationEndResult, type ImpersonationInfo, type ImpersonationStartResult, type IndexDocumentInput, type IndexDocumentResult, type IngestLogsResult, InvalidConnectionUrlError, type InviteMemberInput, type InviteUserRequest, type InviteUserResponse, type KvExpireRequest, type KvHgetRequest, type KvHgetallRequest, type KvHsetRequest, type KvIncrRequest, type KvLpushRequest, type KvLrangeRequest, type KvMgetRequest, type KvMsetRequest, type KvRateLimitRequest, type KvRateLimitResult, type KvScanOptions, type KvScanResult, type KvSetOptions, type KvSetRequest, type KvZMember, type KvZaddRequest, type KvZrangeRequest, type LeaderboardAggregation, type LeaderboardDefinition, type LeaderboardEntry$1 as LeaderboardEntry, type LeaderboardOptions, type LeaderboardQueryOptions, type LeaderboardResetPeriod, type LeaderboardResult$1 as LeaderboardResult, type LeaderboardSortDirection, type LinkAnonymousConsentsInput, type ListFilesOptions, type ListPromosOptions, type ListPromosResult, type ListRedemptionsOptions, type ListRedemptionsResult, type ListRunsOptions, type ListRunsResult, type ListScheduledEmailsOptions, type ListSecretKeysInput, type ListTriggersResult, type ListUsersOptions, type ListUsersResult, type LogEntry, type LogLevel, type LoginHistoryEntry, type LoginRequest, type LoginResponse, type MeResponse, type MemberPermissionsResult, type MintAccessTokenClaims, type MintAccessTokenResult, type MonitoringResponse, type MonitoringSeverity, type NativeStepContext, type NativeTaskDefinition, type TaskRunStatus as NativeTaskRunStatus, NetworkError, NotFoundError, type OAuthAuthorizeInput, type OAuthAuthorizeResult, type OAuthCodeExchangeInput, type OAuthProvider, type OAuthProvidersResult, type OidcDiscoveryDocument, type OidcUserInfoResponse, type OrgRole, type OrgScopedTokenResponse, type OrgTokenPayload, type OrganizationInvitation, type OrganizationMember, type OrganizationMembership, type OrganizationsListResult, type PageInput, type PaginatedResponse, type PaginationInput, type ParsedConnectionUrl, type PasskeyRegistrationInput, type PasskeyRegistrationOptions, type PasskeySummary, type PasskeysList, type PasswordSetInput, type Permission, type PkceMethod, type Plan, type PlatformAccessTokenClaims, type PlatformFunctionsDownloadBundleResult, type PlatformLogoutInput, type PlatformPasswordChangeInput, type PlatformPasswordChangeResult, type PlatformPasswordSetInput, type PlatformPasswordSetResult, type PlatformPasswordStatusResult, type PlatformRealtimeChannel, type PlatformRealtimeCreateChannelResult, type PlatformRealtimeDeleteChannelResult, type PlatformRealtimeListChannelsResult, type PlatformRealtimeStatusResult, type PlatformRefreshInput, type PlatformRefreshResult, type PlatformSessionRenameInput, type PlatformSessionRenameResult, type PlatformSessionRevokeAllResult, type PlatformSessionRevokeInput, type PlatformSessionRevokeOtherResult, type PlatformSessionRevokeResult, type PlatformSessionsListResult, type PlatformUserDeleteInput, type PlatformUserDeleteResult, type PlatformUserExportResult, type PlatformUserRecord, type PlatformUserResolution, type ProcessEvent, type ProcessInfo, type ProcessStartOptions, type ProcessSummary, type ProjectMetadata, type PromoCode, type PromoRedemption, type PromoStatus, type PromoType, type PromoValidationPreview, type PublishEventResult, type PushCampaign, type PushCampaignStats, type PushCampaignVariant, type PushNotification, type PushNotificationPayload, type PushSegment, type PushSegmentFilter, type PushServiceWorkerConfig, type PushSubscription, type QueryLogsOptions, type QueryLogsResult, RETRYABLE_CODES, RateLimitError, type RateLimitStatusFilter, type RateLimitStatusResult, type RateLimitStrategiesFilter, type RateLimitStrategiesResult, type RateLimitStrategyDeleteInput, type RateLimitStrategyDeleteResult, type RateLimitStrategyUpsertInput, type RateLimitStrategyUpsertResult, type RealtimeEmitRequest, type RealtimeEmitResponse, type RealtimeHistoryRequest, type RealtimeHistoryResponse, type RecordActivityInput, type RecordActivityResult, type RedeemPromoInput, type RedeemPromoResult, type RedeemReferralInput, type RedeemResult, type ReferralCode, type ReferralStats, type RegisterInput, type RegisterRequest, type RegisterResponse, type ResendEmailVerificationRequest, type ResendEmailVerificationResponse, type RestClient, type RestClientConfig, type RestDynamicConfig, type RetryConfig, type RevokeTokenOptions, type Role, type RollbackDeployRequest, type Run, RunHandle, type RunLogsResult, type RunMachineSize, type RunResult, type RunStatus, type RunTarget, type RunVolumeMount, type CreateRunOptions as RunWorkerOptions, RunsClient, SandboxClient, type SandboxFile, SandboxFiles, type SandboxMachineSize, type SandboxOptions, SandboxProcesses, type SandboxRecord, SandboxWatch, type ScheduleEmailOptions, type ScheduledEmail, type ScheduledEmailStats, type ScheduledEmailsResult, type SearchInput, type SearchResponse, type SearchResultItem, type SearchStatsResult, type SearchType, type SecretKeyInfo, type SecurityAlert, type SecurityAlertsList, type SecurityScoreResult, type SecuritySettings, type SendEmailOptions, type SendResult, type SendTemplatedEmailOptions, type SendToUserOptions, type SessionResult, type SetConsentsInput, type SetEnvVarRequest, type SignedUrlOptions, StepCompleteSignal, StepSleepSignal, type StoredLogEntry, type StreakDefinition, type StreakFrequency, type StreakState, type StreamMessage, type SubmitScoreInput, type SubmitScoreResult, type Subscription, type SuccessResponse, type SylphxClientInput, type SylphxConfig, type SylphxConfigInput, SylphxError, type SylphxErrorCode, type SylphxErrorOptions, type TaskInput, type TaskResult, type TaskStatus, type TaskTarget, type TextCompletionInput, type TextCompletionResponse, TimeoutError, type TokenIntrospectionResult, type TokenResponse, type Tool, type ToolCall, type TrackClickInput, type TrackInput, type Trigger, type TriggerDeployRequest, type TriggerRunMachineSize, type TriggerSource, type TriggerSourceType, type TriggerStatus, type TriggerTarget, type TriggerTargetType, TriggersClient, type TwoFactorEnableResult, type TwoFactorSetupResult, type TwoFactorVerifyRequest, type UpdateOrgInput, type UpdatePromoInput, type UpdateRoleInput, type UpdateTriggerOptions, type UploadCreateOptions, type UploadProgressEvent, type UpsertDocumentInput, type UpsertDocumentResult, type User, type UserAchievement, type UserConsent, type UserDataExport, type UserFullProfile, type UserOrganization, type UserProfile, type UserSecuritySettings, type UserSession, type UserSessionsList, type UserUpdateProfileInput, type ValidatePromoInput, type ValidatePromoResult, ValidationError, type VisionInput, type WatchEntry, type WatchOptions, type WebhookConfig, type WebhookConfigUpdate, type WebhookDeliveriesResult, type WebhookDelivery, type WebhookStats, RunHandle as WorkerHandle, type RunLogsResult as WorkerLogsResult, type RunResult as WorkerResult, type Run as WorkerRun, type RunStatus as WorkerStatus, type RunVolumeMount as WorkerVolumeMount, WorkersClient, acceptAllConsents, acceptOrganizationInvitation, assignMemberRole, audit, authorizeOAuth, batchIndex, canDeleteOrganization, canManageMembers, canManageSettings, cancelScheduledEmail, cancelTask, captureException, captureExceptionRaw, captureMessage, chat, chatStream, checkFlag, complete, confirmEmailChange, cookies, createCheckout, createClient, createConfig, createCron, createDynamicRestClient, createOrganization, createPermission, createPortalSession, createPromo, createRestClient, createRole, createServerClient, createServiceWorkerScript, createStepContext, createTasksHandler, createTracker, debugError, debugLog, debugTimer, debugWarn, declineOptionalConsents, deleteCron, deleteDocument, deleteEnvVar, deleteOrganization, deletePasskey, deletePermission, deletePromo, deleteRole, deleteUser, deleteUserAccount, device, disableDebug, disableTwoFactor, disconnectOAuthProvider, dpop, embed, enableDebug, exchangeOAuthCode, exponentialBackoff, exportUserData, extendedSignUp, forgotPassword, functions, generateAnonymousId, generatePkce, getAchievement, getAchievementPoints, getAchievements, getAllFlags, getAllSecrets, getAllStreaks, getBackupCodes, getBillingBalance, getBillingUsage, getBuildLogHistory, getCircuitBreakerState, getConsentHistory, getConsentTypes, getDatabaseConnectionString, getDatabaseStatus, getDebugMode, getDeployHistory, getDeployStatus, getErrorCode, getErrorMessage, getFacets, getFlagPayload, getFlags, getLeaderboard, getMemberPermissions, getMyReferralCode, getOidcDiscoveryDocument, getOrgScopedToken, getOrganization, getOrganizationInvitations, getOrganizationMembers, getOrganizations, getPlans, getProjectMetadata, getPromo, getPushPreferences, getRealtimeHistory, getReferralLeaderboard, getReferralStats, getRestErrorMessage, getRole, getScheduledEmail, getScheduledEmailStats, getSearchStats, getSecret, getSecrets, getSecurityScore, getSession, getStreak, getSubscription, getTask, getUser, getUserByEmail, getUserConsents, getUserLeaderboardRank, getUserProfile, getUserSecurity, getVariant, getWebhookConfig, getWebhookDeliveries, getWebhookDelivery, getWebhookStats, hasAllPermissions, hasAnyPermission, hasConsent, hasError, hasPermission, hasRole, hasSecret, identify, impersonation, incrementAchievementProgress, indexDocument, ingestLogs, initPushServiceWorker, installGlobalDebugHelpers, introspectToken, inviteOrganizationMember, inviteUser, isEmailConfigured, isEnabled, isRetryableError, isSylphxError, kvDelete, kvExists, kvExpire, kvGet, kvGetJSON, kvHget, kvHgetall, kvHset, kvIncr, kvLpush, kvLrange, kvMget, kvMset, kvRateLimit, kvScan, kvSet, kvSetJSON, kvZadd, kvZrange, leaveOrganization, linkAnonymousConsents, listEnvVars, listOAuthProviders, listOrganizations, listPasskeys, listPermissions, listPromoRedemptions, listPromos, listRoles, listScheduledEmails, listSecretKeys, listSecurityAlerts, listTasks, listUserSessions, listUsers, markAllSecurityAlertsRead, markSecurityAlertRead, oauth, page, parseOAuthCallback, password, pauseCron, platformAuth, campaigns as pushCampaigns, segments as pushSegments, queryLogs, rateLimits, realtime, realtimeEmit, recordStreakActivity, recoverStreak, redeemPromo, redeemReferralCode, refreshToken, regenerateBackupCodes, regenerateReferralCode, registerPush, registerPushServiceWorker, removeOrganizationMember, renamePasskey, renameUserSession, replayWebhookDelivery, requestEmailChange, rescheduleEmail, resendVerificationEmail, resetCircuitBreaker, resetDebugModeCache, resetPassword, resetPlatformCookieCache, resetPlatformJwksCache, resumeCron, revokeAllTokens, revokeOrganizationInvitation, revokeToken, revokeUserSession, rollbackDeploy, scheduleEmail, scheduleTask, search, sendEmail, sendEmailToUser, sendPush, sendTemplatedEmail, sessions, setConsents, setEnvVar, setPassword, setupTwoFactor, signIn, signOut, signUp, startPasskeyRegistration, storage, streamToString, submitScore, suspendUser, switchOrg, toSylphxError, track, trackBatch, trackClick, triggerDeploy, unlockAchievement, unregisterPush, updateOrganization, updateOrganizationMemberRole, updatePromo, updatePushPreferences, updateRole, updateUser, updateUserMetadata, updateUserProfile, updateWebhookConfig, upsertDocument, user, userInfo, validatePromo, verifyAccessToken, verifyChallenge, verifyEmail, verifyPasskeyRegistration, verifySignature as verifyTaskSignature, verifyTwoFactor, verifyTwoFactorEnable, withToken };
|
|
9674
|
+
export { ACHIEVEMENT_TIER_CONFIG, type AIListModelsOptions, type AIListModelsResponse, type AIMessage, type AIMessageRole, type AIModel, type AIModelInfo, type AIModelsResponse, type AIProvider, type AIRateLimitInfo, type AIRateLimitResponse, type AIRequestType, type AIStreamChunk, type AITool, type AIToolCall, type AIUsageResponse, type AIUsageStats, type AccessTokenPayload, type AchievementCategory, type AchievementCriteria, type AchievementCriterion, type AchievementDefinition, type AchievementTier, type AchievementType, type AchievementUnlockEvent, type AdminUser, type AuditQueryFilter, type AuditQueryResult, AuthenticationError, AuthorizationError, BILLING_ALLOWED_ROLES, BUILD_MINUTES_INCLUDED, BUILD_MINUTE_PRICES, BUILD_SIZE_MULTIPLIERS, BYTES_PER_GB, type BackupCodesResult, type BatchEvent, type BatchIndexInput, type BatchIndexResult, type BillingAllowedRole, type Breadcrumb, type BuildConnectionUrlInput, type BuildLog, type BuildLogHistoryResponse, type BuildMachineTier, CI_BUILD_MINUTE_PRICE_MICRODOLLARS, CI_FREE_MINUTES_PER_MONTH, CI_MACOS_MULTIPLIER, CI_MACOS_SIZE_MULTIPLIERS, CI_SIZE_MULTIPLIERS, COMPUTE_PRICE_PER_HOUR_MICRODOLLARS, COMPUTE_RAM_RATE_MICRODOLLARS, COMPUTE_VCPU_ACTIVE_RATE_MICRODOLLARS, COMPUTE_VCPU_IDLE_RATE_MICRODOLLARS, CONSOLE_APP_SLUG, CREDENTIAL_REGEX, CREDIT_EXPIRY_MONTHS, type CaptureExceptionRequest, type CaptureMessageRequest, type ChallengeMethod, type ChallengeType, type ChallengeVerifyInput, type ChallengeVerifyResult, type ChatCompletionInput, type ChatCompletionResponse, type ChatInput, type ChatMessage, type ChatResult, type ChatStreamChunk, type CircuitBreakerConfig, CircuitBreakerOpenError, type CircuitState, type CommandResult, type ConnectionCredentialType, type ConnectionEnv, type ConsentCategory, type ConsentHistoryEntry, type ConsentHistoryResult, type ConsentPurposeDefaults, type ConsentType, type ContentPart, type CopyFileOptions, type CreateOrgInput, type CreatePermissionInput, type CreatePromoInput, type CreateRoleInput, type CreateRunOptions, type CreateTriggerOptions, type CriteriaOperator, type CronInput, type CronSchedule, type CronSource, DEFAULT_MAX_REPLICAS, DEFAULT_POINTS_REWARD, DISCOUNT_DURATION_MONTHS, DISCOUNT_PERCENT, type DatabaseConnectionInfo, type DatabaseStatus, type DatabaseStatusInfo, type DebugCategory, type DeduplicationConfig, type DeleteAccountResult, type DeleteDocumentInput, type DeployHistoryResponse, type DeployInfo, type DeployStatus, type DeviceApproveInput, type DeviceApproveResult, type DeviceDenyInput, type DeviceDenyResult, type DeviceGrant, type DeviceInitInput, type DevicePollResult, type DynamicRestClient, ERROR_CODE_STATUS, type EmailChangeInput, type EmailConfirmInput, type EmbedInput, type EmbedResult, type EmbeddingInput, type EmbeddingResponse, type LeaderboardEntry as EngagementLeaderboardEntry, type LeaderboardResult as EngagementLeaderboardResult, type EnvVar, type ErrorCode, type ErrorResponse, type EventSource, type ExceptionFrame, type ExceptionValue, type ExecEvent, type ExecOptions, type ExecResult, type ErrorDetails$1 as ExtractedErrorDetails, FREE_COMPUTE_HOURS, FREE_STORAGE_GB, type FacetsResponse, type FileEvent, type FlagContext, type FlagResult, type GetConsentHistoryInput, type GetConsentsInput, type GetFacetsInput, type GetSecretInput, type GetSecretResult, type GetSecretsInput, type GetSecretsResult, HOURS_PER_MONTH, type HttpTarget, INSTANCE_TYPES, INSTANCE_TYPE_ALIASES, INSTANCE_TYPE_ORDER, INVOICE_DUE_DAYS, type IdentifyInput, type ImpersonationActive, type ImpersonationEndResult, type ImpersonationInfo, type ImpersonationStartResult, type IndexDocumentInput, type IndexDocumentResult, type IngestLogsResult, type InstanceTypeDefinition, type InstanceTypeId, InvalidConnectionUrlError, type InviteMemberInput, type InviteUserRequest, type InviteUserResponse, KV_FREE_STORAGE_GB, type KvExpireRequest, type KvHgetRequest, type KvHgetallRequest, type KvHsetRequest, type KvIncrRequest, type KvLpushRequest, type KvLrangeRequest, type KvMetric, type KvMgetRequest, type KvMsetRequest, type KvRateLimitRequest, type KvRateLimitResult, type KvScanOptions, type KvScanResult, type KvSetOptions, type KvSetRequest, type KvZMember, type KvZaddRequest, type KvZrangeRequest, LEGACY_INSTANCE_TYPE_ORDER, type LeaderboardAggregation, type LeaderboardDefinition, type LeaderboardEntry$1 as LeaderboardEntry, type LeaderboardOptions, type LeaderboardQueryOptions, type LeaderboardResetPeriod, type LeaderboardResult$1 as LeaderboardResult, type LeaderboardSortDirection, type LinkAnonymousConsentsInput, type ListFilesOptions, type ListPromosOptions, type ListPromosResult, type ListRedemptionsOptions, type ListRedemptionsResult, type ListRunsOptions, type ListRunsResult, type ListScheduledEmailsOptions, type ListSecretKeysInput, type ListTriggersResult, type ListUsersOptions, type ListUsersResult, type LogEntry, type LogLevel, type LoginHistoryEntry, type LoginRequest, type LoginResponse, MAX_PASSWORD_LENGTH, MAX_PAYMENT_ATTEMPTS, MICRODOLLARS_PER_CENT, MIN_PASSWORD_LENGTH, type MeResponse, type MemberPermissionsResult, type MintAccessTokenClaims, type MintAccessTokenResult, type MonitoringResponse, type MonitoringSeverity, type NativeStepContext, type NativeTaskDefinition, type TaskRunStatus as NativeTaskRunStatus, NetworkError, NotFoundError, type OAuthAuthorizeInput, type OAuthAuthorizeResult, type OAuthCodeExchangeInput, type OAuthProvider, type OAuthProvidersResult, type OidcDiscoveryDocument, type OidcUserInfoResponse, type OrgRole, type OrgScopedTokenResponse, type OrgTokenPayload, type OrganizationInvitation, type OrganizationMember, type OrganizationMembership, type OrganizationsListResult, PASSWORD_REQUIREMENTS, PLATFORM_PLANS, PLATFORM_PLAN_ORDER, PLATFORM_PLAN_ORDER_ALL, PREMIUM_TRIAL_DAYS, type PageInput, type PaginatedResponse, type PaginationInput, type ParsedConnectionUrl, type ParsedUserAgent, type PasskeyRegistrationInput, type PasskeyRegistrationOptions, type PasskeySummary, type PasskeysList, type PasswordSetInput, type Permission, type PkceMethod, type Plan, type PlatformAccessTokenClaims, type PlatformFunctionsDownloadBundleResult, type PlatformLogoutInput, type PlatformPasswordChangeInput, type PlatformPasswordChangeResult, type PlatformPasswordSetInput, type PlatformPasswordSetResult, type PlatformPasswordStatusResult, type PlatformPlanDefinition, type PlatformPlanFeatures, type PlatformPlanId, type PlatformPlanLimits, type PlatformRealtimeChannel, type PlatformRealtimeCreateChannelResult, type PlatformRealtimeDeleteChannelResult, type PlatformRealtimeListChannelsResult, type PlatformRealtimeStatusResult, type PlatformRefreshInput, type PlatformRefreshResult, type PlatformSessionRenameInput, type PlatformSessionRenameResult, type PlatformSessionRevokeAllResult, type PlatformSessionRevokeInput, type PlatformSessionRevokeOtherResult, type PlatformSessionRevokeResult, type PlatformSessionsListResult, type PlatformUserDeleteInput, type PlatformUserDeleteResult, type PlatformUserExportResult, type PlatformUserRecord, type PlatformUserResolution, type ProcessEvent, type ProcessInfo, type ProcessStartOptions, type ProcessSummary, type ProjectMetadata, type PromoCode, type PromoRedemption, type PromoStatus, type PromoType, type PromoValidationPreview, type PublishEventResult, type PushCampaign, type PushCampaignStats, type PushCampaignVariant, type PushNotification, type PushNotificationPayload, type PushSegment, type PushSegmentFilter, type PushServiceWorkerConfig, type PushSubscription, type QueryLogsOptions, type QueryLogsResult, RETRYABLE_CODES, RateLimitError, type RateLimitStatusFilter, type RateLimitStatusResult, type RateLimitStrategiesFilter, type RateLimitStrategiesResult, type RateLimitStrategyDeleteInput, type RateLimitStrategyDeleteResult, type RateLimitStrategyUpsertInput, type RateLimitStrategyUpsertResult, type RealtimeEmitRequest, type RealtimeEmitResponse, type RealtimeHistoryRequest, type RealtimeHistoryResponse, type RealtimeMetric, type RecordActivityInput, type RecordActivityResult, type RedeemPromoInput, type RedeemPromoResult, type RedeemReferralInput, type RedeemResult, type ReferralCode, type ReferralStats, type RegisterInput, type RegisterRequest, type RegisterResponse, type ResendEmailVerificationRequest, type ResendEmailVerificationResponse, type RestClient, type RestClientConfig, type RestDynamicConfig, type RetryConfig, type RevokeTokenOptions, type Role, type RollbackDeployRequest, type Run, RunHandle, type RunLogsResult, type RunMachineSize, type RunResult, type RunStatus, type RunTarget, type RunVolumeMount, type CreateRunOptions as RunWorkerOptions, RunsClient, SERVICE_METRICS, STORAGE_PRICE_PER_GB_MONTH_MICRODOLLARS, SandboxClient, type SandboxFile, SandboxFiles, type SandboxMachineSize, type SandboxOptions, SandboxProcesses, type SandboxRecord, SandboxWatch, type ScheduleEmailOptions, type ScheduledEmail, type ScheduledEmailStats, type ScheduledEmailsResult, type SearchInput, type SearchResponse, type SearchResultItem, type SearchStatsResult, type SearchType, type SecretKeyInfo, type SecurityAlert, type SecurityAlertsList, type SecurityScoreResult, type SecuritySettings, type SendEmailOptions, type SendResult, type SendTemplatedEmailOptions, type SendToUserOptions, type ServiceMetrics, type SessionResult, type SetConsentsInput, type SetEnvVarRequest, type SignedUrlOptions, StepCompleteSignal, StepSleepSignal, type StoredLogEntry, type StreakDefinition, type StreakFrequency, type StreakState, type StreamMessage, type SubmitScoreInput, type SubmitScoreResult, type Subscription, type SuccessResponse, type SylphxClientInput, type SylphxConfig, type SylphxConfigInput, SylphxError, type SylphxErrorCode, type SylphxErrorOptions, TRANSFER_PRICE_PER_GB_MICRODOLLARS, type TaskInput, type TaskResult, type TaskStatus, type TaskTarget, type TextCompletionInput, type TextCompletionResponse, TimeoutError, type TokenIntrospectionResult, type TokenResponse, type Tool, type ToolCall, type TrackClickInput, type TrackInput, type Trigger, type TriggerDeployRequest, type TriggerRunMachineSize, type TriggerSource, type TriggerSourceType, type TriggerStatus, type TriggerTarget, type TriggerTargetType, TriggersClient, type TwoFactorEnableResult, type TwoFactorSetupResult, type TwoFactorVerifyRequest, type UpdateOrgInput, type UpdatePromoInput, type UpdateRoleInput, type UpdateTriggerOptions, type UploadCreateOptions, type UploadProgressEvent, type UpsertDocumentInput, type UpsertDocumentResult, type User, type UserAchievement, type UserConsent, type UserDataExport, type UserFullProfile, type UserOrganization, type UserProfile, type UserSecuritySettings, type UserSession, type UserSessionsList, type UserUpdateProfileInput, type ValidatePromoInput, type ValidatePromoResult, ValidationError, type VisionInput, type WatchEntry, type WatchOptions, type WebhookConfig, type WebhookConfigUpdate, type WebhookDeliveriesResult, type WebhookDelivery, type WebhookStats, RunHandle as WorkerHandle, type RunLogsResult as WorkerLogsResult, type RunResult as WorkerResult, type Run as WorkerRun, type RunStatus as WorkerStatus, type RunVolumeMount as WorkerVolumeMount, WorkersClient, acceptAllConsents, acceptOrganizationInvitation, assignMemberRole, audit, authorizeOAuth, batchIndex, buildConnectionUrl, calculatePercentage, canDeleteOrganization, canManageMembers, canManageSettings, cancelScheduledEmail, cancelTask, captureException, captureExceptionRaw, captureMessage, centsToDollars, chat, chatStream, checkFlag, complete, confirmEmailChange, cookies, createCheckout, createClient, createConfig, createCron, createDynamicRestClient, createOrganization, createPermission, createPortalSession, createPromo, createRestClient, createRole, createServerClient, createServiceWorkerScript, createStepContext, createTasksHandler, createTracker, debugError, debugLog, debugTimer, debugWarn, declineOptionalConsents, deleteCron, deleteDocument, deleteEnvVar, deleteOrganization, deletePasskey, deletePermission, deletePromo, deleteRole, deleteUser, deleteUserAccount, device, disableDebug, disableTwoFactor, disconnectOAuthProvider, dpop, embed, enableDebug, escapeCsvField, escapeHtml, exchangeOAuthCode, exponentialBackoff, exportUserData, extendedSignUp, getErrorDetails$1 as extractErrorDetails, getErrorMessage$1 as extractErrorMessage, forgotPassword, formatBytes, formatCents, formatCurrency, formatDate, formatDateTime, formatDuration, formatMicrodollars, formatMonthYear, formatNumber, formatPercent, formatRelativeTime, formatRelativeTimeShort, formatTime, functions, generateAnonymousId, generatePkce, generateReferralCode, generateSlug, getAchievement, getAchievementPoints, getAchievements, getActivePlans, getAllFlags, getAllSecrets, getAllStreaks, getAvailableInstanceTypes, getBackupCodes, getBaseUrl, getBillingBalance, getBillingStatusVariant, getBillingUsage, getBuildLogHistory, getCircuitBreakerState, getConsentHistory, getConsentTypes, getDatabaseConnectionString, getDatabaseStatus, getDebugMode, getDefaultInstanceType, getDeployHistory, getDeployStatus, getEnvPrefix, getErrorCode, getErrorDetails, getErrorMessage, getFacets, getFlagPayload, getFlags, getInvoiceStatusVariant, getLeaderboard, getMemberPermissions, getMyReferralCode, getOidcDiscoveryDocument, getOrgScopedToken, getOrganization, getOrganizationInvitations, getOrganizationMembers, getOrganizations, getPlanMonthlyPrice, getPlans, getProjectMetadata, getPromo, getPushPreferences, getRealtimeHistory, getReferralLeaderboard, getReferralStats, getRestErrorMessage, getRole, getSafeErrorMessage, getScheduledEmail, getScheduledEmailStats, getSearchStats, getSecret, getSecrets, getSecurityScore, getSession, getStreak, getSubscription, getTask, getUser, getUserByEmail, getUserConsents, getUserLeaderboardRank, getUserProfile, getUserSecurity, getVariant, getWebhookConfig, getWebhookDeliveries, getWebhookDelivery, getWebhookStats, hasAllPermissions, hasAnyPermission, hasBillingAccess, hasConsent, hasError, hasPermission, hasRole, hasSecret, identify, impersonation, incrementAchievementProgress, indexDocument, ingestLogs, initPushServiceWorker, installGlobalDebugHelpers, introspectToken, inviteOrganizationMember, inviteUser, isChallengeRequired, isEmailConfigured, isEnabled, isPlanDeprecated, isRetryableError, isSylphxError, isValidInstanceType, kvDelete, kvExists, kvExpire, kvGet, kvGetJSON, kvHget, kvHgetall, kvHset, kvIncr, kvLpush, kvLrange, kvMget, kvMset, kvRateLimit, kvScan, kvSet, kvSetJSON, kvZadd, kvZrange, leaveOrganization, linkAnonymousConsents, listEnvVars, listOAuthProviders, listOrganizations, listPasskeys, listPermissions, listPromoRedemptions, listPromos, listRoles, listScheduledEmails, listSecretKeys, listSecurityAlerts, listTasks, listUserSessions, listUsers, markAllSecurityAlertsRead, markSecurityAlertRead, microsToDollars, oauth, page, parseConnectionUrl, parseOAuthCallback, parseUserAgent, password, pauseCron, platformAuth, campaigns as pushCampaigns, segments as pushSegments, queryLogs, rateLimits, realtime, realtimeEmit, recordStreakActivity, recoverStreak, redeemPromo, redeemReferralCode, refreshToken, regenerateBackupCodes, regenerateReferralCode, registerPush, registerPushServiceWorker, removeOrganizationMember, renamePasskey, renameUserSession, replayWebhookDelivery, requestEmailChange, rescheduleEmail, resendVerificationEmail, resetCircuitBreaker, resetDebugModeCache, resetPassword, resetPlatformCookieCache, resetPlatformJwksCache, resolveCanonicalInstanceType, resolveMaxReplicas, resolveResources, resumeCron, revokeAllTokens, revokeOrganizationInvitation, revokeToken, revokeUserSession, rollbackDeploy, safeJsonParse, scheduleEmail, scheduleTask, search, sendEmail, sendEmailToUser, sendPush, sendTemplatedEmail, sessions, setConsents, setEnvVar, setPassword, setupTwoFactor, signIn, signOut, signUp, startPasskeyRegistration, storage, streamToString, submitScore, suspendUser, switchOrg, toSylphxError, track, trackBatch, trackClick, triggerDeploy, unlockAchievement, unregisterPush, updateOrganization, updateOrganizationMemberRole, updatePromo, updatePushPreferences, updateRole, updateUser, updateUserMetadata, updateUserProfile, updateWebhookConfig, upsertDocument, user, userInfo, validateInstanceTypeForPlan, validatePromo, verifyAccessToken, verifyChallenge, verifyEmail, verifyPasskeyRegistration, verifySignature as verifyTaskSignature, verifyTwoFactor, verifyTwoFactorEnable, withToken };
|