@abpjs/ui 0.2.0-next.1 → 0.2.0-next.10

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/dist/index.d.ts CHANGED
@@ -218,6 +218,37 @@ 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
+ /** An authenticator code alone passes (the operator's setting, AbpGuard's `appCodeAlone`); else it goes with the password. */
239
+ appCodeAlone: boolean;
240
+ }
241
+ /** What asks the person to confirm who they are: true once confirmed (or a strong factor set up), false if they gave up. */
242
+ type StepUpHandler = (need: StepUpNeed) => Promise<boolean>;
243
+ /** The step-up dialog registers itself here (`StepUpDialog`, drawn by `AbpProvider`); null when it goes. */
244
+ declare function setStepUpHandler(next: StepUpHandler | null): void;
245
+ /** The need an error carries: its code, and the level and methods in its data. */
246
+ declare function stepUpNeedOf(code: string, data: Record<string, unknown> | null | undefined): StepUpNeed;
247
+ /**
248
+ * Asks the person to confirm who they are, once however many calls are waiting for it (ADR 0109 amendment). False when
249
+ * nothing is registered to ask with: the call then fails with the server's refusal, as it would without.
250
+ */
251
+ declare function requestStepUp(need?: StepUpNeed): Promise<boolean>;
221
252
 
222
253
  /** What a call sends: its method, a JSON body (or FormData as is), headers, and a way to stop it. */
223
254
  interface HostRequestInit {
@@ -227,6 +258,8 @@ interface HostRequestInit {
227
258
  signal?: AbortSignal;
228
259
  /** The answer as a file (a Blob and the name Content-Disposition gives) rather than JSON. */
229
260
  as?: 'json' | 'file';
261
+ /** False: a refusal that asks for a step-up is thrown, not asked (the step-up dialog's own calls). */
262
+ stepUp?: false;
230
263
  }
231
264
  /** A file the server answered with. */
232
265
  interface HostFile {
@@ -246,8 +279,11 @@ interface HostRequestOptions {
246
279
  };
247
280
  /** A 401: the host sends the person to sign in. */
248
281
  onUnauthorized?: () => void;
249
- /** A 403 `step_up_required`: the host confirms the person again; true retries the call once. */
250
- stepUp?: () => Promise<boolean>;
282
+ /**
283
+ * A 403 `step_up_required`: the host confirms the person again; true retries the call once. By default the step-up
284
+ * dialog `AbpProvider` draws asks (`requestStepUp`), and without one the call fails as the server answered.
285
+ */
286
+ stepUp?: (need: StepUpNeed) => Promise<boolean>;
251
287
  /** More headers on every call (a development user, a tenant). */
252
288
  headers?: () => Record<string, string>;
253
289
  fetch?: typeof fetch;
@@ -256,7 +292,7 @@ interface HostRequestOptions {
256
292
  declare function fileNameOf(disposition: string | null): string | null;
257
293
  /**
258
294
  * A host request for a host that has none of its own: cookies for the session, the anti-forgery cookie echoed in its
259
- * header, a 401 handed to the host, and one retry after a step-up. A host with its own request passes that instead.
295
+ * header, a 401 handed to the host, and one retry after a step-up (the provider's step-up dialog unless `stepUp` is given). A host with its own request passes that instead.
260
296
  */
261
297
  declare function createHostRequest(options?: HostRequestOptions): HostRequest;
262
298
 
@@ -273,7 +309,7 @@ type HostEvents = (path: string, onEvent: HostEventHandler, options?: {
273
309
  }) => Promise<string | null>;
274
310
  /** Reads a response's server-sent events to its end. */
275
311
  declare function readEvents(res: Response, onEvent: HostEventHandler): Promise<void>;
276
- /** Server-sent events for a host without its own reader: same origin, its headers, a 401 handed back, one step-up. */
312
+ /** 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). */
277
313
  declare function createHostEvents(options?: Pick<HostRequestOptions, 'onUnauthorized' | 'stepUp' | 'headers' | 'fetch'>): HostEvents;
278
314
 
279
315
  /** A scope as a host knows it: a project, an org unit. */
@@ -320,6 +356,11 @@ interface AbpHost {
320
356
  languages?: HostLanguage[];
321
357
  /** The host's words for any area's text, by area then language then key: `{ ai: { en: { 'models.title': 'AI models' } } }`. */
322
358
  texts?: Record<string, Record<string, Record<string, string>>>;
359
+ /**
360
+ * Whether `AbpProvider` draws the step-up dialog (on `paths.guard`), which `createHostRequest` asks by default. On
361
+ * when the host gives `paths.guard`; false for a host that has its own dialog.
362
+ */
363
+ stepUpDialog?: boolean;
323
364
  /** What the host draws in a screen's named places (`guard.account.panels`, `guard.directory.panel`). */
324
365
  slots?: Record<string, ComponentType<Record<string, unknown>>>;
325
366
  }
@@ -331,7 +372,10 @@ declare function HostProvider({ value, children }: {
331
372
  declare function useHost(): AbpHost;
332
373
  /** The host when there is one: for parts that also work without (a slot that draws nothing). */
333
374
  declare function useOptionalHost(): AbpHost | null;
334
- /** A package's calls on this host: its base path in front of each path. */
375
+ /**
376
+ * A package's calls on this host: its base path in front of each path. The same function while the area's path stays
377
+ * the same, whatever the host object is; each call goes through the host's current `request`.
378
+ */
335
379
  declare function useAreaRequest(area: string): HostRequest;
336
380
  interface ApiQuery<T> {
337
381
  data: T | undefined;
@@ -1509,6 +1553,39 @@ declare function useSlotSaves(): {
1509
1553
  run: () => Promise<void>;
1510
1554
  };
1511
1555
 
1556
+ /** Whether what was typed can be a code yet: six digits (spaces between are fine), or a recovery code's ten characters. */
1557
+ declare function looksLikeCode(value: string, recovery: boolean): boolean;
1558
+ /**
1559
+ * Confirms the person before a sensitive action (ADR 0109 amendment, on AbpGuard's step-up): the server answers 403
1560
+ * `step_up_required`, the host's request asks here, and the call is tried again once confirmed.
1561
+ *
1562
+ * - At the password level: the password, and a code of their second factor when they have one (their app, a recovery
1563
+ * code, or one the site sends).
1564
+ * - At the strong level (AbpGuard 0.7.0): a passkey first when they have one, or an authenticator code: alone where the
1565
+ * server says one passes alone (`appCodeAlone`, the operator's setting), else with the password. Where a code passes
1566
+ * alone it's offered at the password level too.
1567
+ * - Asked for a strong step-up with no strong factor (`strong_factor_required`): the password, then setting up a passkey
1568
+ * or the app here (with recovery codes, shown once, for a first factor); the call then asks again, and they confirm
1569
+ * with what they set up.
1570
+ *
1571
+ * Too many wrong passwords end the session (401), which the host's request hands to the host. `AbpProvider` draws it
1572
+ * when the host gives `paths.guard`; a host with its own dialog sets `stepUpDialog: false`.
1573
+ */
1574
+ declare function StepUpDialog(): react.JSX.Element;
1575
+
1576
+ /**
1577
+ * Passkeys in the browser (WebAuthn), in the browser's own JSON both ways, as AbpGuard 0.7.0 speaks it: the options come
1578
+ * as `PublicKeyCredentialCreationOptionsJSON` / `PublicKeyCredentialRequestOptionsJSON`, and the answer goes back as the
1579
+ * credential's `toJSON()`. Browsers without the JSON methods get the same through base64url here.
1580
+ */
1581
+ type Json = Record<string, unknown>;
1582
+ /** Whether this browser can use passkeys at all (a secure page with WebAuthn). */
1583
+ declare function passkeysSupported(): boolean;
1584
+ /** Makes a passkey on this device from the server's creation options; null when the person cancelled. */
1585
+ declare function createPasskey(options: Json, signal?: AbortSignal): Promise<Json | null>;
1586
+ /** Proves a passkey from the server's request options; null when the person cancelled or had none here. */
1587
+ declare function getPasskey(options: Json, signal?: AbortSignal): Promise<Json | null>;
1588
+
1512
1589
  /**
1513
1590
  * A text with its values filled, in the subset of ICU message syntax the screens' texts use: `{name}`, plurals
1514
1591
  * (`{count, plural, =0 {none} one {# item} other {# items}}`, with Arabic's zero, two, few and many) and choices
@@ -2731,4 +2808,4 @@ interface TooltipProps extends Omit<Tooltip$1.RootProps, 'children'> {
2731
2808
  */
2732
2809
  declare const Tooltip: react.ForwardRefExoticComponent<TooltipProps & react.RefAttributes<HTMLDivElement>>;
2733
2810
 
2734
- 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, 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, durations as motionDurations, notify, pageList, partsOf, pastedName, placeCards, placeItem, priorityLevel, progressOf, readAbpError, readEvents, refusal, 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 };
2811
+ 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, createPasskey, curves, defaultBrand, defaultLabels, defaultQueryListLabels, directionOf, droppedFiles, errorText, fileNameOf, findSettingsPage, folderOf, foldersFor, formatDateTime, formatMessage, formatNumber, getPasskey, ghostCss, groupKey, heavierFirst, hiddenPose, inSections, isStepUp, looksLikeCode, durations as motionDurations, needsStepUp, notify, pageList, partsOf, passkeysSupported, 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 };