From ea6225fc12b7085d84be886c65feda28a74d872b Mon Sep 17 00:00:00 2001 From: Hamish Meikle Date: Wed, 11 Sep 2024 13:22:57 +1000 Subject: [PATCH] Add deleteAuthenticator method (#42) --- package.json | 2 +- src/authsignal.ts | 14 ++++++++++++++ src/types.ts | 9 +++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 312d89e..56e4652 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@authsignal/node", - "version": "1.1.3", + "version": "1.1.4", "main": "./dist/index.js", "module": "./dist/index.mjs", "types": "dist/index.d.ts", diff --git a/src/authsignal.ts b/src/authsignal.ts index 7ff7f46..bb8a677 100644 --- a/src/authsignal.ts +++ b/src/authsignal.ts @@ -4,6 +4,8 @@ import { AuthsignalConstructor, ChallengeRequest, ChallengeResponse, + DeleteAuthenticatorRequest, + DeleteAuthenticatorResponse, EnrollVerifiedAuthenticatorRequest, EnrollVerifiedAuthenticatorResponse, GetActionRequest, @@ -135,6 +137,18 @@ export class Authsignal { return response.data; } + public async deleteAuthenticator(request: DeleteAuthenticatorRequest): Promise { + const {userId, userAuthenticatorId} = request; + + const url = `${this.apiBaseUrl}/users/${userId}/authenticators/${userAuthenticatorId}`; + + const config = this.getBasicAuthConfig(); + + const response = await axios.delete(url, config); + + return response.data; + } + public async validateChallenge(request: ValidateChallengeRequest): Promise { const url = `${this.apiBaseUrl}/validate`; diff --git a/src/types.ts b/src/types.ts index 3e35903..a8d60ea 100644 --- a/src/types.ts +++ b/src/types.ts @@ -106,6 +106,15 @@ export interface ValidateChallengeResponse { error?: string; } +export interface DeleteAuthenticatorRequest { + userId: string; + userAuthenticatorId: string; +} + +export interface DeleteAuthenticatorResponse { + success: boolean; +} + export enum UserActionState { ALLOW = "ALLOW", BLOCK = "BLOCK",