Skip to content

Commit 4e19c2f

Browse files
authored
Unity 4.10.0 - Phone EWS, Native Only (#2687)
1 parent 0e479e2 commit 4e19c2f

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

.changeset/pretty-radios-joke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/unity-js-bridge": patch
3+
---
4+
5+
Unity 4.9.2 - Phone EWS, Native Only

packages/unity-js-bridge/src/thirdweb-bridge.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ interface TWBridge {
108108
smartWalletIsDeployed: () => Promise<string>;
109109
resolveENSFromAddress: (address: string) => Promise<string>;
110110
resolveAddressFromENS: (ens: string) => Promise<string>;
111+
copyBuffer: (text: string) => Promise<void>;
111112
}
112113

113114
const w = window;
@@ -151,7 +152,7 @@ class ThirdwebBridge implements TWBridge {
151152
}
152153
(globalThis as any).X_SDK_NAME = "UnitySDK_WebGL";
153154
(globalThis as any).X_SDK_PLATFORM = "unity";
154-
(globalThis as any).X_SDK_VERSION = "4.9.1";
155+
(globalThis as any).X_SDK_VERSION = "4.10.0";
155156
(globalThis as any).X_SDK_OS = browser?.os ?? "unknown";
156157
}
157158
this.initializedChain = chain;
@@ -296,6 +297,7 @@ class ThirdwebBridge implements TWBridge {
296297
chainId: string,
297298
password?: string,
298299
email?: string,
300+
phoneNumber?: string,
299301
personalWallet: PossibleWallet = "localWallet",
300302
authOptions?: string,
301303
smartWalletAccountOverride?: string,
@@ -316,9 +318,9 @@ class ThirdwebBridge implements TWBridge {
316318
const embeddedWallet = walletInstance as EmbeddedWallet;
317319
const authOptionsParsed = JSON.parse(authOptions || "{}");
318320
if (authOptionsParsed.authProvider === 0) {
319-
// DefaultManaged
321+
// EmailOTP
320322
if (!email) {
321-
throw new Error("Email is required for EmbeddedWallet");
323+
throw new Error("Email is required for EmailOTP auth provider");
322324
}
323325
const authResult = await embeddedWallet.authenticate({
324326
strategy: "iframe_email_verification",
@@ -332,12 +334,15 @@ class ThirdwebBridge implements TWBridge {
332334
// OAuth
333335
let authProvider: EmbeddedWalletOauthStrategy;
334336
switch (authOptionsParsed.authProvider) {
337+
// Google
335338
case 1:
336339
authProvider = "google";
337340
break;
341+
// Apple
338342
case 2:
339343
authProvider = "apple";
340344
break;
345+
// Facebook
341346
case 3:
342347
authProvider = "facebook";
343348
break;
@@ -383,6 +388,24 @@ class ThirdwebBridge implements TWBridge {
383388
chainId: chainIdNumber,
384389
authResult,
385390
});
391+
} else if (authOptionsParsed.authProvider === 6) {
392+
// PhoneOTP
393+
throw new Error(
394+
"PhoneOTP auth provider not implemented yet for WebGL, stay tuned!",
395+
);
396+
// if (!phoneNumber) {
397+
// throw new Error(
398+
// "Phone number is required for PhoneOTP auth provider",
399+
// );
400+
// }
401+
// const authResult = await embeddedWallet.authenticate({
402+
// strategy: "iframe_phone_number_verification",
403+
// phoneNumber,
404+
// });
405+
// await embeddedWallet.connect({
406+
// chainId: chainIdNumber,
407+
// authResult,
408+
// });
386409
} else {
387410
throw new Error(
388411
"Invalid auth provider: " + authOptionsParsed.authProvider,
@@ -885,6 +908,12 @@ class ThirdwebBridge implements TWBridge {
885908
return JSON.stringify({ result: res });
886909
}
887910

911+
public async copyBuffer(text: string) {
912+
navigator.clipboard.writeText(text).catch(function (err) {
913+
console.error("Could not copy text: ", err);
914+
});
915+
}
916+
888917
public openPopupWindow() {
889918
const win = window.open("", undefined, "width=350, height=500");
890919
if (win) {

0 commit comments

Comments
 (0)