@stacksjs/server 0.75.573 → 0.75.579

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{createHash}from"node:crypto";import{existsSync,readFileSync,statSync}from"node:fs";import{join}from"node:path";import process from"node:process";import{log}from"@stacksjs/logging/runtime";import{path}from"@stacksjs/path";import{frameworkDefaultsDir}from"./imports";export const SECURITY_DEFAULT_FILES=Object.freeze(["Middleware/Auth.ts","Middleware/Guest.ts","Middleware/Csrf.ts","Middleware/Cors.ts","Middleware/Throttle.ts","Middleware/Signed.ts","Middleware/Abilities.ts","Middleware/Can.ts","Middleware/Permission.ts","Middleware/Role.ts","Middleware/EnsureEmailIsVerified.ts","Actions/Auth/LoginAction.ts","Actions/Auth/LogoutAction.ts","Actions/Auth/LogoutAllAction.ts","Actions/Auth/RegisterAction.ts","Actions/Auth/RefreshTokenAction.ts","Actions/Auth/VerifyTwoFactorLoginAction.ts","Actions/Auth/VerifyEmailAction.ts","Actions/Auth/MagicLinkSendAction.ts","Actions/Auth/MagicLinkConsumeAction.ts","Actions/Auth/PasskeyAuthenticationAction.ts","Actions/Auth/VerifyAuthenticationAction.ts","Actions/Auth/SocialRedirectAction.ts","Actions/Auth/SocialCallbackAction.ts","Actions/Auth/SessionHandoffAction.ts","Actions/Auth/social-flow.ts","Actions/Auth/token-request.ts","Actions/Auth/CreateTokenAction.ts","Actions/Auth/RevokeTokenAction.ts","Actions/Auth/OAuthAuthorizationAction.ts","Actions/Auth/OAuthTokenAction.ts","Actions/Auth/oauth-request.ts","Actions/Password/SendPasswordResetEmailAction.ts","Actions/Password/VerifyResetTokenAction.ts","Actions/Password/PasswordResetAction.ts"]);export const SHADOWED_DEFAULT_REVIEW_MARKER="stacks-reviewed-default:";export const SHADOWED_DEFAULTS_ENV="STACKS_SHADOWED_DEFAULTS_WARN";export function defaultFingerprint(contents){return createHash("sha256").update(contents).digest("hex").slice(0,16)}function isFile(file){try{return statSync(file).isFile()}catch{return false}}function sameBytes(a,b){if(a.byteLength!==b.byteLength)return false;for(let i=0;i<a.byteLength;i++){if(a[i]!==b[i])return false}return true}export function findShadowedSecurityDefaults(appDir,defaultsDir,files=SECURITY_DEFAULT_FILES){const found=[];for(const relative of files){const appFile=join(appDir,relative);const defaultFile=join(defaultsDir,relative);try{if(!isFile(appFile)||!isFile(defaultFile))continue;const own=readFileSync(appFile);const framework=readFileSync(defaultFile);const fingerprint=defaultFingerprint(framework);if(sameBytes(own,framework)){found.push({path:relative,kind:"identical",appFile,defaultFile,fingerprint});continue}if(own.toString("utf8").includes(`${SHADOWED_DEFAULT_REVIEW_MARKER} ${fingerprint}`))continue;found.push({path:relative,kind:"modified",appFile,defaultFile,fingerprint})}catch{}}return found}export function describeShadowedSecurityDefaults(entries){const lines=entries.map((entry)=>{if(entry.kind==="identical")return` - app/${entry.path} is an unchanged copy of the framework default. Delete it to receive security fixes.`;return` - app/${entry.path} differs from the framework default (${entry.defaultFile}). `+`Review it against the current default; once reviewed, add the comment \`// ${SHADOWED_DEFAULT_REVIEW_MARKER} ${entry.fingerprint}\` to it.`});return[`[security] ${entries.length} app/ file${entries.length===1?"":"s"} shadow${entries.length===1?"s":""} a framework security default, so framework security fixes to ${entries.length===1?"it do":"them do"} not reach this app:`,...lines,` Set ${SHADOWED_DEFAULTS_ENV}=false to silence this warning.`].join(`
1
+ import{createHash}from"node:crypto";import{existsSync,readFileSync,statSync}from"node:fs";import{join}from"node:path";import process from"node:process";import{log}from"@stacksjs/logging/runtime";import{path}from"@stacksjs/path";import{frameworkDefaultsDir}from"./imports";export const SECURITY_DEFAULT_FILES=Object.freeze(["Middleware/Auth.ts","Middleware/Guest.ts","Middleware/Csrf.ts","Middleware/Cors.ts","Middleware/Throttle.ts","Middleware/Honeypot.ts","Middleware/Signed.ts","Middleware/Abilities.ts","Middleware/Can.ts","Middleware/Permission.ts","Middleware/Role.ts","Middleware/EnsureEmailIsVerified.ts","Actions/Auth/LoginAction.ts","Actions/Auth/LogoutAction.ts","Actions/Auth/LogoutAllAction.ts","Actions/Auth/RegisterAction.ts","Actions/Auth/RefreshTokenAction.ts","Actions/Auth/VerifyTwoFactorLoginAction.ts","Actions/Auth/VerifyEmailAction.ts","Actions/Auth/MagicLinkSendAction.ts","Actions/Auth/MagicLinkConsumeAction.ts","Actions/Auth/PasskeyAuthenticationAction.ts","Actions/Auth/VerifyAuthenticationAction.ts","Actions/Auth/SocialRedirectAction.ts","Actions/Auth/SocialCallbackAction.ts","Actions/Auth/SessionHandoffAction.ts","Actions/Auth/social-flow.ts","Actions/Auth/token-request.ts","Actions/Auth/CreateTokenAction.ts","Actions/Auth/RevokeTokenAction.ts","Actions/Auth/OAuthAuthorizationAction.ts","Actions/Auth/OAuthTokenAction.ts","Actions/Auth/oauth-request.ts","Actions/Password/SendPasswordResetEmailAction.ts","Actions/Password/VerifyResetTokenAction.ts","Actions/Password/PasswordResetAction.ts"]);export const SHADOWED_DEFAULT_REVIEW_MARKER="stacks-reviewed-default:";export const SHADOWED_DEFAULTS_ENV="STACKS_SHADOWED_DEFAULTS_WARN";export function defaultFingerprint(contents){return createHash("sha256").update(contents).digest("hex").slice(0,16)}function isFile(file){try{return statSync(file).isFile()}catch{return false}}function sameBytes(a,b){if(a.byteLength!==b.byteLength)return false;for(let i=0;i<a.byteLength;i++){if(a[i]!==b[i])return false}return true}export function findShadowedSecurityDefaults(appDir,defaultsDir,files=SECURITY_DEFAULT_FILES){const found=[];for(const relative of files){const appFile=join(appDir,relative);const defaultFile=join(defaultsDir,relative);try{if(!isFile(appFile)||!isFile(defaultFile))continue;const own=readFileSync(appFile);const framework=readFileSync(defaultFile);const fingerprint=defaultFingerprint(framework);if(sameBytes(own,framework)){found.push({path:relative,kind:"identical",appFile,defaultFile,fingerprint});continue}if(own.toString("utf8").includes(`${SHADOWED_DEFAULT_REVIEW_MARKER} ${fingerprint}`))continue;found.push({path:relative,kind:"modified",appFile,defaultFile,fingerprint})}catch{}}return found}export function describeShadowedSecurityDefaults(entries){const lines=entries.map((entry)=>{if(entry.kind==="identical")return` - app/${entry.path} is an unchanged copy of the framework default. Delete it to receive security fixes.`;return` - app/${entry.path} differs from the framework default (${entry.defaultFile}). `+`Review it against the current default; once reviewed, add the comment \`// ${SHADOWED_DEFAULT_REVIEW_MARKER} ${entry.fingerprint}\` to it.`});return[`[security] ${entries.length} app/ file${entries.length===1?"":"s"} shadow${entries.length===1?"s":""} a framework security default, so framework security fixes to ${entries.length===1?"it do":"them do"} not reach this app:`,...lines,` Set ${SHADOWED_DEFAULTS_ENV}=false to silence this warning.`].join(`
2
2
  `)}let warned=false;export function warnShadowedSecurityDefaults(options={}){if(warned&&!options.force)return[];warned=true;if(String(process.env[SHADOWED_DEFAULTS_ENV]??"").toLowerCase()==="false")return[];try{const appDir=options.appDir??path.appPath();const defaultsDir=options.defaultsDir??frameworkDefaultsDir("app");if(!appDir||!defaultsDir||!existsSync(appDir)||!existsSync(defaultsDir))return[];const found=findShadowedSecurityDefaults(appDir,defaultsDir);if(found.length>0)(options.warn??((message)=>log.warn(message)))(describeShadowedSecurityDefaults(found));return found}catch{return[]}}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/server",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.573",
