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

Split up issuance and presentation request content data models #18

Merged
merged 336 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
336 commits
Select commit Hold shift + click to select a range
0983578
Update OpenIdURLRequestResolverTests.swift
symorton Feb 10, 2023
63ca6ee
Create MockLogConsumer.swift
symorton Feb 10, 2023
396e2ca
Add mock verified id request.
symorton Feb 10, 2023
7805146
Make handleRequest function generic instead of using associated type
symorton Feb 10, 2023
9d38bf6
Implement createVerifiedIdRequest
symorton Feb 10, 2023
040dfd3
Update mocks.
symorton Feb 10, 2023
d87caad
complete test cases for VerifiedIdClientTests
symorton Feb 10, 2023
5b57d3a
Fix nits for PR
symorton Feb 10, 2023
806f233
Merge branch 'dev' into symorton/implementCreateVerifiedIdRequest
symorton Feb 13, 2023
de7d9a5
Extend VC SDK Issuance service.
symorton Feb 13, 2023
ba8b5ca
Create protocol for Contract Resolver to use to extend issuance service.
symorton Feb 13, 2023
a0f825a
Create a raw contract protocol that conforms to mappable.
symorton Feb 13, 2023
47d8f0c
Update VerifiedIdRequest.swift
symorton Feb 13, 2023
305bd0f
Delete Contract.swift
symorton Feb 13, 2023
b04af6a
Implement issuance request logic in open id request handler.
symorton Feb 13, 2023
c8376fb
Create ContractIssuanceRequest.swift
symorton Feb 13, 2023
0760996
add contract resolver param to open id handler
symorton Feb 13, 2023
e7f0700
Add Raw Contract as an extension of Issuance Request.
symorton Feb 13, 2023
efd088f
Update IssuanceService+Contract.swift
symorton Feb 13, 2023
ce3a401
Update ContractResolver.swift
symorton Feb 13, 2023
f6342a2
Update ContractIssuanceRequest.swift
symorton Feb 13, 2023
eb98a71
Create MockContractResolver.swift
symorton Feb 13, 2023
14945c1
Add test cases for issuance flow in open id request handler tests.
symorton Feb 13, 2023
ada5a2f
Update OpenIdURLRequestResolverTests.swift
symorton Feb 13, 2023
bc37bfa
Add period to comment.
symorton Feb 13, 2023
3ff9f6b
Create AttestationsDescriptor mapper
symorton Feb 14, 2023
e70c873
Update IssuanceRequest+RawContract.swift
symorton Feb 14, 2023
35c234c
GroupRequirement only supports .ALL
symorton Feb 14, 2023
13f48d8
add comment about pin to OpenIdRequestHandler.
symorton Feb 14, 2023
4f45767
add comment to verified id request content.
symorton Feb 14, 2023
8207597
Update PresentationDefinition mapping.
symorton Feb 14, 2023
0fbfed3
Merge branch 'dev' into symorton/contractResolver2
symorton Feb 15, 2023
f973f15
Create SelfIssuedClaimsDescriptor mapping.
symorton Feb 15, 2023
c8af050
Update AttestationsDescriptor+Mappable.swift
symorton Feb 15, 2023
c089a37
Update AttestationsDescriptor+Mappable.swift
symorton Feb 15, 2023
aa440d0
Merge branch 'symorton/contractResolver2' into symorton/attestationde…
symorton Feb 15, 2023
bd9ad63
Complete Test Cases for Attestations Descriptor Mapping.
symorton Feb 15, 2023
a8cf931
Move presentation and issuance mappings into subfolders.
symorton Feb 15, 2023
bf02d0d
Add error when no requirements found in attestation.
symorton Feb 15, 2023
d4042ad
Move mapping logic into different file for IssuanceRequest.
symorton Feb 15, 2023
63c91f6
Complete Test Cases for SelfIssuedClaimsDescriptor Mapping
symorton Feb 15, 2023
6a86706
Complete test cases for Issuance Request Mapping.
symorton Feb 15, 2023
8afc434
Rename Style Classes.
symorton Feb 15, 2023
f2a0aa0
Fix nit comments before PR.
symorton Feb 15, 2023
5d690f5
add access token validation.
symorton Feb 15, 2023
24446d0
Add group requirements validation.
symorton Feb 15, 2023
e29b2fa
Merge branch 'dev' into symorton/attestationdescriptormapping
symorton Feb 15, 2023
297ffb2
Change name of error in PresentationDefinition mapping.
symorton Feb 15, 2023
e10621e
Fix style naming.
symorton Feb 15, 2023
8e18c6c
Merge branch 'symorton/attestationdescriptormapping' into symorton/ad…
symorton Feb 15, 2023
56bf18b
Update WalletLibraryDemo.entitlements
symorton Feb 16, 2023
aa3d740
Create extension of Issuance Response Container.
symorton Feb 16, 2023
228a48c
create ContractResponder
symorton Feb 16, 2023
93a8a11
Update AccessTokenRequirement.swift
symorton Feb 16, 2023
007c800
Add comment to Group Requirement.
symorton Feb 16, 2023
3e31ffb
Add validation to IdTokenRequirement.
symorton Feb 16, 2023
d10853a
Update PinRequirement.swift
symorton Feb 16, 2023
a7c9638
Update SelfAttestedClaimRequirement.swift
symorton Feb 16, 2023
1b2b1b7
Update IssuanceResponseContainer+RequestContent.swift
symorton Feb 16, 2023
0a92bf9
Make VerifiedIdIssuanceRequest public.
symorton Feb 16, 2023
622fa65
Update name to manifestService
symorton Feb 16, 2023
d386804
Begin complete implementation on ContractIssuanceRequest
symorton Feb 16, 2023
b65cd29
Update ContractResponder.swift
symorton Feb 16, 2023
3b836dd
Update IssuanceService+Contract.swift
symorton Feb 16, 2023
050eca3
Update project.pbxproj
symorton Feb 16, 2023
5492865
Rename Classes.
symorton Feb 16, 2023
106f272
Replace contract noun with manifest.
symorton Feb 16, 2023
8a592e7
add manifestService
symorton Feb 16, 2023
604746c
ContractResponder --> VerifiedIdRequester.
symorton Feb 16, 2023
2a28230
Fix naming in tests.
symorton Feb 16, 2023
e502402
Add errors to IssuanceResponseContainer extension.
symorton Feb 16, 2023
20953fd
RawContract --> RawManifest
symorton Feb 16, 2023
385f3e5
Update IssuanceService+Contract.swift
symorton Feb 16, 2023
2a8f865
Update project.pbxproj
symorton Feb 16, 2023
cab10d8
Split Issuance Service extensions.
symorton Feb 16, 2023
99061e5
Update ManifestResolver.swift
symorton Feb 16, 2023
640a41f
Update folder structure for manifest.
symorton Feb 16, 2023
f4ad149
Make IssuanceResponseContainer and param in ContractIssuanceRequest i…
symorton Feb 16, 2023
c927e42
Create VerifiableCredential.swift
symorton Feb 16, 2023
5495972
Update MockContractResolver.swift
symorton Feb 16, 2023
da6cd08
Update OpenIdRequestHandler.swift
symorton Feb 16, 2023
88b5f2e
Update name of IssuanceResponseContainer extension.
symorton Feb 16, 2023
08bef64
Merge branch 'dev' into symorton/addValidationToRequirements
symorton Feb 16, 2023
216989a
Fix error strings in IssuanceResponseContainer.
symorton Feb 16, 2023
b0320ea
Update IssuanceService+ManifestResolver.swift
symorton Feb 16, 2023
67105af
Add error to Issuance Service extension.
symorton Feb 16, 2023
a188dde
Update vc requester comments.
symorton Feb 16, 2023
4b70143
Separate manifest resolver and vc requester in open id handler.
symorton Feb 16, 2023
f8373c3
Update ContractIssuanceRequest.swift
symorton Feb 16, 2023
8aa0954
Update VerifiedIdClientBuilder.swift
symorton Feb 16, 2023
5af185c
Update tests with new data models.
symorton Feb 16, 2023
04e9275
Complete test cases for pin requirement.
symorton Feb 16, 2023
ac37a8b
Complete test cases for id token requirement.
symorton Feb 16, 2023
d063a7a
Complete test cases for access token requirement.
symorton Feb 16, 2023
738021f
Complete test cases for SelfAttestedClaimRequirement.
symorton Feb 16, 2023
64560ef
Complete test cases for Group Requirement.
symorton Feb 16, 2023
95e5752
Complete test cases for Issuance Response Container Extension.
symorton Feb 17, 2023
4295261
Fix nits before PR.
symorton Feb 17, 2023
99e299a
Add comments to requirements.
symorton Feb 17, 2023
4409d66
Update MockVerifiableCredentialRequester.swift
symorton Feb 17, 2023
ed64163
Update VerifiableCredential-SDK-iOS
symorton Feb 17, 2023
c938793
Update PresentationRequest+MappableTests.swift
symorton Feb 17, 2023
5148668
Add app icon to test app.
symorton Feb 22, 2023
5e98860
Add functionality to test app.
symorton Feb 22, 2023
ebcf067
Support id token hint flow in issuance response container extension.
symorton Feb 22, 2023
c627c00
Remove scope as required value in id token descriptor mapping.
symorton Feb 22, 2023
44756e9
Support id token hint flow in presentation request mapping.
symorton Feb 22, 2023
5ebc105
Update VerifiedIdRequest.swift
symorton Feb 22, 2023
1e0dcf1
Support id token hint flow in OpenIdRequestHandler.
symorton Feb 22, 2023
9dcf2b1
Implement isSatisfied in ContractIssuanceRequest.
symorton Feb 22, 2023
350d5da
Update IdTokenRequirement.swift
symorton Feb 22, 2023
e78765c
Support id token hint flow in VerifiedIdRequestContent.
symorton Feb 22, 2023
55bf5b4
Add VC mapping.
symorton Feb 22, 2023
adac1e1
Create InjectedIdToken.
symorton Feb 22, 2023
744773c
Create file for RequestView.
symorton Feb 22, 2023
2ee900c
Create RequirementView.swift
symorton Feb 22, 2023
a039d37
Update ContentView.swift
symorton Feb 22, 2023
9cedd3f
Update RequirementState.swift
symorton Feb 22, 2023
2d86172
Update comments in SampleViewModel.
symorton Feb 22, 2023
dc41457
Add Verified Id Type.
symorton Feb 23, 2023
30cf908
Update VerifiedId.swift
symorton Feb 23, 2023
c49fb18
Implement mapping for VerifiableCredential.
symorton Feb 23, 2023
3561f0b
Update VerifiedIdClaim.swift
symorton Feb 23, 2023
41caadc
Add showing Verified Id on Request View.
symorton Feb 23, 2023
ca5aa4e
Update RequirementState.swift
symorton Feb 23, 2023
7a3ca69
Update ContentView.swift
symorton Feb 23, 2023
a4ca47b
Update SampleViewModel.swift
symorton Feb 23, 2023
83b29de
Update how we import VC SDK.
symorton Feb 24, 2023
5b2af96
Make VerifiedId a protocol.
symorton Feb 24, 2023
275aec8
VerifiableCredential conforms to Verified Id
symorton Feb 24, 2023
f1cb00c
Update IdTokenDescriptor+MappableTests.swift
symorton Feb 24, 2023
8c2d0c2
Update classes who depend on VC.
symorton Feb 24, 2023
748d75b
Add Error View to test app.
symorton Feb 24, 2023
8447c01
Update request view.
symorton Feb 24, 2023
1d56075
Update requirements view.
symorton Feb 24, 2023
22993a9
Create RequirementListCellView.swift
symorton Feb 24, 2023
d30ef37
Make RequirementState an ObservableObject.
symorton Feb 24, 2023
171d7c0
Create SuccessView.swift
symorton Feb 24, 2023
d057f81
make getClaims a functions instead of property.
symorton Feb 24, 2023
5532d85
Update VerifiableCredential-SDK-iOS
symorton Feb 24, 2023
fb7d948
Add PinDescriptor mapping.
symorton Feb 24, 2023
26afa38
Update IssuanceResponseContainer+WalletLibrary.swift
symorton Feb 24, 2023
6ac88fd
Add PinDescriptor mapping to presentation request mapping.
symorton Feb 24, 2023
9d3fb3c
Update IssuanceResponseContainerExtensionTests.swift
symorton Feb 24, 2023
436157c
Create PinDescriptor+MappableTests.swift
symorton Feb 24, 2023
3aa173a
Update PresentationRequest+MappableTests.swift
symorton Feb 24, 2023
edb6908
Complete test cases for ContractIssuanceRequest.
symorton Feb 24, 2023
e148be1
Add protocol for IssuanceResponseContaining.
symorton Feb 25, 2023
1fdddfd
Update IssuanceResponseContainer+WalletLibrary.swift
symorton Feb 25, 2023
1f1ed09
Update naming.
symorton Feb 25, 2023
59c7244
Update naming.
symorton Feb 25, 2023
8a02caf
Add mocks.
symorton Feb 25, 2023
73adf67
Update naming.
symorton Feb 25, 2023
0fbdd8e
Update VerifiedIdRequestContent.swift
symorton Feb 25, 2023
63f74ba
Update VerifiableCredential.swift
symorton Feb 25, 2023
cf6ebd0
Update VerifiedId.swift
symorton Feb 25, 2023
b28594b
Update VerifiedIdClaim.swift
symorton Feb 25, 2023
c588da2
Create VerifiableCredentialTests.swift
symorton Feb 25, 2023
7da70d7
Update VerifiableCredential-SDK-iOS
symorton Feb 25, 2023
2bcdc0d
Update VerifiableCredentialTests.swift
symorton Feb 28, 2023
a899499
Merge branch 'dev' into symorton/testAppPart1
symorton Feb 28, 2023
0bd2bc8
Update InjectedIdToken.swift
symorton Feb 28, 2023
b445df6
Add IdTokenHint logic to IssuanceResponseContainer extension.
symorton Feb 28, 2023
79ce634
Update IdTokenDescriptor+Mappable.swift
symorton Feb 28, 2023
7448c6e
Create PinDescriptor+Mappable.swift
symorton Feb 28, 2023
12cfd54
Add IdTokenHint logic to presentation request extension.
symorton Feb 28, 2023
ff856e3
Update IssuanceService+VerifiableCredentialRequester.swift
symorton Feb 28, 2023
1529611
Create IssuanceResponseContaining.swift
symorton Feb 28, 2023
3cdcdc7
Update ManifestResolver.swift
symorton Feb 28, 2023
46f80c5
Create VerifiedIdRequester protocol.
symorton Feb 28, 2023
3db52cc
Add IdTokenHint logic to OpenIdRequestHandler.
symorton Feb 28, 2023
bedaa18
Add isSatisfied logic to ContractIssuanceRequest.
symorton Feb 28, 2023
46a4e1e
Update VerifiableCredential-SDK-iOS
symorton Feb 28, 2023
ad29d99
Create InjectedIdToken.swift
symorton Feb 28, 2023
f7681ab
Update GroupRequirement.swift
symorton Feb 28, 2023
bbafc7c
Update IdTokenRequirement.swift
symorton Feb 28, 2023
a7196c7
Update VerifiedIdRequestContent.swift
symorton Feb 28, 2023
5426f72
Update mocks.
symorton Feb 28, 2023
b32e061
Add IdTokenHint logic to IssuanceResponseContainer extension tests.
symorton Feb 28, 2023
edea293
Update IdTokenDescriptor+MappableTests.swift
symorton Feb 28, 2023
d6080e3
Create PinDescriptor+MappableTests.swift
symorton Feb 28, 2023
4224523
Add IdTokenHint logic to presentation request extension tests.
symorton Feb 28, 2023
ef28ff0
Make VerifiedId a protocol.
symorton Feb 28, 2023
b9415c9
Update OpenIdRequestHandlerTests.swift
symorton Feb 28, 2023
e618d0e
Update Resolver tests.
symorton Feb 28, 2023
d5f0b44
Create VerifiableCredentialTests.swift
symorton Feb 28, 2023
ebed072
Fix comment in IssuanceResponseContaining.
symorton Feb 28, 2023
ce8a7cb
Fix naming in ContractIssuanceRequest.
symorton Feb 28, 2023
a07e0aa
Fix error name in VerifiableCredentialError.
symorton Feb 28, 2023
a5dd7e4
Update VerifiedIdRequester.swift
symorton Feb 28, 2023
9618851
Remove VerifiedIdType.
symorton Feb 28, 2023
82127c3
Merge branch 'symorton/idTokenHint' into symorton/testAppPart1
symorton Feb 28, 2023
4073ce8
Update SampleViewModel naming.
symorton Feb 28, 2023
f54a3da
Merge branch 'dev' into symorton/testAppPart1
symorton Mar 7, 2023
3356d5a
update vc sdk git commit.
symorton Mar 7, 2023
7d15b57
Remove Verified Id Type.
symorton Mar 7, 2023
109a4a5
Create extension for PresentationResponseContainer.
symorton Mar 8, 2023
3207ca6
Update PresentationRequest+OpenIdRawRequest.swift
symorton Mar 8, 2023
ee78dc7
Update IssuanceRequest+Mappable.swift
symorton Mar 8, 2023
0acf33c
Update PresentationDescriptor+Mappable.swift
symorton Mar 8, 2023
7455a09
Add id to VerifiedIdRequirement
symorton Mar 8, 2023
13a3fa1
Update PresentationRequest+Mappable.swift
symorton Mar 8, 2023
75071a5
Update PresentationService+OpenIdForVC.swift
symorton Mar 8, 2023
9230730
Update OpenIdForVCResponder.swift
symorton Mar 8, 2023
ee29efc
Make OpenIdRawRequest conform to RawRequest.
symorton Mar 8, 2023
7c0e700
Make RawManifest conform to RawRequest.
symorton Mar 8, 2023
caf5d81
Update OpenIdRequestHandler.swift
symorton Mar 8, 2023
e8e8a59
Update ContractIssuanceRequest.swift
symorton Mar 8, 2023
a320735
Implement complete method for openIdPresentationRequest.
symorton Mar 8, 2023
743e61c
Update VerifiedIdRequestContent.swift
symorton Mar 8, 2023
913a19b
Update VerifiedIdClientBuilder.swift
symorton Mar 8, 2023
0e23abe
Update tests to include id.
symorton Mar 8, 2023
0137bd1
Update MockRawManifest.swift
symorton Mar 8, 2023
3874a36
Create MockPresentationResponder.swift
symorton Mar 8, 2023
dabbe29
Update MockRawRequest.swift
symorton Mar 8, 2023
063c046
Update MockOpenIdRawRequest.swift
symorton Mar 8, 2023
a8a744b
Update MockResolver.swift
symorton Mar 8, 2023
6a13c55
Update tests.
symorton Mar 8, 2023
4cced2f
Remove raw value idea from content.
symorton Mar 8, 2023
0d9533a
Update PresentationService+OpenIdForVC.swift
symorton Mar 8, 2023
eaa579a
Rename to OpenIdResponder.
symorton Mar 8, 2023
e9b3601
Update OpenIdRequestHandler.swift
symorton Mar 8, 2023
d30f24f
Inject raw value into OpenIdPresentationRequest.
symorton Mar 8, 2023
95d1c94
Remove raw value in content idea.
symorton Mar 8, 2023
3c53dc1
fix tests.
symorton Mar 8, 2023
9bbc810
Update project.pbxproj
symorton Mar 8, 2023
04027c6
Move some folders around.
symorton Mar 8, 2023
3171245
Update name of an error on PresentationResponseContainer.
symorton Mar 8, 2023
0f2b258
Create PresentationResponse.swift
symorton Mar 8, 2023
7b6956c
Remove RawRequest from RawManifest.
symorton Mar 8, 2023
d38bb1e
Remove RawRequest idea from OpenIdRawRequest.
symorton Mar 8, 2023
d2c6432
Fix comment in openIdResponder.
symorton Mar 8, 2023
34033de
Fix naming in OpenIdRequestHandler.
symorton Mar 8, 2023
1d362d5
Update AttestationsDescriptor+MappableTests.swift
symorton Mar 8, 2023
9312fbb
Update PresentationDefinition+MappableTests.swift
symorton Mar 8, 2023
f2b6255
Move factories to different folder.
symorton Mar 8, 2023
c7a1993
Split up Issuance and Presentation Request Content.
symorton Mar 8, 2023
d5f123e
Fix mock resolver.
symorton Mar 8, 2023
d468dec
Update name of param in OpenIdRequestHandler.
symorton Mar 8, 2023
0a38249
Move some files changes to new PR.
symorton Mar 8, 2023
471d31e
Create PresentationResponseContainer extension.
symorton Mar 8, 2023
02fac99
Remove code to be added in next pr.
symorton Mar 8, 2023
0cedd82
Fix tests.
symorton Mar 8, 2023
9f574d5
Add placeholder files for extension and content tests.
symorton Mar 9, 2023
88fa301
Update PresentationResponseContainer+WalletLibrary.swift
symorton Mar 9, 2023
9ec9826
Update IssuanceRequestContent.swift
symorton Mar 9, 2023
463f6d3
Complete test cases for issuance request content.
symorton Mar 9, 2023
db429d3
fix nits before PR.
symorton Mar 9, 2023
ebc2ffe
Merge branch 'dev' into symorton/splitIssuanceAndPresentationRequestC…
symorton Mar 9, 2023
686653c
Address PR comments.
symorton Mar 14, 2023
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
74 changes: 41 additions & 33 deletions WalletLibrary/WalletLibrary.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import VCEntities

