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

Suggestions for Browser Extension Manifest V3 #287

Open
alaadaff opened this issue Nov 2, 2023 · 3 comments
Open

Suggestions for Browser Extension Manifest V3 #287

alaadaff opened this issue Nov 2, 2023 · 3 comments

Comments

@alaadaff
Copy link

alaadaff commented Nov 2, 2023

Anyone has used browserify with this hpke-js library for loading into a Chrome browser extension V3? @dajiaji
I'm running into a problem where I can't import {CipherSuite, KemId, KdfId, etc.} into a browser extension's background.js getting an error that the module does not provide an export named "CipherSuite, ..etc"

@dajiaji
Copy link
Owner

dajiaji commented Nov 20, 2023

@alaadaff Sorry for the late reply.

How can I reproduce the problem you are facing?
Please let me know how to do that and I will try to solve the problem.

@alaadaff
Copy link
Author

I'm using the following instructions to browserify the library: https://www.mobilefish.com/developer/nodejs/nodejs_quickguide_browserify_bip32_utils.html
And then once this is completed I'm trying to instantiate a new CipherSuite object in the form:
const suite = new HpkeJS.hpke.CipherSuite{//params}, where "HpkeJS" is the global variable name to the module and "hpke" is an arbitrary name chosen in module.exports in main.js file.

Below is a screenshot of the manifest.json. I'm calling the new CipherSuite object in my extension's background.js.

Also, when I try instead to not use the global module name above and instead import { CipherSuite } from the bundled hpke_browser.js I'm receiving an error that the bundled file does not provide an export named "CipherSuite".

image image

On the other hand the browserified hpke_browser.js works perfectly when loaded into a single html file as shown below. But unfortunately with browser extensions we cant load scripts directly in an html page.

image

@dajiaji
Copy link
Owner

dajiaji commented Nov 21, 2023

The hpke_browser.js can also be generated by using ebuild.
Have you ever tried the following?

$ git clone [email protected]:dajiaji/hpke-js.git
$ cd hpke-js
$ npm install -g esbuild
$ deno task dnt
$ deno task minify > hpke_browser.js

It can be used as follows:

import { Kem, Kdf, Aead, CipherSuite } from './hpke_browser.js';

// ...

See https://github.com/dajiaji/hpke-js/blob/main/test/runtimes/browsers/pages/index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants