Skip to content

Commit 4d4b14a

Browse files
altkdffspreiss
andauthored
feat: CRP-2889 add encrypted chat example (#212)
Co-authored-by: Franz-Stefan Preiss <franzstefan@dfinity.org>
1 parent 8b88c4f commit 4d4b14a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+19878
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: examples-encrypted-chat
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
paths:
8+
- examples/encrypted_chat/**
9+
- .github/workflows/provision-darwin.sh
10+
- .github/workflows/provision-linux.sh
11+
- .github/workflows/examples-encrypted-chat.yml
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
jobs:
16+
examples-encrypted-chat-rust-darwin:
17+
runs-on: macos-15
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Provision Darwin
21+
run: |
22+
bash .github/workflows/provision-darwin.sh
23+
- name: Backend Tests Encrypted Chat Rust Darwin
24+
run: |
25+
set -eExuo pipefail
26+
cd examples/encrypted_chat/rust/backend
27+
cargo build --release --target wasm32-unknown-unknown && cargo test
28+
examples-encrypted-chat-rust-linux:
29+
runs-on: ubuntu-24.04
30+
steps:
31+
- uses: actions/checkout@v4
32+
- name: Provision Linux
33+
run: bash .github/workflows/provision-linux.sh
34+
- name: Backend Tests Encrypted Chat Rust Linux
35+
run: |
36+
set -eExuo pipefail
37+
cd examples/encrypted_chat/rust/backend
38+
cargo build --release --target wasm32-unknown-unknown && cargo test

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ Tools for frontend developers to interact with VetKD enabled canisters.
4949
- **[Password Manager](examples/password_manager)** - A secure, decentralized password manager using Encrypted Maps for vault-based password storage and sharing.
5050
- **[Password Manager with Metadata](examples/password_manager_with_metadata)** - Extends the basic password manager to support unencrypted metadata alongside encrypted passwords.
5151
- **[Encrypted Notes](examples/encrypted_notes_dapp_vetkd)** - A secure note-taking application that uses vetKeys for encryption and enables sharing notes between users without device management.
52+
- **[Encrypted Chat](examples/encrypted_chat)** - An *unfinished prototype* for an end-to-end encrypted messaging application based on vetKeys.

examples/encrypted_chat/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
> **Disclaimer**: This example is an *unfinished* prototype for a vetKeys-based encrypted chat app according to the [SPEC.md](./SPEC.md).
2+
>
3+
> DO NOT USE IN PRODUCTION!!
4+
5+
[![](https://icp.ninja/assets/open.svg)](https://icp.ninja/editor?g=https://github.com/dfinity/vetkeys/tree/alex/encrypted-chat/examples/encrypted_chat/rust)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
test-results
2+
node_modules
3+
4+
# Output
5+
.output
6+
.vercel
7+
.netlify
8+
.wrangler
9+
/.svelte-kit
10+
/build
11+
12+
# OS
13+
.DS_Store
14+
Thumbs.db
15+
16+
# Env
17+
.env
18+
.env.*
19+
!.env.example
20+
!.env.test
21+
22+
# Vite
23+
vite.config.js.timestamp-*
24+
vite.config.ts.timestamp-*
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
engine-strict=true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Package Managers
2+
package-lock.json
3+
pnpm-lock.yaml
4+
yarn.lock
5+
bun.lock
6+
bun.lockb
7+
8+
# Miscellaneous
9+
/static/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"useTabs": true,
3+
"singleQuote": true,
4+
"trailingComma": "none",
5+
"printWidth": 100,
6+
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
7+
"overrides": [
8+
{
9+
"files": "*.svelte",
10+
"options": {
11+
"parser": "svelte"
12+
}
13+
}
14+
],
15+
"tailwindStylesheet": "./src/app.css"
16+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# sv
2+
3+
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
4+
5+
## Creating a project
6+
7+
If you're seeing this, you've probably already done this step. Congrats!
8+
9+
```sh
10+
# create a new project in the current directory
11+
npx sv create
12+
13+
# create a new project in my-app
14+
npx sv create my-app
15+
```
16+
17+
## Developing
18+
19+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
20+
21+
```sh
22+
npm run dev
23+
24+
# or start the server and open the app in a new browser tab
25+
npm run dev -- --open
26+
```
27+
28+
## Building
29+
30+
To create a production version of your app:
31+
32+
```sh
33+
npm run build
34+
```
35+
36+
You can preview the production build with `npm run preview`.
37+
38+
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
test('home page has expected h1', async ({ page }) => {
4+
await page.goto('/');
5+
await expect(page.locator('h1')).toBeVisible();
6+
});
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import prettier from 'eslint-config-prettier';
2+
import { includeIgnoreFile } from '@eslint/compat';
3+
import js from '@eslint/js';
4+
import svelte from 'eslint-plugin-svelte';
5+
import globals from 'globals';
6+
import { fileURLToPath } from 'node:url';
7+
import ts from 'typescript-eslint';
8+
import svelteConfig from './svelte.config.js';
9+
import path from 'node:path';
10+
11+
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
12+
13+
export default ts.config(
14+
includeIgnoreFile(gitignorePath),
15+
js.configs.recommended,
16+
...ts.configs.recommendedTypeChecked,
17+
...svelte.configs.recommended,
18+
prettier,
19+
...svelte.configs.prettier,
20+
{
21+
languageOptions: {
22+
globals: { ...globals.browser, ...globals.node }
23+
},
24+
rules: {
25+
// typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
26+
// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
27+
'no-undef': 'off'
28+
}
29+
},
30+
{
31+
files: ['**/*.ts'],
32+
languageOptions: {
33+
parser: ts.parser,
34+
parserOptions: {
35+
projectService: true,
36+
tsconfigRootDir: import.meta.dirname
37+
}
38+
}
39+
},
40+
{
41+
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
42+
languageOptions: {
43+
parserOptions: {
44+
extraFileExtensions: ['.svelte'],
45+
parser: ts.parser,
46+
svelteConfig,
47+
projectService: true,
48+
tsconfigRootDir: import.meta.dirname
49+
}
50+
}
51+
},
52+
{
53+
ignores: [
54+
'dist/',
55+
'src/declarations',
56+
'*.config.js',
57+
'*.config.ts',
58+
'*.config.cjs',
59+
'*.config.mjs',
60+
'.svelte-kit',
61+
'e2e/'
62+
]
63+
}
64+
);

0 commit comments

Comments
 (0)