Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Added camera access permission to the safe apps iframe #3310

Merged
merged 4 commits into from Jan 17, 2022

Conversation

DaniSomoza
Copy link
Contributor

What it solves

As a part of this ticket to add Camera support on WalletConnect Safe App we need to add special policy to the safe apps iframe.

More info:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attributes
https://developer.mozilla.org/en-US/docs/Web/HTTP/Feature_Policy/Using_Feature_Policy#allowlist
https://blog.addpipe.com/camera-and-microphone-access-in-cross-oirigin-iframes-with-feature-policy/

How this PR fixes it

added allow={'camera'} special policy to the safe apps iframe.

        <StyledIframe
          isLoading={appIsLoading}
          frameBorder="0"
          id={`iframe-${appUrl}`}
          ref={iframeRef}
          src={appUrl}
          title={safeApp.name}
          onLoad={onIframeLoad}
          allow={'camera'}
        />
      </StyledCard>

The allowlist special policy is no needed because Walletconnect Safe App is deployed in the same origin that the Safe. For more details see it in the allowlist docs

Safe origin: https://gnosis-safe.io/app/welcome
WalletConnect Safe App origin: https://apps.gnosis-safe.io/wallet-connect

Screenshots

Captura de pantalla 2022-01-13 a las 17 25 00
Captura de pantalla 2022-01-13 a las 17 44 08

@github-actions
Copy link

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link

github-actions bot commented Jan 17, 2022

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 1 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@coveralls
Copy link

coveralls commented Jan 17, 2022

Pull Request Test Coverage Report for Build 1708658932

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 32.485%

Totals Coverage Status
Change from base Build 1708166281: 0.0%
Covered Lines: 3163
Relevant Lines: 8685

💛 - Coveralls

@github-actions
Copy link

Deployment links

🟠 Safe Rinkeby Safe Mainnet 🟣 Safe Polygon 🟡 Safe BSC Safe Arbitrum 🟢 Safe xDai

@github-actions
Copy link

github-actions bot commented Jan 17, 2022

E2E Tests Failed
Check the results here: https://github.com/gnosis/safe-react-e2e-tests/actions/runs/1708708068

Failed tests:

  • ❌ Add an existing safe Add an existing safe
  • ❌ Safe Apps List Safe Apps List
  • ❌ Read-only transaction creation and review Read-only transaction creation and review
  • ❌ Safe Balances Safe Balances

@@ -165,7 +165,7 @@
]
},
"dependencies": {
"@gnosis.pm/safe-apps-sdk": "6.1.0",
"@gnosis.pm/safe-apps-sdk": "6.2.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is no related with this PR

@@ -320,6 +320,7 @@ const AppFrame = ({ appUrl }: Props): ReactElement => {
src={appUrl}
title={safeApp.name}
onLoad={onIframeLoad}
allow={'camera'}
Copy link
Member

Choose a reason for hiding this comment

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

You need not use braces, e.g. allow='camera'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch! :D

done!

Copy link
Member

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

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

📸

@DaniSomoza
Copy link
Contributor Author

DaniSomoza commented Jan 17, 2022

Hi guys it seems that the AppList.test.tsx was failing. It was an issue in the getSafeApps mock call. A real http request was being performed during tests running.

And also I found a minor bug in the @gnosis.pm/safe-react-gateway-sdk types:

export type SafeAppsResponse = [SafeAppData]

but it should be:

export type SafeAppsResponse = SafeAppData[]

With the current type we only accept arrays with 1 item. I will create a PR in the safe-react-gateway-sdk to fix that.

CC: @katspaugh @iamacook

@katspaugh
Copy link
Member

Thanks Dani!

@DaniSomoza DaniSomoza merged commit 57ffd21 into dev Jan 17, 2022
@DaniSomoza DaniSomoza deleted the feature/enable-use-webcam-safe-apps branch January 17, 2022 15:45
@github-actions github-actions bot locked and limited conversation to collaborators Jan 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants