1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-04 17:43:17 +00:00
This commit is contained in:
Hinton
2023-04-24 14:57:12 +02:00
parent 1823efa0e5
commit 464d1f8a9a
6 changed files with 79 additions and 1 deletions

View File

@@ -183,6 +183,9 @@ namespace Bit.iOS
}
});
var sdkClient = new BitwardenClient();
var test = sdkClient.Fingerprint();
return base.FinishedLaunching(app, options);
}

View File

@@ -0,0 +1,31 @@
using System;
namespace Bit.iOS
{
public class BitwardenClient : IDisposable
{
private readonly BitwardenClientSafeHandle handle;
public BitwardenClient()
{
handle = BitwardenClientWrapper.init("");
}
public string Fingerprint()
{
return BitwardenClientWrapper.run_command("{}", handle.Ptr);
}
protected virtual void Dispose(bool disposing)
{
if (handle != null && !handle.IsInvalid)
handle.Dispose();
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
using Microsoft.Win32.SafeHandles;
namespace Bit.iOS
{
internal class BitwardenClientSafeHandle : SafeHandleZeroOrMinusOneIsInvalid
{
public BitwardenClientSafeHandle() : base(true) { }
public IntPtr Ptr => this.handle;
protected override bool ReleaseHandle()
{
BitwardenClientWrapper.free_mem(handle);
return true;
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Runtime.InteropServices;
namespace Bit.iOS
{
internal static class BitwardenClientWrapper
{
#if Android
const string DllName = "libBitwardenC.so";
#else
const string DllName = "__Internal";
#endif
[DllImport(DllName, EntryPoint = "init")]
internal static extern BitwardenClientSafeHandle init(string settings);
[DllImport(DllName, EntryPoint = "free_mem")]
internal static extern void free_mem(IntPtr clientPtr);
[DllImport(DllName, EntryPoint = "run_command")]
internal static extern string run_command(string loginRequest, IntPtr clientPtr);
}
}

View File

@@ -29,7 +29,7 @@
<MtouchLink>None</MtouchLink>
<MtouchDebug>true</MtouchDebug>
<OptimizePNGs>true</OptimizePNGs>
<MtouchExtraArgs>--nodevcodeshare --http-message-handler=NSUrlSessionHandler -gcc_flags "-L${ProjectDir}/../../lib/ios -largon2 -force_load ${ProjectDir}/../../lib/ios/libargon2.a"</MtouchExtraArgs>
<MtouchExtraArgs>--nodevcodeshare --http-message-handler=NSUrlSessionHandler -gcc_flags "-L${ProjectDir}/../../lib/ios -largon2 -force_load ${ProjectDir}/../../lib/ios/libargon2.a -lbitwarden_c -force_load ${ProjectDir}/../../lib/ios/libbitwarden_c.a.a"</MtouchExtraArgs>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
@@ -144,6 +144,9 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="BitwardenClient.cs" />
<Compile Include="BitwardenClientSafeHandle.cs" />
<Compile Include="BitwardenClientWrapper.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="Services\iOSPushNotificationHandler.cs" />
<Compile Include="Services\iOSPushNotificationService.cs" />