This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add device verification popup, no longer accept all
- Loading branch information
1 parent
73fe4c9
commit f4b0ceb
Showing
8 changed files
with
77 additions
and
85 deletions.
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,12 +1,12 @@ | ||
<script lang="ts"> | ||
<script lang='ts'> | ||
import DeviceVerificationPopup from './popups/DeviceVerificationPopup.svelte' | ||
import { currentPopup } from './index' | ||
import DeviceVerificationPopup from './popups/DeviceVerificationPopup.svelte'; | ||
</script> | ||
|
||
{#if $currentPopup} | ||
<div class="fixed left-[50%] top-[50%] -translate-[50%] bg-surface0 px-8 py-4 rounded flex flex-col items-center"> | ||
<div class='fixed left-[50%] top-[50%] -translate-[50%] bg-surface0 px-8 py-4 rounded-lg flex flex-col items-center'> | ||
{#if $currentPopup.type === 'device-verification'} | ||
<DeviceVerificationPopup {...$currentPopup} /> | ||
{/if} | ||
</div> | ||
{/if} | ||
{/if} |
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
21 changes: 19 additions & 2 deletions
21
services/frontend/src/lib/popup/popups/DeviceVerificationPopup.svelte
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,7 +1,24 @@ | ||
<script lang="ts"> | ||
<script lang='ts'> | ||
import type { ShowSasCallbacks } from 'matrix-js-sdk/lib/crypto-api' | ||
import { clearPopup } from '..' | ||
export const type = 'device-verification' | ||
export let sas: ShowSasCallbacks | ||
</script> | ||
|
||
<h4>Device verification</h4> | ||
<h4>Device verification</h4> | ||
|
||
<div class='flex flex-row gap-2 items-center justify-center flex-wrap'> | ||
{#each sas.sas.emoji ?? [] as emoji} | ||
<div class='flex flex-col gap-1'> | ||
<p>{emoji[0]}</p> | ||
<p>{emoji[1]}</p> | ||
</div> | ||
{/each} | ||
<div class='flex flex-row justify-between w-[90%]'> | ||
<button on:click={() => { sas.mismatch(); clearPopup() }}>They don't match</button> | ||
<button type='button' on:click={() => { sas.confirm(); clearPopup() }}>They match</button> | ||
</div> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { MatrixClient } from 'matrix-js-sdk' | ||
import { type VerificationRequest, VerifierEvent } from 'matrix-js-sdk/lib/crypto-api' | ||
import { createPopup } from '$lib/popup' | ||
|
||
export async function startVerification(_client: MatrixClient, req: VerificationRequest) { | ||
const verifier = await req.startVerification('m.sas.v1') | ||
verifier.on(VerifierEvent.ShowSas, async (sas) => { | ||
createPopup({ | ||
type: 'device-verification', | ||
sas, | ||
}) | ||
}) | ||
|
||
await verifier.verify() | ||
} |
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