@01.software/sdk 0.49.0 → 0.51.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +130 -1
  2. package/MIGRATION.md +56 -0
  3. package/README.md +215 -45
  4. package/dist/client.cjs +188 -137
  5. package/dist/client.cjs.map +1 -1
  6. package/dist/client.d.cts +6 -6
  7. package/dist/client.d.ts +6 -6
  8. package/dist/client.js +188 -137
  9. package/dist/client.js.map +1 -1
  10. package/dist/{collection-client-XfGLPuTf.d.cts → collection-client-CWAeuzV4.d.cts} +6 -4
  11. package/dist/{collection-client-DnDt6EQz.d.ts → collection-client-hYvVfHIm.d.ts} +6 -4
  12. package/dist/{const-DCNV5Kq7.d.ts → const-D8LixhAJ.d.cts} +5 -5
  13. package/dist/{const-CBba4lDo.d.cts → const-JD8obaKg.d.ts} +5 -5
  14. package/dist/embedded-admin/server.cjs +306 -0
  15. package/dist/embedded-admin/server.cjs.map +1 -0
  16. package/dist/embedded-admin/server.d.cts +33 -0
  17. package/dist/embedded-admin/server.d.ts +33 -0
  18. package/dist/embedded-admin/server.js +288 -0
  19. package/dist/embedded-admin/server.js.map +1 -0
  20. package/dist/embedded-admin.cjs +400 -0
  21. package/dist/embedded-admin.cjs.map +1 -0
  22. package/dist/embedded-admin.d.cts +61 -0
  23. package/dist/embedded-admin.d.ts +61 -0
  24. package/dist/embedded-admin.js +377 -0
  25. package/dist/embedded-admin.js.map +1 -0
  26. package/dist/errors.cjs +1 -0
  27. package/dist/errors.cjs.map +1 -1
  28. package/dist/errors.d.cts +3 -3
  29. package/dist/errors.d.ts +3 -3
  30. package/dist/errors.js +1 -0
  31. package/dist/errors.js.map +1 -1
  32. package/dist/{index-CbKyoEzy.d.cts → index-B0Hjh3Ey.d.ts} +72 -10
  33. package/dist/{index-DUuIqUS8.d.ts → index-Bu0kCc6o.d.cts} +72 -10
  34. package/dist/index.cjs +320 -383
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +8 -66
  37. package/dist/index.d.ts +8 -66
  38. package/dist/index.js +320 -383
  39. package/dist/index.js.map +1 -1
  40. package/dist/{payload-types-MKbx5MuJ.d.cts → payload-types-BOsckg8B.d.cts} +263 -54
  41. package/dist/{payload-types-MKbx5MuJ.d.ts → payload-types-BOsckg8B.d.ts} +263 -54
  42. package/dist/query.cjs +94 -70
  43. package/dist/query.cjs.map +1 -1
  44. package/dist/query.d.cts +5 -5
  45. package/dist/query.d.ts +5 -5
  46. package/dist/query.js +94 -70
  47. package/dist/query.js.map +1 -1
  48. package/dist/realtime.d.cts +2 -2
  49. package/dist/realtime.d.ts +2 -2
  50. package/dist/server.cjs +404 -162
  51. package/dist/server.cjs.map +1 -1
  52. package/dist/server.d.cts +7 -7
  53. package/dist/server.d.ts +7 -7
  54. package/dist/server.js +404 -162
  55. package/dist/server.js.map +1 -1
  56. package/dist/storefront-cache.cjs +1 -0
  57. package/dist/storefront-cache.cjs.map +1 -1
  58. package/dist/storefront-cache.js +1 -0
  59. package/dist/storefront-cache.js.map +1 -1
  60. package/dist/{types-L_nh-ED7.d.ts → types-5ZlcAFuU.d.ts} +2 -2
  61. package/dist/{types-BKr_2avj.d.cts → types-B14sEt1z.d.cts} +2 -2
  62. package/dist/{types-1UeOk1Uy.d.cts → types-Bj8j7VHU.d.ts} +79 -23
  63. package/dist/{types-Du4s5anw.d.ts → types-CM5qiR2k.d.cts} +79 -23
  64. package/dist/ui/form.d.cts +1 -1
  65. package/dist/ui/form.d.ts +1 -1
  66. package/dist/ui/video.d.cts +1 -1
  67. package/dist/ui/video.d.ts +1 -1
  68. package/dist/webhook.cjs +124 -80
  69. package/dist/webhook.cjs.map +1 -1
  70. package/dist/webhook.d.cts +21 -5
  71. package/dist/webhook.d.ts +21 -5
  72. package/dist/webhook.js +124 -80
  73. package/dist/webhook.js.map +1 -1
  74. package/package.json +23 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,134 @@
1
1
  # @01.software/sdk
2
2
 
