Skip to content

Commit

Permalink
Export more types from root dir (#79)
Browse files Browse the repository at this point in the history
* Export more types from root dir

* wip
  • Loading branch information
chrisfisher authored Oct 18, 2024
1 parent a7c04e5 commit de4dbca
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 27 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/browser",
"version": "1.0.0",
"version": "1.0.1",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
Expand Down
3 changes: 2 additions & 1 deletion src/api/email-api-client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {ChallengeResponse, EnrollResponse} from "../types";
import {buildHeaders, handleTokenExpired} from "./helpers";
import {ApiClientOptions, ChallengeResponse, EnrollResponse, ErrorResponse, VerifyResponse} from "./types/shared";
import {ApiClientOptions, ErrorResponse, VerifyResponse} from "./types/shared";

export class EmailApiClient {
tenantId: string;
Expand Down
3 changes: 2 additions & 1 deletion src/api/passkey-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import {
AddAuthenticatorResponse,
AuthenticationOptsRequest,
AuthenticationOptsResponse,
ChallengeResponse,
ErrorResponse,
PasskeyAuthenticatorResponse,
RegistrationOptsRequest,
RegistrationOptsResponse,
VerifyRequest,
VerifyResponse,
} from "./types/passkey";
import {ApiClientOptions, ChallengeResponse} from "./types/shared";
import {ApiClientOptions} from "./types/shared";

export class PasskeyApiClient {
tenantId: string;
Expand Down
3 changes: 2 additions & 1 deletion src/api/sms-api-client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {ChallengeResponse, EnrollResponse} from "../types";
import {buildHeaders, handleTokenExpired} from "./helpers";
import {ApiClientOptions, ChallengeResponse, EnrollResponse, ErrorResponse, VerifyResponse} from "./types/shared";
import {ApiClientOptions, ErrorResponse, VerifyResponse} from "./types/shared";

export class SmsApiClient {
tenantId: string;
Expand Down
2 changes: 1 addition & 1 deletion src/api/totp-api-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {buildHeaders, handleTokenExpired} from "./helpers";
import {ApiClientOptions, ErrorResponse, VerifyResponse} from "./types/shared";
import {EnrollTotpResponse} from "./types/totp";
import {EnrollTotpResponse} from "../types";

export class TotpApiClient {
tenantId: string;
Expand Down
9 changes: 0 additions & 9 deletions src/api/types/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ export type ApiClientOptions = {
onTokenExpired?: () => void;
};

export type EnrollResponse = {
userAuthenticatorId: string;
userId: string;
};

export type ChallengeResponse = {
challengeId: string;
};

export type VerifyResponse = {
isVerified: boolean;
accessToken?: string;
Expand Down
6 changes: 0 additions & 6 deletions src/api/types/totp.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/email.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {EmailApiClient} from "./api/email-api-client";
import {ChallengeResponse, EnrollResponse} from "./api/types/shared";
import {handleApiResponse} from "./helpers";
import {TokenCache} from "./token-cache";
import {AuthsignalResponse, VerifyResponse} from "./types";
import {AuthsignalResponse, ChallengeResponse, EnrollResponse, VerifyResponse} from "./types";

type EmailOptions = {
baseUrl: string;
Expand Down
3 changes: 1 addition & 2 deletions src/sms.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {SmsApiClient} from "./api/sms-api-client";
import {ChallengeResponse, EnrollResponse} from "./api/types/shared";
import {handleApiResponse} from "./helpers";
import {TokenCache} from "./token-cache";
import {AuthsignalResponse, VerifyResponse} from "./types";
import {AuthsignalResponse, ChallengeResponse, EnrollResponse, VerifyResponse} from "./types";

type SmsOptions = {
baseUrl: string;
Expand Down
4 changes: 1 addition & 3 deletions src/totp.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {TotpApiClient} from "./api/totp-api-client";
import {VerifyResponse} from "./types";
import {EnrollTotpResponse} from "./api/types/totp";
import {handleApiResponse} from "./helpers";
import {TokenCache} from "./token-cache";
import {AuthsignalResponse} from "./types";
import {AuthsignalResponse, EnrollTotpResponse, VerifyResponse} from "./types";

type TotpOptions = {
baseUrl: string;
Expand Down
14 changes: 14 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ export type AuthsignalResponse<T> = {
data?: T;
};

export type EnrollResponse = {
userAuthenticatorId: string;
userId: string;
};

export type EnrollTotpResponse = {
uri: string;
secret: string;
} & EnrollResponse;

export type ChallengeResponse = {
challengeId: string;
};

export type VerifyResponse = {
isVerified: boolean;
token?: string;
Expand Down

0 comments on commit de4dbca

Please sign in to comment.