1.1.3 • Published 3 years ago

@kaviar/apollo-security-bundle v1.1.3

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

This bundle is to inject into the context the token read from the request and decoded to an userId via the SecurityBundle.

Installation

npm i -S @kaviar/apollo-bundle @kaviar/apollo-security-bundle
import { ApolloSecurityBundle } from "@kaviar/apollo-security-bundle";

kernel.addBundle(
  new ApolloSecurityBundle({
    // options go here
  })
);

Options:

export interface IApolloSecurityBundleConfig {
  // All true by default
  support: {
    headers?: boolean,
    cookies?: boolean,
    websocket?: boolean,
  };
  // kaviar-login-token is the default for all
  identifiers: {
    headers?: string,
    cookies?: string,
    // For websocket you have to send the connection params in order to work
    websocket?: string,
  };
}

Usage:

import { ISecurityContext } from "@kaviar/apollo-security-bundle";

load({
  resolvers: {
    Query: {
      findMyPosts(_, args, context: ISecurityContext) {
        if (!context.userId) {
          // You can throw an error.
        }
      },
    },
  },
});

Support

This package is part of KaviarJS family. If you enjoy this work please show your support by starring the main package. If not, let us know what can we do to deserve it, our feedback form is here

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago