Compare commits

...
Author SHA1 Message Date
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
52f827e8f2 Version Packages (#2586)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-29 11:37:16 -07:00
Jonas DanielsandGitHub 6063f40f87 fix(cli): fix execution on windows and when prettier is not installed (#2587) 2024-03-29 18:16:38 +00:00
YashandGitHub 6bd1b82a58 [CLI] Publish and deploy updates for ZKSync (#2584) 2024-03-29 17:12:50 +00:00
Manan TankandGitHub 052892b396 [v5] Fix WC session request (#2585) 2024-03-29 17:09:06 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
3b12c5c926 Version Packages (#2574)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-29 03:59:31 -07:00
Jonas DanielsandGitHub 02d2377ca5 build: Update dependencies in package.json (#2582) 2024-03-29 03:44:43 -07:00
9545005908 chore(chains): update chains (#2581)
Co-authored-by: GitHub Action <[email protected]>
2024-03-29 03:43:37 -07:00
Jonas DanielsandGitHub d93286bc1f chore: Update devDependencies versions (#2577) 2024-03-29 10:29:33 +00:00
50e7dbaa9d chore(chains): update chains (#2580)
Co-authored-by: GitHub Action <[email protected]>
2024-03-28 21:05:46 -07:00
Joaquim VergesandGitHub 04961f0e9a feat: change getWalletBalance prop from account to address (#2576) 2024-03-28 23:45:15 +00:00
Jonas DanielsandGitHub 37f8433c7c chore: Skip benchmark step for merge groups (#2575) 2024-03-28 22:29:33 +00:00
Jonas DanielsandGitHub c81bb882c5 fix(evm): fix CWE-1333 (#2573) 2024-03-28 22:22:51 +00:00
Jonas DanielsandGitHub 701cd880df chore: point CLI backwards compatibility @latest instead of @beta (#2572) 2024-03-28 22:10:17 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
3f0a3124f3 Version Packages (#2551)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-28 14:51:33 -07:00
949032ee09 Fix jsDoc syntax highlighting for generated functions (#2571)
Co-authored-by: Jonas Daniels <[email protected]>
2024-03-28 20:25:05 +00:00
Jonas DanielsandGitHub 3c58d17aba refactor: Remove unnecessary dependencies and configurations (#2569) 2024-03-28 20:07:06 +00:00
07954bb20b [v5] types/jsdoc cleanup (#2570)
Signed-off-by: Manan Tank <[email protected]>
Co-authored-by: Jonas Daniels <[email protected]>
2024-03-28 19:41:29 +00:00
275af27a81 chore(chains): update chains (#2568)
Co-authored-by: GitHub Action <[email protected]>
2024-03-28 11:50:25 -07:00
YashandGitHub c63d9ea7ac Contract verification status update (#2566) 2024-03-28 17:23:10 +00:00
8518ea18a7 chore(chains): update chains (#2567)
Co-authored-by: GitHub Action <[email protected]>
2024-03-28 10:07:19 -07:00
Jonas DanielsandGitHub 18aaf5a1b8 chore: update references to packages across the repo (#2565) 2024-03-28 16:50:06 +00:00
Jonas DanielsandGitHub 9543a81d76 chore: Remove unnecessary changeset file (#2564) 2024-03-28 16:07:29 +00:00
13f00cf476 fix: fix imToken wallet issue (#2562)
Signed-off-by: Jonas Daniels <[email protected]>
Co-authored-by: Jonas Daniels <[email protected]>
2024-03-28 09:02:27 -07:00
Manan TankandGitHub 9e28754bb1 Add "All wallets" in connect ui (#2560) 2024-03-28 15:39:28 +00:00
github-actions[bot]andGitHub 095d227a13 chore(chains): update chains (#2559) 2024-03-28 08:39:38 -07:00
Manan TankandGitHub 889a1a08f5 smart wallet autoconnect and other fixes (#2558) 2024-03-28 09:48:41 +00:00
FirekeeperandGitHub 6d7eedc213 Unity 4.9.0 (#2556) 2024-03-28 02:59:41 +00:00
Jonas DanielsandGitHub bfdfb2ca38 chore(release): Update Workflows (#2555) 2024-03-28 02:16:28 +00:00
Joaquim VergesandGitHub 17c772e839 ERC721 signature mint (#2554) 2024-03-28 01:51:02 +00:00
Joaquim VergesandGitHub 73b5161a67 Update generate script to expose clean types (#2553) 2024-03-28 01:19:58 +00:00
Jonas DanielsandGitHub 95eb75ac77 chore: move legacy packages to legacy_packages (#2552) 2024-03-28 00:55:03 +00:00
+2 01fd5237f5 Beta (#2356)
Signed-off-by: Joaquim Verges <[email protected]>
Signed-off-by: jxom  <[email protected]>
Signed-off-by: greg <[email protected]>
Signed-off-by: Jonas Daniels <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: Manan Tank <[email protected]>
Co-authored-by: Joaquim Verges <[email protected]>
Co-authored-by: jxom <[email protected]>
Co-authored-by: Nacho Iacovino <[email protected]>
Co-authored-by: greg <[email protected]>
Co-authored-by: Winston Yeo <[email protected]>
Co-authored-by: iketw <[email protected]>
Co-authored-by: Winston Yeo <[email protected]>
Co-authored-by: Isaac Dubuque <[email protected]>
2024-03-27 17:13:03 -07:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
6fd7497c15 Version Packages (#2528)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-27 16:36:02 -07:00
25616ca794 chore(chains): update chains (#2549)
Co-authored-by: GitHub Action <[email protected]>
2024-03-27 15:25:49 -07:00
2a345172a3 chore(chains): update chains (#2546)
Co-authored-by: GitHub Action <[email protected]>
2024-03-27 02:59:43 -07:00
8cb002259a chore(chains): update chains (#2529)
Co-authored-by: GitHub Action <[email protected]>
2024-03-27 00:30:38 -07:00
YashandGitHub 436d9baba2 [SDK] Add external links field to publish metadata (#2545) 2024-03-26 20:53:58 +00:00
FirekeeperandGitHub e417f6ac64 move sw tests from mumbai to arb sep (#2537) 2024-03-25 19:34:01 +00:00
FirekeeperandGitHub 65ea87425c Unity 4.8.0 (#2532) 2024-03-22 23:29:51 +00:00
Phillip HoandGitHub 0aea03e418 chore: bump service-utils version (#2531) 2024-03-22 21:27:03 +00:00
Phillip HoandGitHub d8b488bbc9 chore: Simplify HTTP logs (#2530) 2024-03-22 20:27:41 +00:00
cb0ef6a6a2 chore(chains): update chains (#2527)
Co-authored-by: GitHub Action <[email protected]>
2024-03-21 10:22:12 -07:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
c377290b27 Version Packages (#2524)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-20 18:40:57 -07:00
Nacho IacovinoandGitHub 35bddd69c5 Fix function for old js (#2523) 2024-03-21 01:14:26 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
34be385a5c Version Packages (#2522)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-20 12:29:23 -07:00
79c9e130fd [react, wallets] Add imToken Wallet (#2497)
Signed-off-by: Mako Shan <[email protected]>
Signed-off-by: Jonas Daniels <[email protected]>
Co-authored-by: xwartz <[email protected]>
Co-authored-by: Jonas Daniels <[email protected]>
2024-03-20 11:54:18 -07:00
9c884e2f55 [Unity] Expose additional WC QR Options (#2501)
Co-authored-by: Jonas Daniels <[email protected]>
2024-03-20 17:44:10 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
2e21b52b97 Version Packages (#2495)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-19 19:56:45 -07:00
Jonas DanielsandGitHub e3f44905ca chore: update dependencies and add new ABI file (#2517) 2024-03-20 01:40:10 +00:00
Jonas DanielsandGitHub c47927708a refactor(any-evm-constants): Simplify matchError function (#2514) 2024-03-20 00:17:22 +00:00
4c511f0310 chore(chains): update chains (#2507)
Co-authored-by: GitHub Action <[email protected]>
2024-03-19 17:14:05 -07:00
YashandGitHub b2728ec6f2 Update contracts version (#2509) 2024-03-19 21:47:59 +00:00
Jonas DanielsandGitHub 663759975d chore: update test utils with new RPC endpoints (#2503) 2024-03-19 18:12:00 +00:00
f1971ffe36 chore(chains): update chains (#2506)
Co-authored-by: GitHub Action <[email protected]>
2024-03-19 10:01:37 -07:00
8b134bbb55 chore(chains): update chains (#2500)
Co-authored-by: GitHub Action <[email protected]>
2024-03-19 10:00:21 -07:00
8a20aa5825 chore(chains): update chains (#2427)
Co-authored-by: GitHub Action <[email protected]>
2024-03-18 12:54:41 -07:00
FirekeeperandGitHub 112863ecce Unity 4.7.10 (#2498) 2024-03-18 14:48:47 +00:00
Jonas DanielsandGitHub 863049dc0c fix(sdk): dev deployments and bundleId=undefined query params (#2496) 2024-03-16 03:14:21 +00:00
Nacho IacovinoandGitHub 802ba8c5a9 Smart Wallet -> Smart Account (#2493) 2024-03-15 21:38:50 +00:00
FirekeeperandGitHub e36ebe2243 [Unity] Resolve & Reverse Resolve ENS WebGL (#2494) 2024-03-15 21:31:53 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
c52e3beac1 Version Packages (#2486)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-14 23:04:16 -07:00
Joaquim VergesandGitHub f0250a77cd [SDK] Revert min maxPriorityFeePerGas (#2490) 2024-03-15 05:08:55 +00:00
d4be6479db Added Domain Separator as an input for gasless (#2332)
Co-authored-by: Jonas Daniels <[email protected]>
2024-03-15 05:03:17 +00:00
YashandGitHub c67b287764 Contract verification on zksync (#2481) 2024-03-15 02:47:29 +00:00
7ac4e6ba4e Contracts version 3.11.1 (#2459)
Co-authored-by: Joaquim Verges <[email protected]>
2024-03-14 18:57:34 +00:00
Joaquim VergesandGitHub c494db87cb sync chains (#2484) 2024-03-14 08:01:38 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
1932d601c1 Version Packages (#2474)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-14 01:09:17 -07:00
Joaquim VergesandGitHub 846a3503fe [SDK] Enforce minimum for maxPriorityFeePerGas (#2483) 2024-03-14 07:44:14 +00:00
Jonas DanielsandGitHub 3e7f9cb946 feat(sdk): add support for overriding default admin (#2479) 2024-03-14 01:14:21 +00:00
iketwandGitHub 83526c519a Only pass bundleId if defined (#2472) 2024-03-13 20:13:11 +00:00
Joaquim VergesandGitHub 2e01627c99 [Chains] sync chains (#2464) 2024-03-13 19:11:06 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
7b52c6bba0 Version Packages (#2467)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-13 11:56:41 -07:00
Edward SunandGitHub e024d78ed0 Add pay to usageEventSchema (#2465) 2024-03-13 05:02:40 +00:00
Joaquim VergesandGitHub a2002d1637 [SDK] Better return type for getProofsForAllowListEntry (#2469) 2024-03-13 01:20:22 +00:00
FirekeeperandGitHub 607ab7e860 [Unity] Expose SW isDeployed (#2466) 2024-03-12 22:37:02 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
f27989741a Version Packages (#2461)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-12 12:55:05 -07:00
Joaquim VergesandGitHub b2be63ada4 handle l2 estimations when forcing gasLimit (#2457) 2024-03-12 19:37:02 +00:00
Winston YeoandGitHub eee200f8d4 chore: whitelist embedded-wallet.thirdweb.com in service utils (#2453) 2024-03-12 15:45:09 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
817ab2249f Version Packages (#2446)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-11 17:22:24 -07:00
Joaquim VergesandGitHub 173777ade4 [SDK] update OP SDK to fix pnpm preinstall script issue (#2455) 2024-03-11 23:53:16 +00:00
Manan TankandGitHub 838233075a [react] Fix onConnect called multiple times in EmbeddedWalletSocialLogin (#2447) 2024-03-11 19:03:32 +00:00
FirekeeperandGitHub cabfc29119 [Smart Wallet] Use bundler eth_getUserOperationReceipt instead of rpc eth_getLogs (#2443) 2024-03-11 17:12:35 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
f02570db88 Version Packages (#2442)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-08 16:56:41 -08:00
Joaquim VergesandGitHub c6b025e844 [SDK] handle estimateGasCost for OP chains (#2441) 2024-03-08 16:49:28 -08:00
Joaquim VergesandGitHub 332a14552b [Wallets] make accountInfo/factoryInfo internal props optional in SmartWalletConfig (#2439) 2024-03-09 00:45:04 +00:00
FirekeeperandGitHub c894270401 [Smart Wallet] try fetch sw abi if deployed (#2440) 2024-03-09 00:02:46 +00:00
Joaquim VergesandGitHub 595815dc3e Update README.md (#2438)
Signed-off-by: Joaquim Verges <[email protected]>
2024-03-08 12:42:35 -08:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
b959cafccc Version Packages (#2435)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-08 09:21:46 -08:00
Edward SunandGitHub 4cf0aede0e Update service-utils change to patch (#2434) 2024-03-08 01:53:20 +00:00
Edward SunandGitHub 6cf298a29a Add pay to Services list (#2431) 2024-03-08 01:15:42 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
62b2508a6c Version Packages (#2420)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-07 13:57:31 -08:00
c3967b798e chore(chains): update chains (#2426)
Co-authored-by: GitHub Action <[email protected]>
2024-03-07 13:21:11 -08:00
588897d1b0 chore(chains): update chains (#2416)
Co-authored-by: GitHub Action <[email protected]>
2024-03-07 11:59:05 -08:00
862905e161 refactor: Move checkContractWalletSignature function to a separate file (#2417)
Co-authored-by: 0xFirekeeper <[email protected]>
2024-03-07 06:09:48 +00:00
saminaandGitHub 5f81e246f2 Update README.md (#2418)
Signed-off-by: samina <[email protected]>
2024-03-07 02:43:38 +00:00
Jonas DanielsGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>GitHub Action
1b052d63e9 Version Packages (#2409)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Action <[email protected]>
2024-03-06 15:23:29 -08:00
FirekeeperandGitHub a3f6878649 [Unity] Remove unnecessary logs, add getEmail check (#2415) 2024-03-06 22:44:51 +00:00
Jonas DanielsandGitHub 74a92dcb7d feat(wallets): pass clientId and secretKey to verifySignature functions (#2414) 2024-03-06 22:20:10 +00:00
38fc0b796a chore(chains): update chains (#2412)
Co-authored-by: GitHub Action <[email protected]>
2024-03-06 13:07:04 -08:00
YashandGitHub ef76a96c2d [CLI] Option to link external libraries (#2400) 2024-03-06 18:45:04 +00:00
2667706d8d chore(chains): update chains (#2408)
Co-authored-by: GitHub Action <[email protected]>
2024-03-06 00:03:24 -08:00
047fbe2918 chore(chains): update chains (#2406)
Co-authored-by: GitHub Action <[email protected]>
2024-03-05 23:58:43 -08:00
5198 changed files with 145701 additions and 16915 deletions
-3
View File
@@ -16,9 +16,6 @@
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [
"e2e-cra-5",
"e2e-next-13",
"e2e-vite-3",
"bundlers-esbuild",
"bundlers-vite",
"bundlers-webpack",
+2 -2
View File
@@ -4,11 +4,11 @@ description: "Sets up Node.js and runs install"
runs:
using: composite
steps:
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v3
with:
version: 8
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: "https://registry.npmjs.org"
+7 -7
View File
@@ -22,13 +22,13 @@ We use [Turborepo](https://turborepo.org/docs/getting-started) to manage the mon
You can see a quick outline of each of the projects within this repo below, each living within the [/packages](/packages) directory:
| Package | Description | Latest Version |
| ------------------------------ | -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [/sdk](./packages/sdk) | Best in class web3 SDK for Browser, Node and Mobile apps | <a href="https://www.npmjs.com/package/@thirdweb-dev/sdk"><img src="https://img.shields.io/npm/v/@thirdweb-dev/sdk?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/react](./packages/react) | Ultimate collection of React hooks for your web3 apps | <a href="https://www.npmjs.com/package/@thirdweb-dev/react"><img src="https://img.shields.io/npm/v/@thirdweb-dev/react?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/auth](./packages/auth) | Best in class wallet authentication for Node backends | <a href="https://www.npmjs.com/package/@thirdweb-dev/auth"><img src="https://img.shields.io/npm/v/@thirdweb-dev/auth?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/storage](./packages/storage) | Best in class decentralized storage SDK for Browser and Node | <a href="https://www.npmjs.com/package/@thirdweb-dev/storage"><img src="https://img.shields.io/npm/v/@thirdweb-dev/storage?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/cli](./packages/cli) | Publish and deploy smart contracts without dealing with private keys | <a href="https://www.npmjs.com/package/thirdweb"><img src="https://img.shields.io/npm/v/thirdweb?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| Package | Description | Latest Version |
| ------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [/sdk](./legacy_packages/sdk) | Best in class web3 SDK for Browser, Node and Mobile apps | <a href="https://www.npmjs.com/package/@thirdweb-dev/sdk"><img src="https://img.shields.io/npm/v/@thirdweb-dev/sdk?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/react](./legacy_packages/react) | Ultimate collection of React hooks for your web3 apps | <a href="https://www.npmjs.com/package/@thirdweb-dev/react"><img src="https://img.shields.io/npm/v/@thirdweb-dev/react?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/auth](./legacy_packages/auth) | Best in class wallet authentication for Node backends | <a href="https://www.npmjs.com/package/@thirdweb-dev/auth"><img src="https://img.shields.io/npm/v/@thirdweb-dev/auth?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/storage](./legacy_packages/storage) | Best in class decentralized storage SDK for Browser and Node | <a href="https://www.npmjs.com/package/@thirdweb-dev/storage"><img src="https://img.shields.io/npm/v/@thirdweb-dev/storage?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/cli](./legacy_packages/cli) | Publish and deploy smart contracts without dealing with private keys | <a href="https://www.npmjs.com/package/thirdweb"><img src="https://img.shields.io/npm/v/thirdweb?color=red&label=npm&logo=npm" alt="npm version"/></a> |
## How to contribute
+91 -17
View File
@@ -1,4 +1,4 @@
name: Build, Lint & Test
name: Build, Lint & Test & Benchmark
on:
push:
@@ -8,6 +8,7 @@ on:
# trigger on merge group as well (merge queue)
merge_group:
types: [checks_requested]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@@ -27,14 +28,14 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 25
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.21
bun-version: 1.0.35
- name: Install
uses: ./.github/composite-actions/install
@@ -45,7 +46,7 @@ jobs:
- id: get-week
run: echo "WEEK=$(date +%U)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
- uses: actions/cache@v4
timeout-minutes: 5
id: cache-build
with:
@@ -59,7 +60,7 @@ jobs:
needs: build
steps:
- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
check-latest: true
@@ -67,13 +68,13 @@ jobs:
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.21
bun-version: 1.0.35
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v3
with:
version: 8
- uses: actions/cache@v3
- uses: actions/cache@v4
timeout-minutes: 5
id: restore-build
with:
@@ -89,7 +90,7 @@ jobs:
needs: build
steps:
- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
check-latest: true
@@ -98,25 +99,64 @@ jobs:
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.21
bun-version: 1.0.35
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v3
with:
version: 8
- uses: actions/cache@v3
- uses: actions/cache@v4
timeout-minutes: 5
id: restore-build
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}
- name: Set up foundry
uses: foundry-rs/foundry-toolchain@v1
- run: pnpm test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: ./packages/sdk/coverage/evm/lcov.info
files: ./packages/thirdweb/coverage/lcov.info
test_legacy:
timeout-minutes: 15
name: Unit Tests (Legacy)
runs-on: ubuntu-latest-16
needs: build
steps:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
check-latest: true
# we use bun for some test suites
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.35
- uses: pnpm/action-setup@v3
with:
version: 8
- uses: actions/cache@v4
timeout-minutes: 5
id: restore-build
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}
- run: pnpm test:legacy
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: ./legacy_packages/sdk/coverage/evm/lcov.info
e2e:
timeout-minutes: 15
@@ -125,7 +165,7 @@ jobs:
needs: build
steps:
- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
check-latest: true
@@ -134,13 +174,13 @@ jobs:
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.21
bun-version: 1.0.35
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v3
with:
version: 8
- uses: actions/cache@v3
- uses: actions/cache@v4
timeout-minutes: 5
id: restore-build
with:
@@ -155,3 +195,37 @@ jobs:
env:
NODE_OPTIONS: "--max_old_space_size=4096"
CLI_E2E_API_KEY: ${{ secrets.CLI_E2E_API_KEY }}
benchmark:
# only run if is not merge_group
if: github.event_name != 'merge_group'
timeout-minutes: 15
name: "Benchmark"
runs-on: ubuntu-latest-16
needs: build
steps:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
check-latest: true
- uses: pnpm/action-setup@v3
with:
version: 8
- uses: actions/cache@v4
timeout-minutes: 5
id: restore-build
with:
path: ./*
key: ${{ github.sha }}-${{ github.run_number }}
- name: Set up foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Run benchmarks
uses: CodSpeedHQ/action@v2
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: "pnpm bench"
+30 -31
View File
@@ -13,12 +13,12 @@ name: "CodeQL"
on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
branches: ["main"]
schedule:
- cron: '37 9 * * 3'
- cron: "37 9 * * 3"
jobs:
analyze:
@@ -32,41 +32,40 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
language: ["javascript"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
+16 -9
View File
@@ -10,21 +10,27 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# cancel any previous runs if they were started before this one
cancel-in-progress: true
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TW_SECRET_KEY: ${{ secrets.TW_SECRET_KEY }}
jobs:
release-artifacts:
timeout-minutes: 15
runs-on: ubuntu-latest-16
steps:
- name: Checkout branch
uses: actions/checkout@v3
uses: actions/checkout@v4
# bun setup is required, because pnpm typdoc will run pnpm build and some packages uses bun for build
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.21
bun-version: 1.0.35
- name: Install
uses: ./.github/composite-actions/install
@@ -37,7 +43,7 @@ jobs:
- name: Generate Docs
run: |
cd packages/sdk
cd legacy_packages/sdk
pnpm generate-docs
cd ../react-core
pnpm generate-docs
@@ -53,12 +59,13 @@ jobs:
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git status
git add packages/react/typedoc/documentation.json.gz
git add packages/react-core/typedoc/documentation.json.gz
git add packages/react-native/typedoc/documentation.json.gz
git add packages/sdk/typedoc/documentation.json.gz
git add packages/storage/typedoc/documentation.json.gz
git add packages/wallets/typedoc/documentation.json.gz
git add legacy_packages/react/typedoc/documentation.json.gz
git add legacy_packages/react-core/typedoc/documentation.json.gz
git add legacy_packages/react-native/typedoc/documentation.json.gz
git add legacy_packages/sdk/typedoc/documentation.json.gz
git add legacy_packages/storage/typedoc/documentation.json.gz
git add legacy_packages/wallets/typedoc/documentation.json.gz
git add packages/thirdweb/typedoc/documentation.json.gz
git add snippets/feature_snippets_react.json
git add snippets/feature_snippets_sdk.json
git add snippets/snippets.json
-47
View File
@@ -1,47 +0,0 @@
name: Release Next
on:
push:
paths:
- ".changeset/**"
- "packages/**"
branches:
- next
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
timeout-minutes: 30
runs-on: ubuntu-latest-16
steps:
- name: Checkout branch
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.21
- name: Install
uses: ./.github/composite-actions/install
- name: Build
run: pnpm build
- name: Create @next release
run: |
git checkout next
pnpm version-packages:next
pnpm release:next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+2 -2
View File
@@ -61,7 +61,7 @@ jobs:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: pull the repo.
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: true
repository: ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.repo.full_name }}
@@ -70,7 +70,7 @@ jobs:
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.21
bun-version: 1.0.35
- name: Install
uses: ./.github/composite-actions/install
+3 -2
View File
@@ -8,6 +8,7 @@ on:
paths:
- ".changeset/**"
- "packages/**"
- "legacy_packages/**"
branches:
- main
@@ -25,7 +26,7 @@ jobs:
runs-on: ubuntu-latest-16
steps:
- name: Checkout branch
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
# Do not use the GITHUB_TOKEN by default
@@ -34,7 +35,7 @@ jobs:
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.21
bun-version: 1.0.35
- name: Install
uses: ./.github/composite-actions/install
+2 -2
View File
@@ -15,11 +15,11 @@ jobs:
- name: Install bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.21
bun-version: 1.0.35
- name: Run chains sync
run: bun run db:sync
working-directory: ./packages/chains
working-directory: ./legacy_packages/chains
- name: Check for Changes
id: git-check
+2 -2
View File
@@ -10,7 +10,7 @@ dist-ssr
.cache
server/dist
public/dist
./packages/contracts-js/abis
./legacy_packages/contracts-js/abis
.idea/
.yalc/
yalc.lock
@@ -20,4 +20,4 @@ playwright-report/
.env/
# Artifacts
packages/cli/artifacts/
legacy_packages/cli/artifacts/
+57 -24
View File
@@ -1,11 +1,11 @@
<p align="center">
<br />
<a href="https://thirdweb.com">
<img src="https://github.com/thirdweb-dev/js/blob/main/packages/sdk/logo.svg?raw=true" width="200" alt=""/></a>
<img src="https://github.com/thirdweb-dev/js/blob/main/legacy_packages/sdk/logo.svg?raw=true" width="200" alt=""/></a>
<br />
</p>
<h1 align="center"><a href='https://thirdweb.com/'>thirdweb</a> JavaScript/TypeScript monorepo</h1>
<h1 align="center"><a href='https://thirdweb.com/'>thirdweb</a> TypeScript SDK</h1>
<p align="center">
<a href="https://github.com/thirdweb-dev/js/actions/workflows/build-test-lint.yml">
@@ -16,38 +16,71 @@
</a>
</p>
<p align="center"><strong>Best in class web3 SDKs for Browser, Node and Mobile apps</strong></p>
<p align="center"><strong>All-in-one web3 SDK for Browser, Node and Mobile apps</strong></p>
> [!IMPORTANT]
> We rewrote the thirdweb SDK from scratch for performance! Head over to the [v5 SDK](https://github.com/thirdweb-dev/js/tree/main/packages/thirdweb).
## Features
- Support for React & React-Native
- First party support for [Embedded Wallets](https://portal.thirdweb.com/connect/embedded-wallet/overview) (social/email login)
- First party support for [Account Abstraction](https://portal.thirdweb.com/connect/account-abstraction)
- Instant connection to any chain with RPC Edge integration
- Integrated IPFS upload/download
- UI Components for connection, transactions, nft rendering
- High level contract extensions for interacting with common standards
- Automatic ABI resolution
## Library Comparison
| | thirdweb | Wagmi | Viem | Ethers@6 |
| ----------------------------------------- | -------- | ------------------ | ------------------ | -------- |
| Type safe contract API | ✅ | ✅ | ✅ | ✅ |
| Type safe wallet API | ✅ | ✅ | ✅ | ✅ |
| EVM utils | ✅ | ❌ | ✅ | ✅ |
| RPC for any EVM | ✅  | ⚠️ public RPC only | ⚠️ public RPC only | ❌ |
| Automatic ABI Resolution | ✅ | ❌ | ❌ | ❌ |
| IPFS Upload/Download | ✅ | ❌ | ❌ | ❌ |
| Embedded wallet (email/ social login) | ✅ | ⚠️ via 3rd party | ❌ | ❌ |
| Account abstraction (ERC4337) support | ✅ | ⚠️ via 3rd party | ⚠️ via 3rd party | ❌ |
| Web3 wallet connectors | ✅ | ✅ | ❌ | ❌ |
| Local wallet creation | ✅ | ❌ | ✅ | ✅ |
| Auth (SIWE) | ✅ | ⚠️ via 3rd party | ❌ | ❌ |
| Extensions functions for common standards | ✅ | ❌ | ❌ | ❌ |
| React Hooks | ✅ | ✅ | ❌ | ❌ |
| React UI components | ✅ | ❌ | ❌ | ❌ |
| React Native Hooks | ✅ | ❌ | ❌ | ❌ |
| React Native UI Components | ✅ | ❌ | ❌ | ❌ |
## Packages
| Package | Description | Latest Version |
| ---------------------------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [/sdk](./packages/sdk) | Best in class web3 SDK for Browser, Node and Mobile apps | <a href="https://www.npmjs.com/package/@thirdweb-dev/sdk"><img src="https://img.shields.io/npm/v/@thirdweb-dev/sdk?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/wallets](./packages/wallets) | Unified web3 Wallet library to integrate any wallet into your applications. | <a href="https://www.npmjs.com/package/@thirdweb-dev/wallets"><img src="https://img.shields.io/npm/v/@thirdweb-dev/wallets?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/react](./packages/react) | Ultimate collection of React hooks for your web3 apps | <a href="https://www.npmjs.com/package/@thirdweb-dev/react"><img src="https://img.shields.io/npm/v/@thirdweb-dev/react?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/react-native](./packages/react-native) | Ultimate collection of React hooks for your native mobile web3 apps | <a href="https://www.npmjs.com/package/@thirdweb-dev/react-native"><img src="https://img.shields.io/npm/v/@thirdweb-dev/react-native?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/auth](./packages/auth) | Best in class wallet authentication for Node backends | <a href="https://www.npmjs.com/package/@thirdweb-dev/auth"><img src="https://img.shields.io/npm/v/@thirdweb-dev/auth?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/storage](./packages/storage) | Best in class decentralized storage SDK for Browser and Node | <a href="https://www.npmjs.com/package/@thirdweb-dev/storage"><img src="https://img.shields.io/npm/v/@thirdweb-dev/storage?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/cli](./packages/cli) | Publish and deploy smart contracts without dealing with private keys | <a href="https://www.npmjs.com/package/thirdweb"><img src="https://img.shields.io/npm/v/thirdweb?color=red&label=npm&logo=npm" alt="npm version"/></a> |
| [/chains](./packages/chains) | All EVM chain information as JS objects for easy handling | <a href="https://www.npmjs.com/package/@thirdweb-dev/chains"><img src="https://img.shields.io/npm/v/@thirdweb-dev/chains?color=red&label=npm&logo=npm" alt="npm version"/></a> |
## Documentation
Visit [https://portal.thirdweb.com/](https://portal.thirdweb.com/) to view the full documentation.
<br />
| Package | Description |
| ----------------------------------------------- | --------------------------------------------------------------------------- |
| [/sdk](./legacy_packages/sdk) | Best in class web3 SDK for Browser, Node and Mobile apps |
| [/wallets](./legacy_packages/wallets) | Unified web3 Wallet library to integrate any wallet into your applications. |
| [/react](./legacy_packages/react) | Ultimate collection of React hooks for your web3 apps |
| [/react-native](./legacy_packages/react-native) | Ultimate collection of React hooks for your native mobile web3 apps |
| [/auth](./legacy_packages/auth) | Best in class wallet authentication for Node backends |
| [/storage](./legacy_packages/storage) | Best in class decentralized storage SDK for Browser and Node |
| [/cli](./legacy_packages/cli) | Publish and deploy smart contracts without dealing with private keys |
| [/chains](./legacy_packages/chains) | All EVM chain information as JS objects for easy handling |
## Contributing
We welcome contributions from all developers, regardless of experience level. If you are interested in contributing, please read our [Contributing Guide](.github/contributing.md) where you'll learn how the repo works, how to test your changes, and how to submit a pull request.
We welcome contributions from all developers regardless of experience level. If you are interested in contributing, please read our [Contributing Guide](.github/contributing.md) to learn how the repo works, how to test your changes, and how to submit a pull request.
<br />
See our [open source page](https://thirdweb.com/open-source) for more information on our open-source bounties and program.
## Community
## Additional Resources
The best place to discuss your ideas, ask questions, and troubleshoot issues is our [Discord server](https://discord.gg/thirdweb).
- [SDK Documentation](https://portal.thirdweb.com/typescript/v5)
- [Templates](https://thirdweb.com/templates)
- [YouTube](https://www.youtube.com/c/thirdweb_)
<br/>
## Support
For help or feedback, please [visit our support site](https://thirdweb.com/support)
## Security
@@ -1,5 +1,114 @@
# @thirdweb-dev/auth
## 4.1.51
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@2.4.29
## 4.1.50
### Patch Changes
- [#2577](https://github.com/thirdweb-dev/js/pull/2577) [`d93286b`](https://github.com/thirdweb-dev/js/commit/d93286bc1f8224d055b50ce3ffa4f302869cb2b1) Thanks [@jnsdls](https://github.com/jnsdls)! - update dependencies
- Updated dependencies [[`d93286b`](https://github.com/thirdweb-dev/js/commit/d93286bc1f8224d055b50ce3ffa4f302869cb2b1)]:
- @thirdweb-dev/wallets@2.4.28
## 4.1.49
### Patch Changes
- Updated dependencies [[`13f00cf`](https://github.com/thirdweb-dev/js/commit/13f00cf476b126683649a166e9e03b8e3f6599e4)]:
- @thirdweb-dev/wallets@2.4.27
## 4.1.48
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@2.4.26
## 4.1.47
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@2.4.25
## 4.1.46
### Patch Changes
- Updated dependencies [[`79c9e13`](https://github.com/thirdweb-dev/js/commit/79c9e130fdc6e1f7de1486894a5ac3e6d6776fa4)]:
- @thirdweb-dev/wallets@2.4.24
## 4.1.45
### Patch Changes
- Updated dependencies [[`802ba8c`](https://github.com/thirdweb-dev/js/commit/802ba8c5a980d3bddd308f9b3d14cc9cbb5453d5)]:
- @thirdweb-dev/wallets@2.4.23
## 4.1.44
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@2.4.22
## 4.1.43
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@2.4.21
## 4.1.42
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@2.4.20
## 4.1.41
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@2.4.19
## 4.1.40
### Patch Changes
- Updated dependencies [[`cabfc29`](https://github.com/thirdweb-dev/js/commit/cabfc29119f25a78010f59f766bdcb8c392afa2d)]:
- @thirdweb-dev/wallets@2.4.18
## 4.1.39
### Patch Changes
- Updated dependencies [[`c894270`](https://github.com/thirdweb-dev/js/commit/c894270401850575d1a4df73e16198177b46477a), [`332a145`](https://github.com/thirdweb-dev/js/commit/332a14552bf95e13e5220b1bd73414f000088568)]:
- @thirdweb-dev/wallets@2.4.17
## 4.1.38
### Patch Changes
- [#2417](https://github.com/thirdweb-dev/js/pull/2417) [`862905e`](https://github.com/thirdweb-dev/js/commit/862905e161a091c15eb9b054cfcca0e5d2879fd6) Thanks [@jnsdls](https://github.com/jnsdls)! - make verify login payload be self-sufficient
- Updated dependencies [[`862905e`](https://github.com/thirdweb-dev/js/commit/862905e161a091c15eb9b054cfcca0e5d2879fd6)]:
- @thirdweb-dev/wallets@2.4.16
## 4.1.37
### Patch Changes
- Updated dependencies [[`74a92dc`](https://github.com/thirdweb-dev/js/commit/74a92dcb7dc4be7d03bcb8b7211e87016f52a81f)]:
- @thirdweb-dev/wallets@2.4.15
## 4.1.36
### Patch Changes
@@ -1,6 +1,6 @@
<p align="center">
<br />
<a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/js/blob/main/packages/sdk/logo.svg?raw=true" width="200" alt=""/></a>
<a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/js/blob/main/legacy_packages/sdk/logo.svg?raw=true" width="200" alt=""/></a>
<br />
</p>
<h1 align="center">thirdweb Auth</h1>
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "4.1.36",
"version": "4.1.51",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
@@ -51,7 +51,7 @@
},
"./package.json": "./package.json"
},
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/auth",
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/auth",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
"sideEffects": false,
@@ -61,7 +61,7 @@
"lint": "eslint src/ && bunx publint --strict --level warning",
"fix": "eslint src/ --fix",
"clean": "rm -rf dist/ && rm -rf node_modules/",
"test": "mocha --config './test/.mocharc.json' --timeout 30000 --parallel './test/**/*.test.ts'",
"test": "vitest",
"push": "yalc push"
},
"preconstruct": {
@@ -80,48 +80,37 @@
}
},
"devDependencies": {
"@babel/core": "^7.23.7",
"@babel/preset-env": "^7.23.8",
"@babel/preset-typescript": "^7.23.3",
"@microsoft/api-documenter": "^7.22.30",
"@microsoft/api-extractor": "^7.36.3",
"@microsoft/tsdoc": "^0.14.1",
"@microsoft/api-documenter": "^7.24.1",
"@microsoft/api-extractor": "^7.43.0",
"@microsoft/tsdoc": "^0.14.2",
"@preconstruct/cli": "2.7.0",
"@swc-node/register": "^1.6.8",
"@swc/core": "^1.3.71",
"@swc-node/register": "^1.9.0",
"@swc/core": "^1.4.11",
"@thirdweb-dev/tsconfig": "workspace:*",
"@types/chai": "^4.3.5",
"@types/cookie": "^0.5.1",
"@types/cookie-parser": "^1.4.3",
"@types/express": "^4.17.13",
"@types/mocha": "^10.0.0",
"@types/uuid": "^9.0.5",
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.19.1",
"chai": "^4.3.6",
"@types/cookie": "^0.6.0",
"@types/cookie-parser": "^1.4.7",
"@types/express": "^4.17.21",
"@types/uuid": "^9.0.8",
"cookie-parser": "^1.4.6",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.9.0",
"eslint": "^8.57.0",
"eslint-config-thirdweb": "workspace:*",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-inclusive-language": "^2.2.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-tsdoc": "^0.2.16",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-inclusive-language": "^2.2.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-tsdoc": "^0.2.17",
"ethers": "^5.7.2",
"express": "^4.18.1",
"fastify": "^4.25.2",
"mocha": "^10.2.0",
"next": "^13.4",
"next-auth": "^4.22.3",
"prettier": "^3.1.1",
"typescript": "^5.3.3"
"express": "^4.19.2",
"fastify": "^4.26.2",
"next": "^13.5.6",
"next-auth": "^4.24.7",
"typescript": "5.4.3"
},
"peerDependencies": {
"cookie-parser": "^1.4.6",
"ethers": "^5",
"express": "^4",
"fastify": "^4.25.2",
"next": "^12 || ^13 || ^14",
"next": "^13.4 || ^14",
"next-auth": "^4"
},
"peerDependenciesMeta": {
@@ -145,12 +134,12 @@
}
},
"dependencies": {
"@fastify/cookie": "^9.1.0",
"@fastify/cookie": "^9.3.1",
"@thirdweb-dev/wallets": "workspace:*",
"cookie": "^0.5.0",
"cookie": "^0.6.0",
"fastify-type-provider-zod": "^1.1.9",
"uuid": "^9.0.1",
"zod": "^3.22.3"
"zod": "^3.22.4"
},
"engines": {
"node": ">=18"
@@ -23,14 +23,21 @@ import {
AuthenticateOptionsWithOptionalDomain,
AuthenticationPayload,
} from "./schema/authenticate";
import { ThirdwebAuthOptions } from "./types";
export class ThirdwebAuth {
private domain: string;
private wallet: GenericAuthWallet;
private options: ThirdwebAuthOptions;
constructor(wallet: GenericAuthWallet, domain: string) {
constructor(
wallet: GenericAuthWallet,
domain: string,
options: ThirdwebAuthOptions = {},
) {
this.wallet = wallet;
this.domain = domain;
this.options = options;
}
public updateWallet(wallet: GenericAuthWallet) {
@@ -66,9 +73,9 @@ export class ThirdwebAuth {
options?: VerifyOptionsWithOptionalDomain,
): Promise<string> {
return verifyLoginPayload({
wallet: this.wallet,
payload,
options: this.formatOptions(options),
clientOptions: this.options,
});
}
@@ -80,6 +87,7 @@ export class ThirdwebAuth {
wallet: this.wallet,
payload,
options: this.formatOptions(options),
clientOptions: this.options,
});
}
@@ -99,6 +107,7 @@ export class ThirdwebAuth {
wallet: this.wallet,
jwt,
options: this.formatOptions(options),
clientOptions: this.options,
});
}
@@ -14,6 +14,7 @@ import {
import { GenerateOptionsSchema } from "../schema/generate";
import { RefreshOptionsSchema } from "../schema/refresh";
import { verifyLoginPayload } from "./login";
import { verifySignature } from "./verify-signature";
function isBrowser() {
return typeof window !== "undefined";
@@ -71,15 +72,16 @@ export async function generateJWT({
wallet,
payload,
options,
clientOptions,
}: GenerateJwtParams): Promise<string> {
const parsedOptions = GenerateOptionsSchema.parse(options);
const userAddress = await verifyLoginPayload({
wallet,
payload,
options: {
domain: parsedOptions.domain,
...parsedOptions.verifyOptions,
},
clientOptions,
});
let session: Json | undefined = undefined;
@@ -156,6 +158,7 @@ export async function authenticateJWT<TSession extends Json = Json>({
wallet,
jwt,
options,
clientOptions,
}: AuthenticateJwtParams): Promise<User<TSession>> {
const parsedOptions = AuthenticateOptionsSchema.parse(options);
const { payload, signature } = parseJWT(jwt);
@@ -210,11 +213,13 @@ export async function authenticateJWT<TSession extends Json = Json>({
}
}
const verified = await wallet.verifySignature(
const verified = await verifySignature(
JSON.stringify(payload),
signature,
issuerAddress,
chainId,
clientOptions.clientId,
clientOptions.secretKey,
);
if (!verified) {
throw new Error(
@@ -10,6 +10,7 @@ import {
LoginPayloadDataSchema,
} from "../schema/login";
import { VerifyOptionsSchema } from "../schema/verify";
import { verifySignature } from "./verify-signature";
/**
* Create an EIP-4361 & CAIP-122 compliant message to sign based on the login payload
@@ -113,18 +114,12 @@ export async function buildAndSignLoginPayload({
}
export async function verifyLoginPayload({
wallet,
payload,
options,
clientOptions,
}: VerifyLoginPayloadParams): Promise<string> {
const parsedOptions = VerifyOptionsSchema.parse(options);
if (payload.payload.type !== wallet.type) {
throw new Error(
`Expected chain type '${wallet.type}' does not match chain type on payload '${payload.payload.type}'`,
);
}
// Check that the intended domain matches the domain of the payload
if (payload.payload.domain !== parsedOptions.domain) {
throw new Error(
@@ -204,16 +199,19 @@ export async function verifyLoginPayload({
// Check that the signing address is the claimed wallet address
const message = createLoginMessage(payload.payload);
const chainId =
wallet.type === "evm" && payload.payload.chain_id
? parseInt(payload.payload.chain_id)
: undefined;
const verified = await wallet.verifySignature(
const chainId = payload.payload.chain_id
? parseInt(payload.payload.chain_id)
: undefined;
const verified = await verifySignature(
message,
payload.signature,
payload.payload.address,
chainId,
clientOptions?.clientId,
clientOptions?.secretKey,
);
if (!verified) {
throw new Error(
`Signer address does not match payload address '${payload.payload.address.toLowerCase()}'`,
@@ -0,0 +1,35 @@
import { checkContractWalletSignature } from "@thirdweb-dev/wallets";
import { utils } from "ethers";
export async function verifySignature(
message: string,
signature: string,
address: string,
chainId?: number,
clientId?: string,
secretKey?: string,
): Promise<boolean> {
try {
const messageHash = utils.hashMessage(message);
const messageHashBytes = utils.arrayify(messageHash);
const recoveredAddress = utils.recoverAddress(messageHashBytes, signature);
if (recoveredAddress === address) {
return true;
}
} catch {
// no-op
}
if (!chainId) {
return false;
}
return checkContractWalletSignature(
message,
signature,
address,
chainId,
clientId,
secretKey,
);
}
@@ -7,6 +7,7 @@ import {
} from "./authenticate";
import { RefreshOptions } from "./refresh";
import { GenerateOptions } from "./generate";
import { ThirdwebAuthOptions } from "../types";
export type BuildLoginPayloadParams = {
wallet: GenericAuthWallet;
@@ -19,9 +20,9 @@ export type SignLoginPayloadParams = {
};
export type VerifyLoginPayloadParams = {
wallet: GenericAuthWallet;
payload: LoginPayload;
options: VerifyOptions;
clientOptions: ThirdwebAuthOptions;
};
export type BuildJwtParams = {
@@ -33,6 +34,7 @@ export type GenerateJwtParams = {
wallet: GenericAuthWallet;
payload: LoginPayload;
options: GenerateOptions;
clientOptions: ThirdwebAuthOptions;
};
export type RefreshJwtParams = {
@@ -45,4 +47,5 @@ export type AuthenticateJwtParams = {
wallet: GenericAuthWallet;
jwt: string;
options: AuthenticateOptions;
clientOptions: ThirdwebAuthOptions;
};
+4
View File
@@ -0,0 +1,4 @@
export type ThirdwebAuthOptions = {
clientId?: string;
secretKey?: string;
};
@@ -41,7 +41,7 @@ export function ThirdwebAuth<
): ThirdwebAuthReturnType<TData, TSession> {
const ctx = {
...cfg,
auth: new ThirdwebAuthSDK(cfg.wallet, cfg.domain),
auth: new ThirdwebAuthSDK(cfg.wallet, cfg.domain, cfg.thirdwebAuthOptions),
};
const router = express.Router();
@@ -1,4 +1,5 @@
import { ThirdwebAuth } from "../../core";
import { ThirdwebAuthOptions } from "../../core/types";
import { Json, LoginPayloadOutputSchema, User } from "../../core";
import type { GenericAuthWallet } from "@thirdweb-dev/wallets";
import { Request } from "express";
@@ -68,6 +69,7 @@ export type ThirdwebAuthConfig<
| ((user: User, req: Request) => void)
| ((user: User, req: Request) => Promise<void>);
};
thirdwebAuthOptions?: ThirdwebAuthOptions;
};
export type ThirdwebAuthContext<
@@ -44,7 +44,7 @@ export function ThirdwebAuth<
): ThirdwebAuthReturnType<TData, TSession> {
const ctx = {
...cfg,
auth: new ThirdwebAuthSDK(cfg.wallet, cfg.domain),
auth: new ThirdwebAuthSDK(cfg.wallet, cfg.domain, cfg.thirdwebAuthOptions),
};
const authRouter = async (
@@ -9,6 +9,7 @@ import {
import { z } from "zod";
import { IncomingMessage, ServerResponse } from "http";
import { ZodTypeProvider } from "fastify-type-provider-zod";
import { ThirdwebAuthOptions } from "../../core/types";
export const PayloadBodySchema = z.object({
address: z.string(),
@@ -76,6 +77,7 @@ export type ThirdwebAuthConfig<
| ((user: User, req: FastifyRequest) => void)
| ((user: User, req: FastifyRequest) => Promise<void>);
};
thirdwebAuthOptions?: ThirdwebAuthOptions;
};
export type ThirdwebAuthContext<
@@ -2,6 +2,7 @@ import type { GenericAuthWallet } from "@thirdweb-dev/wallets";
import { z } from "zod";
import { Json, LoginPayloadOutputSchema, User } from "../../core";
import { ThirdwebAuthOptions } from "../../core/types";
export const PayloadBodySchema = z.object({
address: z.string(),
@@ -55,8 +56,9 @@ export type ThirdwebAuthConfigShared = {
sameSite?: "lax" | "strict" | "none";
secure?: boolean;
};
thirdwebAuthOptions?: ThirdwebAuthOptions;
};
export type ThirdwebNextContext = {
params?: Record<string, string | string[]>
params?: Record<string, string | string[]>;
};
@@ -8,19 +8,10 @@ import loginHandler from "./routes/login";
import logoutHandler from "./routes/logout";
import userHandler from "./routes/user";
import switchAccountHandler from "./routes/switch-account";
import type {
ThirdwebAuthConfig,
ThirdwebAuthContext,
} from "./types";
import type {
ThirdwebAuthRoute,
ThirdwebNextContext,
} from "../common/types";
import type { ThirdwebAuthConfig, ThirdwebAuthContext } from "./types";
import type { ThirdwebAuthRoute, ThirdwebNextContext } from "../common/types";
export type {
ThirdwebAuthConfig,
ThirdwebAuthContext,
} from "./types";
export type { ThirdwebAuthConfig, ThirdwebAuthContext } from "./types";
export async function ThirdwebAuthRouter(
req: NextRequest,
@@ -44,7 +35,7 @@ export async function ThirdwebAuthRouter(
default:
return Response.json(
{ message: "Invalid route for authentication." },
{ status: 400},
{ status: 400 },
);
}
}
@@ -55,10 +46,13 @@ export function ThirdwebAuth<
>(cfg: ThirdwebAuthConfig<TData, TSession>) {
const authCtx = {
...cfg,
auth: new ThirdwebAuthSDK(cfg.wallet, cfg.domain),
auth: new ThirdwebAuthSDK(cfg.wallet, cfg.domain, cfg.thirdwebAuthOptions),
};
async function ThirdwebAuthHandler(req: NextRequest, ctx: ThirdwebNextContext) {
async function ThirdwebAuthHandler(
req: NextRequest,
ctx: ThirdwebNextContext,
) {
return await ThirdwebAuthRouter(req, ctx, authCtx as ThirdwebAuthContext);
}
@@ -52,7 +52,7 @@ export function ThirdwebAuth<
>(cfg: ThirdwebAuthConfig<TData, TSession>) {
const ctx = {
...cfg,
auth: new ThirdwebAuthSDK(cfg.wallet, cfg.domain),
auth: new ThirdwebAuthSDK(cfg.wallet, cfg.domain, cfg.thirdwebAuthOptions),
};
function ThirdwebAuthHandler(
+384
View File
@@ -0,0 +1,384 @@
import { ThirdwebAuth } from "../src/core";
import { EthersWallet } from "@thirdweb-dev/wallets/evm/wallets/ethers";
import { Wallet } from "ethers";
import { describe, it, beforeAll, beforeEach, expect } from "vitest";
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("dotenv-mono").load();
describe(
"Wallet Authentication - EVM",
{
timeout: 60000,
},
async () => {
let adminWallet: any, signerWallet: any, attackerWallet: any;
let auth: ThirdwebAuth;
beforeAll(async () => {
const [adminSigner, signerSigner, attackerSigner] = [
Wallet.createRandom(),
Wallet.createRandom(),
Wallet.createRandom(),
];
adminWallet = new EthersWallet(adminSigner);
signerWallet = new EthersWallet(signerSigner);
attackerWallet = new EthersWallet(attackerSigner);
auth = new ThirdwebAuth(signerWallet, "thirdweb.com", {
secretKey: process.env.TW_SECRET_KEY,
});
});
beforeEach(async () => {
auth.updateWallet(signerWallet);
});
it("Should verify logged in wallet", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const address = await auth.verify(payload);
expect(address).to.equal(await signerWallet.getAddress());
});
it("Should verify logged in wallet with chain ID and expiration", async () => {
const payload = await auth.login({
expirationTime: new Date(Date.now() + 1000 * 60 * 5),
chainId: "137",
});
auth.updateWallet(adminWallet);
const address = await auth.verify(payload, {
chainId: "137",
});
expect(address).to.equal(await signerWallet.getAddress());
});
it("Should verify payload with resources", async () => {
const payload = await auth.login({
resources: ["https://example.com", "https://test.com"],
});
auth.updateWallet(adminWallet);
const address = await auth.verify(payload, {
resources: ["https://example.com", "https://test.com"],
});
expect(address).to.equal(await signerWallet.getAddress());
});
it("Should reject payload without necessary resources", async () => {
const payload = await auth.login({
resources: ["https://example.com"],
});
auth.updateWallet(adminWallet);
try {
await auth.verify(payload, {
resources: ["https://example.com", "https://test.com"],
});
expect.fail();
} catch (err: any) {
expect(err.message).to.equal(
"Login request is missing required resources: https://test.com",
);
}
});
it("Should verify payload with customized statement", async () => {
const payload = await auth.login({
statement: "Please sign!",
});
auth.updateWallet(adminWallet);
const address = await auth.verify(payload, {
statement: "Please sign!",
});
expect(address).to.equal(await signerWallet.getAddress());
});
it("Should reject payload with incorrect statement", async () => {
const payload = await auth.login({
statement: "Please sign!",
});
auth.updateWallet(adminWallet);
try {
await auth.verify(payload, {
statement: "Please sign again!",
});
expect.fail();
} catch (err: any) {
expect(err.message).to.include(
"Expected statement 'Please sign again!' does not match statement on payload",
);
}
});
it("Should reject invalid nonce", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
try {
await auth.verify(payload, {
validateNonce: (nonce: string) => {
if (nonce === payload.payload.nonce) {
throw new Error();
}
},
});
expect.fail();
} catch (err: any) {
expect(err.message).to.equal("Login request nonce is invalid");
}
});
it("Should accept valid nonce", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const address = await auth.verify(payload, {
validateNonce: (nonce: string) => {
if (nonce !== payload.payload.nonce) {
throw new Error();
}
},
});
expect(address).to.equal(await signerWallet.getAddress());
});
it("Should reject payload with incorrect domain", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
try {
await auth.verify(payload, { domain: "test.thirdweb.com" });
expect.fail();
} catch (err: any) {
expect(err.message).to.equal(
"Expected domain 'test.thirdweb.com' does not match domain on payload 'thirdweb.com'",
);
}
});
it("Should reject expired login payload", async () => {
const payload = await auth.login({
expirationTime: new Date(Date.now() - 1000 * 60 * 5),
});
auth.updateWallet(adminWallet);
try {
await auth.verify(payload);
expect.fail();
} catch (err: any) {
expect(err.message).to.equal("Login request has expired");
}
});
it("Should reject payload with incorrect chain ID", async () => {
const payload = await auth.login({
chainId: "1",
});
auth.updateWallet(adminWallet);
try {
await auth.verify(payload, {
chainId: "137",
});
expect.fail();
} catch (err: any) {
expect(err.message).to.equal(
"Expected chain ID '137' does not match chain ID on payload '1'",
);
}
});
it("Should reject payload with incorrect signer", async () => {
const payload = await auth.login();
payload.payload.address = await attackerWallet.getAddress();
auth.updateWallet(adminWallet);
try {
await auth.verify(payload);
expect.fail();
} catch (err: any) {
expect(err.message).to.contain("does not match payload address");
}
});
it("Should generate valid authentication token", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload);
const user = await auth.authenticate(token);
expect(user.address).to.equal(await signerWallet.getAddress());
});
it("Should reject token with incorrect domain", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload);
try {
await auth.authenticate(token, { domain: "test.thirdweb.com" });
expect.fail();
} catch (err: any) {
expect(err.message).to.contain(
"Expected token to be for the domain 'test.thirdweb.com', but found token with domain 'thirdweb.com'",
);
}
});
it("Should reject token before invalid before", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload, {
invalidBefore: new Date(Date.now() + 1000 * 60 * 5),
});
try {
await auth.authenticate(token);
expect.fail();
} catch (err: any) {
expect(err.message).to.contain("This token is invalid before");
}
});
it("Should reject expired authentication token", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload, {
expirationTime: new Date(Date.now() - 1000 * 60 * 5),
});
try {
await auth.authenticate(token);
expect.fail();
} catch (err: any) {
expect(err.message).to.contain("This token expired");
}
});
it("Should reject if admin address is not connected wallet address", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload);
auth.updateWallet(signerWallet);
try {
await auth.authenticate(token);
expect.fail();
} catch (err: any) {
expect(err.message).to.contain(
`The expected issuer address '${await signerWallet.getAddress()}' did not match the token issuer address '${await adminWallet.getAddress()}'`,
);
}
});
it("Should accept token with valid token ID", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload, {
tokenId: "test",
});
const user = await auth.authenticate(token, {
validateTokenId: (tokenId: string) => {
if (tokenId !== "test") {
throw new Error();
}
},
});
expect(user.address).to.equal(await signerWallet.getAddress());
});
it("Should reject token with invalid token ID", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload, {
tokenId: "test",
});
try {
await auth.authenticate(token, {
validateTokenId: (tokenId: string) => {
if (tokenId !== "invalid") {
throw new Error();
}
},
});
expect.fail();
} catch (err: any) {
expect(err.message).to.contain("Token ID is invalid");
}
});
it("Should propagate session on token", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload, {
session: { role: "admin" },
});
const user = await auth.authenticate(token);
expect(user.address).to.equal(await signerWallet.getAddress());
expect(user.session).to.deep.equal({ role: "admin" });
});
it("Should call session callback function", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload, {
session: (address: string) => {
return { address, role: "admin" };
},
});
const user = await auth.authenticate(token);
expect(user.address).to.equal(await signerWallet.getAddress());
expect(user.session).to.deep.equal({
address: await signerWallet.getAddress(),
role: "admin",
});
});
it("Should authenticate with issuer address", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload);
auth.updateWallet(attackerWallet);
try {
await auth.authenticate(token);
expect.fail();
} catch (err: any) {
expect(err.message).to.contain("The expected issuer address");
}
const user = await auth.authenticate(token, {
issuerAddress: await adminWallet.getAddress(),
});
expect(user.address).to.equal(await signerWallet.getAddress());
});
},
);
@@ -0,0 +1,391 @@
import { LocalWallet, SmartWallet } from "@thirdweb-dev/wallets";
import { ThirdwebAuth } from "../src/core";
import { EthersWallet } from "@thirdweb-dev/wallets/evm/wallets/ethers";
import { Wallet } from "ethers";
import { describe, it, beforeEach, beforeAll, expect } from "vitest";
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("dotenv-mono").load();
describe(
"Wallet Authentication - EVM - Smart Wallet",
{
timeout: 60000,
},
async () => {
let adminWallet: any, signerWallet: any, attackerWallet: any;
let auth: ThirdwebAuth;
beforeAll(async () => {
const factoryAddress = "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052";
const chain = 421614;
const localWallet = new LocalWallet();
await localWallet.generate();
const smartWallet = new SmartWallet({
chain: chain,
factoryAddress: factoryAddress,
gasless: true,
secretKey: process.env.TW_SECRET_KEY,
});
await smartWallet.connect({ personalWallet: localWallet });
adminWallet = new EthersWallet(Wallet.createRandom());
signerWallet = smartWallet;
attackerWallet = new EthersWallet(Wallet.createRandom());
auth = new ThirdwebAuth(signerWallet, "thirdweb.com", {
secretKey: process.env.TW_SECRET_KEY,
});
});
beforeEach(async () => {
auth.updateWallet(signerWallet);
});
it("Should verify logged in wallet", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const address = await auth.verify(payload);
expect(address).to.equal(await signerWallet.getAddress());
});
it("Should verify logged in wallet with chain ID and expiration", async () => {
const payload = await auth.login({
expirationTime: new Date(Date.now() + 1000 * 60 * 5),
chainId: "421614",
});
auth.updateWallet(adminWallet);
const address = await auth.verify(payload, {
chainId: "421614",
});
expect(address).to.equal(await signerWallet.getAddress());
});
it("Should verify payload with resources", async () => {
const payload = await auth.login({
resources: ["https://example.com", "https://test.com"],
});
auth.updateWallet(adminWallet);
const address = await auth.verify(payload, {
resources: ["https://example.com", "https://test.com"],
});
expect(address).to.equal(await signerWallet.getAddress());
});
it("Should reject payload without necessary resources", async () => {
const payload = await auth.login({
resources: ["https://example.com"],
});
auth.updateWallet(adminWallet);
try {
await auth.verify(payload, {
resources: ["https://example.com", "https://test.com"],
});
expect.fail();
} catch (err: any) {
expect(err.message).to.equal(
"Login request is missing required resources: https://test.com",
);
}
});
it("Should verify payload with customized statement", async () => {
const payload = await auth.login({
statement: "Please sign!",
});
auth.updateWallet(adminWallet);
const address = await auth.verify(payload, {
statement: "Please sign!",
});
expect(address).to.equal(await signerWallet.getAddress());
});
it("Should reject payload with incorrect statement", async () => {
const payload = await auth.login({
statement: "Please sign!",
});
auth.updateWallet(adminWallet);
try {
await auth.verify(payload, {
statement: "Please sign again!",
});
expect.fail();
} catch (err: any) {
expect(err.message).to.include(
"Expected statement 'Please sign again!' does not match statement on payload",
);
}
});
it("Should reject invalid nonce", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
try {
await auth.verify(payload, {
validateNonce: (nonce: string) => {
if (nonce === payload.payload.nonce) {
throw new Error();
}
},
});
expect.fail();
} catch (err: any) {
expect(err.message).to.equal("Login request nonce is invalid");
}
});
it("Should accept valid nonce", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const address = await auth.verify(payload, {
validateNonce: (nonce: string) => {
if (nonce !== payload.payload.nonce) {
throw new Error();
}
},
});
expect(address).to.equal(await signerWallet.getAddress());
});
it("Should reject payload with incorrect domain", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
try {
await auth.verify(payload, { domain: "test.thirdweb.com" });
expect.fail();
} catch (err: any) {
expect(err.message).to.equal(
"Expected domain 'test.thirdweb.com' does not match domain on payload 'thirdweb.com'",
);
}
});
it("Should reject expired login payload", async () => {
const payload = await auth.login({
expirationTime: new Date(Date.now() - 1000 * 60 * 5),
});
auth.updateWallet(adminWallet);
try {
await auth.verify(payload);
expect.fail();
} catch (err: any) {
expect(err.message).to.equal("Login request has expired");
}
});
it("Should reject payload with incorrect chain ID", async () => {
const payload = await auth.login({
chainId: "1",
});
auth.updateWallet(adminWallet);
try {
await auth.verify(payload, {
chainId: "137",
});
expect.fail();
} catch (err: any) {
expect(err.message).to.equal(
"Expected chain ID '137' does not match chain ID on payload '1'",
);
}
});
it("Should reject payload with incorrect signer", async () => {
const payload = await auth.login();
payload.payload.address = await attackerWallet.getAddress();
auth.updateWallet(adminWallet);
try {
await auth.verify(payload);
expect.fail();
} catch (err: any) {
expect(err.message).to.contain("does not match payload address");
}
});
it("Should generate valid authentication token", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload);
const user = await auth.authenticate(token);
expect(user.address).to.equal(await signerWallet.getAddress());
});
it("Should reject token with incorrect domain", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload);
try {
await auth.authenticate(token, { domain: "test.thirdweb.com" });
expect.fail();
} catch (err: any) {
expect(err.message).to.contain(
"Expected token to be for the domain 'test.thirdweb.com', but found token with domain 'thirdweb.com'",
);
}
});
it("Should reject token before invalid before", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload, {
invalidBefore: new Date(Date.now() + 1000 * 60 * 5),
});
try {
await auth.authenticate(token);
expect.fail();
} catch (err: any) {
expect(err.message).to.contain("This token is invalid before");
}
});
it("Should reject expired authentication token", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload, {
expirationTime: new Date(Date.now() - 1000 * 60 * 5),
});
try {
await auth.authenticate(token);
expect.fail();
} catch (err: any) {
expect(err.message).to.contain("This token expired");
}
});
it("Should reject if admin address is not connected wallet address", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload);
auth.updateWallet(signerWallet);
try {
await auth.authenticate(token);
expect.fail();
} catch (err: any) {
expect(err.message).to.contain(
`The expected issuer address '${await signerWallet.getAddress()}' did not match the token issuer address '${await adminWallet.getAddress()}'`,
);
}
});
it("Should accept token with valid token ID", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload, {
tokenId: "test",
});
const user = await auth.authenticate(token, {
validateTokenId: (tokenId: string) => {
if (tokenId !== "test") {
throw new Error();
}
},
});
expect(user.address).to.equal(await signerWallet.getAddress());
});
it("Should reject token with invalid token ID", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload, {
tokenId: "test",
});
try {
await auth.authenticate(token, {
validateTokenId: (tokenId: string) => {
if (tokenId !== "invalid") {
throw new Error();
}
},
});
expect.fail();
} catch (err: any) {
expect(err.message).to.contain("Token ID is invalid");
}
});
it("Should propagate session on token", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload, {
session: { role: "admin" },
});
const user = await auth.authenticate(token);
expect(user.address).to.equal(await signerWallet.getAddress());
expect(user.session).to.deep.equal({ role: "admin" });
});
it("Should call session callback function", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload, {
session: (address: string) => {
return { address, role: "admin" };
},
});
const user = await auth.authenticate(token);
expect(user.address).to.equal(await signerWallet.getAddress());
expect(user.session).to.deep.equal({
address: await signerWallet.getAddress(),
role: "admin",
});
});
it("Should authenticate with issuer address", async () => {
const payload = await auth.login();
auth.updateWallet(adminWallet);
const token = await auth.generate(payload);
auth.updateWallet(attackerWallet);
try {
await auth.authenticate(token);
expect.fail();
} catch (err: any) {
expect(err.message).to.contain("The expected issuer address");
}
const user = await auth.authenticate(token, {
issuerAddress: await adminWallet.getAddress(),
});
expect(user.address).to.equal(await signerWallet.getAddress());
});
},
);
@@ -1,5 +1,57 @@
# @thirdweb-dev/chains
## 0.1.84
### Patch Changes
- [#2577](https://github.com/thirdweb-dev/js/pull/2577) [`d93286b`](https://github.com/thirdweb-dev/js/commit/d93286bc1f8224d055b50ce3ffa4f302869cb2b1) Thanks [@jnsdls](https://github.com/jnsdls)! - update dependencies
- [#2580](https://github.com/thirdweb-dev/js/pull/2580) [`50e7dba`](https://github.com/thirdweb-dev/js/commit/50e7dbaa9dae77cb8cd865405c322495e2498c65) Thanks [@github-actions](https://github.com/apps/github-actions)! - Synced Chains Package
## 0.1.83
### Patch Changes
- [#2559](https://github.com/thirdweb-dev/js/pull/2559) [`095d227`](https://github.com/thirdweb-dev/js/commit/095d227a13d0c9c1de76fa3812b7f71b2130d532) Thanks [@github-actions](https://github.com/apps/github-actions)! - Synced Chains Package
## 0.1.82
### Patch Changes
- [#2527](https://github.com/thirdweb-dev/js/pull/2527) [`cb0ef6a`](https://github.com/thirdweb-dev/js/commit/cb0ef6a6a25cee255e18b8489fdb4123bb69c279) Thanks [@github-actions](https://github.com/apps/github-actions)! - Synced Chains Package
## 0.1.81
### Patch Changes
- [#2496](https://github.com/thirdweb-dev/js/pull/2496) [`863049d`](https://github.com/thirdweb-dev/js/commit/863049dc0ca989d2654b4aacba811263931a33fe) Thanks [@jnsdls](https://github.com/jnsdls)! - do not append `?bundleId` query param to rpc url if the bundle id is undefined
- [#2427](https://github.com/thirdweb-dev/js/pull/2427) [`8a20aa5`](https://github.com/thirdweb-dev/js/commit/8a20aa58259edc5bac578dc5e4f4d971ed7adf36) Thanks [@github-actions](https://github.com/apps/github-actions)! - Synced Chains Package
## 0.1.80
### Patch Changes
- [#2484](https://github.com/thirdweb-dev/js/pull/2484) [`c494db8`](https://github.com/thirdweb-dev/js/commit/c494db87cbfa4b6fc4013abb01936e86a4350ea8) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Update chains
## 0.1.79
### Patch Changes
- [#2464](https://github.com/thirdweb-dev/js/pull/2464) [`2e01627`](https://github.com/thirdweb-dev/js/commit/2e01627c998a49a1dd41041f3743a28488c92697) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Sync chains
## 0.1.78
### Patch Changes
- [#2416](https://github.com/thirdweb-dev/js/pull/2416) [`588897d`](https://github.com/thirdweb-dev/js/commit/588897d1b04e6c63da13639aeb47ca701308e1b2) Thanks [@github-actions](https://github.com/apps/github-actions)! - Synced Chains Package
## 0.1.77
### Patch Changes
- [#2406](https://github.com/thirdweb-dev/js/pull/2406) [`047fbe2`](https://github.com/thirdweb-dev/js/commit/047fbe2918808cbc8fded90104458b6e38d1207d) Thanks [@github-actions](https://github.com/apps/github-actions)! - Synced Chains Package
## 0.1.76
### Patch Changes
@@ -1,6 +1,6 @@
<p align="center">
<br />
<a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/js/blob/main/packages/sdk/logo.svg?raw=true" width="200" alt=""/></a>
<a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/js/blob/main/legacy_packages/sdk/logo.svg?raw=true" width="200" alt=""/></a>
<br />
</p>
<h1 align="center">thirdweb chains</h1>
@@ -71,7 +71,9 @@ export default {
"wss://mainnet.gateway.tenderly.co",
"https://rpc.blocknative.com/boost",
"https://rpc.flashbots.net/fast",
"https://rpc.mevblocker.io/fullprivacy"
"https://rpc.mevblocker.io/fullprivacy",
"https://eth.drpc.org",
"wss://eth.drpc.org"
],
"shortName": "eth",
"slip44": 60,
@@ -57,7 +57,9 @@ export default {
"https://optimism.gateway.tenderly.co",
"wss://optimism.gateway.tenderly.co",
"https://optimism-rpc.publicnode.com",
"wss://optimism-rpc.publicnode.com"
"wss://optimism-rpc.publicnode.com",
"https://optimism.drpc.org",
"wss://optimism.drpc.org"
],
"shortName": "oeth",
"slug": "optimism",

Some files were not shown because too many files have changed in this diff Show More