thirdweb 5.99.1-nightly-fb4c190eb3fa2da13da668281adf3ae45ed457a2-20250514000358 → 5.99.2-nightly-ae7407dca4f6577624a5ccc737e6b85d8ffb99f9-20250515000359

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/cjs/version.js +1 -1
  2. package/dist/cjs/wallets/in-app/core/actions/get-enclave-user-status.js +4 -6
  3. package/dist/cjs/wallets/in-app/core/actions/get-enclave-user-status.js.map +1 -1
  4. package/dist/cjs/wallets/in-app/web/in-app.js +76 -30
  5. package/dist/cjs/wallets/in-app/web/in-app.js.map +1 -1
  6. package/dist/cjs/wallets/in-app/web/lib/web-connector.js +9 -1
  7. package/dist/cjs/wallets/in-app/web/lib/web-connector.js.map +1 -1
  8. package/dist/esm/version.js +1 -1
  9. package/dist/esm/wallets/in-app/core/actions/get-enclave-user-status.js +4 -6
  10. package/dist/esm/wallets/in-app/core/actions/get-enclave-user-status.js.map +1 -1
  11. package/dist/esm/wallets/in-app/web/in-app.js +76 -30
  12. package/dist/esm/wallets/in-app/web/in-app.js.map +1 -1
  13. package/dist/esm/wallets/in-app/web/lib/web-connector.js +9 -1
  14. package/dist/esm/wallets/in-app/web/lib/web-connector.js.map +1 -1
  15. package/dist/types/version.d.ts +1 -1
  16. package/dist/types/wallets/in-app/core/actions/get-enclave-user-status.d.ts +1 -1
  17. package/dist/types/wallets/in-app/core/actions/get-enclave-user-status.d.ts.map +1 -1
  18. package/dist/types/wallets/in-app/web/in-app.d.ts +76 -30
  19. package/dist/types/wallets/in-app/web/in-app.d.ts.map +1 -1
  20. package/dist/types/wallets/in-app/web/lib/web-connector.d.ts.map +1 -1
  21. package/package.json +2 -2
  22. package/src/version.ts +1 -1
  23. package/src/wallets/in-app/core/actions/get-enclave-user-status.ts +5 -7
  24. package/src/wallets/in-app/web/in-app.ts +76 -30
  25. package/src/wallets/in-app/web/lib/in-app-integration.test.ts +112 -0
  26. package/src/wallets/in-app/web/lib/web-connector.ts +11 -1
  27. package/src/wallets/in-app/web/lib/in-app-backend.test.ts +0 -27
@@ -10,5 +10,5 @@ export declare function getUserStatus({ authToken, client, ecosystem, }: {
10
10
  authToken: string;
11
11
  client: ThirdwebClient;
12
12
  ecosystem?: Ecosystem;
13
- }): Promise<UserStatus | undefined>;
13
+ }): Promise<UserStatus>;
14
14
  //# sourceMappingURL=get-enclave-user-status.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-enclave-user-status.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/actions/get-enclave-user-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,EAClC,SAAS,EACT,MAAM,EACN,SAAS,GACV,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAwBlC"}
1
+ {"version":3,"file":"get-enclave-user-status.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/actions/get-enclave-user-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,EAClC,SAAS,EACT,MAAM,EACN,SAAS,GACV,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,GAAG,OAAO,CAAC,UAAU,CAAC,CAsBtB"}
@@ -20,7 +20,7 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
20
20
  * const account = await wallet.connect({
21
21
  * client,
22
22
  * chain,
23
- * strategy: "google",
23
+ * strategy: "google", // or "apple", "facebook","discord", "github", "twitch", "x", "telegram", "line", "coinbase", etc
24
24
  * });
25
25
  * ```
26
26
  *
@@ -28,15 +28,21 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
28
28
  *
29
29
  * ### Enable smart accounts and sponsor gas for your users:
30
30
  *
31
+ * With the `executionMode` option, you can enable smart accounts and sponsor gas for your users.
32
+ *
33
+ * **Using EIP-7702** (recommended):
34
+ *
35
+ * On chains with EIP-7702 enabled, you can upgrade the inapp wallet to a smart account, keeping the same address and performance as the regular EOA.
36
+ *
31
37
  * ```ts
