@vectoriox/iox-ui 5.98.0 → 5.100.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 (43) hide show
  1. package/actions-core/index.d.ts +7 -4
  2. package/composite-core/index.d.ts +222 -2
  3. package/design-core/index.d.ts +334 -1
  4. package/fesm2022/vectoriox-iox-ui-actions-core.mjs +16 -7
  5. package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
  6. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +948 -256
  7. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  8. package/fesm2022/vectoriox-iox-ui-design-core.mjs +416 -1
  9. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  10. package/fesm2022/vectoriox-iox-ui-forms-core.mjs +3 -24
  11. package/fesm2022/vectoriox-iox-ui-forms-core.mjs.map +1 -1
  12. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +23 -13
  13. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  14. package/fesm2022/vectoriox-iox-ui-identity-core.mjs +633 -0
  15. package/fesm2022/vectoriox-iox-ui-identity-core.mjs.map +1 -0
  16. package/fesm2022/vectoriox-iox-ui.mjs +2 -59
  17. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  18. package/forms-core/index.d.ts +2 -23
  19. package/generation-core/index.d.ts +3 -1
  20. package/identity-core/index.d.ts +426 -0
  21. package/identity-core/package.json +3 -0
  22. package/index.d.ts +0 -1
  23. package/package.json +5 -1
  24. package/src/actions-core/action.model.ts +1 -1
  25. package/src/actions-core/element-actions.ts +16 -6
  26. package/src/composite-core/account-runtime.ts +428 -0
  27. package/src/composite-core/account.ts +281 -0
  28. package/src/composite-core/public-api.ts +2 -0
  29. package/src/composite-core/recipe-parts.ts +48 -0
  30. package/src/composite-core/shop.ts +6 -26
  31. package/src/design-core/field-classes.ts +65 -0
  32. package/src/design-core/flavor-spec.generated.ts +346 -0
  33. package/src/design-core/public-api.ts +1 -0
  34. package/src/forms-core/field-markup.ts +2 -22
  35. package/src/generation-core/compose-site.ts +19 -9
  36. package/src/generation-core/nav-shape.ts +4 -4
  37. package/src/identity-core/guards.ts +87 -0
  38. package/src/identity-core/public-api.ts +14 -0
  39. package/src/identity-core/sign-in.ts +223 -0
  40. package/src/identity-core/site-auth-transport.ts +134 -0
  41. package/src/identity-core/site-auth.ts +182 -0
  42. package/src/identity-core/words.ts +194 -0
  43. package/styles/iox-design.css +38 -0
@@ -1577,6 +1577,36 @@ export const SPEC_TIERS = {
1577
1577
  "name": "cart-note-bg",
1578
1578
  "type": "color",
1579
1579
  "default": "var(--iox-surface-2)"
1580
+ },
1581
+ {
1582
+ "name": "account-button-pad",
1583
+ "type": "spacing",
1584
+ "default": "3px 12px"
1585
+ },
1586
+ {
1587
+ "name": "account-button-gap",
1588
+ "type": "spacing",
1589
+ "default": "8px"
1590
+ },
1591
+ {
1592
+ "name": "account-avatar-size",
1593
+ "type": "size",
1594
+ "default": "26px"
1595
+ },
1596
+ {
1597
+ "name": "account-avatar-bg",
1598
+ "type": "color",
1599
+ "default": "var(--iox-accent)"
1600
+ },
1601
+ {
1602
+ "name": "account-avatar-ink",
1603
+ "type": "color",
1604
+ "default": "var(--iox-accent-ink)"
1605
+ },
1606
+ {
1607
+ "name": "sign-in-error-ink",
1608
+ "type": "color",
1609
+ "default": "var(--iox-danger)"
1580
1610
  }
1581
1611
  ]
1582
1612
  } as const;
@@ -4742,6 +4772,70 @@ export const SPEC_ELEMENT_STYLES = [
4742
4772
  "fontSize": "var(--iox-size-small)"
4743
4773
  }
4744
4774
  },
