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 all 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.

Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,20 @@ public void setAttestationObject(@NonNull String setterArg) {
this.attestationObject = setterArg;
}

/** The supported transports for the authenticator */
private @NonNull List<String> transports;

public @NonNull List<String> getTransports() {
return transports;
}

public void setTransports(@NonNull List<String> setterArg) {
if (setterArg == null) {
throw new IllegalStateException("Nonnull field \"transports\" is null.");
}
this.transports = setterArg;
}

/** Constructor is non-public to enforce null safety; use Builder. */
RegisterResponse() {}

Expand Down Expand Up @@ -741,23 +755,32 @@ public static final class Builder {
return this;
}

private @Nullable List<String> transports;

public @NonNull Builder setTransports(@NonNull List<String> setterArg) {
this.transports = setterArg;
return this;
}

public @NonNull RegisterResponse build() {
RegisterResponse pigeonReturn = new RegisterResponse();
pigeonReturn.setId(id);
pigeonReturn.setRawId(rawId);
pigeonReturn.setClientDataJSON(clientDataJSON);
pigeonReturn.setAttestationObject(attestationObject);
pigeonReturn.setTransports(transports);
return pigeonReturn;
}
}

@NonNull
ArrayList<Object> toList() {
ArrayList<Object> toListResult = new ArrayList<Object>(4);
ArrayList<Object> toListResult = new ArrayList<Object>(5);
toListResult.add(id);
toListResult.add(rawId);
toListResult.add(clientDataJSON);
toListResult.add(attestationObject);
toListResult.add(transports);
return toListResult;
}

Expand All @@ -771,6 +794,8 @@ ArrayList<Object> toList() {
pigeonResult.setClientDataJSON((String) clientDataJSON);
Object attestationObject = list.get(3);
pigeonResult.setAttestationObject((String) attestationObject);
Object transports = list.get(4);
pigeonResult.setTransports((List<String>) transports);
return pigeonResult;
}
}
Expand Down
6 changes: 6 additions & 0 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<Object?>?)!.cast<String?>(),
);
}
}
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.whereType<String>().toList(),
);
}

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;
}

/// Represents an authenticate response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class RegisterController: NSObject, ASAuthorizationControllerDelegate, ASAuthori
id: credentialRegistration.credentialID.toBase64URL(),
rawId: credentialRegistration.credentialID.toBase64URL(),
clientDataJSON: credentialRegistration.rawClientDataJSON.toBase64URL(),
attestationObject: credentialRegistration.rawAttestationObject!.toBase64URL()
attestationObject: credentialRegistration.rawAttestationObject!.toBase64URL(),
transports: credentialRegistration.transports
)
completion?(.success(response))
break
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[4] 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
6 changes: 6 additions & 0 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<Object?>?)!.cast<String?>(),
);
}
}
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.whereType<String>().toList(),
);
}

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;
}
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);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/passkeys/passkeys_web/lib/passkeys_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class PasskeysWeb extends PasskeysPlatform {
rawId: typedResponse.rawId,
clientDataJSON: typedResponse.response.clientDataJSON,
attestationObject: typedResponse.response.attestationObject,
transports: typedResponse.response.transports,
);
} catch (e) {
final exception = _parseException(e as String);
Expand Down