3 Commits
Author SHA1 Message Date
Daniel LeeandGitHub 6ab1e32756 Support streaming streaming responses for callable functions. (#8609)
The new .stream() API allows the client to consume streaming responses from the WIP streaming callable functions in Firebase Functions Node.js SDK.

When client makes a request to the callable function w/ header Accept: text/event-stream, the callable function responds with response chunks in Server-Sent Event format.

The sdk changes here abstracts over the wire-protocol by parsing the response chunks and returning an instance of a AsyncIterable to consume to data:

import { getFunctions, httpsCallable } from "firebase/functions";

const functions = getFunctions();
const generateText = httpsCallable(functions, 'generateText');
const resp = await generateText.stream(
  { text: 'What is your favorite Firebase service and why?' },
  { signal: AbortSignal.timeout(60_000) },
);
try {
  for await (const message of resp.stream) {
     console.log(message); // prints "foo", "bar"
  }
  console.log(await resp.data) // prints "foo bar"
} catch (e) {
  // FirebaseError(code='cancelled', message='Request was cancelled.');
  console.error(e)
}
2024-12-04 09:48:50 -08:00
6c0138f0e3 Add support for App Check replay protection in callable functions (#7296)
* Add limited token support for functions

* add test, works as a unit test, broken karma

* Finish adding support for app check callable functions SDK

* PR Feedback

* Doc feedback

Co-authored-by: Kevin Cheung <[email protected]>

* s/useLimitedUseAppCheckToken/limitedUseAppCheckTokens/g

* PR Feedback

---------

Co-authored-by: Samuel Bushi <[email protected]>
Co-authored-by: Kevin Cheung <[email protected]>
2023-05-15 16:25:05 -07:00
Christina HollandandGitHub 013938a4b2 Check in generated docs to git (#7025) 2023-02-10 14:58:50 -08:00