diff --git a/Assets/Plugins/Web3AuthSDK/Editor/BuildPostProcess.cs b/Assets/Plugins/Web3AuthSDK/Editor/BuildPostProcess.cs index 64fba3a..cb1c0e0 100644 --- a/Assets/Plugins/Web3AuthSDK/Editor/BuildPostProcess.cs +++ b/Assets/Plugins/Web3AuthSDK/Editor/BuildPostProcess.cs @@ -39,7 +39,14 @@ public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProj urlSchemes.AddString(uri.Scheme); infoPlist.WriteToFile(infoPlistPath); - + + + + using (StreamWriter sw = File.AppendText(pathToBuiltProject + "/Podfile")) + { + sw.WriteLine("pod 'Firebase/Messaging', '6.6.0'\n"); + } + #endif } diff --git a/Assets/Plugins/Web3AuthSDK/Keystore/KeyStoreManagerUtils.cs b/Assets/Plugins/Web3AuthSDK/Keystore/KeyStoreManagerUtils.cs index 7db3419..2987f05 100644 --- a/Assets/Plugins/Web3AuthSDK/Keystore/KeyStoreManagerUtils.cs +++ b/Assets/Plugins/Web3AuthSDK/Keystore/KeyStoreManagerUtils.cs @@ -5,9 +5,20 @@ using Org.BouncyCastle.Crypto.Signers; using Org.BouncyCastle.Math; using Org.BouncyCastle.Utilities.Encoders; +using System.Runtime.InteropServices; public class KeyStoreManagerUtils { +#if UNITY_IOS + [DllImport("__Internal")] + extern static int web3auth_keystore_set(string key, string value); + + [DllImport("__Internal")] + extern static string web3auth_keystore_get(string key); + + [DllImport("__Internal")] + extern static int web3auth_keystore_delete(string key); +#endif public static string SESSION_ID = "sessionId"; public static string IV_KEY = "ivKey"; @@ -27,26 +38,35 @@ public static string getPubKey(string sessionId) static KeyStoreManagerUtils() { +#if !UNITY_IOS SecurePlayerPrefs.Init(); +#endif } public static void savePreferenceData(string key, string value) { +#if UNITY_IOS + web3auth_keystore_set(key, value); +#else SecurePlayerPrefs.SetString(key, value); +#endif } public static string getPreferencesData(string key) { +#if UNITY_IOS + return web3auth_keystore_get(key); +#else return SecurePlayerPrefs.GetString(key); +#endif } public static void deletePreferencesData(string key) { +#if UNITY_IOS + web3auth_keystore_delete(key); +#else SecurePlayerPrefs.DeleteKey(key); - } - - public static void clearPreferencesData() - { - SecurePlayerPrefs.DeleteAll(); +#endif } public static string getECDSASignature(string privateKey, string data){ diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index ede7a01..cb0144b 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -386,7 +386,18 @@ private void sessionTimeOutAPI() if (result != null) { - KeyStoreManagerUtils.clearPreferencesData(); + try + { + KeyStoreManagerUtils.deletePreferencesData(KeyStoreManagerUtils.EPHEM_PUBLIC_Key); + KeyStoreManagerUtils.deletePreferencesData(KeyStoreManagerUtils.IV_KEY); + KeyStoreManagerUtils.deletePreferencesData(KeyStoreManagerUtils.MAC); + KeyStoreManagerUtils.deletePreferencesData(KeyStoreManagerUtils.SESSION_ID); + KeyStoreManagerUtils.deletePreferencesData(web3AuthOptions.loginConfig?.Values.First()?.verifier); + } + catch (Exception ex) + { + Debug.LogError(ex.Message); + } } } } diff --git a/Assets/Plugins/Web3AuthSDK/iOS/WebAuthenticate.mm b/Assets/Plugins/Web3AuthSDK/iOS/WebAuthenticate.mm index 96f98a1..b391782 100644 --- a/Assets/Plugins/Web3AuthSDK/iOS/WebAuthenticate.mm +++ b/Assets/Plugins/Web3AuthSDK/iOS/WebAuthenticate.mm @@ -8,9 +8,74 @@ #import #import #import +#import extern "C" { void web3auth_launch(const char *url, const char *redirectUri, const char *objectName) { [WebAuthenticate launch:[NSString stringWithUTF8String:url] :[NSString stringWithUTF8String:redirectUri] :[NSString stringWithUTF8String:objectName]]; } + + int web3auth_keystore_set(const char* dataType, const char* value) { + NSMutableDictionary* attributes = nil; + NSMutableDictionary* query = [NSMutableDictionary dictionary]; + NSData* sata = [[NSString stringWithCString:value encoding:NSUTF8StringEncoding] dataUsingEncoding:NSUTF8StringEncoding]; + + [query setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass]; + [query setObject:(id)[NSString stringWithCString:dataType encoding:NSUTF8StringEncoding] forKey:(id)kSecAttrAccount]; + + OSStatus err = SecItemCopyMatching((CFDictionaryRef)query, NULL); + + if (err == noErr) { + attributes = [NSMutableDictionary dictionary]; + [attributes setObject:sata forKey:(id)kSecValueData]; + [attributes setObject:[NSDate date] forKey:(id)kSecAttrModificationDate]; + + err = SecItemUpdate((CFDictionaryRef)query, (CFDictionaryRef)attributes); + return (int)err; + } else if (err == errSecItemNotFound) { + attributes = [NSMutableDictionary dictionary]; + [attributes setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass]; + [attributes setObject:(id)[NSString stringWithCString:dataType encoding:NSUTF8StringEncoding] forKey:(id)kSecAttrAccount]; + [attributes setObject:sata forKey:(id)kSecValueData]; + [attributes setObject:[NSDate date] forKey:(id)kSecAttrCreationDate]; + [attributes setObject:[NSDate date] forKey:(id)kSecAttrModificationDate]; + err = SecItemAdd((CFDictionaryRef)attributes, NULL); + return (int)err; + } else { + return (int)err; + } + } + + char* web3auth_keystore_get(const char* dataType) { + NSMutableDictionary* query = [NSMutableDictionary dictionary]; + [query setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass]; + [query setObject:(id)[NSString stringWithCString:dataType encoding:NSUTF8StringEncoding] forKey:(id)kSecAttrAccount]; + [query setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnData]; + + CFDataRef cfresult = NULL; + OSStatus err = SecItemCopyMatching((CFDictionaryRef)query, (CFTypeRef*)&cfresult); + + if (err == noErr) { + NSData* passwordData = (__bridge_transfer NSData *)cfresult; + const char* value = [[[NSString alloc] initWithData:passwordData encoding:NSUTF8StringEncoding] UTF8String]; + char *str = strdup(value); + return str; + } else { + return NULL; + } + } + + int web3auth_keystore_delete(const char* dataType) { + NSMutableDictionary* query = [NSMutableDictionary dictionary]; + [query setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass]; + [query setObject:(id)[NSString stringWithCString:dataType encoding:NSUTF8StringEncoding] forKey:(id)kSecAttrAccount]; + + OSStatus err = SecItemDelete((CFDictionaryRef)query); + + if (err == noErr) { + return 0; + } else { + return (int)err; + } + } } diff --git a/Assets/StreamingAssets.meta b/Assets/StreamingAssets.meta deleted file mode 100644 index d33aabe..0000000 --- a/Assets/StreamingAssets.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: cdd52a26d71f14fc78447133899898d6 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/ProjectSettings/GvhProjectSettings.xml b/ProjectSettings/GvhProjectSettings.xml new file mode 100644 index 0000000..8ed9444 --- /dev/null +++ b/ProjectSettings/GvhProjectSettings.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file