@adminforth/two-factors-auth 2.9.10 → 2.9.12

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.
Files changed (3) hide show
  1. package/dist/index.js +10 -2
  2. package/index.ts +10 -2
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -163,7 +163,15 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
163
163
  }
164
164
  credMeta.counter = authenticationInfo.newCounter;
165
165
  credMeta.last_used_at = new Date().toISOString();
166
- yield this.adminforth.resource(this.options.passkeys.credentialResourceID).update(cred[this.options.passkeys.credentialIdFieldName], { [this.options.passkeys.credentialMetaFieldName]: JSON.stringify(credMeta) });
166
+ const credResource = this.adminforth.config.resources.find(r => r.resourceId === this.options.passkeys.credentialResourceID);
167
+ const credResourcePKColumn = credResource === null || credResource === void 0 ? void 0 : credResource.columns.find(c => c.primaryKey);
168
+ if (!credResource || !credResourcePKColumn) {
169
+ throw new Error('Credential resource or its primary key is not configured correctly');
170
+ }
171
+ const credResourcePKName = credResourcePKColumn.name;
172
+ yield this.adminforth
173
+ .resource(this.options.passkeys.credentialResourceID)
174
+ .update(cred[credResourcePKName], { [this.options.passkeys.credentialMetaFieldName]: JSON.stringify(credMeta) });
167
175
  return { ok: true, passkeyConfirmed: true };
168
176
  }
169
177
  catch (e) {
@@ -455,7 +463,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
455
463
  }
456
464
  const passkeyRecord = yield this.adminforth.resource(this.options.passkeys.credentialResourceID).get([Filters.EQ(this.options.passkeys.credentialIdFieldName, credential_id)]);
457
465
  if (!passkeyRecord) {
458
- return { error: 'No registered passkey found, probably it was removed' };
466
+ return { error: 'No such passkey found, most likeley it was removed on this website but you still have it on your device' };
459
467
  }
460
468
  const userPk = passkeyRecord[this.options.passkeys.credentialUserIdFieldName];
461
469
  if (!userPk) {
package/index.ts CHANGED
@@ -175,7 +175,15 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
175
175
  }
176
176
  credMeta.counter = authenticationInfo.newCounter;
177
177
  credMeta.last_used_at = new Date().toISOString();
178
- await this.adminforth.resource(this.options.passkeys.credentialResourceID).update(cred[this.options.passkeys.credentialIdFieldName], { [this.options.passkeys.credentialMetaFieldName]: JSON.stringify(credMeta) });
178
+ const credResource = this.adminforth.config.resources.find(r => r.resourceId === this.options.passkeys.credentialResourceID);
179
+ const credResourcePKColumn = credResource?.columns.find(c => c.primaryKey);
180
+ if (!credResource || !credResourcePKColumn) {
181
+ throw new Error('Credential resource or its primary key is not configured correctly');
182
+ }
183
+ const credResourcePKName = credResourcePKColumn.name;
184
+ await this.adminforth
185
+ .resource(this.options.passkeys.credentialResourceID)
186
+ .update(cred[credResourcePKName], { [this.options.passkeys.credentialMetaFieldName]: JSON.stringify(credMeta) });
179
187
  return { ok: true, passkeyConfirmed: true };
180
188
  } catch (e) {
181
189
  return { ok: false, error: 'Error authenticating passkey: ' + e };
@@ -498,7 +506,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
498
506
 
499
507
  const passkeyRecord = await this.adminforth.resource(this.options.passkeys.credentialResourceID).get([Filters.EQ(this.options.passkeys.credentialIdFieldName, credential_id)]);
500
508
  if (!passkeyRecord) {
501
- return { error: 'No registered passkey found, probably it was removed' };
509
+ return { error: 'No such passkey found, most likeley it was removed on this website but you still have it on your device' };
502
510
  }
503
511
 
504
512
  const userPk = passkeyRecord[this.options.passkeys.credentialUserIdFieldName];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "2.9.10",
3
+ "version": "2.9.12",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",