Skip to content

Commit

Permalink
DRY Factor types
Browse files Browse the repository at this point in the history
  • Loading branch information
Aupajo committed Apr 29, 2024
1 parent f25cde1 commit b95fcb7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 58 deletions.
30 changes: 1 addition & 29 deletions src/types/api/post-challenge.d.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,6 @@
import { User } from "../user";
import { Cache } from "./cache";

interface SimpleFactor {
/** A type of authentication factor such as `push-notification`, `phone`, `email`, `otp`, `webauthn-roaming` and `webauthn-platform`. */
type:
| "otp"
| "recovery-code"
| "email"
| "webauthn-platform"
| "webauthn-roaming"
| "push-notification"
| string;

/** Additional options for configuring a factor of a given type. */
options?: {
[property: string]: any;
};
}

type PhoneFactor = {
type: "phone";
options?: { preferredMethod?: "voice" | "sms" | "both" };
};

type Factor = SimpleFactor | PhoneFactor;

export interface MultifactorEnableOptions {
allowRememberBrowser?: boolean;
providerOptions?: Record<string, unknown>;
}
import { Factor } from "../factor";

export interface PostChallenge {
/**
Expand Down
30 changes: 1 addition & 29 deletions src/types/api/post-login.d.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,6 @@
import { User } from "../user";
import { Cache } from "./cache";

interface SimpleFactor {
/** A type of authentication factor such as `push-notification`, `phone`, `email`, `otp`, `webauthn-roaming` and `webauthn-platform`. */
type:
| "otp"
| "recovery-code"
| "email"
| "webauthn-platform"
| "webauthn-roaming"
| "push-notification"
| string;

/** Additional options for configuring a factor of a given type. */
options?: {
[property: string]: any;
};
}

type PhoneFactor = {
type: "phone";
options?: { preferredMethod?: "voice" | "sms" | "both" };
};

type Factor = SimpleFactor | PhoneFactor;

export interface MultifactorEnableOptions {
allowRememberBrowser?: boolean;
providerOptions?: Record<string, unknown>;
}
import { Factor } from "../factor";

export interface PostLogin {
/**
Expand Down
28 changes: 28 additions & 0 deletions src/types/factor.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
interface SimpleFactor {
/** A type of authentication factor such as `push-notification`, `phone`, `email`, `otp`, `webauthn-roaming` and `webauthn-platform`. */
type:
| "otp"
| "recovery-code"
| "email"
| "webauthn-platform"
| "webauthn-roaming"
| "push-notification"
| string;

/** Additional options for configuring a factor of a given type. */
options?: {
[property: string]: any;
};
}

type PhoneFactor = {
type: "phone";
options?: { preferredMethod?: "voice" | "sms" | "both" };
};

export type Factor = SimpleFactor | PhoneFactor;

export interface MultifactorEnableOptions {
allowRememberBrowser?: boolean;
providerOptions?: Record<string, unknown>;
}
1 change: 1 addition & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from "./api/credentials-exchange";
export * from "./authentication";
export * from "./client";
export * from "./connection";
export * from "./factor";
export * from "./identity";
export * from "./organization";
export * from "./request";
Expand Down

0 comments on commit b95fcb7

Please sign in to comment.