@adminforth/two-factors-auth 2.10.6 → 2.10.8

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,4 +16,4 @@ custom/tsconfig.json
16
16
  custom/utils.js
17
17
 
18
18
  sent 273,574 bytes received 210 bytes 547,568.00 bytes/sec
19
- total size is 272,758 speedup is 1.00
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
@@ -17,13 +17,11 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
17
17
  constructor(options) {
18
18
  super(options, import.meta.url);
19
19
  this.options = options;
20
+ this.shouldHaveSingleInstancePerWholeApp = () => true;
20
21
  }
21
22
  instanceUniqueRepresentation(pluginOptions) {
22
23
  return `single`;
23
24
  }
24
- shouldHaveSingleInstancePerWholeApp() {
25
- return true;
26
- }
27
25
  checkIfSkipSetupAllowSkipVerify(adminUser) {
28
26
  return __awaiter(this, void 0, void 0, function* () {
29
27
  if (this.options.usersFilterToAllowSkipSetup) {
@@ -106,9 +104,12 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
106
104
  }
107
105
  verify(confirmationResult, opts) {
108
106
  return __awaiter(this, void 0, void 0, function* () {
109
- var _a, _b, _c, _d, _e;
107
+ var _a, _b, _c, _d, _e, _f;
110
108
  if (!confirmationResult)
111
109
  return { error: "Confirmation result is required" };
110
+ if (!(opts === null || opts === void 0 ? void 0 : opts.cookies)) {
111
+ opts.cookies = (_a = opts.extra) === null || _a === void 0 ? void 0 : _a.cookies;
112
+ }
112
113
  if (this.options.usersFilterToApply) {
113
114
  const res = this.options.usersFilterToApply(opts.adminUser);
114
115
  if (res === false) {
@@ -121,7 +122,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
121
122
  return { ok: true };
122
123
  }
123
124
  }
124
- if (this.options.stepUpMfaGracePeriodSeconds && ((_a = opts.extra) === null || _a === void 0 ? void 0 : _a.headers) && !confirmationResult.mode) {
125
+ if (this.options.stepUpMfaGracePeriodSeconds && ((_b = opts.extra) === null || _b === void 0 ? void 0 : _b.headers) && !confirmationResult.mode) {
125
126
  const verificationResult = yield this.isTempSkip2FAGraceValid(opts.extra.headers, opts.cookies);
126
127
  if (verificationResult === true) {
127
128
  return { ok: true };
@@ -134,10 +135,10 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
134
135
  if (!authRes)
135
136
  return { error: "Auth resource not found" };
136
137
  const connector = this.adminforth.connectors[authRes.dataSource];
137
- const pkName = (_b = authRes.columns.find(c => c.primaryKey)) === null || _b === void 0 ? void 0 : _b.name;
138
+ const pkName = (_c = authRes.columns.find(c => c.primaryKey)) === null || _c === void 0 ? void 0 : _c.name;
138
139
  if (!pkName)
139
140
  return { error: "Primary key not found on auth resource" };
140
- 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];
141
+ 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];
141
142
  if (!pk)
142
143
  return { error: "User PK is required" };
143
144
  const user = yield connector.getRecordByPrimaryKey(authRes, pk);
@@ -580,6 +581,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
580
581
  requestUrl,
581
582
  query,
582
583
  body: {},
584
+ response,
583
585
  meta: {
584
586
  loginAllowedByPasskeyDirectSignIn: true
585
587
  },
package/index.ts CHANGED
@@ -22,15 +22,13 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
22
22
  constructor(options: PluginOptions) {
23
23
  super(options, import.meta.url);
24
24
  this.options = options;
25
+ this.shouldHaveSingleInstancePerWholeApp = () => true;
25
26
  }
26
27
 
27
28
  instanceUniqueRepresentation(pluginOptions: any) : string {
28
29
  return `single`;
29
30
  }
30
31
 
31
- shouldHaveSingleInstancePerWholeApp(): boolean {
32
- return true;
33
- }
34
32
 
35
33
  public async checkIfSkipSetupAllowSkipVerify(adminUser: AdminUser): Promise<{ skipAllowed: boolean }> {
36
34
  if (this.options.usersFilterToAllowSkipSetup) {
@@ -118,6 +116,9 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
118
116
  opts?: { adminUser?: AdminUser; userPk?: string; cookies?: any, response?: IAdminForthHttpResponse, extra?: HttpExtra }
119
117
  ): Promise<{ ok: true } | { error: string }> {
120
118
  if (!confirmationResult) return { error: "Confirmation result is required" };
119
+ if (!opts?.cookies) {
120
+ opts.cookies = opts.extra?.cookies;
121
+ }
121
122
  if (this.options.usersFilterToApply) {
122
123
  const res = this.options.usersFilterToApply(opts.adminUser);
123
124
  if ( res === false ) {
@@ -633,6 +634,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
633
634
  requestUrl,
634
635
  query,
635
636
  body: {},
637
+ response,
636
638
  meta: {
637
639
  loginAllowedByPasskeyDirectSignIn: true
638
640
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "2.10.6",
3
+ "version": "2.10.8",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",