4.0.0 • Published 1 year ago

rps-engine-client-js v4.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

rps-engine-client-js

npm version

Regdata RPS Engine Client library (JS)

RPS Engine Client library documentation

The full documentation is available in RPS Community

Installation

Use npm to install the RPS Engine Client library:

npm i rps-engine-client-js

Usage

Simple example

const {
  EngineClient,
  RequestBuilder,
  TokenProvider,
  RPSContext,
  RPSValue,
  RPSEvidence
} = require('rps-engine-client-js/lib')

const IDENTITY_SERVER_HOST_NAME = 'https://identity.rpsprod.ch'
const ENGINE_HOST_NAME = 'https://engine.rpsprod.ch'

const CLIENT_ID = 'c6cbde13-542d-4849-a69e-3962ed09bc10'
const CLIENT_SECRET = '37571534bf6d40878fa77cb7b354b3274e6c047bd6404468b0fa2345cb7ebe61'

const secrets = {
  clientId: CLIENT_ID,
  clientSecret: CLIENT_SECRET
}

const rightsContext = new RPSContext([
  new RPSEvidence({name: 'Role', value: 'Admin'})
])

const processingContext = new RPSContext([
  new RPSEvidence({name: 'Action', value: 'Protect'})
])

const tokenProvider = new TokenProvider({
  identityServerHostName: IDENTITY_SERVER_HOST_NAME,
  ...secrets
})

const engineClient = new EngineClient({
  config: {baseURL: ENGINE_HOST_NAME},
  tokenProvider
})

const instances = [
  new RPSValue({className: 'User', propertyName: 'FirstName', value: 'Jonny'}),
  new RPSValue({className: 'User', propertyName: 'LastName', value: 'Silverhand'}),
  new RPSValue({className: 'User', propertyName: 'BirthDate', value: '16.11.1988'})
]

const requestData = new RequestBuilder()
  .addRequest({instances, rightsContext, processingContext})
  .build()

const response = await engineClient.transform(requestData)
console.log(response)
3.11.0

1 year ago

3.11.2

1 year ago

3.11.1

1 year ago

4.0.0

1 year ago

3.11.4

1 year ago

3.11.3

1 year ago

3.10.7

1 year ago

3.10.9

1 year ago

3.10.8

1 year ago

3.10.3

2 years ago

3.10.5

2 years ago

3.10.4

2 years ago

3.10.6

2 years ago

3.10.2

2 years ago

3.10.1

2 years ago

3.10.0

2 years ago