@@ -53,3 +53,178 @@ declare namespace AWSCloudFrontFunction {
5353 } ;
5454 }
5555}
56+
57+ declare module "cloudfront" {
58+ /**
59+ * Retrieves a reference to a CloudFront Key-Value Store (KVS) by its ID.
60+ * @param kvsId The identifier of the KVS to use.
61+ * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-custom-methods.html
62+ */
63+ function kvs ( kvsId : string ) : KVStore ;
64+
65+ interface KVStore {
66+ /**
67+ * Retrieve a value from the store.
68+ * @param key Key to retrieve.
69+ * @throws If key does not exist.
70+ */
71+ get ( key : string ) : Promise < string > ;
72+ get ( key : string , options : { format : "string" } ) : Promise < string > ;
73+ get ( key : string , options : { format : "bytes" } ) : Promise < Uint8Array > ;
74+ get ( key : string , options : { format : "json" } ) : Promise < unknown > ;
75+
76+ /**
77+ * Check if the key exists in the store.
78+ * @param key Key to check.
79+ */
80+ exists ( key : string ) : Promise < boolean > ;
81+
82+ /**
83+ * Retrieve metadata about the key-value store.
84+ */
85+ meta ( ) : Promise < {
86+ creationDateTime : string ;
87+ lastUpdatedDateTime : string ;
88+ keyCount : number ;
89+ } > ;
90+ }
91+
92+ interface OriginAccessControlConfig {
93+ enabled : boolean ;
94+ signingBehavior : "always" | "never" | "no-override" ;
95+ signingProtocol : "sigv4" ;
96+ originType : "s3" | "mediapackagev2" | "mediastore" | "lambda" ;
97+ }
98+
99+ interface OriginShield {
100+ enabled : boolean ;
101+ region : string ;
102+ }
103+
104+ interface Timeouts {
105+ /**
106+ * Max time (seconds) to wait for a response or next packet. (1–60)
107+ */
108+ readTimeout ?: number ;
109+
110+ /**
111+ * Max time (seconds) to keep the connection alive after response. (1–60)
112+ */
113+ keepAliveTimeout ?: number ;
114+
115+ /**
116+ * Max time (seconds) to wait for connection establishment. (1–10)
117+ */
118+ connectionTimeout ?: number ;
119+ }
120+
121+ interface CustomOriginConfig {
122+ /**
123+ * Port number of the origin. e.g., 80 or 443
124+ */
125+ port : number ;
126+
127+ /**
128+ * Protocol used to connect. Must be "http" or "https"
129+ */
130+ protocol : "http" | "https" ;
131+
132+ /**
133+ * Minimum TLS/SSL version to use for HTTPS connections.
134+ */
135+ sslProtocols : Array < "SSLv3" | "TLSv1" | "TLSv1.1" | "TLSv1.2" > ;
136+ }
137+
138+ interface UpdateRequestOriginParams {
139+ /**
140+ * New origin's domain name. Optional if reusing existing origin's domain.
141+ */
142+ domainName ?: string ;
143+
144+ /**
145+ * Path prefix to append when forwarding request to origin.
146+ */
147+ originPath ?: string ;
148+
149+ /**
150+ * Override or clear custom headers for the origin request.
151+ */
152+ customHeaders ?: Record < string , string > ;
153+
154+ /**
155+ * Number of connection attempts (1–3).
156+ */
157+ connectionAttempts ?: number ;
158+
159+ /**
160+ * Origin Shield configuration. Enables shield layer if specified.
161+ */
162+ originShield ?: OriginShield ;
163+
164+ /**
165+ * Origin Access Control (OAC) configuration.
166+ */
167+ originAccessControlConfig ?: OriginAccessControlConfig ;
168+
169+ /**
170+ * Response and connection timeout configurations.
171+ */
172+ timeouts ?: Timeouts ;
173+
174+ /**
175+ * Settings for non-S3 origins or S3 with static website hosting.
176+ */
177+ customOriginConfig ?: CustomOriginConfig ;
178+ }
179+
180+ /**
181+ * Mutates the current request’s origin.
182+ * You can specify a new origin (e.g., S3 or ALB), change custom headers, enable OAC, or enable Origin Shield.
183+ * Missing fields will inherit values from the assigned origin.
184+ * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/helper-functions-origin-modification.html#update-request-origin-helper-function
185+ */
186+ function updateRequestOrigin ( params : UpdateRequestOriginParams ) : void ;
187+
188+ /**
189+ * Switches to another origin already defined in the distribution by origin ID.
190+ * This is more efficient than defining a new one via `updateRequestOrigin()`.
191+ * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/helper-functions-origin-modification.html#select-request-origin-id-helper-function
192+ */
193+ function selectRequestOriginById ( originId : string ) : void ;
194+
195+ interface CreateRequestOriginGroupParams {
196+ /**
197+ * Two origin IDs to form an origin group.
198+ * The first is primary; the second is used for failover.
199+ */
200+ originIds : [ string , string ] ;
201+
202+ /**
203+ * Failover selection strategy: default or media-quality-score.
204+ */
205+ selectionCriteria ?: "default" | "media-quality-score" ;
206+
207+ /**
208+ * List of status codes that trigger failover to the secondary origin.
209+ */
210+ failoverCriteria : {
211+ statusCodes : number [ ] ;
212+ } ;
213+ }
214+
215+ /**
216+ * Creates a new origin group for failover logic.
217+ * The origin group can be referenced later via origin ID.
218+ * @see https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/helper-functions-origin-modification.html#create-request-origin-group-helper-function
219+ */
220+ function createRequestOriginGroup ( params : CreateRequestOriginGroupParams ) : void ;
221+
222+ const cf : {
223+ kvs : typeof kvs ;
224+ updateRequestOrigin : typeof updateRequestOrigin ;
225+ selectRequestOriginById : typeof selectRequestOriginById ;
226+ createRequestOriginGroup : typeof createRequestOriginGroup ;
227+ } ;
228+
229+ export default cf ;
230+ }
0 commit comments