diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 121c127..21acceb 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -78,7 +78,7 @@ jobs: strategy: max-parallel: 4 matrix: - variant: ['full', 'lite'] + variant: ['full', 'lite', 'mac'] steps: - name: Build info @@ -136,6 +136,14 @@ jobs: npm run build npm run build-zip + - name: Build Mac version + if: matrix.variant == 'mac' + shell: bash + run: | + npm install + npm run build:mac + npm run build-zip + - name: Package extension run: | ZIP_NAME=$(find dist-zip -type f -name '*.zip' | head -n 1) diff --git a/README.md b/README.md index 33fe78f..4e25b00 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,12 @@ In order to build the extension yourself, please follow these steps: - (Optional, only useful for beta build) Build beta version: change `betaRev` in `package.json`, then generate zip file using +## How to build a version for Mac + +For the development, you can run `npm run start:mac` for the Mac app. + +For the production release, `npm run build:mac` + ```bash npm run build:beta && npm run build-zip ``` \ No newline at end of file diff --git a/package.json b/package.json index ef03020..eb37417 100644 --- a/package.json +++ b/package.json @@ -13,11 +13,13 @@ "build:lite": "cross-env NODE_ENV=production LITE=1 webpack", "build:beta": "cross-env NODE_ENV=production BETA=1 webpack", "build:dev": "cross-env NODE_ENV=development BETA=1 webpack", + "build:mac": "cross-env NODE_ENV=production MAC=1 webpack", "build-zip": "node scripts/build-zip.js", "generate:buildconfig": "node scripts/generateBuildConfig.js", "watch": "npm run build -- --watch", "watch:dev": "cross-env HMR=true npm run build:dev -- --watch", - "start": "cross-env HMR=true npm run build:dev -- --watch" + "start": "cross-env HMR=true npm run build:dev -- --watch", + "start:mac": "cross-env HMR=true MAC=1 npm run build:dev -- --watch" }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^1.2.36", diff --git a/src/popup/components/AppSettings.vue b/src/popup/components/AppSettings.vue index 38ea19e..a12c006 100644 --- a/src/popup/components/AppSettings.vue +++ b/src/popup/components/AppSettings.vue @@ -5,6 +5,18 @@ App Settings ({{ userEmail }})

+
+ + Currently you have a free SimpleLogin account. Upgrade your account to + create unlimited aliases, add more mailboxes, create aliases + on-the-fly with your domain or SimpleLogin subdomain and more. + + +
+
+ @@ -114,6 +128,7 @@ export default { extension_version: "development", userEmail: "", theme: "", + freeAccount: false, THEMES, THEME_LABELS, }; @@ -136,6 +151,11 @@ export default { API_ON_ERR.TOAST ); this.userEmail = userInfo.data.email; + if (userInfo.data.in_trial) { + this.freeAccount = true; + } else { + this.freeAccount = !userInfo.data.is_premium; + } }, methods: { async handleToggleSLButton() { @@ -165,6 +185,16 @@ export default { await SLStorage.remove(SLStorage.SETTINGS.API_KEY); EventManager.broadcast(EventManager.EVENT.SETTINGS_CHANGED); Navigation.clearHistoryAndNavigateTo(Navigation.PATH.LOGIN); + + if (process.env.MAC) { + console.log("send log out event to host app"); + await browser.runtime.sendNativeMessage( + "application.id", + JSON.stringify({ + logged_out: {}, + }) + ); + } }, async setMailToUri() { @@ -175,6 +205,22 @@ export default { ); this.reportURISLButton = `mailto:extension@simplelogin.io?subject=${subject}&body=${body}`; }, + async upgrade() { + if (process.env.MAC) { + console.log("send upgrade event to host app"); + await browser.runtime.sendNativeMessage( + "application.id", + JSON.stringify({ + upgrade: {}, + }) + ); + } else { + console.info("can't send data to native app", error); + let apiUrl = await SLStorage.get(SLStorage.SETTINGS.API_URL); + let upgradeURL = apiUrl + "/dashboard/pricing"; + browser.tabs.create({ url: upgradeURL }); + } + }, }, computed: {}, watch: { diff --git a/src/popup/components/Main.vue b/src/popup/components/Main.vue index afdc2e7..3757036 100644 --- a/src/popup/components/Main.vue +++ b/src/popup/components/Main.vue @@ -93,14 +93,19 @@ class="btn btn-outline-primary btn-sm" @click="createRandomAlias" > - OR create a totally random alias + + OR create a totally random alias

You have reached limit number of email aliases in free plan, please - upgrade + upgrade or reuse one of the existing aliases.

@@ -257,6 +262,21 @@ export default { this.apiUrl = await SLStorage.get(SLStorage.SETTINGS.API_URL); this.apiKey = await SLStorage.get(SLStorage.SETTINGS.API_KEY); + if (this.apiKey && process.env.MAC) { + console.log("send api key to host app"); + await browser.runtime.sendNativeMessage( + "application.id", + JSON.stringify({ + logged_in: { + data: { + api_key: this.apiKey, + api_url: this.apiUrl, + }, + }, + }) + ); + } + this.contentElem = document.querySelector(".app > .content"); await this.getUserOptions(); @@ -503,6 +523,22 @@ export default { Navigation.navigateTo(Navigation.PATH.REVERSE_ALIAS, true); }, + async upgrade() { + if (process.env.MAC) { + console.log("send upgrade event to host app"); + await browser.runtime.sendNativeMessage( + "application.id", + JSON.stringify({ + upgrade: {}, + }) + ); + } else { + console.info("can't send data to native app", error); + let upgradeURL = this.apiUrl + "/dashboard/pricing"; + browser.tabs.create({ url: upgradeURL }); + } + }, + // Clipboard clipboardSuccessHandler({ value, event }) { Utils.showSuccess(value + " copied to clipboard"); diff --git a/webpack.config.js b/webpack.config.js index d3d1249..031eec4 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -138,6 +138,10 @@ const config = { jsonContent.short_name = "SimpleLogin Without SL icon"; } + if (process.env.MAC) { + jsonContent.permissions.push("nativeMessaging"); + } + return JSON.stringify(jsonContent, null, 2); }, }, @@ -155,6 +159,14 @@ if (config.mode === 'development') { ]); } +if (process.env.MAC){ + config.plugins = (config.plugins || []).concat([ + new webpack.DefinePlugin({ + 'process.env.MAC': JSON.stringify(!!process.env.MAC), + }), + ]); +} + if (config.mode === 'production') { config.plugins = (config.plugins || []).concat([ new webpack.DefinePlugin({
@@ -27,7 +39,9 @@ v-show="showSLButton" target="_blank" > -
Report an issue +
+ + Report an issue