-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 155-update-links-in-readmemd-to-point-to-hyp…
…erledger-repos
- Loading branch information
Showing
25 changed files
with
663 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...gentSDK/Pollux/Sources/Models/PresentationExchage/PresentationExchangeClaimVerifier.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Foundation | ||
|
||
public protocol PresentationExchangeClaimVerifier { | ||
func verifyClaim(inputDescriptor: InputDescriptor) throws | ||
} |
8 changes: 8 additions & 0 deletions
8
...AgentSDK/Pollux/Sources/Models/PresentationExchage/SubmissionDescriptorFormatParser.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
|
||
public protocol SubmissionDescriptorFormatParser { | ||
var format: String { get } | ||
func parse(path: String, presentationData: Data) async throws -> String | ||
func parsePayload(path: String, presentationData: Data) async throws -> Data | ||
func parseClaimVerifier(descriptor: PresentationSubmission.Descriptor, presentationData: Data) async throws -> PresentationExchangeClaimVerifier | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
EdgeAgentSDK/Pollux/Sources/Operation/JWT/JWTPresentationExchangeParser.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Domain | ||
import Foundation | ||
import JSONSchema | ||
import JSONWebToken | ||
|
||
struct JWTPresentationExchangeParser: SubmissionDescriptorFormatParser { | ||
let format = "jwt" | ||
let verifier: VerifyJWT | ||
|
||
func parse(path: String, presentationData: Data) async throws -> String { | ||
guard | ||
let jwt = presentationData.query(string: path) | ||
else { | ||
throw PolluxError.credentialPathInvalid(path: path) | ||
} | ||
|
||
guard try await verifier.verifyJWT(jwtString: jwt) else { | ||
throw PolluxError.cannotVerifyCredential(credential: jwt, internalErrors: []) | ||
} | ||
|
||
return jwt | ||
} | ||
|
||
func parsePayload(path: String, presentationData: Data) async throws -> Data { | ||
let jwt = try await parse(path: path, presentationData: presentationData) | ||
return try JWT.getPayload(jwtString: jwt) | ||
} | ||
|
||
func parseClaimVerifier(descriptor: PresentationSubmission.Descriptor, presentationData: Data) async throws -> PresentationExchangeClaimVerifier { | ||
let jwt = try await parse(path: descriptor.path, presentationData: presentationData) | ||
return JWTVerifierPresentationExchange( | ||
castor: verifier.castor, | ||
jwtString: jwt, | ||
submissionDescriptor: descriptor | ||
) | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
EdgeAgentSDK/Pollux/Sources/Operation/JWT/JWTVCPresentationExchangeParser.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Domain | ||
import Foundation | ||
import JSONSchema | ||
import JSONWebToken | ||
|
||
struct JWTVCPresentationExchangeParser: SubmissionDescriptorFormatParser { | ||
let format = "jwt_vc" | ||
let verifier: VerifyJWT | ||
|
||
func parse(path: String, presentationData: Data) async throws -> String { | ||
guard | ||
let jwt = presentationData.query(string: path) | ||
else { | ||
throw PolluxError.credentialPathInvalid(path: path) | ||
} | ||
|
||
guard try await verifier.verifyJWT(jwtString: jwt) else { | ||
throw PolluxError.cannotVerifyCredential(credential: jwt, internalErrors: []) | ||
} | ||
|
||
return jwt | ||
} | ||
|
||
func parsePayload(path: String, presentationData: Data) async throws -> Data { | ||
let jwt = try await parse(path: path, presentationData: presentationData) | ||
return try JWT.getPayload(jwtString: jwt) | ||
} | ||
|
||
func parseClaimVerifier(descriptor: PresentationSubmission.Descriptor, presentationData: Data) async throws -> PresentationExchangeClaimVerifier { | ||
let jwt = try await parse(path: descriptor.path, presentationData: presentationData) | ||
return JWTVerifierPresentationExchange( | ||
castor: verifier.castor, | ||
jwtString: jwt, | ||
submissionDescriptor: descriptor | ||
) | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
EdgeAgentSDK/Pollux/Sources/Operation/JWT/JWTVPPresentationExchangeParser.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Domain | ||
import Foundation | ||
import JSONSchema | ||
import JSONWebToken | ||
|
||
struct JWTVPPresentationExchangeParser: SubmissionDescriptorFormatParser { | ||
let format = "jwt_vp" | ||
let verifier: VerifyJWT | ||
|
||
func parse(path: String, presentationData: Data) async throws -> String { | ||
guard | ||
let jwt = presentationData.query(string: path) | ||
else { | ||
throw PolluxError.credentialPathInvalid(path: path) | ||
} | ||
|
||
guard try await verifier.verifyJWT(jwtString: jwt) else { | ||
throw PolluxError.cannotVerifyCredential(credential: jwt, internalErrors: []) | ||
} | ||
|
||
return jwt | ||
} | ||
|
||
func parsePayload(path: String, presentationData: Data) async throws -> Data { | ||
let jwt = try await parse(path: path, presentationData: presentationData) | ||
return try JWT.getPayload(jwtString: jwt) | ||
} | ||
|
||
func parseClaimVerifier(descriptor: PresentationSubmission.Descriptor, presentationData: Data) async throws -> PresentationExchangeClaimVerifier { | ||
let jwt = try await parse(path: descriptor.path, presentationData: presentationData) | ||
return JWTVerifierPresentationExchange( | ||
castor: verifier.castor, | ||
jwtString: jwt, | ||
submissionDescriptor: descriptor | ||
) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
EdgeAgentSDK/Pollux/Sources/Operation/JWT/PresentationExchangeJWTClaimVerifier.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Domain | ||
import Foundation | ||
import JSONWebToken | ||
|
||
struct JWTVerifierPresentationExchange: PresentationExchangeClaimVerifier { | ||
let castor: Castor | ||
let jwtString: String | ||
let submissionDescriptor: PresentationSubmission.Descriptor | ||
|
||
func verifyClaim(inputDescriptor: InputDescriptor) throws { | ||
let payload = try JWT.getPayload(jwtString: jwtString) | ||
try VerifyJsonClaim.verify(inputDescriptor: inputDescriptor, jsonData: payload) | ||
} | ||
} |
Oops, something went wrong.