All files / src/CommonNetworkMember PublicTools.ts

50% Statements 3/6
100% Branches 0/0
0% Functions 0/2
50% Lines 3/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40  1x     1x     1x                                                                
import { EventComponent } from '@affinidi/affinity-metrics-lib'
import { Affinity } from '@affinidi/common'
import { SimpleThing, VCV1, VCV1Subject } from '@affinidi/vc-common'
import { SdkOptions } from '../dto'
import { getOptionsFromEnvironment } from '../shared/getOptionsFromEnvironment'
import { IPlatformCryptographyTools } from '../shared/interfaces'
 
export class PublicTools {
  private readonly affinidi
 
  constructor(
    platformCryptographyTools: IPlatformCryptographyTools,
    inputOptions: SdkOptions,
    component: EventComponent,
  ) {
    const {
      accessApiKey,
      basicOptions: { metricsUrl, registryUrl },
    } = getOptionsFromEnvironment(inputOptions)
 
    this.affinidi = new Affinity(
      {
        apiKey: accessApiKey,
        component,
        metricsUrl,
        registryUrl,
      },
      platformCryptographyTools,
    )
  }
 
  deriveSegmentProof<TKeys extends string, TData extends SimpleThing & Record<TKeys, unknown>>(
    credential: VCV1<VCV1Subject<TData>>,
    fields: string[],
    didDocument?: any,
  ) {
    return this.affinidi.deriveSegmentProof(credential, fields, didDocument)
  }
}