switchman-dev 0.1.11 → 0.1.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "switchman-dev",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Project manager for AI coding assistants running safely on one codebase",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -123,6 +123,13 @@ export async function checkLicence() {
123
123
  return { valid: false, reason: 'not_logged_in' };
124
124
  }
125
125
 
126
+ // Proactively refresh if token expires within 5 minutes
127
+ if (creds.expires_at && Date.now() > creds.expires_at - 5 * 60 * 1000) {
128
+ if (creds.refresh_token) {
129
+ await refreshToken(creds.refresh_token);
130
+ }
131
+ }
132
+
126
133
  // Check the 24-hour cache first
127
134
  const cache = readLicenceCache();
128
135
  if (cache?.valid && cache.cached_at) {
@@ -134,12 +141,13 @@ export async function checkLicence() {
134
141
 
135
142
  // Try live validation
136
143
  try {
137
- const res = await fetch(VALIDATE_URL, {
138
- headers: {
139
- 'Authorization': `Bearer ${creds.access_token}`,
140
- 'apikey': SUPABASE_ANON,
141
- },
142
- });
144
+ const res = await fetch(VALIDATE_URL, {
145
+ headers: {
146
+ 'Authorization': `Bearer ${SUPABASE_ANON}`,
147
+ 'apikey': SUPABASE_ANON,
148
+ 'x-user-token': creds.access_token,
149
+ },
150
+ });
143
151
 
144
152
  if (!res.ok) {
145
153
  // If token is expired, try to refresh