Skip to content

Commit a8464f6

Browse files
Merge branch 'main' into ciara/tba
2 parents 8a07db2 + 41fd6f9 commit a8464f6

File tree

227 files changed

+5207
-1601
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

227 files changed

+5207
-1601
lines changed

.changeset/clever-buttons-bake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/sdk": patch
3+
---
4+
5+
Improve performance for contract-roles methods

.changeset/cold-dryers-dream.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
"@thirdweb-dev/react-native": patch
3+
---
4+
5+
Custom JWT support in React Native
6+
7+
Enables passing a custom JWT to the embeddedWallet:
8+
9+
```javascript
10+
import {
11+
embeddedWallet,
12+
ThirdwebProvider,
13+
useConnect,
14+
} from "@thirdweb-dev/react-native";
15+
import { Button } from "react-native";
16+
import React from "react";
17+
18+
const App = () => {
19+
return (
20+
<ThirdwebProvider
21+
supportedWallets={[
22+
embeddedWallet({
23+
custom_auth: true, // when true, it will not display a UI
24+
}),
25+
]}
26+
>
27+
<AppInner />
28+
</ThirdwebProvider>
29+
);
30+
};
31+
32+
const AppInner = () => {
33+
const connect = useConnect();
34+
35+
const triggerConnect = async () => {
36+
connect(embeddedWallet(), {
37+
loginType: "custom_jwt_auth",
38+
encryptionKey: "strong-encryption-key",
39+
jwtToken: "your-jwt-token",
40+
});
41+
};
42+
43+
return <Button title={"Connect with custom JWT"} onPress={triggerConnect} />;
44+
};
45+
```

.changeset/mean-lamps-tap.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/shy-mayflies-peel.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/strong-ghosts-leave.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/tame-snakes-retire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/wallets": patch
3+
---
4+
5+
Use BigInt function instead of bigint primitive numbers to fix broken Vite templates

.changeset/thick-buckets-deny.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@thirdweb-dev/chains": patch
3+
"@thirdweb-dev/sdk": patch
4+
---
5+
6+
Spicy Chain deployments

.changeset/warm-dots-rule.md

Lines changed: 0 additions & 27 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ playwright-report/
2020
.env/
2121

2222
# Artifacts
23-
packages/cli/artifacts/
23+
packages/cli/artifacts/
24+
25+
typedoc

packages/auth/CHANGELOG.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,57 @@
11
# @thirdweb-dev/auth
22

3+
## 4.1.0
4+
5+
### Minor Changes
6+
7+
- [#1801](https://github.com/thirdweb-dev/js/pull/1801) [`99d7ec06`](https://github.com/thirdweb-dev/js/commit/99d7ec06ec4f31308627edc87d3122c21a884b5a) Thanks [@adam-maj](https://github.com/adam-maj)! - Add support for fastify
8+
9+
### Patch Changes
10+
11+
- [#1812](https://github.com/thirdweb-dev/js/pull/1812) [`c238fde8`](https://github.com/thirdweb-dev/js/commit/c238fde8777fd14b39837117e2d3fda1dd301029) Thanks [@adam-maj](https://github.com/adam-maj)! - Update to call uuidv4 to generate jti
12+
13+
- [#1811](https://github.com/thirdweb-dev/js/pull/1811) [`54860198`](https://github.com/thirdweb-dev/js/commit/548601981f6dd8706d7a9bd4ca48e4abc7723a1d) Thanks [@adam-maj](https://github.com/adam-maj)! - Expose buildJWT function
14+
15+
- [#1812](https://github.com/thirdweb-dev/js/pull/1812) [`c238fde8`](https://github.com/thirdweb-dev/js/commit/c238fde8777fd14b39837117e2d3fda1dd301029) Thanks [@adam-maj](https://github.com/adam-maj)! - Update to use uuidv4 for default jti
16+
17+
- Updated dependencies [[`5ffbcfc3`](https://github.com/thirdweb-dev/js/commit/5ffbcfc302f74167768b196d93a328f979344036), [`d27a3dee`](https://github.com/thirdweb-dev/js/commit/d27a3dee8398d5707d2d1343c428abf8e03f67e3), [`ff996646`](https://github.com/thirdweb-dev/js/commit/ff996646b228d4d095eea04b05004dd26fc7e522), [`aa9f48d1`](https://github.com/thirdweb-dev/js/commit/aa9f48d1361194fc81146da530c95a3409bd0799), [`fd7a9f09`](https://github.com/thirdweb-dev/js/commit/fd7a9f09989e39b02a93d9dfd01cc7378e6ead53), [`2307f11a`](https://github.com/thirdweb-dev/js/commit/2307f11ab311aa4a775edd23e777d10f8015ce86), [`64138642`](https://github.com/thirdweb-dev/js/commit/64138642e84d8b56b254762eca613d443cca292b)]:
18+
- @thirdweb-dev/wallets@2.0.8
19+
20+
## 4.0.7
21+
22+
### Patch Changes
23+
24+
- Updated dependencies []:
25+
- @thirdweb-dev/wallets@2.0.7
26+
27+
## 4.0.6
28+
29+
### Patch Changes
30+
31+
- Updated dependencies []:
32+
- @thirdweb-dev/wallets@2.0.6
33+
34+
## 4.0.5
35+
36+
### Patch Changes
37+
38+
- Updated dependencies []:
39+
- @thirdweb-dev/wallets@2.0.5
40+
41+
## 4.0.4
42+
43+
### Patch Changes
44+
45+
- Updated dependencies []:
46+
- @thirdweb-dev/wallets@2.0.4
47+
48+
## 4.0.3
49+
50+
### Patch Changes
51+
52+
- Updated dependencies []:
53+
- @thirdweb-dev/wallets@2.0.3
54+
355
## 4.0.2
456

557
### Patch Changes

packages/auth/fastify/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"main": "dist/thirdweb-dev-auth-fastify.cjs.js",
3+
"module": "dist/thirdweb-dev-auth-fastify.esm.js",
4+
"browser": {
5+
"./dist/thirdweb-dev-auth-fastify.esm.js": "./dist/thirdweb-dev-auth-fastify.browser.esm.js"
6+
}
7+
}

packages/auth/package.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@thirdweb-dev/auth",
3-
"version": "4.0.2",
3+
"version": "4.1.0",
44
"main": "dist/thirdweb-dev-auth.cjs.js",
55
"module": "dist/thirdweb-dev-auth.esm.js",
66
"browser": {
@@ -35,6 +35,13 @@
3535
},
3636
"default": "./express/dist/thirdweb-dev-auth-express.cjs.js"
3737
},
38+
"./fastify": {
39+
"module": {
40+
"browser": "./fastify/dist/thirdweb-dev-auth-fastify.browser.esm.js",
41+
"default": "./fastify/dist/thirdweb-dev-auth-fastify.esm.js"
42+
},
43+
"default": "./fastify/dist/thirdweb-dev-auth-fastify.cjs.js"
44+
},
3845
"./next-auth": {
3946
"module": {
4047
"browser": "./next-auth/dist/thirdweb-dev-auth-next-auth.browser.esm.js",
@@ -63,6 +70,7 @@
6370
"express/index.ts",
6471
"next/index.ts",
6572
"next-auth/index.ts",
73+
"fastify/index.ts",
6674
"evm/index.ts"
6775
],
6876
"exports": {
@@ -101,6 +109,7 @@
101109
"eslint-plugin-tsdoc": "^0.2.16",
102110
"ethers": "^5.7.2",
103111
"express": "^4.18.1",
112+
"fastify": "^4.24.2",
104113
"mocha": "^10.2.0",
105114
"next": "^12.3.4",
106115
"next-auth": "^4.22.3",
@@ -111,6 +120,7 @@
111120
"cookie-parser": "^1.4.6",
112121
"ethers": "^5",
113122
"express": "^4",
123+
"fastify": "^4.24.2",
114124
"next": "^12 || ^13",
115125
"next-auth": "^4"
116126
},
@@ -124,6 +134,9 @@
124134
"express": {
125135
"optional": true
126136
},
137+
"fastify": {
138+
"optional": true
139+
},
127140
"next": {
128141
"optional": true
129142
},
@@ -132,8 +145,10 @@
132145
}
133146
},
134147
"dependencies": {
148+
"@fastify/cookie": "^9.1.0",
135149
"@thirdweb-dev/wallets": "workspace:*",
136150
"cookie": "^0.5.0",
151+
"fastify-type-provider-zod": "^1.1.9",
137152
"uuid": "^9.0.1",
138153
"zod": "^3.22.3"
139154
}

packages/auth/src/core/functions/jwt.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ function base64decode(data: string): string {
3838
/**
3939
* Build JWT token based on the authentication payload
4040
*/
41-
async function buildJWT({ wallet, payload }: BuildJwtParams): Promise<string> {
41+
export async function buildJWT({
42+
wallet,
43+
payload,
44+
}: BuildJwtParams): Promise<string> {
4245
const payloadData = AuthenticationPayloadDataSchema.parse(payload);
4346

4447
const message = JSON.stringify(payloadData);

packages/auth/src/core/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export { ThirdwebAuth } from "./auth";
33

44
// Export individual auth functions
55
export {
6+
buildJWT,
67
generateJWT,
78
parseJWT,
89
refreshJWT,

packages/auth/src/core/schema/authenticate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const AuthenticationPayloadDataSchema = z.object({
99
exp: RawDateSchema,
1010
nbf: RawDateSchema,
1111
iat: RawDateSchema,
12-
jti: z.string().default(uuidv4()),
12+
jti: z.string().default(() => uuidv4()),
1313
ctx: JsonSchema.optional(),
1414
});
1515

packages/auth/src/core/schema/login.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const LoginPayloadDataSchema = z.object({
4444
uri: z.string().optional(),
4545
version: z.string().default("1"),
4646
chain_id: z.string().optional(),
47-
nonce: z.string().default(uuidv4()),
47+
nonce: z.string().default(() => uuidv4()),
4848
issued_at: z
4949
.date()
5050
.default(new Date())

packages/auth/src/express/helpers/user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
THIRDWEB_AUTH_ACTIVE_ACCOUNT_COOKIE,
33
THIRDWEB_AUTH_TOKEN_COOKIE_PREFIX,
44
} from "../../constants";
5-
import { Json } from "../../core/schema";
5+
import { Json } from "../../core";
66
import { ThirdwebAuthContext, ThirdwebAuthUser } from "../types";
77
import { Request } from "express";
88

packages/auth/src/express/routes/login.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
THIRDWEB_AUTH_ACTIVE_ACCOUNT_COOKIE,
33
THIRDWEB_AUTH_TOKEN_COOKIE_PREFIX,
44
} from "../../constants";
5-
import { GenerateOptions } from "../../core";
5+
import { GenerateOptionsWithOptionalDomain } from "../../core";
66
import { LoginPayloadBodySchema, ThirdwebAuthContext } from "../types";
77
import { serialize } from "cookie";
88
import { Request, Response } from "express";
@@ -41,7 +41,7 @@ export default async function handler(
4141
? new Date(Date.now() + 1000 * ctx.authOptions.tokenDurationInSeconds)
4242
: undefined;
4343

44-
const generateOptions: GenerateOptions = {
44+
const generateOptions: GenerateOptionsWithOptionalDomain = {
4545
verifyOptions: {
4646
statement: ctx.authOptions?.statement,
4747
uri: ctx.authOptions?.uri,
@@ -68,6 +68,10 @@ export default async function handler(
6868
}
6969
}
7070

71+
if (ctx.callbacks?.onToken) {
72+
await ctx.callbacks.onToken(token, req);
73+
}
74+
7175
const {
7276
payload: { exp },
7377
} = ctx.auth.parseToken(token);
@@ -84,7 +88,7 @@ export default async function handler(
8488
sameSite: ctx.cookieOptions?.sameSite || "none",
8589
expires: new Date(exp * 1000),
8690
httpOnly: true,
87-
secure: true,
91+
secure: ctx.cookieOptions?.secure || true,
8892
},
8993
),
9094
serialize(THIRDWEB_AUTH_ACTIVE_ACCOUNT_COOKIE, payload.payload.address, {
@@ -93,7 +97,7 @@ export default async function handler(
9397
sameSite: ctx.cookieOptions?.sameSite || "none",
9498
expires: new Date(exp * 1000),
9599
httpOnly: true,
96-
secure: true,
100+
secure: ctx.cookieOptions?.secure || true,
97101
}),
98102
]);
99103

packages/auth/src/express/routes/logout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default async function handler(
3737
sameSite: ctx.cookieOptions?.sameSite || "none",
3838
expires: new Date(Date.now() + 5 * 1000),
3939
httpOnly: true,
40-
secure: true,
40+
secure: ctx.cookieOptions?.secure || true,
4141
}),
4242
);
4343

packages/auth/src/express/routes/switch-account.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default async function handler(
5555
sameSite: ctx.cookieOptions?.sameSite || "none",
5656
expires: cookieExpiration,
5757
httpOnly: true,
58-
secure: true,
58+
secure: ctx.cookieOptions?.secure || true,
5959
}),
6060
]);
6161

packages/auth/src/express/routes/user.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default async function handler(
5353
sameSite: ctx.cookieOptions?.sameSite || "none",
5454
expires: new Date(refreshedPayload.payload.exp * 1000),
5555
httpOnly: true,
56-
secure: true,
56+
secure: ctx.cookieOptions?.secure || true,
5757
},
5858
),
5959
serialize(THIRDWEB_AUTH_ACTIVE_ACCOUNT_COOKIE, user.address, {
@@ -62,7 +62,7 @@ export default async function handler(
6262
sameSite: ctx.cookieOptions?.sameSite || "none",
6363
expires: new Date(refreshedPayload.payload.exp * 1000),
6464
httpOnly: true,
65-
secure: true,
65+
secure: ctx.cookieOptions?.secure || true,
6666
}),
6767
]);
6868
}

0 commit comments

Comments
 (0)