mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-06-08 00:51:00 +08:00
feature: update dependencies (#651)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { Context } from "hono";
|
||||
import { HonoCustomType } from "../types";
|
||||
import { handleListQuery } from "../common";
|
||||
|
||||
export default {
|
||||
|
||||
@@ -4,7 +4,6 @@ import { CONSTANTS } from '../constants';
|
||||
import { getJsonSetting, saveSetting, checkUserPassword, getDomains, getUserRoles } from '../utils';
|
||||
import { UserSettings, GeoData, UserInfo } from "../models";
|
||||
import { handleListQuery } from '../common'
|
||||
import { HonoCustomType } from '../types';
|
||||
import UserBindAddressModule from '../user_api/bind_address';
|
||||
import i18n from '../i18n';
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import { cleanup } from '../common';
|
||||
import { CONSTANTS } from '../constants';
|
||||
import { getJsonSetting, saveSetting } from '../utils';
|
||||
import { CleanupSettings } from '../models';
|
||||
import { HonoCustomType } from '../types';
|
||||
|
||||
export default {
|
||||
cleanup: async (c: Context<HonoCustomType>) => {
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Hono } from 'hono'
|
||||
import { Jwt } from 'hono/utils/jwt'
|
||||
|
||||
import i18n from '../i18n'
|
||||
import { HonoCustomType } from '../types'
|
||||
import { sendAdminInternalMail, getJsonSetting, saveSetting, getUserRoles } from '../utils'
|
||||
import { newAddress, handleListQuery } from '../common'
|
||||
import { CONSTANTS } from '../constants'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Context } from "hono";
|
||||
import { HonoCustomType, ParsedEmailContext } from "../types";
|
||||
import { CONSTANTS } from "../constants";
|
||||
import { WebhookSettings } from "../models";
|
||||
import { commonParseMail, sendWebhook } from "../common";
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Context } from 'hono';
|
||||
|
||||
import { CONSTANTS } from '../constants';
|
||||
import { UserOauth2Settings } from "../models";
|
||||
import { HonoCustomType } from '../types';
|
||||
import { getJsonSetting, saveSetting } from '../utils';
|
||||
|
||||
async function getUserOauth2Settings(c: Context<HonoCustomType>): Promise<Response> {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Context } from "hono";
|
||||
import { HonoCustomType } from "../types";
|
||||
import { sendMail } from "../mails_api/send_mail_api";
|
||||
|
||||
export const sendMailbyAdmin = async (c: Context<HonoCustomType>) => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Context } from "hono";
|
||||
import { HonoCustomType } from "../types";
|
||||
import { CONSTANTS } from "../constants";
|
||||
import { AdminWebhookSettings } from "../models";
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Context } from 'hono';
|
||||
|
||||
import { HonoCustomType } from '../types';
|
||||
import { getAdminPasswords, getBooleanValue, getDefaultDomains, getDomains, getIntValue, getPasswords, getStringArray, getStringValue, getUserRoles, getSubdomainForwardAddressList, getAnotherWorkerList, getSplitStringListValue } from '../utils';
|
||||
import utils from '../utils';
|
||||
import { CONSTANTS } from '../constants';
|
||||
import { isS3Enabled } from '../mails_api/s3_attachment';
|
||||
|
||||
@@ -10,49 +9,49 @@ export default {
|
||||
return c.json({
|
||||
"DEFAULT_LANG": c.env.DEFAULT_LANG,
|
||||
"TITLE": c.env.TITLE,
|
||||
"HAS_PASSWORD": getPasswords(c).length,
|
||||
"HAS_ADMIN_PASSWORDS": getAdminPasswords(c).length,
|
||||
"ANNOUNCEMENT": getStringValue(c.env.ANNOUNCEMENT),
|
||||
"HAS_PASSWORD": utils.getPasswords(c).length,
|
||||
"HAS_ADMIN_PASSWORDS": utils.getAdminPasswords(c).length,
|
||||
"ANNOUNCEMENT": utils.getStringValue(c.env.ANNOUNCEMENT),
|
||||
|
||||
"PREFIX": getStringValue(c.env.PREFIX),
|
||||
"ADDRESS_CHECK_REGEX": getStringValue(c.env.ADDRESS_CHECK_REGEX),
|
||||
"ADDRESS_REGEX": getStringValue(c.env.ADDRESS_REGEX),
|
||||
"MIN_ADDRESS_LEN": getIntValue(c.env.MIN_ADDRESS_LEN, 1),
|
||||
"MAX_ADDRESS_LEN": getIntValue(c.env.MAX_ADDRESS_LEN, 30),
|
||||
"PREFIX": utils.getStringValue(c.env.PREFIX),
|
||||
"ADDRESS_CHECK_REGEX": utils.getStringValue(c.env.ADDRESS_CHECK_REGEX),
|
||||
"ADDRESS_REGEX": utils.getStringValue(c.env.ADDRESS_REGEX),
|
||||
"MIN_ADDRESS_LEN": utils.getIntValue(c.env.MIN_ADDRESS_LEN, 1),
|
||||
"MAX_ADDRESS_LEN": utils.getIntValue(c.env.MAX_ADDRESS_LEN, 30),
|
||||
|
||||
"FORWARD_ADDRESS_LIST": getStringArray(c.env.FORWARD_ADDRESS_LIST),
|
||||
"SUBDOMAIN_FORWARD_ADDRESS_LIST": getSubdomainForwardAddressList(c),
|
||||
"DEFAULT_DOMAINS": getDefaultDomains(c),
|
||||
"DOMAINS": getDomains(c),
|
||||
"DOMAIN_LABELS": getStringArray(c.env.DOMAIN_LABELS),
|
||||
"FORWARD_ADDRESS_LIST": utils.getStringArray(c.env.FORWARD_ADDRESS_LIST),
|
||||
"SUBDOMAIN_FORWARD_ADDRESS_LIST": utils.getJsonObjectValue<SubdomainForwardAddressList[]>(c.env.SUBDOMAIN_FORWARD_ADDRESS_LIST),
|
||||
"DEFAULT_DOMAINS": utils.getDefaultDomains(c),
|
||||
"DOMAINS": utils.getDomains(c),
|
||||
"DOMAIN_LABELS": utils.getStringArray(c.env.DOMAIN_LABELS),
|
||||
|
||||
"HAS_JWT_SECRET": !!getStringValue(c.env.JWT_SECRET),
|
||||
"HAS_JWT_SECRET": !!utils.getStringValue(c.env.JWT_SECRET),
|
||||
|
||||
"ADMIN_USER_ROLE": getStringValue(c.env.ADMIN_USER_ROLE),
|
||||
"USER_DEFAULT_ROLE": getStringValue(c.env.USER_DEFAULT_ROLE),
|
||||
"USER_ROLES": getUserRoles(c),
|
||||
"NO_LIMIT_SEND_ROLE": getSplitStringListValue(c.env.NO_LIMIT_SEND_ROLE),
|
||||
"ADMIN_USER_ROLE": utils.getStringValue(c.env.ADMIN_USER_ROLE),
|
||||
"USER_DEFAULT_ROLE": utils.getStringValue(c.env.USER_DEFAULT_ROLE),
|
||||
"USER_ROLES": utils.getUserRoles(c),
|
||||
"NO_LIMIT_SEND_ROLE": utils.getSplitStringListValue(c.env.NO_LIMIT_SEND_ROLE),
|
||||
|
||||
"ADMIN_CONTACT": c.env.ADMIN_CONTACT,
|
||||
"ENABLE_USER_CREATE_EMAIL": getBooleanValue(c.env.ENABLE_USER_CREATE_EMAIL),
|
||||
"DISABLE_ANONYMOUS_USER_CREATE_EMAIL": getBooleanValue(c.env.DISABLE_ANONYMOUS_USER_CREATE_EMAIL),
|
||||
"ENABLE_USER_DELETE_EMAIL": getBooleanValue(c.env.ENABLE_USER_DELETE_EMAIL),
|
||||
"ENABLE_AUTO_REPLY": getBooleanValue(c.env.ENABLE_AUTO_REPLY),
|
||||
"ENABLE_USER_CREATE_EMAIL": utils.getBooleanValue(c.env.ENABLE_USER_CREATE_EMAIL),
|
||||
"DISABLE_ANONYMOUS_USER_CREATE_EMAIL": utils.getBooleanValue(c.env.DISABLE_ANONYMOUS_USER_CREATE_EMAIL),
|
||||
"ENABLE_USER_DELETE_EMAIL": utils.getBooleanValue(c.env.ENABLE_USER_DELETE_EMAIL),
|
||||
"ENABLE_AUTO_REPLY": utils.getBooleanValue(c.env.ENABLE_AUTO_REPLY),
|
||||
"COPYRIGHT": c.env.COPYRIGHT,
|
||||
"ENABLE_WEBHOOK": getBooleanValue(c.env.ENABLE_WEBHOOK),
|
||||
"ENABLE_WEBHOOK": utils.getBooleanValue(c.env.ENABLE_WEBHOOK),
|
||||
"S3_ENABLED": isS3Enabled(c),
|
||||
"VERSION": CONSTANTS.VERSION,
|
||||
"DISABLE_SHOW_GITHUB": !getBooleanValue(c.env.DISABLE_SHOW_GITHUB),
|
||||
"DISABLE_ADMIN_PASSWORD_CHECK": getBooleanValue(c.env.DISABLE_ADMIN_PASSWORD_CHECK),
|
||||
"ENABLE_CHECK_JUNK_MAIL": getBooleanValue(c.env.ENABLE_CHECK_JUNK_MAIL),
|
||||
"JUNK_MAIL_CHECK_LIST": getStringArray(c.env.JUNK_MAIL_CHECK_LIST),
|
||||
"JUNK_MAIL_FORCE_PASS_LIST": getStringArray(c.env.JUNK_MAIL_FORCE_PASS_LIST),
|
||||
"DISABLE_SHOW_GITHUB": !utils.getBooleanValue(c.env.DISABLE_SHOW_GITHUB),
|
||||
"DISABLE_ADMIN_PASSWORD_CHECK": utils.getBooleanValue(c.env.DISABLE_ADMIN_PASSWORD_CHECK),
|
||||
"ENABLE_CHECK_JUNK_MAIL": utils.getBooleanValue(c.env.ENABLE_CHECK_JUNK_MAIL),
|
||||
"JUNK_MAIL_CHECK_LIST": utils.getStringArray(c.env.JUNK_MAIL_CHECK_LIST),
|
||||
"JUNK_MAIL_FORCE_PASS_LIST": utils.getStringArray(c.env.JUNK_MAIL_FORCE_PASS_LIST),
|
||||
|
||||
"REMOVE_EXCEED_SIZE_ATTACHMENT": getBooleanValue(c.env.REMOVE_EXCEED_SIZE_ATTACHMENT),
|
||||
"REMOVE_ALL_ATTACHMENT": getBooleanValue(c.env.REMOVE_ALL_ATTACHMENT),
|
||||
"REMOVE_EXCEED_SIZE_ATTACHMENT": utils.getBooleanValue(c.env.REMOVE_EXCEED_SIZE_ATTACHMENT),
|
||||
"REMOVE_ALL_ATTACHMENT": utils.getBooleanValue(c.env.REMOVE_ALL_ATTACHMENT),
|
||||
|
||||
"ENABLE_ANOTHER_WORKER": getBooleanValue(c.env.ENABLE_ANOTHER_WORKER),
|
||||
"ANOTHER_WORKER_LIST": getAnotherWorkerList(c),
|
||||
"ENABLE_ANOTHER_WORKER": utils.getBooleanValue(c.env.ENABLE_ANOTHER_WORKER),
|
||||
"ANOTHER_WORKER_LIST": utils.getAnotherWorkerList(c),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Hono } from 'hono'
|
||||
|
||||
import { getDomains, getPasswords, getBooleanValue, getIntValue, getStringArray, getDefaultDomains, getStringValue } from './utils';
|
||||
import { CONSTANTS } from './constants';
|
||||
import { HonoCustomType } from './types';
|
||||
import { isS3Enabled } from './mails_api/s3_attachment';
|
||||
|
||||
const api = new Hono<HonoCustomType>
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Context } from 'hono';
|
||||
import { Jwt } from 'hono/utils/jwt'
|
||||
|
||||
import { getBooleanValue, getDomains, getStringValue, getIntValue, getUserRoles, getDefaultDomains, getJsonSetting, getAnotherWorkerList } from './utils';
|
||||
import { HonoCustomType, UserRole, AnotherWorker, RPCEmailMessage, ParsedEmailContext } from './types';
|
||||
import { unbindTelegramByAddress } from './telegram_api/common';
|
||||
import { CONSTANTS } from './constants';
|
||||
import { AdminWebhookSettings, WebhookMail, WebhookSettings } from './models';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { createMimeMessage } from "mimetext";
|
||||
import { getBooleanValue } from "../utils";
|
||||
import { Bindings } from "../types";
|
||||
|
||||
export const auto_reply = async (message: ForwardableEmailMessage, env: Bindings): Promise<void> => {
|
||||
const message_id = message.headers.get("Message-ID");
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { CONSTANTS } from "../constants";
|
||||
import { Bindings } from "../types";
|
||||
|
||||
export const isBlocked = async (from: string, env: Bindings): Promise<boolean> => {
|
||||
if (env.BLACK_LIST && env.BLACK_LIST.split(",").some(word => from.includes(word))) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Bindings, ParsedEmailContext } from "../types";
|
||||
import { getBooleanValue } from "../utils";
|
||||
import { commonParseMail } from "../common";
|
||||
import { createMimeMessage } from "mimetext";
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Bindings, ParsedEmailContext } from "../types";
|
||||
import { getBooleanValue, getStringArray } from "../utils";
|
||||
import { commonParseMail } from "../common";
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { Context } from "hono";
|
||||
|
||||
import { getEnvStringList } from "../utils";
|
||||
import { getSubdomainForwardAddressList } from "../utils";
|
||||
import { getEnvStringList, getJsonObjectValue } from "../utils";
|
||||
import { sendMailToTelegram } from "../telegram_api";
|
||||
import { Bindings, HonoCustomType, RPCEmailMessage, ParsedEmailContext } from "../types";
|
||||
import { auto_reply } from "./auto_reply";
|
||||
import { isBlocked } from "./black_list";
|
||||
import { triggerWebhook, triggerAnotherWorker, commonParseMail } from "../common";
|
||||
@@ -70,24 +68,24 @@ async function email(message: ForwardableEmailMessage, env: Bindings, ctx: Execu
|
||||
|
||||
// forward subdomain email
|
||||
try {
|
||||
// 遍历 FORWARD_ADDRESS_LIST
|
||||
const subdomainForwardAddressList = getSubdomainForwardAddressList(env.SUBDOMAIN_FORWARD_ADDRESS_LIST)
|
||||
for (const subdomainForwardAddress of subdomainForwardAddressList) {
|
||||
// 检查邮件是否匹配 domains
|
||||
if (subdomainForwardAddress.domains && subdomainForwardAddress.domains.length > 0) {
|
||||
for (const domain of subdomainForwardAddress.domains) {
|
||||
if (message.to.endsWith(domain)) {
|
||||
// 转发邮件
|
||||
await message.forward(subdomainForwardAddress.forward);
|
||||
// 支持多邮箱转发收件,不进行截止
|
||||
// break;
|
||||
// 遍历 FORWARD_ADDRESS_LIST
|
||||
const subdomainForwardAddressList = getJsonObjectValue<SubdomainForwardAddressList[]>(env.SUBDOMAIN_FORWARD_ADDRESS_LIST) || [];
|
||||
for (const subdomainForwardAddress of subdomainForwardAddressList) {
|
||||
// 检查邮件是否匹配 domains
|
||||
if (subdomainForwardAddress.domains && subdomainForwardAddress.domains.length > 0) {
|
||||
for (const domain of subdomainForwardAddress.domains) {
|
||||
if (message.to.endsWith(domain)) {
|
||||
// 转发邮件
|
||||
await message.forward(subdomainForwardAddress.forward);
|
||||
// 支持多邮箱转发收件,不进行截止
|
||||
// break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 如果 domains 为空,则转发所有邮件
|
||||
await message.forward(subdomainForwardAddress.forward);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 如果 domains 为空,则转发所有邮件
|
||||
await message.forward(subdomainForwardAddress.forward);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("subdomain forward email error", error);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { LocaleMessages } from "./type";
|
||||
import zh from "./zh";
|
||||
import en from "./en";
|
||||
import { HonoCustomType } from "../types";
|
||||
import { Context } from "hono";
|
||||
|
||||
export default {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Context } from "hono";
|
||||
import { getBooleanValue } from "../utils";
|
||||
import { HonoCustomType } from "../types";
|
||||
|
||||
|
||||
export default {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Hono } from 'hono'
|
||||
|
||||
import i18n from '../i18n';
|
||||
import { HonoCustomType } from "../types";
|
||||
import { getBooleanValue, getJsonSetting, checkCfTurnstile, getStringValue, getSplitStringListValue } from '../utils';
|
||||
import { newAddress, handleListQuery, deleteAddressWithData, getAddressPrefix, getAllowDomains } from '../common'
|
||||
import { CONSTANTS } from '../constants'
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { HonoCustomType } from "../types";
|
||||
import { Context } from "hono";
|
||||
import {
|
||||
S3Client,
|
||||
|
||||
@@ -9,7 +9,6 @@ import { CONSTANTS } from '../constants'
|
||||
import { getJsonSetting, getDomains, getIntValue, getBooleanValue, getStringValue, getJsonObjectValue, getSplitStringListValue } from '../utils';
|
||||
import { GeoData } from '../models'
|
||||
import { handleListQuery } from '../common'
|
||||
import { HonoCustomType } from '../types';
|
||||
|
||||
|
||||
export const api = new Hono<HonoCustomType>()
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { Context } from "hono";
|
||||
import { HonoCustomType, ParsedEmailContext } from "../types";
|
||||
import { CONSTANTS } from "../constants";
|
||||
import { AdminWebhookSettings, WebhookSettings } from "../models";
|
||||
import { getBooleanValue } from "../utils";
|
||||
import { commonParseMail, sendWebhook } from "../common";
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import { cleanup } from './common'
|
||||
import { CONSTANTS } from './constants'
|
||||
import { getJsonSetting } from './utils';
|
||||
import { CleanupSettings } from './models';
|
||||
import { Bindings, HonoCustomType } from './types';
|
||||
|
||||
export async function scheduled(event: ScheduledEvent, env: Bindings, ctx: any) {
|
||||
console.log("Scheduled event: ", event);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Context } from "hono";
|
||||
import { Jwt } from "hono/utils/jwt";
|
||||
import { CONSTANTS } from "../constants";
|
||||
import { HonoCustomType } from "../types";
|
||||
import { getIntValue, getJsonSetting } from "../utils";
|
||||
import { deleteAddressWithData, newAddress } from "../common";
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Hono } from 'hono'
|
||||
import { ServerResponse } from 'node:http'
|
||||
import { Writable } from 'node:stream'
|
||||
|
||||
import { HonoCustomType } from '../types'
|
||||
import { newTelegramBot, initTelegramBotCommands, sendMailToTelegram } from './telegram'
|
||||
import settings from './settings'
|
||||
import miniapp from './miniapp'
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Context } from "hono";
|
||||
import { Jwt } from 'hono/utils/jwt'
|
||||
import { HonoCustomType } from "../types";
|
||||
import { CONSTANTS } from "../constants";
|
||||
import { bindTelegramAddress, jwtListToAddressData, tgUserNewAddress, unbindTelegramAddress } from "./common";
|
||||
import { checkCfTurnstile } from "../utils";
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Context } from "hono";
|
||||
import { HonoCustomType } from "../types";
|
||||
import { CONSTANTS } from "../constants";
|
||||
|
||||
export class TelegramSettings {
|
||||
|
||||
@@ -5,7 +5,6 @@ import { callbackQuery } from "telegraf/filters";
|
||||
|
||||
import { CONSTANTS } from "../constants";
|
||||
import { getDomains, getJsonObjectValue, getStringValue } from '../utils';
|
||||
import { HonoCustomType, ParsedEmailContext } from "../types";
|
||||
import { TelegramSettings } from "./settings";
|
||||
import { bindTelegramAddress, deleteTelegramAddress, jwtListToAddressData, tgUserNewAddress, unbindTelegramAddress, unbindTelegramByAddress } from "./common";
|
||||
import { commonParseMail } from "../common";
|
||||
|
||||
17
worker/src/types.d.ts
vendored
17
worker/src/types.d.ts
vendored
@@ -1,15 +1,10 @@
|
||||
export type UserRole = {
|
||||
type UserRole = {
|
||||
domains: string[] | undefined | null,
|
||||
role: string,
|
||||
prefix: string | undefined | null
|
||||
}
|
||||
|
||||
export type SubdomainForwardAddressList = {
|
||||
domains: string[] | undefined | null,
|
||||
forward: string
|
||||
}
|
||||
|
||||
export type Bindings = {
|
||||
type Bindings = {
|
||||
// bindings
|
||||
DB: D1Database
|
||||
KV: KVNamespace
|
||||
@@ -49,7 +44,6 @@ export type Bindings = {
|
||||
COPYRIGHT: string | undefined
|
||||
DISABLE_SHOW_GITHUB: string | boolean | undefined
|
||||
FORWARD_ADDRESS_LIST: string | string[] | undefined
|
||||
SUBDOMAIN_FORWARD_ADDRESS_LIST: string | SubdomainForwardAddressList[] | undefined
|
||||
|
||||
ENABLE_CHECK_JUNK_MAIL: string | boolean | undefined
|
||||
JUNK_MAIL_CHECK_LIST: string | string[] | undefined
|
||||
@@ -58,6 +52,8 @@ export type Bindings = {
|
||||
ENABLE_ANOTHER_WORKER: string | boolean | undefined
|
||||
ANOTHER_WORKER_LIST: string | AnotherWorker[] | undefined
|
||||
|
||||
SUBDOMAIN_FORWARD_ADDRESS_LIST: string | SubdomainForwardAddressList[] | undefined
|
||||
|
||||
REMOVE_ALL_ATTACHMENT: string | boolean | undefined
|
||||
REMOVE_EXCEED_SIZE_ATTACHMENT: string | boolean | undefined
|
||||
|
||||
@@ -135,3 +131,8 @@ type ParsedEmailContext = {
|
||||
headers?: Record<string, string>[]
|
||||
} | undefined
|
||||
}
|
||||
|
||||
type SubdomainForwardAddressList = {
|
||||
domains: string[] | undefined | null,
|
||||
forward: string,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Context } from 'hono';
|
||||
import { Jwt } from 'hono/utils/jwt'
|
||||
|
||||
import { HonoCustomType } from '../types';
|
||||
import { UserSettings } from "../models";
|
||||
import { getJsonSetting } from "../utils"
|
||||
import { CONSTANTS } from "../constants";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Hono } from 'hono';
|
||||
|
||||
import { HonoCustomType } from '../types';
|
||||
import settings from './settings';
|
||||
import user from './user';
|
||||
import bind_address from './bind_address';
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Context } from 'hono';
|
||||
import { Jwt } from 'hono/utils/jwt'
|
||||
|
||||
import i18n from '../i18n';
|
||||
import { HonoCustomType } from '../types';
|
||||
import { getJsonSetting } from '../utils';
|
||||
import { UserOauth2Settings } from '../models';
|
||||
import { CONSTANTS } from '../constants';
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
verifyAuthenticationResponse
|
||||
} from '@simplewebauthn/server';
|
||||
|
||||
import { HonoCustomType } from '../types';
|
||||
import { Passkey } from '../models';
|
||||
import { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types';
|
||||
import { isoBase64URL } from '@simplewebauthn/server/helpers';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Context } from "hono";
|
||||
|
||||
import i18n from "../i18n";
|
||||
import { HonoCustomType } from "../types";
|
||||
import { UserOauth2Settings, UserSettings } from "../models";
|
||||
import { getJsonSetting, getUserRoles } from "../utils"
|
||||
import { CONSTANTS } from "../constants";
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Context } from 'hono';
|
||||
import { Jwt } from 'hono/utils/jwt'
|
||||
|
||||
import i18n from '../i18n';
|
||||
import { HonoCustomType } from '../types';
|
||||
import { checkCfTurnstile, getJsonSetting, checkUserPassword, getUserRoles, getStringValue } from "../utils"
|
||||
import { CONSTANTS } from "../constants";
|
||||
import { GeoData, UserInfo, UserSettings } from "../models";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Context } from "hono";
|
||||
import { handleListQuery } from "../common";
|
||||
import { HonoCustomType } from "../types";
|
||||
import UserBindAddressModule from "./bind_address";
|
||||
|
||||
export default {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Context } from "hono";
|
||||
import { createMimeMessage } from "mimetext";
|
||||
import { HonoCustomType, UserRole, SubdomainForwardAddressList, AnotherWorker } from "./types";
|
||||
|
||||
export const getJsonObjectValue = <T = any>(
|
||||
value: string | any
|
||||
@@ -165,22 +164,6 @@ export const getUserRoles = (c: Context<HonoCustomType>): UserRole[] => {
|
||||
return c.env.USER_ROLES;
|
||||
}
|
||||
|
||||
export const getSubdomainForwardAddressList = (c: Context<HonoCustomType>): SubdomainForwardAddressList[] => {
|
||||
if (!c.env.SUBDOMAIN_FORWARD_ADDRESS_LIST) {
|
||||
return [];
|
||||
}
|
||||
// check if SUBDOMAIN_FORWARD_ADDRESS_LIST is an array, if not use json.parse
|
||||
if (!Array.isArray(c.env.SUBDOMAIN_FORWARD_ADDRESS_LIST)) {
|
||||
try {
|
||||
return JSON.parse(c.env.SUBDOMAIN_FORWARD_ADDRESS_LIST);
|
||||
} catch (e) {
|
||||
console.error("Failed to parse SUBDOMAIN_FORWARD_ADDRESS_LIST", e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
return c.env.SUBDOMAIN_FORWARD_ADDRESS_LIST;
|
||||
}
|
||||
|
||||
export const getAnotherWorkerList = (c: Context<HonoCustomType>): AnotherWorker[] => {
|
||||
if (!c.env.ANOTHER_WORKER_LIST) {
|
||||
return [];
|
||||
@@ -312,3 +295,27 @@ export const checkUserPassword = (password: string) => {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export default {
|
||||
getJsonObjectValue,
|
||||
getSetting,
|
||||
saveSetting,
|
||||
getStringValue,
|
||||
getSplitStringListValue,
|
||||
getBooleanValue,
|
||||
getIntValue,
|
||||
getStringArray,
|
||||
getDefaultDomains,
|
||||
getDomains,
|
||||
getUserRoles,
|
||||
getAnotherWorkerList,
|
||||
getPasswords,
|
||||
getAdminPasswords,
|
||||
getEnvStringList,
|
||||
sendAdminInternalMail,
|
||||
checkCfTurnstile,
|
||||
checkUserPassword,
|
||||
getJsonSetting,
|
||||
getJsonValue: getJsonObjectValue,
|
||||
getStringList: getStringArray
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import i18n from './i18n';
|
||||
import { email } from './email';
|
||||
import { scheduled } from './scheduled';
|
||||
import { getAdminPasswords, getPasswords, getBooleanValue, getStringArray } from './utils';
|
||||
import { HonoCustomType, UserPayload } from './types';
|
||||
|
||||
const API_PATHS = [
|
||||
"/api/",
|
||||
|
||||
Reference in New Issue
Block a user