@pontive/pontkit-core 1.38.0 → 1.40.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 (55) hide show
  1. package/catalog.json +1 -1
  2. package/custom-elements.json +1 -1
  3. package/dist/index.js +1410 -1263
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +14296 -12214
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/pont2/core/context-root.d.ts +1 -0
  8. package/dist/pont2/core/events.d.ts +1 -1
  9. package/dist/pont2/core/icons.d.ts +6 -0
  10. package/dist/pont2/core/index.d.ts +1 -0
  11. package/dist/pont2/core/messages.d.ts +21 -0
  12. package/dist/pont2/core/popup/index.d.ts +1 -0
  13. package/dist/pont2/core/popup/modal.d.ts +56 -0
  14. package/dist/pont2/core/popup/popup-content.d.ts +7 -0
  15. package/dist/pont2/core/popup/story-helpers.d.ts +6 -0
  16. package/dist/pont2/custom-elements.json +42860 -18234
  17. package/dist/pont2/index.d.ts +7 -0
  18. package/dist/pont2/index.mjs +4434 -2359
  19. package/dist/pont2/index.mjs.map +1 -1
  20. package/dist/pont2/kit/badge-selector/badge-selector.d.ts +65 -0
  21. package/dist/pont2/kit/consent/consent.d.ts +3 -2
  22. package/dist/pont2/kit/data-table/data-table.d.ts +120 -0
  23. package/dist/pont2/kit/data-table/rows.d.ts +25 -0
  24. package/dist/pont2/kit/flow-widget/flow-widget.d.ts +21 -8
  25. package/dist/pont2/kit/index.d.ts +7 -0
  26. package/dist/pont2/kit/layout/layout.d.ts +7 -0
  27. package/dist/pont2/kit/multi-email-input/emails.d.ts +19 -0
  28. package/dist/pont2/kit/multi-email-input/multi-email-input.d.ts +78 -0
  29. package/dist/pont2/kit/multi-select-filter/multi-select-filter.d.ts +53 -0
  30. package/dist/pont2/kit/pagination/pagination.d.ts +61 -0
  31. package/dist/pont2/kit/pagination/range.d.ts +17 -0
  32. package/dist/pont2/kit/provider/coexistence.d.ts +19 -0
  33. package/dist/pont2/kit/provider/contexts.d.ts +46 -0
  34. package/dist/pont2/kit/provider/provider.d.ts +185 -0
  35. package/dist/pont2/kit/provider/redirect.d.ts +122 -0
  36. package/dist/pont2/kit/provider/runtime-config.d.ts +24 -0
  37. package/dist/pont2/kit/provider/sdk.d.ts +86 -0
  38. package/dist/pont2/kit/provider/signed-in.d.ts +81 -0
  39. package/dist/pont2/kit/provider/widget-messages.d.ts +35 -0
  40. package/dist/pont2/primitives/alert-dialog/alert-dialog.d.ts +132 -0
  41. package/dist/pont2/primitives/combobox/combobox.d.ts +82 -14
  42. package/dist/pont2/primitives/dialog/dialog.d.ts +195 -0
  43. package/dist/pont2/primitives/drawer/drawer.d.ts +112 -0
  44. package/dist/pont2/primitives/hover-card/hover-card.d.ts +83 -0
  45. package/dist/pont2/primitives/pagination/pagination.d.ts +120 -0
  46. package/dist/pont2/primitives/sheet/sheet.d.ts +92 -0
  47. package/dist/pont2/primitives/sonner/sonner.d.ts +86 -0
  48. package/dist/pont2/primitives/sonner/toast-store.d.ts +81 -0
  49. package/dist/pont2/styles.css +1325 -81
  50. package/dist/pont2/theme/tokens.json.d.ts +700 -1
  51. package/dist/pont2/theme-golden.json +85 -43
  52. package/dist/pont2/theme.mjs +119 -119
  53. package/dist/pont2/tokens.json +700 -1
  54. package/dist/styles.css +1325 -81
  55. package/package.json +11 -5
