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

@people.io/ppl-api-client-js

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@people.io/ppl-api-client-js - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

9

index.js

@@ -16,3 +16,7 @@ const client = require('./lib/httpClient');

function getUserAuthURL(scope, desination, clientId, state) {
async function getUserIdToken({ token, apiKey, clientId } = {} ) {
return client.execute('post', 'idToken', undefined, { token, apiKey, clientId });
}
function getUserAuthURL(scope, desination, { clientId, state} = {}) {
if (!Array.isArray(scope)) {

@@ -30,3 +34,4 @@ throw new Error(`"Scope" param must be an array of strings. You current scope is: ${JSON.stringify(scope)}`)

getUserAudiences,
getUserAuthURL
getUserAuthURL,
getUserIdToken
}

@@ -15,3 +15,4 @@ const axios = require('axios');

audiences: `/${config.apiVersion}/audiences`,
audienceGroups: `/${config.apiVersion}/audiences/groups`
audienceGroups: `/${config.apiVersion}/audiences/groups`,
idToken: `/${config.apiVersion}/users/id-token`
};

@@ -90,6 +91,6 @@

function execute(method = 'get', endpointName = 'none', data, options = {}) {
function execute(method = 'get', endpointName = 'none', data = {}, options = {}) {
const params = getCallParams(endpointName, options);
const request = getApiBaseRequest(method, data, params);
// console.log('executing request: ', {request});
return axios(request);

@@ -96,0 +97,0 @@ }

{
"name": "@people.io/ppl-api-client-js",
"version": "1.0.1",
"version": "1.1.0",
"description": "Simple client for people.io api",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -22,4 +22,5 @@ # ppl-api-client-js

const destination = "https://myserver.io/tokenCapture";
const state = 'calculate-your-state-hash'
const url = client.getUserAuthURL(scope, destination);
const url = client.getUserAuthURL(scope, destination, { state });
console.log('User authentication page: ', url);

@@ -63,3 +64,5 @@ ```

* `getAudienceGroups(name, { limit, page, token, apiKey, clientId })`
* `getUserAudiences(audienceGroupId, { token, apiKey, clientId })`;
* `getUserAudiences(audienceGroupId, { token, apiKey, clientId })`
* `getUserIdToken({ token, apiKey, clientId })`
* `getUserAuthURL(scope, desination, { clientId, state })`

@@ -66,0 +69,0 @@ The `token`, `apiKey`, and `clientId` parameters become optional when previously stated or configured.

@@ -47,3 +47,8 @@ const chaiAsPromised = require("chai-as-promised");

it('Can generate a valid user implicit outh url', function () {
const url = client.getUserAuthURL(['test', 'scope'], 'http://server.io/captureToken', 'test-client-id', 'test-state-string');
const clientId = 'test-client-id';
const state = 'test-state-string';
const scope = ['test', 'scope'];
const destination = 'http://server.io/captureToken';
const url = client.getUserAuthURL(scope, destination, {clientId, state});
return expect(url).to.equal(mockValues.userAuthUrl);

@@ -53,3 +58,3 @@ });

it('Can list audiences', function () {
moxios.stubRequest('https://api.people.io/v1/audiences', mockValues.apiResponses.userAudiences);
moxios.stubRequest('https://api.people.io/v1/audiences', mockValues.apiResponses.audiences);
return expect(client.getAudiences()).to.eventually.be.fulfilled;

@@ -59,3 +64,3 @@ });

it('Can inspect a audience group', function () {
moxios.stubRequest('https://api.people.io/v1/audiences/groups', mockValues.apiResponses.userAudiences);
moxios.stubRequest('https://api.people.io/v1/audiences/groups', mockValues.apiResponses.audienceGroups);
return expect(client.getAudienceGroups()).to.eventually.be.fulfilled;

@@ -68,2 +73,8 @@ });

});
it('Can Obtain a user id token', function () {
moxios.stubRequest('https://api.people.io/v1/users/id-token', mockValues.apiResponses.userIdToken);
return expect(client.getUserIdToken()).to.eventually.be.fulfilled;
});
});

@@ -11,3 +11,4 @@ const configErrors = {

audienceGroups: { status: 200, responseText: 'audienceGroups-result' },
userAudiences: { status: 200, responseText: 'userAudiences-result' }
userAudiences: { status: 200, responseText: 'userAudiences-result' },
userIdToken: { status: 200, responseText: 'userAudiences-result' }
}

@@ -14,0 +15,0 @@

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