@willbooster/shared-lib-blitz-next 3.1.1 → 3.1.3
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.d.ts +2 -2
- package/dist/middleware.js.map +1 -1
- package/package.json +13 -13
package/dist/middleware.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.cjs","sources":["../src/middleware.ts"],"sourcesContent":["import type { RequestMiddleware } from 'blitz';\n\
|
|
1
|
+
{"version":3,"file":"middleware.cjs","sources":["../src/middleware.ts"],"sourcesContent":["import type { RequestMiddleware } from 'blitz';\n\ninterface BasicAuthMiddlewareOptions {\n password: string;\n realm?: string;\n username: 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): RequestMiddleware {\n return async (request, response, next) => {\n const authorizationHeader = request.headers.authorization ?? '';\n const [type, encodedCredentials] = authorizationHeader.split(' ');\n const expected = Buffer.from(`${options.username}:${options.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 response.setHeader('WWW-Authenticate', `Basic realm='${options.realm || 'Secure Area'}'`);\n response.statusCode = 401;\n response.end('Unauthorized');\n return;\n }\n\n await next();\n };\n}\n"],"names":["options","async","request","response","next","_request$headers$auth","authorizationHeader","headers","authorization","type","encodedCredentials","split","expected","Buffer","from","username","password","provided","toLowerCase","length","a","b","result","i","element","entries","_b$i","timingSafeEqual","setHeader","realm","statusCode","end"],"mappings":"yCAwBO,SAA6BA,GAClC,OAAOC,MAAOC,EAASC,EAAUC,KAAS,IAAAC,EACxC,MAAMC,EAAmD,OAAhCD,EAAGH,EAAQK,QAAQC,eAAaH,EAAI,IACtDI,EAAMC,GAAsBJ,EAAoBK,MAAM,KACvDC,EAAWC,OAAOC,KAAK,GAAGd,EAAQe,YAAYf,EAAQgB,YACtDC,EAAWJ,OAAOC,KAAuB,MAAlBJ,EAAAA,EAAsB,GAAI,UAEvD,GAC0B,WAApB,MAAJD,OAAI,EAAJA,EAAMS,gBACc,IAApBD,EAASE,QACTP,EAASO,SAAWF,EAASE,SAtBnC,SAAyBC,EAAWC,GAClC,GAAID,EAAED,SAAWE,EAAEF,OACjB,OAAO,EAGT,IAAIG,EAAS,EACb,IAAK,MAAOC,EAAGC,KAAYJ,EAAEK,UAAW,CAAA,IAAAC,EACtCJ,GAAUE,GAAe,OAARE,EAAIL,EAAEE,IAAEG,EAAI,EAC/B,CACA,OAAkB,IAAXJ,CACT,CAaOK,CAAgBV,EAAUL,GAK3B,OAHAT,EAASyB,UAAU,mBAAoB,gBAAgB5B,EAAQ6B,OAAS,kBACxE1B,EAAS2B,WAAa,SACtB3B,EAAS4B,IAAI,sBAIT3B,IAEV"}
|
package/dist/middleware.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { RequestMiddleware } from 'blitz';
|
|
2
|
-
|
|
2
|
+
interface BasicAuthMiddlewareOptions {
|
|
3
3
|
password: string;
|
|
4
4
|
realm?: string;
|
|
5
5
|
username: string;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
export declare function BasicAuthMiddleware(options: BasicAuthMiddlewareOptions): RequestMiddleware;
|
|
8
8
|
export {};
|
package/dist/middleware.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sources":["../src/middleware.ts"],"sourcesContent":["import type { RequestMiddleware } from 'blitz';\n\
|
|
1
|
+
{"version":3,"file":"middleware.js","sources":["../src/middleware.ts"],"sourcesContent":["import type { RequestMiddleware } from 'blitz';\n\ninterface BasicAuthMiddlewareOptions {\n password: string;\n realm?: string;\n username: 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): RequestMiddleware {\n return async (request, response, next) => {\n const authorizationHeader = request.headers.authorization ?? '';\n const [type, encodedCredentials] = authorizationHeader.split(' ');\n const expected = Buffer.from(`${options.username}:${options.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 response.setHeader('WWW-Authenticate', `Basic realm='${options.realm || 'Secure Area'}'`);\n response.statusCode = 401;\n response.end('Unauthorized');\n return;\n }\n\n await next();\n };\n}\n"],"names":["BasicAuthMiddleware","options","async","request","response","next","_request$headers$auth","authorizationHeader","headers","authorization","type","encodedCredentials","split","expected","Buffer","from","username","password","provided","toLowerCase","length","a","b","result","i","element","entries","_b$i","timingSafeEqual","setHeader","realm","statusCode","end"],"mappings":"AAwBO,SAASA,EAAoBC,GAClC,OAAOC,MAAOC,EAASC,EAAUC,KAAS,IAAAC,EACxC,MAAMC,EAAmD,OAAhCD,EAAGH,EAAQK,QAAQC,eAAaH,EAAI,IACtDI,EAAMC,GAAsBJ,EAAoBK,MAAM,KACvDC,EAAWC,OAAOC,KAAK,GAAGd,EAAQe,YAAYf,EAAQgB,YACtDC,EAAWJ,OAAOC,KAAuB,MAAlBJ,EAAAA,EAAsB,GAAI,UAEvD,GAC0B,WAApB,MAAJD,OAAI,EAAJA,EAAMS,gBACc,IAApBD,EAASE,QACTP,EAASO,SAAWF,EAASE,SAtBnC,SAAyBC,EAAWC,GAClC,GAAID,EAAED,SAAWE,EAAEF,OACjB,OAAO,EAGT,IAAIG,EAAS,EACb,IAAK,MAAOC,EAAGC,KAAYJ,EAAEK,UAAW,CAAA,IAAAC,EACtCJ,GAAUE,GAAe,OAARE,EAAIL,EAAEE,IAAEG,EAAI,EAC/B,CACA,OAAkB,IAAXJ,CACT,CAaOK,CAAgBV,EAAUL,GAK3B,OAHAT,EAASyB,UAAU,mBAAoB,gBAAgB5B,EAAQ6B,OAAS,kBACxE1B,EAAS2B,WAAa,SACtB3B,EAAS4B,IAAI,sBAIT3B,IAEV"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/shared-lib-blitz-next",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "WillBooster Inc.",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -39,29 +39,29 @@
|
|
|
39
39
|
"prettier": "@willbooster/prettier-config",
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/eslint": "9.6.1",
|
|
42
|
-
"@types/micromatch": "4.0.
|
|
43
|
-
"@willbooster/eslint-config-ts": "11.4.
|
|
44
|
-
"@willbooster/prettier-config": "10.2.
|
|
42
|
+
"@types/micromatch": "4.0.10",
|
|
43
|
+
"@willbooster/eslint-config-ts": "11.4.10",
|
|
44
|
+
"@willbooster/prettier-config": "10.2.1",
|
|
45
45
|
"blitz": "3.0.2",
|
|
46
|
-
"build-ts": "16.0.
|
|
47
|
-
"eslint": "9.
|
|
46
|
+
"build-ts": "16.0.12",
|
|
47
|
+
"eslint": "9.39.1",
|
|
48
48
|
"eslint-config-flat-gitignore": "2.1.0",
|
|
49
49
|
"eslint-config-prettier": "10.1.8",
|
|
50
50
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
51
51
|
"eslint-plugin-import-x": "4.16.1",
|
|
52
52
|
"eslint-plugin-sort-class-members": "1.21.0",
|
|
53
53
|
"eslint-plugin-sort-destructure-keys": "2.0.0",
|
|
54
|
-
"eslint-plugin-unicorn": "
|
|
55
|
-
"eslint-plugin-unused-imports": "4.
|
|
56
|
-
"globals": "16.
|
|
57
|
-
"lint-staged": "16.2.
|
|
54
|
+
"eslint-plugin-unicorn": "62.0.0",
|
|
55
|
+
"eslint-plugin-unused-imports": "4.3.0",
|
|
56
|
+
"globals": "16.5.0",
|
|
57
|
+
"lint-staged": "16.2.6",
|
|
58
58
|
"micromatch": "4.0.8",
|
|
59
59
|
"prettier": "3.6.2",
|
|
60
|
-
"prettier-plugin-java": "2.7.
|
|
60
|
+
"prettier-plugin-java": "2.7.7",
|
|
61
61
|
"sort-package-json": "3.4.0",
|
|
62
62
|
"typescript": "5.9.3",
|
|
63
|
-
"typescript-eslint": "8.
|
|
64
|
-
"vitest": "
|
|
63
|
+
"typescript-eslint": "8.46.3",
|
|
64
|
+
"vitest": "4.0.3"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|