@mesob/auth-hono 0.4.1 → 0.4.2

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.
@@ -1,7 +1,7 @@
1
1
  import * as hono from 'hono';
2
2
  import { OpenAPIHono } from '@hono/zod-openapi';
3
3
  import { PermissionTree } from '@mesob/common';
4
- import { D as Database } from './index-zShda6U3.js';
4
+ import { D as Database } from './index-Cb7JZobZ.js';
5
5
 
6
6
  type SessionStatus = 'valid' | 'no_cookie' | 'invalid_session' | 'user_not_found' | 'error';
7
7
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { A as AuthConfig, M as MesobAuth } from './index-CKOeabpa.js';
2
- export { a as SendInvitationParams, b as SendVerificationOTPParams, c as Session, S as SessionStatus, U as User } from './index-CKOeabpa.js';
3
- import { D as Database } from './index-zShda6U3.js';
4
- export { c as createDatabase } from './index-zShda6U3.js';
1
+ import { A as AuthConfig, M as MesobAuth } from './index-BNJj_z2x.js';
2
+ export { a as SendInvitationParams, b as SendVerificationOTPParams, c as Session, S as SessionStatus, U as User } from './index-BNJj_z2x.js';
3
+ import { D as Database } from './index-Cb7JZobZ.js';
4
+ export { c as createDatabase } from './index-Cb7JZobZ.js';
5
5
  export { cleanupExpiredData, cleanupExpiredSessions, cleanupExpiredVerifications } from './lib/cleanup.js';
6
6
  export { hasPermission, hasPermissionThrow, hasRole, hasRoleThrow } from './lib/has-role-permission.js';
7
7
  import * as hono from 'hono';
package/dist/index.js CHANGED
@@ -1056,17 +1056,17 @@ var checkAccountHandler = async (c) => {
1056
1056
  email: usersInIam.email,
1057
1057
  phone: usersInIam.phone,
1058
1058
  verified: isEmail ? usersInIam.emailVerified : usersInIam.phoneVerified,
1059
- password: accountsInIam.password
1060
- }).from(usersInIam).leftJoin(
1061
- accountsInIam,
1062
- and5(
1063
- eq5(accountsInIam.tenantId, resolvedTenantId),
1064
- eq5(accountsInIam.userId, usersInIam.id),
1065
- eq5(accountsInIam.provider, "credentials")
1066
- )
1067
- ).where(whereClause).limit(1);
1059
+ hasPassword: sql4`exists(
1060
+ select 1
1061
+ from ${accountsInIam}
1062
+ where ${accountsInIam.tenantId} = ${resolvedTenantId}
1063
+ and ${accountsInIam.userId} = ${usersInIam.id}
1064
+ and ${accountsInIam.provider} = 'credentials'
1065
+ and ${accountsInIam.password} is not null
1066
+ )`
1067
+ }).from(usersInIam).where(whereClause).limit(1);
1068
1068
  const verified = result?.verified ?? false;
1069
- const hasPassword = Boolean(result?.password);
1069
+ const hasPassword = result?.hasPassword ?? false;
1070
1070
  return c.json(
1071
1071
  {
1072
1072
  exists: !!result,
@@ -1416,15 +1416,15 @@ var fetchUserForLogin = async ({
1416
1416
  lastSignInAt: usersInIam.lastSignInAt,
1417
1417
  bannedUntil: usersInIam.bannedUntil,
1418
1418
  loginAttempt: usersInIam.loginAttempt,
1419
- hasPassword: sql6`coalesce(${accountsInIam.password} is not null, false)`
1420
- }).from(usersInIam).leftJoin(
1421
- accountsInIam,
1422
- and7(
1423
- eq7(accountsInIam.tenantId, tenantId),
1424
- eq7(accountsInIam.userId, usersInIam.id),
1425
- eq7(accountsInIam.provider, "credentials")
1426
- )
1427
- ).where(whereClause).limit(1);
1419
+ hasPassword: sql6`exists(
1420
+ select 1
1421
+ from ${accountsInIam}
1422
+ where ${accountsInIam.tenantId} = ${tenantId}
1423
+ and ${accountsInIam.userId} = ${usersInIam.id}
1424
+ and ${accountsInIam.provider} = 'credentials'
1425
+ and ${accountsInIam.password} is not null
1426
+ )`
1427
+ }).from(usersInIam).where(whereClause).limit(1);
1428
1428
  return row || null;
1429
1429
  };
1430
1430
  var fetchUserByIdWithRoles = async ({