firebase-admin 10.3.0 → 11.0.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.
- package/README.md +1 -2
- package/lib/app/core.d.ts +1 -1
- package/lib/app/core.js +1 -1
- package/lib/app/credential-factory.d.ts +1 -1
- package/lib/app/credential-factory.js +8 -8
- package/lib/app/credential-internal.d.ts +1 -1
- package/lib/app/credential-internal.js +97 -106
- package/lib/app/credential.d.ts +1 -1
- package/lib/app/credential.js +1 -1
- package/lib/app/firebase-app.d.ts +1 -1
- package/lib/app/firebase-app.js +76 -91
- package/lib/app/firebase-namespace.d.ts +1 -1
- package/lib/app/firebase-namespace.js +209 -279
- package/lib/app/index.d.ts +1 -1
- package/lib/app/index.js +4 -4
- package/lib/app/lifecycle.d.ts +1 -1
- package/lib/app/lifecycle.js +37 -43
- package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
- package/lib/app-check/app-check-api-client-internal.js +54 -73
- package/lib/app-check/app-check-api.d.ts +1 -1
- package/lib/app-check/app-check-api.js +1 -1
- package/lib/app-check/app-check-namespace.d.ts +1 -1
- package/lib/app-check/app-check-namespace.js +1 -1
- package/lib/app-check/app-check.d.ts +1 -1
- package/lib/app-check/app-check.js +17 -19
- package/lib/app-check/index.d.ts +1 -1
- package/lib/app-check/index.js +7 -7
- package/lib/app-check/token-generator.d.ts +1 -1
- package/lib/app-check/token-generator.js +47 -52
- package/lib/app-check/token-verifier.d.ts +1 -1
- package/lib/app-check/token-verifier.js +46 -50
- package/lib/auth/action-code-settings-builder.d.ts +1 -1
- package/lib/auth/action-code-settings-builder.js +10 -11
- package/lib/auth/auth-api-request.d.ts +1 -1
- package/lib/auth/auth-api-request.js +346 -393
- package/lib/auth/auth-config.d.ts +1 -1
- package/lib/auth/auth-config.js +95 -106
- package/lib/auth/auth-namespace.d.ts +1 -1
- package/lib/auth/auth-namespace.js +1 -1
- package/lib/auth/auth.d.ts +1 -1
- package/lib/auth/auth.js +20 -40
- package/lib/auth/base-auth.d.ts +1 -1
- package/lib/auth/base-auth.js +137 -144
- package/lib/auth/identifier.d.ts +1 -1
- package/lib/auth/identifier.js +2 -2
- package/lib/auth/index.d.ts +1 -1
- package/lib/auth/index.js +7 -7
- package/lib/auth/tenant-manager.d.ts +1 -1
- package/lib/auth/tenant-manager.js +49 -71
- package/lib/auth/tenant.d.ts +1 -1
- package/lib/auth/tenant.js +44 -55
- package/lib/auth/token-generator.d.ts +1 -1
- package/lib/auth/token-generator.js +49 -53
- package/lib/auth/token-verifier.d.ts +1 -1
- package/lib/auth/token-verifier.js +83 -91
- package/lib/auth/user-import-builder.d.ts +1 -1
- package/lib/auth/user-import-builder.js +70 -73
- package/lib/auth/user-record.d.ts +1 -1
- package/lib/auth/user-record.js +61 -84
- package/lib/credential/index.d.ts +1 -1
- package/lib/credential/index.js +2 -2
- package/lib/database/database-namespace.d.ts +1 -1
- package/lib/database/database-namespace.js +1 -1
- package/lib/database/database.d.ts +1 -1
- package/lib/database/database.js +92 -108
- package/lib/database/index.d.ts +1 -1
- package/lib/database/index.js +10 -10
- package/lib/default-namespace.d.ts +1 -1
- package/lib/default-namespace.js +2 -2
- package/lib/eventarc/cloudevent.d.ts +1 -1
- package/lib/eventarc/cloudevent.js +1 -1
- package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
- package/lib/eventarc/eventarc-client-internal.js +63 -129
- package/lib/eventarc/eventarc-utils.d.ts +1 -1
- package/lib/eventarc/eventarc-utils.js +16 -32
- package/lib/eventarc/eventarc.d.ts +1 -1
- package/lib/eventarc/eventarc.js +51 -65
- package/lib/eventarc/index.d.ts +1 -1
- package/lib/eventarc/index.js +7 -7
- package/lib/firebase-namespace-api.d.ts +1 -1
- package/lib/firebase-namespace-api.js +8 -3
- package/lib/firestore/firestore-internal.d.ts +1 -1
- package/lib/firestore/firestore-internal.js +28 -37
- package/lib/firestore/firestore-namespace.d.ts +9 -1
- package/lib/firestore/firestore-namespace.js +2 -2
- package/lib/firestore/index.d.ts +2 -2
- package/lib/firestore/index.js +7 -7
- package/lib/functions/functions-api-client-internal.d.ts +1 -1
- package/lib/functions/functions-api-client-internal.js +71 -93
- package/lib/functions/functions-api.d.ts +1 -1
- package/lib/functions/functions-api.js +1 -1
- package/lib/functions/functions.d.ts +1 -1
- package/lib/functions/functions.js +13 -15
- package/lib/functions/index.d.ts +1 -1
- package/lib/functions/index.js +7 -7
- package/lib/index.d.ts +1 -1
- package/lib/index.js +14 -4
- package/lib/installations/index.d.ts +1 -1
- package/lib/installations/index.js +6 -6
- package/lib/installations/installations-namespace.d.ts +1 -1
- package/lib/installations/installations-namespace.js +1 -1
- package/lib/installations/installations-request-handler.d.ts +1 -1
- package/lib/installations/installations-request-handler.js +33 -36
- package/lib/installations/installations.d.ts +1 -1
- package/lib/installations/installations.js +17 -22
- package/lib/instance-id/index.d.ts +1 -1
- package/lib/instance-id/index.js +6 -6
- package/lib/instance-id/instance-id-namespace.d.ts +1 -1
- package/lib/instance-id/instance-id-namespace.js +1 -1
- package/lib/instance-id/instance-id.d.ts +1 -1
- package/lib/instance-id/instance-id.js +21 -26
- package/lib/machine-learning/index.d.ts +1 -1
- package/lib/machine-learning/index.js +7 -7
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +110 -124
- package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
- package/lib/machine-learning/machine-learning-namespace.js +1 -1
- package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
- package/lib/machine-learning/machine-learning-utils.js +9 -24
- package/lib/machine-learning/machine-learning.d.ts +1 -1
- package/lib/machine-learning/machine-learning.js +146 -207
- package/lib/messaging/batch-request-internal.d.ts +1 -1
- package/lib/messaging/batch-request-internal.js +33 -35
- package/lib/messaging/index.d.ts +1 -1
- package/lib/messaging/index.js +7 -7
- package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
- package/lib/messaging/messaging-api-request-internal.js +38 -40
- package/lib/messaging/messaging-api.d.ts +1 -1
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +1 -1
- package/lib/messaging/messaging-errors-internal.js +12 -13
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +51 -51
- package/lib/messaging/messaging-namespace.d.ts +1 -1
- package/lib/messaging/messaging-namespace.js +1 -1
- package/lib/messaging/messaging.d.ts +1 -1
- package/lib/messaging/messaging.js +184 -208
- package/lib/project-management/android-app.d.ts +1 -1
- package/lib/project-management/android-app.js +41 -43
- package/lib/project-management/app-metadata.d.ts +1 -1
- package/lib/project-management/app-metadata.js +1 -1
- package/lib/project-management/index.d.ts +1 -1
- package/lib/project-management/index.js +7 -7
- package/lib/project-management/ios-app.d.ts +1 -1
- package/lib/project-management/ios-app.js +25 -26
- package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
- package/lib/project-management/project-management-api-request-internal.js +84 -89
- package/lib/project-management/project-management-namespace.d.ts +1 -1
- package/lib/project-management/project-management-namespace.js +1 -1
- package/lib/project-management/project-management.d.ts +1 -1
- package/lib/project-management/project-management.js +80 -87
- package/lib/remote-config/index.d.ts +1 -1
- package/lib/remote-config/index.js +7 -7
- package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
- package/lib/remote-config/remote-config-api-client-internal.js +116 -154
- package/lib/remote-config/remote-config-api.d.ts +1 -1
- package/lib/remote-config/remote-config-api.js +1 -1
- package/lib/remote-config/remote-config-namespace.d.ts +1 -1
- package/lib/remote-config/remote-config-namespace.js +1 -1
- package/lib/remote-config/remote-config.d.ts +1 -1
- package/lib/remote-config/remote-config.js +51 -59
- package/lib/security-rules/index.d.ts +1 -1
- package/lib/security-rules/index.js +7 -7
- package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-api-client-internal.js +95 -107
- package/lib/security-rules/security-rules-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-internal.js +6 -21
- package/lib/security-rules/security-rules-namespace.d.ts +1 -1
- package/lib/security-rules/security-rules-namespace.js +1 -1
- package/lib/security-rules/security-rules.d.ts +1 -1
- package/lib/security-rules/security-rules.js +82 -91
- package/lib/storage/index.d.ts +1 -1
- package/lib/storage/index.js +7 -7
- package/lib/storage/storage-namespace.d.ts +1 -1
- package/lib/storage/storage-namespace.js +1 -1
- package/lib/storage/storage.d.ts +1 -1
- package/lib/storage/storage.js +25 -30
- package/lib/utils/api-request.d.ts +3 -1
- package/lib/utils/api-request.js +278 -356
- package/lib/utils/crypto-signer.d.ts +1 -1
- package/lib/utils/crypto-signer.js +58 -93
- package/lib/utils/deep-copy.d.ts +1 -1
- package/lib/utils/deep-copy.js +3 -3
- package/lib/utils/error.d.ts +1 -1
- package/lib/utils/error.js +611 -681
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +38 -43
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/jwt.js +97 -123
- package/lib/utils/validator.d.ts +1 -1
- package/lib/utils/validator.js +13 -13
- package/package.json +5 -5
package/lib/auth/base-auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v11.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2021 Google Inc.
|
|
@@ -17,33 +17,33 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.BaseAuth = exports.createFirebaseTokenGenerator = void 0;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
const error_1 = require("../utils/error");
|
|
21
|
+
const deep_copy_1 = require("../utils/deep-copy");
|
|
22
|
+
const validator = require("../utils/validator");
|
|
23
|
+
const auth_api_request_1 = require("./auth-api-request");
|
|
24
|
+
const token_generator_1 = require("./token-generator");
|
|
25
|
+
const token_verifier_1 = require("./token-verifier");
|
|
26
|
+
const auth_config_1 = require("./auth-config");
|
|
27
|
+
const user_record_1 = require("./user-record");
|
|
28
|
+
const identifier_1 = require("./identifier");
|
|
29
|
+
const crypto_signer_1 = require("../utils/crypto-signer");
|
|
30
30
|
/**
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
33
|
function createFirebaseTokenGenerator(app, tenantId) {
|
|
34
34
|
try {
|
|
35
|
-
|
|
35
|
+
const signer = (0, auth_api_request_1.useEmulator)() ? new token_generator_1.EmulatedSigner() : (0, crypto_signer_1.cryptoSignerFromApp)(app);
|
|
36
36
|
return new token_generator_1.FirebaseTokenGenerator(signer, tenantId);
|
|
37
37
|
}
|
|
38
38
|
catch (err) {
|
|
39
|
-
throw token_generator_1.handleCryptoSignerError(err);
|
|
39
|
+
throw (0, token_generator_1.handleCryptoSignerError)(err);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
exports.createFirebaseTokenGenerator = createFirebaseTokenGenerator;
|
|
43
43
|
/**
|
|
44
44
|
* Common parent interface for both `Auth` and `TenantAwareAuth` APIs.
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
class BaseAuth {
|
|
47
47
|
/**
|
|
48
48
|
* The BaseAuth class constructor.
|
|
49
49
|
*
|
|
@@ -55,7 +55,7 @@ var BaseAuth = /** @class */ (function () {
|
|
|
55
55
|
* @constructor
|
|
56
56
|
* @internal
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
constructor(app,
|
|
59
59
|
/** @internal */ authRequestHandler, tokenGenerator) {
|
|
60
60
|
this.authRequestHandler = authRequestHandler;
|
|
61
61
|
if (tokenGenerator) {
|
|
@@ -64,9 +64,9 @@ var BaseAuth = /** @class */ (function () {
|
|
|
64
64
|
else {
|
|
65
65
|
this.tokenGenerator = createFirebaseTokenGenerator(app);
|
|
66
66
|
}
|
|
67
|
-
this.sessionCookieVerifier = token_verifier_1.createSessionCookieVerifier(app);
|
|
68
|
-
this.idTokenVerifier = token_verifier_1.createIdTokenVerifier(app);
|
|
69
|
-
this.authBlockingTokenVerifier = token_verifier_1.createAuthBlockingTokenVerifier(app);
|
|
67
|
+
this.sessionCookieVerifier = (0, token_verifier_1.createSessionCookieVerifier)(app);
|
|
68
|
+
this.idTokenVerifier = (0, token_verifier_1.createIdTokenVerifier)(app);
|
|
69
|
+
this.authBlockingTokenVerifier = (0, token_verifier_1.createAuthBlockingTokenVerifier)(app);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* Creates a new Firebase custom token (JWT) that can be sent back to a client
|
|
@@ -84,9 +84,9 @@ var BaseAuth = /** @class */ (function () {
|
|
|
84
84
|
* @returns A promise fulfilled with a custom token for the
|
|
85
85
|
* provided `uid` and payload.
|
|
86
86
|
*/
|
|
87
|
-
|
|
87
|
+
createCustomToken(uid, developerClaims) {
|
|
88
88
|
return this.tokenGenerator.createCustomToken(uid, developerClaims);
|
|
89
|
-
}
|
|
89
|
+
}
|
|
90
90
|
/**
|
|
91
91
|
* Verifies a Firebase ID token (JWT). If the token is valid, the promise is
|
|
92
92
|
* fulfilled with the token's decoded claims; otherwise, the promise is
|
|
@@ -111,19 +111,17 @@ var BaseAuth = /** @class */ (function () {
|
|
|
111
111
|
* token's decoded claims if the ID token is valid; otherwise, a rejected
|
|
112
112
|
* promise.
|
|
113
113
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (checkRevoked === void 0) { checkRevoked = false; }
|
|
117
|
-
var isEmulator = auth_api_request_1.useEmulator();
|
|
114
|
+
verifyIdToken(idToken, checkRevoked = false) {
|
|
115
|
+
const isEmulator = (0, auth_api_request_1.useEmulator)();
|
|
118
116
|
return this.idTokenVerifier.verifyJWT(idToken, isEmulator)
|
|
119
|
-
.then(
|
|
117
|
+
.then((decodedIdToken) => {
|
|
120
118
|
// Whether to check if the token was revoked.
|
|
121
119
|
if (checkRevoked || isEmulator) {
|
|
122
|
-
return
|
|
120
|
+
return this.verifyDecodedJWTNotRevokedOrDisabled(decodedIdToken, error_1.AuthClientErrorCode.ID_TOKEN_REVOKED);
|
|
123
121
|
}
|
|
124
122
|
return decodedIdToken;
|
|
125
123
|
});
|
|
126
|
-
}
|
|
124
|
+
}
|
|
127
125
|
/**
|
|
128
126
|
* Gets the user data for the user corresponding to a given `uid`.
|
|
129
127
|
*
|
|
@@ -135,13 +133,13 @@ var BaseAuth = /** @class */ (function () {
|
|
|
135
133
|
* @returns A promise fulfilled with the user
|
|
136
134
|
* data corresponding to the provided `uid`.
|
|
137
135
|
*/
|
|
138
|
-
|
|
136
|
+
getUser(uid) {
|
|
139
137
|
return this.authRequestHandler.getAccountInfoByUid(uid)
|
|
140
|
-
.then(
|
|
138
|
+
.then((response) => {
|
|
141
139
|
// Returns the user record populated with server response.
|
|
142
140
|
return new user_record_1.UserRecord(response.users[0]);
|
|
143
141
|
});
|
|
144
|
-
}
|
|
142
|
+
}
|
|
145
143
|
/**
|
|
146
144
|
* Gets the user data for the user corresponding to a given email.
|
|
147
145
|
*
|
|
@@ -154,13 +152,13 @@ var BaseAuth = /** @class */ (function () {
|
|
|
154
152
|
* @returns A promise fulfilled with the user
|
|
155
153
|
* data corresponding to the provided email.
|
|
156
154
|
*/
|
|
157
|
-
|
|
155
|
+
getUserByEmail(email) {
|
|
158
156
|
return this.authRequestHandler.getAccountInfoByEmail(email)
|
|
159
|
-
.then(
|
|
157
|
+
.then((response) => {
|
|
160
158
|
// Returns the user record populated with server response.
|
|
161
159
|
return new user_record_1.UserRecord(response.users[0]);
|
|
162
160
|
});
|
|
163
|
-
}
|
|
161
|
+
}
|
|
164
162
|
/**
|
|
165
163
|
* Gets the user data for the user corresponding to a given phone number. The
|
|
166
164
|
* phone number has to conform to the E.164 specification.
|
|
@@ -174,13 +172,13 @@ var BaseAuth = /** @class */ (function () {
|
|
|
174
172
|
* @returns A promise fulfilled with the user
|
|
175
173
|
* data corresponding to the provided phone number.
|
|
176
174
|
*/
|
|
177
|
-
|
|
175
|
+
getUserByPhoneNumber(phoneNumber) {
|
|
178
176
|
return this.authRequestHandler.getAccountInfoByPhoneNumber(phoneNumber)
|
|
179
|
-
.then(
|
|
177
|
+
.then((response) => {
|
|
180
178
|
// Returns the user record populated with server response.
|
|
181
179
|
return new user_record_1.UserRecord(response.users[0]);
|
|
182
180
|
});
|
|
183
|
-
}
|
|
181
|
+
}
|
|
184
182
|
/**
|
|
185
183
|
* Gets the user data for the user corresponding to a given provider id.
|
|
186
184
|
*
|
|
@@ -194,7 +192,7 @@ var BaseAuth = /** @class */ (function () {
|
|
|
194
192
|
* @returns A promise fulfilled with the user data corresponding to the
|
|
195
193
|
* given provider id.
|
|
196
194
|
*/
|
|
197
|
-
|
|
195
|
+
getUserByProviderUid(providerId, uid) {
|
|
198
196
|
// Although we don't really advertise it, we want to also handle
|
|
199
197
|
// non-federated idps with this call. So if we detect one of them, we'll
|
|
200
198
|
// reroute this request appropriately.
|
|
@@ -205,11 +203,11 @@ var BaseAuth = /** @class */ (function () {
|
|
|
205
203
|
return this.getUserByEmail(uid);
|
|
206
204
|
}
|
|
207
205
|
return this.authRequestHandler.getAccountInfoByFederatedUid(providerId, uid)
|
|
208
|
-
.then(
|
|
206
|
+
.then((response) => {
|
|
209
207
|
// Returns the user record populated with server response.
|
|
210
208
|
return new user_record_1.UserRecord(response.users[0]);
|
|
211
209
|
});
|
|
212
|
-
}
|
|
210
|
+
}
|
|
213
211
|
/**
|
|
214
212
|
* Gets the user data corresponding to the specified identifiers.
|
|
215
213
|
*
|
|
@@ -225,30 +223,30 @@ var BaseAuth = /** @class */ (function () {
|
|
|
225
223
|
* @throws FirebaseAuthError If any of the identifiers are invalid or if more than 100
|
|
226
224
|
* identifiers are specified.
|
|
227
225
|
*/
|
|
228
|
-
|
|
226
|
+
getUsers(identifiers) {
|
|
229
227
|
if (!validator.isArray(identifiers)) {
|
|
230
228
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, '`identifiers` parameter must be an array');
|
|
231
229
|
}
|
|
232
230
|
return this.authRequestHandler
|
|
233
231
|
.getAccountInfoByIdentifiers(identifiers)
|
|
234
|
-
.then(
|
|
232
|
+
.then((response) => {
|
|
235
233
|
/**
|
|
236
234
|
* Checks if the specified identifier is within the list of
|
|
237
235
|
* UserRecords.
|
|
238
236
|
*/
|
|
239
|
-
|
|
240
|
-
return !!userRecords.find(
|
|
241
|
-
if (identifier_1.isUidIdentifier(id)) {
|
|
237
|
+
const isUserFound = ((id, userRecords) => {
|
|
238
|
+
return !!userRecords.find((userRecord) => {
|
|
239
|
+
if ((0, identifier_1.isUidIdentifier)(id)) {
|
|
242
240
|
return id.uid === userRecord.uid;
|
|
243
241
|
}
|
|
244
|
-
else if (identifier_1.isEmailIdentifier(id)) {
|
|
242
|
+
else if ((0, identifier_1.isEmailIdentifier)(id)) {
|
|
245
243
|
return id.email === userRecord.email;
|
|
246
244
|
}
|
|
247
|
-
else if (identifier_1.isPhoneIdentifier(id)) {
|
|
245
|
+
else if ((0, identifier_1.isPhoneIdentifier)(id)) {
|
|
248
246
|
return id.phoneNumber === userRecord.phoneNumber;
|
|
249
247
|
}
|
|
250
|
-
else if (identifier_1.isProviderIdentifier(id)) {
|
|
251
|
-
|
|
248
|
+
else if ((0, identifier_1.isProviderIdentifier)(id)) {
|
|
249
|
+
const matchingUserInfo = userRecord.providerData.find((userInfo) => {
|
|
252
250
|
return id.providerId === userInfo.providerId;
|
|
253
251
|
});
|
|
254
252
|
return !!matchingUserInfo && id.providerUid === matchingUserInfo.uid;
|
|
@@ -258,11 +256,11 @@ var BaseAuth = /** @class */ (function () {
|
|
|
258
256
|
}
|
|
259
257
|
});
|
|
260
258
|
});
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return { users
|
|
259
|
+
const users = response.users ? response.users.map((user) => new user_record_1.UserRecord(user)) : [];
|
|
260
|
+
const notFound = identifiers.filter((id) => !isUserFound(id, users));
|
|
261
|
+
return { users, notFound };
|
|
264
262
|
});
|
|
265
|
-
}
|
|
263
|
+
}
|
|
266
264
|
/**
|
|
267
265
|
* Retrieves a list of users (single batch only) with a size of `maxResults`
|
|
268
266
|
* starting from the offset as specified by `pageToken`. This is used to
|
|
@@ -278,18 +276,18 @@ var BaseAuth = /** @class */ (function () {
|
|
|
278
276
|
* @returns A promise that resolves with
|
|
279
277
|
* the current batch of downloaded users and the next page token.
|
|
280
278
|
*/
|
|
281
|
-
|
|
279
|
+
listUsers(maxResults, pageToken) {
|
|
282
280
|
return this.authRequestHandler.downloadAccount(maxResults, pageToken)
|
|
283
|
-
.then(
|
|
281
|
+
.then((response) => {
|
|
284
282
|
// List of users to return.
|
|
285
|
-
|
|
283
|
+
const users = [];
|
|
286
284
|
// Convert each user response to a UserRecord.
|
|
287
|
-
response.users.forEach(
|
|
285
|
+
response.users.forEach((userResponse) => {
|
|
288
286
|
users.push(new user_record_1.UserRecord(userResponse));
|
|
289
287
|
});
|
|
290
288
|
// Return list of user records and the next page token if available.
|
|
291
|
-
|
|
292
|
-
users
|
|
289
|
+
const result = {
|
|
290
|
+
users,
|
|
293
291
|
pageToken: response.nextPageToken,
|
|
294
292
|
};
|
|
295
293
|
// Delete result.pageToken if undefined.
|
|
@@ -298,7 +296,7 @@ var BaseAuth = /** @class */ (function () {
|
|
|
298
296
|
}
|
|
299
297
|
return result;
|
|
300
298
|
});
|
|
301
|
-
}
|
|
299
|
+
}
|
|
302
300
|
/**
|
|
303
301
|
* Creates a new user.
|
|
304
302
|
*
|
|
@@ -311,21 +309,20 @@ var BaseAuth = /** @class */ (function () {
|
|
|
311
309
|
* @returns A promise fulfilled with the user
|
|
312
310
|
* data corresponding to the newly created user.
|
|
313
311
|
*/
|
|
314
|
-
|
|
315
|
-
var _this = this;
|
|
312
|
+
createUser(properties) {
|
|
316
313
|
return this.authRequestHandler.createNewAccount(properties)
|
|
317
|
-
.then(
|
|
314
|
+
.then((uid) => {
|
|
318
315
|
// Return the corresponding user record.
|
|
319
|
-
return
|
|
316
|
+
return this.getUser(uid);
|
|
320
317
|
})
|
|
321
|
-
.catch(
|
|
318
|
+
.catch((error) => {
|
|
322
319
|
if (error.code === 'auth/user-not-found') {
|
|
323
320
|
// Something must have happened after creating the user and then retrieving it.
|
|
324
321
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'Unable to create the user record provided.');
|
|
325
322
|
}
|
|
326
323
|
throw error;
|
|
327
324
|
});
|
|
328
|
-
}
|
|
325
|
+
}
|
|
329
326
|
/**
|
|
330
327
|
* Deletes an existing user.
|
|
331
328
|
*
|
|
@@ -337,12 +334,12 @@ var BaseAuth = /** @class */ (function () {
|
|
|
337
334
|
* @returns An empty promise fulfilled once the user has been
|
|
338
335
|
* deleted.
|
|
339
336
|
*/
|
|
340
|
-
|
|
337
|
+
deleteUser(uid) {
|
|
341
338
|
return this.authRequestHandler.deleteAccount(uid)
|
|
342
|
-
.then(
|
|
339
|
+
.then(() => {
|
|
343
340
|
// Return nothing on success.
|
|
344
341
|
});
|
|
345
|
-
}
|
|
342
|
+
}
|
|
346
343
|
/**
|
|
347
344
|
* Deletes the users specified by the given uids.
|
|
348
345
|
*
|
|
@@ -365,13 +362,13 @@ var BaseAuth = /** @class */ (function () {
|
|
|
365
362
|
* deletions, as well as the array of errors that corresponds to the
|
|
366
363
|
* failed deletions.
|
|
367
364
|
*/
|
|
368
|
-
|
|
365
|
+
deleteUsers(uids) {
|
|
369
366
|
if (!validator.isArray(uids)) {
|
|
370
367
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, '`uids` parameter must be an array');
|
|
371
368
|
}
|
|
372
369
|
return this.authRequestHandler.deleteAccounts(uids, /*force=*/ true)
|
|
373
|
-
.then(
|
|
374
|
-
|
|
370
|
+
.then((batchDeleteAccountsResponse) => {
|
|
371
|
+
const result = {
|
|
375
372
|
failureCount: 0,
|
|
376
373
|
successCount: uids.length,
|
|
377
374
|
errors: [],
|
|
@@ -381,14 +378,14 @@ var BaseAuth = /** @class */ (function () {
|
|
|
381
378
|
}
|
|
382
379
|
result.failureCount = batchDeleteAccountsResponse.errors.length;
|
|
383
380
|
result.successCount = uids.length - batchDeleteAccountsResponse.errors.length;
|
|
384
|
-
result.errors = batchDeleteAccountsResponse.errors.map(
|
|
381
|
+
result.errors = batchDeleteAccountsResponse.errors.map((batchDeleteErrorInfo) => {
|
|
385
382
|
if (batchDeleteErrorInfo.index === undefined) {
|
|
386
383
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'Corrupt BatchDeleteAccountsResponse detected');
|
|
387
384
|
}
|
|
388
|
-
|
|
385
|
+
const errMsgToError = (msg) => {
|
|
389
386
|
// We unconditionally set force=true, so the 'NOT_DISABLED' error
|
|
390
387
|
// should not be possible.
|
|
391
|
-
|
|
388
|
+
const code = msg && msg.startsWith('NOT_DISABLED') ?
|
|
392
389
|
error_1.AuthClientErrorCode.USER_NOT_DISABLED : error_1.AuthClientErrorCode.INTERNAL_ERROR;
|
|
393
390
|
return new error_1.FirebaseAuthError(code, batchDeleteErrorInfo.message);
|
|
394
391
|
};
|
|
@@ -399,7 +396,7 @@ var BaseAuth = /** @class */ (function () {
|
|
|
399
396
|
});
|
|
400
397
|
return result;
|
|
401
398
|
});
|
|
402
|
-
}
|
|
399
|
+
}
|
|
403
400
|
/**
|
|
404
401
|
* Updates an existing user.
|
|
405
402
|
*
|
|
@@ -413,16 +410,15 @@ var BaseAuth = /** @class */ (function () {
|
|
|
413
410
|
* @returns A promise fulfilled with the
|
|
414
411
|
* updated user data.
|
|
415
412
|
*/
|
|
416
|
-
|
|
417
|
-
var _this = this;
|
|
413
|
+
updateUser(uid, properties) {
|
|
418
414
|
// Although we don't really advertise it, we want to also handle linking of
|
|
419
415
|
// non-federated idps with this call. So if we detect one of them, we'll
|
|
420
416
|
// adjust the properties parameter appropriately. This *does* imply that a
|
|
421
417
|
// conflict could arise, e.g. if the user provides a phoneNumber property,
|
|
422
418
|
// but also provides a providerToLink with a 'phone' provider id. In that
|
|
423
419
|
// case, we'll throw an error.
|
|
424
|
-
properties = deep_copy_1.deepCopy(properties);
|
|
425
|
-
if (properties
|
|
420
|
+
properties = (0, deep_copy_1.deepCopy)(properties);
|
|
421
|
+
if (properties?.providerToLink) {
|
|
426
422
|
if (properties.providerToLink.providerId === 'email') {
|
|
427
423
|
if (typeof properties.email !== 'undefined') {
|
|
428
424
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "Both UpdateRequest.email and UpdateRequest.providerToLink.providerId='email' were set. To "
|
|
@@ -440,7 +436,7 @@ var BaseAuth = /** @class */ (function () {
|
|
|
440
436
|
delete properties.providerToLink;
|
|
441
437
|
}
|
|
442
438
|
}
|
|
443
|
-
if (properties
|
|
439
|
+
if (properties?.providersToUnlink) {
|
|
444
440
|
if (properties.providersToUnlink.indexOf('phone') !== -1) {
|
|
445
441
|
// If we've been told to unlink the phone provider both via setting
|
|
446
442
|
// phoneNumber to null *and* by setting providersToUnlink to include
|
|
@@ -453,11 +449,11 @@ var BaseAuth = /** @class */ (function () {
|
|
|
453
449
|
}
|
|
454
450
|
}
|
|
455
451
|
return this.authRequestHandler.updateExistingAccount(uid, properties)
|
|
456
|
-
.then(
|
|
452
|
+
.then((existingUid) => {
|
|
457
453
|
// Return the corresponding user record.
|
|
458
|
-
return
|
|
454
|
+
return this.getUser(existingUid);
|
|
459
455
|
});
|
|
460
|
-
}
|
|
456
|
+
}
|
|
461
457
|
/**
|
|
462
458
|
* Sets additional developer claims on an existing user identified by the
|
|
463
459
|
* provided `uid`, typically used to define user roles and levels of
|
|
@@ -481,12 +477,12 @@ var BaseAuth = /** @class */ (function () {
|
|
|
481
477
|
* @returns A promise that resolves when the operation completes
|
|
482
478
|
* successfully.
|
|
483
479
|
*/
|
|
484
|
-
|
|
480
|
+
setCustomUserClaims(uid, customUserClaims) {
|
|
485
481
|
return this.authRequestHandler.setCustomUserClaims(uid, customUserClaims)
|
|
486
|
-
.then(
|
|
482
|
+
.then(() => {
|
|
487
483
|
// Return nothing on success.
|
|
488
484
|
});
|
|
489
|
-
}
|
|
485
|
+
}
|
|
490
486
|
/**
|
|
491
487
|
* Revokes all refresh tokens for an existing user.
|
|
492
488
|
*
|
|
@@ -506,12 +502,12 @@ var BaseAuth = /** @class */ (function () {
|
|
|
506
502
|
* @returns An empty promise fulfilled once the user's refresh
|
|
507
503
|
* tokens have been revoked.
|
|
508
504
|
*/
|
|
509
|
-
|
|
505
|
+
revokeRefreshTokens(uid) {
|
|
510
506
|
return this.authRequestHandler.revokeRefreshTokens(uid)
|
|
511
|
-
.then(
|
|
507
|
+
.then(() => {
|
|
512
508
|
// Return nothing on success.
|
|
513
509
|
});
|
|
514
|
-
}
|
|
510
|
+
}
|
|
515
511
|
/**
|
|
516
512
|
* Imports the provided list of users into Firebase Auth.
|
|
517
513
|
* A maximum of 1000 users are allowed to be imported one at a time.
|
|
@@ -529,9 +525,9 @@ var BaseAuth = /** @class */ (function () {
|
|
|
529
525
|
* number of successful imports, the number of failed imports and their
|
|
530
526
|
* corresponding errors.
|
|
531
527
|
*/
|
|
532
|
-
|
|
528
|
+
importUsers(users, options) {
|
|
533
529
|
return this.authRequestHandler.uploadAccount(users, options);
|
|
534
|
-
}
|
|
530
|
+
}
|
|
535
531
|
/**
|
|
536
532
|
* Creates a new Firebase session cookie with the specified options. The created
|
|
537
533
|
* JWT string can be set as a server-side session cookie with a custom cookie
|
|
@@ -549,14 +545,14 @@ var BaseAuth = /** @class */ (function () {
|
|
|
549
545
|
* @returns A promise that resolves on success with the
|
|
550
546
|
* created session cookie.
|
|
551
547
|
*/
|
|
552
|
-
|
|
548
|
+
createSessionCookie(idToken, sessionCookieOptions) {
|
|
553
549
|
// Return rejected promise if expiresIn is not available.
|
|
554
550
|
if (!validator.isNonNullObject(sessionCookieOptions) ||
|
|
555
551
|
!validator.isNumber(sessionCookieOptions.expiresIn)) {
|
|
556
552
|
return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_SESSION_COOKIE_DURATION));
|
|
557
553
|
}
|
|
558
554
|
return this.authRequestHandler.createSessionCookie(idToken, sessionCookieOptions.expiresIn);
|
|
559
|
-
}
|
|
555
|
+
}
|
|
560
556
|
/**
|
|
561
557
|
* Verifies a Firebase session cookie. Returns a Promise with the cookie claims.
|
|
562
558
|
* Rejects the promise if the cookie could not be verified.
|
|
@@ -582,19 +578,17 @@ var BaseAuth = /** @class */ (function () {
|
|
|
582
578
|
* session cookie's decoded claims if the session cookie is valid; otherwise,
|
|
583
579
|
* a rejected promise.
|
|
584
580
|
*/
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
if (checkRevoked === void 0) { checkRevoked = false; }
|
|
588
|
-
var isEmulator = auth_api_request_1.useEmulator();
|
|
581
|
+
verifySessionCookie(sessionCookie, checkRevoked = false) {
|
|
582
|
+
const isEmulator = (0, auth_api_request_1.useEmulator)();
|
|
589
583
|
return this.sessionCookieVerifier.verifyJWT(sessionCookie, isEmulator)
|
|
590
|
-
.then(
|
|
584
|
+
.then((decodedIdToken) => {
|
|
591
585
|
// Whether to check if the token was revoked.
|
|
592
586
|
if (checkRevoked || isEmulator) {
|
|
593
|
-
return
|
|
587
|
+
return this.verifyDecodedJWTNotRevokedOrDisabled(decodedIdToken, error_1.AuthClientErrorCode.SESSION_COOKIE_REVOKED);
|
|
594
588
|
}
|
|
595
589
|
return decodedIdToken;
|
|
596
590
|
});
|
|
597
|
-
}
|
|
591
|
+
}
|
|
598
592
|
/**
|
|
599
593
|
* Generates the out of band email action link to reset a user's password.
|
|
600
594
|
* The link is generated for the user with the specified email address. The
|
|
@@ -644,9 +638,9 @@ var BaseAuth = /** @class */ (function () {
|
|
|
644
638
|
* are configured in the same Firebase Auth project.
|
|
645
639
|
* @returns A promise that resolves with the generated link.
|
|
646
640
|
*/
|
|
647
|
-
|
|
641
|
+
generatePasswordResetLink(email, actionCodeSettings) {
|
|
648
642
|
return this.authRequestHandler.getEmailActionLink('PASSWORD_RESET', email, actionCodeSettings);
|
|
649
|
-
}
|
|
643
|
+
}
|
|
650
644
|
/**
|
|
651
645
|
* Generates the out of band email action link to verify the user's ownership
|
|
652
646
|
* of the specified email. The {@link ActionCodeSettings} object provided
|
|
@@ -695,9 +689,9 @@ var BaseAuth = /** @class */ (function () {
|
|
|
695
689
|
* are configured in the same Firebase Auth project.
|
|
696
690
|
* @returns A promise that resolves with the generated link.
|
|
697
691
|
*/
|
|
698
|
-
|
|
692
|
+
generateEmailVerificationLink(email, actionCodeSettings) {
|
|
699
693
|
return this.authRequestHandler.getEmailActionLink('VERIFY_EMAIL', email, actionCodeSettings);
|
|
700
|
-
}
|
|
694
|
+
}
|
|
701
695
|
/**
|
|
702
696
|
* Generates an out-of-band email action link to verify the user's ownership
|
|
703
697
|
* of the specified email. The {@link ActionCodeSettings} object provided
|
|
@@ -722,9 +716,9 @@ var BaseAuth = /** @class */ (function () {
|
|
|
722
716
|
* are configured in the same Firebase Auth project.
|
|
723
717
|
* @returns A promise that resolves with the generated link.
|
|
724
718
|
*/
|
|
725
|
-
|
|
719
|
+
generateVerifyAndChangeEmailLink(email, newEmail, actionCodeSettings) {
|
|
726
720
|
return this.authRequestHandler.getEmailActionLink('VERIFY_AND_CHANGE_EMAIL', email, actionCodeSettings, newEmail);
|
|
727
|
-
}
|
|
721
|
+
}
|
|
728
722
|
/**
|
|
729
723
|
* Generates the out of band email action link to verify the user's ownership
|
|
730
724
|
* of the specified email. The {@link ActionCodeSettings} object provided
|
|
@@ -773,9 +767,9 @@ var BaseAuth = /** @class */ (function () {
|
|
|
773
767
|
* are configured in the same Firebase Auth project.
|
|
774
768
|
* @returns A promise that resolves with the generated link.
|
|
775
769
|
*/
|
|
776
|
-
|
|
770
|
+
generateSignInWithEmailLink(email, actionCodeSettings) {
|
|
777
771
|
return this.authRequestHandler.getEmailActionLink('EMAIL_SIGNIN', email, actionCodeSettings);
|
|
778
|
-
}
|
|
772
|
+
}
|
|
779
773
|
/**
|
|
780
774
|
* Returns the list of existing provider configurations matching the filter
|
|
781
775
|
* provided. At most, 100 provider configs can be listed at a time.
|
|
@@ -788,11 +782,11 @@ var BaseAuth = /** @class */ (function () {
|
|
|
788
782
|
* @returns A promise that resolves with the list of provider configs meeting the
|
|
789
783
|
* filter requirements.
|
|
790
784
|
*/
|
|
791
|
-
|
|
792
|
-
|
|
785
|
+
listProviderConfigs(options) {
|
|
786
|
+
const processResponse = (response, providerConfigs) => {
|
|
793
787
|
// Return list of provider configuration and the next page token if available.
|
|
794
|
-
|
|
795
|
-
providerConfigs
|
|
788
|
+
const result = {
|
|
789
|
+
providerConfigs,
|
|
796
790
|
};
|
|
797
791
|
// Delete result.pageToken if undefined.
|
|
798
792
|
if (Object.prototype.hasOwnProperty.call(response, 'nextPageToken')) {
|
|
@@ -802,11 +796,11 @@ var BaseAuth = /** @class */ (function () {
|
|
|
802
796
|
};
|
|
803
797
|
if (options && options.type === 'oidc') {
|
|
804
798
|
return this.authRequestHandler.listOAuthIdpConfigs(options.maxResults, options.pageToken)
|
|
805
|
-
.then(
|
|
799
|
+
.then((response) => {
|
|
806
800
|
// List of provider configurations to return.
|
|
807
|
-
|
|
801
|
+
const providerConfigs = [];
|
|
808
802
|
// Convert each provider config response to a OIDCConfig.
|
|
809
|
-
response.oauthIdpConfigs.forEach(
|
|
803
|
+
response.oauthIdpConfigs.forEach((configResponse) => {
|
|
810
804
|
providerConfigs.push(new auth_config_1.OIDCConfig(configResponse));
|
|
811
805
|
});
|
|
812
806
|
// Return list of provider configuration and the next page token if available.
|
|
@@ -815,11 +809,11 @@ var BaseAuth = /** @class */ (function () {
|
|
|
815
809
|
}
|
|
816
810
|
else if (options && options.type === 'saml') {
|
|
817
811
|
return this.authRequestHandler.listInboundSamlConfigs(options.maxResults, options.pageToken)
|
|
818
|
-
.then(
|
|
812
|
+
.then((response) => {
|
|
819
813
|
// List of provider configurations to return.
|
|
820
|
-
|
|
814
|
+
const providerConfigs = [];
|
|
821
815
|
// Convert each provider config response to a SAMLConfig.
|
|
822
|
-
response.inboundSamlConfigs.forEach(
|
|
816
|
+
response.inboundSamlConfigs.forEach((configResponse) => {
|
|
823
817
|
providerConfigs.push(new auth_config_1.SAMLConfig(configResponse));
|
|
824
818
|
});
|
|
825
819
|
// Return list of provider configuration and the next page token if available.
|
|
@@ -827,7 +821,7 @@ var BaseAuth = /** @class */ (function () {
|
|
|
827
821
|
});
|
|
828
822
|
}
|
|
829
823
|
return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, '"AuthProviderConfigFilter.type" must be either "saml" or "oidc"'));
|
|
830
|
-
}
|
|
824
|
+
}
|
|
831
825
|
/**
|
|
832
826
|
* Looks up an Auth provider configuration by the provided ID.
|
|
833
827
|
* Returns a promise that resolves with the provider configuration
|
|
@@ -843,21 +837,21 @@ var BaseAuth = /** @class */ (function () {
|
|
|
843
837
|
* @returns A promise that resolves
|
|
844
838
|
* with the configuration corresponding to the provided ID.
|
|
845
839
|
*/
|
|
846
|
-
|
|
840
|
+
getProviderConfig(providerId) {
|
|
847
841
|
if (auth_config_1.OIDCConfig.isProviderId(providerId)) {
|
|
848
842
|
return this.authRequestHandler.getOAuthIdpConfig(providerId)
|
|
849
|
-
.then(
|
|
843
|
+
.then((response) => {
|
|
850
844
|
return new auth_config_1.OIDCConfig(response);
|
|
851
845
|
});
|
|
852
846
|
}
|
|
853
847
|
else if (auth_config_1.SAMLConfig.isProviderId(providerId)) {
|
|
854
848
|
return this.authRequestHandler.getInboundSamlConfig(providerId)
|
|
855
|
-
.then(
|
|
849
|
+
.then((response) => {
|
|
856
850
|
return new auth_config_1.SAMLConfig(response);
|
|
857
851
|
});
|
|
858
852
|
}
|
|
859
853
|
return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_PROVIDER_ID));
|
|
860
|
-
}
|
|
854
|
+
}
|
|
861
855
|
/**
|
|
862
856
|
* Deletes the provider configuration corresponding to the provider ID passed.
|
|
863
857
|
* If the specified ID does not exist, an `auth/configuration-not-found` error
|
|
@@ -871,7 +865,7 @@ var BaseAuth = /** @class */ (function () {
|
|
|
871
865
|
* config to delete.
|
|
872
866
|
* @returns A promise that resolves on completion.
|
|
873
867
|
*/
|
|
874
|
-
|
|
868
|
+
deleteProviderConfig(providerId) {
|
|
875
869
|
if (auth_config_1.OIDCConfig.isProviderId(providerId)) {
|
|
876
870
|
return this.authRequestHandler.deleteOAuthIdpConfig(providerId);
|
|
877
871
|
}
|
|
@@ -879,7 +873,7 @@ var BaseAuth = /** @class */ (function () {
|
|
|
879
873
|
return this.authRequestHandler.deleteInboundSamlConfig(providerId);
|
|
880
874
|
}
|
|
881
875
|
return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_PROVIDER_ID));
|
|
882
|
-
}
|
|
876
|
+
}
|
|
883
877
|
/**
|
|
884
878
|
* Returns a promise that resolves with the updated `AuthProviderConfig`
|
|
885
879
|
* corresponding to the provider ID specified.
|
|
@@ -895,24 +889,24 @@ var BaseAuth = /** @class */ (function () {
|
|
|
895
889
|
* @param updatedConfig - The updated configuration.
|
|
896
890
|
* @returns A promise that resolves with the updated provider configuration.
|
|
897
891
|
*/
|
|
898
|
-
|
|
892
|
+
updateProviderConfig(providerId, updatedConfig) {
|
|
899
893
|
if (!validator.isNonNullObject(updatedConfig)) {
|
|
900
894
|
return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, 'Request is missing "UpdateAuthProviderRequest" configuration.'));
|
|
901
895
|
}
|
|
902
896
|
if (auth_config_1.OIDCConfig.isProviderId(providerId)) {
|
|
903
897
|
return this.authRequestHandler.updateOAuthIdpConfig(providerId, updatedConfig)
|
|
904
|
-
.then(
|
|
898
|
+
.then((response) => {
|
|
905
899
|
return new auth_config_1.OIDCConfig(response);
|
|
906
900
|
});
|
|
907
901
|
}
|
|
908
902
|
else if (auth_config_1.SAMLConfig.isProviderId(providerId)) {
|
|
909
903
|
return this.authRequestHandler.updateInboundSamlConfig(providerId, updatedConfig)
|
|
910
|
-
.then(
|
|
904
|
+
.then((response) => {
|
|
911
905
|
return new auth_config_1.SAMLConfig(response);
|
|
912
906
|
});
|
|
913
907
|
}
|
|
914
908
|
return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_PROVIDER_ID));
|
|
915
|
-
}
|
|
909
|
+
}
|
|
916
910
|
/**
|
|
917
911
|
* Returns a promise that resolves with the newly created `AuthProviderConfig`
|
|
918
912
|
* when the new provider configuration is created.
|
|
@@ -924,33 +918,33 @@ var BaseAuth = /** @class */ (function () {
|
|
|
924
918
|
* @param config - The provider configuration to create.
|
|
925
919
|
* @returns A promise that resolves with the created provider configuration.
|
|
926
920
|
*/
|
|
927
|
-
|
|
921
|
+
createProviderConfig(config) {
|
|
928
922
|
if (!validator.isNonNullObject(config)) {
|
|
929
923
|
return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CONFIG, 'Request is missing "AuthProviderConfig" configuration.'));
|
|
930
924
|
}
|
|
931
925
|
if (auth_config_1.OIDCConfig.isProviderId(config.providerId)) {
|
|
932
926
|
return this.authRequestHandler.createOAuthIdpConfig(config)
|
|
933
|
-
.then(
|
|
927
|
+
.then((response) => {
|
|
934
928
|
return new auth_config_1.OIDCConfig(response);
|
|
935
929
|
});
|
|
936
930
|
}
|
|
937
931
|
else if (auth_config_1.SAMLConfig.isProviderId(config.providerId)) {
|
|
938
932
|
return this.authRequestHandler.createInboundSamlConfig(config)
|
|
939
|
-
.then(
|
|
933
|
+
.then((response) => {
|
|
940
934
|
return new auth_config_1.SAMLConfig(response);
|
|
941
935
|
});
|
|
942
936
|
}
|
|
943
937
|
return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_PROVIDER_ID));
|
|
944
|
-
}
|
|
938
|
+
}
|
|
945
939
|
/** @alpha */
|
|
946
940
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
947
|
-
|
|
948
|
-
|
|
941
|
+
_verifyAuthBlockingToken(token, audience) {
|
|
942
|
+
const isEmulator = (0, auth_api_request_1.useEmulator)();
|
|
949
943
|
return this.authBlockingTokenVerifier._verifyAuthBlockingToken(token, isEmulator, audience)
|
|
950
|
-
.then(
|
|
944
|
+
.then((decodedAuthBlockingToken) => {
|
|
951
945
|
return decodedAuthBlockingToken;
|
|
952
946
|
});
|
|
953
|
-
}
|
|
947
|
+
}
|
|
954
948
|
/**
|
|
955
949
|
* Verifies the decoded Firebase issued JWT is not revoked or disabled. Returns a promise that
|
|
956
950
|
* resolves with the decoded claims on success. Rejects the promise with revocation error if revoked
|
|
@@ -961,19 +955,19 @@ var BaseAuth = /** @class */ (function () {
|
|
|
961
955
|
* detection.
|
|
962
956
|
* @returns A promise that will be fulfilled after a successful verification.
|
|
963
957
|
*/
|
|
964
|
-
|
|
958
|
+
verifyDecodedJWTNotRevokedOrDisabled(decodedIdToken, revocationErrorInfo) {
|
|
965
959
|
// Get tokens valid after time for the corresponding user.
|
|
966
960
|
return this.getUser(decodedIdToken.sub)
|
|
967
|
-
.then(
|
|
961
|
+
.then((user) => {
|
|
968
962
|
if (user.disabled) {
|
|
969
963
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.USER_DISABLED, 'The user record is disabled.');
|
|
970
964
|
}
|
|
971
965
|
// If no tokens valid after time available, token is not revoked.
|
|
972
966
|
if (user.tokensValidAfterTime) {
|
|
973
967
|
// Get the ID token authentication time and convert to milliseconds UTC.
|
|
974
|
-
|
|
968
|
+
const authTimeUtc = decodedIdToken.auth_time * 1000;
|
|
975
969
|
// Get user tokens valid after time in milliseconds UTC.
|
|
976
|
-
|
|
970
|
+
const validSinceUtc = new Date(user.tokensValidAfterTime).getTime();
|
|
977
971
|
// Check if authentication time is older than valid since time.
|
|
978
972
|
if (authTimeUtc < validSinceUtc) {
|
|
979
973
|
throw new error_1.FirebaseAuthError(revocationErrorInfo);
|
|
@@ -982,7 +976,6 @@ var BaseAuth = /** @class */ (function () {
|
|
|
982
976
|
// All checks above passed. Return the decoded token.
|
|
983
977
|
return decodedIdToken;
|
|
984
978
|
});
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
}());
|
|
979
|
+
}
|
|
980
|
+
}
|
|
988
981
|
exports.BaseAuth = BaseAuth;
|