Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@metamask/detect-provider

Package Overview
Dependencies
Maintainers
5
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/detect-provider - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

7

dist/detect-provider.js

@@ -1,2 +0,2 @@

(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.detectEthereumProvider = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
/**

@@ -16,3 +16,3 @@ * Returns a Promise that resolves to the value of window.ethereum if it is

*/
module.exports = function detectProvider ({
module.exports = function detectEthereumProvider ({
mustBeMetaMask = false,

@@ -75,2 +75,3 @@ timeout = 3000,

},{}]},{},[1]);
},{}]},{},[1])(1)
});

@@ -1,4 +0,5 @@

(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.detectEthereumProvider = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
module.exports=function({mustBeMetaMask:e=!1,timeout:t=3e3}={}){if("number"!=typeof t)throw new Error("@metamask/detect-provider: Expected 'number' timeout.");if("boolean"!=typeof e)throw new Error("@metamask/detect-provider: Expected 'boolean' mustBeMetaMask.");let o=!1;return new Promise(r=>{function n(){if(o)return;o=!0,window.removeEventListener("ethereum#initialized",n);const{ethereum:t}=window;if(!t||e&&!t.isMetaMask){const o=e&&t?"Non-MetaMask window.ethereum detected.":"Unable to detect window.ethereum.";console.error("@metamask/detect-provider:",o),r(null)}else r(t)}window.ethereum?n():(window.addEventListener("ethereum#initialized",n,{once:!0}),setTimeout(()=>{n()},t))})};
},{}]},{},[1]);
},{}]},{},[1])(1)
});

@@ -15,3 +15,3 @@ /**

*/
module.exports = function detectProvider ({
module.exports = function detectEthereumProvider ({
mustBeMetaMask = false,

@@ -18,0 +18,0 @@ timeout = 3000,

{
"name": "@metamask/detect-provider",
"version": "1.0.0",
"version": "1.0.1",
"description": "A tiny utility for detecting the MetaMask Ethereum provider, or any EIP 1193-compliant provider.",

@@ -14,5 +14,3 @@ "main": "index.js",

"lint:fix": "eslint . --ext js,json --fix",
"build": "mkdir -p dist && yarn build:browser && yarn build:browser:min",
"build:browser": "browserify index.js > dist/detect-provider.js",
"build:browser:min": "browserify -g uglifyify index.js > dist/detect-provider.min.js",
"build": "./build.sh",
"prepare": "yarn build"

@@ -30,2 +28,8 @@ },

},
"keywords": [
"ethereum",
"provider",
"metamask",
"web3"
],
"bugs": {

@@ -32,0 +36,0 @@ "url": "https://github.com/MetaMask/detect-provider/issues"

@@ -12,2 +12,4 @@ # @metamask/detect-provider

### Node.js
```javascript

@@ -29,3 +31,3 @@ import detectEthereumProvider from '@metamask/detect-provider'

const chainId = await provider.request({
method: 'eth_chainId
method: 'eth_chainId'
})

@@ -39,2 +41,17 @@ } else {

### HTML
```html
<script src="https://unpkg.com/@metamask/detect-provider/dist/detect-provider.min.js"></script>
<script type="text/javascript">
const provider = await detectEthereumProvider()
if (provider) {
// handle provider
} else {
// handle no provider
}
</script>
```
### Options

@@ -41,0 +58,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc