Skip to content

Commit 6201339

Browse files
committed
chore: DSPX-1665 add link to docs
1 parent 06ef9ce commit 6201339

File tree

1 file changed

+52
-45
lines changed

1 file changed

+52
-45
lines changed

README.md

Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
# OpenTDF Web Browser Client opentdf
22

3-
This project is focused on providing web client support for the OpenTDF platform.
4-
This includes encrypting and decrypting TDF content,
5-
and some management tasks for ABAC.
3+
This project is focused on providing web client support for the OpenTDF platform. This includes
4+
encrypting and decrypting TDF content, and management tasks for ABAC.
5+
6+
**[OpenTDF Web Documentation](https://opentdf.github.io/web-sdk/)**
67

78
## Usage (NanoTDF)
89

910
```typescript
1011
import { AuthProviders, NanoTDFClient } from '@opentdf/sdk';
1112

1213
// Configuration Options
13-
const kasEndpoint = "http://localhost:65432/kas";
14+
const kasEndpoint = 'http://localhost:65432/kas';
1415

1516
// Authentication options (vary by middleware)
16-
const oidcOrigin = "http://localhost:65432/auth/realms/opentdf";
17-
const clientId = "applicationNameFromIdP";
18-
const refreshToken = "refreshTokenValueFromIdP";
17+
const oidcOrigin = 'http://localhost:65432/auth/realms/opentdf';
18+
const clientId = 'applicationNameFromIdP';
19+
const refreshToken = 'refreshTokenValueFromIdP';
1920

2021
// AuthProviders are middlewares that add `Authorization` or other bearer tokens to requests.
2122
// These include The `refresh` provider can be handed a refresh and optional access token.
@@ -30,7 +31,7 @@ const client = new NanoTDFClient({
3031
authProvider,
3132
kasEndpoint,
3233
});
33-
client.dataAttributes = ["http://opentdf.io/attr/class/value/secret"]
34+
client.dataAttributes = ['http://opentdf.io/attr/class/value/secret'];
3435
const cipherText = await client.encrypt(plainText);
3536
const clearText = await client.decrypt(cipherText);
3637
```
@@ -39,16 +40,16 @@ const clearText = await client.decrypt(cipherText);
3940

4041
#### Client Credentials
4142

42-
For long running server-side apps, a client id + secret is allowed with OAuth2.
43-
This should not be used in a browser, but within a Deno or Node process.
43+
For long running server-side apps, a client id + secret is allowed with OAuth2. This should not be
44+
used in a browser, but within a Deno or Node process.
4445

4546
```typescript
4647
import { AuthProviders } from '@opentdf/sdk';
4748

4849
// Authentication options (vary by middleware)
49-
const oidcOrigin = "http://localhost:65432/auth/realms/opentdf";
50-
const clientId = "username";
51-
const clientSecret = "IdP_GENERATED_SECRET";
50+
const oidcOrigin = 'http://localhost:65432/auth/realms/opentdf';
51+
const clientId = 'username';
52+
const clientSecret = 'IdP_GENERATED_SECRET';
5253

5354
const authProvider = await AuthProviders.clientSecretAuthProvider({
5455
clientId,
@@ -60,7 +61,8 @@ const authProvider = await AuthProviders.clientSecretAuthProvider({
6061

6162
#### Given Credentials
6263

63-
The `refreshAuthProvider` and `externalAuthProvder` allow the application developer to use existing tokens.
64+
The `refreshAuthProvider` and `externalAuthProvder` allow the application developer to use existing
65+
tokens.
6466

6567
```typescript
6668
import { AuthProviders, NanoTDFClient } from '@opentdf/sdk';
@@ -70,14 +72,13 @@ const oidcCredentials: RefreshTokenCredentials = {
7072
exchange: 'refresh',
7173
refreshToken: refreshToken,
7274
oidcOrigin: keycloakUrlWithRealm,
73-
}
75+
};
7476
```
7577

7678
#### Building your own provider
7779

78-
A more complete example of using an OIDC compatible provider
79-
with support for authorization code flow with PKCE and DPoP
80-
is available in the [sample `web-app` folder](./web-app/src/session.ts)
80+
A more complete example of using an OIDC compatible provider with support for authorization code
81+
flow with PKCE and DPoP is available in the [sample `web-app` folder](./web-app/src/session.ts)
8182

8283
## Platform Client
8384

@@ -91,7 +92,9 @@ Below is an example of how to use the `PlatformClient` to interact with the plat
9192
import { AuthProvider, OpenTDF } from '@opentdf/sdk';
9293
import { PlatformClient } from '@opentdf/sdk/platform';
9394

94-
const authProvider: AuthProvider = {/* configure your auth provider */};
95+
const authProvider: AuthProvider = {
96+
/* configure your auth provider */
97+
};
9598
const platform = new PlatformClient({
9699
authProvider,
97100
platformUrl: '/api',
@@ -112,9 +115,12 @@ exampleUsage();
112115

113116
### Using Interceptor
114117

115-
The `PlatformClient` client supports the use of interceptors for customizing RPC calls. Interceptors allow you to modify requests or responses, such as adding custom headers or handling authentication, before or after the RPC call is executed.
118+
The `PlatformClient` client supports the use of interceptors for customizing RPC calls. Interceptors
119+
allow you to modify requests or responses, such as adding custom headers or handling authentication,
120+
before or after the RPC call is executed.
116121

117-
Below is an example of using an interceptor to add an `Authorization` header to all outgoing requests:
122+
Below is an example of using an interceptor to add an `Authorization` header to all outgoing
123+
requests:
118124

119125
```typescript
120126
import { platformConnect, PlatformClient } from '@opentdf/sdk/platform';
@@ -131,42 +137,43 @@ const platform = new PlatformClient({
131137
```
132138

133139
### Key Notes
134-
Interceptors are particularly useful for scenarios where you need to dynamically modify requests, such as adding authentication tokens or logging request/response data.
135140

141+
Interceptors are particularly useful for scenarios where you need to dynamically modify requests,
142+
such as adding authentication tokens or logging request/response data.
136143

137144
## Building and Testing
138145

139146
### Makefile Commands
140147

141-
The project provides a `Makefile` to simplify common development tasks. Below are the available commands:
142-
143-
| Command | Description |
144-
|-------------------|----------------------------------------------------------------------------------------------|
145-
| `make` | Builds and tests everything (default target). |
146-
| `make start` | Builds all packages and starts the web application in development mode. |
147-
| `make ci` | Installs dependencies and links the SDK package for all subprojects. |
148-
| `make i` | Installs dependencies and links the SDK package for all subprojects (without clean install). |
149-
| `make clean` | Removes build artifacts, packed files, and `node_modules` directories. |
150-
| `make cli` | Builds and packs the CLI tool. |
151-
| `make audit` | Runs `npm audit` for all packages except dev dependencies. |
152-
| `make format` | Runs code formatting for all packages. |
153-
| `make lint` | Runs linter for all packages. |
154-
| `make test` | Runs tests for all packages. |
155-
| `make license-check` | Checks license compliance for all packages. |
156-
| `make doc` | Generates documentation for the SDK. |
157-
| `make generate-platform` | Runs the platform code generation script. |
158-
| `make dist` | Copies the SDK package to the root directory. |
148+
The project provides a `Makefile` to simplify common development tasks. Below are the available
149+
commands:
150+
151+
| Command | Description |
152+
| ------------------------ | -------------------------------------------------------------------------------------------- |
153+
| `make` | Builds and tests everything (default target). |
154+
| `make start` | Builds all packages and starts the web application in development mode. |
155+
| `make ci` | Installs dependencies and links the SDK package for all subprojects. |
156+
| `make i` | Installs dependencies and links the SDK package for all subprojects (without clean install). |
157+
| `make clean` | Removes build artifacts, packed files, and `node_modules` directories. |
158+
| `make cli` | Builds and packs the CLI tool. |
159+
| `make audit` | Runs `npm audit` for all packages except dev dependencies. |
160+
| `make format` | Runs code formatting for all packages. |
161+
| `make lint` | Runs linter for all packages. |
162+
| `make test` | Runs tests for all packages. |
163+
| `make license-check` | Checks license compliance for all packages. |
164+
| `make doc` | Generates documentation for the SDK. |
165+
| `make generate-platform` | Runs the platform code generation script. |
166+
| `make dist` | Copies the SDK package to the root directory. |
159167

160168
You can run any of these commands using `make <command>`.
161169

162-
163170
## Contribute
164171

165172
### Prerequisites
166173

167-
Developing with this code requires a recent version of `npm` and `node`.
168-
We develop using [nvm](https://github.com/nvm-sh/nvm#readme),
169-
which allows us to pin to the same version of `npm` easily.
174+
Developing with this code requires a recent version of `npm` and `node`. We develop using
175+
[nvm](https://github.com/nvm-sh/nvm#readme), which allows us to pin to the same version of `npm`
176+
easily.
170177

171178
- Install [nvm](https://github.com/nvm-sh/nvm#readme)
172179
- see <https://github.com/nvm-sh/nvm#installing-and-updating>
@@ -180,4 +187,4 @@ To check out, build, and validate your installation, and test the sample web app
180187
nvm use
181188
make test
182189
make start
183-
```
190+
```

0 commit comments

Comments
 (0)