diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..949c6da --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,37 @@ +--- +name: Bug report +about: A plugin behaves differently from what its README or its types promise +labels: bug +--- + +## Which plugin + + + +## What happened + +## What you expected + +## Minimal reproduction + +The smallest app that shows it — the `createApp` call, the plugin options, and the route: + +```ts + +``` + +## Environment + +- Plugin version: +- `@green-tea/core` version: +- Runtime and version: +- OS: + + diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..a9bf880 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,14 @@ +# Design questions and "should this live here?" threads do not fit a form, and they are +# worth having. Keep the blank option available. +blank_issues_enabled: true + +contact_links: + - name: Security vulnerability + url: https://github.com/Expressive-Tea/green-tea-plugins/security/advisories/new + about: Report it privately instead. Never in a public issue — see SECURITY.md. + - name: A bug in green-tea itself + url: https://github.com/Expressive-Tea/green-tea/issues/new + about: The framework lives in its own repository. Plugins are types-only against it. + - name: Documentation + url: https://green-tea.expressive-tea.io/docs/ + about: How to wire a route, a module, a plugin or a runtime adapter. diff --git a/.github/ISSUE_TEMPLATE/plugin_proposal.md b/.github/ISSUE_TEMPLATE/plugin_proposal.md new file mode 100644 index 0000000..138e6e7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/plugin_proposal.md @@ -0,0 +1,35 @@ +--- +name: Plugin proposal +about: Suggest something for the official set — before writing it +labels: enhancement +--- + +## What it does + + + +## Why it belongs in the official set + + + +## Runtimes it could support + + + +## Shape + +```ts +// The call as a user would write it. +``` diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..7eaae4b --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,26 @@ +> **Base branch:** on GitHub this must target `contrib`, not `main`. You can change it above before you submit — and [here is why](https://github.com/Expressive-Tea/green-tea-plugins/blob/main/CONTRIBUTING.md#where-to-send-your-changes). Delete this line once the base is right. + +## What this changes + + + +Closes # + +## Which runtimes you ran + + + +- [ ] `npm test` (Node) +- [ ] `npm run test:deno` +- [ ] `npm run test:bun` +- [ ] `npm run test:edge` + +## Checklist + +- [ ] The base branch above is `contrib` +- [ ] Commits are signed off (`git commit -s`) +- [ ] `lint`, `format:check`, `typecheck`, `complexity:check` and `deno publish --dry-run` pass locally +- [ ] New behaviour has a test +- [ ] Core is still imported as `import type` only — never a value import +- [ ] If `engines` changed, the package README's Runtimes table changed with it +- [ ] A breaking change is under `### Breaking`, first in that package's CHANGELOG diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml index 3f4a239..6b7286f 100644 --- a/.github/workflows/promote.yml +++ b/.github/workflows/promote.yml @@ -1,25 +1,27 @@ name: Promote → GitHub -# Promotion. Runs on GITEA ONLY. Mirrors one branch to the public GitHub repo and nothing else: +# Promotion. Runs on GITEA ONLY. Mirrors two branches to the public GitHub repo and nothing else: # -# main → GitHub main +# main → GitHub main what has been promoted +# develop → GitHub contrib what outside contributors fork from and target # -# Development happens on `develop` and feature branches, and those stay Gitea-private — which is -# why this is a workflow rather than Gitea's push-mirror, since that would expose every branch. +# Feature branches stay private, which is why this is a workflow rather than a push-mirror — that +# would expose every branch. # -# Only `main`, and no `contrib` counterpart yet: unlike core, this repository has no documented -# flow for outside contributions, so there is nothing for a second mirrored branch to serve. Add -# one here when that flow exists, rather than shipping a branch nobody targets. +# `contrib` exists because CONTRIBUTING.md sends people there. A pull request against `main` would +# put the two forges out of step, so contributors need a branch that tracks current development, +# and this is it. Same arrangement as core. # -# The push is NOT forced. A refusal means GitHub `main` holds commits that Gitea `main` does not, -# which is a question to answer rather than an obstacle to remove. +# Neither push is forced. For `contrib` that is the guard rather than a limitation: the push is +# refused exactly when `contrib` holds external merges nobody has carried into `develop` yet. Carry +# them, and the next develop push fast-forwards. # # Tags are deliberately NOT mirrored, and `--tags` is left off the push for the same reason. These # packages publish to JSR, where a version can never be replaced or removed — so promoting a tag # has to stay a decision someone takes deliberately, never a side effect of promoting a branch. on: push: - branches: [main] + branches: [main, develop] jobs: push-github: @@ -33,12 +35,17 @@ jobs: env: GH_TOKEN: ${{ secrets.GH_PROMOTE_TOKEN }} run: | + case "$GITHUB_REF_NAME" in + main) target=main ;; + develop) target=contrib ;; + *) echo "::error::promote runs for main and develop only, got '$GITHUB_REF_NAME'"; exit 1 ;; + esac if [ -z "$GH_TOKEN" ]; then - echo "::error::GH_PROMOTE_TOKEN is not set on this repository. Add it in Settings → Actions → Secrets; core carries the same secret." + echo "::error::GH_PROMOTE_TOKEN is not set on this repository. Add it in Settings → Actions → Secrets." exit 1 fi git remote add github "https://x-access-token:${GH_TOKEN}@github.com/Expressive-Tea/green-tea-plugins.git" - if ! git push github "HEAD:refs/heads/main"; then - echo "::error::GitHub main has commits that Gitea main does not. Find out what they are and carry them; never force this push." + if ! git push github "HEAD:refs/heads/${target}"; then + echo "::error::GitHub ${target} has commits that ${GITHUB_REF_NAME} does not. For contrib that means external merges not yet carried into develop — carry them (CONTRIBUTING.md); never force this push." exit 1 fi diff --git a/AGENTS.md b/AGENTS.md index e6281f0..155e334 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -24,22 +24,31 @@ Run all of them before proposing anything as finished. CI runs each one and each ## Two forges -Development lives on a private Gitea instance. GitHub is a downstream mirror that receives `main` -and nothing else. On the development forge `develop` and `main` are protected; everything lands -through a pull request. +Development lives on a private Gitea instance. GitHub is a downstream mirror that receives `main`, +and `develop` under the name `contrib`. On the development forge `develop` and `main` are +protected; everything lands through a pull request. ``` feature/* → develop → main → [promote.yml] → GitHub main + │ │ + └─[promote.yml]┴──→ GitHub contrib ← external pull requests ``` -`promote.yml` runs on the development forge only. Feature branches and `develop` stay private, -which is why this is a workflow rather than a push-mirror — that would expose every branch. The -push is never forced: a refusal means GitHub `main` holds commits the source `main` does not, and -that is a question to answer, not an obstacle to remove. +`promote.yml` runs on the development forge only. Feature branches stay private, which is why this +is a workflow rather than a push-mirror — that would expose every branch. Neither push is forced. -There is **no `contrib` branch** here, unlike core. This repository has no documented flow for -outside contributions yet, so there is nothing for a second mirrored branch to serve. Add one when -that flow exists rather than shipping a branch nobody targets. +`contrib` exists because `CONTRIBUTING.md` sends people there: a pull request against `main` would +put the two forges out of step, so contributors need a branch that tracks current development. For +`contrib` the unforced push is the guard rather than a limitation — it is refused exactly when +`contrib` holds external merges nobody has carried into `develop` yet. Carry them and the next +develop push fast-forwards. Never force it. + +**External contributions** arrive on `contrib`. Merge the pull request there, fetch `contrib` into +a branch on the development forge, then open a pull request from it into `develop` and merge that. +The next develop push mirrors back and fast-forwards, because `develop` now contains everything +`contrib` had. Merge rather than rebase: rewriting a contributor's SHAs gains nothing and leaves +`contrib` holding commits `develop` does not have, which is exactly the state that makes the +mirror push refuse. **Tags are not mirrored.** These packages publish to JSR, where a version can never be replaced or removed, so promoting a tag has to stay a deliberate act rather than a side effect of promoting a diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..48dee4b --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,89 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at **compliance@expressive-tea.io**. All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the reporter of any incident. + +If you would rather write to a named person than to an address, the project lead reads +diego.resendez@expressive-tea.io. Reports about a maintainer, including the project lead, +should go to compliance@expressive-tea.io, which is not maintained by the project team. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of actions. + +**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..8195005 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,136 @@ +# Contributing to green-tea plugins + +Thanks for your interest. These are the official plugins for [green-tea](https://github.com/Expressive-Tea/green-tea), and they are open source — but nobody pushes directly. Everything lands through a reviewed pull request with a **DCO sign-off**. + +## Where to send your changes + +Development happens on a private Gitea instance. The GitHub repository is a downstream mirror: it receives `main`, and `develop` under the name `contrib`. + +**Open your pull request against `contrib`. Not `main`.** `main` is a mirror of what has been promoted, and merging into it puts the two forges out of step and breaks the next promotion. A maintainer reviews on `contrib` and carries your commits upstream with your authorship and your sign-off intact. Because `contrib` follows `develop`, you are working against current code rather than the last promotion. + +### Worked example + +```bash +# fork Expressive-Tea/green-tea-plugins on GitHub, then +git clone git@github.com:/green-tea-plugins.git +cd green-tea-plugins +git remote add upstream https://github.com/Expressive-Tea/green-tea-plugins.git +git fetch upstream + +# branch from contrib, not from main +git checkout -b fix/sweep-interval upstream/contrib + +# ... make the change, add a test ... + +git commit -s -m "fix(rate-limit): clear the sweep timer on close" +git push origin fix/sweep-interval +``` + +`contrib` moves whenever development does. If your branch has been open a while, rebase onto the current `contrib` before pushing again. + +## Developer Certificate of Origin (DCO) + +We use the [Developer Certificate of Origin](./DCO) instead of a CLA. It is a per-commit affirmation that you have the right to submit your work under this project's license. No copyright assignment, no paperwork. + +**Every commit must be signed off:** + +```bash +git commit -s -m "feat(metrics): count upgrades separately" +``` + +That appends `Signed-off-by: Your Name `, and the name and email must match your real `git config`. Commits without it are rejected by CI. + +Forgot on a range you already wrote? + +```bash +git rebase --signoff +``` + +Or on the commit you just made: `git commit --amend -s`, then `git push --force-with-lease`. + +## Local setup + +Node 22 or newer, which is what every package's `engines` requires and what CI runs. + +```bash +npm install +``` + +That points `core.hooksPath` at `.githooks/`, which installs a pre-commit gate: it formats and lint-fixes your staged sources, then refuses the commit if `lint` or `complexity:check` fails. It exists so CI tells you nothing you could not have heard locally. Confirm it took: + +```bash +git config core.hooksPath # should print .githooks +``` + +If it prints nothing, run `git config core.hooksPath .githooks` yourself. + +**There is no build step.** These packages publish to JSR, which transpiles the TypeScript and generates the declarations, so what you edit in `src/` is what ships. `deno publish --dry-run` is the closest thing to a build, and CI runs it. + +## Before you open a pull request + +Run what CI runs: + +```bash +npm run lint +npm run format:check +npm run typecheck +npm run complexity:check +npm test # Node: every package's contract tests plus the workspace checks +npm run test:deno # packages whose engines declare deno +npm run test:bun # packages whose engines declare bun +npm run test:edge # packages whose engines declare workerd +deno publish --dry-run # the actual publish path, including the slow-types check +``` + +You are not expected to install every runtime to fix a typo. You are expected to run the one your change touches, and to say in the pull request which ones you ran. + +## What a plugin has to do + +The full list is in [`AGENTS.md`](./AGENTS.md), and `test/workspace.test.ts` enforces most of it so you will hear about a miss before a reviewer has to mention it. The parts that catch people out: + +- **A plugin imports core as types only.** `import type { Plugin } from '@green-tea/core'` — never a value import. A type import leaves nothing behind when it compiles, which is what keeps a plugin from dragging a second copy of the framework into someone's application. +- **Runtimes are declared twice and the two must agree:** as `engines` keys, and as the Runtimes table in the package README, which lists all four with a reason beside every one that is not supported. Nobody should have to open an issue to find out where a plugin runs. +- **Errors carry the `Symbol.for('green-tea.http-error')` brand** rather than extending `HttpError`. A lint rule and the workspace test enforce it. +- **A breaking change goes under `### Breaking`**, first in that package's CHANGELOG. +- **Relative imports carry the `.ts` extension.** Deno and JSR require it. + +## Commits + +Follow [Conventional Commits](https://www.conventionalcommits.org/), scoped to the package where that helps: `fix(jwt):`, `feat(metrics):`, `docs:`. Focus the message on the *why*. Do not add AI co-authoring attribution. + +## Working with AI assistance + +Use one if it helps. There is no permission to ask for and nothing to declare. + +What we do ask is that you read what it hands you before it becomes a pull request. Every line that lands here is reviewed by a person, by hand, and usually that person is one person. A diff its own author has not read moves that work onto them, and turns review into proofreading — which is the thing review is worst at. + +So go through the diff the way you would go through a stranger's, because that is what it is. If you cannot say why a line is there, it is not ready to send. + +**What assistants tend to get wrong in this repository in particular:** + +- They turn `import type` into a value import, which is the one thing a plugin must never do to core. +- They add a build. There isn't one, and `package.json` deliberately carries no `main`, `exports` or `files`. +- They write for Node and assume the rest follows. `npm test` does not cover Deno, Bun or workerd. +- They update `engines` without the README table, or the table without `engines`. + +**Where you are unsure, say so** — not as a disclosure, as a pointer. "I am not confident about the Deno path here" tells a reviewer where to spend their attention, and that is worth more than a pull request that merely looks clean. + +None of this changes the sign-off. `Signed-off-by` says you have the right to submit the work under this project's license, and that stays true however the text was produced. + +If your assistant reads repository instructions, [`AGENTS.md`](./AGENTS.md) has the conventions. + +## Proposing a new plugin + +Open an issue before writing it. The useful question is not whether the code is good — it is whether the thing belongs in the official set at all, and that is cheaper to answer in a paragraph than in a pull request you have already written. + +A plugin that depends on a service, a vendor or a protocol we cannot test is usually better as your own package. Nothing stops you publishing `@you/green-tea-whatever` to JSR or npm, and that is a first-class outcome rather than a consolation. + +## Reporting issues + +Open an issue with a minimal reproduction: which plugin and version, the runtime and version, and the smallest app that shows the problem. + +**Except for security.** If what you found is exploitable, do not open an issue — an issue is world-readable the moment you press the button. See [`SECURITY.md`](./SECURITY.md). + +## Code of conduct + +By taking part here you agree to the [Code of Conduct](./CODE_OF_CONDUCT.md), which is the Contributor Covenant 2.1. Reports go to compliance@expressive-tea.io. diff --git a/DCO b/DCO new file mode 100644 index 0000000..8201f99 --- /dev/null +++ b/DCO @@ -0,0 +1,37 @@ +Developer Certificate of Origin +Version 1.1 + +Copyright (C) 2004, 2006 The Linux Foundation and its contributors. +1 Letterman Drive +Suite D4700 +San Francisco, CA, 94129 + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + + +Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +(b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +(c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +(d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..5fc3d33 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,47 @@ +# Security Policy + +## Reporting a vulnerability + +Email **security@expressive-tea.io**. Please do not open a public issue for something exploitable — an issue is world-readable from the moment you press the button, and that is the one thing a security report cannot be. + +Include whatever you have: which plugin, the version, the runtime, and the smallest app that shows it. A route and a request is usually enough. If you have a working exploit, send it; if you only have a suspicion, send that instead of sitting on it. + +You can also report privately through GitHub's [security advisory form](https://github.com/Expressive-Tea/green-tea-plugins/security/advisories/new), which reaches the same people. + +## What happens next + +Acknowledgement within **5 working days**. A verdict on whether we agree it is a vulnerability within **15**. If we agree, you get the fix timeline and a heads-up before the advisory goes public. If we don't, you get the reasoning rather than silence. + +Those numbers are deliberately slower than the 24 to 48 hours you will see quoted elsewhere. That figure describes vendors and coordinators — organizations with someone on rotation. This project is one person. A number that only holds in a good week is worse than an honest one. + +Which is why there is an escape hatch, and you should use it. **If you have no acknowledgement after 10 working days**, write directly to diego.resendez@expressive-tea.io. If that is also met with silence, consider yourself released from any embargo and disclose as you see fit. You will not have done anything wrong: a project that goes quiet on a security report has spent whatever claim it had on your patience. + +## Disclosure window + +We ask for **90 days** from your report before public disclosure, or until the fix ships, whichever comes first. If the fix is out in a week, so is the advisory. + +If a vulnerability is being actively exploited, the window is however long it takes us to ship, and we will say so rather than hold you to 90 days while users are being attacked. + +We publish a GitHub advisory for anything that affects a released version, and credit you by the name you ask for. Say so if you would rather not be named. + +There is no bug bounty and no money, which we would rather state here than leave you to find out after the work. + +## Supported versions + +Nothing has been released yet. When the first versions ship, only the most recent of each package receives fixes, and this section gets the real table. + +## Scope + +Each package is its own scope, and a report should name which one. + +**In scope** — anything in a package's `src/` that ships: + +- `@green-tea/jwt` — key loading, signature verification, claim validation, and anything that could make a bad token verify or a good one fail open. +- `@green-tea/rate-limit` — anything that lets a caller exceed a configured limit, or that lets one caller's traffic count against another's. +- `@green-tea/metrics` — anything that puts request data into the metrics output that should not be there, since that endpoint is often less protected than the app around it. + +**Out of scope:** the test suites, dev-only tooling, and anything that requires an attacker to already control your application code. A misconfiguration is not a vulnerability — a plugin that does what you told it to, where what you told it was unsafe, belongs in an issue or the documentation rather than here. If you are unsure which one you have, send it and let us decide. + +**Vulnerabilities in green-tea itself** go to the [core repository](https://github.com/Expressive-Tea/green-tea/security/advisories/new) instead. Same address, same people, but the advisory needs to live where the fix does. + +Advisories in a dependency — `jose`, for instance — are worth telling us about, and we handle them as ordinary dependency updates rather than as vulnerabilities in these packages. If the advisory is exploitable *through* the way a plugin uses that dependency, that is a real report and we want it.