@crvouga/mockingbird-service-whoop 1.12.0 → 1.14.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 +17 -1
- package/dist/chunk-CVNEDIVD.js +369 -0
- package/dist/chunk-CVNEDIVD.js.map +7 -0
- package/dist/chunk-QHDVXA6F.js +36 -0
- package/dist/chunk-QHDVXA6F.js.map +7 -0
- package/dist/cli.js +3 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +102 -94
- package/dist/index.js +1 -2
- package/dist/server.d.ts +45 -37
- package/dist/server.js +2 -3
- package/package.json +3 -2
- package/dist/admin-ui.js +0 -27
- package/dist/admin-ui.js.map +0 -7
- package/dist/chunk-EGBD5MD3.js +0 -5438
- package/dist/chunk-EGBD5MD3.js.map +0 -7
- package/dist/chunk-NMDB2AS4.js +0 -7
- package/dist/chunk-NMDB2AS4.js.map +0 -7
- package/dist/chunk-YWL5TTJ3.js +0 -5083
- package/dist/chunk-YWL5TTJ3.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-whoop
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1.14.0 (2026-11-17)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- let a runtime skip the checkpoint it records after every write ([40a7387](https://github.com/crvouga/mockingbird/commit/40a7387208ec5f1fc0108859eded818efc3e3b5e))
|
|
8
|
+
|
|
9
|
+
## 1.13.0 (2026-11-14)
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
- expand in-process emulation and resolve Plane and streaming gaps ([e6733fd](https://github.com/crvouga/mockingbird/commit/e6733fd00f5dd03259f36cc0f452780a7e0deea4))
|
|
14
|
+
- add browser runtime polyfills and edge-snapping app cycle ([815b739](https://github.com/crvouga/mockingbird/commit/815b7399f1e058b89b3fa025f79a5014172b3ab8))
|
|
15
|
+
- run lab systems in browser PR previews ([df14882](https://github.com/crvouga/mockingbird/commit/df148828ca66db1e20cf9fa2fdf38b56b5116da4))
|
|
16
|
+
- publish the shared runtime once; services depend on it instead of inlining it ([4903c4a](https://github.com/crvouga/mockingbird/commit/4903c4a748fd801001ad3fd34b6016b55e0f9953))
|
|
17
|
+
- add transcript storage, signature and meetings; tags, teams, messages, macros and calls ([ee21e12](https://github.com/crvouga/mockingbird/commit/ee21e12024768bd52c6902b1722fb35a94d2444b))
|
|
18
|
+
|
|
19
|
+
## 1.12.0 (2026-11-12)
|
|
4
20
|
|
|
5
21
|
### Features
|
|
6
22
|
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
|
|
19
|
+
// <define:__MOCKINGBIRD_ADMIN_BRAND__>
|
|
20
|
+
var define_MOCKINGBIRD_ADMIN_BRAND_default = { vendor: "WHOOP", website: "https://www.whoop.com", docs: "https://developer.whoop.com/api/", guide: "https://m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VVXz8SlJkjMuNvav92+uZcAtWWh6RsaOUbf7kKqqiVoGI4QgOSkZZrMZgUAAriHXsrcPABAfF4e4+HgwVcV1lwszMzOayBNC1NiYmJd6L13+lTE5iQO33I1+58BTdWaT6U1CiKYdxTnH0PAQPu38FM5+pybyAOAeH0dnZye6urs1kweAKIPhVPrq1W/NkwfC1AGlpaWpnV1df/PL8oOaR74LkCSpb1VKyv7urq4zN35f5Hgul8ubkZ5+xR8IVKqquuii68uAKAiTCXFxzzn7+j66tS3s2eVwOFqTEhN/IIriki8jdwuUENliNr/8rSf2/zNc+5JHBmchkpmds8s9Pv7bYCi07oujuDREQZi0mM0v5+bmvt505kzYumXZwzc3L69seHT01wFZruKf42F8pZAkyRkXE/NSYcG6Q/85WRf+jhEaCd1z7z1ZA4PXX/D5/fu/6JdKQogaZTDUJyYk/LS5ztaUkpUWsWDXPKNbt2yJutbZ+ZBnevrHM8Fg8Upqaa2QJGnAZIz+c3Zm1pstLS2acjNt4Q9Ab2+vMj09fcVaUHBMUdUhxlgS5zyeR7hT1QJCCJMkqd9kNL6dkpT03FPffPLoocOHvZrtb+enH75zlLz4y5+nusfHN/v98p6ZYLBMUZR0zrmBcx5xzLlUIyiK4qgoivboKMPH8XFxx+8rKna8fejQkr5+RwXciIcffkjndPZnDY+O3AOO0vHJyXXg3Mw4lxhjwixnogqCoHDOZbPJ2KfXGy6aTaa25MTET20NDZpnOxz+B7DWTUeP1HMRAAAAAElFTkSuQmCC", color: null, description: "WHOOP wearable fitness data API." };
|
|
21
|
+
|
|
22
|
+
// mockingbird-service-runtime:@crvouga/mockingbird-runtime/service
|
|
23
|
+
var service_exports = {};
|
|
24
|
+
__export(service_exports, {
|
|
25
|
+
PACKAGE_VERSION: () => PACKAGE_VERSION,
|
|
26
|
+
createRuntime: () => createRuntime
|
|
27
|
+
});
|
|
28
|
+
__reExport(service_exports, service_star);
|
|
29
|
+
import * as service_star from "@crvouga/mockingbird-runtime/service";
|
|
30
|
+
import { PACKAGE_VERSION as SHARED_VERSION, createRuntime as sharedRuntime } from "@crvouga/mockingbird-runtime/service";
|
|
31
|
+
var PACKAGE_VERSION = true ? "1.14.0" : SHARED_VERSION;
|
|
32
|
+
var ADMIN_BRAND = typeof define_MOCKINGBIRD_ADMIN_BRAND_default === "object" ? define_MOCKINGBIRD_ADMIN_BRAND_default : void 0;
|
|
33
|
+
var createRuntime = (options) => sharedRuntime({
|
|
34
|
+
...options,
|
|
35
|
+
version: options.version ?? PACKAGE_VERSION,
|
|
36
|
+
adminBrand: options.adminBrand ?? ADMIN_BRAND
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// src/generated/openapi.ts
|
|
40
|
+
var document = JSON.parse(`{"openapi":"3.0.3","info":{"title":"WHOOP v2 emulator","version":"2.0"},"servers":[{"url":"https://api.prod.whoop.com"}],"paths":{"/developer/v2/activity/workout":{"get":{"tags":["Workout"],"description":"Get all workouts for a user, paginated. Results are sorted by start time in descending order.","operationId":"ListWorkout","parameters":[{"name":"limit","in":"query","description":"Limit on the number of workouts returned","schema":{"maximum":25,"type":"integer","format":"int32","default":10}},{"name":"start","in":"query","description":"Return workouts that occurred after or during (inclusive) this time. If not specified, the response will not filter workouts by a minimum time.","schema":{"type":"string","format":"date-time"}},{"name":"end","in":"query","description":"Return workouts that intersect this time or ended before (exclusive) this time. If not specified, \`end\` will be set to \`now\`.","schema":{"type":"string","format":"date-time"}},{"name":"nextToken","in":"query","description":"Optional next token from the previous response to get the next page. If not provided, the first page in the collection is returned","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkoutCollection"}}}},"400":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"401":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"403":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"429":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"500":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}}},"security":[{"OAuth":["read:workout"]}],"x-mockingbird":{"parity":{"safe":true}}}},"/developer/v2/activity/sleep":{"get":{"tags":["Sleep"],"description":"Get all sleeps for a user, paginated. Results are sorted by start time in descending order.","operationId":"ListSleep","parameters":[{"name":"limit","in":"query","description":"Limit on the number of sleeps returned","schema":{"maximum":25,"type":"integer","format":"int32","default":10}},{"name":"start","in":"query","description":"Return sleeps that occurred after or during (inclusive) this time. If not specified, the response will not filter sleeps by a minimum time.","schema":{"type":"string","format":"date-time"}},{"name":"end","in":"query","description":"Return sleeps that intersect this time or ended before (exclusive) this time. If not specified, \`end\` will be set to \`now\`.","schema":{"type":"string","format":"date-time"}},{"name":"nextToken","in":"query","description":"Optional next token from the previous response to get the next page. If not provided, the first page in the collection is returned","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedSleepResponse"}}}},"400":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"401":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"403":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"429":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"500":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}}},"security":[{"OAuth":["read:sleep"]}],"x-mockingbird":{"parity":{"safe":true}}}},"/developer/v2/recovery":{"get":{"tags":["Recovery"],"description":"Get all recoveries for a user, paginated. Results are sorted by start time of the related sleep in descending order.","operationId":"ListRecovery","parameters":[{"name":"limit","in":"query","description":"Limit on the number of recoveries returned","schema":{"maximum":25,"type":"integer","format":"int32","default":10}},{"name":"start","in":"query","description":"Return recoveries that occurred after or during (inclusive) this time. If not specified, the response will not filter recoveries by a minimum time.","schema":{"type":"string","format":"date-time"}},{"name":"end","in":"query","description":"Return recoveries that intersect this time or ended before (exclusive) this time. If not specified, \`end\` will be set to \`now\`.","schema":{"type":"string","format":"date-time"}},{"name":"nextToken","in":"query","description":"Optional next token from the previous response to get the next page. If not provided, the first page in the collection is returned","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecoveryCollection"}}}},"400":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"401":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"403":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"429":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"500":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}}},"security":[{"OAuth":["read:recovery"]}],"x-mockingbird":{"parity":{"safe":true}}}},"/developer/v2/cycle":{"get":{"tags":["Cycle"],"description":"Get all physiological cycles for a user, paginated. Results are sorted by start time in descending order.","operationId":"ListCycle","parameters":[{"name":"limit","in":"query","description":"Limit on the number of cycles returned","schema":{"maximum":25,"type":"integer","format":"int32","default":10}},{"name":"start","in":"query","description":"Return cycles that occurred after or during (inclusive) this time. If not specified, the response will not filter cycles by a minimum time.","schema":{"type":"string","format":"date-time"}},{"name":"end","in":"query","description":"Return cycles that intersect this time or ended before (exclusive) this time. If not specified, \`end\` will be set to \`now\`.","schema":{"type":"string","format":"date-time"}},{"name":"nextToken","in":"query","description":"Optional next token from the previous response to get the next page. If not provided, the first page in the collection is returned","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedCycleResponse"}}}},"400":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"401":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"403":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"429":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"500":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}}},"security":[{"OAuth":["read:cycles"]}],"x-mockingbird":{"parity":{"safe":true}}}},"/developer/v2/user/profile/basic":{"get":{"tags":["User"],"description":"Get the user's basic profile, including their name and email.","operationId":"GetProfileBasic","responses":{"200":{"description":"Successful request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserBasicProfile"}}}},"401":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"403":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"404":{"description":"No profile for the user","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"429":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"500":{"description":"Provider error (preset body is a scripted fixture)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}}},"security":[{"OAuth":["read:profile"]}],"x-mockingbird":{"parity":{"safe":true}}}},"/oauth/oauth2/auth":{"get":{"operationId":"OAuthAuthorize","description":"Authorization endpoint (Ory Hydra on WHOOP). The emulator has no consent page: the consent row for the client decides, and the browser is redirected to redirect_uri with code and state, or error and state. An unknown client or unregistered redirect_uri is answered in place, never redirected to.","x-mockingbird":{"parity":{"safe":false}},"security":[],"parameters":[{"name":"response_type","in":"query","description":"Must be \`code\`.","schema":{"type":"string"}},{"name":"client_id","in":"query","description":"The registered client.","schema":{"type":"string"}},{"name":"redirect_uri","in":"query","description":"Must match a redirect URI registered for the client exactly.","schema":{"type":"string"}},{"name":"scope","in":"query","description":"Space-delimited scopes.","schema":{"type":"string"}},{"name":"state","in":"query","description":"Opaque CSRF value, echoed unchanged. At least 8 characters.","schema":{"type":"string"}},{"name":"code_challenge","in":"query","description":"Optional PKCE challenge.","schema":{"type":"string"}},{"name":"code_challenge_method","in":"query","description":"Only \`S256\`.","schema":{"type":"string"}}],"responses":{"302":{"description":"Redirect to redirect_uri with code and state, or error, error_description and state","headers":{"Location":{"schema":{"type":"string"}}}},"400":{"description":"redirect_uri missing or not registered, or client_id missing (never redirected)","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"401":{"description":"Unknown client","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}}}}},"/oauth/oauth2/token":{"post":{"operationId":"OAuthToken","x-mockingbird":{"parity":{"safe":false}},"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","required":["grant_type"],"properties":{"grant_type":{"type":"string"},"code":{"type":"string"},"refresh_token":{"type":"string"},"client_id":{"type":"string"},"client_secret":{"type":"string"},"redirect_uri":{"type":"string"},"code_verifier":{"type":"string"},"scope":{"type":"string"}}}}}},"responses":{"200":{"description":"Token","content":{"application/json":{"schema":{"type":"object","required":["access_token","expires_in","token_type","scope"],"properties":{"access_token":{"type":"string","x-mockingbird-volatile":{"kind":"token"}},"refresh_token":{"type":"string","x-mockingbird-volatile":{"kind":"token"}},"expires_in":{"type":"integer"},"token_type":{"type":"string"},"scope":{"type":"string"}}}}}},"400":{"description":"OAuth error","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string"},"status":{"type":"integer"},"error_description":{"type":"string"}}}}}}}}}},"components":{"schemas":{"WorkoutCollection":{"type":"object","properties":{"records":{"type":"array","description":"The collection of records in this page.","items":{"$ref":"#/components/schemas/WorkoutV2"}},"next_token":{"type":"string","description":"A token that can be used on the next request to access the next page of records. If the token is not present, there are no more records in the collection.","example":"MTIzOjEyMzEyMw"}},"description":"Paginated collection of workout activities with next token for pagination"},"PaginatedSleepResponse":{"type":"object","properties":{"records":{"type":"array","description":"The collection of records in this page.","items":{"$ref":"#/components/schemas/Sleep"}},"next_token":{"type":"string","description":"A token that can be used on the next request to access the next page of records. If the token is not present, there are no more records in the collection.","example":"MTIzOjEyMzEyMw"}}},"RecoveryCollection":{"type":"object","properties":{"records":{"type":"array","description":"The collection of records in this page.","items":{"$ref":"#/components/schemas/Recovery"}},"next_token":{"type":"string","description":"A token that can be used on the next request to access the next page of records. If the token is not present, there are no more records in the collection.","example":"MTIzOjEyMzEyMw"}},"description":"Paginated collection of recovery activities with next token for pagination"},"PaginatedCycleResponse":{"type":"object","properties":{"records":{"type":"array","description":"The collection of records in this page.","items":{"$ref":"#/components/schemas/Cycle"}},"next_token":{"type":"string","description":"A token that can be used on the next request to access the next page of records. If the token is not present, there are no more records in the collection.","example":"MTIzOjEyMzEyMw"}}},"WorkoutV2":{"required":["created_at","end","id","score_state","sport_name","start","timezone_offset","updated_at","user_id"],"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the workout activity","format":"uuid","example":"ecfc6a15-4661-442f-a9a4-f160dd7afae8"},"v1_id":{"type":"integer","description":"Previous generation identifier for the activity. Will not exist past 09/01/2025","format":"int64","example":1043},"user_id":{"type":"integer","description":"The WHOOP User who performed the workout","format":"int64","example":9012},"created_at":{"type":"string","description":"The time the workout activity was recorded in WHOOP","format":"date-time","example":"2022-04-24T11:25:44.774Z"},"updated_at":{"type":"string","description":"The time the workout activity was last updated in WHOOP","format":"date-time","example":"2022-04-24T14:25:44.774Z"},"start":{"type":"string","description":"Start time bound of the workout","format":"date-time","example":"2022-04-24T02:25:44.774Z"},"end":{"type":"string","description":"End time bound of the workout","format":"date-time","example":"2022-04-24T10:25:44.774Z"},"timezone_offset":{"type":"string","description":"The user's timezone offset at the time the workout was recorded. Follows format for Time Zone Designator (TZD) - '+hh:mm', '-hh:mm', or 'Z'.","example":"-05:00","externalDocs":{"description":"Learn more about the Time Zone Designator from the W3C Standard","url":"https://www.w3.org/TR/NOTE-datetime"}},"sport_name":{"type":"string","description":"Name of the WHOOP Sport performed during the workout","example":"running"},"score_state":{"type":"string","description":"\`SCORED\` means the workout activity was scored and the measurement values will be present. \`PENDING_SCORE\` means WHOOP is currently evaluating the workout activity. \`UNSCORABLE\` means this activity could not be scored for some reason - commonly because there is not enough user metric data for the time range.","example":"SCORED","enum":["SCORED","PENDING_SCORE","UNSCORABLE"]},"score":{"$ref":"#/components/schemas/WorkoutScore"},"sport_id":{"type":"integer","description":"ID of the WHOOP Sport performed during the workout. Will not exist past 09/01/2025","format":"int32","example":1}},"description":"A WHOOP workout activity with full details and scoring information"},"Sleep":{"required":["created_at","cycle_id","end","id","nap","score_state","start","timezone_offset","updated_at","user_id"],"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the sleep activity","format":"uuid","example":"ecfc6a15-4661-442f-a9a4-f160dd7afae8"},"cycle_id":{"type":"integer","description":"Unique identifier for the cycle this sleep belongs to","format":"int64","example":93845},"v1_id":{"type":"integer","description":"Previous generation identifier for the activity. Will not exist past 09/01/2025","format":"int64","example":93845},"user_id":{"type":"integer","description":"The WHOOP User who performed the sleep activity","format":"int64","example":10129},"created_at":{"type":"string","description":"The time the sleep activity was recorded in WHOOP","format":"date-time","example":"2022-04-24T11:25:44.774Z"},"updated_at":{"type":"string","description":"The time the sleep activity was last updated in WHOOP","format":"date-time","example":"2022-04-24T14:25:44.774Z"},"start":{"type":"string","description":"Start time bound of the sleep","format":"date-time","example":"2022-04-24T02:25:44.774Z"},"end":{"type":"string","description":"End time bound of the sleep","format":"date-time","example":"2022-04-24T10:25:44.774Z"},"timezone_offset":{"type":"string","description":"The user's timezone offset at the time the sleep was recorded. Follows format for Time Zone Designator (TZD) - '+hh:mm', '-hh:mm', or 'Z'.","example":"-05:00","externalDocs":{"description":"Learn more about the Time Zone Designator from the W3C Standard","url":"https://www.w3.org/TR/NOTE-datetime"}},"nap":{"type":"boolean","description":"If true, this sleep activity was a nap for the user","example":false},"score_state":{"type":"string","description":"\`SCORED\` means the sleep activity was scored and the measurement values will be present. \`PENDING_SCORE\` means WHOOP is currently evaluating the sleep activity. \`UNSCORABLE\` means this activity could not be scored for some reason - commonly because there is not enough user metric data for the time range.","example":"SCORED","enum":["SCORED","PENDING_SCORE","UNSCORABLE"]},"score":{"$ref":"#/components/schemas/SleepScore"}},"description":"The collection of records in this page."},"Recovery":{"required":["created_at","cycle_id","score_state","sleep_id","updated_at","user_id"],"type":"object","properties":{"cycle_id":{"type":"integer","description":"The Recovery represents how recovered the user is for this physiological cycle","format":"int64","example":93845},"sleep_id":{"type":"string","description":"ID of the Sleep associated with the Recovery","format":"uuid","example":"123e4567-e89b-12d3-a456-426614174000"},"user_id":{"type":"integer","description":"The WHOOP User for the recovery","format":"int64","example":10129},"created_at":{"type":"string","description":"The time the recovery was recorded in WHOOP","format":"date-time","example":"2022-04-24T11:25:44.774Z"},"updated_at":{"type":"string","description":"The time the recovery was last updated in WHOOP","format":"date-time","example":"2022-04-24T14:25:44.774Z"},"score_state":{"type":"string","description":"\`SCORED\` means the recovery was scored and the measurement values will be present. \`PENDING_SCORE\` means WHOOP is currently evaluating the cycle. \`UNSCORABLE\` means this activity could not be scored for some reason - commonly because there is not enough user metric data for the time range.","example":"SCORED","enum":["SCORED","PENDING_SCORE","UNSCORABLE"]},"score":{"$ref":"#/components/schemas/RecoveryScore"}}},"Cycle":{"required":["created_at","id","score_state","start","timezone_offset","updated_at","user_id"],"type":"object","properties":{"id":{"type":"integer","description":"Unique identifier for the physiological cycle","format":"int64","example":93845},"user_id":{"type":"integer","description":"The WHOOP User for the physiological cycle","format":"int64","example":10129},"created_at":{"type":"string","description":"The time the cycle was recorded in WHOOP","format":"date-time","example":"2022-04-24T11:25:44.774Z"},"updated_at":{"type":"string","description":"The time the cycle was last updated in WHOOP","format":"date-time","example":"2022-04-24T14:25:44.774Z"},"start":{"type":"string","description":"Start time bound of the cycle","format":"date-time","example":"2022-04-24T02:25:44.774Z"},"end":{"type":"string","description":"End time bound of the cycle. If not present, the user is currently in this cycle","format":"date-time","example":"2022-04-24T10:25:44.774Z"},"timezone_offset":{"type":"string","description":"The user's timezone offset at the time the cycle was recorded. Follows format for Time Zone Designator (TZD) - '+hh:mm', '-hh:mm', or 'Z'.","example":"-05:00","externalDocs":{"description":"Learn more about the Time Zone Designator from the W3C Standard","url":"https://www.w3.org/TR/NOTE-datetime"}},"score_state":{"type":"string","description":"\`SCORED\` means the cycle was scored and the measurement values will be present. \`PENDING_SCORE\` means WHOOP is currently evaluating the cycle. \`UNSCORABLE\` means this activity could not be scored for some reason - commonly because there is not enough user metric data for the time range.","example":"SCORED","enum":["SCORED","PENDING_SCORE","UNSCORABLE"]},"score":{"$ref":"#/components/schemas/CycleScore"},"step_count":{"type":"integer","description":"Total number of steps taken during the cycle. Null when no step data exists for the cycle (e.g. the device was not worn for the full cycle).","format":"int32","nullable":true,"example":8234}},"description":"The collection of records in this page."},"WorkoutScore":{"required":["average_heart_rate","kilojoule","max_heart_rate","percent_recorded","strain","zone_durations"],"type":"object","properties":{"strain":{"type":"number","description":"WHOOP metric of the cardiovascular load - the level of strain the workout had on the user's cardiovascular system based on the user's heart rate. Strain is scored on a scale from 0 to 21.","format":"float","example":8.2463,"externalDocs":{"description":"WHOOP Strain","url":"https://api.prod.whoop.com/url-mapping-service/v1/STRAIN"}},"average_heart_rate":{"type":"integer","description":"The user's average heart rate (beats per minute) during the workout.","format":"int32","example":123},"max_heart_rate":{"type":"integer","description":"The user's max heart rate (beats per minute) during the workout.","format":"int32","example":146},"kilojoule":{"type":"number","description":"Kilojoules the user expended during the workout.","format":"float","example":1569.34033203125},"percent_recorded":{"type":"number","description":"Percentage (0-100%) of heart rate data WHOOP received during the workout.","format":"float","example":100},"distance_meter":{"type":"number","description":"The distance the user travelled during the workout. Only present if distance data sent to WHOOP","format":"float","example":1772.77035916},"altitude_gain_meter":{"type":"number","description":"The altitude gained during the workout. This measurement does not account for downward travel - it is strictly a measure of altitude climbed. If a member climbed up and down a 1,000 meter mountain, ending at the same altitude, this measurement would be 1,000 meters. Only present if altitude data is included as part of the workout","format":"float","example":46.64384460449},"altitude_change_meter":{"type":"number","description":"The altitude difference between the start and end points of the workout. If a member climbed up and down a mountain, ending at the same altitude, this measurement would be 0. Only present if altitude data is included as part of the workout","format":"float","example":-0.781372010707855},"zone_durations":{"$ref":"#/components/schemas/ZoneDurations"}},"description":"WHOOP's measurements and evaluation of the workout activity. Only present if the Workout State is \`SCORED\`"},"SleepScore":{"required":["sleep_needed","stage_summary"],"type":"object","properties":{"stage_summary":{"$ref":"#/components/schemas/SleepStageSummary"},"sleep_needed":{"$ref":"#/components/schemas/SleepNeeded"},"respiratory_rate":{"type":"number","description":"The user's respiratory rate during the sleep.","format":"float","example":16.11328125},"sleep_performance_percentage":{"type":"number","description":"A percentage (0-100%) of the time a user is asleep over the amount of sleep the user needed. May not be reported if WHOOP does not have enough data about a user yet to calculate Sleep Need.","format":"float","example":98},"sleep_consistency_percentage":{"type":"number","description":"Percentage (0-100%) of how similar this sleep and wake times compared to the previous day. May not be reported if WHOOP does not have enough sleep data about a user yet to understand consistency.","format":"float","example":90,"externalDocs":{"description":"WHOOP Locker - What is Sleep Consistency?","url":"https://www.whoop.com/thelocker/new-feature-sleep-consistency-why-we-track-it/"}},"sleep_efficiency_percentage":{"type":"number","description":"A percentage (0-100%) of the time you spend in bed that you are actually asleep.","format":"float","example":91.69533848,"externalDocs":{"description":"WHOOP Locker - Sleep Efficiency: What is It, How Do You Stack Up & How Can You Improve?","url":"https://www.whoop.com/thelocker/app-feature-improve-sleep-efficiency/"}}},"description":"WHOOP's measurements and evaluation of the sleep activity. Only present if the Sleep State is \`SCORED\`"},"RecoveryScore":{"required":["hrv_rmssd_milli","recovery_score","resting_heart_rate","user_calibrating"],"type":"object","properties":{"user_calibrating":{"type":"boolean","description":"True if the user is still calibrating and not enough data is available in WHOOP to provide an accurate recovery.","example":false},"recovery_score":{"type":"number","description":"Percentage (0-100%) that reflects how well prepared the user's body is to take on Strain. The Recovery score is a measure of the user body's \\"return to baseline\\" after a stressor.","format":"float","example":44,"externalDocs":{"description":"WHOOP Recovery","url":"https://api.prod.whoop.com/url-mapping-service/v1/RECOVERY"}},"resting_heart_rate":{"type":"number","description":"The user's resting heart rate.","format":"float","example":64},"hrv_rmssd_milli":{"type":"number","description":"The user's Heart Rate Variability measured using Root Mean Square of Successive Differences (RMSSD), in milliseconds.","format":"float","example":31.813562},"spo2_percentage":{"type":"number","description":"The percentage of oxygen in the user's blood. Only present if the user is on 4.0 or greater.","format":"float","example":95.6875},"skin_temp_celsius":{"type":"number","description":"The user's skin temperature, in Celsius. Only present if the user is on 4.0 or greater.","format":"float","example":33.7}},"description":"WHOOP's measurements and evaluation of the recovery. Only present if the Recovery State is \`SCORED\`"},"CycleScore":{"required":["average_heart_rate","kilojoule","max_heart_rate","strain"],"type":"object","properties":{"strain":{"type":"number","description":"WHOOP metric of the cardiovascular load - the level of strain on the user's cardiovascular system based on the user's heart rate during the cycle. Strain is scored on a scale from 0 to 21.","format":"float","example":5.2951527,"externalDocs":{"description":"WHOOP Strain","url":"https://api.prod.whoop.com/url-mapping-service/v1/STRAIN"}},"kilojoule":{"type":"number","description":"Kilojoules the user expended during the cycle.","format":"float","example":8288.297},"average_heart_rate":{"type":"integer","description":"The user's average heart rate during the cycle.","format":"int32","example":68},"max_heart_rate":{"type":"integer","description":"The user's max heart rate during the cycle.","format":"int32","example":141}},"description":"WHOOP's measurements and evaluation of the cycle. Only present if the score state is \`SCORED\`"},"ZoneDurations":{"required":["zone_five_milli","zone_four_milli","zone_one_milli","zone_three_milli","zone_two_milli","zone_zero_milli"],"type":"object","properties":{"zone_zero_milli":{"type":"integer","description":"Duration in milliseconds spent in Zone 0 (very light activity)","format":"int64","example":300000},"zone_one_milli":{"type":"integer","description":"Duration in milliseconds spent in Zone 1 (light activity)","format":"int64","example":600000},"zone_two_milli":{"type":"integer","description":"Duration in milliseconds spent in Zone 2 (moderate activity)","format":"int64","example":900000},"zone_three_milli":{"type":"integer","description":"Duration in milliseconds spent in Zone 3 (hard activity)","format":"int64","example":900000},"zone_four_milli":{"type":"integer","description":"Duration in milliseconds spent in Zone 4 (very hard activity)","format":"int64","example":600000},"zone_five_milli":{"type":"integer","description":"Duration in milliseconds spent in Zone 5 (maximum effort)","format":"int64","example":300000}},"description":"Breakdown of time spent in each heart rate zone during the workout.","externalDocs":{"description":"WHOOP Locker - Training with Heart Rate Zones","url":"https://www.whoop.com/thelocker/max-heart-rate-training-zones/"}},"SleepStageSummary":{"required":["disturbance_count","sleep_cycle_count","total_awake_time_milli","total_in_bed_time_milli","total_light_sleep_time_milli","total_no_data_time_milli","total_rem_sleep_time_milli","total_slow_wave_sleep_time_milli"],"type":"object","properties":{"total_in_bed_time_milli":{"type":"integer","description":"Total time the user spent in bed, in milliseconds","format":"int32","example":30272735},"total_awake_time_milli":{"type":"integer","description":"Total time the user spent awake, in milliseconds","format":"int32","example":1403507},"total_no_data_time_milli":{"type":"integer","description":"Total time WHOOP did not receive data from the user during the sleep, in milliseconds","format":"int32","example":0},"total_light_sleep_time_milli":{"type":"integer","description":"Total time the user spent in light sleep, in milliseconds","format":"int32","example":14905851},"total_slow_wave_sleep_time_milli":{"type":"integer","description":"Total time the user spent in Slow Wave Sleep (SWS), in milliseconds","format":"int32","example":6630370},"total_rem_sleep_time_milli":{"type":"integer","description":"Total time the user spent in Rapid Eye Movement (REM) sleep, in milliseconds","format":"int32","example":5879573},"sleep_cycle_count":{"type":"integer","description":"Number of sleep cycles during the user's sleep","format":"int32","example":3},"disturbance_count":{"type":"integer","description":"Number of times the user was disturbed during sleep","format":"int32","example":12}},"description":"Summary of the sleep stages","externalDocs":{"description":"Sleep Consistency and Sleep Stages","url":"https://support.whoop.com/hc/en-us/articles/360019623493-Sleep-Consistency-and-Sleep-Stages"}},"SleepNeeded":{"required":["baseline_milli","need_from_recent_nap_milli","need_from_recent_strain_milli","need_from_sleep_debt_milli"],"type":"object","properties":{"baseline_milli":{"type":"integer","description":"The amount of sleep a user needed based on historical trends","format":"int64","example":27395716},"need_from_sleep_debt_milli":{"type":"integer","description":"The difference between the amount of sleep the user's body required and the amount the user actually got","format":"int64","example":352230,"externalDocs":{"description":"WHOOP Locker - What is Sleep Debt & How Do You Catch Up on Sleep?","url":"https://www.whoop.com/thelocker/what-is-sleep-debt-catch-up/"}},"need_from_recent_strain_milli":{"type":"integer","description":"Additional sleep need accrued based on the user's strain","format":"int64","example":208595},"need_from_recent_nap_milli":{"type":"integer","description":"Reduction in sleep need accrued based on the user's recent nap activity (negative value or zero)","format":"int64","example":-12312}},"description":"Breakdown of the amount of sleep a user needed before the sleep activity. Summing all individual components results in the amount of sleep the user needed prior to this sleep activity"},"UserBasicProfile":{"required":["user_id","email","first_name","last_name"],"type":"object","properties":{"user_id":{"type":"integer","description":"The WHOOP User","format":"int64","example":10129},"email":{"type":"string","description":"User's Email","example":"jsmith123@whoop.com"},"first_name":{"type":"string","description":"User's First Name","example":"John"},"last_name":{"type":"string","description":"User's Last Name","example":"Smith"}}}},"securitySchemes":{"OAuth":{"type":"oauth2","flows":{"authorizationCode":{"authorizationUrl":"https://api.prod.whoop.com/oauth/oauth2/auth","tokenUrl":"https://api.prod.whoop.com/oauth/oauth2/token","scopes":{"read:recovery":"Read Recovery data, including score, heart rate variability, and resting heart rate.","read:cycles":"Read cycles data, including day Strain and average heart rate during a physiological cycle.","read:workout":"Read workout data, including activity Strain and average heart rate.","read:sleep":"Read sleep data, including performance % and duration per sleep stage.","read:profile":"Read profile data, including name and email.","read:body_measurement":"Read body measurements data, including height, weight, and max heart rate."}}}}}}}`);
|
|
41
|
+
var operationIds = ["ListWorkout", "ListSleep", "ListRecovery", "ListCycle", "GetProfileBasic", "OAuthAuthorize", "OAuthToken"];
|
|
42
|
+
var supportedOperationIds = ["ListWorkout", "ListSleep", "ListRecovery", "ListCycle", "GetProfileBasic", "OAuthAuthorize", "OAuthToken"];
|
|
43
|
+
|
|
44
|
+
// src/runtime.ts
|
|
45
|
+
var WHOOP_PRESETS = {
|
|
46
|
+
unauthorized: {
|
|
47
|
+
description: "Expired access token",
|
|
48
|
+
rules: [
|
|
49
|
+
{
|
|
50
|
+
status: 401,
|
|
51
|
+
body: {
|
|
52
|
+
detail: "The access token provided is expired, revoked, malformed, or invalid for other reasons."
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
rate_limited: {
|
|
58
|
+
description: "Scripted quota failure; body is a local fixture",
|
|
59
|
+
rules: [
|
|
60
|
+
{
|
|
61
|
+
status: 429,
|
|
62
|
+
body: { detail: "Rate limit exceeded." },
|
|
63
|
+
headers: {
|
|
64
|
+
"retry-after": "1",
|
|
65
|
+
"x-ratelimit-limit": "1",
|
|
66
|
+
"x-ratelimit-window": "1",
|
|
67
|
+
"x-ratelimit-reset": "0",
|
|
68
|
+
"x-ratelimit-tier": "access-token"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
server_error: {
|
|
74
|
+
description: "Scripted server failure",
|
|
75
|
+
rules: [{ status: 500, body: { detail: "Internal Server Error" } }]
|
|
76
|
+
},
|
|
77
|
+
connection_drop: { description: "Dropped connection", rules: [{ drop: true }] }
|
|
78
|
+
};
|
|
79
|
+
var createRuntime2 = (options = {}) => createRuntime({
|
|
80
|
+
name: WHOOP_NAMESPACE,
|
|
81
|
+
document,
|
|
82
|
+
presets: WHOOP_PRESETS,
|
|
83
|
+
credential: service_exports.bearerToken,
|
|
84
|
+
...options.sqlite ? { sqlite: options.sqlite } : {},
|
|
85
|
+
...options.clock ? { clock: options.clock } : {},
|
|
86
|
+
...options.seed !== void 0 ? { seed: options.seed } : {},
|
|
87
|
+
...options.adminPrefix ? { adminPrefix: options.adminPrefix } : {},
|
|
88
|
+
...options.adminKey ? { adminKey: options.adminKey } : {},
|
|
89
|
+
...options.adminControls !== void 0 ? { adminControls: options.adminControls } : {},
|
|
90
|
+
...options.onLog ? { onLog: options.onLog } : {},
|
|
91
|
+
create: ({ sqlite, namespace, clock }) => new WhoopAPI({ ...options, sqlite, namespace, now: clock.now })
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// src/index.ts
|
|
95
|
+
var WHOOP_NAMESPACE = "whoop";
|
|
96
|
+
var COLLECTION_SCOPES = {
|
|
97
|
+
workout: "read:workout",
|
|
98
|
+
sleep: "read:sleep",
|
|
99
|
+
recovery: "read:recovery",
|
|
100
|
+
cycle: "read:cycles",
|
|
101
|
+
profile: "read:profile"
|
|
102
|
+
};
|
|
103
|
+
var KNOWN_SCOPES = [
|
|
104
|
+
"offline",
|
|
105
|
+
"read:recovery",
|
|
106
|
+
"read:cycles",
|
|
107
|
+
"read:workout",
|
|
108
|
+
"read:sleep",
|
|
109
|
+
"read:profile",
|
|
110
|
+
"read:body_measurement"
|
|
111
|
+
];
|
|
112
|
+
var MIN_STATE_LENGTH = 8;
|
|
113
|
+
var unauthorized = () => (0, service_exports.jsonRes)(401, { message: "Unauthorized" });
|
|
114
|
+
var oauthError = (error, description) => (0, service_exports.jsonRes)(400, { error, error_description: description });
|
|
115
|
+
var isWebUrl = (value) => {
|
|
116
|
+
try {
|
|
117
|
+
return ["http:", "https:"].includes(new URL(value).protocol);
|
|
118
|
+
} catch {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var redirect = (target) => new Response(null, { status: 302, headers: { location: target.toString() } });
|
|
123
|
+
var WhoopAPI = class {
|
|
124
|
+
app;
|
|
125
|
+
grants;
|
|
126
|
+
clients;
|
|
127
|
+
codes;
|
|
128
|
+
consents;
|
|
129
|
+
records;
|
|
130
|
+
initialized;
|
|
131
|
+
ids;
|
|
132
|
+
service;
|
|
133
|
+
now;
|
|
134
|
+
fixtures;
|
|
135
|
+
pageSize;
|
|
136
|
+
ttl;
|
|
137
|
+
constructor(options = {}) {
|
|
138
|
+
const sqlite = (0, service_exports.bootSqlite)(options.sqlite), namespace = options.namespace ?? WHOOP_NAMESPACE;
|
|
139
|
+
this.now = options.now ?? Date.now;
|
|
140
|
+
this.grants = new service_exports.Collection(sqlite, namespace, "grants");
|
|
141
|
+
this.clients = new service_exports.Collection(sqlite, namespace, "clients");
|
|
142
|
+
this.codes = new service_exports.Collection(sqlite, namespace, "codes");
|
|
143
|
+
this.consents = new service_exports.Collection(sqlite, namespace, "consents");
|
|
144
|
+
this.records = new service_exports.Collection(sqlite, namespace, "records");
|
|
145
|
+
this.initialized = new service_exports.Collection(sqlite, namespace, "initialized");
|
|
146
|
+
this.ids = new service_exports.IdSequence(sqlite, namespace);
|
|
147
|
+
this.pageSize = options.pageSize ?? 10;
|
|
148
|
+
this.ttl = options.tokenTtlSeconds ?? 3600;
|
|
149
|
+
if (!Number.isInteger(this.pageSize) || this.pageSize < 1)
|
|
150
|
+
throw new Error("pageSize must be positive");
|
|
151
|
+
this.fixtures = structuredClone({
|
|
152
|
+
grants: options.grants ?? [
|
|
153
|
+
{
|
|
154
|
+
token: "mock_whoop_token",
|
|
155
|
+
refreshToken: "mock_whoop_refresh",
|
|
156
|
+
clientId: "mock_client",
|
|
157
|
+
userId: "synthetic-user",
|
|
158
|
+
scopes: ["read:cycles", "read:recovery", "read:workout", "read:sleep", "offline"],
|
|
159
|
+
expiresAt: 41024448e5
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
clients: options.clients ?? [{ id: "mock_client", secret: "mock_client_secret" }],
|
|
163
|
+
codes: options.codes ?? [],
|
|
164
|
+
consents: options.consents ?? [],
|
|
165
|
+
records: options.records ?? []
|
|
166
|
+
});
|
|
167
|
+
this.seed();
|
|
168
|
+
this.service = (0, service_exports.createService)({
|
|
169
|
+
document,
|
|
170
|
+
sqlite,
|
|
171
|
+
namespace,
|
|
172
|
+
now: this.now,
|
|
173
|
+
notFound: () => (0, service_exports.jsonRes)(404, { detail: "Not Found" }),
|
|
174
|
+
onError: (error) => {
|
|
175
|
+
throw error;
|
|
176
|
+
},
|
|
177
|
+
handlers: (0, service_exports.defineOperations)({
|
|
178
|
+
OAuthAuthorize: (c) => this.authorize(c),
|
|
179
|
+
OAuthToken: (c) => this.exchange(c),
|
|
180
|
+
GetProfileBasic: (c) => this.profile(c),
|
|
181
|
+
ListWorkout: (c) => this.list(c, "workout"),
|
|
182
|
+
ListSleep: (c) => this.list(c, "sleep"),
|
|
183
|
+
ListRecovery: (c) => this.list(c, "recovery"),
|
|
184
|
+
ListCycle: (c) => this.list(c, "cycle")
|
|
185
|
+
})
|
|
186
|
+
});
|
|
187
|
+
this.app = this.service.app;
|
|
188
|
+
}
|
|
189
|
+
seed() {
|
|
190
|
+
if (this.initialized.has("seed")) return;
|
|
191
|
+
for (const g of this.fixtures.grants) this.grants.insert(g.token, g);
|
|
192
|
+
for (const c of this.fixtures.clients) this.clients.insert(c.id, c);
|
|
193
|
+
for (const c of this.fixtures.codes) this.codes.insert(c.code, c);
|
|
194
|
+
for (const c of this.fixtures.consents) this.consents.insert(c.id, c);
|
|
195
|
+
for (const r of this.fixtures.records) this.records.insert(r.key, r);
|
|
196
|
+
this.initialized.insert("seed", { value: true });
|
|
197
|
+
}
|
|
198
|
+
fetch(request) {
|
|
199
|
+
return this.service.fetch(request);
|
|
200
|
+
}
|
|
201
|
+
async reset() {
|
|
202
|
+
await this.service.reset();
|
|
203
|
+
this.seed();
|
|
204
|
+
}
|
|
205
|
+
authorize(c) {
|
|
206
|
+
const query = new URL(c.request.url).searchParams;
|
|
207
|
+
const clientId = query.get("client_id") ?? "";
|
|
208
|
+
const failure = (status, error, description) => (0, service_exports.jsonRes)(status, { error, error_description: description });
|
|
209
|
+
if (!clientId) return failure(400, "invalid_request", "Missing required parameter client_id.");
|
|
210
|
+
const client = this.clients.get(clientId);
|
|
211
|
+
if (!client) return failure(401, "invalid_client", "Client authentication failed.");
|
|
212
|
+
const redirectUri = query.get("redirect_uri") ?? "";
|
|
213
|
+
if (!redirectUri)
|
|
214
|
+
return failure(400, "invalid_request", "Missing required parameter redirect_uri.");
|
|
215
|
+
if (client.redirectUris ? !client.redirectUris.includes(redirectUri) : !isWebUrl(redirectUri))
|
|
216
|
+
return failure(400, "invalid_request", "The redirect_uri is not registered for the client.");
|
|
217
|
+
const state = query.get("state");
|
|
218
|
+
const bounce = (error, description) => {
|
|
219
|
+
const target2 = new URL(redirectUri);
|
|
220
|
+
target2.searchParams.set("error", error);
|
|
221
|
+
target2.searchParams.set("error_description", description);
|
|
222
|
+
if (state !== null) target2.searchParams.set("state", state);
|
|
223
|
+
return redirect(target2);
|
|
224
|
+
};
|
|
225
|
+
const responseType = query.get("response_type");
|
|
226
|
+
if (!responseType) return bounce("invalid_request", "Missing required parameter response_type.");
|
|
227
|
+
if (responseType !== "code")
|
|
228
|
+
return bounce("unsupported_response_type", "Only response_type=code is supported.");
|
|
229
|
+
const scopes = [...new Set((query.get("scope") ?? "").split(/\s+/).filter(Boolean))], allowed = client.scopes ?? KNOWN_SCOPES;
|
|
230
|
+
const unknown = scopes.find((s) => !allowed.includes(s));
|
|
231
|
+
if (unknown !== void 0)
|
|
232
|
+
return bounce("invalid_scope", `The scope ${unknown} is not allowed.`);
|
|
233
|
+
if ((state ?? "").length < MIN_STATE_LENGTH)
|
|
234
|
+
return bounce(
|
|
235
|
+
"invalid_state",
|
|
236
|
+
`Parameter state must be at least ${MIN_STATE_LENGTH} characters long.`
|
|
237
|
+
);
|
|
238
|
+
const challenge = query.get("code_challenge") ?? void 0;
|
|
239
|
+
if (challenge !== void 0 && query.get("code_challenge_method") !== "S256")
|
|
240
|
+
return bounce("invalid_request", "Only code_challenge_method=S256 is supported.");
|
|
241
|
+
const consent = this.consents.get(clientId) ?? this.consents.get("*");
|
|
242
|
+
if (consent?.decision === "deny")
|
|
243
|
+
return bounce(
|
|
244
|
+
consent.error ?? "access_denied",
|
|
245
|
+
consent.errorDescription ?? "The resource owner denied the request."
|
|
246
|
+
);
|
|
247
|
+
if (consent?.decision === "error")
|
|
248
|
+
return bounce(
|
|
249
|
+
consent.error ?? "server_error",
|
|
250
|
+
consent.errorDescription ?? "The authorization server encountered an error."
|
|
251
|
+
);
|
|
252
|
+
const code = this.ids.next("mock_code");
|
|
253
|
+
this.codes.insert(code, {
|
|
254
|
+
code,
|
|
255
|
+
clientId,
|
|
256
|
+
userId: consent?.userId ?? "synthetic-user",
|
|
257
|
+
scopes,
|
|
258
|
+
redirectUri,
|
|
259
|
+
...challenge ? { challenge } : {},
|
|
260
|
+
expiresAt: this.now() + (consent?.codeTtlSeconds ?? 600) * 1e3
|
|
261
|
+
});
|
|
262
|
+
const target = new URL(redirectUri);
|
|
263
|
+
target.searchParams.set("code", code);
|
|
264
|
+
target.searchParams.set("state", state ?? "");
|
|
265
|
+
return redirect(target);
|
|
266
|
+
}
|
|
267
|
+
profile(c) {
|
|
268
|
+
const grant = this.grants.get((0, service_exports.bearerToken)(c.request) ?? "");
|
|
269
|
+
if (!grant || grant.expiresAt <= this.now()) return unauthorized();
|
|
270
|
+
if (!grant.scopes.includes(COLLECTION_SCOPES.profile))
|
|
271
|
+
return (0, service_exports.jsonRes)(403, { detail: "Access forbidden." });
|
|
272
|
+
const row = this.records.list({ order: "oldest" }).map((r) => r.value).find((r) => r.collection === "profile" && r.userId === grant.userId);
|
|
273
|
+
return row ? (0, service_exports.jsonRes)(200, row.data) : (0, service_exports.jsonRes)(404, { detail: "Not Found" });
|
|
274
|
+
}
|
|
275
|
+
async exchange(c) {
|
|
276
|
+
const body = new URLSearchParams(
|
|
277
|
+
c.body.kind === "form" ? c.body.value : {}
|
|
278
|
+
), basic = (0, service_exports.basicAuth)(c.request);
|
|
279
|
+
const clientId = basic?.username ?? body.get("client_id") ?? "", client = this.clients.get(clientId);
|
|
280
|
+
if (!client || client.secret !== (basic?.password ?? body.get("client_secret")))
|
|
281
|
+
return oauthError("invalid_client", "Invalid client_id.");
|
|
282
|
+
if (!c.request.headers.get("content-type")?.startsWith("application/x-www-form-urlencoded"))
|
|
283
|
+
return oauthError("invalid_request", "Expected form encoded body.");
|
|
284
|
+
let userId, scopes;
|
|
285
|
+
if (body.get("grant_type") === "refresh_token") {
|
|
286
|
+
const previous = this.grants.list({ order: "oldest" }).map((r) => r.value).find(
|
|
287
|
+
(g) => g.refreshToken && g.refreshToken === body.get("refresh_token") && g.clientId === clientId
|
|
288
|
+
);
|
|
289
|
+
if (!previous) return oauthError("invalid_grant", "Invalid refresh_token.");
|
|
290
|
+
userId = previous.userId;
|
|
291
|
+
scopes = previous.scopes;
|
|
292
|
+
this.grants.delete(previous.token);
|
|
293
|
+
} else if (body.get("grant_type") === "authorization_code") {
|
|
294
|
+
const code = this.codes.get(body.get("code") ?? "");
|
|
295
|
+
if (!code || code.clientId !== clientId || code.expiresAt <= this.now() || code.redirectUri !== (body.get("redirect_uri") ?? void 0))
|
|
296
|
+
return oauthError("invalid_grant", "Invalid authorization code.");
|
|
297
|
+
if (code.challenge) {
|
|
298
|
+
const verifier = body.get("code_verifier") ?? "";
|
|
299
|
+
const digest = new Uint8Array(
|
|
300
|
+
await crypto.subtle.digest("SHA-256", new TextEncoder().encode(verifier))
|
|
301
|
+
);
|
|
302
|
+
const encoded = btoa(String.fromCharCode(...digest)).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
303
|
+
if (verifier.length < 43 || verifier.length > 128 || encoded !== code.challenge)
|
|
304
|
+
return oauthError("invalid_grant", "Invalid code_verifier.");
|
|
305
|
+
}
|
|
306
|
+
userId = code.userId;
|
|
307
|
+
scopes = code.scopes;
|
|
308
|
+
if (!this.codes.has(code.code) || code.expiresAt <= this.now())
|
|
309
|
+
return oauthError("invalid_grant", "Authorization code already used.");
|
|
310
|
+
this.codes.delete(code.code);
|
|
311
|
+
} else return oauthError("unsupported_grant_type", "Unsupported grant_type.");
|
|
312
|
+
const token = this.ids.next("mock_access"), refreshToken = this.ids.next("mock_refresh");
|
|
313
|
+
this.grants.insert(token, {
|
|
314
|
+
token,
|
|
315
|
+
refreshToken: scopes.includes("offline") ? refreshToken : "",
|
|
316
|
+
clientId,
|
|
317
|
+
userId,
|
|
318
|
+
scopes,
|
|
319
|
+
expiresAt: this.now() + this.ttl * 1e3
|
|
320
|
+
});
|
|
321
|
+
return (0, service_exports.jsonRes)(200, {
|
|
322
|
+
access_token: token,
|
|
323
|
+
...scopes.includes("offline") ? { refresh_token: refreshToken } : {},
|
|
324
|
+
scope: scopes.join(" "),
|
|
325
|
+
expires_in: this.ttl,
|
|
326
|
+
token_type: "bearer"
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
list(c, collection) {
|
|
330
|
+
const grant = this.grants.get((0, service_exports.bearerToken)(c.request) ?? "");
|
|
331
|
+
if (!grant || grant.expiresAt <= this.now()) return unauthorized();
|
|
332
|
+
if (!grant.scopes.includes(COLLECTION_SCOPES[collection]))
|
|
333
|
+
return (0, service_exports.jsonRes)(403, { detail: "Access forbidden." });
|
|
334
|
+
const query = new URL(c.request.url).searchParams;
|
|
335
|
+
const from = query.get("start"), to = query.get("end") ?? new Date(this.now()).toISOString();
|
|
336
|
+
const limit = Number(query.get("limit") ?? this.pageSize);
|
|
337
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 25 || from && !Number.isFinite(Date.parse(from)) || !Number.isFinite(Date.parse(to)))
|
|
338
|
+
return (0, service_exports.jsonRes)(400, { message: "Invalid collection parameters" });
|
|
339
|
+
const all = this.records.list({ order: "oldest" }).map((r) => r.value).filter((r) => r.userId === grant.userId);
|
|
340
|
+
const startTime = (row) => {
|
|
341
|
+
const data = collection === "recovery" ? all.find((r) => r.collection === "sleep" && r.data.id === row.data.sleep_id)?.data : row.data;
|
|
342
|
+
return Date.parse(String(data?.start ?? ""));
|
|
343
|
+
};
|
|
344
|
+
const rows = all.filter((r) => r.collection === collection).filter(
|
|
345
|
+
(r) => Number.isFinite(startTime(r)) && (!from || startTime(r) >= Date.parse(from)) && startTime(r) < Date.parse(to)
|
|
346
|
+
).sort((a, b) => startTime(b) - startTime(a));
|
|
347
|
+
const cursor = query.get("nextToken"), offset = cursor ? rows.findIndex((r) => r.key === cursor) + 1 : 0;
|
|
348
|
+
if (cursor && offset === 0) return (0, service_exports.jsonRes)(400, { message: "Invalid nextToken" });
|
|
349
|
+
const page = rows.slice(offset, offset + limit);
|
|
350
|
+
return (0, service_exports.jsonRes)(200, {
|
|
351
|
+
records: page.map((r) => r.data),
|
|
352
|
+
...offset + page.length < rows.length ? { next_token: page.at(-1)?.key } : {}
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
export {
|
|
358
|
+
document,
|
|
359
|
+
operationIds,
|
|
360
|
+
supportedOperationIds,
|
|
361
|
+
WHOOP_PRESETS,
|
|
362
|
+
createRuntime2 as createRuntime,
|
|
363
|
+
WHOOP_NAMESPACE,
|
|
364
|
+
COLLECTION_SCOPES,
|
|
365
|
+
KNOWN_SCOPES,
|
|
366
|
+
MIN_STATE_LENGTH,
|
|
367
|
+
WhoopAPI
|
|
368
|
+
};
|
|
369
|
+
//# sourceMappingURL=chunk-CVNEDIVD.js.map
|