@01.software/sdk 0.45.0 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @01.software/sdk
2
2
 
3
+ ## 0.46.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8742373: Add a server-only custom PaymentSession bridge with typed create and confirm
8
+ operations, strict safe projections, exact-body optional HMAC proof signing,
9
+ and shared OpenAPI transport parity.
10
+
3
11
  ## 0.45.0
4
12
 
5
13
  ### Minor Changes
package/MIGRATION.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @01.software/sdk Migration Notes
2
2
 
3
+ ## SDK 0.46 server-only custom-provider bridge (#3485)
4
+
5
+ SDK 0.46 adds
6
+ `createServerClient().commerce.paymentSessions.custom.create/confirm` for the
7
+ existing bounded custom PaymentSession endpoints. This is additive and
8
+ server-only: browser clients and the package root expose neither the namespace
9
+ nor its custom types.
10
+
11
+ Create requires a durable header idempotency key and returns only
12
+ `{ id, provider, providerSessionId, money }`. The caller independently verifies
13
+ its provider API response or signed webhook, then confirms the exact provider
14
+ session/payment/event identities and captured Money. Where tenant policy
15
+ requires custom-payment HMAC, pass `createProof(rawBody)` as the confirm option;
16
+ it signs the exact JSON bytes sent by the SDK.
17
+
18
+ This bridge does not restore `orders.create`, `orders.confirmPayment`, or
19
+ `orders.updateTransaction`, and it is not adapter support, refund authority, or
20
+ a manual/offline pending-order placement API.
21
+
3
22
  ## SDK 0.45 canonical commerce surface (#2375)
4
23
 
5
24
  Target release: `0.45.0`. This is a `BREAKING (0.x minor)` release.
package/README.md CHANGED
@@ -1383,6 +1383,49 @@ const checkoutPage = await server.commerce.checkouts.query({
1383
1383
  void checkoutPage.nextCursor
1384
1384
  ```
1385
1385
 
1386
+ For a provider that is not backed by a first-party adapter, trusted server code
1387
+ can use the bounded custom bridge. The caller must first verify the provider's
1388
+ authoritative API response or signed webhook, then report the exact captured
1389
+ identity and Money. The create response is intentionally limited to
1390
+ `{ id, provider, providerSessionId, money }`.
1391
+
1392
+ ```typescript
1393
+ const customSession = await server.commerce.paymentSessions.custom.create({
1394
+ provider: 'my-provider',
1395
+ checkoutToken,
1396
+ idempotencyKey: createCommerceIdempotencyKey(),
1397
+ })
1398
+
1399
+ const verifiedCapture = await verifyMyProviderCapture({
1400
+ expectedAmount: customSession.money.amountMinor,
1401
+ expectedCurrency: customSession.money.currency,
1402
+ })
1403
+
1404
+ if (!verifiedCapture.ok) throw new Error('Provider capture was not verified')
1405
+
1406
+ const customConfirmation = await server.commerce.paymentSessions.custom.confirm(
1407
+ {
1408
+ provider: customSession.provider,
1409
+ providerSessionId: customSession.providerSessionId,
1410
+ providerPaymentId: verifiedCapture.paymentId,
1411
+ providerEventId: verifiedCapture.eventId,
1412
+ amount: customSession.money.amountMinor,
1413
+ currency: customSession.money.currency,
1414
+ occurredAt: verifiedCapture.occurredAt,
1415
+ },
1416
+ )
1417
+
1418
+ console.log(customConfirmation.orderId)
1419
+ ```
1420
+
1421
+ If the tenant's custom-provider policy requires HMAC, pass
1422
+ `{ createProof(rawBody) }` as the second argument to `custom.confirm`. The
1423
+ callback receives the exact JSON bytes the SDK sends and returns `{ timestamp,
1424
+ signature }`; signature headers are redacted from SDK debug output. This is not
1425
+ a generic “mark paid” API, adapter support, refund authority, or a manual/offline
1426
+ pending-order flow. Use Draft Orders for current back-office manual pending
1427
+ orders; storefront manual/offline placement is a separate capability.
1428
+
1386
1429
  `checkoutToken` is returned only alongside Checkout creation; ordinary Checkout
1387
1430
  DTOs never echo the bearer capability. Browser `checkouts.retrieve` and
1388
1431
  PaymentSession retrieve/cancel calls accept that token. Server
@@ -1396,10 +1439,12 @@ is preserved as `reason: 'unknown_commerce_error'` plus `rawReason`.
1396
1439
  ### Commerce Orders (post-placement operations)
1397
1440
 
1398
1441
  Provider-paid `orders.create`, `orders.confirmPayment`, and ordinary
1399
- `orders.updateTransaction` were removed in SDK 0.45. No general manual Order API
1400
- is exposed. After a PaymentSession commits an Order, trusted server code can use
1401
- the remaining fulfillment, cancellation, and return operations. Customer order
1402
- reads remain available through `client.commerce.orders.listMine()`.
1442
+ `orders.updateTransaction` were removed in SDK 0.45. The server-only custom
1443
+ PaymentSession bridge above does not restore those methods or expose a general
1444
+ manual Order API. After a PaymentSession commits an Order, trusted server code
1445
+ can use the remaining fulfillment, cancellation, and return operations.
1446
+ Customer order reads remain available through
1447
+ `client.commerce.orders.listMine()`.
1403
1448
 
1404
1449
  The SDK root no longer exports raw generated `Order`, `Transaction`, `Cart`, or
1405
1450
  `CartItem` Payload documents. Use the canonical `PublicOrder` / `PublicCart`
package/dist/client.cjs CHANGED
@@ -403,6 +403,11 @@ function redactSensitiveHeaders(headers) {
403
403
  redacted["x-preview-token"]
404
404
  );
405
405
  }
406
+ if (redacted["x-custom-payment-signature"]) {
407
+ redacted["x-custom-payment-signature"] = redactSensitiveHeader(
408
+ redacted["x-custom-payment-signature"]
409
+ );
410
+ }
406
411
  return redacted;
407
412
  }
408
413
  function getErrorSuggestion(status) {
@@ -1396,6 +1401,14 @@ var COMMERCE_ENDPOINTS = {
1396
1401
  create: endpoint("POST", "/api/payment-sessions/create"),
1397
1402
  retrieve: endpoint("POST", "/api/payment-sessions/retrieve"),
1398
1403
  cancel: endpoint("POST", "/api/payment-sessions/cancel"),
1404
+ custom: {
1405
+ create: sharedEndpoint(
1406
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.create
1407
+ ),
1408
+ confirm: sharedEndpoint(
1409
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.confirm
1410
+ )
1411
+ },
1399
1412
  server: {
1400
1413
  create: endpoint("POST", "/api/payment-sessions/server/create"),
1401
1414
  retrieve: endpoint("POST", "/api/payment-sessions/server/retrieve"),