-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add new notify mechanism and refined selfAddr
semantics, rate limits API and rework sendUpdate docs and drop 'descr'
#94
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3fd9ea9
removing the `descr` parameter that was never really used except for …
hpk42 8e4bd98
introduce limits for sendUpdate and realtime (#91)
hpk42 9d02a5b
docs: webxdc notify & privacy preserving selfAddr (#90)
r10s 65a0269
require the descr argument for now (desktop 1.48.0 depends on it, and…
hpk42 959b9dc
refine messenger spec (#95)
hpk42 dd963e7
add docs for notify and href also to the receiving side (setUpdateLis…
hpk42 26eb5a5
better wording
hpk42 e0cfc02
more wording
hpk42 05d4ae6
start doing a changelog
hpk42 290d0e2
reference spec changelog from TOC
hpk42 ba4813b
bring back some of the previous wording, as suggested by review in chat
hpk42 e1a0e19
reword the linkability aspect and degrade it to "SHOULD"
hpk42 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 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 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 |
---|---|---|
@@ -1,19 +1,6 @@ | ||
|
||
# Compatibility | ||
|
||
## Other APIs and Tags Usage Hints | ||
|
||
Webxdc apps run in a restricted environment, but the following practices are permitted: | ||
|
||
- `localStorage`, `sessionStorage`, `indexedDB` | ||
- `visibilitychange` events | ||
- `window.navigator.language` | ||
- internal links, such as `<a href="localfile.html">` | ||
- `mailto` links, such as `<a href="mailto:[email protected]?body=...">` | ||
- `<meta name="viewport" ...>` is useful especially as webviews from different platforms have different defaults | ||
- `<input type="file">` allows importing of files for further | ||
processing; see [`sendToChat()`](../spec/sendToChat.md) for a way to export files | ||
|
||
### Discouraged Practises | ||
|
||
- `document.cookie` is known not to work on desktop and iOS—use `localStorage` instead | ||
|
This file contains 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,31 @@ | ||
# Changelog | ||
|
||
## [1.2] - 2024-12-15 | ||
|
||
### New APIs | ||
|
||
- modify `webxdc.selfAddr` to return a per-app identifier | ||
that can be used for the new "notify" list | ||
|
||
- add new `update.notify` attribute to allow causing | ||
a user-visible system notification to raise awareness | ||
that something in an app changed | ||
|
||
- add new `update.href` attribute so that clicking info messages | ||
will provide a "deep link" into an app to ease navigation | ||
|
||
- add new `webxdc.sendUpdateMaxInterval` and `webxdc.sendUpdateMaxSize` | ||
rate limits which helps apps to adapt to transport characteristics/limitations | ||
|
||
|
||
### Deprecations | ||
|
||
- `webxdc.sendUpdate` does not take a "descr" argument anymore. | ||
|
||
|
||
### Other changes | ||
|
||
- shifted "supported" DOM/Javascript features from the FAQ | ||
into the messenger spec section | ||
|
||
- improved wording in several places |
This file contains 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 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 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 |
---|---|---|
|
@@ -9,49 +9,69 @@ The same webxdc container file shared in two separate chat messages | |
will be regarded as two separate "webxdc apps" | ||
and the two apps can not communicate with, or even know about, each other. | ||
|
||
### Webview Constraints for Running Apps | ||
### Webview Constraints | ||
|
||
When starting a web view for a webxdc app to run, messenger implementors: | ||
When starting a web view for a webxdc app to run, messenger implementors | ||
|
||
- MUST run the [webxdc container file](./format.md) in a constrained, | ||
network-isolated webview that | ||
MUST deny all forms of internet access. | ||
If you don't do this | ||
unsuspecting users may leak data of their private interactions to outside third parties. | ||
You do not need to offer "privacy" or "cookie" consent screens as | ||
there is no way a webxdc app can implicitly transfer user data to the internet. | ||
- MUST serve all resources from the [webxdc container file](./format.md) | ||
to the webxdc application. | ||
|
||
- on initial opening, MUST open root URL for the webview with `index.html` appended | ||
- MUST implement the [Webxdc Javascript API](api.md) | ||
and serve a `webxdc.js` file accordingly. | ||
|
||
- MUST deny all forms of Internet access; | ||
if you don't restrict internet access | ||
unsuspecting users may run 3rd party apps | ||
that leak data of private interactions to outside third parties. | ||
See ["Bringing E2E privacy to the web"](https://delta.chat/en/2023-05-22-webxdc-security) | ||
which contains a deep discussion of the unique privacy guarantees of webxdc. | ||
|
||
- MUST support `localStorage`, `sessionStorage` and `indexedDB` | ||
|
||
- MUST isolate all storage and state of one webxdc app from any other | ||
|
||
- MUST support `visibilitychange` events | ||
|
||
- MUST allow unrestricted use of DOM storage (local storage, indexed db and co), | ||
but make sure it is scoped to each webxdc app so they can not delete or modify | ||
the data of other webxdc content. | ||
- MUST support `window.navigator.language` | ||
|
||
- MUST inject `webxdc.js` and implement the | ||
[Webxdc Javascript API](api.md) so that messages are relayed and shown in chats. | ||
- MUST support `window.location.href` but you can not specify or assume anything | ||
about the protocol scheme or domain part of the url. | ||
|
||
- MUST make sure the standard JavaScript API works as described at | ||
[Other APIs and Tags Usage Hints](../faq/compat.md#other-apis-and-tags-usage-hints). | ||
- MUST support HTML links such as `<a href="localfile.html">` | ||
|
||
- MUST support `mailto` links, such as `<a href="mailto:[email protected]?body=...">` | ||
|
||
- MUST support `<meta name="viewport" ...>` is useful especially as webviews from different platforms have different defaults | ||
|
||
- MUST support `<input type="file">` to allow importing of files; | ||
see [`sendToChat()`](../spec/sendToChat.md) for a way to export files. | ||
|
||
In ["Bringing E2E privacy to the web"](https://delta.chat/en/2023-05-22-webxdc-security) | ||
Delta Chat developers discuss the unique privacy guarantees of webxdc, | ||
and which mitigations messengers using Chromium webviews need to implement to satisfy them. | ||
|
||
### UI Interactions in Chats | ||
|
||
- Text from `update.info` SHOULD be shown in the chats | ||
and tapping them should jump to their webxdc message | ||
and tapping them SHOULD open the webxdc app directly. | ||
If `update.href` was set then the webxdc app MUST | ||
be started with the root URL for the webview with | ||
the value of `update.href` appended. | ||
|
||
- The most recent text from `update.document` and `update.summary` SHOULD be shown inside the webxdc message, | ||
- The most recent text from `update.document` | ||
and `update.summary` SHOULD be shown inside the webxdc message, | ||
together with name and icon. | ||
Only one line of text SHOULD be shown and truncation is fine | ||
as webxdc devs SHOULD NOT be encouraged to send long texts here. | ||
as webxdc application developers SHOULD NOT be encouraged to send long texts here. | ||
|
||
- A "Start" button MUST be offered that runs the webxdc app. | ||
Note that there is no need to ask for "privacy" or "cookie" consent because | ||
there is no way a webxdc app can implicitly transfer user data to the internet. | ||
|
||
- A "Start" button SHOULD run the webxdc app. | ||
|
||
### Example Messenger Implementations | ||
|
||
- [Android using Java](https://github.com/deltachat/deltachat-android/blob/master/src/org/thoughtcrime/securesms/WebxdcActivity.java) | ||
- [Delta Chat Android using Java](https://github.com/deltachat/deltachat-android/blob/master/src/org/thoughtcrime/securesms/WebxdcActivity.java) | ||
|
||
- [iOS using Swift](https://github.com/deltachat/deltachat-ios/blob/master/deltachat-ios/Controller/WebxdcViewController.swift) | ||
- [Delta Chat iOS using Swift](https://github.com/deltachat/deltachat-ios/blob/master/deltachat-ios/Controller/WebxdcViewController.swift) | ||
|
||
- [Desktop using TypeScript](https://github.com/deltachat/deltachat-desktop/blob/786b7514d69ffb723bbe6e706494852a2641bfcd/src/main/deltachat/webxdc.ts) | ||
- [Delta Chat Desktop using TypeScript](https://github.com/deltachat/deltachat-desktop/blob/786b7514d69ffb723bbe6e706494852a2641bfcd/src/main/deltachat/webxdc.ts) | ||
|
This file contains 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 |
---|---|---|
@@ -1,27 +1,76 @@ | ||
# selfAddr & selfName | ||
|
||
## selfName | ||
|
||
```js | ||
window.webxdc.selfName | ||
``` | ||
|
||
`selfName` is the nick or display name for the user | ||
which the webxdc application may show in its user interface. | ||
|
||
|
||
## selfAddr | ||
|
||
```js | ||
window.webxdc.selfAddr | ||
``` | ||
|
||
A string with an unique ID identifying the user in the current webxdc. | ||
Every user of an webxdc must get a different ID | ||
and that ID must be the same if the webxdc is started again later for the same user. | ||
The same user in different webxdc, however, may have different IDs. | ||
`selfAddr` is a unique string within a webxdc application that | ||
|
||
Especially useful if you want to differentiate between different peers - | ||
just send the ID along with the payload, | ||
and, if needed, compare the payload addresses against `selfAddr` later on. | ||
- has no meaning outside the webxdc app, | ||
|
||
## selfName | ||
- can be used in other webxdc APIs, | ||
|
||
- should not be shown in the user interface of the webxdc application, | ||
|
||
- is identical across multiple invocations of the same webxdc application, | ||
|
||
- is identical on multiple devices of the user using the same webxdc application. | ||
|
||
- is not linkable to addresses in other webxdc apps: | ||
even if a web app manipulates users to share addresses via copy+paste with another web app, | ||
addresses between the two web apps can not be correlated. | ||
|
||
|
||
## Example using selfAddr and selfName | ||
|
||
Here is a simple chat app that sends out a reply using the display names | ||
but uses the addresses for notifications. | ||
|
||
```js | ||
window.webxdc.selfName | ||
``` | ||
|
||
Name of the current account, as defined in settings. | ||
If empty, this defaults to the peer's address. | ||
// Receive a message from anyone in the chat | ||
let users = new Set(); | ||
|
||
setUpdateListener((update) => { | ||
const prompt = `${update.payload.senderName} (${update.payload.senderAddr}):`; | ||
users.add(update.payload.senderAddr); | ||
console.log(`${prompt} ${update.message}`); | ||
}) | ||
|
||
// start some user interface which calls the following function for | ||
// message sending | ||
|
||
sendMessage(text) => { | ||
let payload = { | ||
senderAddr: webxdc.selfAddr, | ||
senderName: webxdc.selfName, | ||
message: text | ||
}; | ||
|
||
// notify all users who ever sent a message in the chat app | ||
let notify = {}; | ||
for (const addr of users) { | ||
notify[addr] = `new message from ${webxdc.selfName}`; | ||
} | ||
|
||
sendUpdate({ | ||
payload: payload, | ||
notify: notify | ||
}) | ||
}) | ||
``` | ||
|
||
|
||
[`sendUpdate()`]: ./sendUpdate.html |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is moved to
spec/messenger.md
because it's a requirement not some hint.