4775
+ {
4776
+ "id": "account-button",
4777
+ "label": "Account button",
4778
+ "group": "Buttons",
4779
+ "appliesTo": [
4780
+ "ButtonBlock"
4781
+ ],
4782
+ "base": {
4783
+ "color": "var(--iox-text)",
4784
+ "backgroundColor": "transparent",
4785
+ "minHeight": "var(--iox-cart-button-size)",
4786
+ "padding": "var(--iox-account-button-pad)",
4787
+ "gap": "var(--iox-account-button-gap)",
4788
+ "borderStyle": "solid",
4789
+ "borderWidth": "var(--iox-border-width)",
4790
+ "borderColor": "var(--iox-line-strong)",
4791
+ "borderRadius": "var(--iox-radius-pill)",
4792
+ "fontFamily": "var(--iox-font-label)",
4793
+ "fontSize": "var(--iox-size-small)",
4794
+ "transitionDuration": "var(--iox-dur-hover)",
4795
+ "transitionTimingFunction": "var(--iox-ease-hover)"
4796
+ },
4797
+ "hover": {
4798
+ "backgroundColor": "var(--iox-surface-2)"
4799
+ },
4800
+ "active": {
4801
+ "scaleX": "var(--iox-press-scale)",
4802
+ "scaleY": "var(--iox-press-scale)"
4803
+ },
4804
+ "focus": {
4805
+ "boxShadow": "var(--iox-focus-ring)"
4806
+ }
4807
+ },
4808
+ {
4809
+ "id": "account-avatar",
4810
+ "label": "Account initial",
4811
+ "group": "Content blocks",
4812
+ "appliesTo": [
4813
+ "Container"
4814
+ ],
4815
+ "base": {
4816
+ "backgroundColor": "var(--iox-account-avatar-bg)",
4817
+ "color": "var(--iox-account-avatar-ink)",
4818
+ "borderRadius": "var(--iox-radius-pill)",
4819
+ "minWidth": "var(--iox-account-avatar-size)",
4820
+ "minHeight": "var(--iox-account-avatar-size)",
4821
+ "fontFamily": "var(--iox-font-label)",
4822
+ "fontSize": "var(--iox-size-label)",
4823
+ "fontWeight": "var(--iox-weight-strong)"
4824
+ }
4825
+ },
4826
+ {
4827
+ "id": "sign-in-error",
4828
+ "label": "Sign-in error",
4829
+ "group": "Text",
4830
+ "appliesTo": [
4831
+ "Text"
4832
+ ],
4833
+ "base": {
4834
+ "color": "var(--iox-sign-in-error-ink)",
4835
+ "fontFamily": "var(--iox-font-body)",
4836
+ "fontSize": "var(--iox-size-small)"
4837
+ }
4838
+ },
4745
4839
  {
4746
4840
  "id": "notice-success",
4747
4841
  "label": "Success message",
@@ -7726,6 +7820,48 @@ export const SPEC_FLAVOR_PACKS = [
7726
7820
  "type": "color",
7727
7821
  "group": "components",
7728
7822
  "value": "var(--iox-surface-2)"
7823
+ },
7824
+ {
7825
+ "name": "account-button-pad",
7826
+ "tier": "component",
7827
+ "type": "spacing",
7828
+ "group": "components",
7829
+ "value": "3px 12px"
7830
+ },
7831
+ {
7832
+ "name": "account-button-gap",
7833
+ "tier": "component",
7834
+ "type": "spacing",
7835
+ "group": "components",
7836
+ "value": "8px"
7837
+ },
7838
+ {
7839
+ "name": "account-avatar-size",
7840
+ "tier": "component",
7841
+ "type": "size",
7842
+ "group": "components",
7843
+ "value": "26px"
7844
+ },
7845
+ {
7846
+ "name": "account-avatar-bg",
7847
+ "tier": "component",
7848
+ "type": "color",
7849
+ "group": "components",
7850
+ "value": "var(--iox-accent)"
7851
+ },
7852
+ {
7853
+ "name": "account-avatar-ink",
7854
+ "tier": "component",
7855
+ "type": "color",
7856
+ "group": "components",
7857
+ "value": "var(--iox-accent-ink)"
7858
+ },
7859
+ {
7860
+ "name": "sign-in-error-ink",
7861
+ "tier": "component",
7862
+ "type": "color",
7863
+ "group": "components",
7864
+ "value": "var(--iox-danger)"
7729
7865
  }
7730
7866
  ]
