Skip to content

Commit

Permalink
Rename InstanceUrl to DidDomainName (#723)
Browse files Browse the repository at this point in the history
* chore: rename InstanceUrl to DidDomainName
  • Loading branch information
tnotheis authored Jul 2, 2024
1 parent 5644ee7 commit a6ae55c
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .ci/appsettings.override.postgres.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"Devices": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down Expand Up @@ -70,7 +70,7 @@
},
"Messages": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
4 changes: 2 additions & 2 deletions .ci/appsettings.override.sqlserver.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"Devices": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down Expand Up @@ -70,7 +70,7 @@
},
"Messages": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
2 changes: 1 addition & 1 deletion AdminApi/src/AdminApi/appsettings.override.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"Devices": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"Devices": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ public static bool IsValid(string? stringValue)
return checksumIsValid;
}

public static IdentityAddress Create(byte[] publicKey, string instanceUrl)
public static IdentityAddress Create(byte[] publicKey, string didDomainName)
{
var hashedPublicKey = SHA256.HashData(SHA512.HashData(publicKey))[..10];

var identitySpecificPart = Hex(hashedPublicKey);

var mainPhrase = $"did:e:{instanceUrl}:dids:{identitySpecificPart}";
var mainPhrase = $"did:e:{didDomainName}:dids:{identitySpecificPart}";
var checksum = CalculateChecksum(mainPhrase);

return new IdentityAddress((mainPhrase + checksum).ToLower());
Expand Down Expand Up @@ -124,7 +124,7 @@ public static implicit operator IdentityAddress(string stringValue)
return ParseUnsafe(stringValue);
}

[GeneratedRegex($@"^(?<addressWithoutChecksum>did:e:(?<instanceUrl>(?:[a-z0-9]+\.)*[a-z]{{2,}}):dids:(?<identitySpecificPart>[0-9a-f]{{20}}))(?<checksum>[0-9a-f]{{{CHECKSUM_LENGTH_S}}})$")]
[GeneratedRegex($@"^(?<addressWithoutChecksum>did:e:(?<didDomainName>(?:[a-z0-9]+\.)*[a-z]{{2,}}):dids:(?<identitySpecificPart>[0-9a-f]{{20}}))(?<checksum>[0-9a-f]{{{CHECKSUM_LENGTH_S}}})$")]
private static partial Regex IdentityAddressValidatorRegex();

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void IsValidReturnsFalseForInvalidAddress(string identityAddress)
public void AddressIsCreatedCorrectly()
{
var testData = TestData.Valid();
var address = IdentityAddress.Create(testData.PublicKey, testData.InstanceUrl);
var address = IdentityAddress.Create(testData.PublicKey, testData.DidDomainName);

address.Value.Should().Be(testData.Address);
}
Expand All @@ -56,7 +56,7 @@ public void AddressIsCreatedCorrectly()
public void EfConverterWorksCorrectly()
{
var testData = TestData.Valid();
var address = IdentityAddress.Create(testData.PublicKey, testData.InstanceUrl);
var address = IdentityAddress.Create(testData.PublicKey, testData.DidDomainName);

address.Value.Should().Be(testData.Address);
}
Expand Down Expand Up @@ -91,7 +91,7 @@ public void AddressesWithInvalidMainPartAreDeclined()

internal class TestData
{
public required string InstanceUrl { get; set; }
public required string DidDomainName { get; set; }
public required byte[] PublicKey { get; set; }

public required string Address { get; set; }
Expand All @@ -105,7 +105,7 @@ public static TestData Valid()
Address = "did:e:prod.enmeshed.eu:dids:56b3f2a0c202e27229aa87",
PublicKey = Convert.FromBase64String("tB9KFp/YqHrom3m5qUuZsd6l30DkaNjN14SxRw7YZuI="),
Checksum = "87",
InstanceUrl = "prod.enmeshed.eu"
DidDomainName = "prod.enmeshed.eu"
};
}

Expand All @@ -116,7 +116,7 @@ public static TestData WithInvalidMainPart()
Address = "did:e:prod.enmeshed.eu:dids:56b3f2a0c202e27d39aa87",
PublicKey = Convert.FromBase64String("tB9KFp/YqHrom3m5qUuZsd6l30DkaNjN14SxRw7YZuI="),
Checksum = "87",
InstanceUrl = "prod.enmeshed.eu"
DidDomainName = "prod.enmeshed.eu"
};
}

Expand All @@ -127,7 +127,7 @@ public static TestData WithInvalidChecksum()
Address = "did:e:prod.enmeshed.eu:dids:56b3f2a0c202e27229aa55",
PublicKey = Convert.FromBase64String("tB9KFp/YqHrom3m5qUuZsd6l30DkaNjN14SxRw7YZuI="),
Checksum = "55",
InstanceUrl = "prod.enmeshed.eu"
DidDomainName = "prod.enmeshed.eu"
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"Devices": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand All @@ -38,7 +38,7 @@
},
"Messages": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
4 changes: 2 additions & 2 deletions ConsumerApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"Devices": {
"Application": {
"InstanceUrl": "localhost",
"DidDomainName": "localhost",
"Pagination": {
"DefaultPageSize": 50,
"MaxPageSize": 200
Expand All @@ -45,7 +45,7 @@
},
"Messages": {
"Application": {
"InstanceUrl": "localhost",
"DidDomainName": "localhost",
"MaxNumberOfUnreceivedMessagesFromOneSender": 20,
"Pagination": {
"DefaultPageSize": 50,
Expand Down
4 changes: 2 additions & 2 deletions ConsumerApi/appsettings.override.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"Devices": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down Expand Up @@ -83,7 +83,7 @@
},
"Messages": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"Devices": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down Expand Up @@ -70,7 +70,7 @@
},
"Messages": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
2 changes: 1 addition & 1 deletion Jobs/src/Job.IdentityDeletion/appsettings.override.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"Devices": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ApplicationOptions
[Required]
[MinLength(3)]
[MaxLength(45)]
public string InstanceUrl { get; set; } = null!;
public string DidDomainName { get; set; } = null!;
}

public class PaginationOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task<CreateIdentityResponse> Handle(CreateIdentityCommand command,

_logger.LogTrace("Challenge successfully validated.");

var address = IdentityAddress.Create(publicKey.Key, _applicationOptions.InstanceUrl);
var address = IdentityAddress.Create(publicKey.Key, _applicationOptions.DidDomainName);

_logger.LogTrace("Address created. Result: '{address}'", address);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public async Task Handle(SeedTestUsersCommand request, CancellationToken cancell
var basicTier = await _tiersRepository.FindBasicTier(cancellationToken);

var user = new ApplicationUser(new Device(new Identity("test",
IdentityAddress.Create([1, 1, 1, 1, 1], _applicationOptions.InstanceUrl),
IdentityAddress.Create([1, 1, 1, 1, 1], _applicationOptions.DidDomainName),
[1, 1, 1, 1, 1], basicTier!.Id, 1
), CommunicationLanguage.DEFAULT_LANGUAGE))
{
Expand All @@ -42,7 +42,7 @@ public async Task Handle(SeedTestUsersCommand request, CancellationToken cancell
await _dbContext.Set<ApplicationUser>().AddAsync(user, cancellationToken);

user = new ApplicationUser(new Device(new Identity("test",
IdentityAddress.Create([2, 2, 2, 2, 2], _applicationOptions.InstanceUrl),
IdentityAddress.Create([2, 2, 2, 2, 2], _applicationOptions.DidDomainName),
[2, 2, 2, 2, 2], basicTier.Id, 1
), CommunicationLanguage.DEFAULT_LANGUAGE))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ApplicationOptions
[Required]
[MinLength(3)]
[MaxLength(45)]
public string InstanceUrl { get; set; } = null!;
public string DidDomainName { get; set; } = null!;
}

public class PaginationOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task Handle(AnonymizeMessagesOfIdentityCommand request, Cancellatio
{
var messages = await _messagesRepository.Find(Message.WasCreatedBy(request.IdentityAddress), cancellationToken);

var newIdentityAddress = IdentityAddress.Create(Encoding.Unicode.GetBytes(DELETED_IDENTITY_STRING), _applicationOptions.InstanceUrl);
var newIdentityAddress = IdentityAddress.Create(Encoding.Unicode.GetBytes(DELETED_IDENTITY_STRING), _applicationOptions.DidDomainName);

foreach (var message in messages)
{
Expand Down
2 changes: 1 addition & 1 deletion SseServer/src/SseServer/appsettings.override.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"Modules": {
"Devices": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose/adminui.appsettings.override.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"Devices": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose/consumerapi.appsettings.override.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"Devices": {
"Application": {
"InstanceUrl": "localhost"
"DidDomainName": "localhost"
},
"Infrastructure": {
"SqlDatabase": {
Expand Down

0 comments on commit a6ae55c

Please sign in to comment.