-
Notifications
You must be signed in to change notification settings - Fork 6
Widget lifecycle module api #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/element-web-module-api/src/api/widget-lifecycle.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* | ||
| Copyright 2026 Element Creations Ltd. | ||
|
|
||
| SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial | ||
| Please see LICENSE files in the repository root for full details. | ||
| */ | ||
|
|
||
| /** | ||
| * A description of a widget passed to approver callbacks. | ||
| * Contains the information needed to make approval decisions. | ||
| * @alpha Subject to change. | ||
| */ | ||
| export type WidgetDescriptor = { | ||
| /** The unique identifier of the widget. */ | ||
| id: string; | ||
| /** The template URL of the widget, which may contain `$matrix_*` placeholder variables. */ | ||
| templateUrl: string; | ||
| /** The Matrix user ID of the user who created the widget. */ | ||
| creatorUserId: string; | ||
| /** The widget type, e.g. `m.custom`, `m.jitsi`, `m.stickerpicker`. */ | ||
| type: string; | ||
| /** The origin of the widget URL. */ | ||
| origin: string; | ||
| /** The room ID the widget belongs to, if it is a room widget. */ | ||
| roomId?: string; | ||
| }; | ||
|
|
||
| /** | ||
| * Callback that decides whether a widget should be auto-approved for preloading | ||
| * (i.e. loaded without the user clicking "Continue"). | ||
| * Return `true` to auto-approve, or any other value to defer to the default consent flow. | ||
| * @alpha Subject to change. | ||
| */ | ||
| export type PreloadApprover = (widget: WidgetDescriptor) => boolean | Promise<boolean> | undefined; | ||
| /** | ||
| * Callback that decides whether a widget should be auto-approved to receive | ||
| * the user's OpenID identity token. | ||
| * Return `true` to auto-approve, or any other value to defer to the default consent flow. | ||
| * @alpha Subject to change. | ||
| */ | ||
| export type IdentityApprover = (widget: WidgetDescriptor) => boolean | Promise<boolean> | undefined; | ||
| /** | ||
| * Callback that decides which of a widget's requested capabilities should be auto-approved. | ||
| * Return a `Set` of approved capability strings, or `undefined` to defer to the default consent flow. | ||
| * @alpha Subject to change. | ||
| */ | ||
| export type CapabilitiesApprover = ( | ||
| widget: WidgetDescriptor, | ||
| requestedCapabilities: Set<string>, | ||
| ) => Set<string> | Promise<Set<string> | undefined> | undefined; | ||
|
|
||
| /** | ||
| * API for modules to auto-approve widget preloading, identity token requests, and capability requests. | ||
| * @alpha Subject to change. | ||
| */ | ||
| export interface WidgetLifecycleApi { | ||
| /** | ||
| * Register a handler that can auto-approve widget preloading. | ||
| * Returning true auto-approves; any other value results in no auto-approval. | ||
| */ | ||
| registerPreloadApprover(approver: PreloadApprover): void; | ||
|
|
||
| /** | ||
| * Register a handler that can auto-approve identity token requests. | ||
| * Returning true auto-approves; any other value results in no auto-approval. | ||
| */ | ||
| registerIdentityApprover(approver: IdentityApprover): void; | ||
|
|
||
| /** | ||
| * Register a handler that can auto-approve widget capabilities. | ||
| * Return a set containing the capabilities to approve. | ||
| */ | ||
| registerCapabilitiesApprover(approver: CapabilitiesApprover): void; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.