@hyodotdev/openiap-commerce-protocol 0.0.0-bootstrap.0 → 0.1.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 (42) hide show
  1. package/CONVENTION.md +168 -0
  2. package/DESIGN.md +1056 -0
  3. package/README.md +227 -5
  4. package/SPEC.md +1471 -0
  5. package/conformance/index.d.ts +303 -0
  6. package/conformance/index.mjs +2126 -0
  7. package/conformance/mock-provider.mjs +491 -0
  8. package/examples/entitlement-granted-no-subscription.json +12 -0
  9. package/examples/entitlement-revoked.json +21 -0
  10. package/examples/provider-capabilities.json +209 -0
  11. package/examples/store-event-mapping.json +287 -0
  12. package/examples/subscription-canceled.json +22 -0
  13. package/examples/subscription-product-changed.json +30 -0
  14. package/examples/subscription-renewed.json +29 -0
  15. package/examples/verify-purchase-request.json +6 -0
  16. package/examples/verify-purchase-result.json +7 -0
  17. package/generated/bindings/graphql-operations.json +87 -0
  18. package/generated/bindings/http-binding.json +143 -0
  19. package/generated/bindings/introspection-signature.json +320 -0
  20. package/generated/bindings/operations-sdl.json +4 -0
  21. package/generated/bindings/operations.graphql +366 -0
  22. package/generated/commerce-protocol.graphql +1219 -0
  23. package/generated/openapi/commerce-protocol.openapi.json +1413 -0
  24. package/generated/schemas/commerce-event.schema.json +499 -0
  25. package/generated/schemas/commerce-protocol.bundle.schema.json +1576 -0
  26. package/generated/schemas/operations.schema.json +578 -0
  27. package/generated/schemas/primitives.schema.json +101 -0
  28. package/generated/schemas/provider-capabilities.schema.json +205 -0
  29. package/generated/schemas/store-event-mapping.schema.json +211 -0
  30. package/generated/vectors/lifecycle.json +908 -0
  31. package/generated/vectors/operations.json +1122 -0
  32. package/package.json +62 -12
  33. package/schema/01-primitives.graphql +102 -0
  34. package/schema/02-commerce-event.graphql +195 -0
  35. package/schema/03-provider-capabilities.graphql +139 -0
  36. package/schema/04-store-event-mapping.graphql +98 -0
  37. package/schema/05-operations.graphql +461 -0
  38. package/schema/06-compiler-vocabulary.graphql +139 -0
  39. package/schema/07-protocol-metadata.graphql +76 -0
  40. package/src/index.d.ts +63 -0
  41. package/src/index.mjs +121 -0
  42. package/vectors/signatures.json +139 -0
