firebase-tools 9.23.3 → 10.1.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/lib/api.js +1 -1
- package/lib/apiv2.js +2 -2
- package/lib/appdistribution/client.js +1 -1
- package/lib/appdistribution/options-parser-util.js +1 -1
- package/lib/auth.js +2 -2
- package/lib/command.js +26 -26
- package/lib/commands/appdistribution-distribute.js +4 -4
- package/lib/commands/appdistribution-testers-add.js +2 -2
- package/lib/commands/appdistribution-testers-remove.js +2 -2
- package/lib/commands/apps-android-sha-create.js +2 -2
- package/lib/commands/apps-android-sha-delete.js +2 -2
- package/lib/commands/apps-android-sha-list.js +2 -2
- package/lib/commands/apps-create.js +9 -9
- package/lib/commands/apps-list.js +3 -3
- package/lib/commands/apps-sdkconfig.js +8 -8
- package/lib/commands/database-get.js +1 -1
- package/lib/commands/database-instances-create.js +4 -4
- package/lib/commands/database-instances-list.js +4 -4
- package/lib/commands/database-profile.js +1 -1
- package/lib/commands/database-push.js +1 -1
- package/lib/commands/database-remove.js +4 -4
- package/lib/commands/database-set.js +4 -4
- package/lib/commands/database-settings-get.js +1 -1
- package/lib/commands/database-settings-set.js +1 -1
- package/lib/commands/database-update.js +4 -4
- package/lib/commands/ext-configure.js +2 -2
- package/lib/commands/ext-dev-deprecate.js +4 -4
- package/lib/commands/ext-dev-extension-delete.js +3 -3
- package/lib/commands/ext-dev-init.js +3 -3
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-publish.js +3 -3
- package/lib/commands/ext-dev-register.js +5 -5
- package/lib/commands/ext-dev-undeprecate.js +4 -4
- package/lib/commands/ext-dev-unpublish.js +3 -3
- package/lib/commands/ext-dev-usage.js +145 -0
- package/lib/commands/ext-export.js +8 -8
- package/lib/commands/ext-info.js +4 -4
- package/lib/commands/ext-install.js +26 -22
- package/lib/commands/ext-list.js +2 -2
- package/lib/commands/ext-sources-create.js +2 -2
- package/lib/commands/ext-uninstall.js +3 -3
- package/lib/commands/ext-update.js +17 -17
- package/lib/commands/ext.js +3 -3
- package/lib/commands/firestore-delete.js +3 -3
- package/lib/commands/functions-config-export.js +11 -11
- package/lib/commands/functions-delete.js +3 -3
- package/lib/commands/functions-deletegcfartifacts.js +4 -4
- package/lib/commands/functions-list.js +1 -1
- package/lib/commands/functions-log.js +1 -1
- package/lib/commands/hosting-channel-create.js +12 -12
- package/lib/commands/hosting-channel-delete.js +9 -9
- package/lib/commands/hosting-channel-deploy.js +17 -17
- package/lib/commands/hosting-channel-list.js +5 -5
- package/lib/commands/hosting-channel-open.js +9 -9
- package/lib/commands/hosting-clone.js +15 -15
- package/lib/commands/hosting-disable.js +4 -4
- package/lib/commands/hosting-sites-create.js +7 -7
- package/lib/commands/hosting-sites-delete.js +7 -7
- package/lib/commands/hosting-sites-get.js +2 -2
- package/lib/commands/hosting-sites-list.js +3 -3
- package/lib/commands/index.js +1 -0
- package/lib/commands/login.js +2 -2
- package/lib/commands/logout.js +1 -1
- package/lib/commands/open.js +1 -1
- package/lib/commands/projects-addfirebase.js +2 -2
- package/lib/commands/projects-create.js +2 -2
- package/lib/commands/projects-list.js +1 -1
- package/lib/commands/remoteconfig-get.js +3 -3
- package/lib/commands/remoteconfig-rollback.js +3 -3
- package/lib/commands/remoteconfig-versions-list.js +1 -1
- package/lib/commands/setup-emulators-storage.js +1 -1
- package/lib/config.js +6 -6
- package/lib/database/api.js +2 -2
- package/lib/deploy/extensions/deploy.js +4 -4
- package/lib/deploy/extensions/deploymentSummary.js +5 -4
- package/lib/deploy/extensions/index.js +1 -0
- package/lib/deploy/extensions/params.js +1 -1
- package/lib/deploy/extensions/planner.js +3 -3
- package/lib/deploy/extensions/prepare.js +9 -9
- package/lib/deploy/extensions/release.js +1 -1
- package/lib/deploy/extensions/secrets.js +7 -7
- package/lib/deploy/extensions/validate.js +2 -2
- package/lib/deploy/functions/backend.js +6 -4
- package/lib/deploy/functions/checkIam.js +7 -7
- package/lib/deploy/functions/containerCleaner.js +3 -3
- package/lib/deploy/functions/deploy.js +10 -11
- package/lib/deploy/functions/ensureCloudBuildEnabled.js +3 -3
- package/lib/deploy/functions/index.js +1 -0
- package/lib/deploy/functions/prepare.js +27 -21
- package/lib/deploy/functions/prompts.js +5 -5
- package/lib/deploy/functions/release/executor.js +4 -1
- package/lib/deploy/functions/release/fabricator.js +5 -5
- package/lib/deploy/functions/release/index.js +3 -3
- package/lib/deploy/functions/release/planner.js +6 -6
- package/lib/deploy/functions/release/reporter.js +8 -4
- package/lib/deploy/functions/runtimes/discovery/index.js +2 -2
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +14 -14
- package/lib/deploy/functions/runtimes/golang/index.js +9 -13
- package/lib/deploy/functions/runtimes/index.js +6 -10
- package/lib/deploy/functions/runtimes/node/index.js +6 -10
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +1 -1
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +3 -3
- package/lib/deploy/functions/runtimes/node/validate.js +2 -1
- package/lib/deploy/functions/services/storage.js +1 -1
- package/lib/deploy/functions/triggerRegionHelper.js +1 -1
- package/lib/deploy/functions/validate.js +4 -3
- package/lib/deploy/hosting/deploy.js +7 -7
- package/lib/deploy/hosting/uploader.js +1 -1
- package/lib/deploy/hosting/validate.js +3 -3
- package/lib/deploy/remoteconfig/prepare.js +3 -3
- package/lib/deploy/remoteconfig/release.js +3 -3
- package/lib/deploy/storage/deploy.js +1 -1
- package/lib/deploy/storage/release.js +2 -2
- package/lib/detectProjectRoot.js +5 -5
- package/lib/emulator/auth/apiSpec.js +13 -7
- package/lib/emulator/auth/handlers.js +3 -3
- package/lib/emulator/auth/index.js +1 -1
- package/lib/emulator/auth/operations.js +256 -248
- package/lib/emulator/auth/server.js +11 -8
- package/lib/emulator/auth/state.js +12 -12
- package/lib/emulator/commandUtils.js +5 -5
- package/lib/emulator/controller.js +16 -11
- package/lib/emulator/downloadableEmulators.js +2 -2
- package/lib/emulator/emulatorLogger.js +1 -1
- package/lib/emulator/functionsEmulator.js +101 -74
- package/lib/emulator/functionsEmulatorRuntime.js +33 -18
- package/lib/emulator/functionsEmulatorShell.js +3 -2
- package/lib/emulator/functionsRuntimeWorker.js +1 -1
- package/lib/emulator/hubExport.js +2 -2
- package/lib/emulator/storage/apis/firebase.js +2 -2
- package/lib/emulator/storage/apis/gcloud.js +2 -2
- package/lib/emulator/storage/cloudFunctions.js +1 -1
- package/lib/emulator/storage/files.js +14 -14
- package/lib/emulator/storage/index.js +2 -2
- package/lib/emulator/storage/metadata.js +7 -6
- package/lib/emulator/storage/rules/runtime.js +5 -5
- package/lib/emulator/storage/server.js +2 -2
- package/lib/ensureApiEnabled.js +7 -7
- package/lib/error.js +3 -3
- package/lib/extensions/askUserForConsent.js +2 -3
- package/lib/extensions/askUserForParam.js +10 -10
- package/lib/extensions/billingMigrationHelper.js +1 -1
- package/lib/extensions/changelog.js +3 -3
- package/lib/extensions/displayExtensionInfo.js +5 -5
- package/lib/extensions/emulator/optionsHelper.js +1 -1
- package/lib/extensions/emulator/specHelper.js +1 -1
- package/lib/extensions/emulator/triggerHelper.js +1 -1
- package/lib/extensions/export.js +6 -6
- package/lib/extensions/extensionsApi.js +14 -1
- package/lib/extensions/extensionsHelper.js +38 -29
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/localHelper.js +1 -1
- package/lib/extensions/metricsTypeDef.js +2 -0
- package/lib/extensions/metricsUtils.js +98 -0
- package/lib/extensions/paramHelper.js +6 -6
- package/lib/extensions/provisioningHelper.js +6 -4
- package/lib/extensions/resolveSource.js +1 -1
- package/lib/extensions/secretsUtils.js +3 -3
- package/lib/extensions/updateHelper.js +9 -9
- package/lib/extensions/utils.js +1 -1
- package/lib/extensions/warnings.js +10 -9
- package/lib/fetchWebSetup.js +2 -2
- package/lib/filterTargets.js +2 -2
- package/lib/firestore/indexes.js +2 -2
- package/lib/fsAsync.js +3 -3
- package/lib/fsutils.js +2 -2
- package/lib/functional.js +2 -1
- package/lib/functions/env.js +1 -1
- package/lib/functions/runtimeConfigExport.js +4 -4
- package/lib/functionsConfig.js +3 -3
- package/lib/functionsShellCommandAction.js +4 -3
- package/lib/gcp/cloudmonitoring.js +74 -0
- package/lib/gcp/cloudscheduler.js +1 -1
- package/lib/gcp/iam.js +2 -2
- package/lib/gcp/resourceManager.js +2 -2
- package/lib/gcp/secretManager.js +3 -2
- package/lib/getDefaultDatabaseInstance.js +1 -1
- package/lib/getDefaultHostingSite.js +1 -1
- package/lib/getProjectNumber.js +2 -2
- package/lib/handlePreviewToggles.js +5 -5
- package/lib/hosting/api.js +6 -6
- package/lib/hosting/cloudRunProxy.js +6 -6
- package/lib/hosting/functionsProxy.js +3 -3
- package/lib/hosting/implicitInit.js +2 -2
- package/lib/hosting/normalizedHostingConfigs.js +3 -3
- package/lib/hosting/proxy.js +2 -2
- package/lib/init/features/account.js +7 -7
- package/lib/init/features/database.js +9 -9
- package/lib/init/features/emulators.js +8 -8
- package/lib/init/features/firestore/index.js +3 -3
- package/lib/init/features/firestore/indexes.js +2 -2
- package/lib/init/features/firestore/rules.js +2 -2
- package/lib/init/features/functions/golang.js +4 -4
- package/lib/init/features/functions/index.js +4 -4
- package/lib/init/features/hosting/github.js +31 -31
- package/lib/init/features/project.js +8 -8
- package/lib/init/features/remoteconfig.js +2 -2
- package/lib/init/features/storage.js +2 -2
- package/lib/listFiles.js +1 -1
- package/lib/management/apps.js +3 -3
- package/lib/management/projects.js +6 -6
- package/lib/previews.js +2 -2
- package/lib/profiler.js +1 -1
- package/lib/projectPath.js +1 -1
- package/lib/projectUtils.js +1 -1
- package/lib/prompt.js +0 -1
- package/lib/rc.js +1 -1
- package/lib/requireAuth.js +2 -2
- package/lib/requireDatabaseInstance.js +1 -1
- package/lib/requireHostingSite.js +1 -1
- package/lib/requirePermissions.js +4 -4
- package/lib/rulesDeploy.js +2 -2
- package/lib/serve/functions.js +14 -7
- package/lib/serve/hosting.js +7 -7
- package/lib/utils.js +3 -2
- package/npm-shrinkwrap.json +24889 -0
- package/package.json +24 -24
- package/templates/init/functions/javascript/package.lint.json +1 -1
- package/templates/init/functions/javascript/package.nolint.json +1 -1
- package/templates/init/functions/typescript/package.lint.json +1 -1
- package/templates/init/functions/typescript/package.nolint.json +1 -1
- package/templates/init/hosting/index.html +1 -1
- package/CHANGELOG.md +0 -1
|
@@ -102,25 +102,25 @@ const MFA_INELIGIBLE_PROVIDER = new Set([
|
|
|
102
102
|
]);
|
|
103
103
|
function signUp(state, reqBody, ctx) {
|
|
104
104
|
var _a;
|
|
105
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
106
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
105
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
106
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
107
107
|
let provider;
|
|
108
108
|
const updates = {
|
|
109
109
|
lastLoginAt: Date.now().toString(),
|
|
110
110
|
};
|
|
111
111
|
if ((_a = ctx.security) === null || _a === void 0 ? void 0 : _a.Oauth2) {
|
|
112
112
|
if (reqBody.idToken) {
|
|
113
|
-
errors_1.assert(!reqBody.localId, "UNEXPECTED_PARAMETER : User ID");
|
|
113
|
+
(0, errors_1.assert)(!reqBody.localId, "UNEXPECTED_PARAMETER : User ID");
|
|
114
114
|
}
|
|
115
115
|
if (reqBody.localId) {
|
|
116
|
-
errors_1.assert(!state.getUserByLocalId(reqBody.localId), "DUPLICATE_LOCAL_ID");
|
|
116
|
+
(0, errors_1.assert)(!state.getUserByLocalId(reqBody.localId), "DUPLICATE_LOCAL_ID");
|
|
117
117
|
}
|
|
118
118
|
updates.displayName = reqBody.displayName;
|
|
119
119
|
updates.photoUrl = reqBody.photoUrl;
|
|
120
120
|
updates.emailVerified = reqBody.emailVerified || false;
|
|
121
121
|
if (reqBody.phoneNumber) {
|
|
122
|
-
errors_1.assert(utils_1.isValidPhoneNumber(reqBody.phoneNumber), "INVALID_PHONE_NUMBER : Invalid format.");
|
|
123
|
-
errors_1.assert(!state.getUserByPhoneNumber(reqBody.phoneNumber), "PHONE_NUMBER_EXISTS");
|
|
122
|
+
(0, errors_1.assert)((0, utils_1.isValidPhoneNumber)(reqBody.phoneNumber), "INVALID_PHONE_NUMBER : Invalid format.");
|
|
123
|
+
(0, errors_1.assert)(!state.getUserByPhoneNumber(reqBody.phoneNumber), "PHONE_NUMBER_EXISTS");
|
|
124
124
|
updates.phoneNumber = reqBody.phoneNumber;
|
|
125
125
|
}
|
|
126
126
|
if (reqBody.disabled) {
|
|
@@ -128,32 +128,32 @@ function signUp(state, reqBody, ctx) {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
|
-
errors_1.assert(!reqBody.localId, "UNEXPECTED_PARAMETER : User ID");
|
|
131
|
+
(0, errors_1.assert)(!reqBody.localId, "UNEXPECTED_PARAMETER : User ID");
|
|
132
132
|
if (reqBody.idToken || reqBody.password || reqBody.email) {
|
|
133
133
|
updates.displayName = reqBody.displayName;
|
|
134
134
|
updates.emailVerified = false;
|
|
135
|
-
errors_1.assert(reqBody.email, "MISSING_EMAIL");
|
|
136
|
-
errors_1.assert(reqBody.password, "MISSING_PASSWORD");
|
|
135
|
+
(0, errors_1.assert)(reqBody.email, "MISSING_EMAIL");
|
|
136
|
+
(0, errors_1.assert)(reqBody.password, "MISSING_PASSWORD");
|
|
137
137
|
provider = state_1.PROVIDER_PASSWORD;
|
|
138
|
-
errors_1.assert(state.allowPasswordSignup, "OPERATION_NOT_ALLOWED");
|
|
138
|
+
(0, errors_1.assert)(state.allowPasswordSignup, "OPERATION_NOT_ALLOWED");
|
|
139
139
|
}
|
|
140
140
|
else {
|
|
141
141
|
provider = state_1.PROVIDER_ANONYMOUS;
|
|
142
|
-
errors_1.assert(state.enableAnonymousUser, "ADMIN_ONLY_OPERATION");
|
|
142
|
+
(0, errors_1.assert)(state.enableAnonymousUser, "ADMIN_ONLY_OPERATION");
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
if (reqBody.email) {
|
|
146
|
-
errors_1.assert(utils_1.isValidEmailAddress(reqBody.email), "INVALID_EMAIL");
|
|
147
|
-
const email = utils_1.canonicalizeEmailAddress(reqBody.email);
|
|
148
|
-
errors_1.assert(!state.getUserByEmail(email), "EMAIL_EXISTS");
|
|
146
|
+
(0, errors_1.assert)((0, utils_1.isValidEmailAddress)(reqBody.email), "INVALID_EMAIL");
|
|
147
|
+
const email = (0, utils_1.canonicalizeEmailAddress)(reqBody.email);
|
|
148
|
+
(0, errors_1.assert)(!state.getUserByEmail(email), "EMAIL_EXISTS");
|
|
149
149
|
updates.email = email;
|
|
150
150
|
}
|
|
151
151
|
if (reqBody.password) {
|
|
152
|
-
errors_1.assert(reqBody.password.length >= PASSWORD_MIN_LENGTH, `WEAK_PASSWORD : Password should be at least ${PASSWORD_MIN_LENGTH} characters`);
|
|
153
|
-
updates.salt = "fakeSalt" + utils_1.randomId(20);
|
|
152
|
+
(0, errors_1.assert)(reqBody.password.length >= PASSWORD_MIN_LENGTH, `WEAK_PASSWORD : Password should be at least ${PASSWORD_MIN_LENGTH} characters`);
|
|
153
|
+
updates.salt = "fakeSalt" + (0, utils_1.randomId)(20);
|
|
154
154
|
updates.passwordHash = hashPassword(reqBody.password, updates.salt);
|
|
155
155
|
updates.passwordUpdatedAt = Date.now();
|
|
156
|
-
updates.validSince = utils_1.toUnixTimestamp(new Date()).toString();
|
|
156
|
+
updates.validSince = (0, utils_1.toUnixTimestamp)(new Date()).toString();
|
|
157
157
|
}
|
|
158
158
|
if (reqBody.mfaInfo) {
|
|
159
159
|
updates.mfaInfo = getMfaEnrollmentsFromRequest(state, reqBody.mfaInfo, {
|
|
@@ -170,7 +170,7 @@ function signUp(state, reqBody, ctx) {
|
|
|
170
170
|
if (!user) {
|
|
171
171
|
if (reqBody.localId) {
|
|
172
172
|
user = state.createUserWithLocalId(reqBody.localId, updates);
|
|
173
|
-
errors_1.assert(user, "DUPLICATE_LOCAL_ID");
|
|
173
|
+
(0, errors_1.assert)(user, "DUPLICATE_LOCAL_ID");
|
|
174
174
|
}
|
|
175
175
|
else {
|
|
176
176
|
user = state.createUser(updates);
|
|
@@ -183,7 +183,7 @@ function signUp(state, reqBody, ctx) {
|
|
|
183
183
|
}
|
|
184
184
|
function lookup(state, reqBody, ctx) {
|
|
185
185
|
var _a, _b, _c, _d, _e;
|
|
186
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
186
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
187
187
|
const seenLocalIds = new Set();
|
|
188
188
|
const users = [];
|
|
189
189
|
function tryAddUser(maybeUser) {
|
|
@@ -213,7 +213,7 @@ function lookup(state, reqBody, ctx) {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
else {
|
|
216
|
-
errors_1.assert(reqBody.idToken, "MISSING_ID_TOKEN");
|
|
216
|
+
(0, errors_1.assert)(reqBody.idToken, "MISSING_ID_TOKEN");
|
|
217
217
|
const { user } = parseIdToken(state, reqBody.idToken);
|
|
218
218
|
users.push(redactPasswordHash(user));
|
|
219
219
|
}
|
|
@@ -224,15 +224,15 @@ function lookup(state, reqBody, ctx) {
|
|
|
224
224
|
}
|
|
225
225
|
function batchCreate(state, reqBody) {
|
|
226
226
|
var _a, _b;
|
|
227
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
228
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
229
|
-
errors_1.assert((_a = reqBody.users) === null || _a === void 0 ? void 0 : _a.length, "MISSING_USER_ACCOUNT");
|
|
227
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
228
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
229
|
+
(0, errors_1.assert)((_a = reqBody.users) === null || _a === void 0 ? void 0 : _a.length, "MISSING_USER_ACCOUNT");
|
|
230
230
|
if (reqBody.sanityCheck) {
|
|
231
231
|
if (state.oneAccountPerEmail) {
|
|
232
232
|
const existingEmails = new Set();
|
|
233
233
|
for (const userInfo of reqBody.users) {
|
|
234
234
|
if (userInfo.email) {
|
|
235
|
-
errors_1.assert(!existingEmails.has(userInfo.email), `DUPLICATE_EMAIL : ${userInfo.email}`);
|
|
235
|
+
(0, errors_1.assert)(!existingEmails.has(userInfo.email), `DUPLICATE_EMAIL : ${userInfo.email}`);
|
|
236
236
|
existingEmails.add(userInfo.email);
|
|
237
237
|
}
|
|
238
238
|
}
|
|
@@ -241,7 +241,7 @@ function batchCreate(state, reqBody) {
|
|
|
241
241
|
for (const userInfo of reqBody.users) {
|
|
242
242
|
for (const { providerId, rawId } of (_b = userInfo.providerUserInfo) !== null && _b !== void 0 ? _b : []) {
|
|
243
243
|
const key = `${providerId}:${rawId}`;
|
|
244
|
-
errors_1.assert(!existingProviderAccounts.has(key), `DUPLICATE_RAW_ID : Provider id(${providerId}), Raw id(${rawId})`);
|
|
244
|
+
(0, errors_1.assert)(!existingProviderAccounts.has(key), `DUPLICATE_RAW_ID : Provider id(${providerId}), Raw id(${rawId})`);
|
|
245
245
|
existingProviderAccounts.add(key);
|
|
246
246
|
}
|
|
247
247
|
}
|
|
@@ -250,7 +250,7 @@ function batchCreate(state, reqBody) {
|
|
|
250
250
|
const existingLocalIds = new Set();
|
|
251
251
|
for (const userInfo of reqBody.users) {
|
|
252
252
|
const localId = userInfo.localId || "";
|
|
253
|
-
errors_1.assert(!existingLocalIds.has(localId), `DUPLICATE_LOCAL_ID : ${localId}`);
|
|
253
|
+
(0, errors_1.assert)(!existingLocalIds.has(localId), `DUPLICATE_LOCAL_ID : ${localId}`);
|
|
254
254
|
existingLocalIds.add(localId);
|
|
255
255
|
}
|
|
256
256
|
}
|
|
@@ -258,7 +258,7 @@ function batchCreate(state, reqBody) {
|
|
|
258
258
|
for (let index = 0; index < reqBody.users.length; index++) {
|
|
259
259
|
const userInfo = reqBody.users[index];
|
|
260
260
|
try {
|
|
261
|
-
errors_1.assert(userInfo.localId, "localId is missing");
|
|
261
|
+
(0, errors_1.assert)(userInfo.localId, "localId is missing");
|
|
262
262
|
const uploadTime = new Date();
|
|
263
263
|
const fields = {
|
|
264
264
|
displayName: userInfo.displayName,
|
|
@@ -266,7 +266,7 @@ function batchCreate(state, reqBody) {
|
|
|
266
266
|
lastLoginAt: userInfo.lastLoginAt,
|
|
267
267
|
};
|
|
268
268
|
if (userInfo.tenantId) {
|
|
269
|
-
errors_1.assert(state instanceof state_1.TenantProjectState && state.tenantId === userInfo.tenantId, "Tenant id in userInfo does not match the tenant id in request.");
|
|
269
|
+
(0, errors_1.assert)(state instanceof state_1.TenantProjectState && state.tenantId === userInfo.tenantId, "Tenant id in userInfo does not match the tenant id in request.");
|
|
270
270
|
}
|
|
271
271
|
if (state instanceof state_1.TenantProjectState) {
|
|
272
272
|
fields.tenantId = state.tenantId;
|
|
@@ -277,7 +277,7 @@ function batchCreate(state, reqBody) {
|
|
|
277
277
|
fields.passwordUpdatedAt = uploadTime.getTime();
|
|
278
278
|
}
|
|
279
279
|
else if (userInfo.rawPassword) {
|
|
280
|
-
fields.salt = userInfo.salt || "fakeSalt" + utils_1.randomId(20);
|
|
280
|
+
fields.salt = userInfo.salt || "fakeSalt" + (0, utils_1.randomId)(20);
|
|
281
281
|
fields.passwordHash = hashPassword(userInfo.rawPassword, fields.salt);
|
|
282
282
|
fields.passwordUpdatedAt = uploadTime.getTime();
|
|
283
283
|
}
|
|
@@ -294,59 +294,59 @@ function batchCreate(state, reqBody) {
|
|
|
294
294
|
}
|
|
295
295
|
if (!rawId || !providerId) {
|
|
296
296
|
if (!federatedId) {
|
|
297
|
-
errors_1.assert(false, "federatedId or (providerId & rawId) is required");
|
|
297
|
+
(0, errors_1.assert)(false, "federatedId or (providerId & rawId) is required");
|
|
298
298
|
}
|
|
299
299
|
else {
|
|
300
|
-
errors_1.assert(false, "((Parsing federatedId is not implemented in Auth Emulator; please specify providerId AND rawId as a workaround.))");
|
|
300
|
+
(0, errors_1.assert)(false, "((Parsing federatedId is not implemented in Auth Emulator; please specify providerId AND rawId as a workaround.))");
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
const existingUserWithRawId = state.getUserByProviderRawId(providerId, rawId);
|
|
304
|
-
errors_1.assert(!existingUserWithRawId || existingUserWithRawId.localId === userInfo.localId, "raw id exists in other account in database");
|
|
304
|
+
(0, errors_1.assert)(!existingUserWithRawId || existingUserWithRawId.localId === userInfo.localId, "raw id exists in other account in database");
|
|
305
305
|
fields.providerUserInfo.push(Object.assign(Object.assign({}, providerUserInfo), { providerId, rawId }));
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
if (userInfo.phoneNumber) {
|
|
309
|
-
errors_1.assert(utils_1.isValidPhoneNumber(userInfo.phoneNumber), "phone number format is invalid");
|
|
309
|
+
(0, errors_1.assert)((0, utils_1.isValidPhoneNumber)(userInfo.phoneNumber), "phone number format is invalid");
|
|
310
310
|
fields.phoneNumber = userInfo.phoneNumber;
|
|
311
311
|
}
|
|
312
|
-
fields.validSince = utils_1.toUnixTimestamp(uploadTime).toString();
|
|
312
|
+
fields.validSince = (0, utils_1.toUnixTimestamp)(uploadTime).toString();
|
|
313
313
|
fields.createdAt = uploadTime.getTime().toString();
|
|
314
314
|
if (fields.createdAt && !isNaN(Number(userInfo.createdAt))) {
|
|
315
315
|
fields.createdAt = userInfo.createdAt;
|
|
316
316
|
}
|
|
317
317
|
if (userInfo.email) {
|
|
318
318
|
const email = userInfo.email;
|
|
319
|
-
errors_1.assert(utils_1.isValidEmailAddress(email), "email is invalid");
|
|
319
|
+
(0, errors_1.assert)((0, utils_1.isValidEmailAddress)(email), "email is invalid");
|
|
320
320
|
const existingUserWithEmail = state.getUserByEmail(email);
|
|
321
|
-
errors_1.assert(!existingUserWithEmail || existingUserWithEmail.localId === userInfo.localId, reqBody.sanityCheck && state.oneAccountPerEmail
|
|
321
|
+
(0, errors_1.assert)(!existingUserWithEmail || existingUserWithEmail.localId === userInfo.localId, reqBody.sanityCheck && state.oneAccountPerEmail
|
|
322
322
|
? "email exists in other account in database"
|
|
323
323
|
: `((Auth Emulator does not support importing duplicate email: ${email}))`);
|
|
324
|
-
fields.email = utils_1.canonicalizeEmailAddress(email);
|
|
324
|
+
fields.email = (0, utils_1.canonicalizeEmailAddress)(email);
|
|
325
325
|
}
|
|
326
326
|
fields.emailVerified = !!userInfo.emailVerified;
|
|
327
327
|
fields.disabled = !!userInfo.disabled;
|
|
328
328
|
if (userInfo.mfaInfo) {
|
|
329
329
|
fields.mfaInfo = [];
|
|
330
|
-
errors_1.assert(fields.email, "Second factor account requires email to be presented.");
|
|
331
|
-
errors_1.assert(fields.emailVerified, "Second factor account requires email to be verified.");
|
|
330
|
+
(0, errors_1.assert)(fields.email, "Second factor account requires email to be presented.");
|
|
331
|
+
(0, errors_1.assert)(fields.emailVerified, "Second factor account requires email to be verified.");
|
|
332
332
|
const existingIds = new Set();
|
|
333
333
|
for (const enrollment of userInfo.mfaInfo) {
|
|
334
334
|
if (enrollment.mfaEnrollmentId) {
|
|
335
|
-
errors_1.assert(!existingIds.has(enrollment.mfaEnrollmentId), "Enrollment id already exists.");
|
|
335
|
+
(0, errors_1.assert)(!existingIds.has(enrollment.mfaEnrollmentId), "Enrollment id already exists.");
|
|
336
336
|
existingIds.add(enrollment.mfaEnrollmentId);
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
for (const enrollment of userInfo.mfaInfo) {
|
|
340
340
|
enrollment.mfaEnrollmentId = enrollment.mfaEnrollmentId || newRandomId(28, existingIds);
|
|
341
341
|
enrollment.enrolledAt = enrollment.enrolledAt || new Date().toISOString();
|
|
342
|
-
errors_1.assert(enrollment.phoneInfo, "Second factor not supported.");
|
|
343
|
-
errors_1.assert(utils_1.isValidPhoneNumber(enrollment.phoneInfo), "Phone number format is invalid");
|
|
342
|
+
(0, errors_1.assert)(enrollment.phoneInfo, "Second factor not supported.");
|
|
343
|
+
(0, errors_1.assert)((0, utils_1.isValidPhoneNumber)(enrollment.phoneInfo), "Phone number format is invalid");
|
|
344
344
|
enrollment.unobfuscatedPhoneInfo = enrollment.phoneInfo;
|
|
345
345
|
fields.mfaInfo.push(enrollment);
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
if (state.getUserByLocalId(userInfo.localId)) {
|
|
349
|
-
errors_1.assert(reqBody.allowOverwrite, "localId belongs to an existing account - can not overwrite.");
|
|
349
|
+
(0, errors_1.assert)(reqBody.allowOverwrite, "localId belongs to an existing account - can not overwrite.");
|
|
350
350
|
}
|
|
351
351
|
state.overwriteUserWithLocalId(userInfo.localId, fields);
|
|
352
352
|
}
|
|
@@ -381,7 +381,7 @@ function batchDelete(state, reqBody) {
|
|
|
381
381
|
var _a;
|
|
382
382
|
const errors = [];
|
|
383
383
|
const localIds = (_a = reqBody.localIds) !== null && _a !== void 0 ? _a : [];
|
|
384
|
-
errors_1.assert(localIds.length > 0 && localIds.length <= 1000, "LOCAL_ID_LIST_EXCEEDS_LIMIT");
|
|
384
|
+
(0, errors_1.assert)(localIds.length > 0 && localIds.length <= 1000, "LOCAL_ID_LIST_EXCEEDS_LIMIT");
|
|
385
385
|
for (let index = 0; index < localIds.length; index++) {
|
|
386
386
|
const localId = localIds[index];
|
|
387
387
|
const user = state.getUserByLocalId(localId);
|
|
@@ -402,7 +402,7 @@ function batchDelete(state, reqBody) {
|
|
|
402
402
|
return { errors: errors.length ? errors : undefined };
|
|
403
403
|
}
|
|
404
404
|
function batchGet(state, reqBody, ctx) {
|
|
405
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
405
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
406
406
|
const maxResults = Math.min(Math.floor(ctx.params.query.maxResults) || 20, 1000);
|
|
407
407
|
const users = state.queryUsers({}, { sortByField: "localId", order: "ASC", startToken: ctx.params.query.nextPageToken });
|
|
408
408
|
let newPageToken = undefined;
|
|
@@ -420,17 +420,17 @@ function batchGet(state, reqBody, ctx) {
|
|
|
420
420
|
}
|
|
421
421
|
function createAuthUri(state, reqBody) {
|
|
422
422
|
var _a;
|
|
423
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
424
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
425
|
-
const sessionId = reqBody.sessionId || utils_1.randomId(27);
|
|
423
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
424
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
425
|
+
const sessionId = reqBody.sessionId || (0, utils_1.randomId)(27);
|
|
426
426
|
if (reqBody.providerId) {
|
|
427
427
|
throw new errors_1.NotImplementedError("Sign-in with IDP is not yet supported.");
|
|
428
428
|
}
|
|
429
|
-
errors_1.assert(reqBody.identifier, "MISSING_IDENTIFIER");
|
|
430
|
-
errors_1.assert(reqBody.continueUri, "MISSING_CONTINUE_URI");
|
|
431
|
-
errors_1.assert(utils_1.isValidEmailAddress(reqBody.identifier), "INVALID_IDENTIFIER");
|
|
432
|
-
const email = utils_1.canonicalizeEmailAddress(reqBody.identifier);
|
|
433
|
-
errors_1.assert(utils_1.parseAbsoluteUri(reqBody.continueUri), "INVALID_CONTINUE_URI");
|
|
429
|
+
(0, errors_1.assert)(reqBody.identifier, "MISSING_IDENTIFIER");
|
|
430
|
+
(0, errors_1.assert)(reqBody.continueUri, "MISSING_CONTINUE_URI");
|
|
431
|
+
(0, errors_1.assert)((0, utils_1.isValidEmailAddress)(reqBody.identifier), "INVALID_IDENTIFIER");
|
|
432
|
+
const email = (0, utils_1.canonicalizeEmailAddress)(reqBody.identifier);
|
|
433
|
+
(0, errors_1.assert)((0, utils_1.parseAbsoluteUri)(reqBody.continueUri), "INVALID_CONTINUE_URI");
|
|
434
434
|
const allProviders = [];
|
|
435
435
|
const signinMethods = [];
|
|
436
436
|
let registered = false;
|
|
@@ -481,31 +481,31 @@ function createAuthUri(state, reqBody) {
|
|
|
481
481
|
const SESSION_COOKIE_MIN_VALID_DURATION = 5 * 60;
|
|
482
482
|
exports.SESSION_COOKIE_MAX_VALID_DURATION = 14 * 24 * 60 * 60;
|
|
483
483
|
function createSessionCookie(state, reqBody, ctx) {
|
|
484
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
485
|
-
errors_1.assert(reqBody.idToken, "MISSING_ID_TOKEN");
|
|
484
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
485
|
+
(0, errors_1.assert)(reqBody.idToken, "MISSING_ID_TOKEN");
|
|
486
486
|
const validDuration = Number(reqBody.validDuration) || exports.SESSION_COOKIE_MAX_VALID_DURATION;
|
|
487
|
-
errors_1.assert(validDuration >= SESSION_COOKIE_MIN_VALID_DURATION &&
|
|
487
|
+
(0, errors_1.assert)(validDuration >= SESSION_COOKIE_MIN_VALID_DURATION &&
|
|
488
488
|
validDuration <= exports.SESSION_COOKIE_MAX_VALID_DURATION, "INVALID_DURATION");
|
|
489
489
|
const { payload } = parseIdToken(state, reqBody.idToken);
|
|
490
|
-
const issuedAt = utils_1.toUnixTimestamp(new Date());
|
|
490
|
+
const issuedAt = (0, utils_1.toUnixTimestamp)(new Date());
|
|
491
491
|
const expiresAt = issuedAt + validDuration;
|
|
492
|
-
const sessionCookie = jsonwebtoken_1.sign(Object.assign(Object.assign({}, payload), { iat: issuedAt, exp: expiresAt, iss: `https://session.firebase.google.com/${payload.aud}` }), "", {
|
|
492
|
+
const sessionCookie = (0, jsonwebtoken_1.sign)(Object.assign(Object.assign({}, payload), { iat: issuedAt, exp: expiresAt, iss: `https://session.firebase.google.com/${payload.aud}` }), "", {
|
|
493
493
|
algorithm: "none",
|
|
494
494
|
});
|
|
495
495
|
return { sessionCookie };
|
|
496
496
|
}
|
|
497
497
|
function deleteAccount(state, reqBody, ctx) {
|
|
498
498
|
var _a;
|
|
499
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
499
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
500
500
|
let user;
|
|
501
501
|
if ((_a = ctx.security) === null || _a === void 0 ? void 0 : _a.Oauth2) {
|
|
502
|
-
errors_1.assert(reqBody.localId, "MISSING_LOCAL_ID");
|
|
502
|
+
(0, errors_1.assert)(reqBody.localId, "MISSING_LOCAL_ID");
|
|
503
503
|
const maybeUser = state.getUserByLocalId(reqBody.localId);
|
|
504
|
-
errors_1.assert(maybeUser, "USER_NOT_FOUND");
|
|
504
|
+
(0, errors_1.assert)(maybeUser, "USER_NOT_FOUND");
|
|
505
505
|
user = maybeUser;
|
|
506
506
|
}
|
|
507
507
|
else {
|
|
508
|
-
errors_1.assert(reqBody.idToken, "MISSING_ID_TOKEN");
|
|
508
|
+
(0, errors_1.assert)(reqBody.idToken, "MISSING_ID_TOKEN");
|
|
509
509
|
user = parseIdToken(state, reqBody.idToken).user;
|
|
510
510
|
}
|
|
511
511
|
state.deleteUser(user);
|
|
@@ -514,8 +514,8 @@ function deleteAccount(state, reqBody, ctx) {
|
|
|
514
514
|
};
|
|
515
515
|
}
|
|
516
516
|
function getProjects(state) {
|
|
517
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
518
|
-
errors_1.assert(state instanceof state_1.AgentProjectState, "UNSUPPORTED_TENANT_OPERATION");
|
|
517
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
518
|
+
(0, errors_1.assert)(state instanceof state_1.AgentProjectState, "UNSUPPORTED_TENANT_OPERATION");
|
|
519
519
|
return {
|
|
520
520
|
projectId: state.projectNumber,
|
|
521
521
|
authorizedDomains: [
|
|
@@ -524,7 +524,7 @@ function getProjects(state) {
|
|
|
524
524
|
};
|
|
525
525
|
}
|
|
526
526
|
function getRecaptchaParams(state) {
|
|
527
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
527
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
528
528
|
return {
|
|
529
529
|
kind: "identitytoolkit#GetRecaptchaParamResponse",
|
|
530
530
|
recaptchaStoken: "This-is-a-fake-token__Dont-send-this-to-the-Recaptcha-service__The-Auth-Emulator-does-not-support-Recaptcha",
|
|
@@ -533,7 +533,7 @@ function getRecaptchaParams(state) {
|
|
|
533
533
|
}
|
|
534
534
|
function queryAccounts(state, reqBody) {
|
|
535
535
|
var _a;
|
|
536
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
536
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
537
537
|
if ((_a = reqBody.expression) === null || _a === void 0 ? void 0 : _a.length) {
|
|
538
538
|
throw new errors_1.NotImplementedError("expression is not implemented.");
|
|
539
539
|
}
|
|
@@ -570,26 +570,26 @@ function queryAccounts(state, reqBody) {
|
|
|
570
570
|
}
|
|
571
571
|
function resetPassword(state, reqBody) {
|
|
572
572
|
var _a;
|
|
573
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
574
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
575
|
-
errors_1.assert(state.allowPasswordSignup, "PASSWORD_LOGIN_DISABLED");
|
|
576
|
-
errors_1.assert(reqBody.oobCode, "MISSING_OOB_CODE");
|
|
573
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
574
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
575
|
+
(0, errors_1.assert)(state.allowPasswordSignup, "PASSWORD_LOGIN_DISABLED");
|
|
576
|
+
(0, errors_1.assert)(reqBody.oobCode, "MISSING_OOB_CODE");
|
|
577
577
|
const oob = state.validateOobCode(reqBody.oobCode);
|
|
578
|
-
errors_1.assert(oob, "INVALID_OOB_CODE");
|
|
578
|
+
(0, errors_1.assert)(oob, "INVALID_OOB_CODE");
|
|
579
579
|
if (reqBody.newPassword) {
|
|
580
|
-
errors_1.assert(oob.requestType === "PASSWORD_RESET", "INVALID_OOB_CODE");
|
|
581
|
-
errors_1.assert(reqBody.newPassword.length >= PASSWORD_MIN_LENGTH, `WEAK_PASSWORD : Password should be at least ${PASSWORD_MIN_LENGTH} characters`);
|
|
580
|
+
(0, errors_1.assert)(oob.requestType === "PASSWORD_RESET", "INVALID_OOB_CODE");
|
|
581
|
+
(0, errors_1.assert)(reqBody.newPassword.length >= PASSWORD_MIN_LENGTH, `WEAK_PASSWORD : Password should be at least ${PASSWORD_MIN_LENGTH} characters`);
|
|
582
582
|
state.deleteOobCode(reqBody.oobCode);
|
|
583
583
|
let user = state.getUserByEmail(oob.email);
|
|
584
|
-
errors_1.assert(user, "INVALID_OOB_CODE");
|
|
585
|
-
const salt = "fakeSalt" + utils_1.randomId(20);
|
|
584
|
+
(0, errors_1.assert)(user, "INVALID_OOB_CODE");
|
|
585
|
+
const salt = "fakeSalt" + (0, utils_1.randomId)(20);
|
|
586
586
|
const passwordHash = hashPassword(reqBody.newPassword, salt);
|
|
587
587
|
user = state.updateUserByLocalId(user.localId, {
|
|
588
588
|
emailVerified: true,
|
|
589
589
|
passwordHash,
|
|
590
590
|
salt,
|
|
591
591
|
passwordUpdatedAt: Date.now(),
|
|
592
|
-
validSince: utils_1.toUnixTimestamp(new Date()).toString(),
|
|
592
|
+
validSince: (0, utils_1.toUnixTimestamp)(new Date()).toString(),
|
|
593
593
|
}, { deleteProviders: (_a = user.providerUserInfo) === null || _a === void 0 ? void 0 : _a.map((info) => info.providerId) });
|
|
594
594
|
}
|
|
595
595
|
return {
|
|
@@ -601,41 +601,41 @@ function resetPassword(state, reqBody) {
|
|
|
601
601
|
exports.resetPassword = resetPassword;
|
|
602
602
|
function sendOobCode(state, reqBody, ctx) {
|
|
603
603
|
var _a;
|
|
604
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
605
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
606
|
-
errors_1.assert(reqBody.requestType && reqBody.requestType !== "OOB_REQ_TYPE_UNSPECIFIED", "MISSING_REQ_TYPE");
|
|
604
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
605
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
606
|
+
(0, errors_1.assert)(reqBody.requestType && reqBody.requestType !== "OOB_REQ_TYPE_UNSPECIFIED", "MISSING_REQ_TYPE");
|
|
607
607
|
if (reqBody.returnOobLink) {
|
|
608
|
-
errors_1.assert((_a = ctx.security) === null || _a === void 0 ? void 0 : _a.Oauth2, "INSUFFICIENT_PERMISSION");
|
|
608
|
+
(0, errors_1.assert)((_a = ctx.security) === null || _a === void 0 ? void 0 : _a.Oauth2, "INSUFFICIENT_PERMISSION");
|
|
609
609
|
}
|
|
610
610
|
if (reqBody.continueUrl) {
|
|
611
|
-
errors_1.assert(utils_1.parseAbsoluteUri(reqBody.continueUrl), "INVALID_CONTINUE_URI: ((expected an absolute URI with valid scheme and host))");
|
|
611
|
+
(0, errors_1.assert)((0, utils_1.parseAbsoluteUri)(reqBody.continueUrl), "INVALID_CONTINUE_URI: ((expected an absolute URI with valid scheme and host))");
|
|
612
612
|
}
|
|
613
613
|
let email;
|
|
614
614
|
let mode;
|
|
615
615
|
switch (reqBody.requestType) {
|
|
616
616
|
case "EMAIL_SIGNIN":
|
|
617
|
-
errors_1.assert(state.enableEmailLinkSignin, "OPERATION_NOT_ALLOWED");
|
|
617
|
+
(0, errors_1.assert)(state.enableEmailLinkSignin, "OPERATION_NOT_ALLOWED");
|
|
618
618
|
mode = "signIn";
|
|
619
|
-
errors_1.assert(reqBody.email, "MISSING_EMAIL");
|
|
620
|
-
email = utils_1.canonicalizeEmailAddress(reqBody.email);
|
|
619
|
+
(0, errors_1.assert)(reqBody.email, "MISSING_EMAIL");
|
|
620
|
+
email = (0, utils_1.canonicalizeEmailAddress)(reqBody.email);
|
|
621
621
|
break;
|
|
622
622
|
case "PASSWORD_RESET":
|
|
623
623
|
mode = "resetPassword";
|
|
624
|
-
errors_1.assert(reqBody.email, "MISSING_EMAIL");
|
|
625
|
-
email = utils_1.canonicalizeEmailAddress(reqBody.email);
|
|
626
|
-
errors_1.assert(state.getUserByEmail(email), "EMAIL_NOT_FOUND");
|
|
624
|
+
(0, errors_1.assert)(reqBody.email, "MISSING_EMAIL");
|
|
625
|
+
email = (0, utils_1.canonicalizeEmailAddress)(reqBody.email);
|
|
626
|
+
(0, errors_1.assert)(state.getUserByEmail(email), "EMAIL_NOT_FOUND");
|
|
627
627
|
break;
|
|
628
628
|
case "VERIFY_EMAIL":
|
|
629
629
|
mode = "verifyEmail";
|
|
630
630
|
if (reqBody.returnOobLink && !reqBody.idToken) {
|
|
631
|
-
errors_1.assert(reqBody.email, "MISSING_EMAIL");
|
|
632
|
-
email = utils_1.canonicalizeEmailAddress(reqBody.email);
|
|
631
|
+
(0, errors_1.assert)(reqBody.email, "MISSING_EMAIL");
|
|
632
|
+
email = (0, utils_1.canonicalizeEmailAddress)(reqBody.email);
|
|
633
633
|
const maybeUser = state.getUserByEmail(email);
|
|
634
|
-
errors_1.assert(maybeUser, "USER_NOT_FOUND");
|
|
634
|
+
(0, errors_1.assert)(maybeUser, "USER_NOT_FOUND");
|
|
635
635
|
}
|
|
636
636
|
else {
|
|
637
637
|
const user = parseIdToken(state, reqBody.idToken || "").user;
|
|
638
|
-
errors_1.assert(user.email, "MISSING_EMAIL");
|
|
638
|
+
(0, errors_1.assert)(user.email, "MISSING_EMAIL");
|
|
639
639
|
email = user.email;
|
|
640
640
|
}
|
|
641
641
|
break;
|
|
@@ -645,7 +645,7 @@ function sendOobCode(state, reqBody, ctx) {
|
|
|
645
645
|
if (reqBody.canHandleCodeInApp) {
|
|
646
646
|
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.AUTH).log("WARN", "canHandleCodeInApp is unsupported in Auth Emulator. All OOB operations will complete via web.");
|
|
647
647
|
}
|
|
648
|
-
const url = utils_1.authEmulatorUrl(ctx.req);
|
|
648
|
+
const url = (0, utils_1.authEmulatorUrl)(ctx.req);
|
|
649
649
|
const oobRecord = createOobRecord(state, email, url, {
|
|
650
650
|
requestType: reqBody.requestType,
|
|
651
651
|
mode,
|
|
@@ -669,12 +669,12 @@ function sendOobCode(state, reqBody, ctx) {
|
|
|
669
669
|
}
|
|
670
670
|
function sendVerificationCode(state, reqBody) {
|
|
671
671
|
var _a;
|
|
672
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
673
|
-
errors_1.assert(state instanceof state_1.AgentProjectState, "UNSUPPORTED_TENANT_OPERATION");
|
|
674
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
675
|
-
errors_1.assert(reqBody.phoneNumber && utils_1.isValidPhoneNumber(reqBody.phoneNumber), "INVALID_PHONE_NUMBER : Invalid format.");
|
|
672
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
673
|
+
(0, errors_1.assert)(state instanceof state_1.AgentProjectState, "UNSUPPORTED_TENANT_OPERATION");
|
|
674
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
675
|
+
(0, errors_1.assert)(reqBody.phoneNumber && (0, utils_1.isValidPhoneNumber)(reqBody.phoneNumber), "INVALID_PHONE_NUMBER : Invalid format.");
|
|
676
676
|
const user = state.getUserByPhoneNumber(reqBody.phoneNumber);
|
|
677
|
-
errors_1.assert(!((_a = user === null || user === void 0 ? void 0 : user.mfaInfo) === null || _a === void 0 ? void 0 : _a.length), "UNSUPPORTED_FIRST_FACTOR : A phone number cannot be set as a first factor on an SMS based MFA user.");
|
|
677
|
+
(0, errors_1.assert)(!((_a = user === null || user === void 0 ? void 0 : user.mfaInfo) === null || _a === void 0 ? void 0 : _a.length), "UNSUPPORTED_FIRST_FACTOR : A phone number cannot be set as a first factor on an SMS based MFA user.");
|
|
678
678
|
const { sessionInfo, phoneNumber, code } = state.createVerificationCode(reqBody.phoneNumber);
|
|
679
679
|
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.AUTH).log("BULLET", `To verify the phone number ${phoneNumber}, use the code ${code}.`);
|
|
680
680
|
return {
|
|
@@ -683,9 +683,9 @@ function sendVerificationCode(state, reqBody) {
|
|
|
683
683
|
}
|
|
684
684
|
function setAccountInfo(state, reqBody, ctx) {
|
|
685
685
|
var _a;
|
|
686
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
687
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
688
|
-
const url = utils_1.authEmulatorUrl(ctx.req);
|
|
686
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
687
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
688
|
+
const url = (0, utils_1.authEmulatorUrl)(ctx.req);
|
|
689
689
|
return setAccountInfoImpl(state, reqBody, {
|
|
690
690
|
privileged: !!((_a = ctx.security) === null || _a === void 0 ? void 0 : _a.Oauth2),
|
|
691
691
|
emulatorUrl: url,
|
|
@@ -704,11 +704,11 @@ function setAccountInfoImpl(state, reqBody, { privileged = false, emulatorUrl =
|
|
|
704
704
|
}
|
|
705
705
|
}
|
|
706
706
|
if (!privileged) {
|
|
707
|
-
errors_1.assert(reqBody.idToken || reqBody.oobCode, "INVALID_REQ_TYPE : Unsupported request parameters.");
|
|
708
|
-
errors_1.assert(reqBody.customAttributes == null, "INSUFFICIENT_PERMISSION");
|
|
707
|
+
(0, errors_1.assert)(reqBody.idToken || reqBody.oobCode, "INVALID_REQ_TYPE : Unsupported request parameters.");
|
|
708
|
+
(0, errors_1.assert)(reqBody.customAttributes == null, "INSUFFICIENT_PERMISSION");
|
|
709
709
|
}
|
|
710
710
|
else {
|
|
711
|
-
errors_1.assert(reqBody.localId, "MISSING_LOCAL_ID");
|
|
711
|
+
(0, errors_1.assert)(reqBody.localId, "MISSING_LOCAL_ID");
|
|
712
712
|
}
|
|
713
713
|
if (reqBody.customAttributes) {
|
|
714
714
|
validateSerializedCustomClaims(reqBody.customAttributes);
|
|
@@ -725,13 +725,13 @@ function setAccountInfoImpl(state, reqBody, { privileged = false, emulatorUrl =
|
|
|
725
725
|
let isEmailUpdate = false;
|
|
726
726
|
if (reqBody.oobCode) {
|
|
727
727
|
const oob = state.validateOobCode(reqBody.oobCode);
|
|
728
|
-
errors_1.assert(oob, "INVALID_OOB_CODE");
|
|
728
|
+
(0, errors_1.assert)(oob, "INVALID_OOB_CODE");
|
|
729
729
|
switch (oob.requestType) {
|
|
730
730
|
case "VERIFY_EMAIL": {
|
|
731
731
|
state.deleteOobCode(reqBody.oobCode);
|
|
732
732
|
signInProvider = state_1.PROVIDER_PASSWORD;
|
|
733
733
|
const maybeUser = state.getUserByEmail(oob.email);
|
|
734
|
-
errors_1.assert(maybeUser, "INVALID_OOB_CODE");
|
|
734
|
+
(0, errors_1.assert)(maybeUser, "INVALID_OOB_CODE");
|
|
735
735
|
user = maybeUser;
|
|
736
736
|
updates.emailVerified = true;
|
|
737
737
|
if (oob.email !== user.email) {
|
|
@@ -742,8 +742,8 @@ function setAccountInfoImpl(state, reqBody, { privileged = false, emulatorUrl =
|
|
|
742
742
|
case "RECOVER_EMAIL": {
|
|
743
743
|
state.deleteOobCode(reqBody.oobCode);
|
|
744
744
|
const maybeUser = state.getUserByInitialEmail(oob.email);
|
|
745
|
-
errors_1.assert(maybeUser, "INVALID_OOB_CODE");
|
|
746
|
-
errors_1.assert(!state.getUserByEmail(oob.email), "EMAIL_EXISTS");
|
|
745
|
+
(0, errors_1.assert)(maybeUser, "INVALID_OOB_CODE");
|
|
746
|
+
(0, errors_1.assert)(!state.getUserByEmail(oob.email), "EMAIL_EXISTS");
|
|
747
747
|
user = maybeUser;
|
|
748
748
|
if (oob.email !== user.email) {
|
|
749
749
|
updates.email = oob.email;
|
|
@@ -758,19 +758,19 @@ function setAccountInfoImpl(state, reqBody, { privileged = false, emulatorUrl =
|
|
|
758
758
|
else {
|
|
759
759
|
if (reqBody.idToken) {
|
|
760
760
|
({ user, signInProvider } = parseIdToken(state, reqBody.idToken));
|
|
761
|
-
errors_1.assert(reqBody.disableUser == null, "OPERATION_NOT_ALLOWED");
|
|
761
|
+
(0, errors_1.assert)(reqBody.disableUser == null, "OPERATION_NOT_ALLOWED");
|
|
762
762
|
}
|
|
763
763
|
else {
|
|
764
|
-
errors_1.assert(reqBody.localId, "MISSING_LOCAL_ID");
|
|
764
|
+
(0, errors_1.assert)(reqBody.localId, "MISSING_LOCAL_ID");
|
|
765
765
|
const maybeUser = state.getUserByLocalId(reqBody.localId);
|
|
766
|
-
errors_1.assert(maybeUser, "USER_NOT_FOUND");
|
|
766
|
+
(0, errors_1.assert)(maybeUser, "USER_NOT_FOUND");
|
|
767
767
|
user = maybeUser;
|
|
768
768
|
}
|
|
769
769
|
if (reqBody.email) {
|
|
770
|
-
errors_1.assert(utils_1.isValidEmailAddress(reqBody.email), "INVALID_EMAIL");
|
|
771
|
-
const newEmail = utils_1.canonicalizeEmailAddress(reqBody.email);
|
|
770
|
+
(0, errors_1.assert)((0, utils_1.isValidEmailAddress)(reqBody.email), "INVALID_EMAIL");
|
|
771
|
+
const newEmail = (0, utils_1.canonicalizeEmailAddress)(reqBody.email);
|
|
772
772
|
if (newEmail !== user.email) {
|
|
773
|
-
errors_1.assert(!state.getUserByEmail(newEmail), "EMAIL_EXISTS");
|
|
773
|
+
(0, errors_1.assert)(!state.getUserByEmail(newEmail), "EMAIL_EXISTS");
|
|
774
774
|
updates.email = newEmail;
|
|
775
775
|
updates.emailVerified = false;
|
|
776
776
|
isEmailUpdate = true;
|
|
@@ -780,14 +780,14 @@ function setAccountInfoImpl(state, reqBody, { privileged = false, emulatorUrl =
|
|
|
780
780
|
}
|
|
781
781
|
}
|
|
782
782
|
if (reqBody.password) {
|
|
783
|
-
errors_1.assert(reqBody.password.length >= PASSWORD_MIN_LENGTH, `WEAK_PASSWORD : Password should be at least ${PASSWORD_MIN_LENGTH} characters`);
|
|
784
|
-
updates.salt = "fakeSalt" + utils_1.randomId(20);
|
|
783
|
+
(0, errors_1.assert)(reqBody.password.length >= PASSWORD_MIN_LENGTH, `WEAK_PASSWORD : Password should be at least ${PASSWORD_MIN_LENGTH} characters`);
|
|
784
|
+
updates.salt = "fakeSalt" + (0, utils_1.randomId)(20);
|
|
785
785
|
updates.passwordHash = hashPassword(reqBody.password, updates.salt);
|
|
786
786
|
updates.passwordUpdatedAt = Date.now();
|
|
787
787
|
signInProvider = state_1.PROVIDER_PASSWORD;
|
|
788
788
|
}
|
|
789
789
|
if (reqBody.password || reqBody.validSince || updates.email) {
|
|
790
|
-
updates.validSince = utils_1.toUnixTimestamp(new Date()).toString();
|
|
790
|
+
updates.validSince = (0, utils_1.toUnixTimestamp)(new Date()).toString();
|
|
791
791
|
}
|
|
792
792
|
if (reqBody.mfa) {
|
|
793
793
|
if (reqBody.mfa.enrollments && reqBody.mfa.enrollments.length > 0) {
|
|
@@ -806,15 +806,15 @@ function setAccountInfoImpl(state, reqBody, { privileged = false, emulatorUrl =
|
|
|
806
806
|
updates.disabled = reqBody.disableUser;
|
|
807
807
|
}
|
|
808
808
|
if (reqBody.phoneNumber && reqBody.phoneNumber !== user.phoneNumber) {
|
|
809
|
-
errors_1.assert(utils_1.isValidPhoneNumber(reqBody.phoneNumber), "INVALID_PHONE_NUMBER : Invalid format.");
|
|
810
|
-
errors_1.assert(!state.getUserByPhoneNumber(reqBody.phoneNumber), "PHONE_NUMBER_EXISTS");
|
|
809
|
+
(0, errors_1.assert)((0, utils_1.isValidPhoneNumber)(reqBody.phoneNumber), "INVALID_PHONE_NUMBER : Invalid format.");
|
|
810
|
+
(0, errors_1.assert)(!state.getUserByPhoneNumber(reqBody.phoneNumber), "PHONE_NUMBER_EXISTS");
|
|
811
811
|
updates.phoneNumber = reqBody.phoneNumber;
|
|
812
812
|
}
|
|
813
813
|
fieldsToCopy.push("emailVerified", "customAttributes", "createdAt", "lastLoginAt", "validSince");
|
|
814
814
|
}
|
|
815
815
|
for (const field of fieldsToCopy) {
|
|
816
816
|
if (reqBody[field] != null) {
|
|
817
|
-
utils_1.mirrorFieldTo(updates, field, reqBody);
|
|
817
|
+
(0, utils_1.mirrorFieldTo)(updates, field, reqBody);
|
|
818
818
|
}
|
|
819
819
|
}
|
|
820
820
|
for (const attr of reqBody.deleteAttribute) {
|
|
@@ -909,8 +909,8 @@ function logOobMessage(oobRecord) {
|
|
|
909
909
|
}
|
|
910
910
|
function signInWithCustomToken(state, reqBody) {
|
|
911
911
|
var _a;
|
|
912
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
913
|
-
errors_1.assert(reqBody.token, "MISSING_CUSTOM_TOKEN");
|
|
912
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
913
|
+
(0, errors_1.assert)(reqBody.token, "MISSING_CUSTOM_TOKEN");
|
|
914
914
|
let payload;
|
|
915
915
|
if (reqBody.token.startsWith("{")) {
|
|
916
916
|
try {
|
|
@@ -921,20 +921,20 @@ function signInWithCustomToken(state, reqBody) {
|
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
923
|
else {
|
|
924
|
-
const decoded = jsonwebtoken_1.decode(reqBody.token, { complete: true });
|
|
924
|
+
const decoded = (0, jsonwebtoken_1.decode)(reqBody.token, { complete: true });
|
|
925
925
|
if (state instanceof state_1.TenantProjectState) {
|
|
926
|
-
errors_1.assert((decoded === null || decoded === void 0 ? void 0 : decoded.payload.tenant_id) === state.tenantId, "TENANT_ID_MISMATCH");
|
|
926
|
+
(0, errors_1.assert)((decoded === null || decoded === void 0 ? void 0 : decoded.payload.tenant_id) === state.tenantId, "TENANT_ID_MISMATCH");
|
|
927
927
|
}
|
|
928
|
-
errors_1.assert(decoded, "INVALID_CUSTOM_TOKEN : Invalid assertion format");
|
|
928
|
+
(0, errors_1.assert)(decoded, "INVALID_CUSTOM_TOKEN : Invalid assertion format");
|
|
929
929
|
if (decoded.header.alg !== "none") {
|
|
930
930
|
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.AUTH).log("WARN", "Received a signed custom token. Auth Emulator does not validate JWTs and IS NOT SECURE");
|
|
931
931
|
}
|
|
932
|
-
errors_1.assert(decoded.payload.aud === exports.CUSTOM_TOKEN_AUDIENCE, `INVALID_CUSTOM_TOKEN : ((Invalid aud (audience): ${decoded.payload.aud} ` +
|
|
932
|
+
(0, errors_1.assert)(decoded.payload.aud === exports.CUSTOM_TOKEN_AUDIENCE, `INVALID_CUSTOM_TOKEN : ((Invalid aud (audience): ${decoded.payload.aud} ` +
|
|
933
933
|
"Note: Firebase ID Tokens / third-party tokens cannot be used with signInWithCustomToken.))");
|
|
934
934
|
payload = decoded.payload;
|
|
935
935
|
}
|
|
936
936
|
const localId = (_a = coercePrimitiveToString(payload.uid)) !== null && _a !== void 0 ? _a : coercePrimitiveToString(payload.user_id);
|
|
937
|
-
errors_1.assert(localId, "MISSING_IDENTIFIER");
|
|
937
|
+
(0, errors_1.assert)(localId, "MISSING_IDENTIFIER");
|
|
938
938
|
let extraClaims = {};
|
|
939
939
|
if ("claims" in payload) {
|
|
940
940
|
validateCustomClaims(payload.claims);
|
|
@@ -948,7 +948,7 @@ function signInWithCustomToken(state, reqBody) {
|
|
|
948
948
|
tenantId: state instanceof state_1.TenantProjectState ? state.tenantId : undefined,
|
|
949
949
|
};
|
|
950
950
|
if (user) {
|
|
951
|
-
errors_1.assert(!user.disabled, "USER_DISABLED");
|
|
951
|
+
(0, errors_1.assert)(!user.disabled, "USER_DISABLED");
|
|
952
952
|
user = state.updateUserByLocalId(localId, updates);
|
|
953
953
|
}
|
|
954
954
|
else {
|
|
@@ -961,16 +961,16 @@ function signInWithCustomToken(state, reqBody) {
|
|
|
961
961
|
}
|
|
962
962
|
function signInWithEmailLink(state, reqBody) {
|
|
963
963
|
var _a;
|
|
964
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
965
|
-
errors_1.assert(state.enableEmailLinkSignin, "OPERATION_NOT_ALLOWED");
|
|
966
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
964
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
965
|
+
(0, errors_1.assert)(state.enableEmailLinkSignin, "OPERATION_NOT_ALLOWED");
|
|
966
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
967
967
|
const userFromIdToken = reqBody.idToken ? parseIdToken(state, reqBody.idToken).user : undefined;
|
|
968
|
-
errors_1.assert(reqBody.email, "MISSING_EMAIL");
|
|
969
|
-
const email = utils_1.canonicalizeEmailAddress(reqBody.email);
|
|
970
|
-
errors_1.assert(reqBody.oobCode, "MISSING_OOB_CODE");
|
|
968
|
+
(0, errors_1.assert)(reqBody.email, "MISSING_EMAIL");
|
|
969
|
+
const email = (0, utils_1.canonicalizeEmailAddress)(reqBody.email);
|
|
970
|
+
(0, errors_1.assert)(reqBody.oobCode, "MISSING_OOB_CODE");
|
|
971
971
|
const oob = state.validateOobCode(reqBody.oobCode);
|
|
972
|
-
errors_1.assert(oob && oob.requestType === "EMAIL_SIGNIN", "INVALID_OOB_CODE");
|
|
973
|
-
errors_1.assert(email === oob.email, "INVALID_EMAIL : The email provided does not match the sign-in email address.");
|
|
972
|
+
(0, errors_1.assert)(oob && oob.requestType === "EMAIL_SIGNIN", "INVALID_OOB_CODE");
|
|
973
|
+
(0, errors_1.assert)(email === oob.email, "INVALID_EMAIL : The email provided does not match the sign-in email address.");
|
|
974
974
|
state.deleteOobCode(reqBody.oobCode);
|
|
975
975
|
const updates = {
|
|
976
976
|
email,
|
|
@@ -991,8 +991,8 @@ function signInWithEmailLink(state, reqBody) {
|
|
|
991
991
|
}
|
|
992
992
|
}
|
|
993
993
|
else {
|
|
994
|
-
errors_1.assert(!user.disabled, "USER_DISABLED");
|
|
995
|
-
errors_1.assert(!userFromIdToken || userFromIdToken.localId === user.localId, "EMAIL_EXISTS");
|
|
994
|
+
(0, errors_1.assert)(!user.disabled, "USER_DISABLED");
|
|
995
|
+
(0, errors_1.assert)(!userFromIdToken || userFromIdToken.localId === user.localId, "EMAIL_EXISTS");
|
|
996
996
|
user = state.updateUserByLocalId(user.localId, updates);
|
|
997
997
|
}
|
|
998
998
|
const response = {
|
|
@@ -1001,7 +1001,8 @@ function signInWithEmailLink(state, reqBody) {
|
|
|
1001
1001
|
localId: user.localId,
|
|
1002
1002
|
isNewUser,
|
|
1003
1003
|
};
|
|
1004
|
-
if ((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1004
|
+
if ((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1005
|
+
((_a = user.mfaInfo) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1005
1006
|
return Object.assign(Object.assign({}, response), mfaPending(state, user, state_1.PROVIDER_PASSWORD));
|
|
1006
1007
|
}
|
|
1007
1008
|
else {
|
|
@@ -1011,8 +1012,8 @@ function signInWithEmailLink(state, reqBody) {
|
|
|
1011
1012
|
}
|
|
1012
1013
|
function signInWithIdp(state, reqBody) {
|
|
1013
1014
|
var _a, _b, _c;
|
|
1014
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
1015
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1015
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
1016
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1016
1017
|
if (reqBody.returnRefreshToken) {
|
|
1017
1018
|
throw new errors_1.NotImplementedError("returnRefreshToken is not implemented yet.");
|
|
1018
1019
|
}
|
|
@@ -1021,7 +1022,7 @@ function signInWithIdp(state, reqBody) {
|
|
|
1021
1022
|
}
|
|
1022
1023
|
const normalizedUri = getNormalizedUri(reqBody);
|
|
1023
1024
|
const providerId = (_a = normalizedUri.searchParams.get("providerId")) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
1024
|
-
errors_1.assert(providerId, `INVALID_CREDENTIAL_OR_PROVIDER_ID : Invalid IdP response/credential: ${normalizedUri.toString()}`);
|
|
1025
|
+
(0, errors_1.assert)(providerId, `INVALID_CREDENTIAL_OR_PROVIDER_ID : Invalid IdP response/credential: ${normalizedUri.toString()}`);
|
|
1025
1026
|
const oauthIdToken = normalizedUri.searchParams.get("id_token") || undefined;
|
|
1026
1027
|
const oauthAccessToken = normalizedUri.searchParams.get("access_token") || undefined;
|
|
1027
1028
|
const claims = parseClaims(oauthIdToken) || parseClaims(oauthAccessToken);
|
|
@@ -1046,9 +1047,9 @@ function signInWithIdp(state, reqBody) {
|
|
|
1046
1047
|
if (normalizedUri.searchParams.get("SAMLResponse")) {
|
|
1047
1048
|
samlResponse = JSON.parse(normalizedUri.searchParams.get("SAMLResponse"));
|
|
1048
1049
|
signInAttributes = (_b = samlResponse.assertion) === null || _b === void 0 ? void 0 : _b.attributeStatements;
|
|
1049
|
-
errors_1.assert(samlResponse.assertion, "INVALID_IDP_RESPONSE ((Missing assertion in SAMLResponse.))");
|
|
1050
|
-
errors_1.assert(samlResponse.assertion.subject, "INVALID_IDP_RESPONSE ((Missing assertion.subject in SAMLResponse.))");
|
|
1051
|
-
errors_1.assert(samlResponse.assertion.subject.nameId, "INVALID_IDP_RESPONSE ((Missing assertion.subject.nameId in SAMLResponse.))");
|
|
1050
|
+
(0, errors_1.assert)(samlResponse.assertion, "INVALID_IDP_RESPONSE ((Missing assertion in SAMLResponse.))");
|
|
1051
|
+
(0, errors_1.assert)(samlResponse.assertion.subject, "INVALID_IDP_RESPONSE ((Missing assertion.subject in SAMLResponse.))");
|
|
1052
|
+
(0, errors_1.assert)(samlResponse.assertion.subject.nameId, "INVALID_IDP_RESPONSE ((Missing assertion.subject.nameId in SAMLResponse.))");
|
|
1052
1053
|
}
|
|
1053
1054
|
let { response, rawId } = fakeFetchUserInfoFromIdp(providerId, claims, samlResponse);
|
|
1054
1055
|
response.oauthAccessToken =
|
|
@@ -1059,7 +1060,7 @@ function signInWithIdp(state, reqBody) {
|
|
|
1059
1060
|
let accountUpdates;
|
|
1060
1061
|
try {
|
|
1061
1062
|
if (userFromIdToken) {
|
|
1062
|
-
errors_1.assert(!userMatchingProvider, "FEDERATED_USER_ID_ALREADY_LINKED");
|
|
1063
|
+
(0, errors_1.assert)(!userMatchingProvider, "FEDERATED_USER_ID_ALREADY_LINKED");
|
|
1063
1064
|
({ accountUpdates, response } = handleLinkIdp(state, response, userFromIdToken));
|
|
1064
1065
|
}
|
|
1065
1066
|
else if (state.oneAccountPerEmail) {
|
|
@@ -1110,7 +1111,8 @@ function signInWithIdp(state, reqBody) {
|
|
|
1110
1111
|
if (state instanceof state_1.TenantProjectState) {
|
|
1111
1112
|
response.tenantId = state.tenantId;
|
|
1112
1113
|
}
|
|
1113
|
-
if ((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1114
|
+
if ((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1115
|
+
((_c = user.mfaInfo) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
1114
1116
|
return Object.assign(Object.assign({}, response), mfaPending(state, user, providerId));
|
|
1115
1117
|
}
|
|
1116
1118
|
else {
|
|
@@ -1120,30 +1122,31 @@ function signInWithIdp(state, reqBody) {
|
|
|
1120
1122
|
}
|
|
1121
1123
|
function signInWithPassword(state, reqBody) {
|
|
1122
1124
|
var _a;
|
|
1123
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
1124
|
-
errors_1.assert(state.allowPasswordSignup, "PASSWORD_LOGIN_DISABLED");
|
|
1125
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1126
|
-
errors_1.assert(reqBody.email, "MISSING_EMAIL");
|
|
1127
|
-
errors_1.assert(reqBody.password, "MISSING_PASSWORD");
|
|
1125
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
1126
|
+
(0, errors_1.assert)(state.allowPasswordSignup, "PASSWORD_LOGIN_DISABLED");
|
|
1127
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1128
|
+
(0, errors_1.assert)(reqBody.email, "MISSING_EMAIL");
|
|
1129
|
+
(0, errors_1.assert)(reqBody.password, "MISSING_PASSWORD");
|
|
1128
1130
|
if (reqBody.captchaResponse || reqBody.captchaChallenge) {
|
|
1129
1131
|
throw new errors_1.NotImplementedError("captcha unimplemented");
|
|
1130
1132
|
}
|
|
1131
1133
|
if (reqBody.idToken || reqBody.pendingIdToken) {
|
|
1132
1134
|
throw new errors_1.NotImplementedError("idToken / pendingIdToken is no longer in use and unsupported by the Auth Emulator.");
|
|
1133
1135
|
}
|
|
1134
|
-
const email = utils_1.canonicalizeEmailAddress(reqBody.email);
|
|
1136
|
+
const email = (0, utils_1.canonicalizeEmailAddress)(reqBody.email);
|
|
1135
1137
|
let user = state.getUserByEmail(email);
|
|
1136
|
-
errors_1.assert(user, "EMAIL_NOT_FOUND");
|
|
1137
|
-
errors_1.assert(!user.disabled, "USER_DISABLED");
|
|
1138
|
-
errors_1.assert(user.passwordHash && user.salt, "INVALID_PASSWORD");
|
|
1139
|
-
errors_1.assert(user.passwordHash === hashPassword(reqBody.password, user.salt), "INVALID_PASSWORD");
|
|
1138
|
+
(0, errors_1.assert)(user, "EMAIL_NOT_FOUND");
|
|
1139
|
+
(0, errors_1.assert)(!user.disabled, "USER_DISABLED");
|
|
1140
|
+
(0, errors_1.assert)(user.passwordHash && user.salt, "INVALID_PASSWORD");
|
|
1141
|
+
(0, errors_1.assert)(user.passwordHash === hashPassword(reqBody.password, user.salt), "INVALID_PASSWORD");
|
|
1140
1142
|
const response = {
|
|
1141
1143
|
kind: "identitytoolkit#VerifyPasswordResponse",
|
|
1142
1144
|
registered: true,
|
|
1143
1145
|
localId: user.localId,
|
|
1144
1146
|
email,
|
|
1145
1147
|
};
|
|
1146
|
-
if ((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1148
|
+
if ((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1149
|
+
((_a = user.mfaInfo) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1147
1150
|
return Object.assign(Object.assign({}, response), mfaPending(state, user, state_1.PROVIDER_PASSWORD));
|
|
1148
1151
|
}
|
|
1149
1152
|
else {
|
|
@@ -1153,19 +1156,19 @@ function signInWithPassword(state, reqBody) {
|
|
|
1153
1156
|
}
|
|
1154
1157
|
function signInWithPhoneNumber(state, reqBody) {
|
|
1155
1158
|
var _a;
|
|
1156
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
1157
|
-
errors_1.assert(state instanceof state_1.AgentProjectState, "UNSUPPORTED_TENANT_OPERATION");
|
|
1158
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1159
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
1160
|
+
(0, errors_1.assert)(state instanceof state_1.AgentProjectState, "UNSUPPORTED_TENANT_OPERATION");
|
|
1161
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1159
1162
|
let phoneNumber;
|
|
1160
1163
|
if (reqBody.temporaryProof) {
|
|
1161
|
-
errors_1.assert(reqBody.phoneNumber, "MISSING_PHONE_NUMBER");
|
|
1164
|
+
(0, errors_1.assert)(reqBody.phoneNumber, "MISSING_PHONE_NUMBER");
|
|
1162
1165
|
const proof = state.validateTemporaryProof(reqBody.temporaryProof, reqBody.phoneNumber);
|
|
1163
|
-
errors_1.assert(proof, "INVALID_TEMPORARY_PROOF");
|
|
1166
|
+
(0, errors_1.assert)(proof, "INVALID_TEMPORARY_PROOF");
|
|
1164
1167
|
({ phoneNumber } = proof);
|
|
1165
1168
|
}
|
|
1166
1169
|
else {
|
|
1167
|
-
errors_1.assert(reqBody.sessionInfo, "MISSING_SESSION_INFO");
|
|
1168
|
-
errors_1.assert(reqBody.code, "MISSING_CODE");
|
|
1170
|
+
(0, errors_1.assert)(reqBody.sessionInfo, "MISSING_SESSION_INFO");
|
|
1171
|
+
(0, errors_1.assert)(reqBody.code, "MISSING_CODE");
|
|
1169
1172
|
phoneNumber = verifyPhoneNumber(state, reqBody.sessionInfo, reqBody.code);
|
|
1170
1173
|
}
|
|
1171
1174
|
let user = state.getUserByPhoneNumber(phoneNumber);
|
|
@@ -1177,7 +1180,7 @@ function signInWithPhoneNumber(state, reqBody) {
|
|
|
1177
1180
|
const userFromIdToken = reqBody.idToken ? parseIdToken(state, reqBody.idToken).user : undefined;
|
|
1178
1181
|
if (!user) {
|
|
1179
1182
|
if (userFromIdToken) {
|
|
1180
|
-
errors_1.assert(!((_a = userFromIdToken.mfaInfo) === null || _a === void 0 ? void 0 : _a.length), "UNSUPPORTED_FIRST_FACTOR : A phone number cannot be set as a first factor on an SMS based MFA user.");
|
|
1183
|
+
(0, errors_1.assert)(!((_a = userFromIdToken.mfaInfo) === null || _a === void 0 ? void 0 : _a.length), "UNSUPPORTED_FIRST_FACTOR : A phone number cannot be set as a first factor on an SMS based MFA user.");
|
|
1181
1184
|
user = state.updateUserByLocalId(userFromIdToken.localId, updates);
|
|
1182
1185
|
}
|
|
1183
1186
|
else {
|
|
@@ -1186,7 +1189,7 @@ function signInWithPhoneNumber(state, reqBody) {
|
|
|
1186
1189
|
}
|
|
1187
1190
|
}
|
|
1188
1191
|
else {
|
|
1189
|
-
errors_1.assert(!user.disabled, "USER_DISABLED");
|
|
1192
|
+
(0, errors_1.assert)(!user.disabled, "USER_DISABLED");
|
|
1190
1193
|
if (userFromIdToken && userFromIdToken.localId !== user.localId) {
|
|
1191
1194
|
if (!reqBody.temporaryProof) {
|
|
1192
1195
|
return Object.assign({}, state.createTemporaryProof(phoneNumber));
|
|
@@ -1200,13 +1203,13 @@ function signInWithPhoneNumber(state, reqBody) {
|
|
|
1200
1203
|
phoneNumber, localId: user.localId }, tokens);
|
|
1201
1204
|
}
|
|
1202
1205
|
function grantToken(state, reqBody) {
|
|
1203
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1204
|
-
errors_1.assert(reqBody.grantType, "MISSING_GRANT_TYPE");
|
|
1205
|
-
errors_1.assert(reqBody.grantType === "refresh_token", "INVALID_GRANT_TYPE");
|
|
1206
|
-
errors_1.assert(reqBody.refreshToken, "MISSING_REFRESH_TOKEN");
|
|
1206
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1207
|
+
(0, errors_1.assert)(reqBody.grantType, "MISSING_GRANT_TYPE");
|
|
1208
|
+
(0, errors_1.assert)(reqBody.grantType === "refresh_token", "INVALID_GRANT_TYPE");
|
|
1209
|
+
(0, errors_1.assert)(reqBody.refreshToken, "MISSING_REFRESH_TOKEN");
|
|
1207
1210
|
const refreshTokenRecord = state.validateRefreshToken(reqBody.refreshToken);
|
|
1208
|
-
errors_1.assert(refreshTokenRecord, "INVALID_REFRESH_TOKEN");
|
|
1209
|
-
errors_1.assert(!refreshTokenRecord.user.disabled, "USER_DISABLED");
|
|
1211
|
+
(0, errors_1.assert)(refreshTokenRecord, "INVALID_REFRESH_TOKEN");
|
|
1212
|
+
(0, errors_1.assert)(!refreshTokenRecord.user.disabled, "USER_DISABLED");
|
|
1210
1213
|
const tokens = issueTokens(state, refreshTokenRecord.user, refreshTokenRecord.provider, {
|
|
1211
1214
|
extraClaims: refreshTokenRecord.extraClaims,
|
|
1212
1215
|
secondFactor: refreshTokenRecord.secondFactor,
|
|
@@ -1237,15 +1240,15 @@ function updateEmulatorProjectConfig(state, reqBody) {
|
|
|
1237
1240
|
var _a;
|
|
1238
1241
|
const allowDuplicateEmails = (_a = reqBody.signIn) === null || _a === void 0 ? void 0 : _a.allowDuplicateEmails;
|
|
1239
1242
|
if (allowDuplicateEmails != null) {
|
|
1240
|
-
errors_1.assert(state instanceof state_1.AgentProjectState, "((Only top level projects can set oneAccountPerEmail.))");
|
|
1243
|
+
(0, errors_1.assert)(state instanceof state_1.AgentProjectState, "((Only top level projects can set oneAccountPerEmail.))");
|
|
1241
1244
|
state.oneAccountPerEmail = !allowDuplicateEmails;
|
|
1242
1245
|
}
|
|
1243
1246
|
const usageMode = reqBody.usageMode;
|
|
1244
1247
|
if (usageMode != null) {
|
|
1245
|
-
errors_1.assert(state instanceof state_1.AgentProjectState, "((Only top level projects can set usageMode.))");
|
|
1248
|
+
(0, errors_1.assert)(state instanceof state_1.AgentProjectState, "((Only top level projects can set usageMode.))");
|
|
1246
1249
|
switch (usageMode) {
|
|
1247
1250
|
case "PASSTHROUGH":
|
|
1248
|
-
errors_1.assert(state.getUserCount() === 0, "Users are present, unable to set passthrough mode");
|
|
1251
|
+
(0, errors_1.assert)(state.getUserCount() === 0, "Users are present, unable to set passthrough mode");
|
|
1249
1252
|
state.usageMode = state_1.UsageMode.PASSTHROUGH;
|
|
1250
1253
|
break;
|
|
1251
1254
|
case "DEFAULT":
|
|
@@ -1269,16 +1272,17 @@ function listVerificationCodesInProject(state) {
|
|
|
1269
1272
|
}
|
|
1270
1273
|
function mfaEnrollmentStart(state, reqBody) {
|
|
1271
1274
|
var _a, _b;
|
|
1272
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
1273
|
-
errors_1.assert((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1274
|
-
|
|
1275
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
1276
|
+
(0, errors_1.assert)((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1277
|
+
((_a = state.mfaConfig.enabledProviders) === null || _a === void 0 ? void 0 : _a.includes("PHONE_SMS")), "OPERATION_NOT_ALLOWED : SMS based MFA not enabled.");
|
|
1278
|
+
(0, errors_1.assert)(reqBody.idToken, "MISSING_ID_TOKEN");
|
|
1275
1279
|
const { user, signInProvider } = parseIdToken(state, reqBody.idToken);
|
|
1276
|
-
errors_1.assert(!MFA_INELIGIBLE_PROVIDER.has(signInProvider), "UNSUPPORTED_FIRST_FACTOR : MFA is not available for the given first factor.");
|
|
1277
|
-
errors_1.assert(user.emailVerified, "UNVERIFIED_EMAIL : Need to verify email first before enrolling second factors.");
|
|
1278
|
-
errors_1.assert(reqBody.phoneEnrollmentInfo, "INVALID_ARGUMENT : ((Missing phoneEnrollmentInfo.))");
|
|
1280
|
+
(0, errors_1.assert)(!MFA_INELIGIBLE_PROVIDER.has(signInProvider), "UNSUPPORTED_FIRST_FACTOR : MFA is not available for the given first factor.");
|
|
1281
|
+
(0, errors_1.assert)(user.emailVerified, "UNVERIFIED_EMAIL : Need to verify email first before enrolling second factors.");
|
|
1282
|
+
(0, errors_1.assert)(reqBody.phoneEnrollmentInfo, "INVALID_ARGUMENT : ((Missing phoneEnrollmentInfo.))");
|
|
1279
1283
|
const phoneNumber = reqBody.phoneEnrollmentInfo.phoneNumber;
|
|
1280
|
-
errors_1.assert(phoneNumber && utils_1.isValidPhoneNumber(phoneNumber), "INVALID_PHONE_NUMBER : Invalid format.");
|
|
1281
|
-
errors_1.assert(!((_b = user.mfaInfo) === null || _b === void 0 ? void 0 : _b.some((enrollment) => enrollment.unobfuscatedPhoneInfo === phoneNumber)), "SECOND_FACTOR_EXISTS : Phone number already enrolled as second factor for this account.");
|
|
1284
|
+
(0, errors_1.assert)(phoneNumber && (0, utils_1.isValidPhoneNumber)(phoneNumber), "INVALID_PHONE_NUMBER : Invalid format.");
|
|
1285
|
+
(0, errors_1.assert)(!((_b = user.mfaInfo) === null || _b === void 0 ? void 0 : _b.some((enrollment) => enrollment.unobfuscatedPhoneInfo === phoneNumber)), "SECOND_FACTOR_EXISTS : Phone number already enrolled as second factor for this account.");
|
|
1282
1286
|
const { sessionInfo, code } = state.createVerificationCode(phoneNumber);
|
|
1283
1287
|
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.AUTH).log("BULLET", `To enroll MFA with ${phoneNumber}, use the code ${code}.`);
|
|
1284
1288
|
return {
|
|
@@ -1289,20 +1293,21 @@ function mfaEnrollmentStart(state, reqBody) {
|
|
|
1289
1293
|
}
|
|
1290
1294
|
function mfaEnrollmentFinalize(state, reqBody) {
|
|
1291
1295
|
var _a, _b;
|
|
1292
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
1293
|
-
errors_1.assert((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1294
|
-
|
|
1296
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
1297
|
+
(0, errors_1.assert)((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1298
|
+
((_a = state.mfaConfig.enabledProviders) === null || _a === void 0 ? void 0 : _a.includes("PHONE_SMS")), "OPERATION_NOT_ALLOWED : SMS based MFA not enabled.");
|
|
1299
|
+
(0, errors_1.assert)(reqBody.idToken, "MISSING_ID_TOKEN");
|
|
1295
1300
|
let { user, signInProvider } = parseIdToken(state, reqBody.idToken);
|
|
1296
|
-
errors_1.assert(!MFA_INELIGIBLE_PROVIDER.has(signInProvider), "UNSUPPORTED_FIRST_FACTOR : MFA is not available for the given first factor.");
|
|
1297
|
-
errors_1.assert(reqBody.phoneVerificationInfo, "INVALID_ARGUMENT : ((Missing phoneVerificationInfo.))");
|
|
1301
|
+
(0, errors_1.assert)(!MFA_INELIGIBLE_PROVIDER.has(signInProvider), "UNSUPPORTED_FIRST_FACTOR : MFA is not available for the given first factor.");
|
|
1302
|
+
(0, errors_1.assert)(reqBody.phoneVerificationInfo, "INVALID_ARGUMENT : ((Missing phoneVerificationInfo.))");
|
|
1298
1303
|
if (reqBody.phoneVerificationInfo.androidVerificationProof) {
|
|
1299
1304
|
throw new errors_1.NotImplementedError("androidVerificationProof is unsupported!");
|
|
1300
1305
|
}
|
|
1301
1306
|
const { code, sessionInfo } = reqBody.phoneVerificationInfo;
|
|
1302
|
-
errors_1.assert(code, "MISSING_CODE");
|
|
1303
|
-
errors_1.assert(sessionInfo, "MISSING_SESSION_INFO");
|
|
1307
|
+
(0, errors_1.assert)(code, "MISSING_CODE");
|
|
1308
|
+
(0, errors_1.assert)(sessionInfo, "MISSING_SESSION_INFO");
|
|
1304
1309
|
const phoneNumber = verifyPhoneNumber(state, sessionInfo, code);
|
|
1305
|
-
errors_1.assert(!((_b = user.mfaInfo) === null || _b === void 0 ? void 0 : _b.some((enrollment) => enrollment.unobfuscatedPhoneInfo === phoneNumber)), "SECOND_FACTOR_EXISTS : Phone number already enrolled as second factor for this account.");
|
|
1310
|
+
(0, errors_1.assert)(!((_b = user.mfaInfo) === null || _b === void 0 ? void 0 : _b.some((enrollment) => enrollment.unobfuscatedPhoneInfo === phoneNumber)), "SECOND_FACTOR_EXISTS : Phone number already enrolled as second factor for this account.");
|
|
1306
1311
|
const existingFactors = user.mfaInfo || [];
|
|
1307
1312
|
const existingIds = new Set();
|
|
1308
1313
|
for (const { mfaEnrollmentId } of existingFactors) {
|
|
@@ -1329,26 +1334,27 @@ function mfaEnrollmentFinalize(state, reqBody) {
|
|
|
1329
1334
|
};
|
|
1330
1335
|
}
|
|
1331
1336
|
function mfaEnrollmentWithdraw(state, reqBody) {
|
|
1332
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
1333
|
-
errors_1.assert(reqBody.idToken, "MISSING_ID_TOKEN");
|
|
1337
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
1338
|
+
(0, errors_1.assert)(reqBody.idToken, "MISSING_ID_TOKEN");
|
|
1334
1339
|
let { user, signInProvider } = parseIdToken(state, reqBody.idToken);
|
|
1335
|
-
errors_1.assert(user.mfaInfo, "MFA_ENROLLMENT_NOT_FOUND");
|
|
1340
|
+
(0, errors_1.assert)(user.mfaInfo, "MFA_ENROLLMENT_NOT_FOUND");
|
|
1336
1341
|
const updatedList = user.mfaInfo.filter((enrollment) => enrollment.mfaEnrollmentId !== reqBody.mfaEnrollmentId);
|
|
1337
|
-
errors_1.assert(updatedList.length < user.mfaInfo.length, "MFA_ENROLLMENT_NOT_FOUND");
|
|
1342
|
+
(0, errors_1.assert)(updatedList.length < user.mfaInfo.length, "MFA_ENROLLMENT_NOT_FOUND");
|
|
1338
1343
|
user = state.updateUserByLocalId(user.localId, { mfaInfo: updatedList });
|
|
1339
1344
|
return Object.assign({}, issueTokens(state, user, signInProvider));
|
|
1340
1345
|
}
|
|
1341
1346
|
function mfaSignInStart(state, reqBody) {
|
|
1342
1347
|
var _a, _b;
|
|
1343
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
1344
|
-
errors_1.assert((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1345
|
-
|
|
1346
|
-
errors_1.assert(reqBody.
|
|
1348
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
1349
|
+
(0, errors_1.assert)((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1350
|
+
((_a = state.mfaConfig.enabledProviders) === null || _a === void 0 ? void 0 : _a.includes("PHONE_SMS")), "OPERATION_NOT_ALLOWED : SMS based MFA not enabled.");
|
|
1351
|
+
(0, errors_1.assert)(reqBody.mfaPendingCredential, "MISSING_MFA_PENDING_CREDENTIAL : Request does not have MFA pending credential.");
|
|
1352
|
+
(0, errors_1.assert)(reqBody.mfaEnrollmentId, "MISSING_MFA_ENROLLMENT_ID : No second factor identifier is provided.");
|
|
1347
1353
|
const { user } = parsePendingCredential(state, reqBody.mfaPendingCredential);
|
|
1348
1354
|
const enrollment = (_b = user.mfaInfo) === null || _b === void 0 ? void 0 : _b.find((factor) => factor.mfaEnrollmentId === reqBody.mfaEnrollmentId);
|
|
1349
|
-
errors_1.assert(enrollment, "MFA_ENROLLMENT_NOT_FOUND");
|
|
1355
|
+
(0, errors_1.assert)(enrollment, "MFA_ENROLLMENT_NOT_FOUND");
|
|
1350
1356
|
const phoneNumber = enrollment.unobfuscatedPhoneInfo;
|
|
1351
|
-
errors_1.assert(phoneNumber, "INVALID_ARGUMENT : MFA provider not supported!");
|
|
1357
|
+
(0, errors_1.assert)(phoneNumber, "INVALID_ARGUMENT : MFA provider not supported!");
|
|
1352
1358
|
const { sessionInfo, code } = state.createVerificationCode(phoneNumber);
|
|
1353
1359
|
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.AUTH).log("BULLET", `To sign in with MFA using ${phoneNumber}, use the code ${code}.`);
|
|
1354
1360
|
return {
|
|
@@ -1359,22 +1365,23 @@ function mfaSignInStart(state, reqBody) {
|
|
|
1359
1365
|
}
|
|
1360
1366
|
function mfaSignInFinalize(state, reqBody) {
|
|
1361
1367
|
var _a, _b;
|
|
1362
|
-
errors_1.assert(!state.disableAuth, "PROJECT_DISABLED");
|
|
1363
|
-
errors_1.assert((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1364
|
-
|
|
1365
|
-
errors_1.assert(reqBody.
|
|
1368
|
+
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
1369
|
+
(0, errors_1.assert)((state.mfaConfig.state === "ENABLED" || state.mfaConfig.state === "MANDATORY") &&
|
|
1370
|
+
((_a = state.mfaConfig.enabledProviders) === null || _a === void 0 ? void 0 : _a.includes("PHONE_SMS")), "OPERATION_NOT_ALLOWED : SMS based MFA not enabled.");
|
|
1371
|
+
(0, errors_1.assert)(reqBody.mfaPendingCredential, "MISSING_CREDENTIAL : Please set MFA Pending Credential.");
|
|
1372
|
+
(0, errors_1.assert)(reqBody.phoneVerificationInfo, "INVALID_ARGUMENT : MFA provider not supported!");
|
|
1366
1373
|
if (reqBody.phoneVerificationInfo.androidVerificationProof) {
|
|
1367
1374
|
throw new errors_1.NotImplementedError("androidVerificationProof is unsupported!");
|
|
1368
1375
|
}
|
|
1369
1376
|
const { code, sessionInfo } = reqBody.phoneVerificationInfo;
|
|
1370
|
-
errors_1.assert(code, "MISSING_CODE");
|
|
1371
|
-
errors_1.assert(sessionInfo, "MISSING_SESSION_INFO");
|
|
1377
|
+
(0, errors_1.assert)(code, "MISSING_CODE");
|
|
1378
|
+
(0, errors_1.assert)(sessionInfo, "MISSING_SESSION_INFO");
|
|
1372
1379
|
const phoneNumber = verifyPhoneNumber(state, sessionInfo, code);
|
|
1373
1380
|
let { user, signInProvider } = parsePendingCredential(state, reqBody.mfaPendingCredential);
|
|
1374
1381
|
const enrollment = (_b = user.mfaInfo) === null || _b === void 0 ? void 0 : _b.find((enrollment) => enrollment.unobfuscatedPhoneInfo == phoneNumber);
|
|
1375
|
-
errors_1.assert(enrollment && enrollment.mfaEnrollmentId, "MFA_ENROLLMENT_NOT_FOUND");
|
|
1382
|
+
(0, errors_1.assert)(enrollment && enrollment.mfaEnrollmentId, "MFA_ENROLLMENT_NOT_FOUND");
|
|
1376
1383
|
user = state.updateUserByLocalId(user.localId, { lastLoginAt: Date.now().toString() });
|
|
1377
|
-
errors_1.assert(!user.disabled, "USER_DISABLED");
|
|
1384
|
+
(0, errors_1.assert)(!user.disabled, "USER_DISABLED");
|
|
1378
1385
|
const { idToken, refreshToken } = issueTokens(state, user, signInProvider, {
|
|
1379
1386
|
secondFactor: { identifier: enrollment.mfaEnrollmentId, provider: state_1.PROVIDER_PHONE },
|
|
1380
1387
|
});
|
|
@@ -1428,20 +1435,20 @@ function issueTokens(state, user, signInProvider, { extraClaims, secondFactor, s
|
|
|
1428
1435
|
};
|
|
1429
1436
|
}
|
|
1430
1437
|
function parseIdToken(state, idToken) {
|
|
1431
|
-
errors_1.assert(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1432
|
-
const decoded = jsonwebtoken_1.decode(idToken, { complete: true });
|
|
1433
|
-
errors_1.assert(decoded, "INVALID_ID_TOKEN");
|
|
1438
|
+
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1439
|
+
const decoded = (0, jsonwebtoken_1.decode)(idToken, { complete: true });
|
|
1440
|
+
(0, errors_1.assert)(decoded, "INVALID_ID_TOKEN");
|
|
1434
1441
|
if (decoded.header.alg !== "none") {
|
|
1435
1442
|
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.AUTH).log("WARN", "Received a signed JWT. Auth Emulator does not validate JWTs and IS NOT SECURE");
|
|
1436
1443
|
}
|
|
1437
1444
|
if (decoded.payload.firebase.tenant) {
|
|
1438
|
-
errors_1.assert(state instanceof state_1.TenantProjectState, "((Parsed token that belongs to tenant in a non-tenant project.))");
|
|
1439
|
-
errors_1.assert(decoded.payload.firebase.tenant === state.tenantId, "TENANT_ID_MISMATCH");
|
|
1445
|
+
(0, errors_1.assert)(state instanceof state_1.TenantProjectState, "((Parsed token that belongs to tenant in a non-tenant project.))");
|
|
1446
|
+
(0, errors_1.assert)(decoded.payload.firebase.tenant === state.tenantId, "TENANT_ID_MISMATCH");
|
|
1440
1447
|
}
|
|
1441
1448
|
const user = state.getUserByLocalId(decoded.payload.user_id);
|
|
1442
|
-
errors_1.assert(user, "USER_NOT_FOUND");
|
|
1443
|
-
errors_1.assert(!user.validSince || decoded.payload.iat >= Number(user.validSince), "TOKEN_EXPIRED");
|
|
1444
|
-
errors_1.assert(!user.disabled, "USER_DISABLED");
|
|
1449
|
+
(0, errors_1.assert)(user, "USER_NOT_FOUND");
|
|
1450
|
+
(0, errors_1.assert)(!user.validSince || decoded.payload.iat >= Number(user.validSince), "TOKEN_EXPIRED");
|
|
1451
|
+
(0, errors_1.assert)(!user.disabled, "USER_DISABLED");
|
|
1445
1452
|
const signInProvider = decoded.payload.firebase.sign_in_provider;
|
|
1446
1453
|
return { user, signInProvider, payload: decoded.payload };
|
|
1447
1454
|
}
|
|
@@ -1462,7 +1469,7 @@ function generateJwt(user, { projectId, signInProvider, expiresInSeconds, extraC
|
|
|
1462
1469
|
}
|
|
1463
1470
|
}
|
|
1464
1471
|
const customAttributes = JSON.parse(user.customAttributes || "{}");
|
|
1465
|
-
const customPayloadFields = Object.assign(Object.assign(Object.assign({ name: user.displayName, picture: user.photoUrl }, customAttributes), extraClaims), { email: user.email, email_verified: user.emailVerified, phone_number: user.phoneNumber, provider_id: signInProvider === "anonymous" ? signInProvider : undefined, auth_time: utils_1.toUnixTimestamp(getAuthTime(user)), user_id: user.localId, firebase: {
|
|
1472
|
+
const customPayloadFields = Object.assign(Object.assign(Object.assign({ name: user.displayName, picture: user.photoUrl }, customAttributes), extraClaims), { email: user.email, email_verified: user.emailVerified, phone_number: user.phoneNumber, provider_id: signInProvider === "anonymous" ? signInProvider : undefined, auth_time: (0, utils_1.toUnixTimestamp)(getAuthTime(user)), user_id: user.localId, firebase: {
|
|
1466
1473
|
identities,
|
|
1467
1474
|
sign_in_provider: signInProvider,
|
|
1468
1475
|
second_factor_identifier: secondFactor === null || secondFactor === void 0 ? void 0 : secondFactor.identifier,
|
|
@@ -1471,7 +1478,7 @@ function generateJwt(user, { projectId, signInProvider, expiresInSeconds, extraC
|
|
|
1471
1478
|
tenant: tenantId,
|
|
1472
1479
|
sign_in_attributes: signInAttributes,
|
|
1473
1480
|
} });
|
|
1474
|
-
const jwtStr = jsonwebtoken_1.sign(customPayloadFields, "", {
|
|
1481
|
+
const jwtStr = (0, jsonwebtoken_1.sign)(customPayloadFields, "", {
|
|
1475
1482
|
algorithm: "none",
|
|
1476
1483
|
expiresIn: expiresInSeconds,
|
|
1477
1484
|
subject: user.localId,
|
|
@@ -1502,14 +1509,14 @@ function getAuthTime(user) {
|
|
|
1502
1509
|
}
|
|
1503
1510
|
function verifyPhoneNumber(state, sessionInfo, code) {
|
|
1504
1511
|
const verification = state.getVerificationCodeBySessionInfo(sessionInfo);
|
|
1505
|
-
errors_1.assert(verification, "INVALID_SESSION_INFO");
|
|
1506
|
-
errors_1.assert(verification.code === code, "INVALID_CODE");
|
|
1512
|
+
(0, errors_1.assert)(verification, "INVALID_SESSION_INFO");
|
|
1513
|
+
(0, errors_1.assert)(verification.code === code, "INVALID_CODE");
|
|
1507
1514
|
state.deleteVerificationCodeBySessionInfo(sessionInfo);
|
|
1508
1515
|
return verification.phoneNumber;
|
|
1509
1516
|
}
|
|
1510
1517
|
const CUSTOM_ATTRIBUTES_MAX_LENGTH = 1000;
|
|
1511
1518
|
function validateSerializedCustomClaims(claims) {
|
|
1512
|
-
errors_1.assert(claims.length <= CUSTOM_ATTRIBUTES_MAX_LENGTH, "CLAIMS_TOO_LARGE");
|
|
1519
|
+
(0, errors_1.assert)(claims.length <= CUSTOM_ATTRIBUTES_MAX_LENGTH, "CLAIMS_TOO_LARGE");
|
|
1513
1520
|
let parsed;
|
|
1514
1521
|
try {
|
|
1515
1522
|
parsed = JSON.parse(claims);
|
|
@@ -1538,14 +1545,14 @@ const FORBIDDEN_CUSTOM_CLAIMS = [
|
|
|
1538
1545
|
"c_hash",
|
|
1539
1546
|
];
|
|
1540
1547
|
function validateCustomClaims(claims) {
|
|
1541
|
-
errors_1.assert(typeof claims === "object" && claims != null && !Array.isArray(claims), "INVALID_CLAIMS");
|
|
1548
|
+
(0, errors_1.assert)(typeof claims === "object" && claims != null && !Array.isArray(claims), "INVALID_CLAIMS");
|
|
1542
1549
|
for (const reservedField of FORBIDDEN_CUSTOM_CLAIMS) {
|
|
1543
|
-
errors_1.assert(!(reservedField in claims), `FORBIDDEN_CLAIM : ${reservedField}`);
|
|
1550
|
+
(0, errors_1.assert)(!(reservedField in claims), `FORBIDDEN_CLAIM : ${reservedField}`);
|
|
1544
1551
|
}
|
|
1545
1552
|
}
|
|
1546
1553
|
function newRandomId(length, existingIds) {
|
|
1547
1554
|
for (let i = 0; i < 10; i++) {
|
|
1548
|
-
const id = utils_1.randomId(length);
|
|
1555
|
+
const id = (0, utils_1.randomId)(length);
|
|
1549
1556
|
if (!(existingIds === null || existingIds === void 0 ? void 0 : existingIds.has(id))) {
|
|
1550
1557
|
return id;
|
|
1551
1558
|
}
|
|
@@ -1557,12 +1564,13 @@ function getMfaEnrollmentsFromRequest(state, request, options) {
|
|
|
1557
1564
|
const phoneNumbers = new Set();
|
|
1558
1565
|
const enrollmentIds = new Set();
|
|
1559
1566
|
for (const enrollment of request) {
|
|
1560
|
-
errors_1.assert(enrollment.phoneInfo && utils_1.isValidPhoneNumber(enrollment.phoneInfo), "INVALID_MFA_PHONE_NUMBER : Invalid format.");
|
|
1567
|
+
(0, errors_1.assert)(enrollment.phoneInfo && (0, utils_1.isValidPhoneNumber)(enrollment.phoneInfo), "INVALID_MFA_PHONE_NUMBER : Invalid format.");
|
|
1561
1568
|
if (!phoneNumbers.has(enrollment.phoneInfo)) {
|
|
1562
|
-
const mfaEnrollmentId = (options === null || options === void 0 ? void 0 : options.generateEnrollmentIds)
|
|
1569
|
+
const mfaEnrollmentId = (options === null || options === void 0 ? void 0 : options.generateEnrollmentIds)
|
|
1570
|
+
? newRandomId(28, enrollmentIds)
|
|
1563
1571
|
: enrollment.mfaEnrollmentId;
|
|
1564
|
-
errors_1.assert(mfaEnrollmentId, "INVALID_MFA_ENROLLMENT_ID : mfaEnrollmentId must be defined.");
|
|
1565
|
-
errors_1.assert(!enrollmentIds.has(mfaEnrollmentId), "DUPLICATE_MFA_ENROLLMENT_ID");
|
|
1572
|
+
(0, errors_1.assert)(mfaEnrollmentId, "INVALID_MFA_ENROLLMENT_ID : mfaEnrollmentId must be defined.");
|
|
1573
|
+
(0, errors_1.assert)(!enrollmentIds.has(mfaEnrollmentId), "DUPLICATE_MFA_ENROLLMENT_ID");
|
|
1566
1574
|
enrollments.push(Object.assign(Object.assign({}, enrollment), { mfaEnrollmentId, unobfuscatedPhoneInfo: enrollment.phoneInfo }));
|
|
1567
1575
|
phoneNumbers.add(enrollment.phoneInfo);
|
|
1568
1576
|
enrollmentIds.add(mfaEnrollmentId);
|
|
@@ -1571,9 +1579,9 @@ function getMfaEnrollmentsFromRequest(state, request, options) {
|
|
|
1571
1579
|
return state.validateMfaEnrollments(enrollments);
|
|
1572
1580
|
}
|
|
1573
1581
|
function getNormalizedUri(reqBody) {
|
|
1574
|
-
errors_1.assert(reqBody.requestUri, "MISSING_REQUEST_URI");
|
|
1575
|
-
const normalizedUri = utils_1.parseAbsoluteUri(reqBody.requestUri);
|
|
1576
|
-
errors_1.assert(normalizedUri, "INVALID_REQUEST_URI");
|
|
1582
|
+
(0, errors_1.assert)(reqBody.requestUri, "MISSING_REQUEST_URI");
|
|
1583
|
+
const normalizedUri = (0, utils_1.parseAbsoluteUri)(reqBody.requestUri);
|
|
1584
|
+
(0, errors_1.assert)(normalizedUri, "INVALID_REQUEST_URI");
|
|
1577
1585
|
if (reqBody.postBody) {
|
|
1578
1586
|
const postBodyParams = new url_1.URLSearchParams(reqBody.postBody);
|
|
1579
1587
|
for (const key of postBodyParams.keys()) {
|
|
@@ -1604,20 +1612,20 @@ function parseClaims(idTokenOrJsonClaims) {
|
|
|
1604
1612
|
}
|
|
1605
1613
|
}
|
|
1606
1614
|
else {
|
|
1607
|
-
const decoded = jsonwebtoken_1.decode(idTokenOrJsonClaims, { json: true });
|
|
1615
|
+
const decoded = (0, jsonwebtoken_1.decode)(idTokenOrJsonClaims, { json: true });
|
|
1608
1616
|
if (!decoded) {
|
|
1609
1617
|
return undefined;
|
|
1610
1618
|
}
|
|
1611
1619
|
claims = decoded;
|
|
1612
1620
|
}
|
|
1613
|
-
errors_1.assert(claims.sub, 'INVALID_IDP_RESPONSE : Invalid Idp Response: id_token missing required fields. ((Missing "sub" field. This field is required and must be a unique identifier.))');
|
|
1614
|
-
errors_1.assert(typeof claims.sub === "string", 'INVALID_IDP_RESPONSE : ((The "sub" field must be a string.))');
|
|
1621
|
+
(0, errors_1.assert)(claims.sub, 'INVALID_IDP_RESPONSE : Invalid Idp Response: id_token missing required fields. ((Missing "sub" field. This field is required and must be a unique identifier.))');
|
|
1622
|
+
(0, errors_1.assert)(typeof claims.sub === "string", 'INVALID_IDP_RESPONSE : ((The "sub" field must be a string.))');
|
|
1615
1623
|
return claims;
|
|
1616
1624
|
}
|
|
1617
1625
|
function fakeFetchUserInfoFromIdp(providerId, claims, samlResponse) {
|
|
1618
1626
|
var _a, _b, _c, _d, _e;
|
|
1619
1627
|
const rawId = claims.sub;
|
|
1620
|
-
const email = claims.email ? utils_1.canonicalizeEmailAddress(claims.email) : undefined;
|
|
1628
|
+
const email = claims.email ? (0, utils_1.canonicalizeEmailAddress)(claims.email) : undefined;
|
|
1621
1629
|
const emailVerified = !!claims.email_verified;
|
|
1622
1630
|
const displayName = claims.name;
|
|
1623
1631
|
const photoUrl = claims.picture;
|
|
@@ -1657,7 +1665,7 @@ function fakeFetchUserInfoFromIdp(providerId, claims, samlResponse) {
|
|
|
1657
1665
|
}
|
|
1658
1666
|
case (_a = providerId.match(/^saml\./)) === null || _a === void 0 ? void 0 : _a.input:
|
|
1659
1667
|
const nameId = (_c = (_b = samlResponse === null || samlResponse === void 0 ? void 0 : samlResponse.assertion) === null || _b === void 0 ? void 0 : _b.subject) === null || _c === void 0 ? void 0 : _c.nameId;
|
|
1660
|
-
response.email = nameId && utils_1.isValidEmailAddress(nameId) ? nameId : response.email;
|
|
1668
|
+
response.email = nameId && (0, utils_1.isValidEmailAddress)(nameId) ? nameId : response.email;
|
|
1661
1669
|
response.emailVerified = true;
|
|
1662
1670
|
response.rawUserInfo = JSON.stringify((_d = samlResponse === null || samlResponse === void 0 ? void 0 : samlResponse.assertion) === null || _d === void 0 ? void 0 : _d.attributeStatements);
|
|
1663
1671
|
break;
|
|
@@ -1672,7 +1680,7 @@ function fakeFetchUserInfoFromIdp(providerId, claims, samlResponse) {
|
|
|
1672
1680
|
function handleLinkIdp(state, response, userFromIdToken) {
|
|
1673
1681
|
if (state.oneAccountPerEmail && response.email) {
|
|
1674
1682
|
const userMatchingEmail = state.getUserByEmail(response.email);
|
|
1675
|
-
errors_1.assert(!userMatchingEmail || userMatchingEmail.localId === userFromIdToken.localId, "EMAIL_EXISTS");
|
|
1683
|
+
(0, errors_1.assert)(!userMatchingEmail || userMatchingEmail.localId === userFromIdToken.localId, "EMAIL_EXISTS");
|
|
1676
1684
|
}
|
|
1677
1685
|
response.localId = userFromIdToken.localId;
|
|
1678
1686
|
const fields = {};
|
|
@@ -1718,7 +1726,7 @@ function handleIdpSigninEmailRequired(response, rawId, userMatchingProvider, use
|
|
|
1718
1726
|
if (!userMatchingEmail.emailVerified) {
|
|
1719
1727
|
accountUpdates.fields.passwordHash = undefined;
|
|
1720
1728
|
accountUpdates.fields.phoneNumber = undefined;
|
|
1721
|
-
accountUpdates.fields.validSince = utils_1.toUnixTimestamp(new Date()).toString();
|
|
1729
|
+
accountUpdates.fields.validSince = (0, utils_1.toUnixTimestamp)(new Date()).toString();
|
|
1722
1730
|
accountUpdates.deleteProviders = (_b = userMatchingEmail.providerUserInfo) === null || _b === void 0 ? void 0 : _b.map((info) => info.providerId);
|
|
1723
1731
|
}
|
|
1724
1732
|
accountUpdates.fields.dateOfBirth = response.dateOfBirth;
|
|
@@ -1805,16 +1813,16 @@ function parsePendingCredential(state, pendingCredential) {
|
|
|
1805
1813
|
pendingCredentialPayload = JSON.parse(json);
|
|
1806
1814
|
}
|
|
1807
1815
|
catch (_a) {
|
|
1808
|
-
errors_1.assert(false, "((Invalid phoneVerificationInfo.mfaPendingCredential.))");
|
|
1816
|
+
(0, errors_1.assert)(false, "((Invalid phoneVerificationInfo.mfaPendingCredential.))");
|
|
1809
1817
|
}
|
|
1810
|
-
errors_1.assert(pendingCredentialPayload._AuthEmulatorMfaPendingCredential, "((Invalid phoneVerificationInfo.mfaPendingCredential.))");
|
|
1811
|
-
errors_1.assert(pendingCredentialPayload.projectId === state.projectId, "INVALID_PROJECT_ID : Project ID does not match MFA pending credential.");
|
|
1818
|
+
(0, errors_1.assert)(pendingCredentialPayload._AuthEmulatorMfaPendingCredential, "((Invalid phoneVerificationInfo.mfaPendingCredential.))");
|
|
1819
|
+
(0, errors_1.assert)(pendingCredentialPayload.projectId === state.projectId, "INVALID_PROJECT_ID : Project ID does not match MFA pending credential.");
|
|
1812
1820
|
if (state instanceof state_1.TenantProjectState) {
|
|
1813
|
-
errors_1.assert(pendingCredentialPayload.tenantId === state.tenantId, "INVALID_PROJECT_ID : Project ID does not match MFA pending credential.");
|
|
1821
|
+
(0, errors_1.assert)(pendingCredentialPayload.tenantId === state.tenantId, "INVALID_PROJECT_ID : Project ID does not match MFA pending credential.");
|
|
1814
1822
|
}
|
|
1815
1823
|
const { localId, signInProvider } = pendingCredentialPayload;
|
|
1816
1824
|
const user = state.getUserByLocalId(localId);
|
|
1817
|
-
errors_1.assert(user, "((User in pendingCredentialPayload does not exist.))");
|
|
1825
|
+
(0, errors_1.assert)(user, "((User in pendingCredentialPayload does not exist.))");
|
|
1818
1826
|
return { user, signInProvider };
|
|
1819
1827
|
}
|
|
1820
1828
|
function createTenant(state, reqBody) {
|
|
@@ -1841,7 +1849,7 @@ function createTenant(state, reqBody) {
|
|
|
1841
1849
|
return state.createTenant(tenant);
|
|
1842
1850
|
}
|
|
1843
1851
|
function listTenants(state, reqBody, ctx) {
|
|
1844
|
-
errors_1.assert(state instanceof state_1.AgentProjectState, "((Can only list tenants in agent project.))");
|
|
1852
|
+
(0, errors_1.assert)(state instanceof state_1.AgentProjectState, "((Can only list tenants in agent project.))");
|
|
1845
1853
|
const pageSize = Math.min(Math.floor(ctx.params.query.pageSize) || 20, 1000);
|
|
1846
1854
|
const tenants = state.listTenants(ctx.params.query.pageToken);
|
|
1847
1855
|
let nextPageToken = undefined;
|
|
@@ -1855,15 +1863,15 @@ function listTenants(state, reqBody, ctx) {
|
|
|
1855
1863
|
};
|
|
1856
1864
|
}
|
|
1857
1865
|
function deleteTenant(state, reqBody, ctx) {
|
|
1858
|
-
errors_1.assert(state instanceof state_1.TenantProjectState, "((Can only delete tenant on tenant projects.))");
|
|
1866
|
+
(0, errors_1.assert)(state instanceof state_1.TenantProjectState, "((Can only delete tenant on tenant projects.))");
|
|
1859
1867
|
state.delete();
|
|
1860
1868
|
return {};
|
|
1861
1869
|
}
|
|
1862
1870
|
function getTenant(state, reqBody, ctx) {
|
|
1863
|
-
errors_1.assert(state instanceof state_1.TenantProjectState, "((Can only get tenant on tenant projects.))");
|
|
1871
|
+
(0, errors_1.assert)(state instanceof state_1.TenantProjectState, "((Can only get tenant on tenant projects.))");
|
|
1864
1872
|
return state.tenantConfig;
|
|
1865
1873
|
}
|
|
1866
1874
|
function updateTenant(state, reqBody, ctx) {
|
|
1867
|
-
errors_1.assert(state instanceof state_1.TenantProjectState, "((Can only update tenant on tenant projects.))");
|
|
1875
|
+
(0, errors_1.assert)(state instanceof state_1.TenantProjectState, "((Can only update tenant on tenant projects.))");
|
|
1868
1876
|
return state.updateTenant(reqBody, ctx.params.query.updateMask);
|
|
1869
1877
|
}
|