Registry /
auth-security / passport-sendoso-postilize
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Strategy
✓ import { Strategy as SendosoStrategy } from 'passport-sendoso-postilize';
✗ import SendosoStrategy from 'passport-sendoso-postilize';
The primary OAuth 2.0 strategy class is typically aliased to 'SendosoStrategy' for clarity in ESM. CommonJS environments use `require('passport-sendoso-postilize').Strategy`.
passport
✓ import passport from 'passport';
✗ import * as passport from 'passport';
The core Passport.js library, usually imported as a default export for direct use with `passport.use()` and `passport.authenticate()`.
Demonstrates how to configure and use the Passport-Sendoso-postilize strategy with Express, including session management, authentication routes, and user serialization/deserialization.
const express = require('express');
const passport = require('passport');
const session = require('express-session'); // Required for Passport sessions
const { Strategy: SendosoStrategy } = require('passport-sendoso-postilize'); // Using destructuring for clarity
const app = express();
// Passport configuration
passport.use(new SendosoStrategy({
clientID: process.env.SENDOSO_CLIENT_ID ?? 'YOUR_SENDOSO_CLIENT_ID',
clientSecret: process.env.SENDOSO_CLIENT_SECRET ?? 'YOUR_SENDOSO_CLIENT_SECRET',
callbackURL: "http://localhost:3000/auth/sendoso/callback",
passReqToCallback: true
},
function(request, accessToken, refreshToken, profile, done) {
// In a real application, you would typically find or create a user in your database
// based on the profile information returned by Sendoso.
// The 'profile' object would contain user details provided by Sendoso.
// For demonstration, we'll return a placeholder user.
const user = { id: profile?.id || 'sendoso_user_123', name: profile?.displayName || 'Sendoso User' };
console.log('Sendoso Profile:', profile);
console.log('Access Token:', accessToken);
done(null, user); // Call done with null for error and the user object
}
));
// Passport session setup.
// To support persistent login sessions, Passport needs to be able to
// serialize users into and deserialize users out of the session.
// Typically, this will be as simple as storing the user ID when serializing
// and finding the user by ID when deserializing.
passport.serializeUser(function(user, done) {
done(null, user.id);
});
passport.deserializeUser(function(id, done) {
// In a real application, retrieve user from database by ID
const user = { id: id, name: 'Deserialized User' }; // Placeholder
done(null, user);
});
// Middleware for Express
app.use(session({ secret: 'keyboard cat', resave: false, saveUninitialized: false }));
app.use(passport.initialize());
app.use(passport.session());
// Define authentication routes
app.get('/auth/sendoso',
passport.authenticate('sendoso', { scope: 'profile email' } // Replace 'profile email' with actual Sendoso scopes if available
));
app.get('/auth/sendoso/callback',
passport.authenticate('sendoso', {
successRedirect: '/profile', // Redirect to a profile page on success
failureRedirect: '/login' // Redirect to login on failure
})
);
app.get('/profile', (req, res) => {
if (req.isAuthenticated()) {
res.send(`<h1>Welcome, ${req.user.name || 'authenticated user'}!</h1><pre>${JSON.stringify(req.user, null, 2)}</pre><p><a href="/logout">Logout</a></p>`);
} else {
res.redirect('/login');
}
});
app.get('/login', (req, res) => {
res.send('<h1>Login with Sendoso</h1><p><a href="/auth/sendoso">Login with Sendoso</a></p>');
});
app.get('/logout', (req, res, next) => {
req.logout((err) => {
if (err) { return next(err); }
res.redirect('/login');
});
});
const PORT = 3000;
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
console.log('Visit http://localhost:3000/login to start the authentication flow.');
});
Errors
Common errors & fixes
Error: Unknown authentication strategy "sendoso"
The Passport strategy has not been correctly registered with `passport.use()` before attempting to use it.
fixEnsure `passport.use(new SendosoStrategy(...))` is called and the strategy name matches what is used in `passport.authenticate('sendoso', ...)`. OAuth2Strategy requires a clientID option
The `clientID` option was not provided or was an empty string in the `SendosoStrategy` configuration.
fixProvide a valid `clientID` string obtained from your Sendoso application registration to the `SendosoStrategy` options.
Error: Failed to obtain access token
Commonly caused by an incorrect `clientSecret`, an invalid `callbackURL` (which must exactly match the one registered with Sendoso), or network issues.
fixDouble-check your `clientSecret` and ensure your `callbackURL` in the strategy configuration precisely matches the one registered in your Sendoso application settings.
TypeError: Cannot read properties of undefined (reading 'authenticate')
The Passport middleware (`passport.initialize()` and `passport.session()`) has not been applied to the Express app, or Passport itself hasn't been imported.
fixMake sure you have `app.use(passport.initialize());` and `app.use(passport.session());` configured in your Express application middleware chain after session middleware.
Audit
Dependencies
passportrequiredCore authentication framework for which this strategy is built.