Skip to content

Commit

Permalink
fix: update and fix upgraded torusUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
ieow committed Feb 16, 2024
1 parent 57bd8da commit 2e52eaf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
26 changes: 13 additions & 13 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,22 @@
"version": "1.7.2"
}
},
{
"package": "curvelib.swift",
"repositoryURL": "https://github.com/tkey/curvelib.swift",
"state": {
"branch": null,
"revision": "508322dbd3b18a92c1e9c4eb68da6a228acb1d7d",
"version": "0.1.1"
}
},
{
"package": "FetchNodeDetails",
"repositoryURL": "https://github.com/torusresearch/fetch-node-details-swift.git",
"state": {
"branch": null,
"revision": "68459eb481c382bfbbe28345b8eb25b3897c7447",
"version": "5.0.0"
"revision": "d591af500f32ce3c88d04af9bb74d746585acfea",
"version": "5.1.0"
}
},
{
Expand All @@ -55,15 +64,6 @@
"version": "3.1.0"
}
},
{
"package": "secp256k1",
"repositoryURL": "https://github.com/GigaBitcoin/secp256k1.swift.git",
"state": {
"branch": null,
"revision": "1a14e189def5eaa92f839afdd2faad8e43b61a6e",
"version": "0.12.2"
}
},
{
"package": "swift-crypto",
"repositoryURL": "https://github.com/apple/swift-crypto.git",
Expand All @@ -78,8 +78,8 @@
"repositoryURL": "https://github.com/torusresearch/torus-utils-swift.git",
"state": {
"branch": null,
"revision": "61b36686c2def5f2f40d8cb0d5bc3af34559c1d5",
"version": "6.0.1"
"revision": "76c9b17b461152e98216dddbbf320071011cf1cb",
"version": "7.0.0"
}
}
]
Expand Down
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// swift-tools-version:5.2
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "CustomAuth",
platforms: [
.iOS(.v13), .macOS(.v10_15)
.iOS(.v13), .macOS(.v11)
],
products: [
.library(
name: "CustomAuth",
targets: ["CustomAuth"])
],
dependencies: [
.package(name: "TorusUtils", url: "https://github.com/torusresearch/torus-utils-swift.git", from: "6.0.1"),
.package(name: "TorusUtils", url: "https://github.com/torusresearch/torus-utils-swift.git", from: "7.0.0"),
.package(name: "jwt-kit", url: "https://github.com/vapor/jwt-kit.git", from: "4.13.0"),
.package(name: "JWTDecode", url: "https://github.com/auth0/JWTDecode.swift.git", from: "3.1.0")
],
Expand Down
26 changes: 13 additions & 13 deletions Tests/CustomAuthTests/CustomAuthTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import JWTDecode
import TorusUtils
import UIKit
import XCTest
import curveSecp256k1

final class MockSDKTest: XCTestCase {
func test_jwtDecodeTest() {
Expand All @@ -11,11 +12,11 @@ final class MockSDKTest: XCTestCase {
print(decodedData)
}

func testGetTorusKey() async {
func testGetTorusKey() async throws {
let expectation = XCTestExpectation(description: "getTorusKey should correctly proxy input and output to/from TorusUtils")

let expectedPrivateKey = fakeData.generatePrivateKey()
let expectedPublicAddress = fakeData.generatePublicKey()
let expectedPrivateKey = try fakeData.generatePrivateKey()
let expectedPublicAddress = try fakeData.generatePublicKey()
let expectedVerifier = fakeData.generateVerifier()
let expectedVerfierId = fakeData.generateRandomEmail(of: 6)

Expand Down Expand Up @@ -48,11 +49,11 @@ final class MockSDKTest: XCTestCase {
}
}

func testGetAggregateTorusKey() async {
func testGetAggregateTorusKey() async throws {
let expectation = XCTestExpectation(description: "getAggregateTorusKey should correctly proxy input and output to/from TorusUtils")

let expectedPrivateKey = fakeData.generatePrivateKey()
let expectedPublicAddress = fakeData.generatePublicKey()
let expectedPrivateKey = try fakeData.generatePrivateKey()
let expectedPublicAddress = try fakeData.generatePublicKey()
let expectedVerifier = fakeData.generateVerifier()
let expectedVerfierId = fakeData.generateRandomEmail(of: 6)

Expand Down Expand Up @@ -96,15 +97,14 @@ class fakeData {
return String.randomString(length: 10)
}

static func generatePrivateKey() -> String {
let privateKey = Data.randomOfLength(32)
return (privateKey?.toHexString())!
static func generatePrivateKey() throws -> String {
let privateKey = curveSecp256k1.SecretKey()
return try privateKey.serialize()
}

static func generatePublicKey() -> String {
let privateKey = Data.randomOfLength(32)!
let publicKey = SECP256K1.privateToPublic(privateKey: privateKey)?.subdata(in: 1 ..< 65)
return publicKey!.toHexString()
static func generatePublicKey() throws -> String {
// drop "04"
return try String(curveSecp256k1.SecretKey().toPublic().serialize(compressed: false).dropFirst(2))
}

static func generateRandomEmail(of length: Int) -> String {
Expand Down
2 changes: 1 addition & 1 deletion Tests/CustomAuthTests/StubURLProtocolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class StubMockTorusUtils: TorusUtils {
return ret
}

override open func generatePrivateKeyData() -> Data? {
open func generatePrivateKeyData() -> Data? {
// empty bytes
// let ret = Data(count: 32)

Expand Down

0 comments on commit 2e52eaf

Please sign in to comment.