@sylphx/sdk 0.10.0 → 0.10.2

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.
@@ -922,7 +922,7 @@ type FlagClientEvent = {
922
922
  * import { createClient } from '@sylphx/sdk'
923
923
  *
924
924
  * const sylphx = createClient(process.env.SYLPHX_URL!)
925
- * // Parses: sylphx://pk_prod_{hex}@bold-river-a1b2c3.api.sylphx.com
925
+ * // Parses: sylphx://pk_prod_{ref?}_{hex}@bold-river-a1b2c3.api.sylphx.com
926
926
  * ```
927
927
  */
928
928
 
@@ -2377,6 +2377,8 @@ interface AuthContextValue extends AuthState {
2377
2377
  }) => Promise<void>;
2378
2378
  /** Get current access token (refreshes if expired) */
2379
2379
  getToken: () => Promise<string | null>;
2380
+ /** Exchange the current session for an org-scoped access token. */
2381
+ switchOrganizationToken: (orgId: string) => Promise<void>;
2380
2382
  /** Reset password with token */
2381
2383
  resetPassword: (options: ResetPasswordOptions) => Promise<void>;
2382
2384
  /** Verify email with token */
@@ -2827,6 +2829,8 @@ interface UseOrganizationReturn {
2827
2829
  hasPermission: (permission: 'manage_members' | 'access_billing' | 'manage_apps' | 'view_analytics') => boolean;
2828
2830
  /** Switch to a different organization */
2829
2831
  setOrganization: (orgIdOrSlug: string | null) => Promise<void>;
2832
+ /** Switch to a different organization and refresh the active session token. */
2833
+ switchOrg: (orgIdOrSlug: string | null) => Promise<void>;
2830
2834
  /** Create a new organization */
2831
2835
  createOrganization: (data: {
2832
2836
  name: string;
@@ -6414,6 +6418,8 @@ interface PlatformContextValue {
6414
6418
  appId: string;
6415
6419
  /** Platform API URL */
6416
6420
  platformUrl: string;
6421
+ /** Same-origin auth route prefix used by middleware BFF routes. */
6422
+ authPrefix: string;
6417
6423
  /** Project slug (ADR-055) for SDK config */
6418
6424
  slug?: string;
6419
6425
  /**
@@ -7428,7 +7434,7 @@ interface SylphxProviderProps {
7428
7434
  *
7429
7435
  * export default async function RootLayout({ children }) {
7430
7436
  * const config = await getAppConfig({
7431
- * secretKey: process.env.SYLPHX_SECRET_KEY!,
7437
+ * secretKey: createServerClient(process.env.SYLPHX_SECRET_URL!).secretKey!,
7432
7438
  * appId: process.env.NEXT_PUBLIC_SYLPHX_APP_ID!,
7433
7439
  * })
7434
7440
  *
@@ -7789,9 +7795,8 @@ declare function useHasPermission(permissions: string[], required: string | stri
7789
7795
  * Features (built-in defaults, ADR-100 §2.8):
7790
7796
  * - Idempotency-Key auto-generated (UUIDv7) on every POST
7791
7797
  * - Single-part PUT or multipart, picked server-side from `size`
7792
- * - Streaming SHA-256 (browser `crypto.subtle.digest` / node `crypto.createHash`)
7793
- * - Resumable: persists `(uploadId, completedParts[])` to localStorage
7794
- * (browser) or `~/.sylphx/uploads.json` (node)
7798
+ * - Streaming SHA-256 via the Web Crypto API
7799
+ * - Resumable: persists `(uploadId, completedParts[])` to localStorage when available
7795
7800
  * - AbortSignal cancellation; auto-DELETE upload session on abort
7796
7801
  * - Exponential backoff with full jitter (5 retries, 1s base, 30s cap)
7797
7802
  * - Progress: byte-accurate via XHR (browser) or stream sampling (node)
@@ -7849,10 +7854,13 @@ interface ListFilesOptions {
7849
7854
 
7850
7855
  interface UseStorageReturn {
7851
7856
  upload(file: Blob | File, options?: UploadCreateOptions): Promise<File$1>;
7857
+ uploadAvatar(file: Blob | File, options?: UploadCreateOptions): Promise<File$1>;
7852
7858
  files: File$1[] | undefined;
7853
7859
  isUploading: boolean;
7854
7860
  isLoadingFiles: boolean;
7861
+ progress: number;
7855
7862
  error: Error | null;
7863
+ uploadError: Error | null;
7856
7864
  refetch(): Promise<void>;
7857
7865
  }
7858
7866
  /**
@@ -9960,17 +9968,17 @@ declare function sanitizeUrl$1(url: string): string | null;
9960
9968
  * 5. Single Source of Truth - All key logic in one place
9961
9969
  *
9962
9970
  * Key Formats (ADR-021):
9963
- * - Publishable key: pk_(dev|stg|prod)_{ref}_{32hex} — client-safe (new)
9964
- * - Secret Key: sk_(dev|stg|prod)_{ref}_{64hex} — server-side only
9971
+ * - Publishable key: pk_(dev|stg|prod|prev)_{ref}_{32hex} — client-safe (new)
9972
+ * - Secret Key: sk_(dev|stg|prod|prev)_{ref}_{64hex} — server-side only
9965
9973
  *
9966
9974
  * Legacy Key Formats (backward-compat):
9967
- * - App ID (old): app_(dev|stg|prod)_[identifier] — Public identifier
9975
+ * - App ID (old): app_(dev|stg|prod|prev)_[identifier] — Public identifier
9968
9976
  *
9969
9977
  * Special Internal Formats (NOT rotated):
9970
9978
  * - Console bootstrap: app_prod_platform_{slug} / sk_prod_platform_{slug}
9971
9979
  */
9972
9980
  /** Environment type derived from key prefix */
9973
- type EnvironmentType = 'development' | 'staging' | 'production';
9981
+ type EnvironmentType = 'development' | 'staging' | 'production' | 'preview';
9974
9982
  /** Key type - publicKey (pk_*), appId (legacy app_*), or secret (sk_*) */
9975
9983
  type KeyType = 'publicKey' | 'appId' | 'secret';
9976
9984
  /** Validation result with clear error information */
@@ -10020,7 +10028,7 @@ declare function validateAndSanitizeAppId(key: string | undefined | null): strin
10020
10028
  *
10021
10029
  * @example
10022
10030
  * ```typescript
10023
- * const result = validateSecretKey(process.env.SYLPHX_SECRET_KEY)
10031
+ * const result = validateSecretKey('sk_prod_...')
10024
10032
  * if (!result.valid) {
10025
10033
  * throw new Error(result.error)
10026
10034
  * }
@@ -10092,7 +10100,7 @@ declare function isSecretKey(key: string): boolean;
10092
10100
  *
10093
10101
  * @example
10094
10102
  * ```typescript
10095
- * const result = validateKey(process.env.SYLPHX_SECRET_KEY)
10103
+ * const result = validateKey('sk_prod_...')
10096
10104
  * if (!result.valid) {
10097
10105
  * throw new Error(result.error)
10098
10106
  * }
@@ -13862,7 +13870,7 @@ declare function useKv(options?: UseKvOptions): UseKvReturn;
13862
13870
  * import { createConfig, indexDocument, search, batchIndex } from '@sylphx/sdk'
13863
13871
  *
13864
13872
  * const config = createConfig({
13865
- * secretKey: process.env.SYLPHX_SECRET_KEY!,
13873
+ * secretKey: createServerClient(process.env.SYLPHX_SECRET_URL!).secretKey!,
13866
13874
  * })
13867
13875
  *
13868
13876
  * // Index a document