@pontive/pontkit-core 1.34.0 → 1.35.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/i18n/messages.d.ts +1 -1
- package/dist/index.js +389 -389
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2566 -2539
- package/dist/index.mjs.map +1 -1
- package/dist/pont2/core/index.d.ts +2 -0
- package/dist/pont2/core/messages.d.ts +71 -0
- package/dist/pont2/core/url.d.ts +19 -0
- package/dist/pont2/index.mjs +1677 -1423
- package/dist/pont2/index.mjs.map +1 -1
- package/dist/pont2/kit/auth-field/password-field.d.ts +4 -1
- package/dist/pont2/kit/consent/consent-api.d.ts +53 -0
- package/dist/pont2/kit/consent/consent.d.ts +83 -0
- package/dist/pont2/kit/countdown/countdown.d.ts +2 -2
- package/dist/pont2/kit/flow-widget/flow-widget.d.ts +37 -6
- package/dist/pont2/kit/index.d.ts +1 -0
- package/dist/pont2/kit/layout/flow-error.d.ts +24 -1
- package/dist/pont2/kit/layout/layout.d.ts +9 -2
- package/dist/pont2/kit/link/link.d.ts +43 -4
- package/dist/pont2/styles.css +33 -2
- package/dist/utils/instance-unavailable.d.ts +19 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { nothing, PropertyDeclarations, TemplateResult } from 'lit';
|
|
2
2
|
import { ActionController } from '../../core/controllers/action';
|
|
3
|
+
import { MessagesController } from '../../core/messages';
|
|
3
4
|
import { InputOptions } from '../../primitives/input/input';
|
|
4
5
|
import { AuthField, FieldIssue } from './auth-field';
|
|
5
6
|
export type PasswordRuleName = "uppercase" | "lowercase" | "number" | "special";
|
|
@@ -35,7 +36,7 @@ export type SecretFieldVariant = "toggle" | "simple";
|
|
|
35
36
|
* never normalised.
|
|
36
37
|
*
|
|
37
38
|
* @attr variant - toggle (default) | simple
|
|
38
|
-
* @attr show-label - the toggle's accessible name (default "Show password")
|
|
39
|
+
* @attr show-label - the toggle's accessible name (default: the `show_password` message, "Show password" in English)
|
|
39
40
|
*/
|
|
40
41
|
export declare abstract class SecretField extends AuthField {
|
|
41
42
|
static properties: PropertyDeclarations;
|
|
@@ -43,6 +44,8 @@ export declare abstract class SecretField extends AuthField {
|
|
|
43
44
|
showLabel: string;
|
|
44
45
|
/** Whether the value is currently shown as text. */
|
|
45
46
|
revealed: boolean;
|
|
47
|
+
/** Re-renders when the page's message table changes (the toggle's name). */
|
|
48
|
+
protected readonly messagesController: MessagesController;
|
|
46
49
|
constructor();
|
|
47
50
|
protected inputType(): "text" | "password";
|
|
48
51
|
protected inputAttrs(): {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The consent screen's two calls to auth-api (pontive-spec 40 §4.3), ported
|
|
3
|
+
* from the legacy `pont-consent` (carry-over §8).
|
|
4
|
+
*
|
|
5
|
+
* Plain `fetch` rather than the auth SDK: the screen is not an auth flow. The
|
|
6
|
+
* person already has a session, and the session cookie is what proves the
|
|
7
|
+
* consent request is theirs, so every call is same-origin and carries it.
|
|
8
|
+
*
|
|
9
|
+
* GET {base}/auth/v1/consent/{id}?locales=… → { render_spec, locale?, dir? }
|
|
10
|
+
* POST {base}/auth/v1/consent/{id} { event, data } → { redirect_to } | a view to render
|
|
11
|
+
*
|
|
12
|
+
* Errors use the platform envelope `{ error: { code, message } }` (or flat).
|
|
13
|
+
* A 404 means the request expired, was already answered, or isn't this
|
|
14
|
+
* session's; the server doesn't say which, and the way on is the same.
|
|
15
|
+
*/
|
|
16
|
+
/** What `GET /auth/v1/consent/{id}` answers, and a re-rendered screen. */
|
|
17
|
+
export interface ConsentView {
|
|
18
|
+
render_spec: string;
|
|
19
|
+
locale?: string;
|
|
20
|
+
dir?: string;
|
|
21
|
+
}
|
|
22
|
+
/** What `POST /auth/v1/consent/{id}` answers. */
|
|
23
|
+
export type ConsentOutcome = {
|
|
24
|
+
redirect_to: string;
|
|
25
|
+
} | ConsentView;
|
|
26
|
+
/** A refused or failed consent call, shaped as `describeFlowError` reads one (`status`, `code`, `message`). */
|
|
27
|
+
export declare class ConsentError extends Error {
|
|
28
|
+
readonly code: string;
|
|
29
|
+
readonly status?: number | undefined;
|
|
30
|
+
constructor(message: string, code: string, status?: number | undefined);
|
|
31
|
+
}
|
|
32
|
+
/** The person-facing sentence for an expired request (a 404). */
|
|
33
|
+
export declare const CONSENT_EXPIRED_EN = "This request has expired. Go back to the app and try again.";
|
|
34
|
+
/** `consent_expired` from the page's message table, else English. */
|
|
35
|
+
export declare const consentExpired: () => string;
|
|
36
|
+
export declare function consentEndpoint(baseUrl: string, id: string): string;
|
|
37
|
+
/** Loads the screen for a consent request. */
|
|
38
|
+
export declare function fetchConsent(baseUrl: string, id: string, options?: {
|
|
39
|
+
locales?: string;
|
|
40
|
+
}): Promise<ConsentView>;
|
|
41
|
+
/**
|
|
42
|
+
* Answers a consent request: `allow` with the ticked scopes (`data.scope`, one
|
|
43
|
+
* space-separated string, which auth-api requires), or `deny`. A 404 is reworded
|
|
44
|
+
* as the expired-request sentence, so the layout's banner shows it as is.
|
|
45
|
+
*/
|
|
46
|
+
export declare function submitConsent(baseUrl: string, id: string, event: string, data?: Record<string, unknown>): Promise<ConsentOutcome>;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the browser may be sent to a `redirect_to`. It is the app's
|
|
49
|
+
* registered redirect URI, which may be a native app's custom scheme
|
|
50
|
+
* (`com.example.app:/callback`), so this is not limited to http(s); it only
|
|
51
|
+
* refuses the schemes that run code or read local data in this page.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isNavigableRedirect(url: string, base?: string): boolean;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { nothing, PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
|
+
import { HostElement } from '../../core/host-element';
|
|
3
|
+
import { MessagesController } from '../../core/messages';
|
|
4
|
+
import { BrandingEntitlements } from '../block/branding';
|
|
5
|
+
import { FlowClient, Layout } from '../layout/layout';
|
|
6
|
+
export { CONSENT_EXPIRED_EN, ConsentError, consentEndpoint, consentExpired, fetchConsent, isNavigableRedirect, submitConsent, type ConsentOutcome, type ConsentView, } from './consent-api';
|
|
7
|
+
/**
|
|
8
|
+
* # `<pont2-consent>`: an app asks for access; the person allows or denies
|
|
9
|
+
*
|
|
10
|
+
* ```html
|
|
11
|
+
* <pont2-consent consent-request="cr_123"></pont2-consent>
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* The OAuth consent screen (pontive-spec 40 §4.3), ported from the legacy
|
|
15
|
+
* `pont-consent` (carry-over §8). **Not a flow widget:** the person already has
|
|
16
|
+
* a session, so there is no flow to start and no SDK to wait for. The screen is
|
|
17
|
+
* one consent request, which auth-api renders like a flow view (the built-in
|
|
18
|
+
* `authorize_app` widget in the instance's brand and copy) and answers with a
|
|
19
|
+
* redirect.
|
|
20
|
+
*
|
|
21
|
+
* It still renders through `pont2-layout`, with a consent-specific **client**,
|
|
22
|
+
* so the markup, the error banner, the busy state and the branding entitlement
|
|
23
|
+
* work as on every other screen:
|
|
24
|
+
*
|
|
25
|
+
* - **Load:** `GET {base-url}/auth/v1/consent/{consent-request}?locales=…`, same
|
|
26
|
+
* origin with the session cookie (`fetchConsent`). The view's `locale` and
|
|
27
|
+
* `dir` become the element's `lang` and `dir`.
|
|
28
|
+
* - **Answer:** Allow and Deny are submit buttons naming the `allow` / `deny`
|
|
29
|
+
* event; `pont2-scope-list` submits the ticked scopes as `scope`, one
|
|
30
|
+
* space-separated string. The client posts `{ event, data }`
|
|
31
|
+
* (`submitConsent`) and then either sends the browser to `redirect_to` (the
|
|
32
|
+
* app's redirect URI, which may be a custom scheme; only code-running schemes
|
|
33
|
+
* are refused) or renders the screen the server sent back.
|
|
34
|
+
* - **Errors:** a request that expired, was already answered or isn't this
|
|
35
|
+
* session's (404) says "This request has expired. Go back to the app and try
|
|
36
|
+
* again." (`consent_expired`) and offers nothing to retry. Any other failure
|
|
37
|
+
* is worded by `describeFlowError` and offers "Start again", which reloads the
|
|
38
|
+
* request.
|
|
39
|
+
*
|
|
40
|
+
* @tag pont2-consent
|
|
41
|
+
* @attr consent-request - the consent request's id (the page's `consent_request` parameter)
|
|
42
|
+
* @attr base-url - where auth-api is; empty (default) means same origin, which the session cookie needs
|
|
43
|
+
* @attr locales - preferred languages, passed to the load (`?locales=`)
|
|
44
|
+
* @prop branding - the account's branding entitlements (fail closed: the watermark shows)
|
|
45
|
+
*/
|
|
46
|
+
export declare class Consent extends HostElement {
|
|
47
|
+
static identity: string;
|
|
48
|
+
static properties: PropertyDeclarations;
|
|
49
|
+
consentRequest: string;
|
|
50
|
+
baseUrl: string;
|
|
51
|
+
locales: string;
|
|
52
|
+
branding: BrandingEntitlements;
|
|
53
|
+
protected renderSpec: string;
|
|
54
|
+
protected loadError: {
|
|
55
|
+
message: string;
|
|
56
|
+
retryable: boolean;
|
|
57
|
+
} | null;
|
|
58
|
+
protected readonly messagesController: MessagesController;
|
|
59
|
+
/** Bumped per load, so only the latest answer lands on the screen. */
|
|
60
|
+
private loadSeq;
|
|
61
|
+
/** The request, server and languages last loaded: a change means load again. */
|
|
62
|
+
private loadedKey;
|
|
63
|
+
/**
|
|
64
|
+
* What the layout calls for Allow / Deny. Stable for the element's lifetime:
|
|
65
|
+
* the layout keeps it across screens.
|
|
66
|
+
*/
|
|
67
|
+
readonly client: FlowClient;
|
|
68
|
+
constructor();
|
|
69
|
+
/** The element's layout. */
|
|
70
|
+
get layout(): Layout | null;
|
|
71
|
+
/** Loads (or reloads) the consent request. */
|
|
72
|
+
load(): Promise<void>;
|
|
73
|
+
private show;
|
|
74
|
+
private answer;
|
|
75
|
+
protected willUpdate(_changed: PropertyValues): void;
|
|
76
|
+
protected updated(changed: PropertyValues): void;
|
|
77
|
+
render(): import('lit-html').TemplateResult<1> | typeof nothing;
|
|
78
|
+
}
|
|
79
|
+
declare global {
|
|
80
|
+
interface HTMLElementTagNameMap {
|
|
81
|
+
"pont2-consent": Consent;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -4,8 +4,8 @@ export interface CountdownEndDetail {
|
|
|
4
4
|
/** Where the countdown will navigate (already resolved), or null. */
|
|
5
5
|
url: string | null;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
export declare
|
|
7
|
+
/** Kept as countdown's export; the check itself is `safeUrl` (core/url.ts), shared with `pont2-link`. */
|
|
8
|
+
export declare const safeRedirect: (raw: string, base?: string) => string | null;
|
|
9
9
|
/**
|
|
10
10
|
* # `<pont2-countdown>`: "Redirecting in 5s…"
|
|
11
11
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { PropertyDeclarations, PropertyValues } from 'lit';
|
|
1
|
+
import { nothing, PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
2
|
import { HostElement } from '../../core/host-element';
|
|
3
|
+
import { MessagesController } from '../../core/messages';
|
|
3
4
|
import { BrandingEntitlements } from '../block/branding';
|
|
4
5
|
import { FlowClient, Layout } from '../layout/layout';
|
|
5
6
|
/**
|
|
@@ -15,7 +16,6 @@ export interface WidgetClient extends FlowClient {
|
|
|
15
16
|
export interface FlowStart {
|
|
16
17
|
render_spec?: unknown;
|
|
17
18
|
messages?: Record<string, string>;
|
|
18
|
-
[key: string]: unknown;
|
|
19
19
|
}
|
|
20
20
|
/** The parts of the SDK's `FlowStateChangeEvent` a widget reads. */
|
|
21
21
|
export interface FlowStateEvent {
|
|
@@ -23,7 +23,6 @@ export interface FlowStateEvent {
|
|
|
23
23
|
flowType?: string;
|
|
24
24
|
render_spec?: unknown;
|
|
25
25
|
messages?: Record<string, string>;
|
|
26
|
-
[key: string]: unknown;
|
|
27
26
|
}
|
|
28
27
|
/**
|
|
29
28
|
* Feeds the SDK's asynchronous flow-state changes (a resumed flow, a flow an
|
|
@@ -95,7 +94,10 @@ export declare abstract class FlowWidget extends HostElement {
|
|
|
95
94
|
protected starting: boolean;
|
|
96
95
|
protected startError: {
|
|
97
96
|
message: string;
|
|
97
|
+
restartable: boolean;
|
|
98
98
|
} | null;
|
|
99
|
+
/** Re-renders when the page's message table changes (the loading label). */
|
|
100
|
+
protected readonly messagesController: MessagesController;
|
|
99
101
|
/** The SDK's `flowType` this widget runs ("signin", "signup"): which flow-state events apply. */
|
|
100
102
|
protected abstract readonly flowType: string;
|
|
101
103
|
private started;
|
|
@@ -106,6 +108,8 @@ export declare abstract class FlowWidget extends HostElement {
|
|
|
106
108
|
restart(): Promise<void>;
|
|
107
109
|
/** Applies an SDK flow-state change (what `dispatchFlowState` delivers). */
|
|
108
110
|
applyFlowState(event: FlowStateEvent): void;
|
|
111
|
+
/** A set the flow sent: this widget's, and the page's message table (core/messages.ts). */
|
|
112
|
+
private receiveMessages;
|
|
109
113
|
private msg;
|
|
110
114
|
private continuedElsewhereSpec;
|
|
111
115
|
private onFlowState;
|
|
@@ -114,9 +118,9 @@ export declare abstract class FlowWidget extends HostElement {
|
|
|
114
118
|
protected willUpdate(changed: PropertyValues): void;
|
|
115
119
|
protected updated(changed: PropertyValues): void;
|
|
116
120
|
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
|
|
121
|
+
/** The flow id used when `flow-id` is not set; `undefined` lets the SDK choose (an invitation). */
|
|
122
|
+
protected abstract defaultFlowId(): string | undefined;
|
|
123
|
+
render(): import('lit-html').TemplateResult<1> | typeof nothing;
|
|
120
124
|
}
|
|
121
125
|
/**
|
|
122
126
|
* # `<pont2-signin>`: the sign-in widget
|
|
@@ -140,10 +144,37 @@ export declare class SignUp extends FlowWidget {
|
|
|
140
144
|
protected readonly flowType = "signup";
|
|
141
145
|
protected defaultFlowId(): string;
|
|
142
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* # `<pont2-invitation>`: accepting an invitation
|
|
149
|
+
*
|
|
150
|
+
* The invitee arrives from an emailed link holding a token and nothing else.
|
|
151
|
+
* They aren't asked who they are, since the invitation already knows: the widget
|
|
152
|
+
* starts the **invitation flow**, which resolves the token, decides whether the
|
|
153
|
+
* invitee signs in or registers, and accepts the invitation once they are
|
|
154
|
+
* authenticated. A port of the legacy `pont-invitation` (migration tracker W-4).
|
|
155
|
+
*
|
|
156
|
+
* It starts with **no flow id**: the SDK takes the invitation flow from the
|
|
157
|
+
* page's path, so the app names that path as `invitationUrl` when it configures
|
|
158
|
+
* the SDK (the legacy provider's `env.invitationUrl`; `<pont2-provider>` will
|
|
159
|
+
* do it, W-1). An invitation answered by the sign-in flow would sign the invitee
|
|
160
|
+
* in and join them to nothing, which is why this is its own element. The page
|
|
161
|
+
* should also drop an existing session before the flow (the legacy
|
|
162
|
+
* `answersInvitation`; the provider's job, W-1).
|
|
163
|
+
*
|
|
164
|
+
* Everything on screen comes from the flow's render spec: the instance's own
|
|
165
|
+
* invitation widgets if it published any, else the built-in ones.
|
|
166
|
+
*
|
|
167
|
+
* @tag pont2-invitation
|
|
168
|
+
*/
|
|
169
|
+
export declare class Invitation extends FlowWidget {
|
|
170
|
+
protected readonly flowType = "invitation";
|
|
171
|
+
protected defaultFlowId(): undefined;
|
|
172
|
+
}
|
|
143
173
|
declare global {
|
|
144
174
|
interface HTMLElementTagNameMap {
|
|
145
175
|
"pont2-signin": SignIn;
|
|
146
176
|
"pont2-signup": SignUp;
|
|
177
|
+
"pont2-invitation": Invitation;
|
|
147
178
|
}
|
|
148
179
|
interface DocumentEventMap {
|
|
149
180
|
"pont2-flow-state": CustomEvent<FlowStateEvent>;
|
|
@@ -23,6 +23,7 @@ export * from './qr-code/qr-code';
|
|
|
23
23
|
export * from './recovery-codes/recovery-codes';
|
|
24
24
|
export * from './scope-list/scope-list';
|
|
25
25
|
export * from './layout/layout';
|
|
26
|
+
export * from './consent/consent';
|
|
26
27
|
export * from './flow-widget/flow-widget';
|
|
27
28
|
export * from './flow-widget/preview';
|
|
28
29
|
export * from './flow-widget/specimens';
|
|
@@ -4,18 +4,41 @@
|
|
|
4
4
|
* from the legacy kit), with the same English and the same message codes, so
|
|
5
5
|
* a flow's localised `messages` (keyed by code) apply unchanged.
|
|
6
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";
|
|
7
|
+
export type FlowMessageCode = "connection_failed" | "too_many_attempts" | "server_error" | "instance_unavailable" | "generic_error" | "flow_ended" | "passkey_cancelled" | "start_again" | "continued_elsewhere_title" | "continued_elsewhere_subtitle" | "continue_here";
|
|
8
|
+
/** The flow codes' English (a subset of `KIT_MESSAGES_EN`, core/messages.ts). */
|
|
8
9
|
export declare const FLOW_MESSAGES_EN: Record<FlowMessageCode, string>;
|
|
9
10
|
export interface FlowErrorDescription {
|
|
10
11
|
message: string;
|
|
11
12
|
/** The flow is over (409): offer "Start again". */
|
|
12
13
|
restartable: boolean;
|
|
14
|
+
/** The instance has stopped: nothing will work, so offer nothing to retry. */
|
|
15
|
+
unavailable?: boolean;
|
|
13
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* A stopped instance (paused, or its owner's Pontive account paused, cancelled or
|
|
19
|
+
* deleted) refuses everything it serves to end users with this one code and no
|
|
20
|
+
* reason (pontive-spec 01, "Who is told why"; carry-over §6).
|
|
21
|
+
*/
|
|
22
|
+
export declare const INSTANCE_UNAVAILABLE = "instance_unavailable";
|
|
23
|
+
/** Whether a failed call was refused because the instance has stopped (its own `code`, or its body's). */
|
|
24
|
+
export declare function isInstanceUnavailable(error: unknown): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Keeps the sentence a stopped instance was refused with. Once stopped, the page
|
|
27
|
+
* can no longer ask for its text, so the auth service words the refusal itself
|
|
28
|
+
* (in the page's language and the instance's copy). Kept in the message table,
|
|
29
|
+
* it is what every widget says for the code from then on, including for
|
|
30
|
+
* refusals from services that only send English.
|
|
31
|
+
*/
|
|
32
|
+
export declare function rememberUnavailable(sentence?: string): void;
|
|
14
33
|
/**
|
|
15
34
|
* - a cancelled or timed-out WebAuthn prompt (`NotAllowedError` / `AbortError`) → passkey_cancelled
|
|
35
|
+
* - `instance_unavailable` → the refusal's own sentence, kept for the page (rememberUnavailable); not restartable
|
|
16
36
|
* - 409 → the server's sentence, else flow_ended; restartable
|
|
17
37
|
* - no response at all (NETWORK_ERROR / TIMEOUT) → connection_failed
|
|
18
38
|
* - 429 → too_many_attempts; ≥ 500 → server_error
|
|
19
39
|
* - anything else → the server's sentence, else generic_error
|
|
40
|
+
*
|
|
41
|
+
* Text comes from `messages` when given (a set a caller holds), else the
|
|
42
|
+
* page-wide message table (core/messages.ts), else English.
|
|
20
43
|
*/
|
|
21
44
|
export declare function describeFlowError(error: unknown, messages?: Partial<Record<string, string>>): FlowErrorDescription;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
2
|
import { HostElement } from '../../core/host-element';
|
|
3
3
|
import { BrandingEntitlements } from '../block/branding';
|
|
4
|
-
export { describeFlowError, FLOW_MESSAGES_EN, type FlowErrorDescription, type FlowMessageCode } from './flow-error';
|
|
4
|
+
export { describeFlowError, FLOW_MESSAGES_EN, INSTANCE_UNAVAILABLE, isInstanceUnavailable, rememberUnavailable, type FlowErrorDescription, type FlowMessageCode, } from './flow-error';
|
|
5
5
|
/**
|
|
6
6
|
* What the layout needs from an auth client: one method. `Auth` from
|
|
7
7
|
* `@pontive/oidc-client` satisfies it structurally, so pont2 never imports an
|
|
@@ -18,7 +18,6 @@ export interface FlowEventRequest {
|
|
|
18
18
|
export interface FlowEventResponse {
|
|
19
19
|
state?: string;
|
|
20
20
|
render_spec?: unknown;
|
|
21
|
-
[key: string]: unknown;
|
|
22
21
|
}
|
|
23
22
|
export interface UnregisteredElementDetail {
|
|
24
23
|
tag: string;
|
|
@@ -101,6 +100,14 @@ export declare class Layout extends HostElement {
|
|
|
101
100
|
protected willUpdate(changed: PropertyValues): void;
|
|
102
101
|
protected updated(changed: PropertyValues): void;
|
|
103
102
|
private renderScreen;
|
|
103
|
+
/**
|
|
104
|
+
* The layout's form never submits natively. Every submission is either answered here (a
|
|
105
|
+
* `pont2-action` the layout responds to, which prevents it) or it is a mistake: no `client`
|
|
106
|
+
* yet, or a submit button without `event`. A native submission would then be a GET to the
|
|
107
|
+
* current URL with every field, password included, in the query string. So whatever is left
|
|
108
|
+
* unhandled is stopped here, at the form, after the submit buttons' own listeners have run.
|
|
109
|
+
*/
|
|
110
|
+
private onFormSubmit;
|
|
104
111
|
render(): import('lit-html').TemplateResult<1>;
|
|
105
112
|
}
|
|
106
113
|
declare global {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PropertyDeclarations, PropertyValues } from 'lit';
|
|
1
|
+
import { nothing, PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
2
|
import { ActionController } from '../../core/controllers/action';
|
|
3
3
|
import { HostElement } from '../../core/host-element';
|
|
4
4
|
export type LinkAlign = "start" | "center" | "end";
|
|
@@ -16,7 +16,10 @@ export type LinkAlign = "start" | "center" | "end";
|
|
|
16
16
|
* primitive's part:
|
|
17
17
|
*
|
|
18
18
|
* - **with `href`**: a real `<a href>` (navigation, middle-click, "open in
|
|
19
|
-
* new tab" work), styled as a link
|
|
19
|
+
* new tab" work), styled as a link. Only an http(s) URL, absolute or
|
|
20
|
+
* relative, is linked (`safeUrl`): a `javascript:`, `data:` or other
|
|
21
|
+
* scheme renders **nothing** and the row is hidden (`data-invalid-href`),
|
|
22
|
+
* because an `href` from a render spec is data, not trusted markup;
|
|
20
23
|
* - **otherwise**: a `<button type="button">` that requests `event` through
|
|
21
24
|
* the action protocol (`data: { service }`), busy until it settles, like
|
|
22
25
|
* the auth buttons. The legacy `service="other"` (no auth call) maps to:
|
|
@@ -27,7 +30,7 @@ export type LinkAlign = "start" | "center" | "end";
|
|
|
27
30
|
* @attr prompt - text before the link
|
|
28
31
|
* @attr event - the action requested on press (button form)
|
|
29
32
|
* @attr service - auth (default) | other: passed in the request's data
|
|
30
|
-
* @attr href, target, rel - render a real link instead
|
|
33
|
+
* @attr href, target, rel - render a real link instead (http(s) only; anything else renders nothing)
|
|
31
34
|
* @attr align - start | center (default) | end
|
|
32
35
|
* @attr disabled, loading
|
|
33
36
|
* @cssprop --pont2-link-fg - the row's text (default muted-foreground)
|
|
@@ -54,11 +57,47 @@ export declare class Link extends HostElement {
|
|
|
54
57
|
get busy(): boolean;
|
|
55
58
|
/** The native `<a>` or `<button>`. */
|
|
56
59
|
get control(): HTMLAnchorElement | HTMLButtonElement | null;
|
|
60
|
+
/** `href` is set but is not an http(s) URL: the link renders nothing. */
|
|
61
|
+
protected get invalidHref(): boolean;
|
|
57
62
|
protected willUpdate(_changed: PropertyValues): void;
|
|
58
|
-
render(): import('lit-html').TemplateResult<1
|
|
63
|
+
render(): import('lit-html').TemplateResult<1> | typeof nothing;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* # `<pont2-external-link>`: a page outside the flow, in a new tab
|
|
67
|
+
*
|
|
68
|
+
* ```html
|
|
69
|
+
* <pont2-external-link label="Privacy policy" href="{{consent_privacy_policy_url}}"></pont2-external-link>
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* The consent screen's links to an app's privacy policy, terms or homepage. It
|
|
73
|
+
* is `pont2-link`'s `href` form with the rules of the legacy
|
|
74
|
+
* `pont-external-link` (carry-over §7):
|
|
75
|
+
*
|
|
76
|
+
* - only an **absolute** http(s) URL with a host renders (`safeExternalUrl`).
|
|
77
|
+
* The href is usually a server placeholder filled from the app's settings,
|
|
78
|
+
* so empty, still a placeholder, relative or any other scheme renders
|
|
79
|
+
* **nothing** and the row is hidden (`data-invalid-href`);
|
|
80
|
+
* - it always opens a new tab, with `rel="noopener noreferrer"`;
|
|
81
|
+
* - `label` falls back to the URL;
|
|
82
|
+
* - it never requests an action and fires no event, so it is safe on screens
|
|
83
|
+
* that are not an auth flow.
|
|
84
|
+
*
|
|
85
|
+
* Styled by `pont2-link`'s recipe and tokens, so the two read as one kind of
|
|
86
|
+
* thing on a screen.
|
|
87
|
+
*
|
|
88
|
+
* @tag pont2-external-link
|
|
89
|
+
* @attr href - absolute http(s) URL; anything else renders nothing
|
|
90
|
+
* @attr label - link text (default: the URL)
|
|
91
|
+
* @attr prompt - text before the link
|
|
92
|
+
* @attr align - start | center (default) | end
|
|
93
|
+
*/
|
|
94
|
+
export declare class ExternalLink extends Link {
|
|
95
|
+
protected get invalidHref(): boolean;
|
|
96
|
+
render(): import('lit-html').TemplateResult<1> | typeof nothing;
|
|
59
97
|
}
|
|
60
98
|
declare global {
|
|
61
99
|
interface HTMLElementTagNameMap {
|
|
62
100
|
"pont2-link": Link;
|
|
101
|
+
"pont2-external-link": ExternalLink;
|
|
63
102
|
}
|
|
64
103
|
}
|
package/dist/pont2/styles.css
CHANGED
|
@@ -5776,6 +5776,11 @@ layer(pont2.tokens);
|
|
|
5776
5776
|
}
|
|
5777
5777
|
|
|
5778
5778
|
/* Recipe */
|
|
5779
|
+
/* An href that is not http(s) renders nothing; the row goes with it. */
|
|
5780
|
+
:is(pont2-link, [data-pont2-link])[data-invalid-href] {
|
|
5781
|
+
display: none;
|
|
5782
|
+
}
|
|
5783
|
+
|
|
5779
5784
|
:is(pont2-link, [data-pont2-link]) {
|
|
5780
5785
|
display: flex;
|
|
5781
5786
|
flex-wrap: wrap;
|
|
@@ -5928,6 +5933,17 @@ layer(pont2.tokens);
|
|
|
5928
5933
|
:is([data-pont2-title], [data-pont2-subtitle])[data-align="end"] {
|
|
5929
5934
|
text-align: end;
|
|
5930
5935
|
}
|
|
5936
|
+
/*
|
|
5937
|
+
* In a flex_row container the cross axis is vertical: stretching there would
|
|
5938
|
+
* change the element's height, not its width. The row keeps its own
|
|
5939
|
+
* alignment, and `align` only aligns the lines (the legacy kit's rule,
|
|
5940
|
+
* carry-over §9).
|
|
5941
|
+
*/
|
|
5942
|
+
[data-pont2-container][data-type="flex_row"]
|
|
5943
|
+
> :is(pont2-title, pont2-subtitle)
|
|
5944
|
+
> :is([data-pont2-title], [data-pont2-subtitle]):not([data-align="auto"]) {
|
|
5945
|
+
align-self: auto;
|
|
5946
|
+
}
|
|
5931
5947
|
}
|
|
5932
5948
|
|
|
5933
5949
|
/* ../kit/provider-field/provider-field.css */
|
|
@@ -6474,10 +6490,25 @@ layer(pont2.tokens);
|
|
|
6474
6490
|
}
|
|
6475
6491
|
}
|
|
6476
6492
|
|
|
6493
|
+
/* ../kit/consent/consent.css */
|
|
6494
|
+
/* <pont2-consent>: a block-level host; a centred spinner until the screen loads (as the flow widgets). */
|
|
6495
|
+
@layer pont2.kit {
|
|
6496
|
+
:is(pont2-consent, [data-pont2-consent]) {
|
|
6497
|
+
display: block;
|
|
6498
|
+
width: 100%;
|
|
6499
|
+
}
|
|
6500
|
+
[data-pont2-consent] > [data-slot="flow-widget-loading"] {
|
|
6501
|
+
display: grid;
|
|
6502
|
+
place-items: center;
|
|
6503
|
+
min-height: 12rem;
|
|
6504
|
+
color: var(--pont2-sem-color-muted-foreground);
|
|
6505
|
+
}
|
|
6506
|
+
}
|
|
6507
|
+
|
|
6477
6508
|
/* ../kit/flow-widget/flow-widget.css */
|
|
6478
|
-
/* <pont2-signin> / <pont2-signup>: a block-level host; a centred spinner until the first screen. */
|
|
6509
|
+
/* <pont2-signin> / <pont2-signup> / <pont2-invitation>: a block-level host; a centred spinner until the first screen. */
|
|
6479
6510
|
@layer pont2.kit {
|
|
6480
|
-
:is(pont2-signin, pont2-signup, [data-pont2-flow-widget]) {
|
|
6511
|
+
:is(pont2-signin, pont2-signup, pont2-invitation, [data-pont2-flow-widget]) {
|
|
6481
6512
|
display: block;
|
|
6482
6513
|
width: 100%;
|
|
6483
6514
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A stopped instance: paused, or its owner's Pontive account paused, cancelled
|
|
3
|
+
* or deleted. Pontive refuses everything it serves to end users with this one
|
|
4
|
+
* code and no reason (pontive-spec 01, Who is told why), so every widget says
|
|
5
|
+
* the same thing: "This app isn't available right now."
|
|
6
|
+
*/
|
|
7
|
+
export declare const INSTANCE_UNAVAILABLE = "instance_unavailable";
|
|
8
|
+
/** Whether a failed call was refused because the instance has stopped. */
|
|
9
|
+
export declare function isInstanceUnavailable(error: unknown): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Keep the sentence a stopped instance's auth domain refused with. Once the
|
|
12
|
+
* instance has stopped, the page can no longer ask for its text, so the auth
|
|
13
|
+
* service words the refusal itself, in the page's language and the instance's
|
|
14
|
+
* copy; kept here, it is what msg("instance_unavailable") says from then on,
|
|
15
|
+
* including for refusals from services that send only English.
|
|
16
|
+
*/
|
|
17
|
+
export declare function rememberUnavailable(sentence?: string): void;
|
|
18
|
+
/** The sentence to show for a refusal of a stopped instance. */
|
|
19
|
+
export declare function instanceUnavailableMessage(): string;
|