@insforge/sdk 1.2.10 → 1.3.0-ssr.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/dist/index.js CHANGED
@@ -1172,8 +1172,11 @@ var Auth = class {
1172
1172
  * Browser mode:
1173
1173
  * - Uses httpOnly refresh cookie and optional CSRF header.
1174
1174
  *
1175
- * Server mode (`isServerMode: true`):
1175
+ * Legacy server mode (`isServerMode: true`):
1176
1176
  * - Uses mobile auth flow and requires `refreshToken` in request body.
1177
+ *
1178
+ * SSR apps should prefer `createRefreshAuthRouter()` / `refreshAuth()` from
1179
+ * `@insforge/sdk/ssr`.
1177
1180
  */
1178
1181
  async refreshSession(options) {
1179
1182
  try {
@@ -1183,7 +1186,7 @@ var Auth = class {
1183
1186
  error: new InsForgeError(
1184
1187
  "refreshToken is required when refreshing session in server mode",
1185
1188
  400,
1186
- "REFRESH_TOKEN_REQUIRED"
1189
+ import_shared_schemas.ERROR_CODES.AUTH_UNAUTHORIZED
1187
1190
  )
1188
1191
  };
1189
1192
  }
@@ -1645,10 +1648,23 @@ var StorageBucket = class {
1645
1648
  */
1646
1649
  async download(path) {
1647
1650
  try {
1648
- const strategyResponse = await this.http.post(
1649
- `/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}/download-strategy`,
1650
- { expiresIn: 3600 }
1651
- );
1651
+ const encodedKey = encodeURIComponent(path);
1652
+ let strategyResponse;
1653
+ try {
1654
+ strategyResponse = await this.http.get(
1655
+ `/api/storage/buckets/${this.bucketName}/download-strategy/objects/${encodedKey}`
1656
+ );
1657
+ } catch (err) {
1658
+ const status = err instanceof InsForgeError ? err.statusCode : void 0;
1659
+ if (status === 404 || status === 405) {
1660
+ strategyResponse = await this.http.post(
1661
+ `/api/storage/buckets/${this.bucketName}/objects/${encodedKey}/download-strategy`,
1662
+ {}
1663
+ );
1664
+ } else {
1665
+ throw err;
1666
+ }
1667
+ }
1652
1668
  const downloadUrl = strategyResponse.url;
1653
1669
  const headers = {};
1654
1670
  if (strategyResponse.method === "direct") {