@atmosphere-money/app-node 0.0.0-beta.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 ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## 0.0.0-beta.0
4
+
5
+ - Initial closed-beta App Node SDK package shape for server-side ATM app integrations.
6
+ - Adds hosted checkout helpers for strict `network.attested.payment.initiate`.
7
+ - Adds ATM signed webhook verification plus Request/Response, Next, and Express-style route helpers.
8
+ - Adds optional XRPC receiver verification helpers, including receiver-audience construction.
9
+ - Adds app-facing ticket availability, hold, free-claim, release, listing, verify, and check-in helpers.
10
+ - Adds typed event envelopes for common payment, subscription, product, and ticket events.
11
+ - Adds package release checks, API snapshot checks, and dry-run tarball validation.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Atmosphere Money
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,305 @@
1
+ # @atmosphere-money/app-node
2
+
3
+ Server-side TypeScript helpers for apps integrating with Atmosphere Money.
4
+
5
+ This package is intentionally server-only. Keep app service-auth, webhook
6
+ secrets, checkout envelopes, buyer assertions, scan tokens, and fulfillment
7
+ mutations out of browser code.
8
+
9
+ The package is framework-agnostic. Use it from any trusted Node-compatible
10
+ backend that can mint AT Protocol service-auth JWTs, call ATM XRPC methods, and
11
+ verify raw webhook bodies. Next.js, Express, Fastify, Hono, and backend-only
12
+ services should all share the same payment and event contract.
13
+
14
+ ## Status
15
+
16
+ `@atmosphere-money/app-node` is the canonical SDK package shape for closed-beta
17
+ integrations. Until npm publishing is enabled, closed-beta apps install it from
18
+ a local checkout or private tarball. The exported API is intended to be the
19
+ public package surface.
20
+ The SDK package is MIT licensed. That license applies to this package only; the
21
+ ATM monorepo, dashboard, processor, and business logic remain private
22
+ Atmosphere Money code.
23
+
24
+ ## Install during closed beta
25
+
26
+ Use the package from a local checkout during closed beta:
27
+
28
+ ```sh
29
+ npm install ../path/to/atmosphere-money/packages/app-node
30
+ ```
31
+
32
+ When published, the install shape will be:
33
+
34
+ ```sh
35
+ npm install @atmosphere-money/app-node
36
+ ```
37
+
38
+ ## Initialize
39
+
40
+ ```ts
41
+ import { createAtmAppClient } from "@atmosphere-money/app-node";
42
+
43
+ const atm = createAtmAppClient({
44
+ getServiceAuthToken: async ({ lxm, aud }) => {
45
+ return mintMyAppServiceAuthJwt({ lxm, aud });
46
+ },
47
+ });
48
+ ```
49
+
50
+ `getServiceAuthToken` must return a fresh AT Protocol service-auth JWT scoped to
51
+ the exact XRPC method being called.
52
+
53
+ ## Start checkout
54
+
55
+ ```ts
56
+ const payout = await atm.getPayoutStatus("did:plc:creator");
57
+ if (!payout.payable) {
58
+ throw new Error("Recipient cannot receive payments yet");
59
+ }
60
+
61
+ const checkout = await atm.initiatePayment({
62
+ recipient: "did:plc:creator",
63
+ amount: 1200,
64
+ currency: "usd",
65
+ paymentType: "shop",
66
+ environment: "test",
67
+ returnUrl: "https://app.example/orders/ord_123",
68
+ cancelUrl: "https://app.example/products/product_123",
69
+ metadata: {
70
+ appOrderId: "ord_123",
71
+ },
72
+ });
73
+
74
+ return checkout.url;
75
+ ```
76
+
77
+ ## Verify HTTP webhooks
78
+
79
+ ```ts
80
+ import {
81
+ constructAtmWebhookEvent,
82
+ constructTypedAtmWebhookEvent,
83
+ } from "@atmosphere-money/app-node";
84
+
85
+ const event = constructAtmWebhookEvent({
86
+ rawBody,
87
+ secret: process.env.ATM_WEBHOOK_SECRET!,
88
+ headers: {
89
+ signature: request.headers.get("atm-signature"),
90
+ deliveryId: request.headers.get("atm-delivery-id"),
91
+ event: request.headers.get("atm-event"),
92
+ apiVersion: request.headers.get("atm-api-version"),
93
+ environment: request.headers.get("atm-environment"),
94
+ },
95
+ });
96
+ ```
97
+
98
+ Verify the exact raw request body before JSON mutation and deduplicate by
99
+ delivery id before fulfillment.
100
+
101
+ For common events, use the typed constructor:
102
+
103
+ ```ts
104
+ const paymentEvent = constructTypedAtmWebhookEvent({
105
+ rawBody,
106
+ secret: process.env.ATM_WEBHOOK_SECRET!,
107
+ expectedType: "payment.completed",
108
+ headers: {
109
+ signature: request.headers.get("atm-signature"),
110
+ deliveryId: request.headers.get("atm-delivery-id"),
111
+ apiVersion: request.headers.get("atm-api-version"),
112
+ environment: request.headers.get("atm-environment"),
113
+ },
114
+ });
115
+
116
+ console.log(paymentEvent.data.payment.id);
117
+ ```
118
+
119
+ ## Webhook route helpers
120
+
121
+ Use the lower-level constructors when you want full control. For common server
122
+ routes, the package also includes small handler helpers.
123
+
124
+ ```ts
125
+ import { createNodeWebhookHandler } from "@atmosphere-money/app-node";
126
+
127
+ export const POST = createNodeWebhookHandler({
128
+ secret: process.env.ATM_WEBHOOK_SECRET!,
129
+ expectedType: "payment.completed",
130
+ insertDeliveryIdOnce: async (deliveryId) => {
131
+ return insertDeliveryIdOnce(deliveryId);
132
+ },
133
+ onEvent: async (event) => {
134
+ const metadata = event.data.payment.metadata as
135
+ | { appOrderId?: string }
136
+ | undefined;
137
+ const appOrderId = String(metadata?.appOrderId ?? "");
138
+ if (!appOrderId) {
139
+ return { status: 422, body: { error: "MissingAppOrderId" } };
140
+ }
141
+ await markOrderPaid(appOrderId, event.data.payment.id);
142
+ return { body: { ok: true } };
143
+ },
144
+ });
145
+ ```
146
+
147
+ Express-style apps can use `createExpressWebhookHandler` with `express.raw()` or
148
+ an explicit `getRawBody` callback. `createNextWebhookRoute` is an alias for the
149
+ standard Web `Request` handler shape used by Next route handlers.
150
+
151
+ ## Verify XRPC receiver events
152
+
153
+ Apps that expose an AT Protocol-shaped receiver can use the same event envelope
154
+ with service-auth verification.
155
+
156
+ ```ts
157
+ import {
158
+ ATM_EVENT_RECEIVE_NSID,
159
+ createAtmXrpcReceiverAudience,
160
+ constructTypedAtmXrpcReceiverEvent,
161
+ } from "@atmosphere-money/app-node";
162
+
163
+ const audience = createAtmXrpcReceiverAudience("did:plc:yourapp");
164
+
165
+ const event = await constructTypedAtmXrpcReceiverEvent({
166
+ rawBody,
167
+ appDid: "did:plc:yourapp",
168
+ expectedType: "payment.completed",
169
+ headers: {
170
+ authorization: request.headers.get("authorization"),
171
+ deliveryId: request.headers.get("atm-delivery-id"),
172
+ event: request.headers.get("atm-event"),
173
+ apiVersion: request.headers.get("atm-api-version"),
174
+ environment: request.headers.get("atm-environment"),
175
+ },
176
+ verifyServiceAuthJwt: async ({ token, expectedIss, expectedAud, expectedLxm }) => {
177
+ if (expectedAud !== audience || expectedLxm !== ATM_EVENT_RECEIVE_NSID) {
178
+ throw new Error("Unexpected ATM receiver audience");
179
+ }
180
+ return verifyServiceAuthJwtWithYourAtprotoStack({
181
+ token,
182
+ expectedIss,
183
+ expectedAud,
184
+ expectedLxm,
185
+ });
186
+ },
187
+ });
188
+
189
+ const metadata = event.data.payment.metadata as
190
+ | { appOrderId?: string }
191
+ | undefined;
192
+ await markOrderPaid(String(metadata?.appOrderId ?? ""));
193
+ ```
194
+
195
+ ## Tickets helpers
196
+
197
+ ```ts
198
+ const availability = await atm.getTicketAvailability({
199
+ environment: "test",
200
+ eventUri: "at://did:plc:organizer/community.lexicon.calendar.event/demo",
201
+ });
202
+
203
+ const hold = await atm.createTicketHold({
204
+ environment: "test",
205
+ eventUri: "at://did:plc:organizer/community.lexicon.calendar.event/demo",
206
+ buyerDid: "did:plc:buyer",
207
+ buyerAssertionJwt: "short-lived-buyer-assertion",
208
+ items: [{ ticketTierId: "tier_123", quantity: 2 }],
209
+ returnUrl: "https://app.example/tickets/return",
210
+ cancelUrl: "https://app.example/events/demo",
211
+ });
212
+
213
+ const freeClaim = await atm.claimFreeTicket({
214
+ environment: "test",
215
+ eventUri: "at://did:plc:organizer/community.lexicon.calendar.event/demo",
216
+ ticketTierId: "tier_free",
217
+ buyerDid: "did:plc:buyer",
218
+ buyerAssertionJwt: "short-lived-buyer-assertion",
219
+ idempotencyKey: "claim:event:buyer:tier_free",
220
+ });
221
+
222
+ const listed = await atm.listBuyerTickets({
223
+ environment: "test",
224
+ buyerDid: "did:plc:buyer",
225
+ });
226
+
227
+ const verified = await atm.verifyTicket({
228
+ environment: "test",
229
+ ticketToken: "opaque_scan_token",
230
+ });
231
+ ```
232
+
233
+ ## API surface
234
+
235
+ - `createAtmAppClient(options)`
236
+ - `createAtmCheckoutProduct(input)`
237
+ - `ATM_XRPC_METHODS`
238
+ - `createPaymentInitiateBody(input)`
239
+ - `constructAtmWebhookEvent(options)`
240
+ - `constructTypedAtmWebhookEvent(options)`
241
+ - `createNodeWebhookHandler(options)`
242
+ - `createNextWebhookRoute(options)`
243
+ - `createExpressWebhookHandler(options)`
244
+ - `constructAtmXrpcReceiverEvent(options)`
245
+ - `constructTypedAtmXrpcReceiverEvent(options)`
246
+ - `createAtmXrpcReceiverAudience(appDid, serviceRef?)`
247
+ - `signAtmWebhookPayload(options)`
248
+ - `verifyAtmWebhookSignature(options)`
249
+ - `verifyAtmReceiverServiceAuthClaims(options)`
250
+ - `AtmApiError`
251
+ - `AtmWebhookSignatureError`
252
+ - `AtmXrpcReceiverAuthError`
253
+
254
+ Client methods:
255
+
256
+ - `atm.getPayoutStatus(actorDid)`
257
+ - `atm.initiatePayment(input)`
258
+ - `atm.getPaymentStatus(token)`
259
+ - `atm.getProfile(actorDid)`
260
+ - `atm.createCapacityGroup(input)`
261
+ - `atm.updateCapacityGroup(input)`
262
+ - `atm.createTicketTier(input)`
263
+ - `atm.updateTicketTier(input)`
264
+ - `atm.archiveTicketTier(input)`
265
+ - `atm.getTicketAvailability(input)`
266
+ - `atm.createTicketHold(input)`
267
+ - `atm.releaseTicketHold(input)`
268
+ - `atm.claimFreeTicket(input)`
269
+ - `atm.listBuyerTickets(input)`
270
+ - `atm.listOrganizerTickets(input)`
271
+ - `atm.verifyTicket(input)`
272
+ - `atm.checkInTicket(input)`
273
+
274
+ ## What this package does not cover
275
+
276
+ - Browser checkout embeds.
277
+ - Supper website widgets.
278
+ - Minting app service-auth JWTs from your PDS.
279
+ - Writing app-specific fulfillment records.
280
+ - Replacing ATM webhooks or XRPC receiver delivery.
281
+ - Framework-specific routing decisions.
282
+
283
+ Those are separate integration surfaces so the App Node package can stay small,
284
+ auditable, and safe to use from backend code.
285
+
286
+ ## Local checks
287
+
288
+ ```sh
289
+ npm run check
290
+ npm run release:check
291
+ npm run pack:dry-run
292
+ ```
293
+
294
+ Before public npm publishing, read [`RELEASE.md`](./RELEASE.md). `npm run
295
+ publish:check` intentionally fails until the package-private guard is removed
296
+ as part of the manual npm release step.
297
+
298
+ For the broader package policy, see
299
+ [`../../docs/developer/SDK_PUBLISHING.md`](../../docs/developer/SDK_PUBLISHING.md)
300
+ and [`../../docs/developer/SDK_VERSIONING.md`](../../docs/developer/SDK_VERSIONING.md).
301
+
302
+ ## License
303
+
304
+ `@atmosphere-money/app-node` is released under the MIT license. The package
305
+ license does not license the rest of the ATM monorepo or hosted platform code.