Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5b9e1ceda |
@@ -1,105 +0,0 @@
|
||||
# Runs on every push and pull request: typecheck, lint, unit tests, build.
|
||||
# Gitea Actions uses the GitHub Actions syntax; needs a runner with Docker.
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
# --ignore-scripts: skip `prepare` (the build) here; it runs as its own step.
|
||||
- run: pnpm install --frozen-lockfile --ignore-scripts
|
||||
- run: pnpm typecheck
|
||||
- run: pnpm lint
|
||||
- run: pnpm test:int
|
||||
- run: pnpm build
|
||||
|
||||
# The reference site (reference/, docs/dev/reference-site-proposal.md). Fast part on every push and PR:
|
||||
# install against the freshly built plugin, committed generated files current, typecheck.
|
||||
reference:
|
||||
runs-on: ubuntu-latest
|
||||
needs: check
|
||||
env:
|
||||
PAYLOAD_SECRET: ci-reference-secret-0123456789abcdef
|
||||
DATABASE_URI: mongodb://127.0.0.1:27017/example-studiopl_dev
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile --ignore-scripts
|
||||
- run: pnpm build
|
||||
# file:.. + injected: the site gets a copy of the built plugin with its peers from the site (README.md)
|
||||
- run: pnpm --dir reference install --frozen-lockfile --ignore-workspace
|
||||
- run: pnpm --dir reference exec iapl-tokens --check
|
||||
- run: pnpm --dir reference generate:importmap && git diff --exit-code reference/src/app
|
||||
- run: pnpm --dir reference generate:types && git diff --exit-code reference/src/payload-types.ts
|
||||
- run: pnpm --dir reference typecheck
|
||||
# iapl-doctor (static, docs/doctor.md): the reference site is the zero-findings example — any unsilenced finding fails
|
||||
- run: node bin/iapl-doctor.mjs reference --strict --offline
|
||||
|
||||
# Full run on main (and before a release): MongoDB, seed, production build, smoke tests.
|
||||
reference-full:
|
||||
if: github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
needs: reference
|
||||
services:
|
||||
mongo:
|
||||
image: mongo:7
|
||||
ports: ['27017:27017']
|
||||
env:
|
||||
CI: '1'
|
||||
DATABASE_URI: mongodb://127.0.0.1:27017/example-studiopl_dev
|
||||
PAYLOAD_SECRET: ci-reference-secret-0123456789abcdef
|
||||
NEXT_PUBLIC_SERVER_URL: http://localhost:3100
|
||||
IAPL_IP_HEADER: x-forwarded-for
|
||||
# cookieScanner.crawl → iaplEnvRules({ cookieCrawl }) requires both in production; CI never starts a crawl
|
||||
IAPL_COOKIE_SCAN_URL: http://127.0.0.1:9/crawl
|
||||
IAPL_COOKIE_SCAN_TOKEN: ci-cookie-scan-token-0123456789
|
||||
NEXT_PUBLIC_TURNSTILE_SITE_KEY: 1x00000000000000000000AA
|
||||
TURNSTILE_SECRET_KEY: 1x0000000000000000000000000000000AA
|
||||
ALLOW_LOCAL_MEDIA: '1'
|
||||
E2E_BASE_URL: http://localhost:3100
|
||||
E2E_ADMIN_EMAIL: [email protected]
|
||||
E2E_ADMIN_PASSWORD: ci-e2e-password-not-secret
|
||||
E2E_TOTP_SECRET: JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile --ignore-scripts
|
||||
- run: pnpm build
|
||||
- run: pnpm --dir reference install --frozen-lockfile --ignore-workspace
|
||||
- run: pnpm --dir reference seed
|
||||
# the documented production seed path (Coolify Terminal): one named record, dry run
|
||||
- run: SEED_ONLY="pages:kontakt" SEED_DRY_RUN=1 pnpm --dir reference seed
|
||||
- run: pnpm --dir reference payload run e2e/create-test-admin.ts
|
||||
- run: pnpm --dir reference build
|
||||
- run: pnpm --dir reference exec playwright install --with-deps chromium
|
||||
- run: pnpm --dir reference test:e2e
|
||||
# iapl-doctor (deep + HTTP): read-only database counts, the import map, the env rules, and the running site
|
||||
- run: |
|
||||
PORT=3100 pnpm --dir reference start &
|
||||
for i in $(seq 1 60); do curl -sf http://localhost:3100/api/health >/dev/null && break; sleep 2; done
|
||||
node bin/iapl-doctor.mjs reference --strict --offline --deep --url http://localhost:3100
|
||||
+5
-7
@@ -50,11 +50,9 @@ next-env.d.ts
|
||||
# local db & build artifacts
|
||||
*.db
|
||||
*.tgz
|
||||
0
|
||||
|
||||
# build output — produced by `pnpm build` (prepare/prepublishOnly), not committed
|
||||
/dist
|
||||
|
||||
# pnpm starter:gate work folder
|
||||
.starter-gate/
|
||||
.legacy-site-*/
|
||||
.tmp-consent-upgrade-*
|
||||
# local db & build artifacts
|
||||
*.db
|
||||
*.tgz
|
||||
0
|
||||
|
||||
@@ -2,20 +2,3 @@
|
||||
|
||||
This project uses the Payload CMS skill at `.claude/skills/payload/`.
|
||||
Start with `.claude/skills/payload/SKILL.md` for a quick reference, then see `.claude/skills/payload/reference/` for detailed docs.
|
||||
|
||||
## Main rule: the plugin helps projects, never limits them
|
||||
|
||||
IAPL (Intecion Advanced Payload Library, package `@intecion/ipal-kit`, formerly ipal-kit) is a plugin. Every change must leave the consuming project free to adapt it.
|
||||
|
||||
- Every module and feature can be turned off on its own. Turning one off never takes away anything the project still needs.
|
||||
- Every default can be overridden: access rules, fields, hooks, labels, routes, collections and globals. The project's own config is merged with the plugin's and wins.
|
||||
- Secure defaults are welcome. They come with an option to loosen or extend them, never as a hard lock.
|
||||
- Export the building blocks (helpers, builders, hooks), not only finished features.
|
||||
- Never force a dependency, route, UI or data shape where an option or an exported piece would do.
|
||||
|
||||
## Rule: an agent that adds the plugin gets the complete guide
|
||||
|
||||
When an agent adds IAPL to a project, `docs/agent/AGENT.md` and the `iapl-*` skills (installed by `iapl-skills`) must tell it how to set up and use every function the plugin supports.
|
||||
|
||||
- Every export, option, env var, route, middleware, layout component, admin import-map entry and hook a project must wire is documented, with steps and a way to verify it.
|
||||
- A change that adds or alters a feature updates the agent guide and the matching skill in the same change.
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
# IAPL (`@intecion/ipal-kit`)
|
||||
# @intecion/ipal-kit
|
||||
|
||||
IAPL, the Intecion Advanced Payload Library — a plugin for Payload CMS 3. It was called ipal-kit before 1.17.0;
|
||||
the package name, `@intecion/ipal-kit`, is unchanged, and every older name keeps working
|
||||
([names table](./docs/agent/AGENT.md#names-iapl-and-ipal-kit)).
|
||||
Intecion Payload Advanced Library — a plugin for Payload CMS 3.
|
||||
|
||||
Provides internationalization (per-locale routing, hreflang, language switcher),
|
||||
SEO (metadata, canonical, sitemap, robots), forms (Turnstile, rate limiting,
|
||||
validation), consent management (consent mode), analytics (GA4/GTM), and a
|
||||
blog/archive system (collections under an archive page, listing, pagination).
|
||||
|
||||
**Principle:** IAPL helps projects, never limits them — every module can be
|
||||
turned off on its own, every default (access, fields, hooks, labels, routes,
|
||||
collections, globals) can be overridden and the project's config wins, and the
|
||||
building blocks are exported, not only the finished features. Where the code
|
||||
doesn't meet this yet, the module's doc says so.
|
||||
|
||||
**Repository:** https://git.intecion.net/IntecionSoftware/ipal-kit
|
||||
|
||||
---
|
||||
@@ -52,7 +44,7 @@ You *can* install straight from the repo
|
||||
quick throwaway test it works. But prefer the registry for real projects:
|
||||
|
||||
- **Client components resolve correctly.** A git install unpacks into a
|
||||
commit-hashed path (`.pnpm/@intecion+IAPL@git+https…#hash/…`) that breaks
|
||||
commit-hashed path (`.pnpm/@intecion+ipal-kit@git+https…#hash/…`) that breaks
|
||||
Next.js's React Client Manifest — the consent banner, analytics, and Turnstile
|
||||
components fail at runtime with "Could not find the module … in the React
|
||||
Client Manifest". The registry unpacks to a clean `node_modules/@intecion/…`
|
||||
@@ -63,80 +55,23 @@ quick throwaway test it works. But prefer the registry for real projects:
|
||||
Keep the git install only for pulling a specific unreleased commit during
|
||||
plugin development.
|
||||
|
||||
### A new site in one command
|
||||
|
||||
```bash
|
||||
pnpm --config.auto-install-peers=false dlx @intecion/ipal-kit@<version> create intecion.com
|
||||
```
|
||||
|
||||
Asks the architecture questions (or reads `--answers answers.json`), generates the site from the reference
|
||||
site with every team convention, installs it from a shipped lockfile and makes the first commit. Needs the
|
||||
`@intecion` registry line in `~/.npmrc`. Details: [docs/project-starter.md](./docs/project-starter.md).
|
||||
|
||||
---
|
||||
|
||||
## Finish setting up your project
|
||||
|
||||
`nodemailer`, `lucide-react`, `slugify` and `server-only` are regular
|
||||
`dependencies` of the plugin — they install with it; don't add them yourself.
|
||||
The plugin's `nodemailer` 10 needs **Node.js 20 or later**; Payload 3.94 itself needs **Node.js 22.23.5 or later**
|
||||
on the 22 line.
|
||||
|
||||
What you provide are the **peer dependencies** — packages the plugin shares with
|
||||
your project — in a version matching your Payload. The plugin accepts Payload `^3.90.2`; the reference site and the starter use
|
||||
**3.94.1** (with `react` / `react-dom` 19.3.1, which Payload 3.94 requires):
|
||||
|
||||
| Peer | Range | Notes |
|
||||
|---|---|---|
|
||||
| `payload`, `@payloadcms/next`, `@payloadcms/ui`, `@payloadcms/richtext-lexical` | `^3.90.2` | already in a `create-payload-app` project |
|
||||
| `next`, `react` | `>=15`, `^19.0.0` | already in a `create-payload-app` project |
|
||||
| `@payloadcms/plugin-seo`, `@payloadcms/plugin-form-builder` | `^3.90.2` | **add these** |
|
||||
| `@clocklimited/payload-2fa` | `^3.0.0-0` | optional peer, but **needed by default**: 2FA is enforced and `iapl()` throws at startup unless you pass `twoFactor: { issuer, plugin: payloadTotp }` (or opt out with `twoFactor: false`) |
|
||||
| `@payloadcms/storage-s3` | `^3.90.2` | optional — only when media go to Cloudflare R2 ([docs/storage.md](./docs/storage.md)) |
|
||||
The plugin doesn't pull in the dependencies it shares with Payload — add them
|
||||
yourself, in a version matching your Payload:
|
||||
|
||||
```bash
|
||||
pnpm add @payloadcms/plugin-seo@3.94.1 @payloadcms/plugin-form-builder@3.94.1 \
|
||||
@clocklimited/payload-2fa
|
||||
pnpm add @payloadcms/[email protected] # only with R2 media
|
||||
pnpm add @payloadcms/plugin-seo@3.84.1 @payloadcms/plugin-form-builder@3.84.1 \
|
||||
nodemailer lucide-react slugify server-only
|
||||
```
|
||||
|
||||
Keep every `@payloadcms/*` at exactly the same version as `payload`
|
||||
(`pnpm.overrides` — see PROGRAMISTA.md §1). Then run `pnpm audit --prod`: even
|
||||
Payload 3.94.1 brings a vulnerable `happy-dom` (via Lexical) and `dompurify` — add
|
||||
the two overrides from [AGENT.md §4 item 12](./docs/agent/AGENT.md); an older Payload
|
||||
also needs the `mongoose` (MongoDB adapter, up to 3.93) and `undici` (up to 3.91)
|
||||
ones listed there (recommended, not required by the plugin). Upload optimization and image
|
||||
placeholders also use the `sharp` you pass to `buildConfig({ sharp })`
|
||||
(standard in a `create-payload-app` project).
|
||||
> **Match `lucide-react` to the plugin.** The plugin uses `lucide-react@^0.400.0`.
|
||||
> If your project pulls a different major (e.g. `1.x`), you end up with two copies
|
||||
> and confusing type errors. Pin your project to the same range.
|
||||
|
||||
> **`lucide-react` comes with the plugin, at `^0.400.0`.** For a `0.x` version
|
||||
> the caret means **`0.400.x` only** — not "0.400 or newer". If your project also
|
||||
> uses `lucide-react` at another version (e.g. `0.5xx` or `1.x`), you end up with two
|
||||
> copies and confusing type errors. Pin your project to `~0.400.0` too.
|
||||
|
||||
**Working with an AI agent?** Run this right after installing (and after every upgrade):
|
||||
|
||||
```bash
|
||||
pnpm exec iapl-skills
|
||||
```
|
||||
|
||||
It copies the `iapl-*` agent skills into `.agents/skills/` and adds a marked
|
||||
`<!-- iapl:start -->` block to `AGENTS.md` (plus a `CLAUDE.md` that imports it, if you
|
||||
have none) pointing the agent at the full guide: `AGENT.md`, the `iapl-reference` skill
|
||||
(every option, env var, route and export) and the `iapl-setup` skill. Only the text between
|
||||
the markers is ever rewritten. `--no-pointer` skips that step. There is no `postinstall` script.
|
||||
|
||||
`pnpm exec iapl-skills --external` also adds a few well-known third-party skills as `ext-*` folders — Vercel's
|
||||
React best practices and composition patterns, Addy Osmani's accessibility skill, Anthropic's frontend-design
|
||||
skill and the official Payload 3 skill. They are vendored into the package at pinned commits (text only, each
|
||||
with its licence and source), so nothing is downloaded, and each starts with a note that IAPL's rules win.
|
||||
Pick some with `--external ext-accessibility,ext-payload`.
|
||||
|
||||
*Updating the pins (plugin maintainers):* change the commit in `scripts/vendor-external-skills.mjs`, run
|
||||
`node scripts/vendor-external-skills.mjs`, review `git diff docs/agent/external`, and run
|
||||
`pnpm vitest run test/externalSkills.test.ts`.
|
||||
|
||||
From here, the guide takes over: **[docs/dev/PROGRAMISTA.md](./docs/dev/PROGRAMISTA.md)** —
|
||||
From here, the guide takes over: **[docs/getting-started.md](./docs/getting-started.md)** —
|
||||
from an empty project to a working site.
|
||||
|
||||
---
|
||||
@@ -161,20 +96,15 @@ scope `write:package`. Put it in the `GITEA_TOKEN` env var.
|
||||
| Linux / Ubuntu | `~/.npmrc` |
|
||||
| Windows | `%USERPROFILE%\.npmrc` |
|
||||
|
||||
Then version and publish (commit your changes first — `npm version` needs a
|
||||
clean working tree):
|
||||
Then build and publish:
|
||||
|
||||
```bash
|
||||
npm version patch # 1.0.0 → 1.0.1 (commit + tag)
|
||||
npm publish # prepublishOnly runs: pnpm clean && pnpm build && pnpm build:starter && pnpm test:int && pnpm starter:gate
|
||||
git push && git push --tags
|
||||
pnpm clean && pnpm build
|
||||
npm version patch # 1.0.0 → 1.0.1
|
||||
npm publish
|
||||
```
|
||||
|
||||
`publishConfig.registry` in `package.json` already points at the Gitea registry,
|
||||
so `npm publish` needs no `--registry` flag. A failing build or test aborts the
|
||||
publish.
|
||||
|
||||
Full checklist and troubleshooting: **[docs/dev/PROGRAMISTA.md §8](./docs/dev/PROGRAMISTA.md)**.
|
||||
Full checklist and troubleshooting: **[docs/publishing.md](./docs/publishing.md)**.
|
||||
|
||||
---
|
||||
|
||||
@@ -182,10 +112,9 @@ Full checklist and troubleshooting: **[docs/dev/PROGRAMISTA.md §8](./docs/dev/P
|
||||
|
||||
Everything lives in the **[docs/](./docs)** directory. To get started:
|
||||
|
||||
- **[AGENT.md](./docs/agent/AGENT.md)** — rules for AI agents
|
||||
- **[PROGRAMISTA.md](./docs/dev/PROGRAMISTA.md)** — setup, deployment, upgrades, releasing
|
||||
- **[getting-started.md](./docs/getting-started.md)** — project setup, step by step
|
||||
- **[publishing.md](./docs/publishing.md)** — releasing new plugin versions
|
||||
- **[README.md](./docs/README.md)** — index of the plugin's modules
|
||||
- **[CHANGELOG.md](./docs/CHANGELOG.md)** — what changed per version and what projects must update
|
||||
|
||||
---
|
||||
|
||||
@@ -195,9 +124,8 @@ Everything lives in the **[docs/](./docs)** directory. To get started:
|
||||
|---|---|
|
||||
| `404` on `pnpm add @intecion/...` | the `@intecion:registry` line is missing from `.npmrc` — the install went to public npm instead of Gitea |
|
||||
| `Could not find the module … in the React Client Manifest` | installed from git, not the registry — reinstall from the registry (clean path) |
|
||||
| two versions of `lucide-react` | your project uses a `lucide-react` outside the plugin's `^0.400.0` (= `0.400.x`) — align them |
|
||||
| `[iapl] 2FA is enforced but no 2FA plugin was injected` | install `@clocklimited/payload-2fa` and pass `twoFactor: { issuer, plugin: payloadTotp }` |
|
||||
| two versions of `lucide-react` | your project pins a different major than the plugin's `^0.400.0` — align them |
|
||||
| `missing secret key … to secure Payload` | `PAYLOAD_SECRET` isn't set in the runtime environment (not a plugin issue) |
|
||||
|
||||
If you get stuck, see **[docs/dev/PROGRAMISTA.md](./docs/dev/PROGRAMISTA.md)** or message the
|
||||
If you get stuck, see **[docs/publishing.md](./docs/publishing.md)** or message the
|
||||
team that maintains the plugin.
|
||||
@@ -1,102 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// iapl-blocks — the block library's command line.
|
||||
// pnpm exec iapl-blocks list → the library blocks
|
||||
// pnpm exec iapl-blocks eject faq → src/blocks/Faq/{config.ts,Component.tsx}
|
||||
// pnpm exec iapl-blocks eject faq --dest src/blocks --dry-run
|
||||
// Eject copies one block's source into the project, with its imports pointing at the
|
||||
// package entries, so the project owns it: same slug and data shape, no migration.
|
||||
// Then: use the ejected builder in Pages.layout instead of the library one, pass the ejected
|
||||
// component as createBlockRegistry({ components: { faq: FaqBlock } }), record it in AGENTS.md.
|
||||
|
||||
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
|
||||
import { dirname, join, relative, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const args = process.argv.slice(2)
|
||||
const [command, slug] = args
|
||||
const dryRun = args.includes('--dry-run')
|
||||
const destArg = args.indexOf('--dest')
|
||||
const dest = resolve(process.cwd(), destArg >= 0 ? args[destArg + 1] : 'src/blocks')
|
||||
|
||||
const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
||||
const libRoot = join(pkgRoot, 'src/modules/block-library')
|
||||
const blocksRoot = join(libRoot, 'blocks')
|
||||
|
||||
if (!command || command === '--help' || command === '-h') {
|
||||
console.log('Usage: iapl-blocks list | iapl-blocks eject <block> [--dest src/blocks] [--dry-run]')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const slugs = existsSync(blocksRoot) ? readdirSync(blocksRoot).sort() : []
|
||||
|
||||
if (command === 'list') {
|
||||
console.log(slugs.join('\n'))
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
if (command !== 'eject' || !slug) {
|
||||
console.error('Usage: iapl-blocks eject <block>')
|
||||
process.exit(1)
|
||||
}
|
||||
if (!slugs.includes(slug)) {
|
||||
console.error(`Unknown block "${slug}". Blocks: ${slugs.join(', ')}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Where an import inside the library goes in a project, by the file it points at.
|
||||
* Config files (no React) take the Payload-side entries; components take /rsc and /client.
|
||||
*/
|
||||
const ROOT = '@intecion/ipal-kit'
|
||||
const BLOCKS = '@intecion/ipal-kit/blocks'
|
||||
const RSC = '@intecion/ipal-kit/blocks/rsc'
|
||||
function target(file, isComponent) {
|
||||
const rel = relative(join(pkgRoot, 'src/modules'), file).replace(/\\/g, '/').replace(/\.js$/, '')
|
||||
if (rel.startsWith('block-library/')) {
|
||||
const inner = rel.slice('block-library/'.length)
|
||||
if (/^(define|fields|options|shared|types|faq|library|manifest|thumbnails)$/.test(inner)) {return BLOCKS}
|
||||
return RSC // context, data, texts, ui/*
|
||||
}
|
||||
if (rel === 'lightbox/LightboxProvider' || rel === 'richtext/TableOfContents') {return '@intecion/ipal-kit/client'}
|
||||
if (rel === 'forms/RenderForm' || rel === 'richtext/RenderRichText') {return '@intecion/ipal-kit/rsc'}
|
||||
if (rel === 'richtext/headings') {return isComponent ? '@intecion/ipal-kit/rsc' : ROOT}
|
||||
return ROOT
|
||||
}
|
||||
|
||||
/** Rewrites relative imports to package entries and merges imports of the same entry. */
|
||||
function rewrite(source, file) {
|
||||
const isComponent = file.endsWith('.tsx')
|
||||
const merged = new Map()
|
||||
const body = source.replace(/^import (type )?\{([^}]*)\} from '(\.[^']+)'\n/gm, (_, type, names, spec) => {
|
||||
const entry = target(resolve(dirname(file), spec), isComponent)
|
||||
const key = `${type ? 'type ' : ''}${entry}`
|
||||
const set = merged.get(key) ?? new Set()
|
||||
for (const n of names.split(',').map((s) => s.trim()).filter(Boolean)) {set.add(n)}
|
||||
merged.set(key, set)
|
||||
return ''
|
||||
})
|
||||
const lines = [...merged].map(([key, set]) => {
|
||||
const [type, entry] = key.startsWith('type ') ? ['type ', key.slice(5)] : ['', key]
|
||||
return `import ${type}{ ${[...set].sort().join(', ')} } from '${entry}'`
|
||||
})
|
||||
return body.replace(/^((?:import [^\n]*\n)*)/, (head) => `${head}${lines.join('\n')}\n`).replace(/\n{3,}/g, '\n\n')
|
||||
}
|
||||
|
||||
const folder = slug[0].toUpperCase() + slug.slice(1)
|
||||
const outDir = join(dest, folder)
|
||||
const files = readdirSync(join(blocksRoot, slug)).filter((f) => /\.(ts|tsx)$/.test(f))
|
||||
for (const name of files) {
|
||||
const from = join(blocksRoot, slug, name)
|
||||
const to = join(outDir, name)
|
||||
if (existsSync(to)) {
|
||||
console.error(`skip ${relative(process.cwd(), to)} (exists — delete it first to eject again)`)
|
||||
continue
|
||||
}
|
||||
const out = `// Ejected from @intecion/ipal-kit (block library: ${slug}). The project owns this file now.\n${rewrite(readFileSync(from, 'utf8'), from)}`
|
||||
console.log(`${dryRun ? 'would write' : 'write'} ${relative(process.cwd(), to)}`)
|
||||
if (!dryRun) {
|
||||
mkdirSync(outDir, { recursive: true })
|
||||
writeFileSync(to, out)
|
||||
}
|
||||
}
|
||||
console.log(`\nNext: Pages.layout → the ejected build${folder}Block; registry → components: { ${slug}: ${folder}Block }; AGENTS.md → "Project decisions".`)
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// iapl-doctor — checks a site against the IAPL team rules and lists every gap with a fix hint
|
||||
// (docs/doctor.md). Static by default: reads files, writes nothing (except a first-seen date in
|
||||
// iapl-doctor.json outside CI).
|
||||
// pnpm exec iapl-doctor → this project, human-readable
|
||||
// pnpm exec iapl-doctor --strict --offline → CI on a new site: any finding fails
|
||||
// pnpm exec iapl-doctor --deep --url http://localhost:3000
|
||||
// pnpm exec iapl-doctor --json > doctor.json
|
||||
// pnpm dlx --package=@intecion/ipal-kit@latest iapl-doctor → the newest rules
|
||||
// Exit: 0 ok · 1 findings · 2 could not run · 3 a rule crashed.
|
||||
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
|
||||
const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..')
|
||||
const { runDoctorCli } = await import(pathToFileURL(join(pkgRoot, 'dist', 'modules', 'doctor', 'cli.js')).href)
|
||||
process.exit(await runDoctorCli(process.argv.slice(2), { packageRoot: pkgRoot }))
|
||||
@@ -1,211 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// iapl-skills — copies the IAPL agent skills into the project.
|
||||
// pnpm exec iapl-skills → ./.agents/skills/iapl-*
|
||||
// pnpm exec iapl-skills --dry-run → show what would change
|
||||
// pnpm exec iapl-skills --dest .claude/skills
|
||||
// pnpm exec iapl-skills --no-pointer → skills only, leave AGENTS.md / CLAUDE.md alone
|
||||
// pnpm exec iapl-skills --external → also the vendored third-party skills (ext-*, pinned, text only)
|
||||
// pnpm exec iapl-skills --external ext-accessibility,ext-payload → only those
|
||||
// Only folders named iapl-* are touched; the project's own skills stay as they are.
|
||||
// iapl-* folders that no longer exist in the package are removed (renamed/retired skills).
|
||||
// Before 1.17.0 the skills were named ipal-*: the 16 folders of that set are removed by their
|
||||
// exact names (LEGACY_SKILLS) — any other ipal-<something> folder is the project's own and stays.
|
||||
// `ipal-skills` is the same command under its old name.
|
||||
// ext-* folders are touched only with --external, and only those carrying IAPL's SOURCE.md.
|
||||
// AGENTS.md (and CLAUDE.md) get a marked IAPL block pointing at the guide — only the
|
||||
// text between the markers is ever rewritten; the project's own content stays as it is.
|
||||
|
||||
import { createHash } from 'node:crypto'
|
||||
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs'
|
||||
import { basename, dirname, join, relative, resolve, sep } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const args = process.argv.slice(2)
|
||||
if (args.includes('--help') || args.includes('-h')) {
|
||||
console.log('Usage: iapl-skills [--dest <dir>] [--dry-run] [--no-pointer] [--external [ext-a,ext-b]]\nDefault dest: .agents/skills')
|
||||
process.exit(0)
|
||||
}
|
||||
const dryRun = args.includes('--dry-run')
|
||||
const pointer = !args.includes('--no-pointer')
|
||||
const externalArg = args.indexOf('--external')
|
||||
const externalPick = externalArg >= 0 && args[externalArg + 1] && !args[externalArg + 1].startsWith('-')
|
||||
? args[externalArg + 1].split(',').map((n) => n.trim()).filter(Boolean)
|
||||
: null
|
||||
const destArg = args.indexOf('--dest')
|
||||
const destValue = destArg >= 0 ? args[destArg + 1] : '.agents/skills'
|
||||
// A missing value would resolve to cwd and remove every iapl-* folder there.
|
||||
if (!destValue || destValue.startsWith('-')) {
|
||||
console.error('iapl-skills: --dest needs a directory, e.g. --dest .claude/skills')
|
||||
process.exit(1)
|
||||
}
|
||||
const dest = resolve(process.cwd(), destValue)
|
||||
// Compared AFTER resolving links: `--dest root-link` (a link to `.`), `..` or `/` would otherwise pass and lose
|
||||
// the iapl-* folders of the project root, its parent or the filesystem root. A folder that does not exist yet is
|
||||
// resolved through its nearest existing parent.
|
||||
const real = (path) => {
|
||||
const rest = []
|
||||
let at = path
|
||||
while (!existsSync(at) && dirname(at) !== at) {
|
||||
rest.unshift(basename(at))
|
||||
at = dirname(at)
|
||||
}
|
||||
return join(realpathSync(at), ...rest)
|
||||
}
|
||||
const realDest = real(dest)
|
||||
const realRoot = real(resolve(process.cwd()))
|
||||
if (realDest === realRoot || realRoot.startsWith(realDest.endsWith(sep) ? realDest : `${realDest}${sep}`)) {
|
||||
console.error(`iapl-skills: --dest must be a folder inside the project or elsewhere, not the project root or a folder that holds it (${destValue} is ${realDest})`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
||||
const src = join(pkgRoot, 'docs', 'agent', 'skills')
|
||||
if (!existsSync(src)) {
|
||||
console.error(`iapl-skills: no skills found in ${src} — is @intecion/ipal-kit installed with docs?`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Validate --external before anything is copied.
|
||||
const extSrc = join(pkgRoot, 'docs', 'agent', 'external')
|
||||
const manifest = externalArg >= 0 ? JSON.parse(readFileSync(join(extSrc, 'manifest.json'), 'utf8')) : { skills: [] }
|
||||
const known = manifest.skills.map((skill) => skill.name)
|
||||
const unknown = (externalPick ?? []).filter((name) => !known.includes(name))
|
||||
if (unknown.length) {
|
||||
console.error(`iapl-skills: unknown external skill(s): ${unknown.join(', ')} — available: ${known.join(', ')}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// The same list as LEGACY_SKILL_NAMES in src/modules/doctor/rules/legacy.ts (test/legacyNames.test.ts compares them).
|
||||
const LEGACY_SKILLS = [
|
||||
'audit', 'block', 'collection', 'consent-check', 'debug', 'doctor', 'form', 'locale-add',
|
||||
'migrate-fields', 'nav', 'plugin-gap', 'reference', 'seo-check', 'setup', 'site', 'upgrade',
|
||||
].map((name) => `ipal-${name}`)
|
||||
const isDir = (base, name) => statSync(join(base, name)).isDirectory()
|
||||
const isSkillDir = (base, name) => name.startsWith('iapl-') && isDir(base, name)
|
||||
const shipped = readdirSync(src).filter((n) => isSkillDir(src, n))
|
||||
const existing = existsSync(dest) ? readdirSync(dest).filter((n) => isSkillDir(dest, n)) : []
|
||||
const retired = [
|
||||
...existing.filter((n) => !shipped.includes(n)),
|
||||
...(existsSync(dest) ? readdirSync(dest).filter((n) => LEGACY_SKILLS.includes(n) && isDir(dest, n)) : []),
|
||||
]
|
||||
|
||||
if (!dryRun) mkdirSync(dest, { recursive: true })
|
||||
for (const name of shipped) {
|
||||
const action = existing.includes(name) ? 'update' : 'add '
|
||||
console.log(`${action} ${name}`)
|
||||
if (!dryRun) {
|
||||
rmSync(join(dest, name), { recursive: true, force: true }) // drop files removed upstream
|
||||
cpSync(join(src, name), join(dest, name), { recursive: true })
|
||||
}
|
||||
}
|
||||
for (const name of retired) {
|
||||
console.log(`remove ${name} (${LEGACY_SKILLS.includes(name) ? `now ${name.replace('ipal-', 'iapl-')}` : 'no longer in IAPL'})`)
|
||||
if (!dryRun) rmSync(join(dest, name), { recursive: true, force: true })
|
||||
}
|
||||
console.log(`${dryRun ? '[dry-run] ' : ''}${shipped.length} skill(s) → ${dest}`)
|
||||
|
||||
// Third-party skills, vendored into the package at pinned commits (docs/agent/external,
|
||||
// scripts/vendor-external-skills.mjs). Nothing is downloaded here: every file is checked
|
||||
// against manifest.json before it is copied.
|
||||
if (externalArg >= 0) {
|
||||
const MARK = 'Vendored by @intecion/ipal-kit'
|
||||
const ours = (name) => existsSync(join(dest, name, 'SOURCE.md')) && readFileSync(join(dest, name, 'SOURCE.md'), 'utf8').includes(MARK)
|
||||
const filesOf = (dir) => readdirSync(dir).flatMap((n) => (statSync(join(dir, n)).isDirectory() ? filesOf(join(dir, n)).map((f) => `${n}/${f}`) : [n]))
|
||||
for (const skill of manifest.skills.filter((s) => !externalPick || externalPick.includes(s.name))) {
|
||||
const from = join(extSrc, skill.name)
|
||||
const files = filesOf(from).sort()
|
||||
const tampered = files.filter((f) => skill.files[f] !== createHash('sha256').update(readFileSync(join(from, f))).digest('hex'))
|
||||
if (tampered.length || files.length !== Object.keys(skill.files).length) {
|
||||
console.error(`iapl-skills: ${skill.name} does not match manifest.json (${tampered.join(', ') || 'file list'}) — skipped`)
|
||||
process.exitCode = 1
|
||||
continue
|
||||
}
|
||||
if (existsSync(join(dest, skill.name)) && !ours(skill.name)) {
|
||||
console.warn(`skip ${skill.name} (a folder of that name exists and is not from IAPL)`)
|
||||
continue
|
||||
}
|
||||
console.log(`${existsSync(join(dest, skill.name)) ? 'update' : 'add '} ${skill.name} (${skill.publisher}, ${skill.license}, ${skill.commit.slice(0, 12)})`)
|
||||
if (!dryRun) {
|
||||
rmSync(join(dest, skill.name), { recursive: true, force: true })
|
||||
cpSync(from, join(dest, skill.name), { recursive: true })
|
||||
}
|
||||
}
|
||||
const retiredExt = existsSync(dest)
|
||||
? readdirSync(dest).filter((n) => n.startsWith('ext-') && !known.includes(n) && ours(n))
|
||||
: []
|
||||
for (const name of retiredExt) {
|
||||
console.log(`remove ${name} (no longer in IAPL)`)
|
||||
if (!dryRun) rmSync(join(dest, name), { recursive: true, force: true })
|
||||
}
|
||||
}
|
||||
|
||||
// Pointer block: an agent opening the project must find the guide without being told.
|
||||
// AGENTS.md is read by Codex/Cursor/Antigravity, CLAUDE.md by Claude Code (which also
|
||||
// follows `@AGENTS.md` imports, so a CLAUDE.md that imports AGENTS.md needs no copy).
|
||||
if (pointer) {
|
||||
const START = '<!-- iapl:start -->'
|
||||
const END = '<!-- iapl:end -->'
|
||||
const OLD_START = '<!-- ipal-kit:start -->'
|
||||
const OLD_END = '<!-- ipal-kit:end -->'
|
||||
const version = JSON.parse(readFileSync(join(pkgRoot, 'package.json'), 'utf8')).version
|
||||
const skillsDir = relative(process.cwd(), dest).split('\\').join('/')
|
||||
const block = [
|
||||
START,
|
||||
`## IAPL ${version} — agent guide`,
|
||||
'',
|
||||
'<!-- Managed by `pnpm exec iapl-skills` — edits between the markers are overwritten. -->',
|
||||
'This project is built on `@intecion/ipal-kit` (a Payload CMS 3 plugin). Before you write code:',
|
||||
'',
|
||||
'1. Rules: `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md`.',
|
||||
`2. Everything the plugin provides (options, env vars, routes, layout, hooks, collections, globals, every export): the \`iapl-reference\` skill — \`${skillsDir}/iapl-reference/SKILL.md\`.`,
|
||||
`3. New project or missing foundation: the \`iapl-setup\` skill; a whole site: \`iapl-site\`. All skills: \`${skillsDir}/\`.`,
|
||||
'4. Module details: `node_modules/@intecion/ipal-kit/docs/<module>.md`.',
|
||||
'5. IAPL first: if the plugin has it, use it. Broken or not enough → report it with the `iapl-plugin-gap` skill and wait for the owner — no hand-built replacement, never patch `node_modules`.',
|
||||
'6. Before you set up a site: ask the owner the architecture questions (AGENT.md "Ask before you build") and wait for the answers; record them under "Project decisions".',
|
||||
'7. IAPL docs, this guide and the skills are in English; write rules, AGENTS.md entries and gap reports in English.',
|
||||
END,
|
||||
].join('\n')
|
||||
const upsert = (file, { create }) => {
|
||||
const path = join(process.cwd(), file)
|
||||
const text = existsSync(path) ? readFileSync(path, 'utf8') : null
|
||||
let next
|
||||
if (text === null) {
|
||||
if (!create) return
|
||||
next = create === 'import' ? '@AGENTS.md\n' : `# ${file.replace('.md', '')}\n\n${block}\n`
|
||||
} else if (text.includes(START) && text.includes(END)) {
|
||||
next = text.slice(0, text.indexOf(START)) + block + text.slice(text.indexOf(END) + END.length)
|
||||
// both blocks (an upgrade, a rollback whose installer added the old block again, an upgrade): the old one goes
|
||||
if (next.includes(OLD_START) && next.includes(OLD_END)) {
|
||||
next = (next.slice(0, next.indexOf(OLD_START)).replace(/\s*$/, '') + '\n\n' + next.slice(next.indexOf(OLD_END) + OLD_END.length).replace(/^\s*/, '')).replace(/\s*$/, '\n')
|
||||
}
|
||||
} else if (text.includes(OLD_START) && text.includes(OLD_END)) {
|
||||
// the block written before 1.17.0: replaced where it stands, markers included
|
||||
next = text.slice(0, text.indexOf(OLD_START)) + block + text.slice(text.indexOf(OLD_END) + OLD_END.length)
|
||||
} else {
|
||||
next = `${text.replace(/\s*$/, '')}\n\n${block}\n`
|
||||
}
|
||||
if (next === text) return console.log(`ok ${file}`)
|
||||
console.log(`${text === null ? 'create' : 'update'} ${file}`)
|
||||
if (!dryRun) writeFileSync(path, next)
|
||||
}
|
||||
upsert('AGENTS.md', { create: 'block' })
|
||||
const claude = join(process.cwd(), 'CLAUDE.md')
|
||||
const importsAgents = existsSync(claude) && /^@AGENTS\.md\s*$/m.test(readFileSync(claude, 'utf8'))
|
||||
// CLAUDE.md that imports AGENTS.md already sees the block — don't duplicate it.
|
||||
if (!importsAgents) upsert('CLAUDE.md', { create: 'import' })
|
||||
}
|
||||
|
||||
// Skills ship .ts/.tsx templates and scripts. A Next tsconfig ("include": ["**/*.tsx"]) would
|
||||
// type-check them as project code and break `tsc` / `next build` → they must be excluded.
|
||||
const tsconfig = join(process.cwd(), 'tsconfig.json')
|
||||
const top = relative(process.cwd(), dest).split(/[\\/]/)[0]
|
||||
if (existsSync(tsconfig) && top && !top.startsWith('..')) {
|
||||
const text = readFileSync(tsconfig, 'utf8')
|
||||
const exclude = text.match(/"exclude"\s*:\s*\[([^\]]*)\]/)?.[1] ?? ''
|
||||
const entries = [...exclude.matchAll(/"([^"]*)"/g)].map((m) => m[1].replace(/^\.\//, '').replace(/\/(\*\*)?$/, ''))
|
||||
if (!entries.includes(top)) {
|
||||
console.warn(`\n⚠ tsconfig.json does not exclude "${top}" — skill templates would be type-checked and break the build.`)
|
||||
console.warn(` Add it: "exclude": ["node_modules", "${top}"]`)
|
||||
process.exitCode = 1
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// iapl-tokens — the brand's design tokens: src/design/tokens.ts → src/design/tokens.css,
|
||||
// plus a WCAG contrast check (docs/design-tokens.md).
|
||||
// pnpm exec iapl-tokens → write src/design/tokens.css, print the contrast report
|
||||
// pnpm exec iapl-tokens --check → fail when the CSS is out of date (CI, iapl-doctor)
|
||||
// pnpm exec iapl-tokens --in x.ts --out y.css --warn-only
|
||||
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
|
||||
const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..')
|
||||
const { runTokensCli } = await import(pathToFileURL(join(pkgRoot, 'dist', 'modules', 'tokens', 'cli.js')).href)
|
||||
process.exit(await runTokensCli(process.argv.slice(2)))
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// iapl — the IAPL command line (also installed as `ipal-kit`, its name before 1.17.0, which `pnpm dlx @intecion/ipal-kit` runs).
|
||||
// pnpm dlx @intecion/ipal-kit@<version> create intecion.com → a new client site (docs/project-starter.md)
|
||||
// pnpm exec iapl create intecion.com --dir ../intecioncom-web --answers answers.json
|
||||
// `pnpm dlx <package>` runs the bin named after the package, so every subcommand lives here.
|
||||
// The other tools keep their own bins: iapl-skills, iapl-blocks, iapl-tokens, iapl-doctor.
|
||||
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
|
||||
const USAGE = `Usage: iapl <command> [options]
|
||||
create <domain> a new client site from the reference site (iapl create --help)
|
||||
|
||||
Other tools: iapl-skills, iapl-blocks, iapl-tokens, iapl-doctor`
|
||||
|
||||
const [command, ...args] = process.argv.slice(2)
|
||||
if (command !== 'create') {
|
||||
console.log(USAGE)
|
||||
process.exit(command === undefined || command === '--help' || command === '-h' ? 0 : 1)
|
||||
}
|
||||
const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..')
|
||||
const { runCreateCli } = await import(pathToFileURL(join(pkgRoot, 'dist', 'modules', 'starter', 'cli.js')).href)
|
||||
process.exit(await runCreateCli(args))
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
|
||||
import './iapl-blocks.mjs'
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
|
||||
import './iapl-doctor.mjs'
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
|
||||
import './iapl.mjs'
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
|
||||
import './iapl-skills.mjs'
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
|
||||
import './iapl-tokens.mjs'
|
||||
@@ -1,112 +0,0 @@
|
||||
# Changelog of the wire contract
|
||||
|
||||
## 1.7.1 — 2026-11-25 (not released; no tag yet)
|
||||
|
||||
Wording only; nothing for a client to change, and a copy of 1.7.0 need not be refreshed for it.
|
||||
|
||||
- **1.7.0 is required, not optional.** A client of 1.6 or older gets `400 invalid-request` on every request
|
||||
that carries a token, because it does not send `X-Intecion-Site`. By the rule for development versions (§9)
|
||||
it was numbered as a minor; read it as a breaking step. No client of 1.6 or older was released.
|
||||
|
||||
## 1.7.0 — 2026-11-25 (never released)
|
||||
|
||||
From the independent review of the first client. What a client built against 1.6.0 has to change is marked.
|
||||
|
||||
- **New, required: the header `X-Intecion-Site: <own host>` on every request that carries a token.** Missing:
|
||||
`400 invalid-request`. Not the token's host: the new code **`403 host-mismatch`** (forget the token, enrol as
|
||||
yourself). **Client: send the header; handle the code.** All examples with a token carry it; two new
|
||||
examples (`send-host-mismatch`, `status-no-site-header`).
|
||||
- **A client stores the host with the token and compares it with its own before use**, and compares the `host`
|
||||
of `/v1/status` (§8, checklist 3). **Client: add the check.**
|
||||
- **The confirm endpoint's limiter counts only refused calls**, after the nonce was looked up; never by the
|
||||
caller's address first (§2). **Client: check the order.**
|
||||
|
||||
## 1.6.0 — 2026-11-25 (never released)
|
||||
|
||||
From the first client built against the contract (IAPL's). **The service did not change**; these are the
|
||||
contract's words. What a client built against 1.5.0 has to change is marked.
|
||||
|
||||
- **An answer that is not the service's JSON** is no longer "like `503 unavailable`" for the report: with a
|
||||
status from 400 to 499 it is *not sent*, with any other status (200 included) *not confirmed*.
|
||||
**Client: change the report for that case.** Retrying it is as before.
|
||||
- **A client that cannot keep key and bytes** (§1): no retry by itself after the report; a repeat by a person
|
||||
is a new message; keys derived from the message's record are described, and for such a key
|
||||
`idempotency-conflict` means "already handled". **Client: nothing must change; derived keys are an option.**
|
||||
- **A site with a hand-issued token** does not enrol on `reverify` / `invalid-token`; it reports
|
||||
`relay-refused` and what to ask Intecion for. **Client: nothing, if it already does this.**
|
||||
- **`Origin` / `Sec-Fetch-Site`:** a client sends neither; said in §1. **Client: nothing for Node.**
|
||||
- A stand-in need not reproduce the service's lists; said in §10.
|
||||
|
||||
## 1.5.0 — 2026-11-25 (never released)
|
||||
|
||||
After the third review.
|
||||
|
||||
- `new-recipients`: `account` mail is outside it; a form's confirmations may use four fifths of it.
|
||||
- Failed sends: those in flight are counted in.
|
||||
- Wording: `backend-failed`, `internal` and unknown codes mean "probably not sent"; the checklist asks a client
|
||||
to limit "forgot password" itself.
|
||||
|
||||
## 1.4.0 — 2026-11-25 (never released)
|
||||
|
||||
After the second review.
|
||||
|
||||
- **Limits by kind:** `security-alert` has a budget of its own (`limit: "alerts"`, `limits.securityAlertsPerDay`)
|
||||
outside hour and day; `account` mail may use the whole hour and day, every other kind four fifths. The
|
||||
`quota` of a send answer is for that kind. `recipient` counts `form-confirmation` messages only.
|
||||
- **The idempotency promise is now what the service does:** a key whose message was handed to the mail back end
|
||||
is never sent again within 24 hours; when the result was not recorded it answers `in-progress` until then.
|
||||
- **Failed sends** have a limit of their own: `429 rate-limited` after 60 in an hour.
|
||||
- **Retrying:** three attempts, 30 seconds each, ten seconds of waiting in all; an enrolment on the way does
|
||||
not count.
|
||||
- **Subject:** U+200D, U+200C and U+00AD are allowed; everything else as before, with the rule a client strips by.
|
||||
- Any mail of a site to Intecion's own address gets `[host]` in front of its subject.
|
||||
- The confirm address: no redirect is followed — the usual causes and what to do; `given.quota` gains
|
||||
`hour-share-used`.
|
||||
|
||||
## 1.3.0 — 2026-11-25 (never released)
|
||||
|
||||
- **The confirm path is fixed per product** (owner, 2026-11-25): `iapl` → `/api/iapl/mail-relay/confirm`,
|
||||
`iawl` → `/?rest_route=/iawl/v1/mail-relay/confirm`. **`callbackPath` is gone from the enrolment request**
|
||||
(a request that carries it is refused). A site that serves its API elsewhere has its path set by Intecion.
|
||||
- Suppression is account-wide and stays so (owner, 2026-11-25): said in the code table.
|
||||
|
||||
## 1.2.0 — 2026-11-25 (never released)
|
||||
|
||||
After the first independent review. The wire format is the same; the text now has one reading where it had two.
|
||||
|
||||
- **Retrying:** at most three attempts in ten seconds, and the ten seconds win over `retryAfter`; "no answer"
|
||||
and `in-progress` are reported as *not confirmed*, never as *not sent*.
|
||||
- **Idempotency:** "the same body" is the same bytes; a client encodes a message once.
|
||||
- **The confirm endpoint:** exactly `200` and the JSON object, at most 1024 bytes, within 8 seconds; the site
|
||||
keeps its earlier token until `/v1/enrol` answers 200.
|
||||
- **An answer that is not JSON** is `unavailable`, retryable.
|
||||
- `Authorization: Bearer` in any case.
|
||||
- **Schema:** `code` and `warnings` are open strings (new ones are minor changes); `to` is required unless the
|
||||
kind is `security-alert`; recipients' `maxItems` is the service's bound, the site's limit is in `/v1/status`;
|
||||
base64 is padded to a multiple of four (said in words: a pattern for it overflows on large files); lengths are
|
||||
in code points.
|
||||
- **Changed behaviour:** the per-recipient limit refuses `form-confirmation` only; a subject may not start with
|
||||
the service's name in brackets; a `security-alert` gets the site's host in front of its subject;
|
||||
`attachment-refused` names the file in `field` (suggested status `relay-attachment-refused`);
|
||||
invisible characters (all of Unicode category Cf) are refused in subject and file names.
|
||||
- Added: `limits.serverAddresses` in `/v1/status`; what happens beyond it.
|
||||
- Before the first release tag, versions are development versions (§9).
|
||||
|
||||
## 1.1.0 — 2026-11-25 (never released)
|
||||
|
||||
- **The base address is `https://webservices.intecion.net/mail`**: one host for Intecion's web services, this
|
||||
one under the path `/mail`. Paths in the contract are relative to the base address, as before; a client that
|
||||
kept the base address as one constant changes that constant and nothing else.
|
||||
- Added: `service.name` in the answer of `/v1/status` ("Intecion Notifications Webservice").
|
||||
- The service sends from `[email protected]` (owner, 2026-11-25).
|
||||
|
||||
Minor, by the contract's own rule (§9): an answer field was added. No copy of 1.0.0 was released; a client that
|
||||
copied it during development copies the folder again.
|
||||
|
||||
## 1.0.0 — 2026-11-25 (never released)
|
||||
|
||||
First version: `/v1/enrol` with the call-back and its confirmation, `/v1/send`, `/v1/status`, `/v1/rotate`,
|
||||
`/v1/revoke`, `/health`; the error codes; the examples and the runner.
|
||||
|
||||
Differs from the design proposal (draft 4) in one visible point: the site's confirm endpoint answers `200` with
|
||||
a `confirmation` (SHA-256 of nonce and token), not a bare `204`. Reason: `services/mail-relay/DECISIONS.md`, D1.
|
||||
@@ -1,64 +0,0 @@
|
||||
3d5c4b7ed53fe6fe2c7c28826c0cf666f9c1d0b79f861b404503e7029728a61f README.md
|
||||
53da77d5dfff9948d68fca26b828563e21f83418245053d78b03a5aecac6c1d1 CHANGELOG.md
|
||||
249182a01164b81a5f7af87e5c5cdbd3344a80a7a66dfca624cecfb1501b2420 VERSION
|
||||
2ff0ad5b6a245365c0fa8733fa17b7bbd3ab91d4825981709d0fd02b762b939f schema.json
|
||||
9d8381d2e3465e97dc801a61f598fcf822e27e73a2c0729877744ec307097910 runner.mjs
|
||||
7c46860adee597e570832c72bcdb418752a20b9f7d1b2d7a656ed065f9632b2a checksums.mjs
|
||||
df6015faf02a7cf7e9b5816b9e22b2e82968678ddd72a61c1f9665a8c0897ddf examples/callback-confirm-wordpress.json
|
||||
f5018ca4fb7d25794ee92168d715aaf47feeba3d907c0550651b16c10a691ceb examples/callback-confirm.json
|
||||
27bd95712cc36a71519cddc52c03d857b1009c2c384940dbc052022d86bc4231 examples/callback-unknown-nonce.json
|
||||
de693b060c10c3d0f88fb8edfcd38c491cf141628d747328beee1b50c700c19b examples/enrol-address-literal.json
|
||||
7c4cf75eb9ab156a3031336ab2688e7c9dcd4cd266b7b7e5e4592285dcbd25ba examples/enrol-callback-no-content.json
|
||||
64466afc5bf0fecfa36f986d973cd987bbe1f64867e01cdf35e0de40838eb0d1 examples/enrol-callback-not-found.json
|
||||
0000bcb2b3b676e4fda6c30b8de6e062c88f98c1fa2cc9f75bcd350d65dc0db4 examples/enrol-callback-path-given.json
|
||||
8b522f16bc9b9980a5c849e94cea35fb268b0ba664dcd5a2e8e0fedd67c2c034 examples/enrol-callback-redirect.json
|
||||
1e6483ebd85e3851848357266d8e16628a70420428b30d3ddb15253cdc2d9a0d examples/enrol-callback-wrong-confirmation.json
|
||||
f64e4c75ced60e70b0f2f8e16adbde151be888fe5ac75813cdbe7eb5ecf8a00b examples/enrol-from-browser.json
|
||||
218f463c95fd79868916390d4616c796d66154398a9864615f9ad0768f801aff examples/enrol-listed-active.json
|
||||
b628eb5b30e693767e6830de58e0fd172497336f67b76a49a5fb06bfa626c481 examples/enrol-localhost.json
|
||||
93304590382de5153a47fa88ee98356d0a5ba8039e195959291acd3c33e4a406 examples/enrol-short-nonce.json
|
||||
e86e6ab23088c1c985ba18f287f66b49c50f51a584a7ca679b8b768597130efd examples/enrol-suspended.json
|
||||
fe38f1fd1394a7fd42b1a1b0b74aa604578f17ab52590bf95a462a0c0f7d6087 examples/enrol-unlisted-pending.json
|
||||
b9f71fe993dc39bdbc07e775e925a37175e18e1682fd8bffcc72b3581919be17 examples/health.json
|
||||
5dff4194764f6f61b01a3f7f504907e578306a486d214e22d1a70b1a207e5ca3 examples/not-found.json
|
||||
94943f85503cd891f1fb6f0258ab97b2eb48ec10e5f7ea233d349d4da97b8a1b examples/revoke-ok.json
|
||||
1b467eac1040d56369276e5b8c12540a84942c8b7e3c2e458fc8da5b4f027c86 examples/rotate-ok.json
|
||||
348f96a160c168797ab27ff0739b17df1762cc2ffdd72cb0a2b3ec2c695093bc examples/rotate-previous-token.json
|
||||
39774a2ce0434dc791d79f9efb4b14f23203b7e8d58138acc7654265a875609b examples/send-attachments-too-large.json
|
||||
75ec4de22780b36b41f198f065e38937beb4a50879fd204e080bdb935c2b5e8f examples/send-backend-failed.json
|
||||
e3331a33604c2239c91c889d3dd338e473fd9b5d80fccb84a39491810bcceac0 examples/send-bearer-any-case.json
|
||||
26f4f8a2929d132598bcb87e813616cef7b6277249c657cc618f4ede4cb4d906 examples/send-day-quota.json
|
||||
660dbe2a747686077788f46fe45f269c3eb57e4579225979f91841e9f00fae7b examples/send-display-name-recipient.json
|
||||
1c6bd0ed454f51acf545f0213fe6108f3639af975fb0751ef8d23bd92da9d4c7 examples/send-executable-attachment.json
|
||||
ed6869754e418cc5e2a809e52a0242680d79f1bbc2eedd391de04375f29f7b9a examples/send-from-browser.json
|
||||
e39d197f857b56103726b0f165c67a3476a06207961a59c6f6a1cf333bc3e7e9 examples/send-from-field.json
|
||||
5c826cd0c297c773510ce37b66a0f6a6425e6282abc1ad30094fd5b545ae9193 examples/send-headers-field.json
|
||||
3918635b33b32783db96ae17ebbd4296d2deca05d092b55573c574be172601ec examples/send-host-mismatch.json
|
||||
a6809a8d475106f8e31ba432e56b46e9bf8683a0eca9d62378b1392cd6c44305 examples/send-hour-quota-account.json
|
||||
c46852c9d9fc7eb83ac6bc3ca2a7c5b79100d2cae93a5cee6720b702b4c22490 examples/send-hour-quota.json
|
||||
dc0f9c1c946d256aded0de70588c1d1f95740d333b234127f9bce8a4ed8beefb examples/send-key-reused.json
|
||||
69edbf23c9723337f6327484e587b8cb7603c23e4b4954ebd275a0a794171325 examples/send-no-sender-name.json
|
||||
bcbf5adcd0c224edb81c3b4188f261252835f715f541030db10432fa7ebd71a4 examples/send-no-token.json
|
||||
32125ac9ff5460991633cce55febcb310247ca518eae7c650ef634e3f86376e0 examples/send-ok.json
|
||||
7d8b14d372730f013ee7192021dda68859f779337b8d535bc564ac955a00e325 examples/send-pending.json
|
||||
e3bbb041217d0a4f378285c06584a093d5e808d223d564e735c559f461fae8b8 examples/send-previous-token.json
|
||||
53132e3e2177937dc2a35f7fe87f2f383f45ab001fc0306490941b44bb466e3c examples/send-recipient-quota-other-kinds.json
|
||||
aff454882faab57d4a697be7250fdbac0272bcc2e0c099a6a27c50e0a980ac70 examples/send-recipient-quota.json
|
||||
d514bc65a75f522389c90f1239d9afa43d96c7c2e7bd31fe0e85dd4c9d543ebd examples/send-recipient-suppressed.json
|
||||
eb68d83a8d582a3722bf99330246d3d641e49a53e08bbe48e04e09a970cbb866 examples/send-replay.json
|
||||
189dbdb3df1f0da0b6a1e8fdd0e90babf9dbfe9cfcaeb423ba24e2d59802b663 examples/send-security-alert.json
|
||||
f299bc4f5193de0619d78551653a0b133a4ae5774dba93b23812b689a074a87d examples/send-sender-name-replaced.json
|
||||
39a09b2bd01fc12d0e8cb2f93b71b24f31a4f2d0f639fe93b6bf37a7357be0ae examples/send-subject-direction-mark.json
|
||||
ce4cbea2306f73bd5905249c10ab451a2599cb779e2386828971f40c97b8c591 examples/send-subject-imitates-service.json
|
||||
247619f5575e898bd558ff7f7674f241c39f3a1e0ae51f589eb6a6dc2fe21e2b examples/send-subject-line-break.json
|
||||
59175981e46a6f782ce3b4ed9c885699d7766823d660e5a524e89a4f2c6c459a examples/send-subject-visitor-text.json
|
||||
987a2b4433161b4f2a6502d0487bf18f512f7a630a930ac66b1038cd6e000dc3 examples/send-suspended.json
|
||||
91cd894526eef28e4dfb2456e476ba0be381e6d621ea833761cc9c63fe247e03 examples/send-text-plain.json
|
||||
9c6278fcb13d7e06e0dd38ef34eba1abfbcb9c75100994b93c1c5a5444c35f85 examples/send-to-intecion-marked.json
|
||||
1a1faf5a451220a35f2f0d66bb906e0d9944ed0a71c8209e07da419734a82567 examples/send-too-many-recipients.json
|
||||
43d04c99549a4fe3c64af6f68b598299e92486af5a52432a2c93c3f9564f7959 examples/send-unknown-address.json
|
||||
28e05f3c53cab6433b6af4d425511fa6655d0673df2e840af1fed9d25294a123 examples/send-unknown-token.json
|
||||
f105c38ab11ab5fc508ba0ed3f23f69108c318765c2670029b230b5b9a83912a examples/status-active.json
|
||||
89009ee9ab8f38e9ec290fb5412f206e1be28ad10fce6a7071d4406ac52dd4f0 examples/status-no-site-header.json
|
||||
c9f49fa0dae1f0beacaacfe01660b467d06f990228c35a653307c8793f3c97a5 examples/status-pending.json
|
||||
afdb07ba8279479b6bbfdc4289efda657d4e5a9eccd94b8de165ec728b4a2386 examples/status-unknown-address.json
|
||||
@@ -1,540 +0,0 @@
|
||||
# Intecion Notifications Webservice — wire contract
|
||||
|
||||
Version: see [`VERSION`](VERSION) (this text describes **1.7.1**). Path prefix of this major version: `/v1`.
|
||||
|
||||
This is the whole agreement between the Intecion Notifications Webservice ("the service" below) and a client (the mail transport built into a
|
||||
site's plugin). It names no product: nothing here says Payload, WordPress, IAPL or IAWL except the values of
|
||||
the `product` field. A client written from this document, in any language, works with the service.
|
||||
|
||||
| File | What |
|
||||
|---|---|
|
||||
| `README.md` | This document. Where it and the schema disagree, the schema wins and that is a bug to report |
|
||||
| `schema.json` | JSON Schema (2020-12) of every body, under `$defs` |
|
||||
| `examples/*.json` | One request and its answer per file, with the state it needs. They are the contract tests |
|
||||
| `runner.mjs` | Runs the examples against anything that speaks the contract. No dependency; works in Node and in the Workers runtime |
|
||||
| `checksums.mjs`, `CHECKSUMS` | SHA-256 of every file above, to detect a hand-edited copy |
|
||||
| `VERSION`, `CHANGELOG.md` | Semantic version of the contract and what changed |
|
||||
|
||||
## 1. Basics
|
||||
|
||||
- **Base address: `https://webservices.intecion.net/mail`** — a client keeps it as one constant, host and path
|
||||
together. Every path in this document and in the examples is relative to it: `POST /v1/send` is
|
||||
`POST https://webservices.intecion.net/mail/v1/send`, `GET /health` is `…/mail/health`. A client joins the
|
||||
base address and the path as text; it never resolves a path against the host alone.
|
||||
- HTTPS only. Bodies are JSON in UTF-8. A request with a body carries `Content-Type: application/json`.
|
||||
- **The service is for servers, not browsers.** It sends no CORS header, and it refuses any request that
|
||||
carries an `Origin` header or a `Sec-Fetch-Site` header other than `none` (`403 browser-not-allowed`).
|
||||
A client must send neither. A server runtime's `fetch` that adds them by itself has to be told not to, or the
|
||||
header removed, or the service will take the site for a browser. (`Sec-Fetch-Mode` and `Sec-Fetch-Dest` are
|
||||
not looked at: Node's `fetch` sends `sec-fetch-mode: cors` and passes.)
|
||||
- **Requests are closed:** an unknown field is refused with `400 invalid-request` and the field's name. A
|
||||
client cannot set `From`, `Sender`, `Return-Path` or any free header — there are no such fields.
|
||||
- **Answers are open:** a client ignores fields it does not know.
|
||||
- A client identifies itself with `User-Agent: <product>/<version>` (not checked, used for the log).
|
||||
- **An answer that is not the service's JSON** — an error page of the network in front of the service, an empty
|
||||
body, a cut-off answer — is no answer of the service. The client may retry it (as if `retryable` were true),
|
||||
and what it means for a message depends on the status alone:
|
||||
- status **400 to 499**: the request was turned away before the service handled it — **not sent**;
|
||||
- **any other status, `200` included**: the service may have handled the request and only its answer was
|
||||
lost — **not confirmed**, exactly like no answer at all (§1, "Retrying").
|
||||
|
||||
### Answers
|
||||
|
||||
Success is status `200` and a body with `"ok": true`.
|
||||
|
||||
Every refusal has the same body ([`Error`](schema.json)) — with one exception: `/health` answers only
|
||||
`{ "ok": false }`.
|
||||
|
||||
```json
|
||||
{ "ok": false, "code": "quota-exceeded", "message": "…", "retryable": false, "limit": "hour", "retryAfter": 1260 }
|
||||
```
|
||||
|
||||
- `code` is what a client acts on. `message` is English text for a log or an administrator; never show it to a visitor.
|
||||
- **`retryable` decides whether to try again, not the status.** `429 quota-exceeded` is not retryable;
|
||||
`429 rate-limited` is.
|
||||
- `retryAfter` (seconds) is also sent as the `Retry-After` header.
|
||||
- The list of codes grows with minor versions. A client that meets a code it does not know acts on `retryable`
|
||||
and shows the `message` to an administrator.
|
||||
|
||||
### All codes
|
||||
|
||||
| Status | `code` | Meaning | Retry | What a client does | Suggested site status |
|
||||
|---|---|---|---|---|---|
|
||||
| 400 | `invalid-request` | Body, header or field is wrong; `field` names it | no | Report a bug | — |
|
||||
| 401 | `invalid-token` | No token, or one the service does not know (unknown, expired, revoked) | no | Enrol again, then send once more (§2, "Which token") | — |
|
||||
| 401 | `reverify` | The token is good but comes from a server address the service has not seen for this site | no | Enrol again (the same call-back), then send once more | — |
|
||||
| 403 | `site-pending` | Enrolled, waiting for approval by Intecion | no | Keep the token; show "waiting for approval" | `relay-pending` |
|
||||
| 403 | `site-suspended` | Stopped by Intecion | no | Keep the token; show it; do not enrol again | `relay-suspended` |
|
||||
| 403 | `host-not-allowed` | Enrolment: the host is not a public DNS name | no | Show it (a local or private site cannot use the service) | `relay-refused` |
|
||||
| 403 | `enrolment-closed` | Enrolment is closed for this product, or altogether | no | Show it | `relay-refused` |
|
||||
| 403 | `host-mismatch` | The token is good and comes from a known address, but the request's `X-Intecion-Site` names another site than the token's | no | Forget the token (it is another site's — a copied database, a token pasted into the wrong site), enrol as your own host, then send once more | — |
|
||||
| 403 | `browser-not-allowed` | The request came from a browser | no | — | — |
|
||||
| 404 | `not-found` | No such route | no | Report a bug | — |
|
||||
| 405 | `method-not-allowed` | Wrong method | no | Report a bug | — |
|
||||
| 409 | `enrolment-in-progress` | Another enrolment for this host is running right now | **yes** | Wait `retryAfter`, read your own store again (another process may have the token by now), enrol only if still without one | — |
|
||||
| 409 | `in-progress` | A send with this `Idempotency-Key` is running right now — or was handed to the mail back end and its result was never recorded (then `retryAfter` is long, and the message may be out) | **yes** | Retry with the same key within the ten seconds; then report "not confirmed" | — |
|
||||
| 409 | `idempotency-conflict` | This `Idempotency-Key` was used for a different message | no | Report a bug | — |
|
||||
| 409 | `already-rotated` | `/v1/rotate` with a token that is no longer the current one | no | Read your own store again; if it has no newer token, enrol again | — |
|
||||
| 413 | `too-large` | `limit` says what: `request`, `body` or `attachments` | no | Show it | `relay-too-large` |
|
||||
| 415 | `unsupported-media-type` | Not `application/json` | no | Report a bug | — |
|
||||
| 422 | `callback-failed` | Enrolment: the site's confirm endpoint did not confirm; `reason` is `unreachable`, `timeout`, `redirect`, `status` or `confirmation` | no | Show it, with the reason: firewall or wrong public host (`unreachable`, `timeout`); the site answers the confirm address with a redirect (`redirect`, §2); the endpoint is missing, blocked, or served at another path than its product's (`status`); something prints around the JSON (`confirmation`) | `relay-refused` |
|
||||
| 422 | `too-many-recipients` | More than the allowed number in To, CC and BCC together | no | Show it | `relay-quota` |
|
||||
| 422 | `attachment-refused` | A file type the service never carries, or a bad file name; `field` says which file (`attachments[0]`) | no | Show it; the message can be sent without that file | `relay-attachment-refused` |
|
||||
| 422 | `recipient-suppressed` | The back end refuses one of the recipients (it bounced or complained before — for any site: **the suppression list is one for the whole service, and there is none per site**; an address that bounced for one client's site is refused for every other site too, until Intecion removes it). **Nothing was sent, to anybody.** The service is not told which address it is | no | Show it. With several recipients a client may send to each alone, each with a new key, to find the one | `relay-recipient-suppressed` |
|
||||
| 429 | `rate-limited` | Too many requests from this address — or too many of this site's sends were refused or failed at the mail back end within the hour (60; a send that fails costs no quota, so it has a limit of its own; account mail and alerts are counted apart from the rest) | **yes** | Wait `retryAfter`; when that is longer than the ten seconds, report | `relay-unreachable` if it persists |
|
||||
| 429 | `quota-exceeded` | A limit of the site (`limit`: `hour`, `day`, `recipient`, `new-recipients`, `alerts`) or of the whole service (`service`) | no | Show it; the message is not sent | `relay-quota` |
|
||||
| 502 | `backend-failed` | The mail back end failed, or refused this message | **as `retryable` says** | Retry with the same key when `retryable` is true | `relay-unreachable` if it persists |
|
||||
| 503 | `unavailable` | The service cannot work right now | **as `retryable` says** | Retry when `retryable` is true | `relay-unreachable` if it persists |
|
||||
| 500 | `internal` | A fault in the service | **yes** | Retry | `relay-unreachable` if it persists |
|
||||
|
||||
A network error or a time-out is treated like `503`. The "suggested site status" column is advice, in the words
|
||||
the IAPL design uses; a product may name its own. The warning `sender-name-replaced` (below) maps to
|
||||
`relay-name-replaced`.
|
||||
|
||||
**Retrying — the one rule.** A client makes at most **three attempts** for one message, the same
|
||||
`Idempotency-Key` and the same bytes each time, and only after an answer with `retryable: true` (or no usable
|
||||
answer at all). Between the attempts it waits **at most ten seconds in all**. **The ten seconds win over
|
||||
`retryAfter`:** when `retryAfter` is longer than what is left of them, the client stops at once and reports.
|
||||
|
||||
- **One attempt** has a time-out of **30 seconds** from sending the request to the end of the answer (a 10 MB
|
||||
attachment has to fit). An attempt that times out counts as "no answer".
|
||||
- **An enrolment made on the way** — because the client had no token, or got `invalid-token` or `reverify` — is
|
||||
not one of the three attempts and its time (up to 10 seconds: the call-back has 8) is not part of the ten
|
||||
seconds. A client enrols at most once per message.
|
||||
|
||||
What the client reports:
|
||||
|
||||
| The last thing that happened | The message | Report |
|
||||
|---|---|---|
|
||||
| `200` | was accepted | sent |
|
||||
| A refusal with `retryable: false` | was not sent | the status of that code |
|
||||
| `rate-limited`, `unavailable`, `enrolment-in-progress` (as the service's own JSON), or an answer that is not the service's JSON with a status from 400 to 499 | was not sent | `relay-unreachable` |
|
||||
| `backend-failed`, `internal`, or a code the client does not know | **probably** not sent — the mail back end failed in a way it does not explain, and it does not say whether such a message can still go out | `relay-unreachable`, worded as "probably not sent". Like the next row: the same key and bytes if it is tried again |
|
||||
| **No answer** (time-out, connection lost), an answer that is not the service's JSON with any status outside 400–499, or `409 in-progress` | **may have been sent** — the service cannot say yet, or will never be able to | `relay-unreachable`, worded as "not confirmed", never as "not sent". If the client tries this message again later it uses the **same key and bytes**: within 24 hours of the first attempt that cannot produce a second mail — once the service has handed a message to the mail back end, its key either answers with the result or goes on answering `in-progress`; it is never sent again. A client never sends the message under a new key by itself |
|
||||
|
||||
**"The same key and bytes" — and a client that cannot keep them.** The promise that a message is not sent
|
||||
twice holds for as long as the client still has the message's key and its encoded bytes. What a client does
|
||||
depends on what it can keep:
|
||||
|
||||
- **Within one attempt to deliver a message** (the three tries above) every client keeps both in memory.
|
||||
- **A client with storage for unsent mail** keeps key and bytes with the message and may try again later.
|
||||
- **A client without such storage** does not try again by itself once it has reported. "Not confirmed" is then
|
||||
final for that message: the report says that the mail may or may not have gone out. If a person causes the
|
||||
mail again — submits the form again, presses "send again" — that is a **new message with a new key**, and
|
||||
when the first one did go out, the recipient gets it twice. The service cannot prevent that and a client
|
||||
need not; it should say "not confirmed" in a way that does not invite an immediate repeat.
|
||||
- **A key derived from the message's own record** narrows this without storing the mail: when the mail belongs
|
||||
to something the site stores anyway (a form submission, a password-reset request), the client may build the
|
||||
key from that record's id and the mail's role in it (for example the SHA-256 of both, in the key's
|
||||
alphabet). A second attempt for the same record — after a restart, from another process — then arrives under
|
||||
the same key, and the service answers it with the first result (`replayed`), with `in-progress`, or, when the
|
||||
bytes differ because the mail was built again, with `409 idempotency-conflict`. For a derived key the client
|
||||
treats **`idempotency-conflict` as "this record's mail was already handled"**, not as a bug: no second mail
|
||||
either way. A deliberate "send again" by a person uses a new key (the record's id and a counter).
|
||||
|
||||
## 2. Enrolment — `POST /v1/enrol`
|
||||
|
||||
A site gets its token by proving that it is served at its host. No authentication, nothing to type.
|
||||
|
||||
1. The site makes a random **nonce** (32 to 128 characters of `A–Z a–z 0–9 _ -`; at least 128 bits of
|
||||
randomness), keeps it for 5 minutes, and sends:
|
||||
|
||||
```json
|
||||
{ "host": "example.com", "nonce": "…", "product": "iapl", "productVersion": "1.17.0" }
|
||||
```
|
||||
|
||||
- `host`: the site's public DNS name, lowercase, punycode. No scheme, port, path, address literal, single
|
||||
label, or private suffix (`.local`, `.internal`, `.test`, `localhost` …).
|
||||
- There is **no call-back address in the request.** Where a site is called back is fixed per product
|
||||
(below); a request that names a path is refused (`400`, field `callbackPath`).
|
||||
|
||||
2. Before it answers, the service calls the site: `POST https://<host><confirm path of the product>`, port 443,
|
||||
no redirect followed, **8 seconds** for the whole exchange, body ([`CallbackRequest`](schema.json)):
|
||||
|
||||
```json
|
||||
{ "nonce": "…", "token": "ims_…", "state": "active" }
|
||||
```
|
||||
|
||||
3. **The site's confirm endpoint** accepts the call only if it holds exactly this nonce (compare in constant
|
||||
time; single use; not expired). Then it stores the token and answers `200` with
|
||||
|
||||
```json
|
||||
{ "confirmation": "<lowercase hex SHA-256 of nonce + \".\" + token>" }
|
||||
```
|
||||
|
||||
In every other case it answers `404` and changes nothing.
|
||||
|
||||
**It is a public route: limit it — but only the calls it refuses.** Look the nonce up **first**. A call that
|
||||
carries the nonce the site holds is the service's and is always answered; only calls that do **not** match
|
||||
a held nonce count towards a limit. Do not limit by the caller's address before that look-up: the service's
|
||||
calls come from addresses that every Worker on Cloudflare shares, so a stranger who sends a few requests
|
||||
from a Worker of their own would use up "the service's" allowance and block the site's enrolment. (When the
|
||||
site holds no nonce at all — it started no enrolment in the last five minutes — every call is a refused one
|
||||
and can be answered `404` without any work.)
|
||||
|
||||
**Exactly this answer and nothing else.** Status `200` (not 201, not 204). The body is the JSON object alone,
|
||||
UTF-8, at most 1024 bytes, the hex in lower case. Anything printed before or after it — a PHP notice, a
|
||||
debug toolbar, a wrapper of the framework — makes the enrolment fail with `callback-failed`, reason
|
||||
`confirmation`. The service reads no more than 1024 bytes and waits no longer than the 8 seconds.
|
||||
|
||||
**Which token.** The call-back arrives *before* `/v1/enrol` has answered. The site stores the new token
|
||||
**beside** the one it has, and makes it the token it uses when `/v1/enrol` answers `200`. If that answer
|
||||
never arrives, the site tries the new token on its next request and goes back to the earlier one on
|
||||
`401 invalid-token` (the service may have failed after the call-back; the earlier token is then still good).
|
||||
A site never throws a working token away for one it has not seen accepted.
|
||||
|
||||
4. The service checks the confirmation. Only then does the token become valid, the calling server's address
|
||||
become one of the site's known addresses, and `/v1/enrol` answer `200`:
|
||||
|
||||
```json
|
||||
{ "ok": true, "state": "active" }
|
||||
```
|
||||
|
||||
`state` is `active` (the site may send) or `pending` (waiting for approval; sends answer `403 site-pending`
|
||||
until Intecion approves, then the same token works). **The answer never carries the token.**
|
||||
|
||||
Why the confirmation, and not a bare `204`: plenty of ordinary endpoints answer "no content" to any POST (a
|
||||
report collector, for one). Only an endpoint that knows the nonce *and* has read the token can compute the
|
||||
confirmation, so nothing else on the host can be mistaken for the confirm endpoint.
|
||||
|
||||
Rules a client must know:
|
||||
|
||||
- **Enrolling again is the same call** and is how a site heals: after `401 invalid-token`, after `401 reverify`,
|
||||
after a lost token. The earlier token stays valid for 24 hours (so other processes of the same site are not
|
||||
cut off), the state is kept — a suspended site stays suspended (`403 site-suspended`, no call-back is made).
|
||||
- A failed enrolment changes nothing on the service: tokens and addresses stay as they were.
|
||||
- `409 enrolment-in-progress`: an enrolment for this host from this server is already running (or the
|
||||
registry changed while the site was being called). It is retryable and is not counted against the site.
|
||||
- **The confirm path is fixed per product**; a site cannot choose it:
|
||||
|
||||
| `product` | The service calls | Notes |
|
||||
|---|---|---|
|
||||
| `iapl` | `POST https://<host>/api/iapl/mail-relay/confirm` | Under Payload's default API route (`/api`) |
|
||||
| `iawl` | `POST https://<host>/?rest_route=/iawl/v1/mail-relay/confirm` | WordPress's REST API addressed by query: the same address works with and without pretty permalinks. The route is `mail-relay/confirm` in the namespace `iawl/v1` |
|
||||
|
||||
The service calls **exactly that address and follows no redirect.** A site that redirects it fails with
|
||||
reason `redirect` — the usual causes: the site adds or removes a trailing slash (Next.js `trailingSlash`),
|
||||
sends `example.com` to `www.example.com` (enrol the host the site really answers on), or redirects `/` by
|
||||
language. On WordPress, a security plugin or a setting that blocks or redirects `?rest_route=` gives
|
||||
`status`. In each case either the site is changed to answer at the address, or Intecion sets the address it
|
||||
does answer at (a path ending in `/confirm/`, for a site with trailing slashes).
|
||||
|
||||
**A project that serves its API somewhere else** — Payload with another `routes.api`, WordPress installed in a
|
||||
sub-folder, a path prefix in front of the site — cannot say so in the request. Its path is set for its host
|
||||
**by Intecion** (`ims callback-path <host> <path>`), before the site enrols; until then the enrolment fails
|
||||
with `callback-failed`, reason `status`. A client shows that as "ask Intecion to set this site's confirm
|
||||
address", with the address it serves. When an enrolled host confirms at another path than before, Intecion
|
||||
is told.
|
||||
- **Server addresses.** A site may send from a limited number of server addresses at a time
|
||||
(`limits.serverAddresses` in `/v1/status`, 8 unless Intecion set another number). Each new address enrols by
|
||||
itself after `401 reverify`; beyond the limit the address used longest ago is dropped and gets `reverify`
|
||||
again. A site whose requests leave from many changing addresses (serverless hosting, a pool of egress
|
||||
addresses) must have the limit raised by Intecion, or it will enrol in a loop.
|
||||
- **A site with a token issued by hand cannot heal by itself.** It holds such a token because it cannot be
|
||||
called back, so "enrol again" is not open to it. Its client does **not** enrol on `401 reverify` or
|
||||
`401 invalid-token`; it stops and reports `relay-refused`, with what the administrator has to ask Intecion
|
||||
for: after `reverify` (the site sends from a server address Intecion does not know yet — after a move, or
|
||||
from a second server) that the new address be added; after `invalid-token` a new token. A client knows that
|
||||
its token was issued by hand because it was pasted into it; the service's answer does not say so.
|
||||
- A site on `localhost` or behind a firewall cannot be called back. Intecion can issue a token by hand; the
|
||||
site stores it the same way.
|
||||
- Use the token only from the site's server. Never print it, never send it to a browser.
|
||||
|
||||
## 3. Sending — `POST /v1/send`
|
||||
|
||||
Headers (`Bearer` in any case; one space; then the token exactly):
|
||||
|
||||
```
|
||||
Authorization: Bearer ims_…
|
||||
X-Intecion-Site: example.com
|
||||
Idempotency-Key: <16 to 128 characters of A–Z a–z 0–9 _ ->
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
Body ([`SendRequest`](schema.json)):
|
||||
|
||||
```json
|
||||
{
|
||||
"product": "iapl", "productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": ["[email protected]"],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "…", "html": "…",
|
||||
"attachments": [{ "filename": "cv.pdf", "contentType": "application/pdf", "content": "<base64>" }]
|
||||
}
|
||||
```
|
||||
|
||||
- **`kind`** (required): `form-notification`, `form-confirmation`, `account`, `security-alert`, `system`, `test`.
|
||||
Mail whose purpose the client does not know is `system`. **The kind decides which limits apply (§3.3), so a
|
||||
client must set it truthfully for its own mail:** `account` only for mail to an account holder (password
|
||||
reset, invitation), `form-confirmation` for mail to an address a visitor typed.
|
||||
- **`to`, `cc`, `bcc`**: bare addresses (`name@domain`), ASCII, no display names. At least one `to` (for every
|
||||
kind but `security-alert`). The total over the three lists is limited per site
|
||||
(`limits.recipientsPerMessage` in `/v1/status`; the schema's 50 is only the service's upper bound).
|
||||
- **`security-alert` is addressed by the service.** `to`, `cc` and `bcc` may be left out and are ignored;
|
||||
whoever controls a site cannot redirect its alerts. The service puts the site's host in front of the
|
||||
subject: `[example.com] …` — as it does for **any** mail of a site that has Intecion's own address among its
|
||||
recipients.
|
||||
- **`replyTo`**: one bare address. The sender address has no mailbox, so send one whenever a reply makes sense.
|
||||
- **`senderName`**: the display name. Optional; without it the mail leaves under the site's host. See §3.1.
|
||||
- **`subject`**: 1 to 300 characters, **no line breaks, no control characters, no characters that hide or
|
||||
reorder text** — Unicode categories Cc, Zl, Zp, Co, lone surrogates, and Cf (zero-width space, direction
|
||||
marks and overrides, word joiner, byte-order mark, tag characters) **except three that are ordinary text**:
|
||||
the zero-width joiner U+200D (inside emoji), the zero-width non-joiner U+200C (Persian and other scripts) and
|
||||
the soft hyphen U+00AD. A subject is often a visitor's own words: **the client strips what is not allowed
|
||||
before sending** (a regular expression for it: `/[\p{Cc}\p{Zl}\p{Zp}\p{Co}\p{Cs}]|(?![\u200C\u200D\u00AD])\p{Cf}/gu`);
|
||||
the service refuses, it does not repair, and a refused message is a lost one. A subject must not start with the
|
||||
service's name in brackets (`[Intecion Notifications Webservice] …`): that is how the service's own notices
|
||||
begin.
|
||||
- **`text` and/or `html`**: at least one. Together at most `limits.maxBodyBytes` (UTF-8).
|
||||
- **`senderName`**, **`subject`**: lengths are counted in characters (Unicode code points), not bytes.
|
||||
- **`attachments`**: `content` is base64 (standard alphabet, padded to a multiple of four, no line breaks).
|
||||
Decoded, all files together are at most `limits.maxAttachmentBytes`. File names: no path, no quotes, no
|
||||
control or invisible characters. Programs and scripts are refused by extension
|
||||
(`422 attachment-refused`, with `field` naming the file).
|
||||
- The sender address is fixed by the service. It adds `X-Intecion-Site: <host>` and `X-Intecion-Product: <product>`
|
||||
to the mail.
|
||||
|
||||
Answer ([`SendResponse`](schema.json)):
|
||||
|
||||
```json
|
||||
{ "ok": true, "id": "…", "messageId": "…", "replayed": false,
|
||||
"senderName": "Kancelaria Example", "warnings": [],
|
||||
"quota": { "hour": { "limit": 30, "remaining": 29 }, "day": { "limit": 200, "remaining": 199 } } }
|
||||
```
|
||||
|
||||
`200` means the back end accepted the message for delivery, not that it arrived.
|
||||
|
||||
### 3.1 The sender name
|
||||
|
||||
The service cleans the name and may replace it. A name that is not accepted is **not** a failed send: the mail
|
||||
leaves under the site's host instead, and the answer carries `"warnings": ["sender-name-replaced"]` and the
|
||||
name used in `senderName`.
|
||||
|
||||
Accepted: at most 64 characters; letters, digits, spaces and `. , & ' - ( ) /`; letters of one script only.
|
||||
The guard errs on the careful side and will now and then replace an honest name (one that contains a word
|
||||
from the list, or reads like a web address: "Dom.Pl"). **A client shows the warning in its panel, with the name
|
||||
that was used,** so that the site's owner can choose another.
|
||||
|
||||
Not accepted: `@ < > " \`, anything that looks like an e-mail or web address (the site's own host is allowed),
|
||||
and names on the service's list of names that are never a client's (mailbox providers, banks, "support",
|
||||
"security", "administrator", "no-reply" …). The list is the service's and can change without a new contract
|
||||
version.
|
||||
|
||||
### 3.2 `Idempotency-Key`
|
||||
|
||||
- One key per message; the same key on every retry of that message.
|
||||
- **"The same body" means the same bytes.** A client encodes a message to JSON **once**, keeps those bytes with
|
||||
the key, and sends exactly them on every retry. Encoding the same message again is not safe: another order of
|
||||
the fields, `\/` instead of `/`, or other spacing is another body.
|
||||
- The same key with the same bytes within 24 hours: no second mail; the first answer comes back with
|
||||
`"replayed": true`.
|
||||
- The same key with other bytes: `409 idempotency-conflict`.
|
||||
- A send that was refused or failed does not use up its key.
|
||||
|
||||
### 3.3 Limits
|
||||
|
||||
A message that would pass a limit is refused whole with `429 quota-exceeded` and `limit`:
|
||||
|
||||
| `limit` | Counted | Applies to |
|
||||
|---|---|---|
|
||||
| `hour` | messages in the last 60 minutes | every kind but `security-alert`. **`account` mail may use all of it; every other kind only four fifths** (24 of 30), so that a busy or abused form cannot use up the room for a password reset |
|
||||
| `day` | messages this UTC day | the same: four fifths (160 of 200) for everything but `account` |
|
||||
| `alerts` | `security-alert` messages this UTC day | `security-alert` only: a budget of its own (`limits.securityAlertsPerDay`, 20), outside `hour` and `day` in both directions — alerts use up nothing else, and nothing else can use up the alerts |
|
||||
| `recipient` | `form-confirmation` messages to one address this UTC day | `form-confirmation` only: it is for addresses a visitor typed into a form. Other mail to one address (a form's notification to the client's office) is never refused by it |
|
||||
| `new-recipients` | addresses this site has not mailed in the last 30 days, this UTC day | every kind but `account` and `security-alert`. **A form's confirmations may use four fifths of it** (40 of 50); the rest is kept for the site's other mail, so that addresses a stranger invents in a form cannot keep a notification from an office the site has not written to for a month. `account` mail is outside it altogether: a password reset goes to whoever asked |
|
||||
| `service` | all sites together this UTC day | every kind |
|
||||
|
||||
The numbers are the service's, per site, and are reported by `/v1/status` (`limits`; its `quota` is the whole
|
||||
hour and day). The `quota` in the answer to a send is what is left **for a message of that kind**. A refused or
|
||||
failed send costs no quota (failed ones are limited by themselves: 60 an hour per site, the sends that are
|
||||
with the mail back end at that moment counted in, then `rate-limited`, §1). With a limit below
|
||||
five nothing is set apart.
|
||||
|
||||
## 4. Status — `GET /v1/status`
|
||||
|
||||
`Authorization: Bearer ims_…`. Answers for a pending and a suspended site too, so a panel can say why mail does
|
||||
not go out ([`StatusResponse`](schema.json)):
|
||||
|
||||
```json
|
||||
{ "ok": true, "state": "active", "host": "example.com", "product": "iapl",
|
||||
"service": { "name": "Intecion Notifications Webservice", "version": "1.0.0", "contract": "1.7.1" },
|
||||
"sender": { "address": "[email protected]" },
|
||||
"limits": { "messagesPerHour": 30, "messagesPerDay": 200, "recipientsPerMessage": 10,
|
||||
"perRecipientPerDay": 10, "newRecipientsPerDay": 50,
|
||||
"maxBodyBytes": 512000, "maxAttachmentBytes": 10485760, "maxAttachments": 20 },
|
||||
"quota": { "hour": { "limit": 30, "remaining": 30 }, "day": { "limit": 200, "remaining": 200 } },
|
||||
"kinds": ["form-notification", "form-confirmation", "account", "security-alert", "system", "test"],
|
||||
"token": { "issuedAt": "2026-11-25T10:00:00.000Z", "rotateAfter": "2027-02-23T10:00:00.000Z" } }
|
||||
```
|
||||
|
||||
A client takes its attachment limit from `limits.maxAttachmentBytes`, never from a constant of its own.
|
||||
|
||||
## 5. Rotation — `POST /v1/rotate`
|
||||
|
||||
`Authorization: Bearer ims_…`, no body. When `token.rotateAfter` has passed (90 days after issue), the client
|
||||
asks for a new token. The answer carries it ([`RotateResponse`](schema.json)):
|
||||
|
||||
```json
|
||||
{ "ok": true, "token": "ims_…", "previousValidUntil": "2027-02-24T10:00:00.000Z" }
|
||||
```
|
||||
|
||||
- Store the new token at once. The previous one stays valid for 24 hours.
|
||||
- Only the **current** token can rotate. With several processes on one site, exactly one rotation wins; the
|
||||
others get `409 already-rotated` and read the shared store again.
|
||||
- If the answer is lost, the new token is lost: the old one works for 24 hours, then `401 invalid-token` leads
|
||||
to a new enrolment. A client that gets `already-rotated` and finds no newer token in its store enrols again
|
||||
at once instead of waiting for that.
|
||||
|
||||
## 6. Giving up the token — `POST /v1/revoke`
|
||||
|
||||
`Authorization: Bearer ims_…`, no body. Every token of the site stops working at once; `{ "ok": true }`. The
|
||||
site's state is kept. To send again the site enrols again.
|
||||
|
||||
## 7. `GET /health`
|
||||
|
||||
No authentication. `200 { "ok": true }` or `503 { "ok": false }`, nothing else. For an uptime check, not for a client.
|
||||
|
||||
## 8. Authentication, in one place
|
||||
|
||||
- The token is `ims_` and 43 characters. It is opaque; the service keeps only its SHA-256.
|
||||
- Every route except `/v1/enrol` and `/health` needs it, **and** needs the request to come from a server
|
||||
address the site enrolled from (IPv6: the same `/64`). A good token from another address gets `401 reverify`
|
||||
and nothing else — not even the site's state.
|
||||
- **A token belongs to one host and cannot act for another — and both sides hold it to that.**
|
||||
- **Every request with a token carries `X-Intecion-Site: <the site's own public host>`** (the host it
|
||||
enrolled as, lower case). Without the header: `400 invalid-request`. With a host that is not the token's:
|
||||
`403 host-mismatch` — nothing is sent, read, rotated or revoked.
|
||||
- **A client stores the host together with the token** (at the confirm endpoint: the host it is enrolling
|
||||
as) and, before it uses a token, compares that stored host with its own public host of this moment. When
|
||||
they differ the token is not its own — the database was copied from another site (staging from
|
||||
production, a restored backup of another project), or somebody pasted a foreign token: the client does not
|
||||
use it, forgets it, and enrols as itself.
|
||||
- A client that reads `/v1/status` compares the `host` in the answer with its own the same way.
|
||||
|
||||
This is a guard against an honest mistake, not against a thief — whoever steals a token can name its host;
|
||||
the address binding is what stops them. Without the guard, a copy of a site running on the same server as
|
||||
the original would send mail as the original, on the original's limits.
|
||||
|
||||
## 9. Versions
|
||||
|
||||
- `VERSION` is `major.minor.patch`. The major is the path prefix (`/v1`).
|
||||
- **Minor:** something was added that an older client need not know — a new optional request field, a new
|
||||
answer field, a new `kind`, a new error `code` (treat an unknown code by its `retryable`), a new warning.
|
||||
For that reason `code` and `warnings` are open strings in the schema, not closed lists.
|
||||
- **Before the first release** (the first `mail-relay-contract/v…` tag) these are development versions: any
|
||||
change of behaviour bumps the minor, and nobody is promised that an older copy still works. From the first
|
||||
tag on the rules above hold strictly.
|
||||
- **Patch:** wording, examples.
|
||||
- **Major:** anything else. The service keeps answering the previous major for as long as any released client
|
||||
speaks it.
|
||||
- `/v1/status` reports the contract version the service speaks. A client carries the `VERSION` of its copy.
|
||||
|
||||
## 10. The examples and the runner
|
||||
|
||||
Each file in `examples/` is one case:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "send-hour-quota",
|
||||
"title": "…",
|
||||
"given": { "site": "active", "quota": "hour-exhausted" },
|
||||
"request": { "method": "POST", "path": "/v1/send",
|
||||
"headers": { "authorization": "Bearer {{token}}", "idempotency-key": "{{idempotencyKey}}", "content-type": "application/json" },
|
||||
"schema": "SendRequest", "body": { } },
|
||||
"response": { "status": 429, "schema": "Error", "body": { "ok": false, "code": "quota-exceeded", "limit": "hour" } },
|
||||
"then": { "mails": 0 },
|
||||
"client": { "retry": false, "reEnrol": false, "status": "relay-quota" }
|
||||
}
|
||||
```
|
||||
|
||||
- **`given`** names the state the case needs; whoever runs the examples arranges it (table below).
|
||||
- **`request`** is sent as written, after `{{name}}` is replaced. `schema` names the `$defs` entry the body
|
||||
must match (left out when the body is wrong on purpose). `{ "$base64Bytes": n }` stands for the base64 of
|
||||
`n` bytes.
|
||||
- **`response.body`** is a subset: every field written must be there with that value; more may be there.
|
||||
- **`then`** says what must be true afterwards: `mails` (how many messages reached the back end in this case)
|
||||
and `mail` (fields of the one message).
|
||||
- **`client`** says what a client does with this answer: `retry`, `reEnrol`, and the suggested site status.
|
||||
Use it to test a client against a canned answer.
|
||||
- `"direction": "service-to-site"` marks a case that describes the call-back: the request is what the
|
||||
service sends, the response what the site's confirm endpoint answers.
|
||||
|
||||
### `given`
|
||||
|
||||
| Key | Values | Meaning |
|
||||
|---|---|---|
|
||||
| `site` | `none`, `pending`, `active`, `suspended` | State of `{{host}}` in the registry. Anything but `none` implies a token in `{{token}}` |
|
||||
| `listed` | `true`, `false` | Enrolment: whether `{{host}}` is on Intecion's list |
|
||||
| `callback` | `ok`, `not-found`, `wrong-confirmation`, `redirect`, `no-content` | Enrolment: how the site's confirm endpoint behaves. `no-content` answers a bare `204` |
|
||||
| `token` | `current`, `unknown`, `previous`, `none` | Which token `{{token}}` is. `previous` is a token replaced less than 24 hours ago. `none`: the header is left out |
|
||||
| `address` | `known`, `unknown` | Whether the request comes from an address the site enrolled from |
|
||||
| `quota` | `fresh`, `hour-exhausted`, `day-exhausted`, `recipient-exhausted`, `hour-share-used` | The site's counters. `recipient-exhausted`: `{{recipient}}` got the day's maximum of form confirmations. `hour-share-used`: mail other than `account` has used its four fifths of the hour |
|
||||
| `idempotency` | `fresh`, `sent-same`, `sent-other` | Whether `{{idempotencyKey}}` was already used: for this very body, or for another |
|
||||
| `backend` | `ok`, `recipient-suppressed`, `failure` | How the mail back end answers |
|
||||
|
||||
Variables: `{{host}}`, `{{token}}`, `{{nonce}}`, `{{idempotencyKey}}`, `{{recipient}}`, and — read from the
|
||||
service — `{{senderAddress}}`, `{{alertRecipient}}`.
|
||||
|
||||
### Running them
|
||||
|
||||
```js
|
||||
import { runExample } from './runner.mjs'
|
||||
|
||||
const driver = {
|
||||
// Arrange `given`; return the variables for {{…}}.
|
||||
async arrange(given, example) { return { host, token, nonce, idempotencyKey, recipient, senderAddress, alertRecipient } },
|
||||
// Send one request to the thing under test.
|
||||
async request({ method, path, headers, body }) { return { status, headers, body } },
|
||||
// Optional: validate `value` against schema.json#/$defs/<name>; return a list of problems.
|
||||
validate(name, value) { return [] },
|
||||
// Optional: the messages that reached the back end since arrange().
|
||||
async mails() { return [{ from, fromName, to, cc, bcc, replyTo, subject, headers }] },
|
||||
}
|
||||
|
||||
for (const example of examples) await runExample(example, driver) // throws on the first mismatch
|
||||
```
|
||||
|
||||
The service runs every example against the Worker under the local Workers runtime
|
||||
(`services/mail-relay/test/contract.test.ts`). A client's local stand-in for the service runs the same files.
|
||||
|
||||
**A stand-in is not the service.** The examples are chosen so that the rules stated in this document decide
|
||||
them (a sender name with an address in it; a file called `.exe`). The service's own lists — names that are
|
||||
never a client's, file types it does not carry — are not part of the contract, can change without a new
|
||||
version, and need not be reproduced: a stand-in approximates them, and a client must not rely on a name or a
|
||||
file type passing because its stand-in let it pass.
|
||||
|
||||
## 11. Using the contract in a client
|
||||
|
||||
Until a client lives in this repository it **copies** this folder (all of it, `CHECKSUMS` included) from a
|
||||
`mail-relay-contract/v…` tag, and has one test that runs `node checksums.mjs --check` on the copy, so a
|
||||
hand-edited copy fails. The copy's `VERSION` says which contract the client speaks.
|
||||
|
||||
Checklist for a client:
|
||||
|
||||
1. Constants: the base address, the contract version. No secret.
|
||||
2. A confirm endpoint (public; `404` unless it holds the nonce; the nonce looked up before any limiter, and
|
||||
only refused calls counted by it; constant-time compare, single use, answers the confirmation as the only output, keeps the earlier token until the new one is accepted).
|
||||
3. A token store that is never readable from outside and never printed — holding the token **and the host it
|
||||
was issued to**. Before every use: is that host still this site's own public host? If not, do not use the
|
||||
token; enrol as this site. Send `X-Intecion-Site` with every request that carries a token; on
|
||||
`403 host-mismatch` forget the token and enrol.
|
||||
4. Enrol on the first send without a token, after `invalid-token` and after `reverify` — unless the token was
|
||||
issued by hand: then stop and report (§2). Guard against two processes enrolling at once
|
||||
(`enrolment-in-progress`).
|
||||
5. One `Idempotency-Key` per message and one encoding of it, both kept across retries; at most three attempts,
|
||||
30 seconds each, ten seconds of waiting in all, only when `retryable`; an enrolment on the way does not
|
||||
count; "no answer", `in-progress` and an answer that is not the service's JSON (unless its status is 400 to
|
||||
499) are reported as not confirmed, never as not sent. No `Origin` or `Sec-Fetch-Site` header. Without
|
||||
storage for unsent mail: no retry after the report; consider keys derived from the record (§1).
|
||||
6. **Limit what a visitor can make the site send as `account` mail.** "Forgot password" for an address somebody
|
||||
types is a visitor's lever like a form: the service lets `account` mail use the whole hour and day and no
|
||||
limit per address, so thirty requests use up the site's hour. The client's own limiter (per address and per
|
||||
visitor) is what decides; the service cannot tell a wanted reset from an unwanted one.
|
||||
7. Strip from the subject what §3 does not allow (line breaks, control characters, direction marks and other
|
||||
invisible characters — not only line breaks); bare addresses only; the right `kind` for each mail.
|
||||
8. Read limits from `/v1/status`; rotate after `token.rotateAfter`.
|
||||
9. Run the examples: the `client` block of each against canned answers, and the whole set against your local
|
||||
stand-in.
|
||||
@@ -1 +0,0 @@
|
||||
1.7.1
|
||||
@@ -1,62 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// SHA-256 of every contract file, so a hand-edited copy is noticed.
|
||||
// node checksums.mjs --check compare the files with CHECKSUMS (exit 1 on any difference)
|
||||
// node checksums.mjs --write rewrite CHECKSUMS (only in the IWDL repository, when the contract changes)
|
||||
// Node only, no dependency. Works on a copy of this folder anywhere.
|
||||
import { createHash } from 'node:crypto'
|
||||
import { readFileSync, readdirSync, writeFileSync, existsSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const FIXED = ['README.md', 'CHANGELOG.md', 'VERSION', 'schema.json', 'runner.mjs', 'checksums.mjs']
|
||||
|
||||
function files() {
|
||||
const examples = readdirSync(join(here, 'examples'))
|
||||
.filter((f) => f.endsWith('.json'))
|
||||
.sort()
|
||||
.map((f) => `examples/${f}`)
|
||||
return [...FIXED, ...examples]
|
||||
}
|
||||
|
||||
function sums() {
|
||||
return files()
|
||||
.map((f) => `${createHash('sha256').update(readFileSync(join(here, f))).digest('hex')} ${f}`)
|
||||
.join('\n') + '\n'
|
||||
}
|
||||
|
||||
const mode = process.argv[2]
|
||||
if (mode === '--write') {
|
||||
writeFileSync(join(here, 'CHECKSUMS'), sums())
|
||||
console.log(`CHECKSUMS written (${files().length} files)`)
|
||||
} else if (mode === '--check') {
|
||||
if (!existsSync(join(here, 'CHECKSUMS'))) {
|
||||
console.error('CHECKSUMS is missing')
|
||||
process.exit(1)
|
||||
}
|
||||
const want = new Map(
|
||||
readFileSync(join(here, 'CHECKSUMS'), 'utf8').split('\n').filter(Boolean).map((l) => {
|
||||
const [sum, name] = l.split(' ')
|
||||
return [name, sum]
|
||||
}),
|
||||
)
|
||||
const have = new Map(sums().split('\n').filter(Boolean).map((l) => {
|
||||
const [sum, name] = l.split(' ')
|
||||
return [name, sum]
|
||||
}))
|
||||
const problems = []
|
||||
for (const [name, sum] of have) {
|
||||
if (!want.has(name)) problems.push(`not in CHECKSUMS: ${name}`)
|
||||
else if (want.get(name) !== sum) problems.push(`changed: ${name}`)
|
||||
}
|
||||
for (const name of want.keys()) if (!have.has(name)) problems.push(`missing: ${name}`)
|
||||
if (problems.length) {
|
||||
console.error(problems.join('\n'))
|
||||
console.error('\nThe contract files do not match CHECKSUMS. Copy them again from IWDL; do not edit a copy.')
|
||||
process.exit(1)
|
||||
}
|
||||
console.log(`contract ${readFileSync(join(here, 'VERSION'), 'utf8').trim()}: ${have.size} files match CHECKSUMS`)
|
||||
} else {
|
||||
console.error('usage: node checksums.mjs --check | --write')
|
||||
process.exit(2)
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"id": "callback-confirm-wordpress",
|
||||
"direction": "service-to-site",
|
||||
"title": "IAWL (WordPress) sites: the same call at the REST route addressed by query, which works with and without pretty permalinks",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/?rest_route=/iawl/v1/mail-relay/confirm",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"schema": "CallbackRequest",
|
||||
"body": {
|
||||
"nonce": "EXAMPLEnonceEXAMPLEnonceEXAMPLEnonce00000000",
|
||||
"token": "ims_EXAMPLEtokenEXAMPLEtokenEXAMPLEtoken0000000",
|
||||
"state": "active"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "CallbackResponse",
|
||||
"body": {
|
||||
"confirmation": "1d5818782053c1f5aae3f9abd898a530cf974c59526d240902c9e19619e0462b"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"id": "callback-confirm",
|
||||
"direction": "service-to-site",
|
||||
"title": "IAPL (Payload) sites: the call the service makes, and the only answer that enrols. confirmation = hex SHA-256 of nonce + \".\" + token",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/api/iapl/mail-relay/confirm",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"schema": "CallbackRequest",
|
||||
"body": {
|
||||
"nonce": "EXAMPLEnonceEXAMPLEnonceEXAMPLEnonce00000000",
|
||||
"token": "ims_EXAMPLEtokenEXAMPLEtokenEXAMPLEtoken0000000",
|
||||
"state": "active"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "CallbackResponse",
|
||||
"body": {
|
||||
"confirmation": "1d5818782053c1f5aae3f9abd898a530cf974c59526d240902c9e19619e0462b"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"id": "callback-unknown-nonce",
|
||||
"direction": "service-to-site",
|
||||
"title": "A call with a nonce the site does not hold: 404, nothing stored",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/api/iapl/mail-relay/confirm",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"schema": "CallbackRequest",
|
||||
"body": {
|
||||
"nonce": "UNKNOWNnonceUNKNOWNnonceUNKNOWNnonce00000000",
|
||||
"token": "ims_EXAMPLEtokenEXAMPLEtokenEXAMPLEtoken0000000",
|
||||
"state": "active"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 404
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"id": "enrol-address-literal",
|
||||
"title": "An address literal is not a host",
|
||||
"given": {
|
||||
"site": "none"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/enrol",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"body": {
|
||||
"host": "192.0.2.10",
|
||||
"nonce": "{{nonce}}",
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 403,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "host-not-allowed"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-refused"
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"id": "enrol-callback-no-content",
|
||||
"title": "An endpoint that answers 204 to anything is not a confirm endpoint",
|
||||
"given": {
|
||||
"site": "none",
|
||||
"listed": true,
|
||||
"callback": "no-content"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/enrol",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"schema": "EnrolRequest",
|
||||
"body": {
|
||||
"host": "{{host}}",
|
||||
"nonce": "{{nonce}}",
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 422,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "callback-failed",
|
||||
"reason": "status"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-refused"
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"id": "enrol-callback-not-found",
|
||||
"title": "Enrolment for a host whose confirm endpoint does not hold the nonce (a host the caller does not control) yields nothing",
|
||||
"given": {
|
||||
"site": "none",
|
||||
"listed": true,
|
||||
"callback": "not-found"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/enrol",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"schema": "EnrolRequest",
|
||||
"body": {
|
||||
"host": "{{host}}",
|
||||
"nonce": "{{nonce}}",
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 422,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "callback-failed",
|
||||
"reason": "status",
|
||||
"retryable": false
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-refused"
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"id": "enrol-callback-path-given",
|
||||
"title": "A site cannot say where it is to be called back: the path is fixed per product",
|
||||
"given": {
|
||||
"site": "none",
|
||||
"listed": true,
|
||||
"callback": "ok"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/enrol",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"body": {
|
||||
"host": "{{host}}",
|
||||
"callbackPath": "/api/iapl/mail-relay/confirm",
|
||||
"nonce": "{{nonce}}",
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 400,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "invalid-request",
|
||||
"field": "callbackPath"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"id": "enrol-callback-redirect",
|
||||
"title": "A redirect is never followed",
|
||||
"given": {
|
||||
"site": "none",
|
||||
"listed": true,
|
||||
"callback": "redirect"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/enrol",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"schema": "EnrolRequest",
|
||||
"body": {
|
||||
"host": "{{host}}",
|
||||
"nonce": "{{nonce}}",
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 422,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "callback-failed",
|
||||
"reason": "redirect"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-refused"
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"id": "enrol-callback-wrong-confirmation",
|
||||
"title": "A 200 answer without the right confirmation does not enrol",
|
||||
"given": {
|
||||
"site": "none",
|
||||
"listed": true,
|
||||
"callback": "wrong-confirmation"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/enrol",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"schema": "EnrolRequest",
|
||||
"body": {
|
||||
"host": "{{host}}",
|
||||
"nonce": "{{nonce}}",
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 422,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "callback-failed",
|
||||
"reason": "confirmation"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-refused"
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"id": "enrol-from-browser",
|
||||
"title": "A cross-site POST from a browser is refused",
|
||||
"given": {
|
||||
"site": "none",
|
||||
"listed": true,
|
||||
"callback": "ok"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/enrol",
|
||||
"headers": {
|
||||
"content-type": "application/json",
|
||||
"origin": "https://evil.example.net"
|
||||
},
|
||||
"schema": "EnrolRequest",
|
||||
"body": {
|
||||
"host": "{{host}}",
|
||||
"nonce": "{{nonce}}",
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 403,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "browser-not-allowed"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"id": "enrol-listed-active",
|
||||
"title": "A host on Intecion's list enrols and is active at once; the answer has no token",
|
||||
"given": {
|
||||
"site": "none",
|
||||
"listed": true,
|
||||
"callback": "ok"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/enrol",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"schema": "EnrolRequest",
|
||||
"body": {
|
||||
"host": "{{host}}",
|
||||
"nonce": "{{nonce}}",
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "EnrolResponse",
|
||||
"body": {
|
||||
"ok": true,
|
||||
"state": "active"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"id": "enrol-localhost",
|
||||
"title": "A local name cannot be enrolled",
|
||||
"given": {
|
||||
"site": "none"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/enrol",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"body": {
|
||||
"host": "shop.localhost",
|
||||
"nonce": "{{nonce}}",
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 403,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "host-not-allowed"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-refused"
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"id": "enrol-short-nonce",
|
||||
"title": "A short nonce is refused",
|
||||
"given": {
|
||||
"site": "none",
|
||||
"listed": true,
|
||||
"callback": "ok"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/enrol",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"body": {
|
||||
"host": "{{host}}",
|
||||
"nonce": "short",
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 400,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "invalid-request",
|
||||
"field": "nonce"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
{
|
||||
"id": "enrol-suspended",
|
||||
"title": "A suspended site cannot enrol its way back",
|
||||
"given": {
|
||||
"site": "suspended",
|
||||
"callback": "ok"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/enrol",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"schema": "EnrolRequest",
|
||||
"body": {
|
||||
"host": "{{host}}",
|
||||
"nonce": "{{nonce}}",
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 403,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "site-suspended"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-suspended"
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"id": "enrol-unlisted-pending",
|
||||
"title": "A host that is not on the list enrols and waits for approval",
|
||||
"given": {
|
||||
"site": "none",
|
||||
"listed": false,
|
||||
"callback": "ok"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/enrol",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"schema": "EnrolRequest",
|
||||
"body": {
|
||||
"host": "{{host}}",
|
||||
"nonce": "{{nonce}}",
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "EnrolResponse",
|
||||
"body": {
|
||||
"ok": true,
|
||||
"state": "pending"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-pending"
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"id": "health",
|
||||
"title": "Health says yes or no and nothing else",
|
||||
"given": {},
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"path": "/health",
|
||||
"headers": {}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "HealthResponse",
|
||||
"body": {
|
||||
"ok": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"id": "not-found",
|
||||
"title": "An unknown route",
|
||||
"given": {},
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"path": "/v2/send",
|
||||
"headers": {}
|
||||
},
|
||||
"response": {
|
||||
"status": 404,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "not-found"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"id": "revoke-ok",
|
||||
"title": "The site gives up its token",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/revoke",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"x-intecion-site": "{{host}}"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "RevokeResponse",
|
||||
"body": {
|
||||
"ok": true
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"id": "rotate-ok",
|
||||
"title": "The current token rotates; the answer carries the new one",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/rotate",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"x-intecion-site": "{{host}}"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "RotateResponse",
|
||||
"body": {
|
||||
"ok": true
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"id": "rotate-previous-token",
|
||||
"title": "A token that was already replaced cannot rotate",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"token": "previous"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/rotate",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"x-intecion-site": "{{host}}"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 409,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "already-rotated"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
{
|
||||
"id": "send-attachments-too-large",
|
||||
"title": "Attachments over the limit",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello.",
|
||||
"attachments": [
|
||||
{
|
||||
"filename": "big.pdf",
|
||||
"contentType": "application/pdf",
|
||||
"content": {
|
||||
"$base64Bytes": 10485761
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 413,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "too-large",
|
||||
"limit": "attachments"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-too-large"
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"id": "send-backend-failed",
|
||||
"title": "The back end fails; the client may retry with the same key",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"backend": "failure"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 502,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "backend-failed",
|
||||
"retryable": true
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": true,
|
||||
"reEnrol": false,
|
||||
"status": "relay-unreachable"
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"id": "send-bearer-any-case",
|
||||
"title": "The word \"Bearer\" in any case",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "SendResponse",
|
||||
"body": {
|
||||
"ok": true,
|
||||
"replayed": false,
|
||||
"senderName": "Kancelaria Example",
|
||||
"warnings": []
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 1
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
{
|
||||
"id": "send-day-quota",
|
||||
"title": "The daily limit refuses the message",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"quota": "day-exhausted"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 429,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "quota-exceeded",
|
||||
"limit": "day",
|
||||
"retryable": false
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-quota"
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"id": "send-display-name-recipient",
|
||||
"title": "Recipients are bare addresses",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"Jan <[email protected]>"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 400,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "invalid-request",
|
||||
"field": "to"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
{
|
||||
"id": "send-executable-attachment",
|
||||
"title": "A program is never carried",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello.",
|
||||
"attachments": [
|
||||
{
|
||||
"filename": "invoice.pdf.exe",
|
||||
"contentType": "application/pdf",
|
||||
"content": "TVqQAAMAAAA="
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 422,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "attachment-refused",
|
||||
"field": "attachments[0]"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-attachment-refused"
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"id": "send-from-browser",
|
||||
"title": "A request with an Origin header is refused whatever the token",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"origin": "https://evil.example.net",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 403,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "browser-not-allowed"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"id": "send-from-field",
|
||||
"title": "The sender address cannot be set",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello.",
|
||||
"from": "[email protected]"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 400,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "invalid-request",
|
||||
"field": "from"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
{
|
||||
"id": "send-headers-field",
|
||||
"title": "Free headers cannot be set",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello.",
|
||||
"headers": {
|
||||
"Return-Path": "[email protected]"
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 400,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "invalid-request",
|
||||
"field": "headers"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"id": "send-host-mismatch",
|
||||
"title": "A token used by a site that names another host (a copy of the site's database, a token pasted into the wrong site) is refused",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "copy-of-{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 403,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "host-mismatch",
|
||||
"retryable": false
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": true,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"id": "send-hour-quota-account",
|
||||
"title": "When other mail has used its share of the hour, account mail (a password reset) still goes out",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"quota": "hour-share-used"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "account",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "SendResponse",
|
||||
"body": {
|
||||
"ok": true
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 1
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
{
|
||||
"id": "send-hour-quota",
|
||||
"title": "The hourly limit refuses the message and says so",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"quota": "hour-exhausted"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 429,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "quota-exceeded",
|
||||
"limit": "hour",
|
||||
"retryable": false
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-quota"
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"id": "send-key-reused",
|
||||
"title": "The same Idempotency-Key for another message",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"idempotency": "sent-other"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 409,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "idempotency-conflict"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
{
|
||||
"id": "send-no-sender-name",
|
||||
"title": "Without a sender name the mail leaves under the host, with no warning",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "SendResponse",
|
||||
"body": {
|
||||
"ok": true,
|
||||
"senderName": "{{host}}",
|
||||
"warnings": []
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 1,
|
||||
"mail": {
|
||||
"fromName": "{{host}}"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"id": "send-no-token",
|
||||
"title": "No Authorization header",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"token": "none"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 401,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "invalid-token"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": true,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
{
|
||||
"id": "send-ok",
|
||||
"title": "An active site sends one message",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "SendResponse",
|
||||
"body": {
|
||||
"ok": true,
|
||||
"replayed": false,
|
||||
"senderName": "Kancelaria Example",
|
||||
"warnings": []
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 1,
|
||||
"mail": {
|
||||
"from": "{{senderAddress}}",
|
||||
"fromName": "Kancelaria Example",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"subject": "New enquiry",
|
||||
"headers": {
|
||||
"X-Intecion-Site": "{{host}}",
|
||||
"X-Intecion-Product": "iapl"
|
||||
}
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"id": "send-pending",
|
||||
"title": "A site waiting for approval sends nothing",
|
||||
"given": {
|
||||
"site": "pending"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 403,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "site-pending"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-pending"
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"id": "send-previous-token",
|
||||
"title": "A token replaced less than 24 hours ago still sends",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"token": "previous"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "SendResponse",
|
||||
"body": {
|
||||
"ok": true
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 1
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"id": "send-recipient-quota-other-kinds",
|
||||
"title": "Other mail to the same address is not refused by that limit (a form's notification to the client's office)",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"quota": "recipient-exhausted"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "SendResponse",
|
||||
"body": {
|
||||
"ok": true
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 1
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"id": "send-recipient-quota",
|
||||
"title": "A form's confirmation: one address gets only so many a day",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"quota": "recipient-exhausted"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-confirmation",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 429,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "quota-exceeded",
|
||||
"limit": "recipient"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-quota"
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"id": "send-recipient-suppressed",
|
||||
"title": "The back end refuses a suppressed recipient",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"backend": "recipient-suppressed"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 422,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "recipient-suppressed",
|
||||
"retryable": false
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-recipient-suppressed"
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"id": "send-replay",
|
||||
"title": "The same Idempotency-Key and body again: no second mail",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"idempotency": "sent-same"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "SendResponse",
|
||||
"body": {
|
||||
"ok": true,
|
||||
"replayed": true
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
{
|
||||
"id": "send-security-alert",
|
||||
"title": "A security alert is addressed by the service and marked with the site's host; the recipients in the request are ignored",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "security-alert",
|
||||
"to": [
|
||||
"[email protected]"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "SendResponse",
|
||||
"body": {
|
||||
"ok": true
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 1,
|
||||
"mail": {
|
||||
"to": [
|
||||
"{{alertRecipient}}"
|
||||
],
|
||||
"cc": [],
|
||||
"bcc": [],
|
||||
"subject": "[{{host}}] New enquiry"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
{
|
||||
"id": "send-sender-name-replaced",
|
||||
"title": "A sender name that looks like an address is replaced by the host; the mail still goes out",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "PayPal <[email protected]>",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "SendResponse",
|
||||
"body": {
|
||||
"ok": true,
|
||||
"senderName": "{{host}}",
|
||||
"warnings": [
|
||||
"sender-name-replaced"
|
||||
]
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 1,
|
||||
"mail": {
|
||||
"fromName": "{{host}}"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-name-replaced"
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"id": "send-subject-direction-mark",
|
||||
"title": "A direction override in the subject is refused: the client strips such characters first",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "Invoice fdp.exe",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 400,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "invalid-request",
|
||||
"field": "subject"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"id": "send-subject-imitates-service",
|
||||
"title": "A subject that starts like one of the service's own notices is refused",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "[Intecion Notifications Webservice] example.com waits for approval",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 400,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "invalid-request",
|
||||
"field": "subject"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"id": "send-subject-line-break",
|
||||
"title": "A line break in the subject (header injection) is refused, not repaired",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "Hello\r\nBcc: [email protected]",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 400,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "invalid-request",
|
||||
"field": "subject"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
{
|
||||
"id": "send-subject-visitor-text",
|
||||
"title": "A subject with what visitors write — an emoji made of several, a soft hyphen — is carried as it is",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "👩💻 Straßenbahn",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "SendResponse",
|
||||
"body": {
|
||||
"ok": true,
|
||||
"replayed": false,
|
||||
"senderName": "Kancelaria Example",
|
||||
"warnings": []
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 1,
|
||||
"mail": {
|
||||
"subject": "👩💻 Straßenbahn"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"id": "send-suspended",
|
||||
"title": "A suspended site sends nothing",
|
||||
"given": {
|
||||
"site": "suspended"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 403,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "site-suspended"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-suspended"
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"id": "send-text-plain",
|
||||
"title": "A form post (text/plain) is refused",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "text/plain",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 415,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "unsupported-media-type"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
{
|
||||
"id": "send-to-intecion-marked",
|
||||
"title": "Any mail of a site that reaches Intecion's own address gets the site's host in front of its subject",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "system",
|
||||
"to": [
|
||||
"{{alertRecipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "SendResponse",
|
||||
"body": {
|
||||
"ok": true
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 1,
|
||||
"mail": {
|
||||
"to": [
|
||||
"{{alertRecipient}}"
|
||||
],
|
||||
"subject": "[{{host}}] New enquiry"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
{
|
||||
"id": "send-too-many-recipients",
|
||||
"title": "More than ten recipients over To, CC and BCC",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"[email protected]",
|
||||
"[email protected]",
|
||||
"[email protected]",
|
||||
"[email protected]",
|
||||
"[email protected]",
|
||||
"[email protected]"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello.",
|
||||
"cc": [
|
||||
"[email protected]",
|
||||
"[email protected]",
|
||||
"[email protected]"
|
||||
],
|
||||
"bcc": [
|
||||
"[email protected]",
|
||||
"[email protected]"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 422,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "too-many-recipients"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-quota"
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"id": "send-unknown-address",
|
||||
"title": "A good token from a server address the site never enrolled from (a stolen token)",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"address": "unknown"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 401,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "reverify",
|
||||
"retryable": false
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": true,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"id": "send-unknown-token",
|
||||
"title": "A token the service does not know",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"token": "unknown"
|
||||
},
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"path": "/v1/send",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"idempotency-key": "{{idempotencyKey}}",
|
||||
"content-type": "application/json",
|
||||
"x-intecion-site": "{{host}}"
|
||||
},
|
||||
"schema": "SendRequest",
|
||||
"body": {
|
||||
"product": "iapl",
|
||||
"productVersion": "1.17.0",
|
||||
"kind": "form-notification",
|
||||
"to": [
|
||||
"{{recipient}}"
|
||||
],
|
||||
"replyTo": "[email protected]",
|
||||
"senderName": "Kancelaria Example",
|
||||
"subject": "New enquiry",
|
||||
"text": "Hello."
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 401,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "invalid-token"
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"mails": 0
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": true,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"id": "status-active",
|
||||
"title": "Status of an active site",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"path": "/v1/status",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"x-intecion-site": "{{host}}"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "StatusResponse",
|
||||
"body": {
|
||||
"ok": true,
|
||||
"state": "active",
|
||||
"host": "{{host}}",
|
||||
"product": "iapl",
|
||||
"service": {
|
||||
"name": "Intecion Notifications Webservice"
|
||||
},
|
||||
"sender": {
|
||||
"address": "{{senderAddress}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"id": "status-no-site-header",
|
||||
"title": "Every request with a token names its site",
|
||||
"given": {
|
||||
"site": "active"
|
||||
},
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"path": "/v1/status",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 400,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "invalid-request",
|
||||
"field": "X-Intecion-Site"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"id": "status-pending",
|
||||
"title": "Status answers for a pending site too",
|
||||
"given": {
|
||||
"site": "pending"
|
||||
},
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"path": "/v1/status",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"x-intecion-site": "{{host}}"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 200,
|
||||
"schema": "StatusResponse",
|
||||
"body": {
|
||||
"ok": true,
|
||||
"state": "pending"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": false,
|
||||
"status": "relay-pending"
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"id": "status-unknown-address",
|
||||
"title": "Status gives nothing to a token from an unknown address",
|
||||
"given": {
|
||||
"site": "active",
|
||||
"address": "unknown"
|
||||
},
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"path": "/v1/status",
|
||||
"headers": {
|
||||
"authorization": "Bearer {{token}}",
|
||||
"x-intecion-site": "{{host}}"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status": 401,
|
||||
"schema": "Error",
|
||||
"body": {
|
||||
"ok": false,
|
||||
"code": "reverify"
|
||||
}
|
||||
},
|
||||
"client": {
|
||||
"retry": false,
|
||||
"reEnrol": true,
|
||||
"status": null
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
// Contract test runner for the Intecion Notifications Webservice.
|
||||
// No dependency. Works in Node 20+ and in the Workers runtime (uses only WebCrypto, btoa and TextEncoder).
|
||||
// How to use it: README.md, "The examples and the runner".
|
||||
|
||||
export const CONTRACT_VERSION = '1.7.1'
|
||||
|
||||
export class ContractError extends Error {
|
||||
constructor(exampleId, message) {
|
||||
super(`[${exampleId}] ${message}`)
|
||||
this.name = 'ContractError'
|
||||
this.exampleId = exampleId
|
||||
}
|
||||
}
|
||||
|
||||
/** The confirmation a site's confirm endpoint answers with: lowercase hex SHA-256 of nonce + "." + token. */
|
||||
export async function confirmationFor(nonce, token) {
|
||||
const bytes = new TextEncoder().encode(`${nonce}.${token}`)
|
||||
const digest = await crypto.subtle.digest('SHA-256', bytes)
|
||||
return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
|
||||
/** Base64 of `n` zero bytes, built without holding the bytes. */
|
||||
export function base64OfBytes(n) {
|
||||
const full = Math.floor(n / 3)
|
||||
const rest = n % 3
|
||||
return 'AAAA'.repeat(full) + (rest === 1 ? 'AA==' : rest === 2 ? 'AAA=' : '')
|
||||
}
|
||||
|
||||
/** Replace {{name}} and { "$base64Bytes": n } everywhere in a value. Unknown names are an error. */
|
||||
export function expand(value, vars, exampleId = '?') {
|
||||
if (typeof value === 'string') {
|
||||
return value.replace(/\{\{([A-Za-z]+)\}\}/g, (_, name) => {
|
||||
if (vars[name] === undefined || vars[name] === null) {
|
||||
throw new ContractError(exampleId, `the driver's arrange() gave no value for {{${name}}}`)
|
||||
}
|
||||
return String(vars[name])
|
||||
})
|
||||
}
|
||||
if (Array.isArray(value)) return value.map((v) => expand(v, vars, exampleId))
|
||||
if (value && typeof value === 'object') {
|
||||
if (typeof value.$base64Bytes === 'number') return base64OfBytes(value.$base64Bytes)
|
||||
const out = {}
|
||||
for (const [k, v] of Object.entries(value)) out[k] = expand(v, vars, exampleId)
|
||||
return out
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
/** Every field of `expected` must be in `actual` with that value; `actual` may have more. Arrays must be equal. */
|
||||
export function subsetMismatch(actual, expected, path = '') {
|
||||
if (expected === null || typeof expected !== 'object') {
|
||||
return Object.is(actual, expected) ? null : `${path || 'value'}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`
|
||||
}
|
||||
if (Array.isArray(expected)) {
|
||||
if (!Array.isArray(actual) || actual.length !== expected.length) {
|
||||
return `${path || 'value'}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`
|
||||
}
|
||||
for (let i = 0; i < expected.length; i++) {
|
||||
const m = subsetMismatch(actual[i], expected[i], `${path}[${i}]`)
|
||||
if (m) return m
|
||||
}
|
||||
return null
|
||||
}
|
||||
if (actual === null || typeof actual !== 'object') {
|
||||
return `${path || 'value'}: expected an object, got ${JSON.stringify(actual)}`
|
||||
}
|
||||
for (const [k, v] of Object.entries(expected)) {
|
||||
const m = subsetMismatch(actual[k], v, path ? `${path}.${k}` : k)
|
||||
if (m) return m
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function headerLookup(headers) {
|
||||
const out = {}
|
||||
for (const [k, v] of Object.entries(headers ?? {})) out[k.toLowerCase()] = v
|
||||
return out
|
||||
}
|
||||
|
||||
/**
|
||||
* Run one example (direction site-to-service) against a driver. Throws ContractError on the first mismatch.
|
||||
* Returns { request, response, vars } for further checks by the caller.
|
||||
*/
|
||||
export async function runExample(example, driver) {
|
||||
const id = example.id
|
||||
if (example.direction === 'service-to-site') {
|
||||
throw new ContractError(id, 'this example describes the call-back; use runCallbackExample()')
|
||||
}
|
||||
const given = example.given ?? {}
|
||||
const vars = (await driver.arrange(given, example)) ?? {}
|
||||
|
||||
const headers = expand(example.request.headers ?? {}, given.token === 'none' ? { ...vars, token: '' } : vars, id)
|
||||
if (given.token === 'none') delete headers.authorization
|
||||
const body = example.request.body === undefined ? undefined : expand(example.request.body, vars, id)
|
||||
|
||||
if (example.request.schema && driver.validate) {
|
||||
const problems = driver.validate(example.request.schema, body)
|
||||
if (problems.length) throw new ContractError(id, `the example's request does not match ${example.request.schema}: ${problems.join('; ')}`)
|
||||
}
|
||||
|
||||
const request = { method: example.request.method, path: example.request.path, headers, body }
|
||||
const response = await driver.request(request)
|
||||
|
||||
if (response.status !== example.response.status) {
|
||||
throw new ContractError(id, `status: expected ${example.response.status}, got ${response.status} ${JSON.stringify(response.body)}`)
|
||||
}
|
||||
if (example.response.schema && driver.validate) {
|
||||
const problems = driver.validate(example.response.schema, response.body)
|
||||
if (problems.length) throw new ContractError(id, `the answer does not match ${example.response.schema}: ${problems.join('; ')}`)
|
||||
}
|
||||
if (example.response.body !== undefined) {
|
||||
const m = subsetMismatch(response.body, expand(example.response.body, vars, id))
|
||||
if (m) throw new ContractError(id, `body: ${m}`)
|
||||
}
|
||||
if (response.body && response.body.ok === false) {
|
||||
const got = headerLookup(response.headers)
|
||||
if (typeof response.body.retryAfter === 'number' && got['retry-after'] !== undefined && String(got['retry-after']) !== String(response.body.retryAfter)) {
|
||||
throw new ContractError(id, `Retry-After header (${got['retry-after']}) differs from retryAfter (${response.body.retryAfter})`)
|
||||
}
|
||||
if (example.client && typeof example.client.retry === 'boolean' && response.body.retryable !== example.client.retry) {
|
||||
throw new ContractError(id, `retryable: expected ${example.client.retry}, got ${response.body.retryable}`)
|
||||
}
|
||||
}
|
||||
const cors = headerLookup(response.headers)['access-control-allow-origin']
|
||||
if (cors !== undefined) throw new ContractError(id, 'the service must not send CORS headers')
|
||||
|
||||
if (example.then && driver.mails) {
|
||||
const mails = await driver.mails()
|
||||
if (typeof example.then.mails === 'number' && mails.length !== example.then.mails) {
|
||||
throw new ContractError(id, `mails handed to the back end: expected ${example.then.mails}, got ${mails.length}`)
|
||||
}
|
||||
if (example.then.mail) {
|
||||
const m = subsetMismatch(mails[0], expand(example.then.mail, vars, id), 'mail')
|
||||
if (m) throw new ContractError(id, m)
|
||||
}
|
||||
}
|
||||
return { request, response, vars }
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a call-back example against a site's confirm endpoint.
|
||||
* `site.prepare(body)` makes the site hold (or not hold) the nonce; `site.confirm(request)` calls the endpoint.
|
||||
*/
|
||||
export async function runCallbackExample(example, site) {
|
||||
const id = example.id
|
||||
if (example.direction !== 'service-to-site') throw new ContractError(id, 'not a call-back example')
|
||||
const holds = example.response.status === 200
|
||||
await site.prepare({ ...example.request.body, held: holds })
|
||||
const response = await site.confirm({ ...example.request })
|
||||
if (response.status !== example.response.status) {
|
||||
throw new ContractError(id, `status: expected ${example.response.status}, got ${response.status}`)
|
||||
}
|
||||
if (holds) {
|
||||
const expected = await confirmationFor(example.request.body.nonce, example.request.body.token)
|
||||
if (!response.body || response.body.confirmation !== expected) {
|
||||
throw new ContractError(id, 'the confirmation is not hex SHA-256 of nonce + "." + token')
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
@@ -1,624 +0,0 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://webservices.intecion.net/mail/contract/v1/schema.json",
|
||||
"title": "Intecion Notifications Webservice — wire contract v1",
|
||||
"description": "Bodies of every request and answer. Requests are closed (an unknown field is refused); answers are open (a client ignores fields it does not know).",
|
||||
"$defs": {
|
||||
"Host": {
|
||||
"description": "A public DNS name, lowercase, punycode for international names. No scheme, port, path or address literal.",
|
||||
"type": "string",
|
||||
"minLength": 4,
|
||||
"maxLength": 253,
|
||||
"pattern": "^(?=.{4,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]([a-z0-9-]{0,61}[a-z0-9])$"
|
||||
},
|
||||
"Product": {
|
||||
"description": "The client product. The list is the service's.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"iapl",
|
||||
"iawl"
|
||||
]
|
||||
},
|
||||
"ProductVersion": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 32,
|
||||
"pattern": "^[0-9A-Za-z][0-9A-Za-z.+_-]*$"
|
||||
},
|
||||
"Kind": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"form-notification",
|
||||
"form-confirmation",
|
||||
"account",
|
||||
"security-alert",
|
||||
"system",
|
||||
"test"
|
||||
]
|
||||
},
|
||||
"SiteState": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"pending",
|
||||
"active",
|
||||
"suspended"
|
||||
]
|
||||
},
|
||||
"Address": {
|
||||
"description": "A bare e-mail address. No display name, no angle brackets, no comment.",
|
||||
"type": "string",
|
||||
"minLength": 6,
|
||||
"maxLength": 254,
|
||||
"pattern": "^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@([A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?\\.)+[A-Za-z]([A-Za-z0-9-]{0,61}[A-Za-z0-9])$"
|
||||
},
|
||||
"Nonce": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9_-]{32,128}$"
|
||||
},
|
||||
"Token": {
|
||||
"description": "Opaque. Never logged, never shown.",
|
||||
"type": "string",
|
||||
"pattern": "^ims_[A-Za-z0-9_-]{43}$"
|
||||
},
|
||||
"Window": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"limit",
|
||||
"remaining"
|
||||
],
|
||||
"properties": {
|
||||
"limit": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"remaining": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"Quota": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"hour",
|
||||
"day"
|
||||
],
|
||||
"properties": {
|
||||
"hour": {
|
||||
"$ref": "#/$defs/Window"
|
||||
},
|
||||
"day": {
|
||||
"$ref": "#/$defs/Window"
|
||||
}
|
||||
}
|
||||
},
|
||||
"EnrolRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"host",
|
||||
"nonce",
|
||||
"product",
|
||||
"productVersion"
|
||||
],
|
||||
"properties": {
|
||||
"host": {
|
||||
"$ref": "#/$defs/Host"
|
||||
},
|
||||
"nonce": {
|
||||
"$ref": "#/$defs/Nonce"
|
||||
},
|
||||
"product": {
|
||||
"$ref": "#/$defs/Product"
|
||||
},
|
||||
"productVersion": {
|
||||
"$ref": "#/$defs/ProductVersion"
|
||||
}
|
||||
},
|
||||
"description": "No call-back path: the service calls the path fixed for the product (README §2)."
|
||||
},
|
||||
"EnrolResponse": {
|
||||
"description": "Never carries the token: it went to the site's confirm endpoint.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ok",
|
||||
"state"
|
||||
],
|
||||
"properties": {
|
||||
"ok": {
|
||||
"const": true
|
||||
},
|
||||
"state": {
|
||||
"$ref": "#/$defs/SiteState"
|
||||
}
|
||||
},
|
||||
"not": {
|
||||
"required": [
|
||||
"token"
|
||||
]
|
||||
}
|
||||
},
|
||||
"CallbackRequest": {
|
||||
"description": "Sent BY the service TO the site's confirm endpoint: POST https://<host><the product's confirm path>.",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"nonce",
|
||||
"token",
|
||||
"state"
|
||||
],
|
||||
"properties": {
|
||||
"nonce": {
|
||||
"$ref": "#/$defs/Nonce"
|
||||
},
|
||||
"token": {
|
||||
"$ref": "#/$defs/Token"
|
||||
},
|
||||
"state": {
|
||||
"$ref": "#/$defs/SiteState"
|
||||
}
|
||||
}
|
||||
},
|
||||
"CallbackResponse": {
|
||||
"description": "The site's answer: status 200, a body of at most 1024 bytes that is this JSON object and nothing else, within 8 seconds. confirmation = lowercase hex SHA-256 of the UTF-8 text nonce + \".\" + token.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"confirmation"
|
||||
],
|
||||
"properties": {
|
||||
"confirmation": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9a-f]{64}$"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Attachment": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"filename",
|
||||
"contentType",
|
||||
"content"
|
||||
],
|
||||
"properties": {
|
||||
"filename": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 255
|
||||
},
|
||||
"contentType": {
|
||||
"type": "string",
|
||||
"maxLength": 127,
|
||||
"pattern": "^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*/[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*$"
|
||||
},
|
||||
"content": {
|
||||
"description": "Base64, standard alphabet, no line breaks, padded: the length is a multiple of four. The pattern states the alphabet only — a pattern that also stated the length would overflow regular-expression engines on a 10 MB file; the service checks the length.",
|
||||
"type": "string",
|
||||
"minLength": 4,
|
||||
"pattern": "^[A-Za-z0-9+/]+={0,2}$"
|
||||
}
|
||||
}
|
||||
},
|
||||
"SendRequest": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"product",
|
||||
"productVersion",
|
||||
"kind",
|
||||
"subject"
|
||||
],
|
||||
"properties": {
|
||||
"product": {
|
||||
"$ref": "#/$defs/Product"
|
||||
},
|
||||
"productVersion": {
|
||||
"$ref": "#/$defs/ProductVersion"
|
||||
},
|
||||
"kind": {
|
||||
"$ref": "#/$defs/Kind"
|
||||
},
|
||||
"to": {
|
||||
"description": "Bare addresses. The number over to, cc and bcc together is limited per site: limits.recipientsPerMessage in /v1/status (the schema only states the service's upper bound).",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/$defs/Address"
|
||||
},
|
||||
"maxItems": 50
|
||||
},
|
||||
"cc": {
|
||||
"description": "Bare addresses. The number over to, cc and bcc together is limited per site: limits.recipientsPerMessage in /v1/status (the schema only states the service's upper bound).",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/$defs/Address"
|
||||
},
|
||||
"maxItems": 50
|
||||
},
|
||||
"bcc": {
|
||||
"description": "Bare addresses. The number over to, cc and bcc together is limited per site: limits.recipientsPerMessage in /v1/status (the schema only states the service's upper bound).",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/$defs/Address"
|
||||
},
|
||||
"maxItems": 50
|
||||
},
|
||||
"replyTo": {
|
||||
"$ref": "#/$defs/Address"
|
||||
},
|
||||
"senderName": {
|
||||
"description": "At most 256 characters (Unicode code points).",
|
||||
"type": "string",
|
||||
"maxLength": 256
|
||||
},
|
||||
"subject": {
|
||||
"description": "1 to 300 characters (code points). No line breaks, control characters or characters that hide or reorder text (README §3 has the exact rule and the three exceptions); must not start with the service's name in brackets.",
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 300
|
||||
},
|
||||
"text": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"html": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"attachments": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/$defs/Attachment"
|
||||
},
|
||||
"maxItems": 20
|
||||
}
|
||||
},
|
||||
"anyOf": [
|
||||
{
|
||||
"required": [
|
||||
"text"
|
||||
]
|
||||
},
|
||||
{
|
||||
"required": [
|
||||
"html"
|
||||
]
|
||||
}
|
||||
],
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"kind": {
|
||||
"const": "security-alert"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"kind"
|
||||
]
|
||||
},
|
||||
"else": {
|
||||
"required": [
|
||||
"to"
|
||||
],
|
||||
"properties": {
|
||||
"to": {
|
||||
"minItems": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"SendResponse": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ok",
|
||||
"id",
|
||||
"replayed",
|
||||
"senderName",
|
||||
"warnings",
|
||||
"quota"
|
||||
],
|
||||
"properties": {
|
||||
"ok": {
|
||||
"const": true
|
||||
},
|
||||
"id": {
|
||||
"description": "The service's id of this message in its log.",
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"messageId": {
|
||||
"description": "The back end's id, when it gave one.",
|
||||
"type": "string"
|
||||
},
|
||||
"replayed": {
|
||||
"description": "true when this Idempotency-Key was already sent and no second mail went out.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"senderName": {
|
||||
"description": "The name the mail left under.",
|
||||
"type": "string"
|
||||
},
|
||||
"warnings": {
|
||||
"description": "Known today: sender-name-replaced. A client ignores a warning it does not know.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"quota": {
|
||||
"description": "What is left for a message of the kind just sent.",
|
||||
"$ref": "#/$defs/Quota"
|
||||
}
|
||||
}
|
||||
},
|
||||
"StatusResponse": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ok",
|
||||
"state",
|
||||
"host",
|
||||
"product",
|
||||
"service",
|
||||
"sender",
|
||||
"limits",
|
||||
"quota",
|
||||
"kinds",
|
||||
"token"
|
||||
],
|
||||
"properties": {
|
||||
"ok": {
|
||||
"const": true
|
||||
},
|
||||
"state": {
|
||||
"$ref": "#/$defs/SiteState"
|
||||
},
|
||||
"host": {
|
||||
"$ref": "#/$defs/Host"
|
||||
},
|
||||
"product": {
|
||||
"$ref": "#/$defs/Product"
|
||||
},
|
||||
"service": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"version",
|
||||
"contract"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "The service's name, for a panel to show.",
|
||||
"type": "string"
|
||||
},
|
||||
"version": {
|
||||
"type": "string"
|
||||
},
|
||||
"contract": {
|
||||
"type": "string",
|
||||
"pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sender": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"address"
|
||||
],
|
||||
"properties": {
|
||||
"address": {
|
||||
"$ref": "#/$defs/Address"
|
||||
}
|
||||
}
|
||||
},
|
||||
"limits": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"messagesPerHour",
|
||||
"messagesPerDay",
|
||||
"recipientsPerMessage",
|
||||
"perRecipientPerDay",
|
||||
"newRecipientsPerDay",
|
||||
"maxBodyBytes",
|
||||
"maxAttachmentBytes",
|
||||
"maxAttachments"
|
||||
],
|
||||
"properties": {
|
||||
"messagesPerHour": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"messagesPerDay": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"recipientsPerMessage": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"perRecipientPerDay": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"newRecipientsPerDay": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"maxBodyBytes": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"maxAttachmentBytes": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"maxAttachments": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"serverAddresses": {
|
||||
"description": "Server addresses the site may send from at a time.",
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"securityAlertsPerDay": {
|
||||
"description": "Security alerts a day: a budget of their own, outside the hour and day limits.",
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"quota": {
|
||||
"$ref": "#/$defs/Quota"
|
||||
},
|
||||
"kinds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"token": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"issuedAt",
|
||||
"rotateAfter"
|
||||
],
|
||||
"properties": {
|
||||
"issuedAt": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"rotateAfter": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
},
|
||||
"senderName": {
|
||||
"description": "The name the last mail left under, when there was one.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"RotateResponse": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ok",
|
||||
"token",
|
||||
"previousValidUntil"
|
||||
],
|
||||
"properties": {
|
||||
"ok": {
|
||||
"const": true
|
||||
},
|
||||
"token": {
|
||||
"$ref": "#/$defs/Token"
|
||||
},
|
||||
"previousValidUntil": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
},
|
||||
"RevokeResponse": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ok"
|
||||
],
|
||||
"properties": {
|
||||
"ok": {
|
||||
"const": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"HealthResponse": {
|
||||
"description": "No detail on purpose — also when it says no: the one answer that is not an Error.",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"ok"
|
||||
],
|
||||
"properties": {
|
||||
"ok": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ErrorCode": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"invalid-request",
|
||||
"invalid-token",
|
||||
"reverify",
|
||||
"site-pending",
|
||||
"site-suspended",
|
||||
"host-not-allowed",
|
||||
"enrolment-closed",
|
||||
"enrolment-in-progress",
|
||||
"callback-failed",
|
||||
"host-mismatch",
|
||||
"browser-not-allowed",
|
||||
"not-found",
|
||||
"method-not-allowed",
|
||||
"unsupported-media-type",
|
||||
"idempotency-conflict",
|
||||
"in-progress",
|
||||
"already-rotated",
|
||||
"too-large",
|
||||
"too-many-recipients",
|
||||
"attachment-refused",
|
||||
"recipient-suppressed",
|
||||
"rate-limited",
|
||||
"quota-exceeded",
|
||||
"backend-failed",
|
||||
"unavailable",
|
||||
"internal"
|
||||
],
|
||||
"description": "The codes the service answers with today. The list grows with minor versions; that is why Error.code is an open string."
|
||||
},
|
||||
"Error": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ok",
|
||||
"code",
|
||||
"message",
|
||||
"retryable"
|
||||
],
|
||||
"properties": {
|
||||
"ok": {
|
||||
"const": false
|
||||
},
|
||||
"code": {
|
||||
"description": "One of ErrorCode today. A client that meets a code it does not know acts on `retryable`.",
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"message": {
|
||||
"description": "For a log or an administrator. English. Never shown to a visitor.",
|
||||
"type": "string"
|
||||
},
|
||||
"retryable": {
|
||||
"description": "true: the same request, with the same Idempotency-Key, may be sent again after a short wait.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"retryAfter": {
|
||||
"description": "Seconds.",
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"field": {
|
||||
"description": "With invalid-request: the field at fault. With attachment-refused: which file, as attachments[n] (n from 0).",
|
||||
"type": "string"
|
||||
},
|
||||
"limit": {
|
||||
"description": "With quota-exceeded: hour, day, alerts, recipient, new-recipients or service. With too-large: request, body or attachments.",
|
||||
"type": "string"
|
||||
},
|
||||
"reason": {
|
||||
"description": "With callback-failed: unreachable, timeout, redirect, status or confirmation.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -1,3 +1,2 @@
|
||||
# SQLite file for the dev sandbox (default: ./payload.db). Delete the file to start fresh.
|
||||
DATABASE_URI=file:./payload.db
|
||||
DATABASE_URL=mongodb://127.0.0.1/payload-plugin-template
|
||||
PAYLOAD_SECRET=YOUR_SECRET_HERE
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<!-- BEGIN:nextjs-agent-rules -->
|
||||
|
||||
## This is NOT the Next.js you know
|
||||
|
||||
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices.
|
||||
|
||||
This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean.
|
||||
|
||||
<!-- END:nextjs-agent-rules -->
|
||||
@@ -1,18 +0,0 @@
|
||||
import { notFound, permanentRedirect } from 'next/navigation.js'
|
||||
import { createPageRoute } from '@intecion/ipal-kit/rsc'
|
||||
|
||||
import { FormBlock } from '../../../../blocks/FormBlock.js'
|
||||
import * as content from '../../../../lib/content.js'
|
||||
import { sendForm } from '../actions.js'
|
||||
|
||||
export const revalidate = 3600
|
||||
|
||||
const route = createPageRoute(content, {
|
||||
blockProps: async ({ locale }) => ({ formTexts: await content.getFormTexts(locale), sendForm }),
|
||||
blocks: { formBlock: FormBlock },
|
||||
notFound,
|
||||
permanentRedirect,
|
||||
})
|
||||
export default route.Page
|
||||
export const generateMetadata = route.generateMetadata
|
||||
export const generateStaticParams = route.generateStaticParams
|
||||
@@ -1,7 +0,0 @@
|
||||
'use server'
|
||||
import { headers } from 'next/headers.js'
|
||||
import { createSubmitAction } from '@intecion/ipal-kit/server'
|
||||
|
||||
import { getCachedPayload } from '../../../lib/content.js'
|
||||
|
||||
export const sendForm = createSubmitAction({ getCachedPayload, headers })
|
||||
@@ -1,28 +0,0 @@
|
||||
import { notFound } from 'next/navigation.js'
|
||||
import { CookieBanner } from '@intecion/ipal-kit/client'
|
||||
import { SiteProviders } from '@intecion/ipal-kit/rsc'
|
||||
|
||||
import { getConfiguredLocales, getSiteShell } from '../../../lib/content.js'
|
||||
import './styles.css'
|
||||
|
||||
type Props = { children: React.ReactNode; params: Promise<{ locale: string }> }
|
||||
|
||||
export default async function LocaleLayout({ children, params }: Props) {
|
||||
const { locale } = await params
|
||||
if (!(await getConfiguredLocales()).includes(locale)) notFound()
|
||||
return (
|
||||
<html lang={locale}>
|
||||
<body>
|
||||
<SiteProviders banner={<CookieBanner controls="switch" equalChoice settings="detailed" />} logEndpoint="/api/ipal/consent" shell={await getSiteShell(locale)} stats={{ locale }}>
|
||||
<main>{children}</main>
|
||||
{/* A footer with links in the bottom-left corner: CookieButton must not cover them. */}
|
||||
<footer style={{ borderTop: '1px solid #e5e5e5', display: 'flex', gap: '1.5rem', marginTop: '60vh', padding: '1.5rem 1rem' }}>
|
||||
<a href={`/${locale}`}>Home</a>
|
||||
<a href={`/${locale}/kontakt`}>Kontakt</a>
|
||||
<a href={`/${locale}/polityka-prywatnosci`}>Polityka prywatności</a>
|
||||
</footer>
|
||||
</SiteProviders>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import { createNotFoundPage } from '@intecion/ipal-kit/rsc'
|
||||
|
||||
import { FormBlock } from '../../../blocks/FormBlock.js'
|
||||
import * as content from '../../../lib/content.js'
|
||||
|
||||
export default createNotFoundPage(content, { blocks: { formBlock: FormBlock }, fallback: <h1>404</h1> })
|
||||
@@ -1,10 +0,0 @@
|
||||
/* Sandbox look — in a project this is the design system. */
|
||||
body { font-family: system-ui, sans-serif; margin: 0 auto; max-width: 40rem; padding: 1rem; }
|
||||
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, 1fr); }
|
||||
.field { grid-column: span 2; } .half { grid-column: span 1; }
|
||||
.label, legend { display: block; font-weight: 600; margin-bottom: .25rem; }
|
||||
.input { border: 1px solid #999; border-radius: 6px; box-sizing: border-box; padding: .5rem; width: 100%; }
|
||||
.choices { border: 0; display: grid; gap: .25rem; margin: 0; padding: 0; } .choice { display: flex; gap: .5rem; }
|
||||
.error { color: #b00020; } .progress { color: #555; } .step-title { font-size: 1.25rem; font-weight: 700; }
|
||||
.actions { display: flex; gap: .5rem; margin-top: 1rem; } .btn { background: #111; border: 0; border-radius: 6px; color: #fff; padding: .6rem 1rem; }
|
||||
.btn-secondary { background: #ddd; color: #111; } .success { background: #e7f7ec; padding: 1rem; }
|
||||
@@ -1,106 +1,6 @@
|
||||
import { TOTPField as TOTPField_3eb2cc20d1a2569c2ccbafcee15bd128 } from '@clocklimited/payload-2fa/rsc'
|
||||
import { OverviewComponent as OverviewComponent_a8a977ebc872c5d5ea7ee689724c0860 } from '@payloadcms/plugin-seo/client'
|
||||
import { MetaTitleComponent as MetaTitleComponent_a8a977ebc872c5d5ea7ee689724c0860 } from '@payloadcms/plugin-seo/client'
|
||||
import { MetaDescriptionComponent as MetaDescriptionComponent_a8a977ebc872c5d5ea7ee689724c0860 } from '@payloadcms/plugin-seo/client'
|
||||
import { MetaDescriptionCheck as MetaDescriptionCheck_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { MetaImageComponent as MetaImageComponent_a8a977ebc872c5d5ea7ee689724c0860 } from '@payloadcms/plugin-seo/client'
|
||||
import { PreviewComponent as PreviewComponent_a8a977ebc872c5d5ea7ee689724c0860 } from '@payloadcms/plugin-seo/client'
|
||||
import { RscEntryLexicalCell as RscEntryLexicalCell_44fe37237e0ebf4470c9990d8cb7b07e } from '@payloadcms/richtext-lexical/rsc'
|
||||
import { RscEntryLexicalField as RscEntryLexicalField_44fe37237e0ebf4470c9990d8cb7b07e } from '@payloadcms/richtext-lexical/rsc'
|
||||
import { LexicalDiffComponent as LexicalDiffComponent_44fe37237e0ebf4470c9990d8cb7b07e } from '@payloadcms/richtext-lexical/rsc'
|
||||
import { InlineToolbarFeatureClient as InlineToolbarFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { HorizontalRuleFeatureClient as HorizontalRuleFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { UploadFeatureClient as UploadFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { BlockquoteFeatureClient as BlockquoteFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { RelationshipFeatureClient as RelationshipFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { LinkFeatureClient as LinkFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { ChecklistFeatureClient as ChecklistFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { OrderedListFeatureClient as OrderedListFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { UnorderedListFeatureClient as UnorderedListFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { IndentFeatureClient as IndentFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { AlignFeatureClient as AlignFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { HeadingFeatureClient as HeadingFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { ParagraphFeatureClient as ParagraphFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { InlineCodeFeatureClient as InlineCodeFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { SuperscriptFeatureClient as SuperscriptFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { SubscriptFeatureClient as SubscriptFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { StrikethroughFeatureClient as StrikethroughFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { UnderlineFeatureClient as UnderlineFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { BoldFeatureClient as BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { ItalicFeatureClient as ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864 } from '@payloadcms/richtext-lexical/client'
|
||||
import { CookieScanButton as CookieScanButton_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { FaviconCheck as FaviconCheck_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { IntegrationStatusBanner as IntegrationStatusBanner_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { MaskedField as MaskedField_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { TestEmailButton as TestEmailButton_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { RowLabel as RowLabel_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { CookieReviewTab as CookieReviewTab_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { CookieSiteCheckTab as CookieSiteCheckTab_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { AdminIcon as AdminIcon_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { AdminLogo as AdminLogo_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { IntecionCredit as IntecionCredit_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { StatsNavLink as StatsNavLink_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { CookieCrawlAlert as CookieCrawlAlert_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { StatsWidget as StatsWidget_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { IntegrationAlerts as IntegrationAlerts_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { TotpRedirectProvider as TotpRedirectProvider_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { TOTPSetup as TOTPSetup_3eb2cc20d1a2569c2ccbafcee15bd128 } from '@clocklimited/payload-2fa/rsc'
|
||||
import { TOTPVerify as TOTPVerify_3eb2cc20d1a2569c2ccbafcee15bd128 } from '@clocklimited/payload-2fa/rsc'
|
||||
import { CookieApprovalView as CookieApprovalView_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { StatsView as StatsView_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { CollectionCards as CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1 } from '@payloadcms/next/rsc'
|
||||
|
||||
/** @type import('payload').ImportMap */
|
||||
export const importMap = {
|
||||
"@clocklimited/payload-2fa/rsc#TOTPField": TOTPField_3eb2cc20d1a2569c2ccbafcee15bd128,
|
||||
"@payloadcms/plugin-seo/client#OverviewComponent": OverviewComponent_a8a977ebc872c5d5ea7ee689724c0860,
|
||||
"@payloadcms/plugin-seo/client#MetaTitleComponent": MetaTitleComponent_a8a977ebc872c5d5ea7ee689724c0860,
|
||||
"@payloadcms/plugin-seo/client#MetaDescriptionComponent": MetaDescriptionComponent_a8a977ebc872c5d5ea7ee689724c0860,
|
||||
"@intecion/ipal-kit/admin#MetaDescriptionCheck": MetaDescriptionCheck_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@payloadcms/plugin-seo/client#MetaImageComponent": MetaImageComponent_a8a977ebc872c5d5ea7ee689724c0860,
|
||||
"@payloadcms/plugin-seo/client#PreviewComponent": PreviewComponent_a8a977ebc872c5d5ea7ee689724c0860,
|
||||
"@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell": RscEntryLexicalCell_44fe37237e0ebf4470c9990d8cb7b07e,
|
||||
"@payloadcms/richtext-lexical/rsc#RscEntryLexicalField": RscEntryLexicalField_44fe37237e0ebf4470c9990d8cb7b07e,
|
||||
"@payloadcms/richtext-lexical/rsc#LexicalDiffComponent": LexicalDiffComponent_44fe37237e0ebf4470c9990d8cb7b07e,
|
||||
"@payloadcms/richtext-lexical/client#InlineToolbarFeatureClient": InlineToolbarFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#HorizontalRuleFeatureClient": HorizontalRuleFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#UploadFeatureClient": UploadFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#BlockquoteFeatureClient": BlockquoteFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#RelationshipFeatureClient": RelationshipFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#LinkFeatureClient": LinkFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#ChecklistFeatureClient": ChecklistFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#OrderedListFeatureClient": OrderedListFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#UnorderedListFeatureClient": UnorderedListFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#IndentFeatureClient": IndentFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#AlignFeatureClient": AlignFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#HeadingFeatureClient": HeadingFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#ParagraphFeatureClient": ParagraphFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#InlineCodeFeatureClient": InlineCodeFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#SuperscriptFeatureClient": SuperscriptFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#SubscriptFeatureClient": SubscriptFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#StrikethroughFeatureClient": StrikethroughFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#UnderlineFeatureClient": UnderlineFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#BoldFeatureClient": BoldFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@payloadcms/richtext-lexical/client#ItalicFeatureClient": ItalicFeatureClient_e70f5e05f09f93e00b997edb1ef0c864,
|
||||
"@intecion/ipal-kit/admin#CookieScanButton": CookieScanButton_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#FaviconCheck": FaviconCheck_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#IntegrationStatusBanner": IntegrationStatusBanner_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#MaskedField": MaskedField_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#TestEmailButton": TestEmailButton_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#RowLabel": RowLabel_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#CookieReviewTab": CookieReviewTab_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#CookieSiteCheckTab": CookieSiteCheckTab_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#AdminIcon": AdminIcon_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#AdminLogo": AdminLogo_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#IntecionCredit": IntecionCredit_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#StatsNavLink": StatsNavLink_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#CookieCrawlAlert": CookieCrawlAlert_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#StatsWidget": StatsWidget_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#IntegrationAlerts": IntegrationAlerts_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#TotpRedirectProvider": TotpRedirectProvider_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@clocklimited/payload-2fa/rsc#TOTPSetup": TOTPSetup_3eb2cc20d1a2569c2ccbafcee15bd128,
|
||||
"@clocklimited/payload-2fa/rsc#TOTPVerify": TOTPVerify_3eb2cc20d1a2569c2ccbafcee15bd128,
|
||||
"@intecion/ipal-kit/admin#CookieApprovalView": CookieApprovalView_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#StatsView": StatsView_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@payloadcms/next/rsc#CollectionCards": CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
export { mcpGET as GET, mcpPOST as POST } from '../../../lib/content.js'
|
||||
export const dynamic = 'force-dynamic'
|
||||
@@ -1,2 +0,0 @@
|
||||
export { llmsRoute as GET } from '../../lib/content.js'
|
||||
export const dynamic = 'force-dynamic'
|
||||
@@ -0,0 +1,12 @@
|
||||
import configPromise from '@payload-config'
|
||||
import { getPayload } from 'payload'
|
||||
|
||||
export const GET = async (request: Request) => {
|
||||
const payload = await getPayload({
|
||||
config: configPromise,
|
||||
})
|
||||
|
||||
return Response.json({
|
||||
message: 'This is an example of a custom route.',
|
||||
})
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import type { FormNotificationTexts } from '@intecion/ipal-kit'
|
||||
import { RenderForm, type SendFormAction } from '@intecion/ipal-kit/rsc'
|
||||
|
||||
// Classes set once per project — here plain names the sandbox CSS styles.
|
||||
const formClasses = {
|
||||
actions: 'actions', back: 'btn btn-secondary', choice: 'choice', choices: 'choices', error: 'error', field: 'field',
|
||||
fieldHalf: 'half', fields: 'grid', form: 'form', formError: 'error', input: 'input', label: 'label', progress: 'progress',
|
||||
select: 'input', stepTitle: 'step-title', submit: 'btn', success: 'success', textarea: 'input',
|
||||
}
|
||||
|
||||
type Props = { form?: unknown; formTexts?: FormNotificationTexts; locale: string; sendForm?: SendFormAction }
|
||||
|
||||
export function FormBlock({ form, formTexts, locale, sendForm }: Props) {
|
||||
if (!formTexts || !sendForm) return null
|
||||
return <RenderForm action={sendForm} classNames={formClasses} form={form as never} locale={locale} requiredMark=" *" texts={formTexts} />
|
||||
}
|
||||
+3
-4
@@ -1,13 +1,12 @@
|
||||
import { expect, test } from '@playwright/test'
|
||||
|
||||
import { devUser } from './helpers/credentials.js'
|
||||
|
||||
// this is an example Playwright e2e test
|
||||
test('should render admin panel logo', async ({ page }) => {
|
||||
await page.goto('/admin')
|
||||
|
||||
// login
|
||||
await page.fill('#field-email', devUser.email)
|
||||
await page.fill('#field-password', devUser.password)
|
||||
await page.fill('#field-email', '[email protected]')
|
||||
await page.fill('#field-password', 'test')
|
||||
await page.click('.form-submit button')
|
||||
|
||||
// should show dashboard
|
||||
|
||||
@@ -2,9 +2,3 @@ export const devUser = {
|
||||
email: '[email protected]',
|
||||
password: '[email protected]',
|
||||
}
|
||||
|
||||
/** Second dev login with the editor role — for checking what editors see. */
|
||||
export const devEditor = {
|
||||
email: '[email protected]',
|
||||
password: '[email protected]',
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
export const i18nConfig = {
|
||||
defaultLocale: 'pl',
|
||||
locales: [
|
||||
{ code: 'pl', label: 'Polski' },
|
||||
{ code: 'en', label: 'English' },
|
||||
],
|
||||
} as const
|
||||
@@ -0,0 +1,52 @@
|
||||
import type { Payload } from 'payload'
|
||||
|
||||
import config from '@payload-config'
|
||||
import { createPayloadRequest, getPayload } from 'payload'
|
||||
import { afterAll, beforeAll, describe, expect, test } from 'vitest'
|
||||
|
||||
import { customEndpointHandler } from '../src/endpoints/customEndpointHandler.js'
|
||||
|
||||
let payload: Payload
|
||||
|
||||
afterAll(async () => {
|
||||
await payload.destroy()
|
||||
})
|
||||
|
||||
beforeAll(async () => {
|
||||
payload = await getPayload({ config })
|
||||
})
|
||||
|
||||
describe('Plugin integration tests', () => {
|
||||
test('should query custom endpoint added by plugin', async () => {
|
||||
const request = new Request('http://localhost:3000/api/my-plugin-endpoint', {
|
||||
method: 'GET',
|
||||
})
|
||||
|
||||
const payloadRequest = await createPayloadRequest({ config, request })
|
||||
const response = await customEndpointHandler(payloadRequest)
|
||||
expect(response.status).toBe(200)
|
||||
|
||||
const data = await response.json()
|
||||
expect(data).toMatchObject({
|
||||
message: 'Hello from custom endpoint',
|
||||
})
|
||||
})
|
||||
|
||||
test('can create post with custom text field added by plugin', async () => {
|
||||
const post = await payload.create({
|
||||
collection: 'posts',
|
||||
data: {
|
||||
addedByPlugin: 'added by plugin',
|
||||
},
|
||||
})
|
||||
expect(post.addedByPlugin).toBe('added by plugin')
|
||||
})
|
||||
|
||||
test('plugin creates and seeds plugin-collection', async () => {
|
||||
expect(payload.collections['plugin-collection']).toBeDefined()
|
||||
|
||||
const { docs } = await payload.find({ collection: 'plugin-collection' })
|
||||
|
||||
expect(docs).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
@@ -1,11 +0,0 @@
|
||||
// Sandbox data layer — the same one line every project has (PROGRAMISTA §2.7).
|
||||
import config from '@payload-config'
|
||||
import { createContentHelpers } from '@intecion/ipal-kit'
|
||||
|
||||
import { i18nConfig } from '../i18n.config.js'
|
||||
|
||||
export const {
|
||||
generatePageMetadata, generateStaticParams, getCachedPayload, getConfiguredLocales, getFormTexts, getLinkOptions,
|
||||
getNotFoundPage, getPageJsonLd, getSettings, getSiteShell, healthRoute, i18n, llmsRoute, mcpGET, mcpPOST,
|
||||
resolveNav, resolvePageRedirect, resolveRoute,
|
||||
} = createContentHelpers({ baseUrl: 'http://localhost:3000', config, i18n: i18nConfig, mcp: { serverName: 'ipal-sandbox' } })
|
||||
@@ -15,6 +15,7 @@ const nextConfig = {
|
||||
|
||||
return webpackConfig
|
||||
},
|
||||
serverExternalPackages: ['mongodb-memory-server'],
|
||||
}
|
||||
|
||||
export default withPayload(nextConfig, { devBundleServerPackages: false })
|
||||
|
||||
+27
-1083
File diff suppressed because it is too large
Load Diff
+66
-71
@@ -1,14 +1,13 @@
|
||||
import { payloadTotp } from '@clocklimited/payload-2fa'
|
||||
import { sqliteAdapter } from '@payloadcms/db-sqlite'
|
||||
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
||||
import { iapl } from '../src/index.js'
|
||||
import { ipalKit } from 'ipal-kit'
|
||||
import { MongoMemoryReplSet } from 'mongodb-memory-server'
|
||||
import path from 'path'
|
||||
import { buildConfig } from 'payload'
|
||||
import sharp from 'sharp'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
import { testEmailAdapter } from './helpers/testEmailAdapter.js'
|
||||
import { i18nConfig } from './i18n.config.js'
|
||||
import { seed } from './seed.js'
|
||||
|
||||
const filename = fileURLToPath(import.meta.url)
|
||||
@@ -18,74 +17,70 @@ if (!process.env.ROOT_DIR) {
|
||||
process.env.ROOT_DIR = dirname
|
||||
}
|
||||
|
||||
export default buildConfig({
|
||||
admin: {
|
||||
importMap: {
|
||||
baseDir: path.resolve(dirname),
|
||||
},
|
||||
},
|
||||
collections: [
|
||||
{
|
||||
slug: 'users',
|
||||
auth: true,
|
||||
fields: [],
|
||||
},
|
||||
{
|
||||
slug: 'pages',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', localized: true },
|
||||
{ name: 'slug', type: 'text', index: true, localized: true },
|
||||
{
|
||||
name: 'layout',
|
||||
type: 'blocks',
|
||||
blocks: [{ slug: 'formBlock', fields: [{ name: 'form', type: 'relationship', relationTo: 'forms' }] }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
slug: 'posts',
|
||||
fields: [{ name: 'title', type: 'text' }],
|
||||
},
|
||||
{
|
||||
slug: 'media',
|
||||
fields: [],
|
||||
upload: { staticDir: path.resolve(dirname, 'media') },
|
||||
},
|
||||
],
|
||||
const buildConfigWithMemoryDB = async () => {
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
const memoryDB = await MongoMemoryReplSet.create({
|
||||
replSet: {
|
||||
count: 3,
|
||||
dbName: 'payloadmemory',
|
||||
},
|
||||
})
|
||||
|
||||
db: sqliteAdapter({
|
||||
client: {
|
||||
url: process.env.DATABASE_URI || 'file:./payload.db',
|
||||
process.env.DATABASE_URL = `${memoryDB.getUri()}&retryWrites=true`
|
||||
}
|
||||
|
||||
return buildConfig({
|
||||
admin: {
|
||||
importMap: {
|
||||
baseDir: path.resolve(dirname),
|
||||
},
|
||||
},
|
||||
}),
|
||||
editor: lexicalEditor(),
|
||||
email: testEmailAdapter,
|
||||
onInit: async (payload) => {
|
||||
await seed(payload)
|
||||
},
|
||||
plugins: [
|
||||
iapl({
|
||||
access: { authCollection: 'users' },
|
||||
i18n: i18nConfig,
|
||||
consentLog: true,
|
||||
// Cookie review + "Crawl site" (needs IAPL_COOKIE_SCAN_URL / IAPL_COOKIE_SCAN_TOKEN and a running services/cookie-crawler).
|
||||
cookieScanner: { crawl: true },
|
||||
forms: {},
|
||||
seo: { collections: ['posts', 'pages'] },
|
||||
stats: true,
|
||||
// 2FA is enforced by default; the dev sandbox opts out so it boots without an authenticator.
|
||||
// IPAL_DEV_2FA=1 turns it on (first-login setup and verify screens).
|
||||
twoFactor: process.env.IPAL_DEV_2FA ? { issuer: 'IAPL dev', plugin: payloadTotp } : false,
|
||||
// Panel logo/icon from Site settings and the technology support credit.
|
||||
whiteLabel: true,
|
||||
collections: [
|
||||
{
|
||||
slug: 'users',
|
||||
auth: true,
|
||||
fields: [],
|
||||
},
|
||||
{
|
||||
slug: 'posts',
|
||||
fields: [],
|
||||
},
|
||||
{
|
||||
slug: 'media',
|
||||
fields: [],
|
||||
upload: { staticDir: path.resolve(dirname, 'media') },
|
||||
},
|
||||
],
|
||||
|
||||
db: sqliteAdapter({
|
||||
client: {
|
||||
url: process.env.DATABASE_URI || 'file:./payload.db',
|
||||
},
|
||||
}),
|
||||
],
|
||||
secret: process.env.PAYLOAD_SECRET || 'test-secret_key',
|
||||
sharp,
|
||||
typescript: {
|
||||
// Payload's dev init spawns `payload generate:types` on every start/recompile and never
|
||||
// reaps it, so each restart left an orphan. Run `pnpm generate:types` when types change.
|
||||
autoGenerate: false,
|
||||
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
||||
},
|
||||
})
|
||||
editor: lexicalEditor(),
|
||||
email: testEmailAdapter,
|
||||
onInit: async (payload) => {
|
||||
await seed(payload)
|
||||
},
|
||||
plugins: [
|
||||
ipalKit({
|
||||
access: { authCollection: 'users' },
|
||||
i18n: {
|
||||
defaultLocale: 'pl',
|
||||
locales: [
|
||||
{ code: 'pl', label: 'Polski' },
|
||||
{ code: 'en', label: 'English' },
|
||||
],
|
||||
},
|
||||
seo: { collections: ['posts', 'pages'] },
|
||||
}),
|
||||
],
|
||||
secret: process.env.PAYLOAD_SECRET || 'test-secret_key',
|
||||
sharp,
|
||||
typescript: {
|
||||
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export default buildConfigWithMemoryDB()
|
||||
|
||||
+1
-52
@@ -1,6 +1,6 @@
|
||||
import type { Payload } from 'payload'
|
||||
|
||||
import { devEditor, devUser } from './helpers/credentials.js'
|
||||
import { devUser } from './helpers/credentials.js'
|
||||
|
||||
export const seed = async (payload: Payload) => {
|
||||
const { totalDocs } = await payload.count({
|
||||
@@ -22,55 +22,4 @@ export const seed = async (payload: Payload) => {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const editors = await payload.count({ collection: 'users', where: { email: { equals: devEditor.email } } })
|
||||
if (!editors.totalDocs) {
|
||||
await payload.create({ collection: 'users', data: { ...devEditor, roles: ['editor'] } })
|
||||
}
|
||||
|
||||
await seedContactPage(payload)
|
||||
}
|
||||
|
||||
const text = (t: string) => ({
|
||||
root: {
|
||||
children: [{ children: [{ detail: 0, format: 0, mode: 'normal', style: '', text: t, type: 'text', version: 1 }], direction: null, format: '', indent: 0, type: 'paragraph', version: 1 }],
|
||||
direction: null,
|
||||
format: '',
|
||||
indent: 0,
|
||||
type: 'root',
|
||||
version: 1,
|
||||
},
|
||||
})
|
||||
|
||||
/** A step-by-step quote form on /pl/kontakt — exercises RenderForm, steps, choice lists, dates. */
|
||||
async function seedContactPage(payload: Payload) {
|
||||
const { totalDocs } = await payload.count({ collection: 'pages', where: { slug: { equals: 'kontakt' } } })
|
||||
if (totalDocs) {return}
|
||||
const form = await payload.create({
|
||||
collection: 'forms',
|
||||
data: {
|
||||
confirmationMessage: text('Dziękujemy! Odezwiemy się w ciągu 24 godzin.'),
|
||||
confirmationType: 'message',
|
||||
fields: [
|
||||
{ blockType: 'step', title: 'Kontakt' },
|
||||
{ name: 'name', blockType: 'text', label: 'Imię i nazwisko', required: true, width: 50 },
|
||||
{ name: 'email', blockType: 'email', label: 'E-mail', required: true, width: 50 },
|
||||
{ blockType: 'step', description: 'Zaznacz, czego potrzebujesz.', title: 'Projekt' },
|
||||
{ name: 'services', blockType: 'checkboxGroup', label: 'Usługi', options: [{ label: 'Strona WWW', value: 'www' }, { label: 'SEO', value: 'seo' }, { label: 'Kampanie', value: 'ads' }], required: true },
|
||||
{ name: 'budget', blockType: 'radio', label: 'Budżet', options: [{ label: 'do 10 tys.', value: 's' }, { label: 'powyżej 10 tys.', value: 'l' }], required: true },
|
||||
{ name: 'deadline', blockType: 'date', label: 'Termin' },
|
||||
{ blockType: 'message', message: text('Dane przetwarzamy wyłącznie w celu przygotowania wyceny.') },
|
||||
{ name: 'consent', blockType: 'checkbox', label: 'Zgadzam się na przetwarzanie danych.', required: true },
|
||||
],
|
||||
submitButtonLabel: 'Wyślij zapytanie',
|
||||
title: 'Wycena',
|
||||
} as never,
|
||||
})
|
||||
const page = await payload.create({
|
||||
collection: 'pages',
|
||||
data: { layout: [{ blockType: 'formBlock', form: form.id }], slug: 'kontakt', title: 'Kontakt' } as never,
|
||||
})
|
||||
await payload.updateGlobal({ slug: 'site-settings' as never, data: { siteName: 'Sandbox' } as never })
|
||||
payload.logger.info(`[seed] /pl/kontakt (page ${page.id}, form ${form.id})`)
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user