3
+ ## 0.51.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8dd8ef7: BREAKING (0.x minor): reclassify `discounts` from the browser-public
8
+ `COLLECTIONS` bucket to `SERVER_ONLY_COLLECTIONS`. This is the
9
+ `PLAT-API-002` security/implementation-boundary correction: raw discount
10
+ definitions require a server credential, so a publishable-key-only raw read
11
+ never succeeded. Browser discount validation remains available through the
12
+ existing shaped `POST /api/discounts/validate` operation.
13
+
14
+ `SERVER_COLLECTIONS` continues to include `discounts` for secret-key/PAT SDK
15
+ clients. The browser `PublicCollection` union no longer accepts `discounts`,
16
+ and the raw REST route now rejects its publishable-key-only reads at the
17
+ server-only guard (404) rather than at collection access (403). Contract v1.23.0
18
+ is a compatible correction of that false callable-surface claim; this SDK
19
+ package change is still a pre-1.0 breaking minor under `docs/packages/release.md`.
20
+
21
+ - b08250c: Add a redacted `01 doctor` app-integration diagnostic with structured Agent CLI output.
22
+ Its explicit app environment input is the Node-runtime-safe `--app-env-file`.
23
+
24
+ Export the canonical tenant-context path on the SDK server entry for the
25
+ diagnostic-only, uncredentialed CORS probe.
26
+
27
+ Print the redacted app-integration diagnostic as the next setup step only for
28
+ Next.js and Node targets that receive its required app credential pair.
29
+
30
+ - bf6df96: BREAKING (0.x minor): Make signed webhook receivers fail closed when their
31
+ signing secret is missing, empty, or blank. Use `handleSignedWebhook()` for the
32
+ default signed path and `handleUnsignedWebhook()` only for an intentionally
33
+ unsigned endpoint; both new names and `SignedWebhookOptions` are exported from
34
+ `@01.software/sdk/webhook`, not the SDK root. The deprecated `handleWebhook()`
35
+ and `WebhookOptions` compatibility exports remain available at their existing
36
+ root and webhook-subpath locations, require signed options, and follow the same
37
+ fail-closed runtime behavior.
38
+
39
+ `toleranceSeconds` is now validated. It keeps its 300-second default for an
40
+ absent or null value, but a present value must be a number within an inclusive
41
+ 0-86400-second range; anything else (including `Infinity`, `NaN`, a negative
42
+ number, a non-number, or a week-long window) is a configuration error that
43
+ returns 500 with a distinct tolerance message before the body is consumed.
44
+
45
+ - 2ce3aa9: Add explicit embedded-admin browser and server SDK entrypoints for the receiver
46
+ handshake and strict assertion verification. Add the PAT-only Human CLI
47
+ `embedded-app show`, `configure`, and `disable` commands for single-binding
48
+ management.
49
+
50
+ ### Patch Changes
51
+
52
+ - 48372ad: Synchronize the optional tenant embedded-admin binding in generated Payload
53
+ types. This does not add an SDK method or expose embedded session credentials.
54
+ - 3fb53f0: Clarify PAT revocation audit metadata for trusted machine reconciliation.
55
+ - eea3ea8: Align canonical Order and Checkout response validation with the authoritative non-empty nullable item fields.
56
+ - 46c32e6: Ensure the packed SDK runtime declares its `jose` dependency with the portable
57
+ npm range used by standalone consumers.
58
+ - a1567cc: Validate SDK release tarballs with patched package-analysis dependencies.
59
+ - 9fecd85: Register the internal `commerce-payment-webhook-routes` collection so the SDK
60
+ collection registry stays in lockstep with Console. The collection is
61
+ Console-internal PortOne webhook routing state: it adds no SDK method, appears
62
+ in no public or server-only bucket, and exposes no credential.
63
+ - 41fbcb6: Synchronize required customer, period-end, and idempotency-key fields for the
64
+ SDK-hidden `membership-charges` generated type. The collection remains
65
+ server-only and gains no public write method.
66
+
67
+ ## 0.50.0
68
+
69
+ ### Minor Changes
70
+
71
+ - 0e0ab60: Add server-only full-tuple PortOne payment find and durable reconciliation methods, including atomic domain-and-receipt completion for crash-safe same-key replay.
72
+ - 743b895: Add optional canonical `allDayStartDate` and exclusive
73
+ `allDayEndDateExclusive` fields to public event-range DTOs while retaining
74
+ instant compatibility shadows and existing TypeScript object-literal source
75
+ compatibility. Generated Event types also add optional canonical
76
+ `recurrence.untilDate` for all-day structured recurrence; existing object
77
+ literals that omit it remain valid.
78
+ - 743b895: Expose `managed_refund_attestation_forbidden` as the typed commerce error for registered managed captures while preserving existing cancel-refund errors and detail placement.
79
+ - 6b584bc: Expose the PortOne Standard V2 action's permanent non-cancelability and exact-action-only retry policy through an exact negotiated create/retrieve projection, while normalizing released Console responses for bidirectional non-lockstep compatibility. Console may deploy first because unnegotiated responses retain the released exact shape; the SDK may deploy first because it accepts and normalizes that old-server shape. Hosted create and all cancel operations remain unnegotiated. Package publication remains a separate post-merge release action.
80
+ - 743b895: BREAKING (0.x minor): Retire the expired ADR 0025 product media compatibility
81
+ shims. `resolveProductMedia()` and `resolveProductGallery()` — plus their
82
+ compatibility-only types `MediaPointerSource`, `ResolveProductMediaInput`,
83
+ `ResolveProductMediaResult`, `ProductMediaSetMatchType`, `ProductMediaSetInput`,
84
+ `ProductGallerySource`, `ResolveProductGalleryInput`, and
85
+ `ResolveProductGalleryResult` — are no longer exported from the package root or
86
+ `utils`.
87
+
88
+ These shipped in 0.34.0 as a one-release migration aid and forwarded to the
89
+ canonical resolvers. Replace `resolveProductMedia()` and
90
+ `resolveProductGallery()` with `resolveProductSelectionMedia()` for
91
+ variant/option selection media and `resolveProductDisplayMedia()` for listing
92
+ and PDP display fallback. Pre-ADR-0025 `mediaSets` inputs have no replacement:
93
+ variant `images[]` subsets and `product-option-values.swatch.mediaItemId` are
94
+ the canonical selection sources.
95
+
96
+ Canonical selection and display precedence, result shapes, and edge-case
97
+ behavior are unchanged. See `packages/published/sdk/MIGRATION.md`.
98
+
99
+ - bca928f: Add provider-neutral `paymentReconciliationRequired` and
100
+ `paymentRefundRequiresAttention` commerce notification webhook types, handlers,
101
+ and runtime validation.
102
+
103
+ ### Patch Changes
104
+
105
+ - 743b895: Expose the nullable ownership scope on the generated server-only inbound
106
+ webhook ledger document type.
107
+ - 743b895: Align commerce endpoint descriptors with the shared HTTP contract manifest without changing endpoint methods, paths, or error families.
108
+ - 743b895: Expose the additive Toss capture-evidence variants in generated private
109
+ PaymentSession types while preserving the existing public payment API.
110
+ - 743b895: Expose the additive durable Return-refund canonical envelope and stable
111
+ post-commit replay outcome in generated Payload types. Refund execution now
112
+ rejects changed payment identity and cross-tenant explicit-key reuse before
113
+ provider I/O while preserving identical cache-loss replay payloads.
114
+ - 0c4c5fd: Synchronize generated ProviderConnection configuration-attestation fields for
115
+ the SDK-hidden `commerce-payment-accounts` collection. The operator-only REST
116
+ actions remain internal to Console and add no public SDK transport method.
117
+ - 743b895: Standardize customer-facing Console terminology in initialization guidance and
118
+ generated SDK descriptions without changing runtime behavior or API contracts.
119
+ - 743b895: Remove the unsupported minor and guardian-consent fields from generated
120
+ server-only Customer document types as a privacy correction. Shaped customer
121
+ registration and `/me` response types are unchanged.
122
+ - 743b895: Clarify the generated webhook subscription descriptions: an empty subscription
123
+ list is a wildcard for ordinary collection create/update events only, and
124
+ commerce notifications require an explicit row for their source collection.
125
+ Descriptions only — no schema, runtime, or API contract change.
126
+ - 743b895: Add optional sanitized commerce notification diagnostics fields (`eventType`,
127
+ `notificationEvent`, `notificationIntentId`, `notificationDedupeKey`,
128
+ `sourceId`) to the generated internal `WebhookDelivery` document type. The
129
+ collection stays internal and is not exposed through the SDK surface;
130
+ existing object literals remain valid because every field is optional.
131
+
3
132
  ## 0.49.0
