diff --git a/app/config/collections.php b/app/config/collections.php index e02e25829f..c2b450b353 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -4808,6 +4808,107 @@ $consoleCollections = array_merge([ ], ], + 'developmentKeys' => [ + '$collection' => ID::custom(Database::METADATA), + '$id' => ID::custom('developmentKeys'), + 'name' => 'keys', + 'attributes' => [ + [ + '$id' => ID::custom('projectInternalId'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('projectId'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => 0, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('name'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('secret'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 512, // var_dump of \bin2hex(\random_bytes(128)) => string(256) doubling for encryption + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => ['encrypt'], + ], + [ + '$id' => ID::custom('expire'), + 'type' => Database::VAR_DATETIME, + 'format' => '', + 'size' => 0, + 'signed' => false, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['datetime'], + ], + [ + '$id' => ID::custom('accessedAt'), + 'type' => Database::VAR_DATETIME, + 'format' => '', + 'size' => 0, + 'signed' => false, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['datetime'], + ], + [ + '$id' => ID::custom('sdks'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => true, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => ID::custom('_key_project'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectInternalId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => '_key_accessedAt', + 'type' => Database::INDEX_KEY, + 'attributes' => ['accessedAt'], + 'lengths' => [], + 'orders' => [], + ], + ], + ], + 'webhooks' => [ '$collection' => ID::custom(Database::METADATA), '$id' => ID::custom('webhooks'), diff --git a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Create.php b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Create.php index f8b4f75ea2..cb588d3696 100644 --- a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Create.php +++ b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Create.php @@ -69,7 +69,7 @@ class Create extends Action 'secret' => API_KEY_STANDARD . '_' . \bin2hex(\random_bytes(128)), ]); - $key = $dbForConsole->createDocument('development_keys', $key); + $key = $dbForConsole->createDocument('developmentKeys', $key); $dbForConsole->purgeCachedDocument('projects', $project->getId()); diff --git a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Delete.php b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Delete.php index a599b660d9..a1e0dad5b0 100644 --- a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Delete.php +++ b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Delete.php @@ -46,7 +46,7 @@ class Delete extends Action throw new Exception(Exception::PROJECT_NOT_FOUND); } - $key = $dbForConsole->findOne('development_keys', [ + $key = $dbForConsole->findOne('developmentKeys', [ Query::equal('$id', [$keyId]), Query::equal('projectInternalId', [$project->getInternalId()]), ]); diff --git a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Get.php b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Get.php index c8cf672b61..6f9f2d73b2 100644 --- a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Get.php +++ b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Get.php @@ -47,7 +47,7 @@ class Get extends Action throw new Exception(Exception::PROJECT_NOT_FOUND); } - $key = $dbForConsole->findOne('development_keys', [ + $key = $dbForConsole->findOne('developmentKeys', [ Query::equal('$id', [$keyId]), Query::equal('projectInternalId', [$project->getInternalId()]), ]); diff --git a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Update.php b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Update.php index da9d9c65b8..553f28b41a 100644 --- a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Update.php +++ b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/Update.php @@ -49,7 +49,7 @@ class Update extends Action throw new Exception(Exception::PROJECT_NOT_FOUND); } - $key = $dbForConsole->findOne('development_keys', [ + $key = $dbForConsole->findOne('developmentKeys', [ Query::equal('$id', [$keyId]), Query::equal('projectInternalId', [$project->getInternalId()]), ]); diff --git a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/XList.php b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/XList.php index 725ceda826..49605b0fdd 100644 --- a/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/XList.php +++ b/src/Appwrite/Platform/Modules/DevelopmentKeys/Http/XList.php @@ -47,7 +47,7 @@ class XList extends Action throw new Exception(Exception::PROJECT_NOT_FOUND); } - $keys = $dbForConsole->find('development_keys', [ + $keys = $dbForConsole->find('developmentKeys', [ Query::equal('projectInternalId', [$project->getInternalId()]), Query::limit(5000), ]);