diff --git a/openapi/resource-server.yaml b/openapi/resource-server.yaml index 8feb6a16..ac42d585 100644 --- a/openapi/resource-server.yaml +++ b/openapi/resource-server.yaml @@ -671,7 +671,6 @@ paths: description: A client can fetch the latest state of an incoming payment to determine the amount received into the wallet address. parameters: - $ref: '#/components/parameters/id' - - $ref: '#/components/parameters/wallet-address' '/incoming-payments/{id}/complete': post: summary: Complete an Incoming Payment @@ -712,21 +711,6 @@ paths: $ref: '#/components/responses/403' '404': description: Incoming Payment Not Found - requestBody: - content: - application/json: - schema: - type: object - additionalProperties: false - properties: - walletAddress: - $ref: ./schemas.yaml#/components/schemas/walletAddress - required: - - walletAddress - examples: - Complete incoming payment for https://openpayments.guide/alice: - value: - walletAddress: 'https://openpayments.guide/alice/' description: |- A client with the appropriate permissions MAY mark a non-expired **incoming payment** as `completed` indicating that the client is not going to make any further payments toward this **incoming payment**, even though the full `incomingAmount` may not have been received. @@ -785,7 +769,6 @@ paths: - $ref: '#/components/parameters/signature' parameters: - $ref: '#/components/parameters/id' - - $ref: '#/components/parameters/wallet-address' '/quotes/{id}': get: summary: Get a Quote diff --git a/packages/open-payments/src/client/grant.ts b/packages/open-payments/src/client/grant.ts index 83cda8d5..420f2d07 100644 --- a/packages/open-payments/src/client/grant.ts +++ b/packages/open-payments/src/client/grant.ts @@ -2,7 +2,7 @@ import { HttpMethod } from '@interledger/openapi' import { GrantOrTokenRequestArgs, RouteDeps, - UnauthenticatedRequestArgs + UnauthenticatedResourceRequestArgs } from '.' import { getASPath, @@ -19,7 +19,7 @@ export interface GrantRouteDeps extends RouteDeps { export interface GrantRoutes { request( - postArgs: UnauthenticatedRequestArgs, + postArgs: UnauthenticatedResourceRequestArgs, args: Omit ): Promise continue( @@ -47,7 +47,7 @@ export const createGrantRoutes = (deps: GrantRouteDeps): GrantRoutes => { return { request: ( - { url }: UnauthenticatedRequestArgs, + { url }: UnauthenticatedResourceRequestArgs, args: Omit ) => post( diff --git a/packages/open-payments/src/client/incoming-payment.test.ts b/packages/open-payments/src/client/incoming-payment.test.ts index 554cd19b..bcf773d2 100644 --- a/packages/open-payments/src/client/incoming-payment.test.ts +++ b/packages/open-payments/src/client/incoming-payment.test.ts @@ -56,15 +56,13 @@ describe('incoming-payment', (): void => { nock(serverAddress) .get('/incoming-payments/1') - .query({ 'wallet-address': walletAddress }) .reply(200, incomingPayment) const result = await getIncomingPayment( { axiosInstance, logger }, { url: `${serverAddress}/incoming-payments/1`, - accessToken, - walletAddress + accessToken }, openApiValidators.successfulValidator ) @@ -87,7 +85,6 @@ describe('incoming-payment', (): void => { nock(serverAddress) .get('/incoming-payments/1') - .query({ 'wallet-address': walletAddress }) .reply(200, incomingPayment) await expect( @@ -98,8 +95,7 @@ describe('incoming-payment', (): void => { }, { url: `${serverAddress}/incoming-payments/1`, - accessToken, - walletAddress + accessToken }, openApiValidators.successfulValidator ) @@ -122,8 +118,7 @@ describe('incoming-payment', (): void => { }, { url: `${serverAddress}/incoming-payments/1`, - accessToken, - walletAddress + accessToken }, openApiValidators.failedValidator ) @@ -191,9 +186,10 @@ describe('incoming-payment', (): void => { const result = await createIncomingPayment( { axiosInstance, logger }, - { url: serverAddress, walletAddress, accessToken }, + { url: serverAddress, accessToken }, openApiValidators.successfulValidator, { + walletAddress, incomingAmount, expiresAt, metadata @@ -225,9 +221,9 @@ describe('incoming-payment', (): void => { await expect( createIncomingPayment( { axiosInstance, logger }, - { url: serverAddress, walletAddress, accessToken }, + { url: serverAddress, accessToken }, openApiValidators.successfulValidator, - {} + { walletAddress } ) ).rejects.toThrowError() scope.done() @@ -243,9 +239,9 @@ describe('incoming-payment', (): void => { await expect( createIncomingPayment( { axiosInstance, logger }, - { url: serverAddress, walletAddress, accessToken }, + { url: serverAddress, accessToken }, openApiValidators.failedValidator, - {} + { walletAddress } ) ).rejects.toThrowError() scope.done() @@ -266,8 +262,7 @@ describe('incoming-payment', (): void => { { axiosInstance, logger }, { url: `${serverAddress}/incoming-payments/${incomingPayment.id}`, - accessToken, - walletAddress + accessToken }, openApiValidators.successfulValidator ) @@ -291,8 +286,7 @@ describe('incoming-payment', (): void => { { axiosInstance, logger }, { url: `${serverAddress}/incoming-payments/${incomingPayment.id}`, - accessToken, - walletAddress + accessToken }, openApiValidators.successfulValidator ) @@ -315,8 +309,7 @@ describe('incoming-payment', (): void => { { axiosInstance, logger }, { url: `${serverAddress}/incoming-payments/${incomingPayment.id}`, - accessToken, - walletAddress + accessToken }, openApiValidators.failedValidator ) @@ -670,7 +663,7 @@ describe('incoming-payment', (): void => { openApi, axiosInstance, logger - }).get({ url, accessToken, walletAddress }) + }).get({ url, accessToken }) expect(getSpy).toHaveBeenCalledWith( { @@ -679,11 +672,7 @@ describe('incoming-payment', (): void => { }, { url, - accessToken, - walletAddress, - queryParams: { - 'wallet-address': walletAddress - } + accessToken }, true ) @@ -695,7 +684,7 @@ describe('incoming-payment', (): void => { const mockResponseValidator = ({ path, method }) => path === '/incoming-payments/{id}' && method === HttpMethod.GET - const url = `${walletAddress}/incoming-payments/1` + const url = `${serverAddress}/incoming-payments/1` jest .spyOn(openApi, 'createResponseValidator') @@ -712,7 +701,7 @@ describe('incoming-payment', (): void => { openApi, axiosInstance, logger - }).getPublic({ accessToken, url }) + }).getPublic({ url }) expect(getSpy).toHaveBeenCalledWith( { @@ -775,6 +764,7 @@ describe('incoming-payment', (): void => { const url = `${serverAddress}/incoming-payments` const incomingPaymentCreateArgs = { + walletAddress, description: 'Invoice', incomingAmount: { assetCode: 'USD', assetScale: 2, value: '10' } } @@ -793,7 +783,7 @@ describe('incoming-payment', (): void => { axiosInstance, logger }).create( - { url: serverAddress, walletAddress, accessToken }, + { url: serverAddress, accessToken }, incomingPaymentCreateArgs ) @@ -829,7 +819,7 @@ describe('incoming-payment', (): void => { openApi, axiosInstance, logger - }).complete({ url: incomingPaymentUrl, accessToken, walletAddress }) + }).complete({ url: incomingPaymentUrl, accessToken }) expect(postSpy).toHaveBeenCalledWith( { @@ -838,10 +828,7 @@ describe('incoming-payment', (): void => { }, { url: `${incomingPaymentUrl}/complete`, - accessToken, - body: { - walletAddress - } + accessToken }, true ) @@ -854,7 +841,7 @@ describe('incoming-payment', (): void => { const mockResponseValidator = ({ path, method }) => path === '/incoming-payments/{id}' && method === HttpMethod.GET - const url = `${walletAddress}/incoming-payments/1` + const url = `${serverAddress}/incoming-payments/1` jest .spyOn(openApi, 'createResponseValidator') diff --git a/packages/open-payments/src/client/incoming-payment.ts b/packages/open-payments/src/client/incoming-payment.ts index abe94c13..36c847d5 100644 --- a/packages/open-payments/src/client/incoming-payment.ts +++ b/packages/open-payments/src/client/incoming-payment.ts @@ -1,9 +1,10 @@ import { HttpMethod, ResponseValidator } from '@interledger/openapi' import { BaseDeps, - ResourceOrCollectionRequestArgs, + ResourceRequestArgs, + CollectionRequestArgs, RouteDeps, - UnauthenticatedRequestArgs + UnauthenticatedResourceRequestArgs } from '.' import { IncomingPayment, @@ -19,19 +20,17 @@ import { get, post } from './requests' type AnyIncomingPayment = IncomingPayment | IncomingPaymentWithPaymentMethods export interface IncomingPaymentRoutes { - get( - args: ResourceOrCollectionRequestArgs - ): Promise + get(args: ResourceRequestArgs): Promise getPublic( - args: ResourceOrCollectionRequestArgs + args: UnauthenticatedResourceRequestArgs ): Promise create( - args: ResourceOrCollectionRequestArgs, + args: ResourceRequestArgs, createArgs: CreateIncomingPaymentArgs ): Promise - complete(args: ResourceOrCollectionRequestArgs): Promise + complete(args: ResourceRequestArgs): Promise list( - args: ResourceOrCollectionRequestArgs, + args: CollectionRequestArgs, pagination?: PaginationArgs ): Promise } @@ -72,23 +71,22 @@ export const createIncomingPaymentRoutes = ( }) return { - get: (args: ResourceOrCollectionRequestArgs) => + get: (args: ResourceRequestArgs) => getIncomingPayment( { axiosInstance, logger }, args, getIncomingPaymentOpenApiValidator ), - getPublic: (args: ResourceOrCollectionRequestArgs) => { + getPublic: (args: UnauthenticatedResourceRequestArgs) => { // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { accessToken, ...argsWithoutAccessToken } = args return getPublicIncomingPayment( { axiosInstance, logger }, - argsWithoutAccessToken, + args, getPublicIncomingPaymentOpenApiValidator ) }, create: ( - requestArgs: ResourceOrCollectionRequestArgs, + requestArgs: ResourceRequestArgs, createArgs: CreateIncomingPaymentArgs ) => createIncomingPayment( @@ -97,16 +95,13 @@ export const createIncomingPaymentRoutes = ( createIncomingPaymentOpenApiValidator, createArgs ), - complete: (args: ResourceOrCollectionRequestArgs) => + complete: (args: ResourceRequestArgs) => completeIncomingPayment( { axiosInstance, logger }, args, completeIncomingPaymentOpenApiValidator ), - list: ( - args: ResourceOrCollectionRequestArgs, - pagination?: PaginationArgs - ) => + list: (args: CollectionRequestArgs, pagination?: PaginationArgs) => listIncomingPayment( { axiosInstance, logger }, args, @@ -117,7 +112,7 @@ export const createIncomingPaymentRoutes = ( } export interface UnauthenticatedIncomingPaymentRoutes { - get(args: UnauthenticatedRequestArgs): Promise + get(args: UnauthenticatedResourceRequestArgs): Promise } export const createUnauthenticatedIncomingPaymentRoutes = ( @@ -132,7 +127,7 @@ export const createUnauthenticatedIncomingPaymentRoutes = ( }) return { - get: (args: UnauthenticatedRequestArgs) => + get: (args: UnauthenticatedResourceRequestArgs) => getPublicIncomingPayment( { axiosInstance, logger }, args, @@ -143,19 +138,16 @@ export const createUnauthenticatedIncomingPaymentRoutes = ( export const getIncomingPayment = async ( deps: BaseDeps, - args: ResourceOrCollectionRequestArgs, + args: ResourceRequestArgs, validateOpenApiResponse: ResponseValidator ) => { const { axiosInstance, logger } = deps - const { url, walletAddress } = args + const { url } = args const incomingPayment = await get( { axiosInstance, logger }, { - ...args, - queryParams: { - 'wallet-address': walletAddress - } + ...args }, validateOpenApiResponse ) @@ -175,7 +167,7 @@ export const getIncomingPayment = async ( export const getPublicIncomingPayment = async ( deps: BaseDeps, - args: UnauthenticatedRequestArgs, + args: UnauthenticatedResourceRequestArgs, validateOpenApiResponse: ResponseValidator ) => { const { axiosInstance, logger } = deps @@ -184,7 +176,7 @@ export const getPublicIncomingPayment = async ( export const createIncomingPayment = async ( deps: BaseDeps, - requestArgs: ResourceOrCollectionRequestArgs, + requestArgs: ResourceRequestArgs, validateOpenApiResponse: ResponseValidator, createArgs: CreateIncomingPaymentArgs ) => { @@ -213,16 +205,16 @@ export const createIncomingPayment = async ( export const completeIncomingPayment = async ( deps: BaseDeps, - args: ResourceOrCollectionRequestArgs, + args: ResourceRequestArgs, validateOpenApiResponse: ResponseValidator ) => { const { axiosInstance, logger } = deps - const { url: incomingPaymentUrl, accessToken, walletAddress } = args + const { url: incomingPaymentUrl, accessToken } = args const url = `${incomingPaymentUrl}/complete` const incomingPayment = await post( { axiosInstance, logger }, - { url, accessToken, body: { walletAddress } }, + { url, accessToken }, validateOpenApiResponse ) @@ -241,7 +233,7 @@ export const completeIncomingPayment = async ( export const listIncomingPayment = async ( deps: BaseDeps, - args: ResourceOrCollectionRequestArgs, + args: CollectionRequestArgs, validateOpenApiResponse: ResponseValidator, pagination?: PaginationArgs ) => { diff --git a/packages/open-payments/src/client/index.ts b/packages/open-payments/src/client/index.ts index c79dfb17..a0737faf 100644 --- a/packages/open-payments/src/client/index.ts +++ b/packages/open-payments/src/client/index.ts @@ -39,7 +39,7 @@ export interface RouteDeps extends BaseDeps { logger: Logger } -export interface UnauthenticatedRequestArgs { +export interface UnauthenticatedResourceRequestArgs { /** * The full URL of the requested resource. * @@ -62,11 +62,15 @@ interface AuthenticatedRequestArgs { } export interface GrantOrTokenRequestArgs - extends UnauthenticatedRequestArgs, + extends UnauthenticatedResourceRequestArgs, AuthenticatedRequestArgs {} -export interface ResourceOrCollectionRequestArgs - extends UnauthenticatedRequestArgs, +export interface ResourceRequestArgs + extends UnauthenticatedResourceRequestArgs, + AuthenticatedRequestArgs {} + +export interface CollectionRequestArgs + extends UnauthenticatedResourceRequestArgs, AuthenticatedRequestArgs { /** * The wallet address URL of the requested collection. diff --git a/packages/open-payments/src/client/outgoing-payment.test.ts b/packages/open-payments/src/client/outgoing-payment.test.ts index 89dce783..ab195c94 100644 --- a/packages/open-payments/src/client/outgoing-payment.test.ts +++ b/packages/open-payments/src/client/outgoing-payment.test.ts @@ -47,15 +47,13 @@ describe('outgoing-payment', (): void => { const scope = nock(serverAddress) .get('/outgoing-payments/1') - .query({ 'wallet-address': walletAddress }) .reply(200, outgoingPayment) const result = await getOutgoingPayment( { axiosInstance, logger }, { url: `${serverAddress}/outgoing-payments/1`, - accessToken: 'accessToken', - walletAddress + accessToken: 'accessToken' }, openApiValidators.successfulValidator ) @@ -79,7 +77,6 @@ describe('outgoing-payment', (): void => { const scope = nock(serverAddress) .get('/outgoing-payments/1') - .query({ 'wallet-address': walletAddress }) .reply(200, outgoingPayment) await expect( @@ -87,8 +84,7 @@ describe('outgoing-payment', (): void => { { axiosInstance, logger }, { url: `${serverAddress}/outgoing-payments/1`, - accessToken: 'accessToken', - walletAddress + accessToken: 'accessToken' }, openApiValidators.successfulValidator ) @@ -101,7 +97,6 @@ describe('outgoing-payment', (): void => { const scope = nock(serverAddress) .get('/outgoing-payments/1') - .query({ 'wallet-address': walletAddress }) .reply(200, outgoingPayment) await expect( @@ -109,8 +104,7 @@ describe('outgoing-payment', (): void => { { axiosInstance, logger }, { url: `${serverAddress}/outgoing-payments/1`, - accessToken: 'accessToken', - walletAddress + accessToken: 'accessToken' }, openApiValidators.failedValidator ) @@ -297,13 +291,13 @@ describe('outgoing-payment', (): void => { { axiosInstance, logger }, { url: serverAddress, - walletAddress, accessToken: 'accessToken' }, openApiValidators.successfulValidator, { quoteId, - metadata + metadata, + walletAddress } ) expect(result).toEqual(outgoingPayment) @@ -333,12 +327,12 @@ describe('outgoing-payment', (): void => { { axiosInstance, logger }, { url: serverAddress, - walletAddress, accessToken: 'accessToken' }, openApiValidators.successfulValidator, { - quoteId: uuid() + quoteId: uuid(), + walletAddress } ) ).rejects.toThrowError() @@ -360,12 +354,12 @@ describe('outgoing-payment', (): void => { }, { url: serverAddress, - walletAddress, accessToken: 'accessToken' }, openApiValidators.failedValidator, { - quoteId: uuid() + quoteId: uuid(), + walletAddress } ) ).rejects.toThrowError() @@ -481,7 +475,7 @@ describe('outgoing-payment', (): void => { openApi, axiosInstance, logger - }).get({ url, accessToken: 'accessToken', walletAddress }) + }).get({ url, accessToken: 'accessToken' }) expect(getSpy).toHaveBeenCalledWith( { @@ -490,10 +484,7 @@ describe('outgoing-payment', (): void => { }, { url, - accessToken: 'accessToken', - queryParams: { - 'wallet-address': walletAddress - } + accessToken: 'accessToken' }, true ) @@ -554,7 +545,8 @@ describe('outgoing-payment', (): void => { const url = `${serverAddress}/outgoing-payments` const outgoingPaymentCreateArgs = { - quoteId: uuid() + quoteId: uuid(), + walletAddress } jest @@ -571,7 +563,7 @@ describe('outgoing-payment', (): void => { axiosInstance, logger }).create( - { url: serverAddress, walletAddress, accessToken: 'accessToken' }, + { url: serverAddress, accessToken: 'accessToken' }, outgoingPaymentCreateArgs ) diff --git a/packages/open-payments/src/client/outgoing-payment.ts b/packages/open-payments/src/client/outgoing-payment.ts index 93478f40..48301d4e 100644 --- a/packages/open-payments/src/client/outgoing-payment.ts +++ b/packages/open-payments/src/client/outgoing-payment.ts @@ -1,5 +1,10 @@ import { HttpMethod, ResponseValidator } from '@interledger/openapi' -import { BaseDeps, ResourceOrCollectionRequestArgs, RouteDeps } from '.' +import { + BaseDeps, + ResourceRequestArgs, + CollectionRequestArgs, + RouteDeps +} from '.' import { CreateOutgoingPaymentArgs, getRSPath, @@ -10,13 +15,13 @@ import { import { get, post } from './requests' export interface OutgoingPaymentRoutes { - get(args: ResourceOrCollectionRequestArgs): Promise + get(args: ResourceRequestArgs): Promise list( - args: ResourceOrCollectionRequestArgs, + args: CollectionRequestArgs, pagination?: PaginationArgs ): Promise create( - requestArgs: ResourceOrCollectionRequestArgs, + requestArgs: ResourceRequestArgs, createArgs: CreateOutgoingPaymentArgs ): Promise } @@ -45,16 +50,13 @@ export const createOutgoingPaymentRoutes = ( }) return { - get: (requestArgs: ResourceOrCollectionRequestArgs) => + get: (requestArgs: ResourceRequestArgs) => getOutgoingPayment( { axiosInstance, logger }, requestArgs, getOutgoingPaymentOpenApiValidator ), - list: ( - requestArgs: ResourceOrCollectionRequestArgs, - pagination?: PaginationArgs - ) => + list: (requestArgs: CollectionRequestArgs, pagination?: PaginationArgs) => listOutgoingPayments( { axiosInstance, logger }, requestArgs, @@ -62,7 +64,7 @@ export const createOutgoingPaymentRoutes = ( pagination ), create: ( - requestArgs: ResourceOrCollectionRequestArgs, + requestArgs: ResourceRequestArgs, createArgs: CreateOutgoingPaymentArgs ) => createOutgoingPayment( @@ -76,20 +78,17 @@ export const createOutgoingPaymentRoutes = ( export const getOutgoingPayment = async ( deps: BaseDeps, - requestArgs: ResourceOrCollectionRequestArgs, + requestArgs: ResourceRequestArgs, validateOpenApiResponse: ResponseValidator ) => { const { axiosInstance, logger } = deps - const { url, walletAddress, accessToken } = requestArgs + const { url, accessToken } = requestArgs const outgoingPayment = await get( { axiosInstance, logger }, { url, - accessToken, - queryParams: { - 'wallet-address': walletAddress - } + accessToken }, validateOpenApiResponse ) @@ -109,7 +108,7 @@ export const getOutgoingPayment = async ( export const createOutgoingPayment = async ( deps: BaseDeps, - requestArgs: ResourceOrCollectionRequestArgs, + requestArgs: ResourceRequestArgs, validateOpenApiResponse: ResponseValidator, createArgs: CreateOutgoingPaymentArgs ) => { @@ -138,7 +137,7 @@ export const createOutgoingPayment = async ( export const listOutgoingPayments = async ( deps: BaseDeps, - requestArgs: ResourceOrCollectionRequestArgs, + requestArgs: CollectionRequestArgs, validateOpenApiResponse: ResponseValidator, pagination?: PaginationArgs ) => { diff --git a/packages/open-payments/src/client/quote.test.ts b/packages/open-payments/src/client/quote.test.ts index 7d5421c8..10cea754 100644 --- a/packages/open-payments/src/client/quote.test.ts +++ b/packages/open-payments/src/client/quote.test.ts @@ -75,25 +75,25 @@ describe('quote', (): void => { describe('createQuote', (): void => { test('returns the quote if it passes open api validation', async (): Promise => { - const scope = nock(walletAddress).post(`/quotes`).reply(200, quote) + const scope = nock(baseUrl).post(`/quotes`).reply(200, quote) const result = await createQuote( { axiosInstance, logger }, { - walletAddress, + url: baseUrl, accessToken }, openApiValidators.successfulValidator, - { receiver: quote.receiver, method: 'ilp' } + { receiver: quote.receiver, method: 'ilp', walletAddress } ) expect(result).toStrictEqual(quote) scope.done() }) test('throws if quote does not pass open api validation', async (): Promise => { - const scope = nock(walletAddress).post(`/quotes`).reply(200, quote) + const scope = nock(baseUrl).post(`/quotes`).reply(200, quote) await expect(() => createQuote( { @@ -101,11 +101,11 @@ describe('quote', (): void => { logger }, { - walletAddress, + url: baseUrl, accessToken }, openApiValidators.failedValidator, - { receiver: quote.receiver, method: 'ilp' } + { receiver: quote.receiver, method: 'ilp', walletAddress } ) ).rejects.toThrowError() scope.done() @@ -161,7 +161,7 @@ describe('quote', (): void => { const postSpy = jest .spyOn(requestors, 'post') .mockResolvedValueOnce(quote) - const url = `${walletAddress}${getRSPath('/quotes')}` + const url = `${baseUrl}${getRSPath('/quotes')}` await createQuoteRoutes({ openApi, @@ -169,10 +169,10 @@ describe('quote', (): void => { logger }).create( { - walletAddress, + url: baseUrl, accessToken }, - { receiver: quote.receiver, method: 'ilp' } + { receiver: quote.receiver, method: 'ilp', walletAddress } ) expect(postSpy).toHaveBeenCalledWith( @@ -183,7 +183,7 @@ describe('quote', (): void => { { url, accessToken, - body: { receiver: quote.receiver, method: 'ilp' } + body: { receiver: quote.receiver, method: 'ilp', walletAddress } }, true ) diff --git a/packages/open-payments/src/client/quote.ts b/packages/open-payments/src/client/quote.ts index f2439ecf..275f9272 100644 --- a/packages/open-payments/src/client/quote.ts +++ b/packages/open-payments/src/client/quote.ts @@ -1,12 +1,12 @@ import { HttpMethod, ResponseValidator } from '@interledger/openapi' -import { ResourceOrCollectionRequestArgs, BaseDeps, RouteDeps } from '.' +import { ResourceRequestArgs, BaseDeps, RouteDeps } from '.' import { CreateQuoteArgs, getRSPath, Quote } from '../types' import { get, post } from './requests' export interface QuoteRoutes { - get(args: ResourceOrCollectionRequestArgs): Promise + get(args: ResourceRequestArgs): Promise create( - createArgs: ResourceOrCollectionRequestArgs, + createArgs: ResourceRequestArgs, createQuoteArgs: CreateQuoteArgs ): Promise } @@ -25,10 +25,10 @@ export const createQuoteRoutes = (deps: RouteDeps): QuoteRoutes => { }) return { - get: (args: ResourceOrCollectionRequestArgs) => + get: (args: ResourceRequestArgs) => getQuote({ axiosInstance, logger }, args, getQuoteOpenApiValidator), create: ( - createArgs: ResourceOrCollectionRequestArgs, + createArgs: ResourceRequestArgs, createQuoteArgs: CreateQuoteArgs ) => createQuote( @@ -42,7 +42,7 @@ export const createQuoteRoutes = (deps: RouteDeps): QuoteRoutes => { export const getQuote = async ( deps: BaseDeps, - args: ResourceOrCollectionRequestArgs, + args: ResourceRequestArgs, validateOpenApiResponse: ResponseValidator ) => { const { axiosInstance, logger } = deps @@ -58,13 +58,13 @@ export const getQuote = async ( export const createQuote = async ( deps: BaseDeps, - createArgs: ResourceOrCollectionRequestArgs, + createArgs: ResourceRequestArgs, validateOpenApiResponse: ResponseValidator, createQuoteArgs: CreateQuoteArgs ) => { const { axiosInstance, logger } = deps - const { accessToken, walletAddress } = createArgs - const url = `${walletAddress}${getRSPath('/quotes')}` + const { accessToken, url: baseUrl } = createArgs + const url = `${baseUrl}${getRSPath('/quotes')}` const quote = await post( { axiosInstance, logger }, diff --git a/packages/open-payments/src/client/wallet-address.ts b/packages/open-payments/src/client/wallet-address.ts index eaf60875..b1297e97 100644 --- a/packages/open-payments/src/client/wallet-address.ts +++ b/packages/open-payments/src/client/wallet-address.ts @@ -1,11 +1,11 @@ import { HttpMethod } from '@interledger/openapi' -import { RouteDeps, UnauthenticatedRequestArgs } from '.' +import { RouteDeps, UnauthenticatedResourceRequestArgs } from '.' import { JWKS, WalletAddress, getRSPath } from '../types' import { get } from './requests' export interface WalletAddressRoutes { - get(args: UnauthenticatedRequestArgs): Promise - getKeys(args: UnauthenticatedRequestArgs): Promise + get(args: UnauthenticatedResourceRequestArgs): Promise + getKeys(args: UnauthenticatedResourceRequestArgs): Promise } export const createWalletAddressRoutes = ( @@ -25,9 +25,9 @@ export const createWalletAddressRoutes = ( }) return { - get: (args: UnauthenticatedRequestArgs) => + get: (args: UnauthenticatedResourceRequestArgs) => get({ axiosInstance, logger }, args, getPaymentPaymentValidator), - getKeys: (args: UnauthenticatedRequestArgs) => + getKeys: (args: UnauthenticatedResourceRequestArgs) => get( { axiosInstance, logger }, { diff --git a/packages/open-payments/src/openapi/generated/resource-server-types.ts b/packages/open-payments/src/openapi/generated/resource-server-types.ts index af6c385a..7f4e2858 100644 --- a/packages/open-payments/src/openapi/generated/resource-server-types.ts +++ b/packages/open-payments/src/openapi/generated/resource-server-types.ts @@ -60,10 +60,6 @@ export interface paths { /** Sub-resource identifier */ id: components["parameters"]["id"]; }; - query: { - /** URL of a wallet address hosted by a Rafiki instance. */ - "wallet-address": components["parameters"]["wallet-address"]; - }; }; }; "/incoming-payments/{id}/complete": { @@ -88,10 +84,6 @@ export interface paths { /** Sub-resource identifier */ id: components["parameters"]["id"]; }; - query: { - /** URL of a wallet address hosted by a Rafiki instance. */ - "wallet-address": components["parameters"]["wallet-address"]; - }; }; }; "/quotes/{id}": { @@ -576,10 +568,6 @@ export interface operations { /** Sub-resource identifier */ id: components["parameters"]["id"]; }; - query: { - /** URL of a wallet address hosted by a Rafiki instance. */ - "wallet-address": components["parameters"]["wallet-address"]; - }; header: { /** The Signature-Input field is a Dictionary structured field containing the metadata for one or more message signatures generated from components within the HTTP message. Each member describes a single message signature. The member's key is the label that uniquely identifies the message signature within the context of the HTTP message. The member's value is the serialization of the covered components Inner List plus all signature metadata parameters identified by the label. The following components MUST be included: - "@method" - "@target-uri" - "authorization". When the message contains a request body, the covered components MUST also include the following: - "content-digest" The keyid parameter of the signature MUST be set to the kid value of the JWK. See [ietf-httpbis-message-signatures](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-message-signatures#section-4.1) for more details. */ "Signature-Input"?: components["parameters"]["optional-signature-input"]; @@ -633,13 +621,6 @@ export interface operations { /** Incoming Payment Not Found */ 404: unknown; }; - requestBody: { - content: { - "application/json": { - walletAddress: external["schemas.yaml"]["components"]["schemas"]["walletAddress"]; - }; - }; - }; }; /** A client can fetch the latest state of an outgoing payment. */ "get-outgoing-payment": { @@ -648,10 +629,6 @@ export interface operations { /** Sub-resource identifier */ id: components["parameters"]["id"]; }; - query: { - /** URL of a wallet address hosted by a Rafiki instance. */ - "wallet-address": components["parameters"]["wallet-address"]; - }; header: { /** The Signature-Input field is a Dictionary structured field containing the metadata for one or more message signatures generated from components within the HTTP message. Each member describes a single message signature. The member's key is the label that uniquely identifies the message signature within the context of the HTTP message. The member's value is the serialization of the covered components Inner List plus all signature metadata parameters identified by the label. The following components MUST be included: - "@method" - "@target-uri" - "authorization". When the message contains a request body, the covered components MUST also include the following: - "content-digest" The keyid parameter of the signature MUST be set to the kid value of the JWK. See [ietf-httpbis-message-signatures](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-message-signatures#section-4.1) for more details. */ "Signature-Input": components["parameters"]["signature-input"]; diff --git a/packages/open-payments/src/types.ts b/packages/open-payments/src/types.ts index eedadf3a..c9495b4c 100644 --- a/packages/open-payments/src/types.ts +++ b/packages/open-payments/src/types.ts @@ -51,6 +51,7 @@ export type JWK = RSComponents['schemas']['json-web-key'] export type JWKS = RSComponents['schemas']['json-web-key-set'] export type Quote = RSComponents['schemas']['quote'] type QuoteArgsBase = { + walletAddress: RSOperations['create-quote']['requestBody']['content']['application/json']['walletAddress'] receiver: RSOperations['create-quote']['requestBody']['content']['application/json']['receiver'] method: RSComponents['schemas']['payment-method'] }