Skip to content

Commit

Permalink
Add deleteAuthenticator method (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
hwhmeikle authored Sep 11, 2024
1 parent 3cc3ca5 commit ea6225f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 14 additions & 0 deletions src/authsignal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
AuthsignalConstructor,
ChallengeRequest,
ChallengeResponse,
DeleteAuthenticatorRequest,
DeleteAuthenticatorResponse,
EnrollVerifiedAuthenticatorRequest,
EnrollVerifiedAuthenticatorResponse,
GetActionRequest,
Expand Down Expand Up @@ -135,6 +137,18 @@ export class Authsignal {
return response.data;
}

public async deleteAuthenticator(request: DeleteAuthenticatorRequest): Promise<DeleteAuthenticatorResponse> {
const {userId, userAuthenticatorId} = request;

const url = `${this.apiBaseUrl}/users/${userId}/authenticators/${userAuthenticatorId}`;

const config = this.getBasicAuthConfig();

const response = await axios.delete<DeleteAuthenticatorResponse>(url, config);

return response.data;
}

public async validateChallenge(request: ValidateChallengeRequest): Promise<ValidateChallengeResponse> {
const url = `${this.apiBaseUrl}/validate`;

Expand Down
9 changes: 9 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit ea6225f

Please sign in to comment.