1.3.4 • Published 3 days ago

@earnaha/auth0-action-helper v1.3.4

Weekly downloads
-
License
ISC
Repository
github
Last release
3 days ago

AHA auth0 action helper

Create custom actions in auth0

  1. login auth0 account
  2. create a action: e.g. actions Flows Login Add Action Build 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 = Applications Applications Machine to Machine App Settings Basic Information Domain
    • AUTH0_CLIENT_ID = Applications Applications Machine to Machine App Settings Basic Information Client ID
    • AUTH0_CLIENT_SECRET = Applications Applications Machine to Machine App Settings Basic Information Client 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

1.3.4

3 days ago

1.3.3

6 days ago

1.3.2

6 days ago

1.3.1

7 days ago

1.3.0

7 days ago

1.2.8

2 months ago

1.2.7

2 months ago

1.2.11

2 months ago

1.2.9

2 months ago

1.2.6

3 months ago

1.2.5

3 months ago

1.2.4

3 months ago

1.2.0

7 months ago

1.2.3

7 months ago

1.2.2

7 months ago

1.2.1

7 months ago

1.0.62

9 months ago

1.0.61

9 months ago

1.0.60

9 months ago

1.0.64

9 months ago

1.0.63

9 months ago

1.1.1

9 months ago

1.1.7

7 months ago

1.1.6

7 months ago

1.1.5

8 months ago

1.1.4

8 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.0.59

9 months ago

1.0.58

11 months ago

1.0.57

11 months ago

1.0.56

12 months ago

1.0.55

12 months ago

1.0.54

12 months ago

1.0.53

12 months ago

1.0.52

12 months ago

1.0.51

12 months ago

1.0.50

12 months ago

1.0.49

12 months ago

1.0.48

12 months ago

1.0.47

12 months ago

1.0.46

12 months ago

1.0.45

12 months ago

1.0.44

12 months ago

1.0.43

12 months ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.40

1 year ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.0

1 year ago