@zuplo/runtime 6.67.11 → 6.67.13
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/out/esm/index.js +45 -45
- package/out/esm/index.js.map +1 -1
- package/out/types/index.d.ts +76 -0
- package/package.json +1 -1
package/out/types/index.d.ts
CHANGED
|
@@ -586,6 +586,82 @@ export declare interface ApiAuthKeyInboundPolicyOptions {
|
|
|
586
586
|
*/
|
|
587
587
|
declare type APIKey = string;
|
|
588
588
|
|
|
589
|
+
/**
|
|
590
|
+
* Represents a consumer in the API Key service.
|
|
591
|
+
* @public
|
|
592
|
+
*/
|
|
593
|
+
export declare interface ApiKeyConsumer {
|
|
594
|
+
/** The unique consumer identifier, e.g. csmr_f9HGke8lQHi2HgxFa4OIst9W */
|
|
595
|
+
id: string;
|
|
596
|
+
/** The consumer name */
|
|
597
|
+
name: string;
|
|
598
|
+
/** Optional description of the consumer */
|
|
599
|
+
description?: string;
|
|
600
|
+
/** Custom metadata stored with the consumer */
|
|
601
|
+
metadata?: unknown;
|
|
602
|
+
/** ISO timestamp when the consumer was created */
|
|
603
|
+
createdOn: string;
|
|
604
|
+
/** ISO timestamp when the consumer was last updated */
|
|
605
|
+
updatedOn: string;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* A client for retrieving consumer data from the Zuplo API key service.
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```typescript
|
|
613
|
+
* import { ApiKeyConsumerClient, ZuploContext, ZuploRequest } from "@zuplo/runtime";
|
|
614
|
+
*
|
|
615
|
+
* // Configure once (e.g., at module level)
|
|
616
|
+
* const consumers = new ApiKeyConsumerClient({
|
|
617
|
+
* cacheDurationSeconds: 300,
|
|
618
|
+
* });
|
|
619
|
+
*
|
|
620
|
+
* export async function myHandler(request: ZuploRequest, context: ZuploContext) {
|
|
621
|
+
* const consumer = await consumers.get("csmr_f9HGke8lQHi2HgxFa4OIst9W");
|
|
622
|
+
*
|
|
623
|
+
* context.log.info(`Consumer: ${consumer.name}`);
|
|
624
|
+
* const metadata = consumer.metadata as { plan: string };
|
|
625
|
+
*
|
|
626
|
+
* return Response.json({ consumer });
|
|
627
|
+
* }
|
|
628
|
+
* ```
|
|
629
|
+
*
|
|
630
|
+
* @beta
|
|
631
|
+
* @public
|
|
632
|
+
*/
|
|
633
|
+
export declare class ApiKeyConsumerClient {
|
|
634
|
+
private readonly bucketId;
|
|
635
|
+
private readonly cacheDurationSeconds;
|
|
636
|
+
private cacheNamePromise;
|
|
637
|
+
constructor(options?: ApiKeyConsumerClientOptions);
|
|
638
|
+
private getCacheName;
|
|
639
|
+
/**
|
|
640
|
+
* Get consumer data by consumer ID.
|
|
641
|
+
*
|
|
642
|
+
* @param consumerId - The unique identifier of the consumer
|
|
643
|
+
* @returns The consumer data including metadata
|
|
644
|
+
*/
|
|
645
|
+
get(consumerId: string): Promise<ApiKeyConsumer>;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Configuration options for {@link ApiKeyConsumerClient}.
|
|
650
|
+
* @public
|
|
651
|
+
*/
|
|
652
|
+
export declare interface ApiKeyConsumerClientOptions {
|
|
653
|
+
/**
|
|
654
|
+
* The bucket ID for the API key service.
|
|
655
|
+
* Defaults to the ZUPLO_SERVICE_BUCKET_ID environment variable.
|
|
656
|
+
*/
|
|
657
|
+
bucketId?: string;
|
|
658
|
+
/**
|
|
659
|
+
* Cache duration in seconds. Set to 0 to disable caching.
|
|
660
|
+
* Defaults to 60.
|
|
661
|
+
*/
|
|
662
|
+
cacheDurationSeconds?: number;
|
|
663
|
+
}
|
|
664
|
+
|
|
589
665
|
/**
|
|
590
666
|
* Authenticates requests based on API Keys using Zuplo's built-in API key management.
|
|
591
667
|
* This policy validates API keys against Zuplo's key storage, caches results for performance,
|