@hszrdm/create-commerce 1.20.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hszrdm/create-commerce",
3
- "version": "1.20.0",
3
+ "version": "1.22.0",
4
4
  "description": "Create a complete HSZRDM Commerce webshop project.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
package/src/cli.mjs CHANGED
@@ -287,7 +287,8 @@ function configureProject(root, settings) {
287
287
  ".DS_Store",
288
288
  "*.log",
289
289
  "backups/",
290
- ".core/deployment-environment",
290
+ ".core/",
291
+ "backend/.core/",
291
292
  "",
292
293
  ].join("\n"),
293
294
  )
@@ -7,9 +7,13 @@
7
7
  # Required for every shop: DATABASE_URL, JWT_SECRET, COOKIE_SECRET,
8
8
  # STORE_CORS, ADMIN_CORS, AUTH_CORS.
9
9
  #
10
- # External integrations are preferably configured in HSZRDM Commerce Admin
11
- # (Settings -> Integrációk). Environment variables below are fallback/bootstrap
12
- # options only. Do not copy unused integration secrets into production.
10
+ # Merchant credentials and customer-specific settings belong only in encrypted
11
+ # Admin Integration Settings, not in generated .env files.
12
+ # Configure optional integrations after startup in Medusa Admin.
13
+ # Deployment transport, infrastructure and webhook security remain ENV-only.
14
+ # Carrier transport endpoints, sandbox modes and timeouts belong only in the
15
+ # deployment ENV. Prices and free-shipping thresholds belong in Medusa Shipping Options.
16
+ # Never put real customer secrets into generated templates or source control.
13
17
 
14
18
  # -----------------------------------------------------------------------------
15
19
  # Runtime / infrastructure
@@ -37,9 +41,9 @@ AUTH_CORS=http://localhost:3000,http://localhost:9000,http://localhost:7001
37
41
  # Encrypts secrets stored by Settings -> Integrációk.
38
42
  INTEGRATION_SETTINGS_ENCRYPTION_KEY=replace-with-at-least-32-random-characters
39
43
  INTEGRATION_SETTINGS_FILE=
40
- # Shared inbound shipping callback secret. Required only for enabled callback-based providers.
41
- # Security PR #53 requires 32-256 random characters; weaker configuration disables callbacks.
42
- # Generate a unique secret per deployment: openssl rand -hex 32
44
+ # Inbound FOXPOST/GLS status callbacks: deployment ENV only, never Admin DB.
45
+ # Keep off until the callback provider uses the same 32-256 character secret.
46
+ SHIPPING_WEBHOOK_ENABLED=false
43
47
  SHIPPING_WEBHOOK_SECRET=
44
48
 
45
49
  # -----------------------------------------------------------------------------
@@ -82,42 +86,11 @@ OPENAI_BASE_URL=https://api.openai.com/v1
82
86
  # Email Center / transactional email
83
87
  # -----------------------------------------------------------------------------
84
88
  EMAIL_CENTER_ENABLED=true
85
- # SMTP is the only supported email transport. This legacy selector is optional.
89
+ # SMTP is the only supported email transport. Configure and enable it in Admin.
90
+ # SMTP credentials, sender identities and event switches are DB-only.
86
91
  EMAIL_PROVIDER=smtp
87
- # New stores have no SMTP host yet; enable after configuring and verifying SMTP in Admin.
88
- SMTP_ENABLED=false
89
92
  EMAIL_FROM="Example Store <system@example.com>"
90
93
  EMAIL_REPLY_TO=support@example.com
91
- SMTP_HOST=
92
- SMTP_PORT=587
93
- # true for implicit TLS (typically 465), false for STARTTLS (typically 587)
94
- SMTP_SECURE=false
95
- SMTP_REQUIRE_TLS=true
96
- SMTP_USER=
97
- SMTP_PASSWORD=
98
- SMTP_FROM="Example Store <system@example.com>"
99
- SMTP_REPLY_TO=
100
- # Opcionális, a SMTP-szolgáltatónál engedélyezett alternatív feladócímek (Send As)
101
- SMTP_ALLOWED_FROM_ADDRESSES=
102
-
103
- EMAIL_CUSTOMER_WELCOME_ENABLED=
104
- EMAIL_REGISTRATION_VERIFICATION_ENABLED=
105
- EMAIL_PASSWORD_RESET_ENABLED=
106
- EMAIL_CHANGE_VERIFICATION_ENABLED=
107
- EMAIL_PASSWORD_CHANGED_ENABLED=
108
- EMAIL_CHANGED_ENABLED=
109
- EMAIL_ACCOUNT_DELETED_ENABLED=
110
- EMAIL_ORDER_PLACED_ENABLED=
111
- EMAIL_PAYMENT_CAPTURED_ENABLED=
112
- EMAIL_FULFILLMENT_CREATED_ENABLED=
113
- EMAIL_SHIPMENT_CREATED_ENABLED=
114
- EMAIL_ORDER_CANCELED_ENABLED=
115
- EMAIL_PAYMENT_REFUNDED_ENABLED=
116
- EMAIL_AFTER_SALES_SUBMITTED_ENABLED=
117
- EMAIL_AFTER_SALES_APPROVED_ENABLED=
118
- EMAIL_AFTER_SALES_REJECTED_ENABLED=
119
- EMAIL_RETURN_INSTRUCTIONS_ENABLED=
120
- EMAIL_RETURN_RECEIVED_ENABLED=
121
94
 
