@dymo-api/better-auth 1.2.12

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.
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.dymoEmailPlugin = void 0;
7
+ const api_1 = require("better-auth/api");
8
+ const dymo_api_1 = __importDefault(require("dymo-api"));
9
+ const dymoEmailPlugin = ({ apiKey, emailRules }) => {
10
+ const defaultRules = {
11
+ deny: ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"]
12
+ };
13
+ const dymoClient = new dymo_api_1.default({
14
+ apiKey,
15
+ rules: {
16
+ email: {
17
+ deny: emailRules?.deny ?? defaultRules.deny
18
+ }
19
+ }
20
+ });
21
+ return {
22
+ id: "dymoEmailPlugin",
23
+ hooks: {
24
+ before: [
25
+ {
26
+ matcher: (context) => context.path.startsWith("/sign-up/email"),
27
+ handler: (0, api_1.createAuthMiddleware)(async (ctx) => {
28
+ const { email } = ctx.body;
29
+ if (typeof email !== "string")
30
+ throw new api_1.APIError("BAD_REQUEST", { message: "Email must be a string." });
31
+ const decision = await dymoClient.isValidEmail(email);
32
+ if (!decision.allow) {
33
+ throw new api_1.APIError("BAD_REQUEST", {
34
+ message: "Email is invalid or blocked.",
35
+ reasons: decision.reasons
36
+ });
37
+ }
38
+ return { context: ctx };
39
+ })
40
+ }
41
+ ]
42
+ }
43
+ };
44
+ };
45
+ exports.dymoEmailPlugin = dymoEmailPlugin;
@@ -0,0 +1,38 @@
1
+ import { APIError, createAuthMiddleware } from "better-auth/api";
2
+ import DymoAPI from "dymo-api";
3
+ export const dymoEmailPlugin = ({ apiKey, emailRules }) => {
4
+ const defaultRules = {
5
+ deny: ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"]
6
+ };
7
+ const dymoClient = new DymoAPI({
8
+ apiKey,
9
+ rules: {
10
+ email: {
11
+ deny: emailRules?.deny ?? defaultRules.deny
12
+ }
13
+ }
14
+ });
15
+ return {
16
+ id: "dymoEmailPlugin",
17
+ hooks: {
18
+ before: [
19
+ {
20
+ matcher: (context) => context.path.startsWith("/sign-up/email"),
21
+ handler: createAuthMiddleware(async (ctx) => {
22
+ const { email } = ctx.body;
23
+ if (typeof email !== "string")
24
+ throw new APIError("BAD_REQUEST", { message: "Email must be a string." });
25
+ const decision = await dymoClient.isValidEmail(email);
26
+ if (!decision.allow) {
27
+ throw new APIError("BAD_REQUEST", {
28
+ message: "Email is invalid or blocked.",
29
+ reasons: decision.reasons
30
+ });
31
+ }
32
+ return { context: ctx };
33
+ })
34
+ }
35
+ ]
36
+ }
37
+ };
38
+ };
@@ -0,0 +1,17 @@
1
+ import { EmailValidatorRules } from "dymo-api";
2
+ interface DymoEmailPluginOptions {
3
+ apiKey: string;
4
+ emailRules?: Partial<EmailValidatorRules>;
5
+ }
6
+ export declare const dymoEmailPlugin: ({ apiKey, emailRules }: DymoEmailPluginOptions) => {
7
+ id: "dymoEmailPlugin";
8
+ hooks: {
9
+ before: {
10
+ matcher: (context: any) => any;
11
+ handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
12
+ context: any;
13
+ }>;
14
+ }[];
15
+ };
16
+ };
17
+ export {};
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@dymo-api/better-auth",
3
+ "version": "1.2.12",
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",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "require": "./dist/cjs/dymo-api.cjs",
12
+ "import": "./dist/esm/dymo-api.js",
13
+ "types": "./dist/types/dymo-api.d.ts"
14
+ },
15
+ "./*": {
16
+ "require": "./dist/cjs/**/*.cjs",
17
+ "import": "./dist/esm/**/*.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist/**/*",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "scripts": {
26
+ "clean": "rimraf dist",
27
+ "build:cjs": "tsc -p tsconfig.cjs.json && tsc-alias -p tsconfig.cjs.json",
28
+ "build:esm": "tsc -p tsconfig.esm.json && tsc-alias -p tsconfig.esm.json",
29
+ "build": "npm run clean && npm run build:cjs && npm run build:esm && node ./scripts/rename.js",
30
+ "start": "ts-node src/index.ts",
31
+ "prepublishOnly": "npm run build",
32
+ "test": "vitest"
33
+ },
34
+ "repository": {
35
+ "url": "https://github.com/TPEOficial/dymo-api-node"
36
+ },
37
+ "keywords": [
38
+ "Dymo",
39
+ "Dymo API",
40
+ "TPEOficial",
41
+ "Ciphera"
42
+ ],
43
+ "author": "TPEOficial LLC",
44
+ "license": "Apache-2.0",
45
+ "bugs": {
46
+ "url": "https://github.com/TPEOficial/dymo-api-node/issues"
47
+ },
48
+ "homepage": "https://dymo.tpeoficial.com",
49
+ "dependencies": {
50
+ "better-auth": "^1.3.23",
51
+ "dymo-api": "^1.2.14",
52
+ "path": "^0.12.7"
53
+ },
54
+ "contributors": [
55
+ "TPEOficial (https://github.com/TPEOficial)",
56
+ "FJRG2007 (https://github.com/FJRG2007)"
57
+ ],
58
+ "devDependencies": {
59
+ "@types/jest": "^30.0.0",
60
+ "@types/node": "^22.18.7",
61
+ "dotenv": "^17.2.2",
62
+ "jest": "^30.1.3",
63
+ "rimraf": "^6.0.1",
64
+ "ts-jest": "^29.4.4",
65
+ "ts-node": "^10.9.2",
66
+ "tsc-alias": "^1.8.16",
67
+ "typescript": "^5.5.4",
68
+ "vitest": "^3.2.4"
69
+ },
70
+ "prettier": {
71
+ "tabWidth": 4,
72
+ "useTabs": false
73
+ }
74
+ }