@firebase/functions 0.7.3-canary.ba40cde9c → 0.7.3-canary.dbfe09e9d

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