add collection for development keys

This commit is contained in:
Damodar Lohani 2024-07-16 07:50:42 +00:00
parent af3dc25e2c
commit 03000c3ad0
6 changed files with 106 additions and 5 deletions

View file

@ -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'),

View file

@ -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());

View file

@ -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()]),
]);

View file

@ -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()]),
]);

View file

@ -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()]),
]);

View file

@ -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),
]);