@adminforth/two-factors-auth 4.3.1 → 4.3.2

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
@@ -17,5 +17,5 @@ custom/tsconfig.json
17
17
  custom/use2faApi.ts
18
18
  custom/utils.js
19
19
 
20
- sent 288,126 bytes received 248 bytes 576,748.00 bytes/sec
20
+ sent 288,139 bytes received 248 bytes 576,774.00 bytes/sec
21
21
  total size is 287,166 speedup is 1.00
@@ -199,6 +199,10 @@ export class PasskeyService {
199
199
  const credentialID = credential.id;
200
200
  const base64CredentialID = credentialID;
201
201
  const base64PublicKey = isoBase64URL.fromBuffer(credentialPublicKey);
202
+ const existingPasskey = yield this.passkeyRepository.getByCredentialId(base64CredentialID);
203
+ if (existingPasskey) {
204
+ throw new Error('This passkey is already registered');
205
+ }
202
206
  yield this.passkeyRepository.create({
203
207
  [this.options.passkeys.credentialIdFieldName]: base64CredentialID,
204
208
  [this.options.passkeys.credentialUserIdFieldName]: adminUser.pk,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "4.3.1",
3
+ "version": "4.3.2",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -214,6 +214,11 @@ export class PasskeyService {
214
214
  const base64CredentialID = credentialID;
215
215
  const base64PublicKey = isoBase64URL.fromBuffer(credentialPublicKey);
216
216
 
217
+ const existingPasskey = await this.passkeyRepository.getByCredentialId(base64CredentialID);
218
+ if (existingPasskey) {
219
+ throw new Error('This passkey is already registered');
220
+ }
221
+
217
222
  await this.passkeyRepository.create({
218
223
  [this.options.passkeys.credentialIdFieldName] : base64CredentialID,
219
224
  [this.options.passkeys.credentialUserIdFieldName] : adminUser.pk,