@mohasinac/appkit 4.29.1 → 4.30.1

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.
Files changed (165) hide show
  1. package/dist/_internal/client/features/layout/SidebarCollapseToggle.js +1 -1
  2. package/dist/_internal/shared/features/blog/schema.d.ts +2 -2
  3. package/dist/_internal/shared/features/blog/schema.js +2 -1
  4. package/dist/_internal/shared/features/brands/schema.d.ts +2 -2
  5. package/dist/_internal/shared/features/brands/schema.js +3 -1
  6. package/dist/_internal/shared/features/categories/bundle-schemas.d.ts +3 -3
  7. package/dist/_internal/shared/features/categories/bundle-schemas.js +2 -1
  8. package/dist/_internal/shared/features/events/schema.d.ts +2 -2
  9. package/dist/_internal/shared/features/events/schema.js +2 -1
  10. package/dist/_internal/shared/features/products/schema.d.ts +8 -8
  11. package/dist/_internal/shared/features/products/schema.js +3 -2
  12. package/dist/_internal/shared/features/reviews/schema.d.ts +1 -1
  13. package/dist/_internal/shared/features/reviews/schema.js +2 -1
  14. package/dist/_internal/shared/types/action-result.d.ts +0 -2
  15. package/dist/client/api/surface-error.d.ts +9 -0
  16. package/dist/client/api/surface-error.js +29 -3
  17. package/dist/client/api/useApiMutation.d.ts +10 -0
  18. package/dist/client/api/useApiMutation.js +2 -1
  19. package/dist/core/server-action.d.ts +3 -14
  20. package/dist/core/server-action.js +11 -2
  21. package/dist/errors/error-envelope.d.ts +73 -0
  22. package/dist/errors/error-envelope.js +96 -0
  23. package/dist/errors/error-handler.js +14 -7
  24. package/dist/features/account/components/NotificationBell.js +1 -1
  25. package/dist/features/account/components/UserSidebar.js +2 -2
  26. package/dist/features/account/components/UserSupportView.js +2 -6
  27. package/dist/features/account/hooks/useProfile.d.ts +6 -0
  28. package/dist/features/account/hooks/useProfile.js +1 -0
  29. package/dist/features/admin/components/AdminAdEditorView.js +1 -3
  30. package/dist/features/admin/components/AdminAddressClustersView.js +1 -3
  31. package/dist/features/admin/components/AdminAddressEditorView.js +2 -4
  32. package/dist/features/admin/components/AdminAddressesView.js +1 -3
  33. package/dist/features/admin/components/AdminAllEventEntriesView.js +1 -3
  34. package/dist/features/admin/components/AdminBidsView.js +1 -3
  35. package/dist/features/admin/components/AdminBlogEditorView.js +2 -2
  36. package/dist/features/admin/components/AdminBrandEditorView.js +4 -5
  37. package/dist/features/admin/components/AdminCarouselGroupEditorView.js +1 -3
  38. package/dist/features/admin/components/AdminCategoryEditorView.js +2 -4
  39. package/dist/features/admin/components/AdminContactEditorView.js +1 -3
  40. package/dist/features/admin/components/AdminContactView.js +2 -6
  41. package/dist/features/admin/components/AdminCouponEditorView.js +2 -4
  42. package/dist/features/admin/components/AdminEmployeeEditorView.js +3 -9
  43. package/dist/features/admin/components/AdminFaqEditorView.js +2 -4
  44. package/dist/features/admin/components/AdminFeatureEditorView.js +0 -9
  45. package/dist/features/admin/components/AdminFeatureFlagsView.js +2 -4
  46. package/dist/features/admin/components/AdminNavEditorView.js +1 -3
  47. package/dist/features/admin/components/AdminNavigationView.js +3 -3
  48. package/dist/features/admin/components/AdminNewsletterView.js +1 -3
  49. package/dist/features/admin/components/AdminNotificationsView.js +2 -6
  50. package/dist/features/admin/components/AdminOffersView.js +1 -3
  51. package/dist/features/admin/components/AdminOrderEditorView.js +1 -3
  52. package/dist/features/admin/components/AdminPaymentClustersView.js +1 -3
  53. package/dist/features/admin/components/AdminPaymentMethodsView.js +1 -3
  54. package/dist/features/admin/components/AdminPayoutMarkPaidModal.js +2 -4
  55. package/dist/features/admin/components/AdminProductEditorView.js +2 -4
  56. package/dist/features/admin/components/AdminReturnRequestsView.js +2 -6
  57. package/dist/features/admin/components/AdminReviewsView.js +2 -6
  58. package/dist/features/admin/components/AdminScammerEditorView.js +2 -6
  59. package/dist/features/admin/components/AdminSectionsView.js +2 -6
  60. package/dist/features/admin/components/AdminSessionsView.js +1 -3
  61. package/dist/features/admin/components/AdminSidebar.js +2 -2
  62. package/dist/features/admin/components/AdminSiteSettingsView.js +1 -1
  63. package/dist/features/admin/components/AdminStoreEditorView.js +1 -3
  64. package/dist/features/admin/components/AdminStoresView.js +2 -6
  65. package/dist/features/admin/components/AdminSublistingCategoryEditorView.js +2 -6
  66. package/dist/features/admin/components/AdminSupportTicketDetailView.js +7 -21
  67. package/dist/features/admin/components/AdminTesterChecklistItemEditorView.js +2 -4
  68. package/dist/features/admin/components/AdminUserEditorView.js +6 -18
  69. package/dist/features/admin/components/AdminUsersView.js +2 -6
  70. package/dist/features/admin/components/BrandQuickCreateForm.js +2 -4
  71. package/dist/features/admin/components/CategoryQuickCreateForm.js +2 -4
  72. package/dist/features/auctions/components/PlaceBidFormClient.js +1 -1
  73. package/dist/features/auth/components/ForgotPasswordView.js +1 -1
  74. package/dist/features/auth/components/LoginForm.js +1 -1
  75. package/dist/features/auth/components/RegisterForm.js +1 -1
  76. package/dist/features/auth/components/ResetPasswordView.js +1 -1
  77. package/dist/features/auth/components/SocialAuthButtons.js +1 -1
  78. package/dist/features/auth/repository/session.repository.js +13 -1
  79. package/dist/features/auth/repository/token.repository.d.ts +25 -2
  80. package/dist/features/auth/repository/token.repository.js +26 -18
  81. package/dist/features/blog/actions/blog-actions.d.ts +14 -14
  82. package/dist/features/blog/actions/blog-actions.js +6 -8
  83. package/dist/features/blog/schemas/index.d.ts +1 -1
  84. package/dist/features/blog/schemas/index.js +2 -4
  85. package/dist/features/categories/api/[id]/route.js +2 -1
  86. package/dist/features/categories/api/route.js +2 -1
  87. package/dist/features/events/schemas/index.d.ts +1 -1
  88. package/dist/features/events/schemas/index.js +2 -4
  89. package/dist/features/faq/components/ContactCTA.js +1 -1
  90. package/dist/features/filters/AsyncFacetSection.js +1 -1
  91. package/dist/features/filters/FilterFacetSection.js +1 -1
  92. package/dist/features/filters/RangeFilter.js +1 -1
  93. package/dist/features/filters/SwitchFilter.js +1 -1
  94. package/dist/features/homepage/api/carousel/[id]/route.js +4 -3
  95. package/dist/features/homepage/api/carousel/route.js +4 -3
  96. package/dist/features/homepage/api/route.js +3 -2
  97. package/dist/features/homepage/components/GoogleReviewsSection.js +1 -1
  98. package/dist/features/homepage/components/HeroBanner.js +1 -1
  99. package/dist/features/homepage/components/HeroCarousel.js +1 -1
  100. package/dist/features/homepage/components/SocialPostCard.js +1 -1
  101. package/dist/features/homepage/components/WhatsAppCommunitySection.js +1 -1
  102. package/dist/features/layout/AppLayoutShell.js +4 -4
  103. package/dist/features/layout/BottomNavbar.js +2 -2
  104. package/dist/features/layout/MainNavbar.js +1 -1
  105. package/dist/features/layout/TitleBarLayout.js +24 -12
  106. package/dist/features/media/AvatarUpload.js +28 -10
  107. package/dist/features/media/modals/ImageCropModal.js +1 -1
  108. package/dist/features/media/modals/ImageEditor.js +1 -1
  109. package/dist/features/products/components/MakeOfferButton.js +1 -1
  110. package/dist/features/reviews/api/[id]/route.js +3 -2
  111. package/dist/features/reviews/api/route.js +3 -2
  112. package/dist/features/search/components/Search.js +2 -2
  113. package/dist/features/seller/components/SellerAnalyticsAlertsView.js +3 -3
  114. package/dist/features/seller/components/SellerSidebar.js +2 -2
  115. package/dist/features/store-extensions/components/ReviewDecisionModal.js +1 -1
  116. package/dist/features/stores/repository/store.repository.d.ts +21 -0
  117. package/dist/features/stores/repository/store.repository.js +32 -0
  118. package/dist/features/whatsapp-bot/components/SellerWhatsAppSettingsView.js +0 -2
  119. package/dist/index.d.ts +3 -4
  120. package/dist/index.js +4 -7
  121. package/dist/next/api/api-response.d.ts +29 -12
  122. package/dist/next/api/api-response.js +9 -8
  123. package/dist/next/api/apiHandler.d.ts +6 -1
  124. package/dist/next/api/apiHandler.js +13 -1
  125. package/dist/next/api/routeHandler.js +6 -6
  126. package/dist/next/middleware/pii-scrubber.js +5 -2
  127. package/dist/providers/db-firebase/base.repository.d.ts +14 -0
  128. package/dist/providers/db-firebase/base.repository.js +22 -0
  129. package/dist/providers/db-firebase/sieve.d.ts +14 -1
  130. package/dist/providers/db-firebase/sieve.js +48 -4
  131. package/dist/security/browser.d.ts +1 -1
  132. package/dist/security/browser.js +1 -1
  133. package/dist/security/index.d.ts +2 -2
  134. package/dist/security/index.js +2 -2
  135. package/dist/security/pii-encrypt.d.ts +12 -10
  136. package/dist/security/pii-encrypt.js +91 -29
  137. package/dist/security/pii-mask.d.ts +39 -1
  138. package/dist/security/pii-mask.js +33 -4
  139. package/dist/security/pii-redact.d.ts +0 -13
  140. package/dist/security/pii-redact.js +3 -1
  141. package/dist/security/pii-schemas.d.ts +0 -6
  142. package/dist/security/pii-schemas.js +29 -6
  143. package/dist/security/settings-encryption.js +31 -3
  144. package/dist/seed/test-utils.js +6 -2
  145. package/dist/server.d.ts +1 -1
  146. package/dist/server.js +1 -1
  147. package/dist/ui/DataTable.js +2 -2
  148. package/dist/ui/components/CollapsibleSection.js +1 -1
  149. package/dist/ui/components/ImageGallery.js +1 -1
  150. package/dist/ui/components/ListingLayout.js +1 -1
  151. package/dist/ui/forms/FormShell.d.ts +0 -19
  152. package/dist/ui/forms/FormShell.js +4 -23
  153. package/dist/ui/forms/apply-zod-issues.d.ts +34 -0
  154. package/dist/ui/forms/apply-zod-issues.js +38 -0
  155. package/dist/ui/forms/index.d.ts +2 -1
  156. package/dist/ui/forms/index.js +2 -1
  157. package/dist/ui/icons/icon-registry.d.ts +8 -0
  158. package/dist/ui/icons/icon-registry.js +13 -1
  159. package/dist/utils/action-response.d.ts +1 -1
  160. package/dist/utils/media-url.d.ts +49 -0
  161. package/dist/utils/media-url.js +72 -1
  162. package/dist/validation/schemas.d.ts +15 -2
  163. package/dist/validation/schemas.js +18 -22
  164. package/package.json +1 -1
  165. package/scripts/seed-cli.mjs +21 -6
@@ -108,9 +108,17 @@ if (!SERVICE_ACCOUNT_OVERRIDE && missing.length > 0) {
108
108
 
109
109
  // PII keys are mandatory for collections that encrypt fields
110
110
  const PII_REQUIRED = ["users", "addresses", "storeAddresses", "products", "orders", "reviews", "bids", "payouts", "eventEntries"];
111
- const PII_KEY_PRESENT = Boolean(process.env.PII_SECRET || process.env.PII_ENCRYPTION_KEY);
111
+ // PII_ENCRYPTION_KEY ONLY. `PII_SECRET` used to be accepted here as an
112
+ // alternative and is read by no runtime code — so a machine with only that set
113
+ // passed this check and then threw at the first encrypt, mid-load, with some
114
+ // collections already written.
115
+ const PII_KEY_PRESENT = Boolean(process.env.PII_ENCRYPTION_KEY);
112
116
  if (ACTION === "load" && !PII_KEY_PRESENT) {
113
- console.warn("⚠ PII_SECRET / PII_ENCRYPTION_KEY not set — collections with PII fields will fail.");
117
+ // A hard stop, not a warning. Loading without the key does not skip the PII
118
+ // collections — it writes some and then throws, leaving a half-seeded
119
+ // database that looks like a successful run until someone reads it.
120
+ console.error("✖ PII_ENCRYPTION_KEY is not set — users, addresses, orders, reviews, bids, payouts and eventEntries all encrypt fields at write time.");
121
+ process.exit(2);
114
122
  }
115
123
 
116
124
  // ---------------------------------------------------------------------------
@@ -166,7 +174,7 @@ const appkit = await import("@mohasinac/appkit");
166
174
  // client-safe barrel, only from "@mohasinac/appkit/server". The *_PII_FIELDS
167
175
  // / *_PII_INDEX_MAP constants are plain data and stay in the main barrel.
168
176
  const appkitServer = await import("@mohasinac/appkit/server");
169
- const { encryptPiiFields, addPiiIndices, encryptPayoutDetails, encryptPayoutBankAccount, encryptShippingConfig } = appkitServer;
177
+ const { encryptPiiFields, piiIndicesFor, encryptPayoutDetails, encryptPayoutBankAccount, encryptShippingConfig } = appkitServer;
170
178
 
171
179
  const {
172
180
  // seed data
@@ -480,9 +488,16 @@ async function loadUsers(seed, stats) {
480
488
  await auth.setCustomUserClaims(uid, { role: u.role });
481
489
  }
482
490
 
483
- let docData = stripUndefined({ ...u });
484
- docData = addPiiIndices(docData, USER_PII_INDEX_MAP);
485
- docData = encryptPiiFields(docData, [...USER_PII_FIELDS]);
491
+ // Both arguments read the PLAINTEXT `plain`: indices must be hashed from
492
+ // the source text, and encryption must not see an already-hashed value.
493
+ // The previous form relied on ordering alone (indices first, THEN
494
+ // encrypt) — correct, but one line-swap away from spreading plaintext
495
+ // back over ciphertext, which is why `addPiiIndices` no longer exists.
496
+ const plain = stripUndefined({ ...u });
497
+ let docData = {
498
+ ...encryptPiiFields(plain, [...USER_PII_FIELDS]),
499
+ ...piiIndicesFor(plain, USER_PII_INDEX_MAP),
500
+ };
486
501
  if (docData.payoutDetails) docData.payoutDetails = encryptPayoutDetails(docData.payoutDetails);
487
502
  if (docData.shippingConfig) docData.shippingConfig = encryptShippingConfig(docData.shippingConfig);
488
503
  await docRef.set(docData, { merge: true });