@mesob/auth-hono 0.1.1 → 0.2.0
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.
- package/README.md +1 -1
- package/dist/{index-CScADcDn.d.ts → index-DCxsFKQ2.d.ts} +7 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +540 -379
- package/dist/index.js.map +1 -1
- package/dist/lib/cookie.d.ts +1 -1
- package/dist/lib/error-handler.d.ts +5 -0
- package/dist/lib/error-handler.js +99 -0
- package/dist/lib/error-handler.js.map +1 -0
- package/dist/lib/normalize-user.d.ts +1 -1
- package/dist/lib/openapi-config.d.ts +1 -1
- package/dist/lib/openapi-config.js +6 -1
- package/dist/lib/openapi-config.js.map +1 -1
- package/dist/lib/phone-validation.d.ts +15 -0
- package/dist/lib/phone-validation.js +15 -0
- package/dist/lib/phone-validation.js.map +1 -0
- package/dist/lib/session.d.ts +1 -1
- package/dist/lib/tenant.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -430,7 +430,7 @@ var createDatabase = (connectionString) => {
|
|
|
430
430
|
};
|
|
431
431
|
|
|
432
432
|
// src/handler.ts
|
|
433
|
-
import { OpenAPIHono as
|
|
433
|
+
import { OpenAPIHono as OpenAPIHono17 } from "@hono/zod-openapi";
|
|
434
434
|
import { getCookie as getCookie3 } from "hono/cookie";
|
|
435
435
|
|
|
436
436
|
// src/db/orm/session.ts
|
|
@@ -691,8 +691,104 @@ var hashToken = async (token, secret) => {
|
|
|
691
691
|
};
|
|
692
692
|
var generateToken = (bytes = 48) => randomHex(bytes);
|
|
693
693
|
|
|
694
|
+
// src/lib/error-handler.ts
|
|
695
|
+
import { logger } from "@mesob/common";
|
|
696
|
+
import { HTTPException } from "hono/http-exception";
|
|
697
|
+
var isDatabaseError = (error) => {
|
|
698
|
+
if (typeof error !== "object" || error === null) {
|
|
699
|
+
return false;
|
|
700
|
+
}
|
|
701
|
+
if ("code" in error || "query" in error || "detail" in error) {
|
|
702
|
+
return true;
|
|
703
|
+
}
|
|
704
|
+
if (error instanceof Error) {
|
|
705
|
+
const message = error.message.toLowerCase();
|
|
706
|
+
return message.includes("failed query") || message.includes("relation") || message.includes("column") || message.includes("syntax error") || message.includes("duplicate key") || message.includes("foreign key") || message.includes("null value");
|
|
707
|
+
}
|
|
708
|
+
return false;
|
|
709
|
+
};
|
|
710
|
+
var sanitizeDatabaseError = (error) => {
|
|
711
|
+
const code = error.code;
|
|
712
|
+
if (code === "23505") {
|
|
713
|
+
return "Resource already exists";
|
|
714
|
+
}
|
|
715
|
+
if (code === "23503") {
|
|
716
|
+
return "Referenced resource not found";
|
|
717
|
+
}
|
|
718
|
+
if (code === "23502") {
|
|
719
|
+
return "Required field is missing";
|
|
720
|
+
}
|
|
721
|
+
if (code === "42P01") {
|
|
722
|
+
return "Resource not found";
|
|
723
|
+
}
|
|
724
|
+
if (code === "42703") {
|
|
725
|
+
return "Invalid request";
|
|
726
|
+
}
|
|
727
|
+
if (code === "23514") {
|
|
728
|
+
return "Validation failed";
|
|
729
|
+
}
|
|
730
|
+
return "An error occurred while processing your request";
|
|
731
|
+
};
|
|
732
|
+
var isDatabaseErrorMessage = (message) => {
|
|
733
|
+
const lowerMessage = message.toLowerCase();
|
|
734
|
+
return lowerMessage.includes("failed query") || lowerMessage.includes("select") || lowerMessage.includes("insert") || lowerMessage.includes("update") || lowerMessage.includes("delete") || lowerMessage.includes("from") || lowerMessage.includes("where") || lowerMessage.includes("limit") || lowerMessage.includes("params:") || lowerMessage.includes("query") || message.includes('"iam".') || message.includes('"tenants"') || message.includes('"users"') || message.includes('"sessions"') || message.includes('"accounts"') || lowerMessage.includes("relation") || lowerMessage.includes("column") || lowerMessage.includes("syntax error") || lowerMessage.includes("database") || lowerMessage.includes("postgres") || lowerMessage.includes("sql");
|
|
735
|
+
};
|
|
736
|
+
var handleError = (error, c) => {
|
|
737
|
+
logger.error("API Error:", {
|
|
738
|
+
error,
|
|
739
|
+
path: c.req.path,
|
|
740
|
+
method: c.req.method,
|
|
741
|
+
url: c.req.url
|
|
742
|
+
});
|
|
743
|
+
if (error instanceof HTTPException) {
|
|
744
|
+
const message = isDatabaseErrorMessage(error.message) ? "An error occurred while processing your request" : error.message;
|
|
745
|
+
return c.json({ error: message }, error.status);
|
|
746
|
+
}
|
|
747
|
+
if (isDatabaseError(error)) {
|
|
748
|
+
const userMessage = sanitizeDatabaseError(error);
|
|
749
|
+
logger.error("Database error details:", {
|
|
750
|
+
code: error.code,
|
|
751
|
+
message: error.message,
|
|
752
|
+
detail: error.detail,
|
|
753
|
+
query: error.query,
|
|
754
|
+
parameters: error.parameters
|
|
755
|
+
});
|
|
756
|
+
return c.json({ error: userMessage }, 500);
|
|
757
|
+
}
|
|
758
|
+
if (error instanceof Error) {
|
|
759
|
+
const message = error.message;
|
|
760
|
+
const lowerMessage = message.toLowerCase();
|
|
761
|
+
const isDatabaseError2 = lowerMessage.includes("failed query") || lowerMessage.includes("select") || lowerMessage.includes("insert") || lowerMessage.includes("update") || lowerMessage.includes("delete") || lowerMessage.includes("from") || lowerMessage.includes("where") || lowerMessage.includes("limit") || lowerMessage.includes("params:") || lowerMessage.includes("query") || message.includes('"iam".') || message.includes('"tenants"') || message.includes('"users"') || message.includes('"sessions"') || message.includes('"accounts"') || lowerMessage.includes("relation") || lowerMessage.includes("column") || lowerMessage.includes("syntax error") || lowerMessage.includes("duplicate key") || lowerMessage.includes("foreign key") || lowerMessage.includes("null value") || lowerMessage.includes("database") || lowerMessage.includes("postgres") || lowerMessage.includes("sql");
|
|
762
|
+
if (isDatabaseError2) {
|
|
763
|
+
logger.error("SQL/database error detected:", {
|
|
764
|
+
message: error.message,
|
|
765
|
+
stack: error.stack,
|
|
766
|
+
name: error.name
|
|
767
|
+
});
|
|
768
|
+
return c.json(
|
|
769
|
+
{ error: "An error occurred while processing your request" },
|
|
770
|
+
500
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
logger.error("Error details:", {
|
|
774
|
+
message: error.message,
|
|
775
|
+
stack: error.stack,
|
|
776
|
+
name: error.name
|
|
777
|
+
});
|
|
778
|
+
return c.json(
|
|
779
|
+
{ error: "An error occurred while processing your request" },
|
|
780
|
+
500
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
logger.error("Unknown error:", error);
|
|
784
|
+
return c.json(
|
|
785
|
+
{ error: "An error occurred while processing your request" },
|
|
786
|
+
500
|
|
787
|
+
);
|
|
788
|
+
};
|
|
789
|
+
|
|
694
790
|
// src/routes/index.ts
|
|
695
|
-
import { OpenAPIHono as
|
|
791
|
+
import { OpenAPIHono as OpenAPIHono16 } from "@hono/zod-openapi";
|
|
696
792
|
|
|
697
793
|
// src/routes/auth/auth.route.ts
|
|
698
794
|
import { createRoute, OpenAPIHono } from "@hono/zod-openapi";
|
|
@@ -804,11 +900,12 @@ var verifyPasswordSchema = z.object({
|
|
|
804
900
|
var messageWithVerificationIdSchema = messageSchema.extend({
|
|
805
901
|
verificationId: z.string().uuid().optional()
|
|
806
902
|
});
|
|
807
|
-
var
|
|
808
|
-
|
|
903
|
+
var checkAccountSchema = z.object({
|
|
904
|
+
username: z.string()
|
|
809
905
|
});
|
|
810
|
-
var
|
|
811
|
-
exists: z.boolean()
|
|
906
|
+
var checkAccountResponseSchema = z.object({
|
|
907
|
+
exists: z.boolean(),
|
|
908
|
+
verified: z.boolean()
|
|
812
909
|
});
|
|
813
910
|
var updateProfileSchema = z.object({
|
|
814
911
|
fullName: z.string().min(1).max(255).optional().describe("User full name")
|
|
@@ -833,131 +930,55 @@ var pendingAccountChangeResponseSchema = z.object({
|
|
|
833
930
|
verificationId: z.string().uuid().nullable()
|
|
834
931
|
});
|
|
835
932
|
|
|
836
|
-
// src/routes/auth/handler/check-
|
|
933
|
+
// src/routes/auth/handler/check-account.ts
|
|
837
934
|
import { and as and4, eq as eq4, sql as sql4 } from "drizzle-orm";
|
|
838
935
|
|
|
839
936
|
// src/lib/tenant.ts
|
|
840
|
-
import { HTTPException } from "hono/http-exception";
|
|
937
|
+
import { HTTPException as HTTPException2 } from "hono/http-exception";
|
|
841
938
|
var ensureTenantId = (config, tenantId) => {
|
|
842
939
|
const enableTenant = config.tenant?.enabled ?? true;
|
|
843
940
|
if (enableTenant) {
|
|
844
941
|
if (!tenantId) {
|
|
845
|
-
throw new
|
|
942
|
+
throw new HTTPException2(400, {
|
|
846
943
|
message: "Missing tenantId. Tenant isolation is enabled."
|
|
847
944
|
});
|
|
848
945
|
}
|
|
849
946
|
return tenantId;
|
|
850
947
|
}
|
|
851
948
|
if (!config.tenant?.tenantId) {
|
|
852
|
-
throw new
|
|
949
|
+
throw new HTTPException2(500, {
|
|
853
950
|
message: "tenantId must be provided in config.tenant when tenant.enabled is false."
|
|
854
951
|
});
|
|
855
952
|
}
|
|
856
953
|
return config.tenant.tenantId;
|
|
857
954
|
};
|
|
858
955
|
|
|
859
|
-
// src/routes/auth/handler/check-
|
|
860
|
-
var
|
|
956
|
+
// src/routes/auth/handler/check-account.ts
|
|
957
|
+
var checkAccountHandler = async (c) => {
|
|
861
958
|
const body = c.req.valid("json");
|
|
862
959
|
const config = c.get("config");
|
|
863
960
|
const database = c.get("database");
|
|
864
961
|
const tenantId = c.get("tenantId");
|
|
865
962
|
const resolvedTenantId = ensureTenantId(config, tenantId);
|
|
866
|
-
const {
|
|
867
|
-
const isEmail =
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
'id', ${userRolesInIam.id},
|
|
886
|
-
'roleId', ${rolesInIam.id},
|
|
887
|
-
'code', ${rolesInIam.code},
|
|
888
|
-
'name', ${rolesInIam.name},
|
|
889
|
-
'description', ${rolesInIam.description}
|
|
890
|
-
)
|
|
891
|
-
) FILTER (WHERE ${userRolesInIam.id} IS NOT NULL),
|
|
892
|
-
'[]'::json
|
|
893
|
-
)
|
|
894
|
-
`
|
|
895
|
-
}).from(usersInIam).leftJoin(
|
|
896
|
-
userRolesInIam,
|
|
897
|
-
and4(
|
|
898
|
-
eq4(userRolesInIam.userId, usersInIam.id),
|
|
899
|
-
eq4(userRolesInIam.tenantId, resolvedTenantId)
|
|
900
|
-
)
|
|
901
|
-
).leftJoin(
|
|
902
|
-
rolesInIam,
|
|
903
|
-
and4(
|
|
904
|
-
eq4(userRolesInIam.roleId, rolesInIam.id),
|
|
905
|
-
eq4(rolesInIam.tenantId, resolvedTenantId)
|
|
906
|
-
)
|
|
907
|
-
).where(
|
|
908
|
-
and4(
|
|
909
|
-
eq4(usersInIam.tenantId, resolvedTenantId),
|
|
910
|
-
sql4`lower(${usersInIam.email}) = lower(${identifier})`
|
|
911
|
-
)
|
|
912
|
-
).groupBy(usersInIam.id).limit(1);
|
|
913
|
-
user = result || null;
|
|
914
|
-
} else {
|
|
915
|
-
const [result] = await database.select({
|
|
916
|
-
id: usersInIam.id,
|
|
917
|
-
tenantId: usersInIam.tenantId,
|
|
918
|
-
fullName: usersInIam.fullName,
|
|
919
|
-
email: usersInIam.email,
|
|
920
|
-
phone: usersInIam.phone,
|
|
921
|
-
handle: usersInIam.handle,
|
|
922
|
-
image: usersInIam.image,
|
|
923
|
-
emailVerified: usersInIam.emailVerified,
|
|
924
|
-
phoneVerified: usersInIam.phoneVerified,
|
|
925
|
-
lastSignInAt: usersInIam.lastSignInAt,
|
|
926
|
-
userRoles: sql4`
|
|
927
|
-
COALESCE(
|
|
928
|
-
json_agg(
|
|
929
|
-
json_build_object(
|
|
930
|
-
'id', ${userRolesInIam.id},
|
|
931
|
-
'roleId', ${rolesInIam.id},
|
|
932
|
-
'code', ${rolesInIam.code},
|
|
933
|
-
'name', ${rolesInIam.name},
|
|
934
|
-
'description', ${rolesInIam.description}
|
|
935
|
-
)
|
|
936
|
-
) FILTER (WHERE ${userRolesInIam.id} IS NOT NULL),
|
|
937
|
-
'[]'::json
|
|
938
|
-
)
|
|
939
|
-
`
|
|
940
|
-
}).from(usersInIam).leftJoin(
|
|
941
|
-
userRolesInIam,
|
|
942
|
-
and4(
|
|
943
|
-
eq4(userRolesInIam.userId, usersInIam.id),
|
|
944
|
-
eq4(userRolesInIam.tenantId, resolvedTenantId)
|
|
945
|
-
)
|
|
946
|
-
).leftJoin(
|
|
947
|
-
rolesInIam,
|
|
948
|
-
and4(
|
|
949
|
-
eq4(userRolesInIam.roleId, rolesInIam.id),
|
|
950
|
-
eq4(rolesInIam.tenantId, resolvedTenantId)
|
|
951
|
-
)
|
|
952
|
-
).where(
|
|
953
|
-
and4(
|
|
954
|
-
eq4(usersInIam.tenantId, resolvedTenantId),
|
|
955
|
-
eq4(usersInIam.phone, identifier)
|
|
956
|
-
)
|
|
957
|
-
).groupBy(usersInIam.id).limit(1);
|
|
958
|
-
user = result || null;
|
|
959
|
-
}
|
|
960
|
-
return c.json({ exists: !!user }, 200);
|
|
963
|
+
const { username } = body;
|
|
964
|
+
const isEmail = username.includes("@");
|
|
965
|
+
const whereClause = isEmail ? and4(
|
|
966
|
+
eq4(usersInIam.tenantId, resolvedTenantId),
|
|
967
|
+
sql4`lower(${usersInIam.email}) = lower(${username})`
|
|
968
|
+
) : and4(
|
|
969
|
+
eq4(usersInIam.tenantId, resolvedTenantId),
|
|
970
|
+
eq4(usersInIam.phone, username)
|
|
971
|
+
);
|
|
972
|
+
const [result] = await database.select({
|
|
973
|
+
verified: isEmail ? usersInIam.emailVerified : usersInIam.phoneVerified
|
|
974
|
+
}).from(usersInIam).where(whereClause).limit(1);
|
|
975
|
+
return c.json(
|
|
976
|
+
{
|
|
977
|
+
exists: !!result,
|
|
978
|
+
verified: result?.verified ?? false
|
|
979
|
+
},
|
|
980
|
+
200
|
|
981
|
+
);
|
|
961
982
|
};
|
|
962
983
|
|
|
963
984
|
// src/routes/auth/handler/sign-in.ts
|
|
@@ -1688,6 +1709,18 @@ function withTransaction(database, callback) {
|
|
|
1688
1709
|
return database.transaction(async (tx) => callback(tx));
|
|
1689
1710
|
}
|
|
1690
1711
|
|
|
1712
|
+
// src/lib/phone-validation.ts
|
|
1713
|
+
var createPhoneField = (config) => {
|
|
1714
|
+
const phoneRegex = config.phone.phoneRegex || /^(\+2519|\+2517|2519|2517|09|07)\d{8}$/;
|
|
1715
|
+
const regex = typeof phoneRegex === "string" ? new RegExp(phoneRegex) : phoneRegex;
|
|
1716
|
+
return {
|
|
1717
|
+
validate: (phone) => {
|
|
1718
|
+
return regex.test(phone.trim());
|
|
1719
|
+
},
|
|
1720
|
+
regex
|
|
1721
|
+
};
|
|
1722
|
+
};
|
|
1723
|
+
|
|
1691
1724
|
// src/routes/auth/handler/sign-up.ts
|
|
1692
1725
|
var SignUpError = class extends Error {
|
|
1693
1726
|
constructor(message, status) {
|
|
@@ -1707,6 +1740,12 @@ var signUpHandler = async (c) => {
|
|
|
1707
1740
|
return c.json({ error: "Either email or phone is required" }, 409);
|
|
1708
1741
|
}
|
|
1709
1742
|
const isEmail = identifier.includes("@");
|
|
1743
|
+
if (phone) {
|
|
1744
|
+
const phoneValidator = createPhoneField(config);
|
|
1745
|
+
if (!phoneValidator.validate(phone)) {
|
|
1746
|
+
return c.json({ error: "Invalid phone number format" }, 400);
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1710
1749
|
if (isEmail && !config.email.enabled) {
|
|
1711
1750
|
return c.json({ error: "Email authentication is disabled" }, 403);
|
|
1712
1751
|
}
|
|
@@ -1871,6 +1910,14 @@ var signUpRoute = createRoute({
|
|
|
1871
1910
|
},
|
|
1872
1911
|
description: "Account created"
|
|
1873
1912
|
},
|
|
1913
|
+
400: {
|
|
1914
|
+
content: {
|
|
1915
|
+
"application/json": {
|
|
1916
|
+
schema: errorResponseSchema
|
|
1917
|
+
}
|
|
1918
|
+
},
|
|
1919
|
+
description: "Invalid request"
|
|
1920
|
+
},
|
|
1874
1921
|
403: {
|
|
1875
1922
|
content: {
|
|
1876
1923
|
"application/json": {
|
|
@@ -1922,16 +1969,16 @@ var signInRoute = createRoute({
|
|
|
1922
1969
|
}
|
|
1923
1970
|
}
|
|
1924
1971
|
});
|
|
1925
|
-
var
|
|
1972
|
+
var checkAccountRoute = createRoute({
|
|
1926
1973
|
method: "post",
|
|
1927
|
-
path: "/check-
|
|
1974
|
+
path: "/check-account",
|
|
1928
1975
|
tags: ["Auth"],
|
|
1929
|
-
summary: "Check if
|
|
1976
|
+
summary: "Check if account exists",
|
|
1930
1977
|
request: {
|
|
1931
1978
|
body: {
|
|
1932
1979
|
content: {
|
|
1933
1980
|
"application/json": {
|
|
1934
|
-
schema:
|
|
1981
|
+
schema: checkAccountSchema
|
|
1935
1982
|
}
|
|
1936
1983
|
}
|
|
1937
1984
|
}
|
|
@@ -1940,10 +1987,10 @@ var checkUserRoute = createRoute({
|
|
|
1940
1987
|
200: {
|
|
1941
1988
|
content: {
|
|
1942
1989
|
"application/json": {
|
|
1943
|
-
schema:
|
|
1990
|
+
schema: checkAccountResponseSchema
|
|
1944
1991
|
}
|
|
1945
1992
|
},
|
|
1946
|
-
description: "
|
|
1993
|
+
description: "Account check result"
|
|
1947
1994
|
}
|
|
1948
1995
|
}
|
|
1949
1996
|
});
|
|
@@ -1959,7 +2006,7 @@ var signOutRoute = createRoute({
|
|
|
1959
2006
|
}
|
|
1960
2007
|
}
|
|
1961
2008
|
});
|
|
1962
|
-
var authRoutes = new OpenAPIHono().openapi(signUpRoute, signUpHandler).openapi(signInRoute, signInHandler).openapi(
|
|
2009
|
+
var authRoutes = new OpenAPIHono().openapi(signUpRoute, signUpHandler).openapi(signInRoute, signInHandler).openapi(checkAccountRoute, checkAccountHandler).openapi(signOutRoute, signOutHandler);
|
|
1963
2010
|
var auth_route_default = authRoutes;
|
|
1964
2011
|
|
|
1965
2012
|
// src/routes/domains/domains.route.ts
|
|
@@ -3388,6 +3435,10 @@ var phoneVerificationRequestHandler = async (c) => {
|
|
|
3388
3435
|
if (!phone) {
|
|
3389
3436
|
return c.json({ error: "Phone required" }, 400);
|
|
3390
3437
|
}
|
|
3438
|
+
const phoneValidator = createPhoneField(config);
|
|
3439
|
+
if (!phoneValidator.validate(phone)) {
|
|
3440
|
+
return c.json({ error: "Invalid phone number format" }, 400);
|
|
3441
|
+
}
|
|
3391
3442
|
const genericResponse = {
|
|
3392
3443
|
message: "If the account exists, a verification code was sent."
|
|
3393
3444
|
};
|
|
@@ -3665,19 +3716,38 @@ var meHandler = (c) => {
|
|
|
3665
3716
|
var sessionHandler = (c) => {
|
|
3666
3717
|
const user = c.get("user");
|
|
3667
3718
|
const session = c.get("session");
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3719
|
+
const status = c.get("sessionStatus");
|
|
3720
|
+
if (status === "no_cookie") {
|
|
3721
|
+
return c.json({ user: null, session: null }, 200);
|
|
3722
|
+
}
|
|
3723
|
+
if (status === "invalid_session") {
|
|
3724
|
+
return c.json({ error: "Invalid session", code: "INVALID_SESSION" }, 401);
|
|
3725
|
+
}
|
|
3726
|
+
if (status === "user_not_found") {
|
|
3727
|
+
return c.json({ error: "User not found", code: "USER_NOT_FOUND" }, 401);
|
|
3728
|
+
}
|
|
3729
|
+
if (status === "error") {
|
|
3730
|
+
return c.json(
|
|
3731
|
+
{ error: "Session check error", code: "SESSION_CHECK_ERROR" },
|
|
3732
|
+
500
|
|
3733
|
+
);
|
|
3734
|
+
}
|
|
3735
|
+
if (user && session) {
|
|
3736
|
+
return c.json(
|
|
3737
|
+
{
|
|
3738
|
+
user: normalizeUser(user),
|
|
3739
|
+
session: {
|
|
3740
|
+
id: session.id,
|
|
3741
|
+
expiresAt: session.expiresAt,
|
|
3742
|
+
createdAt: session.createdAt,
|
|
3743
|
+
userAgent: session.userAgent,
|
|
3744
|
+
ip: session.ip
|
|
3745
|
+
}
|
|
3746
|
+
},
|
|
3747
|
+
200
|
|
3748
|
+
);
|
|
3749
|
+
}
|
|
3750
|
+
return c.json({ user: null, session: null }, 200);
|
|
3681
3751
|
};
|
|
3682
3752
|
|
|
3683
3753
|
// src/routes/profile/handler/update.ts
|
|
@@ -3805,6 +3875,10 @@ var updatePhoneHandler = async (c) => {
|
|
|
3805
3875
|
return c.json({ error: AUTH_ERRORS.UNAUTHORIZED }, 401);
|
|
3806
3876
|
}
|
|
3807
3877
|
const resolvedTenantId = ensureTenantId(config, tenantId);
|
|
3878
|
+
const phoneValidator = createPhoneField(config);
|
|
3879
|
+
if (!phoneValidator.validate(body.phone)) {
|
|
3880
|
+
return c.json({ error: "Invalid phone number format" }, 400);
|
|
3881
|
+
}
|
|
3808
3882
|
if (user.phone && session?.id) {
|
|
3809
3883
|
await database.delete(sessionsInIam).where(
|
|
3810
3884
|
and27(
|
|
@@ -3899,7 +3973,23 @@ var sessionRoute = createRoute7({
|
|
|
3899
3973
|
})
|
|
3900
3974
|
}
|
|
3901
3975
|
},
|
|
3902
|
-
description: "
|
|
3976
|
+
description: "Session info (null if no cookie sent)"
|
|
3977
|
+
},
|
|
3978
|
+
401: {
|
|
3979
|
+
content: {
|
|
3980
|
+
"application/json": {
|
|
3981
|
+
schema: errorResponseSchema
|
|
3982
|
+
}
|
|
3983
|
+
},
|
|
3984
|
+
description: "Invalid session (cookie sent but invalid/expired)"
|
|
3985
|
+
},
|
|
3986
|
+
500: {
|
|
3987
|
+
content: {
|
|
3988
|
+
"application/json": {
|
|
3989
|
+
schema: errorResponseSchema
|
|
3990
|
+
}
|
|
3991
|
+
},
|
|
3992
|
+
description: "Server error checking session"
|
|
3903
3993
|
}
|
|
3904
3994
|
}
|
|
3905
3995
|
});
|
|
@@ -4008,6 +4098,14 @@ var updatePhoneRoute = createRoute7({
|
|
|
4008
4098
|
},
|
|
4009
4099
|
description: "Phone updated"
|
|
4010
4100
|
},
|
|
4101
|
+
400: {
|
|
4102
|
+
content: {
|
|
4103
|
+
"application/json": {
|
|
4104
|
+
schema: errorResponseSchema
|
|
4105
|
+
}
|
|
4106
|
+
},
|
|
4107
|
+
description: "Invalid request"
|
|
4108
|
+
},
|
|
4011
4109
|
401: {
|
|
4012
4110
|
content: {
|
|
4013
4111
|
"application/json": {
|
|
@@ -4716,8 +4814,69 @@ var revokeAllSessionsRoute = createRoute10({
|
|
|
4716
4814
|
var sessionRoutes = new OpenAPIHono10().openapi(listSessionsRoute, listSessionsHandler).openapi(getSessionRoute, getSessionHandler).openapi(revokeSessionRoute, revokeSessionHandler).openapi(revokeAllSessionsRoute, revokeAllSessionsHandler);
|
|
4717
4815
|
var sessions_route_default = sessionRoutes;
|
|
4718
4816
|
|
|
4719
|
-
// src/routes/
|
|
4817
|
+
// src/routes/system/system.route.ts
|
|
4720
4818
|
import { createRoute as createRoute11, OpenAPIHono as OpenAPIHono11 } from "@hono/zod-openapi";
|
|
4819
|
+
import { z as z8 } from "zod";
|
|
4820
|
+
|
|
4821
|
+
// src/routes/system/handler/tenant.ts
|
|
4822
|
+
var tenantHandler = (c) => {
|
|
4823
|
+
const tenantId = c.get("tenantId");
|
|
4824
|
+
const tenant = c.get("tenant");
|
|
4825
|
+
const host = c.get("host");
|
|
4826
|
+
return c.json(
|
|
4827
|
+
{
|
|
4828
|
+
host: host || null,
|
|
4829
|
+
tenantId: tenantId || null,
|
|
4830
|
+
tenant: tenant || null,
|
|
4831
|
+
status: "ok"
|
|
4832
|
+
},
|
|
4833
|
+
200
|
|
4834
|
+
);
|
|
4835
|
+
};
|
|
4836
|
+
|
|
4837
|
+
// src/routes/system/system.route.ts
|
|
4838
|
+
var tenantRoute = createRoute11({
|
|
4839
|
+
method: "get",
|
|
4840
|
+
path: "/init",
|
|
4841
|
+
tags: ["System"],
|
|
4842
|
+
summary: "Get tenant info",
|
|
4843
|
+
responses: {
|
|
4844
|
+
200: {
|
|
4845
|
+
content: {
|
|
4846
|
+
"application/json": {
|
|
4847
|
+
schema: z8.object({
|
|
4848
|
+
host: z8.string().nullable(),
|
|
4849
|
+
tenantId: z8.string().nullable(),
|
|
4850
|
+
tenant: z8.object({
|
|
4851
|
+
id: z8.string(),
|
|
4852
|
+
name: z8.unknown(),
|
|
4853
|
+
description: z8.unknown(),
|
|
4854
|
+
isActive: z8.boolean()
|
|
4855
|
+
}).nullable(),
|
|
4856
|
+
status: z8.literal("ok")
|
|
4857
|
+
})
|
|
4858
|
+
}
|
|
4859
|
+
},
|
|
4860
|
+
description: "Tenant info"
|
|
4861
|
+
},
|
|
4862
|
+
500: {
|
|
4863
|
+
content: {
|
|
4864
|
+
"application/json": {
|
|
4865
|
+
schema: errorResponseSchema
|
|
4866
|
+
}
|
|
4867
|
+
},
|
|
4868
|
+
description: "Server error"
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4871
|
+
});
|
|
4872
|
+
var tenantRoutes = new OpenAPIHono11().openapi(
|
|
4873
|
+
tenantRoute,
|
|
4874
|
+
tenantHandler
|
|
4875
|
+
);
|
|
4876
|
+
var system_route_default = tenantRoutes;
|
|
4877
|
+
|
|
4878
|
+
// src/routes/tenants/tenants.route.ts
|
|
4879
|
+
import { createRoute as createRoute12, OpenAPIHono as OpenAPIHono12 } from "@hono/zod-openapi";
|
|
4721
4880
|
|
|
4722
4881
|
// src/routes/tenants/handler/create-tenant.ts
|
|
4723
4882
|
import { eq as eq38 } from "drizzle-orm";
|
|
@@ -4849,79 +5008,79 @@ var updateTenantHandler = async (c) => {
|
|
|
4849
5008
|
};
|
|
4850
5009
|
|
|
4851
5010
|
// src/routes/tenants/tenants.schema.ts
|
|
4852
|
-
import { z as
|
|
4853
|
-
var listTenantsQuerySchema =
|
|
4854
|
-
page:
|
|
4855
|
-
limit:
|
|
4856
|
-
isActive:
|
|
4857
|
-
});
|
|
4858
|
-
var tenantIdParamSchema =
|
|
4859
|
-
id:
|
|
4860
|
-
});
|
|
4861
|
-
var createTenantSchema =
|
|
4862
|
-
id:
|
|
4863
|
-
name:
|
|
4864
|
-
description:
|
|
4865
|
-
theme:
|
|
4866
|
-
supportedLanguages:
|
|
4867
|
-
defaultLanguage:
|
|
4868
|
-
supportedCurrency:
|
|
4869
|
-
defaultCurrency:
|
|
4870
|
-
timezone:
|
|
4871
|
-
isActive:
|
|
4872
|
-
locale:
|
|
4873
|
-
settings:
|
|
4874
|
-
seo:
|
|
4875
|
-
});
|
|
4876
|
-
var updateTenantSchema =
|
|
4877
|
-
name:
|
|
4878
|
-
description:
|
|
4879
|
-
theme:
|
|
4880
|
-
supportedLanguages:
|
|
4881
|
-
defaultLanguage:
|
|
4882
|
-
supportedCurrency:
|
|
4883
|
-
defaultCurrency:
|
|
4884
|
-
timezone:
|
|
4885
|
-
isActive:
|
|
4886
|
-
locale:
|
|
4887
|
-
settings:
|
|
4888
|
-
seo:
|
|
4889
|
-
});
|
|
4890
|
-
var tenantSchema =
|
|
4891
|
-
id:
|
|
4892
|
-
createdAt:
|
|
4893
|
-
updatedAt:
|
|
4894
|
-
name:
|
|
4895
|
-
description:
|
|
4896
|
-
theme:
|
|
4897
|
-
supportedLanguages:
|
|
4898
|
-
defaultLanguage:
|
|
4899
|
-
supportedCurrency:
|
|
4900
|
-
defaultCurrency:
|
|
4901
|
-
timezone:
|
|
4902
|
-
isActive:
|
|
4903
|
-
locale:
|
|
4904
|
-
settings:
|
|
4905
|
-
seo:
|
|
4906
|
-
});
|
|
4907
|
-
var listTenantsResponseSchema =
|
|
4908
|
-
tenants:
|
|
4909
|
-
total:
|
|
4910
|
-
page:
|
|
4911
|
-
limit:
|
|
4912
|
-
});
|
|
4913
|
-
var tenantResponseSchema =
|
|
5011
|
+
import { z as z9 } from "zod";
|
|
5012
|
+
var listTenantsQuerySchema = z9.object({
|
|
5013
|
+
page: z9.coerce.number().min(1).default(1).optional(),
|
|
5014
|
+
limit: z9.coerce.number().min(1).max(100).default(20).optional(),
|
|
5015
|
+
isActive: z9.coerce.boolean().optional()
|
|
5016
|
+
});
|
|
5017
|
+
var tenantIdParamSchema = z9.object({
|
|
5018
|
+
id: z9.string()
|
|
5019
|
+
});
|
|
5020
|
+
var createTenantSchema = z9.object({
|
|
5021
|
+
id: z9.string().max(30),
|
|
5022
|
+
name: z9.unknown(),
|
|
5023
|
+
description: z9.unknown().optional(),
|
|
5024
|
+
theme: z9.unknown().optional(),
|
|
5025
|
+
supportedLanguages: z9.unknown().optional(),
|
|
5026
|
+
defaultLanguage: z9.string().optional(),
|
|
5027
|
+
supportedCurrency: z9.unknown().optional(),
|
|
5028
|
+
defaultCurrency: z9.string().optional(),
|
|
5029
|
+
timezone: z9.string().optional(),
|
|
5030
|
+
isActive: z9.boolean().default(true).optional(),
|
|
5031
|
+
locale: z9.unknown().optional(),
|
|
5032
|
+
settings: z9.unknown().optional(),
|
|
5033
|
+
seo: z9.unknown().optional()
|
|
5034
|
+
});
|
|
5035
|
+
var updateTenantSchema = z9.object({
|
|
5036
|
+
name: z9.unknown().optional(),
|
|
5037
|
+
description: z9.unknown().nullable().optional(),
|
|
5038
|
+
theme: z9.unknown().nullable().optional(),
|
|
5039
|
+
supportedLanguages: z9.unknown().nullable().optional(),
|
|
5040
|
+
defaultLanguage: z9.string().nullable().optional(),
|
|
5041
|
+
supportedCurrency: z9.unknown().nullable().optional(),
|
|
5042
|
+
defaultCurrency: z9.string().nullable().optional(),
|
|
5043
|
+
timezone: z9.string().nullable().optional(),
|
|
5044
|
+
isActive: z9.boolean().optional(),
|
|
5045
|
+
locale: z9.unknown().nullable().optional(),
|
|
5046
|
+
settings: z9.unknown().nullable().optional(),
|
|
5047
|
+
seo: z9.unknown().nullable().optional()
|
|
5048
|
+
});
|
|
5049
|
+
var tenantSchema = z9.object({
|
|
5050
|
+
id: z9.string(),
|
|
5051
|
+
createdAt: z9.string(),
|
|
5052
|
+
updatedAt: z9.string(),
|
|
5053
|
+
name: z9.unknown(),
|
|
5054
|
+
description: z9.unknown().nullable(),
|
|
5055
|
+
theme: z9.unknown().nullable(),
|
|
5056
|
+
supportedLanguages: z9.unknown().nullable(),
|
|
5057
|
+
defaultLanguage: z9.string().nullable(),
|
|
5058
|
+
supportedCurrency: z9.unknown().nullable(),
|
|
5059
|
+
defaultCurrency: z9.string().nullable(),
|
|
5060
|
+
timezone: z9.string().nullable(),
|
|
5061
|
+
isActive: z9.boolean(),
|
|
5062
|
+
locale: z9.unknown().nullable(),
|
|
5063
|
+
settings: z9.unknown().nullable(),
|
|
5064
|
+
seo: z9.unknown().nullable()
|
|
5065
|
+
});
|
|
5066
|
+
var listTenantsResponseSchema = z9.object({
|
|
5067
|
+
tenants: z9.array(tenantSchema),
|
|
5068
|
+
total: z9.number(),
|
|
5069
|
+
page: z9.number(),
|
|
5070
|
+
limit: z9.number()
|
|
5071
|
+
});
|
|
5072
|
+
var tenantResponseSchema = z9.object({
|
|
4914
5073
|
tenant: tenantSchema
|
|
4915
5074
|
});
|
|
4916
|
-
var deleteTenantResponseSchema =
|
|
4917
|
-
message:
|
|
5075
|
+
var deleteTenantResponseSchema = z9.object({
|
|
5076
|
+
message: z9.string()
|
|
4918
5077
|
});
|
|
4919
|
-
var errorResponseSchema7 =
|
|
4920
|
-
error:
|
|
5078
|
+
var errorResponseSchema7 = z9.object({
|
|
5079
|
+
error: z9.string()
|
|
4921
5080
|
});
|
|
4922
5081
|
|
|
4923
5082
|
// src/routes/tenants/tenants.route.ts
|
|
4924
|
-
var listTenantsRoute =
|
|
5083
|
+
var listTenantsRoute = createRoute12({
|
|
4925
5084
|
method: "get",
|
|
4926
5085
|
path: "/",
|
|
4927
5086
|
tags: ["Tenants"],
|
|
@@ -4940,7 +5099,7 @@ var listTenantsRoute = createRoute11({
|
|
|
4940
5099
|
}
|
|
4941
5100
|
}
|
|
4942
5101
|
});
|
|
4943
|
-
var getTenantRoute =
|
|
5102
|
+
var getTenantRoute = createRoute12({
|
|
4944
5103
|
method: "get",
|
|
4945
5104
|
path: "/{id}",
|
|
4946
5105
|
tags: ["Tenants"],
|
|
@@ -4967,7 +5126,7 @@ var getTenantRoute = createRoute11({
|
|
|
4967
5126
|
}
|
|
4968
5127
|
}
|
|
4969
5128
|
});
|
|
4970
|
-
var createTenantRoute =
|
|
5129
|
+
var createTenantRoute = createRoute12({
|
|
4971
5130
|
method: "post",
|
|
4972
5131
|
path: "/",
|
|
4973
5132
|
tags: ["Tenants"],
|
|
@@ -5000,7 +5159,7 @@ var createTenantRoute = createRoute11({
|
|
|
5000
5159
|
}
|
|
5001
5160
|
}
|
|
5002
5161
|
});
|
|
5003
|
-
var updateTenantRoute =
|
|
5162
|
+
var updateTenantRoute = createRoute12({
|
|
5004
5163
|
method: "put",
|
|
5005
5164
|
path: "/{id}",
|
|
5006
5165
|
tags: ["Tenants"],
|
|
@@ -5034,7 +5193,7 @@ var updateTenantRoute = createRoute11({
|
|
|
5034
5193
|
}
|
|
5035
5194
|
}
|
|
5036
5195
|
});
|
|
5037
|
-
var deleteTenantRoute =
|
|
5196
|
+
var deleteTenantRoute = createRoute12({
|
|
5038
5197
|
method: "delete",
|
|
5039
5198
|
path: "/{id}",
|
|
5040
5199
|
tags: ["Tenants"],
|
|
@@ -5061,11 +5220,11 @@ var deleteTenantRoute = createRoute11({
|
|
|
5061
5220
|
}
|
|
5062
5221
|
}
|
|
5063
5222
|
});
|
|
5064
|
-
var
|
|
5065
|
-
var tenants_route_default =
|
|
5223
|
+
var tenantRoutes2 = new OpenAPIHono12().openapi(listTenantsRoute, listTenantsHandler).openapi(getTenantRoute, getTenantHandler).openapi(createTenantRoute, createTenantHandler).openapi(updateTenantRoute, updateTenantHandler).openapi(deleteTenantRoute, deleteTenantHandler);
|
|
5224
|
+
var tenants_route_default = tenantRoutes2;
|
|
5066
5225
|
|
|
5067
5226
|
// src/routes/user-roles/user-roles.route.ts
|
|
5068
|
-
import { createRoute as
|
|
5227
|
+
import { createRoute as createRoute13, OpenAPIHono as OpenAPIHono13 } from "@hono/zod-openapi";
|
|
5069
5228
|
|
|
5070
5229
|
// src/routes/user-roles/handler/assign-user-role.ts
|
|
5071
5230
|
var assignUserRoleHandler = async (c) => {
|
|
@@ -5125,39 +5284,39 @@ var revokeUserRoleHandler = async (c) => {
|
|
|
5125
5284
|
};
|
|
5126
5285
|
|
|
5127
5286
|
// src/routes/user-roles/user-roles.schema.ts
|
|
5128
|
-
import { z as
|
|
5129
|
-
var listUserRolesQuerySchema =
|
|
5130
|
-
userId:
|
|
5131
|
-
roleId:
|
|
5287
|
+
import { z as z10 } from "zod";
|
|
5288
|
+
var listUserRolesQuerySchema = z10.object({
|
|
5289
|
+
userId: z10.uuid().optional(),
|
|
5290
|
+
roleId: z10.uuid().optional()
|
|
5132
5291
|
});
|
|
5133
|
-
var userRoleIdParamSchema =
|
|
5134
|
-
id:
|
|
5292
|
+
var userRoleIdParamSchema = z10.object({
|
|
5293
|
+
id: z10.uuid()
|
|
5135
5294
|
});
|
|
5136
|
-
var assignUserRoleSchema =
|
|
5137
|
-
userId:
|
|
5138
|
-
roleId:
|
|
5295
|
+
var assignUserRoleSchema = z10.object({
|
|
5296
|
+
userId: z10.uuid(),
|
|
5297
|
+
roleId: z10.uuid()
|
|
5139
5298
|
});
|
|
5140
|
-
var userRoleSchema2 =
|
|
5141
|
-
id:
|
|
5142
|
-
tenantId:
|
|
5143
|
-
userId:
|
|
5144
|
-
roleId:
|
|
5299
|
+
var userRoleSchema2 = z10.object({
|
|
5300
|
+
id: z10.uuid(),
|
|
5301
|
+
tenantId: z10.string(),
|
|
5302
|
+
userId: z10.uuid(),
|
|
5303
|
+
roleId: z10.uuid()
|
|
5145
5304
|
});
|
|
5146
|
-
var listUserRolesResponseSchema =
|
|
5147
|
-
userRoles:
|
|
5305
|
+
var listUserRolesResponseSchema = z10.object({
|
|
5306
|
+
userRoles: z10.array(userRoleSchema2)
|
|
5148
5307
|
});
|
|
5149
|
-
var userRoleResponseSchema =
|
|
5308
|
+
var userRoleResponseSchema = z10.object({
|
|
5150
5309
|
userRole: userRoleSchema2
|
|
5151
5310
|
});
|
|
5152
|
-
var revokeUserRoleResponseSchema =
|
|
5153
|
-
message:
|
|
5311
|
+
var revokeUserRoleResponseSchema = z10.object({
|
|
5312
|
+
message: z10.string()
|
|
5154
5313
|
});
|
|
5155
|
-
var errorResponseSchema8 =
|
|
5156
|
-
error:
|
|
5314
|
+
var errorResponseSchema8 = z10.object({
|
|
5315
|
+
error: z10.string()
|
|
5157
5316
|
});
|
|
5158
5317
|
|
|
5159
5318
|
// src/routes/user-roles/user-roles.route.ts
|
|
5160
|
-
var listUserRolesRoute =
|
|
5319
|
+
var listUserRolesRoute = createRoute13({
|
|
5161
5320
|
method: "get",
|
|
5162
5321
|
path: "/",
|
|
5163
5322
|
tags: ["User Roles"],
|
|
@@ -5176,7 +5335,7 @@ var listUserRolesRoute = createRoute12({
|
|
|
5176
5335
|
}
|
|
5177
5336
|
}
|
|
5178
5337
|
});
|
|
5179
|
-
var assignUserRoleRoute =
|
|
5338
|
+
var assignUserRoleRoute = createRoute13({
|
|
5180
5339
|
method: "post",
|
|
5181
5340
|
path: "/",
|
|
5182
5341
|
tags: ["User Roles"],
|
|
@@ -5209,7 +5368,7 @@ var assignUserRoleRoute = createRoute12({
|
|
|
5209
5368
|
}
|
|
5210
5369
|
}
|
|
5211
5370
|
});
|
|
5212
|
-
var revokeUserRoleRoute =
|
|
5371
|
+
var revokeUserRoleRoute = createRoute13({
|
|
5213
5372
|
method: "delete",
|
|
5214
5373
|
path: "/{id}",
|
|
5215
5374
|
tags: ["User Roles"],
|
|
@@ -5236,11 +5395,11 @@ var revokeUserRoleRoute = createRoute12({
|
|
|
5236
5395
|
}
|
|
5237
5396
|
}
|
|
5238
5397
|
});
|
|
5239
|
-
var userRoleRoutes = new
|
|
5398
|
+
var userRoleRoutes = new OpenAPIHono13().openapi(listUserRolesRoute, listUserRolesHandler).openapi(assignUserRoleRoute, assignUserRoleHandler).openapi(revokeUserRoleRoute, revokeUserRoleHandler);
|
|
5240
5399
|
var user_roles_route_default = userRoleRoutes;
|
|
5241
5400
|
|
|
5242
5401
|
// src/routes/users/users.route.ts
|
|
5243
|
-
import { createRoute as
|
|
5402
|
+
import { createRoute as createRoute14, OpenAPIHono as OpenAPIHono14 } from "@hono/zod-openapi";
|
|
5244
5403
|
|
|
5245
5404
|
// src/routes/users/handler/ban-user.ts
|
|
5246
5405
|
import { and as and41, eq as eq45, sql as sql22 } from "drizzle-orm";
|
|
@@ -5531,72 +5690,72 @@ var updateUserHandler = async (c) => {
|
|
|
5531
5690
|
};
|
|
5532
5691
|
|
|
5533
5692
|
// src/routes/users/users.schema.ts
|
|
5534
|
-
import { z as
|
|
5535
|
-
var listUsersQuerySchema =
|
|
5536
|
-
page:
|
|
5537
|
-
limit:
|
|
5538
|
-
tenantId:
|
|
5539
|
-
email:
|
|
5540
|
-
phone:
|
|
5541
|
-
handle:
|
|
5542
|
-
});
|
|
5543
|
-
var userIdParamSchema2 = z10.object({
|
|
5544
|
-
id: z10.uuid()
|
|
5693
|
+
import { z as z11 } from "zod";
|
|
5694
|
+
var listUsersQuerySchema = z11.object({
|
|
5695
|
+
page: z11.coerce.number().min(1).default(1).optional(),
|
|
5696
|
+
limit: z11.coerce.number().min(1).max(100).default(20).optional(),
|
|
5697
|
+
tenantId: z11.string().optional(),
|
|
5698
|
+
email: z11.string().optional(),
|
|
5699
|
+
phone: z11.string().optional(),
|
|
5700
|
+
handle: z11.string().optional()
|
|
5545
5701
|
});
|
|
5546
|
-
var
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
});
|
|
5567
|
-
var
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5702
|
+
var userIdParamSchema2 = z11.object({
|
|
5703
|
+
id: z11.uuid()
|
|
5704
|
+
});
|
|
5705
|
+
var createUserSchema = z11.object({
|
|
5706
|
+
email: z11.string().email().optional(),
|
|
5707
|
+
phone: z11.string().optional(),
|
|
5708
|
+
fullName: z11.string().min(1),
|
|
5709
|
+
handle: z11.string().optional(),
|
|
5710
|
+
image: z11.string().url().optional(),
|
|
5711
|
+
emailVerified: z11.boolean().default(false).optional(),
|
|
5712
|
+
phoneVerified: z11.boolean().default(false).optional()
|
|
5713
|
+
});
|
|
5714
|
+
var updateUserSchema = z11.object({
|
|
5715
|
+
fullName: z11.string().min(1).optional(),
|
|
5716
|
+
email: z11.string().email().nullable().optional(),
|
|
5717
|
+
phone: z11.string().nullable().optional(),
|
|
5718
|
+
handle: z11.string().optional(),
|
|
5719
|
+
image: z11.string().url().nullable().optional(),
|
|
5720
|
+
emailVerified: z11.boolean().optional(),
|
|
5721
|
+
phoneVerified: z11.boolean().optional()
|
|
5722
|
+
});
|
|
5723
|
+
var banUserSchema = z11.object({
|
|
5724
|
+
bannedUntil: z11.string().datetime().nullable().optional()
|
|
5725
|
+
});
|
|
5726
|
+
var listUsersResponseSchema = z11.object({
|
|
5727
|
+
users: z11.array(userSchema),
|
|
5728
|
+
total: z11.number(),
|
|
5729
|
+
page: z11.number(),
|
|
5730
|
+
limit: z11.number()
|
|
5731
|
+
});
|
|
5732
|
+
var userResponseSchema = z11.object({
|
|
5574
5733
|
user: userSchema
|
|
5575
5734
|
});
|
|
5576
|
-
var deleteUserResponseSchema =
|
|
5577
|
-
message:
|
|
5735
|
+
var deleteUserResponseSchema = z11.object({
|
|
5736
|
+
message: z11.string()
|
|
5578
5737
|
});
|
|
5579
|
-
var errorResponseSchema9 =
|
|
5580
|
-
error:
|
|
5738
|
+
var errorResponseSchema9 = z11.object({
|
|
5739
|
+
error: z11.string()
|
|
5581
5740
|
});
|
|
5582
|
-
var searchUsersQuerySchema =
|
|
5583
|
-
search:
|
|
5584
|
-
limit:
|
|
5741
|
+
var searchUsersQuerySchema = z11.object({
|
|
5742
|
+
search: z11.string().optional().describe("Search term"),
|
|
5743
|
+
limit: z11.coerce.number().int().positive().optional().default(20).describe("Limit")
|
|
5585
5744
|
});
|
|
5586
|
-
var userSearchResultSchema =
|
|
5587
|
-
id:
|
|
5588
|
-
fullName:
|
|
5589
|
-
email:
|
|
5590
|
-
phone:
|
|
5591
|
-
handle:
|
|
5592
|
-
image:
|
|
5745
|
+
var userSearchResultSchema = z11.object({
|
|
5746
|
+
id: z11.string().uuid().describe("User ID"),
|
|
5747
|
+
fullName: z11.string().describe("Full name"),
|
|
5748
|
+
email: z11.string().nullable().describe("Email"),
|
|
5749
|
+
phone: z11.string().nullable().describe("Phone"),
|
|
5750
|
+
handle: z11.string().describe("Handle"),
|
|
5751
|
+
image: z11.string().nullable().describe("Image URL")
|
|
5593
5752
|
});
|
|
5594
|
-
var searchUsersResponseSchema =
|
|
5595
|
-
users:
|
|
5753
|
+
var searchUsersResponseSchema = z11.object({
|
|
5754
|
+
users: z11.array(userSearchResultSchema).describe("Users")
|
|
5596
5755
|
});
|
|
5597
5756
|
|
|
5598
5757
|
// src/routes/users/users.route.ts
|
|
5599
|
-
var listUsersRoute =
|
|
5758
|
+
var listUsersRoute = createRoute14({
|
|
5600
5759
|
method: "get",
|
|
5601
5760
|
path: "/",
|
|
5602
5761
|
tags: ["Users"],
|
|
@@ -5615,7 +5774,7 @@ var listUsersRoute = createRoute13({
|
|
|
5615
5774
|
}
|
|
5616
5775
|
}
|
|
5617
5776
|
});
|
|
5618
|
-
var getUserRoute =
|
|
5777
|
+
var getUserRoute = createRoute14({
|
|
5619
5778
|
method: "get",
|
|
5620
5779
|
path: "/{id}",
|
|
5621
5780
|
tags: ["Users"],
|
|
@@ -5642,7 +5801,7 @@ var getUserRoute = createRoute13({
|
|
|
5642
5801
|
}
|
|
5643
5802
|
}
|
|
5644
5803
|
});
|
|
5645
|
-
var createUserRoute =
|
|
5804
|
+
var createUserRoute = createRoute14({
|
|
5646
5805
|
method: "post",
|
|
5647
5806
|
path: "/",
|
|
5648
5807
|
tags: ["Users"],
|
|
@@ -5675,7 +5834,7 @@ var createUserRoute = createRoute13({
|
|
|
5675
5834
|
}
|
|
5676
5835
|
}
|
|
5677
5836
|
});
|
|
5678
|
-
var updateUserRoute =
|
|
5837
|
+
var updateUserRoute = createRoute14({
|
|
5679
5838
|
method: "put",
|
|
5680
5839
|
path: "/{id}",
|
|
5681
5840
|
tags: ["Users"],
|
|
@@ -5717,7 +5876,7 @@ var updateUserRoute = createRoute13({
|
|
|
5717
5876
|
}
|
|
5718
5877
|
}
|
|
5719
5878
|
});
|
|
5720
|
-
var deleteUserRoute =
|
|
5879
|
+
var deleteUserRoute = createRoute14({
|
|
5721
5880
|
method: "delete",
|
|
5722
5881
|
path: "/{id}",
|
|
5723
5882
|
tags: ["Users"],
|
|
@@ -5744,7 +5903,7 @@ var deleteUserRoute = createRoute13({
|
|
|
5744
5903
|
}
|
|
5745
5904
|
}
|
|
5746
5905
|
});
|
|
5747
|
-
var banUserRoute =
|
|
5906
|
+
var banUserRoute = createRoute14({
|
|
5748
5907
|
method: "post",
|
|
5749
5908
|
path: "/{id}/ban",
|
|
5750
5909
|
tags: ["Users"],
|
|
@@ -5778,7 +5937,7 @@ var banUserRoute = createRoute13({
|
|
|
5778
5937
|
}
|
|
5779
5938
|
}
|
|
5780
5939
|
});
|
|
5781
|
-
var searchUsersRoute =
|
|
5940
|
+
var searchUsersRoute = createRoute14({
|
|
5782
5941
|
method: "get",
|
|
5783
5942
|
path: "/search",
|
|
5784
5943
|
tags: ["Users"],
|
|
@@ -5797,11 +5956,11 @@ var searchUsersRoute = createRoute13({
|
|
|
5797
5956
|
}
|
|
5798
5957
|
}
|
|
5799
5958
|
});
|
|
5800
|
-
var userRoutes = new
|
|
5959
|
+
var userRoutes = new OpenAPIHono14().openapi(listUsersRoute, listUsersHandler).openapi(getUserRoute, getUserHandler).openapi(createUserRoute, createUserHandler).openapi(updateUserRoute, updateUserHandler).openapi(deleteUserRoute, deleteUserHandler).openapi(banUserRoute, banUserHandler).openapi(searchUsersRoute, searchUsersHandler);
|
|
5801
5960
|
var users_route_default = userRoutes;
|
|
5802
5961
|
|
|
5803
5962
|
// src/routes/verifications/verifications.route.ts
|
|
5804
|
-
import { createRoute as
|
|
5963
|
+
import { createRoute as createRoute15, OpenAPIHono as OpenAPIHono15 } from "@hono/zod-openapi";
|
|
5805
5964
|
|
|
5806
5965
|
// src/routes/verifications/handler/invalidate-verification.ts
|
|
5807
5966
|
import { and as and47, eq as eq51 } from "drizzle-orm";
|
|
@@ -5863,44 +6022,44 @@ var listVerificationsHandler = async (c) => {
|
|
|
5863
6022
|
};
|
|
5864
6023
|
|
|
5865
6024
|
// src/routes/verifications/verifications.schema.ts
|
|
5866
|
-
import { z as
|
|
5867
|
-
var listVerificationsQuerySchema =
|
|
5868
|
-
page:
|
|
5869
|
-
limit:
|
|
5870
|
-
userId:
|
|
5871
|
-
type:
|
|
5872
|
-
status:
|
|
5873
|
-
});
|
|
5874
|
-
var verificationIdParamSchema =
|
|
5875
|
-
id:
|
|
5876
|
-
});
|
|
5877
|
-
var verificationSchema =
|
|
5878
|
-
id:
|
|
5879
|
-
tenantId:
|
|
5880
|
-
userId:
|
|
5881
|
-
code:
|
|
5882
|
-
expiresAt:
|
|
5883
|
-
type:
|
|
5884
|
-
attempt:
|
|
5885
|
-
to:
|
|
5886
|
-
createdAt:
|
|
5887
|
-
updatedAt:
|
|
5888
|
-
});
|
|
5889
|
-
var listVerificationsResponseSchema =
|
|
5890
|
-
verifications:
|
|
5891
|
-
total:
|
|
5892
|
-
page:
|
|
5893
|
-
limit:
|
|
5894
|
-
});
|
|
5895
|
-
var invalidateVerificationResponseSchema =
|
|
5896
|
-
message:
|
|
5897
|
-
});
|
|
5898
|
-
var errorResponseSchema10 =
|
|
5899
|
-
error:
|
|
6025
|
+
import { z as z12 } from "zod";
|
|
6026
|
+
var listVerificationsQuerySchema = z12.object({
|
|
6027
|
+
page: z12.coerce.number().min(1).default(1).optional(),
|
|
6028
|
+
limit: z12.coerce.number().min(1).max(100).default(20).optional(),
|
|
6029
|
+
userId: z12.uuid().optional(),
|
|
6030
|
+
type: z12.string().optional(),
|
|
6031
|
+
status: z12.enum(["active", "expired", "consumed"]).optional()
|
|
6032
|
+
});
|
|
6033
|
+
var verificationIdParamSchema = z12.object({
|
|
6034
|
+
id: z12.uuid()
|
|
6035
|
+
});
|
|
6036
|
+
var verificationSchema = z12.object({
|
|
6037
|
+
id: z12.uuid(),
|
|
6038
|
+
tenantId: z12.string(),
|
|
6039
|
+
userId: z12.uuid(),
|
|
6040
|
+
code: z12.string(),
|
|
6041
|
+
expiresAt: z12.string(),
|
|
6042
|
+
type: z12.string().nullable(),
|
|
6043
|
+
attempt: z12.number().nullable(),
|
|
6044
|
+
to: z12.string().nullable(),
|
|
6045
|
+
createdAt: z12.string(),
|
|
6046
|
+
updatedAt: z12.string()
|
|
6047
|
+
});
|
|
6048
|
+
var listVerificationsResponseSchema = z12.object({
|
|
6049
|
+
verifications: z12.array(verificationSchema),
|
|
6050
|
+
total: z12.number(),
|
|
6051
|
+
page: z12.number(),
|
|
6052
|
+
limit: z12.number()
|
|
6053
|
+
});
|
|
6054
|
+
var invalidateVerificationResponseSchema = z12.object({
|
|
6055
|
+
message: z12.string()
|
|
6056
|
+
});
|
|
6057
|
+
var errorResponseSchema10 = z12.object({
|
|
6058
|
+
error: z12.string()
|
|
5900
6059
|
});
|
|
5901
6060
|
|
|
5902
6061
|
// src/routes/verifications/verifications.route.ts
|
|
5903
|
-
var listVerificationsRoute =
|
|
6062
|
+
var listVerificationsRoute = createRoute15({
|
|
5904
6063
|
method: "get",
|
|
5905
6064
|
path: "/",
|
|
5906
6065
|
tags: ["Verifications"],
|
|
@@ -5919,7 +6078,7 @@ var listVerificationsRoute = createRoute14({
|
|
|
5919
6078
|
}
|
|
5920
6079
|
}
|
|
5921
6080
|
});
|
|
5922
|
-
var invalidateVerificationRoute =
|
|
6081
|
+
var invalidateVerificationRoute = createRoute15({
|
|
5923
6082
|
method: "delete",
|
|
5924
6083
|
path: "/{id}",
|
|
5925
6084
|
tags: ["Verifications"],
|
|
@@ -5946,11 +6105,11 @@ var invalidateVerificationRoute = createRoute14({
|
|
|
5946
6105
|
}
|
|
5947
6106
|
}
|
|
5948
6107
|
});
|
|
5949
|
-
var verificationRoutes = new
|
|
6108
|
+
var verificationRoutes = new OpenAPIHono15().openapi(listVerificationsRoute, listVerificationsHandler).openapi(invalidateVerificationRoute, invalidateVerificationHandler);
|
|
5950
6109
|
var verifications_route_default = verificationRoutes;
|
|
5951
6110
|
|
|
5952
6111
|
// src/routes/index.ts
|
|
5953
|
-
var routes = new
|
|
6112
|
+
var routes = new OpenAPIHono16().route("/", auth_route_default).route("/", profile_route_default).route("/password", password_route_default).route("/email", email_route_default).route("/phone", phone_route_default).route("/users", users_route_default).route("/system", system_route_default).route("/tenants", tenants_route_default).route("/domains", domains_route_default).route("/roles", roles_route_default).route("/permissions", permissions_route_default).route("/role-permissions", role_permissions_route_default).route("/user-roles", user_roles_route_default).route("/sessions", sessions_route_default).route("/verifications", verifications_route_default);
|
|
5954
6113
|
var routes_default = routes;
|
|
5955
6114
|
|
|
5956
6115
|
// src/utility/set-auth-context.ts
|
|
@@ -6031,7 +6190,10 @@ var createAuthRoutes = ({
|
|
|
6031
6190
|
config,
|
|
6032
6191
|
database
|
|
6033
6192
|
}) => {
|
|
6034
|
-
const app = new
|
|
6193
|
+
const app = new OpenAPIHono17();
|
|
6194
|
+
app.onError((error, c) => {
|
|
6195
|
+
return handleError(error, c);
|
|
6196
|
+
});
|
|
6035
6197
|
app.use(
|
|
6036
6198
|
"*",
|
|
6037
6199
|
createAuthMiddleware({
|
|
@@ -6092,13 +6254,18 @@ var createOpenApiConfig = (config) => {
|
|
|
6092
6254
|
},
|
|
6093
6255
|
{ name: "User Roles", description: "User-role assignment (IAM)" },
|
|
6094
6256
|
{ name: "Sessions", description: "Session management (IAM)" },
|
|
6095
|
-
{ name: "Verifications", description: "Verification management (IAM)" }
|
|
6257
|
+
{ name: "Verifications", description: "Verification management (IAM)" },
|
|
6258
|
+
{ name: "System", description: "System initialization" }
|
|
6096
6259
|
],
|
|
6097
6260
|
"x-tagGroups": [
|
|
6098
6261
|
{
|
|
6099
6262
|
name: "Authentication",
|
|
6100
6263
|
tags: ["Auth", "Profile", "Password", "Email", "Phone"]
|
|
6101
6264
|
},
|
|
6265
|
+
{
|
|
6266
|
+
name: "System",
|
|
6267
|
+
tags: ["System"]
|
|
6268
|
+
},
|
|
6102
6269
|
{
|
|
6103
6270
|
name: "IAM Management",
|
|
6104
6271
|
tags: [
|
|
@@ -6126,10 +6293,12 @@ var createSessionMiddleware = () => {
|
|
|
6126
6293
|
c.set("user", null);
|
|
6127
6294
|
c.set("session", null);
|
|
6128
6295
|
c.set("userId", null);
|
|
6296
|
+
c.set("sessionStatus", "error");
|
|
6129
6297
|
return await next();
|
|
6130
6298
|
}
|
|
6131
6299
|
const sessionData = await authInstance.getSession(c);
|
|
6132
|
-
const { session, user } = sessionData;
|
|
6300
|
+
const { session, user, status } = sessionData;
|
|
6301
|
+
c.set("sessionStatus", status);
|
|
6133
6302
|
if (!(session && user)) {
|
|
6134
6303
|
c.set("user", null);
|
|
6135
6304
|
c.set("session", null);
|
|
@@ -6145,16 +6314,9 @@ var createSessionMiddleware = () => {
|
|
|
6145
6314
|
};
|
|
6146
6315
|
|
|
6147
6316
|
// src/middlewares/tenant-middleware.ts
|
|
6148
|
-
import { logger } from "@mesob/common";
|
|
6317
|
+
import { logger as logger2 } from "@mesob/common";
|
|
6149
6318
|
import { createMiddleware as createMiddleware2 } from "hono/factory";
|
|
6150
|
-
import { HTTPException as
|
|
6151
|
-
var TENANT_TEST_PATH = "/api/health/tenant-test";
|
|
6152
|
-
var AUTH_DOCS_PATHS = [
|
|
6153
|
-
"/api/auth/docs",
|
|
6154
|
-
"/api/auth/openapi.json",
|
|
6155
|
-
"/api/docs",
|
|
6156
|
-
"/api/openapi.json"
|
|
6157
|
-
];
|
|
6319
|
+
import { HTTPException as HTTPException3 } from "hono/http-exception";
|
|
6158
6320
|
function resolveHost(hostHeader, forwardedHost) {
|
|
6159
6321
|
const hostHeaderStr = hostHeader || "";
|
|
6160
6322
|
const forwardedHostStr = forwardedHost || "";
|
|
@@ -6194,7 +6356,7 @@ async function resolveTenant(database, config, host) {
|
|
|
6194
6356
|
}
|
|
6195
6357
|
return { tenantId, tenant };
|
|
6196
6358
|
} catch (err) {
|
|
6197
|
-
|
|
6359
|
+
logger2.error("Tenant resolution error:", err);
|
|
6198
6360
|
throw err;
|
|
6199
6361
|
}
|
|
6200
6362
|
}
|
|
@@ -6212,19 +6374,13 @@ function validateTenant(tenantId, tenant) {
|
|
|
6212
6374
|
}
|
|
6213
6375
|
var createTenantMiddleware = (database, config) => {
|
|
6214
6376
|
return createMiddleware2(async (c, next) => {
|
|
6215
|
-
const pathname = new URL(c.req.url).pathname;
|
|
6216
|
-
const isTenantTest = pathname === TENANT_TEST_PATH;
|
|
6217
|
-
const isAuthDocs = AUTH_DOCS_PATHS.includes(pathname);
|
|
6218
6377
|
const host = resolveHost(
|
|
6219
6378
|
c.req.header("host"),
|
|
6220
6379
|
c.req.header("x-forwarded-host")
|
|
6221
6380
|
);
|
|
6222
6381
|
c.set("host", host);
|
|
6223
6382
|
if (!host) {
|
|
6224
|
-
|
|
6225
|
-
return await next();
|
|
6226
|
-
}
|
|
6227
|
-
throw new HTTPException2(400, { message: "Missing Host header" });
|
|
6383
|
+
throw new HTTPException3(400, { message: "Missing Host header" });
|
|
6228
6384
|
}
|
|
6229
6385
|
let tenantId = null;
|
|
6230
6386
|
let tenant = null;
|
|
@@ -6233,15 +6389,13 @@ var createTenantMiddleware = (database, config) => {
|
|
|
6233
6389
|
tenantId = result.tenantId;
|
|
6234
6390
|
tenant = result.tenant;
|
|
6235
6391
|
} catch {
|
|
6236
|
-
|
|
6237
|
-
throw new HTTPException2(500, { message: "Tenant resolution failed" });
|
|
6238
|
-
}
|
|
6392
|
+
throw new HTTPException3(500, { message: "Tenant resolution failed" });
|
|
6239
6393
|
}
|
|
6240
6394
|
c.set("tenantId", tenantId);
|
|
6241
6395
|
c.set("tenant", tenant);
|
|
6242
6396
|
const error = validateTenant(tenantId, tenant);
|
|
6243
|
-
if (error
|
|
6244
|
-
throw new
|
|
6397
|
+
if (error) {
|
|
6398
|
+
throw new HTTPException3(404, { message: error });
|
|
6245
6399
|
}
|
|
6246
6400
|
return await next();
|
|
6247
6401
|
});
|
|
@@ -6253,7 +6407,12 @@ var createGetSession = (database, config) => {
|
|
|
6253
6407
|
return async (c) => {
|
|
6254
6408
|
const sessionToken = getCookie4(c, getSessionCookieName(config));
|
|
6255
6409
|
if (!sessionToken) {
|
|
6256
|
-
return {
|
|
6410
|
+
return {
|
|
6411
|
+
session: null,
|
|
6412
|
+
user: null,
|
|
6413
|
+
sessionToken: null,
|
|
6414
|
+
status: "no_cookie"
|
|
6415
|
+
};
|
|
6257
6416
|
}
|
|
6258
6417
|
try {
|
|
6259
6418
|
const hashedToken = await hashToken(sessionToken, config.secret);
|
|
@@ -6264,7 +6423,12 @@ var createGetSession = (database, config) => {
|
|
|
6264
6423
|
});
|
|
6265
6424
|
if (!session) {
|
|
6266
6425
|
deleteSessionCookie(c, config);
|
|
6267
|
-
return {
|
|
6426
|
+
return {
|
|
6427
|
+
session: null,
|
|
6428
|
+
user: null,
|
|
6429
|
+
sessionToken: null,
|
|
6430
|
+
status: "invalid_session"
|
|
6431
|
+
};
|
|
6268
6432
|
}
|
|
6269
6433
|
const user = await fetchUserWithRoles({
|
|
6270
6434
|
database,
|
|
@@ -6278,7 +6442,12 @@ var createGetSession = (database, config) => {
|
|
|
6278
6442
|
tenantId: session.tenantId
|
|
6279
6443
|
});
|
|
6280
6444
|
deleteSessionCookie(c, config);
|
|
6281
|
-
return {
|
|
6445
|
+
return {
|
|
6446
|
+
session: null,
|
|
6447
|
+
user: null,
|
|
6448
|
+
sessionToken: null,
|
|
6449
|
+
status: "user_not_found"
|
|
6450
|
+
};
|
|
6282
6451
|
}
|
|
6283
6452
|
const rememberMe = session.meta?.rememberMe !== false;
|
|
6284
6453
|
const updateAge = getSessionUpdateAge({
|
|
@@ -6302,21 +6471,22 @@ var createGetSession = (database, config) => {
|
|
|
6302
6471
|
return {
|
|
6303
6472
|
session: { ...session, expiresAt: newExpiresAt },
|
|
6304
6473
|
user,
|
|
6305
|
-
sessionToken
|
|
6474
|
+
sessionToken,
|
|
6475
|
+
status: "valid"
|
|
6306
6476
|
};
|
|
6307
6477
|
}
|
|
6308
|
-
return { session, user, sessionToken };
|
|
6478
|
+
return { session, user, sessionToken, status: "valid" };
|
|
6309
6479
|
} catch {
|
|
6310
|
-
return { session: null, user: null, sessionToken: null };
|
|
6480
|
+
return { session: null, user: null, sessionToken: null, status: "error" };
|
|
6311
6481
|
}
|
|
6312
6482
|
};
|
|
6313
6483
|
};
|
|
6314
6484
|
|
|
6315
6485
|
// src/types/index.ts
|
|
6316
|
-
import { logger as
|
|
6486
|
+
import { logger as logger3 } from "@mesob/common";
|
|
6317
6487
|
var createDefaultSendVerificationOTP = (expiresIn) => {
|
|
6318
6488
|
return (params) => {
|
|
6319
|
-
|
|
6489
|
+
logger3.log(
|
|
6320
6490
|
`[Verification OTP] Code: ${params.code}, Hash: ${params.hash}, ExpiresIn: ${expiresIn}, Type: ${params.type}`
|
|
6321
6491
|
);
|
|
6322
6492
|
};
|
|
@@ -6330,6 +6500,7 @@ var defaultConfig = {
|
|
|
6330
6500
|
resendInterval: "30s",
|
|
6331
6501
|
sendVerificationOTP: createDefaultSendVerificationOTP("15m")
|
|
6332
6502
|
};
|
|
6503
|
+
var defaultPhoneRegex = /^(\+2519|\+2517|2519|2517|09|07)\d{8}$/;
|
|
6333
6504
|
var defaultAuthConfig = {
|
|
6334
6505
|
tenant: {
|
|
6335
6506
|
enabled: true,
|
|
@@ -6350,7 +6521,10 @@ var defaultAuthConfig = {
|
|
|
6350
6521
|
maxPerUser: 5
|
|
6351
6522
|
},
|
|
6352
6523
|
email: defaultConfig,
|
|
6353
|
-
phone:
|
|
6524
|
+
phone: {
|
|
6525
|
+
...defaultConfig,
|
|
6526
|
+
phoneRegex: defaultPhoneRegex
|
|
6527
|
+
},
|
|
6354
6528
|
security: {
|
|
6355
6529
|
maxLoginAttempts: 5,
|
|
6356
6530
|
lockoutDuration: "15m"
|
|
@@ -6406,20 +6580,7 @@ var createMesobAuth = (authConfig) => {
|
|
|
6406
6580
|
const getSession = createGetSession(database, config);
|
|
6407
6581
|
const tenantMiddleware = createTenantMiddleware(database, config);
|
|
6408
6582
|
const sessionMiddleware = createSessionMiddleware();
|
|
6409
|
-
const routes2 =
|
|
6410
|
-
...routesApp,
|
|
6411
|
-
fetch: async (request, env) => {
|
|
6412
|
-
if (basePath && request.url) {
|
|
6413
|
-
const url = new URL(request.url);
|
|
6414
|
-
if (url.pathname.startsWith(basePath)) {
|
|
6415
|
-
url.pathname = url.pathname.slice(basePath.length) || "/";
|
|
6416
|
-
const modifiedRequest = new Request(url, request);
|
|
6417
|
-
return await routesApp.fetch(modifiedRequest, env);
|
|
6418
|
-
}
|
|
6419
|
-
}
|
|
6420
|
-
return await routesApp.fetch(request, env);
|
|
6421
|
-
}
|
|
6422
|
-
};
|
|
6583
|
+
const routes2 = routesApp;
|
|
6423
6584
|
return {
|
|
6424
6585
|
routes: routes2,
|
|
6425
6586
|
getSession,
|