@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.
- package/dist/index.js +10 -2
- package/index.ts +10 -2
- 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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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];
|