From 2f828a700fbd423f4007f9b50265d18579717825 Mon Sep 17 00:00:00 2001 From: "v.snigerev" Date: Sat, 6 Jun 2026 20:39:07 +0300 Subject: [PATCH] test(invoices): pin endpoint A contract for server-side encryption (DEV-202) The privara SDK is a thin REST client with no crypto, so moving FHE encryption into the backend Lambda (server-side endpoint A) needs no SDK change. Add a regression test pinning create() to POST /api/v1/invoices with the request contract unchanged, so SDK consumers are unaffected by the migration. Agent-payments inherit in-Lambda encryption transparently via the CreateInvoice container (they call this same endpoint through the SDK). Containerizing the CreateAgentPayment Lambda for in-process FHE belongs with the agent-payment-direct-domain-call refactor. --- tests/resources/invoices.test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/resources/invoices.test.ts b/tests/resources/invoices.test.ts index 0178896..0d6b49f 100644 --- a/tests/resources/invoices.test.ts +++ b/tests/resources/invoices.test.ts @@ -45,6 +45,29 @@ describe('Invoices resource', () => { expect(headers['X-Idempotency-Key']).toBeTruthy(); }); + // DEV-202: the SDK is a thin REST client with no crypto. Moving encryption + // into the backend Lambda (server-side endpoint A) must keep the create() + // path + request contract identical so SDK consumers need zero changes. + it('create() targets endpoint A (POST /api/v1/invoices) with the contract unchanged', async () => { + mockFetch({ public_id: 'inv_1', challenge_id: 'ch_1' }); + + const params = { + from: 'test@test.com', + due_date: '2025-12-31', + reference: 'Test', + amount: 100, + currency: { type: 'crypto', code: 'USDC' }, + wallet_id: 'w_1', + } as const; + + await privara.invoices.create(params); + + const [url, init] = (globalThis.fetch as ReturnType).mock.calls[0]; + expect(url).toBe('https://api.test.io/api/v1/invoices'); + expect(init.method).toBe('POST'); + expect(JSON.parse(init.body as string)).toEqual(params); + }); + it('gets an invoice without auth', async () => { mockFetch(mockInvoice); await privara.invoices.get('inv_1');