Use the right public key representation for push subscriptions

This commit is contained in:
Shadowfacts 2024-04-09 11:48:53 -04:00
parent 7a47b09b39
commit 42a3f6c880
1 changed files with 4 additions and 1 deletions

View File

@ -67,7 +67,10 @@ struct PushInstanceSettingsView: View {
let subscription = try await PushManager.shared.createSubscription(account: account)
let req = Pachyderm.PushSubscription.create(
endpoint: pushProxyRegistration.endpoint,
publicKey: subscription.secretKey.publicKey.rawRepresentation,
// mastodon docs just say "Base64 encoded string of a public key from a ECDH keypair using the prime256v1 curve."
// other apps use SecKeyCopyExternalRepresentation which is documented to use X9.63 for elliptic curve keys
// and that seems to work
publicKey: subscription.secretKey.publicKey.x963Representation,
authSecret: subscription.authSecret,
alerts: .init(subscription.alerts),
policy: .init(subscription.policy)