{"_id":"@axiasolar-js/ui-keyring","_rev":"2-8e6e0a012b5241caa1ca4bb646f6d186","name":"@axiasolar-js/ui-keyring","dist-tags":{"latest":"1.1.0"},"versions":{"1.1.0":{"name":"@axiasolar-js/ui-keyring","version":"1.1.0","type":"module","main":"index.js","sideEffects":["./detectPackage.js","./detectPackage.cjs"],"repository":{"type":"git","url":"git+https://github.com/axiasolar-js/apps.git"},"author":{"name":"Sankar boro","email":"sankar.boro@zeeve.io"},"maintainers":[{"name":"abhishek-zeeve","email":"abhishek.rana@zeeve.io"},{"name":"sankar-boro-zeeve","email":"sankar.boro@zeeve.io"}],"contributors":[],"license":"Apache-2.0","dependencies":{"@babel/runtime":"^7.15.4","@axiasolar-js/hw-ledger":"1.1.0","@axiasolar-js/keyring":"1.1.0","@axiasolar-js/ui-settings":"1.1.0","@axiasolar-js/util":"1.1.0","mkdirp":"^1.0.4","rxjs":"^7.3.0","store":"^2.0.12"},"devDependencies":{"@types/mkdirp":"^1.0.2","@types/store":"^2.0.2"},"peerDependencies":{"@axiasolar-js/keyring":"*","@axiasolar-js/ui-settings":"*","@axiasolar-js/util":"*"},"exports":{".":{"require":"./index.cjs","default":"./index.js"},"./Base":{"require":"./Base.cjs","default":"./Base.js"},"./Base.d.ts":"./Base.d.ts","./bundle":{"require":"./bundle.cjs","default":"./bundle.js"},"./bundle.d.ts":"./bundle.d.ts","./defaults":{"require":"./defaults.cjs","default":"./defaults.js"},"./defaults.d.ts":"./defaults.d.ts","./detectPackage":{"require":"./detectPackage.cjs","default":"./detectPackage.js"},"./detectPackage.d.ts":"./detectPackage.d.ts","./index.d.ts":"./index.d.ts","./Keyring":{"require":"./Keyring.cjs","default":"./Keyring.js"},"./Keyring.d.ts":"./Keyring.d.ts","./observable":{"require":"./observable/index.cjs","default":"./observable/index.js"},"./observable/accounts":{"require":"./observable/accounts.cjs","default":"./observable/accounts.js"},"./observable/accounts.d.ts":"./observable/accounts.d.ts","./observable/addresses":{"require":"./observable/addresses.cjs","default":"./observable/addresses.js"},"./observable/addresses.d.ts":"./observable/addresses.d.ts","./observable/contracts":{"require":"./observable/contracts.cjs","default":"./observable/contracts.js"},"./observable/contracts.d.ts":"./observable/contracts.d.ts","./observable/env":{"require":"./observable/env.cjs","default":"./observable/env.js"},"./observable/env.d.ts":"./observable/env.d.ts","./observable/genericSubject":{"require":"./observable/genericSubject.cjs","default":"./observable/genericSubject.js"},"./observable/genericSubject.d.ts":"./observable/genericSubject.d.ts","./observable/index.d.ts":"./observable/index.d.ts","./observable/types":{"require":"./observable/types.cjs","default":"./observable/types.js"},"./observable/types.d.ts":"./observable/types.d.ts","./options":{"require":"./options/index.cjs","default":"./options/index.js"},"./options/index.d.ts":"./options/index.d.ts","./options/item":{"require":"./options/item.cjs","default":"./options/item.js"},"./options/item.d.ts":"./options/item.d.ts","./options/types":{"require":"./options/types.cjs","default":"./options/types.js"},"./options/types.d.ts":"./options/types.d.ts","./package.json":"./package.json","./packageInfo":{"require":"./packageInfo.cjs","default":"./packageInfo.js"},"./packageInfo.d.ts":"./packageInfo.d.ts","./README.md":"./README.md","./stores":{"require":"./stores/index.cjs","default":"./stores/index.js"},"./stores/Browser":{"require":"./stores/Browser.cjs","default":"./stores/Browser.js"},"./stores/Browser.d.ts":"./stores/Browser.d.ts","./stores/File":{"require":"./stores/File.cjs","default":"./stores/File.js"},"./stores/File.d.ts":"./stores/File.d.ts","./stores/index.d.ts":"./stores/index.d.ts","./types":{"require":"./types.cjs","default":"./types.js"},"./types.d.ts":"./types.d.ts"},"description":"A wrapper extending the base @axiasolar-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/axiasolar-js/apps/issues"},"homepage":"https://github.com/axiasolar-js/apps#readme","_id":"@axiasolar-js/ui-keyring@1.1.0","_nodeVersion":"14.17.6","_npmVersion":"6.14.15","dist":{"integrity":"sha512-f9usPdD6cZzFoSYgSu/Knn6jEFywZ6TR5Dr7pe+8EAf5VRJ+pDs3DBn32TLkPmg0btEimjzcUnmz+qDUtY8EWQ==","shasum":"23645b99e176130b906fdece9a0671c518a297dc","tarball":"https://registry.npmjs.org/@axiasolar-js/ui-keyring/-/ui-keyring-1.1.0.tgz","fileCount":66,"unpackedSize":197684,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh12NWCRA9TVsSAnZWagAA34AQAIbSSNgjLltJyaboloPF\ntSffv9onI9iTGjkHHjrKDxZuqfYkecainHSKrySNzJtUBY5YFbIleVcre2HA\nY/m3dW4ymt2+dvve3CDtmqEbC6N9wqbgsvxOrS1jKTz1XCwMKAwfXAmaZ6g/\nIzlk0VDEO9uY+4amQE/0mcDcfeT/RjgrohM3HrtkAdOEqsfw3wFeSFRdVQDc\nP+/o9+ALJMUSJkE/ZKbZ10cxSS3cxzpljE1SNIUNXPaYNGWBc0+z5wWraudb\nCpmj3brySLbzjP6A8q9xAhpEheR3/w18qUfXPdrYLFCZvZoKYYMgh6Pk50dd\nV2sxKzvYFOPDe4mzRtmACJr5M8aFQDgFdJhTFt6ot09PR5npQuhpe6QAkusm\nYUEEtF5/ttUBnsLomBbTSVBuAhHaupiCakogxYy0DXtmBYKhxbx1CO2NJa5H\nmS7uLAXE4cwKOa6x7oApntqJAKqG9RmD/m1TFRLGIOy/TvEdcotpKHmTLHXb\niERemL86nKcIihN1jWFeo6Zgr4CAeJa2R+QOaz4LMjLxkBcXrN0S7Fj4Aj4m\n2das9dDfidFSY/+nbyQ4em/VV2TPgHFdNXHQVnS1UnGvp9L4VOd5C3bJBIKz\ndjTAr1qzQ40jRcjBRjVZAiRjq4Q+odLLU+navfydQjij8Tijx9ASJy10Cc7J\nkTk5\r\n=RU9c\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAEBA469AJJHk5geQqCoWuDVaPezA7HfvTlBsZzAEJlLAiEAsjIU28NGdoJHHFTdQB0ModP1M5+UUjNDSD6YVgAmIHI="}]},"_npmUser":{"name":"sankar-boro-zeeve","email":"sankar.boro@zeeve.io"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ui-keyring_1.1.0_1632467678751_0.5028439133088474"},"_hasShrinkwrap":false}},"time":{"created":"2021-09-24T07:14:38.705Z","1.1.0":"2021-09-24T07:14:38.954Z","modified":"2022-04-04T17:11:07.967Z"},"maintainers":[{"name":"abhishek-zeeve","email":"abhishek.rana@zeeve.io"},{"name":"sankar-boro-zeeve","email":"sankar.boro@zeeve.io"}],"description":"A wrapper extending the base @axiasolar-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/axiasolar-js/apps#readme","repository":{"type":"git","url":"git+https://github.com/axiasolar-js/apps.git"},"contributors":[],"author":{"name":"Sankar boro","email":"sankar.boro@zeeve.io"},"bugs":{"url":"https://github.com/axiasolar-js/apps/issues"},"license":"Apache-2.0","readme":"# @axiasolar-js/ui-keyring\n\nA wrapper extending the base @axiasolar-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 @axiasolar-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 '@axiasolar-js/ui-keyring/observable/accounts';\nimport { SingleAddress, SubjectInfo } from '@axiasolar-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 '@axiasolar-js/ui-keyring/observable/accounts';\nimport { SingleAddress, SubjectInfo } from '@axiasolar-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/axiasolar-js/ui/issues).**\n\n\n## Users\n\nKeyring is core to many axiasolar/substrate apps.\n\n* [axiasolar-js/apps](https://github.com/axiasolar-js/apps)\n* [axia-tech/substrate-light-ui](https://github.com/axia-tech/substrate-light-ui)\n","readmeFilename":"README.md"}