@sylphx/sdk 0.3.4 → 0.3.6

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.
@@ -694,14 +694,6 @@ interface TaskRunStatus {
694
694
  updatedAt: string;
695
695
  }
696
696
 
697
- /**
698
- * SDK Configuration
699
- *
700
- * Create a config object that can be passed to SDK functions.
701
- * This is the foundation for the function-based API.
702
- *
703
- * Uses appId or secretKey for authentication via x-app-secret header.
704
- */
705
697
  /**
706
698
  * SDK Configuration for Pure Functions
707
699
  *
@@ -725,27 +717,26 @@ interface TaskRunStatus {
725
717
  */
726
718
  interface SylphxConfig {
727
719
  /**
728
- * Your app key — identifies the app and environment.
729
- *
730
- * Accepts either:
731
- * - Secret key (sk_dev_, sk_stg_, sk_prod_) — full access, server-side only
732
- * - Publishable key (app_dev_, app_stg_, app_prod_) — limited access, safe for client
733
- *
734
- * Get this from Platform Console → Apps → Your App → Environments
720
+ * Secret key (sk_*) full access, server-side only.
721
+ * Embed project ref, env, and routing info (ADR-021).
722
+ * Get from Platform Console → Apps → Your App → Environments.
735
723
  */
736
724
  readonly secretKey?: string;
737
725
  /**
738
- * Project refshort 12-char lowercase alphanumeric string (e.g. "abc123def456").
739
- *
726
+ * Publishable key (pk_*) client-safe, read-only access.
727
+ * Embeds project ref, env, and routing info (ADR-021).
728
+ * Get from Platform Console → Apps → Your App → Environments.
729
+ */
730
+ readonly publicKey?: string;
731
+ /**
732
+ * Project ref — 12-char lowercase alphanumeric string.
733
+ * Extracted from the key automatically (ADR-021).
740
734
  * The SDK targets: https://{ref}.api.sylphx.com/v1
741
- *
742
- * Get this from Platform Console → Projects → Your Project → Overview.
743
735
  */
744
736
  readonly ref: string;
745
737
  /**
746
738
  * Pre-computed base URL: https://{ref}.api.sylphx.com/v1
747
- *
748
- * Used by buildApiUrl and callApi internally.
739
+ * Derived from the embedded ref in the key.
749
740
  */
750
741
  readonly baseUrl: string;
751
742
  /** Optional: Current access token for authenticated requests */
@@ -15399,18 +15390,20 @@ declare function sanitizeUrl$1(url: string): string | null;
15399
15390
  * 4. No silent fixes - Transparency over convenience (but warn + continue)
15400
15391
  * 5. Single Source of Truth - All key logic in one place
15401
15392
  *
15402
- * Key Formats (OAuth 2.0 Standard):
15403
- * - App ID: app_(dev|stg|prod)_[identifier]Public identifier (like OAuth client_id)
15404
- * - Secret Key: sk_(dev|stg|prod)_[identifier]Server-side only (like OAuth client_secret)
15393
+ * Key Formats (ADR-021):
15394
+ * - Publishable key: pk_(dev|stg|prod)_{ref}_{32hex}client-safe (new)
15395
+ * - Secret Key: sk_(dev|stg|prod)_{ref}_{64hex}server-side only
15405
15396
  *
15406
- * Identifier Types:
15407
- * - Customer apps: 32 hex chars
15408
- * - Platform apps: platform_{app-slug} (e.g., platform_sylphx-console)
15397
+ * Legacy Key Formats (backward-compat):
15398
+ * - App ID (old): app_(dev|stg|prod)_[identifier] Public identifier
15399
+ *
15400
+ * Special Internal Formats (NOT rotated):
15401
+ * - Console bootstrap: app_prod_platform_{slug} / sk_prod_platform_{slug}
15409
15402
  */
15410
15403
  /** Environment type derived from key prefix */
15411
15404
  type EnvironmentType = 'development' | 'staging' | 'production';
15412
- /** Key type - appId (public) or secret (server) */
15413
- type KeyType = 'appId' | 'secret';
15405
+ /** Key type - publicKey (pk_*), appId (legacy app_*), or secret (sk_*) */
15406
+ type KeyType = 'publicKey' | 'appId' | 'secret';
15414
15407
  /** Validation result with clear error information */
15415
15408
  interface KeyValidationResult {
15416
15409
  /** Whether the key is valid (possibly after sanitization) */
@@ -15429,7 +15422,9 @@ interface KeyValidationResult {
15429
15422
  issues?: string[];
15430
15423
  }
15431
15424
  /**
15432
- * Validate an App ID and return detailed results
15425
+ * Validate a legacy App ID (app_*) and return detailed results.
15426
+ *
15427
+ * @deprecated Use validatePublicKey() for new pk_* keys (ADR-021).
15433
15428
  *
15434
15429
  * @example
15435
15430
  * ```typescript
@@ -15444,8 +15439,9 @@ interface KeyValidationResult {
15444
15439
  */
15445
15440
  declare function validateAppId(key: string | undefined | null): KeyValidationResult;
15446
15441
  /**
15447
- * Validate and sanitize App ID, logging warnings
15442
+ * Validate and sanitize App ID, logging warnings.
15448
15443
  *
15444
+ * @deprecated Use validateAndSanitizePublicKey() for new pk_* keys (ADR-021).
15449
15445
  * @throws Error if the key is invalid and cannot be sanitized
15450
15446
  * @returns The sanitized App ID
15451
15447
  */
@@ -15504,17 +15500,19 @@ declare function isProductionKey(key: string): boolean;
15504
15500
  */
15505
15501
  declare function getCookieNamespace(secretKey: string): string;
15506
15502
  /**
15507
- * Detect the type of key (App ID or Secret Key)
15503
+ * Detect the type of key.
15508
15504
  *
15509
- * @returns 'appId', 'secret', or null if unknown
15505
+ * @returns 'publicKey' (pk_*), 'appId' (legacy app_*), 'secret' (sk_*), or null if unknown
15510
15506
  */
15511
15507
  declare function detectKeyType(key: string): KeyType | null;
15512
15508
  /**
15513
- * Check if a key is an App ID
15509
+ * Check if a key is an App ID (legacy app_* format)
15510
+ *
15511
+ * @deprecated Use isPublishableKey() to also accept new pk_* keys
15514
15512
  */
15515
15513
  declare function isAppId(key: string): boolean;
15516
15514
  /**
15517
- * Check if a key is a secret key
15515
+ * Check if a key is a secret key (sk_*)
15518
15516
  */
15519
15517
  declare function isSecretKey(key: string): boolean;
15520
15518
  /**
@@ -694,14 +694,6 @@ interface TaskRunStatus {
694
694
  updatedAt: string;
695
695
  }
696
696
 
697
- /**
698
- * SDK Configuration
699
- *
700
- * Create a config object that can be passed to SDK functions.
701
- * This is the foundation for the function-based API.
702
- *
703
- * Uses appId or secretKey for authentication via x-app-secret header.
704
- */
705
697
  /**
706
698
  * SDK Configuration for Pure Functions
707
699
  *
@@ -725,27 +717,26 @@ interface TaskRunStatus {
725
717
  */
726
718
  interface SylphxConfig {
727
719
  /**
728
- * Your app key — identifies the app and environment.
729
- *
730
- * Accepts either:
731
- * - Secret key (sk_dev_, sk_stg_, sk_prod_) — full access, server-side only
732
- * - Publishable key (app_dev_, app_stg_, app_prod_) — limited access, safe for client
733
- *
734
- * Get this from Platform Console → Apps → Your App → Environments
720
+ * Secret key (sk_*) full access, server-side only.
721
+ * Embed project ref, env, and routing info (ADR-021).
722
+ * Get from Platform Console → Apps → Your App → Environments.
735
723
  */
736
724
  readonly secretKey?: string;
737
725
  /**
738
- * Project refshort 12-char lowercase alphanumeric string (e.g. "abc123def456").
739
- *
726
+ * Publishable key (pk_*) client-safe, read-only access.
727
+ * Embeds project ref, env, and routing info (ADR-021).
728
+ * Get from Platform Console → Apps → Your App → Environments.
729
+ */
730
+ readonly publicKey?: string;
731
+ /**
732
+ * Project ref — 12-char lowercase alphanumeric string.
733
+ * Extracted from the key automatically (ADR-021).
740
734
  * The SDK targets: https://{ref}.api.sylphx.com/v1
741
- *
742
- * Get this from Platform Console → Projects → Your Project → Overview.
743
735
  */
744
736
  readonly ref: string;
745
737
  /**
746
738
  * Pre-computed base URL: https://{ref}.api.sylphx.com/v1
747
- *
748
- * Used by buildApiUrl and callApi internally.
739
+ * Derived from the embedded ref in the key.
749
740
  */
750
741
  readonly baseUrl: string;
751
742
  /** Optional: Current access token for authenticated requests */
@@ -15399,18 +15390,20 @@ declare function sanitizeUrl$1(url: string): string | null;
15399
15390
  * 4. No silent fixes - Transparency over convenience (but warn + continue)
15400
15391
  * 5. Single Source of Truth - All key logic in one place
15401
15392
  *
15402
- * Key Formats (OAuth 2.0 Standard):
15403
- * - App ID: app_(dev|stg|prod)_[identifier]Public identifier (like OAuth client_id)
15404
- * - Secret Key: sk_(dev|stg|prod)_[identifier]Server-side only (like OAuth client_secret)
15393
+ * Key Formats (ADR-021):
15394
+ * - Publishable key: pk_(dev|stg|prod)_{ref}_{32hex}client-safe (new)
15395
+ * - Secret Key: sk_(dev|stg|prod)_{ref}_{64hex}server-side only
15405
15396
  *
15406
- * Identifier Types:
15407
- * - Customer apps: 32 hex chars
15408
- * - Platform apps: platform_{app-slug} (e.g., platform_sylphx-console)
15397
+ * Legacy Key Formats (backward-compat):
15398
+ * - App ID (old): app_(dev|stg|prod)_[identifier] Public identifier
15399
+ *
15400
+ * Special Internal Formats (NOT rotated):
15401
+ * - Console bootstrap: app_prod_platform_{slug} / sk_prod_platform_{slug}
15409
15402
  */
15410
15403
  /** Environment type derived from key prefix */
15411
15404
  type EnvironmentType = 'development' | 'staging' | 'production';
15412
- /** Key type - appId (public) or secret (server) */
15413
- type KeyType = 'appId' | 'secret';
15405
+ /** Key type - publicKey (pk_*), appId (legacy app_*), or secret (sk_*) */
15406
+ type KeyType = 'publicKey' | 'appId' | 'secret';
15414
15407
  /** Validation result with clear error information */
15415
15408
  interface KeyValidationResult {
15416
15409
  /** Whether the key is valid (possibly after sanitization) */
@@ -15429,7 +15422,9 @@ interface KeyValidationResult {
15429
15422
  issues?: string[];
15430
15423
  }
15431
15424
  /**
15432
- * Validate an App ID and return detailed results
15425
+ * Validate a legacy App ID (app_*) and return detailed results.
15426
+ *
15427
+ * @deprecated Use validatePublicKey() for new pk_* keys (ADR-021).
15433
15428
  *
15434
15429
  * @example
15435
15430
  * ```typescript
@@ -15444,8 +15439,9 @@ interface KeyValidationResult {
15444
15439
  */
15445
15440
  declare function validateAppId(key: string | undefined | null): KeyValidationResult;
15446
15441
  /**
15447
- * Validate and sanitize App ID, logging warnings
15442
+ * Validate and sanitize App ID, logging warnings.
15448
15443
  *
15444
+ * @deprecated Use validateAndSanitizePublicKey() for new pk_* keys (ADR-021).
15449
15445
  * @throws Error if the key is invalid and cannot be sanitized
15450
15446
  * @returns The sanitized App ID
15451
15447
  */
@@ -15504,17 +15500,19 @@ declare function isProductionKey(key: string): boolean;
15504
15500
  */
15505
15501
  declare function getCookieNamespace(secretKey: string): string;
15506
15502
  /**
15507
- * Detect the type of key (App ID or Secret Key)
15503
+ * Detect the type of key.
15508
15504
  *
15509
- * @returns 'appId', 'secret', or null if unknown
15505
+ * @returns 'publicKey' (pk_*), 'appId' (legacy app_*), 'secret' (sk_*), or null if unknown
15510
15506
  */
15511
15507
  declare function detectKeyType(key: string): KeyType | null;
15512
15508
  /**
15513
- * Check if a key is an App ID
15509
+ * Check if a key is an App ID (legacy app_* format)
15510
+ *
15511
+ * @deprecated Use isPublishableKey() to also accept new pk_* keys
15514
15512
  */
15515
15513
  declare function isAppId(key: string): boolean;
15516
15514
  /**
15517
- * Check if a key is a secret key
15515
+ * Check if a key is a secret key (sk_*)
15518
15516
  */
15519
15517
  declare function isSecretKey(key: string): boolean;
15520
15518
  /**