122
95
  EMAIL_LOGO_URL=
123
96
  EMAIL_TRACKING_ENABLED=true
@@ -209,56 +182,11 @@ SEO_ALLOW_INDEXING=
209
182
  SEO_ROBOTS_DISALLOW=
210
183
 
211
184
  # -----------------------------------------------------------------------------
212
- # Payment fallback/bootstrap settings
213
- # Prefer Admin -> Settings -> Integrációk.
214
- # -----------------------------------------------------------------------------
215
- STRIPE_ENABLED=false
216
- STRIPE_API_KEY=
217
- STRIPE_WEBHOOK_SECRET=
218
- STRIPE_WEBHOOK_URL=http://localhost:9000/hooks/payment/stripe_stripe
219
-
220
- SIMPLEPAY_ENABLED=false
221
- SIMPLEPAY_SANDBOX=true
222
- SIMPLEPAY_HUF_MERCHANT=
223
- SIMPLEPAY_HUF_SECRET_KEY=
224
- SIMPLEPAY_EUR_MERCHANT=
225
- SIMPLEPAY_EUR_SECRET_KEY=
226
- SIMPLEPAY_USD_MERCHANT=
227
- SIMPLEPAY_USD_SECRET_KEY=
228
- SIMPLEPAY_RETURN_BASE_URL=http://localhost:9000/store/simplepay/back
229
- SIMPLEPAY_STOREFRONT_URL=http://localhost:3000
230
- SIMPLEPAY_TIMEOUT_MS=15000
231
-
232
- BANK_TRANSFER_ENABLED=false
233
- BANK_TRANSFER_BANK_NAME=
234
- BANK_TRANSFER_ACCOUNT_HOLDER=
235
- BANK_TRANSFER_ACCOUNT_NUMBER=
236
- BANK_TRANSFER_IBAN=
237
- BANK_TRANSFER_BIC=
238
- BANK_TRANSFER_DUE_DAYS=3
239
- BANK_TRANSFER_REFERENCE_PREFIX=
240
- BANK_TRANSFER_EMAIL_ENABLED=true
241
- BANK_TRANSFER_BILLINGO_PROFORMA=false
242
- BANK_TRANSFER_BILLINGO_PROFORMA_SEND=true
243
-
244
- # -----------------------------------------------------------------------------
245
- # Billingo fallback/bootstrap settings
185
+ # Provider deployment defaults; merchant payment and Billingo integration
186
+ # fields are configured in Admin -> Settings -> Integrációk.
246
187
  # -----------------------------------------------------------------------------
247
- BILLINGO_ENABLED=false
248
- BILLINGO_API_URL=https://api.billingo.hu/v3
249
- BILLINGO_API_KEY=
250
- BILLINGO_DOCUMENT_BLOCK_ID=
251
- BILLINGO_BANK_ACCOUNT_ID=
252
188
  BILLINGO_PAYMENT_METHOD=stripe
253
- BILLINGO_LANGUAGE=hu
254
- BILLINGO_ELECTRONIC=true
255
- BILLINGO_DUE_DAYS=0
256
189
  BILLINGO_UNIT=db
257
- BILLINGO_TIMEOUT_MS=30000
258
- BILLINGO_AUTO_INVOICE=true
259
- BILLINGO_AUTO_SEND=true
260
- BILLINGO_AUTO_CANCEL_ON_ORDER_CANCELED=false
261
- BILLINGO_INVOICE_TRIGGER=payment_captured
262
190
 
263
191
  # -----------------------------------------------------------------------------
264
192
  # Background carrier status sync: FOXPOST, GLS, Packeta, Csomagpiac every 30 minutes.
@@ -267,33 +195,22 @@ BILLINGO_INVOICE_TRIGGER=payment_captured
267
195
  SHIPPING_STATUS_SYNC_ENABLED=true
