diff --git a/packages/shorebird_code_push_protocol/lib/src/messages/create_patch_artifact/create_patch_artifact_request.dart b/packages/shorebird_code_push_protocol/lib/src/messages/create_patch_artifact/create_patch_artifact_request.dart index ecbeffe9..3878a061 100644 --- a/packages/shorebird_code_push_protocol/lib/src/messages/create_patch_artifact/create_patch_artifact_request.dart +++ b/packages/shorebird_code_push_protocol/lib/src/messages/create_patch_artifact/create_patch_artifact_request.dart @@ -14,6 +14,7 @@ class CreatePatchArtifactRequest { required this.platform, required this.hash, required this.size, + this.hashSignature, }); /// Converts a Map to a [CreatePatchArtifactRequest] @@ -32,6 +33,13 @@ class CreatePatchArtifactRequest { /// The hash of the artifact. final String hash; + /// The signature of the [hash]. + /// + /// Patch code signing is an opt in feature, introduced later in the life of + /// the product, so when this field is null, the patch does not uses code + /// signing. + final String? hashSignature; + /// The size of the artifact in bytes. @JsonKey(fromJson: _parseStringToInt, toJson: _parseIntToString) final int size; diff --git a/packages/shorebird_code_push_protocol/lib/src/messages/create_patch_artifact/create_patch_artifact_request.g.dart b/packages/shorebird_code_push_protocol/lib/src/messages/create_patch_artifact/create_patch_artifact_request.g.dart index ad4af47a..7db1e2ea 100644 --- a/packages/shorebird_code_push_protocol/lib/src/messages/create_patch_artifact/create_patch_artifact_request.g.dart +++ b/packages/shorebird_code_push_protocol/lib/src/messages/create_patch_artifact/create_patch_artifact_request.g.dart @@ -21,9 +21,11 @@ CreatePatchArtifactRequest _$CreatePatchArtifactRequestFromJson( hash: $checkedConvert('hash', (v) => v as String), size: $checkedConvert( 'size', (v) => CreatePatchArtifactRequest._parseStringToInt(v)), + hashSignature: $checkedConvert('hash_signature', (v) => v as String?), ); return val; }, + fieldKeyMap: const {'hashSignature': 'hash_signature'}, ); Map _$CreatePatchArtifactRequestToJson( @@ -32,6 +34,7 @@ Map _$CreatePatchArtifactRequestToJson( 'arch': instance.arch, 'platform': _$ReleasePlatformEnumMap[instance.platform]!, 'hash': instance.hash, + 'hash_signature': instance.hashSignature, 'size': CreatePatchArtifactRequest._parseIntToString(instance.size), }; diff --git a/packages/shorebird_code_push_protocol/test/src/messages/create_patch_artifact/create_patch_artifact_request_test.dart b/packages/shorebird_code_push_protocol/test/src/messages/create_patch_artifact/create_patch_artifact_request_test.dart index d10bb6f1..bf7a5a25 100644 --- a/packages/shorebird_code_push_protocol/test/src/messages/create_patch_artifact/create_patch_artifact_request_test.dart +++ b/packages/shorebird_code_push_protocol/test/src/messages/create_patch_artifact/create_patch_artifact_request_test.dart @@ -15,5 +15,23 @@ void main() { equals(request.toJson()), ); }); + + group('when there is a hash signature', () { + test('can be (de)serialized', () { + const request = CreatePatchArtifactRequest( + arch: 'arm64', + platform: ReleasePlatform.android, + hash: '1234', + hashSignature: 'Shh', + size: 9876, + ); + final instance = CreatePatchArtifactRequest.fromJson(request.toJson()); + expect( + instance.toJson(), + equals(request.toJson()), + ); + expect(instance.hashSignature, equals('Shh')); + }); + }); }); }