Skip to content

Commit

Permalink
Merge pull request #27 from BoiseITGuru/get-account-proof
Browse files Browse the repository at this point in the history
Added function to retrieve account-proof
  • Loading branch information
lmcmz authored Sep 7, 2023
2 parents b707e78 + 9a3f738 commit c3d81cd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Sources/Config/FCLMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public extension FCL {
}

public struct AccountProofConfig {
let appIdentifier: String
let nonce: String
public let appIdentifier: String
public let nonce: String

public init(appIdentifier: String, nonce: String = fcl.generateNonce()) {
self.appIdentifier = appIdentifier
Expand Down
14 changes: 14 additions & 0 deletions Sources/Method/AccountProof.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ import Flow
import Foundation

public extension FCL {
func getAccountProof() async throws -> FCLDataResponse {
guard let currentUser = currentUser, currentUser.loggedIn else {
throw Flow.FError.unauthenticated
}

guard let service = serviceOfType(services: currentUser.services, type: .accountProof),
let data = service.data
else {
throw FCLError.invaildService
}

return data
}

func verifyAccountProof(includeDomainTag: Bool = false) async throws -> Bool {
guard let currentUser = currentUser, currentUser.loggedIn else {
throw Flow.FError.unauthenticated
Expand Down
2 changes: 1 addition & 1 deletion Sources/Models/FCLResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ extension FCL {
}
}

struct FCLDataResponse: Codable {
public struct FCLDataResponse: Codable {
let fType: String
let fVsn: String
let nonce: String?
Expand Down

0 comments on commit c3d81cd

Please sign in to comment.