@vectoriox/iox-ui 5.99.0 → 5.101.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.
Files changed (47) hide show
  1. package/actions-core/index.d.ts +7 -4
  2. package/commerce-core/index.d.ts +2 -0
  3. package/composite-core/index.d.ts +238 -2
  4. package/design-core/index.d.ts +334 -1
  5. package/fesm2022/vectoriox-iox-ui-actions-core.mjs +16 -7
  6. package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
  7. package/fesm2022/vectoriox-iox-ui-commerce-core.mjs +3 -0
  8. package/fesm2022/vectoriox-iox-ui-commerce-core.mjs.map +1 -1
  9. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +1005 -256
  10. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  11. package/fesm2022/vectoriox-iox-ui-design-core.mjs +416 -1
  12. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  13. package/fesm2022/vectoriox-iox-ui-forms-core.mjs +3 -24
  14. package/fesm2022/vectoriox-iox-ui-forms-core.mjs.map +1 -1
  15. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +23 -13
  16. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  17. package/fesm2022/vectoriox-iox-ui-identity-core.mjs +300 -22
  18. package/fesm2022/vectoriox-iox-ui-identity-core.mjs.map +1 -1
  19. package/fesm2022/vectoriox-iox-ui.mjs +7 -61
  20. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  21. package/forms-core/index.d.ts +2 -23
  22. package/generation-core/index.d.ts +3 -1
  23. package/identity-core/index.d.ts +190 -14
  24. package/index.d.ts +0 -12
  25. package/package.json +1 -1
  26. package/src/actions-core/action.model.ts +1 -1
  27. package/src/actions-core/element-actions.ts +16 -6
  28. package/src/commerce-core/site-checkout.ts +3 -0
  29. package/src/composite-core/account-runtime.ts +461 -0
  30. package/src/composite-core/account.ts +309 -0
  31. package/src/composite-core/public-api.ts +2 -0
  32. package/src/composite-core/recipe-parts.ts +48 -0
  33. package/src/composite-core/shop.ts +6 -26
  34. package/src/design-core/field-classes.ts +65 -0
  35. package/src/design-core/flavor-spec.generated.ts +346 -0
  36. package/src/design-core/public-api.ts +1 -0
  37. package/src/forms-core/field-markup.ts +2 -22
  38. package/src/generation-core/compose-site.ts +19 -9
  39. package/src/generation-core/nav-shape.ts +4 -4
  40. package/src/identity-core/provider-marks.ts +60 -0
  41. package/src/identity-core/public-api.ts +3 -0
  42. package/src/identity-core/sign-in.ts +43 -6
  43. package/src/identity-core/site-auth-transport.ts +142 -0
  44. package/src/identity-core/site-auth.ts +36 -0
  45. package/src/identity-core/site-methods.ts +78 -0
  46. package/src/identity-core/words.ts +60 -17
  47. package/styles/iox-design.css +38 -0
@@ -13,11 +13,12 @@ var SignInPurpose;
13
13
  /** portal.iox.studio. */
14
14
  SignInPurpose["Portal"] = "portal";
15
15
  })(SignInPurpose || (SignInPurpose = {}));
16
- /** A provider the broker runs. Google is live; the rest join one adapter at a time (board 18). */
16
+ /** A provider the broker runs (board 18). The enum's order is the order every sign-in shows them in. Each id is the path
17
+ * segment of the ONE address registered with that provider: `https://auth.iox.studio/<id>/callback`. */
17
18
  var SignInProvider;
18
19
  (function (SignInProvider) {
19
20
  SignInProvider["Google"] = "google";
20
- SignInProvider["Meta"] = "meta";
21
+ SignInProvider["Facebook"] = "facebook";
21
22
  SignInProvider["GitHub"] = "github";
22
23
  SignInProvider["LinkedIn"] = "linkedin";
23
24
  })(SignInProvider || (SignInProvider = {}));
@@ -29,10 +30,12 @@ var SignInProtocol;
29
30
  })(SignInProtocol || (SignInProtocol = {}));
30
31
  const SIGN_IN_PROVIDER_SPECS = Object.freeze({
31
32
  [SignInProvider.Google]: { protocol: SignInProtocol.Oidc, signedAnswer: true, live: true },
32
- [SignInProvider.LinkedIn]: { protocol: SignInProtocol.Oidc, signedAnswer: true, live: false },
33
- [SignInProvider.Meta]: { protocol: SignInProtocol.OAuth2, signedAnswer: false, live: false },
34
- [SignInProvider.GitHub]: { protocol: SignInProtocol.OAuth2, signedAnswer: false, live: false },
33
+ [SignInProvider.Facebook]: { protocol: SignInProtocol.OAuth2, signedAnswer: false, live: true },
34
+ [SignInProvider.GitHub]: { protocol: SignInProtocol.OAuth2, signedAnswer: false, live: true },
35
+ [SignInProvider.LinkedIn]: { protocol: SignInProtocol.Oidc, signedAnswer: true, live: true },
35
36
  });
37
+ /** Every provider, in the order a sign-in shows them. */
38
+ const SIGN_IN_PROVIDERS = Object.freeze(Object.values(SignInProvider));
36
39
  function isSignInProvider(value) {
37
40
  return typeof value === 'string' && Object.values(SignInProvider).includes(value);
38
41
  }
