Skip to content

Commit

Permalink
feat: Attempt to implement DEFAULT #1752 #1755
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Aug 1, 2023
1 parent b57fc3d commit 5785731
Show file tree
Hide file tree
Showing 31 changed files with 850 additions and 394 deletions.
98 changes: 51 additions & 47 deletions lib/app/shared/enum/type/oidc4vc_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enum OIDC4VCType {
offerPrefix: 'openid-credential-offer://',
presentationPrefix: 'openid-vc://',
cryptographicBindingMethodsSupported: ['DID'],
credentialSupported: [],
credentialSupported: ['EmployeeCredential', 'VerifiableId'],
grantTypesSupported: [
'authorization_code',
'urn:ietf:params:oauth:grant-type:pre-authorized_code'
Expand All @@ -20,12 +20,15 @@ enum OIDC4VCType {
'ES512',
'RS256'
],
subjectSyntaxTypesSupported: ['did:ebsi', 'did:key', 'did:ethr', 'did:tz'],
subjectSyntaxTypesSupported: ['did:key'],
schemaForType: false,
oidc4VciDraft:
'https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html',
siopv2Draft: '',
serviceDocumentation: 'Last release of the OIDC4VC documentation',
publicJWKNeeded: false,
serviceDocumentation:
'''WORK IN PROGRESS. WE use JSON-LD VC and VP and last release of the specs.\n'''
'''oidc4vci_draft : https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html\n'''
'''siopv2_draft : https://openid.net/specs/openid-connect-self-issued-v2-1_0.html\n'''
'''oidc4vp_draft : https://openid.net/specs/openid-4-verifiable-presentations-1_0.html\n'''
'''Issuer pour projet Docaposte Gaia-X''',
),

EBSIV2(
Expand All @@ -48,37 +51,35 @@ enum OIDC4VCType {
],
credentialSupported: ['VerifiableDiploma', 'VerifiableId'],
schemaForType: true,
oidc4VciDraft:
'https://openid.net/specs/openid-connect-4-verifiable-credential-issuance-1_0-05.html#abstract',
siopv2Draft: '',
publicJWKNeeded: true,
serviceDocumentation:
'It is the profile of the EBSI V2 compliant test. DID for natural person is did:ebsi. The schema url is used as the VC type in the credential offer QR code. The prefix openid_initiate_issuance://',
),

ARF(
issuerVcType: 'jwt_vc',
verifierVpType: 'jwt_vp',
offerPrefix: 'openid-credential-offer://',
presentationPrefix: 'openid-vc://',
cryptographicBindingMethodsSupported: ['DID'],
credentialSupported: [],
grantTypesSupported: [
'authorization_code',
'urn:ietf:params:oauth:grant-type:pre-authorized_code'
],
cryptographicSuitesSupported: [
'ES256K',
'ES256',
'ES384',
'ES512',
'RS256'
],
subjectSyntaxTypesSupported: ['did:ebsi', 'did:key', 'did:ethr', 'did:tz'],
schemaForType: false,
oidc4VciDraft: '',
siopv2Draft: '',
serviceDocumentation: '',
),
// ARF(
// issuerVcType: 'jwt_vc',
// verifierVpType: 'jwt_vp',
// offerPrefix: 'openid-credential-offer://',
// presentationPrefix: 'openid-vc://',
// cryptographicBindingMethodsSupported: ['DID'],
// credentialSupported: [],
// grantTypesSupported: [
// 'authorization_code',
// 'urn:ietf:params:oauth:grant-type:pre-authorized_code'
// ],
// cryptographicSuitesSupported: [
// 'ES256K',
// 'ES256',
// 'ES384',
// 'ES512',
// 'RS256'
// ],
// subjectSyntaxTypesSupported: ['did:ebsi', 'did:key', 'did:ethr', 'did:tz'],
// schemaForType: false,
// oidc4VciDraft: '',
// siopv2Draft: '',
// serviceDocumentation: '',
// ),

EBSIV3(
issuerVcType: 'jwt_vc',
Expand All @@ -100,9 +101,7 @@ enum OIDC4VCType {
],
subjectSyntaxTypesSupported: ['did:key'],
schemaForType: false,
oidc4VciDraft:
'https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html',
siopv2Draft: '',
publicJWKNeeded: true,
serviceDocumentation: '',
),

Expand All @@ -123,8 +122,7 @@ enum OIDC4VCType {
],
subjectSyntaxTypesSupported: ['did:ion'],
schemaForType: false,
oidc4VciDraft: '',
siopv2Draft: '',
publicJWKNeeded: true,
serviceDocumentation: '',
);

