generated from fission-codes/project-template
-
Notifications
You must be signed in to change notification settings - Fork 24
/
local.ts
46 lines (38 loc) · 936 Bytes
/
local.ts
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
41
42
43
44
45
46
import * as Crypto from "../components/crypto/implementation.js"
import { publicKeyToDid } from "./transformers.js"
/**
* Create a DID based on the exchange key-pair.
*/
export async function exchange(crypto: Crypto.Implementation): Promise<string> {
const pubKey = await crypto.keystore.publicExchangeKey()
const ksAlg = await crypto.keystore.getAlgorithm()
return publicKeyToDid(
crypto,
pubKey,
ksAlg
)
}
/**
* Create a DID based on the write key-pair.
*/
export async function write(crypto: Crypto.Implementation): Promise<string> {
const pubKey = await crypto.keystore.publicWriteKey()
const ksAlg = await crypto.keystore.getAlgorithm()
return publicKeyToDid(
crypto,
pubKey,
ksAlg
)
}
/**
* Alias `exchange` to `sharing`
*/
export { exchange as sharing }
/**
* Alias `write` to `agent`
*/
export { write as agent }
/**
* Alias `write` to `ucan`
*/
export { write as ucan }