@@ -58,7 +61,23 @@ var BrokerApiRoute;
58
61
  (function (BrokerApiRoute) {
59
62
  BrokerApiRoute["Tickets"] = "instances/me/sign-in/tickets";
60
63
  BrokerApiRoute["Redeem"] = "instances/me/sign-in/redeem";
64
+ /** `GET` → only the providers that are ON: `{ "google": true }` (`SignInProvidersAnswer`). */
65
+ BrokerApiRoute["Providers"] = "instances/me/sign-in/providers";
61
66
  })(BrokerApiRoute || (BrokerApiRoute = {}));
67
+ /** The providers ON in a broker's answer, in the order a sign-in shows them; anything else in the body is ignored. */
68
+ function providersOn(answer) {
69
+ if (!answer || typeof answer !== 'object' || Array.isArray(answer))
70
+ return [];
71
+ const on = answer;
72
+ return SIGN_IN_PROVIDERS.filter(p => on[p] === true);
73
+ }
74
+ /** The providers ON at the broker that may serve `purpose` (C-D6: a team member only with a signed answer). */
75
+ function providersServing(on, purpose) {
76
+ const set = new Set(on);
77
+ return SIGN_IN_PROVIDERS.filter(p => set.has(p) && SIGN_IN_PROVIDER_SPECS[p].live && providerServes(p, purpose));
78
+ }
79
+ /** How long a studio or the portal may keep the broker's providers answer before asking again. */
80
+ const SIGN_IN_PROVIDERS_CACHE_SECONDS = 60;
62
81
  /** The browser's routes on `auth.iox.studio`, one pair per provider. */
63
82
  var BrokerBrowserRoute;
64
83
  (function (BrokerBrowserRoute) {
@@ -97,6 +116,8 @@ var BrokerRefusalCode;
97
116
  BrokerRefusalCode["CodeUsedOrExpired"] = "code-used-or-expired";
98
117
  /** 403 — another tenant's code. */
99
118
  BrokerRefusalCode["NotYours"] = "not-yours";
119
+ /** 400 — a purpose this asker may not use, or a provider that may not serve it (C-D6). */
120
+ BrokerRefusalCode["InvalidRequest"] = "invalid-request";
100
121
  })(BrokerRefusalCode || (BrokerRefusalCode = {}));
