najm-auth 3.1.5 → 3.2.1
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 +53 -14
- package/dist/client/edge.d.ts +9 -1
- package/dist/client/edge.js +3 -1
- package/dist/client/server/index.d.ts +83 -57
- package/dist/client/server/index.js +175 -154
- package/dist/index.d.ts +35 -13
- package/dist/index.js +462 -423
- package/dist/schema/pg.d.ts +2 -2
- package/dist/schema/sqlite.d.ts +4 -4
- package/package.json +1 -1
|
@@ -756,11 +756,13 @@ function withAuthMiddleware(config) {
|
|
|
756
756
|
sessionCookieName = "najm.session",
|
|
757
757
|
sessionSecret,
|
|
758
758
|
sessionMaxAge,
|
|
759
|
-
verifyAlways = false,
|
|
759
|
+
verifyAlways: legacyVerifyAlways = false,
|
|
760
|
+
proxySessionMode,
|
|
760
761
|
recoveryURL,
|
|
761
762
|
internalRecoveryURL,
|
|
762
763
|
onRecoveryFailure
|
|
763
764
|
} = config;
|
|
765
|
+
const verifyAlways = proxySessionMode === void 0 ? legacyVerifyAlways : proxySessionMode === "authoritative";
|
|
764
766
|
const resolvedInternalRecoveryURL = resolveInternalRecoveryURL(internalRecoveryURL);
|
|
765
767
|
return /* @__PURE__ */ __name(async function middleware(request) {
|
|
766
768
|
const { NextResponse } = await import("next/server");
|
|
@@ -1442,157 +1444,6 @@ function attachReactServerInternals(kit, internals) {
|
|
|
1442
1444
|
}
|
|
1443
1445
|
__name(attachReactServerInternals, "attachReactServerInternals");
|
|
1444
1446
|
|
|
1445
|
-
// src/client/server/defineAuth.ts
|
|
1446
|
-
function defineAuth(authConfig = {}) {
|
|
1447
|
-
const {
|
|
1448
|
-
apiBaseURL = "/api",
|
|
1449
|
-
authPrefix = "/auth",
|
|
1450
|
-
loginRoute = "/login",
|
|
1451
|
-
forbiddenRoute = "/forbidden",
|
|
1452
|
-
publicRoutes = [],
|
|
1453
|
-
protectedRoutes = [],
|
|
1454
|
-
roleRoutes = {},
|
|
1455
|
-
cookieName: cookieName2 = "refreshToken",
|
|
1456
|
-
sessionCookieName = "najm.session",
|
|
1457
|
-
sessionSecret,
|
|
1458
|
-
sessionMaxAge,
|
|
1459
|
-
recoveryURL,
|
|
1460
|
-
internalRecoveryURL,
|
|
1461
|
-
matcher = ["/((?!_next/static|_next/image|favicon.ico|api).*)"],
|
|
1462
|
-
verifyAlways = false,
|
|
1463
|
-
onRecoveryFailure,
|
|
1464
|
-
refreshThreshold,
|
|
1465
|
-
tabSync,
|
|
1466
|
-
channelName,
|
|
1467
|
-
timeout,
|
|
1468
|
-
retry
|
|
1469
|
-
} = authConfig;
|
|
1470
|
-
const sessionConfig = {
|
|
1471
|
-
baseURL: apiBaseURL,
|
|
1472
|
-
authPrefix,
|
|
1473
|
-
cookieName: cookieName2,
|
|
1474
|
-
sessionCookieName,
|
|
1475
|
-
sessionSecret,
|
|
1476
|
-
sessionMaxAge,
|
|
1477
|
-
recoveryURL,
|
|
1478
|
-
internalRecoveryURL,
|
|
1479
|
-
onRecoveryFailure
|
|
1480
|
-
};
|
|
1481
|
-
let _client = null;
|
|
1482
|
-
const getClient = /* @__PURE__ */ __name(() => {
|
|
1483
|
-
if (_client) return _client;
|
|
1484
|
-
_client = createAuthClient({
|
|
1485
|
-
baseURL: apiBaseURL,
|
|
1486
|
-
authPrefix,
|
|
1487
|
-
refreshThreshold,
|
|
1488
|
-
tabSync,
|
|
1489
|
-
channelName,
|
|
1490
|
-
timeout,
|
|
1491
|
-
retry
|
|
1492
|
-
});
|
|
1493
|
-
return _client;
|
|
1494
|
-
}, "getClient");
|
|
1495
|
-
const getSession2 = /* @__PURE__ */ __name(async (opts) => {
|
|
1496
|
-
const { getSession: resolveSession } = await Promise.resolve().then(() => (init_getSession(), getSession_exports));
|
|
1497
|
-
return resolveSession({ ...sessionConfig, ...opts });
|
|
1498
|
-
}, "getSession");
|
|
1499
|
-
const resolveSessionOutcome2 = /* @__PURE__ */ __name(async () => {
|
|
1500
|
-
const { resolveSessionOutcome: resolve } = await Promise.resolve().then(() => (init_getSession(), getSession_exports));
|
|
1501
|
-
return resolve(sessionConfig);
|
|
1502
|
-
}, "resolveSessionOutcome");
|
|
1503
|
-
const requireSession = /* @__PURE__ */ __name(async () => {
|
|
1504
|
-
const outcome = await resolveSessionOutcome2();
|
|
1505
|
-
if (outcome.status === "authenticated") return outcome.session;
|
|
1506
|
-
if (redirectsToLogin(outcome)) {
|
|
1507
|
-
const { redirect } = await import("next/navigation");
|
|
1508
|
-
redirect(loginRoute);
|
|
1509
|
-
}
|
|
1510
|
-
throw outcome.error;
|
|
1511
|
-
}, "requireSession");
|
|
1512
|
-
const requireRole = /* @__PURE__ */ __name(async (roles) => {
|
|
1513
|
-
const session = await requireSession();
|
|
1514
|
-
if (!heldRoles(session).some((role) => roles.includes(role))) {
|
|
1515
|
-
const { redirect } = await import("next/navigation");
|
|
1516
|
-
redirect(forbiddenRoute);
|
|
1517
|
-
}
|
|
1518
|
-
return session;
|
|
1519
|
-
}, "requireRole");
|
|
1520
|
-
const middleware = withAuthMiddleware({
|
|
1521
|
-
protectedRoutes,
|
|
1522
|
-
publicRoutes,
|
|
1523
|
-
loginRoute,
|
|
1524
|
-
roleRoutes,
|
|
1525
|
-
cookieName: cookieName2,
|
|
1526
|
-
apiBaseURL,
|
|
1527
|
-
authPrefix,
|
|
1528
|
-
sessionCookieName,
|
|
1529
|
-
sessionSecret,
|
|
1530
|
-
sessionMaxAge,
|
|
1531
|
-
recoveryURL,
|
|
1532
|
-
internalRecoveryURL,
|
|
1533
|
-
verifyAlways,
|
|
1534
|
-
onRecoveryFailure
|
|
1535
|
-
});
|
|
1536
|
-
const protect = /* @__PURE__ */ __name((Page, options) => {
|
|
1537
|
-
return /* @__PURE__ */ __name(async function ProtectedPage(props) {
|
|
1538
|
-
const session = await getSession2();
|
|
1539
|
-
if (!session) {
|
|
1540
|
-
const { redirect } = await import("next/navigation");
|
|
1541
|
-
redirect(loginRoute);
|
|
1542
|
-
}
|
|
1543
|
-
if (options?.role) {
|
|
1544
|
-
if (!heldRoles(session).includes(options.role)) {
|
|
1545
|
-
const { redirect } = await import("next/navigation");
|
|
1546
|
-
redirect(forbiddenRoute);
|
|
1547
|
-
}
|
|
1548
|
-
}
|
|
1549
|
-
if (options?.permission) {
|
|
1550
|
-
const { matchPermission: matchPermission2 } = await Promise.resolve().then(() => (init_permissions(), permissions_exports));
|
|
1551
|
-
const perms = session.permissions ?? session.user.permissions ?? [];
|
|
1552
|
-
if (!matchPermission2(perms, options.permission)) {
|
|
1553
|
-
const { redirect } = await import("next/navigation");
|
|
1554
|
-
redirect(forbiddenRoute);
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
return Page({ session, ...props });
|
|
1558
|
-
}, "ProtectedPage");
|
|
1559
|
-
}, "protect");
|
|
1560
|
-
return attachReactServerInternals({
|
|
1561
|
-
get client() {
|
|
1562
|
-
return getClient();
|
|
1563
|
-
},
|
|
1564
|
-
get api() {
|
|
1565
|
-
return getClient().api;
|
|
1566
|
-
},
|
|
1567
|
-
getSession: getSession2,
|
|
1568
|
-
requireSession,
|
|
1569
|
-
requireRole,
|
|
1570
|
-
middleware,
|
|
1571
|
-
config: { matcher },
|
|
1572
|
-
protect
|
|
1573
|
-
}, { resolveSessionOutcome: resolveSessionOutcome2, loginRoute, forbiddenRoute });
|
|
1574
|
-
}
|
|
1575
|
-
__name(defineAuth, "defineAuth");
|
|
1576
|
-
|
|
1577
|
-
// src/client/server/safeRedirect.ts
|
|
1578
|
-
var DEFAULT_BLOCKED_PREFIXES = ["/api", "/login", "/_next"];
|
|
1579
|
-
var ASSET_EXTENSIONS = /\.(?:css|gif|ico|jpe?g|js|json|map|png|svg|webmanifest|webp)$/i;
|
|
1580
|
-
function getSafeRedirectPath(value, options = {}) {
|
|
1581
|
-
const {
|
|
1582
|
-
fallback = "/dashboard",
|
|
1583
|
-
blockedPrefixes = DEFAULT_BLOCKED_PREFIXES
|
|
1584
|
-
} = typeof options === "string" ? { fallback: options } : options;
|
|
1585
|
-
const path = Array.isArray(value) ? value[0] : value;
|
|
1586
|
-
if (!path || !path.startsWith("/") || // Protocol-relative: the browser treats `//host/x` as off-site.
|
|
1587
|
-
path.startsWith("//") || // A backslash is normalized to a forward slash by some browsers, so
|
|
1588
|
-
// `/\evil.test` is another way to spell the case above.
|
|
1589
|
-
path.startsWith("/\\") || blockedPrefixes.some((prefix) => path.startsWith(prefix)) || ASSET_EXTENSIONS.test(path.split("?")[0] ?? path)) {
|
|
1590
|
-
return fallback;
|
|
1591
|
-
}
|
|
1592
|
-
return path;
|
|
1593
|
-
}
|
|
1594
|
-
__name(getSafeRedirectPath, "getSafeRedirectPath");
|
|
1595
|
-
|
|
1596
1447
|
// src/client/server/authCookiePersistence.ts
|
|
1597
1448
|
var DEFAULTS = {
|
|
1598
1449
|
authCookieNames: ["refreshToken", "najm.session"],
|
|
@@ -1742,9 +1593,9 @@ function withAuthCookiePersistence(handler, options = {}) {
|
|
|
1742
1593
|
statusText: response.statusText
|
|
1743
1594
|
});
|
|
1744
1595
|
}, "applyAction");
|
|
1745
|
-
return async (request) => {
|
|
1596
|
+
return async (request, ...args) => {
|
|
1746
1597
|
let action = await resolveAction(request);
|
|
1747
|
-
const response = await handler(request);
|
|
1598
|
+
const response = await handler(request, ...args);
|
|
1748
1599
|
if (!response.ok) return response;
|
|
1749
1600
|
if (action?.type === "apply" && loginPaths.includes(new URL(request.url).pathname)) {
|
|
1750
1601
|
const payload = await response.clone().json().catch(() => null);
|
|
@@ -1761,6 +1612,176 @@ function withAuthCookiePersistence(handler, options = {}) {
|
|
|
1761
1612
|
};
|
|
1762
1613
|
}
|
|
1763
1614
|
__name(withAuthCookiePersistence, "withAuthCookiePersistence");
|
|
1615
|
+
|
|
1616
|
+
// src/client/server/defineAuth.ts
|
|
1617
|
+
function defineAuth(authConfig = {}) {
|
|
1618
|
+
const {
|
|
1619
|
+
apiBaseURL = "/api",
|
|
1620
|
+
authPrefix = "/auth",
|
|
1621
|
+
loginRoute = "/login",
|
|
1622
|
+
forbiddenRoute = "/forbidden",
|
|
1623
|
+
publicRoutes = [],
|
|
1624
|
+
protectedRoutes = [],
|
|
1625
|
+
roleRoutes = {},
|
|
1626
|
+
cookieName: cookieName2 = "refreshToken",
|
|
1627
|
+
sessionCookieName = "najm.session",
|
|
1628
|
+
sessionSecret,
|
|
1629
|
+
sessionMaxAge,
|
|
1630
|
+
recoveryURL,
|
|
1631
|
+
internalRecoveryURL,
|
|
1632
|
+
matcher = ["/((?!_next/static|_next/image|favicon.ico|api).*)"],
|
|
1633
|
+
verifyAlways,
|
|
1634
|
+
proxySessionMode,
|
|
1635
|
+
onRecoveryFailure,
|
|
1636
|
+
refreshThreshold,
|
|
1637
|
+
tabSync,
|
|
1638
|
+
channelName,
|
|
1639
|
+
timeout,
|
|
1640
|
+
retry
|
|
1641
|
+
} = authConfig;
|
|
1642
|
+
const sessionConfig = {
|
|
1643
|
+
baseURL: apiBaseURL,
|
|
1644
|
+
authPrefix,
|
|
1645
|
+
cookieName: cookieName2,
|
|
1646
|
+
sessionCookieName,
|
|
1647
|
+
sessionSecret,
|
|
1648
|
+
sessionMaxAge,
|
|
1649
|
+
recoveryURL,
|
|
1650
|
+
internalRecoveryURL,
|
|
1651
|
+
onRecoveryFailure
|
|
1652
|
+
};
|
|
1653
|
+
let _client = null;
|
|
1654
|
+
const getClient = /* @__PURE__ */ __name(() => {
|
|
1655
|
+
if (_client) return _client;
|
|
1656
|
+
_client = createAuthClient({
|
|
1657
|
+
baseURL: apiBaseURL,
|
|
1658
|
+
authPrefix,
|
|
1659
|
+
refreshThreshold,
|
|
1660
|
+
tabSync,
|
|
1661
|
+
channelName,
|
|
1662
|
+
timeout,
|
|
1663
|
+
retry
|
|
1664
|
+
});
|
|
1665
|
+
return _client;
|
|
1666
|
+
}, "getClient");
|
|
1667
|
+
const getSession2 = /* @__PURE__ */ __name(async (opts) => {
|
|
1668
|
+
const { getSession: resolveSession } = await Promise.resolve().then(() => (init_getSession(), getSession_exports));
|
|
1669
|
+
return resolveSession({ ...sessionConfig, ...opts });
|
|
1670
|
+
}, "getSession");
|
|
1671
|
+
const resolveSessionOutcome2 = /* @__PURE__ */ __name(async () => {
|
|
1672
|
+
const { resolveSessionOutcome: resolve } = await Promise.resolve().then(() => (init_getSession(), getSession_exports));
|
|
1673
|
+
return resolve(sessionConfig);
|
|
1674
|
+
}, "resolveSessionOutcome");
|
|
1675
|
+
const requireSession = /* @__PURE__ */ __name(async () => {
|
|
1676
|
+
const outcome = await resolveSessionOutcome2();
|
|
1677
|
+
if (outcome.status === "authenticated") return outcome.session;
|
|
1678
|
+
if (redirectsToLogin(outcome)) {
|
|
1679
|
+
const { redirect } = await import("next/navigation");
|
|
1680
|
+
redirect(loginRoute);
|
|
1681
|
+
}
|
|
1682
|
+
throw outcome.error;
|
|
1683
|
+
}, "requireSession");
|
|
1684
|
+
const requireRole = /* @__PURE__ */ __name(async (roles) => {
|
|
1685
|
+
const session = await requireSession();
|
|
1686
|
+
if (!heldRoles(session).some((role) => roles.includes(role))) {
|
|
1687
|
+
const { redirect } = await import("next/navigation");
|
|
1688
|
+
redirect(forbiddenRoute);
|
|
1689
|
+
}
|
|
1690
|
+
return session;
|
|
1691
|
+
}, "requireRole");
|
|
1692
|
+
const middleware = withAuthMiddleware({
|
|
1693
|
+
protectedRoutes,
|
|
1694
|
+
publicRoutes,
|
|
1695
|
+
loginRoute,
|
|
1696
|
+
roleRoutes,
|
|
1697
|
+
cookieName: cookieName2,
|
|
1698
|
+
apiBaseURL,
|
|
1699
|
+
authPrefix,
|
|
1700
|
+
sessionCookieName,
|
|
1701
|
+
sessionSecret,
|
|
1702
|
+
sessionMaxAge,
|
|
1703
|
+
recoveryURL,
|
|
1704
|
+
internalRecoveryURL,
|
|
1705
|
+
verifyAlways,
|
|
1706
|
+
proxySessionMode,
|
|
1707
|
+
onRecoveryFailure
|
|
1708
|
+
});
|
|
1709
|
+
const routeHandlers = /* @__PURE__ */ __name((handler, options = {}) => {
|
|
1710
|
+
const persistentHandler = withAuthCookiePersistence(handler, {
|
|
1711
|
+
...options,
|
|
1712
|
+
authCookieNames: options.authCookieNames ?? [cookieName2, sessionCookieName]
|
|
1713
|
+
});
|
|
1714
|
+
return {
|
|
1715
|
+
GET: persistentHandler,
|
|
1716
|
+
POST: persistentHandler,
|
|
1717
|
+
PUT: persistentHandler,
|
|
1718
|
+
PATCH: persistentHandler,
|
|
1719
|
+
DELETE: persistentHandler,
|
|
1720
|
+
HEAD: persistentHandler,
|
|
1721
|
+
OPTIONS: persistentHandler
|
|
1722
|
+
};
|
|
1723
|
+
}, "routeHandlers");
|
|
1724
|
+
const protect = /* @__PURE__ */ __name((Page, options) => {
|
|
1725
|
+
return /* @__PURE__ */ __name(async function ProtectedPage(props) {
|
|
1726
|
+
const session = await getSession2();
|
|
1727
|
+
if (!session) {
|
|
1728
|
+
const { redirect } = await import("next/navigation");
|
|
1729
|
+
redirect(loginRoute);
|
|
1730
|
+
}
|
|
1731
|
+
if (options?.role) {
|
|
1732
|
+
if (!heldRoles(session).includes(options.role)) {
|
|
1733
|
+
const { redirect } = await import("next/navigation");
|
|
1734
|
+
redirect(forbiddenRoute);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
if (options?.permission) {
|
|
1738
|
+
const { matchPermission: matchPermission2 } = await Promise.resolve().then(() => (init_permissions(), permissions_exports));
|
|
1739
|
+
const perms = session.permissions ?? session.user.permissions ?? [];
|
|
1740
|
+
if (!matchPermission2(perms, options.permission)) {
|
|
1741
|
+
const { redirect } = await import("next/navigation");
|
|
1742
|
+
redirect(forbiddenRoute);
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
return Page({ session, ...props });
|
|
1746
|
+
}, "ProtectedPage");
|
|
1747
|
+
}, "protect");
|
|
1748
|
+
return attachReactServerInternals({
|
|
1749
|
+
get client() {
|
|
1750
|
+
return getClient();
|
|
1751
|
+
},
|
|
1752
|
+
get api() {
|
|
1753
|
+
return getClient().api;
|
|
1754
|
+
},
|
|
1755
|
+
getSession: getSession2,
|
|
1756
|
+
requireSession,
|
|
1757
|
+
requireRole,
|
|
1758
|
+
proxy: middleware,
|
|
1759
|
+
middleware,
|
|
1760
|
+
config: { matcher },
|
|
1761
|
+
routeHandlers,
|
|
1762
|
+
protect
|
|
1763
|
+
}, { resolveSessionOutcome: resolveSessionOutcome2, loginRoute, forbiddenRoute });
|
|
1764
|
+
}
|
|
1765
|
+
__name(defineAuth, "defineAuth");
|
|
1766
|
+
|
|
1767
|
+
// src/client/server/safeRedirect.ts
|
|
1768
|
+
var DEFAULT_BLOCKED_PREFIXES = ["/api", "/login", "/_next"];
|
|
1769
|
+
var ASSET_EXTENSIONS = /\.(?:css|gif|ico|jpe?g|js|json|map|png|svg|webmanifest|webp)$/i;
|
|
1770
|
+
function getSafeRedirectPath(value, options = {}) {
|
|
1771
|
+
const {
|
|
1772
|
+
fallback = "/dashboard",
|
|
1773
|
+
blockedPrefixes = DEFAULT_BLOCKED_PREFIXES
|
|
1774
|
+
} = typeof options === "string" ? { fallback: options } : options;
|
|
1775
|
+
const path = Array.isArray(value) ? value[0] : value;
|
|
1776
|
+
if (!path || !path.startsWith("/") || // Protocol-relative: the browser treats `//host/x` as off-site.
|
|
1777
|
+
path.startsWith("//") || // A backslash is normalized to a forward slash by some browsers, so
|
|
1778
|
+
// `/\evil.test` is another way to spell the case above.
|
|
1779
|
+
path.startsWith("/\\") || blockedPrefixes.some((prefix) => path.startsWith(prefix)) || ASSET_EXTENSIONS.test(path.split("?")[0] ?? path)) {
|
|
1780
|
+
return fallback;
|
|
1781
|
+
}
|
|
1782
|
+
return path;
|
|
1783
|
+
}
|
|
1784
|
+
__name(getSafeRedirectPath, "getSafeRedirectPath");
|
|
1764
1785
|
export {
|
|
1765
1786
|
AuthConfigError,
|
|
1766
1787
|
AuthTransportError,
|
package/dist/index.d.ts
CHANGED
|
@@ -169,6 +169,8 @@ interface AuthConfig {
|
|
|
169
169
|
frontendUrl: string;
|
|
170
170
|
/** Registration mode: 'active' auto-activates, 'pending' requires admin approval (default: 'active') */
|
|
171
171
|
registrationMode: 'active' | 'pending';
|
|
172
|
+
/** Whether the unauthenticated POST /auth/register route is mounted. */
|
|
173
|
+
publicRegistration: boolean;
|
|
172
174
|
/** When true, users with emailVerified=false are blocked from logging in (default: false) */
|
|
173
175
|
requireVerifiedEmail: boolean;
|
|
174
176
|
/** Cookie path for the refresh token. Scope to the refresh endpoint to limit exposure (default: '/') */
|
|
@@ -234,6 +236,13 @@ type AuthPluginConfig = {
|
|
|
234
236
|
frontendUrl?: string;
|
|
235
237
|
/** Registration mode: 'active' auto-activates new users, 'pending' requires admin approval (default: 'active') */
|
|
236
238
|
registrationMode?: 'active' | 'pending';
|
|
239
|
+
/**
|
|
240
|
+
* Mount the unauthenticated POST /auth/register route (default: true for
|
|
241
|
+
* backwards compatibility). Set false when onboarding belongs to an
|
|
242
|
+
* application-owned approval flow. Internal AuthService provisioning stays
|
|
243
|
+
* available.
|
|
244
|
+
*/
|
|
245
|
+
publicRegistration?: boolean;
|
|
237
246
|
/** Block login for users whose email is not verified (default: false) */
|
|
238
247
|
requireVerifiedEmail?: boolean;
|
|
239
248
|
/** Cookie path for the refresh token (default: '/'). Set e.g. '/auth' to keep it off unrelated routes. */
|
|
@@ -705,6 +714,7 @@ declare class UserValidator {
|
|
|
705
714
|
* Check if user exists by email
|
|
706
715
|
*/
|
|
707
716
|
checkUserExistsByEmail(email: string): Promise<{
|
|
717
|
+
password: string;
|
|
708
718
|
id: string;
|
|
709
719
|
name: string;
|
|
710
720
|
createdAt: string;
|
|
@@ -713,9 +723,8 @@ declare class UserValidator {
|
|
|
713
723
|
emailVerified: boolean;
|
|
714
724
|
phone: string;
|
|
715
725
|
phoneVerified: boolean;
|
|
716
|
-
password: string;
|
|
717
726
|
image: string;
|
|
718
|
-
status: "active" | "
|
|
727
|
+
status: "active" | "pending" | "inactive";
|
|
719
728
|
roleId: string;
|
|
720
729
|
lastLogin: string;
|
|
721
730
|
failedLoginAttempts: number;
|
|
@@ -727,6 +736,7 @@ declare class UserValidator {
|
|
|
727
736
|
* Check if email exists in database
|
|
728
737
|
*/
|
|
729
738
|
checkEmailExists(email: string): Promise<{
|
|
739
|
+
password: string;
|
|
730
740
|
id: string;
|
|
731
741
|
name: string;
|
|
732
742
|
createdAt: string;
|
|
@@ -735,9 +745,8 @@ declare class UserValidator {
|
|
|
735
745
|
emailVerified: boolean;
|
|
736
746
|
phone: string;
|
|
737
747
|
phoneVerified: boolean;
|
|
738
|
-
password: string;
|
|
739
748
|
image: string;
|
|
740
|
-
status: "active" | "
|
|
749
|
+
status: "active" | "pending" | "inactive";
|
|
741
750
|
roleId: string;
|
|
742
751
|
lastLogin: string;
|
|
743
752
|
failedLoginAttempts: number;
|
|
@@ -1260,8 +1269,8 @@ declare const createUserDto: z.ZodObject<{
|
|
|
1260
1269
|
emailVerified: z.ZodDefault<z.ZodBoolean>;
|
|
1261
1270
|
status: z.ZodOptional<z.ZodEnum<{
|
|
1262
1271
|
active: "active";
|
|
1263
|
-
inactive: "inactive";
|
|
1264
1272
|
pending: "pending";
|
|
1273
|
+
inactive: "inactive";
|
|
1265
1274
|
}>>;
|
|
1266
1275
|
}, z.core.$strip>;
|
|
1267
1276
|
declare const updateUserDto: z.ZodObject<{
|
|
@@ -1273,8 +1282,8 @@ declare const updateUserDto: z.ZodObject<{
|
|
|
1273
1282
|
emailVerified: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
1274
1283
|
status: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
|
|
1275
1284
|
active: "active";
|
|
1276
|
-
inactive: "inactive";
|
|
1277
1285
|
pending: "pending";
|
|
1286
|
+
inactive: "inactive";
|
|
1278
1287
|
}>>>;
|
|
1279
1288
|
}, z.core.$strip>;
|
|
1280
1289
|
declare const registerDto: z.ZodObject<{
|
|
@@ -1652,9 +1661,9 @@ declare const authIdentityRateLimitKey: (ctx: Context) => Promise<string>;
|
|
|
1652
1661
|
declare class AuthController {
|
|
1653
1662
|
private authService;
|
|
1654
1663
|
constructor(authService: AuthService);
|
|
1655
|
-
registerUser(body: RegisterDto): Promise<SanitizedUser>;
|
|
1656
1664
|
loginUser(body: LoginDto): Promise<LoginResult>;
|
|
1657
1665
|
inviteUser(body: InviteUserDto): Promise<Omit<{
|
|
1666
|
+
password: string;
|
|
1658
1667
|
id: string;
|
|
1659
1668
|
name: string;
|
|
1660
1669
|
createdAt: string;
|
|
@@ -1663,9 +1672,8 @@ declare class AuthController {
|
|
|
1663
1672
|
emailVerified: boolean;
|
|
1664
1673
|
phone: string;
|
|
1665
1674
|
phoneVerified: boolean;
|
|
1666
|
-
password: string;
|
|
1667
1675
|
image: string;
|
|
1668
|
-
status: "active" | "
|
|
1676
|
+
status: "active" | "pending" | "inactive";
|
|
1669
1677
|
roleId: string;
|
|
1670
1678
|
lastLogin: string;
|
|
1671
1679
|
failedLoginAttempts: number;
|
|
@@ -1688,6 +1696,7 @@ declare class AuthController {
|
|
|
1688
1696
|
message: string;
|
|
1689
1697
|
}>;
|
|
1690
1698
|
userProfile(authorization?: string): Promise<Omit<{
|
|
1699
|
+
password: string;
|
|
1691
1700
|
id: string;
|
|
1692
1701
|
name: string;
|
|
1693
1702
|
createdAt: string;
|
|
@@ -1696,9 +1705,8 @@ declare class AuthController {
|
|
|
1696
1705
|
emailVerified: boolean;
|
|
1697
1706
|
phone: string;
|
|
1698
1707
|
phoneVerified: boolean;
|
|
1699
|
-
password: string;
|
|
1700
1708
|
image: string;
|
|
1701
|
-
status: "active" | "
|
|
1709
|
+
status: "active" | "pending" | "inactive";
|
|
1702
1710
|
roleId: string;
|
|
1703
1711
|
lastLogin: string;
|
|
1704
1712
|
failedLoginAttempts: number;
|
|
@@ -1772,6 +1780,17 @@ declare class AuthIdentityContextService {
|
|
|
1772
1780
|
configure(): Promise<void>;
|
|
1773
1781
|
}
|
|
1774
1782
|
|
|
1783
|
+
/**
|
|
1784
|
+
* Public self-registration is isolated from the rest of the auth transport so
|
|
1785
|
+
* applications can omit this controller without disabling internal account
|
|
1786
|
+
* provisioning through AuthService.
|
|
1787
|
+
*/
|
|
1788
|
+
declare class RegistrationController {
|
|
1789
|
+
private authService;
|
|
1790
|
+
constructor(authService: AuthService);
|
|
1791
|
+
registerUser(body: RegisterDto): Promise<SanitizedUser>;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1775
1794
|
type IdentityResolver = (value: unknown) => string | null;
|
|
1776
1795
|
/**
|
|
1777
1796
|
* Build the identifier pipeline used by login lookup, lockout accounting, and
|
|
@@ -1811,7 +1830,10 @@ interface RunAsUser {
|
|
|
1811
1830
|
}
|
|
1812
1831
|
declare function runAsUser<T>(container: Container, user: RunAsUser, fn: () => Promise<T> | T): Promise<T>;
|
|
1813
1832
|
|
|
1814
|
-
declare const
|
|
1833
|
+
declare const AUTH_CORE_MODULE: readonly [typeof AuthService, typeof AuthSessionService, typeof CookieManager, typeof EncryptionService, typeof AuthGuard, typeof AuthController, typeof AuthResolver, typeof AuthIdentityContextService];
|
|
1834
|
+
declare const PUBLIC_REGISTRATION_MODULE: readonly [typeof RegistrationController];
|
|
1835
|
+
/** Full module retained for consumers that register the exported module directly. */
|
|
1836
|
+
declare const AUTH_MODULE: readonly [typeof AuthService, typeof AuthSessionService, typeof CookieManager, typeof EncryptionService, typeof AuthGuard, typeof AuthController, typeof AuthResolver, typeof AuthIdentityContextService, typeof RegistrationController];
|
|
1815
1837
|
|
|
1816
1838
|
declare class PermissionRepository {
|
|
1817
1839
|
db: TDb;
|
|
@@ -2765,4 +2787,4 @@ declare const authSeed: (config: AuthSeedConfig) => Record<string, SeedEntry>;
|
|
|
2765
2787
|
*/
|
|
2766
2788
|
declare function seedAuthData(config: SeedAuthDataConfig): Promise<SeedAuthDataResult>;
|
|
2767
2789
|
|
|
2768
|
-
export { AUTH_CONFIG, en as AUTH_EN, AUTH_LOCALES, AUTH_LOGIN_RATE_LIMIT_ENV, AUTH_MODULE, AUTH_PERMISSIONS, AUTH_ROLE, AUTH_SCHEMA, AUTH_SUPPORTED_LANGUAGES, AUTH_USER, type AssignPermissionDto, type AssignRoleDto, type AssignRoleParams, type AuthConfig, AuthController, AuthGuard, type AuthLoginRateLimitConfig, type AuthPluginConfig, AuthQueries, type AuthRateLimitEnvironment, AuthResolver, type AuthSchema, type AuthSeedConfig, AuthService, AuthSessionService, type AuthUser, CREDENTIAL_SETUP_CODES, CREDENTIAL_SETUP_MODULE, Can, CanCreate, CanDelete, CanList, CanRead, CanUpdate, type ChainableGuard, type ChangePasswordDto, type CheckPermissionDto, type ConfiguredOwnership, type ConfirmResetPasswordDto, CookieManager, type CreatePermissionDto, type CreateRoleDto, type CreateTokenDto, type CreateUserDto, type CredentialSetupChangeDto, type CredentialSetupCode, type CredentialSetupConfig, CredentialSetupController, type CredentialSetupOptions, type CredentialSetupPasswordOptions, type CredentialSetupPending, CredentialSetupRepository, CredentialSetupRequirementRepository, type CredentialSetupRequirementRow, CredentialSetupRequirementService, CredentialSetupService, type CredentialSetupSessionInfo, type CredentialSetupStarted, DEFAULT_AUTH_LOGIN_RATE_LIMIT, DEFAULT_CREDENTIAL_SETUP_COOKIE_NAME, DEFAULT_CREDENTIAL_SETUP_TTL_MS, type DefineRolesOptions, type EmailParam, EncryptionService, type GoogleOAuthConfig, IdentityConfig, type IdentityResolver, type InviteUserDto, type JwtConfig, type JwtPayload, type LanguageParam, type LoginDto, type LoginResult, NewPermission, NewRoleEntity, NewUser, type OAuthConfig, type OAuthProvider, Owned, type OwnedMethods, type OwnershipConfig, type OwnershipProvider, type OwnershipRule, OwnershipToken, type OwnershipTokenOptions, PASSWORD_SETUP_PURPOSE, PasswordSetupService, Permission, PermissionController, PermissionGuard, type PermissionIdParam, PermissionRepository, PermissionService, PermissionValidator, Policy, type ProvisionUserInput, type ProvisionUserWithPasswordInput, type ProvisionUserWithSetupInput, ROLES, ROLE_GROUPS, type RefreshTokenDto, type RegisterDto, type ResetPasswordDto, type ResolvedCredentialSetupConfig, ResolvedIdentityConfig, type ResourceAccessor, type ResourceGuards, type ResourceGuardsOptions, type RevokeTokenDto, Role, RoleController, RoleEntity, RoleGuard, type RoleIdParam, type RoleInput, RolePermission, RoleRepository, RoleService, type RoleType, RoleValidator, type RunAsUser, type SanitizedUser, ScopeContext, type ScopeResult, type SeedAuthDataConfig, type SeedAuthDataResult, type SeedUserConfig, type SessionCookieData, TOKEN_STATUS, TOKEN_TYPE, TemporaryCredentialInput, type TokenIdParam, type TokenPair, TokenRepository, TokenService, USER_STATUS, type UpdatePermissionDto, type UpdateRoleDto, type UpdateTokenDto, type UpdateUserDto, User, UserController, type UserIdInParam, type UserIdParam, type UserListQuery, UserRepository, UserService, UserValidator, type UserWithPermissions, type VerifyTokenDto, assignPermissionDto, assignRoleDto, assignRoleParams, auth$1 as auth, authIdentityRateLimitKey, authSeed, avatarsPath, calculateAge, calculateYearsOfExperience, changePasswordDto, checkPermissionDto, clean, configureOwnership, confirmResetPasswordDto, createIdentityResolver, createPermissionDto, createRoleDto, createTokenDto, createUserDto, credentialSetupChangeDto, credentialSetupError, defaultCredentialSetupPasswordSchema, defineRoles, emailParam, formatDate, getAuthLocale, getAvatarFile, inviteUserDto, isAdmin, isAdministrator, isAuth, isEmailIdentifier, isEmpty, isFile, isPath, join, languageParam, loginDto, normalizeAuthIdentifier, normalizeSetupPurpose, own, parseSchema, permissionIdParam, pickProps, refreshTokenDto, registerDto, resetPasswordDto, resolveAuthLoginRateLimitConfig, revokeTokenDto, roleIdParam, runAsUser, seedAuthData, tokenIdParam, updatePermissionDto, updateRoleDto, updateTokenDto, updateUserDto, userIdInParam, userIdParam, userListQuery, verifyTokenDto, where };
|
|
2790
|
+
export { AUTH_CONFIG, AUTH_CORE_MODULE, en as AUTH_EN, AUTH_LOCALES, AUTH_LOGIN_RATE_LIMIT_ENV, AUTH_MODULE, AUTH_PERMISSIONS, AUTH_ROLE, AUTH_SCHEMA, AUTH_SUPPORTED_LANGUAGES, AUTH_USER, type AssignPermissionDto, type AssignRoleDto, type AssignRoleParams, type AuthConfig, AuthController, AuthGuard, type AuthLoginRateLimitConfig, type AuthPluginConfig, AuthQueries, type AuthRateLimitEnvironment, AuthResolver, type AuthSchema, type AuthSeedConfig, AuthService, AuthSessionService, type AuthUser, CREDENTIAL_SETUP_CODES, CREDENTIAL_SETUP_MODULE, Can, CanCreate, CanDelete, CanList, CanRead, CanUpdate, type ChainableGuard, type ChangePasswordDto, type CheckPermissionDto, type ConfiguredOwnership, type ConfirmResetPasswordDto, CookieManager, type CreatePermissionDto, type CreateRoleDto, type CreateTokenDto, type CreateUserDto, type CredentialSetupChangeDto, type CredentialSetupCode, type CredentialSetupConfig, CredentialSetupController, type CredentialSetupOptions, type CredentialSetupPasswordOptions, type CredentialSetupPending, CredentialSetupRepository, CredentialSetupRequirementRepository, type CredentialSetupRequirementRow, CredentialSetupRequirementService, CredentialSetupService, type CredentialSetupSessionInfo, type CredentialSetupStarted, DEFAULT_AUTH_LOGIN_RATE_LIMIT, DEFAULT_CREDENTIAL_SETUP_COOKIE_NAME, DEFAULT_CREDENTIAL_SETUP_TTL_MS, type DefineRolesOptions, type EmailParam, EncryptionService, type GoogleOAuthConfig, IdentityConfig, type IdentityResolver, type InviteUserDto, type JwtConfig, type JwtPayload, type LanguageParam, type LoginDto, type LoginResult, NewPermission, NewRoleEntity, NewUser, type OAuthConfig, type OAuthProvider, Owned, type OwnedMethods, type OwnershipConfig, type OwnershipProvider, type OwnershipRule, OwnershipToken, type OwnershipTokenOptions, PASSWORD_SETUP_PURPOSE, PUBLIC_REGISTRATION_MODULE, PasswordSetupService, Permission, PermissionController, PermissionGuard, type PermissionIdParam, PermissionRepository, PermissionService, PermissionValidator, Policy, type ProvisionUserInput, type ProvisionUserWithPasswordInput, type ProvisionUserWithSetupInput, ROLES, ROLE_GROUPS, type RefreshTokenDto, type RegisterDto, RegistrationController, type ResetPasswordDto, type ResolvedCredentialSetupConfig, ResolvedIdentityConfig, type ResourceAccessor, type ResourceGuards, type ResourceGuardsOptions, type RevokeTokenDto, Role, RoleController, RoleEntity, RoleGuard, type RoleIdParam, type RoleInput, RolePermission, RoleRepository, RoleService, type RoleType, RoleValidator, type RunAsUser, type SanitizedUser, ScopeContext, type ScopeResult, type SeedAuthDataConfig, type SeedAuthDataResult, type SeedUserConfig, type SessionCookieData, TOKEN_STATUS, TOKEN_TYPE, TemporaryCredentialInput, type TokenIdParam, type TokenPair, TokenRepository, TokenService, USER_STATUS, type UpdatePermissionDto, type UpdateRoleDto, type UpdateTokenDto, type UpdateUserDto, User, UserController, type UserIdInParam, type UserIdParam, type UserListQuery, UserRepository, UserService, UserValidator, type UserWithPermissions, type VerifyTokenDto, assignPermissionDto, assignRoleDto, assignRoleParams, auth$1 as auth, authIdentityRateLimitKey, authSeed, avatarsPath, calculateAge, calculateYearsOfExperience, changePasswordDto, checkPermissionDto, clean, configureOwnership, confirmResetPasswordDto, createIdentityResolver, createPermissionDto, createRoleDto, createTokenDto, createUserDto, credentialSetupChangeDto, credentialSetupError, defaultCredentialSetupPasswordSchema, defineRoles, emailParam, formatDate, getAuthLocale, getAvatarFile, inviteUserDto, isAdmin, isAdministrator, isAuth, isEmailIdentifier, isEmpty, isFile, isPath, join, languageParam, loginDto, normalizeAuthIdentifier, normalizeSetupPurpose, own, parseSchema, permissionIdParam, pickProps, refreshTokenDto, registerDto, resetPasswordDto, resolveAuthLoginRateLimitConfig, revokeTokenDto, roleIdParam, runAsUser, seedAuthData, tokenIdParam, updatePermissionDto, updateRoleDto, updateTokenDto, updateUserDto, userIdInParam, userIdParam, userListQuery, verifyTokenDto, where };
|