{"_id":"@axia-js/ui-keyring","_rev":"2-d3b27d01c28898ddbe055fadf661b384","name":"@axia-js/ui-keyring","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@axia-js/ui-keyring","version":"0.1.0","type":"module","main":"index.js","sideEffects":["./detectPackage.js","./detectPackage.cjs"],"repository":{"type":"git","url":"git+https://github.com/axia-js/apps.git"},"author":{"name":"Sankar boro","email":"sankar.boro@zeeve.io"},"maintainers":[{"name":"sankar-boro-zeeve","email":"sankar.boro@zeeve.io"}],"contributors":[],"license":"Apache-2.0","dependencies":{"@axia-js/hw-ledger":"0.1.0","@axia-js/keyring":"0.1.2","@axia-js/ui-settings":"0.1.0","@axia-js/util":"0.1.0","@babel/runtime":"^7.15.4","mkdirp":"^1.0.4","rxjs":"^7.3.0","store":"^2.0.12"},"devDependencies":{"@types/mkdirp":"^1.0.2","@types/store":"^2.0.2"},"peerDependencies":{"@axia-js/keyring":"0.1.2","@axia-js/ui-settings":"0.1.0","@axia-js/util":"0.1.0"},"exports":{".":{"require":"./index.cjs","default":"./index.js"},"./Base":{"require":"./Base.cjs","default":"./Base.js"},"./bundle":{"require":"./bundle.cjs","default":"./bundle.js"},"./defaults":{"require":"./defaults.cjs","default":"./defaults.js"},"./detectPackage":{"require":"./detectPackage.cjs","default":"./detectPackage.js"},"./Keyring":{"require":"./Keyring.cjs","default":"./Keyring.js"},"./observable":{"require":"./observable/index.cjs","default":"./observable/index.js"},"./observable/accounts":{"require":"./observable/accounts.cjs","default":"./observable/accounts.js"},"./observable/addresses":{"require":"./observable/addresses.cjs","default":"./observable/addresses.js"},"./observable/contracts":{"require":"./observable/contracts.cjs","default":"./observable/contracts.js"},"./observable/env":{"require":"./observable/env.cjs","default":"./observable/env.js"},"./observable/genericSubject":{"require":"./observable/genericSubject.cjs","default":"./observable/genericSubject.js"},"./observable/types":{"require":"./observable/types.cjs","default":"./observable/types.js"},"./options":{"require":"./options/index.cjs","default":"./options/index.js"},"./options/item":{"require":"./options/item.cjs","default":"./options/item.js"},"./options/types":{"require":"./options/types.cjs","default":"./options/types.js"},"./package.json":"./package.json","./packageInfo":{"require":"./packageInfo.cjs","default":"./packageInfo.js"},"./README.md":"./README.md","./stores":{"require":"./stores/index.cjs","default":"./stores/index.js"},"./stores/Browser":{"require":"./stores/Browser.cjs","default":"./stores/Browser.js"},"./stores/File":{"require":"./stores/File.cjs","default":"./stores/File.js"},"./types":{"require":"./types.cjs","default":"./types.js"}},"description":"A wrapper extending the base @axia-js/keyring interface for usage in the browser: Key management of user accounts including generation and retrieval of keyring pairs from a variety of input combinations.","bugs":{"url":"https://github.com/axia-js/apps/issues"},"homepage":"https://github.com/axia-js/apps#readme","_id":"@axia-js/ui-keyring@0.1.0","_nodeVersion":"14.18.1","_npmVersion":"6.14.15","dist":{"integrity":"sha512-hCgmWVcZ+KVKItgDnIu/5Oh4HlHiqr/LCV24Pky1bsYcTpuz0leyUUqi/pzk45y0AAMMoM/IKaYxy2bGx4c+LQ==","shasum":"d5cab2c55cb963d62e910517032e97fa0cdfe0ad","tarball":"https://registry.npmjs.org/@axia-js/ui-keyring/-/ui-keyring-0.1.0.tgz","fileCount":44,"unpackedSize":69904,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzG5sCRA9TVsSAnZWagAA5XsP/1CtQNxbATRxgQl8J/zI\nBc0gzqaoJ4vnjdYLvt1bUya8Dn5/rNCcJ9Jg3C3PZHz2I7Ou3ckpFp4qfUtC\nAkmVydnerfEjO0450K50D+mhKJlMhZ1QlIN7Mzpns2DfoWIYrXNInS8R2zt6\n6HbO8hH4ezQ4zVMa4bVneAkG92XrCeHUtMKvEFebgwvgc1btLQJodIDOR22h\nvXONJDbKc8PoRrQ2AUuk01qwjRe+fEOnxIWD+DxsXaiR+IEx+iTm+I8peh5V\nvGgvVG7dYEEjSYqtjg3ST6yJM79SeLjE/ZYXOjrCgbTOd6kENLQAWRZjtNvW\nYzQYw6eJ4h2j9SSCsjrbmnMDlqvvZz2zRJ9vOCJMv44Vmx0iB5lY1Et+ZQIU\nXCAM87r0VplaZ20iP4SYvK13Z2WdIVl4iTbOiN8ocNurgfbntscrDk7yTjiM\nKMs+qqL93AKc89JJdFCUYFtx5XJR9AvdnPKJ13zN36fPX/pC12VKrwjUfFoM\nXrRqDLrC8DhWEthyZ/HpXZKg05oehr5HELH5cQtCyvdU5z0F9L5MOB+890kv\nFTZBAoGqwttF0iY3hWxLe4uxkCH9OilfE963m8XGEfF7YGgRdytV6xUsTNvg\n6D5S7c1V14tjZkZwD8sYEaTlK2RgBdH4U2zKKO6WFxwvU4umKenHg6hKdoTs\nJJYn\r\n=U+1r\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC9btYL+uZl2SoOyjXg8xteptPPB2833DhDQexOo+Y+JAiEAyp71msvYerGawxbd1JL/Pj8FYDaR2Fg6KnrESvnO+58="}]},"_npmUser":{"name":"sankar-boro-zeeve","email":"sankar.boro@zeeve.io"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ui-keyring_0.1.0_1636943833525_0.09158421938183059"},"_hasShrinkwrap":false}},"time":{"created":"2021-11-15T02:37:13.462Z","0.1.0":"2021-11-15T02:37:13.706Z","modified":"2022-04-04T17:10:37.453Z"},"maintainers":[{"name":"sankar-boro-zeeve","email":"sankar.boro@zeeve.io"}],"description":"A wrapper extending the base @axia-js/keyring interface for usage in the browser: Key management of user accounts including generation and retrieval of keyring pairs from a variety of input combinations.","homepage":"https://github.com/axia-js/apps#readme","repository":{"type":"git","url":"git+https://github.com/axia-js/apps.git"},"contributors":[],"author":{"name":"Sankar boro","email":"sankar.boro@zeeve.io"},"bugs":{"url":"https://github.com/axia-js/apps/issues"},"license":"Apache-2.0","readme":"# @axia-js/ui-keyring\n\nA wrapper extending the base @axia-js/keyring interface for usage in the browser:\nKey management of user accounts including generation and retrieval of keyring pairs from a variety of input combinations.\n\n## Usage Examples\n\nAll module methods are exposed through a single default export.\n\n### Regular\n\n```js\nimport keyring from @axia-js/ui-keyring\n\nrender () {\n  // encode publicKey to ss58 address\n  const address = keyring.encodeAddress(publicKey);\n\n  // get keyring pair from ss58 address\n  const pair = keyring.getPair(address);\n\n  // ask questions about that particular keyring pair\n  const isLocked = pair.isLocked;\n  const meta = pair.meta;\n\n  // save account from pair\n  keyring.saveAccount(pair, password);\n\n  // save address without unlocking it\n  keyring.saveAddress(address, { ...meta });\n}\n```\n\n## Observables\n\nOption 1: Declarative subscribe/unsubscribe w/ react-with-observable (recommended 'React' way)\n\n```js\nimport accountObservable from '@axia-js/ui-keyring/observable/accounts';\nimport { SingleAddress, SubjectInfo } from '@axia-js/ui-keyring/observable/types';\nimport React from 'react';\nimport { Subscribe } from 'react-with-observable';\nimport { map } from 'rxjs';\n\nclass MyReactComponent extends React.PureComponent {\n  render () {\n    <Subscribe>\n      {accountObservable.subject.pipe(\n        map((allAccounts: SubjectInfo) =>\n          !allAccounts\n            ? this.renderEmpty()\n            : Object.values(allAccounts).map((account: SingleAddress) =>\n                // Your component goes here\n                console.log(account.json.address)\n            )\n        ))}\n    </Subscribe>\n  }\n\n  renderEmpty () {\n    return (\n      <div> no accounts to display ... </div>\n    );\n  }\n}\n\n```\n\nOption 2: Imperative subscribe/unsubscribe\n\n```js\nimport accountObservable from '@axia-js/ui-keyring/observable/accounts';\nimport { SingleAddress, SubjectInfo } from '@axia-js/ui-keyring/observable/types';\nimport React from 'react';\nimport { Subscription } from 'rxjs';\n\ntype State = {\n  allAccounts?: SubjectInfo,\n  subscriptions?: [Subscription]\n}\n\nclass MyReactComponent extends React.PureComponent<State> {\n  componentDidMount () {\n    const accountSubscription = accountObservable.subject.subscribe((observedAccounts) => {\n      this.setState({\n        accounts: observedAccounts\n      });\n    })\n\n    this.setState({\n      subscriptions: [accountSubscription]\n    });\n  }\n\n  componentWillUnmount () {\n    const { subscriptions } = this.state;\n\n    for (s in subscriptions) {\n      s.subject.unsubscribe();\n    }\n  }\n\n  render () {\n    const { accounts } = this.state;\n\n    return (\n      <h1>All Accounts</h1>\n      {\n        Object.keys(accounts).map((address: SingleAddress) => {\n          return <p> {address} </p>;\n        })\n      }\n    )\n  }\n}\n```\n\n## FAQ\n\n- Difference between Keyring Accounts and Addresses?\n  - From the perspective of the keyring, it saves a particular user's unlocked identities as an account, a la keyring.saveAccount(pair, password). So with these accounts you are able to send and sign transactions.\n  - To save addresses without unlocking them (i.e. because a user might want to have easy access to addresses they frequently transact with), use keyring.saveAddress(address, meta)\n- What are 'external' accounts, i.e. when to set the `isExternal` meta key to true?\n  - An external account is one where the keys are not managed by keyring, e.g. in Parity Signer or Ledger Nano.\n- SS58 Encode / Decode?\n  -  SS58 is a simple address format designed for Substrate based chains. You can read about its specification in more detail in the [Parity Wiki](https://wiki.parity.io/External-Address-Format-(SS58)).\n\n**If you have any unanswered/undocumented questions, please raise an issue [here](https://github.com/axia-js/ui/issues).**\n\n\n## Users\n\nKeyring is core to many axia/substrate apps.\n\n* [axia-js/apps](https://github.com/axia-js/apps)\n* [axia-tech/substrate-light-ui](https://github.com/axia-tech/substrate-light-ui)\n","readmeFilename":"README.md"}