{"_id":"@caict-bif/bop-typescript-sdk","_rev":"4-276f48d04cedf27c987015293932d8ec","name":"@caict-bif/bop-typescript-sdk","dist-tags":{"latest":"1.2.0"},"versions":{"1.1.0":{"name":"@caict-bif/bop-typescript-sdk","version":"1.1.0","keywords":["caict","bop"],"author":{"name":"maxufeng","email":"maxufeng@caict.ac.cn"},"license":"apache2.0","_id":"@caict-bif/bop-typescript-sdk@1.1.0","maintainers":[{"name":"zhangbo3","email":"zhangbo3@caict.ac.cn"}],"homepage":"https://github.com/caict-4iot-dev/bop-typescript-sdk#readme","bugs":{"url":"https://github.com/caict-4iot-dev/bop-typescript-sdk/issues"},"dist":{"shasum":"bdb953aa2c935f843be151096c71cbc8c831bb6a","tarball":"https://registry.npmjs.org/@caict-bif/bop-typescript-sdk/-/bop-typescript-sdk-1.1.0.tgz","fileCount":365,"integrity":"sha512-Jbq55XjqZmI0ifqkdaAo8+9JyhcqLWLyl5a/UbQth6LzGf3plJlurnjApERUSmShohdi+WwAO8/Hlto2SeAgHw==","signatures":[{"sig":"MEQCIFJl9wyJghG/KS4Poec2JszvueLMvzmmvdPdgxA9jUEBAiAyieUhTbwLSiC9HzhLTBXC5QXZNYRN6o76PK82msJafA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5364715},"main":"dist/index.js","types":"./dist/index.d.ts","engines":{"node":"18.20.4"},"gitHead":"1b6c553034a8e79d5ce24925044c780e9331544b","scripts":{"lint":"npx prettier --check . && npx eslint .","test":"npm run test:compile && npm run test-bop && npm run test-sdk","build":"npm run test:compile","clean":"rm -rf ./dist","ws-demo":"npm run build && node dist/bop/bop-ws/sample/sample.js","lint:fix":"npx prettier --write . && npx eslint --fix .","test-bop":"npm run test:compile && mocha --recursive 'dist/bop/**/test/**/*.js' -c --exit --timeout 30000","test-sdk":"npm run test:compile && mocha --recursive 'dist/bop-sdk/**/test/**/*.js' -c --exit --timeout 30000","test:compile":"tsc --project tsconfig.json && copyfiles -u 4 src/bop-sdk/interface/service/offline/**/* dist/bop-sdk/interface/service/"},"_npmUser":{"name":"zhangbo3","email":"zhangbo3@caict.ac.cn"},"overrides":{"crypto-js":"$crypto-js"},"repository":{"url":"git+https://github.com/caict-4iot-dev/bop-typescript-sdk.git","type":"git"},"_npmVersion":"10.8.2","description":"Xinghuo bop sdk","directories":{},"_nodeVersion":"20.20.2","dependencies":{"ws":"^8.21.0","long":"^5.2.3","sjcl":"^1.0.9","bn.js":"^5.2.3","chalk":"^2.4.2","debug":"^4.1.1","io-ts":"^1.10.4","assert":"^2.1.0","crypto":"^1.0.1","eslint":"^9.5.0","semver":"^6.3.0","js-sha3":"^0.9.3","fs-extra":"^7.0.1","brdc-sjcl":"^1.1.1","crypto-js":"^4.2.0","is-type-of":"^2.1.0","typescript":"~5.0.0","@caict/bs58":"^5.0.0","@types/chai":"^4.2.0","@types/node":"^18.0.0","co-wrap-all":"^1.0.0","json-bigint":"^1.0.0","randombytes":"^2.1.0","@types/mocha":">=9.1.0","@types/sinon":"^9.0.8","bignumber.js":"^9.1.2","merge-descriptors":"^2.0.0","@bufbuild/protobuf":"^2.2.3","@caict/bif-protocol":"^1.0.2","reconnecting-websocket":"^4.4.0","@caict-bif/bif-encryption":"^1.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"4.2.0","mocha":"^11.0.1","sinon":"^19.0.2","ts-proto":"^2.6.0","copyfiles":"^2.4.1","chai-as-promised":"^8.0.1"},"_npmOperationalInternal":{"tmp":"tmp/bop-typescript-sdk_1.1.0_1786808694384_0.889089772719847","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@caict-bif/bop-typescript-sdk","version":"1.1.1","keywords":["caict","bop"],"author":{"name":"maxufeng","email":"maxufeng@caict.ac.cn"},"license":"apache2.0","_id":"@caict-bif/bop-typescript-sdk@1.1.1","maintainers":[{"name":"zhangbo3","email":"zhangbo3@caict.ac.cn"}],"homepage":"https://github.com/caict-4iot-dev/bop-typescript-sdk#readme","bugs":{"url":"https://github.com/caict-4iot-dev/bop-typescript-sdk/issues"},"dist":{"shasum":"fd16d10905a18fa027b6d23425611c38d238aa97","tarball":"https://registry.npmjs.org/@caict-bif/bop-typescript-sdk/-/bop-typescript-sdk-1.1.1.tgz","fileCount":369,"integrity":"sha512-K2Yymgp4GU+jC649KrJ/SRtO1MhFBph2dqZDEO+/D98nljIgE1mbZzvCUoA8W4t3fAL3BzoGhXFGOKPCSTu3NA==","signatures":[{"sig":"MEUCIQCXILX8c+rNPv9D/ufWoIdsEmO0udz1t0xwRYe+/vs3QgIgB45bvpgulLCOjVolUhuwmw82aGN84pBe++t5qNZwKvk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5364948},"main":"dist/index.js","types":"./dist/index.d.ts","engines":{"node":"18.20.4"},"gitHead":"93ef858d70de9646749e70409bb53166424afe1e","scripts":{"lint":"npx prettier --check . && npx eslint .","test":"npm run test:compile && npm run test-bop && npm run test-sdk","build":"npm run test:compile","clean":"rm -rf ./dist","ws-demo":"npm run build && node dist/bop/bop-ws/sample/sample.js","lint:fix":"npx prettier --write . && npx eslint --fix .","test-bop":"npm run test:compile && mocha --recursive \"dist/bop/**/test/**/*.js\" -c --exit --timeout 30000","test-sdk":"npm run test:compile && mocha --recursive \"dist/bop-sdk/**/test/**/*.js\" -c --exit --timeout 30000","test:compile":"tsc --project tsconfig.json && copyfiles -u 4 src/bop-sdk/interface/service/offline/**/* dist/bop-sdk/interface/service/"},"_npmUser":{"name":"zhangbo3","email":"zhangbo3@caict.ac.cn"},"overrides":{"crypto-js":"$crypto-js"},"repository":{"url":"git+https://github.com/caict-4iot-dev/bop-typescript-sdk.git","type":"git"},"_npmVersion":"10.8.2","description":"Xinghuo bop sdk","directories":{},"_nodeVersion":"20.20.2","dependencies":{"ws":"^8.21.0","long":"^5.2.3","sjcl":"^1.0.9","bn.js":"^5.2.3","chalk":"^2.4.2","debug":"^4.1.1","io-ts":"^1.10.4","assert":"^2.1.0","crypto":"^1.0.1","eslint":"^9.5.0","semver":"^6.3.0","js-sha3":"^0.9.3","fs-extra":"^7.0.1","brdc-sjcl":"^1.1.1","crypto-js":"^4.2.0","is-type-of":"^2.1.0","typescript":"~5.0.0","@caict/bs58":"^5.0.0","@types/chai":"^4.2.0","@types/node":"^18.0.0","co-wrap-all":"^1.0.0","json-bigint":"^1.0.0","randombytes":"^2.1.0","@types/mocha":">=9.1.0","@types/sinon":"^9.0.8","bignumber.js":"^9.1.2","merge-descriptors":"^2.0.0","@bufbuild/protobuf":"^2.2.3","@caict/bif-protocol":"^1.0.2","reconnecting-websocket":"^4.4.0","@caict-bif/bif-encryption":"^1.2.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"4.2.0","mocha":"^11.0.1","sinon":"^19.0.2","ts-proto":"^2.6.0","copyfiles":"^2.4.1","chai-as-promised":"^8.0.1"},"_npmOperationalInternal":{"tmp":"tmp/bop-typescript-sdk_1.1.1_1786902660666_0.24743472325575122","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@caict-bif/bop-typescript-sdk","version":"1.1.2","keywords":["caict","bop"],"author":{"name":"maxufeng","email":"maxufeng@caict.ac.cn"},"license":"apache2.0","_id":"@caict-bif/bop-typescript-sdk@1.1.2","maintainers":[{"name":"zhangbo3","email":"zhangbo3@caict.ac.cn"}],"homepage":"https://github.com/caict-4iot-dev/bop-typescript-sdk#readme","bugs":{"url":"https://github.com/caict-4iot-dev/bop-typescript-sdk/issues"},"dist":{"shasum":"95391a9d4be6324e5bce39f9d2da1090df4ea90a","tarball":"https://registry.npmjs.org/@caict-bif/bop-typescript-sdk/-/bop-typescript-sdk-1.1.2.tgz","fileCount":369,"integrity":"sha512-OIEB8t9/rsqq39zFryOpvuwwhoC7ci0vXXaBt3k9xxO6i63ZucI6PMAgyPrsT2y4WV7ujclWvfPutbQzddV+Mg==","signatures":[{"sig":"MEQCID59VQVnJNLVMtTA9w+s38ev/Y1tNJzZwCnn7EdOdKKXAiB0TAEIiZnguXpfz3USo2kmxbux0FP6I4tDXIL5naoRhg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5364948},"main":"dist/index.js","types":"./dist/index.d.ts","engines":{"node":"18.20.4"},"gitHead":"ba0f9ab3565227ef637298a838f98e386dff3e29","scripts":{"lint":"npx prettier --check . && npx eslint .","test":"npm run test:compile && npm run test-bop && npm run test-sdk","build":"npm run test:compile","clean":"rm -rf ./dist","ws-demo":"npm run build && node dist/bop/bop-ws/sample/sample.js","lint:fix":"npx prettier --write . && npx eslint --fix .","test-bop":"npm run test:compile && mocha --recursive \"dist/bop/**/test/**/*.js\" -c --exit --timeout 30000","test-sdk":"npm run test:compile && mocha --recursive \"dist/bop-sdk/**/test/**/*.js\" -c --exit --timeout 30000","test:compile":"tsc --project tsconfig.json && copyfiles -u 4 src/bop-sdk/interface/service/offline/**/* dist/bop-sdk/interface/service/"},"_npmUser":{"name":"zhangbo3","email":"zhangbo3@caict.ac.cn"},"overrides":{"crypto-js":"$crypto-js"},"repository":{"url":"git+https://github.com/caict-4iot-dev/bop-typescript-sdk.git","type":"git"},"_npmVersion":"10.8.2","description":"Xinghuo bop sdk","directories":{},"_nodeVersion":"20.20.2","dependencies":{"ws":"^8.21.0","long":"^5.2.3","sjcl":"^1.0.9","bn.js":"^5.2.3","chalk":"^2.4.2","debug":"^4.1.1","io-ts":"^1.10.4","assert":"^2.1.0","crypto":"^1.0.1","eslint":"^9.5.0","semver":"^6.3.0","js-sha3":"^0.9.3","fs-extra":"^7.0.1","brdc-sjcl":"^1.1.1","crypto-js":"^4.2.0","is-type-of":"^2.1.0","typescript":"~5.0.0","@caict/bs58":"^5.0.0","@types/chai":"^4.2.0","@types/node":"^18.0.0","co-wrap-all":"^1.0.0","json-bigint":"^1.0.0","randombytes":"^2.1.0","@types/mocha":">=9.1.0","@types/sinon":"^9.0.8","bignumber.js":"^9.1.2","merge-descriptors":"^2.0.0","@bufbuild/protobuf":"^2.2.3","@caict/bif-protocol":"^1.0.2","reconnecting-websocket":"^4.4.0","@caict-bif/bif-encryption":"^1.2.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"4.2.0","mocha":"^11.0.1","sinon":"^19.0.2","ts-proto":"^2.6.0","copyfiles":"^2.4.1","chai-as-promised":"^8.0.1"},"_npmOperationalInternal":{"tmp":"tmp/bop-typescript-sdk_1.1.2_1786903351758_0.9662051095136837","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@caict-bif/bop-typescript-sdk","version":"1.2.0","description":"Xinghuo bop sdk","main":"dist/index.js","scripts":{"build":"npm run test:compile","lint":"npx prettier --check . && npx eslint .","lint:fix":"npx prettier --write . && npx eslint --fix .","clean":"rm -rf ./dist","test":"npm run test:compile && npm run test-bop && npm run test-sdk","test:compile":"tsc --project tsconfig.json && copyfiles -u 4 src/bop-sdk/interface/service/offline/**/* dist/bop-sdk/interface/service/","test-bop":"npm run test:compile && mocha --recursive \"dist/bop/**/test/**/*.js\" -c --exit --timeout 30000","test-sdk":"npm run test:compile && mocha --recursive \"dist/bop-sdk/**/test/**/*.js\" -c --exit --timeout 30000","ws-demo":"npm run build && node dist/bop/bop-ws/sample/sample.js"},"keywords":["caict","bop"],"author":{"name":"maxufeng","email":"maxufeng@caict.ac.cn"},"license":"apache2.0","engines":{"node":"18.20.4"},"repository":{"type":"git","url":"git+https://github.com/caict-4iot-dev/bop-typescript-sdk.git"},"bugs":{"url":"https://github.com/caict-4iot-dev/bop-typescript-sdk/issues"},"publishConfig":{"access":"public"},"dependencies":{"@bufbuild/protobuf":"^2.2.3","@caict-bif/bif-encryption":"^1.3.0","@caict/bif-protocol":"^1.0.2","@caict/bs58":"^5.0.0","@types/chai":"^4.2.0","@types/mocha":">=9.1.0","@types/node":"^18.0.0","@types/sinon":"^9.0.8","assert":"^2.1.0","bignumber.js":"^9.1.2","bn.js":"^5.2.3","brdc-sjcl":"^1.1.1","chalk":"^2.4.2","co-wrap-all":"^1.0.0","crypto":"^1.0.1","crypto-js":"^4.2.0","debug":"^4.1.1","eslint":"^9.5.0","fs-extra":"^7.0.1","io-ts":"^1.10.4","is-type-of":"^2.1.0","js-sha3":"^0.9.3","json-bigint":"^1.0.0","long":"^5.2.3","merge-descriptors":"^2.0.0","randombytes":"^2.1.0","reconnecting-websocket":"^4.4.0","semver":"^6.3.0","sjcl":"^1.0.9","typescript":"~5.0.0","ws":"^8.21.0"},"overrides":{"crypto-js":"$crypto-js"},"devDependencies":{"chai":"4.2.0","chai-as-promised":"^8.0.1","copyfiles":"^2.4.1","mocha":"^11.0.1","sinon":"^19.0.2","ts-proto":"^2.6.0"},"_id":"@caict-bif/bop-typescript-sdk@1.2.0","gitHead":"2e8ee03b734d6ee65eee168904b006b6d317ad3d","types":"./dist/index.d.ts","homepage":"https://github.com/caict-4iot-dev/bop-typescript-sdk#readme","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-TrDqrSVLTeU+ND4UBUX6ibIVt7z1RyABqn+09Iq8HWB4TIHBJLWOc3jjvcjwB4NTN2XZs0XXN+CcrIVcLG7e0w==","shasum":"905a30969a51f611080e7d4fa78e0c9052237479","tarball":"https://registry.npmjs.org/@caict-bif/bop-typescript-sdk/-/bop-typescript-sdk-1.2.0.tgz","fileCount":369,"unpackedSize":5382455,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDkrt7VYWcJ9HRM3YPMisfJwnpeq+JH/eXFqiNM0cz/qwIhAMKWKsRc+0rdJlXkne6wBbL9gHbkVC0dWDaCK3t61BAa"}]},"_npmUser":{"name":"zhangbo3","email":"zhangbo3@caict.ac.cn"},"directories":{},"maintainers":[{"name":"zhangbo3","email":"zhangbo3@caict.ac.cn"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bop-typescript-sdk_1.2.0_1786955719495_0.7678740891248572"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-15T15:44:54.201Z","modified":"2026-08-17T08:35:19.905Z","1.1.0":"2026-08-15T15:44:54.635Z","1.1.1":"2026-08-16T17:51:00.866Z","1.1.2":"2026-08-16T18:02:31.967Z","1.2.0":"2026-08-17T08:35:19.652Z"},"bugs":{"url":"https://github.com/caict-4iot-dev/bop-typescript-sdk/issues"},"author":{"name":"maxufeng","email":"maxufeng@caict.ac.cn"},"license":"apache2.0","homepage":"https://github.com/caict-4iot-dev/bop-typescript-sdk#readme","keywords":["caict","bop"],"repository":{"type":"git","url":"git+https://github.com/caict-4iot-dev/bop-typescript-sdk.git"},"description":"Xinghuo bop sdk","maintainers":[{"name":"zhangbo3","email":"zhangbo3@caict.ac.cn"}],"readme":"# bop-typescript-sdk\n\n[bop] sdk to develop with Xinghuo BIF Open Platform\n\n## What\n\nThe current package is primarily designed to implement interfaces for the Xinghuo Open Platform. Up to now, it has already realized two major modules, namely, the [Basic Service API] and the [Message Subscription Service]. Through these modules, direct communication with the Xinghuo Open Platform is feasible. In addition, relevant protocol components are handled using Protocol Buffers (protobuf).\n\n## Installation\n\nFirst, you need to install the sdk by running\n\n```bash\nnpm install @caict-bif/bop-typescript-sdk\n```\n\nAnd add the following statement to your file:\n\n```js\nrequire(\"@caict-bif/bop-typescript-sdk\");\n```\n\nOr, if you are using TypeScript, add this to your file:\n\n```ts\nimport \"@caict-bif/bop-typescript-sdk\";\n```\n\n## Use example\n\n### https service\n\n```ts\nimport {\n  Config,\n  ProviderByBop,\n  BopInterface,\n  SignerByBop,\n} from \"@caict-bif/bop-typescript-sdk\";\n\n(async () => {\n  const apiKey = \"xxx\";\n  const apiSecret = \"xxx\";\n  const config = new Config(\n    \"https://bif-mainnet.bitfactory.cn\",\n    apiKey,\n    apiSecret,\n  );\n  let provider = new ProviderByBop(new BopInterface(config));\n  console.log(await provider.chain.getChainInfo());\n\n  let signer = new SignerByBop(\"your enc private key\");\n  let signerWithProvider = signer.connect(provider);\n  console.log(await signerWithProvider.getAccount());\n})();\n```\n\n### ws service\n\n```ts\nimport {\n  WsProviderByBop,\n  BopWsInterface,\n  WsConfig,\n  bopwsprotocol,\n} from \"@caict-bif/bop-typescript-sdk\";\n\nasync function main() {\n  try {\n    // 创建 BopWsInterface 实例，这里假设已经有 bopWs 实例化代码，可根据实际情况修改\n    const config = new WsConfig(\"ws://bif-mainnet.bitfactory.cn/bif/subscribe\"); // 替换为实际的 WebSocket 地址\n    const bopWs = new BopWsInterface(config.url, config.heartBeatInterval);\n\n    // 标志位，用于判断 BLOCK_HEADER 回调是否已经发生\n    let blockHeaderCallbackTriggered = false;\n\n    const subscriptionBlockHeaderId = await bopWs.bop.subscribe(\n      bopwsprotocol.MessageType.BLOCK_HEADER,\n      (data) => {\n        let message: LedgerHeaderMessage = {};\n        message = LedgerHeaderMessage.fromJSON(data);\n        console.log(\"dealBlockHeader ing...\", message);\n\n        // 设置标志位为 true，表示回调已经发生\n        blockHeaderCallbackTriggered = true;\n      },\n    );\n    console.log(\"Subscription BlockHeader ID:\", subscriptionBlockHeaderId);\n\n    if (subscriptionBlockHeaderId !== \"-1\") {\n      // 等待 BLOCK_HEADER 回调发生\n      await new Promise<void>((resolve) => {\n        const intervalId = setInterval(() => {\n          if (blockHeaderCallbackTriggered) {\n            clearInterval(intervalId);\n            resolve();\n          }\n        }, 100); // 每 100 毫秒检查一次标志位\n      });\n      // 取消订阅\n      await bopWs.bop.unsubscribe(\n        bopwsprotocol.MessageType.BLOCK_HEADER,\n        subscriptionBlockHeaderId,\n      );\n      console.log(\"Unsubscribed from BLOCK_HEADER\");\n    }\n\n    // 断开连接\n    await bopWs.bop.disconnect();\n    console.log(\"Disconnected from WebSocket\");\n  } catch (error) {\n    console.error(\"An error occurred:\", error);\n  }\n}\n\n// 调用 main 函数\nmain();\n```\n","readmeFilename":"README.md"}