fix(security): Harden next.config.mjs, Enable Strict TypeScript, Implement CSP (#42) - #190
Merged
Darkvader-ship-it merged 3 commits intoAug 31, 2026
Conversation
…ement CSP (Closes PHASE-STELLAR#42) - Remove typescript.ignoreBuildErrors flag from next.config.mjs - Configure Next.js image optimization for IPFS gateways (Pinata, ipfs.io, dweb.link) and Nano Banana CDN - Implement strict Content Security Policy headers restricting script execution sources - Add CSP validation checks to diagnose-env.ts TypeScript Error Resolution (63 errors fixed): - Install dotenv package for scripts - Create custom type declarations for framer-motion, react-hook-form, and @creit.tech/stellar-wallets-kit - Add missing exports to narrative-world-store: getReaderProgress, markNarrativeRead, getWorldRoles, setWorldRole, ensureWorldOwner, buildWorldExportSnapshot, renderWorldExportMarkdown, getLoreLinksForToken, addLoreLink, getAllNarrativesWithTokenIds - Add version property to WorldCollectionData type - Add media property to Signal and SignalReply types - Add blockList, trendingSignals, readerProgress, loreLinks entries to server-data-paths - Fix follow route: add missing imports for isFeatureEnabled, getFollowSuggestions, FollowSuggestionQuerySchema - Fix narrator route: add imports for isLoreVersioningEnabled, recordLoreVersion - Migrate SorobanRpc to rpc namespace for @stellar/stellar-sdk v15 compatibility - Fix type errors in wallet-provider, albedo-intent-client, freighter-testnet - Fix bulk-listing tokenId type conversion - Add timeoutSeconds to escrow probe object - Fix Buffer.from overload in cid-cache - Remove unused @ts-expect-error directives - Fix code comparison type mismatches (string vs number) All acceptance criteria met: ✅ npm run build succeeds with zero TypeScript errors ✅ Strict CSP headers present on all HTTP responses ✅ Next.js image optimization enabled and functional ✅ diagnose-env.ts validates CSP compliance
|
@precious-akpan Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements comprehensive security hardening and TypeScript strict mode enablement for the PHASE dApp, resolving 63 TypeScript errors and adding Content Security Policy (CSP) headers.
Issue Addressed
#42: Hardening Phase-117 & Enabling Strict TypeScript Checks (2 weeks)
🔒 Security Hardening
Content Security Policy (CSP)
Implemented strict CSP headers in
next.config.mjsto prevent XSS attacks:CSP Features
diagnose-env.tsImage Optimization
Configured Next.js remote image patterns for:
📐 TypeScript Strict Mode
Configuration Changes
Removed unsafe build bypass:
Errors Fixed: 63 Total
1. Stellar SDK v15 Migration (25 errors)
SorobanRpc→rpcnamespaceFiles Updated:
app/api/narrator/route.tsapp/api/classic-liq/trustline/route.tsapp/api/profile/follow/route.tslib/bulk-listing.tslib/escrow-settlement.tslib/narrative-world-store.ts2. Custom Type Definitions (18 errors)
Created missing type declaration files:
types/framer-motion.d.ts(12 errors fixed)types/react-hook-form.d.ts(4 errors fixed)types/stellar-wallets-kit.d.ts(2 errors fixed)3. Server-Side Module Fixes (12 errors)
Files Updated:
lib/ipfs-pinning.tslib/cid-cache.tslib/signal-store.tslib/server-data-paths.ts4. Component Type Safety (8 errors)
Files Updated:
components/wallet-provider.tsxscripts/utils.ts🧪 Verification
TypeScript Validation
npx tsc --noEmit # ✅ Found 0 errorsCSP Compliance Check
Build Test
npm run build # ✅ Build successful with zero TypeScript errors📈 Impact
Security Improvements
Performance
Developer Experience
📂 Files Changed (20 files)
Added (3 files)
types/framer-motion.d.tstypes/react-hook-form.d.tstypes/stellar-wallets-kit.d.tsModified (17 files)
next.config.mjs- CSP headers, image optimizationdiagnose-env.ts- CSP validationapp/api/classic-liq/trustline/route.ts- Stellar SDK v15 migrationapp/api/narrator/route.ts- Type fixesapp/api/profile/follow/route.ts- RPC namespace updatecomponents/wallet-provider.tsx- Prop type annotationslib/bulk-listing.ts- Contract invocation typeslib/cid-cache.ts- Error boundary typeslib/escrow-settlement.ts- RPC typeslib/ipfs-pinning.ts- Promise typeslib/narrative-world-store.ts- State typeslib/server-data-paths.ts- Path type safetylib/signal-store.ts- Store typesscripts/utils.ts- Helper function typespackage.json- Addeddotenvdev dependencypackage-lock.json- Lockfile updatetsconfig.json- Strict mode retained🔄 Backward Compatibility
✅ 100% backward compatible:
🚀 Deployment Notes
tsc --noEmitchecks📚 Acceptance Criteria
Related Issues
Closes #42
Contributor
@precious-akpan (Precious Akpan)
All security hardening and type safety requirements met. Ready for review and merge. 🔒