onehitter 2.0.11 → 2.0.13

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.
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.OtpAuthService = void 0;
7
7
  const events_1 = require("events");
8
- const onehitter_1 = __importDefault(require("./onehitter"));
8
+ const onehitter_js_1 = __importDefault(require("./onehitter.js"));
9
9
  /**
10
10
  * The core OTP service. Extends EventEmitter to provide fan-out capabilities
11
11
  * via the 'auth:success' and 'auth:failure' events.
@@ -19,7 +19,7 @@ const onehitter_1 = __importDefault(require("./onehitter"));
19
19
  class OtpAuthService extends events_1.EventEmitter {
20
20
  constructor(deps) {
21
21
  super();
22
- this.oneHitter = deps?.oneHitter ?? new onehitter_1.default();
22
+ this.oneHitter = deps?.oneHitter ?? new onehitter_js_1.default();
23
23
  this.buildPayload =
24
24
  deps?.buildPayload ??
25
25
  ((userId, extra) => ({
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ensureCreatedAtTTLIndex = ensureCreatedAtTTLIndex;
4
4
  exports.main = main;
5
5
  const mongodb_1 = require("mongodb");
6
- const config_1 = require("../config");
6
+ const config_js_1 = require("../config.js");
7
7
  /**
8
8
  * Ensure there is a TTL index on createdAt.
9
9
  * If an index exists with a different expireAfterSeconds, it will be recreated.
@@ -35,7 +35,7 @@ async function ensureCreatedAtTTLIndex(client, ttlSeconds) {
35
35
  async function main() {
36
36
  const parsed = Number(process.env.OTP_EXPIRY);
37
37
  const ttlSeconds = Number.isFinite(parsed) && parsed > 0 ? parsed : 1800;
38
- const conn = config_1.MONGO_CONNECTION;
38
+ const conn = config_js_1.MONGO_CONNECTION;
39
39
  if (!conn)
40
40
  throw new Error('MONGO_CONNECTION is required to run ensure-ttl');
41
41
  const client = new mongodb_1.MongoClient(conn, {
@@ -1,20 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAdapter = getAdapter;
4
- const shared_1 = require("./shared");
5
- const mongo_adapter_1 = require("./mongo-adapter");
6
- const sqlite_adapter_1 = require("./sqlite-adapter");
4
+ const shared_js_1 = require("./shared.js");
5
+ const mongo_adapter_js_1 = require("./mongo-adapter.js");
6
+ const sqlite_adapter_js_1 = require("./sqlite-adapter.js");
7
7
  let mongoAdapter = null;
8
8
  let sqliteAdapter = null;
9
9
  function getAdapter(opts) {
10
10
  // If a MongoClient is provided by the caller, prefer Mongo regardless of env
11
- const d = opts?.hasClient ? 'mongodb' : (0, shared_1.currentDriver)();
11
+ const d = opts?.hasClient ? 'mongodb' : (0, shared_js_1.currentDriver)();
12
12
  if (d === 'sqlite') {
13
13
  if (!sqliteAdapter)
14
- sqliteAdapter = new sqlite_adapter_1.SqliteAdapter();
14
+ sqliteAdapter = new sqlite_adapter_js_1.SqliteAdapter();
15
15
  return sqliteAdapter;
16
16
  }
17
17
  if (!mongoAdapter)
18
- mongoAdapter = new mongo_adapter_1.MongoAdapter();
18
+ mongoAdapter = new mongo_adapter_js_1.MongoAdapter();
19
19
  return mongoAdapter;
20
20
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MongoAdapter = void 0;
4
- const mongodb_functions_1 = require("./mongodb-functions");
4
+ const mongodb_functions_js_1 = require("./mongodb-functions.js");
5
5
  class MongoAdapter {
6
6
  constructor() {
7
7
  this.name = 'mongodb';
@@ -9,12 +9,12 @@ class MongoAdapter {
9
9
  async create(args) {
10
10
  if (!args.client)
11
11
  throw new Error('MongoAdapter.create requires a MongoClient');
12
- return await (0, mongodb_functions_1.otpCreate)(args.client, args.otp);
12
+ return await (0, mongodb_functions_js_1.otpCreate)(args.client, args.otp);
13
13
  }
14
14
  async validateWithStatus(args) {
15
15
  if (!args.client)
16
16
  throw new Error('MongoAdapter.validateWithStatus requires a MongoClient');
17
- return await (0, mongodb_functions_1.otpValidateWithStatus)(args.client, args.otp);
17
+ return await (0, mongodb_functions_js_1.otpValidateWithStatus)(args.client, args.otp);
18
18
  }
19
19
  }
20
20
  exports.MongoAdapter = MongoAdapter;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.otpValidate = exports.otpValidateWithStatus = exports.otpCreate = void 0;
4
- const shared_1 = require("./shared");
4
+ const shared_js_1 = require("./shared.js");
5
5
  const otpCreate = async (client, otp) => {
6
6
  if (!process.env.OTP_MONGO_DATABASE || !process.env.OTP_MONGO_COLLECTION) {
7
7
  throw new Error('Missing OTP_MONGO_DATABASE or OTP_MONGO_COLLECTION');
@@ -15,8 +15,8 @@ const otpCreate = async (client, otp) => {
15
15
  throw new Error('otpCreate does not accept an _id; it will be generated by MongoDB');
16
16
  }
17
17
  const doc = {
18
- contactId: (0, shared_1.computeContactId)(otp.contact),
19
- otpHash: (0, shared_1.computeOtpHash)(otp.contact, otp.otp),
18
+ contactId: (0, shared_js_1.computeContactId)(otp.contact),
19
+ otpHash: (0, shared_js_1.computeOtpHash)(otp.contact, otp.otp),
20
20
  createdAt: otp.createdAt,
21
21
  };
22
22
  return await cursor.insertOne(doc);
@@ -34,8 +34,8 @@ const otpValidateWithStatus = async (client, otp, now = new Date(), ttlSeconds)
34
34
  }
35
35
  const database = client.db(process.env.OTP_MONGO_DATABASE);
36
36
  const cursor = database.collection(process.env.OTP_MONGO_COLLECTION);
37
- const otpHash = (0, shared_1.computeOtpHash)(otp.contact, otp.otp);
38
- const contactId = (0, shared_1.computeContactId)(otp.contact);
37
+ const otpHash = (0, shared_js_1.computeOtpHash)(otp.contact, otp.otp);
38
+ const contactId = (0, shared_js_1.computeContactId)(otp.contact);
39
39
  // Delete matching doc and retrieve the deleted document for inspection
40
40
  const res = await cursor.findOneAndDelete({ contactId, otpHash });
41
41
  const deleted = res && (res.createdAt ? res : (res.value ?? null));
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SqliteAdapter = void 0;
4
- const sqlite_functions_1 = require("./sqlite-functions");
4
+ const sqlite_functions_js_1 = require("./sqlite-functions.js");
5
5
  class SqliteAdapter {
6
6
  constructor() {
7
7
  this.name = 'sqlite';
8
8
  }
9
9
  async create(args) {
10
- return await (0, sqlite_functions_1.otpCreate)(args.otp);
10
+ return await (0, sqlite_functions_js_1.otpCreate)(args.otp);
11
11
  }
12
12
  async validateWithStatus(args) {
13
- return await (0, sqlite_functions_1.otpValidateWithStatus)(args.otp);
13
+ return await (0, sqlite_functions_js_1.otpValidateWithStatus)(args.otp);
14
14
  }
15
15
  }
16
16
  exports.SqliteAdapter = SqliteAdapter;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.otpValidateWithStatus = exports.otpCreate = void 0;
4
- const shared_1 = require("./shared");
4
+ const shared_js_1 = require("./shared.js");
5
5
  let sqlite3;
6
6
  let db = null;
7
7
  // Bundler-safe loader for optional sqlite3 dependency.
@@ -27,7 +27,7 @@ function getDb() {
27
27
  return db;
28
28
  // Lazy-load sqlite3 only when the SQLite driver is actually used
29
29
  const s = sqlite3 ?? (sqlite3 = loadSqlite3());
30
- db = new s.Database(shared_1.SQLITE_PATH);
30
+ db = new s.Database(shared_js_1.SQLITE_PATH);
31
31
  db.serialize(() => {
32
32
  db.run('CREATE TABLE IF NOT EXISTS otp (\n' +
33
33
  ' id INTEGER PRIMARY KEY AUTOINCREMENT,\n' +
@@ -43,8 +43,8 @@ function getDb() {
43
43
  const otpCreate = async (otp) => {
44
44
  const database = getDb();
45
45
  const createdAt = otp.createdAt ? otp.createdAt.getTime() : Date.now();
46
- const otpHash = (0, shared_1.computeOtpHash)(otp.contact, otp.otp);
47
- const contactId = (0, shared_1.computeContactId)(otp.contact);
46
+ const otpHash = (0, shared_js_1.computeOtpHash)(otp.contact, otp.otp);
47
+ const contactId = (0, shared_js_1.computeContactId)(otp.contact);
48
48
  return await new Promise((resolve, reject) => {
49
49
  database.run('INSERT INTO otp (contactId, otpHash, createdAt) VALUES (?, ?, ?)', [contactId, otpHash, createdAt], function (err) {
50
50
  if (err)
@@ -57,8 +57,8 @@ const otpCreate = async (otp) => {
57
57
  exports.otpCreate = otpCreate;
58
58
  const otpValidateWithStatus = async (otp, now = new Date(), ttlSeconds) => {
59
59
  const database = getDb();
60
- const otpHash = (0, shared_1.computeOtpHash)(otp.contact, otp.otp);
61
- const contactId = (0, shared_1.computeContactId)(otp.contact);
60
+ const otpHash = (0, shared_js_1.computeOtpHash)(otp.contact, otp.otp);
61
+ const contactId = (0, shared_js_1.computeContactId)(otp.contact);
62
62
  return await new Promise((resolve, reject) => {
63
63
  // Single-statement atomicity: select the newest id, then conditionally delete it.
64
64
  // We avoid explicit BEGIN/COMMIT to prevent nested transaction errors under concurrency.
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const db_1 = require("./db");
7
- const sender_1 = __importDefault(require("./sender"));
6
+ const index_js_1 = require("./db/index.js");
7
+ const sender_js_1 = __importDefault(require("./sender.js"));
8
8
  const otp_generator_1 = __importDefault(require("otp-generator"));
9
- const rate_limiter_1 = require("./rate-limiter");
10
- const config_1 = require("./config");
9
+ const rate_limiter_js_1 = require("./rate-limiter.js");
10
+ const config_js_1 = require("./config.js");
11
11
  class OneHitter {
12
12
  /**
13
13
  * @class OneHitter
@@ -35,15 +35,15 @@ class OneHitter {
35
35
  if (options?.rateLimiter) {
36
36
  this.limiter = options.rateLimiter;
37
37
  }
38
- else if (config_1.ONEHITTER_ENABLE_INMEM_LIMITER) {
39
- this.limiter = new rate_limiter_1.InMemoryRateLimiter({
40
- max: config_1.ONEHITTER_LIMIT_MAX,
41
- windowMs: config_1.ONEHITTER_LIMIT_WINDOW_MS,
42
- cooldownMs: config_1.ONEHITTER_LIMIT_COOLDOWN_MS,
38
+ else if (config_js_1.ONEHITTER_ENABLE_INMEM_LIMITER) {
39
+ this.limiter = new rate_limiter_js_1.InMemoryRateLimiter({
40
+ max: config_js_1.ONEHITTER_LIMIT_MAX,
41
+ windowMs: config_js_1.ONEHITTER_LIMIT_WINDOW_MS,
42
+ cooldownMs: config_js_1.ONEHITTER_LIMIT_COOLDOWN_MS,
43
43
  });
44
44
  }
45
45
  else {
46
- this.limiter = new rate_limiter_1.NoopRateLimiter();
46
+ this.limiter = new rate_limiter_js_1.NoopRateLimiter();
47
47
  }
48
48
  this.message = options?.message;
49
49
  this.email = options?.email;
@@ -52,7 +52,7 @@ class OneHitter {
52
52
  const isOtpFirst = arg1?.contact && !arg1?.db;
53
53
  const otp = (isOtpFirst ? arg1 : arg2);
54
54
  const client = isOtpFirst ? undefined : arg1;
55
- const adapter = (0, db_1.getAdapter)({ hasClient: !!client });
55
+ const adapter = (0, index_js_1.getAdapter)({ hasClient: !!client });
56
56
  return await adapter.create({ client, otp });
57
57
  }
58
58
  /**
@@ -76,10 +76,10 @@ class OneHitter {
76
76
  * @throws {Error} If the required configuration value `OTP_URL` is missing.
77
77
  */