7731
7867
  },
@@ -10016,6 +10152,48 @@ export const SPEC_FLAVOR_PACKS = [
10016
10152
  "type": "color",
10017
10153
  "group": "components",
10018
10154
  "value": "var(--iox-surface-2)"
10155
+ },
10156
+ {
10157
+ "name": "account-button-pad",
10158
+ "tier": "component",
10159
+ "type": "spacing",
10160
+ "group": "components",
10161
+ "value": "3px 12px"
10162
+ },
10163
+ {
10164
+ "name": "account-button-gap",
10165
+ "tier": "component",
10166
+ "type": "spacing",
10167
+ "group": "components",
10168
+ "value": "8px"
10169
+ },
10170
+ {
10171
+ "name": "account-avatar-size",
10172
+ "tier": "component",
10173
+ "type": "size",
10174
+ "group": "components",
10175
+ "value": "26px"
10176
+ },
10177
+ {
10178
+ "name": "account-avatar-bg",
10179
+ "tier": "component",
10180
+ "type": "color",
10181
+ "group": "components",
10182
+ "value": "var(--iox-accent)"
10183
+ },
10184
+ {
10185
+ "name": "account-avatar-ink",
10186
+ "tier": "component",
10187
+ "type": "color",
10188
+ "group": "components",
10189
+ "value": "var(--iox-accent-ink)"
10190
+ },
10191
+ {
10192
+ "name": "sign-in-error-ink",
10193
+ "tier": "component",
10194
+ "type": "color",
10195
+ "group": "components",
10196
+ "value": "var(--iox-danger)"
10019
10197
  }
10020
10198
  ]
10021
10199
  },
@@ -12294,6 +12472,48 @@ export const SPEC_FLAVOR_PACKS = [
12294
12472
  "type": "color",
12295
12473
  "group": "components",
12296
12474
  "value": "var(--iox-surface-2)"
12475
+ },
12476
+ {
12477
+ "name": "account-button-pad",
12478
+ "tier": "component",
12479
+ "type": "spacing",
12480
+ "group": "components",
12481
+ "value": "3px 12px"
12482
+ },
12483
+ {
12484
+ "name": "account-button-gap",
12485
+ "tier": "component",
12486
+ "type": "spacing",
12487
+ "group": "components",
12488
+ "value": "8px"
12489
+ },
12490
+ {
12491
+ "name": "account-avatar-size",
12492
+ "tier": "component",
12493
+ "type": "size",
12494
+ "group": "components",
12495
+ "value": "26px"
12496
+ },
12497
+ {
12498
+ "name": "account-avatar-bg",
12499
+ "tier": "component",
12500
+ "type": "color",
12501
+ "group": "components",
12502
+ "value": "var(--iox-accent)"
12503
+ },
12504
+ {
12505
+ "name": "account-avatar-ink",
12506
+ "tier": "component",
12507
+ "type": "color",
12508
+ "group": "components",
12509
+ "value": "var(--iox-accent-ink)"
12510
+ },
12511
+ {
12512
+ "name": "sign-in-error-ink",
12513
+ "tier": "component",
12514
+ "type": "color",
12515
+ "group": "components",
12516
+ "value": "var(--iox-danger)"
12297
12517
  }
12298
12518
  ]
12299
12519
  },
