dsh-hub-oauth-gateway 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/CHANGELOG.md +195 -0
  2. package/CODE_OF_CONDUCT.md +46 -0
  3. package/CONTRIBUTING.md +150 -0
  4. package/LICENSE +21 -0
  5. package/LICENSES/Apache-2.0.txt +179 -0
  6. package/NOTICE +16 -0
  7. package/README.md +235 -0
  8. package/SECURITY.md +93 -0
  9. package/cordis.patch.yml +5 -0
  10. package/docs/00-project-rules.md +317 -0
  11. package/docs/architecture.md +176 -0
  12. package/docs/configuration.md +288 -0
  13. package/docs/migration-v1.md +135 -0
  14. package/docs/oauth-provenance.md +26 -0
  15. package/docs/research/ccswitch-provider-usage.md +411 -0
  16. package/docs/research/token-monitor-supplement-proposal.md +475 -0
  17. package/docs/research/token-monitor.md +119 -0
  18. package/docs/research/usage-analytics-landscape.md +201 -0
  19. package/lib/bin.js +27593 -0
  20. package/lib/bin.js.map +7 -0
  21. package/lib/cli/coding-oauth.d.ts +6 -0
  22. package/lib/cli/coding-oauth.d.ts.map +1 -0
  23. package/lib/client.js +70 -0
  24. package/lib/client.js.map +7 -0
  25. package/lib/index.d.ts +6 -0
  26. package/lib/index.d.ts.map +1 -0
  27. package/lib/index.js +56934 -0
  28. package/lib/index.js.map +7 -0
  29. package/lib/invariant.d.ts +9 -0
  30. package/lib/invariant.d.ts.map +1 -0
  31. package/lib/invariant.js +14 -0
  32. package/lib/invariant.js.map +7 -0
  33. package/lib/server/accounts/adapters/antigravity-quota.d.ts +13 -0
  34. package/lib/server/accounts/adapters/antigravity-quota.d.ts.map +1 -0
  35. package/lib/server/accounts/adapters/balance-schemes.d.ts +31 -0
  36. package/lib/server/accounts/adapters/balance-schemes.d.ts.map +1 -0
  37. package/lib/server/accounts/adapters/coding-plans.d.ts +23 -0
  38. package/lib/server/accounts/adapters/coding-plans.d.ts.map +1 -0
  39. package/lib/server/accounts/adapters/declarative.d.ts +9 -0
  40. package/lib/server/accounts/adapters/declarative.d.ts.map +1 -0
  41. package/lib/server/accounts/adapters/new-api.d.ts +9 -0
  42. package/lib/server/accounts/adapters/new-api.d.ts.map +1 -0
  43. package/lib/server/accounts/adapters/oauth-device.d.ts +46 -0
  44. package/lib/server/accounts/adapters/oauth-device.d.ts.map +1 -0
  45. package/lib/server/accounts/adapters/oauth-subscriptions.d.ts +28 -0
  46. package/lib/server/accounts/adapters/oauth-subscriptions.d.ts.map +1 -0
  47. package/lib/server/accounts/adapters/ollama-cloud.d.ts +13 -0
  48. package/lib/server/accounts/adapters/ollama-cloud.d.ts.map +1 -0
  49. package/lib/server/accounts/adapters/opencode-go.d.ts +14 -0
  50. package/lib/server/accounts/adapters/opencode-go.d.ts.map +1 -0
  51. package/lib/server/accounts/adapters/sub2api.d.ts +8 -0
  52. package/lib/server/accounts/adapters/sub2api.d.ts.map +1 -0
  53. package/lib/server/accounts/adapters/volcengine-coding-plan.d.ts +34 -0
  54. package/lib/server/accounts/adapters/volcengine-coding-plan.d.ts.map +1 -0
  55. package/lib/server/accounts/config.d.ts +4 -0
  56. package/lib/server/accounts/config.d.ts.map +1 -0
  57. package/lib/server/accounts/errors.d.ts +14 -0
  58. package/lib/server/accounts/errors.d.ts.map +1 -0
  59. package/lib/server/accounts/normalize.d.ts +54 -0
  60. package/lib/server/accounts/normalize.d.ts.map +1 -0
  61. package/lib/server/accounts/registry.d.ts +11 -0
  62. package/lib/server/accounts/registry.d.ts.map +1 -0
  63. package/lib/server/accounts/repository.d.ts +12 -0
  64. package/lib/server/accounts/repository.d.ts.map +1 -0
  65. package/lib/server/accounts/security.d.ts +39 -0
  66. package/lib/server/accounts/security.d.ts.map +1 -0
  67. package/lib/server/accounts/service.d.ts +32 -0
  68. package/lib/server/accounts/service.d.ts.map +1 -0
  69. package/lib/server/accounts/specs.d.ts +7 -0
  70. package/lib/server/accounts/specs.d.ts.map +1 -0
  71. package/lib/server/accounts/transport.d.ts +31 -0
  72. package/lib/server/accounts/transport.d.ts.map +1 -0
  73. package/lib/server/accounts/types.d.ts +214 -0
  74. package/lib/server/accounts/types.d.ts.map +1 -0
  75. package/lib/server/alerts/service.d.ts +5 -0
  76. package/lib/server/alerts/service.d.ts.map +1 -0
  77. package/lib/server/api/credentials.d.ts +22 -0
  78. package/lib/server/api/credentials.d.ts.map +1 -0
  79. package/lib/server/api/legacy.d.ts +22 -0
  80. package/lib/server/api/legacy.d.ts.map +1 -0
  81. package/lib/server/api/router.d.ts +51 -0
  82. package/lib/server/api/router.d.ts.map +1 -0
  83. package/lib/server/api/security.d.ts +16 -0
  84. package/lib/server/api/security.d.ts.map +1 -0
  85. package/lib/server/coding-oauth/adapter.d.ts +24 -0
  86. package/lib/server/coding-oauth/adapter.d.ts.map +1 -0
  87. package/lib/server/coding-oauth/alias-adapter.d.ts +43 -0
  88. package/lib/server/coding-oauth/alias-adapter.d.ts.map +1 -0
  89. package/lib/server/coding-oauth/auth-routes.d.ts +155 -0
  90. package/lib/server/coding-oauth/auth-routes.d.ts.map +1 -0
  91. package/lib/server/coding-oauth/auth.d.ts +29 -0
  92. package/lib/server/coding-oauth/auth.d.ts.map +1 -0
  93. package/lib/server/coding-oauth/capability-routes.d.ts +43 -0
  94. package/lib/server/coding-oauth/capability-routes.d.ts.map +1 -0
  95. package/lib/server/coding-oauth/capability-runtime.d.ts +56 -0
  96. package/lib/server/coding-oauth/capability-runtime.d.ts.map +1 -0
  97. package/lib/server/coding-oauth/capability-settings.d.ts +263 -0
  98. package/lib/server/coding-oauth/capability-settings.d.ts.map +1 -0
  99. package/lib/server/coding-oauth/capability-tools.d.ts +50 -0
  100. package/lib/server/coding-oauth/capability-tools.d.ts.map +1 -0
  101. package/lib/server/coding-oauth/catalog.d.ts +53 -0
  102. package/lib/server/coding-oauth/catalog.d.ts.map +1 -0
  103. package/lib/server/coding-oauth/codex-http.d.ts +77 -0
  104. package/lib/server/coding-oauth/codex-http.d.ts.map +1 -0
  105. package/lib/server/coding-oauth/codex-images.d.ts +109 -0
  106. package/lib/server/coding-oauth/codex-images.d.ts.map +1 -0
  107. package/lib/server/coding-oauth/codex-model-capabilities.d.ts +112 -0
  108. package/lib/server/coding-oauth/codex-model-capabilities.d.ts.map +1 -0
  109. package/lib/server/coding-oauth/codex-search.d.ts +96 -0
  110. package/lib/server/coding-oauth/codex-search.d.ts.map +1 -0
  111. package/lib/server/coding-oauth/codex-usage.d.ts +79 -0
  112. package/lib/server/coding-oauth/codex-usage.d.ts.map +1 -0
  113. package/lib/server/coding-oauth/compose.d.ts +84 -0
  114. package/lib/server/coding-oauth/compose.d.ts.map +1 -0
  115. package/lib/server/coding-oauth/gateway-anthropic-messages.d.ts +8 -0
  116. package/lib/server/coding-oauth/gateway-anthropic-messages.d.ts.map +1 -0
  117. package/lib/server/coding-oauth/gateway-auth.d.ts +22 -0
  118. package/lib/server/coding-oauth/gateway-auth.d.ts.map +1 -0
  119. package/lib/server/coding-oauth/gateway-backend.d.ts +62 -0
  120. package/lib/server/coding-oauth/gateway-backend.d.ts.map +1 -0
  121. package/lib/server/coding-oauth/gateway-body.d.ts +9 -0
  122. package/lib/server/coding-oauth/gateway-body.d.ts.map +1 -0
  123. package/lib/server/coding-oauth/gateway-config.d.ts +24 -0
  124. package/lib/server/coding-oauth/gateway-config.d.ts.map +1 -0
  125. package/lib/server/coding-oauth/gateway-http.d.ts +16 -0
  126. package/lib/server/coding-oauth/gateway-http.d.ts.map +1 -0
  127. package/lib/server/coding-oauth/gateway-openai-chat.d.ts +8 -0
  128. package/lib/server/coding-oauth/gateway-openai-chat.d.ts.map +1 -0
  129. package/lib/server/coding-oauth/gateway-openai-responses.d.ts +8 -0
  130. package/lib/server/coding-oauth/gateway-openai-responses.d.ts.map +1 -0
  131. package/lib/server/coding-oauth/gateway-parse.d.ts +10 -0
  132. package/lib/server/coding-oauth/gateway-parse.d.ts.map +1 -0
  133. package/lib/server/coding-oauth/gateway-protocol.d.ts +47 -0
  134. package/lib/server/coding-oauth/gateway-protocol.d.ts.map +1 -0
  135. package/lib/server/coding-oauth/gateway-routes.d.ts +21 -0
  136. package/lib/server/coding-oauth/gateway-routes.d.ts.map +1 -0
  137. package/lib/server/coding-oauth/gateway.d.ts +48 -0
  138. package/lib/server/coding-oauth/gateway.d.ts.map +1 -0
  139. package/lib/server/coding-oauth/grok-imagine.d.ts +271 -0
  140. package/lib/server/coding-oauth/grok-imagine.d.ts.map +1 -0
  141. package/lib/server/coding-oauth/grok-import.d.ts +21 -0
  142. package/lib/server/coding-oauth/grok-import.d.ts.map +1 -0
  143. package/lib/server/coding-oauth/http-json.d.ts +10 -0
  144. package/lib/server/coding-oauth/http-json.d.ts.map +1 -0
  145. package/lib/server/coding-oauth/ids.d.ts +33 -0
  146. package/lib/server/coding-oauth/ids.d.ts.map +1 -0
  147. package/lib/server/coding-oauth/imagine-routes.d.ts +59 -0
  148. package/lib/server/coding-oauth/imagine-routes.d.ts.map +1 -0
  149. package/lib/server/coding-oauth/invariant.d.ts +9 -0
  150. package/lib/server/coding-oauth/invariant.d.ts.map +1 -0
  151. package/lib/server/coding-oauth/kimi-errors.d.ts +13 -0
  152. package/lib/server/coding-oauth/kimi-errors.d.ts.map +1 -0
  153. package/lib/server/coding-oauth/media-store.d.ts +130 -0
  154. package/lib/server/coding-oauth/media-store.d.ts.map +1 -0
  155. package/lib/server/coding-oauth/oauth-import-routes.d.ts +52 -0
  156. package/lib/server/coding-oauth/oauth-import-routes.d.ts.map +1 -0
  157. package/lib/server/coding-oauth/oauth-providers.d.ts +26 -0
  158. package/lib/server/coding-oauth/oauth-providers.d.ts.map +1 -0
  159. package/lib/server/coding-oauth/oauth-session.d.ts +40 -0
  160. package/lib/server/coding-oauth/oauth-session.d.ts.map +1 -0
  161. package/lib/server/coding-oauth/oauth-sources.d.ts +205 -0
  162. package/lib/server/coding-oauth/oauth-sources.d.ts.map +1 -0
  163. package/lib/server/coding-oauth/oauth.d.ts +79 -0
  164. package/lib/server/coding-oauth/oauth.d.ts.map +1 -0
  165. package/lib/server/coding-oauth/provider.d.ts +38 -0
  166. package/lib/server/coding-oauth/provider.d.ts.map +1 -0
  167. package/lib/server/coding-oauth/proxy.d.ts +17 -0
  168. package/lib/server/coding-oauth/proxy.d.ts.map +1 -0
  169. package/lib/server/coding-oauth/redact.d.ts +5 -0
  170. package/lib/server/coding-oauth/redact.d.ts.map +1 -0
  171. package/lib/server/coding-oauth/session.d.ts +40 -0
  172. package/lib/server/coding-oauth/session.d.ts.map +1 -0
  173. package/lib/server/coding-oauth/store.d.ts +46 -0
  174. package/lib/server/coding-oauth/store.d.ts.map +1 -0
  175. package/lib/server/coding-oauth/web-origin.d.ts +10 -0
  176. package/lib/server/coding-oauth/web-origin.d.ts.map +1 -0
  177. package/lib/server/coding-oauth/web-routes.d.ts +20 -0
  178. package/lib/server/coding-oauth/web-routes.d.ts.map +1 -0
  179. package/lib/server/config.d.ts +154 -0
  180. package/lib/server/config.d.ts.map +1 -0
  181. package/lib/server/context.d.ts +28 -0
  182. package/lib/server/context.d.ts.map +1 -0
  183. package/lib/server/export/auto-export.d.ts +22 -0
  184. package/lib/server/export/auto-export.d.ts.map +1 -0
  185. package/lib/server/fees/repository.d.ts +9 -0
  186. package/lib/server/fees/repository.d.ts.map +1 -0
  187. package/lib/server/host/providers.d.ts +6 -0
  188. package/lib/server/host/providers.d.ts.map +1 -0
  189. package/lib/server/host/session-inventory.d.ts +34 -0
  190. package/lib/server/host/session-inventory.d.ts.map +1 -0
  191. package/lib/server/index.d.ts +161 -0
  192. package/lib/server/index.d.ts.map +1 -0
  193. package/lib/server/migration.d.ts +17 -0
  194. package/lib/server/migration.d.ts.map +1 -0
  195. package/lib/server/pricing/engine.d.ts +10 -0
  196. package/lib/server/pricing/engine.d.ts.map +1 -0
  197. package/lib/server/pricing/repository.d.ts +11 -0
  198. package/lib/server/pricing/repository.d.ts.map +1 -0
  199. package/lib/server/providers/catalog.d.ts +9 -0
  200. package/lib/server/providers/catalog.d.ts.map +1 -0
  201. package/lib/server/scheduler.d.ts +29 -0
  202. package/lib/server/scheduler.d.ts.map +1 -0
  203. package/lib/server/settings/repository.d.ts +10 -0
  204. package/lib/server/settings/repository.d.ts.map +1 -0
  205. package/lib/server/storage/database.d.ts +11 -0
  206. package/lib/server/storage/database.d.ts.map +1 -0
  207. package/lib/server/storage/path.d.ts +2 -0
  208. package/lib/server/storage/path.d.ts.map +1 -0
  209. package/lib/server/usage/projector.d.ts +34 -0
  210. package/lib/server/usage/projector.d.ts.map +1 -0
  211. package/lib/server/usage/query.d.ts +25 -0
  212. package/lib/server/usage/query.d.ts.map +1 -0
  213. package/lib/server/usage/repository.d.ts +30 -0
  214. package/lib/server/usage/repository.d.ts.map +1 -0
  215. package/lib/server/usage/service.d.ts +31 -0
  216. package/lib/server/usage/service.d.ts.map +1 -0
  217. package/lib/server/usage/time.d.ts +2 -0
  218. package/lib/server/usage/time.d.ts.map +1 -0
  219. package/lib/shared/contracts.d.ts +349 -0
  220. package/lib/shared/contracts.d.ts.map +1 -0
  221. package/lib/shared/domain.d.ts +183 -0
  222. package/lib/shared/domain.d.ts.map +1 -0
  223. package/lib/shared/fees.d.ts +73 -0
  224. package/lib/shared/fees.d.ts.map +1 -0
  225. package/lib/shared/preferences.d.ts +114 -0
  226. package/lib/shared/preferences.d.ts.map +1 -0
  227. package/lib/shared/providers.d.ts +321 -0
  228. package/lib/shared/providers.d.ts.map +1 -0
  229. package/lib/shared/time.d.ts +7 -0
  230. package/lib/shared/time.d.ts.map +1 -0
  231. package/package.json +190 -0
  232. package/scripts/install.mjs +309 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,195 @@
