@adminforth/two-factors-auth 1.0.2 → 1.0.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/index.js CHANGED
@@ -57,7 +57,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
57
57
  }
58
58
  else {
59
59
  const value = this.adminforth.auth.issueJWT({ userName, issuer: brandName, pk: userPk }, 'tempTotp');
60
- response.setHeader('Set-Cookie', `adminforth_totpTemporaryJWT=${value}; Path=${this.adminforth.config.baseUrl || '/'}; HttpOnly; SameSite=Strict; Expires=${new Date(Date.now() + '1h').toUTCString()} `);
60
+ response.setHeader('Set-Cookie', `adminforth_totpTemporaryJWT=${value}; Path=${this.adminforth.config.baseUrl || '/'}; HttpOnly; SameSite=Strict; max-age=3600; `);
61
61
  return {
62
62
  body: {
63
63
  loginAllowed: false,
@@ -83,8 +83,9 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
83
83
  path: `/plugin/twofa/initSetup`,
84
84
  noAuth: true,
85
85
  handler: (server) => __awaiter(this, void 0, void 0, function* () {
86
+ var _a;
86
87
  const toReturn = { totpJWT: null, status: 'ok', };
87
- const totpTemporaryJWT = server.cookies['adminforth_totpTemporaryJWT'];
88
+ const totpTemporaryJWT = (_a = server.cookies.find((cookie) => cookie.key === 'adminforth_totpTemporaryJWT')) === null || _a === void 0 ? void 0 : _a.value;
88
89
  if (totpTemporaryJWT) {
89
90
  toReturn.totpJWT = totpTemporaryJWT;
90
91
  }
@@ -95,7 +96,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
95
96
  method: 'POST',
96
97
  path: `/plugin/twofa/confirmSetup`,
97
98
  noAuth: true,
98
- handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, response, cookies }) {
99
+ handler: (_b) => __awaiter(this, [_b], void 0, function* ({ body, adminUser, response, cookies }) {
99
100
  const totpTemporaryJWT = cookies['adminforth_totpTemporaryJWT'];
100
101
  const decoded = yield this.adminforth.auth.verify(totpTemporaryJWT, 'tempTotp');
101
102
  if (!decoded) {
package/index.ts CHANGED
@@ -59,7 +59,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
59
59
  newSecret = tempSecret.secret
60
60
  } else {
61
61
  const value = this.adminforth.auth.issueJWT({userName, issuer:brandName, pk:userPk },'tempTotp');
62
- response.setHeader('Set-Cookie', `adminforth_totpTemporaryJWT=${value}; Path=${this.adminforth.config.baseUrl || '/'}; HttpOnly; SameSite=Strict; Expires=${new Date(Date.now() + '1h').toUTCString() } `);
62
+ response.setHeader('Set-Cookie', `adminforth_totpTemporaryJWT=${value}; Path=${this.adminforth.config.baseUrl || '/'}; HttpOnly; SameSite=Strict; max-age=3600; `);
63
63
 
64
64
  return {
65
65
  body:{
@@ -91,7 +91,8 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
91
91
  noAuth: true,
92
92
  handler: async (server) => {
93
93
  const toReturn = {totpJWT:null,status:'ok',}
94
- const totpTemporaryJWT = server.cookies['adminforth_totpTemporaryJWT']
94
+
95
+ const totpTemporaryJWT = server.cookies.find((cookie)=>cookie.key === 'adminforth_totpTemporaryJWT')?.value;
95
96
  if (totpTemporaryJWT){
96
97
  toReturn.totpJWT = totpTemporaryJWT
97
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",