New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@scalar/oas-utils

Package Overview
Dependencies
Maintainers
8
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scalar/oas-utils - npm Package Compare versions

Comparing version 0.2.65 to 0.2.66

9

CHANGELOG.md
# @scalar/oas-utils
## 0.2.66
### Patch Changes
- c929284: fix: add default redirectURI and prefix relative redirectURIs with activeServer
- 2275977: feat: import from way more sources, leverage the proxy more
- 3a0c367: fix: improve handling of non-string enums in parameter schema
- 89a2cc7: fix: preselect auth in the modal
## 0.2.65

@@ -4,0 +13,0 @@

5

dist/entities/spec/request-examples.js

@@ -92,3 +92,6 @@ import { z } from 'zod';

'');
const parseEnum = schema?.type === 'number' ? schema?.enum?.map(String) : schema?.enum;
// Handle non-string enums
const parseEnum = schema?.enum && schema?.type !== 'string'
? schema.enum?.map(String)
: schema?.enum;
// safe parse the example

@@ -95,0 +98,0 @@ const example = schemaModel({

14

dist/entities/spec/security.js

@@ -172,2 +172,6 @@ import { schemaModel } from '../../helpers/schema-model.js';

});
/** Setup a default redirect uri if we can */
const defaultRedirectUri = typeof window !== 'undefined'
? window.location.origin + window.location.pathname
: '';
const oasOauthFlowSchema = z

@@ -179,3 +183,6 @@ .discriminatedUnion('type', [

authorizationUrl,
'x-scalar-redirect-uri': z.string().optional().default(''),
'x-scalar-redirect-uri': z
.string()
.optional()
.default(defaultRedirectUri),
}),

@@ -196,3 +203,6 @@ /** Configuration for the OAuth Resource Owner Password flow */

authorizationUrl,
'x-scalar-redirect-uri': z.string().optional().default(''),
'x-scalar-redirect-uri': z
.string()
.optional()
.default(defaultRedirectUri),
tokenUrl,

@@ -199,0 +209,0 @@ }),

@@ -0,1 +1,8 @@

export type FetchWithProxyFallbackOptions = {
proxy?: string;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/API/Request/cache
*/
cache?: RequestInit['cache'];
};
/**

@@ -6,6 +13,4 @@ * Fetches an OpenAPI document with a proxy fallback mechanism.

* If the proxy fetch fails or is not used, it will fall back to a direct fetch.
*
* Also handles cases where the input is a JSON object instead of a URL.
*/
export declare function fetchWithProxyFallback(value: string, proxy?: string): Promise<Response>;
export declare function fetchWithProxyFallback(url: string, { proxy, cache }: FetchWithProxyFallbackOptions): Promise<Response>;
//# sourceMappingURL=fetchWithProxyFallback.d.ts.map

@@ -1,2 +0,1 @@

import { resolve } from '@scalar/import';
import { shouldUseProxy, redirectToProxy } from './redirectToProxy.js';

@@ -9,24 +8,11 @@

* If the proxy fetch fails or is not used, it will fall back to a direct fetch.
*
* Also handles cases where the input is a JSON object instead of a URL.
*/
async function fetchWithProxyFallback(value, proxy) {
// Maybe it’s not an OpenAPI document URL, but we can still find the actual URL
const url = await resolve(value);
// If the value is an object, mock a fetch response with beautified JSON
if (typeof value === 'object' && value !== null) {
const json = JSON.stringify(value, null, 2);
return {
ok: true,
status: 200,
text: async () => json,
};
}
if (typeof url !== 'string') {
throw new Error(`[fetchWithProxyFallback] Can’t fetch URL: ${url}`);
}
async function fetchWithProxyFallback(url, { proxy, cache }) {
const fetchOptions = {
cache: cache || 'default',
};
const shouldTryProxy = shouldUseProxy(proxy, url);
const initialUrl = shouldTryProxy ? redirectToProxy(proxy, url) : url;
try {
const result = await fetch(initialUrl, { cache: 'no-cache' });
const result = await fetch(initialUrl, fetchOptions);
if (result.ok || !shouldTryProxy) {

@@ -36,3 +22,3 @@ return result;

// Retry without proxy if the initial request failed
return await fetch(url, { cache: 'no-cache' });
return await fetch(url, fetchOptions);
}

@@ -42,3 +28,3 @@ catch (error) {

// If proxy failed, try without it
return await fetch(url, { cache: 'no-cache' });
return await fetch(url, fetchOptions);
}

@@ -45,0 +31,0 @@ throw error;

@@ -271,6 +271,8 @@ import { securitySchemeSchema, authExampleFromSchema } from '../entities/spec/security.js';

}, {});
/** Selected security scheme UIDs for the collection */
const securityKeys = Object.keys(security);
let selectedSecuritySchemeUids = [];
if (setCollectionSecurity && authentication?.preferredSecurityScheme) {
const uid = securitySchemeMap[authentication.preferredSecurityScheme];
/** Selected security scheme UIDs for the collection, defaults to the first key */
if (setCollectionSecurity && securityKeys.length) {
const preferred = authentication?.preferredSecurityScheme || securityKeys[0];
const uid = securitySchemeMap[preferred];
selectedSecuritySchemeUids = [uid];

@@ -277,0 +279,0 @@ }

@@ -19,3 +19,3 @@ {

],
"version": "0.2.65",
"version": "0.2.66",
"engines": {

@@ -110,7 +110,6 @@ "node": ">=18"

"zod": "^3.23.8",
"@scalar/import": "0.0.3",
"@scalar/openapi-types": "0.1.4",
"@scalar/object-utils": "1.1.11",
"@scalar/types": "0.0.18",
"@scalar/themes": "0.9.45"
"@scalar/themes": "0.9.45",
"@scalar/types": "0.0.18"
},

@@ -117,0 +116,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc