@medialane/sdk 0.177.0 → 0.179.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.cjs +11 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -696,6 +696,7 @@ interface AppGatewayConfig {
|
|
|
696
696
|
appId: string;
|
|
697
697
|
backendUrl: string;
|
|
698
698
|
apiKey: string | undefined;
|
|
699
|
+
appSecret?: string;
|
|
699
700
|
allow: Record<string, RegExp[]>;
|
|
700
701
|
cacheableGets?: RegExp[];
|
|
701
702
|
timeoutMs?: number;
|
|
@@ -707,6 +708,7 @@ interface AppSessionConfig {
|
|
|
707
708
|
appId: string;
|
|
708
709
|
backendUrl: string;
|
|
709
710
|
apiKey: string | undefined;
|
|
711
|
+
appSecret?: string;
|
|
710
712
|
fetchImpl?: typeof fetch;
|
|
711
713
|
}
|
|
712
714
|
declare function createAppSessionHandler(config: AppSessionConfig): {
|
package/dist/index.d.ts
CHANGED
|
@@ -696,6 +696,7 @@ interface AppGatewayConfig {
|
|
|
696
696
|
appId: string;
|
|
697
697
|
backendUrl: string;
|
|
698
698
|
apiKey: string | undefined;
|
|
699
|
+
appSecret?: string;
|
|
699
700
|
allow: Record<string, RegExp[]>;
|
|
700
701
|
cacheableGets?: RegExp[];
|
|
701
702
|
timeoutMs?: number;
|
|
@@ -707,6 +708,7 @@ interface AppSessionConfig {
|
|
|
707
708
|
appId: string;
|
|
708
709
|
backendUrl: string;
|
|
709
710
|
apiKey: string | undefined;
|
|
711
|
+
appSecret?: string;
|
|
710
712
|
fetchImpl?: typeof fetch;
|
|
711
713
|
}
|
|
712
714
|
declare function createAppSessionHandler(config: AppSessionConfig): {
|
package/dist/index.js
CHANGED
|
@@ -130,6 +130,7 @@ var DROPPED_REQUEST_HEADERS = /* @__PURE__ */ new Set([
|
|
|
130
130
|
"cookie",
|
|
131
131
|
"x-api-key",
|
|
132
132
|
"x-app-id",
|
|
133
|
+
"x-app-secret",
|
|
133
134
|
"x-account-session",
|
|
134
135
|
"authorization"
|
|
135
136
|
]);
|
|
@@ -175,6 +176,7 @@ function createAppGateway(config) {
|
|
|
175
176
|
});
|
|
176
177
|
headers2.set("x-api-key", config.apiKey);
|
|
177
178
|
headers2.set("x-app-id", config.appId);
|
|
179
|
+
if (config.appSecret) headers2.set("x-app-secret", config.appSecret);
|
|
178
180
|
const session = readCookie(req, ACCOUNT_SESSION_COOKIE);
|
|
179
181
|
if (session) headers2.set("x-account-session", session);
|
|
180
182
|
const search = new URL(req.url).search;
|
|
@@ -208,12 +210,12 @@ function createAppGateway(config) {
|
|
|
208
210
|
} catch {
|
|
209
211
|
body = null;
|
|
210
212
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
+
const token = typeof body?.accountToken === "string" ? body.accountToken : null;
|
|
214
|
+
if (!body || !token) return new Response(text, { status: res.status, headers: out });
|
|
213
215
|
delete body.accountToken;
|
|
214
216
|
delete body.token;
|
|
215
217
|
out.set("content-type", "application/json");
|
|
216
|
-
|
|
218
|
+
out.append("set-cookie", sessionCookie(token));
|
|
217
219
|
return new Response(JSON.stringify(body), { status: res.status, headers: out });
|
|
218
220
|
}
|
|
219
221
|
if (method === "GET" && res.ok && !session && (config.cacheableGets ?? []).some((re) => re.test(joined))) {
|
|
@@ -237,7 +239,12 @@ function createAppSessionHandler(config) {
|
|
|
237
239
|
const session = readCookie(req, ACCOUNT_SESSION_COOKIE);
|
|
238
240
|
if (!session) return Response.json(null);
|
|
239
241
|
const res = await doFetch(`${base}/v1/users/me`, {
|
|
240
|
-
headers: {
|
|
242
|
+
headers: {
|
|
243
|
+
"x-api-key": config.apiKey ?? "",
|
|
244
|
+
"x-app-id": config.appId,
|
|
245
|
+
...config.appSecret ? { "x-app-secret": config.appSecret } : {},
|
|
246
|
+
"x-account-session": session
|
|
247
|
+
},
|
|
241
248
|
cache: "no-store"
|
|
242
249
|
});
|
|
243
250
|
if (res.status === 401 || res.status === 403) return signedOut();
|