Members area with profiles and a directory
Members area: the gate, member profiles, an opt-in member directory, groups with forum threads and an activity feed, courses with per-member progress, direct messages with block and report, and an install as a phone web app
For when the answer to “People sign in to a members area: profiles, a member directory, and private groups with a forum and feed” is yes.
A members area is the place a paying or signed-up customer goes that the public does not.
Skip the rebuild
You do not write this one. It arrives in your project as ordinary source you can read, change and keep, with its audit record and its caveats beside it.
- Download the Playground. It is free and runs on your own machine.
- Start a new app and tick “People sign in to a members area: profiles, a member directory, and private groups with a forum and feed”.
- This block is written in, along with anything else you ticked.
The mistake it removes
Six, and all are quiet. A members gate with no real identity behind it denies nothing while looking complete, so the gate refuses to be built without the host app's own account lookup and stays closed when that lookup breaks. A directory that lists every member publishes a list of your customers, so being listed is opt-in and a profile is shown through an allowlist. And a group post shown to anyone outside the group is a private conversation leaked: every read and write in community.js checks membership on the server at the moment of the request, the home feed is built only from the caller's own groups, an invite-only group answers a stranger exactly as a missing one does, and the handlers take the account from the gate and ignore any accountId a caller writes into the request. Courses follow the same rule: a lesson is readable only by someone the course's gate lets in, checked at every request, a hidden course answers exactly like a missing one, an entitlement course with no entitlement check lets nobody in, and progress is keyed by the member's own account with no way to ask for anyone else's. And a direct message shown to anyone but its two participants is the most private leak of all: every read in messages.js checks that the caller is one of the two, an outsider is answered exactly as if the conversation did not exist, a member can open a conversation only with someone they share a group with, a block stops new messages both ways without announcing itself and can name only a member the blocker shares a group or a conversation with, a member reports a given message once, and the notifier the host passes never receives the words. And an installed members app can leak on a shared phone: a service worker that cached what it saw would hand the last member's feed or messages to the next person who opens it offline. node/pwa.js caches only the shell the host names, fetches it without cookies, refuses any shell answer marked private, no-store or varying by Cookie or Authorization, never touches the members API, and drops its cache on the sign-out message.
What the audit found
Named rather than summarized. The reasoning behind each one ships inside the block, so it travels with the code instead of living on a page you have to trust. A finding marked fixed was fixed after the audit ran; the verdict above is still the one the audit gave.
- No path erases one member, while block.json declares category 8 coverage "full" major · Privacy & data (8) / Claims (25) Fixed after the audit in
5b7154b27 - Role changes and member removals leave no record of who did it or what changed major · Security (1): audit trail Fixed after the audit in
0e135f9b0 - List endpoints with no page size, and myCourses fans out one host call per course major · Correctness (2): API shape Fixed after the audit in
825e52809 - report and block are uncapped and undeduplicated: one member can write unbounded 5 KB records major · API cost & abuse (12) / Durable growth (29) Fixed after the audit in
1f12660cb - The documented escape "set a large max" crashes the limiter once a window holds ~125k stamps minor · Correctness (2) / Claims (25) Fixed after the audit in
d3fa1f086 - publicProfile passes avatarUrl through with no scheme check minor · Security (1) Fixed after the audit in
b6822899a - community.js and courses.js build store keys from raw ids while messages.js and takeRateSlot encode them minor · Code quality (9) / Correctness (2) Fixed after the audit in
448e61a8c - Zero surviving mutants, but no test starts at the block's real store contract minor · Verification integrity (28) Fixed after the audit in
f6e2675a2
What you still have to do
A copied file cannot own your secrets, your host or your legal obligations. This is the part the block deliberately does not claim.
- A request limiter in front of every handler, per IP or per session. This block limits each member: posting per group (test/community.test.mjs section 10), and creating groups, joining, inviting and reading (section 11), creating courses and reading courses (test/courses.test.mjs section 8), sending and reading direct messages (test/messages.test.mjs section 11), and blocking and reporting (section 12). Adding and completing lessons are limited too (test/courses.test.mjs section 11). Those counts are per account, so one person with many accounts gets many allowances. Each count is taken under a per-key lock, so a burst against one server process gets exactly the limit (test/race.test.mjs, raced on three stores); a host running several server instances on one store is covered only when its store offers the optional atomic update(key, fn), which every per-member count then uses (test/race.test.mjs section 5, two servers over one store). Blocking and reporting are bounded by key as well as by rate: a member reports a given message once (a repeat returns the first report), blocks only someone they share a group or a conversation with, and keeps at most 500 accounts on their block list (MAX_BLOCKS_PER_ACCOUNT in node/messages.js).
- A real database behind the four store methods. memoryStore() keeps groups, posts, courses and progress in process memory and loses all of them on a restart or a new serverless instance; it exists for tests and local development only.
What lands in your project
node
- node/members.js
- node/community.js
- node/courses.js
- node/messages.js
- node/pwa.js
No package is imported and no database is assumed. members.js is pure functions: requireMember(resolveAccount) builds the gate from the host app's own account lookup; publicProfile, directory and canEditProfile take plain objects. community.js takes a store with four async methods (get, set, del, list by prefix), ships memoryStore() as a reference for tests and local development, exports communityHandlers({ gate, community }) as framework-free route handlers, and limits posting to postLimit ({ max, windowMs }, default 10 in 60 seconds) per member per group. Every service also takes limits: per-member sliding windows on group creation, joins, invites and reads (community.js), course creation, adding lessons, completing lessons and reads (courses.js), and sending, reads, blocks and reports (messages.js), with the defaults exported as DEFAULT_LIMITS, DEFAULT_COURSE_LIMITS and DEFAULT_MESSAGE_LIMITS. courses.js takes the same store plus the host's optional hasEntitlement(account, entitlement) and canAuthor(account), and exports courseHandlers({ gate, courses }). messages.js takes the same store plus a REQUIRED notify({ toAccountId, fromAccountId, conversationId, messageId }), which never carries the message text, and exports messageHandlers({ gate, messaging }); reports() is for the host's moderators and has no route handler. To erase one member, the host calls eraseAccount(accountId) on community, courses and messaging alike: memberships, invites, progress, conversation pointers, blocks and rate records are deleted, and the member's posts and messages keep their place with the words blanked and the author replaced by a fresh random id. Reports and community audit records are kept with the member's id replaced the same way. setRole, removeMember, leaveGroup and deletePost each write an append-only audit record under audit:<groupId>:<auditId> before the change; the host reads a group's trail with store.list('audit:<groupId>:'). eraseAccount has no route handler; who may erase is the host's decision. Lists that can grow come back one page at a time: discoverGroups, myGroups, myConversations, myBlocks and reports() take { limit, cursor } (50 by default, never more than 200, a bad one is a 400) and answer nextCursor, and the handlers read limit and cursor from the query. A thread's replies come the same way. The group feed, a thread, the home feed and a conversation read newest-first index records (threadhead/threadpage, replyhead/replypage, dmhead/dmpage) through get and never list a group's posts or a conversation's messages, so a page reads about one record per item on it; the feeds answer nextBefore, the before for the next page. Data written before those indexes (schemaVersion 1) is indexed the first time its group or conversation is used. myCourses reads the caller's own groups and a per-gate course index, and calls hasEntitlement once per distinct entitlement, not once per course. Every read-then-write count runs under withKeyLock(key) (community.js), one at a time per key in the process, so a simultaneous burst against one server lets exactly the limit through. That lock does not reach a second server instance, so the store may offer a fifth, optional method, update(key, fn): fn(current) is synchronous, returns the next value (undefined deletes the key), and may be called more than once by a store that retries on a conflict. When the store has it, every per-member rate count goes through it, and a burst spread over several servers on one store lets exactly the limit through too (test/race.test.mjs section 5); memoryStore() has one. Lesson numbering and the lesson completion record span more than one key and stay on the in-process lock. pwa.js exports membersManifest, membersServiceWorker, pwaHandlers and membersRegisterSnippet: the host mounts the manifest at <scope>manifest.webmanifest and the worker at <scope>sw.js, outside the members gate since neither holds member data, and posts the sign-out message from its sign-out page. The scaffold copies these five files into a new app's server/blocks/ and mounts none of their handlers, the same as every other block: the host mounts communityHandlers, courseHandlers, messageHandlers and pwaHandlers on its own router, behind its own gate and store.
What you supply
- resolveAccount: the host app's function from a request to { accountId, ... } or null: the account (F74.1) the members area keys on; there is no login in this block
- listed: a per-profile boolean the member sets; only true appears in the directory
- store: the host's store for groups, memberships, posts, courses, lessons and progress: an object with async get(key), set(key, value), del(key) and list(prefix), and optionally update(key, fn), an atomic change of one key that a host running more than one server instance needs for its rate counts to stay exact. memoryStore() loses everything on restart and is for tests and local development only. A real store should answer list(prefix) with a bounded range query over an ordered key index, not a scan of the whole table: the pages bound what a caller gets back, only the store can bound what it reads
- postLimit: { max, windowMs }: how many posts one member may write in one group within a sliding window. Default 10 in 60 seconds. It cannot be switched off; the escape for a loose limit is a large max, at most 100,000 (LIMIT_MAX_CEILING), and a larger one is refused at build time
- limits: per service, an object of { max, windowMs } by name, each a per-member sliding window. createCommunity: createGroup (default 5 an hour), join (30 an hour), invite (50 an hour), read (300 a minute). createCourses: createCourse (10 an hour), addLesson (100 an hour), completeLesson (60 a minute), read (300 a minute). createMessaging: send, counting sends and replies together (20 a minute), read (300 a minute), block (30 an hour), report (30 an hour). A name left out keeps its default; none can be switched off, and max is at most 100,000 (LIMIT_MAX_CEILING)
- hasEntitlement: the host app's async function (account, entitlement) -> true when the account holds it, for courses gated to an entitlement such as a paid plan. Without it an entitlement course lets nobody in, and one that throws answers 503
- canAuthor: the host app's async function (account) -> true for accounts allowed to create entitlement courses. Group courses are written by the group's owner and moderators
- notify: the host app's async function that tells a member a message arrived (an email, a push). Required; pass one that does nothing to send no notifications. It gets ids only, never the words, and one that throws leaves the message sent
- pwa: membersManifest({ name, icons, scope = '/members/', themeColor, backgroundColor }) needs your own 192x192 and 512x512 icons; membersServiceWorker({ version, shell, offline, scope }) takes a version to change on every release and the static shell paths inside the scope, the same for every member. Never list a page that shows a member's own data in shell.
Licensed MIT. It is a starting point, not a finished product.
Get it
Download the Playground See the other blocks
Nothing here is locked. The files are yours, in your folder, under a permissive license.
Questions
- Is Members area with profiles and a directory audited?
- It was audited on 2026-09-29, and the verdict was not a clean pass. 8 findings have been fixed since then, and the verdict stands until the block is audited again.
- What do I still have to do myself?
- A request limiter in front of every handler, per IP or per session. This block limits each member: posting per group (test/community.test.mjs section 10), and creating groups, joining, inviting and reading (section 11), creating courses and reading courses (test/courses.test.mjs section 8), sending and reading direct messages (test/messages.test.mjs section 11), and blocking and reporting (section 12). Adding and completing lessons are limited too (test/courses.test.mjs section 11). Those counts are per account, so one person with many accounts gets many allowances. Each count is taken under a per-key lock, so a burst against one server process gets exactly the limit (test/race.test.mjs, raced on three stores); a host running several server instances on one store is covered only when its store offers the optional atomic update(key, fn), which every per-member count then uses (test/race.test.mjs section 5, two servers over one store). Blocking and reporting are bounded by key as well as by rate: a member reports a given message once (a repeat returns the first report), blocks only someone they share a group or a conversation with, and keeps at most 500 accounts on their block list (MAX_BLOCKS_PER_ACCOUNT in node/messages.js).
- How do I get this code?
- Download the Playground, start a new app, and tick “People sign in to a members area: profiles, a member directory, and private groups with a forum and feed”. The block is written into your project as ordinary source you can read and edit.
All pre-built code blocks · Learn to build from zero · The coding guide