268
196
  SHIPPING_STATUS_SYNC_BATCH_SIZE=100
269
197
 
270
- # Shipping fallback/bootstrap settings
271
- # Prefer Admin -> Settings -> Integrációk.
198
+ # Carrier technical URL, mode, feed and timeout: deployment ENV only.
199
+ # Merchant credentials: encrypted Admin DB. Rates: Medusa Shipping Options.
272
200
  # -----------------------------------------------------------------------------
273
- FOXPOST_ENABLED=false
274
201
  # FOXPOST transport: operator-owned ENV only, never editable in Admin.
275
202
  # A blank FOXPOST_SANDBOX follows APP_ENV (production=false, other=true).
276
203
  # Egyedi környezetben itt felülírható.
277
204
  FOXPOST_API_URL=
278
- FOXPOST_API_USERNAME=
279
- FOXPOST_API_PASSWORD=
280
- FOXPOST_API_KEY=
281
205
  FOXPOST_SANDBOX=
282
206
  # Fixed FOXPOST parcel size sent during Create Fulfillment (XS/S/M/L/XL); default M.
283
207
  FOXPOST_PACKAGE_SIZE=M
284
208
  FOXPOST_LOCKER_FEED_URL=https://cdn.foxpost.hu/foxplus.json
285
209
  FOXPOST_TIMEOUT_MS=10000
286
210
 
287
- GLS_ENABLED=false
288
211
  GLS_API_URL=https://api.mygls.hu
289
- GLS_USERNAME=
290
- GLS_PASSWORD=
291
- GLS_CLIENT_NUMBER=
292
212
  GLS_SANDBOX=false
293
213
  GLS_DELIVERY_POINTS_URL=https://map.gls-hungary.com/data/deliveryPoints/hu.json
294
- GLS_POINT_PRICE_HUF=1490
295
- GLS_HOME_DELIVERY_PRICE_HUF=1990
296
- GLS_FREE_SHIPPING_THRESHOLD_HUF=
297
214
  GLS_TIMEOUT_MS=15000
298
215
  GLS_PRINTER_TYPE=A4_2x2
299
216
  # Optional absolute PRIVATE directory for original GLS PDF labels.
@@ -301,137 +218,45 @@ GLS_PRINTER_TYPE=A4_2x2
301
218
  # Must survive deploy and be included in filesystem backups. Never expose via /static.
302
219
  GLS_PRIVATE_LABEL_DIR=
303
220
  GLS_WEBSHOP_ENGINE=HSZRDM Commerce
304
- GLS_PICKUP_NAME=Example Store
305
- GLS_PICKUP_STREET=
306
- GLS_PICKUP_HOUSE_NUMBER=
307
- GLS_PICKUP_HOUSE_NUMBER_INFO=
308
- GLS_PICKUP_CITY=
309
- GLS_PICKUP_POSTAL_CODE=
310
- GLS_PICKUP_COUNTRY_CODE=HU
311
- GLS_PICKUP_CONTACT_NAME=
312
- GLS_PICKUP_PHONE=
313
- GLS_PICKUP_EMAIL=
314
221
 
315
- PACKETA_ENABLED=false
316
222
  PACKETA_API_URL=https://www.zasilkovna.cz/api/rest
317
- PACKETA_API_KEY=
318
- PACKETA_API_PASSWORD=
319
- PACKETA_SENDER_INDICATION=
320
- PACKETA_HOME_CARRIER_ID=
321
223
  # Optional JSON map of destination country to contracted Packeta HOME carrier ID.
322
- PACKETA_HOME_CARRIER_IDS=
323
224
  # Technical, fixed at server deployment; not mutable from Admin.
324
225
  PACKETA_TIMEOUT_MS=15000
325
- PACKETA_DEFAULT_WEIGHT_KG=1
326
- PACKETA_LABEL_FORMAT=A6 on A6
327
- PACKETA_LANGUAGE=hu
328
226
  # Signing key for signed Packeta callbacks. Confirm provider compatibility;
329
227
  # raw body and timestamp are mandatory. Rotate separately from other webhook secrets.
330
228
  PACKETA_WEBHOOK_SIGNING_KEY=
331
229
 
332
230
  # DPD technical settings are deployment-controlled. Blank sandbox follows APP_ENV.
333
231
  # Shipping prices are fixed Medusa Shipping Options, not DPD ENV fields.
334
- DPD_ENABLED=false
335
232
  DPD_SANDBOX=
336
233
  DPD_API_URL=