Expand All @@ -139,8 +137,7 @@ enum OIDC4VCType {
required this.grantTypesSupported,
required this.credentialSupported,
required this.schemaForType,
required this.oidc4VciDraft,
required this.siopv2Draft,
required this.publicJWKNeeded,
required this.serviceDocumentation,
});

Expand All @@ -154,8 +151,7 @@ enum OIDC4VCType {
final List<String> grantTypesSupported;
final List<String> credentialSupported;
final bool schemaForType;
final String oidc4VciDraft;
final String siopv2Draft;
final bool publicJWKNeeded;
final String serviceDocumentation;
}

Expand All @@ -175,8 +171,7 @@ extension OIDC4VCTypeX on OIDC4VCType {
grantTypesSupported: grantTypesSupported,
credentialSupported: credentialSupported,
schemaForType: schemaForType,
oidc4VciDraft: oidc4VciDraft,
siopv2Draft: siopv2Draft,
publicJWKNeeded: publicJWKNeeded,
serviceDocumentation: serviceDocumentation,
),
);
Expand All @@ -190,18 +185,27 @@ extension OIDC4VCTypeX on OIDC4VCType {
return 'EBSI-V2';
case OIDC4VCType.EBSIV3:
return 'EBSI-V3';
case OIDC4VCType.ARF:
return 'ARF';
case OIDC4VCType.JWTVC:
return 'JWT-VC';
}
}

int get index {
switch (this) {
case OIDC4VCType.DEFAULT:
return 2;
case OIDC4VCType.EBSIV2:
case OIDC4VCType.EBSIV3:
case OIDC4VCType.JWTVC:
return 1;
}
}

