@mushi-mushi/svelte 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Kenji Sakuramoto
3
+ Copyright (c) 2026 Kenji Sakuramoto / Kensaurus 合同会社
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,77 +2,32 @@
2
2
 
3
3
  > **Your AI wrote it. Mushi tells you why it broke.**
4
4
 
5
- Svelte SDK for Mushi Mushi bug reporting. **API-only** — captures errors and submits reports but does not include the widget UI. Add `@mushi-mushi/web` alongside this package for the full Shadow DOM widget experience.
5
+ Adds a bug-report widget to your Svelte or SvelteKit app. When a user reports
6
+ a problem, [Mushi Mushi](https://github.com/kensaurus/mushi-mushi) gets a
7
+ screenshot, the route and recent console and network events, explains the
8
+ cause in plain English, and hands your editor a fix to start from.
6
9
 
7
- > **One-command setup:** `npx mushi-mushi` auto-detects Svelte / SvelteKit and installs this package + `@mushi-mushi/web`.
8
- >
9
- > **Other frameworks:** [`@mushi-mushi/react`](https://npmjs.com/package/@mushi-mushi/react) · [`@mushi-mushi/vue`](https://npmjs.com/package/@mushi-mushi/vue) · [`@mushi-mushi/angular`](https://npmjs.com/package/@mushi-mushi/angular) · [`@mushi-mushi/react-native`](https://npmjs.com/package/@mushi-mushi/react-native) · [`@mushi-mushi/capacitor`](https://npmjs.com/package/@mushi-mushi/capacitor) · [`@mushi-mushi/web`](https://npmjs.com/package/@mushi-mushi/web) (vanilla JS)
10
-
11
- ## Install
10
+ Call `initMushi(config)` once, from `hooks.client.ts` or a top-level
11
+ `+layout.svelte` `onMount`. It pulls in `@mushi-mushi/web` for the widget, so
12
+ do not call `Mushi.init()` separately.
12
13
 
13
14
  ```bash
14
- npm install @mushi-mushi/svelte @mushi-mushi/web
15
+ npm install @mushi-mushi/svelte
15
16
  # or: npx mushi-mushi
16
17
  ```
17
18
 
18
- ## Environment variables
19
-
20
- | Stack | Project ID | API key |
21
- | --- | --- | --- |
22
- | Vite / SvelteKit | `VITE_MUSHI_PROJECT_ID` | `VITE_MUSHI_API_KEY` |
23
-
24
- See [Project ID & API keys](https://docs.mushimushi.dev/concepts/credentials).
25
-
26
- ## Usage
27
-
28
- ```ts
29
- import { initMushi, getMushi } from '@mushi-mushi/svelte'
30
-
31
- initMushi({
32
- projectId: import.meta.env.VITE_MUSHI_PROJECT_ID,
33
- apiKey: import.meta.env.VITE_MUSHI_API_KEY,
34
- })
35
-
36
- const mushi = getMushi()
37
- mushi.submitReport({ title: 'broken', description: '...' })
38
- ```
39
-
40
- ### With widget UI
41
-
42
19
  ```ts
43
20
  import { initMushi } from '@mushi-mushi/svelte'
44
- import { Mushi } from '@mushi-mushi/web'
45
21
 
46
22
  initMushi({
47
23
  projectId: import.meta.env.VITE_MUSHI_PROJECT_ID,
48
24
  apiKey: import.meta.env.VITE_MUSHI_API_KEY,
49
25
  })
50
-
51
- Mushi.init({
52
- projectId: import.meta.env.VITE_MUSHI_PROJECT_ID,
53
- apiKey: import.meta.env.VITE_MUSHI_API_KEY,
54
- })
55
26
  ```
56
27
 
57
- ### SvelteKit error handler
58
-
59
- ```ts
60
- import { createMushiErrorHandler } from '@mushi-mushi/svelte'
61
-
62
- export const handleError = createMushiErrorHandler()
63
- ```
64
-
65
- ## API
66
-
67
- | Export | Purpose |
68
- | --- | --- |
69
- | `initMushi(config)` | Initialize once at app startup |
70
- | `getMushi()` | Access the SDK instance |
71
- | `createMushiErrorHandler()` | SvelteKit `handleError` integration |
72
-
73
- ## Peer dependencies
74
-
75
- - `svelte` >= 4
28
+ Docs: [Svelte SDK](https://kensaur.us/mushi-mushi/docs/sdks/svelte) ·
29
+ [Quickstart](https://kensaur.us/mushi-mushi/docs/quickstart/svelte) ·
30
+ [Credentials](https://kensaur.us/mushi-mushi/docs/concepts/credentials)
76
31
 
77
32
  ## License
78
33
 
package/package.json CHANGED
@@ -1,27 +1,35 @@
1
1
  {
2
2
  "name": "@mushi-mushi/svelte",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "license": "MIT",
5
5
  "description": "Svelte SDK for Mushi Mushi — context-based init, SvelteKit error hook integration",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
+ "size-limit": [
10
+ {
11
+ "path": "dist/index.js",
12
+ "limit": "1 KB"
13
+ }
14
+ ],
9
15
  "peerDependencies": {
10
16
  "svelte": ">=4"
11
17
  },
12
18
  "dependencies": {
13
- "@mushi-mushi/core": "^1.21.0",
14
- "@mushi-mushi/web": "^1.21.0"
19
+ "@mushi-mushi/core": "^1.33.3",
20
+ "@mushi-mushi/web": "^1.33.3"
15
21
  },
16
22
  "devDependencies": {
17
- "eslint": "^10.4.1",
18
- "svelte": "^5.56.3",
23
+ "@size-limit/file": "^12.1.0",
24
+ "eslint": "^10.6.0",
25
+ "size-limit": "^12.1.0",
26
+ "svelte": "^5.56.4",
19
27
  "tsup": "^8.5.1",
20
28
  "typescript": "^6.0.3",
21
- "vitest": "^4.1.8",
29
+ "vitest": "^4.1.9",
22
30
  "@mushi-mushi/eslint-config": "0.0.0"
23
31
  },
24
- "author": "Kenji Sakuramoto (https://bsky.app/profile/mushimushi.dev)",
32
+ "author": "Kenji Sakuramoto <kensaurus@gmail.com> (https://github.com/kensaurus)",
25
33
  "repository": {
26
34
  "type": "git",
27
35
  "url": "https://github.com/kensaurus/mushi-mushi.git",
@@ -38,10 +46,7 @@
38
46
  "files": [
39
47
  "dist",
40
48
  "README.md",
41
- "LICENSE",
42
- "CONTRIBUTING.md",
43
- "CODE_OF_CONDUCT.md",
44
- "SECURITY.md"
49
+ "LICENSE"
45
50
  ],
46
51
  "sideEffects": false,
47
52
  "keywords": [
@@ -56,7 +61,6 @@
56
61
  "screenshot",
57
62
  "shake-to-report",
58
63
  "sentry-companion",
59
- "sentry-alternative",
60
64
  "error-tracking",
61
65
  "ai-triage",
62
66
  "auto-fix",
@@ -78,16 +82,13 @@
78
82
  },
79
83
  "type": "module",
80
84
  "engines": {
81
- "node": ">=20"
82
- },
83
- "funding": {
84
- "type": "github",
85
- "url": "https://github.com/sponsors/kensaurus"
85
+ "node": ">=20.19.0"
86
86
  },
87
87
  "scripts": {
88
88
  "build": "tsup",
89
89
  "lint": "eslint src/",
90
90
  "test": "vitest run",
91
- "typecheck": "tsc --noEmit"
91
+ "typecheck": "tsc --noEmit",
92
+ "size": "size-limit"
92
93
  }
93
94
  }
@@ -1,51 +0,0 @@
1
- <!--
2
- AUTO-SYNCED from repo root by scripts/sync-community-files.mjs.
3
- Do not edit here — edit the canonical file at the repository root and
4
- re-run `node scripts/sync-community-files.mjs` (pre-commit hook does this
5
- automatically).
6
- -->
7
-
8
- # Contributor Covenant Code of Conduct
9
-
10
- ## Our Pledge
11
-
12
- We as members, contributors, and leaders pledge to make participation in our
13
- community a harassment-free experience for everyone, regardless of age, body
14
- size, visible or invisible disability, ethnicity, sex characteristics, gender
15
- identity and expression, level of experience, education, socio-economic status,
16
- nationality, personal appearance, race, caste, color, religion, or sexual
17
- identity and orientation.
18
-
19
- We pledge to act and interact in ways that contribute to an open, welcoming,
20
- diverse, inclusive, and healthy community.
21
-
22
- ## Our Standards
23
-
24
- Examples of behavior that contributes to a positive environment:
25
-
26
- - Using welcoming and inclusive language
27
- - Being respectful of differing viewpoints and experiences
28
- - Gracefully accepting constructive criticism
29
- - Focusing on what is best for the community
30
- - Showing empathy towards other community members
31
-
32
- Examples of unacceptable behavior:
33
-
34
- - The use of sexualized language or imagery, and sexual attention or advances of any kind
35
- - Trolling, insulting or derogatory comments, and personal or political attacks
36
- - Public or private harassment
37
- - Publishing others' private information without explicit permission
38
- - Other conduct which could reasonably be considered inappropriate in a professional setting
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
43
- reported to the project team at **kensaurus@gmail.com**.
44
-
45
- All complaints will be reviewed and investigated promptly and fairly.
46
-
47
- ## Attribution
48
-
49
- This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/),
50
- version 2.1, available at
51
- https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.
package/CONTRIBUTING.md DELETED
@@ -1,218 +0,0 @@
1
- <!--
2
- AUTO-SYNCED from repo root by scripts/sync-community-files.mjs.
3
- Do not edit here — edit the canonical file at the repository root and
4
- re-run `node scripts/sync-community-files.mjs` (pre-commit hook does this
5
- automatically).
6
- -->
7
-
8
- # Contributing to Mushi Mushi
9
-
10
- Thanks for wanting to help. Here's everything you need to get started.
11
-
12
- ## Prerequisites
13
-
14
- - **Node.js >= 22** (see `.node-version`)
15
- - **pnpm >= 10** — install with `corepack enable`
16
-
17
- ## Setup
18
-
19
- ```bash
20
- git clone https://github.com/kensaurus/mushi-mushi.git
21
- cd mushi-mushi
22
- pnpm install
23
- pnpm build
24
- ```
25
-
26
- ## Development
27
-
28
- ```bash
29
- pnpm dev # Start all dev servers (admin on :6464)
30
- ```
31
-
32
- | Surface | URL |
33
- | --- | --- |
34
- | Admin console | http://localhost:6464 |
35
- | Docs site | http://localhost:3000 |
36
- | CLI console override | `MUSHI_CONSOLE_URL=http://localhost:6464` |
37
-
38
- ```bash
39
- pnpm test # Run Vitest across all packages
40
- pnpm typecheck # TypeScript checks
41
- pnpm lint # ESLint
42
- pnpm format # Prettier
43
- pnpm smoke:cli-setup # Playwright: onboarding ?setup=cli + success panel (skips headless if unsigned)
44
- ```
45
-
46
- Set `CLI_SETUP_SMOKE_STRICT=1` to fail the smoke script when Playwright is not signed in (CI gate).
47
-
48
- Ad-hoc screenshots captured during UI reviews can live temporarily at the repo
49
- root, but root-level `*.png` files are intentionally ignored. Canonical
50
- screenshots that should be versioned belong under `docs/screenshots/`.
51
-
52
- ### Working on a single package
53
-
54
- ```bash
55
- cd packages/core
56
- pnpm dev # Watch mode
57
- pnpm test # Tests for this package only
58
- ```
59
-
60
- ## Project Structure
61
-
62
- ```
63
- packages/
64
- core/ Types, API client, offline queue (MIT)
65
- web/ Browser SDK — widget, capture (MIT)
66
- react/ React bindings (MIT)
67
- vue/ Vue 3 plugin (MIT)
68
- svelte/ Svelte SDK (MIT)
69
- angular/ Angular SDK (MIT)
70
- react-native/ React Native SDK (MIT)
71
- cli/ CLI tool (MIT)
72
- mcp/ MCP server for coding agents (MIT)
73
- server/ Supabase Edge Functions (AGPLv3; ee/ is commercial)
74
- agents/ Agentic fix pipeline (AGPLv3)
75
- verify/ Fix verification (AGPLv3)
76
- apps/
77
- admin/ Admin dashboard (React + Tailwind)
78
- docs/ Documentation site (Nextra — apps/docs)
79
- tooling/
80
- eslint-config/ Shared ESLint flat config
81
- tsconfig/ Shared TypeScript configs
82
- ```
83
-
84
- ## What we don't accept
85
-
86
- Knowing this upfront saves everyone time.
87
-
88
- - **Automated / bulk / AI-slop PRs** — any PR that was opened by a script, an LLM agent acting without meaningful human review, or as part of a parallel bounty-farming sweep is closed on sight. The commit history, branch name, or helper scripts included in the PR make this obvious.
89
- - **PRs that target the wrong base** — all PRs must branch from and target `master`. PRs targeting `main` or any other branch are closed (and will show an inflated diff that is not your work).
90
- - **One PR per issue, one issue per PR** — splitting or duplicating work just to collect acknowledgements isn't welcome.
91
- - **Good-first-issues without claiming first** — comment on the issue to claim it before starting. If two people open PRs for the same issue, the one that commented first is prioritised.
92
- - **Documentation-only PRs that merely duplicate existing content** — if the information already exists (e.g. in another file in this repo), adding a redundant copy adds noise without value.
93
-
94
- If a PR violates these policies it will be closed with a brief explanation. No hard feelings — a genuine contribution on the same issue is always welcome.
95
-
96
- ## Making Changes
97
-
98
- 1. Create a feature branch from `master`
99
- 2. Make your changes
100
- 3. Add tests for new functionality
101
- 4. Run `pnpm typecheck && pnpm lint && pnpm test` to verify
102
- 5. Create a changeset if your change affects published packages:
103
- ```bash
104
- pnpm changeset
105
- ```
106
- 6. Open a pull request
107
-
108
- ### Documentation (docs-as-code)
109
-
110
- If your PR changes **user-visible SDK or CLI behavior**, update docs in the **same PR**:
111
-
112
- | Surface | When to update |
113
- | --- | --- |
114
- | `packages/*/README.md` | npm-facing install/API/config changes for that package |
115
- | `apps/docs/content/**/*.mdx` | Long-form guides, quickstarts, admin console docs |
116
- | Root `README.md` | Marketing stats only when counts change — run `pnpm check:docs-stats` |
117
-
118
- Guardrails (run locally before pushing):
119
-
120
- ```bash
121
- pnpm check:docs-stats # root README stat badges
122
- pnpm check:sdk-version-matrix # apps/docs/content/sdks/index.mdx versions
123
- pnpm check:internal-doc-links # dead /foo links in MDX
124
- pnpm check:onboarding-drift # phantom MCP env vars / stale tool names
125
- pnpm check:bundle-docs # @mushi-mushi/web size-limit vs README
126
- pnpm gen:llms-txt # regenerate apps/docs/public/llms.txt after nav changes
127
- pnpm gen:mcp-tools-doc # regenerate sdks/mcp-tools.generated.mdx from catalog.ts
128
- ```
129
-
130
- README changes on npm packages only appear on [npmjs.com](https://www.npmjs.com) after the next **Changesets publish**.
131
-
132
- ## Changesets
133
-
134
- We use [Changesets](https://github.com/changesets/changesets) for versioning. If your PR modifies a published package (`core`, `web`, `react`, `vue`, `svelte`, `angular`, `react-native`, `cli`, `mcp`), add a changeset:
135
-
136
- ```bash
137
- pnpm changeset
138
- ```
139
-
140
- Select the affected packages, the semver bump type, and write a summary. The changeset file gets committed with your PR.
141
-
142
- ## Release flow
143
-
144
- Releases are fully automated once the version PR is merged. Maintainers don't run
145
- `npm publish` by hand for routine bumps. See **[`docs/DEPLOYMENT.md`](docs/DEPLOYMENT.md)**
146
- for the full production runbook (edge functions, admin SPA, docs site, migrations).
147
-
148
- 1. PRs land on `master` with one or more changeset files in `.changeset/`.
149
- Orphaned changesets (only ignored packages) fail `pnpm check:changeset-orphans`.
150
- 2. `release.yml` runs on every push to `master`. It opens (or updates) a
151
- **`chore: version packages`** PR on `changeset-release/master` that bumps
152
- affected `package.json` files, rolls up changelogs, and deletes consumed
153
- changesets.
154
- 3. **Wait for CI on the version PR.** If checks don't appear (bot-branch
155
- suppression), push an empty commit to `changeset-release/master`. If
156
- `check:sdk-version-matrix` fails, run `pnpm gen:sdk-version-matrix` on that
157
- branch and commit `apps/docs/content/sdks/index.mdx`.
158
- 4. Merge the version PR. The publish step uses **OIDC Trusted Publishers** +
159
- Sigstore provenance (with `NPM_TOKEN` only for brand-new package bootstrap).
160
- 5. **Manually dispatch Release** unless a run starts within ~2 minutes:
161
- **Actions → Release → Run workflow → `master`**. Squash-merges attributed to
162
- `github-actions[bot]` usually suppress the auto `push` trigger — manual
163
- dispatch is the normal path, not a fallback of last resort.
164
-
165
- ```bash
166
- gh workflow run release.yml --ref master
167
- ```
168
-
169
- ### Adding a brand-new publishable package
170
-
171
- Trusted Publisher bindings are configured **per package** on `npmjs.com` and require the package to already exist on the registry. New packages therefore need a one-time bootstrap before OIDC can take over.
172
-
173
- 1. Add the package under `packages/<name>/` with a real `version`, `files`, `publishConfig.access: "public"`, `LICENSE`, and the standard fields enforced by `pnpm check:publish-readiness`.
174
- 2. Build it locally: `pnpm install && pnpm -r build`.
175
- 3. Mint a short-lived granular access token at `https://www.npmjs.com/settings/<your-user>/tokens/granular-access-tokens/new` — **Bypass 2FA: ON**, **Read and write: All packages**, **Expiration: 7 days**.
176
- 4. Bootstrap-publish:
177
- ```bash
178
- NPM_TOKEN=npm_xxx pnpm bootstrap:new-package
179
- ```
180
- The script auto-detects which workspace packages are missing on npm and publishes them via `pnpm publish --no-provenance` (so `workspace:^` specifiers get rewritten to real semver in the tarball).
181
- 5. The script prints one URL per freshly-published package. Open each, click **GitHub Actions** under "Trusted Publisher", confirm the auto-filled fields (`<owner>` / `<repo>` / `release.yml`), and tap your security key.
182
- 6. Revoke the bootstrap token at `https://www.npmjs.com/settings/<your-user>/tokens`.
183
-
184
- From the next changeset bump onward, that package publishes through the normal `release.yml` flow with full OIDC provenance — same as the rest.
185
-
186
- ## Code Style
187
-
188
- - **TypeScript strict mode** — no `any` unless absolutely necessary
189
- - **Prettier** formats everything — run `pnpm format` before committing
190
- - **ESLint** catches bugs — `pnpm lint` must pass
191
- - **No default exports** in library packages — use named exports
192
- - **Dual ESM/CJS** builds via tsup for all SDK packages
193
-
194
- ## Commit Messages
195
-
196
- Use conventional commits:
197
-
198
- ```
199
- feat(core): add batch report submission
200
- fix(web): prevent widget from opening during screenshot
201
- docs(react): update provider usage example
202
- chore: bump dependencies
203
- ```
204
-
205
- ## Tests
206
-
207
- - **Framework:** Vitest
208
- - **Location:** Co-located with source (`src/foo.test.ts`)
209
- - **Coverage:** Required for `core`, `web`, `react` — encouraged for all packages
210
-
211
- ## License
212
-
213
- - SDK packages are MIT — your contributions will be MIT-licensed
214
- - Server/agents/verify are AGPLv3 — contributions to those packages fall under AGPLv3. A [commercial license](./COMMERCIAL-LICENSE.md) is available for hosted-SaaS use cases that cannot publish modifications. The `packages/server/ee/` directory is source-available but commercial (production use needs a license); contributions there are accepted under the same EE terms.
215
-
216
- ## Questions?
217
-
218
- Open an issue or start a discussion. We're happy to help.
package/SECURITY.md DELETED
@@ -1,287 +0,0 @@
1
- <!--
2
- AUTO-SYNCED from repo root by scripts/sync-community-files.mjs.
3
- Do not edit here — edit the canonical file at the repository root and
4
- re-run `node scripts/sync-community-files.mjs` (pre-commit hook does this
5
- automatically).
6
- -->
7
-
8
- # Security Policy
9
-
10
- ## Supported Versions
11
-
12
- | Version | Supported |
13
- |---------|-----------|
14
- | 0.x | Yes |
15
-
16
- ## Reporting a Vulnerability
17
-
18
- If you discover a security vulnerability, please report it responsibly.
19
-
20
- **Do NOT open a public GitHub issue.**
21
-
22
- Use either channel below:
23
-
24
- 1. **GitHub Private Vulnerability Reporting** — strongly preferred.
25
- <https://github.com/kensaurus/mushi-mushi/security/advisories/new>
26
- Routes the report into a private advisory with built-in CVE issuance,
27
- patch coordination, and contributor-credit workflow.
28
- 2. **Email** — `kensaurus@gmail.com`, subject prefix `[mushi-security]`.
29
- PGP welcome but not required.
30
-
31
- Include:
32
- - Description of the vulnerability
33
- - Steps to reproduce (smallest reproducer wins)
34
- - Impact assessment (what an attacker gains)
35
- - Suggested fix (if any)
36
- - Whether you want public credit (and how to spell your name)
37
-
38
- ### Coordinated-disclosure timeline
39
-
40
- | Day | Action |
41
- |-----|--------|
42
- | 0 | Report received |
43
- | ≤ 2 | Acknowledgment + assigned a tracking ID |
44
- | ≤ 7 | Triage complete: severity assigned (CVSS 3.1) and target patch date communicated |
45
- | ≤ 30 | Patch released for critical / high (CVSS ≥ 7.0); ≤ 60 days for medium; best-effort for low |
46
- | Patch + 7 | Public advisory + CVE published; reporter credited unless they declined |
47
- | Patch + 90 | Embargo expires regardless; if upstream is unresponsive, the reporter is free to publish |
48
-
49
- ### Safe harbor
50
-
51
- Good-faith security research on Mushi Mushi is welcome. If you stay
52
- within the rules below, we will not pursue legal action, will not ask
53
- your hosting provider to take you offline, and will publicly credit your
54
- work:
55
-
56
- - Test only against your own self-hosted instance, the public demo at
57
- <https://kensaur.us/mushi-mushi/admin/>, or accounts you own.
58
- - Do not access, exfiltrate, or modify data belonging to other users.
59
- - Do not run automated scanning that affects availability for others
60
- (rate-limit your tooling, exclude `/health`).
61
- - Disclose privately first (channels above); do not publish before the
62
- embargo above expires.
63
- - Do not intentionally exploit a finding to escalate beyond proving it
64
- exists.
65
-
66
- If a finding requires touching production data to confirm, **stop and
67
- ask first** — describe what you'd need to do and we'll spin up a sandbox.
68
-
69
- ### Hall of fame
70
-
71
- Researchers who report a confirmed vulnerability are credited in the
72
- release notes for the patched version and added to
73
- [`docs/SECURITY_HALL_OF_FAME.md`](./docs/SECURITY_HALL_OF_FAME.md) (with
74
- permission).
75
-
76
- ## Scope
77
-
78
- - All `@mushi-mushi/*` npm packages
79
- - Supabase Edge Functions (server-side)
80
- - Admin console application
81
- - CLI tool
82
-
83
- ## Out of Scope
84
-
85
- - Self-hosted deployments configured by the user
86
- - Third-party integrations (Jira, Linear, PagerDuty)
87
- - Vulnerabilities requiring physical access
88
-
89
- ## Security Best Practices for Users
90
-
91
- - **Never commit your API keys** — use environment variables
92
- - **Rotate API keys** regularly via the admin console
93
- - **Enable SSO** for team projects (Enterprise tier)
94
- - **Review audit logs** periodically for suspicious activity
95
- - **Verify SDK integrity** with `npm audit signatures` after install
96
- - **Set `Content-Security-Policy`** on any page embedding the Mushi widget;
97
- the widget itself ships with `script-src 'self'` and does not load
98
- remote scripts.
99
-
100
- ## Threat model
101
-
102
- What we treat as in-scope attacker capabilities, and what we don't.
103
-
104
- | Capability | In scope | Notes |
105
- |-----------|----------|-------|
106
- | Unauthenticated network attacker hitting public endpoints | ✅ | Rate-limit + HMAC + replay protection on every webhook endpoint (`packages/server/supabase/functions/_shared/webhook-middleware.ts`). |
107
- | Authenticated user trying to read another tenant's data | ✅ | Postgres RLS on every `public.*` table; advisor lints reviewed monthly. |
108
- | Authenticated user trying to escalate to super-admin | ✅ | Role lives in `auth.users.raw_app_meta_data.role`; cannot be self-edited via PostgREST. |
109
- | Compromised dependency (npm supply-chain attack) | ✅ | 7-day cooldown + provenance + Harden-Runner + pinned SHAs (see "Supply-chain hardening" below). |
110
- | Stolen API key | ✅ | Per-key scopes (`api_key_has_scope`), revocation via admin console, audit log of every use. |
111
- | User pasting a Stripe / OpenAI / GitHub PAT into a bug report | ✅ | PII scrubber redacts ~15 vendor token formats client-side before the report leaves the device. Mirrors `packages/core/src/pii-scrubber.ts` across iOS, Android, Flutter, React Native. |
112
- | Stolen end-user device with the SDK installed | ⚠️ partial | Offline queue is AsyncStorage / Keychain / SharedPreferences — no app-level encryption beyond the OS default. Reports waiting to flush are vulnerable to a forensic attacker. |
113
- | Compromised Supabase service-role key | ❌ | Treated as a tier-0 incident; would require key rotation and audit-log forensics. Not defendable in software. |
114
- | Compromise of `kensaurus@gmail.com` | ❌ | Treated as a project-fork event; downstream consumers should pin to the last known-good version and follow the new release channel. |
115
- | Physical / OS-level attacker on an end-user device | ❌ | Out of scope. |
116
- | Malicious fork using the Mushi name to ship malware | ❌ (technical) ✅ (legal) | The MIT / AGPLv3 grant lets the fork exist; the trademark policy (`TRADEMARK.md`) makes shipping it under the Mushi name an infringement we will pursue. |
117
-
118
- ## Data handling and PII
119
-
120
- ### What the SDK collects by default
121
-
122
- | Field | Scope | PII risk |
123
- |-------|-------|----------|
124
- | URL / route the user was on | Always | Low — strip query strings if your routes encode user IDs. |
125
- | Browser / OS / device | Always | None |
126
- | Console errors (last 50) | Opt-in via `captureConsole: true` | Medium — can include user data your code logs. |
127
- | Network failures (URL + status) | Opt-in via `captureNetwork: true` | Medium — query params logged as-is unless you redact in-app. |
128
- | User id / email / role | Only if you call `setUser()` | High — only set what you need; we do not auto-discover. |
129
- | Session replay frames | Off by default | High — handled by the masking layer; passwords / cards / opted-out elements never leave the page. |
130
- | Free-text bug description | Always | Medium — passed through the PII scrubber (see below). |
131
-
132
- ### What the PII scrubber redacts before send
133
-
134
- Implemented identically across `@mushi-mushi/core`, the iOS, Android,
135
- Flutter, and React Native SDKs. Defaults are below — every category can
136
- be toggled off, but `secretTokens` is on by default and we recommend
137
- keeping it that way.
138
-
139
- | Category | Default | Patterns |
140
- |----------|---------|----------|
141
- | `ssns` | on | `123-45-6789` |
142
- | `creditCards` | on | 12–19 digit Luhn-shaped sequences with optional separators |
143
- | `secretTokens` | on | AWS access key (`AKIA…` / `ASIA…`), AWS secret (`aws_secret_access_key=…`), Stripe (`sk_live_…`, `sk_test_…`, `rk_…`, `pk_…`), Slack (`xox[abpor]-…`), GitHub PAT (`ghp_…`, `github_pat_…`), OpenAI (`sk-…`, `sk-proj-…`), Anthropic (`sk-ant-…`), Google API (`AIza…`), JWT (`eyJ…` 3-segment) |
144
- | `emails` | on | RFC-5322 lite |
145
- | `phones` | on | E.164 with optional country code |
146
- | `ipAddresses` | off | IPv4 (off because internal IPs are usually not PII and noise hurts triage) |
147
- | `ipv6` | off | Same |
148
-
149
- The fields scrubbed are:
150
-
151
- - `description` — primary free-text field of every bug report
152
- - `summary` — short summary, in the same composer
153
- - `breadcrumbs[].message` — auto-captured user-action trail (clicks, route changes, console messages)
154
-
155
- Structured fields you set explicitly (`metadata.userEmail`,
156
- `metadata.userId`, etc.) are intentionally **not** scrubbed — those are
157
- opt-in attribution data, and silently rewriting them would break
158
- support workflows.
159
-
160
- ### Where data lives
161
-
162
- - **Reports & telemetry** — Supabase Postgres in the `us-west-1` region.
163
- - **Session replays** — Supabase Storage, same region. Lifecycle policy
164
- trims replays older than 30 days unless explicitly retained from the
165
- admin console.
166
- - **Inbound webhook bodies** — only a SHA-256 hash + `delivery_id` of
167
- the body is persisted (`webhook_audit_log`). The full body is
168
- processed in memory and discarded.
169
- - **Outbound integrations** (Slack, Jira, …) — Mushi is a sender only;
170
- the receiving system's retention applies.
171
-
172
- ### Encryption
173
-
174
- | Surface | At rest | In transit |
175
- |---------|---------|------------|
176
- | Postgres (Supabase) | AES-256 (Supabase default) | TLS 1.2+ |
177
- | Supabase Storage (replays) | AES-256 | TLS 1.2+ |
178
- | Edge Function ↔ Postgres | — | TLS via the Supavisor pooler |
179
- | SDK ↔ ingest endpoint | — | TLS 1.2+ enforced; HSTS preload on `kensaur.us` |
180
- | Inbound webhooks | — | TLS terminated at CloudFront / Supabase edge |
181
- | Audit log integrity | append-only by RLS; no in-row signing | — |
182
-
183
- ### Cryptographic primitives
184
-
185
- | Use | Algorithm | Implementation |
186
- |-----|-----------|---------------|
187
- | Webhook HMAC verification (Sentry, GitHub, Datadog, Honeycomb, Grafana, Bugsnag, Rollbar, Crashlytics) | HMAC-SHA256, constant-time compare | Web Crypto in Deno; `crypto.subtle.timingSafeEqual` analogue |
188
- | AWS SNS subscription confirmation | RSA-SHA1 / RSA-SHA256 | Deno `crypto.subtle.verify` with the cert from `SigningCertURL` (URL allow-listed to `*.sns.*.amazonaws.com`) |
189
- | Opsgenie JWT shared-token | HS256 with `aud` claim verification | `jose` (Deno-compatible) |
190
- | API-key hashing (database) | SHA-256 prefix + bcrypt secret half | `pgcrypto` |
191
- | Provenance attestations (npm) | Sigstore (Fulcio + Rekor) | `npm publish --provenance` |
192
-
193
- We deliberately do not roll our own crypto. If you find an algorithm or
194
- library above that has been deprecated, please file a security advisory.
195
-
196
- ### Operator security checklist
197
-
198
- When you provision a new self-hosted Mushi instance:
199
-
200
- - [ ] Set `auth_leaked_password_protection = true` in Supabase Auth
201
- (HaveIBeenPwned blocklist; flagged as `auth_leaked_password_protection`
202
- in the security advisor).
203
- - [ ] Enable at least two MFA factors in Supabase Auth (`auth_insufficient_mfa_options`).
204
- - [ ] Rotate the service-role key on day 1, then quarterly.
205
- - [ ] Restrict Postgres direct connections to your CI / migration runners
206
- via Supabase network restrictions.
207
- - [ ] Run `pnpm dlx supabase advisors --project-ref <ref>` after every
208
- migration; aim for zero ERROR-level findings.
209
- - [ ] Configure a Supabase log drain to your SIEM if you are subject to
210
- SOC 2 / ISO 27001.
211
- - [ ] Set CSP `frame-ancestors` on the host page if you embed the Mushi
212
- widget (the widget is iframe-friendly but does not enforce
213
- framing constraints itself).
214
-
215
- ## Supply-chain hardening (how this package is protected)
216
-
217
- Mushi Mushi is built and published with the controls below. Consumers can
218
- verify each control independently — the goal is to make tampering both
219
- difficult and detectable.
220
-
221
- ### Publish-time controls
222
-
223
- | Control | What it does | How to verify |
224
- |---|---|---|
225
- | **npm Trusted Publisher (OIDC)** | Every release is published from `.github/workflows/release.yml` on `master` using a short-lived OIDC token. Long-lived `NPM_TOKEN` is not used for publishing. | `npm view @mushi-mushi/<pkg> --json` shows `"trustedPublisher"` populated for recent versions. |
226
- | **npm provenance attestations** | Every published tarball ships a [Sigstore provenance attestation](https://docs.npmjs.com/generating-provenance-statements) cryptographically linking the tarball to the exact GitHub Actions run that built it. | `npm audit signatures` (run inside any project that depends on `@mushi-mushi/*`) reports `verified registry signatures` and `verified attestations`. The npm web UI shows a "Built and signed on GitHub Actions" badge on each version. |
227
- | **Pre-publish workspace-protocol guard** | Aborts the publish if `workspace:*` ranges leaked into the tarball (the bug class behind the v0.1.0 incident). | `scripts/check-workspace-protocol.mjs` runs before `changeset publish` in `pnpm release`. |
228
- | **Post-publish tarball verification** | Re-downloads each just-published tarball and asserts it doesn't contain `workspace:*`. | See the "Verify published tarballs do not contain workspace:*" step in `release.yml`. |
229
- | **Post-publish `npm audit signatures`** | Re-installs each published version and validates registry signatures + provenance against npm's transparency log. | See the "Audit signatures of installed dependencies" step in `release.yml`. |
230
-
231
- ### Build-time controls
232
-
233
- | Control | What it does |
234
- |---|---|
235
- | **All third-party GitHub Actions pinned to commit SHAs** | Every `uses:` in every workflow under `.github/workflows/` is pinned to a 40-character commit SHA with a version comment. Floating tags (`@v4`, `@main`) are mutable and were the entry point for the [tj-actions/changed-files compromise (CVE-2025-30066)](https://github.com/step-security/harden-runner#detected-attacks). |
236
- | **Harden-Runner egress audit on every job** | [step-security/harden-runner](https://github.com/step-security/harden-runner) records every outbound network call, file write, and process spawn on every CI runner. Detects exfiltration attempts in real time — caught the tj-actions, NX, Shai-Hulud, and Axios attacks for other projects. |
237
- | **OpenSSF Scorecard** | Weekly + on-push score of the repo's security posture (Pinned-Dependencies, Token-Permissions, Branch-Protection, Code-Review, Dangerous-Workflow, Maintained, SAST, Security-Policy, Signed-Releases, Vulnerabilities). Public results at [scorecard.dev](https://scorecard.dev/viewer/?uri=github.com/kensaurus/mushi-mushi). |
238
- | **Server-side secret scan (Gitleaks)** | Every PR and every push to `master` runs Gitleaks across the diff / full tree. Belt-and-suspenders to the local pre-commit hook (`scripts/check-no-secrets.mjs`) which can be bypassed with `--no-verify`. |
239
- | **Local pre-commit secret scanner** | `scripts/check-no-secrets.mjs` runs as a git hook installed by `pnpm install`, blocking commits that look like AWS / Stripe / GitHub / Anthropic / OpenAI / Slack / Supabase keys. |
240
- | **CodeQL `security-extended`** | Semantic analysis of every TypeScript / JavaScript change finds injection sinks, taint flows, prototype pollution, etc. Runs on every PR, push, and weekly cron. |
241
- | **Dependency review on PRs** | `actions/dependency-review-action` blocks the PR if it adds or upgrades a dep with a high-severity advisory. |
242
- | **`pnpm audit --prod --audit-level=high`** | Weekly cron + every push to `master` fails on any high/critical advisory in production deps. |
243
-
244
- ### Install-time controls (protect the project's own dependency graph)
245
-
246
- | Control | What it does |
247
- |---|---|
248
- | **`min-release-age` (npm) / `minimumReleaseAge` (pnpm)** | Refuses to resolve any dep version published less than 7 days ago. The Axios 1.14.1 / 0.30.4 compromise (Mar 2026) was detected and removed within ~5 hours; Shai-Hulud (Sep 2025) within <12 hours — a 7-day cooldown blocks every publicly-disclosed 2025–2026 npm supply-chain attack outright. |
249
- | **`strictDepBuilds: true`** | Fails the install if any transitive dep tries to run a `postinstall` hook the workspace hasn't pre-approved (`onlyBuiltDependencies` allow-list). |
250
- | **`blockExoticSubdeps: true`** | Refuses to resolve transitive deps from git URLs, tarball URLs, or filesystem paths — anything that didn't go through the npm registry's signing pipeline. |
251
- | **Dependabot with cooldown** | Routine dep upgrades wait 7 days; security advisories bypass the cooldown automatically. |
252
- | **`pnpm audit signatures`-style verification** | The release pipeline re-runs `npm audit signatures` against each published version after the publish, with `--audit-level=high`. |
253
-
254
- ### Verifying a Mushi Mushi tarball before installing
255
-
256
- ```bash
257
- # 1. Check provenance attestation matches the public GitHub Actions run
258
- npm view @mushi-mushi/core --json | jq '.signatures, .dist'
259
-
260
- # 2. Inside your own project after install
261
- npm audit signatures
262
-
263
- # Expected: every @mushi-mushi/* package reports
264
- # "verified registry signature"
265
- # "verified attestation"
266
- ```
267
-
268
- If `npm audit signatures` reports any `@mushi-mushi/*` package as unsigned
269
- or with an invalid attestation, **stop the install and email
270
- kensaurus@gmail.com immediately** — that's the symptom of either a
271
- registry compromise or a tampered tarball, and we want to know within
272
- hours, not days.
273
-
274
- ### What this hardening does NOT cover
275
-
276
- - **Self-hosted deployments.** Once the package is on your machine, the
277
- security of your `node_modules`, build pipeline, and runtime is your
278
- responsibility. The hardening above protects the path from source to
279
- registry; it cannot protect a tarball after it has been downloaded.
280
- - **Compromise of `kensaurus@gmail.com`.** A trusted-publisher rule still
281
- lets the legitimate maintainer publish from any branch they push. If
282
- you find yourself with admin access to this repo, treat
283
- `.github/workflows/release.yml` as a tier-0 secret.
284
- - **First-party bugs.** Provenance proves *who* built the tarball and
285
- *when*; it does not prove the code is bug-free. CodeQL + tests cover
286
- that surface, but no automation catches everything — please continue
287
- to report issues to the address above.