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

E2ee #168

Merged
merged 8 commits into from
Dec 28, 2024
Merged

E2ee #168

Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

A set of tools for AI developers to build on top of [XMTP](https://xmtp.org)

## What's inside?

### MessageKit

- [`message-kit`](/packages/message-kit): A kit for quickly building messaging apps
Expand Down
7 changes: 0 additions & 7 deletions community/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@
"icon": "📒",
"author": "humanagent"
},
{
"href": "/plugins/xmtp",
"title": "xmtp",
"description": "Use Xmtp to send E2EE messages.",
"icon": "💬",
"author": "ephemeraHQ"
},
{
"href": "/plugins/xmtp-groups",
"title": "Xmtp Groups",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"templates": "node scripts/devTemplates.js",
"test": "FORCE_COLOR=1 turbo run test --force --concurrency=1",
"test:client": "cd packages/xmtp/tests && yarn test:client",
"test:e2e": "cd packages/xmtp/tests && yarn test:e2e",
"test:flow": "cd packages/message-kit/tests && yarn test:flow",
"test:intent": "cd packages/message-kit/tests && yarn test:intent",
"test:links": "cd packages/message-kit/tests && yarn test:links",
Expand Down
13 changes: 9 additions & 4 deletions packages/client/src/components/Chat.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,13 @@
}

.urlContainer {
margin: 8px 0;
display: flex;
flex-direction: column;
gap: 8px;
border-radius: 8px 8px 0 0;
max-width: 300px;
background: #e0e0e0;
}

.urlPreview {
border-radius: 8px 8px 0 0;
overflow: hidden;
background: #ffffff;
border: 1px solid #b0b0b0;
Expand Down Expand Up @@ -231,3 +228,11 @@
color: var(--accent);
font-size: 0.9rem;
}
.encryptionInfo {
text-align: center !important;
width: 100%;
font-size: 0.7rem;
padding: 0rem;
padding-top: 0.4rem;
display: block !important;
}
17 changes: 9 additions & 8 deletions packages/client/src/components/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ function Chat({ user }: { user: UserInfo }) {
const [processedMessageIds] = useState(new Set<string>());

useEffect(() => {
console.log("useEffect triggered with user:", user);

const init = async () => {
try {
setRecipientInfo(user);
Expand All @@ -64,7 +62,6 @@ function Chat({ user }: { user: UserInfo }) {

const onMessage = async (message: Message | undefined) => {
if (message) {
console.log("onMessage", message);
setMessages((prevMessages) => [...prevMessages, message]);
}
};
Expand All @@ -88,7 +85,6 @@ function Chat({ user }: { user: UserInfo }) {
receivers: [recipientInfo.address],
originalMessage: undefined,
})) as Message;
console.log("message", message);

setMessages((prevMessages) => [...prevMessages, message]);
setNewMessage("");
Expand Down Expand Up @@ -144,17 +140,19 @@ function Chat({ user }: { user: UserInfo }) {
if (urlRegex.test(part)) {
try {
const urlType = getUrlType(part);
const isMessageKitUrl = part.includes("message-kit.org");

const isMessageKitUrl =
part.includes("message-kit.org") ||
part.includes("baselinks.vercel.app");
const isMobile = window.innerWidth < 768;
return (
<div key={index} className={styles.urlContainer}>
{isMessageKitUrl && <UrlPreview url={part} urlType={urlType} />}
{isMessageKitUrl && <UrlPreview url={part} />}
<div className={styles.buttonContainer}>
{urlType === "payment" && (
<button
onClick={() => {
const ethUrl = ethereumURL(part);
openUrl(ethUrl);
isMobile ? openUrl(ethUrl) : alert("Not on mobile");
}}
className={styles.urlButton}>
Pay in USDC
Expand Down Expand Up @@ -248,6 +246,9 @@ function Chat({ user }: { user: UserInfo }) {
Send
</button>
</div>
<div className={styles.encryptionInfo}>
End-to-end encrypted powered by XMTP
</div>
</form>
</div>
);
Expand Down
8 changes: 1 addition & 7 deletions packages/client/src/components/UrlPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ interface OgData {
url?: string;
}

export const UrlPreview = ({
url,
urlType,
}: {
url: string;
urlType?: string;
}) => {
export const UrlPreview = ({ url }: { url: string; urlType?: string }) => {
const [ogData, setOgData] = useState<OgData | null>(null);
const [loading, setLoading] = useState(true);

Expand Down
2 changes: 1 addition & 1 deletion packages/create-message-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
}
2 changes: 1 addition & 1 deletion packages/docs/pages/concepts/xmtp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[XMTP](https://xmtp.org/) is the protocol that MessageKit uses to send and receive messages.

> Check out the [XMTP AI](/plugins/xmtp) plugins for more information.
> Check out the [xmtp e2ee](https://docs-xmtp-org-git-agents-ephemerahq.vercel.app/agents/pluginxmtp) plugins for more information.

## Context

Expand Down
177 changes: 0 additions & 177 deletions packages/docs/pages/plugins/xmtp.mdx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/xmtp-e2ee/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# XMTP

> See [XMTP AI](https://message-kit.org/plugins/xmtp) plugin
> See [xmtp e2ee](https://docs-xmtp-org-git-agents-ephemerahq.vercel.app/agents/plugins) plugins

### Installation

Expand Down
4 changes: 2 additions & 2 deletions packages/xmtp-e2ee/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xmtp-e2ee",
"version": "0.0.8",
"version": "0.0.9",
"license": "MIT",
"type": "module",
"exports": {
Expand Down Expand Up @@ -61,4 +61,4 @@
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
}
3 changes: 2 additions & 1 deletion packages/xmtp-e2ee/src/lib/xmtp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ async function streamMessages(
while (true) {
try {
const stream = await client.conversations.streamAllMessages();
console.log(`Stream started`);
console.log(`XMTP: [v2] Stream started`);

for await (const message of stream) {
if (message) {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/xmtp/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# XMTP

> See [XMTP AI](https://message-kit.org/plugins/xmtp) plugin
> See [xmtp e2ee](https://docs-xmtp-org-git-agents-ephemerahq.vercel.app/agents/plugins) plugin

### Installation

Expand Down
7 changes: 4 additions & 3 deletions packages/xmtp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xmtp",
"version": "0.0.8",
"version": "0.0.9",
"license": "MIT",
"type": "module",
"exports": {
Expand All @@ -22,7 +22,8 @@
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"publish": "npm publish",
"test": "yarn build && vitest",
"test:client": "vitest run tests/client"
"test:client": "vitest run tests/client",
"test:e2e": "vitest run tests/encryption"
},
"dependencies": {
"@changesets/changelog-git": "^0.2.0",
Expand Down Expand Up @@ -59,4 +60,4 @@
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
}
Loading
Loading