@pontive/pontkit-core 1.27.0 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/catalog.json +1 -1
- package/custom-elements.json +1 -1
- package/dist/components/renderers/auth/scope-list/_scope-list.d.ts +1 -1
- package/dist/components/renderers/auth/scope-list/scope-list.types.d.ts +1 -1
- package/dist/components/widgets/pont-consent/consent-api.d.ts +1 -1
- package/dist/components/widgets/pont-consent/pont-consent.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/pont2/core/controllers/action.d.ts +79 -0
- package/dist/pont2/core/controllers/copy.d.ts +34 -0
- package/dist/pont2/core/icons.d.ts +24 -16
- package/dist/pont2/core/index.d.ts +2 -0
- package/dist/pont2/core/names.d.ts +1 -1
- package/dist/pont2/globals.css +19 -7
- package/dist/pont2/index.mjs +3349 -1494
- package/dist/pont2/index.mjs.map +1 -1
- package/dist/pont2/kit/alert/alert.d.ts +2 -1
- package/dist/pont2/kit/auth-button/auth-button.d.ts +185 -0
- package/dist/pont2/kit/auth-button/providers.d.ts +15 -0
- package/dist/pont2/kit/auth-field/auth-field.d.ts +267 -0
- package/dist/pont2/kit/auth-field/password-field.d.ts +124 -0
- package/dist/pont2/kit/block/block.d.ts +66 -0
- package/dist/pont2/kit/block/branding.d.ts +36 -0
- package/dist/pont2/kit/container/container.d.ts +40 -0
- package/dist/pont2/kit/countdown/countdown.d.ts +64 -0
- package/dist/pont2/kit/divider/divider.d.ts +30 -0
- package/dist/pont2/kit/edit-identifier/edit-identifier.d.ts +47 -0
- package/dist/pont2/kit/flow-widget/flow-widget.d.ts +151 -0
- package/dist/pont2/kit/gap/gap.d.ts +36 -0
- package/dist/pont2/kit/header/header.d.ts +37 -0
- package/dist/pont2/kit/index.d.ts +23 -0
- package/dist/pont2/kit/input-otp/input-otp.d.ts +7 -0
- package/dist/pont2/kit/layout/flow-error.d.ts +21 -0
- package/dist/pont2/kit/layout/layout.d.ts +120 -0
- package/dist/pont2/kit/link/link.d.ts +64 -0
- package/dist/pont2/kit/logo/logo.d.ts +57 -0
- package/dist/pont2/kit/otp-field/otp-field.d.ts +93 -0
- package/dist/pont2/kit/otp-field/otp-resend.d.ts +63 -0
- package/dist/pont2/kit/provider-field/provider-field.d.ts +87 -0
- package/dist/pont2/kit/qr-code/qr-code.d.ts +87 -0
- package/dist/pont2/kit/recovery-codes/recovery-codes.d.ts +65 -0
- package/dist/pont2/kit/scope-list/scope-list.d.ts +69 -0
- package/dist/pont2/kit/scope-list/scope-value.d.ts +16 -0
- package/dist/pont2/kit/secret/secret.d.ts +67 -0
- package/dist/pont2/kit/story-helpers.d.ts +9 -0
- package/dist/pont2/kit/typography/typography.d.ts +74 -0
- package/dist/pont2/kit/watermark/pontive-logo.d.ts +8 -0
- package/dist/pont2/kit/watermark/watermark.d.ts +44 -0
- package/dist/pont2/primitives/card/card.d.ts +3 -1
- package/dist/pont2/primitives/dropdown-menu/dropdown-menu.d.ts +5 -0
- package/dist/pont2/primitives/popover/popover.d.ts +2 -0
- package/dist/pont2/primitives/tooltip/tooltip.d.ts +2 -0
- package/dist/pont2/styles.css +3042 -935
- package/dist/pont2/theme/apply.d.ts +29 -0
- package/dist/pont2/theme/compile.d.ts +23 -0
- package/dist/pont2/theme/index.d.ts +23 -0
- package/dist/pont2/theme/manifest.d.ts +2 -0
- package/dist/pont2/theme/scopes.d.ts +13 -0
- package/dist/pont2/theme/shadcn.d.ts +7 -0
- package/dist/pont2/theme/tokens.json.d.ts +7009 -0
- package/dist/pont2/theme/types.d.ts +92 -0
- package/dist/pont2/theme/validate.d.ts +11 -0
- package/dist/pont2/theme/value.d.ts +10 -0
- package/dist/pont2/theme/vocabulary.d.ts +32 -0
- package/dist/pont2/theme.mjs +337 -0
- package/dist/pont2/theme.mjs.map +1 -0
- package/dist/pont2/tokens.json +7006 -0
- package/dist/pont2/with-legacy.css +1 -1
- package/package.json +8 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ReactiveElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Account-level branding entitlements, the pont2 side of
|
|
4
|
+
* docs/branding-entitlements.md (same rule, same shape):
|
|
5
|
+
*
|
|
6
|
+
* > A branding entitlement is a fact about the account, resolved by the
|
|
7
|
+
* > backend, delivered as context. An element that renders branding *asks*
|
|
8
|
+
* > for it. It is never *told* by its own markup.
|
|
9
|
+
*
|
|
10
|
+
* So there is no attribute, property or other escape hatch on any pont2
|
|
11
|
+
* element; the flow host (the future pont2 widgets/layout) provides
|
|
12
|
+
* `brandingContext` from the backend response, and Storybook provides it with
|
|
13
|
+
* a `ContextProvider`.
|
|
14
|
+
*
|
|
15
|
+
* The context is the Context Community Protocol (`context-request` events)
|
|
16
|
+
* through `@lit/context`. Its key is `pont2:branding`, separate from the
|
|
17
|
+
* legacy `pont:branding` (docs/08-parallel-constraints.md §4).
|
|
18
|
+
*/
|
|
19
|
+
export interface BrandingEntitlements {
|
|
20
|
+
/** Whether the Pontive watermark must be rendered on the screen shell. */
|
|
21
|
+
showWatermark: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Fail closed: no provider, or an old backend, means the watermark shows. */
|
|
24
|
+
export declare const DEFAULT_BRANDING: BrandingEntitlements;
|
|
25
|
+
export declare const brandingContext: {
|
|
26
|
+
__context__: BrandingEntitlements;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Reads the entitlements for one element (subscribing, so a late or changed
|
|
30
|
+
* provider value re-renders it). Deliberately no attribute override.
|
|
31
|
+
*/
|
|
32
|
+
export declare class BrandingController {
|
|
33
|
+
private consumer;
|
|
34
|
+
constructor(host: ReactiveElement);
|
|
35
|
+
get showWatermark(): boolean;
|
|
36
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PropertyDeclarations } from 'lit';
|
|
2
|
+
import { HostElement } from '../../core/host-element';
|
|
3
|
+
/** The legacy render-spec values. */
|
|
4
|
+
export type ContainerType = "flex_column" | "flex_row";
|
|
5
|
+
export type ContainerAlign = "stretch" | "start" | "center" | "end";
|
|
6
|
+
export type ContainerJustify = "start" | "center" | "end" | "between";
|
|
7
|
+
/**
|
|
8
|
+
* # `<pont2-container>`: a flex group of screen elements
|
|
9
|
+
*
|
|
10
|
+
* ```html
|
|
11
|
+
* <pont2-container type="flex_row" justify="between">…</pont2-container>
|
|
12
|
+
* → <pont2-container data-pont2-container data-slot="container" data-type="flex_row" data-justify="between">…</pont2-container>
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Tier 1 host-as-root: the host is the flex box and the children stay where
|
|
16
|
+
* they are (the legacy element rendered an inner `div` and moved the children
|
|
17
|
+
* into it). Not a composite: it contains content.
|
|
18
|
+
*
|
|
19
|
+
* @tag pont2-container
|
|
20
|
+
* @attr type - flex_column (default) | flex_row
|
|
21
|
+
* @attr align - stretch (default) | start | center | end (cross axis)
|
|
22
|
+
* @attr justify - start (default) | center | end | between (main axis)
|
|
23
|
+
* @cssprop --pont2-container-gap - default 1rem
|
|
24
|
+
*/
|
|
25
|
+
export declare class Container extends HostElement {
|
|
26
|
+
static identity: string;
|
|
27
|
+
static slotName: string;
|
|
28
|
+
static composite: boolean;
|
|
29
|
+
static properties: PropertyDeclarations;
|
|
30
|
+
type: ContainerType;
|
|
31
|
+
align: ContainerAlign;
|
|
32
|
+
justify: ContainerJustify;
|
|
33
|
+
constructor();
|
|
34
|
+
protected willUpdate(): void;
|
|
35
|
+
}
|
|
36
|
+
declare global {
|
|
37
|
+
interface HTMLElementTagNameMap {
|
|
38
|
+
"pont2-container": Container;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
|
+
import { HostElement } from '../../core/host-element';
|
|
3
|
+
export interface CountdownEndDetail {
|
|
4
|
+
/** Where the countdown will navigate (already resolved), or null. */
|
|
5
|
+
url: string | null;
|
|
6
|
+
}
|
|
7
|
+
/** Resolves `raw` against the page and accepts only http(s) URLs (no `javascript:`, `data:` …). */
|
|
8
|
+
export declare function safeRedirect(raw: string, base?: string): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* # `<pont2-countdown>`: "Redirecting in 5s…"
|
|
11
|
+
*
|
|
12
|
+
* ```html
|
|
13
|
+
* <pont2-countdown content="Redirecting you in" duration="5" redirect-url="/dashboard"></pont2-countdown>
|
|
14
|
+
* → <pont2-countdown data-pont2-countdown data-slot="countdown" role="timer">Redirecting you in 5s…</pont2-countdown>
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Host-as-root (the legacy element rendered a `div` inside its tag). Counts
|
|
18
|
+
* down once a second; at zero it fires a **cancelable** `pont2-countdown-end`
|
|
19
|
+
* and, unless a listener prevents it, navigates to `redirect-url`.
|
|
20
|
+
*
|
|
21
|
+
* **Only http(s) URLs are followed.** Render specs are author-editable HTML,
|
|
22
|
+
* so a `javascript:` or `data:` redirect would be script injection; those are
|
|
23
|
+
* refused (the event still fires, with `url: null`). The legacy element
|
|
24
|
+
* assigned `location.href` unconditionally and defaulted to `/`; pont2 has no
|
|
25
|
+
* default: without `redirect-url` it only fires the event.
|
|
26
|
+
*
|
|
27
|
+
* `role="timer"`: assistive technology is not interrupted every second.
|
|
28
|
+
*
|
|
29
|
+
* @tag pont2-countdown
|
|
30
|
+
* @attr duration - seconds (default 5)
|
|
31
|
+
* @attr content - text before the seconds
|
|
32
|
+
* @attr redirect-url - where to go at zero (http/https, relative URLs resolve against the page)
|
|
33
|
+
* @fires pont2-countdown-end - `{ url }`, cancelable: `preventDefault()` stops the redirect
|
|
34
|
+
*/
|
|
35
|
+
export declare class Countdown extends HostElement {
|
|
36
|
+
static identity: string;
|
|
37
|
+
static slotName: string;
|
|
38
|
+
static role: string;
|
|
39
|
+
static composite: boolean;
|
|
40
|
+
static properties: PropertyDeclarations;
|
|
41
|
+
duration: number;
|
|
42
|
+
content: string;
|
|
43
|
+
redirectUrl: string;
|
|
44
|
+
/** Seconds left. */
|
|
45
|
+
remaining: number;
|
|
46
|
+
private timer;
|
|
47
|
+
constructor();
|
|
48
|
+
/** (Re)starts from `duration`. */
|
|
49
|
+
restart(): void;
|
|
50
|
+
private stop;
|
|
51
|
+
private end;
|
|
52
|
+
connectedCallback(): void;
|
|
53
|
+
disconnectedCallback(): void;
|
|
54
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
55
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
56
|
+
}
|
|
57
|
+
declare global {
|
|
58
|
+
interface HTMLElementTagNameMap {
|
|
59
|
+
"pont2-countdown": Countdown;
|
|
60
|
+
}
|
|
61
|
+
interface HTMLElementEventMap {
|
|
62
|
+
"pont2-countdown-end": CustomEvent<CountdownEndDetail>;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PropertyDeclarations } from 'lit';
|
|
2
|
+
import { FieldSeparator } from '../../primitives/field/field';
|
|
3
|
+
/**
|
|
4
|
+
* # `<pont2-divider>`: "Or continue with"
|
|
5
|
+
*
|
|
6
|
+
* ```html
|
|
7
|
+
* <pont2-divider label="Or continue with"></pont2-divider>
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* **Is a FieldSeparator** (`extends FieldSeparator`), as shadcn's login
|
|
11
|
+
* blocks write it (`<FieldSeparator>Or continue with</FieldSeparator>`): one
|
|
12
|
+
* node, the rule halves drawn by the primitive's `::before`/`::after`, the
|
|
13
|
+
* label a text node. Without a label it is a plain rule
|
|
14
|
+
* (`data-content="false"`).
|
|
15
|
+
*
|
|
16
|
+
* @tag pont2-divider
|
|
17
|
+
* @attr label - text in the middle
|
|
18
|
+
*/
|
|
19
|
+
export declare class Divider extends FieldSeparator {
|
|
20
|
+
static composite: boolean;
|
|
21
|
+
static properties: PropertyDeclarations;
|
|
22
|
+
label: string;
|
|
23
|
+
constructor();
|
|
24
|
+
render(): string;
|
|
25
|
+
}
|
|
26
|
+
declare global {
|
|
27
|
+
interface HTMLElementTagNameMap {
|
|
28
|
+
"pont2-divider": Divider;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { PropertyDeclarations } from 'lit';
|
|
2
|
+
import { ActionController } from '../../core/controllers/action';
|
|
3
|
+
import { HostElement } from '../../core/host-element';
|
|
4
|
+
/**
|
|
5
|
+
* # `<pont2-edit-identifier>`: "ada@example.com ✎"
|
|
6
|
+
*
|
|
7
|
+
* The identifier the user entered on the previous step, with a button to go
|
|
8
|
+
* back and change it.
|
|
9
|
+
*
|
|
10
|
+
* ```html
|
|
11
|
+
* <pont2-edit-identifier identifier="ada@example.com" event="change_identifier"></pont2-edit-identifier>
|
|
12
|
+
* → <pont2-edit-identifier data-pont2-edit-identifier data-slot="edit-identifier">
|
|
13
|
+
* <span data-slot="edit-identifier-value">ada@example.com</span>
|
|
14
|
+
* <button data-pont2-button data-variant="ghost" data-size="icon-xs" aria-label="Change ada@example.com" type="button"><svg/></button>
|
|
15
|
+
* </pont2-edit-identifier>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* The button is the button primitive's part and requests `event` through the
|
|
19
|
+
* action protocol (`data: { identifier }`), busy until it settles. The
|
|
20
|
+
* legacy element made the *whole* element a click target and its icon button
|
|
21
|
+
* had no accessible name; here only the button acts, and it is named
|
|
22
|
+
* ("Change ada@example.com", `label` + the identifier).
|
|
23
|
+
*
|
|
24
|
+
* @tag pont2-edit-identifier
|
|
25
|
+
* @attr identifier - the value shown
|
|
26
|
+
* @attr event - the action requested on press
|
|
27
|
+
* @attr label - the button's accessible name prefix (default "Change")
|
|
28
|
+
* @fires pont2-action, pont2-action-success, pont2-action-error
|
|
29
|
+
*/
|
|
30
|
+
export declare class EditIdentifier extends HostElement {
|
|
31
|
+
static identity: string;
|
|
32
|
+
static slotName: string;
|
|
33
|
+
static composite: boolean;
|
|
34
|
+
static properties: PropertyDeclarations;
|
|
35
|
+
identifier: string;
|
|
36
|
+
event: string | undefined;
|
|
37
|
+
label: string;
|
|
38
|
+
protected readonly action: ActionController;
|
|
39
|
+
constructor();
|
|
40
|
+
get control(): HTMLButtonElement | null;
|
|
41
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
42
|
+
}
|
|
43
|
+
declare global {
|
|
44
|
+
interface HTMLElementTagNameMap {
|
|
45
|
+
"pont2-edit-identifier": EditIdentifier;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
|
+
import { HostElement } from '../../core/host-element';
|
|
3
|
+
import { BrandingEntitlements } from '../block/branding';
|
|
4
|
+
import { FlowClient, Layout } from '../layout/layout';
|
|
5
|
+
/**
|
|
6
|
+
* What a widget needs from an auth client: the layout's `processLoginflowEvent`
|
|
7
|
+
* plus `startLoginflow`, and optionally `whenConfigured`. The SDK's `Auth`
|
|
8
|
+
* satisfies it structurally (docs/kit/layout.md, option (b)).
|
|
9
|
+
*/
|
|
10
|
+
export interface WidgetClient extends FlowClient {
|
|
11
|
+
startLoginflow(flowId?: string): Promise<FlowStart>;
|
|
12
|
+
whenConfigured?(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/** The parts of the SDK's `StartLoginflowResponse` a widget reads. */
|
|
15
|
+
export interface FlowStart {
|
|
16
|
+
render_spec?: unknown;
|
|
17
|
+
messages?: Record<string, string>;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/** The parts of the SDK's `FlowStateChangeEvent` a widget reads. */
|
|
21
|
+
export interface FlowStateEvent {
|
|
22
|
+
eventType: string;
|
|
23
|
+
flowType?: string;
|
|
24
|
+
render_spec?: unknown;
|
|
25
|
+
messages?: Record<string, string>;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Feeds the SDK's asynchronous flow-state changes (a resumed flow, a flow an
|
|
30
|
+
* emailed link continued, "continued in another tab") to every connected
|
|
31
|
+
* pont2 flow widget of that `flowType`.
|
|
32
|
+
*
|
|
33
|
+
* The SDK reports them only through the one `onFlowStateChange` callback of
|
|
34
|
+
* `Auth.configure()` (which replaces the whole configuration), so the widget
|
|
35
|
+
* cannot subscribe by itself; the app that configures `Auth` passes this:
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* Auth.configure({ …config, onFlowStateChange: dispatchFlowState });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function dispatchFlowState(event: FlowStateEvent): void;
|
|
42
|
+
/** Text placed in a double-quoted attribute of markup built as a string. */
|
|
43
|
+
export declare function escapeAttr(value: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* # FlowWidget: the base of `<pont2-signin>` / `<pont2-signup>`
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { Auth } from "@pontive/oidc-client";
|
|
49
|
+
* import { dispatchFlowState } from "@pontive/pontkit-core/pont2";
|
|
50
|
+
*
|
|
51
|
+
* Auth.configure({ …, onFlowStateChange: dispatchFlowState });
|
|
52
|
+
* document.querySelector("pont2-signin")!.client = Auth;
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* ```html
|
|
56
|
+
* <pont2-signin data-pont2-flow-widget data-slot="flow-widget" data-state="screen">
|
|
57
|
+
* <pont2-layout>…the current screen…</pont2-layout>
|
|
58
|
+
* </pont2-signin>
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* It **starts the flow** (`client.startLoginflow(flowId)`, after
|
|
62
|
+
* `client.whenConfigured()` when the client has one), renders **one
|
|
63
|
+
* `pont2-layout`** with the screen, the client, the branding entitlements and
|
|
64
|
+
* the flow's localised messages, and keeps it current:
|
|
65
|
+
*
|
|
66
|
+
* - each request's next screen is rendered by the layout itself;
|
|
67
|
+
* - asynchronous changes arrive through `dispatchFlowState` (see above): a new
|
|
68
|
+
* `render_spec`, new `messages`, or `flow_continued_elsewhere`, which shows
|
|
69
|
+
* "You continued in another tab" with a "Continue here instead" link
|
|
70
|
+
* (`continue_here`, handled by the SDK);
|
|
71
|
+
* - "Start again" in the layout (`pont2-layout-restart`), or `restart()`,
|
|
72
|
+
* starts the flow over;
|
|
73
|
+
* - a flow that fails to start shows the error in the layout, restartable.
|
|
74
|
+
*
|
|
75
|
+
* Until the first screen arrives it shows a spinner (`data-state="loading"`).
|
|
76
|
+
*
|
|
77
|
+
* Nesting `pont2-layout` in a kit template is the allow-listed case (docs/10
|
|
78
|
+
* §5 rule 6): the layout is the stateful flow host, one per widget.
|
|
79
|
+
*
|
|
80
|
+
* @prop client - `WidgetClient` (e.g. the SDK's `Auth`); the flow starts once it is set and the widget is connected
|
|
81
|
+
* @prop branding - `BrandingEntitlements` from the backend (attribute-less; fails closed)
|
|
82
|
+
* @attr flow-id - the flow to start (each widget has a default)
|
|
83
|
+
* @fires pont2-flow-response - (from the layout) after every successful request
|
|
84
|
+
*/
|
|
85
|
+
export declare abstract class FlowWidget extends HostElement {
|
|
86
|
+
static identity: string;
|
|
87
|
+
static slotName: string;
|
|
88
|
+
static composite: boolean;
|
|
89
|
+
static properties: PropertyDeclarations;
|
|
90
|
+
client: WidgetClient | undefined;
|
|
91
|
+
branding: BrandingEntitlements;
|
|
92
|
+
flowId: string;
|
|
93
|
+
protected renderSpec: string;
|
|
94
|
+
protected messages: Partial<Record<string, string>>;
|
|
95
|
+
protected starting: boolean;
|
|
96
|
+
protected startError: {
|
|
97
|
+
message: string;
|
|
98
|
+
} | null;
|
|
99
|
+
/** The SDK's `flowType` this widget runs ("signin", "signup"): which flow-state events apply. */
|
|
100
|
+
protected abstract readonly flowType: string;
|
|
101
|
+
private started;
|
|
102
|
+
constructor();
|
|
103
|
+
/** The widget's layout. */
|
|
104
|
+
get layout(): Layout | null;
|
|
105
|
+
/** Starts the flow over. */
|
|
106
|
+
restart(): Promise<void>;
|
|
107
|
+
/** Applies an SDK flow-state change (what `dispatchFlowState` delivers). */
|
|
108
|
+
applyFlowState(event: FlowStateEvent): void;
|
|
109
|
+
private msg;
|
|
110
|
+
private continuedElsewhereSpec;
|
|
111
|
+
private onFlowState;
|
|
112
|
+
connectedCallback(): void;
|
|
113
|
+
disconnectedCallback(): void;
|
|
114
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
115
|
+
protected updated(changed: PropertyValues): void;
|
|
116
|
+
private start;
|
|
117
|
+
/** The flow id used when `flow-id` is not set. */
|
|
118
|
+
protected abstract defaultFlowId(): string;
|
|
119
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* # `<pont2-signin>`: the sign-in widget
|
|
123
|
+
*
|
|
124
|
+
* Runs `sys_signin-flow-passkey` (the legacy default) unless `flow-id` says otherwise.
|
|
125
|
+
*
|
|
126
|
+
* @tag pont2-signin
|
|
127
|
+
*/
|
|
128
|
+
export declare class SignIn extends FlowWidget {
|
|
129
|
+
protected readonly flowType = "signin";
|
|
130
|
+
protected defaultFlowId(): string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* # `<pont2-signup>`: the sign-up widget
|
|
134
|
+
*
|
|
135
|
+
* Runs `sys_signup-flow` (the legacy default) unless `flow-id` says otherwise.
|
|
136
|
+
*
|
|
137
|
+
* @tag pont2-signup
|
|
138
|
+
*/
|
|
139
|
+
export declare class SignUp extends FlowWidget {
|
|
140
|
+
protected readonly flowType = "signup";
|
|
141
|
+
protected defaultFlowId(): string;
|
|
142
|
+
}
|
|
143
|
+
declare global {
|
|
144
|
+
interface HTMLElementTagNameMap {
|
|
145
|
+
"pont2-signin": SignIn;
|
|
146
|
+
"pont2-signup": SignUp;
|
|
147
|
+
}
|
|
148
|
+
interface DocumentEventMap {
|
|
149
|
+
"pont2-flow-state": CustomEvent<FlowStateEvent>;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
|
+
import { HostElement } from '../../core/host-element';
|
|
3
|
+
export type GapType = "vertical" | "horizontal";
|
|
4
|
+
/**
|
|
5
|
+
* # `<pont2-gap>`: a fixed spacer
|
|
6
|
+
*
|
|
7
|
+
* ```html
|
|
8
|
+
* <pont2-gap size="24px"></pont2-gap>
|
|
9
|
+
* → <pont2-gap data-pont2-gap data-type="vertical" style="--pont2-gap-size: 24px"></pont2-gap>
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* The host *is* the spacer (the legacy element rendered a sized `div` inside
|
|
13
|
+
* itself). The size is any CSS length, passed through the `--pont2-gap-size`
|
|
14
|
+
* custom property on the host, so no inline width/height overrides author CSS.
|
|
15
|
+
* Decorative: `aria-hidden`.
|
|
16
|
+
*
|
|
17
|
+
* @tag pont2-gap
|
|
18
|
+
* @attr size - CSS length (default 8px)
|
|
19
|
+
* @attr type - vertical (default: takes height) | horizontal (takes width)
|
|
20
|
+
*/
|
|
21
|
+
export declare class Gap extends HostElement {
|
|
22
|
+
static identity: string;
|
|
23
|
+
static slotName: string;
|
|
24
|
+
static composite: boolean;
|
|
25
|
+
static properties: PropertyDeclarations;
|
|
26
|
+
size: string;
|
|
27
|
+
type: GapType;
|
|
28
|
+
constructor();
|
|
29
|
+
connectedCallback(): void;
|
|
30
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
31
|
+
}
|
|
32
|
+
declare global {
|
|
33
|
+
interface HTMLElementTagNameMap {
|
|
34
|
+
"pont2-gap": Gap;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PropertyDeclarations } from 'lit';
|
|
2
|
+
import { HostElement } from '../../core/host-element';
|
|
3
|
+
export type HeaderAlign = "start" | "center" | "end";
|
|
4
|
+
/**
|
|
5
|
+
* # `<pont2-header>`: the screen's heading group (logo, title, subtitle)
|
|
6
|
+
*
|
|
7
|
+
* ```html
|
|
8
|
+
* <pont2-header>
|
|
9
|
+
* <pont2-logo image-url="/logo.svg"></pont2-logo>
|
|
10
|
+
* <pont2-title content="Welcome back"></pont2-title>
|
|
11
|
+
* <pont2-subtitle content="Login to your Acme Inc account"></pont2-subtitle>
|
|
12
|
+
* </pont2-header>
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* shadcn's login blocks: `<div class="flex flex-col items-center gap-2
|
|
16
|
+
* text-center">`. Tier 1 host-as-root (the legacy element moved its children
|
|
17
|
+
* into an inner `div`); `align` sets both the boxes' and the text's alignment,
|
|
18
|
+
* as the legacy header does. Not a composite: it contains content.
|
|
19
|
+
*
|
|
20
|
+
* @tag pont2-header
|
|
21
|
+
* @attr align - start | center (default) | end
|
|
22
|
+
* @cssprop --pont2-header-gap - default 0.5rem
|
|
23
|
+
*/
|
|
24
|
+
export declare class Header extends HostElement {
|
|
25
|
+
static identity: string;
|
|
26
|
+
static slotName: string;
|
|
27
|
+
static composite: boolean;
|
|
28
|
+
static properties: PropertyDeclarations;
|
|
29
|
+
align: HeaderAlign;
|
|
30
|
+
constructor();
|
|
31
|
+
protected willUpdate(): void;
|
|
32
|
+
}
|
|
33
|
+
declare global {
|
|
34
|
+
interface HTMLElementTagNameMap {
|
|
35
|
+
"pont2-header": Header;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,3 +1,26 @@
|
|
|
1
1
|
export * from './alert/alert';
|
|
2
2
|
export * from './avatar/avatar';
|
|
3
3
|
export * from './input-otp/input-otp';
|
|
4
|
+
export * from './auth-button/auth-button';
|
|
5
|
+
export * from './auth-field/auth-field';
|
|
6
|
+
export * from './auth-field/password-field';
|
|
7
|
+
export * from './otp-field/otp-field';
|
|
8
|
+
export * from './otp-field/otp-resend';
|
|
9
|
+
export * from './link/link';
|
|
10
|
+
export * from './divider/divider';
|
|
11
|
+
export * from './typography/typography';
|
|
12
|
+
export * from './provider-field/provider-field';
|
|
13
|
+
export * from './block/block';
|
|
14
|
+
export * from './watermark/watermark';
|
|
15
|
+
export * from './container/container';
|
|
16
|
+
export * from './header/header';
|
|
17
|
+
export * from './gap/gap';
|
|
18
|
+
export * from './logo/logo';
|
|
19
|
+
export * from './countdown/countdown';
|
|
20
|
+
export * from './edit-identifier/edit-identifier';
|
|
21
|
+
export * from './secret/secret';
|
|
22
|
+
export * from './qr-code/qr-code';
|
|
23
|
+
export * from './recovery-codes/recovery-codes';
|
|
24
|
+
export * from './scope-list/scope-list';
|
|
25
|
+
export * from './layout/layout';
|
|
26
|
+
export * from './flow-widget/flow-widget';
|
|
@@ -2,6 +2,13 @@ import { PropertyDeclarations } from 'lit';
|
|
|
2
2
|
import { InputOTP } from '../../primitives/input-otp/input-otp';
|
|
3
3
|
/** `groupSizes(6, 3)` → `[3, 3]`; `groupSizes(7, 3)` → `[3, 3, 1]`; size ≤ 0 → one group. */
|
|
4
4
|
export declare function groupSizes(length: number, size: number): number[];
|
|
5
|
+
/**
|
|
6
|
+
* The slot structure for `length` characters: groups of `groupSize` (one group
|
|
7
|
+
* when 0), separators between groups when `separator`. Groups and separators
|
|
8
|
+
* are parts; slots are `pont2-prim-input-otp-slot` elements (they have
|
|
9
|
+
* behaviour). Shared with the OTP field (kit/otp-field).
|
|
10
|
+
*/
|
|
11
|
+
export declare function otpGroups(length: number, groupSize: number, separator: boolean): import('lit-html').TemplateResult<1>[];
|
|
5
12
|
/**
|
|
6
13
|
* # `<pont2-input-otp>`: kit composite over `<pont2-prim-input-otp>`
|
|
7
14
|
*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning a failed flow request into words for the user: the legacy
|
|
3
|
+
* `describeFlowError` (src/utils/flow-error.ts), ported (pont2 imports nothing
|
|
4
|
+
* from the legacy kit), with the same English and the same message codes, so
|
|
5
|
+
* a flow's localised `messages` (keyed by code) apply unchanged.
|
|
6
|
+
*/
|
|
7
|
+
export type FlowMessageCode = "connection_failed" | "too_many_attempts" | "server_error" | "generic_error" | "flow_ended" | "passkey_cancelled" | "start_again" | "continued_elsewhere_title" | "continued_elsewhere_subtitle" | "continue_here";
|
|
8
|
+
export declare const FLOW_MESSAGES_EN: Record<FlowMessageCode, string>;
|
|
9
|
+
export interface FlowErrorDescription {
|
|
10
|
+
message: string;
|
|
11
|
+
/** The flow is over (409): offer "Start again". */
|
|
12
|
+
restartable: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* - a cancelled or timed-out WebAuthn prompt (`NotAllowedError` / `AbortError`) → passkey_cancelled
|
|
16
|
+
* - 409 → the server's sentence, else flow_ended; restartable
|
|
17
|
+
* - no response at all (NETWORK_ERROR / TIMEOUT) → connection_failed
|
|
18
|
+
* - 429 → too_many_attempts; ≥ 500 → server_error
|
|
19
|
+
* - anything else → the server's sentence, else generic_error
|
|
20
|
+
*/
|
|
21
|
+
export declare function describeFlowError(error: unknown, messages?: Partial<Record<string, string>>): FlowErrorDescription;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
|
+
import { HostElement } from '../../core/host-element';
|
|
3
|
+
import { BrandingEntitlements } from '../block/branding';
|
|
4
|
+
export { describeFlowError, FLOW_MESSAGES_EN, type FlowErrorDescription, type FlowMessageCode } from './flow-error';
|
|
5
|
+
/**
|
|
6
|
+
* What the layout needs from an auth client: one method. `Auth` from
|
|
7
|
+
* `@pontive/oidc-client` satisfies it structurally, so pont2 never imports an
|
|
8
|
+
* auth client (option (b), docs/kit/layout.md).
|
|
9
|
+
*/
|
|
10
|
+
export interface FlowClient {
|
|
11
|
+
processLoginflowEvent(request: FlowEventRequest): Promise<FlowEventResponse>;
|
|
12
|
+
}
|
|
13
|
+
export interface FlowEventRequest {
|
|
14
|
+
event: string;
|
|
15
|
+
data?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
/** The parts of the SDK's `ProcessEventResponse` the layout reads. */
|
|
18
|
+
export interface FlowEventResponse {
|
|
19
|
+
state?: string;
|
|
20
|
+
render_spec?: unknown;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface UnregisteredElementDetail {
|
|
24
|
+
tag: string;
|
|
25
|
+
}
|
|
26
|
+
/** FormData → the plain object the flow API takes (last value wins, files dropped). */
|
|
27
|
+
export declare function formDataToObject(fd: FormData | undefined | null): Record<string, unknown> | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* # `<pont2-layout>`: renders a flow screen and runs its requests
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { Auth } from "@pontive/oidc-client";
|
|
33
|
+
* const layout = document.createElement("pont2-layout");
|
|
34
|
+
* layout.client = Auth; // anything with processLoginflowEvent()
|
|
35
|
+
* layout.branding = response.branding; // the account's entitlements (fail closed)
|
|
36
|
+
* layout.renderSpec = response.render_spec; // the server's HTML for the screen
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* ```html
|
|
40
|
+
* <pont2-layout data-pont2-layout data-slot="layout">
|
|
41
|
+
* <form data-slot="layout-form" aria-busy="false">
|
|
42
|
+
* …the render spec (e.g. <pont2-block>…</pont2-block>)…
|
|
43
|
+
* </form>
|
|
44
|
+
* </pont2-layout>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* The **flow host** for one screen. It:
|
|
48
|
+
*
|
|
49
|
+
* 1. **renders the spec** (server HTML) inside one native `<form>`, upgrading
|
|
50
|
+
* pont2 elements and reporting tags this bundle does not define
|
|
51
|
+
* (`pont2-unregistered-element` on `document`, once per tag);
|
|
52
|
+
* 2. **answers every `pont2-action`** from inside the screen (submit, provider,
|
|
53
|
+
* passkey, link, OTP, resend, forgot, edit-identifier) with
|
|
54
|
+
* `client.processLoginflowEvent({ event, data })`, where `data` is the
|
|
55
|
+
* form's normalised FormData when the request carries one (submit, OTP
|
|
56
|
+
* auto-submit); while a request is pending, another one joins it (no double
|
|
57
|
+
* submit) and the form is `aria-busy`;
|
|
58
|
+
* 3. **renders the next screen** when a response carries `render_spec`;
|
|
59
|
+
* 4. **shows flow errors** (every `pont2-action-error` from inside) as an
|
|
60
|
+
* error `pont2-alert` banner at the top of the screen, with "Start again"
|
|
61
|
+
* (`pont2-layout-restart`) when the flow is over (409);
|
|
62
|
+
* 5. **provides the branding entitlements** (`pont2:branding` context) to the
|
|
63
|
+
* screen's block. Fails closed: without `branding`, the watermark shows.
|
|
64
|
+
*
|
|
65
|
+
* Trust boundary: the render spec is **server HTML** and is inserted as such
|
|
66
|
+
* (as in the legacy `pont-layout`); everything a user types goes through
|
|
67
|
+
* native inputs, never into markup. The spec must not contain its own
|
|
68
|
+
* `<form>` (the layout's form is the one form).
|
|
69
|
+
*
|
|
70
|
+
* @tag pont2-layout
|
|
71
|
+
* @prop client - `FlowClient` (e.g. the SDK's `Auth`). Without one, actions are not answered.
|
|
72
|
+
* @prop renderSpec - the screen's HTML
|
|
73
|
+
* @prop branding - `BrandingEntitlements` (attribute-less on purpose)
|
|
74
|
+
* @prop messages - localised flow messages by code (the flow's `messages`)
|
|
75
|
+
* @fires pont2-flow-response - `{ action, result }` after every successful request
|
|
76
|
+
* @fires pont2-layout-restart - "Start again" pressed (the widget restarts the flow)
|
|
77
|
+
* @fires pont2-unregistered-element - on `document`, `{ tag }`
|
|
78
|
+
*/
|
|
79
|
+
export declare class Layout extends HostElement {
|
|
80
|
+
static identity: string;
|
|
81
|
+
static slotName: string;
|
|
82
|
+
static composite: boolean;
|
|
83
|
+
static properties: PropertyDeclarations;
|
|
84
|
+
client: FlowClient | undefined;
|
|
85
|
+
renderSpec: string;
|
|
86
|
+
branding: BrandingEntitlements;
|
|
87
|
+
messages: Partial<Record<string, string>>;
|
|
88
|
+
protected busy: boolean;
|
|
89
|
+
private provider;
|
|
90
|
+
private pending;
|
|
91
|
+
constructor();
|
|
92
|
+
/** The layout's form (holds the screen). */
|
|
93
|
+
get form(): HTMLFormElement | null;
|
|
94
|
+
/** Runs one flow request (what a `pont2-action` from inside triggers). */
|
|
95
|
+
run(event: string, data?: Record<string, unknown>): Promise<FlowEventResponse>;
|
|
96
|
+
private onAction;
|
|
97
|
+
private onError;
|
|
98
|
+
/** Shows a flow error at the top of the screen (after its logo/header). */
|
|
99
|
+
showError(message: string, restartable?: boolean): void;
|
|
100
|
+
private clearBanner;
|
|
101
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
102
|
+
protected updated(changed: PropertyValues): void;
|
|
103
|
+
private renderScreen;
|
|
104
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
105
|
+
}
|
|
106
|
+
declare global {
|
|
107
|
+
interface HTMLElementTagNameMap {
|
|
108
|
+
"pont2-layout": Layout;
|
|
109
|
+
}
|
|
110
|
+
interface HTMLElementEventMap {
|
|
111
|
+
"pont2-flow-response": CustomEvent<{
|
|
112
|
+
action: string;
|
|
113
|
+
result: FlowEventResponse;
|
|
114
|
+
}>;
|
|
115
|
+
"pont2-layout-restart": CustomEvent<Record<string, never>>;
|
|
116
|
+
}
|
|
117
|
+
interface DocumentEventMap {
|
|
118
|
+
"pont2-unregistered-element": CustomEvent<UnregisteredElementDetail>;
|
|
119
|
+
}
|
|
120
|
+
}
|