{"_id":"@de-openfabtwin/bcf-client","name":"@de-openfabtwin/bcf-client","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@de-openfabtwin/bcf-client","version":"0.1.0","description":"JavaScript client library for BCF REST API 3.0","type":"module","main":"src/BcfClient.js","exports":{".":"./src/BcfClient.js","./auth":"./src/auth/FoundationClient.js","./exception":"./src/BcfException.js"},"keywords":["bcf","bim","ifc","buildingsmart","openapi"],"license":"MIT","dependencies":{"open":"^10.1.0"},"engines":{"node":">=18.0.0"},"gitHead":"05283970a02c4d050648baa49cb275588b526801","_id":"@de-openfabtwin/bcf-client@0.1.0","_nodeVersion":"24.12.0","_npmVersion":"11.7.0","dist":{"integrity":"sha512-gABcT5lceZckqzdmoxsnBb4aCI3Rp8FWEepzxRHOzIHUPie0IOXYrxwLZZLOdFkhFGpgQNeZI7oW5t578WLHPQ==","shasum":"d108df4d8331167864e498c8e93e5b97c1b0525f","tarball":"https://registry.npmjs.org/@de-openfabtwin/bcf-client/-/bcf-client-0.1.0.tgz","fileCount":19,"unpackedSize":50529,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCtg9sOSZgdiTnzhRhUDg/1ZgIX8tAyRKiD5OuBgzLUMgIhAOJKhTSGTrloLoTMq9gL341AUeioJQDoGFk5l8BJgwCP"}]},"_npmUser":{"name":"zaqifathis","email":"zaqifathis@gmail.com"},"directories":{},"maintainers":[{"name":"zaqifathis","email":"zaqifathis@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bcf-client_0.1.0_1774272257983_0.15789130485521952"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-23T13:24:17.930Z","0.1.0":"2026-03-23T13:24:18.148Z","modified":"2026-03-23T13:24:18.364Z"},"maintainers":[{"name":"zaqifathis","email":"zaqifathis@gmail.com"}],"description":"JavaScript client library for BCF REST API 3.0","keywords":["bcf","bim","ifc","buildingsmart","openapi"],"license":"MIT","readme":"# bcf-client-js\r\n\r\nA JavaScript client library for the **BCF REST API 3.0** (BIM Collaboration Format).  \r\nImplements the full [buildingSMART BCF API spec](https://github.com/buildingSMART/BCF-API) — authentication, projects, topics, comments, viewpoints, documents, and more.\r\n\r\n---\r\n\r\n## Requirements\r\n\r\n- Node.js >= 18.0.0\r\n- ES Modules (`\"type\": \"module\"` in your `package.json`)\r\n- A running BCF server that supports `authorization_code_grant`\r\n\r\n---\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @de-openfabtwin/bcf-client\r\n```\r\n\r\n---\r\n\r\n## Quick Start\r\n\r\n```js\r\nimport { FoundationClient } from '@openfabtwin-bim/bcf-client/auth';\r\nimport { BcfClient }        from '@openfabtwin-bim/bcf-client';\r\n\r\n// 1. Create the auth client\r\nconst foundation = new FoundationClient(\r\n  'https://your-bcf-server.example.com/',\r\n  'your-client-id',\r\n  'your-client-secret'\r\n);\r\n\r\n// 2. Create the BCF client and resolve the API version\r\nconst bcf = new BcfClient(foundation, '3.0');\r\nawait bcf.resolveVersion(); // triggers browser login on first use\r\n\r\n// 3. Use the sub-clients\r\nconst projects = await bcf.project.getAllProjects();\r\nconsole.log(projects);\r\n```\r\n\r\n> `resolveVersion()` must be called **once** before using any sub-client.  \r\n> It discovers the server's BCF base URL, triggers OAuth login if needed, and wires all clients.\r\n\r\n---\r\n\r\n## Architecture\r\n\r\n```\r\nBcfClient\r\n├── FoundationClient      ← OAuth 2.0 auth (authorization_code_grant)\r\n│   └── OAuthReceiver     ← Temporary localhost:8081 server to catch OAuth redirect\r\n├── BcfHttpClient         ← Thin HTTP layer (GET, POST, PUT, DELETE, binary)\r\n└── Sub-clients (wired after resolveVersion())\r\n    ├── project           → ProjectClient\r\n    ├── topic             → TopicClient\r\n    ├── comment           → CommentClient\r\n    ├── viewpoint         → ViewpointClient\r\n    ├── document          → DocumentClient\r\n    ├── documentReference → DocumentReferenceClient\r\n    ├── event             → EventClient\r\n    ├── file              → FileClient\r\n    ├── relatedTopic      → RelatedTopicClient\r\n    └── snippet           → SnippetClient\r\n```\r\n\r\n---\r\n\r\n## Authentication\r\n\r\nAuthentication is handled by `FoundationClient`. It implements the BCF Foundation API auth flow:\r\n\r\n1. `GET /foundation/1.1/auth` — discovers OAuth endpoints\r\n2. Opens browser for login (`authorization_code_grant`)\r\n3. Catches the redirect code via a temporary local server on `localhost:8081`\r\n4. Exchanges code for access + refresh tokens\r\n5. Auto-refreshes tokens on expiry — transparent to callers\r\n\r\n```js\r\nconst foundation = new FoundationClient(baseUrl, clientId, clientSecret);\r\nconst token = await foundation.getAccessToken(); // login triggered automatically\r\n```\r\n\r\n---\r\n\r\n## Project Structure\r\n\r\n```\r\nsrc/\r\n├── BcfClient.js              ← Main entry point\r\n├── BcfHttpClient.js          ← HTTP layer (JSON + binary)\r\n├── BcfException.js           ← Error class\r\n├── queryBuilder.js           ← OData query string builder ($filter, $orderby, etc.)\r\n├── auth/\r\n│   ├── FoundationClient.js   ← OAuth 2.0 auth flow\r\n│   └── OauthReceiver.js      ← Local redirect server (localhost:8081)\r\n└── client/\r\n    ├── ProjectClient.js\r\n    ├── TopicClient.js\r\n    ├── CommentClient.js\r\n    ├── ViewpointClient.js\r\n    ├── DocumentClient.js\r\n    ├── DocumentReferenceClient.js\r\n    ├── EventClient.js\r\n    ├── FileClient.js\r\n    ├── RelatedTopicClient.js\r\n    └── SnippetClient.js\r\n```\r\n\r\n---\r\n\r\n## License\r\nMIT\r\n\r\n\r\n## Acknowledgment\r\nThis work is funded by the German Federal Ministry for Economic Affairs and Climate Action\r\n(BMWK) through the central innovation programme for small and medium-sized enterprises\r\n(ZIM-program), with funding provided under grant number 16KN106902.\r\n","readmeFilename":"README.md","_rev":"1-e72563292c52162055ff251427ef7703"}