Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove new lines when parsing Apple certificate #139

Merged
merged 2 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changesets/gmm6h.patch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix: Remove new lines when parsing Apple certificate
15 changes: 10 additions & 5 deletions src/providers/apple.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TimeSpan, createDate } from "oslo";
import { decodeBase64 } from "oslo/encoding";
import { base64 } from "oslo/encoding";
import { createJWT } from "oslo/jwt";
import { OAuth2Client } from "oslo/oauth2";

Expand Down Expand Up @@ -113,10 +113,15 @@ export interface AppleCredentials {
}

function parsePKCS8PEM(pkcs8: string): Uint8Array {
return decodeBase64(
return base64.decode(
pkcs8
.replace(/-----BEGIN PRIVATE KEY-----/, "")
.replace(/-----END PRIVATE KEY-----/, "")
.trim()
.replace("-----BEGIN PRIVATE KEY-----", "")
.replace("-----END PRIVATE KEY-----", "")
.replaceAll("\r", "")
.replaceAll("\n", "")
.trim(),
{
strict: false
}
);
}
Loading