agentlang 0.0.62 → 0.0.64

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.
@@ -324,7 +324,7 @@ export async function createUser(
324
324
  'CreateUser',
325
325
  {
326
326
  id: id,
327
- email: email,
327
+ email: email.toLowerCase(),
328
328
  firstName: firstName,
329
329
  lastName: lastName,
330
330
  },
@@ -346,7 +346,7 @@ export async function findUserByEmail(email: string, env: Environment): Promise<
346
346
  return await evalEvent(
347
347
  'FindUserByEmail',
348
348
  {
349
- email: email,
349
+ email: email.toLowerCase(),
350
350
  },
351
351
  env
352
352
  );
@@ -375,7 +375,7 @@ export async function ensureUser(
375
375
  lastName: string,
376
376
  env: Environment
377
377
  ) {
378
- const user = await findUserByEmail(email, env);
378
+ const user = await findUserByEmail(email.toLowerCase(), env);
379
379
  if (user) {
380
380
  // Update existing user with latest name information from ID token
381
381
  const userId = user.lookup('id');
@@ -384,7 +384,7 @@ export async function ensureUser(
384
384
  });
385
385
  return user;
386
386
  }
387
- return await createUser(crypto.randomUUID(), email, firstName, lastName, env);
387
+ return await createUser(crypto.randomUUID(), email.toLowerCase(), firstName, lastName, env);
388
388
  }
389
389
 
390
390
  export async function ensureUserRoles(userid: string, userRoles: string[], env: Environment) {
@@ -543,12 +543,14 @@ export async function assignUserToRoleByEmail(
543
543
  env: Environment
544
544
  ): Promise<boolean> {
545
545
  let r: boolean = true;
546
- await evalEvent('AssignUserToRoleByEmail', { email: email, roleName: roleName }, env).catch(
547
- (reason: any) => {
548
- logger.error(`Failed to assign user ${email} to role ${roleName} - ${reason}`);
549
- r = false;
550
- }
551
- );
546
+ await evalEvent(
547
+ 'AssignUserToRoleByEmail',
548
+ { email: email.toLowerCase(), roleName: roleName },
549
+ env
550
+ ).catch((reason: any) => {
551
+ logger.error(`Failed to assign user ${email} to role ${roleName} - ${reason}`);
552
+ r = false;
553
+ });
552
554
  return r;
553
555
  }
554
556
 
@@ -719,7 +721,7 @@ export async function signUpUser(
719
721
  await fetchAuthImpl().signUp(
720
722
  firstName,
721
723
  lastName,
722
- username,
724
+ username.toLowerCase(),
723
725
  password,
724
726
  userData ? new Map(Object.entries(userData)) : undefined,
725
727
  env,
@@ -740,7 +742,7 @@ export async function confirmSignupUser(
740
742
  env: Environment
741
743
  ): Promise<Result> {
742
744
  try {
743
- await fetchAuthImpl().confirmSignup(username, confirmationCode, env);
745
+ await fetchAuthImpl().confirmSignup(username.toLowerCase(), confirmationCode, env);
744
746
  return {
745
747
  status: 'ok',
746
748
  message: 'User confirmed successfully',
@@ -756,7 +758,7 @@ export async function resendConfirmationCodeUser(
756
758
  env: Environment
757
759
  ): Promise<Result> {
758
760
  try {
759
- await fetchAuthImpl().resendConfirmationCode(username, env);
761
+ await fetchAuthImpl().resendConfirmationCode(username.toLowerCase(), env);
760
762
  return {
761
763
  status: 'ok',
762
764
  message: 'Confirmation code resent successfully',
@@ -769,7 +771,7 @@ export async function resendConfirmationCodeUser(
769
771
 
770
772
  export async function forgotPasswordUser(username: string, env: Environment): Promise<Result> {
771
773
  try {
772
- await fetchAuthImpl().forgotPassword(username, env);
774
+ await fetchAuthImpl().forgotPassword(username.toLowerCase(), env);
773
775
  return { status: 'ok', message: 'Password reset code sent' };
774
776
  } catch (err: any) {
775
777
  logger.error(`Forgot password failed for ${username}: ${err.message}`);
@@ -784,7 +786,12 @@ export async function confirmForgotPasswordUser(
784
786
  env: Environment
785
787
  ): Promise<Result> {
786
788
  try {
787
- await fetchAuthImpl().confirmForgotPassword(username, confirmationCode, newPassword, env);
789
+ await fetchAuthImpl().confirmForgotPassword(
790
+ username.toLowerCase(),
791
+ confirmationCode,
792
+ newPassword,
793
+ env
794
+ );
788
795
  return { status: 'ok', message: 'Password has been reset' };
789
796
  } catch (err: any) {
790
797
  logger.error(`Confirm forgot password failed for ${username}: ${err.message}`);
@@ -799,7 +806,7 @@ export async function loginUser(
799
806
  ): Promise<string | object> {
800
807
  let result: string | object = '';
801
808
  try {
802
- await fetchAuthImpl().login(username, password, env, (r: SessionInfo) => {
809
+ await fetchAuthImpl().login(username.toLowerCase(), password, env, (r: SessionInfo) => {
803
810
  // Check if Cognito is configured by checking if we have the tokens
804
811
  if (r.idToken && r.accessToken && r.refreshToken) {
805
812
  // Return full token response for Cognito
@@ -928,7 +935,7 @@ async function verifyJwtToken(token: string, env?: Environment): Promise<ActiveS
928
935
 
929
936
  let localUser = null;
930
937
  if (email) {
931
- localUser = await findUserByEmail(email, env);
938
+ localUser = await findUserByEmail(email.toLowerCase(), env);
932
939
  }
933
940
 
934
941
  if (!localUser && userId) {
@@ -1026,7 +1033,7 @@ export async function getUserInfoByEmail(email: string, env: Environment): Promi
1026
1033
  env = env ? env : new Environment();
1027
1034
  const f = async () => {
1028
1035
  try {
1029
- return await fetchAuthImpl().getUserByEmail(email, env);
1036
+ return await fetchAuthImpl().getUserByEmail(email.toLowerCase(), env);
1030
1037
  } catch (err: any) {
1031
1038
  logger.error(`Failed to get user info for email ${email}: ${err.message}`);
1032
1039
  throw err; // Re-throw to preserve error type