@revenexx/cover 0.23.0 → 0.24.2

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 (36) hide show
  1. package/app/components/account/orders/AccountOrderPay.vue +5 -1
  2. package/app/components/auth/AuthRegisterPanel.vue +10 -1
  3. package/app/components/checkout/onepage/CheckoutAddressSection.vue +2 -2
  4. package/app/components/checkout/onepage/CheckoutGuestDetailsSection.vue +6 -0
  5. package/app/components/checkout/onepage/CheckoutNotesSection.vue +2 -0
  6. package/app/components/checkout/onepage/CheckoutPaymentSection.vue +2 -0
  7. package/app/components/ui/forms/FormKitDatePicker.vue +1 -1
  8. package/app/composables/useAuthStore.ts +4 -0
  9. package/app/composables/useCheckoutOnePage.ts +7 -0
  10. package/app/shared/signInLink.ts +86 -0
  11. package/i18n/locales/de/account.json +2 -1
  12. package/i18n/locales/de/auth.json +2 -0
  13. package/i18n/locales/de/checkout.json +1 -0
  14. package/i18n/locales/en/account.json +2 -1
  15. package/i18n/locales/en/auth.json +2 -0
  16. package/i18n/locales/en/checkout.json +1 -0
  17. package/nuxt.config.ts +13 -0
  18. package/package.json +23 -21
  19. package/server/api/account/orders/[id]/pay.post.ts +7 -0
  20. package/server/api/auth/register.post.ts +15 -41
  21. package/server/api/campaigns/touches.post.ts +1 -1
  22. package/server/api/orders/index.post.ts +7 -0
  23. package/server/api/payment/methods.post.ts +11 -4
  24. package/server/middleware/market-scope.ts +24 -0
  25. package/server/services/ApiAuthService.ts +14 -3
  26. package/server/utils/appSettings.ts +1 -1
  27. package/server/utils/buyerIdentity.ts +28 -1
  28. package/server/utils/country.ts +71 -12
  29. package/server/utils/eligiblePaymentMethods.ts +37 -0
  30. package/server/utils/locale.ts +2 -2
  31. package/server/utils/market.ts +131 -7
  32. package/server/utils/orderAttribution.ts +1 -17
  33. package/server/utils/orderPayment.ts +26 -1
  34. package/server/utils/registration.ts +149 -0
  35. package/server/utils/revenexxSdk.ts +33 -6
  36. package/server/utils/sdkClientAdding.ts +25 -0
@@ -25,7 +25,7 @@ import {
25
25
 
26
26
  // Explicit rather than a Nitro auto-import, so the header logic is reachable
27
27
  // from a unit test that imports this module.
28
- import { buyerPrincipal } from "./buyerIdentity";
28
+ import { buyerPrincipal, buyerSession } from "./buyerIdentity";
29
29
 
30
30
  /**
31
31
  * The generated revenexx web SDK, configured for the BFF. Every live
@@ -227,14 +227,15 @@ export function apiErrorContext(err: unknown): Record<string, unknown> {
227
227
  const clients = new Map<string, RevenexxSdk>();
228
228
 
229
229
  /**
230
- * The active market for the current request, from the `cover-market` cookie the
231
- * locale selector sets. "" when none — then no X-Revenexx-Market is sent and the
232
- * gateway returns only global rows. Per-request, and never part of a cache key
233
- * (see useRevenexxSdk).
230
+ * The market the current request is made in (requestMarket in ./market.ts):
231
+ * the buyer's choice, else the shop's own market (RAD-479). "" only when
232
+ * neither is known — then no X-Revenexx-Market is sent and the gateway returns
233
+ * only global rows. Per-request, and never part of a cache key (see
234
+ * useRevenexxSdk).
234
235
  */
235
236
  function activeMarket(): string {
236
237
  try {
237
- return resolveSelectedMarket(useEvent()) ?? "";
238
+ return requestMarket(useEvent()) ?? "";
238
239
  }
239
240
  catch {
240
241
  // No async context (e.g. startup code) — no market scoping.
@@ -297,6 +298,24 @@ function activePrincipal(): string {
297
298
  }
298
299
  }
299
300
 
301
+ /**
302
+ * The platform session to assert beside `principal` (RAD-472): the verified
303
+ * buyer's own, and only when the call is made for that very buyer. A call made
304
+ * for nobody, or for a principal a caller named explicitly, carries none.
305
+ */
306
+ function activeSession(principal: string): string {
307
+ if (!principal) {
308
+ return "";
309
+ }
310
+ try {
311
+ const event = useEvent();
312
+ return principal === buyerPrincipal(event) ? buyerSession(event) : "";
313
+ }
314
+ catch {
315
+ return "";
316
+ }
317
+ }
318
+
300
319
  export function useRevenexxSdk(options: RevenexxSdkOptions = {}): RevenexxSdk {
301
320
  const { tenant, apiKey, jwt, source } = resolveRevenexxCredentials();
302
321
  const market = activeMarket();
@@ -349,6 +368,14 @@ export function useRevenexxSdk(options: RevenexxSdkOptions = {}): RevenexxSdk {
349
368
  // call made for a buyer, and on none made for nobody.
350
369
  if (principal) {
351
370
  client.headers["X-Revenexx-Principal"] = principal;
371
+ // The session the buyer holds, so the gateway can tell a session a sales
372
+ // rep opened for them from their own, and name the rep to every app
373
+ // (X-Revenexx-Acting-Rep). It names a rep only for the buyer it belongs
374
+ // to, and never changes who the buyer is.
375
+ const session = activeSession(principal);
376
+ if (session) {
377
+ client.headers["X-Revenexx-Session"] = session;
378
+ }
352
379
  }
353
380
  // Auth: the brokered context wins — it is a Zitadel JWT the gateway
354
381
  // verifies against the same JWKS as any interactive caller, so one theme
@@ -0,0 +1,25 @@
1
+ import type { RevenexxSdk } from "./revenexxSdk";
2
+
3
+ type SdkClient = RevenexxSdk["client"];
4
+
5
+ /**
6
+ * The SDK client, adding `extra` to the body of every request it sends.
7
+ *
8
+ * The typed SDK builds a request body from the parameters it knows and drops
9
+ * the rest without a word. Where an app takes a key the SDK has not caught up
10
+ * with, the call is still made through the generated method — its own mapping
11
+ * of the known keys stays the one source — on a client that adds the unknown
12
+ * keys on the way out. Used as `new Orders(clientAdding(sdk.client, extra))`.
13
+ */
14
+ export function clientAdding(client: SdkClient, extra: Record<string, unknown>): SdkClient {
15
+ return new Proxy(client, {
16
+ get(target, prop, receiver) {
17
+ if (prop === "call") {
18
+ return (method: string, url: URL, headers: Record<string, string>, payload?: Record<string, unknown>) =>
19
+ target.call(method, url, headers, { ...(payload ?? {}), ...extra } as never);
20
+ }
21
+ const value = Reflect.get(target, prop, receiver);
22
+ return typeof value === "function" ? value.bind(target) : value;
23
+ },
24
+ });
25
+ }