firebase-admin 10.2.0 → 11.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- 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 +7 -1
- package/lib/app/credential-internal.js +120 -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 +62 -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 +19 -1
- package/lib/functions/functions-api-client-internal.js +83 -103
- 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 +3 -1
- package/lib/security-rules/security-rules-api-client-internal.js +118 -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 +83 -92
- 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 +25 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v11.0.1 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2018 Google Inc.
|
|
@@ -17,38 +17,38 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.UserImportBuilder = exports.convertMultiFactorInfoToServerFormat = void 0;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const deep_copy_1 = require("../utils/deep-copy");
|
|
21
|
+
const utils = require("../utils");
|
|
22
|
+
const validator = require("../utils/validator");
|
|
23
|
+
const error_1 = require("../utils/error");
|
|
24
24
|
/**
|
|
25
25
|
* Converts a client format second factor object to server format.
|
|
26
26
|
* @param multiFactorInfo - The client format second factor.
|
|
27
27
|
* @returns The corresponding AuthFactorInfo server request format.
|
|
28
28
|
*/
|
|
29
29
|
function convertMultiFactorInfoToServerFormat(multiFactorInfo) {
|
|
30
|
-
|
|
30
|
+
let enrolledAt;
|
|
31
31
|
if (typeof multiFactorInfo.enrollmentTime !== 'undefined') {
|
|
32
32
|
if (validator.isUTCDateString(multiFactorInfo.enrollmentTime)) {
|
|
33
33
|
// Convert from UTC date string (client side format) to ISO date string (server side format).
|
|
34
34
|
enrolledAt = new Date(multiFactorInfo.enrollmentTime).toISOString();
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ENROLLMENT_TIME,
|
|
37
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ENROLLMENT_TIME, `The second factor "enrollmentTime" for "${multiFactorInfo.uid}" must be a valid ` +
|
|
38
38
|
'UTC date string.');
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
// Currently only phone second factors are supported.
|
|
42
42
|
if (isPhoneFactor(multiFactorInfo)) {
|
|
43
43
|
// If any required field is missing or invalid, validation will still fail later.
|
|
44
|
-
|
|
44
|
+
const authFactorInfo = {
|
|
45
45
|
mfaEnrollmentId: multiFactorInfo.uid,
|
|
46
46
|
displayName: multiFactorInfo.displayName,
|
|
47
47
|
// Required for all phone second factors.
|
|
48
48
|
phoneInfo: multiFactorInfo.phoneNumber,
|
|
49
|
-
enrolledAt
|
|
49
|
+
enrolledAt,
|
|
50
50
|
};
|
|
51
|
-
for (
|
|
51
|
+
for (const objKey in authFactorInfo) {
|
|
52
52
|
if (typeof authFactorInfo[objKey] === 'undefined') {
|
|
53
53
|
delete authFactorInfo[objKey];
|
|
54
54
|
}
|
|
@@ -57,7 +57,7 @@ function convertMultiFactorInfoToServerFormat(multiFactorInfo) {
|
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
59
|
// Unsupported second factor.
|
|
60
|
-
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.UNSUPPORTED_SECOND_FACTOR,
|
|
60
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.UNSUPPORTED_SECOND_FACTOR, `Unsupported second factor "${JSON.stringify(multiFactorInfo)}" provided.`);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
exports.convertMultiFactorInfoToServerFormat = convertMultiFactorInfoToServerFormat;
|
|
@@ -83,7 +83,7 @@ function getNumberField(obj, key) {
|
|
|
83
83
|
* @returns {UploadAccountUser} The corresponding UploadAccountUser to return.
|
|
84
84
|
*/
|
|
85
85
|
function populateUploadAccountUser(user, userValidator) {
|
|
86
|
-
|
|
86
|
+
const result = {
|
|
87
87
|
localId: user.uid,
|
|
88
88
|
email: user.email,
|
|
89
89
|
emailVerified: user.emailVerified,
|
|
@@ -117,7 +117,7 @@ function populateUploadAccountUser(user, userValidator) {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
if (validator.isArray(user.providerData)) {
|
|
120
|
-
user.providerData.forEach(
|
|
120
|
+
user.providerData.forEach((providerData) => {
|
|
121
121
|
result.providerUserInfo.push({
|
|
122
122
|
providerId: providerData.providerId,
|
|
123
123
|
rawId: providerData.uid,
|
|
@@ -130,12 +130,12 @@ function populateUploadAccountUser(user, userValidator) {
|
|
|
130
130
|
// Convert user.multiFactor.enrolledFactors to server format.
|
|
131
131
|
if (validator.isNonNullObject(user.multiFactor) &&
|
|
132
132
|
validator.isNonEmptyArray(user.multiFactor.enrolledFactors)) {
|
|
133
|
-
user.multiFactor.enrolledFactors.forEach(
|
|
133
|
+
user.multiFactor.enrolledFactors.forEach((multiFactorInfo) => {
|
|
134
134
|
result.mfaInfo.push(convertMultiFactorInfoToServerFormat(multiFactorInfo));
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
// Remove blank fields.
|
|
138
|
-
|
|
138
|
+
let key;
|
|
139
139
|
for (key in result) {
|
|
140
140
|
if (typeof result[key] === 'undefined') {
|
|
141
141
|
delete result[key];
|
|
@@ -158,7 +158,7 @@ function populateUploadAccountUser(user, userValidator) {
|
|
|
158
158
|
* Class that provides a helper for building/validating uploadAccount requests and
|
|
159
159
|
* UserImportResult responses.
|
|
160
160
|
*/
|
|
161
|
-
|
|
161
|
+
class UserImportBuilder {
|
|
162
162
|
/**
|
|
163
163
|
* @param {UserImportRecord[]} users The list of user records to import.
|
|
164
164
|
* @param {UserImportOptions=} options The import options which includes hashing
|
|
@@ -166,7 +166,7 @@ var UserImportBuilder = /** @class */ (function () {
|
|
|
166
166
|
* @param {ValidatorFunction=} userRequestValidator The user request validator function.
|
|
167
167
|
* @constructor
|
|
168
168
|
*/
|
|
169
|
-
|
|
169
|
+
constructor(users, options, userRequestValidator) {
|
|
170
170
|
this.requiresHashOptions = false;
|
|
171
171
|
this.validatedUsers = [];
|
|
172
172
|
this.userImportResultErrors = [];
|
|
@@ -178,42 +178,41 @@ var UserImportBuilder = /** @class */ (function () {
|
|
|
178
178
|
* Returns the corresponding constructed uploadAccount request.
|
|
179
179
|
* @returns {UploadAccountRequest} The constructed uploadAccount request.
|
|
180
180
|
*/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return deep_copy_1.deepCopy(user);
|
|
181
|
+
buildRequest() {
|
|
182
|
+
const users = this.validatedUsers.map((user) => {
|
|
183
|
+
return (0, deep_copy_1.deepCopy)(user);
|
|
184
184
|
});
|
|
185
|
-
return deep_copy_1.deepExtend({ users
|
|
186
|
-
}
|
|
185
|
+
return (0, deep_copy_1.deepExtend)({ users }, (0, deep_copy_1.deepCopy)(this.validatedOptions));
|
|
186
|
+
}
|
|
187
187
|
/**
|
|
188
188
|
* Populates the UserImportResult using the client side detected errors and the server
|
|
189
189
|
* side returned errors.
|
|
190
190
|
* @returns {UserImportResult} The user import result based on the returned failed
|
|
191
191
|
* uploadAccount response.
|
|
192
192
|
*/
|
|
193
|
-
|
|
194
|
-
var _this = this;
|
|
193
|
+
buildResponse(failedUploads) {
|
|
195
194
|
// Initialize user import result.
|
|
196
|
-
|
|
195
|
+
const importResult = {
|
|
197
196
|
successCount: this.validatedUsers.length,
|
|
198
197
|
failureCount: this.userImportResultErrors.length,
|
|
199
|
-
errors: deep_copy_1.deepCopy(this.userImportResultErrors),
|
|
198
|
+
errors: (0, deep_copy_1.deepCopy)(this.userImportResultErrors),
|
|
200
199
|
};
|
|
201
200
|
importResult.failureCount += failedUploads.length;
|
|
202
201
|
importResult.successCount -= failedUploads.length;
|
|
203
|
-
failedUploads.forEach(
|
|
202
|
+
failedUploads.forEach((failedUpload) => {
|
|
204
203
|
importResult.errors.push({
|
|
205
204
|
// Map backend request index to original developer provided array index.
|
|
206
|
-
index:
|
|
205
|
+
index: this.indexMap[failedUpload.index],
|
|
207
206
|
error: new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_USER_IMPORT, failedUpload.message),
|
|
208
207
|
});
|
|
209
208
|
});
|
|
210
209
|
// Sort errors by index.
|
|
211
|
-
importResult.errors.sort(
|
|
210
|
+
importResult.errors.sort((a, b) => {
|
|
212
211
|
return a.index - b.index;
|
|
213
212
|
});
|
|
214
213
|
// Return sorted result.
|
|
215
214
|
return importResult;
|
|
216
|
-
}
|
|
215
|
+
}
|
|
217
216
|
/**
|
|
218
217
|
* Validates and returns the hashing options of the uploadAccount request.
|
|
219
218
|
* Throws an error whenever an invalid or missing options is detected.
|
|
@@ -221,8 +220,8 @@ var UserImportBuilder = /** @class */ (function () {
|
|
|
221
220
|
* @param {boolean} requiresHashOptions Whether to require hash options.
|
|
222
221
|
* @returns {UploadAccountOptions} The populated UploadAccount options.
|
|
223
222
|
*/
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
populateOptions(options, requiresHashOptions) {
|
|
224
|
+
let populatedOptions;
|
|
226
225
|
if (!requiresHashOptions) {
|
|
227
226
|
return {};
|
|
228
227
|
}
|
|
@@ -236,7 +235,7 @@ var UserImportBuilder = /** @class */ (function () {
|
|
|
236
235
|
!validator.isNonEmptyString(options.hash.algorithm)) {
|
|
237
236
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_ALGORITHM, '"hash.algorithm" must be a string matching the list of supported algorithms.');
|
|
238
237
|
}
|
|
239
|
-
|
|
238
|
+
let rounds;
|
|
240
239
|
switch (options.hash.algorithm) {
|
|
241
240
|
case 'HMAC_SHA512':
|
|
242
241
|
case 'HMAC_SHA256':
|
|
@@ -244,7 +243,7 @@ var UserImportBuilder = /** @class */ (function () {
|
|
|
244
243
|
case 'HMAC_MD5':
|
|
245
244
|
if (!validator.isBuffer(options.hash.key)) {
|
|
246
245
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_KEY, 'A non-empty "hash.key" byte buffer must be provided for ' +
|
|
247
|
-
|
|
246
|
+
`hash algorithm ${options.hash.algorithm}.`);
|
|
248
247
|
}
|
|
249
248
|
populatedOptions = {
|
|
250
249
|
hashAlgorithm: options.hash.algorithm,
|
|
@@ -257,14 +256,14 @@ var UserImportBuilder = /** @class */ (function () {
|
|
|
257
256
|
case 'SHA512': {
|
|
258
257
|
// MD5 is [0,8192] but SHA1, SHA256, and SHA512 are [1,8192]
|
|
259
258
|
rounds = getNumberField(options.hash, 'rounds');
|
|
260
|
-
|
|
259
|
+
const minRounds = options.hash.algorithm === 'MD5' ? 0 : 1;
|
|
261
260
|
if (isNaN(rounds) || rounds < minRounds || rounds > 8192) {
|
|
262
|
-
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_ROUNDS,
|
|
263
|
-
|
|
261
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_ROUNDS, `A valid "hash.rounds" number between ${minRounds} and 8192 must be provided for ` +
|
|
262
|
+
`hash algorithm ${options.hash.algorithm}.`);
|
|
264
263
|
}
|
|
265
264
|
populatedOptions = {
|
|
266
265
|
hashAlgorithm: options.hash.algorithm,
|
|
267
|
-
rounds
|
|
266
|
+
rounds,
|
|
268
267
|
};
|
|
269
268
|
break;
|
|
270
269
|
}
|
|
@@ -273,27 +272,27 @@ var UserImportBuilder = /** @class */ (function () {
|
|
|
273
272
|
rounds = getNumberField(options.hash, 'rounds');
|
|
274
273
|
if (isNaN(rounds) || rounds < 0 || rounds > 120000) {
|
|
275
274
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_ROUNDS, 'A valid "hash.rounds" number between 0 and 120000 must be provided for ' +
|
|
276
|
-
|
|
275
|
+
`hash algorithm ${options.hash.algorithm}.`);
|
|
277
276
|
}
|
|
278
277
|
populatedOptions = {
|
|
279
278
|
hashAlgorithm: options.hash.algorithm,
|
|
280
|
-
rounds
|
|
279
|
+
rounds,
|
|
281
280
|
};
|
|
282
281
|
break;
|
|
283
282
|
case 'SCRYPT': {
|
|
284
283
|
if (!validator.isBuffer(options.hash.key)) {
|
|
285
284
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_KEY, 'A "hash.key" byte buffer must be provided for ' +
|
|
286
|
-
|
|
285
|
+
`hash algorithm ${options.hash.algorithm}.`);
|
|
287
286
|
}
|
|
288
287
|
rounds = getNumberField(options.hash, 'rounds');
|
|
289
288
|
if (isNaN(rounds) || rounds <= 0 || rounds > 8) {
|
|
290
289
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_ROUNDS, 'A valid "hash.rounds" number between 1 and 8 must be provided for ' +
|
|
291
|
-
|
|
290
|
+
`hash algorithm ${options.hash.algorithm}.`);
|
|
292
291
|
}
|
|
293
|
-
|
|
292
|
+
const memoryCost = getNumberField(options.hash, 'memoryCost');
|
|
294
293
|
if (isNaN(memoryCost) || memoryCost <= 0 || memoryCost > 14) {
|
|
295
294
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_MEMORY_COST, 'A valid "hash.memoryCost" number between 1 and 14 must be provided for ' +
|
|
296
|
-
|
|
295
|
+
`hash algorithm ${options.hash.algorithm}.`);
|
|
297
296
|
}
|
|
298
297
|
if (typeof options.hash.saltSeparator !== 'undefined' &&
|
|
299
298
|
!validator.isBuffer(options.hash.saltSeparator)) {
|
|
@@ -302,8 +301,8 @@ var UserImportBuilder = /** @class */ (function () {
|
|
|
302
301
|
populatedOptions = {
|
|
303
302
|
hashAlgorithm: options.hash.algorithm,
|
|
304
303
|
signerKey: utils.toWebSafeBase64(options.hash.key),
|
|
305
|
-
rounds
|
|
306
|
-
memoryCost
|
|
304
|
+
rounds,
|
|
305
|
+
memoryCost,
|
|
307
306
|
saltSeparator: utils.toWebSafeBase64(options.hash.saltSeparator || Buffer.from('')),
|
|
308
307
|
};
|
|
309
308
|
break;
|
|
@@ -314,40 +313,40 @@ var UserImportBuilder = /** @class */ (function () {
|
|
|
314
313
|
};
|
|
315
314
|
break;
|
|
316
315
|
case 'STANDARD_SCRYPT': {
|
|
317
|
-
|
|
316
|
+
const cpuMemCost = getNumberField(options.hash, 'memoryCost');
|
|
318
317
|
if (isNaN(cpuMemCost)) {
|
|
319
318
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_MEMORY_COST, 'A valid "hash.memoryCost" number must be provided for ' +
|
|
320
|
-
|
|
319
|
+
`hash algorithm ${options.hash.algorithm}.`);
|
|
321
320
|
}
|
|
322
|
-
|
|
321
|
+
const parallelization = getNumberField(options.hash, 'parallelization');
|
|
323
322
|
if (isNaN(parallelization)) {
|
|
324
323
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_PARALLELIZATION, 'A valid "hash.parallelization" number must be provided for ' +
|
|
325
|
-
|
|
324
|
+
`hash algorithm ${options.hash.algorithm}.`);
|
|
326
325
|
}
|
|
327
|
-
|
|
326
|
+
const blockSize = getNumberField(options.hash, 'blockSize');
|
|
328
327
|
if (isNaN(blockSize)) {
|
|
329
328
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_BLOCK_SIZE, 'A valid "hash.blockSize" number must be provided for ' +
|
|
330
|
-
|
|
329
|
+
`hash algorithm ${options.hash.algorithm}.`);
|
|
331
330
|
}
|
|
332
|
-
|
|
331
|
+
const dkLen = getNumberField(options.hash, 'derivedKeyLength');
|
|
333
332
|
if (isNaN(dkLen)) {
|
|
334
333
|
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_DERIVED_KEY_LENGTH, 'A valid "hash.derivedKeyLength" number must be provided for ' +
|
|
335
|
-
|
|
334
|
+
`hash algorithm ${options.hash.algorithm}.`);
|
|
336
335
|
}
|
|
337
336
|
populatedOptions = {
|
|
338
337
|
hashAlgorithm: options.hash.algorithm,
|
|
339
|
-
cpuMemCost
|
|
340
|
-
parallelization
|
|
341
|
-
blockSize
|
|
342
|
-
dkLen
|
|
338
|
+
cpuMemCost,
|
|
339
|
+
parallelization,
|
|
340
|
+
blockSize,
|
|
341
|
+
dkLen,
|
|
343
342
|
};
|
|
344
343
|
break;
|
|
345
344
|
}
|
|
346
345
|
default:
|
|
347
|
-
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_ALGORITHM,
|
|
346
|
+
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_ALGORITHM, `Unsupported hash algorithm provider "${options.hash.algorithm}".`);
|
|
348
347
|
}
|
|
349
348
|
return populatedOptions;
|
|
350
|
-
}
|
|
349
|
+
}
|
|
351
350
|
/**
|
|
352
351
|
* Validates and returns the users list of the uploadAccount request.
|
|
353
352
|
* Whenever a user with an error is detected, the error is cached and will later be
|
|
@@ -358,30 +357,28 @@ var UserImportBuilder = /** @class */ (function () {
|
|
|
358
357
|
* @param {ValidatorFunction=} userValidator The user validator function.
|
|
359
358
|
* @returns {UploadAccountUser[]} The populated uploadAccount users.
|
|
360
359
|
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
users.forEach(function (user, index) {
|
|
360
|
+
populateUsers(users, userValidator) {
|
|
361
|
+
const populatedUsers = [];
|
|
362
|
+
users.forEach((user, index) => {
|
|
365
363
|
try {
|
|
366
|
-
|
|
364
|
+
const result = populateUploadAccountUser(user, userValidator);
|
|
367
365
|
if (typeof result.passwordHash !== 'undefined') {
|
|
368
|
-
|
|
366
|
+
this.requiresHashOptions = true;
|
|
369
367
|
}
|
|
370
368
|
// Only users that pass client screening will be passed to backend for processing.
|
|
371
369
|
populatedUsers.push(result);
|
|
372
370
|
// Map user's index (the one to be sent to backend) to original developer provided array.
|
|
373
|
-
|
|
371
|
+
this.indexMap[populatedUsers.length - 1] = index;
|
|
374
372
|
}
|
|
375
373
|
catch (error) {
|
|
376
374
|
// Save the client side error with respect to the developer provided array.
|
|
377
|
-
|
|
378
|
-
index
|
|
379
|
-
error
|
|
375
|
+
this.userImportResultErrors.push({
|
|
376
|
+
index,
|
|
377
|
+
error,
|
|
380
378
|
});
|
|
381
379
|
}
|
|
382
380
|
});
|
|
383
381
|
return populatedUsers;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
}());
|
|
382
|
+
}
|
|
383
|
+
}
|
|
387
384
|
exports.UserImportBuilder = UserImportBuilder;
|