bool get isEnabled {
switch (this) {
case OIDC4VCType.DEFAULT:
case OIDC4VCType.EBSIV2:
case OIDC4VCType.ARF:
//case OIDC4VCType.ARF:
return true;
case OIDC4VCType.EBSIV3:
case OIDC4VCType.JWTVC:
Expand Down
3 changes: 3 additions & 0 deletions lib/app/view/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class App extends StatelessWidget {
didKitProvider: DIDKitProvider(),
secureStorageProvider: secure_storage.getSecureStorage,
profileCubit: context.read<ProfileCubit>(),
didCubit: context.read<DIDCubit>(),
),
),
BlocProvider<QRCodeScanCubit>(
Expand All @@ -160,6 +161,8 @@ class App extends StatelessWidget {
walletConnectCubit: context.read<WalletConnectCubit>(),
secureStorageProvider: secure_storage.getSecureStorage,
polygonIdCubit: context.read<PolygonIdCubit>(),
didCubit: context.read<DIDCubit>(),
didKitProvider: DIDKitProvider(),
),
),
BlocProvider(
Expand Down
12 changes: 10 additions & 2 deletions lib/dashboard/drawer/src/widgets/drawer_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ class DrawerItem extends StatelessWidget {
const DrawerItem({
super.key,
required this.title,
this.isDisabled = false,
this.onTap,
this.trailing,
});

final bool isDisabled;
final Widget? trailing;
final String title;
final VoidCallback? onTap;
Expand All @@ -35,7 +37,11 @@ class DrawerItem extends StatelessWidget {
Expanded(
child: Text(
title,
style: Theme.of(context).textTheme.drawerItem,
style: Theme.of(context).textTheme.drawerItem.copyWith(
color: isDisabled
? Theme.of(context).colorScheme.lightGrey
: null,
),
),
),
if (trailing != null)
Expand All @@ -45,7 +51,9 @@ class DrawerItem extends StatelessWidget {
Icon(
Icons.chevron_right,
size: 26,
color: Theme.of(context).colorScheme.unSelectedLabel,
color: isDisabled
? Theme.of(context).colorScheme.lightGrey
: Theme.of(context).colorScheme.unSelectedLabel,
)
],
],
Expand Down
10 changes: 6 additions & 4 deletions lib/dashboard/drawer/ssi/manage_did/manage_did.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export 'cubit/did_private_key_cubit.dart';
export 'cubit/did_private_key_dialog_cubit.dart';
export 'view/did/did_private_key_page.dart';
export 'view/did/manage_did_page.dart';
export 'view/did_ebsi/did_ebsi_private_key_page.dart';
export 'view/did_ebsi/manage_did_ebsi_page.dart';
export 'view/did_ebsi_v2/did_ebsi_v2_private_key_page.dart';
export 'view/did_ebsi_v2/manage_did_ebsi_v2_page.dart';
export 'view/did_edDSA/did_edDSA_private_key_page.dart';
export 'view/did_edDSA/manage_did_edDSA_page.dart';
export 'view/did_polygon_id/manage_did_polygon_id_page.dart';
export 'view/did_secp256k1/did_secp256k1_private_key_page.dart';
export 'view/did_secp256k1/manage_did_secp256k1_page.dart';
export 'widgets/widgets.dart';
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:altme/theme/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:secure_storage/secure_storage.dart';

class DidEbsiPrivateKeyPage extends StatefulWidget {
const DidEbsiPrivateKeyPage({super.key});
class DidEbsiV2PrivateKeyPage extends StatefulWidget {
const DidEbsiV2PrivateKeyPage({super.key});

static Route<dynamic> route() {
return MaterialPageRoute<void>(
builder: (_) => const DidEbsiPrivateKeyPage(),
settings: const RouteSettings(name: '/DidEbsiPrivateKeyPage'),
builder: (_) => const DidEbsiV2PrivateKeyPage(),
settings: const RouteSettings(name: '/DidEbsiV2PrivateKeyPage'),
);
}

@override
State<DidEbsiPrivateKeyPage> createState() => _DidEbsiPrivateKeyPageState();
State<DidEbsiV2PrivateKeyPage> createState() =>
_DidEbsiV2PrivateKeyPageState();
}

class _DidEbsiPrivateKeyPageState extends State<DidEbsiPrivateKeyPage>
class _DidEbsiV2PrivateKeyPageState extends State<DidEbsiV2PrivateKeyPage>
with SingleTickerProviderStateMixin {
late Animation<double> animation;
late AnimationController animationController;

Future<String> getPrivateKey() async {
final oidc4vc =
context.read<ProfileCubit>().state.model.oidc4vcType.getOIDC4VC;
final oidc4vc = OIDC4VCType.EBSIV2.getOIDC4VC;
final mnemonic = await getSecureStorage.get(SecureStorageKeys.ssiMnemonic);
final privateKey =
await oidc4vc.privateKeyFromMnemonic(mnemonic: mnemonic!);
final privateKey = await oidc4vc.privateKeyFromMnemonic(
mnemonic: mnemonic!,
index: OIDC4VCType.EBSIV2.index,
);
return privateKey;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/ebsi/initiate_ebsi_credential_issuance.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:fast_base58/fast_base58.dart';
import 'package:flutter/material.dart';
import 'package:secure_storage/secure_storage.dart';

class ManageDidEbsiV2Page extends StatefulWidget {
const ManageDidEbsiV2Page({super.key});

static Route<dynamic> route() {
return MaterialPageRoute<void>(
builder: (_) => const ManageDidEbsiV2Page(),
settings: const RouteSettings(name: '/ManageDidEbsiV2Page'),
);
}

@override
State<ManageDidEbsiV2Page> createState() => _ManageDidEbsiPageState();
}

class _ManageDidEbsiPageState extends State<ManageDidEbsiV2Page> {
Future<String> getDid() async {
final oidc4vc = OIDC4VCType.EBSIV2.getOIDC4VC;
final mnemonic = await getSecureStorage.get(SecureStorageKeys.ssiMnemonic);

final privateKey = await oidc4vc.privateKeyFromMnemonic(
mnemonic: mnemonic!,
index: OIDC4VCType.EBSIV2.index,
);

final private = await oidc4vc.getPrivateKey(mnemonic, privateKey);

final thumbprint = getThumbprint(private);
final encodedAddress = Base58Encode([2, ...thumbprint]);
return 'did:ebsi:z$encodedAddress';
}

@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return BasePage(
title: l10n.manageEbsiV2DecentralizedId,
titleAlignment: Alignment.topCenter,
scrollView: false,
titleLeading: const BackLeadingButton(),
body: BackgroundCard(
height: double.infinity,
width: double.infinity,
padding: const EdgeInsets.all(Sizes.spaceSmall),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
FutureBuilder<String>(
future: getDid(),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.done:
final did = snapshot.data!;
return Did(did: did);
case ConnectionState.waiting:
case ConnectionState.none:
case ConnectionState.active:
return const SizedBox();
}
},
),
const Padding(
padding: EdgeInsets.symmetric(horizontal: Sizes.spaceNormal),
child: Divider(),
),
DidPrivateKey(route: DidEbsiV2PrivateKeyPage.route()),
],
),
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class DIDPrivateKeyPage extends StatelessWidget {
const DIDPrivateKeyPage({super.key});
class DIDEdDSAPrivateKeyPage extends StatelessWidget {
const DIDEdDSAPrivateKeyPage({super.key});

static Route<dynamic> route() {
return MaterialPageRoute<void>(
builder: (_) => const DIDPrivateKeyPage(),
settings: const RouteSettings(name: '/DIDPrivateKeyPage'),
builder: (_) => const DIDEdDSAPrivateKeyPage(),
settings: const RouteSettings(name: '/DIDEdDSAPrivateKeyPage'),
);
}

Expand Down
Loading

0 comments on commit 5785731

Please sign in to comment.