firebase-admin 9.100.0-alpha.0 → 10.0.2
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 +7 -3
- package/lib/app/core.d.ts +15 -22
- package/lib/app/core.js +1 -1
- package/lib/app/credential-factory.d.ts +17 -33
- package/lib/app/credential-factory.js +17 -33
- package/lib/app/credential-internal.d.ts +10 -9
- package/lib/app/credential-internal.js +15 -13
- package/lib/app/credential.d.ts +3 -9
- package/lib/app/credential.js +1 -1
- package/lib/app/firebase-app.d.ts +6 -30
- package/lib/app/firebase-app.js +72 -216
- package/lib/app/firebase-namespace.d.ts +28 -34
- package/lib/app/firebase-namespace.js +119 -99
- package/lib/app/index.d.ts +6 -1
- package/lib/app/index.js +1 -1
- package/lib/app/lifecycle.d.ts +24 -3
- package/lib/app/lifecycle.js +119 -25
- package/lib/app-check/app-check-api-client-internal.d.ts +32 -0
- package/lib/app-check/app-check-api-client-internal.js +197 -0
- package/lib/app-check/app-check-api.d.ts +95 -0
- package/lib/app-check/app-check-api.js +19 -0
- package/lib/app-check/app-check-namespace.d.ts +65 -0
- package/lib/app-check/app-check-namespace.js +18 -0
- package/lib/app-check/app-check.d.ts +49 -0
- package/lib/app-check/app-check.js +82 -0
- package/lib/app-check/index.d.ts +53 -0
- package/lib/app-check/index.js +63 -0
- package/lib/app-check/token-generator.d.ts +25 -0
- package/lib/app-check/token-generator.js +159 -0
- package/lib/app-check/token-verifier.d.ts +17 -0
- package/lib/app-check/token-verifier.js +151 -0
- package/lib/auth/action-code-settings-builder.d.ts +1 -1
- package/lib/auth/action-code-settings-builder.js +2 -2
- package/lib/auth/auth-api-request.d.ts +28 -32
- package/lib/auth/auth-api-request.js +167 -125
- package/lib/auth/auth-config.d.ts +123 -21
- package/lib/auth/auth-config.js +85 -34
- package/lib/auth/auth-namespace.d.ts +157 -4
- package/lib/auth/auth-namespace.js +1 -1
- package/lib/auth/auth.d.ts +5 -3
- package/lib/auth/auth.js +6 -4
- package/lib/auth/base-auth.d.ts +134 -116
- package/lib/auth/base-auth.js +213 -143
- package/lib/auth/identifier.d.ts +5 -5
- package/lib/auth/identifier.js +1 -1
- package/lib/auth/index.d.ts +10 -5
- package/lib/auth/index.js +9 -4
- package/lib/auth/tenant-manager.d.ts +19 -19
- package/lib/auth/tenant-manager.js +21 -25
- package/lib/auth/tenant.d.ts +14 -5
- package/lib/auth/tenant.js +19 -11
- package/lib/auth/token-generator.d.ts +7 -108
- package/lib/auth/token-generator.js +52 -145
- package/lib/auth/token-verifier.d.ts +3 -4
- package/lib/auth/token-verifier.js +96 -145
- package/lib/auth/user-import-builder.d.ts +11 -11
- package/lib/auth/user-import-builder.js +9 -9
- package/lib/auth/user-record.d.ts +23 -15
- package/lib/auth/user-record.js +30 -20
- package/lib/credential/index.d.ts +18 -35
- package/lib/credential/index.js +17 -33
- package/lib/database/database-namespace.d.ts +39 -10
- package/lib/database/database-namespace.js +1 -1
- package/lib/database/database.d.ts +16 -6
- package/lib/database/database.js +61 -6
- package/lib/database/index.d.ts +19 -18
- package/lib/database/index.js +21 -23
- package/lib/default-namespace.d.ts +7 -1
- package/lib/default-namespace.js +4 -4
- package/lib/esm/app/index.js +10 -0
- package/lib/esm/app-check/index.js +4 -0
- package/lib/esm/auth/index.js +14 -0
- package/lib/esm/database/index.js +6 -0
- package/lib/esm/firestore/index.js +24 -0
- package/lib/esm/installations/index.js +4 -0
- package/lib/esm/instance-id/index.js +4 -0
- package/lib/esm/machine-learning/index.js +5 -0
- package/lib/esm/messaging/index.js +4 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/project-management/index.js +8 -0
- package/lib/esm/remote-config/index.js +4 -0
- package/lib/esm/security-rules/index.js +6 -0
- package/lib/esm/storage/index.js +4 -0
- package/lib/firebase-namespace-api.d.ts +12 -6
- package/lib/firebase-namespace-api.js +5 -1
- package/lib/firestore/firestore-internal.d.ts +2 -2
- package/lib/firestore/firestore-internal.js +2 -2
- package/lib/firestore/firestore-namespace.d.ts +6 -1
- package/lib/firestore/firestore-namespace.js +2 -1
- package/lib/firestore/index.d.ts +36 -4
- package/lib/firestore/index.js +29 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/installations/index.d.ts +52 -0
- package/lib/installations/index.js +62 -0
- package/lib/installations/installations-namespace.d.ts +55 -0
- package/lib/installations/installations-namespace.js +18 -0
- package/lib/{instance-id/instance-id-request-internal.d.ts → installations/installations-request-handler.d.ts} +8 -8
- package/lib/{instance-id/instance-id-request-internal.js → installations/installations-request-handler.js} +23 -23
- package/lib/installations/installations.d.ts +38 -0
- package/lib/installations/installations.js +63 -0
- package/lib/instance-id/index.d.ts +20 -9
- package/lib/instance-id/index.js +20 -9
- package/lib/instance-id/instance-id-namespace.d.ts +9 -8
- package/lib/instance-id/instance-id-namespace.js +1 -1
- package/lib/instance-id/instance-id.d.ts +8 -6
- package/lib/instance-id/instance-id.js +20 -11
- package/lib/machine-learning/index.d.ts +29 -27
- package/lib/machine-learning/index.js +29 -27
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +4 -4
- package/lib/machine-learning/machine-learning-namespace.d.ts +33 -8
- 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 +1 -1
- package/lib/machine-learning/machine-learning.d.ts +19 -19
- package/lib/machine-learning/machine-learning.js +20 -20
- package/lib/messaging/batch-request-internal.d.ts +3 -3
- package/lib/messaging/batch-request-internal.js +9 -9
- package/lib/messaging/index.d.ts +11 -9
- package/lib/messaging/index.js +11 -9
- package/lib/messaging/messaging-api-request-internal.d.ts +8 -8
- package/lib/messaging/messaging-api-request-internal.js +8 -8
- package/lib/messaging/messaging-api.d.ts +79 -75
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +5 -5
- package/lib/messaging/messaging-errors-internal.js +7 -7
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +6 -31
- package/lib/messaging/messaging-namespace.d.ts +105 -8
- package/lib/messaging/messaging-namespace.js +1 -1
- package/lib/messaging/messaging.d.ts +70 -86
- package/lib/messaging/messaging.js +76 -89
- package/lib/project-management/android-app.d.ts +11 -12
- package/lib/project-management/android-app.js +13 -14
- 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 +11 -9
- package/lib/project-management/index.js +11 -9
- package/lib/project-management/ios-app.d.ts +6 -7
- package/lib/project-management/ios-app.js +6 -7
- package/lib/project-management/project-management-api-request-internal.d.ts +1 -80
- package/lib/project-management/project-management-api-request-internal.js +14 -14
- package/lib/project-management/project-management-namespace.d.ts +31 -9
- package/lib/project-management/project-management-namespace.js +1 -1
- package/lib/project-management/project-management.d.ts +18 -21
- package/lib/project-management/project-management.js +19 -22
- package/lib/remote-config/index.d.ts +12 -10
- package/lib/remote-config/index.js +11 -9
- package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
- package/lib/remote-config/remote-config-api-client-internal.js +2 -2
- package/lib/remote-config/remote-config-api.d.ts +12 -2
- package/lib/remote-config/remote-config-api.js +1 -1
- package/lib/remote-config/remote-config-namespace.d.ts +50 -9
- package/lib/remote-config/remote-config-namespace.js +1 -1
- package/lib/remote-config/remote-config.d.ts +19 -21
- package/lib/remote-config/remote-config.js +25 -25
- package/lib/security-rules/index.d.ts +12 -10
- package/lib/security-rules/index.js +12 -10
- package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-api-client-internal.js +1 -1
- package/lib/security-rules/security-rules-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-internal.js +1 -1
- package/lib/security-rules/security-rules-namespace.d.ts +43 -28
- package/lib/security-rules/security-rules-namespace.js +1 -1
- package/lib/security-rules/security-rules.d.ts +39 -42
- package/lib/security-rules/security-rules.js +38 -39
- package/lib/storage/index.d.ts +9 -7
- package/lib/storage/index.js +9 -7
- package/lib/storage/storage-namespace.d.ts +7 -6
- package/lib/storage/storage-namespace.js +1 -1
- package/lib/storage/storage.d.ts +3 -3
- package/lib/storage/storage.js +14 -4
- package/lib/utils/api-request.d.ts +24 -24
- package/lib/utils/api-request.js +25 -25
- package/lib/utils/crypto-signer.d.ts +128 -0
- package/lib/utils/crypto-signer.js +237 -0
- package/lib/utils/deep-copy.d.ts +6 -6
- package/lib/utils/deep-copy.js +6 -6
- package/lib/utils/error.d.ts +69 -36
- package/lib/utils/error.js +98 -43
- package/lib/utils/index.d.ts +30 -19
- package/lib/utils/index.js +47 -20
- package/lib/utils/jwt.d.ts +131 -0
- package/lib/utils/jwt.js +355 -0
- package/lib/utils/validator.d.ts +37 -37
- package/lib/utils/validator.js +37 -37
- package/package.json +126 -53
package/lib/auth/base-auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v10.0.2 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2021 Google Inc.
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.BaseAuth = void 0;
|
|
19
|
+
exports.BaseAuth = exports.createFirebaseTokenGenerator = void 0;
|
|
20
20
|
var error_1 = require("../utils/error");
|
|
21
|
+
var deep_copy_1 = require("../utils/deep-copy");
|
|
21
22
|
var validator = require("../utils/validator");
|
|
22
23
|
var auth_api_request_1 = require("./auth-api-request");
|
|
23
24
|
var token_generator_1 = require("./token-generator");
|
|
@@ -25,6 +26,20 @@ var token_verifier_1 = require("./token-verifier");
|
|
|
25
26
|
var auth_config_1 = require("./auth-config");
|
|
26
27
|
var user_record_1 = require("./user-record");
|
|
27
28
|
var identifier_1 = require("./identifier");
|
|
29
|
+
var crypto_signer_1 = require("../utils/crypto-signer");
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
function createFirebaseTokenGenerator(app, tenantId) {
|
|
34
|
+
try {
|
|
35
|
+
var signer = auth_api_request_1.useEmulator() ? new token_generator_1.EmulatedSigner() : crypto_signer_1.cryptoSignerFromApp(app);
|
|
36
|
+
return new token_generator_1.FirebaseTokenGenerator(signer, tenantId);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
throw token_generator_1.handleCryptoSignerError(err);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.createFirebaseTokenGenerator = createFirebaseTokenGenerator;
|
|
28
43
|
/**
|
|
29
44
|
* Common parent interface for both `Auth` and `TenantAwareAuth` APIs.
|
|
30
45
|
*/
|
|
@@ -32,9 +47,9 @@ var BaseAuth = /** @class */ (function () {
|
|
|
32
47
|
/**
|
|
33
48
|
* The BaseAuth class constructor.
|
|
34
49
|
*
|
|
35
|
-
* @param app The FirebaseApp to associate with this Auth instance.
|
|
36
|
-
* @param authRequestHandler The RPC request handler for this instance.
|
|
37
|
-
* @param tokenGenerator Optional token generator. If not specified, a
|
|
50
|
+
* @param app - The FirebaseApp to associate with this Auth instance.
|
|
51
|
+
* @param authRequestHandler - The RPC request handler for this instance.
|
|
52
|
+
* @param tokenGenerator - Optional token generator. If not specified, a
|
|
38
53
|
* (non-tenant-aware) instance will be created. Use this paramter to
|
|
39
54
|
* specify a tenant-aware tokenGenerator.
|
|
40
55
|
* @constructor
|
|
@@ -47,8 +62,7 @@ var BaseAuth = /** @class */ (function () {
|
|
|
47
62
|
this.tokenGenerator = tokenGenerator;
|
|
48
63
|
}
|
|
49
64
|
else {
|
|
50
|
-
|
|
51
|
-
this.tokenGenerator = new token_generator_1.FirebaseTokenGenerator(cryptoSigner);
|
|
65
|
+
this.tokenGenerator = createFirebaseTokenGenerator(app);
|
|
52
66
|
}
|
|
53
67
|
this.sessionCookieVerifier = token_verifier_1.createSessionCookieVerifier(app);
|
|
54
68
|
this.idTokenVerifier = token_verifier_1.createIdTokenVerifier(app);
|
|
@@ -59,14 +73,14 @@ var BaseAuth = /** @class */ (function () {
|
|
|
59
73
|
* methods. (Tenant-aware instances will also embed the tenant ID in the
|
|
60
74
|
* token.)
|
|
61
75
|
*
|
|
62
|
-
* See
|
|
63
|
-
* samples and detailed documentation.
|
|
76
|
+
* See {@link https://firebase.google.com/docs/auth/admin/create-custom-tokens | Create Custom Tokens}
|
|
77
|
+
* for code samples and detailed documentation.
|
|
64
78
|
*
|
|
65
|
-
* @param uid The `uid` to use as the custom token's subject.
|
|
66
|
-
* @param developerClaims Optional additional claims to include
|
|
79
|
+
* @param uid - The `uid` to use as the custom token's subject.
|
|
80
|
+
* @param developerClaims - Optional additional claims to include
|
|
67
81
|
* in the custom token's payload.
|
|
68
82
|
*
|
|
69
|
-
* @
|
|
83
|
+
* @returns A promise fulfilled with a custom token for the
|
|
70
84
|
* provided `uid` and payload.
|
|
71
85
|
*/
|
|
72
86
|
BaseAuth.prototype.createCustomToken = function (uid, developerClaims) {
|
|
@@ -76,43 +90,48 @@ var BaseAuth = /** @class */ (function () {
|
|
|
76
90
|
* Verifies a Firebase ID token (JWT). If the token is valid, the promise is
|
|
77
91
|
* fulfilled with the token's decoded claims; otherwise, the promise is
|
|
78
92
|
* rejected.
|
|
79
|
-
* An optional flag can be passed to additionally check whether the ID token
|
|
80
|
-
* was revoked.
|
|
81
93
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
94
|
+
* If `checkRevoked` is set to true, first verifies whether the corresponding
|
|
95
|
+
* user is disabled. If yes, an `auth/user-disabled` error is thrown. If no,
|
|
96
|
+
* verifies if the session corresponding to the ID token was revoked. If the
|
|
97
|
+
* corresponding user's session was invalidated, an `auth/id-token-revoked`
|
|
98
|
+
* error is thrown. If not specified the check is not applied.
|
|
84
99
|
*
|
|
85
|
-
* @
|
|
86
|
-
*
|
|
100
|
+
* See {@link https://firebase.google.com/docs/auth/admin/verify-id-tokens | Verify ID Tokens}
|
|
101
|
+
* for code samples and detailed documentation.
|
|
102
|
+
*
|
|
103
|
+
* @param idToken - The ID token to verify.
|
|
104
|
+
* @param checkRevoked - Whether to check if the ID token was revoked.
|
|
87
105
|
* This requires an extra request to the Firebase Auth backend to check
|
|
88
106
|
* the `tokensValidAfterTime` time for the corresponding user.
|
|
89
107
|
* When not specified, this additional check is not applied.
|
|
90
108
|
*
|
|
91
|
-
* @
|
|
109
|
+
* @returns A promise fulfilled with the
|
|
92
110
|
* token's decoded claims if the ID token is valid; otherwise, a rejected
|
|
93
111
|
* promise.
|
|
94
112
|
*/
|
|
95
113
|
BaseAuth.prototype.verifyIdToken = function (idToken, checkRevoked) {
|
|
96
114
|
var _this = this;
|
|
97
115
|
if (checkRevoked === void 0) { checkRevoked = false; }
|
|
98
|
-
|
|
116
|
+
var isEmulator = auth_api_request_1.useEmulator();
|
|
117
|
+
return this.idTokenVerifier.verifyJWT(idToken, isEmulator)
|
|
99
118
|
.then(function (decodedIdToken) {
|
|
100
119
|
// Whether to check if the token was revoked.
|
|
101
|
-
if (
|
|
102
|
-
return decodedIdToken;
|
|
120
|
+
if (checkRevoked || isEmulator) {
|
|
121
|
+
return _this.verifyDecodedJWTNotRevokedOrDisabled(decodedIdToken, error_1.AuthClientErrorCode.ID_TOKEN_REVOKED);
|
|
103
122
|
}
|
|
104
|
-
return
|
|
123
|
+
return decodedIdToken;
|
|
105
124
|
});
|
|
106
125
|
};
|
|
107
126
|
/**
|
|
108
127
|
* Gets the user data for the user corresponding to a given `uid`.
|
|
109
128
|
*
|
|
110
|
-
* See
|
|
129
|
+
* See {@link https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data | Retrieve user data}
|
|
111
130
|
* for code samples and detailed documentation.
|
|
112
131
|
*
|
|
113
|
-
* @param uid The `uid` corresponding to the user whose data to fetch.
|
|
132
|
+
* @param uid - The `uid` corresponding to the user whose data to fetch.
|
|
114
133
|
*
|
|
115
|
-
* @
|
|
134
|
+
* @returns A promise fulfilled with the user
|
|
116
135
|
* data corresponding to the provided `uid`.
|
|
117
136
|
*/
|
|
118
137
|
BaseAuth.prototype.getUser = function (uid) {
|
|
@@ -125,13 +144,13 @@ var BaseAuth = /** @class */ (function () {
|
|
|
125
144
|
/**
|
|
126
145
|
* Gets the user data for the user corresponding to a given email.
|
|
127
146
|
*
|
|
128
|
-
* See
|
|
147
|
+
* See {@link https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data | Retrieve user data}
|
|
129
148
|
* for code samples and detailed documentation.
|
|
130
149
|
*
|
|
131
|
-
* @param email The email corresponding to the user whose data to
|
|
150
|
+
* @param email - The email corresponding to the user whose data to
|
|
132
151
|
* fetch.
|
|
133
152
|
*
|
|
134
|
-
* @
|
|
153
|
+
* @returns A promise fulfilled with the user
|
|
135
154
|
* data corresponding to the provided email.
|
|
136
155
|
*/
|
|
137
156
|
BaseAuth.prototype.getUserByEmail = function (email) {
|
|
@@ -145,13 +164,13 @@ var BaseAuth = /** @class */ (function () {
|
|
|
145
164
|
* Gets the user data for the user corresponding to a given phone number. The
|
|
146
165
|
* phone number has to conform to the E.164 specification.
|
|
147
166
|
*
|
|
148
|
-
* See
|
|
167
|
+
* See {@link https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data | Retrieve user data}
|
|
149
168
|
* for code samples and detailed documentation.
|
|
150
169
|
*
|
|
151
|
-
* @param phoneNumber The phone number corresponding to the user whose
|
|
170
|
+
* @param phoneNumber - The phone number corresponding to the user whose
|
|
152
171
|
* data to fetch.
|
|
153
172
|
*
|
|
154
|
-
* @
|
|
173
|
+
* @returns A promise fulfilled with the user
|
|
155
174
|
* data corresponding to the provided phone number.
|
|
156
175
|
*/
|
|
157
176
|
BaseAuth.prototype.getUserByPhoneNumber = function (phoneNumber) {
|
|
@@ -161,6 +180,35 @@ var BaseAuth = /** @class */ (function () {
|
|
|
161
180
|
return new user_record_1.UserRecord(response.users[0]);
|
|
162
181
|
});
|
|
163
182
|
};
|
|
183
|
+
/**
|
|
184
|
+
* Gets the user data for the user corresponding to a given provider id.
|
|
185
|
+
*
|
|
186
|
+
* See {@link https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data | Retrieve user data}
|
|
187
|
+
* for code samples and detailed documentation.
|
|
188
|
+
*
|
|
189
|
+
* @param providerId - The provider ID, for example, "google.com" for the
|
|
190
|
+
* Google provider.
|
|
191
|
+
* @param uid - The user identifier for the given provider.
|
|
192
|
+
*
|
|
193
|
+
* @returns A promise fulfilled with the user data corresponding to the
|
|
194
|
+
* given provider id.
|
|
195
|
+
*/
|
|
196
|
+
BaseAuth.prototype.getUserByProviderUid = function (providerId, uid) {
|
|
197
|
+
// Although we don't really advertise it, we want to also handle
|
|
198
|
+
// non-federated idps with this call. So if we detect one of them, we'll
|
|
199
|
+
// reroute this request appropriately.
|
|
200
|
+
if (providerId === 'phone') {
|
|
201
|
+
return this.getUserByPhoneNumber(uid);
|
|
202
|
+
}
|
|
203
|
+
else if (providerId === 'email') {
|
|
204
|
+
return this.getUserByEmail(uid);
|
|
205
|
+
}
|
|
206
|
+
return this.authRequestHandler.getAccountInfoByFederatedUid(providerId, uid)
|
|
207
|
+
.then(function (response) {
|
|
208
|
+
// Returns the user record populated with server response.
|
|
209
|
+
return new user_record_1.UserRecord(response.users[0]);
|
|
210
|
+
});
|
|
211
|
+
};
|
|
164
212
|
/**
|
|
165
213
|
* Gets the user data corresponding to the specified identifiers.
|
|
166
214
|
*
|
|
@@ -170,9 +218,9 @@ var BaseAuth = /** @class */ (function () {
|
|
|
170
218
|
* Only a maximum of 100 identifiers may be supplied. If more than 100 identifiers are supplied,
|
|
171
219
|
* this method throws a FirebaseAuthError.
|
|
172
220
|
*
|
|
173
|
-
* @param identifiers The identifiers used to indicate which user records should be returned.
|
|
174
|
-
* Must have
|
|
175
|
-
* @
|
|
221
|
+
* @param identifiers - The identifiers used to indicate which user records should be returned.
|
|
222
|
+
* Must not have more than 100 entries.
|
|
223
|
+
* @returns A promise that resolves to the corresponding user records.
|
|
176
224
|
* @throws FirebaseAuthError If any of the identifiers are invalid or if more than 100
|
|
177
225
|
* identifiers are specified.
|
|
178
226
|
*/
|
|
@@ -219,14 +267,14 @@ var BaseAuth = /** @class */ (function () {
|
|
|
219
267
|
* starting from the offset as specified by `pageToken`. This is used to
|
|
220
268
|
* retrieve all the users of a specified project in batches.
|
|
221
269
|
*
|
|
222
|
-
* See
|
|
270
|
+
* See {@link https://firebase.google.com/docs/auth/admin/manage-users#list_all_users | List all users}
|
|
223
271
|
* for code samples and detailed documentation.
|
|
224
272
|
*
|
|
225
|
-
* @param maxResults The page size, 1000 if undefined. This is also
|
|
273
|
+
* @param maxResults - The page size, 1000 if undefined. This is also
|
|
226
274
|
* the maximum allowed limit.
|
|
227
|
-
* @param pageToken The next page token. If not specified, returns
|
|
275
|
+
* @param pageToken - The next page token. If not specified, returns
|
|
228
276
|
* users starting without any offset.
|
|
229
|
-
* @
|
|
277
|
+
* @returns A promise that resolves with
|
|
230
278
|
* the current batch of downloaded users and the next page token.
|
|
231
279
|
*/
|
|
232
280
|
BaseAuth.prototype.listUsers = function (maxResults, pageToken) {
|
|
@@ -253,13 +301,13 @@ var BaseAuth = /** @class */ (function () {
|
|
|
253
301
|
/**
|
|
254
302
|
* Creates a new user.
|
|
255
303
|
*
|
|
256
|
-
* See
|
|
257
|
-
* samples and detailed documentation.
|
|
304
|
+
* See {@link https://firebase.google.com/docs/auth/admin/manage-users#create_a_user | Create a user}
|
|
305
|
+
* for code samples and detailed documentation.
|
|
258
306
|
*
|
|
259
|
-
* @param properties The properties to set on the
|
|
307
|
+
* @param properties - The properties to set on the
|
|
260
308
|
* new user record to be created.
|
|
261
309
|
*
|
|
262
|
-
* @
|
|
310
|
+
* @returns A promise fulfilled with the user
|
|
263
311
|
* data corresponding to the newly created user.
|
|
264
312
|
*/
|
|
265
313
|
BaseAuth.prototype.createUser = function (properties) {
|
|
@@ -280,12 +328,12 @@ var BaseAuth = /** @class */ (function () {
|
|
|
280
328
|
/**
|
|
281
329
|
* Deletes an existing user.
|
|
282
330
|
*
|
|
283
|
-
* See
|
|
284
|
-
* samples and detailed documentation.
|
|
331
|
+
* See {@link https://firebase.google.com/docs/auth/admin/manage-users#delete_a_user | Delete a user}
|
|
332
|
+
* for code samples and detailed documentation.
|
|
285
333
|
*
|
|
286
|
-
* @param uid The `uid` corresponding to the user to delete.
|
|
334
|
+
* @param uid - The `uid` corresponding to the user to delete.
|
|
287
335
|
*
|
|
288
|
-
* @
|
|
336
|
+
* @returns An empty promise fulfilled once the user has been
|
|
289
337
|
* deleted.
|
|
290
338
|
*/
|
|
291
339
|
BaseAuth.prototype.deleteUser = function (uid) {
|
|
@@ -310,9 +358,9 @@ var BaseAuth = /** @class */ (function () {
|
|
|
310
358
|
* delete more than 1000 users, you may need to add a delay to ensure you
|
|
311
359
|
* don't go over this limit.
|
|
312
360
|
*
|
|
313
|
-
* @param uids The `uids` corresponding to the users to delete.
|
|
361
|
+
* @param uids - The `uids` corresponding to the users to delete.
|
|
314
362
|
*
|
|
315
|
-
* @
|
|
363
|
+
* @returns A Promise that resolves to the total number of successful/failed
|
|
316
364
|
* deletions, as well as the array of errors that corresponds to the
|
|
317
365
|
* failed deletions.
|
|
318
366
|
*/
|
|
@@ -354,18 +402,55 @@ var BaseAuth = /** @class */ (function () {
|
|
|
354
402
|
/**
|
|
355
403
|
* Updates an existing user.
|
|
356
404
|
*
|
|
357
|
-
* See
|
|
358
|
-
* samples and detailed documentation.
|
|
405
|
+
* See {@link https://firebase.google.com/docs/auth/admin/manage-users#update_a_user | Update a user}
|
|
406
|
+
* for code samples and detailed documentation.
|
|
359
407
|
*
|
|
360
|
-
* @param uid The `uid` corresponding to the user to update.
|
|
361
|
-
* @param properties The properties to update on
|
|
408
|
+
* @param uid - The `uid` corresponding to the user to update.
|
|
409
|
+
* @param properties - The properties to update on
|
|
362
410
|
* the provided user.
|
|
363
411
|
*
|
|
364
|
-
* @
|
|
412
|
+
* @returns A promise fulfilled with the
|
|
365
413
|
* updated user data.
|
|
366
414
|
*/
|
|
367
415
|
BaseAuth.prototype.updateUser = function (uid, properties) {
|
|
368
416
|
var _this = this;
|
|
417
|
+
// Although we don't really advertise it, we want to also handle linking of
|
|
418
|
+
// non-federated idps with this call. So if we detect one of them, we'll
|
|
419
|
+
// adjust the properties parameter appropriately. This *does* imply that a
|
|
420
|
+
// conflict could arise, e.g. if the user provides a phoneNumber property,
|
|
421
|
+
// but also provides a providerToLink with a 'phone' provider id. In that
|
|
422
|
+
// case, we'll throw an error.
|
|
423
|
+
properties = deep_copy_1.deepCopy(properties);
|
|
424
|
+
if (properties === null || properties === void 0 ? void 0 : properties.providerToLink) {
|
|
425
|
+
if (properties.providerToLink.providerId === 'email') {
|
|
426
|
+
if (typeof properties.email !== 'undefined') {
|
|
427
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "Both UpdateRequest.email and UpdateRequest.providerToLink.providerId='email' were set. To "
|
|
428
|
+
+ 'link to the email/password provider, only specify the UpdateRequest.email field.');
|
|
429
|
+
}
|
|
430
|
+
properties.email = properties.providerToLink.uid;
|
|
431
|
+
delete properties.providerToLink;
|
|
432
|
+
}
|
|
433
|
+
else if (properties.providerToLink.providerId === 'phone') {
|
|
434
|
+
if (typeof properties.phoneNumber !== 'undefined') {
|
|
435
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "Both UpdateRequest.phoneNumber and UpdateRequest.providerToLink.providerId='phone' were set. To "
|
|
436
|
+
+ 'link to a phone provider, only specify the UpdateRequest.phoneNumber field.');
|
|
437
|
+
}
|
|
438
|
+
properties.phoneNumber = properties.providerToLink.uid;
|
|
439
|
+
delete properties.providerToLink;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
if (properties === null || properties === void 0 ? void 0 : properties.providersToUnlink) {
|
|
443
|
+
if (properties.providersToUnlink.indexOf('phone') !== -1) {
|
|
444
|
+
// If we've been told to unlink the phone provider both via setting
|
|
445
|
+
// phoneNumber to null *and* by setting providersToUnlink to include
|
|
446
|
+
// 'phone', then we'll reject that. Though it might also be reasonable
|
|
447
|
+
// to relax this restriction and just unlink it.
|
|
448
|
+
if (properties.phoneNumber === null) {
|
|
449
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "Both UpdateRequest.phoneNumber=null and UpdateRequest.providersToUnlink=['phone'] were set. To "
|
|
450
|
+
+ 'unlink from a phone provider, only specify the UpdateRequest.phoneNumber=null field.');
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
369
454
|
return this.authRequestHandler.updateExistingAccount(uid, properties)
|
|
370
455
|
.then(function (existingUid) {
|
|
371
456
|
// Return the corresponding user record.
|
|
@@ -381,18 +466,18 @@ var BaseAuth = /** @class */ (function () {
|
|
|
381
466
|
* is used (sub, iat, iss, etc), an error is thrown. They are set on the
|
|
382
467
|
* authenticated user's ID token JWT.
|
|
383
468
|
*
|
|
384
|
-
* See
|
|
385
|
-
*
|
|
469
|
+
* See {@link https://firebase.google.com/docs/auth/admin/custom-claims |
|
|
470
|
+
* Defining user roles and access levels}
|
|
386
471
|
* for code samples and detailed documentation.
|
|
387
472
|
*
|
|
388
|
-
* @param uid The `uid` of the user to edit.
|
|
389
|
-
* @param customUserClaims The developer claims to set. If null is
|
|
473
|
+
* @param uid - The `uid` of the user to edit.
|
|
474
|
+
* @param customUserClaims - The developer claims to set. If null is
|
|
390
475
|
* passed, existing custom claims are deleted. Passing a custom claims payload
|
|
391
476
|
* larger than 1000 bytes will throw an error. Custom claims are added to the
|
|
392
477
|
* user's ID token which is transmitted on every authenticated request.
|
|
393
478
|
* For profile non-access related user attributes, use database or other
|
|
394
479
|
* separate storage systems.
|
|
395
|
-
* @
|
|
480
|
+
* @returns A promise that resolves when the operation completes
|
|
396
481
|
* successfully.
|
|
397
482
|
*/
|
|
398
483
|
BaseAuth.prototype.setCustomUserClaims = function (uid, customUserClaims) {
|
|
@@ -404,22 +489,20 @@ var BaseAuth = /** @class */ (function () {
|
|
|
404
489
|
/**
|
|
405
490
|
* Revokes all refresh tokens for an existing user.
|
|
406
491
|
*
|
|
407
|
-
* This API will update the user's
|
|
408
|
-
* {@link auth.UserRecord.tokensValidAfterTime `tokensValidAfterTime`} to
|
|
492
|
+
* This API will update the user's {@link UserRecord.tokensValidAfterTime} to
|
|
409
493
|
* the current UTC. It is important that the server on which this is called has
|
|
410
494
|
* its clock set correctly and synchronized.
|
|
411
495
|
*
|
|
412
496
|
* While this will revoke all sessions for a specified user and disable any
|
|
413
497
|
* new ID tokens for existing sessions from getting minted, existing ID tokens
|
|
414
498
|
* may remain active until their natural expiration (one hour). To verify that
|
|
415
|
-
* ID tokens are revoked, use
|
|
416
|
-
* {@link auth.Auth.verifyIdToken `verifyIdToken(idToken, true)`}
|
|
499
|
+
* ID tokens are revoked, use {@link BaseAuth.verifyIdToken}
|
|
417
500
|
* where `checkRevoked` is set to true.
|
|
418
501
|
*
|
|
419
|
-
* @param uid The `uid` corresponding to the user whose refresh tokens
|
|
502
|
+
* @param uid - The `uid` corresponding to the user whose refresh tokens
|
|
420
503
|
* are to be revoked.
|
|
421
504
|
*
|
|
422
|
-
* @
|
|
505
|
+
* @returns An empty promise fulfilled once the user's refresh
|
|
423
506
|
* tokens have been revoked.
|
|
424
507
|
*/
|
|
425
508
|
BaseAuth.prototype.revokeRefreshTokens = function (uid) {
|
|
@@ -432,15 +515,15 @@ var BaseAuth = /** @class */ (function () {
|
|
|
432
515
|
* Imports the provided list of users into Firebase Auth.
|
|
433
516
|
* A maximum of 1000 users are allowed to be imported one at a time.
|
|
434
517
|
* When importing users with passwords,
|
|
435
|
-
* {@link
|
|
518
|
+
* {@link UserImportOptions} are required to be
|
|
436
519
|
* specified.
|
|
437
520
|
* This operation is optimized for bulk imports and will ignore checks on `uid`,
|
|
438
521
|
* `email` and other identifier uniqueness which could result in duplications.
|
|
439
522
|
*
|
|
440
|
-
* @param users The list of user records to import to Firebase Auth.
|
|
441
|
-
* @param options The user import options, required when the users provided include
|
|
523
|
+
* @param users - The list of user records to import to Firebase Auth.
|
|
524
|
+
* @param options - The user import options, required when the users provided include
|
|
442
525
|
* password credentials.
|
|
443
|
-
* @
|
|
526
|
+
* @returns A promise that resolves when
|
|
444
527
|
* the operation completes with the result of the import. This includes the
|
|
445
528
|
* number of successful imports, the number of failed imports and their
|
|
446
529
|
* corresponding errors.
|
|
@@ -454,15 +537,15 @@ var BaseAuth = /** @class */ (function () {
|
|
|
454
537
|
* policy, and be used for session management. The session cookie JWT will have
|
|
455
538
|
* the same payload claims as the provided ID token.
|
|
456
539
|
*
|
|
457
|
-
* See
|
|
458
|
-
* samples and detailed documentation.
|
|
540
|
+
* See {@link https://firebase.google.com/docs/auth/admin/manage-cookies | Manage Session Cookies}
|
|
541
|
+
* for code samples and detailed documentation.
|
|
459
542
|
*
|
|
460
|
-
* @param idToken The Firebase ID token to exchange for a session
|
|
543
|
+
* @param idToken - The Firebase ID token to exchange for a session
|
|
461
544
|
* cookie.
|
|
462
|
-
* @param sessionCookieOptions The session
|
|
545
|
+
* @param sessionCookieOptions - The session
|
|
463
546
|
* cookie options which includes custom session duration.
|
|
464
547
|
*
|
|
465
|
-
* @
|
|
548
|
+
* @returns A promise that resolves on success with the
|
|
466
549
|
* created session cookie.
|
|
467
550
|
*/
|
|
468
551
|
BaseAuth.prototype.createSessionCookie = function (idToken, sessionCookieOptions) {
|
|
@@ -475,41 +558,46 @@ var BaseAuth = /** @class */ (function () {
|
|
|
475
558
|
};
|
|
476
559
|
/**
|
|
477
560
|
* Verifies a Firebase session cookie. Returns a Promise with the cookie claims.
|
|
478
|
-
* Rejects the promise if the cookie could not be verified.
|
|
479
|
-
* set to true, verifies if the session corresponding to the session cookie was
|
|
480
|
-
* revoked. If the corresponding user's session was revoked, an
|
|
481
|
-
* `auth/session-cookie-revoked` error is thrown. If not specified the check is
|
|
482
|
-
* not performed.
|
|
561
|
+
* Rejects the promise if the cookie could not be verified.
|
|
483
562
|
*
|
|
484
|
-
*
|
|
563
|
+
* If `checkRevoked` is set to true, first verifies whether the corresponding
|
|
564
|
+
* user is disabled: If yes, an `auth/user-disabled` error is thrown. If no,
|
|
565
|
+
* verifies if the session corresponding to the session cookie was revoked.
|
|
566
|
+
* If the corresponding user's session was invalidated, an
|
|
567
|
+
* `auth/session-cookie-revoked` error is thrown. If not specified the check
|
|
568
|
+
* is not performed.
|
|
569
|
+
*
|
|
570
|
+
* See {@link https://firebase.google.com/docs/auth/admin/manage-cookies#verify_session_cookie_and_check_permissions |
|
|
571
|
+
* Verify Session Cookies}
|
|
485
572
|
* for code samples and detailed documentation
|
|
486
573
|
*
|
|
487
|
-
* @param sessionCookie The session cookie to verify.
|
|
488
|
-
* @param checkForRevocation Whether to check if the session cookie was
|
|
574
|
+
* @param sessionCookie - The session cookie to verify.
|
|
575
|
+
* @param checkForRevocation - Whether to check if the session cookie was
|
|
489
576
|
* revoked. This requires an extra request to the Firebase Auth backend to
|
|
490
577
|
* check the `tokensValidAfterTime` time for the corresponding user.
|
|
491
578
|
* When not specified, this additional check is not performed.
|
|
492
579
|
*
|
|
493
|
-
* @
|
|
580
|
+
* @returns A promise fulfilled with the
|
|
494
581
|
* session cookie's decoded claims if the session cookie is valid; otherwise,
|
|
495
582
|
* a rejected promise.
|
|
496
583
|
*/
|
|
497
584
|
BaseAuth.prototype.verifySessionCookie = function (sessionCookie, checkRevoked) {
|
|
498
585
|
var _this = this;
|
|
499
586
|
if (checkRevoked === void 0) { checkRevoked = false; }
|
|
500
|
-
|
|
587
|
+
var isEmulator = auth_api_request_1.useEmulator();
|
|
588
|
+
return this.sessionCookieVerifier.verifyJWT(sessionCookie, isEmulator)
|
|
501
589
|
.then(function (decodedIdToken) {
|
|
502
590
|
// Whether to check if the token was revoked.
|
|
503
|
-
if (
|
|
504
|
-
return decodedIdToken;
|
|
591
|
+
if (checkRevoked || isEmulator) {
|
|
592
|
+
return _this.verifyDecodedJWTNotRevokedOrDisabled(decodedIdToken, error_1.AuthClientErrorCode.SESSION_COOKIE_REVOKED);
|
|
505
593
|
}
|
|
506
|
-
return
|
|
594
|
+
return decodedIdToken;
|
|
507
595
|
});
|
|
508
596
|
};
|
|
509
597
|
/**
|
|
510
598
|
* Generates the out of band email action link to reset a user's password.
|
|
511
599
|
* The link is generated for the user with the specified email address. The
|
|
512
|
-
* optional {@link
|
|
600
|
+
* optional {@link ActionCodeSettings} object
|
|
513
601
|
* defines whether the link is to be handled by a mobile app or browser and the
|
|
514
602
|
* additional state information to be passed in the deep link, etc.
|
|
515
603
|
*
|
|
@@ -538,9 +626,9 @@ var BaseAuth = /** @class */ (function () {
|
|
|
538
626
|
* });
|
|
539
627
|
* ```
|
|
540
628
|
*
|
|
541
|
-
* @param email The email address of the user whose password is to be
|
|
629
|
+
* @param email - The email address of the user whose password is to be
|
|
542
630
|
* reset.
|
|
543
|
-
* @param actionCodeSettings The action
|
|
631
|
+
* @param actionCodeSettings - The action
|
|
544
632
|
* code settings. If specified, the state/continue URL is set as the
|
|
545
633
|
* "continueUrl" parameter in the password reset link. The default password
|
|
546
634
|
* reset landing page will use this to display a link to go back to the app
|
|
@@ -553,15 +641,14 @@ var BaseAuth = /** @class */ (function () {
|
|
|
553
641
|
* and accepts the Firebase Dynamic Links terms of service.
|
|
554
642
|
* The Android package name and iOS bundle ID are respected only if they
|
|
555
643
|
* are configured in the same Firebase Auth project.
|
|
556
|
-
* @
|
|
644
|
+
* @returns A promise that resolves with the generated link.
|
|
557
645
|
*/
|
|
558
646
|
BaseAuth.prototype.generatePasswordResetLink = function (email, actionCodeSettings) {
|
|
559
647
|
return this.authRequestHandler.getEmailActionLink('PASSWORD_RESET', email, actionCodeSettings);
|
|
560
648
|
};
|
|
561
649
|
/**
|
|
562
650
|
* Generates the out of band email action link to verify the user's ownership
|
|
563
|
-
* of the specified email. The
|
|
564
|
-
* {@link auth.ActionCodeSettings `ActionCodeSettings`} object provided
|
|
651
|
+
* of the specified email. The {@link ActionCodeSettings} object provided
|
|
565
652
|
* as an argument to this method defines whether the link is to be handled by a
|
|
566
653
|
* mobile app or browser along with additional state information to be passed in
|
|
567
654
|
* the deep link, etc.
|
|
@@ -591,8 +678,8 @@ var BaseAuth = /** @class */ (function () {
|
|
|
591
678
|
* });
|
|
592
679
|
* ```
|
|
593
680
|
*
|
|
594
|
-
* @param email The email account to verify.
|
|
595
|
-
* @param actionCodeSettings The action
|
|
681
|
+
* @param email - The email account to verify.
|
|
682
|
+
* @param actionCodeSettings - The action
|
|
596
683
|
* code settings. If specified, the state/continue URL is set as the
|
|
597
684
|
* "continueUrl" parameter in the email verification link. The default email
|
|
598
685
|
* verification landing page will use this to display a link to go back to
|
|
@@ -605,15 +692,14 @@ var BaseAuth = /** @class */ (function () {
|
|
|
605
692
|
* and accepts the Firebase Dynamic Links terms of service.
|
|
606
693
|
* The Android package name and iOS bundle ID are respected only if they
|
|
607
694
|
* are configured in the same Firebase Auth project.
|
|
608
|
-
* @
|
|
695
|
+
* @returns A promise that resolves with the generated link.
|
|
609
696
|
*/
|
|
610
697
|
BaseAuth.prototype.generateEmailVerificationLink = function (email, actionCodeSettings) {
|
|
611
698
|
return this.authRequestHandler.getEmailActionLink('VERIFY_EMAIL', email, actionCodeSettings);
|
|
612
699
|
};
|
|
613
700
|
/**
|
|
614
701
|
* Generates the out of band email action link to verify the user's ownership
|
|
615
|
-
* of the specified email. The
|
|
616
|
-
* {@link auth.ActionCodeSettings `ActionCodeSettings`} object provided
|
|
702
|
+
* of the specified email. The {@link ActionCodeSettings} object provided
|
|
617
703
|
* as an argument to this method defines whether the link is to be handled by a
|
|
618
704
|
* mobile app or browser along with additional state information to be passed in
|
|
619
705
|
* the deep link, etc.
|
|
@@ -643,8 +729,8 @@ var BaseAuth = /** @class */ (function () {
|
|
|
643
729
|
* });
|
|
644
730
|
* ```
|
|
645
731
|
*
|
|
646
|
-
* @param email The email account to verify.
|
|
647
|
-
* @param actionCodeSettings The action
|
|
732
|
+
* @param email - The email account to verify.
|
|
733
|
+
* @param actionCodeSettings - The action
|
|
648
734
|
* code settings. If specified, the state/continue URL is set as the
|
|
649
735
|
* "continueUrl" parameter in the email verification link. The default email
|
|
650
736
|
* verification landing page will use this to display a link to go back to
|
|
@@ -657,7 +743,7 @@ var BaseAuth = /** @class */ (function () {
|
|
|
657
743
|
* and accepts the Firebase Dynamic Links terms of service.
|
|
658
744
|
* The Android package name and iOS bundle ID are respected only if they
|
|
659
745
|
* are configured in the same Firebase Auth project.
|
|
660
|
-
* @
|
|
746
|
+
* @returns A promise that resolves with the generated link.
|
|
661
747
|
*/
|
|
662
748
|
BaseAuth.prototype.generateSignInWithEmailLink = function (email, actionCodeSettings) {
|
|
663
749
|
return this.authRequestHandler.getEmailActionLink('EMAIL_SIGNIN', email, actionCodeSettings);
|
|
@@ -668,10 +754,10 @@ var BaseAuth = /** @class */ (function () {
|
|
|
668
754
|
*
|
|
669
755
|
* SAML and OIDC provider support requires Google Cloud's Identity Platform
|
|
670
756
|
* (GCIP). To learn more about GCIP, including pricing and features,
|
|
671
|
-
* see the
|
|
757
|
+
* see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
|
|
672
758
|
*
|
|
673
|
-
* @param options The provider config filter to apply.
|
|
674
|
-
* @
|
|
759
|
+
* @param options - The provider config filter to apply.
|
|
760
|
+
* @returns A promise that resolves with the list of provider configs meeting the
|
|
675
761
|
* filter requirements.
|
|
676
762
|
*/
|
|
677
763
|
BaseAuth.prototype.listProviderConfigs = function (options) {
|
|
@@ -722,11 +808,11 @@ var BaseAuth = /** @class */ (function () {
|
|
|
722
808
|
*
|
|
723
809
|
* SAML and OIDC provider support requires Google Cloud's Identity Platform
|
|
724
810
|
* (GCIP). To learn more about GCIP, including pricing and features,
|
|
725
|
-
* see the
|
|
811
|
+
* see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
|
|
726
812
|
*
|
|
727
|
-
* @param providerId The provider ID corresponding to the provider
|
|
813
|
+
* @param providerId - The provider ID corresponding to the provider
|
|
728
814
|
* config to return.
|
|
729
|
-
* @
|
|
815
|
+
* @returns A promise that resolves
|
|
730
816
|
* with the configuration corresponding to the provided ID.
|
|
731
817
|
*/
|
|
732
818
|
BaseAuth.prototype.getProviderConfig = function (providerId) {
|
|
@@ -751,11 +837,11 @@ var BaseAuth = /** @class */ (function () {
|
|
|
751
837
|
*
|
|
752
838
|
* SAML and OIDC provider support requires Google Cloud's Identity Platform
|
|
753
839
|
* (GCIP). To learn more about GCIP, including pricing and features,
|
|
754
|
-
* see the
|
|
840
|
+
* see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
|
|
755
841
|
*
|
|
756
|
-
* @param providerId The provider ID corresponding to the provider
|
|
842
|
+
* @param providerId - The provider ID corresponding to the provider
|
|
757
843
|
* config to delete.
|
|
758
|
-
* @
|
|
844
|
+
* @returns A promise that resolves on completion.
|
|
759
845
|
*/
|
|
760
846
|
BaseAuth.prototype.deleteProviderConfig = function (providerId) {
|
|
761
847
|
if (auth_config_1.OIDCConfig.isProviderId(providerId)) {
|
|
@@ -774,12 +860,12 @@ var BaseAuth = /** @class */ (function () {
|
|
|
774
860
|
*
|
|
775
861
|
* SAML and OIDC provider support requires Google Cloud's Identity Platform
|
|
776
862
|
* (GCIP). To learn more about GCIP, including pricing and features,
|
|
777
|
-
* see the
|
|
863
|
+
* see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
|
|
778
864
|
*
|
|
779
|
-
* @param providerId The provider ID corresponding to the provider
|
|
865
|
+
* @param providerId - The provider ID corresponding to the provider
|
|
780
866
|
* config to update.
|
|
781
|
-
* @param updatedConfig The updated configuration.
|
|
782
|
-
* @
|
|
867
|
+
* @param updatedConfig - The updated configuration.
|
|
868
|
+
* @returns A promise that resolves with the updated provider configuration.
|
|
783
869
|
*/
|
|
784
870
|
BaseAuth.prototype.updateProviderConfig = function (providerId, updatedConfig) {
|
|
785
871
|
if (!validator.isNonNullObject(updatedConfig)) {
|
|
@@ -805,10 +891,10 @@ var BaseAuth = /** @class */ (function () {
|
|
|
805
891
|
*
|
|
806
892
|
* SAML and OIDC provider support requires Google Cloud's Identity Platform
|
|
807
893
|
* (GCIP). To learn more about GCIP, including pricing and features,
|
|
808
|
-
* see the
|
|
894
|
+
* see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
|
|
809
895
|
*
|
|
810
|
-
* @param config The provider configuration to create.
|
|
811
|
-
* @
|
|
896
|
+
* @param config - The provider configuration to create.
|
|
897
|
+
* @returns A promise that resolves with the created provider configuration.
|
|
812
898
|
*/
|
|
813
899
|
BaseAuth.prototype.createProviderConfig = function (config) {
|
|
814
900
|
if (!validator.isNonNullObject(config)) {
|
|
@@ -829,18 +915,22 @@ var BaseAuth = /** @class */ (function () {
|
|
|
829
915
|
return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_PROVIDER_ID));
|
|
830
916
|
};
|
|
831
917
|
/**
|
|
832
|
-
* Verifies the decoded Firebase issued JWT is not revoked. Returns a promise that
|
|
833
|
-
* with the decoded claims on success. Rejects the promise with revocation error if revoked
|
|
918
|
+
* Verifies the decoded Firebase issued JWT is not revoked or disabled. Returns a promise that
|
|
919
|
+
* resolves with the decoded claims on success. Rejects the promise with revocation error if revoked
|
|
920
|
+
* or user disabled.
|
|
834
921
|
*
|
|
835
|
-
* @param decodedIdToken The JWT's decoded claims.
|
|
836
|
-
* @param revocationErrorInfo The revocation error info to throw on revocation
|
|
922
|
+
* @param decodedIdToken - The JWT's decoded claims.
|
|
923
|
+
* @param revocationErrorInfo - The revocation error info to throw on revocation
|
|
837
924
|
* detection.
|
|
838
|
-
* @
|
|
925
|
+
* @returns A promise that will be fulfilled after a successful verification.
|
|
839
926
|
*/
|
|
840
|
-
BaseAuth.prototype.
|
|
927
|
+
BaseAuth.prototype.verifyDecodedJWTNotRevokedOrDisabled = function (decodedIdToken, revocationErrorInfo) {
|
|
841
928
|
// Get tokens valid after time for the corresponding user.
|
|
842
929
|
return this.getUser(decodedIdToken.sub)
|
|
843
930
|
.then(function (user) {
|
|
931
|
+
if (user.disabled) {
|
|
932
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.USER_DISABLED, 'The user record is disabled.');
|
|
933
|
+
}
|
|
844
934
|
// If no tokens valid after time available, token is not revoked.
|
|
845
935
|
if (user.tokensValidAfterTime) {
|
|
846
936
|
// Get the ID token authentication time and convert to milliseconds UTC.
|
|
@@ -856,26 +946,6 @@ var BaseAuth = /** @class */ (function () {
|
|
|
856
946
|
return decodedIdToken;
|
|
857
947
|
});
|
|
858
948
|
};
|
|
859
|
-
/**
|
|
860
|
-
* Enable or disable ID token verification. This is used to safely short-circuit token verification with the
|
|
861
|
-
* Auth emulator. When disabled ONLY unsigned tokens will pass verification, production tokens will not pass.
|
|
862
|
-
*
|
|
863
|
-
* WARNING: This is a dangerous method that will compromise your app's security and break your app in
|
|
864
|
-
* production. Developers should never call this method, it is for internal testing use only.
|
|
865
|
-
*
|
|
866
|
-
* @internal
|
|
867
|
-
*/
|
|
868
|
-
// @ts-expect-error: this method appears unused but is used privately.
|
|
869
|
-
BaseAuth.prototype.setJwtVerificationEnabled = function (enabled) {
|
|
870
|
-
if (!enabled && !auth_api_request_1.useEmulator()) {
|
|
871
|
-
// We only allow verification to be disabled in conjunction with
|
|
872
|
-
// the emulator environment variable.
|
|
873
|
-
throw new Error('This method is only available when connected to the Authentication emulator.');
|
|
874
|
-
}
|
|
875
|
-
var algorithm = enabled ? token_verifier_1.ALGORITHM_RS256 : 'none';
|
|
876
|
-
this.idTokenVerifier.setAlgorithm(algorithm);
|
|
877
|
-
this.sessionCookieVerifier.setAlgorithm(algorithm);
|
|
878
|
-
};
|
|
879
949
|
return BaseAuth;
|
|
880
950
|
}());
|
|
881
951
|
exports.BaseAuth = BaseAuth;
|