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

@earnaha/auth0-action-helper

v1.3.4

Published

AHA auth0 action helper

Downloads

584

Readme

AHA auth0 action helper

Create custom actions in auth0

  1. login auth0 account
  2. create a action: e.g. actionsFlowsLoginAdd ActionBuild Custom
  3. initialize the action:
    name = Post Login
    Trigger = Login / Post Login
    Runtime = Node 16
  4. click Create

Add dependencies

  1. click the cube icon in the left side of codes
  2. click Add Dependency
    name = @earnaha/auth0-action-helper
    version = 1.0.21 or latest
  3. click Create

Setup event secrets

  1. click the key icon in the left side of codes
  2. click Add Secret, input keys and values like below, and then click Create for each one.
    • ENV = local, dev, test, stage, alpha, beta, gamma, prod, ...etc.
    • SERVICE = any string to distinguish your sites or services.
    • DOMAIN = https://subdomain.yourdomain.com (backend url, https required)
    • ACCESS_KEY = the secret key to access your backend api, encode string more than 25 letters
    • ACCESS_SALT = the secret salt to access your backend api, a number more than 10 digits
    • AUTH0_DOMAIN = ApplicationsApplicationsMachine to Machine AppSettingsBasic InformationDomain
    • AUTH0_CLIENT_ID = ApplicationsApplicationsMachine to Machine AppSettingsBasic InformationClient ID
    • AUTH0_CLIENT_SECRET = ApplicationsApplicationsMachine to Machine AppSettingsBasic InformationClient Secret
    • SENTRY_DSN = the sentry dns for logging, a sentry account is required. (https://sentry.io/)
    • SENTRY_TRACES_SAMPLE_RATE = the sentry trace setting. e.g. 0.1, 1.0, ...etc.
    • SENTRY_LOGGER_LEVEL = the sentry logger level setting. e,g, debug, info, ...etc.
    • LINK_ACCOUNT_TIME = YYYY-MM-DD, account created after this date, merge accounts if having the same email.

Code in actions

Post login

make an API in your backend side with the route /auth/v3/login to handle the signed in/up account data.

const AhaHelper = require('@earnaha/auth0-action-helper');

/**
* Handler that will be called during the execution of a PostLogin flow.
*
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.
*/
exports.onExecutePostLogin = async (event, api) => {
	try {
		const helper = new AhaHelper.PostLoginHelper(event.secrets);
		const res = await helper.exec(event, api);
		console.log('onExecutePostLogin res=',res);

	} catch (e) {
		console.error('onExecutePostLogin error=', e?.response?.data || e.message);
		throw e;
	}
};

Post change password

make an API in your backend side with the route /auth/v3/refer/invitation/accept to handle the invitation acceptance things after the invited account signs in/up.

const AhaHelper = require('@earnaha/auth0-action-helper');
/**
* Handler that will be called during the execution of a PostChangePassword flow.
*
* @param {Event} event - Details about the user and the context in which the change password is happening.
* @param {PostChangePasswordAPI} api - Methods and utilities to help change the behavior after a user changes their password.
*/
exports.onExecutePostChangePassword = async (event, api) => {
	try {
		const helper = new AhaHelper.PostChangePasswordHelper(event.secrets);
		const res = await helper.exec(event, api);
		console.log('onExecutePostChangePassword res=',res);
	} catch (e) {
		console.error('onExecutePostChangePassword error=', e?.response?.data || e.message);
		throw e;
	}
};

Post user registration

currently no further handling in the exec function.

const AhaHelper = require('@earnaha/auth0-action-helper');
/**
* Handler that will be called during the execution of a PostUserRegistration flow.
*
* @param {Event} event - Details about the context and user that has registered.
* @param {PostUserRegistrationAPI} api - Methods and utilities to help change the behavior after a signup.
*/
exports.onExecutePostUserRegistration = async (event, api) => {
	try {
		const helper = new AhaHelper.PostUserRegistrationHelper(event.secrets);
		const res = await helper.exec(event, api);
		console.log('onExecutePostUserRegistration res=',res);
	} catch (e) {
		console.error('onExecutePostUserRegistration error=', e?.response?.data || e.message);
		throw e;
	}
};

Pre user registration

currently no further handling in the exec function.

const AhaHelper = require('@earnaha/auth0-action-helper');
/**
* Handler that will be called during the execution of a PreUserRegistration flow.
*
* @param {Event} event - Details about the context and user that is attempting to register.
* @param {PreUserRegistrationAPI} api - Interface whose methods can be used to change the behavior of the signup.
*/
exports.onExecutePreUserRegistration = async (event, api) => {
	try {
		const helper = new AhaHelper.PreUserRegistrationHelper(event.secrets);
		const res = await helper.exec(event, api);
		console.log('onExecutePreUserRegistration res=',res);
	} catch (e) {
		console.error('onExecutePreUserRegistration error=', e?.response?.data || e.message);
		throw e;
	}
};

Deploy and test