@budibase/backend-core 2.13.14 → 2.13.15
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/dist/index.js +56 -24
- package/dist/index.js.map +2 -2
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/src/auth/auth.js.map +1 -1
- package/dist/src/configs/configs.js +3 -4
- package/dist/src/configs/configs.js.map +1 -1
- package/dist/src/constants/db.js.map +1 -1
- package/dist/src/db/utils.js.map +1 -1
- package/dist/src/docIds/conversions.js.map +1 -1
- package/dist/src/events/processors/posthog/index.js.map +1 -1
- package/dist/src/features/index.js.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/installation.js +2 -3
- package/dist/src/installation.js.map +1 -1
- package/dist/src/logging/correlation/correlation.js.map +1 -1
- package/dist/src/logging/correlation/middleware.js.map +1 -1
- package/dist/src/logging/pino/middleware.js.map +1 -1
- package/dist/src/middleware/index.js.map +1 -1
- package/dist/src/middleware/passport/sso/google.js.map +1 -1
- package/dist/src/objectStore/objectStore.js.map +1 -1
- package/dist/src/security/roles.js +1 -2
- package/dist/src/security/roles.js.map +1 -1
- package/dist/src/security/sessions.js.map +1 -1
- package/dist/src/users/db.d.ts +5 -0
- package/dist/src/users/db.js +28 -2
- package/dist/src/users/db.js.map +1 -1
- package/dist/src/users/users.d.ts +12 -11
- package/dist/src/users/users.js +175 -144
- package/dist/src/users/users.js.map +1 -1
- package/dist/src/utils/hashing.js.map +1 -1
- package/dist/src/utils/utils.js.map +1 -1
- package/dist/tests/core/utilities/mocks/alerts.js.map +1 -1
- package/dist/tests/core/utilities/mocks/index.js.map +1 -1
- package/dist/tests/core/utilities/structures/generator.js.map +1 -1
- package/dist/tests/jestSetup.js.map +1 -1
- package/package.json +4 -4
- package/src/auth/auth.ts +2 -0
- package/src/configs/configs.ts +3 -4
- package/src/constants/db.ts +1 -0
- package/src/db/utils.ts +1 -0
- package/src/docIds/conversions.ts +1 -0
- package/src/events/processors/posthog/index.ts +1 -0
- package/src/events/processors/posthog/tests/PosthogProcessor.spec.ts +2 -0
- package/src/features/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/installation.ts +1 -2
- package/src/logging/correlation/correlation.ts +1 -0
- package/src/logging/correlation/middleware.ts +1 -0
- package/src/logging/pino/middleware.ts +3 -0
- package/src/middleware/index.ts +1 -0
- package/src/middleware/passport/sso/google.ts +1 -0
- package/src/middleware/passport/sso/tests/google.spec.ts +1 -0
- package/src/middleware/passport/sso/tests/sso.spec.ts +1 -0
- package/src/middleware/tests/builder.spec.ts +1 -0
- package/src/objectStore/objectStore.ts +1 -0
- package/src/security/roles.ts +7 -2
- package/src/security/sessions.ts +1 -0
- package/src/users/db.ts +33 -5
- package/src/users/users.ts +28 -16
- package/src/utils/hashing.ts +1 -0
- package/src/utils/utils.ts +1 -0
- package/tests/core/utilities/mocks/alerts.ts +1 -0
- package/tests/core/utilities/mocks/index.ts +1 -0
- package/tests/core/utilities/structures/generator.ts +1 -0
- package/tests/jestSetup.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -6675,6 +6675,7 @@ __export(users_exports3, {
|
|
|
6675
6675
|
bulkGetGlobalUsersById: () => bulkGetGlobalUsersById,
|
|
6676
6676
|
bulkUpdateGlobalUsers: () => bulkUpdateGlobalUsers,
|
|
6677
6677
|
cleanseUserObject: () => cleanseUserObject,
|
|
6678
|
+
doesUserExist: () => doesUserExist,
|
|
6678
6679
|
getAccountHolderFromUserIds: () => getAccountHolderFromUserIds,
|
|
6679
6680
|
getAllUserIds: () => getAllUserIds,
|
|
6680
6681
|
getById: () => getById,
|
|
@@ -7492,7 +7493,7 @@ function removeUserPassword(users) {
|
|
|
7492
7493
|
}
|
|
7493
7494
|
return users;
|
|
7494
7495
|
}
|
|
7495
|
-
|
|
7496
|
+
function isSupportedUserSearch(query) {
|
|
7496
7497
|
const allowed = [
|
|
7497
7498
|
{ op: "string" /* STRING */, key: "email" },
|
|
7498
7499
|
{ op: "equal" /* EQUAL */, key: "_id" }
|
|
@@ -7513,8 +7514,8 @@ var isSupportedUserSearch = (query) => {
|
|
|
7513
7514
|
}
|
|
7514
7515
|
}
|
|
7515
7516
|
return true;
|
|
7516
|
-
}
|
|
7517
|
-
|
|
7517
|
+
}
|
|
7518
|
+
async function bulkGetGlobalUsersById(userIds, opts) {
|
|
7518
7519
|
const db = getGlobalDB();
|
|
7519
7520
|
let users = (await db.allDocs({
|
|
7520
7521
|
keys: userIds,
|
|
@@ -7524,8 +7525,8 @@ var bulkGetGlobalUsersById = async (userIds, opts) => {
|
|
|
7524
7525
|
users = removeUserPassword(users);
|
|
7525
7526
|
}
|
|
7526
7527
|
return users;
|
|
7527
|
-
}
|
|
7528
|
-
|
|
7528
|
+
}
|
|
7529
|
+
async function getAllUserIds() {
|
|
7529
7530
|
const db = getGlobalDB();
|
|
7530
7531
|
const startKey = `${"us" /* USER */}${SEPARATOR}`;
|
|
7531
7532
|
const response = await db.allDocs({
|
|
@@ -7533,11 +7534,11 @@ var getAllUserIds = async () => {
|
|
|
7533
7534
|
endkey: `${startKey}${UNICODE_MAX}`
|
|
7534
7535
|
});
|
|
7535
7536
|
return response.rows.map((row) => row.id);
|
|
7536
|
-
}
|
|
7537
|
-
|
|
7537
|
+
}
|
|
7538
|
+
async function bulkUpdateGlobalUsers(users) {
|
|
7538
7539
|
const db = getGlobalDB();
|
|
7539
7540
|
return await db.bulkDocs(users);
|
|
7540
|
-
}
|
|
7541
|
+
}
|
|
7541
7542
|
async function getById(id, opts) {
|
|
7542
7543
|
const db = getGlobalDB();
|
|
7543
7544
|
let user = await db.get(id);
|
|
@@ -7546,7 +7547,7 @@ async function getById(id, opts) {
|
|
|
7546
7547
|
}
|
|
7547
7548
|
return user;
|
|
7548
7549
|
}
|
|
7549
|
-
|
|
7550
|
+
async function getGlobalUserByEmail(email, opts) {
|
|
7550
7551
|
if (email == null) {
|
|
7551
7552
|
throw "Must supply an email address to view";
|
|
7552
7553
|
}
|
|
@@ -7562,8 +7563,19 @@ var getGlobalUserByEmail = async (email, opts) => {
|
|
|
7562
7563
|
user = removeUserPassword(user);
|
|
7563
7564
|
}
|
|
7564
7565
|
return user;
|
|
7565
|
-
}
|
|
7566
|
-
|
|
7566
|
+
}
|
|
7567
|
+
async function doesUserExist(email) {
|
|
7568
|
+
try {
|
|
7569
|
+
const user = await getGlobalUserByEmail(email);
|
|
7570
|
+
if (Array.isArray(user) || user != null) {
|
|
7571
|
+
return true;
|
|
7572
|
+
}
|
|
7573
|
+
} catch (err) {
|
|
7574
|
+
return false;
|
|
7575
|
+
}
|
|
7576
|
+
return false;
|
|
7577
|
+
}
|
|
7578
|
+
async function searchGlobalUsersByApp(appId, opts, getOpts) {
|
|
7567
7579
|
if (typeof appId !== "string") {
|
|
7568
7580
|
throw new Error("Must provide a string based app ID");
|
|
7569
7581
|
}
|
|
@@ -7580,8 +7592,8 @@ var searchGlobalUsersByApp = async (appId, opts, getOpts) => {
|
|
|
7580
7592
|
users = removeUserPassword(users);
|
|
7581
7593
|
}
|
|
7582
7594
|
return users;
|
|
7583
|
-
}
|
|
7584
|
-
|
|
7595
|
+
}
|
|
7596
|
+
async function searchGlobalUsersByAppAccess(appId, opts) {
|
|
7585
7597
|
const roleSelector = `roles.${appId}`;
|
|
7586
7598
|
let orQuery = [
|
|
7587
7599
|
{
|
|
@@ -7610,14 +7622,14 @@ var searchGlobalUsersByAppAccess = async (appId, opts) => {
|
|
|
7610
7622
|
};
|
|
7611
7623
|
const resp = await directCouchFind(getGlobalDBName(), searchOptions);
|
|
7612
7624
|
return resp.rows;
|
|
7613
|
-
}
|
|
7614
|
-
|
|
7625
|
+
}
|
|
7626
|
+
function getGlobalUserByAppPage(appId, user) {
|
|
7615
7627
|
if (!user) {
|
|
7616
7628
|
return;
|
|
7617
7629
|
}
|
|
7618
7630
|
return generateAppUserID(getProdAppID(appId), user._id);
|
|
7619
|
-
}
|
|
7620
|
-
|
|
7631
|
+
}
|
|
7632
|
+
async function searchGlobalUsersByEmail(email, opts, getOpts) {
|
|
7621
7633
|
if (typeof email !== "string") {
|
|
7622
7634
|
throw new Error("Must provide a string to search by");
|
|
7623
7635
|
}
|
|
@@ -7636,14 +7648,14 @@ var searchGlobalUsersByEmail = async (email, opts, getOpts) => {
|
|
|
7636
7648
|
users = removeUserPassword(users);
|
|
7637
7649
|
}
|
|
7638
7650
|
return users;
|
|
7639
|
-
}
|
|
7651
|
+
}
|
|
7640
7652
|
var PAGE_LIMIT = 8;
|
|
7641
|
-
|
|
7653
|
+
async function paginatedUsers({
|
|
7642
7654
|
bookmark,
|
|
7643
7655
|
query,
|
|
7644
7656
|
appId,
|
|
7645
7657
|
limit
|
|
7646
|
-
} = {})
|
|
7658
|
+
} = {}) {
|
|
7647
7659
|
const db = getGlobalDB();
|
|
7648
7660
|
const pageSize = limit ?? PAGE_LIMIT;
|
|
7649
7661
|
const pageLimit = pageSize + 1;
|
|
@@ -7672,7 +7684,7 @@ var paginatedUsers = async ({
|
|
|
7672
7684
|
property,
|
|
7673
7685
|
getKey
|
|
7674
7686
|
});
|
|
7675
|
-
}
|
|
7687
|
+
}
|
|
7676
7688
|
async function getUserCount() {
|
|
7677
7689
|
const response = await queryGlobalViewRaw("by_email2" /* USER_BY_EMAIL */, {
|
|
7678
7690
|
limit: 0,
|
|
@@ -8425,7 +8437,6 @@ __export(installation_exports, {
|
|
|
8425
8437
|
getInstallFromDB: () => getInstallFromDB
|
|
8426
8438
|
});
|
|
8427
8439
|
init_db4();
|
|
8428
|
-
init_db4();
|
|
8429
8440
|
init_src();
|
|
8430
8441
|
init_context2();
|
|
8431
8442
|
var import_semver = __toESM(require("semver"));
|
|
@@ -10697,6 +10708,29 @@ var UserDB = class _UserDB {
|
|
|
10697
10708
|
await user_exports.invalidateUser(userId);
|
|
10698
10709
|
await invalidateSessions(userId, { reason: "deletion" });
|
|
10699
10710
|
}
|
|
10711
|
+
static async createAdminUser(email, password, tenantId, opts) {
|
|
10712
|
+
const user = {
|
|
10713
|
+
email,
|
|
10714
|
+
password,
|
|
10715
|
+
createdAt: Date.now(),
|
|
10716
|
+
roles: {},
|
|
10717
|
+
builder: {
|
|
10718
|
+
global: true
|
|
10719
|
+
},
|
|
10720
|
+
admin: {
|
|
10721
|
+
global: true
|
|
10722
|
+
},
|
|
10723
|
+
tenantId
|
|
10724
|
+
};
|
|
10725
|
+
if (opts?.ssoId) {
|
|
10726
|
+
user.ssoId = opts.ssoId;
|
|
10727
|
+
}
|
|
10728
|
+
await bustCache("checklist" /* CHECKLIST */);
|
|
10729
|
+
return await _UserDB.save(user, {
|
|
10730
|
+
hashPassword: opts?.hashPassword,
|
|
10731
|
+
requirePassword: opts?.requirePassword
|
|
10732
|
+
});
|
|
10733
|
+
}
|
|
10700
10734
|
static async getGroups(groupIds) {
|
|
10701
10735
|
return await this.groups.getBulk(groupIds);
|
|
10702
10736
|
}
|
|
@@ -10934,7 +10968,6 @@ async function getCode2(code) {
|
|
|
10934
10968
|
// src/configs/configs.ts
|
|
10935
10969
|
init_context2();
|
|
10936
10970
|
init_environment2();
|
|
10937
|
-
init_environment2();
|
|
10938
10971
|
function generateConfigID(type) {
|
|
10939
10972
|
return `${"config" /* CONFIG */}${SEPARATOR}${type}`;
|
|
10940
10973
|
}
|
|
@@ -11446,7 +11479,6 @@ var GLOBAL_BUILDER = "globalBuilder" /* GLOBAL_BUILDER */;
|
|
|
11446
11479
|
// src/security/roles.ts
|
|
11447
11480
|
init_db4();
|
|
11448
11481
|
init_context2();
|
|
11449
|
-
init_db4();
|
|
11450
11482
|
var import_cloneDeep2 = __toESM(require("lodash/fp/cloneDeep"));
|
|
11451
11483
|
var BUILTIN_ROLE_IDS = {
|
|
11452
11484
|
ADMIN: "ADMIN",
|