✨ Key pairs
This commit is contained in:
parent
64e2644745
commit
cb2de52bee
@ -753,5 +753,11 @@
|
|||||||
"accountBadges": "Badges",
|
"accountBadges": "Badges",
|
||||||
"accountBadgesDescription": "View and manage your badges.",
|
"accountBadgesDescription": "View and manage your badges.",
|
||||||
"badgeActivated": "Activated badge {}.",
|
"badgeActivated": "Activated badge {}.",
|
||||||
"viewDetailedAttachment": "Details"
|
"viewDetailedAttachment": "Details",
|
||||||
|
"screenKeyPairs": "Key Pairs",
|
||||||
|
"accountKeyPairs": "Key Pairs",
|
||||||
|
"accountKeyPairsDescription": "Manage the key pairs which used to encrypt messages.",
|
||||||
|
"enrollNewKeyPair": "Enroll New One",
|
||||||
|
"enrollNewKeyPairDescription": "Generate a new key pair.",
|
||||||
|
"keyPairHasPrivateKey": "With private key"
|
||||||
}
|
}
|
||||||
|
@ -751,5 +751,11 @@
|
|||||||
"accountBadges": "徽章",
|
"accountBadges": "徽章",
|
||||||
"accountBadgesDescription": "查看并管理你的徽章。",
|
"accountBadgesDescription": "查看并管理你的徽章。",
|
||||||
"badgeActivated": "已佩戴徽章 {}。",
|
"badgeActivated": "已佩戴徽章 {}。",
|
||||||
"viewDetailedAttachment": "查看附件详情"
|
"viewDetailedAttachment": "查看附件详情",
|
||||||
|
"screenKeyPairs": "密钥对",
|
||||||
|
"accountKeyPairs": "密钥对",
|
||||||
|
"accountKeyPairsDescription": "管理用于加密信息的密钥对。",
|
||||||
|
"enrollNewKeyPair": "新建密钥对",
|
||||||
|
"enrollNewKeyPairDescription": "生成一对新密钥对。",
|
||||||
|
"keyPairHasPrivateKey": "有私钥"
|
||||||
}
|
}
|
||||||
|
@ -751,5 +751,11 @@
|
|||||||
"accountBadges": "徽章",
|
"accountBadges": "徽章",
|
||||||
"accountBadgesDescription": "查看並管理你的徽章。",
|
"accountBadgesDescription": "查看並管理你的徽章。",
|
||||||
"badgeActivated": "已佩戴徽章 {}。",
|
"badgeActivated": "已佩戴徽章 {}。",
|
||||||
"viewDetailedAttachment": "查看附件詳情"
|
"viewDetailedAttachment": "查看附件詳情",
|
||||||
|
"screenKeyPairs": "密鑰對",
|
||||||
|
"accountKeyPairs": "密鑰對",
|
||||||
|
"accountKeyPairsDescription": "管理用於加密信息的密鑰對。",
|
||||||
|
"enrollNewKeyPair": "新建密鑰對",
|
||||||
|
"enrollNewKeyPairDescription": "生成一對新密鑰對,覆蓋當前的;如果已有一個密鑰將會丟棄舊密鑰的私鑰。",
|
||||||
|
"keyPairHasPrivateKey": "有私鑰"
|
||||||
}
|
}
|
||||||
|
@ -751,5 +751,11 @@
|
|||||||
"accountBadges": "徽章",
|
"accountBadges": "徽章",
|
||||||
"accountBadgesDescription": "查看並管理你的徽章。",
|
"accountBadgesDescription": "查看並管理你的徽章。",
|
||||||
"badgeActivated": "已佩戴徽章 {}。",
|
"badgeActivated": "已佩戴徽章 {}。",
|
||||||
"viewDetailedAttachment": "查看附件詳情"
|
"viewDetailedAttachment": "查看附件詳情",
|
||||||
|
"screenKeyPairs": "密鑰對",
|
||||||
|
"accountKeyPairs": "密鑰對",
|
||||||
|
"accountKeyPairsDescription": "管理用於加密信息的密鑰對。",
|
||||||
|
"enrollNewKeyPair": "新建密鑰對",
|
||||||
|
"enrollNewKeyPairDescription": "生成一對新密鑰對,覆蓋當前的;如果已有一個密鑰將會丟棄舊密鑰的私鑰。",
|
||||||
|
"keyPairHasPrivateKey": "有私鑰"
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
{"_meta":{"description":"This file contains a serialized version of schema entities for drift.","version":"1.2.0"},"options":{"store_date_time_values_as_text":false},"entities":[{"id":0,"references":[],"type":"table","data":{"name":"sn_local_chat_channel","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"alias","getter_name":"alias","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"content","getter_name":"content","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const SnChannelConverter()","dart_type_name":"SnChannel"}},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CAST(strftime(\\'%s\\', CURRENT_TIMESTAMP) AS INTEGER)')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":1,"references":[],"type":"table","data":{"name":"sn_local_chat_message","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"channel_id","getter_name":"channelId","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"content","getter_name":"content","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const SnMessageConverter()","dart_type_name":"SnChatMessage"}},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CAST(strftime(\\'%s\\', CURRENT_TIMESTAMP) AS INTEGER)')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":2,"references":[],"type":"table","data":{"name":"sn_local_key_pair","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"account_id","getter_name":"accountId","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"public_key","getter_name":"publicKey","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"private_key","getter_name":"privateKey","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}}]}
|
{"_meta":{"description":"This file contains a serialized version of schema entities for drift.","version":"1.2.0"},"options":{"store_date_time_values_as_text":false},"entities":[{"id":0,"references":[],"type":"table","data":{"name":"sn_local_chat_channel","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"alias","getter_name":"alias","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"content","getter_name":"content","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const SnChannelConverter()","dart_type_name":"SnChannel"}},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CAST(strftime(\\'%s\\', CURRENT_TIMESTAMP) AS INTEGER)')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":1,"references":[],"type":"table","data":{"name":"sn_local_chat_message","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"int","nullable":false,"customConstraints":null,"defaultConstraints":"PRIMARY KEY AUTOINCREMENT","dialectAwareDefaultConstraints":{"sqlite":"PRIMARY KEY AUTOINCREMENT"},"default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"channel_id","getter_name":"channelId","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"content","getter_name":"content","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const SnMessageConverter()","dart_type_name":"SnChatMessage"}},{"name":"created_at","getter_name":"createdAt","moor_type":"dateTime","nullable":false,"customConstraints":null,"default_dart":"const CustomExpression('CAST(strftime(\\'%s\\', CURRENT_TIMESTAMP) AS INTEGER)')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":2,"references":[],"type":"table","data":{"name":"sn_local_key_pair","was_declared_in_moor":false,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"account_id","getter_name":"accountId","moor_type":"int","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"public_key","getter_name":"publicKey","moor_type":"string","nullable":false,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"private_key","getter_name":"privateKey","moor_type":"string","nullable":true,"customConstraints":null,"default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"is_active","getter_name":"isActive","moor_type":"bool","nullable":false,"customConstraints":null,"defaultConstraints":"CHECK (\"is_active\" IN (0, 1))","dialectAwareDefaultConstraints":{"sqlite":"CHECK (\"is_active\" IN (0, 1))"},"default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}}]}
|
@ -567,8 +567,19 @@ class $SnLocalKeyPairTable extends SnLocalKeyPair
|
|||||||
late final GeneratedColumn<String> privateKey = GeneratedColumn<String>(
|
late final GeneratedColumn<String> privateKey = GeneratedColumn<String>(
|
||||||
'private_key', aliasedName, true,
|
'private_key', aliasedName, true,
|
||||||
type: DriftSqlType.string, requiredDuringInsert: false);
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
||||||
|
static const VerificationMeta _isActiveMeta =
|
||||||
|
const VerificationMeta('isActive');
|
||||||
@override
|
@override
|
||||||
List<GeneratedColumn> get $columns => [id, accountId, publicKey, privateKey];
|
late final GeneratedColumn<bool> isActive = GeneratedColumn<bool>(
|
||||||
|
'is_active', aliasedName, false,
|
||||||
|
type: DriftSqlType.bool,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultConstraints:
|
||||||
|
GeneratedColumn.constraintIsAlways('CHECK ("is_active" IN (0, 1))'),
|
||||||
|
defaultValue: Constant(false));
|
||||||
|
@override
|
||||||
|
List<GeneratedColumn> get $columns =>
|
||||||
|
[id, accountId, publicKey, privateKey, isActive];
|
||||||
@override
|
@override
|
||||||
String get aliasedName => _alias ?? actualTableName;
|
String get aliasedName => _alias ?? actualTableName;
|
||||||
@override
|
@override
|
||||||
@ -602,6 +613,10 @@ class $SnLocalKeyPairTable extends SnLocalKeyPair
|
|||||||
privateKey.isAcceptableOrUnknown(
|
privateKey.isAcceptableOrUnknown(
|
||||||
data['private_key']!, _privateKeyMeta));
|
data['private_key']!, _privateKeyMeta));
|
||||||
}
|
}
|
||||||
|
if (data.containsKey('is_active')) {
|
||||||
|
context.handle(_isActiveMeta,
|
||||||
|
isActive.isAcceptableOrUnknown(data['is_active']!, _isActiveMeta));
|
||||||
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,6 +634,8 @@ class $SnLocalKeyPairTable extends SnLocalKeyPair
|
|||||||
.read(DriftSqlType.string, data['${effectivePrefix}public_key'])!,
|
.read(DriftSqlType.string, data['${effectivePrefix}public_key'])!,
|
||||||
privateKey: attachedDatabase.typeMapping
|
privateKey: attachedDatabase.typeMapping
|
||||||
.read(DriftSqlType.string, data['${effectivePrefix}private_key']),
|
.read(DriftSqlType.string, data['${effectivePrefix}private_key']),
|
||||||
|
isActive: attachedDatabase.typeMapping
|
||||||
|
.read(DriftSqlType.bool, data['${effectivePrefix}is_active'])!,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,11 +651,13 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
final int accountId;
|
final int accountId;
|
||||||
final String publicKey;
|
final String publicKey;
|
||||||
final String? privateKey;
|
final String? privateKey;
|
||||||
|
final bool isActive;
|
||||||
const SnLocalKeyPairData(
|
const SnLocalKeyPairData(
|
||||||
{required this.id,
|
{required this.id,
|
||||||
required this.accountId,
|
required this.accountId,
|
||||||
required this.publicKey,
|
required this.publicKey,
|
||||||
this.privateKey});
|
this.privateKey,
|
||||||
|
required this.isActive});
|
||||||
@override
|
@override
|
||||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
final map = <String, Expression>{};
|
final map = <String, Expression>{};
|
||||||
@ -648,6 +667,7 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
if (!nullToAbsent || privateKey != null) {
|
if (!nullToAbsent || privateKey != null) {
|
||||||
map['private_key'] = Variable<String>(privateKey);
|
map['private_key'] = Variable<String>(privateKey);
|
||||||
}
|
}
|
||||||
|
map['is_active'] = Variable<bool>(isActive);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,6 +679,7 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
privateKey: privateKey == null && nullToAbsent
|
privateKey: privateKey == null && nullToAbsent
|
||||||
? const Value.absent()
|
? const Value.absent()
|
||||||
: Value(privateKey),
|
: Value(privateKey),
|
||||||
|
isActive: Value(isActive),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,6 +691,7 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
accountId: serializer.fromJson<int>(json['accountId']),
|
accountId: serializer.fromJson<int>(json['accountId']),
|
||||||
publicKey: serializer.fromJson<String>(json['publicKey']),
|
publicKey: serializer.fromJson<String>(json['publicKey']),
|
||||||
privateKey: serializer.fromJson<String?>(json['privateKey']),
|
privateKey: serializer.fromJson<String?>(json['privateKey']),
|
||||||
|
isActive: serializer.fromJson<bool>(json['isActive']),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@override
|
@override
|
||||||
@ -680,6 +702,7 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
'accountId': serializer.toJson<int>(accountId),
|
'accountId': serializer.toJson<int>(accountId),
|
||||||
'publicKey': serializer.toJson<String>(publicKey),
|
'publicKey': serializer.toJson<String>(publicKey),
|
||||||
'privateKey': serializer.toJson<String?>(privateKey),
|
'privateKey': serializer.toJson<String?>(privateKey),
|
||||||
|
'isActive': serializer.toJson<bool>(isActive),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,12 +710,14 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
{String? id,
|
{String? id,
|
||||||
int? accountId,
|
int? accountId,
|
||||||
String? publicKey,
|
String? publicKey,
|
||||||
Value<String?> privateKey = const Value.absent()}) =>
|
Value<String?> privateKey = const Value.absent(),
|
||||||
|
bool? isActive}) =>
|
||||||
SnLocalKeyPairData(
|
SnLocalKeyPairData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
accountId: accountId ?? this.accountId,
|
accountId: accountId ?? this.accountId,
|
||||||
publicKey: publicKey ?? this.publicKey,
|
publicKey: publicKey ?? this.publicKey,
|
||||||
privateKey: privateKey.present ? privateKey.value : this.privateKey,
|
privateKey: privateKey.present ? privateKey.value : this.privateKey,
|
||||||
|
isActive: isActive ?? this.isActive,
|
||||||
);
|
);
|
||||||
SnLocalKeyPairData copyWithCompanion(SnLocalKeyPairCompanion data) {
|
SnLocalKeyPairData copyWithCompanion(SnLocalKeyPairCompanion data) {
|
||||||
return SnLocalKeyPairData(
|
return SnLocalKeyPairData(
|
||||||
@ -701,6 +726,7 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
publicKey: data.publicKey.present ? data.publicKey.value : this.publicKey,
|
publicKey: data.publicKey.present ? data.publicKey.value : this.publicKey,
|
||||||
privateKey:
|
privateKey:
|
||||||
data.privateKey.present ? data.privateKey.value : this.privateKey,
|
data.privateKey.present ? data.privateKey.value : this.privateKey,
|
||||||
|
isActive: data.isActive.present ? data.isActive.value : this.isActive,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,13 +736,15 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
..write('id: $id, ')
|
..write('id: $id, ')
|
||||||
..write('accountId: $accountId, ')
|
..write('accountId: $accountId, ')
|
||||||
..write('publicKey: $publicKey, ')
|
..write('publicKey: $publicKey, ')
|
||||||
..write('privateKey: $privateKey')
|
..write('privateKey: $privateKey, ')
|
||||||
|
..write('isActive: $isActive')
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(id, accountId, publicKey, privateKey);
|
int get hashCode =>
|
||||||
|
Object.hash(id, accountId, publicKey, privateKey, isActive);
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
identical(this, other) ||
|
identical(this, other) ||
|
||||||
@ -724,7 +752,8 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
other.id == this.id &&
|
other.id == this.id &&
|
||||||
other.accountId == this.accountId &&
|
other.accountId == this.accountId &&
|
||||||
other.publicKey == this.publicKey &&
|
other.publicKey == this.publicKey &&
|
||||||
other.privateKey == this.privateKey);
|
other.privateKey == this.privateKey &&
|
||||||
|
other.isActive == this.isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
||||||
@ -732,12 +761,14 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
final Value<int> accountId;
|
final Value<int> accountId;
|
||||||
final Value<String> publicKey;
|
final Value<String> publicKey;
|
||||||
final Value<String?> privateKey;
|
final Value<String?> privateKey;
|
||||||
|
final Value<bool> isActive;
|
||||||
final Value<int> rowid;
|
final Value<int> rowid;
|
||||||
const SnLocalKeyPairCompanion({
|
const SnLocalKeyPairCompanion({
|
||||||
this.id = const Value.absent(),
|
this.id = const Value.absent(),
|
||||||
this.accountId = const Value.absent(),
|
this.accountId = const Value.absent(),
|
||||||
this.publicKey = const Value.absent(),
|
this.publicKey = const Value.absent(),
|
||||||
this.privateKey = const Value.absent(),
|
this.privateKey = const Value.absent(),
|
||||||
|
this.isActive = const Value.absent(),
|
||||||
this.rowid = const Value.absent(),
|
this.rowid = const Value.absent(),
|
||||||
});
|
});
|
||||||
SnLocalKeyPairCompanion.insert({
|
SnLocalKeyPairCompanion.insert({
|
||||||
@ -745,6 +776,7 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
required int accountId,
|
required int accountId,
|
||||||
required String publicKey,
|
required String publicKey,
|
||||||
this.privateKey = const Value.absent(),
|
this.privateKey = const Value.absent(),
|
||||||
|
this.isActive = const Value.absent(),
|
||||||
this.rowid = const Value.absent(),
|
this.rowid = const Value.absent(),
|
||||||
}) : id = Value(id),
|
}) : id = Value(id),
|
||||||
accountId = Value(accountId),
|
accountId = Value(accountId),
|
||||||
@ -754,6 +786,7 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
Expression<int>? accountId,
|
Expression<int>? accountId,
|
||||||
Expression<String>? publicKey,
|
Expression<String>? publicKey,
|
||||||
Expression<String>? privateKey,
|
Expression<String>? privateKey,
|
||||||
|
Expression<bool>? isActive,
|
||||||
Expression<int>? rowid,
|
Expression<int>? rowid,
|
||||||
}) {
|
}) {
|
||||||
return RawValuesInsertable({
|
return RawValuesInsertable({
|
||||||
@ -761,6 +794,7 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
if (accountId != null) 'account_id': accountId,
|
if (accountId != null) 'account_id': accountId,
|
||||||
if (publicKey != null) 'public_key': publicKey,
|
if (publicKey != null) 'public_key': publicKey,
|
||||||
if (privateKey != null) 'private_key': privateKey,
|
if (privateKey != null) 'private_key': privateKey,
|
||||||
|
if (isActive != null) 'is_active': isActive,
|
||||||
if (rowid != null) 'rowid': rowid,
|
if (rowid != null) 'rowid': rowid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -770,12 +804,14 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
Value<int>? accountId,
|
Value<int>? accountId,
|
||||||
Value<String>? publicKey,
|
Value<String>? publicKey,
|
||||||
Value<String?>? privateKey,
|
Value<String?>? privateKey,
|
||||||
|
Value<bool>? isActive,
|
||||||
Value<int>? rowid}) {
|
Value<int>? rowid}) {
|
||||||
return SnLocalKeyPairCompanion(
|
return SnLocalKeyPairCompanion(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
accountId: accountId ?? this.accountId,
|
accountId: accountId ?? this.accountId,
|
||||||
publicKey: publicKey ?? this.publicKey,
|
publicKey: publicKey ?? this.publicKey,
|
||||||
privateKey: privateKey ?? this.privateKey,
|
privateKey: privateKey ?? this.privateKey,
|
||||||
|
isActive: isActive ?? this.isActive,
|
||||||
rowid: rowid ?? this.rowid,
|
rowid: rowid ?? this.rowid,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -795,6 +831,9 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
if (privateKey.present) {
|
if (privateKey.present) {
|
||||||
map['private_key'] = Variable<String>(privateKey.value);
|
map['private_key'] = Variable<String>(privateKey.value);
|
||||||
}
|
}
|
||||||
|
if (isActive.present) {
|
||||||
|
map['is_active'] = Variable<bool>(isActive.value);
|
||||||
|
}
|
||||||
if (rowid.present) {
|
if (rowid.present) {
|
||||||
map['rowid'] = Variable<int>(rowid.value);
|
map['rowid'] = Variable<int>(rowid.value);
|
||||||
}
|
}
|
||||||
@ -808,6 +847,7 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
..write('accountId: $accountId, ')
|
..write('accountId: $accountId, ')
|
||||||
..write('publicKey: $publicKey, ')
|
..write('publicKey: $publicKey, ')
|
||||||
..write('privateKey: $privateKey, ')
|
..write('privateKey: $privateKey, ')
|
||||||
|
..write('isActive: $isActive, ')
|
||||||
..write('rowid: $rowid')
|
..write('rowid: $rowid')
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
@ -1152,6 +1192,7 @@ typedef $$SnLocalKeyPairTableCreateCompanionBuilder = SnLocalKeyPairCompanion
|
|||||||
required int accountId,
|
required int accountId,
|
||||||
required String publicKey,
|
required String publicKey,
|
||||||
Value<String?> privateKey,
|
Value<String?> privateKey,
|
||||||
|
Value<bool> isActive,
|
||||||
Value<int> rowid,
|
Value<int> rowid,
|
||||||
});
|
});
|
||||||
typedef $$SnLocalKeyPairTableUpdateCompanionBuilder = SnLocalKeyPairCompanion
|
typedef $$SnLocalKeyPairTableUpdateCompanionBuilder = SnLocalKeyPairCompanion
|
||||||
@ -1160,6 +1201,7 @@ typedef $$SnLocalKeyPairTableUpdateCompanionBuilder = SnLocalKeyPairCompanion
|
|||||||
Value<int> accountId,
|
Value<int> accountId,
|
||||||
Value<String> publicKey,
|
Value<String> publicKey,
|
||||||
Value<String?> privateKey,
|
Value<String?> privateKey,
|
||||||
|
Value<bool> isActive,
|
||||||
Value<int> rowid,
|
Value<int> rowid,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1183,6 +1225,9 @@ class $$SnLocalKeyPairTableFilterComposer
|
|||||||
|
|
||||||
ColumnFilters<String> get privateKey => $composableBuilder(
|
ColumnFilters<String> get privateKey => $composableBuilder(
|
||||||
column: $table.privateKey, builder: (column) => ColumnFilters(column));
|
column: $table.privateKey, builder: (column) => ColumnFilters(column));
|
||||||
|
|
||||||
|
ColumnFilters<bool> get isActive => $composableBuilder(
|
||||||
|
column: $table.isActive, builder: (column) => ColumnFilters(column));
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$SnLocalKeyPairTableOrderingComposer
|
class $$SnLocalKeyPairTableOrderingComposer
|
||||||
@ -1205,6 +1250,9 @@ class $$SnLocalKeyPairTableOrderingComposer
|
|||||||
|
|
||||||
ColumnOrderings<String> get privateKey => $composableBuilder(
|
ColumnOrderings<String> get privateKey => $composableBuilder(
|
||||||
column: $table.privateKey, builder: (column) => ColumnOrderings(column));
|
column: $table.privateKey, builder: (column) => ColumnOrderings(column));
|
||||||
|
|
||||||
|
ColumnOrderings<bool> get isActive => $composableBuilder(
|
||||||
|
column: $table.isActive, builder: (column) => ColumnOrderings(column));
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$SnLocalKeyPairTableAnnotationComposer
|
class $$SnLocalKeyPairTableAnnotationComposer
|
||||||
@ -1227,6 +1275,9 @@ class $$SnLocalKeyPairTableAnnotationComposer
|
|||||||
|
|
||||||
GeneratedColumn<String> get privateKey => $composableBuilder(
|
GeneratedColumn<String> get privateKey => $composableBuilder(
|
||||||
column: $table.privateKey, builder: (column) => column);
|
column: $table.privateKey, builder: (column) => column);
|
||||||
|
|
||||||
|
GeneratedColumn<bool> get isActive =>
|
||||||
|
$composableBuilder(column: $table.isActive, builder: (column) => column);
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$SnLocalKeyPairTableTableManager extends RootTableManager<
|
class $$SnLocalKeyPairTableTableManager extends RootTableManager<
|
||||||
@ -1260,6 +1311,7 @@ class $$SnLocalKeyPairTableTableManager extends RootTableManager<
|
|||||||
Value<int> accountId = const Value.absent(),
|
Value<int> accountId = const Value.absent(),
|
||||||
Value<String> publicKey = const Value.absent(),
|
Value<String> publicKey = const Value.absent(),
|
||||||
Value<String?> privateKey = const Value.absent(),
|
Value<String?> privateKey = const Value.absent(),
|
||||||
|
Value<bool> isActive = const Value.absent(),
|
||||||
Value<int> rowid = const Value.absent(),
|
Value<int> rowid = const Value.absent(),
|
||||||
}) =>
|
}) =>
|
||||||
SnLocalKeyPairCompanion(
|
SnLocalKeyPairCompanion(
|
||||||
@ -1267,6 +1319,7 @@ class $$SnLocalKeyPairTableTableManager extends RootTableManager<
|
|||||||
accountId: accountId,
|
accountId: accountId,
|
||||||
publicKey: publicKey,
|
publicKey: publicKey,
|
||||||
privateKey: privateKey,
|
privateKey: privateKey,
|
||||||
|
isActive: isActive,
|
||||||
rowid: rowid,
|
rowid: rowid,
|
||||||
),
|
),
|
||||||
createCompanionCallback: ({
|
createCompanionCallback: ({
|
||||||
@ -1274,6 +1327,7 @@ class $$SnLocalKeyPairTableTableManager extends RootTableManager<
|
|||||||
required int accountId,
|
required int accountId,
|
||||||
required String publicKey,
|
required String publicKey,
|
||||||
Value<String?> privateKey = const Value.absent(),
|
Value<String?> privateKey = const Value.absent(),
|
||||||
|
Value<bool> isActive = const Value.absent(),
|
||||||
Value<int> rowid = const Value.absent(),
|
Value<int> rowid = const Value.absent(),
|
||||||
}) =>
|
}) =>
|
||||||
SnLocalKeyPairCompanion.insert(
|
SnLocalKeyPairCompanion.insert(
|
||||||
@ -1281,6 +1335,7 @@ class $$SnLocalKeyPairTableTableManager extends RootTableManager<
|
|||||||
accountId: accountId,
|
accountId: accountId,
|
||||||
publicKey: publicKey,
|
publicKey: publicKey,
|
||||||
privateKey: privateKey,
|
privateKey: privateKey,
|
||||||
|
isActive: isActive,
|
||||||
rowid: rowid,
|
rowid: rowid,
|
||||||
),
|
),
|
||||||
withReferenceMapper: (p0) => p0
|
withReferenceMapper: (p0) => p0
|
||||||
|
@ -53,6 +53,7 @@ final class Schema2 extends i0.VersionedSchema {
|
|||||||
_column_6,
|
_column_6,
|
||||||
_column_7,
|
_column_7,
|
||||||
_column_8,
|
_column_8,
|
||||||
|
_column_9,
|
||||||
],
|
],
|
||||||
attachedDatabase: database,
|
attachedDatabase: database,
|
||||||
),
|
),
|
||||||
@ -115,6 +116,8 @@ class Shape2 extends i0.VersionedTable {
|
|||||||
columnsByName['public_key']! as i1.GeneratedColumn<String>;
|
columnsByName['public_key']! as i1.GeneratedColumn<String>;
|
||||||
i1.GeneratedColumn<String> get privateKey =>
|
i1.GeneratedColumn<String> get privateKey =>
|
||||||
columnsByName['private_key']! as i1.GeneratedColumn<String>;
|
columnsByName['private_key']! as i1.GeneratedColumn<String>;
|
||||||
|
i1.GeneratedColumn<bool> get isActive =>
|
||||||
|
columnsByName['is_active']! as i1.GeneratedColumn<bool>;
|
||||||
}
|
}
|
||||||
|
|
||||||
i1.GeneratedColumn<String> _column_5(String aliasedName) =>
|
i1.GeneratedColumn<String> _column_5(String aliasedName) =>
|
||||||
@ -129,6 +132,12 @@ i1.GeneratedColumn<String> _column_7(String aliasedName) =>
|
|||||||
i1.GeneratedColumn<String> _column_8(String aliasedName) =>
|
i1.GeneratedColumn<String> _column_8(String aliasedName) =>
|
||||||
i1.GeneratedColumn<String>('private_key', aliasedName, true,
|
i1.GeneratedColumn<String>('private_key', aliasedName, true,
|
||||||
type: i1.DriftSqlType.string);
|
type: i1.DriftSqlType.string);
|
||||||
|
i1.GeneratedColumn<bool> _column_9(String aliasedName) =>
|
||||||
|
i1.GeneratedColumn<bool>('is_active', aliasedName, false,
|
||||||
|
type: i1.DriftSqlType.bool,
|
||||||
|
defaultConstraints: i1.GeneratedColumn.constraintIsAlways(
|
||||||
|
'CHECK ("is_active" IN (0, 1))'),
|
||||||
|
defaultValue: const CustomExpression('0'));
|
||||||
i0.MigrationStepWithVersion migrationSteps({
|
i0.MigrationStepWithVersion migrationSteps({
|
||||||
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
|
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
|
||||||
}) {
|
}) {
|
||||||
|
@ -8,4 +8,6 @@ class SnLocalKeyPair extends Table {
|
|||||||
TextColumn get publicKey => text()();
|
TextColumn get publicKey => text()();
|
||||||
|
|
||||||
TextColumn get privateKey => text().nullable()();
|
TextColumn get privateKey => text().nullable()();
|
||||||
|
|
||||||
|
BoolColumn get isActive => boolean().withDefault(Constant(false))();
|
||||||
}
|
}
|
||||||
|
@ -309,6 +309,7 @@ class _AppSplashScreenState extends State<_AppSplashScreen> with TrayListener {
|
|||||||
await notify.registerPushNotifications();
|
await notify.registerPushNotifications();
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
final kp = context.read<KeyPairProvider>();
|
final kp = context.read<KeyPairProvider>();
|
||||||
|
await kp.reloadActive();
|
||||||
kp.listen();
|
kp.listen();
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
final sticker = context.read<SnStickerProvider>();
|
final sticker = context.read<SnStickerProvider>();
|
||||||
|
@ -27,8 +27,6 @@ class KeyPairProvider {
|
|||||||
_dt = context.read<DatabaseProvider>();
|
_dt = context.read<DatabaseProvider>();
|
||||||
_ua = context.read<UserProvider>();
|
_ua = context.read<UserProvider>();
|
||||||
_ws = context.read<WebSocketProvider>();
|
_ws = context.read<WebSocketProvider>();
|
||||||
|
|
||||||
reloadActive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void listen() {
|
void listen() {
|
||||||
@ -150,6 +148,7 @@ class KeyPairProvider {
|
|||||||
final kp = await (_dt.db.snLocalKeyPair.select()
|
final kp = await (_dt.db.snLocalKeyPair.select()
|
||||||
..where((e) => e.accountId.equals(_ua.user!.id))
|
..where((e) => e.accountId.equals(_ua.user!.id))
|
||||||
..where((e) => e.privateKey.isNotNull())
|
..where((e) => e.privateKey.isNotNull())
|
||||||
|
..where((e) => e.isActive.equals(true))
|
||||||
..limit(1))
|
..limit(1))
|
||||||
.getSingleOrNull();
|
.getSingleOrNull();
|
||||||
|
|
||||||
@ -169,16 +168,42 @@ class KeyPairProvider {
|
|||||||
return activeKp;
|
return activeKp;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<SnKeyPair> enrollNew() async {
|
Future<List<SnKeyPair>> listKeyPair() async {
|
||||||
if (!_ua.isAuthorized) throw Exception('Unauthorized');
|
final kps = await (_dt.db.snLocalKeyPair.select()).get();
|
||||||
|
return kps
|
||||||
|
.map((e) => SnKeyPair(
|
||||||
|
id: e.id,
|
||||||
|
accountId: e.accountId,
|
||||||
|
publicKey: e.publicKey,
|
||||||
|
privateKey: e.privateKey,
|
||||||
|
isActive: e.isActive,
|
||||||
|
))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
final existsOne = await (_dt.db.snLocalKeyPair.select()
|
Future<void> activeKeyPair(String kpId) async {
|
||||||
..where((e) => e.accountId.equals(_ua.user!.id))
|
final kp = await (_dt.db.snLocalKeyPair.select()
|
||||||
|
..where((e) => e.id.equals(kpId))
|
||||||
..where((e) => e.privateKey.isNotNull())
|
..where((e) => e.privateKey.isNotNull())
|
||||||
..limit(1))
|
..limit(1))
|
||||||
.getSingleOrNull();
|
.getSingleOrNull();
|
||||||
|
if (kp == null) return;
|
||||||
|
|
||||||
final id = existsOne?.id ?? const Uuid().v4();
|
await _dt.db.transaction(() async {
|
||||||
|
await (_dt.db.update(_dt.db.snLocalKeyPair)
|
||||||
|
..where((e) => e.isActive.equals(true)))
|
||||||
|
.write(SnLocalKeyPairCompanion(isActive: Value(false)));
|
||||||
|
|
||||||
|
await (_dt.db.update(_dt.db.snLocalKeyPair)
|
||||||
|
..where((e) => e.id.equals(kp.id)))
|
||||||
|
.write(SnLocalKeyPairCompanion(isActive: Value(true)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<SnKeyPair> enrollNew() async {
|
||||||
|
if (!_ua.isAuthorized) throw Exception('Unauthorized');
|
||||||
|
|
||||||
|
final id = const Uuid().v4();
|
||||||
final kp = await RSA.generate(2048);
|
final kp = await RSA.generate(2048);
|
||||||
final kpMeta = SnKeyPair(
|
final kpMeta = SnKeyPair(
|
||||||
id: id,
|
id: id,
|
||||||
@ -189,20 +214,21 @@ class KeyPairProvider {
|
|||||||
|
|
||||||
// Save the keypair to the local database
|
// Save the keypair to the local database
|
||||||
// If there is already one with private key, it will be overwritten
|
// If there is already one with private key, it will be overwritten
|
||||||
await _dt.db.snLocalKeyPair.insertOne(
|
await _dt.db.transaction(() async {
|
||||||
SnLocalKeyPairCompanion.insert(
|
await (_dt.db.update(_dt.db.snLocalKeyPair)
|
||||||
id: kpMeta.id,
|
..where((e) => e.isActive.equals(true)))
|
||||||
accountId: kpMeta.accountId,
|
.write(SnLocalKeyPairCompanion(isActive: Value(false)));
|
||||||
publicKey: kpMeta.publicKey,
|
|
||||||
privateKey: Value(kpMeta.privateKey),
|
await _dt.db.snLocalKeyPair.insertOne(
|
||||||
),
|
SnLocalKeyPairCompanion.insert(
|
||||||
onConflict: DoUpdate(
|
id: kpMeta.id,
|
||||||
(_) => SnLocalKeyPairCompanion.custom(
|
accountId: kpMeta.accountId,
|
||||||
publicKey: Constant(kpMeta.publicKey),
|
publicKey: kpMeta.publicKey,
|
||||||
privateKey: Constant(kpMeta.privateKey),
|
privateKey: Value(kpMeta.privateKey),
|
||||||
|
isActive: Value(true),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
});
|
||||||
|
|
||||||
await reloadActive(autoEnroll: false);
|
await reloadActive(autoEnroll: false);
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import 'package:surface/screens/account.dart';
|
|||||||
import 'package:surface/screens/account/account_settings.dart';
|
import 'package:surface/screens/account/account_settings.dart';
|
||||||
import 'package:surface/screens/account/badges.dart';
|
import 'package:surface/screens/account/badges.dart';
|
||||||
import 'package:surface/screens/account/factor_settings.dart';
|
import 'package:surface/screens/account/factor_settings.dart';
|
||||||
|
import 'package:surface/screens/account/keypairs.dart';
|
||||||
import 'package:surface/screens/account/profile_page.dart';
|
import 'package:surface/screens/account/profile_page.dart';
|
||||||
import 'package:surface/screens/account/profile_edit.dart';
|
import 'package:surface/screens/account/profile_edit.dart';
|
||||||
import 'package:surface/screens/account/publishers/publisher_edit.dart';
|
import 'package:surface/screens/account/publishers/publisher_edit.dart';
|
||||||
@ -43,8 +44,8 @@ import 'package:surface/types/post.dart';
|
|||||||
import 'package:surface/widgets/about.dart';
|
import 'package:surface/widgets/about.dart';
|
||||||
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
||||||
|
|
||||||
Widget _fadeThroughTransition(
|
Widget _fadeThroughTransition(BuildContext context, Animation<double> animation,
|
||||||
BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
|
Animation<double> secondaryAnimation, Widget child) {
|
||||||
return FadeThroughTransition(
|
return FadeThroughTransition(
|
||||||
animation: animation,
|
animation: animation,
|
||||||
secondaryAnimation: secondaryAnimation,
|
secondaryAnimation: secondaryAnimation,
|
||||||
@ -86,13 +87,15 @@ final _appRoutes = [
|
|||||||
name: 'postSearch',
|
name: 'postSearch',
|
||||||
builder: (context, state) => PostSearchScreen(
|
builder: (context, state) => PostSearchScreen(
|
||||||
initialTags: state.uri.queryParameters['tags']?.split(','),
|
initialTags: state.uri.queryParameters['tags']?.split(','),
|
||||||
initialCategories: state.uri.queryParameters['categories']?.split(','),
|
initialCategories:
|
||||||
|
state.uri.queryParameters['categories']?.split(','),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/publishers/:name',
|
path: '/publishers/:name',
|
||||||
name: 'postPublisher',
|
name: 'postPublisher',
|
||||||
builder: (context, state) => PostPublisherScreen(name: state.pathParameters['name']!),
|
builder: (context, state) =>
|
||||||
|
PostPublisherScreen(name: state.pathParameters['name']!),
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/:slug',
|
path: '/:slug',
|
||||||
@ -119,6 +122,11 @@ final _appRoutes = [
|
|||||||
name: 'accountWallet',
|
name: 'accountWallet',
|
||||||
builder: (context, state) => const WalletScreen(),
|
builder: (context, state) => const WalletScreen(),
|
||||||
),
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/keypairs',
|
||||||
|
name: 'accountKeyPairs',
|
||||||
|
builder: (context, state) => const KeyPairScreen(),
|
||||||
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/settings',
|
path: '/settings',
|
||||||
name: 'accountSettings',
|
name: 'accountSettings',
|
||||||
@ -222,7 +230,8 @@ final _appRoutes = [
|
|||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/:alias',
|
path: '/:alias',
|
||||||
name: 'realmDetail',
|
name: 'realmDetail',
|
||||||
builder: (context, state) => RealmDetailScreen(alias: state.pathParameters['alias']!),
|
builder: (context, state) =>
|
||||||
|
RealmDetailScreen(alias: state.pathParameters['alias']!),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -45,7 +45,8 @@ class AccountScreen extends StatelessWidget {
|
|||||||
? Stack(
|
? Stack(
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
AutoResizeUniversalImage(sn.getAttachmentUrl(ua.user!.banner), fit: BoxFit.cover),
|
AutoResizeUniversalImage(sn.getAttachmentUrl(ua.user!.banner),
|
||||||
|
fit: BoxFit.cover),
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 0,
|
top: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
@ -79,7 +80,9 @@ class AccountScreen extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: ua.isAuthorized ? _AuthorizedAccountScreen() : _UnauthorizedAccountScreen(),
|
child: ua.isAuthorized
|
||||||
|
? _AuthorizedAccountScreen()
|
||||||
|
: _UnauthorizedAccountScreen(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -115,9 +118,11 @@ class _AuthorizedAccountScreen extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||||
textBaseline: TextBaseline.alphabetic,
|
textBaseline: TextBaseline.alphabetic,
|
||||||
children: [
|
children: [
|
||||||
Text(ua.user!.nick).textStyle(Theme.of(context).textTheme.titleLarge!),
|
Text(ua.user!.nick)
|
||||||
|
.textStyle(Theme.of(context).textTheme.titleLarge!),
|
||||||
const Gap(4),
|
const Gap(4),
|
||||||
Text('@${ua.user!.name}').textStyle(Theme.of(context).textTheme.bodySmall!),
|
Text('@${ua.user!.name}')
|
||||||
|
.textStyle(Theme.of(context).textTheme.bodySmall!),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
@ -183,6 +188,16 @@ class _AuthorizedAccountScreen extends StatelessWidget {
|
|||||||
GoRouter.of(context).pushNamed('accountBadges');
|
GoRouter.of(context).pushNamed('accountBadges');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text('accountKeyPairs').tr(),
|
||||||
|
subtitle: Text('accountKeyPairsDescription').tr(),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
leading: const Icon(Symbols.key),
|
||||||
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
|
onTap: () {
|
||||||
|
GoRouter.of(context).pushNamed('accountKeyPairs');
|
||||||
|
},
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text('accountSettings').tr(),
|
title: Text('accountSettings').tr(),
|
||||||
subtitle: Text('accountSettingsSubtitle').tr(),
|
subtitle: Text('accountSettingsSubtitle').tr(),
|
||||||
@ -236,7 +251,9 @@ class _UnauthorizedAccountScreen extends StatelessWidget {
|
|||||||
child: Icon(Symbols.waving_hand, size: 28),
|
child: Icon(Symbols.waving_hand, size: 28),
|
||||||
),
|
),
|
||||||
const Gap(8),
|
const Gap(8),
|
||||||
Text('accountIntroTitle').tr().textStyle(Theme.of(context).textTheme.titleLarge!),
|
Text('accountIntroTitle')
|
||||||
|
.tr()
|
||||||
|
.textStyle(Theme.of(context).textTheme.titleLarge!),
|
||||||
Text('accountIntroSubtitle').tr(),
|
Text('accountIntroSubtitle').tr(),
|
||||||
],
|
],
|
||||||
).padding(all: 20),
|
).padding(all: 20),
|
||||||
|
106
lib/screens/account/keypairs.dart
Normal file
106
lib/screens/account/keypairs.dart
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:surface/providers/keypair.dart';
|
||||||
|
import 'package:surface/types/keypair.dart';
|
||||||
|
import 'package:surface/widgets/loading_indicator.dart';
|
||||||
|
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
||||||
|
|
||||||
|
class KeyPairScreen extends StatefulWidget {
|
||||||
|
const KeyPairScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<KeyPairScreen> createState() => _KeyPairScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _KeyPairScreenState extends State<KeyPairScreen> {
|
||||||
|
bool _isBusy = false;
|
||||||
|
List<SnKeyPair>? _keyPairs;
|
||||||
|
|
||||||
|
Future<void> _loadKeyPairs() async {
|
||||||
|
setState(() => _isBusy = true);
|
||||||
|
final kps = await context.read<KeyPairProvider>().listKeyPair();
|
||||||
|
setState(() {
|
||||||
|
_keyPairs = kps;
|
||||||
|
_isBusy = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadKeyPairs();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AppScaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text('screenKeyPairs').tr(),
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
LoadingIndicator(isActive: _isBusy),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Symbols.add),
|
||||||
|
title: Text('enrollNewKeyPair').tr(),
|
||||||
|
subtitle: Text('enrollNewKeyPairDescription').tr(),
|
||||||
|
onTap: () async {
|
||||||
|
await context.read<KeyPairProvider>().enrollNew();
|
||||||
|
_loadKeyPairs();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Divider(height: 1),
|
||||||
|
if (_keyPairs != null)
|
||||||
|
Expanded(
|
||||||
|
child: MediaQuery.removePadding(
|
||||||
|
context: context,
|
||||||
|
removeTop: true,
|
||||||
|
child: RefreshIndicator(
|
||||||
|
onRefresh: _loadKeyPairs,
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: _keyPairs!.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final kp = _keyPairs![index];
|
||||||
|
return ListTile(
|
||||||
|
title: Text(kp.id.toUpperCase()),
|
||||||
|
subtitle: Row(
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
if (kp.privateKey != null)
|
||||||
|
Text(
|
||||||
|
'keyPairHasPrivateKey'.tr(),
|
||||||
|
),
|
||||||
|
if (kp.privateKey != null) Text('·'),
|
||||||
|
Flexible(
|
||||||
|
flex: 1,
|
||||||
|
child: Text(
|
||||||
|
'UID #${kp.accountId.toString().padLeft(8, '0')}',
|
||||||
|
style: GoogleFonts.robotoMono(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: const Icon(Symbols.check),
|
||||||
|
onPressed: kp.isActive == true
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
final k = context.read<KeyPairProvider>();
|
||||||
|
await k.activeKeyPair(kp.id);
|
||||||
|
_loadKeyPairs();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -9,8 +9,10 @@ abstract class SnKeyPair with _$SnKeyPair {
|
|||||||
required String id,
|
required String id,
|
||||||
required int accountId,
|
required int accountId,
|
||||||
required String publicKey,
|
required String publicKey,
|
||||||
|
bool? isActive,
|
||||||
String? privateKey,
|
String? privateKey,
|
||||||
}) = _SnKeyPair;
|
}) = _SnKeyPair;
|
||||||
|
|
||||||
factory SnKeyPair.fromJson(Map<String, Object?> json) => _$SnKeyPairFromJson(json);
|
factory SnKeyPair.fromJson(Map<String, Object?> json) =>
|
||||||
}
|
_$SnKeyPairFromJson(json);
|
||||||
|
}
|
||||||
|
@ -18,6 +18,7 @@ mixin _$SnKeyPair {
|
|||||||
String get id;
|
String get id;
|
||||||
int get accountId;
|
int get accountId;
|
||||||
String get publicKey;
|
String get publicKey;
|
||||||
|
bool? get isActive;
|
||||||
String? get privateKey;
|
String? get privateKey;
|
||||||
|
|
||||||
/// Create a copy of SnKeyPair
|
/// Create a copy of SnKeyPair
|
||||||
@ -40,6 +41,8 @@ mixin _$SnKeyPair {
|
|||||||
other.accountId == accountId) &&
|
other.accountId == accountId) &&
|
||||||
(identical(other.publicKey, publicKey) ||
|
(identical(other.publicKey, publicKey) ||
|
||||||
other.publicKey == publicKey) &&
|
other.publicKey == publicKey) &&
|
||||||
|
(identical(other.isActive, isActive) ||
|
||||||
|
other.isActive == isActive) &&
|
||||||
(identical(other.privateKey, privateKey) ||
|
(identical(other.privateKey, privateKey) ||
|
||||||
other.privateKey == privateKey));
|
other.privateKey == privateKey));
|
||||||
}
|
}
|
||||||
@ -47,11 +50,11 @@ mixin _$SnKeyPair {
|
|||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode =>
|
int get hashCode =>
|
||||||
Object.hash(runtimeType, id, accountId, publicKey, privateKey);
|
Object.hash(runtimeType, id, accountId, publicKey, isActive, privateKey);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SnKeyPair(id: $id, accountId: $accountId, publicKey: $publicKey, privateKey: $privateKey)';
|
return 'SnKeyPair(id: $id, accountId: $accountId, publicKey: $publicKey, isActive: $isActive, privateKey: $privateKey)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +63,12 @@ abstract mixin class $SnKeyPairCopyWith<$Res> {
|
|||||||
factory $SnKeyPairCopyWith(SnKeyPair value, $Res Function(SnKeyPair) _then) =
|
factory $SnKeyPairCopyWith(SnKeyPair value, $Res Function(SnKeyPair) _then) =
|
||||||
_$SnKeyPairCopyWithImpl;
|
_$SnKeyPairCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String id, int accountId, String publicKey, String? privateKey});
|
$Res call(
|
||||||
|
{String id,
|
||||||
|
int accountId,
|
||||||
|
String publicKey,
|
||||||
|
bool? isActive,
|
||||||
|
String? privateKey});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -78,6 +86,7 @@ class _$SnKeyPairCopyWithImpl<$Res> implements $SnKeyPairCopyWith<$Res> {
|
|||||||
Object? id = null,
|
Object? id = null,
|
||||||
Object? accountId = null,
|
Object? accountId = null,
|
||||||
Object? publicKey = null,
|
Object? publicKey = null,
|
||||||
|
Object? isActive = freezed,
|
||||||
Object? privateKey = freezed,
|
Object? privateKey = freezed,
|
||||||
}) {
|
}) {
|
||||||
return _then(_self.copyWith(
|
return _then(_self.copyWith(
|
||||||
@ -93,6 +102,10 @@ class _$SnKeyPairCopyWithImpl<$Res> implements $SnKeyPairCopyWith<$Res> {
|
|||||||
? _self.publicKey
|
? _self.publicKey
|
||||||
: publicKey // ignore: cast_nullable_to_non_nullable
|
: publicKey // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String,
|
||||||
|
isActive: freezed == isActive
|
||||||
|
? _self.isActive
|
||||||
|
: isActive // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool?,
|
||||||
privateKey: freezed == privateKey
|
privateKey: freezed == privateKey
|
||||||
? _self.privateKey
|
? _self.privateKey
|
||||||
: privateKey // ignore: cast_nullable_to_non_nullable
|
: privateKey // ignore: cast_nullable_to_non_nullable
|
||||||
@ -108,6 +121,7 @@ class _SnKeyPair implements SnKeyPair {
|
|||||||
{required this.id,
|
{required this.id,
|
||||||
required this.accountId,
|
required this.accountId,
|
||||||
required this.publicKey,
|
required this.publicKey,
|
||||||
|
this.isActive,
|
||||||
this.privateKey});
|
this.privateKey});
|
||||||
factory _SnKeyPair.fromJson(Map<String, dynamic> json) =>
|
factory _SnKeyPair.fromJson(Map<String, dynamic> json) =>
|
||||||
_$SnKeyPairFromJson(json);
|
_$SnKeyPairFromJson(json);
|
||||||
@ -119,6 +133,8 @@ class _SnKeyPair implements SnKeyPair {
|
|||||||
@override
|
@override
|
||||||
final String publicKey;
|
final String publicKey;
|
||||||
@override
|
@override
|
||||||
|
final bool? isActive;
|
||||||
|
@override
|
||||||
final String? privateKey;
|
final String? privateKey;
|
||||||
|
|
||||||
/// Create a copy of SnKeyPair
|
/// Create a copy of SnKeyPair
|
||||||
@ -146,6 +162,8 @@ class _SnKeyPair implements SnKeyPair {
|
|||||||
other.accountId == accountId) &&
|
other.accountId == accountId) &&
|
||||||
(identical(other.publicKey, publicKey) ||
|
(identical(other.publicKey, publicKey) ||
|
||||||
other.publicKey == publicKey) &&
|
other.publicKey == publicKey) &&
|
||||||
|
(identical(other.isActive, isActive) ||
|
||||||
|
other.isActive == isActive) &&
|
||||||
(identical(other.privateKey, privateKey) ||
|
(identical(other.privateKey, privateKey) ||
|
||||||
other.privateKey == privateKey));
|
other.privateKey == privateKey));
|
||||||
}
|
}
|
||||||
@ -153,11 +171,11 @@ class _SnKeyPair implements SnKeyPair {
|
|||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode =>
|
int get hashCode =>
|
||||||
Object.hash(runtimeType, id, accountId, publicKey, privateKey);
|
Object.hash(runtimeType, id, accountId, publicKey, isActive, privateKey);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'SnKeyPair(id: $id, accountId: $accountId, publicKey: $publicKey, privateKey: $privateKey)';
|
return 'SnKeyPair(id: $id, accountId: $accountId, publicKey: $publicKey, isActive: $isActive, privateKey: $privateKey)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +187,12 @@ abstract mixin class _$SnKeyPairCopyWith<$Res>
|
|||||||
__$SnKeyPairCopyWithImpl;
|
__$SnKeyPairCopyWithImpl;
|
||||||
@override
|
@override
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String id, int accountId, String publicKey, String? privateKey});
|
$Res call(
|
||||||
|
{String id,
|
||||||
|
int accountId,
|
||||||
|
String publicKey,
|
||||||
|
bool? isActive,
|
||||||
|
String? privateKey});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -187,6 +210,7 @@ class __$SnKeyPairCopyWithImpl<$Res> implements _$SnKeyPairCopyWith<$Res> {
|
|||||||
Object? id = null,
|
Object? id = null,
|
||||||
Object? accountId = null,
|
Object? accountId = null,
|
||||||
Object? publicKey = null,
|
Object? publicKey = null,
|
||||||
|
Object? isActive = freezed,
|
||||||
Object? privateKey = freezed,
|
Object? privateKey = freezed,
|
||||||
}) {
|
}) {
|
||||||
return _then(_SnKeyPair(
|
return _then(_SnKeyPair(
|
||||||
@ -202,6 +226,10 @@ class __$SnKeyPairCopyWithImpl<$Res> implements _$SnKeyPairCopyWith<$Res> {
|
|||||||
? _self.publicKey
|
? _self.publicKey
|
||||||
: publicKey // ignore: cast_nullable_to_non_nullable
|
: publicKey // ignore: cast_nullable_to_non_nullable
|
||||||
as String,
|
as String,
|
||||||
|
isActive: freezed == isActive
|
||||||
|
? _self.isActive
|
||||||
|
: isActive // ignore: cast_nullable_to_non_nullable
|
||||||
|
as bool?,
|
||||||
privateKey: freezed == privateKey
|
privateKey: freezed == privateKey
|
||||||
? _self.privateKey
|
? _self.privateKey
|
||||||
: privateKey // ignore: cast_nullable_to_non_nullable
|
: privateKey // ignore: cast_nullable_to_non_nullable
|
||||||
|
@ -10,6 +10,7 @@ _SnKeyPair _$SnKeyPairFromJson(Map<String, dynamic> json) => _SnKeyPair(
|
|||||||
id: json['id'] as String,
|
id: json['id'] as String,
|
||||||
accountId: (json['account_id'] as num).toInt(),
|
accountId: (json['account_id'] as num).toInt(),
|
||||||
publicKey: json['public_key'] as String,
|
publicKey: json['public_key'] as String,
|
||||||
|
isActive: json['is_active'] as bool?,
|
||||||
privateKey: json['private_key'] as String?,
|
privateKey: json['private_key'] as String?,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -18,5 +19,6 @@ Map<String, dynamic> _$SnKeyPairToJson(_SnKeyPair instance) =>
|
|||||||
'id': instance.id,
|
'id': instance.id,
|
||||||
'account_id': instance.accountId,
|
'account_id': instance.accountId,
|
||||||
'public_key': instance.publicKey,
|
'public_key': instance.publicKey,
|
||||||
|
'is_active': instance.isActive,
|
||||||
'private_key': instance.privateKey,
|
'private_key': instance.privateKey,
|
||||||
};
|
};
|
||||||
|
@ -465,8 +465,16 @@ class SnLocalKeyPair extends Table
|
|||||||
late final GeneratedColumn<String> privateKey = GeneratedColumn<String>(
|
late final GeneratedColumn<String> privateKey = GeneratedColumn<String>(
|
||||||
'private_key', aliasedName, true,
|
'private_key', aliasedName, true,
|
||||||
type: DriftSqlType.string, requiredDuringInsert: false);
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
||||||
|
late final GeneratedColumn<bool> isActive = GeneratedColumn<bool>(
|
||||||
|
'is_active', aliasedName, false,
|
||||||
|
type: DriftSqlType.bool,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultConstraints:
|
||||||
|
GeneratedColumn.constraintIsAlways('CHECK ("is_active" IN (0, 1))'),
|
||||||
|
defaultValue: const CustomExpression('0'));
|
||||||
@override
|
@override
|
||||||
List<GeneratedColumn> get $columns => [id, accountId, publicKey, privateKey];
|
List<GeneratedColumn> get $columns =>
|
||||||
|
[id, accountId, publicKey, privateKey, isActive];
|
||||||
@override
|
@override
|
||||||
String get aliasedName => _alias ?? actualTableName;
|
String get aliasedName => _alias ?? actualTableName;
|
||||||
@override
|
@override
|
||||||
@ -486,6 +494,8 @@ class SnLocalKeyPair extends Table
|
|||||||
.read(DriftSqlType.string, data['${effectivePrefix}public_key'])!,
|
.read(DriftSqlType.string, data['${effectivePrefix}public_key'])!,
|
||||||
privateKey: attachedDatabase.typeMapping
|
privateKey: attachedDatabase.typeMapping
|
||||||
.read(DriftSqlType.string, data['${effectivePrefix}private_key']),
|
.read(DriftSqlType.string, data['${effectivePrefix}private_key']),
|
||||||
|
isActive: attachedDatabase.typeMapping
|
||||||
|
.read(DriftSqlType.bool, data['${effectivePrefix}is_active'])!,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,11 +511,13 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
final int accountId;
|
final int accountId;
|
||||||
final String publicKey;
|
final String publicKey;
|
||||||
final String? privateKey;
|
final String? privateKey;
|
||||||
|
final bool isActive;
|
||||||
const SnLocalKeyPairData(
|
const SnLocalKeyPairData(
|
||||||
{required this.id,
|
{required this.id,
|
||||||
required this.accountId,
|
required this.accountId,
|
||||||
required this.publicKey,
|
required this.publicKey,
|
||||||
this.privateKey});
|
this.privateKey,
|
||||||
|
required this.isActive});
|
||||||
@override
|
@override
|
||||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
final map = <String, Expression>{};
|
final map = <String, Expression>{};
|
||||||
@ -515,6 +527,7 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
if (!nullToAbsent || privateKey != null) {
|
if (!nullToAbsent || privateKey != null) {
|
||||||
map['private_key'] = Variable<String>(privateKey);
|
map['private_key'] = Variable<String>(privateKey);
|
||||||
}
|
}
|
||||||
|
map['is_active'] = Variable<bool>(isActive);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,6 +539,7 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
privateKey: privateKey == null && nullToAbsent
|
privateKey: privateKey == null && nullToAbsent
|
||||||
? const Value.absent()
|
? const Value.absent()
|
||||||
: Value(privateKey),
|
: Value(privateKey),
|
||||||
|
isActive: Value(isActive),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -537,6 +551,7 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
accountId: serializer.fromJson<int>(json['accountId']),
|
accountId: serializer.fromJson<int>(json['accountId']),
|
||||||
publicKey: serializer.fromJson<String>(json['publicKey']),
|
publicKey: serializer.fromJson<String>(json['publicKey']),
|
||||||
privateKey: serializer.fromJson<String?>(json['privateKey']),
|
privateKey: serializer.fromJson<String?>(json['privateKey']),
|
||||||
|
isActive: serializer.fromJson<bool>(json['isActive']),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@override
|
@override
|
||||||
@ -547,6 +562,7 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
'accountId': serializer.toJson<int>(accountId),
|
'accountId': serializer.toJson<int>(accountId),
|
||||||
'publicKey': serializer.toJson<String>(publicKey),
|
'publicKey': serializer.toJson<String>(publicKey),
|
||||||
'privateKey': serializer.toJson<String?>(privateKey),
|
'privateKey': serializer.toJson<String?>(privateKey),
|
||||||
|
'isActive': serializer.toJson<bool>(isActive),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,12 +570,14 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
{String? id,
|
{String? id,
|
||||||
int? accountId,
|
int? accountId,
|
||||||
String? publicKey,
|
String? publicKey,
|
||||||
Value<String?> privateKey = const Value.absent()}) =>
|
Value<String?> privateKey = const Value.absent(),
|
||||||
|
bool? isActive}) =>
|
||||||
SnLocalKeyPairData(
|
SnLocalKeyPairData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
accountId: accountId ?? this.accountId,
|
accountId: accountId ?? this.accountId,
|
||||||
publicKey: publicKey ?? this.publicKey,
|
publicKey: publicKey ?? this.publicKey,
|
||||||
privateKey: privateKey.present ? privateKey.value : this.privateKey,
|
privateKey: privateKey.present ? privateKey.value : this.privateKey,
|
||||||
|
isActive: isActive ?? this.isActive,
|
||||||
);
|
);
|
||||||
SnLocalKeyPairData copyWithCompanion(SnLocalKeyPairCompanion data) {
|
SnLocalKeyPairData copyWithCompanion(SnLocalKeyPairCompanion data) {
|
||||||
return SnLocalKeyPairData(
|
return SnLocalKeyPairData(
|
||||||
@ -568,6 +586,7 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
publicKey: data.publicKey.present ? data.publicKey.value : this.publicKey,
|
publicKey: data.publicKey.present ? data.publicKey.value : this.publicKey,
|
||||||
privateKey:
|
privateKey:
|
||||||
data.privateKey.present ? data.privateKey.value : this.privateKey,
|
data.privateKey.present ? data.privateKey.value : this.privateKey,
|
||||||
|
isActive: data.isActive.present ? data.isActive.value : this.isActive,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,13 +596,15 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
..write('id: $id, ')
|
..write('id: $id, ')
|
||||||
..write('accountId: $accountId, ')
|
..write('accountId: $accountId, ')
|
||||||
..write('publicKey: $publicKey, ')
|
..write('publicKey: $publicKey, ')
|
||||||
..write('privateKey: $privateKey')
|
..write('privateKey: $privateKey, ')
|
||||||
|
..write('isActive: $isActive')
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(id, accountId, publicKey, privateKey);
|
int get hashCode =>
|
||||||
|
Object.hash(id, accountId, publicKey, privateKey, isActive);
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
identical(this, other) ||
|
identical(this, other) ||
|
||||||
@ -591,7 +612,8 @@ class SnLocalKeyPairData extends DataClass
|
|||||||
other.id == this.id &&
|
other.id == this.id &&
|
||||||
other.accountId == this.accountId &&
|
other.accountId == this.accountId &&
|
||||||
other.publicKey == this.publicKey &&
|
other.publicKey == this.publicKey &&
|
||||||
other.privateKey == this.privateKey);
|
other.privateKey == this.privateKey &&
|
||||||
|
other.isActive == this.isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
||||||
@ -599,12 +621,14 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
final Value<int> accountId;
|
final Value<int> accountId;
|
||||||
final Value<String> publicKey;
|
final Value<String> publicKey;
|
||||||
final Value<String?> privateKey;
|
final Value<String?> privateKey;
|
||||||
|
final Value<bool> isActive;
|
||||||
final Value<int> rowid;
|
final Value<int> rowid;
|
||||||
const SnLocalKeyPairCompanion({
|
const SnLocalKeyPairCompanion({
|
||||||
this.id = const Value.absent(),
|
this.id = const Value.absent(),
|
||||||
this.accountId = const Value.absent(),
|
this.accountId = const Value.absent(),
|
||||||
this.publicKey = const Value.absent(),
|
this.publicKey = const Value.absent(),
|
||||||
this.privateKey = const Value.absent(),
|
this.privateKey = const Value.absent(),
|
||||||
|
this.isActive = const Value.absent(),
|
||||||
this.rowid = const Value.absent(),
|
this.rowid = const Value.absent(),
|
||||||
});
|
});
|
||||||
SnLocalKeyPairCompanion.insert({
|
SnLocalKeyPairCompanion.insert({
|
||||||
@ -612,6 +636,7 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
required int accountId,
|
required int accountId,
|
||||||
required String publicKey,
|
required String publicKey,
|
||||||
this.privateKey = const Value.absent(),
|
this.privateKey = const Value.absent(),
|
||||||
|
this.isActive = const Value.absent(),
|
||||||
this.rowid = const Value.absent(),
|
this.rowid = const Value.absent(),
|
||||||
}) : id = Value(id),
|
}) : id = Value(id),
|
||||||
accountId = Value(accountId),
|
accountId = Value(accountId),
|
||||||
@ -621,6 +646,7 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
Expression<int>? accountId,
|
Expression<int>? accountId,
|
||||||
Expression<String>? publicKey,
|
Expression<String>? publicKey,
|
||||||
Expression<String>? privateKey,
|
Expression<String>? privateKey,
|
||||||
|
Expression<bool>? isActive,
|
||||||
Expression<int>? rowid,
|
Expression<int>? rowid,
|
||||||
}) {
|
}) {
|
||||||
return RawValuesInsertable({
|
return RawValuesInsertable({
|
||||||
@ -628,6 +654,7 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
if (accountId != null) 'account_id': accountId,
|
if (accountId != null) 'account_id': accountId,
|
||||||
if (publicKey != null) 'public_key': publicKey,
|
if (publicKey != null) 'public_key': publicKey,
|
||||||
if (privateKey != null) 'private_key': privateKey,
|
if (privateKey != null) 'private_key': privateKey,
|
||||||
|
if (isActive != null) 'is_active': isActive,
|
||||||
if (rowid != null) 'rowid': rowid,
|
if (rowid != null) 'rowid': rowid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -637,12 +664,14 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
Value<int>? accountId,
|
Value<int>? accountId,
|
||||||
Value<String>? publicKey,
|
Value<String>? publicKey,
|
||||||
Value<String?>? privateKey,
|
Value<String?>? privateKey,
|
||||||
|
Value<bool>? isActive,
|
||||||
Value<int>? rowid}) {
|
Value<int>? rowid}) {
|
||||||
return SnLocalKeyPairCompanion(
|
return SnLocalKeyPairCompanion(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
accountId: accountId ?? this.accountId,
|
accountId: accountId ?? this.accountId,
|
||||||
publicKey: publicKey ?? this.publicKey,
|
publicKey: publicKey ?? this.publicKey,
|
||||||
privateKey: privateKey ?? this.privateKey,
|
privateKey: privateKey ?? this.privateKey,
|
||||||
|
isActive: isActive ?? this.isActive,
|
||||||
rowid: rowid ?? this.rowid,
|
rowid: rowid ?? this.rowid,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -662,6 +691,9 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
if (privateKey.present) {
|
if (privateKey.present) {
|
||||||
map['private_key'] = Variable<String>(privateKey.value);
|
map['private_key'] = Variable<String>(privateKey.value);
|
||||||
}
|
}
|
||||||
|
if (isActive.present) {
|
||||||
|
map['is_active'] = Variable<bool>(isActive.value);
|
||||||
|
}
|
||||||
if (rowid.present) {
|
if (rowid.present) {
|
||||||
map['rowid'] = Variable<int>(rowid.value);
|
map['rowid'] = Variable<int>(rowid.value);
|
||||||
}
|
}
|
||||||
@ -675,6 +707,7 @@ class SnLocalKeyPairCompanion extends UpdateCompanion<SnLocalKeyPairData> {
|
|||||||
..write('accountId: $accountId, ')
|
..write('accountId: $accountId, ')
|
||||||
..write('publicKey: $publicKey, ')
|
..write('publicKey: $publicKey, ')
|
||||||
..write('privateKey: $privateKey, ')
|
..write('privateKey: $privateKey, ')
|
||||||
|
..write('isActive: $isActive, ')
|
||||||
..write('rowid: $rowid')
|
..write('rowid: $rowid')
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user