@@ -14616,6 +14836,48 @@ export const SPEC_FLAVOR_PACKS = [
14616
14836
  "type": "color",
14617
14837
  "group": "components",
14618
14838
  "value": "var(--iox-surface-2)"
14839
+ },
14840
+ {
14841
+ "name": "account-button-pad",
14842
+ "tier": "component",
14843
+ "type": "spacing",
14844
+ "group": "components",
14845
+ "value": "3px 12px"
14846
+ },
14847
+ {
14848
+ "name": "account-button-gap",
14849
+ "tier": "component",
14850
+ "type": "spacing",
14851
+ "group": "components",
14852
+ "value": "8px"
14853
+ },
14854
+ {
14855
+ "name": "account-avatar-size",
14856
+ "tier": "component",
14857
+ "type": "size",
14858
+ "group": "components",
14859
+ "value": "26px"
14860
+ },
14861
+ {
14862
+ "name": "account-avatar-bg",
14863
+ "tier": "component",
14864
+ "type": "color",
14865
+ "group": "components",
14866
+ "value": "var(--iox-accent)"
14867
+ },
14868
+ {
14869
+ "name": "account-avatar-ink",
14870
+ "tier": "component",
14871
+ "type": "color",
14872
+ "group": "components",
14873
+ "value": "var(--iox-accent-ink)"
14874
+ },
14875
+ {
14876
+ "name": "sign-in-error-ink",
14877
+ "tier": "component",
14878
+ "type": "color",
14879
+ "group": "components",
14880
+ "value": "var(--iox-danger)"
14619
14881
  }
14620
14882
  ]
14621
14883
  },
@@ -16900,6 +17162,48 @@ export const SPEC_FLAVOR_PACKS = [
16900
17162
  "type": "color",
16901
17163
  "group": "components",
16902
17164
  "value": "var(--iox-surface-2)"
17165
+ },
17166
+ {
17167
+ "name": "account-button-pad",
17168
+ "tier": "component",
17169
+ "type": "spacing",
17170
+ "group": "components",
17171
+ "value": "3px 12px"
17172
+ },
17173
+ {
17174
+ "name": "account-button-gap",
17175
+ "tier": "component",
17176
+ "type": "spacing",
17177
+ "group": "components",
17178
+ "value": "8px"
17179
+ },
17180
+ {
17181
+ "name": "account-avatar-size",
17182
+ "tier": "component",
17183
+ "type": "size",
17184
+ "group": "components",
17185
+ "value": "26px"
17186
+ },
17187
+ {
17188
+ "name": "account-avatar-bg",
17189
+ "tier": "component",
17190
+ "type": "color",
17191
+ "group": "components",
17192
+ "value": "var(--iox-accent)"
17193
+ },
17194
+ {
17195
+ "name": "account-avatar-ink",
17196
+ "tier": "component",
17197
+ "type": "color",
17198
+ "group": "components",
17199
+ "value": "var(--iox-accent-ink)"
17200
+ },
17201
+ {
17202
+ "name": "sign-in-error-ink",
17203
+ "tier": "component",
17204
+ "type": "color",
17205
+ "group": "components",
17206
+ "value": "var(--iox-danger)"
16903
17207
  }
16904
17208
  ]
16905
17209
  },
@@ -19193,6 +19497,48 @@ export const SPEC_FLAVOR_PACKS = [
19193
19497
  "type": "color",
19194
19498
  "group": "components",
19195
19499
  "value": "var(--iox-surface-2)"
19500
+ },
19501
+ {
19502
+ "name": "account-button-pad",
19503
+ "tier": "component",
19504
+ "type": "spacing",
19505
+ "group": "components",
19506
+ "value": "3px 12px"
19507
+ },
19508
+ {
19509
+ "name": "account-button-gap",
19510
+ "tier": "component",
19511
+ "type": "spacing",
19512
+ "group": "components",
19513
+ "value": "8px"
19514
+ },
19515
+ {
19516
+ "name": "account-avatar-size",
19517
+ "tier": "component",
19518
+ "type": "size",
19519
+ "group": "components",
19520
+ "value": "26px"
19521
+ },
19522
+ {
19523
+ "name": "account-avatar-bg",
19524
+ "tier": "component",
19525
+ "type": "color",
19526
+ "group": "components",
19527
+ "value": "var(--iox-accent)"
19528
+ },
19529
+ {
19530
+ "name": "account-avatar-ink",
19531
+ "tier": "component",
19532
+ "type": "color",
19533
+ "group": "components",
19534
+ "value": "var(--iox-accent-ink)"
19535
+ },
19536
+ {
19537
+ "name": "sign-in-error-ink",
19538
+ "tier": "component",
19539
+ "type": "color",
19540
+ "group": "components",
19541
+ "value": "var(--iox-danger)"
19196
19542
  }
