From 42c0a1411d017476ad592b02f8444b3a93d82e0e Mon Sep 17 00:00:00 2001 From: Paul Ccari <46382556+paulclindo@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:03:45 -0500 Subject: [PATCH] fix: credentials on multiple requests (#91) --- shinkai-mini-apps/shinkai-tray/package-lock.json | 8 ++++---- shinkai-mini-apps/shinkai-tray/package.json | 2 +- .../shinkai-tray/src/api/mutations/createChat/types.ts | 5 ++++- .../src/api/mutations/sendTextMessage/index.ts | 4 ++++ .../shinkai-tray/src/api/queries/getAgents/index.ts | 4 ++++ .../shinkai-tray/src/api/queries/getInboxes/index.ts | 4 ++++ .../shinkai-tray/src/pages/chat/chat-conversation.tsx | 2 ++ .../shinkai-tray/src/pages/chat/empty-message.tsx | 2 ++ shinkai-mini-apps/shinkai-tray/src/pages/chat/layout.tsx | 2 ++ shinkai-mini-apps/shinkai-tray/src/pages/create-job.tsx | 2 ++ 10 files changed, 29 insertions(+), 6 deletions(-) diff --git a/shinkai-mini-apps/shinkai-tray/package-lock.json b/shinkai-mini-apps/shinkai-tray/package-lock.json index c92beb353..3057be7fe 100644 --- a/shinkai-mini-apps/shinkai-tray/package-lock.json +++ b/shinkai-mini-apps/shinkai-tray/package-lock.json @@ -24,7 +24,7 @@ "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-switch": "^1.0.3", "@radix-ui/react-tooltip": "^1.0.6", - "@shinkai_network/shinkai-message-ts": "^0.0.5", + "@shinkai_network/shinkai-message-ts": "^0.0.6", "@tanstack/react-query": "^4.35.3", "@tauri-apps/api": "^1.4.0", "@tiptap/extension-placeholder": "^2.1.11", @@ -1613,9 +1613,9 @@ } }, "node_modules/@shinkai_network/shinkai-message-ts": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/@shinkai_network/shinkai-message-ts/-/shinkai-message-ts-0.0.5.tgz", - "integrity": "sha512-bgBWE3b/Xi4CwsN3kEKdTwuNM2xZh1UWj73iANzNwZ9OJ8kdKnkul4KOinLkyzr/Yhvlf+akzxX9orTIdE1zvA==", + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/@shinkai_network/shinkai-message-ts/-/shinkai-message-ts-0.0.6.tgz", + "integrity": "sha512-wHtr9h7YlBWx4O3gKc6dMqQtGXBMK9gR2Cd+T9ZDDYUKO8aVdm5NsjKFFd/Rt8w5v5YpOSIeEIMHjLgLmN/jJA==", "dependencies": { "@noble/ed25519": "^2.0.0", "curve25519-js": "^0.0.4" diff --git a/shinkai-mini-apps/shinkai-tray/package.json b/shinkai-mini-apps/shinkai-tray/package.json index f3a3de8b9..40efbb7ba 100644 --- a/shinkai-mini-apps/shinkai-tray/package.json +++ b/shinkai-mini-apps/shinkai-tray/package.json @@ -27,7 +27,7 @@ "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-switch": "^1.0.3", "@radix-ui/react-tooltip": "^1.0.6", - "@shinkai_network/shinkai-message-ts": "^0.0.5", + "@shinkai_network/shinkai-message-ts": "^0.0.6", "@tanstack/react-query": "^4.35.3", "@tauri-apps/api": "^1.4.0", "@tiptap/extension-placeholder": "^2.1.11", diff --git a/shinkai-mini-apps/shinkai-tray/src/api/mutations/createChat/types.ts b/shinkai-mini-apps/shinkai-tray/src/api/mutations/createChat/types.ts index bb296adb9..7fe20278e 100644 --- a/shinkai-mini-apps/shinkai-tray/src/api/mutations/createChat/types.ts +++ b/shinkai-mini-apps/shinkai-tray/src/api/mutations/createChat/types.ts @@ -3,7 +3,10 @@ import type { ShinkaiMessage, } from "@shinkai_network/shinkai-message-ts/models"; -export type CreateChatInput = CredentialsPayload & { +export type CreateChatInput = Pick< + CredentialsPayload, + "my_device_encryption_sk" | "my_device_identity_sk" | "node_encryption_pk" +> & { sender: string; senderSubidentity: string; receiver: string; diff --git a/shinkai-mini-apps/shinkai-tray/src/api/mutations/sendTextMessage/index.ts b/shinkai-mini-apps/shinkai-tray/src/api/mutations/sendTextMessage/index.ts index 95fbcddc2..cae15d134 100644 --- a/shinkai-mini-apps/shinkai-tray/src/api/mutations/sendTextMessage/index.ts +++ b/shinkai-mini-apps/shinkai-tray/src/api/mutations/sendTextMessage/index.ts @@ -10,10 +10,14 @@ export const sendMessageToInbox = async ({ my_device_encryption_sk, my_device_identity_sk, node_encryption_pk, + profile_encryption_sk, + profile_identity_sk, }: SendMessageToInboxInput) => { return await sendTextMessageWithInbox(sender, "", receiver, message, inboxId, { my_device_encryption_sk, my_device_identity_sk, node_encryption_pk, + profile_encryption_sk, + profile_identity_sk, }); }; diff --git a/shinkai-mini-apps/shinkai-tray/src/api/queries/getAgents/index.ts b/shinkai-mini-apps/shinkai-tray/src/api/queries/getAgents/index.ts index bf555d855..958fef3bd 100644 --- a/shinkai-mini-apps/shinkai-tray/src/api/queries/getAgents/index.ts +++ b/shinkai-mini-apps/shinkai-tray/src/api/queries/getAgents/index.ts @@ -9,12 +9,16 @@ export const getAgents = async ({ my_device_encryption_sk, my_device_identity_sk, node_encryption_pk, + profile_encryption_sk, + profile_identity_sk, }: GetAgentsInput) => { const profile_sender = sender + "/" + senderSubidentity; const result = await getProfileAgents(profile_sender, "", shinkaiIdentity, { my_device_encryption_sk, my_device_identity_sk, node_encryption_pk, + profile_encryption_sk, + profile_identity_sk, }); return result; }; diff --git a/shinkai-mini-apps/shinkai-tray/src/api/queries/getInboxes/index.ts b/shinkai-mini-apps/shinkai-tray/src/api/queries/getInboxes/index.ts index 4b8fb1504..03945b17a 100644 --- a/shinkai-mini-apps/shinkai-tray/src/api/queries/getInboxes/index.ts +++ b/shinkai-mini-apps/shinkai-tray/src/api/queries/getInboxes/index.ts @@ -10,6 +10,8 @@ export const getInboxes = async ({ my_device_encryption_sk, my_device_identity_sk, node_encryption_pk, + profile_encryption_sk, + profile_identity_sk, }: GetInboxesInput) => { const inboxes = await getAllInboxesForProfile( shinkaiIdentity, @@ -20,6 +22,8 @@ export const getInboxes = async ({ my_device_encryption_sk, my_device_identity_sk, node_encryption_pk, + profile_encryption_sk, + profile_identity_sk, } ); return inboxes.map((inbox) => encodeURIComponent(inbox)); diff --git a/shinkai-mini-apps/shinkai-tray/src/pages/chat/chat-conversation.tsx b/shinkai-mini-apps/shinkai-tray/src/pages/chat/chat-conversation.tsx index 1bdf0ef88..57c29de5c 100644 --- a/shinkai-mini-apps/shinkai-tray/src/pages/chat/chat-conversation.tsx +++ b/shinkai-mini-apps/shinkai-tray/src/pages/chat/chat-conversation.tsx @@ -121,6 +121,8 @@ const ChatConversation = () => { my_device_encryption_sk: setupData.profile_encryption_sk, my_device_identity_sk: setupData.profile_identity_sk, node_encryption_pk: setupData.node_encryption_pk, + profile_encryption_sk: setupData.profile_encryption_sk, + profile_identity_sk: setupData.profile_identity_sk, }); } chatForm.reset(); diff --git a/shinkai-mini-apps/shinkai-tray/src/pages/chat/empty-message.tsx b/shinkai-mini-apps/shinkai-tray/src/pages/chat/empty-message.tsx index 7afd4db00..feb9ed57f 100644 --- a/shinkai-mini-apps/shinkai-tray/src/pages/chat/empty-message.tsx +++ b/shinkai-mini-apps/shinkai-tray/src/pages/chat/empty-message.tsx @@ -16,6 +16,8 @@ const EmptyMessage = () => { my_device_encryption_sk: setupData?.my_device_encryption_sk ?? "", my_device_identity_sk: setupData?.my_device_identity_sk ?? "", node_encryption_pk: setupData?.node_encryption_pk ?? "", + profile_encryption_sk: setupData?.profile_encryption_sk ?? "", + profile_identity_sk: setupData?.profile_identity_sk ?? "", }); return (
diff --git a/shinkai-mini-apps/shinkai-tray/src/pages/chat/layout.tsx b/shinkai-mini-apps/shinkai-tray/src/pages/chat/layout.tsx index 837d41beb..d1ec4a591 100644 --- a/shinkai-mini-apps/shinkai-tray/src/pages/chat/layout.tsx +++ b/shinkai-mini-apps/shinkai-tray/src/pages/chat/layout.tsx @@ -42,6 +42,8 @@ const ChatLayout = () => { // Assuming receiver and target_shinkai_name_profile are the same as sender receiver: setupData?.shinkai_identity ?? "", targetShinkaiNameProfile: `${setupData?.shinkai_identity}/${setupData?.profile}`, + profile_encryption_sk: setupData?.profile_encryption_sk ?? "", + profile_identity_sk: setupData?.profile_identity_sk ?? "", }); return ( diff --git a/shinkai-mini-apps/shinkai-tray/src/pages/create-job.tsx b/shinkai-mini-apps/shinkai-tray/src/pages/create-job.tsx index 86f699cbe..31ea2abb2 100644 --- a/shinkai-mini-apps/shinkai-tray/src/pages/create-job.tsx +++ b/shinkai-mini-apps/shinkai-tray/src/pages/create-job.tsx @@ -42,6 +42,8 @@ const CreateJobPage = () => { my_device_encryption_sk: setupData?.profile_encryption_sk ?? "", my_device_identity_sk: setupData?.profile_identity_sk ?? "", node_encryption_pk: setupData?.node_encryption_pk ?? "", + profile_encryption_sk: setupData?.profile_encryption_sk ?? "", + profile_identity_sk: setupData?.profile_identity_sk ?? "", }); const { isLoading, mutateAsync: createJob } = useCreateJob({