5.0.0 • Published 2 months ago

@ackee/antonio-auth v5.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

ackee|Antonio

GitHub license CI Status PRs Welcome Dependency Status bundlephobia bundlephobia node version @ackee/petrus min required version

@ackee/antonio-auth

It includes a request interceptor for @ackee/antonio-core that sets the Authorization header with an access token obtained from getAccessToken from @ackee/petrus.

Table of contents

Install

yarn add @ackee/antonio-auth -S

# Check you have installed at least these dependencies' versions:
yarn add @ackee/petrus@5.2.1

API

requestAuthHeaderInterceptor(request: Request): Request

A request interceptor that sets the Authorization header with setAuthHeader from @ackee/antonio-utils and obtained from getAccessToken from @ackee/petrus.

Default usage example

import { Antonio } from '@ackee/antonio-core';
import { requestAuthHeaderInterceptor } from '@ackee/antonio-auth';

const api = new Antonio({
    baseURL: '...',
});

api.interceptors.request.use(null, requestAuthHeaderInterceptor);

Custom usage example (without @ackee/petrus)

import { Antonio } from '@ackee/antonio-core';
import { setAuthHeader } from '@ackee/antonio-utils';

const api = new Antonio({
    baseURL: '...',
});

function* getAccessToken() {
    // Your custom function for obtaining the access token.
}

api.interceptors.request.use(null, function* (request) {
    const accessToken = yield getAccessToken();

    setAuthHeader(requst.headers, accessToken);

    return request;
});
5.0.0

2 months ago

4.1.1

7 months ago

4.0.14

1 year ago

4.0.13

1 year ago

4.0.12

2 years ago

4.0.11

2 years ago

4.0.10

3 years ago

4.0.9

3 years ago

4.0.8

3 years ago

4.0.7

3 years ago

4.0.6

3 years ago

4.0.5

3 years ago

4.0.4

3 years ago

4.0.0-beta.37

3 years ago

4.0.0-beta.36

3 years ago

4.0.0-beta.39

3 years ago

4.0.0-beta.38

3 years ago

4.0.0-beta.34

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

4.0.3

3 years ago

4.0.2

3 years ago

4.0.0-beta.10

3 years ago

4.0.0-beta.9

3 years ago

4.0.0-beta.8

3 years ago

4.0.0-beta.7

3 years ago

4.0.0-beta.6

3 years ago

4.0.0-beta.5

3 years ago

4.0.0-beta.4

3 years ago

4.0.0-beta.3

3 years ago

4.0.0-beta.2

3 years ago

4.0.0-beta.1

3 years ago