32
38
  * import { inAppWallet } from "thirdweb/wallets";
33
39
  * import { sepolia } from "thirdweb/chains";
34
40
  *
35
41
  * const wallet = inAppWallet({
36
- * smartAccount: {
37
- * chain: sepolia,
42
+ * executionMode: {
43
+ * mode: "EIP7702",
38
44
  * sponsorGas: true,
39
- * },
45
+ * },
40
46
  * });
41
47
  *
42
48
  * // account will be a smart account with sponsored gas enabled
@@ -46,8 +52,28 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
46
52
  * });
47
53
  * ```
48
54
  *
55
+ * **Using EIP-4337**:
56
+ *
57
+ * On chains without EIP-7702 enabled, you can still use smart accounts using EIP-4337, this will return a different address (the smart contract address) than the regular EOA.
58
+ *
59
+ * ```ts
60
+ * import { inAppWallet } from "thirdweb/wallets/in-app";
61
+ *
62
+ * const wallet = inAppWallet({
63
+ * executionMode: {
64
+ * mode: "EIP4337",
65
+ * smartAccount: {
66
+ * chain: sepolia, // chain required for EIP-4337
67
+ * sponsorGas: true,
68
+ * }
69
+ * },
70
+ * });
71
+ * ```
72
+ *
49
73
  * ### Login with email
50
74
  *
75
+ * To login with email, you can use the `preAuthenticate` function to first send a verification code to the user's email, then login with the verification code.
76
+ *
51
77
  * ```ts
52
78
  * import { inAppWallet, preAuthenticate } from "thirdweb/wallets/in-app";
53
79
  *
@@ -70,22 +96,10 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
70
96
  * });
71
97
  * ```
72
98
  *
73
- * ### Login with SIWE
74
- * ```ts
75
- * import { inAppWallet, createWallet } from "thirdweb/wallets";
76
- *
77
- * const rabby = createWallet("io.rabby");
78
- * const inAppWallet = inAppWallet();
99
+ * ### Login with phone number
79
100
  *
80
- * const account = await inAppWallet.connect({
81
- * strategy: "wallet",
82
- * chain: mainnet,
83
- * wallet: rabby,
84
- * client: MY_CLIENT
85
- * });
86
- * ```
101
+ * Similar to email, you can login with a phone number by first sending a verification code to the user's phone number, then login with the verification code.
87
102
  *
88
- * ### Login with phone number
89
103
  * ```ts
90
104
  * import { inAppWallet, preAuthenticate } from "thirdweb/wallets/in-app";
91
105
  *
@@ -108,8 +122,28 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
108
122
  * });
109
123
  * ```
110
124
  *
125
+ * ### Login with another wallet (SIWE)
126
+ *
127
+ * You can also login to the in-app wallet with another existing wallet by signing a standard Sign in with Ethereum (SIWE) message.
128
+ *
129
+ * ```ts
130
+ * import { inAppWallet, createWallet } from "thirdweb/wallets";
131
+ *
132
+ * const rabby = createWallet("io.rabby");
133
+ * const inAppWallet = inAppWallet();
134
+ *
135
+ * const account = await inAppWallet.connect({
136
+ * strategy: "wallet",
137
+ * chain: mainnet,
138
+ * wallet: rabby,
139
+ * client: MY_CLIENT
140
+ * });
141
+ * ```
142
+ *
111
143
  * ### Login with passkey
112
144
  *
145
+ * You can also login with a passkey. This mode requires specifying whether it should create a new passkey, or sign in with an existing passkey. We recommend checking if the user has a passkey stored in their browser to automatically login with it.
146
+ *
113
147
  * ```ts
114
148
  * import { inAppWallet, hasStoredPasskey } from "thirdweb/wallets/in-app";
115
149
  *
@@ -125,6 +159,11 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
125
159
  * ```
126
160
  *
127
161
  * ### Connect to a guest account
162
+ *
163
+ * You can also connect to a guest account, this will create a new account for the user instantly and store it in the browser's local storage.
164
+ *
165
+ * You can later "upgrade" this account by linking another auth method, like email or phone for example. This will preserve the account's address and history.
166
+ *
128
167
  * ```ts
