New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pdk-client

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdk-client

ProdataKey pdk.io API Client Library for Javascript

  • 0.1.0
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

PDK Javascript Client

This is the Javascript client for interacting with the PDK auth and panel APIs.

This may be helpful as a guide even if you don't use Javascript. The APIs use a REST style HTTP JSON interface that is simple to use from nearly any lanugage with an intelligent HTTP library.

Layout

The src/ directory contains the client library. In src/examples/ find examples for using the API for various tasks.

Usage

Async Operations

If you're not using a transpiler for async/await then just use the Promise that is returned by async functions.

import pdk from 'pdk';
pdk.authenticate(client_id, client_secret).then(tokenset => {
  // use tokenset here
});

vs

import { authenticate } from 'pdk';
const tokenset = await authenticate(client_id, client_secret);

Flow

Once calling authenticate to get an authentication context, use makesession to create a session with the API.

import { makesession } from 'pdk';
const session = await makesession(tokenset.token_id);

This session function is a thin facade around got that allows easily making authenticated requests, options are passed on to got.

// `mine` is the ID for the authenticated user's default organization
let response = await session('ous/mine');

The response is a Javascript object representing the response body documented in the API docs.

Functions

const tokenset = function *authenticate* (
  // This launches a user's browser and retrieves an authentication token
  _clientId_: The oAuth client id issued for use,
  _clientSecret_: The oAuth client secret issued,
  _issuer_ (optional): The OpenID Connect provider to auth against,
);

const session = functionn *makesession* (
  // This creates a session that allows making requests to the API endpoints
  _tokenId_: The `token_id` from the tokenset retrieved from `authenticate`,
};

Developers

If you just want to use the client without messing with the guts, just add this module as an npm dependency and import pdk from 'pdk'; (or const pdk = require('pdk'); if you must.

This project uses babel to translate a couple features that haven't hitten Javascript yet, mainly async/await. The if changes are made to src/ then npm run build needs to be run to create the output in lib/ that can be run by node.

FAQs

Package last updated on 19 Jan 2017

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