@thebriangao/totem 1.4.4 → 2.0.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/.dev.vars.example +5 -0
- package/.dockerignore +5 -0
- package/.env.example +29 -20
- package/CHANGELOG.md +99 -1
- package/CONTRIBUTING.md +48 -116
- package/Dockerfile +46 -12
- package/README.md +172 -498
- package/SECURITY.md +36 -59
- package/TOOLS.md +448 -311
- package/WHOOP.md +497 -2659
- package/assets/brand/SOURCES.md +38 -0
- package/assets/brand/totem.png +0 -0
- package/assets/brand/totem.svg +13 -0
- package/assets/fonts/Manrope-OFL.txt +93 -0
- package/assets/fonts/manrope-latin.woff2 +0 -0
- package/dist/build_info.js +5 -0
- package/dist/build_info.js.map +1 -0
- package/dist/cli/app.js +675 -0
- package/dist/cli/app.js.map +1 -0
- package/dist/cli/auth.js +297 -0
- package/dist/cli/auth.js.map +1 -0
- package/dist/cli/auth_flow.js +268 -0
- package/dist/cli/auth_flow.js.map +1 -0
- package/dist/cli/browser_login.js +368 -0
- package/dist/cli/browser_login.js.map +1 -0
- package/dist/cli/clients.js +403 -0
- package/dist/cli/clients.js.map +1 -0
- package/dist/cli/deploy_record.js +96 -0
- package/dist/cli/deploy_record.js.map +1 -0
- package/dist/cli/index.js +39 -575
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/links.js +28 -0
- package/dist/cli/links.js.map +1 -0
- package/dist/cli/logo.js +63 -0
- package/dist/cli/logo.js.map +1 -0
- package/dist/cli/setup.js +1157 -1017
- package/dist/cli/setup.js.map +1 -1
- package/dist/cli/spawn.js +80 -0
- package/dist/cli/spawn.js.map +1 -0
- package/dist/cli/sys.js +219 -0
- package/dist/cli/sys.js.map +1 -0
- package/dist/cli/ui.js +712 -463
- package/dist/cli/ui.js.map +1 -1
- package/dist/cli/update.js +425 -282
- package/dist/cli/update.js.map +1 -1
- package/dist/cloudflare/token_store.js +48 -0
- package/dist/cloudflare/token_store.js.map +1 -0
- package/dist/cloudflare/worker.js +155 -0
- package/dist/cloudflare/worker.js.map +1 -0
- package/dist/data/behaviors.js +2733 -617
- package/dist/data/behaviors.js.map +1 -1
- package/dist/data/endpoint_catalog.js +2681 -0
- package/dist/data/endpoint_catalog.js.map +1 -0
- package/dist/data/exercises.js +373 -4859
- package/dist/data/exercises.js.map +1 -1
- package/dist/data/garments.js +19 -0
- package/dist/data/garments.js.map +1 -0
- package/dist/data/sports.js +219 -208
- package/dist/data/sports.js.map +1 -1
- package/dist/lib/activity_list.js +123 -0
- package/dist/lib/activity_list.js.map +1 -0
- package/dist/lib/activity_records.js +195 -0
- package/dist/lib/activity_records.js.map +1 -0
- package/dist/lib/activity_results.js +44 -0
- package/dist/lib/activity_results.js.map +1 -0
- package/dist/lib/activity_types.js +164 -0
- package/dist/lib/activity_types.js.map +1 -0
- package/dist/lib/brand.js +63 -0
- package/dist/lib/brand.js.map +1 -0
- package/dist/lib/clock.js +24 -0
- package/dist/lib/clock.js.map +1 -0
- package/dist/lib/coach_session.js +345 -0
- package/dist/lib/coach_session.js.map +1 -0
- package/dist/lib/concurrency.js.map +1 -1
- package/dist/lib/dates.js +19 -0
- package/dist/lib/dates.js.map +1 -1
- package/dist/lib/env_file.js +195 -0
- package/dist/lib/env_file.js.map +1 -0
- package/dist/lib/health_plans_write.js +44 -0
- package/dist/lib/health_plans_write.js.map +1 -0
- package/dist/lib/heart_rate.js +34 -0
- package/dist/lib/heart_rate.js.map +1 -0
- package/dist/lib/highlight.js +81 -0
- package/dist/lib/highlight.js.map +1 -0
- package/dist/lib/install_links.js +47 -0
- package/dist/lib/install_links.js.map +1 -0
- package/dist/lib/instant.js +50 -0
- package/dist/lib/instant.js.map +1 -0
- package/dist/lib/journal_behaviors.js +382 -0
- package/dist/lib/journal_behaviors.js.map +1 -0
- package/dist/lib/lift_catalog.js +218 -0
- package/dist/lib/lift_catalog.js.map +1 -0
- package/dist/lib/lift_history.js +66 -0
- package/dist/lib/lift_history.js.map +1 -0
- package/dist/lib/lift_sets.js +146 -0
- package/dist/lib/lift_sets.js.map +1 -0
- package/dist/lib/lift_tool.js +20 -0
- package/dist/lib/lift_tool.js.map +1 -0
- package/dist/lib/profile_settings.js +101 -0
- package/dist/lib/profile_settings.js.map +1 -0
- package/dist/lib/screen_content.js +44 -0
- package/dist/lib/screen_content.js.map +1 -0
- package/dist/lib/timezone.js +48 -6
- package/dist/lib/timezone.js.map +1 -1
- package/dist/lib/walk.js +6 -1
- package/dist/lib/walk.js.map +1 -1
- package/dist/lib/weight_readings.js +61 -0
- package/dist/lib/weight_readings.js.map +1 -0
- package/dist/projections/activities.js +193 -0
- package/dist/projections/activities.js.map +1 -0
- package/dist/projections/alarm_schedule.js +102 -0
- package/dist/projections/alarm_schedule.js.map +1 -0
- package/dist/projections/coach.js +203 -0
- package/dist/projections/coach.js.map +1 -0
- package/dist/projections/community.js +165 -0
- package/dist/projections/community.js.map +1 -0
- package/dist/projections/health_features.js +167 -0
- package/dist/projections/health_features.js.map +1 -0
- package/dist/projections/hormonal_insights.js +239 -0
- package/dist/projections/hormonal_insights.js.map +1 -0
- package/dist/projections/journal_v2.js +157 -0
- package/dist/projections/journal_v2.js.map +1 -0
- package/dist/projections/lift_cards.js +115 -0
- package/dist/projections/lift_cards.js.map +1 -0
- package/dist/projections/lift_exercise_v2.js +131 -0
- package/dist/projections/lift_exercise_v2.js.map +1 -0
- package/dist/projections/lift_library_v2.js +67 -0
- package/dist/projections/lift_library_v2.js.map +1 -0
- package/dist/projections/lift_sessions.js +211 -0
- package/dist/projections/lift_sessions.js.map +1 -0
- package/dist/projections/memory.js +95 -0
- package/dist/projections/memory.js.map +1 -0
- package/dist/projections/milestones.js +119 -0
- package/dist/projections/milestones.js.map +1 -0
- package/dist/projections/profile_v2.js +150 -0
- package/dist/projections/profile_v2.js.map +1 -0
- package/dist/projections/settings_v2.js +153 -0
- package/dist/projections/settings_v2.js.map +1 -0
- package/dist/projections/sleep.js +4 -21
- package/dist/projections/sleep.js.map +1 -1
- package/dist/projections/v2/calendar.js +43 -0
- package/dist/projections/v2/calendar.js.map +1 -0
- package/dist/projections/v2/core_common.js +86 -0
- package/dist/projections/v2/core_common.js.map +1 -0
- package/dist/projections/v2/core_home.js +136 -0
- package/dist/projections/v2/core_home.js.map +1 -0
- package/dist/projections/v2/core_sleep_need.js +23 -0
- package/dist/projections/v2/core_sleep_need.js.map +1 -0
- package/dist/projections/v2/day.js +92 -0
- package/dist/projections/v2/day.js.map +1 -0
- package/dist/projections/v2/heart_rate.js +54 -0
- package/dist/projections/v2/heart_rate.js.map +1 -0
- package/dist/projections/v2/history.js +140 -0
- package/dist/projections/v2/history.js.map +1 -0
- package/dist/projections/v2/now.js +39 -0
- package/dist/projections/v2/now.js.map +1 -0
- package/dist/projections/v2/recovery.js +77 -0
- package/dist/projections/v2/recovery.js.map +1 -0
- package/dist/projections/v2/sleep.js +218 -0
- package/dist/projections/v2/sleep.js.map +1 -0
- package/dist/projections/v2/strain.js +39 -0
- package/dist/projections/v2/strain.js.map +1 -0
- package/dist/projections/v2/stress.js +92 -0
- package/dist/projections/v2/stress.js.map +1 -0
- package/dist/projections/v2/trend.js +205 -0
- package/dist/projections/v2/trend.js.map +1 -0
- package/dist/projections/weekly_plan.js +66 -0
- package/dist/projections/weekly_plan.js.map +1 -0
- package/dist/projections/weight_readings.js +57 -0
- package/dist/projections/weight_readings.js.map +1 -0
- package/dist/projections/workout.js +37 -15
- package/dist/projections/workout.js.map +1 -1
- package/dist/schemas/activities.js +123 -0
- package/dist/schemas/activities.js.map +1 -0
- package/dist/schemas/alarm_schedule.js +62 -0
- package/dist/schemas/alarm_schedule.js.map +1 -0
- package/dist/schemas/coach.js +76 -8
- package/dist/schemas/coach.js.map +1 -1
- package/dist/schemas/community.js +70 -0
- package/dist/schemas/community.js.map +1 -0
- package/dist/schemas/health.js +36 -0
- package/dist/schemas/health.js.map +1 -0
- package/dist/schemas/hormonal_insights.js +90 -0
- package/dist/schemas/hormonal_insights.js.map +1 -0
- package/dist/schemas/journal.js +4 -0
- package/dist/schemas/journal.js.map +1 -1
- package/dist/schemas/journal_v2.js +106 -0
- package/dist/schemas/journal_v2.js.map +1 -0
- package/dist/schemas/memory.js +42 -0
- package/dist/schemas/memory.js.map +1 -0
- package/dist/schemas/milestones.js +39 -0
- package/dist/schemas/milestones.js.map +1 -0
- package/dist/schemas/profile_v2.js +60 -0
- package/dist/schemas/profile_v2.js.map +1 -0
- package/dist/schemas/settings_v2.js +56 -0
- package/dist/schemas/settings_v2.js.map +1 -0
- package/dist/schemas/sleep.js +8 -1
- package/dist/schemas/sleep.js.map +1 -1
- package/dist/schemas/strength.js +10 -1
- package/dist/schemas/strength.js.map +1 -1
- package/dist/schemas/strength_v2.js +190 -0
- package/dist/schemas/strength_v2.js.map +1 -0
- package/dist/schemas/v2/calendar.js +8 -0
- package/dist/schemas/v2/calendar.js.map +1 -0
- package/dist/schemas/v2/core_common.js +42 -0
- package/dist/schemas/v2/core_common.js.map +1 -0
- package/dist/schemas/v2/day.js +73 -0
- package/dist/schemas/v2/day.js.map +1 -0
- package/dist/schemas/v2/now.js +25 -0
- package/dist/schemas/v2/now.js.map +1 -0
- package/dist/schemas/v2/recovery.js +35 -0
- package/dist/schemas/v2/recovery.js.map +1 -0
- package/dist/schemas/v2/sleep.js +44 -0
- package/dist/schemas/v2/sleep.js.map +1 -0
- package/dist/schemas/v2/strain.js +16 -0
- package/dist/schemas/v2/strain.js.map +1 -0
- package/dist/schemas/v2/stress.js +20 -0
- package/dist/schemas/v2/stress.js.map +1 -0
- package/dist/schemas/v2/trend.js +42 -0
- package/dist/schemas/v2/trend.js.map +1 -0
- package/dist/schemas/weekly_plan.js +31 -0
- package/dist/schemas/weekly_plan.js.map +1 -0
- package/dist/schemas/weight.js +28 -0
- package/dist/schemas/weight.js.map +1 -0
- package/dist/scripts/build_behaviors.js +114 -0
- package/dist/scripts/build_behaviors.js.map +1 -0
- package/dist/scripts/cognito_bootstrap.js +9 -277
- package/dist/scripts/cognito_bootstrap.js.map +1 -1
- package/dist/scripts/gen_activity_catalogs.js +104 -0
- package/dist/scripts/gen_activity_catalogs.js.map +1 -0
- package/dist/server-admin.js +156 -0
- package/dist/server-admin.js.map +1 -0
- package/dist/server-http.js +270 -48
- package/dist/server-http.js.map +1 -1
- package/dist/server.js +136 -23
- package/dist/server.js.map +1 -1
- package/dist/tools/annotations.js +15 -0
- package/dist/tools/annotations.js.map +1 -0
- package/dist/tools/define.js +31 -0
- package/dist/tools/define.js.map +1 -0
- package/dist/tools/register.js +59 -94
- package/dist/tools/register.js.map +1 -1
- package/dist/tools/resources.js +70 -0
- package/dist/tools/resources.js.map +1 -0
- package/dist/tools/slim_schema.js +90 -0
- package/dist/tools/slim_schema.js.map +1 -0
- package/dist/tools/v2/activity_delete.js +63 -17
- package/dist/tools/v2/activity_delete.js.map +1 -1
- package/dist/tools/v2/activity_edit.js +396 -0
- package/dist/tools/v2/activity_edit.js.map +1 -0
- package/dist/tools/v2/activity_log.js +152 -0
- package/dist/tools/v2/activity_log.js.map +1 -0
- package/dist/tools/v2/calendar.js +19 -21
- package/dist/tools/v2/calendar.js.map +1 -1
- package/dist/tools/v2/coach_ask.js +74 -110
- package/dist/tools/v2/coach_ask.js.map +1 -1
- package/dist/tools/v2/coach_history.js +120 -0
- package/dist/tools/v2/coach_history.js.map +1 -0
- package/dist/tools/v2/community.js +124 -0
- package/dist/tools/v2/community.js.map +1 -0
- package/dist/tools/v2/cycle.js +63 -15
- package/dist/tools/v2/cycle.js.map +1 -1
- package/dist/tools/v2/cycle_log.js +289 -32
- package/dist/tools/v2/cycle_log.js.map +1 -1
- package/dist/tools/v2/day.js +126 -24
- package/dist/tools/v2/day.js.map +1 -1
- package/dist/tools/v2/health.js +116 -0
- package/dist/tools/v2/health.js.map +1 -0
- package/dist/tools/v2/hr_zones_set.js +134 -34
- package/dist/tools/v2/hr_zones_set.js.map +1 -1
- package/dist/tools/v2/journal.js +75 -17
- package/dist/tools/v2/journal.js.map +1 -1
- package/dist/tools/v2/journal_log.js +306 -65
- package/dist/tools/v2/journal_log.js.map +1 -1
- package/dist/tools/v2/lift_exercise.js +125 -22
- package/dist/tools/v2/lift_exercise.js.map +1 -1
- package/dist/tools/v2/lift_exercise_set.js +291 -0
- package/dist/tools/v2/lift_exercise_set.js.map +1 -0
- package/dist/tools/v2/lift_library.js +51 -12
- package/dist/tools/v2/lift_library.js.map +1 -1
- package/dist/tools/v2/lift_log.js +309 -72
- package/dist/tools/v2/lift_log.js.map +1 -1
- package/dist/tools/v2/lift_sessions.js +248 -0
- package/dist/tools/v2/lift_sessions.js.map +1 -0
- package/dist/tools/v2/lift_template.js +232 -0
- package/dist/tools/v2/lift_template.js.map +1 -0
- package/dist/tools/v2/memory.js +45 -0
- package/dist/tools/v2/memory.js.map +1 -0
- package/dist/tools/v2/memory_set.js +107 -0
- package/dist/tools/v2/memory_set.js.map +1 -0
- package/dist/tools/v2/milestones.js +50 -0
- package/dist/tools/v2/milestones.js.map +1 -0
- package/dist/tools/v2/now.js +49 -0
- package/dist/tools/v2/now.js.map +1 -0
- package/dist/tools/v2/preferences.js +51 -0
- package/dist/tools/v2/preferences.js.map +1 -0
- package/dist/tools/v2/preferences_set.js +388 -0
- package/dist/tools/v2/preferences_set.js.map +1 -0
- package/dist/tools/v2/profile.js +54 -22
- package/dist/tools/v2/profile.js.map +1 -1
- package/dist/tools/v2/profile_update.js +167 -55
- package/dist/tools/v2/profile_update.js.map +1 -1
- package/dist/tools/v2/raw.js +91 -34
- package/dist/tools/v2/raw.js.map +1 -1
- package/dist/tools/v2/recovery.js +37 -23
- package/dist/tools/v2/recovery.js.map +1 -1
- package/dist/tools/v2/sleep.js +52 -16
- package/dist/tools/v2/sleep.js.map +1 -1
- package/dist/tools/v2/smart_alarm.js +54 -20
- package/dist/tools/v2/smart_alarm.js.map +1 -1
- package/dist/tools/v2/smart_alarm_set.js +264 -86
- package/dist/tools/v2/smart_alarm_set.js.map +1 -1
- package/dist/tools/v2/strain.js +15 -15
- package/dist/tools/v2/strain.js.map +1 -1
- package/dist/tools/v2/stress.js +17 -15
- package/dist/tools/v2/stress.js.map +1 -1
- package/dist/tools/v2/trend.js +56 -20
- package/dist/tools/v2/trend.js.map +1 -1
- package/dist/tools/v2/weekly_plan.js +30 -0
- package/dist/tools/v2/weekly_plan.js.map +1 -0
- package/dist/tools/v2/weekly_plan_set.js +134 -0
- package/dist/tools/v2/weekly_plan_set.js.map +1 -0
- package/dist/tools/v2/weight.js +56 -0
- package/dist/tools/v2/weight.js.map +1 -0
- package/dist/tools/v2/weight_log.js +188 -0
- package/dist/tools/v2/weight_log.js.map +1 -0
- package/dist/tools/v2/workouts.js +159 -25
- package/dist/tools/v2/workouts.js.map +1 -1
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/whoop/bff.js +94 -0
- package/dist/whoop/bff.js.map +1 -0
- package/dist/whoop/client.js +392 -18
- package/dist/whoop/client.js.map +1 -1
- package/dist/whoop/cognito.js +106 -79
- package/dist/whoop/cognito.js.map +1 -1
- package/dist/whoop/connect_page.js +165 -0
- package/dist/whoop/connect_page.js.map +1 -0
- package/dist/whoop/consent_font.js +287 -0
- package/dist/whoop/consent_font.js.map +1 -0
- package/dist/whoop/consent_logos.js +22 -0
- package/dist/whoop/consent_logos.js.map +1 -0
- package/dist/whoop/consent_page.js +291 -0
- package/dist/whoop/consent_page.js.map +1 -0
- package/dist/whoop/constants.js +5 -1
- package/dist/whoop/constants.js.map +1 -1
- package/dist/whoop/device.js +4 -4
- package/dist/whoop/device.js.map +1 -1
- package/dist/whoop/errors.js +85 -4
- package/dist/whoop/errors.js.map +1 -1
- package/dist/whoop/init_timezone.js +57 -17
- package/dist/whoop/init_timezone.js.map +1 -1
- package/dist/whoop/installation.js +15 -10
- package/dist/whoop/installation.js.map +1 -1
- package/dist/whoop/json_out.js +52 -6
- package/dist/whoop/json_out.js.map +1 -1
- package/dist/whoop/oauth_provider.js +81 -78
- package/dist/whoop/oauth_provider.js.map +1 -1
- package/dist/whoop/token_lock.js +331 -0
- package/dist/whoop/token_lock.js.map +1 -0
- package/dist/whoop/token_manager.js +536 -42
- package/dist/whoop/token_manager.js.map +1 -1
- package/dist/whoop/token_store.js +303 -36
- package/dist/whoop/token_store.js.map +1 -1
- package/dist/whoop/units.js +28 -0
- package/dist/whoop/units.js.map +1 -0
- package/package.json +29 -13
- package/scripts/build-mcpb.mjs +72 -0
- package/scripts/embed-consent-font.mjs +34 -0
- package/scripts/readme-media.ts +195 -0
- package/scripts/tools-md.ts +89 -0
- package/scripts/whoop-md.ts +119 -0
- package/src/build_info.ts +4 -0
- package/src/cli/app.ts +696 -0
- package/src/cli/auth.ts +350 -0
- package/src/cli/auth_flow.ts +356 -0
- package/src/cli/browser_login.ts +402 -0
- package/src/cli/clients.ts +467 -0
- package/src/cli/deploy_record.ts +100 -0
- package/src/cli/index.ts +41 -583
- package/src/cli/links.ts +43 -0
- package/src/cli/logo.ts +64 -0
- package/src/cli/setup.ts +1147 -979
- package/src/cli/spawn.ts +88 -0
- package/src/cli/sys.ts +267 -0
- package/src/cli/ui.ts +778 -436
- package/src/cli/update.ts +436 -274
- package/src/cloudflare/runtime.d.ts +27 -0
- package/src/cloudflare/token_store.ts +57 -0
- package/src/cloudflare/worker.ts +174 -0
- package/src/data/behaviors.ts +2760 -622
- package/src/data/endpoint_catalog.ts +2695 -0
- package/src/data/exercises.ts +379 -4861
- package/src/data/garments.ts +28 -0
- package/src/data/sports.ts +239 -211
- package/src/lib/activity_list.ts +150 -0
- package/src/lib/activity_records.ts +213 -0
- package/src/lib/activity_results.ts +51 -0
- package/src/lib/activity_types.ts +176 -0
- package/src/lib/brand.ts +71 -0
- package/src/lib/clock.ts +16 -0
- package/src/lib/coach_session.ts +434 -0
- package/src/lib/dates.ts +18 -0
- package/src/lib/env_file.ts +191 -0
- package/src/lib/health_plans_write.ts +53 -0
- package/src/lib/heart_rate.ts +42 -0
- package/src/lib/highlight.ts +71 -0
- package/src/lib/install_links.ts +61 -0
- package/src/lib/instant.ts +54 -0
- package/src/lib/journal_behaviors.ts +453 -0
- package/src/lib/lift_catalog.ts +258 -0
- package/src/lib/lift_history.ts +75 -0
- package/src/lib/lift_sets.ts +164 -0
- package/src/lib/lift_tool.ts +25 -0
- package/src/lib/profile_settings.ts +102 -0
- package/src/lib/screen_content.ts +40 -0
- package/src/lib/timezone.ts +44 -8
- package/src/lib/walk.ts +4 -1
- package/src/lib/weight_readings.ts +82 -0
- package/src/projections/activities.ts +199 -0
- package/src/projections/alarm_schedule.ts +98 -0
- package/src/projections/coach.ts +218 -0
- package/src/projections/community.ts +187 -0
- package/src/projections/health_features.ts +191 -0
- package/src/projections/hormonal_insights.ts +277 -0
- package/src/projections/journal_v2.ts +173 -0
- package/src/projections/lift_cards.ts +131 -0
- package/src/projections/lift_exercise_v2.ts +147 -0
- package/src/projections/lift_library_v2.ts +77 -0
- package/src/projections/lift_sessions.ts +250 -0
- package/src/projections/memory.ts +100 -0
- package/src/projections/milestones.ts +133 -0
- package/src/projections/profile_v2.ts +166 -0
- package/src/projections/settings_v2.ts +179 -0
- package/src/projections/sleep.ts +7 -21
- package/src/projections/v2/calendar.ts +48 -0
- package/src/projections/v2/core_common.ts +95 -0
- package/src/projections/v2/core_home.ts +177 -0
- package/src/projections/v2/core_sleep_need.ts +37 -0
- package/src/projections/v2/day.ts +162 -0
- package/src/projections/v2/heart_rate.ts +73 -0
- package/src/projections/v2/history.ts +153 -0
- package/src/projections/v2/now.ts +59 -0
- package/src/projections/v2/recovery.ts +120 -0
- package/src/projections/v2/sleep.ts +281 -0
- package/src/projections/v2/strain.ts +63 -0
- package/src/projections/v2/stress.ts +111 -0
- package/src/projections/v2/trend.ts +242 -0
- package/src/projections/weekly_plan.ts +79 -0
- package/src/projections/weight_readings.ts +57 -0
- package/src/projections/workout.ts +36 -17
- package/src/schemas/activities.ts +136 -0
- package/src/schemas/alarm_schedule.ts +70 -0
- package/src/schemas/coach.ts +98 -8
- package/src/schemas/community.ts +77 -0
- package/src/schemas/health.ts +36 -0
- package/src/schemas/hormonal_insights.ts +108 -0
- package/src/schemas/journal.ts +4 -0
- package/src/schemas/journal_v2.ts +112 -0
- package/src/schemas/memory.ts +48 -0
- package/src/schemas/milestones.ts +48 -0
- package/src/schemas/profile_v2.ts +63 -0
- package/src/schemas/settings_v2.ts +63 -0
- package/src/schemas/sleep.ts +9 -1
- package/src/schemas/strength.ts +10 -1
- package/src/schemas/strength_v2.ts +210 -0
- package/src/schemas/v2/calendar.ts +8 -0
- package/src/schemas/v2/core_common.ts +50 -0
- package/src/schemas/v2/day.ts +79 -0
- package/src/schemas/v2/now.ts +25 -0
- package/src/schemas/v2/recovery.ts +38 -0
- package/src/schemas/v2/sleep.ts +46 -0
- package/src/schemas/v2/strain.ts +16 -0
- package/src/schemas/v2/stress.ts +20 -0
- package/src/schemas/v2/trend.ts +45 -0
- package/src/schemas/weekly_plan.ts +36 -0
- package/src/schemas/weight.ts +53 -0
- package/src/scripts/build_behaviors.ts +116 -0
- package/src/scripts/cognito_bootstrap.ts +10 -249
- package/src/scripts/gen_activity_catalogs.ts +121 -0
- package/src/server-admin.ts +171 -0
- package/src/server-http.ts +290 -53
- package/src/server.ts +130 -26
- package/src/tools/annotations.ts +25 -0
- package/src/tools/define.ts +53 -0
- package/src/tools/register.ts +64 -94
- package/src/tools/resources.ts +92 -0
- package/src/tools/slim_schema.ts +102 -0
- package/src/tools/v2/activity_delete.ts +61 -23
- package/src/tools/v2/activity_edit.ts +378 -0
- package/src/tools/v2/activity_log.ts +154 -0
- package/src/tools/v2/calendar.ts +22 -21
- package/src/tools/v2/coach_ask.ts +83 -119
- package/src/tools/v2/coach_history.ts +140 -0
- package/src/tools/v2/community.ts +137 -0
- package/src/tools/v2/cycle.ts +78 -20
- package/src/tools/v2/cycle_log.ts +291 -40
- package/src/tools/v2/day.ts +126 -25
- package/src/tools/v2/health.ts +114 -0
- package/src/tools/v2/hr_zones_set.ts +132 -45
- package/src/tools/v2/journal.ts +78 -23
- package/src/tools/v2/journal_log.ts +321 -69
- package/src/tools/v2/lift_exercise.ts +135 -27
- package/src/tools/v2/lift_exercise_set.ts +272 -0
- package/src/tools/v2/lift_library.ts +57 -21
- package/src/tools/v2/lift_log.ts +325 -83
- package/src/tools/v2/lift_sessions.ts +255 -0
- package/src/tools/v2/lift_template.ts +229 -0
- package/src/tools/v2/memory.ts +54 -0
- package/src/tools/v2/memory_set.ts +110 -0
- package/src/tools/v2/milestones.ts +59 -0
- package/src/tools/v2/now.ts +61 -0
- package/src/tools/v2/preferences.ts +61 -0
- package/src/tools/v2/preferences_set.ts +403 -0
- package/src/tools/v2/profile.ts +56 -26
- package/src/tools/v2/profile_update.ts +151 -60
- package/src/tools/v2/raw.ts +89 -36
- package/src/tools/v2/recovery.ts +44 -25
- package/src/tools/v2/sleep.ts +57 -18
- package/src/tools/v2/smart_alarm.ts +62 -24
- package/src/tools/v2/smart_alarm_set.ts +240 -90
- package/src/tools/v2/strain.ts +19 -16
- package/src/tools/v2/stress.ts +22 -17
- package/src/tools/v2/trend.ts +58 -20
- package/src/tools/v2/weekly_plan.ts +38 -0
- package/src/tools/v2/weekly_plan_set.ts +132 -0
- package/src/tools/v2/weight.ts +61 -0
- package/src/tools/v2/weight_log.ts +193 -0
- package/src/tools/v2/workouts.ts +156 -26
- package/src/version.ts +5 -0
- package/src/whoop/bff.ts +84 -0
- package/src/whoop/client.ts +448 -18
- package/src/whoop/cognito.ts +110 -99
- package/src/whoop/connect_page.ts +183 -0
- package/src/whoop/consent_font.ts +289 -0
- package/src/whoop/consent_logos.ts +24 -0
- package/src/whoop/consent_page.ts +326 -0
- package/src/whoop/constants.ts +5 -1
- package/src/whoop/device.ts +4 -4
- package/src/whoop/errors.ts +89 -4
- package/src/whoop/init_timezone.ts +57 -16
- package/src/whoop/installation.ts +16 -7
- package/src/whoop/json_out.ts +51 -6
- package/src/whoop/oauth_provider.ts +84 -91
- package/src/whoop/token_lock.ts +345 -0
- package/src/whoop/token_manager.ts +580 -53
- package/src/whoop/token_store.ts +341 -32
- package/src/whoop/units.ts +35 -0
- package/wrangler.jsonc +17 -0
- package/assets/banner.svg +0 -38
- package/dist/data/endpoints.js +0 -320
- package/dist/data/endpoints.js.map +0 -1
- package/dist/lib/format.js +0 -22
- package/dist/lib/format.js.map +0 -1
- package/dist/lib/stats.js +0 -32
- package/dist/lib/stats.js.map +0 -1
- package/dist/projections/calendar.js +0 -33
- package/dist/projections/calendar.js.map +0 -1
- package/dist/projections/communities.js +0 -105
- package/dist/projections/communities.js.map +0 -1
- package/dist/projections/cycle.js +0 -81
- package/dist/projections/cycle.js.map +0 -1
- package/dist/projections/hr_zones.js +0 -35
- package/dist/projections/hr_zones.js.map +0 -1
- package/dist/projections/journal.js +0 -56
- package/dist/projections/journal.js.map +0 -1
- package/dist/projections/leaderboard.js +0 -37
- package/dist/projections/leaderboard.js.map +0 -1
- package/dist/projections/lift_exercise.js +0 -22
- package/dist/projections/lift_exercise.js.map +0 -1
- package/dist/projections/lift_history.js +0 -133
- package/dist/projections/lift_history.js.map +0 -1
- package/dist/projections/lift_library.js +0 -71
- package/dist/projections/lift_library.js.map +0 -1
- package/dist/projections/lift_progression.js +0 -138
- package/dist/projections/lift_progression.js.map +0 -1
- package/dist/projections/lift_prs.js +0 -20
- package/dist/projections/lift_prs.js.map +0 -1
- package/dist/projections/live_hr.js +0 -19
- package/dist/projections/live_hr.js.map +0 -1
- package/dist/projections/live_state.js +0 -23
- package/dist/projections/live_state.js.map +0 -1
- package/dist/projections/live_stress.js +0 -11
- package/dist/projections/live_stress.js.map +0 -1
- package/dist/projections/performance_assessment.js +0 -15
- package/dist/projections/performance_assessment.js.map +0 -1
- package/dist/projections/profile.js +0 -59
- package/dist/projections/profile.js.map +0 -1
- package/dist/projections/recovery.js +0 -131
- package/dist/projections/recovery.js.map +0 -1
- package/dist/projections/sleep_need.js +0 -32
- package/dist/projections/sleep_need.js.map +0 -1
- package/dist/projections/smart_alarm.js +0 -45
- package/dist/projections/smart_alarm.js.map +0 -1
- package/dist/projections/strain.js +0 -128
- package/dist/projections/strain.js.map +0 -1
- package/dist/projections/stress.js +0 -86
- package/dist/projections/stress.js.map +0 -1
- package/dist/projections/today.js +0 -129
- package/dist/projections/today.js.map +0 -1
- package/dist/projections/trend.js +0 -149
- package/dist/projections/trend.js.map +0 -1
- package/dist/projections/workouts.js +0 -37
- package/dist/projections/workouts.js.map +0 -1
- package/dist/schemas/calendar.js +0 -12
- package/dist/schemas/calendar.js.map +0 -1
- package/dist/schemas/communities.js +0 -51
- package/dist/schemas/communities.js.map +0 -1
- package/dist/schemas/compare.js +0 -15
- package/dist/schemas/compare.js.map +0 -1
- package/dist/schemas/leaderboard.js +0 -25
- package/dist/schemas/leaderboard.js.map +0 -1
- package/dist/schemas/live.js +0 -26
- package/dist/schemas/live.js.map +0 -1
- package/dist/schemas/performance.js +0 -12
- package/dist/schemas/performance.js.map +0 -1
- package/dist/schemas/profile.js +0 -39
- package/dist/schemas/profile.js.map +0 -1
- package/dist/schemas/recovery.js +0 -27
- package/dist/schemas/recovery.js.map +0 -1
- package/dist/schemas/settings.js +0 -26
- package/dist/schemas/settings.js.map +0 -1
- package/dist/schemas/sleep_need.js +0 -15
- package/dist/schemas/sleep_need.js.map +0 -1
- package/dist/schemas/smart_alarm.js +0 -36
- package/dist/schemas/smart_alarm.js.map +0 -1
- package/dist/schemas/strain.js +0 -24
- package/dist/schemas/strain.js.map +0 -1
- package/dist/schemas/stress.js +0 -16
- package/dist/schemas/stress.js.map +0 -1
- package/dist/schemas/today.js +0 -38
- package/dist/schemas/today.js.map +0 -1
- package/dist/schemas/trend.js +0 -50
- package/dist/schemas/trend.js.map +0 -1
- package/dist/schemas/womens_health.js +0 -23
- package/dist/schemas/womens_health.js.map +0 -1
- package/dist/tools/v2/activity_create.js +0 -64
- package/dist/tools/v2/activity_create.js.map +0 -1
- package/dist/tools/v2/behavior_impact.js +0 -36
- package/dist/tools/v2/behavior_impact.js.map +0 -1
- package/dist/tools/v2/communities.js +0 -60
- package/dist/tools/v2/communities.js.map +0 -1
- package/dist/tools/v2/compare.js +0 -67
- package/dist/tools/v2/compare.js.map +0 -1
- package/dist/tools/v2/endpoints.js +0 -28
- package/dist/tools/v2/endpoints.js.map +0 -1
- package/dist/tools/v2/hidden_metric.js +0 -28
- package/dist/tools/v2/hidden_metric.js.map +0 -1
- package/dist/tools/v2/hr_zones.js +0 -24
- package/dist/tools/v2/hr_zones.js.map +0 -1
- package/dist/tools/v2/journal_autopop.js +0 -19
- package/dist/tools/v2/journal_autopop.js.map +0 -1
- package/dist/tools/v2/journal_catalog.js +0 -44
- package/dist/tools/v2/journal_catalog.js.map +0 -1
- package/dist/tools/v2/leaderboard.js +0 -79
- package/dist/tools/v2/leaderboard.js.map +0 -1
- package/dist/tools/v2/lift_catalog.js +0 -47
- package/dist/tools/v2/lift_catalog.js.map +0 -1
- package/dist/tools/v2/lift_custom_exercise.js +0 -108
- package/dist/tools/v2/lift_custom_exercise.js.map +0 -1
- package/dist/tools/v2/lift_history.js +0 -39
- package/dist/tools/v2/lift_history.js.map +0 -1
- package/dist/tools/v2/lift_progression.js +0 -30
- package/dist/tools/v2/lift_progression.js.map +0 -1
- package/dist/tools/v2/lift_prs.js +0 -21
- package/dist/tools/v2/lift_prs.js.map +0 -1
- package/dist/tools/v2/lift_template_save.js +0 -83
- package/dist/tools/v2/lift_template_save.js.map +0 -1
- package/dist/tools/v2/live_hr.js +0 -21
- package/dist/tools/v2/live_hr.js.map +0 -1
- package/dist/tools/v2/live_state.js +0 -21
- package/dist/tools/v2/live_state.js.map +0 -1
- package/dist/tools/v2/live_stress.js +0 -22
- package/dist/tools/v2/live_stress.js.map +0 -1
- package/dist/tools/v2/performance_assessment.js +0 -38
- package/dist/tools/v2/performance_assessment.js.map +0 -1
- package/dist/tools/v2/sleep_need.js +0 -21
- package/dist/tools/v2/sleep_need.js.map +0 -1
- package/dist/tools/v2/sports_catalog.js +0 -26
- package/dist/tools/v2/sports_catalog.js.map +0 -1
- package/dist/tools/v2/symptom_log.js +0 -72
- package/dist/tools/v2/symptom_log.js.map +0 -1
- package/dist/tools/v2/today.js +0 -30
- package/dist/tools/v2/today.js.map +0 -1
- package/dist/tools/v2/workout.js +0 -23
- package/dist/tools/v2/workout.js.map +0 -1
- package/dist/whoop/build_lift_body.js +0 -67
- package/dist/whoop/build_lift_body.js.map +0 -1
- package/dist/whoop/session_state.js +0 -34
- package/dist/whoop/session_state.js.map +0 -1
- package/dist/whoop/types.js +0 -82
- package/dist/whoop/types.js.map +0 -1
- package/src/data/endpoints.ts +0 -319
- package/src/lib/format.ts +0 -27
- package/src/lib/stats.ts +0 -35
- package/src/projections/calendar.ts +0 -46
- package/src/projections/communities.ts +0 -135
- package/src/projections/cycle.ts +0 -85
- package/src/projections/hr_zones.ts +0 -43
- package/src/projections/journal.ts +0 -55
- package/src/projections/leaderboard.ts +0 -49
- package/src/projections/lift_exercise.ts +0 -29
- package/src/projections/lift_history.ts +0 -140
- package/src/projections/lift_library.ts +0 -70
- package/src/projections/lift_progression.ts +0 -138
- package/src/projections/lift_prs.ts +0 -23
- package/src/projections/live_hr.ts +0 -21
- package/src/projections/live_state.ts +0 -28
- package/src/projections/live_stress.ts +0 -13
- package/src/projections/performance_assessment.ts +0 -19
- package/src/projections/profile.ts +0 -71
- package/src/projections/recovery.ts +0 -133
- package/src/projections/sleep_need.ts +0 -36
- package/src/projections/smart_alarm.ts +0 -70
- package/src/projections/strain.ts +0 -131
- package/src/projections/stress.ts +0 -95
- package/src/projections/today.ts +0 -166
- package/src/projections/trend.ts +0 -149
- package/src/projections/workouts.ts +0 -36
- package/src/schemas/calendar.ts +0 -13
- package/src/schemas/communities.ts +0 -56
- package/src/schemas/compare.ts +0 -17
- package/src/schemas/leaderboard.ts +0 -26
- package/src/schemas/live.ts +0 -31
- package/src/schemas/performance.ts +0 -13
- package/src/schemas/profile.ts +0 -40
- package/src/schemas/recovery.ts +0 -28
- package/src/schemas/settings.ts +0 -30
- package/src/schemas/sleep_need.ts +0 -16
- package/src/schemas/smart_alarm.ts +0 -40
- package/src/schemas/strain.ts +0 -25
- package/src/schemas/stress.ts +0 -17
- package/src/schemas/today.ts +0 -39
- package/src/schemas/trend.ts +0 -53
- package/src/schemas/womens_health.ts +0 -26
- package/src/tools/v2/activity_create.ts +0 -74
- package/src/tools/v2/behavior_impact.ts +0 -39
- package/src/tools/v2/communities.ts +0 -65
- package/src/tools/v2/compare.ts +0 -83
- package/src/tools/v2/endpoints.ts +0 -32
- package/src/tools/v2/hidden_metric.ts +0 -33
- package/src/tools/v2/hr_zones.ts +0 -29
- package/src/tools/v2/journal_autopop.ts +0 -26
- package/src/tools/v2/journal_catalog.ts +0 -48
- package/src/tools/v2/leaderboard.ts +0 -92
- package/src/tools/v2/lift_catalog.ts +0 -48
- package/src/tools/v2/lift_custom_exercise.ts +0 -117
- package/src/tools/v2/lift_history.ts +0 -52
- package/src/tools/v2/lift_progression.ts +0 -34
- package/src/tools/v2/lift_prs.ts +0 -26
- package/src/tools/v2/lift_template_save.ts +0 -89
- package/src/tools/v2/live_hr.ts +0 -26
- package/src/tools/v2/live_state.ts +0 -26
- package/src/tools/v2/live_stress.ts +0 -27
- package/src/tools/v2/performance_assessment.ts +0 -44
- package/src/tools/v2/sleep_need.ts +0 -26
- package/src/tools/v2/sports_catalog.ts +0 -32
- package/src/tools/v2/symptom_log.ts +0 -78
- package/src/tools/v2/today.ts +0 -35
- package/src/tools/v2/workout.ts +0 -28
- package/src/whoop/build_lift_body.ts +0 -84
- package/src/whoop/session_state.ts +0 -41
- package/src/whoop/types.ts +0 -89
|
@@ -1,60 +1,554 @@
|
|
|
1
|
-
// Holds the
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// Holds the WHOOP login, refreshes it, and keeps it alive.
|
|
2
|
+
//
|
|
3
|
+
// - Durable (G6): every rotated refresh token is written to the TokenStore
|
|
4
|
+
// BEFORE the new access token is handed out. A failed write is fatal: the old
|
|
5
|
+
// refresh token is already spent, so carrying on would strand the login at the
|
|
6
|
+
// next restart.
|
|
7
|
+
// - Keep-alive (G7): refresh when less than 10 minutes of access life remain,
|
|
8
|
+
// plus a periodic refresh (default every 12 h, TOTEM_KEEPALIVE_HOURS) so an
|
|
9
|
+
// idle server never lets the refresh token go unused. The timer is unref'd and
|
|
10
|
+
// shares the single-flight with on-demand refreshes.
|
|
11
|
+
// - One owner (G8): with a TokenLock, only the lock holder refreshes. Another
|
|
12
|
+
// process on the same token file runs as a follower: it picks up the owner's
|
|
13
|
+
// rotated tokens from the file and never refreshes; it takes over only when
|
|
14
|
+
// the owner's lock goes stale, and otherwise fails with WhoopTokenOwnedError.
|
|
15
|
+
// - The file is the source of truth: when another writer changes it (`totem
|
|
16
|
+
// auth`, a push to the admin endpoint), the manager adopts the new login on
|
|
17
|
+
// its next call, without a restart.
|
|
18
|
+
// - G9: WhoopAuthExpiredError only when Cognito refuses the refresh itself.
|
|
19
|
+
import { CognitoError, decodeJwtExp, refreshCognitoSession } from "./cognito.js";
|
|
20
|
+
import { WhoopAuthExpiredError } from "./errors.js";
|
|
21
|
+
import { WhoopTokenOwnedError } from "./token_lock.js";
|
|
22
|
+
import { isHandoff } from "./token_store.js";
|
|
23
|
+
const MINUTE = 60_000;
|
|
24
|
+
const HOUR = 60 * MINUTE;
|
|
25
|
+
/**
|
|
26
|
+
* The keep-alive timer wakes at least this often and compares wall clocks.
|
|
27
|
+
* Node's timers count running time, which on Linux excludes suspend: a timer
|
|
28
|
+
* set for "in 12 hours" would fire 12 hours of awake time later.
|
|
29
|
+
*/
|
|
30
|
+
const MAX_TICK_MS = MINUTE;
|
|
31
|
+
/**
|
|
32
|
+
* A token we refreshed less than this long ago is used as it is, whatever its
|
|
33
|
+
* `exp` says. Without it a clock running far ahead (every new token looks
|
|
34
|
+
* expired on arrival), an undecodable token or a tiny TOTEM_KEEPALIVE_HOURS
|
|
35
|
+
* turns every call or every second into a refresh, and each refresh rotates
|
|
36
|
+
* the refresh token. A 401 still forces a refresh (see invalidate()).
|
|
37
|
+
*/
|
|
38
|
+
const MIN_REFRESH_GAP_MS = 5 * MINUTE;
|
|
39
|
+
/** A follower lets the owner go first, then checks. */
|
|
40
|
+
const FOLLOWER_GRACE_MS = 2 * MINUTE;
|
|
41
|
+
/** A follower re-checks this often while a live owner hasn't refreshed yet. */
|
|
42
|
+
const FOLLOWER_POLL_MS = 5 * MINUTE;
|
|
43
|
+
/** A follower keeps using an access token until this close to expiry. */
|
|
44
|
+
const FOLLOWER_MIN_LIFE_MS = 30_000;
|
|
45
|
+
/** No login saved on this server or machine. */
|
|
46
|
+
export class WhoopNotLoggedInError extends WhoopAuthExpiredError {
|
|
47
|
+
constructor(where) {
|
|
48
|
+
super();
|
|
49
|
+
this.message = `No WHOOP login on this server (${where}). Run \`totem auth\` to log in (without the totem command: \`npx @thebriangao/totem auth --local\`).`;
|
|
50
|
+
this.name = "WhoopNotLoggedInError";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** This copy's login was pushed to a deployment by `totem auth`; it must not refresh. */
|
|
54
|
+
export class WhoopLoginHandedOffError extends WhoopAuthExpiredError {
|
|
55
|
+
to;
|
|
56
|
+
constructor(to, at) {
|
|
57
|
+
super();
|
|
58
|
+
this.to = to;
|
|
59
|
+
this.message =
|
|
60
|
+
`This WHOOP login was handed to ${to} (${at.slice(0, 10)}), so this copy no longer refreshes it. ` +
|
|
61
|
+
"Run `totem auth --local` to give this machine its own login.";
|
|
62
|
+
this.name = "WhoopLoginHandedOffError";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** The rotated refresh token could not be written. Fatal: the old one is spent. */
|
|
66
|
+
export class WhoopTokenPersistError extends Error {
|
|
67
|
+
constructor(where, cause) {
|
|
68
|
+
super(`Couldn't save the rotated WHOOP refresh token to ${where} (${cause instanceof Error ? cause.message : String(cause)}). ` +
|
|
69
|
+
"The previous refresh token is already spent, so this login can't survive a restart. Fix the disk, then run `totem auth`.");
|
|
70
|
+
this.name = "WhoopTokenPersistError";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The token directory can't be written right now, found out BEFORE spending the
|
|
75
|
+
* refresh token. Nothing is lost: the login is still valid and refreshes again
|
|
76
|
+
* once the disk is writable.
|
|
77
|
+
*/
|
|
78
|
+
export class WhoopTokenUnwritableError extends Error {
|
|
79
|
+
constructor(where, cause) {
|
|
80
|
+
super(`Can't write next to the WHOOP token file ${where} (${cause instanceof Error ? cause.message : String(cause)}), ` +
|
|
81
|
+
"so the token wasn't refreshed (a rotated refresh token that can't be saved would end the login). Fix the disk or its permissions.");
|
|
82
|
+
this.name = "WhoopTokenUnwritableError";
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** The refresh failed for a reason other than a refused login (network, throttling, outage). */
|
|
86
|
+
export class WhoopRefreshUnavailableError extends Error {
|
|
87
|
+
constructor(cause) {
|
|
88
|
+
super(`Couldn't reach WHOOP's login service to refresh the token (${cause instanceof Error ? cause.message : String(cause)}). Try again shortly.`);
|
|
89
|
+
this.name = "WhoopRefreshUnavailableError";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
7
92
|
export class TokenManager {
|
|
8
|
-
email;
|
|
9
|
-
accessToken;
|
|
10
|
-
refreshToken;
|
|
11
|
-
expiresAt; // epoch ms
|
|
12
|
-
skewMs;
|
|
13
93
|
store;
|
|
94
|
+
lock;
|
|
95
|
+
skewMs;
|
|
96
|
+
keepAliveMs;
|
|
97
|
+
retryBaseMs;
|
|
98
|
+
saveAttempts;
|
|
99
|
+
now;
|
|
100
|
+
refreshFn;
|
|
101
|
+
log;
|
|
102
|
+
onFatal;
|
|
103
|
+
onLoginChange;
|
|
104
|
+
record = null;
|
|
105
|
+
handoff = null;
|
|
106
|
+
expired = null;
|
|
107
|
+
fatal = null;
|
|
108
|
+
forceRefresh = false;
|
|
109
|
+
lastRefreshAt = 0;
|
|
110
|
+
seenVersion = null;
|
|
111
|
+
/** Version of a token file that failed to load (reported once). */
|
|
112
|
+
unreadableVersion = undefined;
|
|
113
|
+
loaded = false;
|
|
14
114
|
refreshing = null;
|
|
115
|
+
timer = null;
|
|
116
|
+
nextAt = null;
|
|
117
|
+
retryMs;
|
|
118
|
+
stopped = true;
|
|
119
|
+
ownerHint = null;
|
|
15
120
|
constructor(config) {
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
|
|
22
|
-
|
|
121
|
+
this.store = config.store;
|
|
122
|
+
this.lock = config.lock ?? null;
|
|
123
|
+
this.skewMs = config.refreshSkewMs ?? 10 * MINUTE;
|
|
124
|
+
this.keepAliveMs = config.keepAliveMs ?? 12 * HOUR;
|
|
125
|
+
this.retryBaseMs = config.retryBaseMs ?? MINUTE;
|
|
126
|
+
this.retryMs = this.retryBaseMs;
|
|
127
|
+
this.saveAttempts = Math.max(1, config.saveAttempts ?? 3);
|
|
128
|
+
this.now = config.now ?? Date.now;
|
|
129
|
+
this.refreshFn = config.refresh ?? refreshCognitoSession;
|
|
130
|
+
this.log = config.log ?? ((m) => console.error(`[totem] ${m}`));
|
|
131
|
+
this.onFatal = config.onFatal;
|
|
132
|
+
this.onLoginChange = config.onLoginChange;
|
|
133
|
+
}
|
|
134
|
+
/** Load the saved login, claim ownership, and start the keep-alive timer. */
|
|
135
|
+
start() {
|
|
136
|
+
this.stopped = false;
|
|
137
|
+
this.sync(true);
|
|
138
|
+
if (this.lock) {
|
|
139
|
+
const result = this.lock.tryAcquire();
|
|
140
|
+
if (result.acquired) {
|
|
141
|
+
this.lock.startHeartbeat(() => this.log("lost the token lock to another process; this process won't refresh any more"));
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
this.ownerHint = result.holder;
|
|
145
|
+
this.log(`another totem process (pid ${result.holder?.pid ?? "?"}) owns this login; this one follows its token file and won't refresh`);
|
|
146
|
+
}
|
|
23
147
|
}
|
|
24
|
-
|
|
25
|
-
|
|
148
|
+
this.schedule();
|
|
149
|
+
}
|
|
150
|
+
/** Stop the timer and release the lock. */
|
|
151
|
+
stop() {
|
|
152
|
+
this.stopped = true;
|
|
153
|
+
this.clearTimer();
|
|
154
|
+
this.lock?.release();
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* When the keep-alive next means to refresh (epoch ms), or null when there is
|
|
158
|
+
* nothing to keep alive. A host that may freeze the process between requests
|
|
159
|
+
* (a Cloudflare Durable Object) schedules its own wake-up for this time.
|
|
160
|
+
*/
|
|
161
|
+
nextRefreshAt() {
|
|
162
|
+
return this.nextAt;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Run the keep-alive now if it is due: the host's scheduled wake-up, for when
|
|
166
|
+
* a timer can't be trusted to survive. Errors are handled as the timer's are
|
|
167
|
+
* (logged, retried with backoff), so this never throws.
|
|
168
|
+
*/
|
|
169
|
+
async wake() {
|
|
170
|
+
if (this.stopped)
|
|
171
|
+
return;
|
|
172
|
+
this.sync();
|
|
173
|
+
if (!this.record || this.handoff || this.fatal || this.expired)
|
|
174
|
+
return;
|
|
175
|
+
if (this.now() < this.dueAt(this.record))
|
|
176
|
+
return;
|
|
177
|
+
this.clearTimer();
|
|
178
|
+
await this.keepAlive();
|
|
179
|
+
}
|
|
180
|
+
/** The current access token, refreshing first when needed. */
|
|
181
|
+
async getToken() {
|
|
182
|
+
this.sync();
|
|
183
|
+
const record = this.usable();
|
|
184
|
+
if (!this.needsRefresh(record))
|
|
185
|
+
return record.access_token;
|
|
186
|
+
await this.ensureFresh("on demand", (r) => this.needsRefresh(r));
|
|
187
|
+
return this.usable().access_token;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* WHOOP answered 401 with `rejectedToken`: force the next getToken() to refresh.
|
|
191
|
+
* Ignored when that token is no longer current (parallel 401s cost one refresh)
|
|
192
|
+
* or within a minute of the last refresh (a token WHOOP keeps rejecting is
|
|
193
|
+
* path-specific, not expired; see client.ts).
|
|
194
|
+
*/
|
|
195
|
+
invalidate(rejectedToken) {
|
|
196
|
+
if (rejectedToken !== this.record?.access_token)
|
|
197
|
+
return;
|
|
198
|
+
if (this.now() - this.lastRefreshAt < MINUTE)
|
|
199
|
+
return;
|
|
200
|
+
this.forceRefresh = true;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Install a new login (POST /admin/tokens). Persists it first; throws when the
|
|
204
|
+
* write fails, leaving the previous login in place.
|
|
205
|
+
*/
|
|
206
|
+
adopt(record) {
|
|
207
|
+
if (this.lock && !this.lock.held) {
|
|
208
|
+
const result = this.lock.tryAcquire();
|
|
209
|
+
if (result.acquired)
|
|
210
|
+
this.lock.startHeartbeat();
|
|
26
211
|
}
|
|
27
|
-
|
|
28
|
-
|
|
212
|
+
this.store.save(record);
|
|
213
|
+
this.seenVersion = this.store.version();
|
|
214
|
+
this.loaded = true;
|
|
215
|
+
this.setRecord(record, null);
|
|
216
|
+
this.lastRefreshAt = 0;
|
|
217
|
+
this.fatal = null;
|
|
218
|
+
this.retryMs = this.retryBaseMs;
|
|
219
|
+
this.log(`installed a new WHOOP login (${record.source}); saved to ${this.store.description}`);
|
|
220
|
+
this.schedule();
|
|
221
|
+
}
|
|
222
|
+
/** Record extra fields on the current login (owner only, best-effort). */
|
|
223
|
+
annotate(patch) {
|
|
224
|
+
// Start from the file, and only as the proven owner: writing our in-memory
|
|
225
|
+
// copy as a process that lost the lock would put a spent refresh token back
|
|
226
|
+
// over the one the new owner rotated.
|
|
227
|
+
this.sync();
|
|
228
|
+
if (!this.record || (this.lock && !this.lock.verify()))
|
|
229
|
+
return;
|
|
230
|
+
const next = { ...this.record };
|
|
231
|
+
if (patch.user_id !== undefined)
|
|
232
|
+
next.user_id = patch.user_id;
|
|
233
|
+
if (patch.installation_id !== undefined)
|
|
234
|
+
next.installation_id = patch.installation_id;
|
|
235
|
+
try {
|
|
236
|
+
this.store.save(next);
|
|
237
|
+
this.seenVersion = this.store.version();
|
|
238
|
+
this.record = next;
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
this.log(`couldn't update ${this.store.description}: ${error.message}`);
|
|
29
242
|
}
|
|
30
243
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
244
|
+
/** The current login, if any (after picking up file changes). */
|
|
245
|
+
current() {
|
|
246
|
+
this.sync();
|
|
247
|
+
return this.record;
|
|
248
|
+
}
|
|
249
|
+
status() {
|
|
250
|
+
this.sync();
|
|
251
|
+
const role = !this.lock ? "solo" : this.lock.held ? "owner" : "follower";
|
|
252
|
+
const r = this.record;
|
|
253
|
+
const state = this.fatal ? "fatal"
|
|
254
|
+
: this.handoff ? "handed-off"
|
|
255
|
+
: !r ? "no-login"
|
|
256
|
+
: this.expired ? "expired"
|
|
257
|
+
: "ok";
|
|
258
|
+
const exp = r ? decodeJwtExp(r.access_token) * 1000 : 0;
|
|
259
|
+
const owner = role === "follower" ? (this.lock?.readHolder() ?? this.ownerHint) : null;
|
|
260
|
+
return {
|
|
261
|
+
state,
|
|
262
|
+
role,
|
|
263
|
+
store: this.store.description,
|
|
264
|
+
source: r?.source,
|
|
265
|
+
client_id: r?.client_id,
|
|
266
|
+
user_id: r?.user_id ?? this.handoff?.user_id,
|
|
267
|
+
saved_at: r?.saved_at ?? this.handoff?.saved_at,
|
|
268
|
+
refreshed_at: r?.refreshed_at,
|
|
269
|
+
access_expires_at: exp ? new Date(exp).toISOString() : undefined,
|
|
270
|
+
next_keepalive_at: this.nextAt ? new Date(this.nextAt).toISOString() : undefined,
|
|
271
|
+
handed_off_to: this.handoff?.handed_off_to,
|
|
272
|
+
owner: owner ? { pid: owner.pid, host: owner.host } : undefined,
|
|
273
|
+
detail: this.fatal?.message ?? this.expired ?? undefined,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
// ── internals ────────────────────────────────────────────────────────────
|
|
277
|
+
/** The current record, or the error explaining why there isn't a usable one. */
|
|
278
|
+
usable() {
|
|
279
|
+
if (this.fatal)
|
|
280
|
+
throw this.fatal;
|
|
281
|
+
if (this.handoff)
|
|
282
|
+
throw new WhoopLoginHandedOffError(this.handoff.handed_off_to, this.handoff.saved_at);
|
|
283
|
+
if (!this.record)
|
|
284
|
+
throw new WhoopNotLoggedInError(this.store.description);
|
|
285
|
+
if (this.expired)
|
|
286
|
+
throw new WhoopAuthExpiredError(this.expired);
|
|
287
|
+
return this.record;
|
|
288
|
+
}
|
|
289
|
+
timeLeft(record) {
|
|
290
|
+
return decodeJwtExp(record.access_token) * 1000 - this.now();
|
|
291
|
+
}
|
|
292
|
+
/** Last refresh (or login) time of a record, epoch ms. */
|
|
293
|
+
refreshedAt(record) {
|
|
294
|
+
const t = Date.parse(record.refreshed_at ?? record.saved_at);
|
|
295
|
+
return Number.isFinite(t) ? t : 0;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Whether this record came out of a refresh less than MIN_REFRESH_GAP_MS ago
|
|
299
|
+
* (by `refreshed_at`, which only a refresh writes; a timestamp in the future
|
|
300
|
+
* means the clock was changed, and counts as "no").
|
|
301
|
+
*/
|
|
302
|
+
justRefreshed(record) {
|
|
303
|
+
const at = Date.parse(record.refreshed_at ?? "");
|
|
304
|
+
if (!Number.isFinite(at))
|
|
305
|
+
return false;
|
|
306
|
+
const since = this.now() - at;
|
|
307
|
+
return since >= 0 && since < MIN_REFRESH_GAP_MS;
|
|
308
|
+
}
|
|
309
|
+
/** Whether a call must refresh before it gets a token. */
|
|
310
|
+
needsRefresh(record) {
|
|
311
|
+
if (this.forceRefresh)
|
|
312
|
+
return true;
|
|
313
|
+
return this.timeLeft(record) <= this.skewMs && !this.justRefreshed(record);
|
|
314
|
+
}
|
|
315
|
+
/** When the keep-alive should next refresh this record. */
|
|
316
|
+
dueAt(record) {
|
|
317
|
+
const byExpiry = decodeJwtExp(record.access_token) * 1000 - this.skewMs;
|
|
318
|
+
const byPeriod = this.keepAliveMs > 0 ? this.refreshedAt(record) + this.keepAliveMs : Infinity;
|
|
319
|
+
const due = Math.min(byExpiry, byPeriod);
|
|
320
|
+
return this.justRefreshed(record) ? Math.max(due, Date.parse(record.refreshed_at) + MIN_REFRESH_GAP_MS) : due;
|
|
321
|
+
}
|
|
322
|
+
/** dueAt, plus a grace period for a follower so the owner goes first. */
|
|
323
|
+
followerAwareDue(record) {
|
|
324
|
+
return this.dueAt(record) + (this.lock && !this.lock.held ? FOLLOWER_GRACE_MS : 0);
|
|
325
|
+
}
|
|
326
|
+
/** Re-read the store when it changed (or when forced). */
|
|
327
|
+
sync(force = false) {
|
|
328
|
+
const version = this.store.version();
|
|
329
|
+
if (!force && this.loaded && version === this.seenVersion)
|
|
330
|
+
return;
|
|
331
|
+
let content;
|
|
332
|
+
try {
|
|
333
|
+
content = this.store.load();
|
|
334
|
+
}
|
|
335
|
+
catch (error) {
|
|
336
|
+
// Keep what we have and look again on the next call. Say so once per
|
|
337
|
+
// bad file, not on every call.
|
|
338
|
+
if (version !== this.unreadableVersion)
|
|
339
|
+
this.log(error.message);
|
|
340
|
+
this.unreadableVersion = version;
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
this.unreadableVersion = undefined;
|
|
344
|
+
this.loaded = true;
|
|
345
|
+
this.seenVersion = version;
|
|
346
|
+
if (!content)
|
|
347
|
+
this.setRecord(null, null);
|
|
348
|
+
else if (isHandoff(content))
|
|
349
|
+
this.setRecord(null, content);
|
|
350
|
+
else
|
|
351
|
+
this.setRecord(content, null);
|
|
352
|
+
}
|
|
353
|
+
setRecord(record, handoff) {
|
|
354
|
+
const before = this.record;
|
|
355
|
+
const newLogin = (before?.saved_at ?? null) !== (record?.saved_at ?? null) ||
|
|
356
|
+
(before?.source ?? null) !== (record?.source ?? null) ||
|
|
357
|
+
Boolean(this.handoff) !== Boolean(handoff);
|
|
358
|
+
if (before?.refresh_token !== record?.refresh_token) {
|
|
359
|
+
this.expired = null;
|
|
360
|
+
this.forceRefresh = false;
|
|
361
|
+
}
|
|
362
|
+
this.record = record;
|
|
363
|
+
this.handoff = handoff;
|
|
364
|
+
if (newLogin && this.loaded) {
|
|
365
|
+
this.onLoginChange?.(record);
|
|
366
|
+
if (!this.stopped)
|
|
367
|
+
this.schedule();
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/** Make sure we own the login (or may take it over). */
|
|
371
|
+
claim() {
|
|
372
|
+
if (!this.lock)
|
|
373
|
+
return true;
|
|
374
|
+
if (!this.lock.held) {
|
|
375
|
+
const result = this.lock.tryAcquire();
|
|
376
|
+
if (!result.acquired) {
|
|
377
|
+
this.ownerHint = result.holder;
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
this.log(`took over the WHOOP login${this.ownerHint ? ` from pid ${this.ownerHint.pid}, which stopped` : ""}`);
|
|
381
|
+
this.ownerHint = null;
|
|
382
|
+
this.lock.startHeartbeat(() => this.log("lost the token lock to another process; this process won't refresh any more"));
|
|
383
|
+
}
|
|
384
|
+
// Whether we held the lock all along or took it over a moment ago: prove,
|
|
385
|
+
// under the guard, that the lock file names us, and stamp a fresh heartbeat,
|
|
386
|
+
// right before the refresh token is spent. Believing isn't enough: after a
|
|
387
|
+
// laptop sleep our heartbeat is hours old and a follower waking beside us
|
|
388
|
+
// would take the "stale" lock while our refresh is on the wire.
|
|
389
|
+
let state;
|
|
390
|
+
try {
|
|
391
|
+
state = this.lock.confirm();
|
|
392
|
+
}
|
|
393
|
+
catch (error) {
|
|
394
|
+
// The lock sits next to the token file. If it can't be written, the
|
|
395
|
+
// rotated refresh token couldn't be saved either: don't spend this one.
|
|
396
|
+
throw new WhoopTokenUnwritableError(this.store.description, error);
|
|
397
|
+
}
|
|
398
|
+
if (state === "held")
|
|
399
|
+
return true;
|
|
400
|
+
this.ownerHint = this.lock.readHolder(); // lost, or another process is changing the lock right now
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
ensureFresh(reason, mustRefresh) {
|
|
35
404
|
if (!this.refreshing) {
|
|
36
|
-
this.refreshing = this.
|
|
405
|
+
this.refreshing = this.refreshOnce(reason, mustRefresh).finally(() => {
|
|
37
406
|
this.refreshing = null;
|
|
38
407
|
});
|
|
39
408
|
}
|
|
40
|
-
|
|
41
|
-
return this.accessToken;
|
|
409
|
+
return this.refreshing;
|
|
42
410
|
}
|
|
43
|
-
|
|
44
|
-
|
|
411
|
+
async refreshOnce(reason, mustRefresh) {
|
|
412
|
+
if (!this.claim()) {
|
|
413
|
+
// Follower: the owner refreshes and writes the file; we only read it.
|
|
414
|
+
this.sync(true);
|
|
415
|
+
const record = this.usable();
|
|
416
|
+
this.forceRefresh = false;
|
|
417
|
+
if (this.timeLeft(record) > FOLLOWER_MIN_LIFE_MS || this.justRefreshed(record))
|
|
418
|
+
return;
|
|
419
|
+
throw new WhoopTokenOwnedError(this.ownerHint, this.lock.path);
|
|
420
|
+
}
|
|
421
|
+
// Pick up a login another writer saved (`totem auth`) before spending ours.
|
|
422
|
+
this.sync();
|
|
423
|
+
const before = this.usable();
|
|
424
|
+
if (!mustRefresh(before))
|
|
425
|
+
return;
|
|
426
|
+
const versionBefore = this.store.version();
|
|
427
|
+
let next;
|
|
428
|
+
try {
|
|
429
|
+
next = await this.refreshFn(before.refresh_token, before.client_id);
|
|
430
|
+
}
|
|
431
|
+
catch (error) {
|
|
432
|
+
if (error instanceof CognitoError && error.isAuthFailure) {
|
|
433
|
+
this.expired = error.message;
|
|
434
|
+
this.log(`WHOOP refused the refresh token (${error.message}). Run \`totem auth\` to log in again.`);
|
|
435
|
+
throw new WhoopAuthExpiredError(error.message);
|
|
436
|
+
}
|
|
437
|
+
throw new WhoopRefreshUnavailableError(error);
|
|
438
|
+
}
|
|
439
|
+
// The file changed while we were refreshing. If `totem auth` replaced the
|
|
440
|
+
// login, handed it to a deployment, or the file was removed, that wins: the
|
|
441
|
+
// session we just refreshed is abandoned, never written back over it.
|
|
442
|
+
if (this.store.version() !== versionBefore) {
|
|
443
|
+
this.sync(true);
|
|
444
|
+
if (!this.record) {
|
|
445
|
+
this.log("the login was handed off or removed while refreshing; not saving the refreshed session");
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
if (this.record.refresh_token !== before.refresh_token) {
|
|
449
|
+
this.log("the login was replaced while refreshing; using the new one");
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
const record = {
|
|
454
|
+
...(this.record ?? before), // the same login, with anything annotate() added meanwhile
|
|
455
|
+
access_token: next.accessToken,
|
|
456
|
+
refresh_token: next.refreshToken || before.refresh_token,
|
|
457
|
+
refreshed_at: new Date(this.now()).toISOString(),
|
|
458
|
+
};
|
|
459
|
+
this.persist(record); // before anyone sees the new access token
|
|
460
|
+
this.record = record;
|
|
461
|
+
this.forceRefresh = false;
|
|
462
|
+
this.lastRefreshAt = this.now();
|
|
463
|
+
const exp = decodeJwtExp(record.access_token) * 1000;
|
|
464
|
+
this.log(`refreshed the WHOOP access token (${reason}); it expires ${exp ? new Date(exp).toISOString() : "at an unknown time"}` +
|
|
465
|
+
`${record.refresh_token !== before.refresh_token ? "; rotated refresh token saved" : ""}`);
|
|
466
|
+
this.schedule();
|
|
45
467
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
468
|
+
persist(record) {
|
|
469
|
+
let lastError;
|
|
470
|
+
for (let attempt = 0; attempt < this.saveAttempts; attempt++) {
|
|
471
|
+
try {
|
|
472
|
+
this.store.save(record);
|
|
473
|
+
this.seenVersion = this.store.version();
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
catch (error) {
|
|
477
|
+
lastError = error;
|
|
478
|
+
}
|
|
55
479
|
}
|
|
56
|
-
|
|
57
|
-
this.
|
|
480
|
+
const fatal = new WhoopTokenPersistError(this.store.description, lastError);
|
|
481
|
+
this.fatal = fatal;
|
|
482
|
+
this.clearTimer();
|
|
483
|
+
this.log(fatal.message);
|
|
484
|
+
this.onFatal?.(fatal);
|
|
485
|
+
throw fatal;
|
|
486
|
+
}
|
|
487
|
+
// ── keep-alive ───────────────────────────────────────────────────────────
|
|
488
|
+
clearTimer() {
|
|
489
|
+
if (this.timer)
|
|
490
|
+
clearTimeout(this.timer);
|
|
491
|
+
this.timer = null;
|
|
492
|
+
this.nextAt = null;
|
|
493
|
+
}
|
|
494
|
+
schedule(delayOverride) {
|
|
495
|
+
this.clearTimer();
|
|
496
|
+
if (this.stopped || this.fatal || this.handoff || this.expired || !this.record)
|
|
497
|
+
return;
|
|
498
|
+
const delay = Math.max(delayOverride ?? this.followerAwareDue(this.record) - this.now(), 1_000);
|
|
499
|
+
this.nextAt = this.now() + delay;
|
|
500
|
+
this.arm();
|
|
58
501
|
}
|
|
502
|
+
/** Sleep until `nextAt` by the wall clock, in steps of at most MAX_TICK_MS. */
|
|
503
|
+
arm() {
|
|
504
|
+
if (this.nextAt === null)
|
|
505
|
+
return;
|
|
506
|
+
const wait = Math.min(Math.max(this.nextAt - this.now(), 0), MAX_TICK_MS);
|
|
507
|
+
this.timer = setTimeout(() => void this.keepAlive(), wait);
|
|
508
|
+
this.timer.unref?.();
|
|
509
|
+
}
|
|
510
|
+
async keepAlive() {
|
|
511
|
+
this.timer = null;
|
|
512
|
+
if (this.stopped)
|
|
513
|
+
return;
|
|
514
|
+
if (this.nextAt !== null && this.now() < this.nextAt) {
|
|
515
|
+
this.arm(); // only a tick: not due yet by the wall clock
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
this.nextAt = null;
|
|
519
|
+
try {
|
|
520
|
+
this.sync();
|
|
521
|
+
if (!this.record || this.handoff || this.fatal || this.expired)
|
|
522
|
+
return;
|
|
523
|
+
await this.ensureFresh("keep-alive", (r) => this.now() >= this.dueAt(r));
|
|
524
|
+
this.retryMs = this.retryBaseMs;
|
|
525
|
+
// A follower whose live owner hasn't refreshed yet polls instead of spinning.
|
|
526
|
+
const waiting = this.record && this.followerAwareDue(this.record) <= this.now();
|
|
527
|
+
this.schedule(waiting ? FOLLOWER_POLL_MS : undefined);
|
|
528
|
+
}
|
|
529
|
+
catch (error) {
|
|
530
|
+
if (error instanceof WhoopTokenOwnedError) {
|
|
531
|
+
this.schedule(FOLLOWER_POLL_MS);
|
|
532
|
+
}
|
|
533
|
+
else if (error instanceof WhoopAuthExpiredError || error instanceof WhoopTokenPersistError) {
|
|
534
|
+
// Logged where it happened; nothing to retry until a new login arrives.
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
this.log(`keep-alive refresh failed (${error.message}); retrying in ${Math.round(this.retryMs / 1000)}s`);
|
|
538
|
+
const delay = this.retryMs;
|
|
539
|
+
this.retryMs = Math.min(this.retryMs * 2, 15 * MINUTE);
|
|
540
|
+
this.schedule(delay);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
/** Keep-alive interval from TOTEM_KEEPALIVE_HOURS (default 12; 0 = expiry-driven only). */
|
|
546
|
+
export function keepAliveMsFromEnv(value) {
|
|
547
|
+
if (value === undefined || value.trim() === "")
|
|
548
|
+
return 12 * HOUR;
|
|
549
|
+
const hours = Number(value);
|
|
550
|
+
if (!Number.isFinite(hours) || hours < 0)
|
|
551
|
+
return 12 * HOUR;
|
|
552
|
+
return Math.round(hours * HOUR);
|
|
59
553
|
}
|
|
60
554
|
//# sourceMappingURL=token_manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token_manager.js","sourceRoot":"","sources":["../../src/whoop/token_manager.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,yEAAyE;AACzE,4EAA4E;AAC5E,kCAAkC;AAClC,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAmB,MAAM,kBAAkB,CAAC;AAiBtE,MAAM,OAAO,YAAY;IACf,KAAK,CAAS;IACd,WAAW,CAAS;IACpB,YAAY,CAA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