@redmix/auth-dbauth-api 0.0.1 → 9.0.0-canary.518
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/DbAuthHandler.js +2 -2
- package/dist/decoder.d.ts +1 -1
- package/dist/decoder.d.ts.map +1 -1
- package/dist/decoder.js +2 -2
- package/dist/shared.d.ts +3 -3
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -12
- package/package.json +5 -8
package/dist/DbAuthHandler.js
CHANGED
@@ -121,7 +121,7 @@ class DbAuthHandler {
|
|
121
121
|
deleteHeaders.append(
|
122
122
|
"set-cookie",
|
123
123
|
[
|
124
|
-
`${(0, import_shared.
|
124
|
+
`${(0, import_shared.generateCookieName)(this.options.cookie?.name)}=`,
|
125
125
|
...this._cookieAttributes({ expires: "now" })
|
126
126
|
].join(";")
|
127
127
|
);
|
@@ -690,7 +690,7 @@ class DbAuthHandler {
|
|
690
690
|
const session = JSON.stringify(data) + ";" + csrfToken;
|
691
691
|
const encrypted = (0, import_shared.encryptSession)(session);
|
692
692
|
const sessionCookieString = [
|
693
|
-
`${(0, import_shared.
|
693
|
+
`${(0, import_shared.generateCookieName)(this.options.cookie?.name)}=${encrypted}`,
|
694
694
|
...this._cookieAttributes({ expires: this.sessionExpiresDate })
|
695
695
|
].join(";");
|
696
696
|
return sessionCookieString;
|
package/dist/decoder.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { Decoder } from '@redmix/api';
|
2
|
-
export declare const createAuthDecoder: (
|
2
|
+
export declare const createAuthDecoder: (cookieNameTemplate: string) => Decoder;
|
3
3
|
/** @deprecated use `createAuthDecoder` */
|
4
4
|
export declare const authDecoder: Decoder;
|
5
5
|
//# sourceMappingURL=decoder.d.ts.map
|
package/dist/decoder.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"decoder.d.ts","sourceRoot":"","sources":["../src/decoder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAI1C,eAAO,MAAM,iBAAiB,
|
1
|
+
{"version":3,"file":"decoder.d.ts","sourceRoot":"","sources":["../src/decoder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAI1C,eAAO,MAAM,iBAAiB,uBAAwB,MAAM,KAAG,OAW9D,CAAA;AAED,0CAA0C;AAC1C,eAAO,MAAM,WAAW,EAAE,OAezB,CAAA"}
|
package/dist/decoder.js
CHANGED
@@ -23,12 +23,12 @@ __export(decoder_exports, {
|
|
23
23
|
});
|
24
24
|
module.exports = __toCommonJS(decoder_exports);
|
25
25
|
var import_shared = require("./shared");
|
26
|
-
const createAuthDecoder = (
|
26
|
+
const createAuthDecoder = (cookieNameTemplate) => {
|
27
27
|
return async (_token, type, req) => {
|
28
28
|
if (type !== "dbAuth") {
|
29
29
|
return null;
|
30
30
|
}
|
31
|
-
const session = (0, import_shared.dbAuthSession)(req.event,
|
31
|
+
const session = (0, import_shared.dbAuthSession)(req.event, cookieNameTemplate);
|
32
32
|
return session;
|
33
33
|
};
|
34
34
|
};
|
package/dist/shared.d.ts
CHANGED
@@ -13,8 +13,8 @@ export declare const extractCookie: (event: APIGatewayProxyEvent | Request) => a
|
|
13
13
|
export declare const isLegacySession: (text: string | undefined) => boolean;
|
14
14
|
export declare const decryptSession: (text: string | null) => any[];
|
15
15
|
export declare const encryptSession: (dataString: string) => string;
|
16
|
-
export declare const getSession: (text: string | undefined,
|
17
|
-
export declare const dbAuthSession: (event: APIGatewayProxyEvent | Request,
|
16
|
+
export declare const getSession: (text: string | undefined, cookieNameTemplate: string | undefined) => string | null;
|
17
|
+
export declare const dbAuthSession: (event: APIGatewayProxyEvent | Request, cookieNameTemplate: string | undefined) => any;
|
18
18
|
export declare const webAuthnSession: (event: APIGatewayProxyEvent | Request) => any;
|
19
19
|
export declare const hashToken: (token: string) => string;
|
20
20
|
export declare const hashPassword: (text: string, { salt, options, }?: {
|
@@ -22,7 +22,7 @@ export declare const hashPassword: (text: string, { salt, options, }?: {
|
|
22
22
|
options?: ScryptOptions;
|
23
23
|
}) => string[];
|
24
24
|
export declare const legacyHashPassword: (text: string, salt?: string) => string[];
|
25
|
-
export declare
|
25
|
+
export declare function generateCookieName(template: string | undefined): string;
|
26
26
|
/**
|
27
27
|
* Returns a builder for a lambda response
|
28
28
|
*
|
package/dist/shared.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAM9C,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AA8ED,eAAO,MAAM,aAAa,UAAW,oBAAoB,GAAG,OAAO,QAElE,CAAA;AAGD,eAAO,MAAM,eAAe,SAAU,MAAM,GAAG,SAAS,YAOvD,CAAA;AAGD,eAAO,MAAM,cAAc,SAAU,MAAM,GAAG,IAAI,UAiCjD,CAAA;AAED,eAAO,MAAM,cAAc,eAAgB,MAAM,WAWhD,CAAA;AAGD,eAAO,MAAM,UAAU,SACf,MAAM,GAAG,SAAS,
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEtD,OAAO,KAAK,EAAE,WAAW,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E,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,eACY,WAAW;gBAQV,MAAM;aACT,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;wBACtB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;WACrC,MAAM;EA2BlB;AAYD,eAAO,MAAM,qBAAqB,SAAU,MAAM,KAAG,aAYpD,CAAA"}
|
package/dist/shared.js
CHANGED
@@ -28,12 +28,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
29
|
var shared_exports = {};
|
30
30
|
__export(shared_exports, {
|
31
|
-
cookieName: () => cookieName,
|
32
31
|
dbAuthSession: () => dbAuthSession,
|
33
32
|
decryptSession: () => decryptSession,
|
34
33
|
encryptSession: () => encryptSession,
|
35
34
|
extractCookie: () => extractCookie,
|
36
35
|
extractHashingOptions: () => extractHashingOptions,
|
36
|
+
generateCookieName: () => generateCookieName,
|
37
37
|
getDbAuthResponseBuilder: () => getDbAuthResponseBuilder,
|
38
38
|
getSession: () => getSession,
|
39
39
|
hashPassword: () => hashPassword,
|
@@ -145,26 +145,27 @@ const encryptSession = (dataString) => {
|
|
145
145
|
encryptedData += cipher.final("base64");
|
146
146
|
return `${encryptedData}|${iv.toString("base64")}`;
|
147
147
|
};
|
148
|
-
const getSession = (text,
|
148
|
+
const getSession = (text, cookieNameTemplate) => {
|
149
149
|
if (typeof text === "undefined" || text === null) {
|
150
150
|
return null;
|
151
151
|
}
|
152
|
+
const cookieName = generateCookieName(cookieNameTemplate);
|
152
153
|
const cookies = text.split(";");
|
153
154
|
const sessionCookie = cookies.find((cookie) => {
|
154
|
-
return cookie.split("=")[0].trim() === cookieName
|
155
|
+
return cookie.split("=")[0].trim() === cookieName;
|
155
156
|
});
|
156
|
-
if (!sessionCookie || sessionCookie === `${cookieName
|
157
|
+
if (!sessionCookie || sessionCookie === `${cookieName}=`) {
|
157
158
|
return null;
|
158
159
|
}
|
159
|
-
return sessionCookie.replace(`${cookieName
|
160
|
+
return sessionCookie.replace(`${cookieName}=`, "").trim();
|
160
161
|
};
|
161
|
-
const dbAuthSession = (event,
|
162
|
+
const dbAuthSession = (event, cookieNameTemplate) => {
|
162
163
|
const sessionCookie = extractCookie(event);
|
163
164
|
if (!sessionCookie) {
|
164
165
|
return null;
|
165
166
|
}
|
166
167
|
const [session, _csrfToken] = decryptSession(
|
167
|
-
getSession(sessionCookie,
|
168
|
+
getSession(sessionCookie, cookieNameTemplate)
|
168
169
|
);
|
169
170
|
return session;
|
170
171
|
};
|
@@ -203,11 +204,11 @@ const legacyHashPassword = (text, salt) => {
|
|
203
204
|
useSalt
|
204
205
|
];
|
205
206
|
};
|
206
|
-
|
207
|
+
function generateCookieName(template) {
|
207
208
|
const port = getPort();
|
208
|
-
const
|
209
|
-
return
|
210
|
-
}
|
209
|
+
const cookieName = template?.replace("%port%", "" + port) ?? "session";
|
210
|
+
return cookieName;
|
211
|
+
}
|
211
212
|
function getDbAuthResponseBuilder(event) {
|
212
213
|
return (response, corsHeaders) => {
|
213
214
|
const headers = {
|
@@ -252,12 +253,12 @@ const extractHashingOptions = (text) => {
|
|
252
253
|
};
|
253
254
|
// Annotate the CommonJS export names for ESM import in node:
|
254
255
|
0 && (module.exports = {
|
255
|
-
cookieName,
|
256
256
|
dbAuthSession,
|
257
257
|
decryptSession,
|
258
258
|
encryptSession,
|
259
259
|
extractCookie,
|
260
260
|
extractHashingOptions,
|
261
|
+
generateCookieName,
|
261
262
|
getDbAuthResponseBuilder,
|
262
263
|
getSession,
|
263
264
|
hashPassword,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@redmix/auth-dbauth-api",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "9.0.0-canary.518+f9439a7a6",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "git+https://github.com/redmix-run/redmix.git",
|
@@ -57,15 +57,15 @@
|
|
57
57
|
"test:watch": "vitest watch"
|
58
58
|
},
|
59
59
|
"dependencies": {
|
60
|
-
"@redmix/project-config": "0.0.
|
60
|
+
"@redmix/project-config": "9.0.0-canary.518",
|
61
61
|
"base64url": "3.0.1",
|
62
62
|
"md5": "2.3.0",
|
63
63
|
"uuid": "10.0.0"
|
64
64
|
},
|
65
65
|
"devDependencies": {
|
66
66
|
"@arethetypeswrong/cli": "0.16.4",
|
67
|
-
"@redmix/api": "0.0.
|
68
|
-
"@redmix/framework-tools": "0.0.
|
67
|
+
"@redmix/api": "9.0.0-canary.518",
|
68
|
+
"@redmix/framework-tools": "9.0.0-canary.518",
|
69
69
|
"@simplewebauthn/server": "7.4.0",
|
70
70
|
"@types/md5": "2.3.5",
|
71
71
|
"@types/uuid": "10.0.0",
|
@@ -75,8 +75,5 @@
|
|
75
75
|
"typescript": "5.6.2",
|
76
76
|
"vitest": "2.1.9"
|
77
77
|
},
|
78
|
-
"
|
79
|
-
"access": "public"
|
80
|
-
},
|
81
|
-
"gitHead": "688027c97502c500ebbede9cdc7cc51545a8dcf3"
|
78
|
+
"gitHead": "f9439a7a6478e5c522bda13a779f323b2b714f3a"
|
82
79
|
}
|