78
78
  async send(to, otp) {
79
- if (!config_1.OTP_URL || String(config_1.OTP_URL).trim().length === 0) {
79
+ if (!config_js_1.OTP_URL || String(config_js_1.OTP_URL).trim().length === 0) {
80
80
  throw new Error('Missing OTP_URL: set environment variable OTP_URL or provide it via config');
81
81
  }
82
- await (0, sender_1.default)(to, otp, config_1.OTP_URL, config_1.OTP_EXPIRY, this.message, this.email);
82
+ await (0, sender_js_1.default)(to, otp, config_js_1.OTP_URL, config_js_1.OTP_EXPIRY, this.message, this.email);
83
83
  }
84
84
  async validate(arg1, arg2) {
85
85
  const status = await this.validateStatus(arg1, arg2);
@@ -91,7 +91,7 @@ class OneHitter {
91
91
  const allowed = await this.limiter.beforeValidate(otp.contact);
92
92
  if (!allowed)
93
93
  return 'blocked';
94
- const adapter = (0, db_1.getAdapter)({ hasClient });
94
+ const adapter = (0, index_js_1.getAdapter)({ hasClient });
95
95
  const status = await adapter.validateWithStatus({ client: hasClient ? arg1 : undefined, otp });
96
96
  if (status === 'ok')
97
97
  await this.limiter.onSuccess(otp.contact);
@@ -119,13 +119,13 @@ class OneHitter {
119
119
  * @returns {string} The newly generated OTP string.
120
120
  */
121
121
  make() {
122
- const rawLength = Number.isFinite(config_1.OTP_LENGTH) && config_1.OTP_LENGTH > 0 ? config_1.OTP_LENGTH : 6;
122
+ const rawLength = Number.isFinite(config_js_1.OTP_LENGTH) && config_js_1.OTP_LENGTH > 0 ? config_js_1.OTP_LENGTH : 6;
123
123
  const length = Math.min(rawLength, 64);
124
124
  const base = {
125
- upperCaseAlphabets: config_1.OTP_LETTERS_UPPER,
126
- lowerCaseAlphabets: config_1.OTP_LETTERS_LOWER,
127
- digits: config_1.OTP_DIGITS,
128
- specialChars: config_1.OTP_SPECIAL_CHARS,
125
+ upperCaseAlphabets: config_js_1.OTP_LETTERS_UPPER,
126
+ lowerCaseAlphabets: config_js_1.OTP_LETTERS_LOWER,
127
+ digits: config_js_1.OTP_DIGITS,
128
+ specialChars: config_js_1.OTP_SPECIAL_CHARS,
129
129
  };
130
130
  const hasAny = base.upperCaseAlphabets || base.lowerCaseAlphabets || base.digits || base.specialChars;
131
131
  const options = hasAny ? base : { ...base, digits: true };
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createSesV2Transport = createSesV2Transport;
7
7
  const nodemailer_1 = __importDefault(require("nodemailer"));
8
- const config_1 = require("./config");
8
+ const config_js_1 = require("./config.js");
9
9
  /**
10
10
  * @function formatExpiry
11
11
  * @description
@@ -27,7 +27,7 @@ const config_1 = require("./config");
27
27
  */
28
28
  function formatExpiry(expiry) {
29
29
  const secFromArg = Number(expiry);
30
- const envExpiryNum = Number(config_1.OTP_EXPIRY);
30
+ const envExpiryNum = Number(config_js_1.OTP_EXPIRY);
31
31
  const seconds = (Number.isFinite(secFromArg) && secFromArg > 0)
32
32
  ? secFromArg
33
33
  : ((Number.isFinite(envExpiryNum) && envExpiryNum > 0) ? envExpiryNum : 1800); // default 30m
@@ -80,7 +80,7 @@ function resolveMessage(to, otp, url, expiry, cfgOrFn) {
80
80
  if (cfg.from)
81
81
  override.from = cfg.from;
82
82
  }
83
- const subject = override.subject ?? config_1.OTP_MESSAGE_SUBJECT;
83
+ const subject = override.subject ?? config_js_1.OTP_MESSAGE_SUBJECT;
84
84
  const text = override.text ?? `This is your one-time password to access ${url}
85
85
 
86
86
  ${otp}
@@ -90,7 +90,7 @@ Once used, this one-time password can not be used again. That's why it's called
90
90
  // Prefer explicitly configured from, then library-level config default, and
91
91
  // finally fall back to the live environment variable. This makes tests and
92
92
  // applications resilient when env is loaded after the module is imported.
93
- const from = override.from ?? config_1.OTP_MESSAGE_FROM ?? process.env.OTP_MESSAGE_FROM;
93
+ const from = override.from ?? config_js_1.OTP_MESSAGE_FROM ?? process.env.OTP_MESSAGE_FROM;
94
94
  return { subject, text, html, from };
95
95
  }
96
96
  /**
@@ -133,7 +133,7 @@ async function send(to, otp, url, expiry, message, opts) {
133
133
  if (!to || String(to).trim().length === 0) {
134
134
  throw new Error('Missing recipient email: ensure OTP_MESSAGE_TEST_TO (for tests) or the "to" argument is set');
135
135
  }
136
- const region = opts?.region ?? config_1.OTP_SES_REGION ?? 'us-east-1';
136
+ const region = opts?.region ?? config_js_1.OTP_SES_REGION ?? 'us-east-1';
137
137
  const transporter = opts?.transporter ?? createSesTransport(region);
138
138
  const { subject, text, html, from } = resolveMessage(to, otp, url, expiry, message);
139
139
  if (!from || String(from).trim().length === 0) {
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from 'events';
2
- import OneHitter from './onehitter';
2
+ import OneHitter from './onehitter.js';
3
3
  /**
4
4
  * The core OTP service. Extends EventEmitter to provide fan-out capabilities
5
5
  * via the 'auth:success' and 'auth:failure' events.
@@ -1,5 +1,5 @@
1
1
  import { MongoClient, ServerApiVersion } from 'mongodb';
2
- import { MONGO_CONNECTION } from '../config';
2
+ import { MONGO_CONNECTION } from '../config.js';
3
3
  /**
4
4
  * Ensure there is a TTL index on createdAt.
5
5
  * If an index exists with a different expireAfterSeconds, it will be recreated.
@@ -1,6 +1,6 @@
1
- import { currentDriver } from './shared';
2
- import { MongoAdapter } from './mongo-adapter';
3
- import { SqliteAdapter } from './sqlite-adapter';
1
+ import { currentDriver } from './shared.js';
2
+ import { MongoAdapter } from './mongo-adapter.js';
3
+ import { SqliteAdapter } from './sqlite-adapter.js';
4
4
  let mongoAdapter = null;
5
5
  let sqliteAdapter = null;
6
6
  export function getAdapter(opts) {
@@ -1,4 +1,4 @@
1
- import { otpCreate, otpValidateWithStatus } from './mongodb-functions';
1
+ import { otpCreate, otpValidateWithStatus } from './mongodb-functions.js';
2
2
  export class MongoAdapter {
3
3
  constructor() {
4
4
  this.name = 'mongodb';
@@ -1,4 +1,4 @@
1
- import { computeOtpHash, computeContactId } from './shared';
1
+ import { computeOtpHash, computeContactId } from './shared.js';
2
2
  export const otpCreate = async (client, otp) => {
3
3
  if (!process.env.OTP_MONGO_DATABASE || !process.env.OTP_MONGO_COLLECTION) {
4
4
  throw new Error('Missing OTP_MONGO_DATABASE or OTP_MONGO_COLLECTION');
@@ -1,4 +1,4 @@
1
- import { otpCreate, otpValidateWithStatus } from './sqlite-functions';
1
+ import { otpCreate, otpValidateWithStatus } from './sqlite-functions.js';
2
2
  export class SqliteAdapter {
3
3
  constructor() {
4
4
  this.name = 'sqlite';
@@ -1,4 +1,4 @@
1
- import { SQLITE_PATH, computeOtpHash, computeContactId } from './shared';
1
+ import { SQLITE_PATH, computeOtpHash, computeContactId } from './shared.js';
2
2
  let sqlite3;
3
3
  let db = null;
4
4
  // Bundler-safe loader for optional sqlite3 dependency.
@@ -1,8 +1,8 @@
1
- import { getAdapter } from './db';
2
- import sendEmail from './sender';
1
+ import { getAdapter } from './db/index.js';
2
+ import sendEmail from './sender.js';
3
3
  import otpGenerator from 'otp-generator';
4
- import { NoopRateLimiter, InMemoryRateLimiter } from './rate-limiter';
5
- import { ONEHITTER_ENABLE_INMEM_LIMITER, ONEHITTER_LIMIT_COOLDOWN_MS, ONEHITTER_LIMIT_MAX, ONEHITTER_LIMIT_WINDOW_MS, OTP_DIGITS, OTP_LETTERS_LOWER, OTP_LETTERS_UPPER, OTP_LENGTH, OTP_SPECIAL_CHARS, OTP_URL, OTP_EXPIRY, } from './config';
4
+ import { NoopRateLimiter, InMemoryRateLimiter } from './rate-limiter.js';
5
+ import { ONEHITTER_ENABLE_INMEM_LIMITER, ONEHITTER_LIMIT_COOLDOWN_MS, ONEHITTER_LIMIT_MAX, ONEHITTER_LIMIT_WINDOW_MS, OTP_DIGITS, OTP_LETTERS_LOWER, OTP_LETTERS_UPPER, OTP_LENGTH, OTP_SPECIAL_CHARS, OTP_URL, OTP_EXPIRY, } from './config.js';
6
6
  class OneHitter {
7
7
  /**
8
8
  * @class OneHitter
@@ -1,5 +1,5 @@
1
1
  import nodemailer from 'nodemailer';
2
- import { OTP_MESSAGE_FROM, OTP_MESSAGE_SUBJECT, OTP_SES_REGION, OTP_EXPIRY } from './config';
2
+ import { OTP_MESSAGE_FROM, OTP_MESSAGE_SUBJECT, OTP_SES_REGION, OTP_EXPIRY } from './config.js';
3
3
  /**
4
4
  * @function formatExpiry
5
5
  * @description
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from 'events';
2
- import OneHitter from './onehitter';
2
+ import OneHitter from './onehitter.js';
3
3
  export interface AuthSuccessPayload {
4
4
  userId: string;
5
5
  authTime: Date;
@@ -1,4 +1,4 @@
1
- import type { DbAdapter } from './shared';
1
+ import type { DbAdapter } from './shared.js';
2
2
  export declare function getAdapter(opts?: {
3
3
  hasClient?: boolean;
4
4
  }): DbAdapter;
@@ -1,5 +1,5 @@
1
1
  import type { MongoClient, InsertOneResult } from 'mongodb';
2
- import type { DbAdapter, OtpDoc, ValidateStatus } from './shared';
2
+ import type { DbAdapter, OtpDoc, ValidateStatus } from './shared.js';
3
3
  export declare class MongoAdapter implements DbAdapter {
4
4
  readonly name: "mongodb";
5
5
  create(args: {
@@ -1,5 +1,5 @@
1
1
  import type { MongoClient, InsertOneResult, ObjectId } from 'mongodb';
2
- import { type ValidateStatus, type OtpDoc } from './shared';
2
+ import { type ValidateStatus, type OtpDoc } from './shared.js';
3
3
  interface StoredOtpDoc {
4
4
  contactId: string;
5
5
  otpHash: string;
@@ -1,5 +1,5 @@
1
1
  import type { InsertOneResult } from 'mongodb';
2
- import type { DbAdapter, OtpDoc, ValidateStatus } from './shared';
2
+ import type { DbAdapter, OtpDoc, ValidateStatus } from './shared.js';
3
3
  export declare class SqliteAdapter implements DbAdapter {
4
4
  readonly name: "sqlite";
5
5
  create(args: {
@@ -1,4 +1,4 @@
1
1
  import type { InsertOneResult } from 'mongodb';
2
- import { type OtpDoc, type ValidateStatus } from './shared';
2
+ import { type OtpDoc, type ValidateStatus } from './shared.js';
3
3
  export declare const otpCreate: (otp: OtpDoc) => Promise<InsertOneResult<unknown>>;
4
4
  export declare const otpValidateWithStatus: (otp: Pick<OtpDoc, "contact" | "otp">, now?: Date, ttlSeconds?: number) => Promise<ValidateStatus>;
@@ -1,7 +1,7 @@
1
1
  import type { MongoClient, InsertOneResult } from 'mongodb';
2
- import type { OtpDoc, ValidateStatus } from './db/shared';
3
- import { type MessageConfig, type MessageTemplate } from './sender';
4
- import { type OneHitterOptions } from './rate-limiter';
2
+ import type { OtpDoc, ValidateStatus } from './db/shared.js';
3
+ import { type MessageConfig, type MessageTemplate } from './sender.js';
4
+ import { type OneHitterOptions } from './rate-limiter.js';
5
5
  type EmailOption = {
6
6
  message?: MessageConfig | MessageTemplate;
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onehitter",
3
- "version": "2.0.11",
3
+ "version": "2.0.13",
4
4
  "description": "One-time password user validation package.",
5
5
  "main": "dist/cjs/onehitter.js",
6
6
  "module": "dist/esm/onehitter.js",
@@ -78,7 +78,7 @@
78
78
  "author": "Keith Vance <discgolfer@uniflydiscs.com>",
79
79
  "license": "MIT",
80
80
  "engines": {
81
- "node": "^18 || ^20"
81
+ "node": "^18 || ^20 || ^22"
82
82
  },
83
83
  "files": [
84
84
  "dist/esm",
@@ -92,7 +92,7 @@
92
92
  "@aws-sdk/client-sesv2": "^3.716.0",
93
93
  "dotenv-safe": "^9.1.0",
94
94
  "mongodb": "^7.0.0",
95
- "nodemailer": "^7.0.10",
95
+ "nodemailer": "^7.0.11",
96
96
  "otp-generator": "^4.0.1"
97
97
  },
98
98
  "devDependencies": {