Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Commit

Permalink
bumping versions. fixing compile errors. DidXYZ.create() no longer re…
Browse files Browse the repository at this point in the history
…turns PortableDid, wip
  • Loading branch information
jiyoonie9 committed Feb 6, 2024
1 parent ea8a44f commit b45f7bd
Show file tree
Hide file tree
Showing 8 changed files with 450 additions and 222 deletions.
618 changes: 419 additions & 199 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"type": "module",
"version": "1.0.0",
"dependencies": {
"@tbdex/http-server": "0.23.0",
"@web5/common": "0.2.2",
"@web5/crypto": "0.3.0",
"@web5/dids": "0.2.4",
"@tbdex/http-server": "0.24.0",
"@web5/common": "0.2.3",
"@web5/crypto": "0.4.0",
"@web5/dids": "0.3.0",
"@web5/credentials": "0.4.1",
"ajv": "8.12.0",
"cborg": "^3.0.0",
"dotenv": "16.3.1",
Expand Down
6 changes: 4 additions & 2 deletions src/client-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TbdexHttpClient, DevTools, Rfq } from '@tbdex/http-client'
import { VerifiableCredential } from '@web5/credentials'
import fs from 'fs/promises'

//
Expand Down Expand Up @@ -40,14 +41,15 @@ const alice = await createOrLoadDid('alice.json')
//
// Create a sanctions credential so that the PFI knows that Alice is legit.
// This is normally done by a third party.
const { signedCredential } = await DevTools.createCredential({
const vc = await VerifiableCredential.create({
type : 'SanctionCredential',
issuer : issuer,
subject : alice.did,
data : {
'beep': 'boop'
}
})
const vcJwt = await vc.sign({ did: issuer.did })

//
//
Expand All @@ -68,7 +70,7 @@ const rfq = Rfq.create({
reason: 'I got kids'
}
},
claims: [signedCredential]
claims: [vcJwt]
}
})

Expand Down
23 changes: 14 additions & 9 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import type { LogLevelDesc } from 'loglevel'
import fs from 'node:fs'

import 'dotenv/config'

import { DidIonMethod, PortableDid } from '@web5/dids'
import { DidDht, PortableDid } from '@web5/dids'

export type Environment = 'local' | 'staging' | 'production'

Expand Down Expand Up @@ -39,11 +38,17 @@ export const config: Config = {
// a new one will be generated every time the process starts.
if (!config.did) {
console.log('Creating an ephemeral DID.....')
const DidIon = await DidIonMethod.create({
services: [{ id: 'pfi', type: 'PFI', serviceEndpoint: config.host }]
})


config.did = DidIon
fs.writeFileSync('server-did.txt', config.did.did)
const did = await DidDht.create({
options: {
services: [
{
id: 'pfi',
type: 'PFI',
serviceEndpoint: [config.host]
}
]
}})

config.did = did

Check failure on line 52 in src/config.ts

View workflow job for this annotation

GitHub Actions / build_and_test (20.4.0)

Property 'verificationMethods' is missing in type 'Did' but required in type 'PortableDid'.
fs.writeFileSync('server-did.txt', config.did.uri)
}
8 changes: 4 additions & 4 deletions src/db/exchange-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class _ExchangeRepository implements ExchangesApi {
if (message.kind == 'rfq') {
const quote = Quote.create({
metadata: {
from: config.did.did,
from: config.did.uri,
to: message.from,
exchangeId: message.exchangeId
},
Expand All @@ -162,7 +162,7 @@ class _ExchangeRepository implements ExchangesApi {
if (message.kind == 'order') {
let orderStatus = OrderStatus.create({
metadata: {
from: config.did.did,
from: config.did.uri,
to: message.from,
exchangeId: message.exchangeId
},
Expand All @@ -177,7 +177,7 @@ class _ExchangeRepository implements ExchangesApi {

orderStatus = OrderStatus.create({
metadata: {
from: config.did.did,
from: config.did.uri,
to: message.from,
exchangeId: message.exchangeId
},
Expand All @@ -191,7 +191,7 @@ class _ExchangeRepository implements ExchangesApi {
// finally close the exchange
const close = Close.create({
metadata: {
from: config.did.did,
from: config.did.uri,
to: message.from,
exchangeId: message.exchangeId
},
Expand Down
4 changes: 2 additions & 2 deletions src/example/issue-credential.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DevTools } from '@tbdex/http-client'
import { createOrLoadDid } from './utils.js'
import { VerifiableCredential } from '@web5/credentials'


// get the did from the command line parameter
Expand All @@ -16,7 +16,7 @@ const issuer = await createOrLoadDid('issuer.json')
//
// Create a sanctions credential so that the PFI knows that Alice is legit.
//
const { signedCredential } = await DevTools.createCredential({
const signedCredential = await VerifiableCredential.create({
type : 'SanctionCredential',
issuer : issuer,
subject : customerDid,
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const server = httpApi.listen(config.port, () => {
log.info(`Mock PFI listening on port ${config.port}`)
})

console.log('PFI DID: ', config.did.did)
console.log('PFI DID: ', config.did.uri)

httpApi.api.get('/', (req, res) => {
res.send('Please use the tbdex protocol to communicate with this server or a suitable library: https://github.com/TBD54566975/tbdex-protocol')
Expand Down
2 changes: 1 addition & 1 deletion src/seed-offerings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ await Postgres.connect()
await Postgres.clear()

const offering = Offering.create({
metadata: { from: config.did.did },
metadata: { from: config.did.uri },
data: {
description: 'fake offering 1',
payoutUnitsPerPayinUnit: '0.0069', // ex. we send 100 dollars, so that means 14550.00 KES
Expand Down

0 comments on commit b45f7bd

Please sign in to comment.