@ucptools/validator 1.0.0 → 1.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.
- package/dist/auth/config.d.ts +20 -0
- package/dist/auth/config.d.ts.map +1 -0
- package/dist/auth/config.js +114 -0
- package/dist/auth/config.js.map +1 -0
- package/dist/auth/index.d.ts +5 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +17 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/middleware.d.ts +45 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +170 -0
- package/dist/auth/middleware.js.map +1 -0
- package/dist/auth/service.d.ts +80 -0
- package/dist/auth/service.d.ts.map +1 -0
- package/dist/auth/service.js +298 -0
- package/dist/auth/service.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +375 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/mock-server.d.ts +20 -0
- package/dist/cli/mock-server.d.ts.map +1 -0
- package/dist/cli/mock-server.js +261 -0
- package/dist/cli/mock-server.js.map +1 -0
- package/dist/compliance/compliance-generator.d.ts +34 -0
- package/dist/compliance/compliance-generator.d.ts.map +1 -0
- package/dist/compliance/compliance-generator.js +320 -0
- package/dist/compliance/compliance-generator.js.map +1 -0
- package/dist/compliance/index.d.ts +8 -0
- package/dist/compliance/index.d.ts.map +1 -0
- package/dist/compliance/index.js +17 -0
- package/dist/compliance/index.js.map +1 -0
- package/dist/compliance/templates.d.ts +34 -0
- package/dist/compliance/templates.d.ts.map +1 -0
- package/{src/compliance/templates.ts → dist/compliance/templates.js} +117 -155
- package/dist/compliance/templates.js.map +1 -0
- package/dist/compliance/types.d.ts +64 -0
- package/dist/compliance/types.d.ts.map +1 -0
- package/dist/compliance/types.js +64 -0
- package/dist/compliance/types.js.map +1 -0
- package/dist/db/index.d.ts +17 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +80 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema.d.ts +3886 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +425 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/db/utils.d.ts +252 -0
- package/dist/db/utils.d.ts.map +1 -0
- package/dist/db/utils.js +295 -0
- package/dist/db/utils.js.map +1 -0
- package/dist/feed-analyzer/feed-analyzer.d.ts +26 -0
- package/dist/feed-analyzer/feed-analyzer.d.ts.map +1 -0
- package/{src/feed-analyzer/feed-analyzer.ts → dist/feed-analyzer/feed-analyzer.js} +856 -726
- package/dist/feed-analyzer/feed-analyzer.js.map +1 -0
- package/dist/feed-analyzer/index.d.ts +8 -0
- package/dist/feed-analyzer/index.d.ts.map +1 -0
- package/dist/feed-analyzer/index.js +19 -0
- package/dist/feed-analyzer/index.js.map +1 -0
- package/dist/feed-analyzer/types.d.ts +285 -0
- package/dist/feed-analyzer/types.d.ts.map +1 -0
- package/dist/feed-analyzer/types.js +175 -0
- package/dist/feed-analyzer/types.js.map +1 -0
- package/{src/generator/index.ts → dist/generator/index.d.ts} +1 -1
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +13 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/key-generator.d.ts +24 -0
- package/dist/generator/key-generator.d.ts.map +1 -0
- package/dist/generator/key-generator.js +144 -0
- package/dist/generator/key-generator.js.map +1 -0
- package/dist/generator/profile-builder.d.ts +15 -0
- package/dist/generator/profile-builder.d.ts.map +1 -0
- package/dist/generator/profile-builder.js +338 -0
- package/dist/generator/profile-builder.js.map +1 -0
- package/dist/hosting/artifacts-generator.d.ts +10 -0
- package/dist/hosting/artifacts-generator.d.ts.map +1 -0
- package/{src/hosting/artifacts-generator.ts → dist/hosting/artifacts-generator.js} +191 -241
- package/dist/hosting/artifacts-generator.js.map +1 -0
- package/{src/hosting/index.ts → dist/hosting/index.d.ts} +1 -1
- package/dist/hosting/index.d.ts.map +1 -0
- package/dist/hosting/index.js +10 -0
- package/dist/hosting/index.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/analytics.d.ts +337 -0
- package/dist/lib/analytics.d.ts.map +1 -0
- package/dist/lib/analytics.js +188 -0
- package/dist/lib/analytics.js.map +1 -0
- package/{src/security/index.ts → dist/security/index.d.ts} +8 -15
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +12 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/security-scanner.d.ts +10 -0
- package/dist/security/security-scanner.d.ts.map +1 -0
- package/dist/security/security-scanner.js +669 -0
- package/dist/security/security-scanner.js.map +1 -0
- package/dist/security/types.d.ts +80 -0
- package/dist/security/types.d.ts.map +1 -0
- package/dist/security/types.js +21 -0
- package/dist/security/types.js.map +1 -0
- package/dist/services/analytics.d.ts +114 -0
- package/dist/services/analytics.d.ts.map +1 -0
- package/dist/services/analytics.js +862 -0
- package/dist/services/analytics.js.map +1 -0
- package/dist/services/badge.d.ts +31 -0
- package/dist/services/badge.d.ts.map +1 -0
- package/dist/services/badge.js +152 -0
- package/dist/services/badge.js.map +1 -0
- package/dist/services/cron.d.ts +125 -0
- package/dist/services/cron.d.ts.map +1 -0
- package/dist/services/cron.js +613 -0
- package/dist/services/cron.js.map +1 -0
- package/dist/services/directory.d.ts +106 -0
- package/dist/services/directory.d.ts.map +1 -0
- package/dist/services/directory.js +351 -0
- package/dist/services/directory.js.map +1 -0
- package/dist/services/email.d.ts +112 -0
- package/dist/services/email.d.ts.map +1 -0
- package/dist/services/email.js +772 -0
- package/dist/services/email.js.map +1 -0
- package/dist/services/hosted-profiles.d.ts +77 -0
- package/dist/services/hosted-profiles.d.ts.map +1 -0
- package/dist/services/hosted-profiles.js +433 -0
- package/dist/services/hosted-profiles.js.map +1 -0
- package/dist/services/latency.d.ts +67 -0
- package/dist/services/latency.d.ts.map +1 -0
- package/dist/services/latency.js +274 -0
- package/dist/services/latency.js.map +1 -0
- package/dist/services/manifest-compliance.d.ts +64 -0
- package/dist/services/manifest-compliance.d.ts.map +1 -0
- package/dist/services/manifest-compliance.js +271 -0
- package/dist/services/manifest-compliance.js.map +1 -0
- package/dist/services/monitoring-diff.d.ts +31 -0
- package/dist/services/monitoring-diff.d.ts.map +1 -0
- package/dist/services/monitoring-diff.js +189 -0
- package/dist/services/monitoring-diff.js.map +1 -0
- package/dist/services/notifications.d.ts +46 -0
- package/dist/services/notifications.d.ts.map +1 -0
- package/dist/services/notifications.js +88 -0
- package/dist/services/notifications.js.map +1 -0
- package/dist/services/stripe.d.ts +93 -0
- package/dist/services/stripe.d.ts.map +1 -0
- package/dist/services/stripe.js +490 -0
- package/dist/services/stripe.js.map +1 -0
- package/dist/services/validation-history.d.ts +99 -0
- package/dist/services/validation-history.d.ts.map +1 -0
- package/dist/services/validation-history.js +344 -0
- package/dist/services/validation-history.js.map +1 -0
- package/dist/services/validation-logging.d.ts +103 -0
- package/dist/services/validation-logging.d.ts.map +1 -0
- package/dist/services/validation-logging.js +210 -0
- package/dist/services/validation-logging.js.map +1 -0
- package/dist/services/validation.d.ts +119 -0
- package/dist/services/validation.d.ts.map +1 -0
- package/dist/services/validation.js +1185 -0
- package/dist/services/validation.js.map +1 -0
- package/dist/simulator/agent-simulator.d.ts +69 -0
- package/dist/simulator/agent-simulator.d.ts.map +1 -0
- package/dist/simulator/agent-simulator.js +870 -0
- package/dist/simulator/agent-simulator.js.map +1 -0
- package/{src/simulator/index.ts → dist/simulator/index.d.ts} +7 -7
- package/dist/simulator/index.d.ts.map +1 -0
- package/dist/simulator/index.js +23 -0
- package/dist/simulator/index.js.map +1 -0
- package/{src/simulator/types.ts → dist/simulator/types.d.ts} +171 -170
- package/dist/simulator/types.d.ts.map +1 -0
- package/dist/simulator/types.js +18 -0
- package/dist/simulator/types.js.map +1 -0
- package/dist/types/acp-validation.d.ts +87 -0
- package/dist/types/acp-validation.d.ts.map +1 -0
- package/dist/types/acp-validation.js +40 -0
- package/dist/types/acp-validation.js.map +1 -0
- package/dist/types/analytics.d.ts +182 -0
- package/dist/types/analytics.d.ts.map +1 -0
- package/dist/types/analytics.js +7 -0
- package/dist/types/analytics.js.map +1 -0
- package/dist/types/generator.d.ts +106 -0
- package/dist/types/generator.d.ts.map +1 -0
- package/dist/types/generator.js +6 -0
- package/dist/types/generator.js.map +1 -0
- package/{src/types/index.ts → dist/types/index.d.ts} +1 -1
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +23 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/ucp-profile.d.ts +111 -0
- package/dist/types/ucp-profile.d.ts.map +1 -0
- package/dist/types/ucp-profile.js +45 -0
- package/dist/types/ucp-profile.js.map +1 -0
- package/dist/types/validation.d.ts +76 -0
- package/dist/types/validation.d.ts.map +1 -0
- package/dist/types/validation.js +42 -0
- package/dist/types/validation.js.map +1 -0
- package/dist/validator/acp/index.d.ts +31 -0
- package/dist/validator/acp/index.d.ts.map +1 -0
- package/dist/validator/acp/index.js +574 -0
- package/dist/validator/acp/index.js.map +1 -0
- package/dist/validator/index.d.ts +26 -0
- package/dist/validator/index.d.ts.map +1 -0
- package/dist/validator/index.js +161 -0
- package/dist/validator/index.js.map +1 -0
- package/dist/validator/network-validator.d.ts +28 -0
- package/dist/validator/network-validator.d.ts.map +1 -0
- package/dist/validator/network-validator.js +319 -0
- package/dist/validator/network-validator.js.map +1 -0
- package/dist/validator/rules-validator.d.ts +19 -0
- package/dist/validator/rules-validator.d.ts.map +1 -0
- package/dist/validator/rules-validator.js +306 -0
- package/dist/validator/rules-validator.js.map +1 -0
- package/dist/validator/sdk-validator.d.ts +58 -0
- package/dist/validator/sdk-validator.d.ts.map +1 -0
- package/{src/validator/sdk-validator.ts → dist/validator/sdk-validator.js} +273 -330
- package/dist/validator/sdk-validator.js.map +1 -0
- package/dist/validator/structural-validator.d.ts +11 -0
- package/dist/validator/structural-validator.d.ts.map +1 -0
- package/dist/validator/structural-validator.js +549 -0
- package/dist/validator/structural-validator.js.map +1 -0
- package/dist/validator/utils.d.ts +51 -0
- package/dist/validator/utils.d.ts.map +1 -0
- package/dist/validator/utils.js +132 -0
- package/dist/validator/utils.js.map +1 -0
- package/package.json +44 -12
- package/CLAUDE.md +0 -109
- package/api/analyze-feed.js +0 -140
- package/api/badge.js +0 -185
- package/api/benchmark.js +0 -177
- package/api/directory-stats.ts +0 -29
- package/api/directory.ts +0 -73
- package/api/generate-compliance.js +0 -143
- package/api/generate-schema.js +0 -457
- package/api/generate.js +0 -132
- package/api/security-scan.js +0 -133
- package/api/simulate.js +0 -187
- package/api/tsconfig.json +0 -10
- package/api/validate.js +0 -1351
- package/apify-actor/.actor/actor.json +0 -68
- package/apify-actor/.actor/input_schema.json +0 -32
- package/apify-actor/APIFY-STORE-LISTING.md +0 -412
- package/apify-actor/Dockerfile +0 -8
- package/apify-actor/README.md +0 -166
- package/apify-actor/main.ts +0 -111
- package/apify-actor/package.json +0 -17
- package/apify-actor/src/main.js +0 -199
- package/docs/BRAND-IDENTITY.md +0 -238
- package/docs/BRAND-STYLE-GUIDE.md +0 -356
- package/drizzle/0000_black_king_cobra.sql +0 -39
- package/drizzle/meta/0000_snapshot.json +0 -309
- package/drizzle/meta/_journal.json +0 -13
- package/drizzle.config.ts +0 -10
- package/public/.well-known/ucp +0 -25
- package/public/android-chrome-192x192.png +0 -0
- package/public/android-chrome-512x512.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/brand.css +0 -321
- package/public/directory.html +0 -701
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/guides/bigcommerce.html +0 -743
- package/public/guides/fastucp.html +0 -838
- package/public/guides/magento.html +0 -779
- package/public/guides/shopify.html +0 -726
- package/public/guides/squarespace.html +0 -749
- package/public/guides/wix.html +0 -747
- package/public/guides/woocommerce.html +0 -733
- package/public/index.html +0 -3835
- package/public/learn.html +0 -396
- package/public/logo.jpeg +0 -0
- package/public/og-image-icon.png +0 -0
- package/public/og-image.png +0 -0
- package/public/robots.txt +0 -6
- package/public/site.webmanifest +0 -31
- package/public/sitemap.xml +0 -69
- package/public/social/linkedin-banner-1128x191.png +0 -0
- package/public/social/temp.PNG +0 -0
- package/public/social/x-header-1500x500.png +0 -0
- package/public/verify.html +0 -410
- package/scripts/generate-favicons.js +0 -44
- package/scripts/generate-ico.js +0 -23
- package/scripts/generate-og-image.js +0 -45
- package/scripts/reset-db.ts +0 -77
- package/scripts/seed-db.ts +0 -71
- package/scripts/setup-benchmark-db.js +0 -70
- package/src/api/server.ts +0 -266
- package/src/cli/index.ts +0 -302
- package/src/compliance/compliance-generator.ts +0 -452
- package/src/compliance/index.ts +0 -28
- package/src/compliance/types.ts +0 -170
- package/src/db/index.ts +0 -28
- package/src/db/schema.ts +0 -84
- package/src/feed-analyzer/index.ts +0 -34
- package/src/feed-analyzer/types.ts +0 -354
- package/src/generator/key-generator.ts +0 -124
- package/src/generator/profile-builder.ts +0 -402
- package/src/index.ts +0 -105
- package/src/security/security-scanner.ts +0 -604
- package/src/security/types.ts +0 -55
- package/src/services/directory.ts +0 -434
- package/src/simulator/agent-simulator.ts +0 -941
- package/src/types/generator.ts +0 -140
- package/src/types/ucp-profile.ts +0 -140
- package/src/types/validation.ts +0 -89
- package/src/validator/index.ts +0 -194
- package/src/validator/network-validator.ts +0 -417
- package/src/validator/rules-validator.ts +0 -297
- package/src/validator/structural-validator.ts +0 -476
- package/tests/fixtures/non-compliant-profile.json +0 -25
- package/tests/fixtures/official-sample-profile.json +0 -75
- package/tests/integration/benchmark.test.ts +0 -207
- package/tests/integration/database.test.ts +0 -163
- package/tests/integration/directory-api.test.ts +0 -268
- package/tests/integration/simulate-api.test.ts +0 -230
- package/tests/integration/validate-api.test.ts +0 -269
- package/tests/setup.ts +0 -15
- package/tests/unit/agent-simulator.test.ts +0 -575
- package/tests/unit/compliance-generator.test.ts +0 -374
- package/tests/unit/directory-service.test.ts +0 -272
- package/tests/unit/feed-analyzer.test.ts +0 -517
- package/tests/unit/lint-suggestions.test.ts +0 -423
- package/tests/unit/official-samples.test.ts +0 -211
- package/tests/unit/pdf-report.test.ts +0 -390
- package/tests/unit/sdk-validator.test.ts +0 -531
- package/tests/unit/security-scanner.test.ts +0 -410
- package/tests/unit/validation.test.ts +0 -390
- package/tsconfig.json +0 -20
- package/vercel.json +0 -34
- package/vitest.config.ts +0 -22
package/src/types/generator.ts
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generator Types for UCP Profile Generator
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { Environment, ProfileStatus } from './ucp-profile.js';
|
|
6
|
-
|
|
7
|
-
// Merchant information
|
|
8
|
-
export interface MerchantInfo {
|
|
9
|
-
merchantId: string;
|
|
10
|
-
primaryDomain: string;
|
|
11
|
-
displayName?: string;
|
|
12
|
-
environment?: Environment;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Transport configuration inputs
|
|
16
|
-
export interface TransportConfig {
|
|
17
|
-
rest?: {
|
|
18
|
-
endpoint: string;
|
|
19
|
-
schemaUrl?: string; // Override default
|
|
20
|
-
};
|
|
21
|
-
mcp?: {
|
|
22
|
-
endpoint: string;
|
|
23
|
-
schemaUrl?: string;
|
|
24
|
-
};
|
|
25
|
-
a2a?: {
|
|
26
|
-
agentCardUrl: string;
|
|
27
|
-
};
|
|
28
|
-
embedded?: {
|
|
29
|
-
schemaUrl: string;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Capability selection (based on official UCP spec)
|
|
34
|
-
export interface CapabilitySelection {
|
|
35
|
-
checkout: boolean; // Default: true
|
|
36
|
-
order: boolean; // Requires signing keys
|
|
37
|
-
fulfillment: boolean; // Extension of order
|
|
38
|
-
discount: boolean; // Extension
|
|
39
|
-
payment?: boolean; // Payment capability
|
|
40
|
-
buyerConsent?: boolean; // Buyer consent capability
|
|
41
|
-
customCapabilities?: CustomCapability[];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Custom/vendor capability
|
|
45
|
-
export interface CustomCapability {
|
|
46
|
-
namespace: string; // e.g., "com.myvendor"
|
|
47
|
-
name: string; // e.g., "custom-feature"
|
|
48
|
-
version: string;
|
|
49
|
-
specUrl: string;
|
|
50
|
-
schemaUrl: string;
|
|
51
|
-
extendsCapability?: string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Security configuration
|
|
55
|
-
export interface SecurityConfig {
|
|
56
|
-
generateSigningKeys: boolean;
|
|
57
|
-
signingKeyAlgorithm?: 'ES256' | 'RS256';
|
|
58
|
-
uploadedPublicKey?: string; // PEM or JWK format
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Complete generator input
|
|
62
|
-
export interface GeneratorInput {
|
|
63
|
-
merchant: MerchantInfo;
|
|
64
|
-
transport: TransportConfig;
|
|
65
|
-
capabilities: CapabilitySelection;
|
|
66
|
-
security?: SecurityConfig;
|
|
67
|
-
ucpVersion?: string; // Override default version
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Generator output artifacts
|
|
71
|
-
export interface GeneratorOutput {
|
|
72
|
-
profile: object; // The UCP profile JSON
|
|
73
|
-
profileJson: string; // Formatted JSON string
|
|
74
|
-
installInstructions: string; // Markdown instructions
|
|
75
|
-
validationReport?: object; // Initial validation
|
|
76
|
-
signingKeyPair?: { // If keys were generated
|
|
77
|
-
publicKey: object; // JWK public key
|
|
78
|
-
privateKey: string; // PEM private key (for merchant to store securely)
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Hosting mode options
|
|
83
|
-
export type HostingMode = 'static' | 'edge-worker' | 'reverse-proxy';
|
|
84
|
-
|
|
85
|
-
// Hosting target platforms
|
|
86
|
-
export type HostingPlatform =
|
|
87
|
-
| 'nginx'
|
|
88
|
-
| 'apache'
|
|
89
|
-
| 'vercel'
|
|
90
|
-
| 'netlify'
|
|
91
|
-
| 'cloudflare-worker'
|
|
92
|
-
| 'cloudflare-pages'
|
|
93
|
-
| 's3-cloudfront'
|
|
94
|
-
| 'generic';
|
|
95
|
-
|
|
96
|
-
// Hosting configuration
|
|
97
|
-
export interface HostingConfig {
|
|
98
|
-
mode: HostingMode;
|
|
99
|
-
platform?: HostingPlatform;
|
|
100
|
-
merchantId: string;
|
|
101
|
-
merchantDomain: string;
|
|
102
|
-
hostedProfileUrl?: string; // For edge/proxy modes
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Install artifact
|
|
106
|
-
export interface InstallArtifact {
|
|
107
|
-
filename: string;
|
|
108
|
-
content: string;
|
|
109
|
-
contentType: 'json' | 'javascript' | 'nginx' | 'apache' | 'markdown';
|
|
110
|
-
description: string;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Database models (for API service)
|
|
114
|
-
export interface MerchantRecord {
|
|
115
|
-
id: string;
|
|
116
|
-
primaryDomain: string;
|
|
117
|
-
displayName?: string;
|
|
118
|
-
createdAt: Date;
|
|
119
|
-
updatedAt: Date;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export interface ProfileRecord {
|
|
123
|
-
id: string;
|
|
124
|
-
merchantId: string;
|
|
125
|
-
versionTag: string;
|
|
126
|
-
ucpVersion: string;
|
|
127
|
-
jsonBody: object;
|
|
128
|
-
status: ProfileStatus;
|
|
129
|
-
createdAt: Date;
|
|
130
|
-
updatedAt: Date;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export interface ValidationRunRecord {
|
|
134
|
-
id: string;
|
|
135
|
-
profileId: string;
|
|
136
|
-
mode: 'draft' | 'remote';
|
|
137
|
-
result: object;
|
|
138
|
-
ok: boolean;
|
|
139
|
-
createdAt: Date;
|
|
140
|
-
}
|
package/src/types/ucp-profile.ts
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UCP (Universal Commerce Protocol) Profile Types
|
|
3
|
-
* Based on https://ucp.dev/specification/overview/
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Current UCP version
|
|
7
|
-
export const CURRENT_UCP_VERSION = '2026-01-11';
|
|
8
|
-
|
|
9
|
-
// Transport binding types
|
|
10
|
-
export interface RestTransport {
|
|
11
|
-
schema: string; // OpenAPI schema URL
|
|
12
|
-
endpoint: string; // REST API endpoint (https, no trailing slash)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface McpTransport {
|
|
16
|
-
schema: string; // MCP schema URL
|
|
17
|
-
endpoint: string; // MCP endpoint URL
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface A2aTransport {
|
|
21
|
-
agentCard: string; // A2A agent card URL
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface EmbeddedTransport {
|
|
25
|
-
schema: string; // Embedded schema URL
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Service definition with transport bindings
|
|
29
|
-
export interface UcpService {
|
|
30
|
-
version: string;
|
|
31
|
-
spec: string;
|
|
32
|
-
rest?: RestTransport;
|
|
33
|
-
mcp?: McpTransport;
|
|
34
|
-
a2a?: A2aTransport;
|
|
35
|
-
embedded?: EmbeddedTransport;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Capability definition
|
|
39
|
-
export interface UcpCapability {
|
|
40
|
-
name: string; // e.g., "dev.ucp.shopping.checkout"
|
|
41
|
-
version: string; // e.g., "2026-01-11"
|
|
42
|
-
spec: string; // Specification URL
|
|
43
|
-
schema: string; // JSON Schema URL
|
|
44
|
-
extends?: string; // Parent capability for extensions
|
|
45
|
-
config?: Record<string, unknown>; // Capability-specific settings
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// JWK (JSON Web Key) for signing
|
|
49
|
-
export interface JwkKey {
|
|
50
|
-
kty: string; // Key type (e.g., "EC", "RSA")
|
|
51
|
-
kid: string; // Key ID
|
|
52
|
-
use?: string; // Key use (e.g., "sig")
|
|
53
|
-
alg?: string; // Algorithm (e.g., "ES256")
|
|
54
|
-
crv?: string; // Curve (for EC keys)
|
|
55
|
-
x?: string; // X coordinate (for EC keys)
|
|
56
|
-
y?: string; // Y coordinate (for EC keys)
|
|
57
|
-
n?: string; // Modulus (for RSA keys)
|
|
58
|
-
e?: string; // Exponent (for RSA keys)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Signing keys - array of JWK public keys at root level
|
|
62
|
-
export type SigningKeys = JwkKey[];
|
|
63
|
-
|
|
64
|
-
// Payment handler definition
|
|
65
|
-
export interface PaymentHandler {
|
|
66
|
-
id: string; // Handler identifier
|
|
67
|
-
name: string; // Display name
|
|
68
|
-
version: string; // Handler version (YYYY-MM-DD)
|
|
69
|
-
spec: string; // Handler specification URL
|
|
70
|
-
config_schema?: string; // Configuration schema URL
|
|
71
|
-
instrument_schemas?: string[]; // Payment instrument schemas
|
|
72
|
-
config?: Record<string, unknown>; // Handler-specific config
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Payment configuration
|
|
76
|
-
export interface PaymentConfig {
|
|
77
|
-
handlers: PaymentHandler[];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Main UCP object within profile
|
|
81
|
-
export interface UcpObject {
|
|
82
|
-
version: string;
|
|
83
|
-
services: Record<string, UcpService>;
|
|
84
|
-
capabilities: UcpCapability[];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Complete UCP Business Profile (/.well-known/ucp)
|
|
88
|
-
export interface UcpProfile {
|
|
89
|
-
ucp: UcpObject;
|
|
90
|
-
payment?: PaymentConfig; // Payment handlers configuration
|
|
91
|
-
signing_keys?: SigningKeys; // JWK public keys for webhook verification
|
|
92
|
-
// Additional vendor extensions can be added as siblings
|
|
93
|
-
[key: string]: unknown;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Known capability namespaces
|
|
97
|
-
export const CAPABILITY_NAMESPACES = {
|
|
98
|
-
UCP_OFFICIAL: 'dev.ucp.',
|
|
99
|
-
VENDOR_PREFIX: 'com.',
|
|
100
|
-
} as const;
|
|
101
|
-
|
|
102
|
-
// Known UCP capabilities (from official spec)
|
|
103
|
-
export const KNOWN_CAPABILITIES = {
|
|
104
|
-
CHECKOUT: 'dev.ucp.shopping.checkout',
|
|
105
|
-
ORDER: 'dev.ucp.shopping.order',
|
|
106
|
-
PAYMENT: 'dev.ucp.shopping.payment',
|
|
107
|
-
PAYMENT_DATA: 'dev.ucp.shopping.payment_data',
|
|
108
|
-
FULFILLMENT: 'dev.ucp.shopping.fulfillment',
|
|
109
|
-
DISCOUNT: 'dev.ucp.shopping.discount',
|
|
110
|
-
BUYER_CONSENT: 'dev.ucp.shopping.buyer_consent',
|
|
111
|
-
} as const;
|
|
112
|
-
|
|
113
|
-
// Known UCP services
|
|
114
|
-
export const KNOWN_SERVICES = {
|
|
115
|
-
SHOPPING: 'dev.ucp.shopping',
|
|
116
|
-
} as const;
|
|
117
|
-
|
|
118
|
-
// Default URLs for UCP official resources
|
|
119
|
-
export const UCP_DEFAULTS = {
|
|
120
|
-
SPEC_BASE: 'https://ucp.dev/specification/',
|
|
121
|
-
SCHEMA_BASE: 'https://ucp.dev/schemas/',
|
|
122
|
-
SERVICE_SCHEMA_BASE: 'https://ucp.dev/services/',
|
|
123
|
-
|
|
124
|
-
// Default schema URLs
|
|
125
|
-
SHOPPING_REST_SCHEMA: 'https://ucp.dev/services/shopping/rest.openapi.json',
|
|
126
|
-
CHECKOUT_SPEC: 'https://ucp.dev/specification/checkout/',
|
|
127
|
-
CHECKOUT_SCHEMA: 'https://ucp.dev/schemas/shopping/checkout.json',
|
|
128
|
-
ORDER_SPEC: 'https://ucp.dev/specification/order/',
|
|
129
|
-
ORDER_SCHEMA: 'https://ucp.dev/schemas/shopping/order.json',
|
|
130
|
-
FULFILLMENT_SPEC: 'https://ucp.dev/specification/fulfillment/',
|
|
131
|
-
FULFILLMENT_SCHEMA: 'https://ucp.dev/schemas/shopping/fulfillment.json',
|
|
132
|
-
DISCOUNT_SPEC: 'https://ucp.dev/specification/discount/',
|
|
133
|
-
DISCOUNT_SCHEMA: 'https://ucp.dev/schemas/shopping/discount.json',
|
|
134
|
-
} as const;
|
|
135
|
-
|
|
136
|
-
// Environment types
|
|
137
|
-
export type Environment = 'production' | 'staging' | 'development';
|
|
138
|
-
|
|
139
|
-
// Profile status
|
|
140
|
-
export type ProfileStatus = 'draft' | 'published';
|
package/src/types/validation.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validation Types for UCP Profile Validator
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// Validation severity levels
|
|
6
|
-
export type ValidationSeverity = 'error' | 'warn' | 'info';
|
|
7
|
-
|
|
8
|
-
// Validation error codes
|
|
9
|
-
export const ValidationErrorCodes = {
|
|
10
|
-
// Structural errors
|
|
11
|
-
MISSING_UCP_OBJECT: 'UCP_MISSING_ROOT',
|
|
12
|
-
MISSING_VERSION: 'UCP_MISSING_VERSION',
|
|
13
|
-
INVALID_VERSION_FORMAT: 'UCP_INVALID_VERSION_FORMAT',
|
|
14
|
-
MISSING_SERVICES: 'UCP_MISSING_SERVICES',
|
|
15
|
-
MISSING_CAPABILITIES: 'UCP_MISSING_CAPABILITIES',
|
|
16
|
-
INVALID_SERVICE_STRUCTURE: 'UCP_INVALID_SERVICE',
|
|
17
|
-
INVALID_CAPABILITY_STRUCTURE: 'UCP_INVALID_CAPABILITY',
|
|
18
|
-
|
|
19
|
-
// UCP rules errors
|
|
20
|
-
NS_ORIGIN_MISMATCH: 'UCP_NS_ORIGIN_MISMATCH',
|
|
21
|
-
ORPHANED_EXTENSION: 'UCP_ORPHANED_EXTENSION',
|
|
22
|
-
ENDPOINT_NOT_HTTPS: 'UCP_ENDPOINT_NOT_HTTPS',
|
|
23
|
-
ENDPOINT_TRAILING_SLASH: 'UCP_ENDPOINT_TRAILING_SLASH',
|
|
24
|
-
MISSING_SIGNING_KEYS: 'UCP_MISSING_SIGNING_KEYS',
|
|
25
|
-
INVALID_SIGNING_KEY: 'UCP_INVALID_SIGNING_KEY',
|
|
26
|
-
|
|
27
|
-
// Network validation errors
|
|
28
|
-
PROFILE_FETCH_FAILED: 'UCP_PROFILE_FETCH_FAILED',
|
|
29
|
-
SCHEMA_FETCH_FAILED: 'UCP_SCHEMA_FETCH_FAILED',
|
|
30
|
-
SCHEMA_NOT_SELF_DESCRIBING: 'UCP_SCHEMA_NOT_SELF_DESCRIBING',
|
|
31
|
-
SCHEMA_NAME_MISMATCH: 'UCP_SCHEMA_NAME_MISMATCH',
|
|
32
|
-
SCHEMA_VERSION_MISMATCH: 'UCP_SCHEMA_VERSION_MISMATCH',
|
|
33
|
-
PRIVATE_IP_ENDPOINT: 'UCP_PRIVATE_IP_ENDPOINT',
|
|
34
|
-
} as const;
|
|
35
|
-
|
|
36
|
-
export type ValidationErrorCode = typeof ValidationErrorCodes[keyof typeof ValidationErrorCodes];
|
|
37
|
-
|
|
38
|
-
// Single validation issue
|
|
39
|
-
export interface ValidationIssue {
|
|
40
|
-
severity: ValidationSeverity;
|
|
41
|
-
code: ValidationErrorCode;
|
|
42
|
-
path: string; // JSON path (e.g., "$.ucp.capabilities[0].schema")
|
|
43
|
-
message: string; // Human-readable message
|
|
44
|
-
hint?: string; // Suggestion for fixing
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Validation report
|
|
48
|
-
export interface ValidationReport {
|
|
49
|
-
ok: boolean;
|
|
50
|
-
profile_url?: string; // For remote validation
|
|
51
|
-
ucp_version?: string;
|
|
52
|
-
issues: ValidationIssue[];
|
|
53
|
-
validated_at: string; // ISO timestamp
|
|
54
|
-
validation_mode: ValidationMode;
|
|
55
|
-
sdk_validation?: { // Official SDK validation info
|
|
56
|
-
validated: boolean; // Whether SDK validation passed
|
|
57
|
-
sdk_version: string; // @ucp-js/sdk version used
|
|
58
|
-
compliant: boolean; // Whether profile is SDK-compliant
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Validation modes
|
|
63
|
-
export type ValidationMode = 'structural' | 'rules' | 'network' | 'full';
|
|
64
|
-
|
|
65
|
-
// Validation options
|
|
66
|
-
export interface ValidationOptions {
|
|
67
|
-
mode?: ValidationMode;
|
|
68
|
-
skipNetworkChecks?: boolean;
|
|
69
|
-
timeoutMs?: number;
|
|
70
|
-
cacheTtlMs?: number;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Schema cache entry
|
|
74
|
-
export interface SchemaCacheEntry {
|
|
75
|
-
url: string;
|
|
76
|
-
etag?: string;
|
|
77
|
-
fetchedAt: string;
|
|
78
|
-
body: Record<string, unknown>;
|
|
79
|
-
expiresAt: string;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Remote fetch result
|
|
83
|
-
export interface FetchResult<T> {
|
|
84
|
-
success: boolean;
|
|
85
|
-
data?: T;
|
|
86
|
-
error?: string;
|
|
87
|
-
statusCode?: number;
|
|
88
|
-
etag?: string;
|
|
89
|
-
}
|
package/src/validator/index.ts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UCP Profile Validator
|
|
3
|
-
* Main entry point combining structural, rules, and network validation
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { UcpProfile } from '../types/ucp-profile.js';
|
|
7
|
-
import type {
|
|
8
|
-
ValidationReport,
|
|
9
|
-
ValidationIssue,
|
|
10
|
-
ValidationMode,
|
|
11
|
-
ValidationOptions,
|
|
12
|
-
} from '../types/validation.js';
|
|
13
|
-
import { validateStructure } from './structural-validator.js';
|
|
14
|
-
import { validateRules } from './rules-validator.js';
|
|
15
|
-
import { validateNetwork, validateRemoteProfile, clearSchemaCache } from './network-validator.js';
|
|
16
|
-
import { safeValidateWithSdk, getSdkVersion, isSdkCompliant } from './sdk-validator.js';
|
|
17
|
-
import type { NetworkValidationOptions } from './network-validator.js';
|
|
18
|
-
|
|
19
|
-
export { validateStructure } from './structural-validator.js';
|
|
20
|
-
export { validateRules } from './rules-validator.js';
|
|
21
|
-
export { validateNetwork, validateRemoteProfile, clearSchemaCache } from './network-validator.js';
|
|
22
|
-
export {
|
|
23
|
-
safeValidateWithSdk,
|
|
24
|
-
validateWithSdk,
|
|
25
|
-
getSdkVersion,
|
|
26
|
-
isSdkCompliant,
|
|
27
|
-
validateServiceWithSdk,
|
|
28
|
-
validateCapabilityWithSdk,
|
|
29
|
-
validateSigningKeysWithSdk,
|
|
30
|
-
} from './sdk-validator.js';
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Validate a UCP profile (local JSON)
|
|
34
|
-
*/
|
|
35
|
-
export async function validateProfile(
|
|
36
|
-
profile: unknown,
|
|
37
|
-
options: ValidationOptions = {}
|
|
38
|
-
): Promise<ValidationReport> {
|
|
39
|
-
const mode = options.mode || 'full';
|
|
40
|
-
const issues: ValidationIssue[] = [];
|
|
41
|
-
|
|
42
|
-
// Phase 1: Structural validation (always run)
|
|
43
|
-
if (mode === 'structural' || mode === 'rules' || mode === 'full') {
|
|
44
|
-
const structuralIssues = validateStructure(profile);
|
|
45
|
-
issues.push(...structuralIssues);
|
|
46
|
-
|
|
47
|
-
// If structural validation has errors, don't proceed with rules/network
|
|
48
|
-
const hasStructuralErrors = structuralIssues.some(i => i.severity === 'error');
|
|
49
|
-
if (hasStructuralErrors && mode !== 'structural') {
|
|
50
|
-
return buildReport(issues, mode, undefined, profile);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// At this point, profile structure is valid
|
|
55
|
-
const ucpProfile = profile as UcpProfile;
|
|
56
|
-
|
|
57
|
-
// Phase 2: UCP rules validation
|
|
58
|
-
if (mode === 'rules' || mode === 'full') {
|
|
59
|
-
const rulesIssues = validateRules(ucpProfile);
|
|
60
|
-
issues.push(...rulesIssues);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Phase 3: Network validation (optional)
|
|
64
|
-
if (mode === 'network' || mode === 'full') {
|
|
65
|
-
if (!options.skipNetworkChecks) {
|
|
66
|
-
const networkOptions: NetworkValidationOptions = {
|
|
67
|
-
timeoutMs: options.timeoutMs,
|
|
68
|
-
cacheTtlMs: options.cacheTtlMs,
|
|
69
|
-
};
|
|
70
|
-
const networkIssues = await validateNetwork(ucpProfile, networkOptions);
|
|
71
|
-
issues.push(...networkIssues);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return buildReport(issues, mode, undefined, ucpProfile);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Validate a remote UCP profile (fetches from domain)
|
|
80
|
-
*/
|
|
81
|
-
export async function validateRemote(
|
|
82
|
-
domain: string,
|
|
83
|
-
options: ValidationOptions = {}
|
|
84
|
-
): Promise<ValidationReport> {
|
|
85
|
-
const issues: ValidationIssue[] = [];
|
|
86
|
-
|
|
87
|
-
// Fetch remote profile
|
|
88
|
-
const { profile, profileUrl: foundProfileUrl, issues: fetchIssues } = await validateRemoteProfile(domain, {
|
|
89
|
-
timeoutMs: options.timeoutMs,
|
|
90
|
-
cacheTtlMs: options.cacheTtlMs,
|
|
91
|
-
});
|
|
92
|
-
issues.push(...fetchIssues);
|
|
93
|
-
|
|
94
|
-
const profileUrl = foundProfileUrl || `https://${domain}/.well-known/ucp`;
|
|
95
|
-
|
|
96
|
-
if (!profile) {
|
|
97
|
-
return buildReport(issues, 'network', profileUrl, undefined);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Run full validation on fetched profile
|
|
101
|
-
const validationResult = await validateProfile(profile, options);
|
|
102
|
-
issues.push(...validationResult.issues);
|
|
103
|
-
|
|
104
|
-
return buildReport(issues, options.mode || 'full', profileUrl, profile);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Build validation report
|
|
109
|
-
*/
|
|
110
|
-
function buildReport(
|
|
111
|
-
issues: ValidationIssue[],
|
|
112
|
-
mode: ValidationMode,
|
|
113
|
-
profileUrl?: string,
|
|
114
|
-
profile?: unknown
|
|
115
|
-
): ValidationReport {
|
|
116
|
-
// Determine if validation passed (no errors)
|
|
117
|
-
const hasErrors = issues.some(i => i.severity === 'error');
|
|
118
|
-
|
|
119
|
-
// Extract UCP version if available
|
|
120
|
-
let ucpVersion: string | undefined;
|
|
121
|
-
if (profile && typeof profile === 'object') {
|
|
122
|
-
const p = profile as Record<string, unknown>;
|
|
123
|
-
if (p.ucp && typeof p.ucp === 'object') {
|
|
124
|
-
const ucp = p.ucp as Record<string, unknown>;
|
|
125
|
-
if (typeof ucp.version === 'string') {
|
|
126
|
-
ucpVersion = ucp.version;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Run SDK validation for compliance check
|
|
132
|
-
const sdkCompliant = profile ? isSdkCompliant(profile) : false;
|
|
133
|
-
|
|
134
|
-
return {
|
|
135
|
-
ok: !hasErrors,
|
|
136
|
-
profile_url: profileUrl,
|
|
137
|
-
ucp_version: ucpVersion,
|
|
138
|
-
issues,
|
|
139
|
-
validated_at: new Date().toISOString(),
|
|
140
|
-
validation_mode: mode,
|
|
141
|
-
sdk_validation: {
|
|
142
|
-
validated: true,
|
|
143
|
-
sdk_version: getSdkVersion(),
|
|
144
|
-
compliant: sdkCompliant,
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Quick validation (structural + rules only, no network)
|
|
151
|
-
*/
|
|
152
|
-
export function validateQuick(profile: unknown): ValidationReport {
|
|
153
|
-
const issues: ValidationIssue[] = [];
|
|
154
|
-
|
|
155
|
-
// Structural validation
|
|
156
|
-
const structuralIssues = validateStructure(profile);
|
|
157
|
-
issues.push(...structuralIssues);
|
|
158
|
-
|
|
159
|
-
// If structural is OK, run rules validation
|
|
160
|
-
const hasStructuralErrors = structuralIssues.some(i => i.severity === 'error');
|
|
161
|
-
if (!hasStructuralErrors) {
|
|
162
|
-
const rulesIssues = validateRules(profile as UcpProfile);
|
|
163
|
-
issues.push(...rulesIssues);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return buildReport(issues, 'rules', undefined, profile);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Parse and validate JSON string
|
|
171
|
-
*/
|
|
172
|
-
export async function validateJsonString(
|
|
173
|
-
json: string,
|
|
174
|
-
options: ValidationOptions = {}
|
|
175
|
-
): Promise<ValidationReport> {
|
|
176
|
-
try {
|
|
177
|
-
const profile = JSON.parse(json);
|
|
178
|
-
return validateProfile(profile, options);
|
|
179
|
-
} catch (error) {
|
|
180
|
-
const message = error instanceof Error ? error.message : 'Invalid JSON';
|
|
181
|
-
return {
|
|
182
|
-
ok: false,
|
|
183
|
-
issues: [{
|
|
184
|
-
severity: 'error',
|
|
185
|
-
code: 'UCP_MISSING_ROOT' as const,
|
|
186
|
-
path: '$',
|
|
187
|
-
message: `Failed to parse JSON: ${message}`,
|
|
188
|
-
hint: 'Ensure the input is valid JSON',
|
|
189
|
-
}],
|
|
190
|
-
validated_at: new Date().toISOString(),
|
|
191
|
-
validation_mode: options.mode || 'full',
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
}
|