@insforge/sdk 1.2.9 → 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/README.md +60 -14
- package/dist/client-B8ykVESe.d.mts +1121 -0
- package/dist/client-B8ykVESe.d.ts +1121 -0
- package/dist/index.d.mts +4 -1113
- package/dist/index.d.ts +4 -1113
- package/dist/index.js +28 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -9
- package/dist/index.mjs.map +1 -1
- package/dist/ssr.d.mts +93 -0
- package/dist/ssr.d.ts +93 -0
- package/dist/ssr.js +3158 -0
- package/dist/ssr.js.map +1 -0
- package/dist/ssr.mjs +3119 -0
- package/dist/ssr.mjs.map +1 -0
- package/package.json +7 -2
package/dist/index.mjs
CHANGED
|
@@ -628,7 +628,9 @@ var HttpClient = class {
|
|
|
628
628
|
try {
|
|
629
629
|
await this.refreshAndSaveSession();
|
|
630
630
|
} catch (error2) {
|
|
631
|
-
|
|
631
|
+
if (error2 instanceof InsForgeError && (error2.statusCode === 401 || error2.statusCode === 403)) {
|
|
632
|
+
this.clearAuthSession();
|
|
633
|
+
}
|
|
632
634
|
throw error2;
|
|
633
635
|
}
|
|
634
636
|
return await this.handleRequest(method, path, {
|
|
@@ -734,7 +736,9 @@ var HttpClient = class {
|
|
|
734
736
|
try {
|
|
735
737
|
newTokenData = await this.refreshAndSaveSession();
|
|
736
738
|
} catch (error) {
|
|
737
|
-
|
|
739
|
+
if (error instanceof InsForgeError && (error.statusCode === 401 || error.statusCode === 403)) {
|
|
740
|
+
this.clearAuthSession();
|
|
741
|
+
}
|
|
738
742
|
throw error;
|
|
739
743
|
}
|
|
740
744
|
const retryHeaders = new Headers(initHeaders);
|
|
@@ -882,7 +886,7 @@ function cleanUrlParams(...params) {
|
|
|
882
886
|
}
|
|
883
887
|
|
|
884
888
|
// src/modules/auth/auth.ts
|
|
885
|
-
import { oAuthProvidersSchema } from "@insforge/shared-schemas";
|
|
889
|
+
import { ERROR_CODES, oAuthProvidersSchema } from "@insforge/shared-schemas";
|
|
886
890
|
var Auth = class {
|
|
887
891
|
constructor(http, tokenManager, options = {}) {
|
|
888
892
|
this.http = http;
|
|
@@ -1127,8 +1131,11 @@ var Auth = class {
|
|
|
1127
1131
|
* Browser mode:
|
|
1128
1132
|
* - Uses httpOnly refresh cookie and optional CSRF header.
|
|
1129
1133
|
*
|
|
1130
|
-
*
|
|
1134
|
+
* Legacy server mode (`isServerMode: true`):
|
|
1131
1135
|
* - Uses mobile auth flow and requires `refreshToken` in request body.
|
|
1136
|
+
*
|
|
1137
|
+
* SSR apps should prefer `createRefreshAuthRouter()` / `refreshAuth()` from
|
|
1138
|
+
* `@insforge/sdk/ssr`.
|
|
1132
1139
|
*/
|
|
1133
1140
|
async refreshSession(options) {
|
|
1134
1141
|
try {
|
|
@@ -1138,7 +1145,7 @@ var Auth = class {
|
|
|
1138
1145
|
error: new InsForgeError(
|
|
1139
1146
|
"refreshToken is required when refreshing session in server mode",
|
|
1140
1147
|
400,
|
|
1141
|
-
|
|
1148
|
+
ERROR_CODES.AUTH_UNAUTHORIZED
|
|
1142
1149
|
)
|
|
1143
1150
|
};
|
|
1144
1151
|
}
|
|
@@ -1600,10 +1607,23 @@ var StorageBucket = class {
|
|
|
1600
1607
|
*/
|
|
1601
1608
|
async download(path) {
|
|
1602
1609
|
try {
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1610
|
+
const encodedKey = encodeURIComponent(path);
|
|
1611
|
+
let strategyResponse;
|
|
1612
|
+
try {
|
|
1613
|
+
strategyResponse = await this.http.get(
|
|
1614
|
+
`/api/storage/buckets/${this.bucketName}/download-strategy/objects/${encodedKey}`
|
|
1615
|
+
);
|
|
1616
|
+
} catch (err) {
|
|
1617
|
+
const status = err instanceof InsForgeError ? err.statusCode : void 0;
|
|
1618
|
+
if (status === 404 || status === 405) {
|
|
1619
|
+
strategyResponse = await this.http.post(
|
|
1620
|
+
`/api/storage/buckets/${this.bucketName}/objects/${encodedKey}/download-strategy`,
|
|
1621
|
+
{}
|
|
1622
|
+
);
|
|
1623
|
+
} else {
|
|
1624
|
+
throw err;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1607
1627
|
const downloadUrl = strategyResponse.url;
|
|
1608
1628
|
const headers = {};
|
|
1609
1629
|
if (strategyResponse.method === "direct") {
|