@scalar/mock-server 0.10.0 → 0.10.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/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-open-auth-token-urls.d.ts","sourceRoot":"","sources":["../../src/utils/get-open-auth-token-urls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA0B,MAAM,uBAAuB,CAAA;AAE5E;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAYlD;AAiBD,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"get-open-auth-token-urls.d.ts","sourceRoot":"","sources":["../../src/utils/get-open-auth-token-urls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA0B,MAAM,uBAAuB,CAAA;AAE5E;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAYlD;AAiBD,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,GAAG,MAAM,EAAE,CAoCxE"}
|
|
@@ -15,14 +15,14 @@ export function getPathFromUrl(url) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Returns
|
|
18
|
+
* Returns OAuth token and refresh URLs without the domain.
|
|
19
19
|
*/
|
|
20
20
|
// Type guard for OAuth2 security scheme
|
|
21
21
|
function isOAuth2Scheme(scheme) {
|
|
22
22
|
return scheme.type === 'oauth2';
|
|
23
23
|
}
|
|
24
|
-
// Validate
|
|
25
|
-
function
|
|
24
|
+
// Validate OAuth URL
|
|
25
|
+
function isValidOAuthUrl(url) {
|
|
26
26
|
return url.trim().length > 0;
|
|
27
27
|
}
|
|
28
28
|
export function getOpenAuthTokenUrls(schema) {
|
|
@@ -31,22 +31,26 @@ export function getOpenAuthTokenUrls(schema) {
|
|
|
31
31
|
}
|
|
32
32
|
const securitySchemes = schema.components.securitySchemes;
|
|
33
33
|
// Use Set from the start for better memory efficiency
|
|
34
|
-
const
|
|
34
|
+
const oauthUrls = new Set();
|
|
35
35
|
// Iterate through all security schemes
|
|
36
36
|
for (const scheme of Object.values(securitySchemes)) {
|
|
37
37
|
if (!isOAuth2Scheme(scheme)) {
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
40
|
const flows = scheme.flows; // Type assertion no longer needed
|
|
41
|
-
// Helper to safely add valid
|
|
42
|
-
const
|
|
43
|
-
if (url &&
|
|
44
|
-
|
|
41
|
+
// Helper to safely add valid OAuth URLs
|
|
42
|
+
const addOAuthUrl = (url) => {
|
|
43
|
+
if (url && isValidOAuthUrl(url)) {
|
|
44
|
+
oauthUrls.add(getPathFromUrl(url));
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
addOAuthUrl(flows?.password?.tokenUrl);
|
|
48
|
+
addOAuthUrl(flows?.password?.refreshUrl);
|
|
49
|
+
addOAuthUrl(flows?.clientCredentials?.tokenUrl);
|
|
50
|
+
addOAuthUrl(flows?.clientCredentials?.refreshUrl);
|
|
51
|
+
addOAuthUrl(flows?.authorizationCode?.tokenUrl);
|
|
52
|
+
addOAuthUrl(flows?.authorizationCode?.refreshUrl);
|
|
53
|
+
addOAuthUrl(flows?.implicit?.refreshUrl);
|
|
50
54
|
}
|
|
51
|
-
return Array.from(
|
|
55
|
+
return Array.from(oauthUrls);
|
|
52
56
|
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"swagger",
|
|
17
17
|
"cli"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.10.
|
|
19
|
+
"version": "0.10.2",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=22"
|
|
22
22
|
},
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@faker-js/faker": "10.4.0",
|
|
55
55
|
"hono": "^4.12.7",
|
|
56
|
-
"@scalar/
|
|
57
|
-
"@scalar/
|
|
58
|
-
"@scalar/
|
|
59
|
-
"@scalar/openapi-
|
|
60
|
-
"@scalar/openapi-
|
|
61
|
-
"@scalar/
|
|
56
|
+
"@scalar/helpers": "0.5.1",
|
|
57
|
+
"@scalar/openapi-types": "0.8.0",
|
|
58
|
+
"@scalar/workspace-store": "0.46.2",
|
|
59
|
+
"@scalar/openapi-upgrader": "0.2.6",
|
|
60
|
+
"@scalar/openapi-parser": "0.25.11",
|
|
61
|
+
"@scalar/json-magic": "0.12.7"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@types/node": "^24.1.0",
|