From dc53bd531e9787fb7107cfb09c57752bfd708bb1 Mon Sep 17 00:00:00 2001 From: aksejs <mirukawa@protonmail.ch> Date: Sun, 10 Dec 2023 05:09:58 +0100 Subject: [PATCH 1/2] [functions] Add options parameter to useHttpsCallable --- functions/useHttpsCallable.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/functions/useHttpsCallable.ts b/functions/useHttpsCallable.ts index 28b14f6..fe9e49b 100644 --- a/functions/useHttpsCallable.ts +++ b/functions/useHttpsCallable.ts @@ -1,6 +1,7 @@ import { Functions, httpsCallable, + HttpsCallableOptions, HttpsCallableResult, } from 'firebase/functions'; import { useCallback, useState } from 'react'; @@ -20,7 +21,8 @@ export type HttpsCallableHook< export default <RequestData = unknown, ResponseData = unknown>( functions: Functions, - name: string + name: string, + options?: HttpsCallableOptions, ): HttpsCallableHook<RequestData, ResponseData> => { const [error, setError] = useState<Error>(); const [loading, setLoading] = useState<boolean>(false); @@ -31,7 +33,8 @@ export default <RequestData = unknown, ResponseData = unknown>( ): Promise<HttpsCallableResult<ResponseData> | undefined> => { const callable = httpsCallable<RequestData, ResponseData>( functions, - name + name, + options, ); setLoading(true); setError(undefined); @@ -43,7 +46,7 @@ export default <RequestData = unknown, ResponseData = unknown>( setLoading(false); } }, - [functions, name] + [functions, name, options] ); return [callCallable, loading, error] as const; From e94cae455d885427c4513738f71ef750147b1313 Mon Sep 17 00:00:00 2001 From: aksejs <mirukawa@protonmail.ch> Date: Sun, 10 Dec 2023 05:22:44 +0100 Subject: [PATCH 2/2] [functions] Update README.md --- functions/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/README.md b/functions/README.md index 5008942..40040a5 100644 --- a/functions/README.md +++ b/functions/README.md @@ -27,6 +27,9 @@ The `useHttpsCallable` hook takes the following parameters: - `functions`: `functions.Functions` instance for your Firebase app - `name`: A `string` representing the name of the function to call +- `options`: (optional) `Object` with the following parameters: + - `timeout`: (optional) `number` Time in milliseconds after which to cancel if there is no response + - `limitedUseAppCheckTokens`: (optional) `boolean` If set to true, uses limited-use App Check token for callable function requests from this instance of `Functions` Returns: