{"dist":{"shasum":"6b3cdcf87e79eedb1364ee18398b89c91d043e6e","tarball":"https://registry.npmjs.org/@ledgerhq/connect-kit-loader/-/connect-kit-loader-1.0.0-beta.3.tgz","fileCount":8,"integrity":"sha512-1ysAze8UQatiKc9AirsoAzcPgW4V8siRgRoJjzxNGak3oaUBEgX+NBvai7ACLseQwziCqxXWMkOK2KizEACUQA==","signatures":[{"sig":"MEUCIQCtWCZdJeSYRga/hzeW8uypQYjDZVrqcp9MKNOLPmvP3gIgMOuEICx/NzbkadB1BMPkXNzczhxTjCd9th1DqIXwybI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11045,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjYUctACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo+hQ/9FQCwK0Ews+OJRtyG33DCG2BMP1RPADk8i8pEj0RGuLtyHASm\r\nUNYpovYnbuCLPSHvdDDaP1IqE792VONRLk+R/0a3gal4yIW+YKsc3uOxAUX4\r\nshraqGcErINpHeOLjIh0GS2YoEaAj+n2VymN9Aqp8yTsk+i55QFxMHkz1Eik\r\nOYc6GuCeP7lkItu9xkaJsHcxDzdsS1j6PTKKemzk3tKvXkUSU2BZKxSAeSIW\r\nH6dwHL//Q+m6CixErNrXvxWEaRo1yP8MxAoax2xd1W9r19cmPfZ2Uwf8MdCJ\r\nOBZMbHTyxrvdDfx9qitBxLQ+WEv6Vhy59/bjL9BMhO5TzR+W15zEsPSxbtyO\r\nb96IbUN5XLAQgMTIaURuVDA7i199p1p0GypWbFeTPhul/q1CseDvru8PuBBx\r\nZRIpj270muoxB7+ZujtWrtrM15nTcvhVXvO/6tbKLvGPP4XQ0HieC897+mt7\r\nSK2Tdi48sCC2oH52sllUcH6Am+ii3cWY2+HpOqE5pg0cRKu74HwhAjcKAP7n\r\nJUX8NV6rXGC8viKI70sNaWnzpscJhLi1R7rKl+AYO9sCfZQZKNLUJ2w8m/iO\r\nlSk9ScclxYHWiKSRxK5kHsGWTgnYUG1YcSiX+B8upYgtzL8aycoB7vl3CB+D\r\nME5PoRg20yNaNAy0Wsl8TAxYrERejTiCsew=\r\n=CoWk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/esm/index.js","name":"@ledgerhq/connect-kit-loader","types":"index","author":{"name":"Hugo Lopes"},"module":"dist/esm/index.js","readme":"# Ledger Connect Kit\n\nThe Ledger Connect Kit can be used to check the level of support for [Ledger\nConnect](https://get-connect.ledger.com) on the user's platform. We will guide\nthe user to install Connect or use a fallback connection to the Ledger Live\napp. The code is designed to be loaded at runtime from a CDN so that the logic\nand UI can be updated as we release new updates to Connect without the wait for\nwallet libraries and dapps updating package versions and releasing new builds.\n\nThe `@ledgerhq/connect-kit-loader` allows developers to consume Connect Kit in\na transparent way.\n\n\n## Support status\n\nLedger Connect is currently only supported on Safari iOS. There are two edge\ncases in the detection logic:\n\n- Safari on iPadOS is shown as supported if the user requests the mobile\n  website, as it sets the userAgent string to be the same as iOS, otherwise\n  the userAgent string is the same as Safari on MacOS, which is not supported\n  yet.\n- Brave on iOS is shown as supported because it sets the userAgest string to\n  be the same as Safari on iOS, but Connect will not work.\n\n\n## Connect Kit loader\n\nTo use Connect Kit you just have to add the `@ledgerhq/connect-kit-loader`\npackage as a dependency using your preferred package manager, using yarn as an example\n\n```sh\nyarn add @ledgerhq/connect-kit-loader\n```\n\nand use it as below\n\n```js\nimport { loadConnectKit } from '@ledgerhq/connect-kit-loader'\n\nconst connectKit = await loadConnectKit()\n```\n\nIf you are using classes you can get the promise on the class constructor and\nits value where you need it\n\n```ts\nimport { loadConnectKit } from '@ledgerhq/connect-kit-loader'\n\nexport class LedgerConnector {\n  private provider: any\n  private connectKitPromise: Promise<LedgerConnectKit>\n\n  constructor() {\n    super()\n\n    this.connectKitPromise = loadConnectKit()\n  }\n\n  public async connect(): Promise<Connector> {\n    if (!this.provider) {\n      // load Connect Kit, check support and show a UI modal if not supported\n      const connectKit = await this.connectKitPromise\n```\n\nYou can check that Connect Kit is loaded by looking at the network tab on the\ndeveloper tools. You should see a request for `https://<CDN>/umd/index.js`.\n\nSee what functions are provided by the Connect Kit API below.\n\n\n## Connect Kit API\n\nConnect Kit exports three functions, `enableDebugLogs`, `checkSupport` and\n`getProvider`.\n\n### `enableDebugLogs`\n\n#### Description\n\nEnables debug messages on the console in case you need to diagnose a possible\nproblem. Just reload the dapp to disable them.\n\nOnce Connect Kit is loaded you can call it from the browser's developer tools\nconsole with `window.ledgerConnectKit.enableDebugLogs()` and call the other\nConnect Kit functions to see the messages.\n\n### `checkSupport`\n\n#### Parameters\n\n```ts\ntype CheckSupportOptions = {\n  providerType: SupportedProviders;\n  chainId: ConnectSupportedChains;\n  bridge?: string;\n  infuraId?: string;\n  rpc: { [chainId: number]: string; };\n}\n```\n\n#### Returns\n\n```ts\ntype ConnectSupport = type CheckSupportResult = {\n  isLedgerConnectSupported?: boolean;\n  isLedgerConnectEnabled?: boolean;\n  isChainIdSupported?: boolean;\n  providerImplementation: 'LedgerConnect' | 'WalletConnect';\n}\n```\n\n#### Description\n\nLets you know the level of support for Ledger Connect on the user's platform,\nand shows a UI to guide the user.\n\nIf the Connect extension is installed and enabled you will just get the response\nand no UI will be shown. If Connect is not available on the user's platform one\nof these modals will be shown:\n\n- Try Ledger Connect, in case the user's platform supports Connect but\n  it is not installed or enabled; a button will be shown to let the user\n  install the browser extension.\n- Connect with Ledger Live, in case the user's platform does not support\n  Connect they will be able to use Ledger Live Mobile or Desktop to connect.\n\n### `getProvider`\n\n#### Returns\n\n`Promise<EthereumProvider | SolanaProvider>`\n\n#### Description\n\nBased on the options passed to `checkSupport` it returns a promise to a Ledger\nConnect Ethereum provider, Ledger Connect Solana Provider or a WalletConnect\nprovider.\n\n### Example\n\nAn example function using the *Ledger Connect Kit* and *ethers.js*, that would\nbe called when pressing the connect button on a React app.\n\n`setProvider`, `setLibrary`, `setAccount`, `setChainId` and `setError` are just\nsimple `useState` functions to keep app state.\n\n```js\n// JSX code\n<Button onClick={() => connectWallet()}>Connect With Ledger</Button>\n```\n\n```js\n// click handler function\nconst connectWallet = async () => {\n  try {\n    const connectKit = await loadConnectKit();\n    connectKit.enableDebugLogs();\n    const checkSupportResult = connectKit.checkSupport({\n      chainId: 1,\n      providerType: SupportedProviders.Ethereum,\n      rpc: {\n        1: `https://cloudflare-eth.com`, // Mainnet\n        137: \"https://matic-mainnet.chainstacklabs.com\", // Polygon\n      }\n    });\n    console.log('checkSupportResult is', checkSupportResult);\n    const provider = await connectKit.getProvider();\n\n    const library = new ethers.providers.Web3Provider(provider);\n    const accounts = await library.listAccounts();\n    const network = await library.getNetwork();\n\n    setProvider(provider);\n    setLibrary(library);\n\n    if (accounts) setAccount(accounts[0]);\n    setChainId(network.chainId);\n  } catch (error) {\n    setError(error);\n  }\n}\n```\n","license":"MIT","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"rollup -c --compact"},"typings":"dist/esm/index.d.ts","_npmUser":{"name":"sergii-shkolin","email":"sergii.shkolin-ext@ledger.fr"},"homepage":"https://get-connect.ledger.com/","keywords":["ledger","hardware wallet","ethereum","blockchain","provider","dapps","onboarding"],"repository":{"url":"https://github.com/LedgerHQ/connect-kit","type":"git","directory":"packages/connect-kit-loader"},"description":"Load Ledger Connect Kit at runtime, a library for dapps to integrate with Ledger Connect and Ledger Live","directories":{},"maintainers":[{"name":"sergii-shkolin","email":"sergii.shkolin-ext@ledger.fr"},{"name":"yogh","email":"jerome.caporossi@ledger.fr"},{"name":"haammar-ledger","email":"hakim.aammar-ext@ledger.fr"},{"name":"kvn-ledger","email":"kevin.lambert@ledger.fr"},{"name":"ofreyssinet","email":"olivier.freyssinet@gmail.com"},{"name":"jelbaz-ledger","email":"julien.el-baz@ledger.fr"},{"name":"achabrolin-ledger","email":"alexandre.chabrolin@ledger.fr"},{"name":"gre","email":"renaudeau.gaetan@gmail.com"},{"name":"btchip","email":"nicolas+npmjs@ledger.com"},{"name":"meriadec","email":"meriadec.pillet@gmail.com"},{"name":"flocks","email":"teissierflorent@gmail.com"},{"name":"amougel","email":"alix.mougel@gmail.com"},{"name":"juan-cortes","email":"juan@bohem.io"},{"name":"val_pinkman","email":"valentin.d.pinkman@icloud.com"},{"name":"iammorrow","email":"hugo.morosini@gmail.com"},{"name":"phenry-ledger","email":"pascal.henry@ledger.fr"},{"name":"jdecussy-ledger","email":"jerome.decussy@ledger.fr"},{"name":"lfbarreto","email":"barreto.luiz.f@gmail.com"},{"name":"junsugiura","email":"jun.sugiura.jp@gmail.com"},{"name":"hzheng_ledger","email":"huiqi.zheng@ledger.fr"}],"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tslib":"^2.4.0","rollup":"^2.75.6","typescript":"^4.7.3","@rollup/plugin-alias":"^3.1.9","rollup-plugin-terser":"^7.0.2","@rollup/plugin-commonjs":"^22.0.0","@rollup/plugin-typescript":"^8.3.3","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/connect-kit-loader_1.0.0-beta.3_1667319597456_0.18531933059286487","host":"s3://npm-registry-packages"},"_id":"@ledgerhq/connect-kit-loader@1.0.0-beta.3","version":"1.0.0-beta.3"}