Git Product home page Git Product logo

ironoxide-swift's Introduction

IronOxide Swift

Swift SDK for using IronCore Labs from your iOS mobile applications.

Setup (iOS)

  • Install libironoxide via Homebrew with brew install IronCoreLabs/ironcore/ironoxide.
  • Within XCode, go to File > Swift Packages > Add Package Dependency. Put in the URL for this GitHub repo and select the latest version to use. Then go to your build target Build Phases > Dependencies and select IronOxide from the list. Then you'll be able to import IronOxide into your XCode project.

SDK Documentation

Documentation for the latest GitHub tag can be viewed at https://ironcorelabs.github.io/ironoxide-swift/.

Version Compatibility

The following table shows the compatibility between the version of this Swift library and the required version of the ironoxide Homebrew library.

ironoxide-swift Homebrew ironoxide
0.16.x 0.15.0
0.15.0 0.14.7
0.14.0 0.14.2
0.13.2 0.13.2

Building and Testing on MacOS/Linux

Building and testing this library to run on MacOS/Linux varies pretty heavily depending on what architecture you are building for.

  • Install Swift via the recommended method. You should have at least Swift 5.2 installed.
  • This repo requires artifacts from building the IronOxide Swig Bindings repo so you'll need to have that repo checked out.
  • Build the C/C++ bindings within your ironoxide-swig-bindings/cpp checkout. This will generate a bunch of C/C++ header files in a sdk/generated folder as well as generate a library binary in the ironoxide-swig-bindings/target/release/ directory.
    • cargo build --release
  • Add a symlink in your /usr/local/lib directory to point to the .dylib or .so created above.
    • ln -s /path/to/ironoxide-swig-bindings/target/release/libironoxide.dylib libironoxide.dylib (or to libironoxide.so for Linux).
  • Add a symlink in your /usr/local/include/ directory to point to the C header files directory above.
    • ln -s /path/to/ironoxide-swig-bindings/cpp/generated/sdk ironoxide
  • Copy ironoxide.pc.in to your /usr/local/lib/pkgconfig (or /usr/lib/pkgconfig on Linux) directory.
    • cp /path/to/ironoxide-swig-bindings/cpp/ironoxide.pc.in ironoxide.pc
  • Replace %PREFIX% in ironoxide.pc from previous step with /usr/local
    • sed -i 's/%PREFIX%/\/usr\/local/' ironoxide.pc
  • Now you can compile this project via swift build. If successful this should generate a .build directory. You should also be able to run the tests via swift test as well (Linux users will need to run swift test --enable-test-discovery).

VSCode Setup

  • Install SwiftLint and SwiftFormat binaries.
  • Install the SwiftLint and SwiftFormat extensions. If you don't have it enabled already, enable the Format on Save option in VSCode.
  • Clone the sourcekit-lsp extension. Then follow the instructions for how to build and install the extension into VSCode. In order for this extension to work you'll need to have the sourcekit-lsp binary that came with your Swift installation in your path.

Generating Docs

We use jazzy to generate an HTML version of our API docs. Jazzy requires Ruby and can be installed with [sudo] gem install jazzy. On a Mac, the docs can be generated simply by running jazzy --module IronOxide from the root of the repository. This will generate a docs/ folder that contains the html files. To run jazzy on Linux, additional steps for installing and running can be found here. Documentation for this library is automatically updated via a GitHub action that runs when a new tag is pushed. The docs are hosted via GitHub Pages via the gh-pages branch of this repo.

Copyright (c) 2021 IronCore Labs, Inc. All rights reserved.

ironoxide-swift's People

Contributors

coltfred avatar ernieturner avatar giarc3 avatar skeet70 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ironoxide-swift's Issues

[SPIKE] Swift unit test research

Figure out how Swift unit tests work and what type of tests we want to write for the SDK wrappers. We'll likely need to do an integration level test for most things unless there's a good way to mock out the underlying C calls somehow. This ticket should probably be done somewhere in the middle of the rest of the tickets so we have a good understanding of the repo layout. Written as a SPIKE because trying to do all the unit tests in a single ticket would take forever.

Version upgrade to last

