Skip to content
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

Latest changes for thirdroom/dev #1091

Merged
merged 198 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
198 commits
Select commit Hold shift + click to select a range
087a4ad
Add copy permalink action
MadLittleMods Nov 11, 2022
f0d53fe
Remove newline
MadLittleMods Nov 11, 2022
29aac09
Add types to function parameters
MadLittleMods Nov 11, 2022
35a08e3
Update language to "Copy matrix.to permalink"
MadLittleMods Nov 18, 2022
772d91f
WIP
MidhunSureshR Feb 16, 2023
d81864e
WIP
MidhunSureshR Feb 16, 2023
e6ea003
WIP +1
MidhunSureshR Feb 17, 2023
3321859
Add more stages
MidhunSureshR Feb 22, 2023
5e1dca9
Free olmSas after all stages have completed
MidhunSureshR Feb 22, 2023
af918e3
Remove comment
MidhunSureshR Feb 22, 2023
75688cf
REFACTOR: Extract methods and functions
MidhunSureshR Feb 22, 2023
ed4eb9b
Emit event from DeviceMessageHandler
MidhunSureshR Feb 27, 2023
e46b760
Remove log
MidhunSureshR Feb 27, 2023
b6041cd
Channel WIP
MidhunSureshR Feb 27, 2023
1510905
Store cross-signing keys in format as returned from server, in separa…
bwindels Feb 24, 2023
b8fb2b6
Store device keys in format needed to sign/verify, convert to TS
bwindels Feb 27, 2023
683e055
WIP
MidhunSureshR Mar 1, 2023
daf66e1
implement signing users and other devices
bwindels Mar 2, 2023
a9412aa
fix import paths after TS conversion
bwindels Mar 2, 2023
4dce93e
make sure the key property doesn't leak out of the storage layer
bwindels Mar 2, 2023
20a6fcd
don't allow signing own user
bwindels Mar 2, 2023
504d869
provide correct user id for signing key owner when signing other user
bwindels Mar 2, 2023
34b113b
don't upload pre-existing signatures when signing
bwindels Mar 2, 2023
3a303ff
cleanup comments
bwindels Mar 2, 2023
fa662db
show cross-sign user option in right panel
bwindels Mar 2, 2023
9789e58
cleanup
bwindels Mar 2, 2023
1dc3aca
use enum for device tracking status
bwindels Mar 2, 2023
7d806b0
mark all existing user identities outdated as cross-signing keys missing
bwindels Mar 3, 2023
c747d5f
rename deviceTrackingStatus to keysTrackingStatus
bwindels Mar 3, 2023
2563aa2
actually write modified values in migration
bwindels Mar 3, 2023
08984ad
log amount of marked user identities in migration
bwindels Mar 3, 2023
eff495c
also delete old crossSigningKeys field on userIdentities
bwindels Mar 3, 2023
c2ee824
fix lint warning from previous cross-signing PR
bwindels Mar 3, 2023
774efc1
extract method to sign key, as most params are always the same
bwindels Mar 3, 2023
4c7f784
implement verifying signaturs for user trust (green shield/red shield)
bwindels Mar 3, 2023
149f187
expose user trust in member panel
bwindels Mar 3, 2023
e00d02a
fix ts error
bwindels Mar 3, 2023
78b5d69
Upgrade olm
MidhunSureshR Mar 4, 2023
c9b462c
Implement mac and done stage
MidhunSureshR Mar 4, 2023
4540ba2
Implement send ready stage
MidhunSureshR Mar 5, 2023
b3cc07c
Accept verification from device message
MidhunSureshR Mar 6, 2023
bae18c0
return enum explaining user trust level rather than boolean
bwindels Mar 7, 2023
f1ecad5
adjust UI to more detailed trust level
bwindels Mar 7, 2023
a065189
delay signature validation of cross-signing keys until calculating trust
bwindels Mar 7, 2023
0b51fc0
Throw specific error when cancelled
MidhunSureshR Mar 7, 2023
a69246f
return undefined if we don't have the signing key
bwindels Mar 7, 2023
1f8fb93
Implement timeout and cancel
MidhunSureshR Mar 7, 2023
760da62
remove unused transaction
bwindels Mar 9, 2023
780dfeb
WIP
bwindels Mar 13, 2023
2e653d5
Write a class that generates fixtures for test
MidhunSureshR Mar 13, 2023
720585b
Write unit tests
MidhunSureshR Mar 13, 2023
9c82dd7
Refactor code
MidhunSureshR Mar 13, 2023
fd96d58
Throw error if verification was cancelled
MidhunSureshR Mar 14, 2023
806e672
Convert console.log to logger calls
MidhunSureshR Mar 14, 2023
dedf64d
Base stage class does not need disposable
MidhunSureshR Mar 14, 2023
d70dd66
Refactor code
MidhunSureshR Mar 14, 2023
65c0afb
Rename class
MidhunSureshR Mar 14, 2023
8e08916
Remove magic string
MidhunSureshR Mar 14, 2023
c08e136
Add more logging
MidhunSureshR Mar 14, 2023
fc86789
Fix formatting
MidhunSureshR Mar 14, 2023
ec66e88
Fix comment
MidhunSureshR Mar 14, 2023
2cde9b2
Refactor SendMacStage
MidhunSureshR Mar 14, 2023
f54a4d1
Refactor SendReadyStage
MidhunSureshR Mar 14, 2023
d60214d
Fix string in logger
MidhunSureshR Mar 14, 2023
d41746e
Refactor SendAcceptVerificationStage
MidhunSureshR Mar 14, 2023
ed70feb
Refactor CalculateSASStage
MidhunSureshR Mar 14, 2023
a5743e8
Refactor VerifyMacStage
MidhunSureshR Mar 14, 2023
672b0ac
Refactor SASVerification class
MidhunSureshR Mar 14, 2023
1904659
Remove comment
MidhunSureshR Mar 15, 2023
fc6e56b
Pass log last
MidhunSureshR Mar 15, 2023
cd9b340
Refactor Channel
MidhunSureshR Mar 15, 2023
610bbcc
Remove code from room vm
MidhunSureshR Mar 15, 2023
ed9fc14
Fix import
MidhunSureshR Mar 21, 2023
9d8c045
Move import up
MidhunSureshR Mar 21, 2023
dd59f37
WIP2
bwindels Mar 21, 2023
a1086a7
Add support for arbitrary notifications
MidhunSureshR Mar 22, 2023
93d37ae
Create views based on viewmodel
MidhunSureshR Mar 22, 2023
120c93d
Merge branch 'support-arbitrary-toast-notifications' into sas-verific…
MidhunSureshR Mar 23, 2023
762a91b
don't reuse existing transaction to read from 4S, as webcrypto termin…
bwindels Mar 24, 2023
e2ae5e7
Do not emit for now
MidhunSureshR Mar 24, 2023
321775b
Rename CancelTypes -> CancelReason
MidhunSureshR Mar 24, 2023
1c09f20
Pass device-id through options
MidhunSureshR Mar 24, 2023
589bc16
Inherit from EventEmitter
MidhunSureshR Mar 24, 2023
7c6bcbc
Add explaining comment
MidhunSureshR Mar 24, 2023
225a778
Use deferred
MidhunSureshR Mar 24, 2023
ae60c30
VerificationEventTypes -> VerificationEventType
MidhunSureshR Mar 24, 2023
8ea484e
Inline code
MidhunSureshR Mar 24, 2023
2f7e67d
Change type
MidhunSureshR Mar 24, 2023
90faad5
remove txn argument that was removed in previous commit
bwindels Mar 24, 2023
d170c6f
crossSigning is an observable value now
bwindels Mar 24, 2023
9383246
remove obsolete parameter here as well
bwindels Mar 24, 2023
eaa7de8
fix import
bwindels Mar 24, 2023
6abc918
show shield as icon
bwindels Mar 27, 2023
21729a6
add newlines between getters
bwindels Mar 27, 2023
2214061
clear cross-signing object when disabling 4s
bwindels Mar 27, 2023
117ee3b
Merge pull request #1042 from vector-im/cross-signing/self-sign-other…
bwindels Mar 27, 2023
07df6a8
Merge pull request #1062 from vector-im/cross-signing/user-shield2
bwindels Mar 27, 2023
371916e
Merge branch 'master' into madlittlemods/copy-permalink
MadLittleMods Mar 27, 2023
acba597
Label magic number
MadLittleMods Mar 27, 2023
98d4dfd
Move copy function to platform
MadLittleMods Mar 27, 2023
aeb5e9d
Merge pull request #1058 from vector-im/support-arbitrary-toast-notif…
MidhunSureshR Mar 28, 2023
3e7a4d9
Merge branch 'master' into sas-verification
MidhunSureshR Mar 28, 2023
10c92c5
Fix tests and code to use new data structure
MidhunSureshR Mar 28, 2023
1c923a7
fix login not working
bwindels Mar 28, 2023
36fe043
Merge branch 'master' into sas-verification
MidhunSureshR Mar 28, 2023
3b17dc6
fix not being able to switch to passphrase mode anymore for key backup
bwindels Mar 28, 2023
18d735b
Merge branch 'master' into sas-verification
MidhunSureshR Mar 28, 2023
58f7363
fix crossSigning never getting enabled if you haven't fetched your ow…
bwindels Mar 28, 2023
8c1878c
Merge branch 'master' into sas-verification
MidhunSureshR Mar 28, 2023
ac9c244
fix logging after return
bwindels Mar 28, 2023
30c0da3
expand all parents of item that has an error
bwindels Mar 28, 2023
cc4da5c
fix ts errors with latest tsc 4.x version (as used on CI)
bwindels Mar 28, 2023
f0e945b
Merge pull request #1065 from vector-im/bwindels/fix-ts-errors-with-4.9
bwindels Mar 28, 2023
e71ecdd
Merge branch 'master' into sas-verification
bwindels Mar 28, 2023
6c294b1
fix wrong import path that crept in merge again
bwindels Mar 28, 2023
c92fd60
group imports and import types
bwindels Mar 28, 2023
8c6c957
Merge pull request #1064 from vector-im/bwindels/console-logging-expa…
bwindels Mar 28, 2023
0f7ef69
WIP: Add views/view-models
MidhunSureshR Mar 21, 2023
4c6a240
WIP: Toast notification
MidhunSureshR Mar 24, 2023
90ce3f5
Remove toast when receiving cancel
MidhunSureshR Mar 24, 2023
4aa86c6
Support multiple requests
MidhunSureshR Mar 24, 2023
16c1448
Refactor code
MidhunSureshR Mar 24, 2023
15ab7e7
Create viewmodel inside start method
MidhunSureshR Mar 24, 2023
8c06582
Fix rebase
MidhunSureshR Mar 24, 2023
cd3e32d
Track view-model instance
MidhunSureshR Mar 27, 2023
e380406
Remove "any" type
MidhunSureshR Mar 27, 2023
918ee6b
Change log string
MidhunSureshR Mar 27, 2023
d32d0de
Fix emit
MidhunSureshR Mar 27, 2023
0588d04
Pass in cancellation object
MidhunSureshR Mar 27, 2023
ac1a16d
Remove unused code
MidhunSureshR Mar 27, 2023
7e2823b
Import as types
MidhunSureshR Mar 27, 2023
8becb2b
Import as type
MidhunSureshR Mar 27, 2023
5fa4afa
Combine css styles
MidhunSureshR Mar 27, 2023
41ebf13
Some more changes
MidhunSureshR Mar 27, 2023
e0b3e9f
Use optional chaining
MidhunSureshR Mar 27, 2023
f822a7a
Wrap in feature flag
MidhunSureshR Mar 28, 2023
53c0fc2
Fix rebase
MidhunSureshR Mar 28, 2023
6e2cd35
Fix rebase again
MidhunSureshR Mar 28, 2023
9080263
Fix SAS failing
MidhunSureshR Mar 28, 2023
6e054fc
Update src/platform/web/ui/css/themes/element/theme.css
MidhunSureshR Mar 28, 2023
6fefc15
Change method name
MidhunSureshR Mar 28, 2023
b2d6a78
Remove property
MidhunSureshR Mar 28, 2023
38a82b2
Use getter
MidhunSureshR Mar 28, 2023
82692ed
cancellation can be undefined
MidhunSureshR Mar 28, 2023
6a8007f
Use switch case
MidhunSureshR Mar 28, 2023
9884ee2
Fix render error
MidhunSureshR Mar 28, 2023
7eb1c09
Use e2ee account
MidhunSureshR Mar 28, 2023
ce01878
Make code more clear
MidhunSureshR Mar 29, 2023
d8d4f2b
Merge pull request #1040 from vector-im/sas-verification
bwindels Mar 30, 2023
67cc426
Update src/matrix/verification/CrossSigning.ts
bwindels Mar 30, 2023
f158197
Update src/matrix/verification/CrossSigning.ts
bwindels Mar 30, 2023
e78580c
Merge remote-tracking branch 'origin/device-verification-ui'
bwindels Mar 30, 2023
3f5e2af
Abort SAS when disposing vm
MidhunSureshR Mar 30, 2023
244d56b
Fix broken tests
MidhunSureshR Mar 30, 2023
b8e2823
Log mac method
MidhunSureshR Mar 30, 2023
51c3e31
Merge pull request #1066 from vector-im/fix-sas-issues
bwindels Mar 30, 2023
74fe742
sign device or user when mac check out during sas
bwindels Mar 30, 2023
c2b6c44
actually, don't need to pass this, it's already in options
bwindels Mar 30, 2023
ab65745
fix tests
bwindels Mar 30, 2023
915ab9c
Merge pull request #1067 from vector-im/cross-signing/sign-device-aft…
bwindels Mar 30, 2023
f659970
implementing observing user trust so UI can update when signing
bwindels Mar 30, 2023
a1b7696
fix lint
bwindels Mar 30, 2023
c876951
adjust comment to reflect which keys we're talking about
bwindels Mar 31, 2023
515bd24
Merge pull request #1068 from vector-im/cross-signing/user-trust-obse…
bwindels Mar 31, 2023
016f9ff
Send done before waiting for message
MidhunSureshR Mar 31, 2023
4a0e2c7
Merge pull request #1070 from vector-im/fix-more-sas-issues
bwindels Mar 31, 2023
7e20440
Dispose cross-signing
MidhunSureshR Mar 31, 2023
a925ec6
Merge pull request #1071 from vector-im/dispose-handler
bwindels Mar 31, 2023
457f1e5
export BlobHandle and add method to create handle from buffer with un…
bwindels Apr 6, 2023
c37e861
Merge pull request #1073 from vector-im/bwindels/export-blobhandle-sdk
bwindels Apr 6, 2023
3019710
expose method on BlobHandle to create a handle without mimetype filte…
bwindels Apr 7, 2023
a87edcf
Merge pull request #1074 from vector-im/bwindels/expose-create-blob-m…
bwindels Apr 7, 2023
ee5105c
sdk version 0.1.2
bwindels Apr 7, 2023
82a7c9d
Use new prop names
MidhunSureshR Apr 11, 2023
a8d4928
Merge pull request #921 from vector-im/madlittlemods/copy-permalink
bwindels Apr 11, 2023
b52489c
we pass Member as a DeviceKey here, so also create the right getters
bwindels Apr 11, 2023
7a726ff
Merge pull request #1075 from vector-im/fix-broken-key-share
bwindels Apr 14, 2023
2ae2c21
Export contents from ./feature
MidhunSureshR Apr 17, 2023
13d198d
Update docs
MidhunSureshR Apr 17, 2023
a35f6af
Add command to install olm as well
MidhunSureshR Apr 17, 2023
e77727e
Merge pull request #1077 from vector-im/update-sdk-1
MidhunSureshR Apr 17, 2023
1686b3d
Accommodate long dates in sticky date headers
MadLittleMods Apr 26, 2023
99e67fe
Load call handler before using it
MidhunSureshR May 1, 2023
72c6172
Implement a method to discard logs
MidhunSureshR May 2, 2023
d9bdf11
Add discard method to NullLogItem
MidhunSureshR May 3, 2023
e5d5f46
Merge pull request #1080 from vector-im/fix-call-issues
MidhunSureshR May 3, 2023
f28b23b
Add workflow file
MidhunSureshR May 4, 2023
d47fcc6
Merge pull request #1084 from vector-im/sdk-release-action
MidhunSureshR May 4, 2023
d31ba7c
Remove comment
MidhunSureshR May 4, 2023
fcd7f91
Lock node version
MidhunSureshR May 4, 2023
c6fa81b
Use setup node
MidhunSureshR May 4, 2023
c45a84e
Check if e2eeAccount is available first
MidhunSureshR May 5, 2023
4cb11a1
Merge pull request #1085 from vector-im/fix-1081
MidhunSureshR May 5, 2023
eb697ba
Merge branch 'thirdroom/dev' into tr-master
ajbura May 8, 2023
afc5b68
export submitLogsToRageshakeServer
ajbura May 8, 2023
e42b767
Merge pull request #1078 from vector-im/madlittlemods/accommodate-lon…
MidhunSureshR May 10, 2023
c20e291
fix member dispose mutating global member options
ajbura May 11, 2023
701a6fa
Merge branch 'fix-unreliable-call' into tr-master
ajbura May 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/sdk-release.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Publish to npm
on:
push:
tags:
- "sdk-v**"
jobs:
npm:
name: Publish to npm
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.1.0]