4
133
 
5
134
  ### Minor Changes
@@ -1070,7 +1199,7 @@ displayStatus` JSDoc comment from `Order.status`. The Console removed that
1070
1199
  disabled. Customer auth failures now surface the same SDK-specific error classes
1071
1200
  as other SDK requests instead of the previous generic API error shape.
1072
1201
 
1073
- ## Unreleased
1202
+ ## Historical 0.34.0 migration notes
1074
1203
 
1075
1204
  ### Minor Changes
1076
1205
 
package/MIGRATION.md CHANGED
@@ -1,5 +1,61 @@
1
1
  # @01.software/sdk Migration Notes
2
2
 
3
+ ## Product media compatibility shim retirement (#721)
4
+
5
+ This is a `BREAKING (0.x minor)` change. The ADR 0025 one-release compatibility
6
+ shims first published in `0.34.0` are removed from the package root and
7
+ `utils`.
8
+
9
+ | Removed | Replacement |
10
+ | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
11
+ | `resolveProductMedia(input)` | `resolveProductSelectionMedia(input)`, then `resolveProductDisplayMedia(input)` fallback |
12
+ | `resolveProductGallery(input)` | `resolveProductSelectionMedia(input)`, then `resolveProductDisplayMedia(input)` fallback |
13
+ | `ResolveProductMediaInput` / `ResolveProductGalleryInput` | `ResolveProductSelectionMediaInput` |
14
+ | `ResolveProductMediaResult` / `ResolveProductGalleryResult` | `ResolveProductSelectionMediaResult` |
15
+ | `MediaPointerSource` / `ProductGallerySource` | `ProductSelectionMediaSource` / `ProductDisplayMediaSource` |
16
+ | `ProductMediaSetInput` / `ProductMediaSetMatchType` | none; use variant `images[]` and `swatch.mediaItemId` |
17
+
18
+ ```ts
19
+ // Before
20
+ const gallery = resolveProductGallery({
21
+ pool: product.images,
22
+ selectedVariantId: variant.id,
23
+ selectedOptionValueIds: valueIds,
24
+ })
25
+
26
+ // After
27
+ const selection = resolveProductSelectionMedia({
28
+ productMediaPool: product.images,
29
+ selectedVariant: variant,
30
+ selectedOptionValues: optionValues,
31
+ })
32
+ const media =
33
+ selection.source === 'none'
34
+ ? resolveProductDisplayMedia({
35
+ productMediaPool: product.images,
36
+ featuredImage: product.featuredImage,
37
+ })
38
+ : selection
39
+ ```
40
+
41
+ Use this two-step sequence when replacing either shim. Stopping after a
42
+ selection result with `source === 'none'` would drop the previous
43
+ featured-image/product-pool display fallback.
44
+
45
+ The shims already forwarded to these resolvers, so canonical selection and
46
+ display precedence, result shapes, and edge-case behavior are unchanged. The
47
+ legacy-only inputs they accepted have no replacement:
48
+ `variantFeaturedMediaItemId` and `selectedOptionValueMediaItemIds` become
49
+ `selectedVariant.images[]` and `selectedOptionValues[].swatch`, the `legacy`
50
+ direct-media object was already ignored, and `mediaSets` was removed from the
51
+ product schema before the shims expired.
52
+
53
+ `source` values also narrow: the shim-only `'variant_featured'`,
54
+ `'exact_variant_set'`, `'option_value_set'`, and `'default_set'` values are gone.
55
+ Selection media reports `'variant_media_selected'`, `'variant_media_matching'`,
56
+ `'option_swatch'`, or `'none'`; display media reports `'featured_image'`,
57
+ `'product_pool'`, or `'none'`.
58
+
3
59
  ## SDK 0.46 server-only custom-provider bridge (#3485)
4
60
 
5
61
  SDK 0.46 adds
package/README.md CHANGED
@@ -33,7 +33,7 @@ import { createServerClient, isCommerceSDKError } from '@01.software/sdk/server'
33
33
 
34
34
  // Webhook only - webhook handlers
35
35
  import {
36
- handleWebhook,
36
+ handleSignedWebhook,
37
37
  createTypedWebhookHandler,
38
38
  } from '@01.software/sdk/webhook'
39
39
 
@@ -43,6 +43,12 @@ import { RealtimeConnection } from '@01.software/sdk/realtime'
43
43
  // Storefront cache resource names for SSG/ISR adapters
44
44
  import { storefrontCacheResources } from '@01.software/sdk/storefront-cache'
45
45
 
46
+ // Embedded app browser handshake
47
+ import { receiveEmbeddedAdminSession } from '@01.software/sdk/embedded-admin'
48
+
49
+ // Embedded app backend verification
50
+ import { verifyEmbeddedAdminSession } from '@01.software/sdk/embedded-admin/server'
51
+
46
52
  // Components - sub-path imports per domain
47
53
  import { Analytics } from '@01.software/sdk/analytics/react'
48
54
  import { RichTextContent } from '@01.software/sdk/ui/rich-text'
@@ -58,26 +64,28 @@ types lightweight. Server, React Query, and UI features live behind explicit
58
64
  sub-paths so consumers install feature peers only when they import the matching
59
65
  entry.
60
66
 
61
- | Import | Feature(s) | Install when used |
62
- | ----------------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------- |
63
- | `@01.software/sdk` | browser-safe `createClient`, commerce helpers, collection helpers, types | none |
64
- | `@01.software/sdk/client` | browser-safe `createClient` entry and SDK error guards | none |
65
- | `@01.software/sdk/server` | `createServerClient`, server-only APIs, and SDK error guards | none; keep `secretKey` code on the server |
66
- | `@01.software/sdk/errors` | SDK error classes and guards | none |
67
- | `@01.software/sdk/analytics` | browser analytics client and typed event helpers | none |
68
- | `@01.software/sdk/metadata` | SEO metadata extraction and generation helpers | none |
69
- | `@01.software/sdk/webhook` | webhook handlers, event guards, and webhook types | none |
70
- | `@01.software/sdk/query` | React Query hooks, cache helpers, `getQueryClient` | `@tanstack/react-query`, `react`, `react-dom` |
71
- | `@01.software/sdk/realtime` | `RealtimeConnection`, `useRealtimeQuery` | `@tanstack/react-query`, `react`, `react-dom` |
72
- | `@01.software/sdk/storefront-cache` | product storefront cache resource name helpers | none |
73
- | `@01.software/sdk/analytics/react` | `<Analytics />` | `react`, `react-dom` |
74
- | `@01.software/sdk/ui/rich-text` | `RichTextContent`, `StyledRichTextContent` | `react`, `react-dom`, `@payloadcms/richtext-lexical` |
75
- | `@01.software/sdk/ui/form` | `FormRenderer` | `react`, `react-dom` |
76
- | `@01.software/sdk/ui/code-block` | `CodeBlock`, `highlight` | `react`, `react-dom`, `shiki`, `hast-util-to-jsx-runtime` |
77
- | `@01.software/sdk/ui/canvas` | `CanvasRenderer`, `CanvasFrame`, `useCanvas`, `prefetchCanvas` | `react`, `react-dom`, `@tanstack/react-query`, `@xyflow/react`, `quickjs-emscripten`, `postcss`, `sucrase` |
78
- | `@01.software/sdk/ui/canvas/server` | canvas server helpers | none |
79
- | `@01.software/sdk/ui/video` | `VideoPlayer` | `react`, `react-dom`, `@mux/mux-player-react` |
80
- | `@01.software/sdk/ui/image` | `Image` | `react`, `react-dom` |
67
+ | Import | Feature(s) | Install when used |
68
+ | ---------------------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------- |
69
+ | `@01.software/sdk` | browser-safe `createClient`, commerce helpers, collection helpers, types | none |
70
+ | `@01.software/sdk/client` | browser-safe `createClient` entry and SDK error guards | none |
71
+ | `@01.software/sdk/server` | `createServerClient`, server-only APIs, and SDK error guards | none; keep `secretKey` code on the server |
72
+ | `@01.software/sdk/errors` | SDK error classes and guards | none |
73
+ | `@01.software/sdk/analytics` | browser analytics client and typed event helpers | none |
74
+ | `@01.software/sdk/metadata` | SEO metadata extraction and generation helpers | none |
75
+ | `@01.software/sdk/webhook` | webhook handlers, event guards, and webhook types | none |
76
+ | `@01.software/sdk/query` | React Query hooks, cache helpers, `getQueryClient` | `@tanstack/react-query`, `react`, `react-dom` |
77
+ | `@01.software/sdk/realtime` | `RealtimeConnection`, `useRealtimeQuery` | `@tanstack/react-query`, `react`, `react-dom` |
78
+ | `@01.software/sdk/storefront-cache` | product storefront cache resource name helpers | none |
79
+ | `@01.software/sdk/embedded-admin` | embedded app browser handshake and shared protocol types | none |
80
+ | `@01.software/sdk/embedded-admin/server` | assertion verification and JWKS loading | none; keep receiver session creation on the server |
81
+ | `@01.software/sdk/analytics/react` | `<Analytics />` | `react`, `react-dom` |
82
+ | `@01.software/sdk/ui/rich-text` | `RichTextContent`, `StyledRichTextContent` | `react`, `react-dom`, `@payloadcms/richtext-lexical` |
83
+ | `@01.software/sdk/ui/form` | `FormRenderer` | `react`, `react-dom` |
84
+ | `@01.software/sdk/ui/code-block` | `CodeBlock`, `highlight` | `react`, `react-dom`, `shiki`, `hast-util-to-jsx-runtime` |
85
+ | `@01.software/sdk/ui/canvas` | `CanvasRenderer`, `CanvasFrame`, `useCanvas`, `prefetchCanvas` | `react`, `react-dom`, `@tanstack/react-query`, `@xyflow/react`, `quickjs-emscripten`, `postcss`, `sucrase` |
86
+ | `@01.software/sdk/ui/canvas/server` | canvas server helpers | none |
87
+ | `@01.software/sdk/ui/video` | `VideoPlayer` | `react`, `react-dom`, `@mux/mux-player-react` |
88
+ | `@01.software/sdk/ui/image` | `Image` | `react`, `react-dom` |
81
89
 
82
90
  `CanvasRenderer` renders reserved `shape` nodes (`terminator`, `process`,
83
91
  `decision`, `io`, `subprocess`) with first-party SVG geometry, without a tenant
@@ -87,6 +95,54 @@ If a feature is not listed here, it does not need a separate peer install.
87
95
  For the full component-to-peer mapping, see
88
96
  `packages/published/sdk/.claude/rules/components-reference.md`.
89
97
 
98
+ ### Embedded Admin App
99
+
100
+ An embedded admin app is one tenant-owned management UI rendered inside the
101
+ Console Developer Settings surface. The browser helper accepts exactly one
102
+ short-lived Console assertion through the pinned parent/origin challenge. Send
103
+ the receipt immediately to your own backend; do not decode it into a browser
104
+ session or persist it.
105
+
106
+ ```typescript
107
+ import { receiveEmbeddedAdminSession } from '@01.software/sdk/embedded-admin'
108
+
109
+ const receipt = await receiveEmbeddedAdminSession({
110
+ consoleOrigin: 'https://console.01.software',
111
+ })
112
+
113
+ await fetch('/api/embedded-admin/session', {
114
+ method: 'POST',
115
+ headers: { 'Content-Type': 'application/json' },
116
+ body: JSON.stringify(receipt),
117
+ })
118
+ ```
119
+
120
+ The receiver backend verifies the assertion against the Console JWKS and pins
121
+ its own exact origin. Establish an app-local session only after this succeeds.
122
+
123
+ ```typescript
124
+ import { verifyEmbeddedAdminSession } from '@01.software/sdk/embedded-admin/server'
125
+
126
+ const claims = await verifyEmbeddedAdminSession({
127
+ channelId: body.requestId,
128
+ consoleOrigin: 'https://console.01.software',
129
+ destination: 'https://admin.example.com',
130
+ token: body.token,
131
+ })
132
+ ```
133
+
134
+ Tenant admins configure the active tenant's single binding through the Human
135
+ CLI (`01 embedded-app configure`) with a user-scoped PAT. Binding management is
136
+ an operator control-plane action and is intentionally not exposed as a public
137
+ SDK mutation facade. A tenant API key (`sk01_`) is rejected.
138
+
139
+ Loopback HTTP is disabled by default. Only non-production fixtures may set
140
+ `allowLoopbackHttp: true` on the receiver and verifier options.
141
+
142
+ The assertion proves operator and tenant context only. It is not a Console API
143
+ credential; the external backend must use its own server-held credential and
144
+ authorization policy for tenant data.
145
+
90
146
  Migration quick reference:
91
147
 
92
148
  - `createClient` remains available from `@01.software/sdk` and
@@ -196,6 +252,8 @@ honored only when `mode` is unset.
196
252
 
197
253
  ### Client
198
254
 
255
+ <!-- sdk-docs-sync-shaped-first: commerce.product.listingPage -->
256
+
199
257
  ```typescript
