quidproquo-webserver 0.0.86 → 0.0.88
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.
|
@@ -8,5 +8,6 @@ export interface ApiQPQWebServerConfigSetting extends QPQConfigSetting {
|
|
|
8
8
|
onRootDomain: boolean;
|
|
9
9
|
apiName: string;
|
|
10
10
|
buildPath: string;
|
|
11
|
+
deprecated: boolean;
|
|
11
12
|
}
|
|
12
13
|
export declare const defineApi: (apiSubdomain: string, buildPath: string, options?: QPQConfigAdvancedApiSettings) => ApiQPQWebServerConfigSetting;
|
|
@@ -11,6 +11,7 @@ const defineApi = (apiSubdomain, buildPath, options) => {
|
|
|
11
11
|
// advanced
|
|
12
12
|
onRootDomain: (options === null || options === void 0 ? void 0 : options.onRootDomain) || false,
|
|
13
13
|
apiName: (options === null || options === void 0 ? void 0 : options.apiName) || 'api',
|
|
14
|
+
deprecated: (options === null || options === void 0 ? void 0 : options.deprecated) || false,
|
|
14
15
|
};
|
|
15
16
|
};
|
|
16
17
|
exports.defineApi = defineApi;
|
package/lib/utils/headerUtils.js
CHANGED
|
@@ -26,12 +26,16 @@ exports.getAllowedOrigins = getAllowedOrigins;
|
|
|
26
26
|
const getCorsHeaders = (qpqConfig, route, reqHeaders) => {
|
|
27
27
|
const origin = (0, exports.getHeaderValue)('origin', reqHeaders) || '';
|
|
28
28
|
const allowedOrigins = (0, exports.getAllowedOrigins)(qpqConfig, route);
|
|
29
|
-
const
|
|
29
|
+
const allowCredentials = Object.keys(route.routeAuthSettings || {}).length > 0;
|
|
30
|
+
// If we have an auth endpoint, then we don't let wildcard origins access the API for security reasons
|
|
31
|
+
const allowOrigin = (!allowCredentials
|
|
32
|
+
? allowedOrigins.find((ao) => origin === ao || ao === '*')
|
|
33
|
+
: allowedOrigins.find((ao) => origin === ao)) || allowedOrigins[0];
|
|
30
34
|
return {
|
|
31
35
|
'Access-Control-Allow-Headers': '*',
|
|
32
36
|
'Access-Control-Allow-Methods': '*',
|
|
33
37
|
'Access-Control-Allow-Origin': allowOrigin,
|
|
34
|
-
'Access-Control-Allow-Credentials': `${
|
|
38
|
+
'Access-Control-Allow-Credentials': `${allowCredentials}`,
|
|
35
39
|
Vary: 'Origin',
|
|
36
40
|
};
|
|
37
41
|
};
|