Skip to content

Commit

Permalink
fix: AuthType EVM account userId in lower case
Browse files Browse the repository at this point in the history
  • Loading branch information
gabin54 committed Jul 12, 2023
1 parent 6269242 commit 354e631
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
3 changes: 3 additions & 0 deletions packages/sismo-connect-client/src/common-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
29 changes: 28 additions & 1 deletion packages/sismo-connect-client/tests/sismo-connect.test.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");
});
});
3 changes: 3 additions & 0 deletions packages/sismo-connect-server/src/common-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit 354e631

Please sign in to comment.