mirror of
https://github.com/bitwarden/mobile
synced 2025-12-05 23:53:33 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bdbc30873 | ||
|
|
39bfda0a24 | ||
|
|
3172b0d571 | ||
|
|
464d1f8a9a |
BIN
lib/ios/libbitwarden_c.a
Normal file
BIN
lib/ios/libbitwarden_c.a
Normal file
Binary file not shown.
@@ -11,6 +11,21 @@ namespace Bit.iOS.Autofill
|
||||
get; set;
|
||||
}
|
||||
|
||||
public override void FinishedLaunching(UIApplication application)
|
||||
{
|
||||
|
||||
var ln = @"libbitwarden_c.framework/libbitwarden_c";
|
||||
var documentsPath = NSBundle.MainBundle.BundlePath;
|
||||
var filePath = System.IO.Path.Combine(documentsPath, "Frameworks", ln);
|
||||
var ptr = ObjCRuntime.Dlfcn.dlopen(filePath, 0);
|
||||
|
||||
var sdkClient = new BitwardenClient();
|
||||
var test = sdkClient.Fingerprint();
|
||||
|
||||
|
||||
base.FinishedLaunching(application);
|
||||
}
|
||||
|
||||
public override void OnResignActivation(UIApplication application)
|
||||
{
|
||||
}
|
||||
|
||||
31
src/iOS.Autofill/BitwardenClient.cs
Normal file
31
src/iOS.Autofill/BitwardenClient.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
18
src/iOS.Autofill/BitwardenClientSafeHandle.cs
Normal file
18
src/iOS.Autofill/BitwardenClientSafeHandle.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
23
src/iOS.Autofill/BitwardenClientWrapper.cs
Normal file
23
src/iOS.Autofill/BitwardenClientWrapper.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -194,6 +194,9 @@
|
||||
<InterfaceDefinition Include="MainInterface.storyboard" />
|
||||
<BundleResource Include="Resources\MaterialIcons_Regular.ttf" />
|
||||
<BundleResource Include="Resources\bwi-font.ttf" />
|
||||
<Compile Include="BitwardenClient.cs" />
|
||||
<Compile Include="BitwardenClientSafeHandle.cs" />
|
||||
<Compile Include="BitwardenClientWrapper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
@@ -278,5 +281,11 @@
|
||||
<ItemGroup>
|
||||
<BundleResource Include="Resources\yubikey%403x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<NativeReference Include="..\..\..\sdk\libbitwarden_c.framework">
|
||||
<Kind>Framework</Kind>
|
||||
<SmartLink>False</SmartLink>
|
||||
</NativeReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.AppExtension.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -182,7 +182,15 @@ namespace Bit.iOS
|
||||
LoggerHelper.LogEvenIfCantBeResolved(ex);
|
||||
}
|
||||
});
|
||||
|
||||
var ln = @"libbitwarden_c.framework/libbitwarden_c";
|
||||
var documentsPath = NSBundle.MainBundle.BundlePath;
|
||||
var filePath = System.IO.Path.Combine(documentsPath, "Frameworks", ln);
|
||||
var ptr = ObjCRuntime.Dlfcn.dlopen(filePath, 0);
|
||||
|
||||
var sdkClient = new BitwardenClient();
|
||||
var test = sdkClient.Fingerprint();
|
||||
|
||||
return base.FinishedLaunching(app, options);
|
||||
}
|
||||
|
||||
|
||||
31
src/iOS/BitwardenClient.cs
Normal file
31
src/iOS/BitwardenClient.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
18
src/iOS/BitwardenClientSafeHandle.cs
Normal file
18
src/iOS/BitwardenClientSafeHandle.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
23
src/iOS/BitwardenClientWrapper.cs
Normal file
23
src/iOS/BitwardenClientWrapper.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -183,6 +183,9 @@
|
||||
<ImageAsset Include="Resources\Assets.xcassets\empty_items_state.imageset\Empty-items-state-dark.pdf" />
|
||||
<ImageAsset Include="Resources\Assets.xcassets\empty_items_state.imageset\Empty-items-state.pdf" />
|
||||
<ImageAsset Include="Resources\Assets.xcassets\empty_items_state.imageset\Contents.json" />
|
||||
<Compile Include="BitwardenClient.cs" />
|
||||
<Compile Include="BitwardenClientSafeHandle.cs" />
|
||||
<Compile Include="BitwardenClientWrapper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InterfaceDefinition Include="LaunchScreen.storyboard" />
|
||||
@@ -424,6 +427,12 @@
|
||||
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
|
||||
<_ResolvedWatchAppReferences Include="$(WatchAppBundleFullPath)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<NativeReference Include="..\..\..\sdk\libbitwarden_c.framework">
|
||||
<Kind>Framework</Kind>
|
||||
<SmartLink>False</SmartLink>
|
||||
</NativeReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(_ResolvedWatchAppReferences)' != '' ">
|
||||
<CodesignExtraArgs>--deep</CodesignExtraArgs>
|
||||
</PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user