@unchainedshop/api 2.0.0-beta7 → 2.0.0-beta9
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/jest.config.js +9 -0
- package/lib/acl.d.ts +2 -0
- package/lib/acl.js +2 -2
- package/lib/acl.js.map +1 -1
- package/lib/api-index.d.ts +4 -6
- package/lib/api-index.js +5 -13
- package/lib/api-index.js.map +1 -1
- package/lib/context.d.ts +0 -1
- package/lib/context.js +0 -12
- package/lib/context.js.map +1 -1
- package/lib/createGraphQLServer.d.ts +1 -1
- package/lib/createGraphQLServer.js +13 -50
- package/lib/createGraphQLServer.js.map +1 -1
- package/lib/errors.d.ts +20 -0
- package/lib/errors.js +20 -0
- package/lib/errors.js.map +1 -1
- package/lib/express/createApolloMiddleware.d.ts +4 -0
- package/lib/express/createApolloMiddleware.js +34 -0
- package/lib/express/createApolloMiddleware.js.map +1 -0
- package/lib/express/createBulkImportMiddleware.d.ts +2 -0
- package/lib/express/createBulkImportMiddleware.js +79 -0
- package/lib/express/createBulkImportMiddleware.js.map +1 -0
- package/lib/express/createERCMetadataMiddleware.d.ts +3 -0
- package/lib/express/createERCMetadataMiddleware.js +57 -0
- package/lib/express/createERCMetadataMiddleware.js.map +1 -0
- package/lib/express/createSingleSignOnMiddleware.d.ts +6 -0
- package/lib/express/createSingleSignOnMiddleware.js +71 -0
- package/lib/express/createSingleSignOnMiddleware.js.map +1 -0
- package/lib/express/index.d.ts +6 -0
- package/lib/express/index.js +27 -0
- package/lib/express/index.js.map +1 -0
- package/lib/loaders/index.js +5 -9
- package/lib/loaders/index.js.map +1 -1
- package/lib/resolvers/mutations/accounts/changePassword.d.ts +0 -2
- package/lib/resolvers/mutations/accounts/changePassword.js +14 -3
- package/lib/resolvers/mutations/accounts/changePassword.js.map +1 -1
- package/lib/resolvers/mutations/accounts/createUser.js +19 -5
- package/lib/resolvers/mutations/accounts/createUser.js.map +1 -1
- package/lib/resolvers/mutations/accounts/disableTOTP.js +15 -2
- package/lib/resolvers/mutations/accounts/disableTOTP.js.map +1 -1
- package/lib/resolvers/mutations/accounts/enableTOTP.js +12 -1
- package/lib/resolvers/mutations/accounts/enableTOTP.js.map +1 -1
- package/lib/resolvers/mutations/accounts/enrollUser.js +18 -5
- package/lib/resolvers/mutations/accounts/enrollUser.js.map +1 -1
- package/lib/resolvers/mutations/accounts/forgotPassword.js +11 -1
- package/lib/resolvers/mutations/accounts/forgotPassword.js.map +1 -1
- package/lib/resolvers/mutations/accounts/impersonate.js +1 -1
- package/lib/resolvers/mutations/accounts/impersonate.js.map +1 -1
- package/lib/resolvers/mutations/accounts/loginWithPassword.d.ts +0 -1
- package/lib/resolvers/mutations/accounts/loginWithPassword.js +22 -4
- package/lib/resolvers/mutations/accounts/loginWithPassword.js.map +1 -1
- package/lib/resolvers/mutations/accounts/loginWithWebAuthn.js +13 -1
- package/lib/resolvers/mutations/accounts/loginWithWebAuthn.js.map +1 -1
- package/lib/resolvers/mutations/accounts/logout.d.ts +1 -1
- package/lib/resolvers/mutations/accounts/logout.js +6 -2
- package/lib/resolvers/mutations/accounts/logout.js.map +1 -1
- package/lib/resolvers/mutations/accounts/logoutAllSessions.js +4 -1
- package/lib/resolvers/mutations/accounts/logoutAllSessions.js.map +1 -1
- package/lib/resolvers/mutations/accounts/resetPassword.d.ts +0 -1
- package/lib/resolvers/mutations/accounts/resetPassword.js +18 -3
- package/lib/resolvers/mutations/accounts/resetPassword.js.map +1 -1
- package/lib/resolvers/mutations/accounts/setPassword.d.ts +0 -1
- package/lib/resolvers/mutations/accounts/setPassword.js +1 -1
- package/lib/resolvers/mutations/accounts/setPassword.js.map +1 -1
- package/lib/resolvers/mutations/assortments/addAssortmentFilter.js +1 -2
- package/lib/resolvers/mutations/assortments/addAssortmentFilter.js.map +1 -1
- package/lib/resolvers/mutations/assortments/addAssortmentLink.js +16 -9
- package/lib/resolvers/mutations/assortments/addAssortmentLink.js.map +1 -1
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.js +2 -3
- package/lib/resolvers/mutations/assortments/addAssortmentMedia.js.map +1 -1
- package/lib/resolvers/mutations/assortments/addAssortmentProduct.js +1 -2
- package/lib/resolvers/mutations/assortments/addAssortmentProduct.js.map +1 -1
- package/lib/resolvers/mutations/assortments/createAssortment.js +1 -2
- package/lib/resolvers/mutations/assortments/createAssortment.js.map +1 -1
- package/lib/resolvers/mutations/assortments/prepareAssortmentMediaUpload.js +0 -1
- package/lib/resolvers/mutations/assortments/prepareAssortmentMediaUpload.js.map +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortment.js +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortment.js.map +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentFilter.js +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentFilter.js.map +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentLink.js +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentLink.js.map +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentMedia.js +2 -2
- package/lib/resolvers/mutations/assortments/removeAssortmentMedia.js.map +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentProduct.js +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentProduct.js.map +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentFilters.js +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentFilters.js.map +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentLinks.js +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentLinks.js.map +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentMedia.js +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentMedia.js.map +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentProducts.js +1 -1
- package/lib/resolvers/mutations/assortments/reorderAssortmentProducts.js.map +1 -1
- package/lib/resolvers/mutations/assortments/setBaseAssortment.js +1 -1
- package/lib/resolvers/mutations/assortments/setBaseAssortment.js.map +1 -1
- package/lib/resolvers/mutations/assortments/updateAssortment.js +1 -1
- package/lib/resolvers/mutations/assortments/updateAssortment.js.map +1 -1
- package/lib/resolvers/mutations/assortments/updateAssortmentMediaTexts.js +1 -1
- package/lib/resolvers/mutations/assortments/updateAssortmentMediaTexts.js.map +1 -1
- package/lib/resolvers/mutations/assortments/updateAssortmentTexts.js +1 -1
- package/lib/resolvers/mutations/assortments/updateAssortmentTexts.js.map +1 -1
- package/lib/resolvers/mutations/bookmarks/bookmark.js +2 -2
- package/lib/resolvers/mutations/bookmarks/bookmark.js.map +1 -1
- package/lib/resolvers/mutations/bookmarks/createBookmark.js +1 -1
- package/lib/resolvers/mutations/bookmarks/createBookmark.js.map +1 -1
- package/lib/resolvers/mutations/countries/createCountry.js +1 -2
- package/lib/resolvers/mutations/countries/createCountry.js.map +1 -1
- package/lib/resolvers/mutations/countries/removeCountry.js +1 -1
- package/lib/resolvers/mutations/countries/removeCountry.js.map +1 -1
- package/lib/resolvers/mutations/countries/updateCountry.js +1 -1
- package/lib/resolvers/mutations/countries/updateCountry.js.map +1 -1
- package/lib/resolvers/mutations/currencies/createCurrency.js +1 -2
- package/lib/resolvers/mutations/currencies/createCurrency.js.map +1 -1
- package/lib/resolvers/mutations/currencies/removeCurrency.js +1 -1
- package/lib/resolvers/mutations/currencies/removeCurrency.js.map +1 -1
- package/lib/resolvers/mutations/currencies/updateCurrency.js +1 -1
- package/lib/resolvers/mutations/currencies/updateCurrency.js.map +1 -1
- package/lib/resolvers/mutations/delivery/createDeliveryProvider.js +1 -2
- package/lib/resolvers/mutations/delivery/createDeliveryProvider.js.map +1 -1
- package/lib/resolvers/mutations/delivery/removeDeliveryProvider.js +1 -1
- package/lib/resolvers/mutations/delivery/removeDeliveryProvider.js.map +1 -1
- package/lib/resolvers/mutations/delivery/updateDeliveryProvider.js +1 -1
- package/lib/resolvers/mutations/delivery/updateDeliveryProvider.js.map +1 -1
- package/lib/resolvers/mutations/enrollments/activateEnrollment.js +1 -1
- package/lib/resolvers/mutations/enrollments/activateEnrollment.js.map +1 -1
- package/lib/resolvers/mutations/enrollments/terminateEnrollment.js +1 -1
- package/lib/resolvers/mutations/enrollments/terminateEnrollment.js.map +1 -1
- package/lib/resolvers/mutations/enrollments/updateEnrollment.d.ts +1 -1
- package/lib/resolvers/mutations/enrollments/updateEnrollment.js +5 -5
- package/lib/resolvers/mutations/enrollments/updateEnrollment.js.map +1 -1
- package/lib/resolvers/mutations/filters/createFilter.js +1 -2
- package/lib/resolvers/mutations/filters/createFilter.js.map +1 -1
- package/lib/resolvers/mutations/filters/createFilterOption.js +1 -1
- package/lib/resolvers/mutations/filters/createFilterOption.js.map +1 -1
- package/lib/resolvers/mutations/filters/removeFilter.d.ts +1 -1
- package/lib/resolvers/mutations/filters/removeFilter.js +4 -4
- package/lib/resolvers/mutations/filters/removeFilter.js.map +1 -1
- package/lib/resolvers/mutations/filters/updateFilter.js +1 -1
- package/lib/resolvers/mutations/filters/updateFilter.js.map +1 -1
- package/lib/resolvers/mutations/filters/updateFilterTexts.js +1 -1
- package/lib/resolvers/mutations/filters/updateFilterTexts.js.map +1 -1
- package/lib/resolvers/mutations/index.d.ts +2 -1
- package/lib/resolvers/mutations/index.js +2 -0
- package/lib/resolvers/mutations/index.js.map +1 -1
- package/lib/resolvers/mutations/languages/createLanguage.js +1 -2
- package/lib/resolvers/mutations/languages/createLanguage.js.map +1 -1
- package/lib/resolvers/mutations/languages/removeLanguage.js +1 -1
- package/lib/resolvers/mutations/languages/removeLanguage.js.map +1 -1
- package/lib/resolvers/mutations/languages/updateLanguage.js +1 -1
- package/lib/resolvers/mutations/languages/updateLanguage.js.map +1 -1
- package/lib/resolvers/mutations/orders/createCart.js +1 -1
- package/lib/resolvers/mutations/orders/createCart.js.map +1 -1
- package/lib/resolvers/mutations/orders/payOrder.js +1 -1
- package/lib/resolvers/mutations/orders/payOrder.js.map +1 -1
- package/lib/resolvers/mutations/orders/removeOrder.js +1 -1
- package/lib/resolvers/mutations/orders/removeOrder.js.map +1 -1
- package/lib/resolvers/mutations/pageView.d.ts +1 -1
- package/lib/resolvers/mutations/pageView.js +2 -2
- package/lib/resolvers/mutations/pageView.js.map +1 -1
- package/lib/resolvers/mutations/payment/createPaymentProvider.js +1 -2
- package/lib/resolvers/mutations/payment/createPaymentProvider.js.map +1 -1
- package/lib/resolvers/mutations/payment/registerPaymentCredentials.js +2 -2
- package/lib/resolvers/mutations/payment/registerPaymentCredentials.js.map +1 -1
- package/lib/resolvers/mutations/payment/removePaymentProvider.js +1 -1
- package/lib/resolvers/mutations/payment/removePaymentProvider.js.map +1 -1
- package/lib/resolvers/mutations/payment/updatePaymentProvider.js +1 -1
- package/lib/resolvers/mutations/payment/updatePaymentProvider.js.map +1 -1
- package/lib/resolvers/mutations/products/addProductAssignment.js +1 -1
- package/lib/resolvers/mutations/products/addProductAssignment.js.map +1 -1
- package/lib/resolvers/mutations/products/addProductMedia.js +1 -2
- package/lib/resolvers/mutations/products/addProductMedia.js.map +1 -1
- package/lib/resolvers/mutations/products/addProductReviewVote.js +1 -1
- package/lib/resolvers/mutations/products/addProductReviewVote.js.map +1 -1
- package/lib/resolvers/mutations/products/createProduct.js +1 -2
- package/lib/resolvers/mutations/products/createProduct.js.map +1 -1
- package/lib/resolvers/mutations/products/createProductBundleItem.js +1 -1
- package/lib/resolvers/mutations/products/createProductBundleItem.js.map +1 -1
- package/lib/resolvers/mutations/products/createProductReview.js +1 -1
- package/lib/resolvers/mutations/products/createProductReview.js.map +1 -1
- package/lib/resolvers/mutations/products/createProductVariation.js +1 -2
- package/lib/resolvers/mutations/products/createProductVariation.js.map +1 -1
- package/lib/resolvers/mutations/products/createProductVariationOption.js +4 -1
- package/lib/resolvers/mutations/products/createProductVariationOption.js.map +1 -1
- package/lib/resolvers/mutations/products/prepareProductMediaUpload.js +0 -1
- package/lib/resolvers/mutations/products/prepareProductMediaUpload.js.map +1 -1
- package/lib/resolvers/mutations/products/publishProduct.js +1 -1
- package/lib/resolvers/mutations/products/publishProduct.js.map +1 -1
- package/lib/resolvers/mutations/products/removeBundleItem.js +2 -2
- package/lib/resolvers/mutations/products/removeBundleItem.js.map +1 -1
- package/lib/resolvers/mutations/products/removeProduct.d.ts +1 -1
- package/lib/resolvers/mutations/products/removeProduct.js +17 -8
- package/lib/resolvers/mutations/products/removeProduct.js.map +1 -1
- package/lib/resolvers/mutations/products/removeProductAssignment.js +1 -1
- package/lib/resolvers/mutations/products/removeProductAssignment.js.map +1 -1
- package/lib/resolvers/mutations/products/removeProductMedia.js +2 -2
- package/lib/resolvers/mutations/products/removeProductMedia.js.map +1 -1
- package/lib/resolvers/mutations/products/removeProductReview.js +1 -1
- package/lib/resolvers/mutations/products/removeProductReview.js.map +1 -1
- package/lib/resolvers/mutations/products/removeProductReviewVote.js +1 -1
- package/lib/resolvers/mutations/products/removeProductReviewVote.js.map +1 -1
- package/lib/resolvers/mutations/products/removeProductVariation.js +1 -1
- package/lib/resolvers/mutations/products/removeProductVariation.js.map +1 -1
- package/lib/resolvers/mutations/products/removeProductVariationOption.js +1 -1
- package/lib/resolvers/mutations/products/removeProductVariationOption.js.map +1 -1
- package/lib/resolvers/mutations/products/reorderProductMedia.js +1 -1
- package/lib/resolvers/mutations/products/reorderProductMedia.js.map +1 -1
- package/lib/resolvers/mutations/products/unpublishProduct.js +1 -1
- package/lib/resolvers/mutations/products/unpublishProduct.js.map +1 -1
- package/lib/resolvers/mutations/products/updateProduct.js +1 -1
- package/lib/resolvers/mutations/products/updateProduct.js.map +1 -1
- package/lib/resolvers/mutations/products/updateProductCommerce.js +1 -1
- package/lib/resolvers/mutations/products/updateProductCommerce.js.map +1 -1
- package/lib/resolvers/mutations/products/updateProductMediaTexts.js +1 -1
- package/lib/resolvers/mutations/products/updateProductMediaTexts.js.map +1 -1
- package/lib/resolvers/mutations/products/updateProductPlan.js +1 -1
- package/lib/resolvers/mutations/products/updateProductPlan.js.map +1 -1
- package/lib/resolvers/mutations/products/updateProductReview.js +1 -1
- package/lib/resolvers/mutations/products/updateProductReview.js.map +1 -1
- package/lib/resolvers/mutations/products/updateProductSupply.js +1 -1
- package/lib/resolvers/mutations/products/updateProductSupply.js.map +1 -1
- package/lib/resolvers/mutations/products/updateProductTexts.js +1 -1
- package/lib/resolvers/mutations/products/updateProductTexts.js.map +1 -1
- package/lib/resolvers/mutations/products/updateProductTokenization.js +1 -1
- package/lib/resolvers/mutations/products/updateProductTokenization.js.map +1 -1
- package/lib/resolvers/mutations/products/updateProductVariationTexts.js +1 -1
- package/lib/resolvers/mutations/products/updateProductVariationTexts.js.map +1 -1
- package/lib/resolvers/mutations/products/updateProductWarehousing.js +1 -1
- package/lib/resolvers/mutations/products/updateProductWarehousing.js.map +1 -1
- package/lib/resolvers/mutations/users/prepareUserAvatarUpload.js +0 -1
- package/lib/resolvers/mutations/users/prepareUserAvatarUpload.js.map +1 -1
- package/lib/resolvers/mutations/users/removeUser.d.ts +4 -0
- package/lib/resolvers/mutations/users/removeUser.js +11 -0
- package/lib/resolvers/mutations/users/removeUser.js.map +1 -0
- package/lib/resolvers/mutations/users/setRoles.js +1 -1
- package/lib/resolvers/mutations/users/setRoles.js.map +1 -1
- package/lib/resolvers/mutations/users/setUserTags.js +1 -1
- package/lib/resolvers/mutations/users/setUserTags.js.map +1 -1
- package/lib/resolvers/mutations/users/updateUserAvatar.js +1 -2
- package/lib/resolvers/mutations/users/updateUserAvatar.js.map +1 -1
- package/lib/resolvers/mutations/users/updateUserProfile.js +1 -1
- package/lib/resolvers/mutations/users/updateUserProfile.js.map +1 -1
- package/lib/resolvers/mutations/utils/getOrderCart.js +1 -1
- package/lib/resolvers/mutations/utils/getOrderCart.js.map +1 -1
- package/lib/resolvers/mutations/warehousing/createWarehousingProvider.js +1 -2
- package/lib/resolvers/mutations/warehousing/createWarehousingProvider.js.map +1 -1
- package/lib/resolvers/mutations/warehousing/removeWarehousingProvider.js +1 -1
- package/lib/resolvers/mutations/warehousing/removeWarehousingProvider.js.map +1 -1
- package/lib/resolvers/mutations/warehousing/updateWarehousingProvider.js +1 -1
- package/lib/resolvers/mutations/warehousing/updateWarehousingProvider.js.map +1 -1
- package/lib/resolvers/mutations/worker/addWork.js +1 -1
- package/lib/resolvers/mutations/worker/addWork.js.map +1 -1
- package/lib/resolvers/mutations/worker/finishWork.js +1 -1
- package/lib/resolvers/mutations/worker/finishWork.js.map +1 -1
- package/lib/resolvers/mutations/worker/removeWork.js +1 -1
- package/lib/resolvers/mutations/worker/removeWork.js.map +1 -1
- package/lib/resolvers/queries/products/productCatalogPrices.js +0 -1
- package/lib/resolvers/queries/products/productCatalogPrices.js.map +1 -1
- package/lib/resolvers/queries/users/users.d.ts +2 -1
- package/lib/resolvers/queries/users/users.js.map +1 -1
- package/lib/resolvers/queries/worker/workQueue.d.ts +1 -1
- package/lib/resolvers/queries/worker/workQueue.js +1 -1
- package/lib/resolvers/queries/worker/workQueue.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-filter-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-filter-types.js +0 -1
- package/lib/resolvers/type/assortment/assortment-filter-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-link-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-link-types.js +0 -2
- package/lib/resolvers/type/assortment/assortment-link-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-media-types.d.ts +1 -1
- package/lib/resolvers/type/assortment/assortment-media-types.js +2 -0
- package/lib/resolvers/type/assortment/assortment-media-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-path-link-types.d.ts +1 -4
- package/lib/resolvers/type/assortment/assortment-path-link-types.js +1 -7
- package/lib/resolvers/type/assortment/assortment-path-link-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-product-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-product-types.js +0 -2
- package/lib/resolvers/type/assortment/assortment-product-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-types.d.ts +1 -1
- package/lib/resolvers/type/assortment/assortment-types.js +8 -4
- package/lib/resolvers/type/assortment/assortment-types.js.map +1 -1
- package/lib/resolvers/type/bookmark-types.d.ts +1 -1
- package/lib/resolvers/type/bookmark-types.js +0 -1
- package/lib/resolvers/type/bookmark-types.js.map +1 -1
- package/lib/resolvers/type/country-types.d.ts +1 -1
- package/lib/resolvers/type/delivery-provider-types.d.ts +1 -1
- package/lib/resolvers/type/enrollment/enrollment-delivery-types.d.ts +2 -2
- package/lib/resolvers/type/enrollment/enrollment-payment-types.d.ts +2 -2
- package/lib/resolvers/type/enrollment/enrollment-period-types.d.ts +2 -2
- package/lib/resolvers/type/enrollment/enrollment-plan-tyes.d.ts +2 -2
- package/lib/resolvers/type/enrollment/enrollment-plan-tyes.js +0 -1
- package/lib/resolvers/type/enrollment/enrollment-plan-tyes.js.map +1 -1
- package/lib/resolvers/type/enrollment/enrollment-types.d.ts +2 -2
- package/lib/resolvers/type/event-types.d.ts +1 -1
- package/lib/resolvers/type/filter/filter-option-types.d.ts +2 -2
- package/lib/resolvers/type/filter/filter-types.d.ts +2 -2
- package/lib/resolvers/type/index.d.ts +1 -0
- package/lib/resolvers/type/login-method-response-types.d.ts +1 -0
- package/lib/resolvers/type/order/order-delivery-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-delivery-shipping-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-global-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-item-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-item-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-item-types.js +0 -3
- package/lib/resolvers/type/order/order-item-types.js.map +1 -1
- package/lib/resolvers/type/order/order-payment-card-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-generic-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-invoice-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-types.d.ts +1 -1
- package/lib/resolvers/type/price-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-assortment-path-types.js +1 -0
- package/lib/resolvers/type/product/product-assortment-path-types.js.map +1 -1
- package/lib/resolvers/type/product/product-bundle-item-types.js +0 -1
- package/lib/resolvers/type/product/product-bundle-item-types.js.map +1 -1
- package/lib/resolvers/type/product/product-configurable-types.js +1 -0
- package/lib/resolvers/type/product/product-configurable-types.js.map +1 -1
- package/lib/resolvers/type/product/product-discount.d.ts +1 -1
- package/lib/resolvers/type/product/product-media-types.js +2 -0
- package/lib/resolvers/type/product/product-media-types.js.map +1 -1
- package/lib/resolvers/type/product/product-plan-types.js +1 -12
- package/lib/resolvers/type/product/product-plan-types.js.map +1 -1
- package/lib/resolvers/type/product/product-review-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-review-types.js +0 -1
- package/lib/resolvers/type/product/product-review-types.js.map +1 -1
- package/lib/resolvers/type/product/product-variation-assignment-types.js +0 -1
- package/lib/resolvers/type/product/product-variation-assignment-types.js.map +1 -1
- package/lib/resolvers/type/quotation-types.d.ts +2 -2
- package/lib/resolvers/type/quotation-types.js +0 -1
- package/lib/resolvers/type/quotation-types.js.map +1 -1
- package/lib/resolvers/type/shop-types.d.ts +1 -1
- package/lib/resolvers/type/token-types.d.ts +1 -1
- package/lib/resolvers/type/token-types.js +2 -1
- package/lib/resolvers/type/token-types.js.map +1 -1
- package/lib/resolvers/type/user-types.d.ts +4 -3
- package/lib/resolvers/type/user-types.js +10 -21
- package/lib/resolvers/type/user-types.js.map +1 -1
- package/lib/resolvers/type/webauthn-credentials-types.d.ts +1 -1
- package/lib/resolvers/type/work-types.d.ts +1 -1
- package/lib/roles/admin.js +3 -72
- package/lib/roles/admin.js.map +1 -1
- package/lib/schema/{types/log.d.ts → directives.d.ts} +0 -0
- package/lib/schema/directives.js +15 -0
- package/lib/schema/directives.js.map +1 -0
- package/lib/schema/index.js +2 -1
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/inputTypes.js +0 -15
- package/lib/schema/inputTypes.js.map +1 -1
- package/lib/schema/mutation.js +22 -36
- package/lib/schema/mutation.js.map +1 -1
- package/lib/schema/query.js +42 -22
- package/lib/schema/query.js.map +1 -1
- package/lib/schema/types/assortment.js +10 -10
- package/lib/schema/types/color.js +1 -1
- package/lib/schema/types/country.js +1 -1
- package/lib/schema/types/currency.js +1 -1
- package/lib/schema/types/delivery.js +3 -2
- package/lib/schema/types/delivery.js.map +1 -1
- package/lib/schema/types/dimensions.js +1 -1
- package/lib/schema/types/discount.js +1 -1
- package/lib/schema/types/filter.js +5 -8
- package/lib/schema/types/filter.js.map +1 -1
- package/lib/schema/types/geo-position.js +1 -1
- package/lib/schema/types/language.js +1 -1
- package/lib/schema/types/media.js +1 -1
- package/lib/schema/types/payment.js +3 -3
- package/lib/schema/types/price.js +2 -2
- package/lib/schema/types/product/bundle-product.js +2 -3
- package/lib/schema/types/product/bundle-product.js.map +1 -1
- package/lib/schema/types/product/configurable-product.js +7 -7
- package/lib/schema/types/product/plan-product.js +3 -3
- package/lib/schema/types/product/product.js +11 -11
- package/lib/schema/types/product/simple-product.js +4 -4
- package/lib/schema/types/product/tokenized-product.js +3 -3
- package/lib/schema/types/search.js +3 -8
- package/lib/schema/types/search.js.map +1 -1
- package/lib/schema/types/shop.js +2 -2
- package/lib/schema/types/types.js +1 -1
- package/lib/schema/types/user.js +4 -3
- package/lib/schema/types/user.js.map +1 -1
- package/lib/schema/types/warehousing.js +3 -3
- package/package.json +26 -12
- package/src/acl.ts +2 -2
- package/src/api-index.ts +6 -27
- package/src/context.ts +0 -18
- package/src/createGraphQLServer.ts +14 -68
- package/src/errors.ts +85 -0
- package/src/express/createApolloMiddleware.ts +40 -0
- package/src/express/createBulkImportMiddleware.ts +87 -0
- package/src/express/createERCMetadataMiddleware.ts +73 -0
- package/src/express/createSingleSignOnMiddleware.ts +84 -0
- package/src/express/index.ts +48 -0
- package/src/loaders/index.ts +27 -35
- package/src/resolvers/mutations/accounts/changePassword.ts +11 -6
- package/src/resolvers/mutations/accounts/createUser.ts +21 -6
- package/src/resolvers/mutations/accounts/disableTOTP.ts +13 -3
- package/src/resolvers/mutations/accounts/enableTOTP.ts +9 -2
- package/src/resolvers/mutations/accounts/enrollUser.ts +20 -5
- package/src/resolvers/mutations/accounts/forgotPassword.ts +8 -1
- package/src/resolvers/mutations/accounts/impersonate.ts +1 -1
- package/src/resolvers/mutations/accounts/loginWithPassword.ts +27 -5
- package/src/resolvers/mutations/accounts/loginWithWebAuthn.ts +13 -2
- package/src/resolvers/mutations/accounts/logout.ts +9 -2
- package/src/resolvers/mutations/accounts/logoutAllSessions.ts +7 -1
- package/src/resolvers/mutations/accounts/resetPassword.ts +21 -5
- package/src/resolvers/mutations/accounts/setPassword.ts +2 -2
- package/src/resolvers/mutations/assortments/addAssortmentFilter.ts +5 -9
- package/src/resolvers/mutations/assortments/addAssortmentLink.ts +22 -14
- package/src/resolvers/mutations/assortments/addAssortmentMedia.ts +2 -6
- package/src/resolvers/mutations/assortments/addAssortmentProduct.ts +0 -2
- package/src/resolvers/mutations/assortments/createAssortment.ts +4 -8
- package/src/resolvers/mutations/assortments/prepareAssortmentMediaUpload.ts +0 -1
- package/src/resolvers/mutations/assortments/removeAssortment.ts +1 -1
- package/src/resolvers/mutations/assortments/removeAssortmentFilter.ts +1 -1
- package/src/resolvers/mutations/assortments/removeAssortmentLink.ts +1 -1
- package/src/resolvers/mutations/assortments/removeAssortmentMedia.ts +2 -2
- package/src/resolvers/mutations/assortments/removeAssortmentProduct.ts +1 -1
- package/src/resolvers/mutations/assortments/reorderAssortmentFilters.ts +3 -6
- package/src/resolvers/mutations/assortments/reorderAssortmentLinks.ts +0 -1
- package/src/resolvers/mutations/assortments/reorderAssortmentMedia.ts +3 -6
- package/src/resolvers/mutations/assortments/reorderAssortmentProducts.ts +0 -1
- package/src/resolvers/mutations/assortments/setBaseAssortment.ts +1 -1
- package/src/resolvers/mutations/assortments/updateAssortment.ts +1 -1
- package/src/resolvers/mutations/assortments/updateAssortmentMediaTexts.ts +1 -1
- package/src/resolvers/mutations/assortments/updateAssortmentTexts.ts +1 -1
- package/src/resolvers/mutations/bookmarks/bookmark.ts +4 -7
- package/src/resolvers/mutations/bookmarks/createBookmark.ts +4 -7
- package/src/resolvers/mutations/countries/createCountry.ts +3 -7
- package/src/resolvers/mutations/countries/removeCountry.ts +1 -1
- package/src/resolvers/mutations/countries/updateCountry.ts +1 -1
- package/src/resolvers/mutations/currencies/createCurrency.ts +3 -7
- package/src/resolvers/mutations/currencies/removeCurrency.ts +1 -1
- package/src/resolvers/mutations/currencies/updateCurrency.ts +1 -1
- package/src/resolvers/mutations/delivery/createDeliveryProvider.ts +3 -7
- package/src/resolvers/mutations/delivery/removeDeliveryProvider.ts +1 -1
- package/src/resolvers/mutations/delivery/updateDeliveryProvider.ts +1 -1
- package/src/resolvers/mutations/enrollments/activateEnrollment.ts +1 -1
- package/src/resolvers/mutations/enrollments/terminateEnrollment.ts +1 -1
- package/src/resolvers/mutations/enrollments/updateEnrollment.ts +5 -5
- package/src/resolvers/mutations/filters/createFilter.ts +0 -2
- package/src/resolvers/mutations/filters/createFilterOption.ts +5 -1
- package/src/resolvers/mutations/filters/removeFilter.ts +4 -4
- package/src/resolvers/mutations/filters/updateFilter.ts +1 -1
- package/src/resolvers/mutations/filters/updateFilterTexts.ts +1 -1
- package/src/resolvers/mutations/index.ts +2 -0
- package/src/resolvers/mutations/languages/createLanguage.ts +3 -7
- package/src/resolvers/mutations/languages/removeLanguage.ts +1 -1
- package/src/resolvers/mutations/languages/updateLanguage.ts +1 -1
- package/src/resolvers/mutations/orders/createCart.ts +4 -1
- package/src/resolvers/mutations/orders/payOrder.ts +1 -1
- package/src/resolvers/mutations/orders/removeOrder.ts +1 -1
- package/src/resolvers/mutations/pageView.ts +2 -2
- package/src/resolvers/mutations/payment/createPaymentProvider.ts +3 -7
- package/src/resolvers/mutations/payment/registerPaymentCredentials.ts +6 -2
- package/src/resolvers/mutations/payment/removePaymentProvider.ts +1 -1
- package/src/resolvers/mutations/payment/updatePaymentProvider.ts +1 -1
- package/src/resolvers/mutations/products/addProductAssignment.ts +4 -8
- package/src/resolvers/mutations/products/addProductMedia.ts +1 -2
- package/src/resolvers/mutations/products/addProductReviewVote.ts +1 -1
- package/src/resolvers/mutations/products/createProduct.ts +4 -8
- package/src/resolvers/mutations/products/createProductBundleItem.ts +1 -1
- package/src/resolvers/mutations/products/createProductReview.ts +5 -8
- package/src/resolvers/mutations/products/createProductVariation.ts +6 -10
- package/src/resolvers/mutations/products/createProductVariationOption.ts +4 -5
- package/src/resolvers/mutations/products/prepareProductMediaUpload.ts +0 -1
- package/src/resolvers/mutations/products/publishProduct.ts +1 -1
- package/src/resolvers/mutations/products/removeBundleItem.ts +2 -2
- package/src/resolvers/mutations/products/removeProduct.ts +26 -7
- package/src/resolvers/mutations/products/removeProductAssignment.ts +1 -1
- package/src/resolvers/mutations/products/removeProductMedia.ts +2 -2
- package/src/resolvers/mutations/products/removeProductReview.ts +1 -1
- package/src/resolvers/mutations/products/removeProductReviewVote.ts +1 -1
- package/src/resolvers/mutations/products/removeProductVariation.ts +1 -1
- package/src/resolvers/mutations/products/removeProductVariationOption.ts +0 -1
- package/src/resolvers/mutations/products/reorderProductMedia.ts +1 -1
- package/src/resolvers/mutations/products/unpublishProduct.ts +1 -1
- package/src/resolvers/mutations/products/updateProduct.ts +1 -1
- package/src/resolvers/mutations/products/updateProductCommerce.ts +1 -1
- package/src/resolvers/mutations/products/updateProductMediaTexts.ts +1 -1
- package/src/resolvers/mutations/products/updateProductPlan.ts +1 -1
- package/src/resolvers/mutations/products/updateProductReview.ts +1 -1
- package/src/resolvers/mutations/products/updateProductSupply.ts +1 -1
- package/src/resolvers/mutations/products/updateProductTexts.ts +1 -1
- package/src/resolvers/mutations/products/updateProductTokenization.ts +1 -1
- package/src/resolvers/mutations/products/updateProductVariationTexts.ts +0 -1
- package/src/resolvers/mutations/products/updateProductWarehousing.ts +1 -1
- package/src/resolvers/mutations/users/prepareUserAvatarUpload.ts +0 -1
- package/src/resolvers/mutations/users/removeUser.ts +19 -0
- package/src/resolvers/mutations/users/setRoles.ts +1 -1
- package/src/resolvers/mutations/users/setUserTags.ts +1 -1
- package/src/resolvers/mutations/users/updateUserAvatar.ts +1 -2
- package/src/resolvers/mutations/users/updateUserProfile.ts +1 -1
- package/src/resolvers/mutations/utils/getOrderCart.ts +1 -1
- package/src/resolvers/mutations/warehousing/createWarehousingProvider.ts +3 -7
- package/src/resolvers/mutations/warehousing/removeWarehousingProvider.ts +1 -1
- package/src/resolvers/mutations/warehousing/updateWarehousingProvider.ts +1 -1
- package/src/resolvers/mutations/worker/addWork.ts +1 -1
- package/src/resolvers/mutations/worker/finishWork.ts +8 -12
- package/src/resolvers/mutations/worker/removeWork.ts +1 -1
- package/src/resolvers/queries/products/productCatalogPrices.ts +0 -1
- package/src/resolvers/queries/users/users.ts +2 -1
- package/src/resolvers/queries/worker/workQueue.ts +1 -1
- package/src/resolvers/type/assortment/assortment-filter-types.ts +0 -1
- package/src/resolvers/type/assortment/assortment-link-types.ts +0 -2
- package/src/resolvers/type/assortment/assortment-media-types.ts +2 -0
- package/src/resolvers/type/assortment/assortment-path-link-types.ts +1 -11
- package/src/resolvers/type/assortment/assortment-product-types.ts +0 -2
- package/src/resolvers/type/assortment/assortment-types.ts +9 -4
- package/src/resolvers/type/bookmark-types.ts +0 -1
- package/src/resolvers/type/enrollment/enrollment-plan-tyes.ts +0 -1
- package/src/resolvers/type/order/order-item-types.ts +0 -3
- package/src/resolvers/type/product/product-assortment-path-types.ts +1 -0
- package/src/resolvers/type/product/product-bundle-item-types.ts +0 -1
- package/src/resolvers/type/product/product-configurable-types.ts +1 -0
- package/src/resolvers/type/product/product-media-types.ts +2 -0
- package/src/resolvers/type/product/product-plan-types.ts +2 -18
- package/src/resolvers/type/product/product-review-types.ts +0 -1
- package/src/resolvers/type/product/product-variation-assignment-types.ts +0 -1
- package/src/resolvers/type/quotation-types.ts +0 -1
- package/src/resolvers/type/token-types.ts +2 -1
- package/src/resolvers/type/user-types.ts +14 -25
- package/src/roles/admin.ts +3 -72
- package/src/schema/directives.js +14 -0
- package/src/schema/index.js +2 -1
- package/src/schema/inputTypes.js +0 -15
- package/src/schema/mutation.js +22 -36
- package/src/schema/query.js +42 -22
- package/src/schema/types/assortment.js +10 -10
- package/src/schema/types/color.js +1 -1
- package/src/schema/types/country.js +1 -1
- package/src/schema/types/currency.js +1 -1
- package/src/schema/types/delivery.js +3 -2
- package/src/schema/types/dimensions.js +1 -1
- package/src/schema/types/discount.js +1 -1
- package/src/schema/types/filter.js +5 -8
- package/src/schema/types/geo-position.js +1 -1
- package/src/schema/types/language.js +1 -1
- package/src/schema/types/media.js +1 -1
- package/src/schema/types/payment.js +3 -3
- package/src/schema/types/price.js +2 -2
- package/src/schema/types/product/bundle-product.js +2 -3
- package/src/schema/types/product/configurable-product.js +7 -7
- package/src/schema/types/product/plan-product.js +3 -3
- package/src/schema/types/product/product.js +11 -11
- package/src/schema/types/product/simple-product.js +4 -4
- package/src/schema/types/product/tokenized-product.js +3 -3
- package/src/schema/types/search.js +3 -8
- package/src/schema/types/shop.js +2 -2
- package/src/schema/types/types.js +1 -1
- package/src/schema/types/user.js +4 -3
- package/src/schema/types/warehousing.js +3 -3
- package/tests/api-index.test.ts +78 -0
- package/lib/createBulkImportServer.d.ts +0 -2
- package/lib/createBulkImportServer.js +0 -81
- package/lib/createBulkImportServer.js.map +0 -1
- package/lib/createERCMetadataServer.d.ts +0 -2
- package/lib/createERCMetadataServer.js +0 -59
- package/lib/createERCMetadataServer.js.map +0 -1
- package/lib/schema/types/log.js +0 -16
- package/lib/schema/types/log.js.map +0 -1
- package/src/createBulkImportServer.ts +0 -95
- package/src/createERCMetadataServer.ts +0 -78
- package/src/schema/types/log.js +0 -15
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/// <reference lib="dom" />
|
|
2
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
3
|
+
import cookie from 'cookie';
|
|
4
|
+
const { ROOT_URL, NODE_ENV, UNCHAINED_CLOUD_ENDPOINT } = process.env;
|
|
5
|
+
const logger = createLogger('unchained:unchained-cloud-sso');
|
|
6
|
+
const loginWithSingleSignOn = async (remoteToken, context) => {
|
|
7
|
+
const domain = process.env.UNCHAINED_COOKIE_DOMAIN || new URL(ROOT_URL).hostname || 'localhost';
|
|
8
|
+
const result = await fetch(UNCHAINED_CLOUD_ENDPOINT, {
|
|
9
|
+
method: 'POST',
|
|
10
|
+
headers: {
|
|
11
|
+
'content-type': 'application/json',
|
|
12
|
+
},
|
|
13
|
+
body: JSON.stringify({
|
|
14
|
+
operationName: 'consume',
|
|
15
|
+
variables: {
|
|
16
|
+
token: remoteToken,
|
|
17
|
+
},
|
|
18
|
+
query: 'mutation consume($token: ID!) { controlConsumeSingleSignOnToken(token: $token) { domain } }',
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
const json = await result.json();
|
|
22
|
+
if (json?.errors?.length > 0) {
|
|
23
|
+
throw new Error(json.errors[0].message);
|
|
24
|
+
}
|
|
25
|
+
if (domain === 'localhost' || domain === json?.data?.controlConsumeSingleSignOnToken?.domain) {
|
|
26
|
+
// create sso user if not exist and login
|
|
27
|
+
const ssoUserId = (await context.modules.users.findUser({ username: 'sso' }))?._id ||
|
|
28
|
+
(await context.modules.accounts.createUser({
|
|
29
|
+
username: 'sso',
|
|
30
|
+
roles: ['admin'],
|
|
31
|
+
email: 'sso@unchained.local',
|
|
32
|
+
password: null,
|
|
33
|
+
guest: false,
|
|
34
|
+
}, { skipMessaging: true }));
|
|
35
|
+
const { tokenExpires, token } = await context.modules.accounts.createLoginToken(ssoUserId, context);
|
|
36
|
+
const expires = new Date(tokenExpires || new Date().getTime() + 100000);
|
|
37
|
+
const authCookie = cookie.serialize(process.env.UNCHAINED_COOKIE_NAME, token, {
|
|
38
|
+
domain,
|
|
39
|
+
httpOnly: true,
|
|
40
|
+
expires,
|
|
41
|
+
path: '/',
|
|
42
|
+
sameSite: 'strict',
|
|
43
|
+
secure: NODE_ENV === 'production',
|
|
44
|
+
});
|
|
45
|
+
return authCookie;
|
|
46
|
+
}
|
|
47
|
+
throw new Error('Invalid token/domain pair');
|
|
48
|
+
};
|
|
49
|
+
export default function singleSignOnMiddleware(contextResolver) {
|
|
50
|
+
return async (req, res, next) => {
|
|
51
|
+
try {
|
|
52
|
+
if (req.query?.token) {
|
|
53
|
+
const context = await contextResolver({ req, res });
|
|
54
|
+
const authCookie = await loginWithSingleSignOn(req.query.token, context);
|
|
55
|
+
if (authCookie) {
|
|
56
|
+
res.writeHead(303, {
|
|
57
|
+
'Set-Cookie': authCookie,
|
|
58
|
+
Location: '/',
|
|
59
|
+
});
|
|
60
|
+
res.end();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
logger.error(e.message);
|
|
67
|
+
}
|
|
68
|
+
next();
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=createSingleSignOnMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSingleSignOnMiddleware.js","sourceRoot":"","sources":["../../src/express/createSingleSignOnMiddleware.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,wBAAwB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAErE,MAAM,MAAM,GAAG,YAAY,CAAC,+BAA+B,CAAC,CAAC;AAE7D,MAAM,qBAAqB,GAAG,KAAK,EAAE,WAAW,EAAE,OAAsB,EAAE,EAAE;IAC1E,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB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/server';
|
|
2
|
+
import type e from 'express';
|
|
3
|
+
export declare const useMiddlewareWithCurrentContext: (expressApp: any, path: any, ...middleware: any[]) => void;
|
|
4
|
+
export declare const connect: (expressApp: e.Express, { apolloGraphQLServer }: {
|
|
5
|
+
apolloGraphQLServer: ApolloServer;
|
|
6
|
+
}) => void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getCurrentContextResolver } from '../context';
|
|
2
|
+
import createBulkImportMiddleware from './createBulkImportMiddleware';
|
|
3
|
+
import createERCMetadataMiddleware from './createERCMetadataMiddleware';
|
|
4
|
+
import createApolloMiddleware from './createApolloMiddleware';
|
|
5
|
+
import createSingleSignOnMiddleware from './createSingleSignOnMiddleware';
|
|
6
|
+
const { BULK_IMPORT_API_PATH = '/bulk-import', ERC_METADATA_API_PATH = '/erc-metadata', GRAPHQL_API_PATH = '/graphql', } = process.env;
|
|
7
|
+
export const useMiddlewareWithCurrentContext = (expressApp, path, ...middleware) => {
|
|
8
|
+
const context = getCurrentContextResolver();
|
|
9
|
+
const addContext = async function middlewareWithContext(req, res, next) {
|
|
10
|
+
try {
|
|
11
|
+
req.unchainedContext = await context({ req, res });
|
|
12
|
+
next();
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
next(error);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
expressApp.use(path, addContext, ...middleware);
|
|
19
|
+
};
|
|
20
|
+
export const connect = (expressApp, { apolloGraphQLServer }) => {
|
|
21
|
+
const contextResolver = getCurrentContextResolver();
|
|
22
|
+
expressApp.use(GRAPHQL_API_PATH, createApolloMiddleware(contextResolver, { apolloGraphQLServer }));
|
|
23
|
+
expressApp.use(ERC_METADATA_API_PATH, createERCMetadataMiddleware(contextResolver));
|
|
24
|
+
expressApp.use(BULK_IMPORT_API_PATH, createBulkImportMiddleware(contextResolver));
|
|
25
|
+
expressApp.use(['/', '/.well-known/unchained/cloud-sso'], createSingleSignOnMiddleware(contextResolver));
|
|
26
|
+
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AAE,CAAC,CAAC,CAAC;IACnG,UAAU,CAAC,GAAG,CAAC,qBAAqB,EAAE,2BAA2B,CAAC,eAAe,CAAC,CAAC,CAAC;IACpF,UAAU,CAAC,GAAG,CAAC,oBAAoB,EAAE,0BAA0B,CAAC,eAAe,CAAC,CAAC,CAAC;IAClF,UAAU,CAAC,GAAG,CACZ,CAAC,GAAG,EAAE,kCAAkC,CAAC,EACzC,4BAA4B,CAAC,eAAe,CAAC,CAC9C,CAAC;AACJ,CAAC,CAAC"}
|
package/lib/loaders/index.js
CHANGED
|
@@ -12,13 +12,10 @@ export default async (req, res, unchainedAPI) => {
|
|
|
12
12
|
includeInactive: true,
|
|
13
13
|
includeLeaves: true,
|
|
14
14
|
});
|
|
15
|
-
return queries.map(({ assortmentId
|
|
15
|
+
return queries.map(({ assortmentId }) => {
|
|
16
16
|
return assortments.find((assortment) => {
|
|
17
17
|
if (assortment._id !== assortmentId)
|
|
18
18
|
return false;
|
|
19
|
-
if (!includeInactive) {
|
|
20
|
-
return assortment.isActive === true;
|
|
21
|
-
}
|
|
22
19
|
return true;
|
|
23
20
|
});
|
|
24
21
|
});
|
|
@@ -85,15 +82,14 @@ export default async (req, res, unchainedAPI) => {
|
|
|
85
82
|
const productIds = [...new Set(queries.map((q) => q.productId).filter(Boolean))];
|
|
86
83
|
const products = await unchainedAPI.modules.products.findProducts({
|
|
87
84
|
productIds,
|
|
88
|
-
|
|
85
|
+
productSelector: {
|
|
86
|
+
status: { $in: [null, ProductStatus.ACTIVE, ProductStatus.DELETED] },
|
|
87
|
+
},
|
|
89
88
|
});
|
|
90
|
-
return queries.map(({ productId
|
|
89
|
+
return queries.map(({ productId }) => {
|
|
91
90
|
return products.find((product) => {
|
|
92
91
|
if (product._id !== productId)
|
|
93
92
|
return false;
|
|
94
|
-
if (!includeDrafts) {
|
|
95
|
-
return product.status === ProductStatus.ACTIVE;
|
|
96
|
-
}
|
|
97
93
|
return true;
|
|
98
94
|
});
|
|
99
95
|
});
|
package/lib/loaders/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,SAAS,MAAM,QAAQ,CAAC;AAK/B,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;AAE7B,eAAe,KAAK,EAClB,GAAoB,EACpB,GAAoB,EACpB,YAA2B,EACW,EAAE;IACxC,OAAO;QACL,gBAAgB,EAAE,IAAI,UAAU,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,SAAS,MAAM,QAAQ,CAAC;AAK/B,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;AAE7B,eAAe,KAAK,EAClB,GAAoB,EACpB,GAAoB,EACpB,YAA2B,EACW,EAAE;IACxC,OAAO;QACL,gBAAgB,EAAE,IAAI,UAAU,CAAuC,KAAK,EAAE,OAAO,EAAE,EAAE;YACvF,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAEvF,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC;gBACzE,aAAa;gBACb,eAAe,EAAE,IAAI;gBACrB,aAAa,EAAE,IAAI;aACpB,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S,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAClC;gBACE,IAAI,EAAE;oBACJ,SAAS,EAAE,CAAC;iBACb;aACF,CACF,CAAC;YAEF,MAAM,mBAAmB,GAAG,CAAC,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;YAE7E,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE;gBAC3C,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;gBACrC,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;gBAC1E,IAAI,CAAC,YAAY,CAAC,MAAM;oBAAE,OAAO,IAAI,CAAC;gBACtC,MAAM,aAAa,GAAG,CAAC,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,QAAQ,EAAE,GAAG,mBAAmB,CAAC,CAAC;gBAEzF,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAc,CAAC,GAAG,EAAE,YAAY,EAAE,EAAE;oBAC1E,IAAI,GAAG;wBAAE,OAAO,GAAG,CAAC;oBACpB,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,YAAY,CAAC,CAAC;gBAC7D,CAAC,EAAE,IAAI,CAAC,CAAC;gBACT,OAAO,WAAW,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;YACxC,CAAC,CAAC,CAAC;QACL,CAAC,CACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Context, Root } from '@unchainedshop/types/api';
|
|
2
2
|
export default function changePassword(root: Root, params: {
|
|
3
|
-
oldPassword?: string;
|
|
4
3
|
oldPlainPassword?: string;
|
|
5
|
-
newPassword?: string;
|
|
6
4
|
newPlainPassword?: string;
|
|
7
5
|
}, { modules, userId }: Context): Promise<{
|
|
8
6
|
success: boolean;
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
|
+
import { AuthOperationFailedError, InvalidCredentialsError } from '../../../errors';
|
|
2
3
|
export default async function changePassword(root, params, { modules, userId }) {
|
|
3
4
|
log('mutation changePassword', { userId });
|
|
4
|
-
if (!params.
|
|
5
|
+
if (!params.newPlainPassword) {
|
|
5
6
|
throw new Error('New password is required');
|
|
6
7
|
}
|
|
7
|
-
if (!params.
|
|
8
|
+
if (!params.oldPlainPassword) {
|
|
8
9
|
throw new Error('Old password is required');
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
let success = false;
|
|
12
|
+
try {
|
|
13
|
+
success = await modules.accounts.changePassword(userId, params);
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
success = false;
|
|
17
|
+
if (e.code === 'InvalidCredentials')
|
|
18
|
+
throw new InvalidCredentialsError({});
|
|
19
|
+
else
|
|
20
|
+
throw new AuthOperationFailedError({});
|
|
21
|
+
}
|
|
11
22
|
return { success };
|
|
12
23
|
}
|
|
13
24
|
//# sourceMappingURL=changePassword.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changePassword.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/changePassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"changePassword.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/changePassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAEpF,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,cAAc,CAC1C,IAAU,EACV,MAGC,EACD,EAAE,OAAO,EAAE,MAAM,EAAW;IAE5B,GAAG,CAAC,yBAAyB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAE3C,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;KAC7C;IACD,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;KAC7C;IACD,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI;QACF,OAAO,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACjE;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,GAAG,KAAK,CAAC;QAChB,IAAI,CAAC,CAAC,IAAI,KAAK,oBAAoB;YAAE,MAAM,IAAI,uBAAuB,CAAC,EAAE,CAAC,CAAC;;YACtE,MAAM,IAAI,wBAAwB,CAAC,EAAE,CAAC,CAAC;KAC7C;IAED,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
2
|
import { hashPassword } from '../../../hashPassword';
|
|
3
|
+
import { AuthOperationFailedError, EmailAlreadyExistsError, UsernameAlreadyExistsError, UsernameOrEmailRequiredError, } from '../../../errors';
|
|
3
4
|
export default async function createUser(root, params, context) {
|
|
4
5
|
const { modules, userId } = context;
|
|
5
6
|
log('mutation createUser', { email: params.email, username: params.username, userId });
|
|
6
|
-
if (!params.
|
|
7
|
+
if (!params.plainPassword && !params.webAuthnPublicKeyCredentials) {
|
|
7
8
|
throw new Error('Password or Public Key is required');
|
|
8
9
|
}
|
|
9
10
|
const mappedUser = { ...params };
|
|
10
|
-
if (
|
|
11
|
+
if (mappedUser.plainPassword) {
|
|
11
12
|
mappedUser.password = hashPassword(mappedUser.plainPassword);
|
|
12
13
|
}
|
|
13
14
|
delete mappedUser.plainPassword;
|
|
14
15
|
delete mappedUser.webAuthnPublicKeyCredentials;
|
|
15
16
|
const webAuthnService = params.webAuthnPublicKeyCredentials &&
|
|
16
17
|
(await modules.accounts.webAuthn.verifyCredentialCreation(params.username, params.webAuthnPublicKeyCredentials));
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
let newUserId;
|
|
19
|
+
try {
|
|
20
|
+
newUserId = await modules.accounts.createUser(mappedUser, {
|
|
21
|
+
skipPasswordEnrollment: !!webAuthnService,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
if (e.code === 'EmailAlreadyExists')
|
|
26
|
+
throw new EmailAlreadyExistsError({ email: params?.email });
|
|
27
|
+
else if (e.code === 'UsernameAlreadyExists')
|
|
28
|
+
throw new UsernameAlreadyExistsError({ username: params?.username });
|
|
29
|
+
else if (e.code === 'UsernameOrEmailRequired')
|
|
30
|
+
throw new UsernameOrEmailRequiredError({ username: params?.username });
|
|
31
|
+
else
|
|
32
|
+
throw new AuthOperationFailedError({ username: params?.username, email: params.email });
|
|
33
|
+
}
|
|
20
34
|
if (newUserId && webAuthnService) {
|
|
21
35
|
await modules.users.updateUser({ _id: newUserId }, {
|
|
22
36
|
$push: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUser.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/createUser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"createUser.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/createUser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EACL,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E,CAAC,CAAC;aAC5F,IAAI,CAAC,CAAC,IAAI,KAAK,uBAAuB;YACzC,MAAM,IAAI,0BAA0B,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;aAClE,IAAI,CAAC,CAAC,IAAI,KAAK,yBAAyB;YAC3C,MAAM,IAAI,4BAA4B,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;;YACpE,MAAM,IAAI,wBAAwB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;KAC9F;IAED,IAAI,SAAS,IAAI,eAAe,EAAE;QAChC,MAAM,OAAO,CAAC,KAAK,CAAC,UAAU,CAC5B,EAAE,GAAG,EAAE,SAAS,EAAE,EAClB;YACE,KAAK,EAAE;gBACL,mBAAmB,EAAE,eAAe;aACrC;SACF,EACD,EAAE,CACH,CAAC;KACH;IAED,OAAO,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
|
-
import { UserNotFoundError } from '../../../errors';
|
|
2
|
+
import { TwoFactorCodeDidNotMatchError, TwoFactorNotSetError, UserNotFoundError } from '../../../errors';
|
|
3
3
|
export default async function disableTOTP(root, params, { modules, userId }) {
|
|
4
4
|
const normalizedUserId = params.userId || userId;
|
|
5
5
|
log(`mutation disableTOTP ${params.code} ${normalizedUserId}`, {
|
|
@@ -8,7 +8,20 @@ export default async function disableTOTP(root, params, { modules, userId }) {
|
|
|
8
8
|
const user = await modules.users.findUserById(normalizedUserId);
|
|
9
9
|
if (!user)
|
|
10
10
|
throw new UserNotFoundError({ userId: normalizedUserId });
|
|
11
|
-
|
|
11
|
+
try {
|
|
12
|
+
await modules.accounts.disableTOTP(normalizedUserId, params.code);
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
if (e?.message?.includes("2FA code didn't match"))
|
|
16
|
+
throw new TwoFactorCodeDidNotMatchError({
|
|
17
|
+
submittedCode: params.code,
|
|
18
|
+
userId: params?.userId || userId,
|
|
19
|
+
});
|
|
20
|
+
else if (e?.message?.includes('2FA not set'))
|
|
21
|
+
throw new TwoFactorNotSetError({ userId: params?.userId || userId });
|
|
22
|
+
else
|
|
23
|
+
throw e;
|
|
24
|
+
}
|
|
12
25
|
return user;
|
|
13
26
|
}
|
|
14
27
|
//# sourceMappingURL=disableTOTP.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disableTOTP.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/disableTOTP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"disableTOTP.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/disableTOTP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzG,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,WAAW,CACvC,IAAU,EACV,MAAwC,EACxC,EAAE,OAAO,EAAE,MAAM,EAAW;IAE5B,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC;IAEjD,GAAG,CAAC,wBAAwB,MAAM,CAAC,IAAI,IAAI,gBAAgB,EAAE,EAAE;QAC7D,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAChE,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,iBAAiB,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACrE,IAAI;QACF,MAAM,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;KACnE;IAAC,OAAO,CAAC,EAAE;QACV,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,uBAAuB,CAAC;YAC/C,MAAM,IAAI,6BAA6B,CAAC;gBACtC,aAAa,EAAE,MAAM,CAAC,IAAI;gBAC1B,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,MAAM;aACjC,CAAC,CAAC;aACA,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC;YAC1C,MAAM,IAAI,oBAAoB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,MAAM,EAAE,CAAC,CAAC;;YAClE,MAAM,CAAC,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
|
+
import { TwoFactorAlreadySetError, TwoFactorCodeDidNotMatchError } from '../../../errors';
|
|
2
3
|
export default async function enableTOTP(root, params, { modules, userId }) {
|
|
3
4
|
log(`mutation enableTOTP ${params.code}`, {
|
|
4
5
|
userId,
|
|
5
6
|
});
|
|
6
|
-
|
|
7
|
+
try {
|
|
8
|
+
await modules.accounts.enableTOTP(userId, params.secretBase32, params.code);
|
|
9
|
+
}
|
|
10
|
+
catch (e) {
|
|
11
|
+
if (e?.message?.includes("2FA code didn't match"))
|
|
12
|
+
throw new TwoFactorCodeDidNotMatchError({ submittedCode: params.code, userId });
|
|
13
|
+
else if (e?.message?.includes('2FA already set'))
|
|
14
|
+
throw new TwoFactorAlreadySetError({ userId });
|
|
15
|
+
else
|
|
16
|
+
throw e;
|
|
17
|
+
}
|
|
7
18
|
return modules.users.findUserById(userId);
|
|
8
19
|
}
|
|
9
20
|
//# sourceMappingURL=enableTOTP.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableTOTP.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/enableTOTP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"enableTOTP.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/enableTOTP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAE1F,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,UAAU,CACtC,IAAU,EACV,MAA8C,EAC9C,EAAE,OAAO,EAAE,MAAM,EAAW;IAE5B,GAAG,CAAC,uBAAuB,MAAM,CAAC,IAAI,EAAE,EAAE;QACxC,MAAM;KACP,CAAC,CAAC;IACH,IAAI;QACF,MAAM,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;KAC7E;IAAC,OAAO,CAAC,EAAE;QACV,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,uBAAuB,CAAC;YAC/C,MAAM,IAAI,6BAA6B,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;aAC7E,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC;YAAE,MAAM,IAAI,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;;YAC5F,MAAM,CAAC,CAAC;KACd;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
2
|
import { hashPassword } from '../../../hashPassword';
|
|
3
|
+
import { AuthOperationFailedError, EmailAlreadyExistsError, UsernameAlreadyExistsError, UsernameOrEmailRequiredError, } from '../../../errors';
|
|
3
4
|
export default async function enrollUser(root, params, context) {
|
|
4
5
|
const { modules } = context;
|
|
5
6
|
log('mutation enrollUser', { email: params.email, userId: context.userId });
|
|
6
7
|
const mappedUserData = params;
|
|
7
8
|
mappedUserData.initialPassword = true;
|
|
8
|
-
if (
|
|
9
|
+
if (mappedUserData.plainPassword) {
|
|
9
10
|
mappedUserData.password = hashPassword(mappedUserData.plainPassword);
|
|
10
11
|
}
|
|
11
12
|
delete mappedUserData.plainPassword;
|
|
12
13
|
// Skip Messaging when password is set so we
|
|
13
14
|
// don't send a verification e-mail after enrollment
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
try {
|
|
16
|
+
const userId = await modules.accounts.createUser(mappedUserData, {
|
|
17
|
+
skipMessaging: !!mappedUserData.password,
|
|
18
|
+
});
|
|
19
|
+
return modules.users.findUserById(userId);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
if (e.code === 'EmailAlreadyExists')
|
|
23
|
+
throw new EmailAlreadyExistsError({ email: params?.email });
|
|
24
|
+
else if (e.code === 'UsernameAlreadyExists')
|
|
25
|
+
throw new UsernameAlreadyExistsError({ username: params?.username, email: params.email });
|
|
26
|
+
else if (e.code === 'UsernameOrEmailRequired')
|
|
27
|
+
throw new UsernameOrEmailRequiredError({ username: params?.username, email: params.email });
|
|
28
|
+
else
|
|
29
|
+
throw new AuthOperationFailedError({ username: params?.username, email: params.email });
|
|
30
|
+
}
|
|
18
31
|
}
|
|
19
32
|
//# sourceMappingURL=enrollUser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enrollUser.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/enrollUser.ts"],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oB;YAAE,MAAM,IAAI,uBAAuB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;aAC5F,IAAI,CAAC,CAAC,IAAI,KAAK,uBAAuB;YACzC,MAAM,IAAI,0BAA0B,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;aACvF,IAAI,CAAC,CAAC,IAAI,KAAK,yBAAyB;YAC3C,MAAM,IAAI,4BAA4B,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;;YACzF,MAAM,IAAI,wBAAwB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;KAC9F;AACH,CAAC"}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
|
+
import { AuthOperationFailedError, UserNotFoundError } from '../../../errors';
|
|
2
3
|
export default async function forgotPassword(root, { email }, { modules, userId }) {
|
|
3
4
|
log('mutation forgotPassword', { email, userId });
|
|
4
|
-
|
|
5
|
+
let success = false;
|
|
6
|
+
try {
|
|
7
|
+
success = await modules.accounts.sendResetPasswordEmail(email);
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
if (e.code === 'UserNotFound')
|
|
11
|
+
throw new UserNotFoundError({ email });
|
|
12
|
+
else
|
|
13
|
+
throw new AuthOperationFailedError({ email });
|
|
14
|
+
}
|
|
5
15
|
return { success };
|
|
6
16
|
}
|
|
7
17
|
//# sourceMappingURL=forgotPassword.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forgotPassword.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/forgotPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"forgotPassword.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/forgotPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE9E,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,cAAc,CAC1C,IAAU,EACV,EAAE,KAAK,EAAqB,EAC5B,EAAE,OAAO,EAAE,MAAM,EAAW;IAE5B,GAAG,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IAElD,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI;QACF,OAAO,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;KAChE;IAAC,OAAO,CAAC,EAAE;QACV,IAAI,CAAC,CAAC,IAAI,KAAK,cAAc;YAAE,MAAM,IAAI,iBAAiB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;;YACjE,MAAM,IAAI,wBAAwB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;KACpD;IAED,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -4,7 +4,7 @@ const impersonate = async (root, { userId }, context) => {
|
|
|
4
4
|
log(`mutation impersonate ${userId}`);
|
|
5
5
|
const userToImpersonate = await context.modules.users.findUserById(userId);
|
|
6
6
|
if (!userToImpersonate) {
|
|
7
|
-
throw new UserNotFoundError(
|
|
7
|
+
throw new UserNotFoundError({ userId });
|
|
8
8
|
}
|
|
9
9
|
if ((userToImpersonate.roles || []).includes('admin')) {
|
|
10
10
|
throw new NoPermissionError("Cannot impersonate users with role 'admin'");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impersonate.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/impersonate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,MAAM,WAAW,GAAG,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,OAAgB,EAAE,EAAE;IAC/D,GAAG,CAAC,wBAAwB,MAAM,EAAE,CAAC,CAAC;IAEtC,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAE3E,IAAI,CAAC,iBAAiB,EAAE;QACtB,MAAM,IAAI,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"impersonate.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/impersonate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,MAAM,WAAW,GAAG,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,OAAgB,EAAE,EAAE;IAC/D,GAAG,CAAC,wBAAwB,MAAM,EAAE,CAAC,CAAC;IAEtC,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAE3E,IAAI,CAAC,iBAAiB,EAAE;QACtB,MAAM,IAAI,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;KACzC;IAED,IAAI,CAAC,iBAAiB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACrD,MAAM,IAAI,iBAAiB,CAAC,4CAA4C,CAAC,CAAC;KAC3E;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAC3F,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
import { log } from '@unchainedshop/logger';
|
|
2
|
+
import { AuthenticationFailedError, AuthOperationFailedError, InvalidCredentialsError, TwoFactorCodeDidNotMatchError, TwoFactorCodeRequiredError, UserDeactivatedError, } from '../../../errors';
|
|
2
3
|
import { hashPassword } from '../../../hashPassword';
|
|
3
4
|
export default async function loginWithPassword(root, params, context) {
|
|
4
5
|
const { modules } = context;
|
|
5
|
-
const { username, email,
|
|
6
|
+
const { username, email, plainPassword, totpCode } = params;
|
|
6
7
|
log('mutation loginWithPassword', { username, email });
|
|
7
|
-
if (!
|
|
8
|
+
if (!plainPassword) {
|
|
8
9
|
throw new Error('Password is required');
|
|
9
10
|
}
|
|
10
11
|
const mappedUserLoginParams = {
|
|
11
12
|
user: email ? { email } : { username },
|
|
12
|
-
password:
|
|
13
|
+
password: hashPassword(plainPassword),
|
|
13
14
|
code: totpCode,
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
+
try {
|
|
17
|
+
const result = await modules.accounts.loginWithService({ service: 'password', ...mappedUserLoginParams }, context);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
if (e.code === 'AuthenticationFailed')
|
|
22
|
+
throw new AuthenticationFailedError({ username, email });
|
|
23
|
+
else if (e.code === 'UserDeactivated')
|
|
24
|
+
throw new UserDeactivatedError({ username, email });
|
|
25
|
+
else if (e.code === 'InvalidCredentials')
|
|
26
|
+
throw new InvalidCredentialsError({ username, email });
|
|
27
|
+
else if (e?.message?.includes('2FA code required'))
|
|
28
|
+
throw new TwoFactorCodeRequiredError({ username, email });
|
|
29
|
+
else if (e?.message?.includes("2FA code didn't match"))
|
|
30
|
+
throw new TwoFactorCodeDidNotMatchError({ submittedCode: params.totpCode, username, email });
|
|
31
|
+
else
|
|
32
|
+
throw new AuthOperationFailedError({ submittedCode: params.totpCode, username, email });
|
|
33
|
+
}
|
|
16
34
|
}
|
|
17
35
|
//# sourceMappingURL=loginWithPassword.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loginWithPassword.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/loginWithPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,iBAAiB,CAC7C,IAAU,EACV,
|
|
1
|
+
{"version":3,"file":"loginWithPassword.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/loginWithPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,6BAA6B,EAC7B,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,iBAAiB,CAC7C,IAAU,EACV,MAKC,EACD,OAAgB;IAEhB,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAE5D,GAAG,CAAC,4BAA4B,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAEvD,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;KACzC;IAED,MAAM,qBAAqB,GAAG;QAC5B,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CA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edError, } from '../../../errors';
|
|
2
3
|
export default async function loginWithWebAuthn(root, params, context) {
|
|
3
4
|
const { modules } = context;
|
|
4
5
|
log('mutation loginWithWebAuthn');
|
|
5
|
-
|
|
6
|
+
try {
|
|
7
|
+
const result = await modules.accounts.loginWithService({ service: 'webAuthn', ...params }, context);
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
catch (e) {
|
|
11
|
+
if (e.code === 'AuthenticationFailed')
|
|
12
|
+
throw new AuthenticationFailedError({});
|
|
13
|
+
else if (e.code === 'UserDeactivated')
|
|
14
|
+
throw new UserDeactivatedError({});
|
|
15
|
+
else
|
|
16
|
+
throw new AuthOperationFailedError({});
|
|
17
|
+
}
|
|
6
18
|
}
|
|
7
19
|
//# sourceMappingURL=loginWithWebAuthn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loginWithWebAuthn.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/loginWithWebAuthn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"loginWithWebAuthn.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/loginWithWebAuthn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,iBAAiB,CAC7C,IAAU,EACV,MAEC,EACD,OAAgB;IAEhB,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE5B,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAClC,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;QACpG,OAAO,MAAM,CAAC;KACf;IAAC,OAAO,CAAC,EAAE;QACV,IAAI,CAAC,CAAC,IAAI,KAAK,sBAAsB;YAAE,MAAM,IAAI,yBAAyB,CAAC,EAAE,CAAC,CAAC;aAC1E,IAAI,CAAC,CAAC,IAAI,KAAK,iBAAiB;YAAE,MAAM,IAAI,oBAAoB,CAAC,EAAE,CAAC,CAAC;;YACrE,MAAM,IAAI,wBAAwB,CAAC,EAAE,CAAC,CAAC;KAC7C;AACH,CAAC"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { log, LogLevel } from '@unchainedshop/logger';
|
|
2
|
-
export default async function logout(root,
|
|
2
|
+
export default async function logout(root, { token }, context) {
|
|
3
3
|
const { modules, userId, setLoginToken } = context;
|
|
4
4
|
log('mutation logout', { userId });
|
|
5
|
-
const loggedOut = await modules.accounts.logout(
|
|
5
|
+
const loggedOut = await modules.accounts.logout({
|
|
6
|
+
token,
|
|
7
|
+
loginToken: context.loginToken,
|
|
8
|
+
userId: context.userId,
|
|
9
|
+
}, context);
|
|
6
10
|
if (loggedOut.error) {
|
|
7
11
|
log('Error while logging out', {
|
|
8
12
|
logLevel: LogLevel.Error,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/logout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,MAAM,CAAC,IAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/logout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,MAAM,CAAC,IAAU,EAAE,EAAE,KAAK,EAAqB,EAAE,OAAgB;IAC7F,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAEnD,GAAG,CAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAEnC,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAC7C;QACE,KAAK;QACL,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,EACD,OAAO,CACR,CAAC;IAEF,IAAI,SAAS,CAAC,KAAK,EAAE;QACnB,GAAG,CAAC,yBAAyB,EAAE;YAC7B,QAAQ,EAAE,QAAQ,CAAC,KAAK;YACxB,GAAG,SAAS,CAAC,KAAK;SACnB,CAAC,CAAC;KACJ;SAAM;QACL,aAAa,CAAC,IAAI,CAAC,CAAC;KACrB;IAED,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -2,7 +2,10 @@ import { log, LogLevel } from '@unchainedshop/logger';
|
|
|
2
2
|
export default async function logoutAllSessions(root, _, context) {
|
|
3
3
|
const { modules, userId, setLoginToken } = context;
|
|
4
4
|
log('mutation logoutAllSessions', { userId });
|
|
5
|
-
const loggedOut = await modules.accounts.logout({
|
|
5
|
+
const loggedOut = await modules.accounts.logout({
|
|
6
|
+
loginToken: context.loginToken,
|
|
7
|
+
userId: context.userId,
|
|
8
|
+
}, context);
|
|
6
9
|
if (loggedOut.error) {
|
|
7
10
|
log('Error while logging out', {
|
|
8
11
|
logLevel: LogLevel.Error,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logoutAllSessions.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/logoutAllSessions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAU,EAAE,CAAM,EAAE,OAAgB;IAClF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAEnD,GAAG,CAAC,4BAA4B,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAE9C,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"logoutAllSessions.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/logoutAllSessions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAU,EAAE,CAAM,EAAE,OAAgB;IAClF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAEnD,GAAG,CAAC,4BAA4B,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAE9C,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAC7C;QACE,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,EACD,OAAO,CACR,CAAC;IAEF,IAAI,SAAS,CAAC,KAAK,EAAE;QACnB,GAAG,CAAC,yBAAyB,EAAE;YAC7B,QAAQ,EAAE,QAAQ,CAAC,KAAK;YACxB,GAAG,SAAS,CAAC,KAAK;SACnB,CAAC,CAAC;KACJ;SAAM;QACL,aAAa,CAAC,IAAI,CAAC,CAAC;KACrB;IAED,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC;AACxC,CAAC"}
|