@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.
Files changed (225) hide show
  1. package/AGENTS.md +75 -0
  2. package/CHANGELOG.md +1053 -0
  3. package/LICENSE +21 -0
  4. package/QUICKSTART.md +239 -0
  5. package/README.md +117 -2
  6. package/dist/adapters/express.d.ts +39 -0
  7. package/dist/adapters/express.js +106 -0
  8. package/dist/adapters/hono.d.ts +16 -0
  9. package/dist/adapters/hono.js +15 -0
  10. package/dist/adapters/next.d.ts +29 -0
  11. package/dist/adapters/next.js +38 -0
  12. package/dist/agent-card.d.ts +14 -0
  13. package/dist/agent-card.js +58 -0
  14. package/dist/agent-docs.d.ts +36 -0
  15. package/dist/agent-docs.js +78 -0
  16. package/dist/agent-hooks.d.ts +66 -0
  17. package/dist/agent-hooks.js +280 -0
  18. package/dist/agents.d.ts +24 -0
  19. package/dist/agents.js +120 -0
  20. package/dist/api-key.d.ts +6 -0
  21. package/dist/api-key.js +33 -0
  22. package/dist/cache.d.ts +46 -0
  23. package/dist/cache.js +86 -0
  24. package/dist/cart-tokens.d.ts +31 -0
  25. package/dist/cart-tokens.js +58 -0
  26. package/dist/cart-transfer.d.ts +95 -0
  27. package/dist/cart-transfer.js +387 -0
  28. package/dist/catalog-enrichment.d.ts +6 -0
  29. package/dist/catalog-enrichment.js +71 -0
  30. package/dist/catalog-reads.d.ts +126 -0
  31. package/dist/catalog-reads.js +104 -0
  32. package/dist/catalog.d.ts +78 -0
  33. package/dist/catalog.js +288 -0
  34. package/dist/charge-claims.d.ts +11 -0
  35. package/dist/charge-claims.js +47 -0
  36. package/dist/check.d.ts +44 -0
  37. package/dist/check.js +152 -0
  38. package/dist/checklist-manifest.d.ts +72 -0
  39. package/dist/checklist-manifest.js +341 -0
  40. package/dist/checkout.d.ts +222 -0
  41. package/dist/checkout.js +353 -0
  42. package/dist/cli.d.ts +2 -0
  43. package/dist/cli.js +727 -0
  44. package/dist/confirmation.d.ts +78 -0
  45. package/dist/confirmation.js +124 -0
  46. package/dist/context.d.ts +81 -0
  47. package/dist/context.js +10 -0
  48. package/dist/discovery.d.ts +151 -0
  49. package/dist/discovery.js +346 -0
  50. package/dist/doctor-cart-transfer.d.ts +33 -0
  51. package/dist/doctor-cart-transfer.js +186 -0
  52. package/dist/doctor-catalog.d.ts +8 -0
  53. package/dist/doctor-catalog.js +47 -0
  54. package/dist/doctor-evidence.d.ts +22 -0
  55. package/dist/doctor-evidence.js +57 -0
  56. package/dist/doctor-merchant.d.ts +48 -0
  57. package/dist/doctor-merchant.js +74 -0
  58. package/dist/doctor-source.d.ts +5 -0
  59. package/dist/doctor-source.js +142 -0
  60. package/dist/doctor-variants.d.ts +70 -0
  61. package/dist/doctor-variants.js +102 -0
  62. package/dist/doctor.d.ts +215 -0
  63. package/dist/doctor.js +1689 -0
  64. package/dist/events.d.ts +95 -0
  65. package/dist/events.js +200 -0
  66. package/dist/feed-mapping.d.ts +114 -0
  67. package/dist/feed-mapping.js +152 -0
  68. package/dist/feed-values.d.ts +13 -0
  69. package/dist/feed-values.js +40 -0
  70. package/dist/feeds.d.ts +104 -0
  71. package/dist/feeds.js +366 -0
  72. package/dist/identify.d.ts +102 -0
  73. package/dist/identify.js +124 -0
  74. package/dist/identity.d.ts +37 -0
  75. package/dist/identity.js +54 -0
  76. package/dist/index.d.ts +42 -0
  77. package/dist/index.js +41 -0
  78. package/dist/init.d.ts +157 -0
  79. package/dist/init.js +912 -0
  80. package/dist/kit-config.d.ts +19 -0
  81. package/dist/kit-config.js +43 -0
  82. package/dist/kit-environment.d.ts +20 -0
  83. package/dist/kit-environment.js +32 -0
  84. package/dist/kit-updates.d.ts +47 -0
  85. package/dist/kit-updates.js +77 -0
  86. package/dist/kit-version-project.d.ts +18 -0
  87. package/dist/kit-version-project.js +214 -0
  88. package/dist/kit-version.d.ts +37 -0
  89. package/dist/kit-version.js +162 -0
  90. package/dist/kit.d.ts +516 -0
  91. package/dist/kit.js +1309 -0
  92. package/dist/layers/pages.d.ts +3 -0
  93. package/dist/layers/pages.js +5 -0
  94. package/dist/layers/payments.d.ts +7 -0
  95. package/dist/layers/payments.js +9 -0
  96. package/dist/layers/products.d.ts +10 -0
  97. package/dist/layers/products.js +13 -0
  98. package/dist/live.d.ts +13 -0
  99. package/dist/live.js +52 -0
  100. package/dist/mcp.d.ts +270 -0
  101. package/dist/mcp.js +312 -0
  102. package/dist/next-steps.d.ts +101 -0
  103. package/dist/next-steps.js +257 -0
  104. package/dist/order-pending.d.ts +57 -0
  105. package/dist/order-pending.js +127 -0
  106. package/dist/orders.d.ts +12 -0
  107. package/dist/orders.js +21 -0
  108. package/dist/payments-init.d.ts +19 -0
  109. package/dist/payments-init.js +70 -0
  110. package/dist/payments-routes.d.ts +54 -0
  111. package/dist/payments-routes.js +123 -0
  112. package/dist/payments.d.ts +165 -0
  113. package/dist/payments.js +192 -0
  114. package/dist/pnpm-workspace.d.ts +58 -0
  115. package/dist/pnpm-workspace.js +250 -0
  116. package/dist/policies.d.ts +111 -0
  117. package/dist/policies.js +317 -0
  118. package/dist/preview-hosts.d.ts +64 -0
  119. package/dist/preview-hosts.js +175 -0
  120. package/dist/private-config.d.ts +169 -0
  121. package/dist/private-config.js +820 -0
  122. package/dist/progress.d.ts +54 -0
  123. package/dist/progress.js +153 -0
  124. package/dist/protocol-inputs.d.ts +22 -0
  125. package/dist/protocol-inputs.js +151 -0
  126. package/dist/public-origin.d.ts +50 -0
  127. package/dist/public-origin.js +180 -0
  128. package/dist/refusals.d.ts +86 -0
  129. package/dist/refusals.js +157 -0
  130. package/dist/relay.d.ts +107 -0
  131. package/dist/relay.js +655 -0
  132. package/dist/release-notes.d.ts +2 -0
  133. package/dist/release-notes.js +290 -0
  134. package/dist/relyon-cart-tokens.d.ts +101 -0
  135. package/dist/relyon-cart-tokens.js +521 -0
  136. package/dist/relyon.d.ts +141 -0
  137. package/dist/relyon.js +238 -0
  138. package/dist/robots.d.ts +27 -0
  139. package/dist/robots.js +127 -0
  140. package/dist/rules.d.ts +144 -0
  141. package/dist/rules.js +347 -0
  142. package/dist/sdk/generated/public-api.d.ts +4816 -0
  143. package/dist/sdk/generated/public-api.js +1 -0
  144. package/dist/sdk/index.d.ts +24 -0
  145. package/dist/sdk/index.js +34 -0
  146. package/dist/sdk/signatures.d.ts +17 -0
  147. package/dist/sdk/signatures.js +33 -0
  148. package/dist/setup.d.ts +37 -0
  149. package/dist/setup.js +94 -0
  150. package/dist/signatures.d.ts +112 -0
  151. package/dist/signatures.js +443 -0
  152. package/dist/state.d.ts +185 -0
  153. package/dist/state.js +96 -0
  154. package/dist/store-payments.d.ts +48 -0
  155. package/dist/store-payments.js +143 -0
  156. package/dist/structured-fields.d.ts +26 -0
  157. package/dist/structured-fields.js +200 -0
  158. package/dist/templates.d.ts +19 -0
  159. package/dist/templates.js +193 -0
  160. package/dist/test-checkout-command.d.ts +32 -0
  161. package/dist/test-checkout-command.js +161 -0
  162. package/dist/test-checkout.d.ts +88 -0
  163. package/dist/test-checkout.js +292 -0
  164. package/dist/types.d.ts +103 -0
  165. package/dist/types.js +18 -0
  166. package/dist/ucp-versions.d.ts +57 -0
  167. package/dist/ucp-versions.js +129 -0
  168. package/dist/util.d.ts +23 -0
  169. package/dist/util.js +68 -0
  170. package/dist/variants.d.ts +67 -0
  171. package/dist/variants.js +146 -0
  172. package/dist/version.d.ts +9 -0
  173. package/dist/version.js +10 -0
  174. package/dist/waiting.d.ts +43 -0
  175. package/dist/waiting.js +57 -0
  176. package/dist/webhook-command.d.ts +48 -0
  177. package/dist/webhook-command.js +367 -0
  178. package/dist/webhook-registration.d.ts +47 -0
  179. package/dist/webhook-registration.js +69 -0
  180. package/dist/webmcp-schema.d.ts +14 -0
  181. package/dist/webmcp-schema.js +140 -0
  182. package/dist/webmcp-script.d.ts +3 -0
  183. package/dist/webmcp-script.js +176 -0
  184. package/dist/webmcp-store.d.ts +102 -0
  185. package/dist/webmcp-store.js +116 -0
  186. package/dist/webmcp.d.ts +242 -0
  187. package/dist/webmcp.js +866 -0
  188. package/dist/wire-names.d.ts +85 -0
  189. package/dist/wire-names.js +109 -0
  190. package/package.json +118 -4
  191. package/release-notes.json +290 -0
  192. package/scripts/install-notice.cjs +7 -0
  193. package/skills/relyon-agents/SKILL.md +327 -0
  194. package/skills/relyon-catalog/SKILL.md +499 -0
  195. package/skills/relyon-catalog/references/example-store.md +218 -0
  196. package/skills/relyon-checkout/SKILL.md +603 -0
  197. package/skills/relyon-checkout/references/checkout-flow.md +257 -0
  198. package/skills/relyon-checkout/references/checkout-page.md +315 -0
  199. package/skills/relyon-go-live/SKILL.md +344 -0
  200. package/skills/relyon-orders/SKILL.md +191 -0
  201. package/skills/relyon-orders/references/webhook-receiver.md +113 -0
  202. package/skills/relyon-payments/SKILL.md +117 -0
  203. package/skills/relyon-setup/SKILL.md +1061 -0
  204. package/skills/relyon-setup/references/QUICKSTART.md +239 -0
  205. package/skills/relyon-setup/references/durable-state.md +209 -0
  206. package/skills/relyon-setup/references/express-server.md +388 -0
  207. package/skills/relyon-setup/references/next-app-router.md +251 -0
  208. package/templates/common/STORE-README.md +67 -0
  209. package/templates/common/gitignore +8 -0
  210. package/templates/common/scripts/check-pricing.ts +22 -0
  211. package/templates/common/scripts/serve.mjs +13 -0
  212. package/templates/common/server/catalog.ts +79 -0
  213. package/templates/common/server/checkout-flow.d.ts +34 -0
  214. package/templates/common/server/pages.ts +184 -0
  215. package/templates/common/server/storage.ts +114 -0
  216. package/templates/common/server/store.ts +67 -0
  217. package/templates/express/server/express.ts +20 -0
  218. package/templates/express/tsconfig.build.json +6 -0
  219. package/templates/express/tsconfig.json +9 -0
  220. package/templates/next/app/[[...path]]/route.ts +24 -0
  221. package/templates/next/next.config.mjs +19 -0
  222. package/templates/next/tsconfig.json +12 -0
  223. package/templates/payments/express.ts +39 -0
  224. package/templates/payments/next.ts +38 -0
  225. package/templates/payments/node.ts +39 -0
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Header on the kit's own Test 404 for `/.well-known/relyon-verification` when
3
+ * the address has no Relyon domain: positive evidence, for the doctor, of a
4
+ * Test store on a preview address (an app's fallback 404 never carries it).
5
+ */
6
+ export declare const TEST_PREVIEW_HEADER = "x-relyon-test-preview";
7
+ /** Loopback hostnames the kit accepts in Test (as a URL gives them). */
8
+ export declare const LOOPBACK_HOSTNAMES: readonly ["localhost", "127.0.0.1", "[::1]"];
9
+ /** True for a loopback hostname (`localhost`, `*.localhost`, `127.x.x.x`, `[::1]`). */
10
+ export declare function isLoopbackHostname(hostname: string): boolean;
11
+ /**
12
+ * True for an unspecified ("bind to every interface") address: `0.0.0.0`,
13
+ * `[::]` or the IPv4-mapped `[::ffff:0:0]`, in any spelling a URL parser
14
+ * normalizes to one of them (`0`, `0x0`, `[0:0::0]`...). A server listens
15
+ * on these; no browser or agent can reach a store there, so the kit never
16
+ * treats one as a store hostname, a loopback name or a link origin.
17
+ */
18
+ export declare function isUnspecifiedHostname(hostname: string): boolean;
19
+ /**
20
+ * True for a hostname Relyon accepts as a Test preview address: loopback, or
21
+ * any DNS name with two or more labels that is not an IP literal. The same
22
+ * rule on every platform; decided from the hostname string alone.
23
+ */
24
+ export declare function isPreviewHostname(hostname: string): boolean;
25
+ type Env = Record<string, string | undefined>;
26
+ /**
27
+ * Well-known environment variables some platforms set to the app's own
28
+ * address. Hints only, never a gate: anything not listed here is named with
29
+ * RELYON_PREVIEW_HOSTS (or `store.previewHosts`) instead.
30
+ */
31
+ export declare const PLATFORM_HINTS: ReadonlyArray<(env: Env) => Array<string | undefined>>;
32
+ /**
33
+ * The preview hostnames named for this app: RELYON_PREVIEW_HOSTS (comma
34
+ * separated hostnames or URLs) first, then the platform hints. Lower case,
35
+ * valid DNS names only, no duplicates.
36
+ */
37
+ export declare function previewHostnames(env?: Env): string[];
38
+ /**
39
+ * The hostnames a Test kit answers on: the configured ones first (the first
40
+ * stays the primary one), then `extra` (the `store.previewHosts` list), then
41
+ * the named preview addresses (RELYON_PREVIEW_HOSTS and platform hints), then
42
+ * loopback.
43
+ */
44
+ export declare function testHostnames(configured: readonly string[], env?: Env, extra?: readonly string[]): string[];
45
+ /**
46
+ * True for a hostname that obviously rotates away — a platform preview address
47
+ * (any `replit.dev` subdomain, including Replit's per-deployment preview
48
+ * hosts) or loopback. A webhook endpoint registered for one would keep being
49
+ * called at an address that is gone, so the `webhook` command refuses them and
50
+ * asks for the public origin.
51
+ */
52
+ export declare function isRotatingPreviewHost(hostname: string): boolean;
53
+ /**
54
+ * The hostname the kit asks Relyon's UCP profile for. Relyon's hostname
55
+ * parameter takes dotted names only, so bare `localhost` and `[::1]` ask for
56
+ * the loopback address 127.0.0.1 (the profile's endpoints are then rewritten
57
+ * to the request's own origin).
58
+ */
59
+ export declare function profileHostname(hostname: string): string;
60
+ /** What the go-live steps are, everywhere the kit says them. */
61
+ export declare const GO_LIVE_STEPS: string;
62
+ /** How the kit names a store running in Test on its preview address. */
63
+ export declare const TEST_ON_PREVIEW = "Test on preview address";
64
+ export {};
@@ -0,0 +1,175 @@
1
+ // Test agent checkout on the store's preview address.
2
+ //
3
+ // Relyon accepts a Test key on ANY preview or development address of the
4
+ // store (an https DNS name, or loopback over http with a port) without a
5
+ // verified domain, as the key's own Test store. No platform list decides
6
+ // that: it works the same on any coding platform, host, tunnel or local
7
+ // machine.
8
+ //
9
+ // The kit itself still answers only on hostnames it knows, so a spoofed Host
10
+ // header can't make it speak for an address it was never given. In Test mode
11
+ // it knows:
12
+ // - the configured `store.hostnames` (the first stays the primary one);
13
+ // - `store.previewHosts` when it is a list, and the comma-separated
14
+ // RELYON_PREVIEW_HOSTS setting (hostnames or URLs): the generic way to name
15
+ // a preview address on any platform, a tunnel, or a custom host;
16
+ // - as hints only, the app's own address when its platform says it in a
17
+ // well-known environment variable (see PLATFORM_HINTS); these only save
18
+ // setting RELYON_PREVIEW_HOSTS, they never decide what Relyon accepts;
19
+ // - loopback (`localhost`, `127.0.0.1`, `[::1]`).
20
+ // Live mode never adds any of them: Live keeps its rules
21
+ // (`assertLiveStoreUrls`), and Relyon refuses Live on any unverified host.
22
+ /**
23
+ * Header on the kit's own Test 404 for `/.well-known/relyon-verification` when
24
+ * the address has no Relyon domain: positive evidence, for the doctor, of a
25
+ * Test store on a preview address (an app's fallback 404 never carries it).
26
+ */
27
+ export const TEST_PREVIEW_HEADER = "x-relyon-test-preview";
28
+ /** Loopback hostnames the kit accepts in Test (as a URL gives them). */
29
+ export const LOOPBACK_HOSTNAMES = ["localhost", "127.0.0.1", "[::1]"];
30
+ const LABEL = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
31
+ function validHostname(value) {
32
+ return value.length > 0 && value.length <= 253 && value.split(".").every((label) => LABEL.test(label));
33
+ }
34
+ /** True for a loopback hostname (`localhost`, `*.localhost`, `127.x.x.x`, `[::1]`). */
35
+ export function isLoopbackHostname(hostname) {
36
+ const host = hostname.toLowerCase();
37
+ if (host === "[::1]" || host === "::1")
38
+ return true;
39
+ const parts = host.split(".");
40
+ if (parts.length === 4 && parts[0] === "127" && parts.every((part) => /^(0|[1-9]\d{0,2})$/.test(part) && Number(part) <= 255))
41
+ return true;
42
+ return validHostname(host) && (host === "localhost" || host.endsWith(".localhost"));
43
+ }
44
+ /**
45
+ * True for an unspecified ("bind to every interface") address: `0.0.0.0`,
46
+ * `[::]` or the IPv4-mapped `[::ffff:0:0]`, in any spelling a URL parser
47
+ * normalizes to one of them (`0`, `0x0`, `[0:0::0]`...). A server listens
48
+ * on these; no browser or agent can reach a store there, so the kit never
49
+ * treats one as a store hostname, a loopback name or a link origin.
50
+ */
51
+ export function isUnspecifiedHostname(hostname) {
52
+ let host = hostname.trim().toLowerCase();
53
+ if (host === "::" || host === "::ffff:0:0" || host === "::ffff:0.0.0.0")
54
+ return true;
55
+ try {
56
+ host = new URL(`http://${host}/`).hostname;
57
+ }
58
+ catch {
59
+ return false;
60
+ }
61
+ return host === "0.0.0.0" || host === "[::]" || host === "[::ffff:0:0]";
62
+ }
63
+ /**
64
+ * True for a hostname Relyon accepts as a Test preview address: loopback, or
65
+ * any DNS name with two or more labels that is not an IP literal. The same
66
+ * rule on every platform; decided from the hostname string alone.
67
+ */
68
+ export function isPreviewHostname(hostname) {
69
+ const host = hostname.toLowerCase();
70
+ if (isLoopbackHostname(host))
71
+ return true;
72
+ const labels = host.split(".");
73
+ return validHostname(host) && labels.length >= 2 && !/^\d+$/.test(labels.at(-1));
74
+ }
75
+ function processEnv() {
76
+ return typeof process !== "undefined" && process.env ? process.env : {};
77
+ }
78
+ /** A hostname from a setting that may hold a bare hostname or a URL; null when it is neither. */
79
+ function hostnameOf(value) {
80
+ const raw = value?.trim();
81
+ if (!raw)
82
+ return null;
83
+ let host = raw.toLowerCase();
84
+ if (/^[a-z][a-z0-9+.-]*:\/\//.test(host)) {
85
+ try {
86
+ host = new URL(host).hostname;
87
+ }
88
+ catch {
89
+ return null;
90
+ }
91
+ }
92
+ else {
93
+ host = host.split("/")[0].replace(/:\d+$/, "");
94
+ }
95
+ host = host.replace(/\.$/, "");
96
+ return isPreviewHostname(host) && !isLoopbackHostname(host) ? host : null;
97
+ }
98
+ /**
99
+ * Well-known environment variables some platforms set to the app's own
100
+ * address. Hints only, never a gate: anything not listed here is named with
101
+ * RELYON_PREVIEW_HOSTS (or `store.previewHosts`) instead.
102
+ */
103
+ export const PLATFORM_HINTS = [
104
+ // Replit
105
+ (env) => [env.REPLIT_DEV_DOMAIN, ...(env.REPLIT_DOMAINS ?? "").split(",")],
106
+ // Vercel
107
+ (env) => env.VERCEL ? [env.VERCEL_URL, env.VERCEL_BRANCH_URL, env.VERCEL_PROJECT_PRODUCTION_URL] : [],
108
+ // Netlify
109
+ (env) => env.NETLIFY === "true" ? [env.URL, env.DEPLOY_PRIME_URL, env.DEPLOY_URL] : [],
110
+ // GitHub Codespaces (the forwarded port of the app's server)
111
+ (env) => env.CODESPACES === "true" && env.CODESPACE_NAME && env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN && env.PORT
112
+ ? [`${env.CODESPACE_NAME}-${env.PORT}.${env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}`] : [],
113
+ // Render, Railway
114
+ (env) => [env.RENDER_EXTERNAL_HOSTNAME, env.RAILWAY_PUBLIC_DOMAIN],
115
+ ];
116
+ /**
117
+ * The preview hostnames named for this app: RELYON_PREVIEW_HOSTS (comma
118
+ * separated hostnames or URLs) first, then the platform hints. Lower case,
119
+ * valid DNS names only, no duplicates.
120
+ */
121
+ export function previewHostnames(env = processEnv()) {
122
+ const found = [];
123
+ const add = (value) => {
124
+ const host = hostnameOf(value);
125
+ if (host && !found.includes(host))
126
+ found.push(host);
127
+ };
128
+ for (const value of (env.RELYON_PREVIEW_HOSTS ?? "").split(","))
129
+ add(value);
130
+ for (const hint of PLATFORM_HINTS)
131
+ for (const value of hint(env))
132
+ add(value);
133
+ return found;
134
+ }
135
+ /**
136
+ * The hostnames a Test kit answers on: the configured ones first (the first
137
+ * stays the primary one), then `extra` (the `store.previewHosts` list), then
138
+ * the named preview addresses (RELYON_PREVIEW_HOSTS and platform hints), then
139
+ * loopback.
140
+ */
141
+ export function testHostnames(configured, env = processEnv(), extra = []) {
142
+ const all = [];
143
+ const named = extra.map(hostnameOf).filter((host) => host !== null);
144
+ for (const host of [...configured, ...named, ...previewHostnames(env), ...LOOPBACK_HOSTNAMES]) {
145
+ const lower = host.toLowerCase();
146
+ if (!all.includes(lower))
147
+ all.push(lower);
148
+ }
149
+ return all;
150
+ }
151
+ /**
152
+ * True for a hostname that obviously rotates away — a platform preview address
153
+ * (any `replit.dev` subdomain, including Replit's per-deployment preview
154
+ * hosts) or loopback. A webhook endpoint registered for one would keep being
155
+ * called at an address that is gone, so the `webhook` command refuses them and
156
+ * asks for the public origin.
157
+ */
158
+ export function isRotatingPreviewHost(hostname) {
159
+ const host = hostname.toLowerCase().replace(/\.$/, "");
160
+ return isLoopbackHostname(host) || host === "replit.dev" || host.endsWith(".replit.dev");
161
+ }
162
+ /**
163
+ * The hostname the kit asks Relyon's UCP profile for. Relyon's hostname
164
+ * parameter takes dotted names only, so bare `localhost` and `[::1]` ask for
165
+ * the loopback address 127.0.0.1 (the profile's endpoints are then rewritten
166
+ * to the request's own origin).
167
+ */
168
+ export function profileHostname(hostname) {
169
+ return hostname === "localhost" || hostname === "[::1]" ? "127.0.0.1" : hostname;
170
+ }
171
+ /** What the go-live steps are, everywhere the kit says them. */
172
+ export const GO_LIVE_STEPS = "To take agent checkout live: publish the app on your platform, add its domain in Relyon and verify it, "
173
+ + "then switch to a Live key, only with the merchant's approval.";
174
+ /** How the kit names a store running in Test on its preview address. */
175
+ export const TEST_ON_PREVIEW = "Test on preview address";
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Node server-only configuration. No host secret-manager integration is assumed.
3
+ *
4
+ * Automatic Test setup keeps the sandbox key in an owner-only (0700) private
5
+ * folder outside the project and every git tree: RELYON_PRIVATE_DIR when it is
6
+ * set, else `$XDG_CONFIG_HOME/relyon/<project-id>` (or
7
+ * `~/.config/relyon/<project-id>`). The key file (`sandbox.json`) never holds
8
+ * the claim link: that lives in its own owner-only file (`CLAIM_LINK_FILE`),
9
+ * which agents never need to read. Init also sets RELYON_API_KEY in the
10
+ * project's `.env` (0600, gitignored, never when `.env` is tracked by git).
11
+ */
12
+ export interface PrivateSandbox {
13
+ object: "sandbox";
14
+ id: string;
15
+ livemode: false;
16
+ restrictedKey: string;
17
+ publishableKey: string;
18
+ expiresAt: string;
19
+ }
20
+ /** A provisioning response as POST /v1/sandboxes returns it (with the claim link). */
21
+ export interface ProvisionedSandbox extends PrivateSandbox {
22
+ claimUrl: string;
23
+ }
24
+ /** The key file the runtime reads. */
25
+ export declare const SANDBOX_FILE = "sandbox.json";
26
+ /** A Test key the merchant entered (init --key-from-stdin). */
27
+ export declare const ENTERED_KEY_FILE = "test-key.json";
28
+ /** The private ownership (claim) link, kept apart from the key file. */
29
+ export declare const CLAIM_LINK_FILE = "ownership-link.txt";
30
+ /** A newly provisioned response must be complete and still within its unclaimed lifetime. */
31
+ export declare function validSandbox(value: unknown): value is ProvisionedSandbox;
32
+ /** Fail closed on links, shared permissions, tracked storage, or app descendants. */
33
+ export declare function privateDirectory(dir: string, project: string): Promise<string>;
34
+ /** A short, stable folder name for a project: its name and a hash of its real path. */
35
+ export declare function projectId(realProject: string): string;
36
+ /**
37
+ * The default private folder candidates for a project when RELYON_PRIVATE_DIR
38
+ * is unset, most preferred first: `$XDG_CONFIG_HOME/relyon/<project-id>`, then
39
+ * `$HOME/.config/relyon/<project-id>`. Distinct absolute paths only; empty when
40
+ * the environment names neither.
41
+ */
42
+ export declare function defaultPrivateDirs(project: string, env: NodeJS.ProcessEnv): Promise<string[]>;
43
+ /** The first default candidate (unchanged when only one exists); for callers that report a location. */
44
+ export declare function defaultPrivateDir(project: string, env: NodeJS.ProcessEnv): Promise<string | undefined>;
45
+ /** A private folder that can't be used, with the reason init prints. */
46
+ export interface RefusedPrivateDir {
47
+ path: string;
48
+ reason: string;
49
+ }
50
+ /** Every usable RELYON_API_KEY assignment in a dotenv text, in order (placeholders count as none). */
51
+ export declare function dotenvApiKeys(text: string): string[];
52
+ /** The usable RELYON_API_KEY in a dotenv text, if any (placeholders count as none). */
53
+ export declare function dotenvApiKey(text: string): string | undefined;
54
+ export type EnvFileOutcome = {
55
+ status: "written";
56
+ } | {
57
+ status: "unchanged";
58
+ } | {
59
+ status: "refused";
60
+ reason: string;
61
+ };
62
+ /** The .env variables the kit writes, with the comment each assignment carries. */
63
+ export declare const ENV_FILE_VALUES: {
64
+ readonly RELYON_API_KEY: "# Relyon Test key, set by npx @relyon/store-kit init (never commit this file)";
65
+ readonly RELYON_WEBHOOK_SECRET: "# Relyon webhook signing secret, set by npx @relyon/store-kit webhook (never commit this file)";
66
+ readonly RELYON_WEBHOOK_ENDPOINT_ID: "# Relyon webhook endpoint the signing secret belongs to, set by npx @relyon/store-kit webhook (never commit this file)";
67
+ };
68
+ export type EnvFileValueName = keyof typeof ENV_FILE_VALUES;
69
+ /**
70
+ * Reads one kit-written variable from the project's `.env`: undefined when the
71
+ * file is absent, unreadable or carries no usable assignment. Never throws.
72
+ */
73
+ export declare function readEnvValue(project: string, name: EnvFileValueName): Promise<string | undefined>;
74
+ /**
75
+ * Sets one variable (RELYON_API_KEY, RELYON_WEBHOOK_SECRET or
76
+ * RELYON_WEBHOOK_ENDPOINT_ID) in the project's
77
+ * `.env`: makes sure `.gitignore` (and an existing `.dockerignore`) lists
78
+ * `.env` first, refuses when `.env` is tracked by git (with the reason),
79
+ * keeps every other line, and leaves the file 0600. Never prints or returns
80
+ * the value. With preflight=true, checks storage without changing dotenv or
81
+ * ignore files; callers must still repeat the checks when actually writing.
82
+ */
83
+ export declare function writeEnvValue(project: string, name: EnvFileValueName, value: string, env?: NodeJS.ProcessEnv, preflight?: boolean): Promise<EnvFileOutcome>;
84
+ /** Sets RELYON_API_KEY in the project's `.env`. Never prints or returns the key. */
85
+ export declare function writeEnvKey(project: string, key: string, env?: NodeJS.ProcessEnv): Promise<EnvFileOutcome>;
86
+ /**
87
+ * Import only on the Node server; never import in client modules. Order: a
88
+ * usable RELYON_API_KEY in the environment; the private folder
89
+ * (RELYON_PRIVATE_DIR, else the default one); RELYON_API_KEY in the project's
90
+ * dotenv files (`.env`, `.env.local`, `.env.production`, … in sorted order).
91
+ * A placeholder or malformed value counts as no key. Returns `{}`
92
+ * (the kit waits for a sandbox key) rather than a fabricated credential.
93
+ * With RELYON_LIVE=true only RELYON_API_KEY in the environment is used: no
94
+ * saved Test key is read from the private folder or `.env`.
95
+ * webhookSecret resolves independently: environment first, then the project's
96
+ * dotenv files in the same sorted order. Private storage holds API keys, not
97
+ * webhook secrets; the webhook command saves its signing secret in `.env`.
98
+ */
99
+ export declare function loadTestConfig(options: {
100
+ project: string;
101
+ env?: NodeJS.ProcessEnv;
102
+ }): Promise<{
103
+ apiKey?: string;
104
+ webhookSecret?: string;
105
+ }>;
106
+ export type AutoSetupStatus = "existing" | "created" | "waiting";
107
+ export interface AutoSetupResult {
108
+ status: AutoSetupStatus;
109
+ /** What init did with RELYON_API_KEY in the project's .env (created or saved keys only). */
110
+ envFile?: EnvFileOutcome;
111
+ /** Where the private ownership (claim) link is saved, when there is one. Never the link itself. */
112
+ claimFile?: string;
113
+ /**
114
+ * Why automatic setup couldn't run (no secret, no remote text).
115
+ * "hosted-signup": there is no key to reuse and the kit never creates one —
116
+ * sandbox creation is authenticated and lives on the hosted key page.
117
+ */
118
+ reason?: "live" | "hosted-signup";
119
+ /** The accepted key was already in the project's own `.env` (not the private folder). */
120
+ fromDotenv?: true;
121
+ /** The accepted key came from the environment, not a saved copy. */
122
+ fromEnv?: true;
123
+ /** The project dotenv file holding the key, when one is known. */
124
+ dotenvFile?: string;
125
+ }
126
+ /**
127
+ * The legacy environment variable that once opted an unattended run into
128
+ * automatic Test setup. Init never creates sandboxes anymore (creation is
129
+ * authenticated and lives on the hosted key page), so this is accepted and
130
+ * changes nothing; the name stays exported for scripts that still set it.
131
+ */
132
+ export declare const AUTO_TEST_KEY_ENV = "RELYON_AUTO_TEST_KEY";
133
+ /**
134
+ * Reuses the project's existing Test key (environment, .env, or the private
135
+ * folder) and reports "waiting" when there is none. It never creates a
136
+ * sandbox: creation is authenticated and attaches to the creator's own
137
+ * workspace, so a first-time developer gets the key from the hosted key page
138
+ * and `init --key-from-stdin` (init's GET_KEY_LINES). Never provisions or
139
+ * uses a Live key: RELYON_LIVE=true turns automatic setup off. Never prints
140
+ * anything. The `fetch`/`timeoutMs`/`interactive`/`optIn`/`scratch` options
141
+ * are accepted for call-site compatibility and no longer used.
142
+ */
143
+ export declare function autoTestSetup(options: {
144
+ project: string;
145
+ env?: NodeJS.ProcessEnv;
146
+ fetch?: typeof fetch;
147
+ timeoutMs?: number;
148
+ /** Accepted for call-site compatibility; unused. */
149
+ interactive?: boolean;
150
+ /** Accepted for call-site compatibility (init --auto-test-key); no longer provisions. */
151
+ optIn?: boolean;
152
+ /** Accepted for call-site compatibility (init --template … --dir); unused. */
153
+ scratch?: boolean;
154
+ }): Promise<AutoSetupResult>;
155
+ /** Why a key entered for init can't be saved, without repeating it; null when it is a Test key. */
156
+ export declare function enteredKeyProblem(value: string): string | null;
157
+ /**
158
+ * Saves a Test key the merchant entered (init --key-from-stdin): in the
159
+ * private folder (owner-only) and as RELYON_API_KEY in the project's .env.
160
+ * Never prints or returns the key.
161
+ */
162
+ export declare function saveEnteredTestKey(options: {
163
+ project: string;
164
+ key: string;
165
+ env?: NodeJS.ProcessEnv;
166
+ }): Promise<{
167
+ privateFile?: string;
168
+ envFile: EnvFileOutcome;
169
+ }>;