Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update register response with transports field #80

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

72 changes: 52 additions & 20 deletions packages/passkeys/passkeys_android/lib/messages.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class RegisterResponse {
required this.rawId,
required this.clientDataJSON,
required this.attestationObject,
required this.transports,
});

/// The ID
Expand All @@ -232,12 +233,16 @@ class RegisterResponse {
/// The attestation object
String attestationObject;

/// The supported transports for the authenticator
List<String> transports;

Object encode() {
return <Object?>[
id,
rawId,
clientDataJSON,
attestationObject,
transports,
];
}

Expand All @@ -248,6 +253,7 @@ class RegisterResponse {
rawId: result[1]! as String,
clientDataJSON: result[2]! as String,
attestationObject: result[3]! as String,
transports: result[4]! as List<String>,
);
}
}
Expand Down Expand Up @@ -340,21 +346,21 @@ class _PasskeysApiCodec extends StandardMessageCodec {
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 128:
case 128:
return AllowCredential.decode(readValue(buffer)!);
case 129:
case 129:
return AuthenticateResponse.decode(readValue(buffer)!);
case 130:
case 130:
return AuthenticatorSelection.decode(readValue(buffer)!);
case 131:
case 131:
return ExcludeCredential.decode(readValue(buffer)!);
case 132:
case 132:
return PubKeyCredParam.decode(readValue(buffer)!);
case 133:
case 133:
return RegisterResponse.decode(readValue(buffer)!);
case 134:
case 134:
return RelyingParty.decode(readValue(buffer)!);
case 135:
case 135:
return User.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
Expand All @@ -374,10 +380,10 @@ class PasskeysApi {

Future<bool> canAuthenticate() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.passkeys_android.PasskeysApi.canAuthenticate', codec,
'dev.flutter.pigeon.passkeys_android.PasskeysApi.canAuthenticate',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(null) as List<Object?>?;
final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
Expand All @@ -399,12 +405,28 @@ class PasskeysApi {
}
}

Future<RegisterResponse> register(String arg_challenge, RelyingParty arg_relyingParty, User arg_user, AuthenticatorSelection arg_authenticatorSelection, List<PubKeyCredParam?>? arg_pubKeyCredParams, int? arg_timeout, String? arg_attestation, List<ExcludeCredential?> arg_excludeCredentials) async {
Future<RegisterResponse> register(
String arg_challenge,
RelyingParty arg_relyingParty,
User arg_user,
AuthenticatorSelection arg_authenticatorSelection,
List<PubKeyCredParam?>? arg_pubKeyCredParams,
int? arg_timeout,
String? arg_attestation,
List<ExcludeCredential?> arg_excludeCredentials) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.passkeys_android.PasskeysApi.register', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_challenge, arg_relyingParty, arg_user, arg_authenticatorSelection, arg_pubKeyCredParams, arg_timeout, arg_attestation, arg_excludeCredentials]) as List<Object?>?;
final List<Object?>? replyList = await channel.send(<Object?>[
arg_challenge,
arg_relyingParty,
arg_user,
arg_authenticatorSelection,
arg_pubKeyCredParams,
arg_timeout,
arg_attestation,
arg_excludeCredentials
]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
Expand All @@ -426,12 +448,22 @@ class PasskeysApi {
}
}

Future<AuthenticateResponse> authenticate(String arg_relyingPartyId, String arg_challenge, int? arg_timeout, String? arg_userVerification, List<AllowCredential?>? arg_allowCredentials) async {
Future<AuthenticateResponse> authenticate(
String arg_relyingPartyId,
String arg_challenge,
int? arg_timeout,
String? arg_userVerification,
List<AllowCredential?>? arg_allowCredentials) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.passkeys_android.PasskeysApi.authenticate', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_relyingPartyId, arg_challenge, arg_timeout, arg_userVerification, arg_allowCredentials]) as List<Object?>?;
final List<Object?>? replyList = await channel.send(<Object?>[
arg_relyingPartyId,
arg_challenge,
arg_timeout,
arg_userVerification,
arg_allowCredentials
]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
Expand All @@ -455,10 +487,10 @@ class PasskeysApi {

Future<void> cancelCurrentAuthenticatorOperation() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.passkeys_android.PasskeysApi.cancelCurrentAuthenticatorOperation', codec,
'dev.flutter.pigeon.passkeys_android.PasskeysApi.cancelCurrentAuthenticatorOperation',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(null) as List<Object?>?;
final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class PasskeysAndroid extends PasskeysPlatform {
rawId: r.rawId,
clientDataJSON: r.clientDataJSON,
attestationObject: r.attestationObject,
transports: r.transports,
);
}

Expand Down
4 changes: 4 additions & 0 deletions packages/passkeys/passkeys_android/pigeons/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class RegisterResponse {
required this.rawId,
required this.clientDataJSON,
required this.attestationObject,
required this.transports,
});

/// The ID
Expand All @@ -117,6 +118,9 @@ class RegisterResponse {

/// The attestation object
final String attestationObject;

/// The supported transports for the authenticator
final List<String> transports;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For pigeon (the library we use to generate the glue code between Flutter and native code) every generic type has to be nullable => we have to use final List<String?> transports here and update line 90 in passkeys_android.dart like this r.transports.whereType<String>().toList().

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

}

/// Represents an authenticate response
Expand Down
7 changes: 6 additions & 1 deletion packages/passkeys/passkeys_ios/ios/Classes/messages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,22 @@ struct RegisterResponse {
var clientDataJSON: String
/// The attestation object
var attestationObject: String
/// The supported transports for the authenticator
var transports: [String]

static func fromList(_ list: [Any?]) -> RegisterResponse? {
let id = list[0] as! String
let rawId = list[1] as! String
let clientDataJSON = list[2] as! String
let attestationObject = list[3] as! String
let transports = list[3] as! [String]

return RegisterResponse(
id: id,
rawId: rawId,
clientDataJSON: clientDataJSON,
attestationObject: attestationObject
attestationObject: attestationObject,
transports: transports
)
}
func toList() -> [Any?] {
Expand All @@ -122,6 +126,7 @@ struct RegisterResponse {
rawId,
clientDataJSON,
attestationObject,
transports,
]
}
}
Expand Down
53 changes: 38 additions & 15 deletions packages/passkeys/passkeys_ios/lib/messages.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class RegisterResponse {
required this.rawId,
required this.clientDataJSON,
required this.attestationObject,
required this.transports,
});

/// The ID
Expand All @@ -87,12 +88,16 @@ class RegisterResponse {
/// The attestation object
String attestationObject;

/// The supported transports for the authenticator
List<String> transports;

Object encode() {
return <Object?>[
id,
rawId,
clientDataJSON,
attestationObject,
transports,
];
}

Expand All @@ -103,6 +108,7 @@ class RegisterResponse {
rawId: result[1]! as String,
clientDataJSON: result[2]! as String,
attestationObject: result[3]! as String,
transports: result[4]! as List<String>,
);
}
}
Expand Down Expand Up @@ -183,13 +189,13 @@ class _PasskeysApiCodec extends StandardMessageCodec {
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 128:
case 128:
return AuthenticateResponse.decode(readValue(buffer)!);
case 129:
case 129:
return RegisterResponse.decode(readValue(buffer)!);
case 130:
case 130:
return RelyingParty.decode(readValue(buffer)!);
case 131:
case 131:
return User.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
Expand All @@ -211,8 +217,7 @@ class PasskeysApi {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.passkeys_ios.PasskeysApi.canAuthenticate', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(null) as List<Object?>?;
final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
Expand All @@ -234,12 +239,20 @@ class PasskeysApi {
}
}

Future<RegisterResponse> register(String arg_challenge, RelyingParty arg_relyingParty, User arg_user, List<String?> arg_excludeCredentialIDs) async {
Future<RegisterResponse> register(
String arg_challenge,
RelyingParty arg_relyingParty,
User arg_user,
List<String?> arg_excludeCredentialIDs) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.passkeys_ios.PasskeysApi.register', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_challenge, arg_relyingParty, arg_user, arg_excludeCredentialIDs]) as List<Object?>?;
final List<Object?>? replyList = await channel.send(<Object?>[
arg_challenge,
arg_relyingParty,
arg_user,
arg_excludeCredentialIDs
]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
Expand All @@ -261,12 +274,22 @@ class PasskeysApi {
}
}

Future<AuthenticateResponse> authenticate(String arg_relyingPartyId, String arg_challenge, bool arg_conditionalUI, List<String?> arg_allowedCredentialIDs, bool arg_preferImmediatelyAvailableCredentials) async {
Future<AuthenticateResponse> authenticate(
String arg_relyingPartyId,
String arg_challenge,
bool arg_conditionalUI,
List<String?> arg_allowedCredentialIDs,
bool arg_preferImmediatelyAvailableCredentials) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.passkeys_ios.PasskeysApi.authenticate', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_relyingPartyId, arg_challenge, arg_conditionalUI, arg_allowedCredentialIDs, arg_preferImmediatelyAvailableCredentials]) as List<Object?>?;
final List<Object?>? replyList = await channel.send(<Object?>[
arg_relyingPartyId,
arg_challenge,
arg_conditionalUI,
arg_allowedCredentialIDs,
arg_preferImmediatelyAvailableCredentials
]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
Expand All @@ -290,10 +313,10 @@ class PasskeysApi {

Future<void> cancelCurrentAuthenticatorOperation() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.passkeys_ios.PasskeysApi.cancelCurrentAuthenticatorOperation', codec,
'dev.flutter.pigeon.passkeys_ios.PasskeysApi.cancelCurrentAuthenticatorOperation',
codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(null) as List<Object?>?;
final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
Expand Down
1 change: 1 addition & 0 deletions packages/passkeys/passkeys_ios/lib/passkeys_ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class PasskeysIOS extends PasskeysPlatform {
rawId: r.rawId,
clientDataJSON: r.clientDataJSON,
attestationObject: r.attestationObject,
transports: r.transports,
);
}

Expand Down
4 changes: 4 additions & 0 deletions packages/passkeys/passkeys_ios/pigeons/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class RegisterResponse {
required this.rawId,
required this.clientDataJSON,
required this.attestationObject,
required this.transports,
});

/// The ID
Expand All @@ -51,6 +52,9 @@ class RegisterResponse {

/// The attestation object
final String attestationObject;

/// The supported transports for the authenticator
final List<String> transports;
}

/// Represents an authenticate response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ class RegisterResponseType {
required this.rawId,
required this.clientDataJSON,
required this.attestationObject,
required this.transports,
});

final String id;
final String rawId;
final String clientDataJSON;
final String attestationObject;
final List<String> transports;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar as with passkeys_android we have to use List<String?> here => you also have to set this new transport field in RegisterController.swift then.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, although please check the Swift code if possible.

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ class AttestationResponse {
factory AttestationResponse.fromJson(Map<String, dynamic> json) =>
_$AttestationResponseFromJson(json);

AttestationResponse(this.clientDataJSON, this.attestationObject);
AttestationResponse(
this.clientDataJSON,
this.attestationObject,
this.transports,
);

final String clientDataJSON;
final String attestationObject;
final List<String> transports;

Map<String, dynamic> toJson() => _$AttestationResponseToJson(this);
}
Loading