129
168
  * import { inAppWallet } from "thirdweb/wallets";
130
169
  *
@@ -138,19 +177,19 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
138
177
  *
139
178
  * ### Connect to a backend account
140
179
  *
141
- * for usage in backends, you might also need to provide a 'storage' to store auth tokens. In-memory usually works for most purposes.
180
+ * For usage in backends, you can create wallets with the `backend` strategy and a stable walletSecret.
181
+ *
182
+ * Make sure to keep that walletSecret safe as it is the key to access that wallet, never expose it to the client.
142
183
  *
143
184
  * ```ts
144
185
  * import { inAppWallet } from "thirdweb/wallets";
145
186
  *
146
- * const wallet = inAppWallet({
147
- * storage: inMemoryStorage, // for usage in backends/scripts
148
- * });
187
+ * const wallet = inAppWallet();
149
188
  *
150
189
  * const account = await wallet.connect({
151
190
  * client,
152
191
  * strategy: "backend",
153
- * walletSecret: "...", // Provided by your app
192
+ * walletSecret: "...", // Your own secret, keep it safe
154
193
  * });
155
194
  * ```
156
195
  *
@@ -186,16 +225,21 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
186
225
  * });
187
226
  * ```
188
227
  *
189
- * ### Specify a logo for your login page (Connect UI)
228
+ * ### Specify a logo, icon and name for your login page (Connect UI)
229
+ *
230
+ * You can specify a logo, icon and name for your login page to customize how in-app wallets are displayed in the Connect UI components (ConnectButton and ConnectEmbed).
231
+ *
190
232
  * ```ts
191
233
  * import { inAppWallet } from "thirdweb/wallets";