steps:
- name: 🧮 Checkout code
uses: actions/checkout@v3

- name: Install tools
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: 🔧 Yarn cache
uses: actions/setup-node@v3
with:
cache: "yarn"
registry-url: "https://registry.npmjs.org"

- name: 🔨 Install dependencies
run: "yarn install --prefer-offline --frozen-lockfile"

- name: Run Unit tests
run: "yarn test"

- name: Run Lint Checks
run: "yarn run lint-ci"

- name: Run Typescript Checks
run: "yarn run tsc"

- name: Run SDK tests
run: "yarn test:sdk"

- name: Build SDK
run: "yarn build:sdk"

- name: 🚀 Publish to npm
id: npm-publish
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
package: ./target
dry-run: true
6 changes: 5 additions & 1 deletion doc/SDK.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ yarn create vite
cd <your-project-name>
yarn
yarn add hydrogen-view-sdk
yarn add https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz
```

You should see a `index.html` in the project root directory, containing an element with `id="app"`. Add the attribute `class="hydrogen"` to this element, as the CSS we'll include from the SDK assumes for now that the app is rendered in an element with this classname.
Expand All @@ -32,7 +33,8 @@ import {
createRouter,
RoomViewModel,
TimelineView,
viewClassForTile
viewClassForTile,
FeatureSet
} from "hydrogen-view-sdk";
import downloadSandboxPath from 'hydrogen-view-sdk/download-sandbox.html?url';
import workerPath from 'hydrogen-view-sdk/main.js?url';
Expand Down Expand Up @@ -81,12 +83,14 @@ async function main() {
const {session} = client;
// looks for room corresponding to #element-dev:matrix.org, assuming it is already joined
const room = session.rooms.get("!bEWtlqtDwCLFIAKAcv:matrix.org");
const features = await FeatureSet.load(platform.settingsStorage);
const vm = new RoomViewModel({
room,
ownUserId: session.userId,
platform,
urlRouter: urlRouter,
navigation,
features,
});
await vm.load();
const view = new TimelineView(vm.timelineViewModel, viewClassForTile);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"xxhashjs": "^0.2.2"
},
"dependencies": {
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz",
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz",
"another-json": "^0.2.0",
"base64-arraybuffer": "^0.2.0",
"dompurify": "^2.3.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/sdk/base-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thirdroom/hydrogen-view-sdk",
"description": "Embeddable matrix client library, including view components",
"version": "0.1.1",
"version": "0.1.2",
"main": "./lib-build/hydrogen.cjs.js",
"exports": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/AccountSetupViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

import {ViewModel} from "./ViewModel";
import {KeyType} from "../matrix/ssss/index";
import {Status} from "./session/settings/KeyBackupViewModel.js";
import {Status} from "./session/settings/KeyBackupViewModel";

export class AccountSetupViewModel extends ViewModel {
constructor(options) {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/SessionLoadViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class SessionLoadViewModel extends ViewModel {
this._ready(client);
}
if (loadError) {
console.error("session load error", loadError);
console.error("session load error", loadError.stack);
}
} catch (err) {
this._error = err;
Expand Down
4 changes: 3 additions & 1 deletion src/domain/navigation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export type SegmentType = {
"details": true;
"members": true;
"member": string;
"device-verification": string | boolean;
"join-room": true;
"oidc": {
state: string,
} &
Expand Down Expand Up @@ -63,7 +65,7 @@ function allowsChild(parent: Segment<SegmentType> | undefined, child: Segment<Se
// allowed root segments
return type === "login" || type === "session" || type === "sso" || type === "logout" || type === "oidc";
case "session":
return type === "room" || type === "rooms" || type === "settings" || type === "create-room" || type === "join-room";
return type === "room" || type === "rooms" || type === "settings" || type === "create-room" || type === "join-room" || type === "device-verification";
case "rooms":
// downside of the approach: both of these will control which tile is selected
return type === "room" || type === "empty-grid-tile";
Expand Down
28 changes: 27 additions & 1 deletion src/domain/session/SessionViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {RoomGridViewModel} from "./RoomGridViewModel.js";
import {SettingsViewModel} from "./settings/SettingsViewModel.js";
import {CreateRoomViewModel} from "./CreateRoomViewModel.js";
import {JoinRoomViewModel} from "./JoinRoomViewModel";
import {DeviceVerificationViewModel} from "./verification/DeviceVerificationViewModel";
import {ViewModel} from "../ViewModel";
import {RoomViewModelObservable} from "./RoomViewModelObservable.js";
import {RightPanelViewModel} from "./rightpanel/RightPanelViewModel.js";
Expand All @@ -48,6 +49,7 @@ export class SessionViewModel extends ViewModel {
this._gridViewModel = null;
this._createRoomViewModel = null;
this._joinRoomViewModel = null;
this._verificationViewModel = null;
this._toastCollectionViewModel = this.track(new ToastCollectionViewModel(this.childOptions({
session: this._client.session,
})));
Expand Down Expand Up @@ -95,6 +97,14 @@ export class SessionViewModel extends ViewModel {
}));
this._updateJoinRoom(joinRoom.get());

if (this.features.crossSigning) {
const verification = this.navigation.observe("device-verification");
this.track(verification.subscribe((txnId) => {
this._updateVerification(txnId);
}));
this._updateVerification(verification.get());
}

const lightbox = this.navigation.observe("lightbox");
this.track(lightbox.subscribe(eventId => {
this._updateLightbox(eventId);
Expand Down Expand Up @@ -143,7 +153,8 @@ export class SessionViewModel extends ViewModel {
this._gridViewModel ||
this._settingsViewModel ||
this._createRoomViewModel ||
this._joinRoomViewModel
this._joinRoomViewModel ||
this._verificationViewModel
);
}

Expand Down Expand Up @@ -179,6 +190,10 @@ export class SessionViewModel extends ViewModel {
return this._joinRoomViewModel;
}

get verificationViewModel() {
return this._verificationViewModel;
}

get toastCollectionViewModel() {
return this._toastCollectionViewModel;
}
Expand Down Expand Up @@ -327,6 +342,17 @@ export class SessionViewModel extends ViewModel {
this.emitChange("activeMiddleViewModel");
}

_updateVerification(txnId) {
if (this._verificationViewModel) {
this._verificationViewModel = this.disposeTracked(this._verificationViewModel);
}
if (txnId) {
const request = this._client.session.crossSigning.get()?.receivedSASVerifications.get(txnId);
this._verificationViewModel = this.track(new DeviceVerificationViewModel(this.childOptions({ session: this._client.session, request })));
}
this.emitChange("activeMiddleViewModel");
}

_updateLightbox(eventId) {
if (this._lightboxViewModel) {
this._lightboxViewModel = this.disposeTracked(this._lightboxViewModel);
Expand Down
68 changes: 68 additions & 0 deletions src/domain/session/rightpanel/MemberDetailsViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
import {ViewModel} from "../../ViewModel";
import {RoomVisibility} from "../../../matrix/room/common";
import {avatarInitials, getIdentifierColorNumber, getAvatarHttpUrl} from "../../avatar";
import {UserTrust} from "../../../matrix/verification/CrossSigning";

export class MemberDetailsViewModel extends ViewModel {
constructor(options) {
Expand All @@ -29,13 +30,56 @@ export class MemberDetailsViewModel extends ViewModel {
this._session = options.session;
this.track(this._powerLevelsObservable.subscribe(() => this._onPowerLevelsChange()));
this.track(this._observableMember.subscribe( () => this._onMemberChange()));
this._userTrust = undefined;
this._userTrustSubscription = undefined;
if (this.features.crossSigning) {
this.track(this._session.crossSigning.subscribe(() => {
this._onCrossSigningChange();
}));
}
this._onCrossSigningChange();
}

get name() { return this._member.name; }

get userId() { return this._member.userId; }

get trustDescription() {
switch (this._userTrust?.get()) {
case UserTrust.Trusted: return this.i18n`You have verified this user. This user has verified all of their sessions.`;
case UserTrust.UserNotSigned: return this.i18n`You have not verified this user.`;
case UserTrust.UserSignatureMismatch: return this.i18n`You appear to have signed this user, but the signature is invalid.`;
case UserTrust.UserDeviceNotSigned: return this.i18n`You have verified this user, but they have one or more unverified sessions.`;
case UserTrust.UserDeviceSignatureMismatch: return this.i18n`This user has a session signature that is invalid.`;
case UserTrust.UserSetupError: return this.i18n`This user hasn't set up cross-signing correctly`;
case UserTrust.OwnSetupError: return this.i18n`Cross-signing wasn't set up correctly on your side.`;
case undefined:
default: // adding default as well because jslint can't check for switch exhaustiveness
return this.i18n`Please wait…`;
}
}

