X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Factivitypub%2Factor.ts;h=2f44522a5813979def3f09694ec5c7ce165bb920;hb=f2eb23cd87cf32b8fe545178143b5f49e06a58da;hp=ec4dd6f96a151c38983d43f507d0818bff6492b4;hpb=47581df0737ebcc058a5863143c752f9112a4424;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/activitypub/actor.ts b/server/helpers/custom-validators/activitypub/actor.ts index ec4dd6f96..2f44522a5 100644 --- a/server/helpers/custom-validators/activitypub/actor.ts +++ b/server/helpers/custom-validators/activitypub/actor.ts @@ -1,4 +1,4 @@ -import * as validator from 'validator' +import validator from 'validator' import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' import { exists, isArray } from '../misc' import { isActivityPubUrlValid, isBaseActivityValid, setValidAttributedTo } from './misc' @@ -6,7 +6,7 @@ import { isHostValid } from '../servers' import { peertubeTruncate } from '@server/helpers/core-utils' function isActorEndpointsObjectValid (endpointObject: any) { - if (endpointObject && endpointObject.sharedInbox) { + if (endpointObject?.sharedInbox) { return isActivityPubUrlValid(endpointObject.sharedInbox) } @@ -28,7 +28,7 @@ function isActorPublicKeyValid (publicKey: string) { return exists(publicKey) && typeof publicKey === 'string' && publicKey.startsWith('-----BEGIN PUBLIC KEY-----') && - publicKey.indexOf('-----END PUBLIC KEY-----') !== -1 && + publicKey.includes('-----END PUBLIC KEY-----') && validator.isLength(publicKey, CONSTRAINTS_FIELDS.ACTORS.PUBLIC_KEY) } @@ -43,7 +43,7 @@ function isActorPrivateKeyValid (privateKey: string) { typeof privateKey === 'string' && privateKey.startsWith('-----BEGIN RSA PRIVATE KEY-----') && // Sometimes there is a \n at the end, so just assert the string contains the end mark - privateKey.indexOf('-----END RSA PRIVATE KEY-----') !== -1 && + privateKey.includes('-----END RSA PRIVATE KEY-----') && validator.isLength(privateKey, CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY) } @@ -101,8 +101,6 @@ function normalizeActor (actor: any) { actor.summary = null } } - - return } function isValidActorHandle (handle: string) {