@depup/firebase__functions 0.13.2-depup.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/serializer.ts","../src/constants.ts","../src/error.ts","../src/context.ts","../src/service.ts","../src/config.ts","../src/api.ts","../src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconst LONG_TYPE = 'type.googleapis.com/google.protobuf.Int64Value';\nconst UNSIGNED_LONG_TYPE = 'type.googleapis.com/google.protobuf.UInt64Value';\n\nfunction mapValues(\n // { [k: string]: unknown } is no longer a wildcard assignment target after typescript 3.5\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n o: { [key: string]: any },\n f: (arg0: unknown) => unknown\n): object {\n const result: { [key: string]: unknown } = {};\n for (const key in o) {\n if (o.hasOwnProperty(key)) {\n result[key] = f(o[key]);\n }\n }\n return result;\n}\n\n/**\n * Takes data and encodes it in a JSON-friendly way, such that types such as\n * Date are preserved.\n * @internal\n * @param data - Data to encode.\n */\nexport function encode(data: unknown): unknown {\n if (data == null) {\n return null;\n }\n if (data instanceof Number) {\n data = data.valueOf();\n }\n if (typeof data === 'number' && isFinite(data)) {\n // Any number in JS is safe to put directly in JSON and parse as a double\n // without any loss of precision.\n return data;\n }\n if (data === true || data === false) {\n return data;\n }\n if (Object.prototype.toString.call(data) === '[object String]') {\n return data;\n }\n if (data instanceof Date) {\n return data.toISOString();\n }\n if (Array.isArray(data)) {\n return data.map(x => encode(x));\n }\n if (typeof data === 'function' || typeof data === 'object') {\n return mapValues(data!, x => encode(x));\n }\n // If we got this far, the data is not encodable.\n throw new Error('Data cannot be encoded in JSON: ' + data);\n}\n\n/**\n * Takes data that's been encoded in a JSON-friendly form and returns a form\n * with richer datatypes, such as Dates, etc.\n * @internal\n * @param json - JSON to convert.\n */\nexport function decode(json: unknown): unknown {\n if (json == null) {\n return json;\n }\n if ((json as { [key: string]: unknown })['@type']) {\n switch ((json as { [key: string]: unknown })['@type']) {\n case LONG_TYPE:\n // Fall through and handle this the same as unsigned.\n case UNSIGNED_LONG_TYPE: {\n // Technically, this could work return a valid number for malformed\n // data if there was a number followed by garbage. But it's just not\n // worth all the extra code to detect that case.\n const value = Number((json as { [key: string]: unknown })['value']);\n if (isNaN(value)) {\n throw new Error('Data cannot be decoded from JSON: ' + json);\n }\n return value;\n }\n default: {\n throw new Error('Data cannot be decoded from JSON: ' + json);\n }\n }\n }\n if (Array.isArray(json)) {\n return json.map(x => decode(x));\n }\n if (typeof json === 'function' || typeof json === 'object') {\n return mapValues(json!, x => decode(x));\n }\n // Anything else is safe to return.\n return json;\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Type constant for Firebase Functions.\n */\nexport const FUNCTIONS_TYPE = 'functions';\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FunctionsErrorCodeCore as FunctionsErrorCode } from './public-types';\nimport { decode } from './serializer';\nimport { HttpResponseBody } from './service';\nimport { FirebaseError } from '@firebase/util';\nimport { FUNCTIONS_TYPE } from './constants';\n\n/**\n * Standard error codes for different ways a request can fail, as defined by:\n * https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto\n *\n * This map is used primarily to convert from a backend error code string to\n * a client SDK error code string, and make sure it's in the supported set.\n */\nconst errorCodeMap: { [name: string]: FunctionsErrorCode } = {\n OK: 'ok',\n CANCELLED: 'cancelled',\n UNKNOWN: 'unknown',\n INVALID_ARGUMENT: 'invalid-argument',\n DEADLINE_EXCEEDED: 'deadline-exceeded',\n NOT_FOUND: 'not-found',\n ALREADY_EXISTS: 'already-exists',\n PERMISSION_DENIED: 'permission-denied',\n UNAUTHENTICATED: 'unauthenticated',\n RESOURCE_EXHAUSTED: 'resource-exhausted',\n FAILED_PRECONDITION: 'failed-precondition',\n ABORTED: 'aborted',\n OUT_OF_RANGE: 'out-of-range',\n UNIMPLEMENTED: 'unimplemented',\n INTERNAL: 'internal',\n UNAVAILABLE: 'unavailable',\n DATA_LOSS: 'data-loss'\n};\n\n/**\n * An error returned by the Firebase Functions client SDK.\n *\n * See {@link FunctionsErrorCode} for full documentation of codes.\n *\n * @public\n */\nexport class FunctionsError extends FirebaseError {\n /**\n * Constructs a new instance of the `FunctionsError` class.\n */\n constructor(\n /**\n * A standard error code that will be returned to the client. This also\n * determines the HTTP status code of the response, as defined in code.proto.\n */\n code: FunctionsErrorCode,\n message?: string,\n /**\n * Additional details to be converted to JSON and included in the error response.\n */\n readonly details?: unknown\n ) {\n super(`${FUNCTIONS_TYPE}/${code}`, message || '');\n\n // Since the FirebaseError constructor sets the prototype of `this` to FirebaseError.prototype,\n // we also have to do it in all subclasses to allow for correct `instanceof` checks.\n Object.setPrototypeOf(this, FunctionsError.prototype);\n }\n}\n\n/**\n * Takes an HTTP status code and returns the corresponding ErrorCode.\n * This is the standard HTTP status code -> error mapping defined in:\n * https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto\n *\n * @param status An HTTP status code.\n * @return The corresponding ErrorCode, or ErrorCode.UNKNOWN if none.\n */\nfunction codeForHTTPStatus(status: number): FunctionsErrorCode {\n // Make sure any successful status is OK.\n if (status >= 200 && status < 300) {\n return 'ok';\n }\n switch (status) {\n case 0:\n // This can happen if the server returns 500.\n return 'internal';\n case 400:\n return 'invalid-argument';\n case 401:\n return 'unauthenticated';\n case 403:\n return 'permission-denied';\n case 404:\n return 'not-found';\n case 409:\n return 'aborted';\n case 429:\n return 'resource-exhausted';\n case 499:\n return 'cancelled';\n case 500:\n return 'internal';\n case 501:\n return 'unimplemented';\n case 503:\n return 'unavailable';\n case 504:\n return 'deadline-exceeded';\n default: // ignore\n }\n return 'unknown';\n}\n\n/**\n * Takes an HTTP response and returns the corresponding Error, if any.\n */\nexport function _errorForResponse(\n status: number,\n bodyJSON: HttpResponseBody | null\n): Error | null {\n let code = codeForHTTPStatus(status);\n\n // Start with reasonable defaults from the status code.\n let description: string = code;\n\n let details: unknown = undefined;\n\n // Then look through the body for explicit details.\n try {\n const errorJSON = bodyJSON && bodyJSON.error;\n if (errorJSON) {\n const status = errorJSON.status;\n if (typeof status === 'string') {\n if (!errorCodeMap[status]) {\n // They must've included an unknown error code in the body.\n return new FunctionsError('internal', 'internal');\n }\n code = errorCodeMap[status];\n\n // TODO(klimt): Add better default descriptions for error enums.\n // The default description needs to be updated for the new code.\n description = status;\n }\n\n const message = errorJSON.message;\n if (typeof message === 'string') {\n description = message;\n }\n\n details = errorJSON.details;\n if (details !== undefined) {\n details = decode(details);\n }\n }\n } catch (e) {\n // If we couldn't parse explicit error data, that's fine.\n }\n\n if (code === 'ok') {\n // Technically, there's an edge case where a developer could explicitly\n // return an error code of OK, and we will treat it as success, but that\n // seems reasonable.\n return null;\n }\n\n return new FunctionsError(code, description, details);\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Provider } from '@firebase/component';\nimport { _isFirebaseServerApp, FirebaseApp } from '@firebase/app';\nimport {\n AppCheckInternalComponentName,\n FirebaseAppCheckInternal\n} from '@firebase/app-check-interop-types';\nimport {\n MessagingInternal,\n MessagingInternalComponentName\n} from '@firebase/messaging-interop-types';\nimport {\n FirebaseAuthInternal,\n FirebaseAuthInternalName\n} from '@firebase/auth-interop-types';\n\n/**\n * The metadata that should be supplied with function calls.\n * @internal\n */\nexport interface Context {\n authToken?: string;\n messagingToken?: string;\n appCheckToken: string | null;\n}\n\n/**\n * Helper class to get metadata that should be included with a function call.\n * @internal\n */\nexport class ContextProvider {\n private auth: FirebaseAuthInternal | null = null;\n private messaging: MessagingInternal | null = null;\n private appCheck: FirebaseAppCheckInternal | null = null;\n private serverAppAppCheckToken: string | null = null;\n constructor(\n readonly app: FirebaseApp,\n authProvider: Provider<FirebaseAuthInternalName>,\n messagingProvider: Provider<MessagingInternalComponentName>,\n appCheckProvider: Provider<AppCheckInternalComponentName>\n ) {\n if (_isFirebaseServerApp(app) && app.settings.appCheckToken) {\n this.serverAppAppCheckToken = app.settings.appCheckToken;\n }\n this.auth = authProvider.getImmediate({ optional: true });\n this.messaging = messagingProvider.getImmediate({\n optional: true\n });\n\n if (!this.auth) {\n authProvider.get().then(\n auth => (this.auth = auth),\n () => {\n /* get() never rejects */\n }\n );\n }\n\n if (!this.messaging) {\n messagingProvider.get().then(\n messaging => (this.messaging = messaging),\n () => {\n /* get() never rejects */\n }\n );\n }\n\n if (!this.appCheck) {\n appCheckProvider?.get().then(\n appCheck => (this.appCheck = appCheck),\n () => {\n /* get() never rejects */\n }\n );\n }\n }\n\n async getAuthToken(): Promise<string | undefined> {\n if (!this.auth) {\n return undefined;\n }\n\n try {\n const token = await this.auth.getToken();\n return token?.accessToken;\n } catch (e) {\n // If there's any error when trying to get the auth token, leave it off.\n return undefined;\n }\n }\n\n async getMessagingToken(): Promise<string | undefined> {\n if (\n !this.messaging ||\n !('Notification' in self) ||\n Notification.permission !== 'granted'\n ) {\n return undefined;\n }\n\n try {\n return await this.messaging.getToken();\n } catch (e) {\n // We don't warn on this, because it usually means messaging isn't set up.\n // console.warn('Failed to retrieve instance id token.', e);\n\n // If there's any error when trying to get the token, leave it off.\n return undefined;\n }\n }\n\n async getAppCheckToken(\n limitedUseAppCheckTokens?: boolean\n ): Promise<string | null> {\n if (this.serverAppAppCheckToken) {\n return this.serverAppAppCheckToken;\n }\n if (this.appCheck) {\n const result = limitedUseAppCheckTokens\n ? await this.appCheck.getLimitedUseToken()\n : await this.appCheck.getToken();\n if (result.error) {\n // Do not send the App Check header to the functions endpoint if\n // there was an error from the App Check exchange endpoint. The App\n // Check SDK will already have logged the error to console.\n return null;\n }\n return result.token;\n }\n return null;\n }\n\n async getContext(limitedUseAppCheckTokens?: boolean): Promise<Context> {\n const authToken = await this.getAuthToken();\n const messagingToken = await this.getMessagingToken();\n const appCheckToken = await this.getAppCheckToken(limitedUseAppCheckTokens);\n return { authToken, messagingToken, appCheckToken };\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FirebaseApp, _FirebaseService } from '@firebase/app';\nimport {\n HttpsCallable,\n HttpsCallableResult,\n HttpsCallableStreamResult,\n HttpsCallableOptions,\n HttpsCallableStreamOptions\n} from './public-types';\nimport { _errorForResponse, FunctionsError } from './error';\nimport { ContextProvider } from './context';\nimport { encode, decode } from './serializer';\nimport { Provider } from '@firebase/component';\nimport { FirebaseAuthInternalName } from '@firebase/auth-interop-types';\nimport { MessagingInternalComponentName } from '@firebase/messaging-interop-types';\nimport { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';\nimport {\n isCloudWorkstation,\n pingServer,\n updateEmulatorBanner\n} from '@firebase/util';\n\nexport const DEFAULT_REGION = 'us-central1';\n\nconst responseLineRE = /^data: (.*?)(?:\\n|$)/;\n\n/**\n * The response to an http request.\n */\ninterface HttpResponse {\n status: number;\n json: HttpResponseBody | null;\n}\n/**\n * Describes the shape of the HttpResponse body.\n * It makes functions that would otherwise take {} able to access the\n * possible elements in the body more easily\n */\nexport interface HttpResponseBody {\n data?: unknown;\n result?: unknown;\n error?: {\n message?: unknown;\n status?: unknown;\n details?: unknown;\n };\n}\n\ninterface CancellablePromise<T> {\n promise: Promise<T>;\n cancel: () => void;\n}\n\n/**\n * Returns a Promise that will be rejected after the given duration.\n * The error will be of type FunctionsError.\n *\n * @param millis Number of milliseconds to wait before rejecting.\n */\nfunction failAfter(millis: number): CancellablePromise<never> {\n // Node timers and browser timers are fundamentally incompatible, but we\n // don't care about the value here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let timer: any | null = null;\n return {\n promise: new Promise((_, reject) => {\n timer = setTimeout(() => {\n reject(new FunctionsError('deadline-exceeded', 'deadline-exceeded'));\n }, millis);\n }),\n cancel: () => {\n if (timer) {\n clearTimeout(timer);\n }\n }\n };\n}\n\n/**\n * The main class for the Firebase Functions SDK.\n * @internal\n */\nexport class FunctionsService implements _FirebaseService {\n readonly contextProvider: ContextProvider;\n emulatorOrigin: string | null = null;\n cancelAllRequests: Promise<void>;\n deleteService!: () => Promise<void>;\n region: string;\n customDomain: string | null;\n\n /**\n * Creates a new Functions service for the given app.\n * @param app - The FirebaseApp to use.\n */\n constructor(\n readonly app: FirebaseApp,\n authProvider: Provider<FirebaseAuthInternalName>,\n messagingProvider: Provider<MessagingInternalComponentName>,\n appCheckProvider: Provider<AppCheckInternalComponentName>,\n regionOrCustomDomain: string = DEFAULT_REGION,\n readonly fetchImpl: typeof fetch = (...args) => fetch(...args)\n ) {\n this.contextProvider = new ContextProvider(\n app,\n authProvider,\n messagingProvider,\n appCheckProvider\n );\n // Cancels all ongoing requests when resolved.\n this.cancelAllRequests = new Promise(resolve => {\n this.deleteService = () => {\n return Promise.resolve(resolve());\n };\n });\n\n // Resolve the region or custom domain overload by attempting to parse it.\n try {\n const url = new URL(regionOrCustomDomain);\n this.customDomain =\n url.origin + (url.pathname === '/' ? '' : url.pathname);\n this.region = DEFAULT_REGION;\n } catch (e) {\n this.customDomain = null;\n this.region = regionOrCustomDomain;\n }\n }\n\n _delete(): Promise<void> {\n return this.deleteService();\n }\n\n /**\n * Returns the URL for a callable with the given name.\n * @param name - The name of the callable.\n * @internal\n */\n _url(name: string): string {\n const projectId = this.app.options.projectId;\n if (this.emulatorOrigin !== null) {\n const origin = this.emulatorOrigin;\n return `${origin}/${projectId}/${this.region}/${name}`;\n }\n\n if (this.customDomain !== null) {\n return `${this.customDomain}/${name}`;\n }\n\n return `https://${this.region}-${projectId}.cloudfunctions.net/${name}`;\n }\n}\n\n/**\n * Modify this instance to communicate with the Cloud Functions emulator.\n *\n * Note: this must be called before this instance has been used to do any operations.\n *\n * @param host The emulator host (ex: localhost)\n * @param port The emulator port (ex: 5001)\n * @public\n */\nexport function connectFunctionsEmulator(\n functionsInstance: FunctionsService,\n host: string,\n port: number\n): void {\n const useSsl = isCloudWorkstation(host);\n functionsInstance.emulatorOrigin = `http${\n useSsl ? 's' : ''\n }://${host}:${port}`;\n // Workaround to get cookies in Firebase Studio\n if (useSsl) {\n void pingServer(functionsInstance.emulatorOrigin + '/backends');\n updateEmulatorBanner('Functions', true);\n }\n}\n\n/**\n * Returns a reference to the callable https trigger with the given name.\n * @param name - The name of the trigger.\n * @public\n */\nexport function httpsCallable<RequestData, ResponseData, StreamData = unknown>(\n functionsInstance: FunctionsService,\n name: string,\n options?: HttpsCallableOptions\n): HttpsCallable<RequestData, ResponseData, StreamData> {\n const callable = (\n data?: RequestData | null\n ): Promise<HttpsCallableResult> => {\n return call(functionsInstance, name, data, options || {});\n };\n\n callable.stream = (\n data?: RequestData | null,\n options?: HttpsCallableStreamOptions\n ) => {\n return stream(functionsInstance, name, data, options);\n };\n\n return callable as HttpsCallable<RequestData, ResponseData, StreamData>;\n}\n\n/**\n * Returns a reference to the callable https trigger with the given url.\n * @param url - The url of the trigger.\n * @public\n */\nexport function httpsCallableFromURL<\n RequestData,\n ResponseData,\n StreamData = unknown\n>(\n functionsInstance: FunctionsService,\n url: string,\n options?: HttpsCallableOptions\n): HttpsCallable<RequestData, ResponseData, StreamData> {\n const callable = (\n data?: RequestData | null\n ): Promise<HttpsCallableResult> => {\n return callAtURL(functionsInstance, url, data, options || {});\n };\n\n callable.stream = (\n data?: RequestData | null,\n options?: HttpsCallableStreamOptions\n ) => {\n return streamAtURL(functionsInstance, url, data, options || {});\n };\n return callable as HttpsCallable<RequestData, ResponseData, StreamData>;\n}\n\nfunction getCredentials(\n functionsInstance: FunctionsService\n): 'include' | undefined {\n return functionsInstance.emulatorOrigin &&\n isCloudWorkstation(functionsInstance.emulatorOrigin)\n ? 'include'\n : undefined;\n}\n\n/**\n * Does an HTTP POST and returns the completed response.\n * @param url The url to post to.\n * @param body The JSON body of the post.\n * @param headers The HTTP headers to include in the request.\n * @param functionsInstance functions instance that is calling postJSON\n * @return A Promise that will succeed when the request finishes.\n */\nasync function postJSON(\n url: string,\n body: unknown,\n headers: { [key: string]: string },\n fetchImpl: typeof fetch,\n functionsInstance: FunctionsService\n): Promise<HttpResponse> {\n headers['Content-Type'] = 'application/json';\n\n let response: Response;\n try {\n response = await fetchImpl(url, {\n method: 'POST',\n body: JSON.stringify(body),\n headers,\n credentials: getCredentials(functionsInstance)\n });\n } catch (e) {\n // This could be an unhandled error on the backend, or it could be a\n // network error. There's no way to know, since an unhandled error on the\n // backend will fail to set the proper CORS header, and thus will be\n // treated as a network error by fetch.\n return {\n status: 0,\n json: null\n };\n }\n let json: HttpResponseBody | null = null;\n try {\n json = await response.json();\n } catch (e) {\n // If we fail to parse JSON, it will fail the same as an empty body.\n }\n return {\n status: response.status,\n json\n };\n}\n\n/**\n * Creates authorization headers for Firebase Functions requests.\n * @param functionsInstance The Firebase Functions service instance.\n * @param options Options for the callable function, including AppCheck token settings.\n * @return A Promise that resolves a headers map to include in outgoing fetch request.\n */\nasync function makeAuthHeaders(\n functionsInstance: FunctionsService,\n options: HttpsCallableOptions\n): Promise<Record<string, string>> {\n const headers: Record<string, string> = {};\n const context = await functionsInstance.contextProvider.getContext(\n options.limitedUseAppCheckTokens\n );\n if (context.authToken) {\n headers['Authorization'] = 'Bearer ' + context.authToken;\n }\n if (context.messagingToken) {\n headers['Firebase-Instance-ID-Token'] = context.messagingToken;\n }\n if (context.appCheckToken !== null) {\n headers['X-Firebase-AppCheck'] = context.appCheckToken;\n }\n return headers;\n}\n\n/**\n * Calls a callable function asynchronously and returns the result.\n * @param name The name of the callable trigger.\n * @param data The data to pass as params to the function.\n */\nfunction call(\n functionsInstance: FunctionsService,\n name: string,\n data: unknown,\n options: HttpsCallableOptions\n): Promise<HttpsCallableResult> {\n const url = functionsInstance._url(name);\n return callAtURL(functionsInstance, url, data, options);\n}\n\n/**\n * Calls a callable function asynchronously and returns the result.\n * @param url The url of the callable trigger.\n * @param data The data to pass as params to the function.\n */\nasync function callAtURL(\n functionsInstance: FunctionsService,\n url: string,\n data: unknown,\n options: HttpsCallableOptions\n): Promise<HttpsCallableResult> {\n // Encode any special types, such as dates, in the input data.\n data = encode(data);\n const body = { data };\n\n // Add a header for the authToken.\n const headers = await makeAuthHeaders(functionsInstance, options);\n\n // Default timeout to 70s, but let the options override it.\n const timeout = options.timeout || 70000;\n\n const failAfterHandle = failAfter(timeout);\n const response = await Promise.race([\n postJSON(\n url,\n body,\n headers,\n functionsInstance.fetchImpl,\n functionsInstance\n ),\n failAfterHandle.promise,\n functionsInstance.cancelAllRequests\n ]);\n\n // Always clear the failAfter timeout\n failAfterHandle.cancel();\n\n // If service was deleted, interrupted response throws an error.\n if (!response) {\n throw new FunctionsError(\n 'cancelled',\n 'Firebase Functions instance was deleted.'\n );\n }\n\n // Check for an error status, regardless of http status.\n const error = _errorForResponse(response.status, response.json);\n if (error) {\n throw error;\n }\n\n if (!response.json) {\n throw new FunctionsError('internal', 'Response is not valid JSON object.');\n }\n\n let responseData = response.json.data;\n // TODO(klimt): For right now, allow \"result\" instead of \"data\", for\n // backwards compatibility.\n if (typeof responseData === 'undefined') {\n responseData = response.json.result;\n }\n if (typeof responseData === 'undefined') {\n // Consider the response malformed.\n throw new FunctionsError('internal', 'Response is missing data field.');\n }\n\n // Decode any special types, such as dates, in the returned data.\n const decodedData = decode(responseData);\n\n return { data: decodedData };\n}\n\n/**\n * Calls a callable function asynchronously and returns a streaming result.\n * @param name The name of the callable trigger.\n * @param data The data to pass as params to the function.\n * @param options Streaming request options.\n */\nfunction stream(\n functionsInstance: FunctionsService,\n name: string,\n data: unknown,\n options?: HttpsCallableStreamOptions\n): Promise<HttpsCallableStreamResult> {\n const url = functionsInstance._url(name);\n return streamAtURL(functionsInstance, url, data, options || {});\n}\n\n/**\n * Calls a callable function asynchronously and return a streaming result.\n * @param url The url of the callable trigger.\n * @param data The data to pass as params to the function.\n * @param options Streaming request options.\n */\nasync function streamAtURL(\n functionsInstance: FunctionsService,\n url: string,\n data: unknown,\n options: HttpsCallableStreamOptions\n): Promise<HttpsCallableStreamResult> {\n // Encode any special types, such as dates, in the input data.\n data = encode(data);\n const body = { data };\n //\n // Add a header for the authToken.\n const headers = await makeAuthHeaders(functionsInstance, options);\n headers['Content-Type'] = 'application/json';\n headers['Accept'] = 'text/event-stream';\n\n let response: Response;\n try {\n response = await functionsInstance.fetchImpl(url, {\n method: 'POST',\n body: JSON.stringify(body),\n headers,\n signal: options?.signal,\n credentials: getCredentials(functionsInstance)\n });\n } catch (e) {\n if (e instanceof Error && e.name === 'AbortError') {\n const error = new FunctionsError('cancelled', 'Request was cancelled.');\n return {\n data: Promise.reject(error),\n stream: {\n [Symbol.asyncIterator]() {\n return {\n next() {\n return Promise.reject(error);\n }\n };\n }\n }\n };\n }\n // This could be an unhandled error on the backend, or it could be a\n // network error. There's no way to know, since an unhandled error on the\n // backend will fail to set the proper CORS header, and thus will be\n // treated as a network error by fetch.\n const error = _errorForResponse(0, null);\n return {\n data: Promise.reject(error),\n // Return an empty async iterator\n stream: {\n [Symbol.asyncIterator]() {\n return {\n next() {\n return Promise.reject(error);\n }\n };\n }\n }\n };\n }\n let resultResolver: (value: unknown) => void;\n let resultRejecter: (reason: unknown) => void;\n const resultPromise = new Promise<unknown>((resolve, reject) => {\n resultResolver = resolve;\n resultRejecter = reject;\n });\n options?.signal?.addEventListener('abort', () => {\n const error = new FunctionsError('cancelled', 'Request was cancelled.');\n resultRejecter(error);\n });\n const reader = response.body!.getReader();\n const rstream = createResponseStream(\n reader,\n resultResolver!,\n resultRejecter!,\n options?.signal\n );\n return {\n stream: {\n [Symbol.asyncIterator]() {\n const rreader = rstream.getReader();\n return {\n async next() {\n const { value, done } = await rreader.read();\n return { value: value as unknown, done };\n },\n async return() {\n await rreader.cancel();\n return { done: true, value: undefined };\n }\n };\n }\n },\n data: resultPromise\n };\n}\n\n/**\n * Creates a ReadableStream that processes a streaming response from a streaming\n * callable function that returns data in server-sent event format.\n *\n * @param reader The underlying reader providing raw response data\n * @param resultResolver Callback to resolve the final result when received\n * @param resultRejecter Callback to reject with an error if encountered\n * @param signal Optional AbortSignal to cancel the stream processing\n * @returns A ReadableStream that emits decoded messages from the response\n *\n * The returned ReadableStream:\n * 1. Emits individual messages when \"message\" data is received\n * 2. Resolves with the final result when a \"result\" message is received\n * 3. Rejects with an error if an \"error\" message is received\n */\nfunction createResponseStream(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n resultResolver: (value: unknown) => void,\n resultRejecter: (reason: unknown) => void,\n signal?: AbortSignal\n): ReadableStream<unknown> {\n const processLine = (\n line: string,\n controller: ReadableStreamDefaultController\n ): void => {\n const match = line.match(responseLineRE);\n // ignore all other lines (newline, comments, etc.)\n if (!match) {\n return;\n }\n const data = match[1];\n try {\n const jsonData = JSON.parse(data);\n if ('result' in jsonData) {\n resultResolver(decode(jsonData.result));\n return;\n }\n if ('message' in jsonData) {\n controller.enqueue(decode(jsonData.message));\n return;\n }\n if ('error' in jsonData) {\n const error = _errorForResponse(0, jsonData);\n controller.error(error);\n resultRejecter(error);\n return;\n }\n } catch (error) {\n if (error instanceof FunctionsError) {\n controller.error(error);\n resultRejecter(error);\n return;\n }\n // ignore other parsing errors\n }\n };\n\n const decoder = new TextDecoder();\n return new ReadableStream({\n start(controller) {\n let currentText = '';\n return pump();\n async function pump(): Promise<void> {\n if (signal?.aborted) {\n const error = new FunctionsError(\n 'cancelled',\n 'Request was cancelled'\n );\n controller.error(error);\n resultRejecter(error);\n return Promise.resolve();\n }\n try {\n const { value, done } = await reader.read();\n if (done) {\n if (currentText.trim()) {\n processLine(currentText.trim(), controller);\n }\n controller.close();\n return;\n }\n if (signal?.aborted) {\n const error = new FunctionsError(\n 'cancelled',\n 'Request was cancelled'\n );\n controller.error(error);\n resultRejecter(error);\n await reader.cancel();\n return;\n }\n currentText += decoder.decode(value, { stream: true });\n const lines = currentText.split('\\n');\n currentText = lines.pop() || '';\n for (const line of lines) {\n if (line.trim()) {\n processLine(line.trim(), controller);\n }\n }\n return pump();\n } catch (error) {\n const functionsError =\n error instanceof FunctionsError\n ? error\n : _errorForResponse(0, null);\n controller.error(functionsError);\n resultRejecter(functionsError);\n }\n }\n },\n cancel() {\n return reader.cancel();\n }\n });\n}\n","/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { _registerComponent, registerVersion } from '@firebase/app';\nimport { FunctionsService } from './service';\nimport {\n Component,\n ComponentType,\n ComponentContainer,\n InstanceFactory\n} from '@firebase/component';\nimport { FUNCTIONS_TYPE } from './constants';\nimport { FirebaseAuthInternalName } from '@firebase/auth-interop-types';\nimport { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';\nimport { MessagingInternalComponentName } from '@firebase/messaging-interop-types';\nimport { name, version } from '../package.json';\n\nconst AUTH_INTERNAL_NAME: FirebaseAuthInternalName = 'auth-internal';\nconst APP_CHECK_INTERNAL_NAME: AppCheckInternalComponentName =\n 'app-check-internal';\nconst MESSAGING_INTERNAL_NAME: MessagingInternalComponentName =\n 'messaging-internal';\n\nexport function registerFunctions(variant?: string): void {\n const factory: InstanceFactory<'functions'> = (\n container: ComponentContainer,\n { instanceIdentifier: regionOrCustomDomain }\n ) => {\n // Dependencies\n const app = container.getProvider('app').getImmediate();\n const authProvider = container.getProvider(AUTH_INTERNAL_NAME);\n const messagingProvider = container.getProvider(MESSAGING_INTERNAL_NAME);\n const appCheckProvider = container.getProvider(APP_CHECK_INTERNAL_NAME);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return new FunctionsService(\n app,\n authProvider,\n messagingProvider,\n appCheckProvider,\n regionOrCustomDomain\n );\n };\n\n _registerComponent(\n new Component(\n FUNCTIONS_TYPE,\n factory,\n ComponentType.PUBLIC\n ).setMultipleInstances(true)\n );\n\n registerVersion(name, version, variant);\n // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation\n registerVersion(name, version, '__BUILD_TARGET__');\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { _getProvider, FirebaseApp, getApp } from '@firebase/app';\nimport { FUNCTIONS_TYPE } from './constants';\n\nimport { Provider } from '@firebase/component';\nimport { Functions, HttpsCallableOptions, HttpsCallable } from './public-types';\nimport {\n FunctionsService,\n DEFAULT_REGION,\n connectFunctionsEmulator as _connectFunctionsEmulator,\n httpsCallable as _httpsCallable,\n httpsCallableFromURL as _httpsCallableFromURL\n} from './service';\nimport {\n getModularInstance,\n getDefaultEmulatorHostnameAndPort\n} from '@firebase/util';\n\nexport { FunctionsError } from './error';\nexport * from './public-types';\n\n/**\n * Returns a {@link Functions} instance for the given app.\n * @param app - The {@link @firebase/app#FirebaseApp} to use.\n * @param regionOrCustomDomain - one of:\n * a) The region the callable functions are located in (ex: us-central1)\n * b) A custom domain hosting the callable functions (ex: https://mydomain.com)\n * @public\n */\nexport function getFunctions(\n app: FirebaseApp = getApp(),\n regionOrCustomDomain: string = DEFAULT_REGION\n): Functions {\n // Dependencies\n const functionsProvider: Provider<'functions'> = _getProvider(\n getModularInstance(app),\n FUNCTIONS_TYPE\n );\n const functionsInstance = functionsProvider.getImmediate({\n identifier: regionOrCustomDomain\n });\n const emulator = getDefaultEmulatorHostnameAndPort('functions');\n if (emulator) {\n connectFunctionsEmulator(functionsInstance, ...emulator);\n }\n return functionsInstance;\n}\n\n/**\n * Modify this instance to communicate with the Cloud Functions emulator.\n *\n * Note: this must be called before this instance has been used to do any operations.\n *\n * @param host - The emulator host (ex: localhost)\n * @param port - The emulator port (ex: 5001)\n * @public\n */\nexport function connectFunctionsEmulator(\n functionsInstance: Functions,\n host: string,\n port: number\n): void {\n _connectFunctionsEmulator(\n getModularInstance<FunctionsService>(functionsInstance as FunctionsService),\n host,\n port\n );\n}\n\n/**\n * Returns a reference to the callable HTTPS trigger with the given name.\n * @param name - The name of the trigger.\n * @public\n */\nexport function httpsCallable<\n RequestData = unknown,\n ResponseData = unknown,\n StreamData = unknown\n>(\n functionsInstance: Functions,\n name: string,\n options?: HttpsCallableOptions\n): HttpsCallable<RequestData, ResponseData, StreamData> {\n return _httpsCallable<RequestData, ResponseData, StreamData>(\n getModularInstance<FunctionsService>(functionsInstance as FunctionsService),\n name,\n options\n );\n}\n\n/**\n * Returns a reference to the callable HTTPS trigger with the specified url.\n * @param url - The url of the trigger.\n * @public\n */\nexport function httpsCallableFromURL<\n RequestData = unknown,\n ResponseData = unknown,\n StreamData = unknown\n>(\n functionsInstance: Functions,\n url: string,\n options?: HttpsCallableOptions\n): HttpsCallable<RequestData, ResponseData, StreamData> {\n return _httpsCallableFromURL<RequestData, ResponseData, StreamData>(\n getModularInstance<FunctionsService>(functionsInstance as FunctionsService),\n url,\n options\n );\n}\n","/**\n * Cloud Functions for Firebase\n *\n * @packageDocumentation\n */\n\n/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { registerFunctions } from './config';\n\nexport * from './api';\nexport * from './public-types';\n\nregisterFunctions();\n"],"names":["FirebaseError","app","_isFirebaseServerApp","connectFunctionsEmulator","isCloudWorkstation","pingServer","updateEmulatorBanner","httpsCallable","httpsCallableFromURL","_registerComponent","Component","registerVersion","getApp","_getProvider","getModularInstance","getDefaultEmulatorHostnameAndPort","_connectFunctionsEmulator","_httpsCallable","_httpsCallableFromURL"],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AACH,MAAM,SAAS,GAAG,gDAAgD,CAAC;AACnE,MAAM,kBAAkB,GAAG,iDAAiD,CAAC;AAE7E,SAAS,SAAS;AAChB;AACA;AACA,CAAyB,EACzB,CAA6B,EAAA;IAE7B,MAAM,MAAM,GAA+B,EAAE,CAAC;AAC9C,IAAA,KAAK,MAAM,GAAG,IAAI,CAAC,EAAE;AACnB,QAAA,IAAI,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;YACzB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;SACzB;KACF;AACD,IAAA,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;AAKG;AACG,SAAU,MAAM,CAAC,IAAa,EAAA;AAClC,IAAA,IAAI,IAAI,IAAI,IAAI,EAAE;AAChB,QAAA,OAAO,IAAI,CAAC;KACb;AACD,IAAA,IAAI,IAAI,YAAY,MAAM,EAAE;AAC1B,QAAA,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;KACvB;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;;;AAG9C,QAAA,OAAO,IAAI,CAAC;KACb;IACD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE;AACnC,QAAA,OAAO,IAAI,CAAC;KACb;AACD,IAAA,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,iBAAiB,EAAE;AAC9D,QAAA,OAAO,IAAI,CAAC;KACb;AACD,IAAA,IAAI,IAAI,YAAY,IAAI,EAAE;A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ACa,aAAa,CAK3B,iBAA4B,EAC5B,IAAY,EACZ,OAA8B,EAAA;IAE9B,OAAOG,eAAc,CACnBH,uBAAkB,CAAmB,iBAAqC,CAAC,EAC3E,IAAI,EACJ,OAAO,CACR,CAAC;AACJ,CAAC;AAED;;;;AAIG;SACa,oBAAoB,CAKlC,iBAA4B,EAC5B,GAAW,EACX,OAA8B,EAAA;IAE9B,OAAOI,sBAAqB,CAC1BJ,uBAAkB,CAAmB,iBAAqC,CAAC,EAC3E,GAAG,EACH,OAAO,CACR,CAAC;AACJ;;AC7HA;;;;AAIG;AAuBH,iBAAiB,EAAE;;;;;;;;"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { FirebaseApp } from '@firebase/app';
18
+ import { Functions, HttpsCallableOptions, HttpsCallable } from './public-types';
19
+ export { FunctionsError } from './error';
20
+ export * from './public-types';
21
+ /**
22
+ * Returns a {@link Functions} instance for the given app.
23
+ * @param app - The {@link @firebase/app#FirebaseApp} to use.
24
+ * @param regionOrCustomDomain - one of:
25
+ * a) The region the callable functions are located in (ex: us-central1)
26
+ * b) A custom domain hosting the callable functions (ex: https://mydomain.com)
27
+ * @public
28
+ */
29
+ export declare function getFunctions(app?: FirebaseApp, regionOrCustomDomain?: string): Functions;
30
+ /**
31
+ * Modify this instance to communicate with the Cloud Functions emulator.
32
+ *
33
+ * Note: this must be called before this instance has been used to do any operations.
34
+ *
35
+ * @param host - The emulator host (ex: localhost)
36
+ * @param port - The emulator port (ex: 5001)
37
+ * @public
38
+ */
39
+ export declare function connectFunctionsEmulator(functionsInstance: Functions, host: string, port: number): void;
40
+ /**
41
+ * Returns a reference to the callable HTTPS trigger with the given name.
42
+ * @param name - The name of the trigger.
43
+ * @public
44
+ */
45
+ export declare function httpsCallable<RequestData = unknown, ResponseData = unknown, StreamData = unknown>(functionsInstance: Functions, name: string, options?: HttpsCallableOptions): HttpsCallable<RequestData, ResponseData, StreamData>;
46
+ /**
47
+ * Returns a reference to the callable HTTPS trigger with the specified url.
48
+ * @param url - The url of the trigger.
49
+ * @public
50
+ */
51
+ export declare function httpsCallableFromURL<RequestData = unknown, ResponseData = unknown, StreamData = unknown>(functionsInstance: Functions, url: string, options?: HttpsCallableOptions): HttpsCallable<RequestData, ResponseData, StreamData>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export declare function registerFunctions(variant?: string): void;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Type constant for Firebase Functions.
19
+ */
20
+ export declare const FUNCTIONS_TYPE = "functions";
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Provider } from '@firebase/component';
18
+ import { FirebaseApp } from '@firebase/app';
19
+ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
20
+ import { MessagingInternalComponentName } from '@firebase/messaging-interop-types';
21
+ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
22
+ /**
23
+ * The metadata that should be supplied with function calls.
24
+ * @internal
25
+ */
26
+ export interface Context {
27
+ authToken?: string;
28
+ messagingToken?: string;
29
+ appCheckToken: string | null;
30
+ }
31
+ /**
32
+ * Helper class to get metadata that should be included with a function call.
33
+ * @internal
34
+ */
35
+ export declare class ContextProvider {
36
+ readonly app: FirebaseApp;
37
+ private auth;
38
+ private messaging;
39
+ private appCheck;
40
+ private serverAppAppCheckToken;
41
+ constructor(app: FirebaseApp, authProvider: Provider<FirebaseAuthInternalName>, messagingProvider: Provider<MessagingInternalComponentName>, appCheckProvider: Provider<AppCheckInternalComponentName>);
42
+ getAuthToken(): Promise<string | undefined>;
43
+ getMessagingToken(): Promise<string | undefined>;
44
+ getAppCheckToken(limitedUseAppCheckTokens?: boolean): Promise<string | null>;
45
+ getContext(limitedUseAppCheckTokens?: boolean): Promise<Context>;
46
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { FunctionsErrorCodeCore as FunctionsErrorCode } from './public-types';
18
+ import { HttpResponseBody } from './service';
19
+ import { FirebaseError } from '@firebase/util';
20
+ /**
21
+ * An error returned by the Firebase Functions client SDK.
22
+ *
23
+ * See {@link FunctionsErrorCode} for full documentation of codes.
24
+ *
25
+ * @public
26
+ */
27
+ export declare class FunctionsError extends FirebaseError {
28
+ /**
29
+ * Additional details to be converted to JSON and included in the error response.
30
+ */
31
+ readonly details?: unknown;
32
+ /**
33
+ * Constructs a new instance of the `FunctionsError` class.
34
+ */
35
+ constructor(
36
+ /**
37
+ * A standard error code that will be returned to the client. This also
38
+ * determines the HTTP status code of the response, as defined in code.proto.
39
+ */
40
+ code: FunctionsErrorCode, message?: string,
41
+ /**
42
+ * Additional details to be converted to JSON and included in the error response.
43
+ */
44
+ details?: unknown);
45
+ }
46
+ /**
47
+ * Takes an HTTP response and returns the corresponding Error, if any.
48
+ */
49
+ export declare function _errorForResponse(status: number, bodyJSON: HttpResponseBody | null): Error | null;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Cloud Functions for Firebase
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export * from './api';
7
+ export * from './public-types';
@@ -0,0 +1,150 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2018 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { FirebaseApp } from '@firebase/app';
18
+ /**
19
+ * An `HttpsCallableResult` wraps a single result from a function call.
20
+ * @public
21
+ */
22
+ export interface HttpsCallableResult<ResponseData = unknown> {
23
+ /**
24
+ * Data returned from callable function.
25
+ */
26
+ readonly data: ResponseData;
27
+ }
28
+ /**
29
+ * An `HttpsCallableStreamResult` wraps a single streaming result from a function call.
30
+ * @public
31
+ */
32
+ export interface HttpsCallableStreamResult<ResponseData = unknown, StreamData = unknown> {
33
+ readonly data: Promise<ResponseData>;
34
+ readonly stream: AsyncIterable<StreamData>;
35
+ }
36
+ /**
37
+ * A reference to a "callable" HTTP trigger in Cloud Functions.
38
+ * @param data - Data to be passed to callable function.
39
+ * @public
40
+ */
41
+ export interface HttpsCallable<RequestData = unknown, ResponseData = unknown, StreamData = unknown> {
42
+ (data?: RequestData | null): Promise<HttpsCallableResult<ResponseData>>;
43
+ stream: (data?: RequestData | null, options?: HttpsCallableStreamOptions) => Promise<HttpsCallableStreamResult<ResponseData, StreamData>>;
44
+ }
45
+ /**
46
+ * An interface for metadata about how calls should be executed.
47
+ * @public
48
+ */
49
+ export interface HttpsCallableOptions {
50
+ /**
51
+ * Time in milliseconds after which to cancel if there is no response.
52
+ * Default is 70000.
53
+ */
54
+ timeout?: number;
55
+ /**
56
+ * If set to true, uses a limited-use App Check token for callable function requests from this
57
+ * instance of {@link Functions}. You must use limited-use tokens to call functions with
58
+ * replay protection enabled. By default, this is false.
59
+ */
60
+ limitedUseAppCheckTokens?: boolean;
61
+ }
62
+ /**
63
+ * An interface for metadata about how a stream call should be executed.
64
+ * @public
65
+ */
66
+ export interface HttpsCallableStreamOptions {
67
+ /**
68
+ * An `AbortSignal` that can be used to cancel the streaming response. When the signal is aborted,
69
+ * the underlying HTTP connection will be terminated.
70
+ */
71
+ signal?: AbortSignal;
72
+ /**
73
+ * If set to true, uses a limited-use App Check token for callable function requests from this
74
+ * instance of {@link Functions}. You must use limited-use tokens to call functions with
75
+ * replay protection enabled. By default, this is false.
76
+ */
77
+ limitedUseAppCheckTokens?: boolean;
78
+ }
79
+ /**
80
+ * A `Functions` instance.
81
+ * @public
82
+ */
83
+ export interface Functions {
84
+ /**
85
+ * The {@link @firebase/app#FirebaseApp} this `Functions` instance is associated with.
86
+ */
87
+ app: FirebaseApp;
88
+ /**
89
+ * The region the callable Cloud Functions are located in.
90
+ * Default is `us-central-1`.
91
+ */
92
+ region: string;
93
+ /**
94
+ * A custom domain hosting the callable Cloud Functions.
95
+ * ex: https://mydomain.com
96
+ */
97
+ customDomain: string | null;
98
+ }
99
+ /**
100
+ * Functions error code string appended after "functions/" product prefix.
101
+ * See {@link FunctionsErrorCode} for full documentation of codes.
102
+ * @public
103
+ */
104
+ export type FunctionsErrorCodeCore = 'ok' | 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated';
105
+ /**
106
+ * The set of Firebase Functions status codes. The codes are the same at the
107
+ * ones exposed by gRPC here:
108
+ * https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
109
+ *
110
+ * Possible values:
111
+ * - 'cancelled': The operation was cancelled (typically by the caller).
112
+ * - 'unknown': Unknown error or an error from a different error domain.
113
+ * - 'invalid-argument': Client specified an invalid argument. Note that this
114
+ * differs from 'failed-precondition'. 'invalid-argument' indicates
115
+ * arguments that are problematic regardless of the state of the system
116
+ * (e.g. an invalid field name).
117
+ * - 'deadline-exceeded': Deadline expired before operation could complete.
118
+ * For operations that change the state of the system, this error may be
119
+ * returned even if the operation has completed successfully. For example,
120
+ * a successful response from a server could have been delayed long enough
121
+ * for the deadline to expire.
122
+ * - 'not-found': Some requested document was not found.
123
+ * - 'already-exists': Some document that we attempted to create already
124
+ * exists.
125
+ * - 'permission-denied': The caller does not have permission to execute the
126
+ * specified operation.
127
+ * - 'resource-exhausted': Some resource has been exhausted, perhaps a
128
+ * per-user quota, or perhaps the entire file system is out of space.
129
+ * - 'failed-precondition': Operation was rejected because the system is not
130
+ * in a state required for the operation's execution.
131
+ * - 'aborted': The operation was aborted, typically due to a concurrency
132
+ * issue like transaction aborts, etc.
133
+ * - 'out-of-range': Operation was attempted past the valid range.
134
+ * - 'unimplemented': Operation is not implemented or not supported/enabled.
135
+ * - 'internal': Internal errors. Means some invariants expected by
136
+ * underlying system has been broken. If you see one of these errors,
137
+ * something is very broken.
138
+ * - 'unavailable': The service is currently unavailable. This is most likely
139
+ * a transient condition and may be corrected by retrying with a backoff.
140
+ * - 'data-loss': Unrecoverable data loss or corruption.
141
+ * - 'unauthenticated': The request does not have valid authentication
142
+ * credentials for the operation.
143
+ * @public
144
+ */
145
+ export type FunctionsErrorCode = `functions/${FunctionsErrorCodeCore}`;
146
+ declare module '@firebase/component' {
147
+ interface NameServiceMapping {
148
+ 'functions': Functions;
149
+ }
150
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Takes data and encodes it in a JSON-friendly way, such that types such as
3
+ * Date are preserved.
4
+ * @internal
5
+ * @param data - Data to encode.
6
+ */
7
+ export declare function encode(data: unknown): unknown;
8
+ /**
9
+ * Takes data that's been encoded in a JSON-friendly form and returns a form
10
+ * with richer datatypes, such as Dates, etc.
11
+ * @internal
12
+ * @param json - JSON to convert.
13
+ */
14
+ export declare function decode(json: unknown): unknown;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { FirebaseApp, _FirebaseService } from '@firebase/app';
18
+ import { HttpsCallable, HttpsCallableOptions } from './public-types';
19
+ import { ContextProvider } from './context';
20
+ import { Provider } from '@firebase/component';
21
+ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
22
+ import { MessagingInternalComponentName } from '@firebase/messaging-interop-types';
23
+ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
24
+ export declare const DEFAULT_REGION = "us-central1";
25
+ /**
26
+ * Describes the shape of the HttpResponse body.
27
+ * It makes functions that would otherwise take {} able to access the
28
+ * possible elements in the body more easily
29
+ */
30
+ export interface HttpResponseBody {
31
+ data?: unknown;
32
+ result?: unknown;
33
+ error?: {
34
+ message?: unknown;
35
+ status?: unknown;
36
+ details?: unknown;
37
+ };
38
+ }
39
+ /**
40
+ * The main class for the Firebase Functions SDK.
41
+ * @internal
42
+ */
43
+ export declare class FunctionsService implements _FirebaseService {
44
+ readonly app: FirebaseApp;
45
+ readonly fetchImpl: typeof fetch;
46
+ readonly contextProvider: ContextProvider;
47
+ emulatorOrigin: string | null;
48
+ cancelAllRequests: Promise<void>;
49
+ deleteService: () => Promise<void>;
50
+ region: string;
51
+ customDomain: string | null;
52
+ /**
53
+ * Creates a new Functions service for the given app.
54
+ * @param app - The FirebaseApp to use.
55
+ */
56
+ constructor(app: FirebaseApp, authProvider: Provider<FirebaseAuthInternalName>, messagingProvider: Provider<MessagingInternalComponentName>, appCheckProvider: Provider<AppCheckInternalComponentName>, regionOrCustomDomain?: string, fetchImpl?: typeof fetch);
57
+ _delete(): Promise<void>;
58
+ /**
59
+ * Returns the URL for a callable with the given name.
60
+ * @param name - The name of the callable.
61
+ * @internal
62
+ */
63
+ _url(name: string): string;
64
+ }
65
+ /**
66
+ * Modify this instance to communicate with the Cloud Functions emulator.
67
+ *
68
+ * Note: this must be called before this instance has been used to do any operations.
69
+ *
70
+ * @param host The emulator host (ex: localhost)
71
+ * @param port The emulator port (ex: 5001)
72
+ * @public
73
+ */
74
+ export declare function connectFunctionsEmulator(functionsInstance: FunctionsService, host: string, port: number): void;
75
+ /**
76
+ * Returns a reference to the callable https trigger with the given name.
77
+ * @param name - The name of the trigger.
78
+ * @public
79
+ */
80
+ export declare function httpsCallable<RequestData, ResponseData, StreamData = unknown>(functionsInstance: FunctionsService, name: string, options?: HttpsCallableOptions): HttpsCallable<RequestData, ResponseData, StreamData>;
81
+ /**
82
+ * Returns a reference to the callable https trigger with the given url.
83
+ * @param url - The url of the trigger.
84
+ * @public
85
+ */
86
+ export declare function httpsCallableFromURL<RequestData, ResponseData, StreamData = unknown>(functionsInstance: FunctionsService, url: string, options?: HttpsCallableOptions): HttpsCallable<RequestData, ResponseData, StreamData>;
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "0.1.2"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { FirebaseOptions, FirebaseApp } from '@firebase/app';
18
+ import { Provider } from '@firebase/component';
19
+ import { FunctionsService } from '../src/service';
20
+ export declare function makeFakeApp(options?: FirebaseOptions): FirebaseApp;
21
+ export declare function createTestService(app: FirebaseApp, region?: string, authProvider?: Provider<"auth-internal">, messagingProvider?: Provider<"messaging-internal">, appCheckProvider?: Provider<"app-check-internal">): FunctionsService;