Changelog
โจ Addedโ
Documentation siteโ
- Overview: layered architecture, namespace exports, composition patterns, and links to all major sections.
- Quickstart: end-to-end bootstrap with
authServiceandprofileServiceagainst SDK 0.13.0. - Concepts: error handling and functional programming.
- How-to guides: custom service, composite service, custom datastore, WebSocket service, and schema override.
- Components: service, schema, handler, route, feature, blocks, validator, middleware, types, and driver references.
- Block catalogue: responsibility tables for all 18 block domains and how reference pages fit together.
Services (12)โ
- Authentication, Profile, Identity, Organization, Product, Order, Category, Attribute, Chat, Location, Address, and Notification.
Block integration guides (18)โ
- Mountable services: Authentication, Profile, Identity, Organization, Product, Order, Category, Attribute, Chat, Location, Address, and Notification.
- Auth-composed: OAuth and Invitation.
- Foundation modules: Common, Mongo, File Storage, and Avatar.
Block reference pages (~82 pages)โ
- Source-verified routes, schemas, features, handlers, validators, and blocks pages where the SDK exports that layer; each domain Reference map lists its exact set (for example, Category and Attribute omit
blocks.md; Identity omitshandlers.md; Invitation and OAuth omit domain validator pages). - Validators alignment: standardized inventory tables across 13 entity
validators.mdfiles (identity reference contract). - Schemas alignment: standardized section order and inventory tables across block
schemas.mdfiles; Common schemas consolidated from nestedblocks/common/schemas/pages into a single reference. - Deep route and handler references for high-traffic domains (for example, Authentication routes, Product routes).
- Removed legacy
blocks/user/documentation tree; replaced byblocks/profile/with full reference pages.
Component, utility, and driver referenceโ
- Composition utilities:
defService, WebSocket routing,withSoftDelete, andmapMatchingErrorToFalse. - Auth, cookie, cache, and schema utilities:
whenCookieAuth, cookie-mode branching, LRU caching, and query-filter hardening. - New component pages: middleware and types.
- Route, schema, and blocks component pages aligned with SDK source patterns.
- Drivers index and references: drivers overview, mail-service, file-storage, database, OAuth, and Japan Post.
Reference depth and consistencyโ
- Unified block
index.mdcontract: Start here โ Common tasks โ Reference map โ Related modules, with Bearer/Cookie/Custom HTTP workflow examples on mountable services. - 12 alignment/audit scripts in
scripts/(align-*-md.mjs,audit-*-md.mjs); 2 wired inpackage.jsonasalign:index-mdandaudit:index-md.
๐ Changedโ
Naming and importsโ
- User โ Profile across services, collections, routes, and examples (
profileService,profilescollection,/profilespaths). See Profile service and Profile blocks. - Removed the legacy
blocks/user/documentation tree; all user-domain reference now lives underblocks/profile/. - Namespace-only imports in canonical integration examples:
import { services, primitives, drivers, validators } from '@nodeblocks/backend-sdk'. Flat root imports and deprecateduserServicenames are removed from those guides.
Authentication configurationโ
- Token lifetimes documented through
accessTokenSignOptions,refreshTokenSignOptions, andonetimeTokenSignOptions(replacing flat expiry keys). Default access-token lifetime is 15m (older 2h defaults are no longer shown). See Authentication index and auth utility. - Cookie auth (0.13.0):
authMode: 'cookie', hostcookie-parser, per-serviceauthModeon protected CRUD services, and cookie-mode login/refresh/logout response shapes. See cookie utility.
API response shapesโ
- Paginated list endpoints document
{ data, metadata: { pagination } }instead of legacy{ count, total, value }envelopes. See Common schemas.
How-to, concepts, and componentsโ
- Composite service, custom datastore, and related guides updated for Profile naming and current service factories.
- Error handling aligned with current
NodeblocksError,BlockError, andResultpatterns from source. - Functional programming documents block-first composition versus legacy handler routes, with links to Route ยป Handler-based routes (legacy).
๐ Fixed (documentation corrections)โ
- Configuration naming:
identity.typeIdsand related auth configuration examples corrected from legacyuser.typeIdspatterns in service and integration guides. - Request and response contracts: service and route pages updated after source audits (organization members, auth logout/email templates, order admin create, product and organization list envelopes, chat attachments, and related examples).
- Change-email behavior: enumeration-hardening flow documented with
mapMatchingErrorToFalseon Authentication routes.
SDK 0.13.0 (2026-07-14)โ
โจ Addedโ
Servicesโ
- Optional
authMode?: 'bearer' | 'cookie'on protected CRUD / domain service configurations (attributes, profile, product, category, organization, location, order, chat, identity, notification, address). WhenauthModeis'cookie', each service wiresgetCookieTokenInfointocontext.authenticate; otherwise it usesgetBearerTokenInfo. See Authentication service and mountable domain integration guides.
Authenticationโ
checkIp?: boolean(defaulttrue) onAuthenticationServiceConfiguration; bothgetBearerTokenInfoandgetCookieTokenInfohonor this option. See Authentication service.whenCookieAuthutility (exported from utils) branches a composed handler between cookie-mode and bearer-mode implementations based onauthMode.context.authenticatetyped field onServiceContext/ServiceDefinition, populated withgetCookieTokenInfoorgetBearerTokenInfodepending onauthMode.- Standalone
logoutFeature, selectinglogoutCookieSchemaorlogoutBearerSchemaat compose time based onauthMode. refreshTokenBearerSchemaandrefreshTokenCookieSchema;refreshTokenSchemaremains as a deprecated alias forrefreshTokenBearerSchema.cookieOpts.httpOnlyandcookieOpts.secureare now configurable (previously hard-coded totrue).
๐ Changedโ
Authenticationโ
- Session cookie
maxAgeis derived automatically from each token'sexpiresIn(accessTokenSignOptions/refreshTokenSignOptions) when cookies are set, so the cookie and token always expire together. loginWithCredentialsRoute: cookie mode returns only{ id }in the response body; tokens are delivered viaSet-Cookie. Bearer mode is unchanged ({ accessToken, id, refreshToken }).refreshTokenRoute: cookie mode sets refreshed cookies and returns 204 with an empty body; bearer mode is unchanged (200 { accessToken, refreshToken }).setResponseCookiederives access-token and refresh-token cookie options independently fromaccessTokenSignOptions.expiresIn/refreshTokenSignOptions.expiresIn, instead of sharing a single set of options.
๐ Fixedโ
Authenticationโ
logoutRoute: clearsaccessTokenandrefreshTokencookies unconditionally, instead of only when a refreshToken cookie was present on the request; resolves the caller's identity viacontext.authenticate(cookie- or bearer-aware); treats an already-revoked refresh token as success instead of error; returns success when no refresh token can be resolved instead of error.deactivateRoute: reads the access token from theaccessTokencookie in cookie mode instead of always requiring anAuthorizationheader.
Organizationโ
createChangeRequestRoute: reads the access token from theaccessTokencookie in cookie mode instead of always requiring anAuthorizationheader.
๐ Securityโ
- Removed an undocumented bypass in
getCookieTokenInfothat accepted an app-typeAuthorization: Bearertoken to skip cookie/session validation entirely. getCookieTokenInfono longer hard-codescheckIp: false; cookie-authenticated user tokens are IP-checked by default like bearer tokens.
๐ฆ Migrationโ
- Cookie auth hosts: Setting authMode: 'cookie' on authentication alone is not enough. Pass authMode: 'cookie' on every mounted protected service that must accept cookie sessions, and register cookie-parser middleware.
- Cookie-mode clients: Read access/refresh tokens from Set-Cookie response headers on POST /auth/login and POST /auth/token/refresh; they are no longer present in the response body.
- Manual loginWithCredentialsFeature compositions: Add logoutFeature explicitly to keep POST /auth/logout (the authService factory already does this automatically).
- Access token lifetime: If you relied on the default 2h access token lifetime, set
accessTokenSignOptions: { expiresIn: '2h' }explicitly โ the default is now 15m. - Cookie auth IP checks: If your deployment's client IP can legitimately change between requests (e.g. some proxies or mobile networks), set checkIp: false explicitly in AuthenticationServiceConfiguration.
- Removed validators: Replace any direct imports of validateResourceAccess, validateOrganizationAccess, validateOrderAccess, validateMessageAccess, validateChannelAccess, verifyAuthentication, requireParam, isUUID, or isNumber with their current equivalents (isAuthenticated, hasOrgRole, ownsResource, ownsOrder, ownsMessage, ownsChannel, etc.).
โ ๏ธ Breaking Changesโ
- Authentication:
AuthenticationServiceConfiguration.cookieOpts.maxAgehas been removed. Cookie lifetime follows the matching token'sexpiresIn. Remove anycookieOpts.maxAgeconfiguration. - Authentication: Default
accessTokenSignOptions.expiresInchanged from2hto15m. - Authentication:
loginWithCredentialsFeatureno longer composeslogoutRoute. Custom compositions built directly onloginWithCredentialsFeature(outsideauthService) must addlogoutFeatureseparately. - Authentication: Cookie-mode login and refresh no longer return tokens in the response body.
- Authentication:
getCookieTokenInfono longer acceptsAuthorization: Beareras a bypass path for cookie auth. - Validators: Removed unused legacy validator exports from Common validators:
validateResourceAccess,validateOrganizationAccess,validateOrderAccess,validateMessageAccess,validateChannelAccess,verifyAuthentication,requireParam,isUUID, andisNumber.
SDK 0.12.0 (2026-07-07)โ
๐ Fixedโ
Authenticationโ
completePasswordResetRoute: revokes all active refresh tokens when a user resets their password to invalidate existing sessions across all devices.changePasswordRoute: revokes all active refresh tokens when a user changes their password.- Fingerprint security check:
tokenPassesSecurityChecktreatsundefinedand''as equivalent; token generation normalizes fingerprint to''at generation time. logoutRoute: clears auth token cookies only when refresh token revocation succeeds.
๐ Changedโ
Authenticationโ
softDeleteRefreshTokenssetsdeletedAtinstead ofdelFlgto align with refresh token revocation checks.refreshTokenRoute: rotates refresh tokens on each use (newjti+ DB row); returns 401 on reuse of a revoked refresh token without revoking other device sessions; usesresolveRefreshTokenFromRequestfor cookie/body resolution.logoutRoute: revokes the presented refresh token (cookie or body) after verifying it belongs to the authenticated identity.- Cookie-based refresh reads fingerprint from the
x-nb-fingerprintheader (same as body path) and runs IP/UA checks. See cookie utility.
โ ๏ธ Breaking Changesโ
- Cookie-based refresh (
refreshTokenRoute) and cookie-based logout (logoutRoute) require thex-nb-fingerprintheader.request.body.fingerprintis no longer read on the cookie path.
SDK 0.11.0 (2026-05-26)โ
โจ Addedโ
Combinatorsโ
mapMatchingErrorToFalse: maps only a specific matched error class took(false), replacing the previousmapErrorToFalsewhich converted all errors.
๐ Changedโ
Profile (formerly User)โ
- Renamed user handlers, blocks, routes, schemas, features, and service to profile. See Profile service and Profile blocks.
- Updated
userscollection references toprofilesin organization and product routes and services. - Removed deprecated
validateUserProfileAccessvalidator. - Updated return type for
getProfileById.
๐ Securityโ
Change Emailโ
changeEmailRoute: returns 204 instead of an error when the requested email address is already in use, preventing email enumeration.- Uses
mapMatchingErrorToFalseto convert only conflict errors took(false).
โ ๏ธ Breaking Changesโ
- Profile rename:
userservice, routes, blocks, schemas, and features are renamed toprofile. Update all imports fromuser*toprofile*. - Validators:
validateUserProfileAccesshas been removed. Use the updated Profile validators instead. - Combinators:
mapErrorToFalseis renamed tomapMatchingErrorToFalseand requires an error class as the first argument.
SDK 0.10.0 (2026-03-17)โ
โจ Addedโ
Notification Managementโ
- New service: Notification service.
- New endpoints:
GET /notifications/identities/:identityIdโ find notifications with pagination. See Notification routes.POST /notifications/:notificationId/readโ mark a single notification as read.POST /notifications/identities/:identityId/readโ batch mark as read up to an anchor notification.
- Notification blocks for create, bulk create, find, get, single update, and batch update operations.
Address Lookupโ
- New service: Address service with Japan Post driver.
- New endpoint:
GET /addressesโ find a Japanese address by postal code. See Address routes. - Reusable in-memory LRU cache utility for address lookup results.
Organization Member Protectionโ
- Validators to prevent removing the last owner from an organization.
- Role-assignment validation so members cannot assign roles above their own rank.
- Same-or-above role validation before deleting organization members. See Organization validators.
๐ Fixedโ
Identityโ
getIdentityRoute: prevents matching token records stored in the identities collection by excluding documents withjti.
Address Lookupโ
- Japan Post postal code handling requires a full 7-digit code at lookup time.
- Returns
nullfor ambiguous town names instead of guessing when multiple towns share the same postal code.
๐ Changedโ
Authentication Configurationโ
- Replace string-based expiration settings with
accessTokenSignOptions,refreshTokenSignOptions, andonetimeTokenSignOptions. See Authentication service and auth utility. - Apply shared one-time token signing options across password reset, email change, MFA, and OAuth flows.
Authorization Rulesโ
- Strengthen organization member upsert and delete routes with additional role hierarchy checks.
SDK 0.9.1 (2026-01-22)โ
โจ Addedโ
Authenticationโ
- Password validation to check new password is not the same as the current password.
- Separate bcrypt compare and matches logic into two blocks; new
assertDoesNotMatchblock for password-must-not-match flows.
Schema Validationโ
- Handle type-less schemas with object-related keywords in
applySchemaDefaults. - Support for union types including
objectin schema validation.
๐ Changedโ
- Enhanced OpenAPI schema generation with improved tag propagation and nullable schema support.
๐ Securityโ
- MongoDB query filter validation for NoSQL injection protection. See schema utilities and Schema component (
queryFilterhardening).
SDK 0.9.0 (2025-11-04)โ
โจ Addedโ
Location Managementโ
- New service: Location service.
- New endpoints:
POST /locations,GET /locations/:locationId,PATCH /locations/:locationId,DELETE /locations/:locationId,GET /locations. See Location routes. - Parent-child relationship handling with automatic ancestors calculation.
Profile Follow Systemโ
- New endpoints:
PUT /profiles/:profileId/profile-follows/:followProfileIdโ create profile follow. See Profile routes.DELETE /profiles/:profileId/profile-follows/:followProfileIdโ delete profile follow.GET /profiles/:profileId/followersโ get profile followers with pagination.
Organization Follow Systemโ
- New endpoints:
PUT /profiles/:profileId/organization-follows/:followOrganizationIdโ create organization follow.DELETE /profiles/:profileId/organization-follows/:followOrganizationIdโ delete organization follow.GET /organizations/:organizationId/followersโ get organization followers. See Organization routes.
Product Like Systemโ
- New endpoints:
PUT /profiles/:profileId/product-likes/:likeProductIdโ create product like.DELETE /profiles/:profileId/product-likes/:likeProductIdโ delete product like.GET /products/:productId/likersโ get product likers. See Product routes.
Chat Message Template Managementโ
- New endpoints:
GET /message-templatesโfindChatMessageTemplatesRoute.GET /organizations/:organizationId/message-templatesโfindChatMessageTemplatesForOrganizationRoute.PATCH /message-templates/:messageTemplateIdโupdateChatMessageTemplateRoute.DELETE /message-templates/:messageTemplateIdโdeleteChatMessageTemplateRoute.
Product Variant Bulk Operationsโ
- New endpoints:
POST /products/:productId/variants/bulk,PATCH /products/:productId/variants/bulk,DELETE /products/:productId/variants/bulk,GET /products/:productId/variants. See Product routes.
Find Endpointsโ
GET /profiles/identities/:identityIdโ find profiles by identity ID.GET /organizations/:organizationId/ordersโ find orders by organization ID.GET /organizations/:organizationId/productsโ find products by organization ID.
Identity Lock/Unlockโ
- New endpoints:
POST /identities/:identityId/lockโlockIdentityRoute.POST /identities/:identityId/unlockโunlockIdentityRoute.
Chat Channel Icon Managementโ
- New endpoint:
GET /channels/:channelId/icon-upload-urlโgetChatChannelIconUploadUrlRoute.
Soft Deleteโ
withSoftDeletecombinator for MongoDB collections with automatic filtering and audit trail.
๐ Fixedโ
- Add missing
updatedAt/createdAttimestamps to all create and update operations. - Cast IDs to strings in all database queries for security.
๐ Changedโ
- Chat message updates restricted to message owners only (admin override removed). See
updateChatMessageRoute. - Entity creation simplified: messages and products created without attachments/images; attachments managed via dedicated endpoints.
SDK 0.8.0 (2025-09-24)โ
โจ Addedโ
Product Variant Managementโ
- New endpoints:
POST /products/:productId/variantsโ create product variant.GET /products/:productId/variants/:productVariantIdโ get product variant by ID.PATCH /products/:productId/variants/:productVariantIdโ update product variant.DELETE /products/:productId/variants/:productVariantIdโ delete product variant.
- See Product features and Product routes.
Organization Change Request Systemโ
- New endpoints:
createChangeRequestRoute:POST /organizations/:organizationId/change-requests.findChangeRequestsForOrganizationRoute:GET /organizations/:organizationId/change-requests.
Organization Managementโ
updateOrganizationAsAdminRoute:PATCH /admin/organizations/:organizationId/.- Certificate image URL added to normalized organization responses.
Multi-Factor Authentication (MFA)โ
- New endpoints:
resendMfaCodeRoute:POST /auth/mfa/resend.verifyMfaCodeRoute:POST /auth/mfa/verify.
- MFA enabled via
isMfaEnabled: truein service configuration. See Authentication features.
One-Time Token (OTT) Authenticationโ
loginWithOnetimeTokenRoute:POST /auth/ott/login.- OAuth callback flow returns one-time tokens; frontend exchanges via OTT login endpoint.
Pagination Systemโ
- Restructured
PaginationResult<T>to separate data and metadata. - List endpoints return
{ data, metadata: { pagination } }instead of legacy{ count, total, value }. paginationQueryParametersSchemaandpaginationSchemafor standard query parameters and metadata.findOrganizationMembersRoute: embedded pagination viawithPaginatedProperty.
๐ Fixedโ
- WebSocket IP address availability in WebSocket requests.
- Pagination metadata return issues.
SDK 0.7.0 (2025-09-12)โ
โจ Addedโ
Chat Message Attachmentsโ
- New endpoints:
createChatMessageAttachmentRoute:POST /messages/:messageId/attachments.deleteChatMessageAttachmentRoute:DELETE /messages/:messageId/attachments/:attachmentId.getChatMessageAttachmentUploadUrlRoute:GET /messages/:messageId/attachment-upload-url.
Chat Channel Messagesโ
getChannelMessagesRoute:GET /channels/:channelId/messages.
Chat Read Receiptsโ
upsertChatChannelReadStateRoute:PUT /channels/:channelId/read-state.
Chat WebSocket Subscriptionโ
streamChatMessagesRoute: WebSocket/messages/listenfor real-time message streaming.
LINE OAuth Authenticationโ
- New endpoints:
lineOAuthRoute:GET /auth/oauth/line.lineOAuthCallbackRoute:GET /auth/oauth/line/callback.
Product Image Managementโ
- New endpoints:
POST /products/:productId/imagesโ create product images.DELETE /products/:productId/images/:imageIdโ delete product image.
- See Product routes.
Blocksโ
- Chat read-state blocks:
createChatChannelReadState,updateChatChannelReadState,findChatChannelReadStates, and query/payload builders. - Chat message blocks:
createChatMessage,getChatMessageById, attachment CRUD, and normalization helpers. - Product blocks:
getProductById,findProducts, image normalization helpers. - OAuth blocks:
requestLineOAuth,authenticateLineOAuth,verifyLineOAuth. normalizeFile: centralized file normalization utility.
๐ Changedโ
- Chat and product normalization refactored to use centralized
normalizeFileutility. - Entity creation simplified: core messages and products created without attachments/images; attachments managed via dedicated endpoints.
๐ Fixedโ
- Chat attachment normalization in update responses; security ID casting; admin access restrictions for attachment operations.
- OAuth: Google and Twitter flows fixed to use provider/providerId instead of email workarounds.
SDK 0.6.0 (2025-08-28)โ
๐ฅ Demo Videoโ
๐น NodeBlocks Backend SDK v0.6.0 Demo โ Complete walkthrough of all new features and functionality.
โจ Addedโ
Chat Message Template Systemโ
- New endpoints:
createChatMessageTemplateRoute:POST /message-templates.getChatMessageTemplateRoute:GET /message-templates/:messageTemplateId.
- Blocks:
createChatMessageTemplate,getChatMessageTemplateById. - Features:
createChatMessageTemplateFeature,getChatMessageTemplateFeature. - Schemas:
createChatMessageTemplateSchema. - Validators:
hasOrganizationAccessToMessageTemplate.
Twitter OAuth Authenticationโ
- New endpoints:
twitterOAuthRoute:GET /auth/oauth/twitter.twitterOAuthCallbackRoute:GET /auth/oauth/twitter/callback.
- Drivers:
createTwitterOAuthDriver,verifyTwitterCallback.
Refresh Token Systemโ
- New endpoints:
refreshTokenRoute:POST /auth/token/refresh.deleteRefreshTokensRoute:DELETE /auth/:identityId/refresh-tokens.
WebSocket Support with RxJSโ
- Enhanced
defServiceto support WebSocket server integration. - WebSocket route handling with RxJS bridging;
protocol: 'ws'routes alongside HTTP routes. notFromEmitterandmarkAsFromEmitterfor emitter-based message filtering.
๐ Changedโ
Servicesโ
- Authentication service: added Twitter OAuth support and refresh token functionality; updated datastore to include
chatMessageTemplatescollection.
๐ Fixedโ
- Organization blocks export issue.
refreshTokenRoute: removedisAuthenticatedvalidator from refresh flow.- Configuration property names corrected (
user.typeIdsโidentity.typeIds;user?: stringโregular?: string).
Migration guide (upgrading from 0.6.x docs)โ
- Install
@nodeblocks/backend-sdk@^0.13.0and follow the Quickstart. - Replace
userService,/users, anduserscollection examples withprofileService,/profiles, andprofiles. - Replace flat token expiry keys with
accessTokenSignOptions,refreshTokenSignOptions, andonetimeTokenSignOptions. SetaccessTokenSignOptions: { expiresIn: '2h' }explicitly if you still need a 2h access token. - For cookie sessions, set
authMode: 'cookie'on Authentication and every protected service you mount, registercookie-parserbefore those routers, and read tokens fromSet-Cookieon login/refreshโnot from JSON bodies. - Replace removed validator imports (
validateResourceAccess,verifyAuthentication,requireParam, and similar) with current exports documented under Common validators and domain validator pages. - Use the block catalogue and domain Reference map tables to find the current route, schema, and validator contracts for each endpoint.
- Send the
x-nb-fingerprintheader on cookie-mode refresh and logout requests (SDK 0.12.0). - Add
logoutFeatureto custom compositions built onloginWithCredentialsFeatureoutsideauthService(SDK 0.13.0). - Remove
cookieOpts.maxAge; cookie lifetime follows the matching tokenexpiresIn(SDK 0.13.0). - Replace
mapErrorToFalsewithmapMatchingErrorToFalse(errorClass, [...])(SDK 0.11.0); see composition utilities.
Breaking documentation changesโ
- Versioned snapshots under
backend_versioned_docs/version-0.6.0andversion-0.7.0remain historical references. New integrations should use canary v2 docs at/v2/backend/next. - Examples no longer show flat SDK imports,
user*service names, or legacy pagination envelopes. - Cookie-mode login and refresh examples no longer return access or refresh tokens in response bodies; clients must use session cookies instead.
Security documentation updatesโ
- Cookie auth no longer documents an undocumented Bearer bypass on cookie-protected routes; IP checking defaults to enabled via
checkIpunless explicitly disabled. See Authentication service. - Change-email responses document 204 instead of conflict errors to reduce email enumeration; see Authentication routes.
- Organization member protection, notification ownership, and address lookup validation are documented with current access rules on their respective validators and routes pages.