19197
19543
  ]
19198
19544
  }
@@ -18,6 +18,7 @@ export * from './flavor';
18
18
  export * from './element-styles';
19
19
  export * from './adopt';
20
20
  export * from './node-classes';
21
+ export * from './field-classes';
21
22
  export * from './empty-image';
22
23
  export * from './node-links';
23
24
  export * from './brand';
@@ -15,29 +15,9 @@
15
15
  import { ChoiceAppearance, ControlType } from './form.model';
16
16
  import { datePickerWords } from './dates';
17
17
  import { fieldOptionsOf } from './options';
18
+ import { FieldClass } from '@vectoriox/iox-ui/design-core';
18
19
 
19
- /** The classes the markup carries — the runtimes and the shared CSS key on these, never on a literal. */
20
- export enum FieldClass {
21
- Root = 'iox-field',
22
- Label = 'iox-field__label',
23
- LabelHidden = 'iox-field__label--hidden',
24
- Required = 'iox-field__required',
25
- Control = 'iox-field__control',
26
- Help = 'iox-field__help',
27
- Error = 'iox-field__error',
28
- Group = 'iox-field__group',
29
- Option = 'iox-field__option',
30
- Choices = 'iox-field__choices',
31
- ChoicesChips = 'iox-field__choices--chips',
32
- ChoicesList = 'iox-field__choices--list',
33
- Chips = 'iox-field__chips',
34
- Chip = 'iox-field__chip',
35
- ChipInput = 'iox-field__control--chip',
36
- DateButton = 'iox-field__control--date',
37
- DateValue = 'iox-field__date-value',
38
- DateIcon = 'iox-field__date-icon',
39
- DateInput = 'iox-field__date-input',
40
- }
20
+ export { FIELD_INVALID_CLASS, FieldClass, writeFieldError } from '@vectoriox/iox-ui/design-core';
41
21
 
42
22
  /** On the date button: the raw Earliest / Latest (`'0'`, an ISO day), resolved by the visitor's own today. */
43
23
  export const DATE_MIN_ATTRIBUTE = 'data-iox-date-min';
@@ -9,7 +9,7 @@ import {
9
9
  AccordionAutoBinds, CompositeNodeSpec, findByRole, LIGHTBOX_LABEL, SLIDE_TO_ROW, SLIDE_TYPE, buildTabsRecipe, tabLabelNodeOf,
10
10
  tabPanelImageOf, tabPanelTextOf, tabsListOf, tabsPanels, tabsPanelsOf, tabsTriggers, TABS_CONTENT_LIMIT, TABS_IMAGE_BIND_PROP, TABS_LABEL_BIND_PROP,
11
11
  TABS_TEXT_BIND_PROP, TABS_WORDS, TabsAutoBinds, BadgeTone, BADGE_TONES, buildSegmentedRecipe, CardWords, ITEM_OPEN_STATE, segmentedOptions,
12
- setHeaderBehaviour, SHOP_RECIPES, ShopRecipe, ShopRole, bindShopPart, ShopBindTarget,
12
+ setHeaderBehaviour, SHOP_RECIPES, ShopRecipe, ShopRole, bindShopPart, ShopBindTarget, ACCOUNT_RECIPES, AccountRecipe,
13
13
  } from '@vectoriox/iox-ui/composite-core';
14
14
 
15
15
  import { EntranceMark, EntrancePart, planEntrances } from './entrances';
@@ -1094,6 +1094,11 @@ const CART_DRAWER_KEY = 'cart-drawer';
1094
1094
  /** The ids the composer gives them (the header's bag; the drawer, a global after the page). */
1095
1095
  export const SHOP_CART_BUTTON_ID = 'header-cart';
1096
1096
  export const SHOP_CART_DRAWER_ID = 'cart';
1097
+ /** E3a's root keys and the ids the composer gives them: the header's account entry, the ONE sign-in dialog (a global). */
1098
+ const ACCOUNT_ENTRY_KEY = 'account';
1099
+ const SIGN_IN_DIALOG_KEY = 'sign-in';
1100
+ export const ACCOUNT_ENTRY_ID = 'header-account';
1101
+ export const SIGN_IN_DIALOG_ID = 'sign-in';
1097
1102
 
1098
1103
  /**
1099
1104
  * Commerce G1: a shop part stamped whole from E1c's recipe (`SHOP_RECIPES`) — the product page's own reading the page's
@@ -1120,26 +1125,31 @@ function composeShopRecipe(pn: PatternNode, id: string, repeater: RepeaterScope
1120
1125
  }
1121
1126
 
1122
1127
  /**
1123
- * Commerce G1 (C-D21): a selling site is a whole store on every page — the header holds the bag (before the menu
1124
- * button; the brand takes the row's free space, so the bag sits at the end on every width, either direction), and the
1125
- * site holds the ONE cart drawer as a global after the page (`SHOP_GLOBAL_RECIPES`), which every bag opens. Check out
1126
- * is the drawer's own (the fixed checkout). Pure: new globals.
1128
+ * Commerce G1 (C-D21): a selling site is a whole store on every page — the header holds the account entry and the bag
1129
+ * (before the menu button; the brand takes the row's free space, so they sit at the end on every width, either
1130
+ * direction), and the site holds the ONE cart drawer and the ONE sign-in dialog as globals after the page
1131
+ * (`SHOP_GLOBAL_RECIPES`, `ACCOUNT_GLOBAL_RECIPES` — E3a, R-H9), which every bag and every entry open. Check out is the
1132
+ * drawer's own (the fixed checkout). Pure: new globals.
1127
1133
  */
1128
- function withStore(globals: SerializedNode[]): SerializedNode[] {
1134
+ function withStore(globals: SerializedNode[], locale: string): SerializedNode[] {
1129
1135
  const out = [...globals];
1130
1136
  const header = out.find(g => g.id === GlobalSlot.Header);
1131
1137
  if (header) {
1132
1138
  const kids = header.children ?? (header.children = []);
1139
+ const account = ACCOUNT_RECIPES[AccountRecipe.Entry](recipeFactory(ACCOUNT_ENTRY_ID, ACCOUNT_ENTRY_KEY), locale) as SerializedNode;
1133
1140
  const bag = SHOP_RECIPES[ShopRecipe.CartButton](recipeFactory(SHOP_CART_BUTTON_ID, CART_BUTTON_KEY)) as SerializedNode;
1134
1141
  const menu = kids.findIndex(k => k.role === NavRole.MenuButton);
1135
- kids.splice(menu >= 0 ? menu : kids.length, 0, bag);
1142
+ kids.splice(menu >= 0 ? menu : kids.length, 0, account, bag);
1136
1143
  const brand = kids.find(k => k.role === NavRole.Brand);
1137
1144
  if (brand) setStyleProps(brand, { flexGrow: '1' });
1138
1145
  }
1139
1146
  const drawer = SHOP_RECIPES[ShopRecipe.CartDrawer](recipeFactory(SHOP_CART_DRAWER_ID, CART_DRAWER_KEY)) as SerializedNode;
1140
1147
  drawer.isGlobal = true;
1141
1148
  drawer.globalPosition = PatternGlobalPosition.After;
1142
- out.push(drawer);
1149
+ const signIn = ACCOUNT_RECIPES[AccountRecipe.SignInDialog](recipeFactory(SIGN_IN_DIALOG_ID, SIGN_IN_DIALOG_KEY), locale) as SerializedNode;
1150
+ signIn.isGlobal = true;
1151
+ signIn.globalPosition = PatternGlobalPosition.After;
1152
+ out.push(drawer, signIn);
1143
1153
  return out;
1144
1154
  }
1145
1155
 
@@ -1481,7 +1491,7 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
1481
1491
  const root = header ? globals.find(g => g.id === slot) : null;
1482
1492
  if (header && root) setHeaderBehaviour(root as unknown as CompositeNode, header.behaviour, header.edge ?? null);
1483
1493
  }
