@pontive/pontkit-react 1.5.1 → 1.6.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.
@@ -0,0 +1,118 @@
1
+ import { ReactNode } from 'react';
2
+ import { AccountClient, AccountMenuItem, AccountSettingsContent, AccountSettingsLayout, AccountSettingsMode, AccountSettingsOrientation, AppSdkConfig, BrandingEntitlements, MemberManagementMode, ProviderSdk, SessionChange, WidgetClient } from '@pontive/pontkit-core/pont2';
3
+ export type { AccountClient, AccountMenuItem, AuthState, ProviderSdk, SessionChange, WidgetClient, } from '@pontive/pontkit-core/pont2';
4
+ /**
5
+ * Events core declares on `HTMLElementEventMap` are typed from there; this
6
+ * covers the ones it fires without declaring.
7
+ */
8
+ interface UndeclaredEvents {
9
+ "pont2-session-changed": CustomEvent<SessionChange>;
10
+ }
11
+ /** The event a generated `on…` callback receives: the DOM event itself. */
12
+ export type Pont2Event<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : K extends keyof UndeclaredEvents ? UndeclaredEvents[K] : CustomEvent<unknown>;
13
+ /** The inputs of `<pont2-provider>` (pontkit-core pont2/docs/kit/provider.md). */
14
+ export interface ProviderInputProps {
15
+ /** Required. */
16
+ appId: string;
17
+ /** Required: a hostname, a `/path` on this origin (the auth proxy, `/__pontive`), or a base URL. */
18
+ domain: string;
19
+ /** BCP-47 tags in preference order; empty lets the server negotiate. */
20
+ locales?: string;
21
+ signinUrl?: string;
22
+ signupUrl?: string;
23
+ invitationUrl?: string;
24
+ /** Where a signed-in user is sent from the sign-in, sign-up and invitation pages. */
25
+ signinRedirectUrl?: string;
26
+ /** "Continue here instead" (default: `signinRedirectUrl`). */
27
+ continueHereUrl?: string;
28
+ /** The OAuth scopes every flow asks for. Member management needs `pontive:org:member:*`. */
29
+ scope?: string | string[];
30
+ /** The organization a sign-in starts in. */
31
+ organizationId?: string;
32
+ /**
33
+ * The management gateway the default account client calls
34
+ * (`https://api.us.pontive.com`). Absolute http(s) only: the auth proxy does
35
+ * not forward `/me` or `/mgmt/v1`.
36
+ */
37
+ apiBaseUrl?: string;
38
+ /** The identifier to pre-fill (default: the URL's `login_hint`). */
39
+ loginHint?: string;
40
+ /** Default on. `false` keeps a signed-in user on the auth pages. */
41
+ autoRedirect?: boolean;
42
+ /** `"none"` opts out of linking the published theme. */
43
+ theme?: string;
44
+ /** Extra request headers for the SDK and the default account client. */
45
+ headers?: Record<string, string>;
46
+ /** The app's own account client; wins over the default one. */
47
+ accountClient?: AccountClient;
48
+ /**
49
+ * The app's own SDK options and callbacks (`onFlowStateChange`,
50
+ * `onAuthenticated` …). The provider chains them after its own; don't call
51
+ * `Auth.configure()` yourself.
52
+ */
53
+ config?: AppSdkConfig;
54
+ }
55
+ /** The raw `<pont2-provider>` wrapper's props: the inputs plus the SDK. */
56
+ export interface ProviderElementProps extends ProviderInputProps {
57
+ children?: ReactNode;
58
+ sdk?: ProviderSdk;
59
+ }
60
+ /** `pont2-signin`, `pont2-signup`, `pont2-invitation`. */
61
+ export interface FlowWidgetProps {
62
+ /**
63
+ * Shown until the first screen renders, then removed by the widget
64
+ * (pontkit-core tracker F-17).
65
+ */
66
+ fallback?: ReactNode | null;
67
+ /** The widget's own client. Inside a `Pont2Provider` it uses the provider's. */
68
+ client?: WidgetClient;
69
+ /** Its own branding entitlements. Inside a `Pont2Provider` it uses the provider's. */
70
+ branding?: BrandingEntitlements;
71
+ /** Default `sys_signin-flow-passkey` / `sys_signup-flow`; none for the invitation. */
72
+ flowId?: string;
73
+ }
74
+ /** `pont2-consent` (the OAuth consent page). */
75
+ export interface ConsentProps {
76
+ /** The page's `consent_request` parameter. */
77
+ consentRequest: string;
78
+ /** Where auth-api is (default: this origin, which the session cookie needs). */
79
+ baseUrl?: string;
80
+ locales?: string;
81
+ branding?: BrandingEntitlements;
82
+ }
83
+ /** What every account widget takes. */
84
+ interface AccountWidgetProps {
85
+ /** Its own account client. Inside a `Pont2Provider` it uses the provider's. */
86
+ client?: AccountClient;
87
+ }
88
+ export interface AccountMenuProps extends AccountWidgetProps {
89
+ /** Where "Account settings" goes when `onAccountSettings` doesn't cancel. */
90
+ accountSettingsUrl?: string;
91
+ /** Entries between "Account settings" and "Log out". */
92
+ items?: AccountMenuItem[];
93
+ }
94
+ export interface OrganizationSwitcherProps extends AccountWidgetProps {
95
+ /** Reload the page after a switch (for server-rendered pages). */
96
+ reloadOnSwitch?: boolean;
97
+ /** The button's text while the session acts in no organization. */
98
+ emptyLabel?: string;
99
+ }
100
+ export interface AccountSettingsProps extends AccountWidgetProps {
101
+ mode?: AccountSettingsMode;
102
+ orientation?: AccountSettingsOrientation;
103
+ widgetsLayout?: AccountSettingsLayout;
104
+ /** Modal mode: whether the dialog is open. */
105
+ open?: boolean;
106
+ content?: AccountSettingsContent | null;
107
+ }
108
+ export interface MemberManagementProps extends AccountWidgetProps {
109
+ /** The organization to manage (default: the session's). */
110
+ organizationId?: string;
111
+ mode?: MemberManagementMode;
112
+ /** Modal mode: whether the dialog is open. */
113
+ open?: boolean;
114
+ heading?: string;
115
+ description?: string;
116
+ /** 5, 10 or 25. */
117
+ pageSize?: number;
118
+ }
package/dist/pont2.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./coexistence-dvfn_5A6.cjs"),r=require("react"),k=require("@pontive/pontkit-loader"),w=a.wrapPont2("pont2-provider",{events:{onAuthChanged:"pont2-auth-changed",onLocaleChanged:"pont2-locale-changed",onSessionChanged:"pont2-session-changed",onRedirect:"pont2-redirect"},fallback:!1,provider:!0}),A=a.wrapPont2("pont2-signin",{events:{onFlowResponse:"pont2-flow-response"},fallback:!0}),b=a.wrapPont2("pont2-signup",{events:{onFlowResponse:"pont2-flow-response"},fallback:!0}),C=a.wrapPont2("pont2-invitation",{events:{onFlowResponse:"pont2-flow-response"},fallback:!0}),M=a.wrapPont2("pont2-consent",{events:{},fallback:!1}),E=a.wrapPont2("pont2-account-menu",{events:{onAccountSettings:"pont2-account-settings",onLogout:"pont2-logout",onMenuItemClick:"pont2-menu-item-click",onOpenChange:"pont2-open-change"},fallback:!1}),O=a.wrapPont2("pont2-organization-switcher",{events:{onOrganizationChanged:"pont2-organization-changed",onOrganizationSwitchFailed:"pont2-organization-switch-failed",onOpenChange:"pont2-open-change"},fallback:!1}),y=a.wrapPont2("pont2-account-settings",{events:{onProfileUpdated:"pont2-profile-updated",onOpenChange:"pont2-open-change"},fallback:!1}),I=a.wrapPont2("pont2-member-management",{events:{onMembersInvited:"pont2-members-invited",onMemberRolesUpdated:"pont2-member-roles-updated",onMemberRemoved:"pont2-member-removed",onInvitationResent:"pont2-invitation-resent",onInvitationRevoked:"pont2-invitation-revoked"},fallback:!1}),g=r.createContext(void 0);function d(e){const t=r.useContext(g);if(t===void 0)throw new Error(`${e} was called outside <Pont2Provider>. Wrap your app in the Pont2Provider from @pontive/pontkit-react/pont2 (the legacy <Provider> from the package root feeds a different context).`);return t}function h(){if(!(typeof window>"u"))return window.__pontCoreSdk?.Auth}function R(e){const[t,i]=r.useState(void 0);return r.useEffect(()=>{if(e)return;let n=!1;function o(){if(n)return;const s=h();s?i(()=>s):console.error("[pontive] <Pont2Provider>: the loaded @pontive/pontkit-core has no `Auth`. Pass the SDK yourself: `sdk={Auth}` from @pontive/oidc-client.")}return h()?o():k.loadWebComponents().then(o).catch(s=>console.error(s)),()=>{n=!0}},[e]),e??t}const P=r.forwardRef(({children:e,sdk:t,...i},n)=>{a.useProviderPresence("pont2");const[o,s]=r.useState(null),u=R(t),c=a.useProviderAuthState(o,"pont2-provider","pont2-auth-changed"),f=x(o),v=i.signinUrl??null,m=r.useMemo(()=>({auth:c,session:f,sdk:u??null,signinUrl:v}),[c,f,u,v]);function S(p){s(p),typeof n=="function"?n(p):n&&(n.current=p)}return r.createElement(w,{...i,...u?{sdk:u}:{},ref:S},r.createElement(g.Provider,{value:m},e))});P.displayName="Pont2Provider";function x(e){const[t,i]=r.useState(null);return r.useEffect(()=>{if(!e)return;function n(o){const s=o.detail;s&&i({...s})}return e.addEventListener("pont2-session-changed",n),()=>e.removeEventListener("pont2-session-changed",n)},[e]),t}function l(){return d("usePont2Auth").auth}function z(){return d("usePont2Session").session}function U(){return d("usePont2Sdk").sdk}function L({children:e,fallback:t=null}){const{isAuthenticated:i,resolved:n}=l();return n?i?e:null:t}function F({children:e,fallback:t=null}){const{isAuthenticated:i,resolved:n}=l();return n?i?null:e:t}function q({children:e,fallback:t=null}){return l().resolved?e:t}function W({children:e,loading:t=null,redirectUrl:i,onRedirect:n}){const{auth:o,signinUrl:s}=d("Authenticated"),u=r.useRef(!1),c=i||s||void 0;return r.useEffect(()=>{if(!(!o.resolved||o.isAuthenticated||u.current)){if(!c){console.error("[pontive] <Authenticated> has nobody to redirect to: pass `redirectUrl`, or give the Pont2Provider a `signinUrl`.");return}u.current=!0,n?n(c):window.location.href=c}},[o.resolved,o.isAuthenticated,c,n]),o.resolved?o.isAuthenticated?e:null:t}exports.AccountMenu=E;exports.AccountSettings=y;exports.AuthResolved=q;exports.Authenticated=W;exports.Consent=M;exports.Invitation=C;exports.MemberManagement=I;exports.OrganizationSwitcher=O;exports.Pont2Provider=P;exports.SignedIn=L;exports.SignedOut=F;exports.Signin=A;exports.Signup=b;exports.usePont2Auth=l;exports.usePont2Sdk=U;exports.usePont2Session=z;
2
+ //# sourceMappingURL=pont2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pont2.cjs","sources":["../src/pont2/elements.generated.ts","../src/pont2/provider.ts"],"sourcesContent":["// GENERATED by tools/gen-wrappers — do not edit.\n//\n// Source: @pontive/pontkit-core@1.41.0 pont2/custom-elements.json.\n// Which elements are wrapped, and under what name, is PONT2_WRAPPED in\n// tools/gen-wrappers/elements.config.mjs; the events are the manifest's.\n//\n// The element classes are imported as TYPES only. This package must never\n// bundle core: the loader fetches it from the CDN at a release the platform\n// decides, so a value import here would ship a second, pinned copy.\nimport type {\n Provider as Pont2ProviderElement,\n SignIn as Pont2SigninElement,\n SignUp as Pont2SignupElement,\n Invitation as Pont2InvitationElement,\n Consent as Pont2ConsentElement,\n AccountMenu as Pont2AccountMenuElement,\n OrganizationSwitcher as Pont2OrganizationSwitcherElement,\n AccountSettings as Pont2AccountSettingsElement,\n MemberManagement as Pont2MemberManagementElement,\n} from \"@pontive/pontkit-core/pont2\";\n\nimport { wrapPont2 } from \"../wrap\";\nimport type {\n Pont2Event,\n ProviderElementProps,\n FlowWidgetProps,\n ConsentProps,\n AccountMenuProps,\n OrganizationSwitcherProps,\n AccountSettingsProps,\n MemberManagementProps,\n} from \"./types\";\n\nexport type {\n Pont2ProviderElement,\n Pont2SigninElement,\n Pont2SignupElement,\n Pont2InvitationElement,\n Pont2ConsentElement,\n Pont2AccountMenuElement,\n Pont2OrganizationSwitcherElement,\n Pont2AccountSettingsElement,\n Pont2MemberManagementElement,\n};\n\n/** The `pont2-provider` events, as callback props. */\nexport interface ProviderElementEvents {\n /** `pont2-auth-changed`: `AuthState` (a copy), whenever it changes */\n onAuthChanged?: (event: Pont2Event<\"pont2-auth-changed\">) => void;\n /** `pont2-locale-changed`: `{ locales }`, whenever the configured locales change */\n onLocaleChanged?: (event: Pont2Event<\"pont2-locale-changed\">) => void;\n /** `pont2-session-changed`: `{ reason, source, isAuthenticated, organizationId }`, on every SDK session change, here or in another tab (no tokens) */\n onSessionChanged?: (event: Pont2Event<\"pont2-session-changed\">) => void;\n /** `pont2-redirect`: `{ url }`, cancelable, before a post-sign-in navigation */\n onRedirect?: (event: Pont2Event<\"pont2-redirect\">) => void;\n}\n\nexport const ProviderElement = /* @__PURE__ */ wrapPont2<Pont2ProviderElement, ProviderElementProps & ProviderElementEvents>(\"pont2-provider\", {\n events: {\n onAuthChanged: \"pont2-auth-changed\",\n onLocaleChanged: \"pont2-locale-changed\",\n onSessionChanged: \"pont2-session-changed\",\n onRedirect: \"pont2-redirect\",\n },\n fallback: false,\n provider: true,\n});\n\n/** The `pont2-signin` events, as callback props. */\nexport interface SigninEvents {\n /** `pont2-flow-response`: (from the layout) after every successful request */\n onFlowResponse?: (event: Pont2Event<\"pont2-flow-response\">) => void;\n}\n\nexport const Signin = /* @__PURE__ */ wrapPont2<Pont2SigninElement, FlowWidgetProps & SigninEvents>(\"pont2-signin\", {\n events: {\n onFlowResponse: \"pont2-flow-response\",\n },\n fallback: true,\n});\n\n/** The `pont2-signup` events, as callback props. */\nexport interface SignupEvents {\n /** `pont2-flow-response`: (from the layout) after every successful request */\n onFlowResponse?: (event: Pont2Event<\"pont2-flow-response\">) => void;\n}\n\nexport const Signup = /* @__PURE__ */ wrapPont2<Pont2SignupElement, FlowWidgetProps & SignupEvents>(\"pont2-signup\", {\n events: {\n onFlowResponse: \"pont2-flow-response\",\n },\n fallback: true,\n});\n\n/** The `pont2-invitation` events, as callback props. */\nexport interface InvitationEvents {\n /** `pont2-flow-response`: (from the layout) after every successful request */\n onFlowResponse?: (event: Pont2Event<\"pont2-flow-response\">) => void;\n}\n\nexport const Invitation = /* @__PURE__ */ wrapPont2<Pont2InvitationElement, FlowWidgetProps & InvitationEvents>(\"pont2-invitation\", {\n events: {\n onFlowResponse: \"pont2-flow-response\",\n },\n fallback: true,\n});\n\n/** The `pont2-consent` events, as callback props. */\nexport interface ConsentEvents {}\n\nexport const Consent = /* @__PURE__ */ wrapPont2<Pont2ConsentElement, ConsentProps & ConsentEvents>(\"pont2-consent\", {\n events: {},\n fallback: false,\n});\n\n/** The `pont2-account-menu` events, as callback props. */\nexport interface AccountMenuEvents {\n /** `pont2-account-settings`: cancelable, `{}`: \"Account settings\" was chosen */\n onAccountSettings?: (event: Pont2Event<\"pont2-account-settings\">) => void;\n /** `pont2-logout`: cancelable, `{}`: \"Log out\" was chosen */\n onLogout?: (event: Pont2Event<\"pont2-logout\">) => void;\n /** `pont2-menu-item-click`: cancelable `{ item, checked?, value? }`: one of `items` was chosen */\n onMenuItemClick?: (event: Pont2Event<\"pont2-menu-item-click\">) => void;\n /** `pont2-open-change`: cancelable `{ open, reason }` (the menu's) */\n onOpenChange?: (event: Pont2Event<\"pont2-open-change\">) => void;\n}\n\nexport const AccountMenu = /* @__PURE__ */ wrapPont2<Pont2AccountMenuElement, AccountMenuProps & AccountMenuEvents>(\"pont2-account-menu\", {\n events: {\n onAccountSettings: \"pont2-account-settings\",\n onLogout: \"pont2-logout\",\n onMenuItemClick: \"pont2-menu-item-click\",\n onOpenChange: \"pont2-open-change\",\n },\n fallback: false,\n});\n\n/** The `pont2-organization-switcher` events, as callback props. */\nexport interface OrganizationSwitcherEvents {\n /** `pont2-organization-changed`: `{ organizationId, roles, permissions }`, after a switch */\n onOrganizationChanged?: (event: Pont2Event<\"pont2-organization-changed\">) => void;\n /** `pont2-organization-switch-failed`: `{ organizationId, error }`, when a switch is refused */\n onOrganizationSwitchFailed?: (event: Pont2Event<\"pont2-organization-switch-failed\">) => void;\n /** `pont2-open-change`: cancelable `{ open, reason }` (the menu's) */\n onOpenChange?: (event: Pont2Event<\"pont2-open-change\">) => void;\n}\n\nexport const OrganizationSwitcher = /* @__PURE__ */ wrapPont2<Pont2OrganizationSwitcherElement, OrganizationSwitcherProps & OrganizationSwitcherEvents>(\"pont2-organization-switcher\", {\n events: {\n onOrganizationChanged: \"pont2-organization-changed\",\n onOrganizationSwitchFailed: \"pont2-organization-switch-failed\",\n onOpenChange: \"pont2-open-change\",\n },\n fallback: false,\n});\n\n/** The `pont2-account-settings` events, as callback props. */\nexport interface AccountSettingsEvents {\n /** `pont2-profile-updated`: `{ section, profile }`, after a section was saved */\n onProfileUpdated?: (event: Pont2Event<\"pont2-profile-updated\">) => void;\n /** `pont2-open-change`: modal mode: cancelable `{ open, reason }` (the dialog's) */\n onOpenChange?: (event: Pont2Event<\"pont2-open-change\">) => void;\n}\n\nexport const AccountSettings = /* @__PURE__ */ wrapPont2<Pont2AccountSettingsElement, AccountSettingsProps & AccountSettingsEvents>(\"pont2-account-settings\", {\n events: {\n onProfileUpdated: \"pont2-profile-updated\",\n onOpenChange: \"pont2-open-change\",\n },\n fallback: false,\n});\n\n/** The `pont2-member-management` events, as callback props. */\nexport interface MemberManagementEvents {\n /** `pont2-members-invited`: `{ organizationId, emails, roles, invitations }` */\n onMembersInvited?: (event: Pont2Event<\"pont2-members-invited\">) => void;\n /** `pont2-member-roles-updated`: `{ organizationId, userId, roles }` */\n onMemberRolesUpdated?: (event: Pont2Event<\"pont2-member-roles-updated\">) => void;\n /** `pont2-member-removed`: `{ organizationId, userId }` */\n onMemberRemoved?: (event: Pont2Event<\"pont2-member-removed\">) => void;\n /** `pont2-invitation-resent`: `{ organizationId, invitationId, email }` */\n onInvitationResent?: (event: Pont2Event<\"pont2-invitation-resent\">) => void;\n /** `pont2-invitation-revoked`: `{ organizationId, invitationId, email, notifyInvitee }` */\n onInvitationRevoked?: (event: Pont2Event<\"pont2-invitation-revoked\">) => void;\n}\n\nexport const MemberManagement = /* @__PURE__ */ wrapPont2<Pont2MemberManagementElement, MemberManagementProps & MemberManagementEvents>(\"pont2-member-management\", {\n events: {\n onMembersInvited: \"pont2-members-invited\",\n onMemberRolesUpdated: \"pont2-member-roles-updated\",\n onMemberRemoved: \"pont2-member-removed\",\n onInvitationResent: \"pont2-invitation-resent\",\n onInvitationRevoked: \"pont2-invitation-revoked\",\n },\n fallback: false,\n});\n","import React, {\n createContext,\n createElement,\n forwardRef,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { loadWebComponents } from \"@pontive/pontkit-loader\";\nimport { useProviderAuthState } from \"../auth\";\nimport { useProviderPresence } from \"../coexistence\";\nimport { ProviderElement } from \"./elements.generated\";\nimport type {\n Pont2ProviderElement,\n ProviderElementEvents,\n} from \"./elements.generated\";\nimport type {\n AuthState,\n ProviderInputProps,\n ProviderSdk,\n SessionChange,\n} from \"./types\";\n\n/**\n * `<Pont2Provider>`: `<pont2-provider>` for React.\n *\n * What the element can't do for itself is get the SDK: pont2 never imports\n * `Auth`, it is injected (`provider.sdk = Auth`, pontkit-core\n * pont2/docs/kit/provider.md). This injects it, and turns the element's\n * `pont2-auth-changed` / `pont2-session-changed` into React context, the way\n * the legacy `<Provider>` turns `pont:auth-changed` into it.\n *\n * **Which `Auth`.** By default the one the loaded bundle carries\n * (`window.__pontCoreSdk.Auth`, which the loader wraps so calls made before\n * `configure()` wait for it). That is the SDK release the platform picked with\n * the elements, and the only copy on the page, so nothing here bundles a\n * second one. An app that installs `@pontive/oidc-client` itself can pass\n * `sdk={Auth}` instead; then the provider configures without waiting for the\n * CDN.\n */\n\nexport interface Pont2ProviderProps\n extends ProviderInputProps,\n ProviderElementEvents {\n children?: React.ReactNode;\n /** The auth SDK. Default: the loaded bundle's `Auth`. */\n sdk?: ProviderSdk;\n}\n\nconst UNRESOLVED: AuthState = { isAuthenticated: false, resolved: false };\n\ninterface Pont2ContextValue {\n auth: AuthState;\n /** The last `pont2-session-changed`, or null before the first. */\n session: SessionChange | null;\n /** The SDK the provider was given (null until the bundle has loaded). */\n sdk: ProviderSdk | null;\n /** `<Authenticated>`'s default redirect target. */\n signinUrl: string | null;\n}\n\n/**\n * A context of its own, not the legacy one: the two providers must not be\n * mounted together (W-15), and at S7 this subpath becomes the root.\n * `undefined` means \"no provider above\", as in ../auth.ts.\n */\nconst Pont2Context = createContext<Pont2ContextValue | undefined>(undefined);\n\nfunction usePont2Context(caller: string): Pont2ContextValue {\n const value = useContext(Pont2Context);\n\n if (value === undefined) {\n throw new Error(\n `${caller} was called outside <Pont2Provider>. Wrap your app in the ` +\n \"Pont2Provider from @pontive/pontkit-react/pont2 (the legacy \" +\n \"<Provider> from the package root feeds a different context).\",\n );\n }\n\n return value;\n}\n\n/** What the loader put on the window, as far as this file reads it. */\nfunction loadedSdk(): ProviderSdk | undefined {\n if (typeof window === \"undefined\") return undefined;\n return (window as unknown as { __pontCoreSdk?: { Auth?: ProviderSdk } })\n .__pontCoreSdk?.Auth;\n}\n\n/** The SDK to inject: the app's, else the bundle's once it has loaded. */\nfunction useSdk(own: ProviderSdk | undefined): ProviderSdk | undefined {\n const [loaded, setLoaded] = useState<ProviderSdk | undefined>(undefined);\n\n useEffect(() => {\n if (own) return;\n\n let cancelled = false;\n\n function take() {\n if (cancelled) return;\n const sdk = loadedSdk();\n if (sdk) setLoaded(() => sdk);\n else\n console.error(\n \"[pontive] <Pont2Provider>: the loaded @pontive/pontkit-core has no \" +\n \"`Auth`. Pass the SDK yourself: `sdk={Auth}` from @pontive/oidc-client.\",\n );\n }\n\n if (loadedSdk()) take();\n else\n loadWebComponents()\n .then(take)\n .catch((err) => console.error(err));\n\n return () => {\n cancelled = true;\n };\n }, [own]);\n\n return own ?? loaded;\n}\n\nexport const Pont2Provider = forwardRef<Pont2ProviderElement, Pont2ProviderProps>(\n ({ children, sdk: ownSdk, ...props }, forwardedRef) => {\n useProviderPresence(\"pont2\");\n\n const [element, setElement] = useState<Pont2ProviderElement | null>(null);\n const sdk = useSdk(ownSdk);\n const auth = useProviderAuthState(\n element,\n \"pont2-provider\",\n \"pont2-auth-changed\",\n ) as AuthState;\n const session = useSessionChange(element);\n const signinUrl = props.signinUrl ?? null;\n\n const contextValue = useMemo<Pont2ContextValue>(\n () => ({ auth, session, sdk: sdk ?? null, signinUrl }),\n [auth, session, sdk, signinUrl],\n );\n\n // State rather than a ref: the subscriptions re-run when the element arrives.\n function captureRef(el: Pont2ProviderElement | null) {\n setElement(el);\n\n if (typeof forwardedRef === \"function\") forwardedRef(el);\n else if (forwardedRef) forwardedRef.current = el;\n }\n\n return createElement(\n ProviderElement,\n { ...props, ...(sdk ? { sdk } : {}), ref: captureRef },\n createElement(Pont2Context.Provider, { value: contextValue }, children),\n );\n },\n);\n\nPont2Provider.displayName = \"Pont2Provider\";\n\n/** The last `pont2-session-changed` the element announced. */\nfunction useSessionChange(element: HTMLElement | null): SessionChange | null {\n const [session, setSession] = useState<SessionChange | null>(null);\n\n useEffect(() => {\n if (!element) return;\n\n function onChange(event: Event) {\n const detail = (event as CustomEvent<SessionChange>).detail;\n if (detail) setSession({ ...detail });\n }\n\n element.addEventListener(\"pont2-session-changed\", onChange);\n return () => element.removeEventListener(\"pont2-session-changed\", onChange);\n }, [element]);\n\n return session;\n}\n\n/**\n * The session as the nearest `<Pont2Provider>` knows it. `resolved` is false\n * until `restoreSession()` has come back; act on nothing before it.\n */\nexport function usePont2Auth(): AuthState {\n return usePont2Context(\"usePont2Auth\").auth;\n}\n\n/**\n * The last session change (`reason`: `signed-in`, `restored`, `refreshed`,\n * `organization-changed`, `signed-out`, `expired`), here or in another tab.\n * Null before the first. Use it to reload what depends on the organization.\n */\nexport function usePont2Session(): SessionChange | null {\n return usePont2Context(\"usePont2Session\").session;\n}\n\n/**\n * The SDK the provider injected, for the calls the widgets don't make\n * (`signOut()`, `getManagementToken()` …). Null until the bundle has loaded.\n */\nexport function usePont2Sdk(): ProviderSdk | null {\n return usePont2Context(\"usePont2Sdk\").sdk;\n}\n\nexport interface ControlProps {\n children?: React.ReactNode;\n /** Rendered until the session is known (default: nothing). */\n fallback?: React.ReactNode | null;\n}\n\n/**\n * Children for a signed-in user. A React component rather than a wrapper over\n * `<pont2-signed-in>`, which detaches its children: nodes React must keep\n * owning (provider.md: framework hosts branch on `pont2-auth-changed`).\n */\nexport function SignedIn({ children, fallback = null }: ControlProps): React.ReactNode {\n const { isAuthenticated, resolved } = usePont2Auth();\n if (!resolved) return fallback;\n return isAuthenticated ? children : null;\n}\n\n/** Children for everyone else, once the session is known. */\nexport function SignedOut({ children, fallback = null }: ControlProps): React.ReactNode {\n const { isAuthenticated, resolved } = usePont2Auth();\n if (!resolved) return fallback;\n return isAuthenticated ? null : children;\n}\n\n/** Children once the session is known; `fallback` until then. */\nexport function AuthResolved({ children, fallback = null }: ControlProps): React.ReactNode {\n return usePont2Auth().resolved ? children : fallback;\n}\n\nexport interface AuthenticatedProps {\n children?: React.ReactNode;\n /** Rendered while the session is being resolved. */\n loading?: React.ReactNode;\n /** Where to send a signed-out visitor. Default: the provider's `signinUrl`. */\n redirectUrl?: string;\n /** Navigate with the app's router (`router.push`) instead of a page load. */\n onRedirect?: (url: string) => void;\n}\n\n/**\n * Children for a signed-in user; everyone else is sent to the sign-in page,\n * once the session has resolved (never on the interim \"signed out\").\n */\nexport function Authenticated({\n children,\n loading = null,\n redirectUrl,\n onRedirect,\n}: AuthenticatedProps): React.ReactNode {\n const { auth, signinUrl } = usePont2Context(\"Authenticated\");\n const redirected = useRef(false);\n const target = redirectUrl || signinUrl || undefined;\n\n useEffect(() => {\n if (!auth.resolved || auth.isAuthenticated || redirected.current) return;\n\n if (!target) {\n console.error(\n \"[pontive] <Authenticated> has nobody to redirect to: pass \" +\n \"`redirectUrl`, or give the Pont2Provider a `signinUrl`.\",\n );\n return;\n }\n\n redirected.current = true;\n\n if (onRedirect) onRedirect(target);\n else window.location.href = target;\n }, [auth.resolved, auth.isAuthenticated, target, onRedirect]);\n\n if (!auth.resolved) return loading;\n\n return auth.isAuthenticated ? children : null;\n}\n"],"names":["ProviderElement","Signin","Signup","Invitation","Consent","AccountMenu","OrganizationSwitcher","AccountSettings","MemberManagement","Pont2Context","createContext","usePont2Context","caller","value","useContext","loadedSdk","useSdk","own","loaded","setLoaded","useState","useEffect","cancelled","take","sdk","loadWebComponents","err","Pont2Provider","forwardRef","children","ownSdk","props","forwardedRef","useProviderPresence","element","setElement","auth","useProviderAuthState","session","useSessionChange","signinUrl","contextValue","useMemo","captureRef","el","createElement","setSession","onChange","event","detail","usePont2Auth","usePont2Session","usePont2Sdk","SignedIn","fallback","isAuthenticated","resolved","SignedOut","AuthResolved","Authenticated","loading","redirectUrl","onRedirect","redirected","useRef","target"],"mappings":"sLAyDaA,cAAgH,iBAAkB,CAC7I,OAAQ,CACN,cAAe,qBACf,gBAAiB,uBACjB,iBAAkB,wBAClB,WAAY,gBAAA,EAEd,SAAU,GACV,SAAU,EACZ,CAAC,EAQYC,cAAuF,eAAgB,CAClH,OAAQ,CACN,eAAgB,qBAAA,EAElB,SAAU,EACZ,CAAC,EAQYC,cAAuF,eAAgB,C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SAAUA,EAAK,gBAAiB6B,EAAQH,CAAU,CAAC,EAEvD1B,EAAK,SAEHA,EAAK,gBAAkBP,EAAW,KAFd+B,CAG7B"}
package/dist/pont2.js ADDED
@@ -0,0 +1,181 @@
1
+ import { g as i, u as b, a as A } from "./coexistence-CEqhGd4-.js";
2
+ import { useRef as C, useEffect as d, forwardRef as w, useState as p, useMemo as M, createElement as g, useContext as x, createContext as y } from "react";
3
+ import { loadWebComponents as E } from "@pontive/pontkit-loader";
4
+ const O = /* @__PURE__ */ i("pont2-provider", {
5
+ events: {
6
+ onAuthChanged: "pont2-auth-changed",
7
+ onLocaleChanged: "pont2-locale-changed",
8
+ onSessionChanged: "pont2-session-changed",
9
+ onRedirect: "pont2-redirect"
10
+ },
11
+ fallback: !1,
12
+ provider: !0
13
+ }), W = /* @__PURE__ */ i("pont2-signin", {
14
+ events: {
15
+ onFlowResponse: "pont2-flow-response"
16
+ },
17
+ fallback: !0
18
+ }), _ = /* @__PURE__ */ i("pont2-signup", {
19
+ events: {
20
+ onFlowResponse: "pont2-flow-response"
21
+ },
22
+ fallback: !0
23
+ }), D = /* @__PURE__ */ i("pont2-invitation", {
24
+ events: {
25
+ onFlowResponse: "pont2-flow-response"
26
+ },
27
+ fallback: !0
28
+ }), K = /* @__PURE__ */ i("pont2-consent", {
29
+ events: {},
30
+ fallback: !1
31
+ }), N = /* @__PURE__ */ i("pont2-account-menu", {
32
+ events: {
33
+ onAccountSettings: "pont2-account-settings",
34
+ onLogout: "pont2-logout",
35
+ onMenuItemClick: "pont2-menu-item-click",
36
+ onOpenChange: "pont2-open-change"
37
+ },
38
+ fallback: !1
39
+ }), V = /* @__PURE__ */ i("pont2-organization-switcher", {
40
+ events: {
41
+ onOrganizationChanged: "pont2-organization-changed",
42
+ onOrganizationSwitchFailed: "pont2-organization-switch-failed",
43
+ onOpenChange: "pont2-open-change"
44
+ },
45
+ fallback: !1
46
+ }), $ = /* @__PURE__ */ i("pont2-account-settings", {
47
+ events: {
48
+ onProfileUpdated: "pont2-profile-updated",
49
+ onOpenChange: "pont2-open-change"
50
+ },
51
+ fallback: !1
52
+ }), j = /* @__PURE__ */ i("pont2-member-management", {
53
+ events: {
54
+ onMembersInvited: "pont2-members-invited",
55
+ onMemberRolesUpdated: "pont2-member-roles-updated",
56
+ onMemberRemoved: "pont2-member-removed",
57
+ onInvitationResent: "pont2-invitation-resent",
58
+ onInvitationRevoked: "pont2-invitation-revoked"
59
+ },
60
+ fallback: !1
61
+ }), P = y(void 0);
62
+ function c(n) {
63
+ const t = x(P);
64
+ if (t === void 0)
65
+ throw new Error(
66
+ `${n} was called outside <Pont2Provider>. Wrap your app in the Pont2Provider from @pontive/pontkit-react/pont2 (the legacy <Provider> from the package root feeds a different context).`
67
+ );
68
+ return t;
69
+ }
70
+ function m() {
71
+ if (!(typeof window > "u"))
72
+ return window.__pontCoreSdk?.Auth;
73
+ }
74
+ function R(n) {
75
+ const [t, r] = p(void 0);
76
+ return d(() => {
77
+ if (n) return;
78
+ let e = !1;
79
+ function o() {
80
+ if (e) return;
81
+ const s = m();
82
+ s ? r(() => s) : console.error(
83
+ "[pontive] <Pont2Provider>: the loaded @pontive/pontkit-core has no `Auth`. Pass the SDK yourself: `sdk={Auth}` from @pontive/oidc-client."
84
+ );
85
+ }
86
+ return m() ? o() : E().then(o).catch((s) => console.error(s)), () => {
87
+ e = !0;
88
+ };
89
+ }, [n]), n ?? t;
90
+ }
91
+ const U = w(
92
+ ({ children: n, sdk: t, ...r }, e) => {
93
+ b("pont2");
94
+ const [o, s] = p(null), a = R(t), u = A(
95
+ o,
96
+ "pont2-provider",
97
+ "pont2-auth-changed"
98
+ ), v = z(o), h = r.signinUrl ?? null, k = M(
99
+ () => ({ auth: u, session: v, sdk: a ?? null, signinUrl: h }),
100
+ [u, v, a, h]
101
+ );
102
+ function S(l) {
103
+ s(l), typeof e == "function" ? e(l) : e && (e.current = l);
104
+ }
105
+ return g(
106
+ O,
107
+ { ...r, ...a ? { sdk: a } : {}, ref: S },
108
+ g(P.Provider, { value: k }, n)
109
+ );
110
+ }
111
+ );
112
+ U.displayName = "Pont2Provider";
113
+ function z(n) {
114
+ const [t, r] = p(null);
115
+ return d(() => {
116
+ if (!n) return;
117
+ function e(o) {
118
+ const s = o.detail;
119
+ s && r({ ...s });
120
+ }
121
+ return n.addEventListener("pont2-session-changed", e), () => n.removeEventListener("pont2-session-changed", e);
122
+ }, [n]), t;
123
+ }
124
+ function f() {
125
+ return c("usePont2Auth").auth;
126
+ }
127
+ function q() {
128
+ return c("usePont2Session").session;
129
+ }
130
+ function B() {
131
+ return c("usePont2Sdk").sdk;
132
+ }
133
+ function G({ children: n, fallback: t = null }) {
134
+ const { isAuthenticated: r, resolved: e } = f();
135
+ return e ? r ? n : null : t;
136
+ }
137
+ function H({ children: n, fallback: t = null }) {
138
+ const { isAuthenticated: r, resolved: e } = f();
139
+ return e ? r ? null : n : t;
140
+ }
141
+ function J({ children: n, fallback: t = null }) {
142
+ return f().resolved ? n : t;
143
+ }
144
+ function Q({
145
+ children: n,
146
+ loading: t = null,
147
+ redirectUrl: r,
148
+ onRedirect: e
149
+ }) {
150
+ const { auth: o, signinUrl: s } = c("Authenticated"), a = C(!1), u = r || s || void 0;
151
+ return d(() => {
152
+ if (!(!o.resolved || o.isAuthenticated || a.current)) {
153
+ if (!u) {
154
+ console.error(
155
+ "[pontive] <Authenticated> has nobody to redirect to: pass `redirectUrl`, or give the Pont2Provider a `signinUrl`."
156
+ );
157
+ return;
158
+ }
159
+ a.current = !0, e ? e(u) : window.location.href = u;
160
+ }
161
+ }, [o.resolved, o.isAuthenticated, u, e]), o.resolved ? o.isAuthenticated ? n : null : t;
162
+ }
163
+ export {
164
+ N as AccountMenu,
165
+ $ as AccountSettings,
166
+ J as AuthResolved,
167
+ Q as Authenticated,
168
+ K as Consent,
169
+ D as Invitation,
170
+ j as MemberManagement,
171
+ V as OrganizationSwitcher,
172
+ U as Pont2Provider,
173
+ G as SignedIn,
174
+ H as SignedOut,
175
+ W as Signin,
176
+ _ as Signup,
177
+ f as usePont2Auth,
178
+ B as usePont2Sdk,
179
+ q as usePont2Session
180
+ };
181
+ //# sourceMappingURL=pont2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pont2.js","sources":["../src/pont2/elements.generated.ts","../src/pont2/provider.ts"],"sourcesContent":["// GENERATED by tools/gen-wrappers — do not edit.\n//\n// Source: @pontive/pontkit-core@1.41.0 pont2/custom-elements.json.\n// Which elements are wrapped, and under what name, is PONT2_WRAPPED in\n// tools/gen-wrappers/elements.config.mjs; the events are the manifest's.\n//\n// The element classes are imported as TYPES only. This package must never\n// bundle core: the loader fetches it from the CDN at a release the platform\n// decides, so a value import here would ship a second, pinned copy.\nimport type {\n Provider as Pont2ProviderElement,\n SignIn as Pont2SigninElement,\n SignUp as Pont2SignupElement,\n Invitation as Pont2InvitationElement,\n Consent as Pont2ConsentElement,\n AccountMenu as Pont2AccountMenuElement,\n OrganizationSwitcher as Pont2OrganizationSwitcherElement,\n AccountSettings as Pont2AccountSettingsElement,\n MemberManagement as Pont2MemberManagementElement,\n} from \"@pontive/pontkit-core/pont2\";\n\nimport { wrapPont2 } from \"../wrap\";\nimport type {\n Pont2Event,\n ProviderElementProps,\n FlowWidgetProps,\n ConsentProps,\n AccountMenuProps,\n OrganizationSwitcherProps,\n AccountSettingsProps,\n MemberManagementProps,\n} from \"./types\";\n\nexport type {\n Pont2ProviderElement,\n Pont2SigninElement,\n Pont2SignupElement,\n Pont2InvitationElement,\n Pont2ConsentElement,\n Pont2AccountMenuElement,\n Pont2OrganizationSwitcherElement,\n Pont2AccountSettingsElement,\n Pont2MemberManagementElement,\n};\n\n/** The `pont2-provider` events, as callback props. */\nexport interface ProviderElementEvents {\n /** `pont2-auth-changed`: `AuthState` (a copy), whenever it changes */\n onAuthChanged?: (event: Pont2Event<\"pont2-auth-changed\">) => void;\n /** `pont2-locale-changed`: `{ locales }`, whenever the configured locales change */\n onLocaleChanged?: (event: Pont2Event<\"pont2-locale-changed\">) => void;\n /** `pont2-session-changed`: `{ reason, source, isAuthenticated, organizationId }`, on every SDK session change, here or in another tab (no tokens) */\n onSessionChanged?: (event: Pont2Event<\"pont2-session-changed\">) => void;\n /** `pont2-redirect`: `{ url }`, cancelable, before a post-sign-in navigation */\n onRedirect?: (event: Pont2Event<\"pont2-redirect\">) => void;\n}\n\nexport const ProviderElement = /* @__PURE__ */ wrapPont2<Pont2ProviderElement, ProviderElementProps & ProviderElementEvents>(\"pont2-provider\", {\n events: {\n onAuthChanged: \"pont2-auth-changed\",\n onLocaleChanged: \"pont2-locale-changed\",\n onSessionChanged: \"pont2-session-changed\",\n onRedirect: \"pont2-redirect\",\n },\n fallback: false,\n provider: true,\n});\n\n/** The `pont2-signin` events, as callback props. */\nexport interface SigninEvents {\n /** `pont2-flow-response`: (from the layout) after every successful request */\n onFlowResponse?: (event: Pont2Event<\"pont2-flow-response\">) => void;\n}\n\nexport const Signin = /* @__PURE__ */ wrapPont2<Pont2SigninElement, FlowWidgetProps & SigninEvents>(\"pont2-signin\", {\n events: {\n onFlowResponse: \"pont2-flow-response\",\n },\n fallback: true,\n});\n\n/** The `pont2-signup` events, as callback props. */\nexport interface SignupEvents {\n /** `pont2-flow-response`: (from the layout) after every successful request */\n onFlowResponse?: (event: Pont2Event<\"pont2-flow-response\">) => void;\n}\n\nexport const Signup = /* @__PURE__ */ wrapPont2<Pont2SignupElement, FlowWidgetProps & SignupEvents>(\"pont2-signup\", {\n events: {\n onFlowResponse: \"pont2-flow-response\",\n },\n fallback: true,\n});\n\n/** The `pont2-invitation` events, as callback props. */\nexport interface InvitationEvents {\n /** `pont2-flow-response`: (from the layout) after every successful request */\n onFlowResponse?: (event: Pont2Event<\"pont2-flow-response\">) => void;\n}\n\nexport const Invitation = /* @__PURE__ */ wrapPont2<Pont2InvitationElement, FlowWidgetProps & InvitationEvents>(\"pont2-invitation\", {\n events: {\n onFlowResponse: \"pont2-flow-response\",\n },\n fallback: true,\n});\n\n/** The `pont2-consent` events, as callback props. */\nexport interface ConsentEvents {}\n\nexport const Consent = /* @__PURE__ */ wrapPont2<Pont2ConsentElement, ConsentProps & ConsentEvents>(\"pont2-consent\", {\n events: {},\n fallback: false,\n});\n\n/** The `pont2-account-menu` events, as callback props. */\nexport interface AccountMenuEvents {\n /** `pont2-account-settings`: cancelable, `{}`: \"Account settings\" was chosen */\n onAccountSettings?: (event: Pont2Event<\"pont2-account-settings\">) => void;\n /** `pont2-logout`: cancelable, `{}`: \"Log out\" was chosen */\n onLogout?: (event: Pont2Event<\"pont2-logout\">) => void;\n /** `pont2-menu-item-click`: cancelable `{ item, checked?, value? }`: one of `items` was chosen */\n onMenuItemClick?: (event: Pont2Event<\"pont2-menu-item-click\">) => void;\n /** `pont2-open-change`: cancelable `{ open, reason }` (the menu's) */\n onOpenChange?: (event: Pont2Event<\"pont2-open-change\">) => void;\n}\n\nexport const AccountMenu = /* @__PURE__ */ wrapPont2<Pont2AccountMenuElement, AccountMenuProps & AccountMenuEvents>(\"pont2-account-menu\", {\n events: {\n onAccountSettings: \"pont2-account-settings\",\n onLogout: \"pont2-logout\",\n onMenuItemClick: \"pont2-menu-item-click\",\n onOpenChange: \"pont2-open-change\",\n },\n fallback: false,\n});\n\n/** The `pont2-organization-switcher` events, as callback props. */\nexport interface OrganizationSwitcherEvents {\n /** `pont2-organization-changed`: `{ organizationId, roles, permissions }`, after a switch */\n onOrganizationChanged?: (event: Pont2Event<\"pont2-organization-changed\">) => void;\n /** `pont2-organization-switch-failed`: `{ organizationId, error }`, when a switch is refused */\n onOrganizationSwitchFailed?: (event: Pont2Event<\"pont2-organization-switch-failed\">) => void;\n /** `pont2-open-change`: cancelable `{ open, reason }` (the menu's) */\n onOpenChange?: (event: Pont2Event<\"pont2-open-change\">) => void;\n}\n\nexport const OrganizationSwitcher = /* @__PURE__ */ wrapPont2<Pont2OrganizationSwitcherElement, OrganizationSwitcherProps & OrganizationSwitcherEvents>(\"pont2-organization-switcher\", {\n events: {\n onOrganizationChanged: \"pont2-organization-changed\",\n onOrganizationSwitchFailed: \"pont2-organization-switch-failed\",\n onOpenChange: \"pont2-open-change\",\n },\n fallback: false,\n});\n\n/** The `pont2-account-settings` events, as callback props. */\nexport interface AccountSettingsEvents {\n /** `pont2-profile-updated`: `{ section, profile }`, after a section was saved */\n onProfileUpdated?: (event: Pont2Event<\"pont2-profile-updated\">) => void;\n /** `pont2-open-change`: modal mode: cancelable `{ open, reason }` (the dialog's) */\n onOpenChange?: (event: Pont2Event<\"pont2-open-change\">) => void;\n}\n\nexport const AccountSettings = /* @__PURE__ */ wrapPont2<Pont2AccountSettingsElement, AccountSettingsProps & AccountSettingsEvents>(\"pont2-account-settings\", {\n events: {\n onProfileUpdated: \"pont2-profile-updated\",\n onOpenChange: \"pont2-open-change\",\n },\n fallback: false,\n});\n\n/** The `pont2-member-management` events, as callback props. */\nexport interface MemberManagementEvents {\n /** `pont2-members-invited`: `{ organizationId, emails, roles, invitations }` */\n onMembersInvited?: (event: Pont2Event<\"pont2-members-invited\">) => void;\n /** `pont2-member-roles-updated`: `{ organizationId, userId, roles }` */\n onMemberRolesUpdated?: (event: Pont2Event<\"pont2-member-roles-updated\">) => void;\n /** `pont2-member-removed`: `{ organizationId, userId }` */\n onMemberRemoved?: (event: Pont2Event<\"pont2-member-removed\">) => void;\n /** `pont2-invitation-resent`: `{ organizationId, invitationId, email }` */\n onInvitationResent?: (event: Pont2Event<\"pont2-invitation-resent\">) => void;\n /** `pont2-invitation-revoked`: `{ organizationId, invitationId, email, notifyInvitee }` */\n onInvitationRevoked?: (event: Pont2Event<\"pont2-invitation-revoked\">) => void;\n}\n\nexport const MemberManagement = /* @__PURE__ */ wrapPont2<Pont2MemberManagementElement, MemberManagementProps & MemberManagementEvents>(\"pont2-member-management\", {\n events: {\n onMembersInvited: \"pont2-members-invited\",\n onMemberRolesUpdated: \"pont2-member-roles-updated\",\n onMemberRemoved: \"pont2-member-removed\",\n onInvitationResent: \"pont2-invitation-resent\",\n onInvitationRevoked: \"pont2-invitation-revoked\",\n },\n fallback: false,\n});\n","import React, {\n createContext,\n createElement,\n forwardRef,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { loadWebComponents } from \"@pontive/pontkit-loader\";\nimport { useProviderAuthState } from \"../auth\";\nimport { useProviderPresence } from \"../coexistence\";\nimport { ProviderElement } from \"./elements.generated\";\nimport type {\n Pont2ProviderElement,\n ProviderElementEvents,\n} from \"./elements.generated\";\nimport type {\n AuthState,\n ProviderInputProps,\n ProviderSdk,\n SessionChange,\n} from \"./types\";\n\n/**\n * `<Pont2Provider>`: `<pont2-provider>` for React.\n *\n * What the element can't do for itself is get the SDK: pont2 never imports\n * `Auth`, it is injected (`provider.sdk = Auth`, pontkit-core\n * pont2/docs/kit/provider.md). This injects it, and turns the element's\n * `pont2-auth-changed` / `pont2-session-changed` into React context, the way\n * the legacy `<Provider>` turns `pont:auth-changed` into it.\n *\n * **Which `Auth`.** By default the one the loaded bundle carries\n * (`window.__pontCoreSdk.Auth`, which the loader wraps so calls made before\n * `configure()` wait for it). That is the SDK release the platform picked with\n * the elements, and the only copy on the page, so nothing here bundles a\n * second one. An app that installs `@pontive/oidc-client` itself can pass\n * `sdk={Auth}` instead; then the provider configures without waiting for the\n * CDN.\n */\n\nexport interface Pont2ProviderProps\n extends ProviderInputProps,\n ProviderElementEvents {\n children?: React.ReactNode;\n /** The auth SDK. Default: the loaded bundle's `Auth`. */\n sdk?: ProviderSdk;\n}\n\nconst UNRESOLVED: AuthState = { isAuthenticated: false, resolved: false };\n\ninterface Pont2ContextValue {\n auth: AuthState;\n /** The last `pont2-session-changed`, or null before the first. */\n session: SessionChange | null;\n /** The SDK the provider was given (null until the bundle has loaded). */\n sdk: ProviderSdk | null;\n /** `<Authenticated>`'s default redirect target. */\n signinUrl: string | null;\n}\n\n/**\n * A context of its own, not the legacy one: the two providers must not be\n * mounted together (W-15), and at S7 this subpath becomes the root.\n * `undefined` means \"no provider above\", as in ../auth.ts.\n */\nconst Pont2Context = createContext<Pont2ContextValue | undefined>(undefined);\n\nfunction usePont2Context(caller: string): Pont2ContextValue {\n const value = useContext(Pont2Context);\n\n if (value === undefined) {\n throw new Error(\n `${caller} was called outside <Pont2Provider>. Wrap your app in the ` +\n \"Pont2Provider from @pontive/pontkit-react/pont2 (the legacy \" +\n \"<Provider> from the package root feeds a different context).\",\n );\n }\n\n return value;\n}\n\n/** What the loader put on the window, as far as this file reads it. */\nfunction loadedSdk(): ProviderSdk | undefined {\n if (typeof window === \"undefined\") return undefined;\n return (window as unknown as { __pontCoreSdk?: { Auth?: ProviderSdk } })\n .__pontCoreSdk?.Auth;\n}\n\n/** The SDK to inject: the app's, else the bundle's once it has loaded. */\nfunction useSdk(own: ProviderSdk | undefined): ProviderSdk | undefined {\n const [loaded, setLoaded] = useState<ProviderSdk | undefined>(undefined);\n\n useEffect(() => {\n if (own) return;\n\n let cancelled = false;\n\n function take() {\n if (cancelled) return;\n const sdk = loadedSdk();\n if (sdk) setLoaded(() => sdk);\n else\n console.error(\n \"[pontive] <Pont2Provider>: the loaded @pontive/pontkit-core has no \" +\n \"`Auth`. Pass the SDK yourself: `sdk={Auth}` from @pontive/oidc-client.\",\n );\n }\n\n if (loadedSdk()) take();\n else\n loadWebComponents()\n .then(take)\n .catch((err) => console.error(err));\n\n return () => {\n cancelled = true;\n };\n }, [own]);\n\n return own ?? loaded;\n}\n\nexport const Pont2Provider = forwardRef<Pont2ProviderElement, Pont2ProviderProps>(\n ({ children, sdk: ownSdk, ...props }, forwardedRef) => {\n useProviderPresence(\"pont2\");\n\n const [element, setElement] = useState<Pont2ProviderElement | null>(null);\n const sdk = useSdk(ownSdk);\n const auth = useProviderAuthState(\n element,\n \"pont2-provider\",\n \"pont2-auth-changed\",\n ) as AuthState;\n const session = useSessionChange(element);\n const signinUrl = props.signinUrl ?? null;\n\n const contextValue = useMemo<Pont2ContextValue>(\n () => ({ auth, session, sdk: sdk ?? null, signinUrl }),\n [auth, session, sdk, signinUrl],\n );\n\n // State rather than a ref: the subscriptions re-run when the element arrives.\n function captureRef(el: Pont2ProviderElement | null) {\n setElement(el);\n\n if (typeof forwardedRef === \"function\") forwardedRef(el);\n else if (forwardedRef) forwardedRef.current = el;\n }\n\n return createElement(\n ProviderElement,\n { ...props, ...(sdk ? { sdk } : {}), ref: captureRef },\n createElement(Pont2Context.Provider, { value: contextValue }, children),\n );\n },\n);\n\nPont2Provider.displayName = \"Pont2Provider\";\n\n/** The last `pont2-session-changed` the element announced. */\nfunction useSessionChange(element: HTMLElement | null): SessionChange | null {\n const [session, setSession] = useState<SessionChange | null>(null);\n\n useEffect(() => {\n if (!element) return;\n\n function onChange(event: Event) {\n const detail = (event as CustomEvent<SessionChange>).detail;\n if (detail) setSession({ ...detail });\n }\n\n element.addEventListener(\"pont2-session-changed\", onChange);\n return () => element.removeEventListener(\"pont2-session-changed\", onChange);\n }, [element]);\n\n return session;\n}\n\n/**\n * The session as the nearest `<Pont2Provider>` knows it. `resolved` is false\n * until `restoreSession()` has come back; act on nothing before it.\n */\nexport function usePont2Auth(): AuthState {\n return usePont2Context(\"usePont2Auth\").auth;\n}\n\n/**\n * The last session change (`reason`: `signed-in`, `restored`, `refreshed`,\n * `organization-changed`, `signed-out`, `expired`), here or in another tab.\n * Null before the first. Use it to reload what depends on the organization.\n */\nexport function usePont2Session(): SessionChange | null {\n return usePont2Context(\"usePont2Session\").session;\n}\n\n/**\n * The SDK the provider injected, for the calls the widgets don't make\n * (`signOut()`, `getManagementToken()` …). Null until the bundle has loaded.\n */\nexport function usePont2Sdk(): ProviderSdk | null {\n return usePont2Context(\"usePont2Sdk\").sdk;\n}\n\nexport interface ControlProps {\n children?: React.ReactNode;\n /** Rendered until the session is known (default: nothing). */\n fallback?: React.ReactNode | null;\n}\n\n/**\n * Children for a signed-in user. A React component rather than a wrapper over\n * `<pont2-signed-in>`, which detaches its children: nodes React must keep\n * owning (provider.md: framework hosts branch on `pont2-auth-changed`).\n */\nexport function SignedIn({ children, fallback = null }: ControlProps): React.ReactNode {\n const { isAuthenticated, resolved } = usePont2Auth();\n if (!resolved) return fallback;\n return isAuthenticated ? children : null;\n}\n\n/** Children for everyone else, once the session is known. */\nexport function SignedOut({ children, fallback = null }: ControlProps): React.ReactNode {\n const { isAuthenticated, resolved } = usePont2Auth();\n if (!resolved) return fallback;\n return isAuthenticated ? null : children;\n}\n\n/** Children once the session is known; `fallback` until then. */\nexport function AuthResolved({ children, fallback = null }: ControlProps): React.ReactNode {\n return usePont2Auth().resolved ? children : fallback;\n}\n\nexport interface AuthenticatedProps {\n children?: React.ReactNode;\n /** Rendered while the session is being resolved. */\n loading?: React.ReactNode;\n /** Where to send a signed-out visitor. Default: the provider's `signinUrl`. */\n redirectUrl?: string;\n /** Navigate with the app's router (`router.push`) instead of a page load. */\n onRedirect?: (url: string) => void;\n}\n\n/**\n * Children for a signed-in user; everyone else is sent to the sign-in page,\n * once the session has resolved (never on the interim \"signed out\").\n */\nexport function Authenticated({\n children,\n loading = null,\n redirectUrl,\n onRedirect,\n}: AuthenticatedProps): React.ReactNode {\n const { auth, signinUrl } = usePont2Context(\"Authenticated\");\n const redirected = useRef(false);\n const target = redirectUrl || signinUrl || undefined;\n\n useEffect(() => {\n if (!auth.resolved || auth.isAuthenticated || redirected.current) return;\n\n if (!target) {\n console.error(\n \"[pontive] <Authenticated> has nobody to redirect to: pass \" +\n \"`redirectUrl`, or give the Pont2Provider a `signinUrl`.\",\n );\n return;\n }\n\n redirected.current = true;\n\n if (onRedirect) onRedirect(target);\n else window.location.href = target;\n }, [auth.resolved, auth.isAuthenticated, target, onRedirect]);\n\n if (!auth.resolved) return loading;\n\n return auth.isAuthenticated ? children : null;\n}\n"],"names":["ProviderElement","Signin","Signup","Invitation","Consent","AccountMenu","OrganizationSwitcher","AccountSettings","MemberManagement","Pont2Context","createContext","usePont2Context","caller","value","useContext","loadedSdk","useSdk","own","loaded","setLoaded","useState","useEffect","cancelled","take","sdk","loadWebComponents","err","Pont2Provider","forwardRef","children","ownSdk","props","forwardedRef","useProviderPresence","element","setElement","auth","useProviderAuthState","session","useSessionChange","signinUrl","contextValue","useMemo","captureRef","el","createElement","setSession","onChange","event","detail","usePont2Auth","usePont2Session","usePont2Sdk","SignedIn","fallback","isAuthenticated","resolved","SignedOut","AuthResolved","Authenticated","loading","redirectUrl","onRedirect","redirected","useRef","target"],"mappings":";;;AAyDO,MAAMA,sBAAgH,kBAAkB;AAAA,EAC7I,QAAQ;AAAA,IACN,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,YAAY;AAAA,EAAA;AAAA,EAEd,UAAU;AAAA,EACV,UAAU;AACZ,CAAC,GAQYC,sBAAuF,gBAAgB;AAAA,EAClH,QAAQ;AAAA,IACN,gBAAgB;AAAA,EAAA;AAAA,EAElB,UAAU;AACZ,CAAC,GAQYC,sBAAuF,gBAAgB;AAAA,EAClH,QAAQ;AAAA,IACN,gBAAgB;AAAA,EAAA;AAAA,EAElB,UAAU;AACZ,CAAC,GAQYC,sBAAmG,oBAAoB;AAAA,EAClI,QAAQ;AAAA,IACN,gBAAgB;AAAA,EAAA;AAAA,EAElB,UAAU;AACZ,CAAC,GAKYC,sBAAuF,iBAAiB;AAAA,EACnH,QAAQ,CAAA;AAAA,EACR,UAAU;AACZ,CAAC,GAcYC,sBAAuG,sBAAsB;AAAA,EACxI,QAAQ;AAAA,IACN,mBAAmB;AAAA,IACnB,UAAU;AAAA,IACV,iBAAiB;AAAA,IACjB,cAAc;AAAA,EAAA;AAAA,EAEhB,UAAU;AACZ,CAAC,GAYYC,sBAA2I,+BAA+B;AAAA,EACrL,QAAQ;AAAA,IACN,uBAAuB;AAAA,IACvB,4BAA4B;AAAA,IAC5B,cAAc;AAAA,EAAA;AAAA,EAEhB,UAAU;AACZ,CAAC,GAUYC,sBAAuH,0BAA0B;AAAA,EAC5J,QAAQ;AAAA,IACN,kBAAkB;AAAA,IAClB,cAAc;AAAA,EAAA;AAAA,EAEhB,UAAU;A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AAiB,UAAAC,EAAA,IAAaN,EAAA;AACtC,SAAKM,IACED,IAAkB1B,IAAW,OADdyB;AAExB;AAGO,SAASG,EAAU,EAAE,UAAA5B,GAAU,UAAAyB,IAAW,QAAuC;AACtF,QAAM,EAAE,iBAAAC,GAAiB,UAAAC,EAAA,IAAaN,EAAA;AACtC,SAAKM,IACED,IAAkB,OAAO1B,IADVyB;AAExB;AAGO,SAASI,EAAa,EAAE,UAAA7B,GAAU,UAAAyB,IAAW,QAAuC;AACzF,SAAOJ,EAAA,EAAe,WAAWrB,IAAWyB;AAC9C;AAgBO,SAASK,EAAc;AAAA,EAC5B,UAAA9B;AAAA,EACA,SAAA+B,IAAU;AAAA,EACV,aAAAC;AAAA,EACA,YAAAC;AACF,GAAwC;AACtC,QAAM,EAAE,MAAA1B,GAAM,WAAAI,MAAc7B,EAAgB,eAAe,GACrDoD,IAAaC,EAAO,EAAK,GACzBC,IAASJ,KAAerB,KAAa;AAmB3C,SAjBAnB,EAAU,MAAM;AACd,QAAI,GAACe,EAAK,YAAYA,EAAK,mBAAmB2B,EAAW,UAEzD;AAAA,UAAI,CAACE,GAAQ;AACX,gBAAQ;AAAA,UACN;AAAA,QAAA;AAGF;AAAA,MACF;AAEA,MAAAF,EAAW,UAAU,IAEjBD,MAAuBG,CAAM,IAC5B,OAAO,SAAS,OAAOA;AAAA;AAAA,EAC9B,GAAG,CAAC7B,EAAK,UAAUA,EAAK,iBAAiB6B,GAAQH,CAAU,CAAC,GAEvD1B,EAAK,WAEHA,EAAK,kBAAkBP,IAAW,OAFd+B;AAG7B;"}
package/dist/wrap.d.ts CHANGED
@@ -1,6 +1,29 @@
1
1
  import { default as React } from 'react';
