@adminforth/two-factors-auth 2.10.3 → 2.10.4

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/build.log CHANGED
@@ -15,5 +15,5 @@ custom/package.json
15
15
  custom/tsconfig.json
16
16
  custom/utils.js
17
17
 
18
- sent 273,585 bytes received 210 bytes 547,590.00 bytes/sec
18
+ sent 273,574 bytes received 210 bytes 547,568.00 bytes/sec
19
19
  total size is 272,758 speedup is 1.00
package/dist/index.js CHANGED
@@ -51,7 +51,6 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
51
51
  const userAgent = headers['user-agent'] || '';
52
52
  const acceptLanguage = headers['accept-language'] || '';
53
53
  const session_cookie = this.adminforth.auth.getCustomCookie({ cookies: cookies, name: "jwt" });
54
- console.log("👺👺👺👺👺👺👺👺👺 Generating hash for Step-Up MFA grace cookie with ip:", ip, "userAgent:", userAgent, "acceptLanguage:", acceptLanguage, "session_cookie:", session_cookie);
55
54
  if (!ip || !userAgent || !acceptLanguage || !session_cookie) {
56
55
  console.error("❗️❗️❗️ Cannot set step-up MFA grace cookie: missing required request headers to identify client ❗️❗️❗️");
57
56
  return null;
@@ -60,23 +59,18 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
60
59
  const hmac = crypto.createHmac('sha256', process.env.ADMINFORTH_SECRET)
61
60
  .update(`${acceptLanguage}_${userAgent}_${ip}_${session_cookie}`)
62
61
  .digest('hex');
63
- console.log("👺👺👺👺👺👺👺👺👺 Generated hash for Step-Up MFA grace cookie:", hmac);
64
62
  return hmac;
65
63
  }
66
64
  }
