-
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.
feat(pollux): add support for sd-jwt
This commit adds support for sd-jwt. Receive issued credentials and present. Fixes ATL-7185
- Loading branch information
1 parent
8e68386
commit 8bb9b74
Showing
26 changed files
with
505 additions
and
229 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,6 +198,8 @@ public extension EdgeAgent { | |
switch offerFormat { | ||
case "prism/jwt": | ||
format = "prism/jwt" | ||
case "vc+sd-jwt": | ||
format = "vc+sd-jwt" | ||
case "anoncreds/[email protected]": | ||
format = "anoncreds/[email protected]" | ||
default: | ||
|
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 |
---|---|---|
|
@@ -44,7 +44,7 @@ public extension EdgeAgent { | |
.linkSecret(id: "", secret: linkSecretString) | ||
] | ||
) | ||
case "prism/jwt", "dif/presentation-exchange/[email protected]": | ||
case "prism/jwt", "vc+sd-jwt", "dif/presentation-exchange/[email protected]": | ||
guard | ||
let subjectDIDString = credential.subject | ||
else { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ extension JWTCredential: ProvableCredential { | |
switch attachment.format { | ||
case "dif/presentation-exchange/[email protected]": | ||
let requestData = try JSONDecoder.didComm().decode(PresentationExchangeRequest.self, from: jsonData) | ||
let payload = try JWT<DefaultJWTClaimsImpl>.getPayload(jwtString: jwtString) | ||
let payload: Data = try JWT.getPayload(jwtString: jwtString) | ||
do { | ||
try VerifyPresentationSubmission.verifyPresentationSubmissionClaims( | ||
request: requestData.presentationDefinition, credentials: [payload] | ||
|
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
21 changes: 21 additions & 0 deletions
21
EdgeAgentSDK/Pollux/Sources/Models/SDJWT/SDJWT+Codable.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,21 @@ | ||
import Foundation | ||
|
||
extension SDJWTCredential: Codable { | ||
enum CodingKeys: String, CodingKey { | ||
case sdjwtString | ||
} | ||
|
||
func encode(to encoder: any Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
|
||
try container.encode(sdjwtString, forKey: .sdjwtString) | ||
} | ||
|
||
init(from decoder: any Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
|
||
let sdjwtString = try container.decode(String.self, forKey: .sdjwtString) | ||
|
||
try self.init(sdjwtString: sdjwtString) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
EdgeAgentSDK/Pollux/Sources/Models/SDJWT/SDJWT+ProvableCredential.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,16 @@ | ||
import Domain | ||
import Foundation | ||
|
||
extension SDJWTCredential: ProvableCredential { | ||
func presentation(request: Domain.Message, options: [Domain.CredentialOperationsOptions]) throws -> String { | ||
try SDJWTPresentation().createPresentation( | ||
credential: self, | ||
request: request, | ||
options: options | ||
) | ||
} | ||
|
||
func isValidForPresentation(request: Domain.Message, options: [Domain.CredentialOperationsOptions]) throws -> Bool { | ||
request.attachments.first.map { $0.format == "vc+sd-jwt"} ?? true | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
EdgeAgentSDK/Pollux/Sources/Models/SDJWT/SDJWT+StorableCredential.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,48 @@ | ||
import Domain | ||
import Foundation | ||
|
||
extension SDJWTCredential: StorableCredential { | ||
var storingId: String { | ||
sdjwtString | ||
} | ||
|
||
var recoveryId: String { | ||
"sd-jwt+credential" | ||
} | ||
|
||
var credentialData: Data { | ||
(try? sdjwtString.tryToData()) ?? Data() | ||
} | ||
|
||
var queryIssuer: String? { | ||
issuer | ||
} | ||
|
||
var querySubject: String? { | ||
subject | ||
} | ||
|
||
var queryCredentialCreated: Date? { | ||
nil | ||
} | ||
|
||
var queryCredentialUpdated: Date? { | ||
nil | ||
} | ||
|
||
var queryCredentialSchema: String? { | ||
nil | ||
} | ||
|
||
var queryValidUntil: Date? { | ||
nil | ||
} | ||
|
||
var queryRevoked: Bool? { | ||
nil | ||
} | ||
|
||
var queryAvailableClaims: [String] { | ||
claims.map(\.key) | ||
} | ||
} |
Oops, something went wrong.