{"_id":"@cardananium/cardano-peer-connect","_rev":"2-d1cd8918b71c075b7094abb0254ac447","name":"@cardananium/cardano-peer-connect","dist-tags":{"latest":"1.2.19"},"versions":{"1.2.18":{"name":"@cardananium/cardano-peer-connect","version":"1.2.18","keywords":["WebRTC","WebTorrent","wallet","dapp"],"author":"","license":"Apache-2.0","_id":"@cardananium/cardano-peer-connect@1.2.18","maintainers":[{"name":"lisicky","email":"lisickyzheka@gmail.com"}],"dist":{"shasum":"b385ec46a8b8decdf37c2373422f98dbe7746338","tarball":"https://registry.npmjs.org/@cardananium/cardano-peer-connect/-/cardano-peer-connect-1.2.18.tgz","fileCount":41,"integrity":"sha512-LB8nIhqFtjaesPO6KrbDIsg4m2ICH04mB0XOGtFF8OZHQ3egKRtERC/KCAr38FVn69UEQeswnCZSITEuxXkcKw==","signatures":[{"sig":"MEQCIDjO/TZtevonsmPVMatOVQykq2QtmDx91w47hSEWDVxgAiBvGntdZOjO0s4zoKOgrTKZEqb2yzAlNi9Ltu50A12kQg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":3693409},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.js","gitHead":"315022f2d6eab15fec11b98ec91d643f3a34f1c7","scripts":{"test":"npm run build && cypress run","build":"webpack && tsc --emitDeclarationOnly","cy:run":"cypress run"},"_npmUser":{"name":"lisicky","email":"lisickyzheka@gmail.com"},"overrides":{"ip":"npm:@webpod/ip@latest"},"_npmVersion":"10.5.0","description":"This library aims to provide an abstract class to simplify to wallet implementation for CIP-0045","directories":{},"_nodeVersion":"21.7.3","dependencies":{"qrcode-svg":"^1.1.0","@cardananium/meerkat":"^1.0.17","@cardananium/marble-identicons":"^0.1.2"},"_hasShrinkwrap":false,"devDependencies":{"cypress":"^13.16.0","webpack":"^5.96.1","typescript":"^5.7.2","@babel/core":"^7.26.0","webpack-cli":"^5.1.4","babel-loader":"^9.2.1","@babel/preset-env":"^7.26.0","@types/qrcode-svg":"^1.1.5","clean-webpack-plugin":"^4.0.0","@babel/preset-typescript":"^7.26.0"},"_npmOperationalInternal":{"tmp":"tmp/cardano-peer-connect_1.2.18_1762959019792_0.5023817846194065","host":"s3://npm-registry-packages-npm-production"}},"1.2.19":{"name":"@cardananium/cardano-peer-connect","version":"1.2.19","description":"This library aims to provide an abstract class to simplify to wallet implementation for CIP-0045","main":"dist/index.js","module":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"webpack && tsc --emitDeclarationOnly","cy:run":"cypress run","test":"npm run build && cypress run"},"keywords":["WebRTC","WebTorrent","wallet","dapp"],"author":"","license":"Apache-2.0","devDependencies":{"@babel/core":"^7.26.0","@babel/preset-env":"^7.26.0","@babel/preset-typescript":"^7.26.0","@types/qrcode-svg":"^1.1.5","babel-loader":"^9.2.1","clean-webpack-plugin":"^4.0.0","cypress":"^13.16.0","typescript":"^5.7.2","webpack":"^5.96.1","webpack-cli":"^5.1.4"},"dependencies":{"@cardananium/marble-identicons":"^0.1.2","@cardananium/meerkat":"^1.0.18","qrcode-svg":"^1.1.0"},"overrides":{"ip":"npm:@webpod/ip@latest"},"_id":"@cardananium/cardano-peer-connect@1.2.19","gitHead":"5caf745aa6ed323b9c219927d545abe4376e087a","_nodeVersion":"21.7.3","_npmVersion":"10.5.0","dist":{"integrity":"sha512-LiRHceU7MG2mEww5StYC3H4Pv2GMcKHMiYjqi/Kz7EQ2/msk/C0njhckjAiJZQ72n03QaMIVc/S+LzE/xCyCwA==","shasum":"22e6c0468604e1803f0e00f6de9bbfb6e4058a17","tarball":"https://registry.npmjs.org/@cardananium/cardano-peer-connect/-/cardano-peer-connect-1.2.19.tgz","fileCount":41,"unpackedSize":3505122,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDmsiEYS1xV+569B7OdYByE5H8SYLk+Mc54Uya1rfaY0AIgfGwySDQnbu/tmgKNXt61C1iuo4qIisHpXjXoDi9ofcA="}]},"_npmUser":{"name":"lisicky","email":"lisickyzheka@gmail.com"},"directories":{},"maintainers":[{"name":"lisicky","email":"lisickyzheka@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cardano-peer-connect_1.2.19_1762959862707_0.14595653241105366"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-12T14:50:19.676Z","modified":"2025-11-12T15:04:23.196Z","1.2.18":"2025-11-12T14:50:20.034Z","1.2.19":"2025-11-12T15:04:22.984Z"},"license":"Apache-2.0","keywords":["WebRTC","WebTorrent","wallet","dapp"],"description":"This library aims to provide an abstract class to simplify to wallet implementation for CIP-0045","maintainers":[{"name":"lisicky","email":"lisickyzheka@gmail.com"}],"readme":"# Cardano Peer Connect\n\n<p align=\"left\">\n<img alt=\"Tests\" src=\"https://img.shields.io/github/actions/workflow/status/fabianbormann/cardano-peer-connect/test.yml?label=Tests&style=for-the-badge\" />\n<img alt=\"Release\" src=\"https://img.shields.io/github/actions/workflow/status/fabianbormann/cardano-peer-connect/release.yml?label=Release&style=for-the-badge\" />\n<img alt=\"Bundle\" src=\"https://img.shields.io/github/actions/workflow/status/fabianbormann/cardano-peer-connect/bundle.yml?label=Bundle&style=for-the-badge\" />\n<img alt=\"Publish\" src=\"https://img.shields.io/github/actions/workflow/status/fabianbormann/cardano-peer-connect/publish.yml?label=Publish&style=for-the-badge\" />\n<a href=\"https://conventionalcommits.org\"><img alt=\"conventionalcommits\" src=\"https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&style=for-the-badge\" /></a>\n</p>\n\nThis library aims to provide simple interfaces to implement [CIP-0045](https://github.com/cardano-foundation/CIPs/pull/395) for dApps and wallets.\nIf you want to see `cardano-peer-connect` in action, please visit the [cip-0045-demo-implementation](https://github.com/fabianbormann/cip-0045-demo-implementation) repository.\n\n<img src=\"https://user-images.githubusercontent.com/1525818/209772566-54ac650b-efb2-4f84-8f7b-eaeedb6f5f90.gif\" width=\"600\" />\n\n## Getting Started\n\n```zsh\nnpm i @fabianbormann/cardano-peer-connect\n```\n\n### Infos for usage in the wallet\n\nExtend the base CardanoPeerConnect class for your wallet:\n\n```js\nclass BoostPeerConnect extends CardanoPeerConnect {\n  constructor(name: string, apiVersion: string, icon: string) {\n    super({\n      name: name,\n      version: apiVersion,\n      icon: icon,\n    });\n\n    //further actions to let you wallet know about the new connection\n    // ...\n  }\n\n  // and implement all CIP-30 functions\n  getRewardAddresses(): Promise<Cbor[]> {\n    return new Promise((resolve, reject) => {\n      //in here you determine the reward addresses for yur wallet used\n      const rewardAddresses = [\n        'e1820506cb0ce54ae75.....7265e8792cb86afc94e0872',\n      ];\n\n      return resolve(rewardAddresses);\n    });\n  }\n\n  //...\n}\n```\n\nThen create an instance of that class in your code and add a callback to let your wallet know about the connection status.\n\n```js\nimport {\n  CardanoPeerConnect,\n  DAppPeerConnect,\n} from '@fabianbormann/cardano-peer-connect';\nimport { IConnectMessage } from '@fabianbormann/cardano-peer-connect/dist/src/types';\n\n// the id the dapp is showing you.\nconst dAppIdentifier = 'bYUh6Bn6A........388LR1JCrED';\n\npeerConnect.value = new BoostPeerConnect(\n  'Your wallet name',\n  '1.0.1',\n  '<img src=\"data:image/png;base64,iVB.....>' //your wallet logo\n);\n\n/**\n * Define a callback to handle all connection attempts. This will be called by the DApp when a connection is\n * tried to be established.\n */\npeerConnect.value.setOnConnect((message: IConnectMessage) => {\n  connectStatus.value = message;\n\n  if (!message.dApp.address) {\n    // every dapp should send some infos about it.\n  }\n\n  if (message.dApp.address !== dAppIdentifier) {\n    // the connected dapp id should match the one that the user requested\n  }\n\n  if (message.error) {\n    //handle the connection error (message.errorMessage)\n  }\n\n  //now handle the message and show which dapp was connected to your wallet\n});\n\n// finally try to connect to the dapp\nconst seed = peerConnect.value.connect(\n  dAppIdentifier,\n  [\n    'https://pro.passwordchaos.gimbalabs.io',\n    'wss://tracker.files.fm:7073/announce',\n    'wss://tracker.btorrent.xyz',\n    'ws://tracker.files.fm:7072/announce',\n    'wss://tracker.openwebtorrent.com:443/announce',\n  ],\n  getPeerSeed()\n);\n\n//seed will be the unique connection id between you and the dapp\n//The connection is not yet established. The user needs to grant the permission to establish the connection on the\n//dapp side. See next section on how a DApp must implement this.\n```\n\n### Infos for usage in DApp site\n\nThis is the necessary minimal implementation a DApp provider has to do, to get his app connected to peer connect.\n\n```html\n<script src=\"https://fabianbormann.github.io/cardano-peer-connect/latest/index.js\"></script>\n<script>\n\n  // Give your app some basic information that will be displayed to the client wallet when he is connecting to your DApp.\n  const dAppInfo: IDAppInfos = {\n    name: 'An awesome DApp',\n    url: 'http://an-awesome-dapp-url.tld/'\n  }\n\n  // Define a function that will be called when the client tries to connect to your DApp.\n  const verifyConnection = (\n    walletInfo: IWalletInfo,\n    callback: (granted: boolean) => void\n  ) => {\n    callback(//\n      window.confirm(`Do you want to connect to wallet ${walletInfo.name} (${walletInfo.address})?`)\n    );\n\n  const dAppConnect = new DAppPeerConnect({\n    dAppInfo: dAppInfo,\n    verifyConnection: verifyConnection,\n    onApiInject: onApiInject, // will be call when api was successfully injected\n    onApiEject: onApiEject,   // will be call when api was ejected\n  });\n\n  // This is the code (identifier) that the client needs to enter into the wallet to connect to your dapp\n  const clientConnectCode = dAppConnect.getAddress()\n\n  // Create and insert a QR code on your DApp, so the user can scan it easily in their app\n  dAppConnect.generateQRCode(document.getElementById('qr-code'));\n\n  //after the api was injected you cann call all cip-30 function on window.cardanop2p as you would on window.cardano\n</script>\n```\n","readmeFilename":"README.md"}