@@ -135,25 +135,50 @@ internal enum FunctionsConstants {
135135 return functions ( app: app, region: FunctionsConstants . defaultRegion, customDomain: customDomain)
136136 }
137137
138- /**
139- * Creates a reference to the Callable HTTPS trigger with the given name.
140- * - Parameter name The name of the Callable HTTPS trigger.
141- */
138+ /// Creates a reference to the Callable HTTPS trigger with the given name.
139+ /// - Parameter name: The name of the Callable HTTPS trigger.
140+ /// - Returns: A reference to a Callable HTTPS trigger.
142141 @objc ( HTTPSCallableWithName: ) open func httpsCallable( _ name: String ) -> HTTPSCallable {
143142 return HTTPSCallable ( functions: self , name: name)
144143 }
145144
145+ /// Creates a reference to the Callable HTTPS trigger with the given name and configuration options.
146+ /// - Parameters:
147+ /// - name: The name of the Callable HTTPS trigger.
148+ /// - options: The options with which to customize the Callable HTTPS trigger.
149+ /// - Returns: A reference to a Callable HTTPS trigger.
150+ @objc ( HTTPSCallableWithName: options: ) public func httpsCallable( _ name: String ,
151+ options: HTTPSCallableOptions )
152+ -> HTTPSCallable {
153+ return HTTPSCallable ( functions: self , name: name, options: options)
154+ }
155+
156+ /// Creates a reference to the Callable HTTPS trigger with the given name.
157+ /// - Parameter url: The URL of the Callable HTTPS trigger.
158+ /// - Returns: A reference to a Callable HTTPS trigger.
146159 @objc ( HTTPSCallableWithURL: ) open func httpsCallable( _ url: URL ) -> HTTPSCallable {
147160 return HTTPSCallable ( functions: self , url: url)
148161 }
149162
163+ /// Creates a reference to the Callable HTTPS trigger with the given name and configuration options.
164+ /// - Parameters:
165+ /// - url: The URL of the Callable HTTPS trigger.
166+ /// - options: The options with which to customize the Callable HTTPS trigger.
167+ /// - Returns: A reference to a Callable HTTPS trigger.
168+ @objc ( HTTPSCallableWithURL: options: ) public func httpsCallable( _ url: URL ,
169+ options: HTTPSCallableOptions )
170+ -> HTTPSCallable {
171+ return HTTPSCallable ( functions: self , url: url, options: options)
172+ }
173+
150174 /// Creates a reference to the Callable HTTPS trigger with the given name, the type of an `Encodable`
151175 /// request and the type of a `Decodable` response.
152- /// - Parameter name: The name of the Callable HTTPS trigger
153- /// - Parameter requestAs: The type of the `Encodable` entity to use for requests to this `Callable`
154- /// - Parameter responseAs: The type of the `Decodable` entity to use for responses from this `Callable`
155- /// - Parameter encoder: The encoder instance to use to run the encoding.
156- /// - Parameter decoder: The decoder instance to use to run the decoding.
176+ /// - Parameters:
177+ /// - name: The name of the Callable HTTPS trigger
178+ /// - requestAs: The type of the `Encodable` entity to use for requests to this `Callable`
179+ /// - responseAs: The type of the `Decodable` entity to use for responses from this `Callable`
180+ /// - encoder: The encoder instance to use to perform encoding.
181+ /// - decoder: The decoder instance to use to perform decoding.
157182 /// - Returns: A reference to an HTTPS-callable Cloud Function that can be used to make Cloud Functions invocations.
158183 open func httpsCallable< Request: Encodable ,
159184 Response: Decodable > ( _ name: String ,
@@ -164,16 +189,48 @@ internal enum FunctionsConstants {
164189 decoder: FirebaseDataDecoder = FirebaseDataDecoder (
165190 ) )
166191 -> Callable < Request , Response > {
167- return Callable ( callable: httpsCallable ( name) , encoder: encoder, decoder: decoder)
192+ return Callable (
193+ callable: httpsCallable ( name) ,
194+ encoder: encoder,
195+ decoder: decoder
196+ )
168197 }
169198
170199 /// Creates a reference to the Callable HTTPS trigger with the given name, the type of an `Encodable`
171200 /// request and the type of a `Decodable` response.
172- /// - Parameter url: The url of the Callable HTTPS trigger
173- /// - Parameter requestAs: The type of the `Encodable` entity to use for requests to this `Callable`
174- /// - Parameter responseAs: The type of the `Decodable` entity to use for responses from this `Callable`
175- /// - Parameter encoder: The encoder instance to use to run the encoding.
176- /// - Parameter decoder: The decoder instance to use to run the decoding.
201+ /// - Parameters:
202+ /// - name: The name of the Callable HTTPS trigger
203+ /// - options: The options with which to customize the Callable HTTPS trigger.
204+ /// - requestAs: The type of the `Encodable` entity to use for requests to this `Callable`
205+ /// - responseAs: The type of the `Decodable` entity to use for responses from this `Callable`
206+ /// - encoder: The encoder instance to use to perform encoding.
207+ /// - decoder: The decoder instance to use to perform decoding.
208+ /// - Returns: A reference to an HTTPS-callable Cloud Function that can be used to make Cloud Functions invocations.
209+ open func httpsCallable< Request: Encodable ,
210+ Response: Decodable > ( _ name: String ,
211+ options: HTTPSCallableOptions ,
212+ requestAs: Request . Type = Request . self,
213+ responseAs: Response . Type = Response . self,
214+ encoder: FirebaseDataEncoder = FirebaseDataEncoder (
215+ ) ,
216+ decoder: FirebaseDataDecoder = FirebaseDataDecoder (
217+ ) )
218+ -> Callable < Request , Response > {
219+ return Callable (
220+ callable: httpsCallable ( name, options: options) ,
221+ encoder: encoder,
222+ decoder: decoder
223+ )
224+ }
225+
226+ /// Creates a reference to the Callable HTTPS trigger with the given name, the type of an `Encodable`
227+ /// request and the type of a `Decodable` response.
228+ /// - Parameters:
229+ /// - url: The url of the Callable HTTPS trigger
230+ /// - requestAs: The type of the `Encodable` entity to use for requests to this `Callable`
231+ /// - responseAs: The type of the `Decodable` entity to use for responses from this `Callable`
232+ /// - encoder: The encoder instance to use to perform encoding.
233+ /// - decoder: The decoder instance to use to perform decoding.
177234 /// - Returns: A reference to an HTTPS-callable Cloud Function that can be used to make Cloud Functions invocations.
178235 open func httpsCallable< Request: Encodable ,
179236 Response: Decodable > ( _ url: URL ,
@@ -184,7 +241,38 @@ internal enum FunctionsConstants {
184241 decoder: FirebaseDataDecoder = FirebaseDataDecoder (
185242 ) )
186243 -> Callable < Request , Response > {
187- return Callable ( callable: httpsCallable ( url) , encoder: encoder, decoder: decoder)
244+ return Callable (
245+ callable: httpsCallable ( url) ,
246+ encoder: encoder,
247+ decoder: decoder
248+ )
249+ }
250+
251+ /// Creates a reference to the Callable HTTPS trigger with the given name, the type of an `Encodable`
252+ /// request and the type of a `Decodable` response.
253+ /// - Parameters:
254+ /// - url: The url of the Callable HTTPS trigger
255+ /// - options: The options with which to customize the Callable HTTPS trigger.
256+ /// - requestAs: The type of the `Encodable` entity to use for requests to this `Callable`
257+ /// - responseAs: The type of the `Decodable` entity to use for responses from this `Callable`
258+ /// - encoder: The encoder instance to use to perform encoding.
259+ /// - decoder: The decoder instance to use to perform decoding.
260+ /// - Returns: A reference to an HTTPS-callable Cloud Function that can be used to make Cloud Functions invocations.
261+ open func httpsCallable< Request: Encodable ,
262+ Response: Decodable > ( _ url: URL ,
263+ options: HTTPSCallableOptions ,
264+ requestAs: Request . Type = Request . self,
265+ responseAs: Response . Type = Response . self,
266+ encoder: FirebaseDataEncoder = FirebaseDataEncoder (
267+ ) ,
268+ decoder: FirebaseDataDecoder = FirebaseDataDecoder (
269+ ) )
270+ -> Callable < Request , Response > {
271+ return Callable (
272+ callable: httpsCallable ( url, options: options) ,
273+ encoder: encoder,
274+ decoder: decoder
275+ )
188276 }
189277
190278 /**
@@ -273,10 +361,11 @@ internal enum FunctionsConstants {
273361
274362 internal func callFunction( name: String ,
275363 withObject data: Any ? ,
364+ options: HTTPSCallableOptions ? ,
276365 timeout: TimeInterval ,
277366 completion: @escaping ( ( Result < HTTPSCallableResult , Error > ) -> Void ) ) {
278367 // Get context first.
279- contextProvider. getContext { context, error in
368+ contextProvider. getContext ( options : options ) { context, error in
280369 // Note: context is always non-nil since some checks could succeed, we're only failing if
281370 // there's an error.
282371 if let error = error {
@@ -285,6 +374,7 @@ internal enum FunctionsConstants {
285374 let url = self . urlWithName ( name)
286375 self . callFunction ( url: URL ( string: url) !,
287376 withObject: data,
377+ options: options,
288378 timeout: timeout,
289379 context: context,
290380 completion: completion)
@@ -294,17 +384,19 @@ internal enum FunctionsConstants {
294384
295385 internal func callFunction( url: URL ,
296386 withObject data: Any ? ,
387+ options: HTTPSCallableOptions ? ,
297388 timeout: TimeInterval ,
298389 completion: @escaping ( ( Result < HTTPSCallableResult , Error > ) -> Void ) ) {
299390 // Get context first.
300- contextProvider. getContext { context, error in
391+ contextProvider. getContext ( options : options ) { context, error in
301392 // Note: context is always non-nil since some checks could succeed, we're only failing if
302393 // there's an error.
303394 if let error = error {
304395 completion ( . failure( error) )
305396 } else {
306397 self . callFunction ( url: url,
307398 withObject: data,
399+ options: options,
308400 timeout: timeout,
309401 context: context,
310402 completion: completion)
@@ -314,6 +406,7 @@ internal enum FunctionsConstants {
314406
315407 private func callFunction( url: URL ,
316408 withObject data: Any ? ,
409+ options: HTTPSCallableOptions ? ,
317410 timeout: TimeInterval ,
318411 context: FunctionsContext ,
319412 completion: @escaping ( ( Result < HTTPSCallableResult , Error > ) -> Void ) ) {
@@ -353,8 +446,18 @@ internal enum FunctionsConstants {
353446 fetcher. setRequestValue ( fcmToken, forHTTPHeaderField: Constants . fcmTokenHeader)
354447 }
355448
356- if let appCheckToken = context. appCheckToken {
357- fetcher. setRequestValue ( appCheckToken, forHTTPHeaderField: Constants . appCheckTokenHeader)
449+ if options? . requireLimitedUseAppCheckTokens == true {
450+ if let appCheckToken = context. limitedUseAppCheckToken {
451+ fetcher. setRequestValue (
452+ appCheckToken,
453+ forHTTPHeaderField: Constants . appCheckTokenHeader
454+ )
455+ }
456+ } else if let appCheckToken = context. appCheckToken {
457+ fetcher. setRequestValue (
458+ appCheckToken,
459+ forHTTPHeaderField: Constants . appCheckTokenHeader
460+ )
358461 }
359462
360463 // Override normal security rules if this is a local test.
0 commit comments