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

feat: hide content of textarea with multiline keys #2816

Merged

Conversation

davidsoderberg
Copy link
Contributor

What change does this PR introduce?

Fix so private key in apns can be multiline

Screenshot 2023-02-17 at 08 20 17

Screenshot 2023-02-17 at 08 24 54

@linear
Copy link

linear bot commented Feb 17, 2023

NV-1529 🐛 Bug Report: APNS private key is not being parsed correctly

📜 Description

In APNS provider there is a field in order to set the private key. However, it seems that if someone copies the key and places it in that specific field, it's not getting parsed correctly and as a result, an error occurs when trying to send a notification.

{
"stack": "Error: Could not build push handler id: 638f1b1c79b266fa794fd3e5, error: VError: Failed to generate token: error:0909006C:PEM routines:get_name:no start line\n at PushFactory.getHandler (/usr/src/app/apps/api/dist/main.js:16142:19)\n at SendMessagePush. (/usr/src/app/apps/api/dist/main.js:16089:54)\n at Generator.next ()\n at fulfilled (/usr/src/app/apps/api/dist/main.js:15948:58)\n at runMicrotasks ()\n at processTicksAndRejections (node:internal/process/task_queues:96:5)",
"message": "Could not build push handler id: 638f1b1c79b266fa794fd3e5, error: VError: Failed to generate token: error:0909006C:PEM routines:get_name:no start line"
}

NOTE:
****The private key is being set correctly if you update the provider using the API /v1/integrations/{providerId} and manually set the key in the request body with a valid format.

👟 Reproduction steps

  1. Copy the APNS private key
  2. Enter it in the private key field
  3. Enter the other values (key id, team id) and activate the provider
  4. Send a push notification using APNS

👍 Expected behavior

Push notification should be sent.

👎 Actual Behavior with Screenshots

{
"stack": "Error: Could not build push handler id: 638f1b1c79b266fa794fd3e5, error: VError: Failed to generate token: error:0909006C:PEM routines:get_name:no start line\n at PushFactory.getHandler (/usr/src/app/apps/api/dist/main.js:16142:19)\n at SendMessagePush. (/usr/src/app/apps/api/dist/main.js:16089:54)\n at Generator.next ()\n at fulfilled (/usr/src/app/apps/api/dist/main.js:15948:58)\n at runMicrotasks ()\n at processTicksAndRejections (node:internal/process/task_queues:96:5)",
"message": "Could not build push handler id: 638f1b1c79b266fa794fd3e5, error: VError: Failed to generate token: error:0909006C:PEM routines:get_name:no start line"
}

The format of the key normally is the following:

-----BEGIN PRIVATE KEY-----
aaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbb
cccccccccccccccc
dddddddd
-----END PRIVATE KEY-----

After setting it in the dashboard like I described above, the /v1/integrations API returns:

-----BEGIN PRIVATE KEY----- aaaaaaaaaaaa bbbbbbbbbbbbbbbbbbb cccccccccccccccc dddddddd -----END PRIVATE KEY-----

It seems that it replaces the \n with whitespaces.

💻 Operating system

MacOS

🤖 Node Version

Using docker (ghcr.io/novuhq/novu/api:0.9.0) - I think Node 16

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

@@ -13,6 +14,10 @@ export function IntegrationInput({
register: any;
}) {
if (isNeededToHide(credential.key)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can refactor this to have the PasswordInput if statement not here, but rather on the "string" type input 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes lets create a tech debt for this 😄

@davidsoderberg davidsoderberg added this pull request to the merge queue Feb 17, 2023
Merged via the queue into next with commit ebf9627 Feb 17, 2023
@davidsoderberg davidsoderberg deleted the nv-1529-bug-report-apns-private-key-is-not-being branch February 17, 2023 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants