Socket
Socket
Sign inDemoInstall

@zappar/zw-api-client

Package Overview
Dependencies
Maintainers
11
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zappar/zw-api-client

ZapWorks API JS client


Version published
Maintainers
11
Created
Source

ZapWorks API JS client

This client wraps AppAuth, provides a clean way of connecting to the ZapWorks API and type definitions for all data sent back.

By default an OAuth2 Authorization Code Grant with PKCE will be used.

Examples of AppAuth usage:

https://github.com/openid/AppAuth-JS/blob/master/src/app/index.ts https://github.com/openid/AppAuth-JS/blob/master/src/node_app/index.ts

Client usage on a browser (front-end)

const client = new zw.Client({
  clientId: 'abc123',
  redirectURI: 'https://example.com/oauth/callback/',
  env: zw.Environment.Dev,
})

client.checkForAuthorizationResponse().then(async () => {
  const qs = new URLSearchParams(location.search)
  if (qs.get('error')) return // Display auth error to user

  if (qs.get('code')) { // check if we got a code on the callback request
    await client.makeTokenRequest() // request an access token
  }

  // from here the client has an access token to call the API
  client.getUser().then(console.log)
})

Client usage in NodeJS

const client = new zw.NodeClient({
  clientId: 'abc123',
  env: zw.Environment.Dev
})

await client.makeAuthorizationRequest()
console.log(await client.getUser())

FAQs

Package last updated on 07 Dec 2023

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