get trustShieldColor() {
if (!this._isEncrypted) {
return "";
}
switch (this._userTrust?.get()) {
case undefined:
case UserTrust.OwnSetupError:
return "";
case UserTrust.Trusted:
return "green";
case UserTrust.UserNotSigned:
return "black";
default:
return "red";
}
}

get type() { return "member-details"; }

get shouldShowBackButton() { return true; }

get previousSegmentName() { return "members"; }

get role() {
Expand All @@ -54,6 +98,15 @@ export class MemberDetailsViewModel extends ViewModel {
this.emitChange("role");
}

async signUser() {
const crossSigning = this._session.crossSigning.get();
if (crossSigning) {
await this.logger.run("MemberDetailsViewModel.signUser", async log => {
await crossSigning.signUser(this.userId, log);
});
}
}

get avatarLetter() {
return avatarInitials(this.name);
}
Expand Down Expand Up @@ -94,4 +147,19 @@ export class MemberDetailsViewModel extends ViewModel {
}
this.navigation.push("room", roomId);
}

_onCrossSigningChange() {
const crossSigning = this._session.crossSigning.get();
this._userTrustSubscription = this.disposeTracked(this._userTrustSubscription);
this._userTrust = undefined;
if (crossSigning) {
this.logger.run("MemberDetailsViewModel.observeUserTrust", log => {
this._userTrust = crossSigning.observeUserTrust(this.userId, log);
this._userTrustSubscription = this.track(this._userTrust.subscribe(() => {
this.emitChange("trustShieldColor");
}));
});
}
this.emitChange("trustShieldColor");
}
}
5 changes: 5 additions & 0 deletions src/domain/session/room/timeline/tiles/BaseMessageTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {SimpleTile} from "./SimpleTile.js";
import {ReactionsViewModel} from "../ReactionsViewModel.js";
import {getIdentifierColorNumber, avatarInitials, getAvatarHttpUrl} from "../../../../avatar";


export class BaseMessageTile extends SimpleTile {
constructor(entry, options) {
super(entry, options);
Expand All @@ -44,6 +45,10 @@ export class BaseMessageTile extends SimpleTile {
return `https://matrix.to/#/${encodeURIComponent(this._room.id)}/${encodeURIComponent(this._entry.id)}`;
}

copyPermalink() {
this.platform.copyPlaintext(this.permaLink);
}

get senderProfileLink() {
return `https://matrix.to/#/${encodeURIComponent(this.sender)}`;
}
Expand Down
Loading