UNPKG

746 BPlain TextView Raw
1import * as crypto from '../crypto/index'
2import { publicKeyToDid } from './transformers'
3import { toKeyType } from './util'
4
5
6/**
7 * Create a DID based on the exchange key-pair.
8 */
9export async function exchange(): Promise<string> {
10 const pubKeyB64 = await crypto.keystore.publicReadKey()
11 const ksAlg = await crypto.keystore.getAlg()
12
13 return publicKeyToDid(
14 pubKeyB64,
15 toKeyType(ksAlg)
16 )
17}
18
19/**
20 * Alias `write` to `ucan`
21 */
22export { write as ucan }
23
24/**
25 * Create a DID based on the write key-pair.
26 */
27export async function write(): Promise<string> {
28 const pubKeyB64 = await crypto.keystore.publicWriteKey()
29 const ksAlg = await crypto.keystore.getAlg()
30
31 return publicKeyToDid(
32 pubKeyB64,
33 toKeyType(ksAlg)
34 )
35}