All files / src _helpers.ts

80% Statements 12/15
0% Branches 0/2
50% Functions 2/4
72.72% Lines 8/11

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 291x 1x       1x   1x                 1x             1x 42x     1048x  
import { SUPPORTED_DID_METHODS } from './_defaultConfig'
import SdkErrorFromCode from './shared/SdkErrorFromCode'
import { CredentialLike, W3cCredentialLike } from './dto/internal'
import { DidMethod } from './dto/shared.dto'
 
const packageInfo = require('../package.json')
 
export const validateDidMethodSupported = (didMethod: DidMethod) => {
  if (!SUPPORTED_DID_METHODS.includes(didMethod)) {
    throw new SdkErrorFromCode('COM-10', {
      didMethod: didMethod,
      supportedDidMethods: SUPPORTED_DID_METHODS.join(', '),
    })
  }
}
 
export const stripParamsFromDidUrl = (did: string): string =>
  did
    // Strip out matrix params
    .replace(/;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*/g, '')
    // Strip out query params
    .replace(/([?][^#]*)?/g, '')
 
export function isW3cCredential(credential: CredentialLike): credential is W3cCredentialLike {
  return !!credential.type
}
 
export const extractSDKVersion = (): string => packageInfo.version