-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontext.ts
More file actions
36 lines (28 loc) · 977 Bytes
/
Copy pathcontext.ts
File metadata and controls
36 lines (28 loc) · 977 Bytes
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
import { PointsWriter, PointsReader } from '@ceramic-solutions/points'
import { getAuthenticatedDID } from '@ceramic-solutions/key-did'
import { fromString } from 'uint8arrays'
const CERAMIC_PRIVATE_KEY: string = process.env.CERAMIC_PRIVATE_KEY ?? ''
const aggregationModelID: string | undefined = process.env.AGGREGATION_ID ?? undefined
//eslint-disable-next-line
const seed = fromString(CERAMIC_PRIVATE_KEY, 'base16') as Uint8Array
// create a context writer
const contextWriter = await PointsWriter.fromSeed({
aggregationModelID,
seed,
})
// create a total writer
const writer = await PointsWriter.fromSeed({
seed,
})
// generate issuer for reader context
const issuer = await getAuthenticatedDID(seed)
//create a context reader
const contextReader = PointsReader.create({
issuer: issuer.id,
aggregationModelID,
})
//create a total reader
const reader = PointsReader.create({
issuer: issuer.id,
})
export { contextWriter, writer, contextReader, reader }