Skip to content

Commit

Permalink
fix: fix backward compatibility for did registry interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Harasz committed May 17, 2022
1 parent 434e262 commit a24a91c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
35 changes: 14 additions & 21 deletions src/modules/did-registry/did-registry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,11 @@ export class DidRegistry {
* @param {GetDIDDocumentOptions} options object with options
* @return DID document
*/
async getDidDocument(
{ did, includeClaims }: GetDIDDocumentOptions = {
did: this._did,
includeClaims: true,
}
): Promise<IDIDDocument> {
async getDidDocument({
did = this._did,
includeClaims = true,
}: GetDIDDocumentOptions = {}): Promise<IDIDDocument> {
getLogger().info(`Getting DID document for ${did}`);
if (this._cacheClient) {
try {
const didDoc = await this._cacheClient.getDidDocument(
Expand Down Expand Up @@ -179,11 +178,9 @@ export class DidRegistry {
* @param {GetServicesOptions} options object with options
* @returns list of claims
*/
async getServices(
{ did }: GetServicesOptions = {
did: this._signerService.did,
}
): Promise<IServiceEndpoint[]> {
async getServices({
did = this._signerService.did,
}: GetServicesOptions = {}): Promise<IServiceEndpoint[]> {
const didDocument = await this.getDidDocument({ did });
return didDocument?.service;
}
Expand All @@ -199,11 +196,9 @@ export class DidRegistry {
* @param {GetDidPublicKeysOptions} options object with options
* @returns list of public keys
*/
async getDidPublicKeys(
{ did }: GetDidPublicKeysOptions = {
did: this._signerService.did,
}
): Promise<IPublicKey[]> {
async getDidPublicKeys({
did = this._signerService.did,
}: GetDidPublicKeysOptions = {}): Promise<IPublicKey[]> {
const didDocument = await this.getDidDocument({ did });
return didDocument?.publicKey;
}
Expand All @@ -219,11 +214,9 @@ export class DidRegistry {
* @param {GetDidDelegatesOptions} options object with options
* @returns list of delegates
*/
async getDidDelegates(
{ did }: GetDidDelegatesOptions = {
did: this._did,
}
): Promise<string[] | undefined> {
async getDidDelegates({
did = this._signerService.did,
}: GetDidDelegatesOptions = {}): Promise<string[] | undefined> {
const didDocument = await this.getDidDocument({ did });
return didDocument?.delegates;
}
Expand Down
6 changes: 3 additions & 3 deletions src/modules/did-registry/did.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ export interface GetDIDDocumentOptions {

export interface GetServicesOptions {
/* DID of the user */
did: string;
did?: string;
}

export interface GetDidPublicKeysOptions {
/* DID of the user */
did: string;
did?: string;
}

export interface GetDidDelegatesOptions {
/* DID of the user */
did: string;
did?: string;
}

export interface CreatePublicClaimOptions {
Expand Down

0 comments on commit a24a91c

Please sign in to comment.