1484
- if (planSells(plan)) globals = withStore(globals);
1494
+ if (planSells(plan)) globals = withStore(globals, plan.locale ?? DEFAULT_SITE_LOCALE);
1485
1495
 
1486
1496
  return {
1487
1497
  source: clone(plan.source),
@@ -1,4 +1,4 @@
1
- import { ShopRole } from '@vectoriox/iox-ui/composite-core';
1
+ import { AccountRole, ShopRole } from '@vectoriox/iox-ui/composite-core';
2
2
  import { LinkType } from '@vectoriox/iox-ui/design-core';
3
3
 
4
4
  import { PatternGlobalPosition } from './patterns';
@@ -434,10 +434,10 @@ function removeRole(node: SerializedNode, role: NavRole): SerializedNode | null
434
434
  return removed;
435
435
  }
436
436
 
437
- /** The root's own parts that hide at the phone width: everything but the brand, the menu button, the drawer and a
438
- * store's bag (commerce G1 — a phone visitor reaches the cart from every page). */
437
+ /** The root's own parts that hide at the phone width: everything but the brand, the menu button, the drawer, a store's
438
+ * bag (commerce G1 — a phone visitor reaches the cart from every page) and its account entry (E3a — icon only there). */
439
439
  function phoneHiddenParts(root: SerializedNode): SerializedNode[] {
440
- const keep = new Set<string | undefined>([NavRole.Brand, NavRole.MenuButton, NavRole.Drawer, ShopRole.CartButton]);
440
+ const keep = new Set<string | undefined>([NavRole.Brand, NavRole.MenuButton, NavRole.Drawer, ShopRole.CartButton, AccountRole.Account]);
441
441
  return (root.children ?? []).filter((c, i) => !keep.has(roleOf(c)) && !(i === 0 && !c.role && c.type === LINKED));
442
442
  }
443
443
 
