From 7f6a8aa7e5ac2c65f3b1f05832b39fd5376bec89 Mon Sep 17 00:00:00 2001 From: Chris Fisher Date: Wed, 31 May 2023 12:26:46 +1200 Subject: [PATCH] Fix types and include token in track response (#21) * Fix types and include token in track response * wip --- package.json | 2 +- src/authsignal.ts | 12 ------------ src/types.ts | 31 ++++++++++++------------------- 3 files changed, 13 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 57dce20..d897582 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@authsignal/node", - "version": "0.0.42", + "version": "0.0.43", "main": "./dist/index.js", "module": "./dist/index.mjs", "types": "dist/index.d.ts", diff --git a/src/authsignal.ts b/src/authsignal.ts index c333d85..27edd3d 100644 --- a/src/authsignal.ts +++ b/src/authsignal.ts @@ -10,8 +10,6 @@ import { LoginWithEmailRequest, LoginWithEmailResponse, RedirectTokenPayload, - TokenRequest, - TokenResponse, TrackRequest, TrackResponse, UserActionState, @@ -131,16 +129,6 @@ export class Authsignal { return {userId, success: false, state: undefined}; } - public async token(request: TokenRequest): Promise { - const url = `${this.apiBaseUrl}/token`; - - const config = this.getBasicAuthConfig(); - - const response = await axios.post(url, request, config); - - return response.data; - } - private getBasicAuthConfig() { return { auth: { diff --git a/src/types.ts b/src/types.ts index bc476a5..12355c6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -10,33 +10,35 @@ export interface UserRequest { export interface UserResponse { isEnrolled: boolean; - enrolledVerificationMethods?: VerificationMethod; - allowedVerificationMethods?: VerificationMethod; + email?: string; + phoneNumber?: string; + enrolledVerificationMethods?: VerificationMethod[]; + allowedVerificationMethods?: VerificationMethod[]; } export interface TrackRequest { userId: string; action: string; - email?: string; idempotencyKey?: string; redirectUrl?: string; + redirectToSettings?: boolean; ipAddress?: string; userAgent?: string; deviceId?: string; - custom?: object; - redirectToSettings?: boolean; scope?: string; + email?: string; + phoneNumber?: string; + custom?: object; } export interface TrackResponse { state: UserActionState; idempotencyKey: string; - ruleIds: string[]; url: string; + token: string; isEnrolled: boolean; - enrolledVerificationMethods?: VerificationMethod; - allowedVerificationMethods?: VerificationMethod; - challengeUrl?: string; + enrolledVerificationMethods?: VerificationMethod[]; + allowedVerificationMethods?: VerificationMethod[]; } export interface GetActionRequest { @@ -55,7 +57,7 @@ export interface EnrollVerifiedAuthenticatorRequest { oobChannel: string; phoneNumber?: string; email?: string; - setDefault?: boolean; + isDefault?: boolean; } export interface EnrollVerifiedAuthenticatorResponse { @@ -82,15 +84,6 @@ export interface ValidateChallengeResponse { state?: UserActionState; } -export interface TokenRequest { - userId: string; - scope?: string; -} - -export interface TokenResponse { - accessToken: string; -} - export enum UserActionState { ALLOW = "ALLOW", BLOCK = "BLOCK",