firebase-functions 4.1.1 → 4.2.1
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/lib/common/providers/database.js +1 -6
- package/lib/common/providers/https.js +28 -1
- package/lib/params/index.d.ts +4 -4
- package/lib/params/index.js +16 -1
- package/lib/params/types.d.ts +25 -0
- package/lib/params/types.js +62 -8
- package/lib/v1/function-configuration.d.ts +1 -1
- package/lib/v1/providers/testLab.d.ts +1 -1
- package/lib/v2/options.d.ts +1 -1
- package/lib/v2/providers/alerts/alerts.d.ts +1 -1
- package/lib/v2/providers/alerts/appDistribution.d.ts +1 -1
- package/lib/v2/providers/alerts/crashlytics.d.ts +1 -1
- package/lib/v2/providers/database.d.ts +1 -1
- package/lib/v2/providers/database.js +8 -2
- package/lib/v2/providers/eventarc.d.ts +1 -1
- package/lib/v2/providers/eventarc.js +6 -0
- package/lib/v2/providers/https.d.ts +1 -1
- package/lib/v2/providers/https.js +5 -1
- package/lib/v2/providers/identity.d.ts +1 -1
- package/lib/v2/providers/pubsub.d.ts +1 -1
- package/lib/v2/providers/storage.d.ts +1 -1
- package/lib/v2/providers/tasks.d.ts +1 -1
- package/package.json +3 -3
|
@@ -31,14 +31,9 @@ const path_1 = require("../../common/utilities/path");
|
|
|
31
31
|
class DataSnapshot {
|
|
32
32
|
constructor(data, path, // path is undefined for the database root
|
|
33
33
|
app, instance) {
|
|
34
|
-
var _a, _b;
|
|
35
34
|
this.app = app;
|
|
36
35
|
const config = (0, config_1.firebaseConfig)();
|
|
37
|
-
if (
|
|
38
|
-
// In this case we're dealing with an emulator
|
|
39
|
-
this.instance = app.options.databaseURL;
|
|
40
|
-
}
|
|
41
|
-
else if (instance) {
|
|
36
|
+
if (instance) {
|
|
42
37
|
// SDK always supplies instance, but user's unit tests may not
|
|
43
38
|
this.instance = instance;
|
|
44
39
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.onCallHandler = exports.checkAuthToken = exports.unsafeDecodeAppCheckToken = exports.unsafeDecodeIdToken = exports.unsafeDecodeToken = exports.decode = exports.encode = exports.isValidRequest = exports.HttpsError = void 0;
|
|
24
|
+
exports.onCallHandler = exports.checkAuthToken = exports.unsafeDecodeAppCheckToken = exports.unsafeDecodeIdToken = exports.unsafeDecodeToken = exports.decode = exports.encode = exports.isValidRequest = exports.HttpsError = exports.ORIGINAL_AUTH_HEADER = exports.CALLABLE_AUTH_HEADER = void 0;
|
|
25
25
|
const cors = require("cors");
|
|
26
26
|
const logger = require("../../logger");
|
|
27
27
|
// TODO(inlined): Decide whether we want to un-version apps or whether we want a
|
|
@@ -31,6 +31,10 @@ const auth_1 = require("firebase-admin/auth");
|
|
|
31
31
|
const app_1 = require("../app");
|
|
32
32
|
const debug_1 = require("../debug");
|
|
33
33
|
const JWT_REGEX = /^[a-zA-Z0-9\-_=]+?\.[a-zA-Z0-9\-_=]+?\.([a-zA-Z0-9\-_=]+)?$/;
|
|
34
|
+
/** @internal */
|
|
35
|
+
exports.CALLABLE_AUTH_HEADER = "x-callable-context-auth";
|
|
36
|
+
/** @internal */
|
|
37
|
+
exports.ORIGINAL_AUTH_HEADER = "x-original-auth";
|
|
34
38
|
/**
|
|
35
39
|
* Standard error codes and HTTP statuses for different ways a request can fail,
|
|
36
40
|
* as defined by:
|
|
@@ -382,6 +386,29 @@ function wrapOnCallHandler(options, handler) {
|
|
|
382
386
|
throw new HttpsError("invalid-argument", "Bad Request");
|
|
383
387
|
}
|
|
384
388
|
const context = { rawRequest: req };
|
|
389
|
+
// TODO(colerogers): yank this when we release a breaking change of the CLI that removes
|
|
390
|
+
// our monkey-patching code referenced below and increases the minimum supported SDK version.
|
|
391
|
+
//
|
|
392
|
+
// Note: This code is needed to fix v1 callable functions in the emulator with a monorepo setup.
|
|
393
|
+
// The original monkey-patched code lived in the functionsEmulatorRuntime
|
|
394
|
+
// (link: https://github.com/firebase/firebase-tools/blob/accea7abda3cc9fa6bb91368e4895faf95281c60/src/emulator/functionsEmulatorRuntime.ts#L480)
|
|
395
|
+
// and was not compatible with how monorepos separate out packages (see https://github.com/firebase/firebase-tools/issues/5210).
|
|
396
|
+
if ((0, debug_1.isDebugFeatureEnabled)("skipTokenVerification") && handler.length === 2) {
|
|
397
|
+
const authContext = context.rawRequest.header(exports.CALLABLE_AUTH_HEADER);
|
|
398
|
+
if (authContext) {
|
|
399
|
+
logger.debug("Callable functions auth override", {
|
|
400
|
+
key: exports.CALLABLE_AUTH_HEADER,
|
|
401
|
+
value: authContext,
|
|
402
|
+
});
|
|
403
|
+
context.auth = JSON.parse(decodeURIComponent(authContext));
|
|
404
|
+
delete context.rawRequest.headers[exports.CALLABLE_AUTH_HEADER];
|
|
405
|
+
}
|
|
406
|
+
const originalAuth = context.rawRequest.header(exports.ORIGINAL_AUTH_HEADER);
|
|
407
|
+
if (originalAuth) {
|
|
408
|
+
context.rawRequest.headers["authorization"] = originalAuth;
|
|
409
|
+
delete context.rawRequest.headers[exports.ORIGINAL_AUTH_HEADER];
|
|
410
|
+
}
|
|
411
|
+
}
|
|
385
412
|
const tokenStatus = await checkTokens(req, context);
|
|
386
413
|
if (tokenStatus.auth === "INVALID") {
|
|
387
414
|
throw new HttpsError("unauthenticated", "Unauthenticated");
|
package/lib/params/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @hidden
|
|
3
3
|
* @alpha
|
|
4
4
|
*/
|
|
5
|
-
import { BooleanParam, Expression,
|
|
5
|
+
import { BooleanParam, Expression, IntParam, Param, ParamOptions, SecretParam, StringParam, ListParam } from "./types";
|
|
6
6
|
export { ParamOptions, Expression };
|
|
7
7
|
declare type SecretOrExpr = Param<any> | SecretParam;
|
|
8
8
|
export declare const declaredParams: SecretOrExpr[];
|
|
@@ -62,10 +62,10 @@ export declare function defineBoolean(name: string, options?: ParamOptions<boole
|
|
|
62
62
|
*/
|
|
63
63
|
export declare function defineInt(name: string, options?: ParamOptions<number>): IntParam;
|
|
64
64
|
/**
|
|
65
|
-
* Declare a
|
|
65
|
+
* Declare a list param.
|
|
66
66
|
*
|
|
67
67
|
* @param name The name of the environment variable to use to load the param.
|
|
68
68
|
* @param options Configuration options for the param.
|
|
69
|
-
* @returns A Param with a `
|
|
69
|
+
* @returns A Param with a `string[]` return type for `.value`.
|
|
70
70
|
*/
|
|
71
|
-
export declare function
|
|
71
|
+
export declare function defineList(name: string, options?: ParamOptions<string[]>): ListParam;
|
package/lib/params/index.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.defineFloat = exports.defineInt = exports.defineBoolean = exports.defineString = exports.defineSecret = exports.storageBucket = exports.gcloudProject = exports.projectID = exports.databaseURL = exports.clearParams = exports.declaredParams = exports.Expression = void 0;
|
|
24
|
+
exports.defineList = exports.defineFloat = exports.defineInt = exports.defineBoolean = exports.defineString = exports.defineSecret = exports.storageBucket = exports.gcloudProject = exports.projectID = exports.databaseURL = exports.clearParams = exports.declaredParams = exports.Expression = void 0;
|
|
25
25
|
/**
|
|
26
26
|
* @hidden
|
|
27
27
|
* @alpha
|
|
@@ -131,6 +131,8 @@ exports.defineInt = defineInt;
|
|
|
131
131
|
* @param name The name of the environment variable to use to load the param.
|
|
132
132
|
* @param options Configuration options for the param.
|
|
133
133
|
* @returns A Param with a `number` return type for `.value`.
|
|
134
|
+
*
|
|
135
|
+
* @internal
|
|
134
136
|
*/
|
|
135
137
|
function defineFloat(name, options = {}) {
|
|
136
138
|
const param = new types_1.FloatParam(name, options);
|
|
@@ -138,3 +140,16 @@ function defineFloat(name, options = {}) {
|
|
|
138
140
|
return param;
|
|
139
141
|
}
|
|
140
142
|
exports.defineFloat = defineFloat;
|
|
143
|
+
/**
|
|
144
|
+
* Declare a list param.
|
|
145
|
+
*
|
|
146
|
+
* @param name The name of the environment variable to use to load the param.
|
|
147
|
+
* @param options Configuration options for the param.
|
|
148
|
+
* @returns A Param with a `string[]` return type for `.value`.
|
|
149
|
+
*/
|
|
150
|
+
function defineList(name, options = {}) {
|
|
151
|
+
const param = new types_1.ListParam(name, options);
|
|
152
|
+
registerParam(param);
|
|
153
|
+
return param;
|
|
154
|
+
}
|
|
155
|
+
exports.defineList = defineList;
|
package/lib/params/types.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ declare type ParamInput<T> = {
|
|
|
34
34
|
text: TextInput<T>;
|
|
35
35
|
} | {
|
|
36
36
|
select: SelectInput<T>;
|
|
37
|
+
} | {
|
|
38
|
+
multiSelect: MultiSelectInput;
|
|
37
39
|
} | {
|
|
38
40
|
resource: ResourceInput;
|
|
39
41
|
};
|
|
@@ -73,6 +75,14 @@ export interface ResourceInput {
|
|
|
73
75
|
export interface SelectInput<T = unknown> {
|
|
74
76
|
options: Array<SelectOptions<T>>;
|
|
75
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Specifies that a Param's value should be determined by having the user select
|
|
80
|
+
* a subset from a list of pre-canned options interactively at deploy-time.
|
|
81
|
+
* Will result in errors if used on Params of type other than string[].
|
|
82
|
+
*/
|
|
83
|
+
export interface MultiSelectInput {
|
|
84
|
+
options: Array<SelectOptions<string>>;
|
|
85
|
+
}
|
|
76
86
|
/**
|
|
77
87
|
* One of the options provided to a SelectInput, containing a value and
|
|
78
88
|
* optionally a human-readable label to display in the selection interface.
|
|
@@ -186,4 +196,19 @@ export declare class BooleanParam extends Param<boolean> {
|
|
|
186
196
|
then<T extends string | number | boolean>(ifTrue: T | Expression<T>, ifFalse: T | Expression<T>): TernaryExpression<T>;
|
|
187
197
|
thenElse<T extends string | number | boolean>(ifTrue: T | Expression<T>, ifFalse: T | Expression<T>): TernaryExpression<T>;
|
|
188
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* A parametrized value of String[] type that will be read from .env files
|
|
201
|
+
* if present, or prompted for by the CLI if missing.
|
|
202
|
+
*/
|
|
203
|
+
export declare class ListParam extends Param<string[]> {
|
|
204
|
+
static type: ParamValueType;
|
|
205
|
+
/** @hidden */
|
|
206
|
+
greaterThan(rhs: string[] | Expression<string[]>): CompareExpression<string[]>;
|
|
207
|
+
/** @hidden */
|
|
208
|
+
greaterThanOrEqualTo(rhs: string[] | Expression<string[]>): CompareExpression<string[]>;
|
|
209
|
+
/** @hidden */
|
|
210
|
+
lessThan(rhs: string[] | Expression<string[]>): CompareExpression<string[]>;
|
|
211
|
+
/** @hidden */
|
|
212
|
+
lessThanorEqualTo(rhs: string[] | Expression<string[]>): CompareExpression<string[]>;
|
|
213
|
+
}
|
|
189
214
|
export {};
|
package/lib/params/types.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
// SOFTWARE.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.BooleanParam = exports.FloatParam = exports.IntParam = exports.InternalExpression = exports.StringParam = exports.SecretParam = exports.Param = exports.CompareExpression = exports.TernaryExpression = exports.Expression = void 0;
|
|
24
|
+
exports.ListParam = exports.BooleanParam = exports.FloatParam = exports.IntParam = exports.InternalExpression = exports.StringParam = exports.SecretParam = exports.Param = exports.CompareExpression = exports.TernaryExpression = exports.Expression = void 0;
|
|
25
25
|
const logger = require("../logger");
|
|
26
26
|
/*
|
|
27
27
|
* A CEL expression which can be evaluated during function deployment, and
|
|
@@ -51,15 +51,29 @@ class Expression {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
exports.Expression = Expression;
|
|
54
|
-
function quoteIfString(literal) {
|
|
55
|
-
// TODO(vsfan@): CEL's string escape semantics are slightly different than Javascript's, what do we do here?
|
|
56
|
-
return typeof literal === "string" ? `"${literal}"` : literal;
|
|
57
|
-
}
|
|
58
54
|
function valueOf(arg) {
|
|
59
55
|
return arg instanceof Expression ? arg.runtimeValue() : arg;
|
|
60
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns how an entity (either an Expression or a literal value) should be represented in CEL.
|
|
59
|
+
* - Expressions delegate to the .toString() method, which is used by the WireManifest
|
|
60
|
+
* - Strings have to be quoted explicitly
|
|
61
|
+
* - Arrays are represented as []-delimited, parsable JSON
|
|
62
|
+
* - Numbers and booleans are not quoted explicitly
|
|
63
|
+
*/
|
|
61
64
|
function refOf(arg) {
|
|
62
|
-
|
|
65
|
+
if (arg instanceof Expression) {
|
|
66
|
+
return arg.toString();
|
|
67
|
+
}
|
|
68
|
+
else if (typeof arg === "string") {
|
|
69
|
+
return `"${arg}"`;
|
|
70
|
+
}
|
|
71
|
+
else if (Array.isArray(arg)) {
|
|
72
|
+
return JSON.stringify(arg);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return arg.toString();
|
|
76
|
+
}
|
|
63
77
|
}
|
|
64
78
|
/**
|
|
65
79
|
* A CEL expression corresponding to a ternary operator, e.g {{ cond ? ifTrue : ifFalse }}
|
|
@@ -99,9 +113,9 @@ class CompareExpression extends Expression {
|
|
|
99
113
|
const right = valueOf(this.rhs);
|
|
100
114
|
switch (this.cmp) {
|
|
101
115
|
case "==":
|
|
102
|
-
return left === right;
|
|
116
|
+
return Array.isArray(left) ? this.arrayEquals(left, right) : left === right;
|
|
103
117
|
case "!=":
|
|
104
|
-
return left !== right;
|
|
118
|
+
return Array.isArray(left) ? !this.arrayEquals(left, right) : left !== right;
|
|
105
119
|
case ">":
|
|
106
120
|
return left > right;
|
|
107
121
|
case ">=":
|
|
@@ -114,6 +128,10 @@ class CompareExpression extends Expression {
|
|
|
114
128
|
throw new Error(`Unknown comparator ${this.cmp}`);
|
|
115
129
|
}
|
|
116
130
|
}
|
|
131
|
+
/** @internal */
|
|
132
|
+
arrayEquals(a, b) {
|
|
133
|
+
return a.every((item) => b.includes(item)) && b.every((item) => a.includes(item));
|
|
134
|
+
}
|
|
117
135
|
toString() {
|
|
118
136
|
const rhsStr = refOf(this.rhs);
|
|
119
137
|
return `${this.lhs} ${this.cmp} ${rhsStr}`;
|
|
@@ -309,3 +327,39 @@ class BooleanParam extends Param {
|
|
|
309
327
|
}
|
|
310
328
|
exports.BooleanParam = BooleanParam;
|
|
311
329
|
BooleanParam.type = "boolean";
|
|
330
|
+
/**
|
|
331
|
+
* A parametrized value of String[] type that will be read from .env files
|
|
332
|
+
* if present, or prompted for by the CLI if missing.
|
|
333
|
+
*/
|
|
334
|
+
class ListParam extends Param {
|
|
335
|
+
/** @internal */
|
|
336
|
+
runtimeValue() {
|
|
337
|
+
const val = JSON.parse(process.env[this.name]);
|
|
338
|
+
if (!Array.isArray(val) || !val.every((v) => typeof v === "string")) {
|
|
339
|
+
return [];
|
|
340
|
+
}
|
|
341
|
+
return val;
|
|
342
|
+
}
|
|
343
|
+
/** @hidden */
|
|
344
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
345
|
+
greaterThan(rhs) {
|
|
346
|
+
throw new Error(">/< comparison operators not supported on params of type List");
|
|
347
|
+
}
|
|
348
|
+
/** @hidden */
|
|
349
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
350
|
+
greaterThanOrEqualTo(rhs) {
|
|
351
|
+
throw new Error(">/< comparison operators not supported on params of type List");
|
|
352
|
+
}
|
|
353
|
+
/** @hidden */
|
|
354
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
355
|
+
lessThan(rhs) {
|
|
356
|
+
throw new Error(">/< comparison operators not supported on params of type List");
|
|
357
|
+
}
|
|
358
|
+
/** @hidden */
|
|
359
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
360
|
+
lessThanorEqualTo(rhs) {
|
|
361
|
+
throw new Error(">/< comparison operators not supported on params of type List");
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
exports.ListParam = ListParam;
|
|
365
|
+
ListParam.type = "list";
|
|
@@ -141,7 +141,7 @@ export interface RuntimeOptions {
|
|
|
141
141
|
/**
|
|
142
142
|
* Connect cloud function to specified VPC connector.
|
|
143
143
|
*/
|
|
144
|
-
vpcConnector?: string | ResetValue;
|
|
144
|
+
vpcConnector?: string | Expression<string> | ResetValue;
|
|
145
145
|
/**
|
|
146
146
|
* Egress settings for VPC connector.
|
|
147
147
|
*/
|
|
@@ -121,7 +121,7 @@ export declare class ResultStorage {
|
|
|
121
121
|
* - `USE_DESTINATION_ARTIFACTS`: One or more of the test targets defined in the
|
|
122
122
|
* .xctestrun file specifies "UseDestinationArtifacts", which is disallowed.
|
|
123
123
|
*
|
|
124
|
-
* - `
|
|
124
|
+
* - `TEST_NOT_APP_HOSTED`: XC tests which run on physical devices must have
|
|
125
125
|
* "IsAppHostedTestBundle" == "true" in the xctestrun file.
|
|
126
126
|
*
|
|
127
127
|
* - `PLIST_CANNOT_BE_PARSED`: An Info.plist file in the XCTest zip could not be
|
package/lib/v2/options.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ export interface FirebaseAlertOptions extends options.EventHandlerOptions {
|
|
|
97
97
|
* Connect cloud function to specified VPC connector.
|
|
98
98
|
* A value of null removes the VPC connector
|
|
99
99
|
*/
|
|
100
|
-
vpcConnector?: string | ResetValue;
|
|
100
|
+
vpcConnector?: string | Expression<string> | ResetValue;
|
|
101
101
|
/**
|
|
102
102
|
* Egress settings for VPC connector.
|
|
103
103
|
* A value of null turns off VPC connector egress settings
|
|
@@ -123,7 +123,7 @@ export interface AppDistributionOptions extends options.EventHandlerOptions {
|
|
|
123
123
|
/**
|
|
124
124
|
* Connect cloud function to specified VPC connector.
|
|
125
125
|
*/
|
|
126
|
-
vpcConnector?: string | ResetValue;
|
|
126
|
+
vpcConnector?: string | Expression<string> | ResetValue;
|
|
127
127
|
/**
|
|
128
128
|
* Egress settings for VPC connector.
|
|
129
129
|
*/
|
|
@@ -189,7 +189,7 @@ export interface CrashlyticsOptions extends options.EventHandlerOptions {
|
|
|
189
189
|
/**
|
|
190
190
|
* Connect cloud function to specified VPC connector.
|
|
191
191
|
*/
|
|
192
|
-
vpcConnector?: string | ResetValue;
|
|
192
|
+
vpcConnector?: string | Expression<string> | ResetValue;
|
|
193
193
|
/**
|
|
194
194
|
* Egress settings for VPC connector.
|
|
195
195
|
*/
|
|
@@ -111,7 +111,7 @@ export interface ReferenceOptions<Ref extends string = string> extends options.E
|
|
|
111
111
|
/**
|
|
112
112
|
* Connect cloud function to specified VPC connector.
|
|
113
113
|
*/
|
|
114
|
-
vpcConnector?: string | ResetValue;
|
|
114
|
+
vpcConnector?: string | Expression<string> | ResetValue;
|
|
115
115
|
/**
|
|
116
116
|
* Egress settings for VPC connector.
|
|
117
117
|
*/
|
|
@@ -178,7 +178,7 @@ function onChangedOperation(eventType, referenceOrOpts, handler) {
|
|
|
178
178
|
// wrap the handler
|
|
179
179
|
const func = (raw) => {
|
|
180
180
|
const event = raw;
|
|
181
|
-
const instanceUrl =
|
|
181
|
+
const instanceUrl = getInstance(event);
|
|
182
182
|
const params = makeParams(event, pathPattern, instancePattern);
|
|
183
183
|
const databaseEvent = makeChangedDatabaseEvent(event, instanceUrl, params);
|
|
184
184
|
return (0, trace_1.wrapTraceContext)(handler)(databaseEvent);
|
|
@@ -196,7 +196,7 @@ function onOperation(eventType, referenceOrOpts, handler) {
|
|
|
196
196
|
// wrap the handler
|
|
197
197
|
const func = (raw) => {
|
|
198
198
|
const event = raw;
|
|
199
|
-
const instanceUrl =
|
|
199
|
+
const instanceUrl = getInstance(event);
|
|
200
200
|
const params = makeParams(event, pathPattern, instancePattern);
|
|
201
201
|
const data = eventType === exports.deletedEventType ? event.data.data : event.data.delta;
|
|
202
202
|
const databaseEvent = makeDatabaseEvent(event, data, instanceUrl, params);
|
|
@@ -207,3 +207,9 @@ function onOperation(eventType, referenceOrOpts, handler) {
|
|
|
207
207
|
return func;
|
|
208
208
|
}
|
|
209
209
|
exports.onOperation = onOperation;
|
|
210
|
+
function getInstance(event) {
|
|
211
|
+
const emuHost = process.env.FIREBASE_DATABASE_EMULATOR_HOST;
|
|
212
|
+
return emuHost
|
|
213
|
+
? `http://${emuHost}/?ns=${event.instance}`
|
|
214
|
+
: `https://${event.instance}.${event.firebasedatabasehost}`;
|
|
215
|
+
}
|
|
@@ -88,7 +88,7 @@ export interface EventarcTriggerOptions extends options.EventHandlerOptions {
|
|
|
88
88
|
/**
|
|
89
89
|
* Connect cloud function to specified VPC connector.
|
|
90
90
|
*/
|
|
91
|
-
vpcConnector?: string | ResetValue;
|
|
91
|
+
vpcConnector?: string | Expression<string> | ResetValue;
|
|
92
92
|
/**
|
|
93
93
|
* Egress settings for VPC connector.
|
|
94
94
|
*/
|
|
@@ -67,6 +67,12 @@ function onCustomEventPublished(eventTypeOrOpts, handler) {
|
|
|
67
67
|
(0, encoding_1.convertIfPresent)(endpoint.eventTrigger, opts, "eventFilters", "filters");
|
|
68
68
|
(0, encoding_1.copyIfPresent)(endpoint.eventTrigger, opts, "retry");
|
|
69
69
|
func.__endpoint = endpoint;
|
|
70
|
+
func.__requiredAPIs = [
|
|
71
|
+
{
|
|
72
|
+
api: "eventarcpublishing.googleapis.com",
|
|
73
|
+
reason: "Needed for custom event functions",
|
|
74
|
+
},
|
|
75
|
+
];
|
|
70
76
|
return func;
|
|
71
77
|
}
|
|
72
78
|
exports.onCustomEventPublished = onCustomEventPublished;
|
|
@@ -75,7 +75,7 @@ export interface HttpsOptions extends Omit<GlobalOptions, "region"> {
|
|
|
75
75
|
/**
|
|
76
76
|
* Connect cloud function to specified VPC connector.
|
|
77
77
|
*/
|
|
78
|
-
vpcConnector?: string | ResetValue;
|
|
78
|
+
vpcConnector?: string | Expression<string> | ResetValue;
|
|
79
79
|
/**
|
|
80
80
|
* Egress settings for VPC connector.
|
|
81
81
|
*/
|
|
@@ -44,7 +44,11 @@ function onRequest(optsOrHandler, handler) {
|
|
|
44
44
|
opts = optsOrHandler;
|
|
45
45
|
}
|
|
46
46
|
if ((0, debug_1.isDebugFeatureEnabled)("enableCors") || "cors" in opts) {
|
|
47
|
-
|
|
47
|
+
let origin = opts.cors;
|
|
48
|
+
if ((0, debug_1.isDebugFeatureEnabled)("enableCors")) {
|
|
49
|
+
// Respect `cors: false` to turn off cors even if debug feature is enabled.
|
|
50
|
+
origin = opts.cors === false ? false : true;
|
|
51
|
+
}
|
|
48
52
|
const userProvidedHandler = handler;
|
|
49
53
|
handler = (req, res) => {
|
|
50
54
|
return new Promise((resolve) => {
|
|
@@ -144,7 +144,7 @@ export interface PubSubOptions extends options.EventHandlerOptions {
|
|
|
144
144
|
/**
|
|
145
145
|
* Connect cloud function to specified VPC connector.
|
|
146
146
|
*/
|
|
147
|
-
vpcConnector?: string | ResetValue;
|
|
147
|
+
vpcConnector?: string | Expression<string> | ResetValue;
|
|
148
148
|
/**
|
|
149
149
|
* Egress settings for VPC connector.
|
|
150
150
|
*/
|
|
@@ -220,7 +220,7 @@ export interface StorageOptions extends options.EventHandlerOptions {
|
|
|
220
220
|
/**
|
|
221
221
|
* Connect cloud function to specified VPC connector.
|
|
222
222
|
*/
|
|
223
|
-
vpcConnector?: string | ResetValue;
|
|
223
|
+
vpcConnector?: string | Expression<string> | ResetValue;
|
|
224
224
|
/**
|
|
225
225
|
* Egress settings for VPC connector.
|
|
226
226
|
*/
|
|
@@ -79,7 +79,7 @@ export interface TaskQueueOptions extends options.EventHandlerOptions {
|
|
|
79
79
|
/**
|
|
80
80
|
* Connect cloud function to specified VPC connector.
|
|
81
81
|
*/
|
|
82
|
-
vpcConnector?: string | ResetValue;
|
|
82
|
+
vpcConnector?: string | Expression<string> | ResetValue;
|
|
83
83
|
/**
|
|
84
84
|
* Egress settings for VPC connector.
|
|
85
85
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-functions",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "Firebase SDK for Cloud Functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"firebase",
|
|
@@ -201,7 +201,7 @@
|
|
|
201
201
|
"@microsoft/api-extractor": "^7.18.7",
|
|
202
202
|
"@types/chai": "^4.1.7",
|
|
203
203
|
"@types/chai-as-promised": "^7.1.0",
|
|
204
|
-
"@types/jsonwebtoken": "^
|
|
204
|
+
"@types/jsonwebtoken": "^9.0.0",
|
|
205
205
|
"@types/mocha": "^5.2.7",
|
|
206
206
|
"@types/mock-require": "^2.0.0",
|
|
207
207
|
"@types/nock": "^10.0.3",
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
"firebase-admin": "^10.3.0",
|
|
223
223
|
"js-yaml": "^3.13.1",
|
|
224
224
|
"jsdom": "^16.2.1",
|
|
225
|
-
"jsonwebtoken": "^
|
|
225
|
+
"jsonwebtoken": "^9.0.0",
|
|
226
226
|
"jwk-to-pem": "^2.0.5",
|
|
227
227
|
"mocha": "^6.1.4",
|
|
228
228
|
"mock-require": "^3.0.3",
|