]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/activitypub/actor.ts
Feature/filter already watched videos (#5739)
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / activitypub / actor.ts
index 675a7b66324e2d40781dde86faaf126768b76cf2..f43c35b239d22031f5b53d8756eaba89edda04de 100644 (file)
@@ -41,9 +41,9 @@ function isActorPreferredUsernameValid (preferredUsername: string) {
 function isActorPrivateKeyValid (privateKey: string) {
   return exists(privateKey) &&
     typeof privateKey === 'string' &&
-    privateKey.startsWith('-----BEGIN RSA PRIVATE KEY-----') &&
+    (privateKey.startsWith('-----BEGIN RSA PRIVATE KEY-----') || privateKey.startsWith('-----BEGIN PRIVATE KEY-----')) &&
     // Sometimes there is a \n at the end, so just assert the string contains the end mark
-    privateKey.includes('-----END RSA PRIVATE KEY-----') &&
+    (privateKey.includes('-----END RSA PRIVATE KEY-----') || privateKey.includes('-----END PRIVATE KEY-----')) &&
     validator.isLength(privateKey, CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY)
 }
 
@@ -60,11 +60,12 @@ function isActorDeleteActivityValid (activity: any) {
 }
 
 function sanitizeAndCheckActorObject (actor: any) {
+  if (!isActorTypeValid(actor.type)) return false
+
   normalizeActor(actor)
 
   return exists(actor) &&
     isActivityPubUrlValid(actor.id) &&
-    isActorTypeValid(actor.type) &&
     isActivityPubUrlValid(actor.inbox) &&
     isActorPreferredUsernameValid(actor.preferredUsername) &&
     isActivityPubUrlValid(actor.url) &&