-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
548 additions
and
296 deletions.
There are no files selected for viewing
19 changes: 0 additions & 19 deletions
19
holo-key-manager-extension/build-scripts/removeExportFromScript.cjs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
import type { Message } from '@sharedTypes'; | ||
import { responseToMessage, sendMessage } from '@sharedServices'; | ||
import { MessageSchema, MessageWithIdSchema } from '@sharedTypes'; | ||
|
||
console.log('Content script loaded'); | ||
const isMessageFromSelf = (event: MessageEvent) => event.source === window; | ||
const isSignInAction = (data: Message) => data.action === 'SignIn'; | ||
|
||
window.addEventListener('message', async (event: MessageEvent) => { | ||
const parseAndHandleMessage = async (event: MessageEvent) => { | ||
if (!isMessageFromSelf(event)) return; | ||
if (isSignInAction(event.data)) { | ||
const response = await chrome.runtime.sendMessage(event.data); | ||
window.postMessage({ ...response, id: event.data.id }, '*'); | ||
const parsedResult = MessageWithIdSchema.safeParse(event.data); | ||
if (!parsedResult.success || parsedResult.data.action !== 'SignIn') return; | ||
|
||
try { | ||
const response = await sendMessage(parsedResult.data); | ||
const parsedMessageSchema = MessageSchema.safeParse(response); | ||
if (!parsedMessageSchema.success) throw new Error('Invalid response format'); | ||
window.postMessage(responseToMessage(parsedMessageSchema.data, parsedResult.data.id), '*'); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}); | ||
}; | ||
|
||
window.addEventListener('message', parseAndHandleMessage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "holo-key-manager-extension-scripts", | ||
"version": "1.0.0", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"build": "rollup -c" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import tscAlias from 'rollup-plugin-tsc-alias'; | ||
import typescript from 'rollup-plugin-typescript2'; | ||
|
||
const createConfig = (input, file) => ({ | ||
input, | ||
output: { | ||
file, | ||
format: 'esm' | ||
}, | ||
plugins: [tscAlias(), typescript(), resolve()] | ||
}); | ||
|
||
export default [ | ||
createConfig('background.ts', '../build/scripts/background.js'), | ||
createConfig('content.ts', '../build/scripts/content.js') | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "../build", | ||
"paths": { | ||
"@sharedTypes": ["../../shared/types"], | ||
"@sharedTypes/*": ["../../shared/types/*"] | ||
} | ||
"outDir": "../build" | ||
}, | ||
"include": ["background.ts", "content.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,26 @@ | ||
{ | ||
"name": "Holo key manager", | ||
"description": "A browser extension to manage holo keys", | ||
"version": "0.0.35", | ||
"version": "0.0.36", | ||
"manifest_version": 3, | ||
"action": { | ||
"default_title": "Holo key manager", | ||
"default_icon": "favicon.png", | ||
"default_popup": "index.html" | ||
}, | ||
"content_security_policy": { | ||
"extension_pages": "default-src 'self' 'wasm-unsafe-eval'" | ||
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'" | ||
}, | ||
"background": { | ||
"service_worker": "holo-key-manager-extension/scripts/background.js", | ||
"service_worker": "scripts/background.js", | ||
"type": "module" | ||
}, | ||
"permissions": ["activeTab", "storage", "tabs", "nativeMessaging"], | ||
"externally_connectable": { | ||
"matches": ["*://localhost/*"] | ||
}, | ||
"host_permissions": ["<all_urls>"], | ||
"content_scripts": [ | ||
{ | ||
"matches": ["*://localhost/*"], | ||
"js": ["holo-key-manager-extension/scripts/content.js"] | ||
"js": ["scripts/content.js"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import tscAlias from 'rollup-plugin-tsc-alias'; | ||
import typescript from 'rollup-plugin-typescript2'; | ||
|
||
export default [ | ||
{ | ||
input: 'src/index.ts', | ||
output: { | ||
file: 'lib/index.js', | ||
format: 'esm' | ||
}, | ||
plugins: [typescript(), resolve(), tscAlias()] | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.