@bool-ts/core 1.4.1 → 1.4.2
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 +1 -1
- package/src/hooks/factory.ts +37 -24
package/package.json
CHANGED
package/src/hooks/factory.ts
CHANGED
|
@@ -141,32 +141,53 @@ export const BoolFactory = (target: new (...args: any[]) => unknown, options: TB
|
|
|
141
141
|
try {
|
|
142
142
|
const reqHeaders = request.headers;
|
|
143
143
|
const origin = reqHeaders.get("origin");
|
|
144
|
+
const resHeaders = new Headers({
|
|
145
|
+
"Access-Control-Allow-Origin": origin || "*",
|
|
146
|
+
"Access-Control-Allow-Headers": "*",
|
|
147
|
+
"Access-Control-Allow-Credentials": "true",
|
|
148
|
+
"Access-Control-Allow-Methods": allowMethods.join(", "),
|
|
149
|
+
"Content-Type": "application/json"
|
|
150
|
+
});
|
|
144
151
|
|
|
145
152
|
if (!allowOrigins.includes("*")) {
|
|
146
153
|
if (!origin) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
return new Response(
|
|
155
|
+
JSON.stringify({
|
|
156
|
+
httpCode: 403,
|
|
157
|
+
message: "Origin not found.",
|
|
158
|
+
data: {
|
|
159
|
+
origin: {
|
|
160
|
+
code: "origin:invalid:0x00001",
|
|
161
|
+
message: "Origin not found."
|
|
162
|
+
}
|
|
154
163
|
}
|
|
164
|
+
}),
|
|
165
|
+
{
|
|
166
|
+
status: 403,
|
|
167
|
+
statusText: "Origin not found.",
|
|
168
|
+
headers: resHeaders
|
|
155
169
|
}
|
|
156
|
-
|
|
170
|
+
);
|
|
157
171
|
}
|
|
158
172
|
|
|
159
173
|
if (!allowOrigins.includes(origin)) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
174
|
+
return new Response(
|
|
175
|
+
JSON.stringify({
|
|
176
|
+
httpCode: 403,
|
|
177
|
+
message: "Origin not found.",
|
|
178
|
+
data: {
|
|
179
|
+
origin: {
|
|
180
|
+
code: "origin:invalid:0x00002",
|
|
181
|
+
message: "Invalid origin."
|
|
182
|
+
}
|
|
167
183
|
}
|
|
184
|
+
}),
|
|
185
|
+
{
|
|
186
|
+
status: 403,
|
|
187
|
+
statusText: "Invalid origin.",
|
|
188
|
+
headers: resHeaders
|
|
168
189
|
}
|
|
169
|
-
|
|
190
|
+
);
|
|
170
191
|
}
|
|
171
192
|
}
|
|
172
193
|
|
|
@@ -274,14 +295,6 @@ export const BoolFactory = (target: new (...args: any[]) => unknown, options: TB
|
|
|
274
295
|
responseBody = responseData;
|
|
275
296
|
}
|
|
276
297
|
|
|
277
|
-
const resHeaders = new Headers({
|
|
278
|
-
"Access-Control-Allow-Origin": origin || "*",
|
|
279
|
-
"Access-Control-Allow-Headers": "*",
|
|
280
|
-
"Access-Control-Allow-Credentials": "true",
|
|
281
|
-
"Access-Control-Allow-Methods": allowMethods.join(", "),
|
|
282
|
-
"Content-Type": "application/json"
|
|
283
|
-
});
|
|
284
|
-
|
|
285
298
|
const response = new Response(
|
|
286
299
|
JSON.stringify({
|
|
287
300
|
httpCode: 200,
|