ucpify 1.1.0 → 1.2.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/src/schema.ts CHANGED
@@ -30,6 +30,23 @@ export const PaymentHandlerSchema = z.object({
30
30
  config: z.record(z.string(), z.unknown()).optional(),
31
31
  });
32
32
 
33
+ // OAuth Configuration Schema
34
+ export const OAuthConfigSchema = z.discriminatedUnion('provider', [
35
+ z.object({
36
+ provider: z.literal('built-in'),
37
+ }),
38
+ z.object({
39
+ provider: z.literal('external'),
40
+ issuer: z.string().url(),
41
+ authorization_endpoint: z.string().url(),
42
+ token_endpoint: z.string().url(),
43
+ revocation_endpoint: z.string().url().optional(),
44
+ jwks_uri: z.string().url().optional(),
45
+ }),
46
+ ]);
47
+
48
+ export type OAuthConfig = z.infer<typeof OAuthConfigSchema>;
49
+
33
50
  // Merchant Configuration Schema
34
51
  export const MerchantConfigSchema = z.object({
35
52
  name: z.string(),
@@ -42,6 +59,7 @@ export const MerchantConfigSchema = z.object({
42
59
  payment_handlers: z.array(PaymentHandlerSchema).default([]),
43
60
  tax_rate: z.number().min(0).max(1).default(0), // e.g., 0.08 for 8%
44
61
  port: z.number().default(3000),
62
+ oauth: OAuthConfigSchema.optional(),
45
63
  });
46
64
 
47
65
  export type Item = z.infer<typeof ItemSchema>;
@@ -57,6 +57,11 @@ export class UCPServerDB {
57
57
  'dev.ucp.shopping.order': [
58
58
  { version: UCP_VERSION, spec: 'https://ucp.dev/specification/order', schema: 'https://ucp.dev/schemas/shopping/order.json' },
59
59
  ],
60
+ ...(this.config.oauth ? {
61
+ 'dev.ucp.identity_linking': [
62
+ { version: UCP_VERSION, spec: 'https://ucp.dev/specification/identity-linking' },
63
+ ],
64
+ } : {}),
60
65
  },
61
66
  payment_handlers: paymentHandlers,
62
67
  },
@@ -105,9 +110,9 @@ export class UCPServerDB {
105
110
 
106
111
  private sessionFromRow(row: any): CheckoutSession | undefined {
107
112
  if (!row) return undefined;
108
-
113
+
109
114
  const lineItems = db.prepare('SELECT * FROM line_items WHERE checkout_id = ?').all(row.id) as any[];
110
-
115
+
111
116
  return {
112
117
  ucp: {
113
118
  version: UCP_VERSION,
@@ -169,7 +174,7 @@ export class UCPServerDB {
169
174
  `);
170
175
 
171
176
  db.transaction(() => {
172
- insertCheckout.run(id, status, this.config.currency, JSON.stringify(totals), JSON.stringify(links),
177
+ insertCheckout.run(id, status, this.config.currency, JSON.stringify(totals), JSON.stringify(links),
173
178
  messages.length > 0 ? JSON.stringify(messages) : null, continueUrl, expiresAt, now, now);
174
179
  for (const li of lineItems) {
175
180
  insertLineItem.run(li.id, id, JSON.stringify(li.item), li.quantity, JSON.stringify(li.totals));
@@ -284,13 +289,13 @@ export class UCPServerDB {
284
289
 
285
290
  // Get total amount for payment
286
291
  const totalAmount = session.totals.find(t => t.type === 'total')?.amount || 0;
287
-
292
+
288
293
  // Payment processing - try Stripe first, then PayPal
289
294
  let paymentIntentId: string | null = null;
290
295
  let paypalOrderId: string | null = null;
291
296
  let paymentProvider: string | null = null;
292
297
  let paymentStatus = 'none';
293
-
298
+
294
299
  if (totalAmount > 0) {
295
300
  // Try Stripe first
296
301
  if (isStripeConfigured()) {
package/src/ucp-server.ts CHANGED
@@ -76,6 +76,14 @@ export class UCPServer {
76
76
  schema: 'https://ucp.dev/schemas/shopping/order.json',
77
77
  },
78
78
  ],
79
+ ...(this.config.oauth ? {
80
+ 'dev.ucp.identity_linking': [
81
+ {
82
+ version: UCP_VERSION,
83
+ spec: 'https://ucp.dev/specification/identity-linking',
84
+ },
85
+ ],
86
+ } : {}),
79
87
  },
80
88
  payment_handlers: paymentHandlers,
81
89
  },