Skip to content

Commit

Permalink
Fix types and include token in track response (#21)
Browse files Browse the repository at this point in the history
* Fix types and include token in track response

* wip
  • Loading branch information
chrisfisher authored May 31, 2023
1 parent d11764e commit 7f6a8aa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 32 deletions.
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": "0.0.42",
"version": "0.0.43",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "dist/index.d.ts",
Expand Down
12 changes: 0 additions & 12 deletions src/authsignal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
LoginWithEmailRequest,
LoginWithEmailResponse,
RedirectTokenPayload,
TokenRequest,
TokenResponse,
TrackRequest,
TrackResponse,
UserActionState,
Expand Down Expand Up @@ -131,16 +129,6 @@ export class Authsignal {
return {userId, success: false, state: undefined};
}

public async token(request: TokenRequest): Promise<TokenResponse> {
const url = `${this.apiBaseUrl}/token`;

const config = this.getBasicAuthConfig();

const response = await axios.post<TokenResponse>(url, request, config);

return response.data;
}

private getBasicAuthConfig() {
return {
auth: {
Expand Down
31 changes: 12 additions & 19 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -55,7 +57,7 @@ export interface EnrollVerifiedAuthenticatorRequest {
oobChannel: string;
phoneNumber?: string;
email?: string;
setDefault?: boolean;
isDefault?: boolean;
}

export interface EnrollVerifiedAuthenticatorResponse {
Expand All @@ -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",
Expand Down

0 comments on commit 7f6a8aa

Please sign in to comment.