2
2
  import { ProviderProps as ReactProviderProps } from './types';
3
- export declare function wrap<T extends HTMLElement, P = {}>(tagName: string): React.ForwardRefExoticComponent<React.PropsWithoutRef<P & React.RefAttributes<T> & (P extends ReactProviderProps ? {
3
+ /**
4
+ * What a pont2 wrapper says about its element (generated, see
5
+ * tools/gen-wrappers). The legacy wrappers pass none.
6
+ */
7
+ export interface WrapOptions {
8
+ /**
9
+ * Callback prop -> DOM event. pont2 elements report through events where
10
+ * the legacy ones took callback properties, so these props are listened
11
+ * for instead of assigned, and the callback gets the event itself (a
12
+ * cancelable one can be `preventDefault()`ed).
13
+ */
14
+ events?: Readonly<Record<string, string>>;
15
+ /** Whether the element honours the `[part="fallback"]` contract. */
16
+ fallback?: boolean;
17
+ /** Starts the CDN load on mount, as the legacy provider does. */
18
+ provider?: boolean;
19
+ }
20
+ /**
21
+ * A pont2 wrapper: `wrap()` with the element's options, typed by `P` alone.
22
+ * Children and `fallback` are whatever its props type says, because only the
23
+ * provider takes children and only the flow widgets honour a fallback.
24
+ */
25
+ export declare function wrapPont2<T extends HTMLElement, P = {}>(tagName: string, options: WrapOptions): React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>;
26
+ export declare function wrap<T extends HTMLElement, P = {}>(tagName: string, options?: WrapOptions): React.ForwardRefExoticComponent<React.PropsWithoutRef<P & React.RefAttributes<T> & (P extends ReactProviderProps ? {
4
27
  children?: React.ReactNode;
5
28
  } : {
6
29
  children?: React.ReactNode;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@pontive/pontkit-react",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "license": "MIT",
5
- "description": "React components over the pont-* custom elements.",
5
+ "description": "React components over the pont-* custom elements (and pont2-* under /pont2).",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.js",
@@ -12,6 +12,11 @@
12
12
  "types": "./dist/index.d.ts",
13
13
  "import": "./dist/index.js",
14
14
  "require": "./dist/index.cjs"
15
+ },
16
+ "./pont2": {
17
+ "types": "./dist/pont2/index.d.ts",
18
+ "import": "./dist/pont2.js",
19
+ "require": "./dist/pont2.cjs"
15
20
  }
16
21
  },
17
22
  "files": [
@@ -31,11 +36,11 @@
31
36
  "react-dom": "^18 || ^19"
32
37
  },
33
38
  "dependencies": {
34
- "@pontive/pontkit-loader": "^1.5.1"
39
+ "@pontive/pontkit-loader": "^1.6.0"
35
40
  },
36
41
  "devDependencies": {
37
42
  "@pontive/oidc-client": "^1.0.0",
38
- "@pontive/pontkit-core": "1.5.0",
43
+ "@pontive/pontkit-core": "1.41.0",
39
44
  "@testing-library/dom": "^10.4.1",
40
45
  "@testing-library/react": "^16.3.3",
41
46
  "@types/react-dom": "^19.2.5",