101
122
  const BROKER_REFUSAL_STATUS = Object.freeze({
102
123
  [BrokerRefusalCode.ReturnHostRefused]: 403,
@@ -105,6 +126,7 @@ const BROKER_REFUSAL_STATUS = Object.freeze({
105
126
  [BrokerRefusalCode.CodeUnknown]: 404,
106
127
  [BrokerRefusalCode.CodeUsedOrExpired]: 410,
107
128
  [BrokerRefusalCode.NotYours]: 403,
129
+ [BrokerRefusalCode.InvalidRequest]: 400,
108
130
  });
109
131
  function isBrokerRefusalCode(value) {
110
132
  return typeof value === 'string' && Object.values(BrokerRefusalCode).includes(value);
@@ -114,6 +136,14 @@ function isBrokerRefusalCode(value) {
114
136
  const SIGN_IN_HANDOFF_PARAM = 'iox_signin';
115
137
  /** The failure's query parameter on the return address. */
116
138
  const SIGN_IN_ERROR_PARAM = 'iox_signin_error';
139
+ /** Beside a failure a studio sends back: the provider it was (`?iox_signin_via=github`), so the words can name it. */
140
+ const SIGN_IN_VIA_PARAM = 'iox_signin_via';
141
+ /**
142
+ * The binding parameter on every return address a studio or the portal asks the broker for: `iox_sb=<sha256 of the
143
+ * random value in the starting browser's httpOnly cookie>`. The redeemed `returnUrl` must carry THIS browser's hash — a
144
+ * hand-off started in another browser is refused (login CSRF).
145
+ */
146
+ const SIGN_IN_BINDING_PARAM = 'iox_sb';
117
147
  /** Why the browser came back without a person. */
118
148
  var SignInReturnError;
119
149
  (function (SignInReturnError) {
@@ -262,6 +292,8 @@ var SiteAuthRoute;
262
292
  /** `GET` → `{ customer }` (null when signed out). */
263
293
  SiteAuthRoute["Me"] = "me";
264
294
  SiteAuthRoute["MyOrders"] = "me/orders";
295
+ /** `GET` → `{ methods }` — the ways this site lets a buyer sign in right now (`siteSignInMethods`). Public. */
296
+ SiteAuthRoute["Methods"] = "auth/methods";
265
297
  })(SiteAuthRoute || (SiteAuthRoute = {}));
266
298
  /** Every route a site's sign-in calls, by name (the provider pair is per provider — `siteProviderPath`). */
267
299
  const SITE_AUTH_ROUTES = Object.freeze({ ...SiteAuthRoute });
@@ -325,6 +357,15 @@ function customerCookieName(orgId) {
325
357
  function signInStateCookieName(orgId) {
326
358
  return `${SIGN_IN_STATE_COOKIE_PREFIX}${orgId}`;
327
359
  }
360
+ /**
361
+ * A cookie no sibling host can plant (vectoriox/iox-cms#73 — cookie tossing from another `*.iox.studio`): over https the
362
+ * name takes the `__Host-` prefix, which a browser accepts only `Secure`, with `Path=/` and no `Domain`. A server that
363
+ * sets one with this name must set exactly those; plain http (local development) keeps the bare name.
364
+ */
365
+ const HOST_ONLY_COOKIE_PREFIX = '__Host-';
366
+ function hostOnlyCookieName(name, secure) {
367
+ return secure ? `${HOST_ONLY_COOKIE_PREFIX}${name}` : name;
368
+ }
328
369
  // ── the email code ─────────────────────────────────────────────────────────────────────────────
329
370
  const EMAIL_CODE_LENGTH = 6;
330
371
  const EMAIL_CODE_TTL_MINUTES = 10;
@@ -352,6 +393,60 @@ function emailCodeExpired(sentAt, now) {
352
393
  function emailCodeTriesLeft(wrongTries) {
353
394
  return Math.max(0, EMAIL_CODE_MAX_TRIES - Math.max(0, Math.floor(wrongTries || 0)));
354
395
  }
396
+ // ── the fixed account page (C-D3: fixed like checkout, the look's dress) ────────────────────────
397
+ const ACCOUNT_PATH = 'account';
398
+ /** The buyer's account page — their orders: `/<orgLabel>/account` (the engine answers it on every studio). */
399
+ function accountHref(orgLabel) {
400
+ const label = String(orgLabel ?? '').replace(/^\/+|\/+$/g, '');
401
+ return label ? `/${encodeURIComponent(label)}/${ACCOUNT_PATH}` : `/${ACCOUNT_PATH}`;
402
+ }
403
+ /** The account page's segment for one order: `/<orgLabel>/account/orders/<number>`. */
404
+ const ACCOUNT_ORDERS_SEGMENT = 'orders';
405
+ /** One of the signed-in buyer's own orders, under the account page — read by the session, never by a link token. */
406
+ function accountOrderHref(orgLabel, orderNumber) {
407
+ return `${accountHref(orgLabel)}/${ACCOUNT_ORDERS_SEGMENT}/${encodeURIComponent(String(orderNumber))}`;
408
+ }
409
+ /** `GET /api/site/<org>/me/orders/<number>` — one order of the signed-in buyer (404 for anyone else's). */
410
+ function siteMyOrderPath(orgId, orderNumber) {
411
+ return `${siteAuthPath(orgId, SiteAuthRoute.MyOrders)}/${encodeURIComponent(String(orderNumber))}`;
412
+ }
413
+
414
+ const SVG = (viewBox, body) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewBox}" aria-hidden="true" focusable="false">${body}</svg>`;
415
+ const GITHUB_PATH = 'M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z';
416
+ const SIGN_IN_PROVIDER_BRANDS = Object.freeze({
417
+ [SignInProvider.Google]: {
418
+ name: 'Google',
419
+ mark: SVG('0 0 48 48', '<path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"/>'
420
+ + '<path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"/>'
421
+ + '<path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"/>'
422
+ + '<path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"/>'),
423
+ },
424
+ [SignInProvider.Facebook]: {
425
+ name: 'Facebook',
426
+ mark: SVG('0 0 24 24', '<circle cx="12" cy="12" r="12" fill="#0866FF"/>'
427
+ + '<path fill="#FFFFFF" d="M16.671 15.469 17.203 12h-3.328V9.749c0-.949.465-1.874 1.956-1.874h1.513V4.922s-1.374-.234-2.686-.234c-2.741 0-4.533 1.66-4.533 4.668V12H7.078v3.469h3.047v8.385a12.09 12.09 0 0 0 3.75 0v-8.385h2.796Z"/>'),
428
+ },
429
+ [SignInProvider.GitHub]: {
430
+ name: 'GitHub',
431
+ mark: SVG('0 0 16 16', `<path fill="currentColor" d="${GITHUB_PATH}"/>`),
432
+ // Black or white only (GitHub's rule): the black mark on its own white disc reads on any button.
433
+ imageMark: SVG('0 0 16 16', `<circle cx="8" cy="8" r="7.5" fill="#FFFFFF"/><path fill="#1F2328" d="${GITHUB_PATH}"/>`),
434
+ },
435
+ [SignInProvider.LinkedIn]: {
436
+ name: 'LinkedIn',
437
+ mark: SVG('0 0 24 24', '<rect width="24" height="24" rx="3" fill="#0A66C2"/>'
438
+ + '<path fill="#FFFFFF" d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 1 1 0-4.125 2.062 2.062 0 0 1 0 4.125zm1.782 13.019H3.555V9h3.564v11.452z"/>'),
439
+ },
440
+ });
441
+ /** The provider's name as its brand writes it. */
442
+ function signInProviderName(provider) {
443
+ return (provider && SIGN_IN_PROVIDER_BRANDS[provider]?.name) || '';
444
+ }
445
+ /** The mark as a `data:` address — for an `<img>` (a builder Image part, an admin button). */
446
+ function signInProviderMarkUri(provider) {
447
+ const brand = SIGN_IN_PROVIDER_BRANDS[provider];
448
+ return `data:image/svg+xml,${encodeURIComponent(brand.imageMark ?? brand.mark)}`;
449
+ }
355
450
 
356
451
  var SignInLanguage;
357
452
  (function (SignInLanguage) {
@@ -370,7 +465,8 @@ var SignInWord;
370
465
  SignInWord["SignIn"] = "signIn";
371
466
  SignInWord["SignInTo"] = "signInTo";
372
467
  SignInWord["Why"] = "why";
373
- SignInWord["ContinueWithGoogle"] = "continueWithGoogle";
468
+ /** `{provider}` = the brand's own name (`signInProviderName`), never translated. */
469
+ SignInWord["ContinueWith"] = "continueWith";
374
470
  SignInWord["Or"] = "or";
375
471
  SignInWord["Email"] = "email";
376
472
  SignInWord["EmailPlaceholder"] = "emailPlaceholder";
@@ -390,13 +486,19 @@ var SignInWord;
390
486
  SignInWord["SignedIn"] = "signedIn";
391
487
  SignInWord["SignedOut"] = "signedOut";
392
488
  SignInWord["NoPassword"] = "noPassword";
489
+ /** Before the checkout's "Sign in". */
490
+ SignInWord["HaveAccount"] = "haveAccount";
491
+ /** The account page with no orders. */
492
+ SignInWord["NoOrders"] = "noOrders";
493
+ /** An order row on the account page: `{date}`. */
494
+ SignInWord["PlacedOn"] = "placedOn";
393
495
  })(SignInWord || (SignInWord = {}));
394
496
  /** `{site}`, `{email}`, `{name}`, `{minutes}` are filled by `signInWord`. */
395
497
  const SIGN_IN_WORDS = Object.freeze({
396
498
  [SignInWord.SignIn]: { en: 'Sign in', he: 'התחברות' },
397
499
  [SignInWord.SignInTo]: { en: 'Sign in to {site}', he: 'התחברות ל־{site}' },
398
500
  [SignInWord.Why]: { en: 'See your orders and check out faster.', he: 'לראות את ההזמנות שלך ולשלם מהר יותר.' },
399
- [SignInWord.ContinueWithGoogle]: { en: 'Continue with Google', he: 'המשך עם Google' },
501
+ [SignInWord.ContinueWith]: { en: 'Continue with {provider}', he: 'המשך עם {provider}' },
400
502
  [SignInWord.Or]: { en: 'or', he: 'או' },
401
503
  [SignInWord.Email]: { en: 'Email', he: 'אימייל' },
402
504
  [SignInWord.EmailPlaceholder]: { en: 'name@example.com', he: 'name@example.com' },
@@ -416,6 +518,9 @@ const SIGN_IN_WORDS = Object.freeze({
416
518
  [SignInWord.SignedIn]: { en: 'You are signed in.', he: 'התחברת.' },
417
519
  [SignInWord.SignedOut]: { en: 'You are signed out.', he: 'התנתקת.' },
418
520
  [SignInWord.NoPassword]: { en: 'No password — we email you a code.', he: 'בלי סיסמה — נשלח לך קוד במייל.' },
521
+ [SignInWord.HaveAccount]: { en: 'Have an account?', he: 'יש לך חשבון?' },
522
+ [SignInWord.NoOrders]: { en: 'No orders yet.', he: 'עדיין אין הזמנות.' },
523
+ [SignInWord.PlacedOn]: { en: 'Placed {date}', he: 'בוצעה ב־{date}' },
419
524
  });
420
525
  function signInWord(word, lang, fill = {}) {
421
526
  return fillIn(SIGN_IN_WORDS[word][signInLanguage(lang)], fill);
@@ -426,7 +531,7 @@ var SignInSlot;
426
531
  (function (SignInSlot) {
427
532
  SignInSlot["Email"] = "email";
428
533
  SignInSlot["Code"] = "code";
429
- /** Under "Continue with Google". */
534
+ /** Under the provider buttons ("Continue with Google"). */
430
535
  SignInSlot["Provider"] = "provider";
431
536
  /** The dialog as a whole. */
432
537
  SignInSlot["Dialog"] = "dialog";
@@ -452,9 +557,12 @@ var SiteSignInRefusalCode;
452
557
  SiteSignInRefusalCode["StateMismatch"] = "state-mismatch";
453
558
  SiteSignInRefusalCode["Blocked"] = "blocked";
454
559
  SiteSignInRefusalCode["NotSignedIn"] = "not-signed-in";
560
+ /** The studio has no working mailer, so it cannot send a code (it never says whether the email is known). */
561
+ SiteSignInRefusalCode["EmailUnavailable"] = "email-unavailable";
455
562
  SiteSignInRefusalCode["Network"] = "network";
456
563
  })(SiteSignInRefusalCode || (SiteSignInRefusalCode = {}));
457
- const TRY_GOOGLE_AGAIN = { en: 'Google sign-in did not work. Try again, or use an email code.', he: 'ההתחברות עם Google לא הצליחה. נסו שוב, או התחברו עם קוד במייל.' };
564
+ /** `{provider}` is the brand's name (`signInRefusal`'s `provider`), else a neutral word. */
565
+ const TRY_PROVIDER_AGAIN = { en: 'Signing in with {provider} did not work. Try again, or use an email code.', he: 'ההתחברות עם {provider} לא הצליחה. נסו שוב, או התחברו עם קוד במייל.' };
458
566
  const SEND_NEW_CODE = { en: 'This code has expired. Send a new one.', he: 'תוקף הקוד פג. שלחו קוד חדש.' };
459
567
  const SIGN_IN_REFUSALS = Object.freeze({
460
568
  [SiteSignInRefusalCode.InvalidEmail]: { slot: SignInSlot.Email, label: { en: 'Enter an email address, like name@example.com.', he: 'הקלידו כתובת אימייל, למשל name@example.com.' } },
@@ -462,14 +570,15 @@ const SIGN_IN_REFUSALS = Object.freeze({
462
570
  [SiteSignInRefusalCode.CodeExpired]: { slot: SignInSlot.Code, label: SEND_NEW_CODE },
463
571
  [SiteSignInRefusalCode.TooManyTries]: { slot: SignInSlot.Code, label: { en: 'Too many wrong codes. Send a new one.', he: 'יותר מדי קודים שגויים. שלחו קוד חדש.' } },
464
572
  [SiteSignInRefusalCode.RateLimited]: { slot: SignInSlot.Dialog, label: { en: 'Too many tries. Wait a minute and try again.', he: 'יותר מדי ניסיונות. המתינו דקה ונסו שוב.' } },
465
- [SiteSignInRefusalCode.ProviderUnavailable]: { slot: SignInSlot.Provider, label: { en: 'Google sign-in is not available right now. Use an email code.', he: 'ההתחברות עם Google לא זמינה כרגע. התחברו עם קוד במייל.' } },
466
- [SiteSignInRefusalCode.Cancelled]: { slot: SignInSlot.Provider, label: { en: 'Google sign-in was cancelled.', he: 'ההתחברות עם Google בוטלה.' } },
467
- [SiteSignInRefusalCode.Refused]: { slot: SignInSlot.Provider, label: { en: 'Google could not confirm this account. Use an email code.', he: 'Google לא אישר את החשבון הזה. התחברו עם קוד במייל.' } },
573
+ [SiteSignInRefusalCode.ProviderUnavailable]: { slot: SignInSlot.Provider, label: { en: 'Signing in with {provider} is not available right now. Use an email code.', he: 'ההתחברות עם {provider} לא זמינה כרגע. התחברו עם קוד במייל.' } },
574
+ [SiteSignInRefusalCode.Cancelled]: { slot: SignInSlot.Provider, label: { en: 'Signing in with {provider} was cancelled.', he: 'ההתחברות עם {provider} בוטלה.' } },
575
+ [SiteSignInRefusalCode.Refused]: { slot: SignInSlot.Provider, label: { en: '{provider} could not confirm this account. Use an email code.', he: '{provider} לא אישר את החשבון הזה. התחברו עם קוד במייל.' } },
468
576
  [SiteSignInRefusalCode.Expired]: { slot: SignInSlot.Provider, label: { en: 'The sign-in took too long. Try again.', he: 'ההתחברות ארכה יותר מדי. נסו שוב.' } },
469
- [SiteSignInRefusalCode.Failed]: { slot: SignInSlot.Provider, label: TRY_GOOGLE_AGAIN },
470
- [SiteSignInRefusalCode.StateMismatch]: { slot: SignInSlot.Provider, label: TRY_GOOGLE_AGAIN },
577
+ [SiteSignInRefusalCode.Failed]: { slot: SignInSlot.Provider, label: TRY_PROVIDER_AGAIN },
578
+ [SiteSignInRefusalCode.StateMismatch]: { slot: SignInSlot.Provider, label: TRY_PROVIDER_AGAIN },
471
579
  [SiteSignInRefusalCode.Blocked]: { slot: SignInSlot.Dialog, label: { en: 'This account cannot sign in here. Contact the business.', he: 'החשבון הזה לא יכול להתחבר כאן. פנו לעסק.' } },
472
580
  [SiteSignInRefusalCode.NotSignedIn]: { slot: SignInSlot.Dialog, label: { en: 'You are signed out. Sign in again.', he: 'התנתקת. התחברו שוב.' } },
581
+ [SiteSignInRefusalCode.EmailUnavailable]: { slot: SignInSlot.Email, label: { en: 'This site cannot send sign-in codes right now. Try again later.', he: 'האתר לא יכול לשלוח קודי התחברות כרגע. נסו שוב מאוחר יותר.' } },
473
582
  [SiteSignInRefusalCode.Network]: { slot: SignInSlot.Dialog, label: { en: 'We could not reach the site. Try again.', he: 'לא הצלחנו להגיע לאתר. נסו שוב.' } },
474
583
  });
475
584
  function isSiteSignInRefusalCode(code) {
@@ -483,6 +592,7 @@ const FROM_BROKER = Object.freeze({
483
592
  [BrokerRefusalCode.CodeUnknown]: SiteSignInRefusalCode.Expired,
484
593
  [BrokerRefusalCode.CodeUsedOrExpired]: SiteSignInRefusalCode.Expired,
485
594
  [BrokerRefusalCode.NotYours]: SiteSignInRefusalCode.Failed,
595
+ [BrokerRefusalCode.InvalidRequest]: SiteSignInRefusalCode.ProviderUnavailable,
486
596
  });
487
597
  const FROM_RETURN = Object.freeze({
488
598
  [SignInReturnError.Cancelled]: SiteSignInRefusalCode.Cancelled,
@@ -500,21 +610,189 @@ function siteSignInCodeOf(code) {
500
610
  return FROM_RETURN[code];
501
611
  return SiteSignInRefusalCode.Failed;
502
612
  }
503
- /** One refusal, on its slot, in the visitor's words. */
504
- function signInRefusal(code, lang) {
613
+ /** A provider refusal names no brand when the provider is not known. */
614
+ const ANY_PROVIDER = { en: 'this account', he: 'החשבון' };
615
+ const NO_PROVIDER_LABEL = {
616
+ [SiteSignInRefusalCode.Refused]: { en: 'The provider could not confirm this account. Use an email code.', he: 'הספק לא אישר את החשבון הזה. התחברו עם קוד במייל.' },
617
+ };
618
+ /** One refusal, on its slot, in the visitor's words; a provider's refusal names it (`provider`). */
619
+ function signInRefusal(code, lang, provider) {
505
620
  const known = siteSignInCodeOf(code);
506
621
  const rule = SIGN_IN_REFUSALS[known];
507
- return { code: known, slot: rule.slot, words: rule.label[signInLanguage(lang)] };
622
+ const language = signInLanguage(lang);
623
+ const name = signInProviderName(provider);
624
+ const label = !name && NO_PROVIDER_LABEL[known] ? NO_PROVIDER_LABEL[known] : rule.label;
625
+ return { code: known, slot: rule.slot, words: fillIn(label[language], { provider: name || ANY_PROVIDER[language] }) };
508
626
  }
509
627
  /** A refused call's body (`{ code }`) — or nothing at all (`network`) — as one refusal. The body's `message` is a log
510
628
  * line and is never shown. A 429 with no code is `rate-limited`. */
511
- function signInRefusalOf(body, lang, status) {
629
+ function signInRefusalOf(body, lang, status, provider) {
512
630
  const code = body && typeof body === 'object' ? body.code : undefined;
513
631
  if (code !== undefined)
514
- return signInRefusal(code, lang);
632
+ return signInRefusal(code, lang, provider);
515
633
  if (status === 429)
516
- return signInRefusal(SiteSignInRefusalCode.RateLimited, lang);
517
- return signInRefusal(body === undefined || body === null ? SiteSignInRefusalCode.Network : SiteSignInRefusalCode.Failed, lang);
634
+ return signInRefusal(SiteSignInRefusalCode.RateLimited, lang, provider);
635
+ return signInRefusal(body === undefined || body === null ? SiteSignInRefusalCode.Network : SiteSignInRefusalCode.Failed, lang, provider);
636
+ }
637
+ function siteSignInReturnRefusal(search) {
638
+ const params = typeof search === 'string' ? new URLSearchParams(search.startsWith('?') ? search.slice(1) : search) : search;
639
+ if (!params)
640
+ return null;
641
+ const raw = params.get(SIGN_IN_ERROR_PARAM);
642
+ if (raw === null)
643
+ return null;
644
+ const via = params.get(SIGN_IN_VIA_PARAM);
645
+ const code = isSiteSignInRefusalCode(raw) ? raw : siteSignInCodeOf(readSignInReturn(params)?.error);
646
+ return { code, provider: isSignInProvider(via) ? via : null };
647
+ }
648
+
649
+ /**
650
+ * Which ways a studio's SITE lets a buyer sign in (Settings ▸ Sign-in, board 18): the email code always, and each
651
+ * provider the owner switched on — while the broker has it ON and it may serve a buyer (C-D6). ONE rule for the studio
652
+ * that enforces it (iox-cms), the site that shows it (the engine, the canvas) and the screen that sets it (cms-client).
653
+ */
654
+ /** The email code — a `customerIdentities.provider` value beside the broker's providers; it never touches the broker. */
655
+ const EMAIL_CODE_PROVIDER = 'email-code';
656
+ /** Every method, in the order a sign-in shows them. */
657
+ const SITE_SIGN_IN_METHODS = Object.freeze([EMAIL_CODE_PROVIDER, ...SIGN_IN_PROVIDERS]);
658
+ function isSiteSignInMethod(value) {
659
+ return typeof value === 'string' && SITE_SIGN_IN_METHODS.includes(value);
660
+ }
661
+ /** The settings type a studio's org stores its choice under (`settings` collection, one row per org). */
662
+ const SITE_SIGN_IN_SETTINGS_TYPE = 'signIn';
663
+ /** A studio that never chose: Google on (C-D6 — "Google on by default, the others as owner switches"). */
664
+ const DEFAULT_SITE_SIGN_IN_SETTINGS = Object.freeze({
665
+ providers: Object.freeze({
666
+ [SignInProvider.Google]: true,
667
+ [SignInProvider.Facebook]: false,
668
+ [SignInProvider.GitHub]: false,
669
+ [SignInProvider.LinkedIn]: false,
670
+ }),
671
+ });
672
+ /** Any stored or posted value as a whole setting: every provider present, booleans only, unknown keys dropped. */
673
+ function normalizeSiteSignInSettings(raw) {
674
+ const given = raw && typeof raw === 'object' ? raw.providers : undefined;
675
+ const map = given && typeof given === 'object' && !Array.isArray(given) ? given : {};
676
+ const providers = {};
677
+ for (const p of SIGN_IN_PROVIDERS)
678
+ providers[p] = typeof map[p] === 'boolean' ? map[p] : DEFAULT_SITE_SIGN_IN_SETTINGS.providers[p];
679
+ return { providers };
680
+ }
681
+ /** The methods a site offers right now: the email code, then every provider the owner switched on that the broker has
682
+ * ON (`brokerOn`) and that may serve a buyer. */
683
+ function siteSignInMethods(settings, brokerOn) {
684
+ const chosen = normalizeSiteSignInSettings(settings).providers;
685
+ return [EMAIL_CODE_PROVIDER, ...providersServing(brokerOn, SignInPurpose.Site).filter(p => chosen[p])];
686
+ }
687
+ /** May a buyer start `provider` on this site right now? */
688
+ function siteOffersProvider(settings, brokerOn, provider) {
689
+ return siteSignInMethods(settings, brokerOn).includes(provider);
690
+ }
691
+ /** The methods in an answer (unknown values dropped, in the shown order); the email code is always one of them. */
692
+ function siteSignInMethodsOf(answer) {
693
+ const listed = answer && typeof answer === 'object' ? answer.methods : undefined;
694
+ const set = new Set(Array.isArray(listed) ? listed.filter(isSiteSignInMethod) : []);
695
+ set.add(EMAIL_CODE_PROVIDER);
696
+ return SITE_SIGN_IN_METHODS.filter(m => set.has(m));
697
+ }
698
+ /** The providers among a site's methods. */
699
+ function siteSignInProviders(methods) {
700
+ return SIGN_IN_PROVIDERS.filter(p => methods.includes(p));
701
+ }
702
+
703
+ /** A refused transport call, carrying the code the visitor's words come from (`signInRefusal`). */
704
+ class SiteAuthError extends Error {
705
+ constructor(code) {
706
+ const known = siteSignInCodeOf(code);
707
+ super(known);
708
+ this.name = 'SiteAuthError';
709
+ this.code = known;
710
+ }
711
+ }
712
+ /** The code any thrown value carries: a `SiteAuthError`'s own, else `network` (the call never answered). */
713
+ function siteAuthErrorCode(error) {
714
+ return error instanceof SiteAuthError ? error.code : SiteSignInRefusalCode.Network;
715
+ }
716
+ /** The sample buyer the canvas signs in as. */
717
+ const SAMPLE_CUSTOMER = Object.freeze({ id: 'sample-customer', email: 'noa.levi@example.com', name: 'Noa Levi' });
718
+ /** The one code the simulated transport accepts (any other six digits are "not right" — so the error can be designed). */
719
+ const SIMULATED_SIGN_IN_CODE = '123456';
720
+ /**
721
+ * The canvas' transport: in memory, nothing sent. A code is "sent" to any well-formed email; `123456` signs in as the
722
+ * sample buyer under the typed email, any other six digits are `code-wrong`; a provider's start answers the broker's
723
+ * address with a sample ticket (the canvas host never follows it).
724
+ */
725
+ function simulatedSiteAuthTransport(start = null, methods = SITE_SIGN_IN_METHODS) {
726
+ let customer = start;
727
+ const sentTo = new Set();
728
+ return {
729
+ get customer() {
730
+ return customer;
731
+ },
732
+ setCustomer(next) {
733
+ customer = next;
734
+ },
735
+ async me() {
736
+ return customer;
737
+ },
738
+ async startProvider(provider, returnPath) {
739
+ if (!isSameOriginPath(returnPath))
740
+ throw new SiteAuthError(SiteSignInRefusalCode.Failed);
741
+ return { startUrl: brokerStartUrl(provider, 'sample-ticket') };
742
+ },
743
+ async sendCode(email) {
744
+ const key = normalizeSignInEmail(email);
745
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(key))
746
+ throw new SiteAuthError(SiteSignInRefusalCode.InvalidEmail);
747
+ sentTo.add(key);
748
+ },
749
+ async verifyCode(email, code) {
750
+ const key = normalizeSignInEmail(email);
751
+ const digits = normalizeEmailCode(code);
752
+ if (!sentTo.has(key) || !isEmailCodeShape(digits))
753
+ throw new SiteAuthError(SiteSignInRefusalCode.CodeWrong);
754
+ if (digits !== SIMULATED_SIGN_IN_CODE)
755
+ throw new SiteAuthError(SiteSignInRefusalCode.CodeWrong);
756
+ customer = { ...SAMPLE_CUSTOMER, email: key };
757
+ return customer;
758
+ },
759
+ async signOut() {
760
+ customer = null;
761
+ },
762
+ async methods() {
763
+ return [EMAIL_CODE_PROVIDER, ...SIGN_IN_PROVIDERS.filter(p => methods.includes(p))];
764
+ },
765
+ };
766
+ }
767
+ /** A transport that has nothing to reach: `me` is null, every change refused as `network`. */
768
+ const NO_SITE_AUTH_TRANSPORT = Object.freeze({
769
+ me: async () => null,
770
+ startProvider: async () => { throw new SiteAuthError(SiteSignInRefusalCode.ProviderUnavailable); },
771
+ sendCode: async () => { throw new SiteAuthError(SiteSignInRefusalCode.Network); },
772
+ verifyCode: async () => { throw new SiteAuthError(SiteSignInRefusalCode.Network); },
773
+ signOut: async () => undefined,
774
+ methods: async () => [EMAIL_CODE_PROVIDER],
775
+ });
776
+ // ── what a page shows of the buyer ───────────────────────────────────────────────────────────
777
+ /** The context slot the account parts bind to (`$customer.initial`, `$customer.name`). */
778
+ const CUSTOMER_SLOT = '$customer';
779
+ /** The first visible letter of a name or an email, upper-cased where the script has case. */
780
+ function customerInitial(customer) {
781
+ const source = (customer?.name ?? '').trim() || (customer?.email ?? '').trim();
782
+ const first = Array.from(source)[0] ?? '';
783
+ return first.toLocaleUpperCase();
784
+ }
785
+ /** The name a page greets with: the buyer's own, else the email's local part. */
786
+ function customerDisplayName(customer) {
787
+ const name = (customer?.name ?? '').trim();
788
+ if (name)
789
+ return name;
790
+ return (customer?.email ?? '').split('@')[0] ?? '';
791
+ }
792
+ function customerSlotOf(customer) {
793
+ if (!customer)
794
+ return { signedIn: false, name: '', initial: '', email: '' };
795
+ return { signedIn: true, name: customerDisplayName(customer), initial: customerInitial(customer), email: customer.email };
518
796
  }
519
797
 
520
798
  /**
@@ -531,5 +809,5 @@ function signInRefusalOf(body, lang, status) {
531
809
  * Generated bundle index. Do not edit.
532
810
  */
533
811
 
534
- export { BROKER_HOST, BROKER_ORIGIN, BROKER_REFUSAL_STATUS, BROKER_TICKET_PARAM, BrokerApiRoute, BrokerBrowserRoute, BrokerRefusalCode, CUSTOMER_COOKIE_PREFIX, EMAIL_CODE_LENGTH, EMAIL_CODE_MAX_TRIES, EMAIL_CODE_TTL_MINUTES, EMAIL_CODE_TTL_MS, NEXT_PATH_MAX_LENGTH, SIGN_IN_ERROR_PARAM, SIGN_IN_HANDOFF_PARAM, SIGN_IN_HANDOFF_TTL_SECONDS, SIGN_IN_NEXT_PARAM, SIGN_IN_PROVIDER_SPECS, SIGN_IN_REFUSALS, SIGN_IN_STATE_COOKIE_PREFIX, SIGN_IN_STATE_MAX_AGE_SECONDS, SIGN_IN_TICKET_TTL_SECONDS, SIGN_IN_WORDS, SITE_AUDIENCE, SITE_AUTH_ROUTES, SITE_COOKIE_PATH, SignInLanguage, SignInProtocol, SignInProvider, SignInPurpose, SignInReturnError, SignInSlot, SignInWord, SiteAuthRoute, SiteProviderRoute, SiteSignInRefusalCode, brokerApiPath, brokerBrowserUrl, brokerCallbackUrl, brokerStartUrl, customerCookieName, emailCodeExpired, emailCodeTriesLeft, hasSiteAudience, isAllowedReturnHost, isBrokerRefusalCode, isEmailCodeShape, isLoopbackHost, isSameOriginPath, isSignInProvider, isSignInPurpose, isSignInReturnError, isSiteSessionClaims, isSiteSignInRefusalCode, normalizeEmailCode, normalizeHost, normalizeSignInEmail, providerServes, readSignInReturn, safeNextPath, signInLanguage, signInRefusal, signInRefusalOf, signInStateCookieName, signInWord, siteAuthPath, siteProviderPath, siteProviderReturnUrl, siteSignInCodeOf, withSignInError, withSignInHandoff };
812
+ export { ACCOUNT_ORDERS_SEGMENT, ACCOUNT_PATH, BROKER_HOST, BROKER_ORIGIN, BROKER_REFUSAL_STATUS, BROKER_TICKET_PARAM, BrokerApiRoute, BrokerBrowserRoute, BrokerRefusalCode, CUSTOMER_COOKIE_PREFIX, CUSTOMER_SLOT, DEFAULT_SITE_SIGN_IN_SETTINGS, EMAIL_CODE_LENGTH, EMAIL_CODE_MAX_TRIES, EMAIL_CODE_PROVIDER, EMAIL_CODE_TTL_MINUTES, EMAIL_CODE_TTL_MS, HOST_ONLY_COOKIE_PREFIX, NEXT_PATH_MAX_LENGTH, NO_SITE_AUTH_TRANSPORT, SAMPLE_CUSTOMER, SIGN_IN_BINDING_PARAM, SIGN_IN_ERROR_PARAM, SIGN_IN_HANDOFF_PARAM, SIGN_IN_HANDOFF_TTL_SECONDS, SIGN_IN_NEXT_PARAM, SIGN_IN_PROVIDERS, SIGN_IN_PROVIDERS_CACHE_SECONDS, SIGN_IN_PROVIDER_BRANDS, SIGN_IN_PROVIDER_SPECS, SIGN_IN_REFUSALS, SIGN_IN_STATE_COOKIE_PREFIX, SIGN_IN_STATE_MAX_AGE_SECONDS, SIGN_IN_TICKET_TTL_SECONDS, SIGN_IN_VIA_PARAM, SIGN_IN_WORDS, SIMULATED_SIGN_IN_CODE, SITE_AUDIENCE, SITE_AUTH_ROUTES, SITE_COOKIE_PATH, SITE_SIGN_IN_METHODS, SITE_SIGN_IN_SETTINGS_TYPE, SignInLanguage, SignInProtocol, SignInProvider, SignInPurpose, SignInReturnError, SignInSlot, SignInWord, SiteAuthError, SiteAuthRoute, SiteProviderRoute, SiteSignInRefusalCode, accountHref, accountOrderHref, brokerApiPath, brokerBrowserUrl, brokerCallbackUrl, brokerStartUrl, customerCookieName, customerDisplayName, customerInitial, customerSlotOf, emailCodeExpired, emailCodeTriesLeft, hasSiteAudience, hostOnlyCookieName, isAllowedReturnHost, isBrokerRefusalCode, isEmailCodeShape, isLoopbackHost, isSameOriginPath, isSignInProvider, isSignInPurpose, isSignInReturnError, isSiteSessionClaims, isSiteSignInMethod, isSiteSignInRefusalCode, normalizeEmailCode, normalizeHost, normalizeSignInEmail, normalizeSiteSignInSettings, providerServes, providersOn, providersServing, readSignInReturn, safeNextPath, signInLanguage, signInProviderMarkUri, signInProviderName, signInRefusal, signInRefusalOf, signInStateCookieName, signInWord, simulatedSiteAuthTransport, siteAuthErrorCode, siteAuthPath, siteMyOrderPath, siteOffersProvider, siteProviderPath, siteProviderReturnUrl, siteSignInCodeOf, siteSignInMethods, siteSignInMethodsOf, siteSignInProviders, siteSignInReturnRefusal, withSignInError, withSignInHandoff };
535
813
  //# sourceMappingURL=vectoriox-iox-ui-identity-core.mjs.map