{"id":13520956,"url":"https://github.com/authzed/authzed-node","last_synced_at":"2025-04-12T22:39:29.286Z","repository":{"id":37045433,"uuid":"342727822","full_name":"authzed/authzed-node","owner":"authzed","description":"Official SpiceDB client library for NodeJS","archived":false,"fork":false,"pushed_at":"2025-04-09T19:57:10.000Z","size":1147,"stargazers_count":54,"open_issues_count":28,"forks_count":20,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-12T22:39:21.750Z","etag":null,"topics":["authorization","authzed","authzed-client","fine-grained-access-control","fine-grained-authorization","javascript","node","nodejs","permissions","sdk","spicedb","spicedb-client","typescript","zanzibar"],"latest_commit_sha":null,"homepage":"https://authzed.com/docs/reference/api","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/authzed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-26T23:36:43.000Z","updated_at":"2025-04-08T13:45:42.000Z","dependencies_parsed_at":"2024-06-29T06:37:05.465Z","dependency_job_id":"9faa45c6-5472-4fe5-ae59-b84aca7e8061","html_url":"https://github.com/authzed/authzed-node","commit_stats":{"total_commits":173,"total_committers":18,"mean_commits":9.61111111111111,"dds":0.7976878612716762,"last_synced_commit":"acc4c7c67ffdfcab7754c6eb053c1f8196304044"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/authzed%2Fauthzed-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/authzed%2Fauthzed-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/authzed%2Fauthzed-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/authzed%2Fauthzed-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/authzed","download_url":"https://codeload.github.com/authzed/authzed-node/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248643044,"owners_count":21138353,"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","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":["authorization","authzed","authzed-client","fine-grained-access-control","fine-grained-authorization","javascript","node","nodejs","permissions","sdk","spicedb","spicedb-client","typescript","zanzibar"],"created_at":"2024-08-01T06:00:25.024Z","updated_at":"2025-04-12T22:39:29.265Z","avatar_url":"https://github.com/authzed.png","language":"TypeScript","funding_links":[],"categories":["Clients","TypeScript"],"sub_categories":["Official Libraries"],"readme":"# Authzed NodeJS Client\n\n[![npm version](https://img.shields.io/npm/v/@authzed/authzed-node.svg?style=flat)](https://www.npmjs.com/package/@authzed/authzed-node)\n[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)\n[![Build Status](https://github.com/authzed/authzed-node/workflows/authzed-node-ci/badge.svg)](https://github.com/authzed/authzed-node/actions)\n[![Mailing List](https://img.shields.io/badge/email-google%20groups-4285F4)](https://groups.google.com/g/authzed-oss)\n[![Discord Server](https://img.shields.io/discord/844600078504951838?color=7289da\u0026logo=discord \"Discord Server\")](https://discord.gg/jTysUaxXzM)\n[![Twitter](https://img.shields.io/twitter/follow/authzed?color=%23179CF0\u0026logo=twitter\u0026style=flat-square)](https://twitter.com/authzed)\n\nThis repository houses the NodeJS client library for Authzed.\n\n[Authzed] is a database and service that stores, computes, and validates your application's permissions.\n\nDevelopers create a schema that models their permissions requirements and use a client library, such as this one, to apply the schema to the database, insert data into the database, and query the data to efficiently check permissions in their applications.\n\nSupported client API versions:\n\n- [v1](https://docs.authzed.com/reference/api#authzedapiv1)\n\nYou can find more info on each API on the [Authzed API reference documentation].\nAdditionally, Protobuf API documentation can be found on the [Buf Registry Authzed API repository].\n\nSee [CONTRIBUTING.md] for instructions on how to contribute and perform common tasks like building the project and running tests.\n\n[Authzed]: https://authzed.com\n[Authzed API Reference documentation]: https://docs.authzed.com/reference/api\n[Buf Registry Authzed API repository]: https://buf.build/authzed/api/docs/main\n[CONTRIBUTING.md]: CONTRIBUTING.md\n\n## Getting Started\n\nWe highly recommend following the **[Protecting Your First App]** guide to learn the latest best practice to integrate an application with Authzed.\n\nIf you're interested in examples of a specific version of the API, they can be found in their respective folders in the [examples directory].\n\n[Protecting Your First App]: https://docs.authzed.com/guides/first-app\n[examples directory]: /examples\n\n## Basic Usage\n\n### Installation\n\nThe project is packaged and distributed via [NPM].\n\nIf you are using the typical npm toolchain, the command to install the library is:\n\n```sh\nnpm i @authzed/authzed-node\n```\n\n[NPM]: https://www.npmjs.com/package/@authzed/authzed-node\n\n### Initializing a client\n\nEverything required to connect and make API calls is located in a module respective to API version.\n\nYou will have to provide a your own API Token from the [Authzed dashboard] in place of `t_your_token_here_1234567deadbeef` in the following example:\n\n```js\nimport { v1 } from '@authzed/authzed-node';\n// if your endpoint is localhost\n// const client = v1.NewClient('t_your_token_here_1234567deadbeef', 'localhost:50051', ClientSecurity.INSECURE_LOCALHOST_ALLOWED);\nconst client = v1.NewClient('t_your_token_here_1234567deadbeef');\n```\n\nOr to use a custom certificate authority, load the CA certificate and pass the file reference to `NewClientWithCustomCert`.\n```js\nimport { v1 } from '@authzed/authzed-node';\nimport fs from 'fs';\n\nconst endpoint = 'localhost:50051';\nconst cert = fs.readFileSync('path/to/cert.pem');\nconst client = v1.NewClientWithCustomCert('t_your_token_here_1234567deadbeef', endpoint, cert);\n```\n\n### Performing an API call\n\nBecause of the verbosity of these types, we recommend writing your own functions/methods to create these types from your existing application's models.\n\nThe `create` method on generated classes takes attributes as input and defaults unspecified attributes to their empty value. This allows you to create request messages, for example, by specifying only relevant fields and leaves optional fields empty.\n\n```js\nimport { v1 } from '@authzed/authzed-node';\n\nconst client = v1.NewClient('token')\n\n// Create the relationship between the resource and the user.\nconst firstPost = v1.ObjectReference.create({\n    objectType: \"blog/post\",\n    objectId: \"1\",\n});\n\n// Create the user reference.\nconst emilia = v1.ObjectReference.create({\n    objectType: \"blog/user\",\n    objectId: \"emilia\",\n});\n\n// Create the subject reference using the user reference\nconst subject = v1.SubjectReference.create({\n    object: emilia,\n});\n\nconst checkPermissionRequest = v1.CheckPermissionRequest.create({\n    resource: firstPost,\n    permission: \"read\",\n    subject,\n});\n\nclient.checkPermission(checkPermissionRequest, (err, response) =\u003e {\n    console.log(response);\n    console.log(err);\n});\n```\n\n### Promises (async/await) support\n\nEach method available in the client has an associated promise-style method in place of callbacks, that can be accessed at the `.promises` property on the client.\n\n```js\nimport { v1 } from '@authzed/authzed-node';\n\nconst client = v1.NewClient('token');\nconst { promises: promiseClient } = client; // access client.promises\n\nconst checkPermissionRequest = /** from above **/;\n\nconst result = await promiseClient.checkPermission(checkPermissionRequest);\n```\n\nFor stream-returning methods, including `client.readRelationships()`, `client.lookupResources()` and `client.lookupSubjects()`, the promise-style method will result in an array of response objects once the stream has been closed.\n\n```js\nimport { v1 } from '@authzed/authzed-node';\n\nconst client = v1.NewClient('token');\nconst { promises: promiseClient } = client; // access client.promises\n\nconst results = await promiseClient.readRelationships(/** req **/);\nconsole.log(results[0]); // first ReadRelationship result\n```\n\n## Requirements\n\nSupported Node.js versions: 18, 20, 22\n\nMinimum TypeScript version 3.8\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauthzed%2Fauthzed-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauthzed%2Fauthzed-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauthzed%2Fauthzed-node/lists"}