/auth0-rules-types

Typescript definitions for auth0 rules environment

Primary LanguageTypeScript

auth0-rules-types

Typescript types for the auth0 rule runtime environment

npm version

Compatible with the node8 runtime of auth0 (current version = v8.11.4)

Install

npm install --save @tepez/auth0-rules-types

Usage

The module declares global variables so you should import it, e.g.:

import '@mleybsage/auth0-rules-types'

It also defines types you can use in the rules:

  • IAuth0RuleUser - the user object (first argument of the rule function)
  • IAuth0RuleContext - the context object (second argument of the rule function)
  • IAuth0RuleCallback - the callback function (third argument of the rule function)
  • IAuthRuleFunction - the rule function itself

Add typings for cache

Add:

declare global {
    namespace NodeJS {
        interface Global {
            CACHE_KEY: string
        }
    }
}

Now you can access the cache on the global variable, global.CACHE_KEY

Add typings for rules configuration

Add:

declare global {
    interface IAuth0RuleConfiguration {
        KEY: string
    }
}

Now you can access the configuration using configuration.KEY