@dymo-api/better-auth 1.2.19 → 1.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.dymoEmailPlugin = void 0;
7
7
  const api_1 = require("better-auth/api");
8
8
  const dymo_api_1 = __importDefault(require("dymo-api"));
9
- const dymoEmailPlugin = ({ apiKey, emailRules }) => {
9
+ const dymoEmailPlugin = ({ apiKey, applyToLogin = false, applyToOAuth = true, emailRules }) => {
10
10
  const defaultRules = {
11
11
  deny: ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"]
12
12
  };
@@ -18,14 +18,21 @@ const dymoEmailPlugin = ({ apiKey, emailRules }) => {
18
18
  }
19
19
  }
20
20
  });
21
+ const activePaths = ["/sign-up/email"];
22
+ if (applyToLogin)
23
+ activePaths.push("/sign-in/email");
24
+ if (applyToOAuth) {
25
+ activePaths.push("/sign-up/oauth");
26
+ activePaths.push("/sign-in/oauth");
27
+ }
21
28
  return {
22
29
  id: "dymoEmailPlugin",
23
30
  hooks: {
24
31
  before: [
25
32
  {
26
- matcher: (context) => context.path.startsWith("/sign-up/email"),
33
+ matcher: (context) => activePaths.some(path => context.path.startsWith(path)),
27
34
  handler: (0, api_1.createAuthMiddleware)(async (ctx) => {
28
- const { email } = ctx.body;
35
+ const email = ctx.body?.email || ctx.body?.profile?.email;
29
36
  if (typeof email !== "string")
30
37
  throw new api_1.APIError("BAD_REQUEST", { message: "Email must be a string." });
31
38
  const decision = await dymoClient.isValidEmail(email);
@@ -1,6 +1,6 @@
1
1
  import { APIError, createAuthMiddleware } from "better-auth/api";
2
2
  import DymoAPI from "dymo-api";
3
- export const dymoEmailPlugin = ({ apiKey, emailRules }) => {
3
+ export const dymoEmailPlugin = ({ apiKey, applyToLogin = false, applyToOAuth = true, emailRules }) => {
4
4
  const defaultRules = {
5
5
  deny: ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"]
6
6
  };
@@ -12,14 +12,21 @@ export const dymoEmailPlugin = ({ apiKey, emailRules }) => {
12
12
  }
13
13
  }
14
14
  });
15
+ const activePaths = ["/sign-up/email"];
16
+ if (applyToLogin)
17
+ activePaths.push("/sign-in/email");
18
+ if (applyToOAuth) {
19
+ activePaths.push("/sign-up/oauth");
20
+ activePaths.push("/sign-in/oauth");
21
+ }
15
22
  return {
16
23
  id: "dymoEmailPlugin",
17
24
  hooks: {
18
25
  before: [
19
26
  {
20
- matcher: (context) => context.path.startsWith("/sign-up/email"),
27
+ matcher: (context) => activePaths.some(path => context.path.startsWith(path)),
21
28
  handler: createAuthMiddleware(async (ctx) => {
22
- const { email } = ctx.body;
29
+ const email = ctx.body?.email || ctx.body?.profile?.email;
23
30
  if (typeof email !== "string")
24
31
  throw new APIError("BAD_REQUEST", { message: "Email must be a string." });
25
32
  const decision = await dymoClient.isValidEmail(email);
@@ -1,13 +1,15 @@
1
1
  import { EmailValidatorRules } from "dymo-api";
2
2
  interface DymoEmailPluginOptions {
3
3
  apiKey: string;
4
+ applyToLogin?: boolean;
5
+ applyToOAuth?: boolean;
4
6
  emailRules?: Partial<EmailValidatorRules>;
5
7
  }
6
- export declare const dymoEmailPlugin: ({ apiKey, emailRules }: DymoEmailPluginOptions) => {
8
+ export declare const dymoEmailPlugin: ({ apiKey, applyToLogin, applyToOAuth, emailRules }: DymoEmailPluginOptions) => {
7
9
  id: "dymoEmailPlugin";
8
10
  hooks: {
9
11
  before: {
10
- matcher: (context: any) => any;
12
+ matcher: (context: any) => boolean;
11
13
  handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
12
14
  context: any;
13
15
  }>;
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@dymo-api/better-auth",
3
- "version": "1.2.19",
3
+ "version": "1.2.21",
4
4
  "description": "Flow system for Dymo API.",
5
- "main": "dist/cjs/dymo-api.js",
6
- "module": "dist/esm/dymo-api.js",
7
- "types": "dist/types/dymo-api.d.ts",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/types/index.d.ts",
8
8
  "type": "module",
9
9
  "exports": {
10
10
  ".": {
11
- "require": "./dist/cjs/dymo-api.cjs",
12
- "import": "./dist/esm/dymo-api.js",
13
- "types": "./dist/types/dymo-api.d.ts"
11
+ "require": "./dist/cjs/index.cjs",
12
+ "import": "./dist/esm/index.js",
13
+ "types": "./dist/types/index.d.ts"
14
14
  },
15
15
  "./*": {
16
16
  "require": "./dist/cjs/**/*.cjs",