{"_id":"@caict/bop-typescript-sdk","_rev":"4-a192cff0b3330596bbe723c03cd94598","name":"@caict/bop-typescript-sdk","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@caict/bop-typescript-sdk","version":"1.0.0","keywords":["caict","bop"],"author":{"name":"maxufeng","email":"maxufeng@caict.ac.cn"},"license":"apache2.0","_id":"@caict/bop-typescript-sdk@1.0.0","maintainers":[{"name":"caict","email":"949552983@qq.com"}],"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":"19396b4e0cb4d2d3e454510eaa7e88831f100d0c","tarball":"https://registry.npmjs.org/@caict/bop-typescript-sdk/-/bop-typescript-sdk-1.0.0.tgz","fileCount":115,"integrity":"sha512-/MGDn5js17p1M4bkhUVyA3kx9nat5J3l7QFkh1zrIMlLMkHY/0Q8bjUjtxC0VawW95CwOmKfPIWURYbErEE6yg==","signatures":[{"sig":"MEUCIQD0D/B7Mek7re1fO2NLAN3pY5lujqWkMON3rB/S6cdkwwIgfw8tMQ73og7JJm4edxshMeQJL6ZtokEIQJGHiAFuPSA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1995735},"main":"dist/index.js","engines":{"node":"18.20.4"},"gitHead":"34597b36e106e3cdb7114953d3c5be2acc194a5a","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":"caict","email":"949552983@qq.com"},"repository":{"url":"git+https://github.com/caict-4iot-dev/bop-typescript-sdk.git","type":"git"},"_npmVersion":"6.14.16","description":"Xinghuo bop sdk","directories":{},"_nodeVersion":"14.19.1","dependencies":{"ws":"^8.18.0","long":"^5.2.3","sjcl":"^1.0.8","bn.js":"^5.2.1","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","lodash":"^4.17.11","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","@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","request-promise":"^4.2.6","@bifproject/bs58":"^5.0.0","merge-descriptors":"^2.0.0","@bufbuild/protobuf":"^2.2.3","@caict/bif-protocol":"^1.0.2","@caict/bif-encryption":"^1.0.1","reconnecting-websocket":"^4.4.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"4.2.0","mocha":"^11.0.1","sinon":"^19.0.2","ts-node":"^10.9.2","ts-proto":"^2.6.0","copyfiles":"^2.4.1","chai-as-promised":"^8.0.1","mocha-typescript":"^1.1.17"},"_npmOperationalInternal":{"tmp":"tmp/bop-typescript-sdk_1.0.0_1741760706970_0.9654755116852514","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@caict/bop-typescript-sdk","version":"1.0.1","keywords":["caict","bop"],"author":{"name":"maxufeng","email":"maxufeng@caict.ac.cn"},"license":"apache2.0","_id":"@caict/bop-typescript-sdk@1.0.1","maintainers":[{"name":"caict","email":"949552983@qq.com"}],"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":"93d5e8a24587e585d31c4452623fada9d42bb964","tarball":"https://registry.npmjs.org/@caict/bop-typescript-sdk/-/bop-typescript-sdk-1.0.1.tgz","fileCount":115,"integrity":"sha512-c+mG4NbbrhPPKgLyfc7b+m4fEaPllN30T2mQmH7E+o+2YI+nCfUd0I2+Wt3posB45yOFo1UWSxZDUACmYeGabg==","signatures":[{"sig":"MEUCICLMHOhcyLrGIiyoM4t6EQBj9hV9NLqs1mFRH61eSaM/AiEAu+3KU0tI8W3g4BxUg3P4oo1LJVsa4GWUB33wg4RRnZQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1995681},"main":"dist/index.js","engines":{"node":"18.20.4"},"gitHead":"fa79bba5445298504d91669a3dfb3753f0e61e93","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":"caict","email":"949552983@qq.com"},"repository":{"url":"git+https://github.com/caict-4iot-dev/bop-typescript-sdk.git","type":"git"},"_npmVersion":"6.14.16","description":"Xinghuo bop sdk","directories":{},"_nodeVersion":"14.19.1","dependencies":{"ws":"^8.18.0","long":"^5.2.3","sjcl":"^1.0.8","bn.js":"^5.2.1","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","lodash":"^4.17.11","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","@caict/bif-encryption":"^1.0.1","reconnecting-websocket":"^4.4.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"4.2.0","mocha":"^11.0.1","sinon":"^19.0.2","ts-node":"^10.9.2","ts-proto":"^2.6.0","copyfiles":"^2.4.1","chai-as-promised":"^8.0.1","mocha-typescript":"^1.1.17"},"_npmOperationalInternal":{"tmp":"tmp/bop-typescript-sdk_1.0.1_1741762815756_0.5543071024500195","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@caict/bop-typescript-sdk","version":"1.0.2","keywords":["caict","bop"],"author":{"name":"maxufeng","email":"maxufeng@caict.ac.cn"},"license":"apache2.0","_id":"@caict/bop-typescript-sdk@1.0.2","maintainers":[{"name":"caict","email":"949552983@qq.com"}],"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":"2da94b0bbf018eef35fbb517b6876e6c419383bb","tarball":"https://registry.npmjs.org/@caict/bop-typescript-sdk/-/bop-typescript-sdk-1.0.2.tgz","fileCount":113,"integrity":"sha512-f3rvM+2bbq9lZxvNlJKMhpbPTjetBIx9/LyhUvT5VYAaG52WhpaE86TTpqJkXcP79aUZtSviHfmOUtUOezOv2g==","signatures":[{"sig":"MEQCICM0o6yLGcAwvgRpWxg4xP26KsIaXNA6XFQWjth79rOQAiBbpDRFdpz2YkRDVZBMPqRZxEdZDv3f93MBataQsJ8HGg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1995475},"main":"dist/index.js","engines":{"node":"18.20.4"},"gitHead":"e01cc2894e64672241a4ed45e3088b5c8f657590","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":"caict","email":"949552983@qq.com"},"repository":{"url":"git+https://github.com/caict-4iot-dev/bop-typescript-sdk.git","type":"git"},"_npmVersion":"10.9.2","description":"Xinghuo bop sdk","directories":{},"_nodeVersion":"18.17.0","dependencies":{"ws":"^8.18.0","long":"^5.2.3","sjcl":"^1.0.8","bn.js":"^5.2.1","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","lodash":"^4.17.11","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","@caict/bif-encryption":"^1.0.1","reconnecting-websocket":"^4.4.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"4.2.0","mocha":"^11.0.1","sinon":"^19.0.2","ts-node":"^10.9.2","ts-proto":"^2.6.0","copyfiles":"^2.4.1","chai-as-promised":"^8.0.1","mocha-typescript":"^1.1.17"},"_npmOperationalInternal":{"tmp":"tmp/bop-typescript-sdk_1.0.2_1744618016492_0.7491476175327672","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@caict/bop-typescript-sdk","version":"1.0.3","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":"guoshijie","email":"guoshijie@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":{"@caict/bop-typescript-sdk":"^1.0.3","@caict/bs58":"^5.0.0","@bufbuild/protobuf":"^2.2.3","@caict/bif-encryption":"^1.0.1","@caict/bif-protocol":"^1.0.2","@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.1","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","lodash":"^4.17.11","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.8","typescript":"~5.0.0","ws":"^8.18.0"},"devDependencies":{"chai":"4.2.0","chai-as-promised":"^8.0.1","copyfiles":"^2.4.1","mocha":"^11.0.1","mocha-typescript":"^1.1.17","sinon":"^19.0.2","ts-node":"^10.9.2","ts-proto":"^2.6.0"},"_id":"@caict/bop-typescript-sdk@1.0.3","gitHead":"e01cc2894e64672241a4ed45e3088b5c8f657590","types":"./dist/index.d.ts","homepage":"https://github.com/caict-4iot-dev/bop-typescript-sdk#readme","_nodeVersion":"18.20.4","_npmVersion":"10.7.0","dist":{"integrity":"sha512-DLXkoXnb35cF3gEY3saGbz/wrN0cakno/ifLrY6jhnoukTBoiPK/Dv9SL5ZxS54xxTiFb5z+2ZFgl2/1+AvOOw==","shasum":"1d9026a2758f637b1cbc37f92e31013c4c1299c9","tarball":"https://registry.npmjs.org/@caict/bop-typescript-sdk/-/bop-typescript-sdk-1.0.3.tgz","fileCount":368,"unpackedSize":5365289,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBMuS7h9fUhKCpnNWrAbLmpDgSaherRKmVNdfd4EsvmMAiEA3sBkxxYS/9VjpNKw49XPsMmibwBtQ/3NWV0TwwL2rZ8="}]},"_npmUser":{"name":"caict","email":"949552983@qq.com"},"directories":{},"maintainers":[{"name":"caict","email":"949552983@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bop-typescript-sdk_1.0.3_1780984313838_0.07703468101671196"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-12T06:25:06.872Z","modified":"2026-06-09T05:51:54.245Z","1.0.0":"2025-03-12T06:25:07.261Z","1.0.1":"2025-03-12T07:00:16.023Z","1.0.2":"2025-04-14T08:06:56.896Z","1.0.3":"2026-06-09T05:51:54.143Z"},"bugs":{"url":"https://github.com/caict-4iot-dev/bop-typescript-sdk/issues"},"author":{"name":"guoshijie","email":"guoshijie@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":"caict","email":"949552983@qq.com"}],"readme":"# bop-typescript-sdk\r\n\r\n[bop] sdk to develop with Xinghuo BIF Open Platform\r\n\r\n## What\r\n\r\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).\r\n\r\n## Installation\r\n\r\nFirst, you need to install the sdk by running\r\n\r\n```bash\r\nnpm install @caict/bop-typescript-sdk\r\n```\r\n\r\nAnd add the following statement to your file:\r\n\r\n```js\r\nrequire(\"@caict/bop-typescript-sdk\");\r\n```\r\n\r\nOr, if you are using TypeScript, add this to your file:\r\n\r\n```ts\r\nimport \"@caict/bop-typescript-sdk\";\r\n```\r\n\r\n## Use example\r\n\r\n### https service\r\n\r\n```ts\r\nimport {\r\n  Config,\r\n  ProviderByBop,\r\n  BopInterface,\r\n  SignerByBop,\r\n} from \"@caict/bop-typescript-sdk\";\r\n\r\n(async () => {\r\n  const apiKey = \"xxx\";\r\n  const apiSecret = \"xxx\";\r\n  const config = new Config(\r\n    \"https://bif-mainnet.bitfactory.cn\",\r\n    apiKey,\r\n    apiSecret,\r\n  );\r\n  let provider = new ProviderByBop(new BopInterface(config));\r\n  console.log(await provider.chain.getChainInfo());\r\n\r\n  let signer = new SignerByBop(\"your enc private key\");\r\n  let signerWithProvider = signer.connect(provider);\r\n  console.log(await signerWithProvider.getAccount());\r\n})();\r\n```\r\n\r\n### ws service\r\n\r\n```ts\r\nimport {\r\n  WsProviderByBop,\r\n  BopWsInterface,\r\n  WsConfig,\r\n  bopwsprotocol,\r\n} from \"@caict/bop-typescript-sdk\";\r\n\r\nasync function main() {\r\n  try {\r\n    // 创建 BopWsInterface 实例，这里假设已经有 bopWs 实例化代码，可根据实际情况修改\r\n    const config = new WsConfig(\"ws://bif-mainnet.bitfactory.cn/bif/subscribe\"); // 替换为实际的 WebSocket 地址\r\n    const bopWs = new BopWsInterface(config.url, config.heartBeatInterval);\r\n\r\n    // 标志位，用于判断 BLOCK_HEADER 回调是否已经发生\r\n    let blockHeaderCallbackTriggered = false;\r\n\r\n    const subscriptionBlockHeaderId = await bopWs.bop.subscribe(\r\n      bopwsprotocol.MessageType.BLOCK_HEADER,\r\n      (data) => {\r\n        let message: LedgerHeaderMessage = {};\r\n        message = LedgerHeaderMessage.fromJSON(data);\r\n        console.log(\"dealBlockHeader ing...\", message);\r\n\r\n        // 设置标志位为 true，表示回调已经发生\r\n        blockHeaderCallbackTriggered = true;\r\n      },\r\n    );\r\n    console.log(\"Subscription BlockHeader ID:\", subscriptionBlockHeaderId);\r\n\r\n    if (subscriptionBlockHeaderId !== \"-1\") {\r\n      // 等待 BLOCK_HEADER 回调发生\r\n      await new Promise<void>((resolve) => {\r\n        const intervalId = setInterval(() => {\r\n          if (blockHeaderCallbackTriggered) {\r\n            clearInterval(intervalId);\r\n            resolve();\r\n          }\r\n        }, 100); // 每 100 毫秒检查一次标志位\r\n      });\r\n      // 取消订阅\r\n      await bopWs.bop.unsubscribe(\r\n        bopwsprotocol.MessageType.BLOCK_HEADER,\r\n        subscriptionBlockHeaderId,\r\n      );\r\n      console.log(\"Unsubscribed from BLOCK_HEADER\");\r\n    }\r\n\r\n    // 断开连接\r\n    await bopWs.bop.disconnect();\r\n    console.log(\"Disconnected from WebSocket\");\r\n  } catch (error) {\r\n    console.error(\"An error occurred:\", error);\r\n  }\r\n}\r\n\r\n// 调用 main 函数\r\nmain();\r\n```\r\n","readmeFilename":"README.md"}