From 2ea12f0c4b28d0f0d092d01026cf45bb0ea73a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Talha=20=C3=96zdemir?= Date: Thu, 21 Sep 2023 12:03:47 +0300 Subject: [PATCH] feat: remove connections endpoint from resource spec (#292) * feat: remove connections endpoint from resource spec * feat(openpayments): remove connections route and associated functionality * feat: add changeset --- .changeset/mighty-adults-unite.md | 6 ++ openapi/resource-server.yaml | 36 ----------- .../src/client/ilp-stream-connection.test.ts | 62 ------------------- .../src/client/ilp-stream-connection.ts | 25 -------- packages/open-payments/src/client/index.ts | 15 ----- .../generated/resource-server-types.ts | 45 -------------- 6 files changed, 6 insertions(+), 183 deletions(-) create mode 100644 .changeset/mighty-adults-unite.md delete mode 100644 packages/open-payments/src/client/ilp-stream-connection.test.ts delete mode 100644 packages/open-payments/src/client/ilp-stream-connection.ts diff --git a/.changeset/mighty-adults-unite.md b/.changeset/mighty-adults-unite.md new file mode 100644 index 00000000..889fb7e4 --- /dev/null +++ b/.changeset/mighty-adults-unite.md @@ -0,0 +1,6 @@ +--- +'@interledger/open-payments': minor +'@interledger/openapi': minor +--- + +removed connections route endpoint from the spec and any associated functionality diff --git a/openapi/resource-server.yaml b/openapi/resource-server.yaml index fcfe71a0..8ccc97aa 100644 --- a/openapi/resource-server.yaml +++ b/openapi/resource-server.yaml @@ -103,42 +103,6 @@ paths: operationId: get-payment-pointer-keys description: Retrieve the public keys of the Payment Pointer. security: [] - '/connections/{id}': - servers: - - url: 'https://openpayments.guide' - get: - summary: Get ILP STREAM credentials for a connection - tags: - - stream-connection - responses: - '200': - description: Connection Found - content: - application/json: - schema: - $ref: '#/components/schemas/ilp-stream-connection' - examples: - Get connection: - value: - id: 'https://openpayments.guide/connections/016da9d5-c9a4-4c80-a354-86b915a04ff8' - ilpAddress: g.ilp.iwuyge987y.98y0f34tsrt8y - sharedSecret: 1c7eaXa4rd2fFOBl1iydvCT1tV5TbM3RW1WLCafu_JA - assetCode: USD - assetScale: 2 - '404': - description: Connection Not Found - operationId: get-ilp-stream-connection - description: |- - *NB* Use server url specific to this path. - - Fetch new connection credentials for an ILP STREAM connection. - - A connection is an ephemeral resource that is created to accommodate new incoming payments. - - A new set of credential will be generated each time this API is called. - security: [] - parameters: - - $ref: '#/components/parameters/id' /incoming-payments: post: summary: Create an Incoming Payment diff --git a/packages/open-payments/src/client/ilp-stream-connection.test.ts b/packages/open-payments/src/client/ilp-stream-connection.test.ts deleted file mode 100644 index 9c77831f..00000000 --- a/packages/open-payments/src/client/ilp-stream-connection.test.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { createILPStreamConnectionRoutes } from './ilp-stream-connection' -import { OpenAPI, HttpMethod, createOpenAPI } from '@interledger/openapi' -import path from 'path' -import { - defaultAxiosInstance, - mockILPStreamConnection, - silentLogger -} from '../test/helpers' -import * as requestors from './requests' - -jest.mock('./requests', () => { - return { - // https://jestjs.io/docs/jest-object#jestmockmodulename-factory-options - __esModule: true, - ...jest.requireActual('./requests') - } -}) - -describe('ilp-stream-connection', (): void => { - let openApi: OpenAPI - - beforeAll(async () => { - openApi = await createOpenAPI( - path.resolve(__dirname, '../openapi/resource-server.yaml') - ) - }) - - const axiosInstance = defaultAxiosInstance - const logger = silentLogger - - describe('routes', (): void => { - const ilpStreamConnection = mockILPStreamConnection() - - describe('get', (): void => { - test('calls get method with correct validator', async (): Promise => { - const mockResponseValidator = ({ path, method }) => - path === '/connections/{id}' && method === HttpMethod.GET - - jest - .spyOn(openApi, 'createResponseValidator') - // eslint-disable-next-line @typescript-eslint/no-explicit-any - .mockImplementation(mockResponseValidator as any) - - const getSpy = jest - .spyOn(requestors, 'get') - .mockResolvedValueOnce(ilpStreamConnection) - - await createILPStreamConnectionRoutes({ - openApi, - axiosInstance, - logger - }).get({ url: ilpStreamConnection.id }) - - expect(getSpy).toHaveBeenCalledWith( - { axiosInstance, logger }, - { url: ilpStreamConnection.id }, - true - ) - }) - }) - }) -}) diff --git a/packages/open-payments/src/client/ilp-stream-connection.ts b/packages/open-payments/src/client/ilp-stream-connection.ts deleted file mode 100644 index 1703c30e..00000000 --- a/packages/open-payments/src/client/ilp-stream-connection.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { HttpMethod } from '@interledger/openapi' -import { RouteDeps, UnauthenticatedResourceRequestArgs } from '.' -import { getRSPath, ILPStreamConnection } from '../types' -import { get } from './requests' - -export interface ILPStreamConnectionRoutes { - get(args: UnauthenticatedResourceRequestArgs): Promise -} - -export const createILPStreamConnectionRoutes = ( - deps: RouteDeps -): ILPStreamConnectionRoutes => { - const { axiosInstance, openApi, logger } = deps - - const getILPStreamConnectionValidator = - openApi.createResponseValidator({ - path: getRSPath('/connections/{id}'), - method: HttpMethod.GET - }) - - return { - get: (args: UnauthenticatedResourceRequestArgs) => - get({ axiosInstance, logger }, args, getILPStreamConnectionValidator) - } -} diff --git a/packages/open-payments/src/client/index.ts b/packages/open-payments/src/client/index.ts index d6d89156..f9f02252 100644 --- a/packages/open-payments/src/client/index.ts +++ b/packages/open-payments/src/client/index.ts @@ -7,10 +7,6 @@ import { createIncomingPaymentRoutes, IncomingPaymentRoutes } from './incoming-payment' -import { - createILPStreamConnectionRoutes, - ILPStreamConnectionRoutes -} from './ilp-stream-connection' import { createPaymentPointerRoutes, PaymentPointerRoutes @@ -110,7 +106,6 @@ export interface CreateUnauthenticatedClientArgs { } export interface UnauthenticatedClient { - ilpStreamConnection: ILPStreamConnectionRoutes paymentPointer: PaymentPointerRoutes } @@ -125,11 +120,6 @@ export const createUnauthenticatedClient = async ( ) return { - ilpStreamConnection: createILPStreamConnectionRoutes({ - axiosInstance, - openApi: resourceServerOpenApi, - logger - }), paymentPointer: createPaymentPointerRoutes({ axiosInstance, openApi: resourceServerOpenApi, @@ -173,11 +163,6 @@ export const createAuthenticatedClient = async ( openApi: resourceServerOpenApi, logger }), - ilpStreamConnection: createILPStreamConnectionRoutes({ - axiosInstance, - openApi: resourceServerOpenApi, - logger - }), paymentPointer: createPaymentPointerRoutes({ axiosInstance, openApi: resourceServerOpenApi, 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 9157c59e..87cfbeb7 100644 --- a/packages/open-payments/src/openapi/generated/resource-server-types.ts +++ b/packages/open-payments/src/openapi/generated/resource-server-types.ts @@ -18,24 +18,6 @@ export interface paths { /** Retrieve the public keys of the Payment Pointer. */ get: operations["get-payment-pointer-keys"]; }; - "/connections/{id}": { - /** - * *NB* Use server url specific to this path. - * - * Fetch new connection credentials for an ILP STREAM connection. - * - * A connection is an ephemeral resource that is created to accommodate new incoming payments. - * - * A new set of credential will be generated each time this API is called. - */ - get: operations["get-ilp-stream-connection"]; - parameters: { - path: { - /** Sub-resource identifier */ - id: components["parameters"]["id"]; - }; - }; - }; "/incoming-payments": { /** List all incoming payments on the payment pointer */ get: operations["list-incoming-payments"]; @@ -371,33 +353,6 @@ export interface operations { 404: unknown; }; }; - /** - * *NB* Use server url specific to this path. - * - * Fetch new connection credentials for an ILP STREAM connection. - * - * A connection is an ephemeral resource that is created to accommodate new incoming payments. - * - * A new set of credential will be generated each time this API is called. - */ - "get-ilp-stream-connection": { - parameters: { - path: { - /** Sub-resource identifier */ - id: components["parameters"]["id"]; - }; - }; - responses: { - /** Connection Found */ - 200: { - content: { - "application/json": components["schemas"]["ilp-stream-connection"]; - }; - }; - /** Connection Not Found */ - 404: unknown; - }; - }; /** List all incoming payments on the payment pointer */ "list-incoming-payments": { parameters: {