enum PresentationResponseError: Error, Equatable {
case unableToCastVCSDKPresentationRequestFromRawRequestOfType(String)
case unsupportedRequirementOfType(String)
case unableToCastVerifableCredentialFromVerifiedIdOfType(String)
case missingIdInVerifiedIdRequirement
}

/**
* An extension of the VCEntities.PresentationResponseContainer class
* to convert Requirements to mappings in PresentationResponseContainer.
*/
extension VCEntities.PresentationResponseContainer: PresentationResponse {

init(rawRequest: any OpenIdRawRequest) throws {

guard let presentationRequest = rawRequest as? VCEntities.PresentationRequest else {
let requestType = String(describing: type(of: rawRequest))
throw PresentationResponseError.unableToCastVCSDKPresentationRequestFromRawRequestOfType(requestType)
}

try self.init(from: presentationRequest)
}

mutating func add(requirement: Requirement) throws {
switch (requirement) {
case let groupRequirement as GroupRequirement:
try add(groupRequirement: groupRequirement)
case let verifiedIdRequirement as VerifiedIdRequirement:
try add(verifiedIdRequirement: verifiedIdRequirement)
default:
let requirementType = String(describing: type(of: requirement))
throw PresentationResponseError.unsupportedRequirementOfType(requirementType)
}
}

private mutating func add(groupRequirement: GroupRequirement) throws {
try groupRequirement.validate()
for requirement in groupRequirement.requirements {
try add(requirement: requirement)
}
}

private mutating func add(verifiedIdRequirement: VerifiedIdRequirement) throws {
throw VerifiedIdClientError.TODO(message: "Implement in next PR.")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import VCEntities
* TODO: Update Style to include VerifiedIdStyle and more requester style attributes.
*/
extension VCEntities.IssuanceRequest: Mappable {
func map(using mapper: Mapping) throws -> VerifiedIdRequestContent {
func map(using mapper: Mapping) throws -> IssuanceRequestContent {

let attestations = try getRequiredProperty(property: content.input.attestations,
propertyName: "attestations")
let requirement = try mapper.map(attestations)
let rootOfTrust = try mapper.map(linkedDomainResult)
let issuerStyle = Manifest2022IssuerStyle(name: content.display.card.issuedBy)

return VerifiedIdRequestContent(style: issuerStyle,
requirement: requirement,
rootOfTrust: rootOfTrust)
return IssuanceRequestContent(style: issuerStyle,
requirement: requirement,
rootOfTrust: rootOfTrust)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enum PresentationRequestMappingError: Error {
*/
extension VCEntities.PresentationRequest: Mappable {

func map(using mapper: Mapping) throws -> VerifiedIdRequestContent {
func map(using mapper: Mapping) throws -> PresentationRequestContent {

guard let presentationDefinition = content.claims?.vpToken?.presentationDefinition else {
throw PresentationRequestMappingError.presentationDefinitionMissingInRequest
Expand All @@ -31,10 +31,10 @@ extension VCEntities.PresentationRequest: Mappable {
let clientName = content.registration?.clientName ?? ""
let requesterStyle = OpenIdVerifierStyle(name: clientName)

let content = VerifiedIdRequestContent(style: requesterStyle,
requirement: requirement,
rootOfTrust: rootOfTrust,
injectedIdToken: injectedIdToken)
let content = PresentationRequestContent(style: requesterStyle,
requirement: requirement,
rootOfTrust: rootOfTrust,
injectedIdToken: injectedIdToken)

return content
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
import VCEntities
import VCServices

enum PresentationServiceError: Error {
case unableToCastOpenIdForVCResponseToPresentationResponseContainer
}

/**
* An extension of the VCServices.PresentationService class.
*/
extension PresentationService: OpenIdForVCResolver, OpenIdForVCResponder {
extension PresentationService: OpenIdForVCResolver, OpenIdResponder {

/// Fetches and validates the presentation request.
func getRequest(url: String) async throws -> any OpenIdRawRequest {
Expand All @@ -20,9 +24,14 @@ extension PresentationService: OpenIdForVCResolver, OpenIdForVCResponder {

/// Sends the presentation response container and if successful, returns void,
/// If unsuccessful, throws an error.
func send(response: VCEntities.PresentationResponseContainer) async throws -> Void {
func send(response: PresentationResponse) async throws -> Void {

guard let presentationResponseContainer = response as? PresentationResponseContainer else {
throw PresentationServiceError.unableToCastOpenIdForVCResponseToPresentationResponseContainer
}

let _ = try await AsyncWrapper().wrap { () in
self.send(response: response)
self.send(response: presentationResponseContainer)
}()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
* Representation of a Raw Contract.
* Object that conforms to this protocol must be able to map to VerifiedIdRequestContent.
*/
protocol RawManifest: Mappable where T == VerifiedIdRequestContent {}
protocol RawManifest: Mappable where T == IssuanceRequestContent {}

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
* Representation of a Raw Open Id Request.
* Object that conforms to this protocol must be able to map to VerifiedIdRequestContent.
*/
protocol OpenIdRawRequest: Mappable where T == VerifiedIdRequestContent {
protocol OpenIdRawRequest: Mappable where T == PresentationRequestContent {

var type: RequestType { get }

var raw: Data? { get }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import VCEntities
/**
* Protocol is used as a wrapper to wrap the VC SDK send presentation response method.
*/
protocol OpenIdForVCResponder {
/// Sends the presentation response container and if successful, returns void,
protocol OpenIdResponder {
/// Sends the presentation response and if successful, returns void,
/// If unsuccessful, throws an error.
func send(response: PresentationResponseContainer) async throws -> Void
func send(response: PresentationResponse) async throws -> Void
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

/**
* An object that describes a raw presense response and defines the behavior of adding a requirement to it.
symorton marked this conversation as resolved.
Show resolved Hide resolved
* For example, a VCSDK.PresentationResponseContainer conforms to this protocol.
*/
protocol PresentationResponse {
mutating func add(requirement: Requirement) throws
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ struct OpenIdRequestHandler: RequestHandling {

private let configuration: LibraryConfiguration

private let openIdResponder: OpenIdResponder

private let manifestResolver: ManifestResolver

private let verifiableCredentialRequester: VerifiedIdRequester
private let verifiedIdRequester: VerifiedIdRequester

/// TODO: post private preview, manifest resolving and verified id requester will be handled by processors.
init(configuration: LibraryConfiguration,
openIdResponder: OpenIdResponder,
manifestResolver: ManifestResolver,
verifiableCredentialRequester: VerifiedIdRequester) {
self.configuration = configuration
self.openIdResponder = openIdResponder
self.manifestResolver = manifestResolver
self.verifiableCredentialRequester = verifiableCredentialRequester
self.verifiedIdRequester = verifiableCredentialRequester
}

/// Create a VeriifiedIdRequest based on the Open Id raw request given.
Expand All @@ -45,10 +49,10 @@ struct OpenIdRequestHandler: RequestHandling {
return try await handleIssuanceRequest(from: requestContent)
}

return try handlePresentationRequest(from: requestContent)
return handlePresentationRequest(requestContent: requestContent, rawRequest: request)
}

private func handleIssuanceRequest(from requestContent: VerifiedIdRequestContent) async throws -> any VerifiedIdIssuanceRequest {
private func handleIssuanceRequest(from requestContent: PresentationRequestContent) async throws -> any VerifiedIdIssuanceRequest {

guard let verifiedIdRequirement = requestContent.requirement as? VerifiedIdRequirement else {
throw OpenIdRequestHandlerError.unableToCastRequirementToVerifiedIdRequirement
Expand All @@ -69,11 +73,15 @@ struct OpenIdRequestHandler: RequestHandling {

return ContractIssuanceRequest(content: issuanceRequestContent,
issuanceResponseContainer: issuanceResponseContainer,
verifiedIdRequester: verifiableCredentialRequester,
verifiedIdRequester: verifiedIdRequester,
configuration: configuration)
}

private func handlePresentationRequest(from requestContent: VerifiedIdRequestContent) throws -> any VerifiedIdPresentationRequest {
return OpenIdPresentationRequest(content: requestContent, configuration: configuration)
private func handlePresentationRequest(requestContent: PresentationRequestContent,
rawRequest: any OpenIdRawRequest) -> any VerifiedIdPresentationRequest {
return OpenIdPresentationRequest(content: requestContent,
rawRequest: rawRequest,
openIdResponder: openIdResponder,
configuration: configuration)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,49 @@
*--------------------------------------------------------------------------------------------*/

/**
* Contents in a Verified Id Request.
* Contents in a Verified Id Issuance Request.
* This object is used to map protocol specific requests to common request object.
* TODO: make this object extensible by separating Presentation with Issuance esp. for InjectedIdToken logic.
* TODO: add VerifiedIdStyle to Issuance Content.
*/
struct VerifiedIdRequestContent {
struct IssuanceRequestContent {

private struct Constants {
static let IdTokenHintKey = "https://self-issued.me"
}

let style: RequesterStyle

var requirement: Requirement

let rootOfTrust: RootOfTrust

let injectedIdToken: InjectedIdToken?

init(style: RequesterStyle,
requirement: Requirement,
rootOfTrust: RootOfTrust,
injectedIdToken: InjectedIdToken? = nil) {
self.style = style
self.requirement = requirement
self.rootOfTrust = rootOfTrust
self.injectedIdToken = injectedIdToken
}

mutating func addRequirement(from injectedIdToken: InjectedIdToken) {
switch (requirement) {
case var groupRequirement as GroupRequirement:
repopulateGroupRequirementIfInjectedIdTokenExists(injectedIdToken: injectedIdToken,
groupRequirement: &groupRequirement)
groupRequirement: groupRequirement)
case let idTokenRequirement as IdTokenRequirement:
addInjectedIdTokenHintToIdTokenRequirement(injectedIdToken: injectedIdToken,
idTokenRequirement: idTokenRequirement)
default:
return
}
}

private mutating func addInjectedIdTokenHintToIdTokenRequirement(injectedIdToken: InjectedIdToken,
symorton marked this conversation as resolved.
Show resolved Hide resolved
idTokenRequirement: IdTokenRequirement) {
if idTokenRequirement.configuration.absoluteString == Constants.IdTokenHintKey {
idTokenRequirement.fulfill(with: injectedIdToken.rawToken)
if let pinRequirement = injectedIdToken.pin {
requirement = GroupRequirement(required: false,
requirements: [idTokenRequirement, pinRequirement],
requirementOperator: .ALL)
}
default:
return
}
}

private func repopulateGroupRequirementIfInjectedIdTokenExists(injectedIdToken: InjectedIdToken,
groupRequirement: inout GroupRequirement) {
groupRequirement: GroupRequirement) {
for requirement in groupRequirement.requirements {
if let idTokenRequirement = requirement as? IdTokenRequirement {
idTokenRequirement.fulfill(with: injectedIdToken.rawToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ContractIssuanceRequest: VerifiedIdIssuanceRequest {

private var responseContainer: IssuanceResponseContaining

init(content: VerifiedIdRequestContent,
init(content: IssuanceRequestContent,
issuanceResponseContainer: IssuanceResponseContaining,
verifiedIdRequester: VerifiedIdRequester,
configuration: LibraryConfiguration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,22 @@ class OpenIdPresentationRequest: VerifiedIdPresentationRequest {

let rootOfTrust: RootOfTrust

private let rawRequest: any OpenIdRawRequest

private let responder: OpenIdResponder

private let configuration: LibraryConfiguration

init(content: VerifiedIdRequestContent, configuration: LibraryConfiguration) {
init(content: PresentationRequestContent,
rawRequest: any OpenIdRawRequest,
openIdResponder: OpenIdResponder,
configuration: LibraryConfiguration) {

self.style = content.style
self.requirement = content.requirement
self.rootOfTrust = content.rootOfTrust
self.rawRequest = rawRequest
self.responder = openIdResponder
self.configuration = configuration
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

/**
* Contents in a Verified Id Presentation Request.
* This object is used to map protocol specific requests to common request object.
*/
struct PresentationRequestContent {

let style: RequesterStyle

var requirement: Requirement

let rootOfTrust: RootOfTrust

let injectedIdToken: InjectedIdToken?

init(style: RequesterStyle,
requirement: Requirement,
rootOfTrust: RootOfTrust,
injectedIdToken: InjectedIdToken? = nil) {
self.style = style
self.requirement = requirement
self.rootOfTrust = rootOfTrust
self.injectedIdToken = injectedIdToken
}
}
2 changes: 2 additions & 0 deletions WalletLibrary/WalletLibrary/VerifiedIdClientBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public class VerifiedIdClientBuilder {

private func registerSupportedRequestHandlers(with configuration: LibraryConfiguration) {
let issuanceService = IssuanceService()
let presentationService = PresentationService()
let openIdHandler = OpenIdRequestHandler(configuration: configuration,
openIdResponder: presentationService,
manifestResolver: issuanceService,
verifiableCredentialRequester: issuanceService)
requestHandlers.append(openIdHandler)
Expand Down
Loading