firebase-functions 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,16 +9,17 @@ export { HttpsError };
|
|
|
9
9
|
*/
|
|
10
10
|
export type AuthBlockingEventType = "beforeCreate" | "beforeSignIn";
|
|
11
11
|
/**
|
|
12
|
-
* The UserRecord passed to Cloud Functions is the same
|
|
13
|
-
*
|
|
12
|
+
* The `UserRecord` passed to Cloud Functions is the same
|
|
13
|
+
* {@link https://firebase.google.com/docs/reference/admin/node/firebase-admin.auth.userrecord | UserRecord}
|
|
14
|
+
* that is returned by the Firebase Admin SDK.
|
|
14
15
|
*/
|
|
15
16
|
export type UserRecord = auth.UserRecord;
|
|
16
17
|
/**
|
|
17
|
-
* UserInfo that is part of the UserRecord
|
|
18
|
+
* `UserInfo` that is part of the `UserRecord`.
|
|
18
19
|
*/
|
|
19
20
|
export type UserInfo = auth.UserInfo;
|
|
20
21
|
/**
|
|
21
|
-
* Helper class to create the user metadata in a UserRecord object
|
|
22
|
+
* Helper class to create the user metadata in a `UserRecord` object.
|
|
22
23
|
*/
|
|
23
24
|
export declare class UserRecordMetadata implements auth.UserMetadata {
|
|
24
25
|
creationTime: string;
|
|
@@ -28,13 +29,13 @@ export declare class UserRecordMetadata implements auth.UserMetadata {
|
|
|
28
29
|
toJSON(): AuthUserMetadata;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
|
-
* Helper function that creates a UserRecord
|
|
32
|
+
* Helper function that creates a `UserRecord` class from data sent over the wire.
|
|
32
33
|
* @param wireData data sent over the wire
|
|
33
|
-
* @returns an instance of UserRecord with correct toJSON functions
|
|
34
|
+
* @returns an instance of `UserRecord` with correct toJSON functions
|
|
34
35
|
*/
|
|
35
36
|
export declare function userRecordConstructor(wireData: Record<string, unknown>): UserRecord;
|
|
36
37
|
/**
|
|
37
|
-
* User info that is part of the AuthUserRecord
|
|
38
|
+
* User info that is part of the `AuthUserRecord`.
|
|
38
39
|
*/
|
|
39
40
|
export interface AuthUserInfo {
|
|
40
41
|
/**
|
|
@@ -110,7 +111,7 @@ export interface AuthMultiFactorSettings {
|
|
|
110
111
|
enrolledFactors: AuthMultiFactorInfo[];
|
|
111
112
|
}
|
|
112
113
|
/**
|
|
113
|
-
* The UserRecord passed to auth blocking
|
|
114
|
+
* The `UserRecord` passed to auth blocking functions from the identity platform.
|
|
114
115
|
*/
|
|
115
116
|
export interface AuthUserRecord {
|
|
116
117
|
/**
|
|
@@ -205,7 +206,7 @@ export interface AuthEventContext extends EventContext {
|
|
|
205
206
|
additionalUserInfo?: AdditionalUserInfo;
|
|
206
207
|
credential?: Credential;
|
|
207
208
|
}
|
|
208
|
-
/** Defines the auth event for
|
|
209
|
+
/** Defines the auth event for 2nd gen blocking events */
|
|
209
210
|
export interface AuthBlockingEvent extends AuthEventContext {
|
|
210
211
|
data: AuthUserRecord;
|
|
211
212
|
}
|
|
@@ -213,7 +214,7 @@ export interface AuthBlockingEvent extends AuthEventContext {
|
|
|
213
214
|
* The reCAPTCHA action options.
|
|
214
215
|
*/
|
|
215
216
|
export type RecaptchaActionOptions = "ALLOW" | "BLOCK";
|
|
216
|
-
/** The handler response type for beforeCreate blocking events */
|
|
217
|
+
/** The handler response type for `beforeCreate` blocking events */
|
|
217
218
|
export interface BeforeCreateResponse {
|
|
218
219
|
displayName?: string;
|
|
219
220
|
disabled?: boolean;
|
|
@@ -222,7 +223,7 @@ export interface BeforeCreateResponse {
|
|
|
222
223
|
customClaims?: object;
|
|
223
224
|
recaptchaActionOverride?: RecaptchaActionOptions;
|
|
224
225
|
}
|
|
225
|
-
/** The handler response type for beforeSignIn blocking events */
|
|
226
|
+
/** The handler response type for `beforeSignIn` blocking events */
|
|
226
227
|
export interface BeforeSignInResponse extends BeforeCreateResponse {
|
|
227
228
|
sessionClaims?: object;
|
|
228
229
|
}
|
|
@@ -51,7 +51,7 @@ const EVENT_MAPPING = {
|
|
|
51
51
|
beforeSignIn: "providers/cloud.auth/eventTypes/user.beforeSignIn",
|
|
52
52
|
};
|
|
53
53
|
/**
|
|
54
|
-
* Helper class to create the user metadata in a UserRecord object
|
|
54
|
+
* Helper class to create the user metadata in a `UserRecord` object.
|
|
55
55
|
*/
|
|
56
56
|
class UserRecordMetadata {
|
|
57
57
|
constructor(creationTime, lastSignInTime) {
|
|
@@ -68,9 +68,9 @@ class UserRecordMetadata {
|
|
|
68
68
|
}
|
|
69
69
|
exports.UserRecordMetadata = UserRecordMetadata;
|
|
70
70
|
/**
|
|
71
|
-
* Helper function that creates a UserRecord
|
|
71
|
+
* Helper function that creates a `UserRecord` class from data sent over the wire.
|
|
72
72
|
* @param wireData data sent over the wire
|
|
73
|
-
* @returns an instance of UserRecord with correct toJSON functions
|
|
73
|
+
* @returns an instance of `UserRecord` with correct toJSON functions
|
|
74
74
|
*/
|
|
75
75
|
function userRecordConstructor(wireData) {
|
|
76
76
|
// Falsey values from the wire format proto get lost when converted to JSON, this adds them back.
|
|
@@ -122,7 +122,7 @@ function userRecordConstructor(wireData) {
|
|
|
122
122
|
}
|
|
123
123
|
exports.userRecordConstructor = userRecordConstructor;
|
|
124
124
|
/**
|
|
125
|
-
* Checks for a valid identity platform web request, otherwise throws an HttpsError
|
|
125
|
+
* Checks for a valid identity platform web request, otherwise throws an HttpsError.
|
|
126
126
|
* @internal
|
|
127
127
|
*/
|
|
128
128
|
function isValidRequest(req) {
|
|
@@ -156,7 +156,7 @@ function unsafeDecodeAuthBlockingToken(token) {
|
|
|
156
156
|
return decoded;
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
|
-
* Helper function to parse the decoded metadata object into a UserMetaData object
|
|
159
|
+
* Helper function to parse the decoded metadata object into a `UserMetaData` object
|
|
160
160
|
* @internal
|
|
161
161
|
*/
|
|
162
162
|
function parseMetadata(metadata) {
|
|
@@ -173,7 +173,7 @@ function parseMetadata(metadata) {
|
|
|
173
173
|
}
|
|
174
174
|
exports.parseMetadata = parseMetadata;
|
|
175
175
|
/**
|
|
176
|
-
* Helper function to parse the decoded user info array into an AuthUserInfo array
|
|
176
|
+
* Helper function to parse the decoded user info array into an `AuthUserInfo` array.
|
|
177
177
|
* @internal
|
|
178
178
|
*/
|
|
179
179
|
function parseProviderData(providerData) {
|
|
@@ -192,7 +192,7 @@ function parseProviderData(providerData) {
|
|
|
192
192
|
}
|
|
193
193
|
exports.parseProviderData = parseProviderData;
|
|
194
194
|
/**
|
|
195
|
-
* Helper function to parse the date into a UTC string
|
|
195
|
+
* Helper function to parse the date into a UTC string.
|
|
196
196
|
* @internal
|
|
197
197
|
*/
|
|
198
198
|
function parseDate(tokensValidAfterTime) {
|
|
@@ -276,7 +276,7 @@ function parseAuthUserRecord(decodedJWTUserRecord) {
|
|
|
276
276
|
};
|
|
277
277
|
}
|
|
278
278
|
exports.parseAuthUserRecord = parseAuthUserRecord;
|
|
279
|
-
/** Helper to get the AdditionalUserInfo from the decoded
|
|
279
|
+
/** Helper to get the `AdditionalUserInfo` from the decoded JWT */
|
|
280
280
|
function parseAdditionalUserInfo(decodedJWT) {
|
|
281
281
|
let profile;
|
|
282
282
|
let username;
|
|
@@ -327,7 +327,7 @@ function generateResponsePayload(authResponse) {
|
|
|
327
327
|
return result;
|
|
328
328
|
}
|
|
329
329
|
exports.generateResponsePayload = generateResponsePayload;
|
|
330
|
-
/** Helper to get the Credential from the decoded
|
|
330
|
+
/** Helper to get the Credential from the decoded JWT */
|
|
331
331
|
function parseAuthCredential(decodedJWT, time) {
|
|
332
332
|
if (!decodedJWT.sign_in_attributes &&
|
|
333
333
|
!decodedJWT.oauth_id_token &&
|
|
@@ -61,8 +61,8 @@ export interface TaskContext {
|
|
|
61
61
|
/**
|
|
62
62
|
* The "short" name of the task, or, if no name was specified at creation, a unique
|
|
63
63
|
* system-generated id.
|
|
64
|
-
* This is the my-task-id value in the complete task name,
|
|
65
|
-
* projects/my-project-id/locations/my-location/queues/my-queue-id/tasks/my-task-id.
|
|
64
|
+
* This is the "my-task-id" value in the complete task name, such as "task_name =
|
|
65
|
+
* projects/my-project-id/locations/my-location/queues/my-queue-id/tasks/my-task-id."
|
|
66
66
|
* Populated via the `X-CloudTasks-TaskName` header.
|
|
67
67
|
*/
|
|
68
68
|
id: string;
|
|
@@ -177,7 +177,8 @@ export interface RuntimeOptions {
|
|
|
177
177
|
*
|
|
178
178
|
* @remarks
|
|
179
179
|
* Set this to true to enable the App Check replay protection feature by consuming the App Check token on callable
|
|
180
|
-
* request. Tokens that are found to be already consumed will have request.app.alreadyConsumed property set
|
|
180
|
+
* request. Tokens that are found to be already consumed will have the `request.app.alreadyConsumed` property set
|
|
181
|
+
* to true.
|
|
181
182
|
*
|
|
182
183
|
*
|
|
183
184
|
* Tokens are only considered to be consumed if it is sent to the App Check service by setting this option to true.
|
|
@@ -188,10 +189,10 @@ export interface RuntimeOptions {
|
|
|
188
189
|
* performance and can potentially deplete your attestation providers' quotas faster. Use this feature only for
|
|
189
190
|
* protecting low volume, security critical, or expensive operations.
|
|
190
191
|
*
|
|
191
|
-
* This option does not affect the enforceAppCheck option. Setting the latter to true will cause the callable function
|
|
192
|
-
* to automatically respond with a 401 Unauthorized status code when request includes an invalid App Check token.
|
|
193
|
-
* When request includes valid but consumed App Check tokens, requests will not be automatically rejected. Instead,
|
|
194
|
-
* the request.app.alreadyConsumed property will be set to true and pass the execution to the handler code for making
|
|
192
|
+
* This option does not affect the `enforceAppCheck` option. Setting the latter to true will cause the callable function
|
|
193
|
+
* to automatically respond with a 401 Unauthorized status code when the request includes an invalid App Check token.
|
|
194
|
+
* When the request includes valid but consumed App Check tokens, requests will not be automatically rejected. Instead,
|
|
195
|
+
* the `request.app.alreadyConsumed` property will be set to true and pass the execution to the handler code for making
|
|
195
196
|
* further decisions, such as requiring additional security checks or rejecting the request.
|
|
196
197
|
*/
|
|
197
198
|
consumeAppCheckToken?: boolean;
|
|
@@ -119,11 +119,12 @@ function onCall(optsOrHandler, handler) {
|
|
|
119
119
|
// onCallHandler sniffs the function length to determine which API to present.
|
|
120
120
|
// fix the length to prevent api versions from being mismatched.
|
|
121
121
|
const fixedLen = (req) => handler(req);
|
|
122
|
-
|
|
122
|
+
let func = (0, https_1.onCallHandler)({
|
|
123
123
|
cors: { origin, methods: "POST" },
|
|
124
124
|
enforceAppCheck: (_a = opts.enforceAppCheck) !== null && _a !== void 0 ? _a : options.getGlobalOptions().enforceAppCheck,
|
|
125
125
|
consumeAppCheckToken: opts.consumeAppCheckToken,
|
|
126
126
|
}, fixedLen);
|
|
127
|
+
func = (0, trace_1.wrapTraceContext)(func);
|
|
127
128
|
Object.defineProperty(func, "__trigger", {
|
|
128
129
|
get: () => {
|
|
129
130
|
const baseOpts = options.optionsToTriggerAnnotations(options.getGlobalOptions());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-functions",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "Firebase SDK for Cloud Functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"firebase",
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
"eslint-config-prettier": "^8.3.0",
|
|
226
226
|
"eslint-plugin-jsdoc": "^39.2.9",
|
|
227
227
|
"eslint-plugin-prettier": "^4.0.0",
|
|
228
|
-
"firebase-admin": "^
|
|
228
|
+
"firebase-admin": "^12.0.0",
|
|
229
229
|
"js-yaml": "^3.13.1",
|
|
230
230
|
"jsdom": "^16.2.1",
|
|
231
231
|
"jsonwebtoken": "^9.0.0",
|
|
@@ -245,7 +245,7 @@
|
|
|
245
245
|
"yargs": "^15.3.1"
|
|
246
246
|
},
|
|
247
247
|
"peerDependencies": {
|
|
248
|
-
"firebase-admin": "^10.0.0 || ^11.0.0"
|
|
248
|
+
"firebase-admin": "^10.0.0 || ^11.0.0 || ^12.0.0"
|
|
249
249
|
},
|
|
250
250
|
"engines": {
|
|
251
251
|
"node": ">=14.10.0"
|