ironoxide-swift library does not support ironoxide-swig-bindings v0.14.7.
Please update this library for supporting ironoxide-swig-bindings v0.14.7.

Add sample iOS app to Swift repo

Work on a sample iOS app and README that we can add to the Swift repo to show how to use the SDK. Probably just a simple todo app like we have for Android.

Also need to test this on an actual device.

Use Jwt and JwtClaims types

Consuming latest ironoxide-cpp, user create, user verify, and device generate all need to use the new Jwt class.

Support timeout options on various SDK calls

We allow callers to specify HTTP timeout options in various places in ironoxide. All pre-init functions take an optional duration and the IronOxideConfig has a sdk_operation_timeout. Figure out how to pass those in from Swift.

Auth0 jwt validation error

if let ironJwt = Jwt(auth0IdToken) {
print(ironJwt)
}

This is showing error like this :

"'jwt' failed validation with the error 'JSON error: missing field pid at line 1 column 543'"

[SPIKE] Try to figure out how to handle memory leaks

There are various places within our Swift library where we're not feeing memory used within Rust correctly or completely, which will cause memory leaks in an application which uses our library. Places we've found so far:

  • The Util.collectTo method copies memory when converting from Rust vectors to Swift arrays. We should free the underlying memory after copying
  • When converting strings (Util.rustStringToSwift) from Rust to Swift, we're calling free methods on the underlying Rust types, but we aren't doing anything when we move data from Swift into Rust (Util.rustStringToSwift) which might also need work to free
  • Look into this comment about strings going out of scope when passing them to Rust.

Auth0 jwt error

@giarc3

let jwt = Jwt(auth0token)

Getting below error for Social logins(facebook and google)

"'jwt' failed validation with the error 'JSON error: duplicate field sid at line 1 column 780'"

Originally posted by @BaiXiaoYan in #57 (comment)

Add init with rotation functionality

Figure out the best way to implement the initialize_check_rotation method from IronOxide and how that works within Swift. Probably look at how we did it in Java.

Move initializeSearch to SearchOperations

Consuming the latest ironoxide-java, initialize_blind_index_search was moved from EncryptedBlindIndexSalt to IronOxide.

We need to match these changes and fix tests and imports.

Add struct and function docs

These can mostly come from ironoxide, but need to make sense in Swift (use nil instead of None, use typical swift doc comment format, etc).

Commit Swift docs to repo and update/commit on push to master

GitHub pages supports having a /docs folder in a projects tree to host docs for a project, e.g, https://ironcorelabs.github.io/ironoxide-swift/. Now that we have docs being generated via Jazzy, we should publish those on GitHub pages as it's as good a place as any to point to.

In order to keep them up to date without work, we should modify our GitHub actions build script to automatically update and commit them. Ideally we would do this when a tag is pushed since that will indicate a new version was released, but if that is too difficult then doing it on merge to master would also work.

Convert SDK code into Swift library

The Swift project that we've done a PoC for so far is in a Swift application with view files, etc. We should instead move that over to a Swift library that we can build and (somehow) publish for other projects to depend on. XCode has the ability to create a new Library project, we should start there and see what we can do.

As part of this, we should also figure out how to do some initial unit tests in order to test and run this library.

Experiment with memory management for C code

We had found a number of issues with the memory model between the JVM and ironoxide that caused us to implement a number of changes so that the JVM didn't crash when developers re-used things they passed down to our SDK. We should do some of the same experiments with Swift to see if it has the same problems and what types of changes we need to implement to make sure the same doesn't happen there.

Convert structs to classes and add deinit method to clear memory, clean up accessor methods to be properties

We need to deallocate the memory of our OpaquePointers when a Swift wrapping struct gets garbage collected. Unfortunately this cannot be done on structs as the deinit only exists on classes. So switch everything over to a class and add the deinit method and _delete call to clear the native struct.

Also, our wrapping structs all have accessor methods. It seems more Swift-like to have properties instead. Swift has evaluated properties but also can do lazy evaluation as well, so figure out the best way to make that work.

Add group SDK methods

Add wrappers for all Group SDK methods. Also includes work to create/expose out Swift structs for the input/output types.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.