337
- DPD_TOKEN=
338
- DPD_BU_CODE=
339
- DPD_CUSTOMER_ID=
340
- DPD_SENDER_ADDRESS_ID=
341
- DPD_HOME_SERVICE_CODE=
342
- DPD_COD_PAYMENT_TYPE=Cash
343
- DPD_PUDO_SOURCE=disabled
344
- DPD_PUDO_SERVICE_CODE=
345
234
  DPD_PUDO_LOCATOR_URL=
346
- DPD_PUDO_DELIS_ID=
347
- DPD_PUDO_PASSWORD=
348
- DPD_PUDO_MESSAGE_LANGUAGE=en_US
349
235
  DPD_TIMEOUT_MS=15000
350
- DPD_DEFAULT_WEIGHT_KG=1
351
- DPD_LABEL_SIZE=A6
352
- DPD_PRINT_FORMAT=PDF
353
- DPD_LABEL_DPI=203
354
236
  DPD_STATUSDATA_ENABLED=false
355
- DPD_STATUSDATA_FTP_HOST=
356
- DPD_STATUSDATA_FTP_PORT=21
357
- DPD_STATUSDATA_FTP_USERNAME=
358
- DPD_STATUSDATA_FTP_PASSWORD=
359
- DPD_STATUSDATA_FTP_DIR=
360
- DPD_STATUSDATA_FTP_TIMEOUT_MS=15000
361
237
 
362
- MPL_ENABLED=false
363
- MPL_SANDBOX=true
238
+ # MPL sandbox mode is ENV-only; blank follows APP_ENV (production = live).
239
+ MPL_SANDBOX=
364
240
  MPL_API_URL=
365
241
  MPL_TRACKING_API_URL=
366
242
  MPL_PUSH_TRACKING_API_URL=
367
243
  MPL_PUSH_TRACKING_STREAM_URL=https://net.posta.hu/tracking/public/tracking/TrackingData
368
244
  MPL_TOKEN_URL=
369
- MPL_API_KEY=
370
- MPL_API_SECRET=
371
- MPL_AGREEMENT=
372
- MPL_ACCOUNT_NO=
373
- MPL_SENDER_NAME=Example Store
374
- MPL_SENDER_EMAIL=orders@example.com
375
- MPL_SENDER_PHONE=
376
- MPL_SENDER_POST_CODE=
377
- MPL_SENDER_CITY=
378
- MPL_SENDER_ADDRESS=
379
- MPL_DEVELOPER=HSZRDM Commerce
380
- MPL_BASIC_SERVICE_CODE=
381
- MPL_EXTRA_SERVICES=
382
- MPL_PAYMENT_MODE=
383
- MPL_TAG=
384
- MPL_HOME_DELIVERY_MODE=HA
385
- MPL_POINT_PRICE_HUF=1290
386
- MPL_HOME_DELIVERY_PRICE_HUF=1990
387
- MPL_FREE_SHIPPING_THRESHOLD_HUF=
388
245
  MPL_TIMEOUT_MS=15000
389
- MPL_DEFAULT_WEIGHT_KG=1
390
- MPL_LABEL_TYPE=A6
391
- MPL_PACKAGE_RETENTION=5
392
246
  MPL_TRACKING_ENABLED=false
393
247
  MPL_PUSH_TRACKING_ENABLED=false
394
- MPL_TRACKING_ACCOUNT_CODE=
395
248
  MPL_PUSH_READ_WINDOW_MS=8000
396
249
  MPL_TRACKING_LANGUAGE=hu
397
250
 
398
- # Csomagpiac technical transport is operator-owned; credentials, sender ID,
399
- # label format and service profiles are configured in the encrypted Admin DB.
251
+ # Csomagpiac transport is operator-owned; merchant fields and service
252
+ # profiles are configured in the encrypted Admin DB.
400
253
  # Leave CSOMAGPIAC_LIVE unset to follow APP_ENV automatically.
401
254
  CSOMAGPIAC_LIVE=
402
255
  CSOMAGPIAC_API_URL=
403
256
  CSOMAGPIAC_TIMEOUT_MS=15000
404
257
 
405
258
  # -----------------------------------------------------------------------------
