Skip to content

Commit

Permalink
fix(signer): passkey sessions were being wiped by oauth prep (#1154)
Browse files Browse the repository at this point in the history
  • Loading branch information
moldy530 authored Nov 14, 2024
1 parent 155d1fb commit 9f0543f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
7 changes: 6 additions & 1 deletion account-kit/signer/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getWebAuthnAttestation } from "@turnkey/http";
import { IframeStamper } from "@turnkey/iframe-stamper";
import { WebauthnStamper } from "@turnkey/webauthn-stamper";
import { z } from "zod";
import { OAuthProvidersError } from "../errors.js";
import { getDefaultScopeAndClaims, getOauthNonce } from "../oauth.js";
import type { AuthParams, OauthMode } from "../signer.js";
import { base64UrlEncode } from "../utils/base64UrlEncode.js";
Expand All @@ -19,7 +20,6 @@ import type {
OauthParams,
User,
} from "./types.js";
import { OAuthProvidersError } from "../errors.js";

const CHECK_CLOSE_INTERVAL = 500;

Expand Down Expand Up @@ -304,6 +304,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
await this.initWebauthnStamper(user);
if (user) {
this.user = user;
this.eventEmitter.emit("connectedPasskey", user);
return user;
}

Expand Down Expand Up @@ -665,7 +666,11 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
};

protected override getOauthConfig = async (): Promise<OauthConfig> => {
const currentStamper = this.turnkeyClient.stamper;
const publicKey = await this.initIframeStamper();

// swap the stamper back in case the user logged in with a different stamper (passkeys)
this.setStamper(currentStamper);
const nonce = getOauthNonce(publicKey);
return this.request("/v1/prepare-oauth", { nonce });
};
Expand Down
1 change: 1 addition & 0 deletions account-kit/signer/src/session/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export class SessionManager {
orgId: existingSession.user.orgId,
authenticatingType: existingSession.type,
connectedEventName,
idToken: existingSession.user.idToken,
})
.catch((e) => {
console.warn("Failed to load user from session", e);
Expand Down
2 changes: 1 addition & 1 deletion account-kit/smart-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"./package.json": "./package.json"
},
"scripts": {
"generate": "npx tsx ../plugingen/src/cli.ts generate && yarn _lint:generated",
"generate": "npx tsx ../plugingen/src/cli.ts generate && yarn _lint:generated 1> /dev/null",
"_lint:generated": "dotenv -e ../../.env -- eslint . --fix --config ../../.eslintrc --ignore-path ../../.prettierignore && prettier --write --ignore-path ../../.prettierignore .",
"build": "yarn clean && yarn build:esm && yarn build:types",
"build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export const MintCard = () => {
});
setNFTTransfered(true);
};
const handleError = () => {
const handleError = (error: Error) => {
console.error(error);
setStatus(initialValuePropState);
setToast({
type: "error",
Expand Down
5 changes: 0 additions & 5 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
"docs:gen": {
"dependsOn": ["ak-docgen#build"],
"outputs": ["../../site/pages/reference/**"]
},
"dev": {
"dependsOn": ["^build"],
"persistent": true,
"cache": false
}
}
}

0 comments on commit 9f0543f

Please sign in to comment.