AtServerAtKeysIo constructor
AtServerAtKeysIo({
- required EnrollmentDocumentStore documents,
- required String atSign,
- required Future<
String> seal(), - required Future<
Map< open(String, dynamic> >- String record
- required String enrollmentId,
- required ApkamKeyPair apkamKeyPair,
- AtKeys? restored,
- Duration lockTtl = const Duration(seconds: 10),
- Duration lockWait = const Duration(seconds: 15),
The store of enrollmentId's document for atSign through documents,
sealed by seal and opened by open, holding apkamKeyPair; a
restored document is served by read without I/O. Each take of the
lock lasts lockTtl, and a write waits up to lockWait to take it,
counted from when the atServer has let this store's own last lock go.
Throws ArgumentError for a lockTtl under a millisecond or over
maxServerMutexTtl, or a lockWait that is not positive.
Implementation
AtServerAtKeysIo(
{required EnrollmentDocumentStore documents,
required String atSign,
required Future<String> Function(Map<String, dynamic> document) seal,
required Future<Map<String, dynamic>> Function(String record) open,
required String enrollmentId,
required ApkamKeyPair apkamKeyPair,
AtKeys? restored,
Duration lockTtl = const Duration(seconds: 10),
Duration lockWait = const Duration(seconds: 15)})
: _documents = documents,
_atSign = atSign.toAtsign(),
_seal = seal,
_open = open,
_enrollmentId = enrollmentId,
_lockTtl = checkedServerMutexTtl(lockTtl, 'lockTtl'),
_lockWait = lockWait > Duration.zero
? lockWait
: throw ArgumentError.value(
lockWait, 'lockWait', 'must be positive'),
_publicKey = apkamKeyPair.publicKey,
_private = base64Decode(apkamKeyPair.privateKey) {
final seed = restored;
if (seed != null && seed.atsign != null) {
_requireStoreAtsign(seed.atsign.toString());
_cache = jsonEncode(_stripped(seed));
}
}