1
+ # Changelog
2
+
3
+ All notable changes to `dsh-hub-oauth-gateway` are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
5
+ [Semantic Versioning](https://semver.org/). Release and publication rules are
6
+ defined in [`docs/00-project-rules.md`](docs/00-project-rules.md).
7
+
8
+ ## Unreleased
9
+
10
+ ### Changed
11
+
12
+ - Verification policy: Docker sandbox is no longer required. Agents and
13
+ contributors verify in the Cursor Cloud environment with `pnpm` gates and an
14
+ isolated DeepSeek Harness (`DSH_HOME`) install for plugin smoke tests.
15
+ Documented in `AGENTS.md`, `docs/00-project-rules.md`, and `CONTRIBUTING.md`.
16
+
17
+ ### Added
18
+
19
+ - Integrate coding-subscription OAuth (Grok Build, Codex, Kimi Code, Claude Code),
20
+ CLI Pull, optional Codex/Imagine capabilities, and the opt-in local API gateway
21
+ into this plugin. Compatibility routes, credential files, and CLI names are
22
+ preserved.
23
+ - Add a unified provider catalog at `GET /api/usage-stats/v1/providers` and a
24
+ Settings provider-management view with independent connection, auth, model, and
25
+ quota states.
26
+
27
+ ## 1.5.0
28
+
29
+ ### Changed
30
+
31
+ - Full dashboard and Settings → Usage Center use top tabs (one panel at a time),
32
+ following the coding-subscription OAuth settings pattern, so modules and
33
+ settings no longer stack as a long waterfall.
34
+ - Quick Peek and the full dashboard use content height with `max-height` instead
35
+ of fixed 760px / 900px frames; Peek account cards keep a compact scroll cap.
36
+
37
+ ## 1.4.0
38
+
39
+ ### Added
40
+
41
+ #### Wave 2 — account coverage
42
+
43
+ - `volcengine-coding-plan` adapter via signed OpenAPI `GetCodingPlanUsage`
44
+ (no chat-completion probe).
45
+ - `zai-team-plan` adapter (`open.bigmodel.cn` quota `type=2`) isolated from
46
+ personal `zai-token-plan`.
47
+ - lastGood hardening: consecutive transient failures keep stale last-good data
48
+ until a configurable limit, then clear; Account UI shows last-good time.
49
+ - Multi-profile monitors (`accounts.monitors.*.profiles[]`) with snapshot key
50
+ `(providerId, profileId)` (schema v3) and fee `profileId` attachment.
51
+
52
+ #### Wave 3 — ops / optional
53
+
54
+ - Adaptive account refresh (`refresh.accountMode: fixed | adaptive`, default
55
+ `fixed`); ordinary GET still does not credential-refresh.
56
+ - Breakdown table expands input/output/cacheRead/cacheWrite columns (local data
57
+ only).
58
+ - Opt-in local-directory auto export (absolute path; refused in CI/sandbox;
59
+ never writes credentials/sessions).
60
+ - Opt-in `antigravity-quota` (external credential + usage URL only) and
61
+ `ollama-cloud` (requires `allowCookieSession: true`, host pinned to
62
+ `ollama.com`).
63
+
64
+ ## 1.2.0
65
+
66
+ ### Added
67
+
68
+ - Activity heatmap and streak over a rolling 370-day window in the configured
69
+ time zone (`GET /api/usage-stats/v1/activity`), independent of the dashboard
70
+ range filter.
71
+ - Dashboard module composition: preference-backed order/hidden list, preset
72
+ templates, and a Settings reset that clears customization.
73
+ - Local subscription/top-up fee ledger (`account_fees`, schema v2) with
74
+ `GET`/`PUT /api/usage-stats/v1/fees`, Settings editing, and payback tooltips on
75
+ account cards when currency and monthly cost coverage match.
76
+ - Export layouts: `layout=filtered` (default), `daily` CSV (date × provider), and
77
+ `bundle` JSON; fee rows remain excluded from exports.
78
+
79
+ ### Changed
80
+
81
+ - User preferences keep `version: 1` while defaulting new Wave 1 fields
82
+ (`modules`, `modulesCustomized`, `streakMinTokens`) for older saved payloads.
83
+
84
+ ## 1.1.0
85
+
86
+ ### Added
87
+
88
+ - Add public project governance, contribution, conduct, and release-inspection
89
+ rules adapted to this repository's local-first security and committed-build
90
+ model.
91
+ - Add a Docker-only sandbox pipeline for dependency installation, lint,
92
+ type-checking, tests, release builds, artifact/lockfile export, reproducibility
93
+ checks, and npm package inspection; project code runs without network or host
94
+ bind mounts, and CI uses the same sandbox.
95
+
96
+ ### Changed
97
+
98
+ - **Breaking:** rename the package and repository from `dsh-usage-stats`
99
+ (`Ychris12138/dsh-usage-stats`) to `dsh-hub-oauth-gateway`
100
+ (`lninghaha/dsh-hub-oauth-gateway`) ahead of the planned coding-plan OAuth
101
+ and API gateway work. The plugin/bundle identity and install/update contract
102
+ change with the name: `dsh plugin update dsh-usage-stats` no longer resolves,
103
+ and the old npm/GitHub package name will not receive updates. Existing
104
+ installations must remove the old entry and install the new package name.
105
+ Local data files (`usage-stats-v1.sqlite`, legacy JSON caches), the internal
106
+ `usage-stats` Cordis entry id, and the `/api/usage-stats/*` wire paths are
107
+ unchanged, so historical statistics are picked up in place.
108
+
109
+ ### Fixed
110
+
111
+ - Accept direct loopback and same-origin HTTPS reverse-proxy browser requests
112
+ without confusing the browser-facing origin with the proxy's rewritten backend
113
+ Host. Forwarded mode requires loopback transport, canonical single-value
114
+ `X-Forwarded-Host`/`X-Forwarded-Proto`, the plugin marker, and an exact client
115
+ target authority; every presented Origin/Referer must match either the backend
116
+ or forwarded origin, while hostile preflight remains blocked without CORS.
117
+ - Preserve structured API failure codes so the bilingual client can show
118
+ actionable local browser-context recovery guidance instead of exposing a
119
+ misleading raw guard message.
120
+ - Add bounded browser-guard rejection classifications to local warning logs and
121
+ failure details without recording raw headers, URLs, cookies, or authorization
122
+ data.
123
+ - Prioritize accounts with real balance or quota windows in Quick Peek instead
124
+ of letting unconfigured compatibility cards consume the four compact slots.
125
+ - Query MiniMax Token Plan quota on the provider `api.*` host instead of the
126
+ browser-facing `www.*` host, then fall back to the legacy first-party path only
127
+ after an explicit zero-status response with no usable quota fields. Accept
128
+ non-video model labels and current reset-time fields while keeping HTTP,
129
+ provider-level, and malformed responses fail-closed without a second request.
130
+
131
+ ## 1.0.0
132
+
133
+ ### Added
134
+
135
+ - Rebuild the plugin in TypeScript around a versioned local SQLite store for
136
+ session usage facts, account snapshots, preferences, pricing, and sanitized
137
+ migration state.
138
+ - Add Quick Peek and Full Dashboard views with time ranges, provider/model
139
+ breakdowns, calendar-correct trends, bounded forecasts, alerts, and CSV/JSON
140
+ export.
141
+ - Add user-owned price rules with separate input, output, cache-read, and
142
+ cache-write prices plus explicit estimate coverage.
143
+ - Add normalized balance and subscription monitoring through 21 built-in
144
+ adapters and a constrained declarative JSON monitor.
145
+ - Add server-side credential metadata/write/import endpoints and an optional
146
+ GitHub Copilot device flow without a bundled third-party OAuth client ID.
147
+ - Add bilingual Simplified Chinese/English UI and configurable presentation,
148
+ provider visibility, aliases, colors, density, privacy, and alert settings.
149
+ - Add Vitest coverage for storage, migration, time zones/DST, projection,
150
+ pricing, forecasts, account transport, API guards, credentials, export,
151
+ bundles, installer behavior, and React components.
152
+
153
+ ### Changed
154
+
155
+ - Make GET endpoints local-snapshot reads; projection and credential-bearing
156
+ account refresh happen at startup, on schedule, or through explicit
157
+ mutations.
158
+ - Produce standalone server and classic-script client bundles, publish TypeScript
159
+ declarations, and commit deterministic `lib/` artifacts for Git-host
160
+ installation.
161
+ - Use pnpm with a committed lockfile and support Node.js `^22.19.0 || >=24.0.0`.
162
+ - Move monitor configuration under `accounts.monitors` while preserving the
163
+ legacy root `monitors` compatibility transform.
164
+ - Make fallback installation stage, verify, and atomically replace a complete
165
+ package; it refuses a duplicate manual mount when DSH bundles already manage
166
+ the plugin.
167
+
168
+ ### Removed
169
+
170
+ - Remove the undocumented v0.3 JavaScript subpath exports and stale split
171
+ runtime files. The stable integration surface is the root Cordis plugin,
172
+ `./client`, and the versioned HTTP API.
173
+
174
+ ### Security
175
+
176
+ - Enforce loopback peer and Host checks, same-origin/request-context guards,
177
+ a plugin request header, JSON-only mutations, and request/body limits.
178
+ - Centralize outbound HTTPS/origin/DNS/private-address/redirect/timeout/size
179
+ validation and pin the validated DNS result into the connection.
180
+ - Keep credential values, prompts, responses, working directories, local
181
+ credential paths, and raw provider responses out of SQLite and browser APIs.
182
+ - Add restrictive storage permissions, session anonymization, export redaction,
183
+ and spreadsheet-formula escaping.
184
+
185
+ ## 0.3.0
186
+
187
+ ### Added
188
+
189
+ - Add credential management and nine additional provider adapters.
190
+
191
+ ## 0.2.0
192
+
193
+ ### Added
194
+
195
+ - Add multi-provider account monitoring alongside token-usage analytics.
@@ -0,0 +1,46 @@
1
+ # Code of Conduct
2
+
3
+ ## Our commitment
4
+
5
+ We are committed to a welcoming, harassment-free, and technically constructive
6
+ community for everyone, regardless of background, identity, experience level,
7
+ or preferred tools.
8
+
9
+ ## Expected behavior
10
+
11
+ - Be respectful, patient, and specific.
12
+ - Critique ideas and code, not people.
13
+ - Assume good intent while accepting correction.
14
+ - Make reviews actionable and acknowledge trade-offs.
15
+ - Respect privacy. Never ask someone to post credentials, private account data,
16
+ prompts, responses, production databases, or identifying logs.
17
+ - Disclose conflicts of interest and distinguish personal opinion from project
18
+ policy or verified provider behavior.
19
+
20
+ ## Unacceptable behavior
21
+
22
+ - Harassment, threats, discrimination, insults, or sustained disruption;
23
+ - publishing another person's private information or credentials;
24
+ - pressuring maintainers or reporters to expose sensitive vulnerability
25
+ details publicly;
26
+ - impersonating a vendor, contributor, or maintainer;
27
+ - knowingly making deceptive claims about usage, cost, provider support, or
28
+ project endorsement.
29
+
30
+ ## Scope and enforcement
31
+
32
+ This policy applies in repository issues, pull requests, reviews, discussions,
33
+ release channels, and other spaces where someone represents this project.
34
+ Report conduct concerns privately to a maintainer. For a software
35
+ vulnerability, use the process in [`SECURITY.md`](SECURITY.md) instead.
36
+
37
+ Maintainers may edit or remove comments, reject contributions, temporarily
38
+ limit participation, or ban participants when behavior threatens people, the
39
+ project, or user safety. Enforcement decisions should be proportionate,
40
+ private where possible, and free from retaliation.
41
+
42
+ ## Attribution
43
+
44
+ This concise policy is inspired by the principles of the Contributor Covenant
45
+ 2.1, while using project-specific wording. The Contributor Covenant is
46
+ available at <https://www.contributor-covenant.org/version/2/1/code_of_conduct/>.
@@ -0,0 +1,150 @@
1
+ # Contributing to dsh-hub-oauth-gateway
2
+
3
+ Thank you for helping improve `dsh-hub-oauth-gateway`. Bug reports, documentation,
4
+ tests, accessibility improvements, adapters, and focused pull requests are
5
+ welcome.
6
+
7
+ Before contributing, read:
8
+
9
+ - [project rules](docs/00-project-rules.md) for publication, compatibility, and
10
+ release requirements;
11
+ - [security policy](SECURITY.md) for the supported deployment and private
12
+ vulnerability reporting;
13
+ - [code of conduct](CODE_OF_CONDUCT.md) for community expectations.
14
+
15
+ By submitting a contribution, you agree that it may be distributed under this
16
+ repository's [MIT License](LICENSE).
17
+
18
+ ## Before opening an issue
19
+
20
+ 1. Search existing issues and the changelog.
21
+ 2. Reproduce on a supported Node.js/DSH version when possible.
22
+ 3. Remove credentials, account details, session identifiers, prompts,
23
+ responses, raw provider payloads, local paths, and host information.
24
+ 4. For a security vulnerability, **do not open a public issue**. Follow
25
+ `SECURITY.md`.
26
+
27
+ A useful bug report includes expected and actual behavior, minimal sanitized
28
+ configuration, version information, and deterministic reproduction steps. Do
29
+ not attach a production database or credential-bearing log. Feature requests
30
+ should explain the user problem and trust/data-flow impact rather than only a
31
+ proposed UI.
32
+
33
+ ## Development setup
34
+
35
+ Verify in the **Cursor Cloud / local cloud workspace** with the declared Node.js
36
+ and pnpm versions. Docker is optional, not required.
37
+
38
+ ```bash
39
+ node -v # ^22.19 || >=24
40
+ pnpm -v # packageManager in package.json
41
+ pnpm install --frozen-lockfile
42
+ pnpm run check:next
43
+ ```
44
+
45
+ For plugin smoke tests, use an **isolated** `DSH_HOME` (never the operator’s
46
+ personal profile), install `@deepseek-ai/dsh`, add this package to the web
47
+ profile, and start `dsh web` on loopback.
48
+
49
+ Automated tests use mocks and sanitized fixtures. They must not read a
50
+ personal DSH profile, local CLI login, credential store, production SQLite, or
51
+ require live provider access.
52
+
53
+ ## Repository model
54
+
55
+ - Edit runtime behavior under `src/`.
56
+ - Add or update tests under `tests/v1/`.
57
+ - Do not edit `lib/` manually. It is a committed installation artifact rebuilt
58
+ from `src/` in the cloud/dev environment, reviewed, then committed.
59
+ - `.next/`, `output/`, coverage, optional Docker exports, images, and TypeScript
60
+ build info are local/rebuildable outputs.
61
+ - Put private machine-specific research in ignored `docs/local/`, never in a
62
+ pull request. Public reusable research belongs in a reviewed public doc.
63
+ - Use pnpm only. Dependency changes include `pnpm-lock.yaml` and must not add
64
+ `package-lock.json`.
65
+
66
+ Architecture and configuration contracts are documented in
67
+ [`docs/architecture.md`](docs/architecture.md) and
68
+ [`docs/configuration.md`](docs/configuration.md).
69
+
70
+ ## Change workflow
71
+
72
+ 1. Discuss a large or compatibility-affecting change in an issue first.
73
+ 2. Branch from the default branch and keep the change focused.
74
+ 3. Use a conventional commit prefix where practical:
75
+ - `feat:` backward-compatible capability;
76
+ - `fix:` bug or security fix;
77
+ - `docs:` public documentation;
78
+ - `test:` test-only change;
79
+ - `refactor:` behavior-preserving cleanup;
80
+ - `build:` build/dependency/release tooling;
81
+ - `chore:` repository maintenance.
82
+ 4. Add regression tests for fixes and negative tests for security boundaries.
83
+ 5. Update public documentation when behavior, API, configuration, installation,
84
+ migration, compatibility, or trust assumptions change.
85
+ 6. Add a concise user/operator-facing entry under `Unreleased` in
86
+ `CHANGELOG.md`.
87
+ 7. For runtime changes, regenerate `lib/` from `src/`, review the diff, commit
88
+ it, run `pnpm run check`, and smoke-test with an isolated DSH install when
89
+ UI or install behavior changed.
90
+
91
+ User-visible copy must remain available in Simplified Chinese and English.
92
+ Usage and costs must stay clearly identified as analytics/estimates; an
93
+ unpriced token category is unknown, not free.
94
+
95
+ ## Required checks
96
+
97
+ Fast source gate:
98
+
99
+ ```bash
100
+ pnpm install --frozen-lockfile
101
+ pnpm run check:next
102
+ ```
103
+
104
+ After a runtime source change, rebuild and review `lib/`, then run:
105
+
106
+ ```bash
107
+ pnpm run check
108
+ npm pack --dry-run --json --ignore-scripts
109
+ ```
110
+
111
+ Optional UI smoke (isolated `DSH_HOME` only):
112
+
113
+ ```bash
114
+ export DSH_HOME=/tmp/dsh-verify-$USER
115
+ # install @deepseek-ai/dsh, then:
116
+ dsh plugin --profile web add "$PWD"
117
+ dsh web --host 127.0.0.1 --port 3080
118
+ ```
119
+
120
+ Never use a live credential or provider call as evidence that replaces an
121
+ automated regression test.
122
+
123
+ ## Pull requests
124
+
125
+ A pull request should include:
126
+
127
+ - the problem and scope;
128
+ - compatibility, migration, security, and privacy impact;
129
+ - tests and exact commands run;
130
+ - screenshots only when useful and fully synthetic/sanitized;
131
+ - linked issues and remaining follow-ups.
132
+
133
+ Reviewers will check correctness, failure isolation, accessibility, public API
134
+ compatibility, privacy boundaries, docs/changelog synchronization, generated
135
+ artifacts, and npm package contents. Maintainers may ask to split unrelated
136
+ changes.
137
+
138
+ At least one maintainer approval and green required CI are expected before
139
+ merge. Authors should not rewrite shared history after review without warning.
140
+
141
+ ## Releases
142
+
143
+ Maintainers perform releases according to
144
+ [`docs/00-project-rules.md`](docs/00-project-rules.md). Release preparation and
145
+ inspection are local; version bumps, tags, pushes, registry publication, and
146
+ GitHub Releases require an explicit human decision. Contributors should not
147
+ include an unsolicited version bump or tag in a feature pull request.
148
+
149
+ Installing or developing the plugin never authorizes a tool or contributor to
150
+ restart DSH Web. A user chooses when to restart the service.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-hub-oauth-gateway contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,179 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ Copyright 2026 dsh-xai contributors
8
+ Copyright 2026 dsh-coding-subscription-oauth contributors
9
+
10
+ 1. Definitions.
11
+
12
+ "License" shall mean the terms and conditions for use, reproduction,
13
+ and distribution as defined by Sections 1 through 9 of this document.
14
+
15
+ "Licensor" shall mean the copyright owner or entity authorized by
16
+ the copyright owner that is granting the License.
17
+
18
+ "Legal Entity" shall mean the union of the acting entity and all
19
+ other entities that control, are controlled by, or are under common
20
+ control with that entity. For the purposes of this definition,
21
+ "control" means (i) the power, direct or indirect, to cause the
22
+ direction or management of such entity, whether by contract or
23
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
24
+ outstanding shares, or (iii) beneficial ownership of such entity.
25
+
26
+ "You" (or "Your") shall mean an individual or Legal Entity
27
+ exercising permissions granted by this License.
28
+
29
+ "Source" form shall mean the preferred form for making modifications,
30
+ including but not limited to software source code, documentation
31
+ source, and configuration files.
32
+
33
+ "Object" form shall mean any form resulting from mechanical
34
+ transformation or translation of a Source form, including but
35
+ not limited to compiled object code, generated documentation,
36
+ and conversions to other media types.
37
+
38
+ "Work" shall mean the work of authorship, whether in Source or
39
+ Object form, made available under the License, as indicated by a
40
+ copyright notice that is included in or attached to the work
41
+ (an example is provided in the Appendix below).
42
+
43
+ "Derivative Works" shall mean any work, whether in Source or Object
44
+ form, that is based on (or derived from) the Work and for which the
45
+ editorial revisions, annotations, elaborations, or other modifications
46
+ represent, as a whole, an original work of authorship. For the purposes
47
+ of this License, Derivative Works shall not include works that remain
48
+ separable from, or merely link (or bind by name) to the interfaces of,
49
+ the Work and Derivative Works thereof.
50
+
51
+ "Contribution" shall mean any work of authorship, including
52
+ the original version of the Work and any modifications or additions
53
+ to that Work or Derivative Works thereof, that is intentionally
54
+ submitted to Licensor for inclusion in the Work by the copyright owner
55
+ or by an individual or Legal Entity authorized to submit on behalf of
56
+ the copyright owner. For the purposes of this definition, "submitted"
57
+ means any form of electronic, verbal, or written communication sent
58
+ to the Licensor or its representatives, including but not limited to
59
+ communication on electronic mailing lists, source code control systems,
60
+ and issue tracking systems that are managed by, or on behalf of, the
61
+ Licensor for the purpose of discussing and improving the Work, but
62
+ excluding communication that is conspicuously marked or otherwise
63
+ designated in writing by the copyright owner as "Not a Contribution."
64
+
65
+ "Contributor" shall mean Licensor and any individual or Legal Entity
66
+ on behalf of whom a Contribution has been received by Licensor and
67
+ subsequently incorporated within the Work.
68
+
69
+ 2. Grant of Copyright License. Subject to the terms and conditions of
70
+ this License, each Contributor hereby grants to You a perpetual,
71
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
72
+ copyright license to reproduce, prepare Derivative Works of,
73
+ publicly display, publicly perform, sublicense, and distribute the
74
+ Work and such Derivative Works in Source or Object form.
75
+
76
+ 3. Grant of Patent License. Subject to the terms and conditions of
77
+ this License, each Contributor hereby grants to You a perpetual,
78
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
79
+ (except as stated in this section) patent license to make, have made,
80
+ use, offer to sell, sell, import, and otherwise transfer the Work,
81
+ where such license applies only to those patent claims licensable
82
+ by such Contributor that are necessarily infringed by their
83
+ Contribution(s) alone or by combination of their Contribution(s)
84
+ with the Work to which such Contribution(s) was submitted. If You
85
+ institute patent litigation against any entity (including a
86
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
87
+ or a Contribution incorporated within the Work constitutes direct
88
+ or contributory patent infringement, then any patent licenses
89
+ granted to You under this License for that Work shall terminate
90
+ as of the date such litigation is filed.
91
+
92
+ 4. Redistribution. You may reproduce and distribute copies of the
93
+ Work or Derivative Works thereof in any medium, with or without
94
+ modifications, and in Source or Object form, provided that You
95
+ meet the following conditions:
96
+
97
+ (a) You must give any other recipients of the Work or
98
+ Derivative Works a copy of this License; and
99
+
100
+ (b) You must cause any modified files to carry prominent notices
101
+ stating that You changed the files; and
102
+
103
+ (c) You must retain, in the Source form of any Derivative Works
104
+ that You distribute, all copyright, patent, trademark, and
105
+ attribution notices from the Source form of the Work,
106
+ excluding those notices that do not pertain to any part of
107
+ the Derivative Works; and
108
+
109
+ (d) If the Work includes a "NOTICE" text file as part of its
110
+ distribution, then any Derivative Works that You distribute must
111
+ include a readable copy of the attribution notices contained
112
+ within such NOTICE file, excluding those notices that do not
113
+ pertain to any part of the Derivative Works, in at least one
114
+ of the following places: within a NOTICE text file distributed
115
+ as part of the Derivative Works; within the Source form or
116
+ documentation, if provided along with the Derivative Works; or,
117
+ within a display generated by the Derivative Works, if and
118
+ wherever such third-party notices normally appear. The contents
119
+ of the NOTICE file are for informational purposes only and
120
+ do not modify the License. You may add Your own attribution
121
+ notices within Derivative Works that You distribute, alongside
122
+ or as an addendum to the NOTICE text from the Work, provided
123
+ that such additional attribution notices cannot be construed
124
+ as modifying the License.
125
+
126
+ You may add Your own copyright statement to Your modifications and
127
+ may provide additional or different license terms and conditions
128
+ for use, reproduction, or distribution of Your modifications, or
129
+ for any such Derivative Works as a whole, provided Your use,
130
+ reproduction, and distribution of the Work otherwise complies with
131
+ the conditions stated in this License.
132
+
133
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
134
+ any Contribution intentionally submitted for inclusion in the Work
135
+ by You to the Licensor shall be under the terms and conditions of
136
+ this License, without any additional terms or conditions.
137
+ Notwithstanding the above, nothing herein shall supersede or modify
138
+ the terms of any separate license agreement you may have executed
139
+ with Licensor regarding such Contributions.
140
+
141
+ 6. Trademarks. This License does not grant permission to use the trade
142
+ names, trademarks, service marks, or product names of the Licensor,
143
+ except as required for reasonable and customary use in describing the
144
+ origin of the Work and reproducing the content of the NOTICE file.
145
+
146
+ 7. Disclaimer of Warranty. Unless required by applicable law or
147
+ agreed to in writing, Licensor provides the Work (and each
148
+ Contributor provides its Contributions) on an "AS IS" BASIS,
149
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
150
+ implied, including, without limitation, any warranties or conditions
151
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
152
+ PARTICULAR PURPOSE. You are solely responsible for determining the
153
+ appropriateness of using or redistributing the Work and assume any
154
+ risks associated with Your exercise of permissions under this License.
155
+
156
+ 8. Limitation of Liability. In no event and under no legal theory,
157
+ whether in tort (including negligence), contract, or otherwise,
158
+ unless required by applicable law (such as deliberate and grossly
159
+ negligent acts) or agreed to in writing, shall any Contributor be
160
+ liable to You for damages, including any direct, indirect, special,
161
+ incidental, or consequential damages of any character arising as a
162
+ result of this License or out of the use or inability to use the
163
+ Work (including but not limited to damages for loss of goodwill,
164
+ work stoppage, computer failure or malfunction, or any and all
165
+ other commercial damages or losses), even if such Contributor
166
+ has been advised of the possibility of such damages.
167
+
168
+ 9. Accepting Warranty or Additional Liability. While redistributing
169
+ the Work or Derivative Works thereof, You may choose to offer,
170
+ and charge a fee for, acceptance of support, warranty, indemnity,
171
+ or other liability obligations and/or rights consistent with this
172
+ License. However, in accepting such obligations, You may act only
173
+ on Your own behalf and on Your sole responsibility, not on behalf
174
+ of any other Contributor, and only if You agree to indemnify,
175
+ defend, and hold each Contributor harmless for any liability
176
+ incurred by, or claims asserted against, such Contributor by reason
177
+ of your accepting any such warranty or additional liability.
178
+
179
+ END OF TERMS AND CONDITIONS
package/NOTICE ADDED
@@ -0,0 +1,16 @@
1
+ NOTICE
2
+ ======
3
+
4
+ dsh-hub-oauth-gateway
5
+ Copyright 2026 dsh-hub-oauth-gateway contributors
6
+
7
+ This product is licensed under MIT AND Apache-2.0.
8
+
9
+ This product includes software derived from dsh-coding-subscription-oauth
10
+ (formerly dsh-grok-build), licensed under the Apache License, Version 2.0.
11
+ See LICENSES/Apache-2.0.txt and docs/oauth-provenance.md.
12
+
13
+ That OAuth implementation includes software developed by the dsh-xai project
14
+ (https://github.com/MirDie/dsh-xai), licensed under the Apache License,
15
+ Version 2.0. Portions of the coding-oauth store, session, grok-import, redact,
16
+ invariant, adapter, auth, and CLI modules are derived from that work.