67
65
  issueTempSkip2FAGraceJWT(opts) {
68
- console.log("👺👺👺👺👺👺👺👺👺 Issuing TempSkip2FAGraceJWT");
69
66
  if (opts.response) {
70
67
  if (opts.extra.headers) {
71
- console.log("👺👺👺👺👺👺👺👺👺 Issuing TempSkip2FAGraceJWT with headers:", opts.extra.headers);
72
68
  const hash = this.generateHashForStepUpMfaGraceCookie(opts.extra.headers, opts.cookies);
73
69
  if (!hash) {
74
70
  return;
75
71
  }
76
- console.log("👺👺👺👺👺👺👺👺👺 Issuing TempSkip2FAGraceJWT with hash:", hash);
77
72
  const jwt = this.adminforth.auth.issueJWT({ hash: hash }, 'MfaGrace', `${this.options.stepUpMfaGracePeriodSeconds}s`);
78
73
  //TODO: fix ts-ignore after releasing new version of adminforth with updated types
79
- console.log("👺👺👺👺👺👺👺👺👺 Issuing TempSkip2FAGraceJWT with jwt:", jwt);
80
74
  //@ts-ignore
81
75
  this.adminforth.auth.setCustomCookie({ response: opts.response, payload: { name: "TempSkip2FA_Modal_JWT", value: jwt, expirySeconds: this.options.stepUpMfaGracePeriodSeconds, httpOnly: true } });
82
76
  }
@@ -110,35 +104,27 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
110
104
  verify(confirmationResult, opts) {
111
105
  return __awaiter(this, void 0, void 0, function* () {
112
106
  var _a, _b, _c, _d, _e;
113
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify called with confirmationResult:", confirmationResult);
114
107
  if (!confirmationResult)
115
108
  return { error: "Confirmation result is required" };
116
109
  if (this.options.usersFilterToApply) {
117
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify called with adminUser:", opts.adminUser);
118
110
  const res = this.options.usersFilterToApply(opts.adminUser);
119
111
  if (res === false) {
120
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify skipped due to usersFilterToApply");
121
112
  return { ok: true };
122
113
  }
123
114
  }
124
115
  if (this.options.usersFilterToAllowSkipSetup) {
125
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify called with adminUser for usersFilterToAllowSkipSetup:", opts.adminUser);
126
116
  const res = yield this.checkIfSkipSetupAllowSkipVerify(opts.adminUser);
127
117
  if (res.skipAllowed === true) {
128
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify skipped due to usersFilterToAllowSkipVerify");
129
118
  return { ok: true };
130
119
  }
131
120
  }
132
121
  if (this.options.stepUpMfaGracePeriodSeconds && ((_a = opts.extra) === null || _a === void 0 ? void 0 : _a.headers) && !confirmationResult.mode) {
133
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify called with stepUpMfaGracePeriodSeconds and no mode");
134
122
  const verificationResult = yield this.isTempSkip2FAGraceValid(opts.extra.headers, opts.cookies);
135
123
  if (verificationResult === true) {
136
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify skipped due to valid step-up MFA grace cookie");
137
124
  return { ok: true };
138
125
  }
139
126
  }
140
127
  if (confirmationResult.mode === "totp") {
141
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify called with mode totp");
142
128
  const code = confirmationResult.result;
143
129
  const authRes = this.adminforth.config.resources
144
130
  .find(r => r.resourceId === this.adminforth.config.auth.usersResourceId);
@@ -161,7 +147,6 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
161
147
  //* SET GRACE COOKIE *//
162
148
  if (verified) {
163
149
  if (this.options.stepUpMfaGracePeriodSeconds) {
164
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Setting grace cookie due to stepUpMfaGracePeriodSeconds");
165
150
  this.issueTempSkip2FAGraceJWT(opts);
166
151
  }
167
152
  return { ok: true };
@@ -182,10 +167,8 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
182
167
  }
183
168
  const verificationResult = yield this.verifyPasskeyResponse(confirmationResult.result, opts.userPk, decodedPasskeysCookies);
184
169
  if (verificationResult.ok && verificationResult.passkeyConfirmed) {
185
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify passed with mode passkey");
186
170
  //* SET GRACE COOKIE *//
187
171
  if (this.options.stepUpMfaGracePeriodSeconds) {
188
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Setting grace cookie due to stepUpMfaGracePeriodSeconds");
189
172
  this.issueTempSkip2FAGraceJWT(opts);
190
173
  }
191
174
  return { ok: true };
package/index.ts CHANGED
@@ -60,7 +60,6 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
60
60
  const userAgent = headers['user-agent'] || '';
61
61
  const acceptLanguage = headers['accept-language'] || '';
62
62
  const session_cookie = this.adminforth.auth.getCustomCookie({cookies: cookies, name: "jwt"});
63
- console.log("👺👺👺👺👺👺👺👺👺 Generating hash for Step-Up MFA grace cookie with ip:", ip, "userAgent:", userAgent, "acceptLanguage:", acceptLanguage, "session_cookie:", session_cookie);
64
63
  if (!ip || !userAgent || !acceptLanguage || !session_cookie) {
65
64
  console.error("❗️❗️❗️ Cannot set step-up MFA grace cookie: missing required request headers to identify client ❗️❗️❗️");
66
65
  return null;
@@ -68,24 +67,19 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
68
67
  const hmac = crypto.createHmac('sha256', process.env.ADMINFORTH_SECRET)
69
68
  .update(`${acceptLanguage}_${userAgent}_${ip}_${session_cookie}`)
70
69
  .digest('hex');
71
- console.log("👺👺👺👺👺👺👺👺👺 Generated hash for Step-Up MFA grace cookie:", hmac);
72
70
  return hmac;
73
71
  }
74
72
  }
75
73
 
76
74
  private issueTempSkip2FAGraceJWT(opts): void {
77
- console.log("👺👺👺👺👺👺👺👺👺 Issuing TempSkip2FAGraceJWT");
78
75
  if (opts.response) {
79
76
  if (opts.extra.headers) {
80
- console.log("👺👺👺👺👺👺👺👺👺 Issuing TempSkip2FAGraceJWT with headers:", opts.extra.headers);
81
77
  const hash = this.generateHashForStepUpMfaGraceCookie(opts.extra.headers, opts.cookies);
82
78
  if (!hash) {
83
79
  return;
84
80
  }
85
- console.log("👺👺👺👺👺👺👺👺👺 Issuing TempSkip2FAGraceJWT with hash:", hash);
86
81
  const jwt = this.adminforth.auth.issueJWT({ hash: hash }, 'MfaGrace', `${this.options.stepUpMfaGracePeriodSeconds}s`);
87
82
  //TODO: fix ts-ignore after releasing new version of adminforth with updated types
88
- console.log("👺👺👺👺👺👺👺👺👺 Issuing TempSkip2FAGraceJWT with jwt:", jwt);
89
83
  //@ts-ignore
90
84
  this.adminforth.auth.setCustomCookie({response: opts.response, payload: {name: "TempSkip2FA_Modal_JWT", value: jwt, expirySeconds: this.options.stepUpMfaGracePeriodSeconds, httpOnly: true}});
91
85
  }
@@ -119,35 +113,27 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
119
113
  confirmationResult: Record<string, any>,
120
114
  opts?: { adminUser?: AdminUser; userPk?: string; cookies?: any, response?: IAdminForthHttpResponse, extra?: HttpExtra }
121
115
  ): Promise<{ ok: true } | { error: string }> {
122
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify called with confirmationResult:", confirmationResult);
123
116
  if (!confirmationResult) return { error: "Confirmation result is required" };
124
117
  if (this.options.usersFilterToApply) {
125
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify called with adminUser:", opts.adminUser);
126
118
  const res = this.options.usersFilterToApply(opts.adminUser);
127
119
  if ( res === false ) {
128
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify skipped due to usersFilterToApply");
129
120
  return { ok: true };
130
121
  }
131
122
  }
132
123
  if (this.options.usersFilterToAllowSkipSetup) {
133
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify called with adminUser for usersFilterToAllowSkipSetup:", opts.adminUser);
134
124
  const res = await this.checkIfSkipSetupAllowSkipVerify(opts.adminUser);
135
125
  if ( res.skipAllowed === true ) {
136
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify skipped due to usersFilterToAllowSkipVerify");
137
126
  return { ok: true };
138
127
  }
139
128
  }
140
129
  if ( this.options.stepUpMfaGracePeriodSeconds && opts.extra?.headers && !confirmationResult.mode) {
141
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify called with stepUpMfaGracePeriodSeconds and no mode");
142
130
  const verificationResult = await this.isTempSkip2FAGraceValid(opts.extra.headers, opts.cookies);
143
131
  if ( verificationResult === true ) {
144
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify skipped due to valid step-up MFA grace cookie");
145
132
  return { ok: true };
146
133
  }
147
134
  }
148
135
 
149
136
  if (confirmationResult.mode === "totp") {
150
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify called with mode totp");
151
137
  const code = confirmationResult.result;
152
138
  const authRes = this.adminforth.config.resources
153
139
  .find(r => r.resourceId === this.adminforth.config.auth.usersResourceId);
@@ -172,7 +158,6 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
172
158
  //* SET GRACE COOKIE *//
173
159
  if ( verified ) {
174
160
  if (this.options.stepUpMfaGracePeriodSeconds) {
175
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Setting grace cookie due to stepUpMfaGracePeriodSeconds");
176
161
  this.issueTempSkip2FAGraceJWT(opts);
177
162
  }
178
163
  return { ok: true }
@@ -192,10 +177,9 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
192
177
  const verificationResult = await this.verifyPasskeyResponse(confirmationResult.result, opts.userPk, decodedPasskeysCookies );
193
178
 
194
179
  if (verificationResult.ok && verificationResult.passkeyConfirmed) {
195
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Verify passed with mode passkey");
180
+
196
181
  //* SET GRACE COOKIE *//
197
182
  if (this.options.stepUpMfaGracePeriodSeconds) {
198
- console.log("🥵🥵🥵🥵🥵🥵🥵🥵TFA Setting grace cookie due to stepUpMfaGracePeriodSeconds");
199
183
  this.issueTempSkip2FAGraceJWT(opts);
200
184
  }
201
185
  return { ok: true }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "2.10.3",
3
+ "version": "2.10.4",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",