Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@obelisk/client

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@obelisk/client

Typescript client to interact with Obelisk on a higher level than with regular ReST API calls.

  • 0.3.0-rc.0
  • rc
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by800%
Maintainers
1
Weekly downloads
 
Created
Source

Obelisk Client

pipeline status

A client library written in Typescript to interact with Obelisk. Link back to the full documentation here.

Prerequisites

This library makes use of RxJS (Reactive Extensions for JavaScript). RxJS comes as a peer dependency.

Overview

The client has a clear purpose:

  • Make it easier to do follow up requests on Temporal Pages (see IoT-stack documentation).
  • Do the heavy lifting on authentication and authorization

The client help with authorization to the Obelisk keycloak authorization Server. This should handle:

  • Logging in to a supported Identity Provider (eg. Google)
  • Getting the access token
  • Getting the RPT token
  • Refreshing tokens when needed
  • Login/logout support

With the client you create Endpoints. These endpoints can be acted on with methods like execute() or get(). An endpoint takes an API uri as argument. This means that the HTTP REST api is as important to you, as this API.

Installation

npm install obelisk-client rxjs --save

Usage

To start you need to create an IotClient instance with a proper options object.

import { ClientOptions, IotClient } from '@obelisk/client';

// Create shareable observable. (caches the client object)
const options: ClientOptions = {
    host: 'https://obelisk.ilabt.imec.be',
    apiVersion: 'v1',
    realm: 'idlab-iot',
    clientId: 'my-client'
}
let client = new IotClient(options);

Now init the client to connect to the Obelisk back-end and start using it. init() returns an Observable that copmletes once initialization is over.

this.client.init().subscribe({
    next: _ => {
        // do something with the client.
    }
})

Angular

There is an optional angular package to use in conjunction with the client packages. To include it in you main AppModule, do this:

import { APP_INITIALIZER } from '@angular/core';
import { ObeliskNgxModule, ObeliskService, OBELISK_DEPS, factory } from '@obelisk/ngx';

const options: ClientOptions = {
    host: 'https://obelisk.ilabt.imec.be',
    apiVersion: 'v1',
    realm: 'idlab-iot',
    clientId: 'my-client'
}

@NgModule({
    declarations: [...],
    imports: [
        ...,
        ObeliskNgxModule.forRoot(options)
    ],
    providers: [
        {
            provide: APP_INITIALIZER,
            deps: OBELISK_DEPS,
            useFactory: factory,
            multi: true
        }
        ...
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }

Now you can inject ObeliskService and get an already initialized client from it any time.

If you are logged in it will handle all the tokens in the headers for you.

Keywords

FAQs

Package last updated on 12 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc