@willbooster/shared-lib-next 1.3.15 → 1.3.17
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/index.cjs +1 -2
- package/dist/index.js +1 -2
- package/dist/middleware.cjs +2 -2
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.js +2 -2
- package/dist/middleware.js.map +1 -1
- package/package.json +6 -6
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./middleware.cjs");exports.BasicAuthMiddleware=e.BasicAuthMiddleware;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{BasicAuthMiddleware as e}from"./middleware.js";export{e as BasicAuthMiddleware};
|
package/dist/middleware.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//# sourceMappingURL=middleware.cjs.map
|
|
1
|
+
"use strict";let e=require("next/server.js");function t(e,t){if(e.length!==t.length)return!1;let n=0;for(let[r,i]of e.entries())n|=i^(t[r]??0);return n===0}function n(n){let r=n.username??process.env.BASIC_AUTH_USERNAME,i=n.password??process.env.BASIC_AUTH_PASSWORD,a=n.realm??process.env.BASIC_AUTH_REALM;return!r&&!i?()=>e.NextResponse.next():n=>{let[o,s]=(n.headers.get(`authorization`)??``).split(` `),c=Buffer.from(`${r}:${i}`),l=Buffer.from(s??``,`base64`);return o?.toLowerCase()!==`basic`||l.length===0||c.length!==l.length||!t(l,c)?new e.NextResponse(`Unauthorized`,{headers:{"WWW-Authenticate":`Basic realm="${a||`Secure Area`}"`},status:401}):e.NextResponse.next()}}exports.BasicAuthMiddleware=n;
|
|
2
|
+
//# sourceMappingURL=middleware.cjs.map
|
package/dist/middleware.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.cjs","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"],"
|
|
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,SAAS,EAAgB,EAAW,EAAoB,CACtD,GAAI,EAAE,SAAW,EAAE,OACjB,MAAO,GAGT,IAAI,EAAS,EACb,IAAK,GAAM,CAAC,EAAG,KAAY,EAAE,QAAQ,EACnC,GAAU,GAAW,EAAE,IAAM,GAE/B,OAAO,IAAW,CACpB,CAEA,SAAgB,EAAoB,EAA6E,CAC/G,IAAM,EAAW,EAAQ,UAAY,QAAQ,IAAI,oBAC3C,EAAW,EAAQ,UAAY,QAAQ,IAAI,oBAC3C,EAAQ,EAAQ,OAAS,QAAQ,IAAI,iBAI3C,MAFI,CAAC,GAAY,CAAC,MAAuBA,EAAAA,aAAa,KAAK,EAEnD,GAAY,CAElB,GAAM,CAAC,EAAM,IADe,EAAQ,QAAQ,IAAI,eAAe,GAAK,GAAA,CACb,MAAM,GAAG,EAC1D,EAAW,OAAO,KAAK,GAAG,EAAS,GAAG,GAAU,EAChD,EAAW,OAAO,KAAK,GAAsB,GAAI,QAAQ,EAc/D,OAXE,GAAM,YAAY,IAAM,SACxB,EAAS,SAAW,GACpB,EAAS,SAAW,EAAS,QAC7B,CAAC,EAAgB,EAAU,CAAQ,EAE5B,IAAIA,EAAAA,aAAa,eAAgB,CACtC,QAAS,CAAE,mBAAoB,gBAAgB,GAAS,cAAc,EAAG,EACzE,OAAQ,GACV,CAAC,EAGIA,EAAAA,aAAa,KAAK,CAC3B,CACF"}
|
package/dist/middleware.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{NextResponse as e}from"next/server.js";function
|
|
2
|
-
//# sourceMappingURL=middleware.js.map
|
|
1
|
+
import{NextResponse as e}from"next/server.js";function t(e,t){if(e.length!==t.length)return!1;let n=0;for(let[r,i]of e.entries())n|=i^(t[r]??0);return n===0}function n(n){let r=n.username??process.env.BASIC_AUTH_USERNAME,i=n.password??process.env.BASIC_AUTH_PASSWORD,a=n.realm??process.env.BASIC_AUTH_REALM;return!r&&!i?()=>e.next():n=>{let[o,s]=(n.headers.get(`authorization`)??``).split(` `),c=Buffer.from(`${r}:${i}`),l=Buffer.from(s??``,`base64`);return o?.toLowerCase()!==`basic`||l.length===0||c.length!==l.length||!t(l,c)?new e(`Unauthorized`,{headers:{"WWW-Authenticate":`Basic realm="${a||`Secure Area`}"`},status:401}):e.next()}}export{n as BasicAuthMiddleware};
|
|
2
|
+
//# sourceMappingURL=middleware.js.map
|
package/dist/middleware.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","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"],"
|
|
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,SAAS,EAAgB,EAAW,EAAoB,CACtD,GAAI,EAAE,SAAW,EAAE,OACjB,MAAO,GAGT,IAAI,EAAS,EACb,IAAK,GAAM,CAAC,EAAG,KAAY,EAAE,QAAQ,EACnC,GAAU,GAAW,EAAE,IAAM,GAE/B,OAAO,IAAW,CACpB,CAEA,SAAgB,EAAoB,EAA6E,CAC/G,IAAM,EAAW,EAAQ,UAAY,QAAQ,IAAI,oBAC3C,EAAW,EAAQ,UAAY,QAAQ,IAAI,oBAC3C,EAAQ,EAAQ,OAAS,QAAQ,IAAI,iBAI3C,MAFI,CAAC,GAAY,CAAC,MAAuB,EAAa,KAAK,EAEnD,GAAY,CAElB,GAAM,CAAC,EAAM,IADe,EAAQ,QAAQ,IAAI,eAAe,GAAK,GAAA,CACb,MAAM,GAAG,EAC1D,EAAW,OAAO,KAAK,GAAG,EAAS,GAAG,GAAU,EAChD,EAAW,OAAO,KAAK,GAAsB,GAAI,QAAQ,EAc/D,OAXE,GAAM,YAAY,IAAM,SACxB,EAAS,SAAW,GACpB,EAAS,SAAW,EAAS,QAC7B,CAAC,EAAgB,EAAU,CAAQ,EAE5B,IAAI,EAAa,eAAgB,CACtC,QAAS,CAAE,mBAAoB,gBAAgB,GAAS,cAAc,EAAG,EACzE,OAAQ,GACV,CAAC,EAGI,EAAa,KAAK,CAC3B,CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/shared-lib-next",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.17",
|
|
4
4
|
"description": "Shared library for WillBooster Next.js projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"@typescript/native-preview": "7.0.0-dev.20260504.1",
|
|
50
50
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
51
51
|
"@willbooster/oxlint-config": "1.4.8",
|
|
52
|
-
"@willbooster/wb": "13.
|
|
53
|
-
"build-ts": "17.1.
|
|
52
|
+
"@willbooster/wb": "13.23.1",
|
|
53
|
+
"build-ts": "17.1.31",
|
|
54
54
|
"next": "16.2.6",
|
|
55
|
-
"oxfmt": "0.
|
|
56
|
-
"oxlint": "1.
|
|
57
|
-
"oxlint-tsgolint": "0.
|
|
55
|
+
"oxfmt": "0.58.0",
|
|
56
|
+
"oxlint": "1.73.0",
|
|
57
|
+
"oxlint-tsgolint": "0.24.0",
|
|
58
58
|
"sort-package-json": "4.0.0",
|
|
59
59
|
"vitest": "4.1.5"
|
|
60
60
|
},
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|