@pontive/pontkit-core 1.40.0 → 1.41.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,42 @@
1
+ import { BadgeOption } from '../badge-selector/badge-selector';
2
+ import { AssignableRole, RoleRef } from '../provider/account-client';
3
+ /**
4
+ * # The role ceiling (carry-over §5; pontive-spec 41 §6)
5
+ *
6
+ * The caller's assignable roles (`GET …/assignable-roles`) say, per role,
7
+ * whether the caller may assign or remove it (`assignable_by_caller`). What
8
+ * the server would refuse is not offered. Pure; unit-tested in `roles.test.ts`.
9
+ */
10
+ /**
11
+ * The organization's roles as role-picker options. A role the caller may not assign or remove
12
+ * (beyond their own permissions, or `owner` without the right to transfer ownership) is locked:
13
+ * it can be neither added nor, once held, taken away (`role_ceiling`).
14
+ */
15
+ export declare function roleOptions(roles: AssignableRole[]): BadgeOption[];
16
+ /** Whether any option is locked (the picker then says so: `roles_locked_hint`). */
17
+ export declare function hasLockedRole(roles: AssignableRole[]): boolean;
18
+ /** Whether the caller may assign or remove any of the organization's roles ("Manage roles" is hidden on every row otherwise). */
19
+ export declare function mayAssignAny(roles: AssignableRole[]): boolean;
20
+ /**
21
+ * Whether the caller may remove a member holding `memberRoles`. Removing a member takes every role
22
+ * they hold, each held to the same ceiling as a role change, so one role the caller may not remove
23
+ * (`owner` without the right to transfer ownership, or one carrying permissions they don't hold)
24
+ * keeps the member, the caller's own row included. A role missing from `roles` is left to the server.
25
+ */
26
+ export declare function mayRemoveMember(memberRoles: string[], roles: AssignableRole[]): boolean;
27
+ /**
28
+ * Whether "Manage roles" shows on a member's row: the session may manage, the caller may assign at
29
+ * least one role, and the row is not the caller's own (`self_role_change`). Locked roles show
30
+ * locked inside the dialog, so a row holding one keeps the action.
31
+ */
32
+ export declare function mayManageRoles(member: {
33
+ userId: string;
34
+ }, ctx: {
35
+ canManage: boolean;
36
+ selfId: string | undefined;
37
+ roles: AssignableRole[];
38
+ }): boolean;
39
+ /** The role keys of a member or invitation. */
40
+ export declare function roleKeys(roles: RoleRef[] | undefined): string[];
41
+ /** A role's display name: the member's own copy of it, else the organization's, else its key. */
42
+ export declare function roleName(role: RoleRef, roles: AssignableRole[]): string;
@@ -0,0 +1,111 @@
1
+ import { nothing, PropertyDeclarations, PropertyValues } from 'lit';
2
+ import { MessagesController } from '../../core/messages';
3
+ import { DropdownMenu } from '../../primitives/dropdown-menu/dropdown-menu';
4
+ import { AccountClient, MyOrganization } from '../provider/account-client';
5
+ import { AccountController } from '../provider/account-controller';
6
+ /** Detail of `pont2-organization-changed` (and the `onOrganizationChanged` callback). */
7
+ export interface OrganizationChangedDetail {
8
+ organizationId: string;
9
+ roles: string[];
10
+ permissions: string[];
11
+ }
12
+ /** Detail of `pont2-organization-switch-failed` (and `onSwitchFailed`). The session is unchanged. */
13
+ export interface OrganizationSwitchFailedDetail {
14
+ organizationId: string;
15
+ error: unknown;
16
+ }
17
+ /** The sentence for a refused switch: a stopped instance says so (carry-over §6), anything else is "you can't". */
18
+ export declare function describeSwitchError(error: unknown): string;
19
+ /**
20
+ * # `<pont2-organization-switcher>`: move the session to another organization
21
+ *
22
+ * ```html
23
+ * <pont2-provider app-id="app_123" domain="auth.acme.com" api-base-url="https://api.us.pontive.com">
24
+ * <pont2-organization-switcher></pont2-organization-switcher>
25
+ * </pont2-provider>
26
+ * ```
27
+ *
28
+ * The legacy `pont-organization-switcher`. The session acts in one
29
+ * organization at a time; choosing another is a refresh naming it (new
30
+ * tokens, same session, no sign-in). An outline button with the current
31
+ * organization opens a Dropdown Menu of the user's organizations as radio
32
+ * items. It **is** the Dropdown Menu primitive's root (`extends DropdownMenu`).
33
+ *
34
+ * - **Data** comes from the account client (`pont2:account-client`, or its own
35
+ * `client`): `listMyOrganizations()` (`GET /mgmt/v1/me/organizations`, the
36
+ * organizations the user is a direct member of, bounded), `getOrganization()`
37
+ * and `switchOrganization()`. It never calls the SDK or `fetch` itself.
38
+ * - **Renders nothing** until the auth state is resolved, for a signed-out
39
+ * visitor, and for a user with no organizations (a B2C app can include it
40
+ * and never show it).
41
+ * - **Follows the session:** a switch made in another tab, or by another
42
+ * switcher, moves the checked item (the client's `onSessionChange`; a client
43
+ * without one is re-read when the window regains focus). Signing in as
44
+ * someone else reloads the list.
45
+ * - **After a switch** it fires `pont2-organization-changed` and calls
46
+ * `onOrganizationChanged`, so the app can reload what it shows for the old
47
+ * organization; with `reload-on-switch` it reloads the page instead (a
48
+ * server-rendered page reads the new token from the cookie). A refused
49
+ * switch leaves the session as it was, says so inside the menu, fires
50
+ * `pont2-organization-switch-failed` and calls `onSwitchFailed`.
51
+ *
52
+ * Words: `select_organization` (no current organization; `empty-label`
53
+ * overrides it), `organization_switching`, `organization_switch_failed`,
54
+ * `instance_unavailable`.
55
+ *
56
+ * @tag pont2-organization-switcher
57
+ * @attr reload-on-switch - reload the page after a successful switch
58
+ * @attr empty-label - the button's text when the session acts in no organization (default `msg("select_organization")`)
59
+ * @prop client - its own `AccountClient` (default: the provider's)
60
+ * @prop onOrganizationChanged - `(detail: OrganizationChangedDetail) => void`, after a switch
61
+ * @prop onSwitchFailed - `(detail: OrganizationSwitchFailedDetail) => void`, when a switch is refused
62
+ * @prop organizations - `MyOrganization[]` (read-only): the list shown
63
+ * @prop currentId - `string | null` (read-only): the organization the session acts in
64
+ * @fires pont2-organization-changed - `{ organizationId, roles, permissions }`, after a switch
65
+ * @fires pont2-organization-switch-failed - `{ organizationId, error }`, when a switch is refused
66
+ * @fires pont2-open-change - cancelable `{ open, reason }` (the menu's)
67
+ */
68
+ export declare class OrganizationSwitcher extends DropdownMenu {
69
+ static composite: boolean;
70
+ static properties: PropertyDeclarations;
71
+ client: AccountClient | undefined;
72
+ reloadOnSwitch: boolean;
73
+ emptyLabel: string;
74
+ onOrganizationChanged: ((detail: OrganizationChangedDetail) => void) | undefined;
75
+ onSwitchFailed: ((detail: OrganizationSwitchFailedDetail) => void) | undefined;
76
+ organizations: MyOrganization[];
77
+ currentId: string | null;
78
+ /** The list has been read for the current user. */
79
+ loaded: boolean;
80
+ /** The organization being switched to, while a switch is in the air. */
81
+ switching: string | null;
82
+ /** The last refusal's sentence, shown in the menu until the next attempt. */
83
+ error: string | null;
84
+ protected readonly messages: MessagesController;
85
+ protected readonly account: AccountController;
86
+ /** Bumped per list read, so only the latest answer is shown. */
87
+ private loadSeq;
88
+ /** Who the list was read for (`sub`), so a sign-in as someone else reads it again. */
89
+ private loadedFor;
90
+ constructor();
91
+ /** Reads the list again (and the current organization). */
92
+ reload(): Promise<void>;
93
+ private refresh;
94
+ private whoAmI;
95
+ private readCurrent;
96
+ private load;
97
+ /** Moves the session to `organizationId`, as choosing it in the menu does. */
98
+ select(organizationId: string): Promise<void>;
99
+ private nameOf;
100
+ protected willUpdate(changed: PropertyValues): void;
101
+ render(): import('lit-html').TemplateResult<1> | typeof nothing;
102
+ }
103
+ declare global {
104
+ interface HTMLElementTagNameMap {
105
+ "pont2-organization-switcher": OrganizationSwitcher;
106
+ }
107
+ interface HTMLElementEventMap {
108
+ "pont2-organization-changed": CustomEvent<OrganizationChangedDetail>;
109
+ "pont2-organization-switch-failed": CustomEvent<OrganizationSwitchFailedDetail>;
110
+ }
111
+ }
@@ -0,0 +1,355 @@
1
+ import { SessionChange } from './sdk';
2
+ /**
3
+ * # `AccountClient`: what the account widgets talk to (migration decision D9, tracker W-12)
4
+ *
5
+ * The signed-in widgets (account menu, organization switcher, and later
6
+ * account settings and member management) never call the auth SDK or `fetch`
7
+ * themselves. They talk to an injected `AccountClient`, the way the flow
8
+ * widgets talk to their `WidgetClient`:
9
+ *
10
+ * - `<pont2-provider>` builds the default one from its SDK and `api-base-url`
11
+ * (`createAccountClient`) and provides it as `pont2:account-client`;
12
+ * - an app can provide its own (`provider.accountClient = …`), or give one
13
+ * widget its own (`widget.client = …`), which wins.
14
+ *
15
+ * ## Shape, and how it grows
16
+ *
17
+ * The interface is the **session part** (required: every account widget needs
18
+ * it) plus the **profile** (account settings, W-8) and **members** (member
19
+ * management, W-10) parts, which are optional on `AccountClient` so that an app
20
+ * whose own client only drives the menu and the switcher need not implement
21
+ * them. The default client implements all three. Methods added later are
22
+ * added as **optional** members, so an app's own client keeps compiling; a
23
+ * widget that needs a method the client lacks says it can't do that.
24
+ *
25
+ * Every request method rejects with an {@link AccountApiError} (or the SDK's
26
+ * `ManagementTokenError`, which carries a `code` as well): read `code` and
27
+ * `status`, never the English `message`.
28
+ */
29
+ /** Who is signed in, from the session's claims (OpenID Connect names). Local: no request. */
30
+ export interface SessionUser {
31
+ sub?: string;
32
+ email?: string;
33
+ name?: string;
34
+ given_name?: string;
35
+ family_name?: string;
36
+ picture?: string;
37
+ username?: string;
38
+ }
39
+ /** The organization the session acts in (the access token's `org_id`), with the user's roles there. */
40
+ export interface SessionOrganization {
41
+ id: string;
42
+ roles: string[];
43
+ permissions: string[];
44
+ }
45
+ /** One organization the signed-in user is a direct member of (`GET /mgmt/v1/me/organizations`). */
46
+ export interface MyOrganization {
47
+ id: string;
48
+ /** The organization's display name; may be missing (show the id). */
49
+ name?: string;
50
+ roles: {
51
+ key: string;
52
+ name?: string;
53
+ }[];
54
+ }
55
+ export interface SignOutOptions {
56
+ /** Where the browser comes back to when the sign-out leaves the page (must be registered on the app). */
57
+ returnTo?: string;
58
+ }
59
+ /** The management API's list pagination. */
60
+ export interface PageInfo {
61
+ page: number;
62
+ limit: number;
63
+ total: number;
64
+ total_pages: number;
65
+ }
66
+ /** One page of a management-API list. */
67
+ export interface Page<T> {
68
+ data: T[];
69
+ pagination?: PageInfo;
70
+ }
71
+ /** The signed-in user's own profile (`GET /mgmt/v1/me`), as the management API sends it. */
72
+ export interface AccountProfile {
73
+ id: string;
74
+ email?: string;
75
+ email_verified?: boolean;
76
+ phone?: string;
77
+ phone_verified?: boolean;
78
+ username?: string;
79
+ name?: string;
80
+ given_name?: string;
81
+ middle_name?: string;
82
+ family_name?: string;
83
+ nickname?: string;
84
+ gender?: string;
85
+ birthdate?: number;
86
+ picture?: string;
87
+ profile?: string;
88
+ website?: string;
89
+ locale?: string;
90
+ zoneinfo?: string;
91
+ address?: {
92
+ country?: string;
93
+ formatted?: string;
94
+ locality?: string;
95
+ postal_code?: string;
96
+ region?: string;
97
+ street_address?: string;
98
+ };
99
+ metadata?: Record<string, unknown>;
100
+ created_at?: number;
101
+ updated_at?: number;
102
+ }
103
+ /** What `PATCH /mgmt/v1/me` takes: the fields to change. */
104
+ export type AccountProfileUpdate = Partial<Omit<AccountProfile, "id" | "email_verified" | "phone_verified" | "created_at" | "updated_at">>;
105
+ /** A role on a member or an invitation. */
106
+ export interface RoleRef {
107
+ key: string;
108
+ name?: string;
109
+ }
110
+ /** A member of an organization (`GET /mgmt/v1/organizations/{id}/members`). */
111
+ export interface OrganizationMember {
112
+ id: string;
113
+ organization_id: string;
114
+ roles: RoleRef[];
115
+ joined_at?: string;
116
+ last_active_at?: string;
117
+ created_at?: string;
118
+ updated_at?: string;
119
+ user: {
120
+ id: string;
121
+ email?: string;
122
+ email_verified?: boolean;
123
+ name?: string;
124
+ given_name?: string;
125
+ family_name?: string;
126
+ picture?: string;
127
+ status?: string;
128
+ username?: string;
129
+ };
130
+ }
131
+ /** A pending invitation (`GET /mgmt/v1/organizations/{id}/invitations`). */
132
+ export interface OrganizationInvitation {
133
+ id: string;
134
+ organization_id: string;
135
+ invitee_email: string;
136
+ roles: RoleRef[];
137
+ invited_by?: {
138
+ id: string;
139
+ name?: string;
140
+ };
141
+ created_at?: number;
142
+ updated_at?: number;
143
+ expires_at?: number;
144
+ last_sent_at?: number;
145
+ resend_count?: number;
146
+ message?: string;
147
+ }
148
+ /**
149
+ * A role a member can be given (`GET /mgmt/v1/organizations/{id}/assignable-roles`), marked with
150
+ * whether the caller may assign or remove it (carry-over §5: a locked role is shown locked).
151
+ */
152
+ export interface AssignableRole {
153
+ key: string;
154
+ name: string;
155
+ description?: string;
156
+ /** Assigning or removing it transfers ownership (`owner`). */
157
+ requires_transfer: boolean;
158
+ assignable_by_caller: boolean;
159
+ organization_scoped: boolean;
160
+ }
161
+ export interface ListParams {
162
+ search?: string;
163
+ page?: number;
164
+ limit?: number;
165
+ order?: string;
166
+ /** Comma-separated role keys. */
167
+ roles?: string;
168
+ }
169
+ export interface MemberListParams extends ListParams {
170
+ user_ids?: string[];
171
+ emails?: string[];
172
+ }
173
+ export interface InvitationListParams extends ListParams {
174
+ invitee_emails?: string[];
175
+ }
176
+ export interface InviteMembersRequest {
177
+ emails: string[];
178
+ /** Organization roles; with none, the organization's roles-on-join apply. */
179
+ roles?: string[];
180
+ message?: string;
181
+ /** The app the invitation is for. The default client fills in the provider's `app-id` (carry-over §5). */
182
+ app_id?: string;
183
+ }
184
+ /** What every account widget needs: the session, the user's organizations, switching, signing out. */
185
+ export interface AccountSessionApi {
186
+ /** Who is signed in (local), or `null`. */
187
+ getUser(): SessionUser | null;
188
+ /** The organization the session acts in (local), or `null` for none. */
189
+ getOrganization(): SessionOrganization | null;
190
+ /** The organizations the user is a direct member of. A bounded list: it is for a menu. */
191
+ listMyOrganizations(): Promise<MyOrganization[]>;
192
+ /**
193
+ * Moves the session to `organizationId` (new tokens, no sign-in) and resolves with the
194
+ * organization it now acts in. Rejects, leaving the session as it was, when refused.
195
+ */
196
+ switchOrganization(organizationId: string): Promise<SessionOrganization | null>;
197
+ /** Ends the session, here and at the authorization server (which may leave the page). */
198
+ signOut(options?: SignOutOptions): Promise<void>;
199
+ /**
200
+ * Tells `listener` about every session change, in this tab or another (sign-in, refresh,
201
+ * organization switch, sign-out, expiry). Returns the unsubscribe. Optional: a widget whose
202
+ * client lacks it re-reads the session when the window regains focus.
203
+ */
204
+ onSessionChange?(listener: (change: SessionChange) => void): () => void;
205
+ }
206
+ /** Account settings (W-8): the user's own profile, with the session's token. */
207
+ export interface AccountProfileApi {
208
+ getProfile(): Promise<AccountProfile>;
209
+ updateProfile(update: AccountProfileUpdate): Promise<AccountProfile>;
210
+ }
211
+ /**
212
+ * Member management (W-10). Every call uses a **management-API token**, drawn before each
213
+ * request (the SDK caches it), never the session's access token (carry-over §5).
214
+ */
215
+ export interface AccountMembersApi {
216
+ /** Whether the session is known to hold `scope` (the member scopes read false until a management token was drawn). */
217
+ hasScope(scope: string): boolean;
218
+ /** Draws (or reuses) a management token and resolves with its scopes. */
219
+ getManagementScopes(): Promise<string[]>;
220
+ listMembers(organizationId: string, params?: MemberListParams): Promise<Page<OrganizationMember>>;
221
+ updateMemberRoles(organizationId: string, userId: string, roles: string[]): Promise<void>;
222
+ removeMember(organizationId: string, userId: string): Promise<void>;
223
+ listInvitations(organizationId: string, params?: InvitationListParams): Promise<Page<OrganizationInvitation>>;
224
+ inviteMembers(organizationId: string, request: InviteMembersRequest): Promise<Page<OrganizationInvitation>>;
225
+ resendInvitation(organizationId: string, invitationId: string): Promise<void>;
226
+ revokeInvitation(organizationId: string, invitationId: string, options?: {
227
+ notifyInvitee?: boolean;
228
+ }): Promise<void>;
229
+ listAssignableRoles(organizationId: string): Promise<AssignableRole[]>;
230
+ /**
231
+ * The OAuth scopes the app asks for at sign-in (the provider's `scope`), so that a refused
232
+ * management token can be explained: an app that never requests the member scopes is set up
233
+ * wrong, one that does is refused for the user's roles (carry-over §5). Optional: without it the
234
+ * widget assumes they are requested.
235
+ */
236
+ requestedScopes?(): string[];
237
+ }
238
+ /** The account widgets' client: the session part, plus the parts the settings and members widgets need. */
239
+ export interface AccountClient extends AccountSessionApi, Partial<AccountProfileApi>, Partial<AccountMembersApi> {
240
+ }
241
+ /**
242
+ * `pont2:account-client`: the account widgets' client. Undefined until the provider has configured
243
+ * its SDK (or when the SDK can't serve one); an app's own `provider.accountClient` is provided as is.
244
+ */
245
+ export declare const accountClientContext: {
246
+ __context__: AccountClient | undefined;
247
+ };
248
+ /**
249
+ * A refused or failed account request. `code` is the error envelope's `error.code`
250
+ * (`role_ceiling`, `instance_unavailable` …) when the server sent one, or the client's own:
251
+ * `NETWORK_ERROR` (no answer), `NOT_AUTHENTICATED` (no session to send), `INVALID_REQUEST` (no
252
+ * usable `api-base-url`). `status` is 0 when no response came back.
253
+ */
254
+ export declare class AccountApiError extends Error {
255
+ readonly status: number;
256
+ readonly code?: string;
257
+ readonly data?: unknown;
258
+ constructor(message: string, status: number, code?: string, data?: unknown);
259
+ }
260
+ /** The code a failed account call carries: its own `code`, or its body's `error.code`. */
261
+ export declare function accountErrorCode(error: unknown): string | undefined;
262
+ /** The management token's refusal code (`ManagementTokenError.code`), or undefined for anything else. */
263
+ export declare function tokenErrorCode(error: unknown): string | undefined;
264
+ /** No answer came back at all. */
265
+ export declare function isNetworkFailure(error: unknown): boolean;
266
+ /**
267
+ * What the default client needs from the auth SDK. `Auth` (`@pontive/oidc-client` ≥ 1.7.0)
268
+ * satisfies it, pinned by `flow-widget/sdk-compat.test.ts`.
269
+ */
270
+ export interface AccountSdk {
271
+ getAuthenticatedUser(): SessionUser | null;
272
+ getCurrentSession(): {
273
+ access_token: string;
274
+ } | null;
275
+ getOrganization(): SessionOrganization | null;
276
+ switchOrganization(organizationId: string): Promise<unknown>;
277
+ signOut(options?: SignOutOptions): Promise<void>;
278
+ getManagementToken(apiBaseUrl: string): Promise<{
279
+ access_token: string;
280
+ scopes: string[];
281
+ }>;
282
+ hasScope(scope: string): boolean;
283
+ onSessionChange?(listener: (change: SessionChange) => void): () => void;
284
+ }
285
+ /** Whether `sdk` has what the default account client needs (an older SDK or a flow-only fake may not). */
286
+ export declare function isAccountSdk(sdk: unknown): sdk is AccountSdk;
287
+ export interface AccountClientOptions {
288
+ sdk: AccountSdk;
289
+ /** The management gateway (`https://api.us.pontive.com`); `/mgmt/v1` is added. */
290
+ apiBaseUrl: string;
291
+ /** The app's id, sent as an invitation's `app_id` when the caller gives none. */
292
+ appId?: string;
293
+ /** Extra request headers (the provider's `headers`, as the legacy kit sent them). */
294
+ headers?: Record<string, string>;
295
+ /** The scopes the app requests at sign-in (the provider's `scope`), for `requestedScopes()`. */
296
+ scope?: string | string[];
297
+ /** For tests. */
298
+ fetch?: typeof fetch;
299
+ }
300
+ /**
301
+ * The management gateway's path prefix. The load balancer routes on it: without it a request is
302
+ * answered by the balancer (a bare 404 without CORS headers, which a browser reports as a CORS failure).
303
+ */
304
+ export declare const MANAGEMENT_PREFIX = "/mgmt/v1";
305
+ /** `/me/organizations` page size, and how many pages a switcher reads at most: it is a menu, not a directory. */
306
+ export declare const MY_ORGANIZATIONS_PAGE_SIZE = 100;
307
+ export declare const MY_ORGANIZATIONS_MAX_PAGES = 5;
308
+ /** The gateway base without a trailing slash, or `null` unless it is an absolute http(s) URL. */
309
+ export declare function managementBase(apiBaseUrl: string | undefined): string | null;
310
+ /**
311
+ * The default {@link AccountClient}: the session from the SDK, `/me` routes with the session's
312
+ * access token, organization routes with a management token drawn before **each** request
313
+ * (`getManagementToken`, cached and coalesced by the SDK; carry-over §5). What the legacy
314
+ * `src/service/http` did, as one object.
315
+ */
316
+ export declare class SdkAccountClient implements AccountSessionApi, AccountProfileApi, AccountMembersApi {
317
+ readonly sdk: AccountSdk;
318
+ readonly apiBaseUrl: string;
319
+ readonly appId: string | undefined;
320
+ readonly headers: Record<string, string>;
321
+ readonly scope: string | string[] | undefined;
322
+ private readonly fetchImpl;
323
+ constructor(options: AccountClientOptions);
324
+ getUser(): SessionUser | null;
325
+ getOrganization(): SessionOrganization | null;
326
+ listMyOrganizations(): Promise<MyOrganization[]>;
327
+ switchOrganization(organizationId: string): Promise<SessionOrganization | null>;
328
+ signOut(options?: SignOutOptions): Promise<void>;
329
+ onSessionChange(listener: (change: SessionChange) => void): () => void;
330
+ getProfile(): Promise<AccountProfile>;
331
+ updateProfile(update: AccountProfileUpdate): Promise<AccountProfile>;
332
+ hasScope(scope: string): boolean;
333
+ getManagementScopes(): Promise<string[]>;
334
+ listMembers(organizationId: string, params?: MemberListParams): Promise<Page<OrganizationMember>>;
335
+ updateMemberRoles(organizationId: string, userId: string, roles: string[]): Promise<void>;
336
+ removeMember(organizationId: string, userId: string): Promise<void>;
337
+ listInvitations(organizationId: string, params?: InvitationListParams): Promise<Page<OrganizationInvitation>>;
338
+ inviteMembers(organizationId: string, request: InviteMembersRequest): Promise<Page<OrganizationInvitation>>;
339
+ resendInvitation(organizationId: string, invitationId: string): Promise<void>;
340
+ revokeInvitation(organizationId: string, invitationId: string, options?: {
341
+ notifyInvitee?: boolean;
342
+ }): Promise<void>;
343
+ listAssignableRoles(organizationId: string): Promise<AssignableRole[]>;
344
+ requestedScopes(): string[];
345
+ private list;
346
+ private managementToken;
347
+ private bearer;
348
+ /**
349
+ * One management-API request. No credentials and no instance header: the bearer's issuer
350
+ * names the instance, so the request needs nothing else (and no credentialed CORS).
351
+ */
352
+ private request;
353
+ }
354
+ /** The default account client over `sdk`. */
355
+ export declare function createAccountClient(options: AccountClientOptions): SdkAccountClient;
@@ -0,0 +1,47 @@
1
+ import { ReactiveController, ReactiveElement } from 'lit';
2
+ import { AccountClient } from './account-client';
3
+ import { AuthState } from './contexts';
4
+ import { SessionChange } from './sdk';
5
+ /** Why an account widget is asked to look at the session again. */
6
+ export type AccountRefreshReason = "client" | "auth" | "session" | "focus";
7
+ /**
8
+ * # AccountController: what every account widget follows
9
+ *
10
+ * - **The client:** the widget's own `client` (an app's), else the provider's
11
+ * `pont2:account-client`.
12
+ * - **The auth state:** the provider's `pont2:auth`. Nothing is decided until
13
+ * it is `resolved` (the interim answer is "signed out", so acting on it would
14
+ * flash a signed-out widget at a signed-in user). A widget given its own
15
+ * client with no provider around takes the client's `getUser()` as the answer.
16
+ * - **Session changes:** the client's `onSessionChange` (the SDK's, in this tab
17
+ * or another: an organization switch, a sign-in as someone else …). A client
18
+ * without it gets a re-read whenever the window regains focus, as the legacy
19
+ * switcher did.
20
+ *
21
+ * It calls `onRefresh(reason, change?)` whenever any of these changes; the
22
+ * widget re-reads what it shows.
23
+ */
24
+ export declare class AccountController implements ReactiveController {
25
+ private readonly host;
26
+ private readonly ownClient;
27
+ private readonly onRefresh;
28
+ private readonly clientConsumer;
29
+ private readonly authConsumer;
30
+ private subscribedTo;
31
+ private unsubscribe;
32
+ private lastAuth;
33
+ private focusListening;
34
+ constructor(host: ReactiveElement, ownClient: () => AccountClient | undefined, onRefresh: (reason: AccountRefreshReason, change?: SessionChange) => void);
35
+ /** The client the widget talks to, or undefined while there is none. */
36
+ get client(): AccountClient | undefined;
37
+ /** The auth state the widget follows. */
38
+ get auth(): AuthState;
39
+ /** Signed in, as far as the provider (or the widget's own client) has said. */
40
+ get signedIn(): boolean;
41
+ hostConnected(): void;
42
+ hostDisconnected(): void;
43
+ /** After every host update: (re)subscribe to the client, and report what changed. */
44
+ hostUpdated(): void;
45
+ private listenForFocus;
46
+ private onFocus;
47
+ }
@@ -0,0 +1,16 @@
1
+ import { SessionUser } from './account-client';
2
+ /** The name to show for a user: `name`, else given + family name, else the username. */
3
+ export declare function displayName(user: SessionUser | null | undefined): string;
4
+ /** Whether `href` names the page already open (same path and query): following it would only reload. */
5
+ export declare function isCurrentPage(href: string, here?: {
6
+ href: string;
7
+ pathname: string;
8
+ search: string;
9
+ }): boolean;
10
+ /**
11
+ * Up to two letters for an avatar fallback: the first and last words' initials ("Ada Lovelace" →
12
+ * "AL"), two letters of a single word ("acme" → "AC"). An email is reduced to its local part first
13
+ * (the domain is shared by every colleague), split on `.`, `_` and `-` ("ada.lovelace@…" → "AL"),
14
+ * as the legacy `getInitials` does.
15
+ */
16
+ export declare function accountInitials(text: string | undefined | null): string;