directus 9.23.1 → 9.23.4
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/app.js +25 -21
- package/dist/auth/auth.d.ts +3 -3
- package/dist/auth/auth.js +2 -0
- package/dist/auth/drivers/ldap.d.ts +1 -1
- package/dist/auth/drivers/ldap.js +57 -46
- package/dist/auth/drivers/local.d.ts +1 -1
- package/dist/auth/drivers/local.js +20 -17
- package/dist/auth/drivers/oauth2.d.ts +1 -1
- package/dist/auth/drivers/oauth2.js +44 -35
- package/dist/auth/drivers/openid.d.ts +1 -1
- package/dist/auth/drivers/openid.js +50 -41
- package/dist/auth/drivers/saml.d.ts +1 -1
- package/dist/auth/drivers/saml.js +20 -17
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +8 -7
- package/dist/cache.d.ts +9 -1
- package/dist/cache.js +66 -18
- package/dist/cli/commands/bootstrap/index.js +7 -6
- package/dist/cli/commands/init/index.js +3 -3
- package/dist/cli/commands/schema/apply.js +14 -15
- package/dist/cli/commands/schema/snapshot.js +2 -2
- package/dist/cli/utils/create-db-connection.d.ts +1 -1
- package/dist/cli/utils/create-db-connection.js +3 -2
- package/dist/cli/utils/create-env/index.d.ts +2 -2
- package/dist/cli/utils/create-env/index.js +1 -1
- package/dist/cli/utils/drivers.d.ts +1 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +7 -7
- package/dist/controllers/activity.js +10 -11
- package/dist/controllers/assets.js +31 -25
- package/dist/controllers/auth.js +40 -26
- package/dist/controllers/collections.js +10 -10
- package/dist/controllers/dashboards.js +14 -11
- package/dist/controllers/extensions.js +3 -3
- package/dist/controllers/fields.js +20 -20
- package/dist/controllers/files.js +26 -20
- package/dist/controllers/flows.js +16 -13
- package/dist/controllers/folders.js +14 -11
- package/dist/controllers/graphql.js +6 -8
- package/dist/controllers/items.js +22 -19
- package/dist/controllers/not-found.d.ts +1 -1
- package/dist/controllers/not-found.js +1 -2
- package/dist/controllers/notifications.js +14 -11
- package/dist/controllers/operations.js +14 -11
- package/dist/controllers/panels.js +14 -11
- package/dist/controllers/permissions.js +14 -11
- package/dist/controllers/presets.js +14 -11
- package/dist/controllers/relations.js +10 -10
- package/dist/controllers/revisions.js +3 -3
- package/dist/controllers/roles.js +14 -11
- package/dist/controllers/schema.js +5 -5
- package/dist/controllers/server.js +7 -7
- package/dist/controllers/settings.js +2 -2
- package/dist/controllers/shares.js +21 -18
- package/dist/controllers/users.js +32 -36
- package/dist/controllers/utils.js +10 -15
- package/dist/controllers/webhooks.js +14 -11
- package/dist/database/helpers/fn/dialects/mssql.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/mssql.js +10 -11
- package/dist/database/helpers/fn/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/mysql.js +2 -3
- package/dist/database/helpers/fn/dialects/oracle.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/oracle.js +10 -11
- package/dist/database/helpers/fn/dialects/postgres.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/postgres.js +10 -11
- package/dist/database/helpers/fn/dialects/sqlite.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/sqlite.js +10 -11
- package/dist/database/helpers/fn/types.d.ts +5 -6
- package/dist/database/helpers/fn/types.js +4 -5
- package/dist/database/helpers/geometry/dialects/mssql.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/geometry/dialects/oracle.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/postgres.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/postgres.js +1 -2
- package/dist/database/helpers/geometry/dialects/redshift.d.ts +2 -2
- package/dist/database/helpers/geometry/dialects/sqlite.d.ts +1 -1
- package/dist/database/helpers/geometry/types.d.ts +2 -2
- package/dist/database/helpers/geometry/types.js +1 -2
- package/dist/database/helpers/index.d.ts +5 -5
- package/dist/database/helpers/schema/dialects/cockroachdb.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mssql.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mysql.js +1 -2
- package/dist/database/helpers/schema/dialects/oracle.d.ts +2 -2
- package/dist/database/helpers/schema/dialects/oracle.js +4 -6
- package/dist/database/helpers/schema/types.d.ts +4 -4
- package/dist/database/helpers/types.d.ts +1 -1
- package/dist/database/helpers/types.js +1 -0
- package/dist/database/index.d.ts +1 -1
- package/dist/database/index.js +13 -13
- package/dist/database/migrations/20201028A-remove-collection-foreign-keys.d.ts +1 -1
- package/dist/database/migrations/20201029A-remove-system-relations.d.ts +1 -1
- package/dist/database/migrations/20201029B-remove-system-collections.d.ts +1 -1
- package/dist/database/migrations/20201029C-remove-system-fields.d.ts +1 -1
- package/dist/database/migrations/20201105A-add-cascade-system-relations.d.ts +1 -1
- package/dist/database/migrations/20201105B-change-webhook-url-type.d.ts +1 -1
- package/dist/database/migrations/20210225A-add-relations-sort-field.d.ts +1 -1
- package/dist/database/migrations/20210225A-add-relations-sort-field.js +1 -2
- package/dist/database/migrations/20210304A-remove-locked-fields.d.ts +1 -1
- package/dist/database/migrations/20210312A-webhooks-collections-text.d.ts +1 -1
- package/dist/database/migrations/20210331A-add-refresh-interval.d.ts +1 -1
- package/dist/database/migrations/20210415A-make-filesize-nullable.d.ts +1 -1
- package/dist/database/migrations/20210416A-add-collections-accountability.d.ts +1 -1
- package/dist/database/migrations/20210422A-remove-files-interface.d.ts +1 -1
- package/dist/database/migrations/20210506A-rename-interfaces.d.ts +1 -1
- package/dist/database/migrations/20210510A-restructure-relations.d.ts +1 -1
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.d.ts +1 -1
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.js +1 -1
- package/dist/database/migrations/20210519A-add-system-fk-triggers.d.ts +1 -1
- package/dist/database/migrations/20210519A-add-system-fk-triggers.js +2 -2
- package/dist/database/migrations/20210521A-add-collections-icon-color.d.ts +1 -1
- package/dist/database/migrations/20210525A-add-insights.d.ts +1 -1
- package/dist/database/migrations/20210608A-add-deep-clone-config.d.ts +1 -1
- package/dist/database/migrations/20210626A-change-filesize-bigint.d.ts +1 -1
- package/dist/database/migrations/20210716A-add-conditions-to-fields.d.ts +1 -1
- package/dist/database/migrations/20210721A-add-default-folder.d.ts +1 -1
- package/dist/database/migrations/20210802A-replace-groups.d.ts +1 -1
- package/dist/database/migrations/20210803A-add-required-to-fields.d.ts +1 -1
- package/dist/database/migrations/20210805A-update-groups.d.ts +1 -1
- package/dist/database/migrations/20210805B-change-image-metadata-structure.d.ts +1 -1
- package/dist/database/migrations/20210805B-change-image-metadata-structure.js +15 -15
- package/dist/database/migrations/20210811A-add-geometry-config.d.ts +1 -1
- package/dist/database/migrations/20210831A-remove-limit-column.d.ts +1 -1
- package/dist/database/migrations/20210903A-add-auth-provider.d.ts +1 -1
- package/dist/database/migrations/20210907A-webhooks-collections-not-null.d.ts +1 -1
- package/dist/database/migrations/20210910A-move-module-setup.d.ts +1 -1
- package/dist/database/migrations/20210920A-webhooks-url-not-null.d.ts +1 -1
- package/dist/database/migrations/20210924A-add-collection-organization.d.ts +1 -1
- package/dist/database/migrations/20210927A-replace-fields-group.d.ts +1 -1
- package/dist/database/migrations/20210927B-replace-m2m-interface.d.ts +1 -1
- package/dist/database/migrations/20210929A-rename-login-action.d.ts +1 -1
- package/dist/database/migrations/20211007A-update-presets.d.ts +1 -1
- package/dist/database/migrations/20211007A-update-presets.js +7 -9
- package/dist/database/migrations/20211009A-add-auth-data.d.ts +1 -1
- package/dist/database/migrations/20211016A-add-webhook-headers.d.ts +1 -1
- package/dist/database/migrations/20211103A-set-unique-to-user-token.d.ts +1 -1
- package/dist/database/migrations/20211103B-update-special-geometry.d.ts +1 -1
- package/dist/database/migrations/20211104A-remove-collections-listing.d.ts +1 -1
- package/dist/database/migrations/20211118A-add-notifications.d.ts +1 -1
- package/dist/database/migrations/20211211A-add-shares.d.ts +1 -1
- package/dist/database/migrations/20211230A-add-project-descriptor.d.ts +1 -1
- package/dist/database/migrations/20220303A-remove-default-project-color.d.ts +1 -1
- package/dist/database/migrations/20220308A-add-bookmark-icon-and-color.d.ts +1 -1
- package/dist/database/migrations/20220314A-add-translation-strings.d.ts +1 -1
- package/dist/database/migrations/20220322A-rename-field-typecast-flags.d.ts +1 -1
- package/dist/database/migrations/20220323A-add-field-validation.d.ts +1 -1
- package/dist/database/migrations/20220325A-fix-typecast-flags.d.ts +1 -1
- package/dist/database/migrations/20220325B-add-default-language.d.ts +1 -1
- package/dist/database/migrations/20220402A-remove-default-value-panel-icon.d.ts +1 -1
- package/dist/database/migrations/20220429A-add-flows.d.ts +1 -1
- package/dist/database/migrations/20220429B-add-color-to-insights-icon.d.ts +1 -1
- package/dist/database/migrations/20220429C-drop-non-null-from-ip-of-activity.d.ts +1 -1
- package/dist/database/migrations/20220429D-drop-non-null-from-sender-of-notifications.d.ts +1 -1
- package/dist/database/migrations/20220614A-rename-hook-trigger-to-event.d.ts +1 -1
- package/dist/database/migrations/20220801A-update-notifications-timestamp-column.d.ts +1 -1
- package/dist/database/migrations/20220802A-add-custom-aspect-ratios.d.ts +1 -1
- package/dist/database/migrations/20220826A-add-origin-to-accountability.d.ts +1 -1
- package/dist/database/migrations/run.d.ts +1 -1
- package/dist/database/migrations/run.js +1 -1
- package/dist/database/run-ast.d.ts +3 -3
- package/dist/database/run-ast.js +21 -30
- package/dist/database/seeds/run.d.ts +1 -1
- package/dist/database/seeds/run.js +1 -2
- package/dist/database/system-data/app-access-permissions/index.d.ts +1 -1
- package/dist/database/system-data/collections/index.d.ts +1 -1
- package/dist/database/system-data/collections/index.js +2 -2
- package/dist/database/system-data/fields/collections.yaml +2 -0
- package/dist/database/system-data/fields/index.d.ts +1 -1
- package/dist/database/system-data/fields/index.js +3 -4
- package/dist/database/system-data/fields/settings.yaml +4 -0
- package/dist/database/system-data/relations/index.d.ts +1 -1
- package/dist/emitter.d.ts +1 -1
- package/dist/emitter.js +3 -0
- package/dist/env.js +11 -3
- package/dist/exceptions/database/dialects/mssql.d.ts +1 -1
- package/dist/exceptions/database/dialects/mssql.js +5 -6
- package/dist/exceptions/database/dialects/mysql.d.ts +1 -1
- package/dist/exceptions/database/dialects/mysql.js +19 -25
- package/dist/exceptions/database/dialects/oracle.d.ts +1 -1
- package/dist/exceptions/database/dialects/postgres.d.ts +1 -1
- package/dist/exceptions/database/dialects/sqlite.d.ts +1 -1
- package/dist/exceptions/database/translate.d.ts +1 -1
- package/dist/exceptions/database/value-out-of-range.js +1 -1
- package/dist/exceptions/range-not-satisfiable.js +2 -3
- package/dist/extensions.d.ts +1 -1
- package/dist/extensions.js +43 -33
- package/dist/flows.js +65 -46
- package/dist/logger.d.ts +2 -1
- package/dist/logger.js +35 -19
- package/dist/logger.test.d.ts +1 -0
- package/dist/mailer.js +16 -16
- package/dist/messenger.js +9 -7
- package/dist/middleware/authenticate.d.ts +1 -1
- package/dist/middleware/authenticate.js +13 -6
- package/dist/middleware/cache.d.ts +1 -1
- package/dist/middleware/cache.js +16 -16
- package/dist/middleware/check-ip.d.ts +1 -1
- package/dist/middleware/check-ip.js +1 -1
- package/dist/middleware/collection-exists.d.ts +1 -1
- package/dist/middleware/collection-exists.js +5 -5
- package/dist/middleware/cors.d.ts +1 -1
- package/dist/middleware/cors.js +7 -7
- package/dist/middleware/error-handler.d.ts +1 -1
- package/dist/middleware/error-handler.js +11 -12
- package/dist/middleware/extract-token.d.ts +1 -1
- package/dist/middleware/extract-token.js +2 -2
- package/dist/middleware/get-permissions.d.ts +1 -1
- package/dist/middleware/graphql.d.ts +1 -1
- package/dist/middleware/graphql.js +15 -9
- package/dist/middleware/rate-limiter-global.d.ts +5 -0
- package/dist/middleware/rate-limiter-global.js +48 -0
- package/dist/middleware/{rate-limiter.d.ts → rate-limiter-ip.d.ts} +2 -2
- package/dist/middleware/{rate-limiter.js → rate-limiter-ip.js} +5 -5
- package/dist/middleware/respond.d.ts +1 -1
- package/dist/middleware/respond.js +18 -19
- package/dist/middleware/sanitize-query.d.ts +1 -1
- package/dist/middleware/sanitize-query.js +1 -1
- package/dist/middleware/schema.d.ts +1 -1
- package/dist/middleware/use-collection.d.ts +1 -1
- package/dist/operations/condition/index.d.ts +1 -1
- package/dist/operations/exec/index.js +15 -4
- package/dist/operations/item-create/index.js +1 -2
- package/dist/operations/item-delete/index.d.ts +1 -1
- package/dist/operations/item-read/index.d.ts +1 -1
- package/dist/operations/item-update/index.d.ts +1 -1
- package/dist/operations/item-update/index.js +1 -2
- package/dist/operations/notification/index.js +1 -2
- package/dist/operations/request/index.js +19 -19
- package/dist/operations/trigger/index.js +2 -3
- package/dist/rate-limiter.d.ts +1 -1
- package/dist/rate-limiter.js +9 -9
- package/dist/request/validate-ip.js +2 -2
- package/dist/server.js +12 -13
- package/dist/services/activity.d.ts +1 -1
- package/dist/services/activity.js +17 -16
- package/dist/services/assets.d.ts +3 -3
- package/dist/services/assets.js +35 -37
- package/dist/services/authentication.d.ts +2 -2
- package/dist/services/authentication.js +22 -19
- package/dist/services/authorization.d.ts +3 -3
- package/dist/services/authorization.js +27 -31
- package/dist/services/collections.d.ts +5 -5
- package/dist/services/collections.js +54 -50
- package/dist/services/dashboards.d.ts +1 -1
- package/dist/services/fields.d.ts +5 -5
- package/dist/services/fields.js +50 -50
- package/dist/services/files.d.ts +1 -2
- package/dist/services/files.js +33 -27
- package/dist/services/flows.d.ts +2 -2
- package/dist/services/folders.d.ts +1 -1
- package/dist/services/graphql/index.d.ts +4 -4
- package/dist/services/graphql/index.js +259 -252
- package/dist/services/graphql/utils/add-path-to-validation-error.js +1 -2
- package/dist/services/graphql/utils/process-error.d.ts +2 -2
- package/dist/services/graphql/utils/process-error.js +11 -4
- package/dist/services/import-export.d.ts +3 -3
- package/dist/services/import-export.js +30 -27
- package/dist/services/items.d.ts +3 -3
- package/dist/services/items.js +42 -36
- package/dist/services/mail/index.d.ts +4 -4
- package/dist/services/mail/index.js +14 -10
- package/dist/services/meta.d.ts +3 -3
- package/dist/services/meta.js +11 -9
- package/dist/services/notifications.d.ts +3 -3
- package/dist/services/notifications.js +10 -9
- package/dist/services/operations.d.ts +2 -2
- package/dist/services/panels.d.ts +1 -1
- package/dist/services/payload.d.ts +3 -3
- package/dist/services/payload.js +124 -122
- package/dist/services/permissions.d.ts +3 -3
- package/dist/services/permissions.js +11 -11
- package/dist/services/presets.d.ts +1 -1
- package/dist/services/relations.d.ts +6 -6
- package/dist/services/relations.js +45 -43
- package/dist/services/revisions.d.ts +1 -1
- package/dist/services/revisions.js +3 -3
- package/dist/services/roles.d.ts +2 -2
- package/dist/services/roles.js +7 -7
- package/dist/services/schema.d.ts +3 -3
- package/dist/services/schema.js +9 -11
- package/dist/services/server.d.ts +3 -3
- package/dist/services/server.js +88 -32
- package/dist/services/settings.d.ts +1 -1
- package/dist/services/shares.d.ts +1 -1
- package/dist/services/shares.js +14 -15
- package/dist/services/specifications.d.ts +4 -4
- package/dist/services/specifications.js +137 -119
- package/dist/services/tfa.d.ts +2 -2
- package/dist/services/tfa.js +7 -5
- package/dist/services/users.d.ts +2 -6
- package/dist/services/users.js +37 -40
- package/dist/services/utils.d.ts +3 -3
- package/dist/services/utils.js +10 -8
- package/dist/services/webhooks.d.ts +2 -2
- package/dist/services/webhooks.js +2 -1
- package/dist/storage/register-locations.js +1 -1
- package/dist/types/assets.d.ts +1 -1
- package/dist/types/ast.d.ts +1 -1
- package/dist/types/auth.d.ts +2 -2
- package/dist/types/collection.d.ts +2 -2
- package/dist/types/events.d.ts +2 -2
- package/dist/types/graphql.d.ts +2 -2
- package/dist/types/items.d.ts +3 -3
- package/dist/types/services.d.ts +5 -5
- package/dist/types/snapshot.d.ts +4 -4
- package/dist/utils/apply-diff.d.ts +3 -3
- package/dist/utils/apply-diff.js +25 -28
- package/dist/utils/apply-query.d.ts +3 -3
- package/dist/utils/apply-query.js +10 -12
- package/dist/utils/apply-snapshot.d.ts +3 -3
- package/dist/utils/apply-snapshot.js +5 -6
- package/dist/utils/construct-flow-tree.d.ts +1 -1
- package/dist/utils/construct-flow-tree.js +2 -2
- package/dist/utils/dynamic-import.js +1 -1
- package/dist/utils/filter-items.d.ts +1 -1
- package/dist/utils/generate-hash.js +1 -1
- package/dist/utils/get-accountability-for-role.d.ts +2 -2
- package/dist/utils/get-accountability-for-role.js +1 -1
- package/dist/utils/get-ast-from-query.d.ts +3 -3
- package/dist/utils/get-ast-from-query.js +22 -28
- package/dist/utils/get-auth-providers.js +1 -1
- package/dist/utils/get-cache-headers.d.ts +1 -1
- package/dist/utils/get-cache-headers.js +6 -7
- package/dist/utils/get-cache-key.d.ts +1 -1
- package/dist/utils/get-cache-key.js +2 -3
- package/dist/utils/get-collection-from-alias.d.ts +1 -1
- package/dist/utils/get-collection-from-alias.js +1 -0
- package/dist/utils/get-column-path.d.ts +2 -2
- package/dist/utils/get-column-path.js +3 -4
- package/dist/utils/get-column.d.ts +4 -4
- package/dist/utils/get-column.js +4 -5
- package/dist/utils/get-default-value.d.ts +2 -2
- package/dist/utils/get-default-value.js +2 -3
- package/dist/utils/get-graphql-query-and-variables.d.ts +1 -1
- package/dist/utils/get-graphql-query-and-variables.js +1 -2
- package/dist/utils/get-graphql-type.d.ts +2 -2
- package/dist/utils/get-graphql-type.js +1 -1
- package/dist/utils/get-ip-from-req.d.ts +1 -1
- package/dist/utils/get-ip-from-req.js +2 -2
- package/dist/utils/get-local-type.d.ts +1 -1
- package/dist/utils/get-local-type.js +3 -3
- package/dist/utils/get-milliseconds.js +1 -2
- package/dist/utils/get-permissions.d.ts +1 -1
- package/dist/utils/get-permissions.js +12 -12
- package/dist/utils/get-relation-info.d.ts +1 -1
- package/dist/utils/get-relation-info.js +3 -5
- package/dist/utils/get-relation-type.d.ts +1 -1
- package/dist/utils/get-relation-type.js +3 -4
- package/dist/utils/get-schema.d.ts +2 -2
- package/dist/utils/get-schema.js +20 -22
- package/dist/utils/get-snapshot-diff.js +2 -3
- package/dist/utils/get-snapshot.d.ts +3 -3
- package/dist/utils/get-snapshot.js +6 -8
- package/dist/utils/is-directus-jwt.js +1 -1
- package/dist/utils/is-url-allowed.js +5 -2
- package/dist/utils/job-queue.js +2 -0
- package/dist/utils/jwt.d.ts +1 -1
- package/dist/utils/merge-permissions-for-share.d.ts +1 -1
- package/dist/utils/merge-permissions-for-share.js +3 -4
- package/dist/utils/merge-permissions.d.ts +3 -3
- package/dist/utils/reduce-schema.d.ts +1 -1
- package/dist/utils/reduce-schema.js +12 -12
- package/dist/utils/sanitize-query.d.ts +1 -1
- package/dist/utils/sanitize-query.js +27 -27
- package/dist/utils/sanitize-schema.d.ts +2 -2
- package/dist/utils/should-skip-cache.d.ts +7 -0
- package/dist/utils/should-skip-cache.js +21 -0
- package/dist/utils/should-skip-cache.test.d.ts +1 -0
- package/dist/utils/track.js +16 -16
- package/dist/utils/transformations.d.ts +1 -1
- package/dist/utils/transformations.js +2 -4
- package/dist/utils/url.js +7 -2
- package/dist/utils/user-name.d.ts +1 -1
- package/dist/utils/validate-diff.js +7 -8
- package/dist/utils/validate-keys.d.ts +2 -2
- package/dist/utils/validate-keys.js +1 -1
- package/dist/utils/validate-query.d.ts +1 -1
- package/dist/utils/validate-query.js +3 -3
- package/dist/utils/validate-storage.js +8 -8
- package/dist/webhooks.js +3 -3
- package/package.json +36 -37
- package/dist/utils/with-timeout.d.ts +0 -1
- package/dist/utils/with-timeout.js +0 -16
package/dist/services/shares.js
CHANGED
|
@@ -17,6 +17,7 @@ const items_1 = require("./items");
|
|
|
17
17
|
const mail_1 = require("./mail");
|
|
18
18
|
const users_1 = require("./users");
|
|
19
19
|
class SharesService extends items_1.ItemsService {
|
|
20
|
+
authorizationService;
|
|
20
21
|
constructor(options) {
|
|
21
22
|
super('directus_shares', options);
|
|
22
23
|
this.authorizationService = new authorization_1.AuthorizationService({
|
|
@@ -26,11 +27,10 @@ class SharesService extends items_1.ItemsService {
|
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
async createOne(data, opts) {
|
|
29
|
-
await this.authorizationService.checkAccess('share', data
|
|
30
|
+
await this.authorizationService.checkAccess('share', data['collection'], data['item']);
|
|
30
31
|
return super.createOne(data, opts);
|
|
31
32
|
}
|
|
32
33
|
async login(payload) {
|
|
33
|
-
var _a, _b, _c;
|
|
34
34
|
const { nanoid } = await import('nanoid');
|
|
35
35
|
const record = await this.knex
|
|
36
36
|
.select({
|
|
@@ -45,7 +45,7 @@ class SharesService extends items_1.ItemsService {
|
|
|
45
45
|
share_password: 'password',
|
|
46
46
|
})
|
|
47
47
|
.from('directus_shares')
|
|
48
|
-
.where('id', payload
|
|
48
|
+
.where('id', payload['share'])
|
|
49
49
|
.andWhere((subQuery) => {
|
|
50
50
|
subQuery.whereNull('date_end').orWhere('date_end', '>=', new Date());
|
|
51
51
|
})
|
|
@@ -59,7 +59,7 @@ class SharesService extends items_1.ItemsService {
|
|
|
59
59
|
if (!record) {
|
|
60
60
|
throw new exceptions_1.InvalidCredentialsException();
|
|
61
61
|
}
|
|
62
|
-
if (record.share_password && !(await argon2_1.default.verify(record.share_password, payload
|
|
62
|
+
if (record.share_password && !(await argon2_1.default.verify(record.share_password, payload['password']))) {
|
|
63
63
|
throw new exceptions_1.InvalidCredentialsException();
|
|
64
64
|
}
|
|
65
65
|
await this.knex('directus_shares')
|
|
@@ -75,25 +75,25 @@ class SharesService extends items_1.ItemsService {
|
|
|
75
75
|
collection: record.share_collection,
|
|
76
76
|
},
|
|
77
77
|
};
|
|
78
|
-
const accessToken = jsonwebtoken_1.default.sign(tokenPayload, env_1.default
|
|
79
|
-
expiresIn: env_1.default
|
|
78
|
+
const accessToken = jsonwebtoken_1.default.sign(tokenPayload, env_1.default['SECRET'], {
|
|
79
|
+
expiresIn: env_1.default['ACCESS_TOKEN_TTL'],
|
|
80
80
|
issuer: 'directus',
|
|
81
81
|
});
|
|
82
82
|
const refreshToken = nanoid(64);
|
|
83
|
-
const refreshTokenExpiration = new Date(Date.now() + (0, get_milliseconds_1.getMilliseconds)(env_1.default
|
|
83
|
+
const refreshTokenExpiration = new Date(Date.now() + (0, get_milliseconds_1.getMilliseconds)(env_1.default['REFRESH_TOKEN_TTL'], 0));
|
|
84
84
|
await this.knex('directus_sessions').insert({
|
|
85
85
|
token: refreshToken,
|
|
86
86
|
expires: refreshTokenExpiration,
|
|
87
|
-
ip:
|
|
88
|
-
user_agent:
|
|
89
|
-
origin:
|
|
87
|
+
ip: this.accountability?.ip,
|
|
88
|
+
user_agent: this.accountability?.userAgent,
|
|
89
|
+
origin: this.accountability?.origin,
|
|
90
90
|
share: record.share_id,
|
|
91
91
|
});
|
|
92
92
|
await this.knex('directus_sessions').delete().where('expires', '<', new Date());
|
|
93
93
|
return {
|
|
94
94
|
accessToken,
|
|
95
95
|
refreshToken,
|
|
96
|
-
expires: (0, get_milliseconds_1.getMilliseconds)(env_1.default
|
|
96
|
+
expires: (0, get_milliseconds_1.getMilliseconds)(env_1.default['ACCESS_TOKEN_TTL']),
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
@@ -101,8 +101,7 @@ class SharesService extends items_1.ItemsService {
|
|
|
101
101
|
* if you have read access to that particular share
|
|
102
102
|
*/
|
|
103
103
|
async invite(payload) {
|
|
104
|
-
|
|
105
|
-
if (!((_a = this.accountability) === null || _a === void 0 ? void 0 : _a.user))
|
|
104
|
+
if (!this.accountability?.user)
|
|
106
105
|
throw new exceptions_1.ForbiddenException();
|
|
107
106
|
const share = await this.readOne(payload.share, { fields: ['collection'] });
|
|
108
107
|
const usersService = new users_1.UsersService({
|
|
@@ -116,9 +115,9 @@ class SharesService extends items_1.ItemsService {
|
|
|
116
115
|
const message = `
|
|
117
116
|
Hello!
|
|
118
117
|
|
|
119
|
-
${(0, user_name_1.userName)(userInfo)} has invited you to view an item in ${share
|
|
118
|
+
${(0, user_name_1.userName)(userInfo)} has invited you to view an item in ${share['collection']}.
|
|
120
119
|
|
|
121
|
-
[Open](${new url_1.Url(env_1.default
|
|
120
|
+
[Open](${new url_1.Url(env_1.default['PUBLIC_URL']).addPath('admin', 'shared', payload.share).toString()})
|
|
122
121
|
`;
|
|
123
122
|
for (const email of payload.emails) {
|
|
124
123
|
await mailService.send({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Knex } from 'knex';
|
|
2
|
-
import { OpenAPIObject } from 'openapi3-ts';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { Knex } from 'knex';
|
|
2
|
+
import type { OpenAPIObject } from 'openapi3-ts';
|
|
3
|
+
import type { Accountability, SchemaOverview } from '@directus/shared/types';
|
|
4
|
+
import type { AbstractServiceOptions } from '../types';
|
|
5
5
|
import { CollectionsService } from './collections';
|
|
6
6
|
import { FieldsService } from './fields';
|
|
7
7
|
import { GraphQLService } from './graphql';
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.SpecificationService = void 0;
|
|
7
7
|
const specs_1 = __importDefault(require("@directus/specs"));
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
|
-
// @ts-ignore
|
|
10
9
|
const package_json_1 = require("../../package.json");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
11
|
const database_1 = __importDefault(require("../database"));
|
|
12
12
|
const env_1 = __importDefault(require("../env"));
|
|
13
13
|
const get_relation_type_1 = require("../utils/get-relation-type");
|
|
@@ -15,10 +15,17 @@ const collections_1 = require("./collections");
|
|
|
15
15
|
const fields_1 = require("./fields");
|
|
16
16
|
const graphql_1 = require("./graphql");
|
|
17
17
|
const relations_1 = require("./relations");
|
|
18
|
-
const constants_1 = require("../constants");
|
|
19
18
|
// @ts-ignore
|
|
20
19
|
const format_title_1 = __importDefault(require("@directus/format-title"));
|
|
21
20
|
class SpecificationService {
|
|
21
|
+
accountability;
|
|
22
|
+
knex;
|
|
23
|
+
schema;
|
|
24
|
+
fieldsService;
|
|
25
|
+
collectionsService;
|
|
26
|
+
relationsService;
|
|
27
|
+
oas;
|
|
28
|
+
graphql;
|
|
22
29
|
constructor(options) {
|
|
23
30
|
this.accountability = options.accountability || null;
|
|
24
31
|
this.knex = options.knex || (0, database_1.default)();
|
|
@@ -36,93 +43,13 @@ class SpecificationService {
|
|
|
36
43
|
}
|
|
37
44
|
exports.SpecificationService = SpecificationService;
|
|
38
45
|
class OASSpecsService {
|
|
46
|
+
accountability;
|
|
47
|
+
knex;
|
|
48
|
+
schema;
|
|
49
|
+
fieldsService;
|
|
50
|
+
collectionsService;
|
|
51
|
+
relationsService;
|
|
39
52
|
constructor(options, { fieldsService, collectionsService, relationsService, }) {
|
|
40
|
-
this.fieldTypes = {
|
|
41
|
-
alias: {
|
|
42
|
-
type: 'string',
|
|
43
|
-
},
|
|
44
|
-
bigInteger: {
|
|
45
|
-
type: 'integer',
|
|
46
|
-
format: 'int64',
|
|
47
|
-
},
|
|
48
|
-
binary: {
|
|
49
|
-
type: 'string',
|
|
50
|
-
format: 'binary',
|
|
51
|
-
},
|
|
52
|
-
boolean: {
|
|
53
|
-
type: 'boolean',
|
|
54
|
-
},
|
|
55
|
-
csv: {
|
|
56
|
-
type: 'array',
|
|
57
|
-
items: {
|
|
58
|
-
type: 'string',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
date: {
|
|
62
|
-
type: 'string',
|
|
63
|
-
format: 'date',
|
|
64
|
-
},
|
|
65
|
-
dateTime: {
|
|
66
|
-
type: 'string',
|
|
67
|
-
format: 'date-time',
|
|
68
|
-
},
|
|
69
|
-
decimal: {
|
|
70
|
-
type: 'number',
|
|
71
|
-
},
|
|
72
|
-
float: {
|
|
73
|
-
type: 'number',
|
|
74
|
-
format: 'float',
|
|
75
|
-
},
|
|
76
|
-
hash: {
|
|
77
|
-
type: 'string',
|
|
78
|
-
},
|
|
79
|
-
integer: {
|
|
80
|
-
type: 'integer',
|
|
81
|
-
},
|
|
82
|
-
json: {},
|
|
83
|
-
string: {
|
|
84
|
-
type: 'string',
|
|
85
|
-
},
|
|
86
|
-
text: {
|
|
87
|
-
type: 'string',
|
|
88
|
-
},
|
|
89
|
-
time: {
|
|
90
|
-
type: 'string',
|
|
91
|
-
format: 'time',
|
|
92
|
-
},
|
|
93
|
-
timestamp: {
|
|
94
|
-
type: 'string',
|
|
95
|
-
format: 'timestamp',
|
|
96
|
-
},
|
|
97
|
-
unknown: {
|
|
98
|
-
type: undefined,
|
|
99
|
-
},
|
|
100
|
-
uuid: {
|
|
101
|
-
type: 'string',
|
|
102
|
-
format: 'uuid',
|
|
103
|
-
},
|
|
104
|
-
geometry: {
|
|
105
|
-
type: 'object',
|
|
106
|
-
},
|
|
107
|
-
'geometry.Point': {
|
|
108
|
-
type: 'object',
|
|
109
|
-
},
|
|
110
|
-
'geometry.LineString': {
|
|
111
|
-
type: 'object',
|
|
112
|
-
},
|
|
113
|
-
'geometry.Polygon': {
|
|
114
|
-
type: 'object',
|
|
115
|
-
},
|
|
116
|
-
'geometry.MultiPoint': {
|
|
117
|
-
type: 'object',
|
|
118
|
-
},
|
|
119
|
-
'geometry.MultiLineString': {
|
|
120
|
-
type: 'object',
|
|
121
|
-
},
|
|
122
|
-
'geometry.MultiPolygon': {
|
|
123
|
-
type: 'object',
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
53
|
this.accountability = options.accountability || null;
|
|
127
54
|
this.knex = options.knex || (0, database_1.default)();
|
|
128
55
|
this.schema = options.schema;
|
|
@@ -131,11 +58,10 @@ class OASSpecsService {
|
|
|
131
58
|
this.relationsService = relationsService;
|
|
132
59
|
}
|
|
133
60
|
async generate() {
|
|
134
|
-
var _a, _b;
|
|
135
61
|
const collections = await this.collectionsService.readByQuery();
|
|
136
62
|
const fields = await this.fieldsService.readAll();
|
|
137
63
|
const relations = (await this.relationsService.readAll());
|
|
138
|
-
const permissions =
|
|
64
|
+
const permissions = this.accountability?.permissions ?? [];
|
|
139
65
|
const tags = await this.generateTags(collections);
|
|
140
66
|
const paths = await this.generatePaths(permissions, tags);
|
|
141
67
|
const components = await this.generateComponents(collections, fields, relations, tags);
|
|
@@ -148,18 +74,19 @@ class OASSpecsService {
|
|
|
148
74
|
},
|
|
149
75
|
servers: [
|
|
150
76
|
{
|
|
151
|
-
url: env_1.default
|
|
77
|
+
url: env_1.default['PUBLIC_URL'],
|
|
152
78
|
description: 'Your current Directus instance.',
|
|
153
79
|
},
|
|
154
80
|
],
|
|
155
|
-
tags,
|
|
156
81
|
paths,
|
|
157
|
-
components,
|
|
158
82
|
};
|
|
83
|
+
if (tags)
|
|
84
|
+
spec.tags = tags;
|
|
85
|
+
if (components)
|
|
86
|
+
spec.components = components;
|
|
159
87
|
return spec;
|
|
160
88
|
}
|
|
161
89
|
async generateTags(collections) {
|
|
162
|
-
var _a;
|
|
163
90
|
const systemTags = (0, lodash_1.cloneDeep)(specs_1.default.tags);
|
|
164
91
|
const tags = [];
|
|
165
92
|
// System tags that don't have an associated collection are always readable to the user
|
|
@@ -180,18 +107,20 @@ class OASSpecsService {
|
|
|
180
107
|
}
|
|
181
108
|
}
|
|
182
109
|
else {
|
|
183
|
-
|
|
110
|
+
const tag = {
|
|
184
111
|
name: 'Items' + (0, format_title_1.default)(collection.collection).replace(/ /g, ''),
|
|
185
|
-
description: ((_a = collection.meta) === null || _a === void 0 ? void 0 : _a.note) || undefined,
|
|
186
112
|
'x-collection': collection.collection,
|
|
187
|
-
}
|
|
113
|
+
};
|
|
114
|
+
if (collection.meta?.note) {
|
|
115
|
+
tag.description = collection.meta.note;
|
|
116
|
+
}
|
|
117
|
+
tags.push(tag);
|
|
188
118
|
}
|
|
189
119
|
}
|
|
190
120
|
// Filter out the generic Items information
|
|
191
121
|
return tags.filter((tag) => tag.name !== 'Items');
|
|
192
122
|
}
|
|
193
123
|
async generatePaths(permissions, tags) {
|
|
194
|
-
var _a, _b, _c, _d, _e;
|
|
195
124
|
const paths = {};
|
|
196
125
|
if (!tags)
|
|
197
126
|
return paths;
|
|
@@ -200,11 +129,11 @@ class OASSpecsService {
|
|
|
200
129
|
if (isSystem) {
|
|
201
130
|
for (const [path, pathItem] of Object.entries(specs_1.default.paths)) {
|
|
202
131
|
for (const [method, operation] of Object.entries(pathItem)) {
|
|
203
|
-
if (
|
|
132
|
+
if (operation.tags?.includes(tag.name)) {
|
|
204
133
|
if (!paths[path]) {
|
|
205
134
|
paths[path] = {};
|
|
206
135
|
}
|
|
207
|
-
const hasPermission =
|
|
136
|
+
const hasPermission = this.accountability?.admin === true ||
|
|
208
137
|
'x-collection' in tag === false ||
|
|
209
138
|
!!permissions.find((permission) => permission.collection === tag['x-collection'] &&
|
|
210
139
|
permission.action === this.getActionForMethod(method));
|
|
@@ -212,7 +141,7 @@ class OASSpecsService {
|
|
|
212
141
|
if ('parameters' in pathItem) {
|
|
213
142
|
paths[path][method] = {
|
|
214
143
|
...operation,
|
|
215
|
-
parameters: [...(
|
|
144
|
+
parameters: [...(pathItem.parameters ?? []), ...(operation?.parameters ?? [])],
|
|
216
145
|
};
|
|
217
146
|
}
|
|
218
147
|
else {
|
|
@@ -228,7 +157,7 @@ class OASSpecsService {
|
|
|
228
157
|
const detailBase = (0, lodash_1.cloneDeep)(specs_1.default.paths['/items/{collection}/{id}']);
|
|
229
158
|
const collection = tag['x-collection'];
|
|
230
159
|
for (const method of ['post', 'get', 'patch', 'delete']) {
|
|
231
|
-
const hasPermission =
|
|
160
|
+
const hasPermission = this.accountability?.admin === true ||
|
|
232
161
|
!!permissions.find((permission) => permission.collection === collection && permission.action === this.getActionForMethod(method));
|
|
233
162
|
if (hasPermission) {
|
|
234
163
|
if (!paths[`/items/${collection}`])
|
|
@@ -239,7 +168,7 @@ class OASSpecsService {
|
|
|
239
168
|
paths[`/items/${collection}`][method] = (0, lodash_1.mergeWith)((0, lodash_1.cloneDeep)(listBase[method]), {
|
|
240
169
|
description: listBase[method].description.replace('item', collection + ' item'),
|
|
241
170
|
tags: [tag.name],
|
|
242
|
-
parameters: 'parameters' in listBase ? this.filterCollectionFromParams(listBase
|
|
171
|
+
parameters: 'parameters' in listBase ? this.filterCollectionFromParams(listBase.parameters) : [],
|
|
243
172
|
operationId: `${this.getActionForMethod(method)}${tag.name}`,
|
|
244
173
|
requestBody: ['get', 'delete'].includes(method)
|
|
245
174
|
? undefined
|
|
@@ -284,6 +213,7 @@ class OASSpecsService {
|
|
|
284
213
|
}, (obj, src) => {
|
|
285
214
|
if (Array.isArray(obj))
|
|
286
215
|
return obj.concat(src);
|
|
216
|
+
return undefined;
|
|
287
217
|
});
|
|
288
218
|
}
|
|
289
219
|
if (detailBase[method]) {
|
|
@@ -291,7 +221,7 @@ class OASSpecsService {
|
|
|
291
221
|
description: detailBase[method].description.replace('item', collection + ' item'),
|
|
292
222
|
tags: [tag.name],
|
|
293
223
|
operationId: `${this.getActionForMethod(method)}Single${tag.name}`,
|
|
294
|
-
parameters: 'parameters' in detailBase ? this.filterCollectionFromParams(detailBase
|
|
224
|
+
parameters: 'parameters' in detailBase ? this.filterCollectionFromParams(detailBase.parameters) : [],
|
|
295
225
|
requestBody: ['get', 'delete'].includes(method)
|
|
296
226
|
? undefined
|
|
297
227
|
: {
|
|
@@ -323,6 +253,7 @@ class OASSpecsService {
|
|
|
323
253
|
}, (obj, src) => {
|
|
324
254
|
if (Array.isArray(obj))
|
|
325
255
|
return obj.concat(src);
|
|
256
|
+
return undefined;
|
|
326
257
|
});
|
|
327
258
|
}
|
|
328
259
|
}
|
|
@@ -332,13 +263,12 @@ class OASSpecsService {
|
|
|
332
263
|
return paths;
|
|
333
264
|
}
|
|
334
265
|
async generateComponents(collections, fields, relations, tags) {
|
|
335
|
-
var _a;
|
|
336
266
|
let components = (0, lodash_1.cloneDeep)(specs_1.default.components);
|
|
337
267
|
if (!components)
|
|
338
268
|
components = {};
|
|
339
269
|
components.schemas = {};
|
|
340
270
|
// Always includes the schemas with these names
|
|
341
|
-
if (
|
|
271
|
+
if (specs_1.default.components?.schemas !== null) {
|
|
342
272
|
for (const schemaName of constants_1.OAS_REQUIRED_SCHEMAS) {
|
|
343
273
|
if (specs_1.default.components.schemas[schemaName] !== null) {
|
|
344
274
|
components.schemas[schemaName] = (0, lodash_1.cloneDeep)(specs_1.default.components.schemas[schemaName]);
|
|
@@ -377,7 +307,7 @@ class OASSpecsService {
|
|
|
377
307
|
return components;
|
|
378
308
|
}
|
|
379
309
|
filterCollectionFromParams(parameters) {
|
|
380
|
-
return parameters.filter((param) =>
|
|
310
|
+
return parameters.filter((param) => param?.$ref !== '#/components/parameters/Collection');
|
|
381
311
|
}
|
|
382
312
|
getActionForMethod(method) {
|
|
383
313
|
switch (method) {
|
|
@@ -393,16 +323,15 @@ class OASSpecsService {
|
|
|
393
323
|
}
|
|
394
324
|
}
|
|
395
325
|
generateField(field, relations, tags, fields) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
nullable
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
});
|
|
326
|
+
let propertyObject = {};
|
|
327
|
+
if (field.schema && 'is_nullable' in field.schema) {
|
|
328
|
+
propertyObject.nullable = field.schema.is_nullable;
|
|
329
|
+
}
|
|
330
|
+
if (field.meta?.note) {
|
|
331
|
+
propertyObject.description = field.meta.note;
|
|
332
|
+
}
|
|
333
|
+
const relation = relations.find((relation) => (relation.collection === field.collection && relation.field === field.field) ||
|
|
334
|
+
(relation.related_collection === field.collection && relation.meta?.one_field === field.field));
|
|
406
335
|
if (!relation) {
|
|
407
336
|
propertyObject = {
|
|
408
337
|
...propertyObject,
|
|
@@ -417,7 +346,7 @@ class OASSpecsService {
|
|
|
417
346
|
});
|
|
418
347
|
if (relationType === 'm2o') {
|
|
419
348
|
const relatedTag = tags.find((tag) => tag['x-collection'] === relation.related_collection);
|
|
420
|
-
const relatedPrimaryKeyField = fields.find((field) =>
|
|
349
|
+
const relatedPrimaryKeyField = fields.find((field) => field.collection === relation.related_collection && field.schema?.is_primary_key);
|
|
421
350
|
if (!relatedTag || !relatedPrimaryKeyField)
|
|
422
351
|
return propertyObject;
|
|
423
352
|
propertyObject.oneOf = [
|
|
@@ -431,7 +360,7 @@ class OASSpecsService {
|
|
|
431
360
|
}
|
|
432
361
|
else if (relationType === 'o2m') {
|
|
433
362
|
const relatedTag = tags.find((tag) => tag['x-collection'] === relation.collection);
|
|
434
|
-
const relatedPrimaryKeyField = fields.find((field) =>
|
|
363
|
+
const relatedPrimaryKeyField = fields.find((field) => field.collection === relation.collection && field.schema?.is_primary_key);
|
|
435
364
|
if (!relatedTag || !relatedPrimaryKeyField)
|
|
436
365
|
return propertyObject;
|
|
437
366
|
propertyObject.type = 'array';
|
|
@@ -463,8 +392,97 @@ class OASSpecsService {
|
|
|
463
392
|
}
|
|
464
393
|
return propertyObject;
|
|
465
394
|
}
|
|
395
|
+
fieldTypes = {
|
|
396
|
+
alias: {
|
|
397
|
+
type: 'string',
|
|
398
|
+
},
|
|
399
|
+
bigInteger: {
|
|
400
|
+
type: 'integer',
|
|
401
|
+
format: 'int64',
|
|
402
|
+
},
|
|
403
|
+
binary: {
|
|
404
|
+
type: 'string',
|
|
405
|
+
format: 'binary',
|
|
406
|
+
},
|
|
407
|
+
boolean: {
|
|
408
|
+
type: 'boolean',
|
|
409
|
+
},
|
|
410
|
+
csv: {
|
|
411
|
+
type: 'array',
|
|
412
|
+
items: {
|
|
413
|
+
type: 'string',
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
date: {
|
|
417
|
+
type: 'string',
|
|
418
|
+
format: 'date',
|
|
419
|
+
},
|
|
420
|
+
dateTime: {
|
|
421
|
+
type: 'string',
|
|
422
|
+
format: 'date-time',
|
|
423
|
+
},
|
|
424
|
+
decimal: {
|
|
425
|
+
type: 'number',
|
|
426
|
+
},
|
|
427
|
+
float: {
|
|
428
|
+
type: 'number',
|
|
429
|
+
format: 'float',
|
|
430
|
+
},
|
|
431
|
+
hash: {
|
|
432
|
+
type: 'string',
|
|
433
|
+
},
|
|
434
|
+
integer: {
|
|
435
|
+
type: 'integer',
|
|
436
|
+
},
|
|
437
|
+
json: {},
|
|
438
|
+
string: {
|
|
439
|
+
type: 'string',
|
|
440
|
+
},
|
|
441
|
+
text: {
|
|
442
|
+
type: 'string',
|
|
443
|
+
},
|
|
444
|
+
time: {
|
|
445
|
+
type: 'string',
|
|
446
|
+
format: 'time',
|
|
447
|
+
},
|
|
448
|
+
timestamp: {
|
|
449
|
+
type: 'string',
|
|
450
|
+
format: 'timestamp',
|
|
451
|
+
},
|
|
452
|
+
unknown: {},
|
|
453
|
+
uuid: {
|
|
454
|
+
type: 'string',
|
|
455
|
+
format: 'uuid',
|
|
456
|
+
},
|
|
457
|
+
geometry: {
|
|
458
|
+
type: 'object',
|
|
459
|
+
},
|
|
460
|
+
'geometry.Point': {
|
|
461
|
+
type: 'object',
|
|
462
|
+
},
|
|
463
|
+
'geometry.LineString': {
|
|
464
|
+
type: 'object',
|
|
465
|
+
},
|
|
466
|
+
'geometry.Polygon': {
|
|
467
|
+
type: 'object',
|
|
468
|
+
},
|
|
469
|
+
'geometry.MultiPoint': {
|
|
470
|
+
type: 'object',
|
|
471
|
+
},
|
|
472
|
+
'geometry.MultiLineString': {
|
|
473
|
+
type: 'object',
|
|
474
|
+
},
|
|
475
|
+
'geometry.MultiPolygon': {
|
|
476
|
+
type: 'object',
|
|
477
|
+
},
|
|
478
|
+
};
|
|
466
479
|
}
|
|
467
480
|
class GraphQLSpecsService {
|
|
481
|
+
accountability;
|
|
482
|
+
knex;
|
|
483
|
+
schema;
|
|
484
|
+
items;
|
|
485
|
+
system;
|
|
468
486
|
constructor(options) {
|
|
469
487
|
this.accountability = options.accountability || null;
|
|
470
488
|
this.knex = options.knex || (0, database_1.default)();
|
package/dist/services/tfa.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Knex } from 'knex';
|
|
1
|
+
import type { Knex } from 'knex';
|
|
2
|
+
import type { AbstractServiceOptions, PrimaryKey } from '../types';
|
|
2
3
|
import { ItemsService } from './items';
|
|
3
|
-
import { AbstractServiceOptions, PrimaryKey } from '../types';
|
|
4
4
|
export declare class TFAService {
|
|
5
5
|
knex: Knex;
|
|
6
6
|
itemsService: ItemsService;
|
package/dist/services/tfa.js
CHANGED
|
@@ -9,6 +9,8 @@ const database_1 = __importDefault(require("../database"));
|
|
|
9
9
|
const exceptions_1 = require("../exceptions");
|
|
10
10
|
const items_1 = require("./items");
|
|
11
11
|
class TFAService {
|
|
12
|
+
knex;
|
|
13
|
+
itemsService;
|
|
12
14
|
constructor(options) {
|
|
13
15
|
this.knex = options.knex || (0, database_1.default)();
|
|
14
16
|
this.itemsService = new items_1.ItemsService('directus_users', options);
|
|
@@ -18,29 +20,29 @@ class TFAService {
|
|
|
18
20
|
return otplib_1.authenticator.check(otp, secret);
|
|
19
21
|
}
|
|
20
22
|
const user = await this.knex.select('tfa_secret').from('directus_users').where({ id: key }).first();
|
|
21
|
-
if (!
|
|
23
|
+
if (!user?.tfa_secret) {
|
|
22
24
|
throw new exceptions_1.InvalidPayloadException(`User "${key}" doesn't have TFA enabled.`);
|
|
23
25
|
}
|
|
24
26
|
return otplib_1.authenticator.check(otp, user.tfa_secret);
|
|
25
27
|
}
|
|
26
28
|
async generateTFA(key) {
|
|
27
29
|
const user = await this.knex.select('email', 'tfa_secret').from('directus_users').where({ id: key }).first();
|
|
28
|
-
if (
|
|
30
|
+
if (user?.tfa_secret !== null) {
|
|
29
31
|
throw new exceptions_1.InvalidPayloadException('TFA Secret is already set for this user');
|
|
30
32
|
}
|
|
31
|
-
if (!
|
|
33
|
+
if (!user?.email) {
|
|
32
34
|
throw new exceptions_1.InvalidPayloadException('User must have a valid email to enable TFA');
|
|
33
35
|
}
|
|
34
36
|
const secret = otplib_1.authenticator.generateSecret();
|
|
35
37
|
const project = await this.knex.select('project_name').from('directus_settings').limit(1).first();
|
|
36
38
|
return {
|
|
37
39
|
secret,
|
|
38
|
-
url: otplib_1.authenticator.keyuri(user.email,
|
|
40
|
+
url: otplib_1.authenticator.keyuri(user.email, project?.project_name || 'Directus', secret),
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
async enableTFA(key, otp, secret) {
|
|
42
44
|
const user = await this.knex.select('tfa_secret').from('directus_users').where({ id: key }).first();
|
|
43
|
-
if (
|
|
45
|
+
if (user?.tfa_secret !== null) {
|
|
44
46
|
throw new exceptions_1.InvalidPayloadException('TFA Secret is already set for this user');
|
|
45
47
|
}
|
|
46
48
|
if (!otplib_1.authenticator.check(otp, secret)) {
|
package/dist/services/users.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AbstractServiceOptions, Item,
|
|
3
|
-
import { Query, SchemaOverview, Accountability } from '@directus/shared/types';
|
|
1
|
+
import type { Query } from '@directus/shared/types';
|
|
2
|
+
import type { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
|
4
3
|
import { ItemsService } from './items';
|
|
5
4
|
export declare class UsersService extends ItemsService {
|
|
6
|
-
knex: Knex;
|
|
7
|
-
accountability: Accountability | null;
|
|
8
|
-
schema: SchemaOverview;
|
|
9
5
|
constructor(options: AbstractServiceOptions);
|
|
10
6
|
/**
|
|
11
7
|
* User email has to be unique case-insensitive. This is an additional check to make sure that
|