192
234
  * const wallet = inAppWallet({
193
235
  * metadata: {
194
- * image: {
195
- * src: "https://example.com/logo.png",
196
- * alt: "My logo",
197
- * width: 100,
198
- * height: 100,
236
+ * name: "My App",
237
+ * icon: "https://example.com/icon.png",
238
+ * image: {
239
+ * src: "https://example.com/logo.png",
240
+ * alt: "My logo",
241
+ * width: 100,
242
+ * height: 100,
199
243
  * },
200
244
  * },
201
245
  * });
@@ -203,6 +247,8 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
203
247
  *
204
248
  * ### Hide the ability to export the private key within the Connect Modal UI
205
249
  *
250
+ * By default, the Connect Modal will show a button to export the private key of the wallet. You can hide this button by setting the `hidePrivateKeyExport` option to `true`.
251
+ *
206
252
  * ```ts
207
253
  * import { inAppWallet } from "thirdweb/wallets";
208
254
  * const wallet = inAppWallet({
@@ -225,7 +271,7 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
225
271
  *
226
272
  * ### Override storage for the wallet state
227
273
  *
228
- * By default, wallet state is stored in the browser's local storage. You can override this behavior by providing a custom storage object, useful for server side integrations.
274
+ * By default, wallet state is stored in the browser's local storage if in the browser, or in-memory storage if not in the browser. You can override this behavior by providing a custom storage object, useful for server side and CLI integrations.
229
275
  *
230
276
  * ```ts
231
277
  * import { inAppWallet } from "thirdweb/wallets";
@@ -1 +1 @@
1
- {"version":3,"file":"in-app.d.ts","sourceRoot":"","sources":["../../../../../src/wallets/in-app/web/in-app.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0PG;AACH,wBAAgB,WAAW,CACzB,aAAa,CAAC,EAAE,0BAA0B,GACzC,MAAM,CAAC,OAAO,CAAC,CAYjB"}
1
+ {"version":3,"file":"in-app.d.ts","sourceRoot":"","sources":["../../../../../src/wallets/in-app/web/in-app.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwSG;AACH,wBAAgB,WAAW,CACzB,aAAa,CAAC,EAAE,0BAA0B,GACzC,MAAM,CAAC,OAAO,CAAC,CAYjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"web-connector.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/web/lib/web-connector.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAiB7D,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,mCAAmC,EACnC,OAAO,EACP,gBAAgB,EAChB,qBAAqB,EACrB,yBAAyB,EACzB,OAAO,EACP,sBAAsB,EACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EAAE,IAAI,EAAyB,MAAM,uBAAuB,CAAC;AAKpE;;GAEG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IACtD,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,OAAO,CAAkD;IACjE,OAAO,CAAC,OAAO,CAAsB;IAErC,OAAO,CAAC,MAAM,CAAC,CAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,CAAC,aAAa,CAAC,CAAS;IAE/B,OAAO,CAAC,qBAAqB;IAO7B;;;;OAIG;gBACS,EACV,MAAM,EACN,aAAa,EACb,SAAS,EACT,aAAa,EACb,OAAO,GACR,EAAE,0BAA0B;IA6FvB,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAwC/D;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAejC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAOxB,eAAe,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/D,wBAAwB,CAC5B,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,EACtC,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC;IAUV,kBAAkB,CACtB,UAAU,EAAE,mCAAmC,EAC/C,YAAY,CAAC,EAAE,MAAM;IAKvB;;OAEG;IACG,YAAY,CAChB,IAAI,EAAE,qBAAqB,GAAG,sBAAsB,GACnD,OAAO,CAAC,mCAAmC,CAAC;IAoF/C;;OAEG;IACG,OAAO,CACX,IAAI,EAAE,qBAAqB,GAAG,sBAAsB,GACnD,OAAO,CAAC,mBAAmB,CAAC;IA8CzB,MAAM,IAAI,OAAO,CAAC,gBAAgB,CAAC;YAI3B,WAAW;IAgCnB,WAAW,CAAC,IAAI,EAAE,YAAY;IAU9B,aAAa,CAAC,OAAO,EAAE,OAAO;IAS9B,WAAW;CAOlB"}
1
+ {"version":3,"file":"web-connector.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/web/lib/web-connector.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAiB7D,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,mCAAmC,EACnC,OAAO,EACP,gBAAgB,EAChB,qBAAqB,EACrB,yBAAyB,EACzB,OAAO,EACP,sBAAsB,EACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EAAE,IAAI,EAAyB,MAAM,uBAAuB,CAAC;AAKpE;;GAEG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IACtD,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,OAAO,CAAkD;IACjE,OAAO,CAAC,OAAO,CAAsB;IAErC,OAAO,CAAC,MAAM,CAAC,CAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,CAAC,aAAa,CAAC,CAAS;IAE/B,OAAO,CAAC,qBAAqB;IAO7B;;;;OAIG;gBACS,EACV,MAAM,EACN,aAAa,EACb,SAAS,EACT,aAAa,EACb,OAAO,GACR,EAAE,0BAA0B;IA6FvB,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAwC/D;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAejC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAOxB,eAAe,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/D,wBAAwB,CAC5B,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,EACtC,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC;IAUV,kBAAkB,CACtB,UAAU,EAAE,mCAAmC,EAC/C,YAAY,CAAC,EAAE,MAAM;IAKvB;;OAEG;IACG,YAAY,CAChB,IAAI,EAAE,qBAAqB,GAAG,sBAAsB,GACnD,OAAO,CAAC,mCAAmC,CAAC;IAoF/C;;OAEG;IACG,OAAO,CACX,IAAI,EAAE,qBAAqB,GAAG,sBAAsB,GACnD,OAAO,CAAC,mBAAmB,CAAC;IA8CzB,MAAM,IAAI,OAAO,CAAC,gBAAgB,CAAC;YAI3B,WAAW;IAgCnB,WAAW,CAAC,IAAI,EAAE,YAAY;IAU9B,aAAa,CAAC,OAAO,EAAE,OAAO;IAS9B,WAAW;CAOlB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thirdweb",
3
- "version": "5.99.1-nightly-fb4c190eb3fa2da13da668281adf3ae45ed457a2-20250514000358",
3
+ "version": "5.99.2-nightly-ae7407dca4f6577624a5ccc737e6b85d8ffb99f9-20250515000359",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/thirdweb-dev/js.git#main"
@@ -250,7 +250,7 @@
250
250
  "toml": "3.0.0",
251
251
  "uqr": "0.1.2",
252
252
  "viem": "2.28.1",
253
- "@thirdweb-dev/engine": "3.0.0",
253
+ "@thirdweb-dev/engine": "3.0.1-nightly-ae7407dca4f6577624a5ccc737e6b85d8ffb99f9-20250515000359",
254
254
  "@thirdweb-dev/insight": "1.0.0"
255
255
  },
256
256
  "peerDependencies": {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.99.1-nightly-fb4c190eb3fa2da13da668281adf3ae45ed457a2-20250514000358";
1
+ export const version = "5.99.2-nightly-ae7407dca4f6577624a5ccc737e6b85d8ffb99f9-20250515000359";
@@ -17,7 +17,7 @@ export async function getUserStatus({
17
17
  authToken: string;
18
18
  client: ThirdwebClient;
19
19
  ecosystem?: Ecosystem;
20
- }): Promise<UserStatus | undefined> {
20
+ }): Promise<UserStatus> {
21
21
  const clientFetch = getClientFetch(client, ecosystem);
22
22
  const response = await clientFetch(
23
23
  `${getThirdwebBaseUrl("inAppWallet")}/api/2024-05-05/accounts`,
@@ -32,12 +32,10 @@ export async function getUserStatus({
32
32
  );
33
33
 
34
34
  if (!response.ok) {
35
- if (response.status === 401) {
36
- // 401 response indicates there is no user logged in, so we return undefined
37
- return undefined;
38
- }
39
- const result = await response.json();
40
- throw new Error(`Failed to get user status: ${result.message}`);
35
+ const result = await response.text().catch(() => {
36
+ return "Unknown error";
37
+ });
38
+ throw new Error(`Failed to get user info: ${result}`);
41
39
  }
42
40
 
43
41
  return (await response.json()) as UserStatus;
@@ -23,7 +23,7 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
23
23
  * const account = await wallet.connect({
24
24
  * client,
25
25
  * chain,
26
- * strategy: "google",
26
+ * strategy: "google", // or "apple", "facebook","discord", "github", "twitch", "x", "telegram", "line", "coinbase", etc
27
27
  * });
28
28
  * ```
29
29
  *
@@ -31,15 +31,21 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
31
31
  *
32
32
  * ### Enable smart accounts and sponsor gas for your users:
33
33
  *
34
+ * With the `executionMode` option, you can enable smart accounts and sponsor gas for your users.
35
+ *
36
+ * **Using EIP-7702** (recommended):
37
+ *
38
+ * On chains with EIP-7702 enabled, you can upgrade the inapp wallet to a smart account, keeping the same address and performance as the regular EOA.
39
+ *
34
40
  * ```ts
35
41
  * import { inAppWallet } from "thirdweb/wallets";
36
42
  * import { sepolia } from "thirdweb/chains";
37
43
  *
38
44
  * const wallet = inAppWallet({
39
- * smartAccount: {
40
- * chain: sepolia,
45
+ * executionMode: {
46
+ * mode: "EIP7702",
41
47
  * sponsorGas: true,
42
- * },
48
+ * },
43
49
  * });
44
50
  *
45
51
  * // account will be a smart account with sponsored gas enabled
@@ -49,8 +55,28 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
49
55
  * });
50
56
  * ```
51
57
  *
58
+ * **Using EIP-4337**:
59
+ *
60
+ * On chains without EIP-7702 enabled, you can still use smart accounts using EIP-4337, this will return a different address (the smart contract address) than the regular EOA.
61
+ *
62
+ * ```ts
63
+ * import { inAppWallet } from "thirdweb/wallets/in-app";
64
+ *
65
+ * const wallet = inAppWallet({
66
+ * executionMode: {
67
+ * mode: "EIP4337",
68
+ * smartAccount: {
69
+ * chain: sepolia, // chain required for EIP-4337
70
+ * sponsorGas: true,
71
+ * }
72
+ * },
73
+ * });
74
+ * ```
75
+ *
52
76
  * ### Login with email
53
77
  *
78
+ * To login with email, you can use the `preAuthenticate` function to first send a verification code to the user's email, then login with the verification code.
79
+ *
54
80
  * ```ts
55
81
  * import { inAppWallet, preAuthenticate } from "thirdweb/wallets/in-app";
56
82
  *
@@ -73,22 +99,10 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
73
99
  * });
74
100
  * ```
75
101
  *
76
- * ### Login with SIWE
77
- * ```ts
78
- * import { inAppWallet, createWallet } from "thirdweb/wallets";
79
- *
80
- * const rabby = createWallet("io.rabby");
81
- * const inAppWallet = inAppWallet();
102
+ * ### Login with phone number
82
103
  *
83
- * const account = await inAppWallet.connect({
84
- * strategy: "wallet",
85
- * chain: mainnet,
86
- * wallet: rabby,
87
- * client: MY_CLIENT
88
- * });
89
- * ```
104
+ * Similar to email, you can login with a phone number by first sending a verification code to the user's phone number, then login with the verification code.
90
105
  *
91
- * ### Login with phone number
92
106
  * ```ts
93
107
  * import { inAppWallet, preAuthenticate } from "thirdweb/wallets/in-app";
94
108
  *
@@ -111,8 +125,28 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
111
125
  * });
112
126
  * ```
113
127
  *
128
+ * ### Login with another wallet (SIWE)
129
+ *
130
+ * You can also login to the in-app wallet with another existing wallet by signing a standard Sign in with Ethereum (SIWE) message.
131
+ *
132
+ * ```ts
133
+ * import { inAppWallet, createWallet } from "thirdweb/wallets";
134
+ *
135
+ * const rabby = createWallet("io.rabby");
136
+ * const inAppWallet = inAppWallet();
137
+ *
138
+ * const account = await inAppWallet.connect({
139
+ * strategy: "wallet",
140
+ * chain: mainnet,
141
+ * wallet: rabby,
142
+ * client: MY_CLIENT
143
+ * });
144
+ * ```
145
+ *
114
146
  * ### Login with passkey
115
147
  *
148
+ * You can also login with a passkey. This mode requires specifying whether it should create a new passkey, or sign in with an existing passkey. We recommend checking if the user has a passkey stored in their browser to automatically login with it.
149
+ *
116
150
  * ```ts
117
151
  * import { inAppWallet, hasStoredPasskey } from "thirdweb/wallets/in-app";
118
152
  *
@@ -128,6 +162,11 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
128
162
  * ```
129
163
  *
130
164
  * ### Connect to a guest account
165
+ *
166
+ * You can also connect to a guest account, this will create a new account for the user instantly and store it in the browser's local storage.
167
+ *
168
+ * You can later "upgrade" this account by linking another auth method, like email or phone for example. This will preserve the account's address and history.
169
+ *
131
170
  * ```ts
132
171
  * import { inAppWallet } from "thirdweb/wallets";
133
172
  *
@@ -141,19 +180,19 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
141
180
  *
142
181
  * ### Connect to a backend account
143
182
  *
144
- * for usage in backends, you might also need to provide a 'storage' to store auth tokens. In-memory usually works for most purposes.
183
+ * For usage in backends, you can create wallets with the `backend` strategy and a stable walletSecret.
184
+ *
185
+ * Make sure to keep that walletSecret safe as it is the key to access that wallet, never expose it to the client.
145
186
  *
146
187
  * ```ts
147
188
  * import { inAppWallet } from "thirdweb/wallets";
148
189
  *
149
- * const wallet = inAppWallet({
150
- * storage: inMemoryStorage, // for usage in backends/scripts
151
- * });
190
+ * const wallet = inAppWallet();
152
191
  *
153
192
  * const account = await wallet.connect({
154
193
  * client,
155
194
  * strategy: "backend",
156
- * walletSecret: "...", // Provided by your app
195
+ * walletSecret: "...", // Your own secret, keep it safe
157
196
  * });
158
197
  * ```
159
198
  *
@@ -189,16 +228,21 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
189
228
  * });
