Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions apps/example/cfg/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ThirdwebAuth } from "@thirdweb-dev/auth/next";
import { ethers } from "ethers";

const privateKey = ethers.Wallet.createRandom().privateKey;

export const { ThirdwebAuthHandler, getUser } = ThirdwebAuth({
domain: "example.com",
privateKey,
});
1 change: 1 addition & 0 deletions apps/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@thirdweb-dev/auth": "^0.2.0",
"@thirdweb-dev/react": "*",
"@thirdweb-dev/sdk": "^2",
"ethers": "^5.6.8",
Expand Down
5 changes: 4 additions & 1 deletion apps/example/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ const activeChainId = ChainId.Rinkeby;

function MyApp({ Component, pageProps }: AppProps) {
return (
<ThirdwebProvider desiredChainId={activeChainId}>
<ThirdwebProvider
desiredChainId={activeChainId}
authConfig={{ authUrl: "/api/auth", domain: "example.com" }}
>
<Component {...pageProps} />
</ThirdwebProvider>
);
Expand Down
3 changes: 3 additions & 0 deletions apps/example/pages/api/auth/[...thirdweb].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { ThirdwebAuthHandler } from "../../../cfg/auth";

export default ThirdwebAuthHandler();
1 change: 1 addition & 0 deletions packages/thirdweb-react/docs/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ import { useWalletConnect } from "@thirdweb-dev/react"
| [MediaType](./react.mediatype.md) | |
| [SharedMediaProps](./react.sharedmediaprops.md) | |
| [ThirdwebAuthConfig](./react.thirdwebauthconfig.md) | <b><i>(BETA)</i></b> The configuration to use the react SDK with an \[auth\](https://portal.thirdweb.com/auth) server. |
| [ThirdwebAuthUser](./react.thirdwebauthuser.md) | |
| [ThirdwebNftMediaProps](./react.thirdwebnftmediaprops.md) | The props for the [ThirdwebNftMedia](./react.thirdwebnftmedia.md) component. |
| [ThirdwebProviderProps](./react.thirdwebproviderprops.md) | The possible props for the ThirdwebProvider. |
| [ThirdwebSDKProviderProps](./react.thirdwebsdkproviderprops.md) | |
Expand Down
11 changes: 11 additions & 0 deletions packages/thirdweb-react/docs/react.thirdwebauthuser.address.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [ThirdwebAuthUser](./react.thirdwebauthuser.md) &gt; [address](./react.thirdwebauthuser.address.md)

## ThirdwebAuthUser.address property

<b>Signature:</b>

```typescript
address: string;
```
18 changes: 18 additions & 0 deletions packages/thirdweb-react/docs/react.thirdwebauthuser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [ThirdwebAuthUser](./react.thirdwebauthuser.md)

## ThirdwebAuthUser interface

<b>Signature:</b>

```typescript
export interface ThirdwebAuthUser
```

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [address](./react.thirdwebauthuser.address.md) | | string | |

2 changes: 1 addition & 1 deletion packages/thirdweb-react/docs/react.useuser.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export declare function useUser(): {
```
<b>Returns:</b>

{ user: ThirdwebAuthUser \| undefined; isLoading: boolean; }
{ user: [ThirdwebAuthUser](./react.thirdwebauthuser.md) \| undefined; isLoading: boolean; }

- The currently logged in user or null if not logged in, as well as a loading state.

22 changes: 21 additions & 1 deletion packages/thirdweb-react/etc/react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { IStorage } from '@thirdweb-dev/sdk/dist/browser';
import { Json } from '@thirdweb-dev/sdk/dist/browser';
import { ListingType } from '@thirdweb-dev/sdk/dist/browser';
import { LoginOptions } from '@thirdweb-dev/sdk/dist/src/schema';
import { LoginOptions as LoginOptions_2 } from '@thirdweb-dev/sdk';
import { LoginWithMagicLinkConfiguration } from 'magic-sdk';
import type { MagicSDKAdditionalConfiguration } from 'magic-sdk';
import { Marketplace } from '@thirdweb-dev/sdk/dist/browser';
Expand Down Expand Up @@ -318,6 +319,12 @@ export interface ThirdwebAuthConfig {
loginRedirect?: string;
}

// @public (undocumented)
export interface ThirdwebAuthUser {
// (undocumented)
address: string;
}

// @beta (undocumented)
export const ThirdwebNftMedia: React_2.ForwardRefExoticComponent<ThirdwebNftMediaProps & React_2.RefAttributes<HTMLMediaElement>>;

Expand Down Expand Up @@ -447,6 +454,20 @@ export function useAllRoleMembers<TContract extends ContractWithRoles>(contract:
// @beta
export function useAuctionWinner(contract: RequiredParam<Marketplace>, listingId: RequiredParam<BigNumberish>): UseQueryResult<string | undefined, unknown>;

// Warning: (ae-internal-missing-underscore) The name "useAuth" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export function useAuth(loginConfig?: LoginConfig): {
login: (cfg?: {
chainId?: number | undefined;
nonce?: string | undefined;
expirationTime?: Date | undefined;
} | undefined) => Promise<void>;
logout: () => void;
user: ThirdwebAuthUser | undefined;
isLoading: boolean;
};

// @beta
export function useBalance(tokenAddress?: ContractAddress): UseQueryResult< {
symbol: string;
Expand Down Expand Up @@ -1859,7 +1880,6 @@ export const Web3Button: React.FC<PropsWithChildren<Web3ButtonProps>>;
// dist/declarations/dist/Provider.d.ts:45:5 - (ae-forgotten-export) The symbol "GnosisConnectorArguments" needs to be exported by the entry point thirdweb-dev-react.cjs.d.ts
// dist/declarations/dist/hooks/async/roles.d.ts:126:5 - (ae-incompatible-release-tags) The symbol "role" is marked as @beta, but its signature references "RolesForContract" which is marked as @internal
// dist/declarations/dist/hooks/async/roles.d.ts:161:5 - (ae-incompatible-release-tags) The symbol "role" is marked as @beta, but its signature references "RolesForContract" which is marked as @internal
// dist/declarations/dist/hooks/auth/useUser.d.ts:12:5 - (ae-forgotten-export) The symbol "ThirdwebAuthUser" needs to be exported by the entry point thirdweb-dev-react.cjs.d.ts
// dist/declarations/dist/hooks/useNetwork.d.ts:48:5 - (ae-forgotten-export) The symbol "SwitchChainError" needs to be exported by the entry point thirdweb-dev-react.cjs.d.ts
// dist/declarations/dist/types.d.ts:215:5 - (ae-incompatible-release-tags) The symbol "buyForWallet" is marked as @public, but its signature references "WalletAddress" which is marked as @beta
// dist/declarations/dist/types.d.ts:221:5 - (ae-incompatible-release-tags) The symbol "to" is marked as @public, but its signature references "WalletAddress" which is marked as @beta
Expand Down
2 changes: 1 addition & 1 deletion packages/thirdweb-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "2.7.0",
"version": "2.7.1-2",
"repository": {
"type": "git",
"url": "git+https://github.com:thirdweb-dev/react.git"
Expand Down
Loading