5
+ "version": "0.75.579",
6
6
  "description": "Local development and production-ready.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -58,22 +58,22 @@
58
58
  "prepublishOnly": "bun run build"
59
59
  },
60
60
  "dependencies": {
61
- "@stacksjs/auth": "0.75.573",
61
+ "@stacksjs/auth": "0.75.579",
62
62
  "@stacksjs/bun-router": "^0.1.24",
63
- "@stacksjs/config": "0.75.573",
64
- "@stacksjs/events": "0.75.573",
65
- "@stacksjs/i18n": "0.75.573",
66
- "@stacksjs/logging": "0.75.573",
67
- "@stacksjs/orm": "0.75.573",
68
- "@stacksjs/path": "0.75.573",
69
- "@stacksjs/payments": "0.75.573",
70
- "@stacksjs/router": "0.75.573",
71
- "@stacksjs/storage": "0.75.573",
72
- "@stacksjs/stx": "^0.2.864",
63
+ "@stacksjs/config": "0.75.579",
64
+ "@stacksjs/events": "0.75.579",
65
+ "@stacksjs/i18n": "0.75.579",
66
+ "@stacksjs/logging": "0.75.579",
67
+ "@stacksjs/orm": "0.75.579",
68
+ "@stacksjs/path": "0.75.579",
69
+ "@stacksjs/payments": "0.75.579",
70
+ "@stacksjs/router": "0.75.579",
71
+ "@stacksjs/storage": "0.75.579",
72
+ "@stacksjs/stx": "^0.2.872",
73
73
  "bun-plugin-auto-imports": "^0.4.4"
74
74
  },
75
75
  "devDependencies": {
76
- "@stacksjs/validation": "0.75.573",
76
+ "@stacksjs/validation": "0.75.579",
77
77
  "better-dx": "^0.2.39"
78
78
  }
79
79
  }