Skip to content

Commit

Permalink
Specifying kms is required when converting an account to a key.
Browse files Browse the repository at this point in the history
Fix: Pass default kms when creating a key
  • Loading branch information
jasny committed Jul 21, 2023
1 parent f6f8c4b commit 37c1535
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function ofIdentifier(identifier: IIdentifier): IAccountIn {
return ofKey(managementKey);
}

export function accountAsKey(account: Account, { kms, type }: { kms?: string; type?: 'sign' | 'encrypt' }): IKey {
export function accountAsKey(account: Account, { kms, type }: { kms: string; type?: 'sign' | 'encrypt' }): IKey {
type ??= 'sign';
let keyType: TKeyType;
let keyPair: IKeyPairBytes;
Expand All @@ -42,7 +42,7 @@ export function accountAsKey(account: Account, { kms, type }: { kms?: string; ty

return {
kid: `${account.did}#${type}`,
kms: kms || 'kms',
kms: kms,
privateKeyHex: keyPair.privateKey?.hex,
publicKeyHex: keyPair.publicKey.hex,
type: keyType,
Expand Down
4 changes: 2 additions & 2 deletions src/lto-did-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class LtoDIDProvider extends AbstractIdentifierProvider {
): Promise<IKey> {
if (!account.signKey.privateKey) throw new Error('Account does not have a private key');

const key = accountAsKey(account, { kms, type: 'sign' }) as Required<IKey>;
const key = accountAsKey(account, { kms: kms || this.defaultKms }) as Required<IKey>;
return await context.agent.keyManagerImport(key);
}

Expand All @@ -119,7 +119,7 @@ export class LtoDIDProvider extends AbstractIdentifierProvider {
): Promise<IKey> {
if (!account.encryptKey.privateKey) throw new Error('Account does not have a private encryption key');

const key = accountAsKey(account, { kms, type: 'encrypt' }) as Required<IKey>;
const key = accountAsKey(account, { kms: kms || this.defaultKms, type: 'encrypt' }) as Required<IKey>;
return await context.agent.keyManagerImport(key);
}

Expand Down

0 comments on commit 37c1535

Please sign in to comment.