@adminforth/two-factors-auth 2.10.7 → 2.10.9

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
19
- total size is 272,758 speedup is 1.00
18
+ sent 273,574 bytes received 210 bytes 547,568.00 bytes/sec
19
+ total size is 272,747 speedup is 1.00
@@ -238,7 +238,7 @@
238
238
  isFetchingPasskey.value = true;
239
239
  let confirmationResult;
240
240
  try {
241
- confirmationResult = await window.adminforthTwoFaModal.get2FaConfirmationResult(undefined, "To add passkey first verify yourself");
241
+ confirmationResult = await window.adminforthTwoFaModal.get2FaConfirmationResult("To add passkey first verify yourself");
242
242
  } catch (e) {
243
243
  isFetchingPasskey.value = false;
244
244
  return;
@@ -238,7 +238,7 @@
238
238
  isFetchingPasskey.value = true;
239
239
  let confirmationResult;
240
240
  try {
241
- confirmationResult = await window.adminforthTwoFaModal.get2FaConfirmationResult(undefined, "To add passkey first verify yourself");
241
+ confirmationResult = await window.adminforthTwoFaModal.get2FaConfirmationResult("To add passkey first verify yourself");
242
242
  } catch (e) {
243
243
  isFetchingPasskey.value = false;
244
244
  return;
package/dist/index.js CHANGED
@@ -104,9 +104,20 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
104
104
  }
105
105
  verify(confirmationResult, opts) {
106
106
  return __awaiter(this, void 0, void 0, function* () {
107
- var _a, _b, _c, _d, _e;
107
+ var _a, _b, _c, _d, _e, _f;
108
108
  if (!confirmationResult)
109
109
  return { error: "Confirmation result is required" };
110
+ if (!opts.adminUser)
111
+ return { error: "Admin user is required" };
112
+ if (!opts.userPk)
113
+ return { error: "User PK is required" };
114
+ if (!opts.response)
115
+ return { error: "Response object is required" };
116
+ if (!opts.cookies)
117
+ return { error: "Cookies are required" };
118
+ if (!(opts === null || opts === void 0 ? void 0 : opts.cookies)) {
119
+ opts.cookies = (_a = opts.extra) === null || _a === void 0 ? void 0 : _a.cookies;
120
+ }
110
121
  if (this.options.usersFilterToApply) {
111
122
  const res = this.options.usersFilterToApply(opts.adminUser);
112
123
  if (res === false) {
@@ -119,7 +130,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
119
130
  return { ok: true };
120
131
  }
121
132
  }
122
- if (this.options.stepUpMfaGracePeriodSeconds && ((_a = opts.extra) === null || _a === void 0 ? void 0 : _a.headers) && !confirmationResult.mode) {
133
+ if (this.options.stepUpMfaGracePeriodSeconds && ((_b = opts.extra) === null || _b === void 0 ? void 0 : _b.headers) && !confirmationResult.mode) {
123
134
  const verificationResult = yield this.isTempSkip2FAGraceValid(opts.extra.headers, opts.cookies);
124
135
  if (verificationResult === true) {
125
136
  return { ok: true };
@@ -132,10 +143,10 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
132
143
  if (!authRes)
133
144
  return { error: "Auth resource not found" };
134
145
  const connector = this.adminforth.connectors[authRes.dataSource];
135
- const pkName = (_b = authRes.columns.find(c => c.primaryKey)) === null || _b === void 0 ? void 0 : _b.name;
146
+ const pkName = (_c = authRes.columns.find(c => c.primaryKey)) === null || _c === void 0 ? void 0 : _c.name;
136
147
  if (!pkName)
137
148
  return { error: "Primary key not found on auth resource" };
138
- 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];
149
+ const pk = (_d = opts === null || opts === void 0 ? void 0 : opts.userPk) !== null && _d !== void 0 ? _d : (_f = (_e = opts === null || opts === void 0 ? void 0 : opts.adminUser) === null || _e === void 0 ? void 0 : _e.dbUser) === null || _f === void 0 ? void 0 : _f[pkName];
139
150
  if (!pk)
140
151
  return { error: "User PK is required" };
141
152
  const user = yield connector.getRecordByPrimaryKey(authRes, pk);
package/index.ts CHANGED
@@ -116,6 +116,13 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
116
116
  opts?: { adminUser?: AdminUser; userPk?: string; cookies?: any, response?: IAdminForthHttpResponse, extra?: HttpExtra }
117
117
  ): Promise<{ ok: true } | { error: string }> {
118
118
  if (!confirmationResult) return { error: "Confirmation result is required" };
119
+ if (!opts.adminUser) return { error: "Admin user is required" };
120
+ if (!opts.userPk) return { error: "User PK is required" };
121
+ if (!opts.response) return { error: "Response object is required" };
122
+ if (!opts.cookies) return { error: "Cookies are required" };
123
+ if (!opts?.cookies) {
124
+ opts.cookies = opts.extra?.cookies;
125
+ }
119
126
  if (this.options.usersFilterToApply) {
120
127
  const res = this.options.usersFilterToApply(opts.adminUser);
121
128
  if ( res === false ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "2.10.7",
3
+ "version": "2.10.9",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",