{"id":21322029,"url":"https://github.com/opentdf/web-sdk","last_synced_at":"2026-04-21T00:01:24.784Z","repository":{"id":237811422,"uuid":"421565299","full_name":"opentdf/web-sdk","owner":"opentdf","description":"OpenTDF JavaScript SDK","archived":false,"fork":false,"pushed_at":"2026-04-18T00:57:59.000Z","size":20365,"stargazers_count":9,"open_issues_count":54,"forks_count":4,"subscribers_count":15,"default_branch":"main","last_synced_at":"2026-04-18T02:41:28.102Z","etag":null,"topics":["data-encryption","data-tagging","drm","end-to-end-encryption","file-encryption","open-source","opensource","opentdf","tdf","webclient","zero-trust","zero-trust-security"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause-clear","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opentdf.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2021-10-26T19:53:47.000Z","updated_at":"2026-04-14T15:06:35.000Z","dependencies_parsed_at":"2024-05-29T16:11:15.765Z","dependency_job_id":"4d6be718-0639-4dee-9bb3-a9b34465b9ba","html_url":"https://github.com/opentdf/web-sdk","commit_stats":{"total_commits":249,"total_committers":21,"mean_commits":"11.857142857142858","dds":0.5020080321285141,"last_synced_commit":"2fe2c43ee3c481f6f40eba11a50e0ab8155ea024"},"previous_names":["opentdf/client-web","opentdf/web-sdk"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/opentdf/web-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentdf%2Fweb-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentdf%2Fweb-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentdf%2Fweb-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentdf%2Fweb-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opentdf","download_url":"https://codeload.github.com/opentdf/web-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentdf%2Fweb-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32071013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T21:26:33.338Z","status":"ssl_error","status_checked_at":"2026-04-20T21:26:22.081Z","response_time":94,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["data-encryption","data-tagging","drm","end-to-end-encryption","file-encryption","open-source","opensource","opentdf","tdf","webclient","zero-trust","zero-trust-security"],"created_at":"2024-11-21T20:12:50.485Z","updated_at":"2026-04-21T00:01:24.730Z","avatar_url":"https://github.com/opentdf.png","language":"TypeScript","readme":"# OpenTDF Web Browser Client opentdf\n\nThis project is focused on providing web client support for the OpenTDF platform.\nThis includes encrypting and decrypting TDF content,\nand some management tasks for ABAC.\n\n**[OpenTDF Web Documentation](https://opentdf.github.io/web-sdk/)**\n\n## Usage\n\n### With Interceptors (Recommended)\n\nUse interceptors to provide authentication. The SDK does not manage tokens — you bring your own auth.\n\n```typescript\nimport { authTokenInterceptor, OpenTDF } from '@opentdf/sdk';\n\n// Implementation varies by identity provider (e.g. Auth0, Keycloak, oidc-client-ts)\nasync function getAccessToken(): Promise\u003cstring\u003e {\n  return 'my-access-token';\n}\n\nconst client = new OpenTDF({\n  interceptors: [authTokenInterceptor(getAccessToken)],\n  platformUrl: 'https://platform.example.com',\n});\n\n// Encrypt\nconst cipherText = await client.createTDF({\n  source: { type: 'stream', location: plainTextStream },\n  autoconfigure: false,\n  defaultKASEndpoint: 'https://platform.example.com/kas',\n});\n\n// Decrypt\nconst reader = client.open({ source: { type: 'stream', location: cipherText } });\nconst clearText = await reader.decrypt();\n```\n\nThe `authTokenInterceptor` takes a function that returns an access token. Your auth library handles token refresh, caching, etc.\n\nFor DPoP-bound tokens, use `authTokenDPoPInterceptor`:\n\n```typescript\nimport { authTokenDPoPInterceptor, OpenTDF } from '@opentdf/sdk';\n\nconst dpopInterceptor = authTokenDPoPInterceptor({\n  tokenProvider: getAccessToken,\n});\n\nconst client = new OpenTDF({\n  interceptors: [dpopInterceptor],\n  dpopKeys: dpopInterceptor.dpopKeys,\n  platformUrl: 'https://platform.example.com',\n});\n```\n\nYou can also write your own interceptor for full control over request headers:\n\n```typescript\nimport { type Interceptor, OpenTDF } from '@opentdf/sdk';\n\nconst myInterceptor: Interceptor = (next) =\u003e async (req) =\u003e {\n  req.header.set('Authorization', `Bearer ${await getToken()}`);\n  req.header.set('X-Custom-Header', 'value');\n  return next(req);\n};\n\nconst client = new OpenTDF({\n  interceptors: [myInterceptor],\n  platformUrl: 'https://platform.example.com',\n});\n```\n\n### With AuthProvider (Deprecated)\n\nThe `AuthProvider` pattern is still supported for backwards compatibility but is deprecated since 0.14.0.\n\n```typescript\nimport { AuthProviders, OpenTDF } from '@opentdf/sdk';\n\nconst authProvider = await AuthProviders.refreshAuthProvider({\n  clientId: 'applicationNameFromIdP',\n  exchange: 'refresh',\n  refreshToken: 'refreshTokenValueFromIdP',\n  oidcOrigin: 'http://localhost:65432/auth/realms/opentdf',\n});\n\nconst client = new OpenTDF({\n  authProvider,\n  platformUrl: 'https://platform.example.com',\n  defaultCreateOptions: {\n    defaultKASEndpoint: 'http://localhost:65432/kas',\n  },\n});\n```\n\nYou can bridge an existing `AuthProvider` to the interceptor pattern using `authProviderInterceptor`:\n\n```typescript\nimport { AuthProviders, authProviderInterceptor, OpenTDF } from '@opentdf/sdk';\n\nconst authProvider = await AuthProviders.clientSecretAuthProvider({\n  clientId: 'myClient',\n  clientSecret: 'mySecret',\n  oidcOrigin: 'http://localhost:65432/auth/realms/opentdf',\n  exchange: 'client',\n});\n\nconst client = new OpenTDF({\n  interceptors: [authProviderInterceptor(authProvider)],\n  platformUrl: 'https://platform.example.com',\n});\n```\n\n## Platform Client\n\nThe Platform Client provides an interface to interact with the OpenTDF platform's RPC services.\n\n```typescript\nimport { authTokenInterceptor } from '@opentdf/sdk';\nimport { PlatformClient } from '@opentdf/sdk/platform';\n\nconst platform = new PlatformClient({\n  interceptors: [authTokenInterceptor(getAccessToken)],\n  platformUrl: 'https://platform.example.com',\n});\n\n// Fetch well-known configuration\nconst wellKnownResponse = await platform.v1.wellknown.getWellKnownConfiguration({});\nconsole.log('Well-known configuration:', wellKnownResponse.configuration);\n\n// List policy attributes\nconst attributesResponse = await platform.v1.attributes.listAttributes({});\nconsole.log('Policy Attributes:', attributesResponse.attributes);\n```\n\n\n## Building and Testing\n\n### Makefile Commands\n\nThe project provides a `Makefile` to simplify common development tasks. Below are the available commands:\n\n| Command           | Description                                                                                  |\n|-------------------|----------------------------------------------------------------------------------------------|\n| `make`            | Builds and tests everything (default target).                                                |\n| `make start`      | Builds all packages and starts the web application in development mode.                      |\n| `make ci`         | Installs dependencies and links the SDK package for all subprojects.                         |\n| `make i`          | Installs dependencies and links the SDK package for all subprojects (without clean install). |\n| `make clean`      | Removes build artifacts, packed files, and `node_modules` directories.                       |\n| `make cli`        | Builds and packs the CLI tool.                                                               |\n| `make audit`      | Runs `npm audit` for all packages except dev dependencies.                                   |\n| `make format`     | Runs code formatting for all packages.                                                       |\n| `make lint`       | Runs linter for all packages.                                                                |\n| `make test`       | Runs tests for all packages.                                                                 |\n| `make license-check` | Checks license compliance for all packages.                                               |\n| `make doc`        | Generates documentation for the SDK.                                                         |\n| `make generate-platform` | Runs the platform code generation script.                                             |\n| `make dist`       | Copies the SDK package to the root directory.                                                |\n\nYou can run any of these commands using `make \u003ccommand\u003e`.\n\n\n## Contribute\n\n### Prerequisites\n\nDeveloping with this code requires a recent version of `npm` and `node`.\nWe develop using [nvm](https://github.com/nvm-sh/nvm#readme),\nwhich allows us to pin to the same version of `npm` easily.\n\n- Install [nvm](https://github.com/nvm-sh/nvm#readme)\n  - see \u003chttps://github.com/nvm-sh/nvm#installing-and-updating\u003e\n  - `nvm use` will install `npm` and `node`\n\n[![Build](https://github.com/opentdf/web-sdk/actions/workflows/build.yaml/badge.svg)](https://github.com/opentdf/web-sdk/actions/workflows/build.yaml)\n\nTo check out, build, and validate your installation, and test the sample web application, you may:\n\n```sh\nnvm use\nmake test\nmake start\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentdf%2Fweb-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopentdf%2Fweb-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentdf%2Fweb-sdk/lists"}