Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit aa4f0e8

Browse files
Tackle crash defensively in the case of an invalid signature to a keychain value (#35)
1 parent ae5bf3b commit aa4f0e8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/MagicSDK/Core/Relayer/Types/DPop.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ func createJwt() -> String?{
6262
let signingInput = headersB64 + "." + claimsB64
6363
let signingInputData = signingInput.data(using: .utf8)!
6464

65-
let signature = try! privateKey.signature(for: signingInputData)
65+
guard let signature = try? privateKey.signature(for: signingInputData) else {
66+
// 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
67+
return nil
68+
}
6669

6770
let signatureB64 = base64UrlEncoded(signature.rawRepresentation)
6871

0 commit comments

Comments
 (0)