@willbooster/shared-lib-next 4.1.0 → 4.2.0
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.
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.js.map +1 -1
- package/package.json +9 -10
package/dist/middleware.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.cjs","names":["NextResponse"],"sources":["../src/middleware.ts"],"sourcesContent":["import { NextResponse } from 'next/server.js';\nimport type { NextRequest } from 'next/server.js';\n\ninterface BasicAuthMiddlewareOptions {\n username?: string;\n password?: string;\n realm?: string;\n}\n\n/**\n * Timing-safe comparison of two buffers to prevent timing attacks.\n * This implementation works in all JavaScript environments (Node.js, Edge, Browser).\n */\nfunction timingSafeEqual(a: Buffer, b: Buffer): boolean {\n if (a.length !== b.length) {\n return false;\n }\n\n let result = 0;\n for (const [i, element] of a.entries()) {\n result |= element ^ (b[i] ?? 0);\n }\n return result === 0;\n}\n\nexport function BasicAuthMiddleware(options: BasicAuthMiddlewareOptions): (request: NextRequest) => NextResponse {\n const username = options.username ?? process.env.BASIC_AUTH_USERNAME;\n const password = options.password ?? process.env.BASIC_AUTH_PASSWORD;\n const realm = options.realm ?? process.env.BASIC_AUTH_REALM;\n\n if (!username && !password) return () => NextResponse.next();\n\n return (request) => {\n const authorizationHeader = request.headers.get('authorization') ?? '';\n const [type, encodedCredentials] = authorizationHeader.split(' ');\n const expected = Buffer.from(`${username}:${password}`);\n const provided = Buffer.from(encodedCredentials ?? '', 'base64');\n\n if (\n type?.toLowerCase() !== 'basic' ||\n provided.length === 0 ||\n expected.length !== provided.length ||\n !timingSafeEqual(provided, expected)\n ) {\n return new NextResponse('Unauthorized', {\n headers: { 'WWW-Authenticate': `Basic realm=\"${realm || 'Secure Area'}\"` },\n status: 401,\n });\n }\n\n return NextResponse.next();\n };\n}\n"],"mappings":"6CAaA,
|
|
1
|
+
{"version":3,"file":"middleware.cjs","names":["NextResponse","next_server_js","timingSafeEqual","a","b","result","i","element","BasicAuthMiddleware","username","options","password","realm","type","encodedCredentials","request","expected","provided"],"sources":["../src/middleware.ts"],"sourcesContent":["import { NextResponse } from 'next/server.js';\nimport type { NextRequest } from 'next/server.js';\n\ninterface BasicAuthMiddlewareOptions {\n username?: string;\n password?: string;\n realm?: string;\n}\n\n/**\n * Timing-safe comparison of two buffers to prevent timing attacks.\n * This implementation works in all JavaScript environments (Node.js, Edge, Browser).\n */\nfunction timingSafeEqual(a: Buffer, b: Buffer): boolean {\n if (a.length !== b.length) {\n return false;\n }\n\n let result = 0;\n for (const [i, element] of a.entries()) {\n result |= element ^ (b[i] ?? 0);\n }\n return result === 0;\n}\n\nexport function BasicAuthMiddleware(options: BasicAuthMiddlewareOptions): (request: NextRequest) => NextResponse {\n const username = options.username ?? process.env.BASIC_AUTH_USERNAME;\n const password = options.password ?? process.env.BASIC_AUTH_PASSWORD;\n const realm = options.realm ?? process.env.BASIC_AUTH_REALM;\n\n if (!username && !password) return () => NextResponse.next();\n\n return (request) => {\n const authorizationHeader = request.headers.get('authorization') ?? '';\n const [type, encodedCredentials] = authorizationHeader.split(' ');\n const expected = Buffer.from(`${username}:${password}`);\n const provided = Buffer.from(encodedCredentials ?? '', 'base64');\n\n if (\n type?.toLowerCase() !== 'basic' ||\n provided.length === 0 ||\n expected.length !== provided.length ||\n !timingSafeEqual(provided, expected)\n ) {\n return new NextResponse('Unauthorized', {\n headers: { 'WWW-Authenticate': `Basic realm=\"${realm || 'Secure Area'}\"` },\n status: 401,\n });\n }\n\n return NextResponse.next();\n };\n}\n"],"mappings":"6CAaA,SAASE,EAAgB,EAAW,EAAoB,CACtD,GAAIC,EAAE,SAAWC,EAAE,OACjB,MAAO,GAGT,IAAIC,EAAS,EACb,IAAK,GAAM,CAACC,EAAGC,KAAYJ,EAAE,QAAQ,EACnC,GAAUI,GAAWH,EAAEE,IAAM,GAE/B,OAAOD,IAAW,CACpB,CAEA,SAAgBG,EAAoB,EAA6E,CAC/G,IAAMC,EAAWC,EAAQ,UAAY,QAAQ,IAAI,oBAC3CC,EAAWD,EAAQ,UAAY,QAAQ,IAAI,oBAC3CE,EAAQF,EAAQ,OAAS,QAAQ,IAAI,iBAI3C,MAFI,CAACD,GAAY,CAACE,MAAuBX,EAAAA,aAAa,KAAK,EAEnD,GAAY,CAElB,GAAM,CAACa,EAAMC,IADeC,EAAQ,QAAQ,IAAI,eAAe,GAAK,GAAA,CACb,MAAM,GAAG,EAC1DC,EAAW,OAAO,KAAK,GAAGP,EAAS,GAAGE,GAAU,EAChDM,EAAW,OAAO,KAAKH,GAAsB,GAAI,QAAQ,EAc/D,OAXED,GAAM,YAAY,IAAM,SACxBI,EAAS,SAAW,GACpBD,EAAS,SAAWC,EAAS,QAC7B,CAACf,EAAgBe,EAAUD,CAAQ,EAE5B,IAAIhB,EAAAA,aAAa,eAAgB,CACtC,QAAS,CAAE,mBAAoB,gBAAgBY,GAAS,cAAc,EAAG,EACzE,OAAQ,GACV,CAAC,EAGIZ,EAAAA,aAAa,KAAK,CAC3B,CACF"}
|
package/dist/middleware.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","names":[],"sources":["../src/middleware.ts"],"sourcesContent":["import { NextResponse } from 'next/server.js';\nimport type { NextRequest } from 'next/server.js';\n\ninterface BasicAuthMiddlewareOptions {\n username?: string;\n password?: string;\n realm?: string;\n}\n\n/**\n * Timing-safe comparison of two buffers to prevent timing attacks.\n * This implementation works in all JavaScript environments (Node.js, Edge, Browser).\n */\nfunction timingSafeEqual(a: Buffer, b: Buffer): boolean {\n if (a.length !== b.length) {\n return false;\n }\n\n let result = 0;\n for (const [i, element] of a.entries()) {\n result |= element ^ (b[i] ?? 0);\n }\n return result === 0;\n}\n\nexport function BasicAuthMiddleware(options: BasicAuthMiddlewareOptions): (request: NextRequest) => NextResponse {\n const username = options.username ?? process.env.BASIC_AUTH_USERNAME;\n const password = options.password ?? process.env.BASIC_AUTH_PASSWORD;\n const realm = options.realm ?? process.env.BASIC_AUTH_REALM;\n\n if (!username && !password) return () => NextResponse.next();\n\n return (request) => {\n const authorizationHeader = request.headers.get('authorization') ?? '';\n const [type, encodedCredentials] = authorizationHeader.split(' ');\n const expected = Buffer.from(`${username}:${password}`);\n const provided = Buffer.from(encodedCredentials ?? '', 'base64');\n\n if (\n type?.toLowerCase() !== 'basic' ||\n provided.length === 0 ||\n expected.length !== provided.length ||\n !timingSafeEqual(provided, expected)\n ) {\n return new NextResponse('Unauthorized', {\n headers: { 'WWW-Authenticate': `Basic realm=\"${realm || 'Secure Area'}\"` },\n status: 401,\n });\n }\n\n return NextResponse.next();\n };\n}\n"],"mappings":"8CAaA,
|
|
1
|
+
{"version":3,"file":"middleware.js","names":["timingSafeEqual","a","b","result","i","element","BasicAuthMiddleware","username","options","password","realm","NextResponse","type","encodedCredentials","request","expected","provided"],"sources":["../src/middleware.ts"],"sourcesContent":["import { NextResponse } from 'next/server.js';\nimport type { NextRequest } from 'next/server.js';\n\ninterface BasicAuthMiddlewareOptions {\n username?: string;\n password?: string;\n realm?: string;\n}\n\n/**\n * Timing-safe comparison of two buffers to prevent timing attacks.\n * This implementation works in all JavaScript environments (Node.js, Edge, Browser).\n */\nfunction timingSafeEqual(a: Buffer, b: Buffer): boolean {\n if (a.length !== b.length) {\n return false;\n }\n\n let result = 0;\n for (const [i, element] of a.entries()) {\n result |= element ^ (b[i] ?? 0);\n }\n return result === 0;\n}\n\nexport function BasicAuthMiddleware(options: BasicAuthMiddlewareOptions): (request: NextRequest) => NextResponse {\n const username = options.username ?? process.env.BASIC_AUTH_USERNAME;\n const password = options.password ?? process.env.BASIC_AUTH_PASSWORD;\n const realm = options.realm ?? process.env.BASIC_AUTH_REALM;\n\n if (!username && !password) return () => NextResponse.next();\n\n return (request) => {\n const authorizationHeader = request.headers.get('authorization') ?? '';\n const [type, encodedCredentials] = authorizationHeader.split(' ');\n const expected = Buffer.from(`${username}:${password}`);\n const provided = Buffer.from(encodedCredentials ?? '', 'base64');\n\n if (\n type?.toLowerCase() !== 'basic' ||\n provided.length === 0 ||\n expected.length !== provided.length ||\n !timingSafeEqual(provided, expected)\n ) {\n return new NextResponse('Unauthorized', {\n headers: { 'WWW-Authenticate': `Basic realm=\"${realm || 'Secure Area'}\"` },\n status: 401,\n });\n }\n\n return NextResponse.next();\n };\n}\n"],"mappings":"8CAaA,SAASA,EAAgB,EAAW,EAAoB,CACtD,GAAIC,EAAE,SAAWC,EAAE,OACjB,MAAO,GAGT,IAAIC,EAAS,EACb,IAAK,GAAM,CAACC,EAAGC,KAAYJ,EAAE,QAAQ,EACnC,GAAUI,GAAWH,EAAEE,IAAM,GAE/B,OAAOD,IAAW,CACpB,CAEA,SAAgBG,EAAoB,EAA6E,CAC/G,IAAMC,EAAWC,EAAQ,UAAY,QAAQ,IAAI,oBAC3CC,EAAWD,EAAQ,UAAY,QAAQ,IAAI,oBAC3CE,EAAQF,EAAQ,OAAS,QAAQ,IAAI,iBAI3C,MAFI,CAACD,GAAY,CAACE,MAAuBE,EAAa,KAAK,EAEnD,GAAY,CAElB,GAAM,CAACC,EAAMC,IADeC,EAAQ,QAAQ,IAAI,eAAe,GAAK,GAAA,CACb,MAAM,GAAG,EAC1DC,EAAW,OAAO,KAAK,GAAGR,EAAS,GAAGE,GAAU,EAChDO,EAAW,OAAO,KAAKH,GAAsB,GAAI,QAAQ,EAc/D,OAXED,GAAM,YAAY,IAAM,SACxBI,EAAS,SAAW,GACpBD,EAAS,SAAWC,EAAS,QAC7B,CAAChB,EAAgBgB,EAAUD,CAAQ,EAE5B,IAAIJ,EAAa,eAAgB,CACtC,QAAS,CAAE,mBAAoB,gBAAgBD,GAAS,cAAc,EAAG,EACzE,OAAQ,GACV,CAAC,EAGIC,EAAa,KAAK,CAC3B,CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/shared-lib-next",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Shared library for WillBooster Next.js projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,17 +46,16 @@
|
|
|
46
46
|
"@tsconfig/node-lts": "24.0.1",
|
|
47
47
|
"@tsconfig/node-ts": "23.6.4",
|
|
48
48
|
"@types/bun": "1.4.2",
|
|
49
|
-
"@types/node": "26.6.
|
|
49
|
+
"@types/node": "26.6.4",
|
|
50
50
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
51
51
|
"@willbooster/oxlint-config": "1.4.8",
|
|
52
|
-
"@willbooster/wb": "22.
|
|
53
|
-
"build-ts": "21.0.
|
|
54
|
-
"next": "16.3.
|
|
55
|
-
"oxfmt": "0.
|
|
56
|
-
"oxlint": "1.
|
|
57
|
-
"oxlint-tsgolint": "7.0.
|
|
58
|
-
"sort-package-json": "4.0.0"
|
|
59
|
-
"typescript": "7.0.2"
|
|
52
|
+
"@willbooster/wb": "22.26.0",
|
|
53
|
+
"build-ts": "21.0.25",
|
|
54
|
+
"next": "16.3.8",
|
|
55
|
+
"oxfmt": "0.71.0",
|
|
56
|
+
"oxlint": "1.86.0",
|
|
57
|
+
"oxlint-tsgolint": "7.0.2003",
|
|
58
|
+
"sort-package-json": "4.0.0"
|
|
60
59
|
},
|
|
61
60
|
"peerDependencies": {
|
|
62
61
|
"next": ">=16.3.0"
|