LifeMate — Personal, Family & Learning Companion
feat/standalone-weekly-planner
chore/phase1-repository-cleanup
deploy/stable-web-apk
deployment-static
design/mobile-accessibility-v2
design/mobile-navigation-review
docs/child-education-access-decision
docs/offline-data-rescue-options
docs/owner-guide-and-delivery-plan
docs/phase1-policy-options
docs/public-review-live-2026-10-15
feat/aparat-learning-library
feat/child-device-safety
feat/child-identity-schema
feat/flutter-mobile-navigation
feat/learning-content-operations
feat/local-signing-preflight
feat/online-family-stage0
feat/personal-encrypted-recovery
feat/private-planner-series-api
feat/public-review-page
feat/standalone-weekly-planner
feat/weekly-planner-android
final-feature-1/iran-family-school
fix/auth-abuse-expiry-safety
fix/auth-expiry-after-lock
fix/backend-request-safety
fix/lifeguide-bootstrap-naming-ci
fix/lifeguide-pages-qa-base-preflight
fix/lifeguide-qa-pages-env-deployment
fix/local-task-persistence
fix/managed-child-session-boundary
fix/personal-jalali-dates
fix/personal-notification-controls
fix/personal-upgrade-delivery-guard
fix/sms-approval-gates
fix/study-duration-display
infra/cloudflare-neon-migration
infra/lifeguide-cloudflare-qa
infra/lifeguide-github-pages-qa
infra/lifeguide-supabase-qa
main
phase-1/foundation-completion
phase-2/product-foundation-identity
phase-3/planner-school-family-core
phase-4/ai-learning-wellbeing
phase-5/hardening-observability-release
test/android-reminder-acceptance
test/personal-notification-settings
test/personal-recovery-acceptance
test/role-entry-apk
| 1 | // Experimental identity work is deliberately unavailable in production. |
| 2 | // This switch is not a consent policy or permission to use real child data. |
| 3 | export const childSandboxEnabled = env => ['test', 'development'].includes(env.NODE_ENV) |
| 4 | && env.ENABLE_CHILD_IDENTITY_SANDBOX === 'true'; |
| 5 | |
| 6 | export async function managedChildAccessActive(client, userId, issuerId, env) { |
| 7 | if (!childSandboxEnabled(env) || !issuerId) return false; |
| 8 | return (await client.query(`select 1 from managed_child mc |
| 9 | join child_consent cc on cc.child_user_id=mc.user_id and cc.revoked_at is null |
| 10 | join app_user u on u.id=mc.user_id and u.disabled_at is null and u.is_managed_child |
| 11 | join family_workspace f on f.id=mc.family_id and f.archived_at is null |
| 12 | join family_membership m on m.family_id=mc.family_id and m.user_id=mc.user_id |
| 13 | and m.ended_at is null and m.role='teen_minor' and not m.is_admin |
| 14 | where mc.user_id=$1 and is_active_guardian(mc.family_id,$2,mc.user_id)`, [userId, issuerId])).rowCount > 0; |
| 15 | } |
| 16 | |
| 17 | export function childSessionRouteAllowed(req) { |
| 18 | if (req.method !== 'GET') return false; |
| 19 | // Compare literal original paths: encoded/case/slash variants never expand |
| 20 | // these permissions. Avoid router-relative req.path and prefix wildcards. |
| 21 | const path = (req.originalUrl ?? req.url ?? '').split('?')[0]; |
| 22 | return ['/v1/profile', '/v1/families', '/v1/child-visibility', |
| 23 | '/v1/education/catalog', '/v1/calendar/iran'].includes(path) |
| 24 | || /^\/v1\/education\/units\/[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}(?:\/assessment)?$/i.test(path) |
| 25 | && path.startsWith('/v1/education/units/'); |
| 26 | } |