@@ -0,0 +1,87 @@
1
+ /**
2
+ * The two address checks every sign-in step leans on. Both REFUSE when in doubt: a sign-in that sends a person to the
3
+ * wrong place is worse than one that sends them home.
4
+ */
5
+
6
+ /** Longer than any page path a site has; a longer `next` is refused. */
7
+ export const NEXT_PATH_MAX_LENGTH = 2048;
8
+
9
+ const PROBE_ORIGIN = 'https://same-origin.invalid';
10
+ // Tab, newline and other control characters are stripped by browsers from a URL, so `/\t/evil` becomes `//evil`.
11
+ const CONTROL = /[\u0000-\u001f\u007f]/;
12
+
13
+ function decodedOnce(value: string): string | null {
14
+ try {
15
+ return decodeURIComponent(value);
16
+ } catch {
17
+ return null;
18
+ }
19
+ }
20
+
21
+ /**
22
+ * True only for a path on THIS site — the `next` a sign-in returns to (the open-redirect guard). It must start with ONE
23
+ * `/`, hold no backslash and no control character (raw or percent-encoded), and stay on the origin when a browser
24
+ * resolves it. `//evil.com`, `/\evil.com`, `/%2F%2Fevil.com`, `https://evil.com`, `javascript:` — all refused.
25
+ */
26
+ export function isSameOriginPath(next: unknown): next is string {
27
+ if (typeof next !== 'string' || !next || next.length > NEXT_PATH_MAX_LENGTH) return false;
28
+ if (next[0] !== '/') return false;
29
+ if (CONTROL.test(next) || next.includes('\\')) return false;
30
+ const decoded = decodedOnce(next);
31
+ if (decoded === null) return false;
32
+ if (CONTROL.test(decoded) || decoded.includes('\\') || decoded.startsWith('//')) return false;
33
+ if (next.startsWith('//')) return false;
34
+ try {
35
+ const url = new URL(next, PROBE_ORIGIN);
36
+ return url.origin === PROBE_ORIGIN;
37
+ } catch {
38
+ return false;
39
+ }
40
+ }
41
+
42
+ /** `next` when it is a same-origin path, else `fallback` (the site's home). */
43
+ export function safeNextPath(next: unknown, fallback = '/'): string {
44
+ return isSameOriginPath(next) ? next : fallback;
45
+ }
46
+
47
+ const LOOPBACK_HOSTS: ReadonlySet<string> = new Set(['localhost', '127.0.0.1', '[::1]']);
48
+
49
+ export function isLoopbackHost(hostname: string): boolean {
50
+ return LOOPBACK_HOSTS.has(hostname.toLowerCase());
51
+ }
52
+
53
+ export interface ReturnHostOptions {
54
+ /** Accept `http:` on a loopback host (tests and local stacks only — never in production). */
55
+ allowLoopbackHttp?: boolean;
56
+ }
57
+
58
+ /** A host as `URL` normalises it (lower case, punycode, the default port dropped), or null when it is not one. */
59
+ export function normalizeHost(host: string): string | null {
60
+ const value = String(host ?? '').trim();
61
+ if (!value || /[\s/\\?#@]/.test(value)) return null;
62
+ try {
63
+ return new URL(`https://${value}`).host;
64
+ } catch {
65
+ return null;
66
+ }
67
+ }
68
+
69
+ /**
70
+ * True when `url` returns to one of `hosts` EXACTLY (the broker's return-host check, C-D22): `https:` only (`http:` on a
71
+ * loopback host when asked), no user or password in it, and its host — punycode, with any non-default port — equal to
72
+ * one allowed host. Never a suffix or a prefix: `evil.idos.iox.studio` and `idos.iox.studio.evil.com` are other hosts.
73
+ */
74
+ export function isAllowedReturnHost(url: unknown, hosts: ReadonlyArray<string>, options: ReturnHostOptions = {}): boolean {
75
+ if (typeof url !== 'string' || !url || CONTROL.test(url) || url.includes('\\')) return false;
76
+ let parsed: URL;
77
+ try {
78
+ parsed = new URL(url);
79
+ } catch {
80
+ return false;
81
+ }
82
+ if (parsed.username || parsed.password) return false;
83
+ const loopback = isLoopbackHost(parsed.hostname);
84
+ if (parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && loopback && options.allowLoopbackHttp)) return false;
85
+ const host = parsed.host.toLowerCase();
86
+ return hosts.some(allowed => normalizeHost(allowed) === host);
87
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @vectoriox/iox-ui/identity-core — the shared, FRAMEWORK-FREE vocabulary of signing in (commerce plan §3c, C-D5,
3
+ * C-D6, C-D22): who signs in and with what, the broker's ticket / redeem shapes and refusals, a studio's site sign-in
4
+ * routes, session claims and cookies, the email-code rules, the two address guards (open redirect, return host) and
5
+ * the sign-in dialog's words. The broker (iox-control-plane), the studios (iox-cms), the engine and the builder speak it.
6
+ * It imports nothing — a consumer maps this one entry.
7
+ * ⚠️ Not re-exported from the main entry. Consumers wire the usual trio — ng-package raw-ts assets,
8
+ * jest moduleNameMapper, tsconfig paths — or `nest start` dies with ERR_REQUIRE_ESM.
9
+ */
10
+ export * from './sign-in';
11
+ export * from './guards';
12
+ export * from './site-auth';
13
+ export * from './words';
14
+ export * from './site-auth-transport';