@@ -0,0 +1,366 @@
1
+ # Executable GraphQL projection of the OpenIAP Commerce Protocol 1.0
2
+ # operation surface. Generated from commerce-protocol.graphql — do not edit.
3
+ # A conforming GraphQL binding defines everything this projection
4
+ # defines, exactly as defined; a compatible MINOR may extend it
5
+ # additively. Introspection, where enabled, must agree with the schema
6
+ # served.
7
+
8
+ """
9
+ The commerce platform that is authoritative for the purchase. This is a store, not a device platform: one device platform can host several stores. The value space is OPEN. The listed values are the stores this version names, but an implementation that observes commerce on another platform MUST be able to emit it, and a consumer MUST accept and preserve an unrecognised store opaquely rather than reject the event. Use a lowercase, stable, unambiguous token.
10
+ """
11
+ scalar Store
12
+
13
+ """
14
+ The store environment the purchase belongs to. The value space is open: receivers MUST accept and preserve an unrecognised value opaquely and MUST NOT reject an event because of it.
15
+ """
16
+ scalar Environment
17
+
18
+ """
19
+ An instant, as integer milliseconds since the Unix epoch, UTC. Every timestamp in this specification uses this encoding. The one exception is the transport signature timestamp, which is in seconds; see the webhook section of SPEC.md.
20
+ """
21
+ scalar Timestamp
22
+
23
+ """
24
+ An opaque, implementation-assigned identifier. Consumers MUST treat it as an opaque string and MUST NOT parse structure out of it.
25
+ """
26
+ scalar Identifier
27
+
28
+ """
29
+ The lifecycle state of a subscription. This is a state, not an event, and it does not by itself decide entitlement — see Entitlement in SPEC.md. These members are PascalCase while event types are lowercase-dotted; the inconsistency is inherited from the deployed 1.0 wire format and is recorded in CONVENTION.md rather than silently corrected, because changing it would break receivers already decoding it.
30
+ """
31
+ enum SubscriptionState {
32
+ Active
33
+ InGracePeriod
34
+ InBillingRetry
35
+ Paused
36
+ Expired
37
+ Revoked
38
+ Refunded
39
+ Unknown
40
+ }
41
+
42
+ scalar StoreCapabilitiesMap
43
+
44
+ """
45
+ What an implementation supports: the specification version it speaks, the event types it can emit, and what it can actually observe per store. This is the document a consumer, an operator, or a tool reads to determine compatibility without guessing and without reading prose. It contains no commerce data.
46
+ """
47
+ type ProviderCapabilities {
48
+ """
49
+ OpenIAP Commerce Protocol version this declaration was written against, as MAJOR.MINOR.
50
+ """
51
+ specVersion: MajorMinor!
52
+ """
53
+ Free-form name and version of the backend making this declaration. Present so an operator can tell two backends apart; it carries no normative meaning.
54
+ """
55
+ implementation: Implementation
56
+ """
57
+ Event types this implementation can emit. A consumer uses it to know which lifecycle signals to expect; absence of a type here means this implementation never produces it, which is different from a type that simply has not occurred yet.
58
+ """
59
+ eventTypes: [NamespacedEventType!]!
60
+ """
61
+ Keyed by store, using the same open value space as the event envelope. An implementation declares only the stores it actually integrates.
62
+ """
63
+ stores: StoreCapabilitiesMap!
64
+ """
65
+ Operation profiles this implementation serves, keyed by profile name with the profile version as the value. This version names `verification`, `entitlements`, `events`, and `accountLifecycle`; the key space is open, so a consumer MUST ignore a profile it does not recognise. An implementation MUST declare only profiles it implements and passes conformance for, and MUST NOT declare a profile it partially implements. Absent on a descriptor from an events-only emitter that predates the operation surface.
66
+ """
67
+ profiles: ProfileVersionMap
68
+ """
69
+ Transport bindings this implementation serves for the declared profiles, keyed by binding name with the binding version as the value. This version names `rest` and `graphql`; the key space is open. Declaring a binding means every declared profile operation is reachable over it. An implementation MAY serve one binding only. Absent on a descriptor from an events-only emitter.
70
+ """
71
+ bindings: BindingVersionMap
72
+ }
73
+
74
+ scalar ProfileVersionMap
75
+
76
+ scalar BindingVersionMap
77
+
78
+ """
79
+ Free-form name and version of the backend making this declaration. Present so an operator can tell two backends apart; it carries no normative meaning.
80
+ """
81
+ type Implementation {
82
+ """
83
+ Name of the backend making this declaration, for an operator reading a descriptor without knowing where it came from.
84
+ """
85
+ name: NonEmptyString
86
+ """
87
+ Version of that backend, when it publishes one. Not a specification version — that is `specVersion`.
88
+ """
89
+ version: NonEmptyString
90
+ }
91
+
92
+ """
93
+ The verification verdict for one piece of purchase evidence, as a normalized token. This is the purchase-validation axis SPEC.md 2.3 warns about — a CANCELED verification verdict and a canceled-but-still-entitled subscription are different facts. The value space is OPEN: a caller MUST tolerate a token it does not know and gate on `isValid` alone.
94
+ """
95
+ scalar PurchaseVerificationState
96
+
97
+ """
98
+ The lifecycle state of a user-erasure job. The value space is open; `completed` is the only terminal token this version names.
99
+ """
100
+ scalar ErasureJobStatus
101
+
102
+ """
103
+ A compact signed transaction JWS. Bounded so an oversized body cannot be forwarded to a store: an Apple transaction JWS is a few kilobytes.
104
+ """
105
+ scalar AppleJws
106
+
107
+ """
108
+ An opaque store purchase token. Bounded to keep an oversized body off the store API.
109
+ """
110
+ scalar GooglePurchaseToken
111
+
112
+ """
113
+ A store-issued user identity, as the store's own API returns it. Distinct from the protocol's opaque `userId`.
114
+ """
115
+ scalar StoreUserIdentity
116
+
117
+ """
118
+ A store add-on SKU. Bounded to a predictable identifier length.
119
+ """
120
+ scalar StoreSku
121
+
122
+ """
123
+ A store receipt identifier. Bounded to keep an oversized body off the store API.
124
+ """
125
+ scalar StoreReceiptId
126
+
127
+ """
128
+ Store evidence for one Apple App Store purchase: the signed StoreKit 2 transaction JWS the app received from the store.
129
+ """
130
+ input AppleEvidence {
131
+ """
132
+ The compact signed transaction JWS, verbatim as the store handed it to the app.
133
+ """
134
+ jws: AppleJws!
135
+ }
136
+
137
+ """
138
+ Store evidence for one Google Play purchase: the opaque purchase token the store issued to the device.
139
+ """
140
+ input GoogleEvidence {
141
+ """
142
+ The opaque purchase token, verbatim as the store issued it to the device.
143
+ """
144
+ purchaseToken: GooglePurchaseToken!
145
+ }
146
+
147
+ """
148
+ Store evidence for one Meta Horizon (Quest) entitlement. Horizon issues no server-verifiable receipt, so verification identifies the entitlement by user and SKU; the provider holds the store credentials.
149
+ """
150
+ input HorizonEvidence {
151
+ """
152
+ The store's own user identity for the entitlement holder — not the protocol's opaque `userId`.
153
+ """
154
+ userId: StoreUserIdentity!
155
+ """
156
+ The add-on SKU as configured in the store's developer dashboard.
157
+ """
158
+ sku: StoreSku!
159
+ }
160
+
161
+ """
162
+ Store evidence for one Amazon Appstore purchase, as returned by the Amazon SDK. `sandbox` selects the RVS sandbox for App Tester receipts where the provider permits it.
163
+ """
164
+ input AmazonEvidence {
165
+ """
166
+ The store's own user identity from the purchase response — not the protocol's opaque `userId`.
167
+ """
168
+ userId: StoreUserIdentity!
169
+ """
170
+ The receipt identifier from the purchase or purchase-updates response.
171
+ """
172
+ receiptId: StoreReceiptId!
173
+ """
174
+ Verify against the store's sandbox where the provider permits it. Omitted means production.
175
+ """
176
+ sandbox: Boolean
177
+ }
178
+
179
+ """
180
+ One purchase's store evidence, discriminated by `store`. The store space stays open: a provider that does not integrate the named store rejects the call with UNSUPPORTED_STORE rather than failing schema validation, so a future store is a MINOR evidence-member addition, not a breaking change. For each store this version names, the matching evidence member is required.
181
+ """
182
+ input VerifyPurchaseInput {
183
+ store: Store!
184
+ apple: AppleEvidence
185
+ google: GoogleEvidence
186
+ horizon: HorizonEvidence
187
+ amazon: AmazonEvidence
188
+ }
189
+
190
+ """
191
+ The verification verdict. `isValid` is the authoritative acceptance gate: a caller MUST read it and MUST NOT re-derive acceptance from `state`. A verdict is a statement about the evidence at verification time, never an account mutation — verification binds no user.
192
+ """
193
+ type VerifyPurchaseResult {
194
+ store: Store!
195
+ """
196
+ Whether the provider accepts the evidence. The single authoritative acceptance gate.
197
+ """
198
+ isValid: Boolean!
199
+ state: PurchaseVerificationState!
200
+ """
201
+ The product the store verified, when its response exposes one. Never the caller's claim.
202
+ """
203
+ productId: NonEmptyString
204
+ """
205
+ The store environment the provider verified against, using the same open value space as the event envelope.
206
+ """
207
+ environment: Environment
208
+ }
209
+
210
+ """
211
+ Connects verified store evidence to the adopter's own opaque user identity. Binding is a server-side account mutation: only the server role may call it, and possession of a purchase token is deliberately not proof of ownership — a provider MUST refuse to move an existing binding through this operation.
212
+ """
213
+ input BindPurchaseInput {
214
+ userId: Identifier!
215
+ store: Store!
216
+ apple: AppleEvidence
217
+ google: GoogleEvidence
218
+ horizon: HorizonEvidence
219
+ amazon: AmazonEvidence
220
+ }
221
+
222
+ """
223
+ Whether a binding now exists between this user and the evidenced purchase. `bound: false` covers every non-binding outcome — unknown evidence, evidence bound to a different user, or a store the provider cannot bind — without distinguishing them, so the operation cannot be used to probe whether someone else's purchase exists. Re-binding the same user to the same evidence is idempotent and reports `bound: true`.
224
+ """
225
+ type BindPurchaseResult {
226
+ """
227
+ True when a binding between this user and the evidenced purchase now exists.
228
+ """
229
+ bound: Boolean!
230
+ }
231
+
232
+ """
233
+ Selects the user whose subscription standing the caller's backend reads.
234
+ """
235
+ input SubscriptionStatusInput {
236
+ """
237
+ The opaque app-scoped user identity the caller's backend selected, in the identity space shared by provider and caller.
238
+ """
239
+ userId: Identifier!
240
+ }
241
+
242
+ """
243
+ One subscription as the provider currently records it, shaped for a server-side read. It is tokenless by construction: this object is CLOSED, so the schema itself rejects any member beyond those listed — no purchase token, store transaction identity, signed receipt, or provider-internal record identifier can appear, and the response is safe to hold in a developer backend.
244
+ """
245
+ type SubscriptionStatusSnapshot {
246
+ """
247
+ Store product identifier of the subscription.
248
+ """
249
+ productId: NonEmptyString!
250
+ state: SubscriptionState!
251
+ """
252
+ The entitlement gate for this subscription, evaluated with the predicate in SPEC.md 2.3 at the provider's read time. A caller gates access on this member, never on `state`.
253
+ """
254
+ active: Boolean!
255
+ store: Store
256
+ expiresAt: Timestamp
257
+ renewsAt: Timestamp
258
+ """
259
+ Whether the store will attempt another billing period, when the provider records it.
260
+ """
261
+ willRenew: Boolean
262
+ """
263
+ Why the subscription stopped renewing, as the same open normalized token space the event envelope uses. Advisory, never a billing fact.
264
+ """
265
+ cancellationReason: NonEmptyString
266
+ startedAt: Timestamp
267
+ updatedAt: Timestamp
268
+ }
269
+
270
+ """
271
+ The user's current subscription standing. `active` answers the gate for the user as a whole; `subscription` is the most relevant record — the current entitling subscription when one exists, otherwise the provider's most recent record as context. It is omitted when the provider has no record for this user. A provider that cannot enumerate the user's records completely MUST fail the operation instead of answering from a partial read.
272
+ """
273
+ type SubscriptionStatusResult {
274
+ """
275
+ Whether the user is entitled to anything right now. The gate for simple access checks.
276
+ """
277
+ active: Boolean!
278
+ subscription: SubscriptionStatusSnapshot
279
+ }
280
+
281
+ """
282
+ Selects the user whose access decision the caller's backend reads.
283
+ """
284
+ input EntitlementsInput {
285
+ """
286
+ The opaque app-scoped user identity the caller's backend selected, in the identity space shared by provider and caller.
287
+ """
288
+ userId: Identifier!
289
+ }
290
+
291
+ """
292
+ Every product the user may access right now, with the entitling subscription records. Unknown, expired, and ambiguous records contribute nothing: a product appears only when its gate is open at the provider's read time. A provider that cannot enumerate the user's records completely MUST fail the operation instead of answering from a partial read.
293
+ """
294
+ type EntitlementsResult {
295
+ userId: Identifier!
296
+ """
297
+ Every product the user may access right now, deduplicated.
298
+ """
299
+ productIds: [NonEmptyString!]!
300
+ """
301
+ The subscription records whose open gates produced `productIds`.
302
+ """
303
+ subscriptions: [SubscriptionStatusSnapshot!]!
304
+ }
305
+
306
+ """
307
+ Selects the user identity to erase from the provider's records.
308
+ """
309
+ input EraseUserInput {
310
+ """
311
+ The opaque app-scoped user identity to remove from the provider's subscription records and protocol event identity.
312
+ """
313
+ userId: Identifier!
314
+ }
315
+
316
+ """
317
+ Acknowledgement of an erasure request. Erasure removes the user identity from the provider's own records and event store; it is asynchronous where the provider processes it as a job, and re-requesting the same user is idempotent — it reports the current job rather than failing. A provider CANNOT unsend events: copies already delivered to the caller's own systems are the caller's responsibility to erase.
318
+ """
319
+ type EraseUserResult {
320
+ """
321
+ Whether the provider accepted the erasure request.
322
+ """
323
+ accepted: Boolean!
324
+ jobId: Identifier
325
+ status: ErasureJobStatus
326
+ }
327
+
328
+ scalar MajorMinor
329
+
330
+ scalar NonEmptyString
331
+
332
+ scalar NamespacedEventType
333
+
334
+ type Query {
335
+ """
336
+ What this provider implements: protocol version, profiles, bindings, and per-store capability. Public and free of commerce data, so a consumer or a conformance runner reads it without credentials and without any central registry.
337
+ """
338
+ providerCapabilities: ProviderCapabilities!
339
+
340
+ """
341
+ A developer backend reads one authenticated user's subscription standing. Server role only: a shipped app must not be able to walk arbitrary user identities, which is why the verification role is refused here.
342
+ """
343
+ subscriptionStatus(input: SubscriptionStatusInput!): SubscriptionStatusResult!
344
+
345
+ """
346
+ A developer backend reads one authenticated user's access decision. Server role only, and fail-close: anything the provider cannot classify as currently entitled is absent from the answer.
347
+ """
348
+ entitlements(input: EntitlementsInput!): EntitlementsResult!
349
+ }
350
+
351
+ type Mutation {
352
+ """
353
+ Verifies store evidence and returns the verdict. The verification role suffices: this operation binds no user, reads no account, and repeating it with the same evidence is safe. VERIFICATION_FAILED means the provider could not obtain a verdict — it never stands in for the store rejecting the evidence, which is a successful result with `isValid: false`.
354
+ """
355
+ verifyPurchase(input: VerifyPurchaseInput!): VerifyPurchaseResult!
356
+
357
+ """
358
+ Binds a verified purchase to the adopter's opaque user identity. Server role only; retrying is idempotent.
359
+ """
360
+ bindPurchase(input: BindPurchaseInput!): BindPurchaseResult!
361
+
362
+ """
363
+ Removes a user identity from the provider's subscription records and protocol event identity. Server role only; re-requesting the same user is idempotent and reports the current job.
364
+ """
365
+ eraseUser(input: EraseUserInput!): EraseUserResult!
366
+ }