@adminforth/two-factors-auth 2.9.10 → 2.9.11

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/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) {
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 };
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.11",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",