Skip to content

Commit

Permalink
Unhashed -> Create (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
diehuxx authored Apr 1, 2024
1 parent 717dac3 commit 6619fcc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/protocol/src/dev-tools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import type { BalanceData, OfferingData, QuoteData, UnhashedRfqData } from './types.js'
import type { BalanceData, OfferingData, QuoteData, CreateRfqData } from './types.js'
import type { BearerDid } from '@web5/dids'

import { Balance, Offering } from './resource-kinds/index.js'
Expand Down Expand Up @@ -176,7 +176,7 @@ export class DevTools {
static async createRfq(opts: MessageOptions) {
const { sender, receiver } = opts

const rfqData: UnhashedRfqData = await DevTools.createRfqData(opts)
const rfqData: CreateRfqData = await DevTools.createRfqData(opts)

return Rfq.create({
metadata : { from: sender.uri, to: receiver?.uri ?? 'did:ex:pfi' },
Expand All @@ -187,7 +187,7 @@ export class DevTools {
/**
* creates an example RfqData. Useful for testing purposes
*/
static async createRfqData(opts?: MessageOptions): Promise<UnhashedRfqData> {
static async createRfqData(opts?: MessageOptions): Promise<CreateRfqData> {
let vcJwt: string = ''

if (opts?.sender) {
Expand Down
8 changes: 4 additions & 4 deletions packages/protocol/src/message-kinds/rfq.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { MessageKind, MessageModel, PayinMethod, RfqData, RfqMetadata, RfqPrivateData, UnhashedRfqData } from '../types.js'
import type { MessageKind, MessageModel, PayinMethod, RfqData, RfqMetadata, RfqPrivateData, CreateRfqData } from '../types.js'

import { BigNumber } from 'bignumber.js'
import { Crypto } from '../crypto.js'
Expand All @@ -16,7 +16,7 @@ import { randomBytes } from '@web5/crypto/utils'
* @beta
*/
export type CreateRfqOptions = {
data: UnhashedRfqData
data: CreateRfqData
metadata: Omit<RfqMetadata, 'id' | 'kind' | 'createdAt' | 'exchangeId' | 'protocol'> & { protocol?: RfqMetadata['protocol'] }
}

Expand Down Expand Up @@ -128,8 +128,8 @@ export class Rfq extends Message {
* @returns {@link RfqData} The value of data field.
* @returns {@link RfqPrivateData} The value of privateData field.
*/
private static hashPrivateData(unhashedRfqData: UnhashedRfqData): { data: RfqData, privateData: RfqPrivateData } {
const salt = Convert.uint8Array(randomBytes(16)).toString()
private static hashPrivateData(unhashedRfqData: CreateRfqData): { data: RfqData, privateData: RfqPrivateData } {
const salt = Convert.uint8Array(randomBytes(16)).toBase64Url()

const {
claims,
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,14 @@ export type RfqPrivateData = {
* Data contained in a RFQ message, including data which will be placed in {@link RfqPrivateData}
* @beta
*/
export type UnhashedRfqData = Omit<RfqData, 'payin' | 'payout' | 'claimsHash'> & {
export type CreateRfqData = Omit<RfqData, 'payin' | 'payout' | 'claimsHash'> & {
payin: Omit<SelectedPayinMethod, keyof PrivatePaymentDetails> & PrivatePaymentDetails
payout: Omit<SelectedPayoutMethod, keyof PrivatePaymentDetails> & PrivatePaymentDetails,
claims?: string[]
}

/**
* A container for the unhashed `paymentDetails`
* A container for the cleartext `paymentDetails`
* @beta
*/
export type PrivatePaymentDetails = {
Expand Down

0 comments on commit 6619fcc

Please sign in to comment.