406
- # Product feeds / trust widgets - optional
407
- # -----------------------------------------------------------------------------
408
- GOOGLE_MERCHANT_ENABLED=false
409
- GOOGLE_MERCHANT_COUNTRY_CODE=HU
410
- GOOGLE_MERCHANT_CURRENCY_CODE=HUF
411
- GOOGLE_MERCHANT_LOCALE=hu-HU
412
- GOOGLE_MERCHANT_STOREFRONT_URL=
413
- GOOGLE_MERCHANT_PRODUCT_PATH_TEMPLATE=/{locale}/{products_segment}/{handle}?v_id={variant_id}
414
- GOOGLE_MERCHANT_SALES_CHANNEL_ID=
415
- GOOGLE_MERCHANT_FEED_TITLE=
416
- GOOGLE_MERCHANT_FEED_DESCRIPTION=
417
- GOOGLE_MERCHANT_DEFAULT_BRAND=
418
- GOOGLE_MERCHANT_DEFAULT_CONDITION=new
419
- GOOGLE_MERCHANT_INCLUDE_OUT_OF_STOCK=true
420
-
421
- ARUKERESO_ENABLED=false
422
- ARUKERESO_STOREFRONT_URL=
423
- ARUKERESO_PRODUCT_PATH_TEMPLATE=/hu/termekek/{handle}?v_id={variant_id}
424
- ARUKERESO_SALES_CHANNEL_ID=
425
- ARUKERESO_DEFAULT_MANUFACTURER=
426
- ARUKERESO_USE_SKU_AS_PRODUCT_NUMBER=false
427
- ARUKERESO_INCLUDE_OUT_OF_STOCK=true
428
- ARUKERESO_DEFAULT_DELIVERY_TIME=
429
- ARUKERESO_DEFAULT_DELIVERY_COST=
430
-
431
- FOGYASZTOBARAT_ENABLED=false
432
- # Admin integration: paste full provider <script> snippet (legacy ID still supported)
433
- FOGYASZTOBARAT_EMBED_CODE=
434
- FOGYASZTOBARAT_DATA_ID=
259
+ # Product feed and legal/trust widget credentials and options are Admin DB only.
435
260
 
436
261
  # -----------------------------------------------------------------------------
437
262
  # Generator only (not used by a running shop)
@@ -23,7 +23,7 @@
23
23
  "start:prod": "cd .medusa/server && medusa start"
24
24
  },
25
25
  "dependencies": {
26
- "@hszrdm/core": "1.20.0",
26
+ "@hszrdm/core": "1.22.0",
27
27
  "@medusajs/admin-sdk": "2.22.2",
28
28
  "@medusajs/cli": "2.22.2",
29
29
  "@medusajs/draft-order": "2.22.2",
@@ -14,9 +14,12 @@
14
14
  "test:stripe": "node --experimental-strip-types --test tests/stripe-checkout-phase.test.mjs",
15
15
  "test:company-tax": "node --experimental-strip-types --test tests/company-tax.test.mjs",
16
16
  "test:ga4": "node --experimental-strip-types --test tests/ga4-bootstrap.test.mjs",
17
+ "test:consent": "node --experimental-strip-types --test tests/consent.test.mjs",
17
18
  "test:seo": "node --experimental-strip-types --test tests/technical-seo.test.mjs",
18
19
  "test:account-verification": "node --test tests/account-verification.test.mjs",
19
- "test:product-images": "node --experimental-strip-types --test tests/product-image.test.mjs"
20
+ "test:product-images": "node --experimental-strip-types --test tests/product-image.test.mjs",
21
+ "test:checkout-summary": "node --experimental-strip-types --test tests/checkout-summary.test.mjs",
22
+ "test:checkout-payment-choices": "node --experimental-strip-types --test tests/checkout-payment-choices.test.mjs"
20
23
  },
