Skip to content

Commit c8a4d2b

Browse files
Merge pull request #17 from Web3Auth/feat/add-corekit-key
coreKitKey and coreKitEd25519PrivKey added in Web3AuthResponse
2 parents 35c55e4 + 2615b6a commit c8a4d2b

File tree

5 files changed

+86
-3
lines changed

5 files changed

+86
-3
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
enum ErrorCode
2+
{
3+
NOUSERFOUND,
4+
ENCODING_ERROR,
5+
DECODING_ERROR,
6+
RUNTIME_ERROR,
7+
APP_CANCELLED,
8+
SOMETHING_WENT_WRONG,
9+
}
10+
sealed class Web3AuthError
11+
{
12+
public static string getError(ErrorCode errorCode)
13+
{
14+
switch (errorCode)
15+
{
16+
case ErrorCode.NOUSERFOUND:
17+
return "No user found, please login again!";
18+
case ErrorCode.ENCODING_ERROR:
19+
return "Encoding Error";
20+
case ErrorCode.DECODING_ERROR:
21+
return "Decoding Error";
22+
case ErrorCode.SOMETHING_WENT_WRONG:
23+
return "Something went wrong!";
24+
case ErrorCode.RUNTIME_ERROR:
25+
return "Runtime Error";
26+
case ErrorCode.APP_CANCELLED:
27+
return "App Cancelled!";
28+
29+
}
30+
return "";
31+
}
32+
}

Assets/Plugins/Web3AuthSDK/Types/Web3AuthError.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22
using System.Collections.Generic;
33

44
public class Web3AuthOptions {
5-
//public context: Context,
65
public string clientId { get; set; }
76
public Web3Auth.Network network { get; set; }
87
public Uri redirectUrl { get; set; }
9-
public string sdkUrl { get; set; } = "https://sdk.openlogin.com";
8+
public string sdkUrl {
9+
get {
10+
if (network == Web3Auth.Network.TESTNET)
11+
return "https://dev-sdk.openlogin.com";
12+
else
13+
return "https://sdk.openlogin.com";
14+
}
15+
set { }
16+
}
17+
1018
public WhiteLabelData whiteLabel { get; set; }
1119
public Dictionary<string, LoginConfigItem> loginConfig { get; set; }
20+
public bool? useCoreKitKey { get; set; } = false;
21+
public Web3Auth.ChainNamespace? chainNamespace { get; set; } = Web3Auth.ChainNamespace.EIP155;
1222
}

Assets/Plugins/Web3AuthSDK/Types/Web3AuthResponse.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
public UserInfo userInfo { get; set; }
66
public string error { get; set; }
77
public string sessionId { get; set; }
8+
public string coreKitKey { get; set; }
9+
public string coreKitEd25519PrivKey { get; set; }
810
}

Assets/Plugins/Web3AuthSDK/Web3Auth.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ public class Web3Auth: MonoBehaviour
1313
{
1414
public enum Network
1515
{
16-
MAINNET, TESTNET, CYAN
16+
MAINNET, TESTNET, CYAN, AQUA
17+
}
18+
19+
public enum ChainNamespace
20+
{
21+
EIP155, SOLANA
1722
}
1823

1924
private Web3AuthOptions web3AuthOptions;
@@ -411,6 +416,29 @@ private void sessionTimeOutAPI()
411416
}
412417
}
413418

419+
public string getPrivKey()
420+
{
421+
if (web3AuthResponse == null)
422+
return null
423+
424+
return web3AuthOptions.useCoreKitKey.Value ? web3AuthResponse.coreKitKey : web3AuthResponse.privKey;
425+
}
426+
427+
public string getEd25519PrivKey()
428+
{
429+
if (web3AuthResponse == null)
430+
return null
431+
432+
return web3AuthOptions.useCoreKitKey.Value ? web3AuthResponse.coreKitEd25519PrivKey : web3AuthResponse.ed25519PrivKey;
433+
}
434+
435+
public UserInfo getUserInfo()
436+
{
437+
if (web3AuthResponse == null)
438+
throw new Exception(Web3AuthError.getError(ErrorCode.NOUSERFOUND));
439+
440+
return web3AuthResponse.userInfo;
441+
}
414442

415443
public void Update()
416444
{

0 commit comments

Comments
 (0)