npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@superfaceai/service-client

v5.2.1

Published

Client to access Superface services. (If you are not from Superface Team, you probably don't need this library)

Downloads

87

Readme

Superface Service Client (service-client)

This repository provides HTTP client for communication with Superface services. If you are not from Superface Team, you probably don't need this library.

Table of Contents

Background

Superface (super-interface) is a higher-order API, an abstraction on top of the modern APIs like GraphQL and REST. Superface is one interface to discover, connect, and query any capabilities available via conventional APIs.

Through its focus on application-level semantics, Superface decouples the clients from servers, enabling fully autonomous evolution. As such it minimizes the code base as well as errors and downtimes while providing unmatched resiliency and redundancy.

Superface allows for switching capability providers without development at a runtime in milliseconds. Furthermore, Superface decentralizes the composition and aggregation, and thus creates an Autonomous Integration Mesh.

Motivation behind Superface is nicely described in this video from APIdays conference.

You can get more information at https://superface.ai and https://superface.ai/docs.

Install

Install dependencies:

yarn install

Build TS files:

yarn build

Usage

Fetch

Fetches specified URL. Method adds authorization header to the request by default.

import { ServiceClient } from '@superfaceai/service-client';

const client = new ServiceClient({
  baseUrl: 'https://superface.dev',
  refreshToken: '<refresh token>',
});

const response = client.fetch('/providers', {
  method: 'POST',
  ...
});

Passwordless Authentication Flow

Passwordless flow allows user to login by clicking on magic link in e-mail. As result of passwordless flow application will receive access and refresh tokens.

ServiceClient provides passwordlessLogin and verifyPasswordlessLogin methods. Application should use them to implement passwordless login.

passwordlessLogin method sends e-mail with magic link to user verifyPasswordlessLogin method returns refresh and access token once login has been confirmed

Passwordless authentication sequence

  1. Application requests e-mail address input from user
  2. Application initializes ServiceClient via setOptions with Superface backend base address
  3. Application calls Superface passwordless API via ServiceClient method passwordlessLogin(email)
  4. Superface passwordless API sends e-mail with magic link and returns verify url
  5. Application checks preriodically authentication state via ServiceClient method verifyPasswordlessLogin(verifyUrl)
  6. Once user confirms login request by clicking on received link verifyPasswordlessLogin(token) method returns access and refresh tokens (one time action)
  7. Application persists refresh token (Air can rely on auth cookie)
  8. Application can start authenticated communication to Superface backend APIs via fetch method

Development

When developing, start with cloning the repository using git clone https://github.com/superfaceai/service-client.git (or git clone [email protected]:superfaceai/service-client.git if you have repository access).

After cloning, the dependencies must be downloaded using yarn install or npm install.

Now the repository is ready for code changes.

The package.json also contains scripts (runnable by calling yarn <script-name> or npm run <script-name>):

  • lint - lint the code (use lint --fix to run autofix)
  • test - run unit tests
  • test-e2e - run end to end tests

Lastly, to build a local artifact run yarn build or npm run build.

Maintainers

Contributing

Please open an issue first if you want to make larger changes

Feel free to contribute! Please follow the Contribution Guide.

Licenses of node_modules are checked during CI/CD for every commit. Only the following licenses are allowed:

  • 0BDS
  • MIT
  • Apache-2.0
  • ISC
  • BSD-3-Clause
  • BSD-2-Clause
  • CC-BY-4.0
  • CC-BY-3.0;BSD
  • CC0-1.0
  • Unlicense
  • UNLICENSED

Note: If editing the README, please conform to the standard-readme specification.

License

The Superface is licensed under the MIT. © 2021 Superface