mirror of
https://github.com/mitchell/selfpass.git
synced 2025-12-14 21:27:22 +00:00
Add 'client/' from commit '92f38b5810'
git-subtree-dir: client git-subtree-mainline:024017338egit-subtree-split:92f38b5810
This commit is contained in:
commit
66ec035ee0
90 changed files with 3817 additions and 0 deletions
27
client/lib/types/abstracts.dart
Normal file
27
client/lib/types/abstracts.dart
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'credential.dart';
|
||||
import 'connection_config.dart';
|
||||
|
||||
abstract class CredentialsRepo {
|
||||
Stream<Metadata> getAllMetadata(String sourceHost);
|
||||
Future<Credential> get(String id);
|
||||
Future<Credential> create(CredentialInput input);
|
||||
Future<Credential> update(String id, CredentialInput input);
|
||||
Future<void> delete(String id);
|
||||
}
|
||||
|
||||
abstract class ConfigRepo {
|
||||
Future<void> setPrivateKey(String key);
|
||||
Future<String> get privateKey;
|
||||
|
||||
String get password;
|
||||
Future<void> setPassword(String password);
|
||||
Future<bool> get passwordIsSet;
|
||||
Future<bool> matchesPasswordHash(String password);
|
||||
|
||||
Future<void> setConnectionConfig(ConnectionConfig config);
|
||||
Future<ConnectionConfig> get connectionConfig;
|
||||
|
||||
Future<void> deleteAll();
|
||||
}
|
||||
27
client/lib/types/connection_config.dart
Normal file
27
client/lib/types/connection_config.dart
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
class ConnectionConfig {
|
||||
String host;
|
||||
String caCertificate;
|
||||
String certificate;
|
||||
String privateCertificate;
|
||||
|
||||
ConnectionConfig({
|
||||
this.host,
|
||||
this.caCertificate,
|
||||
this.certificate,
|
||||
this.privateCertificate,
|
||||
});
|
||||
|
||||
ConnectionConfig.fromJson(Map<String, dynamic> json) {
|
||||
host = json['host'];
|
||||
caCertificate = json['caCertificate'];
|
||||
certificate = json['certificate'];
|
||||
privateCertificate = json['privateCertificate'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'host': host,
|
||||
'caCertificate': caCertificate,
|
||||
'certificate': certificate,
|
||||
'privateCertificate': privateCertificate,
|
||||
};
|
||||
}
|
||||
94
client/lib/types/credential.dart
Normal file
94
client/lib/types/credential.dart
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
import '../protobuf/service.pb.dart' as protobuf;
|
||||
|
||||
class Metadata {
|
||||
String id;
|
||||
String sourceHost;
|
||||
DateTime createdAt;
|
||||
DateTime updatedAt;
|
||||
String primary;
|
||||
String loginUrl;
|
||||
String tag;
|
||||
|
||||
Metadata({
|
||||
this.id,
|
||||
this.sourceHost,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.primary,
|
||||
this.loginUrl,
|
||||
this.tag,
|
||||
});
|
||||
|
||||
Metadata.fromProtobuf(protobuf.Metadata metadata) {
|
||||
id = metadata.id;
|
||||
createdAt = metadata.createdAt.toDateTime();
|
||||
updatedAt = metadata.updatedAt.toDateTime();
|
||||
sourceHost = metadata.sourceHost;
|
||||
primary = metadata.primary;
|
||||
loginUrl = metadata.loginUrl;
|
||||
tag = metadata.tag;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => "id: $id";
|
||||
}
|
||||
|
||||
class MetadataInput {
|
||||
String sourceHost;
|
||||
String primary;
|
||||
String loginUrl;
|
||||
String tag;
|
||||
|
||||
MetadataInput({this.sourceHost, this.primary, this.loginUrl, this.tag});
|
||||
}
|
||||
|
||||
class Credential {
|
||||
Metadata meta;
|
||||
String username;
|
||||
String email;
|
||||
String password;
|
||||
String otpSecret;
|
||||
|
||||
Credential({
|
||||
this.meta,
|
||||
this.username,
|
||||
this.email,
|
||||
this.password,
|
||||
this.otpSecret,
|
||||
});
|
||||
|
||||
Credential.fromProtobuf(protobuf.Credential credential) {
|
||||
meta = Metadata(
|
||||
id: credential.id,
|
||||
createdAt: credential.createdAt.toDateTime(),
|
||||
updatedAt: credential.updatedAt.toDateTime(),
|
||||
sourceHost: credential.sourceHost,
|
||||
primary: credential.primary,
|
||||
loginUrl: credential.loginUrl,
|
||||
tag: credential.tag,
|
||||
);
|
||||
username = credential.username;
|
||||
email = credential.email;
|
||||
password = credential.password;
|
||||
otpSecret = credential.otpSecret;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => "meta: $meta\n";
|
||||
}
|
||||
|
||||
class CredentialInput {
|
||||
MetadataInput meta;
|
||||
String username;
|
||||
String email;
|
||||
String password;
|
||||
String otpSecret;
|
||||
|
||||
CredentialInput({
|
||||
this.meta,
|
||||
this.username,
|
||||
this.email,
|
||||
this.password,
|
||||
this.otpSecret,
|
||||
});
|
||||
}
|
||||
8
client/lib/types/screen_arguments.dart
Normal file
8
client/lib/types/screen_arguments.dart
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import 'connection_config.dart';
|
||||
|
||||
class ConfigScreenArguments {
|
||||
final ConnectionConfig connectionConfig;
|
||||
final String privateKey;
|
||||
|
||||
const ConfigScreenArguments({this.connectionConfig, this.privateKey});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue