DVApiKeys constructor
DVApiKeys({
- required DVDatabaseAdapter database,
- required DVApiScopes scopes,
- bool requireExpiry = false,
- Duration defaultOverlap = const Duration(days: 7),
- DateTime clock()?,
- Random? random,
- DVLogger? logger,
Implementation
DVApiKeys({
required this.database,
required this.scopes,
this.requireExpiry = false,
this.defaultOverlap = const Duration(days: 7),
DateTime Function()? clock,
Random? random,
DVLogger? logger,
}) : _clock = clock ?? (() => DateTime.now().toUtc()),
_random = random ?? Random.secure(),
_logger = logger {
_keys = DVRecordTable(
table: 'dv_api_keys',
key: 'id',
columns: const <String>[
'id',
'secret_hash',
'name',
'tenant',
'scopes',
'rate_plan',
'created_by',
'created_at',
'expires_at',
'revoked_at',
'rotated_from',
'rotated_to',
],
types: const <String, String>{
'id': 'TEXT',
'secret_hash': 'TEXT',
'name': 'TEXT',
'tenant': 'TEXT',
'scopes': 'TEXT',
'rate_plan': 'TEXT',
'created_by': 'TEXT',
'created_at': 'TEXT',
'expires_at': 'TEXT',
'revoked_at': 'TEXT',
'rotated_from': 'TEXT',
'rotated_to': 'TEXT',
},
// History records that the hash was written, never the hash: a change
// log is a second copy of the table with a different lifetime.
sensitive: const <String>{'secret_hash'},
history: const DVHistory(),
database: database,
);
}