Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@scalar/oas-utils

Package Overview
Dependencies
Maintainers
0
Versions
100
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.3 to 0.2.4

dist/entities/workspace/security/index.d.ts

6

CHANGELOG.md
# @scalar/oas-utils
## 0.2.4
### Patch Changes
- c20c7d0: feat: security schemes and requirements
## 0.2.3

@@ -4,0 +10,0 @@

68

dist/entities/workspace/collection/collection.d.ts

@@ -17,4 +17,4 @@ import { z } from 'zod';

}, {
description?: string | undefined;
url?: string | undefined;
description?: string | undefined;
}>;

@@ -26,2 +26,10 @@ export type ExternalDocumentation = z.infer<typeof exteralDocumentationSchema>;

openapi: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodLiteral<"3.1.0">, z.ZodLiteral<"4.0.0">]>>>;
/**
* A declaration of which security mechanisms can be used across the API. The list of
* values includes alternative security requirement objects that can be used. Only
* one of the security requirement objects need to be satisfied to authorize a request.
* Individual operations can override this definition. To make security optional, an empty
* security requirement ({}) can be included in the array.
*/
security: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>>, "many">>>;
/** OAS info */

@@ -82,4 +90,4 @@ info: z.ZodOptional<z.ZodObject<{

version: string;
description?: string | undefined;
summary?: string | undefined;
description?: string | undefined;
termsOfService?: string | undefined;

@@ -97,5 +105,5 @@ contact?: {

}, {
description?: string | undefined;
title?: string | undefined;
summary?: string | undefined;
description?: string | undefined;
termsOfService?: string | undefined;

@@ -132,4 +140,4 @@ contact?: {

}, {
description?: string | undefined;
url?: string | undefined;
description?: string | undefined;
}>>;

@@ -144,7 +152,7 @@ }, "strip", z.ZodTypeAny, {

}, {
description?: string | undefined;
name?: string | undefined;
description?: string | undefined;
externalDocs?: {
description?: string | undefined;
url?: string | undefined;
description?: string | undefined;
} | undefined;

@@ -161,7 +169,8 @@ }>, "many">>;

}, {
description?: string | undefined;
url?: string | undefined;
description?: string | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
openapi: string;
security: Record<string, string[]>[];
serverUids: string[];

@@ -183,4 +192,4 @@ tags: {

version: string;
description?: string | undefined;
summary?: string | undefined;
description?: string | undefined;
termsOfService?: string | undefined;

@@ -200,10 +209,11 @@ contact?: {

externalDocs?: {
description?: string | undefined;
url?: string | undefined;
description?: string | undefined;
} | undefined;
openapi?: string | undefined;
security?: Record<string, string[] | undefined>[] | undefined;
info?: {
description?: string | undefined;
title?: string | undefined;
summary?: string | undefined;
description?: string | undefined;
termsOfService?: string | undefined;

@@ -224,10 +234,24 @@ contact?: {

tags?: {
description?: string | undefined;
name?: string | undefined;
description?: string | undefined;
externalDocs?: {
description?: string | undefined;
url?: string | undefined;
description?: string | undefined;
} | undefined;
}[] | undefined;
}>>>;
/**
* The currently selected security scheme key
* TODO eventually we will need to maintain one per request + collection but this will do for now
*/
selectedSecuritySchemes: z.ZodDefault<z.ZodArray<z.ZodObject<{
uid: z.ZodString;
flowKey: z.ZodOptional<z.ZodEnum<["implicit", "clientCredentials", "password", "authorizationCode"]>>;
}, "strip", z.ZodTypeAny, {
uid: string;
flowKey?: "implicit" | "password" | "clientCredentials" | "authorizationCode" | undefined;
}, {
uid: string;
flowKey?: "implicit" | "password" | "clientCredentials" | "authorizationCode" | undefined;
}>, "many">>;
/** The currently selected server */

@@ -241,2 +265,3 @@ selectedServerUid: z.ZodDefault<z.ZodString>;

openapi: string;
security: Record<string, string[]>[];
serverUids: string[];

@@ -258,4 +283,4 @@ tags: {

version: string;
description?: string | undefined;
summary?: string | undefined;
description?: string | undefined;
termsOfService?: string | undefined;

@@ -274,2 +299,6 @@ contact?: {

};
selectedSecuritySchemes: {
uid: string;
flowKey?: "implicit" | "password" | "clientCredentials" | "authorizationCode" | undefined;
}[];
selectedServerUid: string;

@@ -281,10 +310,11 @@ childUids: string[];

externalDocs?: {
description?: string | undefined;
url?: string | undefined;
description?: string | undefined;
} | undefined;
openapi?: string | undefined;
security?: Record<string, string[] | undefined>[] | undefined;
info?: {
description?: string | undefined;
title?: string | undefined;
summary?: string | undefined;
description?: string | undefined;
termsOfService?: string | undefined;

@@ -305,10 +335,14 @@ contact?: {

tags?: {
description?: string | undefined;
name?: string | undefined;
description?: string | undefined;
externalDocs?: {
description?: string | undefined;
url?: string | undefined;
description?: string | undefined;
} | undefined;
}[] | undefined;
} | undefined;
selectedSecuritySchemes?: {
uid: string;
flowKey?: "implicit" | "password" | "clientCredentials" | "authorizationCode" | undefined;
}[] | undefined;
selectedServerUid?: string | undefined;

@@ -315,0 +349,0 @@ childUids?: string[] | undefined;

import { z } from 'zod';
import { securityRequirement } from '../security/security-requirement.js';
import { nanoidSchema } from '../shared/utility.js';

@@ -93,2 +94,10 @@ import { deepMerge } from '../../../helpers/deepMerge.js';

.default('3.1.0'),
/**
* A declaration of which security mechanisms can be used across the API. The list of
* values includes alternative security requirement objects that can be used. Only
* one of the security requirement objects need to be satisfied to authorize a request.
* Individual operations can override this definition. To make security optional, an empty
* security requirement ({}) can be included in the array.
*/
security: z.array(securityRequirement).optional().default([]),
/** OAS info */

@@ -105,2 +114,20 @@ info: infoSchema.optional(),

spec: specSchema.optional().default({}),
/**
* The currently selected security scheme key
* TODO eventually we will need to maintain one per request + collection but this will do for now
*/
selectedSecuritySchemes: z
.array(z.object({
uid: z.string(),
// Wasn't sure how to extract the keys from another schema so hard coded these for now
flowKey: z
.enum([
'implicit',
'clientCredentials',
'password',
'authorizationCode',
])
.optional(),
}))
.default([]),
/** The currently selected server */

@@ -107,0 +134,0 @@ selectedServerUid: z.string().default(''),

@@ -39,4 +39,4 @@ import { z } from 'zod';

value: string;
uid: string;
name: string;
uid: string;
sameSite: "Lax" | "Strict" | "None";

@@ -73,4 +73,4 @@ path?: string | undefined;

value: string;
uid: string;
name: string;
uid: string;
sameSite: "Lax" | "Strict" | "None";

@@ -77,0 +77,0 @@ path?: string | undefined;

@@ -19,4 +19,4 @@ import { z } from 'zod';

}, "strip", z.ZodTypeAny, {
uid: string;
name: string;
uid: string;
color: string;

@@ -30,4 +30,4 @@ raw: string;

}, {
uid?: string | undefined;
name?: string | undefined;
uid?: string | undefined;
color?: string | undefined;

@@ -46,4 +46,4 @@ raw?: string | undefined;

export declare const createEnvironment: (payload: EnvironmentPayload) => {
uid: string;
name: string;
uid: string;
color: string;

@@ -50,0 +50,0 @@ raw: string;

@@ -15,10 +15,10 @@ import { z } from 'zod';

}, "strip", z.ZodTypeAny, {
uid: string;
name: string;
uid: string;
childUids: string[];
description?: string | undefined;
}, {
uid?: string | undefined;
description?: string | undefined;
name?: string | undefined;
description?: string | undefined;
uid?: string | undefined;
childUids?: string[] | undefined;

@@ -31,4 +31,4 @@ }>;

export declare const createFolder: (payload: FolderPayload) => {
uid: string;
name: string;
uid: string;
childUids: string[];

@@ -35,0 +35,0 @@ description?: string | undefined;

@@ -38,9 +38,9 @@ import { z } from 'zod';

default?: string | undefined;
uid?: string | undefined;
description?: string | undefined;
uid?: string | undefined;
enum?: string[] | undefined;
}>>>>;
}, "strip", z.ZodTypeAny, {
uid: string;
url: string;
uid: string;
description?: string | undefined;

@@ -54,9 +54,9 @@ variables?: Record<string, {

}, {
uid?: string | undefined;
description?: string | undefined;
url?: string | undefined;
description?: string | undefined;
uid?: string | undefined;
variables?: Record<string, {
default?: string | undefined;
uid?: string | undefined;
description?: string | undefined;
uid?: string | undefined;
enum?: string[] | undefined;

@@ -75,4 +75,4 @@ }> | null | undefined;

export declare const createServer: (payload: ServerPayload) => {
uid: string;
url: string;
uid: string;
description?: string | undefined;

@@ -79,0 +79,0 @@ variables?: Record<string, {

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

}[];
cookies: {
query: {
value: string;

@@ -248,3 +248,3 @@ key: string;

}[];
headers: {
cookies: {
value: string;

@@ -257,3 +257,3 @@ key: string;

}[];
query: {
headers: {
value: string;

@@ -275,3 +275,3 @@ key: string;

}[] | undefined;
cookies?: {
query?: {
value?: string | number | undefined;

@@ -284,3 +284,3 @@ description?: string | undefined;

}[] | undefined;
headers?: {
cookies?: {
value?: string | number | undefined;

@@ -293,3 +293,3 @@ description?: string | undefined;

}[] | undefined;
query?: {
headers?: {
value?: string | number | undefined;

@@ -305,4 +305,4 @@ description?: string | undefined;

}, "strip", z.ZodTypeAny, {
uid: string;
name: string;
uid: string;
parameters: {

@@ -317,3 +317,3 @@ path: {

}[];
cookies: {
query: {
value: string;

@@ -326,3 +326,3 @@ key: string;

}[];
headers: {
cookies: {
value: string;

@@ -335,3 +335,3 @@ key: string;

}[];
query: {
headers: {
value: string;

@@ -368,4 +368,4 @@ key: string;

requestUid: string;
uid?: string | undefined;
name?: string | undefined;
uid?: string | undefined;
parameters?: {

@@ -380,3 +380,3 @@ path?: {

}[] | undefined;
cookies?: {
query?: {
value?: string | number | undefined;

@@ -389,3 +389,3 @@ description?: string | undefined;

}[] | undefined;
headers?: {
cookies?: {
value?: string | number | undefined;

@@ -398,3 +398,3 @@ description?: string | undefined;

}[] | undefined;
query?: {
headers?: {
value?: string | number | undefined;

@@ -434,4 +434,4 @@ description?: string | undefined;

export declare const createRequestExample: (payload: RequestExamplePayload) => {
uid: string;
name: string;
uid: string;
parameters: {

@@ -446,3 +446,3 @@ path: {

}[];
cookies: {
query: {
value: string;

@@ -455,3 +455,3 @@ key: string;

}[];
headers: {
cookies: {
value: string;

@@ -464,3 +464,3 @@ key: string;

}[];
query: {
headers: {
value: string;

@@ -467,0 +467,0 @@ key: string;

@@ -24,2 +24,3 @@ import type { AxiosResponse } from 'axios';

collectionRef: z.ZodOptional<z.ZodString>;
/** A single request/response set to save to the history stack */
isExternal: z.ZodBoolean;

@@ -55,12 +56,20 @@ }, "strip", z.ZodTypeAny, {

path: Record<string, any>;
query: Record<string, any>;
cookies: Record<string, any>;
headers: Record<string, any>;
query: Record<string, any>;
}, {
path: Record<string, any>;
query: Record<string, any>;
cookies: Record<string, any>;
headers: Record<string, any>;
query: Record<string, any>;
}>>;
/**
* A declaration of which security mechanisms can be used across the API. The list of
* values includes alternative security requirement objects that can be used. Only
* one of the security requirement objects need to be satisfied to authorize a request.
* Individual operations can override this definition. To make security optional, an empty
* security requirement ({}) can be included in the array.
*/
security: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>>, "many">>;
/**
* The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the

@@ -77,4 +86,4 @@ * HTTP 1.1 specification [RFC7231] has explicitly defined semantics for request bodies. In other cases where the

path: string;
uid: string;
tags: string[];
uid: string;
childUids: string[];

@@ -84,5 +93,5 @@ method: "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "TRACE" | "CONNECT" | "DELETE" | "OPTIONS";

path: Record<string, any>;
query: Record<string, any>;
cookies: Record<string, any>;
headers: Record<string, any>;
query: Record<string, any>;
};

@@ -95,4 +104,5 @@ ref: {

history: any[];
description?: string | undefined;
summary?: string | undefined;
description?: string | undefined;
security?: Record<string, string[]>[] | undefined;
operationId?: string | undefined;

@@ -102,6 +112,7 @@ requestBody?: any;

path?: string | undefined;
uid?: string | undefined;
description?: string | undefined;
summary?: string | undefined;
description?: string | undefined;
security?: Record<string, string[] | undefined>[] | undefined;
tags?: string[] | undefined;
uid?: string | undefined;
childUids?: (string | undefined)[] | undefined;

@@ -111,5 +122,5 @@ method?: "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "TRACE" | "CONNECT" | "DELETE" | "OPTIONS" | undefined;

path: Record<string, any>;
query: Record<string, any>;
cookies: Record<string, any>;
headers: Record<string, any>;
query: Record<string, any>;
} | undefined;

@@ -139,4 +150,4 @@ ref?: {

path: string;
uid: string;
tags: string[];
uid: string;
childUids: string[];

@@ -146,5 +157,5 @@ method: "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "TRACE" | "CONNECT" | "DELETE" | "OPTIONS";

path: Record<string, any>;
query: Record<string, any>;
cookies: Record<string, any>;
headers: Record<string, any>;
query: Record<string, any>;
};

@@ -157,4 +168,5 @@ ref: {

history: any[];
description?: string | undefined;
summary?: string | undefined;
description?: string | undefined;
security?: Record<string, string[]>[] | undefined;
operationId?: string | undefined;

@@ -161,0 +173,0 @@ requestBody?: any;

@@ -5,2 +5,3 @@ import { z } from 'zod';

import { nanoidSchema } from '../shared/utility.js';
import { securityRequirement } from '../security/security-requirement.js';
import { deepMerge } from '../../../helpers/deepMerge.js';

@@ -40,2 +41,10 @@

/**
* A declaration of which security mechanisms can be used across the API. The list of
* values includes alternative security requirement objects that can be used. Only
* one of the security requirement objects need to be satisfied to authorize a request.
* Individual operations can override this definition. To make security optional, an empty
* security requirement ({}) can be included in the array.
*/
security: z.array(securityRequirement).optional(),
/**
* The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the

@@ -42,0 +51,0 @@ * HTTP 1.1 specification [RFC7231] has explicitly defined semantics for request bodies. In other cases where the

@@ -16,5 +16,5 @@ import { z } from 'zod';

}, "strip", z.ZodTypeAny, {
uid: string;
description: string;
name: string;
description: string;
uid: string;
isReadOnly: boolean;

@@ -25,5 +25,5 @@ collectionUids: string[];

}, {
uid?: string | undefined;
description?: string | undefined;
name?: string | undefined;
description?: string | undefined;
uid?: string | undefined;
isReadOnly?: boolean | undefined;

@@ -38,5 +38,5 @@ collectionUids?: string[] | undefined;

export declare const createWorkspace: (payload: WorkspacePayload) => {
uid: string;
description: string;
name: string;
description: string;
uid: string;
isReadOnly: boolean;

@@ -43,0 +43,0 @@ collectionUids: string[];

@@ -9,3 +9,3 @@ export * from './createHash.js';

export * from './normalizeMimeTypeObject.js';
export * from './objectMerge.js';
export * from './object.js';
export * from './parse.js';

@@ -15,2 +15,3 @@ export * from './prettyPrintJson.js';

export * from './ssrState.js';
export * from './string.js';
//# sourceMappingURL=index.d.ts.map

@@ -9,3 +9,3 @@ export { createHash } from './createHash.js';

export { normalizeMimeTypeObject } from './normalizeMimeTypeObject.js';
export { objectMerge } from './objectMerge.js';
export { getObjectKeys, objectMerge } from './object.js';
export { formatJsonOrYamlString, isJsonString, json, parseJsonOrYaml, transformToJson, yaml } from './parse.js';

@@ -15,1 +15,2 @@ export { prettyPrintJson, replaceCircularDependencies } from './prettyPrintJson.js';

export { defaultStateFactory, ssrState } from './ssrState.js';
export { camelToTitleWords } from './string.js';

@@ -10,4 +10,4 @@ import { type Request } from '../entities/workspace/spec/index.js';

folders: {
uid: string;
name: string;
uid: string;
childUids: string[];

@@ -17,4 +17,4 @@ description?: string | undefined;

servers: {
uid: string;
url: string;
uid: string;
description?: string | undefined;

@@ -33,2 +33,3 @@ variables?: Record<string, {

openapi: string;
security: Record<string, string[]>[];
serverUids: string[];

@@ -50,4 +51,4 @@ tags: {

version: string;
description?: string | undefined;
summary?: string | undefined;
description?: string | undefined;
termsOfService?: string | undefined;

@@ -66,2 +67,6 @@ contact?: {

};
selectedSecuritySchemes: {
uid: string;
flowKey?: "implicit" | "password" | "clientCredentials" | "authorizationCode" | undefined;
}[];
selectedServerUid: string;

@@ -68,0 +73,0 @@ childUids: string[];

@@ -73,2 +73,3 @@ import { tagObjectSchema } from '../entities/workspace/spec/spec.js';

operationId: operation.operationId,
security: operation.security,
summary: operation.summary,

@@ -114,2 +115,12 @@ externalDocs: operation.externalDocs,

const servers = unparsedServers.map((server) => createServer(server));
// Select initial security
const firstSecurityKey = Object.keys(parsedSpec.components?.securitySchemes ?? {})?.[0];
const firstScheme = parsedSpec.components?.securitySchemes?.[firstSecurityKey ?? ''];
// In the case of oauth2 we need to select the flow as well
const flowKey = firstScheme?.type === 'oauth2'
? Object.keys(firstScheme.flows ?? {})[0]
: undefined;
const selectedSecuritySchemes = firstSecurityKey
? [{ uid: firstSecurityKey, ...(flowKey ? { flowKey } : {}) }]
: [];
const collection = createCollection({

@@ -119,2 +130,3 @@ spec: {

info: schema?.info,
security: parsedSpec.security,
externalDocs: schema?.externalDocs,

@@ -124,2 +136,3 @@ serverUids: servers.map(({ uid }) => uid),

},
selectedSecuritySchemes,
selectedServerUid: servers[0].uid,

@@ -126,0 +139,0 @@ // We default to having all the requests in the root folder

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

],
"version": "0.2.3",
"version": "0.2.4",
"engines": {

@@ -63,5 +63,5 @@ "node": ">=18"

},
"./entities/workspace/security-schemes": {
"import": "./dist/entities/workspace/security-schemes/index.js",
"types": "./dist/entities/workspace/security-schemes/index.d.ts"
"./entities/workspace/security": {
"import": "./dist/entities/workspace/security/index.js",
"types": "./dist/entities/workspace/security/index.d.ts"
},

@@ -68,0 +68,0 @@ "./entities/workspace/folder": {

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