@crvouga/mockingbird-service-whoop 1.6.0 → 1.8.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # Changelog — @crvouga/mockingbird-service-whoop
2
2
 
3
- ## 1.6.0 (2026-10-19)
3
+ ## 1.8.0 (2026-10-21)
4
+
5
+ ### Features
6
+
7
+ - add manual response controls ([4599960](https://github.com/crvouga/mockingbird/commit/45999603e8b860c633181367afc7baa906ba486b))
8
+
9
+ ## 1.7.0 (2026-10-20)
10
+
11
+ ### Features
12
+
13
+ - raise the serve and fleet body limit to the S3 maximum ([86b9e2b](https://github.com/crvouga/mockingbird/commit/86b9e2b80bcaaaef57f52edbac50b27da0b42f33))
14
+ - add authorize endpoints that redirect with code and state, and profile endpoints ([a686188](https://github.com/crvouga/mockingbird/commit/a6861889e02552eb31ea7f8c505db12ffc450072))
15
+
16
+ ## 1.6.0 (2026-10-18)
4
17
 
5
18
  ### Features
6
19
 
package/README.md CHANGED
@@ -32,6 +32,12 @@ Run `mockingbird-whoop serve --port 12129`. Inject the local origin plus `/devel
32
32
 
33
33
  POST `/oauth/oauth2/token` accepts form-encoded authorization-code or refresh-token grants with client credentials. Seed `clients`, `codes`, and `grants` via options or admin state. Default emulator client: `mock_client` / `mock_client_secret`; default bearer `mock_whoop_token` and refresh `mock_whoop_refresh`. The default grant has all four read scopes and `offline`. Codes bind client, optional redirect and optional S256 PKCE challenge. Codes are single-use, including concurrent exchanges. New tokens expire after 3600 seconds (`tokenTtlSeconds` is configurable). Refresh invalidates both old access and refresh tokens, keeps the same user/scopes, and issues a refresh token only for an offline grant.
34
34
 
35
+ GET `/oauth/oauth2/auth` is the authorization endpoint a browser visits to connect a member. There is no consent page: the request is validated, then the `consents` collection answers for the user and the browser is redirected (302) to `redirect_uri` with `code` and `state`, or `error`, `error_description` and `state`. The code is stored in `codes` bound to the client, the exact `redirect_uri`, the granted scopes (so the token's `scope` is what was requested, and `refresh_token` appears only with `offline`) and an optional S256 `code_challenge`; `POST /oauth/oauth2/token` redeems it once. An unknown client (401 `invalid_client`), a missing `client_id` or `redirect_uri`, or a `redirect_uri` the client did not register (400 `invalid_request`, JSON `{error,error_description}`) is answered in place and never redirected to. Clients take optional `redirectUris` (exact match; omitted accepts any absolute http(s) URI so the default `mock_client` works as is) and `scopes` (omitted allows the documented WHOOP scopes). Redirected errors: `invalid_request` (no `response_type`, or a `code_challenge_method` other than `S256`), `unsupported_response_type`, `invalid_scope`, `invalid_state` (missing or under 8 characters). A longer `state` is echoed unchanged.
36
+
37
+ Consent controls: rows `{id, decision: "approve"|"deny"|"error", userId?, codeTtlSeconds?, error?, errorDescription?}` where `id` is a client id or `*` (every client without its own row). Seed with the `consents` option or `POST /__admin/state/consents {"id":"*","value":{"id":"*","decision":"deny"}}`. No row means approve for `synthetic-user` with a 600 second code. `deny` redirects `access_denied` and `error` redirects `server_error` (override with `error`/`errorDescription`), both with the unchanged `state` and no code. Issued codes are listed at `GET /__admin/state/codes`.
38
+
39
+ GET `/developer/v2/user/profile/basic` returns the token user's `{user_id,email,first_name,last_name}`: seed a `records` row with `collection: "profile"`, `userId` the token's user and `data` the profile (fake values only). Scope `read:profile` is required (403 `{detail:"Access forbidden."}` like the collections, 401 for an unknown or expired token, 404 `{detail:"Not Found"}` when the user has no profile row). The default grant does not carry `read:profile`.
40
+
35
41
  GET `/developer/v2/activity/workout`, `/developer/v2/activity/sleep`, `/developer/v2/recovery`, `/developer/v2/cycle` return `{records,next_token}`. `limit` defaults to 10, maximum 25; `nextToken` continues pages. Results sort newest start first; `start` includes equal timestamps, `end` excludes equal starts and defaults to emulate now. The collection time-window implementation uses start timestamps, including activities spanning the end instant. Scope names are `read:workout`, `read:sleep`, `read:recovery`, `read:cycles`.
36
42
 
37
43
  Seed `records: [{key,userId,collection,data}]`; `data` is a synthetic provider-shaped record. **Recovery has `cycle_id` and `sleep_id`, not `id`, `start`, or `end`**: seed a matching sleep record to supply its time window. This corrects the issue's generic recovery field list using the official schema. Missing related-sleep fixtures are excluded. Cycle ids remain numbers; workout/sleep ids remain UUIDs. Metrics and score states are passed through, preserving null or absent metrics. Distinct storage keys can model duplicate vendor records. Cursor internals are local stand-ins; consumers must retain the same query while paginating.
@@ -44,14 +50,16 @@ Standard relocatable `/__admin` health/state/reset/clock/journal/Timeline/fault
44
50
 
45
51
  Derived from the official [OpenAPI](https://api.prod.whoop.com/developer/doc/openapi.json), [OAuth reference](https://developer.whoop.com/docs/developing/oauth/), and [refresh example](https://developer.whoop.com/docs/tutorials/refresh-token-javascript/). The contract retains the official collection response schemas. Authorized live data and OAuth success were not probed; no live credentials used.
46
52
 
53
+ **Best guess, not oracle-verified:** the authorization endpoint and the profile route are not observed live. `/oauth/oauth2/auth` and `/oauth/oauth2/token` are Ory Hydra paths, so redirect status (302), the `error`/`error_description`/`state` redirect shape, the 8 character `state` minimum, and the error codes follow Hydra and its fosite library plus the WHOOP OAuth page. The statuses and JSON bodies for an unknown client or unregistered `redirect_uri` (Hydra renders an error page on the live service), the `invalid_scope` allow-list, treating a missing `scope` as an empty grant, S256-only PKCE, `access_denied`/`server_error` for consent controls, and the 403 for a missing `read:profile` scope are the emulator's choices, not observed vendor responses. The profile shape is the official `UserBasicProfile` schema.
54
+
47
55
  `bun test` runs acceptance, all-operation self-parity and divergence detection. `bun scripts/python-smoke.ts` uses `uv` to run actual requests 2.32.5 and httpx 0.28.1 against local HTTP. It is not the private consumer itself. `bun run parity` requires `WHOOP_ACCESS_TOKEN` and performs a safe collection-envelope probe without printing health data.
48
56
 
49
57
  ## Deliberately not modelled
50
58
 
51
- No real users, device pairing, sensors, consent UI, hardware SDK, webhook delivery, profile/body measurements, partner APIs or scoring computation. No cursor-format parity, real quota enforcement, concurrent refresh grace period or private-client integration claim. Partial synthetic records can be seeded deliberately; validate production fixtures against the supplied official schemas. Recovery relies on matching synthetic sleep fixtures.
59
+ No real users, device pairing, sensors, a consent page (the `consents` rows stand in for the user's answer), hardware SDK, webhook delivery, body measurements, partner APIs or scoring computation. No cursor-format parity, real quota enforcement, concurrent refresh grace period or private-client integration claim. Partial synthetic records can be seeded deliberately; validate production fixtures against the supplied official schemas. Recovery relies on matching synthetic sleep fixtures.
52
60
 
53
61
  ## API
54
62
 
55
- Root runtime exports: `WhoopAPI`, `WHOOP_NAMESPACE`, `COLLECTION_SCOPES`, `createRuntime`, `WHOOP_PRESETS`, `document`, `operationIds`, `supportedOperationIds`. Types: `WhoopAPIOptions`, `Grant`, `OAuthCode`, `Client`, `DataRecord`, `CollectionName`, `WhoopRuntimeOptions`, `WhoopRuntime`, `OperationId`, `SupportedOperationId`.
63
+ Root runtime exports: `WhoopAPI`, `WHOOP_NAMESPACE`, `COLLECTION_SCOPES`, `KNOWN_SCOPES`, `MIN_STATE_LENGTH`, `createRuntime`, `WHOOP_PRESETS`, `document`, `operationIds`, `supportedOperationIds`. Types: `WhoopAPIOptions`, `Grant`, `OAuthCode`, `Client`, `Consent`, `DataRecord`, `CollectionName`, `WhoopRuntimeOptions`, `WhoopRuntime`, `OperationId`, `SupportedOperationId`.
56
64
 
57
65
  `/server`: `createServer`, `serveTarget`, `DEFAULT_PORT`; types `WhoopServerOptions`, `WhoopServer`.
package/SUPPORT.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Generated from `openapi.yaml`; do not edit by hand.
4
4
 
5
- - operations in spec: **5**
6
- - supported by the emulator: **5**
7
- - parity enabled: **5**
5
+ - operations in spec: **7**
6
+ - supported by the emulator: **7**
7
+ - parity enabled: **7**
8
8
 
9
9
  | operationId | route | emulator | parity | notes |
10
10
  | --- | --- | --- | --- | --- |
@@ -12,4 +12,6 @@ Generated from `openapi.yaml`; do not edit by hand.
12
12
  | `ListSleep` | `GET /developer/v2/activity/sleep` | ✅ supported | ✅ | |
13
13
  | `ListRecovery` | `GET /developer/v2/recovery` | ✅ supported | ✅ | |
14
14
  | `ListCycle` | `GET /developer/v2/cycle` | ✅ supported | ✅ | |
15
+ | `GetProfileBasic` | `GET /developer/v2/user/profile/basic` | ✅ supported | ✅ | |
16
+ | `OAuthAuthorize` | `GET /oauth/oauth2/auth` | ✅ supported | ⚠️ unsafe (opt-in) | |
15
17
  | `OAuthToken` | `POST /oauth/oauth2/token` | ✅ supported | ⚠️ unsafe (opt-in) | |
@@ -9,7 +9,7 @@ import {
9
9
  parseFaultHeader,
10
10
  resolveAdminPrefix,
11
11
  restoreClock
12
- } from "./chunk-7HJPXMON.js";
12
+ } from "./chunk-JI3J73EG.js";
13
13
 
14
14
  // ../../adapters/node/dist/cli.js
15
15
  import { readFile as readFile5 } from "node:fs/promises";
@@ -3057,7 +3057,7 @@ async function preflightFleet(config, options) {
3057
3057
  break;
3058
3058
  }
3059
3059
  }
3060
- targets.set(name, { ...target, packageVersion: packageVersion ?? "1.6.0" });
3060
+ targets.set(name, { ...target, packageVersion: packageVersion ?? "1.8.0" });
3061
3061
  } catch (error) {
3062
3062
  throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
3063
3063
  }
@@ -3283,7 +3283,11 @@ var serve = async (api, options = {}) => {
3283
3283
  // ../../adapters/node/dist/listen.js
3284
3284
  var listen = async (api, options = {}) => {
3285
3285
  const host = options.host ?? "127.0.0.1";
3286
- const server = await serve(api, { port: options.port ?? 0, host });
3286
+ const server = await serve(api, {
3287
+ port: options.port ?? 0,
3288
+ host,
3289
+ ...options.maxBodyBytes !== void 0 ? { maxBodyBytes: options.maxBodyBytes } : {}
3290
+ });
3287
3291
  const address = server.address();
3288
3292
  const port = typeof address === "object" && address !== null ? address.port : options.port ?? 0;
3289
3293
  const shown = host.includes(":") ? `[${host}]` : host;
@@ -3482,7 +3486,8 @@ var httpChild = async (target, entry, options, admission, generation, privateAcc
3482
3486
  try {
3483
3487
  server = await listen(api, {
3484
3488
  port: entry.port ?? target.defaultPort,
3485
- host: entry.host ?? "127.0.0.1"
3489
+ host: entry.host ?? "127.0.0.1",
3490
+ ...target.maxBodyBytes !== void 0 ? { maxBodyBytes: target.maxBodyBytes } : {}
3486
3491
  });
3487
3492
  target.listening?.(server);
3488
3493
  } catch (error) {
@@ -4873,7 +4878,11 @@ var start = async (target, values, config) => {
4873
4878
  });
4874
4879
  if (config.idBase !== void 0)
4875
4880
  runtime.setIdBase?.(config.idBase);
4876
- const listening = await listen(runtime, { port: config.port, host: config.host });
4881
+ const listening = await listen(runtime, {
4882
+ port: config.port,
4883
+ host: config.host,
4884
+ ...target.maxBodyBytes !== void 0 ? { maxBodyBytes: target.maxBodyBytes } : {}
4885
+ });
4877
4886
  target.listening?.(listening);
4878
4887
  console.log(`${target.name} emulator listening on ${listening.url}`);
4879
4888
  console.log(`${target.name} health: GET ${listening.url}${adminPrefix}/health`);
@@ -5005,4 +5014,4 @@ export {
5005
5014
  createServer2 as createServer,
5006
5015
  serveTarget
5007
5016
  };
5008
- //# sourceMappingURL=chunk-BR7V52C2.js.map
5017
+ //# sourceMappingURL=chunk-A7KW6YR6.js.map