mnfst 0.5.108 → 0.5.109

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.
@@ -7605,44 +7605,45 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
7605
7605
 
7606
7606
  // Authenticate the fetch for permissioned buckets.
7607
7607
  //
7608
- // Storage's /view, /download and /preview endpoints are
7609
- // designed for embed-in-<img> use and check the user's
7610
- // SESSION COOKIE, not API/dev keys (those are honoured
7611
- // only on the JSON endpoints like /storage/buckets/.../
7612
- // files/.../). So X-Appwrite-Dev-Key alone won't open
7613
- // the door, and in localhost dev the cross-domain
7614
- // session cookie won't be sent by the browser either
7615
- // (SameSite=Lax blocks third-party cookies on plain HTTP).
7608
+ // Storage's /view, /download and /preview endpoints check
7609
+ // the USER SESSION not API/dev keys (those work only on
7610
+ // JSON endpoints like /storage/buckets/.../files/.../).
7611
+ // In localhost dev the browser blocks the cross-domain
7612
+ // session cookie (SameSite=Lax on plain HTTP), so the
7613
+ // request lands at Appwrite as anonymous and a permissioned
7614
+ // file returns 404 storage_file_not_found.
7616
7615
  //
7617
- // Appwrite's recommended fix for this exact case is to
7618
- // mint a short-lived JWT from the active session and
7619
- // pass it as `X-Appwrite-JWT`. JWTs expire after 15 min
7620
- // and are rate-limited (10 / hour / account), so we
7621
- // only mint one for this single fetch.
7616
+ // The Appwrite Web SDK works around this by writing the
7617
+ // session token to localStorage under `cookieFallback`
7618
+ // and replaying it as the `X-Fallback-Cookies` header on
7619
+ // every SDK request. That's why SDK calls (getFile metadata
7620
+ // above, listRows, $create, etc.) succeed cross-domain
7621
+ // while raw fetch() doesn't — raw fetch doesn't know to
7622
+ // read that localStorage key.
7622
7623
  //
7623
- // Falls back to credentials-only fetch when:
7624
- // - the auth plugin isn't loaded (no createJWT path)
7625
- // - the user isn't signed in (createJWT would throw)
7626
- // - JWT mint failed for any other reason
7627
- // …because that path still works in production with a
7628
- // proper same-site or SameSite=None session cookie.
7624
+ // We do exactly what the SDK does: read cookieFallback
7625
+ // and attach it as X-Fallback-Cookies. This is more
7626
+ // reliable than JWT:
7627
+ // - no createJWT round-trip (and dev-key-configured
7628
+ // clients 501 on createJWT)
7629
+ // - no 15-min expiry or rate limit (10/hour/account)
7630
+ // - matches whatever auth the SDK is already using
7631
+ //
7632
+ // Falls through to credentials-only when the user isn't
7633
+ // signed in (no cookieFallback in storage) — that path
7634
+ // still works in production with a SameSite=None cookie.
7629
7635
  const fetchHeaders = {};
7630
7636
  if (appwriteConfig.projectId) {
7631
7637
  fetchHeaders['X-Appwrite-Project'] = appwriteConfig.projectId;
7632
7638
  }
7633
7639
  try {
7634
- const getClient = window.ManifestAppwriteAuthConfig?.getAppwriteClient;
7635
- if (getClient && window.Appwrite?.Account) {
7636
- const { client } = await getClient();
7637
- if (client) {
7638
- const account = new window.Appwrite.Account(client);
7639
- const jwtResult = await account.createJWT();
7640
- if (jwtResult?.jwt) {
7641
- fetchHeaders['X-Appwrite-JWT'] = jwtResult.jwt;
7642
- }
7643
- }
7640
+ const cookieFallback = typeof localStorage !== 'undefined'
7641
+ ? localStorage.getItem('cookieFallback')
7642
+ : null;
7643
+ if (cookieFallback) {
7644
+ fetchHeaders['X-Fallback-Cookies'] = cookieFallback;
7644
7645
  }
7645
- } catch { /* JWT mint failed — fall back to cookie auth */ }
7646
+ } catch { /* localStorage access denied — fall through */ }
7646
7647
 
7647
7648
  const response = await fetch(viewUrl, {
7648
7649
  method: 'GET',
@@ -6,7 +6,7 @@
6
6
  "manifest.color.js": "sha384-Z9G/lzt0vVMxjz4wkPuGG1X9mmQAJR15aOoGX3ephf7r2wnlUWet5GLgkUMtT4vt",
7
7
  "manifest.colorpicker.js": "sha384-0EVn+Ha06h7FIvOxc6WjZYnKYXzi+zba08yKvczSEGTRkWRxyKN2TFrZHI1SDCXu",
8
8
  "manifest.components.js": "sha384-3dCTD5EwCZTiX+1obYtDNM3WWwPh2JDQUQQsdRUUK3gs6FXjse1ShkKaT/2jsNaI",
9
- "manifest.data.js": "sha384-nmEQrihotpNg3oF5UdPh1h/PEMrQx6614+7o5N5K8IP9J0hbDs16JlygEP6n42zL",
9
+ "manifest.data.js": "sha384-pgX6RJRWP7jmWO4ALb+GbS7Gm5JGOrCtxjEOnEcj1aJ8HoGbFjOniyjsntf8IA+B",
10
10
  "manifest.dropdowns.js": "sha384-WMrFoSpKfJuo81dyrwhVrDO8rq+rDwh2x8x4nH01BY5ZHkvjE+/SaT2gWCI0zOn+",
11
11
  "manifest.export.js": "sha384-qvdGz1TiGEDOeWJ5os1z03RURdKX+ezZEQ1KyV+9iC7X0esLK83mtY87t4MQv45t",
12
12
  "manifest.icons.js": "sha384-uOkboYrovjCpl22eey3Jaxpey+pOnot5NDnRRumcRxiR7IOVaRh1i20gYnWXR5dW",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.108",
3
+ "version": "0.5.109",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",