Skip to content

Commit

Permalink
fix: remove qrCodeUri (#131)
Browse files Browse the repository at this point in the history
* fix: remove qrCodeUri

* chore: bump versions
  • Loading branch information
horsefacts authored Jan 29, 2024
1 parent 713a933 commit 7b3a884
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
6 changes: 6 additions & 0 deletions packages/auth-kit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @farcaster/auth-kit

## 0.2.0

### Minor Changes

- fix: remove qrCodeUri return value

## 0.1.4

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/auth-kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ export const SignIn = ({ nonce }: { nonce: string }) => {
Hook for signing in a user. Connects to the relay server, generates a QR code and sign in link to present to the user, and polls relay server for wallet signature.

```tsx
import { useSignIn } from "@farcaster/auth-kit";
import { QRCode, useSignIn } from "@farcaster/auth-kit";

function App() {
const {
signIn,
qrCodeUri,
url
data: { username },
onSuccess: ({ fid }) => console.log("Your fid:", fid);
} = useSignIn();
Expand All @@ -169,7 +169,7 @@ function App() {
<button onClick={signIn}>Sign In</button>
{qrCodeUri && (
<span>
Scan this: <img src={qrCodeUri} />
Scan this: <QRCode uri={url} />
</span>
)}
{username && `Hello, ${username}!`}
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@farcaster/auth-kit",
"version": "0.1.4",
"version": "0.2.0",
"type": "module",
"main": "./dist/auth-kit.js",
"types": "./dist/auth-kit.d.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/auth-kit/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./SignInButton";
export * from "./AuthKitProvider";
export * from "./Demo";
export * from "./QRCode";
12 changes: 3 additions & 9 deletions packages/auth-kit/src/hooks/useCreateChannel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import QRCode from "qrcode";
import { AuthClientError } from "@farcaster/auth-client";
import { useCallback, useEffect, useState } from "react";

Expand All @@ -18,7 +17,6 @@ export interface UseCreateChannelData {
channelToken?: string;
url?: string;
nonce?: string;
qrCodeUri?: string;
}

export function useCreateChannel({
Expand All @@ -34,7 +32,6 @@ export function useCreateChannel({
const appClient = useAppClient();

const [connected, setConnected] = useState<boolean>(false);
const [qrCodeUri, setqrCodeUri] = useState<string>();
const [channelToken, setChannelToken] = useState<string>();
const [url, setUrl] = useState<string>();
const [nonce, setNonce] = useState<string>();
Expand Down Expand Up @@ -67,10 +64,8 @@ export function useCreateChannel({
setUrl(url);
setNonce(nonce);

const qrCodeUri = await QRCode.toDataURL(url, { width: 360 });
setqrCodeUri(qrCodeUri);
setIsSuccess(true);
onSuccess?.({ channelToken, url, qrCodeUri, nonce });
onSuccess?.({ channelToken, url, nonce });
}
}
}, [
Expand Down Expand Up @@ -98,11 +93,10 @@ export function useCreateChannel({
const reset = useCallback(() => {
setChannelToken(undefined);
setUrl(undefined);
setqrCodeUri(undefined);
setIsSuccess(false);
setIsError(false);
setError(undefined);
}, [setChannelToken, setUrl, setqrCodeUri, setIsSuccess, setIsError, setError]);
}, [setChannelToken, setUrl, setIsSuccess, setIsError, setError]);

const reconnect = useCallback(() => {
reset();
Expand All @@ -116,7 +110,7 @@ export function useCreateChannel({
isSuccess,
isError,
error,
data: { channelToken, url, qrCodeUri, nonce },
data: { channelToken, url, nonce },
};
}

Expand Down
3 changes: 1 addition & 2 deletions packages/auth-kit/src/hooks/useSignIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function useSignIn(args: UseSignInArgs) {
connect,
reconnect,
reset,
data: { channelToken, url, qrCodeUri, nonce },
data: { channelToken, url, nonce },
isSuccess: isConnected,
isError: isCreateChannelError,
error: createChannelError,
Expand Down Expand Up @@ -102,7 +102,6 @@ export function useSignIn(args: UseSignInArgs) {
error,
channelToken,
url,
qrCodeUri,
appClient,
data: statusData,
validSignature,
Expand Down

0 comments on commit 7b3a884

Please sign in to comment.