Skip to content

auth-service v10 and wallet-service changes #88

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

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8980c25
auth-service v10 changes
grvgoel81 Apr 10, 2025
57f291c
Update userInfo model
grvgoel81 Apr 14, 2025
0356ade
Update UserInfo
grvgoel81 Apr 15, 2025
18f3993
launchWalletServices and request function changes added. Example upda…
grvgoel81 Apr 15, 2025
95ee49c
authServiceVersion updated.
grvgoel81 Apr 15, 2025
e83c9a7
wallet-service changes added.
grvgoel81 Apr 23, 2025
2643bb5
Renaming varaiables ChainsConfig, W3AInitParams and W3ALoginParams
grvgoel81 Apr 24, 2025
ea2e62d
Updates in Types.swift
grvgoel81 Apr 25, 2025
fe73aee
Rename Web3AuthState to Web3AuthResponse
grvgoel81 Apr 25, 2025
5042b62
changed authConnection jwt to custom
grvgoel81 Apr 29, 2025
4e5b01b
variable naming improvements.
grvgoel81 May 13, 2025
6bc670f
Update LoginParams
grvgoel81 May 14, 2025
c7a0cbb
update wallet-services to v5 version
grvgoel81 May 14, 2025
abe5b8a
update ExtraLoginOptions.kt
grvgoel81 May 15, 2025
82009b4
Update naming convention
grvgoel81 May 15, 2025
de08287
Update Web3AuthOptions
grvgoel81 May 15, 2025
aef6bc0
renamed ed25519PrivKey to ed25519PrivateKey in Web3AuthResponse
grvgoel81 May 19, 2025
ff6a8a3
Initial commit for combining pnp and sfa sdk.
grvgoel81 May 29, 2025
eec79ce
SFA code added.
grvgoel81 May 30, 2025
1b294e0
wallet-services code changes.
grvgoel81 Jun 3, 2025
4f3ef83
request function changes
grvgoel81 Jun 3, 2025
2e6471b
SFA login and aggregate login changes.
grvgoel81 Jun 4, 2025
e9e235b
add whiteLabel data in Web3AuthOptions
grvgoel81 Jun 11, 2025
c368172
defaultChainId value added.
grvgoel81 Jun 12, 2025
99085d1
Changes in fetcHProjectConfig reponse and sessionId change in enableMFA
grvgoel81 Jun 23, 2025
fd1143c
Add error in SFA MFA flow.
grvgoel81 Jun 27, 2025
80b34be
Merge embeddedWalletAuth data with authConnectionConfig in Web3AuthOp…
grvgoel81 Jul 1, 2025
62146d3
update smartWalletschema
grvgoel81 Jul 2, 2025
0b36512
KeyChainHelper added and modify SessionManager initialization logic.
grvgoel81 Jul 9, 2025
5d8be97
Remove sessionNamespace from Web3AuthOptions
grvgoel81 Jul 9, 2025
eb492bd
Update chainid logic in wallet services
grvgoel81 Jul 10, 2025
c1faeb3
set EmailFlowType default valye to code.
grvgoel81 Jul 14, 2025
7302982
Adding authConnectionId in MFA flows
grvgoel81 Jul 20, 2025
0974a51
groupedAuthConnectionId added for MFA flows
grvgoel81 Jul 22, 2025
bbdebf1
groupedAuthConnectionId added in UserInfo schema in SFA flow.
grvgoel81 Jul 29, 2025
c43ab8a
bump authDashboardVersion to v10
grvgoel81 Jul 30, 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
14 changes: 12 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,24 @@ let package = Package(
.package(name:"SessionManager",url: "https://github.com/Web3Auth/session-manager-swift.git",from: "6.0.2"),
.package(name: "curvelib.swift", url: "https://github.com/tkey/curvelib.swift", from: "2.0.0"),
.package(url: "https://github.com/attaswift/BigInt.git", from: "5.3.0"),
.package(url: "https://github.com/torusresearch/torus-utils-swift.git", from: "10.0.1"),
.package(url: "https://github.com/vapor/jwt-kit.git", from: "4.0.0"),
.package(url: "https://github.com/auth0/JWTDecode.swift.git", from: "3.2.0")
],
targets: [
.target(
name: "Web3Auth",
dependencies: ["KeychainSwift", .product(name: "curveSecp256k1", package: "curvelib.swift"), "SessionManager", "BigInt"]),
dependencies: [
"KeychainSwift",
.product(name: "curveSecp256k1", package: "curvelib.swift"),
"SessionManager",
"BigInt",
.product(name: "TorusUtils", package: "torus-utils-swift"),
.product(name: "JWTDecode", package: "JWTDecode.swift")
]),
.testTarget(
name: "Web3AuthTests",
dependencies: ["Web3Auth"])
dependencies: ["Web3Auth", .product(name: "JWTKit", package: "jwt-kit")])
],
swiftLanguageVersions: [.v5]
)
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ Checkout [SDK Reference](https://web3auth.io/docs/sdk/pnp/ios/install#configure-
```swift
import Web3Auth

let web3auth = try Web3Auth(W3AInitParams(
let web3auth = try Web3Auth(Web3AuthOptions(
// Get your Web3Auth Client Id from dashboard.web3auth.io
clientId: "YOUR_WEB3AUTH_CLIENT_ID",
network: .sapphire_mainnet,
web3AuthNetwork: .sapphire_mainnet,
redirectUrl: "bundleId://auth"
))

// Login
let result = try await web3Auth.login(W3ALoginParams(loginProvider: .GOOGLE))
let result = try await web3Auth.login(LoginParams(loginProvider: .GOOGLE))

// Logout
try await web3auth.logout()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

public enum Web3AuthProvider: String, Codable {
public enum AuthConnection: String, Codable {
case GOOGLE = "google"
case FACEBOOK = "facebook"
case REDDIT = "reddit"
Expand All @@ -15,7 +15,7 @@ public enum Web3AuthProvider: String, Codable {
case WEIBO = "weibo"
case WECHAT = "wechat"
case EMAIL_PASSWORDLESS = "email_passwordless"
case JWT = "jwt"
case CUSTOM = "custom"
case SMS_PASSWORDLESS = "sms_passwordless"
case FARCASTER = "farcaster"
}
8 changes: 8 additions & 0 deletions Sources/Web3Auth/Data+extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ internal extension Data {
result = result.replacingOccurrences(of: "=", with: "")
return result
}

var bytes: Array<UInt8> {
Array(self)
}

func toHexString() -> String {
bytes.toHexString()
}
}

internal extension Data {
Expand Down
7 changes: 7 additions & 0 deletions Sources/Web3Auth/EmailFlowType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Foundation

public enum EmailFlowType: String, Codable {
case link
case code
}

65 changes: 65 additions & 0 deletions Sources/Web3Auth/KeyChainHelper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import Foundation
import Security

final class KeychainHelper {

static let shared = KeychainHelper()
private init() {}

// Save any Codable value
func save<T: Codable>(_ value: T, forKey key: String) {
guard let data = try? JSONEncoder().encode(value) else { return }

let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: key
]

// Delete existing before adding new
SecItemDelete(query as CFDictionary)

let addQuery: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: key,
kSecValueData as String: data
]

SecItemAdd(addQuery as CFDictionary, nil)
}

// Get any Codable value
func get<T: Codable>(forKey key: String, as type: T.Type) -> T? {
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: key,
kSecReturnData as String: true,
kSecMatchLimit as String: kSecMatchLimitOne
]

var item: AnyObject?
SecItemCopyMatching(query as CFDictionary, &item)

guard let data = item as? Data else { return nil }
return try? JSONDecoder().decode(type, from: data)
}

// Delete a single key
func delete(forKey key: String) {
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: key
]
SecItemDelete(query as CFDictionary)
}

// Clear all in keychain
func clearAll() {
let query: [String: Any] = [kSecClass as String: kSecClassGenericPassword]
SecItemDelete(query as CFDictionary)
}
}

struct KeychainKeys {
static let isSFA = "isSFA"
}

6 changes: 3 additions & 3 deletions Sources/Web3Auth/KeychainManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import SessionManager

extension KeychainManager {
func saveDappShare(userInfo: Web3AuthUserInfo) {
guard let verifer = userInfo.verifier, let veriferID = userInfo.verifierId, let dappShare = userInfo.dappShare else { return }
guard let verifer = userInfo.authConnectionId, let veriferID = userInfo.userId, let dappShare = userInfo.dappShare else { return }
let key = verifer + " | " + veriferID
KeychainManager.shared.save(key: .custom(dappShare), val: key)
}

func getDappShare(verifier: String) -> String? {
return searchDappShare(query: verifier)
func getDappShare(authConnectionId: String) -> String? {
return searchDappShare(query: authConnectionId)
}

private func searchDappShare(query: String) -> String? {
Expand Down
14 changes: 0 additions & 14 deletions Sources/Web3Auth/Network.swift

This file was deleted.

4 changes: 2 additions & 2 deletions Sources/Web3Auth/Networking/NetworkClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ enum Router: NetworkManagerProtocol {
var path: String {
switch self {
case .get:
return "/api/configuration"
return "/api/v2/configuration"
case .set:
return "/api/configuration"
return "/api/v2/configuration"
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Web3Auth/OSLog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var web3AuthLogType = OSLogType.default
public struct Web3AuthLogger {
static let inactiveLog = OSLog.disabled
static let core = OSLog(subsystem: subsystem, category: "core")
static let network = OSLog(subsystem: subsystem, category: "network")
static let web3AuthNetwork = OSLog(subsystem: subsystem, category: "web3AuthNetwork")
}

@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
Expand Down
Loading
Loading