Skip to content

Commit

Permalink
Hack to make project compile
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyasthiagaraj committed Oct 22, 2019
1 parent b697416 commit 741b69b
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions BlockstackSDK/ios/RNBlockstackSdk/RNBlockstackSdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class RNBlockstackSdk: NSObject {
// TODO: Remove reliance on session config.
@objc public func signIn(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
guard let config = self.config,
let redirectUrl = config["redirectUrl"] as? String,
let redirectUrlString = config["redirectUrl"] as? String,
let redirectURL = URL(string: redirectUrlString),
let appDomainString = config["appDomain"] as? String,
let appDomain = URL(string: appDomainString) else {
reject(self.defaultErrorCode, "Invalid session config", nil)
Expand All @@ -47,9 +48,9 @@ class RNBlockstackSdk: NSObject {
if let manifestPath = config["manifestUrl"] as? String {
manifestURI = URL(string: manifestPath)
}
let scopes = config["scopes"] as? [String] ?? ["store_write"]
let scopes = (config["scopes"] as? [String] ?? ["store_write"]).compactMap { AuthScope.fromString($0) }
// TODO: REJECT when cancelled or failed, and handle this in App.js
Blockstack.shared.signIn(redirectURI: redirectUrl, appDomain: appDomain, manifestURI: manifestURI, scopes: scopes) { authResult in
Blockstack.shared.signIn(redirectURI: redirectURL, appDomain: appDomain, manifestURI: manifestURI, scopes: scopes) { authResult in
var error: Any = NSNull()
let data: [String: Any]
switch authResult {
Expand Down Expand Up @@ -126,7 +127,6 @@ class RNBlockstackSdk: NSObject {
}

}

}

extension Encodable {
Expand All @@ -135,3 +135,19 @@ extension Encodable {
return (try? JSONSerialization.jsonObject(with: data, options: .allowFragments)).flatMap { $0 as? [String: Any] }
}
}

// TODO: Make public Blockstack SDK and remove this hack
extension AuthScope {
static func fromString(_ value: String) -> AuthScope? {
switch value {
case AuthScope.storeWrite.rawValue:
return .storeWrite
case AuthScope.publishData.rawValue:
return .publishData
case AuthScope.email.rawValue:
return .email
default:
return nil
}
}
}

0 comments on commit 741b69b

Please sign in to comment.