firebase-admin 13.9.0 → 14.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 +2 -38
- package/lib/app/core.js +1 -1
- package/lib/app/credential-factory.d.ts +1 -1
- package/lib/app/credential-factory.js +1 -1
- package/lib/app/credential-internal.d.ts +1 -1
- package/lib/app/credential-internal.js +48 -17
- package/lib/app/credential.d.ts +1 -1
- package/lib/app/credential.js +1 -1
- package/lib/app/error.d.ts +47 -0
- package/lib/app/error.js +57 -0
- package/lib/app/firebase-app.d.ts +1 -1
- package/lib/app/firebase-app.js +28 -12
- package/lib/app/index.d.ts +4 -3
- package/lib/app/index.js +6 -4
- package/lib/app/lifecycle.d.ts +2 -2
- package/lib/app/lifecycle.js +46 -21
- package/lib/app-check/app-check-api-client-internal.d.ts +2 -16
- package/lib/app-check/app-check-api-client-internal.js +71 -47
- package/lib/app-check/app-check-api.d.ts +19 -1
- package/lib/app-check/app-check-api.js +1 -1
- package/lib/app-check/app-check.d.ts +1 -1
- package/lib/app-check/app-check.js +7 -3
- package/lib/app-check/error.d.ts +47 -0
- package/lib/app-check/error.js +65 -0
- package/lib/app-check/index.d.ts +2 -1
- package/lib/app-check/index.js +5 -2
- package/lib/app-check/token-generator.d.ts +1 -1
- package/lib/app-check/token-generator.js +43 -13
- package/lib/app-check/token-verifier.d.ts +1 -1
- package/lib/app-check/token-verifier.js +39 -11
- package/lib/auth/action-code-settings-builder.d.ts +1 -1
- package/lib/auth/action-code-settings-builder.js +16 -16
- package/lib/auth/auth-api-request.d.ts +6 -4
- package/lib/auth/auth-api-request.js +277 -166
- package/lib/auth/auth-config.d.ts +31 -2
- package/lib/auth/auth-config.js +103 -103
- package/lib/auth/auth.d.ts +1 -1
- package/lib/auth/auth.js +1 -1
- package/lib/auth/base-auth.d.ts +2 -1
- package/lib/auth/base-auth.js +29 -27
- package/lib/auth/error.d.ts +137 -0
- package/lib/auth/error.js +690 -0
- package/lib/auth/identifier.d.ts +1 -1
- package/lib/auth/identifier.js +1 -1
- package/lib/auth/index.d.ts +2 -2
- package/lib/auth/index.js +4 -4
- package/lib/auth/project-config-manager.d.ts +1 -1
- package/lib/auth/project-config-manager.js +1 -1
- package/lib/auth/project-config.d.ts +1 -1
- package/lib/auth/project-config.js +4 -4
- package/lib/auth/tenant-manager.d.ts +2 -1
- package/lib/auth/tenant-manager.js +13 -10
- package/lib/auth/tenant.d.ts +1 -1
- package/lib/auth/tenant.js +7 -7
- package/lib/auth/token-generator.d.ts +1 -1
- package/lib/auth/token-generator.js +13 -13
- package/lib/auth/token-verifier.d.ts +1 -1
- package/lib/auth/token-verifier.js +22 -22
- package/lib/auth/user-import-builder.d.ts +1 -1
- package/lib/auth/user-import-builder.js +22 -22
- package/lib/auth/user-record.d.ts +1 -1
- package/lib/auth/user-record.js +6 -6
- package/lib/credential/index.d.ts +1 -1
- package/lib/credential/index.js +1 -1
- package/lib/data-connect/data-connect-api-client-internal.d.ts +1 -16
- package/lib/data-connect/data-connect-api-client-internal.js +122 -65
- package/lib/data-connect/data-connect-api.d.ts +1 -1
- package/lib/data-connect/data-connect-api.js +1 -1
- package/lib/data-connect/data-connect.d.ts +1 -1
- package/lib/data-connect/data-connect.js +1 -1
- package/lib/data-connect/error.d.ts +47 -0
- package/lib/data-connect/error.js +66 -0
- package/lib/data-connect/index.d.ts +2 -1
- package/lib/data-connect/index.js +5 -2
- package/lib/data-connect/validate-admin-args.d.ts +1 -1
- package/lib/data-connect/validate-admin-args.js +6 -3
- package/lib/database/database.d.ts +1 -1
- package/lib/database/database.js +11 -6
- package/lib/database/error.d.ts +39 -0
- package/lib/database/error.js +49 -0
- package/lib/database/index.d.ts +2 -2
- package/lib/database/index.js +4 -3
- package/lib/esm/app/index.js +2 -1
- package/lib/esm/app-check/index.js +2 -0
- package/lib/esm/auth/index.js +1 -1
- package/lib/esm/data-connect/index.js +2 -0
- package/lib/esm/database/index.js +1 -0
- package/lib/esm/eventarc/index.js +2 -0
- package/lib/esm/extensions/index.js +2 -0
- package/lib/esm/firebase-admin/index.js +13 -0
- package/lib/esm/firestore/index.js +1 -0
- package/lib/esm/functions/index.js +2 -0
- package/lib/esm/installations/index.js +1 -1
- package/lib/esm/machine-learning/index.js +2 -0
- package/lib/esm/messaging/index.js +1 -1
- package/lib/esm/phone-number-verification/index.js +2 -0
- package/lib/esm/project-management/index.js +1 -0
- package/lib/esm/remote-config/index.js +2 -0
- package/lib/esm/security-rules/index.js +2 -0
- package/lib/esm/storage/index.js +2 -0
- package/lib/eventarc/cloudevent.d.ts +1 -1
- package/lib/eventarc/cloudevent.js +1 -1
- package/lib/eventarc/error.d.ts +38 -0
- package/lib/eventarc/error.js +47 -0
- package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
- package/lib/eventarc/eventarc-client-internal.js +24 -9
- package/lib/eventarc/eventarc-utils.d.ts +1 -13
- package/lib/eventarc/eventarc-utils.js +36 -26
- package/lib/eventarc/eventarc.d.ts +1 -1
- package/lib/eventarc/eventarc.js +18 -6
- package/lib/eventarc/index.d.ts +2 -1
- package/lib/eventarc/index.js +5 -2
- package/lib/extensions/error.d.ts +41 -0
- package/lib/extensions/error.js +50 -0
- package/lib/extensions/extensions-api-client-internal.d.ts +1 -13
- package/lib/extensions/extensions-api-client-internal.js +40 -28
- package/lib/extensions/extensions-api.d.ts +1 -1
- package/lib/extensions/extensions-api.js +1 -1
- package/lib/extensions/extensions.d.ts +1 -1
- package/lib/extensions/extensions.js +18 -5
- package/lib/extensions/index.d.ts +2 -1
- package/lib/extensions/index.js +5 -2
- package/lib/firestore/error.d.ts +41 -0
- package/lib/firestore/error.js +51 -0
- package/lib/firestore/firestore-internal.d.ts +2 -1
- package/lib/firestore/firestore-internal.js +6 -6
- package/lib/firestore/index.d.ts +2 -2
- package/lib/firestore/index.js +7 -7
- package/lib/functions/error.d.ts +48 -0
- package/lib/functions/error.js +67 -0
- package/lib/functions/functions-api-client-internal.d.ts +1 -16
- package/lib/functions/functions-api-client-internal.js +111 -71
- 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 +14 -4
- package/lib/functions/index.d.ts +2 -1
- package/lib/functions/index.js +5 -2
- package/lib/index.d.ts +13 -8
- package/lib/index.js +19 -3
- package/lib/installations/error.d.ts +48 -0
- package/lib/installations/error.js +73 -0
- package/lib/installations/index.d.ts +2 -2
- package/lib/installations/index.js +4 -4
- package/lib/installations/installations-request-handler.d.ts +1 -1
- package/lib/installations/installations-request-handler.js +11 -5
- package/lib/installations/installations.d.ts +1 -1
- package/lib/installations/installations.js +3 -3
- package/lib/machine-learning/error.d.ts +53 -0
- package/lib/machine-learning/error.js +84 -0
- package/lib/machine-learning/index.d.ts +2 -1
- package/lib/machine-learning/index.js +5 -2
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +61 -24
- package/lib/machine-learning/machine-learning.d.ts +1 -1
- package/lib/machine-learning/machine-learning.js +21 -9
- package/lib/messaging/error.d.ts +63 -0
- package/lib/messaging/error.js +286 -0
- package/lib/messaging/index.d.ts +3 -3
- package/lib/messaging/index.js +4 -4
- package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
- package/lib/messaging/messaging-api-request-internal.js +1 -1
- package/lib/messaging/messaging-api.d.ts +1 -280
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +2 -2
- package/lib/messaging/messaging-errors-internal.js +11 -8
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +48 -48
- package/lib/messaging/messaging.d.ts +1 -1
- package/lib/messaging/messaging.js +47 -50
- package/lib/phone-number-verification/error.d.ts +43 -0
- package/lib/phone-number-verification/error.js +48 -0
- package/lib/phone-number-verification/index.d.ts +2 -1
- package/lib/phone-number-verification/index.js +5 -2
- package/lib/phone-number-verification/phone-number-verification-api-client-internal.d.ts +1 -18
- package/lib/phone-number-verification/phone-number-verification-api-client-internal.js +2 -26
- package/lib/phone-number-verification/phone-number-verification-api.d.ts +2 -2
- package/lib/phone-number-verification/phone-number-verification-api.js +5 -4
- package/lib/phone-number-verification/phone-number-verification.d.ts +1 -1
- package/lib/phone-number-verification/phone-number-verification.js +1 -1
- package/lib/phone-number-verification/token-verifier.d.ts +1 -1
- package/lib/phone-number-verification/token-verifier.js +68 -20
- package/lib/project-management/android-app.d.ts +1 -1
- package/lib/project-management/android-app.js +15 -6
- package/lib/project-management/app-metadata.d.ts +1 -1
- package/lib/project-management/app-metadata.js +1 -1
- package/lib/project-management/error.d.ts +45 -0
- package/lib/project-management/error.js +55 -0
- package/lib/project-management/index.d.ts +2 -2
- package/lib/project-management/index.js +4 -3
- package/lib/project-management/ios-app.d.ts +1 -1
- package/lib/project-management/ios-app.js +6 -3
- package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
- package/lib/project-management/project-management-api-request-internal.js +18 -6
- package/lib/project-management/project-management.d.ts +1 -1
- package/lib/project-management/project-management.js +13 -7
- package/lib/remote-config/condition-evaluator-internal.d.ts +1 -1
- package/lib/remote-config/condition-evaluator-internal.js +4 -4
- package/lib/remote-config/error.d.ts +49 -0
- package/lib/remote-config/error.js +70 -0
- package/lib/remote-config/index.d.ts +2 -1
- package/lib/remote-config/index.js +5 -2
- package/lib/remote-config/internal/value-impl.d.ts +1 -1
- package/lib/remote-config/internal/value-impl.js +1 -1
- package/lib/remote-config/remote-config-api-client-internal.d.ts +2 -13
- package/lib/remote-config/remote-config-api-client-internal.js +80 -52
- 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.d.ts +1 -1
- package/lib/remote-config/remote-config.js +92 -23
- package/lib/security-rules/error.d.ts +45 -0
- package/lib/security-rules/error.js +54 -0
- package/lib/security-rules/index.d.ts +2 -1
- package/lib/security-rules/index.js +5 -2
- package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-api-client-internal.js +50 -18
- package/lib/security-rules/security-rules.d.ts +1 -1
- package/lib/security-rules/security-rules.js +32 -11
- package/lib/storage/error.d.ts +41 -0
- package/lib/storage/error.js +50 -0
- package/lib/storage/index.d.ts +2 -1
- package/lib/storage/index.js +8 -5
- package/lib/storage/storage.d.ts +1 -1
- package/lib/storage/storage.js +12 -12
- package/lib/storage/utils.d.ts +1 -1
- package/lib/storage/utils.js +1 -1
- package/lib/utils/api-request.d.ts +12 -12
- package/lib/utils/api-request.js +97 -55
- package/lib/utils/crypto-signer.d.ts +1 -1
- package/lib/utils/crypto-signer.js +2 -7
- package/lib/utils/deep-copy.d.ts +1 -1
- package/lib/utils/deep-copy.js +1 -1
- package/lib/utils/error.d.ts +75 -570
- package/lib/utils/error.js +53 -1047
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +2 -2
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/jwt.js +1 -2
- package/lib/utils/validator.d.ts +1 -1
- package/lib/utils/validator.js +1 -1
- package/package.json +25 -33
- package/lib/app/firebase-namespace.d.ts +0 -163
- package/lib/app/firebase-namespace.js +0 -335
- package/lib/app-check/app-check-namespace.d.ts +0 -72
- package/lib/app-check/app-check-namespace.js +0 -18
- package/lib/auth/auth-namespace.d.ts +0 -257
- package/lib/auth/auth-namespace.js +0 -18
- package/lib/database/database-namespace.d.ts +0 -95
- package/lib/database/database-namespace.js +0 -23
- package/lib/default-namespace.d.ts +0 -24
- package/lib/default-namespace.js +0 -30
- package/lib/esm/instance-id/index.js +0 -6
- package/lib/firebase-namespace-api.d.ts +0 -91
- package/lib/firebase-namespace-api.js +0 -58
- package/lib/firestore/firestore-namespace.d.ts +0 -71
- package/lib/firestore/firestore-namespace.js +0 -52
- package/lib/installations/installations-namespace.d.ts +0 -55
- package/lib/installations/installations-namespace.js +0 -18
- package/lib/instance-id/index.d.ts +0 -62
- package/lib/instance-id/index.js +0 -74
- package/lib/instance-id/instance-id-namespace.d.ts +0 -38
- package/lib/instance-id/instance-id-namespace.js +0 -3
- package/lib/instance-id/instance-id.d.ts +0 -47
- package/lib/instance-id/instance-id.js +0 -77
- package/lib/machine-learning/machine-learning-namespace.d.ts +0 -81
- package/lib/machine-learning/machine-learning-namespace.js +0 -18
- package/lib/machine-learning/machine-learning-utils.d.ts +0 -22
- package/lib/machine-learning/machine-learning-utils.js +0 -47
- package/lib/messaging/messaging-namespace.d.ts +0 -161
- package/lib/messaging/messaging-namespace.js +0 -18
- package/lib/project-management/project-management-namespace.d.ts +0 -82
- package/lib/project-management/project-management-namespace.js +0 -18
- package/lib/remote-config/remote-config-namespace.d.ts +0 -141
- package/lib/remote-config/remote-config-namespace.js +0 -18
- package/lib/security-rules/security-rules-internal.d.ts +0 -21
- package/lib/security-rules/security-rules-internal.js +0 -26
- package/lib/security-rules/security-rules-namespace.d.ts +0 -69
- package/lib/security-rules/security-rules-namespace.js +0 -18
- package/lib/storage/storage-namespace.d.ts +0 -45
- package/lib/storage/storage-namespace.js +0 -18
package/lib/auth/auth.d.ts
CHANGED
package/lib/auth/auth.js
CHANGED
package/lib/auth/base-auth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
/*!
|
|
3
3
|
* Copyright 2021 Google LLC
|
|
4
4
|
*
|
|
@@ -85,6 +85,7 @@ export interface SessionCookieOptions {
|
|
|
85
85
|
* Common parent interface for both `Auth` and `TenantAwareAuth` APIs.
|
|
86
86
|
*/
|
|
87
87
|
export declare abstract class BaseAuth {
|
|
88
|
+
private readonly emulatorMode;
|
|
88
89
|
/**
|
|
89
90
|
* Creates a new Firebase custom token (JWT) that can be sent back to a client
|
|
90
91
|
* device to use to sign in with the client SDKs' `signInWithCustomToken()`
|
package/lib/auth/base-auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2021 Google LLC
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.BaseAuth = void 0;
|
|
20
20
|
exports.createFirebaseTokenGenerator = createFirebaseTokenGenerator;
|
|
21
|
-
const error_1 = require("
|
|
21
|
+
const error_1 = require("./error");
|
|
22
22
|
const deep_copy_1 = require("../utils/deep-copy");
|
|
23
23
|
const validator = require("../utils/validator");
|
|
24
24
|
const auth_api_request_1 = require("./auth-api-request");
|
|
@@ -31,9 +31,10 @@ const crypto_signer_1 = require("../utils/crypto-signer");
|
|
|
31
31
|
/**
|
|
32
32
|
* @internal
|
|
33
33
|
*/
|
|
34
|
-
function createFirebaseTokenGenerator(app, tenantId) {
|
|
34
|
+
function createFirebaseTokenGenerator(app, tenantId, isEmulator) {
|
|
35
35
|
try {
|
|
36
|
-
const
|
|
36
|
+
const shouldEmulate = isEmulator !== undefined ? isEmulator : (0, auth_api_request_1.useEmulator)();
|
|
37
|
+
const signer = shouldEmulate ? new token_generator_1.EmulatedSigner() : (0, crypto_signer_1.cryptoSignerFromApp)(app);
|
|
37
38
|
return new token_generator_1.FirebaseTokenGenerator(signer, tenantId);
|
|
38
39
|
}
|
|
39
40
|
catch (err) {
|
|
@@ -58,6 +59,7 @@ class BaseAuth {
|
|
|
58
59
|
constructor(app,
|
|
59
60
|
/** @internal */ authRequestHandler, tokenGenerator) {
|
|
60
61
|
this.authRequestHandler = authRequestHandler;
|
|
62
|
+
this.emulatorMode = !!this.authRequestHandler.emulatorHostValue;
|
|
61
63
|
if (tokenGenerator) {
|
|
62
64
|
this.tokenGenerator = tokenGenerator;
|
|
63
65
|
}
|
|
@@ -112,12 +114,12 @@ class BaseAuth {
|
|
|
112
114
|
* promise.
|
|
113
115
|
*/
|
|
114
116
|
verifyIdToken(idToken, checkRevoked = false) {
|
|
115
|
-
const isEmulator =
|
|
117
|
+
const isEmulator = this.emulatorMode;
|
|
116
118
|
return this.idTokenVerifier.verifyJWT(idToken, isEmulator)
|
|
117
119
|
.then((decodedIdToken) => {
|
|
118
120
|
// Whether to check if the token was revoked.
|
|
119
121
|
if (checkRevoked || isEmulator) {
|
|
120
|
-
return this.verifyDecodedJWTNotRevokedOrDisabled(decodedIdToken, error_1.
|
|
122
|
+
return this.verifyDecodedJWTNotRevokedOrDisabled(decodedIdToken, error_1.authClientErrorCode.ID_TOKEN_REVOKED);
|
|
121
123
|
}
|
|
122
124
|
return decodedIdToken;
|
|
123
125
|
});
|
|
@@ -225,7 +227,7 @@ class BaseAuth {
|
|
|
225
227
|
*/
|
|
226
228
|
getUsers(identifiers) {
|
|
227
229
|
if (!validator.isArray(identifiers)) {
|
|
228
|
-
throw new error_1.FirebaseAuthError(error_1.
|
|
230
|
+
throw new error_1.FirebaseAuthError(error_1.authClientErrorCode.INVALID_ARGUMENT, '`identifiers` parameter must be an array');
|
|
229
231
|
}
|
|
230
232
|
return this.authRequestHandler
|
|
231
233
|
.getAccountInfoByIdentifiers(identifiers)
|
|
@@ -252,7 +254,7 @@ class BaseAuth {
|
|
|
252
254
|
return !!matchingUserInfo && id.providerUid === matchingUserInfo.uid;
|
|
253
255
|
}
|
|
254
256
|
else {
|
|
255
|
-
throw new error_1.FirebaseAuthError(error_1.
|
|
257
|
+
throw new error_1.FirebaseAuthError(error_1.authClientErrorCode.INTERNAL_ERROR, 'Unhandled identifier type');
|
|
256
258
|
}
|
|
257
259
|
});
|
|
258
260
|
});
|
|
@@ -318,7 +320,7 @@ class BaseAuth {
|
|
|
318
320
|
.catch((error) => {
|
|
319
321
|
if (error.code === 'auth/user-not-found') {
|
|
320
322
|
// Something must have happened after creating the user and then retrieving it.
|
|
321
|
-
throw new error_1.FirebaseAuthError(error_1.
|
|
323
|
+
throw new error_1.FirebaseAuthError(error_1.authClientErrorCode.INTERNAL_ERROR, 'Unable to create the user record provided.');
|
|
322
324
|
}
|
|
323
325
|
throw error;
|
|
324
326
|
});
|
|
@@ -364,7 +366,7 @@ class BaseAuth {
|
|
|
364
366
|
*/
|
|
365
367
|
deleteUsers(uids) {
|
|
366
368
|
if (!validator.isArray(uids)) {
|
|
367
|
-
throw new error_1.FirebaseAuthError(error_1.
|
|
369
|
+
throw new error_1.FirebaseAuthError(error_1.authClientErrorCode.INVALID_ARGUMENT, '`uids` parameter must be an array');
|
|
368
370
|
}
|
|
369
371
|
return this.authRequestHandler.deleteAccounts(uids, /*force=*/ true)
|
|
370
372
|
.then((batchDeleteAccountsResponse) => {
|
|
@@ -380,13 +382,13 @@ class BaseAuth {
|
|
|
380
382
|
result.successCount = uids.length - batchDeleteAccountsResponse.errors.length;
|
|
381
383
|
result.errors = batchDeleteAccountsResponse.errors.map((batchDeleteErrorInfo) => {
|
|
382
384
|
if (batchDeleteErrorInfo.index === undefined) {
|
|
383
|
-
throw new error_1.FirebaseAuthError(error_1.
|
|
385
|
+
throw new error_1.FirebaseAuthError(error_1.authClientErrorCode.INTERNAL_ERROR, 'Corrupt BatchDeleteAccountsResponse detected');
|
|
384
386
|
}
|
|
385
387
|
const errMsgToError = (msg) => {
|
|
386
388
|
// We unconditionally set force=true, so the 'NOT_DISABLED' error
|
|
387
389
|
// should not be possible.
|
|
388
390
|
const code = msg && msg.startsWith('NOT_DISABLED') ?
|
|
389
|
-
error_1.
|
|
391
|
+
error_1.authClientErrorCode.USER_NOT_DISABLED : error_1.authClientErrorCode.INTERNAL_ERROR;
|
|
390
392
|
return new error_1.FirebaseAuthError(code, batchDeleteErrorInfo.message);
|
|
391
393
|
};
|
|
392
394
|
return {
|
|
@@ -421,7 +423,7 @@ class BaseAuth {
|
|
|
421
423
|
if (properties?.providerToLink) {
|
|
422
424
|
if (properties.providerToLink.providerId === 'email') {
|
|
423
425
|
if (typeof properties.email !== 'undefined') {
|
|
424
|
-
throw new error_1.FirebaseAuthError(error_1.
|
|
426
|
+
throw new error_1.FirebaseAuthError(error_1.authClientErrorCode.INVALID_ARGUMENT, "Both UpdateRequest.email and UpdateRequest.providerToLink.providerId='email' were set. To "
|
|
425
427
|
+ 'link to the email/password provider, only specify the UpdateRequest.email field.');
|
|
426
428
|
}
|
|
427
429
|
properties.email = properties.providerToLink.uid;
|
|
@@ -429,7 +431,7 @@ class BaseAuth {
|
|
|
429
431
|
}
|
|
430
432
|
else if (properties.providerToLink.providerId === 'phone') {
|
|
431
433
|
if (typeof properties.phoneNumber !== 'undefined') {
|
|
432
|
-
throw new error_1.FirebaseAuthError(error_1.
|
|
434
|
+
throw new error_1.FirebaseAuthError(error_1.authClientErrorCode.INVALID_ARGUMENT, "Both UpdateRequest.phoneNumber and UpdateRequest.providerToLink.providerId='phone' were set. To "
|
|
433
435
|
+ 'link to a phone provider, only specify the UpdateRequest.phoneNumber field.');
|
|
434
436
|
}
|
|
435
437
|
properties.phoneNumber = properties.providerToLink.uid;
|
|
@@ -443,7 +445,7 @@ class BaseAuth {
|
|
|
443
445
|
// 'phone', then we'll reject that. Though it might also be reasonable
|
|
444
446
|
// to relax this restriction and just unlink it.
|
|
445
447
|
if (properties.phoneNumber === null) {
|
|
446
|
-
throw new error_1.FirebaseAuthError(error_1.
|
|
448
|
+
throw new error_1.FirebaseAuthError(error_1.authClientErrorCode.INVALID_ARGUMENT, "Both UpdateRequest.phoneNumber=null and UpdateRequest.providersToUnlink=['phone'] were set. To "
|
|
447
449
|
+ 'unlink from a phone provider, only specify the UpdateRequest.phoneNumber=null field.');
|
|
448
450
|
}
|
|
449
451
|
}
|
|
@@ -549,7 +551,7 @@ class BaseAuth {
|
|
|
549
551
|
// Return rejected promise if expiresIn is not available.
|
|
550
552
|
if (!validator.isNonNullObject(sessionCookieOptions) ||
|
|
551
553
|
!validator.isNumber(sessionCookieOptions.expiresIn)) {
|
|
552
|
-
return Promise.reject(new error_1.FirebaseAuthError(error_1.
|
|
554
|
+
return Promise.reject(new error_1.FirebaseAuthError(error_1.authClientErrorCode.INVALID_SESSION_COOKIE_DURATION));
|
|
553
555
|
}
|
|
554
556
|
return this.authRequestHandler.createSessionCookie(idToken, sessionCookieOptions.expiresIn);
|
|
555
557
|
}
|
|
@@ -579,12 +581,12 @@ class BaseAuth {
|
|
|
579
581
|
* a rejected promise.
|
|
580
582
|
*/
|
|
581
583
|
verifySessionCookie(sessionCookie, checkRevoked = false) {
|
|
582
|
-
const isEmulator =
|
|
584
|
+
const isEmulator = this.emulatorMode;
|
|
583
585
|
return this.sessionCookieVerifier.verifyJWT(sessionCookie, isEmulator)
|
|
584
586
|
.then((decodedIdToken) => {
|
|
585
587
|
// Whether to check if the token was revoked.
|
|
586
588
|
if (checkRevoked || isEmulator) {
|
|
587
|
-
return this.verifyDecodedJWTNotRevokedOrDisabled(decodedIdToken, error_1.
|
|
589
|
+
return this.verifyDecodedJWTNotRevokedOrDisabled(decodedIdToken, error_1.authClientErrorCode.SESSION_COOKIE_REVOKED);
|
|
588
590
|
}
|
|
589
591
|
return decodedIdToken;
|
|
590
592
|
});
|
|
@@ -820,7 +822,7 @@ class BaseAuth {
|
|
|
820
822
|
return processResponse(response, providerConfigs);
|
|
821
823
|
});
|
|
822
824
|
}
|
|
823
|
-
return Promise.reject(new error_1.FirebaseAuthError(error_1.
|
|
825
|
+
return Promise.reject(new error_1.FirebaseAuthError(error_1.authClientErrorCode.INVALID_ARGUMENT, '"AuthProviderConfigFilter.type" must be either "saml" or "oidc"'));
|
|
824
826
|
}
|
|
825
827
|
/**
|
|
826
828
|
* Looks up an Auth provider configuration by the provided ID.
|
|
@@ -850,7 +852,7 @@ class BaseAuth {
|
|
|
850
852
|
return new auth_config_1.SAMLConfig(response);
|
|
851
853
|
});
|
|
852
854
|
}
|
|
853
|
-
return Promise.reject(new error_1.FirebaseAuthError(error_1.
|
|
855
|
+
return Promise.reject(new error_1.FirebaseAuthError(error_1.authClientErrorCode.INVALID_PROVIDER_ID));
|
|
854
856
|
}
|
|
855
857
|
/**
|
|
856
858
|
* Deletes the provider configuration corresponding to the provider ID passed.
|
|
@@ -872,7 +874,7 @@ class BaseAuth {
|
|
|
872
874
|
else if (auth_config_1.SAMLConfig.isProviderId(providerId)) {
|
|
873
875
|
return this.authRequestHandler.deleteInboundSamlConfig(providerId);
|
|
874
876
|
}
|
|
875
|
-
return Promise.reject(new error_1.FirebaseAuthError(error_1.
|
|
877
|
+
return Promise.reject(new error_1.FirebaseAuthError(error_1.authClientErrorCode.INVALID_PROVIDER_ID));
|
|
876
878
|
}
|
|
877
879
|
/**
|
|
878
880
|
* Returns a promise that resolves with the updated `AuthProviderConfig`
|
|
@@ -891,7 +893,7 @@ class BaseAuth {
|
|
|
891
893
|
*/
|
|
892
894
|
updateProviderConfig(providerId, updatedConfig) {
|
|
893
895
|
if (!validator.isNonNullObject(updatedConfig)) {
|
|
894
|
-
return Promise.reject(new error_1.FirebaseAuthError(error_1.
|
|
896
|
+
return Promise.reject(new error_1.FirebaseAuthError(error_1.authClientErrorCode.INVALID_CONFIG, 'Request is missing "UpdateAuthProviderRequest" configuration.'));
|
|
895
897
|
}
|
|
896
898
|
if (auth_config_1.OIDCConfig.isProviderId(providerId)) {
|
|
897
899
|
return this.authRequestHandler.updateOAuthIdpConfig(providerId, updatedConfig)
|
|
@@ -905,7 +907,7 @@ class BaseAuth {
|
|
|
905
907
|
return new auth_config_1.SAMLConfig(response);
|
|
906
908
|
});
|
|
907
909
|
}
|
|
908
|
-
return Promise.reject(new error_1.FirebaseAuthError(error_1.
|
|
910
|
+
return Promise.reject(new error_1.FirebaseAuthError(error_1.authClientErrorCode.INVALID_PROVIDER_ID));
|
|
909
911
|
}
|
|
910
912
|
/**
|
|
911
913
|
* Returns a promise that resolves with the newly created `AuthProviderConfig`
|
|
@@ -920,7 +922,7 @@ class BaseAuth {
|
|
|
920
922
|
*/
|
|
921
923
|
createProviderConfig(config) {
|
|
922
924
|
if (!validator.isNonNullObject(config)) {
|
|
923
|
-
return Promise.reject(new error_1.FirebaseAuthError(error_1.
|
|
925
|
+
return Promise.reject(new error_1.FirebaseAuthError(error_1.authClientErrorCode.INVALID_CONFIG, 'Request is missing "AuthProviderConfig" configuration.'));
|
|
924
926
|
}
|
|
925
927
|
if (auth_config_1.OIDCConfig.isProviderId(config.providerId)) {
|
|
926
928
|
return this.authRequestHandler.createOAuthIdpConfig(config)
|
|
@@ -934,12 +936,12 @@ class BaseAuth {
|
|
|
934
936
|
return new auth_config_1.SAMLConfig(response);
|
|
935
937
|
});
|
|
936
938
|
}
|
|
937
|
-
return Promise.reject(new error_1.FirebaseAuthError(error_1.
|
|
939
|
+
return Promise.reject(new error_1.FirebaseAuthError(error_1.authClientErrorCode.INVALID_PROVIDER_ID));
|
|
938
940
|
}
|
|
939
941
|
/** @alpha */
|
|
940
942
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
941
943
|
_verifyAuthBlockingToken(token, audience) {
|
|
942
|
-
const isEmulator =
|
|
944
|
+
const isEmulator = this.emulatorMode;
|
|
943
945
|
return this.authBlockingTokenVerifier._verifyAuthBlockingToken(token, isEmulator, audience)
|
|
944
946
|
.then((decodedAuthBlockingToken) => {
|
|
945
947
|
return decodedAuthBlockingToken;
|
|
@@ -960,7 +962,7 @@ class BaseAuth {
|
|
|
960
962
|
return this.getUser(decodedIdToken.sub)
|
|
961
963
|
.then((user) => {
|
|
962
964
|
if (user.disabled) {
|
|
963
|
-
throw new error_1.FirebaseAuthError(error_1.
|
|
965
|
+
throw new error_1.FirebaseAuthError(error_1.authClientErrorCode.USER_DISABLED, 'The user record is disabled.');
|
|
964
966
|
}
|
|
965
967
|
// If no tokens valid after time available, token is not revoked.
|
|
966
968
|
if (user.tokensValidAfterTime) {
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2026 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 { FirebaseError, ErrorInfo } from '../utils/error';
|
|
18
|
+
/**
|
|
19
|
+
* The constant mapping for valid Auth client error codes.
|
|
20
|
+
*/
|
|
21
|
+
export declare const AuthErrorCode: {
|
|
22
|
+
readonly AUTH_BLOCKING_TOKEN_EXPIRED: "auth-blocking-token-expired";
|
|
23
|
+
readonly BILLING_NOT_ENABLED: "billing-not-enabled";
|
|
24
|
+
readonly CLAIMS_TOO_LARGE: "claims-too-large";
|
|
25
|
+
readonly CONFIGURATION_EXISTS: "configuration-exists";
|
|
26
|
+
readonly CONFIGURATION_NOT_FOUND: "configuration-not-found";
|
|
27
|
+
readonly ID_TOKEN_EXPIRED: "id-token-expired";
|
|
28
|
+
readonly INVALID_ARGUMENT: "argument-error";
|
|
29
|
+
readonly INVALID_CONFIG: "invalid-config";
|
|
30
|
+
readonly EMAIL_ALREADY_EXISTS: "email-already-exists";
|
|
31
|
+
readonly EMAIL_NOT_FOUND: "email-not-found";
|
|
32
|
+
readonly FORBIDDEN_CLAIM: "reserved-claim";
|
|
33
|
+
readonly INVALID_ID_TOKEN: "invalid-id-token";
|
|
34
|
+
readonly ID_TOKEN_REVOKED: "id-token-revoked";
|
|
35
|
+
readonly INTERNAL_ERROR: "internal-error";
|
|
36
|
+
readonly INVALID_CLAIMS: "invalid-claims";
|
|
37
|
+
readonly INVALID_CONTINUE_URI: "invalid-continue-uri";
|
|
38
|
+
readonly INVALID_CREATION_TIME: "invalid-creation-time";
|
|
39
|
+
readonly INVALID_CREDENTIAL: "invalid-credential";
|
|
40
|
+
readonly INVALID_DISABLED_FIELD: "invalid-disabled-field";
|
|
41
|
+
readonly INVALID_DISPLAY_NAME: "invalid-display-name";
|
|
42
|
+
readonly INVALID_DYNAMIC_LINK_DOMAIN: "invalid-dynamic-link-domain";
|
|
43
|
+
readonly INVALID_HOSTING_LINK_DOMAIN: "invalid-hosting-link-domain";
|
|
44
|
+
readonly INVALID_EMAIL_VERIFIED: "invalid-email-verified";
|
|
45
|
+
readonly INVALID_EMAIL: "invalid-email";
|
|
46
|
+
readonly INVALID_NEW_EMAIL: "invalid-new-email";
|
|
47
|
+
readonly INVALID_ENROLLED_FACTORS: "invalid-enrolled-factors";
|
|
48
|
+
readonly INVALID_ENROLLMENT_TIME: "invalid-enrollment-time";
|
|
49
|
+
readonly INVALID_HASH_ALGORITHM: "invalid-hash-algorithm";
|
|
50
|
+
readonly INVALID_HASH_BLOCK_SIZE: "invalid-hash-block-size";
|
|
51
|
+
readonly INVALID_HASH_DERIVED_KEY_LENGTH: "invalid-hash-derived-key-length";
|
|
52
|
+
readonly INVALID_HASH_KEY: "invalid-hash-key";
|
|
53
|
+
readonly INVALID_HASH_MEMORY_COST: "invalid-hash-memory-cost";
|
|
54
|
+
readonly INVALID_HASH_PARALLELIZATION: "invalid-hash-parallelization";
|
|
55
|
+
readonly INVALID_HASH_ROUNDS: "invalid-hash-rounds";
|
|
56
|
+
readonly INVALID_HASH_SALT_SEPARATOR: "invalid-hash-salt-separator";
|
|
57
|
+
readonly INVALID_LAST_SIGN_IN_TIME: "invalid-last-sign-in-time";
|
|
58
|
+
readonly INVALID_NAME: "invalid-name";
|
|
59
|
+
readonly INVALID_OAUTH_CLIENT_ID: "invalid-oauth-client-id";
|
|
60
|
+
readonly INVALID_PAGE_TOKEN: "invalid-page-token";
|
|
61
|
+
readonly INVALID_PASSWORD: "invalid-password";
|
|
62
|
+
readonly INVALID_PASSWORD_HASH: "invalid-password-hash";
|
|
63
|
+
readonly INVALID_PASSWORD_SALT: "invalid-password-salt";
|
|
64
|
+
readonly INVALID_PHONE_NUMBER: "invalid-phone-number";
|
|
65
|
+
readonly INVALID_PHOTO_URL: "invalid-photo-url";
|
|
66
|
+
readonly INVALID_PROJECT_ID: "invalid-project-id";
|
|
67
|
+
readonly INVALID_PROVIDER_DATA: "invalid-provider-data";
|
|
68
|
+
readonly INVALID_PROVIDER_ID: "invalid-provider-id";
|
|
69
|
+
readonly INVALID_PROVIDER_UID: "invalid-provider-uid";
|
|
70
|
+
readonly INVALID_OAUTH_RESPONSETYPE: "invalid-oauth-responsetype";
|
|
71
|
+
readonly INVALID_SESSION_COOKIE_DURATION: "invalid-session-cookie-duration";
|
|
72
|
+
readonly INVALID_TENANT_ID: "invalid-tenant-id";
|
|
73
|
+
readonly INVALID_TENANT_TYPE: "invalid-tenant-type";
|
|
74
|
+
readonly INVALID_TESTING_PHONE_NUMBER: "invalid-testing-phone-number";
|
|
75
|
+
readonly INVALID_UID: "invalid-uid";
|
|
76
|
+
readonly INVALID_USER_IMPORT: "invalid-user-import";
|
|
77
|
+
readonly INVALID_TOKENS_VALID_AFTER_TIME: "invalid-tokens-valid-after-time";
|
|
78
|
+
readonly MISMATCHING_TENANT_ID: "mismatching-tenant-id";
|
|
79
|
+
readonly MISSING_ANDROID_PACKAGE_NAME: "missing-android-package-name";
|
|
80
|
+
readonly MISSING_CONFIG: "missing-config";
|
|
81
|
+
readonly MISSING_CONTINUE_URI: "missing-continue-uri";
|
|
82
|
+
readonly MISSING_DISPLAY_NAME: "missing-display-name";
|
|
83
|
+
readonly MISSING_EMAIL: "missing-email";
|
|
84
|
+
readonly MISSING_IOS_BUNDLE_ID: "missing-ios-bundle-id";
|
|
85
|
+
readonly MISSING_ISSUER: "missing-issuer";
|
|
86
|
+
readonly MISSING_HASH_ALGORITHM: "missing-hash-algorithm";
|
|
87
|
+
readonly MISSING_OAUTH_CLIENT_ID: "missing-oauth-client-id";
|
|
88
|
+
readonly MISSING_OAUTH_CLIENT_SECRET: "missing-oauth-client-secret";
|
|
89
|
+
readonly MISSING_PROVIDER_ID: "missing-provider-id";
|
|
90
|
+
readonly MISSING_SAML_RELYING_PARTY_CONFIG: "missing-saml-relying-party-config";
|
|
91
|
+
readonly MAXIMUM_TEST_PHONE_NUMBER_EXCEEDED: "test-phone-number-limit-exceeded";
|
|
92
|
+
readonly MAXIMUM_USER_COUNT_EXCEEDED: "maximum-user-count-exceeded";
|
|
93
|
+
readonly MISSING_UID: "missing-uid";
|
|
94
|
+
readonly OPERATION_NOT_ALLOWED: "operation-not-allowed";
|
|
95
|
+
readonly PHONE_NUMBER_ALREADY_EXISTS: "phone-number-already-exists";
|
|
96
|
+
readonly PROJECT_NOT_FOUND: "project-not-found";
|
|
97
|
+
readonly INSUFFICIENT_PERMISSION: "insufficient-permission";
|
|
98
|
+
readonly QUOTA_EXCEEDED: "quota-exceeded";
|
|
99
|
+
readonly SECOND_FACTOR_LIMIT_EXCEEDED: "second-factor-limit-exceeded";
|
|
100
|
+
readonly SECOND_FACTOR_UID_ALREADY_EXISTS: "second-factor-uid-already-exists";
|
|
101
|
+
readonly SESSION_COOKIE_EXPIRED: "session-cookie-expired";
|
|
102
|
+
readonly SESSION_COOKIE_REVOKED: "session-cookie-revoked";
|
|
103
|
+
readonly TENANT_NOT_FOUND: "tenant-not-found";
|
|
104
|
+
readonly UID_ALREADY_EXISTS: "uid-already-exists";
|
|
105
|
+
readonly UNAUTHORIZED_DOMAIN: "unauthorized-continue-uri";
|
|
106
|
+
readonly UNSUPPORTED_FIRST_FACTOR: "unsupported-first-factor";
|
|
107
|
+
readonly UNSUPPORTED_SECOND_FACTOR: "unsupported-second-factor";
|
|
108
|
+
readonly UNSUPPORTED_TENANT_OPERATION: "unsupported-tenant-operation";
|
|
109
|
+
readonly UNVERIFIED_EMAIL: "unverified-email";
|
|
110
|
+
readonly USER_NOT_FOUND: "user-not-found";
|
|
111
|
+
readonly NOT_FOUND: "not-found";
|
|
112
|
+
readonly USER_DISABLED: "user-disabled";
|
|
113
|
+
readonly USER_NOT_DISABLED: "user-not-disabled";
|
|
114
|
+
readonly INVALID_RECAPTCHA_ACTION: "invalid-recaptcha-action";
|
|
115
|
+
readonly INVALID_RECAPTCHA_ENFORCEMENT_STATE: "invalid-recaptcha-enforcement-state";
|
|
116
|
+
readonly RECAPTCHA_NOT_ENABLED: "recaptcha-not-enabled";
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* The type definition for valid Auth client error codes.
|
|
120
|
+
*/
|
|
121
|
+
export type AuthErrorCode = typeof AuthErrorCode[keyof typeof AuthErrorCode];
|
|
122
|
+
/**
|
|
123
|
+
* Internal Auth client error code mapping used to construct ErrorInfo.
|
|
124
|
+
*/
|
|
125
|
+
export declare const authClientErrorCode: {
|
|
126
|
+
readonly [K in keyof typeof AuthErrorCode]: ErrorInfo;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Firebase Auth error code structure. This extends `FirebaseError`.
|
|
130
|
+
*/
|
|
131
|
+
export declare class FirebaseAuthError extends FirebaseError {
|
|
132
|
+
/**
|
|
133
|
+
* @param info - The error code info.
|
|
134
|
+
* @param message - The error message. This will override the default message if provided.
|
|
135
|
+
*/
|
|
136
|
+
constructor(info: ErrorInfo, message?: string);
|
|
137
|
+
}
|