Skip to content

feat: add MetaMask detection functionality#93

Merged
baptiste-marchand merged 3 commits intomainfrom
feat/add-metamask-detection
Jan 16, 2026
Merged

feat: add MetaMask detection functionality#93
baptiste-marchand merged 3 commits intomainfrom
feat/add-metamask-detection

Conversation

@baptiste-marchand
Copy link
Contributor

@baptiste-marchand baptiste-marchand commented Jan 16, 2026

Add and exports the isMetamaskInstalled function to check either if MetaMask extension is installed, or if we're in the in-app browser.
This feature is required to correctly expose the readyState of TRON wallet adapter


Note

Introduces a simple MetaMask presence check and wires it into the public API.

  • Adds isMetamaskInstalled({ timeout }) in helpers/metamask.ts using EIP-6963 announceProvider/requestProvider
  • Exports isMetamaskInstalled from src/index.ts
  • Switches imports to helpers/metamask (from metamaskExtensionId) in externallyConnectableTransport and its tests
  • Minor robustness tweak to isChromeRuntime check in helpers/utils.ts
  • Updates LavaMoat allowScripts for Vitest/Vite esbuild paths

Written by Cursor Bugbot for commit a5ca5de. This will update automatically on new commits. Configure here.

@baptiste-marchand baptiste-marchand requested a review from a team as a code owner January 16, 2026 11:17
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

@baptiste-marchand baptiste-marchand force-pushed the feat/add-metamask-detection branch from 8aa8b44 to 2c2c56d Compare January 16, 2026 11:28
*/
export const isChromeRuntime = (): boolean => {
return typeof chrome !== 'undefined' && chrome.runtime && typeof chrome.runtime.connect === 'function';
return typeof chrome !== 'undefined' && !!chrome.runtime && typeof chrome.runtime.connect === 'function';
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 was returning undefined instead of a boolean in case chrome.runtime was undefined

@socket-security
Copy link

socket-security bot commented Jan 16, 2026

@socket-security
Copy link

socket-security bot commented Jan 16, 2026

Warning

MetaMask internal reviewing guidelines:

  • Do not ignore-all
  • Each alert has instructions on how to review if you don't know what it means. If lost, ask your Security Liaison or the supply-chain group
  • Copy-paste ignore lines for specific packages or a group of one kind with a note on what research you did to deem it safe.
    @SocketSecurity ignore npm/PACKAGE@VERSION
Action Severity Alert  (click "▶" to expand/collapse)
Warn Low
Potential code anomaly (AI signal): npm @babel/core is 100.0% likely to have a medium risk anomaly

Notes: The examined code is a standard, benign helper for constructing and wrapping configuration items from descriptors within Babel’s tooling. There is no evidence of data leakage, exfiltration, backdoors, or other malicious activity in this fragment. The combination of immutability, brand-based identity, and non-enumerable descriptor storage indicates a well-scoped internal utility rather than anything suspicious.

Confidence: 1.00

Severity: 0.60

From: ?npm/@vitest/coverage-istanbul@3.2.4npm/@babel/core@7.28.6

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@babel/core@7.28.6. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Low
Potential code anomaly (AI signal): npm acorn is 100.0% likely to have a medium risk anomaly

Notes: Overall, the analyzed code is a legitimate, well-structured Acorn 8.x parser fragment with robust handling for ES2020+ features. There is no direct malicious payload, backdoor, or exfiltration mechanism within this fragment. The primary security considerations relate to safe handling of untrusted input to avoid DoS via complex/ pathological RegExp usage or verbose error reporting. In a typical extension usage, isolate parsing to a sandbox and limit resource usage to mitigate potential abuse.

Confidence: 1.00

Severity: 0.60

From: ?npm/ts-node@10.9.2npm/acorn@8.15.0

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/acorn@8.15.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Low
Potential code anomaly (AI signal): npm esbuild is 100.0% likely to have a medium risk anomaly

Notes: On its face this package.json looks like the legitimate esbuild package layout: it runs a local install.js during postinstall and defines many optional platform-specific packages. The main risk is that the uninspected install.js may perform arbitrary, privileged actions (download remote binaries, execute code, add hooks, exfiltrate data, etc.). You should audit the contents of install.js (and any code it downloads or executes) before trusting installation in sensitive environments. The package.json itself does not contain obvious malicious indicators (no http:// deps, no non-registry dependency URLs, no overrides), but the postinstall hook makes it potentially risky.

Confidence: 1.00

Severity: 0.60

From: ?npm/vitest@3.2.4npm/esbuild@0.27.2

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/esbuild@0.27.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Low
Potential code anomaly (AI signal): npm yaml is 100.0% likely to have a medium risk anomaly

Notes: The analyzed code is a standard YAML stringify module with robust tag resolution, anchor handling, and formatting controls. It correctly delegates to appropriate stringify logic and handles edge cases like circular aliases and unresolved tags with explicit errors. Overall security posture is conservative and typical for a serialization library; no malicious activity detected.

Confidence: 1.00

Severity: 0.60

From: ?npm/typedoc@0.26.11npm/yaml@2.8.2

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/yaml@2.8.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Ignoring alerts on:

  • @typescript-eslint/utils@8.53.0
  • @typescript-eslint/typescript-estree@8.53.0
  • @metamask/auto-changelog@5.3.0
  • rollup@4.55.1
  • caniuse-lite@1.0.30001764
  • prettier@3.8.0

View full report

@baptiste-marchand baptiste-marchand marked this pull request as draft January 16, 2026 11:42
@baptiste-marchand baptiste-marchand marked this pull request as ready for review January 16, 2026 11:42
@baptiste-marchand
Copy link
Contributor Author

@SocketSecurity ignore npm/@metamask/auto-changelog@5.3.0
@SocketSecurity ignore npm/@typescript-eslint/typescript-estree@8.53.0
@SocketSecurity ignore npm/@typescript-eslint/utils@8.53.0
@SocketSecurity ignore npm/caniuse-lite@1.0.30001764
@SocketSecurity ignore npm/prettier@3.8.0
@SocketSecurity ignore npm/rollup@4.55.1

@baptiste-marchand baptiste-marchand merged commit bedaf92 into main Jan 16, 2026
22 checks passed
This was referenced Jan 16, 2026
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

Successfully merging this pull request may close these issues.

2 participants