@solidxai/core 0.1.2 → 0.1.5-beta.0
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/.claude/settings.local.json +8 -0
- package/dist/commands/run-tests.command.d.ts +37 -0
- package/dist/commands/run-tests.command.d.ts.map +1 -0
- package/dist/commands/run-tests.command.js +345 -0
- package/dist/commands/run-tests.command.js.map +1 -0
- package/dist/commands/test-data.command.d.ts +6 -6
- package/dist/commands/test-data.command.d.ts.map +1 -1
- package/dist/commands/test-data.command.js +25 -25
- package/dist/commands/test-data.command.js.map +1 -1
- package/dist/commands/test.command.d.ts +5 -0
- package/dist/commands/test.command.d.ts.map +1 -0
- package/dist/commands/test.command.js +26 -0
- package/dist/commands/test.command.js.map +1 -0
- package/dist/constants/error-messages.d.ts +1 -0
- package/dist/constants/error-messages.d.ts.map +1 -1
- package/dist/constants/error-messages.js +1 -0
- package/dist/constants/error-messages.js.map +1 -1
- package/dist/constants.d.ts +3 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +12 -12
- package/dist/constants.js.map +1 -1
- package/dist/controllers/otp-authentication.controller.d.ts +1 -4
- package/dist/controllers/otp-authentication.controller.d.ts.map +1 -1
- package/dist/controllers/otp-authentication.controller.js +1 -1
- package/dist/controllers/role-metadata.controller.d.ts +1 -0
- package/dist/controllers/role-metadata.controller.d.ts.map +1 -1
- package/dist/controllers/role-metadata.controller.js +15 -0
- package/dist/controllers/role-metadata.controller.js.map +1 -1
- package/dist/controllers/service.controller.d.ts +0 -9
- package/dist/controllers/service.controller.d.ts.map +1 -1
- package/dist/controllers/service.controller.js +0 -45
- package/dist/controllers/service.controller.js.map +1 -1
- package/dist/dtos/basic-filters.dto.d.ts.map +1 -1
- package/dist/dtos/basic-filters.dto.js.map +1 -1
- package/dist/dtos/create-email-template.dto.d.ts.map +1 -1
- package/dist/dtos/create-email-template.dto.js.map +1 -1
- package/dist/dtos/create-list-of-values.dto.d.ts.map +1 -1
- package/dist/dtos/create-list-of-values.dto.js.map +1 -1
- package/dist/dtos/create-menu-item-metadata.dto.d.ts.map +1 -1
- package/dist/dtos/create-menu-item-metadata.dto.js.map +1 -1
- package/dist/dtos/create-role-metadata.dto.d.ts.map +1 -1
- package/dist/dtos/create-role-metadata.dto.js.map +1 -1
- package/dist/dtos/create-scheduled-job.dto.d.ts.map +1 -1
- package/dist/dtos/create-scheduled-job.dto.js.map +1 -1
- package/dist/dtos/create-security-rule.dto.d.ts.map +1 -1
- package/dist/dtos/create-security-rule.dto.js.map +1 -1
- package/dist/dtos/create-sms-template.dto.d.ts.map +1 -1
- package/dist/dtos/create-sms-template.dto.js.map +1 -1
- package/dist/dtos/create-user.dto.d.ts +1 -0
- package/dist/dtos/create-user.dto.d.ts.map +1 -1
- package/dist/dtos/create-user.dto.js +2 -1
- package/dist/dtos/create-user.dto.js.map +1 -1
- package/dist/dtos/create-view-metadata.dto.d.ts.map +1 -1
- package/dist/dtos/create-view-metadata.dto.js.map +1 -1
- package/dist/dtos/otp-sign-in.dto.d.ts +1 -1
- package/dist/dtos/otp-sign-in.dto.d.ts.map +1 -1
- package/dist/dtos/otp-sign-in.dto.js +2 -2
- package/dist/dtos/otp-sign-in.dto.js.map +1 -1
- package/dist/dtos/otp-sign-up.dto.d.ts +2 -2
- package/dist/dtos/otp-sign-up.dto.d.ts.map +1 -1
- package/dist/dtos/otp-sign-up.dto.js +2 -2
- package/dist/dtos/otp-sign-up.dto.js.map +1 -1
- package/dist/dtos/resolve-s3-url.dto.d.ts +2 -5
- package/dist/dtos/resolve-s3-url.dto.d.ts.map +1 -1
- package/dist/dtos/resolve-s3-url.dto.js +1 -13
- package/dist/dtos/resolve-s3-url.dto.js.map +1 -1
- package/dist/dtos/sign-up.dto.d.ts.map +1 -1
- package/dist/dtos/sign-up.dto.js.map +1 -1
- package/dist/dtos/update-email-template.dto.d.ts.map +1 -1
- package/dist/dtos/update-email-template.dto.js.map +1 -1
- package/dist/dtos/update-list-of-values.dto.d.ts.map +1 -1
- package/dist/dtos/update-list-of-values.dto.js.map +1 -1
- package/dist/dtos/update-menu-item-metadata.dto.d.ts.map +1 -1
- package/dist/dtos/update-menu-item-metadata.dto.js.map +1 -1
- package/dist/dtos/update-scheduled-job.dto.d.ts.map +1 -1
- package/dist/dtos/update-scheduled-job.dto.js.map +1 -1
- package/dist/dtos/update-security-rule.dto.d.ts.map +1 -1
- package/dist/dtos/update-security-rule.dto.js.map +1 -1
- package/dist/dtos/update-sms-template.dto.d.ts.map +1 -1
- package/dist/dtos/update-sms-template.dto.js.map +1 -1
- package/dist/dtos/update-view-metadata.dto.d.ts.map +1 -1
- package/dist/dtos/update-view-metadata.dto.js.map +1 -1
- package/dist/entities/user.entity.d.ts +1 -0
- package/dist/entities/user.entity.d.ts.map +1 -1
- package/dist/entities/user.entity.js +6 -1
- package/dist/entities/user.entity.js.map +1 -1
- package/dist/helpers/field-crud-managers/ManyToManyRelationFieldCrudManager.d.ts +2 -0
- package/dist/helpers/field-crud-managers/ManyToManyRelationFieldCrudManager.d.ts.map +1 -1
- package/dist/helpers/field-crud-managers/ManyToManyRelationFieldCrudManager.js +33 -23
- package/dist/helpers/field-crud-managers/ManyToManyRelationFieldCrudManager.js.map +1 -1
- package/dist/helpers/field-crud-managers/OneToManyRelationFieldCrudManager.d.ts +3 -0
- package/dist/helpers/field-crud-managers/OneToManyRelationFieldCrudManager.d.ts.map +1 -1
- package/dist/helpers/field-crud-managers/OneToManyRelationFieldCrudManager.js +36 -23
- package/dist/helpers/field-crud-managers/OneToManyRelationFieldCrudManager.js.map +1 -1
- package/dist/helpers/security.helper.js +1 -0
- package/dist/helpers/security.helper.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/repository/solid-base.repository.d.ts +10 -1
- package/dist/repository/solid-base.repository.d.ts.map +1 -1
- package/dist/repository/solid-base.repository.js +109 -0
- package/dist/repository/solid-base.repository.js.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts +2 -0
- package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.js +142 -91
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/module-test-data.service.d.ts.map +1 -1
- package/dist/seeders/module-test-data.service.js +3 -3
- package/dist/seeders/module-test-data.service.js.map +1 -1
- package/dist/seeders/permission-metadata-seeder.service.d.ts +1 -1
- package/dist/seeders/permission-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/permission-metadata-seeder.service.js +1 -1
- package/dist/seeders/permission-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +12 -25
- package/dist/services/authentication.service.d.ts +22 -8
- package/dist/services/authentication.service.d.ts.map +1 -1
- package/dist/services/authentication.service.js +228 -214
- package/dist/services/authentication.service.js.map +1 -1
- package/dist/services/chatter-message.service.d.ts +2 -0
- package/dist/services/chatter-message.service.d.ts.map +1 -1
- package/dist/services/chatter-message.service.js +18 -2
- package/dist/services/chatter-message.service.js.map +1 -1
- package/dist/services/crud-helper.service.d.ts +4 -0
- package/dist/services/crud-helper.service.d.ts.map +1 -1
- package/dist/services/crud-helper.service.js +66 -32
- package/dist/services/crud-helper.service.js.map +1 -1
- package/dist/services/crud.service.d.ts.map +1 -1
- package/dist/services/crud.service.js +7 -4
- package/dist/services/crud.service.js.map +1 -1
- package/dist/services/field-metadata.service.d.ts.map +1 -1
- package/dist/services/field-metadata.service.js.map +1 -1
- package/dist/services/file/disk-file.service.d.ts +0 -2
- package/dist/services/file/disk-file.service.d.ts.map +1 -1
- package/dist/services/file/disk-file.service.js +7 -16
- package/dist/services/file/disk-file.service.js.map +1 -1
- package/dist/services/file/index.d.ts +1 -0
- package/dist/services/file/index.d.ts.map +1 -1
- package/dist/services/file/index.js +1 -0
- package/dist/services/file/index.js.map +1 -1
- package/dist/services/file/storage-path-builder.d.ts +17 -0
- package/dist/services/file/storage-path-builder.d.ts.map +1 -0
- package/dist/{seeders/sms-template-seeder.service.js → services/file/storage-path-builder.js} +45 -35
- package/dist/services/file/storage-path-builder.js.map +1 -0
- package/dist/services/media.service.d.ts +1 -1
- package/dist/services/media.service.d.ts.map +1 -1
- package/dist/services/media.service.js +45 -6
- package/dist/services/media.service.js.map +1 -1
- package/dist/services/mediaStorageProviders/file-s3-storage-provider.js.map +1 -1
- package/dist/services/mediaStorageProviders/file-storage-provider.d.ts.map +1 -1
- package/dist/services/mediaStorageProviders/file-storage-provider.js +46 -7
- package/dist/services/mediaStorageProviders/file-storage-provider.js.map +1 -1
- package/dist/services/module-metadata.service.d.ts +4 -6
- package/dist/services/module-metadata.service.d.ts.map +1 -1
- package/dist/services/module-metadata.service.js +16 -14
- package/dist/services/module-metadata.service.js.map +1 -1
- package/dist/services/queues/common.d.ts +3 -0
- package/dist/services/queues/common.d.ts.map +1 -0
- package/dist/services/queues/common.js +39 -0
- package/dist/services/queues/common.js.map +1 -0
- package/dist/services/queues/database-publisher.service.d.ts.map +1 -1
- package/dist/services/queues/database-publisher.service.js +3 -1
- package/dist/services/queues/database-publisher.service.js.map +1 -1
- package/dist/services/queues/database-subscriber.service.d.ts.map +1 -1
- package/dist/services/queues/database-subscriber.service.js +5 -2
- package/dist/services/queues/database-subscriber.service.js.map +1 -1
- package/dist/services/queues/rabbitmq-publisher.service.d.ts.map +1 -1
- package/dist/services/queues/rabbitmq-publisher.service.js +13 -6
- package/dist/services/queues/rabbitmq-publisher.service.js.map +1 -1
- package/dist/services/queues/rabbitmq-subscriber.service.d.ts.map +1 -1
- package/dist/services/queues/rabbitmq-subscriber.service.js +9 -5
- package/dist/services/queues/rabbitmq-subscriber.service.js.map +1 -1
- package/dist/services/setting.service.d.ts +3 -2
- package/dist/services/setting.service.d.ts.map +1 -1
- package/dist/services/setting.service.js +7 -4
- package/dist/services/setting.service.js.map +1 -1
- package/dist/services/settings/default-settings-provider.service.d.ts +24 -2
- package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
- package/dist/services/settings/default-settings-provider.service.js +8 -6
- package/dist/services/settings/default-settings-provider.service.js.map +1 -1
- package/dist/solid-core.module.d.ts +3 -1
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +49 -9
- package/dist/solid-core.module.js.map +1 -1
- package/dist/testing/__examples__/register-example-specs.d.ts +3 -0
- package/dist/testing/__examples__/register-example-specs.d.ts.map +1 -0
- package/dist/testing/__examples__/register-example-specs.js +8 -0
- package/dist/testing/__examples__/register-example-specs.js.map +1 -0
- package/dist/testing/__examples__/specs/custom-health.spec.d.ts +17 -0
- package/dist/testing/__examples__/specs/custom-health.spec.d.ts.map +1 -0
- package/dist/testing/__examples__/specs/custom-health.spec.js +30 -0
- package/dist/testing/__examples__/specs/custom-health.spec.js.map +1 -0
- package/dist/testing/adapters/api/api-adapter.d.ts +9 -0
- package/dist/testing/adapters/api/api-adapter.d.ts.map +1 -0
- package/dist/testing/adapters/api/api-adapter.js +76 -0
- package/dist/testing/adapters/api/api-adapter.js.map +1 -0
- package/dist/testing/adapters/api/api.types.d.ts +14 -0
- package/dist/testing/adapters/api/api.types.d.ts.map +1 -0
- package/dist/testing/adapters/api/api.types.js +3 -0
- package/dist/testing/adapters/api/api.types.js.map +1 -0
- package/dist/testing/adapters/ui/playwright-adapter.d.ts +14 -0
- package/dist/testing/adapters/ui/playwright-adapter.d.ts.map +1 -0
- package/dist/testing/adapters/ui/playwright-adapter.js +80 -0
- package/dist/testing/adapters/ui/playwright-adapter.js.map +1 -0
- package/dist/testing/adapters/ui/ui.types.d.ts +5 -0
- package/dist/testing/adapters/ui/ui.types.d.ts.map +1 -0
- package/dist/testing/adapters/ui/ui.types.js +3 -0
- package/dist/testing/adapters/ui/ui.types.js.map +1 -0
- package/dist/testing/contracts/runtime-context.types.d.ts +35 -0
- package/dist/testing/contracts/runtime-context.types.d.ts.map +1 -0
- package/dist/testing/contracts/runtime-context.types.js +3 -0
- package/dist/testing/contracts/runtime-context.types.js.map +1 -0
- package/dist/testing/contracts/test-spec.types.d.ts +21 -0
- package/dist/testing/contracts/test-spec.types.d.ts.map +1 -0
- package/dist/testing/contracts/test-spec.types.js +3 -0
- package/dist/testing/contracts/test-spec.types.js.map +1 -0
- package/dist/testing/contracts/testing-metadata.types.d.ts +41 -0
- package/dist/testing/contracts/testing-metadata.types.d.ts.map +1 -0
- package/dist/testing/contracts/testing-metadata.types.js +3 -0
- package/dist/testing/contracts/testing-metadata.types.js.map +1 -0
- package/dist/testing/core/interpolation.d.ts +4 -0
- package/dist/testing/core/interpolation.d.ts.map +1 -0
- package/dist/testing/core/interpolation.js +180 -0
- package/dist/testing/core/interpolation.js.map +1 -0
- package/dist/testing/core/normalize-steps.d.ts +7 -0
- package/dist/testing/core/normalize-steps.d.ts.map +1 -0
- package/dist/testing/core/normalize-steps.js +20 -0
- package/dist/testing/core/normalize-steps.js.map +1 -0
- package/dist/testing/core/resource-store.d.ts +8 -0
- package/dist/testing/core/resource-store.d.ts.map +1 -0
- package/dist/testing/core/resource-store.js +41 -0
- package/dist/testing/core/resource-store.js.map +1 -0
- package/dist/testing/core/spec-registry.d.ts +10 -0
- package/dist/testing/core/spec-registry.d.ts.map +1 -0
- package/dist/testing/core/spec-registry.js +32 -0
- package/dist/testing/core/spec-registry.js.map +1 -0
- package/dist/testing/core/step-registry.d.ts +10 -0
- package/dist/testing/core/step-registry.d.ts.map +1 -0
- package/dist/testing/core/step-registry.js +26 -0
- package/dist/testing/core/step-registry.js.map +1 -0
- package/dist/testing/core/testing-engine.d.ts +14 -0
- package/dist/testing/core/testing-engine.d.ts.map +1 -0
- package/dist/testing/core/testing-engine.js +97 -0
- package/dist/testing/core/testing-engine.js.map +1 -0
- package/dist/testing/core/timeout.d.ts +2 -0
- package/dist/testing/core/timeout.d.ts.map +1 -0
- package/dist/testing/core/timeout.js +18 -0
- package/dist/testing/core/timeout.js.map +1 -0
- package/dist/testing/reporter/attachments.d.ts +4 -0
- package/dist/testing/reporter/attachments.d.ts.map +1 -0
- package/dist/testing/reporter/attachments.js +25 -0
- package/dist/testing/reporter/attachments.js.map +1 -0
- package/dist/testing/reporter/console-reporter.d.ts +45 -0
- package/dist/testing/reporter/console-reporter.d.ts.map +1 -0
- package/dist/testing/reporter/console-reporter.js +189 -0
- package/dist/testing/reporter/console-reporter.js.map +1 -0
- package/dist/testing/reporter/reporter.types.d.ts +37 -0
- package/dist/testing/reporter/reporter.types.d.ts.map +1 -0
- package/dist/testing/reporter/reporter.types.js +3 -0
- package/dist/testing/reporter/reporter.types.js.map +1 -0
- package/dist/testing/runner/lifecycle.d.ts +9 -0
- package/dist/testing/runner/lifecycle.d.ts.map +1 -0
- package/dist/testing/runner/lifecycle.js +33 -0
- package/dist/testing/runner/lifecycle.js.map +1 -0
- package/dist/testing/runner/run-from-metadata.d.ts +24 -0
- package/dist/testing/runner/run-from-metadata.d.ts.map +1 -0
- package/dist/testing/runner/run-from-metadata.js +70 -0
- package/dist/testing/runner/run-from-metadata.js.map +1 -0
- package/dist/testing/runner/scenario-filter.d.ts +9 -0
- package/dist/testing/runner/scenario-filter.d.ts.map +1 -0
- package/dist/testing/runner/scenario-filter.js +22 -0
- package/dist/testing/runner/scenario-filter.js.map +1 -0
- package/dist/testing/steps/api/auth.step.d.ts +3 -0
- package/dist/testing/steps/api/auth.step.d.ts.map +1 -0
- package/dist/testing/steps/api/auth.step.js +38 -0
- package/dist/testing/steps/api/auth.step.js.map +1 -0
- package/dist/testing/steps/api/index.d.ts +3 -0
- package/dist/testing/steps/api/index.d.ts.map +1 -0
- package/dist/testing/steps/api/index.js +10 -0
- package/dist/testing/steps/api/index.js.map +1 -0
- package/dist/testing/steps/api/request.step.d.ts +3 -0
- package/dist/testing/steps/api/request.step.d.ts.map +1 -0
- package/dist/testing/steps/api/request.step.js +281 -0
- package/dist/testing/steps/api/request.step.js.map +1 -0
- package/dist/testing/steps/assert/http.step.d.ts +3 -0
- package/dist/testing/steps/assert/http.step.d.ts.map +1 -0
- package/dist/testing/steps/assert/http.step.js +27 -0
- package/dist/testing/steps/assert/http.step.js.map +1 -0
- package/dist/testing/steps/assert/index.d.ts +3 -0
- package/dist/testing/steps/assert/index.d.ts.map +1 -0
- package/dist/testing/steps/assert/index.js +12 -0
- package/dist/testing/steps/assert/index.js.map +1 -0
- package/dist/testing/steps/assert/jsonpath.step.d.ts +3 -0
- package/dist/testing/steps/assert/jsonpath.step.d.ts.map +1 -0
- package/dist/testing/steps/assert/jsonpath.step.js +40 -0
- package/dist/testing/steps/assert/jsonpath.step.js.map +1 -0
- package/dist/testing/steps/assert/primitives.step.d.ts +3 -0
- package/dist/testing/steps/assert/primitives.step.d.ts.map +1 -0
- package/dist/testing/steps/assert/primitives.step.js +43 -0
- package/dist/testing/steps/assert/primitives.step.js.map +1 -0
- package/dist/testing/steps/test/index.d.ts +3 -0
- package/dist/testing/steps/test/index.d.ts.map +1 -0
- package/dist/testing/steps/test/index.js +8 -0
- package/dist/testing/steps/test/index.js.map +1 -0
- package/dist/testing/steps/test/test-spec.step.d.ts +3 -0
- package/dist/testing/steps/test/test-spec.step.d.ts.map +1 -0
- package/dist/testing/steps/test/test-spec.step.js +41 -0
- package/dist/testing/steps/test/test-spec.step.js.map +1 -0
- package/dist/testing/steps/ui/actions.step.d.ts +3 -0
- package/dist/testing/steps/ui/actions.step.d.ts.map +1 -0
- package/dist/testing/steps/ui/actions.step.js +31 -0
- package/dist/testing/steps/ui/actions.step.js.map +1 -0
- package/dist/testing/steps/ui/assertions.step.d.ts +3 -0
- package/dist/testing/steps/ui/assertions.step.d.ts.map +1 -0
- package/dist/testing/steps/ui/assertions.step.js +41 -0
- package/dist/testing/steps/ui/assertions.step.js.map +1 -0
- package/dist/testing/steps/ui/form.step.d.ts +3 -0
- package/dist/testing/steps/ui/form.step.d.ts.map +1 -0
- package/dist/testing/steps/ui/form.step.js +34 -0
- package/dist/testing/steps/ui/form.step.js.map +1 -0
- package/dist/testing/steps/ui/index.d.ts +3 -0
- package/dist/testing/steps/ui/index.d.ts.map +1 -0
- package/dist/testing/steps/ui/index.js +14 -0
- package/dist/testing/steps/ui/index.js.map +1 -0
- package/dist/testing/steps/ui/navigation.step.d.ts +3 -0
- package/dist/testing/steps/ui/navigation.step.d.ts.map +1 -0
- package/dist/testing/steps/ui/navigation.step.js +39 -0
- package/dist/testing/steps/ui/navigation.step.js.map +1 -0
- package/dist/testing/steps/util/index.d.ts +3 -0
- package/dist/testing/steps/util/index.d.ts.map +1 -0
- package/dist/testing/steps/util/index.js +12 -0
- package/dist/testing/steps/util/index.js.map +1 -0
- package/dist/testing/steps/util/log.step.d.ts +3 -0
- package/dist/testing/steps/util/log.step.d.ts.map +1 -0
- package/dist/testing/steps/util/log.step.js +18 -0
- package/dist/testing/steps/util/log.step.js.map +1 -0
- package/dist/testing/steps/util/require.step.d.ts +3 -0
- package/dist/testing/steps/util/require.step.d.ts.map +1 -0
- package/dist/testing/steps/util/require.step.js +16 -0
- package/dist/testing/steps/util/require.step.js.map +1 -0
- package/dist/testing/steps/util/sleep.step.d.ts +3 -0
- package/dist/testing/steps/util/sleep.step.d.ts.map +1 -0
- package/dist/testing/steps/util/sleep.step.js +13 -0
- package/dist/testing/steps/util/sleep.step.js.map +1 -0
- package/docs/test-data-workflow.md +51 -11
- package/package.json +10 -2
- package/src/commands/run-tests.command.ts +278 -0
- package/src/commands/test-data.command.ts +26 -26
- package/src/commands/test.command.ts +14 -0
- package/src/constants/error-messages.ts +1 -0
- package/src/constants.ts +3 -3
- package/src/controllers/role-metadata.controller.ts +26 -18
- package/src/controllers/service.controller.ts +58 -59
- package/src/dtos/basic-filters.dto.ts +0 -2
- package/src/dtos/create-email-template.dto.ts +7 -0
- package/src/dtos/create-list-of-values.dto.ts +7 -0
- package/src/dtos/create-menu-item-metadata.dto.ts +12 -1
- package/src/dtos/create-role-metadata.dto.ts +9 -0
- package/src/dtos/create-scheduled-job.dto.ts +14 -0
- package/src/dtos/create-security-rule.dto.ts +6 -0
- package/src/dtos/create-sms-template.dto.ts +6 -0
- package/src/dtos/create-user.dto.ts +1 -0
- package/src/dtos/create-view-metadata.dto.ts +11 -0
- package/src/dtos/otp-sign-in.dto.ts +3 -3
- package/src/dtos/otp-sign-up.dto.ts +3 -3
- package/src/dtos/resolve-s3-url.dto.ts +2 -12
- package/src/dtos/sign-up.dto.ts +0 -2
- package/src/dtos/update-email-template.dto.ts +6 -0
- package/src/dtos/update-list-of-values.dto.ts +8 -0
- package/src/dtos/update-menu-item-metadata.dto.ts +12 -0
- package/src/dtos/update-scheduled-job.dto.ts +15 -0
- package/src/dtos/update-security-rule.dto.ts +7 -0
- package/src/dtos/update-sms-template.dto.ts +32 -32
- package/src/dtos/update-view-metadata.dto.ts +12 -0
- package/src/entities/user.entity.ts +3 -0
- package/src/helpers/field-crud-managers/ManyToManyRelationFieldCrudManager.ts +43 -32
- package/src/helpers/field-crud-managers/OneToManyRelationFieldCrudManager.ts +45 -33
- package/src/helpers/security.helper.ts +1 -1
- package/src/index.ts +3 -4
- package/src/repository/solid-base.repository.ts +172 -1
- package/src/seeders/module-metadata-seeder.service.ts +191 -150
- package/src/seeders/module-test-data.service.ts +5 -3
- package/src/seeders/permission-metadata-seeder.service.ts +1 -4
- package/src/seeders/seed-data/solid-core-metadata.json +12 -25
- package/src/services/authentication.service.ts +268 -266
- package/src/services/chatter-message.service.ts +18 -1
- package/src/services/crud-helper.service.ts +79 -36
- package/src/services/crud.service.ts +10 -4
- package/src/services/field-metadata.service.ts +0 -71
- package/src/services/file/disk-file.service.ts +8 -18
- package/src/services/file/index.ts +1 -0
- package/src/services/file/storage-path-builder.ts +56 -0
- package/src/services/media.service.ts +13 -7
- package/src/services/mediaStorageProviders/file-s3-storage-provider.ts +1 -1
- package/src/services/mediaStorageProviders/file-storage-provider.ts +13 -8
- package/src/services/module-metadata.service.ts +18 -15
- package/src/services/queues/common.ts +75 -0
- package/src/services/queues/database-publisher.service.ts +4 -1
- package/src/services/queues/database-subscriber.service.ts +5 -3
- package/src/services/queues/rabbitmq-publisher.service.ts +17 -7
- package/src/services/queues/rabbitmq-subscriber.service.ts +9 -5
- package/src/services/setting.service.ts +5 -3
- package/src/services/settings/default-settings-provider.service.ts +5 -3
- package/src/solid-core.module.ts +20 -12
- package/src/testing/README.md +364 -0
- package/src/testing/__examples__/register-example-specs.ts +6 -0
- package/src/testing/__examples__/specs/custom-health.spec.ts +29 -0
- package/src/testing/__examples__/testing.sample.json +82 -0
- package/src/testing/adapters/api/api-adapter.ts +85 -0
- package/src/testing/adapters/api/api.types.ts +15 -0
- package/src/testing/adapters/ui/playwright-adapter.ts +54 -0
- package/src/testing/adapters/ui/ui.types.ts +4 -0
- package/src/testing/contracts/runtime-context.types.ts +36 -0
- package/src/testing/contracts/test-spec.types.ts +24 -0
- package/src/testing/contracts/testing-metadata.types.ts +46 -0
- package/src/testing/core/interpolation.ts +189 -0
- package/src/testing/core/normalize-steps.ts +21 -0
- package/src/testing/core/resource-store.ts +38 -0
- package/src/testing/core/spec-registry.ts +33 -0
- package/src/testing/core/step-registry.ts +27 -0
- package/src/testing/core/testing-engine.ts +127 -0
- package/src/testing/core/timeout.ts +19 -0
- package/src/testing/reporter/attachments.ts +25 -0
- package/src/testing/reporter/console-reporter.ts +229 -0
- package/src/testing/reporter/reporter.types.ts +36 -0
- package/src/testing/runner/lifecycle.ts +31 -0
- package/src/testing/runner/run-from-metadata.ts +87 -0
- package/src/testing/runner/scenario-filter.ts +33 -0
- package/src/testing/steps/api/auth.step.ts +66 -0
- package/src/testing/steps/api/index.ts +10 -0
- package/src/testing/steps/api/request.step.ts +358 -0
- package/src/testing/steps/assert/http.step.ts +33 -0
- package/src/testing/steps/assert/index.ts +12 -0
- package/src/testing/steps/assert/jsonpath.step.ts +50 -0
- package/src/testing/steps/assert/primitives.step.ts +69 -0
- package/src/testing/steps/test/index.ts +8 -0
- package/src/testing/steps/test/test-spec.step.ts +52 -0
- package/src/testing/steps/ui/actions.step.ts +36 -0
- package/src/testing/steps/ui/assertions.step.ts +54 -0
- package/src/testing/steps/ui/form.step.ts +39 -0
- package/src/testing/steps/ui/index.ts +12 -0
- package/src/testing/steps/ui/navigation.step.ts +53 -0
- package/src/testing/steps/util/index.ts +10 -0
- package/src/testing/steps/util/log.step.ts +19 -0
- package/src/testing/steps/util/require.step.ts +16 -0
- package/src/testing/steps/util/sleep.step.ts +15 -0
- package/tsconfig.json +35 -25
- package/tsconfig.tests.json +14 -0
- package/dist/passport-strategies/local.strategy.d.ts +0 -15
- package/dist/passport-strategies/local.strategy.d.ts.map +0 -1
- package/dist/passport-strategies/local.strategy.js +0 -44
- package/dist/passport-strategies/local.strategy.js.map +0 -1
- package/dist/seeders/email-template-seeder.service.d.ts +0 -10
- package/dist/seeders/email-template-seeder.service.d.ts.map +0 -1
- package/dist/seeders/email-template-seeder.service.js +0 -84
- package/dist/seeders/email-template-seeder.service.js.map +0 -1
- package/dist/seeders/sms-template-seeder.service.d.ts +0 -10
- package/dist/seeders/sms-template-seeder.service.d.ts.map +0 -1
- package/dist/seeders/sms-template-seeder.service.js.map +0 -1
- package/dist/seeders/user-seeder.service.d.ts +0 -10
- package/dist/seeders/user-seeder.service.d.ts.map +0 -1
- package/dist/seeders/user-seeder.service.js +0 -44
- package/dist/seeders/user-seeder.service.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/passport-strategies/local.strategy.ts +0 -28
- package/src/seeders/email-template-seeder.service.ts +0 -49
- package/src/seeders/sms-template-seeder.service.ts +0 -50
- package/src/seeders/user-seeder.service.ts +0 -33
|
@@ -93,23 +93,21 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
93
93
|
relations: { roles: true }
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
async
|
|
97
|
-
const user = await this.resolveUser(signInDto.username, signInDto.email);
|
|
98
|
-
if (!user) {
|
|
99
|
-
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_CREDENTIALS);
|
|
100
|
-
}
|
|
96
|
+
async validateUserForPasswordLogin(user, password) {
|
|
101
97
|
if (!user.active) {
|
|
102
98
|
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_ACTIVE);
|
|
103
99
|
}
|
|
104
|
-
|
|
100
|
+
this.checkAccountBlocked(user);
|
|
101
|
+
const isEqual = await this.hashingService.compare(password, user.password, user.passwordSchemeVersion);
|
|
105
102
|
if (!isEqual) {
|
|
103
|
+
await this.incrementFailedAttempts(user);
|
|
106
104
|
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_CREDENTIALS);
|
|
107
105
|
}
|
|
106
|
+
}
|
|
107
|
+
async rehashPasswordIfRequired(user, password) {
|
|
108
108
|
if (this.hashingService.needsRehash(user.password, user.passwordSchemeVersion)) {
|
|
109
|
-
|
|
110
|
-
return rehashedUser;
|
|
109
|
+
await this.updatePasswordDetails(user, password);
|
|
111
110
|
}
|
|
112
|
-
return user;
|
|
113
111
|
}
|
|
114
112
|
async signUp(signUpDto, activeUser = null) {
|
|
115
113
|
try {
|
|
@@ -258,56 +256,61 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
258
256
|
}
|
|
259
257
|
}
|
|
260
258
|
async otpInitiateRegistration(signUpDto) {
|
|
259
|
+
const isPasswordlessRegistrationEnabled = await this.isPasswordlessRegistrationEnabled();
|
|
260
|
+
if (!isPasswordlessRegistrationEnabled) {
|
|
261
|
+
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORDLESS_REGISTRATION_DISABLED);
|
|
262
|
+
}
|
|
263
|
+
const validationSource = this.resolvePasswordlessValidationSource();
|
|
264
|
+
this.validateOtpRegistrationInput(signUpDto, validationSource);
|
|
265
|
+
const existingUser = await this.findExistingRegistrationUser(signUpDto);
|
|
266
|
+
if ((0, class_validator_1.isNotEmpty)(existingUser) && existingUser.active) {
|
|
267
|
+
throw new common_1.ConflictException(error_messages_1.ERROR_MESSAGES.USER_ALREADY_EXISTS);
|
|
268
|
+
}
|
|
261
269
|
try {
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORDLESS_REGISTRATION_DISABLED);
|
|
265
|
-
}
|
|
266
|
-
if ((0, class_validator_1.isEmpty)(signUpDto.mobile) && (0, class_validator_1.isEmpty)(signUpDto.email)) {
|
|
267
|
-
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.REGISTRATION_REQUIRES_CONTACT);
|
|
268
|
-
}
|
|
269
|
-
if (signUpDto.validationSources.includes(constants_1.TransactionalRegistrationValidationSource.EMAIL) && (0, class_validator_1.isEmpty)(signUpDto.email)) {
|
|
270
|
-
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.EMAIL_REQUIRED_FOR_VALIDATION);
|
|
271
|
-
}
|
|
272
|
-
if (signUpDto.validationSources.includes(constants_1.TransactionalRegistrationValidationSource.MOBILE) && (0, class_validator_1.isEmpty)(signUpDto.mobile)) {
|
|
273
|
-
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.MOBILE_REQUIRED_FOR_VALIDATION);
|
|
274
|
-
}
|
|
275
|
-
const existingUser = await this.userRepository.findOne({
|
|
276
|
-
where: [
|
|
277
|
-
{ email: signUpDto.email, },
|
|
278
|
-
{ mobile: signUpDto.mobile, },
|
|
279
|
-
{ username: signUpDto.username, }
|
|
280
|
-
]
|
|
281
|
-
});
|
|
282
|
-
if ((0, class_validator_1.isNotEmpty)(existingUser) && existingUser.active) {
|
|
283
|
-
throw new common_1.ConflictException(error_messages_1.ERROR_MESSAGES.USER_ALREADY_EXISTS);
|
|
284
|
-
}
|
|
285
|
-
let passwordlessRegistrationValidateWhat = this.settingService.getConfigValue('passwordlessRegistrationValidateWhat');
|
|
286
|
-
if (!Array.isArray(passwordlessRegistrationValidateWhat)) {
|
|
287
|
-
passwordlessRegistrationValidateWhat = [passwordlessRegistrationValidateWhat];
|
|
288
|
-
}
|
|
289
|
-
const finalRegistrationVerificationSources = this.calculateVerificationSources(passwordlessRegistrationValidateWhat, signUpDto);
|
|
290
|
-
let user = existingUser;
|
|
291
|
-
if ((0, class_validator_1.isEmpty)(user)) {
|
|
292
|
-
user = this.createUser(signUpDto);
|
|
293
|
-
await this.populateVerificationTokens(finalRegistrationVerificationSources, user);
|
|
294
|
-
await this.userRepository.save(user);
|
|
295
|
-
await this.userService.addRoleToUser(user.username, this.settingService.getConfigValue('defaultRole'));
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
await this.populateVerificationTokens(finalRegistrationVerificationSources, user);
|
|
299
|
-
await this.userRepository.save(user);
|
|
300
|
-
}
|
|
301
|
-
await this.notifyUserOnOtpInitiateRegistration(user, finalRegistrationVerificationSources);
|
|
302
|
-
return { message: success_messages_1.SUCCESS_MESSAGES.OTP_SENT_SUCCESS_REGISTRATION };
|
|
270
|
+
const user = await this.upsertUserWithRegistrationVerificationTokens(existingUser, signUpDto, validationSource);
|
|
271
|
+
await this.notifyUserOnOtpInitiateRegistration(user, validationSource);
|
|
303
272
|
}
|
|
304
273
|
catch (err) {
|
|
305
|
-
|
|
306
|
-
if (err.code === pgUniqueViolationErrorCode) {
|
|
274
|
+
if (err.code === '23505') {
|
|
307
275
|
throw new common_1.ConflictException(error_messages_1.ERROR_MESSAGES.USER_ALREADY_EXISTS);
|
|
308
276
|
}
|
|
309
277
|
throw err;
|
|
310
278
|
}
|
|
279
|
+
return { message: success_messages_1.SUCCESS_MESSAGES.OTP_SENT_SUCCESS_REGISTRATION };
|
|
280
|
+
}
|
|
281
|
+
validateOtpRegistrationInput(signUpDto, validationSource) {
|
|
282
|
+
if (validationSource === constants_1.PasswordlessRegistrationValidateWhatSources.EMAIL && (0, class_validator_1.isEmpty)(signUpDto.email)) {
|
|
283
|
+
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.EMAIL_REQUIRED_FOR_VALIDATION);
|
|
284
|
+
}
|
|
285
|
+
if (validationSource === constants_1.PasswordlessRegistrationValidateWhatSources.MOBILE && (0, class_validator_1.isEmpty)(signUpDto.mobile)) {
|
|
286
|
+
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.MOBILE_REQUIRED_FOR_VALIDATION);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
async findExistingRegistrationUser(signUpDto) {
|
|
290
|
+
return this.userRepository.findOne({
|
|
291
|
+
where: [
|
|
292
|
+
{ email: signUpDto.email },
|
|
293
|
+
{ mobile: signUpDto.mobile },
|
|
294
|
+
{ username: signUpDto.username },
|
|
295
|
+
]
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
resolvePasswordlessValidationSource() {
|
|
299
|
+
return this.settingService.getConfigValue('passwordlessRegistrationValidateWhat');
|
|
300
|
+
}
|
|
301
|
+
async upsertUserWithRegistrationVerificationTokens(existingUser, signUpDto, validationSource) {
|
|
302
|
+
let user = existingUser;
|
|
303
|
+
if ((0, class_validator_1.isEmpty)(user)) {
|
|
304
|
+
user = this.createUser(signUpDto);
|
|
305
|
+
await this.assignRegistrationOtp(validationSource, user);
|
|
306
|
+
await this.userRepository.save(user);
|
|
307
|
+
await this.userService.addRoleToUser(user.username, this.settingService.getConfigValue('defaultRole'));
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
await this.assignRegistrationOtp(validationSource, user);
|
|
311
|
+
await this.userRepository.save(user);
|
|
312
|
+
}
|
|
313
|
+
return user;
|
|
311
314
|
}
|
|
312
315
|
createUser(signUpDto) {
|
|
313
316
|
const user = new user_entity_1.User();
|
|
@@ -318,44 +321,36 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
318
321
|
user.lastLoginProvider = LoginProvider.OTP;
|
|
319
322
|
return user;
|
|
320
323
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if (configuredRegistrationValidationSources.includes(constants_1.RegistrationValidationSource.TRANSACTIONAL)) {
|
|
324
|
-
finalRegistrationValidationSources.push(...signUpDto.validationSources);
|
|
325
|
-
}
|
|
326
|
-
return finalRegistrationValidationSources;
|
|
327
|
-
}
|
|
328
|
-
async populateVerificationTokens(finalRegistrationValidationSources, user) {
|
|
329
|
-
if (finalRegistrationValidationSources.length === 0) {
|
|
324
|
+
async assignRegistrationOtp(passwordlessRegistrationValidateWhat, user) {
|
|
325
|
+
if (!passwordlessRegistrationValidateWhat) {
|
|
330
326
|
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.VALIDATION_SOURCE_REQUIRED);
|
|
331
327
|
}
|
|
332
|
-
|
|
328
|
+
const autoLoginUserOnRegistration = this.settingService.getConfigValue('autoLoginUserOnRegistration');
|
|
329
|
+
if (passwordlessRegistrationValidateWhat === constants_1.PasswordlessRegistrationValidateWhatSources.EMAIL) {
|
|
333
330
|
const { token, expiresAt } = await this.otp();
|
|
334
331
|
user.emailVerificationTokenOnRegistration = token;
|
|
335
332
|
user.emailVerificationTokenOnRegistrationExpiresAt = expiresAt;
|
|
336
|
-
const autoLoginUserOnRegistration = this.settingService.getConfigValue('autoLoginUserOnRegistration');
|
|
337
333
|
if (autoLoginUserOnRegistration) {
|
|
338
334
|
user.emailVerificationTokenOnLogin = token;
|
|
339
335
|
user.emailVerificationTokenOnLoginExpiresAt = expiresAt;
|
|
340
336
|
}
|
|
341
337
|
}
|
|
342
|
-
if (
|
|
338
|
+
if (passwordlessRegistrationValidateWhat === constants_1.PasswordlessRegistrationValidateWhatSources.MOBILE) {
|
|
343
339
|
const { token, expiresAt } = await this.otp();
|
|
344
340
|
user.mobileVerificationTokenOnRegistration = token;
|
|
345
341
|
user.mobileVerificationTokenOnRegistrationExpiresAt = expiresAt;
|
|
346
|
-
const autoLoginUserOnRegistration = this.settingService.getConfigValue('autoLoginUserOnRegistration');
|
|
347
342
|
if (autoLoginUserOnRegistration) {
|
|
348
343
|
user.mobileVerificationTokenOnLogin = token;
|
|
349
344
|
user.mobileVerificationTokenOnLoginExpiresAt = expiresAt;
|
|
350
345
|
}
|
|
351
346
|
}
|
|
352
347
|
}
|
|
353
|
-
async notifyUserOnOtpInitiateRegistration(user,
|
|
348
|
+
async notifyUserOnOtpInitiateRegistration(user, registrationValidationSource) {
|
|
354
349
|
const companyLogo = await this.getCompanyLogo();
|
|
355
350
|
const dummyOtp = this.settingService.getConfigValue('dummyOtp');
|
|
356
351
|
if (dummyOtp)
|
|
357
352
|
return;
|
|
358
|
-
if (
|
|
353
|
+
if (registrationValidationSource === constants_1.PasswordlessLoginValidateWhatSources.EMAIL) {
|
|
359
354
|
const mailService = this.mailServiceFactory.getMailService();
|
|
360
355
|
mailService.sendEmailUsingTemplate(user.email, 'otp-on-register', {
|
|
361
356
|
solidAppName: this.settingService.getConfigValue('appTitle'),
|
|
@@ -366,7 +361,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
366
361
|
companyLogoUrl: companyLogo
|
|
367
362
|
}, this.settingService.getConfigValue('shouldQueueEmails'), null, null, 'user', user.id);
|
|
368
363
|
}
|
|
369
|
-
if (
|
|
364
|
+
if (registrationValidationSource === constants_1.PasswordlessLoginValidateWhatSources.MOBILE) {
|
|
370
365
|
const smsService = this.smsFactory.getSmsService();
|
|
371
366
|
smsService.sendSMSUsingTemplate(user.mobile, 'otp-on-register', {
|
|
372
367
|
solidAppName: this.settingService.getConfigValue('appTitle'),
|
|
@@ -383,67 +378,65 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
383
378
|
if (!isPasswordlessRegistrationEnabled) {
|
|
384
379
|
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORDLESS_REGISTRATION_DISABLED);
|
|
385
380
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
381
|
+
const { type, identifier, otp } = confirmSignUpDto;
|
|
382
|
+
if (type !== constants_1.PasswordlessRegistrationValidateWhatSources.EMAIL &&
|
|
383
|
+
type !== constants_1.PasswordlessRegistrationValidateWhatSources.MOBILE) {
|
|
384
|
+
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TYPE);
|
|
385
|
+
}
|
|
386
|
+
const user = await this.findUserByRegistrationIdentifier(type, identifier);
|
|
387
|
+
this.validateRegistrationOtp(user, otp, type);
|
|
388
|
+
this.clearRegistrationOtp(user, type);
|
|
389
|
+
user.active = this.settingService.getConfigValue('activateUserOnRegistration') &&
|
|
390
|
+
await this.areAllPasswordlessRegistrationValidationSourcesVerified(user);
|
|
391
|
+
const savedUser = await this.userRepository.save(user);
|
|
392
|
+
this.triggerRegistrationEvent(savedUser);
|
|
393
|
+
return { active: savedUser.active, message: `User registration verified for ${type}` };
|
|
394
|
+
}
|
|
395
|
+
async findUserByRegistrationIdentifier(type, identifier) {
|
|
396
|
+
const where = type === constants_1.PasswordlessRegistrationValidateWhatSources.EMAIL
|
|
397
|
+
? { email: identifier }
|
|
398
|
+
: { mobile: identifier };
|
|
399
|
+
const user = await this.userRepository.findOne({ where });
|
|
400
|
+
if (!user) {
|
|
401
|
+
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
|
|
402
|
+
}
|
|
403
|
+
return user;
|
|
404
|
+
}
|
|
405
|
+
validateRegistrationOtp(user, otp, type) {
|
|
406
|
+
const isEmail = type === constants_1.PasswordlessRegistrationValidateWhatSources.EMAIL;
|
|
407
|
+
const token = isEmail ? user.emailVerificationTokenOnRegistration : user.mobileVerificationTokenOnRegistration;
|
|
408
|
+
const expiresAt = isEmail ? user.emailVerificationTokenOnRegistrationExpiresAt : user.mobileVerificationTokenOnRegistrationExpiresAt;
|
|
409
|
+
if (token !== otp) {
|
|
410
|
+
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
|
|
411
|
+
}
|
|
412
|
+
if (expiresAt < new Date()) {
|
|
413
|
+
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.OTP_EXPIRED);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
clearRegistrationOtp(user, type) {
|
|
417
|
+
if (type === constants_1.PasswordlessRegistrationValidateWhatSources.EMAIL) {
|
|
401
418
|
user.emailVerifiedOnRegistrationAt = new Date();
|
|
402
419
|
user.emailVerificationTokenOnRegistration = null;
|
|
403
420
|
user.emailVerificationTokenOnRegistrationExpiresAt = null;
|
|
404
|
-
user.active = this.settingService.getConfigValue('activateUserOnRegistration') && await this.areRegistrationValidationSourcesVerified(user);
|
|
405
|
-
const savedUser = await this.userRepository.save(user);
|
|
406
|
-
this.triggerRegistrationEvent(savedUser);
|
|
407
|
-
return { active: savedUser.active, message: `User registration verified for ${confirmSignUpDto.type}` };
|
|
408
421
|
}
|
|
409
|
-
else
|
|
410
|
-
const user = await this.userRepository.findOne({
|
|
411
|
-
where: {
|
|
412
|
-
mobile: confirmSignUpDto.identifier,
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
if (!user) {
|
|
416
|
-
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
|
|
417
|
-
}
|
|
418
|
-
if (user.mobileVerificationTokenOnRegistration !== confirmSignUpDto.otp) {
|
|
419
|
-
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
|
|
420
|
-
}
|
|
421
|
-
if (user.mobileVerificationTokenOnRegistrationExpiresAt < new Date()) {
|
|
422
|
-
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
|
|
423
|
-
}
|
|
422
|
+
else {
|
|
424
423
|
user.mobileVerifiedOnRegistrationAt = new Date();
|
|
425
424
|
user.mobileVerificationTokenOnRegistration = null;
|
|
426
425
|
user.mobileVerificationTokenOnRegistrationExpiresAt = null;
|
|
427
|
-
user.active = this.settingService.getConfigValue('activateUserOnRegistration') && await this.areRegistrationValidationSourcesVerified(user);
|
|
428
|
-
const savedUser = await this.userRepository.save(user);
|
|
429
|
-
this.triggerRegistrationEvent(savedUser);
|
|
430
|
-
return { active: savedUser.active, message: `User registration verified for ${confirmSignUpDto.type}` };
|
|
431
426
|
}
|
|
432
|
-
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TYPE);
|
|
433
427
|
}
|
|
434
428
|
triggerRegistrationEvent(savedUser) {
|
|
435
429
|
const event = new interfaces_1.EventDetails(interfaces_1.EventType.USER_REGISTERED, savedUser);
|
|
436
430
|
this.eventEmitter.emit(interfaces_1.EventType.USER_REGISTERED, event);
|
|
437
431
|
}
|
|
438
|
-
async
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
if (registrationValidationSources.includes(constants_1.RegistrationValidationSource.EMAIL)) {
|
|
432
|
+
async areAllPasswordlessRegistrationValidationSourcesVerified(user) {
|
|
433
|
+
const registrationValidationSource = this.resolvePasswordlessValidationSource();
|
|
434
|
+
if (registrationValidationSource === constants_1.PasswordlessLoginValidateWhatSources.EMAIL) {
|
|
442
435
|
if (!user.emailVerifiedOnRegistrationAt) {
|
|
443
436
|
return false;
|
|
444
437
|
}
|
|
445
438
|
}
|
|
446
|
-
if (
|
|
439
|
+
if (registrationValidationSource === constants_1.PasswordlessLoginValidateWhatSources.MOBILE) {
|
|
447
440
|
if (!user.mobileVerifiedOnRegistrationAt) {
|
|
448
441
|
return false;
|
|
449
442
|
}
|
|
@@ -461,7 +454,13 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
461
454
|
};
|
|
462
455
|
}
|
|
463
456
|
async signIn(signInDto) {
|
|
464
|
-
const user = await this.
|
|
457
|
+
const user = await this.resolveUser(signInDto.username, signInDto.email);
|
|
458
|
+
if (!user) {
|
|
459
|
+
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_CREDENTIALS);
|
|
460
|
+
}
|
|
461
|
+
await this.validateUserForPasswordLogin(user, signInDto.password);
|
|
462
|
+
await this.rehashPasswordIfRequired(user, signInDto.password);
|
|
463
|
+
await this.resetFailedAttempts(user);
|
|
465
464
|
const tokens = await this.generateTokens(user);
|
|
466
465
|
await this.userActivityHistoryService.logEvent('login', user);
|
|
467
466
|
return {
|
|
@@ -501,63 +500,67 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
501
500
|
if (!isPasswordlessRegistrationEnabled) {
|
|
502
501
|
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORDLESS_REGISTRATION_DISABLED);
|
|
503
502
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
throw new common_1.
|
|
503
|
+
const type = this.resolveLoginType(signInDto);
|
|
504
|
+
const user = await this.findUserForLogin(type, signInDto.identifier);
|
|
505
|
+
await this.assignLoginOtp(user, type);
|
|
506
|
+
this.notifyUserOnOtpInititateLogin(user, type);
|
|
507
|
+
return this.buildLoginOtpResponse(user, type);
|
|
508
|
+
}
|
|
509
|
+
resolveLoginType(signInDto) {
|
|
510
|
+
const setting = this.settingService.getConfigValue('passwordlessLoginValidateWhat');
|
|
511
|
+
if (setting === constants_1.PasswordlessLoginValidateWhatSources.SELECTABLE) {
|
|
512
|
+
if (signInDto.type !== constants_1.PasswordlessLoginValidateWhatSources.EMAIL &&
|
|
513
|
+
signInDto.type !== constants_1.PasswordlessLoginValidateWhatSources.MOBILE) {
|
|
514
|
+
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TYPE);
|
|
516
515
|
}
|
|
517
|
-
|
|
516
|
+
return signInDto.type;
|
|
517
|
+
}
|
|
518
|
+
if (setting === constants_1.PasswordlessLoginValidateWhatSources.EMAIL ||
|
|
519
|
+
setting === constants_1.PasswordlessLoginValidateWhatSources.MOBILE) {
|
|
520
|
+
return setting;
|
|
521
|
+
}
|
|
522
|
+
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TYPE);
|
|
523
|
+
}
|
|
524
|
+
async findUserForLogin(type, identifier, options = {}) {
|
|
525
|
+
const typeWhere = type === constants_1.PasswordlessLoginValidateWhatSources.EMAIL
|
|
526
|
+
? { email: identifier }
|
|
527
|
+
: { mobile: identifier };
|
|
528
|
+
const user = await this.userRepository.findOne({
|
|
529
|
+
where: [{ username: identifier }, typeWhere],
|
|
530
|
+
...(options.withRoles ? { relations: { roles: true } } : {}),
|
|
531
|
+
});
|
|
532
|
+
if (!user) {
|
|
533
|
+
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
|
|
534
|
+
}
|
|
535
|
+
if (!user.active) {
|
|
536
|
+
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_INACTIVE);
|
|
537
|
+
}
|
|
538
|
+
return user;
|
|
539
|
+
}
|
|
540
|
+
async assignLoginOtp(user, type) {
|
|
541
|
+
const { token, expiresAt } = await this.otp();
|
|
542
|
+
if (type === constants_1.PasswordlessLoginValidateWhatSources.EMAIL) {
|
|
518
543
|
user.emailVerificationTokenOnLogin = token;
|
|
519
544
|
user.emailVerificationTokenOnLoginExpiresAt = expiresAt;
|
|
520
|
-
await this.userRepository.save(user);
|
|
521
|
-
this.notifyUserOnOtpInititateLogin(user, constants_1.RegistrationValidationSource.EMAIL);
|
|
522
|
-
return {
|
|
523
|
-
message: success_messages_1.SUCCESS_MESSAGES.OTP_SENT_SUCCESS_LOGIN,
|
|
524
|
-
user: {
|
|
525
|
-
email: this.maskEmail(user.email)
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
545
|
}
|
|
529
|
-
else
|
|
530
|
-
const user = await this.userRepository.findOne({
|
|
531
|
-
where: [
|
|
532
|
-
{ username: signInDto.identifier },
|
|
533
|
-
{ mobile: signInDto.identifier },
|
|
534
|
-
]
|
|
535
|
-
});
|
|
536
|
-
if (!user) {
|
|
537
|
-
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
|
|
538
|
-
}
|
|
539
|
-
const { token, expiresAt } = await this.otp();
|
|
546
|
+
else {
|
|
540
547
|
user.mobileVerificationTokenOnLogin = token;
|
|
541
548
|
user.mobileVerificationTokenOnLoginExpiresAt = expiresAt;
|
|
542
|
-
await this.userRepository.save(user);
|
|
543
|
-
this.notifyUserOnOtpInititateLogin(user, constants_1.RegistrationValidationSource.MOBILE);
|
|
544
|
-
return {
|
|
545
|
-
message: success_messages_1.SUCCESS_MESSAGES.OTP_SENT_SUCCESS_LOGIN,
|
|
546
|
-
user: {
|
|
547
|
-
mobile: this.maskMobile(user.mobile)
|
|
548
|
-
}
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TYPE);
|
|
553
549
|
}
|
|
550
|
+
await this.userRepository.save(user);
|
|
551
|
+
}
|
|
552
|
+
buildLoginOtpResponse(user, type) {
|
|
553
|
+
const maskedIdentifier = type === constants_1.PasswordlessLoginValidateWhatSources.EMAIL
|
|
554
|
+
? { email: this.maskEmail(user.email) }
|
|
555
|
+
: { mobile: this.maskMobile(user.mobile) };
|
|
556
|
+
return { message: success_messages_1.SUCCESS_MESSAGES.OTP_SENT_SUCCESS_LOGIN, user: maskedIdentifier };
|
|
554
557
|
}
|
|
555
558
|
async notifyUserOnOtpInititateLogin(user, loginType) {
|
|
556
559
|
const companyLogo = await this.getCompanyLogo();
|
|
557
560
|
const dummyOtp = this.settingService.getConfigValue('dummyOtp');
|
|
558
561
|
if (dummyOtp)
|
|
559
562
|
return;
|
|
560
|
-
if (loginType === constants_1.
|
|
563
|
+
if (loginType === constants_1.PasswordlessLoginValidateWhatSources.EMAIL) {
|
|
561
564
|
const mailService = this.mailServiceFactory.getMailService();
|
|
562
565
|
mailService.sendEmailUsingTemplate(user.email, 'otp-on-login', {
|
|
563
566
|
solidAppName: this.settingService.getConfigValue('appTitle'),
|
|
@@ -568,7 +571,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
568
571
|
companyLogoUrl: companyLogo
|
|
569
572
|
}, this.settingService.getConfigValue('shouldQueueEmails'), null, null, 'user', user.id);
|
|
570
573
|
}
|
|
571
|
-
if (loginType === constants_1.
|
|
574
|
+
if (loginType === constants_1.PasswordlessLoginValidateWhatSources.MOBILE) {
|
|
572
575
|
const smsService = this.smsFactory.getSmsService();
|
|
573
576
|
smsService.sendSMSUsingTemplate(user.mobile, 'otp-on-login', {
|
|
574
577
|
solidAppName: this.settingService.getConfigValue('appTitle'),
|
|
@@ -585,69 +588,53 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
585
588
|
if (!isPasswordlessRegistrationEnabled) {
|
|
586
589
|
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORDLESS_REGISTRATION_DISABLED);
|
|
587
590
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
591
|
+
const { type, identifier, otp } = confirmSignInDto;
|
|
592
|
+
if (type !== constants_1.PasswordlessLoginValidateWhatSources.EMAIL &&
|
|
593
|
+
type !== constants_1.PasswordlessLoginValidateWhatSources.MOBILE) {
|
|
594
|
+
throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TYPE);
|
|
595
|
+
}
|
|
596
|
+
const user = await this.findUserForLogin(type, identifier, { withRoles: true });
|
|
597
|
+
this.checkAccountBlocked(user);
|
|
598
|
+
try {
|
|
599
|
+
this.validateLoginOtp(user, otp, type);
|
|
600
|
+
}
|
|
601
|
+
catch (e) {
|
|
602
|
+
await this.incrementFailedAttempts(user);
|
|
603
|
+
throw e;
|
|
604
|
+
}
|
|
605
|
+
this.clearLoginOtp(user, type);
|
|
606
|
+
user.failedLoginAttempts = 0;
|
|
607
|
+
await this.userRepository.save(user);
|
|
608
|
+
return this.buildLoginTokenResponse(user);
|
|
609
|
+
}
|
|
610
|
+
validateLoginOtp(user, otp, type) {
|
|
611
|
+
const isEmail = type === constants_1.PasswordlessLoginValidateWhatSources.EMAIL;
|
|
612
|
+
const token = isEmail ? user.emailVerificationTokenOnLogin : user.mobileVerificationTokenOnLogin;
|
|
613
|
+
const expiresAt = isEmail ? user.emailVerificationTokenOnLoginExpiresAt : user.mobileVerificationTokenOnLoginExpiresAt;
|
|
614
|
+
if (token !== otp) {
|
|
615
|
+
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
|
|
616
|
+
}
|
|
617
|
+
if (expiresAt < new Date()) {
|
|
618
|
+
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.OTP_EXPIRED);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
clearLoginOtp(user, type) {
|
|
622
|
+
if (type === constants_1.PasswordlessLoginValidateWhatSources.EMAIL) {
|
|
610
623
|
user.emailVerifiedOnLoginAt = new Date();
|
|
611
624
|
user.emailVerificationTokenOnLogin = null;
|
|
612
625
|
user.emailVerificationTokenOnLoginExpiresAt = null;
|
|
613
|
-
await this.userRepository.save(user);
|
|
614
|
-
const { accessToken, refreshToken } = await this.generateTokens(user);
|
|
615
|
-
const { id, username, email, mobile, lastLoginProvider } = user;
|
|
616
|
-
const roles = user.roles.map((role) => role.name);
|
|
617
|
-
return { accessToken, refreshToken, user: { id, username, email, mobile, lastLoginProvider, roles } };
|
|
618
626
|
}
|
|
619
|
-
else
|
|
620
|
-
const user = await this.userRepository.findOne({
|
|
621
|
-
where: [
|
|
622
|
-
{ username: confirmSignInDto.identifier },
|
|
623
|
-
{ mobile: confirmSignInDto.identifier },
|
|
624
|
-
],
|
|
625
|
-
relations: {
|
|
626
|
-
roles: true
|
|
627
|
-
}
|
|
628
|
-
});
|
|
629
|
-
if (!user) {
|
|
630
|
-
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_ACTIVE);
|
|
631
|
-
}
|
|
632
|
-
if (!user.active) {
|
|
633
|
-
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_INACTIVE);
|
|
634
|
-
}
|
|
635
|
-
if (user.mobileVerificationTokenOnLogin !== confirmSignInDto.otp) {
|
|
636
|
-
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
|
|
637
|
-
}
|
|
638
|
-
if (user.mobileVerificationTokenOnLoginExpiresAt < new Date()) {
|
|
639
|
-
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
|
|
640
|
-
}
|
|
627
|
+
else {
|
|
641
628
|
user.mobileVerifiedOnLoginAt = new Date();
|
|
642
629
|
user.mobileVerificationTokenOnLogin = null;
|
|
643
630
|
user.mobileVerificationTokenOnLoginExpiresAt = null;
|
|
644
|
-
await this.userRepository.save(user);
|
|
645
|
-
const { accessToken, refreshToken } = await this.generateTokens(user);
|
|
646
|
-
const { id, username, email, mobile, lastLoginProvider } = user;
|
|
647
|
-
const roles = user.roles.map((role) => role.name);
|
|
648
|
-
return { accessToken, refreshToken, user: { id, username, email, mobile, lastLoginProvider, roles } };
|
|
649
631
|
}
|
|
650
|
-
|
|
632
|
+
}
|
|
633
|
+
async buildLoginTokenResponse(user) {
|
|
634
|
+
const { accessToken, refreshToken } = await this.generateTokens(user);
|
|
635
|
+
const { id, username, email, mobile, lastLoginProvider } = user;
|
|
636
|
+
const roles = user.roles.map((role) => role.name);
|
|
637
|
+
return { accessToken, refreshToken, user: { id, username, email, mobile, lastLoginProvider, roles } };
|
|
651
638
|
}
|
|
652
639
|
async changePassword(changePasswordDto, activeUser) {
|
|
653
640
|
const user = await this.userRepository.findOne({
|
|
@@ -911,7 +898,18 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
911
898
|
roles: true
|
|
912
899
|
}
|
|
913
900
|
});
|
|
914
|
-
|
|
901
|
+
if (!user) {
|
|
902
|
+
throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
|
|
903
|
+
}
|
|
904
|
+
this.checkAccountBlocked(user);
|
|
905
|
+
try {
|
|
906
|
+
await this.validateUserUsingGoogle(user);
|
|
907
|
+
}
|
|
908
|
+
catch (e) {
|
|
909
|
+
await this.incrementFailedAttempts(user);
|
|
910
|
+
throw e;
|
|
911
|
+
}
|
|
912
|
+
await this.resetFailedAttempts(user);
|
|
915
913
|
const tokens = await this.generateTokens(user);
|
|
916
914
|
return {
|
|
917
915
|
user: {
|
|
@@ -927,6 +925,22 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
|
|
|
927
925
|
async isPasswordlessRegistrationEnabled() {
|
|
928
926
|
return this.settingService.getConfigValue('passwordLessAuth');
|
|
929
927
|
}
|
|
928
|
+
checkAccountBlocked(user) {
|
|
929
|
+
const maxFailedAttempts = this.settingService.getConfigValue('maxFailedLoginAttempts');
|
|
930
|
+
if (maxFailedAttempts > 0 && user.failedLoginAttempts >= maxFailedAttempts) {
|
|
931
|
+
throw new common_1.ForbiddenException(error_messages_1.ERROR_MESSAGES.ACCOUNT_BLOCKED);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
async incrementFailedAttempts(user) {
|
|
935
|
+
user.failedLoginAttempts += 1;
|
|
936
|
+
await this.userRepository.save(user);
|
|
937
|
+
}
|
|
938
|
+
async resetFailedAttempts(user) {
|
|
939
|
+
if (user.failedLoginAttempts === 0)
|
|
940
|
+
return;
|
|
941
|
+
user.failedLoginAttempts = 0;
|
|
942
|
+
await this.userRepository.save(user);
|
|
943
|
+
}
|
|
930
944
|
async logout(refreshToken) {
|
|
931
945
|
try {
|
|
932
946
|
const payload = this.jwtService.decode(refreshToken);
|