@enterprisestandard/core 0.0.14-beta.20260327.5 → 0.0.14

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 CHANGED
@@ -1860,7 +1860,7 @@ type MetaData = {
1860
1860
  version: number;
1861
1861
  created: Date;
1862
1862
  };
1863
- type SecretsSourceType = "vault" | "lfv" | "azure" | "aws" | "gcp" | "dev";
1863
+ type SecretsSourceType = "vault" | "azure" | "aws" | "gcp" | "dev";
1864
1864
  type SecretRequestSeverity = "low" | "medium" | "high" | "critical";
1865
1865
  type SecretLifecycleRequest = {
1866
1866
  reason?: string;
@@ -1917,7 +1917,7 @@ type SecretsValidators = {
1917
1917
  * Optional hook to validate merged source configs before they are resolved.
1918
1918
  * Throw from this callback to reject invalid secrets source configuration.
1919
1919
  */
1920
- validateSourceConfig?(name: string, config: SecretsSourceConfig): void;
1920
+ validateSourceConfig?(sourceName: string, config: SecretsSourceConfig): void;
1921
1921
  };
1922
1922
  type Secrets = {
1923
1923
  /** Named secrets sources client configurations from RemoteConfig. */
@@ -1925,27 +1925,27 @@ type Secrets = {
1925
1925
  /** Returns configured secrets source names/keys. */
1926
1926
  listSecretsSources(): string[];
1927
1927
  /** Gets a named secrets source client. Throws when missing. */
1928
- getSecretsSource(name: string): SecretsSource;
1928
+ getSecretsSource(sourceName: string): SecretsSource;
1929
1929
  /** Reads a secret from a named secrets source client. */
1930
- getSecret<T>(name: string, path: string, options?: SecretsOperationOptions): Promise<T>;
1930
+ getSecret<T>(sourceName: string, path: string, options?: SecretsOperationOptions): Promise<T>;
1931
1931
  /** Reads full secret data + metadata from a named secrets source client. */
1932
- getFullSecret<T>(name: string, path: string, options?: SecretsOperationOptions): Promise<Secret<T>>;
1932
+ getFullSecret<T>(sourceName: string, path: string, options?: SecretsOperationOptions): Promise<Secret<T>>;
1933
1933
  /** Writes a secret to a named secrets source client. */
1934
- putSecret(name: string, path: string, value: Record<string, unknown>, options?: SecretsOperationOptions): Promise<void>;
1934
+ putSecret(sourceName: string, path: string, value: Record<string, unknown>, options?: SecretsOperationOptions): Promise<void>;
1935
1935
  /** Deletes a secret from a named secrets source client. */
1936
- deleteSecret(name: string, path: string, options?: SecretsOperationOptions): Promise<void>;
1936
+ deleteSecret(sourceName: string, path: string, options?: SecretsOperationOptions): Promise<void>;
1937
1937
  /** Lists child paths under a base path for a named secrets source client. */
1938
- listPaths(name: string, path: string, options?: SecretsOperationOptions): Promise<string[]>;
1938
+ listPaths(sourceName: string, path: string, options?: SecretsOperationOptions): Promise<string[]>;
1939
1939
  /** Returns true when a path exists for a named secrets source client. */
1940
- exists(name: string, path: string, options?: SecretsOperationOptions): Promise<boolean>;
1940
+ exists(sourceName: string, path: string, options?: SecretsOperationOptions): Promise<boolean>;
1941
1941
  /** Requests rotation for a secret path in a named secrets source client. */
1942
- requestRotate(name: string, path: string, request?: SecretLifecycleRequest, options?: SecretsOperationOptions): Promise<void>;
1942
+ requestRotate(sourceName: string, path: string, request?: SecretLifecycleRequest, options?: SecretsOperationOptions): Promise<void>;
1943
1943
  /** Requests revocation for a secret path in a named secrets source client. */
1944
- requestRevoke(name: string, path: string, request?: SecretLifecycleRequest, options?: SecretsOperationOptions): Promise<void>;
1944
+ requestRevoke(sourceName: string, path: string, request?: SecretLifecycleRequest, options?: SecretsOperationOptions): Promise<void>;
1945
1945
  /** Reads metadata for a secret path in a named secrets source client. */
1946
- getMetadata(name: string, path: string, options?: SecretsOperationOptions): Promise<Record<string, unknown>>;
1946
+ getMetadata(sourceName: string, path: string, options?: SecretsOperationOptions): Promise<Record<string, unknown>>;
1947
1947
  /** Subscribes to secret changes on a named secrets source client. */
1948
- subscribe<T>(name: string, path: string, onChange: (fullSecret: Secret<T>) => void): () => void;
1948
+ subscribe<T>(sourceName: string, path: string, onChange: (fullSecret: Secret<T>) => void): () => void;
1949
1949
  /** Returns true when request matches any configured LFV delivery path. */
1950
1950
  isLfvDeliveryRequest?(request: Request): boolean;
1951
1951
  /** Returns true when request matches any configured LFV events path. */
@@ -1969,7 +1969,7 @@ type FrameworkSecretsModuleConfig = Record<string, FrameworkSecretsSourceConfig>
1969
1969
  * TODO: Let's see if we can do some clean inference and remove this!!!
1970
1970
  */
1971
1971
  type SecretsSourceMap = Record<string, SecretsSource>;
1972
- type SecretsSourceConfig = DevSecretsConfig | GcpSecretsConfig | LfvSecretsConfig | VaultSecretsConfig | AwsSecretsConfig | AzureSecretsConfig;
1972
+ type SecretsSourceConfig = DevSecretsConfig | GcpSecretsConfig | VaultSecretsConfig | AwsSecretsConfig | AzureSecretsConfig;
1973
1973
  /**
1974
1974
  * Raw module config keyed by source name.
1975
1975
  * The secrets module resolves this into a runtime SecretsSourceMap.
@@ -1982,8 +1982,7 @@ type DevSecretsConfig = {
1982
1982
  type GcpSecretsConfig = {
1983
1983
  type: "gcp";
1984
1984
  };
1985
- type LfvSecretsConfig = {
1986
- type: "lfv";
1985
+ type VaultLfvSecretsConfig = {
1987
1986
  /** LFV server base URL for OTP/action endpoints. */
1988
1987
  lfvServerUrl?: string;
1989
1988
  /** LFV client id used for OTP issuance. */
@@ -2017,15 +2016,28 @@ type LfvSecretsConfig = {
2017
2016
  * Runtime-ready LFV source config.
2018
2017
  * Input config can be partially declared/merged, but LFV operations require these fields.
2019
2018
  */
2020
- type ResolvedLfvSecretsConfig = Omit<LfvSecretsConfig, "lfvServerUrl" | "clientId" | "path"> & {
2019
+ type ResolvedVaultLfvSecretsConfig = Omit<VaultLfvSecretsConfig, "lfvServerUrl" | "clientId" | "path"> & {
2021
2020
  lfvServerUrl: string;
2022
2021
  clientId: string;
2023
2022
  path: string;
2024
2023
  };
2024
+ type VaultWebSocketAuthHeader = "X-Vault-Token" | "Authorization";
2025
+ type VaultWebSocketSecretsConfig = {
2026
+ /** Websocket URL for vault command execution and live secret subscriptions. */
2027
+ url?: string;
2028
+ /** Token used during websocket connect/auth. */
2029
+ token?: string;
2030
+ /** Header name used to send the websocket token. Defaults to X-Vault-Token. */
2031
+ header?: VaultWebSocketAuthHeader;
2032
+ };
2025
2033
  type VaultSecretsConfig = {
2026
2034
  type: "vault";
2027
2035
  url?: string;
2028
2036
  token?: string;
2037
+ /** Optional LFV transport capability for reads/lifecycle operations. */
2038
+ lfv?: VaultLfvSecretsConfig;
2039
+ /** Optional websocket capability for vault commands and live subscriptions. */
2040
+ websocket?: VaultWebSocketSecretsConfig;
2029
2041
  /**
2030
2042
  * MINIMUM: 600_000 milliseconds (10 minutes). Polls the path every ttl milliseconds and calls onConfig when config changes.
2031
2043
  */
@@ -2131,7 +2143,6 @@ interface UpsertTenantRequest {
2131
2143
  email?: string;
2132
2144
  webhookUrl?: string;
2133
2145
  callbackUrl?: string;
2134
- tenantUrl: string;
2135
2146
  configSource: TenantSecretsConfig;
2136
2147
  }
2137
2148
  type UpsertTenantResponse = {
@@ -2193,26 +2204,22 @@ type TenantValidators = {
2193
2204
  */
2194
2205
  type TenantConfigEnv = {
2195
2206
  ES_CONFIG_TYPE?: ConfigSourceType;
2196
- ES_APP_ID?: string;
2197
- ES_CONFIG_PATH?: string;
2198
- ES_IONITE_URL?: string;
2199
- ES_LFV_PATH?: string;
2200
- ES_LFV_SERVER_URL?: string;
2201
- ES_LFV_CLIENT_ID?: string;
2202
- ES_LFV_SIGNATURE?: string;
2203
- ES_LFV_DELIVERY_ENDPOINT?: string;
2204
- ES_LFV_VERIFY_PUBLIC_KEY?: string;
2205
- ES_LFV_EVENTS_ENDPOINT?: string;
2206
- ES_LFV_DELIVERY_TIMEOUT?: string;
2207
- ES_LFV_RETRY_INTERVAL?: string;
2208
- ES_LFV_WARN_INTERVAL?: string;
2209
- ES_FILE_PATH?: string;
2210
- ES_FILE_WATCH?: string;
2211
- ES_FILE_TTL?: string;
2212
2207
  ES_VAULT_URL?: string;
2213
2208
  ES_VAULT_TOKEN?: string;
2214
2209
  ES_VAULT_PATH?: string;
2215
2210
  ES_VAULT_TTL?: string;
2211
+ ES_VAULT_LFV_SERVER_URL?: string;
2212
+ ES_VAULT_LFV_CLIENT_ID?: string;
2213
+ ES_VAULT_LFV_SIGNATURE?: string;
2214
+ ES_VAULT_LFV_DELIVERY_ENDPOINT?: string;
2215
+ ES_VAULT_LFV_VERIFY_PUBLIC_KEY?: string;
2216
+ ES_VAULT_LFV_EVENTS_ENDPOINT?: string;
2217
+ ES_VAULT_LFV_DELIVERY_TIMEOUT?: string;
2218
+ ES_VAULT_LFV_RETRY_INTERVAL?: string;
2219
+ ES_VAULT_LFV_WARN_INTERVAL?: string;
2220
+ ES_VAULT_WEBSOCKET_URL?: string;
2221
+ ES_VAULT_WEBSOCKET_TOKEN?: string;
2222
+ ES_VAULT_WEBSOCKET_HEADER?: "X-Vault-Token" | "Authorization";
2216
2223
  ES_AZURE_API_VERSION?: string;
2217
2224
  ES_AZURE_SCOPE?: string;
2218
2225
  ES_AZURE_SECRET_NAME_PREFIX?: string;
@@ -2230,23 +2237,32 @@ type TenantConfigEnv = {
2230
2237
  ES_AWS_TTL?: string;
2231
2238
  ES_GCP_TTL?: string;
2232
2239
  };
2233
- type TenantSecretsConfig = LfvSecretsConfig | (VaultSecretsConfig & {
2240
+ type TenantSecretsConfig = (VaultSecretsConfig & {
2234
2241
  path: string;
2235
2242
  retryInterval?: number;
2236
- }) | (DevSecretsConfig & {
2237
- path?: string;
2238
- appId?: string;
2239
2243
  }) | (AwsSecretsConfig & {
2240
2244
  ttl?: number;
2241
2245
  }) | AzureSecretsConfig | (GcpSecretsConfig & {
2242
2246
  ttl?: number;
2243
- }) | {
2244
- type: "localFile";
2245
- path?: string;
2246
- watch?: boolean;
2247
- ttl?: number;
2247
+ });
2248
+ type TenantStoredConfigLocator = {
2249
+ /** Indicates that the tenant config descriptor is stored securely outside the tenant record. */
2250
+ type: "stored";
2251
+ /** Root secure source type used to fetch the stored tenant config descriptor. */
2252
+ sourceType: "vault";
2253
+ /** Path to the stored tenant config descriptor. */
2254
+ path: string;
2248
2255
  };
2249
- type TenantConfigSourceInput = TenantSecretsConfig | ConfigSource;
2256
+ type TenantRemoteConfigLocator = {
2257
+ /** Indicates that the tenant RemoteConfig already exists at this secure source path. */
2258
+ type: "remoteConfig";
2259
+ /** Secure source type used to load the RemoteConfig document directly. */
2260
+ sourceType: "vault";
2261
+ /** Path to the tenant RemoteConfig document. */
2262
+ path: string;
2263
+ };
2264
+ type TenantConfigLocator = TenantStoredConfigLocator | TenantRemoteConfigLocator;
2265
+ type TenantConfigSourceInput = TenantConfigLocator | ConfigSource;
2250
2266
  type TenantBaseRecord = {
2251
2267
  tenantId: string;
2252
2268
  companyId: string;
@@ -2266,11 +2282,18 @@ type TenantBaseRecord = {
2266
2282
  /** Persisted tenant config metadata, or a runtime ConfigSource for internal-only tenants. */
2267
2283
  configSource: TenantConfigSourceInput;
2268
2284
  /** Runtime helper that returns a ConfigSource for this tenant. */
2269
- config: () => ConfigSource;
2285
+ config: (source?: SecretsSource) => ConfigSource;
2270
2286
  };
2271
2287
  type StoredTenant<TExtended extends object = Record<string, never>> = TenantBaseRecord & TExtended;
2272
2288
  type StoredTenantRecord<TExtended extends object = Record<string, never>> = Omit<StoredTenant<TExtended>, "config">;
2273
2289
  type TenantEsFactory<TExtended extends object = Record<string, never>> = (tenant: StoredTenant<TExtended>) => EnterpriseStandard;
2290
+ type TenantConfigStoreRequest<TExtended extends object = Record<string, never>> = {
2291
+ es: EnterpriseStandard;
2292
+ tenantId: string;
2293
+ request: UpsertTenantRequest;
2294
+ configData: TenantSecretsConfig;
2295
+ existingTenant: StoredTenant<TExtended> | null;
2296
+ };
2274
2297
  type TenantStoreWithESOptions<TExtended extends object = Record<string, never>> = {
2275
2298
  /**
2276
2299
  * TTL for cached per-tenant EnterpriseStandard instances, in milliseconds.
@@ -2294,6 +2317,7 @@ type TenantStoreBase<
2294
2317
  TMode extends UserMode = "singleTenantOnly",
2295
2318
  TExtended extends object = Record<string, never>
2296
2319
  > = TenantUserRegistration<TMode> & {
2320
+ storeConfig(config: TenantConfigStoreRequest<TExtended>): Promise<TenantConfigSourceInput>;
2297
2321
  get(tenantId: string): Promise<StoredTenant<TExtended> | null>;
2298
2322
  list(options?: TenantListOptions): Promise<ListResult<StoredTenant<TExtended>>>;
2299
2323
  upsert(tenant: TenantStoreUpsertRecord<TExtended>): Promise<StoredTenant<TExtended>>;
@@ -2352,7 +2376,96 @@ declare class InMemoryTenantStore<
2352
2376
  private resolveTenantsByUserId;
2353
2377
  }
2354
2378
  declare function sendTenantWebhook(webhookUrl: string, payload: TenantWebhookPayload, log: Logger): Promise<void>;
2355
- type ConfigSourceType = "vault" | "lfv" | "azure" | "aws" | "gcp" | "dev" | "localFile";
2379
+ /**
2380
+ * Magic link data stored in the store.
2381
+ *
2382
+ * @template TExtended - Type-safe custom data that consumers can add to magic links
2383
+ */
2384
+ type MagicLink<TExtended = object> = {
2385
+ /**
2386
+ * The magic link token (unique identifier)
2387
+ */
2388
+ token: string;
2389
+ /**
2390
+ * User information associated with this magic link
2391
+ */
2392
+ user: BaseUser;
2393
+ /**
2394
+ * Timestamp when the magic link was created
2395
+ */
2396
+ createdAt: Date;
2397
+ /**
2398
+ * Timestamp when the magic link expires
2399
+ */
2400
+ expiresAt: Date;
2401
+ /**
2402
+ * Allow consumers to add runtime data to magic links
2403
+ */
2404
+ [key: string]: unknown;
2405
+ } & TExtended;
2406
+ /**
2407
+ * Abstract interface for magic link storage backends.
2408
+ *
2409
+ * Consumers can implement this interface to use different storage backends:
2410
+ * - In-memory (for development/testing)
2411
+ * - Redis (for production with fast lookups and automatic expiration)
2412
+ * - Database (PostgreSQL, MySQL, etc.)
2413
+ *
2414
+ * @template TExtended - Type-safe custom data that consumers can add to magic links
2415
+ *
2416
+ * @example
2417
+ * ```typescript
2418
+ * // Custom magic link data
2419
+ * type MyMagicLinkData = {
2420
+ * source: string;
2421
+ * metadata: Record<string, unknown>;
2422
+ * };
2423
+ *
2424
+ * // Implement custom store
2425
+ * class RedisMagicLinkStore implements MagicLinkStore<MyMagicLinkData> {
2426
+ * async create(token: string, user: BaseUser, expiresAt: Date): Promise<void> {
2427
+ * const magicLink: MagicLink<MyMagicLinkData> = {
2428
+ * token,
2429
+ * user,
2430
+ * createdAt: new Date(),
2431
+ * expiresAt,
2432
+ * source: 'api',
2433
+ * metadata: {},
2434
+ * };
2435
+ * const ttl = Math.floor((expiresAt.getTime() - Date.now()) / 1000);
2436
+ * await redis.setex(`magic-link:${token}`, ttl, JSON.stringify(magicLink));
2437
+ * }
2438
+ * // ... other methods
2439
+ * }
2440
+ * ```
2441
+ */
2442
+ interface MagicLinkStore<TExtended = object> {
2443
+ /**
2444
+ * Create a new magic link in the store.
2445
+ *
2446
+ * @param token - The magic link token (unique identifier)
2447
+ * @param user - The user information to associate with this magic link
2448
+ * @param expiresAt - When the magic link expires
2449
+ * @throws Error if magic link with same token already exists
2450
+ */
2451
+ create(token: string, user: BaseUser, expiresAt: Date): Promise<void>;
2452
+ /**
2453
+ * Retrieve a magic link by its token.
2454
+ *
2455
+ * @param token - The magic link token
2456
+ * @returns The magic link if found and not expired, null otherwise
2457
+ */
2458
+ get(token: string): Promise<MagicLink<TExtended> | null>;
2459
+ /**
2460
+ * Delete a magic link by its token.
2461
+ *
2462
+ * Used after a magic link has been consumed (one-time use).
2463
+ *
2464
+ * @param token - The magic link token to delete
2465
+ */
2466
+ delete(token: string): Promise<void>;
2467
+ }
2468
+ type ConfigSourceType = "vault" | "azure" | "aws" | "gcp";
2356
2469
  type ESValidators = {
2357
2470
  sso: SSOValidators;
2358
2471
  iam: IAMValidators;
@@ -2405,13 +2518,26 @@ type RemoteConfig = {
2405
2518
  secrets?: SecretsModuleConfig;
2406
2519
  ciam?: CIAMConfig;
2407
2520
  };
2521
+ /**
2522
+ * Stores supplied by the framework/application when creating an Enterprise Standard instance.
2523
+ */
2524
+ type FrameworkStores = {
2525
+ sessionStore?: SessionStore<unknown>;
2526
+ userStore?: UserStore<unknown>;
2527
+ groupStore?: GroupStore<unknown>;
2528
+ magicLinkStore?: MagicLinkStore<unknown>;
2529
+ workloadTokenStore?: WorkloadTokenStore;
2530
+ };
2531
+ type ModifiableFrameworkConfig = FrameworkConfig & {
2532
+ setStores(stores: FrameworkStores): void;
2533
+ };
2408
2534
  /** Return type from the beforeChange hook passed to enterpriseStandard(). */
2409
2535
  type ESConfigChangeResult = {
2410
2536
  config?: RemoteConfig;
2411
2537
  frameworkConfig?: FrameworkConfig;
2412
2538
  };
2413
2539
  /** beforeChange callback invoked on every config application (initial load and updates). */
2414
- type ESConfigChangeCallback = (config: RemoteConfig, frameworkConfig: FrameworkConfig, oldConfig: RemoteConfig | undefined) => ESConfigChangeResult | void;
2540
+ type ESConfigChangeCallback = (config: RemoteConfig, frameworkConfig: ModifiableFrameworkConfig, oldConfig: RemoteConfig | undefined) => ESConfigChangeResult | void;
2415
2541
  type ConfigSource = {
2416
2542
  load(): Promise<RemoteConfig>;
2417
2543
  /**
@@ -2421,6 +2547,11 @@ type ConfigSource = {
2421
2547
  */
2422
2548
  subscribe(onConfig: (config: RemoteConfig) => void): undefined | (() => void);
2423
2549
  /**
2550
+ * Default secret client for the config source itself.
2551
+ * For vault-backed sources this is the vault used to read RemoteConfig.
2552
+ */
2553
+ secret: SecretsSource;
2554
+ /**
2424
2555
  * Optional. If not set by the creator, the framework may set this before calling load/subscribe
2425
2556
  * so the source can use the same logger.
2426
2557
  */
@@ -2473,6 +2604,8 @@ type EnterpriseStandardBase = {
2473
2604
  tenantId?: string;
2474
2605
  /** Most recent remote config applied to this instance (from ConfigSource, after beforeChange if any). */
2475
2606
  config?: RemoteConfig;
2607
+ /** Default config-source-backed secret client, typically the vault used for RemoteConfig. */
2608
+ secret: SecretsSource;
2476
2609
  secrets?: Secrets;
2477
2610
  sso?: SSO;
2478
2611
  iam?: IAM;
@@ -2497,6 +2630,7 @@ type EnterpriseStandardStrict<C extends FrameworkConfig> = {
2497
2630
  logger?: Logger;
2498
2631
  tenantId?: string;
2499
2632
  config?: RemoteConfig;
2633
+ secret: SecretsSource;
2500
2634
  secrets: ESModuleFromConfig<C, "secrets", Secrets & NamedSecretsFromConfig<C>>;
2501
2635
  sso: ESModuleFromConfig<C, "sso", SSO>;
2502
2636
  iam: ESModuleFromConfig<C, "iam", IAM>;
@@ -2542,102 +2676,13 @@ type ESRoutingOptions = {
2542
2676
  */
2543
2677
  type ESConfigChangeOptions = {
2544
2678
  beforeChange?: ESConfigChangeCallback;
2545
- afterChange?: (es: EnterpriseStandard, config: RemoteConfig, frameworkConfig: FrameworkConfig, oldConfig: RemoteConfig | undefined) => void;
2679
+ afterChange?: (es: EnterpriseStandard, config: RemoteConfig, frameworkConfig: ModifiableFrameworkConfig, oldConfig: RemoteConfig | undefined) => void;
2546
2680
  /**
2547
2681
  * Optional runtime routing customization for `es.handler(request)`.
2548
2682
  */
2549
2683
  routing?: ESRoutingOptions;
2550
2684
  };
2551
2685
  /**
2552
- * Magic link data stored in the store.
2553
- *
2554
- * @template TExtended - Type-safe custom data that consumers can add to magic links
2555
- */
2556
- type MagicLink<TExtended = object> = {
2557
- /**
2558
- * The magic link token (unique identifier)
2559
- */
2560
- token: string;
2561
- /**
2562
- * User information associated with this magic link
2563
- */
2564
- user: BaseUser;
2565
- /**
2566
- * Timestamp when the magic link was created
2567
- */
2568
- createdAt: Date;
2569
- /**
2570
- * Timestamp when the magic link expires
2571
- */
2572
- expiresAt: Date;
2573
- /**
2574
- * Allow consumers to add runtime data to magic links
2575
- */
2576
- [key: string]: unknown;
2577
- } & TExtended;
2578
- /**
2579
- * Abstract interface for magic link storage backends.
2580
- *
2581
- * Consumers can implement this interface to use different storage backends:
2582
- * - In-memory (for development/testing)
2583
- * - Redis (for production with fast lookups and automatic expiration)
2584
- * - Database (PostgreSQL, MySQL, etc.)
2585
- *
2586
- * @template TExtended - Type-safe custom data that consumers can add to magic links
2587
- *
2588
- * @example
2589
- * ```typescript
2590
- * // Custom magic link data
2591
- * type MyMagicLinkData = {
2592
- * source: string;
2593
- * metadata: Record<string, unknown>;
2594
- * };
2595
- *
2596
- * // Implement custom store
2597
- * class RedisMagicLinkStore implements MagicLinkStore<MyMagicLinkData> {
2598
- * async create(token: string, user: BaseUser, expiresAt: Date): Promise<void> {
2599
- * const magicLink: MagicLink<MyMagicLinkData> = {
2600
- * token,
2601
- * user,
2602
- * createdAt: new Date(),
2603
- * expiresAt,
2604
- * source: 'api',
2605
- * metadata: {},
2606
- * };
2607
- * const ttl = Math.floor((expiresAt.getTime() - Date.now()) / 1000);
2608
- * await redis.setex(`magic-link:${token}`, ttl, JSON.stringify(magicLink));
2609
- * }
2610
- * // ... other methods
2611
- * }
2612
- * ```
2613
- */
2614
- interface MagicLinkStore<TExtended = object> {
2615
- /**
2616
- * Create a new magic link in the store.
2617
- *
2618
- * @param token - The magic link token (unique identifier)
2619
- * @param user - The user information to associate with this magic link
2620
- * @param expiresAt - When the magic link expires
2621
- * @throws Error if magic link with same token already exists
2622
- */
2623
- create(token: string, user: BaseUser, expiresAt: Date): Promise<void>;
2624
- /**
2625
- * Retrieve a magic link by its token.
2626
- *
2627
- * @param token - The magic link token
2628
- * @returns The magic link if found and not expired, null otherwise
2629
- */
2630
- get(token: string): Promise<MagicLink<TExtended> | null>;
2631
- /**
2632
- * Delete a magic link by its token.
2633
- *
2634
- * Used after a magic link has been consumed (one-time use).
2635
- *
2636
- * @param token - The magic link token to delete
2637
- */
2638
- delete(token: string): Promise<void>;
2639
- }
2640
- /**
2641
2686
  * Validators for CIAM (magic link) request bodies.
2642
2687
  * Used to validate the POST body for magic link generation (BaseUser).
2643
2688
  * baseUser includes a top-level .validate() for a cleaner API (see withValidate).
@@ -3000,16 +3045,140 @@ interface EnterpriseUser extends BaseUser {
3000
3045
  };
3001
3046
  }
3002
3047
  import { StandardSchemaV1 as StandardSchemaV19 } from "@standard-schema/spec";
3048
+ type RegisterSSOAppPayload = {
3049
+ /** Redirect URIs for the client. */
3050
+ redirectUris: string[];
3051
+ /** Optional back-channel logout URI. */
3052
+ backchannelLogoutUri?: string;
3053
+ /** Optional display name for IdP UIs. */
3054
+ displayName?: string;
3055
+ /** Optional default scope (e.g. openid profile email). */
3056
+ defaultScope?: string;
3057
+ /** Optional customer tenant identifier for the tenant-scoped issuer. */
3058
+ tenantId?: string;
3059
+ /** Optional application identifier so one tenant can register multiple clients. */
3060
+ applicationId?: string;
3061
+ };
3062
+ type RegisterSSOAppResult = {
3063
+ registered: true;
3064
+ /** OIDC client_id; required on success (issued by IdP). */
3065
+ clientId: string;
3066
+ /** OIDC client secret; required on success (issued by IdP). */
3067
+ clientSecret: string;
3068
+ /** OIDC authority/issuer base URL exposed by the IdP. */
3069
+ authority: string;
3070
+ /** OIDC authorization endpoint URL exposed by the IdP. */
3071
+ authorizationUrl: string;
3072
+ /** OIDC JWKS endpoint URL exposed by the IdP. */
3073
+ jwksUri: string;
3074
+ /** OIDC token endpoint URL exposed by the IdP. */
3075
+ tokenUrl: string;
3076
+ appId?: string;
3077
+ message?: string;
3078
+ };
3079
+ type RegisterSSOAppError = {
3080
+ status: number;
3081
+ code?: string;
3082
+ message?: string;
3083
+ details?: unknown;
3084
+ };
3085
+ type SSOAppRegistry = {
3086
+ register: (payload: RegisterSSOAppPayload) => Promise<RegisterSSOAppResult>;
3087
+ };
3088
+ type SSOAppValidators = {
3089
+ registerSSOAppPayload: StandardSchemaV19<unknown, RegisterSSOAppPayload>;
3090
+ };
3091
+ type IAMAppRole = "authoritative_source" | "provisioning_target";
3092
+ type RegisterIAMAppPayload = {
3093
+ /** App/tenant identifier (same tenantId used by the ESA). */
3094
+ tenantId: string;
3095
+ /** Company identifier (reporting only). */
3096
+ companyId: string;
3097
+ /** Company name. */
3098
+ companyName: string;
3099
+ /** Environment type (POC, DEV, QA, PROD). */
3100
+ environmentType: EnvironmentType;
3101
+ /** Base URL of the tenant (if known). */
3102
+ tenantUrl?: string;
3103
+ /** Display name for ESP UIs. */
3104
+ displayName?: string;
3105
+ /** Product identifier (optional categorization for ESPs/ESIs). */
3106
+ productId?: string;
3107
+ /** Application identifier (optional categorization for ESPs/ESIs). */
3108
+ applicationId?: string;
3109
+ /** Base URL for the ESA's SCIM endpoints (e.g. https://tenant/app/api/es/iam). */
3110
+ scimBaseUrl?: string;
3111
+ /** Workload identity configuration the ESP should use to call the ESA. */
3112
+ workload?: WorkloadConfig;
3113
+ /**
3114
+ * SCIM userType values for which this ESA is an HR/source (e.g. Employee, Contractor, Vendor).
3115
+ * The IAM ESP uses this to choose which ESA to pull from or trust for attributes per user type.
3116
+ */
3117
+ sourceUserTypes?: string[];
3118
+ /**
3119
+ * Optional IAM-specific roles for this registration.
3120
+ * Use `authoritative_source` when this app is the source of truth for identity attributes and
3121
+ * `provisioning_target` when onboarding should provision into this app.
3122
+ */
3123
+ iamRoles?: IAMAppRole[];
3124
+ };
3125
+ type RegisterIAMAppResult = {
3126
+ registered: true;
3127
+ appId?: string;
3128
+ message?: string;
3129
+ };
3130
+ type RegisterIAMAppError = {
3131
+ status: number;
3132
+ code?: string;
3133
+ message?: string;
3134
+ details?: unknown;
3135
+ };
3136
+ type IAMAppRegistry = {
3137
+ register: (payload: RegisterIAMAppPayload) => Promise<RegisterIAMAppResult>;
3138
+ };
3139
+ type IAMAppValidators = {
3140
+ registerIAMAppPayload: StandardSchemaV19<unknown, RegisterIAMAppPayload>;
3141
+ };
3142
+ type LfvActionName = "read_secret" | "create_secret" | "update_secret" | "delete_secret" | "request_rotate" | "request_revoke" | "rotate_secret" | "revoke_secret" | "list_paths" | "list_secrets" | "read_metadata" | "read_acl" | "write_acl" | "remove_path";
3143
+ type LfvOtpRequest = {
3144
+ request_id: string;
3145
+ path: string;
3146
+ action: LfvActionName;
3147
+ ttl?: number;
3148
+ };
3149
+ type LfvOtpResponse = {
3150
+ request_id: string;
3151
+ otp: string;
3152
+ expires_at: string;
3153
+ action: LfvActionName;
3154
+ path: string;
3155
+ };
3156
+ type LfvActionRequestBase = {
3157
+ request_id: string;
3158
+ otp: string;
3159
+ path: string;
3160
+ };
3161
+ type LfvActionAcceptedResponse = {
3162
+ request_id: string;
3163
+ operation_id: string;
3164
+ status: "pending" | "accepted" | "completed";
3165
+ };
3166
+ type LfvErrorCode = "invalid_request" | "invalid_signature" | "permission_denied" | "not_found" | "otp_already_used" | "otp_expired" | "rate_limited" | "internal_error";
3167
+ type LfvErrorResponse = {
3168
+ error: LfvErrorCode;
3169
+ message: string;
3170
+ };
3171
+ import { StandardSchemaV1 as StandardSchemaV110 } from "@standard-schema/spec";
3003
3172
  /**
3004
3173
  * Result type for Standard Schema validation (success or failure).
3005
3174
  */
3006
- type ValidateResult<T> = StandardSchemaV19.Result<T>;
3175
+ type ValidateResult<T> = StandardSchemaV110.Result<T>;
3007
3176
  /**
3008
3177
  * A Standard Schema with a top-level `validate()` method for a cleaner API.
3009
3178
  * Use this so callers can call `schema.validate(value)` instead of `schema['~standard'].validate(value)`.
3010
3179
  */
3011
- type StandardSchemaWithValidate<T> = StandardSchemaV19<unknown, T> & {
3012
- validate(value: unknown): Promise<StandardSchemaV19.Result<T>>;
3180
+ type StandardSchemaWithValidate<T> = StandardSchemaV110<unknown, T> & {
3181
+ validate(value: unknown): Promise<StandardSchemaV110.Result<T>>;
3013
3182
  };
3014
3183
  /**
3015
3184
  * Wraps a Standard Schema so it has a top-level `validate(value)` method.
@@ -3020,7 +3189,7 @@ type StandardSchemaWithValidate<T> = StandardSchemaV19<unknown, T> & {
3020
3189
  * const baseUser = withValidate(createBaseUserValidator());
3021
3190
  * const result = await baseUser.validate(requestBody);
3022
3191
  */
3023
- declare function withValidate<T>(schema: StandardSchemaV19<unknown, T>): StandardSchemaWithValidate<T>;
3192
+ declare function withValidate<T>(schema: StandardSchemaV110<unknown, T>): StandardSchemaWithValidate<T>;
3024
3193
  declare function must<T>(value: T | undefined | null, message?: string): T;
3025
3194
  /**
3026
3195
  * Returns a 400 Response with the issues if there are any.
@@ -3053,4 +3222,4 @@ declare function parseJsonc<T>(content: string): T;
3053
3222
  * @returns A promise that resolves when the service is ready.
3054
3223
  */
3055
3224
  declare function waitOn(url: string, test?: (resp: Response) => boolean | Promise<boolean>, pingInterval?: number, warnInterval?: number, timeout?: number): Promise<void>;
3056
- export { workloadTokenResponseSchema, withValidate, waitOn, version, validationFailureResponse, userSchema, tokenResponseSchema, stripJsonComments, silentLogger, setActiveSession, serializeESConfig, sendTenantWebhook, parseJsonc, oidcCallbackSchema, normalizeTenantRoutingStrategy, normalizeTenantPathNamespace, must, mergeConfig, matchTenantPath, listSsoClientIdsFromCookies, list, jwtAssertionClaimsSchema, infoLogger, idTokenClaimsSchema, groupResourceSchema, getActiveSession, findTenantFromStateParam, defaultLogger, decodeUser, debugLogger, consoleLogger, clearActiveSession, claimsToUser, buildTenantPath, X509Certificate, WorkloadValidators, WorkloadTokenStore, WorkloadTokenResponse, WorkloadIncomingOutgoing, WorkloadIdentity, WorkloadConfigMap, WorkloadConfig, WorkloadClient, Workload, VaultSecretsConfig, ValidateResult, UsersInboundHandlerConfig, UserStore, UserSortOptions, UserSortField, UserMode, UserListOptions, User2 as User, UpsertTenantResponse, UpsertTenantRequest, TokenValidationResult, TokenResponse, TenantWebhookPayload, TenantValidators, TenantUserRegistration, TenantStoreWithESOptions, TenantStoreWithES, TenantStoreUpsertRecord, TenantStore, TenantStatus, TenantSortOptions, TenantSortField, TenantSecretsConfig, TenantRoutingStrategy, TenantRequestError, TenantPathRoutingStrategy, TenantPathNamespace, TenantPathMatch, TenantListOptions, TenantJwtRoutingStrategy, TenantEsFactory, TenantDirectoryTenant, TenantDirectoryResponse, TenantDirectoryAccount, TenantConfigSourceInput, TenantConfigEnv, StoredUser, StoredTenantRecord, StoredTenant, StoredGroup, StateCookie, StandardSchemaWithValidate, SortDirection, SessionStore, Session, ServerOnlyWorkloadConfig, SecretsValidators, SecretsSourceType, SecretsSourceMap, SecretsSourceConfig, SecretsSource, SecretsOperationOptions, SecretsModuleConfig, Secrets, SecretRequestSeverity, SecretLifecycleRequest, Secret, User as ScimUser, ScimResult, ScimListResponse, ScimError, SSOValidators, SSOHandlerConfig, SSOConfig, SSO, Role, ResolvedLfvSecretsConfig, RemoteConfig, Photo, PhoneNumber, OidcCallbackParams, Name, MultipleTenantsForUserError, MetaData, MagicLinkStore, MagicLink, LoginConfig, Logger, ListResult, LfvSecretsConfig, JwtBearerWorkloadConfig, JWTAssertionClaims, InMemoryTenantStoreOptions, InMemoryTenantStore, IdTokenClaims, IAMValidators, IAMUsersInbound, IAMHandlerConfig, IAMGroupsOutbound, IAMGroupsInbound, IAMConfig, IAM, GroupsInboundHandlerConfig, GroupStore, GroupSortOptions, GroupSortField, GroupResource, GroupMember, GroupListOptions, Group, GcpSecretsConfig, FrameworkWorkloadIncomingOutgoing, FrameworkWorkloadConfig, FrameworkSecretsSourceConfig, FrameworkSecretsModuleConfig, FrameworkConfig, EnvironmentType, EnterpriseUser, EnterpriseStandardFromConfig, EnterpriseStandardBase, EnterpriseStandard, EnterpriseExtension, Email, ESValidators, ESRoutingOptions, ESRouteModule, ESRouteFilterResult, ESResolvedRoute, ESModuleFromConfig, ESConfigChangeResult, ESConfigChangeOptions, ESConfigChangeCallback, ESConfig, DevSecretsConfig, DEFAULT_TENANT_UI_NAMESPACE, DEFAULT_TENANT_API_NAMESPACE, CreateUserOptions, CreateTenantResponse, CreateTenantRequest, CreateGroupOptions, ConfigSourceType, ConfigSource, ClientCredentialsWorkloadConfig, CachedWorkloadToken, CIAMValidators, CIAMConfigFromCode, CIAMConfig, CIAM, BaseUser, AzureSecretsConfig, AwsSecretsConfig, AwsAuthMethod, ApplicationValidators, Address };
3225
+ export { workloadTokenResponseSchema, withValidate, waitOn, version, validationFailureResponse, userSchema, tokenResponseSchema, stripJsonComments, silentLogger, setActiveSession, serializeESConfig, sendTenantWebhook, parseJsonc, oidcCallbackSchema, normalizeTenantRoutingStrategy, normalizeTenantPathNamespace, must, mergeConfig, matchTenantPath, listSsoClientIdsFromCookies, list, jwtAssertionClaimsSchema, infoLogger, idTokenClaimsSchema, groupResourceSchema, getActiveSession, findTenantFromStateParam, defaultLogger, decodeUser, debugLogger, consoleLogger, clearActiveSession, claimsToUser, buildTenantPath, X509Certificate, WorkloadValidators, WorkloadTokenStore, WorkloadTokenResponse, WorkloadIncomingOutgoing, WorkloadIdentity, WorkloadConfigMap, WorkloadConfig, WorkloadClient, Workload, VaultWebSocketSecretsConfig, VaultWebSocketAuthHeader, VaultSecretsConfig, VaultLfvSecretsConfig, ValidateResult, UsersInboundHandlerConfig, UserStore, UserSortOptions, UserSortField, UserMode, UserListOptions, User2 as User, UpsertTenantResponse, UpsertTenantRequest, TokenValidationResult, TokenResponse, TenantWebhookPayload, TenantValidators, TenantUserRegistration, TenantStoredConfigLocator, TenantStoreWithESOptions, TenantStoreWithES, TenantStoreUpsertRecord, TenantStore, TenantStatus, TenantSortOptions, TenantSortField, TenantSecretsConfig, TenantRoutingStrategy, TenantRequestError, TenantRemoteConfigLocator, TenantPathRoutingStrategy, TenantPathNamespace, TenantPathMatch, TenantListOptions, TenantJwtRoutingStrategy, TenantEsFactory, TenantDirectoryTenant, TenantDirectoryResponse, TenantDirectoryAccount, TenantConfigStoreRequest, TenantConfigSourceInput, TenantConfigLocator, TenantConfigEnv, StoredUser, StoredTenantRecord, StoredTenant, StoredGroup, StateCookie, StandardSchemaWithValidate, SortDirection, SessionStore, Session, ServerOnlyWorkloadConfig, SecretsValidators, SecretsSourceType, SecretsSourceMap, SecretsSourceConfig, SecretsSource, SecretsOperationOptions, SecretsModuleConfig, Secrets, SecretRequestSeverity, SecretLifecycleRequest, Secret, User as ScimUser, ScimResult, ScimListResponse, ScimError, SSOValidators, SSOHandlerConfig, SSOConfig, SSOAppValidators, SSOAppRegistry, SSO, Role, ResolvedVaultLfvSecretsConfig, RemoteConfig, RegisterSSOAppResult, RegisterSSOAppPayload, RegisterSSOAppError, RegisterIAMAppResult, RegisterIAMAppPayload, RegisterIAMAppError, Photo, PhoneNumber, OidcCallbackParams, Name, MultipleTenantsForUserError, ModifiableFrameworkConfig, MetaData, MagicLinkStore, MagicLink, LoginConfig, Logger, ListResult, LfvOtpResponse, LfvOtpRequest, LfvErrorResponse, LfvErrorCode, LfvActionRequestBase, LfvActionName, LfvActionAcceptedResponse, JwtBearerWorkloadConfig, JWTAssertionClaims, InMemoryTenantStoreOptions, InMemoryTenantStore, IdTokenClaims, IAMValidators, IAMUsersInbound, IAMHandlerConfig, IAMGroupsOutbound, IAMGroupsInbound, IAMConfig, IAMAppValidators, IAMAppRole, IAMAppRegistry, IAM, GroupsInboundHandlerConfig, GroupStore, GroupSortOptions, GroupSortField, GroupResource, GroupMember, GroupListOptions, Group, GcpSecretsConfig, FrameworkWorkloadIncomingOutgoing, FrameworkWorkloadConfig, FrameworkStores, FrameworkSecretsSourceConfig, FrameworkSecretsModuleConfig, FrameworkConfig, EnvironmentType, EnterpriseUser, EnterpriseStandardFromConfig, EnterpriseStandardBase, EnterpriseStandard, EnterpriseExtension, Email, ESValidators, ESRoutingOptions, ESRouteModule, ESRouteFilterResult, ESResolvedRoute, ESModuleFromConfig, ESConfigChangeResult, ESConfigChangeOptions, ESConfigChangeCallback, ESConfig, DevSecretsConfig, DEFAULT_TENANT_UI_NAMESPACE, DEFAULT_TENANT_API_NAMESPACE, CreateUserOptions, CreateTenantResponse, CreateTenantRequest, CreateGroupOptions, ConfigSourceType, ConfigSource, ClientCredentialsWorkloadConfig, CachedWorkloadToken, CIAMValidators, CIAMConfigFromCode, CIAMConfig, CIAM, BaseUser, AzureSecretsConfig, AwsSecretsConfig, AwsAuthMethod, ApplicationValidators, Address };