Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Tackle crash defensively in the case of an invalid signature to a key…
Browse files Browse the repository at this point in the history
…chain value (#35)
  • Loading branch information
tristan-warner-smith authored Feb 12, 2024
1 parent ae5bf3b commit aa4f0e8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/MagicSDK/Core/Relayer/Types/DPop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ func createJwt() -> String?{
let signingInput = headersB64 + "." + claimsB64
let signingInputData = signingInput.data(using: .utf8)!

let signature = try! privateKey.signature(for: signingInputData)
guard let signature = try? privateKey.signature(for: signingInputData) else {
// This can happen when the [secure enclave biometrics](https://developer.apple.com/forums/thread/682162?answerId=726099022#726099022) have changed such as when an app is auto-installed on a new device
return nil
}

let signatureB64 = base64UrlEncoded(signature.rawRepresentation)

Expand Down

0 comments on commit aa4f0e8

Please sign in to comment.