Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
didEvents.ts 1.17 KiB
import type { BaseEventInput } from './baseEvents.js';

import { DidDocument, JsonTransformer } from '@aries-framework/core';

import { BaseEvent } from './baseEvents.js';

/**
 *
 * @todo: this should be removed as it is a weird event that should not be needed
 *
 */
export type EventDidsPublicDidInput = BaseEventInput;
/**
 *
 * @todo: this should be removed as it is a weird event that should not be needed
 *
 */
export class EventDidsPublicDid extends BaseEvent<DidDocument> {
  public static token = 'dids.publicDid';

  public get instance() {
    return JsonTransformer.fromJSON(this.data, DidDocument);
  }

  public static fromEvent(e: EventDidsPublicDid) {
    return new EventDidsPublicDid(
      e.data,
      e.tenantId,
      e.id,
      e.type,
      e.timestamp,
    );
  }
}

export type EventDidsResolveInput = BaseEventInput<{ did: string }>;
export class EventDidsResolve extends BaseEvent<DidDocument> {
  public static token = 'dids.resolve';

  public get instance() {
    return JsonTransformer.fromJSON(this.data, DidDocument);
  }

  public static fromEvent(e: EventDidsResolve) {
    return new EventDidsResolve(e.data, e.tenantId, e.id, e.type, e.timestamp);
  }
}