Giter VIP home page Giter VIP logo

client-web's Introduction

OpenTDF Web Browser Client opentdf

This project is focused on providing web client support for the OpenTDF platform. This includes encrypting and decrypting TDF content, and some management tasks for ABAC.

Usage

  // currently we support only ESM import
  import { AuthProviders, NanoTDFClient } from '@opentdf/client';

  const oidcCredentials: RefreshTokenCredentials = {
    clientId: keycloakClientId,
    exchange: 'refresh',
    refreshToken: refreshToken,
    oidcOrigin: keycloakUrlWithRealm,
  }
  const authProvider = await AuthProviders.refreshAuthProvider(oidcCredentials);
  const client = new NanoTDFClient(authProvider, access);
  const cipherText = await client.encrypt(plainText);
  const clearText = await client.decrypt(cipherText);

Build and Test

make

Contribute

Prerequisites

Developing with this code requires a recent version of npm and node. We develop using nvm, which allows us to pin to the same version of npm easily.

Build

To check out, build, and validate your installation, and test the sample web application, you may:

nvm use
make test
make start

Use the platform

Version 2 of this library adds support for ABAC management tasks. This is provided with the opentdf Platform.

Generate Typescript code from platform protobufs

scripts/platform.sh

This will clone the platform repo and generate Typescript code in lib/src/platform.

Import Typescript code

import { GetAttributeRequest } from './lib/src/platform/policy/attributes/attributes_pb';
import { Attribute, AttributeRuleTypeEnum } from './lib/src/platform/policy/objects_pb';
import {
    createConnectTransport,
} from '@connectrpc/connect-web'
import {
    createPromiseClient,
} from '@connectrpc/connect'

const attrData = {
    name: "my-attr",
    rule: AttributeRuleTypeEnum.ALL_OF,
    namespace: {name: 'my-namespace'},
    values: [{value: 'my-value'}],
    active: true,
    extraField: 'this will be ignored' // only proto defined fields and value types are respected
}
const attr = new Attribute(attrData);
console.log(attr.toJson());

// {
//     namespace: { name: 'my-namespace' },
//     name: 'my-attr',
//     rule: 'ATTRIBUTE_RULE_TYPE_ENUM_ALL_OF',
//     values: [ { value: 'my-value' } ],
//     active: true
// }

const req = new GetAttributeRequest({id: 'uuid-here'});
const client = createPromiseClient(
    AttributesService,
    createConnectTransport({
        baseUrl: 'localhost:8080',
    })
)

This is an example to instantiate an Attribute and create a GetAttributeRequest.

client-web's People

Contributors

cassandrabailey293 avatar damorris25 avatar danielricaud avatar dependabot[bot] avatar dmihalcik-virtru avatar elizabethhealy avatar ivanovspvirtru avatar jakedoublev avatar krokhmaliuk-virtru avatar mustyantsev avatar ntrevino-virtru avatar obidenko avatar patmantru avatar pflynn-virtru avatar sievdokymov-virtru avatar suchak1 avatar virtru-cloudnative avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

strantalis

client-web's Issues

feat: attribute based key splits

With the introduction of attribute based key splitting in the go sdk. We now need to introduce this for ztdf in the javascript sdk. Implement the key splitting logic that was done in the go sdk and update x-tests to make
key splits generated with each sdk can interop.

Keep the generated proto code in step with platform releases

We should make sure our generated ts files are up to date in a variety of ways:

  1. Make sure to check out the protos using the latest version of platform/protocol version imported by 'current supported' version of platform/service
  2. Add Gencode update check as part of prepack step
  3. Add gencode up-to-date check to ci
  4. Validate work with round trip test with platform/service

Services SDK generation and implementation

Add SDK support for calling services so web clients can easily access data like a list of attributes or fetch data like the attributes which the current user should have access to.

Tool to generate code: https://github.com/bufbuild/protobuf-es
Example of build with registry and usage: https://github.com/connectrpc/examples-es/tree/main/react/vite

Acceptance Criteria

  • create a workflow that can be executed manually or automated to build the generated code
  • use the upstream protos (opentdf/platform) in a dynamic way so that we can build protos from a supported git tag (aka version)
  • add an example to the README to explain how someone might access the service SDKs
    • focus on connection and not on a specific example
  • (optional) expose the service SDK in a convenient way to improve developer experience -- this work could be split out as a separate issue

JS SDK ZTDF Assertion Support

Update the javascript sdk to support ZTDF Assertions

  • creating assertions
  • validating assertions
  • reading assertions metadata

This support will also be added to the Golang and Java SDKs.

js/sdk: validate (and fix) policy/user auth with platform

  1. Extend the integration test to include policy checks
    a. Configure attributes associated with the sample user
    b. Add attributes to the policy that the user has and validate rewrap works.
    c. Add attributes to the policy the user does not have and validate that rewrap gets a 403.
  2. Fix any issues we find with these tests

feat: nanotdf key id support

With the addition of key id to the nanotdf spec we need to add support within the sdk.

Acceptance Criteria:

  • SDK Sets proper KID specified by KAS
  • Test Updates
  • X-Test Passes

client web: CI test with platform

Implement a CI test that works with the new opentdf/platform artifacts (go services) instead of the now deprecated 'backend' resources

Support bulk rewrap requests

Essentially, the SDK should look for multiple KAOs with the same KAS urls, and send the requests in bulk, instead of individually.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.