1.1.1 • Published 5 months ago

@villedemontreal/auth-oidc-plugin-superagent v1.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
5 months ago

Description

This is the HTTP client binding for the Superagent library.

It provides an implementation of IHttpClient, to use Superagent for all OIDC internal calls, and it provides additional plugins which enable authentication, logging and correlation ID injection.

This library belongs to a monorepo. Please visit https://github.com/VilledeMontreal/authentication-nodejs-lib for more information.

Plugins

Usage

npm install superagent @villemontrea/auth-oidc-plugin-superagent
npm install @types/superagent --save-dev
import * as superagent from 'superagent';
import {
  authenticator,
  createSession,
  requestLogger,
} from '@villedemontreal/auth-oidc-plugin-superagent';
// configure
const session = createSession({
  authMethod: 'client_secret_basic',
  client: {
    id: 'client',
    secret: 'clientSecret',
  },
  issuer: 'http://localhost:5000',
  scopes: ['openid', 'profile'],
});
// custom auth for each http call:
const res = await superagent
  .get('http://localhost:4004/secured/profile')
  .use(requestLogger(session.logger))
  .use(authenticator(session));
console.log(res.status, res.body);
// or configure auth once for all http calls:
const myAgent = superagent.agent().use(authenticator(session));
// then each call will be automatically authenticated
const res2 = await myAgent.get('http://localhost:4004/secured/profile');
console.log(res2.status, res.body);

Documentation

See Documentation.

Examples

See Superagent client

1.1.1

5 months ago

1.1.1-beta.10

5 months ago

1.1.1-beta.9

5 months ago

1.1.1-beta.6

5 months ago

1.1.0

1 year ago

1.1.1-beta.0

1 year ago

1.0.16-beta.0

1 year ago

1.0.15

1 year ago

1.0.15-beta.0

2 years ago

1.0.14-beta.0

2 years ago

1.0.14

2 years ago

1.0.11

2 years ago

1.0.13-beta.0

2 years ago

1.0.12-beta.0

2 years ago

1.0.12

2 years ago

1.0.10-beta.2

2 years ago

1.0.10

2 years ago

1.0.10-beta.0

2 years ago

1.0.9

2 years ago

1.0.8

3 years ago

1.0.9-beta.0

3 years ago

1.0.7

3 years ago

1.0.8-beta.0

3 years ago

1.0.7-beta.4

3 years ago

1.0.7-beta.1

3 years ago

1.0.7-beta.2

3 years ago

1.0.6

3 years ago

1.0.7-beta.0

3 years ago

1.0.4-beta.10

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.4-beta.9

3 years ago

1.0.6-beta.0

3 years ago

1.0.5-beta.0

3 years ago

1.0.4-beta.3

3 years ago

1.0.4-beta.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago