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

fix(providers): validate and format APNs private key before use #7982

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

jainpawan21
Copy link
Member

What changed? Why was the change needed?

  • add validateAndFormatKey function for apns key

User key is in single line format and novu is throwing this error:

{
  "jse_shortmsg": "Failed to generate token",
  "jse_cause": {},
  "jse_info": {},
  "message": "Failed to generate token: secretOrPrivateKey must be an asymmetric key when using ES256"
}

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

linear bot commented Mar 24, 2025

@jainpawan21 jainpawan21 changed the title fix(apns): validate and format APNs private key before use fix(providers): validate and format APNs private key before use Mar 24, 2025

const formattedKey = cleanKey.match(/.{1,64}/g)?.join('\n') || '';

return `-----BEGIN PRIVATE KEY-----\n${formattedKey}\n-----END PRIVATE KEY-----`;
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed offline, we will add a validation error during the creation of APN integration so that users are informed proactively about invalid integration properties.

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