diff --git a/packages/common/types.ts b/packages/common/types.ts index 1a52037..551a584 100644 --- a/packages/common/types.ts +++ b/packages/common/types.ts @@ -217,6 +217,9 @@ export class RequestBuilder { authRequest.isAnon = false; authRequest.isOptional = authRequest.isOptional ?? false; authRequest.userId = authRequest.userId ?? "0"; + if (authRequest.authType === AuthType.EVM_ACCOUNT) { + authRequest.userId = authRequest.userId.toLowerCase(); + } authRequest.extraData = authRequest.extraData ?? ""; if (authRequest.userId === "0") { diff --git a/packages/sismo-connect-client/src/common-types.ts b/packages/sismo-connect-client/src/common-types.ts index 1a52037..551a584 100644 --- a/packages/sismo-connect-client/src/common-types.ts +++ b/packages/sismo-connect-client/src/common-types.ts @@ -217,6 +217,9 @@ export class RequestBuilder { authRequest.isAnon = false; authRequest.isOptional = authRequest.isOptional ?? false; authRequest.userId = authRequest.userId ?? "0"; + if (authRequest.authType === AuthType.EVM_ACCOUNT) { + authRequest.userId = authRequest.userId.toLowerCase(); + } authRequest.extraData = authRequest.extraData ?? ""; if (authRequest.userId === "0") { diff --git a/packages/sismo-connect-client/tests/sismo-connect.test.ts b/packages/sismo-connect-client/tests/sismo-connect.test.ts index 59bf035..cf1f3d8 100644 --- a/packages/sismo-connect-client/tests/sismo-connect.test.ts +++ b/packages/sismo-connect-client/tests/sismo-connect.test.ts @@ -1,4 +1,11 @@ -import { ClaimRequest, SismoConnect, SismoConnectClient, SismoConnectConfig } from "../src"; +import { + Auth, + AuthType, + ClaimRequest, + SismoConnect, + SismoConnectClient, + SismoConnectConfig, +} from "../src"; describe("Sismo Connect Client", () => { let appId: string; @@ -71,4 +78,24 @@ describe("Sismo Connect Client", () => { `https://vault-beta.sismo.io/connect?version=sismo-connect-v1.1&appId=0xf68985adfc209fafebfb1a956913e7fa&claims=[{\"groupId\":\"0x1\",\"claimType\":0,\"extraData\":\"\",\"groupTimestamp\":\"latest\",\"value\":1}]&vault={\"impersonate\":[\"0x123\",\"0x345\"]}&compressed=true` ); }); + + it("should put EVM account userIds in lower case", async () => { + const requestLink = sismoConnect.getRequestLink({ + auths: [ + { + authType: AuthType.EVM_ACCOUNT, + userId: "0xAa1BcC", + }, + { + authType: AuthType.EVM_ACCOUNT, + userId: "0xDaDBcD", + }, + ], + }); + const url = new URL(requestLink); + let params = new URLSearchParams(url.search); + let auths = JSON.parse(params.get("auths") as string) as Auth[]; + expect(auths[0].userId).toEqual("0xaa1bcc"); + expect(auths[1].userId).toEqual("0xdadbcd"); + }); }); diff --git a/packages/sismo-connect-server/src/common-types.ts b/packages/sismo-connect-server/src/common-types.ts index 1a52037..551a584 100644 --- a/packages/sismo-connect-server/src/common-types.ts +++ b/packages/sismo-connect-server/src/common-types.ts @@ -217,6 +217,9 @@ export class RequestBuilder { authRequest.isAnon = false; authRequest.isOptional = authRequest.isOptional ?? false; authRequest.userId = authRequest.userId ?? "0"; + if (authRequest.authType === AuthType.EVM_ACCOUNT) { + authRequest.userId = authRequest.userId.toLowerCase(); + } authRequest.extraData = authRequest.extraData ?? ""; if (authRequest.userId === "0") {