{"id":23109172,"url":"https://github.com/bpanel-org/bpanel-utils","last_synced_at":"2025-08-17T10:39:23.578Z","repository":{"id":104866282,"uuid":"127350191","full_name":"bpanel-org/bpanel-utils","owner":"bpanel-org","description":"Useful utilities for building bPanel plugins","archived":false,"fork":false,"pushed_at":"2019-01-18T04:20:06.000Z","size":506,"stargazers_count":0,"open_issues_count":4,"forks_count":2,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-07-08T18:45:15.569Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bpanel-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-29T21:39:49.000Z","updated_at":"2019-01-18T04:20:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"c4720b45-2ac5-4e86-9e3d-9f6b6a9b1b20","html_url":"https://github.com/bpanel-org/bpanel-utils","commit_stats":{"total_commits":127,"total_committers":4,"mean_commits":31.75,"dds":0.5433070866141732,"last_synced_commit":"9e625f0b003221a968fd3c6febffa4e58e5dc72f"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/bpanel-org/bpanel-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpanel-org%2Fbpanel-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpanel-org%2Fbpanel-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpanel-org%2Fbpanel-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpanel-org%2Fbpanel-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bpanel-org","download_url":"https://codeload.github.com/bpanel-org/bpanel-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpanel-org%2Fbpanel-utils/sbom","scorecard":{"id":249646,"data":{"date":"2025-08-11","repo":{"name":"github.com/bpanel-org/bpanel-utils","commit":"9e625f0b003221a968fd3c6febffa4e58e5dc72f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Code-Review","score":4,"reason":"Found 14/30 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 16 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"86 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: CVE-2023-50475 / GHSA-jj93-39pf-7mcf","Warn: Project is vulnerable to: GHSA-pp7h-53gx-mx7r","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-wg6g-ppvx-927h","Warn: Project is vulnerable to: GHSA-c6rq-rjc2-86v2","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2","Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546","Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9","Warn: Project is vulnerable to: GHSA-8hfj-j24r-96c4","Warn: Project is vulnerable to: GHSA-wc69-rhjr-hc9g","Warn: Project is vulnerable to: GHSA-w7rc-rwvf-8q5r","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-584q-6j8j-r5pm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-h9rv-jmmf-4pgx","Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7","Warn: Project is vulnerable to: GHSA-wpg7-2c88-r8xv","Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq","Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-pq67-2wwv-3xjx","Warn: Project is vulnerable to: GHSA-8cj5-5rvv-wf4v","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T08:12:51.852Z","repository_id":104866282,"created_at":"2025-08-17T08:12:51.852Z","updated_at":"2025-08-17T08:12:51.852Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270837408,"owners_count":24654377,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T01:33:46.738Z","updated_at":"2025-08-17T10:39:23.555Z","avatar_url":"https://github.com/bpanel-org.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bpanel utils\n\nSimple helper utilities for use in bpanel plugins\n\n## Usage\n\n``` js\nconst utils = require('@bpanel/bpanel-utils');\n```\n\n## Utilities\n\n#### User Experience Transaction\n\n```js\nimport { UXTX } from '@bpanel/bpanel-utils';\nimport { WalletClient } from 'bclient';\n\nconst walletClient = new WalletClient({\n  network: 'main',\n  port: 8334,\n  apiKey: SECRETS.API_KEY,\n});\n\nconst id = 'primary';\nconst wallet = walletClient.wallet(id);\n\n/*\n * try fetching the hash yourself\n   curl -s https://blockchain.info/rawblock/0000000000000000000c76fd257881891a21a018c4abd13c33c9f06a822914c9 \\\n     | jq -r .tx[0].hash\n */\n\nconst hash = '6b3aafbed09f215d1f95fb06b7c204d12f7657e1bc1ff3dfa37d3248e05a430c';\n\nconst tx = await wallet.getTX(hash)\n\nconst options = {\n  constants: { DATE_FORMAT: 'moment js date format string' },\n  labels: {}, // see labels object for usable labels\n  json: tx,\n  wallet: id, // wallet name\n};\n\nconst uxtx = UXTX.fromRaw(tx.tx, 'hex', options);\n\nconst json = uxtx.toJSON();\n\n```\n\n`uxtx.toJSON` will use the labels and transaction information to\nreturn human readable information about the transaction.\nIt is particularly useful for calculating tabular data, for example,\ndisplaying if a specific transaction was incoming or outgoing.\nThere are more ways that this class can be extended, for example detecting\ncoinjoin transactions or sweep transactions.\n\n#### Tx Manager\n\nA wrapper around `UXTX` to manage many transactions.\n\n```js\n\nimport { TxManager, TxManagerOptions, UXTXOptions } from '@bpanel/bpanel-utils';\n\n// set bitcoin as the current chain\nUXTXOptions.chain = 'bitcoin';\n\n// use default labels and constants in TxManagerOptions\n(async () =\u003e {\n  const txManager = TxManager.fromOptions(TxManagerOptions);\n\n  const account = 'default';\n  const txs = await wallet.getHistory(account);\n\n  // generate list of UXTX.toJSON with default labels and constants\n  const parsed = txManager.parse(txs, UXTXOptions);\n})();\n```\n\n#### Chain\n\nThis package includes helpers around the chain\n\n```js\n\nimport { chain } from '@bpanel/bpanel-utils';\n\nconsole.log(chain.isChainSupported('bitcoin'));\n// true\n\nconsole.log(chain.isChainSupported('monero'));\n// false\n\nconsole.log(chain.isChainSupported('bitcoincash'));\n// true\n\nconsole.log(chain.isChainSupported('handshake'));\n// true\n```\n\n`chain.isChainSupported` is a helper function that\nreturns a boolean based on whether or not the input\nstring is a supported chain. The supported chains\ncan be inspected in `chain.CHAINS`\n\n\n#### HD\n\nThis package includes helpers around HD tree derivation\n\n```js\n\nimport { COIN_TYPES, PURPOSE } from '@bpanel/bpanel-utils';\nimport assert from 'bsert';\n\nconst bitcoin = COIN_TYPES['bitcoin']['main'];\n\nassert(bitcoin === 0);\n\nconst bitcoincash = COIN_TYPES['bitcoincash']['main'];\n\nassert(bitcoincash === 145);\n\nassert(PURPOSE === 44);\n```\n\n#### BPClient\n\nA utility client to manage connections to a node within your app.\nIt is configured to make connections via the proxy server where your bPanel app\nis served from, but should support custom connections either directly to a remote\nnode or even one running on the client. It will support connecting to a bcoin, bcash,\nor handshake node.\n\nExample:\n\n```js\nimport { BPClient } from '@bpanel/bpanel-utils';\n\n(async function() {\n  const client = new BPClient({ id: 'test', chain: 'bcoin' });\n\n  // get all available clients from your server\n  const clients = await client.getClients();\n\n  // get default client of server if one is set\n  const defaultClient = await client.getDefault();\n\n  // get info for a specific client. Defaults to\n  // the id of your client\n  const getClientInfo = await client.getClientInfo();\n\n  // get a node client to query your node with\n  const nodeClient = client.getNodeClient();\n\n  // use node client to run normal node api operations\n  const nodeInfo = await nodeClient.getInfo();\n})();\n```\n\n##### getClient\n\nUsing `getClient` you can retrieve a global instance of BPClient within your app.\nThis ensures that you are querying the same node as other plugins. The client returned\nwill have all clients and methods available to the parent BPClient class.\n\n\n```js\nimport { getClient } from '@bpanel/bpanel-utils';\n\nconst client = getClient();\n\n(async function() {\n  if (!client.id)\n    client.setClientInfo('test', 'handshake');\n\n  // now you can start using your clients\n  // anywhere else in the app that uses the client from `getClient`\n  // will also be using the `test` clients until the info is changed again\n\n  const info = await client.node.getInfo();\n\n  console.log('info: ', info);\n})();\n```\n\n#### Primitives\n\nA high level goal of bPanel is to allow for many different blockchain\nbackends. To allow for dynamic switching of chains when implementing\nlogic with primitives, it is possible to use objects that are keyed\nby the blockchain name to the primitive. These objects are wrapped\nwith some helper functions that work via the primitive `from` methods.\nEach of the exposed functions are named `toPrimitive` where primitive\nis a bcoin primitive.\n\n```js\n// create a bitcoin mtx\nconst hex = Buffer.from('...', 'hex');\n// first argument shares properties of objects returned\n// by bcoin backend. second argument is the options\nconst mtx = toMTX({ hex }, { type: 'raw', chain: 'bitcoin' });\n\n// create a bitcoin cash mtx\nconst bchmtx = toMTX({ hex }, { type: 'raw', chain: 'bitcoincash' });\n\nconst hns = Buffer.from('...', 'hex');\nconst hnsmtx = toMTX({ hex: hns }, { type: 'raw', chain: 'handshake' });\n```\n\n#### Bytes\n\n```js\n\nimport { helpers } from '@bpanel/bpanel-utils';\nimport assert from 'bsert';\n\nconst twelve = 12;\n\nassert(helpers.isU8(twelve));\n\nconst sixhundredtwelve = 612;\n\nassert(helpers.isU16(sixhundredtwelve));\n```\n\n#### ProxySocket\nA utility that can be passed to a bcoin or bcash node that you would like to run in\nthe browser.\n\n```js\nimport { ProxySocket } from '@bpanel/bpanel-utils';\n\nconst node = new FullNode({\n      prune: true,\n      network: 'main',\n      memory: false,\n      coinCache: 30,\n      createSocket: (port, host) =\u003e {\n        const proto = window.location.protocol === 'https:' ? 'wss' : 'ws';\n        const hostname = window.location.hostname;\n        return ProxySocket.connect(\n          `${proto}://${hostname}`,\n          port,\n          host\n        );\n      }\n    });\n```\n\nTake a look at the bcoin guide to learn more about\n[running a node in the browser](https://bcoin.io/guides/browser.html)\n\n## Contribution and License Agreement\n\nIf you contribute code to this project, you are implicitly allowing your code\nto be distributed under the MIT license. You are also implicitly verifying that\nall code is your original work. `\u003c/legalese\u003e`\n\n## License\n\n- Copyright (c) 2018, Bcoin Devs (MIT License).\n\nSee LICENSE for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpanel-org%2Fbpanel-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbpanel-org%2Fbpanel-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpanel-org%2Fbpanel-utils/lists"}