@thunderid/express 1.3.0 → 1.3.1

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.
@@ -14,7 +14,7 @@ declare class ThunderIDExpressClient<T extends ExpressClientConfig = ExpressClie
14
14
  getSessionCookieName(): string;
15
15
  getUserFromRequest(req: express.Request): Promise<User | undefined>;
16
16
  updateUserCredentialsFromRequest(req: express.Request, payload: Record<string, string>): Promise<void>;
17
- signIn(req: express.Request, res: express.Response, next: express.NextFunction, signInConfig?: Record<string, string | boolean>): Promise<TokenResponse>;
17
+ signIn(req: express.Request, res: express.Response, next?: express.NextFunction, signInConfig?: Record<string, string | boolean>): Promise<TokenResponse>;
18
18
  signOut(userId?: string): Promise<string>;
19
19
  }
20
20
  export default ThunderIDExpressClient;
@@ -1 +1 @@
1
- {"version":3,"file":"ThunderIDExpressClient.d.ts","sourceRoot":"","sources":["../src/ThunderIDExpressClient.ts"],"names":[],"mappings":"AAGA,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;IAMnE,gCAAgC,CAAC,GAAG,EAA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,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7F,MAAM,CAC1B,GAAG,EAAE,OAAO,CAAC,OAAO,EACpB,GAAG,EAAE,OAAO,CAAC,QAAQ,EACrB,IAAI,CAAC,EAAE,OAAO,CAAC,YAAY,EAC3B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAC9C,OAAO,CAAC,aAAa,CAAC;IAuDH,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAGhE;AAED,eAAe,sBAAsB,CAAC"}
@@ -94,7 +94,6 @@ var ThunderIDExpressClient = class extends __thunderid_node.ThunderIDNodeClient
94
94
  secure: sc?.secure ?? CookieConfig_default.defaultSecure
95
95
  });
96
96
  res.redirect(url);
97
- if (typeof next === "function") next();
98
97
  };
99
98
  const authResponse = await super.signIn(authRedirectCallback, userId, req.query["code"], req.query["state"], signInConfig);
100
99
  if (authResponse.accessToken || authResponse.idToken) return authResponse;
@@ -256,13 +255,18 @@ const protect = (onUnauthenticated) => {
256
255
  if (onUnauthenticated) onUnauthenticated(res);
257
256
  else res.status(401).end();
258
257
  };
259
- if (!client || !sessionId) {
260
- __thunderid_node.logger.error("No session ID found in the request cookies");
258
+ if (!client) {
259
+ __thunderid_node.logger.error("thunderID() middleware must be mounted before protect()");
260
+ reject();
261
+ return;
262
+ }
263
+ if (!sessionId) {
264
+ __thunderid_node.logger.debug("No session ID found in the request cookies");
261
265
  reject();
262
266
  return;
263
267
  }
264
268
  if (await client.isSignedIn(sessionId) ?? false) return next();
265
- __thunderid_node.logger.error("Invalid session ID found in the request cookies");
269
+ __thunderid_node.logger.debug("The session in the request cookies is not signed in");
266
270
  reject();
267
271
  };
268
272
  };
@@ -70,7 +70,6 @@ var ThunderIDExpressClient = class extends ThunderIDNodeClient {
70
70
  secure: sc?.secure ?? CookieConfig_default.defaultSecure
71
71
  });
72
72
  res.redirect(url);
73
- if (typeof next === "function") next();
74
73
  };
75
74
  const authResponse = await super.signIn(authRedirectCallback, userId, req.query["code"], req.query["state"], signInConfig);
76
75
  if (authResponse.accessToken || authResponse.idToken) return authResponse;
@@ -232,13 +231,18 @@ const protect = (onUnauthenticated) => {
232
231
  if (onUnauthenticated) onUnauthenticated(res);
233
232
  else res.status(401).end();
234
233
  };
235
- if (!client || !sessionId) {
236
- logger.error("No session ID found in the request cookies");
234
+ if (!client) {
235
+ logger.error("thunderID() middleware must be mounted before protect()");
236
+ reject();
237
+ return;
238
+ }
239
+ if (!sessionId) {
240
+ logger.debug("No session ID found in the request cookies");
237
241
  reject();
238
242
  return;
239
243
  }
240
244
  if (await client.isSignedIn(sessionId) ?? false) return next();
241
- logger.error("Invalid session ID found in the request cookies");
245
+ logger.debug("The session in the request cookies is not signed in");
242
246
  reject();
243
247
  };
244
248
  };
package/dist/index.js CHANGED
@@ -70,7 +70,6 @@ var ThunderIDExpressClient = class extends ThunderIDNodeClient {
70
70
  secure: sc?.secure ?? CookieConfig_default.defaultSecure
71
71
  });
72
72
  res.redirect(url);
73
- if (typeof next === "function") next();
74
73
  };
75
74
  const authResponse = await super.signIn(authRedirectCallback, userId, req.query["code"], req.query["state"], signInConfig);
76
75
  if (authResponse.accessToken || authResponse.idToken) return authResponse;
@@ -232,13 +231,18 @@ const protect = (onUnauthenticated) => {
232
231
  if (onUnauthenticated) onUnauthenticated(res);
233
232
  else res.status(401).end();
234
233
  };
235
- if (!client || !sessionId) {
236
- logger.error("No session ID found in the request cookies");
234
+ if (!client) {
235
+ logger.error("thunderID() middleware must be mounted before protect()");
236
+ reject();
237
+ return;
238
+ }
239
+ if (!sessionId) {
240
+ logger.debug("No session ID found in the request cookies");
237
241
  reject();
238
242
  return;
239
243
  }
240
244
  if (await client.isSignedIn(sessionId) ?? false) return next();
241
- logger.error("Invalid session ID found in the request cookies");
245
+ logger.debug("The session in the request cookies is not signed in");
242
246
  reject();
243
247
  };
244
248
  };
@@ -1 +1 @@
1
- {"version":3,"file":"protect.d.ts","sourceRoot":"","sources":["../../src/middleware/protect.ts"],"names":[],"mappings":"AAIA,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"}
1
+ {"version":3,"file":"protect.d.ts","sourceRoot":"","sources":["../../src/middleware/protect.ts"],"names":[],"mappings":"AAIA,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,CAmC7F,CAAC;AAEF,eAAe,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thunderid/express",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Express.js SDK for ThunderID",
5
5
  "keywords": [
6
6
  "thunderid",
@@ -47,7 +47,7 @@
47
47
  "vitest": "4.1.11"
48
48
  },
49
49
  "dependencies": {
50
- "@thunderid/node": "^1.3.0",
50
+ "@thunderid/node": "^1.3.1",
51
51
  "uuid": "11.1.1"
52
52
  },
53
53
  "peerDependencies": {