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

@magda/authentication-plugin-sdk

v4.2.4

Published

MAGDA Authentication Plugin SDK

Downloads

386

Readme

MAGDA Authentication Plugin SDK

Please information please refer to the Authentication Plugin Spec

Existing Magda Authentication Plugins can be found from here.

You can use this repo as a template to create your own magda authentication plugin.

/**
 * Create an express router that can be used to enable session on an express application.
 *
 * @export
 * @param {MagdaSessionRouterOptions} options
 * @returns {Router}
 */
export declare function createMagdaSessionRouter(
  options: MagdaSessionRouterOptions
): Router;

/**
 * Complete destroy Magda session and remove session cookie from the user agent
 *
 * @export
 * @param {Request} req
 * @param {Response} res
 * @param {SessionCookieOptions} cookieOptions
 * @return {*}  {Promise<void>}
 */
export declare async function destroyMagdaSession(
  req: Request,
  res: Response,
  cookieOptions: SessionCookieOptions
): Promise<void>;

/**
 * Verify the user using the user profile received during the authentication.
 * If a user can be located, return UserToken type data.
 * Otherwise, create a new user and return UserToken type data .
 *
 * @export
 * @param {AuthApiClient} authApi
 * @param {passport.Profile} profile
 * @param {string} source
 * @param {(
 *         authApiClient: AuthApiClient,
 *         userData: User,
 *         profile: passport.Profile
 *     ) => Promise<User>} [beforeUserCreated] an optional handler that will be called just before a user is created.
 * The user data returned by this handler will be used to create a user record. The following parameters will be provided to the handler:
 * - authApiClient: Auth API Client. You can use it to add a role to the user.
 * - userData: the user data that is converted from the user profile received using the default conversion logic.
 * - profile: the user profile received
 *
 * @param {(
 *         authApiClient: AuthApiClient,
 *         user: User,
 *         profile: passport.Profile
 *     ) => Promise<void>} [afterUserCreated] an optional call that will be called when a user has just been created.
 * The following parameters will be provided to the handler:
 * - authApiClient: Auth API Client. You can use it to add a role to the user.
 * - user: the user data of the magda user that is just created.
 * - profile: the user profile received
 *
 * @returns {Promise<UserToken>}
 */
export declare function createOrGetUserToken(
  authApi: AuthApiClient,
  profile: passport.Profile,
  source: string,
  beforeUserCreated?: (
    authApiClient: AuthApiClient,
    userData: User,
    profile: passport.Profile
  ) => Promise<User>,
  afterUserCreated?: (
    authApiClient: AuthApiClient,
    user: User,
    profile: passport.Profile
  ) => Promise<void>
): Promise<UserToken>;

/**
 * Join `url` with `baseUrl` if `url` is not an absolute (full) url string
 *
 * @export
 * @param {string} url A full url string or a url path string (/a/b/c).
 * @param {string} baseUrl A baseUrl used to generate a full url when a url path string is supplied via the `url` parameter.
 * @param {{ [key: string]: string }} [optionalQueries]
 * @param {string[]} [allowedUrlHosts] Optional; when specify, the host of `url` parameter will only be used if it is included by this list.
 * @returns
 */
export declare function getAbsoluteUrl(
  url: string,
  baseUrl: string,
  optionalQueries?: {
    [key: string]: string;
  },
  allowedUrlHosts?: string[]
): string;

export declare function redirectOnSuccess(
  toURL: string,
  req: Request,
  res: Response
): void;

export declare function redirectOnError(
  err: any,
  toURL: string,
  req: Request,
  res: Response
): void;