Skip to content

Commit

Permalink
Update packages/dids/src/methods/did-dht.ts
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Tsai <[email protected]>
  • Loading branch information
nitro-neal and thehenrytsai authored May 2, 2024
1 parent 07dea7e commit 847ecb1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/dids/src/methods/did-dht.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,13 @@ export class DidDhtDocument {
const publicKeyBase64Url = Convert.uint8Array(publicKeyBytes).toBase64Url();

// Define the data for the DNS TXT record.
const txtData = [`id=${methodId}`, `t=${keyType}`, `k=${publicKeyBase64Url}`, ...(alg ? [`a=${alg}`] : [])];
const txtData = [`id=${methodId}`, `t=${keyType}`, `k=${publicKeyBase64Url}`];

// Only set the algorithm property (`a`) if it differs from the default algorithm for the key type.
const algorithmUsedByKey = getJoseSignatureAlgorithmFromPublicKey(publicKey);
if(algorithmUsedByKey !== KeyTypeToDefaultAlgorithmMap[keyType]) {
txtData.push(`a=${algorithmUsedByKey}`);
}

// Add the controller property, if set to a value other than the Identity Key (DID Subject).
if (vm.controller !== didDocument.id) txtData.push(`c=${vm.controller}`);
Expand Down

0 comments on commit 847ecb1

Please sign in to comment.