summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/decodeCredentialPublicKey.ts
blob: 12ff2987c48cec6a35237a19964c2ca61fb125e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { COSEPublicKey } from './cose.ts';
import { isoCBOR } from './iso/index.ts';

export function decodeCredentialPublicKey(
  publicKey: Uint8Array,
): COSEPublicKey {
  return _decodeCredentialPublicKeyInternals.stubThis(
    isoCBOR.decodeFirst<COSEPublicKey>(publicKey),
  );
}

// Make it possible to stub the return value during testing
export const _decodeCredentialPublicKeyInternals = {
  stubThis: (value: COSEPublicKey) => value,
};