anchor.diff:      ]);
     }
   
  -  Future<void> _checkUploadAuthorization(
  -      AuthenticatedAgent agent, Package package, String newVersion) async {
  +  /// Throws a [ResponseException] if [agent] is **not** authorized to upload package.
  +  ///
  +  /// If [package] is null, this is an attempt to publish a new package, not a new version to an existing package.
  +  /// If [package] is not null, this is an attempt to publish [newVersion] of existing package.
  +  Future<void> _requireUploadAuthorization(
  +      AuthenticatedAgent agent, Package? package, String newVersion) async {
  +    // new package
  +    if (package == null) {
  +      if (agent is AuthenticatedUser) {
  +        return;
  +      }
  +      throw PackageRejectedException.onlyUsersAreAllowedToUploadNewPackages();
  +    }
  +
  +    // existing package
  +    if (package.isNotVisible) {
  +      throw PackageRejectedException.isBlocked();
  +    }
       if (agent is AuthenticatedUser &&
           await packageBackend.isPackageAdmin(package, agent.user.userId)) {
         return;
  
positive.code:     final sw = Stopwatch()..start();
      final newVersion = entities.packageVersion;
      final currentDartSdk = await getDartSdkVersion();
  
      // query admin notification emails before the transaction starts
      final existingPackage = await lookupPackage(newVersion.package);
      List<String> uploaderEmails;
      if (existingPackage == null) {
        if (agent is AuthenticatedUser) {
          uploaderEmails = [agent.email!];
        } else {
          throw PackageRejectedException.onlyUsersAreAllowedToUploadNewPackages();
        }
      } else {
        uploaderEmails =
  
negative.code:             version.package, version.version!);
        }
  
        // If the package does not exist, then we create a new package.
        if (package == null) {
          _logger.info('New package uploaded. [new-package-uploaded]');
          package = Package.fromVersion(newVersion);
        }
  
        if (package!.versionCount >= maxVersionsPerPackage) {
  