200
258
  import { createClient } from '@01.software/sdk'
201
259
 
@@ -203,13 +261,16 @@ const client = createClient({
203
261
  publishableKey: process.env.NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY,
204
262
  })
205
263
 
206
- // Query data (returns Payload native response)
207
- const { docs } = await client.collections.from('products').find({
264
+ // Fetch public-safe, card-ready catalog data through the shaped helper.
265
+ const page = await client.commerce.product.listingPage({
208
266
  limit: 10,
209
- select: { title: true, slug: true },
210
267
  })
268
+ const cards = page.cards
211
269
  ```
212
270
 
271
+ For Payload-native reads that shaped helpers do not cover, use the
272
+ [advanced raw collection escape hatch](#advanced-direct-payload-queries-escape-hatch).
273
+
213
274
  ### Server Client
214
275
 
215
276
  ```typescript
@@ -332,7 +393,7 @@ gallery item DTOs include title, description, content, gallery reference, and
332
393
  image media. Tenant, metadata, draft status, and storage/provider internals are
333
394
  omitted. Gallery item reads require either `gallerySlug` or `galleryId`; prefer
334
395
  `gallerySlug` for storefront routes. The default gallery item sort is `manual`,
335
- matching curator order from the Admin Panel.
396
+ matching curator order from the Console.
336
397
 
337
398
  Both helpers return Payload-style pagination (`docs`, `totalDocs`, `page`,
338
399
  `limit`, etc.). `limit` is bounded server-side to `1..100`; invalid query,
@@ -883,6 +944,20 @@ export default async function ProductPage({ params }) {
883
944
  }
884
945
  ```
885
946
 
947
+ The SDK sends
948
+ `Accept: application/vnd.01software.portone-action-capabilities.v1+json` for
949
+ Standard create and browser/server PortOne retrieve. Hosted create and
950
+ browser/server cancel do not send it. It accepts either the negotiated exact action
951
+ or the released Console's exact action, normalizing the latter to
952
+ `cancelable: false` and `retryPolicy: 'same_action_only'`. Partial capability
953
+ fields, different literals, and unknown response fields still fail closed.
954
+ The Accept value must be that sole exact media type after optional surrounding
955
+ whitespace. Lists, wildcards, parameters, and q-values deliberately retain the
956
+ default projection; this makes either Console-first or SDK-first rollout safe.
957
+ Direct HTTP create/retrieve responses use the vendor `Content-Type` only when
958
+ the successful body actually contains the Standard capability action. Hosted,
959
+ Toss, cancel, confirm, and error responses remain `application/json`.
960
+
886
961
  ## API
887
962
 
888
963
  ### Client Configuration
@@ -1383,8 +1458,16 @@ if (
1383
1458
  standardPortOneSession.presentationStatus === 'actionable' &&
1384
1459
  standardPortOneSession.nextAction.type === 'portone_sdk'
1385
1460
  ) {
1461
+ const { cancelable, retryPolicy, ...paymentRequest } =
1462
+ standardPortOneSession.nextAction
1463
+
1386
1464
  // PortOne V2 requires its currency constant (`CURRENCY_KRW`), not ISO `KRW`.
1387
- // await PortOne.requestPayment(standardPortOneSession.nextAction)
1465
+ // A Standard action cannot be canceled or replaced. After browser failure,
1466
+ // retry only this exact payment request and paymentId instead of calling
1467
+ // cancelPortOne() or creating a sibling PaymentSession.
1468
+ if (!cancelable && retryPolicy === 'same_action_only') {
1469
+ // await PortOne.requestPayment(paymentRequest)
1470
+ }
1388
1471
  // Always retrieve the session afterwards; Console lookup/webhook is authoritative.
1389
1472
  }
1390
1473
 
@@ -1405,6 +1488,24 @@ await server.commerce.paymentSessions.retrievePortOne({
1405
1488
  paymentSessionId: portOneSession.id,
1406
1489
  })
1407
1490
 
1491
+ // Operator recovery can start from PortOne's canonical provider identity.
1492
+ // `findPortOne` is strictly local/read-only. `reconcilePortOne` is an explicit
1493
+ // mutation and must reuse one durable key for retries of the same operation;
1494
+ // its domain result and response complete atomically before delivery.
1495
+ const portOneIdentity = {
1496
+ provider: 'portone' as const,
1497
+ providerAccountKey: 'store-id-from-the-registered-connection',
1498
+ environment: 'test' as const,
1499
+ providerPaymentId: 'provider-assigned-payment-id',
1500
+ }
1501
+ const localPortOneState =
1502
+ await server.commerce.paymentSessions.findPortOne(portOneIdentity)
1503
+ const reconciledPortOneState =
1504
+ await server.commerce.paymentSessions.reconcilePortOne({
1505
+ ...portOneIdentity,
1506
+ idempotencyKey: createCommerceIdempotencyKey(),
1507
+ })
1508
+
1408
1509
  // Toss confirmation is a typed server-only adapter action. There is no generic
1409
1510
  // `confirmVerified` or provider-paid Order creation escape hatch.
1410
1511
  const confirmationIdempotencyKey = createCommerceIdempotencyKey()
@@ -1492,6 +1593,20 @@ if (recovered.finalizationStatus === 'committed') {
1492
1593
  }
1493
1594
  ```
1494
1595
 
1596
+ ### Server-only PortOne identity reconciliation
1597
+
1598
+ The PortOne identity facade is available only from `@01.software/sdk/server`.
1599
+ Both methods require the complete `provider`, `providerAccountKey`,
1600
+ `environment`, and `providerPaymentId` tuple; tenant identity is derived from
1601
+ the server credential and is not accepted in the body. `findPortOne` never
1602
+ calls the provider or mutates local state. `reconcilePortOne` requires write scope and a
1603
+ durable idempotency key, then delegates to the existing managed PortOne
1604
+ convergence engine. A retry after an interrupted response replays the first
1605
+ atomically completed result without repeating provider I/O. Its result distinguishes `applied`, `observed`,
1606
+ `recovered_after_ambiguous_result`, and `requires_attention`. `found: false` is
1607
+ the one HTTP/SDK not-found result; reconciliation does not claim or
1608
+ heuristically attach an unknown provider payment.
1609
+
1495
1610
  `custom.retrieve` is an exact lookup by either `providerSessionId` or
1496
1611
  `providerPaymentId` (exactly one). It returns only bounded recovery state:
1497
1612
  provider identity, session/provider/finalization status, Money, and the resolved
@@ -1562,8 +1677,30 @@ The SDK root no longer exports raw generated `Order`, `Transaction`, `Cart`, or
1562
1677
  `CartItem` Payload documents. Use the canonical `PublicOrder` / `PublicCart`
1563
1678
  DTOs for storefront code and explicit server collection types only inside
1564
1679
  trusted operational code. Order cancellation no longer returns the deprecated
1565
- inline provider-refund branch: a paid cancellation returns `refundPending`, and
1566
- the dedicated refund-resolution flow reports provider completion.
1680
+ inline provider-refund branch. `refundPending` is a local financial marker, not
1681
+ authority for caller provider I/O:
1682
+
1683
+ | Captured payment lane | Provider refund owner | `resolveCancelRefund` |
1684
+ | ------------------------------------------------------- | ---------------------------- | ----------------------------------------------------------------------------------- |
1685
+ | Registered managed PaymentSession (Toss or PortOne) | Console only | Rejects `409 managed_refund_attestation_forbidden`; the pending marker is preserved |
1686
+ | Explicit `custom_bridge` capture | Trusted external integration | May report the already-completed provider outcome |
1687
+ | Legacy NULL-origin capture without a registered account | Bounded migration drain only | May report the already-completed provider outcome |
1688
+
1689
+ Do not infer the external lane from a defaulted `sessionOrigin`, an
1690
+ `orderCanceled` notification, or provider-observed cancellation. New managed
1691
+ captures must use Console's refund operation; `resolveCancelRefund` remains
1692
+ only for the two external-drain rows above.
1693
+
1694
+ Managed ownership follows the captured Transaction's exact tenant-bound
1695
+ PaymentSession and historical registered account. Order/provider/environment
1696
+ drift remains Console-owned corruption. Unresolved or cross-tenant identity
1697
+ fails closed opaquely as `payment_transaction_mismatch`; another session is
1698
+ never substitute evidence.
1699
+
1700
+ `managed_refund_attestation_forbidden` is the resolver's typed commerce error.
1701
+ Pre-existing resolver reasons remain generic SDK errors available through
1702
+ `getSDKErrorReason()` / `apiReason`, with legacy extra fields at the top level
1703
+ of the raw body in `error.details.body`.
1567
1704
 
1568
1705
  ```typescript
1569
1706
  await server.commerce.orders.update({ orderNumber, status: 'confirmed' })
@@ -1628,7 +1765,7 @@ options, option values, and variants. It is the tenant-admin safe path because
1628
1765
  it applies the product/option/variant transaction that raw collection writes do
1629
1766
  not provide.
1630
1767
 
1631
- `commerce.product.upsert()` is a graph-write API. For Admin Panel product
1768
+ `commerce.product.upsert()` is a graph-write API. For Console product
1632
1769
  documents, Payload saves product fields first; upsert receives `productId`,
1633
1770
  `graphRevision` (required when updating an existing product via `productId` -
1634
1771
  load from `GET /api/products/:id/composer-draft`), options, and variants. Do
@@ -1835,10 +1972,21 @@ await server.community.moderation.unbanCustomer({ customerId })
1835
1972
 
1836
1973
  ### Webhook
1837
1974
 
1838
- Create or open the endpoint in Console → Integrations → Webhooks. After saving,
1839
- use **Reveal signing secret** once for the initial value, or **Rotate secret** to
1840
- invalidate the previous secret and receive a new one-time plaintext value. Set the
1841
- copied value in the receiver environment as `WEBHOOK_SECRET`.
1975
+ Webhooks created in Console start inactive. Use this setup order so no event is
1976
+ sent before the receiver can verify it:
1977
+
1978
+ 1. Save the inactive endpoint in Console → Integrations → Webhooks.
1979
+ 2. Use **Reveal signing secret** once and copy the plaintext value.
1980
+ 3. Deploy the receiver with that value set as `WEBHOOK_SECRET`.
1981
+ 4. Return to the saved endpoint and choose **Activate webhook**.
1982
+
1983
+ This inactive-first behavior is Console-only and changes no API default.
1984
+ Creating an endpoint through the API with `isActive` omitted still yields an
1985
+ active endpoint (`true`), and an explicit `isActive` value is honored — so send
1986
+ `isActive: false` for the same staged setup outside Console.
1987
+
1988
+ After initial setup, **Rotate secret** invalidates the previous secret and
1989
+ returns a new one-time plaintext value for receiver deployment.
1842
1990
 
1843
1991
  `Webhook` list/read responses do not include plaintext signing secrets — only
1844
1992
  the Console reveal/rotate flows return them. Use `WebhookWithoutSecret` and
@@ -1850,7 +1998,10 @@ secrets.
1850
1998
  Use HMAC-SHA256 signature verification:
1851
1999
 
1852
2000
  ```typescript
1853
- import { handleWebhook, createTypedWebhookHandler } from '@01.software/sdk'
2001
+ import {
2002
+ handleSignedWebhook,
2003
+ createTypedWebhookHandler,
2004
+ } from '@01.software/sdk/webhook'
1854
2005
 
1855
2006
  const handler = createTypedWebhookHandler('orders', async (event) => {
1856
2007
  // event.data is typed as Order
@@ -1859,16 +2010,34 @@ const handler = createTypedWebhookHandler('orders', async (event) => {
1859
2010
 
1860
2011
  export async function POST(request: Request) {
1861
2012
  const secret = process.env.WEBHOOK_SECRET
1862
- if (!secret) throw new Error('WEBHOOK_SECRET is required')
2013
+ if (!secret?.trim()) throw new Error('WEBHOOK_SECRET must be nonblank')
1863
2014
 
1864
- return handleWebhook(request, handler, {
2015
+ return handleSignedWebhook(request, handler, {
1865
2016
  secret,
1866
2017
  })
1867
2018
  }
1868
2019
 
1869
2020
  // Signed deliveries include x-webhook-signature, x-webhook-timestamp,
1870
- // and x-webhook-delivery-id. handleWebhook rejects stale or unsigned
1871
- // deliveries when secret is set.
2021
+ // and x-webhook-delivery-id. handleSignedWebhook rejects stale, invalid,
2022
+ // or unsigned deliveries.
2023
+ ```
2024
+
2025
+ `handleSignedWebhook()` requires `secret` at the type boundary and also checks
2026
+ it at runtime. A missing, empty, or whitespace-only secret returns a
2027
+ configuration `500` before the request body or handler is processed. Missing or
2028
+ invalid signature metadata returns `401`. The deprecated `handleWebhook()` name
2029
+ remains as a signed compatibility alias with the same fail-closed behavior; it
2030
+ no longer selects unsigned mode when the secret is absent.
2031
+
2032
+ Only endpoints intentionally configured without a signing secret should use the
2033
+ explicit unsigned receiver. It performs no signature authentication:
2034
+
2035
+ ```typescript
2036
+ import { handleUnsignedWebhook } from '@01.software/sdk/webhook'
2037
+
2038
+ export async function POST(request: Request) {
2039
+ return handleUnsignedWebhook(request, handler)
2040
+ }
1872
2041
  ```
1873
2042
 
1874
2043
  ```typescript
@@ -1894,18 +2063,18 @@ const customerAuthHandler = createCustomerAuthWebhookHandler({
1894
2063
  // Use isOrderChangedWebhookEvent when you need to distinguish manual ordering
1895
2064
  // from content field edits.
1896
2065
  import {
1897
- handleWebhook,
2066
+ handleSignedWebhook,
1898
2067
  isOrderChangedWebhookEvent,
1899
2068
  } from '@01.software/sdk/webhook'
1900
2069
 
1901
2070
  function getWebhookSecret(): string {
1902
2071
  const secret = process.env.WEBHOOK_SECRET
1903
- if (!secret) throw new Error('WEBHOOK_SECRET is required')
2072
+ if (!secret?.trim()) throw new Error('WEBHOOK_SECRET must be nonblank')
1904
2073
  return secret
1905
2074
  }
1906
2075
 
1907
2076
  export async function POST(request: Request) {
1908
- return handleWebhook(
2077
+ return handleSignedWebhook(
1909
2078
  request,
1910
2079
  async (event) => {
1911
2080
  if (isOrderChangedWebhookEvent(event)) {
@@ -1919,7 +2088,7 @@ export async function POST(request: Request) {
1919
2088
  }
1920
2089
  ```
1921
2090
 
1922
- Orderable Admin Panel drag operations are delivered as `operation: "update"`
2091
+ Orderable Console drag operations are delivered as `operation: "update"`
1923
2092
  with `eventType: "collection.orderChanged"`. For join ordering, the webhook
1924
2093
  uses the public parent collection as `collection` and points `event.change.moved`
1925
2094
  at the public moved entity when one exists, so handlers do not need to depend on
@@ -1936,7 +2105,7 @@ Source of truth: `packages/published/sdk/src/core/collection/const.ts` (`COLLECT
1936
2105
  | Tenant | `tenant-metadata` |
1937
2106
  | Products | `products`, `product-variants`, `product-options`, `product-option-values`, `product-categories`, `product-tags`, `product-collections`, `markets`, `brands` |
1938
2107
  | Customers | `customer-profiles` |
1939
- | Commerce | `discounts`, `shipping-policies`, `shipping-zones` |
2108
+ | Commerce | `shipping-policies`, `shipping-zones` |
1940
2109
  | Content | `documents`, `document-categories`, `document-types`, `articles`, `article-authors`, `article-categories`, `article-tags`, `links`, `link-categories`, `link-tags` |
1941
2110
  | Playlists / Tracks | `playlists`, `playlist-categories`, `playlist-tags`, `tracks`, `track-categories`, `track-tags` |
1942
2111
  | Galleries | `galleries`, `gallery-categories`, `gallery-tags`, `gallery-items` |
@@ -1946,8 +2115,9 @@ Source of truth: `packages/published/sdk/src/core/collection/const.ts` (`COLLECT
1946
2115
  | Community | `reaction-types`, `post-categories`, `post-tags`, `customer-profile-lists` |
1947
2116
  | Events | `event-calendars`, `events`, `event-categories`, `event-occurrences`, `event-tags` |
1948
2117
 
1949
- Server-only collections include raw media/logo records, customer and order
1950
- operational records, raw cart/cart-item records, form submissions, raw community documents
2118
+ Server-only collections include raw media/logo records, raw discount
2119
+ definitions (use `client.commerce.discounts.validate()` for browser validation),
2120
+ customer and order operational records, raw cart/cart-item records, form submissions, raw community documents
1951
2121
  (`posts`, `comments`, `reactions`, `bookmarks`), live stream provider records,
1952
2122
  Canvas graph shell rows (`canvas-nodes`, `canvas-edges`), segmentation records,
1953
2123
  and moderation records. They remain available from