{"_id":"@dhealth/qr-library","_rev":"1-20ae45900a938eb6bb1dbac34aebf720","name":"@dhealth/qr-library","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@dhealth/qr-library","version":"1.0.0","description":"QR Codes library for dHealth Network","main":"dist/index.js","typings":"dist/index.d.ts","directories":{"test":"test"},"dependencies":{"braces":">=2.3.1","canvas":"^2.8.0","crypto-js":"^4.1.1","open":"^8.4.0","qrcode":"^1.5.0"},"devDependencies":{"@dhealth/hd-wallets":"^1.1.3","@dhealth/sdk":"^1.0.3-alpha-202201201200","@types/bip32":"^1.0.2","@types/chai":"^4.3.0","@types/mocha":"^9.0.0","@types/node":"^17.0.5","@types/qrcode":"^1.4.2","async":"^3.2.2","babel-core":"^6.26.3","babel-loader":"^8.2.3","babel-plugin-add-module-exports":"^1.0.4","babel-preset-es2015":"^6.24.1","browserify":"^17.0.0","bufferutil":"4.0.5","chai":"^4.3.4","copyfiles":"^2.4.1","coveralls":"^3.1.1","mocha":"^9.1.3","nyc":"^15.1.0","rxjs":"^7.5.1","ts-loader":"^9.2.6","ts-node":"^10.4.0","tslint":"^6.1.3","typedoc":"^0.22.10","typemoq":"^2.1.0","typescript":"^4.5.4","uglifyify":"^5.0.2","utf-8-validate":"^5.0.7","webpack":"^5.65.0","webpack-cli":"^4.9.1"},"scripts":{"pretest":"npm run build","build":"rm -rf dist/ && tsc","build:browser":"npm run build && webpack","lint:all":"tslint --project .","test":"mocha --ui bdd --recursive ./dist/test","test:cov":"nyc --reporter=lcov --reporter=text-summary npm t","test:coveralls":"npm run test:cov | coveralls","coveralls-report":"cat ./coverage/lcov.info | coveralls","version":"echo $npm_package_version","doc":"typedoc --entryPointStrategy expand --out \"ts-docs/$(npm run version --silent)\" src"},"repository":{"type":"git","url":"git+https://github.com/dhealthproject/dhealth-qr-library.git"},"author":{"name":"Grégory Saive for dHealth Network","email":"greg@evi.as"},"license":"Apache-2.0","bugs":{"url":"https://github.com/dhealthproject/dhealth-qr-library/issues"},"homepage":"https://github.com/dhealthproject/dhealth-qr-library#readme","nyc":{"exclude":["**/*.spec.js"]},"gitHead":"bfc76af4b424c101bbf00d8f54ecc598746120cc","_id":"@dhealth/qr-library@1.0.0","_nodeVersion":"14.5.0","_npmVersion":"6.14.5","dist":{"integrity":"sha512-HMTf48xZs8JOjmbj6NkiJPhva30q0mhPG2M0Mpoa8ijBhZmjdCxb3dprtGF/cC3l4opKtrGTDRZaTyP6ZaZIoA==","shasum":"2312ada6203c3983d0626db1be46d146f2c0a3c1","tarball":"https://registry.npmjs.org/@dhealth/qr-library/-/qr-library-1.0.0.tgz","fileCount":278,"unpackedSize":2844620,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICuKlUEiEfhlrTeSMSXB/kOxi8z/6N2RQzyMurxeeA5tAiEA0Yf/O0IG3gGCMW2mkeN5HBmNRVNHpF7rLdNMyfjbFp0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiWZtoACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoqkhAAnCrbrqFiUgMVJg8OfiLDvFhE9E82hLR+e1hKqq1FJvVNFtx/\r\nBgbJh3nbbi+NaCDj02F00dlmNzM1o/hz5B/Jx63QQPyMRpVodVvGP7DA0zcC\r\njfa8XE4o3O8x7MKodPIP1lv5j7SsLsh3SQZK+tdhd4LcyGRtaJPr3bH8Jnn4\r\nkuMcnPT12yduttJ6YUFW/1+IpxOmIriaDcvZg9B9Poopejy9HXz7QB35ilwQ\r\nqlMh2dH7lPYol08E7aiPGtD6f1ItKJhEpCENhevc20tOU8/2cVQ3aF8cPohZ\r\nzrccV0zm+KnBegspogn2INmhfeVnj889+rRRoj1ufVeneW7HiXCdLwgLW/fi\r\nwqJaAt0o7zeLWpB8at/vWPkSJsAiW2kVZvXiZgmYMQHkgknNkKeVN5GyYph+\r\nL99C9xzBMA/QpJnOt/72DENmKtVh2ZdLYF9Bwei2weG8Lg8n826vysPq/yPM\r\nEIjKgj3YHIei6+RTIpdo2fwYuJNMwTOgqO643yGWj49YExupKFbajdvxmyZL\r\ncXS8a1vHakJYxC2c3Af3ARai1z7n37+FM4eOfat2ylGpMJ3G2abhzz781FRs\r\npsa9wZ9GLKabCGu29JZmchy6oQJS4yFcviSg/VQlAxC0uGvd3yPEJUlOHu/T\r\np4ujSA6MAJnd6LFcjow6Nu/axqHNGvHNIB4=\r\n=3C9h\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"evias.be","email":"greg@evias.be"},"maintainers":[{"name":"evias.be","email":"greg@evias.be"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/qr-library_1.0.0_1650039656175_0.7552537117279476"},"_hasShrinkwrap":false}},"time":{"created":"2022-04-15T16:20:56.117Z","1.0.0":"2022-04-15T16:20:56.434Z","modified":"2023-02-12T14:39:43.583Z"},"maintainers":[{"email":"greg@dhealth.foundation","name":"dhealthbot"},{"email":"greg@evias.be","name":"evias.be"}],"description":"QR Codes library for dHealth Network","homepage":"https://github.com/dhealthproject/dhealth-qr-library#readme","repository":{"type":"git","url":"git+https://github.com/dhealthproject/dhealth-qr-library.git"},"author":{"name":"Grégory Saive for dHealth Network","email":"greg@evi.as"},"bugs":{"url":"https://github.com/dhealthproject/dhealth-qr-library/issues"},"license":"Apache-2.0","readme":"# @dhealth/qr-library\n\n[![npm version](https://badge.fury.io/js/@dhealth%2Fqr-library.svg)][npm]\n[![Discord](https://img.shields.io/badge/chat-on%20discord-green.svg)][discord]\n\nLibrary to generate QR codes for dHealth Network.\n\n**NOTE**: The author of this package cannot be held responsible for any loss of money or any malintentioned usage forms of this package. Please use this package with caution.\n\n## Features\n\nThe software allows you to create the following QR types:\n\n* **TransactionRequest**: QR to prepare transactions ready to be signed.\n* **Address**: QR to share the account address with others.\n* **Contact**: QR to share the account address and public key with others.\n* **Mnemonic**: QR to generate account mnemonic backups (encrypted | plain).\n* **Account**: QR to generate account private key backups (encrypted | plain).\n* **Object**: QR to export  a custom object.\n\n## Requirements\n\n- Node.js 12 LTS\n\n## Installation\n\n`npm install @dhealth/qr-library`\n\n\n## Usage\n\n### Generate QRCode for a Transaction Request\n\n```typescript\nimport { QRCodeGenerator, TransactionQR } from '@dhealth/qr-library';\nimport { Address, Deadline, Mosaic, NamespaceId, NetworkType, PlainMessage, TransferTransaction, UInt64 } from \"@dhealth/sdk\";\n\n// (Optional) create transfer transaction (or read from network)\nconst transfer = TransferTransaction.create(\n  Deadline.create(),\n  Address.createFromPublicKey(\n    'C5C55181284607954E56CD46DE85F4F3EF4CC713CC2B95000FA741998558D268',\n    NetworkType.MAIN_NET\n  ),\n  [new Mosaic(new NamespaceId('dhealth.dhp'), UInt64.fromUint(10000000))],\n  PlainMessage.create('Welcome to dHealth!'),\n  NetworkType.MAIN_NET\n);\n\n// generation hash of the connected network\nconst generationHash = 'ED5761EA890A096C50D3F50B7C2F0CCB4B84AFC9EA870F381E84DDE36D04EF16'\n\n// create QR Code base64\nconst qrCode: TransactionQR = QRCodeGenerator.createTransactionRequest(transfer, NetworkType.MAIN_NET, generationHash);\n\n// get base64 notation for <img> HTML attribute\nconst base64 = qrCode.toBase64();\n```\n\n### Generate AddressQR code\n\n```typescript\nimport { QRCodeGenerator, AddressQR } from '@dhealth/qr-library';\nimport { NetworkType } from '@dhealth/sdk';\n\nconst name = 'test-address-1';\nconst contactAddress = 'TA6QZTYPOIYQYR5NRY4WQ2WRQUX2FN5UK2DO6DI'\n\n// generation hash of the connected network\nconst generationHash = 'ED5761EA890A096C50D3F50B7C2F0CCB4B84AFC9EA870F381E84DDE36D04EF16'\n\n// create QR Code base64\nconst qrCode: AddressQR = QRCodeGenerator.createExportAddress(name, contactAddress, NetworkType.MAIN_NET, generationHash);\n\n// get base64 notation for <img> HTML attribute\nconst base64 = qrCode.toBase64();\n```\n\n### Generate ContactQR code\n\n```typescript\nimport { QRCodeGenerator, ContactQR } from '@dhealth/qr-library';\nimport { NetworkType } from '@dhealth/sdk';\n\nconst name = 'test-contact-1';\nconst accountPublicKey = 'C5C55181284607954E56CD46DE85F4F3EF4CC713CC2B95000FA741998558D268'\n\n// generation hash of the connected network\nconst generationHash = 'ED5761EA890A096C50D3F50B7C2F0CCB4B84AFC9EA870F381E84DDE36D04EF16'\n\n// create QR Code base64\nconst qrCode: ContactQR = QRCodeGenerator.createAddContact(name, accountPublicKey, NetworkType.MAIN_NET, generationHash);\n\n// get base64 notation for <img> HTML attribute\nconst base64 = qrCode.toBase64();\n\n```\n\n### Generate QRCode for a Mnemonic data\n\n```typescript\nimport { QRCodeGenerator, MnemonicQR } from '@dhealth/qr-library';\nimport { NetworkType } from '@dhealth/sdk';\nimport { MnemonicPassPhrase } from '@dhealth/hd-wallets';\n\n// create a mnemonic and password.\nconst mnemonic = MnemonicPassPhrase.createRandom();\n\n// generation hash of the connected network\nconst generationHash = 'ED5761EA890A096C50D3F50B7C2F0CCB4B84AFC9EA870F381E84DDE36D04EF16'\n\n// create QR Code base64\nconst encryptedMnemonicQR: MnemonicQR = new MnemonicQR(mnemonic.plain, NetworkType.MAIN_NET, generationHash, 'password');\n// or\nconst plainMnemonicQR: MnemonicQR = new MnemonicQR(mnemonic.plain, NetworkType.MAIN_NET, generationHash); // no password\n\n// get base64 notation for <img> HTML attribute\nconst base64 = encryptedMnemonicQR.toBase64();\n\n```\n\nThe produced Base64 encoded payload can be used to display the QR Code. An example of display can be done easily with HTML, as follows:\n\n```html\n<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==\" alt=\"Transfer Transaction QR code\" />\n```\n\n### Generate QRCode for an Account Private Key\n\n```typescript\nimport { QRCodeGenerator, AccountQR } from '@dhealth/qr-library';\nimport { NetworkType } from '@dhealth/sdk';\n\nconst accountPrivateKey = 'F97AE23C2A28ECEDE6F8D6C447C0A10B55C92DDE9316CCD36C3177B073906978'\n\n// generation hash of the connected network\nconst generationHash = 'ED5761EA890A096C50D3F50B7C2F0CCB4B84AFC9EA870F381E84DDE36D04EF16'\n\n// create QR Code base64\nconst encryptedAccountQR: AccountQR = QRCodeGenerator.createExportAccount(accountPrivateKey, NetworkType.MAIN_NET, generationHash, 'password')\nconst plainAccountQR: AccountQR = QRCodeGenerator.createExportAccount(accountPrivateKey, NetworkType.MAIN_NET, generationHash) // no password\n\n// get base64 notation for <img> HTML attribute\nconst base64 = encryptedAccountQR.toBase64();\n```\n\n\n### Generate QRCode for a custom object\n\n```typescript\nimport { QRCodeGenerator, ObjectQR } from '@dhealth/qr-library';\nimport { NetworkType } from '@dhealth/sdk';\n\n// define custom object to suit your application use case.\nconst object = {\"obj\": \"test\"};\n\n// generation hash of the connected network\nconst generationHash = 'ED5761EA890A096C50D3F50B7C2F0CCB4B84AFC9EA870F381E84DDE36D04EF16'\n\n// create QR Code base64\nconst qrCode: ObjectQR = QRCodeGenerator.createExportObject(object, NetworkType.MAIN_NET, generationHash);\n\n// get base64 notation for <img> HTML attribute\nconst base64 = qrCode.toBase64();\n```\n\n## Getting help\n\nUse the following available resources to get help:\n\n- [dHealth Documentation][docs]\n- [Package Documentation][self-docs]\n- Join the community on [Discord][discord] \n- If you found a bug, [open a new issue][issues]\n\n## Contributing\n\nContributions are welcome and appreciated. \nCheck [CONTRIBUTING](CONTRIBUTING.md) for information on how to contribute.\n\n## License\n\nCopyright (c) 2022-present, Grégory Saive for dHealth Network, All rights reserved.\n\nLicensed under the [Apache License 2.0](LICENSE)\n\n[self]: https://github.com/dhealthproject/dhealth-qr-library\n[self-docs]: https://dhealthproject.github.io/dhealth-qr-library/1.0.0\n[npm]: https://www.npmjs.com/package/@dhealth/qr-library\n[docs]: https://docs.dhealth.com\n[issues]: https://github.com/dhealthproject/dhealth-qr-library/issues\n[discord]: https://discord.gg/P57WHbmZjk\n","readmeFilename":"README.md"}