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

feat: Safari support #125

Open
wants to merge 139 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 135 commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
9141351
devop: setup macos build and fastlane
Aug 17, 2022
ac9dac0
devop: setup workflow
Aug 17, 2022
feb531d
devop: setup workflow
Aug 17, 2022
64f5b77
devop: fix fastlane
Aug 17, 2022
36af976
devop: fix fastlane
Aug 17, 2022
ee4c32a
fix: fastlane
Aug 18, 2022
65e5326
fix: fastlane
Aug 18, 2022
92f85d2
devop: fix fastlane
Aug 18, 2022
ac123c1
fix: fastlane
Aug 18, 2022
bfce9c6
fix: fastlane
Aug 18, 2022
1f62d71
devop: fix fastlane
Aug 18, 2022
3a86dd6
fix: fastlane
Aug 18, 2022
93806c9
fix: fastlane
Aug 18, 2022
10f6316
fix: macos build
Aug 18, 2022
f7d1056
fix: macos build
Aug 18, 2022
e6c814d
fix: macos build
Aug 18, 2022
d5b5580
fix: macos build
Aug 18, 2022
d5425a3
fix: macos build
Aug 18, 2022
9f73e86
fix: build run id
kvhnuke Aug 18, 2022
00c3e5d
fix: build run id
kvhnuke Aug 18, 2022
08779be
fix: build run id
kvhnuke Aug 18, 2022
c28db05
devop: fix Encryption Excempt
Foboz Aug 18, 2022
6a6953a
Merge pull request #127 from enkryptcom/fix/safari-export-compliance
kvhnuke Aug 18, 2022
5a05aa9
fix: Removed unnecessary link to `.entitlemens` (duplicate)
Foboz Aug 18, 2022
8e08fb6
devop: get proper version
Aug 18, 2022
e4a69d0
Merge branch 'feat/safari-support' of github.com:enkryptcom/enKrypt i…
Aug 18, 2022
108f509
Merge pull request #128 from enkryptcom/fix/xcode-clean
kvhnuke Aug 18, 2022
064c49b
fix: macos versioning
Aug 18, 2022
60e03e6
fix: macos versioning
Aug 18, 2022
d6f9265
fix: safari wasm error
Aug 19, 2022
17b1de5
Merge branch 'develop' into feat/safari-support
Aug 19, 2022
3fb1ff2
Merge branch 'main' into feat/safari-support
kvhnuke Sep 9, 2022
f5f3175
develop: fix Safari extension screen
mihailpolev Sep 15, 2022
e25a53f
fix: build
kvhnuke Sep 15, 2022
2a5de5a
fix: build
Sep 15, 2022
b6129e4
devop: update appstore icons
Sep 15, 2022
266ff38
devop: change safari icons
kvhnuke Sep 16, 2022
e1dd474
merge v1.0.5
kvhnuke Sep 16, 2022
b04d996
fix: build
kvhnuke Sep 16, 2022
af074f1
fix: ui issues
Sep 17, 2022
39f3e48
devop: rebuild
kvhnuke Sep 17, 2022
647b64c
devop: add names to workflow jobs
kvhnuke Sep 17, 2022
190a742
devop: rebuild
kvhnuke Sep 18, 2022
4d8bf3e
devop: rebuild
kvhnuke Sep 19, 2022
3ae790d
devop: rebuild
kvhnuke Sep 22, 2022
82115be
devop: rebuild
kvhnuke Sep 22, 2022
44249fe
fix: safari 16
Sep 27, 2022
d3de924
devop: bump package version
Sep 27, 2022
df6e41f
fix: 🐛 opening onboard on update
kvhnuke Sep 28, 2022
bf3d72c
devop: 🔧 merge v1.6.0
kvhnuke Oct 19, 2022
7e58477
devop: 🔧 update fastlane
kvhnuke Oct 19, 2022
e5a8d8e
Merge branch 'develop' into feat/safari-support
kvhnuke Oct 19, 2022
0b0e44e
devop: 🔧 update fastlane
kvhnuke Oct 19, 2022
cbce89c
devop: update fastlane
Oct 20, 2022
7c35165
Merge branch 'develop' into feat/safari-support
kvhnuke Nov 1, 2022
470931e
Merge branch 'main' into feat/safari-support
kvhnuke Nov 22, 2022
ec14d93
Merge branch 'main' into feat/safari-support
kvhnuke Dec 14, 2022
df492dd
fix: name too long
kvhnuke Dec 14, 2022
dff4aa5
Merge branch 'main' into feat/safari-support
kvhnuke Jan 14, 2023
f91c4ae
Merge branch 'main' into feat/safari-support
kvhnuke Jan 17, 2023
7ea0ad3
Merge branch 'main' into feat/safari-support
kvhnuke Jan 19, 2023
929cf08
Merge branch 'main' into feat/safari-support
kvhnuke Feb 10, 2023
c318ec5
Merge branch 'main' into feat/safari-support
kvhnuke Feb 23, 2023
dce77fe
devop: bump safari version
kvhnuke Feb 23, 2023
4471a33
release v1.13.0
kvhnuke Mar 7, 2023
e2c7089
devop: merge
kvhnuke Mar 17, 2023
30378ff
fix: build
kvhnuke Mar 17, 2023
cc05788
devop: merge
kvhnuke Mar 21, 2023
db9dba3
Merge branch 'main' into feat/safari-support
kvhnuke Mar 29, 2023
52699d7
Merge branch 'main' into feat/safari-support
kvhnuke Apr 4, 2023
1a1fb18
Merge branch 'main' into feat/safari-support
kvhnuke Apr 26, 2023
2589de7
devop: update certs
Apr 27, 2023
baa4d4f
Merge branch 'main' into feat/safari-support
kvhnuke May 5, 2023
7e828b1
oMerge branch 'main' into feat/safari-support
kvhnuke May 15, 2023
6217a45
Merge branch 'main' into feat/safari-support
kvhnuke May 24, 2023
941974d
Merge branch 'main' into feat/safari-support
kvhnuke Jun 2, 2023
09a806d
Merge branch 'main' into feat/safari-support
kvhnuke Jun 13, 2023
e3c213b
Merge branch 'main' into feat/safari-support
kvhnuke Jun 26, 2023
21aeee3
Merge branch 'main' into feat/safari-support
kvhnuke Jul 19, 2023
8b84b74
devop: merge main
kvhnuke Aug 2, 2023
45f11b3
feat: inject immediate
kvhnuke Aug 9, 2023
c5bdd2a
devop: set min safari version
kvhnuke Aug 9, 2023
4d15efc
devop: set min safari version
kvhnuke Aug 9, 2023
ee9368b
devop: set min safari version
kvhnuke Aug 9, 2023
0fe7b3b
devop: merge
kvhnuke Aug 15, 2023
a6c9634
devop: remove unnecessary manifest
kvhnuke Aug 15, 2023
59866de
devop: add host permissions
kvhnuke Aug 17, 2023
e916c0e
devop: merge main
kvhnuke Sep 5, 2023
a2df125
Merge branch 'main' into feat/safari-support
kvhnuke Sep 15, 2023
137aeb2
devop: set compatibility with macos 14
kvhnuke Sep 15, 2023
5676d73
Merge branch 'main' into feat/safari-support
kvhnuke Oct 2, 2023
fa07d7a
Merge branch 'main' into feat/safari-support
kvhnuke Oct 24, 2023
1ef62ce
Merge branch 'main' into feat/safari-support
kvhnuke Jan 3, 2024
673046b
devop: rebuild
kvhnuke Jan 3, 2024
538e461
devop: remove exchange functionality
kvhnuke Jan 4, 2024
6f3c791
Merge branch 'devop/update-popup' into feat/safari-support
kvhnuke Jan 4, 2024
13deed1
devop: merge update notification
kvhnuke Jan 4, 2024
5a19af4
fix: workflows
kvhnuke Jan 4, 2024
07b7f0f
devop: hide dapps on safari
kvhnuke Jan 5, 2024
7188794
Merge branch 'main' into feat/safari-support
kvhnuke Jan 11, 2024
1ce568c
devop: rebuild safari
kvhnuke Jan 11, 2024
bd7fc06
devop: merge main
kvhnuke Jan 23, 2024
dbca981
devop: upload to appstore
kvhnuke Jan 23, 2024
0ee90eb
devop: upload to appstore
kvhnuke Jan 23, 2024
dd01c75
devop: upload to appstore
kvhnuke Jan 23, 2024
9f60b6c
devop: upload to appstore
kvhnuke Jan 23, 2024
8b2b540
devop: redo lock file
Jan 23, 2024
5d47410
devop: update fastlane
Jan 24, 2024
3c3310e
Merge branch 'main' into feat/safari-support
kvhnuke Feb 22, 2024
38ad2b3
Merge branch 'main' into feat/safari-support
kvhnuke Feb 28, 2024
5b847ff
Merge branch 'main' into feat/safari-support
kvhnuke Mar 6, 2024
127f32c
Merge branch 'main' into feat/safari-support
kvhnuke Mar 20, 2024
d18970e
devop: merge main
kvhnuke Apr 1, 2024
7570172
Merge branch 'main' into feat/safari-support
kvhnuke Apr 2, 2024
4603ad5
Merge branch 'main' into feat/safari-support
kvhnuke Apr 4, 2024
e479489
devop: merge main
kvhnuke May 6, 2024
bc874a6
Merge branch 'main' into feat/safari-support
kvhnuke May 20, 2024
bf54bdd
Merge branch 'main' into feat/safari-support
kvhnuke Jun 25, 2024
9081e97
Merge branch 'main' into feat/safari-support
kvhnuke Jul 30, 2024
01a0317
Merge branch 'main' into feat/safari-support
kvhnuke Aug 21, 2024
f4e2df4
Merge branch 'main' into feat/safari-support
kvhnuke Oct 7, 2024
23c9f74
devop: change name
kvhnuke Oct 7, 2024
3c55268
fix: macos sequia support
kvhnuke Oct 9, 2024
e8b650c
fix: macos sequia support
kvhnuke Oct 9, 2024
21034fc
Merge branch 'fix/safari-18' into feat/safari-support
Oct 9, 2024
d1bd5a5
Merge branch 'fix/safari-18' into feat/safari-support
kvhnuke Oct 9, 2024
221a3ef
devop: bump version
kvhnuke Oct 9, 2024
c49dc6d
devop: temp disable polkadot wasm
kvhnuke Oct 9, 2024
4a762a1
devop: merge
kvhnuke Oct 23, 2024
6e52981
devop: remove trezor from safari
kvhnuke Oct 23, 2024
f78205f
devop: remove trezor from safari
kvhnuke Oct 23, 2024
7fde905
devop: disable hw support for safari
kvhnuke Oct 24, 2024
1db5c44
devop: lint
kvhnuke Oct 24, 2024
97cae1f
Merge pull request #574 from enkryptcom/develop
kvhnuke Dec 13, 2024
416e344
devop: merge main
kvhnuke Dec 13, 2024
67a01bf
fix: safari build
kvhnuke Dec 13, 2024
bc85ab7
fix: safari build
kvhnuke Dec 13, 2024
3a5e193
Merge branch 'feat/safari-support' of github.com:enkryptcom/enKrypt i…
Dec 13, 2024
7700199
devop: setup files
Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [pull_request]

jobs:
buildAll:
name: build all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/macos-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: MacOS Safari Deploy

on: [push]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Restrict workflow trigger to relevant events

Running the deployment workflow on every push could lead to unnecessary builds and potential App Store submission rate limits.

Consider limiting to specific branches or tags:

-on: [push]
+on:
+  push:
+    branches:
+      - main
+      - release/*
+    tags:
+      - 'v*'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
on: [push]
on:
push:
branches:
- main
- release/*
tags:
- 'v*'


jobs:
buildApp:
name: safari build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: setup env
id: node-version
run: |
docker build -t enkrypt-build-container .
echo "NODE_VERSION=$(docker run --rm -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "node --version")" >> $GITHUB_OUTPUT
Comment on lines +14 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix shell script safety issues

The shell commands have several safety issues that could cause failures in edge cases.

Apply these fixes:

-          docker build -t enkrypt-build-container .
-          echo "NODE_VERSION=$(docker run --rm -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "node --version")" >> $GITHUB_OUTPUT
+          docker build -t enkrypt-build-container .
+          echo "NODE_VERSION=$(docker run --rm -v "$(pwd)":/home:rw enkrypt-build-container /bin/bash -c "node --version")" >> $GITHUB_OUTPUT

-        run: docker run --rm -v `pwd`:/home:rw --user "$(id -u):$(id -g)" enkrypt-build-container /bin/bash -c "yarn install --silent"
+        run: docker run --rm -v "$(pwd)":/home:rw --user "$(id -u):$(id -g)" enkrypt-build-container /bin/bash -c "yarn install --silent"

-          docker run --rm --user "$(id -u):$(id -g)" -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "cd packages/extension && yarn build:all && yarn build:safari"
+          docker run --rm --user "$(id -u):$(id -g)" -v "$(pwd)":/home:rw enkrypt-build-container /bin/bash -c "cd packages/extension && yarn build:all && yarn build:safari"

Also applies to: 30-30, 34-35

🧰 Tools
🪛 actionlint (1.7.4)

14-14: shellcheck reported issue in this script: SC2046:warning:2:41: Quote this to prevent word splitting

(shellcheck)


14-14: shellcheck reported issue in this script: SC2006:style:2:41: Use $(...) notation instead of legacy backticks ...

(shellcheck)


14-14: shellcheck reported issue in this script: SC2086:info:2:115: Double quote to prevent globbing and word splitting

(shellcheck)


- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- name: Cache yarn modules
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: yarn install
run: docker run --rm -v `pwd`:/home:rw --user "$(id -u):$(id -g)" enkrypt-build-container /bin/bash -c "yarn install --silent"

- name: build
run: |
mkdir release
docker run --rm --user "$(id -u):$(id -g)" -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "cd packages/extension && yarn build:all && yarn build:safari"

- uses: actions/upload-artifact@v3
with:
name: safari-build-artifact
path: packages/extension/dist
retention-days: 1

deploy:
name: Deploying to appstore
needs: buildApp
runs-on: macOS-latest

steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "latest-stable"

- name: Checkout repository
uses: actions/checkout@v3

- name: Retrieve saved safari build
uses: actions/download-artifact@v3
with:
name: safari-build-artifact
path: packages/extension/dist
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0"
bundler-cache: true
working-directory: "macos/Enkrypt"
- name: Deploy via Fastlane
uses: maierj/[email protected]
with:
lane: "buildandrelease"
subdirectory: "macos/Enkrypt"
env:
APPLE_ID: "${{ secrets.OSX_APPLE_ID }}"
APP_ID: "${{ secrets.OSX_APP_ID }}"
FASTLANE_ITC_TEAM_ID: "${{ secrets.OSX_FASTLANE_ITC_TEAM_ID }}"
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: "${{ secrets.OSX_FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }}"
ITC_TEAM_ID: "${{ secrets.OSX_FASTLANE_ITC_TEAM_ID }}"
INSTALLER_CERT: "${{ secrets.OSX_INSTALLER_CERT }}"
SAFARI_PROVISION: "${{ secrets.OSX_SAFARI_PROVISION }}"
EXTENSION_PROVISION: "${{ secrets.OSX_EXTENSION_PROVISION }}"
MATCH_GIT_URL: "${{ secrets.OSX_MATCH_GIT_URL }}"
MATCH_PASSWORD: "${{ secrets.OSX_MATCH_PASSWORD }}"
GIT_AUTHORIZATION: "${{ secrets.OSX_GIT_AUTHORIZATION }}"
API_KEY: "${{ secrets.OSX_API_KEY }}"
API_KEY_ID: "${{ secrets.OSX_API_KEY_ID }}"
API_ISSUER_ID: "${{ secrets.OSX_API_ISSUER_ID }}"

Comment on lines +66 to +86
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for deployment steps

The deployment steps lack explicit error handling which could make debugging failures difficult.

Consider adding:

  1. Timeout settings for the deployment step
  2. Retry logic for transient failures
  3. Error output capture

Example:

       - name: Deploy via Fastlane
         uses: maierj/[email protected]
         with:
           lane: "buildandrelease"
           subdirectory: "macos/Enkrypt"
+          timeout-minutes: 30
+        continue-on-error: false
         env:
           APPLE_ID: "${{ secrets.OSX_APPLE_ID }}"
           # ... other secrets ...
+      - name: Upload deployment logs on failure
+        if: failure()
+        uses: actions/upload-artifact@v4
+        with:
+          name: deployment-logs
+          path: macos/Enkrypt/fastlane/logs
+          retention-days: 5

Committable suggestion skipped: line range outside the PR's diff.

- name: Upload Enkrypt pkg
uses: actions/upload-artifact@v3
with:
name: safari-build-pkg
path: macos/Enkrypt/build/Enkrypt.pkg
retention-days: 1
Comment on lines +88 to +92
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Update outdated GitHub Action

The actions/upload-artifact action is using an outdated version.

-        uses: actions/upload-artifact@v3
+        uses: actions/upload-artifact@v4
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
uses: actions/upload-artifact@v3
with:
name: safari-build-pkg
path: macos/Enkrypt/build/Enkrypt.pkg
retention-days: 1
uses: actions/upload-artifact@v4
with:
name: safari-build-pkg
path: macos/Enkrypt/build/Enkrypt.pkg
retention-days: 1
🧰 Tools
🪛 actionlint (1.7.4)

88-88: the runner of "actions/upload-artifact@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- "v*"
jobs:
release:
name: new release
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add Safari build step to release workflow

The workflow is missing steps to build and package the Safari extension. This is necessary for the Safari support feature.

Add Safari build step after the Firefox build:

      - name: build
        env:
          VIRUS_TOTAL_API_KEY: ${{secrets.VIRUS_TOTAL_API_KEY}}
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
        run: |
          mkdir release
          docker run --rm --user "$(id -u):$(id -g)" -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "yarn build:all"
          docker run --rm --user "$(id -u):$(id -g)" -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "cd packages/extension && yarn build:chrome && yarn zip"
          mv packages/extension/dist/release.zip release/enkrypt-chrome-edge-opera-${{ steps.get_release_tag.outputs.VERSION }}.zip
          docker run --rm --user "$(id -u):$(id -g)" -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "cd packages/extension && yarn build:firefox && yarn zip"
          mv packages/extension/dist/release.zip release/enkrypt-firefox-${{ steps.get_release_tag.outputs.VERSION }}.xpi
+         docker run --rm --user "$(id -u):$(id -g)" -v `pwd`:/home:rw enkrypt-build-container /bin/bash -c "cd packages/extension && yarn build:safari && yarn zip"
+         mv packages/extension/dist/release.zip release/enkrypt-safari-${{ steps.get_release_tag.outputs.VERSION }}.zip

Committable suggestion skipped: line range outside the PR's diff.

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push]

jobs:
test:
name: test all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ typings/
# dotenv environment variables file
.env
.env.test
.env.sh

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down
24 changes: 24 additions & 0 deletions macos/Enkrypt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Mac OS X
*.DS_Store

# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
xcuserdata/

# Generated files
*.o
*.pyc


#Python modules
MANIFEST
dist/
build/

# Backup files
*~.nib
10 changes: 10 additions & 0 deletions macos/Enkrypt/Enkrypt Extension/Enkrypt_Extension.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
13 changes: 13 additions & 0 deletions macos/Enkrypt/Enkrypt Extension/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.Safari.web-extension</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).SafariWebExtensionHandler</string>
</dict>
</dict>
Comment on lines +4 to +12
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add recommended Info.plist keys for Safari extension

The current Info.plist is missing several recommended keys for Safari extensions. Consider adding the following:

 <dict>
+    <key>CFBundleIdentifier</key>
+    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+    <key>CFBundleVersion</key>
+    <string>1</string>
+    <key>CFBundleShortVersionString</key>
+    <string>1.0</string>
+    <key>CFBundleDisplayName</key>
+    <string>Enkrypt</string>
+    <key>Description</key>
+    <string>Enkrypt Safari Extension</string>
     <key>NSExtension</key>
     <dict>
         <key>NSExtensionPointIdentifier</key>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.Safari.web-extension</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).SafariWebExtensionHandler</string>
</dict>
</dict>
<dict>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleDisplayName</key>
<string>Enkrypt</string>
<key>Description</key>
<string>Enkrypt Safari Extension</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.Safari.web-extension</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).SafariWebExtensionHandler</string>
</dict>
</dict>

</plist>
26 changes: 26 additions & 0 deletions macos/Enkrypt/Enkrypt Extension/SafariWebExtensionHandler.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// SafariWebExtensionHandler.swift
// Enkrypt Extension
//
// Created by admin on 8/16/22.
//

import SafariServices
import os.log

let SFExtensionMessageKey = "message"

class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling {

func beginRequest(with context: NSExtensionContext) {
let item = context.inputItems[0] as! NSExtensionItem
let message = item.userInfo?[SFExtensionMessageKey]
os_log(.default, "Received message from browser.runtime.sendNativeMessage: %@", message as! CVarArg)
Comment on lines +15 to +18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove force unwrapping to prevent crashes

The current implementation uses force unwrapping (!) which could lead to runtime crashes. Consider using safe unwrapping with proper error handling.

-    func beginRequest(with context: NSExtensionContext) {
-        let item = context.inputItems[0] as! NSExtensionItem
-        let message = item.userInfo?[SFExtensionMessageKey]
-        os_log(.default, "Received message from browser.runtime.sendNativeMessage: %@", message as! CVarArg)
+    func beginRequest(with context: NSExtensionContext) {
+        guard let item = context.inputItems.first as? NSExtensionItem,
+              let message = item.userInfo?[SFExtensionMessageKey] else {
+            os_log(.error, "Failed to process extension request: invalid input")
+            context.completeRequest(returningItems: nil, completionHandler: nil)
+            return
+        }
+        os_log(.default, "Received message from browser.runtime.sendNativeMessage: %{public}@", String(describing: message))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func beginRequest(with context: NSExtensionContext) {
let item = context.inputItems[0] as! NSExtensionItem
let message = item.userInfo?[SFExtensionMessageKey]
os_log(.default, "Received message from browser.runtime.sendNativeMessage: %@", message as! CVarArg)
func beginRequest(with context: NSExtensionContext) {
guard let item = context.inputItems.first as? NSExtensionItem,
let message = item.userInfo?[SFExtensionMessageKey] else {
os_log(.error, "Failed to process extension request: invalid input")
context.completeRequest(returningItems: nil, completionHandler: nil)
return
}
os_log(.default, "Received message from browser.runtime.sendNativeMessage: %{public}@", String(describing: message))


let response = NSExtensionItem()
response.userInfo = [ SFExtensionMessageKey: [ "Response to": message ] ]

context.completeRequest(returningItems: [response], completionHandler: nil)
Comment on lines +20 to +23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add structured error handling and response validation

The response handling could be more robust with proper error handling and response validation.

-        let response = NSExtensionItem()
-        response.userInfo = [ SFExtensionMessageKey: [ "Response to": message ] ]
-
-        context.completeRequest(returningItems: [response], completionHandler: nil)
+        do {
+            let response = NSExtensionItem()
+            let responseMessage = [ "Response to": message ]
+            response.userInfo = [ SFExtensionMessageKey: responseMessage ]
+            
+            context.completeRequest(returningItems: [response]) { error in
+                if let error = error {
+                    os_log(.error, "Failed to complete request: %{public}@", error.localizedDescription)
+                }
+            }
+        } catch {
+            os_log(.error, "Failed to process response: %{public}@", error.localizedDescription)
+            context.completeRequest(returningItems: nil, completionHandler: nil)
+        }

Committable suggestion skipped: line range outside the PR's diff.

}

}
Loading
Loading