190
229
  * ```
191
230
  *
192
- * ### Specify a logo for your login page (Connect UI)
231
+ * ### Specify a logo, icon and name for your login page (Connect UI)
232
+ *
233
+ * You can specify a logo, icon and name for your login page to customize how in-app wallets are displayed in the Connect UI components (ConnectButton and ConnectEmbed).
234
+ *
193
235
  * ```ts
194
236
  * import { inAppWallet } from "thirdweb/wallets";
195
237
  * const wallet = inAppWallet({
196
238
  * metadata: {
197
- * image: {
198
- * src: "https://example.com/logo.png",
199
- * alt: "My logo",
200
- * width: 100,
201
- * height: 100,
239
+ * name: "My App",
240
+ * icon: "https://example.com/icon.png",
241
+ * image: {
242
+ * src: "https://example.com/logo.png",
243
+ * alt: "My logo",
244
+ * width: 100,
245
+ * height: 100,
202
246
  * },
203
247
  * },
204
248
  * });
@@ -206,6 +250,8 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
206
250
  *
207
251
  * ### Hide the ability to export the private key within the Connect Modal UI
208
252
  *
253
+ * By default, the Connect Modal will show a button to export the private key of the wallet. You can hide this button by setting the `hidePrivateKeyExport` option to `true`.
254
+ *
209
255
  * ```ts
210
256
  * import { inAppWallet } from "thirdweb/wallets";
211
257
  * const wallet = inAppWallet({
@@ -228,7 +274,7 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
228
274
  *
229
275
  * ### Override storage for the wallet state
230
276
  *
231
- * By default, wallet state is stored in the browser's local storage. You can override this behavior by providing a custom storage object, useful for server side integrations.
277
+ * By default, wallet state is stored in the browser's local storage if in the browser, or in-memory storage if not in the browser. You can override this behavior by providing a custom storage object, useful for server side and CLI integrations.
232
278
  *
233
279
  * ```ts
234
280
  * import { inAppWallet } from "thirdweb/wallets";
@@ -0,0 +1,112 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { TEST_CLIENT } from "~test/test-clients.js";
3
+ import { sepolia } from "../../../../chains/chain-definitions/sepolia.js";
4
+ import { parseEventLogs } from "../../../../event/actions/parse-logs.js";
5
+ import { userOperationEventEvent } from "../../../../extensions/erc4337/__generated__/IEntryPoint/events/UserOperationEvent.js";
6
+ import { executedEvent } from "../../../../extensions/erc7702/__generated__/MinimalAccount/events/Executed.js";
7
+ import { sendAndConfirmTransaction } from "../../../../transaction/actions/send-and-confirm-transaction.js";
8
+ import { prepareTransaction } from "../../../../transaction/prepare-transaction.js";
9
+ import { inAppWallet } from "../in-app.js";
10
+ describe("InAppWallet Integration Tests", () => {
11
+ it("should sign a message with backend strategy", async () => {
12
+ const wallet = inAppWallet();
13
+ const account = await wallet.connect({
14
+ client: TEST_CLIENT,
15
+ strategy: "backend",
16
+ walletSecret: "test-secret",
17
+ });
18
+ expect(account.address).toBeDefined();
19
+ const message = await account.signMessage({
20
+ message: "Hello, world!",
21
+ });
22
+ expect(message).toBeDefined();
23
+ });
24
+
25
+ it("should sign a message with guest strategy", async () => {
26
+ const wallet = inAppWallet();
27
+ const account = await wallet.connect({
28
+ client: TEST_CLIENT,
29
+ strategy: "guest",
30
+ });
31
+ expect(account.address).toBeDefined();
32
+ const message = await account.signMessage({
33
+ message: "Hello, world!",
34
+ });
35
+ expect(message).toBeDefined();
36
+ });
37
+
38
+ it("should sponsor gas for a 7702 smart account", async () => {
39
+ const chain = sepolia;
40
+ const wallet = inAppWallet({
41
+ executionMode: {
42
+ mode: "EIP7702",
43
+ sponsorGas: true,
44
+ },
45
+ });
46
+ const account = await wallet.connect({
47
+ client: TEST_CLIENT,
48
+ strategy: "guest",
49
+ chain,
50
+ });
51
+ expect(account.address).toBeDefined();
52
+ const tx = await sendAndConfirmTransaction({
53
+ transaction: prepareTransaction({
54
+ chain,
55
+ client: TEST_CLIENT,
56
+ to: account.address,
57
+ value: 0n,
58
+ }),
59
+ account,
60
+ });
61
+ expect(tx.transactionHash).toBeDefined();
62
+ const logs = parseEventLogs({
63
+ logs: tx.logs,
64
+ events: [executedEvent()],
65
+ });
66
+ const executedLog = logs[0];
67
+ if (!executedLog) {
68
+ throw new Error("No executed log found");
69
+ }
70
+ expect(executedLog.args.to).toBe(account.address);
71
+ expect(executedLog.args.value).toBe(0n);
72
+ });
73
+
74
+ it("should sponsor gas for a 4337 smart account", async () => {
75
+ const chain = sepolia;
76
+ const wallet = inAppWallet({
77
+ executionMode: {
78
+ mode: "EIP4337",
79
+ smartAccount: {
80
+ chain,
81
+ sponsorGas: true,
82
+ },
83
+ },
84
+ });
85
+ const account = await wallet.connect({
86
+ client: TEST_CLIENT,
87
+ strategy: "guest",
88
+ chain,
89
+ });
90
+ expect(account.address).toBeDefined();
91
+ const tx = await sendAndConfirmTransaction({
92
+ transaction: prepareTransaction({
93
+ chain,
94
+ client: TEST_CLIENT,
95
+ to: account.address,
96
+ value: 0n,
97
+ }),
98
+ account,
99
+ });
100
+ expect(tx.transactionHash).toBeDefined();
101
+ const logs = parseEventLogs({
102
+ logs: tx.logs,
103
+ events: [userOperationEventEvent()],
104
+ });
105
+ const executedLog = logs[0];
106
+ if (!executedLog) {
107
+ throw new Error("No executed log found");
108
+ }
109
+ expect(executedLog.args.sender).toBe(account.address);
110
+ expect(executedLog.args.success).toBe(true);
111
+ });
112
+ });
@@ -1,5 +1,7 @@
1
1
  import type { ThirdwebClient } from "../../../../client/client.js";
2
2
  import { getThirdwebBaseUrl } from "../../../../utils/domains.js";
3
+ import type { AsyncStorage } from "../../../../utils/storage/AsyncStorage.js";
4
+ import { inMemoryStorage } from "../../../../utils/storage/inMemoryStorage.js";
3
5
  import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
4
6
  import type { SocialAuthOption } from "../../../../wallets/types.js";
5
7
  import type { Account } from "../../../interfaces/wallet.js";
@@ -86,7 +88,7 @@ export class InAppWebConnector implements InAppConnector {
86
88
  this.ecosystem = ecosystem;
87
89
  this.passkeyDomain = passkeyDomain;
88
90
  this.storage = new ClientScopedStorage({
89
- storage: storage ?? webLocalStorage,
91
+ storage: storage ?? getDefaultStorage(),
90
92
  clientId: client.clientId,
91
93
  ecosystem: ecosystem,
92
94
  });
@@ -489,3 +491,11 @@ export class InAppWebConnector implements InAppConnector {
489
491
  function assertUnreachable(x: never, message?: string): never {
490
492
  throw new Error(message ?? `Invalid param: ${x}`);
491
493
  }
494
+
495
+ function getDefaultStorage(): AsyncStorage {
496
+ if (typeof window !== "undefined" && window.localStorage) {
497
+ return webLocalStorage;
498
+ }
499
+ // default to in-memory storage if we're not in the browser
500
+ return inMemoryStorage;
501
+ }
@@ -1,27 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { TEST_CLIENT } from "~test/test-clients.js";
3
- import { sepolia } from "../../../../chains/chain-definitions/sepolia.js";
4
- import { inMemoryStorage } from "../../../../utils/storage/inMemoryStorage.js";
5
- import { inAppWallet } from "../in-app.js";
6
-
7
- describe("InAppWallet", () => {
8
- it("should sign a message with backend strategy", async () => {
9
- const wallet = inAppWallet({
10
- smartAccount: {
11
- chain: sepolia,
12
- sponsorGas: true,
13
- },
14
- storage: inMemoryStorage,
15
- });
16
- const account = await wallet.connect({
17
- client: TEST_CLIENT,
18
- strategy: "backend",
19
- walletSecret: "test-secret",
20
- });
21
- expect(account.address).toBeDefined();
22
- const message = await account.signMessage({
23
- message: "Hello, world!",
24
- });
25
- expect(message).toBeDefined();
26
- });
27
- });