
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
@supertokens-plugins/progressive-profiling-nodejs
Advanced tools
Progressive Profiling Plugin for SuperTokens
Add progressive profiling functionality to your SuperTokens Node.js backend. This plugin provides APIs and session management for step-by-step user profile collection, allowing you to gather user information gradually through customizable forms and field types.
npm install @supertokens-plugins/progressive-profiling-nodejs
Initialize the plugin in your SuperTokens backend configuration:
import SuperTokens from "supertokens-node";
import ProgressiveProfilingPlugin from "@supertokens-plugins/progressive-profiling-nodejs";
SuperTokens.init({
appInfo: {
// your app info
},
recipeList: [
// your recipes (Session recipe is required)
],
experimental: {
plugins: [
ProgressiveProfilingPlugin.init({
sections: [
{
id: "basic-info",
label: "Basic Information",
description: "Tell us about yourself",
fields: [
{
id: "firstName",
label: "First Name",
type: "string",
required: true,
placeholder: "Enter your first name",
},
{
id: "lastName",
label: "Last Name",
type: "string",
required: true,
placeholder: "Enter your last name",
},
{
id: "company",
label: "Company",
type: "string",
required: false,
placeholder: "Enter your company name",
},
],
},
{
id: "preferences",
label: "Preferences",
description: "Customize your experience",
fields: [
{
id: "notifications",
label: "Email Notifications",
type: "boolean",
required: false,
defaultValue: true,
},
{
id: "theme",
label: "Preferred Theme",
type: "select",
required: false,
options: [
{ value: "light", label: "Light" },
{ value: "dark", label: "Dark" },
{ value: "auto", label: "Auto" },
],
defaultValue: "auto",
},
],
},
],
}),
],
},
});
[!IMPORTANT]
You also have to install and configure the frontend plugin for the complete progressive profiling experience.
The plugin automatically exposes these protected endpoints:
/plugin/supertokens-plugin-progressive-profiling/sections{
"status": "OK",
"sections": [
{
"id": "basic-info",
"label": "Basic Information",
"description": "Tell us about yourself",
"completed": false,
"fields": [
{
"id": "firstName",
"label": "First Name",
"type": "string",
"required": true,
"placeholder": "Enter your first name"
}
]
}
]
}
/plugin/supertokens-plugin-progressive-profiling/profile{
"status": "OK",
"data": [
{
"sectionId": "basic-info",
"fieldId": "firstName",
"value": "John"
},
{
"sectionId": "basic-info",
"fieldId": "lastName",
"value": "Doe"
}
]
}
/plugin/supertokens-plugin-progressive-profiling/profile{
"data": [
{
"sectionId": "basic-info",
"fieldId": "firstName",
"value": "John"
},
{
"sectionId": "basic-info",
"fieldId": "lastName",
"value": "Doe"
}
]
}
{
"status": "OK"
}
{
"status": "INVALID_FIELDS",
"errors": [
{
"id": "firstName",
"error": "The \"First Name\" field is required"
}
]
}
| Option | Type | Default | Description |
|---|---|---|---|
sections | FormSection[] | [] | Array of form sections with fields to collect |
type FormSection = {
id: string; // Unique identifier for the section
label: string; // Display label for the section
description?: string; // Optional description text
fields: FormField[]; // Array of fields in this section
};
type FormField = {
id: string; // Unique identifier for the field
label: string; // Display label for the field
type: FormFieldType; // Field input type (see supported types below)
required?: boolean; // Whether the field is required (default: false)
defaultValue?: FormFieldValue; // Default value for the field
placeholder?: string; // Placeholder text for input
description?: string; // Optional description text
options?: SelectOption[]; // Options for select/multiselect fields
};
The plugin supports various field types for flexible form creation:
| Field Type | Description | Value Type |
|---|---|---|
string | Single-line text input | string |
text | Multi-line text area | string |
number | Numeric input | number |
boolean | Checkbox input | boolean |
toggle | Toggle switch | boolean |
email | Email input with validation | string |
phone | Phone number input | string |
date | Date picker | string (ISO date format) |
select | Dropdown selection | string |
multiselect | Multiple selection dropdown | string[] |
password | Password input | string |
url | URL input with validation | string |
image-url | Image URL input with preview | string |
Register additional form sections programmatically:
import { registerSections } from "@supertokens-plugins/progressive-profiling-nodejs";
registerSections({
storageHandlerId: "custom-storage",
sections: [
{
id: "advanced-settings",
label: "Advanced Settings",
fields: [
{
id: "apiKey",
label: "API Key",
type: "password",
required: true,
},
],
},
],
set: async (data, session, userContext) => {
// Custom storage logic for saving profile data
const userId = session.getUserId(userContext);
await customDatabase.saveUserProfile(userId, data);
},
get: async (session, userContext) => {
// Custom storage logic for retrieving profile data
const userId = session.getUserId(userContext);
return await customDatabase.getUserProfile(userId);
},
});
Get profile data for a the session user:
import { getSectionValues } from "@supertokens-plugins/progressive-profiling-nodejs";
// In your API handler
const profileData = await getSectionValues({
session,
userContext,
});
console.log("User profile:", profileData);
Update profile data for a specific user:
import { setSectionValues } from "@supertokens-plugins/progressive-profiling-nodejs";
// In your API handler
const result = await setSectionValues({
session,
data: [
{
sectionId: "basic-info",
fieldId: "firstName",
value: "John",
},
],
userContext,
});
if (result.status === "INVALID_FIELDS") {
console.error("Validation errors:", result.errors);
}
Get all registered sections:
import { getAllSections } from "@supertokens-plugins/progressive-profiling-nodejs";
const sections = await ProgressiveProfilingPlugin.getAllSections({
session,
userContext,
});
console.log("Available sections:", sections);
Register function to filter global claim validators in all endpoints
import { registerGlobalClaimValidatorOverride } from "@supertokens-plugins/progressive-profiling-nodejs";
import { SessionClaimValidator } from "supertokens-node/recipe/session";
registerGlobalClaimValidatorOverride((globalValidators: SessionClaimValidators[]) => {
// Filter the validators.
return globalValidators;
});
Get the registered function to filter global claim validators in all endpoints
import { getFilterGlobalClaimValidatorsFn } from "@supertokens-plugins/progressive-profiling-nodejs";
const filterFn = getFilterGlobalClaimValidatorsFn();
if (filterFn !== undefined) {
// Do something with the function.
}
By default, the user profile data is handled by the user metadata through the defaultStorageHandlerSetFields and defaultStorageHandlerGetFields methods. These are used whenever sections are added through the plugin config. These methods can also be overriden in order to make use of your own storage system (database, files, third-parties, etc).
You can also implement custom storage logic for different sections:
import { registerSections } from "@supertokens-plugins/progressive-profiling-nodejs";
// Example: Store user preferences in a separate database
registerSections({
storageHandlerId: "preferences-db",
sections: [
{
id: "user-preferences",
label: "User Preferences",
fields: [
{ id: "theme", label: "Theme", type: "select", options: [...] },
{ id: "language", label: "Language", type: "select", options: [...] },
],
},
],
set: async (data, session, userContext) => {
const userId = session.getUserId(userContext);
const preferences = {};
for (const item of data) {
preferences[item.fieldId] = item.value;
}
await preferencesDatabase.updateUserPreferences(userId, preferences);
},
get: async (session, userContext) => {
const userId = session.getUserId(userContext);
const preferences = await preferencesDatabase.getUserPreferences(userId);
return Object.entries(preferences).map(([fieldId, value]) => ({
sectionId: "user-preferences",
fieldId,
value,
}));
},
});
The plugin provides built-in validation for form fields:
You can extend and customise validation by overriding the registerSections implementation method.
By default, the plugin returns the following standardized error responses:
// Missing required field
{
"status": "INVALID_FIELDS",
"errors": [
{
"id": "firstName",
"error": "The \"First Name\" field is required" // "First Name" is the label of the field that encountered the error
}
]
}
// Field not found
{
"status": "INVALID_FIELDS",
"errors": [
{
"id": "unknownField",
"error": "Field with id \"unknownField\" not found"
}
]
}
// Server errors
{
"status": "ERROR",
"message": "Internal server error"
}
FAQs
Progressive Profiling Plugin for SuperTokens
The npm package @supertokens-plugins/progressive-profiling-nodejs receives a total of 20 weekly downloads. As such, @supertokens-plugins/progressive-profiling-nodejs popularity was classified as not popular.
We found that @supertokens-plugins/progressive-profiling-nodejs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.