@firebase/functions 0.9.1 → 0.9.2-20230201003102

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @firebase/functions
2
2
 
3
+ ## 0.9.2-20230201003102
4
+
5
+ ### Patch Changes
6
+
7
+ - [`0bab0b7a7`](https://github.com/firebase/firebase-js-sdk/commit/0bab0b7a786d1563bf665904c7097d1fe06efce5) [#6981](https://github.com/firebase/firebase-js-sdk/pull/6981) - Added browser CJS entry points (expected by Jest when using JSDOM mode).
8
+
9
+ - Updated dependencies [[`0bab0b7a7`](https://github.com/firebase/firebase-js-sdk/commit/0bab0b7a786d1563bf665904c7097d1fe06efce5)]:
10
+ - @firebase/util@1.9.1-20230201003102
11
+ - @firebase/app@0.9.2-20230201003102
12
+ - @firebase/component@0.6.2-20230201003102
13
+
3
14
  ## 0.9.1
4
15
 
5
16
  ### Patch Changes
@@ -603,7 +603,7 @@ async function callAtURL(functionsInstance, url, data, options) {
603
603
  }
604
604
 
605
605
  const name = "@firebase/functions";
606
- const version = "0.9.1";
606
+ const version = "0.9.2-20230201003102";
607
607
 
608
608
  /**
609
609
  * @license
@@ -0,0 +1,722 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var app = require('@firebase/app');
6
+ var util = require('@firebase/util');
7
+ var component = require('@firebase/component');
8
+
9
+ /**
10
+ * @license
11
+ * Copyright 2017 Google LLC
12
+ *
13
+ * Licensed under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License.
15
+ * You may obtain a copy of the License at
16
+ *
17
+ * http://www.apache.org/licenses/LICENSE-2.0
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software
20
+ * distributed under the License is distributed on an "AS IS" BASIS,
21
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ * See the License for the specific language governing permissions and
23
+ * limitations under the License.
24
+ */
25
+ const LONG_TYPE = 'type.googleapis.com/google.protobuf.Int64Value';
26
+ const UNSIGNED_LONG_TYPE = 'type.googleapis.com/google.protobuf.UInt64Value';
27
+ function mapValues(
28
+ // { [k: string]: unknown } is no longer a wildcard assignment target after typescript 3.5
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ o, f) {
31
+ const result = {};
32
+ for (const key in o) {
33
+ if (o.hasOwnProperty(key)) {
34
+ result[key] = f(o[key]);
35
+ }
36
+ }
37
+ return result;
38
+ }
39
+ /**
40
+ * Takes data and encodes it in a JSON-friendly way, such that types such as
41
+ * Date are preserved.
42
+ * @internal
43
+ * @param data - Data to encode.
44
+ */
45
+ function encode(data) {
46
+ if (data == null) {
47
+ return null;
48
+ }
49
+ if (data instanceof Number) {
50
+ data = data.valueOf();
51
+ }
52
+ if (typeof data === 'number' && isFinite(data)) {
53
+ // Any number in JS is safe to put directly in JSON and parse as a double
54
+ // without any loss of precision.
55
+ return data;
56
+ }
57
+ if (data === true || data === false) {
58
+ return data;
59
+ }
60
+ if (Object.prototype.toString.call(data) === '[object String]') {
61
+ return data;
62
+ }
63
+ if (data instanceof Date) {
64
+ return data.toISOString();
65
+ }
66
+ if (Array.isArray(data)) {
67
+ return data.map(x => encode(x));
68
+ }
69
+ if (typeof data === 'function' || typeof data === 'object') {
70
+ return mapValues(data, x => encode(x));
71
+ }
72
+ // If we got this far, the data is not encodable.
73
+ throw new Error('Data cannot be encoded in JSON: ' + data);
74
+ }
75
+ /**
76
+ * Takes data that's been encoded in a JSON-friendly form and returns a form
77
+ * with richer datatypes, such as Dates, etc.
78
+ * @internal
79
+ * @param json - JSON to convert.
80
+ */
81
+ function decode(json) {
82
+ if (json == null) {
83
+ return json;
84
+ }
85
+ if (json['@type']) {
86
+ switch (json['@type']) {
87
+ case LONG_TYPE:
88
+ // Fall through and handle this the same as unsigned.
89
+ case UNSIGNED_LONG_TYPE: {
90
+ // Technically, this could work return a valid number for malformed
91
+ // data if there was a number followed by garbage. But it's just not
92
+ // worth all the extra code to detect that case.
93
+ const value = Number(json['value']);
94
+ if (isNaN(value)) {
95
+ throw new Error('Data cannot be decoded from JSON: ' + json);
96
+ }
97
+ return value;
98
+ }
99
+ default: {
100
+ throw new Error('Data cannot be decoded from JSON: ' + json);
101
+ }
102
+ }
103
+ }
104
+ if (Array.isArray(json)) {
105
+ return json.map(x => decode(x));
106
+ }
107
+ if (typeof json === 'function' || typeof json === 'object') {
108
+ return mapValues(json, x => decode(x));
109
+ }
110
+ // Anything else is safe to return.
111
+ return json;
112
+ }
113
+
114
+ /**
115
+ * @license
116
+ * Copyright 2020 Google LLC
117
+ *
118
+ * Licensed under the Apache License, Version 2.0 (the "License");
119
+ * you may not use this file except in compliance with the License.
120
+ * You may obtain a copy of the License at
121
+ *
122
+ * http://www.apache.org/licenses/LICENSE-2.0
123
+ *
124
+ * Unless required by applicable law or agreed to in writing, software
125
+ * distributed under the License is distributed on an "AS IS" BASIS,
126
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127
+ * See the License for the specific language governing permissions and
128
+ * limitations under the License.
129
+ */
130
+ /**
131
+ * Type constant for Firebase Functions.
132
+ */
133
+ const FUNCTIONS_TYPE = 'functions';
134
+
135
+ /**
136
+ * @license
137
+ * Copyright 2017 Google LLC
138
+ *
139
+ * Licensed under the Apache License, Version 2.0 (the "License");
140
+ * you may not use this file except in compliance with the License.
141
+ * You may obtain a copy of the License at
142
+ *
143
+ * http://www.apache.org/licenses/LICENSE-2.0
144
+ *
145
+ * Unless required by applicable law or agreed to in writing, software
146
+ * distributed under the License is distributed on an "AS IS" BASIS,
147
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
148
+ * See the License for the specific language governing permissions and
149
+ * limitations under the License.
150
+ */
151
+ /**
152
+ * Standard error codes for different ways a request can fail, as defined by:
153
+ * https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
154
+ *
155
+ * This map is used primarily to convert from a backend error code string to
156
+ * a client SDK error code string, and make sure it's in the supported set.
157
+ */
158
+ const errorCodeMap = {
159
+ OK: 'ok',
160
+ CANCELLED: 'cancelled',
161
+ UNKNOWN: 'unknown',
162
+ INVALID_ARGUMENT: 'invalid-argument',
163
+ DEADLINE_EXCEEDED: 'deadline-exceeded',
164
+ NOT_FOUND: 'not-found',
165
+ ALREADY_EXISTS: 'already-exists',
166
+ PERMISSION_DENIED: 'permission-denied',
167
+ UNAUTHENTICATED: 'unauthenticated',
168
+ RESOURCE_EXHAUSTED: 'resource-exhausted',
169
+ FAILED_PRECONDITION: 'failed-precondition',
170
+ ABORTED: 'aborted',
171
+ OUT_OF_RANGE: 'out-of-range',
172
+ UNIMPLEMENTED: 'unimplemented',
173
+ INTERNAL: 'internal',
174
+ UNAVAILABLE: 'unavailable',
175
+ DATA_LOSS: 'data-loss'
176
+ };
177
+ /**
178
+ * An explicit error that can be thrown from a handler to send an error to the
179
+ * client that called the function.
180
+ */
181
+ class FunctionsError extends util.FirebaseError {
182
+ constructor(
183
+ /**
184
+ * A standard error code that will be returned to the client. This also
185
+ * determines the HTTP status code of the response, as defined in code.proto.
186
+ */
187
+ code, message,
188
+ /**
189
+ * Extra data to be converted to JSON and included in the error response.
190
+ */
191
+ details) {
192
+ super(`${FUNCTIONS_TYPE}/${code}`, message || '');
193
+ this.details = details;
194
+ }
195
+ }
196
+ /**
197
+ * Takes an HTTP status code and returns the corresponding ErrorCode.
198
+ * This is the standard HTTP status code -> error mapping defined in:
199
+ * https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
200
+ *
201
+ * @param status An HTTP status code.
202
+ * @return The corresponding ErrorCode, or ErrorCode.UNKNOWN if none.
203
+ */
204
+ function codeForHTTPStatus(status) {
205
+ // Make sure any successful status is OK.
206
+ if (status >= 200 && status < 300) {
207
+ return 'ok';
208
+ }
209
+ switch (status) {
210
+ case 0:
211
+ // This can happen if the server returns 500.
212
+ return 'internal';
213
+ case 400:
214
+ return 'invalid-argument';
215
+ case 401:
216
+ return 'unauthenticated';
217
+ case 403:
218
+ return 'permission-denied';
219
+ case 404:
220
+ return 'not-found';
221
+ case 409:
222
+ return 'aborted';
223
+ case 429:
224
+ return 'resource-exhausted';
225
+ case 499:
226
+ return 'cancelled';
227
+ case 500:
228
+ return 'internal';
229
+ case 501:
230
+ return 'unimplemented';
231
+ case 503:
232
+ return 'unavailable';
233
+ case 504:
234
+ return 'deadline-exceeded';
235
+ }
236
+ return 'unknown';
237
+ }
238
+ /**
239
+ * Takes an HTTP response and returns the corresponding Error, if any.
240
+ */
241
+ function _errorForResponse(status, bodyJSON) {
242
+ let code = codeForHTTPStatus(status);
243
+ // Start with reasonable defaults from the status code.
244
+ let description = code;
245
+ let details = undefined;
246
+ // Then look through the body for explicit details.
247
+ try {
248
+ const errorJSON = bodyJSON && bodyJSON.error;
249
+ if (errorJSON) {
250
+ const status = errorJSON.status;
251
+ if (typeof status === 'string') {
252
+ if (!errorCodeMap[status]) {
253
+ // They must've included an unknown error code in the body.
254
+ return new FunctionsError('internal', 'internal');
255
+ }
256
+ code = errorCodeMap[status];
257
+ // TODO(klimt): Add better default descriptions for error enums.
258
+ // The default description needs to be updated for the new code.
259
+ description = status;
260
+ }
261
+ const message = errorJSON.message;
262
+ if (typeof message === 'string') {
263
+ description = message;
264
+ }
265
+ details = errorJSON.details;
266
+ if (details !== undefined) {
267
+ details = decode(details);
268
+ }
269
+ }
270
+ }
271
+ catch (e) {
272
+ // If we couldn't parse explicit error data, that's fine.
273
+ }
274
+ if (code === 'ok') {
275
+ // Technically, there's an edge case where a developer could explicitly
276
+ // return an error code of OK, and we will treat it as success, but that
277
+ // seems reasonable.
278
+ return null;
279
+ }
280
+ return new FunctionsError(code, description, details);
281
+ }
282
+
283
+ /**
284
+ * @license
285
+ * Copyright 2017 Google LLC
286
+ *
287
+ * Licensed under the Apache License, Version 2.0 (the "License");
288
+ * you may not use this file except in compliance with the License.
289
+ * You may obtain a copy of the License at
290
+ *
291
+ * http://www.apache.org/licenses/LICENSE-2.0
292
+ *
293
+ * Unless required by applicable law or agreed to in writing, software
294
+ * distributed under the License is distributed on an "AS IS" BASIS,
295
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
296
+ * See the License for the specific language governing permissions and
297
+ * limitations under the License.
298
+ */
299
+ /**
300
+ * Helper class to get metadata that should be included with a function call.
301
+ * @internal
302
+ */
303
+ class ContextProvider {
304
+ constructor(authProvider, messagingProvider, appCheckProvider) {
305
+ this.auth = null;
306
+ this.messaging = null;
307
+ this.appCheck = null;
308
+ this.auth = authProvider.getImmediate({ optional: true });
309
+ this.messaging = messagingProvider.getImmediate({
310
+ optional: true
311
+ });
312
+ if (!this.auth) {
313
+ authProvider.get().then(auth => (this.auth = auth), () => {
314
+ /* get() never rejects */
315
+ });
316
+ }
317
+ if (!this.messaging) {
318
+ messagingProvider.get().then(messaging => (this.messaging = messaging), () => {
319
+ /* get() never rejects */
320
+ });
321
+ }
322
+ if (!this.appCheck) {
323
+ appCheckProvider.get().then(appCheck => (this.appCheck = appCheck), () => {
324
+ /* get() never rejects */
325
+ });
326
+ }
327
+ }
328
+ async getAuthToken() {
329
+ if (!this.auth) {
330
+ return undefined;
331
+ }
332
+ try {
333
+ const token = await this.auth.getToken();
334
+ return token === null || token === void 0 ? void 0 : token.accessToken;
335
+ }
336
+ catch (e) {
337
+ // If there's any error when trying to get the auth token, leave it off.
338
+ return undefined;
339
+ }
340
+ }
341
+ async getMessagingToken() {
342
+ if (!this.messaging ||
343
+ !('Notification' in self) ||
344
+ Notification.permission !== 'granted') {
345
+ return undefined;
346
+ }
347
+ try {
348
+ return await this.messaging.getToken();
349
+ }
350
+ catch (e) {
351
+ // We don't warn on this, because it usually means messaging isn't set up.
352
+ // console.warn('Failed to retrieve instance id token.', e);
353
+ // If there's any error when trying to get the token, leave it off.
354
+ return undefined;
355
+ }
356
+ }
357
+ async getAppCheckToken() {
358
+ if (this.appCheck) {
359
+ const result = await this.appCheck.getToken();
360
+ if (result.error) {
361
+ // Do not send the App Check header to the functions endpoint if
362
+ // there was an error from the App Check exchange endpoint. The App
363
+ // Check SDK will already have logged the error to console.
364
+ return null;
365
+ }
366
+ return result.token;
367
+ }
368
+ return null;
369
+ }
370
+ async getContext() {
371
+ const authToken = await this.getAuthToken();
372
+ const messagingToken = await this.getMessagingToken();
373
+ const appCheckToken = await this.getAppCheckToken();
374
+ return { authToken, messagingToken, appCheckToken };
375
+ }
376
+ }
377
+
378
+ /**
379
+ * @license
380
+ * Copyright 2017 Google LLC
381
+ *
382
+ * Licensed under the Apache License, Version 2.0 (the "License");
383
+ * you may not use this file except in compliance with the License.
384
+ * You may obtain a copy of the License at
385
+ *
386
+ * http://www.apache.org/licenses/LICENSE-2.0
387
+ *
388
+ * Unless required by applicable law or agreed to in writing, software
389
+ * distributed under the License is distributed on an "AS IS" BASIS,
390
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
391
+ * See the License for the specific language governing permissions and
392
+ * limitations under the License.
393
+ */
394
+ const DEFAULT_REGION = 'us-central1';
395
+ /**
396
+ * Returns a Promise that will be rejected after the given duration.
397
+ * The error will be of type FunctionsError.
398
+ *
399
+ * @param millis Number of milliseconds to wait before rejecting.
400
+ */
401
+ function failAfter(millis) {
402
+ // Node timers and browser timers are fundamentally incompatible, but we
403
+ // don't care about the value here
404
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
405
+ let timer = null;
406
+ return {
407
+ promise: new Promise((_, reject) => {
408
+ timer = setTimeout(() => {
409
+ reject(new FunctionsError('deadline-exceeded', 'deadline-exceeded'));
410
+ }, millis);
411
+ }),
412
+ cancel: () => {
413
+ if (timer) {
414
+ clearTimeout(timer);
415
+ }
416
+ }
417
+ };
418
+ }
419
+ /**
420
+ * The main class for the Firebase Functions SDK.
421
+ * @internal
422
+ */
423
+ class FunctionsService {
424
+ /**
425
+ * Creates a new Functions service for the given app.
426
+ * @param app - The FirebaseApp to use.
427
+ */
428
+ constructor(app, authProvider, messagingProvider, appCheckProvider, regionOrCustomDomain = DEFAULT_REGION, fetchImpl) {
429
+ this.app = app;
430
+ this.fetchImpl = fetchImpl;
431
+ this.emulatorOrigin = null;
432
+ this.contextProvider = new ContextProvider(authProvider, messagingProvider, appCheckProvider);
433
+ // Cancels all ongoing requests when resolved.
434
+ this.cancelAllRequests = new Promise(resolve => {
435
+ this.deleteService = () => {
436
+ return Promise.resolve(resolve());
437
+ };
438
+ });
439
+ // Resolve the region or custom domain overload by attempting to parse it.
440
+ try {
441
+ const url = new URL(regionOrCustomDomain);
442
+ this.customDomain = url.origin;
443
+ this.region = DEFAULT_REGION;
444
+ }
445
+ catch (e) {
446
+ this.customDomain = null;
447
+ this.region = regionOrCustomDomain;
448
+ }
449
+ }
450
+ _delete() {
451
+ return this.deleteService();
452
+ }
453
+ /**
454
+ * Returns the URL for a callable with the given name.
455
+ * @param name - The name of the callable.
456
+ * @internal
457
+ */
458
+ _url(name) {
459
+ const projectId = this.app.options.projectId;
460
+ if (this.emulatorOrigin !== null) {
461
+ const origin = this.emulatorOrigin;
462
+ return `${origin}/${projectId}/${this.region}/${name}`;
463
+ }
464
+ if (this.customDomain !== null) {
465
+ return `${this.customDomain}/${name}`;
466
+ }
467
+ return `https://${this.region}-${projectId}.cloudfunctions.net/${name}`;
468
+ }
469
+ }
470
+ /**
471
+ * Modify this instance to communicate with the Cloud Functions emulator.
472
+ *
473
+ * Note: this must be called before this instance has been used to do any operations.
474
+ *
475
+ * @param host The emulator host (ex: localhost)
476
+ * @param port The emulator port (ex: 5001)
477
+ * @public
478
+ */
479
+ function connectFunctionsEmulator$1(functionsInstance, host, port) {
480
+ functionsInstance.emulatorOrigin = `http://${host}:${port}`;
481
+ }
482
+ /**
483
+ * Returns a reference to the callable https trigger with the given name.
484
+ * @param name - The name of the trigger.
485
+ * @public
486
+ */
487
+ function httpsCallable$1(functionsInstance, name, options) {
488
+ return (data => {
489
+ return call(functionsInstance, name, data, options || {});
490
+ });
491
+ }
492
+ /**
493
+ * Returns a reference to the callable https trigger with the given url.
494
+ * @param url - The url of the trigger.
495
+ * @public
496
+ */
497
+ function httpsCallableFromURL$1(functionsInstance, url, options) {
498
+ return (data => {
499
+ return callAtURL(functionsInstance, url, data, options || {});
500
+ });
501
+ }
502
+ /**
503
+ * Does an HTTP POST and returns the completed response.
504
+ * @param url The url to post to.
505
+ * @param body The JSON body of the post.
506
+ * @param headers The HTTP headers to include in the request.
507
+ * @return A Promise that will succeed when the request finishes.
508
+ */
509
+ async function postJSON(url, body, headers, fetchImpl) {
510
+ headers['Content-Type'] = 'application/json';
511
+ let response;
512
+ try {
513
+ response = await fetchImpl(url, {
514
+ method: 'POST',
515
+ body: JSON.stringify(body),
516
+ headers
517
+ });
518
+ }
519
+ catch (e) {
520
+ // This could be an unhandled error on the backend, or it could be a
521
+ // network error. There's no way to know, since an unhandled error on the
522
+ // backend will fail to set the proper CORS header, and thus will be
523
+ // treated as a network error by fetch.
524
+ return {
525
+ status: 0,
526
+ json: null
527
+ };
528
+ }
529
+ let json = null;
530
+ try {
531
+ json = await response.json();
532
+ }
533
+ catch (e) {
534
+ // If we fail to parse JSON, it will fail the same as an empty body.
535
+ }
536
+ return {
537
+ status: response.status,
538
+ json
539
+ };
540
+ }
541
+ /**
542
+ * Calls a callable function asynchronously and returns the result.
543
+ * @param name The name of the callable trigger.
544
+ * @param data The data to pass as params to the function.s
545
+ */
546
+ function call(functionsInstance, name, data, options) {
547
+ const url = functionsInstance._url(name);
548
+ return callAtURL(functionsInstance, url, data, options);
549
+ }
550
+ /**
551
+ * Calls a callable function asynchronously and returns the result.
552
+ * @param url The url of the callable trigger.
553
+ * @param data The data to pass as params to the function.s
554
+ */
555
+ async function callAtURL(functionsInstance, url, data, options) {
556
+ // Encode any special types, such as dates, in the input data.
557
+ data = encode(data);
558
+ const body = { data };
559
+ // Add a header for the authToken.
560
+ const headers = {};
561
+ const context = await functionsInstance.contextProvider.getContext();
562
+ if (context.authToken) {
563
+ headers['Authorization'] = 'Bearer ' + context.authToken;
564
+ }
565
+ if (context.messagingToken) {
566
+ headers['Firebase-Instance-ID-Token'] = context.messagingToken;
567
+ }
568
+ if (context.appCheckToken !== null) {
569
+ headers['X-Firebase-AppCheck'] = context.appCheckToken;
570
+ }
571
+ // Default timeout to 70s, but let the options override it.
572
+ const timeout = options.timeout || 70000;
573
+ const failAfterHandle = failAfter(timeout);
574
+ const response = await Promise.race([
575
+ postJSON(url, body, headers, functionsInstance.fetchImpl),
576
+ failAfterHandle.promise,
577
+ functionsInstance.cancelAllRequests
578
+ ]);
579
+ // Always clear the failAfter timeout
580
+ failAfterHandle.cancel();
581
+ // If service was deleted, interrupted response throws an error.
582
+ if (!response) {
583
+ throw new FunctionsError('cancelled', 'Firebase Functions instance was deleted.');
584
+ }
585
+ // Check for an error status, regardless of http status.
586
+ const error = _errorForResponse(response.status, response.json);
587
+ if (error) {
588
+ throw error;
589
+ }
590
+ if (!response.json) {
591
+ throw new FunctionsError('internal', 'Response is not valid JSON object.');
592
+ }
593
+ let responseData = response.json.data;
594
+ // TODO(klimt): For right now, allow "result" instead of "data", for
595
+ // backwards compatibility.
596
+ if (typeof responseData === 'undefined') {
597
+ responseData = response.json.result;
598
+ }
599
+ if (typeof responseData === 'undefined') {
600
+ // Consider the response malformed.
601
+ throw new FunctionsError('internal', 'Response is missing data field.');
602
+ }
603
+ // Decode any special types, such as dates, in the returned data.
604
+ const decodedData = decode(responseData);
605
+ return { data: decodedData };
606
+ }
607
+
608
+ const name = "@firebase/functions";
609
+ const version = "0.9.2-20230201003102";
610
+
611
+ /**
612
+ * @license
613
+ * Copyright 2019 Google LLC
614
+ *
615
+ * Licensed under the Apache License, Version 2.0 (the "License");
616
+ * you may not use this file except in compliance with the License.
617
+ * You may obtain a copy of the License at
618
+ *
619
+ * http://www.apache.org/licenses/LICENSE-2.0
620
+ *
621
+ * Unless required by applicable law or agreed to in writing, software
622
+ * distributed under the License is distributed on an "AS IS" BASIS,
623
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
624
+ * See the License for the specific language governing permissions and
625
+ * limitations under the License.
626
+ */
627
+ const AUTH_INTERNAL_NAME = 'auth-internal';
628
+ const APP_CHECK_INTERNAL_NAME = 'app-check-internal';
629
+ const MESSAGING_INTERNAL_NAME = 'messaging-internal';
630
+ function registerFunctions(fetchImpl, variant) {
631
+ const factory = (container, { instanceIdentifier: regionOrCustomDomain }) => {
632
+ // Dependencies
633
+ const app = container.getProvider('app').getImmediate();
634
+ const authProvider = container.getProvider(AUTH_INTERNAL_NAME);
635
+ const messagingProvider = container.getProvider(MESSAGING_INTERNAL_NAME);
636
+ const appCheckProvider = container.getProvider(APP_CHECK_INTERNAL_NAME);
637
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
638
+ return new FunctionsService(app, authProvider, messagingProvider, appCheckProvider, regionOrCustomDomain, fetchImpl);
639
+ };
640
+ app._registerComponent(new component.Component(FUNCTIONS_TYPE, factory, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true));
641
+ app.registerVersion(name, version, variant);
642
+ // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
643
+ app.registerVersion(name, version, 'cjs2017');
644
+ }
645
+
646
+ /**
647
+ * @license
648
+ * Copyright 2020 Google LLC
649
+ *
650
+ * Licensed under the Apache License, Version 2.0 (the "License");
651
+ * you may not use this file except in compliance with the License.
652
+ * You may obtain a copy of the License at
653
+ *
654
+ * http://www.apache.org/licenses/LICENSE-2.0
655
+ *
656
+ * Unless required by applicable law or agreed to in writing, software
657
+ * distributed under the License is distributed on an "AS IS" BASIS,
658
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
659
+ * See the License for the specific language governing permissions and
660
+ * limitations under the License.
661
+ */
662
+ /**
663
+ * Returns a {@link Functions} instance for the given app.
664
+ * @param app - The {@link @firebase/app#FirebaseApp} to use.
665
+ * @param regionOrCustomDomain - one of:
666
+ * a) The region the callable functions are located in (ex: us-central1)
667
+ * b) A custom domain hosting the callable functions (ex: https://mydomain.com)
668
+ * @public
669
+ */
670
+ function getFunctions(app$1 = app.getApp(), regionOrCustomDomain = DEFAULT_REGION) {
671
+ // Dependencies
672
+ const functionsProvider = app._getProvider(util.getModularInstance(app$1), FUNCTIONS_TYPE);
673
+ const functionsInstance = functionsProvider.getImmediate({
674
+ identifier: regionOrCustomDomain
675
+ });
676
+ const emulator = util.getDefaultEmulatorHostnameAndPort('functions');
677
+ if (emulator) {
678
+ connectFunctionsEmulator(functionsInstance, ...emulator);
679
+ }
680
+ return functionsInstance;
681
+ }
682
+ /**
683
+ * Modify this instance to communicate with the Cloud Functions emulator.
684
+ *
685
+ * Note: this must be called before this instance has been used to do any operations.
686
+ *
687
+ * @param host - The emulator host (ex: localhost)
688
+ * @param port - The emulator port (ex: 5001)
689
+ * @public
690
+ */
691
+ function connectFunctionsEmulator(functionsInstance, host, port) {
692
+ connectFunctionsEmulator$1(util.getModularInstance(functionsInstance), host, port);
693
+ }
694
+ /**
695
+ * Returns a reference to the callable HTTPS trigger with the given name.
696
+ * @param name - The name of the trigger.
697
+ * @public
698
+ */
699
+ function httpsCallable(functionsInstance, name, options) {
700
+ return httpsCallable$1(util.getModularInstance(functionsInstance), name, options);
701
+ }
702
+ /**
703
+ * Returns a reference to the callable HTTPS trigger with the specified url.
704
+ * @param url - The url of the trigger.
705
+ * @public
706
+ */
707
+ function httpsCallableFromURL(functionsInstance, url, options) {
708
+ return httpsCallableFromURL$1(util.getModularInstance(functionsInstance), url, options);
709
+ }
710
+
711
+ /**
712
+ * Cloud Functions for Firebase
713
+ *
714
+ * @packageDocumentation
715
+ */
716
+ registerFunctions(fetch.bind(self));
717
+
718
+ exports.connectFunctionsEmulator = connectFunctionsEmulator;
719
+ exports.getFunctions = getFunctions;
720
+ exports.httpsCallable = httpsCallable;
721
+ exports.httpsCallableFromURL = httpsCallableFromURL;
722
+ //# sourceMappingURL=index.cjs.js.map
@@ -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 explicit error that can be thrown from a handler to send an error to the\n * client that called the function.\n */\nexport class FunctionsError extends FirebaseError {\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 * Extra data 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}\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 {\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 constructor(\n authProvider: Provider<FirebaseAuthInternalName>,\n messagingProvider: Provider<MessagingInternalComponentName>,\n appCheckProvider: Provider<AppCheckInternalComponentName>\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(): Promise<string | null> {\n if (this.appCheck) {\n const result = 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(): Promise<Context> {\n const authToken = await this.getAuthToken();\n const messagingToken = await this.getMessagingToken();\n const appCheckToken = await this.getAppCheckToken();\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 HttpsCallableOptions\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';\n\nexport const DEFAULT_REGION = 'us-central1';\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\n ) {\n this.contextProvider = new ContextProvider(\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 = url.origin;\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 functionsInstance.emulatorOrigin = `http://${host}:${port}`;\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>(\n functionsInstance: FunctionsService,\n name: string,\n options?: HttpsCallableOptions\n): HttpsCallable<RequestData, ResponseData> {\n return (data => {\n return call(functionsInstance, name, data, options || {});\n }) as HttpsCallable<RequestData, ResponseData>;\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<RequestData, ResponseData>(\n functionsInstance: FunctionsService,\n url: string,\n options?: HttpsCallableOptions\n): HttpsCallable<RequestData, ResponseData> {\n return (data => {\n return callAtURL(functionsInstance, url, data, options || {});\n }) as HttpsCallable<RequestData, ResponseData>;\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 * @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): 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 });\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 * 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.s\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.s\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: { [key: string]: string } = {};\n const context = await functionsInstance.contextProvider.getContext();\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\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(url, body, headers, functionsInstance.fetchImpl),\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 * @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(\n fetchImpl: typeof fetch,\n variant?: string\n): 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 fetchImpl\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 esm5, esm2017, cjs5, 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 * 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<RequestData = unknown, ResponseData = unknown>(\n functionsInstance: Functions,\n name: string,\n options?: HttpsCallableOptions\n): HttpsCallable<RequestData, ResponseData> {\n return _httpsCallable<RequestData, ResponseData>(\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>(\n functionsInstance: Functions,\n url: string,\n options?: HttpsCallableOptions\n): HttpsCallable<RequestData, ResponseData> {\n return _httpsCallableFromURL<RequestData, ResponseData>(\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(fetch.bind(self));\n"],"names":["FirebaseError","connectFunctionsEmulator","httpsCallable","httpsCallableFromURL","_registerComponent","Component","registerVersion","app","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;AACzB,SAAA;AACF,KAAA;AACD,IAAA,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;AAKG;AACG,SAAU,MAAM,CAAC,IAAa,EAAA;IAClC,IAAI,IAAI,IAAI,IAAI,EAAE;AAChB,QAAA,OAAO,IAAI,CAAC;AACb,KAAA;IACD,IAAI,IAAI,YAAY,MAAM,EAAE;AAC1B,QAAA,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;AACvB,KAAA;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;;;AAG9C,QAAA,OAAO,IAAI,CAAC;AACb,KAAA;AACD,IAAA,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE;AACnC,QAAA,OAAO,IAAI,CAAC;AACb,KAAA;AACD,IAAA,IAAI,MAAM,CAAC,SAAS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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,CAIlC,iBAA4B,EAC5B,GAAW,EACX,OAA8B,EAAA;IAE9B,OAAOI,sBAAqB,CAC1BJ,uBAAkB,CAAmB,iBAAqC,CAAC,EAC3E,GAAG,EACH,OAAO,CACR,CAAC;AACJ;;ACvHA;;;;AAIG;AAuBH,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;;;;;;"}
package/dist/index.esm.js CHANGED
@@ -679,7 +679,7 @@ function callAtURL(functionsInstance, url, data, options) {
679
679
  }
680
680
 
681
681
  var name = "@firebase/functions";
682
- var version = "0.9.1";
682
+ var version = "0.9.2-20230201003102";
683
683
 
684
684
  /**
685
685
  * @license
@@ -602,7 +602,7 @@ async function callAtURL(functionsInstance, url, data, options) {
602
602
  }
603
603
 
604
604
  const name = "@firebase/functions";
605
- const version = "0.9.1";
605
+ const version = "0.9.2-20230201003102";
606
606
 
607
607
  /**
608
608
  * @license
@@ -688,7 +688,7 @@ function callAtURL(functionsInstance, url, data, options) {
688
688
  }
689
689
 
690
690
  var name = "@firebase/functions";
691
- var version = "0.9.1";
691
+ var version = "0.9.2-20230201003102";
692
692
 
693
693
  /**
694
694
  * @license
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebase/functions",
3
- "version": "0.9.1",
3
+ "version": "0.9.2-20230201003102",
4
4
  "description": "",
5
5
  "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
6
6
  "main": "dist/index.node.cjs.js",
@@ -15,7 +15,11 @@
15
15
  "require": "./dist/index.node.cjs.js"
16
16
  },
17
17
  "esm5": "./dist/index.esm.js",
18
- "default": "./dist/index.esm2017.js"
18
+ "default": "./dist/index.esm2017.js",
19
+ "browser": {
20
+ "require": "./dist/index.cjs.js",
21
+ "import": "./dist/index.esm2017.js"
22
+ }
19
23
  },
20
24
  "./package.json": "./package.json"
21
25
  },
@@ -43,10 +47,10 @@
43
47
  },
44
48
  "license": "Apache-2.0",
45
49
  "peerDependencies": {
46
- "@firebase/app": "0.x"
50
+ "@firebase/app": "0.9.2-20230201003102"
47
51
  },
48
52
  "devDependencies": {
49
- "@firebase/app": "0.9.1",
53
+ "@firebase/app": "0.9.2-20230201003102",
50
54
  "rollup": "2.79.1",
51
55
  "@rollup/plugin-json": "4.1.0",
52
56
  "rollup-plugin-typescript2": "0.31.2",
@@ -62,11 +66,11 @@
62
66
  },
63
67
  "typings": "./dist/functions-public.d.ts",
64
68
  "dependencies": {
65
- "@firebase/component": "0.6.1",
69
+ "@firebase/component": "0.6.2-20230201003102",
66
70
  "@firebase/messaging-interop-types": "0.2.0",
67
71
  "@firebase/auth-interop-types": "0.2.1",
68
72
  "@firebase/app-check-interop-types": "0.2.0",
69
- "@firebase/util": "1.9.0",
73
+ "@firebase/util": "1.9.1-20230201003102",
70
74
  "node-fetch": "2.6.7",
71
75
  "tslib": "^2.1.0"
72
76
  },