@adminforth/two-factors-auth 3.1.0 → 3.1.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.
package/build.log CHANGED
@@ -16,5 +16,5 @@ custom/pnpm-lock.yaml
16
16
  custom/tsconfig.json
17
17
  custom/utils.js
18
18
 
19
- sent 282,665 bytes received 229 bytes 565,788.00 bytes/sec
19
+ sent 282,653 bytes received 229 bytes 565,764.00 bytes/sec
20
20
  total size is 281,759 speedup is 1.00
package/dist/index.js CHANGED
@@ -157,15 +157,15 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
157
157
  }
158
158
  verify(confirmationResult, opts) {
159
159
  return __awaiter(this, void 0, void 0, function* () {
160
- var _a, _b, _c, _d, _e;
160
+ var _a, _b, _c, _d, _e, _f, _g;
161
161
  if (!confirmationResult)
162
162
  return { error: "Confirmation result is required" };
163
163
  if (!opts.adminUser)
164
164
  return { error: "Admin user is required" };
165
165
  if (!opts.userPk)
166
166
  return { error: "User PK is required" };
167
- const cookies = opts.extra.cookies || opts.cookies;
168
- const response = opts.extra.response || opts.response;
167
+ const cookies = ((_a = opts.extra) === null || _a === void 0 ? void 0 : _a.cookies) || opts.cookies;
168
+ const response = ((_b = opts.extra) === null || _b === void 0 ? void 0 : _b.response) || opts.response;
169
169
  if (this.options.usersFilterToApply) {
170
170
  const res = this.options.usersFilterToApply(opts.adminUser);
171
171
  if (res === false) {
@@ -178,7 +178,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
178
178
  return { ok: true };
179
179
  }
180
180
  }
181
- if (this.options.stepUpMfaGracePeriodSeconds && ((_a = opts.extra) === null || _a === void 0 ? void 0 : _a.headers) && !confirmationResult.mode) {
181
+ if (this.options.stepUpMfaGracePeriodSeconds && ((_c = opts.extra) === null || _c === void 0 ? void 0 : _c.headers) && !confirmationResult.mode) {
182
182
  const verificationResult = yield this.isTempSkip2FAGraceValid(opts.extra.headers, cookies);
183
183
  if (verificationResult === true) {
184
184
  return { ok: true };
@@ -191,10 +191,10 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
191
191
  if (!authRes)
192
192
  return { error: "Auth resource not found" };
193
193
  const connector = this.adminforth.connectors[authRes.dataSource];
194
- const pkName = (_b = authRes.columns.find(c => c.primaryKey)) === null || _b === void 0 ? void 0 : _b.name;
194
+ const pkName = (_d = authRes.columns.find(c => c.primaryKey)) === null || _d === void 0 ? void 0 : _d.name;
195
195
  if (!pkName)
196
196
  return { error: "Primary key not found on auth resource" };
197
- const pk = (_c = opts === null || opts === void 0 ? void 0 : opts.userPk) !== null && _c !== void 0 ? _c : (_e = (_d = opts === null || opts === void 0 ? void 0 : opts.adminUser) === null || _d === void 0 ? void 0 : _d.dbUser) === null || _e === void 0 ? void 0 : _e[pkName];
197
+ const pk = (_e = opts === null || opts === void 0 ? void 0 : opts.userPk) !== null && _e !== void 0 ? _e : (_g = (_f = opts === null || opts === void 0 ? void 0 : opts.adminUser) === null || _f === void 0 ? void 0 : _f.dbUser) === null || _g === void 0 ? void 0 : _g[pkName];
198
198
  if (!pk)
199
199
  return { error: "User PK is required" };
200
200
  const user = yield connector.getRecordByPrimaryKey(authRes, pk);
package/index.ts CHANGED
@@ -172,8 +172,8 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
172
172
  if (!confirmationResult) return { error: "Confirmation result is required" };
173
173
  if (!opts.adminUser) return { error: "Admin user is required" };
174
174
  if (!opts.userPk) return { error: "User PK is required" };
175
- const cookies = opts.extra.cookies || opts.cookies;
176
- const response = opts.extra.response || opts.response;
175
+ const cookies = opts.extra?.cookies || opts.cookies;
176
+ const response = opts.extra?.response || opts.response;
177
177
  if (this.options.usersFilterToApply) {
178
178
  const res = this.options.usersFilterToApply(opts.adminUser);
179
179
  if ( res === false ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",