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

@har-sdk/core

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@har-sdk/core - npm Package Compare versions

Comparing version 1.4.1 to 1.4.2

2

dist/bundle.esm5.js

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

import{load as t,YAMLException as e}from"js-yaml";export*from"openapi-types";class r{constructor(t){this.syntaxErrorDetailsExtractor=t}load(t){this.source=t,this.error=void 0;try{return this.parse()}catch(t){throw t instanceof Error&&(this.error=t),t}}getSyntaxErrorDetails(){return this.error&&(this.isSupportedError(this.error)?this.syntaxErrorDetailsExtractor.extract(this.error,this.source):{message:this.error.message})}}class s{get lineOffsets(){if(!this._lineOffsets){let t=0;this._lineOffsets=[0,...(this.source||"").split("\n").map((e=>t+=e.length+1))]}return this._lineOffsets}extract(t,e){this.source=e,this._lineOffsets=void 0;const r=this.extractMessage(t),s=this.extractOffset(t),o=this.extractSnippet(t);return{message:r,...void 0!==s?{offset:s}:{},...void 0!==o?{snippet:o}:{}}}extractSnippet(t){}extractMessage(t){return t.message}calculateOffset(t,e){return t<=this.lineOffsets.length?this.lineOffsets[t-1]+e-1:this.source.length}}class o extends s{constructor(){super(...arguments),this.LOCATION_PATTERNS=[{pattern:/at position (\d+)$/,positionExtractor:([,t])=>+t},{pattern:/at line (\d+) column (\d+)/,positionExtractor:([,t,e])=>({lineNumber:+t,columnNumber:+e})}]}extractOffset(t){const e="lineNumber"in t&&"columnNumber"in t?t:this.extractByLocationPatterns(t.message);return"number"==typeof e?e:e&&this.calculateOffset(e.lineNumber,e.columnNumber)}extractMessage(t){return t.message.replace(/^JSON.parse: /,"").replace(/ at line \d+ column \d+ of the JSON data$/,"").replace(/ at position \d+$/,"")}extractByLocationPatterns(t){for(let e=0;e<this.LOCATION_PATTERNS.length;++e){const r=this.LOCATION_PATTERNS[e],s=t.match(r.pattern);if(s)return r.positionExtractor(s)}}}class n extends s{constructor(){super(...arguments),this.LOCATION_PATTERN=/\((\d+):(\d+)\)$/}extractMessage(t){const[e]=t.message.split("\n");return e.replace(/^YAMLException: /,"").replace(this.LOCATION_PATTERN,"").trim()}extractOffset(t){const[e]=t.message.split("\n"),r=e.match(this.LOCATION_PATTERN);return r?this.calculateOffset(+r[1],+r[2]):void 0}extractSnippet(t){return t.message.split("\n").slice(2).join("\n")}}class i extends r{constructor(){super(new o)}parse(){return JSON.parse(this.source)}isSupportedError(t){return t instanceof SyntaxError}}class a extends r{constructor(){super(new n)}parse(){return t(this.source,{json:!0})}isSupportedError(t){return t instanceof e}}class c{getLoader(t){switch(t){case"json":return new i;case"yaml":return new a}}}class l{constructor(){this.docFormats=["json","yaml"],this.loaderFactory=new c,this.loaders=new Map}async import(t,e){const r=this.load(t.trim(),e);if(r&&this.isSupported(r.doc)){const{format:t,doc:e}=r;return{doc:e,name:this.fileName({format:t,doc:e}),format:t,type:this.type}}}getErrorDetails(t){var e;return null===(e=this.getLoader(t))||void 0===e?void 0:e.getSyntaxErrorDetails()}fileName(t){}load(t,e){return this.initLoaders(),this.docFormats.reduce(((r,s)=>{if(r||e&&e!==s)return r;try{const e=this.getLoader(s).load(t);if(e)return{doc:e,format:s}}catch(t){}}),void 0)}initLoaders(){this.loaders.clear(),this.docFormats.forEach((t=>this.loaders.set(t,this.loaderFactory.getLoader(t))))}getLoader(t){return this.loaders.get(t)}}class u extends l{constructor(){super(),this.SUPPORTED_HAR_VERSION=/^1\.\d+$/}get type(){return"har"}isSupported(t){var e;const r=null===(e=null==t?void 0:t.log)||void 0===e?void 0:e.version;return!("string"!=typeof r||!this.SUPPORTED_HAR_VERSION.test(r.trim())||!Array.isArray(t.log.entries))}}class p extends l{constructor(){super()}fileName({doc:t,format:e}){var r;if("string"==typeof(null===(r=null==t?void 0:t.info)||void 0===r?void 0:r.title)&&"string"==typeof t.info.version)return`${[t.info.title,t.info.version].map((t=>t.trim())).join(" ")}.${e}`}}class h extends p{constructor(){super(),this.SUPPORTED_SWAGGER_VERSION="2.0"}get type(){return"oasv2"}isSupported(t){const e=null==t?void 0:t.swagger;return"string"==typeof e&&e.trim()===this.SUPPORTED_SWAGGER_VERSION}}class d extends p{constructor(){super(),this.SUPPORTED_OPENAPI_VERSION=/^3\.0\.\d+$/}get type(){return"oasv3"}isSupported(t){const e=null==t?void 0:t.openapi;return"string"==typeof e&&this.SUPPORTED_OPENAPI_VERSION.test(e.trim())}}class m extends l{constructor(){super(),this.POSTMAN_SCHEMAS=new Set(["https://schema.getpostman.com/json/collection/v2.0.0/collection.json","https://schema.getpostman.com/json/collection/v2.1.0/collection.json"])}get type(){return"postman"}isSupported(t){var e;const r=null===(e=null==t?void 0:t.info)||void 0===e?void 0:e.schema;return"string"==typeof r&&this.POSTMAN_SCHEMAS.has(r.trim().toLowerCase())}fileName({doc:t,format:e}){var r;return"string"==typeof(null===(r=null==t?void 0:t.info)||void 0===r?void 0:r.name)?`${t.info.name.trim()}.${e}`:void 0}}const f=void 0!==global.window?global.window.URL:require("url").URL,g=t=>t.replace(/\/$/,""),O=t=>t.replace(/^\//,""),E=t=>{const e=new f(t);if(!S(e))throw new TypeError(`Invalid URL: ${e}`);return e},S=t=>{let e;try{e="string"==typeof t?E(t):t}catch{}return!!(e&&e.hostname&&e.origin&&"null"!==e.origin)},v=t=>{const e=E((t=>(!/^\/{2}/.test(t)&&/^\.+\//.test(t)||(t=t.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,"https://")),t))(t));try{e.pathname=(r=e.pathname,decodeURI(g(r.replace(/((?!:).|^)\/{2,}/g,((t,e)=>/^(?!\/)/g.test(e)?`${e}/`:"/")))))}catch{}var r;e.searchParams.sort(),e.hostname=e.hostname.replace(/\.$/,"");let s=e.toString();return"/"===e.pathname&&""===e.hash&&(s=g(s)),s};class y{constructor(t=[new u,new d,new m,new h]){this.importers=t}async import(t,e){let r;try{const s=this.importers.map((r=>r.import(t,e)));r=await((t,e)=>{const r=t.map((t=>new Promise(((r,s)=>t.then((t=>!!e(t)&&r(t)),s)))));return r.push(Promise.all(t).then((()=>{}))),Promise.race(r)})(s,(t=>!!t))}catch{}return r}}export{u as HARImporter,h as OASV2Importer,d as OASV3Importer,m as PostmanImporter,y as SpecImporter,v as normalizeUrl,E as parseUrl,O as removeLeadingSlash,g as removeTrailingSlash,S as validateUrl};
import{load as t,YAMLException as e}from"js-yaml";export*from"openapi-types";class r{constructor(t){this.syntaxErrorDetailsExtractor=t}load(t){this.source=t,this.error=void 0;try{return this.parse()}catch(t){throw t instanceof Error&&(this.error=t),t}}getSyntaxErrorDetails(){return this.error&&(this.isSupportedError(this.error)?this.syntaxErrorDetailsExtractor.extract(this.error,this.source):{message:this.error.message})}}class s{get lineOffsets(){if(!this._lineOffsets){let t=0;this._lineOffsets=[0,...(this.source||"").split("\n").map((e=>t+=e.length+1))]}return this._lineOffsets}extract(t,e){this.source=e,this._lineOffsets=void 0;const r=this.extractMessage(t),s=this.extractOffset(t),o=this.extractSnippet(t);return{message:r,...void 0!==s?{offset:s}:{},...void 0!==o?{snippet:o}:{}}}extractSnippet(t){}extractMessage(t){return t.message}calculateOffset(t,e){return t<=this.lineOffsets.length?this.lineOffsets[t-1]+e-1:this.source.length}}class o extends s{constructor(){super(...arguments),this.LOCATION_PATTERNS=[{pattern:/at position (\d+)$/,positionExtractor:([,t])=>+t},{pattern:/at line (\d+) column (\d+)/,positionExtractor:([,t,e])=>({lineNumber:+t,columnNumber:+e})}]}extractOffset(t){const e="lineNumber"in t&&"columnNumber"in t?t:this.extractByLocationPatterns(t.message);return"number"==typeof e?e:e&&this.calculateOffset(e.lineNumber,e.columnNumber)}extractMessage(t){return t.message.replace(/^JSON.parse: /,"").replace(/ at line \d+ column \d+ of the JSON data$/,"").replace(/ at position \d+$/,"")}extractByLocationPatterns(t){for(let e=0;e<this.LOCATION_PATTERNS.length;++e){const r=this.LOCATION_PATTERNS[e],s=t.match(r.pattern);if(s)return r.positionExtractor(s)}}}class n extends s{constructor(){super(...arguments),this.LOCATION_PATTERN=/\((\d+):(\d+)\)$/}extractMessage(t){const[e]=t.message.split("\n");return e.replace(/^YAMLException: /,"").replace(this.LOCATION_PATTERN,"").trim()}extractOffset(t){const[e]=t.message.split("\n"),r=e.match(this.LOCATION_PATTERN);return r?this.calculateOffset(+r[1],+r[2]):void 0}extractSnippet(t){return t.message.split("\n").slice(2).join("\n")}}class i extends r{constructor(){super(new o)}parse(){return JSON.parse(this.source)}isSupportedError(t){return t instanceof SyntaxError}}class a extends r{constructor(){super(new n)}parse(){return t(this.source,{json:!0})}isSupportedError(t){return t instanceof e}}class c{getLoader(t){switch(t){case"json":return new i;case"yaml":return new a}}}class l{constructor(){this.docFormats=["json","yaml"],this.loaderFactory=new c,this.loaders=new Map}async import(t,e){const r=this.load(t.trim(),e);if(r&&this.isSupported(r.doc)){const{format:t,doc:e}=r;return{doc:e,name:this.fileName({format:t,doc:e}),format:t,type:this.type}}}getErrorDetails(t){var e;return null===(e=this.getLoader(t))||void 0===e?void 0:e.getSyntaxErrorDetails()}fileName(t){}load(t,e){return this.initLoaders(),this.docFormats.reduce(((r,s)=>{if(r||e&&e!==s)return r;try{const e=this.getLoader(s).load(t);if(e)return{doc:e,format:s}}catch(t){}}),void 0)}initLoaders(){this.loaders.clear(),this.docFormats.forEach((t=>this.loaders.set(t,this.loaderFactory.getLoader(t))))}getLoader(t){return this.loaders.get(t)}}class u extends l{constructor(){super(),this.SUPPORTED_HAR_VERSION=/^1\.\d+$/}get type(){return"har"}isSupported(t){var e;const r=null===(e=null==t?void 0:t.log)||void 0===e?void 0:e.version;return!("string"!=typeof r||!this.SUPPORTED_HAR_VERSION.test(r.trim())||!Array.isArray(t.log.entries))}}class p extends l{constructor(){super()}fileName({doc:t,format:e}){var r;if("string"==typeof(null===(r=null==t?void 0:t.info)||void 0===r?void 0:r.title)&&"string"==typeof t.info.version)return`${[t.info.title,t.info.version].map((t=>t.trim())).join(" ")}.${e}`}}class h extends p{constructor(){super(),this.SUPPORTED_SWAGGER_VERSION="2.0"}get type(){return"oasv2"}isSupported(t){const e=null==t?void 0:t.swagger;return"string"==typeof e&&e.trim()===this.SUPPORTED_SWAGGER_VERSION}}class d extends p{constructor(){super(),this.SUPPORTED_OPENAPI_VERSION=/^3\.0\.\d+$/}get type(){return"oasv3"}isSupported(t){const e=null==t?void 0:t.openapi;return"string"==typeof e&&this.SUPPORTED_OPENAPI_VERSION.test(e.trim())}}class m extends l{constructor(){super(),this.POSTMAN_SCHEMAS=new Set(["https://schema.getpostman.com/json/collection/v2.0.0/collection.json","https://schema.getpostman.com/json/collection/v2.1.0/collection.json"])}get type(){return"postman"}isSupported(t){var e;const r=null===(e=null==t?void 0:t.info)||void 0===e?void 0:e.schema;return"string"==typeof r&&this.POSTMAN_SCHEMAS.has(r.trim().toLowerCase())}fileName({doc:t,format:e}){var r;return"string"==typeof(null===(r=null==t?void 0:t.info)||void 0===r?void 0:r.name)?`${t.info.name.trim()}.${e}`:void 0}}const f=void 0!==global.window?global.window.URL:require("url").URL,g=t=>t.replace(/\/$/,""),O=t=>t.replace(/^\//,""),E=t=>{const e=new f(t);if(!S(e))throw new TypeError(`Invalid URL: ${e}`);return e},S=t=>{let e;try{e="string"==typeof t?E(t):t}catch{}return!!(e&&e.hostname&&e.origin&&"null"!==e.origin)},v=t=>{const e=E((t=>(!/^\/{2}/.test(t)&&/^\.+\//.test(t)||(t=t.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,"https://")),t))(t));try{e.pathname=(r=e.pathname,g(r.replace(/((?!:).|^)\/{2,}/g,((t,e)=>/^(?!\/)/g.test(e)?`${e}/`:"/"))))}catch{}var r;e.searchParams.sort(),e.hostname=e.hostname.replace(/\.$/,"");let s=e.toString();return"/"===e.pathname&&""===e.hash&&(s=g(s)),s};class y{constructor(t=[new u,new d,new m,new h]){this.importers=t}async import(t,e){let r;try{const s=this.importers.map((r=>r.import(t,e)));r=await((t,e)=>{const r=t.map((t=>new Promise(((r,s)=>t.then((t=>!!e(t)&&r(t)),s)))));return r.push(Promise.all(t).then((()=>{}))),Promise.race(r)})(s,(t=>!!t))}catch{}return r}}export{u as HARImporter,h as OASV2Importer,d as OASV3Importer,m as PostmanImporter,y as SpecImporter,v as normalizeUrl,E as parseUrl,O as removeLeadingSlash,g as removeTrailingSlash,S as validateUrl};
//# sourceMappingURL=bundle.esm5.js.map

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("js-yaml"),require("openapi-types")):"function"==typeof define&&define.amd?define(["exports","js-yaml","openapi-types"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@har-sdk/core"]={},t.jsYaml,t.openapiTypes)}(this,(function(t,e,r){class s{constructor(t){this.syntaxErrorDetailsExtractor=t}load(t){this.source=t,this.error=void 0;try{return this.parse()}catch(t){throw t instanceof Error&&(this.error=t),t}}getSyntaxErrorDetails(){return this.error&&(this.isSupportedError(this.error)?this.syntaxErrorDetailsExtractor.extract(this.error,this.source):{message:this.error.message})}}class o{get lineOffsets(){if(!this._lineOffsets){let t=0;this._lineOffsets=[0,...(this.source||"").split("\n").map((e=>t+=e.length+1))]}return this._lineOffsets}extract(t,e){this.source=e,this._lineOffsets=void 0;const r=this.extractMessage(t),s=this.extractOffset(t),o=this.extractSnippet(t);return{message:r,...void 0!==s?{offset:s}:{},...void 0!==o?{snippet:o}:{}}}extractSnippet(t){}extractMessage(t){return t.message}calculateOffset(t,e){return t<=this.lineOffsets.length?this.lineOffsets[t-1]+e-1:this.source.length}}class n extends o{constructor(){super(...arguments),this.LOCATION_PATTERNS=[{pattern:/at position (\d+)$/,positionExtractor:([,t])=>+t},{pattern:/at line (\d+) column (\d+)/,positionExtractor:([,t,e])=>({lineNumber:+t,columnNumber:+e})}]}extractOffset(t){const e="lineNumber"in t&&"columnNumber"in t?t:this.extractByLocationPatterns(t.message);return"number"==typeof e?e:e&&this.calculateOffset(e.lineNumber,e.columnNumber)}extractMessage(t){return t.message.replace(/^JSON.parse: /,"").replace(/ at line \d+ column \d+ of the JSON data$/,"").replace(/ at position \d+$/,"")}extractByLocationPatterns(t){for(let e=0;e<this.LOCATION_PATTERNS.length;++e){const r=this.LOCATION_PATTERNS[e],s=t.match(r.pattern);if(s)return r.positionExtractor(s)}}}class i extends o{constructor(){super(...arguments),this.LOCATION_PATTERN=/\((\d+):(\d+)\)$/}extractMessage(t){const[e]=t.message.split("\n");return e.replace(/^YAMLException: /,"").replace(this.LOCATION_PATTERN,"").trim()}extractOffset(t){const[e]=t.message.split("\n"),r=e.match(this.LOCATION_PATTERN);return r?this.calculateOffset(+r[1],+r[2]):void 0}extractSnippet(t){return t.message.split("\n").slice(2).join("\n")}}class a extends s{constructor(){super(new n)}parse(){return JSON.parse(this.source)}isSupportedError(t){return t instanceof SyntaxError}}class c extends s{constructor(){super(new i)}parse(){return e.load(this.source,{json:!0})}isSupportedError(t){return t instanceof e.YAMLException}}class l{getLoader(t){switch(t){case"json":return new a;case"yaml":return new c}}}class p{constructor(){this.docFormats=["json","yaml"],this.loaderFactory=new l,this.loaders=new Map}async import(t,e){const r=this.load(t.trim(),e);if(r&&this.isSupported(r.doc)){const{format:t,doc:e}=r;return{doc:e,name:this.fileName({format:t,doc:e}),format:t,type:this.type}}}getErrorDetails(t){var e;return null===(e=this.getLoader(t))||void 0===e?void 0:e.getSyntaxErrorDetails()}fileName(t){}load(t,e){return this.initLoaders(),this.docFormats.reduce(((r,s)=>{if(r||e&&e!==s)return r;try{const e=this.getLoader(s).load(t);if(e)return{doc:e,format:s}}catch(t){}}),void 0)}initLoaders(){this.loaders.clear(),this.docFormats.forEach((t=>this.loaders.set(t,this.loaderFactory.getLoader(t))))}getLoader(t){return this.loaders.get(t)}}class u extends p{constructor(){super(),this.SUPPORTED_HAR_VERSION=/^1\.\d+$/}get type(){return"har"}isSupported(t){var e;const r=null===(e=null==t?void 0:t.log)||void 0===e?void 0:e.version;return!("string"!=typeof r||!this.SUPPORTED_HAR_VERSION.test(r.trim())||!Array.isArray(t.log.entries))}}class h extends p{constructor(){super()}fileName({doc:t,format:e}){var r;if("string"==typeof(null===(r=null==t?void 0:t.info)||void 0===r?void 0:r.title)&&"string"==typeof t.info.version)return`${[t.info.title,t.info.version].map((t=>t.trim())).join(" ")}.${e}`}}class d extends h{constructor(){super(),this.SUPPORTED_SWAGGER_VERSION="2.0"}get type(){return"oasv2"}isSupported(t){const e=null==t?void 0:t.swagger;return"string"==typeof e&&e.trim()===this.SUPPORTED_SWAGGER_VERSION}}class m extends h{constructor(){super(),this.SUPPORTED_OPENAPI_VERSION=/^3\.0\.\d+$/}get type(){return"oasv3"}isSupported(t){const e=null==t?void 0:t.openapi;return"string"==typeof e&&this.SUPPORTED_OPENAPI_VERSION.test(e.trim())}}class f extends p{constructor(){super(),this.POSTMAN_SCHEMAS=new Set(["https://schema.getpostman.com/json/collection/v2.0.0/collection.json","https://schema.getpostman.com/json/collection/v2.1.0/collection.json"])}get type(){return"postman"}isSupported(t){var e;const r=null===(e=null==t?void 0:t.info)||void 0===e?void 0:e.schema;return"string"==typeof r&&this.POSTMAN_SCHEMAS.has(r.trim().toLowerCase())}fileName({doc:t,format:e}){var r;return"string"==typeof(null===(r=null==t?void 0:t.info)||void 0===r?void 0:r.name)?`${t.info.name.trim()}.${e}`:void 0}}const g=void 0!==global.window?global.window.URL:require("url").URL,O=t=>t.replace(/\/$/,""),y=t=>{const e=new g(t);if(!S(e))throw new TypeError(`Invalid URL: ${e}`);return e},S=t=>{let e;try{e="string"==typeof t?y(t):t}catch{}return!!(e&&e.hostname&&e.origin&&"null"!==e.origin)};t.HARImporter=u,t.OASV2Importer=d,t.OASV3Importer=m,t.PostmanImporter=f,t.SpecImporter=class{constructor(t=[new u,new m,new f,new d]){this.importers=t}async import(t,e){let r;try{const s=this.importers.map((r=>r.import(t,e)));r=await((t,e)=>{const r=t.map((t=>new Promise(((r,s)=>t.then((t=>!!e(t)&&r(t)),s)))));return r.push(Promise.all(t).then((()=>{}))),Promise.race(r)})(s,(t=>!!t))}catch{}return r}},t.normalizeUrl=t=>{const e=y((t=>(!/^\/{2}/.test(t)&&/^\.+\//.test(t)||(t=t.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,"https://")),t))(t));try{e.pathname=(r=e.pathname,decodeURI(O(r.replace(/((?!:).|^)\/{2,}/g,((t,e)=>/^(?!\/)/g.test(e)?`${e}/`:"/")))))}catch{}var r;e.searchParams.sort(),e.hostname=e.hostname.replace(/\.$/,"");let s=e.toString();return"/"===e.pathname&&""===e.hash&&(s=O(s)),s},t.parseUrl=y,t.removeLeadingSlash=t=>t.replace(/^\//,""),t.removeTrailingSlash=O,t.validateUrl=S,Object.keys(r).forEach((function(e){"default"===e||t.hasOwnProperty(e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})}))}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("js-yaml"),require("openapi-types")):"function"==typeof define&&define.amd?define(["exports","js-yaml","openapi-types"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@har-sdk/core"]={},t.jsYaml,t.openapiTypes)}(this,(function(t,e,r){class s{constructor(t){this.syntaxErrorDetailsExtractor=t}load(t){this.source=t,this.error=void 0;try{return this.parse()}catch(t){throw t instanceof Error&&(this.error=t),t}}getSyntaxErrorDetails(){return this.error&&(this.isSupportedError(this.error)?this.syntaxErrorDetailsExtractor.extract(this.error,this.source):{message:this.error.message})}}class o{get lineOffsets(){if(!this._lineOffsets){let t=0;this._lineOffsets=[0,...(this.source||"").split("\n").map((e=>t+=e.length+1))]}return this._lineOffsets}extract(t,e){this.source=e,this._lineOffsets=void 0;const r=this.extractMessage(t),s=this.extractOffset(t),o=this.extractSnippet(t);return{message:r,...void 0!==s?{offset:s}:{},...void 0!==o?{snippet:o}:{}}}extractSnippet(t){}extractMessage(t){return t.message}calculateOffset(t,e){return t<=this.lineOffsets.length?this.lineOffsets[t-1]+e-1:this.source.length}}class n extends o{constructor(){super(...arguments),this.LOCATION_PATTERNS=[{pattern:/at position (\d+)$/,positionExtractor:([,t])=>+t},{pattern:/at line (\d+) column (\d+)/,positionExtractor:([,t,e])=>({lineNumber:+t,columnNumber:+e})}]}extractOffset(t){const e="lineNumber"in t&&"columnNumber"in t?t:this.extractByLocationPatterns(t.message);return"number"==typeof e?e:e&&this.calculateOffset(e.lineNumber,e.columnNumber)}extractMessage(t){return t.message.replace(/^JSON.parse: /,"").replace(/ at line \d+ column \d+ of the JSON data$/,"").replace(/ at position \d+$/,"")}extractByLocationPatterns(t){for(let e=0;e<this.LOCATION_PATTERNS.length;++e){const r=this.LOCATION_PATTERNS[e],s=t.match(r.pattern);if(s)return r.positionExtractor(s)}}}class i extends o{constructor(){super(...arguments),this.LOCATION_PATTERN=/\((\d+):(\d+)\)$/}extractMessage(t){const[e]=t.message.split("\n");return e.replace(/^YAMLException: /,"").replace(this.LOCATION_PATTERN,"").trim()}extractOffset(t){const[e]=t.message.split("\n"),r=e.match(this.LOCATION_PATTERN);return r?this.calculateOffset(+r[1],+r[2]):void 0}extractSnippet(t){return t.message.split("\n").slice(2).join("\n")}}class a extends s{constructor(){super(new n)}parse(){return JSON.parse(this.source)}isSupportedError(t){return t instanceof SyntaxError}}class c extends s{constructor(){super(new i)}parse(){return e.load(this.source,{json:!0})}isSupportedError(t){return t instanceof e.YAMLException}}class l{getLoader(t){switch(t){case"json":return new a;case"yaml":return new c}}}class p{constructor(){this.docFormats=["json","yaml"],this.loaderFactory=new l,this.loaders=new Map}async import(t,e){const r=this.load(t.trim(),e);if(r&&this.isSupported(r.doc)){const{format:t,doc:e}=r;return{doc:e,name:this.fileName({format:t,doc:e}),format:t,type:this.type}}}getErrorDetails(t){var e;return null===(e=this.getLoader(t))||void 0===e?void 0:e.getSyntaxErrorDetails()}fileName(t){}load(t,e){return this.initLoaders(),this.docFormats.reduce(((r,s)=>{if(r||e&&e!==s)return r;try{const e=this.getLoader(s).load(t);if(e)return{doc:e,format:s}}catch(t){}}),void 0)}initLoaders(){this.loaders.clear(),this.docFormats.forEach((t=>this.loaders.set(t,this.loaderFactory.getLoader(t))))}getLoader(t){return this.loaders.get(t)}}class u extends p{constructor(){super(),this.SUPPORTED_HAR_VERSION=/^1\.\d+$/}get type(){return"har"}isSupported(t){var e;const r=null===(e=null==t?void 0:t.log)||void 0===e?void 0:e.version;return!("string"!=typeof r||!this.SUPPORTED_HAR_VERSION.test(r.trim())||!Array.isArray(t.log.entries))}}class h extends p{constructor(){super()}fileName({doc:t,format:e}){var r;if("string"==typeof(null===(r=null==t?void 0:t.info)||void 0===r?void 0:r.title)&&"string"==typeof t.info.version)return`${[t.info.title,t.info.version].map((t=>t.trim())).join(" ")}.${e}`}}class d extends h{constructor(){super(),this.SUPPORTED_SWAGGER_VERSION="2.0"}get type(){return"oasv2"}isSupported(t){const e=null==t?void 0:t.swagger;return"string"==typeof e&&e.trim()===this.SUPPORTED_SWAGGER_VERSION}}class m extends h{constructor(){super(),this.SUPPORTED_OPENAPI_VERSION=/^3\.0\.\d+$/}get type(){return"oasv3"}isSupported(t){const e=null==t?void 0:t.openapi;return"string"==typeof e&&this.SUPPORTED_OPENAPI_VERSION.test(e.trim())}}class f extends p{constructor(){super(),this.POSTMAN_SCHEMAS=new Set(["https://schema.getpostman.com/json/collection/v2.0.0/collection.json","https://schema.getpostman.com/json/collection/v2.1.0/collection.json"])}get type(){return"postman"}isSupported(t){var e;const r=null===(e=null==t?void 0:t.info)||void 0===e?void 0:e.schema;return"string"==typeof r&&this.POSTMAN_SCHEMAS.has(r.trim().toLowerCase())}fileName({doc:t,format:e}){var r;return"string"==typeof(null===(r=null==t?void 0:t.info)||void 0===r?void 0:r.name)?`${t.info.name.trim()}.${e}`:void 0}}const g=void 0!==global.window?global.window.URL:require("url").URL,O=t=>t.replace(/\/$/,""),y=t=>{const e=new g(t);if(!S(e))throw new TypeError(`Invalid URL: ${e}`);return e},S=t=>{let e;try{e="string"==typeof t?y(t):t}catch{}return!!(e&&e.hostname&&e.origin&&"null"!==e.origin)};t.HARImporter=u,t.OASV2Importer=d,t.OASV3Importer=m,t.PostmanImporter=f,t.SpecImporter=class{constructor(t=[new u,new m,new f,new d]){this.importers=t}async import(t,e){let r;try{const s=this.importers.map((r=>r.import(t,e)));r=await((t,e)=>{const r=t.map((t=>new Promise(((r,s)=>t.then((t=>!!e(t)&&r(t)),s)))));return r.push(Promise.all(t).then((()=>{}))),Promise.race(r)})(s,(t=>!!t))}catch{}return r}},t.normalizeUrl=t=>{const e=y((t=>(!/^\/{2}/.test(t)&&/^\.+\//.test(t)||(t=t.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,"https://")),t))(t));try{e.pathname=(r=e.pathname,O(r.replace(/((?!:).|^)\/{2,}/g,((t,e)=>/^(?!\/)/g.test(e)?`${e}/`:"/"))))}catch{}var r;e.searchParams.sort(),e.hostname=e.hostname.replace(/\.$/,"");let s=e.toString();return"/"===e.pathname&&""===e.hash&&(s=O(s)),s},t.parseUrl=y,t.removeLeadingSlash=t=>t.replace(/^\//,""),t.removeTrailingSlash=O,t.validateUrl=S,Object.keys(r).forEach((function(e){"default"===e||t.hasOwnProperty(e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})}))}));
//# sourceMappingURL=bundle.umd.js.map

@@ -7,3 +7,3 @@ const URL = typeof global.window !== 'undefined'

export const removeLeadingSlash = (path) => path.replace(/^\//, '');
const normalizePathName = (pathname) => decodeURI(removeTrailingSlash(pathname.replace(/((?!:).|^)\/{2,}/g, (_, p1) => /^(?!\/)/g.test(p1) ? `${p1}/` : '/')));
const normalizePathName = (pathname) => removeTrailingSlash(pathname.replace(/((?!:).|^)\/{2,}/g, (_, p1) => /^(?!\/)/g.test(p1) ? `${p1}/` : '/'));
const DEFAULT_PROTOCOL = 'https';

@@ -10,0 +10,0 @@ const prependProtocolIfNecessary = (url) => {

{
"name": "@har-sdk/core",
"version": "1.4.1",
"version": "1.4.2",
"private": false,

@@ -5,0 +5,0 @@ "description": "The base package can be used to import specification files (i.e. HAR, OAS and Postman Collection) and detect their type.",

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