keyType = $type; return $this; } /** * Create a new API key for the Panel using the permissions passed in the data request. * This will automatically generate an identifier and an encrypted token that are * stored in the database. * * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ public function handle(array $data, array $permissions = []): ApiKey { $data = array_merge($data, [ 'key_type' => $this->keyType, 'identifier' => ApiKey::generateTokenIdentifier($this->keyType), 'token' => $this->encrypter->encrypt(str_random(ApiKey::KEY_LENGTH)), ]); if ($this->keyType === ApiKey::TYPE_APPLICATION) { $data = array_merge($data, $permissions); } return $this->repository->create($data, true, true); } }