@abpjs/ui 0.2.0-next.4 → 0.2.0-next.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0-next.5
4
+
5
+ A prerelease under npm's `next` tag: the step-up dialog for AbpGuard 0.7.0's strong step-up and passkeys. Against an
6
+ older AbpGuard nothing changes (no level means the password level).
7
+
8
+ - `StepUpDialog` reads the level the server asks for (`step_up_required` with `level`, `methods`). At `strong`, it
9
+ offers a passkey first when the person has one, or the password with an authenticator code. Asked of someone with no
10
+ strong factor (`strong_factor_required`), it takes the password, then sets up a passkey or the app (QR and key) right
11
+ there, with the recovery codes shown once for a first factor; the call then asks again and they confirm with it.
12
+ - Passkeys in the browser's own JSON both ways (`createPasskey`, `getPasskey`, `passkeysSupported`), with a base64url
13
+ fallback for browsers without `PublicKeyCredential.parse*FromJSON`.
14
+ - `requestStepUp(need)` and `StepUpHandler` take the server's need (`StepUpNeed`, `stepUpNeedOf`). `createHostRequest`
15
+ and `createHostEvents` pass it on and ask again when the server asks for more (a factor set up, then the strong step-up),
16
+ up to three times. `HostRequestInit.stepUp: false` throws a step-up refusal instead of asking (the dialog's own calls).
17
+ `needsStepUp` and `STRONG_FACTOR_REQUIRED` beside `isStepUp`.
18
+ - `createHostEvents` asks the step-up dialog by default, as `createHostRequest` does.
19
+
3
20
  ## 0.2.0-next.4
4
21
 
5
22
  A prerelease under npm's `next` tag, for a host's scope page on the `ai` area.
package/dist/index.d.ts CHANGED
@@ -218,6 +218,35 @@ declare function readAbpError(res: Response): Promise<AbpApiError>;
218
218
  /** An error as a person reads it. */
219
219
  declare function errorText(e: unknown): string;
220
220
  declare const isStepUp: (e: unknown) => boolean;
221
+ /** A strong step-up asked of someone with no strong factor yet (AbpGuard 0.7.0): they set one up, then step up. */
222
+ declare const STRONG_FACTOR_REQUIRED = "strong_factor_required";
223
+ /** A refusal the step-up dialog answers: a step-up, or a strong factor to set up first. */
224
+ declare const needsStepUp: (e: unknown) => e is AbpApiError;
225
+
226
+ /**
227
+ * What the server asked for (AbpGuard 0.7.0, ADR 0110 in the application it came from): a step-up at a level, with the
228
+ * person's ways best first, or a strong factor they don't have yet. Older servers send no level: the password level.
229
+ */
230
+ interface StepUpNeed {
231
+ /** `step_up_required`, or `strong_factor_required` when a strong step-up is asked of someone with no strong factor. */
232
+ code: string;
233
+ /** `password` (the password, with a code of a second factor when the person has one) or `strong` (a passkey, or the password and an authenticator code). */
234
+ level: 'password' | 'strong';
235
+ category: string | null;
236
+ /** The person's ways at that level, best first: `passkey`, `app`, `password`, `email`… Empty when the server doesn't say. */
237
+ methods: string[];
238
+ }
239
+ /** What asks the person to confirm who they are: true once confirmed (or a strong factor set up), false if they gave up. */
240
+ type StepUpHandler = (need: StepUpNeed) => Promise<boolean>;
241
+ /** The step-up dialog registers itself here (`StepUpDialog`, drawn by `AbpProvider`); null when it goes. */
242
+ declare function setStepUpHandler(next: StepUpHandler | null): void;
243
+ /** The need an error carries: its code, and the level and methods in its data. */
244
+ declare function stepUpNeedOf(code: string, data: Record<string, unknown> | null | undefined): StepUpNeed;
245
+ /**
246
+ * Asks the person to confirm who they are, once however many calls are waiting for it (ADR 0109 amendment). False when
247
+ * nothing is registered to ask with: the call then fails with the server's refusal, as it would without.
248
+ */
249
+ declare function requestStepUp(need?: StepUpNeed): Promise<boolean>;
221
250
 
222
251
  /** What a call sends: its method, a JSON body (or FormData as is), headers, and a way to stop it. */
223
252
  interface HostRequestInit {
@@ -227,6 +256,8 @@ interface HostRequestInit {
227
256
  signal?: AbortSignal;
228
257
  /** The answer as a file (a Blob and the name Content-Disposition gives) rather than JSON. */
229
258
  as?: 'json' | 'file';
259
+ /** False: a refusal that asks for a step-up is thrown, not asked (the step-up dialog's own calls). */
260
+ stepUp?: false;
230
261
  }
231
262
  /** A file the server answered with. */
232
263
  interface HostFile {
@@ -250,7 +281,7 @@ interface HostRequestOptions {
250
281
  * A 403 `step_up_required`: the host confirms the person again; true retries the call once. By default the step-up
251
282
  * dialog `AbpProvider` draws asks (`requestStepUp`), and without one the call fails as the server answered.
252
283
  */
253
- stepUp?: () => Promise<boolean>;
284
+ stepUp?: (need: StepUpNeed) => Promise<boolean>;
254
285
  /** More headers on every call (a development user, a tenant). */
255
286
  headers?: () => Record<string, string>;
256
287
  fetch?: typeof fetch;
@@ -276,7 +307,7 @@ type HostEvents = (path: string, onEvent: HostEventHandler, options?: {
276
307
  }) => Promise<string | null>;
277
308
  /** Reads a response's server-sent events to its end. */
278
309
  declare function readEvents(res: Response, onEvent: HostEventHandler): Promise<void>;
279
- /** Server-sent events for a host without its own reader: same origin, its headers, a 401 handed back, one step-up. */
310
+ /** Server-sent events for a host without its own reader: same origin, its headers, a 401 handed back, a step-up (the dialog's by default). */
280
311
  declare function createHostEvents(options?: Pick<HostRequestOptions, 'onUnauthorized' | 'stepUp' | 'headers' | 'fetch'>): HostEvents;
281
312
 
282
313
  /** A scope as a host knows it: a project, an org unit. */
@@ -1520,24 +1551,22 @@ declare function useSlotSaves(): {
1520
1551
  run: () => Promise<void>;
1521
1552
  };
1522
1553
 
1523
- /** What asks the person to confirm who they are: true once confirmed, false if they gave up. */
1524
- type StepUpHandler = () => Promise<boolean>;
1525
- /** The step-up dialog registers itself here (`StepUpDialog`, drawn by `AbpProvider`); null when it goes. */
1526
- declare function setStepUpHandler(next: StepUpHandler | null): void;
1527
- /**
1528
- * Asks the person to confirm who they are, once however many calls are waiting for it (ADR 0109 amendment). False when
1529
- * nothing is registered to ask with: the call then fails with the server's `step_up_required`, as it would without.
1530
- */
1531
- declare function requestStepUp(): Promise<boolean>;
1532
-
1533
1554
  /** Whether what was typed can be a code yet: six digits (spaces between are fine), or a recovery code's ten characters. */
1534
1555
  declare function looksLikeCode(value: string, recovery: boolean): boolean;
1535
1556
  /**
1536
- * Asks for the password again before a sensitive action (ADR 0109 amendment, on AbpGuard's step-up): the server answers
1537
- * 403 `step_up_required`, the host's request asks here, and the call is tried again once confirmed. A person with a
1538
- * second factor gives a code too, from their app, a recovery code, or one the site sends. Too many wrong passwords end
1539
- * the session (401), which the host's request hands to the host. `AbpProvider` draws it when the host gives
1540
- * `paths.guard`; a host with its own dialog sets `stepUpDialog: false`.
1557
+ * Confirms the person before a sensitive action (ADR 0109 amendment, on AbpGuard's step-up): the server answers 403
1558
+ * `step_up_required`, the host's request asks here, and the call is tried again once confirmed.
1559
+ *
1560
+ * - At the password level: the password, and a code of their second factor when they have one (their app, a recovery
1561
+ * code, or one the site sends).
1562
+ * - At the strong level (AbpGuard 0.7.0): a passkey first when they have one, or the password with an authenticator
1563
+ * code.
1564
+ * - Asked for a strong step-up with no strong factor (`strong_factor_required`): the password, then setting up a passkey
1565
+ * or the app here (with recovery codes, shown once, for a first factor); the call then asks again, and they confirm
1566
+ * with what they set up.
1567
+ *
1568
+ * Too many wrong passwords end the session (401), which the host's request hands to the host. `AbpProvider` draws it
1569
+ * when the host gives `paths.guard`; a host with its own dialog sets `stepUpDialog: false`.
1541
1570
  */
1542
1571
  declare function StepUpDialog(): react.JSX.Element;
1543
1572
 
@@ -2763,4 +2792,4 @@ interface TooltipProps extends Omit<Tooltip$1.RootProps, 'children'> {
2763
2792
  */
2764
2793
  declare const Tooltip: react.ForwardRefExoticComponent<TooltipProps & react.RefAttributes<HTMLDivElement>>;
2765
2794
 
2766
- export { ABP_UI_VERSION, AbpApiError, type AbpBrand, type AbpHost, type AbpLabels, AbpProvider, type AbpProviderProps, type AbpSystemOptions, type ApiQuery, AppLink, type AppLinkProps, AppShell, type AppShellBrand, type AppShellNavItem, type AppShellNavSection, type AppShellPlace, type AppShellProps, type AppShellSidebar, type AreaTexts, type Arrival, ArriveOnChange, type ArriveOnChangeProps, AttentionChip, type AttentionChipProps, type AvatarPerson, AvatarStack, type AvatarStackProps, Bone, type BoneProps, type BreadcrumbItem, Breadcrumbs, Button, type ButtonProps, type ButtonSize, type ButtonVariant, CalendarGrid, type CalendarGridProps, type CalendarItem, type CardDates, CategoryProgress, type CategoryProgressProps, type CelebrateTarget, Chart, type ChartProps, type ChartSeries, CheckboxField, type CheckboxFieldProps, Collapse, type CollapseProps, type ColorMode, ColorModeProvider, ColorModeToggle, type CommandGroup, type CommandItem, CommandPalette, type CommandPaletteProps, ConfirmDialog, type ConfirmDialogProps, type ConfirmOptions, ConfirmProvider, CountBadge, type CountBadgeProps, Counter, type CounterProps, DashboardGrid, type DashboardGridProps, DataTable, type DataTableColumn, type DataTableProps, type DataTableSelection, type DataTableSort, type Direction, DirectionalIcon, DropHint, type DropHintProps, type DropZoneOptions, type DropZoneState, type DroppedFile, EMPTY_VALUE, EmptyState, type EmptyStateProps, FadeIn, type FadeInProps, Field, type FieldProps, FileDropArea, type FileDropAreaProps, FormDialog, type FormDialogProps, FormField, type GridItem, HighlightText, type HostEventHandler, type HostEvents, type HostFile, type HostLanguage, HostProvider, type HostRequest, type HostRequestInit, type HostRequestOptions, type HostScope, HostSlot, IconButton, type IconButtonProps, IconTile, type IconTileProps, Indicator, type IndicatorProps, InlineAlert, type InlineAlertProps, KanbanBoard, type KanbanBoardProps, type KanbanColumn, type KanbanItem, type KanbanLane, type KanbanMove, type LinkComponent, Loading, type LoadingProps, LoadingState, MotionProvider, type MotionSetting, type MotionState, Nudge, type NudgeProps, PageHeader, type PageHeaderProps, PageTitleProvider, Pagination, type PaginationProps, Panel, type PanelProps, PanelTone, type Particle, PathChips, type PathChipsProps, PersonChip, type PersonChipProps, type PlacedCard, PluginTextsProvider, type Pose, Presence, PresenceItem, type PresenceItemProps, PresenceList, type PresenceListProps, type PresenceProps, Pressable, type PressableProps, PriorityMark, type PriorityMarkProps, type PropertyItem, PropertyList, type PropertyListProps, type QueryConditionJson, type QueryExportFormat, type QueryField, type QueryGroup, type QueryJson, type QueryListLabels, type QueryNodeJson, type QueryRow, type QuerySuggestion, type QuerySuggestions, type QueryValueEditor, QueryableList, type QueryableListError, type QueryableListExport, type QueryableListProps, type QueryableListState, type QueryableListView, type QueueProgress, RecordKey, type RecordKeyProps, type RegisterSlotSave, Reveal, RevealItem, type RevealItemProps, type RevealProps, SHOWN, STEP_UP_REQUIRED, type Scale, SearchInput, type SearchInputProps, type SectionMove, SegmentedControl, type SegmentedControlProps, type SegmentedItem, SelectField, type SelectFieldProps, type SelectOption, type SettingsArea, SettingsLayout, type SettingsLayoutProps, type SettingsPage, type SettingsSection, SlideItem, type SlideItemProps, SlideList, type SlideListProps, type SlotSave, type SortDirection, type SortableSection, SortableSections, type SortableSectionsProps, type StatusCategory, StatusPill, type StatusPillProps, type StatusTone, StepUpDialog, type StepUpHandler, Swap, type SwapProps, SwitchField, type SwitchFieldProps, TITLE_SEPARATOR, TextBone, type TextBoneProps, TextSlot, type TextSlotProps, type TimelineCardItem, TimelineCards, type TimelineCardsProps, TimelineChart, type TimelineChartProps, type TimelineItem, type TimelineRow, type TimelineScale, type TitleParts, Toaster, Tooltip, type TooltipProps, UPLOADS_AT_ONCE, type UploadJob, UploadList, type UploadListProps, type UploadRow, type UploadState, abpConfig, arriveCss, asMotionSetting, avatarPalette, basicConditions, boneWidth, burst, compactLayout, compareOrdinal, composeTitle, covers, createAbpSystem, createAreaTexts, createHostEvents, createHostRequest, curves, defaultBrand, defaultLabels, defaultQueryListLabels, directionOf, droppedFiles, errorText, fileNameOf, findSettingsPage, folderOf, foldersFor, formatDateTime, formatMessage, formatNumber, ghostCss, groupKey, heavierFirst, hiddenPose, inSections, isStepUp, looksLikeCode, durations as motionDurations, notify, pageList, partsOf, pastedName, placeCards, placeItem, priorityLevel, progressOf, readAbpError, readEvents, refusal, requestStepUp, setStepUpHandler, settingsArea, shineCss, springs, staggerDelay, targetOf, toStart, toaster, useAbpLabels, useAbpLocale, useAbpTimeZone, useApiAction, useApiDownload, useApiQuery, useAreaEvents, useAreaRequest, useArriving, useCan, useCelebrate, useColorMode, useConfirm, useDropZone, useFilesOverPage, useFormatters, useHost, useHostLanguages, useLinkComponent, useLoading, useMe, useMotionSetting, useNames, useNavigate, useOptionalHost, usePageDrop, usePageTitle, usePageTitleParts, usePageTitleSite, usePastedFiles, usePluginTexts, useProductName, useSlotSaves, useTokenVar };
2795
+ export { ABP_UI_VERSION, AbpApiError, type AbpBrand, type AbpHost, type AbpLabels, AbpProvider, type AbpProviderProps, type AbpSystemOptions, type ApiQuery, AppLink, type AppLinkProps, AppShell, type AppShellBrand, type AppShellNavItem, type AppShellNavSection, type AppShellPlace, type AppShellProps, type AppShellSidebar, type AreaTexts, type Arrival, ArriveOnChange, type ArriveOnChangeProps, AttentionChip, type AttentionChipProps, type AvatarPerson, AvatarStack, type AvatarStackProps, Bone, type BoneProps, type BreadcrumbItem, Breadcrumbs, Button, type ButtonProps, type ButtonSize, type ButtonVariant, CalendarGrid, type CalendarGridProps, type CalendarItem, type CardDates, CategoryProgress, type CategoryProgressProps, type CelebrateTarget, Chart, type ChartProps, type ChartSeries, CheckboxField, type CheckboxFieldProps, Collapse, type CollapseProps, type ColorMode, ColorModeProvider, ColorModeToggle, type CommandGroup, type CommandItem, CommandPalette, type CommandPaletteProps, ConfirmDialog, type ConfirmDialogProps, type ConfirmOptions, ConfirmProvider, CountBadge, type CountBadgeProps, Counter, type CounterProps, DashboardGrid, type DashboardGridProps, DataTable, type DataTableColumn, type DataTableProps, type DataTableSelection, type DataTableSort, type Direction, DirectionalIcon, DropHint, type DropHintProps, type DropZoneOptions, type DropZoneState, type DroppedFile, EMPTY_VALUE, EmptyState, type EmptyStateProps, FadeIn, type FadeInProps, Field, type FieldProps, FileDropArea, type FileDropAreaProps, FormDialog, type FormDialogProps, FormField, type GridItem, HighlightText, type HostEventHandler, type HostEvents, type HostFile, type HostLanguage, HostProvider, type HostRequest, type HostRequestInit, type HostRequestOptions, type HostScope, HostSlot, IconButton, type IconButtonProps, IconTile, type IconTileProps, Indicator, type IndicatorProps, InlineAlert, type InlineAlertProps, KanbanBoard, type KanbanBoardProps, type KanbanColumn, type KanbanItem, type KanbanLane, type KanbanMove, type LinkComponent, Loading, type LoadingProps, LoadingState, MotionProvider, type MotionSetting, type MotionState, Nudge, type NudgeProps, PageHeader, type PageHeaderProps, PageTitleProvider, Pagination, type PaginationProps, Panel, type PanelProps, PanelTone, type Particle, PathChips, type PathChipsProps, PersonChip, type PersonChipProps, type PlacedCard, PluginTextsProvider, type Pose, Presence, PresenceItem, type PresenceItemProps, PresenceList, type PresenceListProps, type PresenceProps, Pressable, type PressableProps, PriorityMark, type PriorityMarkProps, type PropertyItem, PropertyList, type PropertyListProps, type QueryConditionJson, type QueryExportFormat, type QueryField, type QueryGroup, type QueryJson, type QueryListLabels, type QueryNodeJson, type QueryRow, type QuerySuggestion, type QuerySuggestions, type QueryValueEditor, QueryableList, type QueryableListError, type QueryableListExport, type QueryableListProps, type QueryableListState, type QueryableListView, type QueueProgress, RecordKey, type RecordKeyProps, type RegisterSlotSave, Reveal, RevealItem, type RevealItemProps, type RevealProps, SHOWN, STEP_UP_REQUIRED, STRONG_FACTOR_REQUIRED, type Scale, SearchInput, type SearchInputProps, type SectionMove, SegmentedControl, type SegmentedControlProps, type SegmentedItem, SelectField, type SelectFieldProps, type SelectOption, type SettingsArea, SettingsLayout, type SettingsLayoutProps, type SettingsPage, type SettingsSection, SlideItem, type SlideItemProps, SlideList, type SlideListProps, type SlotSave, type SortDirection, type SortableSection, SortableSections, type SortableSectionsProps, type StatusCategory, StatusPill, type StatusPillProps, type StatusTone, StepUpDialog, type StepUpHandler, type StepUpNeed, Swap, type SwapProps, SwitchField, type SwitchFieldProps, TITLE_SEPARATOR, TextBone, type TextBoneProps, TextSlot, type TextSlotProps, type TimelineCardItem, TimelineCards, type TimelineCardsProps, TimelineChart, type TimelineChartProps, type TimelineItem, type TimelineRow, type TimelineScale, type TitleParts, Toaster, Tooltip, type TooltipProps, UPLOADS_AT_ONCE, type UploadJob, UploadList, type UploadListProps, type UploadRow, type UploadState, abpConfig, arriveCss, asMotionSetting, avatarPalette, basicConditions, boneWidth, burst, compactLayout, compareOrdinal, composeTitle, covers, createAbpSystem, createAreaTexts, createHostEvents, createHostRequest, curves, defaultBrand, defaultLabels, defaultQueryListLabels, directionOf, droppedFiles, errorText, fileNameOf, findSettingsPage, folderOf, foldersFor, formatDateTime, formatMessage, formatNumber, ghostCss, groupKey, heavierFirst, hiddenPose, inSections, isStepUp, looksLikeCode, durations as motionDurations, needsStepUp, notify, pageList, partsOf, pastedName, placeCards, placeItem, priorityLevel, progressOf, readAbpError, readEvents, refusal, requestStepUp, setStepUpHandler, settingsArea, shineCss, springs, staggerDelay, stepUpNeedOf, targetOf, toStart, toaster, useAbpLabels, useAbpLocale, useAbpTimeZone, useApiAction, useApiDownload, useApiQuery, useAreaEvents, useAreaRequest, useArriving, useCan, useCelebrate, useColorMode, useConfirm, useDropZone, useFilesOverPage, useFormatters, useHost, useHostLanguages, useLinkComponent, useLoading, useMe, useMotionSetting, useNames, useNavigate, useOptionalHost, usePageDrop, usePageTitle, usePageTitleParts, usePageTitleSite, usePastedFiles, usePluginTexts, useProductName, useSlotSaves, useTokenVar };