@ozdao/martyrs 0.2.585 → 0.2.587
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/auth.server.js +175 -97
- package/dist/{authJwt-J1csaMWA.js → authJwt-DKbMMjw0.js} +33 -0
- package/dist/chats.server.js +3 -3
- package/dist/community.server.js +2 -2
- package/dist/core.server.js +201 -13
- package/dist/{core.websocket-C2FxNmZ1.js → core.websocket-Cl76z2wT.js} +41 -5
- package/dist/{crud-q1ye5IhV.js → crud-DpOXTZep.js} +1 -1
- package/dist/events.server.js +3 -3
- package/dist/files.server.js +2 -2
- package/dist/gallery.server.js +2 -2
- package/dist/index-kvBwwb0w.js +427 -0
- package/dist/inventory.server.js +3 -3
- package/dist/{mailing-DuEFRsa3.js → mailing-DT7nbNjZ.js} +16 -3
- package/dist/{main-xL-jtBkT.js → main-BIf-WirR.js} +863 -865
- package/dist/marketplace.server.js +2 -2
- package/dist/martyrs/dist/{main-xL-jtBkT.js → main-BIf-WirR.js} +192 -38
- package/dist/martyrs/dist/main-BIf-WirR.js.map +1 -0
- package/dist/martyrs/dist/{web-BA6h6Z8P.js → web-O7lXcjg0.js} +2 -2
- package/dist/martyrs/dist/{web-BA6h6Z8P.js.map → web-O7lXcjg0.js.map} +1 -1
- package/dist/martyrs/src/components/Button/{Button.vue2.js → Button.vue.js} +8 -7
- package/dist/martyrs/src/components/Button/Button.vue.js.map +1 -0
- package/dist/martyrs/src/components/Feed/Carousel.vue.js +1 -1
- package/dist/martyrs/src/components/Feed/Feed.vue.js +1 -1
- package/dist/martyrs/src/components/FieldBig/FieldBig.vue.js +1 -1
- package/dist/martyrs/src/components/Loader/{Loader.vue.js → Loader.vue2.js} +3 -3
- package/dist/martyrs/src/components/Loader/Loader.vue2.js.map +1 -0
- package/dist/martyrs/src/components/LocationMarker/LocationMarker.vue.js +1 -1
- package/dist/martyrs/src/components/Media/Media.vue.js +1 -1
- package/dist/martyrs/src/components/Menu/{Menu.vue.js → Menu.vue2.js} +2 -2
- package/dist/martyrs/src/components/Menu/Menu.vue2.js.map +1 -0
- package/dist/martyrs/src/components/Select/{Select.vue.js → Select.vue2.js} +2 -2
- package/dist/martyrs/src/components/Select/Select.vue2.js.map +1 -0
- package/dist/martyrs/src/components/Tooltip/Tooltip.vue2.js +17 -22
- package/dist/martyrs/src/components/Tooltip/Tooltip.vue2.js.map +1 -1
- package/dist/martyrs/src/components/UploadImage/UploadImage.vue.js +1 -1
- package/dist/martyrs/src/components/UploadImageMultiple/UploadImageMultiple.vue.js +1 -1
- package/dist/martyrs/src/modules/auth/auth.client.js +18 -24
- package/dist/martyrs/src/modules/auth/auth.client.js.map +1 -1
- package/dist/martyrs/src/modules/auth/views/components/blocks/OtpDialog.vue.js +178 -0
- package/dist/martyrs/src/modules/auth/views/components/blocks/OtpDialog.vue.js.map +1 -0
- package/dist/martyrs/src/modules/auth/views/components/pages/Invite.vue.js +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.js +53 -45
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.js.map +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEditAccount.vue.js +198 -14
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEditAccount.vue.js.map +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEditProfile.vue.js +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/ResetPassword.vue.js +70 -29
- package/dist/martyrs/src/modules/auth/views/components/pages/ResetPassword.vue.js.map +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/SignIn.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/SignIn.vue.js.map +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/SignUp.vue.js +86 -30
- package/dist/martyrs/src/modules/auth/views/components/pages/SignUp.vue.js.map +1 -1
- package/dist/martyrs/src/modules/auth/views/plugins/otp.plugin.js +100 -0
- package/dist/martyrs/src/modules/auth/views/plugins/otp.plugin.js.map +1 -0
- package/dist/martyrs/src/modules/auth/views/router/auth.router.js +2 -31
- package/dist/martyrs/src/modules/auth/views/router/auth.router.js.map +1 -1
- package/dist/martyrs/src/modules/auth/views/router/users.router.js +0 -14
- package/dist/martyrs/src/modules/auth/views/router/users.router.js.map +1 -1
- package/dist/martyrs/src/modules/auth/views/store/auth.js +1 -56
- package/dist/martyrs/src/modules/auth/views/store/auth.js.map +1 -1
- package/dist/martyrs/src/modules/auth/views/store/users.js +5 -1
- package/dist/martyrs/src/modules/auth/views/store/users.js.map +1 -1
- package/dist/martyrs/src/modules/community/components/layouts/Community.vue.js +1 -1
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.js +2 -2
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.js +1 -1
- package/dist/martyrs/src/modules/core/views/components/blocks/CardHeader.vue.js +0 -1
- package/dist/martyrs/src/modules/core/views/components/blocks/CardHeader.vue.js.map +1 -1
- package/dist/martyrs/src/modules/core/views/components/blocks/PopupAuth.vue.js +1 -1
- package/dist/martyrs/src/modules/core/views/components/blocks/PopupDateSelector.vue.js +2 -2
- package/dist/martyrs/src/modules/core/views/components/elements/OnlineIndicator.vue.js +74 -0
- package/dist/martyrs/src/modules/core/views/components/elements/OnlineIndicator.vue.js.map +1 -0
- package/dist/martyrs/src/modules/core/views/components/layouts/App.vue.js.map +1 -1
- package/dist/martyrs/src/modules/core/views/components/layouts/Client.vue.js +64 -48
- package/dist/martyrs/src/modules/core/views/components/layouts/Client.vue.js.map +1 -1
- package/dist/martyrs/src/modules/core/views/components/pages/404.vue.js +10 -33
- package/dist/martyrs/src/modules/core/views/components/pages/404.vue.js.map +1 -1
- package/dist/martyrs/src/modules/core/views/components/partials/Header.vue.js +2 -2
- package/dist/martyrs/src/modules/core/views/components/partials/NavigationBar.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/elements/ButtonCheck.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/elements/ButtonJoin.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.js +2 -2
- package/dist/martyrs/src/modules/events/components/pages/EditEventTickets.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/Event.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/sections/EditTickets.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/sections/Feed.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/sections/List.vue.js +1 -1
- package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.js +2 -2
- package/dist/martyrs/src/modules/inventory/components/forms/AdjustmentForm.vue.js +2 -2
- package/dist/martyrs/src/modules/inventory/components/forms/ColumnSettingsMenu.vue.js +1 -1
- package/dist/martyrs/src/modules/inventory/components/forms/HistoryView.vue.js +1 -1
- package/dist/martyrs/src/modules/inventory/components/forms/StockAlertsForm.vue.js +2 -2
- package/dist/martyrs/src/modules/inventory/components/pages/InventoryEdit.vue.js +2 -2
- package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/blocks/ActionButtons.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/cards/AlbumCard.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/cards/ArtistCardSmall.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/cards/PlaylistCard.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/cards/TrackListCard.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/forms/AlbumForm.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/forms/ArtistForm.vue.js +3 -3
- package/dist/martyrs/src/modules/music/components/forms/PlaylistForm.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/forms/SearchForm.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/forms/TrackForm.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Album.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Artist.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/MusicLibrary.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/SearchResults.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Track.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/TrackCreate.vue.js +0 -1
- package/dist/martyrs/src/modules/music/components/pages/TrackCreate.vue.js.map +1 -1
- package/dist/martyrs/src/modules/music/components/player/FullscreenPlayer.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/player/MusicPlayer.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/player/PlayerControls.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/player/VolumeControl.vue.js +1 -1
- package/dist/martyrs/src/modules/notifications/components/sections/NotificationPreferences.vue.js +2 -2
- package/dist/martyrs/src/modules/orders/components/forms/FormApplicationDetails.vue.js +2 -2
- package/dist/martyrs/src/modules/orders/components/forms/FormCustomerDetails.vue.js +2 -2
- package/dist/martyrs/src/modules/orders/components/forms/FormSelectCustomer.vue.js +1 -2
- package/dist/martyrs/src/modules/orders/components/forms/FormSelectCustomer.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.js +2 -2
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/ApplicationDetails.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/CustomerDetails.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormPayment.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/elements/ButtonToggleMembership.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/forms/AddExistingMembersForm.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/forms/DepartmentForm.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/forms/InviteForm.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationEdit.vue.js +3 -3
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.js +1 -2
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.js.map +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/MembersAdd.vue.js +2 -2
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.js +1 -2
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.js.map +1 -1
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.js +0 -1
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.js.map +1 -1
- package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/pages/views/components/partials/SidebarPages.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/elements/Image360.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.js +0 -1
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.js.map +1 -1
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.js +3 -3
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.js +0 -1
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.js.map +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductEdit.vue.js +2 -2
- package/dist/martyrs/src/modules/products/components/pages/Products.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Products.vue.js.map +1 -1
- package/dist/martyrs/src/modules/products/components/sections/EditAttributes.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/sections/EditDiscounts.vue.js +2 -2
- package/dist/martyrs/src/modules/products/components/sections/EditVariants.vue.js +2 -2
- package/dist/martyrs/src/modules/products/components/sections/ProductConfigurator.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/sections/ProductsRecommended.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/sections/SectionProduct.vue.js +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/Gant/GanttToolbar.vue.js +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/RentsEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/reports/components/sections/FormReport.vue.js +2 -2
- package/dist/martyrs/src/modules/spots/components/blocks/SpotMemberModify.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/pages/Map.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/pages/SpotEdit.vue.js +2 -2
- package/dist/martyrs/src/modules/spots/components/sections/WorktimeEdit.vue.js +2 -2
- package/dist/martyrs.css +1 -1
- package/dist/martyrs.es.js +1 -1
- package/dist/music.server.js +1 -1
- package/dist/notifications.server.js +2 -2
- package/dist/orders.server.js +8 -7
- package/dist/organizations.server.js +3 -3
- package/dist/pages.server.js +1 -1
- package/dist/products.server.js +3 -3
- package/dist/profile.schema-C31Lynn3.js +21 -0
- package/dist/rents.server.js +2 -2
- package/dist/reports.server.js +1 -1
- package/dist/sessions.service-COcwjd0f.js +86 -0
- package/dist/spots.server.js +1 -1
- package/dist/style.css +180 -110
- package/dist/{tickets.controller-B7r0mK-5.js → tickets.controller-DdF85W-i.js} +1 -1
- package/dist/visitors.service-B1dhhuSo.js +83 -0
- package/dist/wallet.server.js +3 -3
- package/dist/{web-BA6h6Z8P.js → web-O7lXcjg0.js} +1 -1
- package/package.json +3 -1
- package/src/components/Button/Button.vue +61 -15
- package/src/components/Loader/Loader.vue +1 -1
- package/src/components/Tooltip/Tooltip.vue +31 -23
- package/src/modules/TASKS.MD +30 -1
- package/src/modules/auth/CLAUDE.md +381 -0
- package/src/modules/auth/FIXES.md +0 -38
- package/src/modules/auth/auth.client.js +4 -6
- package/src/modules/auth/auth.server.js +19 -16
- package/src/modules/auth/controllers/middlewares/authJwt.js +59 -17
- package/src/modules/auth/controllers/middlewares/index.js +4 -1
- package/src/modules/auth/controllers/middlewares/otp.middleware.js +166 -0
- package/src/modules/auth/controllers/middlewares/verifySignUp.js +0 -1
- package/src/modules/auth/controllers/middlewares/verifyUser.js +58 -11
- package/src/modules/auth/controllers/routes/auth.routes.js +48 -6
- package/src/modules/auth/controllers/routes/users.routes.js +29 -8
- package/src/modules/auth/controllers/services/auth.service.js +62 -12
- package/src/modules/auth/controllers/services/otp.service.js +109 -0
- package/src/modules/auth/controllers/services/users.service.js +46 -6
- package/src/modules/auth/models/otp.model.js +20 -0
- package/src/modules/auth/views/components/blocks/OtpDialog.vue +168 -0
- package/src/modules/auth/views/components/pages/Profile.vue +18 -13
- package/src/modules/auth/views/components/pages/ProfileEditAccount.vue +199 -45
- package/src/modules/auth/views/components/pages/ResetPassword.vue +170 -132
- package/src/modules/auth/views/components/pages/SignIn.vue +2 -1
- package/src/modules/auth/views/components/pages/SignUp.vue +203 -147
- package/src/modules/auth/views/plugins/otp.plugin.js +104 -0
- package/src/modules/auth/views/router/auth.router.js +1 -24
- package/src/modules/auth/views/router/users.router.js +1 -12
- package/src/modules/auth/views/store/auth.js +0 -68
- package/src/modules/auth/views/store/users.js +6 -2
- package/src/modules/chats/chats.server.js +1 -1
- package/src/modules/community/community.server.js +1 -1
- package/src/modules/core/controllers/classes/core.websocket.js +57 -6
- package/src/modules/core/controllers/middlewares/visitor.logger.js +49 -0
- package/src/modules/core/controllers/services/requests.service.js +53 -0
- package/src/modules/core/controllers/services/sessions.service.js +98 -0
- package/src/modules/core/controllers/services/visitors.service.js +102 -0
- package/src/modules/core/controllers/utils/mailing.js +16 -3
- package/src/modules/core/core.server.js +31 -16
- package/src/modules/core/models/log.model.js +24 -0
- package/src/modules/core/models/request.model.js +30 -0
- package/src/modules/core/models/session.model.js +43 -0
- package/src/modules/core/models/visitor.model.js +28 -0
- package/src/modules/core/views/components/elements/OnlineIndicator.vue +115 -0
- package/src/modules/core/views/components/layouts/App.vue +2 -2
- package/src/modules/core/views/components/layouts/Client.vue +443 -477
- package/src/modules/core/views/components/pages/404.vue +2 -3
- package/src/modules/events/events.server.js +1 -1
- package/src/modules/files/files.server.js +1 -1
- package/src/modules/gallery/gallery.server.js +1 -1
- package/src/modules/governance/governance.server.js +1 -1
- package/src/modules/icons/icons.server.js +1 -1
- package/src/modules/inventory/inventory.server.js +1 -1
- package/src/modules/marketplace/marketplace.server.js +1 -1
- package/src/modules/notifications/notifications.server.js +1 -1
- package/src/modules/orders/controllers/orders.controller.js +3 -3
- package/src/modules/orders/orders.server.js +1 -1
- package/src/modules/organizations/organizations.server.js +1 -1
- package/src/modules/pages/pages.server.js +1 -1
- package/src/modules/products/components/pages/Products.vue +1 -1
- package/src/modules/products/products.server.js +1 -1
- package/src/modules/rents/rents.server.js +1 -1
- package/src/modules/reports/reports.server.js +1 -1
- package/src/modules/spots/spots.server.js +1 -1
- package/src/modules/wallet/wallet.server.js +1 -1
- package/dist/_virtual/alignment-pattern.js +0 -5
- package/dist/_virtual/alignment-pattern.js.map +0 -1
- package/dist/_virtual/browser.js +0 -8
- package/dist/_virtual/browser.js.map +0 -1
- package/dist/_virtual/browser2.js +0 -5
- package/dist/_virtual/browser2.js.map +0 -1
- package/dist/_virtual/canvas.js +0 -5
- package/dist/_virtual/canvas.js.map +0 -1
- package/dist/_virtual/dijkstra.js +0 -5
- package/dist/_virtual/dijkstra.js.map +0 -1
- package/dist/_virtual/error-correction-code.js +0 -5
- package/dist/_virtual/error-correction-code.js.map +0 -1
- package/dist/_virtual/error-correction-level.js +0 -5
- package/dist/_virtual/error-correction-level.js.map +0 -1
- package/dist/_virtual/finder-pattern.js +0 -5
- package/dist/_virtual/finder-pattern.js.map +0 -1
- package/dist/_virtual/format-info.js +0 -5
- package/dist/_virtual/format-info.js.map +0 -1
- package/dist/_virtual/galois-field.js +0 -5
- package/dist/_virtual/galois-field.js.map +0 -1
- package/dist/_virtual/mask-pattern.js +0 -5
- package/dist/_virtual/mask-pattern.js.map +0 -1
- package/dist/_virtual/mode.js +0 -5
- package/dist/_virtual/mode.js.map +0 -1
- package/dist/_virtual/polynomial.js +0 -5
- package/dist/_virtual/polynomial.js.map +0 -1
- package/dist/_virtual/qrcode.js +0 -5
- package/dist/_virtual/qrcode.js.map +0 -1
- package/dist/_virtual/regex.js +0 -5
- package/dist/_virtual/regex.js.map +0 -1
- package/dist/_virtual/segments.js +0 -5
- package/dist/_virtual/segments.js.map +0 -1
- package/dist/_virtual/svg-tag.js +0 -5
- package/dist/_virtual/svg-tag.js.map +0 -1
- package/dist/_virtual/utils.js +0 -5
- package/dist/_virtual/utils.js.map +0 -1
- package/dist/_virtual/utils2.js +0 -5
- package/dist/_virtual/utils2.js.map +0 -1
- package/dist/_virtual/version-check.js +0 -5
- package/dist/_virtual/version-check.js.map +0 -1
- package/dist/_virtual/version.js +0 -5
- package/dist/_virtual/version.js.map +0 -1
- package/dist/index-_Edcmck_.js +0 -170
- package/dist/martyrs/dist/main-xL-jtBkT.js.map +0 -1
- package/dist/martyrs/node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.js +0 -1336
- package/dist/martyrs/node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.js.map +0 -1
- package/dist/martyrs/src/components/Button/Button.vue2.js.map +0 -1
- package/dist/martyrs/src/components/Loader/Loader.vue.js.map +0 -1
- package/dist/martyrs/src/components/Menu/Menu.vue.js.map +0 -1
- package/dist/martyrs/src/components/Select/Select.vue.js.map +0 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/EnterCode.vue.js +0 -166
- package/dist/martyrs/src/modules/auth/views/components/pages/EnterCode.vue.js.map +0 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/EnterPassword.vue.js +0 -118
- package/dist/martyrs/src/modules/auth/views/components/pages/EnterPassword.vue.js.map +0 -1
- package/dist/martyrs/src/modules/auth/views/components/sections/ProfileEditCredentials.vue.js +0 -360
- package/dist/martyrs/src/modules/auth/views/components/sections/ProfileEditCredentials.vue.js.map +0 -1
- package/dist/martyrs/src/modules/auth/views/store/twofa.js +0 -40
- package/dist/martyrs/src/modules/auth/views/store/twofa.js.map +0 -1
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CardBalanceReplenished.vue.js +0 -43
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CardBalanceReplenished.vue.js.map +0 -1
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CardDeposit.vue.js +0 -47
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CardDeposit.vue.js.map +0 -1
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CashDeposit.vue.js +0 -29
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CashDeposit.vue.js.map +0 -1
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.js +0 -89
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.js.map +0 -1
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDepositProcessing.vue.js +0 -136
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDepositProcessing.vue.js.map +0 -1
- package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.js +0 -238
- package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.js.map +0 -1
- package/dist/martyrs/src/modules/wallet/views/localization/wallet.json.js +0 -9
- package/dist/martyrs/src/modules/wallet/views/localization/wallet.json.js.map +0 -1
- package/dist/martyrs/src/modules/wallet/views/store/wallet.store.js +0 -134
- package/dist/martyrs/src/modules/wallet/views/store/wallet.store.js.map +0 -1
- package/dist/node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js +0 -106
- package/dist/node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js +0 -79
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js +0 -14
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js +0 -43
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js +0 -85
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js +0 -40
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js +0 -34
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js +0 -36
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js +0 -367
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js +0 -52
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js +0 -25
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js +0 -24
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js +0 -38
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js +0 -46
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js +0 -149
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js +0 -90
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js +0 -41
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js +0 -44
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js +0 -279
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js +0 -38
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js +0 -33
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js +0 -201
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js +0 -84
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js +0 -14
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js +0 -107
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js +0 -61
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js +0 -64
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js.map +0 -1
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js +0 -87
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js.map +0 -1
- package/dist/profile.schema-CjLOfG7b.js +0 -92
- package/src/modules/auth/controllers/middlewares/visitor.logger.js +0 -75
- package/src/modules/auth/controllers/routes/twofa.routes.js +0 -8
- package/src/modules/auth/controllers/services/twofa.service.js +0 -30
- package/src/modules/auth/models/request.model.js +0 -14
- package/src/modules/auth/models/visitor.model.js +0 -11
- package/src/modules/auth/views/components/pages/EnterCode.vue +0 -204
- package/src/modules/auth/views/components/pages/EnterPassword.vue +0 -123
- package/src/modules/auth/views/components/sections/ProfileEditCredentials.vue +0 -329
- package/src/modules/auth/views/store/twofa.js +0 -70
- package/src/modules/auth//320/220/320/240/320/245/320/230/320/242/320/225/320/232/320/242/320/243/320/240/320/220.md +0 -445
|
@@ -4,6 +4,7 @@ import authSecretModule from './authSecret.js';
|
|
|
4
4
|
import verifySignUpModule from './verifySignUp.js';
|
|
5
5
|
import verifyUserModule from './verifyUser.js';
|
|
6
6
|
import verifyInvitesModule from './verifyInvites.js';
|
|
7
|
+
import otpModule from './otp.middleware.js';
|
|
7
8
|
|
|
8
9
|
const middlewareIndexFactory = db => {
|
|
9
10
|
const authJwt = authJwtModule(db);
|
|
@@ -11,13 +12,15 @@ const middlewareIndexFactory = db => {
|
|
|
11
12
|
const verifySignUp = verifySignUpModule(db);
|
|
12
13
|
const verifyUser = verifyUserModule(db);
|
|
13
14
|
const verifyInvites = verifyInvitesModule(db);
|
|
14
|
-
|
|
15
|
+
const otp = otpModule();
|
|
16
|
+
|
|
15
17
|
return {
|
|
16
18
|
authJwt,
|
|
17
19
|
authSecret,
|
|
18
20
|
verifySignUp,
|
|
19
21
|
verifyUser,
|
|
20
22
|
verifyInvites,
|
|
23
|
+
otp,
|
|
21
24
|
};
|
|
22
25
|
};
|
|
23
26
|
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { getOtpService } from '../services/otp.service.js';
|
|
2
|
+
|
|
3
|
+
function maskIdentifier(identifier) {
|
|
4
|
+
if (identifier.includes('@')) {
|
|
5
|
+
const [name, domain] = identifier.split('@');
|
|
6
|
+
return `${name[0]}${'*'.repeat(Math.max(name.length - 2, 1))}${name.slice(-1)}@${domain}`;
|
|
7
|
+
}
|
|
8
|
+
return `${identifier.slice(0, 2)}${'*'.repeat(identifier.length - 4)}${identifier.slice(-2)}`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const middlewareFactory = () => {
|
|
12
|
+
const { sendOtp, verifyOtp } = getOtpService();
|
|
13
|
+
|
|
14
|
+
const stepUp = (purpose, getCredentials) => {
|
|
15
|
+
return async (req, res, next) => {
|
|
16
|
+
const { identifier, type, target = null } = getCredentials(req);
|
|
17
|
+
|
|
18
|
+
if (!identifier || !type) {
|
|
19
|
+
return res.status(400).json({ errorCode: 'IDENTIFIER_REQUIRED' });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { challengeId, otp } = req.body;
|
|
23
|
+
|
|
24
|
+
if (challengeId && otp) {
|
|
25
|
+
const result = await verifyOtp({ challengeId, code: otp, target });
|
|
26
|
+
|
|
27
|
+
if (result.errorCode) {
|
|
28
|
+
return res.status(result.status || 400).json({ errorCode: result.errorCode, attemptsLeft: result.attemptsLeft });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return next();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const result = await sendOtp({ identifier, type, purpose, target });
|
|
35
|
+
|
|
36
|
+
if (result.errorCode) {
|
|
37
|
+
return res.status(result.status || 500).json({ errorCode: result.errorCode, retryAfter: result.retryAfter });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return res.status(200).json({
|
|
41
|
+
status: 'requires_otp',
|
|
42
|
+
challenge: {
|
|
43
|
+
challengeId: result.challengeId,
|
|
44
|
+
identifier: maskIdentifier(identifier)
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const dualVerify = (field) => {
|
|
51
|
+
return async (req, res, next) => {
|
|
52
|
+
const target = req.userId;
|
|
53
|
+
const targetId = req.params._id;
|
|
54
|
+
|
|
55
|
+
if (target !== targetId) {
|
|
56
|
+
return res.status(403).json({ errorCode: 'FORBIDDEN' });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const oldContact = req.user[field];
|
|
60
|
+
const newContact = req.body[field];
|
|
61
|
+
|
|
62
|
+
if (!newContact) {
|
|
63
|
+
return res.status(400).json({ errorCode: 'MISSING_FIELD', field });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!oldContact) {
|
|
67
|
+
const { challengeId, otp } = req.body;
|
|
68
|
+
|
|
69
|
+
if (challengeId && otp) {
|
|
70
|
+
const result = await verifyOtp({ challengeId, code: otp, target });
|
|
71
|
+
|
|
72
|
+
if (result.errorCode) {
|
|
73
|
+
return res.status(result.status || 400).json({ errorCode: result.errorCode, attemptsLeft: result.attemptsLeft });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return next();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const result = await sendOtp({ identifier: newContact, type: field, purpose: `add-${field}`, target });
|
|
80
|
+
|
|
81
|
+
if (result.errorCode) {
|
|
82
|
+
return res.status(result.status || 500).json({ errorCode: result.errorCode, retryAfter: result.retryAfter });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return res.status(200).json({
|
|
86
|
+
status: 'requires_otp',
|
|
87
|
+
challenge: {
|
|
88
|
+
challengeId: result.challengeId,
|
|
89
|
+
identifier: maskIdentifier(newContact)
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const hasChallenges = req.body.challenges && Array.isArray(req.body.challenges) && req.body.challenges.length > 0;
|
|
95
|
+
if (!hasChallenges) {
|
|
96
|
+
const oldResult = await sendOtp({ identifier: oldContact, type: field, purpose: `change-${field}-old`, target });
|
|
97
|
+
|
|
98
|
+
if (oldResult.errorCode) {
|
|
99
|
+
return res.status(oldResult.status || 500).json({
|
|
100
|
+
errorCode: oldResult.errorCode,
|
|
101
|
+
retryAfter: oldResult.retryAfter,
|
|
102
|
+
field: 'old'
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const newResult = await sendOtp({ identifier: newContact, type: field, purpose: `change-${field}-new`, target });
|
|
107
|
+
|
|
108
|
+
if (newResult.errorCode) {
|
|
109
|
+
return res.status(newResult.status || 500).json({
|
|
110
|
+
errorCode: newResult.errorCode,
|
|
111
|
+
retryAfter: newResult.retryAfter,
|
|
112
|
+
field: 'new'
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return res.json({
|
|
117
|
+
status: 'requires_otp',
|
|
118
|
+
mode: 'dual',
|
|
119
|
+
challenges: [
|
|
120
|
+
{ challengeId: oldResult.challengeId, identifier: maskIdentifier(oldContact), label: 'old' },
|
|
121
|
+
{ challengeId: newResult.challengeId, identifier: maskIdentifier(newContact), label: 'new' }
|
|
122
|
+
]
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const { challenges } = req.body;
|
|
127
|
+
if (!Array.isArray(challenges) || challenges.length !== 2) {
|
|
128
|
+
return res.status(400).json({ errorCode: 'INVALID_CHALLENGES' });
|
|
129
|
+
}
|
|
130
|
+
for (const c of challenges) {
|
|
131
|
+
if (typeof c.challengeId !== 'string' || c.challengeId.length !== 64) {
|
|
132
|
+
return res.status(400).json({ errorCode: 'INVALID_CHALLENGE_ID' });
|
|
133
|
+
}
|
|
134
|
+
if (typeof c.code !== 'string' || c.code.length !== 4) {
|
|
135
|
+
return res.status(400).json({ errorCode: 'INVALID_CODE_FORMAT' });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const oldValid = await verifyOtp({ challengeId: challenges[0].challengeId, code: challenges[0].code, target });
|
|
140
|
+
|
|
141
|
+
if (oldValid.errorCode) {
|
|
142
|
+
return res.status(oldValid.status || 400).json({
|
|
143
|
+
errorCode: oldValid.errorCode,
|
|
144
|
+
field: 'old',
|
|
145
|
+
attemptsLeft: oldValid.attemptsLeft
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const newValid = await verifyOtp({ challengeId: challenges[1].challengeId, code: challenges[1].code, target });
|
|
150
|
+
|
|
151
|
+
if (newValid.errorCode) {
|
|
152
|
+
return res.status(newValid.status || 400).json({
|
|
153
|
+
errorCode: newValid.errorCode,
|
|
154
|
+
field: 'new',
|
|
155
|
+
attemptsLeft: newValid.attemptsLeft
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
next();
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return { stepUp, dualVerify };
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export default middlewareFactory;
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
const middlewareFactory = db => {
|
|
3
3
|
const User = db.user;
|
|
4
4
|
const Role = db.role;
|
|
5
|
+
|
|
6
|
+
const checkOwnership = (req, res, next) => {
|
|
7
|
+
if (!req.userId || req.userId !== req.params._id) {
|
|
8
|
+
return res.status(403).json({ errorCode: 'FORBIDDEN', message: 'Cannot modify other users' });
|
|
9
|
+
}
|
|
10
|
+
next();
|
|
11
|
+
};
|
|
12
|
+
|
|
5
13
|
const checkDuplicateUsername = async (req, res, next) => {
|
|
6
14
|
const { username } = req.body;
|
|
7
15
|
// Если username не передан, пропускаем проверку
|
|
@@ -25,22 +33,58 @@ const middlewareFactory = db => {
|
|
|
25
33
|
res.status(500).send({ message: err.message });
|
|
26
34
|
}
|
|
27
35
|
};
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
|
|
37
|
+
const checkDuplicateEmail = async (req, res, next) => {
|
|
38
|
+
const { email } = req.body;
|
|
39
|
+
if (!email) {
|
|
40
|
+
return next();
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const user = await User.findOne({
|
|
44
|
+
email,
|
|
45
|
+
_id: { $ne: req.params._id }
|
|
46
|
+
});
|
|
47
|
+
if (user) {
|
|
48
|
+
return res.status(400).json({ errorCode: 'EMAIL_ALREADY_USED' });
|
|
49
|
+
}
|
|
50
|
+
next();
|
|
51
|
+
} catch (err) {
|
|
52
|
+
res.status(500).send({ message: err.message });
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const checkDuplicatePhone = async (req, res, next) => {
|
|
57
|
+
const { phone } = req.body;
|
|
58
|
+
if (!phone) {
|
|
59
|
+
return next();
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const user = await User.findOne({
|
|
63
|
+
phone,
|
|
64
|
+
_id: { $ne: req.params._id }
|
|
65
|
+
});
|
|
66
|
+
if (user) {
|
|
67
|
+
return res.status(400).json({ errorCode: 'PHONE_ALREADY_USED' });
|
|
68
|
+
}
|
|
69
|
+
next();
|
|
70
|
+
} catch (err) {
|
|
71
|
+
res.status(500).send({ message: err.message });
|
|
34
72
|
}
|
|
35
|
-
|
|
36
|
-
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const checkUserExist = async (req, res, next) => {
|
|
76
|
+
const { type, identifier } = req.body;
|
|
77
|
+
|
|
78
|
+
if (!type || !identifier) {
|
|
79
|
+
return res.status(400).json({ errorCode: 'MISSING_IDENTIFIER' });
|
|
37
80
|
}
|
|
81
|
+
|
|
82
|
+
const query = type === 'phone' ? { phone: identifier } : { email: identifier };
|
|
83
|
+
|
|
38
84
|
try {
|
|
39
85
|
const user = await User.findOne(query).exec();
|
|
40
86
|
if (!user) {
|
|
41
|
-
|
|
42
|
-
res.status(400).send({ errorCode: 'USER_NOT_REGISTERED_YET' });
|
|
43
|
-
return;
|
|
87
|
+
return res.status(400).json({ errorCode: 'USER_NOT_REGISTERED_YET' });
|
|
44
88
|
}
|
|
45
89
|
next();
|
|
46
90
|
} catch (err) {
|
|
@@ -48,7 +92,10 @@ const middlewareFactory = db => {
|
|
|
48
92
|
}
|
|
49
93
|
};
|
|
50
94
|
return {
|
|
95
|
+
checkOwnership,
|
|
51
96
|
checkDuplicateUsername,
|
|
97
|
+
checkDuplicateEmail,
|
|
98
|
+
checkDuplicatePhone,
|
|
52
99
|
checkUserExist,
|
|
53
100
|
};
|
|
54
101
|
};
|
|
@@ -1,19 +1,61 @@
|
|
|
1
1
|
import middlewareFactory from '../middlewares/index.js';
|
|
2
2
|
import controllerFactory from '../services/auth.service.js';
|
|
3
|
-
import
|
|
3
|
+
import { getSessionsService } from '@martyrs/src/modules/core/controllers/services/sessions.service.js';
|
|
4
|
+
|
|
4
5
|
export default (function (app, db, origins) {
|
|
5
6
|
const controller = controllerFactory(db);
|
|
6
|
-
const
|
|
7
|
-
|
|
7
|
+
const { verifySignUp, verifyUser, otp, authJwt } = middlewareFactory(db);
|
|
8
|
+
|
|
8
9
|
app.post(
|
|
9
10
|
'/api/auth/signup',
|
|
10
11
|
[
|
|
11
12
|
verifySignUp.checkDuplicateUsernameOrEmail,
|
|
12
|
-
|
|
13
|
+
otp.stepUp('signup', req => ({
|
|
14
|
+
identifier: req.body.type === 'email' ? req.body.email : req.body.phone,
|
|
15
|
+
type: req.body.type
|
|
16
|
+
}))
|
|
13
17
|
],
|
|
14
18
|
controller.signup
|
|
15
19
|
);
|
|
20
|
+
|
|
16
21
|
app.post('/api/auth/signin', controller.signin);
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
|
|
23
|
+
// Сброс пароля — публичный flow
|
|
24
|
+
app.post(
|
|
25
|
+
'/api/auth/reset-password',
|
|
26
|
+
[
|
|
27
|
+
verifyUser.checkUserExist,
|
|
28
|
+
otp.stepUp('reset-password', req => ({
|
|
29
|
+
identifier: req.body.identifier,
|
|
30
|
+
type: req.body.type
|
|
31
|
+
}))
|
|
32
|
+
],
|
|
33
|
+
controller.updatePassword
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// Logout current session
|
|
37
|
+
app.post('/api/auth/logout', [authJwt.verifyToken()], async (req, res) => {
|
|
38
|
+
try {
|
|
39
|
+
if (req.sessionId) {
|
|
40
|
+
const sessionsService = getSessionsService();
|
|
41
|
+
await sessionsService.deactivateSession(req.sessionId);
|
|
42
|
+
}
|
|
43
|
+
res.status(200).send({ success: true });
|
|
44
|
+
} catch (err) {
|
|
45
|
+
res.status(500).send({ message: err.message });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Logout all sessions
|
|
50
|
+
app.post('/api/auth/logout-all', [authJwt.verifyToken()], async (req, res) => {
|
|
51
|
+
try {
|
|
52
|
+
if (req.userId) {
|
|
53
|
+
const sessionsService = getSessionsService();
|
|
54
|
+
await sessionsService.deactivateAllUserSessions(req.userId);
|
|
55
|
+
}
|
|
56
|
+
res.status(200).send({ success: true });
|
|
57
|
+
} catch (err) {
|
|
58
|
+
res.status(500).send({ message: err.message });
|
|
59
|
+
}
|
|
60
|
+
});
|
|
19
61
|
});
|
|
@@ -1,15 +1,36 @@
|
|
|
1
1
|
import middlewareFactory from '../middlewares/index.js';
|
|
2
2
|
import controllerFactory from '../services/users.service.js';
|
|
3
|
+
|
|
3
4
|
export default (function (app, db, origins) {
|
|
4
5
|
const controller = controllerFactory(db);
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// Create a User
|
|
6
|
+
const { authJwt, verifyUser, otp } = middlewareFactory(db);
|
|
7
|
+
|
|
8
8
|
app.post('/api/users', [authJwt.verifyToken(), verifyUser.checkDuplicateUsername], controller.create);
|
|
9
|
-
// Fetch Users
|
|
10
9
|
app.get('/api/users', controller.read);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
|
|
11
|
+
// Профиль (без email/phone)
|
|
12
|
+
app.put('/api/users/:_id', [
|
|
13
|
+
authJwt.verifyToken(),
|
|
14
|
+
verifyUser.checkOwnership,
|
|
15
|
+
verifyUser.checkDuplicateUsername
|
|
16
|
+
], controller.update);
|
|
17
|
+
|
|
18
|
+
// Email
|
|
19
|
+
app.put('/api/users/:_id/email', [
|
|
20
|
+
authJwt.verifyToken(),
|
|
21
|
+
authJwt.loadUser,
|
|
22
|
+
verifyUser.checkOwnership,
|
|
23
|
+
verifyUser.checkDuplicateEmail,
|
|
24
|
+
otp.dualVerify('email')
|
|
25
|
+
], controller.updateEmail);
|
|
26
|
+
|
|
27
|
+
// Phone
|
|
28
|
+
app.put('/api/users/:_id/phone', [
|
|
29
|
+
authJwt.verifyToken(),
|
|
30
|
+
authJwt.loadUser,
|
|
31
|
+
verifyUser.checkOwnership,
|
|
32
|
+
verifyUser.checkDuplicatePhone,
|
|
33
|
+
otp.dualVerify('phone')
|
|
34
|
+
], controller.updatePhone);
|
|
35
|
+
|
|
15
36
|
});
|
|
@@ -2,6 +2,9 @@ import bcrypt from 'bcryptjs';
|
|
|
2
2
|
import jwt from 'jsonwebtoken';
|
|
3
3
|
import { Types } from 'mongoose';
|
|
4
4
|
import { verifyAppleIdToken } from '../utils/verifyAppleIdToken.js';
|
|
5
|
+
import { getSessionsService } from '@martyrs/src/modules/core/controllers/services/sessions.service.js';
|
|
6
|
+
import { getVisitorsService } from '@martyrs/src/modules/core/controllers/services/visitors.service.js';
|
|
7
|
+
|
|
5
8
|
const ObjectId = { Types }.Types.ObjectId;
|
|
6
9
|
// Factory
|
|
7
10
|
const controllerFactory = db => {
|
|
@@ -11,6 +14,7 @@ const controllerFactory = db => {
|
|
|
11
14
|
const Organization = db.organization;
|
|
12
15
|
const Invite = db.invite;
|
|
13
16
|
const Role = db.role;
|
|
17
|
+
|
|
14
18
|
const signin = async (req, res) => {
|
|
15
19
|
const { type, email, phone, authorization } = req.body;
|
|
16
20
|
let query;
|
|
@@ -52,9 +56,29 @@ const controllerFactory = db => {
|
|
|
52
56
|
return res.status(401).send({ errorCode: 'INCORRECT_PASSWORD_ENTERED', accessToken: null });
|
|
53
57
|
}
|
|
54
58
|
}
|
|
59
|
+
|
|
60
|
+
// Create session
|
|
61
|
+
const sessionsService = getSessionsService();
|
|
62
|
+
const session = await sessionsService.createSession({
|
|
63
|
+
userId: user._id,
|
|
64
|
+
visitorId: req.visitorId || null,
|
|
65
|
+
req,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Link visitor to user
|
|
69
|
+
if (req.visitorId) {
|
|
70
|
+
const visitorsService = getVisitorsService();
|
|
71
|
+
await visitorsService.linkVisitorToUser({
|
|
72
|
+
visitorId: req.visitorId,
|
|
73
|
+
userId: user._id,
|
|
74
|
+
sessionId: session._id,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
55
78
|
const token = jwt.sign(
|
|
56
79
|
{
|
|
57
80
|
_id: user._id,
|
|
81
|
+
session_id: session._id,
|
|
58
82
|
},
|
|
59
83
|
process.env.SECRET_KEY,
|
|
60
84
|
{
|
|
@@ -128,9 +152,29 @@ const controllerFactory = db => {
|
|
|
128
152
|
console.log(err);
|
|
129
153
|
}
|
|
130
154
|
}
|
|
155
|
+
|
|
156
|
+
// Create session
|
|
157
|
+
const sessionsService = getSessionsService();
|
|
158
|
+
const session = await sessionsService.createSession({
|
|
159
|
+
userId: user._id,
|
|
160
|
+
visitorId: req.visitorId || null,
|
|
161
|
+
req,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Link visitor to user
|
|
165
|
+
if (req.visitorId) {
|
|
166
|
+
const visitorsService = getVisitorsService();
|
|
167
|
+
await visitorsService.linkVisitorToUser({
|
|
168
|
+
visitorId: req.visitorId,
|
|
169
|
+
userId: user._id,
|
|
170
|
+
sessionId: session._id,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
131
174
|
const token = jwt.sign(
|
|
132
175
|
{
|
|
133
176
|
_id: user._id,
|
|
177
|
+
session_id: session._id,
|
|
134
178
|
organization: invite ? invite.organization : null,
|
|
135
179
|
},
|
|
136
180
|
process.env.SECRET_KEY,
|
|
@@ -150,19 +194,13 @@ const controllerFactory = db => {
|
|
|
150
194
|
};
|
|
151
195
|
const updatePassword = async (req, res) => {
|
|
152
196
|
try {
|
|
153
|
-
const {
|
|
154
|
-
|
|
155
|
-
if (type === 'phone' && phone) {
|
|
156
|
-
query = { phone };
|
|
157
|
-
}
|
|
158
|
-
if (type === 'email' && email) {
|
|
159
|
-
query = { email };
|
|
160
|
-
}
|
|
161
|
-
if (!query || !password) {
|
|
197
|
+
const { identifier, password, type } = req.body;
|
|
198
|
+
if (!identifier || !type || !password) {
|
|
162
199
|
return res.status(400).send({ errorCode: 'MISSING_REQUIRED_PARAMETERS' });
|
|
163
200
|
}
|
|
164
|
-
const
|
|
165
|
-
const
|
|
201
|
+
const query = type === 'phone' ? { phone: identifier } : { email: identifier };
|
|
202
|
+
const salt = await bcrypt.genSalt(8);
|
|
203
|
+
const hashedPassword = await bcrypt.hash(password, salt);
|
|
166
204
|
const user = await User.findOneAndUpdate(query, {
|
|
167
205
|
password: hashedPassword,
|
|
168
206
|
})
|
|
@@ -171,7 +209,19 @@ const controllerFactory = db => {
|
|
|
171
209
|
if (!user) {
|
|
172
210
|
return res.status(404).send({ errorCode: 'ERROR_UPDATING_USER' });
|
|
173
211
|
}
|
|
174
|
-
|
|
212
|
+
|
|
213
|
+
// Deactivate all existing sessions (logout-all on password reset)
|
|
214
|
+
const sessionsService = getSessionsService();
|
|
215
|
+
await sessionsService.deactivateAllUserSessions(user._id);
|
|
216
|
+
|
|
217
|
+
// Create new session
|
|
218
|
+
const session = await sessionsService.createSession({
|
|
219
|
+
userId: user._id,
|
|
220
|
+
visitorId: req.visitorId || null,
|
|
221
|
+
req,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
const token = jwt.sign({ _id: user._id, session_id: session._id }, process.env.SECRET_KEY, {
|
|
175
225
|
expiresIn: 86400,
|
|
176
226
|
});
|
|
177
227
|
const authorities = user.roles.map(role => `ROLE_${role.name.toUpperCase()}`);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
import mailing from '@martyrs/src/modules/core/controllers/utils/mailing.js';
|
|
3
|
+
const { sendEmail, sendSms } = mailing;
|
|
4
|
+
|
|
5
|
+
const RATE_LIMIT_SECONDS = 30;
|
|
6
|
+
const MAX_ATTEMPTS = 3;
|
|
7
|
+
|
|
8
|
+
const generateChallengeId = () => crypto.randomBytes(32).toString('hex');
|
|
9
|
+
|
|
10
|
+
let instance = null;
|
|
11
|
+
|
|
12
|
+
export function initOtpService(db) {
|
|
13
|
+
const Otp = db.otp;
|
|
14
|
+
|
|
15
|
+
async function sendOtp({ identifier, type, purpose, target = null }) {
|
|
16
|
+
const existingOtp = await Otp.findOne({ identifier, purpose }).sort({ createdAt: -1 });
|
|
17
|
+
|
|
18
|
+
if (existingOtp) {
|
|
19
|
+
const secondsSinceCreated = (Date.now() - existingOtp.createdAt.getTime()) / 1000;
|
|
20
|
+
if (secondsSinceCreated < RATE_LIMIT_SECONDS) {
|
|
21
|
+
return {
|
|
22
|
+
errorCode: 'RATE_LIMITED',
|
|
23
|
+
status: 429,
|
|
24
|
+
retryAfter: Math.ceil(RATE_LIMIT_SECONDS - secondsSinceCreated)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (target) {
|
|
30
|
+
await Otp.updateMany(
|
|
31
|
+
{ target: new db.mongoose.Types.ObjectId(target), purpose, invalidatedAt: null, verifiedAt: null },
|
|
32
|
+
{ invalidatedAt: new Date() }
|
|
33
|
+
);
|
|
34
|
+
} else if (identifier) {
|
|
35
|
+
await Otp.updateMany(
|
|
36
|
+
{ identifier, purpose, invalidatedAt: null, verifiedAt: null },
|
|
37
|
+
{ invalidatedAt: new Date() }
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const code = String(crypto.randomInt(1000, 10000));
|
|
42
|
+
const challengeId = generateChallengeId();
|
|
43
|
+
|
|
44
|
+
let sent = false;
|
|
45
|
+
if (type === 'email') {
|
|
46
|
+
sent = await sendEmail(
|
|
47
|
+
identifier,
|
|
48
|
+
`${process.env.APP_NAME} Verification Code`,
|
|
49
|
+
`Your ${process.env.APP_NAME} verification code is ${code}`
|
|
50
|
+
);
|
|
51
|
+
} else if (type === 'phone') {
|
|
52
|
+
sent = await sendSms(identifier, `Your ${process.env.APP_NAME} verification code: ${code}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!sent) {
|
|
56
|
+
return { errorCode: 'SEND_FAILED', status: 500 };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
await Otp.create({ identifier, code, type, purpose, target: target ? new db.mongoose.Types.ObjectId(target) : null, challengeId });
|
|
60
|
+
|
|
61
|
+
return { success: true, challengeId };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function verifyOtp({ challengeId, code, target = null }) {
|
|
65
|
+
const otp = await Otp.findOneAndUpdate(
|
|
66
|
+
{
|
|
67
|
+
challengeId,
|
|
68
|
+
verifiedAt: null,
|
|
69
|
+
invalidatedAt: null,
|
|
70
|
+
createdAt: { $gt: new Date(Date.now() - 10 * 60 * 1000) },
|
|
71
|
+
attempts: { $lt: MAX_ATTEMPTS },
|
|
72
|
+
...(target && { target: new db.mongoose.Types.ObjectId(target) })
|
|
73
|
+
},
|
|
74
|
+
{ $inc: { attempts: 1 } },
|
|
75
|
+
{ new: true }
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
if (!otp) {
|
|
79
|
+
return { errorCode: 'CODE_NOT_FOUND' };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (otp.code !== code) {
|
|
83
|
+
return { errorCode: 'INVALID_CODE', attemptsLeft: MAX_ATTEMPTS - otp.attempts };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const consumed = await Otp.findOneAndUpdate(
|
|
87
|
+
{ _id: otp._id, verifiedAt: null, attempts: { $lte: MAX_ATTEMPTS } },
|
|
88
|
+
{ verifiedAt: new Date() }
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
if (!consumed) {
|
|
92
|
+
return { errorCode: 'ALREADY_USED' };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return { valid: true };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
instance = { sendOtp, verifyOtp };
|
|
99
|
+
return instance;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function getOtpService() {
|
|
103
|
+
if (!instance) {
|
|
104
|
+
throw new Error('OTP service not initialized. Call initOtpService(db) first.');
|
|
105
|
+
}
|
|
106
|
+
return instance;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default { initOtpService, getOtpService };
|