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

Verify v2 #1392

Merged
merged 26 commits into from
Aug 13, 2024
Merged

Verify v2 #1392

merged 26 commits into from
Aug 13, 2024

Conversation

llbartekll
Copy link
Contributor

@llbartekll llbartekll commented Jul 24, 2024

Description

Implements verify v2 api

Resolves # (issue)

How Has This Been Tested?

Due Dilligence

  • Breaking change
  • Requires a documentation update

@llbartekll llbartekll marked this pull request as draft July 24, 2024 05:39
@llbartekll llbartekll requested a review from jackpooleywc July 29, 2024 08:04
@llbartekll llbartekll marked this pull request as ready for review July 29, 2024 08:05
Copy link
Contributor

@jackpooleywc jackpooleywc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few small things.


public struct P256JWTValidator {

let jwtString: String
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be private?

Suggested change
let jwtString: String
private let jwtString: String

self.jwtString = jwtString
}

public func isValid(publicKey: P256.Signing.PublicKey) throws -> Bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this unit tested?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not as a unit here but we have it covered in the AttestationJWTVerifierTests as it depends on P256JWTValidator

Comment on lines 125 to 127
func getVerifyContext(requestId: RPCID, domain: String) -> VerifyContext {
(try? verifyContextStore.get(key: requestId.string)) ?? verifyClient.createVerifyContext(origin: nil, domain: domain, isScam: false)
}
Copy link
Contributor

@jackpooleywc jackpooleywc Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this a bit easier to read.

Suggested change
func getVerifyContext(requestId: RPCID, domain: String) -> VerifyContext {
(try? verifyContextStore.get(key: requestId.string)) ?? verifyClient.createVerifyContext(origin: nil, domain: domain, isScam: false)
}
func getVerifyContext(requestId: RPCID, domain: String) -> VerifyContext {
guard let context = try? verifyContextStore.get(key: requestId.string) else {
return verifyClient.createVerifyContext(origin: nil, domain: domain, isScam: false)
}
return context
}

@@ -56,7 +56,14 @@ class AuthRequestSubscriber {
Task(priority: .high) {
let assertionId = payload.decryptedPayload.sha256().toHexString()
do {
let response = try await verifyClient.verifyOrigin(assertionId: assertionId)
let response: VerifyResponse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see warning: let assertionId = payload.decryptedPayload.sha256().toHexString() 👆

@@ -397,7 +401,14 @@ private extension ApproveEngine {
Task(priority: .high) {
let assertionId = payload.decryptedPayload.sha256().toHexString()
do {
let response = try await verifyClient.verifyOrigin(assertionId: assertionId)
let response: VerifyResponse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️


func fetchPublicKey() async throws -> VerifyServerPublicKey {
guard let url = URL(string: urlString) else {
throw NSError(domain: "", code: 0, userInfo: [NSLocalizedDescriptionKey: "Invalid URL"])
Copy link
Contributor

@jackpooleywc jackpooleywc Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just out of curiosity is there a reason we use an NSError here? What not use a custom type conforming to Error?

Copy link

@llbartekll llbartekll merged commit 8823b78 into develop Aug 13, 2024
6 checks passed
@llbartekll llbartekll deleted the verify-v2 branch August 13, 2024 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants