Skip to content

Commit

Permalink
fix: throw error if no auth providers found (#1143)
Browse files Browse the repository at this point in the history
* fix: throw error if no auth providers found

* fix: new oauthproviders error class

* fix: add override to error
  • Loading branch information
RobChangCA authored Nov 13, 2024
1 parent 6d5e229 commit aef02e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions account-kit/signer/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type {
OauthParams,
User,
} from "./types.js";
import { OAuthProvidersError } from "../errors.js";

const CHECK_CLOSE_INTERVAL = 500;

Expand Down Expand Up @@ -518,6 +519,9 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
} = args;
const { codeChallenge, requestKey, authProviders } =
await this.getOauthConfigForMode(mode);
if (!authProviders) {
throw new OAuthProvidersError();
}
const authProvider = authProviders.find(
(provider) =>
provider.id === authProviderId &&
Expand Down
8 changes: 8 additions & 0 deletions account-kit/signer/src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BaseError } from "@aa-sdk/core";

export class NotAuthenticatedError extends BaseError {
override name = "NotAuthenticatedError";
constructor() {
super(
[
Expand All @@ -13,3 +14,10 @@ export class NotAuthenticatedError extends BaseError {
);
}
}

export class OAuthProvidersError extends BaseError {
override name = "OAuthProvidersError";
constructor() {
super("OAuth providers not found", { docsPath: "/react/getting-started" });
}
}

0 comments on commit aef02e1

Please sign in to comment.