Skip to content

Commit

Permalink
v0.0.12
Browse files Browse the repository at this point in the history
*v0.0.12
  • Loading branch information
albertocubeddu authored Aug 13, 2024
1 parent c429792 commit 84edbcd
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 12 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ Move it somewhere else ASAP:

# Changelog

### 0.0.12 (Not release to the public)
- General: Free tier exhaustion. We haven't got a sponsor (yet) to support our community users.
- Google: Added identity, identity.email to enable automatic log-in using your google credentials.

### 0.0.11 (Not released to the public)
- General: Introduced a FREE Tier for users to explore the Extension | OS without needing to understand API Keys.
- Development: Implemented the CRX Public Key to maintain a consistent extension ID across re-installations during development.
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions background/messages/identity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { PlasmoMessaging } from "@plasmohq/messaging";

const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
const data = await chrome.identity.getProfileUserInfo({});
res.send({
data,
});
};

export default handler;
25 changes: 21 additions & 4 deletions content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import loadingImage from "data-base64:~assets/AppIcons/loading.png"
import cssText from "data-text:~/plasmo-overlay.css"
import type { PlasmoCSConfig } from "plasmo"
import { useEffect, useState } from "react"

import { useStorage } from "@plasmohq/storage/hook"
import { sendToBackground } from "@plasmohq/messaging"

// We enable the extension to be used in anywebsite with an http/https protocol.
export const config: PlasmoCSConfig = {
Expand All @@ -25,7 +25,18 @@ const PlasmoOverlay = () => {
const [llmModel] = useStorage("llmModel")
const [debugInfo] = useStorage("debugInfo")


useEffect(() => {

//Trick to fetch the chrome.profile from the background;
const fetchData = async () => {
const resp = await sendToBackground({
name: "identity",
})
return resp;
}

//Function to copy text to the clipboard;
const handleClipboardCopy = async (text) => {
try {
await navigator.clipboard.writeText(text)
Expand All @@ -37,7 +48,7 @@ const PlasmoOverlay = () => {
}
}

const messageListener = (request) => {
const messageListener = async (request) => {
switch (request.action) {
case "copyToClipboard":
setResponseText(request.text)
Expand All @@ -56,8 +67,10 @@ const PlasmoOverlay = () => {
setErrorDivVisibe(false)
}, 15000)
break
default:
console.warn("Unknown action:", request.action)
case "subscriptionLimitReached":
const data = await fetchData()
setIsLoading(false)
window.open(`${process.env.PLASMO_PUBLIC_WEBSITE_EXTENSION_OS}/pricing?email=${data?.data.email}&profile_id=${data?.data.id}`, "_blank")
}
}

Expand All @@ -67,10 +80,14 @@ const PlasmoOverlay = () => {
return () => chrome.runtime.onMessage.removeListener(messageListener)
}, [])



return (
<>

{/* DEBUG BOX */}
<div

style={{
padding: "12px",
backgroundColor: "white",
Expand Down
24 changes: 19 additions & 5 deletions lib/openAITypeCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,27 @@ export async function callOpenAIReturn(
}, 2000);
}

//Extension-os.com || Free Tier Exhausted
if (response.status === 403 && vendor === "extension | OS") {
chrome.tabs.query(
{ active: true, currentWindow: true },
function (tabs) {
if (tabs[0]?.id) {
chrome.tabs.sendMessage(tabs[0].id, {
action: "subscriptionLimitReached",
text: "3000",
});
} else {
throw new Error("No active tab found.");
}
}
);
}

if (!response.ok) {
if (response.status === 401) {
setTimeout(() => chrome.runtime.openOptionsPage(), 2000);
}
throw new Error(
data.error?.message || `HTTP error! status: ${response.status}`
data.error?.message ||
`3rd party API repsponded with HTTP error status: ${response.status}`
);
}

Expand All @@ -101,7 +116,6 @@ export async function callOpenAIReturn(

return { data: data.choices[0].message.content };
} catch (error) {
console.error("Failed to fetch from OpenAI API:", error);
return {
errorMessage: error instanceof Error ? error.message : String(error),
};
Expand Down
7 changes: 7 additions & 0 deletions lib/providers/EmailShowcase.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useUserInfo } from "./UserInfoContext"

export default function EmailShowCase() {
const userInfo = useUserInfo()

return (<div>{userInfo?.email}</div>)
}
1 change: 0 additions & 1 deletion lib/providers/UserInfoContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const UserInfoProvider = ({ children }: { children: ReactNode }) => {
let isMounted = true; // Track if the component is mounted
chrome.identity.getProfileUserInfo((data) => {
if (isMounted && data.email && data.id) {
console.log(data)
setUserInfo(data)
}
})
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "extension-os",
"displayName": "Extension-OS: Your AI Partner",
"version": "0.0.11",
"version": "0.0.12",
"description": "AI at Your Fingertips, Anytime, Anywhere.",
"author": "[email protected]",
"scripts": {
Expand Down Expand Up @@ -58,7 +58,8 @@
"clipboard",
"sidePanel",
"declarativeNetRequest",
"identity"
"identity",
"identity.email"
],
"declarative_net_request": {
"rule_resources": [
Expand Down
2 changes: 2 additions & 0 deletions popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "./globals.css"
import { Button } from "~components/ui/button"

function IndexPopup() {

return (
<div style={{ backgroundImage: `url(${backgroundExt})` }} className="bg-cover bg-center w-[300px] h-[300px] flex flex-col items-center justify-end gap-2">

Expand All @@ -14,6 +15,7 @@ function IndexPopup() {
Configuration
</Button>


<span className="flex pt-5 basis-1/12">
</span>

Expand Down

0 comments on commit 84edbcd

Please sign in to comment.