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

Release #33

Open
wants to merge 100 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
2a82c1f
Modify to comply with First Implementer's Draft and perform refactoring.
moratori Jun 24, 2024
70d0466
WIP Fixing broken test cases.
moratori Jun 24, 2024
9ac8832
Fixed existing test code to work properly. In particular, modified to…
moratori Jun 24, 2024
20814ec
Run formatter
moratori Jun 24, 2024
f378e67
Add test data under the appropriate resouce directory.
moratori Jun 24, 2024
7437efa
Added utility for loading resource file
moratori Jun 24, 2024
7d6255a
Add test case related to TxCode
moratori Jun 24, 2024
4d2c616
Fixed to define data types in the appropriate files.
moratori Jun 24, 2024
34a34e2
Separate test cases
moratori Jun 24, 2024
2e2ed6a
Changes caused by adding files.
moratori Jun 24, 2024
fa04d85
Changed class names to better reflect what the tests do.
moratori Jun 24, 2024
962c917
Removed the incorrect property.
moratori Jun 24, 2024
2687f92
Fixed to use `struct`.
moratori Jun 24, 2024
0944afb
Add testcases
moratori Jun 24, 2024
24af3b3
Add testcases.
moratori Jun 24, 2024
1ffc9f1
Run formatter
moratori Jun 24, 2024
816383d
Remove unnecessary comment
moratori Jun 24, 2024
dc5bb36
Add testdata and a bit of refactoring.
moratori Jun 24, 2024
92d44c5
Added Credential Response variations.
moratori Jun 24, 2024
89ce1f2
Add test
moratori Jun 24, 2024
cfea522
Changes due to file additions
moratori Jun 24, 2024
929550b
Added processing to consider the case where the credential is `nil`.
moratori Jun 24, 2024
2104d6b
Add todo comment
moratori Jun 24, 2024
4983bda
Remove duplicate functions
moratori Jun 25, 2024
a86e0fd
Based on discussions with internal developers, modified to remove red…
moratori Jun 25, 2024
d42d687
Merge branch develop into adopt-first-implementors-draft
moratori Jul 3, 2024
8337ed4
Merge pull request #24 from OWND-Project/release
sadamu Jul 16, 2024
8e338c3
The explanation of the data provided by VP on the data provision scre…
ryosuke-wakaba Jul 16, 2024
e46af5d
format
ryosuke-wakaba Jul 16, 2024
37d5726
Merge branch 'develop' into chore/change-data-source-of-data-sharing-…
ryosuke-wakaba Jul 16, 2024
b030f51
Merge pull request #25 from ryosuke-wakaba/chore/change-data-source-o…
sadamu Jul 18, 2024
61c47e9
Merge branch develop into adopt-first-implementors-draft
moratori Jul 19, 2024
68416ba
Fixed the value of the translation key to the appropriate value.
moratori Jul 19, 2024
1b34dbc
Merge pull request #17 from moratori/adopt-first-implementors-draft
ryosuke-wakaba Jul 19, 2024
95053a5
Fixed to be able to show the preview screen of CredentialDetail.
moratori Aug 21, 2024
64ca6d2
Fix typo
moratori Aug 21, 2024
3001fec
Improved handling of nil
moratori Aug 22, 2024
725d142
Improved conformance to Presentation Exchange v2.0.0.
moratori Aug 22, 2024
4da2e63
run formatter
moratori Aug 22, 2024
4105b7f
Improved conformance to Presentation Exchange v2.0.0
moratori Aug 22, 2024
1d993a6
Change existing preview as a preview for a corrupted credential offer.
moratori Aug 23, 2024
75248f5
run formatter
moratori Aug 26, 2024
06127d5
Added translation for the selective disclosure section
moratori Aug 26, 2024
f38c1a2
In order to make `DisclosureWithOptionality` codable, change this str…
moratori Aug 26, 2024
2045b46
Modified implementation to allow users to select which claims to disc…
moratori Aug 26, 2024
7316cee
Add testcases
moratori Aug 26, 2024
b97e1fc
Merge pull request #2 from moratori/allow-selection-of-disclosure-items
moratori Aug 27, 2024
8e72882
Modifications and refactoring based on review comments.
moratori Sep 3, 2024
13bc156
Change parameter names to represent the actual process.
moratori Sep 4, 2024
352857e
Merge pull request #28 from moratori/fix-credential-detail-preview
ryosuke-wakaba Sep 4, 2024
3d01c77
run formatter
moratori Sep 27, 2024
38a8bc9
Refactoring: Fixed error handling and corrected return values ​​to mo…
moratori Sep 27, 2024
61e064a
remove unnecessary property
moratori Sep 27, 2024
2050e3e
run formatter
moratori Sep 27, 2024
eb953ff
Added test for sending multiple VP tokens.
moratori Sep 27, 2024
2597aff
remove unused data structure
moratori Sep 27, 2024
efb4914
Modified to allow multiple credentials to be held in the model.
moratori Sep 27, 2024
52cef55
run formatter
moratori Sep 27, 2024
15b6937
Updated to resolve issues with Xcode 16
moratori Oct 1, 2024
4f1da03
Change directory structure and remove unnecessary data structures.
moratori Oct 1, 2024
fdbe3c3
Move the implementation to the appropriate location.
moratori Oct 2, 2024
bd43791
Move the method to the appropriate class.
moratori Oct 2, 2024
64e12bd
refactoring
moratori Oct 2, 2024
efb275a
Changed to appropriate naming.
moratori Oct 2, 2024
0b6f704
Merge pull request #29 from moratori/feature-multi-presentation
ryosuke-wakaba Oct 2, 2024
6bcfc7d
Modified to make the return types of respondSIOPResponse and respondV…
moratori Oct 2, 2024
a44c2c5
Added error state
moratori Oct 3, 2024
b8fdd8c
Modified mock class to be able to capture HTTP Request Body.
moratori Oct 3, 2024
825d973
Fix to allow id_token and vp_token to be sent at the same time.
moratori Oct 3, 2024
57641d0
Add testcase
moratori Oct 3, 2024
4144b9d
Modify the test case to also check the actual posted content.
moratori Oct 3, 2024
41f41a0
Fixes related to the review's comments.
moratori Oct 9, 2024
aeb8dee
Added comment that originally existed. Removed unused variables.
moratori Oct 9, 2024
82bd328
Open the `redirect_uri` obtained after VP in an external app.
moratori Oct 9, 2024
12a20fd
Refactoring on JSON data conversion process.
moratori Oct 10, 2024
fd5cb0a
Add test code
moratori Oct 10, 2024
5af750c
Fixed to make it clear that we are only verifying signatures. (Expire…
moratori Oct 10, 2024
3d6281e
Refactoring of JWTUtil class (removal of inappropriate functions, uni…
moratori Oct 10, 2024
ce194db
Merge pull request #30 from moratori/simultaneous-sending-tokens-431
ryosuke-wakaba Oct 10, 2024
1261a1f
Merge pull request #31 from moratori/interpret-response-code-after-vp…
sadamu Oct 11, 2024
d69e5ea
Fix `path` value in `descriptor_map` to be appropriate when VP token …
moratori Oct 11, 2024
d3b108d
Fixes to address reviewer comments. We decided to leave the function …
moratori Oct 16, 2024
f7a0260
Merge pull request #32 from moratori/refactor-jwt-related-processing
ryosuke-wakaba Oct 16, 2024
f94a63d
Fixed a bug related to parsing Disclosure.
moratori Nov 10, 2024
3a672cf
Fixed to allow selection of appropriate inputDescriptor.
moratori Nov 10, 2024
8c72334
run formatter
moratori Nov 10, 2024
a9d6b53
Merge pull request #37 from moratori/bugs/disclosures-parsing
ryosuke-wakaba Nov 21, 2024
db1cbd2
Simplify the structure by removing properties that are not from a tes…
moratori Nov 21, 2024
72f8603
Refactoring to simplify conditionals.
moratori Nov 21, 2024
f68c691
Fixed naming of functions to indicate what is being processed.
moratori Nov 21, 2024
7249bcf
remove ununsed resource file
moratori Nov 21, 2024
a17d69e
refactoring
moratori Nov 21, 2024
79bd3b7
rename resource file
moratori Nov 21, 2024
f09d286
run formatter
moratori Nov 21, 2024
893ce37
Added the case where it is a subset of another inputdescriptor.
moratori Nov 21, 2024
2202b3b
Moved resource file location.
moratori Nov 21, 2024
37cc6cf
Improved inputDescriptor matching process.
moratori Nov 21, 2024
388b2e8
run formatter
moratori Nov 21, 2024
ba7688f
remove unnecessary comments
moratori Nov 22, 2024
713fe2e
Merge pull request #39 from moratori/bugs/proper-selection-of-input-d…
ryosuke-wakaba Nov 22, 2024
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
290 changes: 240 additions & 50 deletions tw2023_wallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/skywinder/web3swift",
"state" : {
"revision" : "74c24f4d3d5f1816616e9ebd16741ca5f7a57eb0",
"version" : "3.2.0"
"revision" : "8a026108ae5ff730ac83e9b574c8cf1c14413c94",
"version" : "3.2.2"
}
},
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,58 @@ class DetailVPModePreviewModel: CredentialDetailViewModel {
// mock data for preview
dataModel.isLoading = true
print("load dummy data..")
claimsToDisclose = [
Disclosure(disclosure: "1", key: "last_name", value: "value1"),
Disclosure(disclosure: "3", key: "age", value: "value3"),
requiredClaims = [
DisclosureWithOptionality(
disclosure: Disclosure(disclosure: "1", key: "last_name", value: "value1"),
isSubmit: true,
isUserSelectable: false),
DisclosureWithOptionality(
disclosure: Disclosure(disclosure: "2", key: "age", value: "value3"),
isSubmit: true,
isUserSelectable: false),
]
claimsNotToDisclosed = [
Disclosure(disclosure: "2", key: "first_name", value: "value2")
undisclosedClaims = [
DisclosureWithOptionality(
disclosure: Disclosure(disclosure: "3", key: "first_name", value: "value2"),
isSubmit: false,
isUserSelectable: false)
]

userSelectableClaims = [
DisclosureWithOptionality(
disclosure: Disclosure(disclosure: "4", key: "address", value: "value4"),
isSubmit: false,
isUserSelectable: true),
DisclosureWithOptionality(
disclosure: Disclosure(disclosure: "5", key: "gender", value: "value4"),
isSubmit: true,
isUserSelectable: true),

]

print("done")
dataModel.isLoading = false
}

func dummyPresentationDefinition() -> PresentationDefinition {
func dummyPresentationDefinition1() -> PresentationDefinition {
let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
let presentationJsonData = presentationJson1.data(using: .utf8)
let presentationDefinition = try! decoder.decode(
PresentationDefinition.self, from: presentationJsonData!)
return presentationDefinition
}

func dummyPresentationDefinition2() -> PresentationDefinition {
let decoder = JSONDecoder()
let presentationJsonData = presentationJson.data(using: .utf8)
decoder.keyDecodingStrategy = .convertFromSnakeCase
let presentationJsonData = presentationJson2.data(using: .utf8)
let presentationDefinition = try! decoder.decode(
PresentationDefinition.self, from: presentationJsonData!)
return presentationDefinition
}

let presentationJson = """
let presentationJson1 = """
{
"id": "12345",
"inputDescriptors": [
Expand Down Expand Up @@ -93,4 +125,45 @@ class DetailVPModePreviewModel: CredentialDetailViewModel {
]
}
"""

let presentationJson2 = """
{
"id": "12345",
"inputDescriptors": [
{
"id": "input1",
"name": "First Input",
"purpose": "For identification",
"format": {
"vc+sd-jwt": {}
},
"group": [
"A"
],
"constraints": {
"limitDisclosure": "required",
"fields": [
{
"path": [
"$.is_older_than_13"
],
"filter": {
"type": "boolean"
},
"optional": true
}
]
}
}
],
"submissionRequirements": [
{
"name": "Over13 Proof",
"rule": "pick",
"count": 1,
"from": "A"
}
]
}
"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,26 @@

import Foundation

func jwtVcJsonClaimsTobeDisclosed(jwt: String) -> [Disclosure] {
if let (_, body, _) = try? JWTUtil.decodeJwt(jwt: jwt),
let vc = body["vc"] as? [String: Any],
let credentialSubject = vc["credentialSubject"] as? [String: Any]
{
let disclosures = credentialSubject.map { key, value in
// valueがネストしていることは想定していない。
return Disclosure(disclosure: nil, key: key, value: value as? String)
}
return disclosures
}
return []
}

@Observable
class CredentialDetailViewModel {
var claimsToDisclose: [Disclosure] = []
var claimsNotToDisclosed: [Disclosure] = []
var requiredClaims: [DisclosureWithOptionality] = []
var userSelectableClaims: [DisclosureWithOptionality] = []
var undisclosedClaims: [DisclosureWithOptionality] = []

var dataModel: CredentialDetailModel = .init()
var inputDescriptor: InputDescriptor? = nil

Expand All @@ -32,26 +48,30 @@ class CredentialDetailViewModel {
if let pd = presentationDefinition {
switch credential.format {
case "vc+sd-jwt":
if let selected = selectDisclosure(
sdJwt: credential.payload, presentationDefinition: pd)
if let matched = pd.firstMatchedInputDescriptor(
sdJwt: credential.payload)
{
let (inputDescriptors, _disclosures) = selected
let (inputDescriptors, disclosuresWithOptionality) = matched
self.inputDescriptor = inputDescriptors
self.claimsToDisclose = _disclosures

let allDisclosures = try! SDJwtUtil.decodeSDJwt(credential.payload)
self.claimsNotToDisclosed = allDisclosures.filter { disclosure in
!claimsToDisclose.contains { selected in
selected.disclosure == disclosure.disclosure
}
self.requiredClaims = disclosuresWithOptionality.filter { d in
d.isSubmit && !d.isUserSelectable
}
self.userSelectableClaims = disclosuresWithOptionality.filter { d in
d.isUserSelectable
}
self.undisclosedClaims = disclosuresWithOptionality.filter { d in
!d.isSubmit && !d.isUserSelectable
}
}
case "jwt_vc_json":
inputDescriptor = pd.inputDescriptors[0] // 選択開示できないので先頭固定
self.claimsNotToDisclosed = []

let jwt = credential.payload
self.claimsToDisclose = JWTUtil.convertJWTClaimsAsDisclosure(jwt: jwt)
self.undisclosedClaims = []
self.requiredClaims = jwtVcJsonClaimsTobeDisclosed(jwt: credential.payload).map
{ it in
return DisclosureWithOptionality(
disclosure: it, isSubmit: true, isUserSelectable: false)
}
default:
inputDescriptor = pd.inputDescriptors[0] // 選択開示できないので先頭固定
}
Expand All @@ -60,15 +80,21 @@ class CredentialDetailViewModel {
print("done")
}

func getSubmissionCredential(credential: Credential) -> SubmissionCredential {
func createSubmissionCredential(
credential: Credential,
discloseClaims: [DisclosureWithOptionality]
)
-> SubmissionCredential
{
let types = try! VCIMetadataUtil.extractTypes(
format: credential.format, credential: credential.payload)
let submissionCredential = SubmissionCredential(
id: credential.id,
format: credential.format,
types: types,
credential: credential.payload,
inputDescriptor: self.inputDescriptor!
inputDescriptor: self.inputDescriptor!,
discloseClaims: discloseClaims
)
return submissionCredential
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,19 @@ class CredentialListViewModel {
print("format: \(format)")
do {
if format == "vc+sd-jwt" {
let ret = selectDisclosure(
sdJwt: credential.payload, presentationDefinition: presentationDefinition)
let ret = presentationDefinition.firstMatchedInputDescriptor(
sdJwt: credential.payload)
if let (_, disclosures) = ret {
return 0 < disclosures.count
return 0
< disclosures.filter { it in (it.isUserSelectable || it.isSubmit) }.count
}
return false
}
else if format == "jwt_vc_json" {
let (_, payload, _) = try JWTUtil.decodeJwt(jwt: credential.payload)
print("satisfyConstrains?")
return satisfyConstrains(
credential: payload, presentationDefinition: presentationDefinition)
return presentationDefinition.satisfyConstrains(
credential: payload)
}
else {
// その他のフォーマットに対する処理が必要な場合、ここに追加
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,13 @@ class DisplayQRCodeViewModel: ObservableObject {
// else {
// return nil
// }
let jsonDict = [
let jsonDict: [String: Any] = [
"format": credential.format,
"credential": credential.payload,
"display": credential.qrDisplay,
]

guard let jsonData = try? JSONSerialization.data(withJSONObject: jsonDict, options: []),
let jsonString = String(data: jsonData, encoding: .utf8)
else {
guard let jsonString = try? jsonDict.toString() else {
return nil
}

Expand Down
Loading
Loading