Skip to content

Commit 4471213

Browse files
committed
chore!: do not expose the TD ID via AugmentedForms
1 parent fdc099a commit 4471213

File tree

6 files changed

+14
-29
lines changed

6 files changed

+14
-29
lines changed

example/complex_example.dart

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,15 @@ const thingDescriptionJson = {
7676
};
7777

7878
final Map<String, BasicCredentials> basicCredentials = {
79-
"urn:test": const BasicCredentials("username", "password"),
79+
"httpbin.org": const BasicCredentials("username", "password"),
8080
};
8181

8282
Future<BasicCredentials?> basicCredentialsCallback(
8383
Uri uri,
84-
AugmentedForm? form, [
84+
AugmentedForm? form,
8585
BasicCredentials? invalidCredentials,
86-
]) async {
87-
final id = form?.tdIdentifier;
88-
89-
return basicCredentials[id];
90-
}
86+
) async =>
87+
basicCredentials[uri.authority];
9188

9289
Future<void> main() async {
9390
final coapClientFactory = CoapClientFactory(

example/http_basic_authentication.dart

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,15 @@ const thingDescriptionJson = {
3838
const basicCredentials = BasicCredentials("username", "password");
3939

4040
final Map<String, BasicCredentials> basicCredentialsMap = {
41-
"urn:test": basicCredentials,
41+
"httpbin.org": basicCredentials,
4242
};
4343

4444
Future<BasicCredentials?> basicCredentialsCallback(
4545
Uri uri,
4646
AugmentedForm? form,
4747
BasicCredentials? invalidCredentials,
48-
) async {
49-
if (form == null) {
50-
return basicCredentials;
51-
}
52-
53-
final id = form.tdIdentifier;
54-
55-
return basicCredentialsMap[id];
56-
}
48+
) async =>
49+
basicCredentialsMap[uri.authority];
5750

5851
/// Illustrates the usage of both the basic and the automatic security scheme,
5952
/// with a server supporting basic authentication.

example/mqtt_example.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,18 @@ const thingDescriptionJson = {
4646
};
4747

4848
final Map<String, BasicCredentials> basicCredentials = {
49-
"urn:test": const BasicCredentials("rw", "readwrite"),
49+
"test.mosquitto.org:1884": const BasicCredentials(
50+
"rw",
51+
"readwrite",
52+
),
5053
};
5154

5255
Future<BasicCredentials?> basicCredentialsCallback(
5356
Uri uri,
5457
AugmentedForm? form, [
5558
BasicCredentials? invalidCredentials,
56-
]) async {
57-
final id = form?.tdIdentifier;
58-
59-
return basicCredentials[id];
60-
}
59+
]) async =>
60+
basicCredentials[uri.authority];
6161

6262
Future<void> main(List<String> args) async {
6363
final servient = Servient.create(

lib/src/binding_mqtt/mqtt_extensions.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ extension MqttFormExtension on AugmentedForm {
140140
if (qosValue != null) {
141141
throw FormatException(
142142
"Encountered unknown QoS value $qosValue. "
143-
"in form with href $href of Thing Description with Identifier "
144-
"$tdIdentifier.",
143+
"in form with resolved href $resolvedHref.",
145144
);
146145
}
147146

lib/src/core/implementation/augmented_form.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ final class AugmentedForm implements Form {
3131

3232
final Map<String, Object>? _userProvidedUriVariables;
3333

34-
/// The identifier of the [_thingDescription] associated with this form.
35-
String get tdIdentifier => _thingDescription.identifier;
36-
3734
@override
3835
Map<String, dynamic> get additionalFields => _form.additionalFields;
3936

test/core/augmented_form_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ void main() {
6363
expect(augmentedForm.href, Uri.parse(href));
6464
expect(augmentedForm.security, ["nosec_sc"]);
6565
expect(augmentedForm.securityDefinitions.first, isA<NoSecurityScheme>());
66-
expect(augmentedForm.tdIdentifier, id);
6766
expect(
6867
augmentedForm.additionalResponses?.first.contentType,
6968
"application/json",

0 commit comments

Comments
 (0)