@@ -0,0 +1,185 @@
1
+ import { PropertyDeclarations, PropertyValues } from 'lit';
2
+ import { HostElement } from '../../core/host-element';
3
+ import { AuthState } from './contexts';
4
+ import { AppSdkConfig, ProviderSdk } from './sdk';
5
+ export * from './contexts';
6
+ export * from './coexistence';
7
+ export * from './redirect';
8
+ export * from './sdk';
9
+ export * from './widget-messages';
10
+ /** Detail of `pont2-set-locales` (on `document`) and `pont2-locale-changed`. */
11
+ export interface LocalesDetail {
12
+ locales: string;
13
+ }
14
+ /** Detail of `pont2-redirect`. Cancel it to navigate yourself (a client-side router). */
15
+ export interface RedirectDetail {
16
+ url: string;
17
+ }
18
+ /**
19
+ * # `<pont2-provider>`: configures the auth SDK and provides it to the page
20
+ *
21
+ * ```html
22
+ * <pont2-provider app-id="app_123" domain="auth.acme.com" signin-url="/sign-in" signup-url="/sign-up">
23
+ * <pont2-signed-out><pont2-signin></pont2-signin></pont2-signed-out>
24
+ * <pont2-signed-in>…the app…</pont2-signed-in>
25
+ * </pont2-provider>
26
+ * <script type="module">
27
+ * import { Auth } from "@pontive/oidc-client";
28
+ * document.querySelector("pont2-provider").sdk = Auth; // the one line pont2 can't do for you
29
+ * </script>
30
+ * ```
31
+ *
32
+ * pont2's version of the legacy `pont-provider` (docs/13-provider.md; migration
33
+ * tracker W-1). The SDK is **injected**, never imported. Once it has `sdk`,
34
+ * `domain` and `app-id`, it:
35
+ *
36
+ * - **configures the SDK** (`sdk.configure(…)`), again whenever an input
37
+ * changes. `configure()` replaces the whole configuration, so the app's own
38
+ * options and callbacks go in `config` and are **chained** after the
39
+ * provider's (W-14);
40
+ * - **provides the SDK** to every flow widget inside it as their `client`
41
+ * (`pont2:client`; an explicit `widget.client` wins), with the branding
42
+ * entitlements (`pont2:branding`) and the URL's `login_hint`
43
+ * (`pont2:login-hint`, F-11);
44
+ * - **resolves the auth state**: `restoreSession()`, then `isAuthenticated()`,
45
+ * provided as `pont2:auth` (read by `pont2-signed-in` / `-out`), readable as
46
+ * `.auth`, and announced as `pont2-auth-changed`. A page opened to answer an
47
+ * invitation drops the existing session first;
48
+ * - **redirects** a signed-in user away from the sign-in, sign-up or invitation
49
+ * page (`auto-redirect`, on by default), with the legacy destination rules
50
+ * and redirect-loop protection (`redirect.ts`);
51
+ * - **follows the locale**: `locales`, `setLocale()` or a `pont2-set-locales`
52
+ * event on `document` reconfigure the SDK, fire `pont2-locale-changed` and
53
+ * `restart()` every flow widget it provides for (F-19);
54
+ * - **loads the widgets' own text** (`/auth/v1/widget-messages`, one request
55
+ * per language per page, I-2) and the published **theme**
56
+ * (`/auth/v1/theme.css`; `theme="none"` opts out);
57
+ * - **reads the branding entitlements** from `/auth/v1/runtime-config`, the
58
+ * server's answer from the workspace's plan. There is deliberately no
59
+ * property for them: an app cannot switch the watermark off, and anything
60
+ * but the server saying so keeps it (docs/branding-entitlements.md, T-5).
61
+ *
62
+ * The host adds no box (`display: contents`). Mount **one** provider per page,
63
+ * and never beside the legacy `pont-provider`: both drive the one `Auth` (W-15).
64
+ *
65
+ * @tag pont2-provider
66
+ * @prop sdk - the auth SDK (`Auth` from `@pontive/oidc-client`), injected
67
+ * @prop config - the app's own SDK options and callbacks (`onFlowStateChange`, `onAuthenticated`), chained after the provider's
68
+ * @prop headers - extra request headers for the SDK
69
+ * @prop auth - `AuthState` (read-only): `{ isAuthenticated, resolved }`
70
+ * @attr app-id - the app's id
71
+ * @attr domain - where the auth endpoints answer: a hostname, `/path` on this origin, or a base URL
72
+ * @attr locales - space-separated BCP-47 tags in preference order; empty lets the server negotiate
73
+ * @attr signin-url - the app's sign-in page path
74
+ * @attr signup-url - the app's sign-up page path
75
+ * @attr invitation-url - the app's invitation page path, when it has one
76
+ * @attr signin-redirect-url - where a signed-in user goes from those pages (http(s))
77
+ * @attr continue-here-url - where "Continue here instead" goes (default: `signin-redirect-url`)
78
+ * @attr scope - OAuth scopes every flow asks for (space-separated; replaces the server's default)
79
+ * @attr organization-id - the organization a sign-in starts in
80
+ * @attr api-base-url - the management gateway, for the account widgets (held for them; not an SDK option)
81
+ * @attr login-hint - the identifier to pre-fill (default: the URL's `login_hint`)
82
+ * @attr auto-redirect - `"false"` turns the post-sign-in redirect off (default on)
83
+ * @attr theme - `"none"` opts out of linking the published theme (default: link it)
84
+ * @fires pont2-auth-changed - `AuthState` (a copy), whenever it changes
85
+ * @fires pont2-locale-changed - `{ locales }`, whenever the configured locales change
86
+ * @fires pont2-redirect - `{ url }`, cancelable, before a post-sign-in navigation
87
+ */
88
+ export declare class Provider extends HostElement {
89
+ static identity: string;
90
+ static slotName: string;
91
+ static composite: boolean;
92
+ static properties: PropertyDeclarations;
93
+ sdk: ProviderSdk | undefined;
94
+ config: AppSdkConfig;
95
+ headers: Record<string, string> | undefined;
96
+ appId: string;
97
+ domain: string;
98
+ locales: string;
99
+ signinUrl: string;
100
+ signupUrl: string;
101
+ invitationUrl: string;
102
+ signinRedirectUrl: string;
103
+ continueHereUrl: string;
104
+ scope: string | string[];
105
+ organizationId: string;
106
+ apiBaseUrl: string;
107
+ loginHint: string | undefined;
108
+ autoRedirect: boolean;
109
+ theme: string;
110
+ /** The auth state (read it; the provider writes it). */
111
+ auth: AuthState;
112
+ private authProvider;
113
+ private clientProvider;
114
+ private brandingProvider;
115
+ private hintProvider;
116
+ /** The SDK the auth state was last resolved for: a new one resolves again. */
117
+ private resolvedFor;
118
+ /** The locales of the last configuration (`undefined`: not configured yet). */
119
+ private configuredLocales;
120
+ /** The auth base the branding entitlements were last asked for. */
121
+ private brandingBase;
122
+ /** Bumped per resolution, so only the latest answer is published. */
123
+ private authSeq;
124
+ constructor();
125
+ /** Changes the language: reconfigures the SDK and restarts the flow widgets it provides for. */
126
+ setLocale(locales: string): void;
127
+ /**
128
+ * Reads the auth state from the SDK again (a local check). The SDK has no
129
+ * auth-state subscription (W-14): call this after `Auth.signOut()`,
130
+ * `Auth.switchOrganization()` or anything else that changes the session
131
+ * outside a flow.
132
+ */
133
+ refresh(): void;
134
+ /** The base the auth endpoints hang off, or `null` while `domain` is unset or invalid. */
135
+ get authBaseUrl(): string | null;
136
+ connectedCallback(): void;
137
+ disconnectedCallback(): void;
138
+ protected willUpdate(changed: PropertyValues): void;
139
+ protected updated(changed: PropertyValues): void;
140
+ private inputs;
141
+ private configureSdk;
142
+ /** Every flow widget inside that runs on the provided client (an explicit `client` is the app's). */
143
+ private restartWidgets;
144
+ private onSetLocales;
145
+ /**
146
+ * Asks the authorization server whether this browser is signed in before
147
+ * publishing an answer: an app whose refresh token is an HttpOnly cookie holds
148
+ * nothing locally on a fresh page, so the local answer alone reports every
149
+ * reload as a sign-out. Publishing "signed out" first and correcting it a
150
+ * moment later would flash the signed-out branch for every signed-in user.
151
+ *
152
+ * A page opened with an invitation drops whoever was signed in first: the
153
+ * invitation is for the invitee, and restoring another session would send the
154
+ * page on to the app before the flow ran.
155
+ */
156
+ private resolveAuth;
157
+ private publishAuth;
158
+ /**
159
+ * The SDK can't say when a session ends elsewhere (W-14). When the tab comes
160
+ * back and the local answer has turned to "signed out", ask the server again
161
+ * (a refresh cookie may still hold) before publishing it.
162
+ */
163
+ private onVisible;
164
+ private redirectIfDone;
165
+ /**
166
+ * Links the instance's published theme (`GET {auth}/auth/v1/theme.css`: the
167
+ * host names the instance; an empty 200 when nothing is published;
168
+ * docs/12-theming-integration.md). The same `<link data-pont2-theme="brand">`
169
+ * that `linkTheme()` writes, so the two never stack.
170
+ */
171
+ private linkTheme;
172
+ }
173
+ declare global {
174
+ interface HTMLElementTagNameMap {
175
+ "pont2-provider": Provider;
176
+ }
177
+ interface HTMLElementEventMap {
178
+ "pont2-auth-changed": CustomEvent<AuthState>;
179
+ "pont2-locale-changed": CustomEvent<LocalesDetail>;
180
+ "pont2-redirect": CustomEvent<RedirectDetail>;
181
+ }
182
+ interface DocumentEventMap {
183
+ "pont2-set-locales": CustomEvent<LocalesDetail>;
184
+ }
185
+ }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Where `<pont2-provider>` sends the browser once someone is signed in, and how
3
+ * it notices that the destination sent them straight back.
4
+ *
5
+ * A port of the legacy rules (`src/utils/post-auth-destination.ts` and the
6
+ * provider's `wasBouncedBackFrom`), as pure functions with injected browser
7
+ * state so they are unit-tested in Node. pont2 may not import `src/`
8
+ * (guardrail), so the code is copied, with its tests (docs/13-provider.md §3).
9
+ *
10
+ * **One change from the legacy kit (a security fix).** The legacy provider
11
+ * assigned `?redirect_url=` to `window.location` unchecked, so a link could send
12
+ * a freshly signed-in user to `javascript:` or to any site (hosted login strips
13
+ * the parameter for that reason). Here the query's `redirect_url` is honoured
14
+ * only when it is on the page's own origin, and the configured
15
+ * `signinRedirectUrl` only when it is http(s). Anything else is ignored, as if
16
+ * it had not been given.
17
+ */
18
+ /** The configuration the destination depends on. */
19
+ export interface PostAuthEnv {
20
+ signinUrl?: string;
21
+ signupUrl?: string;
22
+ invitationUrl?: string;
23
+ signinRedirectUrl?: string;
24
+ }
25
+ export interface PostAuthPage {
26
+ /** The page's path, e.g. `location.pathname`. */
27
+ pathname: string;
28
+ /** The page's query, e.g. `location.search`. */
29
+ search: string;
30
+ /** The page's origin, e.g. `location.origin`. Relative targets resolve against it. */
31
+ origin: string;
32
+ env: PostAuthEnv;
33
+ }
34
+ /**
35
+ * Where to send the browser once a flow has authenticated someone, or `null`
36
+ * to stay put.
37
+ *
38
+ * - On the sign-in, sign-up or invitation page: to the target, else `/`.
39
+ * - On any other page opened to answer an invitation (`?invite_token=`): to the
40
+ * target if there is one. Without one, staying put is better than sending the
41
+ * app's own page to `/`.
42
+ * - Anywhere else: nowhere. The app decides.
43
+ *
44
+ * The target is the query's `redirect_url` (same origin only), else
45
+ * `env.signinRedirectUrl` (http(s) only).
46
+ */
47
+ export declare function postAuthDestination({ pathname, search, origin, env }: PostAuthPage): string | null;
48
+ /**
49
+ * Whether the page was opened to answer an invitation: its query carries the
50
+ * token an invitation link does. Any page mounting a widget can be one.
51
+ */
52
+ export declare function answersInvitation(search: string): boolean;
53
+ /**
54
+ * The identifier the page was opened with as OpenID Connect's `login_hint`, or
55
+ * `undefined`. `/oauth2/authorize` forwards an app's hint to the hosted pages,
56
+ * and an accepted invitation sends the invitee to the app's sign-in page with
57
+ * the address it was sent to. It only pre-fills: nothing is trusted because of
58
+ * it (legacy `src/utils/login-hint.ts`, ported; migration tracker F-11).
59
+ */
60
+ export declare function loginHint(search: string | undefined): string | undefined;
61
+ /**
62
+ * The browser state the loop protection reads, injectable for tests.
63
+ *
64
+ * - `storage`: sessionStorage, not localStorage. A redirect is one navigation
65
+ * in one tab: the marker must not outlive the tab, nor be seen by a second tab
66
+ * signing in on its own.
67
+ * - `navigationType`: how the browser reached this page (Navigation Timing).
68
+ */
69
+ export interface RedirectGuardEnv {
70
+ storage: Pick<Storage, "getItem" | "setItem" | "removeItem"> | null;
71
+ now: () => number;
72
+ navigationType: () => string;
73
+ }
74
+ /** The marker's key. Not the legacy kit's: the two providers never share a page (W-15). */
75
+ export declare const REDIRECT_ATTEMPT_KEY = "pont2_auth_redirect_attempt";
76
+ /**
77
+ * How recently a redirect must have been attempted for a return to count as a
78
+ * bounce. A bounce is two server round trips, so seconds at most; minutes later
79
+ * is a new visit.
80
+ */
81
+ export declare const REDIRECT_BOUNCE_WINDOW_MS = 10000;
82
+ /** The page's own browser state (sessionStorage, Date.now, Navigation Timing). */
83
+ export declare function browserGuardEnv(): RedirectGuardEnv;
84
+ /** Notes that the browser is being sent to `target`. */
85
+ export declare function recordRedirectAttempt(target: string, env: RedirectGuardEnv): void;
86
+ /** Forgets the marker. */
87
+ export declare function clearRedirectAttempt(env: RedirectGuardEnv): void;
88
+ /**
89
+ * Whether we are here because `target` sent us back. Three things must hold,
90
+ * each ruling out an arrival that looks like a bounce but isn't:
91
+ *
92
+ * - a redirect to **this** target was recorded;
93
+ * - it was **recent** (within `REDIRECT_BOUNCE_WINDOW_MS`);
94
+ * - the browser **navigated** here. Back (`back_forward`) or a reload right
95
+ * after a successful sign-in leaves the same marker, and signing that user out
96
+ * would be worse than the loop. A server redirect chain is always `navigate`.
97
+ *
98
+ * The marker is consumed either way, so a stale one can't go on counting.
99
+ */
100
+ export declare function wasBouncedBackFrom(target: string, env: RedirectGuardEnv): boolean;
101
+ /** What the provider does about a signed-in user on this page. */
102
+ export type RedirectDecision = {
103
+ kind: "stay";
104
+ }
105
+ /** The destination refused the session and sent us back: drop it and show the sign-in form. */
106
+ | {
107
+ kind: "bounced";
108
+ target: string;
109
+ } | {
110
+ kind: "go";
111
+ target: string;
112
+ };
113
+ /**
114
+ * The whole post-sign-in decision. `isAuthenticated()` is a local check (memory
115
+ * and an expiry time), while the destination decides the same question with the
116
+ * server's knowledge (a revoked session, `prompt=login`). When they disagree,
117
+ * redirecting on the local answer is an infinite loop, so the server wins:
118
+ * `bounced` means drop the stale session and let the sign-in form render.
119
+ *
120
+ * A `go` decision has already recorded its attempt.
121
+ */
122
+ export declare function decideRedirect(page: PostAuthPage, guard: RedirectGuardEnv): RedirectDecision;
@@ -0,0 +1,24 @@
1
+ import { BrandingEntitlements } from '../block/branding';
2
+ /**
3
+ * The instance's branding entitlements, read by `<pont2-provider>` from
4
+ * `GET {auth}/auth/v1/runtime-config` (`branding: { show_watermark }`, pontive-spec
5
+ * 21 §9.1, 18 "Branding entitlement"; migration tracker T-5).
6
+ *
7
+ * The answer is the server's: resolved from the workspace's plan, never from
8
+ * anything the page or the app supplies (docs/branding-entitlements.md). It
9
+ * **fails closed**: a failed read, an older backend without the field, or any
10
+ * value but `false` keeps the watermark.
11
+ *
12
+ * One request per auth base per page: the provider configures itself more than
13
+ * once, and every configuration asks.
14
+ */
15
+ type Fetch = (url: string, init?: RequestInit) => Promise<Pick<Response, "ok" | "json">>;
16
+ /** The runtime-config URL for an auth base. */
17
+ export declare function runtimeConfigUrl(authBaseUrl: string): string;
18
+ /** The entitlements for an auth base (once per base). Never rejects. */
19
+ export declare function loadBrandingEntitlements(authBaseUrl: string, fetchImpl?: Fetch): Promise<BrandingEntitlements>;
20
+ /** The entitlements a runtime-config body grants: only an explicit `false` hides the watermark. */
21
+ export declare function brandingFrom(body: unknown): BrandingEntitlements;
22
+ /** Forgets every answer. For tests and stories. */
23
+ export declare function resetBrandingEntitlements(): void;
24
+ export {};
@@ -0,0 +1,86 @@
1
+ import { FlowStateEvent, WidgetClient } from '../flow-widget/flow-widget';
2
+ /**
3
+ * What `<pont2-provider>` needs from the auth SDK, structurally. The SDK's
4
+ * `Auth` (`@pontive/oidc-client`) satisfies it as-is, which
5
+ * `flow-widget/sdk-compat.test.ts` pins against the real types. pont2 never
6
+ * imports the SDK: the app injects it (`provider.sdk = Auth`, docs/13-provider.md).
7
+ *
8
+ * No index signatures, on purpose: they are what made `Auth` fail to type-check
9
+ * as a `WidgetClient` before (migration tracker W-13).
10
+ */
11
+ export interface ProviderSdk extends WidgetClient {
12
+ /** Replaces the whole configuration (it does not merge). */
13
+ configure(config: ProviderSdkConfig): void;
14
+ /** Turns an HttpOnly refresh cookie back into a session. Resolves null when there is none. */
15
+ restoreSession(): Promise<unknown>;
16
+ /** A local check: memory and an expiry time. */
17
+ isAuthenticated(): boolean;
18
+ /** Drops the stored session without reloading or tearing the flow machinery down. */
19
+ invalidateSession(): void;
20
+ }
21
+ /** The parts of the SDK's `ConfigOptions` the provider writes. */
22
+ export interface ProviderSdkConfig {
23
+ domain: string;
24
+ appId: string;
25
+ signinUrl: string;
26
+ signupUrl: string;
27
+ invitationUrl?: string;
28
+ locales?: string;
29
+ headers?: Record<string, string>;
30
+ scope?: string | string[];
31
+ organizationId?: string;
32
+ continueHereUrl?: string;
33
+ onFlowStateChange?: (event: FlowStateEvent) => void;
34
+ onAuthenticated?: (session: unknown) => void;
35
+ }
36
+ /** What the app passes through `provider.config`: anything the SDK takes, and its own callbacks. */
37
+ export type AppSdkConfig = Partial<ProviderSdkConfig>;
38
+ /** The provider's own inputs (its attributes and properties). Empty values are "not given". */
39
+ export interface ProviderInputs {
40
+ domain: string;
41
+ appId: string;
42
+ locales?: string;
43
+ signinUrl?: string;
44
+ signupUrl?: string;
45
+ invitationUrl?: string;
46
+ signinRedirectUrl?: string;
47
+ continueHereUrl?: string;
48
+ scope?: string | string[];
49
+ headers?: Record<string, string>;
50
+ organizationId?: string;
51
+ }
52
+ /** The provider's own reactions to the SDK's two callbacks. */
53
+ export interface ProviderHooks {
54
+ onFlowStateChange(event: FlowStateEvent): void;
55
+ onAuthenticated(session: unknown): void;
56
+ }
57
+ /**
58
+ * The configuration the provider passes to `sdk.configure()`.
59
+ *
60
+ * `configure()` **replaces** the SDK's whole configuration, and the SDK has only
61
+ * these two callbacks, so whoever configures last owns them (migration tracker
62
+ * W-14). An app that needs either passes it in `provider.config`, and the
63
+ * provider **chains** it: its own reaction first, then the app's. A throwing
64
+ * callback is reported and never stops the other one.
65
+ *
66
+ * Precedence: the provider's non-empty inputs, over `app` (anything else the
67
+ * SDK takes, such as an option this interface doesn't name yet), over the
68
+ * required defaults (`signinUrl` / `signupUrl` empty). `continueHereUrl`
69
+ * defaults to `signinRedirectUrl`, as in the legacy provider.
70
+ *
71
+ * Note that passing `onAuthenticated` at all replaces the SDK's default (a page
72
+ * reload). The provider always passes one, because it refreshes the auth state
73
+ * in place, as the legacy provider does.
74
+ */
75
+ export declare function buildSdkConfig(inputs: ProviderInputs, own: ProviderHooks, app?: AppSdkConfig): ProviderSdkConfig;
76
+ /**
77
+ * The base the auth endpoints hang off, as an absolute URL without a trailing
78
+ * slash, or `null` when `domain` can't be resolved.
79
+ *
80
+ * A port of the SDK's `resolveAuthBaseUrl`, which is a module export and not a
81
+ * method of `Auth`, so it can't be injected with it (docs/13-provider.md §3).
82
+ * The three shapes: a hostname (`tenant.idp.us.pontive.app`, `https://`, or
83
+ * `http://` for loopback), a path on the page's origin (`/__pontive`), or a full
84
+ * base URL. Query and fragment are dropped.
85
+ */
86
+ export declare function authBaseUrl(domain: string | undefined, pageOrigin?: string): string | null;
@@ -0,0 +1,81 @@
1
+ import { PropertyValues } from 'lit';
2
+ import { HostElement } from '../../core/host-element';
3
+ import { AuthState } from './contexts';
4
+ /**
5
+ * # AuthGate: the base of `<pont2-signed-in>` / `<pont2-signed-out>`
6
+ *
7
+ * ```html
8
+ * <pont2-provider …>
9
+ * <pont2-signed-out><pont2-signin></pont2-signin></pont2-signed-out>
10
+ * <pont2-signed-in><a href="/account">Your account</a></pont2-signed-in>
11
+ * </pont2-provider>
12
+ * ```
13
+ *
14
+ * Shows its children for one answer of the provider's auth state
15
+ * (`pont2:auth`), and holds them **detached** otherwise, so that a widget inside
16
+ * the branch that doesn't apply never connects: a `pont2-signin` in
17
+ * `pont2-signed-out` never starts a flow for a signed-in user (migration tracker
18
+ * W-2).
19
+ *
20
+ * - **Nothing until the provider has asked** (`resolved`): its interim answer is
21
+ * "signed out", so either branch would flash for some users on every load.
22
+ * Without a provider it stays closed.
23
+ * - **No wrapper:** the children go back exactly where the author wrote them,
24
+ * as the host's own children, and the host adds no box (`display: contents`).
25
+ * (The legacy elements re-rendered them inside a `<div>` of their own.)
26
+ * - **A placeholder:** a direct child `[part="fallback"]` stays while the answer
27
+ * is pending and is removed once it arrives, the widgets' contract (F-17).
28
+ * - `data-state`: `pending`, `open` or `closed`.
29
+ *
30
+ * **Framework hosts** (React) should branch on the provider's
31
+ * `pont2-auth-changed` event instead, as the pontkit bindings do: an element
32
+ * that detaches children takes them away from a framework that still thinks it
33
+ * owns them.
34
+ */
35
+ export declare abstract class AuthGate extends HostElement {
36
+ static identity: string;
37
+ static composite: boolean;
38
+ private consumer;
39
+ /** The children held while closed, in order. */
40
+ private held;
41
+ /** Catches children a host adds while the gate is closed. */
42
+ private observer;
43
+ /** Whether this gate opens for `auth` (only asked once `auth.resolved`). */
44
+ protected abstract opensFor(auth: AuthState): boolean;
45
+ /** The auth state the gate is following. */
46
+ get auth(): AuthState;
47
+ /** Whether the children are shown. */
48
+ get open(): boolean;
49
+ connectedCallback(): void;
50
+ disconnectedCallback(): void;
51
+ protected updated(_changed: PropertyValues): void;
52
+ private apply;
53
+ /** Detaches every child but the pending placeholder. */
54
+ private hold;
55
+ }
56
+ /**
57
+ * # `<pont2-signed-in>`: shown once the provider knows someone is signed in
58
+ *
59
+ * @tag pont2-signed-in
60
+ */
61
+ export declare class SignedIn extends AuthGate {
62
+ static identity: string;
63
+ static slotName: string;
64
+ protected opensFor(auth: AuthState): boolean;
65
+ }
66
+ /**
67
+ * # `<pont2-signed-out>`: shown once the provider knows nobody is signed in
68
+ *
69
+ * @tag pont2-signed-out
70
+ */
71
+ export declare class SignedOut extends AuthGate {
72
+ static identity: string;
73
+ static slotName: string;
74
+ protected opensFor(auth: AuthState): boolean;
75
+ }
76
+ declare global {
77
+ interface HTMLElementTagNameMap {
78
+ "pont2-signed-in": SignedIn;
79
+ "pont2-signed-out": SignedOut;
80
+ }
81
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The signed-in widgets' own text (account menu, account settings, organization
3
+ * switcher, member management), which no flow response carries: `<pont2-provider>`
4
+ * reads it from `GET {auth}/auth/v1/widget-messages?locales=…` and hands it to
5
+ * the page's message table (`setMessages`, core/messages.ts). A port of the
6
+ * legacy `loadWidgetMessages` (carry-over §3, migration tracker I-2).
7
+ *
8
+ * **One request per language per page.** The provider configures itself more
9
+ * than once (its inputs, then its locales, settle), and every configuration
10
+ * asks. A URL already asked, or being asked, is not asked again: its answer is
11
+ * kept and applied again, so switching back to a language already loaded
12
+ * restores its text without a request. (The legacy loader remembered only the
13
+ * last URL, so en → de → en asked for English twice.)
14
+ *
15
+ * A failed read is forgotten, so the next configuration can try again. A
16
+ * stopped instance refuses this read too, with its one sentence in the page's
17
+ * language (carry-over §6): that sentence is kept (`rememberUnavailable`).
18
+ */
19
+ /** The read's answer: the language it was served in, and its messages by code. */
20
+ export interface WidgetMessages {
21
+ locale?: string;
22
+ messages?: Record<string, string>;
23
+ }
24
+ type Fetch = (url: string, init?: RequestInit) => Promise<Pick<Response, "ok" | "json">>;
25
+ /** The widget-messages URL for an auth base and a language preference. */
26
+ export declare function widgetMessagesUrl(authBaseUrl: string, locales?: string): string;
27
+ /**
28
+ * Loads (once per URL) and applies the widget messages. Resolves when they are
29
+ * in the message table, or when the read failed (the page keeps English, or
30
+ * whatever it was last served in). Never rejects.
31
+ */
32
+ export declare function loadWidgetMessages(authBaseUrl: string, locales?: string, fetchImpl?: Fetch): Promise<void>;
33
+ /** Forgets every answer. For tests and stories. */
34
+ export declare function resetWidgetMessages(): void;
35
+ export {};
@@ -0,0 +1,132 @@
1
+ import { PropertyDeclarations, PropertyValues } from 'lit';
2
+ import { HostElement } from '../../core/host-element';
3
+ import { Pont2Button } from '../button/button';
4
+ import { ModalContent, ModalRoot, ModalTitle, ModalTrigger } from '../dialog/dialog';
5
+ /**
6
+ * # AlertDialog
7
+ *
8
+ * shadcn: `<AlertDialog>` (Base UI `AlertDialog.Root`) > `<AlertDialogTrigger>`
9
+ * + `<AlertDialogContent size>` (Portal > Overlay + Popup) with
10
+ * `AlertDialogHeader/Media/Title/Description/Footer/Action/Cancel`.
11
+ *
12
+ * A Dialog (dialog.ts) that interrupts: `role=alertdialog`, always modal, and
13
+ * **a press outside does not close it** (Base UI). Escape and Cancel do.
14
+ * `AlertDialogAction` is a plain button (shadcn's is a `<Button>`, not a
15
+ * Close): the app decides when the dialog closes, so an action that can fail
16
+ * keeps the dialog open to show the error.
17
+ *
18
+ * ```html
19
+ * <pont2-prim-alert-dialog>
20
+ * <pont2-prim-alert-dialog-trigger><button data-pont2-button data-variant="outline">Remove member</button></pont2-prim-alert-dialog-trigger>
21
+ * <pont2-prim-alert-dialog-content>
22
+ * <pont2-prim-alert-dialog-header>
23
+ * <pont2-prim-alert-dialog-title>Remove this member?</pont2-prim-alert-dialog-title>
24
+ * <pont2-prim-alert-dialog-description>They lose access immediately.</pont2-prim-alert-dialog-description>
25
+ * </pont2-prim-alert-dialog-header>
26
+ * <pont2-prim-alert-dialog-footer>
27
+ * <pont2-prim-alert-dialog-cancel><button>Cancel</button></pont2-prim-alert-dialog-cancel>
28
+ * <pont2-prim-alert-dialog-action variant="destructive"><button>Remove</button></pont2-prim-alert-dialog-action>
29
+ * </pont2-prim-alert-dialog-footer>
30
+ * </pont2-prim-alert-dialog-content>
31
+ * </pont2-prim-alert-dialog>
32
+ * ```
33
+ *
34
+ * @tag pont2-prim-alert-dialog
35
+ * @attr open
36
+ * @fires pont2-open-change - cancelable, `{ open, reason }`
37
+ */
38
+ export declare class AlertDialog extends ModalRoot {
39
+ static identity: string;
40
+ static family: string;
41
+ constructor();
42
+ protected get dismissOnOutsidePress(): boolean;
43
+ /** An alert dialog is always modal (Base UI has no `modal` prop on it). */
44
+ protected willUpdate(changed: PropertyValues): void;
45
+ }
46
+ /** @tag pont2-prim-alert-dialog-trigger */
47
+ export declare class AlertDialogTrigger extends ModalTrigger {
48
+ static rootTag: string;
49
+ static controlSlot: string;
50
+ }
51
+ /**
52
+ * The popup (`role=alertdialog`), no corner close button.
53
+ *
54
+ * @tag pont2-prim-alert-dialog-content
55
+ * @attr size - default | sm
56
+ * @cssprop --pont2-alert-dialog-bg, --pont2-alert-dialog-fg, --pont2-alert-dialog-border-color, --pont2-alert-dialog-radius - see docs/11-tokens.md
57
+ * @cssprop --pont2-alert-dialog-max-width, --pont2-alert-dialog-sm-max-width, --pont2-alert-dialog-padding-x, --pont2-alert-dialog-padding-y, --pont2-alert-dialog-gap - sizes
58
+ * @cssprop --pont2-alert-dialog-overlay-bg - the overlay colour
59
+ */
60
+ export declare class AlertDialogContent extends ModalContent {
61
+ static identity: string;
62
+ static slotName: string;
63
+ static role: string;
64
+ static family: string;
65
+ static closeButton: boolean;
66
+ static properties: PropertyDeclarations;
67
+ size: "default" | "sm";
68
+ constructor();
69
+ protected willUpdate(changed: PropertyValues): void;
70
+ }
71
+ /** @tag pont2-prim-alert-dialog-header */
72
+ export declare class AlertDialogHeader extends HostElement {
73
+ static identity: string;
74
+ static slotName: string;
75
+ }
76
+ /** @tag pont2-prim-alert-dialog-footer */
77
+ export declare class AlertDialogFooter extends HostElement {
78
+ static identity: string;
79
+ static slotName: string;
80
+ }
81
+ /** An icon tile beside (default size) or above (sm) the title. @tag pont2-prim-alert-dialog-media */
82
+ export declare class AlertDialogMedia extends HostElement {
83
+ static identity: string;
84
+ static slotName: string;
85
+ }
86
+ /** @tag pont2-prim-alert-dialog-title */
87
+ export declare class AlertDialogTitle extends ModalTitle {
88
+ static identity: string;
89
+ static slotName: string;
90
+ }
91
+ /** @tag pont2-prim-alert-dialog-description */
92
+ export declare class AlertDialogDescription extends HostElement {
93
+ static identity: string;
94
+ static slotName: string;
95
+ }
96
+ /**
97
+ * shadcn `AlertDialogAction`: a Button (the button enhancer, so `variant` and
98
+ * `size` work) that does **not** close the dialog by itself. Listen for
99
+ * `click`, do the work, then set `open = false`.
100
+ *
101
+ * @tag pont2-prim-alert-dialog-action
102
+ * @attr variant, size, disabled - the Button's
103
+ */
104
+ export declare class AlertDialogAction extends Pont2Button {
105
+ protected apply(control: HTMLButtonElement | HTMLAnchorElement): void;
106
+ }
107
+ /**
108
+ * shadcn `AlertDialogCancel`: Base UI `AlertDialog.Close` rendered as an
109
+ * outline Button. Closes the dialog (`reason: "close-press"`).
110
+ *
111
+ * @tag pont2-prim-alert-dialog-cancel
112
+ * @attr variant - default outline
113
+ * @attr size
114
+ */
115
+ export declare class AlertDialogCancel extends Pont2Button {
116
+ constructor();
117
+ protected apply(control: HTMLButtonElement | HTMLAnchorElement): void;
118
+ }
119
+ declare global {
120
+ interface HTMLElementTagNameMap {
121
+ "pont2-prim-alert-dialog": AlertDialog;
122
+ "pont2-prim-alert-dialog-trigger": AlertDialogTrigger;
123
+ "pont2-prim-alert-dialog-content": AlertDialogContent;
124
+ "pont2-prim-alert-dialog-header": AlertDialogHeader;
125
+ "pont2-prim-alert-dialog-footer": AlertDialogFooter;
126
+ "pont2-prim-alert-dialog-media": AlertDialogMedia;
127
+ "pont2-prim-alert-dialog-title": AlertDialogTitle;
128
+ "pont2-prim-alert-dialog-description": AlertDialogDescription;
129
+ "pont2-prim-alert-dialog-action": AlertDialogAction;
130
+ "pont2-prim-alert-dialog-cancel": AlertDialogCancel;
131
+ }
132
+ }