@fytkit/sdk 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ All notable changes to `@fytkit/sdk` are documented in this file.
4
4
  Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/).
5
5
  Versioning: [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.6.0](https://github.com/cbarlow1993/fytkit-web/compare/@fytkit/sdk@0.5.0...@fytkit/sdk@0.6.0) (2026-07-05)
8
+
9
+
10
+ ### Features
11
+
12
+ * mobile settings/profile APIs — security, preferences, profile fields, billing (+ SDK) ([#118](https://github.com/cbarlow1993/fytkit-web/issues/118)) ([4f607ca](https://github.com/cbarlow1993/fytkit-web/commit/4f607ca2e18e2e46c23617c538a7795051c1359f))
13
+
14
+ ## [0.5.0](https://github.com/cbarlow1993/fytkit-web/compare/@fytkit/sdk@0.4.0...@fytkit/sdk@0.5.0) (2026-07-05)
15
+
16
+
17
+ ### Features
18
+
19
+ * **sdk:** ad-hoc workout logging, stored PR history and streak endpoints ([#116](https://github.com/cbarlow1993/fytkit-web/issues/116)) ([5b069f9](https://github.com/cbarlow1993/fytkit-web/commit/5b069f993ee66d5aa4d54b04f2096d39a4ca7a37))
20
+
7
21
  ## [0.4.0](https://github.com/cbarlow1993/fytkit-web/compare/@fytkit/sdk@0.3.0...@fytkit/sdk@0.4.0) (2026-06-13)
8
22
 
9
23
 
package/README.md CHANGED
@@ -48,11 +48,106 @@ await fytkit.auth.signOut();
48
48
  off();
49
49
  ```
50
50
 
51
+ ## Tracking a workout
52
+
53
+ Log a workout ad-hoc (no program enrollment needed), record sets, complete
54
+ it, then read back progress:
55
+
56
+ ```ts
57
+ // Start an ad-hoc log against any workout — or pass { sessionId, enrollmentId }
58
+ // instead to log a scheduled program session.
59
+ const { data: log } = await fytkit.sessionLogs.create({ workoutId });
60
+
61
+ await fytkit.sessionLogs.addSet({
62
+ id: log.id,
63
+ exerciseId,
64
+ setNumber: 1,
65
+ reps: 8,
66
+ weightKg: "80.00",
67
+ });
68
+
69
+ await fytkit.sessionLogs.update({ id: log.id, completedAt: new Date().toISOString() });
70
+
71
+ // Workout-by-workout history for that workout
72
+ const { data: history } = await fytkit.sessionLogs.list({ workoutId });
73
+
74
+ // Stored progress: streak, PR history, aggregate summary
75
+ const { data: streak } = await fytkit.progress.getStreak({});
76
+ const { data: prs } = await fytkit.progression.listPrHistory({ exerciseId });
77
+ const { data: summary } = await fytkit.progress.getSummary({ period: "12w" });
78
+ ```
79
+
80
+ ## Two-factor sign-in
81
+
82
+ `auth.signIn` returns a discriminated result. When the trainee has 2FA
83
+ enabled, complete the challenge with whichever method they choose:
84
+
85
+ ```ts
86
+ const result = await fytkit.auth.signIn({ email, password });
87
+
88
+ if (result.kind === "two_factor_required") {
89
+ const { challenge } = result; // challenge.availableMethods: "totp" | "backup_code" | "email_otp"
90
+
91
+ // TOTP from their authenticator app…
92
+ const session = await fytkit.auth.verifyTotp({ challenge, code: "123456" });
93
+
94
+ // …or a one-time backup code:
95
+ // await fytkit.auth.verifyBackupCode({ challenge, code });
96
+
97
+ // …or an emailed code:
98
+ // await fytkit.auth.requestEmailOtp({ challenge });
99
+ // await fytkit.auth.verifyEmailOtp({ challenge, code });
100
+ }
101
+ ```
102
+
103
+ Each verify method caches the issued session exactly like a plain sign-in
104
+ (`signed_in` fires on `onAuthStateChange`).
105
+
106
+ ## 2FA enrollment & account security
107
+
108
+ All of these require a signed-in session:
109
+
110
+ ```ts
111
+ // Enroll: render totpUri as a QR code; show backupCodes exactly once.
112
+ const { totpUri, backupCodes } = await fytkit.auth.enableTotp({ password });
113
+ await fytkit.auth.verifyTotpSetup({ code: "123456" }); // SDK swaps the rotated token for you
114
+
115
+ const status = await fytkit.auth.getSecurityStatus(); // { twoFactorEnabled, totpEnabled, hasBackupCodes }
116
+ await fytkit.auth.regenerateBackupCodes({ password });
117
+ await fytkit.auth.disableTwoFactor({ password });
118
+
119
+ // Password change (verifies the current password server-side). With
120
+ // revokeOtherSessions the SDK adopts the rotated token transparently.
121
+ await fytkit.auth.changePassword({ currentPassword, newPassword, revokeOtherSessions: true });
122
+
123
+ // Email change — a confirmation link is emailed to the new address;
124
+ // nothing changes until the trainee opens it.
125
+ await fytkit.auth.changeEmail({ newEmail });
126
+
127
+ // Devices: revokeId is an opaque id (never the bearer token).
128
+ const sessions = await fytkit.auth.listSessions();
129
+ await fytkit.auth.revokeSession({ revokeId: sessions.find((s) => !s.isCurrent)!.revokeId });
130
+ await fytkit.auth.revokeOtherSessions(); // "sign out of all other devices"
131
+ ```
132
+
133
+ ## Notification preferences
134
+
135
+ Per-member toggles stored server-side (defaults apply until first write):
136
+
137
+ ```ts
138
+ const { data: prefs } = await fytkit.preferences.getNotifications();
139
+ await fytkit.preferences.updateNotifications({ streakAlerts: false }); // partial patch
140
+ ```
141
+
51
142
  ## What's included in this preview
52
143
 
53
144
  - `auth.signUp` / `signIn` / `signOut` / `getSession` / `onAuthStateChange`
54
145
  - `auth.requestPasswordReset` / `confirmPasswordReset` / `confirmEmail`
55
- - Data namespaces: `workouts`, `programs`, `recipes`, `nutrition`, `articles`, `enrollments`, `sessionLogs`, `progression`, `media`, `appConfig`, `subscription`
146
+ - Two-factor: `auth.verifyTotp` / `verifyBackupCode` / `requestEmailOtp` / `verifyEmailOtp` (sign-in), `enableTotp` / `verifyTotpSetup` / `disableTwoFactor` / `regenerateBackupCodes` / `getSecurityStatus` (management)
147
+ - Account security: `auth.changePassword` / `changeEmail` / `listSessions` / `revokeSession` / `revokeOtherSessions`
148
+ - Data namespaces: `workouts`, `programs`, `recipes`, `nutrition`, `nutritionLog`, `profile`, `preferences`, `articles`, `enrollments`, `sessionLogs`, `progression`, `progress`, `bodyMetrics`, `media`, `appConfig`, `subscription`
149
+ - Workout tracking: program session logs and ad-hoc workout logs (`sessionLogs.create` with `workoutId`), set logging, per-workout history (`sessionLogs.list({ workoutId })`)
150
+ - Progress: `progress.getSummary` / `getAdherence` / `getStreak` (stored streaks), `progression.getPrSummary` / `listPrHistory` (stored PR history) / `getHistory`, `bodyMetrics.list` / `record` / `delete`
56
151
  - Automatic header injection (`X-Fytkit-Client-Id`, `Authorization: Bearer …`)
57
152
  - Proactive refresh ~60 s before token expiry + reactive 401 retry
58
153
  - Pluggable token storage (`localStorage` default, in-memory + cookie for SSR)