@budibase/backend-core 2.9.39-alpha.0 → 2.9.39-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +5 -5
- package/dist/src/accounts/accounts.js +100 -0
- package/dist/src/accounts/accounts.js.map +7 -0
- package/dist/src/accounts/api.js +78 -0
- package/dist/src/accounts/api.js.map +7 -0
- package/dist/src/accounts/index.js +23 -0
- package/dist/src/accounts/index.js.map +7 -0
- package/dist/src/auth/auth.js +208 -0
- package/dist/src/auth/auth.js.map +7 -0
- package/dist/src/auth/index.js +23 -0
- package/dist/src/auth/index.js.map +7 -0
- package/dist/src/auth/tests/auth.spec.js +37 -0
- package/dist/src/auth/tests/auth.spec.js.map +7 -0
- package/dist/src/blacklist/blacklist.js +88 -0
- package/dist/src/blacklist/blacklist.js.map +7 -0
- package/dist/src/blacklist/index.js +23 -0
- package/dist/src/blacklist/index.js.map +7 -0
- package/dist/src/blacklist/tests/blacklist.spec.js +61 -0
- package/dist/src/blacklist/tests/blacklist.spec.js.map +7 -0
- package/dist/src/cache/appMetadata.js +86 -0
- package/dist/src/cache/appMetadata.js.map +7 -0
- package/dist/src/cache/base/index.js +102 -0
- package/dist/src/cache/base/index.js.map +7 -0
- package/dist/src/cache/generic.js +69 -0
- package/dist/src/cache/generic.js.map +7 -0
- package/dist/src/cache/index.js +51 -0
- package/dist/src/cache/index.js.map +7 -0
- package/dist/src/cache/tests/writethrough.spec.js +132 -0
- package/dist/src/cache/tests/writethrough.spec.js.map +7 -0
- package/dist/src/cache/user.js +99 -0
- package/dist/src/cache/user.js.map +7 -0
- package/dist/src/cache/writethrough.js +144 -0
- package/dist/src/cache/writethrough.js.map +7 -0
- package/dist/src/configs/configs.js +228 -0
- package/dist/src/configs/configs.js.map +7 -0
- package/dist/src/configs/index.js +23 -0
- package/dist/src/configs/index.js.map +7 -0
- package/dist/src/configs/tests/configs.spec.js +182 -0
- package/dist/src/configs/tests/configs.spec.js.map +7 -0
- package/dist/src/constants/db.js +107 -0
- package/dist/src/constants/db.js.map +7 -0
- package/dist/src/constants/index.js +25 -0
- package/dist/src/constants/index.js.map +7 -0
- package/dist/src/constants/misc.js +92 -0
- package/dist/src/constants/misc.js.map +7 -0
- package/dist/src/context/Context.js +36 -0
- package/dist/src/context/Context.js.map +7 -0
- package/dist/src/context/identity.js +87 -0
- package/dist/src/context/identity.js.map +7 -0
- package/dist/src/context/index.js +45 -0
- package/dist/src/context/index.js.map +7 -0
- package/dist/src/context/mainContext.js +320 -0
- package/dist/src/context/mainContext.js.map +7 -0
- package/dist/src/context/tests/index.spec.js +147 -0
- package/dist/src/context/tests/index.spec.js.map +7 -0
- package/dist/src/context/types.js +17 -0
- package/dist/src/context/types.js.map +7 -0
- package/dist/src/db/Replication.js +89 -0
- package/dist/src/db/Replication.js.map +7 -0
- package/dist/src/db/constants.js +39 -0
- package/dist/src/db/constants.js.map +7 -0
- package/dist/src/db/couch/DatabaseImpl.js +224 -0
- package/dist/src/db/couch/DatabaseImpl.js.map +7 -0
- package/dist/src/db/couch/connections.js +103 -0
- package/dist/src/db/couch/connections.js.map +7 -0
- package/dist/src/db/couch/index.js +44 -0
- package/dist/src/db/couch/index.js.map +7 -0
- package/dist/src/db/couch/pouchDB.js +118 -0
- package/dist/src/db/couch/pouchDB.js.map +7 -0
- package/dist/src/db/couch/pouchDump.js +2 -0
- package/dist/src/db/couch/pouchDump.js.map +7 -0
- package/dist/src/db/couch/utils.js +76 -0
- package/dist/src/db/couch/utils.js.map +7 -0
- package/dist/src/db/db.js +73 -0
- package/dist/src/db/db.js.map +7 -0
- package/dist/src/db/errors.js +43 -0
- package/dist/src/db/errors.js.map +7 -0
- package/dist/src/db/index.js +64 -0
- package/dist/src/db/index.js.map +7 -0
- package/dist/src/db/lucene.js +595 -0
- package/dist/src/db/lucene.js.map +7 -0
- package/dist/src/db/searchIndexes/index.js +23 -0
- package/dist/src/db/searchIndexes/index.js.map +7 -0
- package/dist/src/db/searchIndexes/searchIndexes.js +82 -0
- package/dist/src/db/searchIndexes/searchIndexes.js.map +7 -0
- package/dist/src/db/tests/index.spec.js +24 -0
- package/dist/src/db/tests/index.spec.js.map +7 -0
- package/dist/src/db/tests/lucene.spec.js +312 -0
- package/dist/src/db/tests/lucene.spec.js.map +7 -0
- package/dist/src/db/tests/pouch.spec.js +63 -0
- package/dist/src/db/tests/pouch.spec.js.map +7 -0
- package/dist/src/db/tests/utils.spec.js +50 -0
- package/dist/src/db/tests/utils.spec.js.map +7 -0
- package/dist/src/db/utils.js +198 -0
- package/dist/src/db/utils.js.map +7 -0
- package/dist/src/db/views.js +223 -0
- package/dist/src/db/views.js.map +7 -0
- package/dist/src/docIds/conversions.js +83 -0
- package/dist/src/docIds/conversions.js.map +7 -0
- package/dist/src/docIds/ids.js +101 -0
- package/dist/src/docIds/ids.js.map +7 -0
- package/dist/src/docIds/index.js +25 -0
- package/dist/src/docIds/index.js.map +7 -0
- package/dist/src/docIds/newid.js +32 -0
- package/dist/src/docIds/newid.js.map +7 -0
- package/dist/src/docIds/params.js +136 -0
- package/dist/src/docIds/params.js.map +7 -0
- package/dist/src/docUpdates/index.js +61 -0
- package/dist/src/docUpdates/index.js.map +7 -0
- package/dist/src/environment.js +181 -0
- package/dist/src/environment.js.map +7 -0
- package/dist/src/errors/errors.js +126 -0
- package/dist/src/errors/errors.js.map +7 -0
- package/dist/src/errors/index.js +23 -0
- package/dist/src/errors/index.js.map +7 -0
- package/dist/src/events/analytics.js +42 -0
- package/dist/src/events/analytics.js.map +7 -0
- package/dist/src/events/asyncEvents/index.js +25 -0
- package/dist/src/events/asyncEvents/index.js.map +7 -0
- package/dist/src/events/asyncEvents/publisher.js +39 -0
- package/dist/src/events/asyncEvents/publisher.js.map +7 -0
- package/dist/src/events/asyncEvents/queue.js +42 -0
- package/dist/src/events/asyncEvents/queue.js.map +7 -0
- package/dist/src/events/backfill.js +172 -0
- package/dist/src/events/backfill.js.map +7 -0
- package/dist/src/events/documentId.js +51 -0
- package/dist/src/events/documentId.js.map +7 -0
- package/dist/src/events/events.js +63 -0
- package/dist/src/events/events.js.map +7 -0
- package/dist/src/events/identification.js +275 -0
- package/dist/src/events/identification.js.map +7 -0
- package/dist/src/events/index.js +62 -0
- package/dist/src/events/index.js.map +7 -0
- package/dist/src/events/processors/AnalyticsProcessor.js +76 -0
- package/dist/src/events/processors/AnalyticsProcessor.js.map +7 -0
- package/dist/src/events/processors/AuditLogsProcessor.js +97 -0
- package/dist/src/events/processors/AuditLogsProcessor.js.map +7 -0
- package/dist/src/events/processors/LoggingProcessor.js +58 -0
- package/dist/src/events/processors/LoggingProcessor.js.map +7 -0
- package/dist/src/events/processors/Processors.js +57 -0
- package/dist/src/events/processors/Processors.js.map +7 -0
- package/dist/src/events/processors/async/DocumentUpdateProcessor.js +53 -0
- package/dist/src/events/processors/async/DocumentUpdateProcessor.js.map +7 -0
- package/dist/src/events/processors/index.js +57 -0
- package/dist/src/events/processors/index.js.map +7 -0
- package/dist/src/events/processors/posthog/PosthogProcessor.js +126 -0
- package/dist/src/events/processors/posthog/PosthogProcessor.js.map +7 -0
- package/dist/src/events/processors/posthog/index.js +36 -0
- package/dist/src/events/processors/posthog/index.js.map +7 -0
- package/dist/src/events/processors/posthog/rateLimiting.js +105 -0
- package/dist/src/events/processors/posthog/rateLimiting.js.map +7 -0
- package/dist/src/events/processors/posthog/tests/PosthogProcessor.spec.js +154 -0
- package/dist/src/events/processors/posthog/tests/PosthogProcessor.spec.js.map +7 -0
- package/dist/src/events/processors/types.js +29 -0
- package/dist/src/events/processors/types.js.map +7 -0
- package/dist/src/events/publishers/account.js +49 -0
- package/dist/src/events/publishers/account.js.map +7 -0
- package/dist/src/events/publishers/app.js +145 -0
- package/dist/src/events/publishers/app.js.map +7 -0
- package/dist/src/events/publishers/auditLog.js +42 -0
- package/dist/src/events/publishers/auditLog.js.map +7 -0
- package/dist/src/events/publishers/auth.js +80 -0
- package/dist/src/events/publishers/auth.js.map +7 -0
- package/dist/src/events/publishers/automation.js +111 -0
- package/dist/src/events/publishers/automation.js.map +7 -0
- package/dist/src/events/publishers/backfill.js +92 -0
- package/dist/src/events/publishers/backfill.js.map +7 -0
- package/dist/src/events/publishers/backup.js +49 -0
- package/dist/src/events/publishers/backup.js.map +7 -0
- package/dist/src/events/publishers/datasource.js +59 -0
- package/dist/src/events/publishers/datasource.js.map +7 -0
- package/dist/src/events/publishers/email.js +38 -0
- package/dist/src/events/publishers/email.js.map +7 -0
- package/dist/src/events/publishers/environmentVariable.js +53 -0
- package/dist/src/events/publishers/environmentVariable.js.map +7 -0
- package/dist/src/events/publishers/group.js +105 -0
- package/dist/src/events/publishers/group.js.map +7 -0
- package/dist/src/events/publishers/index.js +108 -0
- package/dist/src/events/publishers/index.js.map +7 -0
- package/dist/src/events/publishers/installation.js +56 -0
- package/dist/src/events/publishers/installation.js.map +7 -0
- package/dist/src/events/publishers/layout.js +42 -0
- package/dist/src/events/publishers/layout.js.map +7 -0
- package/dist/src/events/publishers/license.js +78 -0
- package/dist/src/events/publishers/license.js.map +7 -0
- package/dist/src/events/publishers/org.js +53 -0
- package/dist/src/events/publishers/org.js.map +7 -0
- package/dist/src/events/publishers/plugin.js +61 -0
- package/dist/src/events/publishers/plugin.js.map +7 -0
- package/dist/src/events/publishers/query.js +85 -0
- package/dist/src/events/publishers/query.js.map +7 -0
- package/dist/src/events/publishers/role.js +71 -0
- package/dist/src/events/publishers/role.js.map +7 -0
- package/dist/src/events/publishers/rows.js +43 -0
- package/dist/src/events/publishers/rows.js.map +7 -0
- package/dist/src/events/publishers/screen.js +52 -0
- package/dist/src/events/publishers/screen.js.map +7 -0
- package/dist/src/events/publishers/serve.js +53 -0
- package/dist/src/events/publishers/serve.js.map +7 -0
- package/dist/src/events/publishers/table.js +79 -0
- package/dist/src/events/publishers/table.js.map +7 -0
- package/dist/src/events/publishers/user.js +191 -0
- package/dist/src/events/publishers/user.js.map +7 -0
- package/dist/src/events/publishers/view.js +102 -0
- package/dist/src/events/publishers/view.js.map +7 -0
- package/dist/src/features/index.js +105 -0
- package/dist/src/features/index.js.map +7 -0
- package/dist/src/features/installation.js +42 -0
- package/dist/src/features/installation.js.map +7 -0
- package/dist/src/features/tests/featureFlags.spec.js +86 -0
- package/dist/src/features/tests/featureFlags.spec.js.map +7 -0
- package/dist/src/helpers.js +31 -0
- package/dist/src/helpers.js.map +7 -0
- package/dist/src/index.js +154 -0
- package/dist/src/index.js.map +7 -0
- package/dist/src/installation.js +139 -0
- package/dist/src/installation.js.map +7 -0
- package/dist/src/logging/alerts.js +49 -0
- package/dist/src/logging/alerts.js.map +7 -0
- package/dist/src/logging/correlation/correlation.js +41 -0
- package/dist/src/logging/correlation/correlation.js.map +7 -0
- package/dist/src/logging/correlation/index.js +23 -0
- package/dist/src/logging/correlation/index.js.map +7 -0
- package/dist/src/logging/correlation/middleware.js +37 -0
- package/dist/src/logging/correlation/middleware.js.map +7 -0
- package/dist/src/logging/index.js +48 -0
- package/dist/src/logging/index.js.map +7 -0
- package/dist/src/logging/pino/logger.js +197 -0
- package/dist/src/logging/pino/logger.js.map +7 -0
- package/dist/src/logging/pino/middleware.js +77 -0
- package/dist/src/logging/pino/middleware.js.map +7 -0
- package/dist/src/logging/system.js +110 -0
- package/dist/src/logging/system.js.map +7 -0
- package/dist/src/logging/tests/system.spec.js +59 -0
- package/dist/src/logging/tests/system.spec.js.map +7 -0
- package/dist/src/middleware/adminOnly.js +31 -0
- package/dist/src/middleware/adminOnly.js.map +7 -0
- package/dist/src/middleware/auditLog.js +27 -0
- package/dist/src/middleware/auditLog.js.map +7 -0
- package/dist/src/middleware/authenticated.js +178 -0
- package/dist/src/middleware/authenticated.js.map +7 -0
- package/dist/src/middleware/builderOnly.js +48 -0
- package/dist/src/middleware/builderOnly.js.map +7 -0
- package/dist/src/middleware/builderOrAdmin.js +48 -0
- package/dist/src/middleware/builderOrAdmin.js.map +7 -0
- package/dist/src/middleware/csrf.js +60 -0
- package/dist/src/middleware/csrf.js.map +7 -0
- package/dist/src/middleware/errorHandling.js +62 -0
- package/dist/src/middleware/errorHandling.js.map +7 -0
- package/dist/src/middleware/index.js +95 -0
- package/dist/src/middleware/index.js.map +7 -0
- package/dist/src/middleware/internalApi.js +39 -0
- package/dist/src/middleware/internalApi.js.map +7 -0
- package/dist/src/middleware/joi-validator.js +73 -0
- package/dist/src/middleware/joi-validator.js.map +7 -0
- package/dist/src/middleware/matchers.js +62 -0
- package/dist/src/middleware/matchers.js.map +7 -0
- package/dist/src/middleware/passport/datasource/google.js +103 -0
- package/dist/src/middleware/passport/datasource/google.js.map +7 -0
- package/dist/src/middleware/passport/local.js +73 -0
- package/dist/src/middleware/passport/local.js.map +7 -0
- package/dist/src/middleware/passport/sso/google.js +93 -0
- package/dist/src/middleware/passport/sso/google.js.map +7 -0
- package/dist/src/middleware/passport/sso/oidc.js +135 -0
- package/dist/src/middleware/passport/sso/oidc.js.map +7 -0
- package/dist/src/middleware/passport/sso/sso.js +149 -0
- package/dist/src/middleware/passport/sso/sso.js.map +7 -0
- package/dist/src/middleware/passport/sso/tests/google.spec.js +77 -0
- package/dist/src/middleware/passport/sso/tests/google.spec.js.map +7 -0
- package/dist/src/middleware/passport/sso/tests/oidc.spec.js +143 -0
- package/dist/src/middleware/passport/sso/tests/oidc.spec.js.map +7 -0
- package/dist/src/middleware/passport/sso/tests/sso.spec.js +167 -0
- package/dist/src/middleware/passport/sso/tests/sso.spec.js.map +7 -0
- package/dist/src/middleware/passport/utils.js +62 -0
- package/dist/src/middleware/passport/utils.js.map +7 -0
- package/dist/src/middleware/querystringToBody.js +45 -0
- package/dist/src/middleware/querystringToBody.js.map +7 -0
- package/dist/src/middleware/tenancy.js +46 -0
- package/dist/src/middleware/tenancy.js.map +7 -0
- package/dist/src/middleware/tests/builder.spec.js +169 -0
- package/dist/src/middleware/tests/builder.spec.js.map +7 -0
- package/dist/src/middleware/tests/matchers.spec.js +120 -0
- package/dist/src/middleware/tests/matchers.spec.js.map +7 -0
- package/dist/src/migrations/definitions.js +63 -0
- package/dist/src/migrations/definitions.js.map +7 -0
- package/dist/src/migrations/index.js +25 -0
- package/dist/src/migrations/index.js.map +7 -0
- package/dist/src/migrations/migrations.js +178 -0
- package/dist/src/migrations/migrations.js.map +7 -0
- package/dist/src/migrations/tests/migrations.spec.js +78 -0
- package/dist/src/migrations/tests/migrations.spec.js.map +7 -0
- package/dist/src/objectStore/buckets/app.js +65 -0
- package/dist/src/objectStore/buckets/app.js.map +7 -0
- package/dist/src/objectStore/buckets/global.js +63 -0
- package/dist/src/objectStore/buckets/global.js.map +7 -0
- package/dist/src/objectStore/buckets/index.js +27 -0
- package/dist/src/objectStore/buckets/index.js.map +7 -0
- package/dist/src/objectStore/buckets/plugins.js +101 -0
- package/dist/src/objectStore/buckets/plugins.js.map +7 -0
- package/dist/src/objectStore/buckets/tests/app.spec.js +171 -0
- package/dist/src/objectStore/buckets/tests/app.spec.js.map +7 -0
- package/dist/src/objectStore/buckets/tests/global.spec.js +87 -0
- package/dist/src/objectStore/buckets/tests/global.spec.js.map +7 -0
- package/dist/src/objectStore/buckets/tests/plugins.spec.js +123 -0
- package/dist/src/objectStore/buckets/tests/plugins.spec.js.map +7 -0
- package/dist/src/objectStore/cloudfront.js +74 -0
- package/dist/src/objectStore/cloudfront.js.map +7 -0
- package/dist/src/objectStore/index.js +27 -0
- package/dist/src/objectStore/index.js.map +7 -0
- package/dist/src/objectStore/objectStore.js +372 -0
- package/dist/src/objectStore/objectStore.js.map +7 -0
- package/dist/src/objectStore/utils.js +58 -0
- package/dist/src/objectStore/utils.js.map +7 -0
- package/dist/src/platform/index.js +45 -0
- package/dist/src/platform/index.js.map +7 -0
- package/dist/src/platform/platformDb.js +33 -0
- package/dist/src/platform/platformDb.js.map +7 -0
- package/dist/src/platform/tenants.js +123 -0
- package/dist/src/platform/tenants.js.map +7 -0
- package/dist/src/platform/tests/tenants.spec.js +46 -0
- package/dist/src/platform/tests/tenants.spec.js.map +7 -0
- package/dist/src/platform/users.js +104 -0
- package/dist/src/platform/users.js.map +7 -0
- package/dist/src/plugin/index.js +23 -0
- package/dist/src/plugin/index.js.map +7 -0
- package/dist/src/plugin/tests/validation.spec.js +97 -0
- package/dist/src/plugin/tests/validation.spec.js.map +7 -0
- package/dist/src/plugin/utils.js +153 -0
- package/dist/src/plugin/utils.js.map +7 -0
- package/dist/src/queue/constants.js +35 -0
- package/dist/src/queue/constants.js.map +7 -0
- package/dist/src/queue/inMemoryQueue.js +139 -0
- package/dist/src/queue/inMemoryQueue.js.map +7 -0
- package/dist/src/queue/index.js +25 -0
- package/dist/src/queue/index.js.map +7 -0
- package/dist/src/queue/listeners.js +177 -0
- package/dist/src/queue/listeners.js.map +7 -0
- package/dist/src/queue/queue.js +85 -0
- package/dist/src/queue/queue.js.map +7 -0
- package/dist/src/redis/index.js +48 -0
- package/dist/src/redis/index.js.map +7 -0
- package/dist/src/redis/init.js +128 -0
- package/dist/src/redis/init.js.map +7 -0
- package/dist/src/redis/redis.js +277 -0
- package/dist/src/redis/redis.js.map +7 -0
- package/dist/src/redis/redlockImpl.js +145 -0
- package/dist/src/redis/redlockImpl.js.map +7 -0
- package/dist/src/redis/utils.js +136 -0
- package/dist/src/redis/utils.js.map +7 -0
- package/dist/src/security/encryption.js +184 -0
- package/dist/src/security/encryption.js.map +7 -0
- package/dist/src/security/permissions.js +188 -0
- package/dist/src/security/permissions.js.map +7 -0
- package/dist/src/security/roles.js +337 -0
- package/dist/src/security/roles.js.map +7 -0
- package/dist/src/security/sessions.js +135 -0
- package/dist/src/security/sessions.js.map +7 -0
- package/dist/src/security/tests/encryption.spec.js +51 -0
- package/dist/src/security/tests/encryption.spec.js.map +7 -0
- package/dist/src/security/tests/permissions.spec.js +154 -0
- package/dist/src/security/tests/permissions.spec.js.map +7 -0
- package/dist/src/security/tests/sessions.spec.js +33 -0
- package/dist/src/security/tests/sessions.spec.js.map +7 -0
- package/dist/src/tenancy/db.js +33 -0
- package/dist/src/tenancy/db.js.map +7 -0
- package/dist/src/tenancy/index.js +25 -0
- package/dist/src/tenancy/index.js.map +7 -0
- package/dist/src/tenancy/tenancy.js +129 -0
- package/dist/src/tenancy/tenancy.js.map +7 -0
- package/dist/src/tenancy/tests/tenancy.spec.js +154 -0
- package/dist/src/tenancy/tests/tenancy.spec.js.map +7 -0
- package/dist/src/timers/index.js +23 -0
- package/dist/src/timers/index.js.map +7 -0
- package/dist/src/timers/timers.js +51 -0
- package/dist/src/timers/timers.js.map +7 -0
- package/dist/src/users/db.js +381 -0
- package/dist/src/users/db.js.map +7 -0
- package/dist/src/users/events.js +152 -0
- package/dist/src/users/events.js.map +7 -0
- package/dist/src/users/index.js +36 -0
- package/dist/src/users/index.js.map +7 -0
- package/dist/src/users/lookup.js +110 -0
- package/dist/src/users/lookup.js.map +7 -0
- package/dist/src/users/users.js +257 -0
- package/dist/src/users/users.js.map +7 -0
- package/dist/src/users/utils.js +95 -0
- package/dist/src/users/utils.js.map +7 -0
- package/dist/src/utils/hashing.js +53 -0
- package/dist/src/utils/hashing.js.map +7 -0
- package/dist/src/utils/index.js +27 -0
- package/dist/src/utils/index.js.map +7 -0
- package/dist/src/utils/stringUtils.js +33 -0
- package/dist/src/utils/stringUtils.js.map +7 -0
- package/dist/src/utils/tests/utils.spec.js +165 -0
- package/dist/src/utils/tests/utils.spec.js.map +7 -0
- package/dist/src/utils/utils.js +207 -0
- package/dist/src/utils/utils.js.map +7 -0
- package/dist/tests/core/logging.js +57 -0
- package/dist/tests/core/logging.js.map +7 -0
- package/dist/tests/core/utilities/index.js +54 -0
- package/dist/tests/core/utilities/index.js.map +7 -0
- package/dist/tests/core/utilities/jestUtils.js +50 -0
- package/dist/tests/core/utilities/jestUtils.js.map +7 -0
- package/dist/tests/core/utilities/mocks/alerts.js +41 -0
- package/dist/tests/core/utilities/mocks/alerts.js.map +7 -0
- package/dist/tests/core/utilities/mocks/date.js +32 -0
- package/dist/tests/core/utilities/mocks/date.js.map +7 -0
- package/dist/tests/core/utilities/mocks/events.js +133 -0
- package/dist/tests/core/utilities/mocks/events.js.map +7 -0
- package/dist/tests/core/utilities/mocks/fetch.js +39 -0
- package/dist/tests/core/utilities/mocks/fetch.js.map +7 -0
- package/dist/tests/core/utilities/mocks/index.js +55 -0
- package/dist/tests/core/utilities/mocks/index.js.map +7 -0
- package/dist/tests/core/utilities/mocks/licenses.js +145 -0
- package/dist/tests/core/utilities/mocks/licenses.js.map +7 -0
- package/dist/tests/core/utilities/mocks/posthog.js +9 -0
- package/dist/tests/core/utilities/mocks/posthog.js.map +7 -0
- package/dist/tests/core/utilities/structures/Chance.js +48 -0
- package/dist/tests/core/utilities/structures/Chance.js.map +7 -0
- package/dist/tests/core/utilities/structures/accounts.js +148 -0
- package/dist/tests/core/utilities/structures/accounts.js.map +7 -0
- package/dist/tests/core/utilities/structures/apps.js +47 -0
- package/dist/tests/core/utilities/structures/apps.js.map +7 -0
- package/dist/tests/core/utilities/structures/common.js +35 -0
- package/dist/tests/core/utilities/structures/common.js.map +7 -0
- package/dist/tests/core/utilities/structures/db.js +40 -0
- package/dist/tests/core/utilities/structures/db.js.map +7 -0
- package/dist/tests/core/utilities/structures/documents/index.js +23 -0
- package/dist/tests/core/utilities/structures/documents/index.js.map +7 -0
- package/dist/tests/core/utilities/structures/documents/platform/index.js +39 -0
- package/dist/tests/core/utilities/structures/documents/platform/index.js.map +7 -0
- package/dist/tests/core/utilities/structures/documents/platform/installation.js +48 -0
- package/dist/tests/core/utilities/structures/documents/platform/installation.js.map +7 -0
- package/dist/tests/core/utilities/structures/generator.js +40 -0
- package/dist/tests/core/utilities/structures/generator.js.map +7 -0
- package/dist/tests/core/utilities/structures/index.js +81 -0
- package/dist/tests/core/utilities/structures/index.js.map +7 -0
- package/dist/tests/core/utilities/structures/koa.js +42 -0
- package/dist/tests/core/utilities/structures/koa.js.map +7 -0
- package/dist/tests/core/utilities/structures/licenses.js +175 -0
- package/dist/tests/core/utilities/structures/licenses.js.map +7 -0
- package/dist/tests/core/utilities/structures/plugins.js +46 -0
- package/dist/tests/core/utilities/structures/plugins.js.map +7 -0
- package/dist/tests/core/utilities/structures/quotas.js +94 -0
- package/dist/tests/core/utilities/structures/quotas.js.map +7 -0
- package/dist/tests/core/utilities/structures/scim.js +90 -0
- package/dist/tests/core/utilities/structures/scim.js.map +7 -0
- package/dist/tests/core/utilities/structures/shared.js +46 -0
- package/dist/tests/core/utilities/structures/shared.js.map +7 -0
- package/dist/tests/core/utilities/structures/sso.js +144 -0
- package/dist/tests/core/utilities/structures/sso.js.map +7 -0
- package/dist/tests/core/utilities/structures/tenants.js +32 -0
- package/dist/tests/core/utilities/structures/tenants.js.map +7 -0
- package/dist/tests/core/utilities/structures/userGroups.js +36 -0
- package/dist/tests/core/utilities/structures/userGroups.js.map +7 -0
- package/dist/tests/core/utilities/structures/users.js +96 -0
- package/dist/tests/core/utilities/structures/users.js.map +7 -0
- package/dist/tests/core/utilities/testContainerUtils.js +100 -0
- package/dist/tests/core/utilities/testContainerUtils.js.map +7 -0
- package/dist/tests/core/utilities/utils/index.js +39 -0
- package/dist/tests/core/utilities/utils/index.js.map +7 -0
- package/dist/tests/core/utilities/utils/time.js +31 -0
- package/dist/tests/core/utilities/utils/time.js.map +7 -0
- package/dist/tests/extra/DBTestConfiguration.js +61 -0
- package/dist/tests/extra/DBTestConfiguration.js.map +7 -0
- package/dist/tests/extra/index.js +42 -0
- package/dist/tests/extra/index.js.map +7 -0
- package/dist/tests/extra/testEnv.js +106 -0
- package/dist/tests/extra/testEnv.js.map +7 -0
- package/dist/tests/index.js +23 -0
- package/dist/tests/index.js.map +7 -0
- package/dist/tests/jestEnv.js +8 -0
- package/dist/tests/jestEnv.js.map +7 -0
- package/dist/tests/jestSetup.js +41 -0
- package/dist/tests/jestSetup.js.map +7 -0
- package/package.json +5 -5
- package/dist/tests.js +0 -8467
- package/dist/tests.js.map +0 -7
- package/dist/tests.js.meta.json +0 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var middleware_exports = {};
|
|
30
|
+
__export(middleware_exports, {
|
|
31
|
+
adminOnly: () => import_adminOnly.default,
|
|
32
|
+
auditLog: () => import_auditLog.default,
|
|
33
|
+
authError: () => import_utils.authError,
|
|
34
|
+
authenticated: () => import_authenticated.default,
|
|
35
|
+
builderOnly: () => import_builderOnly.default,
|
|
36
|
+
builderOrAdmin: () => import_builderOrAdmin.default,
|
|
37
|
+
correlation: () => import_middleware2.default,
|
|
38
|
+
csrf: () => import_csrf.default,
|
|
39
|
+
datasource: () => datasource,
|
|
40
|
+
errorHandling: () => import_errorHandling.default,
|
|
41
|
+
google: () => google,
|
|
42
|
+
internalApi: () => import_internalApi.default,
|
|
43
|
+
joiValidator: () => joiValidator,
|
|
44
|
+
local: () => local,
|
|
45
|
+
oidc: () => oidc,
|
|
46
|
+
pino: () => import_middleware.default,
|
|
47
|
+
querystringToBody: () => import_querystringToBody.default,
|
|
48
|
+
ssoCallbackUrl: () => import_utils.ssoCallbackUrl,
|
|
49
|
+
tenancy: () => import_tenancy.default
|
|
50
|
+
});
|
|
51
|
+
module.exports = __toCommonJS(middleware_exports);
|
|
52
|
+
var local = __toESM(require("./passport/local"));
|
|
53
|
+
var google = __toESM(require("./passport/sso/google"));
|
|
54
|
+
var oidc = __toESM(require("./passport/sso/oidc"));
|
|
55
|
+
var datasourceGoogle = __toESM(require("./passport/datasource/google"));
|
|
56
|
+
var import_utils = require("./passport/utils");
|
|
57
|
+
var import_authenticated = __toESM(require("./authenticated"));
|
|
58
|
+
var import_auditLog = __toESM(require("./auditLog"));
|
|
59
|
+
var import_tenancy = __toESM(require("./tenancy"));
|
|
60
|
+
var import_internalApi = __toESM(require("./internalApi"));
|
|
61
|
+
var import_csrf = __toESM(require("./csrf"));
|
|
62
|
+
var import_adminOnly = __toESM(require("./adminOnly"));
|
|
63
|
+
var import_builderOrAdmin = __toESM(require("./builderOrAdmin"));
|
|
64
|
+
var import_builderOnly = __toESM(require("./builderOnly"));
|
|
65
|
+
var import_middleware = __toESM(require("../logging/pino/middleware"));
|
|
66
|
+
var import_middleware2 = __toESM(require("../logging/correlation/middleware"));
|
|
67
|
+
var import_errorHandling = __toESM(require("./errorHandling"));
|
|
68
|
+
var import_querystringToBody = __toESM(require("./querystringToBody"));
|
|
69
|
+
var joiValidator = __toESM(require("./joi-validator"));
|
|
70
|
+
const datasource = {
|
|
71
|
+
google: datasourceGoogle
|
|
72
|
+
};
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
adminOnly,
|
|
76
|
+
auditLog,
|
|
77
|
+
authError,
|
|
78
|
+
authenticated,
|
|
79
|
+
builderOnly,
|
|
80
|
+
builderOrAdmin,
|
|
81
|
+
correlation,
|
|
82
|
+
csrf,
|
|
83
|
+
datasource,
|
|
84
|
+
errorHandling,
|
|
85
|
+
google,
|
|
86
|
+
internalApi,
|
|
87
|
+
joiValidator,
|
|
88
|
+
local,
|
|
89
|
+
oidc,
|
|
90
|
+
pino,
|
|
91
|
+
querystringToBody,
|
|
92
|
+
ssoCallbackUrl,
|
|
93
|
+
tenancy
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/middleware/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * as local from \"./passport/local\"\nexport * as google from \"./passport/sso/google\"\nexport * as oidc from \"./passport/sso/oidc\"\nimport * as datasourceGoogle from \"./passport/datasource/google\"\nexport const datasource = {\n google: datasourceGoogle,\n}\nexport { authError, ssoCallbackUrl } from \"./passport/utils\"\nexport { default as authenticated } from \"./authenticated\"\nexport { default as auditLog } from \"./auditLog\"\nexport { default as tenancy } from \"./tenancy\"\nexport { default as internalApi } from \"./internalApi\"\nexport { default as csrf } from \"./csrf\"\nexport { default as adminOnly } from \"./adminOnly\"\nexport { default as builderOrAdmin } from \"./builderOrAdmin\"\nexport { default as builderOnly } from \"./builderOnly\"\nexport { default as pino } from \"../logging/pino/middleware\"\nexport { default as correlation } from \"../logging/correlation/middleware\"\nexport { default as errorHandling } from \"./errorHandling\"\nexport { default as querystringToBody } from \"./querystringToBody\"\nexport * as joiValidator from \"./joi-validator\"\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,aAAwB;AACxB,WAAsB;AACtB,uBAAkC;AAIlC,mBAA0C;AAC1C,2BAAyC;AACzC,sBAAoC;AACpC,qBAAmC;AACnC,yBAAuC;AACvC,kBAAgC;AAChC,uBAAqC;AACrC,4BAA0C;AAC1C,yBAAuC;AACvC,wBAAgC;AAChC,IAAAA,qBAAuC;AACvC,2BAAyC;AACzC,+BAA6C;AAC7C,mBAA8B;AAhBvB,MAAM,aAAa;AAAA,EACxB,QAAQ;AACV;",
|
|
6
|
+
"names": ["import_middleware"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var internalApi_exports = {};
|
|
20
|
+
__export(internalApi_exports, {
|
|
21
|
+
default: () => internalApi_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(internalApi_exports);
|
|
24
|
+
var import_constants = require("../constants");
|
|
25
|
+
var import_utils = require("../utils");
|
|
26
|
+
var internalApi_default = async (ctx, next) => {
|
|
27
|
+
const apiKey = ctx.request.headers[import_constants.Header.API_KEY];
|
|
28
|
+
if (!apiKey) {
|
|
29
|
+
ctx.throw(403, "Unauthorized");
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(apiKey)) {
|
|
32
|
+
ctx.throw(403, "Unauthorized");
|
|
33
|
+
}
|
|
34
|
+
if (!(0, import_utils.isValidInternalAPIKey)(apiKey)) {
|
|
35
|
+
ctx.throw(403, "Unauthorized");
|
|
36
|
+
}
|
|
37
|
+
return next();
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=internalApi.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/middleware/internalApi.ts"],
|
|
4
|
+
"sourcesContent": ["import { Header } from \"../constants\"\nimport { BBContext } from \"@budibase/types\"\nimport { isValidInternalAPIKey } from \"../utils\"\n\n/**\n * API Key only endpoint.\n */\nexport default async (ctx: BBContext, next: any) => {\n const apiKey = ctx.request.headers[Header.API_KEY]\n if (!apiKey) {\n ctx.throw(403, \"Unauthorized\")\n }\n\n if (Array.isArray(apiKey)) {\n ctx.throw(403, \"Unauthorized\")\n }\n\n if (!isValidInternalAPIKey(apiKey)) {\n ctx.throw(403, \"Unauthorized\")\n }\n\n return next()\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAuB;AAEvB,mBAAsC;AAKtC,IAAO,sBAAQ,OAAO,KAAgB,SAAc;AAClD,QAAM,SAAS,IAAI,QAAQ,QAAQ,wBAAO,OAAO;AACjD,MAAI,CAAC,QAAQ;AACX,QAAI,MAAM,KAAK,cAAc;AAAA,EAC/B;AAEA,MAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,QAAI,MAAM,KAAK,cAAc;AAAA,EAC/B;AAEA,MAAI,KAAC,oCAAsB,MAAM,GAAG;AAClC,QAAI,MAAM,KAAK,cAAc;AAAA,EAC/B;AAEA,SAAO,KAAK;AACd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var joi_validator_exports = {};
|
|
30
|
+
__export(joi_validator_exports, {
|
|
31
|
+
body: () => body,
|
|
32
|
+
params: () => params
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(joi_validator_exports);
|
|
35
|
+
var import_joi = __toESM(require("joi"));
|
|
36
|
+
function validate(schema, property) {
|
|
37
|
+
return (ctx, next) => {
|
|
38
|
+
if (!schema) {
|
|
39
|
+
return next();
|
|
40
|
+
}
|
|
41
|
+
let params2 = null;
|
|
42
|
+
let reqProp = ctx.request?.[property];
|
|
43
|
+
if (ctx[property] != null) {
|
|
44
|
+
params2 = ctx[property];
|
|
45
|
+
} else if (reqProp != null) {
|
|
46
|
+
params2 = reqProp;
|
|
47
|
+
}
|
|
48
|
+
if (schema.append) {
|
|
49
|
+
schema = schema.append({
|
|
50
|
+
createdAt: import_joi.default.any().optional(),
|
|
51
|
+
updatedAt: import_joi.default.any().optional()
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const { error } = schema.validate(params2);
|
|
55
|
+
if (error) {
|
|
56
|
+
ctx.throw(400, `Invalid ${property} - ${error.message}`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
return next();
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function body(schema) {
|
|
63
|
+
return validate(schema, "body");
|
|
64
|
+
}
|
|
65
|
+
function params(schema) {
|
|
66
|
+
return validate(schema, "params");
|
|
67
|
+
}
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
body,
|
|
71
|
+
params
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=joi-validator.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/middleware/joi-validator.ts"],
|
|
4
|
+
"sourcesContent": ["import Joi, { ObjectSchema } from \"joi\"\nimport { BBContext } from \"@budibase/types\"\n\nfunction validate(\n schema: Joi.ObjectSchema | Joi.ArraySchema,\n property: string\n) {\n // Return a Koa middleware function\n return (ctx: BBContext, next: any) => {\n if (!schema) {\n return next()\n }\n let params = null\n // @ts-ignore\n let reqProp = ctx.request?.[property]\n if (ctx[property] != null) {\n params = ctx[property]\n } else if (reqProp != null) {\n params = reqProp\n }\n\n // not all schemas have the append property e.g. array schemas\n if ((schema as Joi.ObjectSchema).append) {\n schema = (schema as Joi.ObjectSchema).append({\n createdAt: Joi.any().optional(),\n updatedAt: Joi.any().optional(),\n })\n }\n\n const { error } = schema.validate(params)\n if (error) {\n ctx.throw(400, `Invalid ${property} - ${error.message}`)\n return\n }\n return next()\n }\n}\n\nexport function body(schema: Joi.ObjectSchema | Joi.ArraySchema) {\n return validate(schema, \"body\")\n}\n\nexport function params(schema: Joi.ObjectSchema | Joi.ArraySchema) {\n return validate(schema, \"params\")\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkC;AAGlC,SAAS,SACP,QACA,UACA;AAEA,SAAO,CAAC,KAAgB,SAAc;AACpC,QAAI,CAAC,QAAQ;AACX,aAAO,KAAK;AAAA,IACd;AACA,QAAIA,UAAS;AAEb,QAAI,UAAU,IAAI,UAAU,QAAQ;AACpC,QAAI,IAAI,QAAQ,KAAK,MAAM;AACzB,MAAAA,UAAS,IAAI,QAAQ;AAAA,IACvB,WAAW,WAAW,MAAM;AAC1B,MAAAA,UAAS;AAAA,IACX;AAGA,QAAK,OAA4B,QAAQ;AACvC,eAAU,OAA4B,OAAO;AAAA,QAC3C,WAAW,WAAAC,QAAI,IAAI,EAAE,SAAS;AAAA,QAC9B,WAAW,WAAAA,QAAI,IAAI,EAAE,SAAS;AAAA,MAChC,CAAC;AAAA,IACH;AAEA,UAAM,EAAE,MAAM,IAAI,OAAO,SAASD,OAAM;AACxC,QAAI,OAAO;AACT,UAAI,MAAM,KAAK,WAAW,QAAQ,MAAM,MAAM,OAAO,EAAE;AACvD;AAAA,IACF;AACA,WAAO,KAAK;AAAA,EACd;AACF;AAEO,SAAS,KAAK,QAA4C;AAC/D,SAAO,SAAS,QAAQ,MAAM;AAChC;AAEO,SAAS,OAAO,QAA4C;AACjE,SAAO,SAAS,QAAQ,QAAQ;AAClC;",
|
|
6
|
+
"names": ["params", "Joi"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var matchers_exports = {};
|
|
20
|
+
__export(matchers_exports, {
|
|
21
|
+
buildMatcherRegex: () => buildMatcherRegex,
|
|
22
|
+
matches: () => matches
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(matchers_exports);
|
|
25
|
+
const PARAM_REGEX = /\/:(.*?)(\/.*)?$/g;
|
|
26
|
+
const buildMatcherRegex = (patterns) => {
|
|
27
|
+
if (!patterns) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
return patterns.map((pattern) => {
|
|
31
|
+
let route = pattern.route;
|
|
32
|
+
const method = pattern.method;
|
|
33
|
+
const strict = pattern.strict ? pattern.strict : false;
|
|
34
|
+
const matches2 = route.match(PARAM_REGEX);
|
|
35
|
+
if (matches2) {
|
|
36
|
+
for (let match of matches2) {
|
|
37
|
+
const suffix = match.endsWith("/") ? "/" : "";
|
|
38
|
+
const pattern2 = "/.*" + suffix;
|
|
39
|
+
route = route.replace(match, pattern2);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { regex: new RegExp(route), method, strict, route };
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const matches = (ctx, options) => {
|
|
46
|
+
return options.find(({ regex, method, strict, route }) => {
|
|
47
|
+
let urlMatch;
|
|
48
|
+
if (strict) {
|
|
49
|
+
urlMatch = ctx.request.url === route;
|
|
50
|
+
} else {
|
|
51
|
+
urlMatch = regex.test(ctx.request.url);
|
|
52
|
+
}
|
|
53
|
+
const methodMatch = method === "ALL" ? true : ctx.request.method.toLowerCase() === method.toLowerCase();
|
|
54
|
+
return urlMatch && methodMatch;
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
buildMatcherRegex,
|
|
60
|
+
matches
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=matchers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/middleware/matchers.ts"],
|
|
4
|
+
"sourcesContent": ["import { BBContext, EndpointMatcher, RegexMatcher } from \"@budibase/types\"\n\nconst PARAM_REGEX = /\\/:(.*?)(\\/.*)?$/g\n\nexport const buildMatcherRegex = (\n patterns: EndpointMatcher[]\n): RegexMatcher[] => {\n if (!patterns) {\n return []\n }\n return patterns.map(pattern => {\n let route = pattern.route\n const method = pattern.method\n const strict = pattern.strict ? pattern.strict : false\n\n // if there is a param in the route\n // use a wildcard pattern\n const matches = route.match(PARAM_REGEX)\n if (matches) {\n for (let match of matches) {\n const suffix = match.endsWith(\"/\") ? \"/\" : \"\"\n const pattern = \"/.*\" + suffix\n route = route.replace(match, pattern)\n }\n }\n\n return { regex: new RegExp(route), method, strict, route }\n })\n}\n\nexport const matches = (ctx: BBContext, options: RegexMatcher[]) => {\n return options.find(({ regex, method, strict, route }) => {\n let urlMatch\n if (strict) {\n urlMatch = ctx.request.url === route\n } else {\n urlMatch = regex.test(ctx.request.url)\n }\n\n const methodMatch =\n method === \"ALL\"\n ? true\n : ctx.request.method.toLowerCase() === method.toLowerCase()\n\n return urlMatch && methodMatch\n })\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,MAAM,cAAc;AAEb,MAAM,oBAAoB,CAC/B,aACmB;AACnB,MAAI,CAAC,UAAU;AACb,WAAO,CAAC;AAAA,EACV;AACA,SAAO,SAAS,IAAI,aAAW;AAC7B,QAAI,QAAQ,QAAQ;AACpB,UAAM,SAAS,QAAQ;AACvB,UAAM,SAAS,QAAQ,SAAS,QAAQ,SAAS;AAIjD,UAAMA,WAAU,MAAM,MAAM,WAAW;AACvC,QAAIA,UAAS;AACX,eAAS,SAASA,UAAS;AACzB,cAAM,SAAS,MAAM,SAAS,GAAG,IAAI,MAAM;AAC3C,cAAMC,WAAU,QAAQ;AACxB,gBAAQ,MAAM,QAAQ,OAAOA,QAAO;AAAA,MACtC;AAAA,IACF;AAEA,WAAO,EAAE,OAAO,IAAI,OAAO,KAAK,GAAG,QAAQ,QAAQ,MAAM;AAAA,EAC3D,CAAC;AACH;AAEO,MAAM,UAAU,CAAC,KAAgB,YAA4B;AAClE,SAAO,QAAQ,KAAK,CAAC,EAAE,OAAO,QAAQ,QAAQ,MAAM,MAAM;AACxD,QAAI;AACJ,QAAI,QAAQ;AACV,iBAAW,IAAI,QAAQ,QAAQ;AAAA,IACjC,OAAO;AACL,iBAAW,MAAM,KAAK,IAAI,QAAQ,GAAG;AAAA,IACvC;AAEA,UAAM,cACJ,WAAW,QACP,OACA,IAAI,QAAQ,OAAO,YAAY,MAAM,OAAO,YAAY;AAE9D,WAAO,YAAY;AAAA,EACrB,CAAC;AACH;",
|
|
6
|
+
"names": ["matches", "pattern"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var google_exports = {};
|
|
30
|
+
__export(google_exports, {
|
|
31
|
+
postAuth: () => postAuth,
|
|
32
|
+
preAuth: () => preAuth
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(google_exports);
|
|
35
|
+
var google = __toESM(require("../sso/google"));
|
|
36
|
+
var import_constants = require("../../../constants");
|
|
37
|
+
var configs = __toESM(require("../../../configs"));
|
|
38
|
+
var cache = __toESM(require("../../../cache"));
|
|
39
|
+
var utils = __toESM(require("../../../utils"));
|
|
40
|
+
var import_sso = require("../sso/sso");
|
|
41
|
+
const GoogleStrategy = require("passport-google-oauth").OAuth2Strategy;
|
|
42
|
+
async function fetchGoogleCreds() {
|
|
43
|
+
let config = await configs.getGoogleDatasourceConfig();
|
|
44
|
+
if (!config) {
|
|
45
|
+
throw new Error("No google configuration found");
|
|
46
|
+
}
|
|
47
|
+
return config;
|
|
48
|
+
}
|
|
49
|
+
async function preAuth(passport, ctx, next) {
|
|
50
|
+
const googleConfig = await fetchGoogleCreds();
|
|
51
|
+
const platformUrl = await configs.getPlatformUrl({ tenantAware: false });
|
|
52
|
+
let callbackUrl = `${platformUrl}/api/global/auth/datasource/google/callback`;
|
|
53
|
+
const strategy = await google.strategyFactory(
|
|
54
|
+
googleConfig,
|
|
55
|
+
callbackUrl,
|
|
56
|
+
import_sso.ssoSaveUserNoOp
|
|
57
|
+
);
|
|
58
|
+
if (!ctx.query.appId) {
|
|
59
|
+
ctx.throw(400, "appId query param not present.");
|
|
60
|
+
}
|
|
61
|
+
return passport.authenticate(strategy, {
|
|
62
|
+
scope: ["profile", "email", "https://www.googleapis.com/auth/spreadsheets"],
|
|
63
|
+
accessType: "offline",
|
|
64
|
+
prompt: "consent"
|
|
65
|
+
})(ctx, next);
|
|
66
|
+
}
|
|
67
|
+
async function postAuth(passport, ctx, next) {
|
|
68
|
+
const config = await fetchGoogleCreds();
|
|
69
|
+
const platformUrl = await configs.getPlatformUrl({ tenantAware: false });
|
|
70
|
+
let callbackUrl = `${platformUrl}/api/global/auth/datasource/google/callback`;
|
|
71
|
+
const authStateCookie = utils.getCookie(ctx, import_constants.Cookie.DatasourceAuth);
|
|
72
|
+
return passport.authenticate(
|
|
73
|
+
new GoogleStrategy(
|
|
74
|
+
{
|
|
75
|
+
clientID: config.clientID,
|
|
76
|
+
clientSecret: config.clientSecret,
|
|
77
|
+
callbackURL: callbackUrl
|
|
78
|
+
},
|
|
79
|
+
(accessToken, refreshToken, _profile, done) => {
|
|
80
|
+
utils.clearCookie(ctx, import_constants.Cookie.DatasourceAuth);
|
|
81
|
+
done(null, { accessToken, refreshToken });
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
{ successRedirect: "/", failureRedirect: "/error" },
|
|
85
|
+
async (err, tokens) => {
|
|
86
|
+
const baseUrl = `/builder/app/${authStateCookie.appId}/data`;
|
|
87
|
+
const id = utils.newid();
|
|
88
|
+
await cache.store(
|
|
89
|
+
`datasource:creation:${authStateCookie.appId}:google:${id}`,
|
|
90
|
+
{
|
|
91
|
+
tokens
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
ctx.redirect(`${baseUrl}/new?continue_google_setup=${id}`);
|
|
95
|
+
}
|
|
96
|
+
)(ctx, next);
|
|
97
|
+
}
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {
|
|
100
|
+
postAuth,
|
|
101
|
+
preAuth
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=google.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/middleware/passport/datasource/google.ts"],
|
|
4
|
+
"sourcesContent": ["import * as google from \"../sso/google\"\nimport { Cookie } from \"../../../constants\"\nimport * as configs from \"../../../configs\"\nimport * as cache from \"../../../cache\"\nimport * as utils from \"../../../utils\"\nimport { UserCtx, SSOProfile } from \"@budibase/types\"\nimport { ssoSaveUserNoOp } from \"../sso/sso\"\n\nconst GoogleStrategy = require(\"passport-google-oauth\").OAuth2Strategy\n\ntype Passport = {\n authenticate: any\n}\n\nasync function fetchGoogleCreds() {\n let config = await configs.getGoogleDatasourceConfig()\n\n if (!config) {\n throw new Error(\"No google configuration found\")\n }\n return config\n}\n\nexport async function preAuth(\n passport: Passport,\n ctx: UserCtx,\n next: Function\n) {\n // get the relevant config\n const googleConfig = await fetchGoogleCreds()\n const platformUrl = await configs.getPlatformUrl({ tenantAware: false })\n\n let callbackUrl = `${platformUrl}/api/global/auth/datasource/google/callback`\n const strategy = await google.strategyFactory(\n googleConfig,\n callbackUrl,\n ssoSaveUserNoOp\n )\n\n if (!ctx.query.appId) {\n ctx.throw(400, \"appId query param not present.\")\n }\n\n return passport.authenticate(strategy, {\n scope: [\"profile\", \"email\", \"https://www.googleapis.com/auth/spreadsheets\"],\n accessType: \"offline\",\n prompt: \"consent\",\n })(ctx, next)\n}\n\nexport async function postAuth(\n passport: Passport,\n ctx: UserCtx,\n next: Function\n) {\n // get the relevant config\n const config = await fetchGoogleCreds()\n const platformUrl = await configs.getPlatformUrl({ tenantAware: false })\n\n let callbackUrl = `${platformUrl}/api/global/auth/datasource/google/callback`\n const authStateCookie = utils.getCookie(ctx, Cookie.DatasourceAuth)\n\n return passport.authenticate(\n new GoogleStrategy(\n {\n clientID: config.clientID,\n clientSecret: config.clientSecret,\n callbackURL: callbackUrl,\n },\n (\n accessToken: string,\n refreshToken: string,\n _profile: SSOProfile,\n done: Function\n ) => {\n utils.clearCookie(ctx, Cookie.DatasourceAuth)\n done(null, { accessToken, refreshToken })\n }\n ),\n { successRedirect: \"/\", failureRedirect: \"/error\" },\n async (err: any, tokens: string[]) => {\n const baseUrl = `/builder/app/${authStateCookie.appId}/data`\n\n const id = utils.newid()\n await cache.store(\n `datasource:creation:${authStateCookie.appId}:google:${id}`,\n {\n tokens,\n }\n )\n\n ctx.redirect(`${baseUrl}/new?continue_google_setup=${id}`)\n }\n )(ctx, next)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,uBAAuB;AACvB,cAAyB;AACzB,YAAuB;AACvB,YAAuB;AAEvB,iBAAgC;AAEhC,MAAM,iBAAiB,QAAQ,uBAAuB,EAAE;AAMxD,eAAe,mBAAmB;AAChC,MAAI,SAAS,MAAM,QAAQ,0BAA0B;AAErD,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AACA,SAAO;AACT;AAEA,eAAsB,QACpB,UACA,KACA,MACA;AAEA,QAAM,eAAe,MAAM,iBAAiB;AAC5C,QAAM,cAAc,MAAM,QAAQ,eAAe,EAAE,aAAa,MAAM,CAAC;AAEvE,MAAI,cAAc,GAAG,WAAW;AAChC,QAAM,WAAW,MAAM,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,CAAC,IAAI,MAAM,OAAO;AACpB,QAAI,MAAM,KAAK,gCAAgC;AAAA,EACjD;AAEA,SAAO,SAAS,aAAa,UAAU;AAAA,IACrC,OAAO,CAAC,WAAW,SAAS,8CAA8C;AAAA,IAC1E,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV,CAAC,EAAE,KAAK,IAAI;AACd;AAEA,eAAsB,SACpB,UACA,KACA,MACA;AAEA,QAAM,SAAS,MAAM,iBAAiB;AACtC,QAAM,cAAc,MAAM,QAAQ,eAAe,EAAE,aAAa,MAAM,CAAC;AAEvE,MAAI,cAAc,GAAG,WAAW;AAChC,QAAM,kBAAkB,MAAM,UAAU,KAAK,wBAAO,cAAc;AAElE,SAAO,SAAS;AAAA,IACd,IAAI;AAAA,MACF;AAAA,QACE,UAAU,OAAO;AAAA,QACjB,cAAc,OAAO;AAAA,QACrB,aAAa;AAAA,MACf;AAAA,MACA,CACE,aACA,cACA,UACA,SACG;AACH,cAAM,YAAY,KAAK,wBAAO,cAAc;AAC5C,aAAK,MAAM,EAAE,aAAa,aAAa,CAAC;AAAA,MAC1C;AAAA,IACF;AAAA,IACA,EAAE,iBAAiB,KAAK,iBAAiB,SAAS;AAAA,IAClD,OAAO,KAAU,WAAqB;AACpC,YAAM,UAAU,gBAAgB,gBAAgB,KAAK;AAErD,YAAM,KAAK,MAAM,MAAM;AACvB,YAAM,MAAM;AAAA,QACV,uBAAuB,gBAAgB,KAAK,WAAW,EAAE;AAAA,QACzD;AAAA,UACE;AAAA,QACF;AAAA,MACF;AAEA,UAAI,SAAS,GAAG,OAAO,8BAA8B,EAAE,EAAE;AAAA,IAC3D;AAAA,EACF,EAAE,KAAK,IAAI;AACb;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var local_exports = {};
|
|
30
|
+
__export(local_exports, {
|
|
31
|
+
authenticate: () => authenticate,
|
|
32
|
+
options: () => options
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(local_exports);
|
|
35
|
+
var import_constants = require("../../constants");
|
|
36
|
+
var import_utils = require("../../utils");
|
|
37
|
+
var users = __toESM(require("../../users"));
|
|
38
|
+
var import_utils2 = require("./utils");
|
|
39
|
+
const INVALID_ERR = "Invalid credentials";
|
|
40
|
+
const EXPIRED = "This account has expired. Please reset your password";
|
|
41
|
+
const options = {
|
|
42
|
+
passReqToCallback: true
|
|
43
|
+
};
|
|
44
|
+
async function authenticate(ctx, email, password, done) {
|
|
45
|
+
if (!email)
|
|
46
|
+
return (0, import_utils2.authError)(done, "Email Required");
|
|
47
|
+
if (!password)
|
|
48
|
+
return (0, import_utils2.authError)(done, "Password Required");
|
|
49
|
+
const dbUser = await users.getGlobalUserByEmail(email);
|
|
50
|
+
if (dbUser == null) {
|
|
51
|
+
console.info(`user=${email} could not be found`);
|
|
52
|
+
return (0, import_utils2.authError)(done, INVALID_ERR);
|
|
53
|
+
}
|
|
54
|
+
if (dbUser.status === import_constants.UserStatus.INACTIVE) {
|
|
55
|
+
console.info(`user=${email} is inactive`, dbUser);
|
|
56
|
+
return (0, import_utils2.authError)(done, INVALID_ERR);
|
|
57
|
+
}
|
|
58
|
+
if (!dbUser.password) {
|
|
59
|
+
console.info(`user=${email} has no password set`, dbUser);
|
|
60
|
+
return (0, import_utils2.authError)(done, EXPIRED);
|
|
61
|
+
}
|
|
62
|
+
if (!await (0, import_utils.compare)(password, dbUser.password)) {
|
|
63
|
+
return (0, import_utils2.authError)(done, INVALID_ERR);
|
|
64
|
+
}
|
|
65
|
+
delete dbUser.password;
|
|
66
|
+
return done(null, dbUser);
|
|
67
|
+
}
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
authenticate,
|
|
71
|
+
options
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/middleware/passport/local.ts"],
|
|
4
|
+
"sourcesContent": ["import { UserStatus } from \"../../constants\"\nimport { compare } from \"../../utils\"\nimport * as users from \"../../users\"\nimport { authError } from \"./utils\"\nimport { BBContext } from \"@budibase/types\"\n\nconst INVALID_ERR = \"Invalid credentials\"\nconst EXPIRED = \"This account has expired. Please reset your password\"\n\nexport const options = {\n passReqToCallback: true,\n}\n\n/**\n * Passport Local Authentication Middleware.\n * @param {*} ctx the request structure\n * @param {*} email username to login with\n * @param {*} password plain text password to log in with\n * @param {*} done callback from passport to return user information and errors\n * @returns The authenticated user, or errors if they occur\n */\nexport async function authenticate(\n ctx: BBContext,\n email: string,\n password: string,\n done: Function\n) {\n if (!email) return authError(done, \"Email Required\")\n if (!password) return authError(done, \"Password Required\")\n\n const dbUser = await users.getGlobalUserByEmail(email)\n if (dbUser == null) {\n console.info(`user=${email} could not be found`)\n return authError(done, INVALID_ERR)\n }\n\n if (dbUser.status === UserStatus.INACTIVE) {\n console.info(`user=${email} is inactive`, dbUser)\n return authError(done, INVALID_ERR)\n }\n\n if (!dbUser.password) {\n console.info(`user=${email} has no password set`, dbUser)\n return authError(done, EXPIRED)\n }\n\n if (!(await compare(password, dbUser.password))) {\n return authError(done, INVALID_ERR)\n }\n\n // intentionally remove the users password in payload\n delete dbUser.password\n return done(null, dbUser)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA2B;AAC3B,mBAAwB;AACxB,YAAuB;AACvB,IAAAA,gBAA0B;AAG1B,MAAM,cAAc;AACpB,MAAM,UAAU;AAET,MAAM,UAAU;AAAA,EACrB,mBAAmB;AACrB;AAUA,eAAsB,aACpB,KACA,OACA,UACA,MACA;AACA,MAAI,CAAC;AAAO,eAAO,yBAAU,MAAM,gBAAgB;AACnD,MAAI,CAAC;AAAU,eAAO,yBAAU,MAAM,mBAAmB;AAEzD,QAAM,SAAS,MAAM,MAAM,qBAAqB,KAAK;AACrD,MAAI,UAAU,MAAM;AAClB,YAAQ,KAAK,QAAQ,KAAK,qBAAqB;AAC/C,eAAO,yBAAU,MAAM,WAAW;AAAA,EACpC;AAEA,MAAI,OAAO,WAAW,4BAAW,UAAU;AACzC,YAAQ,KAAK,QAAQ,KAAK,gBAAgB,MAAM;AAChD,eAAO,yBAAU,MAAM,WAAW;AAAA,EACpC;AAEA,MAAI,CAAC,OAAO,UAAU;AACpB,YAAQ,KAAK,QAAQ,KAAK,wBAAwB,MAAM;AACxD,eAAO,yBAAU,MAAM,OAAO;AAAA,EAChC;AAEA,MAAI,CAAE,UAAM,sBAAQ,UAAU,OAAO,QAAQ,GAAI;AAC/C,eAAO,yBAAU,MAAM,WAAW;AAAA,EACpC;AAGA,SAAO,OAAO;AACd,SAAO,KAAK,MAAM,MAAM;AAC1B;",
|
|
6
|
+
"names": ["import_utils"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var google_exports = {};
|
|
30
|
+
__export(google_exports, {
|
|
31
|
+
buildVerifyFn: () => buildVerifyFn,
|
|
32
|
+
getCallbackUrl: () => getCallbackUrl,
|
|
33
|
+
strategyFactory: () => strategyFactory
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(google_exports);
|
|
36
|
+
var import_utils = require("../utils");
|
|
37
|
+
var sso = __toESM(require("./sso"));
|
|
38
|
+
var import_types = require("@budibase/types");
|
|
39
|
+
const GoogleStrategy = require("passport-google-oauth").OAuth2Strategy;
|
|
40
|
+
function buildVerifyFn(saveUserFn) {
|
|
41
|
+
return (accessToken, refreshToken, profile, done) => {
|
|
42
|
+
const details = {
|
|
43
|
+
provider: "google",
|
|
44
|
+
providerType: import_types.SSOProviderType.GOOGLE,
|
|
45
|
+
userId: profile.id,
|
|
46
|
+
profile,
|
|
47
|
+
email: profile._json.email,
|
|
48
|
+
oauth2: {
|
|
49
|
+
accessToken,
|
|
50
|
+
refreshToken
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return sso.authenticate(
|
|
54
|
+
details,
|
|
55
|
+
true,
|
|
56
|
+
// require local accounts to exist
|
|
57
|
+
done,
|
|
58
|
+
saveUserFn
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async function strategyFactory(config, callbackUrl, saveUserFn) {
|
|
63
|
+
try {
|
|
64
|
+
const { clientID, clientSecret } = config;
|
|
65
|
+
if (!clientID || !clientSecret) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
"Configuration invalid. Must contain google clientID and clientSecret"
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
const verify = buildVerifyFn(saveUserFn);
|
|
71
|
+
return new GoogleStrategy(
|
|
72
|
+
{
|
|
73
|
+
clientID: config.clientID,
|
|
74
|
+
clientSecret: config.clientSecret,
|
|
75
|
+
callbackURL: callbackUrl
|
|
76
|
+
},
|
|
77
|
+
verify
|
|
78
|
+
);
|
|
79
|
+
} catch (err) {
|
|
80
|
+
console.error(err);
|
|
81
|
+
throw new Error(`Error constructing google authentication strategy: ${err}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function getCallbackUrl(config) {
|
|
85
|
+
return (0, import_utils.ssoCallbackUrl)(import_types.ConfigType.GOOGLE, config);
|
|
86
|
+
}
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
buildVerifyFn,
|
|
90
|
+
getCallbackUrl,
|
|
91
|
+
strategyFactory
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=google.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/middleware/passport/sso/google.ts"],
|
|
4
|
+
"sourcesContent": ["import { ssoCallbackUrl } from \"../utils\"\nimport * as sso from \"./sso\"\nimport {\n ConfigType,\n SSOProfile,\n SSOAuthDetails,\n SSOProviderType,\n SaveSSOUserFunction,\n GoogleInnerConfig,\n} from \"@budibase/types\"\nconst GoogleStrategy = require(\"passport-google-oauth\").OAuth2Strategy\n\nexport function buildVerifyFn(saveUserFn: SaveSSOUserFunction) {\n return (\n accessToken: string,\n refreshToken: string,\n profile: SSOProfile,\n done: Function\n ) => {\n const details: SSOAuthDetails = {\n provider: \"google\",\n providerType: SSOProviderType.GOOGLE,\n userId: profile.id,\n profile: profile,\n email: profile._json.email,\n oauth2: {\n accessToken,\n refreshToken,\n },\n }\n\n return sso.authenticate(\n details,\n true, // require local accounts to exist\n done,\n saveUserFn\n )\n }\n}\n\n/**\n * Create an instance of the google passport strategy. This wrapper fetches the configuration\n * from couchDB rather than environment variables, using this factory is necessary for dynamically configuring passport.\n * @returns Dynamically configured Passport Google Strategy\n */\nexport async function strategyFactory(\n config: GoogleInnerConfig,\n callbackUrl: string,\n saveUserFn: SaveSSOUserFunction\n) {\n try {\n const { clientID, clientSecret } = config\n\n if (!clientID || !clientSecret) {\n throw new Error(\n \"Configuration invalid. Must contain google clientID and clientSecret\"\n )\n }\n\n const verify = buildVerifyFn(saveUserFn)\n return new GoogleStrategy(\n {\n clientID: config.clientID,\n clientSecret: config.clientSecret,\n callbackURL: callbackUrl,\n },\n verify\n )\n } catch (err: any) {\n console.error(err)\n throw new Error(`Error constructing google authentication strategy: ${err}`)\n }\n}\n\nexport async function getCallbackUrl(config: GoogleInnerConfig) {\n return ssoCallbackUrl(ConfigType.GOOGLE, config)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAC/B,UAAqB;AACrB,mBAOO;AACP,MAAM,iBAAiB,QAAQ,uBAAuB,EAAE;AAEjD,SAAS,cAAc,YAAiC;AAC7D,SAAO,CACL,aACA,cACA,SACA,SACG;AACH,UAAM,UAA0B;AAAA,MAC9B,UAAU;AAAA,MACV,cAAc,6BAAgB;AAAA,MAC9B,QAAQ,QAAQ;AAAA,MAChB;AAAA,MACA,OAAO,QAAQ,MAAM;AAAA,MACrB,QAAQ;AAAA,QACN;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,IAAI;AAAA,MACT;AAAA,MACA;AAAA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAOA,eAAsB,gBACpB,QACA,aACA,YACA;AACA,MAAI;AACF,UAAM,EAAE,UAAU,aAAa,IAAI;AAEnC,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,SAAS,cAAc,UAAU;AACvC,WAAO,IAAI;AAAA,MACT;AAAA,QACE,UAAU,OAAO;AAAA,QACjB,cAAc,OAAO;AAAA,QACrB,aAAa;AAAA,MACf;AAAA,MACA;AAAA,IACF;AAAA,EACF,SAAS,KAAU;AACjB,YAAQ,MAAM,GAAG;AACjB,UAAM,IAAI,MAAM,sDAAsD,GAAG,EAAE;AAAA,EAC7E;AACF;AAEA,eAAsB,eAAe,QAA2B;AAC9D,aAAO,6BAAe,wBAAW,QAAQ,MAAM;AACjD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|