Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dependencies #30

Open
wants to merge 38 commits into
base: feat/signer
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
08d54ce
update dependencies
metalurgical Jul 30, 2024
71bd3d9
fix: working login, signing, create ,delete factor
ieow Sep 12, 2024
9228f23
fix: update backup and delete backupshare
ieow Sep 12, 2024
6fbf281
add: overwriteMetadataUrl
ieow Sep 12, 2024
4e92f26
revert
metalurgical Sep 15, 2024
ac05a42
update sfa
metalurgical Sep 15, 2024
69bbbcb
update check for the hashed factor pub
AyushBherwani1998 Sep 16, 2024
58c61b4
update existing user check
AyushBherwani1998 Sep 16, 2024
37cc49d
use factorpub for check
AyushBherwani1998 Sep 16, 2024
8d1d830
fix: make tssSign sync
ieow Sep 17, 2024
e9dc224
fix: make public key sync
ieow Sep 17, 2024
7f8f4b0
update dependencies
metalurgical Nov 4, 2024
8aa87ae
fix: use UserInfo type instead of dictionary.
metalurgical Nov 21, 2024
ac4c1ec
update
metalurgical Nov 21, 2024
fe142a0
update: simplify dependencies
metalurgical Nov 21, 2024
b00bfb0
formatting
metalurgical Nov 21, 2024
6f6d5a6
update tss-client 5.0.1
metalurgical Nov 22, 2024
e614b9c
update tkey-mpc-swift to released version (4.0.0)
metalurgical Nov 22, 2024
8c121f7
feat: add podspec
metalurgical Nov 25, 2024
a8e9b5e
fix: address comment
ieow Dec 6, 2024
4560ac1
fix: add default value
ieow Dec 6, 2024
0e91858
resolve comments
AyushBherwani1998 Dec 6, 2024
4e739dd
fix: add default network back
metalurgical Dec 10, 2024
ed436bd
fix: use commitChanges instead
metalurgical Dec 10, 2024
06331d6
fix: enable loginwithJWT aggregate login
ieow Dec 11, 2024
a6e2c35
fix: update with release package
ieow Dec 11, 2024
1dcfa82
fix: update use getTssShare instead of static tssShare
ieow Dec 12, 2024
16633d0
fix: handle edge cases, make tssSign sync
ieow Dec 12, 2024
f9531f3
test: bulk-stream metadata fix
ieow Jan 3, 2025
ad4e182
test: fix set metadata multipart
ieow Jan 3, 2025
9b7094c
fix: make additionalDeviceMetadata valid for both iOS and Mac
metalurgical Jan 3, 2025
7fa1e1c
fix: warnings
metalurgical Jan 3, 2025
ebb331b
fix: mutation of captured variable in concurrent code
metalurgical Jan 3, 2025
9711128
update tkey-mpc version
metalurgical Jan 6, 2025
5babd40
feat: tssSignSync
ieow Jan 8, 2025
fa528f0
use optional var
ieow Jan 8, 2025
742afd2
use completion
ieow Jan 8, 2025
9b37f29
feat: add error propagation
ieow Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 18 additions & 54 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
{
"pins" : [
{
"identity" : "anycodable",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Flight-School/AnyCodable",
"state" : {
"revision" : "862808b2070cd908cb04f9aafe7de83d35f81b05",
"version" : "0.6.7"
}
},
{
"identity" : "bigint",
"kind" : "remoteSourceControl",
Expand All @@ -23,26 +14,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/tkey/curvelib.swift",
"state" : {
"revision" : "9f88bd5e56d1df443a908f7a7e81ae4f4d9170ea",
"version" : "1.0.1"
"revision" : "432bf1abe7ff505fc2ac9fcf697341ff5b2dc6d0",
"version" : "2.0.0"
}
},
{
"identity" : "customauth-swift-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/torusresearch/customauth-swift-sdk",
"state" : {
"revision" : "60b48acb161fb4341c353c27bc6dd96af76887ff",
"version" : "10.0.1"
"revision" : "67f947d087e1c9c6ca37c6627b595fe6913bc558",
"version" : "11.0.2"
}
},
{
"identity" : "fetch-node-details-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/torusresearch/fetch-node-details-swift.git",
"state" : {
"revision" : "22bfadf7491d77a0bc1953af002cadbd61383e7d",
"version" : "6.0.2"
"revision" : "52fb5efaa94e0fe3775913ab00964bcb51601c2a",
"version" : "8.0.0"
}
},
{
Expand All @@ -59,53 +50,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/auth0/JWTDecode.swift.git",
"state" : {
"revision" : "58af7278797871e460d79496621b3e5366b865b2",
"version" : "3.1.0"
}
},
{
"identity" : "keychain-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/evgenyneu/keychain-swift.git",
"state" : {
"revision" : "d108a1fa6189e661f91560548ef48651ed8d93b9",
"version" : "20.0.0"
}
},
{
"identity" : "session-manager-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Web3Auth/session-manager-swift.git",
"state" : {
"revision" : "20cc7bff065d7fe53164d17e7714a3f17d4cea2a",
"version" : "4.0.2"
}
},
{
"identity" : "single-factor-auth-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Web3Auth/single-factor-auth-swift",
"state" : {
"revision" : "73c5066d369c7d2aa1057c56a89b7f1dcdda3270",
"version" : "5.0.0"
"revision" : "1e153ef009969543191970c66b7c60163c0b4a65",
"version" : "3.2.0"
}
},
{
"identity" : "socket.io-client-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/socketio/socket.io-client-swift",
"state" : {
"revision" : "175da8b5156f6b132436f0676cc84c2f6a766b6e",
"version" : "16.1.0"
"revision" : "42da871d9369f290d6ec4930636c40672143905b",
"version" : "16.1.1"
}
},
{
"identity" : "starscream",
"kind" : "remoteSourceControl",
"location" : "https://github.com/daltoniam/Starscream",
"state" : {
"revision" : "ac6c0fc9da221873e01bd1a0d4818498a71eef33",
"version" : "4.0.6"
"revision" : "c6bfd1af48efcc9a9ad203665db12375ba6b145a",
"version" : "4.0.8"
}
},
{
Expand All @@ -122,26 +86,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/tkey/tkey-mpc-swift",
"state" : {
"revision" : "2df2d0a6c51afc76909028eb8542fe78e565d106",
"version" : "3.0.1"
"revision" : "b6d9d1013f21f51105e845a0c16ee39b2f01fd1c",
"version" : "4.0.1"
}
},
{
"identity" : "torus-utils-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/torusresearch/torus-utils-swift.git",
"state" : {
"revision" : "608c28404c506983bfec7bbd957632fc0544db8c",
"version" : "8.1.2"
"revision" : "baa822fc67bdb208ed1a2dc5b3c10485cfca15df",
"version" : "10.0.0"
}
},
{
"identity" : "tss-client-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/torusresearch/tss-client-swift.git",
"state" : {
"revision" : "40246d5e3ff1d2c97d41846576f7a81d58858981",
"version" : "4.0.0"
"revision" : "6f00e4e03184a77eea0330b5b8d092d1452b9eb4",
"version" : "5.0.1"
}
}
],
Expand Down
19 changes: 6 additions & 13 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,26 @@ import PackageDescription

let package = Package(
name: "mpc-core-kit-swift",
platforms: [ .iOS(.v14) ],
platforms: [ .iOS(.v14), .macOS(.v11) ],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "mpc-core-kit-swift",
targets: ["mpc-core-kit-swift"]),
],
dependencies: [
.package(url: "https://github.com/vapor/jwt-kit.git", from: "4.0.0"),
.package(url: "https://github.com/torusresearch/tss-client-swift.git", from: "4.0.0"),
.package(url: "https://github.com/tkey/tkey-mpc-swift", from: "3.0.1"),
.package(url: "https://github.com/torusresearch/customauth-swift-sdk", from: "10.0.1"),
.package(url: "https://github.com/Web3Auth/single-factor-auth-swift", from: "5.0.0"),
.package(url: "https://github.com/auth0/JWTDecode.swift", from: "3.1.0")
.package(url: "https://github.com/torusresearch/tss-client-swift.git", from: "5.0.1"),
.package(url: "https://github.com/tkey/tkey-mpc-swift", from: "4.0.1"),
.package(url: "https://github.com/torusresearch/customauth-swift-sdk", from: "11.0.2"),
.package(url: "https://github.com/vapor/jwt-kit.git", from: "4.0.0")
],

targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "mpc-core-kit-swift",
dependencies: [
.product(name: "CustomAuth", package: "customauth-swift-sdk"),
.product(name: "SingleFactorAuth", package: "single-factor-auth-swift"),
.product(name: "tkey", package: "tkey-mpc-swift" ),
.product(name: "tssClientSwift", package: "tss-client-swift" ),
.product(name: "JWTDecode", package: "JWTDecode.swift")
.product(name: "tssClientSwift", package: "tss-client-swift" )
]
),
.testTarget(
Expand Down
18 changes: 15 additions & 3 deletions Sources/mpc-core-kit-swift/CoreKitError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public enum CoreKitError: Error {
case invalidInput
case notFound(msg: String)
case factorKeyUnavailable
case tssIndexUnavailable
case metadataPubKeyUnavailable
case shareIndexNotFound
case notLoggedIn
Expand All @@ -18,7 +19,6 @@ public enum CoreKitError: Error {
case invalidTKey
case nodeDetailsMissing
case invalidMetadataUrl
case invalidOAuthKey
case invalidHashKey
case invalidAuthSignatures
case invalidFactorKey
Expand All @@ -28,6 +28,10 @@ public enum CoreKitError: Error {
case requireUncompressedPublicKey
case invalidStore
case noTssTags
case invalidDeviceFactorKey
case invalidTssPubKey
case invalidClientId
case runtime(_ msg: String)

public var errorDescription: String {
switch self {
Expand All @@ -41,6 +45,8 @@ public enum CoreKitError: Error {
return "Invalid input"
case .factorKeyUnavailable:
return "Factor key unavailable"
case .tssIndexUnavailable:
return "TSS index unavailable"
case .shareIndexNotFound:
return "Share index not found"
case .notLoggedIn:
Expand All @@ -65,8 +71,6 @@ public enum CoreKitError: Error {
return "Node details absent"
case .invalidMetadataUrl:
return "Invalid metadata url"
case .invalidOAuthKey:
return "Invalid OAuthKey"
case .invalidHashKey:
return "Invalid hash key"
case .invalidAuthSignatures:
Expand All @@ -85,6 +89,14 @@ public enum CoreKitError: Error {
return "Invalid Store"
case .noTssTags:
return "No Tss tags have been set"
case .invalidDeviceFactorKey:
return "Device factor key not found"
case let .runtime(msg: msg):
return msg
case .invalidTssPubKey:
return "Invalid tss public key"
case .invalidClientId:
return "Invalid client id"
}
}
}
20 changes: 10 additions & 10 deletions Sources/mpc-core-kit-swift/CoreKitStorage.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Foundation

public class CoreKitStorage {
public var storage: ILocalStorage
public var storage: IStorage
private var storeKey: String

public init(storeKey: String, storage: ILocalStorage) {
public init(storeKey: String, storage: IStorage) {
self.storage = storage
self.storeKey = storeKey
}
Expand All @@ -27,28 +27,28 @@ public class CoreKitStorage {
return resultStr
}

public func getStore() async throws -> [String: Any] {
public func getStore() async throws -> [String: String] {
let result = try await storage.get(key: storeKey)
if result.isEmpty { return [:] }
let store = try JSONSerialization.jsonObject(with: result) as? [String: Any]
let store = try JSONSerialization.jsonObject(with: result) as? [String: String]
guard let storeUnwrapped = store else {
throw CoreKitError.invalidStore
}
return storeUnwrapped
}

public func get<T>(key: String) async throws -> T {
public func get(key: String) async throws -> Data {
let store = try await getStore()
guard let item = store[key] as? T else {
guard let item = store[key] else {
throw CoreKitError.notFound(msg: "key \(key) value not found")
}
return item
return Data(base64Encoded: item) ?? Data()
}

public func set<T>(key: String, payload: T) async throws {
public func set(key: String, payload: Data) async throws {
var store: [String: Any] = try await getStore()
store.updateValue(payload, forKey: key)
let jsonData = try JSONSerialization.data(withJSONObject: store)
store.updateValue(payload.base64EncodedString(), forKey: key)
let jsonData = try JSONSerialization.data(withJSONObject: store, options: [])
try await storage.set(key: storeKey, payload: jsonData)
}

Expand Down
16 changes: 6 additions & 10 deletions Sources/mpc-core-kit-swift/DeviceFactorStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@ public class DeviceFactorStorage: IFactorStorage {
}

public func setFactor(metadataPubKey: String, factorKey: String) async throws {
var localMetadata: [String: Any] = try await storage.get(key: metadataPubKey)

localMetadata["factorKey"] = factorKey
try await storage.set(key: metadataPubKey, payload: localMetadata)
guard let factorKeyData = Data(hexString: factorKey) else {
throw CoreKitError.invalidFactorKey
}
try await storage.set(key: metadataPubKey, payload: factorKeyData)
}

public func getFactor(metadataPubKey: String) async throws -> String {
let localMetadata: [String: Any] = try await storage.get(key: metadataPubKey)
guard let deviceFactor = localMetadata["factorKey"] as? String else {
throw CoreKitError.notFound(msg: "device factor not found")
}
return deviceFactor
let localMetadata: Data = try await storage.get(key: metadataPubKey)
return localMetadata.hexString
}
}

47 changes: 17 additions & 30 deletions Sources/mpc-core-kit-swift/Helper.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import BigInt
import FetchNodeDetails
import Foundation
import SingleFactorAuth

#if canImport(tkey)
import tkey
Expand All @@ -15,40 +14,28 @@ import SingleFactorAuth
import tssClientSwift
#endif

public class FactorDescription: Codable {
public let module: FactorType
public let tssIndex: TssShareType
public let description: String?
public let dateAdded: Int

public init(module: FactorType, tssIndex: TssShareType, description: String?, dateAdded: Int) {
self.module = module
self.tssIndex = tssIndex
self.description = description
self.dateAdded = dateAdded
}
}

public func createCoreKitFactorDescription(module: FactorType, tssIndex: TssShareType, additional: [String: Any] = [:]) -> [String: Any] {
var description = additional

description["module"] = module
description["tssShareIndex"] = tssIndex
description["dateAdded"] = Date().timeIntervalSince1970

return description
public func createCoreKitFactorDescription(module: FactorType, tssIndex: TssShareType, dateAdded: Int, description: String? = nil) -> FactorDescription {
return FactorDescription(module: module, tssIndex: tssIndex, description: description, dateAdded: dateAdded)
}

func factorDescriptionToJsonStr(dataObj: [String: Any]) throws -> String {
let json = try JSONSerialization.data(withJSONObject: dataObj)
func factorDescriptionToJsonStr(dataObj: FactorDescription) throws -> String {
let json = try JSONEncoder().encode(dataObj)
guard let jsonStr = String(data: json, encoding: .utf8) else {
throw CoreKitError.invalidResult
}
return jsonStr
}

func convertWeb3AuthNetworkToTorusNetWork(network: Web3AuthNetwork) -> TorusNetwork {
switch network {
case Web3AuthNetwork.SAPPHIRE_DEVNET: return .sapphire(.SAPPHIRE_DEVNET)
case Web3AuthNetwork.SAPPHIRE_MAINNET: return .sapphire(.SAPPHIRE_MAINNET)
case Web3AuthNetwork.MAINNET: return .legacy(.MAINNET)
case Web3AuthNetwork.TESTNET: return .legacy(.TESTNET)
case Web3AuthNetwork.CYAN: return .legacy(.CYAN)
case Web3AuthNetwork.AQUA: return .legacy(.AQUA)
case Web3AuthNetwork.CELESTE: return .legacy(.CELESTE)
case Web3AuthNetwork.CUSTOM: return .sapphire(.SAPPHIRE_MAINNET)
}
}

public extension Web3AuthNetwork {
func toTorusNetwork() -> TorusNetwork {
return convertWeb3AuthNetworkToTorusNetWork(network: self)
}
}
Loading