@thunderid/express 0.2.5 → 0.4.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/ThunderIDExpressClient.d.ts +6 -0
- package/dist/ThunderIDExpressClient.d.ts.map +1 -1
- package/dist/cjs/index.cjs +16 -9
- package/dist/constants/CookieConfig.d.ts +0 -2
- package/dist/constants/CookieConfig.d.ts.map +1 -1
- package/dist/edge/index.js +20 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -12
- package/dist/middleware/authentication.d.ts.map +1 -1
- package/dist/middleware/protect.d.ts.map +1 -1
- package/dist/models/config.d.ts +7 -0
- package/dist/models/config.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -23,6 +23,12 @@ declare class ThunderIDExpressClient<T extends ExpressClientConfig = ExpressClie
|
|
|
23
23
|
constructor();
|
|
24
24
|
initialize(config: T, storage?: Storage): Promise<boolean>;
|
|
25
25
|
get expressConfig(): ExpressClientConfig | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Resolves the session cookie name for this client instance, honoring an
|
|
28
|
+
* explicit `sessionCookie.name` override before falling back to the
|
|
29
|
+
* `vendor`-derived default (which itself defaults to `'thunderid'`).
|
|
30
|
+
*/
|
|
31
|
+
getSessionCookieName(): string;
|
|
26
32
|
getUserFromRequest(req: express.Request): Promise<User | undefined>;
|
|
27
33
|
signIn(req: express.Request, res: express.Response, next: express.NextFunction, signInConfig?: Record<string, string | boolean>): Promise<TokenResponse>;
|
|
28
34
|
signOut(userId?: string): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThunderIDExpressClient.d.ts","sourceRoot":"","sources":["../src/ThunderIDExpressClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"ThunderIDExpressClient.d.ts","sourceRoot":"","sources":["../src/ThunderIDExpressClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,mBAAmB,EAEnB,OAAO,EACP,aAAa,EACb,IAAI,EAEL,MAAM,iBAAiB,CAAC;AACzB,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAGpD,cAAM,sBAAsB,CAAC,CAAC,SAAS,mBAAmB,GAAG,mBAAmB,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IAC9G,OAAO,CAAC,cAAc,CAAkC;;IAMlC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAKhF,IAAW,aAAa,IAAI,mBAAmB,GAAG,SAAS,CAE1D;IAED;;;;OAIG;IACI,oBAAoB,IAAI,MAAM;IAOxB,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;IAK1D,MAAM,CAC1B,GAAG,EAAE,OAAO,CAAC,OAAO,EACpB,GAAG,EAAE,OAAO,CAAC,QAAQ,EACrB,IAAI,EAAE,OAAO,CAAC,YAAY,EAC1B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAC9C,OAAO,CAAC,aAAa,CAAC;IAwDH,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAGhE;AAED,eAAe,sBAAsB,CAAC"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -44,8 +44,6 @@ uuid = __toESM(uuid);
|
|
|
44
44
|
* specific language governing permissions and limitations
|
|
45
45
|
* under the License.
|
|
46
46
|
*/
|
|
47
|
-
/** Session cookie name used across the Express SDK. */
|
|
48
|
-
const SESSION_COOKIE_NAME = "THUNDERID_SESSION_ID";
|
|
49
47
|
/** Default cookie configuration values. */
|
|
50
48
|
const CookieConfig = {
|
|
51
49
|
defaultExpirySeconds: 86400,
|
|
@@ -97,18 +95,27 @@ var ThunderIDExpressClient = class extends __thunderid_node.ThunderIDNodeClient
|
|
|
97
95
|
get expressConfig() {
|
|
98
96
|
return this._expressConfig;
|
|
99
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Resolves the session cookie name for this client instance, honoring an
|
|
100
|
+
* explicit `sessionCookie.name` override before falling back to the
|
|
101
|
+
* `vendor`-derived default (which itself defaults to `'thunderid'`).
|
|
102
|
+
*/
|
|
103
|
+
getSessionCookieName() {
|
|
104
|
+
return __thunderid_node.CookieConfig.resolveSessionCookieName(this._expressConfig?.vendor, this._expressConfig?.sessionCookie?.name);
|
|
105
|
+
}
|
|
100
106
|
async getUserFromRequest(req) {
|
|
101
|
-
const sessionId = req.cookies?.[
|
|
107
|
+
const sessionId = req.cookies?.[this.getSessionCookieName()];
|
|
102
108
|
return this.getUser(sessionId);
|
|
103
109
|
}
|
|
104
110
|
async signIn(req, res, next, signInConfig) {
|
|
105
111
|
if (expressUtils_default(req.originalUrl)) return Promise.reject(new __thunderid_node.ThunderIDAuthException("EXPRESS-CLIENT-SI-IV01", "Invalid login request URL", "Login request contains an error query parameter in the URL"));
|
|
106
|
-
|
|
112
|
+
const cookieName = this.getSessionCookieName();
|
|
113
|
+
let userId = req.cookies?.[cookieName];
|
|
107
114
|
if (!userId) userId = (0, uuid.v4)();
|
|
108
115
|
const sc = this._expressConfig?.sessionCookie;
|
|
109
116
|
const authRedirectCallback = (url) => {
|
|
110
117
|
if (!url) return;
|
|
111
|
-
res.cookie(
|
|
118
|
+
res.cookie(cookieName, userId, {
|
|
112
119
|
httpOnly: sc?.httpOnly ?? CookieConfig_default.defaultHttpOnly,
|
|
113
120
|
maxAge: (sc?.expiryTime ?? CookieConfig_default.defaultExpirySeconds) * 1e3,
|
|
114
121
|
sameSite: sc?.sameSite ?? CookieConfig_default.defaultSameSite,
|
|
@@ -241,7 +248,8 @@ const handleSignOut = () => {
|
|
|
241
248
|
onSignOut(res);
|
|
242
249
|
return;
|
|
243
250
|
}
|
|
244
|
-
const
|
|
251
|
+
const cookieName = client.getSessionCookieName();
|
|
252
|
+
const sessionId = req.cookies?.[cookieName];
|
|
245
253
|
if (!sessionId) {
|
|
246
254
|
onError(res, new __thunderid_node.ThunderIDRuntimeError("No cookie found in the request", "EXPRESS-AUTH_MW-LOGOUT-NF01", "express"));
|
|
247
255
|
return;
|
|
@@ -249,7 +257,7 @@ const handleSignOut = () => {
|
|
|
249
257
|
try {
|
|
250
258
|
const signOutURL = await client.signOut(sessionId);
|
|
251
259
|
if (signOutURL) {
|
|
252
|
-
res.cookie(
|
|
260
|
+
res.cookie(cookieName, null, { maxAge: 0 });
|
|
253
261
|
res.redirect(signOutURL);
|
|
254
262
|
}
|
|
255
263
|
} catch (e) {
|
|
@@ -271,7 +279,7 @@ const handleSignOut = () => {
|
|
|
271
279
|
const protect = (onUnauthenticated) => {
|
|
272
280
|
return async (req, res, next) => {
|
|
273
281
|
const client = req.thunderIDAuth;
|
|
274
|
-
const sessionId = req.cookies?.[
|
|
282
|
+
const sessionId = req.cookies?.[client?.getSessionCookieName() ?? ""];
|
|
275
283
|
const reject = () => {
|
|
276
284
|
if (onUnauthenticated) onUnauthenticated(res);
|
|
277
285
|
else res.status(401).end();
|
|
@@ -376,7 +384,6 @@ var flow_default = handleFlow;
|
|
|
376
384
|
|
|
377
385
|
//#endregion
|
|
378
386
|
exports.CookieConfig = CookieConfig_default;
|
|
379
|
-
exports.SESSION_COOKIE_NAME = SESSION_COOKIE_NAME;
|
|
380
387
|
exports.ThunderIDExpressClient = ThunderIDExpressClient_default;
|
|
381
388
|
exports.handleFlow = flow_default;
|
|
382
389
|
exports.handleSignIn = handleSignIn;
|
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
/** Session cookie name used across the Express SDK. */
|
|
19
|
-
export declare const SESSION_COOKIE_NAME = "THUNDERID_SESSION_ID";
|
|
20
18
|
/** Default cookie configuration values. */
|
|
21
19
|
declare const CookieConfig: {
|
|
22
20
|
defaultExpirySeconds: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CookieConfig.d.ts","sourceRoot":"","sources":["../../src/constants/CookieConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,
|
|
1
|
+
{"version":3,"file":"CookieConfig.d.ts","sourceRoot":"","sources":["../../src/constants/CookieConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,2CAA2C;AAC3C,QAAA,MAAM,YAAY;;;;;CAKjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/dist/edge/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ThunderIDAuthException, ThunderIDNodeClient, ThunderIDRuntimeError, executeEmbeddedSignInFlow, logger } from "@thunderid/node";
|
|
1
|
+
import { CookieConfig, ThunderIDAuthException, ThunderIDNodeClient, ThunderIDRuntimeError, executeEmbeddedSignInFlow, logger } from "@thunderid/node";
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
3
|
|
|
4
4
|
export * from "@thunderid/node"
|
|
@@ -21,16 +21,14 @@ export * from "@thunderid/node"
|
|
|
21
21
|
* specific language governing permissions and limitations
|
|
22
22
|
* under the License.
|
|
23
23
|
*/
|
|
24
|
-
/** Session cookie name used across the Express SDK. */
|
|
25
|
-
const SESSION_COOKIE_NAME = "THUNDERID_SESSION_ID";
|
|
26
24
|
/** Default cookie configuration values. */
|
|
27
|
-
const CookieConfig = {
|
|
25
|
+
const CookieConfig$1 = {
|
|
28
26
|
defaultExpirySeconds: 86400,
|
|
29
27
|
defaultHttpOnly: true,
|
|
30
28
|
defaultSameSite: "lax",
|
|
31
29
|
defaultSecure: false
|
|
32
30
|
};
|
|
33
|
-
var CookieConfig_default = CookieConfig;
|
|
31
|
+
var CookieConfig_default = CookieConfig$1;
|
|
34
32
|
|
|
35
33
|
//#endregion
|
|
36
34
|
//#region src/utils/expressUtils.ts
|
|
@@ -74,18 +72,27 @@ var ThunderIDExpressClient = class extends ThunderIDNodeClient {
|
|
|
74
72
|
get expressConfig() {
|
|
75
73
|
return this._expressConfig;
|
|
76
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Resolves the session cookie name for this client instance, honoring an
|
|
77
|
+
* explicit `sessionCookie.name` override before falling back to the
|
|
78
|
+
* `vendor`-derived default (which itself defaults to `'thunderid'`).
|
|
79
|
+
*/
|
|
80
|
+
getSessionCookieName() {
|
|
81
|
+
return CookieConfig.resolveSessionCookieName(this._expressConfig?.vendor, this._expressConfig?.sessionCookie?.name);
|
|
82
|
+
}
|
|
77
83
|
async getUserFromRequest(req) {
|
|
78
|
-
const sessionId = req.cookies?.[
|
|
84
|
+
const sessionId = req.cookies?.[this.getSessionCookieName()];
|
|
79
85
|
return this.getUser(sessionId);
|
|
80
86
|
}
|
|
81
87
|
async signIn(req, res, next, signInConfig) {
|
|
82
88
|
if (expressUtils_default(req.originalUrl)) return Promise.reject(new ThunderIDAuthException("EXPRESS-CLIENT-SI-IV01", "Invalid login request URL", "Login request contains an error query parameter in the URL"));
|
|
83
|
-
|
|
89
|
+
const cookieName = this.getSessionCookieName();
|
|
90
|
+
let userId = req.cookies?.[cookieName];
|
|
84
91
|
if (!userId) userId = v4();
|
|
85
92
|
const sc = this._expressConfig?.sessionCookie;
|
|
86
93
|
const authRedirectCallback = (url) => {
|
|
87
94
|
if (!url) return;
|
|
88
|
-
res.cookie(
|
|
95
|
+
res.cookie(cookieName, userId, {
|
|
89
96
|
httpOnly: sc?.httpOnly ?? CookieConfig_default.defaultHttpOnly,
|
|
90
97
|
maxAge: (sc?.expiryTime ?? CookieConfig_default.defaultExpirySeconds) * 1e3,
|
|
91
98
|
sameSite: sc?.sameSite ?? CookieConfig_default.defaultSameSite,
|
|
@@ -218,7 +225,8 @@ const handleSignOut = () => {
|
|
|
218
225
|
onSignOut(res);
|
|
219
226
|
return;
|
|
220
227
|
}
|
|
221
|
-
const
|
|
228
|
+
const cookieName = client.getSessionCookieName();
|
|
229
|
+
const sessionId = req.cookies?.[cookieName];
|
|
222
230
|
if (!sessionId) {
|
|
223
231
|
onError(res, new ThunderIDRuntimeError("No cookie found in the request", "EXPRESS-AUTH_MW-LOGOUT-NF01", "express"));
|
|
224
232
|
return;
|
|
@@ -226,7 +234,7 @@ const handleSignOut = () => {
|
|
|
226
234
|
try {
|
|
227
235
|
const signOutURL = await client.signOut(sessionId);
|
|
228
236
|
if (signOutURL) {
|
|
229
|
-
res.cookie(
|
|
237
|
+
res.cookie(cookieName, null, { maxAge: 0 });
|
|
230
238
|
res.redirect(signOutURL);
|
|
231
239
|
}
|
|
232
240
|
} catch (e) {
|
|
@@ -248,7 +256,7 @@ const handleSignOut = () => {
|
|
|
248
256
|
const protect = (onUnauthenticated) => {
|
|
249
257
|
return async (req, res, next) => {
|
|
250
258
|
const client = req.thunderIDAuth;
|
|
251
|
-
const sessionId = req.cookies?.[
|
|
259
|
+
const sessionId = req.cookies?.[client?.getSessionCookieName() ?? ""];
|
|
252
260
|
const reject = () => {
|
|
253
261
|
if (onUnauthenticated) onUnauthenticated(res);
|
|
254
262
|
else res.status(401).end();
|
|
@@ -352,4 +360,4 @@ const handleFlow = () => {
|
|
|
352
360
|
var flow_default = handleFlow;
|
|
353
361
|
|
|
354
362
|
//#endregion
|
|
355
|
-
export { CookieConfig_default as CookieConfig,
|
|
363
|
+
export { CookieConfig_default as CookieConfig, ThunderIDExpressClient_default as ThunderIDExpressClient, flow_default as handleFlow, handleSignIn, handleSignOut, protect_default as protect, thunderID };
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,6 @@ export { thunderID, handleSignIn, handleSignOut } from './middleware/authenticat
|
|
|
20
20
|
export { default as protect } from './middleware/protect';
|
|
21
21
|
export { default as handleFlow } from './middleware/flow';
|
|
22
22
|
export type { ExpressClientConfig, ThunderIDExpressConfig, StrictExpressClientConfig } from './models/config';
|
|
23
|
-
export { default as CookieConfig
|
|
23
|
+
export { default as CookieConfig } from './constants/CookieConfig';
|
|
24
24
|
export * from '@thunderid/node';
|
|
25
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAC,OAAO,IAAI,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAG3E,OAAO,EAAC,SAAS,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAGxD,YAAY,EAAC,mBAAmB,EAAE,sBAAsB,EAAE,yBAAyB,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAC,OAAO,IAAI,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAG3E,OAAO,EAAC,SAAS,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAGxD,YAAY,EAAC,mBAAmB,EAAE,sBAAsB,EAAE,yBAAyB,EAAC,MAAM,iBAAiB,CAAC;AAK5G,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAIjE,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ThunderIDAuthException, ThunderIDNodeClient, ThunderIDRuntimeError, executeEmbeddedSignInFlow, logger } from "@thunderid/node";
|
|
1
|
+
import { CookieConfig, ThunderIDAuthException, ThunderIDNodeClient, ThunderIDRuntimeError, executeEmbeddedSignInFlow, logger } from "@thunderid/node";
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
3
|
|
|
4
4
|
export * from "@thunderid/node"
|
|
@@ -21,16 +21,14 @@ export * from "@thunderid/node"
|
|
|
21
21
|
* specific language governing permissions and limitations
|
|
22
22
|
* under the License.
|
|
23
23
|
*/
|
|
24
|
-
/** Session cookie name used across the Express SDK. */
|
|
25
|
-
const SESSION_COOKIE_NAME = "THUNDERID_SESSION_ID";
|
|
26
24
|
/** Default cookie configuration values. */
|
|
27
|
-
const CookieConfig = {
|
|
25
|
+
const CookieConfig$1 = {
|
|
28
26
|
defaultExpirySeconds: 86400,
|
|
29
27
|
defaultHttpOnly: true,
|
|
30
28
|
defaultSameSite: "lax",
|
|
31
29
|
defaultSecure: false
|
|
32
30
|
};
|
|
33
|
-
var CookieConfig_default = CookieConfig;
|
|
31
|
+
var CookieConfig_default = CookieConfig$1;
|
|
34
32
|
|
|
35
33
|
//#endregion
|
|
36
34
|
//#region src/utils/expressUtils.ts
|
|
@@ -74,18 +72,27 @@ var ThunderIDExpressClient = class extends ThunderIDNodeClient {
|
|
|
74
72
|
get expressConfig() {
|
|
75
73
|
return this._expressConfig;
|
|
76
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Resolves the session cookie name for this client instance, honoring an
|
|
77
|
+
* explicit `sessionCookie.name` override before falling back to the
|
|
78
|
+
* `vendor`-derived default (which itself defaults to `'thunderid'`).
|
|
79
|
+
*/
|
|
80
|
+
getSessionCookieName() {
|
|
81
|
+
return CookieConfig.resolveSessionCookieName(this._expressConfig?.vendor, this._expressConfig?.sessionCookie?.name);
|
|
82
|
+
}
|
|
77
83
|
async getUserFromRequest(req) {
|
|
78
|
-
const sessionId = req.cookies?.[
|
|
84
|
+
const sessionId = req.cookies?.[this.getSessionCookieName()];
|
|
79
85
|
return this.getUser(sessionId);
|
|
80
86
|
}
|
|
81
87
|
async signIn(req, res, next, signInConfig) {
|
|
82
88
|
if (expressUtils_default(req.originalUrl)) return Promise.reject(new ThunderIDAuthException("EXPRESS-CLIENT-SI-IV01", "Invalid login request URL", "Login request contains an error query parameter in the URL"));
|
|
83
|
-
|
|
89
|
+
const cookieName = this.getSessionCookieName();
|
|
90
|
+
let userId = req.cookies?.[cookieName];
|
|
84
91
|
if (!userId) userId = v4();
|
|
85
92
|
const sc = this._expressConfig?.sessionCookie;
|
|
86
93
|
const authRedirectCallback = (url) => {
|
|
87
94
|
if (!url) return;
|
|
88
|
-
res.cookie(
|
|
95
|
+
res.cookie(cookieName, userId, {
|
|
89
96
|
httpOnly: sc?.httpOnly ?? CookieConfig_default.defaultHttpOnly,
|
|
90
97
|
maxAge: (sc?.expiryTime ?? CookieConfig_default.defaultExpirySeconds) * 1e3,
|
|
91
98
|
sameSite: sc?.sameSite ?? CookieConfig_default.defaultSameSite,
|
|
@@ -218,7 +225,8 @@ const handleSignOut = () => {
|
|
|
218
225
|
onSignOut(res);
|
|
219
226
|
return;
|
|
220
227
|
}
|
|
221
|
-
const
|
|
228
|
+
const cookieName = client.getSessionCookieName();
|
|
229
|
+
const sessionId = req.cookies?.[cookieName];
|
|
222
230
|
if (!sessionId) {
|
|
223
231
|
onError(res, new ThunderIDRuntimeError("No cookie found in the request", "EXPRESS-AUTH_MW-LOGOUT-NF01", "express"));
|
|
224
232
|
return;
|
|
@@ -226,7 +234,7 @@ const handleSignOut = () => {
|
|
|
226
234
|
try {
|
|
227
235
|
const signOutURL = await client.signOut(sessionId);
|
|
228
236
|
if (signOutURL) {
|
|
229
|
-
res.cookie(
|
|
237
|
+
res.cookie(cookieName, null, { maxAge: 0 });
|
|
230
238
|
res.redirect(signOutURL);
|
|
231
239
|
}
|
|
232
240
|
} catch (e) {
|
|
@@ -248,7 +256,7 @@ const handleSignOut = () => {
|
|
|
248
256
|
const protect = (onUnauthenticated) => {
|
|
249
257
|
return async (req, res, next) => {
|
|
250
258
|
const client = req.thunderIDAuth;
|
|
251
|
-
const sessionId = req.cookies?.[
|
|
259
|
+
const sessionId = req.cookies?.[client?.getSessionCookieName() ?? ""];
|
|
252
260
|
const reject = () => {
|
|
253
261
|
if (onUnauthenticated) onUnauthenticated(res);
|
|
254
262
|
else res.status(401).end();
|
|
@@ -352,4 +360,4 @@ const handleFlow = () => {
|
|
|
352
360
|
var flow_default = handleFlow;
|
|
353
361
|
|
|
354
362
|
//#endregion
|
|
355
|
-
export { CookieConfig_default as CookieConfig,
|
|
363
|
+
export { CookieConfig_default as CookieConfig, ThunderIDExpressClient_default as ThunderIDExpressClient, flow_default as handleFlow, handleSignIn, handleSignOut, protect_default as protect, thunderID };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../../src/middleware/authentication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,OAAO,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../../src/middleware/authentication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AAGxD;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,SAAS,GAAI,QAAQ,sBAAsB,KAAG,OAAO,CAAC,cAsB3D,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,YAAY,QAAO,OAAO,CAAC,cA6BhC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,aAAa,QAAO,OAAO,CAAC,cA6CjC,CAAC;AAEF,OAAO,EAAC,SAAS,EAAE,YAAY,EAAE,aAAa,EAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protect.d.ts","sourceRoot":"","sources":["../../src/middleware/protect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,OAAO,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"protect.d.ts","sourceRoot":"","sources":["../../src/middleware/protect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B;;;;;;;GAOG;AACH,QAAA,MAAM,OAAO,GACX,oBAAoB,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,KAAK,IAAI,KAClD,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CA4B7F,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/dist/models/config.d.ts
CHANGED
|
@@ -40,6 +40,13 @@ export interface StrictExpressClientConfig {
|
|
|
40
40
|
*
|
|
41
41
|
* Set `mode: 'embedded'` to enable app-native embedded auth via `handleFlow()`.
|
|
42
42
|
* Defaults to `'redirect'` (standard OAuth 2.0 authorization-code flow).
|
|
43
|
+
*
|
|
44
|
+
* Inherits `vendor` and `sessionCookie.name` from `ThunderIDNodeConfig` — set
|
|
45
|
+
* either to control the session cookie name written by this SDK (default:
|
|
46
|
+
* `__thunderid__session`, the same `@thunderid/node` `CookieConfig` naming
|
|
47
|
+
* convention used by every server-side ThunderID SDK, derived from `vendor`
|
|
48
|
+
* defaulting to `'thunderid'`). `sessionCookie.name` takes priority over the
|
|
49
|
+
* `vendor`-derived default.
|
|
43
50
|
*/
|
|
44
51
|
export type ExpressClientConfig = ThunderIDNodeConfig & StrictExpressClientConfig;
|
|
45
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/models/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,mBAAmB,EAAE,qBAAqB,EAAE,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC1F,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,aAAa,KAAK,IAAI,CAAC;IACzE,uDAAuD;IACvD,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;IAC5C,oEAAoE;IACpE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAC5E,2FAA2F;IAC3F,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;CACrD;AAED
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/models/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,mBAAmB,EAAE,qBAAqB,EAAE,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC1F,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,aAAa,KAAK,IAAI,CAAC;IACzE,uDAAuD;IACvD,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;IAC5C,oEAAoE;IACpE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAC5E,2FAA2F;IAC3F,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,GAAG,yBAAyB,CAAC;AAElF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thunderid/express",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Express.js SDK for ThunderID",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"thunderid",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"uuid": "11.1.1",
|
|
51
|
-
"@thunderid/node": "^0.
|
|
51
|
+
"@thunderid/node": "^0.5.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"express": ">=4.21.2"
|