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

Commit

Permalink
Merge branch 'main' into requiredPaymentDetails-optional-90
Browse files Browse the repository at this point in the history
* main:
  Add external_id field (#163)
  Stricten, test, and bugfix http-server (#170)
  Version Packages (#167)
  Update web5/dids, web5/credentials, web5/crypto, web5/common to latest  (#177)
  • Loading branch information
Diane Huxley committed Feb 20, 2024
2 parents 4a6dce2 + 5e9a7a2 commit 7834839
Show file tree
Hide file tree
Showing 45 changed files with 1,849 additions and 1,042 deletions.
5 changes: 0 additions & 5 deletions .changeset/gentle-lies-provide.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/green-cheetahs-share.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/mighty-pandas-speak.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/slimy-needles-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tbdex/protocol": patch
---

Add external id to message metadata
18 changes: 18 additions & 0 deletions packages/http-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @tbdex/http-client

## 0.26.0

### Minor Changes

- eba04b8: Upgrade packages web5/[email protected], web5/[email protected], web5/[email protected], web5/[email protected]

- Deprecate did:ion and did:key in favour of did:jwk and did:dht
- Migrate from `PortableDid` to `BearerDid` with the latest @web5/dids upgrade
- Replaces dependency on `Web5Crypto` with `BearerDid` signer abstraction for signing operations

- 629f0c7: Stricten, tested, and remove untested code

### Patch Changes

- Updated dependencies [eba04b8]
- Updated dependencies [589edc3]
- @tbdex/protocol@0.26.0

## 0.25.0

### Minor Changes
Expand Down
10 changes: 5 additions & 5 deletions packages/http-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tbdex/http-client",
"version": "0.25.0",
"version": "0.26.0",
"type": "module",
"description": "Http client that can be used to send tbdex messages",
"license": "Apache-2.0",
Expand Down Expand Up @@ -50,10 +50,10 @@
},
"dependencies": {
"@tbdex/protocol": "workspace:*",
"@web5/common": "0.2.2",
"@web5/credentials": "0.4.1",
"@web5/crypto": "0.2.4",
"@web5/dids": "0.2.4",
"@web5/common": "0.2.3",
"@web5/credentials": "0.4.2",
"@web5/crypto": "0.4.0",
"@web5/dids": "0.4.1",
"ms": "2.1.3",
"query-string": "8.1.0",
"typeid-js": "0.3.0"
Expand Down
15 changes: 8 additions & 7 deletions packages/http-client/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { JwtPayload } from '@web5/crypto'
import type { ErrorDetail } from './types.js'
import type { DidDocument, PortableDid } from '@web5/dids'
import type { DidDocument, BearerDid } from '@web5/dids'
import {
MessageModel,
Parser,
Expand Down Expand Up @@ -30,7 +30,7 @@ import ms from 'ms'
* @beta
*/
export type GenerateRequestTokenParams = {
requesterDid: PortableDid
requesterDid: BearerDid
pfiDid: string
}

Expand Down Expand Up @@ -251,19 +251,20 @@ export class TbdexHttpClient {
* @throws {@link RequestTokenSigningError} If an error occurs during the token generation.
*/
static async generateRequestToken(params: GenerateRequestTokenParams): Promise<string> {
const { pfiDid, requesterDid } = params
const now = Date.now()
const exp = (now + ms('1m'))

const jwtPayload: JwtPayload = {
aud : params.pfiDid,
iss : params.requesterDid.did,
aud : pfiDid,
iss : requesterDid.uri,
exp : Math.floor(exp / 1000),
iat : Math.floor(now / 1000),
jti : typeid().getSuffix()
}

try {
return await Jwt.sign({ signerDid: params.requesterDid, payload: jwtPayload })
return await Jwt.sign({ signerDid: requesterDid, payload: jwtPayload })
} catch(e) {
throw new RequestTokenSigningError({ message: e.message, cause: e })
}
Expand Down Expand Up @@ -351,7 +352,7 @@ export type GetExchangeOptions = {
/** the exchange you want to fetch */
exchangeId: string
/** the message author's DID */
did: PortableDid
did: BearerDid
}

/**
Expand All @@ -361,7 +362,7 @@ export type GetExchangeOptions = {
export type GetExchangesOptions = {
/** the DID of the PFI from whom you want to get offerings */
pfiDid: string
did: PortableDid,
did: BearerDid,
filter?: {
id: string | string[]
}
Expand Down
Loading

0 comments on commit 7834839

Please sign in to comment.