21
24
  "dependencies": {
22
25
  "@stripe/react-stripe-js": "7.0.0",
@@ -138,6 +138,14 @@ input[readonly] { background: var(--surface-soft); color: var(--muted); }
138
138
 
139
139
  .checkout-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
140
140
  .checkout-summary { position: sticky; top: 18px; }
141
+ .checkout-summary-heading { margin: 0; font-size: 1.2rem; line-height: 1.25; font-weight: 850; }
142
+ .checkout-summary-group { display: flex; flex-direction: column; gap: 9px; padding-top: 14px; border-top: 1px solid var(--line); }
143
+ .checkout-summary-group h3 { margin: 0 0 2px; font-size: .93rem; font-weight: 800; }
144
+ .checkout-summary-group .summary-line { font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
145
+ .checkout-summary-group .summary-line span:last-child { color: var(--text); }
146
+ .checkout-summary-group .checkout-summary-gross { color: var(--text); font-weight: 750; }
147
+ .checkout-summary-cod { padding-top: 14px; border-top: 1px solid var(--line); font-weight: 750; font-variant-numeric: tabular-nums; }
148
+ .checkout-summary .summary-total { font-variant-numeric: tabular-nums; }
141
149
 
142
150
  /* Stripe SDK and Payment Element both have an explicit loading stage.
143
151
  Keep Elements mounted (for onReady/confirmPayment) underneath the loader. */
@@ -233,7 +241,12 @@ input[readonly] { background: var(--surface-soft); color: var(--muted); }
233
241
  .consent-toggle span { display: flex; flex-direction: column; gap: 2px; }
234
242
  .consent-toggle small { color: rgba(255,255,255,.65); }
235
243
  .consent-actions { display: flex; flex-direction: column; justify-content: end; gap: 8px; min-width: 220px; }
244
+ .consent-actions > .button:not(.consent-reject) { min-height: 48px; }
236
245
  .consent .button.secondary { border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: white; }
246
+ /* Smaller tertiary choice, still full-width, high-contrast and 44px touch-accessible. */
247
+ .consent-actions > .consent-reject { min-height: 44px; font-size: .88rem; font-weight: 700; padding: 8px 12px; }
248
+ .consent-dismiss { position: absolute; top: 9px; right: 9px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 11px; background: transparent; color: white; cursor: pointer; font-size: 1.35rem; }
249
+ .consent-dismiss:hover, .consent-dismiss:focus-visible { background: rgba(255,255,255,.14); }
237
250
 
238
251
  @media (max-width: 1040px) {
239
252
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@@ -58,6 +58,27 @@ export function AccountDashboard({ config }: { config: CoreConfig }) {
58
58
  const [tab, setTab] = useState<AccountTab>("profile")
59
59
  const [email, setEmail] = useState("")
60
60
  const [password, setPassword] = useState("")
61
+ const [verificationLink, setVerificationLink] = useState("")
62
+ const [emailChangeLink, setEmailChangeLink] = useState("")
63
+
64
+ useEffect(() => {
65
+ const url = new URL(window.location.href)
66
+ const fragment = new URLSearchParams(url.hash.slice(1))
67
+ for (const [key, capture] of [
68
+ ["verify_email", setVerificationLink],
69
+ ["change_email_code", setEmailChangeLink],
70
+ ] as const) {
71
+ const code = fragment.get(key) || url.searchParams.get(key)
72
+ if (!code) continue
73
+ capture(code)
74
+ if (fragment.has(key)) {
75
+ fragment.delete(key)
76
+ url.hash = fragment.toString()
77
+ }
78
+ url.searchParams.delete(key)
79
+ window.history.replaceState(window.history.state, "", url.pathname + url.search + url.hash)
80
+ }
81
+ }, [])
61
82
  const [firstName, setFirstName] = useState("")
62
83
  const [lastName, setLastName] = useState("")
63
84
 
@@ -78,21 +99,15 @@ export function AccountDashboard({ config }: { config: CoreConfig }) {
78
99
  useEffect(() => {
79
100
  void refresh().catch(() => setCustomer(null)).finally(() => setLoading(false))
80
101
  }, [refresh])
81
- // The Email Center template is shared with registration verification.
82
- // Existing email-change links must keep working after adding link support.
83
102
  useEffect(() => {
84
- if (!customer || !isAccountEmailVerified(customer)) return
85
- const url = new URL(window.location.href)
86
- const code = url.searchParams.get("change_email_code")
87
- if (!code) return
88
- url.searchParams.delete("change_email_code")
89
- window.history.replaceState(window.history.state, "", url.pathname + url.search + url.hash)
90
- void api.confirmEmailChange(code).then(() => refresh()).then(() => {
103
+ if (!customer || !isAccountEmailVerified(customer) || !emailChangeLink) return
104
+ setEmailChangeLink("")
105
+ void api.confirmEmailChange(emailChangeLink).then(() => refresh()).then(() => {
91
106
  setAccountNotice({ tone: "success", text: localized(locale, "E-mail-cím módosítva.", "Email address updated.") })
92
- }).catch((error) => {
93
- setAccountNotice({ tone: "error", text: error instanceof Error ? error.message : localized(locale, "Az e-mail módosítása nem sikerült.", "Could not change email.") })
107
+ }).catch(() => {
108
+ setAccountNotice({ tone: "error", text: localized(locale, "Az e-mail módosítása nem sikerült.", "Could not change email.") })
94
109
  })
95
- }, [api, customer, refresh, locale])
110
+ }, [api, customer, emailChangeLink, refresh, locale])
96
111
 
97
112
 
98
113
  const authSubmit = async (event: FormEvent) => {
@@ -121,8 +136,8 @@ export function AccountDashboard({ config }: { config: CoreConfig }) {
121
136
  setMessage(
122
137
  localized(
123
138
  locale,
124
- "A fiók létrejött. Az e-mail megerősítéséhez kövesd a kapott kódot.",
125
- "Your account has been created. Use the code you received to verify your email.",
139
+ "A fiók létrejött. Erősítsd meg az e-mail-címed.",
140
+ "Your account has been created. Verify your email address to continue.",
126
141
  ),
127
142
  )
128
143
  return
@@ -166,6 +181,9 @@ export function AccountDashboard({ config }: { config: CoreConfig }) {
166
181
  <p className="eyebrow">{copy.customerAccount}</p>
167
182
  <h1>{mode === "register" ? copy.register : mode === "forgot" ? copy.forgotPassword : copy.login}</h1>
168
183
  </div>
184
+ {verificationLink || emailChangeLink ? (
185
+ <p role="status">{localized(locale, "A megerősítés folytatásához jelentkezz be.", "Sign in to continue verification.")}</p>
186
+ ) : null}
169
187
  <div className="segmented">
170
188
  <button type="button" className={mode === "login" ? "active" : ""} onClick={() => setMode("login")}>{copy.login}</button>
171
189
  <button type="button" className={mode === "register" ? "active" : ""} onClick={() => setMode("register")}>{copy.register}</button>
@@ -203,6 +221,8 @@ export function AccountDashboard({ config }: { config: CoreConfig }) {
203
221
  api={api}
204
222
  email={stringValue(customer.email)}
205
223
  locale={locale}
224
+ linkCode={verificationLink}
225
+ notice={message}
206
226
  onVerified={onVerificationComplete}
207
227
  onLogout={onVerificationLogout}
208
228
  />
@@ -447,7 +467,7 @@ function SecuritySection({
447
467
  <p className="muted">{localized(locale, "Jelenlegi cím", "Current address")}: {stringValue(customer.email)}</p>
448
468
  <Field label={copy.newEmail} type="email" value={newEmail} onChange={setNewEmail} />
449
469
  <Field label={copy.currentPassword} type="password" value={currentPassword} onChange={setCurrentPassword} />
450
- <button className="button secondary" type="button" onClick={() => void api.requestEmailChange(currentPassword, newEmail).then(() => setMessage(localized(locale, "Megerősítő kód elküldve az új címhez.", "A verification code was sent to the new address.")))}>{copy.requestEmailChange}</button>
470
+ <button className="button secondary" type="button" onClick={() => void api.requestEmailChange(currentPassword, newEmail).then(() => setMessage(localized(locale, "Megerősítő e-mail kérése rögzítve.", "Verification email requested.")))}>{copy.requestEmailChange}</button>
451
471
  <div className="inline-form">
452
472
  <input value={emailCode} onChange={(e) => setEmailCode(e.target.value)} placeholder={copy.verificationCode} />
453
473
  <button className="button" type="button" onClick={() => void api.confirmEmailChange(emailCode).then(refresh).then(() => setMessage(localized(locale, "E-mail cím módosítva.", "Email address changed.")))}>{copy.verify}</button>
@@ -14,12 +14,16 @@ export function AccountVerificationPanel({
14
14
  api,
15
15
  email,
16
16
  locale,
17
+ linkCode,
18
+ notice,
17
19
  onVerified,
18
20
  onLogout,
19
21
  }: {
20
22
  api: ReturnType<typeof accountApi>
21
23
  email: string
22
24
  locale: "hu" | "en"
25
+ linkCode: string
26
+ notice: string | null
23
27
  onVerified: () => Promise<unknown>
24
28
  onLogout: () => Promise<unknown>
25
29
  }) {
@@ -30,6 +34,7 @@ export function AccountVerificationPanel({
30
34
  const [loading, setLoading] = useState(true)
31
35
  const [busy, setBusy] = useState<"resend" | "verify" | "logout" | null>(null)
32
36
  const [message, setMessage] = useState("")
37
+ const inFlight = useRef(false)
33
38
  const usedLink = useRef("")
34
39
  const onVerifiedRef = useRef(onVerified)
35
40
  onVerifiedRef.current = onVerified
@@ -58,55 +63,61 @@ export function AccountVerificationPanel({
58
63
  }, [])
59
64
 
60
65
  const confirm = useCallback(async (value: string) => {
61
- if (!value.trim()) return
66
+ if (!value.trim() || inFlight.current) return
67
+ inFlight.current = true
62
68
  setBusy("verify")
63
69
  setMessage("")
64
70
  try {
65
71
  await api.confirmEmailVerification(value.trim())
66
72
  await onVerifiedRef.current()
67
73
  } catch (error) {
68
- setMessage(error instanceof Error ? error.message : (en ? "Verification failed." : "A megerősítés nem sikerült."))
74
+ setMessage(error instanceof CoreApiError && (error.status === 400 || error.status === 403)
75
+ ? (en ? "The verification code is invalid or expired." : "A kód érvénytelen vagy lejárt.")
76
+ : (en ? "Verification failed. Try again." : "A megerősítés sikertelen. Próbáld újra."))
69
77
  } finally {
78
+ inFlight.current = false
70
79
  setBusy(null)
71
80
  }
72
81
  }, [api, en])
73
82
 
74
- // Links are usable from the same session, or after the customer logs in.
75
- // Remove the sensitive code from browser history as soon as it is consumed.
76
83
  useEffect(() => {
77
- const url = new URL(window.location.href)
78
- const linkCode = url.searchParams.get("verify_email")
79
84
  if (!linkCode || usedLink.current === linkCode) return
80
85
  usedLink.current = linkCode
81
- url.searchParams.delete("verify_email")
82
- window.history.replaceState(window.history.state, "", url.pathname + url.search + url.hash)
83
86
  setCode(linkCode)
84
87
  void confirm(linkCode)
85
- }, [confirm])
88
+ }, [confirm, linkCode])
86
89
 
87
90
  const retrySeconds = retryAt && now ? Math.max(0, Math.ceil((retryAt - now) / 1000)) : 0
88
91
  const countdown = `${Math.floor(retrySeconds / 60).toString().padStart(2, "0")}:${(retrySeconds % 60).toString().padStart(2, "0")}`
89
92
 
90
93
  const resend = async () => {
91
- if (busy || loading || retrySeconds > 0) return
94
+ if (inFlight.current || loading || retrySeconds > 0) return
95
+ inFlight.current = true
92
96
  setBusy("resend")
93
97
  setMessage("")
94
98
  try {
95
99
  const result = await api.requestEmailVerification() as {
96
100
  resend_available_at?: string | null
97
- retry_after_seconds?: number
101
+ already_verified?: boolean
102
+ }
103
+ if (result.already_verified) {
104
+ await onVerifiedRef.current()
105
+ return
98
106
  }
99
107
  const millis = result.resend_available_at ? Date.parse(result.resend_available_at) : NaN
100
- setRetryAt(Number.isFinite(millis) ? millis : Date.now() + 600_000)
108
+ setRetryAt(Number.isFinite(millis) ? millis : null)
101
109
  setMessage(en ? "A new verification email has been requested." : "Új megerősítő e-mailt kértünk.")
102
110
  } catch (error) {
103
111
  if (error instanceof CoreApiError && error.status === 429) {
104
- const payload = error.payload as { retry_after_seconds?: number } | null
105
- setRetryAt(Date.now() + Math.max(1, Number(payload?.retry_after_seconds ?? 600)) * 1000)
112
+ const payload = error.payload as { resend_available_at?: string; retry_after_seconds?: number } | null
113
+ const availableAt = Date.parse(payload?.resend_available_at ?? "")
114
+ setRetryAt(Number.isFinite(availableAt) ? availableAt : Date.now() + (payload?.retry_after_seconds ?? 0) * 1000)
106
115
  } else {
107
- setMessage(error instanceof Error ? error.message : (en ? "Could not resend email." : "Az újraküldés nem sikerült."))
116
+ await refreshStatus().catch(() => undefined)
117
+ setMessage(en ? "Could not request a new email." : "Az újraküldési kérés nem sikerült.")
108
118
  }
109
119
  } finally {
120
+ inFlight.current = false
110
121
  setBusy(null)
111
122
  }
112
123
  }
@@ -115,9 +126,10 @@ export function AccountVerificationPanel({
115
126
  <section className="panel stack" aria-live="polite">
116
127
  <p className="eyebrow">{en ? "Account verification" : "Fiók megerősítése"}</p>
117
128
  <h1>{en ? "Your email is not verified yet" : "Az e-mail-címed még nincs megerősítve"}</h1>
129
+ {notice ? <p role="status">{notice}</p> : null}
118
130
  <p>{en
119
- ? `We sent a confirmation link and code to ${email}. Verify your email to use the store.`
120
- : `Megerősítő linket és kódot küldtünk a(z) ${email} címre. A webshop használatához erősítsd meg az e-mail-címed.`}</p>
131
+ ? `To use the store, verify ${email} with the link or code from your verification email.`
132
+ : `A webshop használatához erősítsd meg a(z) ${email} címet a levélben található linkkel vagy kóddal.`}</p>
121
133
  <button className="button secondary" type="button" onClick={() => void resend()} disabled={loading || busy !== null || retrySeconds > 0}>
122
134
  {busy === "resend"
123
135
  ? (en ? "Sending…" : "Küldés…")