@relyon/kit 0.0.0-stage → 1.0.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/AGENTS.md +75 -0
- package/CHANGELOG.md +1053 -0
- package/LICENSE +21 -0
- package/QUICKSTART.md +239 -0
- package/README.md +117 -2
- package/dist/adapters/express.d.ts +39 -0
- package/dist/adapters/express.js +106 -0
- package/dist/adapters/hono.d.ts +16 -0
- package/dist/adapters/hono.js +15 -0
- package/dist/adapters/next.d.ts +29 -0
- package/dist/adapters/next.js +38 -0
- package/dist/agent-card.d.ts +14 -0
- package/dist/agent-card.js +58 -0
- package/dist/agent-docs.d.ts +36 -0
- package/dist/agent-docs.js +78 -0
- package/dist/agent-hooks.d.ts +66 -0
- package/dist/agent-hooks.js +280 -0
- package/dist/agents.d.ts +24 -0
- package/dist/agents.js +120 -0
- package/dist/api-key.d.ts +6 -0
- package/dist/api-key.js +33 -0
- package/dist/cache.d.ts +46 -0
- package/dist/cache.js +86 -0
- package/dist/cart-tokens.d.ts +31 -0
- package/dist/cart-tokens.js +58 -0
- package/dist/cart-transfer.d.ts +95 -0
- package/dist/cart-transfer.js +387 -0
- package/dist/catalog-enrichment.d.ts +6 -0
- package/dist/catalog-enrichment.js +71 -0
- package/dist/catalog-reads.d.ts +126 -0
- package/dist/catalog-reads.js +104 -0
- package/dist/catalog.d.ts +78 -0
- package/dist/catalog.js +288 -0
- package/dist/charge-claims.d.ts +11 -0
- package/dist/charge-claims.js +47 -0
- package/dist/check.d.ts +44 -0
- package/dist/check.js +152 -0
- package/dist/checklist-manifest.d.ts +72 -0
- package/dist/checklist-manifest.js +341 -0
- package/dist/checkout.d.ts +222 -0
- package/dist/checkout.js +353 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +727 -0
- package/dist/confirmation.d.ts +78 -0
- package/dist/confirmation.js +124 -0
- package/dist/context.d.ts +81 -0
- package/dist/context.js +10 -0
- package/dist/discovery.d.ts +151 -0
- package/dist/discovery.js +346 -0
- package/dist/doctor-cart-transfer.d.ts +33 -0
- package/dist/doctor-cart-transfer.js +186 -0
- package/dist/doctor-catalog.d.ts +8 -0
- package/dist/doctor-catalog.js +47 -0
- package/dist/doctor-evidence.d.ts +22 -0
- package/dist/doctor-evidence.js +57 -0
- package/dist/doctor-merchant.d.ts +48 -0
- package/dist/doctor-merchant.js +74 -0
- package/dist/doctor-source.d.ts +5 -0
- package/dist/doctor-source.js +142 -0
- package/dist/doctor-variants.d.ts +70 -0
- package/dist/doctor-variants.js +102 -0
- package/dist/doctor.d.ts +215 -0
- package/dist/doctor.js +1689 -0
- package/dist/events.d.ts +95 -0
- package/dist/events.js +200 -0
- package/dist/feed-mapping.d.ts +114 -0
- package/dist/feed-mapping.js +152 -0
- package/dist/feed-values.d.ts +13 -0
- package/dist/feed-values.js +40 -0
- package/dist/feeds.d.ts +104 -0
- package/dist/feeds.js +366 -0
- package/dist/identify.d.ts +102 -0
- package/dist/identify.js +124 -0
- package/dist/identity.d.ts +37 -0
- package/dist/identity.js +54 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +41 -0
- package/dist/init.d.ts +157 -0
- package/dist/init.js +912 -0
- package/dist/kit-config.d.ts +19 -0
- package/dist/kit-config.js +43 -0
- package/dist/kit-environment.d.ts +20 -0
- package/dist/kit-environment.js +32 -0
- package/dist/kit-updates.d.ts +47 -0
- package/dist/kit-updates.js +77 -0
- package/dist/kit-version-project.d.ts +18 -0
- package/dist/kit-version-project.js +214 -0
- package/dist/kit-version.d.ts +37 -0
- package/dist/kit-version.js +162 -0
- package/dist/kit.d.ts +516 -0
- package/dist/kit.js +1309 -0
- package/dist/layers/pages.d.ts +3 -0
- package/dist/layers/pages.js +5 -0
- package/dist/layers/payments.d.ts +7 -0
- package/dist/layers/payments.js +9 -0
- package/dist/layers/products.d.ts +10 -0
- package/dist/layers/products.js +13 -0
- package/dist/live.d.ts +13 -0
- package/dist/live.js +52 -0
- package/dist/mcp.d.ts +270 -0
- package/dist/mcp.js +312 -0
- package/dist/next-steps.d.ts +101 -0
- package/dist/next-steps.js +257 -0
- package/dist/order-pending.d.ts +57 -0
- package/dist/order-pending.js +127 -0
- package/dist/orders.d.ts +12 -0
- package/dist/orders.js +21 -0
- package/dist/payments-init.d.ts +19 -0
- package/dist/payments-init.js +70 -0
- package/dist/payments-routes.d.ts +54 -0
- package/dist/payments-routes.js +123 -0
- package/dist/payments.d.ts +165 -0
- package/dist/payments.js +192 -0
- package/dist/pnpm-workspace.d.ts +58 -0
- package/dist/pnpm-workspace.js +250 -0
- package/dist/policies.d.ts +111 -0
- package/dist/policies.js +317 -0
- package/dist/preview-hosts.d.ts +64 -0
- package/dist/preview-hosts.js +175 -0
- package/dist/private-config.d.ts +169 -0
- package/dist/private-config.js +820 -0
- package/dist/progress.d.ts +54 -0
- package/dist/progress.js +153 -0
- package/dist/protocol-inputs.d.ts +22 -0
- package/dist/protocol-inputs.js +151 -0
- package/dist/public-origin.d.ts +50 -0
- package/dist/public-origin.js +180 -0
- package/dist/refusals.d.ts +86 -0
- package/dist/refusals.js +157 -0
- package/dist/relay.d.ts +107 -0
- package/dist/relay.js +655 -0
- package/dist/release-notes.d.ts +2 -0
- package/dist/release-notes.js +290 -0
- package/dist/relyon-cart-tokens.d.ts +101 -0
- package/dist/relyon-cart-tokens.js +521 -0
- package/dist/relyon.d.ts +141 -0
- package/dist/relyon.js +238 -0
- package/dist/robots.d.ts +27 -0
- package/dist/robots.js +127 -0
- package/dist/rules.d.ts +144 -0
- package/dist/rules.js +347 -0
- package/dist/sdk/generated/public-api.d.ts +4816 -0
- package/dist/sdk/generated/public-api.js +1 -0
- package/dist/sdk/index.d.ts +24 -0
- package/dist/sdk/index.js +34 -0
- package/dist/sdk/signatures.d.ts +17 -0
- package/dist/sdk/signatures.js +33 -0
- package/dist/setup.d.ts +37 -0
- package/dist/setup.js +94 -0
- package/dist/signatures.d.ts +112 -0
- package/dist/signatures.js +443 -0
- package/dist/state.d.ts +185 -0
- package/dist/state.js +96 -0
- package/dist/store-payments.d.ts +48 -0
- package/dist/store-payments.js +143 -0
- package/dist/structured-fields.d.ts +26 -0
- package/dist/structured-fields.js +200 -0
- package/dist/templates.d.ts +19 -0
- package/dist/templates.js +193 -0
- package/dist/test-checkout-command.d.ts +32 -0
- package/dist/test-checkout-command.js +161 -0
- package/dist/test-checkout.d.ts +88 -0
- package/dist/test-checkout.js +292 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.js +18 -0
- package/dist/ucp-versions.d.ts +57 -0
- package/dist/ucp-versions.js +129 -0
- package/dist/util.d.ts +23 -0
- package/dist/util.js +68 -0
- package/dist/variants.d.ts +67 -0
- package/dist/variants.js +146 -0
- package/dist/version.d.ts +9 -0
- package/dist/version.js +10 -0
- package/dist/waiting.d.ts +43 -0
- package/dist/waiting.js +57 -0
- package/dist/webhook-command.d.ts +48 -0
- package/dist/webhook-command.js +367 -0
- package/dist/webhook-registration.d.ts +47 -0
- package/dist/webhook-registration.js +69 -0
- package/dist/webmcp-schema.d.ts +14 -0
- package/dist/webmcp-schema.js +140 -0
- package/dist/webmcp-script.d.ts +3 -0
- package/dist/webmcp-script.js +176 -0
- package/dist/webmcp-store.d.ts +102 -0
- package/dist/webmcp-store.js +116 -0
- package/dist/webmcp.d.ts +242 -0
- package/dist/webmcp.js +866 -0
- package/dist/wire-names.d.ts +85 -0
- package/dist/wire-names.js +109 -0
- package/package.json +118 -4
- package/release-notes.json +290 -0
- package/scripts/install-notice.cjs +7 -0
- package/skills/relyon-agents/SKILL.md +327 -0
- package/skills/relyon-catalog/SKILL.md +499 -0
- package/skills/relyon-catalog/references/example-store.md +218 -0
- package/skills/relyon-checkout/SKILL.md +603 -0
- package/skills/relyon-checkout/references/checkout-flow.md +257 -0
- package/skills/relyon-checkout/references/checkout-page.md +315 -0
- package/skills/relyon-go-live/SKILL.md +344 -0
- package/skills/relyon-orders/SKILL.md +191 -0
- package/skills/relyon-orders/references/webhook-receiver.md +113 -0
- package/skills/relyon-payments/SKILL.md +117 -0
- package/skills/relyon-setup/SKILL.md +1061 -0
- package/skills/relyon-setup/references/QUICKSTART.md +239 -0
- package/skills/relyon-setup/references/durable-state.md +209 -0
- package/skills/relyon-setup/references/express-server.md +388 -0
- package/skills/relyon-setup/references/next-app-router.md +251 -0
- package/templates/common/STORE-README.md +67 -0
- package/templates/common/gitignore +8 -0
- package/templates/common/scripts/check-pricing.ts +22 -0
- package/templates/common/scripts/serve.mjs +13 -0
- package/templates/common/server/catalog.ts +79 -0
- package/templates/common/server/checkout-flow.d.ts +34 -0
- package/templates/common/server/pages.ts +184 -0
- package/templates/common/server/storage.ts +114 -0
- package/templates/common/server/store.ts +67 -0
- package/templates/express/server/express.ts +20 -0
- package/templates/express/tsconfig.build.json +6 -0
- package/templates/express/tsconfig.json +9 -0
- package/templates/next/app/[[...path]]/route.ts +24 -0
- package/templates/next/next.config.mjs +19 -0
- package/templates/next/tsconfig.json +12 -0
- package/templates/payments/express.ts +39 -0
- package/templates/payments/next.ts +38 -0
- package/templates/payments/node.ts +39 -0
package/dist/feeds.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type FeedDiagnostic } from "./feed-mapping.js";
|
|
2
|
+
import { type FeedText } from "./feed-values.js";
|
|
3
|
+
import { type StoreCatalogProduct, type StoreCatalogReads } from "./catalog-reads.js";
|
|
4
|
+
export declare const STORE_FEED_PATHS: {
|
|
5
|
+
readonly openai: "/feeds/openai.jsonl";
|
|
6
|
+
readonly openaiGzip: "/feeds/openai.jsonl.gz";
|
|
7
|
+
readonly google: "/feeds/google.xml";
|
|
8
|
+
readonly microsoft: "/feeds/microsoft.xml";
|
|
9
|
+
};
|
|
10
|
+
export type StoreFeedFormat = keyof typeof STORE_FEED_PATHS;
|
|
11
|
+
/**
|
|
12
|
+
* Why a product (or attribute) was left out of a feed. `missing` names the
|
|
13
|
+
* product facts to add, when that is the reason. A `feed_empty` diagnostic
|
|
14
|
+
* (with an empty `productId`) says a feed has no products at all and lists
|
|
15
|
+
* every missing fact seen.
|
|
16
|
+
*/
|
|
17
|
+
export type StoreFeedDiagnostic = Omit<FeedDiagnostic, "format"> & {
|
|
18
|
+
format: "openai" | "google" | "microsoft";
|
|
19
|
+
missing?: readonly string[];
|
|
20
|
+
};
|
|
21
|
+
export interface StoreFeedOptions {
|
|
22
|
+
/** Explicit opt-in files; routes not selected here are not claimed. */
|
|
23
|
+
formats: readonly StoreFeedFormat[];
|
|
24
|
+
/** Internal cache lifetime, 0–300 seconds. Default 60; no stale-on-error. */
|
|
25
|
+
cacheSeconds?: number;
|
|
26
|
+
/** Optional pure plain-text normalizer. Always followed by XML/control-character filtering. */
|
|
27
|
+
normalizeText?: FeedText;
|
|
28
|
+
onDiagnostic?: (diagnostic: StoreFeedDiagnostic) => void;
|
|
29
|
+
}
|
|
30
|
+
export interface StoreFeedMerchant {
|
|
31
|
+
name: string;
|
|
32
|
+
/**
|
|
33
|
+
* The store's public address, such as `https://shop.example.com/`: https
|
|
34
|
+
* on one of `hostnames`, or plain http on a loopback name (a local Test
|
|
35
|
+
* store). Product and image URLs on the store's own hostnames are moved onto it.
|
|
36
|
+
*/
|
|
37
|
+
url: string;
|
|
38
|
+
hostnames: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
/** What the ChatGPT feed needs to mark products eligible for checkout. */
|
|
41
|
+
export interface StoreFeedChatGpt {
|
|
42
|
+
/** True only when Relyon reports the store's ChatGPT channel `connected` (approved and connected). */
|
|
43
|
+
connected: boolean;
|
|
44
|
+
/** The store's privacy and terms pages (ChatGPT requires both for a checkout-eligible item). */
|
|
45
|
+
privacyUrl?: string;
|
|
46
|
+
termsUrl?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface StoreFeedGeneration {
|
|
49
|
+
openai: string;
|
|
50
|
+
google: string;
|
|
51
|
+
microsoft: string;
|
|
52
|
+
diagnostics: readonly StoreFeedDiagnostic[];
|
|
53
|
+
}
|
|
54
|
+
/** Default seam accepts plain text only; supply a trusted HTML sanitizer if your catalog stores HTML. */
|
|
55
|
+
export declare const feedPlainText: FeedText;
|
|
56
|
+
/** A feed group ID as every feed accepts it: 1–50 letters, digits, ".", "_", ":" or "-". */
|
|
57
|
+
export declare const FEED_GROUP_ID: RegExp;
|
|
58
|
+
/**
|
|
59
|
+
* The feed group ID for a store's variant group ID (usually a product
|
|
60
|
+
* handle). A valid ID is used unchanged. A longer one, or one with other
|
|
61
|
+
* characters, becomes a readable prefix plus a hash of the whole original:
|
|
62
|
+
* the same input always gives the same ID, it fits the 50-character limit,
|
|
63
|
+
* and different inputs don't share one. null for an empty (or blank) ID.
|
|
64
|
+
*/
|
|
65
|
+
export declare function feedGroupId(groupId: string): string | null;
|
|
66
|
+
/**
|
|
67
|
+
* A configurable product's `feed.variants` become one product each: the
|
|
68
|
+
* variant's ID, options and exact price, grouped under the product's ID. The
|
|
69
|
+
* usual row checks then apply to each one. Products without variants are
|
|
70
|
+
* unchanged.
|
|
71
|
+
*/
|
|
72
|
+
export declare function expandFeedVariants(products: readonly StoreCatalogProduct[]): StoreCatalogProduct[];
|
|
73
|
+
/** Flat Stable OpenAI + Google/Microsoft-common RSS using the shared API mapping, never ACP Product/Variant. */
|
|
74
|
+
export declare function generateStoreFeeds(merchant: StoreFeedMerchant, products: readonly StoreCatalogProduct[], options?: Pick<StoreFeedOptions, "normalizeText"> & {
|
|
75
|
+
chatgpt?: StoreFeedChatGpt;
|
|
76
|
+
}): StoreFeedGeneration;
|
|
77
|
+
/**
|
|
78
|
+
* One `feed_empty` diagnostic (empty `productId`) for each feed file with no
|
|
79
|
+
* products, listing every product fact the omitted products are missing, so
|
|
80
|
+
* an empty feed always says why.
|
|
81
|
+
*/
|
|
82
|
+
export declare function emptyFeedDiagnostics(generation: StoreFeedGeneration, productCount: number): StoreFeedDiagnostic[];
|
|
83
|
+
export interface StoreFeedSources {
|
|
84
|
+
/** The ChatGPT channel state and policy pages, read for each generation. */
|
|
85
|
+
chatgpt?: () => Promise<StoreFeedChatGpt>;
|
|
86
|
+
}
|
|
87
|
+
export declare class StoreFeedReads {
|
|
88
|
+
private readonly catalog;
|
|
89
|
+
private readonly merchant;
|
|
90
|
+
private readonly options;
|
|
91
|
+
private readonly now;
|
|
92
|
+
private readonly sources;
|
|
93
|
+
readonly formats: readonly StoreFeedFormat[];
|
|
94
|
+
/** Validator history survives a failed refresh, but its body is never served as a fallback. */
|
|
95
|
+
private readonly origins;
|
|
96
|
+
private readonly ttl;
|
|
97
|
+
constructor(catalog: StoreCatalogReads, merchant: StoreFeedMerchant, options: StoreFeedOptions, now: () => number, sources?: StoreFeedSources);
|
|
98
|
+
format(path: string): StoreFeedFormat | undefined;
|
|
99
|
+
urls(origin: string): string[];
|
|
100
|
+
private state;
|
|
101
|
+
private read;
|
|
102
|
+
/** The feed file, with links on `origin` (the store's public address for this request; default the configured one). */
|
|
103
|
+
response(request: Request, format: StoreFeedFormat, origin?: string, waitingForSandboxKey?: boolean): Promise<Response>;
|
|
104
|
+
}
|
package/dist/feeds.js
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { withWaitingXmlMarker } from "./waiting.js";
|
|
2
|
+
import { gzipSync } from "node:zlib";
|
|
3
|
+
import { mapFeedRows } from "./feed-mapping.js";
|
|
4
|
+
import { publicUrl, validGtin } from "./feed-values.js";
|
|
5
|
+
import { APPAREL_DEFAULTS, STORE_AGE_GROUPS, STORE_GENDERS, isApparelCategory, storeDomainUrl } from "./catalog-reads.js";
|
|
6
|
+
import { isLoopbackHostname } from "./preview-hosts.js";
|
|
7
|
+
import { onPublicOrigin, rebaseStoreUrl } from "./public-origin.js";
|
|
8
|
+
import { sha256 } from "./util.js";
|
|
9
|
+
export const STORE_FEED_PATHS = {
|
|
10
|
+
openai: "/feeds/openai.jsonl",
|
|
11
|
+
openaiGzip: "/feeds/openai.jsonl.gz",
|
|
12
|
+
google: "/feeds/google.xml",
|
|
13
|
+
microsoft: "/feeds/microsoft.xml",
|
|
14
|
+
};
|
|
15
|
+
/** Default seam accepts plain text only; supply a trusted HTML sanitizer if your catalog stores HTML. */
|
|
16
|
+
export const feedPlainText = (value, max) => typeof value === "string"
|
|
17
|
+
? Array.from(value.replace(/[^\u0009\u000a\u000d\u0020-\ud7ff\ue000-\ufffd\u{10000}-\u{10ffff}]/gu, "")).slice(0, max).join("")
|
|
18
|
+
: "";
|
|
19
|
+
const placeholder = /^(?:unknown|null|n\/a|undefined)$/i;
|
|
20
|
+
/** A feed group ID as every feed accepts it: 1–50 letters, digits, ".", "_", ":" or "-". */
|
|
21
|
+
export const FEED_GROUP_ID = /^[A-Za-z0-9._:-]{1,50}$/;
|
|
22
|
+
/**
|
|
23
|
+
* The feed group ID for a store's variant group ID (usually a product
|
|
24
|
+
* handle). A valid ID is used unchanged. A longer one, or one with other
|
|
25
|
+
* characters, becomes a readable prefix plus a hash of the whole original:
|
|
26
|
+
* the same input always gives the same ID, it fits the 50-character limit,
|
|
27
|
+
* and different inputs don't share one. null for an empty (or blank) ID.
|
|
28
|
+
*/
|
|
29
|
+
export function feedGroupId(groupId) {
|
|
30
|
+
if (typeof groupId !== "string" || !groupId.trim())
|
|
31
|
+
return null;
|
|
32
|
+
if (FEED_GROUP_ID.test(groupId))
|
|
33
|
+
return groupId;
|
|
34
|
+
const prefix = groupId.normalize("NFKD").replace(/[^A-Za-z0-9._:-]+/g, "-").replace(/-{2,}/g, "-")
|
|
35
|
+
.replace(/^[-.:]+/, "").slice(0, 37).replace(/[-.:]+$/, "");
|
|
36
|
+
const hash = sha256(groupId).slice(0, 12);
|
|
37
|
+
return prefix ? `${prefix}-${hash}` : `g-${hash}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A configurable product's `feed.variants` become one product each: the
|
|
41
|
+
* variant's ID, options and exact price, grouped under the product's ID. The
|
|
42
|
+
* usual row checks then apply to each one. Products without variants are
|
|
43
|
+
* unchanged.
|
|
44
|
+
*/
|
|
45
|
+
export function expandFeedVariants(products) {
|
|
46
|
+
return products.flatMap((product) => {
|
|
47
|
+
const list = product.feed?.variants;
|
|
48
|
+
if (!Array.isArray(list) || !list.length)
|
|
49
|
+
return [product];
|
|
50
|
+
const { variants: _variants, ...facts } = product.feed;
|
|
51
|
+
return list.map((variant) => ({
|
|
52
|
+
...product,
|
|
53
|
+
merchant_product_id: variant.id,
|
|
54
|
+
configurable: false,
|
|
55
|
+
group_id: product.merchant_product_id,
|
|
56
|
+
...(variant.availability ? { availability: variant.availability } : {}),
|
|
57
|
+
...(variant.gtin ? { gtin: variant.gtin } : {}),
|
|
58
|
+
...(variant.mpn ? { mpn: variant.mpn } : {}),
|
|
59
|
+
feed: { ...facts, exactPrice: variant.exactPrice, variant: { groupId: product.merchant_product_id, options: variant.options } },
|
|
60
|
+
}));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Flat Stable OpenAI + Google/Microsoft-common RSS using the shared API mapping, never ACP Product/Variant. */
|
|
64
|
+
export function generateStoreFeeds(merchant, products, options = {}) {
|
|
65
|
+
const normalize = (value, max) => feedPlainText(options.normalizeText ? options.normalizeText(value, max) : value, max).trim();
|
|
66
|
+
const url = feedStoreUrl(merchant.url, merchant.hostnames), name = normalize(merchant.name, 150);
|
|
67
|
+
if (!url || !name || placeholder.test(name) || /[<>]/.test(name))
|
|
68
|
+
throw new TypeError("Feeds need a real seller name and an HTTPS store-domain URL.");
|
|
69
|
+
const origin = new URL(url).origin;
|
|
70
|
+
const diagnostics = [];
|
|
71
|
+
const omit = (id, code, missing) => {
|
|
72
|
+
for (const format of ["openai", "google", "microsoft"])
|
|
73
|
+
diagnostics.push({ productId: id, format, code, ...(missing?.length ? { missing } : {}) });
|
|
74
|
+
};
|
|
75
|
+
const chatgpt = options.chatgpt;
|
|
76
|
+
const chatgptCheckout = Object.create(null);
|
|
77
|
+
const conditions = Object.create(null);
|
|
78
|
+
const variants = Object.create(null);
|
|
79
|
+
const googleCheckout = Object.create(null);
|
|
80
|
+
const identifiers = Object.create(null);
|
|
81
|
+
const demographics = Object.create(null);
|
|
82
|
+
const exact = [], rows = [];
|
|
83
|
+
const ids = new Set(), combinations = new Set();
|
|
84
|
+
const counts = new Map();
|
|
85
|
+
for (const product of products)
|
|
86
|
+
counts.set(product.merchant_product_id, (counts.get(product.merchant_product_id) ?? 0) + 1);
|
|
87
|
+
const groupKeys = new Map();
|
|
88
|
+
/** Feed group ID → the store's own group ID it came from. */
|
|
89
|
+
const groupSources = new Map();
|
|
90
|
+
for (const original of expandFeedVariants(products).sort((a, b) => a.merchant_product_id < b.merchant_product_id ? -1 : 1)) {
|
|
91
|
+
const id = original.merchant_product_id;
|
|
92
|
+
if (original.agent?.visible !== true)
|
|
93
|
+
continue;
|
|
94
|
+
if (ids.has(id))
|
|
95
|
+
continue;
|
|
96
|
+
ids.add(id);
|
|
97
|
+
if (counts.get(id) > 1) {
|
|
98
|
+
omit(id, "duplicate_product_id");
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (!rebaseStoreUrl(original.url, origin, merchant.hostnames)) {
|
|
102
|
+
omit(id, "invalid_or_off_store_product_url", ["url"]);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
// Page and image links on the store's public address, never a dev or build-time one.
|
|
106
|
+
const product = onPublicOrigin(original, origin, merchant.hostnames);
|
|
107
|
+
const unknownText = ["title", "description", "brand"].filter(field => {
|
|
108
|
+
const text = normalize(product[field], 5000);
|
|
109
|
+
return !text || placeholder.test(text) || /[<>]/.test(text);
|
|
110
|
+
});
|
|
111
|
+
if (unknownText.length) {
|
|
112
|
+
if (chatgpt?.connected === true && unknownText.includes("brand")) {
|
|
113
|
+
diagnostics.push({ productId: id, format: "openai", code: "chatgpt_checkout_ineligible:brand_required" });
|
|
114
|
+
}
|
|
115
|
+
omit(id, "unknown_required_text", unknownText);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const facts = product.feed;
|
|
119
|
+
if (!facts?.exactPrice || product.configurable === true) {
|
|
120
|
+
omit(id, "exact_item_price_required", ["feed.exactPrice"]);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
// Unknown condition must not silently become "new" in the Stable consumer.
|
|
124
|
+
if (!facts.condition || !["new", "used", "refurbished"].includes(facts.condition)) {
|
|
125
|
+
omit(id, "condition_unknown", ["feed.condition"]);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const missingFacts = [
|
|
129
|
+
...(product.images?.some(image => publicUrl(image)) ? [] : ["images"]),
|
|
130
|
+
...(product.availability ? [] : ["availability"]),
|
|
131
|
+
];
|
|
132
|
+
if (missingFacts.length) {
|
|
133
|
+
omit(id, "missing_product_facts", missingFacts);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (product.gtin && !validGtin(product.gtin)) {
|
|
137
|
+
diagnostics.push({ productId: id, format: "openai", code: "invalid_gtin_omitted" });
|
|
138
|
+
}
|
|
139
|
+
if (product.group_id || facts.variant) {
|
|
140
|
+
const variant = facts.variant;
|
|
141
|
+
const entries = Object.entries(variant?.options ?? {}).sort(([a], [b]) => a < b ? -1 : 1);
|
|
142
|
+
const groupId = variant ? feedGroupId(variant.groupId) : null;
|
|
143
|
+
if (!variant || groupId === null || variant.groupId === id || groupId === id
|
|
144
|
+
|| (product.group_id && product.group_id !== variant.groupId) || !entries.length
|
|
145
|
+
|| entries.some(([key, value]) => !key.trim() || typeof value !== "string" || !value.trim()
|
|
146
|
+
|| feedPlainText(key, 70) !== key || feedPlainText(value, 200) !== value
|
|
147
|
+
|| /[<>\r\n]/.test(key + value))) {
|
|
148
|
+
omit(id, "invalid_variant");
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const keys = JSON.stringify(entries.map(([key]) => key));
|
|
152
|
+
const combination = `${groupId}\0${JSON.stringify(entries)}`;
|
|
153
|
+
// Two different store group IDs never share one feed group.
|
|
154
|
+
if (combinations.has(combination) || (groupKeys.has(groupId) && groupKeys.get(groupId) !== keys)
|
|
155
|
+
|| (groupSources.has(groupId) && groupSources.get(groupId) !== variant.groupId)) {
|
|
156
|
+
omit(id, "inconsistent_or_duplicate_variant");
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
combinations.add(combination);
|
|
160
|
+
groupKeys.set(groupId, keys);
|
|
161
|
+
groupSources.set(groupId, variant.groupId);
|
|
162
|
+
variants[id] = { groupId, options: Object.fromEntries(entries) };
|
|
163
|
+
}
|
|
164
|
+
conditions[id] = facts.condition;
|
|
165
|
+
exact.push(id);
|
|
166
|
+
if (facts.googleCheckout && typeof facts.googleCheckout.eligible === "boolean")
|
|
167
|
+
googleCheckout[id] = facts.googleCheckout;
|
|
168
|
+
// Identifier attestations are explicit booleans only; anything else is a conflict, never a guess.
|
|
169
|
+
// Own-brand custom goods (customGoods and ownBrand, no GTIN) are the
|
|
170
|
+
// store's own products with its own part number: brand+MPN, never
|
|
171
|
+
// identifier_exists=false. A GTIN contradicts customGoods.
|
|
172
|
+
const ownBrand = facts.ownBrand, customGoods = facts.customGoods;
|
|
173
|
+
if ((ownBrand !== undefined && typeof ownBrand !== "boolean") || (customGoods !== undefined && typeof customGoods !== "boolean")
|
|
174
|
+
|| (ownBrand === true && customGoods === true && typeof product.gtin === "string" && product.gtin.trim() !== ""))
|
|
175
|
+
identifiers[id] = "conflict";
|
|
176
|
+
else if (ownBrand === true)
|
|
177
|
+
identifiers[id] = "own_brand";
|
|
178
|
+
else if (customGoods === true)
|
|
179
|
+
identifiers[id] = "custom_goods";
|
|
180
|
+
// Age group and gender: explicit valid values for any item; documented
|
|
181
|
+
// defaults (with a diagnostic) only for apparel; invalid values omitted.
|
|
182
|
+
const apparel = isApparelCategory(product.category);
|
|
183
|
+
const resolved = { diagnostics: [] };
|
|
184
|
+
for (const [field, allowed, fallback, label] of [
|
|
185
|
+
["ageGroup", STORE_AGE_GROUPS, APPAREL_DEFAULTS.ageGroup, "age_group"],
|
|
186
|
+
["gender", STORE_GENDERS, APPAREL_DEFAULTS.gender, "gender"],
|
|
187
|
+
]) {
|
|
188
|
+
const value = facts[field];
|
|
189
|
+
if (value === undefined) {
|
|
190
|
+
if (apparel) {
|
|
191
|
+
resolved[field] = fallback;
|
|
192
|
+
resolved.diagnostics.push(`${label}_defaulted`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else if (typeof value === "string" && allowed.includes(value))
|
|
196
|
+
resolved[field] = value;
|
|
197
|
+
else
|
|
198
|
+
resolved.diagnostics.push(`invalid_${label}_omitted`);
|
|
199
|
+
}
|
|
200
|
+
if (resolved.ageGroup || resolved.gender || resolved.diagnostics.length)
|
|
201
|
+
demographics[id] = resolved;
|
|
202
|
+
// ChatGPT checkout: only once Relyon reports the channel connected, and
|
|
203
|
+
// only for an in-stock item agents may buy without asking first.
|
|
204
|
+
if (chatgpt?.connected === true) {
|
|
205
|
+
const agent = product.agent;
|
|
206
|
+
const reason = !chatgpt.privacyUrl || !chatgpt.termsUrl ? "privacy_and_terms_urls_required"
|
|
207
|
+
: product.availability !== "in_stock" ? "not_in_stock"
|
|
208
|
+
: agent?.purchasable === false || agent?.restrictions || (Array.isArray(agent?.must_ask) && agent.must_ask.length) ? "purchase_restricted"
|
|
209
|
+
: !normalize(product.brand, 70) ? "brand_required"
|
|
210
|
+
: !validGtin(product.gtin) && !normalize(product.mpn, 70) ? "gtin_or_mpn_required"
|
|
211
|
+
: undefined;
|
|
212
|
+
if (reason)
|
|
213
|
+
diagnostics.push({ productId: id, format: "openai", code: `chatgpt_checkout_ineligible:${reason}` });
|
|
214
|
+
else
|
|
215
|
+
chatgptCheckout[id] = { privacyUrl: chatgpt.privacyUrl, termsUrl: chatgpt.termsUrl };
|
|
216
|
+
}
|
|
217
|
+
rows.push({
|
|
218
|
+
id, organizationId: "store", environment: "test", status: "published", agentVisible: true,
|
|
219
|
+
document: { ...product, from_price: facts.exactPrice, images: product.images?.filter(image => publicUrl(image)) },
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
const input = { merchantId: "store", organizationId: "store", environment: "test", sellerName: name, storeUrl: url, exactPriceProductIds: exact, conditions };
|
|
223
|
+
const profile = { stable: true, variants, googleCheckout, identifiers, demographics, chatgptCheckout };
|
|
224
|
+
const mapped = mapFeedRows(input, rows, normalize, {}, profile);
|
|
225
|
+
// Microsoft receives the common RSS attributes only, never Google's checkout extensions.
|
|
226
|
+
const microsoft = mapFeedRows(input, rows, normalize, {}, { ...profile, googleCheckout: {}, chatgptCheckout: {}, microsoft: true });
|
|
227
|
+
const all = [...diagnostics,
|
|
228
|
+
...mapped.diagnostics.filter(d => d.format !== "jsonld").map(d => ({ ...d, format: d.format === "acp" ? "openai" : "google" })),
|
|
229
|
+
...microsoft.diagnostics.filter(d => d.format === "google").map(d => ({ ...d, format: "microsoft" })),
|
|
230
|
+
];
|
|
231
|
+
const bodies = { openai: mapped.bodies.acp, google: mapped.bodies.google, microsoft: microsoft.bodies.google };
|
|
232
|
+
return { ...bodies, diagnostics: all };
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* One `feed_empty` diagnostic (empty `productId`) for each feed file with no
|
|
236
|
+
* products, listing every product fact the omitted products are missing, so
|
|
237
|
+
* an empty feed always says why.
|
|
238
|
+
*/
|
|
239
|
+
export function emptyFeedDiagnostics(generation, productCount) {
|
|
240
|
+
const out = [];
|
|
241
|
+
for (const format of ["openai", "google", "microsoft"]) {
|
|
242
|
+
if (format === "openai" ? generation.openai !== "" : generation[format].includes("<item>"))
|
|
243
|
+
continue;
|
|
244
|
+
const missing = [...new Set(generation.diagnostics.filter(d => d.format === format).flatMap(d => d.missing ?? []))].sort();
|
|
245
|
+
out.push({ productId: "", format, code: productCount ? "feed_empty" : "feed_empty_no_products", ...(missing.length ? { missing } : {}) });
|
|
246
|
+
}
|
|
247
|
+
return out;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The feed's store URL: an https store-domain URL (as before), or a plain
|
|
251
|
+
* http(s) loopback origin for a local Test store.
|
|
252
|
+
*/
|
|
253
|
+
function feedStoreUrl(value, hostnames) {
|
|
254
|
+
const domain = storeDomainUrl(value, hostnames);
|
|
255
|
+
if (domain)
|
|
256
|
+
return domain;
|
|
257
|
+
const parsed = publicUrl(value);
|
|
258
|
+
if (!parsed)
|
|
259
|
+
return undefined;
|
|
260
|
+
const url = new URL(parsed);
|
|
261
|
+
if (url.username || url.password || url.search || url.hash || url.pathname !== "/" || !isLoopbackHostname(url.hostname))
|
|
262
|
+
return undefined;
|
|
263
|
+
return url.href;
|
|
264
|
+
}
|
|
265
|
+
/** Feeds are cached per public address; a store answers on only a few. */
|
|
266
|
+
const MAX_ORIGINS = 8;
|
|
267
|
+
export class StoreFeedReads {
|
|
268
|
+
catalog;
|
|
269
|
+
merchant;
|
|
270
|
+
options;
|
|
271
|
+
now;
|
|
272
|
+
sources;
|
|
273
|
+
formats;
|
|
274
|
+
/** Validator history survives a failed refresh, but its body is never served as a fallback. */
|
|
275
|
+
origins = new Map();
|
|
276
|
+
ttl;
|
|
277
|
+
constructor(catalog, merchant, options, now, sources = {}) {
|
|
278
|
+
this.catalog = catalog;
|
|
279
|
+
this.merchant = merchant;
|
|
280
|
+
this.options = options;
|
|
281
|
+
this.now = now;
|
|
282
|
+
this.sources = sources;
|
|
283
|
+
if (!Array.isArray(options.formats) || options.formats.some(format => !Object.hasOwn(STORE_FEED_PATHS, format)))
|
|
284
|
+
throw new TypeError("Unknown store feed format.");
|
|
285
|
+
this.formats = [...new Set(options.formats)];
|
|
286
|
+
const ttl = options.cacheSeconds ?? 60;
|
|
287
|
+
if (!Number.isFinite(ttl) || ttl < 0 || ttl > 300)
|
|
288
|
+
throw new TypeError("feeds.cacheSeconds must be between 0 and 300.");
|
|
289
|
+
this.ttl = ttl * 1000;
|
|
290
|
+
// Fail configuration errors early, even on an empty catalog.
|
|
291
|
+
generateStoreFeeds(merchant, [], options);
|
|
292
|
+
}
|
|
293
|
+
format(path) { return this.formats.find(format => STORE_FEED_PATHS[format] === path); }
|
|
294
|
+
urls(origin) { return this.formats.map(format => `${origin}${STORE_FEED_PATHS[format]}`); }
|
|
295
|
+
state(origin) {
|
|
296
|
+
let state = this.origins.get(origin);
|
|
297
|
+
if (state) {
|
|
298
|
+
this.origins.delete(origin);
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
state = {};
|
|
302
|
+
}
|
|
303
|
+
this.origins.set(origin, state);
|
|
304
|
+
while (this.origins.size > MAX_ORIGINS)
|
|
305
|
+
this.origins.delete(this.origins.keys().next().value);
|
|
306
|
+
return state;
|
|
307
|
+
}
|
|
308
|
+
async read(origin) {
|
|
309
|
+
const base = origin ?? new URL(this.merchant.url).origin;
|
|
310
|
+
const state = this.state(base);
|
|
311
|
+
if (state.snapshot && this.now() < state.snapshot.expires)
|
|
312
|
+
return state.snapshot;
|
|
313
|
+
if (state.loading)
|
|
314
|
+
return state.loading;
|
|
315
|
+
state.loading = (async () => {
|
|
316
|
+
// Invalidate before loading: callback failures never serve a stale hidden product.
|
|
317
|
+
const previous = state.lastSuccessful;
|
|
318
|
+
state.snapshot = undefined;
|
|
319
|
+
const products = await this.catalog.all();
|
|
320
|
+
const chatgpt = this.sources.chatgpt ? await this.sources.chatgpt() : undefined;
|
|
321
|
+
const generation = generateStoreFeeds({ ...this.merchant, url: `${base}/` }, products, { ...this.options, ...(chatgpt ? { chatgpt } : {}) });
|
|
322
|
+
for (const diagnostic of [...generation.diagnostics, ...emptyFeedDiagnostics(generation, products.length)])
|
|
323
|
+
this.options.onDiagnostic?.(diagnostic);
|
|
324
|
+
const modified = new Date(this.now()).toUTCString();
|
|
325
|
+
const sameBody = previous && ["openai", "google", "microsoft"].every(key => generation[key] === previous.generation[key]);
|
|
326
|
+
// HTTP dates have only second precision: a change inside that second must
|
|
327
|
+
// never produce a false 304 for a price or newly hidden product.
|
|
328
|
+
const honorModifiedSince = previous
|
|
329
|
+
? sameBody ? previous.honorModifiedSince : Date.parse(modified) > Date.parse(previous.modified)
|
|
330
|
+
: true;
|
|
331
|
+
const snapshot = { generation, expires: this.now() + this.ttl, modified: sameBody ? previous.modified : modified, honorModifiedSince };
|
|
332
|
+
state.snapshot = snapshot;
|
|
333
|
+
state.lastSuccessful = snapshot;
|
|
334
|
+
return snapshot;
|
|
335
|
+
})().finally(() => { state.loading = undefined; });
|
|
336
|
+
return state.loading;
|
|
337
|
+
}
|
|
338
|
+
/** The feed file, with links on `origin` (the store's public address for this request; default the configured one). */
|
|
339
|
+
async response(request, format, origin, waitingForSandboxKey = false) {
|
|
340
|
+
if (request.method !== "GET" && request.method !== "HEAD")
|
|
341
|
+
return new Response(null, { status: 405, headers: { allow: "GET, HEAD" } });
|
|
342
|
+
const snapshot = await this.read(origin);
|
|
343
|
+
const generated = format === "openaiGzip" ? snapshot.generation.openai : snapshot.generation[format];
|
|
344
|
+
// RSS feeds carry the waiting status as an XML comment; JSON Lines can't, so it rides in the x-relyon-status header.
|
|
345
|
+
const body = format === "google" || format === "microsoft" ? withWaitingXmlMarker(generated, waitingForSandboxKey) : generated;
|
|
346
|
+
const bytes = format === "openaiGzip" ? gzipSync(body) : Buffer.from(body, "utf8");
|
|
347
|
+
const etag = `"${sha256(bytes.toString("base64"))}"`;
|
|
348
|
+
const headers = new Headers({
|
|
349
|
+
"content-type": format === "openaiGzip" ? "application/gzip" : format === "openai" ? "application/x-ndjson; charset=utf-8" : "application/rss+xml; charset=utf-8",
|
|
350
|
+
// Require every downstream read to revalidate; freshness is bounded only by the internal TTL.
|
|
351
|
+
"cache-control": "public, max-age=0, must-revalidate",
|
|
352
|
+
etag, "content-length": String(bytes.length),
|
|
353
|
+
});
|
|
354
|
+
if (snapshot.honorModifiedSince)
|
|
355
|
+
headers.set("last-modified", snapshot.modified);
|
|
356
|
+
const noneMatch = request.headers.get("if-none-match");
|
|
357
|
+
const notModified = noneMatch !== null
|
|
358
|
+
? noneMatch.split(",").some(value => value.trim() === "*" || value.trim().replace(/^W\//, "") === etag)
|
|
359
|
+
: snapshot.honorModifiedSince && request.headers.has("if-modified-since") && Date.parse(request.headers.get("if-modified-since")) >= Date.parse(snapshot.modified);
|
|
360
|
+
if (notModified) {
|
|
361
|
+
headers.delete("content-length");
|
|
362
|
+
return new Response(null, { status: 304, headers });
|
|
363
|
+
}
|
|
364
|
+
return new Response(request.method === "HEAD" ? null : bytes, { headers });
|
|
365
|
+
}
|
|
366
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type AgentClaim } from "./agents.js";
|
|
2
|
+
import type { AgentSignatureVerifier, SignatureMethod, SignatureVerdict } from "./signatures.js";
|
|
3
|
+
import type { AgentName, AgentRuleAgent, AgentRules, PaymentChannel } from "./types.js";
|
|
4
|
+
export type AgentVerification = "verified" | "claimed";
|
|
5
|
+
export interface AgentIdentity {
|
|
6
|
+
/** null for a person's browser. */
|
|
7
|
+
name: AgentName | null;
|
|
8
|
+
/** `verified` only after a good signature from an allowlisted key directory. */
|
|
9
|
+
verification: AgentVerification | null;
|
|
10
|
+
/** True when the request is an agent the store can name or that signs itself: fail-closed applies. */
|
|
11
|
+
identified: boolean;
|
|
12
|
+
method: SignatureMethod | null;
|
|
13
|
+
keyId: string | null;
|
|
14
|
+
directory: string | null;
|
|
15
|
+
claim: AgentClaim;
|
|
16
|
+
signature: SignatureVerdict;
|
|
17
|
+
/**
|
|
18
|
+
* Behaviour hints (headless browser, automation library, store-supplied
|
|
19
|
+
* signals). Recorded as claims only: they never verify an agent, never
|
|
20
|
+
* refuse a request and never turn on fail-closed.
|
|
21
|
+
*/
|
|
22
|
+
hints: string[];
|
|
23
|
+
}
|
|
24
|
+
/** Headless or automation hints in the request. Claims only. */
|
|
25
|
+
export declare function behaviourHints(headers: Headers, extra?: readonly string[]): string[];
|
|
26
|
+
export interface IdentifyOptions {
|
|
27
|
+
/** The store's public hostnames: the candidate `@authority` values. */
|
|
28
|
+
authorities: readonly string[];
|
|
29
|
+
mcpClientName?: string;
|
|
30
|
+
/** Store-supplied behaviour signals (bot-manager scores, say). Claims only. */
|
|
31
|
+
hints?: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
/** Names the agent at a request: verified from a signature when possible, otherwise as it claims. */
|
|
34
|
+
export declare function identifyAgent(request: Request, verifier: AgentSignatureVerifier | null, options: IdentifyOptions): Promise<AgentIdentity>;
|
|
35
|
+
/** The Relyon rule behind a refusal. */
|
|
36
|
+
export interface RelyonRuleRef {
|
|
37
|
+
/** `platform` (Relyon-wide) or `merchant` (this store); `relyon` when the source wasn't stated. */
|
|
38
|
+
source: "platform" | "merchant" | "relyon";
|
|
39
|
+
kind: "blocked_agents" | "paused" | "paused_channels";
|
|
40
|
+
/** The blocked entry that matched. */
|
|
41
|
+
entry?: AgentRuleAgent;
|
|
42
|
+
/** The paused channel. */
|
|
43
|
+
channel?: string;
|
|
44
|
+
/** The rules version the decision used. */
|
|
45
|
+
rulesVersion: string;
|
|
46
|
+
/** A readable name, e.g. `merchant blocked_agents name=perplexity (rules v3)`. */
|
|
47
|
+
label: string;
|
|
48
|
+
}
|
|
49
|
+
export type AgentDecision = {
|
|
50
|
+
outcome: "allow";
|
|
51
|
+
identity: AgentIdentity;
|
|
52
|
+
rulesVersion: string | null;
|
|
53
|
+
} | {
|
|
54
|
+
outcome: "refuse";
|
|
55
|
+
code: "agent_refused" | "channel_paused";
|
|
56
|
+
status: 403;
|
|
57
|
+
rule: RelyonRuleRef;
|
|
58
|
+
message: string;
|
|
59
|
+
identity: AgentIdentity;
|
|
60
|
+
} | {
|
|
61
|
+
outcome: "unavailable";
|
|
62
|
+
code: "service_unavailable";
|
|
63
|
+
status: 503;
|
|
64
|
+
message: string;
|
|
65
|
+
identity: AgentIdentity;
|
|
66
|
+
};
|
|
67
|
+
export interface DecideOptions {
|
|
68
|
+
/** The payment channel when pauses apply (agent protocols and hand-offs). Pauses never apply to `web`. */
|
|
69
|
+
channel?: PaymentChannel | null;
|
|
70
|
+
/** Refuse an identified agent when the rules can't be read. Default true. */
|
|
71
|
+
failClosed?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Allow, refuse by a named Relyon rule, or (fail closed) refuse because the
|
|
75
|
+
* rules can't be read. These are the only outcomes: there is no challenge,
|
|
76
|
+
* score or blanket block. A person's browser is never blocked or failed
|
|
77
|
+
* closed; only a Relyon pause on a handed-off agent checkout (a channel the
|
|
78
|
+
* caller passes) applies to it.
|
|
79
|
+
*/
|
|
80
|
+
export declare function decide(identity: AgentIdentity, rules: AgentRules | null, options?: DecideOptions): AgentDecision;
|
|
81
|
+
/**
|
|
82
|
+
* What a store tells its own bot protection (Cloudflare, a CAPTCHA widget):
|
|
83
|
+
* skip the challenge only for an agent whose signature verified and that
|
|
84
|
+
* Relyon's rules allow. Claimed agents and people go through the store's
|
|
85
|
+
* protection unchanged, so the kit never weakens it for a spoofed user agent
|
|
86
|
+
* and never adds a challenge of its own.
|
|
87
|
+
*/
|
|
88
|
+
export interface VerifiedAgentSignal {
|
|
89
|
+
verified: boolean;
|
|
90
|
+
skipChallenge: boolean;
|
|
91
|
+
name: AgentName | null;
|
|
92
|
+
method: SignatureMethod | null;
|
|
93
|
+
keyId: string | null;
|
|
94
|
+
directory: string | null;
|
|
95
|
+
/** Response headers a store can attach (or pass to a WAF rule). */
|
|
96
|
+
headers: Record<string, string>;
|
|
97
|
+
}
|
|
98
|
+
export declare function verifiedAgentSignal(decision: AgentDecision): VerifiedAgentSignal;
|
|
99
|
+
/** The shopper headers forwarded to Relyon on `createPayment`. Nothing else (no cookies, no authorization). */
|
|
100
|
+
export declare const FORWARDED_SHOPPER_HEADERS: readonly ["user-agent", "signature-agent", "signature-input", "signature", "ucp-agent"];
|
|
101
|
+
/** The allowed shopper headers, as the shopper sent them (trimmed, no line breaks, at most 8 KiB each). */
|
|
102
|
+
export declare function forwardedShopperHeaders(headers: Headers): Record<string, string>;
|