ucpify 1.2.0 → 1.2.1
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/package.json +18 -18
- package/dist/__tests__/api.test.d.ts +0 -1
- package/dist/__tests__/api.test.js +0 -121
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -235
- package/dist/config.d.ts +0 -14
- package/dist/config.js +0 -22
- package/dist/db.d.ts +0 -4
- package/dist/db.js +0 -164
- package/dist/express-app.d.ts +0 -5
- package/dist/express-app.js +0 -495
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -12
- package/dist/logger.d.ts +0 -3
- package/dist/logger.js +0 -15
- package/dist/oauth.d.ts +0 -60
- package/dist/oauth.js +0 -211
- package/dist/paypal.d.ts +0 -20
- package/dist/paypal.js +0 -111
- package/dist/schema.d.ts +0 -287
- package/dist/schema.js +0 -113
- package/dist/stripe.d.ts +0 -14
- package/dist/stripe.js +0 -103
- package/dist/ucp-server-db.d.ts +0 -76
- package/dist/ucp-server-db.js +0 -369
- package/dist/ucp-server.d.ts +0 -83
- package/dist/ucp-server.js +0 -381
package/dist/oauth.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.OAuthManager = exports.UCP_SCOPES = void 0;
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
const logger_1 = require("./logger");
|
|
9
|
-
// ─── Constants ───────────────────────────────────────────────────────
|
|
10
|
-
exports.UCP_SCOPES = ['ucp:scopes:checkout_session'];
|
|
11
|
-
const ACCESS_TOKEN_TTL = 60 * 60; // 1 hour
|
|
12
|
-
const REFRESH_TOKEN_TTL = 60 * 60 * 24 * 30; // 30 days
|
|
13
|
-
const AUTH_CODE_TTL = 60 * 10; // 10 minutes
|
|
14
|
-
// ─── Helpers ─────────────────────────────────────────────────────────
|
|
15
|
-
function generateToken(bytes = 32) {
|
|
16
|
-
return crypto_1.default.randomBytes(bytes).toString('hex');
|
|
17
|
-
}
|
|
18
|
-
function hashSecret(secret) {
|
|
19
|
-
return crypto_1.default.createHash('sha256').update(secret).digest('hex');
|
|
20
|
-
}
|
|
21
|
-
function nowEpoch() {
|
|
22
|
-
return Math.floor(Date.now() / 1000);
|
|
23
|
-
}
|
|
24
|
-
// ─── OAuth Manager ───────────────────────────────────────────────────
|
|
25
|
-
class OAuthManager {
|
|
26
|
-
clients = new Map();
|
|
27
|
-
codes = new Map();
|
|
28
|
-
accessTokens = new Map();
|
|
29
|
-
refreshTokens = new Map();
|
|
30
|
-
// ── Client Management ──
|
|
31
|
-
createClient(name, redirectUris) {
|
|
32
|
-
const clientId = `ucp_${generateToken(16)}`;
|
|
33
|
-
const clientSecret = `ucp_secret_${generateToken(24)}`;
|
|
34
|
-
const client = {
|
|
35
|
-
client_id: clientId,
|
|
36
|
-
client_secret: clientSecret,
|
|
37
|
-
client_secret_hash: hashSecret(clientSecret),
|
|
38
|
-
name,
|
|
39
|
-
redirect_uris: redirectUris,
|
|
40
|
-
created_at: new Date().toISOString(),
|
|
41
|
-
};
|
|
42
|
-
this.clients.set(clientId, client);
|
|
43
|
-
logger_1.logger.info({ clientId, name }, 'OAuth client created');
|
|
44
|
-
return client;
|
|
45
|
-
}
|
|
46
|
-
getClient(clientId) {
|
|
47
|
-
return this.clients.get(clientId);
|
|
48
|
-
}
|
|
49
|
-
authenticateClient(clientId, clientSecret) {
|
|
50
|
-
const client = this.clients.get(clientId);
|
|
51
|
-
if (!client)
|
|
52
|
-
return false;
|
|
53
|
-
return client.client_secret_hash === hashSecret(clientSecret);
|
|
54
|
-
}
|
|
55
|
-
// ── Authorization Code ──
|
|
56
|
-
createAuthorizationCode(clientId, userId, scope, redirectUri, codeChallenge, codeChallengeMethod) {
|
|
57
|
-
const code = generateToken(32);
|
|
58
|
-
const authCode = {
|
|
59
|
-
code,
|
|
60
|
-
client_id: clientId,
|
|
61
|
-
user_id: userId,
|
|
62
|
-
scope,
|
|
63
|
-
redirect_uri: redirectUri,
|
|
64
|
-
code_challenge: codeChallenge,
|
|
65
|
-
code_challenge_method: codeChallengeMethod,
|
|
66
|
-
expires_at: nowEpoch() + AUTH_CODE_TTL,
|
|
67
|
-
used: false,
|
|
68
|
-
};
|
|
69
|
-
this.codes.set(code, authCode);
|
|
70
|
-
logger_1.logger.info({ clientId, userId, scope }, 'Authorization code created');
|
|
71
|
-
return code;
|
|
72
|
-
}
|
|
73
|
-
exchangeCode(code, clientId, redirectUri, codeVerifier) {
|
|
74
|
-
const authCode = this.codes.get(code);
|
|
75
|
-
if (!authCode)
|
|
76
|
-
return { error: 'invalid_grant' };
|
|
77
|
-
if (authCode.used)
|
|
78
|
-
return { error: 'invalid_grant' };
|
|
79
|
-
if (authCode.client_id !== clientId)
|
|
80
|
-
return { error: 'invalid_grant' };
|
|
81
|
-
if (authCode.redirect_uri !== redirectUri)
|
|
82
|
-
return { error: 'invalid_grant' };
|
|
83
|
-
if (authCode.expires_at < nowEpoch())
|
|
84
|
-
return { error: 'invalid_grant' };
|
|
85
|
-
// PKCE verification
|
|
86
|
-
if (authCode.code_challenge) {
|
|
87
|
-
if (!codeVerifier)
|
|
88
|
-
return { error: 'invalid_grant' };
|
|
89
|
-
const method = authCode.code_challenge_method || 'S256';
|
|
90
|
-
let computed;
|
|
91
|
-
if (method === 'S256') {
|
|
92
|
-
computed = crypto_1.default.createHash('sha256').update(codeVerifier).digest('base64url');
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
computed = codeVerifier;
|
|
96
|
-
}
|
|
97
|
-
if (computed !== authCode.code_challenge)
|
|
98
|
-
return { error: 'invalid_grant' };
|
|
99
|
-
}
|
|
100
|
-
// Mark code as used
|
|
101
|
-
authCode.used = true;
|
|
102
|
-
this.codes.set(code, authCode);
|
|
103
|
-
// Generate tokens
|
|
104
|
-
const accessToken = this.createAccessToken(clientId, authCode.user_id, authCode.scope);
|
|
105
|
-
const refreshToken = this.createRefreshToken(clientId, authCode.user_id, authCode.scope);
|
|
106
|
-
logger_1.logger.info({ clientId, userId: authCode.user_id }, 'Authorization code exchanged for tokens');
|
|
107
|
-
return {
|
|
108
|
-
access_token: accessToken,
|
|
109
|
-
refresh_token: refreshToken,
|
|
110
|
-
expires_in: ACCESS_TOKEN_TTL,
|
|
111
|
-
scope: authCode.scope,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
// ── Token Management ──
|
|
115
|
-
createAccessToken(clientId, userId, scope) {
|
|
116
|
-
const token = generateToken(32);
|
|
117
|
-
this.accessTokens.set(token, {
|
|
118
|
-
token,
|
|
119
|
-
token_type: 'access',
|
|
120
|
-
client_id: clientId,
|
|
121
|
-
user_id: userId,
|
|
122
|
-
scope,
|
|
123
|
-
expires_at: nowEpoch() + ACCESS_TOKEN_TTL,
|
|
124
|
-
revoked: false,
|
|
125
|
-
});
|
|
126
|
-
return token;
|
|
127
|
-
}
|
|
128
|
-
createRefreshToken(clientId, userId, scope) {
|
|
129
|
-
const token = generateToken(32);
|
|
130
|
-
this.refreshTokens.set(token, {
|
|
131
|
-
token,
|
|
132
|
-
token_type: 'refresh',
|
|
133
|
-
client_id: clientId,
|
|
134
|
-
user_id: userId,
|
|
135
|
-
scope,
|
|
136
|
-
expires_at: nowEpoch() + REFRESH_TOKEN_TTL,
|
|
137
|
-
revoked: false,
|
|
138
|
-
});
|
|
139
|
-
return token;
|
|
140
|
-
}
|
|
141
|
-
refreshAccessToken(refreshToken, clientId) {
|
|
142
|
-
const rt = this.refreshTokens.get(refreshToken);
|
|
143
|
-
if (!rt)
|
|
144
|
-
return { error: 'invalid_grant' };
|
|
145
|
-
if (rt.revoked)
|
|
146
|
-
return { error: 'invalid_grant' };
|
|
147
|
-
if (rt.client_id !== clientId)
|
|
148
|
-
return { error: 'invalid_grant' };
|
|
149
|
-
if (rt.expires_at < nowEpoch())
|
|
150
|
-
return { error: 'invalid_grant' };
|
|
151
|
-
const accessToken = this.createAccessToken(clientId, rt.user_id, rt.scope);
|
|
152
|
-
logger_1.logger.info({ clientId, userId: rt.user_id }, 'Access token refreshed');
|
|
153
|
-
return {
|
|
154
|
-
access_token: accessToken,
|
|
155
|
-
expires_in: ACCESS_TOKEN_TTL,
|
|
156
|
-
scope: rt.scope,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
validateAccessToken(token) {
|
|
160
|
-
const t = this.accessTokens.get(token);
|
|
161
|
-
if (!t)
|
|
162
|
-
return null;
|
|
163
|
-
if (t.revoked)
|
|
164
|
-
return null;
|
|
165
|
-
if (t.expires_at < nowEpoch())
|
|
166
|
-
return null;
|
|
167
|
-
return t;
|
|
168
|
-
}
|
|
169
|
-
revokeToken(token) {
|
|
170
|
-
// Check access tokens
|
|
171
|
-
const at = this.accessTokens.get(token);
|
|
172
|
-
if (at) {
|
|
173
|
-
at.revoked = true;
|
|
174
|
-
this.accessTokens.set(token, at);
|
|
175
|
-
logger_1.logger.info({ tokenType: 'access', clientId: at.client_id }, 'Token revoked');
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
// Check refresh tokens - also revoke all associated access tokens
|
|
179
|
-
const rt = this.refreshTokens.get(token);
|
|
180
|
-
if (rt) {
|
|
181
|
-
rt.revoked = true;
|
|
182
|
-
this.refreshTokens.set(token, rt);
|
|
183
|
-
// Revoke all access tokens for same client+user
|
|
184
|
-
for (const [key, accessToken] of this.accessTokens) {
|
|
185
|
-
if (accessToken.client_id === rt.client_id && accessToken.user_id === rt.user_id) {
|
|
186
|
-
accessToken.revoked = true;
|
|
187
|
-
this.accessTokens.set(key, accessToken);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
logger_1.logger.info({ tokenType: 'refresh', clientId: rt.client_id }, 'Refresh token and associated access tokens revoked');
|
|
191
|
-
return true;
|
|
192
|
-
}
|
|
193
|
-
return false;
|
|
194
|
-
}
|
|
195
|
-
// ── Metadata ──
|
|
196
|
-
getServerMetadata(issuer) {
|
|
197
|
-
return {
|
|
198
|
-
issuer,
|
|
199
|
-
authorization_endpoint: `${issuer}/oauth2/authorize`,
|
|
200
|
-
token_endpoint: `${issuer}/oauth2/token`,
|
|
201
|
-
revocation_endpoint: `${issuer}/oauth2/revoke`,
|
|
202
|
-
scopes_supported: [...exports.UCP_SCOPES],
|
|
203
|
-
response_types_supported: ['code'],
|
|
204
|
-
grant_types_supported: ['authorization_code', 'refresh_token'],
|
|
205
|
-
token_endpoint_auth_methods_supported: ['client_secret_basic'],
|
|
206
|
-
code_challenge_methods_supported: ['S256'],
|
|
207
|
-
service_documentation: `${issuer}/docs/oauth2`,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
exports.OAuthManager = OAuthManager;
|
package/dist/paypal.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare function isPayPalConfigured(): boolean;
|
|
2
|
-
export interface CreatePayPalOrderParams {
|
|
3
|
-
amount: number;
|
|
4
|
-
currency: string;
|
|
5
|
-
checkoutId: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function createPayPalOrder(params: CreatePayPalOrderParams): Promise<{
|
|
9
|
-
id: string;
|
|
10
|
-
status: string;
|
|
11
|
-
} | null>;
|
|
12
|
-
export declare function capturePayPalOrder(orderId: string): Promise<{
|
|
13
|
-
id: string;
|
|
14
|
-
status: string;
|
|
15
|
-
} | null>;
|
|
16
|
-
export declare function getPayPalOrder(orderId: string): Promise<{
|
|
17
|
-
id: string;
|
|
18
|
-
status: string;
|
|
19
|
-
customId?: string;
|
|
20
|
-
} | null>;
|
package/dist/paypal.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPayPalConfigured = isPayPalConfigured;
|
|
4
|
-
exports.createPayPalOrder = createPayPalOrder;
|
|
5
|
-
exports.capturePayPalOrder = capturePayPalOrder;
|
|
6
|
-
exports.getPayPalOrder = getPayPalOrder;
|
|
7
|
-
const paypal_server_sdk_1 = require("@paypal/paypal-server-sdk");
|
|
8
|
-
const config_1 = require("./config");
|
|
9
|
-
const logger_1 = require("./logger");
|
|
10
|
-
let paypalClient = null;
|
|
11
|
-
let ordersController = null;
|
|
12
|
-
function getPayPalClient() {
|
|
13
|
-
if (!config_1.config.paypalClientId || !config_1.config.paypalClientSecret) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
if (!paypalClient) {
|
|
17
|
-
paypalClient = new paypal_server_sdk_1.Client({
|
|
18
|
-
clientCredentialsAuthCredentials: {
|
|
19
|
-
oAuthClientId: config_1.config.paypalClientId,
|
|
20
|
-
oAuthClientSecret: config_1.config.paypalClientSecret,
|
|
21
|
-
},
|
|
22
|
-
environment: config_1.config.paypalMode === 'live' ? paypal_server_sdk_1.Environment.Production : paypal_server_sdk_1.Environment.Sandbox,
|
|
23
|
-
});
|
|
24
|
-
ordersController = new paypal_server_sdk_1.OrdersController(paypalClient);
|
|
25
|
-
logger_1.logger.info('PayPal client initialized');
|
|
26
|
-
}
|
|
27
|
-
return paypalClient;
|
|
28
|
-
}
|
|
29
|
-
function isPayPalConfigured() {
|
|
30
|
-
return !!(config_1.config.paypalClientId && config_1.config.paypalClientSecret);
|
|
31
|
-
}
|
|
32
|
-
async function createPayPalOrder(params) {
|
|
33
|
-
const client = getPayPalClient();
|
|
34
|
-
if (!client || !ordersController) {
|
|
35
|
-
logger_1.logger.warn('PayPal not configured, skipping order creation');
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
// Convert cents to dollars with 2 decimal places
|
|
39
|
-
const amountValue = (params.amount / 100).toFixed(2);
|
|
40
|
-
try {
|
|
41
|
-
const response = await ordersController.createOrder({
|
|
42
|
-
body: {
|
|
43
|
-
intent: paypal_server_sdk_1.CheckoutPaymentIntent.Capture,
|
|
44
|
-
purchaseUnits: [
|
|
45
|
-
{
|
|
46
|
-
amount: {
|
|
47
|
-
currencyCode: params.currency.toUpperCase(),
|
|
48
|
-
value: amountValue,
|
|
49
|
-
},
|
|
50
|
-
description: params.description || `Checkout ${params.checkoutId}`,
|
|
51
|
-
customId: params.checkoutId,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
prefer: 'return=representation',
|
|
56
|
-
});
|
|
57
|
-
const order = response.result;
|
|
58
|
-
logger_1.logger.info({
|
|
59
|
-
paypalOrderId: order.id,
|
|
60
|
-
checkoutId: params.checkoutId,
|
|
61
|
-
amount: params.amount,
|
|
62
|
-
}, 'PayPal order created');
|
|
63
|
-
return { id: order.id, status: order.status };
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
if (error instanceof paypal_server_sdk_1.ApiError) {
|
|
67
|
-
logger_1.logger.error({ error: error.message, checkoutId: params.checkoutId }, 'Failed to create PayPal order');
|
|
68
|
-
}
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async function capturePayPalOrder(orderId) {
|
|
73
|
-
const client = getPayPalClient();
|
|
74
|
-
if (!client || !ordersController)
|
|
75
|
-
return null;
|
|
76
|
-
try {
|
|
77
|
-
const response = await ordersController.captureOrder({
|
|
78
|
-
id: orderId,
|
|
79
|
-
prefer: 'return=representation',
|
|
80
|
-
});
|
|
81
|
-
const order = response.result;
|
|
82
|
-
logger_1.logger.info({ paypalOrderId: orderId, status: order.status }, 'PayPal order captured');
|
|
83
|
-
return { id: order.id, status: order.status };
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
if (error instanceof paypal_server_sdk_1.ApiError) {
|
|
87
|
-
logger_1.logger.error({ error: error.message, paypalOrderId: orderId }, 'Failed to capture PayPal order');
|
|
88
|
-
}
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
async function getPayPalOrder(orderId) {
|
|
93
|
-
const client = getPayPalClient();
|
|
94
|
-
if (!client || !ordersController)
|
|
95
|
-
return null;
|
|
96
|
-
try {
|
|
97
|
-
const response = await ordersController.getOrder({ id: orderId });
|
|
98
|
-
const order = response.result;
|
|
99
|
-
return {
|
|
100
|
-
id: order.id,
|
|
101
|
-
status: order.status,
|
|
102
|
-
customId: order.purchaseUnits?.[0]?.customId,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
if (error instanceof paypal_server_sdk_1.ApiError) {
|
|
107
|
-
logger_1.logger.error({ error: error.message, paypalOrderId: orderId }, 'Failed to get PayPal order');
|
|
108
|
-
}
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
}
|
package/dist/schema.d.ts
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const UCP_VERSION = "2026-01-11";
|
|
3
|
-
export declare const ItemSchema: z.ZodObject<{
|
|
4
|
-
id: z.ZodString;
|
|
5
|
-
title: z.ZodString;
|
|
6
|
-
description: z.ZodOptional<z.ZodString>;
|
|
7
|
-
price: z.ZodNumber;
|
|
8
|
-
image_url: z.ZodOptional<z.ZodString>;
|
|
9
|
-
sku: z.ZodOptional<z.ZodString>;
|
|
10
|
-
stock: z.ZodOptional<z.ZodNumber>;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
export declare const ShippingOptionSchema: z.ZodObject<{
|
|
13
|
-
id: z.ZodString;
|
|
14
|
-
title: z.ZodString;
|
|
15
|
-
description: z.ZodOptional<z.ZodString>;
|
|
16
|
-
price: z.ZodNumber;
|
|
17
|
-
estimated_days: z.ZodOptional<z.ZodString>;
|
|
18
|
-
}, z.core.$strip>;
|
|
19
|
-
export declare const PaymentHandlerSchema: z.ZodObject<{
|
|
20
|
-
namespace: z.ZodString;
|
|
21
|
-
id: z.ZodString;
|
|
22
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
23
|
-
}, z.core.$strip>;
|
|
24
|
-
export declare const OAuthConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
25
|
-
provider: z.ZodLiteral<"built-in">;
|
|
26
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
-
provider: z.ZodLiteral<"external">;
|
|
28
|
-
issuer: z.ZodString;
|
|
29
|
-
authorization_endpoint: z.ZodString;
|
|
30
|
-
token_endpoint: z.ZodString;
|
|
31
|
-
revocation_endpoint: z.ZodOptional<z.ZodString>;
|
|
32
|
-
jwks_uri: z.ZodOptional<z.ZodString>;
|
|
33
|
-
}, z.core.$strip>], "provider">;
|
|
34
|
-
export type OAuthConfig = z.infer<typeof OAuthConfigSchema>;
|
|
35
|
-
export declare const MerchantConfigSchema: z.ZodObject<{
|
|
36
|
-
name: z.ZodString;
|
|
37
|
-
domain: z.ZodString;
|
|
38
|
-
currency: z.ZodDefault<z.ZodString>;
|
|
39
|
-
terms_url: z.ZodOptional<z.ZodString>;
|
|
40
|
-
privacy_url: z.ZodOptional<z.ZodString>;
|
|
41
|
-
items: z.ZodArray<z.ZodObject<{
|
|
42
|
-
id: z.ZodString;
|
|
43
|
-
title: z.ZodString;
|
|
44
|
-
description: z.ZodOptional<z.ZodString>;
|
|
45
|
-
price: z.ZodNumber;
|
|
46
|
-
image_url: z.ZodOptional<z.ZodString>;
|
|
47
|
-
sku: z.ZodOptional<z.ZodString>;
|
|
48
|
-
stock: z.ZodOptional<z.ZodNumber>;
|
|
49
|
-
}, z.core.$strip>>;
|
|
50
|
-
shipping_options: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
51
|
-
id: z.ZodString;
|
|
52
|
-
title: z.ZodString;
|
|
53
|
-
description: z.ZodOptional<z.ZodString>;
|
|
54
|
-
price: z.ZodNumber;
|
|
55
|
-
estimated_days: z.ZodOptional<z.ZodString>;
|
|
56
|
-
}, z.core.$strip>>>;
|
|
57
|
-
payment_handlers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
58
|
-
namespace: z.ZodString;
|
|
59
|
-
id: z.ZodString;
|
|
60
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
61
|
-
}, z.core.$strip>>>;
|
|
62
|
-
tax_rate: z.ZodDefault<z.ZodNumber>;
|
|
63
|
-
port: z.ZodDefault<z.ZodNumber>;
|
|
64
|
-
oauth: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
65
|
-
provider: z.ZodLiteral<"built-in">;
|
|
66
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
67
|
-
provider: z.ZodLiteral<"external">;
|
|
68
|
-
issuer: z.ZodString;
|
|
69
|
-
authorization_endpoint: z.ZodString;
|
|
70
|
-
token_endpoint: z.ZodString;
|
|
71
|
-
revocation_endpoint: z.ZodOptional<z.ZodString>;
|
|
72
|
-
jwks_uri: z.ZodOptional<z.ZodString>;
|
|
73
|
-
}, z.core.$strip>], "provider">>;
|
|
74
|
-
}, z.core.$strip>;
|
|
75
|
-
export type Item = z.infer<typeof ItemSchema>;
|
|
76
|
-
export type ShippingOption = z.infer<typeof ShippingOptionSchema>;
|
|
77
|
-
export type PaymentHandler = z.infer<typeof PaymentHandlerSchema>;
|
|
78
|
-
export type MerchantConfig = z.infer<typeof MerchantConfigSchema>;
|
|
79
|
-
export type CheckoutStatus = 'incomplete' | 'requires_escalation' | 'ready_for_complete' | 'complete_in_progress' | 'completed' | 'canceled';
|
|
80
|
-
export interface Buyer {
|
|
81
|
-
email?: string;
|
|
82
|
-
first_name?: string;
|
|
83
|
-
last_name?: string;
|
|
84
|
-
phone?: string;
|
|
85
|
-
}
|
|
86
|
-
export interface Address {
|
|
87
|
-
id?: string;
|
|
88
|
-
first_name?: string;
|
|
89
|
-
last_name?: string;
|
|
90
|
-
street_address: string;
|
|
91
|
-
address_locality: string;
|
|
92
|
-
address_region: string;
|
|
93
|
-
postal_code: string;
|
|
94
|
-
address_country: string;
|
|
95
|
-
}
|
|
96
|
-
export interface LineItem {
|
|
97
|
-
id: string;
|
|
98
|
-
item: Item;
|
|
99
|
-
quantity: number;
|
|
100
|
-
totals?: {
|
|
101
|
-
type: string;
|
|
102
|
-
amount: number;
|
|
103
|
-
}[];
|
|
104
|
-
}
|
|
105
|
-
export interface FulfillmentOption {
|
|
106
|
-
id: string;
|
|
107
|
-
title: string;
|
|
108
|
-
description?: string;
|
|
109
|
-
totals: {
|
|
110
|
-
type: string;
|
|
111
|
-
amount: number;
|
|
112
|
-
}[];
|
|
113
|
-
}
|
|
114
|
-
export interface FulfillmentGroup {
|
|
115
|
-
id: string;
|
|
116
|
-
line_item_ids: string[];
|
|
117
|
-
selected_option_id?: string;
|
|
118
|
-
options: FulfillmentOption[];
|
|
119
|
-
}
|
|
120
|
-
export interface FulfillmentMethod {
|
|
121
|
-
id: string;
|
|
122
|
-
type: 'shipping' | 'pickup' | 'digital';
|
|
123
|
-
line_item_ids: string[];
|
|
124
|
-
selected_destination_id?: string;
|
|
125
|
-
destinations: Address[];
|
|
126
|
-
groups: FulfillmentGroup[];
|
|
127
|
-
}
|
|
128
|
-
export interface Fulfillment {
|
|
129
|
-
methods: FulfillmentMethod[];
|
|
130
|
-
}
|
|
131
|
-
export interface PaymentInstrument {
|
|
132
|
-
id: string;
|
|
133
|
-
handler_id: string;
|
|
134
|
-
type: string;
|
|
135
|
-
selected?: boolean;
|
|
136
|
-
display?: Record<string, unknown>;
|
|
137
|
-
}
|
|
138
|
-
export interface Payment {
|
|
139
|
-
instruments: PaymentInstrument[];
|
|
140
|
-
}
|
|
141
|
-
export interface CheckoutMessage {
|
|
142
|
-
type: 'error' | 'warning' | 'info';
|
|
143
|
-
code: string;
|
|
144
|
-
path?: string;
|
|
145
|
-
content: string;
|
|
146
|
-
severity: 'recoverable' | 'requires_buyer_input' | 'requires_buyer_review';
|
|
147
|
-
}
|
|
148
|
-
export interface OrderConfirmation {
|
|
149
|
-
id: string;
|
|
150
|
-
permalink_url?: string;
|
|
151
|
-
}
|
|
152
|
-
export interface CheckoutSession {
|
|
153
|
-
ucp: {
|
|
154
|
-
version: string;
|
|
155
|
-
capabilities: Record<string, {
|
|
156
|
-
version: string;
|
|
157
|
-
}[]>;
|
|
158
|
-
payment_handlers?: Record<string, {
|
|
159
|
-
id: string;
|
|
160
|
-
version: string;
|
|
161
|
-
config?: Record<string, unknown>;
|
|
162
|
-
}[]>;
|
|
163
|
-
};
|
|
164
|
-
id: string;
|
|
165
|
-
status: CheckoutStatus;
|
|
166
|
-
messages?: CheckoutMessage[];
|
|
167
|
-
currency: string;
|
|
168
|
-
buyer?: Buyer;
|
|
169
|
-
line_items: LineItem[];
|
|
170
|
-
totals: {
|
|
171
|
-
type: string;
|
|
172
|
-
amount: number;
|
|
173
|
-
}[];
|
|
174
|
-
links: {
|
|
175
|
-
type: string;
|
|
176
|
-
url: string;
|
|
177
|
-
title?: string;
|
|
178
|
-
}[];
|
|
179
|
-
fulfillment?: Fulfillment;
|
|
180
|
-
payment?: Payment;
|
|
181
|
-
continue_url?: string;
|
|
182
|
-
expires_at?: string;
|
|
183
|
-
order?: OrderConfirmation;
|
|
184
|
-
}
|
|
185
|
-
export interface Order {
|
|
186
|
-
ucp: {
|
|
187
|
-
version: string;
|
|
188
|
-
capabilities: Record<string, {
|
|
189
|
-
version: string;
|
|
190
|
-
}[]>;
|
|
191
|
-
};
|
|
192
|
-
id: string;
|
|
193
|
-
checkout_id: string;
|
|
194
|
-
permalink_url?: string;
|
|
195
|
-
line_items: LineItem[];
|
|
196
|
-
buyer?: Buyer;
|
|
197
|
-
totals: {
|
|
198
|
-
type: string;
|
|
199
|
-
amount: number;
|
|
200
|
-
}[];
|
|
201
|
-
fulfillment?: {
|
|
202
|
-
expectations: {
|
|
203
|
-
id: string;
|
|
204
|
-
line_items: {
|
|
205
|
-
id: string;
|
|
206
|
-
quantity: number;
|
|
207
|
-
}[];
|
|
208
|
-
method_type: string;
|
|
209
|
-
destination?: Address;
|
|
210
|
-
description?: string;
|
|
211
|
-
fulfillable_on?: string;
|
|
212
|
-
}[];
|
|
213
|
-
events: {
|
|
214
|
-
id: string;
|
|
215
|
-
occurred_at: string;
|
|
216
|
-
type: string;
|
|
217
|
-
line_items: {
|
|
218
|
-
id: string;
|
|
219
|
-
quantity: number;
|
|
220
|
-
}[];
|
|
221
|
-
tracking_number?: string;
|
|
222
|
-
tracking_url?: string;
|
|
223
|
-
description?: string;
|
|
224
|
-
}[];
|
|
225
|
-
};
|
|
226
|
-
created_at: string;
|
|
227
|
-
}
|
|
228
|
-
export declare const CreateCheckoutRequestSchema: z.ZodObject<{
|
|
229
|
-
line_items: z.ZodArray<z.ZodObject<{
|
|
230
|
-
id: z.ZodOptional<z.ZodString>;
|
|
231
|
-
item: z.ZodObject<{
|
|
232
|
-
id: z.ZodString;
|
|
233
|
-
title: z.ZodOptional<z.ZodString>;
|
|
234
|
-
price: z.ZodOptional<z.ZodNumber>;
|
|
235
|
-
}, z.core.$strip>;
|
|
236
|
-
quantity: z.ZodNumber;
|
|
237
|
-
}, z.core.$strip>>;
|
|
238
|
-
buyer: z.ZodOptional<z.ZodObject<{
|
|
239
|
-
email: z.ZodOptional<z.ZodString>;
|
|
240
|
-
first_name: z.ZodOptional<z.ZodString>;
|
|
241
|
-
last_name: z.ZodOptional<z.ZodString>;
|
|
242
|
-
phone: z.ZodOptional<z.ZodString>;
|
|
243
|
-
}, z.core.$strip>>;
|
|
244
|
-
fulfillment: z.ZodOptional<z.ZodObject<{
|
|
245
|
-
methods: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
246
|
-
id: z.ZodOptional<z.ZodString>;
|
|
247
|
-
type: z.ZodEnum<{
|
|
248
|
-
shipping: "shipping";
|
|
249
|
-
pickup: "pickup";
|
|
250
|
-
digital: "digital";
|
|
251
|
-
}>;
|
|
252
|
-
line_item_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
253
|
-
selected_destination_id: z.ZodOptional<z.ZodString>;
|
|
254
|
-
destinations: z.ZodArray<z.ZodObject<{
|
|
255
|
-
id: z.ZodOptional<z.ZodString>;
|
|
256
|
-
first_name: z.ZodOptional<z.ZodString>;
|
|
257
|
-
last_name: z.ZodOptional<z.ZodString>;
|
|
258
|
-
street_address: z.ZodString;
|
|
259
|
-
address_locality: z.ZodString;
|
|
260
|
-
address_region: z.ZodString;
|
|
261
|
-
postal_code: z.ZodString;
|
|
262
|
-
address_country: z.ZodString;
|
|
263
|
-
}, z.core.$strip>>;
|
|
264
|
-
groups: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
265
|
-
}, z.core.$strip>>>;
|
|
266
|
-
}, z.core.$strip>>;
|
|
267
|
-
}, z.core.$strip>;
|
|
268
|
-
export declare const UpdateCheckoutRequestSchema: z.ZodObject<{
|
|
269
|
-
buyer: z.ZodOptional<z.ZodObject<{
|
|
270
|
-
email: z.ZodOptional<z.ZodString>;
|
|
271
|
-
first_name: z.ZodOptional<z.ZodString>;
|
|
272
|
-
last_name: z.ZodOptional<z.ZodString>;
|
|
273
|
-
phone: z.ZodOptional<z.ZodString>;
|
|
274
|
-
}, z.core.$strip>>;
|
|
275
|
-
line_items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
276
|
-
id: z.ZodOptional<z.ZodString>;
|
|
277
|
-
item: z.ZodObject<{
|
|
278
|
-
id: z.ZodString;
|
|
279
|
-
title: z.ZodOptional<z.ZodString>;
|
|
280
|
-
price: z.ZodOptional<z.ZodNumber>;
|
|
281
|
-
}, z.core.$strip>;
|
|
282
|
-
quantity: z.ZodNumber;
|
|
283
|
-
}, z.core.$strip>>>;
|
|
284
|
-
fulfillment: z.ZodOptional<z.ZodAny>;
|
|
285
|
-
}, z.core.$strip>;
|
|
286
|
-
export type CreateCheckoutRequest = z.infer<typeof CreateCheckoutRequestSchema>;
|
|
287
|
-
export type UpdateCheckoutRequest = z.infer<typeof UpdateCheckoutRequestSchema>;
|