Skip to content

Commit

Permalink
dont hash websites in private comment
Browse files Browse the repository at this point in the history
  • Loading branch information
jonerrr committed Jan 24, 2024
1 parent 4945386 commit 7858ee3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ThemeProvider } from "~theme"
import { type Alias, type Settings, fetchAliases, generateHash } from "~utils"

export default function IndexPopup() {
//TODO: rename because its no longer a hash
const [siteHash, setSiteHash] = useState<string>()
const [aliases, setAliases] = useState<Alias[]>([])
const [loading, setLoading] = useState(true)
Expand All @@ -18,8 +19,8 @@ export default function IndexPopup() {
chrome.tabs.query(
{ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT },
async (t) =>
// create a sha-256 hash with the URL hostname
setSiteHash(await generateHash(new URL(t[0].url!).hostname))

setSiteHash(new URL(t[0].url!).hostname)
)

const configured =
Expand All @@ -35,7 +36,7 @@ export default function IndexPopup() {
return
}

;(async () => {
; (async () => {
await new Promise((r) => setTimeout(r, 1000))
setAliases(await fetchAliases(settings as Required<Settings>))
setLoading(false)
Expand Down
8 changes: 4 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ export async function generateAlias(
hostname?: string
): Promise<Alias> {
const address = generateEmail(settings, hostname)
const hash = await generateHash(hostname ?? "no")
// const hash = await generateHash(hostname ?? "no")
const hash = hostname ?? 'nohostname'
// although mailcow has its own date, the format they use sucks
const createdAt = Date.now()

Expand Down Expand Up @@ -227,9 +228,8 @@ export function generateEmail(
): string {
switch (settings.generationMethod) {
case GenerationMethod.RandomCharacters:
return `${randAlphaNumeric({ length: 16 }).join("")}@${
settings.aliasDomain
}`
return `${randAlphaNumeric({ length: 16 }).join("")}@${settings.aliasDomain
}`

case GenerationMethod.RandomName:
const domain = settings.aliasDomain.split(".") ?? "example.com"
Expand Down

0 comments on commit 7858ee3

Please sign in to comment.