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

@cognite/cognitesdk

Package Overview
Dependencies
Maintainers
26
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cognite/cognitesdk

Javascript client library for Cognite SDK

  • 0.5.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
26
Weekly downloads
 
Created
Source

cognitesdk Dependency Status Coverage Status

Javascript client library for Cognite SDK

Installation

$ npm install --save cognitesdk

Usage

Authentication with 'silent login' (available from version >0.4)

This injects an iframe into the

  // Intially call the redirect function
  cognitesdk.loginWithRedirect();

  // get the token from the url
  const token = some_querystring_parser('access_token');

  // use that token for all subsequent calls to api
  cognitesdk.setBearerToken(token)

  // Figure out how long til the token expires
  const decodedToken = jwtDecode(token);
  const msToExpiration =
    decodedToken.expire_time * 1000 - new Date().getTime();

  /* Call silentlogin function some time before it expires
  repeat every time you get a new token 
  
  This injcts an iframe into your page, and gets the token from the a redirect in that frame
  Pass in the url to an empty html file for fastest load times.
  */
  setTimeout(() => {
    getAccessTokenFromSession('www.myapplication.com/empty.html')
  }, msToExpiration - 5000);
Example get a project
const cognitesdk = require('cognitesdk');

cognitesdk.configure({
  project,
  version,
});


cognitesdk
  .getProject()
  .then(console.log)
  .catch(console.error);

To release

Use the command yarn release

This will build, bump version and release to npm.

Build from repo

The tests need an API key to make sure it's working. Create a file called .secrets.json in the root folder, looking like this:

{
  "apikey": "..."
}
$ git clone git@github.com:cognitedata/cognitesdk-js
$ yarn
$ yarn test

FAQs

Package last updated on 10 Dec 2018

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