@budibase/backend-core 3.2.4 → 3.2.6
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.map +1 -1
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +11 -4
- package/dist/plugins.js.meta.json +1 -1
- package/package.json +11 -4
- package/src/accounts/accounts.ts +0 -82
- package/src/accounts/api.ts +0 -59
- package/src/accounts/index.ts +0 -1
- package/src/auth/auth.ts +0 -210
- package/src/auth/index.ts +0 -1
- package/src/auth/tests/auth.spec.ts +0 -14
- package/src/blacklist/blacklist.ts +0 -54
- package/src/blacklist/index.ts +0 -1
- package/src/blacklist/tests/blacklist.spec.ts +0 -46
- package/src/cache/appMetadata.ts +0 -88
- package/src/cache/base/index.ts +0 -150
- package/src/cache/docWritethrough.ts +0 -105
- package/src/cache/generic.ts +0 -33
- package/src/cache/index.ts +0 -8
- package/src/cache/invite.ts +0 -86
- package/src/cache/passwordReset.ts +0 -49
- package/src/cache/tests/docWritethrough.spec.ts +0 -296
- package/src/cache/tests/user.spec.ts +0 -145
- package/src/cache/tests/writethrough.spec.ts +0 -139
- package/src/cache/user.ts +0 -154
- package/src/cache/writethrough.ts +0 -133
- package/src/configs/configs.ts +0 -263
- package/src/configs/index.ts +0 -1
- package/src/configs/tests/configs.spec.ts +0 -184
- package/src/constants/db.ts +0 -75
- package/src/constants/index.ts +0 -2
- package/src/constants/misc.ts +0 -36
- package/src/context/Context.ts +0 -14
- package/src/context/identity.ts +0 -58
- package/src/context/index.ts +0 -3
- package/src/context/mainContext.ts +0 -422
- package/src/context/tests/index.spec.ts +0 -255
- package/src/context/types.ts +0 -26
- package/src/db/Replication.ts +0 -94
- package/src/db/couch/DatabaseImpl.ts +0 -511
- package/src/db/couch/connections.ts +0 -89
- package/src/db/couch/index.ts +0 -4
- package/src/db/couch/pouchDB.ts +0 -97
- package/src/db/couch/pouchDump.ts +0 -0
- package/src/db/couch/tests/DatabaseImpl.spec.ts +0 -118
- package/src/db/couch/utils.ts +0 -55
- package/src/db/db.ts +0 -34
- package/src/db/errors.ts +0 -14
- package/src/db/index.ts +0 -12
- package/src/db/instrumentation.ts +0 -199
- package/src/db/lucene.ts +0 -721
- package/src/db/searchIndexes/index.ts +0 -1
- package/src/db/searchIndexes/searchIndexes.ts +0 -62
- package/src/db/tests/DatabaseImpl.spec.ts +0 -55
- package/src/db/tests/connections.spec.ts +0 -22
- package/src/db/tests/index.spec.ts +0 -32
- package/src/db/tests/lucene.spec.ts +0 -400
- package/src/db/tests/pouch.spec.js +0 -62
- package/src/db/tests/utils.spec.ts +0 -63
- package/src/db/utils.ts +0 -208
- package/src/db/views.ts +0 -245
- package/src/docIds/conversions.ts +0 -60
- package/src/docIds/ids.ts +0 -126
- package/src/docIds/index.ts +0 -2
- package/src/docIds/newid.ts +0 -5
- package/src/docIds/params.ts +0 -189
- package/src/docUpdates/index.ts +0 -24
- package/src/environment.ts +0 -293
- package/src/errors/errors.ts +0 -119
- package/src/errors/index.ts +0 -1
- package/src/events/analytics.ts +0 -6
- package/src/events/asyncEvents/index.ts +0 -2
- package/src/events/asyncEvents/publisher.ts +0 -12
- package/src/events/asyncEvents/queue.ts +0 -22
- package/src/events/backfill.ts +0 -183
- package/src/events/documentId.ts +0 -56
- package/src/events/events.ts +0 -47
- package/src/events/identification.ts +0 -311
- package/src/events/index.ts +0 -15
- package/src/events/processors/AnalyticsProcessor.ts +0 -64
- package/src/events/processors/AuditLogsProcessor.ts +0 -92
- package/src/events/processors/LoggingProcessor.ts +0 -36
- package/src/events/processors/Processors.ts +0 -52
- package/src/events/processors/async/DocumentUpdateProcessor.ts +0 -38
- package/src/events/processors/index.ts +0 -19
- package/src/events/processors/posthog/PosthogProcessor.ts +0 -118
- package/src/events/processors/posthog/index.ts +0 -3
- package/src/events/processors/posthog/rateLimiting.ts +0 -106
- package/src/events/processors/posthog/tests/PosthogProcessor.spec.ts +0 -164
- package/src/events/processors/types.ts +0 -1
- package/src/events/publishers/account.ts +0 -41
- package/src/events/publishers/ai.ts +0 -21
- package/src/events/publishers/app.ts +0 -168
- package/src/events/publishers/auditLog.ts +0 -26
- package/src/events/publishers/auth.ts +0 -73
- package/src/events/publishers/automation.ts +0 -110
- package/src/events/publishers/backfill.ts +0 -74
- package/src/events/publishers/backup.ts +0 -42
- package/src/events/publishers/datasource.ts +0 -48
- package/src/events/publishers/email.ts +0 -17
- package/src/events/publishers/environmentVariable.ts +0 -38
- package/src/events/publishers/group.ts +0 -99
- package/src/events/publishers/index.ts +0 -25
- package/src/events/publishers/installation.ts +0 -38
- package/src/events/publishers/layout.ts +0 -26
- package/src/events/publishers/license.ts +0 -84
- package/src/events/publishers/org.ts +0 -37
- package/src/events/publishers/plugin.ts +0 -47
- package/src/events/publishers/query.ts +0 -89
- package/src/events/publishers/role.ts +0 -62
- package/src/events/publishers/rows.ts +0 -29
- package/src/events/publishers/screen.ts +0 -36
- package/src/events/publishers/serve.ts +0 -43
- package/src/events/publishers/table.ts +0 -70
- package/src/events/publishers/user.ts +0 -202
- package/src/events/publishers/view.ts +0 -107
- package/src/features/features.ts +0 -277
- package/src/features/index.ts +0 -2
- package/src/features/tests/features.spec.ts +0 -267
- package/src/features/tests/utils.ts +0 -64
- package/src/helpers.ts +0 -9
- package/src/index.ts +0 -59
- package/src/installation.ts +0 -115
- package/src/logging/alerts.ts +0 -26
- package/src/logging/correlation/correlation.ts +0 -15
- package/src/logging/correlation/index.ts +0 -1
- package/src/logging/correlation/middleware.ts +0 -18
- package/src/logging/index.ts +0 -4
- package/src/logging/pino/logger.ts +0 -239
- package/src/logging/pino/middleware.ts +0 -48
- package/src/logging/system.ts +0 -81
- package/src/logging/tests/system.spec.ts +0 -61
- package/src/middleware/adminOnly.ts +0 -9
- package/src/middleware/auditLog.ts +0 -6
- package/src/middleware/authenticated.ts +0 -247
- package/src/middleware/builderOnly.ts +0 -21
- package/src/middleware/builderOrAdmin.ts +0 -21
- package/src/middleware/contentSecurityPolicy.ts +0 -113
- package/src/middleware/csrf.ts +0 -81
- package/src/middleware/errorHandling.ts +0 -43
- package/src/middleware/index.ts +0 -24
- package/src/middleware/internalApi.ts +0 -23
- package/src/middleware/ip.ts +0 -12
- package/src/middleware/joi-validator.ts +0 -58
- package/src/middleware/matchers.ts +0 -39
- package/src/middleware/passport/datasource/google.ts +0 -102
- package/src/middleware/passport/local.ts +0 -54
- package/src/middleware/passport/sso/google.ts +0 -77
- package/src/middleware/passport/sso/oidc.ts +0 -152
- package/src/middleware/passport/sso/sso.ts +0 -138
- package/src/middleware/passport/sso/tests/google.spec.ts +0 -68
- package/src/middleware/passport/sso/tests/oidc.spec.ts +0 -144
- package/src/middleware/passport/sso/tests/sso.spec.ts +0 -197
- package/src/middleware/passport/utils.ts +0 -38
- package/src/middleware/querystringToBody.ts +0 -28
- package/src/middleware/tenancy.ts +0 -36
- package/src/middleware/tests/builder.spec.ts +0 -181
- package/src/middleware/tests/contentSecurityPolicy.spec.ts +0 -75
- package/src/middleware/tests/matchers.spec.ts +0 -100
- package/src/migrations/definitions.ts +0 -40
- package/src/migrations/index.ts +0 -2
- package/src/migrations/migrations.ts +0 -186
- package/src/migrations/tests/__snapshots__/migrations.spec.ts.snap +0 -11
- package/src/migrations/tests/migrations.spec.ts +0 -64
- package/src/objectStore/buckets/app.ts +0 -53
- package/src/objectStore/buckets/global.ts +0 -29
- package/src/objectStore/buckets/index.ts +0 -3
- package/src/objectStore/buckets/plugins.ts +0 -71
- package/src/objectStore/buckets/tests/app.spec.ts +0 -161
- package/src/objectStore/buckets/tests/global.spec.ts +0 -74
- package/src/objectStore/buckets/tests/plugins.spec.ts +0 -111
- package/src/objectStore/cloudfront.ts +0 -41
- package/src/objectStore/index.ts +0 -3
- package/src/objectStore/objectStore.ts +0 -585
- package/src/objectStore/utils.ts +0 -113
- package/src/platform/index.ts +0 -3
- package/src/platform/platformDb.ts +0 -6
- package/src/platform/tenants.ts +0 -101
- package/src/platform/tests/tenants.spec.ts +0 -26
- package/src/platform/users.ts +0 -129
- package/src/plugin/index.ts +0 -1
- package/src/plugin/tests/validation.spec.ts +0 -209
- package/src/plugin/utils.ts +0 -175
- package/src/queue/constants.ts +0 -8
- package/src/queue/inMemoryQueue.ts +0 -189
- package/src/queue/index.ts +0 -2
- package/src/queue/listeners.ts +0 -199
- package/src/queue/queue.ts +0 -84
- package/src/redis/index.ts +0 -6
- package/src/redis/init.ts +0 -118
- package/src/redis/redis.ts +0 -358
- package/src/redis/redlockImpl.ts +0 -155
- package/src/redis/tests/redis.spec.ts +0 -207
- package/src/redis/tests/redlockImpl.spec.ts +0 -105
- package/src/redis/utils.ts +0 -128
- package/src/security/auth.ts +0 -24
- package/src/security/encryption.ts +0 -185
- package/src/security/index.ts +0 -1
- package/src/security/permissions.ts +0 -166
- package/src/security/roles.ts +0 -655
- package/src/security/secrets.ts +0 -20
- package/src/security/sessions.ts +0 -123
- package/src/security/tests/auth.spec.ts +0 -45
- package/src/security/tests/encryption.spec.ts +0 -31
- package/src/security/tests/permissions.spec.ts +0 -146
- package/src/security/tests/secrets.spec.ts +0 -35
- package/src/security/tests/sessions.spec.ts +0 -12
- package/src/sql/designDoc.ts +0 -17
- package/src/sql/index.ts +0 -5
- package/src/sql/sql.ts +0 -1854
- package/src/sql/sqlTable.ts +0 -319
- package/src/sql/utils.ts +0 -193
- package/src/tenancy/db.ts +0 -6
- package/src/tenancy/index.ts +0 -2
- package/src/tenancy/tenancy.ts +0 -148
- package/src/tenancy/tests/tenancy.spec.ts +0 -184
- package/src/timers/index.ts +0 -1
- package/src/timers/timers.ts +0 -22
- package/src/users/db.ts +0 -582
- package/src/users/events.ts +0 -176
- package/src/users/index.ts +0 -4
- package/src/users/lookup.ts +0 -99
- package/src/users/test/db.spec.ts +0 -188
- package/src/users/test/utils.spec.ts +0 -67
- package/src/users/users.ts +0 -353
- package/src/users/utils.ts +0 -81
- package/src/utils/Duration.ts +0 -56
- package/src/utils/hashing.ts +0 -15
- package/src/utils/index.ts +0 -4
- package/src/utils/stringUtils.ts +0 -8
- package/src/utils/tests/Duration.spec.ts +0 -19
- package/src/utils/tests/utils.spec.ts +0 -204
- package/src/utils/utils.ts +0 -249
- package/tests/core/logging.ts +0 -34
- package/tests/core/users/users.spec.js +0 -53
- package/tests/core/utilities/index.ts +0 -7
- package/tests/core/utilities/jestUtils.ts +0 -33
- package/tests/core/utilities/mocks/alerts.ts +0 -4
- package/tests/core/utilities/mocks/date.ts +0 -3
- package/tests/core/utilities/mocks/events.ts +0 -132
- package/tests/core/utilities/mocks/index.ts +0 -9
- package/tests/core/utilities/mocks/licenses.ts +0 -119
- package/tests/core/utilities/queue.ts +0 -9
- package/tests/core/utilities/structures/Chance.ts +0 -20
- package/tests/core/utilities/structures/accounts.ts +0 -80
- package/tests/core/utilities/structures/apps.ts +0 -21
- package/tests/core/utilities/structures/common.ts +0 -7
- package/tests/core/utilities/structures/db.ts +0 -12
- package/tests/core/utilities/structures/documents/index.ts +0 -1
- package/tests/core/utilities/structures/documents/platform/index.ts +0 -1
- package/tests/core/utilities/structures/documents/platform/installation.ts +0 -12
- package/tests/core/utilities/structures/generator.ts +0 -3
- package/tests/core/utilities/structures/index.ts +0 -15
- package/tests/core/utilities/structures/koa.ts +0 -16
- package/tests/core/utilities/structures/licenses.ts +0 -190
- package/tests/core/utilities/structures/plugins.ts +0 -19
- package/tests/core/utilities/structures/quotas.ts +0 -72
- package/tests/core/utilities/structures/scim.ts +0 -80
- package/tests/core/utilities/structures/sso.ts +0 -118
- package/tests/core/utilities/structures/tenants.ts +0 -5
- package/tests/core/utilities/structures/userGroups.ts +0 -10
- package/tests/core/utilities/structures/users.ts +0 -89
- package/tests/core/utilities/testContainerUtils.ts +0 -165
- package/tests/core/utilities/utils/index.ts +0 -2
- package/tests/core/utilities/utils/queue.ts +0 -27
- package/tests/core/utilities/utils/time.ts +0 -3
- package/tests/extra/DBTestConfiguration.ts +0 -36
- package/tests/extra/index.ts +0 -2
- package/tests/extra/testEnv.ts +0 -95
- package/tests/index.ts +0 -2
- package/tests/jestEnv.ts +0 -10
- package/tests/jestSetup.ts +0 -36
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { testEnv, DBTestConfiguration } from "../../../tests/extra"
|
|
2
|
-
import * as migrations from "../index"
|
|
3
|
-
import * as context from "../../context"
|
|
4
|
-
import { MigrationType } from "@budibase/types"
|
|
5
|
-
|
|
6
|
-
testEnv.multiTenant()
|
|
7
|
-
|
|
8
|
-
describe("migrations", () => {
|
|
9
|
-
const config = new DBTestConfiguration()
|
|
10
|
-
|
|
11
|
-
const migrationFunction = jest.fn()
|
|
12
|
-
|
|
13
|
-
const MIGRATIONS = [
|
|
14
|
-
{
|
|
15
|
-
type: MigrationType.GLOBAL,
|
|
16
|
-
name: "test" as any,
|
|
17
|
-
fn: migrationFunction,
|
|
18
|
-
},
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
config.newTenant()
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
afterEach(async () => {
|
|
26
|
-
jest.clearAllMocks()
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
const migrate = () => {
|
|
30
|
-
return migrations.runMigrations(MIGRATIONS, {
|
|
31
|
-
tenantIds: [config.tenantId],
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
it("should run a new migration", async () => {
|
|
36
|
-
await config.doInTenant(async () => {
|
|
37
|
-
await migrate()
|
|
38
|
-
expect(migrationFunction).toHaveBeenCalled()
|
|
39
|
-
const db = context.getGlobalDB()
|
|
40
|
-
const doc = await migrations.getMigrationsDoc(db)
|
|
41
|
-
expect(doc.test).toBeDefined()
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it("should match snapshot", async () => {
|
|
46
|
-
await config.doInTenant(async () => {
|
|
47
|
-
await migrate()
|
|
48
|
-
const doc = await migrations.getMigrationsDoc(context.getGlobalDB())
|
|
49
|
-
expect(doc).toMatchSnapshot()
|
|
50
|
-
})
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it("should skip a previously run migration", async () => {
|
|
54
|
-
await config.doInTenant(async () => {
|
|
55
|
-
const db = context.getGlobalDB()
|
|
56
|
-
await migrate()
|
|
57
|
-
const previousDoc = await migrations.getMigrationsDoc(db)
|
|
58
|
-
await migrate()
|
|
59
|
-
const currentDoc = await migrations.getMigrationsDoc(db)
|
|
60
|
-
expect(migrationFunction).toHaveBeenCalledTimes(1)
|
|
61
|
-
expect(currentDoc.test).toBe(previousDoc.test)
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
})
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import env from "../../environment"
|
|
2
|
-
import * as objectStore from "../objectStore"
|
|
3
|
-
import * as cloudfront from "../cloudfront"
|
|
4
|
-
import qs from "querystring"
|
|
5
|
-
import { DEFAULT_TENANT_ID, getTenantId } from "../../context"
|
|
6
|
-
|
|
7
|
-
export function clientLibraryPath(appId: string) {
|
|
8
|
-
return `${objectStore.sanitizeKey(appId)}/budibase-client.js`
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Previously we used to serve the client library directly from Cloudfront, however
|
|
13
|
-
* due to issues with the domain we were unable to continue doing this - keeping
|
|
14
|
-
* incase we are able to switch back to CDN path again in future.
|
|
15
|
-
*/
|
|
16
|
-
export function clientLibraryCDNUrl(appId: string, version: string) {
|
|
17
|
-
let file = clientLibraryPath(appId)
|
|
18
|
-
if (env.CLOUDFRONT_CDN) {
|
|
19
|
-
// append app version to bust the cache
|
|
20
|
-
if (version) {
|
|
21
|
-
file += `?v=${version}`
|
|
22
|
-
}
|
|
23
|
-
// don't need to use presigned for client with cloudfront
|
|
24
|
-
// file is public
|
|
25
|
-
return cloudfront.getUrl(file)
|
|
26
|
-
} else {
|
|
27
|
-
return objectStore.getPresignedUrl(env.APPS_BUCKET_NAME, file)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function clientLibraryUrl(appId: string, version: string) {
|
|
32
|
-
let tenantId, qsParams: { appId: string; version: string; tenantId?: string }
|
|
33
|
-
try {
|
|
34
|
-
tenantId = getTenantId()
|
|
35
|
-
} finally {
|
|
36
|
-
qsParams = {
|
|
37
|
-
appId,
|
|
38
|
-
version,
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (tenantId && tenantId !== DEFAULT_TENANT_ID) {
|
|
42
|
-
qsParams.tenantId = tenantId
|
|
43
|
-
}
|
|
44
|
-
return `/api/assets/client?${qs.encode(qsParams)}`
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function getAppFileUrl(s3Key: string) {
|
|
48
|
-
if (env.CLOUDFRONT_CDN) {
|
|
49
|
-
return cloudfront.getPresignedUrl(s3Key)
|
|
50
|
-
} else {
|
|
51
|
-
return objectStore.getPresignedUrl(env.APPS_BUCKET_NAME, s3Key)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import env from "../../environment"
|
|
2
|
-
import * as context from "../../context"
|
|
3
|
-
import * as objectStore from "../objectStore"
|
|
4
|
-
import * as cloudfront from "../cloudfront"
|
|
5
|
-
|
|
6
|
-
// URLs
|
|
7
|
-
|
|
8
|
-
export const getGlobalFileUrl = (type: string, name: string, etag?: string) => {
|
|
9
|
-
let file = getGlobalFileS3Key(type, name)
|
|
10
|
-
if (env.CLOUDFRONT_CDN) {
|
|
11
|
-
if (etag) {
|
|
12
|
-
file = `${file}?etag=${etag}`
|
|
13
|
-
}
|
|
14
|
-
return cloudfront.getPresignedUrl(file)
|
|
15
|
-
} else {
|
|
16
|
-
return objectStore.getPresignedUrl(env.GLOBAL_BUCKET_NAME, file)
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// KEYS
|
|
21
|
-
|
|
22
|
-
export const getGlobalFileS3Key = (type: string, name: string) => {
|
|
23
|
-
let file = `${type}/${name}`
|
|
24
|
-
if (env.MULTI_TENANCY) {
|
|
25
|
-
const tenantId = context.getTenantId()
|
|
26
|
-
file = `${tenantId}/${file}`
|
|
27
|
-
}
|
|
28
|
-
return file
|
|
29
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import env from "../../environment"
|
|
2
|
-
import * as objectStore from "../objectStore"
|
|
3
|
-
import * as context from "../../context"
|
|
4
|
-
import * as cloudfront from "../cloudfront"
|
|
5
|
-
import { Plugin } from "@budibase/types"
|
|
6
|
-
|
|
7
|
-
// URLS
|
|
8
|
-
|
|
9
|
-
export function enrichPluginURLs(plugins?: Plugin[]): Plugin[] {
|
|
10
|
-
if (!plugins || !plugins.length) {
|
|
11
|
-
return []
|
|
12
|
-
}
|
|
13
|
-
return plugins.map(plugin => {
|
|
14
|
-
const jsUrl = getPluginJSUrl(plugin)
|
|
15
|
-
const iconUrl = getPluginIconUrl(plugin)
|
|
16
|
-
return { ...plugin, jsUrl, iconUrl }
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function getPluginJSUrl(plugin: Plugin) {
|
|
21
|
-
const s3Key = getPluginJSKey(plugin)
|
|
22
|
-
return getPluginUrl(s3Key)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getPluginIconUrl(plugin: Plugin): string | undefined {
|
|
26
|
-
const s3Key = getPluginIconKey(plugin)
|
|
27
|
-
if (!s3Key) {
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
return getPluginUrl(s3Key)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function getPluginUrl(s3Key: string) {
|
|
34
|
-
if (env.CLOUDFRONT_CDN) {
|
|
35
|
-
return cloudfront.getPresignedUrl(s3Key)
|
|
36
|
-
} else {
|
|
37
|
-
return objectStore.getPresignedUrl(env.PLUGIN_BUCKET_NAME, s3Key)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// S3 KEYS
|
|
42
|
-
|
|
43
|
-
export function getPluginJSKey(plugin: Plugin) {
|
|
44
|
-
return getPluginS3Key(plugin, "plugin.min.js")
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function getPluginIconKey(plugin: Plugin) {
|
|
48
|
-
// stored iconUrl is deprecated - hardcode to icon.svg in this case
|
|
49
|
-
const iconFileName = plugin.iconUrl ? "icon.svg" : plugin.iconFileName
|
|
50
|
-
if (!iconFileName) {
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
return getPluginS3Key(plugin, iconFileName)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function getPluginS3Key(plugin: Plugin, fileName: string) {
|
|
57
|
-
const s3Key = getPluginS3Dir(plugin.name)
|
|
58
|
-
return `${s3Key}/${fileName}`
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function getPluginS3Dir(pluginName: string) {
|
|
62
|
-
let s3Key = `${pluginName}`
|
|
63
|
-
if (env.MULTI_TENANCY) {
|
|
64
|
-
const tenantId = context.getTenantId()
|
|
65
|
-
s3Key = `${tenantId}/${s3Key}`
|
|
66
|
-
}
|
|
67
|
-
if (env.CLOUDFRONT_CDN) {
|
|
68
|
-
s3Key = `plugins/${s3Key}`
|
|
69
|
-
}
|
|
70
|
-
return s3Key
|
|
71
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import * as app from "../app"
|
|
2
|
-
import { testEnv } from "../../../../tests/extra"
|
|
3
|
-
|
|
4
|
-
describe("app", () => {
|
|
5
|
-
beforeEach(() => {
|
|
6
|
-
testEnv.nodeJest()
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
function baseCheck(url: string, tenantId?: string) {
|
|
10
|
-
expect(url).toContain("/api/assets/client")
|
|
11
|
-
if (tenantId) {
|
|
12
|
-
expect(url).toContain(`tenantId=${tenantId}`)
|
|
13
|
-
}
|
|
14
|
-
expect(url).toContain("appId=app_123")
|
|
15
|
-
expect(url).toContain("version=2.0.0")
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
describe("clientLibraryUrl", () => {
|
|
19
|
-
function getClientUrl() {
|
|
20
|
-
return app.clientLibraryUrl("app_123/budibase-client.js", "2.0.0")
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe("single tenant", () => {
|
|
24
|
-
beforeAll(() => {
|
|
25
|
-
testEnv.singleTenant()
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it("gets url in dev", () => {
|
|
29
|
-
testEnv.nodeDev()
|
|
30
|
-
const url = getClientUrl()
|
|
31
|
-
baseCheck(url)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it("gets url with custom S3", () => {
|
|
35
|
-
testEnv.withS3()
|
|
36
|
-
const url = getClientUrl()
|
|
37
|
-
baseCheck(url)
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it("gets url with cloudfront + s3", () => {
|
|
41
|
-
testEnv.withCloudfront()
|
|
42
|
-
const url = getClientUrl()
|
|
43
|
-
baseCheck(url)
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
describe("multi tenant", () => {
|
|
48
|
-
beforeAll(() => {
|
|
49
|
-
testEnv.multiTenant()
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it("gets url in dev", async () => {
|
|
53
|
-
testEnv.nodeDev()
|
|
54
|
-
await testEnv.withTenant(tenantId => {
|
|
55
|
-
const url = getClientUrl()
|
|
56
|
-
baseCheck(url, tenantId)
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it("gets url with embedded minio", async () => {
|
|
61
|
-
await testEnv.withTenant(tenantId => {
|
|
62
|
-
testEnv.withMinio()
|
|
63
|
-
const url = getClientUrl()
|
|
64
|
-
baseCheck(url, tenantId)
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
it("gets url with custom S3", async () => {
|
|
69
|
-
await testEnv.withTenant(tenantId => {
|
|
70
|
-
testEnv.withS3()
|
|
71
|
-
const url = getClientUrl()
|
|
72
|
-
baseCheck(url, tenantId)
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
it("gets url with cloudfront + s3", async () => {
|
|
77
|
-
await testEnv.withTenant(tenantId => {
|
|
78
|
-
testEnv.withCloudfront()
|
|
79
|
-
const url = getClientUrl()
|
|
80
|
-
baseCheck(url, tenantId)
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
describe("getAppFileUrl", () => {
|
|
87
|
-
function getAppFileUrl() {
|
|
88
|
-
return app.getAppFileUrl("app_123/attachments/image.jpeg")
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
describe("single tenant", () => {
|
|
92
|
-
beforeAll(() => {
|
|
93
|
-
testEnv.multiTenant()
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it("gets url with embedded minio", () => {
|
|
97
|
-
testEnv.withMinio()
|
|
98
|
-
const url = getAppFileUrl()
|
|
99
|
-
expect(url).toBe(
|
|
100
|
-
"/files/signed/prod-budi-app-assets/app_123/attachments/image.jpeg"
|
|
101
|
-
)
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
it("gets url with custom S3", () => {
|
|
105
|
-
testEnv.withS3()
|
|
106
|
-
const url = getAppFileUrl()
|
|
107
|
-
expect(url).toBe(
|
|
108
|
-
"http://s3.example.com/prod-budi-app-assets/app_123/attachments/image.jpeg"
|
|
109
|
-
)
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
it("gets url with cloudfront + s3", () => {
|
|
113
|
-
testEnv.withCloudfront()
|
|
114
|
-
const url = getAppFileUrl()
|
|
115
|
-
// omit rest of signed params
|
|
116
|
-
expect(
|
|
117
|
-
url.includes("http://cf.example.com/app_123/attachments/image.jpeg?")
|
|
118
|
-
).toBe(true)
|
|
119
|
-
})
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
describe("multi tenant", () => {
|
|
123
|
-
beforeAll(() => {
|
|
124
|
-
testEnv.multiTenant()
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
it("gets url with embedded minio", async () => {
|
|
128
|
-
testEnv.withMinio()
|
|
129
|
-
await testEnv.withTenant(() => {
|
|
130
|
-
const url = getAppFileUrl()
|
|
131
|
-
expect(url).toBe(
|
|
132
|
-
"/files/signed/prod-budi-app-assets/app_123/attachments/image.jpeg"
|
|
133
|
-
)
|
|
134
|
-
})
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
it("gets url with custom S3", async () => {
|
|
138
|
-
testEnv.withS3()
|
|
139
|
-
await testEnv.withTenant(() => {
|
|
140
|
-
const url = getAppFileUrl()
|
|
141
|
-
expect(url).toBe(
|
|
142
|
-
"http://s3.example.com/prod-budi-app-assets/app_123/attachments/image.jpeg"
|
|
143
|
-
)
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
it("gets url with cloudfront + s3", async () => {
|
|
148
|
-
testEnv.withCloudfront()
|
|
149
|
-
await testEnv.withTenant(() => {
|
|
150
|
-
const url = getAppFileUrl()
|
|
151
|
-
// omit rest of signed params
|
|
152
|
-
expect(
|
|
153
|
-
url.includes(
|
|
154
|
-
"http://cf.example.com/app_123/attachments/image.jpeg?"
|
|
155
|
-
)
|
|
156
|
-
).toBe(true)
|
|
157
|
-
})
|
|
158
|
-
})
|
|
159
|
-
})
|
|
160
|
-
})
|
|
161
|
-
})
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import * as global from "../global"
|
|
2
|
-
import { testEnv } from "../../../../tests/extra"
|
|
3
|
-
|
|
4
|
-
describe("global", () => {
|
|
5
|
-
describe("getGlobalFileUrl", () => {
|
|
6
|
-
function getGlobalFileUrl() {
|
|
7
|
-
return global.getGlobalFileUrl("settings", "logoUrl", "etag")
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
describe("single tenant", () => {
|
|
11
|
-
beforeAll(() => {
|
|
12
|
-
testEnv.singleTenant()
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it("gets url with embedded minio", () => {
|
|
16
|
-
testEnv.withMinio()
|
|
17
|
-
const url = getGlobalFileUrl()
|
|
18
|
-
expect(url).toBe("/files/signed/global/settings/logoUrl")
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it("gets url with custom S3", () => {
|
|
22
|
-
testEnv.withS3()
|
|
23
|
-
const url = getGlobalFileUrl()
|
|
24
|
-
expect(url).toBe("http://s3.example.com/global/settings/logoUrl")
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it("gets url with cloudfront + s3", () => {
|
|
28
|
-
testEnv.withCloudfront()
|
|
29
|
-
const url = getGlobalFileUrl()
|
|
30
|
-
// omit rest of signed params
|
|
31
|
-
expect(
|
|
32
|
-
url.includes("http://cf.example.com/settings/logoUrl?etag=etag&")
|
|
33
|
-
).toBe(true)
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
describe("multi tenant", () => {
|
|
38
|
-
beforeAll(() => {
|
|
39
|
-
testEnv.multiTenant()
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it("gets url with embedded minio", async () => {
|
|
43
|
-
testEnv.withMinio()
|
|
44
|
-
await testEnv.withTenant(tenantId => {
|
|
45
|
-
const url = getGlobalFileUrl()
|
|
46
|
-
expect(url).toBe(`/files/signed/global/${tenantId}/settings/logoUrl`)
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it("gets url with custom S3", async () => {
|
|
51
|
-
testEnv.withS3()
|
|
52
|
-
await testEnv.withTenant(tenantId => {
|
|
53
|
-
const url = getGlobalFileUrl()
|
|
54
|
-
expect(url).toBe(
|
|
55
|
-
`http://s3.example.com/global/${tenantId}/settings/logoUrl`
|
|
56
|
-
)
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it("gets url with cloudfront + s3", async () => {
|
|
61
|
-
testEnv.withCloudfront()
|
|
62
|
-
await testEnv.withTenant(tenantId => {
|
|
63
|
-
const url = getGlobalFileUrl()
|
|
64
|
-
// omit rest of signed params
|
|
65
|
-
expect(
|
|
66
|
-
url.includes(
|
|
67
|
-
`http://cf.example.com/${tenantId}/settings/logoUrl?etag=etag&`
|
|
68
|
-
)
|
|
69
|
-
).toBe(true)
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
})
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import * as plugins from "../plugins"
|
|
2
|
-
import { structures } from "../../../../tests"
|
|
3
|
-
import { testEnv } from "../../../../tests/extra"
|
|
4
|
-
|
|
5
|
-
describe("plugins", () => {
|
|
6
|
-
describe("enrichPluginURLs", () => {
|
|
7
|
-
const plugin = structures.plugins.plugin()
|
|
8
|
-
|
|
9
|
-
function getEnrichedPluginUrls() {
|
|
10
|
-
const enriched = plugins.enrichPluginURLs([plugin])[0]
|
|
11
|
-
return {
|
|
12
|
-
jsUrl: enriched.jsUrl!,
|
|
13
|
-
iconUrl: enriched.iconUrl!,
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
describe("single tenant", () => {
|
|
18
|
-
beforeAll(() => {
|
|
19
|
-
testEnv.singleTenant()
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it("gets url with embedded minio", () => {
|
|
23
|
-
testEnv.withMinio()
|
|
24
|
-
const urls = getEnrichedPluginUrls()
|
|
25
|
-
expect(urls.jsUrl).toBe(
|
|
26
|
-
`/files/signed/plugins/${plugin.name}/plugin.min.js`
|
|
27
|
-
)
|
|
28
|
-
expect(urls.iconUrl).toBe(
|
|
29
|
-
`/files/signed/plugins/${plugin.name}/icon.svg`
|
|
30
|
-
)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it("gets url with custom S3", () => {
|
|
34
|
-
testEnv.withS3()
|
|
35
|
-
const urls = getEnrichedPluginUrls()
|
|
36
|
-
expect(urls.jsUrl).toBe(
|
|
37
|
-
`http://s3.example.com/plugins/${plugin.name}/plugin.min.js`
|
|
38
|
-
)
|
|
39
|
-
expect(urls.iconUrl).toBe(
|
|
40
|
-
`http://s3.example.com/plugins/${plugin.name}/icon.svg`
|
|
41
|
-
)
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it("gets url with cloudfront + s3", () => {
|
|
45
|
-
testEnv.withCloudfront()
|
|
46
|
-
const urls = getEnrichedPluginUrls()
|
|
47
|
-
// omit rest of signed params
|
|
48
|
-
expect(
|
|
49
|
-
urls.jsUrl.includes(
|
|
50
|
-
`http://cf.example.com/plugins/${plugin.name}/plugin.min.js?`
|
|
51
|
-
)
|
|
52
|
-
).toBe(true)
|
|
53
|
-
expect(
|
|
54
|
-
urls.iconUrl.includes(
|
|
55
|
-
`http://cf.example.com/plugins/${plugin.name}/icon.svg?`
|
|
56
|
-
)
|
|
57
|
-
).toBe(true)
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
describe("multi tenant", () => {
|
|
62
|
-
beforeAll(() => {
|
|
63
|
-
testEnv.multiTenant()
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it("gets url with embedded minio", async () => {
|
|
67
|
-
testEnv.withMinio()
|
|
68
|
-
await testEnv.withTenant(tenantId => {
|
|
69
|
-
const urls = getEnrichedPluginUrls()
|
|
70
|
-
expect(urls.jsUrl).toBe(
|
|
71
|
-
`/files/signed/plugins/${tenantId}/${plugin.name}/plugin.min.js`
|
|
72
|
-
)
|
|
73
|
-
expect(urls.iconUrl).toBe(
|
|
74
|
-
`/files/signed/plugins/${tenantId}/${plugin.name}/icon.svg`
|
|
75
|
-
)
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
it("gets url with custom S3", async () => {
|
|
80
|
-
testEnv.withS3()
|
|
81
|
-
await testEnv.withTenant(tenantId => {
|
|
82
|
-
const urls = getEnrichedPluginUrls()
|
|
83
|
-
expect(urls.jsUrl).toBe(
|
|
84
|
-
`http://s3.example.com/plugins/${tenantId}/${plugin.name}/plugin.min.js`
|
|
85
|
-
)
|
|
86
|
-
expect(urls.iconUrl).toBe(
|
|
87
|
-
`http://s3.example.com/plugins/${tenantId}/${plugin.name}/icon.svg`
|
|
88
|
-
)
|
|
89
|
-
})
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
it("gets url with cloudfront + s3", async () => {
|
|
93
|
-
testEnv.withCloudfront()
|
|
94
|
-
await testEnv.withTenant(tenantId => {
|
|
95
|
-
const urls = getEnrichedPluginUrls()
|
|
96
|
-
// omit rest of signed params
|
|
97
|
-
expect(
|
|
98
|
-
urls.jsUrl.includes(
|
|
99
|
-
`http://cf.example.com/plugins/${tenantId}/${plugin.name}/plugin.min.js?`
|
|
100
|
-
)
|
|
101
|
-
).toBe(true)
|
|
102
|
-
expect(
|
|
103
|
-
urls.iconUrl.includes(
|
|
104
|
-
`http://cf.example.com/plugins/${tenantId}/${plugin.name}/icon.svg?`
|
|
105
|
-
)
|
|
106
|
-
).toBe(true)
|
|
107
|
-
})
|
|
108
|
-
})
|
|
109
|
-
})
|
|
110
|
-
})
|
|
111
|
-
})
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import env from "../environment"
|
|
2
|
-
import * as cfsign from "aws-cloudfront-sign"
|
|
3
|
-
|
|
4
|
-
let PRIVATE_KEY: string | undefined
|
|
5
|
-
|
|
6
|
-
function getPrivateKey() {
|
|
7
|
-
if (!env.CLOUDFRONT_PRIVATE_KEY_64) {
|
|
8
|
-
throw new Error("CLOUDFRONT_PRIVATE_KEY_64 is not set")
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (PRIVATE_KEY) {
|
|
12
|
-
return PRIVATE_KEY
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
PRIVATE_KEY = Buffer.from(env.CLOUDFRONT_PRIVATE_KEY_64, "base64").toString(
|
|
16
|
-
"utf-8"
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
return PRIVATE_KEY
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const getCloudfrontSignParams = () => {
|
|
23
|
-
return {
|
|
24
|
-
keypairId: env.CLOUDFRONT_PUBLIC_KEY_ID!,
|
|
25
|
-
privateKeyString: getPrivateKey(),
|
|
26
|
-
expireTime: new Date().getTime() + 1000 * 60 * 60 * 24, // 1 day
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const getPresignedUrl = (s3Key: string) => {
|
|
31
|
-
const url = getUrl(s3Key)
|
|
32
|
-
return cfsign.getSignedUrl(url, getCloudfrontSignParams())
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const getUrl = (s3Key: string) => {
|
|
36
|
-
let prefix = "/"
|
|
37
|
-
if (s3Key.startsWith("/")) {
|
|
38
|
-
prefix = ""
|
|
39
|
-
}
|
|
40
|
-
return `${env.CLOUDFRONT_CDN}${prefix}${s3Key}`
|
|
41
|
-
}
|
package/src/objectStore/index.ts
DELETED