Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
WaaS SDK 1.0.3 (#44)
Browse files Browse the repository at this point in the history
WaaS SDK 1.0.3
- Update yarn dependencies
- Improvements to iOS layer
- Add OpenSSL build script
- Update README
  • Loading branch information
yuga-cb authored Jul 11, 2023
1 parent 9ff2ffc commit 33778e3
Show file tree
Hide file tree
Showing 15 changed files with 2,198 additions and 1,798 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,8 @@ ios/WaasSdkGo.xcframework/ios-arm64/WaasSdkGo.framework
ios/WaasSdkGo.xcframework/ios-arm64-simulator/WaasSdkGo.framework
ios/WaasSdkGo.xcframework/ios-x86_64-simulator/WaasSdkGo.framework

# OpenSSL
ios/openssl_libcrypto.xcframework

# Android built-frameworks
android/libs/go-internal*.aar
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ios/openssl_libcrypto.xcframework:
./scripts/build_openssl.sh

clean-ssl:
rm -rf /tmp/openssl-1.1.1t
rm -rf /tmp/openssl-1.1.1ta
rm -rf /tmp/openssl-1.1.1tb

ssl: ios/openssl_libcrypto.xcframework

11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ For iOS development:
- [Xcode 14.0+](https://developer.apple.com/xcode/)
- iOS15.2+ simulator (iPhone 14 recommended)
- [CocoaPods](https://guides.cocoapods.org/using/getting-started.html)
- [make](https://www.gnu.org/software/make/)

For Android development:
- [Android Studio](https://developer.android.com/studio)
Expand Down Expand Up @@ -55,6 +56,16 @@ yarn bootstrap # Install packages for the root and /example directories
yarn example start # Start the Metro server
yarn example ios --simulator "iPhone 14" # Build and start the app on iOS simulator
```

This comment has been minimized.

Copy link
@mrNmrsBenejam

mrNmrsBenejam Oct 13, 2023

npm install --save @coinbase/waas-sdk-react-native

> *NOTE:* To build an app that depends on the WaaS SDK, you'll also need a compatible version of OpenSSL.
> You can build the OpenSSL framework by running the following on your Mac from the root of this repository:
>
> `yarn ssl-ios`
>
> You can alternatively depend on an open-compiled version of OpenSSL, like [OpenSSL-Universal](https://cocoapods.org/pods/OpenSSL-Universal), by adding the following to your app's Podfile:
>
> `pod "OpenSSL-Universal"`
### Android
Ensure you have the following [Android environment variables](https://developer.android.com/studio/command-line/variables) set correctly:

Expand Down
171 changes: 86 additions & 85 deletions ios/MPCKeyService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,22 @@ class MPCKeyService: NSObject {
Resolves with string "stopped polling for pending DeviceGroup" if polling is stopped successfully;
resolves with the empty string otherwise.
*/
@objc(stopPollingForPendingSeeds:withRejecter:)
func stopPollingForPendingSeed(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
@objc(stopPollingForPendingDeviceGroup:withRejecter:)
func stopPollingForPendingDeviceGroup(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
if self.keyClient == nil {
reject(self.mpcKeyServiceErr, self.uninitializedErr, nil)
return
}

var result: String?
var error: NSError?

result = self.keyClient?.stopPollingPendingDeviceGroup(&error)

if error != nil {
reject(self.mpcKeyServiceErr, error!.localizedDescription, nil)
} else {
resolve(result! as NSString)
let callback: (String?, Error?) -> Void = { data, error in
if let error = error {
reject(self.mpcKeyServiceErr, error.localizedDescription, nil)
} else {
resolve(data ?? "")
}
}

self.keyClient?.stopPollingPendingDeviceBackups(wrapGo(callback))
}

/**
Expand All @@ -118,20 +117,23 @@ class MPCKeyService: NSObject {
*/
@objc(createSignatureFromTx:withTransaction:withResolver:withRejecter:)
func createSignatureFromTx(_ parent: NSString, transaction: NSDictionary,
resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
if self.keyClient == nil {
reject(self.mpcKeyServiceErr, self.uninitializedErr, nil)
return
}

let callback: (String?, Error?) -> Void = { data, error in
if let error = error {
reject(self.mpcKeyServiceErr, error.localizedDescription, nil)
} else {
resolve(data ?? "")
}
}

do {
let serializedTx = try JSONSerialization.data(withJSONObject: transaction)
var error: NSError?
let operationName = self.keyClient?.createTxSignature(parent as String, tx: serializedTx, error: &error)
if error != nil {
reject(self.mpcKeyServiceErr, error?.localizedDescription, nil)
}
resolve(operationName)
self.keyClient?.createTxSignature(parent as String, tx: serializedTx, receiver: wrapGo(callback))
} catch {
reject(self.mpcKeyServiceErr, error.localizedDescription, nil)
}
Expand Down Expand Up @@ -174,22 +176,21 @@ class MPCKeyService: NSObject {
resolves with the empty string otherwise.
*/
@objc(stopPollingForPendingSignatures:withRejecter:)
func stopPollingForPendingSignatures(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
func stopPollingForPendingSignatures(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
if self.keyClient == nil {
reject(self.mpcKeyServiceErr, self.uninitializedErr, nil)
return
}

var result: String?
var error: NSError?

result = self.keyClient?.stopPollingPendingSignatures(&error)

if error != nil {
reject(mpcKeyServiceErr, error!.localizedDescription, nil)
} else {
resolve(result! as NSString)
let callback: (String?, Error?) -> Void = { data, error in
if let error = error {
reject(self.mpcKeyServiceErr, error.localizedDescription, nil)
} else {
resolve(data ?? "")
}
}

self.keyClient?.stopPollingPendingSignatures(wrapGo(callback))
}

/**
Expand Down Expand Up @@ -286,21 +287,22 @@ class MPCKeyService: NSObject {
*/
@objc(prepareDeviceArchive:withDevice:withResolver:withRejecter:)
func prepareDeviceArchive(_ deviceGroup: NSString, device: NSString,
resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
if self.keyClient == nil {
reject(self.mpcKeyServiceErr, self.uninitializedErr, nil)
return
}

var error: NSError?

let operationName = self.keyClient?.prepareDeviceArchive(
deviceGroup as String, device: device as String, error: &error)
if error != nil {
reject(self.mpcKeyServiceErr, error!.localizedDescription, nil)
} else {
resolve(operationName! as NSString)
let callback: (String?, Error?) -> Void = { data, error in
if let error = error {
reject(self.mpcKeyServiceErr, error.localizedDescription, nil)
} else {
resolve(data ?? "")
}
}

self.keyClient?.prepareDeviceArchive(
deviceGroup as String, device: device as String, receiver: wrapGo(callback))
}

/**
Expand Down Expand Up @@ -341,22 +343,21 @@ class MPCKeyService: NSObject {
Resolves with string "stopped polling for pending Device Archives" if polling is stopped successfully; resolves with the empty string otherwise.
*/
@objc(stopPollingForPendingDeviceArchives:withRejecter:)
func stopPollingForPendingDeviceArchives(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
func stopPollingForPendingDeviceArchives(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
if self.keyClient == nil {
reject(self.mpcKeyServiceErr, self.uninitializedErr, nil)
return
}

var result: String?
var error: NSError?

result = self.keyClient?.stopPollingPendingDeviceArchives(&error)

if error != nil {
reject(self.mpcKeyServiceErr, error!.localizedDescription, nil)
} else {
resolve(result! as NSString)
let callback: (String?, Error?) -> Void = { data, error in
if let error = error {
reject(self.mpcKeyServiceErr, error.localizedDescription, nil)
} else {
resolve(data ?? "")
}
}

self.keyClient?.stopPollingPendingDeviceArchives(wrapGo(callback))
}

/**
Expand All @@ -365,21 +366,22 @@ class MPCKeyService: NSObject {
*/
@objc(prepareDeviceBackup:withDevice:withResolver:withRejecter:)
func prepareDeviceBackup(_ deviceGroup: NSString, device: NSString,
resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
if self.keyClient == nil {
reject(self.mpcKeyServiceErr, self.uninitializedErr, nil)
return
}

var error: NSError?

let operationName = self.keyClient?.prepareDeviceBackup(
deviceGroup as String, device: device as String, error: &error)
if error != nil {
reject(self.mpcKeyServiceErr, error!.localizedDescription, nil)
} else {
resolve(operationName! as NSString)
let callback: (String?, Error?) -> Void = { data, error in
if let error = error {
reject(self.mpcKeyServiceErr, error.localizedDescription, nil)
} else {
resolve(data ?? "")
}
}

self.keyClient?.prepareDeviceBackup(
deviceGroup as String, device: device as String, receiver: wrapGo(callback))
}

/**
Expand Down Expand Up @@ -420,22 +422,21 @@ class MPCKeyService: NSObject {
Resolves with string "stopped polling for pending Device Backups" if polling is stopped successfully; resolves with the empty string otherwise.
*/
@objc(stopPollingForPendingDeviceBackups:withRejecter:)
func stopPollingForPendingDeviceBackups(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
func stopPollingForPendingDeviceBackups(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
if self.keyClient == nil {
reject(self.mpcKeyServiceErr, self.uninitializedErr, nil)
return
}

var result: String?
var error: NSError?

result = self.keyClient?.stopPollingPendingDeviceBackups(&error)

if error != nil {
reject(self.mpcKeyServiceErr, error!.localizedDescription, nil)
} else {
resolve(result! as NSString)
let callback: (String?, Error?) -> Void = { data, error in
if let error = error {
reject(self.mpcKeyServiceErr, error.localizedDescription, nil)
} else {
resolve(data ?? "")
}
}

self.keyClient?.stopPollingPendingDeviceBackups(wrapGo(callback))
}

/**
Expand All @@ -444,21 +445,22 @@ class MPCKeyService: NSObject {
*/
@objc(addDevice:withDevice:withResolver:withRejecter:)
func addDevice(_ deviceGroup: NSString, device: NSString,
resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
if self.keyClient == nil {
reject(self.mpcKeyServiceErr, self.uninitializedErr, nil)
return
}

var error: NSError?

let operationName = self.keyClient?.addDevice(
deviceGroup as String, device: device as String, error: &error)
if error != nil {
reject(self.mpcKeyServiceErr, error!.localizedDescription, nil)
} else {
resolve(operationName! as NSString)
let callback: (String?, Error?) -> Void = { data, error in
if let error = error {
reject(self.mpcKeyServiceErr, error.localizedDescription, nil)
} else {
resolve(data ?? "")
}
}

self.keyClient?.addDevice(
deviceGroup as String, device: device as String, receiver: wrapGo(callback))
}

/**
Expand Down Expand Up @@ -499,21 +501,20 @@ class MPCKeyService: NSObject {
Resolves with string "stopped polling for pending Devices" if polling is stopped successfully; resolves with the empty string otherwise.
*/
@objc(stopPollingForPendingDevices:withRejecter:)
func stopPollingForPendingDevices(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
func stopPollingForPendingDevices(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
if self.keyClient == nil {
reject(self.mpcKeyServiceErr, self.uninitializedErr, nil)
return
}

var result: String?
var error: NSError?

result = self.keyClient?.stopPollingPendingDevices(&error)

if error != nil {
reject(self.mpcKeyServiceErr, error!.localizedDescription, nil)
} else {
resolve(result! as NSString)
let callback: (String?, Error?) -> Void = { data, error in
if let error = error {
reject(self.mpcKeyServiceErr, error.localizedDescription, nil)
} else {
resolve(data ?? "")
}
}

self.keyClient?.stopPollingPendingDevices(wrapGo(callback))
}
}
Loading

0 comments on commit 33778e3

Please sign in to comment.