Upgrading to Version 8
Upgrade Process
Updating the Configuration
If you’re upgrading from version 7.x or below of the Node Express, many of the configuration fields have remained the same.
The following configuration fields have been modified:
px_additional_activity_handlerhas been changed. The function signature has been modified from(pxCtx, config) => voidto(config, context, request) => Promise<void> | void.px_enrich_custom_parametershas been changed. The function signature has been modified from(customParams, request) => CustomParametersto(config, request) => Promise<CustomParameters>.px_cors_custom_preflight_handlerhas been changed. The function signature has been modified from(request) => Responseto(request) => Promise<{ body: string, headers: Record<string, string[]>, status: number }>.- The function
px_cors_create_custom_block_response_headershas been changed. The function signature modified from(request) => Promise<Record<string, string>>to(request) => Promise<Record<string, string[]>>.
The following configuration fields have been removed:
px_custom_request_handlerpx_extract_user_ippx_send_async_activities_enabledpx_dynamic_configuration_enabledpx_cd_first_party_enabledpx_testing_mode_enabledpx_custom_template_rootpx_pxhd_secure_enabledpx_proxy_urlpx_modify_context
Updating the Node Express Enforcer Integration
In prior versions of the Node Express Enforcer:
- the module was imported from the
perimeterx-node-expresspackage - the middleware function was initialized by calling
perimeterx.init() - the middleware function was accessible via the
perimeterx.middlewareproperty
See the code sample below for the v7.x integration.
While the same basic principles of importing, initializing, and accessing the middleware still hold true in the new version of the enforcer, they are done in a slightly different way.
- The module is imported via the
@humansecurity/node-express-enforcerpackage. Note that theperimeterx-node-expresspackage is considered deprecated. - The middleware function is initialized by calling
createHumanSecurityHandler() - The middleware function is accessible via the return value of
createHumanSecurityHandler()